diff --git a/viewer/widgets/JFJochDiffractionImage.cpp b/viewer/widgets/JFJochDiffractionImage.cpp index 18789a12..36131d69 100644 --- a/viewer/widgets/JFJochDiffractionImage.cpp +++ b/viewer/widgets/JFJochDiffractionImage.cpp @@ -342,6 +342,7 @@ void JFJochDiffractionImage::loadImage(std::shared_ptr } image = in_image; LoadImageInternal(); + GeneratePixmap(); Redraw(); } else { image.reset(); @@ -364,37 +365,37 @@ void JFJochDiffractionImage::setAutoForeground(bool input) { void JFJochDiffractionImage::setResolutionRing(QVector v) { res_ring = v; res_ring_auto = false; - Redraw(); + updateOverlay(); } void JFJochDiffractionImage::setResolutionRingAuto() { res_ring_auto = true; - Redraw(); + updateOverlay(); } void JFJochDiffractionImage::showSpots(bool input) { show_spots = input; - Redraw(); + updateOverlay(); } void JFJochDiffractionImage::showPredictions(bool input) { show_predictions = input; - Redraw(); + updateOverlay(); } void JFJochDiffractionImage::setSpotColor(QColor input) { spot_color = input; - Redraw(); + updateOverlay(); } void JFJochDiffractionImage::setPredictionColor(QColor input) { prediction_color = input; - Redraw(); + updateOverlay(); } void JFJochDiffractionImage::showHighestPixels(int32_t v) { show_highest_pixels = v; - Redraw(); + updateOverlay(); } void JFJochDiffractionImage::DrawSaturation() { @@ -418,10 +419,11 @@ void JFJochDiffractionImage::DrawCross(float x, float y, float size, float width void JFJochDiffractionImage::showSaturation(bool input) { show_saturation = input; - Redraw(); + GeneratePixmap(); + updateOverlay(); } void JFJochDiffractionImage::highlightIceRings(bool input) { highlight_ice_rings = input; - Redraw(); + updateOverlay(); } diff --git a/viewer/widgets/JFJochImage.cpp b/viewer/widgets/JFJochImage.cpp index 55cea7cb..ce577899 100644 --- a/viewer/widgets/JFJochImage.cpp +++ b/viewer/widgets/JFJochImage.cpp @@ -30,17 +30,22 @@ void JFJochImage::onScroll(int value) { void JFJochImage::changeBackground(float val) { background = val; + GeneratePixmap(); Redraw(); } void JFJochImage::changeForeground(float val) { foreground = val; + // Regenerate the image + GeneratePixmap(); Redraw(); } void JFJochImage::setColorMap(int color_map) { try { color_scale.Select(static_cast(color_map)); + // Regenerate the image + GeneratePixmap(); Redraw(); } catch (...) { } @@ -48,6 +53,7 @@ void JFJochImage::setColorMap(int color_map) { void JFJochImage::setFeatureColor(QColor input) { feature_color = input; + GeneratePixmap(); Redraw(); } @@ -65,6 +71,8 @@ void JFJochImage::wheelEvent(QWheelEvent *event) { new_foreground = 1.0; foreground = new_foreground; emit foregroundChanged(foreground); + + GeneratePixmap(); Redraw(); } else { // Perform zooming @@ -438,15 +446,19 @@ void JFJochImage::Redraw() { // Save the current transformation (zoom state) QTransform currentTransform = this->transform(); - // Regenerate the image - DrawImage(); + QGraphicsScene *currentScene = scene(); + if (!currentScene) { + // First time - create a new scene + currentScene = new QGraphicsScene(this); + setScene(currentScene); + } // Restore the zoom level this->setTransform(currentTransform, false); // "false" prevents resetting the view updateOverlay(); } -void JFJochImage::DrawImage() { +void JFJochImage::GeneratePixmap() { /* if (auto_fg || auto_bg) { @@ -498,13 +510,6 @@ void JFJochImage::DrawImage() { } pixmap = QPixmap::fromImage(qimg); - - QGraphicsScene *currentScene = scene(); - if (!currentScene) { - // First time - create a new scene - currentScene = new QGraphicsScene(this); - setScene(currentScene); - } } void JFJochImage::centerOnSpot(QPointF point) { diff --git a/viewer/widgets/JFJochImage.h b/viewer/widgets/JFJochImage.h index a4ebe7e6..f69c66b4 100644 --- a/viewer/widgets/JFJochImage.h +++ b/viewer/widgets/JFJochImage.h @@ -22,7 +22,7 @@ class JFJochImage : public QGraphicsView { protected: virtual void mouseHover(QMouseEvent* event) = 0; void DrawROI(); - void DrawImage(); + void GeneratePixmap(); void Redraw(); bool show_saturation = false; diff --git a/viewer/widgets/JFJochSimpleImage.cpp b/viewer/widgets/JFJochSimpleImage.cpp index 891276a9..72fc7e7e 100644 --- a/viewer/widgets/JFJochSimpleImage.cpp +++ b/viewer/widgets/JFJochSimpleImage.cpp @@ -24,6 +24,7 @@ void JFJochSimpleImage::setImage(std::shared_ptr img) { if (img) { image_ = std::move(img); loadImageInternal(); + GeneratePixmap(); Redraw(); } else { image_.reset();