MCPcopy Create free account
hub / github.com/analogdevicesinc/scopy / autoscale

Method autoscale

gui/src/plotautoscaler.cpp:88–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86}
87
88void PlotAutoscaler::autoscale()
89{
90 for(PlotChannel *plotCh : qAsConst(m_channels)) {
91 auto data = plotCh->curve()->data();
92 for(int i = 0; i < data->size(); i++) {
93
94 if(m_visibleOnly) {
95 double x = data->sample(i).x();
96 if(x < m_visibleXMin || x > m_visibleXMax)
97 continue;
98 }
99
100 qreal sample;
101 if(m_xAxisMode) {
102 sample = data->sample(i).x();
103 } else {
104 sample = data->sample(i).y();
105 }
106 if(m_max < sample)
107 m_max = sample;
108 if(m_min > sample)
109 m_min = sample;
110 }
111 qDebug(CAT_TIMEYAUTOSCALE)
112 << "Autoscaling channel " << plotCh->name() << "to (" << m_min << ", " << m_max << ")";
113 }
114
115 if(m_min > m_max) {
116 m_max = -1000000.0;
117 m_min = 1000000.0;
118 return;
119 }
120
121 double minTolerance = m_tolerance * m_min;
122 double maxTolerance = m_tolerance * m_max;
123
124 Q_EMIT newMin(m_min - minTolerance);
125 Q_EMIT newMax(m_max + maxTolerance);
126
127 m_max = -1000000.0;
128 m_min = 1000000.0;
129}
130
131void PlotAutoscaler::addChannels(PlotChannel *c)
132{

Callers 3

onStopMethod · 0.80
createYAxisMenuMethod · 0.80
onStopMethod · 0.80

Calls 4

sampleMethod · 0.80
dataMethod · 0.45
curveMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected