[PATCH 1/2] profilewidget2: add resetZoom()

Lubomir I. Ivanov neolit123 at gmail.com
Sun Oct 11 04:21:13 PDT 2015


From: "Lubomir I. Ivanov" <neolit123 at gmail.com>

resetZoom() is now a new method that is called both
when 'printMode' is updated or when the dive is re-plotted.

Fixes a bug where zooming in on the profile and then
printing the dive has the profile at the wrong zoom level (makes
the profile look smaller).

Reported-by: Willem Ferguson <willemferguson at zoology.up.ac.za>
Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
---
 qt-ui/profile/profilewidget2.cpp | 16 +++++++++++-----
 qt-ui/profile/profilewidget2.h   |  1 +
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index 5d2b507..ab9ae2c 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -477,6 +477,15 @@ void ProfileWidget2::setupSceneAndFlags()
 	background->setFlag(QGraphicsItem::ItemIgnoresTransformations);
 }
 
+void ProfileWidget2::resetZoom()
+{
+	if (!zoomLevel)
+		return;
+	const qreal defScale = 1.0 / qPow(zoomFactor, (qreal)zoomLevel);
+	scale(defScale, defScale);
+	zoomLevel = 0;
+}
+
 // Currently just one dive, but the plan is to enable All of the selected dives.
 void ProfileWidget2::plotDive(struct dive *d, bool force)
 {
@@ -521,11 +530,7 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
 	}
 
 	// restore default zoom level
-	if (zoomLevel) {
-		const qreal defScale = 1.0 / qPow(zoomFactor, (qreal)zoomLevel);
-		scale(defScale, defScale);
-		zoomLevel = 0;
-	}
+	resetZoom();
 
 	// reset some item visibility on printMode changes
 	toolTipItem->setVisible(!printMode);
@@ -1473,6 +1478,7 @@ bool ProfileWidget2::getPrintMode()
 void ProfileWidget2::setPrintMode(bool mode, bool grayscale)
 {
 	printMode = mode;
+	resetZoom();
 	isGrayscale = mode ? grayscale : false;
 	mouseFollowerHorizontal->setVisible(!mode);
 	mouseFollowerVertical->setVisible(!mode);
diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h
index 7e038ed..2d1a7bf 100644
--- a/qt-ui/profile/profilewidget2.h
+++ b/qt-ui/profile/profilewidget2.h
@@ -71,6 +71,7 @@ public:
 	};
 
 	ProfileWidget2(QWidget *parent = 0);
+	void resetZoom();
 	void plotDive(struct dive *d = 0, bool force = false);
 	virtual bool eventFilter(QObject *, QEvent *);
 	void setupItem(AbstractProfilePolygonItem *item, DiveCartesianAxis *hAxis, DiveCartesianAxis *vAxis, DivePlotDataModel *model, int vData, int hData, int zValue);
-- 
1.7.11.msysgit.0



More information about the subsurface mailing list