diff --git a/GUI/View/Instrument/DepthprobeInstrumentEditor.cpp b/GUI/View/Instrument/DepthprobeInstrumentEditor.cpp index 0eaf771804f66a18000fa570e103dab04a0ebd65..8680fddf8c24339ca1c5d1142e6e33b07ae0d79b 100644 --- a/GUI/View/Instrument/DepthprobeInstrumentEditor.cpp +++ b/GUI/View/Instrument/DepthprobeInstrumentEditor.cpp @@ -19,11 +19,9 @@ #include "GUI/View/Instrument/ScanEditor.h" #include <QVBoxLayout> -DepthprobeInstrumentEditor::DepthprobeInstrumentEditor(QWidget* parent, - DepthprobeInstrumentItem* instrument, +DepthprobeInstrumentEditor::DepthprobeInstrumentEditor(DepthprobeInstrumentItem* instrument, MultiInstrumentNotifier* ec) - : QWidget(parent) - , m_ec(ec, instrument) + : m_ec(ec, instrument) { ASSERT(instrument); auto* layout = new QVBoxLayout(this); @@ -38,7 +36,6 @@ DepthprobeInstrumentEditor::DepthprobeInstrumentEditor(QWidget* parent, layout->addStretch(); - connect(scanEditor, &ScanEditor::dataChanged, this, &DepthprobeInstrumentEditor::dataChanged); - connect(depthAxisEditor, &AxisPropertyForm::dataChanged, this, - &DepthprobeInstrumentEditor::dataChanged); + connect(scanEditor, &ScanEditor::dataChanged, this, &IComponentEditor::dataChanged); + connect(depthAxisEditor, &AxisPropertyForm::dataChanged, this, &IComponentEditor::dataChanged); } diff --git a/GUI/View/Instrument/DepthprobeInstrumentEditor.h b/GUI/View/Instrument/DepthprobeInstrumentEditor.h index a4a5e8841ebd1c97e4077610d56f5f841be1075a..8983ca73f8dbd19afc03a76602f1ee467093b63c 100644 --- a/GUI/View/Instrument/DepthprobeInstrumentEditor.h +++ b/GUI/View/Instrument/DepthprobeInstrumentEditor.h @@ -16,21 +16,17 @@ #define BORNAGAIN_GUI_VIEW_INSTRUMENT_DEPTHPROBEINSTRUMENTEDITOR_H #include "GUI/Model/Device/InstrumentNotifier.h" -#include <QWidget> +#include "GUI/View/Widget/IComponentEditor.h" class DepthprobeInstrumentItem; class MultiInstrumentNotifier; //! Depthprobe instrument editor, for use in main scroll area of InstrumentView. -class DepthprobeInstrumentEditor : public QWidget { +class DepthprobeInstrumentEditor : public IComponentEditor { Q_OBJECT public: - DepthprobeInstrumentEditor(QWidget* parent, DepthprobeInstrumentItem* instrument, - MultiInstrumentNotifier* ec); - -signals: - void dataChanged(); + DepthprobeInstrumentEditor(DepthprobeInstrumentItem* instrument, MultiInstrumentNotifier* ec); private: InstrumentNotifier m_ec; diff --git a/GUI/View/Instrument/GISASInstrumentEditor.cpp b/GUI/View/Instrument/GISASInstrumentEditor.cpp index 2cf3071dc04cab47bbc052c8f1a03242327f7f96..87ab326c10df4ba0451d08844f083f77db0132d7 100644 --- a/GUI/View/Instrument/GISASInstrumentEditor.cpp +++ b/GUI/View/Instrument/GISASInstrumentEditor.cpp @@ -20,8 +20,7 @@ #include "GUI/View/Instrument/GISASBeamEditor.h" #include "GUI/View/Instrument/PolarizationAnalysisEditor.h" -GISASInstrumentEditor::GISASInstrumentEditor(QWidget* parent, GISASInstrumentItem* instrument) - : QWidget(parent) +GISASInstrumentEditor::GISASInstrumentEditor(GISASInstrumentItem* instrument) { ASSERT(instrument); auto* layout = new QVBoxLayout(this); @@ -41,11 +40,9 @@ GISASInstrumentEditor::GISASInstrumentEditor(QWidget* parent, GISASInstrumentIte layout->addStretch(); - connect(beamEditor, &GISASBeamEditor::dataChanged, this, &GISASInstrumentEditor::dataChanged); - connect(detectorEditor, &DetectorEditor::dataChanged, this, - &GISASInstrumentEditor::dataChanged); + connect(beamEditor, &GISASBeamEditor::dataChanged, this, &IComponentEditor::dataChanged); + connect(detectorEditor, &DetectorEditor::dataChanged, this, &IComponentEditor::dataChanged); connect(polMatricesAnalysisEditor, &PolarizationAnalysisEditor::dataChanged, this, - &GISASInstrumentEditor::dataChanged); - connect(backgroundForm, &BackgroundForm::dataChanged, this, - &GISASInstrumentEditor::dataChanged); + &IComponentEditor::dataChanged); + connect(backgroundForm, &BackgroundForm::dataChanged, this, &IComponentEditor::dataChanged); } diff --git a/GUI/View/Instrument/GISASInstrumentEditor.h b/GUI/View/Instrument/GISASInstrumentEditor.h index 2ed73068a620d299f28fefa5b0f86dfa9eddabb7..e9797f949eda4700e9aa0da11019a813425a12de 100644 --- a/GUI/View/Instrument/GISASInstrumentEditor.h +++ b/GUI/View/Instrument/GISASInstrumentEditor.h @@ -15,19 +15,16 @@ #ifndef BORNAGAIN_GUI_VIEW_INSTRUMENT_GISASINSTRUMENTEDITOR_H #define BORNAGAIN_GUI_VIEW_INSTRUMENT_GISASINSTRUMENTEDITOR_H -#include <QWidget> +#include "GUI/View/Widget/IComponentEditor.h" class GISASInstrumentItem; //! Editor for GISAS instruments, for use in main scroll area of InstrumentView. -class GISASInstrumentEditor : public QWidget { +class GISASInstrumentEditor : public IComponentEditor { Q_OBJECT public: - GISASInstrumentEditor(QWidget* parent, GISASInstrumentItem* instrument); - -signals: - void dataChanged(); + GISASInstrumentEditor(GISASInstrumentItem* instrument); }; #endif // BORNAGAIN_GUI_VIEW_INSTRUMENT_GISASINSTRUMENTEDITOR_H diff --git a/GUI/View/Instrument/InstrumentView.cpp b/GUI/View/Instrument/InstrumentView.cpp index b1de60967de0e91b3ebaa10a138b6f15289aa262..f205ff9d426ffe511c7afcf2d3e291fd6617779c 100644 --- a/GUI/View/Instrument/InstrumentView.cpp +++ b/GUI/View/Instrument/InstrumentView.cpp @@ -128,25 +128,25 @@ void InstrumentView::createWidgetsForCurrentInstrument() auto* ec = gDoc->multiNotifier(); if (auto* ii = dynamic_cast<SpecularInstrumentItem*>(currentInstrument)) { - auto* editor = new SpecularInstrumentEditor(m_scrollArea, ii, ec); + auto* editor = new SpecularInstrumentEditor(ii, ec); connect(editor, &SpecularInstrumentEditor::dataChanged, this, &InstrumentView::onInstrumentChangedByEditor); layout->addWidget(editor); } else if (auto* ii = dynamic_cast<OffspecInstrumentItem*>(currentInstrument)) { - auto* editor = new OffspecInstrumentEditor(m_scrollArea, ii, ec); + auto* editor = new OffspecInstrumentEditor(ii, ec); connect(editor, &OffspecInstrumentEditor::dataChanged, this, &InstrumentView::onInstrumentChangedByEditor); layout->addWidget(editor); } else if (auto* ii = dynamic_cast<GISASInstrumentItem*>(currentInstrument)) { - auto* editor = new GISASInstrumentEditor(m_scrollArea, ii); + auto* editor = new GISASInstrumentEditor(ii); connect(editor, &GISASInstrumentEditor::dataChanged, this, &InstrumentView::onInstrumentChangedByEditor); layout->addWidget(editor); } else if (auto* ii = dynamic_cast<DepthprobeInstrumentItem*>(currentInstrument)) { - auto* editor = new DepthprobeInstrumentEditor(m_scrollArea, ii, ec); + auto* editor = new DepthprobeInstrumentEditor(ii, ec); connect(editor, &DepthprobeInstrumentEditor::dataChanged, this, &InstrumentView::onInstrumentChangedByEditor); layout->addWidget(editor); diff --git a/GUI/View/Instrument/OffspecInstrumentEditor.cpp b/GUI/View/Instrument/OffspecInstrumentEditor.cpp index 77ad00d055872b5ee0c3cea848546d35fd2e0c20..9af894134b5589bd2658f22fe0d457c37547fe4d 100644 --- a/GUI/View/Instrument/OffspecInstrumentEditor.cpp +++ b/GUI/View/Instrument/OffspecInstrumentEditor.cpp @@ -19,11 +19,10 @@ #include "GUI/View/Instrument/PolarizationAnalysisEditor.h" #include "GUI/View/Instrument/ScanEditor.h" -OffspecInstrumentEditor::OffspecInstrumentEditor(QWidget* parent, OffspecInstrumentItem* instrument, +OffspecInstrumentEditor::OffspecInstrumentEditor(OffspecInstrumentItem* instrument, MultiInstrumentNotifier* ec) - : QWidget(parent) - , m_ec(ec, instrument) + : m_ec(ec, instrument) { ASSERT(instrument); auto* layout = new QVBoxLayout(this); @@ -40,9 +39,9 @@ OffspecInstrumentEditor::OffspecInstrumentEditor(QWidget* parent, OffspecInstrum layout->addStretch(); - connect(scanEditor, &ScanEditor::dataChanged, this, &OffspecInstrumentEditor::dataChanged); + connect(scanEditor, &ScanEditor::dataChanged, this, &IComponentEditor::dataChanged); connect(detectorEditor, &OffspecDetectorEditor::dataChanged, this, - &OffspecInstrumentEditor::dataChanged); + &IComponentEditor::dataChanged); connect(polMatricesAnalysisEditor, &PolarizationAnalysisEditor::dataChanged, this, - &OffspecInstrumentEditor::dataChanged); + &IComponentEditor::dataChanged); } diff --git a/GUI/View/Instrument/OffspecInstrumentEditor.h b/GUI/View/Instrument/OffspecInstrumentEditor.h index 14bf320342943caf1cf7f68e846f76ff313cfd72..3c25123f0511005fbd8ab6935be7772c0209d15e 100644 --- a/GUI/View/Instrument/OffspecInstrumentEditor.h +++ b/GUI/View/Instrument/OffspecInstrumentEditor.h @@ -16,21 +16,17 @@ #define BORNAGAIN_GUI_VIEW_INSTRUMENT_OFFSPECINSTRUMENTEDITOR_H #include "GUI/Model/Device/InstrumentNotifier.h" -#include <QWidget> +#include "GUI/View/Widget/IComponentEditor.h" class MultiInstrumentNotifier; class OffspecInstrumentItem; //! Offspec instrument editor, for use in main scroll area of InstrumentView. -class OffspecInstrumentEditor : public QWidget { +class OffspecInstrumentEditor : public IComponentEditor { Q_OBJECT public: - OffspecInstrumentEditor(QWidget* parent, OffspecInstrumentItem* instrument, - MultiInstrumentNotifier* ec); - -signals: - void dataChanged(); + OffspecInstrumentEditor(OffspecInstrumentItem* instrument, MultiInstrumentNotifier* ec); private: InstrumentNotifier m_ec; diff --git a/GUI/View/Instrument/SpecularInstrumentEditor.cpp b/GUI/View/Instrument/SpecularInstrumentEditor.cpp index 23d26f89f9b1b21ab7c6aa83d37cb1e4fc8b0d1b..1ad958d3c878fe905f71546761775c1e5b18cc4d 100644 --- a/GUI/View/Instrument/SpecularInstrumentEditor.cpp +++ b/GUI/View/Instrument/SpecularInstrumentEditor.cpp @@ -19,11 +19,9 @@ #include "GUI/View/Instrument/PolarizationAnalysisEditor.h" #include "GUI/View/Instrument/ScanEditor.h" -SpecularInstrumentEditor::SpecularInstrumentEditor(QWidget* parent, - SpecularInstrumentItem* instrument, +SpecularInstrumentEditor::SpecularInstrumentEditor(SpecularInstrumentItem* instrument, MultiInstrumentNotifier* ec) - : QWidget(parent) - , m_ec(ec, instrument) + : m_ec(ec, instrument) { ASSERT(instrument); auto* layout = new QVBoxLayout(this); @@ -40,9 +38,8 @@ SpecularInstrumentEditor::SpecularInstrumentEditor(QWidget* parent, layout->addStretch(); - connect(scanEditor, &ScanEditor::dataChanged, this, &SpecularInstrumentEditor::dataChanged); + connect(scanEditor, &ScanEditor::dataChanged, this, &IComponentEditor::dataChanged); connect(polMatricesAnalysisEditor, &PolarizationAnalysisEditor::dataChanged, this, - &SpecularInstrumentEditor::dataChanged); - connect(backgroundForm, &BackgroundForm::dataChanged, this, - &SpecularInstrumentEditor::dataChanged); + &IComponentEditor::dataChanged); + connect(backgroundForm, &BackgroundForm::dataChanged, this, &IComponentEditor::dataChanged); } diff --git a/GUI/View/Instrument/SpecularInstrumentEditor.h b/GUI/View/Instrument/SpecularInstrumentEditor.h index 06273e9c07b3ad691a4b03f3f734a7f5866100fd..a34dc07b4aa5e0969d506f0e41038602a868ba55 100644 --- a/GUI/View/Instrument/SpecularInstrumentEditor.h +++ b/GUI/View/Instrument/SpecularInstrumentEditor.h @@ -16,21 +16,17 @@ #define BORNAGAIN_GUI_VIEW_INSTRUMENT_SPECULARINSTRUMENTEDITOR_H #include "GUI/Model/Device/InstrumentNotifier.h" -#include <QWidget> +#include "GUI/View/Widget/IComponentEditor.h" class MultiInstrumentNotifier; class SpecularInstrumentItem; //! Specular instrument editor, for use in main scroll area of InstrumentView. -class SpecularInstrumentEditor : public QWidget { +class SpecularInstrumentEditor : public IComponentEditor { Q_OBJECT public: - SpecularInstrumentEditor(QWidget* parent, SpecularInstrumentItem* instrument, - MultiInstrumentNotifier* ec); - -signals: - void dataChanged(); + SpecularInstrumentEditor(SpecularInstrumentItem* instrument, MultiInstrumentNotifier* ec); private: InstrumentNotifier m_ec; diff --git a/GUI/View/Widget/IComponentEditor.cpp b/GUI/View/Widget/IComponentEditor.cpp new file mode 100644 index 0000000000000000000000000000000000000000..788f82697a1c9354ae1a766c1d5add50595c6483 --- /dev/null +++ b/GUI/View/Widget/IComponentEditor.cpp @@ -0,0 +1,17 @@ +// ************************************************************************************************ +// +// BornAgain: simulate and fit reflection and scattering +// +//! @file GUI/View/Widget/IComponentEditor.cpp +//! @brief Implements class IComponentEditor. +//! +//! @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/Widget/IComponentEditor.h" + +IComponentEditor::IComponentEditor() = default; diff --git a/GUI/View/Widget/IComponentEditor.h b/GUI/View/Widget/IComponentEditor.h new file mode 100644 index 0000000000000000000000000000000000000000..8f05c9d763d5f99547d8291ef05e4f26a3b0201b --- /dev/null +++ b/GUI/View/Widget/IComponentEditor.h @@ -0,0 +1,30 @@ +// ************************************************************************************************ +// +// BornAgain: simulate and fit reflection and scattering +// +//! @file GUI/View/Widget/IComponentEditor.h +//! @brief Defines class IComponentEditor. +//! +//! @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_WIDGET_ICOMPONENTEDITOR_H +#define BORNAGAIN_GUI_VIEW_WIDGET_ICOMPONENTEDITOR_H + +#include <QWidget> + +//! Base class for model component editors + +class IComponentEditor : public QWidget { + Q_OBJECT +public: + IComponentEditor(); +signals: + void dataChanged(); +}; + +#endif // BORNAGAIN_GUI_VIEW_WIDGET_ICOMPONENTEDITOR_H