24 #include "qcustomplot.h"
42 auto custom_plot = std::make_unique<QCustomPlot>();
45 EXPECT_EQ(custom_plot->graphCount(), 0);
52 auto custom_plot = std::make_unique<QCustomPlot>();
59 std::vector<double> expected_centers = {0.5, 1.5};
60 std::vector<double> expected_values = {42.0, 43.0};
61 data_item->setValues(expected_values);
71 EXPECT_EQ(custom_plot->graphCount(), 1);
72 auto graph = custom_plot->graph();
75 EXPECT_EQ(graph->pen().color(), QColor(Qt::black));
76 EXPECT_EQ(graph->pen().style(), Qt::SolidLine);
77 EXPECT_EQ(graph->pen().width(), 1);
82 auto custom_plot = std::make_unique<QCustomPlot>();
89 std::vector<double> expected_centers = {0.5, 1.5};
90 std::vector<double> expected_values = {42.0, 43.0};
91 data_item->setValues(expected_values);
101 auto pen_item = graph_item->penItem();
109 auto graph = custom_plot->graph();
110 EXPECT_EQ(graph->pen().color(), QColor(Qt::red));
111 EXPECT_EQ(graph->pen().style(), Qt::DashLine);
112 EXPECT_EQ(graph->pen().width(), 2);
120 auto custom_plot = std::make_unique<QCustomPlot>();
124 const std::vector<double> expected_centers = {1.0, 2.0, 3.0};
125 const std::vector<double> expected_values = {42.0, 43.0, 44.0};
130 data_item->setValues(expected_values);
134 auto pen_item = graph_item->
penItem();
136 graph_item->setDataItem(data_item);
139 controller.
setItem(graph_item);
142 EXPECT_EQ(custom_plot->graphCount(), 1);
143 auto graph = custom_plot->graph();
146 EXPECT_EQ(graph->pen().color(), QColor(Qt::red));
153 auto custom_plot = std::make_unique<QCustomPlot>();
159 controller.
setItem(graph_item);
162 EXPECT_EQ(custom_plot->graphCount(), 1);
163 auto graph = custom_plot->graph();
170 std::vector<double> expected_centers = {0.5, 1.5};
171 std::vector<double> expected_values = {42.0, 43.0};
172 data_item->setValues(expected_values);
174 graph_item->setDataItem(data_item);
177 EXPECT_EQ(custom_plot->graphCount(), 1);
186 auto custom_plot = std::make_unique<QCustomPlot>();
193 std::vector<double> expected_centers = {0.5, 1.5};
194 std::vector<double> expected_values = {42.0, 43.0};
195 data_item->setValues(expected_values);
199 auto pen_item = graph_item->
penItem();
201 graph_item->setDataItem(data_item);
204 controller.
setItem(graph_item);
207 graph_item->setDataItem(
nullptr);
211 EXPECT_EQ(custom_plot->graphCount(), 1);
212 auto graph = custom_plot->graph();
215 EXPECT_EQ(graph->pen().color(), QColor(Qt::red));
219 EXPECT_EQ(custom_plot->graphCount(), 0);
226 auto custom_plot = std::make_unique<QCustomPlot>();
227 auto controller = std::make_unique<GraphPlotController>(custom_plot.get());
235 graph_item->setDataItem(data_item);
238 controller->setItem(graph_item);
239 EXPECT_EQ(custom_plot->graphCount(), 1);
243 EXPECT_EQ(custom_plot->graphCount(), 0);
250 auto custom_plot = std::make_unique<QCustomPlot>();
251 auto controller = std::make_unique<GraphPlotController>(custom_plot.get());
259 graph_item->setDataItem(data_item);
262 controller->setItem(graph_item);
263 EXPECT_EQ(custom_plot->graphCount(), 1);
266 EXPECT_EQ(custom_plot->graphCount(), 0);
Testing GraphPlotController.
~GraphPlotControllerTest()
Custom property to define list of string values with multiple selections.
void setCurrentIndex(int index)
Represents one-dimensional data (axis and values).
T * setAxis(Args &&... args)
Inserts axis of given type.
Item to represent fixed bin axis.
One-dimensional graph representation of Data1DItem.
void setDataItem(const Data1DItem *item)
Sets link to the data item.
PenItem * penItem() const
Establish communication between QCPGraph and GraphItem.
void setItem(SessionItem *item)
static const std::string P_STYLE
static const std::string P_COLOR
static const std::string P_WIDTH
Item to represent pointwise axis.
SessionItem * parent() const
Returns parent item. Will return nullptr if item doesn't have a parent.
TagRow tagRow() const
Returns TagRow of this item under which it is accessible through its parent.
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.
void removeItem(SessionItem *parent, const TagRow &tagrow)
Removes given row from parent.
TEST_F(GraphPlotControllerTest, initialState)
Initial state.
materialitems.h Collection of materials to populate MaterialModel.
std::vector< double > binValues(const QCPGraph *graph)
Returns vector representing y-values on QCPgraph.
std::vector< double > binCenters(const QCPGraph *graph)
Returns vector representing bin centers on QCPgraph.