[PATCH 1/7] Adapt depth-scale to current way points

Anton Lundin glance at acc.umu.se
Sat Dec 7 07:25:38 UTC 2013


If the scale is to big or to small, adapt the scale automatically.

Signed-off-by: Anton Lundin <glance at acc.umu.se>
---
 qt-ui/diveplanner.cpp | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 5efb7aa..a66256a 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -484,18 +484,28 @@ void DivePlannerGraphics::drawProfile()
 	plannerModel->createTemporaryPlan();
 	struct diveplan diveplan = plannerModel->getDiveplan();
 	struct divedatapoint *dp = diveplan.dp;
+	unsigned int max_depth = 0;
+
 	if (!dp) {
 		plannerModel->deleteTemporaryPlan();
 		return;
 	}
-	while(dp->next)
+	while(dp->next) {
+		if (dp->depth > max_depth)
+			max_depth = dp->depth;
 		dp = dp->next;
+	}
 
 	if (!activeDraggedHandler && (timeLine->maximum() < dp->time / 60.0 + 5 || dp->time / 60.0 + 15 < timeLine->maximum())) {
 		double newMax = fmax(dp->time / 60.0 + 5, minMinutes);
 		timeLine->setMaximum(newMax);
 		timeLine->updateTicks();
 	}
+	if (!activeDraggedHandler && (depthLine->maximum() < max_depth + M_OR_FT(10,30) || max_depth + M_OR_FT(10,30) < depthLine->maximum())) {
+		double newMax = fmax(max_depth + M_OR_FT(10,30), M_OR_FT(40,120));
+		depthLine->setMaximum(newMax);
+		depthLine->updateTicks();
+	}
 
 	// Re-position the user generated dive handlers
 	int last = 0;
-- 
1.8.3.2



More information about the subsurface mailing list