Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkChartExampleTestHelper.cpp
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 
14 
15 // std includes
16 #include <string>
17 
18 std::unique_ptr<QmitkChartxyData> mitk::ChartExampleTestHelper::GetDataOne()
19 {
20  auto myDataOne = std::make_unique<QmitkChartxyData>();
21 
22  std::vector< std::pair<double, double> > data;
23 
24  for (int i = 0; i < 10; i++)
25  {
26  data.emplace_back(i, i);
27  }
28 
29  myDataOne->SetData(data);
30  myDataOne->SetLabel("DataOne");
31  myDataOne->SetChartType("bar");
32  myDataOne->SetColor("red");
33  myDataOne->SetLineStyle("solid");
34 
35  return myDataOne;
36 }
37 
38 std::unique_ptr<QmitkChartxyData> mitk::ChartExampleTestHelper::GetDataTwo()
39 {
40  auto myDataTwo = std::make_unique<QmitkChartxyData>();
41 
42  std::vector< std::pair<double, double> > data;
43 
44  for (int i = 10; i < 20; i++)
45  {
46  data.emplace_back(i, i);
47  }
48 
49  myDataTwo->SetData(data);
50  myDataTwo->SetLabel("DataTwo");
51  myDataTwo->SetChartType("bar");
52  myDataTwo->SetColor("green");
53  myDataTwo->SetLineStyle("solid");
54 
55  return myDataTwo;
56 }
57 
58 std::unique_ptr<QmitkChartxyData> mitk::ChartExampleTestHelper::GetDataThree()
59 {
60  auto myDataThree = std::make_unique<QmitkChartxyData>();
61 
62  std::vector< std::pair<double, double> > data;
63 
64  for (int i = 20; i < 30; i++)
65  {
66  data.emplace_back(i, i);
67  }
68 
69  myDataThree->SetData(data);
70  myDataThree->SetLabel("DataThree");
71  myDataThree->SetChartType("bar");
72  myDataThree->SetColor("blue");
73  myDataThree->SetLineStyle("solid");
74 
75  return myDataThree;
76 }
77 
78 std::unique_ptr<QmitkChartxyData> mitk::ChartExampleTestHelper::GetDataFour()
79 {
80  auto myDataFour = std::make_unique<QmitkChartxyData>();
81 
82  std::vector< std::pair<double, double> > data;
83 
84  for (int i = 30; i < 40; i++)
85  {
86  data.emplace_back(i, i);
87  }
88 
89  myDataFour->SetData(data);
90  myDataFour->SetLabel("DataFour");
91  myDataFour->SetChartType("bar");
92  myDataFour->SetColor("yellow");
93  myDataFour->SetLineStyle("solid");
94 
95  return myDataFour;
96 }
97 
98 std::unique_ptr<QmitkChartxyData> mitk::ChartExampleTestHelper::GetDataFive()
99 {
100  auto myDataFive = std::make_unique<QmitkChartxyData>();
101 
102  std::vector< std::pair<double, double> > data;
103 
104  for (int i = 40; i < 50; i++)
105  {
106  data.emplace_back(i, i);
107  }
108 
109  myDataFive->SetData(data);
110  myDataFive->SetLabel("DataFive");
111  myDataFive->SetChartType("bar");
112  myDataFive->SetColor("black");
113  myDataFive->SetLineStyle("solid");
114 
115  return myDataFive;
116 }
117 
119 {
120  if (chartTypeString == "bar")
121  {
123  }
124 
125  if (chartTypeString == "line")
126  {
128  }
129 
130  if (chartTypeString == "spline")
131  {
133  }
134 
135  if (chartTypeString == "pie")
136  {
138  }
139 
140  if (chartTypeString == "area")
141  {
143  }
144 
145  if (chartTypeString == "area_spline")
146  {
148  }
149 
150  if (chartTypeString == "scatter")
151  {
153  }
154 
156 }
157 
159 {
160  if (chartColorString == "red")
161  {
163  }
164 
165  if (chartColorString == "orange")
166  {
168  }
169 
170  if (chartColorString == "yellow")
171  {
173  }
174 
175  if (chartColorString == "green")
176  {
178  }
179 
180  if (chartColorString == "blue")
181  {
183  }
184 
185  if (chartColorString == "purple")
186  {
188  }
189 
190  if (chartColorString == "brown")
191  {
193  }
194 
195  if (chartColorString == "magenta")
196  {
198  }
199 
200  if (chartColorString == "tan")
201  {
203  }
204 
205  if (chartColorString == "cyan")
206  {
208  }
209 
210  if (chartColorString == "olive")
211  {
213  }
214 
215  if (chartColorString == "maroon")
216  {
218  }
219 
220  if (chartColorString == "navy")
221  {
223  }
224 
225  if (chartColorString == "aquamarine")
226  {
228  }
229 
230  if (chartColorString == "turqouise")
231  {
233  }
234 
235  if (chartColorString == "silver")
236  {
238  }
239 
240  if (chartColorString == "lime")
241  {
243  }
244 
245  if (chartColorString == "teal")
246  {
248  }
249 
250  if (chartColorString == "indigo")
251  {
253  }
254 
255  if (chartColorString == "violet")
256  {
258  }
259 
260  if (chartColorString == "pink")
261  {
263  }
264 
265  if (chartColorString == "black")
266  {
268  }
269 
270  if (chartColorString == "white")
271  {
273  }
274 
275  if (chartColorString == "grey")
276  {
278  }
279 
281 }
282 
284 {
285  if (chartStyleString == "solid")
286  {
288  }
289 
290  if (chartStyleString == "dashed")
291  {
293  }
294 
296 }
297 
299 {
300  std::unique_ptr<QmitkChartxyData> myData;
301  if (dataSet == 1)
302  {
304  }
305 
306  if (dataSet == 2)
307  {
309  }
310 
311  if (dataSet == 3)
312  {
314  }
315 
316  if (dataSet == 4)
317  {
319  }
320 
321  if (dataSet == 5)
322  {
324  }
325 
326  std::vector< std::pair<double, double> > data = mitk::ChartExampleTestHelper::ToStdPairList(myData->GetXData(), myData->GetYData());
327  auto label = myData->GetLabel().toString().toStdString();
328  auto type = myData->GetChartType().toString().toStdString();
329  auto color = myData->GetColor().toString().toStdString();
330  auto style = myData->GetLineStyle().toString().toStdString();
331 
332  qmitkChartWidget.AddChartExampleData(data, label, type, color, style);
333 }
334 
335 std::vector< std::pair<double, double> > mitk::ChartExampleTestHelper::ToStdPairList(QVariantList xData, QVariantList yData)
336 {
337  auto xDataConverted = xData.toVector().toStdVector();
338  auto yDataConverted = yData.toVector().toStdVector();
339 
340  std::vector< std::pair<double, double> > data;
341  for (size_t i = 0; i < xDataConverted.size(); i++)
342  {
343  data.emplace_back(xDataConverted[i].toDouble(), yDataConverted[i].toDouble());
344  }
345 
346  return data;
347 }
348 
350 {
351  // Clear the vector
353 }
QmitkChartWidget::ChartColor ReturnChartColorByString(std::string chartColorString)
QmitkChartWidget::LineStyle ReturnChartStyleByString(std::string chartStyleString)
void AddChartExampleData(const std::vector< std::pair< double, double > > &data2D, const std::string &label, const std::string &type, const std::string &color, const std::string &style, const std::string &pieLabelsData=0)
Q_INVOKABLE QList< QVariant > GetXData() const
ChartType
enum of diagram types.
Q_INVOKABLE QList< QVariant > GetYData() const
Q_INVOKABLE QVariant GetLineStyle() const
std::vector< std::pair< double, double > > ToStdPairList(QVariantList xData, QVariantList yData)
QmitkChartWidget::ChartType ReturnChartTypeByString(std::string chartTypeString)
void Clear()
Clears all data inside and resets the widget.
std::unique_ptr< QmitkChartxyData > GetDataOne()
Q_INVOKABLE QVariant GetLabel() const
std::unique_ptr< QmitkChartxyData > GetDataTwo()
std::unique_ptr< QmitkChartxyData > GetDataFive()
std::unique_ptr< QmitkChartxyData > GetDataThree()
Q_INVOKABLE QVariant GetColor() const
std::unique_ptr< QmitkChartxyData > GetDataFour()
Q_INVOKABLE QVariant GetChartType() const