viewer: draw loaded ROIs on the diffraction image
When a file with ROI definitions is opened (read into experiment.ROI() by the HDF5 reader), the diffraction image now overlays the configured box and circle ROIs as distinct colour-coded outlines, alongside the existing resolution rings and spots. This is the first step of the ROI-map-based multi-ROI canvas: showing the ROIs loaded from a file. Azimuthal ROIs (wedge rendering) and per-ROI statistics from the bitmap follow in subsequent steps. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -313,6 +313,7 @@ void JFJochDiffractionImage::DrawTopPixels() {
|
||||
|
||||
void JFJochDiffractionImage::addCustomOverlay() {
|
||||
DrawResolutionRings();
|
||||
DrawROIs();
|
||||
DrawTopPixels();
|
||||
|
||||
DrawBeamCenter();
|
||||
@@ -326,6 +327,38 @@ void JFJochDiffractionImage::addCustomOverlay() {
|
||||
DrawResolutionText();
|
||||
}
|
||||
|
||||
void JFJochDiffractionImage::DrawROIs() {
|
||||
if (!image)
|
||||
return;
|
||||
|
||||
const auto &rois = image->Dataset().experiment.ROI().GetROIDefinition();
|
||||
|
||||
// Distinct colours per ROI; loaded ROIs use solid lines (the interactively
|
||||
// drawn scratch ROI keeps its dashed feature_color).
|
||||
static const QColor palette[] = {Qt::cyan, Qt::yellow, QColor(0xff, 0x57, 0x22),
|
||||
Qt::green, Qt::magenta, QColor(0x21, 0x96, 0xf3)};
|
||||
const int palette_size = sizeof(palette) / sizeof(palette[0]);
|
||||
int color_index = 0;
|
||||
auto roi_pen = [&]() {
|
||||
QPen pen(palette[color_index % palette_size], 2);
|
||||
pen.setCosmetic(true);
|
||||
color_index++;
|
||||
return pen;
|
||||
};
|
||||
|
||||
for (const auto &b : rois.boxes) {
|
||||
auto *rect = scene()->addRect(b.GetXMin(), b.GetYMin(), b.GetWidth(), b.GetHeight(), roi_pen());
|
||||
addOverlayItem(rect);
|
||||
}
|
||||
|
||||
for (const auto &c : rois.circles) {
|
||||
const float r = c.GetRadius_pxl();
|
||||
auto *ell = scene()->addEllipse(c.GetX() - r, c.GetY() - r, 2 * r, 2 * r, roi_pen());
|
||||
addOverlayItem(ell);
|
||||
}
|
||||
// Azimuthal ROIs are drawn as wedges in a later step.
|
||||
}
|
||||
|
||||
|
||||
void JFJochDiffractionImage::UpdateForeground() {
|
||||
if (!image || !auto_fg)
|
||||
|
||||
@@ -25,6 +25,7 @@ private:
|
||||
void addCustomOverlay() override;
|
||||
void LoadImageInternal();
|
||||
void DrawResolutionRings();
|
||||
void DrawROIs();
|
||||
void DrawSpots();
|
||||
void DrawPredictions();
|
||||
void DrawBeamCenter();
|
||||
|
||||
Reference in New Issue
Block a user