Medical Imaging Interaction Toolkit  2023.04.00
Medical Imaging Interaction Toolkit
QmitkPlotWidget.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef QmitkPlotWidget_h
14 #define QmitkPlotWidget_h
15 
17 #include "mitkCommon.h"
18 #include <qwidget.h>
19 #include <qwt_legend.h>
20 #include <qwt_plot.h>
21 #include <qwt_plot_curve.h>
22 #include <qwt_plot_intervalcurve.h>
23 #include <qwt_symbol.h>
24 #include <qwt_text.h>
25 #include <tuple>
26 #include <vector>
27 
55  : public QWidget
56  {
57 private:
58  Q_OBJECT
59 
60 public:
66  typedef double ScalarType;
67 
73  typedef std::vector<ScalarType> DataVector;
74 
79  typedef std::vector<std::pair<double, double>> XYDataVector;
80 
84  QmitkPlotWidget(QWidget *parent = nullptr,
85  const char *title = nullptr,
86  const char *name = nullptr,
87  Qt::WindowFlags f = nullptr);
88 
92  ~QmitkPlotWidget() override;
93 
98  QwtPlot *GetPlot();
99 
103  void SetPlotTitle(const QwtText &qwt_title);
104 
108  void SetPlotTitle(const char *title);
109 
117  unsigned int InsertCurve(const char *title, QColor color = QColor(Qt::black));
118 
125  void SetAxisTitle(int axis, const char *title);
126 
135  bool SetCurveData(unsigned int curveId, const DataVector &xValues, const DataVector &yValues);
136 
147  bool SetCurveData(unsigned int curveId,
148  const DataVector &xValues,
149  const DataVector &yValues,
150  const DataVector &yLowerError,
151  const DataVector &yUpperError);
152 
165  bool SetCurveData(unsigned int curveId,
166  const DataVector &xValues,
167  const DataVector &yValues,
168  const DataVector &xLowerError,
169  const DataVector &xUpperError,
170  const DataVector &yLowerError,
171  const DataVector &yUpperError);
172 
180  bool SetCurveData(unsigned int curveId, const XYDataVector &data);
181 
187  void SetCurvePen(unsigned int curveId, const QPen &pen);
188 
199  void SetCurveBrush(unsigned int curveId, const QBrush &brush);
200 
207  void SetCurveStyle(unsigned int curveId, const QwtPlotCurve::CurveStyle style);
208 
215  void SetCurveSymbol(unsigned int curveId, QwtSymbol *symbol);
216 
217  void SetCurveAntialiasingOn(unsigned int curveId);
218  void SetCurveAntialiasingOff(unsigned int curveId);
219 
226  void SetCurveTitle(unsigned int curveId, const char *title);
227 
233  void SetErrorPen(unsigned int curveId, const QPen &pen);
234 
240  void SetErrorStyleSymbols(unsigned int curveId, bool drawSmybols);
241 
246  void SetLegend(QwtLegend *legend, QwtPlot::LegendPosition pos = QwtPlot::RightLegend, double ratio = -1);
247 
253  void SetLegendAttribute(unsigned int curveId, const QwtPlotCurve::LegendAttribute &attribute);
254 
259  void Replot();
260 
264  void Clear();
265 
266 protected:
271  double *ConvertToRawArray(const DataVector &values);
272 
280  double *ConvertToRawArray(const XYDataVector &values, unsigned int component);
281 
292  bool AddErrorIntervalCurve(unsigned int curveId,
293  const DataVector &lessError,
294  const DataVector &moreError,
295  bool isXError);
296 
297  QwtPlot *m_Plot;
298  std::vector<std::tuple<QwtPlotCurve *, QwtPlotIntervalCurve *, QwtPlotIntervalCurve *>> m_PlotCurveVector;
299 };
300 
301 #endif
QmitkPlotWidget::m_PlotCurveVector
std::vector< std::tuple< QwtPlotCurve *, QwtPlotIntervalCurve *, QwtPlotIntervalCurve * > > m_PlotCurveVector
Definition: QmitkPlotWidget.h:298
QmitkPlotWidget::m_Plot
QwtPlot * m_Plot
Definition: QmitkPlotWidget.h:297
MITKQTWIDGETSEXT_EXPORT
#define MITKQTWIDGETSEXT_EXPORT
Definition: MitkQtWidgetsExtExports.h:15
QmitkPlotWidget::XYDataVector
std::vector< std::pair< double, double > > XYDataVector
Definition: QmitkPlotWidget.h:79
mitkCommon.h
QmitkPlotWidget::ScalarType
double ScalarType
Definition: QmitkPlotWidget.h:66
QmitkPlotWidget
Definition: QmitkPlotWidget.h:54
MitkQtWidgetsExtExports.h
QmitkPlotWidget::DataVector
std::vector< ScalarType > DataVector
Definition: QmitkPlotWidget.h:73