From d2a834b0cdcf9adae750192dbb04f8a3efeeb74a Mon Sep 17 00:00:00 2001 From: Robert Helling Date: Thu, 26 Jun 2014 17:04:39 +0200 Subject: Rearrange planner UI elements This is my first attempt at grouping UI elements of the planner in a sensible way. It might still be sensible to combine the two bottom panes into one. In addition there is a new field "altutude" which is sychronized with the surface pressure as for planning we often know the altitude of the dive site rather than the atmospheric pressure. Signed-off-by: Robert C. Helling Signed-off-by: Dirk Hohndel --- qt-ui/diveplanner.cpp | 56 ++-- qt-ui/diveplanner.h | 3 +- qt-ui/diveplanner.ui | 111 ++------ qt-ui/mainwindow.cpp | 5 + qt-ui/mainwindow.ui | 187 +++++++------ qt-ui/plannerSettings.ui | 677 ++++++++++++++++++++++++++--------------------- 6 files changed, 562 insertions(+), 477 deletions(-) diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 0708b6aef..1afd62e13 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -241,6 +241,8 @@ void DiveHandler::mouseMoveEvent(QGraphicsSceneMouseEvent *event) DivePlannerWidget::DivePlannerWidget(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f) { ui.setupUi(this); + if (prefs.units.METERS == units::FEET) + ui.atmHeight->setSuffix("ft"); ui.tableWidget->setTitle(tr("Dive Planner Points")); ui.tableWidget->setModel(DivePlannerPointsModel::instance()); DivePlannerPointsModel::instance()->setRecalc(true); @@ -270,18 +272,8 @@ DivePlannerWidget::DivePlannerWidget(QWidget *parent, Qt::WindowFlags f) : QWidg ui.tableWidget->setBtnToolTip(tr("add dive data point")); connect(ui.startTime, SIGNAL(timeChanged(QTime)), plannerModel, SLOT(setStartTime(QTime))); - connect(ui.ATMPressure, SIGNAL(textChanged(QString)), this, SLOT(atmPressureChanged(QString))); - connect(ui.bottomSAC, SIGNAL(valueChanged(int)), this, SLOT(bottomSacChanged(int))); - connect(ui.decoStopSAC, SIGNAL(valueChanged(int)), this, SLOT(decoSacChanged(int))); - connect(ui.gfhigh, SIGNAL(valueChanged(int)), plannerModel, SLOT(setGFHigh(int))); - connect(ui.gfhigh, SIGNAL(editingFinished()), plannerModel, SLOT(emitDataChanged())); - connect(ui.gflow, SIGNAL(valueChanged(int)), plannerModel, SLOT(setGFLow(int))); - connect(ui.gflow, SIGNAL(editingFinished()), plannerModel, SLOT(emitDataChanged())); - connect(ui.printPlan, SIGNAL(pressed()), this, SLOT(printDecoPlan())); - connect(ui.drop_stone_mode, SIGNAL(toggled(bool)), plannerModel, SLOT(setDropStoneMode(bool))); -#ifdef NO_PRINTING - ui.printPlan->hide(); -#endif + connect(ui.ATMPressure, SIGNAL(valueChanged(int)), this, SLOT(atmPressureChanged(int))); + connect(ui.atmHeight, SIGNAL(valueChanged(int)), this, SLOT(heightChanged(int))); // Creating (and canceling) the plan connect(ui.buttonBox, SIGNAL(accepted()), plannerModel, SLOT(createPlan())); @@ -291,11 +283,8 @@ DivePlannerWidget::DivePlannerWidget(QWidget *parent, Qt::WindowFlags f) : QWidg /* set defaults. */ ui.startTime->setTime(QTime(1, 0)); - ui.ATMPressure->setText("1013"); - ui.bottomSAC->setValue(20); - ui.decoStopSAC->setValue(17); - ui.gflow->setValue(prefs.gflow); - ui.gfhigh->setValue(prefs.gfhigh); + ui.ATMPressure->setValue(1013); + ui.atmHeight->setValue(0); setMinimumWidth(0); setMinimumHeight(0); @@ -311,9 +300,23 @@ void DivePlannerPointsModel::addCylinder_clicked() CylindersModel::instance()->add(); } -void DivePlannerWidget::atmPressureChanged(const QString &pressure) +void DivePlannerWidget::atmPressureChanged(const int pressure) { - plannerModel->setSurfacePressure(pressure.toInt()); + const char *depthunit; + + plannerModel->setSurfacePressure(pressure); + ui.atmHeight->blockSignals(true); + ui.atmHeight->setValue((int) get_depth_units((int)(log(1013.0 / pressure) * 7800000), NULL,NULL)); + ui.atmHeight->blockSignals(false); +} + +void DivePlannerWidget::heightChanged(const int height) +{ + int pressure = (int) (1013.0 * exp(- (double) units_to_depth((double) height) / 7800000.0)); + ui.ATMPressure->blockSignals(true); + ui.ATMPressure->setValue(pressure); + ui.ATMPressure->blockSignals(false); + plannerModel->setSurfacePressure(pressure); } void DivePlannerWidget::bottomSacChanged(const int bottomSac) @@ -350,6 +353,7 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f) ui.bottompo2->setValue(prefs.bottompo2 / 1000.0); ui.decopo2->setValue(prefs.decopo2 / 1000.0); + 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))); @@ -367,6 +371,18 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f) connect(ui.descRate, SIGNAL(valueChanged(int)), plannerModel, SLOT(emitDataChanged())); connect(ui.bottompo2, SIGNAL(valueChanged(double)), this, SLOT(setBottomPo2(double))); connect(ui.decopo2, SIGNAL(valueChanged(double)), this, SLOT(setDecoPo2(double))); + connect(ui.drop_stone_mode, SIGNAL(toggled(bool)), plannerModel, SLOT(setDropStoneMode(bool))); + connect(ui.bottomSAC, SIGNAL(valueChanged(int)), this, SLOT(bottomSacChanged(int))); + connect(ui.decoStopSAC, SIGNAL(valueChanged(int)), this, SLOT(decoSacChanged(int))); + connect(ui.gfhigh, SIGNAL(valueChanged(int)), plannerModel, SLOT(setGFHigh(int))); +// connect(ui.gfhigh, SIGNAL(valueChanged()), plannerModel, SLOT(emitDataChanged())); + connect(ui.gflow, SIGNAL(valueChanged(int)), plannerModel, SLOT(setGFLow(int))); +// connect(ui.gflow, SIGNAL(valueChanged()), plannerModel, SLOT(emitDataChanged())); + + ui.bottomSAC->setValue(20); + ui.decoStopSAC->setValue(17); + ui.gflow->setValue(prefs.gflow); + ui.gfhigh->setValue(prefs.gfhigh); setMinimumWidth(0); setMinimumHeight(0); @@ -605,11 +621,13 @@ void DivePlannerPointsModel::setDecoSac(int sac) void DivePlannerPointsModel::setGFHigh(const int gfhigh) { diveplan.gfhigh = gfhigh; + plannerModel->emitDataChanged(); } void DivePlannerPointsModel::setGFLow(const int ghflow) { diveplan.gflow = ghflow; + plannerModel->emitDataChanged(); } void DivePlannerPointsModel::setSurfacePressure(int pressure) diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h index 5955a5a8f..b80aa98da 100644 --- a/qt-ui/diveplanner.h +++ b/qt-ui/diveplanner.h @@ -136,7 +136,8 @@ public: public slots: void settingsChanged(); - void atmPressureChanged(const QString &pressure); + void atmPressureChanged(const int pressure); + void heightChanged(const int height); void bottomSacChanged(const int bottomSac); void decoSacChanged(const int decosac); void printDecoPlan(); diff --git a/qt-ui/diveplanner.ui b/qt-ui/diveplanner.ui index 33ec33cbd..fffed0d99 100644 --- a/qt-ui/diveplanner.ui +++ b/qt-ui/diveplanner.ui @@ -65,10 +65,10 @@ 2 - - + + - + 0 0 @@ -81,10 +81,10 @@ - - + + - + 0 0 @@ -95,24 +95,9 @@ 50 + label_2 - - - - - - - 1 - - - 150 - - - - - - @@ -120,82 +105,50 @@ - - - - GFLow - - - - + QDialogButtonBox::Abort|QDialogButtonBox::Save - - - - - - - 1 - - - 150 - - - - - - - SAC on DECO Stop - - + + - + - Bottom SAC + Altitide - - - - GFHigh - - - - + ATM Pressure - - - - - 0 - 0 - + + + + bar - - - - - - Drop like a stone mode + + 2000 - - - - Print + + + + m + + + -2000 + + + 10000 @@ -215,12 +168,6 @@ startTime - ATMPressure - bottomSAC - decoStopSAC - gflow - gfhigh - printPlan buttonBox scrollArea diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 13a441349..de624a79d 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -83,6 +83,11 @@ MainWindow::MainWindow() : QMainWindow(), connect(information(), SIGNAL(addDiveFinished()), ui.newProfile, SLOT(setProfileState())); connect(DivePlannerPointsModel::instance(), SIGNAL(planCreated()), MainWindow::instance(), SLOT(planCreated())); connect(DivePlannerPointsModel::instance(), SIGNAL(planCanceled()), MainWindow::instance(), SLOT(planCanceled())); + connect(ui.printPlan, SIGNAL(pressed()), ui.divePlannerWidget, SLOT(printDecoPlan())); +#ifdef NO_PRINTING + ui.printPlan->hide(); +#endif + ui.mainErrorMessage->hide(); initialUiSetup(); readSettings(); diff --git a/qt-ui/mainwindow.ui b/qt-ui/mainwindow.ui index 8369b0e4b..d113cd7f6 100644 --- a/qt-ui/mainwindow.ui +++ b/qt-ui/mainwindow.ui @@ -6,8 +6,8 @@ 0 0 - 1418 - 1084 + 1682 + 1151 @@ -38,7 +38,7 @@ - 0 + 1 @@ -109,43 +109,30 @@ 0 - - - - Enable the pO2 Graph - - - ... - - - - :/icon_o2:/icon_o2 + + + + Qt::Vertical - + - 24 - 24 + 20 + 40 - - true - - - true - - + - - + + - Enable the pN2 Graph + Enable the pHe graph ... - :/icon_n2:/icon_n2 + :/icon_he:/icon_he @@ -161,17 +148,17 @@ - - + + - Enable the pHe graph + Calculate All Tissues ... - :/icon_he:/icon_he + :/icon_ceiling_alltissues:/icon_ceiling_alltissues @@ -245,17 +232,17 @@ - - + + - Calculate All Tissues + Show NDL / TTS ... - :/icon_ceiling_alltissues:/icon_ceiling_alltissues + :/icon_NDLTTS:/icon_NDLTTS @@ -375,17 +362,17 @@ - - + + - Show NDL / TTS + Show SAC Rate ... - :/icon_NDLTTS:/icon_NDLTTS + :/icon_lung:/icon_lung @@ -401,17 +388,17 @@ - - + + - Show SAC Rate + Rescale depth axis ... - :/icon_lung:/icon_lung + :/scale:/scale @@ -453,17 +440,17 @@ - - + + - Rescale depth axis + Enable the pO2 Graph ... - :/scale:/scale + :/icon_o2:/icon_o2 @@ -479,21 +466,34 @@ - - - - - - - Qt::Vertical + + + + Enable the pN2 Graph - + + ... + + + + :/icon_n2:/icon_n2 + + - 20 - 40 + 24 + 24 - + + true + + + true + + + + + @@ -504,7 +504,7 @@ - 0 + 1 @@ -548,9 +548,9 @@ - 0 + 1 - + 0 @@ -570,22 +570,54 @@ 0 - + - - - - 16777215 - 20 - - - - Dive plan details - - + + + + + + 16777215 + 20 + + + + <html><head/><body><p><span style=" font-weight:600;">Dive plan details</span></p></body></html> + + + Qt::RichText + + + + + + + + 0 + 0 + + + + Print + + + false + + + false + + + false + + + + + + true + 0 @@ -614,10 +646,7 @@ p, li { white-space: pre-wrap; } - - mainSplitter - mainSplitter - + @@ -626,7 +655,7 @@ p, li { white-space: pre-wrap; } 0 0 - 1418 + 1682 22 diff --git a/qt-ui/plannerSettings.ui b/qt-ui/plannerSettings.ui index 57814eabb..271906e70 100644 --- a/qt-ui/plannerSettings.ui +++ b/qt-ui/plannerSettings.ui @@ -6,312 +6,397 @@ 0 0 - 963 - 324 + 537 + 435 Form - - - - 20 - 20 - 872 - 463 - - - - - - - QFrame::StyledPanel + + + + + + 0 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + surface to the bottom + + + + + + + bar + + + 2.000000000000000 + + + 0.100000000000000 + + + 1.400000000000000 + + + + + + + + 0 + 0 + + + + + 16777215 + 20 + + + + m/min + + + 1 + + + 18 + + + + + + + bar + + + 2.000000000000000 + + + 0.100000000000000 + + + 1.600000000000000 + + + + + + + m/min + + + 1 + + + + + + + bottom pO₂ + + + + + + + <html><head/><body><p><span style=" font-weight:600;">Descent rate</span></p></body></html> + + + + + + + 6m/20ft to surface + + + + + + + deco pO₂ + + + + + + + 75%-50% avg. depth + + + + + + + below 75% avg. depth + + + + + + + 50% avg. depth - 6m/20ft + + + + + + + <html><head/><body><p><span style=" font-weight:600;">Ascent rates</span></p></body></html> + + + + + + + m/min + + + 1 + + + + + + + m/min + + + 1 + + + + + + + <html><head/><body><p><span style=" font-weight:600;">Gas options</span></p></body></html> + + + + + + + m/min + + + 1 + + + + + + + + + + bottom SAC + + + + + + + deco SAC + + + + + + + + + + + + + + 0 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + QLayout::SetNoConstraint - - QFrame::Raised - - - - - - Last Stop at 6m/20ft - - - - - - - plan backgas breaks - - - - - - - Qt::Horizontal - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - QFormLayout::FieldsStayAtSizeHint - - - - - bottom pO₂ - - - - - - - deco pO₂ - - - - - - - bar - - - 2.000000000000000 - - - 0.100000000000000 - - - 1.600000000000000 - - - - - - - bar - - - 2.000000000000000 - - - 0.100000000000000 - - - 1.400000000000000 - - - - - - - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - verbatim diveplan - - - - - - - In dive plan, show runtime (absolute time) of stops - - - display runtime - - - true - - - - - - - true - - - In dive plan, show duration (relative time) of stops - - - display segment duration - - - false - - - - - - - In diveplan, list transitions or treat them as implicit - - - display transitions in deco - - - - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - below 75% avg. depth - - - - - - - 75%-50% avg. depth - - - - - - - 50% avg. depth - 6m/20ft - - - - - - - 6m/20ft to surface - - - - - - - Ascent rates - - - - - - - Descent rate - - - - - - - surface to the bottom - - - - - - - - 0 - 0 - - - - - 16777215 - 20 - - - - m/min - - - 1 - - - 18 - - - - - - - m/min - - - 1 - - - - - - - m/min - - - 1 - - - - - - - m/min - - - 1 - - - - - - - m/min - - - 1 - - - - - - - - + + + + + 0 + 0 + + + + <html><head/><body><p><span style=" font-weight:600;">Planning options</span></p></body></html> + + + + + + + QFrame::NoFrame + + + QFrame::Raised + + + + + + GF low + + + + + + + 1 + + + 150 + + + + + + + GF high + + + + + + + 1 + + + 150 + + + + + + + + + + Drop to first depth + + + + + + + Last Stop at 6m/20ft + + + + + + + plan backgas breaks + + + + + + + + 0 + 0 + + + + <html><head/><body><p><span style=" font-weight:600;">Dive note options</span></p></body></html> + + + + + + + In dive plan, show runtime (absolute time) of stops + + + display runtime + + + true + + + + + + + true + + + In dive plan, show duration (relative time) of stops + + + display segment duration + + + false + + + + + + + In diveplan, list transitions or treat them as implicit + + + display transitions in deco + + + + + + + + 20 + 0 + + + + Qt::Horizontal + + + + + + + verbatim diveplan + + + + + + + - verbatim_plan - display_runtime - display_duration - display_transitions lastStop backgasBreaks - descRate -- cgit v1.2.3-70-g09d2