diff options
-rw-r--r-- | dive.h | 2 | ||||
-rw-r--r-- | planner.c | 3 | ||||
-rw-r--r-- | qt-ui/diveplanner.cpp | 30 |
3 files changed, 17 insertions, 18 deletions
@@ -718,7 +718,7 @@ struct diveplan { struct divedatapoint *dp; }; -void plan_add_segment(struct diveplan *diveplan, int duration, int depth, int o2, int he, int po2); +struct divedatapoint *plan_add_segment(struct diveplan *diveplan, int duration, int depth, int o2, int he, int po2); void add_depth_to_nth_dp(struct diveplan *diveplan, int idx, int depth); void add_gas_to_nth_dp(struct diveplan *diveplan, int idx, int o2, int he); void free_dps(struct divedatapoint *dp); @@ -391,10 +391,11 @@ void add_to_end_of_diveplan(struct diveplan *diveplan, struct divedatapoint *dp) dp->time += lasttime; } -void plan_add_segment(struct diveplan *diveplan, int duration, int depth, int o2, int he, int po2) +struct divedatapoint * plan_add_segment(struct diveplan *diveplan, int duration, int depth, int o2, int he, int po2) { struct divedatapoint *dp = create_dp(duration, depth, o2, he, po2); add_to_end_of_diveplan(diveplan, dp); + return(dp); } struct gaschanges { 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(); } |