MCPcopy Create free account
hub / github.com/MITK/MITK / AddErrorIntervalCurve

Method AddErrorIntervalCurve

Modules/QtWidgetsExt/src/QmitkPlotWidget.cpp:261–321  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

259}
260
261bool QmitkPlotWidget::AddErrorIntervalCurve(unsigned int curveId,
262 const DataVector &lessError,
263 const DataVector &moreError,
264 bool isXError)
265{
266 const QwtSeriesData<QPointF> *curveSeriesData = std::get<0>(this->m_PlotCurveVector[curveId])->data();
267
268 size_t size = curveSeriesData->size();
269
270 if (size != lessError.size() || size != moreError.size())
271 {
272 std::cerr << "Sizes of data arrays don't match." << std::endl;
273 return false;
274 }
275
276 QVector<QwtIntervalSample> samples;
277 QwtIntervalSample *sample;
278 QwtPlotIntervalCurve *curve;
279
280 if (isXError)
281 {
282 curve = std::get<1>(m_PlotCurveVector[curveId]);
283 }
284 else
285 {
286 curve = std::get<2>(m_PlotCurveVector[curveId]);
287 }
288
289 for (unsigned int index = 0; index < size; ++index)
290 {
291 qreal xValue = curveSeriesData->sample(index).x();
292 qreal yValue = curveSeriesData->sample(index).y();
293 if (isXError)
294 {
295 sample = new QwtIntervalSample(xValue, xValue - lessError[index], xValue + moreError[index]);
296 }
297 else
298 {
299 sample = new QwtIntervalSample(xValue, yValue - lessError[index], yValue + moreError[index]);
300 }
301 samples.push_back(*sample);
302 }
303
304 curve->setSamples(samples);
305 curve->setStyle(QwtPlotIntervalCurve::NoCurve);
306
307 QwtIntervalSymbol *errorBar = new QwtIntervalSymbol(QwtIntervalSymbol::Bar);
308 errorBar->setPen(QPen(Qt::black));
309 curve->setSymbol(errorBar);
310
311 if (isXError)
312 {
313 curve->setOrientation(Qt::Horizontal);
314 }
315 else
316 {
317 curve->setOrientation(Qt::Vertical);
318 }

Callers 1

SetCurveDataMethod · 0.95

Calls 3

dataMethod · 0.45
sizeMethod · 0.45
sampleMethod · 0.45

Tested by

no test coverage detected