Skip to content
Snippets Groups Projects
Commit 9ff8b1e1 authored by Yurov, Dmitry's avatar Yurov, Dmitry
Browse files

Remove setShape in favor of updateToRealData

Redmine: #2217
parent 8d091d7e
No related branches found
No related tags found
No related merge requests found
...@@ -62,9 +62,9 @@ std::vector<int> DepthProbeInstrumentItem::shape() const ...@@ -62,9 +62,9 @@ std::vector<int> DepthProbeInstrumentItem::shape() const
throw std::runtime_error("DepthProbeInstrumentItem::shape()"); throw std::runtime_error("DepthProbeInstrumentItem::shape()");
} }
void DepthProbeInstrumentItem::setShape(const std::vector<int>&) void DepthProbeInstrumentItem::updateToRealData(const RealDataItem*)
{ {
throw std::runtime_error("DepthProbeInstrumentItem::setShape()"); throw std::runtime_error("DepthProbeInstrumentItem::updateToRealData()");
} }
std::unique_ptr<DepthProbeSimulation> DepthProbeInstrumentItem::createSimulation() const std::unique_ptr<DepthProbeSimulation> DepthProbeInstrumentItem::createSimulation() const
......
...@@ -33,7 +33,7 @@ public: ...@@ -33,7 +33,7 @@ public:
std::unique_ptr<Instrument> createInstrument() const override; std::unique_ptr<Instrument> createInstrument() const override;
std::vector<int> shape() const override; std::vector<int> shape() const override;
void setShape(const std::vector<int>&) override; void updateToRealData(const RealDataItem* item) override;
// FIXME switch to base Simulation class after InstrumentItem refactoring and // FIXME switch to base Simulation class after InstrumentItem refactoring and
// after Simulation gets createUnitConverter method // after Simulation gets createUnitConverter method
......
...@@ -71,11 +71,6 @@ GroupItem* InstrumentItem::backgroundGroup() ...@@ -71,11 +71,6 @@ GroupItem* InstrumentItem::backgroundGroup()
return &item<GroupItem>(P_BACKGROUND); return &item<GroupItem>(P_BACKGROUND);
} }
void InstrumentItem::updateToRealData(const RealDataItem *item)
{
setShape(item->shape());
}
bool InstrumentItem::alignedWith(const RealDataItem* item) const bool InstrumentItem::alignedWith(const RealDataItem* item) const
{ {
return shape() == item->shape(); return shape() == item->shape();
...@@ -136,15 +131,6 @@ std::vector<int> SpecularInstrumentItem::shape() const ...@@ -136,15 +131,6 @@ std::vector<int> SpecularInstrumentItem::shape() const
return {axis_item->getItemValue(BasicAxisItem::P_NBINS).toInt()}; return {axis_item->getItemValue(BasicAxisItem::P_NBINS).toInt()};
} }
void SpecularInstrumentItem::setShape(const std::vector<int>& data_shape)
{
if (shape().size() != data_shape.size())
throw GUIHelpers::Error("Error in SpecularInstrumentItem::setShape: The type of "
"instrument is incompatible with passed data shape.");
auto axis_item = beamItem()->currentInclinationAxisItem();
axis_item->setItemValue(BasicAxisItem::P_NBINS, data_shape[0]);
}
void SpecularInstrumentItem::updateToRealData(const RealDataItem* item) void SpecularInstrumentItem::updateToRealData(const RealDataItem* item)
{ {
if (shape().size() != item->shape().size()) if (shape().size() != item->shape().size())
...@@ -254,10 +240,14 @@ std::vector<int> GISASInstrumentItem::shape() const ...@@ -254,10 +240,14 @@ std::vector<int> GISASInstrumentItem::shape() const
return {detector_item->xSize(), detector_item->ySize()}; return {detector_item->xSize(), detector_item->ySize()};
} }
void GISASInstrumentItem::setShape(const std::vector<int>& data_shape) void GISASInstrumentItem::updateToRealData(const RealDataItem* item)
{ {
if (!item)
return;
const auto data_shape = item->shape();
if (shape().size() != data_shape.size()) if (shape().size() != data_shape.size())
throw GUIHelpers::Error("Error in GISASInstrumentItem::setShape: The type of " throw GUIHelpers::Error("Error in GISASInstrumentItem::updateToRealData: The type of "
"instrument is incompatible with passed data shape."); "instrument is incompatible with passed data shape.");
detectorItem()->setXSize(data_shape[0]); detectorItem()->setXSize(data_shape[0]);
detectorItem()->setYSize(data_shape[1]); detectorItem()->setYSize(data_shape[1]);
...@@ -278,10 +268,14 @@ std::vector<int> OffSpecInstrumentItem::shape() const ...@@ -278,10 +268,14 @@ std::vector<int> OffSpecInstrumentItem::shape() const
return {x_size, detector_item->ySize()}; return {x_size, detector_item->ySize()};
} }
void OffSpecInstrumentItem::setShape(const std::vector<int>& data_shape) void OffSpecInstrumentItem::updateToRealData(const RealDataItem* item)
{ {
if (!item)
return;
const auto data_shape = item->shape();
if (shape().size() != data_shape.size()) if (shape().size() != data_shape.size())
throw GUIHelpers::Error("Error in OffSpecInstrumentItem::setShape: The type of " throw GUIHelpers::Error("Error in OffSpecInstrumentItem::updateToRealData: The type of "
"instrument is incompatible with passed data shape."); "instrument is incompatible with passed data shape.");
getItem(OffSpecInstrumentItem::P_ALPHA_AXIS) getItem(OffSpecInstrumentItem::P_ALPHA_AXIS)
->setItemValue(BasicAxisItem::P_NBINS, data_shape[0]); ->setItemValue(BasicAxisItem::P_NBINS, data_shape[0]);
......
...@@ -43,7 +43,7 @@ public: ...@@ -43,7 +43,7 @@ public:
virtual std::vector<int> shape() const = 0; virtual std::vector<int> shape() const = 0;
virtual void clearMasks() {} virtual void clearMasks() {}
virtual void importMasks(const MaskContainerItem*) {} virtual void importMasks(const MaskContainerItem*) {}
virtual void updateToRealData(const RealDataItem* item); virtual void updateToRealData(const RealDataItem* item) = 0;
virtual bool alignedWith(const RealDataItem* item) const; virtual bool alignedWith(const RealDataItem* item) const;
protected: protected:
...@@ -51,8 +51,6 @@ protected: ...@@ -51,8 +51,6 @@ protected:
void initBeamGroup(const QString& beam_model); void initBeamGroup(const QString& beam_model);
void initBackgroundGroup(); void initBackgroundGroup();
virtual void setShape(const std::vector<int>& shape) = 0;
}; };
class BA_CORE_API_ SpecularInstrumentItem : public InstrumentItem class BA_CORE_API_ SpecularInstrumentItem : public InstrumentItem
...@@ -69,9 +67,6 @@ public: ...@@ -69,9 +67,6 @@ public:
bool alignedWith(const RealDataItem* item) const override; bool alignedWith(const RealDataItem* item) const override;
std::unique_ptr<IUnitConverter> createUnitConverter() const; std::unique_ptr<IUnitConverter> createUnitConverter() const;
protected:
void setShape(const std::vector<int>& shape) override;
}; };
class BA_CORE_API_ Instrument2DItem : public InstrumentItem class BA_CORE_API_ Instrument2DItem : public InstrumentItem
...@@ -100,9 +95,7 @@ class BA_CORE_API_ GISASInstrumentItem : public Instrument2DItem ...@@ -100,9 +95,7 @@ class BA_CORE_API_ GISASInstrumentItem : public Instrument2DItem
public: public:
GISASInstrumentItem(); GISASInstrumentItem();
std::vector<int> shape() const override; std::vector<int> shape() const override;
void updateToRealData(const RealDataItem* item) override;
protected:
void setShape(const std::vector<int>& data_shape) override;
}; };
class BA_CORE_API_ OffSpecInstrumentItem : public Instrument2DItem class BA_CORE_API_ OffSpecInstrumentItem : public Instrument2DItem
...@@ -112,9 +105,7 @@ public: ...@@ -112,9 +105,7 @@ public:
OffSpecInstrumentItem(); OffSpecInstrumentItem();
std::vector<int> shape() const override; std::vector<int> shape() const override;
void updateToRealData(const RealDataItem* item) override;
protected:
void setShape(const std::vector<int>& data_shape) override;
}; };
#endif // INSTRUMENTITEMS_H #endif // INSTRUMENTITEMS_H
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