Keep track of user requested minimum depth

When got auto-rescaling of the depth scale, always reset the depth scale
to what the profile would suggest. This introduces a concept of user
requested minimum witch we will update and not scale down to lower than.

Reported-by: Henrik Brautaset Aronsen <henrik@synth.no>
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Anton Lundin 2013-12-08 14:52:34 +01:00 committed by Dirk Hohndel
parent a145c2e61a
commit 44848d5457
2 changed files with 8 additions and 4 deletions

View file

@ -158,6 +158,7 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent)
scene()->addItem(depthHandler); scene()->addItem(depthHandler);
minMinutes = TIME_INITIAL_MAX; minMinutes = TIME_INITIAL_MAX;
minDepth = M_OR_FT(40,120);
QAction *action = NULL; QAction *action = NULL;
#define ADD_ACTION( SHORTCUT, Slot ) \ #define ADD_ACTION( SHORTCUT, Slot ) \
@ -360,7 +361,8 @@ void DivePlannerGraphics::increaseDepth()
{ {
if (depthLine->maximum() + M_OR_FT(10,30) > MAX_DEPTH) if (depthLine->maximum() + M_OR_FT(10,30) > MAX_DEPTH)
return; return;
depthLine->setMaximum( depthLine->maximum() + M_OR_FT(10,30)); minDepth += M_OR_FT(10,30);
depthLine->setMaximum( minDepth );
depthLine->updateTicks(); depthLine->updateTicks();
drawProfile(); drawProfile();
} }
@ -387,7 +389,8 @@ void DivePlannerGraphics::decreaseDepth()
return; return;
} }
} }
depthLine->setMaximum(depthLine->maximum() - M_OR_FT(10,30)); minDepth -= M_OR_FT(10,30);
depthLine->setMaximum( minDepth );
depthLine->updateTicks(); depthLine->updateTicks();
drawProfile(); drawProfile();
} }
@ -502,7 +505,7 @@ void DivePlannerGraphics::drawProfile()
timeLine->updateTicks(); timeLine->updateTicks();
} }
if (!activeDraggedHandler && (depthLine->maximum() < max_depth + M_OR_FT(10,30) || max_depth + M_OR_FT(10,30) < depthLine->maximum())) { 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)); double newMax = fmax(max_depth + M_OR_FT(10,30), minDepth);
depthLine->setMaximum(newMax); depthLine->setMaximum(newMax);
depthLine->updateTicks(); depthLine->updateTicks();
} }

View file

@ -221,7 +221,8 @@ private:
ExpanderGraphics *depthHandler; ExpanderGraphics *depthHandler;
ExpanderGraphics *timeHandler; ExpanderGraphics *timeHandler;
int minMinutes; // this holds the minimum duration of the dive. int minMinutes; // this holds the minimum requested window time
int minDepth; // this holds the minimum requested window depth
int dpMaxTime; // this is the time of the dive calculated by the deco. int dpMaxTime; // this is the time of the dive calculated by the deco.
friend class DiveHandler; friend class DiveHandler;