mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Add a checkbox to turn off plan variations
... as those come with a performance penalty Signed-off-by: Robert C. Helling <helling@atdotde.de>
This commit is contained in:
parent
5e9bdce195
commit
a6f186279f
10 changed files with 117 additions and 59 deletions
|
@ -101,8 +101,13 @@ void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_d
|
||||||
get_current_date());
|
get_current_date());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (prefs.display_variations)
|
||||||
len += snprintf(buffer + len, sz_buffer - len, translate("gettextFromC", "Runtime: %dmin VARIATIONS<br></div>"),
|
len += snprintf(buffer + len, sz_buffer - len, translate("gettextFromC", "Runtime: %dmin VARIATIONS<br></div>"),
|
||||||
diveplan_duration(diveplan));
|
diveplan_duration(diveplan));
|
||||||
|
else
|
||||||
|
len += snprintf(buffer + len, sz_buffer - len, translate("gettextFromC", "Runtime: %dmin<br></div>"),
|
||||||
|
diveplan_duration(diveplan));
|
||||||
|
|
||||||
|
|
||||||
if (!plan_verbatim) {
|
if (!plan_verbatim) {
|
||||||
len += snprintf(buffer + len, sz_buffer - len, "<table><thead><tr><th></th><th>%s</th>",
|
len += snprintf(buffer + len, sz_buffer - len, "<table><thead><tr><th></th><th>%s</th>",
|
||||||
|
|
|
@ -126,6 +126,7 @@ struct preferences {
|
||||||
bool display_runtime;
|
bool display_runtime;
|
||||||
bool display_duration;
|
bool display_duration;
|
||||||
bool display_transitions;
|
bool display_transitions;
|
||||||
|
bool display_variations;
|
||||||
bool safetystop;
|
bool safetystop;
|
||||||
bool switch_at_req_stop;
|
bool switch_at_req_stop;
|
||||||
int reserve_gas;
|
int reserve_gas;
|
||||||
|
|
|
@ -1214,6 +1214,11 @@ bool DivePlannerSettings::displayTransitions() const
|
||||||
return prefs.display_transitions;
|
return prefs.display_transitions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DivePlannerSettings::displayVariations() const
|
||||||
|
{
|
||||||
|
return prefs.display_variations;
|
||||||
|
}
|
||||||
|
|
||||||
bool DivePlannerSettings::doo2breaks() const
|
bool DivePlannerSettings::doo2breaks() const
|
||||||
{
|
{
|
||||||
return prefs.doo2breaks;
|
return prefs.doo2breaks;
|
||||||
|
@ -1368,6 +1373,18 @@ void DivePlannerSettings::setDisplayTransitions(bool value)
|
||||||
emit displayTransitionsChanged(value);
|
emit displayTransitionsChanged(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DivePlannerSettings::setDisplayVariations(bool value)
|
||||||
|
{
|
||||||
|
if (value == prefs.display_variations)
|
||||||
|
return;
|
||||||
|
|
||||||
|
QSettings s;
|
||||||
|
s.beginGroup(group);
|
||||||
|
s.setValue("display_variations", value);
|
||||||
|
prefs.display_variations = value;
|
||||||
|
emit displayVariationsChanged(value);
|
||||||
|
}
|
||||||
|
|
||||||
void DivePlannerSettings::setDoo2breaks(bool value)
|
void DivePlannerSettings::setDoo2breaks(bool value)
|
||||||
{
|
{
|
||||||
if (value == prefs.doo2breaks)
|
if (value == prefs.doo2breaks)
|
||||||
|
@ -2339,6 +2356,7 @@ void SettingsObjectWrapper::load()
|
||||||
GET_BOOL("display_duration", display_duration);
|
GET_BOOL("display_duration", display_duration);
|
||||||
GET_BOOL("display_runtime", display_runtime);
|
GET_BOOL("display_runtime", display_runtime);
|
||||||
GET_BOOL("display_transitions", display_transitions);
|
GET_BOOL("display_transitions", display_transitions);
|
||||||
|
GET_BOOL("display_variations", display_variations);
|
||||||
GET_BOOL("safetystop", safetystop);
|
GET_BOOL("safetystop", safetystop);
|
||||||
GET_BOOL("doo2breaks", doo2breaks);
|
GET_BOOL("doo2breaks", doo2breaks);
|
||||||
GET_BOOL("switch_at_req_stop",switch_at_req_stop);
|
GET_BOOL("switch_at_req_stop",switch_at_req_stop);
|
||||||
|
@ -2397,6 +2415,7 @@ void SettingsObjectWrapper::sync()
|
||||||
s.setValue("display_duration", prefs.display_duration);
|
s.setValue("display_duration", prefs.display_duration);
|
||||||
s.setValue("display_runtime", prefs.display_runtime);
|
s.setValue("display_runtime", prefs.display_runtime);
|
||||||
s.setValue("display_transitions", prefs.display_transitions);
|
s.setValue("display_transitions", prefs.display_transitions);
|
||||||
|
s.setValue("display_variations", prefs.display_variations);
|
||||||
s.setValue("safetystop", prefs.safetystop);
|
s.setValue("safetystop", prefs.safetystop);
|
||||||
s.setValue("reserve_gas", prefs.reserve_gas);
|
s.setValue("reserve_gas", prefs.reserve_gas);
|
||||||
s.setValue("ascrate75", prefs.ascrate75);
|
s.setValue("ascrate75", prefs.ascrate75);
|
||||||
|
|
|
@ -398,6 +398,7 @@ class DivePlannerSettings : public QObject {
|
||||||
Q_PROPERTY(bool display_runtime READ displayRuntime WRITE setDisplayRuntime NOTIFY displayRuntimeChanged)
|
Q_PROPERTY(bool display_runtime READ displayRuntime WRITE setDisplayRuntime NOTIFY displayRuntimeChanged)
|
||||||
Q_PROPERTY(bool display_duration READ displayDuration WRITE setDisplayDuration NOTIFY displayDurationChanged)
|
Q_PROPERTY(bool display_duration READ displayDuration WRITE setDisplayDuration NOTIFY displayDurationChanged)
|
||||||
Q_PROPERTY(bool display_transitions READ displayTransitions WRITE setDisplayTransitions NOTIFY displayTransitionsChanged)
|
Q_PROPERTY(bool display_transitions READ displayTransitions WRITE setDisplayTransitions NOTIFY displayTransitionsChanged)
|
||||||
|
Q_PROPERTY(bool display_variations READ displayVariations WRITE setDisplayVariations NOTIFY displayVariationsChanged)
|
||||||
Q_PROPERTY(bool doo2breaks READ doo2breaks WRITE setDoo2breaks NOTIFY doo2breaksChanged)
|
Q_PROPERTY(bool doo2breaks READ doo2breaks WRITE setDoo2breaks NOTIFY doo2breaksChanged)
|
||||||
Q_PROPERTY(bool drop_stone_mode READ dropStoneMode WRITE setDropStoneMode NOTIFY dropStoneModeChanged)
|
Q_PROPERTY(bool drop_stone_mode READ dropStoneMode WRITE setDropStoneMode NOTIFY dropStoneModeChanged)
|
||||||
Q_PROPERTY(bool safetystop READ safetyStop WRITE setSafetyStop NOTIFY safetyStopChanged)
|
Q_PROPERTY(bool safetystop READ safetyStop WRITE setSafetyStop NOTIFY safetyStopChanged)
|
||||||
|
@ -425,6 +426,7 @@ public:
|
||||||
bool displayRuntime() const;
|
bool displayRuntime() const;
|
||||||
bool displayDuration() const;
|
bool displayDuration() const;
|
||||||
bool displayTransitions() const;
|
bool displayTransitions() const;
|
||||||
|
bool displayVariations() const;
|
||||||
bool doo2breaks() const;
|
bool doo2breaks() const;
|
||||||
bool dropStoneMode() const;
|
bool dropStoneMode() const;
|
||||||
bool safetyStop() const;
|
bool safetyStop() const;
|
||||||
|
@ -451,6 +453,7 @@ public 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 setDisplayVariations(bool value);
|
||||||
void setDoo2breaks(bool value);
|
void setDoo2breaks(bool value);
|
||||||
void setDropStoneMode(bool value);
|
void setDropStoneMode(bool value);
|
||||||
void setSafetyStop(bool value);
|
void setSafetyStop(bool value);
|
||||||
|
@ -477,6 +480,7 @@ signals:
|
||||||
void displayRuntimeChanged(bool value);
|
void displayRuntimeChanged(bool value);
|
||||||
void displayDurationChanged(bool value);
|
void displayDurationChanged(bool value);
|
||||||
void displayTransitionsChanged(bool value);
|
void displayTransitionsChanged(bool value);
|
||||||
|
void displayVariationsChanged(bool value);
|
||||||
void doo2breaksChanged(bool value);
|
void doo2breaksChanged(bool value);
|
||||||
void dropStoneModeChanged(bool value);
|
void dropStoneModeChanged(bool value);
|
||||||
void safetyStopChanged(bool value);
|
void safetyStopChanged(bool value);
|
||||||
|
|
|
@ -66,6 +66,7 @@ struct preferences default_prefs = {
|
||||||
.display_runtime = true,
|
.display_runtime = true,
|
||||||
.display_duration = true,
|
.display_duration = true,
|
||||||
.display_transitions = true,
|
.display_transitions = true,
|
||||||
|
.display_variations = false,
|
||||||
.safetystop = true,
|
.safetystop = true,
|
||||||
.bottomsac = 20000,
|
.bottomsac = 20000,
|
||||||
.decosac = 17000,
|
.decosac = 17000,
|
||||||
|
|
|
@ -322,6 +322,7 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f)
|
||||||
ui.display_duration->setChecked(prefs.display_duration);
|
ui.display_duration->setChecked(prefs.display_duration);
|
||||||
ui.display_runtime->setChecked(prefs.display_runtime);
|
ui.display_runtime->setChecked(prefs.display_runtime);
|
||||||
ui.display_transitions->setChecked(prefs.display_transitions);
|
ui.display_transitions->setChecked(prefs.display_transitions);
|
||||||
|
ui.display_variations->setChecked(prefs.display_variations);
|
||||||
ui.safetystop->setChecked(prefs.safetystop);
|
ui.safetystop->setChecked(prefs.safetystop);
|
||||||
ui.sacfactor->setValue(prefs.sacfactor / 100.0);
|
ui.sacfactor->setValue(prefs.sacfactor / 100.0);
|
||||||
ui.problemsolvingtime->setValue(prefs.problemsolvingtime);
|
ui.problemsolvingtime->setValue(prefs.problemsolvingtime);
|
||||||
|
@ -355,6 +356,7 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f)
|
||||||
connect(ui.display_duration, SIGNAL(toggled(bool)), plannerModel, SLOT(setDisplayDuration(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_runtime, SIGNAL(toggled(bool)), plannerModel, SLOT(setDisplayRuntime(bool)));
|
||||||
connect(ui.display_transitions, SIGNAL(toggled(bool)), plannerModel, SLOT(setDisplayTransitions(bool)));
|
connect(ui.display_transitions, SIGNAL(toggled(bool)), plannerModel, SLOT(setDisplayTransitions(bool)));
|
||||||
|
connect(ui.display_variations, SIGNAL(toggled(bool)), plannerModel, SLOT(setDisplayVariations(bool)));
|
||||||
connect(ui.safetystop, SIGNAL(toggled(bool)), plannerModel, SLOT(setSafetyStop(bool)));
|
connect(ui.safetystop, SIGNAL(toggled(bool)), plannerModel, SLOT(setSafetyStop(bool)));
|
||||||
connect(ui.reserve_gas, SIGNAL(valueChanged(int)), plannerModel, SLOT(setReserveGas(int)));
|
connect(ui.reserve_gas, SIGNAL(valueChanged(int)), plannerModel, SLOT(setReserveGas(int)));
|
||||||
connect(ui.ascRate75, SIGNAL(valueChanged(int)), plannerModel, SLOT(emitDataChanged()));
|
connect(ui.ascRate75, SIGNAL(valueChanged(int)), plannerModel, SLOT(emitDataChanged()));
|
||||||
|
|
|
@ -685,6 +685,23 @@
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>2</number>
|
<number>2</number>
|
||||||
</property>
|
</property>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QCheckBox" name="verbatim_plan">
|
||||||
|
<property name="text">
|
||||||
|
<string>Verbatim dive plan</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" 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 in deco</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QCheckBox" name="display_runtime">
|
<widget class="QCheckBox" name="display_runtime">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
|
@ -708,20 +725,16 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QCheckBox" name="display_transitions">
|
<widget class="QCheckBox" name="display_variations">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>In diveplan, list transitions or treat them as implicit</string>
|
<string>Compute variations of plan (performance cost)</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Display transitions in deco</string>
|
<string>Display plan variations</string>
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="0">
|
|
||||||
<widget class="QCheckBox" name="verbatim_plan">
|
|
||||||
<property name="text">
|
|
||||||
<string>Verbatim dive plan</string>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -12,7 +12,7 @@ int getTotalWork(print_options *printOptions)
|
||||||
if (printOptions->print_selected) {
|
if (printOptions->print_selected) {
|
||||||
// return the correct number depending on all/selected dives
|
// return the correct number depending on all/selected dives
|
||||||
// but don't return 0 as we might divide by this number
|
// but don't return 0 as we might divide by this number
|
||||||
return amount_selected ? amount_selected : 1;
|
return amount_selected && !in_planner() ? amount_selected : 1;
|
||||||
}
|
}
|
||||||
return dive_table.nr;
|
return dive_table.nr;
|
||||||
}
|
}
|
||||||
|
@ -98,6 +98,11 @@ QString TemplateLayout::generate()
|
||||||
QVariantList diveList;
|
QVariantList diveList;
|
||||||
|
|
||||||
struct dive *dive;
|
struct dive *dive;
|
||||||
|
if (in_planner()) {
|
||||||
|
DiveObjectHelper *d = new DiveObjectHelper(&displayed_dive);
|
||||||
|
diveList.append(QVariant::fromValue(d));
|
||||||
|
emit progressUpdated(100.0);
|
||||||
|
} else {
|
||||||
int i;
|
int i;
|
||||||
for_each_dive (i, dive) {
|
for_each_dive (i, dive) {
|
||||||
//TODO check for exporting selected dives only
|
//TODO check for exporting selected dives only
|
||||||
|
@ -108,6 +113,7 @@ QString TemplateLayout::generate()
|
||||||
progress++;
|
progress++;
|
||||||
emit progressUpdated(lrint(progress * 100.0 / totalWork));
|
emit progressUpdated(lrint(progress * 100.0 / totalWork));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Grantlee::Context c;
|
Grantlee::Context c;
|
||||||
c.insert("dives", diveList);
|
c.insert("dives", diveList);
|
||||||
c.insert("template_options", QVariant::fromValue(*templateOptions));
|
c.insert("template_options", QVariant::fromValue(*templateOptions));
|
||||||
|
|
|
@ -522,6 +522,13 @@ void DivePlannerPointsModel::setDisplayTransitions(bool value)
|
||||||
emitDataChanged();
|
emitDataChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DivePlannerPointsModel::setDisplayVariations(bool value)
|
||||||
|
{
|
||||||
|
auto planner = SettingsObjectWrapper::instance()->planner_settings;
|
||||||
|
planner->setDisplayVariations(value);
|
||||||
|
emitDataChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void DivePlannerPointsModel::setDecoMode(int mode)
|
void DivePlannerPointsModel::setDecoMode(int mode)
|
||||||
{
|
{
|
||||||
auto planner = SettingsObjectWrapper::instance()->planner_settings;
|
auto planner = SettingsObjectWrapper::instance()->planner_settings;
|
||||||
|
@ -934,8 +941,7 @@ void DivePlannerPointsModel::computeVariations()
|
||||||
struct diveplan plan_copy;
|
struct diveplan plan_copy;
|
||||||
struct divedatapoint *last_segment;
|
struct divedatapoint *last_segment;
|
||||||
|
|
||||||
if(!in_planner())
|
if(in_planner() && prefs.display_variations) {
|
||||||
return;
|
|
||||||
cache_deco_state(&save);
|
cache_deco_state(&save);
|
||||||
cloneDiveplan(&plan_copy);
|
cloneDiveplan(&plan_copy);
|
||||||
plan(&plan_copy, dive, 1, original, &cache, true, false);
|
plan(&plan_copy, dive, 1, original, &cache, true, false);
|
||||||
|
@ -967,7 +973,6 @@ void DivePlannerPointsModel::computeVariations()
|
||||||
plan(&plan_copy, dive, 1, shorter, &cache, true, false);
|
plan(&plan_copy, dive, 1, shorter, &cache, true, false);
|
||||||
free_dps(&plan_copy);
|
free_dps(&plan_copy);
|
||||||
restore_deco_state(save, false);
|
restore_deco_state(save, false);
|
||||||
|
|
||||||
#ifdef SHOWSTOPVARIATIONS
|
#ifdef SHOWSTOPVARIATIONS
|
||||||
printf("\n\n");
|
printf("\n\n");
|
||||||
#endif
|
#endif
|
||||||
|
@ -980,6 +985,7 @@ void DivePlannerPointsModel::computeVariations()
|
||||||
FRACTION(analyzeVariations(shorter, original, longer, "min"), 60));
|
FRACTION(analyzeVariations(shorter, original, longer, "min"), 60));
|
||||||
|
|
||||||
displayed_dive.notes = strdup(notes.replace("VARIATIONS", QString(buf)).toUtf8().data());
|
displayed_dive.notes = strdup(notes.replace("VARIATIONS", QString(buf)).toUtf8().data());
|
||||||
|
}
|
||||||
setRecalc(oldRecalc);
|
setRecalc(oldRecalc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,7 @@ 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 setDisplayVariations(bool value);
|
||||||
void setDecoMode(int mode);
|
void setDecoMode(int mode);
|
||||||
void setSafetyStop(bool value);
|
void setSafetyStop(bool value);
|
||||||
void savePlan();
|
void savePlan();
|
||||||
|
|
Loading…
Reference in a new issue