BornAgain  1.19.0
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/coregui/Views/JobWidgets/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 const QString pan_zoom_tooltip = "Pan/zoom mode (space)\n"
24  "Drag axes with the mouse, use mouse wheel to zoom in/out";
25 
26 const QString reset_view_tooltip = "Reset view\nx,y,z axes range will be set to default";
27 
28 const QString selection_mode_tooltip =
29  "Selection mode\nYou can select existing projections and move them around";
30 
31 const QString horizontal_mode_tooltip =
32  "Horizontal projections mode\nCreate projection along x-axis by clicking on color map";
33 
34 const QString vertical_mode_tooltip =
35  "Vertical projections mode\nCreate projection along y-axis by clicking on color map";
36 
37 } // namespace
38 
40  : QToolBar(parent)
41  , m_editorActions(editorActions)
42  , m_activityButtonGroup(new QButtonGroup(this))
43 {
45  setProperty("_q_custom_style_disabled", QVariant(true));
46 
50 
51 #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
52  connect(m_activityButtonGroup, &QButtonGroup::idClicked, this,
54 #else
55  connect(m_activityButtonGroup,
56  static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), this,
58 #endif
59 
61 }
62 
63 void ProjectionsToolBar::onChangeActivityRequest(MaskEditorFlags::Activity value)
64 {
65  if (value == MaskEditorFlags::PREVIOUS_MODE) {
67  } else {
69  setCurrentActivity(value);
70  }
72 }
73 
74 //! Change activity only if current activity is one of drawing mode (horizontal, vertical
75 //! projections drawing).
76 void ProjectionsToolBar::onProjectionTabChange(MaskEditorFlags::Activity value)
77 {
81 }
82 
84 {
86 }
87 
89 {
90  auto panButton = new QToolButton(this);
91  panButton->setIcon(QIcon(":/images/hand-right.svg"));
92  panButton->setToolTip(pan_zoom_tooltip);
93  panButton->setCheckable(true);
94  panButton->setChecked(true);
95  addWidget(panButton);
96 
97  auto resetViewButton = new QToolButton(this);
98  resetViewButton->setIcon(QIcon(":/images/camera-metering-center.svg"));
99  resetViewButton->setToolTip(reset_view_tooltip);
100  addWidget(resetViewButton);
101  connect(resetViewButton, &QToolButton::clicked, m_editorActions,
103 
104  add_separator();
105 
106  QToolButton* selectionButton = new QToolButton(this);
107  selectionButton->setIcon(QIcon(":/MaskWidgets/images/maskeditor_arrow.svg"));
108  selectionButton->setToolTip(selection_mode_tooltip);
109  selectionButton->setCheckable(true);
110  addWidget(selectionButton);
111 
113  m_activityButtonGroup->addButton(selectionButton, MaskEditorFlags::SELECTION_MODE);
114 }
115 
117 {
118  auto horizontalLineButton = new QToolButton(this);
119  horizontalLineButton->setIcon(QIcon(":/MaskWidgets/images/maskeditor_horizontalline.svg"));
120  horizontalLineButton->setToolTip(horizontal_mode_tooltip);
121  horizontalLineButton->setCheckable(true);
122  addWidget(horizontalLineButton);
123 
124  auto verticalLineButton = new QToolButton(this);
125  verticalLineButton->setIcon(QIcon(":/MaskWidgets/images/maskeditor_verticalline.svg"));
126  verticalLineButton->setToolTip(vertical_mode_tooltip);
127  verticalLineButton->setCheckable(true);
128  addWidget(verticalLineButton);
129 
130  m_activityButtonGroup->addButton(verticalLineButton, MaskEditorFlags::VERTICAL_LINE_MODE);
131  m_activityButtonGroup->addButton(horizontalLineButton, MaskEditorFlags::HORIZONTAL_LINE_MODE);
132 
133  add_separator();
134 }
135 
137 {
138  auto saveButton = new QToolButton(this);
139  saveButton->setIcon(QIcon(":/MaskWidgets/images/maskeditor_save.svg"));
140  saveButton->setToolTip("Save created projections in multi-column ASCII file.");
141  addWidget(saveButton);
142  connect(saveButton, &QToolButton::clicked, m_editorActions,
144 }
145 
147 {
148  addWidget(new QLabel(" "));
149  addSeparator();
150  addWidget(new QLabel(" "));
151 }
152 
153 MaskEditorFlags::Activity ProjectionsToolBar::currentActivity() const
154 {
156 }
157 
158 void ProjectionsToolBar::setCurrentActivity(MaskEditorFlags::Activity value)
159 {
160  int button_index = static_cast<int>(value);
161  m_activityButtonGroup->button(button_index)->setChecked(true);
162 }
Defines class ProjectionsEditorActions.
Defines class ProjectionsToolBar.
Provides various actions for ProjectionsEditor.
void onSaveAction()
Performs saving of projections in ascii file.
QButtonGroup * m_activityButtonGroup
MaskEditorFlags::Activity m_previousActivity
ProjectionsToolBar(ProjectionsEditorActions *editorActions, QWidget *parent=0)
void onProjectionTabChange(MaskEditorFlags::Activity value)
Change activity only if current activity is one of drawing mode (horizontal, vertical projections dra...
void setCurrentActivity(MaskEditorFlags::Activity value)
MaskEditorFlags::Activity currentActivity() const
ProjectionsEditorActions * m_editorActions
void activityModeChanged(MaskEditorFlags::Activity)
void onChangeActivityRequest(MaskEditorFlags::Activity value)
Defines namespace Constants.
const int toolbar_icon_size