Optionally strip diveplan to bare minimum

There are new check-boxes to modify the look of the diveplan in the notes.

The old behaviour appears with "verbatim display", others are shorter,
runtimes, stoplengths and transitions being optional.  Also round to full
meters and minutes to remove optical clutter.

To be done: Remember these setting in the config.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Robert C. Helling 2014-06-02 16:25:58 +02:00 committed by Dirk Hohndel
parent cc012c1fa6
commit 90885bfb8e
6 changed files with 661 additions and 521 deletions

View file

@ -24,6 +24,7 @@ int decostoplevels[] = { 0, 3000, 6000, 9000, 12000, 15000, 18000, 21000, 24000,
180000, 190000, 200000, 220000, 240000, 260000, 280000, 300000, 180000, 190000, 200000, 220000, 240000, 260000, 280000, 300000,
320000, 340000, 360000, 380000 }; 320000, 340000, 360000, 380000 };
double plangflow, plangfhigh; double plangflow, plangfhigh;
bool plan_verbatim = false, plan_display_runtime = true, plan_display_duration = false, plan_display_transitions = false;
#if DEBUG_PLAN #if DEBUG_PLAN
void dump_plan(struct diveplan *diveplan) void dump_plan(struct diveplan *diveplan)
@ -71,6 +72,26 @@ void set_last_stop(bool last_stop_6m)
decostoplevels[1] = 3000; decostoplevels[1] = 3000;
} }
void set_verbatim(bool verbatim)
{
plan_verbatim = verbatim;
}
void set_display_runtime(bool display)
{
plan_display_runtime = display;
}
void set_display_duration(bool display)
{
plan_display_duration = display;
}
void set_display_transitions(bool display)
{
plan_display_transitions = display;
}
void get_gas_from_events(struct divecomputer *dc, int time, struct gasmix *gas) void get_gas_from_events(struct divecomputer *dc, int time, struct gasmix *gas)
{ {
// we don't modify the values passed in if nothing is found // we don't modify the values passed in if nothing is found
@ -493,6 +514,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool
int len, gasidx, lastdepth = 0, lasttime = 0; int len, gasidx, lastdepth = 0, lasttime = 0;
struct divedatapoint *dp = diveplan->dp; struct divedatapoint *dp = diveplan->dp;
const char *disclaimer = ""; const char *disclaimer = "";
bool gaschange = true;
if (!dp) if (!dp)
return; return;
@ -502,9 +524,14 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool
"ALGORITHM AND A DIVE PLANNER IMPLEMENTION BASED ON THAT WHICH HAS " "ALGORITHM AND A DIVE PLANNER IMPLEMENTION BASED ON THAT WHICH HAS "
"RECEIVED ONLY A LIMITED AMOUNT OF TESTING. WE STRONGLY RECOMMEND NOT TO " "RECEIVED ONLY A LIMITED AMOUNT OF TESTING. WE STRONGLY RECOMMEND NOT TO "
"PLAN DIVES SIMPLY BASED ON THE RESULTS GIVEN HERE."); "PLAN DIVES SIMPLY BASED ON THE RESULTS GIVEN HERE.");
snprintf(buffer, sizeof(buffer), len = snprintf(buffer, sizeof(buffer),
translate("gettextFromC", "%s\nSubsurface dive plan\nbased on GFlow = %d and GFhigh = %d\n\n"), translate("gettextFromC", "%s\nSubsurface dive plan\nbased on GFlow = %d and GFhigh = %d\n\ndepth"),
disclaimer, diveplan->gflow, diveplan->gfhigh); disclaimer, diveplan->gflow, diveplan->gfhigh);
if (plan_display_runtime)
len += snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC", " runtime"));
if (plan_display_duration)
len += snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC", " stop time"));
len += snprintf(buffer + len, sizeof(buffer) - len, " gas\n");
do { do {
struct gasmix gasmix, newgasmix; struct gasmix gasmix, newgasmix;
const char *depth_unit; const char *depth_unit;
@ -534,28 +561,59 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool
continue; continue;
gasidx = get_gasidx(dive, &gasmix); gasidx = get_gasidx(dive, &gasmix);
len = strlen(buffer); len = strlen(buffer);
if (dp->depth != lastdepth) if (dp->depth != lastdepth) {
if (plan_display_transitions)
snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC", "Transition to %.*f %s in %d:%02d min - runtime %d:%02u on %s\n"), snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC", "Transition to %.*f %s in %d:%02d min - runtime %d:%02u on %s\n"),
decimals, depthvalue, depth_unit, decimals, depthvalue, depth_unit,
FRACTION(dp->time - lasttime, 60), FRACTION(dp->time - lasttime, 60),
FRACTION(dp->time, 60), FRACTION(dp->time, 60),
gasname(&gasmix)); gasname(&gasmix));
else else
if (dp->entered) {
len += snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC", "%3.0f%s"), depthvalue, depth_unit);
if (plan_display_runtime)
len += snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC", " %3dmin "), (dp->time + 30) / 60);
if (plan_display_duration)
len += snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC", " %3dmin "), (dp->time - lasttime + 30) / 60);
if (gaschange) {
len += snprintf(buffer + len, sizeof(buffer) - len, " %s", gasname(&newgasmix));
gaschange = false;
}
len += snprintf(buffer + len, sizeof(buffer) - len, "\n");
}
} else {
if (plan_verbatim) {
snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC", "Stay at %.*f %s for %d:%02d min - runtime %d:%02u on %s\n"), snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC", "Stay at %.*f %s for %d:%02d min - runtime %d:%02u on %s\n"),
decimals, depthvalue, depth_unit, decimals, depthvalue, depth_unit,
FRACTION(dp->time - lasttime, 60), FRACTION(dp->time - lasttime, 60),
FRACTION(dp->time, 60), FRACTION(dp->time, 60),
gasname(&gasmix)); gasname(&gasmix));
} else {
len += snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC", "%3.0f%s"), depthvalue, depth_unit);
if (plan_display_runtime)
len += snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC", " %3dmin "), (dp->time + 30) / 60);
if (plan_display_duration)
len += snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC", " %3dmin "), (dp->time - lasttime + 30) / 60);
if (gaschange) {
len += snprintf(buffer + len, sizeof(buffer) - len, " %s", gasname(&newgasmix));
gaschange = false;
}
len += snprintf(buffer + len, sizeof(buffer) - len, "\n");
}
}
if (nextdp && gasmix_distance(&gasmix, &newgasmix)) { if (nextdp && gasmix_distance(&gasmix, &newgasmix)) {
// gas switch at this waypoint // gas switch at this waypoint
if (plan_verbatim)
snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC", "Switch gas to %s\n"), gasname(&newgasmix)); snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC", "Switch gas to %s\n"), gasname(&newgasmix));
else
gaschange = true;
gasmix = newgasmix; gasmix = newgasmix;
} }
lasttime = dp->time; lasttime = dp->time;
lastdepth = dp->depth; lastdepth = dp->depth;
} while ((dp = dp->next) != NULL); } while ((dp = dp->next) != NULL);
len = strlen(buffer); len = strlen(buffer);
snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC", "Gas consumption:\n")); snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC", "\nGas consumption:\n"));
for (gasidx = 0; gasidx < MAX_CYLINDERS; gasidx++) { for (gasidx = 0; gasidx < MAX_CYLINDERS; gasidx++) {
double volume; double volume;
const char *unit; const char *unit;

View file

@ -11,6 +11,10 @@ extern int validate_po2(const char *text, int *mbar_po2);
extern timestamp_t current_time_notz(void); extern timestamp_t current_time_notz(void);
extern void show_planned_dive(char **error_string_p); extern void show_planned_dive(char **error_string_p);
extern void set_last_stop(bool last_stop_6m); extern void set_last_stop(bool last_stop_6m);
extern void set_verbatim(bool verbatim);
extern void set_display_runtime(bool display);
extern void set_display_duration(bool display);
extern void set_display_transitions(bool display);
extern void get_gas_from_events(struct divecomputer *dc, int time, struct gasmix *gas); extern void get_gas_from_events(struct divecomputer *dc, int time, struct gasmix *gas);
extern int get_gasidx(struct dive *dive, struct gasmix *mix); extern int get_gasidx(struct dive *dive, struct gasmix *mix);
extern bool diveplan_empty(struct diveplan *diveplan); extern bool diveplan_empty(struct diveplan *diveplan);

View file

@ -273,6 +273,10 @@ DivePlannerWidget::DivePlannerWidget(QWidget *parent, Qt::WindowFlags f) : QWidg
connect(ui.gfhigh, SIGNAL(valueChanged(int)), plannerModel, SLOT(setGFHigh(int))); connect(ui.gfhigh, SIGNAL(valueChanged(int)), plannerModel, SLOT(setGFHigh(int)));
connect(ui.gflow, SIGNAL(valueChanged(int)), plannerModel, SLOT(setGFLow(int))); connect(ui.gflow, SIGNAL(valueChanged(int)), plannerModel, SLOT(setGFLow(int)));
connect(ui.lastStop, SIGNAL(toggled(bool)), plannerModel, SLOT(setLastStop6m(bool))); connect(ui.lastStop, SIGNAL(toggled(bool)), plannerModel, SLOT(setLastStop6m(bool)));
connect(ui.verbatim_plan, SIGNAL(toggled(bool)), plannerModel, SLOT(setVerbatim(bool)));
connect(ui.display_duration, SIGNAL(toggled(bool)), plannerModel, SLOT(setDisplayDuration(bool)));
connect(ui.display_runtime, SIGNAL(toggled(bool)), plannerModel, SLOT(setDisplayRuntime(bool)));
connect(ui.display_transitions, SIGNAL(toggled(bool)), plannerModel, SLOT(setDisplayTransitions(bool)));
// Creating (and canceling) the plan // Creating (and canceling) the plan
connect(ui.buttonBox, SIGNAL(accepted()), plannerModel, SLOT(createPlan())); connect(ui.buttonBox, SIGNAL(accepted()), plannerModel, SLOT(createPlan()));
@ -505,6 +509,30 @@ void DivePlannerPointsModel::setLastStop6m(bool value)
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1)); emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1));
} }
void DivePlannerPointsModel::setVerbatim(bool value)
{
set_verbatim(value);
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1));
}
void DivePlannerPointsModel::setDisplayRuntime(bool value)
{
set_display_runtime(value);
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1));
}
void DivePlannerPointsModel::setDisplayDuration(bool value)
{
set_display_duration(value);
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1));
}
void DivePlannerPointsModel::setDisplayTransitions(bool value)
{
set_display_transitions(value);
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1));
}
void DivePlannerPointsModel::setStartTime(const QTime &t) void DivePlannerPointsModel::setStartTime(const QTime &t)
{ {
diveplan.when = (t.msec() + QDateTime::currentMSecsSinceEpoch()) / 1000 - gettimezoneoffset(); diveplan.when = (t.msec() + QDateTime::currentMSecsSinceEpoch()) / 1000 - gettimezoneoffset();

View file

@ -73,6 +73,10 @@ slots:
void setDecoSac(int sac); void setDecoSac(int sac);
void setStartTime(const QTime &t); void setStartTime(const QTime &t);
void setLastStop6m(bool value); void setLastStop6m(bool value);
void setVerbatim(bool value);
void setDisplayRuntime(bool value);
void setDisplayDuration(bool value);
void setDisplayTransitions(bool value);
void createPlan(); void createPlan();
void remove(const QModelIndex &index); void remove(const QModelIndex &index);
void cancelPlan(); void cancelPlan();

View file

@ -62,87 +62,7 @@
<property name="spacing"> <property name="spacing">
<number>2</number> <number>2</number>
</property> </property>
<item row="1" column="1"> <item row="10" column="0" colspan="2">
<widget class="QLineEdit" name="ATMPressure"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Bottom SAC</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="label_6">
<property name="text">
<string>GFHigh</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_4">
<property name="text">
<string>SAC on DECO Stop</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLineEdit" name="bottomSAC"/>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="decoStopSAC"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>GFLow</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QSpinBox" name="gflow">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>150</number>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QSpinBox" name="gfhigh">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>150</number>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="lastStop">
<property name="text">
<string>Last Stop at 6m</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<widget class="TableView" name="cylinderTableWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<widget class="TableView" name="tableWidget" native="true"> <widget class="TableView" name="tableWidget" native="true">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
@ -159,14 +79,33 @@
</widget> </widget>
</item> </item>
<item row="9" column="0" colspan="2"> <item row="9" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="TableView" name="cylinderTableWidget" native="true">
<property name="standardButtons"> <property name="sizePolicy">
<set>QDialogButtonBox::Abort|QDialogButtonBox::Save</set> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>50</height>
</size>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="3" column="1">
<widget class="QTimeEdit" name="startTime"/> <widget class="QLineEdit" name="decoStopSAC"/>
</item>
<item row="5" column="0">
<widget class="QSpinBox" name="gflow">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>150</number>
</property>
</widget>
</item> </item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
@ -175,6 +114,71 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>GFLow</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QTimeEdit" name="startTime"/>
</item>
<item row="11" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Abort|QDialogButtonBox::Save</set>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="lastStop">
<property name="text">
<string>Last Stop at 6m</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLineEdit" name="bottomSAC"/>
</item>
<item row="5" column="1">
<widget class="QSpinBox" name="gfhigh">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>150</number>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QCheckBox" name="verbatim_plan">
<property name="text">
<string>verbatim diveplan</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_4">
<property name="text">
<string>SAC on DECO Stop</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Bottom SAC</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="label_6">
<property name="text">
<string>GFHigh</string>
</property>
</widget>
</item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
@ -182,6 +186,42 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1">
<widget class="QLineEdit" name="ATMPressure"/>
</item>
<item row="7" column="1">
<widget class="QCheckBox" name="display_duration">
<property name="toolTip">
<string>In dive plan, show duration (relative time) of stops</string>
</property>
<property name="text">
<string>display stop duration</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="display_runtime">
<property name="toolTip">
<string>In dive plan, show runtime (absolute time) of stops</string>
</property>
<property name="text">
<string>display runtime</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="display_transitions">
<property name="toolTip">
<string>In diveplan, list transitions or treat them as implicit</string>
</property>
<property name="text">
<string>display transitions</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</widget> </widget>

View file

@ -497,7 +497,7 @@
</property> </property>
<widget class="QStackedWidget" name="diveListPane"> <widget class="QStackedWidget" name="diveListPane">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>1</number>
</property> </property>
<widget class="DiveListView" name="ListWidget"> <widget class="DiveListView" name="ListWidget">
<property name="alternatingRowColors"> <property name="alternatingRowColors">
@ -544,7 +544,18 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QTextEdit" name="divePlanOutput" native="true"/> <widget class="QTextEdit" name="divePlanOutput">
<property name="styleSheet">
<string notr="true">font: 13pt &quot;Courier&quot;;</string>
</property>
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Courier'; font-size:13pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'.Curier New';&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>
@ -570,7 +581,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1418</width> <width>1418</width>
<height>20</height> <height>22</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile"> <widget class="QMenu" name="menuFile">
@ -971,11 +982,6 @@
<header>globe.h</header> <header>globe.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget>
<class>DivePlannerGraphics</class>
<extends>QGraphicsView</extends>
<header>diveplanner.h</header>
</customwidget>
<customwidget> <customwidget>
<class>DivePlannerWidget</class> <class>DivePlannerWidget</class>
<extends>QWidget</extends> <extends>QWidget</extends>