Medical Imaging Interaction Toolkit  2024.06.99-60d9b802
Medical Imaging Interaction Toolkit
QmitkChartWidget.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 #ifndef QmitkChartWidget_h
13 #define QmitkChartWidget_h
14 
15 #include <map>
16 #include <memory>
17 #include <QWidget>
18 
19 #include <MitkChartExports.h>
20 
21 class QmitkChartxyData;
22 
40 class MITKCHART_EXPORT QmitkChartWidget : public QWidget
41 {
42  Q_OBJECT
43 
44 public:
48  enum class ChartType {
49  bar,
50  line,
51  spline,
52  pie,
53  area,
54  area_spline,
55  scatter
56  };
60  enum class ColorTheme {
61  darkstyle,
62  lightstyle
63  };
64  enum class LineStyle {
65  solid,
66  dashed
67  };
68  enum class MarkerSymbol {
69  circle,
70  diamond,
71  cross,
72  square,
73  pentagon,
74  star,
75  x,
76  diamond_tall,
77  star_diamond,
78  star_triangle_up,
79  star_triangle_down,
80  asterisk,
81  cross_thin,
82  x_thin
83  };
84  enum class ChartColor {
85  red,
86  orange,
87  yellow,
88  green,
89  blue,
90  purple,
91  brown,
92  magenta,
93  tan,
94  cyan,
95  olive,
96  maroon,
97  navy,
98  aquamarine,
99  turqouise,
100  silver,
101  lime,
102  teal,
103  indigo,
104  violet,
105  pink,
106  black,
107  white,
108  grey
109  };
110  enum class AxisScale {
111  linear,
112  log
113  };
114 
119  enum class LegendPosition {
120  bottomMiddle,
121  bottomRight,
122  topRight,
123  topLeft,
124  middleRight
125  };
126 
127  explicit QmitkChartWidget(QWidget* parent = nullptr);
128  //for UnitTests
129  explicit QmitkChartWidget(QWidget *parent, bool unitTest);
130  ~QmitkChartWidget() override;
131 
142  void AddData1D(const std::vector<double>& data1D, const std::string& label, ChartType chartType = ChartType::bar);
143 
150  void UpdateData1D(const std::vector<double> &data1D, const std::string &label);
151 
156  void UpdateData2D(const std::vector< std::pair<double, double> > &data2D, const std::string &label);
157 
158  void UpdateChartExampleData(const std::vector< std::pair<double, double> >& data2D,
159  const std::string& label,
160  const std::string& type,
161  const std::string& color,
162  const std::string& lineStyle,
163  const std::string& pieLabelsData = 0);
164 
175  void AddData2D(const std::vector< std::pair<double, double> > &data2D,
176  const std::string &label,
177  ChartType chartType = ChartType::bar);
178 
179  //Add Function for the ChartExample
180  void AddChartExampleData(const std::vector< std::pair<double, double> >& data2D,
181  const std::string& label,
182  const std::string& type,
183  const std::string& color,
184  const std::string& style,
185  const std::string& pieLabelsData = 0);
186 
193  void RemoveData(const std::string& label);
194 
195  void UpdateLabel(const std::string& existingLabel, const std::string& newLabel);
196 
197  QmitkChartxyData *GetDataElementByLabel(const std::string& label) const;
198 
207  void SetColor(const std::string& label, const std::string& colorName);
208 
217  void SetLineStyle(const std::string& label, LineStyle style);
218 
223  void SetMarkerSymbol(const std::string &label, MarkerSymbol symbol);
224 
229  void SetYAxisScale(AxisScale scale);
230 
231  void SetXAxisLabel(const std::string& label);
232 
233  void SetYAxisLabel(const std::string& label);
234 
239  void SetPieLabels(const std::vector<std::string> &pieLabels, const std::string &label);
243  void SetTitle(const std::string &title);
244 
252  void SetChartType(const std::string& label, ChartType type);
260  void SetXErrorBars(const std::string &label, const std::vector<double> &errorPlus, const std::vector<double>& errorMinus = std::vector<double>());
261 
267  void SetYErrorBars(const std::string &label, const std::vector<double> &errorPlus, const std::vector<double> &errorMinus = std::vector<double>());
268 
274  void SetLegendPosition(LegendPosition position);
275 
276  void SetShowLegend(bool show);
277 
278  void SetStackedData(bool stacked);
279 
285  void Show(bool showSubChart=false);
286 
293  void SetShowDataPoints(bool showDataPoints);
294 
298  void Clear();
299 
305  void SetTheme(ColorTheme themeEnabled);
306 
312  void SetShowSubchart(bool showSubChart);
313 
320  void SetShowErrorBars(bool showErrorBars);
321 
326  void SetMinMaxValueXView(double minValueX,double maxValueX);
331  void SetMinMaxValueYView(double minValueY, double maxValueY);
332 
337  void Reload();
338 
339  QSize sizeHint() const override;
340 
341  void SavePlotAsImage();
342 
343 public slots:
344  void OnLoadFinished(bool isLoadSuccessful);
345  void OnPageSuccessfullyLoaded();
346 
347 signals:
348  void PageSuccessfullyLoaded();
349 
350 private:
352  std::string convertBooleanValue(bool value) const;
353 
354  class Impl;
355  std::unique_ptr<Impl> m_Impl;
356 };
357 
358 #endif
QmitkChartWidget::MarkerSymbol
MarkerSymbol
Definition: QmitkChartWidget.h:68
QmitkChartWidget::ChartType
ChartType
enum of diagram types.
Definition: QmitkChartWidget.h:48
QmitkChartWidget::ChartColor
ChartColor
Definition: QmitkChartWidget.h:84
MitkChartExports.h
MITKCHART_EXPORT
#define MITKCHART_EXPORT
Definition: MitkChartExports.h:15
QmitkChartWidget::LegendPosition
LegendPosition
enum of legend position. See https://plot.ly/javascript/legend/
Definition: QmitkChartWidget.h:119
QmitkChartWidget
QmitkChartWidget is a widget to display various charts based on the javascript chart library plotly.
Definition: QmitkChartWidget.h:40
QmitkChartxyData
Definition: QmitkChartxyData.h:22
QmitkChartWidget::ColorTheme
ColorTheme
enum of chart style (modifies background and line color).
Definition: QmitkChartWidget.h:60
QmitkChartWidget::LineStyle
LineStyle
Definition: QmitkChartWidget.h:64
QmitkChartWidget::AxisScale
AxisScale
Definition: QmitkChartWidget.h:110