summaryrefslogtreecommitdiffstats
path: root/qt-ui/diveplanner.cpp
diff options
context:
space:
mode:
authorGravatar Robert Helling <helling@atdotde.de>2013-06-27 10:56:46 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-06-27 19:51:04 +0800
commit8eb2dc3d65f2364379e82deac8f91d3a8f380015 (patch)
treecdcdaefe63dd257931cf64ac75d642481ad55f07 /qt-ui/diveplanner.cpp
parent1ec8bc5de0518f9859fe7c44a55b3bdd14dd8b7e (diff)
downloadsubsurface-8eb2dc3d65f2364379e82deac8f91d3a8f380015.tar.gz
Removes circle in plan
Remove circle in plan by starting the first line at the first point rather than the last. In addition marks all entered points as entered and not just the first and sets line color accordingly. Makes plan_add_segment return the added data point. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/diveplanner.cpp')
-rw-r--r--qt-ui/diveplanner.cpp30
1 files changed, 14 insertions, 16 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 8cd389777..182a75226 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -118,7 +118,8 @@ void DivePlannerGraphics::createDecoStops()
int po2 = 0;
int deltaT = lastH ? h->sec - lastH->sec : h->sec;
lastH = h;
- plan_add_segment(&diveplan, deltaT, h->mm, o2, he, po2);
+ dp = plan_add_segment(&diveplan, deltaT, h->mm, o2, he, po2);
+ dp->entered = TRUE;
qDebug("time %d, depth %d", h->sec, h->mm);
}
#if DEBUG_PLAN
@@ -165,21 +166,18 @@ void DivePlannerGraphics::createDecoStops()
// }
// Create all 'deco' GraphicsLineItems and put it on the canvas.
- double lastx = handles.last()->x();
- double lasty = handles.last()->y();
+ double lastx = handles.first()->x();
+ double lasty = handles.first()->y();
for (dp = diveplan.dp; dp != NULL; dp = dp->next) {
- if (!dp->entered) {
- // these are the nodes created by the deco
- double xpos = timeLine->posAtValue(dp->time / 60.0);
- double ypos = depthLine->posAtValue(dp->depth / 1000.0);
- qDebug("time/depth %f/%f", dp->time / 60.0, dp->depth / 1000.0);
- QGraphicsLineItem *item = new QGraphicsLineItem(lastx, lasty, xpos, ypos);
- item->setPen(QPen(QBrush(Qt::red),0));
- lastx = xpos;
- lasty = ypos;
- scene()->addItem(item);
- lines << item;
- }
+ double xpos = timeLine->posAtValue(dp->time / 60.0);
+ double ypos = depthLine->posAtValue(dp->depth / 1000.0);
+ qDebug("Not entered: time/depth %f/%f", dp->time / 60.0, dp->depth / 1000.0);
+ QGraphicsLineItem *item = new QGraphicsLineItem(lastx, lasty, xpos, ypos);
+ item->setPen(QPen(QBrush(dp->entered ? Qt::black : Qt::red),0));
+ lastx = xpos;
+ lasty = ypos;
+ scene()->addItem(item);
+ lines << item;
}
}
@@ -250,7 +248,7 @@ void DivePlannerGraphics::moveActiveHandler(const QPointF& pos)
} else {
activeDraggedHandler->setPos(newPos);
}
- qqDeleteAll(lines);
+ qDeleteAll(lines);
lines.clear();
}