Medical Imaging Interaction Toolkit  2018.4.99-389bf124
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 <tuple>
25 #include <vector>
26 
54  : public QWidget
55  {
56 private:
57  Q_OBJECT
58 
59 public:
65  typedef double ScalarType;
66 
72  typedef std::vector<ScalarType> DataVector;
73 
78  typedef std::vector<std::pair<double, double>> XYDataVector;
79 
83  QmitkPlotWidget(QWidget *parent = nullptr,
84  const char *title = nullptr,
85  const char *name = nullptr,
86  Qt::WindowFlags f = nullptr);
87 
91  ~QmitkPlotWidget() override;
92 
97  QwtPlot *GetPlot();
98 
102  void SetPlotTitle(const QwtText &qwt_title);
103 
107  void SetPlotTitle(const char *title);
108 
115  unsigned int InsertCurve(const char *title, QColor color = QColor(Qt::black));
116 
123  void SetAxisTitle(int axis, const char *title);
124 
133  bool SetCurveData(unsigned int curveId, const DataVector &xValues, const DataVector &yValues);
134 
145  bool SetCurveData(unsigned int curveId,
146  const DataVector &xValues,
147  const DataVector &yValues,
148  const DataVector &yLowerError,
149  const DataVector &yUpperError);
150 
163  bool SetCurveData(unsigned int curveId,
164  const DataVector &xValues,
165  const DataVector &yValues,
166  const DataVector &xLowerError,
167  const DataVector &xUpperError,
168  const DataVector &yLowerError,
169  const DataVector &yUpperError);
170 
178  bool SetCurveData(unsigned int curveId, const XYDataVector &data);
179 
185  void SetCurvePen(unsigned int curveId, const QPen &pen);
186 
197  void SetCurveBrush(unsigned int curveId, const QBrush &brush);
198 
204  void SetCurveStyle(unsigned int curveId, const QwtPlotCurve::CurveStyle style);
205 
211  void SetCurveSymbol(unsigned int curveId, QwtSymbol *symbol);
212 
213  void SetCurveAntialiasingOn(unsigned int curveId);
214  void SetCurveAntialiasingOff(unsigned int curveId);
215 
222  void SetCurveTitle(unsigned int curveId, const char *title);
223 
229  void SetErrorPen(unsigned int curveId, const QPen &pen);
230 
236  void SetErrorStyleSymbols(unsigned int curveId, bool drawSmybols);
237 
242  void SetLegend(QwtLegend *legend, QwtPlot::LegendPosition pos = QwtPlot::RightLegend, double ratio = -1);
243 
249  void SetLegendAttribute(unsigned int curveId, const QwtPlotCurve::LegendAttribute &attribute);
250 
255  void Replot();
256 
260  void Clear();
261 
262 protected:
267  double *ConvertToRawArray(const DataVector &values);
268 
276  double *ConvertToRawArray(const XYDataVector &values, unsigned int component);
277 
290  bool AddErrorIntervalCurve(unsigned int curveId,
291  const DataVector &lessError,
292  const DataVector &moreError,
293  bool isXError);
294 
295  QwtPlot *m_Plot;
296  std::vector<std::tuple<QwtPlotCurve *, QwtPlotIntervalCurve *, QwtPlotIntervalCurve *>> m_PlotCurveVector;
297 };
298 
299 #endif
std::vector< ScalarType > DataVector
std::vector< std::pair< double, double > > XYDataVector
#define MITKQTWIDGETSEXT_EXPORT
std::vector< std::tuple< QwtPlotCurve *, QwtPlotIntervalCurve *, QwtPlotIntervalCurve * > > m_PlotCurveVector