mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
profile: set minimum/maximum of axes with a single call
This is bike-shedding: Instead of two setMinimum()/setMaximum() calls, use a single setBounds() call. A few axes (notably depth and time) always have a 0 as lower bound. However, this will change once there is a proper zooming functionality. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
0bef8167d2
commit
89d9105209
4 changed files with 13 additions and 28 deletions
|
@ -17,20 +17,11 @@ void DiveCartesianAxis::setFontLabelScale(qreal scale)
|
|||
changed = true;
|
||||
}
|
||||
|
||||
void DiveCartesianAxis::setMaximum(double maximum)
|
||||
void DiveCartesianAxis::setBounds(double minimum, double maximum)
|
||||
{
|
||||
if (IS_FP_SAME(max, maximum))
|
||||
return;
|
||||
max = maximum;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
void DiveCartesianAxis::setMinimum(double minimum)
|
||||
{
|
||||
if (IS_FP_SAME(min, minimum))
|
||||
return;
|
||||
changed = !IS_FP_SAME(max, maximum) || !IS_FP_SAME(min, minimum);
|
||||
min = minimum;
|
||||
changed = true;
|
||||
max = maximum;
|
||||
}
|
||||
|
||||
DiveCartesianAxis::DiveCartesianAxis(Position position, color_index_t gridColor, double dpr,
|
||||
|
@ -431,7 +422,7 @@ void PartialGasPressureAxis::update(int animSpeed)
|
|||
if (IS_FP_SAME(maximum(), pp))
|
||||
return;
|
||||
|
||||
setMaximum(pp);
|
||||
setBounds(0.0, pp);
|
||||
setTickInterval(pp > 4 ? 0.5 : 0.25);
|
||||
updateTicks(animSpeed);
|
||||
}
|
||||
|
|
|
@ -35,8 +35,7 @@ public:
|
|||
DiveCartesianAxis(Position position, color_index_t gridColor, double dpr,
|
||||
bool printMode, bool isGrayscale, ProfileScene &scene);
|
||||
~DiveCartesianAxis();
|
||||
void setMinimum(double minimum);
|
||||
void setMaximum(double maximum);
|
||||
void setBounds(double min, double max);
|
||||
void setTickInterval(double interval);
|
||||
void setOrientation(Orientation orientation);
|
||||
void setFontLabelScale(qreal scale);
|
||||
|
|
|
@ -82,12 +82,10 @@ ProfileScene::ProfileScene(double dpr, bool printMode, bool isGrayscale) :
|
|||
|
||||
// Initialize axes. Perhaps part of this should be moved down to the axes code?
|
||||
profileYAxis->setOrientation(DiveCartesianAxis::TopToBottom);
|
||||
profileYAxis->setMinimum(0);
|
||||
profileYAxis->setTickInterval(M_OR_FT(10, 30));
|
||||
|
||||
gasYAxis->setOrientation(DiveCartesianAxis::BottomToTop);
|
||||
gasYAxis->setTickInterval(1);
|
||||
gasYAxis->setMinimum(0);
|
||||
gasYAxis->setFontLabelScale(0.7);
|
||||
|
||||
#ifndef SUBSURFACE_MOBILE
|
||||
|
@ -377,11 +375,11 @@ void ProfileScene::plotDive(const struct dive *dIn, int dcIn, DivePlannerPointsM
|
|||
|
||||
// It seems that I'll have a lot of boilerplate setting the model / axis for
|
||||
// each item, I'll mostly like to fix this in the future, but I'll keep at this for now.
|
||||
profileYAxis->setMaximum(maxdepth);
|
||||
profileYAxis->setBounds(0.0, maxdepth);
|
||||
profileYAxis->updateTicks(animSpeed);
|
||||
|
||||
temperatureAxis->setMinimum(plotInfo.mintemp);
|
||||
temperatureAxis->setMaximum(plotInfo.maxtemp - plotInfo.mintemp > 2000 ? plotInfo.maxtemp : plotInfo.mintemp + 2000);
|
||||
temperatureAxis->setBounds(plotInfo.mintemp,
|
||||
plotInfo.maxtemp - plotInfo.mintemp > 2000 ? plotInfo.maxtemp : plotInfo.mintemp + 2000);
|
||||
|
||||
if (hasHeartBeat) {
|
||||
int heartBeatAxisMin = lrint(plotInfo.minhr / 5.0 - 0.5) * 5;
|
||||
|
@ -395,19 +393,17 @@ void ProfileScene::plotDive(const struct dive *dIn, int dcIn, DivePlannerPointsM
|
|||
else
|
||||
heartBeatAxisTick = 50;
|
||||
for (heartBeatAxisMax = heartBeatAxisMin; heartBeatAxisMax < plotInfo.maxhr; heartBeatAxisMax += heartBeatAxisTick);
|
||||
heartBeatAxis->setMinimum(heartBeatAxisMin);
|
||||
heartBeatAxis->setMaximum(heartBeatAxisMax + 1);
|
||||
heartBeatAxis->setBounds(heartBeatAxisMin, heartBeatAxisMax + 1);
|
||||
heartBeatAxis->setTickInterval(heartBeatAxisTick);
|
||||
heartBeatAxis->updateTicks(animSpeed); // this shows the ticks
|
||||
}
|
||||
|
||||
percentageAxis->setMinimum(0);
|
||||
percentageAxis->setMaximum(100);
|
||||
percentageAxis->setBounds(0, 100);
|
||||
percentageAxis->setVisible(false);
|
||||
percentageAxis->updateTicks(animSpeed);
|
||||
|
||||
if (calcMax)
|
||||
timeAxis->setMaximum(maxtime);
|
||||
timeAxis->setBounds(0.0, maxtime);
|
||||
|
||||
int i, incr;
|
||||
static int increments[8] = { 10, 20, 30, 60, 5 * 60, 10 * 60, 15 * 60, 30 * 60 };
|
||||
|
@ -426,8 +422,7 @@ void ProfileScene::plotDive(const struct dive *dIn, int dcIn, DivePlannerPointsM
|
|||
incr *= 2;
|
||||
timeAxis->setTickInterval(incr);
|
||||
timeAxis->updateTicks(animSpeed);
|
||||
cylinderPressureAxis->setMinimum(plotInfo.minpressure);
|
||||
cylinderPressureAxis->setMaximum(plotInfo.maxpressure);
|
||||
cylinderPressureAxis->setBounds(plotInfo.minpressure, plotInfo.maxpressure);
|
||||
|
||||
#ifdef SUBSURFACE_MOBILE
|
||||
if (currentdc->divemode == CCR) {
|
||||
|
|
|
@ -970,7 +970,7 @@ void ProfileWidget2::divePlannerHandlerMoved()
|
|||
// Grow the time axis if necessary.
|
||||
int minutes = lrint(profileScene->timeAxis->valueAt(activeHandler->pos()) / 60);
|
||||
if (minutes * 60 > profileScene->timeAxis->maximum() * 0.9)
|
||||
profileScene->timeAxis->setMaximum(profileScene->timeAxis->maximum() * 1.02);
|
||||
profileScene->timeAxis->setBounds(0.0, profileScene->timeAxis->maximum() * 1.02);
|
||||
|
||||
divedatapoint data = plannerModel->at(index);
|
||||
data.depth.mm = lrint(profileScene->profileYAxis->valueAt(activeHandler->pos()) / M_OR_FT(1, 1)) * M_OR_FT(1, 1);
|
||||
|
|
Loading…
Reference in a new issue