mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Distinguish between entered and calculated waypoints
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
7902af246c
commit
30bdfc8160
5 changed files with 23 additions and 16 deletions
2
dive.h
2
dive.h
|
@ -811,7 +811,7 @@ struct diveplan {
|
||||||
struct divedatapoint *dp;
|
struct divedatapoint *dp;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct divedatapoint *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, bool entered);
|
||||||
void get_gas_string(int o2, int he, char *buf, int len);
|
void get_gas_string(int o2, int he, char *buf, int len);
|
||||||
struct divedatapoint *create_dp(int time_incr, int depth, int o2, int he, int po2);
|
struct divedatapoint *create_dp(int time_incr, int depth, int o2, int he, int po2);
|
||||||
void dump_plan(struct diveplan *diveplan);
|
void dump_plan(struct diveplan *diveplan);
|
||||||
|
|
11
planner.c
11
planner.c
|
@ -382,9 +382,10 @@ void add_to_end_of_diveplan(struct diveplan *diveplan, struct divedatapoint *dp)
|
||||||
dp->time += lasttime;
|
dp->time += lasttime;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct divedatapoint *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, bool entered)
|
||||||
{
|
{
|
||||||
struct divedatapoint *dp = create_dp(duration, depth, o2, he, po2);
|
struct divedatapoint *dp = create_dp(duration, depth, o2, he, po2);
|
||||||
|
dp->entered = entered;
|
||||||
add_to_end_of_diveplan(diveplan, dp);
|
add_to_end_of_diveplan(diveplan, dp);
|
||||||
return (dp);
|
return (dp);
|
||||||
}
|
}
|
||||||
|
@ -620,7 +621,7 @@ void plan(struct diveplan *diveplan, char **cached_datap, struct dive **divep, b
|
||||||
/* if all we wanted was the dive just get us back to the surface */
|
/* if all we wanted was the dive just get us back to the surface */
|
||||||
if (!add_deco) {
|
if (!add_deco) {
|
||||||
transitiontime = depth / 75; /* this still needs to be made configurable */
|
transitiontime = depth / 75; /* this still needs to be made configurable */
|
||||||
plan_add_segment(diveplan, transitiontime, 0, o2, he, po2);
|
plan_add_segment(diveplan, transitiontime, 0, o2, he, po2, false);
|
||||||
/* re-create the dive */
|
/* re-create the dive */
|
||||||
delete_single_dive(dive_table.nr - 1);
|
delete_single_dive(dive_table.nr - 1);
|
||||||
*divep = dive = create_dive_from_plan(diveplan, error_string_p);
|
*divep = dive = create_dive_from_plan(diveplan, error_string_p);
|
||||||
|
@ -662,7 +663,7 @@ void plan(struct diveplan *diveplan, char **cached_datap, struct dive **divep, b
|
||||||
#if DEBUG_PLAN & 2
|
#if DEBUG_PLAN & 2
|
||||||
printf("transitiontime %d:%02d to depth %5.2lfm\n", FRACTION(transitiontime, 60), stoplevels[stopidx] / 1000.0);
|
printf("transitiontime %d:%02d to depth %5.2lfm\n", FRACTION(transitiontime, 60), stoplevels[stopidx] / 1000.0);
|
||||||
#endif
|
#endif
|
||||||
plan_add_segment(diveplan, transitiontime, stoplevels[stopidx], o2, he, po2);
|
plan_add_segment(diveplan, transitiontime, stoplevels[stopidx], o2, he, po2, false);
|
||||||
/* re-create the dive */
|
/* re-create the dive */
|
||||||
delete_single_dive(dive_table.nr - 1);
|
delete_single_dive(dive_table.nr - 1);
|
||||||
*divep = dive = create_dive_from_plan(diveplan, error_string_p);
|
*divep = dive = create_dive_from_plan(diveplan, error_string_p);
|
||||||
|
@ -697,13 +698,13 @@ void plan(struct diveplan *diveplan, char **cached_datap, struct dive **divep, b
|
||||||
stoplevels[stopidx] / 1000.0, ceiling / 1000.0);
|
stoplevels[stopidx] / 1000.0, ceiling / 1000.0);
|
||||||
#endif
|
#endif
|
||||||
if (wait_time)
|
if (wait_time)
|
||||||
plan_add_segment(diveplan, wait_time, stoplevels[stopidx], o2, he, po2);
|
plan_add_segment(diveplan, wait_time, stoplevels[stopidx], o2, he, po2, false);
|
||||||
/* right now all the transitions are at 30ft/min - this needs to be configurable */
|
/* right now all the transitions are at 30ft/min - this needs to be configurable */
|
||||||
transitiontime = (stoplevels[stopidx] - stoplevels[stopidx - 1]) / 150;
|
transitiontime = (stoplevels[stopidx] - stoplevels[stopidx - 1]) / 150;
|
||||||
#if DEBUG_PLAN & 2
|
#if DEBUG_PLAN & 2
|
||||||
printf("transitiontime %d:%02d to depth %5.2lfm\n", FRACTION(transitiontime, 60), stoplevels[stopidx - 1] / 1000.0);
|
printf("transitiontime %d:%02d to depth %5.2lfm\n", FRACTION(transitiontime, 60), stoplevels[stopidx - 1] / 1000.0);
|
||||||
#endif
|
#endif
|
||||||
plan_add_segment(diveplan, transitiontime, stoplevels[stopidx - 1], o2, he, po2);
|
plan_add_segment(diveplan, transitiontime, stoplevels[stopidx - 1], o2, he, po2, false);
|
||||||
/* re-create the dive */
|
/* re-create the dive */
|
||||||
delete_single_dive(dive_table.nr - 1);
|
delete_single_dive(dive_table.nr - 1);
|
||||||
*divep = dive = create_dive_from_plan(diveplan, error_string_p);
|
*divep = dive = create_dive_from_plan(diveplan, error_string_p);
|
||||||
|
|
|
@ -392,16 +392,16 @@ void DivePlannerGraphics::mouseDoubleClickEvent(QMouseEvent *event)
|
||||||
|
|
||||||
int minutes = rint(timeLine->valueAt(mappedPos));
|
int minutes = rint(timeLine->valueAt(mappedPos));
|
||||||
int milimeters = rint(depthLine->valueAt(mappedPos) / M_OR_FT(1, 1)) * M_OR_FT(1, 1);
|
int milimeters = rint(depthLine->valueAt(mappedPos) / M_OR_FT(1, 1)) * M_OR_FT(1, 1);
|
||||||
plannerModel->addStop(milimeters, minutes * 60, -1, 0, 0);
|
plannerModel->addStop(milimeters, minutes * 60, -1, 0, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivePlannerPointsModel::createSimpleDive()
|
void DivePlannerPointsModel::createSimpleDive()
|
||||||
{
|
{
|
||||||
// plannerModel->addStop(0, 0, O2_IN_AIR, 0, 0);
|
// plannerModel->addStop(0, 0, O2_IN_AIR, 0, 0);
|
||||||
plannerModel->addStop(M_OR_FT(15, 45), 1 * 60, O2_IN_AIR, 0, 0);
|
plannerModel->addStop(M_OR_FT(15, 45), 1 * 60, O2_IN_AIR, 0, 0, true);
|
||||||
plannerModel->addStop(M_OR_FT(15, 45), 40 * 60, O2_IN_AIR, 0, 0);
|
plannerModel->addStop(M_OR_FT(15, 45), 40 * 60, O2_IN_AIR, 0, 0, true);
|
||||||
plannerModel->addStop(M_OR_FT(5, 15), 42 * 60, O2_IN_AIR, 0, 0);
|
plannerModel->addStop(M_OR_FT(5, 15), 42 * 60, O2_IN_AIR, 0, 0, true);
|
||||||
plannerModel->addStop(M_OR_FT(5, 15), 45 * 60, O2_IN_AIR, 0, 0);
|
plannerModel->addStop(M_OR_FT(5, 15), 45 * 60, O2_IN_AIR, 0, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivePlannerPointsModel::loadFromDive(dive *d)
|
void DivePlannerPointsModel::loadFromDive(dive *d)
|
||||||
|
@ -422,7 +422,7 @@ void DivePlannerPointsModel::loadFromDive(dive *d)
|
||||||
if (s.time.seconds == 0)
|
if (s.time.seconds == 0)
|
||||||
continue;
|
continue;
|
||||||
get_gas_from_events(&backupDive.dc, lasttime, &o2, &he);
|
get_gas_from_events(&backupDive.dc, lasttime, &o2, &he);
|
||||||
plannerModel->addStop(s.depth.mm, s.time.seconds, o2, he, 0);
|
plannerModel->addStop(s.depth.mm, s.time.seconds, o2, he, 0, true);
|
||||||
lasttime = s.time.seconds;
|
lasttime = s.time.seconds;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -521,12 +521,16 @@ void DivePlannerGraphics::drawProfile()
|
||||||
item->setPen(QPen(QBrush(Qt::red), 0));
|
item->setPen(QPen(QBrush(Qt::red), 0));
|
||||||
scene()->addItem(item);
|
scene()->addItem(item);
|
||||||
lines << item;
|
lines << item;
|
||||||
|
if (dp->depth)
|
||||||
|
qDebug() << "Time: " << dp->time / 60 << " depth: " << dp->depth / 1000;
|
||||||
}
|
}
|
||||||
lastx = xpos;
|
lastx = xpos;
|
||||||
lasty = ypos;
|
lasty = ypos;
|
||||||
poly.append(QPointF(lastx, lasty));
|
poly.append(QPointF(lastx, lasty));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qDebug() << " ";
|
||||||
|
|
||||||
diveBg->setPolygon(poly);
|
diveBg->setPolygon(poly);
|
||||||
QRectF b = poly.boundingRect();
|
QRectF b = poly.boundingRect();
|
||||||
QLinearGradient pat(
|
QLinearGradient pat(
|
||||||
|
@ -1186,7 +1190,7 @@ bool DivePlannerPointsModel::addGas(int o2, int he)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DivePlannerPointsModel::addStop(int milimeters, int seconds, int o2, int he, int ccpoint)
|
int DivePlannerPointsModel::addStop(int milimeters, int seconds, int o2, int he, int ccpoint, bool entered)
|
||||||
{
|
{
|
||||||
int row = divepoints.count();
|
int row = divepoints.count();
|
||||||
if (seconds == 0 && milimeters == 0 && row != 0) {
|
if (seconds == 0 && milimeters == 0 && row != 0) {
|
||||||
|
@ -1253,6 +1257,7 @@ int DivePlannerPointsModel::addStop(int milimeters, int seconds, int o2, int he,
|
||||||
point.o2 = o2;
|
point.o2 = o2;
|
||||||
point.he = he;
|
point.he = he;
|
||||||
point.po2 = ccpoint;
|
point.po2 = ccpoint;
|
||||||
|
point.entered = entered;
|
||||||
divepoints.append(point);
|
divepoints.append(point);
|
||||||
std::sort(divepoints.begin(), divepoints.end(), divePointsLessThan);
|
std::sort(divepoints.begin(), divepoints.end(), divePointsLessThan);
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
|
@ -1410,7 +1415,8 @@ void DivePlannerPointsModel::createTemporaryPlan()
|
||||||
divedatapoint p = at(i);
|
divedatapoint p = at(i);
|
||||||
int deltaT = lastIndex != -1 ? p.time - at(lastIndex).time : p.time;
|
int deltaT = lastIndex != -1 ? p.time - at(lastIndex).time : p.time;
|
||||||
lastIndex = i;
|
lastIndex = i;
|
||||||
plan_add_segment(&diveplan, deltaT, p.depth, p.o2, p.he, p.po2);
|
p.entered = true;
|
||||||
|
plan_add_segment(&diveplan, deltaT, p.depth, p.o2, p.he, p.po2, true);
|
||||||
}
|
}
|
||||||
char *cache = NULL;
|
char *cache = NULL;
|
||||||
tempDive = NULL;
|
tempDive = NULL;
|
||||||
|
|
|
@ -57,7 +57,7 @@ public:
|
||||||
|
|
||||||
public
|
public
|
||||||
slots:
|
slots:
|
||||||
int addStop(int millimeters = 0, int seconds = 0, int o2 = 0, int he = 0, int ccpoint = 0);
|
int addStop(int millimeters = 0, int seconds = 0, int o2 = 0, int he = 0, int ccpoint = 0, bool entered = true);
|
||||||
void addCylinder_clicked();
|
void addCylinder_clicked();
|
||||||
void setGFHigh(const int gfhigh);
|
void setGFHigh(const int gfhigh);
|
||||||
void setGFLow(const int ghflow);
|
void setGFLow(const int ghflow);
|
||||||
|
|
|
@ -78,7 +78,7 @@ MainWindow::MainWindow() : QMainWindow(),
|
||||||
ui.divePlannerWidget->settingsChanged();
|
ui.divePlannerWidget->settingsChanged();
|
||||||
|
|
||||||
#ifndef ENABLE_PLANNER
|
#ifndef ENABLE_PLANNER
|
||||||
ui.menuLog->removeAction(ui.actionDivePlanner);
|
// ui.menuLog->removeAction(ui.actionDivePlanner);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue