diff --git a/GUI/View/Realspace/RealSpaceActions.cpp b/GUI/View/Realspace/RealSpaceActions.cpp deleted file mode 100644 index d85ae9beb3375cac48650f5476c4c51f6e18aaf5..0000000000000000000000000000000000000000 --- a/GUI/View/Realspace/RealSpaceActions.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file GUI/View/Realspace/RealSpaceActions.cpp -//! @brief Implements class RealSpaceActions -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#include "GUI/View/Realspace/RealSpaceActions.h" - -RealSpaceActions::RealSpaceActions(QObject* parent) : QObject(parent) {} diff --git a/GUI/View/Realspace/RealSpaceActions.h b/GUI/View/Realspace/RealSpaceActions.h deleted file mode 100644 index bfc6e3e753b0f511cf2bd45e8933f76fb2ce178c..0000000000000000000000000000000000000000 --- a/GUI/View/Realspace/RealSpaceActions.h +++ /dev/null @@ -1,29 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file GUI/View/Realspace/RealSpaceActions.h -//! @brief Defines class RealSpaceActions -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#ifndef BORNAGAIN_GUI_VIEW_REALSPACE_REALSPACEACTIONS_H -#define BORNAGAIN_GUI_VIEW_REALSPACE_REALSPACEACTIONS_H - -#include <QObject> - -//! Collection of actions for RealSpaceWidget. - -class RealSpaceActions : public QObject { - Q_OBJECT - -public: - RealSpaceActions(QObject* parent = 0); -}; - -#endif // BORNAGAIN_GUI_VIEW_REALSPACE_REALSPACEACTIONS_H diff --git a/GUI/View/Realspace/RealSpaceCanvas.cpp b/GUI/View/Realspace/RealSpaceCanvas.cpp index 3de3a16e3bc9490d16622cdf673c32272b01eee2..ef4cf7b318846154c8bf262ecba96d9991471d28 100644 --- a/GUI/View/Realspace/RealSpaceCanvas.cpp +++ b/GUI/View/Realspace/RealSpaceCanvas.cpp @@ -21,7 +21,7 @@ #include "GUI/View/Info/CautionSign.h" #include "GUI/View/Realspace/RealSpaceBuilder.h" #include "GUI/View/Realspace/RealSpaceModel.h" -#include "GUI/View/Realspace/RealSpaceView.h" +#include "GUI/ba3d/widget.h" #include <QApplication> #include <QFileDialog> #include <QMessageBox> @@ -30,7 +30,7 @@ RealSpaceCanvas::RealSpaceCanvas(QWidget* parent) : QWidget(parent) , m_sampleModel(nullptr) - , m_view(new RealSpaceView) + , m_view(new GUI::RealSpace::Widget3D) , m_selectionModel(nullptr) , m_view_locked(false) , m_sceneGeometry(new SceneGeometry) @@ -187,7 +187,7 @@ void RealSpaceCanvas::updateScene() // if the view is locked, keep the current orientation of the camera if (m_view_locked) builder3D.populate(m_realSpaceModel.get(), *item, *m_sceneGeometry, - m_view->getCamera().getPos()); + m_view->cam().getPos()); // otherwise use default orientation of camera else { builder3D.populate(m_realSpaceModel.get(), *item, *m_sceneGeometry); diff --git a/GUI/View/Realspace/RealSpaceCanvas.h b/GUI/View/Realspace/RealSpaceCanvas.h index aa890b1c918b54dec3695effaa60214f6545d7b2..750042cb50a184bf8d26cf80c32a040940a225ec 100644 --- a/GUI/View/Realspace/RealSpaceCanvas.h +++ b/GUI/View/Realspace/RealSpaceCanvas.h @@ -21,9 +21,11 @@ #include <memory> class SampleModel; -class RealSpaceView; class RealSpaceModel; class CautionSign; +namespace GUI::RealSpace { +class Widget3D; +} // Class for holding size and thickness information of layers class SceneGeometry { @@ -53,7 +55,7 @@ private: double l_min_thickness; }; -//! Provides 3D object generation for RealSpaceWidget. +//! Provides 3D object generation for RealSpace presentation. class RealSpaceCanvas : public QWidget { Q_OBJECT @@ -89,7 +91,7 @@ private: SampleModel* m_sampleModel; QModelIndex m_currentSelection; - RealSpaceView* m_view; + GUI::RealSpace::Widget3D* m_view; std::unique_ptr<RealSpaceModel> m_realSpaceModel; QItemSelectionModel* m_selectionModel; bool m_view_locked; diff --git a/GUI/View/Realspace/RealSpaceToolBar.cpp b/GUI/View/Realspace/RealSpaceToolBar.cpp deleted file mode 100644 index bfc4ae0c956c80765673f56f767a4aee281a8794..0000000000000000000000000000000000000000 --- a/GUI/View/Realspace/RealSpaceToolBar.cpp +++ /dev/null @@ -1,109 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file GUI/View/Realspace/RealSpaceToolBar.cpp -//! @brief Implements class RealSpaceWidget -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#include "GUI/View/Realspace/RealSpaceToolBar.h" -#include "GUI/Util/mainwindow_constants.h" - -#include <QCheckBox> -#include <QToolButton> - -namespace { -const double increaseLayerSizeScale = 1.25; -const double decreaseLayerSizeScale = 0.8; -} // namespace - -RealSpaceToolBar::RealSpaceToolBar(QWidget* parent) - : StyledToolBar(parent) - , m_defaultViewButton(new QToolButton) - , m_sideViewButton(new QToolButton) - , m_topViewButton(new QToolButton) - , m_lockViewCheckBox(new QCheckBox) - , m_increaseLayerSizeButton(new QToolButton) - , m_decreaseLayerSizeButton(new QToolButton) - , m_savePictureButton(new QToolButton) -{ - setMinimumSize(GUI::Constants::styled_toolbar_height, GUI::Constants::styled_toolbar_height); - - // Save image -- this first so it is available for smaller widget sizes - m_savePictureButton->setText("Save Picture"); - m_savePictureButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - m_savePictureButton->setToolTip("Save 3D real space view as .png file"); - connect(m_savePictureButton, &QToolButton::clicked, this, - [&]() { emit RealSpaceToolBar::savePictureAction(); }); - addWidget(m_savePictureButton); - - addSeparator(); - - // Default View - m_defaultViewButton->setText("Default View"); - // m_defaultViewButton->setIcon(QIcon(":/SampleDesigner/images/toolbar_recycle.png")); - m_defaultViewButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - m_defaultViewButton->setToolTip("Reset view and zoom level to default"); - connect(m_defaultViewButton, &QToolButton::clicked, this, &RealSpaceToolBar::defaultViewAction); - addWidget(m_defaultViewButton); - - addSeparator(); - - // Side View - m_sideViewButton->setText("Side View"); - // m_sideViewButton->setIcon(QIcon(":/SampleDesigner/images/toolbar_recycle.png")); - m_sideViewButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - m_sideViewButton->setToolTip("View sample from the side at current zoom level"); - connect(m_sideViewButton, &QToolButton::clicked, this, &RealSpaceToolBar::sideViewAction); - addWidget(m_sideViewButton); - - addSeparator(); - - // Top View - m_topViewButton->setText("Top View"); - // m_topViewButton->setIcon(QIcon(":/SampleDesigner/images/toolbar_recycle.png")); - m_topViewButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - m_topViewButton->setToolTip("View sample from the top at current zoom level"); - connect(m_topViewButton, &QToolButton::clicked, this, &RealSpaceToolBar::topViewAction); - addWidget(m_topViewButton); - - addSeparator(); - - // Lock View - m_lockViewCheckBox->setText("Lock View"); - m_lockViewCheckBox->setToolTip("Lock/unlock current sample selection"); - m_lockViewCheckBox->setCheckable(true); - connect(m_lockViewCheckBox, &QCheckBox::clicked, this, - [&]() { emit RealSpaceToolBar::lockViewAction(m_lockViewCheckBox->isChecked()); }); - addWidget(m_lockViewCheckBox); - - addSeparator(); - - // Increase layer size - m_increaseLayerSizeButton->setText("Enlarge"); - // m_increaseLayerSizeButton->setIcon(QIcon(":/SampleDesigner/images/toolbar_recycle.png")); - m_increaseLayerSizeButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - m_increaseLayerSizeButton->setToolTip("Increase layer size"); - connect(m_increaseLayerSizeButton, &QToolButton::clicked, this, - [&]() { emit RealSpaceToolBar::changeLayerSizeAction(increaseLayerSizeScale); }); - addWidget(m_increaseLayerSizeButton); - - addSeparator(); - - // Decrease layer size - m_decreaseLayerSizeButton->setText("Reduce"); - // m_decreaseLayerSizeButton->setIcon(QIcon(":/SampleDesigner/images/toolbar_recycle.png")); - m_decreaseLayerSizeButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - m_decreaseLayerSizeButton->setToolTip("Decrease layer size"); - connect(m_decreaseLayerSizeButton, &QToolButton::clicked, this, - [&]() { emit RealSpaceToolBar::changeLayerSizeAction(decreaseLayerSizeScale); }); - addWidget(m_decreaseLayerSizeButton); - - addSeparator(); -} diff --git a/GUI/View/Realspace/RealSpaceToolBar.h b/GUI/View/Realspace/RealSpaceToolBar.h deleted file mode 100644 index 1d9c2bc296cfa0d1d380915366ce98d12bb2dc69..0000000000000000000000000000000000000000 --- a/GUI/View/Realspace/RealSpaceToolBar.h +++ /dev/null @@ -1,50 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file GUI/View/Realspace/RealSpaceToolBar.h -//! @brief Defines class RealSpaceWidget -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#ifndef BORNAGAIN_GUI_VIEW_REALSPACE_REALSPACETOOLBAR_H -#define BORNAGAIN_GUI_VIEW_REALSPACE_REALSPACETOOLBAR_H - -#include "GUI/View/Common/StyledToolBar.h" - -class QToolButton; -class QCheckBox; - -//! Thin toolbar on top of RealSpaceWidget. - -class RealSpaceToolBar : public StyledToolBar { - Q_OBJECT - -public: - RealSpaceToolBar(QWidget* parent = nullptr); - -signals: - void defaultViewAction(); - void sideViewAction(); - void topViewAction(); - void lockViewAction(bool); - void changeLayerSizeAction(double); - void savePictureAction(); - -private: - QToolButton* m_defaultViewButton; - QToolButton* m_sideViewButton; - QToolButton* m_topViewButton; - QCheckBox* m_lockViewCheckBox; - - QToolButton* m_increaseLayerSizeButton; - QToolButton* m_decreaseLayerSizeButton; - QToolButton* m_savePictureButton; -}; - -#endif // BORNAGAIN_GUI_VIEW_REALSPACE_REALSPACETOOLBAR_H diff --git a/GUI/View/Realspace/RealSpaceView.cpp b/GUI/View/Realspace/RealSpaceView.cpp deleted file mode 100644 index 2a639dc63eeb8e1f6bf59d92ada793ace004016f..0000000000000000000000000000000000000000 --- a/GUI/View/Realspace/RealSpaceView.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file GUI/View/Realspace/RealSpaceView.cpp -//! @brief Implements class RealSpaceView -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#include "GUI/View/Realspace/RealSpaceView.h" -#include "GUI/View/Realspace/RealSpaceModel.h" -#include "GUI/ba3d/widget.h" -#include <QVBoxLayout> - -RealSpaceView::RealSpaceView(QWidget* parent) - : QWidget(parent), m_3dview(new GUI::RealSpace::Widget3D) -{ - QVBoxLayout* layout = new QVBoxLayout; - layout->setMargin(0); - layout->setSpacing(0); - - layout->addWidget(m_3dview); - setLayout(layout); -} - -void RealSpaceView::setModel(RealSpaceModel* model) -{ - m_3dview->setModel(model); -} - -void RealSpaceView::defaultView() -{ - m_3dview->defaultView(); -} - -void RealSpaceView::sideView() -{ - m_3dview->sideView(); -} - -void RealSpaceView::topView() -{ - m_3dview->topView(); -} - -GUI::RealSpace::Camera& RealSpaceView::getCamera() -{ - return m_3dview->cam(); -} diff --git a/GUI/View/Realspace/RealSpaceView.h b/GUI/View/Realspace/RealSpaceView.h deleted file mode 100644 index 3df16af1cf08a4690f4eca6d1270fd2149f638f2..0000000000000000000000000000000000000000 --- a/GUI/View/Realspace/RealSpaceView.h +++ /dev/null @@ -1,47 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file GUI/View/Realspace/RealSpaceView.h -//! @brief Defines class RealSpaceView -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#ifndef BORNAGAIN_GUI_VIEW_REALSPACE_REALSPACEVIEW_H -#define BORNAGAIN_GUI_VIEW_REALSPACE_REALSPACEVIEW_H - -#include <QWidget> - -class RealSpaceModel; - -namespace GUI::RealSpace { -class Widget3D; -class Camera; -} // namespace GUI::RealSpace - -//! Contains 3D view. - -class RealSpaceView : public QWidget { - Q_OBJECT - -public: - RealSpaceView(QWidget* parent = 0); - - void setModel(RealSpaceModel* model); - - void defaultView(); - void sideView(); - void topView(); - - GUI::RealSpace::Camera& getCamera(); - -private: - GUI::RealSpace::Widget3D* m_3dview; -}; - -#endif // BORNAGAIN_GUI_VIEW_REALSPACE_REALSPACEVIEW_H diff --git a/GUI/View/Realspace/RealSpaceWidget.cpp b/GUI/View/Realspace/RealSpaceWidget.cpp deleted file mode 100644 index 37463b37d8ebda46500c5f8763d1d2a5fa19e527..0000000000000000000000000000000000000000 --- a/GUI/View/Realspace/RealSpaceWidget.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file GUI/View/Realspace/RealSpaceWidget.cpp -//! @brief Implements class RealSpaceWidget -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#include "GUI/View/Realspace/RealSpaceWidget.h" -#include "GUI/View/Realspace/RealSpaceActions.h" -#include "GUI/View/Realspace/RealSpaceCanvas.h" -#include "GUI/View/Realspace/RealSpaceToolBar.h" -#include <QLabel> -#include <QVBoxLayout> - -RealSpaceWidget::RealSpaceWidget(SampleModel* sampleModel, QItemSelectionModel* selectionModel, - QWidget* parent) - : QWidget(parent) - , m_actions(new RealSpaceActions(this)) - , m_toolBar(new RealSpaceToolBar) - , m_canvas(new RealSpaceCanvas) - , m_sampleModel(sampleModel) - , m_selectionModel(selectionModel) -{ - auto hlayout = new QHBoxLayout; - hlayout->setMargin(0); - hlayout->setSpacing(0); - hlayout->setContentsMargins(0, 0, 0, 0); - hlayout->addWidget(m_canvas); - - auto* mainLayout = new QVBoxLayout; - mainLayout->setMargin(0); - mainLayout->setSpacing(0); - mainLayout->setContentsMargins(0, 0, 0, 0); - mainLayout->addWidget(m_toolBar); - mainLayout->addLayout(hlayout); - - setLayout(mainLayout); - - connect(m_toolBar, &RealSpaceToolBar::defaultViewAction, m_canvas, - &RealSpaceCanvas::onDefaultViewAction); - - connect(m_toolBar, &RealSpaceToolBar::sideViewAction, m_canvas, - &RealSpaceCanvas::onSideViewAction); - - connect(m_toolBar, &RealSpaceToolBar::topViewAction, m_canvas, - &RealSpaceCanvas::onTopViewAction); - - connect(m_toolBar, &RealSpaceToolBar::lockViewAction, m_canvas, - &RealSpaceCanvas::onLockViewAction); - - connect(m_toolBar, &RealSpaceToolBar::changeLayerSizeAction, m_canvas, - &RealSpaceCanvas::onChangeLayerSizeAction); - - connect(m_toolBar, &RealSpaceToolBar::savePictureAction, m_canvas, - &RealSpaceCanvas::onSavePictureAction); -} - -void RealSpaceWidget::showEvent(QShowEvent*) -{ - m_canvas->setModel(m_sampleModel, m_selectionModel); -} - -void RealSpaceWidget::hideEvent(QHideEvent*) -{ - m_canvas->setModel(nullptr, nullptr); -} diff --git a/GUI/View/Realspace/RealSpaceWidget.h b/GUI/View/Realspace/RealSpaceWidget.h deleted file mode 100644 index 08260d8fb04941f64455b2dede9ceae22c5a46fe..0000000000000000000000000000000000000000 --- a/GUI/View/Realspace/RealSpaceWidget.h +++ /dev/null @@ -1,48 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file GUI/View/Realspace/RealSpaceWidget.h -//! @brief Defines class RealSpaceWidget -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#ifndef BORNAGAIN_GUI_VIEW_REALSPACE_REALSPACEWIDGET_H -#define BORNAGAIN_GUI_VIEW_REALSPACE_REALSPACEWIDGET_H - -#include <QWidget> - -#include <QTreeView> - -class RealSpaceToolBar; -class RealSpaceCanvas; -class RealSpaceActions; -class SampleModel; - -//! Prototype of real space widget to present sample structure in 3D view. - -class RealSpaceWidget : public QWidget { - Q_OBJECT - -public: - RealSpaceWidget(SampleModel* sampleModel = nullptr, - QItemSelectionModel* selectionModel = nullptr, QWidget* parent = nullptr); - -protected: - void showEvent(QShowEvent*) override; - void hideEvent(QHideEvent*) override; - -private: - RealSpaceActions* m_actions; - RealSpaceToolBar* m_toolBar; - RealSpaceCanvas* m_canvas; - SampleModel* m_sampleModel; - QItemSelectionModel* m_selectionModel; -}; - -#endif // BORNAGAIN_GUI_VIEW_REALSPACE_REALSPACEWIDGET_H diff --git a/GUI/View/SampleDesigner/RealSpacePanel.cpp b/GUI/View/SampleDesigner/RealSpacePanel.cpp index c4f624277de109b5163bafe10fa728c06df15527..2687b89957ba9e066d436f419abb160f9c0077d2 100644 --- a/GUI/View/SampleDesigner/RealSpacePanel.cpp +++ b/GUI/View/SampleDesigner/RealSpacePanel.cpp @@ -7,33 +7,77 @@ //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 +//! @copyright Forschungszentrum Jülich GmbH 2021 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) // // ************************************************************************************************ #include "GUI/View/SampleDesigner/RealSpacePanel.h" -#include "GUI/View/Realspace/RealSpaceWidget.h" +#include "GUI/View/Common/StyledToolBar.h" +#include "GUI/View/Realspace/RealSpaceCanvas.h" #include <QVBoxLayout> RealSpacePanel::RealSpacePanel(SampleModel* sampleModel, QItemSelectionModel* selectionModel, QWidget* parent) - : QWidget(parent), m_realSpaceWidget(nullptr) + : QWidget(parent) + , m_canvas(new RealSpaceCanvas) + , m_sampleModel(sampleModel) + , m_selectionModel(selectionModel) { setWindowTitle("Real Space"); setObjectName("Sample3DPanel"); - auto layout = new QVBoxLayout; - layout->setMargin(0); - layout->setSpacing(0); - layout->setContentsMargins(0, 0, 0, 0); + auto* toolbar = new StyledToolBar(this); - m_realSpaceWidget = new RealSpaceWidget(sampleModel, selectionModel, this); - layout->addWidget(m_realSpaceWidget); - setLayout(layout); + const auto createAction = [&](const QString& text, const QString& tooltip) -> QAction* { + auto* action = new QAction(text, this); + action->setToolTip("Save 3D real space view as .png file"); + toolbar->addAction(action); + toolbar->addSeparator(); + return action; + }; + + auto* action = createAction("Save Picture", "Save 3D real space view as .png file"); + connect(action, &QAction::triggered, m_canvas, &RealSpaceCanvas::onSavePictureAction); + + action = createAction("Default View", "Reset view and zoom level to default"); + connect(action, &QAction::triggered, m_canvas, &RealSpaceCanvas::onDefaultViewAction); + + action = createAction("Side View", "View sample from the side at current zoom level"); + connect(action, &QAction::triggered, m_canvas, &RealSpaceCanvas::onSideViewAction); + + action = createAction("Top View", "View sample from the top at current zoom level"); + connect(action, &QAction::triggered, m_canvas, &RealSpaceCanvas::onTopViewAction); + + action = createAction("Enlarge", "Increase layer size"); + connect(action, &QAction::triggered, [this]() { m_canvas->onChangeLayerSizeAction(1.25); }); + + action = createAction("Reduce", "Decrease layer size"); + connect(action, &QAction::triggered, [this]() { m_canvas->onChangeLayerSizeAction(0.8); }); + + action = createAction("Lock View", "Lock/unlock current sample selection"); + action->setCheckable(true); + connect(action, &QAction::triggered, m_canvas, &RealSpaceCanvas::onLockViewAction); + + auto* mainLayout = new QVBoxLayout(this); + mainLayout->setMargin(0); + mainLayout->setSpacing(0); + mainLayout->setContentsMargins(0, 0, 0, 0); + mainLayout->addWidget(toolbar); + mainLayout->addWidget(m_canvas); } QSize RealSpacePanel::sizeHint() const { return QSize(300, 300); } + +void RealSpacePanel::showEvent(QShowEvent*) +{ + m_canvas->setModel(m_sampleModel, m_selectionModel); +} + +void RealSpacePanel::hideEvent(QHideEvent*) +{ + m_canvas->setModel(nullptr, nullptr); +} diff --git a/GUI/View/SampleDesigner/RealSpacePanel.h b/GUI/View/SampleDesigner/RealSpacePanel.h index e333912078f760305ac8f10786c2c8d4375e72bb..5d5b7d4e9809671dc5bc01b4e304308dba7237ee 100644 --- a/GUI/View/SampleDesigner/RealSpacePanel.h +++ b/GUI/View/SampleDesigner/RealSpacePanel.h @@ -7,7 +7,7 @@ //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 +//! @copyright Forschungszentrum Jülich GmbH 2021 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) // // ************************************************************************************************ @@ -19,9 +19,10 @@ class SampleModel; class QItemSelectionModel; -class RealSpaceWidget; +class RealSpaceCanvas; +class QAction; -//! Panel with item selector, property editor on the right side of RealSpaceWidget. +//! Panel to show 3D view of sample. Contains toolbar and RealSpaceCanvas class RealSpacePanel : public QWidget { Q_OBJECT @@ -31,8 +32,14 @@ public: QSize sizeHint() const override; +protected: + void showEvent(QShowEvent*) override; + void hideEvent(QHideEvent*) override; + private: - RealSpaceWidget* m_realSpaceWidget; + RealSpaceCanvas* m_canvas; + SampleModel* m_sampleModel; + QItemSelectionModel* m_selectionModel; }; #endif // BORNAGAIN_GUI_VIEW_SAMPLEDESIGNER_REALSPACEPANEL_H diff --git a/GUI/View/Toplevel/TestView.cpp b/GUI/View/Toplevel/TestView.cpp index 0b6ebf5a746451334e30bf042f9477507fe4c7b6..a864c51c6784dbd49fd49997b771e0d0c645850b 100644 --- a/GUI/View/Toplevel/TestView.cpp +++ b/GUI/View/Toplevel/TestView.cpp @@ -21,7 +21,6 @@ #include "GUI/Model/Job/JobItem.h" #include "GUI/View/Fit/MinimizerSettingsWidget.h" #include "GUI/View/PropertyEditor/TestComponentView.h" -#include "GUI/View/Realspace/RealSpaceWidget.h" #include "GUI/View/SpecularData/Plot1DCanvas.h" #include <qAccordion/contentpane.h>