diff --git a/viewer/image_viewer/JFJochDiffractionImage.cpp b/viewer/image_viewer/JFJochDiffractionImage.cpp index 9b744348..435cfceb 100644 --- a/viewer/image_viewer/JFJochDiffractionImage.cpp +++ b/viewer/image_viewer/JFJochDiffractionImage.cpp @@ -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) diff --git a/viewer/image_viewer/JFJochDiffractionImage.h b/viewer/image_viewer/JFJochDiffractionImage.h index 80e7871e..49ba0172 100644 --- a/viewer/image_viewer/JFJochDiffractionImage.h +++ b/viewer/image_viewer/JFJochDiffractionImage.h @@ -25,6 +25,7 @@ private: void addCustomOverlay() override; void LoadImageInternal(); void DrawResolutionRings(); + void DrawROIs(); void DrawSpots(); void DrawPredictions(); void DrawBeamCenter();