diff --git a/GUI/coregui/Models/DepthProbeInstrumentItem.cpp b/GUI/coregui/Models/DepthProbeInstrumentItem.cpp deleted file mode 100644 index afea9a15517568a9efdced3300296e2fbcb62209..0000000000000000000000000000000000000000 --- a/GUI/coregui/Models/DepthProbeInstrumentItem.cpp +++ /dev/null @@ -1,99 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file GUI/coregui/Models/DepthProbeInstrumentItem.cpp -//! @brief Implements DepthProbeInstrumentItem class -//! -//! @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/coregui/Models/DepthProbeInstrumentItem.h" -#include "Base/Const/Units.h" -#include "Core/Simulation/DepthProbeSimulation.h" -#include "GUI/coregui/Models/AxesItems.h" -#include "GUI/coregui/Models/BeamItems.h" -#include "GUI/coregui/Models/BeamWavelengthItem.h" -#include "GUI/coregui/Models/SpecularBeamInclinationItem.h" -#include "GUI/coregui/Models/TransformToDomain.h" - -const QString DepthProbeInstrumentItem::P_BEAM = "Beam"; -const QString DepthProbeInstrumentItem::P_Z_AXIS = "Z axis"; - -DepthProbeInstrumentItem::DepthProbeInstrumentItem() : InstrumentItem("DepthProbeInstrument") -{ - setItemName("DepthProbeInstrument"); - - addProperty<SpecularBeamItem>(P_BEAM); - - auto axisItem = beamItem()->currentInclinationAxisItem(); - axisItem->setLowerBound(0.0); - axisItem->setUpperBound(1.0); - axisItem->setBinCount(500); - - auto axis = addProperty<BasicAxisItem>(P_Z_AXIS); - axis->setLowerBound(-100.0); - axis->setUpperBound(100.0); - axis->getItem(BasicAxisItem::P_TITLE)->setVisible(false); - axis->getItem(BasicAxisItem::P_NBINS) - ->setToolTip("Number of points in scan across sample bulk"); - axis->getItem(BasicAxisItem::P_MIN_DEG) - ->setToolTip("Starting value below sample horizont in nm"); - axis->getItem(BasicAxisItem::P_MAX_DEG)->setToolTip("Ending value above sample horizont in nm"); -} - -SpecularBeamItem* DepthProbeInstrumentItem::beamItem() const -{ - return item<SpecularBeamItem>(P_BEAM); -} - -std::unique_ptr<Instrument> DepthProbeInstrumentItem::createInstrument() const -{ - throw std::runtime_error("DepthProbeInstrumentItem::createInstrument()"); -} - -std::vector<int> DepthProbeInstrumentItem::shape() const -{ - return std::vector<int>(); // no certain shape to avoid linking to real data -} - -void DepthProbeInstrumentItem::updateToRealData(const RealDataItem*) -{ - throw std::runtime_error("DepthProbeInstrumentItem::updateToRealData()"); -} - -QString DepthProbeInstrumentItem::defaultName() const -{ - return "DepthProbe"; -} - -std::unique_ptr<DepthProbeSimulation> DepthProbeInstrumentItem::createSimulation() const -{ - std::unique_ptr<DepthProbeSimulation> simulation = std::make_unique<DepthProbeSimulation>(); - - const auto axis_item = beamItem()->currentInclinationAxisItem(); - - auto axis = axis_item->createAxis(Units::deg); - - simulation->setBeamParameters(beamItem()->wavelength(), static_cast<int>(axis->size()), - axis->lowerBound(), axis->upperBound()); - - auto depthAxisItem = dynamic_cast<BasicAxisItem*>(getItem(P_Z_AXIS)); - auto depthAxis = depthAxisItem->createAxis(1.0); - simulation->setZSpan(depthAxis->size(), depthAxis->lowerBound(), depthAxis->upperBound()); - - TransformToDomain::setBeamDistribution( - "Wavelength", *beamItem()->item<BeamWavelengthItem>(SpecularBeamItem::P_WAVELENGTH), - *simulation.get()); - - TransformToDomain::setBeamDistribution( - "InclinationAngle", - *beamItem()->item<SpecularBeamInclinationItem>(SpecularBeamItem::P_INCLINATION_ANGLE), - *simulation.get()); - - return simulation; -} diff --git a/GUI/coregui/Models/DepthProbeInstrumentItem.h b/GUI/coregui/Models/DepthProbeInstrumentItem.h deleted file mode 100644 index ba1f29d09a04c2e0c6fe03242fb8bf7731100855..0000000000000000000000000000000000000000 --- a/GUI/coregui/Models/DepthProbeInstrumentItem.h +++ /dev/null @@ -1,43 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file GUI/coregui/Models/DepthProbeInstrumentItem.h -//! @brief Defines DepthProbeInstrumentItem class -//! -//! @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_COREGUI_MODELS_DEPTHPROBEINSTRUMENTITEM_H -#define BORNAGAIN_GUI_COREGUI_MODELS_DEPTHPROBEINSTRUMENTITEM_H - -#include "GUI/coregui/Models/InstrumentItems.h" - -class DepthProbeSimulation; - -//! Depth probe instrument. - -class BA_CORE_API_ DepthProbeInstrumentItem : public InstrumentItem { -public: - static const QString P_BEAM; - static const QString P_Z_AXIS; - - DepthProbeInstrumentItem(); - - SpecularBeamItem* beamItem() const override; - - std::unique_ptr<Instrument> createInstrument() const override; - std::vector<int> shape() const override; - void updateToRealData(const RealDataItem* item) override; - virtual QString defaultName() const override; - - // FIXME switch to base ISimulation class after InstrumentItem refactoring and - // after ISimulation gets createUnitConverter method - std::unique_ptr<DepthProbeSimulation> createSimulation() const; -}; - -#endif // BORNAGAIN_GUI_COREGUI_MODELS_DEPTHPROBEINSTRUMENTITEM_H diff --git a/GUI/coregui/Models/DomainObjectBuilder.cpp b/GUI/coregui/Models/DomainObjectBuilder.cpp index a2a359ef452bbb7d4195708fbc0e967dd5306fb0..d7489d73fd746561a374f63d08e4bd1316e48847 100644 --- a/GUI/coregui/Models/DomainObjectBuilder.cpp +++ b/GUI/coregui/Models/DomainObjectBuilder.cpp @@ -20,8 +20,8 @@ #include "Device/Detector/UnitConverter2D.h" #include "GUI/coregui/Models/AxesItems.h" #include "GUI/coregui/Models/ComboProperty.h" -#include "GUI/coregui/Models/DepthProbeInstrumentItem.h" #include "GUI/coregui/Models/InterferenceFunctionItems.h" +#include "GUI/coregui/Models/InstrumentItems.h" #include "GUI/coregui/Models/LayerItem.h" #include "GUI/coregui/Models/ParticleDistributionItem.h" #include "GUI/coregui/Models/ParticleLayoutItem.h" diff --git a/GUI/coregui/Models/DomainSimulationBuilder.cpp b/GUI/coregui/Models/DomainSimulationBuilder.cpp index 6d63782be560d98aeaf06253526608367b8c571e..907bd0f2812e48cf175792e1353a13971c120876 100644 --- a/GUI/coregui/Models/DomainSimulationBuilder.cpp +++ b/GUI/coregui/Models/DomainSimulationBuilder.cpp @@ -20,10 +20,10 @@ #include "Device/Beam/IFootprintFactor.h" #include "GUI/coregui/Models/AxesItems.h" #include "GUI/coregui/Models/BackgroundItems.h" -#include "GUI/coregui/Models/DepthProbeInstrumentItem.h" #include "GUI/coregui/Models/DetectorItems.h" #include "GUI/coregui/Models/DomainObjectBuilder.h" #include "GUI/coregui/Models/FootprintItems.h" +#include "GUI/coregui/Models/InstrumentItems.h" #include "GUI/coregui/Models/MultiLayerItem.h" #include "GUI/coregui/Models/SimulationOptionsItem.h" #include "GUI/coregui/Models/SpecularBeamInclinationItem.h" @@ -115,12 +115,12 @@ createSpecularSimulation(std::unique_ptr<MultiLayer> P_multilayer, } std::unique_ptr<DepthProbeSimulation> -createDepthProbeSimulation(std::unique_ptr<MultiLayer> P_multilayer, +createDepthProbeSimulation(std::unique_ptr<MultiLayer> multilayer, const DepthProbeInstrumentItem* instrument, const SimulationOptionsItem* options_item) { std::unique_ptr<DepthProbeSimulation> ret = instrument->createSimulation(); - ret->setSample(*P_multilayer); + ret->setSample(*multilayer); if (options_item) TransformToDomain::setSimulationOptions(ret.get(), *options_item); @@ -130,6 +130,7 @@ createDepthProbeSimulation(std::unique_ptr<MultiLayer> P_multilayer, } // namespace + std::unique_ptr<ISimulation> DomainSimulationBuilder::createSimulation(const MultiLayerItem* sampleItem, const InstrumentItem* instrumentItem, diff --git a/GUI/coregui/Models/InstrumentItems.cpp b/GUI/coregui/Models/InstrumentItems.cpp index f41ca9295725a23d073f8bc82f8808a585a2b10c..98ee33e9313221cd7a13a3a56087a19826e7f2e0 100644 --- a/GUI/coregui/Models/InstrumentItems.cpp +++ b/GUI/coregui/Models/InstrumentItems.cpp @@ -13,11 +13,13 @@ // ************************************************************************************************ #include "GUI/coregui/Models/InstrumentItems.h" +#include "Base/Const/Units.h" #include "Core/Scan/UnitConverter1D.h" +#include "Core/Simulation/DepthProbeSimulation.h" #include "Device/Detector/IDetector2D.h" #include "Device/Instrument/Instrument.h" #include "GUI/coregui/Models/BackgroundItems.h" -#include "GUI/coregui/Models/BeamItems.h" +#include "GUI/coregui/Models/BeamWavelengthItem.h" #include "GUI/coregui/Models/DataItem.h" #include "GUI/coregui/Models/DetectorItems.h" #include "GUI/coregui/Models/GroupItem.h" @@ -27,6 +29,8 @@ #include "GUI/coregui/Models/PointwiseAxisItem.h" #include "GUI/coregui/Models/RealDataItem.h" #include "GUI/coregui/Models/SessionModel.h" +#include "GUI/coregui/Models/SpecularBeamInclinationItem.h" +#include "GUI/coregui/Models/TransformToDomain.h" #include "GUI/coregui/utils/GUIHelpers.h" namespace { @@ -345,3 +349,86 @@ QString OffSpecularInstrumentItem::defaultName() const { return "OffSpecular"; } + + +// ************************************************************************************************ +// class DepthProbeInstrumentItem +// ************************************************************************************************ + + +const QString DepthProbeInstrumentItem::P_BEAM = "Beam"; +const QString DepthProbeInstrumentItem::P_Z_AXIS = "Z axis"; + +DepthProbeInstrumentItem::DepthProbeInstrumentItem() : InstrumentItem("DepthProbeInstrument") +{ + setItemName("DepthProbeInstrument"); + + addProperty<SpecularBeamItem>(P_BEAM); + + auto axisItem = beamItem()->currentInclinationAxisItem(); + axisItem->setLowerBound(0.0); + axisItem->setUpperBound(1.0); + axisItem->setBinCount(500); + + auto axis = addProperty<BasicAxisItem>(P_Z_AXIS); + axis->setLowerBound(-100.0); + axis->setUpperBound(100.0); + axis->getItem(BasicAxisItem::P_TITLE)->setVisible(false); + axis->getItem(BasicAxisItem::P_NBINS) + ->setToolTip("Number of points in scan across sample bulk"); + axis->getItem(BasicAxisItem::P_MIN_DEG) + ->setToolTip("Starting value below sample horizont in nm"); + axis->getItem(BasicAxisItem::P_MAX_DEG)->setToolTip("Ending value above sample horizont in nm"); +} + +SpecularBeamItem* DepthProbeInstrumentItem::beamItem() const +{ + return item<SpecularBeamItem>(P_BEAM); +} + +std::unique_ptr<Instrument> DepthProbeInstrumentItem::createInstrument() const +{ + throw std::runtime_error("DepthProbeInstrumentItem::createInstrument()"); +} + +std::vector<int> DepthProbeInstrumentItem::shape() const +{ + return std::vector<int>(); // no certain shape to avoid linking to real data +} + +void DepthProbeInstrumentItem::updateToRealData(const RealDataItem*) +{ + throw std::runtime_error("DepthProbeInstrumentItem::updateToRealData()"); +} + +QString DepthProbeInstrumentItem::defaultName() const +{ + return "DepthProbe"; +} + +std::unique_ptr<DepthProbeSimulation> DepthProbeInstrumentItem::createSimulation() const +{ + std::unique_ptr<DepthProbeSimulation> simulation = std::make_unique<DepthProbeSimulation>(); + + const auto axis_item = beamItem()->currentInclinationAxisItem(); + + auto axis = axis_item->createAxis(Units::deg); + + simulation->setBeamParameters(beamItem()->wavelength(), static_cast<int>(axis->size()), + axis->lowerBound(), axis->upperBound()); + + auto depthAxisItem = dynamic_cast<BasicAxisItem*>(getItem(P_Z_AXIS)); + auto depthAxis = depthAxisItem->createAxis(1.0); + simulation->setZSpan(depthAxis->size(), depthAxis->lowerBound(), depthAxis->upperBound()); + + TransformToDomain::setBeamDistribution( + "Wavelength", *beamItem()->item<BeamWavelengthItem>(SpecularBeamItem::P_WAVELENGTH), + *simulation.get()); + + TransformToDomain::setBeamDistribution( + "InclinationAngle", + *beamItem()->item<SpecularBeamInclinationItem>(SpecularBeamItem::P_INCLINATION_ANGLE), + *simulation.get()); + + return simulation; +} diff --git a/GUI/coregui/Models/InstrumentItems.h b/GUI/coregui/Models/InstrumentItems.h index d79f2051fff0712fd7ee387f8e6d063b803585df..aa3e0eb0f2081ec54c208f54b7b48302f1e52168 100644 --- a/GUI/coregui/Models/InstrumentItems.h +++ b/GUI/coregui/Models/InstrumentItems.h @@ -15,10 +15,11 @@ #ifndef BORNAGAIN_GUI_COREGUI_MODELS_INSTRUMENTITEMS_H #define BORNAGAIN_GUI_COREGUI_MODELS_INSTRUMENTITEMS_H -#include "GUI/coregui/Models/BeamItems.h" +#include "GUI/coregui/Models/BeamItems.h" // inheritance prevents forward declaration class BackgroundItem; class DataItem; +class DepthProbeSimulation; class DetectorItem; class GroupItem; class Instrument; @@ -123,4 +124,24 @@ public: virtual QString defaultName() const override; }; + +class BA_CORE_API_ DepthProbeInstrumentItem : public InstrumentItem { +public: + static const QString P_BEAM; + static const QString P_Z_AXIS; + + DepthProbeInstrumentItem(); + + SpecularBeamItem* beamItem() const override; + + std::unique_ptr<Instrument> createInstrument() const override; + std::vector<int> shape() const override; + void updateToRealData(const RealDataItem* item) override; + virtual QString defaultName() const override; + + // FIXME switch to base ISimulation class after InstrumentItem refactoring and + // after ISimulation gets createUnitConverter method + std::unique_ptr<DepthProbeSimulation> createSimulation() const; +}; + #endif // BORNAGAIN_GUI_COREGUI_MODELS_INSTRUMENTITEMS_H diff --git a/GUI/coregui/Models/ItemCatalog.cpp b/GUI/coregui/Models/ItemCatalog.cpp index 4c095c430c03c65cecdff1dcc139fd281dddbd4e..a88ffd651e0b57eff86358900d99a71a0fd5e50c 100644 --- a/GUI/coregui/Models/ItemCatalog.cpp +++ b/GUI/coregui/Models/ItemCatalog.cpp @@ -19,7 +19,6 @@ #include "GUI/coregui/Models/Data1DViewItem.h" #include "GUI/coregui/Models/DataProperties.h" #include "GUI/coregui/Models/DataPropertyContainer.h" -#include "GUI/coregui/Models/DepthProbeInstrumentItem.h" #include "GUI/coregui/Models/FTDecayFunctionItems.h" #include "GUI/coregui/Models/FTDistributionItems.h" #include "GUI/coregui/Models/FitParameterItems.h" @@ -27,6 +26,7 @@ #include "GUI/coregui/Models/FootprintItems.h" #include "GUI/coregui/Models/FormFactorItems.h" #include "GUI/coregui/Models/GroupItem.h" +#include "GUI/coregui/Models/InstrumentItems.h" #include "GUI/coregui/Models/IntensityDataItem.h" #include "GUI/coregui/Models/InterferenceFunctionItems.h" #include "GUI/coregui/Models/JobItem.h" diff --git a/GUI/coregui/Models/JobModelFunctions.cpp b/GUI/coregui/Models/JobModelFunctions.cpp index 794d0cd693cea637372d0737e15e672a969092c8..e0e1544ef630fcf8d5702e777701cf0542ea16e2 100644 --- a/GUI/coregui/Models/JobModelFunctions.cpp +++ b/GUI/coregui/Models/JobModelFunctions.cpp @@ -18,7 +18,6 @@ #include "Device/Unit/IUnitConverter.h" #include "GUI/coregui/Models/Data1DViewItem.h" #include "GUI/coregui/Models/DataPropertyContainer.h" -#include "GUI/coregui/Models/DepthProbeInstrumentItem.h" #include "GUI/coregui/Models/DetectorItems.h" #include "GUI/coregui/Models/DomainObjectBuilder.h" #include "GUI/coregui/Models/FitParameterItems.h" diff --git a/GUI/coregui/Models/SessionDecorationModel.cpp b/GUI/coregui/Models/SessionDecorationModel.cpp index 08e166e84681c6fb44ad583608c3ad8a70a7a854..938b0a014771277331b07dca8ef9ab896cbf2440 100644 --- a/GUI/coregui/Models/SessionDecorationModel.cpp +++ b/GUI/coregui/Models/SessionDecorationModel.cpp @@ -13,7 +13,6 @@ // ************************************************************************************************ #include "GUI/coregui/Models/SessionDecorationModel.h" -#include "GUI/coregui/Models/DepthProbeInstrumentItem.h" #include "GUI/coregui/Models/InstrumentItems.h" #include "GUI/coregui/Models/MaterialItem.h" #include "GUI/coregui/Models/SessionModel.h" diff --git a/GUI/coregui/Views/InstrumentWidgets/DepthProbeInstrumentEditor.cpp b/GUI/coregui/Views/InstrumentWidgets/DepthProbeInstrumentEditor.cpp index 36b6ef34bb06df3743899ea6c0e3b15b381371fd..acde70ca74633194322de8410bd221760ec33e13 100644 --- a/GUI/coregui/Views/InstrumentWidgets/DepthProbeInstrumentEditor.cpp +++ b/GUI/coregui/Views/InstrumentWidgets/DepthProbeInstrumentEditor.cpp @@ -13,7 +13,7 @@ // ************************************************************************************************ #include "GUI/coregui/Views/InstrumentWidgets/DepthProbeInstrumentEditor.h" -#include "GUI/coregui/Models/DepthProbeInstrumentItem.h" +#include "GUI/coregui/Models/InstrumentItems.h" #include "GUI/coregui/Models/SpecularBeamInclinationItem.h" #include "GUI/coregui/Views/InfoWidgets/DistributionDialog.h" #include "GUI/coregui/Views/PropertyEditor/ComponentEditor.h" diff --git a/GUI/coregui/Views/InstrumentWidgets/InstrumentPresenter.cpp b/GUI/coregui/Views/InstrumentWidgets/InstrumentPresenter.cpp index 9f12cfd69ef6889d5b2cbf53ab2b70cee1c14d80..03e2c5cf2e5dc22980bb3e4f8aa16fb9230d2be1 100644 --- a/GUI/coregui/Views/InstrumentWidgets/InstrumentPresenter.cpp +++ b/GUI/coregui/Views/InstrumentWidgets/InstrumentPresenter.cpp @@ -13,7 +13,6 @@ // ************************************************************************************************ #include "GUI/coregui/Views/InstrumentWidgets/InstrumentPresenter.h" -#include "GUI/coregui/Models/DepthProbeInstrumentItem.h" #include "GUI/coregui/Models/InstrumentItems.h" #include "GUI/coregui/Models/SessionItem.h" #include "GUI/coregui/Views/InstrumentWidgets/DepthProbeInstrumentEditor.h" diff --git a/GUI/coregui/Views/InstrumentWidgets/InstrumentViewActions.cpp b/GUI/coregui/Views/InstrumentWidgets/InstrumentViewActions.cpp index 8f2c92f192df69b872272ba1895f29cb17d8f80b..cdacc5b732f6234065aed0c34de6239285c68f25 100644 --- a/GUI/coregui/Views/InstrumentWidgets/InstrumentViewActions.cpp +++ b/GUI/coregui/Views/InstrumentWidgets/InstrumentViewActions.cpp @@ -13,7 +13,6 @@ // ************************************************************************************************ #include "GUI/coregui/Views/InstrumentWidgets/InstrumentViewActions.h" -#include "GUI/coregui/Models/DepthProbeInstrumentItem.h" #include "GUI/coregui/Models/GroupItem.h" #include "GUI/coregui/Models/InstrumentItems.h" #include "GUI/coregui/Models/ModelUtils.h"