BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
RealSpacePanel.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/SampleDesigner/RealSpacePanel.cpp
6 //! @brief Implements class RealSpacePanel
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2021
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
18 #include <QVBoxLayout>
19 
21  : QWidget(parent)
22  , m_canvas(new RealSpaceCanvas)
23 {
24  setWindowTitle("Real Space");
25 
26  auto* toolbar = new StyledToolbar(this);
27 
28  const auto createAction = [&](const QString& text, const QString& tooltip) -> QAction* {
29  auto* action = new QAction(text, this);
30  action->setToolTip(tooltip);
31  if (!toolbar->actions().empty())
32  toolbar->addSeparator();
33  toolbar->addAction(action);
34  return action;
35  };
36 
37  auto* action = createAction("Save Picture", "Save 3D real space view as .png file");
38  connect(action, &QAction::triggered, m_canvas, QOverload<>::of(&RealSpaceCanvas::savePicture));
39 
40  action = createAction("Default View", "Reset view and zoom level to default");
41  connect(action, &QAction::triggered, m_canvas, &RealSpaceCanvas::defaultView);
42 
43  action = createAction("Side View", "View sample from the side at current zoom level");
44  connect(action, &QAction::triggered, m_canvas, &RealSpaceCanvas::sideView);
45 
46  action = createAction("Top View", "View sample from the top at current zoom level");
47  connect(action, &QAction::triggered, m_canvas, &RealSpaceCanvas::topView);
48 
49  action = createAction("Enlarge", "Increase layer size");
50  connect(action, &QAction::triggered, [this]() { m_canvas->changeLayerSize(1.25); });
51 
52  action = createAction("Reduce", "Decrease layer size");
53  connect(action, &QAction::triggered, [this]() { m_canvas->changeLayerSize(0.8); });
54 
55  auto* mainLayout = new QVBoxLayout(this);
56  mainLayout->setMargin(0);
57  mainLayout->setSpacing(0);
58  mainLayout->setContentsMargins(0, 0, 0, 0);
59  mainLayout->addWidget(toolbar);
60  mainLayout->addWidget(m_canvas);
61 }
62 
64 {
65  return QSize(300, 300);
66 }
67 
69 {
70  return m_canvas;
71 }
Defines class RealSpaceCanvas.
Defines class RealSpacePanel.
Defines class StyledToolbar.
Provides 3D object generation for RealSpace presentation.
void changeLayerSize(double layerSizeChangeScale)
RealSpaceCanvas * canvas()
RealSpacePanel(QWidget *parent)
QSize sizeHint() const override
RealSpaceCanvas * m_canvas
The StyledToolbar class represents our standard narrow toolbar with the height 24 pixels.
Definition: StyledToolbar.h:22