Skip to content
Snippets Groups Projects
Commit 3d0d9461 authored by Mikhail Svechnikov's avatar Mikhail Svechnikov
Browse files

RectangularDetectorItem: storing alignment in ComboProperty

parent 4653ed60
No related branches found
No related tags found
1 merge request!1172GUI: rm SelectionDescriptor for detector alignment
...@@ -17,8 +17,6 @@ ...@@ -17,8 +17,6 @@
#include "GUI/Util/ComboProperty.h" #include "GUI/Util/ComboProperty.h"
class MinimizerItem;
//! The MinimizerItemCatalog class is a static class to provide MinimizerItem //! The MinimizerItemCatalog class is a static class to provide MinimizerItem
//! with the list of available minimizers/algorithms. //! with the list of available minimizers/algorithms.
......
...@@ -114,14 +114,15 @@ RectangularDetectorItem::RectangularDetectorItem() ...@@ -114,14 +114,15 @@ RectangularDetectorItem::RectangularDetectorItem()
m_distance.init("Distance", "Distance from the sample origin to the detector plane", m_distance.init("Distance", "Distance from the sample origin to the detector plane",
default_detector_distance, "mm", "distance"); default_detector_distance, "mm", "distance");
m_detectorAlignment = RectangularDetector::PERPENDICULAR_TO_DIRECT_BEAM; m_detectorAlignment.fromList(alignment_names_map.keys(),
alignment_names_map.key(RectangularDetector::PERPENDICULAR_TO_DIRECT_BEAM));
updateTooltips(); updateTooltips();
} }
void RectangularDetectorItem::serialize(Streamer& s) void RectangularDetectorItem::serialize(Streamer& s)
{ {
int alignment = m_detectorAlignment; // int alignment = m_detectorAlignment_TEMP;
s.assertVersion(0); s.assertVersion(0);
// base class members // base class members
...@@ -134,7 +135,7 @@ void RectangularDetectorItem::serialize(Streamer& s) ...@@ -134,7 +135,7 @@ void RectangularDetectorItem::serialize(Streamer& s)
Serialize::rwProperty(s, Tag::Width, m_width); Serialize::rwProperty(s, Tag::Width, m_width);
Serialize::rwProperty(s, Tag::Height, m_height); Serialize::rwProperty(s, Tag::Height, m_height);
Serialize::rwValue(s, Tag::Alignment, alignment); // Serialize::rwValue(s, Tag::Alignment, alignment);
m_normalVector.rwProperty(s, Tag::NormalVector); m_normalVector.rwProperty(s, Tag::NormalVector);
m_directionVector.rwProperty(s, Tag::DirectionVector); m_directionVector.rwProperty(s, Tag::DirectionVector);
...@@ -143,21 +144,28 @@ void RectangularDetectorItem::serialize(Streamer& s) ...@@ -143,21 +144,28 @@ void RectangularDetectorItem::serialize(Streamer& s)
Serialize::rwProperty(s, Tag::Distance, m_distance); Serialize::rwProperty(s, Tag::Distance, m_distance);
if (s.xmlReader()) { if (s.xmlReader()) {
setDetectorAlignment(static_cast<RectangularDetector::EDetectorArrangement>(alignment)); // setDetectorAlignment(static_cast<RectangularDetector::EDetectorArrangement>(alignment));
m_resolutionFunction->setUnit("mm"); m_resolutionFunction->setUnit("mm");
} }
} }
void RectangularDetectorItem::setDetectorAlignment(const QString &alignment)
{
ASSERT(alignment_names_map.keys().contains(alignment));
setDetectorAlignment(alignment_names_map.value(alignment));
}
void RectangularDetectorItem::setDetectorAlignment( void RectangularDetectorItem::setDetectorAlignment(
RectangularDetector::EDetectorArrangement alignment) RectangularDetector::EDetectorArrangement alignment)
{ {
m_detectorAlignment = alignment; m_detectorAlignment.setCurrentValue(alignment_names_map.key(alignment));
updateTooltips(); updateTooltips();
} }
RectangularDetector::EDetectorArrangement RectangularDetectorItem::detectorAlignment() const RectangularDetector::EDetectorArrangement RectangularDetectorItem::detectorAlignment() const
{ {
return m_detectorAlignment; ASSERT(alignment_names_map.keys().contains(m_detectorAlignment.currentValue()));
return alignment_names_map.value(m_detectorAlignment.currentValue());
} }
int RectangularDetectorItem::xSize() const int RectangularDetectorItem::xSize() const
...@@ -193,7 +201,7 @@ RectangularDetectorItem::detectorAlignmentSelection() const ...@@ -193,7 +201,7 @@ RectangularDetectorItem::detectorAlignmentSelection() const
const_cast<RectangularDetectorItem*>(this)->setDetectorAlignment(alignments()[newIndex]); const_cast<RectangularDetectorItem*>(this)->setDetectorAlignment(alignments()[newIndex]);
}; };
d.currentIndexGetter = [&]() { return alignments().indexOf(m_detectorAlignment); }; d.currentIndexGetter = [&]() { return alignments().indexOf(detectorAlignment()); };
return d; return d;
} }
...@@ -202,7 +210,7 @@ std::unique_ptr<IDetector> RectangularDetectorItem::createDomainDetector() const ...@@ -202,7 +210,7 @@ std::unique_ptr<IDetector> RectangularDetectorItem::createDomainDetector() const
auto result = std::make_unique<RectangularDetector>(xSize(), width(), ySize(), height()); auto result = std::make_unique<RectangularDetector>(xSize(), width(), ySize(), height());
// distance and alignment // distance and alignment
switch (m_detectorAlignment) { switch (detectorAlignment()) {
case RectangularDetector::GENERIC: case RectangularDetector::GENERIC:
result->setDetectorPosition(m_normalVector, m_u0, m_v0, m_directionVector); result->setDetectorPosition(m_normalVector, m_u0, m_v0, m_directionVector);
break; break;
...@@ -228,7 +236,7 @@ std::unique_ptr<IDetector> RectangularDetectorItem::createDomainDetector() const ...@@ -228,7 +236,7 @@ std::unique_ptr<IDetector> RectangularDetectorItem::createDomainDetector() const
void RectangularDetectorItem::updateTooltips() void RectangularDetectorItem::updateTooltips()
{ {
switch (m_detectorAlignment) { switch (detectorAlignment()) {
case RectangularDetector::GENERIC: case RectangularDetector::GENERIC:
m_u0.setTooltip( m_u0.setTooltip(
"u-coordinate of point of intersection of normal vector and detector plane"); "u-coordinate of point of intersection of normal vector and detector plane");
......
...@@ -39,7 +39,9 @@ public: ...@@ -39,7 +39,9 @@ public:
const DoubleProperty& height() const { return m_height; } const DoubleProperty& height() const { return m_height; }
void setHeight(double v) { m_height.setValue(v); } void setHeight(double v) { m_height.setValue(v); }
void setDetectorAlignment(const QString& alignment);
void setDetectorAlignment(RectangularDetector::EDetectorArrangement alignment); void setDetectorAlignment(RectangularDetector::EDetectorArrangement alignment);
RectangularDetector::EDetectorArrangement detectorAlignment() const; RectangularDetector::EDetectorArrangement detectorAlignment() const;
SelectionDescriptor<RectangularDetector::EDetectorArrangement> SelectionDescriptor<RectangularDetector::EDetectorArrangement>
detectorAlignmentSelection() const; detectorAlignmentSelection() const;
...@@ -69,11 +71,10 @@ private: ...@@ -69,11 +71,10 @@ private:
void updateTooltips(); void updateTooltips();
private: private:
RectangularDetector::EDetectorArrangement m_detectorAlignment; ComboProperty m_detectorAlignment;
int m_xSize; int m_xSize;
int m_ySize; int m_ySize;
protected:
VectorProperty m_normalVector; VectorProperty m_normalVector;
VectorProperty m_directionVector; VectorProperty m_directionVector;
......
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