diff options
-rw-r--r-- | dive.h | 2 | ||||
-rw-r--r-- | planner.c | 11 | ||||
-rw-r--r-- | qt-ui/diveplanner.cpp | 22 | ||||
-rw-r--r-- | qt-ui/diveplanner.h | 2 | ||||
-rw-r--r-- | qt-ui/mainwindow.cpp | 2 |
5 files changed, 23 insertions, 16 deletions
@@ -811,7 +811,7 @@ struct diveplan { 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); struct divedatapoint *create_dp(int time_incr, int depth, int o2, int he, int po2); void dump_plan(struct diveplan *diveplan); @@ -382,9 +382,10 @@ void add_to_end_of_diveplan(struct diveplan *diveplan, struct divedatapoint *dp) 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); + dp->entered = entered; add_to_end_of_diveplan(diveplan, 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 (!add_deco) { 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 */ delete_single_dive(dive_table.nr - 1); *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 printf("transitiontime %d:%02d to depth %5.2lfm\n", FRACTION(transitiontime, 60), stoplevels[stopidx] / 1000.0); #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 */ delete_single_dive(dive_table.nr - 1); *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); #endif 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 */ transitiontime = (stoplevels[stopidx] - stoplevels[stopidx - 1]) / 150; #if DEBUG_PLAN & 2 printf("transitiontime %d:%02d to depth %5.2lfm\n", FRACTION(transitiontime, 60), stoplevels[stopidx - 1] / 1000.0); #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 */ delete_single_dive(dive_table.nr - 1); *divep = dive = create_dive_from_plan(diveplan, error_string_p); diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index c5715f9df..03b1a2043 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -392,16 +392,16 @@ void DivePlannerGraphics::mouseDoubleClickEvent(QMouseEvent *event) int minutes = rint(timeLine->valueAt(mappedPos)); 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() { // 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), 40 * 60, O2_IN_AIR, 0, 0); - plannerModel->addStop(M_OR_FT(5, 15), 42 * 60, O2_IN_AIR, 0, 0); - plannerModel->addStop(M_OR_FT(5, 15), 45 * 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, true); + 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, true); } void DivePlannerPointsModel::loadFromDive(dive *d) @@ -422,7 +422,7 @@ void DivePlannerPointsModel::loadFromDive(dive *d) if (s.time.seconds == 0) continue; 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; } } @@ -521,12 +521,16 @@ void DivePlannerGraphics::drawProfile() item->setPen(QPen(QBrush(Qt::red), 0)); scene()->addItem(item); lines << item; + if (dp->depth) + qDebug() << "Time: " << dp->time / 60 << " depth: " << dp->depth / 1000; } lastx = xpos; lasty = ypos; poly.append(QPointF(lastx, lasty)); } + qDebug() << " "; + diveBg->setPolygon(poly); QRectF b = poly.boundingRect(); QLinearGradient pat( @@ -1186,7 +1190,7 @@ bool DivePlannerPointsModel::addGas(int o2, int he) 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(); 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.he = he; point.po2 = ccpoint; + point.entered = entered; divepoints.append(point); std::sort(divepoints.begin(), divepoints.end(), divePointsLessThan); endInsertRows(); @@ -1410,7 +1415,8 @@ void DivePlannerPointsModel::createTemporaryPlan() divedatapoint p = at(i); int deltaT = lastIndex != -1 ? p.time - at(lastIndex).time : p.time; 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; tempDive = NULL; diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h index 4679d0660..1393d9f78 100644 --- a/qt-ui/diveplanner.h +++ b/qt-ui/diveplanner.h @@ -57,7 +57,7 @@ public: public 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 setGFHigh(const int gfhigh); void setGFLow(const int ghflow); diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 4d4d0baa2..a6a6c14cf 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -78,7 +78,7 @@ MainWindow::MainWindow() : QMainWindow(), ui.divePlannerWidget->settingsChanged(); #ifndef ENABLE_PLANNER - ui.menuLog->removeAction(ui.actionDivePlanner); +// ui.menuLog->removeAction(ui.actionDivePlanner); #endif } |