v1.0.0-rc.119 (#26)
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 10m11s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 10m22s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 10m27s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 8m19s
Build Packages / Generate python client (push) Successful in 17s
Build Packages / Build documentation (push) Successful in 42s
Build Packages / Create release (push) Has been skipped
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 8m44s
Build Packages / build:rpm (rocky8) (push) Successful in 8m44s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 8m33s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 9m11s
Build Packages / build:rpm (rocky9) (push) Successful in 9m54s
Build Packages / Unit tests (push) Failing after 1h11m12s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 10m11s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 10m22s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 10m27s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 8m19s
Build Packages / Generate python client (push) Successful in 17s
Build Packages / Build documentation (push) Successful in 42s
Build Packages / Create release (push) Has been skipped
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 8m44s
Build Packages / build:rpm (rocky8) (push) Successful in 8m44s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 8m33s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 9m11s
Build Packages / build:rpm (rocky9) (push) Successful in 9m54s
Build Packages / Unit tests (push) Failing after 1h11m12s
This is an UNSTABLE release and not recommended for production use (please use rc.111 instead). * jfjoch_broker: Add binary export of data analysis plots over OpenAPI * jfjoch_broker: Minor fixes to HTTP error handling * jfjoch_viewer: Prefer binary plots over JSON plots * jfjoch_viewer: Change foreground with F button + wheel * jfjoch_viewer: Change way how angles are displayed * jfjoch_viewer: Display resolution of the mouse cursor in top left corner Reviewed-on: #26 Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch> Co-committed-by: Filip Leonarski <filip.leonarski@psi.ch>
This commit was merged in pull request #26.
This commit is contained in:
@@ -43,11 +43,22 @@ void JFJochDiffractionImage::mouseHover(QMouseEvent *event) {
|
||||
.arg(coord.y(), 0, 'f', 1)
|
||||
.arg(intensity_str)
|
||||
.arg(res, 0, 'f', 2));
|
||||
} else
|
||||
|
||||
// Update hovered resolution text without rebuilding the whole overlay
|
||||
hover_resolution = res;
|
||||
DrawResolutionText();
|
||||
} else {
|
||||
emit writeStatusBar("");
|
||||
|
||||
// Clear hover resolution text when outside image
|
||||
if (std::isfinite(hover_resolution)) {
|
||||
hover_resolution = NAN;
|
||||
DrawResolutionText();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void JFJochDiffractionImage::LoadImageInternal() {
|
||||
if (!image)
|
||||
return;
|
||||
@@ -298,6 +309,8 @@ void JFJochDiffractionImage::addCustomOverlay() {
|
||||
DrawPredictions();
|
||||
if (show_saturation)
|
||||
DrawSaturation();
|
||||
|
||||
DrawResolutionText();
|
||||
}
|
||||
|
||||
void JFJochDiffractionImage::loadImage(std::shared_ptr<const JFJochReaderImage> in_image) {
|
||||
@@ -316,6 +329,9 @@ void JFJochDiffractionImage::loadImage(std::shared_ptr<const JFJochReaderImage>
|
||||
W = 0; H = 0;
|
||||
if (scene())
|
||||
scene()->clear();
|
||||
hover_resolution = NAN;
|
||||
hover_resolution_item = nullptr;
|
||||
|
||||
CalcROI();
|
||||
}
|
||||
}
|
||||
@@ -403,3 +419,64 @@ void JFJochDiffractionImage::setResolutionRingMode(RingMode mode) {
|
||||
ring_mode = mode;
|
||||
updateOverlay();
|
||||
}
|
||||
|
||||
void JFJochDiffractionImage::DrawResolutionText() {
|
||||
auto scn = scene();
|
||||
if (!scn) {
|
||||
hover_resolution_item = nullptr; // scene gone
|
||||
return;
|
||||
}
|
||||
|
||||
// Hide item if no valid hover resolution
|
||||
if (!image || !std::isfinite(hover_resolution) || hover_resolution <= 0.0f) {
|
||||
if (hover_resolution_item)
|
||||
hover_resolution_item->setVisible(false);
|
||||
return;
|
||||
}
|
||||
|
||||
const QRectF visibleRect = mapToScene(viewport()->geometry()).boundingRect();
|
||||
|
||||
// Fixed on-screen font size (no dependence on scale_factor)
|
||||
QFont font("Arial");
|
||||
font.setPixelSize(32); // big, constant size on screen
|
||||
|
||||
const QString label =
|
||||
QString("d = %1 Å").arg(QString::number(hover_resolution, 'f', 2));
|
||||
|
||||
// Create the item if it does not exist yet; otherwise reuse it
|
||||
if (!hover_resolution_item) {
|
||||
hover_resolution_item = scn->addText(label, font);
|
||||
hover_resolution_item->setZValue(10.0);
|
||||
// Make the text ignore zooming / view transforms
|
||||
hover_resolution_item->setFlag(QGraphicsItem::ItemIgnoresTransformations, true);
|
||||
} else {
|
||||
hover_resolution_item->setFont(font);
|
||||
hover_resolution_item->setPlainText(label);
|
||||
}
|
||||
|
||||
hover_resolution_item->setDefaultTextColor(feature_color);
|
||||
|
||||
// Keep a roughly constant ~10 px margin by compensating with scale_factor
|
||||
const qreal margin_px = 10.0;
|
||||
const qreal margin_scene = margin_px / std::max(0.0001, scale_factor);
|
||||
|
||||
QPointF topLeft(visibleRect.left() + margin_scene,
|
||||
visibleRect.top() + margin_scene);
|
||||
hover_resolution_item->setPos(topLeft);
|
||||
hover_resolution_item->setVisible(true);
|
||||
}
|
||||
|
||||
void JFJochDiffractionImage::beforeOverlayCleared() {
|
||||
// The scene is about to clear (and delete) all its items.
|
||||
// Drop our non-owning pointer so we never touch a deleted item.
|
||||
hover_resolution_item = nullptr;
|
||||
}
|
||||
|
||||
void JFJochDiffractionImage::leaveEvent(QEvent *event) {
|
||||
// Mouse left the view: clear hover resolution and hide text
|
||||
if (std::isfinite(hover_resolution)) {
|
||||
hover_resolution = NAN;
|
||||
DrawResolutionText();
|
||||
}
|
||||
JFJochImage::leaveEvent(event);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user