23 #include "qcustomplot.h"
41 auto custom_plot = std::make_unique<QCustomPlot>();
46 auto color_map = TestUtils::GetPlottable<QCPColorMap>(custom_plot.get());
47 ASSERT_TRUE(color_map !=
nullptr);
54 auto custom_plot = std::make_unique<QCustomPlot>();
60 const int nx = 3, ny = 2;
63 std::vector<double> expected = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0};
64 data_item->setContent(expected);
71 controller.
setItem(colormap_item);
74 EXPECT_EQ(custom_plot->plottableCount(), 1);
75 auto color_map = TestUtils::GetPlottable<QCPColorMap>(custom_plot.get());
76 ASSERT_TRUE(color_map !=
nullptr);
77 EXPECT_EQ(color_map->data()->keySize(), nx);
78 EXPECT_EQ(color_map->data()->valueSize(), ny);
79 EXPECT_EQ(color_map->data()->cell(0, 0), 1.0);
80 EXPECT_EQ(color_map->data()->cell(nx - 1, ny - 1), 6.0);
83 EXPECT_TRUE(color_map->interpolate());
90 auto custom_plot = std::make_unique<QCustomPlot>();
96 controller.
setItem(colormap_item);
99 EXPECT_EQ(custom_plot->plottableCount(), 1);
100 auto color_map = TestUtils::GetPlottable<QCPColorMap>(custom_plot.get());
101 ASSERT_TRUE(color_map !=
nullptr);
102 const int qcpmap_internal_default(10);
103 EXPECT_EQ(color_map->data()->keySize(), qcpmap_internal_default);
104 EXPECT_EQ(color_map->data()->valueSize(), qcpmap_internal_default);
108 const int nx = 3, ny = 2;
111 std::vector<double> expected = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0};
112 data_item->setContent(expected);
114 colormap_item->setDataItem(data_item);
117 EXPECT_EQ(color_map->data()->keySize(), nx);
118 EXPECT_EQ(color_map->data()->valueSize(), ny);
119 EXPECT_EQ(color_map->data()->cell(0, 0), 1.0);
120 EXPECT_EQ(color_map->data()->cell(nx - 1, ny - 1), 6.0);
127 auto custom_plot = std::make_unique<QCustomPlot>();
133 const int nx = 3, ny = 2;
136 std::vector<double> expected = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0};
137 data_item->setContent(expected);
143 controller.
setItem(colormap_item);
145 auto color_map = TestUtils::GetPlottable<QCPColorMap>(custom_plot.get());
146 EXPECT_EQ(color_map->data()->keySize(), nx);
147 EXPECT_EQ(color_map->data()->valueSize(), ny);
150 colormap_item->setDataItem(
nullptr);
152 EXPECT_EQ(custom_plot->plottableCount(), 1);
155 EXPECT_EQ(color_map->data()->keySize(), 0);
156 EXPECT_EQ(color_map->data()->valueSize(), 0);
160 EXPECT_EQ(custom_plot->plottableCount(), 1);
161 EXPECT_EQ(color_map->data()->keySize(), 0);
162 EXPECT_EQ(color_map->data()->valueSize(), 0);
169 auto custom_plot = std::make_unique<QCustomPlot>();
170 auto controller = std::make_unique<ColorMapPlotController>(custom_plot.get());
178 colormap_item->setDataItem(data_item);
181 controller->setItem(colormap_item);
182 EXPECT_EQ(custom_plot->plottableCount(), 1);
186 EXPECT_EQ(custom_plot->plottableCount(), 0);
193 auto custom_plot = std::make_unique<QCustomPlot>();
194 auto controller = std::make_unique<ColorMapPlotController>(custom_plot.get());
202 colormap_item->setDataItem(data_item);
204 controller->setItem(colormap_item);
206 auto color_map = TestUtils::GetPlottable<QCPColorMap>(custom_plot.get());
208 EXPECT_EQ(color_map->gradient(), QCPColorGradient::gpPolar);
213 EXPECT_EQ(color_map->gradient(), QCPColorGradient::gpHot);
Testing ColorMapPlotController.
~ColorMapPlotControllerTest()
Two-dimensional color map representation of Data2DItem.
void setDataItem(const Data2DItem *item)
Sets link to the data item.
static const std::string P_GRADIENT
Establish communication between QCPColorMap and ColorMapItem.
Custom property to define list of string values with multiple selections.
void setValue(const std::string &name)
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)
T property(const std::string &tag) const
Returns data stored in property item.
void setProperty(const std::string &tag, const T &value)
Sets value to property 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(ColorMapPlotControllerTest, initialState)
Initial state.
materialitems.h Collection of materials to populate MaterialModel.