16 #include "Device/Detector/RectangularDetector.h"
27 const double default_detector_width = 20.0;
28 const double default_detector_height = 20.0;
29 const double default_detector_distance = 1000.0;
31 QString alignmentTitle(RectangularDetector::EDetectorArrangement a)
34 case RectangularDetector::GENERIC:
36 case RectangularDetector::PERPENDICULAR_TO_SAMPLE:
37 return "Perpendicular to sample x-axis";
38 case RectangularDetector::PERPENDICULAR_TO_DIRECT_BEAM:
39 return "Perpendicular to direct beam";
40 case RectangularDetector::PERPENDICULAR_TO_REFLECTED_BEAM:
41 return "Perpendicular to reflected beam";
42 case RectangularDetector::PERPENDICULAR_TO_REFLECTED_BEAM_DPOS:
43 return "Perpendicular to reflected beam (intersection unknown)";
50 QList<RectangularDetector::EDetectorArrangement> alignments()
52 return {RectangularDetector::GENERIC, RectangularDetector::PERPENDICULAR_TO_SAMPLE,
53 RectangularDetector::PERPENDICULAR_TO_DIRECT_BEAM,
54 RectangularDetector::PERPENDICULAR_TO_REFLECTED_BEAM,
55 RectangularDetector::PERPENDICULAR_TO_REFLECTED_BEAM_DPOS};
68 "Resolution function",
"Detector resolution function",
"resolutionFunction",
69 initResolutionFunction);
73 m_width.init(
"Width (x-axis)",
"Width of the detector", default_detector_width,
"mm", 3,
74 RealLimits::positive(),
"width");
75 m_height.init(
"Height (y-axis)",
"Height of the detector", default_detector_height,
"mm", 3,
76 RealLimits::positive(),
"height");
80 "Normal of the detector plane with length equal to the sample detector distance",
82 m_normalVector.r3().setX(default_detector_distance);
83 m_directionVector.init(
"Direction vector",
84 "Detector axis direction vector w.r.t. the sample coordinate system",
86 m_directionVector.r3().setY(-1.0);
88 m_u0.init(
"u0",
"", default_detector_width / 2.,
"mm", 3, RealLimits::limitless(),
"u0");
89 m_v0.init(
"v0",
"", 0.0,
"mm", 3, RealLimits::limitless(),
"v0");
90 m_distance.init(
"Distance",
"Distance from the sample origin to the detector plane",
91 default_detector_distance,
"mm",
"distance");
126 RectangularDetector::EDetectorArrangement alignment)
149 m_xSize =
static_cast<int>(nx);
154 m_ySize =
static_cast<int>(ny);
162 d.
label =
"Alignment";
163 for (
auto a : alignments())
164 d.
options << alignmentTitle(a);
174 QVector<std::variant<VectorDescriptor, DoubleDescriptor>>
178 return {normalVector(), directionVector(), u0(), v0()};
180 return {u0(), v0(), distance()};
185 auto result = std::make_unique<RectangularDetector>(
xSize(), width(),
ySize(), height());
189 case RectangularDetector::GENERIC:
190 result->setDetectorPosition(m_normalVector, m_u0, m_v0, m_directionVector);
192 case RectangularDetector::PERPENDICULAR_TO_SAMPLE:
193 result->setPerpendicularToSampleX(m_distance, m_u0, m_v0);
195 case RectangularDetector::PERPENDICULAR_TO_DIRECT_BEAM:
196 result->setPerpendicularToDirectBeam(m_distance, m_u0, m_v0);
198 case RectangularDetector::PERPENDICULAR_TO_REFLECTED_BEAM:
199 result->setPerpendicularToReflectedBeam(m_distance, m_u0, m_v0);
201 case RectangularDetector::PERPENDICULAR_TO_REFLECTED_BEAM_DPOS:
202 result->setPerpendicularToReflectedBeam(m_distance);
203 result->setDirectBeamPosition(m_u0, m_v0);
209 return std::unique_ptr<IDetector>(result.release());
215 case RectangularDetector::GENERIC:
217 "u-coordinate of point of intersection of normal vector and detector plane");
219 "v-coordinate of point of intersection of normal vector and detector plane");
221 case RectangularDetector::PERPENDICULAR_TO_SAMPLE:
222 m_u0.setTooltip(
"u-coordinate of point where sample x-axis crosses the detector");
223 m_v0.setTooltip(
"v-coordinate of point where sample x-axis crosses the detector");
225 case RectangularDetector::PERPENDICULAR_TO_REFLECTED_BEAM:
226 m_u0.setTooltip(
"u-coordinate of point where reflected beam hits the detector");
227 m_v0.setTooltip(
"v-coordinate of point where reflected beam hits the detector");
229 case RectangularDetector::PERPENDICULAR_TO_DIRECT_BEAM:
230 case RectangularDetector::PERPENDICULAR_TO_REFLECTED_BEAM_DPOS:
231 m_u0.setTooltip(
"u-coordinate of point where direct beam hits the detector");
232 m_v0.setTooltip(
"v-coordinate of point where direct beam hits the detector");
Defines various axis items.
Defines class ComboProperty.
Defines class RectangularDetectorItem.
Defines class ResolutionFunctionItemCatalog.
Defines family of ResolutionFunctionItem.
MaskItems m_maskItems
for creation of domain detector; only filled and relevant in jobs
SelectionProperty< ResolutionFunctionItem * > m_resolutionFunction
int ySize() const override
Returns the size of y-axis of the detector.
void setXSize(size_t nx) override
sets the size of x-axis of the detector
SelectionDescriptor< RectangularDetector::EDetectorArrangement > detectorAlignmentSelection() const
void serialize(Streamer &s) override
std::unique_ptr< IDetector > createDomainDetector() const override
RectangularDetector::EDetectorArrangement m_detectorAlignment
QVector< std::variant< VectorDescriptor, DoubleDescriptor > > alignmentPropertiesForUI() const
The properties of the currently active alignment. Sorted as expected on the UI.
void setYSize(size_t ny) override
sets the size of y-axis of the detector
void setDetectorAlignment(RectangularDetector::EDetectorArrangement alignment)
RectangularDetectorItem()
int xSize() const override
Returns the size of x-axis of the detector.
RectangularDetector::EDetectorArrangement detectorAlignment() const
virtual void setUnit(const std::variant< QString, Unit > &)
Set the unit of the distributed value.
Describes a selection (various possibilities and the current one).
function< int()> currentIndexGetter
Function to get currently selected option.
QString label
A label text (short, no trailing colon)
function< void(int)> currentIndexSetter
Function to set currently selected option.
QStringList options
List of options, usually presented as combo entries.
void initWithInitializer(const QString &label, const QString &tooltip, const QString &persistentTag, std::function< void(T newItem, const T oldItem)> initializer)
Initialize by means of a catalog class and an initializer function.
Supports serialization to or deserialization from QXmlStream.
QXmlStreamReader * xmlReader()
Returns stream reader or nullptr.
void assertVersion(unsigned expectedVersion) const
As reader, throws DeserializationException unless the expected version is read. As writer,...
void rwProperty(Streamer &s, DoubleProperty &d)
void rwValue(Streamer &s, const QString &tag, bool &val)
void rwClass(Streamer &s, const QString &tag, T &t)
Serializes an item from a class that provides the function void serialize(Streamer&).