This makes the ProfileView better and faster, for the planner, add and profile modes.
From a9d72f02ecdce7ae0e46dca0f32676063c7e956b Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 26 May 2014 18:20:40 -0300 Subject: [PATCH 1/2] Better movements from the lines when added / removed.
This makes the movements from the lines when added / removed SO much better. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/profile/divecartesianaxis.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/qt-ui/profile/divecartesianaxis.cpp b/qt-ui/profile/divecartesianaxis.cpp index 25b8a55..d4ba92b 100644 --- a/qt-ui/profile/divecartesianaxis.cpp +++ b/qt-ui/profile/divecartesianaxis.cpp @@ -234,11 +234,13 @@ void DiveCartesianAxis::updateTicks(color_indice_t color) lines.push_back(line); if (orientation == RightToLeft || orientation == LeftToRight) { line->setLine(0, -line_size, 0, 0); + line->setPos(scene()->sceneRect().width() + 10, m.y1()); // position it outside of the scene); line->animateMoveTo(childPos, m.y1()); } else { QPointF p1 = mapFromScene(3, 0); QPointF p2 = mapFromScene(line_size, 0); line->setLine(p1.x(), 0, p2.x(), 0); + line->setPos(m.x1(), scene()->sceneRect().height() + 10); line->animateMoveTo(m.x1(), childPos); } } -- 1.9.3
From b15a3f132ed90005c58b48ec33e5aa66fe919a39 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 26 May 2014 19:29:25 -0300 Subject: [PATCH 2/2] Paint the dive Red if the user is breakign ceiling on the planner. This patch paints the dive red if the user is breaking ceiling on the planner - it's quite fast, it analizes the depth over the max(tissue_1 .. tissue_16) and changes the color of the profile. Signed-off-by: Tomaz Canabrava <[email protected]> --- planner.c | 3 --- qt-ui/profile/diveprofileitem.cpp | 26 +++++++++++++++++++++++++- qt-ui/profile/diveprofileitem.h | 3 ++- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/planner.c b/planner.c index 8b45252..300a15d 100644 --- a/planner.c +++ b/planner.c @@ -677,9 +677,6 @@ void plan(struct diveplan *diveplan, char **cached_datap, struct dive **divep, b while (1) { /* We will break out when we hit the surface */ do { - /* Ascend to next stop depth */ - if (deco_allowed_depth(tissue_tolerance, diveplan->surface_pressure / 1000.0, dive, 1) < depth) - fprintf(stderr, "user provided way point above ceiling\n"); int deltad = ascend_velocity(depth, avg_depth, bottom_time) * TIMESTEP; if (ascend_velocity(depth, avg_depth, bottom_time) != last_ascend_rate) { plan_add_segment(diveplan, clock - previous_point_time, depth, o2, he, po2, false); diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp index 2a6d5ac..4a86dc9 100644 --- a/qt-ui/profile/diveprofileitem.cpp +++ b/qt-ui/profile/diveprofileitem.cpp @@ -3,6 +3,7 @@ #include "divecartesianaxis.h" #include "graphicsview-common.h" #include "divetextitem.h" +#include "profilewidget2.h" #include "profile.h" #include "dive.h" #include "preferences.h" @@ -136,6 +137,17 @@ void DiveProfileItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *o } } +int DiveProfileItem::maxCeiling(int row) +{ + int max = -1; + plot_data *entry = dataModel->data().entry + row; + for(int tissue = 0; tissue < 16; tissue++){ + if (max < entry->ceilings[tissue]) + max = entry->ceilings[tissue]; + } + return max; +} + void DiveProfileItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) { if (!shouldCalculateStuff(topLeft, bottomRight)) @@ -147,6 +159,18 @@ void DiveProfileItem::modelDataChanged(const QModelIndex &topLeft, const QModelI show_reported_ceiling = prefs.dcceiling; reported_ceiling_in_red = prefs.redceiling; + profileColor = getColor(DEPTH_BOTTOM); + + int currState = qobject_cast<ProfileWidget2*>(scene()->views().first())->currentState; + if (currState == ProfileWidget2::PLAN) { + plot_data *entry = dataModel->data().entry + dataModel->rowCount() - 1; + for (int i = dataModel->rowCount() - 1; i >= 0; i--, entry--) { + int max = maxCeiling(i); + if (entry->depth < max) { + profileColor = QColor(Qt::red); + } + } + } /* Show any ceiling we may have encountered */ if (prefs.dcceiling && !prefs.redceiling) { @@ -166,7 +190,7 @@ void DiveProfileItem::modelDataChanged(const QModelIndex &topLeft, const QModelI // This is the blueish gradient that the Depth Profile should have. // It's a simple QLinearGradient with 2 stops, starting from top to bottom. QLinearGradient pat(0, polygon().boundingRect().top(), 0, polygon().boundingRect().bottom()); - pat.setColorAt(1, getColor(DEPTH_BOTTOM)); + pat.setColorAt(1, profileColor); pat.setColorAt(0, getColor(DEPTH_TOP)); setBrush(QBrush(pat)); diff --git a/qt-ui/profile/diveprofileitem.h b/qt-ui/profile/diveprofileitem.h index de0c6f0..916404c 100644 --- a/qt-ui/profile/diveprofileitem.h +++ b/qt-ui/profile/diveprofileitem.h @@ -77,10 +77,11 @@ public: virtual void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex()); virtual void settingsChanged(); void plot_depth_sample(struct plot_data *entry, QFlags<Qt::AlignmentFlag> flags, const QColor &color); - + int maxCeiling(int row); private: unsigned int show_reported_ceiling; unsigned int reported_ceiling_in_red; + QColor profileColor; }; class DiveTemperatureItem : public AbstractProfilePolygonItem { -- 1.9.3
_______________________________________________ subsurface mailing list [email protected] http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface
