BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
customplot_test_utils.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // qt-mvvm: Model-view-view-model framework for large GUI applications
4 //
5 //! @file mvvm/tests/testview/customplot_test_utils.cpp
6 //! @brief Implements class CLASS?
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2020
11 //! @authors Gennady Pospelov et al, Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #include "customplot_test_utils.h"
16 #include <qcustomplot.h>
17 
18 std::vector<double> TestUtils::binCenters(const QCPGraph* graph)
19 {
20  return get_values(graph, [](auto x) { return x.key; });
21 }
22 
23 std::vector<double> TestUtils::binValues(const QCPGraph* graph)
24 {
25  return get_values(graph, [](auto x) { return x.value; });
26 }
27 
28 std::vector<double> TestUtils::binErrors(const QCPGraph* graph)
29 {
30  std::vector<double> result;
31  if (auto errorBars = GetPlottable<QCPErrorBars>(graph->parentPlot()); errorBars) {
32  auto container = errorBars->data();
33  std::transform(container->begin(), container->end(), std::back_inserter(result),
34  [](auto x) { return x.errorPlus; });
35  };
36  return result;
37 }
Defines class CLASS?
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.