Skip to content
Snippets Groups Projects
Commit b30ab1a1 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

DetectorPlacement -> {X, T, R}

parent 94b172d8
No related branches found
No related tags found
1 merge request!1841rename some enums, and RectangularDetector -> FlatDetector
......@@ -57,19 +57,19 @@ void RectangularDetector::setDetectorNormal(const R3& k)
void RectangularDetector::setPerpendicularToSampleX(double distance, double u0, double v0)
{
m_detector_arrangement = PERPENDICULAR_TO_SAMPLE;
m_detector_arrangement = X;
setDistanceAndOffset(distance, u0, v0);
}
void RectangularDetector::setPerpendicularToDirectBeam(double distance, double u0, double v0)
{
m_detector_arrangement = PERPENDICULAR_TO_DIRECT_BEAM;
m_detector_arrangement = T;
setDistanceAndOffset(distance, u0, v0);
}
void RectangularDetector::setPerpendicularToReflectedBeam(double distance, double u0, double v0)
{
m_detector_arrangement = PERPENDICULAR_TO_REFLECTED_BEAM;
m_detector_arrangement = R;
setDistanceAndOffset(distance, u0, v0);
}
......@@ -192,13 +192,13 @@ void RectangularDetector::initNormalVector(const R3 central_k)
{
R3 central_k_unit = central_k.unit_or_throw();
if (m_detector_arrangement == PERPENDICULAR_TO_SAMPLE)
if (m_detector_arrangement == X)
m_normal_to_detector = R3(m_distance, 0.0, 0.0);
else if (m_detector_arrangement == PERPENDICULAR_TO_DIRECT_BEAM)
else if (m_detector_arrangement == T)
m_normal_to_detector = m_distance * central_k_unit;
else if (m_detector_arrangement == PERPENDICULAR_TO_REFLECTED_BEAM) {
else if (m_detector_arrangement == R) {
m_normal_to_detector = m_distance * central_k_unit;
m_normal_to_detector.setZ(-m_normal_to_detector.z());
}
......
......@@ -24,13 +24,7 @@ class RectangularPixel;
class RectangularDetector : public IDetector {
public:
enum DetectorPlacement {
GENERIC,
PERPENDICULAR_TO_SAMPLE,
PERPENDICULAR_TO_DIRECT_BEAM,
PERPENDICULAR_TO_REFLECTED_BEAM
};
enum DetectorPlacement { GENERIC, X, T, R };
//! Rectangular detector constructor
//! @param nxbins Number of bins (pixels) in x-direction
......
......@@ -39,9 +39,9 @@ const double default_detector_distance = 1000.0;
//! Holds the alignments as expected on the UI (map is sorted by keys)
const QMap<RectangularDetector::DetectorPlacement, QString> alignment_names_map = {
{RectangularDetector::PERPENDICULAR_TO_SAMPLE, "Perpendicular to sample x-axis"},
{RectangularDetector::PERPENDICULAR_TO_DIRECT_BEAM, "Perpendicular to direct beam"},
{RectangularDetector::PERPENDICULAR_TO_REFLECTED_BEAM, "Perpendicular to reflected beam"}};
{RectangularDetector::X, "Perpendicular to sample x-axis"},
{RectangularDetector::T, "Perpendicular to direct beam"},
{RectangularDetector::R, "Perpendicular to reflected beam"}};
void initResolutionFunction(ResolutionFunctionItem* newFunc, const ResolutionFunctionItem*)
{
......@@ -79,8 +79,7 @@ RectangularDetectorItem::RectangularDetectorItem()
default_detector_distance, "mm", "distance");
m_detectorAlignment = ComboProperty::fromList(
alignment_names_map.values(),
alignment_names_map.value(RectangularDetector::PERPENDICULAR_TO_DIRECT_BEAM));
alignment_names_map.values(), alignment_names_map.value(RectangularDetector::T));
updateTooltips();
}
......@@ -258,13 +257,13 @@ std::unique_ptr<IDetector> RectangularDetectorItem::createDomainDetector() const
// distance and alignment
switch (detectorAlignment()) {
case RectangularDetector::PERPENDICULAR_TO_SAMPLE:
case RectangularDetector::X:
result->setPerpendicularToSampleX(m_distance, m_u0, m_v0);
break;
case RectangularDetector::PERPENDICULAR_TO_DIRECT_BEAM:
case RectangularDetector::T:
result->setPerpendicularToDirectBeam(m_distance, m_u0, m_v0);
break;
case RectangularDetector::PERPENDICULAR_TO_REFLECTED_BEAM:
case RectangularDetector::R:
result->setPerpendicularToReflectedBeam(m_distance, m_u0, m_v0);
break;
default:
......@@ -277,15 +276,15 @@ std::unique_ptr<IDetector> RectangularDetectorItem::createDomainDetector() const
void RectangularDetectorItem::updateTooltips()
{
switch (detectorAlignment()) {
case RectangularDetector::PERPENDICULAR_TO_SAMPLE:
case RectangularDetector::X:
m_u0.setTooltip("u-coordinate of point where sample x-axis crosses the detector");
m_v0.setTooltip("v-coordinate of point where sample x-axis crosses the detector");
break;
case RectangularDetector::PERPENDICULAR_TO_REFLECTED_BEAM:
case RectangularDetector::R:
m_u0.setTooltip("u-coordinate of point where reflected beam hits the detector");
m_v0.setTooltip("v-coordinate of point where reflected beam hits the detector");
break;
case RectangularDetector::PERPENDICULAR_TO_DIRECT_BEAM: // fall-through!
case RectangularDetector::T: // fall-through!
m_u0.setTooltip("u-coordinate of point where direct beam hits the detector");
m_v0.setTooltip("v-coordinate of point where direct beam hits the detector");
break;
......
......@@ -263,17 +263,15 @@ void setRectangularDetector(RectangularDetectorItem* detectorItem,
detectorItem->setV0(detector.getV0());
}
else if (detector.getDetectorArrangment() == RectangularDetector::PERPENDICULAR_TO_SAMPLE) {
else if (detector.getDetectorArrangment() == RectangularDetector::X) {
detectorItem->setDistance(detector.getDistance());
detectorItem->setU0(detector.getU0());
detectorItem->setV0(detector.getV0());
} else if (detector.getDetectorArrangment()
== RectangularDetector::PERPENDICULAR_TO_DIRECT_BEAM) {
} else if (detector.getDetectorArrangment() == RectangularDetector::T) {
detectorItem->setDistance(detector.getDistance());
detectorItem->setU0(detector.getU0());
detectorItem->setV0(detector.getV0());
} else if (detector.getDetectorArrangment()
== RectangularDetector::PERPENDICULAR_TO_REFLECTED_BEAM) {
} else if (detector.getDetectorArrangment() == RectangularDetector::R) {
detectorItem->setDistance(detector.getDistance());
detectorItem->setU0(detector.getU0());
detectorItem->setV0(detector.getV0());
......
......@@ -22,11 +22,11 @@ namespace {
QString alignmentDescription(RectangularDetector::DetectorPlacement a)
{
switch (a) {
case RectangularDetector::PERPENDICULAR_TO_SAMPLE:
case RectangularDetector::X:
return "Intersection of sample x-axis and detector";
case RectangularDetector::PERPENDICULAR_TO_DIRECT_BEAM:
case RectangularDetector::T:
return "Intersection of direct beam and detector";
case RectangularDetector::PERPENDICULAR_TO_REFLECTED_BEAM:
case RectangularDetector::R:
return "Intersection of reflected beam and detector";
default:
ASSERT(false);
......
......@@ -151,19 +151,17 @@ std::string defineDetector(const IDetector& detector)
result << indent() << "detector = ba.RectangularDetector(" << det->xSize() << ", "
<< Py::Fmt::printDouble(det->width()) << ", " << det->ySize() << ", "
<< Py::Fmt::printDouble(det->height()) << ")\n";
if (det->getDetectorArrangment() == RectangularDetector::PERPENDICULAR_TO_SAMPLE) {
if (det->getDetectorArrangment() == RectangularDetector::X) {
result << indent() << "detector.setPerpendicularToSampleX("
<< Py::Fmt::printDouble(det->getDistance()) << ", "
<< Py::Fmt::printDouble(det->getU0()) << ", "
<< Py::Fmt::printDouble(det->getV0()) << ")\n";
} else if (det->getDetectorArrangment()
== RectangularDetector::PERPENDICULAR_TO_DIRECT_BEAM) {
} else if (det->getDetectorArrangment() == RectangularDetector::T) {
result << indent() << "detector.setPerpendicularToDirectBeam("
<< Py::Fmt::printDouble(det->getDistance()) << ", "
<< Py::Fmt::printDouble(det->getU0()) << ", "
<< Py::Fmt::printDouble(det->getV0()) << ")\n";
} else if (det->getDetectorArrangment()
== RectangularDetector::PERPENDICULAR_TO_REFLECTED_BEAM) {
} else if (det->getDetectorArrangment() == RectangularDetector::R) {
result << indent() << "detector.setPerpendicularToReflectedBeam("
<< Py::Fmt::printDouble(det->getDistance()) << ", "
<< Py::Fmt::printDouble(det->getU0()) << ", "
......
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