diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 4b02e4bc1..bd4afdda0 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -7,6 +7,7 @@ * rugnux needs about a third less peak memory to scale, merge and post-refine rotation data with tens of millions of partial observations, with identical results. * `rugnux --model`: the placed coordinate file carries the space group its own coordinates obey, and says so when that is not the group the reflection files beside it carry. * `jfjoch_viewer`: fixes in the dataset plots (the stacked plots line up their y axes, the horizontal crosshair follows the cursor, a run in progress labels the angles of its whole sweep), in the inspector (a long dataset name wraps instead of being cut off, a live session shows its sample-head angles) and in the layout (the resize handle beside the file panel is centred). +* `jfjoch_viewer`: the black outline around spot markers is now off by default, switchable with an "Outline spots in black" checkbox under "Image features", and the highest-pixel markers are black-outlined white boxes around the pixel instead of crosses on top of it. ### 1.0.0-rc.169 diff --git a/viewer/JFJochViewerSidePanel.cpp b/viewer/JFJochViewerSidePanel.cpp index a0b3a12af..c92e0830f 100644 --- a/viewer/JFJochViewerSidePanel.cpp +++ b/viewer/JFJochViewerSidePanel.cpp @@ -51,6 +51,12 @@ JFJochViewerSidePanel::JFJochViewerSidePanel(QWidget *parent) : QWidget(parent) hideIceRingSpotsCheckBox->setToolTip("Leave the spots that fall on an ice ring out of the overlay."); connect(hideIceRingSpotsCheckBox, &QCheckBox::toggled, this, &JFJochViewerSidePanel::hideIceRingSpotsToggled); + auto outlineSpotsCheckBox = new QCheckBox("Outline spots in black", this); + outlineSpotsCheckBox->setCheckState(Qt::CheckState::Unchecked); + outlineSpotsCheckBox->setToolTip("Draw a black casing under each spot marker, so it stays visible " + "where the colour map is light."); + connect(outlineSpotsCheckBox, &QCheckBox::toggled, this, &JFJochViewerSidePanel::outlineSpots); + auto predictionsToggleCheckBox = new QCheckBox("Show predictions", this); predictionsToggleCheckBox->setCheckState(Qt::CheckState::Unchecked); @@ -114,9 +120,10 @@ JFJochViewerSidePanel::JFJochViewerSidePanel(QWidget *parent) : QWidget(parent) image_feature_grid->addWidget(beamStopCheckBox, 2, 1); image_feature_grid->addWidget(saturatedPixelsCheckBox, 3, 0); - image_feature_grid->addWidget(highestPixelsComboBox, 3, 1); - image_feature_grid->addWidget(colorSelectButton, 4, 0); - image_feature_grid->addWidget(spotColorSelectButton, 4, 1); + image_feature_grid->addWidget(outlineSpotsCheckBox, 3, 1); + image_feature_grid->addWidget(highestPixelsComboBox, 4, 0); + image_feature_grid->addWidget(colorSelectButton, 5, 0); + image_feature_grid->addWidget(spotColorSelectButton, 5, 1); // Legend: what each overlay colour means (matches JFJochDiffractionImage draw colours). legend_spot_swatch_ = MakeColorSwatch(this, Qt::green); @@ -140,8 +147,8 @@ JFJochViewerSidePanel::JFJochViewerSidePanel(QWidget *parent) : QWidget(parent) legend_row++; } legendLayout->setColumnStretch(1, 1); - image_feature_grid->addWidget(new QLabel(tr("Legend"), this), 5, 0, 1, 2); - image_feature_grid->addLayout(legendLayout, 6, 0, 1, 2); + image_feature_grid->addWidget(new QLabel(tr("Legend"), this), 6, 0, 1, 2); + image_feature_grid->addLayout(legendLayout, 7, 0, 1, 2); featuresSection->setContentLayout(image_feature_grid); layout->addWidget(featuresSection); diff --git a/viewer/JFJochViewerSidePanel.h b/viewer/JFJochViewerSidePanel.h index 833c6ff74..8f8d46437 100644 --- a/viewer/JFJochViewerSidePanel.h +++ b/viewer/JFJochViewerSidePanel.h @@ -37,6 +37,7 @@ signals: void highlightIceRings(bool input); void hideUnindexedSpots(bool input); void hideIceRingSpots(bool input); + void outlineSpots(bool input); void showROILabels(bool input); void showROIFill(bool input); void roisChanged(ROIDefinition rois); diff --git a/viewer/JFJochViewerWindow.cpp b/viewer/JFJochViewerWindow.cpp index 857765049..7974c439c 100644 --- a/viewer/JFJochViewerWindow.cpp +++ b/viewer/JFJochViewerWindow.cpp @@ -402,6 +402,8 @@ JFJochViewerWindow::JFJochViewerWindow(QWidget *parent, bool dbus, const QString viewer, &JFJochDiffractionImage::hideUnindexedSpots); connect(side_panel, &JFJochViewerSidePanel::hideIceRingSpots, viewer, &JFJochDiffractionImage::hideIceRingSpots); + connect(side_panel, &JFJochViewerSidePanel::outlineSpots, + viewer, &JFJochDiffractionImage::outlineSpots); connect(calibrationWindow, &JFJochCalibrationWindow::loadCalibration, reading_worker, &JFJochImageReadingWorker::LoadCalibration); diff --git a/viewer/image_viewer/JFJochDiffractionImage.cpp b/viewer/image_viewer/JFJochDiffractionImage.cpp index e1d995dd7..221e0d6d3 100644 --- a/viewer/image_viewer/JFJochDiffractionImage.cpp +++ b/viewer/image_viewer/JFJochDiffractionImage.cpp @@ -184,7 +184,8 @@ void JFJochDiffractionImage::DrawSpots() { pen.setCosmetic(true); const QRectF box(s.x - spot_size + 0.5, s.y - spot_size + 0.5, 2 * spot_size, 2 * spot_size); - addOverlayItem(scene()->addRect(box, casing_pen)); // added first, so it stays underneath + if (outline_spots) + addOverlayItem(scene()->addRect(box, casing_pen)); // added first, so it stays underneath addOverlayItem(scene()->addRect(box, pen)); } } @@ -454,14 +455,31 @@ void JFJochDiffractionImage::DrawBeamCenter() { } void JFJochDiffractionImage::DrawTopPixels() { + // A framed box like the spot markers - a white frame in a black casing - rather than a + // cross: the frame tells the user to look inside it, where a cross sits on top of the very + // pixel it points at. Slightly smaller than a spot frame (z above it), so both stay visible + // when a top pixel falls inside a spot. + const qreal half_size = 6.0 / std::sqrt(std::max(0.0001, scale_factor)); + + QPen casing_pen(Qt::black, 3 + MARKER_CASING_EXTRA_WIDTH); + casing_pen.setCosmetic(true); + QPen pen(Qt::white, 3); + pen.setCosmetic(true); + int i = 0; for (const auto& p : image->GetTopPixels()) { if (i >= show_highest_pixels) break; const int32_t idx = p.second; - DrawCross(idx % image->Dataset().experiment.GetXPixelsNum() + 0.5, - idx / image->Dataset().experiment.GetXPixelsNum() + 0.5, 15, 3); + const float x = idx % image->Dataset().experiment.GetXPixelsNum() + 0.5; + const float y = idx / image->Dataset().experiment.GetXPixelsNum() + 0.5; + const QRectF box(x - half_size, y - half_size, 2 * half_size, 2 * half_size); + for (const QPen &p_i : {casing_pen, pen}) { // casing first, so it stays underneath + auto *rect = scene()->addRect(box, p_i); + rect->setZValue(1); + addOverlayItem(rect); + } i++; } } @@ -1083,6 +1101,11 @@ void JFJochDiffractionImage::hideIceRingSpots(bool input) { updateOverlay(); } +void JFJochDiffractionImage::outlineSpots(bool input) { + outline_spots = input; + updateOverlay(); +} + void JFJochDiffractionImage::setResolutionRingMode(RingMode mode) { ring_mode = mode; updateOverlay(); diff --git a/viewer/image_viewer/JFJochDiffractionImage.h b/viewer/image_viewer/JFJochDiffractionImage.h index 3790ca5e7..778b1b579 100644 --- a/viewer/image_viewer/JFJochDiffractionImage.h +++ b/viewer/image_viewer/JFJochDiffractionImage.h @@ -19,13 +19,14 @@ Q_OBJECT QColor prediction_color = Qt::darkRed; QColor ice_ring_color = Qt::cyan; QColor second_lattice_color = QColor(0xFA, 0x72, 0x68); // coral, the viewer "finishing" accent - // Spot markers are drawn twice: a black pen this much wider underneath, then the marker on - // top. The hues mean something - cyan is the colour of ice, magenta is the one colour no - // colour map contains - so none of them moves to gain contrast. The casing carries the - // marker where the colour map's low end is light, the bright core carries it where it is - // dark, so one mechanism covers both without branching on the colour map. Predictions are - // left alone: darkRed is already legible on a light map and a black casing does nothing for - // it on a dark one. + // With outlining on, spot markers are drawn twice: a black pen this much wider underneath, + // then the marker on top. The hues mean something - cyan is the colour of ice, magenta is + // the one colour no colour map contains - so none of them moves to gain contrast. The casing + // carries the marker where the colour map's low end is light, the bright core carries it + // where it is dark, so one mechanism covers both without branching on the colour map. It is + // opt-in (default off): the doubled stroke makes the markers harder to read for some users. + // Predictions are left alone: darkRed is already legible on a light map and a black casing + // does nothing for it on a dark one. static constexpr int MARKER_CASING_EXTRA_WIDTH = 4; float hover_resolution = NAN; @@ -128,6 +129,8 @@ private: bool hide_unindexed_spots = false; bool hide_ice_ring_spots = false; + bool outline_spots = false; // black casing under spot markers, see MARKER_CASING_EXTRA_WIDTH + void mouseHover(const QPointF &scenePos, Qt::KeyboardModifiers modifiers) override; signals: @@ -159,6 +162,7 @@ public slots: void highlightIceRings(bool input); void hideUnindexedSpots(bool input); void hideIceRingSpots(bool input); + void outlineSpots(bool input); void setHDRMode(bool input); };