Skip to content
Snippets Groups Projects
Commit 0e246185 authored by Pospelov, Gennady's avatar Pospelov, Gennady
Browse files

Domain Instrument creation moved to DomainObjectBuilder.

parent b0f2ab76
No related branches found
No related tags found
No related merge requests found
...@@ -129,13 +129,5 @@ DomainObjectBuilder::buildInterferenceFunction(const SessionItem& item) const ...@@ -129,13 +129,5 @@ DomainObjectBuilder::buildInterferenceFunction(const SessionItem& item) const
std::unique_ptr<Instrument> DomainObjectBuilder::buildInstrument(const GISASInstrumentItem& instrumentItem) const std::unique_ptr<Instrument> DomainObjectBuilder::buildInstrument(const GISASInstrumentItem& instrumentItem) const
{ {
auto instrument = std::make_unique<Instrument>(); return instrumentItem.createInstrument();
auto beam = instrumentItem.beamItem()->createBeam();
instrument->setBeam(*beam);
auto detector = instrumentItem.detectorItem()->createDetector();
instrument->setDetector(*detector);
return instrument;
} }
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
#include "GroupItem.h" #include "GroupItem.h"
#include "MaskItems.h" #include "MaskItems.h"
#include "ParameterTranslators.h" #include "ParameterTranslators.h"
#include "Instrument.h"
#include "IDetector2D.h"
namespace { namespace {
const QString background_group_label = "Type"; const QString background_group_label = "Type";
...@@ -54,6 +56,8 @@ Instrument2DItem::Instrument2DItem(const QString& modelType) ...@@ -54,6 +56,8 @@ Instrument2DItem::Instrument2DItem(const QString& modelType)
item->setToolTip("Background type"); item->setToolTip("Background type");
} }
Instrument2DItem::~Instrument2DItem() = default;
BeamItem *Instrument2DItem::beamItem() const BeamItem *Instrument2DItem::beamItem() const
{ {
return &item<BeamItem>(P_BEAM); return &item<BeamItem>(P_BEAM);
...@@ -112,6 +116,19 @@ QStringList Instrument2DItem::translateList(const QStringList& list) const ...@@ -112,6 +116,19 @@ QStringList Instrument2DItem::translateList(const QStringList& list) const
return result; return result;
} }
std::unique_ptr<Instrument> Instrument2DItem::createInstrument() const
{
std::unique_ptr<Instrument> result(new Instrument);
auto beam = beamItem()->createBeam();
result->setBeam(*beam);
auto detector = detectorItem()->createDetector();
result->setDetector(*detector);
return result;
}
GISASInstrumentItem::GISASInstrumentItem() GISASInstrumentItem::GISASInstrumentItem()
: Instrument2DItem(Constants::GISASInstrumentType) : Instrument2DItem(Constants::GISASInstrumentType)
{ {
......
...@@ -22,12 +22,14 @@ class BeamItem; ...@@ -22,12 +22,14 @@ class BeamItem;
class DetectorItem; class DetectorItem;
class MaskContainerItem; class MaskContainerItem;
class GroupItem; class GroupItem;
class Instrument;
class BA_CORE_API_ InstrumentItem : public SessionItem class BA_CORE_API_ InstrumentItem : public SessionItem
{ {
public: public:
static const QString P_IDENTIFIER; static const QString P_IDENTIFIER;
virtual std::unique_ptr<Instrument> createInstrument() const = 0;
protected: protected:
explicit InstrumentItem(const QString& modelType); explicit InstrumentItem(const QString& modelType);
}; };
...@@ -35,6 +37,8 @@ protected: ...@@ -35,6 +37,8 @@ protected:
class BA_CORE_API_ Instrument2DItem : public InstrumentItem class BA_CORE_API_ Instrument2DItem : public InstrumentItem
{ {
public: public:
virtual ~Instrument2DItem();
static const QString P_BEAM; static const QString P_BEAM;
static const QString P_DETECTOR; static const QString P_DETECTOR;
static const QString P_BACKGROUND; static const QString P_BACKGROUND;
...@@ -53,6 +57,8 @@ public: ...@@ -53,6 +57,8 @@ public:
QStringList translateList(const QStringList& list) const override; QStringList translateList(const QStringList& list) const override;
std::unique_ptr<Instrument> createInstrument() const override;
protected: protected:
explicit Instrument2DItem(const QString& modelType); explicit Instrument2DItem(const QString& modelType);
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment