mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
1ec8bc5de0
commit
8eb2dc3d65
3 changed files with 17 additions and 18 deletions
2
dive.h
2
dive.h
|
@ -718,7 +718,7 @@ struct diveplan {
|
||||||
struct divedatapoint *dp;
|
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_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 add_gas_to_nth_dp(struct diveplan *diveplan, int idx, int o2, int he);
|
||||||
void free_dps(struct divedatapoint *dp);
|
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;
|
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);
|
struct divedatapoint *dp = create_dp(duration, depth, o2, he, po2);
|
||||||
add_to_end_of_diveplan(diveplan, dp);
|
add_to_end_of_diveplan(diveplan, dp);
|
||||||
|
return(dp);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct gaschanges {
|
struct gaschanges {
|
||||||
|
|
|
@ -118,7 +118,8 @@ void DivePlannerGraphics::createDecoStops()
|
||||||
int po2 = 0;
|
int po2 = 0;
|
||||||
int deltaT = lastH ? h->sec - lastH->sec : h->sec;
|
int deltaT = lastH ? h->sec - lastH->sec : h->sec;
|
||||||
lastH = h;
|
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);
|
qDebug("time %d, depth %d", h->sec, h->mm);
|
||||||
}
|
}
|
||||||
#if DEBUG_PLAN
|
#if DEBUG_PLAN
|
||||||
|
@ -165,21 +166,18 @@ void DivePlannerGraphics::createDecoStops()
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// Create all 'deco' GraphicsLineItems and put it on the canvas.
|
// Create all 'deco' GraphicsLineItems and put it on the canvas.
|
||||||
double lastx = handles.last()->x();
|
double lastx = handles.first()->x();
|
||||||
double lasty = handles.last()->y();
|
double lasty = handles.first()->y();
|
||||||
for (dp = diveplan.dp; dp != NULL; dp = dp->next) {
|
for (dp = diveplan.dp; dp != NULL; dp = dp->next) {
|
||||||
if (!dp->entered) {
|
double xpos = timeLine->posAtValue(dp->time / 60.0);
|
||||||
// these are the nodes created by the deco
|
double ypos = depthLine->posAtValue(dp->depth / 1000.0);
|
||||||
double xpos = timeLine->posAtValue(dp->time / 60.0);
|
qDebug("Not entered: time/depth %f/%f", dp->time / 60.0, dp->depth / 1000.0);
|
||||||
double ypos = depthLine->posAtValue(dp->depth / 1000.0);
|
QGraphicsLineItem *item = new QGraphicsLineItem(lastx, lasty, xpos, ypos);
|
||||||
qDebug("time/depth %f/%f", dp->time / 60.0, dp->depth / 1000.0);
|
item->setPen(QPen(QBrush(dp->entered ? Qt::black : Qt::red),0));
|
||||||
QGraphicsLineItem *item = new QGraphicsLineItem(lastx, lasty, xpos, ypos);
|
lastx = xpos;
|
||||||
item->setPen(QPen(QBrush(Qt::red),0));
|
lasty = ypos;
|
||||||
lastx = xpos;
|
scene()->addItem(item);
|
||||||
lasty = ypos;
|
lines << item;
|
||||||
scene()->addItem(item);
|
|
||||||
lines << item;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,7 +248,7 @@ void DivePlannerGraphics::moveActiveHandler(const QPointF& pos)
|
||||||
} else {
|
} else {
|
||||||
activeDraggedHandler->setPos(newPos);
|
activeDraggedHandler->setPos(newPos);
|
||||||
}
|
}
|
||||||
qqDeleteAll(lines);
|
qDeleteAll(lines);
|
||||||
lines.clear();
|
lines.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue