BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
sldviewwidget.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file gui2/sldeditor/sldviewwidget.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 
17 #include "gui2/model/jobmodel.h"
20 #include <QResizeEvent>
21 
22 namespace gui2 {
23 
24 //! The constructor
25 SLDViewWidget::SLDViewWidget(QWidget* parent) : QGraphicsView(parent)
26 {
27  GraphicsScene* scene_item = new GraphicsScene(parent = this);
28  setScene(scene_item);
29  setRenderHints(QPainter::Antialiasing);
30  setDragMode(QGraphicsView::ScrollHandDrag);
31  setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
32  setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
33  setContentsMargins(0, 0, 0, 0);
34 }
35 
36 //! The destructor
38 
40 {
41  m_sld_controller = std::make_unique<SLDElementController>(
42  models->materialModel(), models->sampleModel(), models->sldViewModel(), nullptr);
43  m_sld_controller->setScene(dynamic_cast<GraphicsScene*>(scene()));
44  dynamic_cast<GraphicsScene*>(scene())->setItem(models->jobModel()->sldViewport());
45 }
46 
47 //! Resize event management
48 void SLDViewWidget::resizeEvent(QResizeEvent* event)
49 {
50  QWidget::resizeEvent(event);
51  GraphicsScene* scene_item = static_cast<GraphicsScene*>(scene());
52  scene_item->update_size(event->size());
53 }
54 
55 } // namespace gui2
Defines class CLASS?
Main class to holds all models of GUI session.
SLDElementModel * sldViewModel()
MaterialModel * materialModel()
Custom graphics scene to show QCustomPlot with additional elements on top.
Definition: graphicsscene.h:34
void update_size(const QSize &newSize)
Adjust size of scene and color map proxy.
ModelView::GraphViewportItem * sldViewport() const
Definition: jobmodel.cpp:49
SLDViewWidget(QWidget *parent=nullptr)
The constructor.
std::unique_ptr< SLDElementController > m_sld_controller
Definition: sldviewwidget.h:41
void resizeEvent(QResizeEvent *event)
Resize event management.
void setModels(ApplicationModels *models)
~SLDViewWidget()
The destructor.
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?
Defines class CLASS?