mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-27 20:58:47 +00:00
profile: recalculate profile info when switching from empty state
When the profile was to small, it would switch into empty state and clear the plot info. On resize events, the plot info is not recalculated. This means that when making the profile extremely small and then bigger, nothing is shown. This may also happen on startup. The profile is rendered into a 0x0 widget and then gets a resize event. Therefore, remember when the profile is empty and force a recalculation of the plot info. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
261f07dfa4
commit
9bca38afcf
2 changed files with 9 additions and 2 deletions
|
@ -90,6 +90,7 @@ ProfileScene::ProfileScene(double dpr, bool printMode, bool isGrayscale) :
|
||||||
dpr(dpr),
|
dpr(dpr),
|
||||||
printMode(printMode),
|
printMode(printMode),
|
||||||
isGrayscale(isGrayscale),
|
isGrayscale(isGrayscale),
|
||||||
|
empty(true),
|
||||||
maxtime(-1),
|
maxtime(-1),
|
||||||
maxdepth(-1),
|
maxdepth(-1),
|
||||||
profileYAxis(new DiveCartesianAxis(DiveCartesianAxis::Position::Left, true, 3, 0, TIME_GRID, Qt::red, true, true,
|
profileYAxis(new DiveCartesianAxis(DiveCartesianAxis::Position::Left, true, 3, 0, TIME_GRID, Qt::red, true, true,
|
||||||
|
@ -200,6 +201,7 @@ void ProfileScene::clear()
|
||||||
qDeleteAll(eventItems);
|
qDeleteAll(eventItems);
|
||||||
eventItems.clear();
|
eventItems.clear();
|
||||||
free_plot_info_data(&plotInfo);
|
free_plot_info_data(&plotInfo);
|
||||||
|
empty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ppGraphsEnabled(const struct divecomputer *dc, bool simplified)
|
static bool ppGraphsEnabled(const struct divecomputer *dc, bool simplified)
|
||||||
|
@ -429,6 +431,11 @@ void ProfileScene::plotDive(const struct dive *dIn, int dcIn, DivePlannerPointsM
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we come from the empty state, the plot info has to be recalculated.
|
||||||
|
if (empty)
|
||||||
|
keepPlotInfo = false;
|
||||||
|
empty = false;
|
||||||
|
|
||||||
int animSpeed = instant || printMode ? 0 : qPrefDisplay::animation_speed();
|
int animSpeed = instant || printMode ? 0 : qPrefDisplay::animation_speed();
|
||||||
|
|
||||||
// A non-null planner_ds signals to create_plot_info_new that the dive is currently planned.
|
// A non-null planner_ds signals to create_plot_info_new that the dive is currently planned.
|
||||||
|
@ -465,9 +472,8 @@ void ProfileScene::plotDive(const struct dive *dIn, int dcIn, DivePlannerPointsM
|
||||||
*/
|
*/
|
||||||
int newMaxDepth = get_maxdepth(&plotInfo);
|
int newMaxDepth = get_maxdepth(&plotInfo);
|
||||||
if (!calcMax) {
|
if (!calcMax) {
|
||||||
if (maxdepth < newMaxDepth) {
|
if (maxdepth < newMaxDepth)
|
||||||
maxdepth = newMaxDepth;
|
maxdepth = newMaxDepth;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
maxdepth = newMaxDepth;
|
maxdepth = newMaxDepth;
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,6 +65,7 @@ private:
|
||||||
double dpr; // Device Pixel Ratio. A DPR of one corresponds to a "standard" PC screen.
|
double dpr; // Device Pixel Ratio. A DPR of one corresponds to a "standard" PC screen.
|
||||||
bool printMode;
|
bool printMode;
|
||||||
bool isGrayscale;
|
bool isGrayscale;
|
||||||
|
bool empty; // The profile currently shows nothing.
|
||||||
int maxtime;
|
int maxtime;
|
||||||
int maxdepth;
|
int maxdepth;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue