Medical Imaging Interaction Toolkit  2018.4.99-389bf124
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 QmitkC3jsWidget_h
13 #define QmitkC3jsWidget_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 
141  void AddData1D(const std::vector<double>& data1D, const std::string& label, ChartType chartType = ChartType::bar);
142 
149  void UpdateData1D(const std::vector<double> &data1D, const std::string &label);
150 
155  void UpdateData2D(const std::vector< std::pair<double, double> > &data2D, const std::string &label);
156 
167  void UpdateChartExampleData(const std::vector< std::pair<double, double> >& data2D,
168  const std::string& label,
169  const std::string& type,
170  const std::string& color,
171  const std::string& lineStyle,
172  const std::string& pieLabelsData = 0);
173 
174  void AddData2D(const std::vector< std::pair<double, double> > &data2D,
175  const std::string &label,
176  ChartType chartType = ChartType::bar);
177 
178  //Add Function for the ChartExample
179  void AddChartExampleData(const std::vector< std::pair<double, double> >& data2D,
180  const std::string& label,
181  const std::string& type,
182  const std::string& color,
183  const std::string& style,
184  const std::string& pieLabelsData = 0);
185 
192  void RemoveData(const std::string& label);
193 
194  void UpdateLabel(const std::string& existingLabel, const std::string& newLabel);
195 
196  QmitkChartxyData *GetDataElementByLabel(const std::string& label) const;
197 
206  void SetColor(const std::string& label, const std::string& colorName);
207 
216  void SetLineStyle(const std::string& label, LineStyle style);
217 
222  void SetMarkerSymbol(const std::string &label, MarkerSymbol symbol);
223 
228  void SetYAxisScale(AxisScale scale);
229 
230  void SetXAxisLabel(const std::string& label);
231 
232  void SetYAxisLabel(const std::string& label);
233 
238  void SetPieLabels(const std::vector<std::string> &pieLabels, const std::string &label);
242  void SetTitle(const std::string &title);
243 
251  void SetChartType(const std::string& label, ChartType type);
259  void SetXErrorBars(const std::string &label, const std::vector<double> &errorPlus, const std::vector<double>& errorMinus = std::vector<double>());
260 
266  void SetYErrorBars(const std::string &label, const std::vector<double> &errorPlus, const std::vector<double> &errorMinus = std::vector<double>());
267 
273  void SetLegendPosition(LegendPosition position);
274 
275  void SetShowLegend(bool show);
276 
277  void SetStackedData(bool stacked);
278 
284  void Show(bool showSubChart=false);
285 
292  void SetShowDataPoints(bool showDataPoints);
293 
297  void Clear();
298 
304  void SetTheme(ColorTheme themeEnabled);
305 
311  void SetShowSubchart(bool showSubChart);
312 
319  void SetShowErrorBars(bool showErrorBars);
320 
325  void SetMinMaxValueXView(double minValueX,double maxValueX);
330  void SetMinMaxValueYView(double minValueY, double maxValueY);
331 
336  void Reload();
337 
338  QSize sizeHint() const override;
339 
340  void SavePlotAsImage();
341 
342 public slots:
343  void OnLoadFinished(bool isLoadSuccessful);
344  void OnPageSuccessfullyLoaded();
345 
346 signals:
347  void PageSuccessfullyLoaded();
348 
349 private:
351  std::string convertBooleanValue(bool value) const;
352 
353  class Impl;
354  std::unique_ptr<Impl> m_Impl;
355 };
356 
357 #endif
static char * line
Definition: svm.cpp:2870
QmitkChartWidget is a widget to display various charts based on the javascript chart library plotly...
#define MITKCHART_EXPORT
double square(double a)
ChartType
enum of diagram types.
ColorTheme
enum of chart style (modifies background and line color).
LegendPosition
enum of legend position. See https://plot.ly/javascript/legend/