21 #include "qcustomplot.h"
43 auto custom_plot = std::make_unique<QCustomPlot>();
44 auto color_map =
new QCPColorMap(custom_plot->xAxis, custom_plot->yAxis);
45 color_map->data()->clear();
50 EXPECT_EQ(color_map->data()->keySize(), 0);
51 EXPECT_EQ(color_map->data()->valueSize(), 0);
59 auto custom_plot = std::make_unique<QCustomPlot>();
60 auto color_map =
new QCPColorMap(custom_plot->xAxis, custom_plot->yAxis);
68 EXPECT_NO_THROW(controller.setItem(data_item));
71 EXPECT_EQ(color_map->data()->keySize(), 0);
72 EXPECT_EQ(color_map->data()->valueSize(), 0);
80 auto custom_plot = std::make_unique<QCustomPlot>();
81 auto color_map =
new QCPColorMap(custom_plot->xAxis, custom_plot->yAxis);
89 EXPECT_NO_THROW(controller.setItem(data_item));
92 const int nx = 3, ny = 2;
97 EXPECT_EQ(color_map->data()->keySize(), nx);
98 EXPECT_EQ(color_map->data()->valueSize(), ny);
99 EXPECT_EQ(color_map->data()->cell(0, 0), 0.0);
100 EXPECT_EQ(color_map->data()->cell(nx - 1, ny - 1), 0.0);
108 auto custom_plot = std::make_unique<QCustomPlot>();
109 auto color_map =
new QCPColorMap(custom_plot->xAxis, custom_plot->yAxis);
114 const int nx = 3, ny = 2;
122 EXPECT_EQ(color_map->data()->keySize(), nx);
123 EXPECT_EQ(color_map->data()->valueSize(), ny);
124 EXPECT_EQ(color_map->data()->cell(0, 0), 0.0);
125 EXPECT_EQ(color_map->data()->cell(nx - 1, ny - 1), 0.0);
128 std::vector<double> expected = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0};
129 data_item->setContent(expected);
130 EXPECT_EQ(color_map->data()->cell(0, 0), 1.0);
131 EXPECT_EQ(color_map->data()->cell(nx - 1, ny - 1), 6.0);
135 EXPECT_EQ(color_map->data()->keySize(), 0);
136 EXPECT_EQ(color_map->data()->valueSize(), 0);
144 auto custom_plot = std::make_unique<QCustomPlot>();
145 auto color_map =
new QCPColorMap(custom_plot->xAxis, custom_plot->yAxis);
150 const int nx1 = 3, ny1 = 2;
151 std::vector<double> expected1 = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0};
154 data_item1->setContent(expected1);
156 const int nx2 = 2, ny2 = 1;
157 std::vector<double> expected2 = {10.0, 20.0};
160 data_item2->setContent(expected2);
164 controller.
setItem(data_item1);
166 EXPECT_EQ(color_map->data()->keySize(), nx1);
167 EXPECT_EQ(color_map->data()->valueSize(), ny1);
168 EXPECT_EQ(color_map->data()->cell(0, 0), 1.0);
169 EXPECT_EQ(color_map->data()->cell(nx1 - 1, ny1 - 1), 6.0);
172 controller.
setItem(data_item2);
174 EXPECT_EQ(color_map->data()->keySize(), nx2);
175 EXPECT_EQ(color_map->data()->valueSize(), ny2);
176 EXPECT_EQ(color_map->data()->cell(0, 0), 10.0);
177 EXPECT_EQ(color_map->data()->cell(nx2 - 1, ny2 - 1), 20.0);
185 auto custom_plot = std::make_unique<QCustomPlot>();
186 auto color_map =
new QCPColorMap(custom_plot->xAxis, custom_plot->yAxis);
191 const int nx = 3, ny = 2;
194 std::vector<double> expected = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0};
195 data_item->setContent(expected);
201 QSignalSpy spy(color_map, &QCPColorMap::dataRangeChanged);
203 auto range = color_map->dataRange();
204 EXPECT_EQ(spy.count(), 0);
205 EXPECT_EQ(range.lower, 1.0);
206 EXPECT_EQ(range.upper, 6.0);
Testing Data1DPlotController.
~Data2DPlotControllerTest()
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.
Establish communication between QCPColorMap and Data2DItem.
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(Data2DPlotControllerTest, initialState)
Initial state.
materialitems.h Collection of materials to populate MaterialModel.