15 #ifndef BORNAGAIN_MVVM_TESTS_TESTVIEW_CUSTOMPLOT_TEST_UTILS_H
16 #define BORNAGAIN_MVVM_TESTS_TESTVIEW_CUSTOMPLOT_TEST_UTILS_H
19 #include <qcustomplot.h>
28 template <
typename G,
typename T> std::vector<double>
get_values(
const G* graph, T operand)
30 std::vector<double> result;
31 auto graph_data = *graph->data();
32 std::transform(std::begin(graph_data), std::end(graph_data), std::back_inserter(result),
33 [operand](
const auto& point) {
return operand(point); });
38 std::vector<double>
binCenters(
const QCPGraph* graph);
41 std::vector<double>
binValues(
const QCPGraph* graph);
44 std::vector<double>
binErrors(
const QCPGraph* graph);
49 for (
int i = 0; i < custom_plot->plottableCount(); ++i) {
50 if (
auto plottable =
dynamic_cast<T*
>(custom_plot->plottable()); plottable)
57 Q_DECLARE_METATYPE(QCPRange)
Various common utils for unit tests.
std::vector< double > binValues(const QCPGraph *graph)
Returns vector representing y-values on QCPgraph.
std::vector< double > binErrors(const QCPGraph *graph)
Returns vector representing bin errors of QCPGraph.
std::vector< double > binCenters(const QCPGraph *graph)
Returns vector representing bin centers on QCPgraph.
std::vector< double > get_values(const G *graph, T operand)
Returns vector representing bin centers/values on QCPGraph.
T * GetPlottable(QCustomPlot *custom_plot)
Finds and returns specific plottable in QCustomPlot canvas.