diff --git a/GUI/coregui/Models/DepthProbeInstrumentItem.cpp b/GUI/coregui/Models/DepthProbeInstrumentItem.cpp index bac8641d046b5b8785825ae6e2107278492f203d..8f6601d8fb6989ef43d1f95c686cc0e0dcb586ad 100644 --- a/GUI/coregui/Models/DepthProbeInstrumentItem.cpp +++ b/GUI/coregui/Models/DepthProbeInstrumentItem.cpp @@ -62,9 +62,9 @@ std::vector<int> DepthProbeInstrumentItem::shape() const 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 diff --git a/GUI/coregui/Models/DepthProbeInstrumentItem.h b/GUI/coregui/Models/DepthProbeInstrumentItem.h index d3a0e9774cd8dd62de309d96f0ea34355760e1c1..13a63d9109ad12a11c88053e2443d94cc0731b93 100644 --- a/GUI/coregui/Models/DepthProbeInstrumentItem.h +++ b/GUI/coregui/Models/DepthProbeInstrumentItem.h @@ -33,7 +33,7 @@ public: std::unique_ptr<Instrument> createInstrument() 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 // after Simulation gets createUnitConverter method diff --git a/GUI/coregui/Models/InstrumentItems.cpp b/GUI/coregui/Models/InstrumentItems.cpp index e9717a2ef915a1c329db983cba5017ba0dc6781f..75e20b1b488623c5aef1efd92fb2f1bda84b13b7 100644 --- a/GUI/coregui/Models/InstrumentItems.cpp +++ b/GUI/coregui/Models/InstrumentItems.cpp @@ -71,11 +71,6 @@ GroupItem* InstrumentItem::backgroundGroup() return &item<GroupItem>(P_BACKGROUND); } -void InstrumentItem::updateToRealData(const RealDataItem *item) -{ - setShape(item->shape()); -} - bool InstrumentItem::alignedWith(const RealDataItem* item) const { return shape() == item->shape(); @@ -136,15 +131,6 @@ std::vector<int> SpecularInstrumentItem::shape() const 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) { if (shape().size() != item->shape().size()) @@ -254,10 +240,14 @@ std::vector<int> GISASInstrumentItem::shape() const 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()) - 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."); detectorItem()->setXSize(data_shape[0]); detectorItem()->setYSize(data_shape[1]); @@ -278,10 +268,14 @@ std::vector<int> OffSpecInstrumentItem::shape() const 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()) - 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."); getItem(OffSpecInstrumentItem::P_ALPHA_AXIS) ->setItemValue(BasicAxisItem::P_NBINS, data_shape[0]); diff --git a/GUI/coregui/Models/InstrumentItems.h b/GUI/coregui/Models/InstrumentItems.h index dbe3430407a9390595aed71e033f7e5f6a46c9ed..39e04562ea276598f003abbbe490cf58846befaa 100644 --- a/GUI/coregui/Models/InstrumentItems.h +++ b/GUI/coregui/Models/InstrumentItems.h @@ -43,7 +43,7 @@ public: virtual std::vector<int> shape() const = 0; virtual void clearMasks() {} 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; protected: @@ -51,8 +51,6 @@ protected: void initBeamGroup(const QString& beam_model); void initBackgroundGroup(); - - virtual void setShape(const std::vector<int>& shape) = 0; }; class BA_CORE_API_ SpecularInstrumentItem : public InstrumentItem @@ -69,9 +67,6 @@ public: bool alignedWith(const RealDataItem* item) const override; std::unique_ptr<IUnitConverter> createUnitConverter() const; - -protected: - void setShape(const std::vector<int>& shape) override; }; class BA_CORE_API_ Instrument2DItem : public InstrumentItem @@ -100,9 +95,7 @@ class BA_CORE_API_ GISASInstrumentItem : public Instrument2DItem public: GISASInstrumentItem(); std::vector<int> shape() const override; - -protected: - void setShape(const std::vector<int>& data_shape) override; + void updateToRealData(const RealDataItem* item) override; }; class BA_CORE_API_ OffSpecInstrumentItem : public Instrument2DItem @@ -112,9 +105,7 @@ public: OffSpecInstrumentItem(); std::vector<int> shape() const override; - -protected: - void setShape(const std::vector<int>& data_shape) override; + void updateToRealData(const RealDataItem* item) override; }; #endif // INSTRUMENTITEMS_H