Medical Imaging Interaction Toolkit
2016.11.0
Medical Imaging Interaction Toolkit
|
#include <QmitkPlotWidget.h>
Public Types | |
typedef double | ScalarType |
typedef std::vector< ScalarType > | DataVector |
typedef std::vector< std::pair< double, double > > | XYDataVector |
Public Member Functions | |
QmitkPlotWidget (QWidget *parent=nullptr, const char *title=nullptr, const char *name=nullptr, Qt::WindowFlags f=nullptr) | |
virtual | ~QmitkPlotWidget () |
QwtPlot * | GetPlot () |
void | SetPlotTitle (const QwtText &qwt_title) |
void | SetPlotTitle (const char *title) |
unsigned int | InsertCurve (const char *title, QColor color=QColor(Qt::black)) |
void | SetAxisTitle (int axis, const char *title) |
bool | SetCurveData (unsigned int curveId, const DataVector &xValues, const DataVector &yValues) |
bool | SetCurveData (unsigned int curveId, const DataVector &xValues, const DataVector &yValues, const DataVector &yLowerError, const DataVector &yUpperError) |
Sets the data with errors for a previously added curve. More... | |
bool | SetCurveData (unsigned int curveId, const DataVector &xValues, const DataVector &yValues, const DataVector &xLowerError, const DataVector &xUpperError, const DataVector &yLowerError, const DataVector &yUpperError) |
Sets the data with errors for a previously added curve. More... | |
bool | SetCurveData (unsigned int curveId, const XYDataVector &data) |
void | SetCurvePen (unsigned int curveId, const QPen &pen) |
void | SetCurveBrush (unsigned int curveId, const QBrush &brush) |
void | SetCurveStyle (unsigned int curveId, const QwtPlotCurve::CurveStyle style) |
void | SetCurveSymbol (unsigned int curveId, QwtSymbol *symbol) |
void | SetCurveAntialiasingOn (unsigned int curveId) |
void | SetCurveAntialiasingOff (unsigned int curveId) |
void | SetCurveTitle (unsigned int curveId, const char *title) |
void | SetErrorPen (unsigned int curveId, const QPen &pen) |
void | SetErrorStyleSymbols (unsigned int curveId, bool drawSmybols) |
void | SetLegend (QwtLegend *legend, QwtPlot::LegendPosition pos=QwtPlot::RightLegend, double ratio=-1) |
void | SetLegendAttribute (unsigned int curveId, const QwtPlotCurve::LegendAttribute &attribute) |
void | Replot () |
void | Clear () |
Protected Member Functions | |
double * | ConvertToRawArray (const DataVector &values) |
double * | ConvertToRawArray (const XYDataVector &values, unsigned int component) |
bool | AddErrorIntervalCurve (unsigned int curveId, const DataVector &lessError, const DataVector &moreError, bool isXError) |
Protected Attributes | |
QwtPlot * | m_Plot |
std::vector< std::tuple< QwtPlotCurve *, QwtPlotIntervalCurve *, QwtPlotIntervalCurve * > > | m_PlotCurveVector |
Provides a convenient interface for plotting curves using qwt. Designed for qwt version 5.2.1. Can be used with a QmitkPlotDialog, which provides a "Close" button.
To plot data do the following:
Definition at line 56 of file QmitkPlotWidget.h.
typedef std::vector<ScalarType> QmitkPlotWidget::DataVector |
This type may be used to store a set of scalar values representing either x or y coordinates of the data points that should be rendered.
Definition at line 74 of file QmitkPlotWidget.h.
typedef double QmitkPlotWidget::ScalarType |
represents the data type used for scalar values stored in data arrays. This type is provided by qwt and may not be changed.
Definition at line 67 of file QmitkPlotWidget.h.
typedef std::vector<std::pair<double, double> > QmitkPlotWidget::XYDataVector |
convenience type used to store pairs representing x/y coordinates that should be rendered as a curve by the plot widget
Definition at line 80 of file QmitkPlotWidget.h.
QmitkPlotWidget::QmitkPlotWidget | ( | QWidget * | parent = nullptr , |
const char * | title = nullptr , |
||
const char * | name = nullptr , |
||
Qt::WindowFlags | f = nullptr |
||
) |
|
virtual |
Virtual destructor
Definition at line 34 of file QmitkPlotWidget.cpp.
|
protected |
Adds an error interval curve.
All errors should be absolutes. The magnitude will be used.
curveId | Which curve should the error curve be added to |
xValues | Vector of x values an error bar belongs to |
values | The original data value |
lessError | Error in the negative direction (value - lessError) |
moreError | Error in the positive direction (value + lessError) |
isXError | Should the error bars be drawn horizontally |
Definition at line 265 of file QmitkPlotWidget.cpp.
References m_PlotCurveVector.
Referenced by SetCurveData().
void QmitkPlotWidget::Clear | ( | ) |
Resets the plot into an empty state
Definition at line 230 of file QmitkPlotWidget.cpp.
References m_Plot, and m_PlotCurveVector.
Referenced by QmitkTbssRoiAnalysisWidget::CalculateGroupProfilesFibers(), QmitkResidualAnalysisWidget::DrawMeans(), QmitkResidualAnalysisWidget::DrawPercentagesOfOutliers(), QmitkTbssRoiAnalysisWidget::Plot(), QmitkTbssRoiAnalysisWidget::PlotFiberBundles(), QmitkKurtosisWidget::SetData(), QmitkODFDetailsWidget::SetParameters(), QmitkIVIMWidget::SetParameters(), QmitkPartialVolumeAnalysisWidget::SetParameters(), and ~QmitkPlotWidget().
|
protected |
Converts the given values into a raw double* array. A new array is allocated via new and must be deleted[] by the caller.
Definition at line 237 of file QmitkPlotWidget.cpp.
Referenced by SetCurveData().
|
protected |
Converts the given values into a raw double* array. A new array is allocated via new and must be deleted[] by the caller.
values | the x/y values to convert to an array |
component | defines if the x values (0) or the y values(1) should be converted. Other values than 0 and 1 will not be accepted. |
Definition at line 245 of file QmitkPlotWidget.cpp.
QwtPlot * QmitkPlotWidget::GetPlot | ( | ) |
Returns the instance of the plot-widget. This may be used to modify any detail of the appearance of the plot.
Definition at line 40 of file QmitkPlotWidget.cpp.
References m_Plot.
Referenced by QmitkPlotDialog::GetQwtPlot().
unsigned int QmitkPlotWidget::InsertCurve | ( | const char * | title, |
QColor | color = QColor(Qt::black) |
||
) |
Inserts a new curve into the plot-window.
title | the name of the curve |
Definition at line 55 of file QmitkPlotWidget.cpp.
References m_Plot, and m_PlotCurveVector.
Referenced by QmitkResidualAnalysisWidget::DrawMeans(), QmitkResidualAnalysisWidget::DrawPercentagesOfOutliers(), QmitkTbssRoiAnalysisWidget::Plot(), QmitkTbssRoiAnalysisWidget::PlotFiberBundles(), QmitkKurtosisWidget::SetData(), QmitkODFDetailsWidget::SetParameters(), QmitkIVIMWidget::SetParameters(), and QmitkPartialVolumeAnalysisWidget::SetParameters().
void QmitkPlotWidget::Replot | ( | ) |
Triggers a replot of the curve. Replot should be called once after setting new data.
Definition at line 225 of file QmitkPlotWidget.cpp.
References m_Plot.
Referenced by QmitkTbssRoiAnalysisWidget::drawBar(), QmitkResidualAnalysisWidget::DrawMeans(), QmitkResidualAnalysisWidget::DrawPercentagesOfOutliers(), QmitkTbssRoiAnalysisWidget::Plot(), QmitkTbssRoiAnalysisWidget::PlotFiberBundles(), QmitkKurtosisWidget::SetData(), QmitkODFDetailsWidget::SetParameters(), QmitkIVIMWidget::SetParameters(), and QmitkPartialVolumeAnalysisWidget::SetParameters().
void QmitkPlotWidget::SetAxisTitle | ( | int | axis, |
const char * | title | ||
) |
Sets the title of the given axis. For the set of available axes
axis | the axis for which the description should be set. |
title | the name of the axis. |
Definition at line 90 of file QmitkPlotWidget.cpp.
References m_Plot.
void QmitkPlotWidget::SetCurveAntialiasingOff | ( | unsigned int | curveId | ) |
Definition at line 186 of file QmitkPlotWidget.cpp.
References m_PlotCurveVector.
void QmitkPlotWidget::SetCurveAntialiasingOn | ( | unsigned int | curveId | ) |
Definition at line 181 of file QmitkPlotWidget.cpp.
References m_PlotCurveVector.
Referenced by QmitkKurtosisWidget::SetData(), QmitkIVIMWidget::SetParameters(), and QmitkPartialVolumeAnalysisWidget::SetParameters().
void QmitkPlotWidget::SetCurveBrush | ( | unsigned int | curveId, |
const QBrush & | brush | ||
) |
Assign a brush, which defines the fill pattern of shapes drawn by a QPainter. In case of brush.style() != QBrush::NoBrush and * style() != QwtPlotCurve::Sticks the area between the curve and the baseline will be filled. In case !brush.color().isValid() the area will be filled by pen.color(). The fill algorithm simply connects the first and the last curve point to the baseline. So the curve data has to be sorted (ascending or descending).
curveId | the id of the curve for which appearance should be changed |
brush | a QBrush ( |
Definition at line 159 of file QmitkPlotWidget.cpp.
References m_PlotCurveVector.
Referenced by QmitkPartialVolumeAnalysisWidget::SetParameters().
bool QmitkPlotWidget::SetCurveData | ( | unsigned int | curveId, |
const DataVector & | xValues, | ||
const DataVector & | yValues | ||
) |
Sets the data for a previously added curve. Data is provided as two vectors of double. The first vector represents the x coordinates, the second vector represents the y coordinates.
curveId | the id of the curve for which data should be added. |
xValues | the x coordinates of the points that define the curve |
yValues | the y coordinates of the points that define the curve |
Definition at line 95 of file QmitkPlotWidget.cpp.
References ConvertToRawArray(), and m_PlotCurveVector.
Referenced by QmitkResidualAnalysisWidget::DrawMeans(), QmitkResidualAnalysisWidget::DrawPercentagesOfOutliers(), QmitkTbssRoiAnalysisWidget::Plot(), QmitkTbssRoiAnalysisWidget::PlotFiberBundles(), SetCurveData(), QmitkKurtosisWidget::SetData(), QmitkODFDetailsWidget::SetParameters(), QmitkIVIMWidget::SetParameters(), and QmitkPartialVolumeAnalysisWidget::SetParameters().
bool QmitkPlotWidget::SetCurveData | ( | unsigned int | curveId, |
const DataVector & | xValues, | ||
const DataVector & | yValues, | ||
const DataVector & | yLowerError, | ||
const DataVector & | yUpperError | ||
) |
Sets the data with errors for a previously added curve.
curveId | the id of the curve for which data should be added. |
xValues | the x coordinates of the points that define the curve |
yValues | the y coordinates of the points that define the curve |
yLowerError | the magnitude (>0) of the error in the lesser direction of y |
yUpperError | the magnitude (>0) of the error in the larger direction of y |
Definition at line 113 of file QmitkPlotWidget.cpp.
References AddErrorIntervalCurve(), and SetCurveData().
bool QmitkPlotWidget::SetCurveData | ( | unsigned int | curveId, |
const DataVector & | xValues, | ||
const DataVector & | yValues, | ||
const DataVector & | xLowerError, | ||
const DataVector & | xUpperError, | ||
const DataVector & | yLowerError, | ||
const DataVector & | yUpperError | ||
) |
Sets the data with errors for a previously added curve.
curveId | the id of the curve for which data should be added. |
xValues | the x coordinates of the points that define the curve |
yValues | the y coordinates of the points that define the curve |
xLowerError | the magnitude (>0) of the error in the lesser direction of x |
xUpperError | the magnitude (>0) of the error in the larger direction of x |
yLowerError | the magnitude (>0) of the error in the lesser direction of y |
yUpperError | the magnitude (>0) of the error in the larger direction of y |
Definition at line 126 of file QmitkPlotWidget.cpp.
References AddErrorIntervalCurve(), and SetCurveData().
bool QmitkPlotWidget::SetCurveData | ( | unsigned int | curveId, |
const XYDataVector & | data | ||
) |
Sets the data for a previously added curve. Data is provided as a vectors of pairs. The pairs represent x/y coordinates of the points that define the curve.
curveId | the id of the curve for which data should be added. |
data | the coordinates of the points that define the curve |
Definition at line 142 of file QmitkPlotWidget.cpp.
References ConvertToRawArray(), and m_PlotCurveVector.
void QmitkPlotWidget::SetCurvePen | ( | unsigned int | curveId, |
const QPen & | pen | ||
) |
Defines how a curve should be drawn. For drawing a curve, a QPen is used.
curveId | the id of the curve for which appearance should be changed |
pen | a QPen ( |
Definition at line 153 of file QmitkPlotWidget.cpp.
References m_PlotCurveVector.
Referenced by QmitkResidualAnalysisWidget::DrawMeans(), QmitkResidualAnalysisWidget::DrawPercentagesOfOutliers(), QmitkTbssRoiAnalysisWidget::Plot(), QmitkTbssRoiAnalysisWidget::PlotFiberBundles(), QmitkKurtosisWidget::SetData(), QmitkODFDetailsWidget::SetParameters(), QmitkIVIMWidget::SetParameters(), and QmitkPartialVolumeAnalysisWidget::SetParameters().
void QmitkPlotWidget::SetCurveStyle | ( | unsigned int | curveId, |
const QwtPlotCurve::CurveStyle | style | ||
) |
Sets the style how the line is drawn for the curve; like, plain line, or with the data points marked with a symbol;
Definition at line 170 of file QmitkPlotWidget.cpp.
References m_PlotCurveVector.
Referenced by QmitkResidualAnalysisWidget::DrawMeans().
void QmitkPlotWidget::SetCurveSymbol | ( | unsigned int | curveId, |
QwtSymbol * | symbol | ||
) |
Sets the style data points are drawn for the curve; like, a line, or dots;
Definition at line 175 of file QmitkPlotWidget.cpp.
References m_PlotCurveVector.
Referenced by QmitkKurtosisWidget::SetData(), and QmitkIVIMWidget::SetParameters().
void QmitkPlotWidget::SetCurveTitle | ( | unsigned int | curveId, |
const char * | title | ||
) |
Sets the title of the given curve. The title will be shown in the legend of the QwtPlot.
curveId | the id of the curve for which the title should be set |
title | the description of the curve that will be shown in the legend. |
Definition at line 165 of file QmitkPlotWidget.cpp.
References m_Plot.
void QmitkPlotWidget::SetErrorPen | ( | unsigned int | curveId, |
const QPen & | pen | ||
) |
Defines how a curves errors should be drawn. For drawing a QPen is used.
curveId | the id of the curve for which error appearance should be changed |
pen | a QPen ( |
Definition at line 191 of file QmitkPlotWidget.cpp.
References m_PlotCurveVector.
void QmitkPlotWidget::SetErrorStyleSymbols | ( | unsigned int | curveId, |
bool | drawSmybols | ||
) |
Defines the style of errors, symbols or as a curve.
curveId | the id of the curve for which error appearance should be changed |
drawSmybols | true - draw symbols, false - draw curve |
Definition at line 203 of file QmitkPlotWidget.cpp.
References m_PlotCurveVector.
void QmitkPlotWidget::SetLegend | ( | QwtLegend * | legend, |
QwtPlot::LegendPosition | pos = QwtPlot::RightLegend , |
||
double | ratio = -1 |
||
) |
Sets the legend of the plot
Definition at line 45 of file QmitkPlotWidget.cpp.
References m_Plot.
Referenced by QmitkResidualAnalysisWidget::DrawMeans(), QmitkResidualAnalysisWidget::DrawPercentagesOfOutliers(), and QmitkTbssRoiAnalysisWidget::Plot().
void QmitkPlotWidget::SetLegendAttribute | ( | unsigned int | curveId, |
const QwtPlotCurve::LegendAttribute & | attribute | ||
) |
Set a curve's legend attribute
curveId | the id of the curve |
attribute | the öegend attribute to be set |
Definition at line 50 of file QmitkPlotWidget.cpp.
References m_PlotCurveVector.
void QmitkPlotWidget::SetPlotTitle | ( | const QwtText & | qwt_title | ) |
Set the title using (formatted) QwtText object
Definition at line 79 of file QmitkPlotWidget.cpp.
References m_Plot.
Referenced by QmitkResidualAnalysisWidget::DrawMeans(), QmitkResidualAnalysisWidget::DrawPercentagesOfOutliers(), QmitkTbssRoiAnalysisWidget::Plot(), QmitkTbssRoiAnalysisWidget::PlotFiberBundles(), QmitkPartialVolumeAnalysisWidget::SetParameters(), and SetPlotTitle().
void QmitkPlotWidget::SetPlotTitle | ( | const char * | title | ) |
Set plain text title, using default formatting
Definition at line 84 of file QmitkPlotWidget.cpp.
References SetPlotTitle().
|
protected |
Definition at line 297 of file QmitkPlotWidget.h.
Referenced by Clear(), QmitkTbssRoiAnalysisWidget::drawBar(), QmitkResidualAnalysisWidget::DrawMeans(), QmitkResidualAnalysisWidget::DrawPercentagesOfOutliers(), QmitkResidualAnalysisWidget::GetPlot(), GetPlot(), InsertCurve(), QmitkTbssRoiAnalysisWidget::Plot(), QmitkIVIMWidget::QmitkIVIMWidget(), QmitkKurtosisWidget::QmitkKurtosisWidget(), QmitkODFDetailsWidget::QmitkODFDetailsWidget(), QmitkPartialVolumeAnalysisWidget::QmitkPartialVolumeAnalysisWidget(), QmitkPlotWidget(), QmitkResidualAnalysisWidget::QmitkResidualAnalysisWidget(), QmitkTbssRoiAnalysisWidget::QmitkTbssRoiAnalysisWidget(), Replot(), SetAxisTitle(), SetCurveTitle(), QmitkKurtosisWidget::SetData(), SetLegend(), QmitkODFDetailsWidget::SetParameters(), QmitkIVIMWidget::SetParameters(), QmitkPartialVolumeAnalysisWidget::SetParameters(), SetPlotTitle(), and ~QmitkPlotWidget().
|
protected |
Definition at line 298 of file QmitkPlotWidget.h.
Referenced by AddErrorIntervalCurve(), Clear(), InsertCurve(), SetCurveAntialiasingOff(), SetCurveAntialiasingOn(), SetCurveBrush(), SetCurveData(), SetCurvePen(), SetCurveStyle(), SetCurveSymbol(), SetErrorPen(), SetErrorStyleSymbols(), and SetLegendAttribute().