BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
gui2::GraphicsScene Class Reference

Custom graphics scene to show QCustomPlot with additional elements on top. More...

Inheritance diagram for gui2::GraphicsScene:
[legend]
Collaboration diagram for gui2::GraphicsScene:
[legend]

Public Member Functions

 GraphicsScene (QObject *parent=nullptr)
 The contructor. More...
 
 ~GraphicsScene () override
 The destructor. More...
 
ModelView::GraphCanvasgraphCanvas () const
 Set te graph canvas item. More...
 
ModelView::SceneAdapterInterfacesceneAdapter () const
 Return the pointer of the scene adapter on request. More...
 
void setContext ()
 Initialise the GraphicsScene with its elements. More...
 
void setItem (ModelView::GraphViewportItem *viewport_item)
 Set te graph canvas item. More...
 
void update_size (const QSize &newSize)
 Adjust size of scene and color map proxy. More...
 

Private Member Functions

void createPlotProxy (ModelView::GraphCanvas *plot_canvas)
 Create the Proxy item. More...
 

Private Attributes

ModelView::GraphCanvasgraph_canvas {nullptr}
 
ModelView::CustomPlotProxyWidgetplot_proxy {nullptr}
 
std::unique_ptr< ModelView::SceneAdapterInterfacescene_adapter
 

Detailed Description

Custom graphics scene to show QCustomPlot with additional elements on top.

Definition at line 34 of file graphicsscene.h.

Constructor & Destructor Documentation

◆ GraphicsScene()

gui2::GraphicsScene::GraphicsScene ( QObject *  parent = nullptr)

The contructor.

Definition at line 32 of file graphicsscene.cpp.

32  : QGraphicsScene(parent)
33 {
34  setItemIndexMethod(QGraphicsScene::NoIndex);
35  setSceneRect(default_scene_rect);
36  setContext();
37 }
void setContext()
Initialise the GraphicsScene with its elements.

References setContext().

Here is the call graph for this function:

◆ ~GraphicsScene()

gui2::GraphicsScene::~GraphicsScene ( )
overridedefault

The destructor.

Member Function Documentation

◆ createPlotProxy()

void gui2::GraphicsScene::createPlotProxy ( ModelView::GraphCanvas plot_canvas)
private

Create the Proxy item.

Definition at line 74 of file graphicsscene.cpp.

75 {
76  scene_adapter = plot_canvas->createSceneAdapter();
78  addItem(plot_proxy);
79 }
Custom proxy widget to embed color map in graphics scene.
std::unique_ptr< SceneAdapterInterface > createSceneAdapter() const
ModelView::CustomPlotProxyWidget * plot_proxy
Definition: graphicsscene.h:49
std::unique_ptr< ModelView::SceneAdapterInterface > scene_adapter
Definition: graphicsscene.h:50

References ModelView::GraphCanvas::createSceneAdapter(), plot_proxy, and scene_adapter.

Referenced by setContext().

Here is the call graph for this function:

◆ graphCanvas()

ModelView::GraphCanvas * gui2::GraphicsScene::graphCanvas ( ) const

Set te graph canvas item.

Definition at line 56 of file graphicsscene.cpp.

57 {
58  return graph_canvas;
59 }
ModelView::GraphCanvas * graph_canvas
Definition: graphicsscene.h:51

References graph_canvas.

Referenced by gui2::SLDEditor::SLDEditor().

◆ sceneAdapter()

ModelView::SceneAdapterInterface * gui2::GraphicsScene::sceneAdapter ( ) const

Return the pointer of the scene adapter on request.

Definition at line 82 of file graphicsscene.cpp.

83 {
84  return scene_adapter.get();
85 }

References scene_adapter.

Referenced by gui2::ElementView::sceneAdapter(), and gui2::LayerElementController::sceneAdapter().

◆ setContext()

void gui2::GraphicsScene::setContext ( )

Initialise the GraphicsScene with its elements.

Definition at line 43 of file graphicsscene.cpp.

44 {
47 }
Widget to show scientific figure with multiple 1D graphs.
Definition: graphcanvas.h:30
void createPlotProxy(ModelView::GraphCanvas *plot_canvas)
Create the Proxy item.

References createPlotProxy(), and graph_canvas.

Referenced by GraphicsScene().

Here is the call graph for this function:

◆ setItem()

void gui2::GraphicsScene::setItem ( ModelView::GraphViewportItem viewport_item)

Set te graph canvas item.

Definition at line 50 of file graphicsscene.cpp.

51 {
52  graph_canvas->setItem(viewport_item);
53 }
void setItem(GraphViewportItem *viewport_item)

References graph_canvas, and ModelView::GraphCanvas::setItem().

Here is the call graph for this function:

◆ update_size()

void gui2::GraphicsScene::update_size ( const QSize &  newSize)

Adjust size of scene and color map proxy.

Definition at line 62 of file graphicsscene.cpp.

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 }

References plot_proxy.

Referenced by gui2::SLDViewWidget::resizeEvent().

Member Data Documentation

◆ graph_canvas

ModelView::GraphCanvas* gui2::GraphicsScene::graph_canvas {nullptr}
private

Definition at line 51 of file graphicsscene.h.

Referenced by graphCanvas(), setContext(), and setItem().

◆ plot_proxy

ModelView::CustomPlotProxyWidget* gui2::GraphicsScene::plot_proxy {nullptr}
private

Definition at line 49 of file graphicsscene.h.

Referenced by createPlotProxy(), and update_size().

◆ scene_adapter

std::unique_ptr<ModelView::SceneAdapterInterface> gui2::GraphicsScene::scene_adapter
private

Definition at line 50 of file graphicsscene.h.

Referenced by createPlotProxy(), and sceneAdapter().


The documentation for this class was generated from the following files: