Correct the ceiling preference handling

Added the red dc ceiling as preference option.
Hooked them all up together so the sub-preferences are enabled when the
master preference is set (for 3m and red ceiling).
Use the options in the profile plotting functions.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2013-05-29 15:32:31 +09:00
parent c78d0ad51b
commit da52ff56b2
4 changed files with 87 additions and 40 deletions

View file

@ -392,7 +392,7 @@ void MainWindow::readSettings()
prefs.mod_ppO2 = v.toDouble(); prefs.mod_ppO2 = v.toDouble();
GET_BOOL(v, "ead", prefs.ead); GET_BOOL(v, "ead", prefs.ead);
GET_BOOL(v, "redceiling", prefs.profile_red_ceiling); GET_BOOL(v, "redceiling", prefs.profile_red_ceiling);
GET_BOOL(v, "show_dc_reported_ceiling", prefs.profile_dc_ceiling); GET_BOOL(v, "dcceiling", prefs.profile_dc_ceiling);
GET_BOOL(v, "calcceiling", prefs.profile_calc_ceiling); GET_BOOL(v, "calcceiling", prefs.profile_calc_ceiling);
GET_BOOL(v, "calcceiling3m", prefs.calc_ceiling_3m_incr); GET_BOOL(v, "calcceiling3m", prefs.calc_ceiling_3m_incr);
v = settings.value(QString("gflow")); v = settings.value(QString("gflow"));
@ -471,6 +471,7 @@ void MainWindow::writeSettings()
SAVE_VALUE("redceiling", profile_red_ceiling); SAVE_VALUE("redceiling", profile_red_ceiling);
SAVE_VALUE("calcceiling", profile_calc_ceiling); SAVE_VALUE("calcceiling", profile_calc_ceiling);
SAVE_VALUE("calcceiling3m", calc_ceiling_3m_incr); SAVE_VALUE("calcceiling3m", calc_ceiling_3m_incr);
SAVE_VALUE("dcceiling", profile_dc_ceiling);
SAVE_VALUE("gflow", gflow); SAVE_VALUE("gflow", gflow);
SAVE_VALUE("gfhigh", gfhigh); SAVE_VALUE("gfhigh", gfhigh);
settings.endGroup(); settings.endGroup();

View file

@ -25,7 +25,6 @@ PreferencesDialog::PreferencesDialog(QWidget* parent, Qt::WindowFlags f) : QDial
// Graph // Graph
s.beginGroup("TecDetails"); s.beginGroup("TecDetails");
ui->calculated_ceiling->setChecked(B(calcceiling, profile_calc_ceiling));
ui->phe->setChecked(B(phegraph, pp_graphs.phe)); ui->phe->setChecked(B(phegraph, pp_graphs.phe));
ui->pheThreshold->setEnabled(ui->phe->isChecked()); ui->pheThreshold->setEnabled(ui->phe->isChecked());
ui->po2->setChecked(B(po2graph, pp_graphs.po2)); ui->po2->setChecked(B(po2graph, pp_graphs.po2));
@ -37,8 +36,12 @@ PreferencesDialog::PreferencesDialog(QWidget* parent, Qt::WindowFlags f) : QDial
ui->pn2Threshold->setValue(D(pn2threshold, pp_graphs.pn2_threshold)); ui->pn2Threshold->setValue(D(pn2threshold, pp_graphs.pn2_threshold));
ui->ead_end_eadd->setChecked(B(ead, ead)); ui->ead_end_eadd->setChecked(B(ead, ead));
ui->dc_reported_ceiling->setChecked(B(dcceiling, profile_dc_ceiling)); ui->dc_reported_ceiling->setChecked(B(dcceiling, profile_dc_ceiling));
ui->calculated_ceiling->setChecked(B(calceiling, profile_calc_ceiling)); ui->red_ceiling->setEnabled(ui->dc_reported_ceiling->isChecked());
ui->red_ceiling->setChecked(B(redceiling, profile_red_ceiling));
ui->calculated_ceiling->setChecked(B(calcceiling, profile_calc_ceiling));
ui->increment_3m->setEnabled(ui->calculated_ceiling->isChecked());
ui->increment_3m->setChecked(B(calcceiling3m, calc_ceiling_3m_incr)); ui->increment_3m->setChecked(B(calcceiling3m, calc_ceiling_3m_incr));
ui->gflow->setValue((int)(I(gflow, gflow))); ui->gflow->setValue((int)(I(gflow, gflow)));
ui->gfhigh->setValue((int)(I(gfhigh, gfhigh))); ui->gfhigh->setValue((int)(I(gfhigh, gfhigh)));
s.endGroup(); s.endGroup();
@ -98,7 +101,6 @@ void PreferencesDialog::syncSettings()
// Graph // Graph
s.beginGroup("TecDetails"); s.beginGroup("TecDetails");
SB("calcceiling", ui->calculated_ceiling);
SB("phegraph", ui->phe); SB("phegraph", ui->phe);
SB("po2graph", ui->po2); SB("po2graph", ui->po2);
SB("pn2graph", ui->pn2); SB("pn2graph", ui->pn2);
@ -107,7 +109,9 @@ void PreferencesDialog::syncSettings()
s.setValue("pn2threshold", ui->pn2Threshold->value()); s.setValue("pn2threshold", ui->pn2Threshold->value());
SB("ead", ui->ead_end_eadd); SB("ead", ui->ead_end_eadd);
SB("dcceiling", ui->dc_reported_ceiling); SB("dcceiling", ui->dc_reported_ceiling);
SB("calceiling3m", ui->increment_3m); SB("redceiling", ui->red_ceiling);
SB("calcceiling", ui->calculated_ceiling);
SB("calcceiling3m", ui->increment_3m);
s.setValue("gflow", ui->gflow->value()); s.setValue("gflow", ui->gflow->value());
s.setValue("gfhigh", ui->gfhigh->value()); s.setValue("gfhigh", ui->gfhigh->value());
s.endGroup(); s.endGroup();

View file

@ -593,12 +593,39 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="dc_reported_ceiling"> <layout class="QHBoxLayout" name="horizontalLayout_10b">
<property name="text"> <item>
<string>Dive computer reported ceiling</string> <widget class="QCheckBox" name="dc_reported_ceiling">
</property> <property name="text">
</widget> <string>Dive computer reported ceiling</string>
</item> </property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6b">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="red_ceiling">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>draw ceiling red</string>
</property>
</widget>
</item>
</layout>
</item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_10"> <layout class="QHBoxLayout" name="horizontalLayout_10">
<item> <item>
@ -863,6 +890,22 @@
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection>
<sender>dc_ceiling</sender>
<signal>clicked(bool)</signal>
<receiver>red_ceiling</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>288</x>
<y>364</y>
</hint>
<hint type="destinationlabel">
<x>555</x>
<y>371</y>
</hint>
</hints>
</connection>
<connection> <connection>
<sender>calculated_ceiling</sender> <sender>calculated_ceiling</sender>
<signal>clicked(bool)</signal> <signal>clicked(bool)</signal>

View file

@ -1000,14 +1000,16 @@ void ProfileGraphicsView::plot_depth_profile()
p.append(QPointF(SCALEGC(entry->sec, entry->depth))); p.append(QPointF(SCALEGC(entry->sec, entry->depth)));
/* Show any ceiling we may have encountered */ /* Show any ceiling we may have encountered */
for (i = gc.pi.nr - 1; i >= 0; i--, entry--) { if (prefs.profile_dc_ceiling) {
if (entry->ndl) { for (i = gc.pi.nr - 1; i >= 0; i--, entry--) {
/* non-zero NDL implies this is a safety stop, no ceiling */ if (entry->ndl) {
p.append(QPointF(SCALEGC(entry->sec, 0))); /* non-zero NDL implies this is a safety stop, no ceiling */
} else if (entry->stopdepth < entry->depth) { p.append(QPointF(SCALEGC(entry->sec, 0)));
p.append(QPointF(SCALEGC(entry->sec, entry->stopdepth))); } else if (entry->stopdepth < entry->depth) {
} else { p.append(QPointF(SCALEGC(entry->sec, entry->stopdepth)));
p.append(QPointF(SCALEGC(entry->sec, entry->depth))); } else {
p.append(QPointF(SCALEGC(entry->sec, entry->depth)));
}
} }
} }
pat.setColorAt(1, profile_color[DEPTH_BOTTOM].first()); pat.setColorAt(1, profile_color[DEPTH_BOTTOM].first());
@ -1023,9 +1025,7 @@ void ProfileGraphicsView::plot_depth_profile()
/* if the user wants the deco ceiling more visible, do that here (this /* if the user wants the deco ceiling more visible, do that here (this
* basically draws over the background that we had allowed to shine * basically draws over the background that we had allowed to shine
* through so far) */ * through so far) */
// TODO: port the prefs.profile_red_ceiling to QSettings if (prefs.profile_dc_ceiling && prefs.profile_red_ceiling) {
//if (prefs.profile_red_ceiling) {
p.clear(); p.clear();
pat.setColorAt(0, profile_color[CEILING_SHALLOW].first()); pat.setColorAt(0, profile_color[CEILING_SHALLOW].first());
pat.setColorAt(1, profile_color[CEILING_DEEP].first()); pat.setColorAt(1, profile_color[CEILING_DEEP].first());
@ -1049,12 +1049,10 @@ void ProfileGraphicsView::plot_depth_profile()
neatFill->setPolygon(p); neatFill->setPolygon(p);
neatFill->setPen(QPen(QBrush(Qt::NoBrush),0)); neatFill->setPen(QPen(QBrush(Qt::NoBrush),0));
scene()->addItem(neatFill); scene()->addItem(neatFill);
//} }
/* finally, plot the calculated ceiling over all this */ /* finally, plot the calculated ceiling over all this */
// TODO: Port the profile_calc_ceiling to QSettings if (prefs.profile_calc_ceiling) {
// if (prefs.profile_calc_ceiling) {
pat.setColorAt(0, profile_color[CALC_CEILING_SHALLOW].first()); pat.setColorAt(0, profile_color[CALC_CEILING_SHALLOW].first());
pat.setColorAt(1, profile_color[CALC_CEILING_DEEP].first()); pat.setColorAt(1, profile_color[CALC_CEILING_DEEP].first());
@ -1073,25 +1071,26 @@ void ProfileGraphicsView::plot_depth_profile()
neatFill->setPen(QPen(QBrush(Qt::NoBrush),0)); neatFill->setPen(QPen(QBrush(Qt::NoBrush),0));
neatFill->setBrush(pat); neatFill->setBrush(pat);
scene()->addItem(neatFill); scene()->addItem(neatFill);
//} }
/* next show where we have been bad and crossed the dc's ceiling */ /* next show where we have been bad and crossed the dc's ceiling */
pat.setColorAt(0, profile_color[CEILING_SHALLOW].first()); if (prefs.profile_dc_ceiling) {
pat.setColorAt(1, profile_color[CEILING_DEEP].first()); pat.setColorAt(0, profile_color[CEILING_SHALLOW].first());
pat.setColorAt(1, profile_color[CEILING_DEEP].first());
entry = gc.pi.entry; entry = gc.pi.entry;
p.clear(); p.clear();
p.append(QPointF(SCALEGC(0, 0))); p.append(QPointF(SCALEGC(0, 0)));
for (i = 0; i < gc.pi.nr; i++, entry++) for (i = 0; i < gc.pi.nr; i++, entry++)
p.append(QPointF(SCALEGC(entry->sec, entry->depth)));
for (i = gc.pi.nr - 1; i >= 0; i--, entry--) {
if (entry->ndl == 0 && entry->stopdepth > entry->depth) {
p.append(QPointF(SCALEGC(entry->sec, entry->stopdepth)));
} else {
p.append(QPointF(SCALEGC(entry->sec, entry->depth))); p.append(QPointF(SCALEGC(entry->sec, entry->depth)));
for (i = gc.pi.nr - 1; i >= 0; i--, entry--) {
if (entry->ndl == 0 && entry->stopdepth > entry->depth) {
p.append(QPointF(SCALEGC(entry->sec, entry->stopdepth)));
} else {
p.append(QPointF(SCALEGC(entry->sec, entry->depth)));
}
} }
} }
neatFill = new QGraphicsPolygonItem(); neatFill = new QGraphicsPolygonItem();
neatFill->setPolygon(p); neatFill->setPolygon(p);
neatFill->setPen(QPen(QBrush(Qt::NoBrush),0)); neatFill->setPen(QPen(QBrush(Qt::NoBrush),0));