mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
profile: convert the "ruler item" to qt-quick
Code is mostly based on the "tooltip item". The dragging code was slightly reworked to be more logical. A "disk item" was added for the handles. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
b167e130a4
commit
ea0085fef6
14 changed files with 313 additions and 228 deletions
|
@ -2,6 +2,7 @@
|
|||
#include "profileview.h"
|
||||
#include "pictureitem.h"
|
||||
#include "profilescene.h"
|
||||
#include "ruleritem.h"
|
||||
#include "tooltipitem.h"
|
||||
#include "zvalues.h"
|
||||
#include "core/dive.h"
|
||||
|
@ -142,6 +143,7 @@ void ProfileView::resetPointers()
|
|||
{
|
||||
profileItem.reset();
|
||||
tooltip.reset();
|
||||
ruler.reset();
|
||||
pictures.clear();
|
||||
highlightedPicture = nullptr;
|
||||
}
|
||||
|
@ -170,6 +172,8 @@ void ProfileView::clear()
|
|||
//gases.clear();
|
||||
if (tooltip)
|
||||
tooltip->setVisible(false);
|
||||
if (ruler)
|
||||
ruler->setVisible(false);
|
||||
empty = true;
|
||||
d = nullptr;
|
||||
dc = 0;
|
||||
|
@ -217,9 +221,6 @@ void ProfileView::plotDive(const struct dive *dIn, int dcIn, int flags)
|
|||
background = inPlanner ? QColor("#D7E3EF") : getColor(::BACKGROUND, false);
|
||||
profileItem->draw(size(), background, *profileScene);
|
||||
|
||||
//rulerItem->setVisible(prefs.rulergraph && currentState != PLAN && currentState != EDIT);
|
||||
//rulerItem->setPlotInfo(d, profileScene->plotInfo);
|
||||
|
||||
//if ((currentState == EDIT || currentState == PLAN) && plannerModel) {
|
||||
//repositionDiveHandlers();
|
||||
//plannerModel->deleteTemporaryPlan();
|
||||
|
@ -257,6 +258,15 @@ void ProfileView::plotDive(const struct dive *dIn, int dcIn, int flags)
|
|||
tooltip->setVisible(false);
|
||||
}
|
||||
|
||||
if (!ruler)
|
||||
ruler = std::make_unique<RulerItem>(*this, dpr);
|
||||
if (prefs.rulergraph && !(flags & RenderFlags::PlanMode) && !(flags & RenderFlags::EditMode)) {
|
||||
ruler->setVisible(true);
|
||||
updateRuler(animSpeed);
|
||||
} else {
|
||||
ruler->setVisible(false);
|
||||
}
|
||||
|
||||
// Reset animation.
|
||||
animation = make_anim([this](double progress) { anim(progress); }, animSpeed);
|
||||
}
|
||||
|
@ -549,6 +559,20 @@ void ProfileView::updateTooltip(QPointF pos, bool plannerMode, int animSpeed)
|
|||
{ if (tooltip) tooltip->anim(progress); update(); }, animSpeed);
|
||||
}
|
||||
|
||||
void ProfileView::rulerDragged()
|
||||
{
|
||||
updateRuler(qPrefDisplay::animation_speed());
|
||||
}
|
||||
|
||||
void ProfileView::updateRuler(int animSpeed)
|
||||
{
|
||||
ruler->update(d, dpr, *profileScene, profileScene->getPlotInfo(), animSpeed);
|
||||
|
||||
// Reset animation.
|
||||
ruler_animation = make_anim([this](double progress)
|
||||
{ if (ruler) ruler->anim(progress); update(); }, animSpeed);
|
||||
}
|
||||
|
||||
// Create a PictureEntry object and add its thumbnail to the scene if profile pictures are shown.
|
||||
ProfileView::PictureEntry::PictureEntry(offset_t offset, const QString &filename, ChartItemPtr<PictureItem> thumbnail, double dpr, bool synchronous) : offset(offset),
|
||||
filename(filename),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue