Skip to content
Snippets Groups Projects
Commit 0c5b4e43 authored by t.knopff's avatar t.knopff
Browse files

Use string constant for rectangular detector item type name

parent 34a94b67
No related branches found
No related tags found
1 merge request!96Refactor model: detector items
Pipeline #38220 canceled
......@@ -21,6 +21,7 @@
#include "GUI/Models/MaterialDataItems.h"
#include "GUI/Models/PointwiseAxisItem.h"
#include "GUI/Models/RealLimitsItems.h"
#include "GUI/Models/RectangularDetectorItem.h"
#include "GUI/Models/SphericalDetectorItem.h"
GroupInfoCatalog::GroupInfoCatalog()
......@@ -73,7 +74,7 @@ GroupInfoCatalog::GroupInfoCatalog()
info = GroupInfo("Detector group");
info.add(SphericalDetectorItem::M_TYPE, "Spherical detector");
info.add("RectangularDetector", "Rectangular detector");
info.add(RectangularDetectorItem::M_TYPE, "Rectangular detector");
info.setDefaultType(SphericalDetectorItem::M_TYPE);
addInfo(info);
......
......@@ -132,7 +132,7 @@ ItemCatalog::ItemCatalog()
add("LayerZeroRoughness", create_new<LayerZeroRoughnessItem>);
addItem<SphericalDetectorItem>();
add("RectangularDetector", create_new<RectangularDetectorItem>);
addItem<RectangularDetectorItem>();
addItem<DistributionNoneItem>();
addItem<DistributionGateItem>();
......
......@@ -72,8 +72,10 @@ const QString RectangularDetectorItem::P_DBEAM_U0 = "u0 (dbeam)";
const QString RectangularDetectorItem::P_DBEAM_V0 = "v0 (dbeam)";
const QString RectangularDetectorItem::P_DISTANCE = "Distance";
const QString RectangularDetectorItem::M_TYPE = "RectangularDetector";
RectangularDetectorItem::RectangularDetectorItem()
: DetectorItem("RectangularDetector"), m_is_constructed(false)
: DetectorItem(M_TYPE), m_is_constructed(false)
{
// axes parameters
auto axisItem = addProperty<BasicAxisItem>(P_X_AXIS);
......
......@@ -35,6 +35,8 @@ private:
static const QString P_DISTANCE;
public:
static const QString M_TYPE;
RectangularDetectorItem();
void setDetectorAlignment(const QString& alignment);
......
......@@ -302,7 +302,7 @@ void TransformFromDomain::setDetectorGeometry(Instrument2DItem* instrument_item,
auto item = dynamic_cast<SphericalDetectorItem*>(instrument_item->detectorItem());
setSphericalDetector(item, *det);
} else if (auto det = dynamic_cast<const RectangularDetector*>(&detector)) {
instrument_item->setDetectorGroup("RectangularDetector");
instrument_item->setDetectorGroup(RectangularDetectorItem::M_TYPE);
auto item = dynamic_cast<RectangularDetectorItem*>(instrument_item->detectorItem());
setRectangularDetector(item, *det);
} else {
......
......@@ -14,6 +14,7 @@
#include "GUI/Views/InstrumentWidgets/DetectorPresenter.h"
#include "GUI/Models/Error.h"
#include "GUI/Models/RectangularDetectorItem.h"
#include "GUI/Models/SessionItem.h"
#include "GUI/Models/SphericalDetectorItem.h"
#include "GUI/Views/InstrumentWidgets/RectangularDetectorEditor.h"
......@@ -38,7 +39,7 @@ QString DetectorPresenter::itemPresentation() const
if (currentItem()->modelType() == SphericalDetectorItem::M_TYPE)
return SphericalDetectorPresentation;
else if (currentItem()->modelType() == "RectangularDetector")
else if (currentItem()->modelType() == RectangularDetectorItem::M_TYPE)
return RectangularDetectorPresentation;
else
throw Error("DetectorPresenter::itemPresentation() -> Error. Wrong item "
......
......@@ -37,7 +37,7 @@ TEST_F(TestLinkInstrument, test_canLinkToInstrument)
EXPECT_EQ(manager.linkedRealDataItems(instrument), QList<RealDataItem*>() << realData);
// changing detector type and checking that link remain
instrument->setDetectorGroup("RectangularDetector");
instrument->setDetectorGroup(RectangularDetectorItem::M_TYPE);
EXPECT_EQ(manager.linkedRealDataItems(instrument), QList<RealDataItem*>() << realData);
// changing detector binning and checking that link is destroyed
......
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