diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-05-29 15:32:31 +0900 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-05-29 15:32:31 +0900 |
commit | da52ff56b2cc2b4aecda03b4f21f94ce3ff0ce22 (patch) | |
tree | faf2bd2a5fc72f4f017f5b7a02285d8b835c6579 | |
parent | c78d0ad51b2495b4807ae999667b44432a05cb3b (diff) | |
download | subsurface-da52ff56b2cc2b4aecda03b4f21f94ce3ff0ce22.tar.gz |
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>
-rw-r--r-- | qt-ui/mainwindow.cpp | 3 | ||||
-rw-r--r-- | qt-ui/preferences.cpp | 12 | ||||
-rw-r--r-- | qt-ui/preferences.ui | 55 | ||||
-rw-r--r-- | qt-ui/profilegraphics.cpp | 57 |
4 files changed, 87 insertions, 40 deletions
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 7ed4f8aeb..8c600ea19 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -392,7 +392,7 @@ void MainWindow::readSettings() prefs.mod_ppO2 = v.toDouble(); GET_BOOL(v, "ead", prefs.ead); 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, "calcceiling3m", prefs.calc_ceiling_3m_incr); v = settings.value(QString("gflow")); @@ -471,6 +471,7 @@ void MainWindow::writeSettings() SAVE_VALUE("redceiling", profile_red_ceiling); SAVE_VALUE("calcceiling", profile_calc_ceiling); SAVE_VALUE("calcceiling3m", calc_ceiling_3m_incr); + SAVE_VALUE("dcceiling", profile_dc_ceiling); SAVE_VALUE("gflow", gflow); SAVE_VALUE("gfhigh", gfhigh); settings.endGroup(); diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp index 8949a2df0..453f20c34 100644 --- a/qt-ui/preferences.cpp +++ b/qt-ui/preferences.cpp @@ -25,7 +25,6 @@ PreferencesDialog::PreferencesDialog(QWidget* parent, Qt::WindowFlags f) : QDial // Graph s.beginGroup("TecDetails"); - ui->calculated_ceiling->setChecked(B(calcceiling, profile_calc_ceiling)); ui->phe->setChecked(B(phegraph, pp_graphs.phe)); ui->pheThreshold->setEnabled(ui->phe->isChecked()); 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->ead_end_eadd->setChecked(B(ead, ead)); 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->gflow->setValue((int)(I(gflow, gflow))); ui->gfhigh->setValue((int)(I(gfhigh, gfhigh))); s.endGroup(); @@ -98,7 +101,6 @@ void PreferencesDialog::syncSettings() // Graph s.beginGroup("TecDetails"); - SB("calcceiling", ui->calculated_ceiling); SB("phegraph", ui->phe); SB("po2graph", ui->po2); SB("pn2graph", ui->pn2); @@ -107,7 +109,9 @@ void PreferencesDialog::syncSettings() s.setValue("pn2threshold", ui->pn2Threshold->value()); SB("ead", ui->ead_end_eadd); 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("gfhigh", ui->gfhigh->value()); s.endGroup(); diff --git a/qt-ui/preferences.ui b/qt-ui/preferences.ui index c442f5d2c..348e62ecd 100644 --- a/qt-ui/preferences.ui +++ b/qt-ui/preferences.ui @@ -593,12 +593,39 @@ </widget> </item> <item> - <widget class="QCheckBox" name="dc_reported_ceiling"> - <property name="text"> - <string>Dive computer reported ceiling</string> - </property> - </widget> - </item> + <layout class="QHBoxLayout" name="horizontalLayout_10b"> + <item> + <widget class="QCheckBox" name="dc_reported_ceiling"> + <property name="text"> + <string>Dive computer reported ceiling</string> + </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> <layout class="QHBoxLayout" name="horizontalLayout_10"> <item> @@ -864,6 +891,22 @@ </hints> </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> <sender>calculated_ceiling</sender> <signal>clicked(bool)</signal> <receiver>increment_3m</receiver> diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp index 060c36b51..663aefe25 100644 --- a/qt-ui/profilegraphics.cpp +++ b/qt-ui/profilegraphics.cpp @@ -1000,14 +1000,16 @@ void ProfileGraphicsView::plot_depth_profile() p.append(QPointF(SCALEGC(entry->sec, entry->depth))); /* Show any ceiling we may have encountered */ - for (i = gc.pi.nr - 1; i >= 0; i--, entry--) { - if (entry->ndl) { - /* non-zero NDL implies this is a safety stop, no ceiling */ - p.append(QPointF(SCALEGC(entry->sec, 0))); - } else if (entry->stopdepth < entry->depth) { - p.append(QPointF(SCALEGC(entry->sec, entry->stopdepth))); - } else { - p.append(QPointF(SCALEGC(entry->sec, entry->depth))); + if (prefs.profile_dc_ceiling) { + for (i = gc.pi.nr - 1; i >= 0; i--, entry--) { + if (entry->ndl) { + /* non-zero NDL implies this is a safety stop, no ceiling */ + p.append(QPointF(SCALEGC(entry->sec, 0))); + } else if (entry->stopdepth < entry->depth) { + p.append(QPointF(SCALEGC(entry->sec, entry->stopdepth))); + } else { + p.append(QPointF(SCALEGC(entry->sec, entry->depth))); + } } } 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 * basically draws over the background that we had allowed to shine * through so far) */ - // TODO: port the prefs.profile_red_ceiling to QSettings - - //if (prefs.profile_red_ceiling) { + if (prefs.profile_dc_ceiling && prefs.profile_red_ceiling) { p.clear(); pat.setColorAt(0, profile_color[CEILING_SHALLOW].first()); pat.setColorAt(1, profile_color[CEILING_DEEP].first()); @@ -1049,12 +1049,10 @@ void ProfileGraphicsView::plot_depth_profile() neatFill->setPolygon(p); neatFill->setPen(QPen(QBrush(Qt::NoBrush),0)); scene()->addItem(neatFill); - //} + } /* 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(1, profile_color[CALC_CEILING_DEEP].first()); @@ -1073,25 +1071,26 @@ void ProfileGraphicsView::plot_depth_profile() neatFill->setPen(QPen(QBrush(Qt::NoBrush),0)); neatFill->setBrush(pat); scene()->addItem(neatFill); - //} + } /* next show where we have been bad and crossed the dc's ceiling */ - pat.setColorAt(0, profile_color[CEILING_SHALLOW].first()); - pat.setColorAt(1, profile_color[CEILING_DEEP].first()); - - entry = gc.pi.entry; - p.clear(); - p.append(QPointF(SCALEGC(0, 0))); - for (i = 0; i < gc.pi.nr; i++, entry++) - p.append(QPointF(SCALEGC(entry->sec, entry->depth))); + if (prefs.profile_dc_ceiling) { + pat.setColorAt(0, profile_color[CEILING_SHALLOW].first()); + pat.setColorAt(1, profile_color[CEILING_DEEP].first()); - 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 { + entry = gc.pi.entry; + p.clear(); + p.append(QPointF(SCALEGC(0, 0))); + 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))); + } } } - neatFill = new QGraphicsPolygonItem(); neatFill->setPolygon(p); neatFill->setPen(QPen(QBrush(Qt::NoBrush),0)); |