BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
graphicsscene.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file gui2/sldeditor/graphicsscene.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 Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
16 
17 #include "mvvm/model/modelutils.h"
22 
23 namespace {
24 const double scene_origin_x{0.0};
25 const double scene_origin_y{0.0};
26 const QRectF default_scene_rect{QPointF{scene_origin_x, scene_origin_y}, QSizeF{800, 600}};
27 } // namespace
28 
29 namespace gui2 {
30 
31 //! The contructor
32 GraphicsScene::GraphicsScene(QObject* parent) : QGraphicsScene(parent)
33 {
34  setItemIndexMethod(QGraphicsScene::NoIndex);
35  setSceneRect(default_scene_rect);
36  setContext();
37 }
38 
39 //! The destructor
41 
42 //! Initialise the GraphicsScene with its elements
44 {
47 }
48 
49 //! Set te graph canvas item
51 {
52  graph_canvas->setItem(viewport_item);
53 }
54 
55 //! Set te graph canvas item
57 {
58  return graph_canvas;
59 }
60 
61 //! Adjust size of scene and color map proxy.
62 void GraphicsScene::update_size(const QSize& newSize)
63 {
64  if (plot_proxy) {
65  plot_proxy->resize(newSize);
66  setSceneRect(scene_origin_x, scene_origin_y, newSize.width(), newSize.height());
67  plot_proxy->setPos(0.0, 0.0);
68  advance(); // notifies all QGraphicsItem that it is time to replot themself using new status
69  // of scene adapter
70  }
71 }
72 
73 //! Create the Proxy item
75 {
76  scene_adapter = plot_canvas->createSceneAdapter();
78  addItem(plot_proxy);
79 }
80 
81 //! Return the pointer of the scene adapter on request
83 {
84  return scene_adapter.get();
85 }
86 
87 } // namespace gui2
Custom proxy widget to embed color map in graphics scene.
Widget to show scientific figure with multiple 1D graphs.
Definition: graphcanvas.h:30
void setItem(GraphViewportItem *viewport_item)
std::unique_ptr< SceneAdapterInterface > createSceneAdapter() const
2D viewport specialized for showing multiple GraphItem's.
Interface to convert coordinates of "scene" to coordinates of "widget".
ModelView::GraphCanvas * graphCanvas() const
Set te graph canvas item.
~GraphicsScene() override
The destructor.
void setItem(ModelView::GraphViewportItem *viewport_item)
Set te graph canvas item.
ModelView::CustomPlotProxyWidget * plot_proxy
Definition: graphicsscene.h:49
void update_size(const QSize &newSize)
Adjust size of scene and color map proxy.
GraphicsScene(QObject *parent=nullptr)
The contructor.
ModelView::GraphCanvas * graph_canvas
Definition: graphicsscene.h:51
std::unique_ptr< ModelView::SceneAdapterInterface > scene_adapter
Definition: graphicsscene.h:50
ModelView::SceneAdapterInterface * sceneAdapter() const
Return the pointer of the scene adapter on request.
void setContext()
Initialise the GraphicsScene with its elements.
void createPlotProxy(ModelView::GraphCanvas *plot_canvas)
Create the Proxy item.
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
Based on Qt example "codeeditor" Copyright (C) 2016 The Qt Company Ltd.
Definition: app_constants.h:20
Defines class CLASS?