mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
profile: use a flag variable in plotDive()
Positional bool parameters to control the rendering of the plot have been a pain. We are down to one parameter (instant), but more will be readded, so let's use the opportunity to control rendering with a flags parameter. Sadly, C++ has no reasonable way of defining flags that I know of. Either the identifiers leak (enum), or can't be trivially ORed (enum class) or are weakly typed (int). Let's just use an integer for now. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
d3a2c40f52
commit
6dfc2da8d0
2 changed files with 13 additions and 7 deletions
|
@ -185,11 +185,11 @@ void ProfileWidget2::resetZoom()
|
|||
}
|
||||
|
||||
// Currently just one dive, but the plan is to enable All of the selected dives.
|
||||
void ProfileWidget2::plotDive(const struct dive *dIn, int dcIn, bool instant)
|
||||
void ProfileWidget2::plotDive(const struct dive *dIn, int dcIn, int flags)
|
||||
{
|
||||
// If there was no previously displayed dive, turn off animations
|
||||
if (!d)
|
||||
instant = true;
|
||||
flags |= RenderFlags::Instant;
|
||||
|
||||
d = dIn;
|
||||
dc = dcIn;
|
||||
|
@ -205,7 +205,7 @@ void ProfileWidget2::plotDive(const struct dive *dIn, int dcIn, bool instant)
|
|||
bool inPlanner = currentState == PLAN;
|
||||
|
||||
double zoom = zoomLevel == 0 ? 1.0 : pow(zoomFactor, zoomLevel);
|
||||
profileScene->plotDive(d, dc, model, inPlanner, instant, shouldCalculateMax, zoom, zoomedPosition);
|
||||
profileScene->plotDive(d, dc, model, inPlanner, flags & RenderFlags::Instant, shouldCalculateMax, zoom, zoomedPosition);
|
||||
|
||||
#ifndef SUBSURFACE_MOBILE
|
||||
rulerItem->setVisible(prefs.rulergraph && currentState != PLAN && currentState != EDIT);
|
||||
|
@ -216,7 +216,7 @@ void ProfileWidget2::plotDive(const struct dive *dIn, int dcIn, bool instant)
|
|||
repositionDiveHandlers();
|
||||
plannerModel->deleteTemporaryPlan();
|
||||
}
|
||||
plotPicturesInternal(d, instant);
|
||||
plotPicturesInternal(d, flags & RenderFlags::Instant);
|
||||
|
||||
toolTipItem->refresh(d, mapToScene(mapFromGlobal(QCursor::pos())), currentState == PLAN);
|
||||
#endif
|
||||
|
@ -256,7 +256,7 @@ void ProfileWidget2::resizeEvent(QResizeEvent *event)
|
|||
{
|
||||
QGraphicsView::resizeEvent(event);
|
||||
profileScene->resize(viewport()->size());
|
||||
plotDive(d, dc, true); // disable animation on resize events
|
||||
plotDive(d, dc, RenderFlags::Instant); // disable animation on resize events
|
||||
}
|
||||
|
||||
#ifndef SUBSURFACE_MOBILE
|
||||
|
@ -343,7 +343,7 @@ void ProfileWidget2::mouseMoveEvent(QMouseEvent *event)
|
|||
|
||||
if (zoomLevel != 0) {
|
||||
zoomedPosition = pos.x() / profileScene->width();
|
||||
plotDive(d, dc, true); // TODO: animations don't work when scrolling
|
||||
plotDive(d, dc, RenderFlags::Instant); // TODO: animations don't work when scrolling
|
||||
}
|
||||
|
||||
double vValue = profileScene->profileYAxis->valueAt(pos);
|
||||
|
|
|
@ -42,11 +42,17 @@ public:
|
|||
INIT
|
||||
};
|
||||
|
||||
struct RenderFlags {
|
||||
static constexpr int None = 0;
|
||||
static constexpr int Instant = 1 << 0;
|
||||
static constexpr int DontRecalculatePlotInfo = 1 << 1;
|
||||
};
|
||||
|
||||
// Pass null as plannerModel if no support for planning required
|
||||
ProfileWidget2(DivePlannerPointsModel *plannerModel, double dpr, QWidget *parent = 0);
|
||||
~ProfileWidget2();
|
||||
void resetZoom();
|
||||
void plotDive(const struct dive *d, int dc, bool instant = false);
|
||||
void plotDive(const struct dive *d, int dc, int flags = RenderFlags::None);
|
||||
void setProfileState(const struct dive *d, int dc);
|
||||
void setPlanState(const struct dive *d, int dc);
|
||||
void setEditState(const struct dive *d, int dc);
|
||||
|
|
Loading…
Add table
Reference in a new issue