24 #include "qcustomplot.h"
25 #include <qcustomplot.h>
42 auto custom_plot = std::make_unique<QCustomPlot>();
45 EXPECT_TRUE(TestUtils::GetPlottable<QCPColorMap>(custom_plot.get()) !=
nullptr);
47 const double customplot_default_lower(0.0), customplot_default_upper(5.0);
48 EXPECT_DOUBLE_EQ(custom_plot->xAxis->range().lower, customplot_default_lower);
49 EXPECT_DOUBLE_EQ(custom_plot->xAxis->range().upper, customplot_default_upper);
50 EXPECT_DOUBLE_EQ(custom_plot->yAxis->range().lower, customplot_default_lower);
51 EXPECT_DOUBLE_EQ(custom_plot->yAxis->range().upper, customplot_default_upper);
58 auto custom_plot = std::make_unique<QCustomPlot>();
64 controller.
setItem(viewport_item);
66 auto color_map = TestUtils::GetPlottable<QCPColorMap>(custom_plot.get());
67 EXPECT_TRUE(color_map !=
nullptr);
69 const double default_lower(0.0), default_upper(1.0);
70 EXPECT_DOUBLE_EQ(custom_plot->xAxis->range().lower, default_lower);
71 EXPECT_DOUBLE_EQ(custom_plot->xAxis->range().upper, default_upper);
72 EXPECT_DOUBLE_EQ(custom_plot->yAxis->range().lower, default_lower);
73 EXPECT_DOUBLE_EQ(custom_plot->yAxis->range().upper, default_upper);
75 const int qcpmap_internal_default(10);
76 EXPECT_EQ(color_map->data()->keySize(), qcpmap_internal_default);
77 EXPECT_EQ(color_map->data()->valueSize(), qcpmap_internal_default);
84 auto custom_plot = std::make_unique<QCustomPlot>();
89 const int nx = 3, ny = 2;
92 std::vector<double> expected = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0};
93 data_item->setContent(expected);
98 colormap_item->setDataItem(data_item);
101 controller.
setItem(viewport_item);
103 auto color_map = TestUtils::GetPlottable<QCPColorMap>(custom_plot.get());
104 EXPECT_EQ(color_map->data()->keySize(), nx);
105 EXPECT_EQ(color_map->data()->valueSize(), ny);
106 EXPECT_EQ(color_map->data()->cell(0, 0), 1.0);
107 EXPECT_EQ(color_map->data()->cell(nx - 1, ny - 1), 6.0);
114 auto custom_plot = std::make_unique<QCustomPlot>();
120 controller.
setItem(viewport_item);
122 auto color_map = TestUtils::GetPlottable<QCPColorMap>(custom_plot.get());
123 EXPECT_TRUE(color_map !=
nullptr);
127 const int nx = 3, ny = 2;
130 std::vector<double> expected = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0};
131 data_item->setContent(expected);
138 EXPECT_EQ(color_map->data()->keySize(), nx);
139 EXPECT_EQ(color_map->data()->valueSize(), ny);
140 EXPECT_EQ(color_map->data()->cell(0, 0), 1.0);
141 EXPECT_EQ(color_map->data()->cell(nx - 1, ny - 1), 6.0);
Testing ColorMapViewportPlotController.
~ColorMapViewportPlotControllerTest()
Two-dimensional color map representation of Data2DItem.
void setDataItem(const Data2DItem *item)
Sets link to the data item.
Container with viewport and collection of ColorMapItem's to plot.
Establishes communications and mutual updates for ColorMapViewportItem and QCutomPlot.
Represents two-dimensional data (axes definition and 2d array of values).
void setAxes(std::unique_ptr< BinnedAxisItem > x_axis, std::unique_ptr< BinnedAxisItem > y_axis)
Sets axes and put data points to zero.
static std::unique_ptr< FixedBinAxisItem > create(int nbins, double xmin, double xmax)
void setItem(SessionItem *item)
Main class to hold hierarchy of SessionItem objects.
T * insertItem(SessionItem *parent=nullptr, const TagRow &tagrow={})
Inserts item into given parent under given tagrow.
TEST_F(ColorMapViewportPlotControllerTest, initialState)
Initial state.
materialitems.h Collection of materials to populate MaterialModel.