Files
Jungfraujoch/common/ROIBox.cpp
T
leonarski_f 9e57219b31 common: add azimuthal-angle (phi) sectors to ROIAzimuthal
ROIAzimuthal can now be restricted to an azimuthal-angle sector in
addition to its Q/d range, enabling STXM-style directional ROIs. phi
bounds are optional (both-or-neither); absent means a full 360 ring, so
existing Q-only azimuthal ROIs are unchanged.

- ROIElement::CheckROI gains a phi_deg argument; box/circle ignore it.
- MarkROI gains an optional phi_map; ROIMap builds it from Phi_rad
  alongside the resolution map only when azimuthal ROIs are present.
- phi bounds are normalized to [0,360) and wrap-around sectors are
  supported (phi_min > phi_max).
- ROIConfigAzim carries phi_min/phi_max (kept trivially copyable for the
  union; phi_min == phi_max means full ring).

No phi crosses the wire yet (CBOR/API wiring follows separately).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 09:21:39 +02:00

79 lines
1.6 KiB
C++

// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#include "ROIBox.h"
ROIBox::ROIBox(const std::string &in_name, int64_t in_x_min, int64_t in_x_max, int64_t in_y_min, int64_t in_y_max)
: ROIElement(in_name) {
if (in_x_max < in_x_min) {
x_min = in_x_max;
x_max = in_x_min;
} else {
x_min = in_x_min;
x_max = in_x_max;
}
if (in_y_max < in_y_min) {
y_min = in_y_max;
y_max = in_y_min;
} else {
y_min = in_y_min;
y_max = in_y_max;
}
if (x_max < 0) {
x_min = 0;
x_max = -1;
} else if (x_min < 0) {
x_min = 0;
}
if (y_max < 0) {
y_min = 0;
y_max = -1;
} else if (y_min < 0) {
y_min = 0;
}
}
int64_t ROIBox::GetXMin() const {
return x_min;
}
int64_t ROIBox::GetXMax() const {
return x_max;
}
int64_t ROIBox::GetYMin() const {
return y_min;
}
int64_t ROIBox::GetYMax() const {
return y_max;
}
int64_t ROIBox::GetWidth() const {
return x_max - x_min + 1;
}
int64_t ROIBox::GetHeight() const {
return y_max - y_min + 1;
}
int64_t ROIBox::GetArea() const {
return GetWidth() * GetHeight();
}
bool ROIBox::CheckROI(int64_t x, int64_t y, float resolution, float phi_deg) const {
return ((x >= x_min) && (x <= x_max) && (y >= y_min) && (y <= y_max));
}
ROIConfig ROIBox::ExportMetadata() const {
return ROIConfig{
.type = ROIConfig::ROIType::Box,
.name = name,
.box = ROIConfigBox{.xmin = x_min, .xmax = x_max, .ymin = y_min, .ymax = y_max}
};
}