BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
ProjectionsToolbar.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Projection/ProjectionsToolbar.cpp
6 //! @brief Implements class ProjectionsToolbar
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 <QButtonGroup>
19 #include <QLabel>
20 #include <QToolButton>
21 
22 namespace {
23 
24 const QString pan_zoom_tooltip = "Pan/zoom mode (space)\n"
25  "Drag axes with the mouse, use mouse wheel to zoom in/out";
26 
27 const QString reset_view_tooltip = "Reset view\nx,y,z axes range will be set to default";
28 
29 const QString selection_mode_tooltip =
30  "Selection mode\nYou can select existing projections and move them around";
31 
32 const QString horizontal_mode_tooltip =
33  "Horizontal projections mode\nCreate projection along x-axis by clicking on color map";
34 
35 const QString vertical_mode_tooltip =
36  "Vertical projections mode\nCreate projection along y-axis by clicking on color map";
37 
38 } // namespace
39 
41  : QToolBar(parent)
42  , m_editorActions(editorActions)
43  , m_activityButtonGroup(new QButtonGroup(this))
44 {
46  setProperty("_q_custom_style_disabled", QVariant(true));
47 
51 
52 #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
53  connect(m_activityButtonGroup, &QButtonGroup::idClicked, this,
55 #else
56  connect(m_activityButtonGroup,
57  static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), this,
59 #endif
60 
62 }
63 
64 void ProjectionsToolbar::onChangeActivityRequest(MaskEditorFlags::Activity value)
65 {
66  if (value == MaskEditorFlags::PREVIOUS_MODE)
68  else {
70  setCurrentActivity(value);
71  }
73 }
74 
75 //! Change activity only if current activity is one of drawing mode (horizontal, vertical
76 //! projections drawing).
77 void ProjectionsToolbar::onProjectionTabChange(MaskEditorFlags::Activity value)
78 {
82 }
83 
85 {
87 }
88 
90 {
91  auto* panButton = new QToolButton(this);
92  panButton->setIcon(QIcon(":/images/hand-right.svg"));
93  panButton->setToolTip(pan_zoom_tooltip);
94  panButton->setCheckable(true);
95  panButton->setChecked(true);
96  addWidget(panButton);
97 
98  auto* resetViewButton = new QToolButton(this);
99  resetViewButton->setIcon(QIcon(":/images/camera-metering-center.svg"));
100  resetViewButton->setToolTip(reset_view_tooltip);
101  addWidget(resetViewButton);
102  connect(resetViewButton, &QToolButton::clicked, m_editorActions,
104 
105  add_separator();
106 
107  auto* selectionButton = new QToolButton(this);
108  selectionButton->setIcon(QIcon(":/Mask/images/maskeditor_arrow.svg"));
109  selectionButton->setToolTip(selection_mode_tooltip);
110  selectionButton->setCheckable(true);
111  addWidget(selectionButton);
112 
114  m_activityButtonGroup->addButton(selectionButton, MaskEditorFlags::SELECTION_MODE);
115 }
116 
118 {
119  auto* horizontalLineButton = new QToolButton(this);
120  horizontalLineButton->setIcon(QIcon(":/Mask/images/maskeditor_horizontalline.svg"));
121  horizontalLineButton->setToolTip(horizontal_mode_tooltip);
122  horizontalLineButton->setCheckable(true);
123  addWidget(horizontalLineButton);
124 
125  auto* verticalLineButton = new QToolButton(this);
126  verticalLineButton->setIcon(QIcon(":/Mask/images/maskeditor_verticalline.svg"));
127  verticalLineButton->setToolTip(vertical_mode_tooltip);
128  verticalLineButton->setCheckable(true);
129  addWidget(verticalLineButton);
130 
131  m_activityButtonGroup->addButton(verticalLineButton, MaskEditorFlags::VERTICAL_LINE_MODE);
132  m_activityButtonGroup->addButton(horizontalLineButton, MaskEditorFlags::HORIZONTAL_LINE_MODE);
133 
134  add_separator();
135 }
136 
138 {
139  auto* saveButton = new QToolButton(this);
140  saveButton->setIcon(QIcon(":/Mask/images/maskeditor_save.svg"));
141  saveButton->setToolTip("Save created projections in multi-column ASCII file.");
142  addWidget(saveButton);
143  connect(saveButton, &QToolButton::clicked, m_editorActions,
145 }
146 
148 {
149  addWidget(new QLabel(" "));
150  addSeparator();
151  addWidget(new QLabel(" "));
152 }
153 
154 MaskEditorFlags::Activity ProjectionsToolbar::currentActivity() const
155 {
157 }
158 
159 void ProjectionsToolbar::setCurrentActivity(MaskEditorFlags::Activity value)
160 {
161  int button_index = static_cast<int>(value);
162  m_activityButtonGroup->button(button_index)->setChecked(true);
163 }
Defines class ProjectionsEditorActions.
Defines class ProjectionsToolbar.
Provides various actions for ProjectionsEditor.
void onSaveAction()
Performs saving of projections in ascii file.
ProjectionsEditorActions * m_editorActions
MaskEditorFlags::Activity currentActivity() const
void setCurrentActivity(MaskEditorFlags::Activity value)
void activityModeChanged(MaskEditorFlags::Activity)
void onProjectionTabChange(MaskEditorFlags::Activity value)
Change activity only if current activity is one of drawing mode (horizontal, vertical projections dra...
QButtonGroup * m_activityButtonGroup
MaskEditorFlags::Activity m_previousActivity
void onChangeActivityRequest(MaskEditorFlags::Activity value)
ProjectionsToolbar(ProjectionsEditorActions *editorActions, QWidget *parent=nullptr)
Defines namespace GUI::Constants.
const int toolbar_icon_size