Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef _QmitkPlotWidget_H_
18 #define _QmitkPlotWidget_H_
19 
21 #include "mitkCommon.h"
22 #include <qwidget.h>
23 #include <qwt_legend.h>
24 #include <qwt_plot.h>
25 #include <qwt_plot_curve.h>
26 #include <qwt_plot_intervalcurve.h>
27 #include <qwt_symbol.h>
28 #include <tuple>
29 #include <vector>
30 
57 {
58 private:
59  Q_OBJECT
60 
61 public:
67  typedef double ScalarType;
68 
74  typedef std::vector<ScalarType> DataVector;
75 
80  typedef std::vector<std::pair<double, double>> XYDataVector;
81 
85  QmitkPlotWidget(QWidget *parent = nullptr,
86  const char *title = nullptr,
87  const char *name = nullptr,
88  Qt::WindowFlags f = nullptr);
89 
93  virtual ~QmitkPlotWidget();
94 
99  QwtPlot *GetPlot();
100 
104  void SetPlotTitle(const QwtText &qwt_title);
105 
109  void SetPlotTitle(const char *title);
110 
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 
206  void SetCurveStyle(unsigned int curveId, const QwtPlotCurve::CurveStyle style);
207 
213  void SetCurveSymbol(unsigned int curveId, QwtSymbol *symbol);
214 
215  void SetCurveAntialiasingOn(unsigned int curveId);
216  void SetCurveAntialiasingOff(unsigned int curveId);
217 
224  void SetCurveTitle(unsigned int curveId, const char *title);
225 
231  void SetErrorPen(unsigned int curveId, const QPen &pen);
232 
238  void SetErrorStyleSymbols(unsigned int curveId, bool drawSmybols);
239 
244  void SetLegend(QwtLegend *legend, QwtPlot::LegendPosition pos = QwtPlot::RightLegend, double ratio = -1);
245 
251  void SetLegendAttribute(unsigned int curveId, const QwtPlotCurve::LegendAttribute &attribute);
252 
257  void Replot();
258 
262  void Clear();
263 
264 protected:
269  double *ConvertToRawArray(const DataVector &values);
270 
278  double *ConvertToRawArray(const XYDataVector &values, unsigned int component);
279 
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
std::vector< ScalarType > DataVector
std::vector< std::pair< double, double > > XYDataVector
#define MITKQTWIDGETSEXT_EXPORT
std::vector< std::tuple< QwtPlotCurve *, QwtPlotIntervalCurve *, QwtPlotIntervalCurve * > > m_PlotCurveVector