BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
MaskEditor.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Mask/MaskEditor.cpp
6 //! @brief Implements class MaskEditor
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 <QContextMenuEvent>
25 #include <QSplitter>
26 
27 MaskEditor::MaskEditor(QWidget* parent)
28  : QMainWindow(parent)
29  , m_editorActions(new MaskEditorActions(this))
30  , m_toolbar(new MaskEditorToolbar(m_editorActions))
31  , m_editorPropertyPanel(new MaskEditorPropertyPanel)
32  , m_editorCanvas(new MaskEditorCanvas)
33 {
34  setObjectName("MaskEditor");
35  setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
36 
37  auto* splitter = new QSplitter;
38  splitter->addWidget(m_editorCanvas);
39  splitter->addWidget(m_editorPropertyPanel);
40  splitter->setCollapsible(1, true);
41 
42  addToolBar(Qt::RightToolBarArea, m_toolbar);
43 
44  setCentralWidget(splitter);
45 
47 
49 }
50 
51 void MaskEditor::setMaskContext(SessionModel* model, const QModelIndex& maskContainerIndex,
52  IntensityDataItem* intensityItem)
53 {
54  m_editorPropertyPanel->setMaskContext(model, maskContainerIndex, intensityItem);
55 
56  ASSERT(intensityItem);
57  ASSERT(maskContainerIndex.isValid());
58  ASSERT(model->itemForIndex(maskContainerIndex)->modelType() == MaskContainerItem::M_TYPE);
59 
61  m_editorCanvas->setMaskContext(model, maskContainerIndex, intensityItem);
62 
63  m_editorActions->setModel(model, maskContainerIndex);
65 }
66 
68 {
71 }
72 
73 //! shows/hides right panel with properties
75 {
77 }
78 
79 //! Context menu reimplemented to supress default menu
80 void MaskEditor::contextMenuEvent(QContextMenuEvent* event)
81 {
82  Q_UNUSED(event);
83 }
84 
85 //! Returns list of actions intended for styled toolbar (on the top).
86 
88 {
90 }
91 
93 {
94  // reset view request is propagated from editorActions to graphics view
97 
98  // tool panel request is propagated from editorActions to this MaskEditor
101 
102  // save plot request is propagated from editorActions to graphics scene
105 
106  // selection/drawing activity is propagated from Toolbar to graphics scene
109 
110  // mask value is propagated from Toolbar to graphics scene
113 
114  // show results request is propagated from Toolbar to Canvas
117 
118  // space bar push (request for zoom mode) is propagated from graphics view to Toolbar
121 
122  // Delete request is propagated from canvas to actions
125 
126  // context menu request is propagated from graphics scene to MaskEditorActions
129 
130  // context menu request is propagated from PropertyPanel to MaskEditorActions
133 }
Defines class MaskEditorActions.
Defines class MaskEditorCanvas.
Defines class MaskEditorPropertyPanel.
Defines class MaskEditorToolbar.
Defines class MaskEditor.
Defines class MaskGraphicsScene.
Defines MaskItems classes.
Defines class SessionModel.
static constexpr auto M_TYPE
Definition: MaskItems.h:204
Defines actions for MaskEditor which are related to selected MaskItem (toggle mask value,...
QList< QAction * > topToolbarActions()
void propertyPanelRequest()
void onItemContextMenuRequest(const QPoint &point)
Constructs MaskItem context menu following the request from MaskGraphicsScene or MaskEditorInfoPanel.
void setModel(SessionModel *maskModel, const QModelIndex &rootIndex)
void setSelectionModel(QItemSelectionModel *selectionModel)
Painting widget for MaskEditor, contains graphics scene and graphics view.
void deleteSelectedRequest()
void onSavePlotRequest()
Saves plot into project directory.
void changeActivityRequest(MaskEditorFlags::Activity)
MaskGraphicsScene * getScene()
void onPresentationTypeRequest(MaskEditorFlags::PresentationType presentationType)
void setSelectionModel(QItemSelectionModel *model)
void setMaskContext(SessionModel *model, const QModelIndex &maskContainerIndex, IntensityDataItem *intensityItem)
Tool widget for MaskEditor.
void setPanelHidden(bool hidden)
Show/Hide panel. When panel is hidden, all property editors are disabled.
void itemContextMenuRequest(const QPoint &point)
void setMaskContext(SessionModel *model, const QModelIndex &maskContainerIndex, IntensityDataItem *intensityItem)
QItemSelectionModel * selectionModel()
Main class to draw masks on top of intensity data map.
void maskValueChanged(MaskEditorFlags::MaskValue)
void activityModeChanged(MaskEditorFlags::Activity)
void onChangeActivityRequest(MaskEditorFlags::Activity value)
Handles ZOOM requests from MaskGraphicsView while user press and holds space bar. As soon as space ba...
void presentationTypeRequest(MaskEditorFlags::PresentationType)
MaskEditorCanvas * m_editorCanvas
Definition: MaskEditor.h:59
void resetContext()
Definition: MaskEditor.cpp:67
void onPropertyPanelRequest()
shows/hides right panel with properties
Definition: MaskEditor.cpp:74
QList< QAction * > topToolbarActions()
Returns list of actions intended for styled toolbar (on the top).
Definition: MaskEditor.cpp:87
MaskEditor(QWidget *parent=nullptr)
Definition: MaskEditor.cpp:27
MaskEditorToolbar * m_toolbar
Definition: MaskEditor.h:57
void setup_connections()
Definition: MaskEditor.cpp:92
MaskEditorActions * m_editorActions
Definition: MaskEditor.h:56
void setMaskContext(SessionModel *model, const QModelIndex &maskContainerIndex, IntensityDataItem *intensityItem)
Main method to setup context for mask editing.
Definition: MaskEditor.cpp:51
void contextMenuEvent(QContextMenuEvent *event) override
Context menu reimplemented to supress default menu.
Definition: MaskEditor.cpp:80
MaskEditorPropertyPanel * m_editorPropertyPanel
Definition: MaskEditor.h:58
void onMaskValueChanged(MaskEditorFlags::MaskValue value)
void itemContextMenuRequest(const QPoint &point)
void onActivityModeChanged(MaskEditorFlags::Activity value)
QString modelType() const
Get model type.
Base class for a GUI data collection. A collection is e.g. all real data (RealDataModel)....
Definition: SessionModel.h:42
SessionItem * itemForIndex(const QModelIndex &index) const