diff --git a/GUI/Model/From/GUIDomainSampleVisitor.cpp b/GUI/Model/From/GUIDomainSampleVisitor.cpp index e6060320a1475728b38294d11eb2386efe9e9984..cf65051d6ea2f7be2fd7cccc7e790405db444895 100644 --- a/GUI/Model/From/GUIDomainSampleVisitor.cpp +++ b/GUI/Model/From/GUIDomainSampleVisitor.cpp @@ -600,9 +600,9 @@ ParticleItem* GUIDomainSampleVisitor::CreateIParticle(SessionItem* parent, ASSERT(coreshell); auto* parentCoreShell = polymorphic_cast<ParticleCoreShellItem*>(parent); if (particle == coreshell->coreParticle()) - return parentCoreShell->createCore(); + return parentCoreShell->createCore(m_materialModel); if (particle == coreshell->shellParticle()) - return parentCoreShell->createShell(); + return parentCoreShell->createShell(m_materialModel); ASSERT(0); } return m_sampleModel->insertItem<ParticleItem>(parent, -1); diff --git a/GUI/Model/Job/JobItem.cpp b/GUI/Model/Job/JobItem.cpp index 9e6f4594f79873c766f246bd225ffa8ca94eef42..8e6434ac367236f4c9f878d2e9b2426c7f8ad5df 100644 --- a/GUI/Model/Job/JobItem.cpp +++ b/GUI/Model/Job/JobItem.cpp @@ -414,7 +414,6 @@ void JobItem::readNonSessionItems(QXmlStreamReader* reader) reader->skipCurrentElement(); } else if (reader->name() == MaterialsTag) { m_materials.readContentFrom(reader); - reader->skipCurrentElement(); } } } diff --git a/GUI/Model/Sample/ParticleCoreShellItem.cpp b/GUI/Model/Sample/ParticleCoreShellItem.cpp index dbe7fb6951623ded5506b8c6a03a1875b4ed7d84..28d7fc5d3c39e5a0b3a87d429b73341b1ec2ece2 100644 --- a/GUI/Model/Sample/ParticleCoreShellItem.cpp +++ b/GUI/Model/Sample/ParticleCoreShellItem.cpp @@ -13,6 +13,7 @@ // ************************************************************************************************ #include "GUI/Model/Sample/ParticleCoreShellItem.h" +#include "GUI/Model/Material/MaterialModel.h" #include "GUI/Model/Sample/ParticleItem.h" #include "GUI/Model/Session/SessionItemUtils.h" #include "GUI/Model/Session/SessionModel.h" @@ -76,9 +77,12 @@ void ParticleCoreShellItem::setCore(ParticleItem* newCore) model()->moveItem(newCore, this, -1, T_CORE); } -ParticleItem* ParticleCoreShellItem::createCore() +ParticleItem* ParticleCoreShellItem::createCore(MaterialModel* materials) { - return model()->insertItem<ParticleItem>(this, -1, T_CORE); + auto* p = model()->insertItem<ParticleItem>(this, -1, T_CORE); + p->setMaterialModel(materials); + p->setMaterial(materials->defaultMaterial()); + return p; } bool ParticleCoreShellItem::isCoreTagName(const QString& name) @@ -102,9 +106,12 @@ void ParticleCoreShellItem::setShell(ParticleItem* newShell) model()->moveItem(newShell, this, -1, T_SHELL); } -ParticleItem* ParticleCoreShellItem::createShell() +ParticleItem* ParticleCoreShellItem::createShell(MaterialModel* materials) { - return model()->insertItem<ParticleItem>(this, -1, T_SHELL); + auto* p = model()->insertItem<ParticleItem>(this, -1, T_SHELL); + p->setMaterialModel(materials); + p->setMaterial(materials->defaultMaterial()); + return p; } bool ParticleCoreShellItem::isShellTagName(const QString& name) diff --git a/GUI/Model/Sample/ParticleCoreShellItem.h b/GUI/Model/Sample/ParticleCoreShellItem.h index f2c9cf5f8d8b692f7de2aff68d3f556c15aa0656..8a39ffc0d92e8e29d1d389027a0121fd00820657 100644 --- a/GUI/Model/Sample/ParticleCoreShellItem.h +++ b/GUI/Model/Sample/ParticleCoreShellItem.h @@ -20,6 +20,7 @@ class ParticleCoreShell; class ParticleItem; class VectorItem; +class MaterialModel; class BA_CORE_API_ ParticleCoreShellItem : public ItemWithParticles { private: @@ -35,12 +36,12 @@ public: ParticleItem* core() const; void setCore(ParticleItem* core); - ParticleItem* createCore(); + ParticleItem* createCore(MaterialModel* materials); static bool isCoreTagName(const QString& name); ParticleItem* shell() const; void setShell(ParticleItem* newShell); - ParticleItem* createShell(); + ParticleItem* createShell(MaterialModel* materials); static bool isShellTagName(const QString& name); }; diff --git a/GUI/View/Common/InfoPanel.cpp b/GUI/View/Common/InfoPanel.cpp deleted file mode 100644 index 6466b730c0ae089e794b11f5b686a98392fa272c..0000000000000000000000000000000000000000 --- a/GUI/View/Common/InfoPanel.cpp +++ /dev/null @@ -1,121 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file GUI/View/Common/InfoPanel.cpp -//! @brief Declares class InfoPanel -//! -//! @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/Common/InfoPanel.h" -#include "GUI/View/Common/InfoPanelToolBar.h" -#include <QBoxLayout> -#include <QResizeEvent> -#include <QStackedWidget> - -namespace { - -const int minimum_widget_height = 25; // height of toolbar -const int minimum_height_before_collapse = 50; -const int default_height = 200; - -} // namespace - -InfoPanel::InfoPanel(QWidget* parent) - : QFrame(parent) - , m_toolBar(new InfoPanelToolBar) - , m_stackedWidget(new QStackedWidget) - , m_cached_height(default_height) -{ - auto* mainLayout = new QVBoxLayout; - mainLayout->addWidget(m_toolBar); - mainLayout->addWidget(m_stackedWidget); - - mainLayout->setContentsMargins(0, 0, 0, 0); - mainLayout->setMargin(0); - mainLayout->setSpacing(0); - - setLayout(mainLayout); - - connect(m_toolBar, &InfoPanelToolBar::expandButtonClicked, this, - &InfoPanel::onExpandButtonClicked); -} - -QSize InfoPanel::sizeHint() const -{ - QSize result = m_toolBar->sizeHint(); - - if (QWidget* widget = m_stackedWidget->currentWidget()) { - if (widget->isVisible()) - result.setHeight(widget->height() + m_toolBar->height()); - } else { - result.setHeight(m_toolBar->height()); - } - - return result; -} - -QSize InfoPanel::minimumSizeHint() const -{ - return QSize(minimum_widget_height, minimum_widget_height); -} - -void InfoPanel::showToolBar(bool show) -{ - m_toolBar->setVisible(show); -} - -void InfoPanel::onExpandButtonClicked() -{ - setContentVisible(!isContentVisible(), true); -} - -void InfoPanel::setContentVisible(bool editor_status, bool dock_notify) -{ - m_toolBar->setExpandStatus(editor_status); - if (editor_status) { - if (m_cached_height) - if (dock_notify) - emit widgetHeightRequest(m_cached_height); - - if (m_stackedWidget->currentWidget()) - m_stackedWidget->currentWidget()->show(); - } else { - m_cached_height = (height() < minimum_height_before_collapse ? default_height : height()); - if (m_stackedWidget->currentWidget()) - m_stackedWidget->currentWidget()->hide(); - - if (dock_notify) - emit widgetHeightRequest(minimum_widget_height); - } -} - -bool InfoPanel::isContentVisible() -{ - if (m_stackedWidget->currentWidget()) - return m_stackedWidget->currentWidget()->isVisible(); - - return false; -} - -void InfoPanel::resizeEvent(QResizeEvent* event) -{ - // widget is schrinking in height - if (event->oldSize().height() > event->size().height()) { - if (event->size().height() <= minimum_height_before_collapse && isContentVisible()) - setContentVisible(false); - } - - // widget is growing in height - if (event->oldSize().height() < event->size().height()) { - if (event->size().height() > minimum_height_before_collapse && !isContentVisible()) - setContentVisible(true); - } - - QWidget::resizeEvent(event); -} diff --git a/GUI/View/Common/InfoPanel.h b/GUI/View/Common/InfoPanel.h deleted file mode 100644 index 1280411e43be428b1ddbf2bc3367952696e4ed02..0000000000000000000000000000000000000000 --- a/GUI/View/Common/InfoPanel.h +++ /dev/null @@ -1,54 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file GUI/View/Common/InfoPanel.h -//! @brief Defines class InfoPanel -//! -//! @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_COMMON_INFOPANEL_H -#define BORNAGAIN_GUI_VIEW_COMMON_INFOPANEL_H - -#include <QFrame> - -class QStackedWidget; -class InfoPanelToolBar; -class QResizeEvent; - -//! Frame for widgets with tool bar on top and collapse/expand button functionality. -//! Intended for QDockWindow, to be able to quickly minimize/maximize its appearance. - -//! Used in JobMessagePanel. - -class InfoPanel : public QFrame { - Q_OBJECT -public: - explicit InfoPanel(QWidget* parent); - - QSize sizeHint() const override; - QSize minimumSizeHint() const override; - void showToolBar(bool show); - -signals: - void widgetHeightRequest(int); - -protected slots: - void onExpandButtonClicked(); - void setContentVisible(bool editor_status, bool dock_notify = false); - -protected: - bool isContentVisible(); - void resizeEvent(QResizeEvent* event) override; - - InfoPanelToolBar* m_toolBar; - QStackedWidget* m_stackedWidget; - int m_cached_height; -}; - -#endif // BORNAGAIN_GUI_VIEW_COMMON_INFOPANEL_H diff --git a/GUI/View/Common/InfoPanelToolBar.cpp b/GUI/View/Common/InfoPanelToolBar.cpp deleted file mode 100644 index ebf33b42e4af397f98cb60021d6689769be52b62..0000000000000000000000000000000000000000 --- a/GUI/View/Common/InfoPanelToolBar.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file GUI/View/Common/InfoPanelToolBar.cpp -//! @brief Declares class InfoPanelToolBar -//! -//! @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/Common/InfoPanelToolBar.h" -#include <QAction> -#include <QHBoxLayout> -#include <QToolButton> - -namespace { - -const int minimum_size = 25; -const QString icon_up = ":/images/dark-angle-up.svg"; -const QString icon_down = ":/images/dark-angle-down.svg"; -const QString expand_text = "Collapse/expand view"; - -} // namespace - -InfoPanelToolBar::InfoPanelToolBar(QWidget* parent) - : QToolBar(parent), m_expandAction(new QAction(expand_text, this)), m_expanded(false) -{ - setMinimumSize(minimum_size, minimum_size); - setProperty("_q_custom_style_disabled", QVariant(true)); - - m_expandAction->setIcon(QIcon(icon_up)); - m_expandAction->setToolTip(expand_text); - connect(m_expandAction, &QAction::triggered, this, &InfoPanelToolBar::onExpandButtonClicked); - - auto* empty = new QWidget(); - empty->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - addWidget(empty); - - addAction(m_expandAction); -} - -void InfoPanelToolBar::setExpandStatus(bool status) -{ - m_expanded = status; - if (m_expanded) - m_expandAction->setIcon(QIcon(icon_down)); - else - m_expandAction->setIcon(QIcon(icon_up)); -} - -void InfoPanelToolBar::onExpandButtonClicked() -{ - m_expanded = !m_expanded; - setExpandStatus(m_expanded); - emit expandButtonClicked(); -} diff --git a/GUI/View/Common/InfoPanelToolBar.h b/GUI/View/Common/InfoPanelToolBar.h deleted file mode 100644 index c12e7acd24e884e1a469f0e903cbbd21d182eb9b..0000000000000000000000000000000000000000 --- a/GUI/View/Common/InfoPanelToolBar.h +++ /dev/null @@ -1,44 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file GUI/View/Common/InfoPanelToolBar.h -//! @brief Defines class InfoPanelToolBar -//! -//! @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_COMMON_INFOPANELTOOLBAR_H -#define BORNAGAIN_GUI_VIEW_COMMON_INFOPANELTOOLBAR_H - -#include "GUI/View/Common/StyledToolBar.h" - -class QAction; - -//! Toolbar for InfoPanel with collapse/expand buttons. - -class InfoPanelToolBar : public QToolBar { - Q_OBJECT - -public: - explicit InfoPanelToolBar(QWidget* parent = nullptr); - -signals: - void expandButtonClicked(); - -public slots: - void setExpandStatus(bool status); - -protected slots: - void onExpandButtonClicked(); - -private: - QAction* m_expandAction; - bool m_expanded; -}; - -#endif // BORNAGAIN_GUI_VIEW_COMMON_INFOPANELTOOLBAR_H diff --git a/GUI/View/Fit/JobMessagePanel.cpp b/GUI/View/Fit/JobMessagePanel.cpp index 97b2887b0f0afc32014cceb7c1cfdd3ce49af08e..f7af65c2f04cb7d72c38cdcf3165ff01d3bc71ac 100644 --- a/GUI/View/Fit/JobMessagePanel.cpp +++ b/GUI/View/Fit/JobMessagePanel.cpp @@ -13,11 +13,8 @@ // ************************************************************************************************ #include "GUI/View/Fit/JobMessagePanel.h" -#include "GUI/View/Tool/mainwindow_constants.h" #include <QScrollBar> -#include <QStackedWidget> #include <QTextEdit> -#include <QVBoxLayout> namespace { @@ -43,37 +40,23 @@ QColor color(FitLogLevel level) } // namespace -JobMessagePanel::JobMessagePanel(QWidget* parent) - : InfoPanel(parent), m_log(nullptr), m_plainLog(new QTextEdit) +JobMessagePanel::JobMessagePanel(QWidget* parent) : QTextEdit(parent), m_log(nullptr) { - setWindowTitle(GUI::Constants::JobMessagePanelName); - setObjectName("JobMessagePanel"); - - m_plainLog->setReadOnly(true); - // m_plainLog->setMaximumBlockCount(100000); - m_plainLog->setFont(QFont("Courier")); - - m_stackedWidget->addWidget(m_plainLog); - - setContentVisible(false); -} - -void JobMessagePanel::onClearLog() -{ - m_plainLog->clear(); + setWindowTitle("Message Panel"); + setReadOnly(true); + setFont(QFont("Courier")); } void JobMessagePanel::appendMessage(const FitLog::Message& message) { - QScrollBar* scrollbar = m_plainLog->verticalScrollBar(); + QScrollBar* scrollbar = verticalScrollBar(); bool autoscroll = scrollbar->value() == scrollbar->maximum(); - // m_plainLog->appendPlainText(message); - m_plainLog->setTextColor(color(message.level)); - m_plainLog->append(QString::fromStdString(message.text)); + setTextColor(color(message.level)); + append(QString::fromStdString(message.text)); if (autoscroll) { - QTextCursor c = m_plainLog->textCursor(); + QTextCursor c = textCursor(); c.movePosition(QTextCursor::End); - m_plainLog->setTextCursor(c); + setTextCursor(c); } } @@ -82,11 +65,11 @@ void JobMessagePanel::setLog(FitLog* log) if (m_log) m_log->disconnect(this); m_log = log; - m_plainLog->clear(); + clear(); if (m_log) { for (const auto& record : m_log->messages()) appendMessage(record); - connect(m_log, &FitLog::cleared, this, &JobMessagePanel::onClearLog); + connect(m_log, &FitLog::cleared, this, &JobMessagePanel::clear); connect(m_log, &FitLog::messageAppended, this, &JobMessagePanel::appendMessage); } } diff --git a/GUI/View/Fit/JobMessagePanel.h b/GUI/View/Fit/JobMessagePanel.h index 28f1c8b47d640a013503cad4d74596cd018bad41..c14a65ea7bbbc9d362c7f3b2fd4bc772b7d4843d 100644 --- a/GUI/View/Fit/JobMessagePanel.h +++ b/GUI/View/Fit/JobMessagePanel.h @@ -15,28 +15,23 @@ #ifndef BORNAGAIN_GUI_VIEW_FIT_JOBMESSAGEPANEL_H #define BORNAGAIN_GUI_VIEW_FIT_JOBMESSAGEPANEL_H -#include "GUI/View/Common/InfoPanel.h" #include "GUI/View/Fit/FitLog.h" #include <QColor> - -class QTextEdit; +#include <QTextEdit> //! The JobMessagePanel class shows log messages from FitActivityPanel at the //! bottom part of JobView. -class JobMessagePanel : public InfoPanel { +class JobMessagePanel : public QTextEdit { Q_OBJECT public: JobMessagePanel(QWidget* parent = nullptr); -public slots: - void onClearLog(); void appendMessage(const FitLog::Message& message); void setLog(FitLog* log); private: FitLog* m_log; - QTextEdit* m_plainLog; }; #endif // BORNAGAIN_GUI_VIEW_FIT_JOBMESSAGEPANEL_H diff --git a/GUI/View/Fit/JobRealTimeToolBar.cpp b/GUI/View/Fit/JobRealTimeToolBar.cpp deleted file mode 100644 index 9880d1786e663bc9d650e2e03d2ddfb96fdbf506..0000000000000000000000000000000000000000 --- a/GUI/View/Fit/JobRealTimeToolBar.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file GUI/View/Fit/JobRealTimeToolBar.cpp -//! @brief Implements class JobRealTimeToolBar -//! -//! @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/Fit/JobRealTimeToolBar.h" -#include <QToolButton> - -JobRealTimeToolBar::JobRealTimeToolBar(QWidget* parent) - : StyledToolBar(parent), m_resetParametersButton(new QToolButton) -{ - setMinimumSize(minimumHeight(), minimumHeight()); - - m_resetParametersButton->setText("Reset values"); - m_resetParametersButton->setIcon(QIcon(":/images/undo-variant.svg")); - m_resetParametersButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - m_resetParametersButton->setToolTip("Reset parameter tree to initial values"); - addWidget(m_resetParametersButton); - - connect(m_resetParametersButton, &QToolButton::clicked, this, - &JobRealTimeToolBar::resetParameters); -} diff --git a/GUI/View/Fit/JobRealTimeToolBar.h b/GUI/View/Fit/JobRealTimeToolBar.h deleted file mode 100644 index 194b42ec3548d7fc8e341c08f993da6e48421372..0000000000000000000000000000000000000000 --- a/GUI/View/Fit/JobRealTimeToolBar.h +++ /dev/null @@ -1,37 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file GUI/View/Fit/JobRealTimeToolBar.h -//! @brief Defines class JobRealTimeToolBar -//! -//! @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_FIT_JOBREALTIMETOOLBAR_H -#define BORNAGAIN_GUI_VIEW_FIT_JOBREALTIMETOOLBAR_H - -#include "GUI/View/Common/StyledToolBar.h" - -class QToolButton; - -//! Represents a toolbar with buttons for ParameterTuningWidget. - -class JobRealTimeToolBar : public StyledToolBar { - Q_OBJECT - -public: - explicit JobRealTimeToolBar(QWidget* parent = nullptr); - -signals: - void resetParameters(); - -private: - QToolButton* m_resetParametersButton; -}; - -#endif // BORNAGAIN_GUI_VIEW_FIT_JOBREALTIMETOOLBAR_H diff --git a/GUI/View/Fit/ParameterTuningWidget.cpp b/GUI/View/Fit/ParameterTuningWidget.cpp index 5e775ca11c421af36fd272e3734ffde209d79c62..957e803e58fe8ab97d490503eec585b902bab7b7 100644 --- a/GUI/View/Fit/ParameterTuningWidget.cpp +++ b/GUI/View/Fit/ParameterTuningWidget.cpp @@ -19,16 +19,16 @@ #include "GUI/Model/Job/JobItem.h" #include "GUI/Model/Job/JobModel.h" #include "GUI/Util/Error.h" -#include "GUI/View/Fit/JobRealTimeToolBar.h" +#include "GUI/View/Common/StyledToolBar.h" #include "GUI/View/Fit/ParameterTuningDelegate.h" #include "GUI/View/Fit/SliderSettingsWidget.h" #include "GUI/View/Info/CautionSign.h" +#include <QAction> #include <QTreeView> #include <QVBoxLayout> ParameterTuningWidget::ParameterTuningWidget(QWidget* parent) : SessionItemWidget(parent) - , m_toolBar(new JobRealTimeToolBar(this)) , m_jobModel(nullptr) , m_parameterTuningModel(nullptr) , m_sliderSettingsWidget(new SliderSettingsWidget(this)) @@ -43,10 +43,19 @@ ParameterTuningWidget::ParameterTuningWidget(QWidget* parent) m_treeView->setDragDropMode(QAbstractItemView::NoDragDrop); m_treeView->setAttribute(Qt::WA_MacShowFocusRect, false); + auto* resetValuesAction = new QAction(QIcon(":/images/undo-variant.svg"), "Reset values", this); + resetValuesAction->setToolTip("Reset parameter tree to initial values"); + connect(resetValuesAction, &QAction::triggered, this, + &ParameterTuningWidget::restoreModelsOfCurrentJobItem); + + auto* toolBar = new StyledToolBar(this); + toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + toolBar->addAction(resetValuesAction); + auto* mainLayout = new QVBoxLayout; mainLayout->setMargin(0); mainLayout->setSpacing(0); - mainLayout->addWidget(m_toolBar); + mainLayout->addWidget(toolBar); mainLayout->addWidget(m_sliderSettingsWidget); mainLayout->addWidget(m_treeView); setLayout(mainLayout); @@ -59,8 +68,6 @@ ParameterTuningWidget::ParameterTuningWidget(QWidget* parent) &ParameterTuningWidget::onCurrentLinkChanged); connect(m_treeView, &QTreeView::customContextMenuRequested, this, &ParameterTuningWidget::onCustomContextMenuRequested); - connect(m_toolBar, &JobRealTimeToolBar::resetParameters, this, - &ParameterTuningWidget::restoreModelsOfCurrentJobItem); } QItemSelectionModel* ParameterTuningWidget::selectionModel() diff --git a/GUI/View/Fit/ParameterTuningWidget.h b/GUI/View/Fit/ParameterTuningWidget.h index 4f3ff6f3b8e8dfa5d3a368baacd9866319048036..377a442869ccdebc7741e5dabfb24481a36f17a4 100644 --- a/GUI/View/Fit/ParameterTuningWidget.h +++ b/GUI/View/Fit/ParameterTuningWidget.h @@ -17,7 +17,6 @@ #include "GUI/View/Common/SessionItemWidget.h" -class JobRealTimeToolBar; class JobModel; class JobItem; class SessionItem; @@ -68,7 +67,6 @@ private: void closeActiveEditors(); void updateJobStatus(); - JobRealTimeToolBar* m_toolBar; JobModel* m_jobModel; ParameterTuningModel* m_parameterTuningModel; SliderSettingsWidget* m_sliderSettingsWidget; diff --git a/GUI/View/Job/JobView.cpp b/GUI/View/Job/JobView.cpp index 8f5a2e7250947e6217de421196bf39e7b55567a2..3e5a9bf476f550470883b07bd7dea5ef439057b4 100644 --- a/GUI/View/Job/JobView.cpp +++ b/GUI/View/Job/JobView.cpp @@ -109,9 +109,6 @@ void JobView::createSubWindows() m_docks->addWidget(JobViewFlags::FIT_PANEL_DOCK, m_fitActivityPanel, Qt::RightDockWidgetArea); m_docks->addWidget(JobViewFlags::JOB_MESSAGE_DOCK, m_jobMessagePanel, Qt::BottomDockWidgetArea); - connect(m_jobMessagePanel, &JobMessagePanel::widgetHeightRequest, m_docks, - &DocksController::setDockHeightForWidget); - m_fitActivityPanel->setRealTimeWidget(m_jobRealTimeWidget); setCentralWidget(m_jobResultsPresenter); diff --git a/GUI/View/SampleDesigner/SampleEditorController.cpp b/GUI/View/SampleDesigner/SampleEditorController.cpp index b7a2376ecc31a46f87aa4543060636127a879cfb..2039d38c7b92d8e1fccfb0ac33f7e0d6e150bab0 100644 --- a/GUI/View/SampleDesigner/SampleEditorController.cpp +++ b/GUI/View/SampleDesigner/SampleEditorController.cpp @@ -138,8 +138,8 @@ void SampleEditorController::addParticle(ParticleLayoutItem* layoutItem, const Q newItem = layoutItem->model()->insertNewItem(classname, layoutItem); if (auto* cs = dynamic_cast<ParticleCoreShellItem*>(newItem)) { - cs->createCore(); - cs->createShell(); + cs->createCore(materialModel()); + cs->createShell(materialModel()); } // search for particle layout widget for notification @@ -160,12 +160,17 @@ void SampleEditorController::addParticle(ParticleCompositionItem* compositionIte new_particle->setFormFactor(classname); new_particle->setMaterial(materialModel()->defaultMaterial()); newItem = new_particle; - } else + } else { newItem = compositionItem->model()->insertNewItem(classname, compositionItem); + if (auto* p = dynamic_cast<ItemWithMaterial*>(newItem)) { + p->setMaterialModel(materialModel()); + p->setMaterial(materialModel()->defaultMaterial()); + } + } if (auto* cs = dynamic_cast<ParticleCoreShellItem*>(newItem)) { - cs->createCore(); - cs->createShell(); + cs->createCore(materialModel()); + cs->createShell(materialModel()); } // search for composition widget for notification @@ -187,7 +192,7 @@ void SampleEditorController::setCoreFormFactor(ParticleCoreShellForm* widget, } if (particleCoreShell->core() == nullptr) - particleCoreShell->createCore(); + particleCoreShell->createCore(materialModel()); particleCoreShell->core()->setFormFactor(formFactorModelType); widget->createCoreWidgets(); @@ -205,7 +210,7 @@ void SampleEditorController::setShellFormFactor(ParticleCoreShellForm* widget, } if (particleCoreShell->shell() == nullptr) - particleCoreShell->createShell(); + particleCoreShell->createShell(materialModel()); particleCoreShell->shell()->setFormFactor(formFactorModelType); widget->createShellWidgets(); diff --git a/GUI/View/SampleDesigner/SampleView.cpp b/GUI/View/SampleDesigner/SampleView.cpp index 6ccb40759cc433f9df350d0ff066051279b9f4bd..e59ac2d3c097f6e5924bd3d347b3991fd2df8a5c 100644 --- a/GUI/View/SampleDesigner/SampleView.cpp +++ b/GUI/View/SampleDesigner/SampleView.cpp @@ -71,9 +71,6 @@ SampleView::SampleView(QWidget* parent, ProjectDocument* document) m_docks->addWidget(REALSPACEPANEL, m_realSpacePanel, Qt::BottomDockWidgetArea); m_docks->addWidget(PYTHONPANEL, scriptPanel, Qt::BottomDockWidgetArea); - connect(scriptPanel, &ScriptPanel::widgetHeightRequest, m_docks, - &DocksController::setDockHeightForWidget); - connect(sampleSelectionView, &SampleListView::currentSampleChanged, editor, &LayerOrientedSampleEditor::setCurrentSample); diff --git a/GUI/View/SampleDesigner/ScriptPanel.cpp b/GUI/View/SampleDesigner/ScriptPanel.cpp index b48d55a3c2cb5596c9910b13dac5274fbab43be7..db157586f30402faeec11721554a71c8ca4eac75 100644 --- a/GUI/View/SampleDesigner/ScriptPanel.cpp +++ b/GUI/View/SampleDesigner/ScriptPanel.cpp @@ -34,7 +34,7 @@ const int accumulateUpdatesDuringMsec = 20.; } ScriptPanel::ScriptPanel(SampleModel* sampleModel, QWidget* parent) - : InfoPanel(parent) + : QWidget(parent) , m_textEdit(new QTextEdit) , m_sampleModel(sampleModel) , m_highlighter(nullptr) @@ -46,22 +46,14 @@ ScriptPanel::ScriptPanel(SampleModel* sampleModel, QWidget* parent) m_textEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - auto* mainLayout = new QVBoxLayout; + auto* mainLayout = new QVBoxLayout(this); mainLayout->setContentsMargins(0, 0, 0, 0); mainLayout->addWidget(m_textEdit); - auto* mainWidget = new QWidget(this); - mainWidget->setLayout(mainLayout); - m_textEdit->setReadOnly(true); QFont textFont("Monospace"); m_textEdit->setFont(textFont); m_textEdit->setFontPointSize(DesignerHelper::getPythonEditorFontSize()); - - m_stackedWidget->addWidget(mainWidget); - - setContentVisible(false); - showToolBar(false); } void ScriptPanel::updateEditor() diff --git a/GUI/View/SampleDesigner/ScriptPanel.h b/GUI/View/SampleDesigner/ScriptPanel.h index 527fbdf376b62a8b1a08f5f60c35fd3d8abdd474..bc8bd6c6c1a7b8a1fb1048c9d00168aa2fa292dc 100644 --- a/GUI/View/SampleDesigner/ScriptPanel.h +++ b/GUI/View/SampleDesigner/ScriptPanel.h @@ -15,7 +15,7 @@ #ifndef BORNAGAIN_GUI_VIEW_SAMPLEDESIGNER_SCRIPTPANEL_H #define BORNAGAIN_GUI_VIEW_SAMPLEDESIGNER_SCRIPTPANEL_H -#include "GUI/View/Common/InfoPanel.h" +#include <QWidget> class SampleModel; class PythonSyntaxHighlighter; @@ -28,7 +28,7 @@ class QModelIndex; //! Resides at the bottom of SampleView and displays a Python script. -class ScriptPanel : public InfoPanel { +class ScriptPanel : public QWidget { Q_OBJECT public: diff --git a/GUI/View/Tool/mainwindow_constants.h b/GUI/View/Tool/mainwindow_constants.h index b278003ba7eecce19d5dfe2e525430eda3f5fbc0..1dbac7aaa9adf93273afd1248cf1f6c3d797c1bb 100644 --- a/GUI/View/Tool/mainwindow_constants.h +++ b/GUI/View/Tool/mainwindow_constants.h @@ -53,7 +53,6 @@ const QString JobRealTimeWidgetName = "Job Real Time"; const QString JobPropertiesWidgetName = "Job Properties"; const QString JobFitPanelName = "Fit Panel"; const QString JobSelectorWidgetName = "Job Selector"; -const QString JobMessagePanelName = "Message Panel"; const QString JobViewActivityName = "Job View Activity"; const QString JobRealTimeActivityName = "Real Time Activity"; diff --git a/Tests/Unit/GUI/TestParticleCoreShell.cpp b/Tests/Unit/GUI/TestParticleCoreShell.cpp index 23752db3d9ad0ef13aad69daeb09df19e038d484..034c4c125131b6eef8955ec048bffe8c15dca9f6 100644 --- a/Tests/Unit/GUI/TestParticleCoreShell.cpp +++ b/Tests/Unit/GUI/TestParticleCoreShell.cpp @@ -1,3 +1,4 @@ +#include "GUI/Model/Material/MaterialModel.h" #include "GUI/Model/Sample/ParticleCompositionItem.h" #include "GUI/Model/Sample/ParticleCoreShellItem.h" #include "GUI/Model/Sample/ParticleItem.h" @@ -51,6 +52,8 @@ TEST_F(TestParticleCoreShell, moveCoreAndShell) TEST_F(TestParticleCoreShell, propertyAppearance) { SampleModel model; + MaterialModel materials; + materials.addRefractiveMaterial("Default", 1e-3, 1e-5); // empty coreshell particle auto* coreshell = model.insertItem<ParticleCoreShellItem>(); @@ -63,7 +66,7 @@ TEST_F(TestParticleCoreShell, propertyAppearance) EXPECT_EQ(pos.z(), 0.0); // adding core, and checking that abundance is disabled - auto* core = coreshell->createCore(); + auto* core = coreshell->createCore(&materials); EXPECT_FALSE(core->abundanceItem()->isEnabled()); EXPECT_TRUE(core->positionItem()->isEnabled());