Skip to content

Commit 4f0fe59

Browse files
committed
DisplayTrace: make all members private
1 parent a810ac5 commit 4f0fe59

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

QtPMbrowser/DisplayTrace.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,16 @@ void DisplayTrace::render(QPainter& painter, RenderArea* display)
120120
}
121121
}
122122

123+
const std::vector<double>& DisplayTrace::x_data() const
124+
{
125+
if (p_xdata) {
126+
return *p_xdata;
127+
}
128+
else {
129+
throw std::runtime_error("trying to acces non-existing x-data");
130+
}
131+
}
132+
123133
std::tuple<double, double> DisplayTrace::getDataMinMax(int pLeft, int pRight) const
124134
{
125135
double min_val, max_val;

QtPMbrowser/DisplayTrace.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class DisplayTrace
5454
void render(QPainter& painter, RenderArea* display);
5555
bool isValid() const { return !m_data.empty(); }
5656
bool has_x_trace() const { return !!p_xdata; }
57+
const std::vector<double>& x_data() const;
5758

5859
/// <summary>
5960
/// Converts a x-y-trace to an y-only trace (the default)
@@ -95,7 +96,7 @@ class DisplayTrace
9596
{
9697
return { y_min, y_max };
9798
};
98-
void getDataMinMax(double& ymin, double& ymax) {
99+
void getDataMinMax(double& ymin, double& ymax) const {
99100
ymin = y_min;
100101
ymax = y_max;
101102
};
@@ -104,8 +105,6 @@ class DisplayTrace
104105
double m_x0{}, m_deltax{}, y_min{}, y_max{};
105106
QString x_unit, y_unit;
106107
std::vector<double> m_data;
107-
public:
108108
std::unique_ptr<std::vector<double> > p_xdata;
109-
110109
};
111110

QtPMbrowser/renderarea.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ void RenderArea::autoScale()
572572
find_min_max(xTrace.data().cbegin(), xTrace.data().cend(), g_x_min, g_x_max);
573573
}
574574
else if (yTrace.has_x_trace()) {
575-
find_min_max(yTrace.p_xdata->cbegin(), yTrace.p_xdata->cend(), g_x_min, g_x_max);
575+
find_min_max(yTrace.x_data().cbegin(), yTrace.x_data().cend(), g_x_min, g_x_max);
576576
}
577577
else
578578
{
@@ -583,7 +583,7 @@ void RenderArea::autoScale()
583583
for(const auto* t: tracebuffer){
584584
if(t->has_x_trace()){
585585
double minx, maxx;
586-
find_min_max(t->p_xdata->cbegin(), t->p_xdata->cend(), minx, maxx);
586+
find_min_max(t->x_data().cbegin(), t->x_data().cend(), minx, maxx);
587587
g_x_min=std::min(g_x_min,minx);
588588
g_x_max=std::max(g_x_max, maxx);
589589
}

0 commit comments

Comments
 (0)