mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
Offer to save to a copy in replan mode
When replannig a dive, offer another button that creates a new dive rather than overwriting the old. This should help in creating several versions of a planned dive (longer/shorter, deeper/shallower etc). Note that this makes dives that start at the same time not influcence each other's deco. Also, only the first of a row of simultaneous dives contributes to the tissue loadings of later dives. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
06ddfc0122
commit
20a9db779d
5 changed files with 66 additions and 7 deletions
|
@ -347,7 +347,7 @@ double init_decompression(struct dive *dive)
|
||||||
{
|
{
|
||||||
int i, divenr = -1;
|
int i, divenr = -1;
|
||||||
unsigned int surface_time;
|
unsigned int surface_time;
|
||||||
timestamp_t when, lasttime = 0;
|
timestamp_t when, lasttime = 0, laststart = 0;
|
||||||
bool deco_init = false;
|
bool deco_init = false;
|
||||||
double tissue_tolerance, surface_pressure;
|
double tissue_tolerance, surface_pressure;
|
||||||
|
|
||||||
|
@ -370,8 +370,11 @@ double init_decompression(struct dive *dive)
|
||||||
* for how far back we need to go */
|
* for how far back we need to go */
|
||||||
if (dive->divetrip && pdive->divetrip != dive->divetrip)
|
if (dive->divetrip && pdive->divetrip != dive->divetrip)
|
||||||
continue;
|
continue;
|
||||||
if (!pdive || pdive->when > when || pdive->when + pdive->duration.seconds + 48 * 60 * 60 < when)
|
if (!pdive || pdive->when >= when || pdive->when + pdive->duration.seconds + 48 * 60 * 60 < when)
|
||||||
break;
|
break;
|
||||||
|
/* For simultaneous dives, only consider the first */
|
||||||
|
if (pdive->when == laststart)
|
||||||
|
continue;
|
||||||
when = pdive->when;
|
when = pdive->when;
|
||||||
lasttime = when + pdive->duration.seconds;
|
lasttime = when + pdive->duration.seconds;
|
||||||
}
|
}
|
||||||
|
@ -389,6 +392,7 @@ double init_decompression(struct dive *dive)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
add_dive_to_deco(pdive);
|
add_dive_to_deco(pdive);
|
||||||
|
laststart = pdive->when;
|
||||||
#if DECO_CALC_DEBUG & 2
|
#if DECO_CALC_DEBUG & 2
|
||||||
printf("added dive #%d\n", pdive->number);
|
printf("added dive #%d\n", pdive->number);
|
||||||
dump_tissues();
|
dump_tissues();
|
||||||
|
|
|
@ -300,7 +300,9 @@ DivePlannerWidget::DivePlannerWidget(QWidget *parent, Qt::WindowFlags f) : QWidg
|
||||||
connect(DivePlannerPointsModel::instance(), SIGNAL(startTimeChanged(QDateTime)), this, SLOT(setupStartTime(QDateTime)));
|
connect(DivePlannerPointsModel::instance(), SIGNAL(startTimeChanged(QDateTime)), this, SLOT(setupStartTime(QDateTime)));
|
||||||
|
|
||||||
// Creating (and canceling) the plan
|
// Creating (and canceling) the plan
|
||||||
connect(ui.buttonBox, SIGNAL(accepted()), plannerModel, SLOT(createPlan()));
|
replanButton = ui.buttonBox->addButton(tr("Save New"), QDialogButtonBox::ActionRole);
|
||||||
|
connect(replanButton, SIGNAL(clicked()), plannerModel, SLOT(saveDuplicatePlan()));
|
||||||
|
connect(ui.buttonBox, SIGNAL(accepted()), plannerModel, SLOT(savePlan()));
|
||||||
connect(ui.buttonBox, SIGNAL(rejected()), plannerModel, SLOT(cancelPlan()));
|
connect(ui.buttonBox, SIGNAL(rejected()), plannerModel, SLOT(cancelPlan()));
|
||||||
QShortcut *closeKey = new QShortcut(QKeySequence(Qt::Key_Escape), this);
|
QShortcut *closeKey = new QShortcut(QKeySequence(Qt::Key_Escape), this);
|
||||||
connect(closeKey, SIGNAL(activated()), plannerModel, SLOT(cancelPlan()));
|
connect(closeKey, SIGNAL(activated()), plannerModel, SLOT(cancelPlan()));
|
||||||
|
@ -319,6 +321,11 @@ DivePlannerWidget::DivePlannerWidget(QWidget *parent, Qt::WindowFlags f) : QWidg
|
||||||
setMinimumHeight(0);
|
setMinimumHeight(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DivePlannerWidget::setReplanButton(bool replan)
|
||||||
|
{
|
||||||
|
replanButton->setVisible(replan);
|
||||||
|
}
|
||||||
|
|
||||||
void DivePlannerWidget::setupStartTime(QDateTime startTime)
|
void DivePlannerWidget::setupStartTime(QDateTime startTime)
|
||||||
{
|
{
|
||||||
ui.startTime->setTime(startTime.time());
|
ui.startTime->setTime(startTime.time());
|
||||||
|
@ -1168,7 +1175,17 @@ void DivePlannerPointsModel::deleteTemporaryPlan()
|
||||||
free_dps(&diveplan);
|
free_dps(&diveplan);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivePlannerPointsModel::createPlan()
|
void DivePlannerPointsModel::savePlan()
|
||||||
|
{
|
||||||
|
createPlan(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivePlannerPointsModel::saveDuplicatePlan()
|
||||||
|
{
|
||||||
|
createPlan(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivePlannerPointsModel::createPlan(bool replanCopy)
|
||||||
{
|
{
|
||||||
// Ok, so, here the diveplan creates a dive
|
// Ok, so, here the diveplan creates a dive
|
||||||
char *cache = NULL;
|
char *cache = NULL;
|
||||||
|
@ -1188,6 +1205,15 @@ void DivePlannerPointsModel::createPlan()
|
||||||
displayed_dive.maxdepth.mm = 0;
|
displayed_dive.maxdepth.mm = 0;
|
||||||
displayed_dive.dc.maxdepth.mm = 0;
|
displayed_dive.dc.maxdepth.mm = 0;
|
||||||
fixup_dive(&displayed_dive);
|
fixup_dive(&displayed_dive);
|
||||||
|
if (replanCopy) {
|
||||||
|
struct dive *copy = alloc_dive();
|
||||||
|
copy_dive(current_dive, copy);
|
||||||
|
copy->id = 0;
|
||||||
|
copy->divetrip = NULL;
|
||||||
|
if (current_dive->divetrip)
|
||||||
|
add_dive_to_trip(copy, current_dive->divetrip);
|
||||||
|
record_dive(copy);
|
||||||
|
}
|
||||||
copy_dive(&displayed_dive, current_dive);
|
copy_dive(&displayed_dive, current_dive);
|
||||||
}
|
}
|
||||||
mark_divelist_changed(true);
|
mark_divelist_changed(true);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <QGraphicsPathItem>
|
#include <QGraphicsPathItem>
|
||||||
#include <QAbstractTableModel>
|
#include <QAbstractTableModel>
|
||||||
|
#include <QAbstractButton>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
||||||
#include "dive.h"
|
#include "dive.h"
|
||||||
|
@ -80,7 +81,8 @@ slots:
|
||||||
void setDisplayRuntime(bool value);
|
void setDisplayRuntime(bool value);
|
||||||
void setDisplayDuration(bool value);
|
void setDisplayDuration(bool value);
|
||||||
void setDisplayTransitions(bool value);
|
void setDisplayTransitions(bool value);
|
||||||
void createPlan();
|
void savePlan();
|
||||||
|
void saveDuplicatePlan();
|
||||||
void remove(const QModelIndex &index);
|
void remove(const QModelIndex &index);
|
||||||
void cancelPlan();
|
void cancelPlan();
|
||||||
void createTemporaryPlan();
|
void createTemporaryPlan();
|
||||||
|
@ -97,6 +99,7 @@ signals:
|
||||||
private:
|
private:
|
||||||
explicit DivePlannerPointsModel(QObject *parent = 0);
|
explicit DivePlannerPointsModel(QObject *parent = 0);
|
||||||
bool addGas(struct gasmix mix);
|
bool addGas(struct gasmix mix);
|
||||||
|
void createPlan(bool replanCopy);
|
||||||
struct diveplan diveplan;
|
struct diveplan diveplan;
|
||||||
Mode mode;
|
Mode mode;
|
||||||
bool recalc;
|
bool recalc;
|
||||||
|
@ -136,6 +139,7 @@ class DivePlannerWidget : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit DivePlannerWidget(QWidget *parent = 0, Qt::WindowFlags f = 0);
|
explicit DivePlannerWidget(QWidget *parent = 0, Qt::WindowFlags f = 0);
|
||||||
|
void setReplanButton(bool replan);
|
||||||
public
|
public
|
||||||
slots:
|
slots:
|
||||||
void setupStartTime(QDateTime startTime);
|
void setupStartTime(QDateTime startTime);
|
||||||
|
@ -146,6 +150,7 @@ slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::DivePlanner ui;
|
Ui::DivePlanner ui;
|
||||||
|
QAbstractButton *replanButton;
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "ui_plannerSettings.h"
|
#include "ui_plannerSettings.h"
|
||||||
|
|
|
@ -100,7 +100,10 @@
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"/>
|
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Planned dive time</string>
|
<string>Planned dive time</string>
|
||||||
|
@ -109,6 +112,12 @@
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="standardButtons">
|
<property name="standardButtons">
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>
|
||||||
</property>
|
</property>
|
||||||
|
@ -118,13 +127,26 @@
|
||||||
<layout class="QHBoxLayout" name="dateAndTime">
|
<layout class="QHBoxLayout" name="dateAndTime">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDateEdit" name="dateEdit">
|
<widget class="QDateEdit" name="dateEdit">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="calendarPopup">
|
<property name="calendarPopup">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTimeEdit" name="startTime"/>
|
<widget class="QTimeEdit" name="startTime">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -466,6 +466,7 @@ void MainWindow::on_actionReplanDive_triggered()
|
||||||
ui.newProfile->setPlanState();
|
ui.newProfile->setPlanState();
|
||||||
ui.newProfile->clearHandlers();
|
ui.newProfile->clearHandlers();
|
||||||
ui.infoPane->setCurrentIndex(PLANNERWIDGET);
|
ui.infoPane->setCurrentIndex(PLANNERWIDGET);
|
||||||
|
ui.divePlannerWidget->setReplanButton(true);
|
||||||
DivePlannerPointsModel::instance()->loadFromDive(current_dive);
|
DivePlannerPointsModel::instance()->loadFromDive(current_dive);
|
||||||
reset_cylinders(&displayed_dive, true);
|
reset_cylinders(&displayed_dive, true);
|
||||||
ui.diveListPane->setCurrentIndex(1); // switch to the plan output
|
ui.diveListPane->setCurrentIndex(1); // switch to the plan output
|
||||||
|
@ -491,6 +492,7 @@ void MainWindow::on_actionDivePlanner_triggered()
|
||||||
DivePlannerPointsModel::instance()->setupStartTime();
|
DivePlannerPointsModel::instance()->setupStartTime();
|
||||||
DivePlannerPointsModel::instance()->createSimpleDive();
|
DivePlannerPointsModel::instance()->createSimpleDive();
|
||||||
DivePictureModel::instance()->updateDivePictures();
|
DivePictureModel::instance()->updateDivePictures();
|
||||||
|
ui.divePlannerWidget->setReplanButton(false);
|
||||||
|
|
||||||
ui.diveListPane->setCurrentIndex(1); // switch to the plan output
|
ui.diveListPane->setCurrentIndex(1); // switch to the plan output
|
||||||
ui.globePane->setCurrentIndex(1);
|
ui.globePane->setCurrentIndex(1);
|
||||||
|
|
Loading…
Reference in a new issue