BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
ProjectionsEditor.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Projection/ProjectionsEditor.cpp
6 //! @brief Implements class ProjectionsEditor
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
23 #include <QBoxLayout>
24 #include <QItemSelectionModel>
25 #include <QSplitter>
26 
27 ProjectionsEditor::ProjectionsEditor(SessionItemWidget* upperSessionItemWidget, QWidget* parent)
28  : QMainWindow(parent)
29  , m_editorActions(new ProjectionsEditorActions(this))
30  , m_toolbar(new ProjectionsToolbar(m_editorActions))
31  , m_projectionsCanvas(new ProjectionsEditorCanvas)
32  , m_projectionsWidget(new ProjectionsWidget)
33  , m_propertyPanel(new IntensityDataPropertyWidget(
34  upperSessionItemWidget)) // here not "this", because IntensityDataPropertyWidget requires
35  // access to jobItem
36  , m_selectionModel(nullptr)
37 {
38  addToolBar(Qt::RightToolBarArea, m_toolbar);
39 
40  auto* splitter = new QSplitter;
41  splitter->setOrientation(Qt::Vertical);
42  splitter->addWidget(m_projectionsCanvas);
43  splitter->addWidget(m_projectionsWidget);
44 
45  auto* centralWidget = new QWidget(this);
46  auto* hLayout = new QHBoxLayout(centralWidget);
47  hLayout->setContentsMargins(0, 0, 0, 0);
48  hLayout->setSpacing(0);
49  hLayout->addWidget(splitter);
50  hLayout->addWidget(m_propertyPanel);
51 
52  setCentralWidget(centralWidget);
53 
54  m_propertyPanel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
55  m_propertyPanel->setHidden(true);
57 }
58 
59 void ProjectionsEditor::setContext(SessionModel* model, const QModelIndex& shapeContainerIndex,
60  IntensityDataItem* intensityItem)
61 {
62  Q_UNUSED(model);
63  Q_UNUSED(shapeContainerIndex);
64 
65  delete m_selectionModel;
66  m_selectionModel = new QItemSelectionModel(model, this);
67 
68  m_propertyPanel->setItem(intensityItem);
70  m_projectionsCanvas->setContext(model, shapeContainerIndex, intensityItem);
71  m_projectionsWidget->setItem(intensityItem);
72 
73  m_editorActions->setContext(model, shapeContainerIndex, intensityItem);
75 }
76 
78 {
79  m_propertyPanel->setItem(nullptr);
81  m_projectionsWidget->setItem(nullptr);
82 }
83 
85 {
87 }
88 
90 {
91  // tool panel request is propagated from editorActions to this MaskEditor
94 
95  // tool panel request is propagated from editorActions to this MaskEditor
97  [=]() { m_propertyPanel->setHidden(!m_propertyPanel->isHidden()); });
98 
99  // selection/drawing activity is propagated from Toolbar to graphics scene
102 
103  // selection/drawing activity is propagated from Toolbar to Projections Widget
106 
107  // click on projections tab is propagated to tool bar
110 
111  // Delete request is propagated from canvas to actions
114 
115  // space bar push (request for zoom mode) is propagated from graphics view to Toolbar
118 
119  // ColorMap margins changed, canvas -> projection widget
122 
124 }
Defines class IntensityDataItem.
Defines class IntensityDataPropertyWidget.
Defines class ProjectionsEditorActions.
Defines class ProjectionsEditorCanvas.
Defines class ProjectionsEditor.
Defines class ProjectionsToolbar.
Defines class ProjectionsWidget.
Defines class SessionModel.
Widget to edit properties of an IntensityDataItem.
void setItem(IntensityDataItem *mainItem, IntensityDataItem *realItem=nullptr)
Provides various actions for ProjectionsEditor.
void setContext(SessionModel *model, const QModelIndex &shapeContainerIndex, IntensityDataItem *intensityItem)
void setSelectionModel(QItemSelectionModel *selectionModel)
QList< QAction * > topToolbarActions()
Holds a graphics scene to draw projections on top of ColorMap. Being a part of ProjectionEditor,...
void setSelectionModel(QItemSelectionModel *model)
void onActivityModeChanged(MaskEditorFlags::Activity value)
void changeActivityRequest(MaskEditorFlags::Activity)
void setContext(SessionModel *model, const QModelIndex &shapeContainerIndex, IntensityDataItem *intensityItem)
void marginsChanged(double left, double right)
ProjectionsEditorCanvas * m_projectionsCanvas
main tool bar with bottoms at the right
ProjectionsEditor(SessionItemWidget *upperSessionItemWidget=nullptr, QWidget *parent=nullptr)
void setContext(SessionModel *model, const QModelIndex &shapeContainerIndex, IntensityDataItem *intensityItem)
IntensityDataPropertyWidget * m_propertyPanel
bottom widget to draw projections plot
QItemSelectionModel * m_selectionModel
panel at the right with properties
ProjectionsToolbar * m_toolbar
ProjectionsEditorActions * m_editorActions
QList< QAction * > topToolbarActions()
ProjectionsWidget * m_projectionsWidget
canvas with color map at the top
Toolbar with projections buttons (horizontal projections, vertical projections, select,...
void activityModeChanged(MaskEditorFlags::Activity)
void onProjectionTabChange(MaskEditorFlags::Activity value)
Change activity only if current activity is one of drawing mode (horizontal, vertical projections dra...
void onChangeActivityRequest(MaskEditorFlags::Activity value)
Holds tabs of vertical and horizontal projections, located at the bottom of ProjectionsEditor.
void changeActivityRequest(MaskEditorFlags::Activity value)
void onActivityModeChanged(MaskEditorFlags::Activity value)
void onMarginsChanged(double left, double right)
void setItem(SessionItem *intensityItem) override
The SessionItemWidget class is a base for all widgets representing the content of SessionItem....
Base class for a GUI data collection. A collection is e.g. all real data (RealDataModel)....
Definition: SessionModel.h:42