viewer: ring labels in plain type at one screen size, and a cell that holds still
Build Packages / Create release (push) Successful in 59s
Build Packages / build:viewer-tgz:cpu (push) Successful in 11m44s
Build Packages / build:rugnux-tgz (x86_64) (push) Successful in 9m55s
Build Packages / build:viewer-tgz:cuda (push) Successful in 11m51s
Build Packages / build:rugnux:aarch64 (cross) (push) Successful in 5m3s
Build Packages / build:windows:nocuda (push) Successful in 16m58s
Build Packages / build:windows:cuda (push) Successful in 19m23s
Build Packages / HDF5 consumer tests (DIALS, XDS) (push) Successful in 23m30s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 15m12s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 14m46s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 15m2s
Build Packages / build:rugnux:windows (push) Successful in 10m52s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 16m16s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 14m53s
Build Packages / Generate python client (push) Successful in 33s
Build Packages / Build documentation (push) Successful in 1m18s
Build Packages / build:rpm (rocky9_sls9) (push) Successful in 16m27s
Build Packages / build:rpm (rocky8) (push) Successful in 16m46s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 16m47s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 15m58s
Build Packages / build:rpm (rocky9) (push) Successful in 17m35s
Build Packages / Unit tests (push) Successful in 1h14m23s

The cased white label read as an outline artefact, and its scene-space
font - scaled by 1/zoom to hold an apparent size - broke down at high
magnification, where a sub-point font rasterises into a white block.
The label is now drawn in device coordinates (ItemIgnoresTransformations)
at 1.6x the application font, bold, with no outline, so it is the same
size at every zoom by construction. The colour is picked from what ends
up under it: near-black normally - the label usually sits outside the
detector image, on the canvas that is white under every colour map -
and white only over the image of a dark map. Not the ring's magenta:
where the label meets its own dashes the two blend and the glyphs
dissolve.

The unit-cell rows pad every number to three integer digits with figure
spaces, so 95.0 and 102.3 occupy the same width and the columns do not
shift as values change magnitude; no axis reaches 1000 A and no angle
1000 degrees.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vRwzF8PLaaa2novAKYorq
This commit is contained in:
leonarski_fandClaude Fable 5 committed 2026-09-13 21:03:14 +02:00
1 parent 53d6aa4ddf
commit 941c6e45cc
3 files changed
+32 -14

No files matched your search

+1 -1
View File
@@ -8,7 +8,7 @@
* The viewer draws its spot markers over a black outline, so they stay visible on a light colour map and are no longer mistaken for a magenta bad pixel or the coral beam stop.
* The viewer has a background (black-point) slider beside the foreground one; hold B and scroll the wheel to adjust it.
* The viewer's keyboard shortcuts - F, B, A, Home/End/PageUp/PageDown - work whichever panel has the focus, not only with the image focused.
* The viewer's resolution-ring labels follow the font size, are cased like the spot markers so they read on any colour map, and stay whole inside the view instead of clipping at its edge.
* The viewer's resolution-ring labels keep one on-screen size that follows the font setting, print dark on a light colour map and white on a dark one, and stay whole inside the view instead of clipping at its edge.
* The viewer's dataset plots put the rotation-angle ticks on round angles - multiples of 90 degrees when the sweep is wide enough.
* The viewer's inspector prints the indexed cell as two aligned rows, mosaicity with two decimals, and "No lattice" in grey rather than alarm red.
* The viewer's armed "Analyze image" button is marked by a coral outline, instead of turning into a differently-coloured button.
+25 -12
View File
@@ -362,23 +362,28 @@ void JFJochDiffractionImage::DrawResolutionRings() {
for (const auto &[d, path]: ring_cache_) {
addOverlayItem(scene()->addPath(path, pen));
// The "d Å" label follows the application font (View -> Font size) and is white cased in
// black, like the spot markers, so it reads on any colour map and on the ring's own
// colour. The item lives in scene coordinates, so dividing by the view scale keeps it a
// constant size on screen - 1.2x the application font at every zoom. It is centred on the
// first sampled azimuth (staggered per ring) where the whole text fits in the viewport;
// failing that, on the visible ring point closest to the viewport centre, clamped inside -
// never half a label off the edge.
// The "d Å" label is drawn in device coordinates (ItemIgnoresTransformations), so it
// keeps a constant on-screen size - the application font, a step up and bold - at every
// zoom; shrinking a scene-space font by 1/zoom instead breaks glyph rendering once the
// point size drops below one. No outline; the colour is picked from what ends up under
// the label, white only over the image of a dark colour map. It is centred on the first
// sampled azimuth (staggered per ring) where the whole text fits in the viewport;
// failing that, on the visible ring point closest to the viewport centre, clamped
// inside - never half a label off the edge.
QFont font = this->font();
const qreal f = std::clamp(scale_factor, 0.05, 500.0);
font.setPointSizeF(font.pointSizeF() * 1.2 / f);
font.setPointSizeF(font.pointSizeF() * 1.6);
font.setBold(true);
auto *textItem = new QGraphicsSimpleTextItem(
QString("%1 Å").arg(QString::number(d, 'f', 2)));
textItem->setFont(font);
textItem->setBrush(Qt::white);
textItem->setPen(QPen(Qt::black, font.pointSizeF() / 8.0));
const QSizeF sz = textItem->boundingRect().size();
textItem->setFlag(QGraphicsItem::ItemIgnoresTransformations);
textItem->setPen(Qt::NoPen); // brush is chosen below, from what ends up under the label
// Device-size text: convert to scene units for the placement math below.
const qreal sx = std::max(1e-6, transform().m11());
const qreal sy = std::max(1e-6, transform().m22());
const QSizeF dev = textItem->boundingRect().size();
const QSizeF sz(dev.width() / sx, dev.height() / sy);
QRectF inner = visibleRect.adjusted(sz.height() * 0.3, sz.height() * 0.3,
-sz.height() * 0.3, -sz.height() * 0.3);
@@ -420,6 +425,14 @@ void JFJochDiffractionImage::DrawResolutionRings() {
if (r.top() < inner.top()) r.moveTop(inner.top());
if (r.bottom() > inner.bottom()) r.moveBottom(inner.bottom());
}
// The label prints dark unless it lands on the image with a dark colour map: off the
// image the canvas is white whatever the map, and on its own magenta dashes either
// colour separates where the ring colour would blend.
const auto map_zero = color_scale.Apply(0.0f);
const double zero_luminance = 0.2126 * map_zero.r + 0.7152 * map_zero.g + 0.0722 * map_zero.b;
const bool dark_under = zero_luminance <= 127.0
&& QRectF(0, 0, static_cast<qreal>(W), static_cast<qreal>(H)).contains(r.center());
textItem->setBrush(dark_under ? QColor(Qt::white) : QColor(0x20, 0x20, 0x20));
textItem->setPos(r.topLeft());
scene()->addItem(textItem);
addOverlayItem(textItem);
@@ -12,8 +12,13 @@
static QString mkUnitCell(const UnitCell &uc, const char *color = nullptr) {
const QString style = color ? QString(" style=\"color: %1;\"").arg(color) : QString();
auto num = [&style](double v) {
// Padded to three integer digits with figure spaces (digit-wide), so the columns hold
// still as values change magnitude; no axis reaches 1000 Å and no angle 1000°.
QString s = QString::number(v, 'f', 1);
while (s.size() < 5)
s.prepend(QChar(0x2007));
return QString("<td align=\"right\"%1><b>%2</b>&nbsp;&nbsp;</td>")
.arg(style).arg(QString::number(v, 'f', 1));
.arg(style).arg(s);
};
auto unit = [&style](const char *u) {
return QString("<td%1>%2</td>").arg(style).arg(u);