void QmitkPlotWidget::SetErrorPen(unsigned int curveId, const QPen &pen) { std::get<1>(m_PlotCurveVector[curveId])->setPen(pen); QwtIntervalSymbol *errorBar = new QwtIntervalSymbol(QwtIntervalSymbol::Bar); errorBar->setPen(pen); std::get<1>(m_PlotCurveVector[curveId])->setSymbol(errorBar); std::get<2>(m_PlotCurveVector[curveId])->setPen(pen); errorBar = new QwtIntervalSymbol(QwtIntervalSymbol::Bar); errorBar->setPen(pen); std::get<2>(m_PlotCurveVector[curveId])->setSymbol(errorBar); }
void Plot::setMode( int style ) { if ( style == Tube ) { d_intervalCurve->setStyle( QwtPlotIntervalCurve::Tube ); d_intervalCurve->setSymbol( NULL ); d_intervalCurve->setRenderHint( QwtPlotItem::RenderAntialiased, true ); } else { d_intervalCurve->setStyle( QwtPlotIntervalCurve::NoCurve ); QColor c( d_intervalCurve->brush().color().rgb() ); // skip alpha QwtIntervalSymbol *errorBar = new QwtIntervalSymbol( QwtIntervalSymbol::Bar ); errorBar->setWidth( 8 ); // should be something even errorBar->setPen( c ); d_intervalCurve->setSymbol( errorBar ); d_intervalCurve->setRenderHint( QwtPlotItem::RenderAntialiased, false ); } replot(); }
void QmitkPlotWidget::SetErrorStyleSymbols(unsigned int curveId, bool drawSmybols) { if (drawSmybols) { std::get<1>(m_PlotCurveVector[curveId])->setStyle(QwtPlotIntervalCurve::NoCurve); QwtIntervalSymbol *errorBar = new QwtIntervalSymbol(QwtIntervalSymbol::Bar); errorBar->setPen(std::get<1>(m_PlotCurveVector[curveId])->pen()); std::get<1>(m_PlotCurveVector[curveId])->setSymbol(errorBar); std::get<2>(m_PlotCurveVector[curveId])->setStyle(QwtPlotIntervalCurve::NoCurve); errorBar = new QwtIntervalSymbol(QwtIntervalSymbol::Bar); errorBar->setPen(std::get<2>(m_PlotCurveVector[curveId])->pen()); std::get<2>(m_PlotCurveVector[curveId])->setSymbol(errorBar); } else { std::get<1>(m_PlotCurveVector[curveId])->setStyle(QwtPlotIntervalCurve::Tube); std::get<1>(m_PlotCurveVector[curveId])->setSymbol(nullptr); std::get<2>(m_PlotCurveVector[curveId])->setStyle(QwtPlotIntervalCurve::Tube); std::get<2>(m_PlotCurveVector[curveId])->setSymbol(nullptr); } }
int qfit::plotLinearData() { /* standard data */ data_plot = new QwtPlotCurve("data"); data_plot->setSamples(&xdata.at(0), &ydata.at(0), xdata.size()); data_plot->setSymbol(new QwtSymbol(QwtSymbol::XCross, Qt::NoBrush, QPen(Qt::black), QSize(8, 8))); data_plot->setStyle(QwtPlotCurve::NoCurve); data_plot->setRenderHint(QwtPlotItem::RenderAntialiased); /* error bars */ range_plot = new QwtPlotIntervalCurve("range"); QVector<QwtIntervalSample> range(xdata.size()); for(int i = 0; i < (int)xdata.size(); i++) { range[i] = QwtIntervalSample(xdata.at(i), ydata.at(i) - yerrors.at(i), ydata.at(i) + yerrors.at(i)); } QwtIntervalSymbol *errorbar = new QwtIntervalSymbol(QwtIntervalSymbol::Bar); errorbar->setPen(QPen(Qt::black, 1)); range_plot->setSamples(range); range_plot->setSymbol(errorbar); range_plot->setStyle(QwtPlotIntervalCurve::NoCurve); /* model */ FitTools::LinearFitResult tmp = fit->getLinearResult(); double x[2], y[2]; x[0] = xdata.at(0); x[1] = xdata.back(); y[0] = tmp.m * x[0] + tmp.q; y[1] = tmp.m * x[1] + tmp.q; model_plot = new QwtPlotCurve("y=mx+q"); model_plot->setSamples(x, y, 2); model_plot->setPen(QPen(Qt::red, 1)); model_plot->setRenderHint(QwtPlotItem::RenderAntialiased); data_plot->attach(qwtPlot); range_plot->attach(qwtPlot); model_plot->attach(qwtPlot); return(0); }
bool QmitkPlotWidget::AddErrorIntervalCurve(unsigned int curveId, const DataVector &lessError, const DataVector &moreError, bool isXError) { const QwtSeriesData<QPointF> *curveSeriesData = std::get<0>(this->m_PlotCurveVector[curveId])->data(); size_t size = curveSeriesData->size(); if (size != lessError.size() || size != moreError.size()) { std::cerr << "Sizes of data arrays don't match." << std::endl; return false; } QVector<QwtIntervalSample> samples; QwtIntervalSample *sample; QwtPlotIntervalCurve *curve; if (isXError) { curve = std::get<1>(m_PlotCurveVector[curveId]); } else { curve = std::get<2>(m_PlotCurveVector[curveId]); } for (unsigned int index = 0; index < size; ++index) { qreal xValue = curveSeriesData->sample(index).x(); qreal yValue = curveSeriesData->sample(index).y(); if (isXError) { sample = new QwtIntervalSample(xValue, xValue - lessError[index], xValue + moreError[index]); } else { sample = new QwtIntervalSample(xValue, yValue - lessError[index], yValue + moreError[index]); } samples.push_back(*sample); } curve->setSamples(samples); curve->setStyle(QwtPlotIntervalCurve::NoCurve); QwtIntervalSymbol *errorBar = new QwtIntervalSymbol(QwtIntervalSymbol::Bar); errorBar->setPen(QPen(Qt::black)); curve->setSymbol(errorBar); if (isXError) { curve->setOrientation(Qt::Horizontal); } else { curve->setOrientation(Qt::Vertical); } return true; }