From 56400c3f1e9338c7a98f6dc19fcaf27b9b1585ad Mon Sep 17 00:00:00 2001 From: Gennady Pospelov <g.pospelov@fz-juelich.de> Date: Thu, 2 Mar 2017 14:30:49 +0100 Subject: [PATCH] Placeholders for various components of real space widget. --- .../RealSpaceWidgets/RealSpaceActions.cpp | 23 +++++ .../Views/RealSpaceWidgets/RealSpaceActions.h | 33 +++++++ .../Views/RealSpaceWidgets/RealSpacePanel.cpp | 95 +++++++++++++++++++ .../Views/RealSpaceWidgets/RealSpacePanel.h | 53 +++++++++++ .../Views/RealSpaceWidgets/RealSpaceScene.cpp | 23 +++++ .../Views/RealSpaceWidgets/RealSpaceScene.h | 33 +++++++ .../RealSpaceWidgets/RealSpaceToolBar.cpp | 25 +++++ .../Views/RealSpaceWidgets/RealSpaceToolBar.h | 32 +++++++ .../Views/RealSpaceWidgets/RealSpaceView.cpp | 23 +++++ .../Views/RealSpaceWidgets/RealSpaceView.h | 33 +++++++ .../RealSpaceWidgets/RealSpaceWidget.cpp | 32 ++++++- .../Views/RealSpaceWidgets/RealSpaceWidget.h | 18 +++- GUI/coregui/Views/TestView.cpp | 4 +- GUI/coregui/mainwindow/mainwindow.cpp | 2 +- GUI/coregui/mainwindow/mainwindow_constants.h | 7 ++ 15 files changed, 430 insertions(+), 6 deletions(-) create mode 100644 GUI/coregui/Views/RealSpaceWidgets/RealSpaceActions.cpp create mode 100644 GUI/coregui/Views/RealSpaceWidgets/RealSpaceActions.h create mode 100644 GUI/coregui/Views/RealSpaceWidgets/RealSpacePanel.cpp create mode 100644 GUI/coregui/Views/RealSpaceWidgets/RealSpacePanel.h create mode 100644 GUI/coregui/Views/RealSpaceWidgets/RealSpaceScene.cpp create mode 100644 GUI/coregui/Views/RealSpaceWidgets/RealSpaceScene.h create mode 100644 GUI/coregui/Views/RealSpaceWidgets/RealSpaceToolBar.cpp create mode 100644 GUI/coregui/Views/RealSpaceWidgets/RealSpaceToolBar.h create mode 100644 GUI/coregui/Views/RealSpaceWidgets/RealSpaceView.cpp create mode 100644 GUI/coregui/Views/RealSpaceWidgets/RealSpaceView.h diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceActions.cpp b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceActions.cpp new file mode 100644 index 00000000000..aa0de1164b1 --- /dev/null +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceActions.cpp @@ -0,0 +1,23 @@ +// ************************************************************************** // +// +// BornAgain: simulate and fit scattering at grazing incidence +// +//! @file GUI/coregui/Views/RealSpaceWidgets/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 2016 +//! @authors Scientific Computing Group at MLZ Garching +//! @authors Céline Durniak, Marina Ganeva, David Li, Gennady Pospelov +//! @authors Walter Van Herck, Joachim Wuttke +// +// ************************************************************************** // + +#include "RealSpaceActions.h" + +RealSpaceActions::RealSpaceActions(QObject* parent) + : QObject(parent) +{ + +} diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceActions.h b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceActions.h new file mode 100644 index 00000000000..ad6d099e8b4 --- /dev/null +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceActions.h @@ -0,0 +1,33 @@ +// ************************************************************************** // +// +// BornAgain: simulate and fit scattering at grazing incidence +// +//! @file GUI/coregui/Views/RealSpaceWidgets/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 2016 +//! @authors Scientific Computing Group at MLZ Garching +//! @authors Céline Durniak, Marina Ganeva, David Li, Gennady Pospelov +//! @authors Walter Van Herck, Joachim Wuttke +// +// ************************************************************************** // + +#ifndef REALSPACEACTIONS_H +#define REALSPACEACTIONS_H + +#include "WinDllMacros.h" +#include <QObject> + +//! Collection of actions for RealSpaceWidget. + +class BA_CORE_API_ RealSpaceActions : public QObject +{ + Q_OBJECT + +public: + RealSpaceActions(QObject* parent = 0); +}; + +#endif // REALSPACEACTIONS_H diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpacePanel.cpp b/GUI/coregui/Views/RealSpaceWidgets/RealSpacePanel.cpp new file mode 100644 index 00000000000..29c07c51e14 --- /dev/null +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpacePanel.cpp @@ -0,0 +1,95 @@ +// ************************************************************************** // +// +// BornAgain: simulate and fit scattering at grazing incidence +// +//! @file GUI/coregui/Views/RealSpaceWidgets/RealSpacePanel.cpp +//! @brief Implements class RealSpacePanel +//! +//! @homepage http://www.bornagainproject.org +//! @license GNU General Public License v3 or higher (see COPYING) +//! @copyright Forschungszentrum Jülich GmbH 2016 +//! @authors Scientific Computing Group at MLZ Garching +//! @authors Céline Durniak, Marina Ganeva, David Li, Gennady Pospelov +//! @authors Walter Van Herck, Joachim Wuttke +// +// ************************************************************************** // + +#include "RealSpacePanel.h" +#include "mainwindow_constants.h" +#include "ComponentBoxEditor.h" +#include "FilterPropertyProxy.h" +#include "SampleModel.h" +#include <QTreeView> +#include <QItemSelectionModel> +#include <QVBoxLayout> +#include <QDebug> + +RealSpacePanel::RealSpacePanel(QWidget* parent) + : QWidget(parent) + , m_treeView(new QTreeView) + , m_componentEditor(new ComponentEditor) + , m_model(nullptr) + , m_proxy(nullptr) +{ + setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); + + QVBoxLayout* layout = new QVBoxLayout; + layout->setMargin(0); + layout->setSpacing(0); + layout->setContentsMargins(0, 0, 0, 0); + + layout->addWidget(m_treeView); + layout->addWidget(m_componentEditor); + + setLayout(layout); + + +} + +void RealSpacePanel::setModel(SampleModel* model) +{ + m_model = model; + + delete m_proxy; + m_proxy = new FilterPropertyProxy(1, this); + m_proxy->setSourceModel(model); + m_treeView->setModel(m_proxy); + m_treeView->setAttribute(Qt::WA_MacShowFocusRect, false); + + m_treeView->expandAll(); + + connect(m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), + m_treeView, SLOT(expandAll()), Qt::UniqueConnection); + + connect(m_treeView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), + this, SLOT(onSelectionChanged(QItemSelection, QItemSelection)), Qt::UniqueConnection); + +} + +QSize RealSpacePanel::sizeHint() const +{ + return QSize(Constants::hint_panel_width*1.3, 256); + +} + +QSize RealSpacePanel::minimumSizeHint() const +{ + return QSize(Constants::hint_panel_width*1.3, 63); +} + +void RealSpacePanel::onSelectionChanged(const QItemSelection& selected, const QItemSelection&) +{ + qDebug() << "RealSpacePanel::onSelectionChanged"; + Q_ASSERT(m_proxy); + Q_ASSERT(m_model); + QModelIndexList indices = selected.indexes(); + + if(indices.size()) { + QModelIndex index = m_proxy->mapToSource(indices.back()); + SessionItem* item = m_model->itemForIndex(index); + Q_ASSERT(item); + m_componentEditor->setItem(item, item->modelType()); + } else { + m_componentEditor->setItem(0); + } +} diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpacePanel.h b/GUI/coregui/Views/RealSpaceWidgets/RealSpacePanel.h new file mode 100644 index 00000000000..588c36e7a43 --- /dev/null +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpacePanel.h @@ -0,0 +1,53 @@ +// ************************************************************************** // +// +// BornAgain: simulate and fit scattering at grazing incidence +// +//! @file GUI/coregui/Views/RealSpaceWidgets/RealSpacePanel.h +//! @brief Defines class RealSpacePanel +//! +//! @homepage http://www.bornagainproject.org +//! @license GNU General Public License v3 or higher (see COPYING) +//! @copyright Forschungszentrum Jülich GmbH 2016 +//! @authors Scientific Computing Group at MLZ Garching +//! @authors Céline Durniak, Marina Ganeva, David Li, Gennady Pospelov +//! @authors Walter Van Herck, Joachim Wuttke +// +// ************************************************************************** // + +#ifndef REALSPACEPANEL_H +#define REALSPACEPANEL_H + +#include "WinDllMacros.h" +#include <QWidget> + +class QTreeView; +class ComponentEditor; +class SampleModel; +class FilterPropertyProxy; +class QItemSelection; + +//! Panel with item selector, property editor on the right side of RealSpaceWidget. + +class BA_CORE_API_ RealSpacePanel : public QWidget +{ + Q_OBJECT + +public: + RealSpacePanel(QWidget* parent = 0); + + void setModel(SampleModel* model); + + QSize sizeHint() const; + QSize minimumSizeHint() const; + +public slots: + void onSelectionChanged(const QItemSelection& selected, const QItemSelection&); + +private: + QTreeView* m_treeView; + ComponentEditor* m_componentEditor; + SampleModel* m_model; + FilterPropertyProxy* m_proxy; +}; + +#endif // REALSPACEPANEL_H diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceScene.cpp b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceScene.cpp new file mode 100644 index 00000000000..f5256412adb --- /dev/null +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceScene.cpp @@ -0,0 +1,23 @@ +// ************************************************************************** // +// +// BornAgain: simulate and fit scattering at grazing incidence +// +//! @file GUI/coregui/Views/RealSpaceWidgets/RealSpaceScene.cpp +//! @brief Implements class RealSpaceScene +//! +//! @homepage http://www.bornagainproject.org +//! @license GNU General Public License v3 or higher (see COPYING) +//! @copyright Forschungszentrum Jülich GmbH 2016 +//! @authors Scientific Computing Group at MLZ Garching +//! @authors Céline Durniak, Marina Ganeva, David Li, Gennady Pospelov +//! @authors Walter Van Herck, Joachim Wuttke +// +// ************************************************************************** // + +#include "RealSpaceScene.h" + +RealSpaceScene::RealSpaceScene(QObject* parent) + : QObject(parent) +{ + +} diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceScene.h b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceScene.h new file mode 100644 index 00000000000..8e7e3d1fa03 --- /dev/null +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceScene.h @@ -0,0 +1,33 @@ +// ************************************************************************** // +// +// BornAgain: simulate and fit scattering at grazing incidence +// +//! @file GUI/coregui/Views/RealSpaceWidgets/RealSpaceScene.h +//! @brief Defines class RealSpaceScene +//! +//! @homepage http://www.bornagainproject.org +//! @license GNU General Public License v3 or higher (see COPYING) +//! @copyright Forschungszentrum Jülich GmbH 2016 +//! @authors Scientific Computing Group at MLZ Garching +//! @authors Céline Durniak, Marina Ganeva, David Li, Gennady Pospelov +//! @authors Walter Van Herck, Joachim Wuttke +// +// ************************************************************************** // + +#ifndef REALSPACESCENE_H +#define REALSPACESCENE_H + +#include "WinDllMacros.h" +#include <QObject> + +//! Provides 3D object generation logic for RealSpaceWidget. + +class BA_CORE_API_ RealSpaceScene : public QObject +{ + Q_OBJECT + +public: + RealSpaceScene(QObject* parent = 0); +}; + +#endif // REALSPACESCENE_H diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceToolBar.cpp b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceToolBar.cpp new file mode 100644 index 00000000000..0d3cfa5b2da --- /dev/null +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceToolBar.cpp @@ -0,0 +1,25 @@ +// ************************************************************************** // +// +// BornAgain: simulate and fit scattering at grazing incidence +// +//! @file GUI/coregui/Views/RealSpaceWidgets/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 2016 +//! @authors Scientific Computing Group at MLZ Garching +//! @authors Céline Durniak, Marina Ganeva, David Li, Gennady Pospelov +//! @authors Walter Van Herck, Joachim Wuttke +// +// ************************************************************************** // + +#include "RealSpaceToolBar.h" +#include "mainwindow_constants.h" + +RealSpaceToolBar::RealSpaceToolBar(QWidget* parent) + : StyledToolBar(parent) +{ + setMinimumSize(Constants::styled_toolbar_height, Constants::styled_toolbar_height); + +} diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceToolBar.h b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceToolBar.h new file mode 100644 index 00000000000..d15f8adc89a --- /dev/null +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceToolBar.h @@ -0,0 +1,32 @@ +// ************************************************************************** // +// +// BornAgain: simulate and fit scattering at grazing incidence +// +//! @file GUI/coregui/Views/RealSpaceWidgets/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 2016 +//! @authors Scientific Computing Group at MLZ Garching +//! @authors Céline Durniak, Marina Ganeva, David Li, Gennady Pospelov +//! @authors Walter Van Herck, Joachim Wuttke +// +// ************************************************************************** // + +#ifndef REALSPACETOOLBAR_H +#define REALSPACETOOLBAR_H + +#include "StyledToolBar.h" + +//! Thin toolbar on top of RealSpaceWidget. + +class BA_CORE_API_ RealSpaceToolBar : public StyledToolBar +{ + Q_OBJECT + +public: + RealSpaceToolBar(QWidget* parent = 0); +}; + +#endif // REALSPACETOOLBAR_H diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceView.cpp b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceView.cpp new file mode 100644 index 00000000000..157ef435218 --- /dev/null +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceView.cpp @@ -0,0 +1,23 @@ +// ************************************************************************** // +// +// BornAgain: simulate and fit scattering at grazing incidence +// +//! @file GUI/coregui/Views/RealSpaceWidgets/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 2016 +//! @authors Scientific Computing Group at MLZ Garching +//! @authors Céline Durniak, Marina Ganeva, David Li, Gennady Pospelov +//! @authors Walter Van Herck, Joachim Wuttke +// +// ************************************************************************** // + +#include "RealSpaceView.h" + +RealSpaceView::RealSpaceView(QWidget* parent) + : QWidget(parent) +{ + +} diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceView.h b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceView.h new file mode 100644 index 00000000000..a2c81583f09 --- /dev/null +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceView.h @@ -0,0 +1,33 @@ +// ************************************************************************** // +// +// BornAgain: simulate and fit scattering at grazing incidence +// +//! @file GUI/coregui/Views/RealSpaceWidgets/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 2016 +//! @authors Scientific Computing Group at MLZ Garching +//! @authors Céline Durniak, Marina Ganeva, David Li, Gennady Pospelov +//! @authors Walter Van Herck, Joachim Wuttke +// +// ************************************************************************** // + +#ifndef REALSPACEVIEW_H +#define REALSPACEVIEW_H + +#include "WinDllMacros.h" +#include <QWidget> + +//! Contains 3D view. + +class BA_CORE_API_ RealSpaceView : public QWidget +{ + Q_OBJECT + +public: + RealSpaceView(QWidget* parent = 0); +}; + +#endif // REALSPACEVIEW_H diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceWidget.cpp b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceWidget.cpp index e0ea0ba2186..57872fa1e21 100644 --- a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceWidget.cpp +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceWidget.cpp @@ -15,14 +15,40 @@ // ************************************************************************** // #include "RealSpaceWidget.h" +#include "RealSpaceToolBar.h" +#include "RealSpaceScene.h" +#include "RealSpaceView.h" +#include "RealSpaceActions.h" +#include "RealSpacePanel.h" #include <QVBoxLayout> #include <QLabel> RealSpaceWidget::RealSpaceWidget(QWidget* parent) : QWidget(parent) + , m_toolBar(new RealSpaceToolBar) + , m_view(new RealSpaceView) + , m_scene(new RealSpaceScene) + , m_actions(new RealSpaceActions) + , m_panel(new RealSpacePanel) { - QVBoxLayout* layout = new QVBoxLayout; - layout->addWidget(new QLabel("Hello World")); + QHBoxLayout* hlayout = new QHBoxLayout; + hlayout->setMargin(0); + hlayout->setSpacing(0); + hlayout->setContentsMargins(0, 0, 0, 0); + hlayout->addWidget(m_view); + hlayout->addWidget(m_panel); - setLayout(layout); + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->setMargin(0); + mainLayout->setSpacing(0); + mainLayout->setContentsMargins(0,0,0,0); + mainLayout->addWidget(m_toolBar); + mainLayout->addLayout(hlayout); + + setLayout(mainLayout); +} + +void RealSpaceWidget::setModel(SampleModel* model) +{ + m_panel->setModel(model); } diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceWidget.h b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceWidget.h index 64cccc138fe..bf7c80c75d8 100644 --- a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceWidget.h +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceWidget.h @@ -20,6 +20,13 @@ #include "WinDllMacros.h" #include <QWidget> +class RealSpaceToolBar; +class RealSpaceView; +class RealSpaceScene; +class RealSpaceActions; +class RealSpacePanel; +class SampleModel; + //! Prototype of real space widget to present sample structure in 3D view. class BA_CORE_API_ RealSpaceWidget : public QWidget @@ -28,6 +35,15 @@ class BA_CORE_API_ RealSpaceWidget : public QWidget public: RealSpaceWidget(QWidget* parent = 0); + + void setModel(SampleModel* model); + +private: + RealSpaceToolBar* m_toolBar; + RealSpaceView* m_view; + RealSpaceScene* m_scene; + RealSpaceActions* m_actions; + RealSpacePanel* m_panel; }; -#endif +#endif // REALSPACEWIDGET_H diff --git a/GUI/coregui/Views/TestView.cpp b/GUI/coregui/Views/TestView.cpp index c9075e5986f..7357646628b 100644 --- a/GUI/coregui/Views/TestView.cpp +++ b/GUI/coregui/Views/TestView.cpp @@ -148,7 +148,9 @@ void TestView::test_ba3d() layout->setMargin(0); layout->setSpacing(0); #ifdef BORNAGAIN_OPENGL - layout->addWidget(new RealSpaceWidget); + RealSpaceWidget* widget = new RealSpaceWidget; + widget->setModel(m_mainWindow->sampleModel()); + layout->addWidget(widget); #endif setLayout(layout); diff --git a/GUI/coregui/mainwindow/mainwindow.cpp b/GUI/coregui/mainwindow/mainwindow.cpp index b7e0449f0c4..1371574aa3a 100644 --- a/GUI/coregui/mainwindow/mainwindow.cpp +++ b/GUI/coregui/mainwindow/mainwindow.cpp @@ -65,7 +65,7 @@ MainWindow::MainWindow(QWidget *parent) initViews(); initConnections(); -// m_applicationModels->createTestSample(); + m_applicationModels->createTestSample(); // m_applicationModels->createTestJob(); // m_applicationModels->createTestRealData(); } diff --git a/GUI/coregui/mainwindow/mainwindow_constants.h b/GUI/coregui/mainwindow/mainwindow_constants.h index 66576aef877..565ed3d74b1 100644 --- a/GUI/coregui/mainwindow/mainwindow_constants.h +++ b/GUI/coregui/mainwindow/mainwindow_constants.h @@ -56,6 +56,8 @@ const unsigned int MAIN_THEME_COLOR = 0x086FA1; const unsigned int BUTTON_COLOR = 0x044362; const unsigned int BUTTON_TEXT_COLOR = 0xFFFFFF; +// Hints + const unsigned int REALTIME_WIDGET_WIDTH_HINT = 480; const unsigned int FIT_ACTIVITY_PANEL_HEIGHT = 380; const unsigned int FIT_SUITE_WIDGET_HEIGHT= 330; @@ -63,6 +65,9 @@ const unsigned int RUN_FIT_CONTROL_WIDGET_HEIGHT = 50; const unsigned int ITEM_SELECTOR_WIDGET_WIDTH = 128; const unsigned int ITEM_SELECTOR_WIDGET_HEIGHT = 765; +const unsigned int hint_panel_width = 230; +const unsigned int hint_panel_height = 64; + // Widget names const QString JobRealTimeWidgetName = "Job Real Time"; @@ -83,6 +88,8 @@ const QString FitComparisonWidgetName = "Fit Data"; const int toolbar_icon_size = 32; +const int styled_toolbar_height = 25; + } #endif // MAINWINDOW_CONSTANTS_H -- GitLab