9e57219b31
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>
40 lines
1.2 KiB
C++
40 lines
1.2 KiB
C++
// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include "ROICircle.h"
|
|
#include "JFJochException.h"
|
|
|
|
ROICircle::ROICircle(const std::string &name, float in_x, float in_y, float in_r_pxl)
|
|
: ROIElement(name), center_x(in_x), center_y(in_y), r_pxl(in_r_pxl), r_pxl_2(in_r_pxl * in_r_pxl) {
|
|
if (r_pxl <= 0.0)
|
|
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
|
"ROICircle: radius must be positive number");
|
|
}
|
|
|
|
float ROICircle::GetX() const {
|
|
return center_x;
|
|
}
|
|
|
|
float ROICircle::GetY() const {
|
|
return center_y;
|
|
}
|
|
|
|
float ROICircle::GetRadius_pxl() const {
|
|
return r_pxl;
|
|
}
|
|
|
|
ROIConfig ROICircle::ExportMetadata() const {
|
|
return ROIConfig{
|
|
.type = ROIConfig::ROIType::Circle,
|
|
.name = name,
|
|
.circle = ROIConfigCircle{.r = r_pxl, .x = center_x, .y = center_y}
|
|
};
|
|
}
|
|
|
|
bool ROICircle::CheckROI(int64_t x, int64_t y, float resolution, float phi_deg) const {
|
|
float x_fl = static_cast<float>(x) - center_x;
|
|
float y_fl = static_cast<float>(y) - center_y;
|
|
float dist_from_center_sq = x_fl * x_fl + y_fl * y_fl;
|
|
return (dist_from_center_sq <= r_pxl_2);
|
|
}
|