#include <QmitkPlotWidget.h>
|
| QmitkPlotWidget (QWidget *parent=nullptr, const char *title=nullptr, const char *name=nullptr, Qt::WindowFlags f={}) |
|
| ~QmitkPlotWidget () override |
|
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 () |
|
|
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.
- See also
- QmitkPlotDialog
To plot data do the following:
- Create two QmitkPlotWidget::DataVector Objects and fill them with corresponding x/y values. DataVectors are simple stl-vectors of type std::vector<double>. Please note that the xValues vector and the yValues vector MUST have the same size.
- Instantiate the widget for example like that: QmitkPlotWidget* widget = new QmitkPlotWidget( this, "widget" ); widget->SetAxisTitle( QwtPlot::xBottom, "My x asis [mm]" ); widget->SetAxisTitle( QwtPlot::yLeft, "My y axis [mm]" ); int curveId = widget->InsertCurve( "My sophisticated data" ); widget->SetCurveData( curveId, xValues, yValues ); widget->SetCurvePen( curveId, QPen( red ) ); widget->SetCurveTitle( curveId, "My curve description" ); widget->Replot();
- You can modify the behavior of the plot by directly referencing the QwtPlot instance using the method GetPlot().
- See also
- QwtPlot
- Deprecated:
- (as of 2018_04) Use QmitkChartWidget instead
Definition at line 54 of file QmitkPlotWidget.h.
◆ 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 73 of file QmitkPlotWidget.h.
◆ 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 66 of file QmitkPlotWidget.h.
◆ 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 79 of file QmitkPlotWidget.h.
◆ QmitkPlotWidget()
QmitkPlotWidget::QmitkPlotWidget |
( |
QWidget * |
parent = nullptr , |
|
|
const char * |
title = nullptr , |
|
|
const char * |
name = nullptr , |
|
|
Qt::WindowFlags |
f = {} |
|
) |
| |
◆ ~QmitkPlotWidget()
QmitkPlotWidget::~QmitkPlotWidget |
( |
| ) |
|
|
override |
◆ AddErrorIntervalCurve()
bool QmitkPlotWidget::AddErrorIntervalCurve |
( |
unsigned int |
curveId, |
|
|
const DataVector & |
lessError, |
|
|
const DataVector & |
moreError, |
|
|
bool |
isXError |
|
) |
| |
|
protected |
Adds an error interval curve.
All errors should be absolutes. The magnitude will be used.
- Parameters
-
curveId | Which curve should the error curve be added to |
lessError | Error in the negative direction (value - lessError) |
moreError | Error in the positive direction (value + lessError) |
isXError | Should the error bars be drawn horizontally |
◆ Clear()
void QmitkPlotWidget::Clear |
( |
| ) |
|
Resets the plot into an empty state
◆ ConvertToRawArray() [1/2]
double* QmitkPlotWidget::ConvertToRawArray |
( |
const DataVector & |
values | ) |
|
|
protected |
Converts the given values into a raw double* array. A new array is allocated via new and must be deleted[] by the caller.
◆ ConvertToRawArray() [2/2]
double* QmitkPlotWidget::ConvertToRawArray |
( |
const XYDataVector & |
values, |
|
|
unsigned int |
component |
|
) |
| |
|
protected |
Converts the given values into a raw double* array. A new array is allocated via new and must be deleted[] by the caller.
- Parameters
-
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. |
◆ GetPlot()
QwtPlot* QmitkPlotWidget::GetPlot |
( |
| ) |
|
Returns the instance of the plot-widget. This may be used to modify any detail of the appearance of the plot.
◆ InsertCurve()
unsigned int QmitkPlotWidget::InsertCurve |
( |
const char * |
title, |
|
|
QColor |
color = QColor(Qt::black) |
|
) |
| |
Inserts a new curve into the plot-window.
- Parameters
-
title | the name of the curve |
color | |
- Returns
- the id of the curve. Use this id to refer to the curve, if you want to modify or add data.
◆ Replot()
void QmitkPlotWidget::Replot |
( |
| ) |
|
Triggers a replot of the curve. Replot should be called once after setting new data.
◆ SetAxisTitle()
void QmitkPlotWidget::SetAxisTitle |
( |
int |
axis, |
|
|
const char * |
title |
|
) |
| |
Sets the title of the given axis. For the set of available axes
- See also
- QwtPlot::Axis.
- Parameters
-
axis | the axis for which the description should be set. |
title | the name of the axis. |
◆ SetCurveAntialiasingOff()
void QmitkPlotWidget::SetCurveAntialiasingOff |
( |
unsigned int |
curveId | ) |
|
◆ SetCurveAntialiasingOn()
void QmitkPlotWidget::SetCurveAntialiasingOn |
( |
unsigned int |
curveId | ) |
|
◆ SetCurveBrush()
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).
- Parameters
-
curveId | the id of the curve for which appearance should be changed |
brush | a QBrush ( |
- See also
- QBrush) defining the line style
◆ SetCurveData() [1/4]
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.
- Parameters
-
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 |
- Returns
- whether data was added successfully or not
◆ SetCurveData() [2/4]
Sets the data with errors for a previously added curve.
- Parameters
-
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 |
- Returns
- whether data was added successfully or not
◆ SetCurveData() [3/4]
Sets the data with errors for a previously added curve.
- Parameters
-
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 |
- Returns
- whether data was added successfully or not
◆ SetCurveData() [4/4]
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.
- Parameters
-
curveId | the id of the curve for which data should be added. |
data | the coordinates of the points that define the curve |
- Returns
- whether data was added successfully or not
◆ SetCurvePen()
void QmitkPlotWidget::SetCurvePen |
( |
unsigned int |
curveId, |
|
|
const QPen & |
pen |
|
) |
| |
Defines how a curve should be drawn. For drawing a curve, a QPen is used.
- Parameters
-
curveId | the id of the curve for which appearance should be changed |
pen | a QPen ( |
- See also
- QPen) defining the line style
◆ SetCurveStyle()
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;
- Parameters
-
curveId | |
style | A QwtPlotCurve::CurveStyle |
◆ SetCurveSymbol()
void QmitkPlotWidget::SetCurveSymbol |
( |
unsigned int |
curveId, |
|
|
QwtSymbol * |
symbol |
|
) |
| |
Sets the style data points are drawn for the curve; like, a line, or dots;
- Parameters
-
curveId | |
symbol | A QwtSymbol |
◆ SetCurveTitle()
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.
- Parameters
-
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. |
◆ SetErrorPen()
void QmitkPlotWidget::SetErrorPen |
( |
unsigned int |
curveId, |
|
|
const QPen & |
pen |
|
) |
| |
Defines how a curves errors should be drawn. For drawing a QPen is used.
- Parameters
-
curveId | the id of the curve for which error appearance should be changed |
pen | a QPen ( |
- See also
- QPen) defining the line style
◆ SetErrorStyleSymbols()
void QmitkPlotWidget::SetErrorStyleSymbols |
( |
unsigned int |
curveId, |
|
|
bool |
drawSmybols |
|
) |
| |
Defines the style of errors, symbols or as a curve.
- Parameters
-
curveId | the id of the curve for which error appearance should be changed |
drawSmybols | true - draw symbols, false - draw curve |
◆ SetLegend()
void QmitkPlotWidget::SetLegend |
( |
QwtLegend * |
legend, |
|
|
QwtPlot::LegendPosition |
pos = QwtPlot::RightLegend , |
|
|
double |
ratio = -1 |
|
) |
| |
Sets the legend of the plot
◆ SetLegendAttribute()
void QmitkPlotWidget::SetLegendAttribute |
( |
unsigned int |
curveId, |
|
|
const QwtPlotCurve::LegendAttribute & |
attribute |
|
) |
| |
Set a curve's legend attribute
- Parameters
-
curveId | the id of the curve |
attribute | the legend attribute to be set |
◆ SetPlotTitle() [1/2]
void QmitkPlotWidget::SetPlotTitle |
( |
const char * |
title | ) |
|
Set plain text title, using default formatting
◆ SetPlotTitle() [2/2]
void QmitkPlotWidget::SetPlotTitle |
( |
const QwtText & |
qwt_title | ) |
|
Set the title using (formatted) QwtText object
◆ m_Plot
QwtPlot* QmitkPlotWidget::m_Plot |
|
protected |
◆ m_PlotCurveVector
std::vector<std::tuple<QwtPlotCurve *, QwtPlotIntervalCurve *, QwtPlotIntervalCurve *> > QmitkPlotWidget::m_PlotCurveVector |
|
protected |
The documentation for this class was generated from the following file: