BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
quicksimeditortoolbar.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file gui2/quicksimeditor/quicksimeditortoolbar.cpp
6 //! @brief Implements class CLASS?
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2020
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
17 #include <QAction>
18 #include <QCheckBox>
19 #include <QLabel>
20 #include <QProgressBar>
21 #include <QVBoxLayout>
22 
23 namespace gui2 {
24 
26  : QToolBar(parent), m_liveCheckbox(new QCheckBox), m_progressBar(new QProgressBar)
27 {
28  const int toolbar_icon_size = 24;
29  setIconSize(QSize(toolbar_icon_size, toolbar_icon_size));
30  setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
31 
34 
36 }
37 
38 //! Set progress bar to given value.
39 
41 {
42  m_progressBar->setValue(value);
43 }
44 
46 {
47  addWidget(new QLabel(" "));
48  addSeparator();
49  addWidget(new QLabel(" "));
50 }
51 
52 //! Setups elements to run simulation.
53 
55 {
56  // live check box and label
57  const QString live_tooltip = "Automatically run simulation and update plot\n"
58  "on any multilayer change.";
59  m_liveCheckbox->setCheckState(Constants::live_simulation_default_on ? Qt::Checked
60  : Qt::Unchecked);
61  m_liveCheckbox->setToolTip(live_tooltip);
62  auto on_check_state = [this](int state) { realTimeRequest(state == Qt::Checked); };
63  connect(m_liveCheckbox, &QCheckBox::stateChanged, on_check_state);
64  addWidget(m_liveCheckbox);
65  auto label = new QLabel("Live");
66  label->setToolTip(live_tooltip);
67  addWidget(label);
68 
69  // run simulation
70  auto run_action = new QAction("Run", this);
71  run_action->setIcon(QIcon(":/icons/play-circle-outline.svg"));
72  run_action->setToolTip("Run simulation for current multilayer state");
73  connect(run_action, &QAction::triggered, this, &QuickSimEditorToolBar::runSimulationRequest);
74  addAction(run_action);
75 
76  // progress bar
77  m_progressBar->setFixedWidth(150);
78  m_progressBar->setTextVisible(false);
79  addWidget(m_progressBar);
80 
81  // cancel simulation
82  auto cancel_action = new QAction("Cancel", this);
83  cancel_action->setIcon(QIcon(":/icons/close-circle-outline.svg"));
84  cancel_action->setToolTip("Cancel running simulation");
85  connect(cancel_action, &QAction::triggered, this, &QuickSimEditorToolBar::cancelPressed);
86  addAction(cancel_action);
87 }
88 
89 //! Setups actions to reset plot and access its settings.
90 
92 {
93  auto reset_view = new QAction("Replot", this);
94  reset_view->setToolTip("Set plot axes to default range");
95  reset_view->setIcon(QIcon(":/icons/aspect-ratio.svg"));
96  connect(reset_view, &QAction::triggered, this, &QuickSimEditorToolBar::resetViewRequest);
97  addAction(reset_view);
98 }
99 
100 } // namespace gui2
Defines class CLASS?
void setup_plot_elements()
Setups actions to reset plot and access its settings.
void setup_simulation_elements()
Setups elements to run simulation.
QuickSimEditorToolBar(QWidget *parent=nullptr)
void onProgressChanged(int value)
Set progress bar to given value.
const int toolbar_icon_size
const bool live_simulation_default_on
Initial state of some widgets.
Definition: app_constants.h:29
Based on Qt example "codeeditor" Copyright (C) 2016 The Qt Company Ltd.
Definition: app_constants.h:20
Defines class CLASS?