BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
ProjectionsEditorActions.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Projection/ProjectionsEditorActions.cpp
6 //! @brief Implements class ProjectionsEditorActions
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 
18 #include <QAction>
19 #include <QItemSelectionModel>
20 #include <QModelIndexList>
21 
23  : QObject(parent)
24  , m_resetViewAction(new QAction(this))
25  , m_togglePanelAction(new QAction(this))
26  , m_deleteAction(new QAction("Remove selected", this))
27  , m_model(nullptr)
28  , m_intensityDataItem(nullptr)
29  , m_selectionModel(nullptr)
30  , m_parent(parent)
31 {
32  // Actions for top toolbar
33  m_resetViewAction->setText("Center view");
34  m_resetViewAction->setIcon(QIcon(":/images/camera-metering-center.svg"));
35  m_resetViewAction->setToolTip("Reset view\n"
36  "x,y,z axes range will be set to default");
37  connect(m_resetViewAction, &QAction::triggered, this,
39 
40  m_togglePanelAction->setText("Properties");
41  m_togglePanelAction->setIcon(QIcon(":/images/dock-right.svg"));
42  m_togglePanelAction->setToolTip("Toggle property panel");
43  connect(m_togglePanelAction, &QAction::triggered, this,
45 
46  m_deleteAction->setToolTip("Remove selected (Del)");
47  m_deleteAction->setShortcuts(QKeySequence::Delete);
48  connect(m_deleteAction, &QAction::triggered, this, &ProjectionsEditorActions::onDeleteAction);
49 }
50 
51 void ProjectionsEditorActions::setContext(SessionModel* model, const QModelIndex& containerIndex,
52  IntensityDataItem* intensityItem)
53 {
54  m_model = model;
55  m_containerIndex = containerIndex;
56  m_intensityDataItem = intensityItem;
57 }
58 
59 void ProjectionsEditorActions::setSelectionModel(QItemSelectionModel* selectionModel)
60 {
61  m_selectionModel = selectionModel;
62 }
63 
65 {
66  return QList<QAction*>() << m_resetViewAction << m_togglePanelAction;
67 }
68 
70 {
71  ASSERT(m_model);
72  ASSERT(m_selectionModel);
73 
74  QModelIndexList indexes = m_selectionModel->selectedIndexes();
75  while (!indexes.empty()) {
76  m_model->removeRows(indexes.back().row(), 1, indexes.back().parent());
77  indexes = m_selectionModel->selectedIndexes();
78  }
79 }
80 
81 //! Performs saving of projections in ascii file
83 {
85  return;
86 
87  SaveProjectionsAssistant assistant;
89 }
Defines class ProjectionsEditorActions.
Defines class SaveProjectionsAssistant.
Defines class SessionModel.
void setContext(SessionModel *model, const QModelIndex &shapeContainerIndex, IntensityDataItem *intensityItem)
void setSelectionModel(QItemSelectionModel *selectionModel)
QList< QAction * > topToolbarActions()
IntensityDataItem * m_intensityDataItem
QModelIndex m_containerIndex
Index of container with projections.
ProjectionsEditorActions(QWidget *parent=nullptr)
void onSaveAction()
Performs saving of projections in ascii file.
QItemSelectionModel * m_selectionModel
Assistant class which save all projections of IndensityDataItem into ASCII file.
void saveProjections(QWidget *parent, IntensityDataItem *intensityItem)
Calls file open dialog and writes projection data as ASCII.
Base class for a GUI data collection. A collection is e.g. all real data (RealDataModel)....
Definition: SessionModel.h:42
bool removeRows(int row, int count, const QModelIndex &parent) override