BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
colormapviewportplotcontroller.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/view/mvvm/plotting/colormapviewportplotcontroller.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 
22 #include <list>
23 #include <qcustomplot.h>
24 
25 using namespace ModelView;
26 
29  QCustomPlot* m_customPlot{nullptr};
30  QCPColorScale* m_colorScale{nullptr};
31  std::unique_ptr<ViewportAxisPlotController> m_xAxisController;
32  std::unique_ptr<ViewportAxisPlotController> m_yAxisController;
33  std::unique_ptr<ColorScalePlotController> m_colorScaleController;
34  std::unique_ptr<ColorMapPlotController> m_colorMapController;
35 
37  : m_self(master), m_customPlot(plot), m_colorScale(new QCPColorScale(m_customPlot))
38  {
39  m_xAxisController = std::make_unique<ViewportAxisPlotController>(m_customPlot->xAxis);
40  m_yAxisController = std::make_unique<ViewportAxisPlotController>(m_customPlot->yAxis);
41  m_colorScaleController = std::make_unique<ColorScalePlotController>(m_colorScale);
42  m_colorMapController = std::make_unique<ColorMapPlotController>(m_customPlot, m_colorScale);
43  }
44 
46 
47  //! Setup controller components.
48 
50  {
51  auto viewport = viewportItem();
52  m_xAxisController->setItem(viewport->xAxis());
53  m_yAxisController->setItem(viewport->yAxis());
54  m_colorScaleController->setItem(viewport->zAxis());
56  m_colorMapController->setItem(colormap_item);
58  }
59 
61  {
62  m_xAxisController->setItem(nullptr);
63  m_yAxisController->setItem(nullptr);
64  m_colorScaleController->setItem(nullptr);
65  m_colorMapController->setItem(nullptr);
66  }
67 };
68 
70  : p_impl(std::make_unique<ColorMapViewportPlotControllerImpl>(this, custom_plot))
71 {
72 }
73 
75 {
76  auto on_item_inserted = [this](SessionItem*, TagRow) { p_impl->setup_components(); };
77  setOnItemInserted(on_item_inserted);
78 
79  p_impl->setup_components();
80 }
81 
83 {
84  p_impl->unsubscribe_components();
85 }
86 
Defines class CLASS?
Two-dimensional color map representation of Data2DItem.
Definition: colormapitem.h:28
Container with viewport and collection of ColorMapItem's to plot.
void setViewportToContent() override
Sets range of x,y window to show all data.
Establishes communications and mutual updates for ColorMapViewportItem and QCutomPlot.
std::unique_ptr< ColorMapViewportPlotControllerImpl > p_impl
void unsubscribe() override
For necessary manipulations on new item.
void setOnItemInserted(Callbacks::item_tagrow_t f)
Sets callback to be notified on child insertion.
The main object representing an editable/displayable/serializable entity.
Definition: sessionitem.h:38
T * item(const std::string &tag) const
Returns first item under given tag casted to a specified type.
Definition: sessionitem.h:156
Aggregate to hold (tag, row) information for SessionModel.
Definition: tagrow.h:25
static const std::string T_ITEMS
Definition: viewportitem.h:31
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
materialitems.h Collection of materials to populate MaterialModel.
Definition: filesystem.h:81
ColorMapViewportPlotControllerImpl(ColorMapViewportPlotController *master, QCustomPlot *plot)
Defines class CLASS?