Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::ChartExampleTestHelper Class Reference

Test helper class for QmitkChartWidget unit tests. More...

#include <mitkChartExampleTestHelper.h>

Collaboration diagram for mitk::ChartExampleTestHelper:

Public Member Functions

Predefined Test Data Sets
std::unique_ptr< QmitkChartxyData > GetDataOne ()
 Create test data set #1 (x=0..9, y=0..9, bar, red, solid). More...
 
std::unique_ptr< QmitkChartxyData > GetDataTwo ()
 Create test data set #2 (x=10..19, y=10..19, bar, green, solid). More...
 
std::unique_ptr< QmitkChartxyData > GetDataThree ()
 Create test data set #3 (x=20..29, y=20..29, bar, blue, solid). More...
 
std::unique_ptr< QmitkChartxyData > GetDataFour ()
 Create test data set #4 (x=30..39, y=30..39, bar, yellow, solid). More...
 
std::unique_ptr< QmitkChartxyData > GetDataFive ()
 Create test data set #5 (x=40..49, y=40..49, bar, black, solid). More...
 
Utility Functions
QmitkChartWidget::ChartType ReturnChartTypeByString (std::string chartTypeString)
 Convert a chart type string to the corresponding enum value. More...
 
QmitkChartWidget::ChartColor ReturnChartColorByString (std::string chartColorString)
 Convert a color name string to the corresponding enum value. More...
 
QmitkChartWidget::LineStyle ReturnChartStyleByString (std::string chartStyleString)
 Convert a line style string to the corresponding enum value. More...
 
void Add (int dataSet)
 Add a predefined data set to the chart widget. More...
 
std::vector< std::pair< double, double > > ToStdPairList (QVariantList xData, QVariantList yData)
 Convert QVariantLists of x and y data to a vector of std::pair. More...
 
void ClearMemory ()
 Clear all chart data and reset the widget. More...
 

Public Attributes

QmitkChartWidget qmitkChartWidget
 The QmitkChartWidget instance used for testing. More...
 

Detailed Description

Test helper class for QmitkChartWidget unit tests.

Provides predefined data sets and utility functions to facilitate unit testing of the QmitkChartWidget charting framework. Each data set is a simple linear sequence of (x, y) pairs with preconfigured chart type, color, and line style.

See also
QmitkChartWidget
QmitkChartxyData

Definition at line 41 of file mitkChartExampleTestHelper.h.

Member Function Documentation

◆ Add()

void mitk::ChartExampleTestHelper::Add ( int  dataSet)

Add a predefined data set to the chart widget.

Retrieves the data set corresponding to the given number (1-5), extracts its properties, and adds it to qmitkChartWidget.

Parameters
[in]dataSetThe data set number (1 through 5).

◆ ClearMemory()

void mitk::ChartExampleTestHelper::ClearMemory ( )

Clear all chart data and reset the widget.

◆ GetDataFive()

std::unique_ptr<QmitkChartxyData> mitk::ChartExampleTestHelper::GetDataFive ( )

Create test data set #5 (x=40..49, y=40..49, bar, black, solid).

Returns
A unique pointer to the populated QmitkChartxyData.

◆ GetDataFour()

std::unique_ptr<QmitkChartxyData> mitk::ChartExampleTestHelper::GetDataFour ( )

Create test data set #4 (x=30..39, y=30..39, bar, yellow, solid).

Returns
A unique pointer to the populated QmitkChartxyData.

◆ GetDataOne()

std::unique_ptr<QmitkChartxyData> mitk::ChartExampleTestHelper::GetDataOne ( )

Create test data set #1 (x=0..9, y=0..9, bar, red, solid).

Returns
A unique pointer to the populated QmitkChartxyData.

◆ GetDataThree()

std::unique_ptr<QmitkChartxyData> mitk::ChartExampleTestHelper::GetDataThree ( )

Create test data set #3 (x=20..29, y=20..29, bar, blue, solid).

Returns
A unique pointer to the populated QmitkChartxyData.

◆ GetDataTwo()

std::unique_ptr<QmitkChartxyData> mitk::ChartExampleTestHelper::GetDataTwo ( )

Create test data set #2 (x=10..19, y=10..19, bar, green, solid).

Returns
A unique pointer to the populated QmitkChartxyData.

◆ ReturnChartColorByString()

QmitkChartWidget::ChartColor mitk::ChartExampleTestHelper::ReturnChartColorByString ( std::string  chartColorString)

Convert a color name string to the corresponding enum value.

Supported strings include "red", "orange", "yellow", "green", "blue", "purple", "brown", "magenta", etc. Unknown strings default to ChartColor::red.

Parameters
[in]chartColorStringThe color name as a string.
Returns
The corresponding QmitkChartWidget::ChartColor enum value.

◆ ReturnChartStyleByString()

QmitkChartWidget::LineStyle mitk::ChartExampleTestHelper::ReturnChartStyleByString ( std::string  chartStyleString)

Convert a line style string to the corresponding enum value.

Supported strings: "solid", "dashed". Unknown strings default to LineStyle::solid.

Parameters
[in]chartStyleStringThe line style as a string.
Returns
The corresponding QmitkChartWidget::LineStyle enum value.

◆ ReturnChartTypeByString()

QmitkChartWidget::ChartType mitk::ChartExampleTestHelper::ReturnChartTypeByString ( std::string  chartTypeString)

Convert a chart type string to the corresponding enum value.

Supported strings: "bar", "line", "spline", "pie", "area", "area_spline", "scatter". Unknown strings default to ChartType::bar.

Parameters
[in]chartTypeStringThe chart type as a string.
Returns
The corresponding QmitkChartWidget::ChartType enum value.

◆ ToStdPairList()

std::vector<std::pair<double, double> > mitk::ChartExampleTestHelper::ToStdPairList ( QVariantList  xData,
QVariantList  yData 
)

Convert QVariantLists of x and y data to a vector of std::pair.

Parameters
[in]xDataThe x values as a QVariantList.
[in]yDataThe y values as a QVariantList.
Returns
A vector of (x, y) pairs with double values.
Precondition
xData and yData must have the same length.

Member Data Documentation

◆ qmitkChartWidget

QmitkChartWidget mitk::ChartExampleTestHelper::qmitkChartWidget

The QmitkChartWidget instance used for testing.

Definition at line 81 of file mitkChartExampleTestHelper.h.


The documentation for this class was generated from the following file: