diff --git a/dive.h b/dive.h index 70c418706..482af6fa7 100644 --- a/dive.h +++ b/dive.h @@ -766,6 +766,7 @@ struct diveplan { int surface_pressure; /* mbar */ int bottomsac; /* ml/min */ int decosac; /* ml/min */ + int salinity; short gflow; short gfhigh; struct divedatapoint *dp; diff --git a/planner.c b/planner.c index a4181907e..6f09b8e5f 100644 --- a/planner.c +++ b/planner.c @@ -259,6 +259,7 @@ static void create_dive_from_plan(struct diveplan *diveplan, bool track_gas) printf("in create_dive_from_plan\n"); dump_plan(diveplan); #endif + displayed_dive.salinity = diveplan->salinity; // reset the cylinders and clear out the samples and events of the // displayed dive so we can restart reset_cylinders(&displayed_dive, track_gas); diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index d825c6e84..b8d251c2c 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -297,6 +297,7 @@ DivePlannerWidget::DivePlannerWidget(QWidget *parent, Qt::WindowFlags f) : QWidg connect(ui.dateEdit, SIGNAL(dateChanged(QDate)), plannerModel, SLOT(setStartDate(QDate))); connect(ui.ATMPressure, SIGNAL(valueChanged(int)), this, SLOT(atmPressureChanged(int))); connect(ui.atmHeight, SIGNAL(valueChanged(int)), this, SLOT(heightChanged(int))); + connect(ui.salinity, SIGNAL(valueChanged(double)), this, SLOT(salinityChanged(double))); connect(DivePlannerPointsModel::instance(), SIGNAL(startTimeChanged(QDateTime)), this, SLOT(setupStartTime(QDateTime))); // Creating (and canceling) the plan @@ -367,6 +368,12 @@ void DivePlannerWidget::heightChanged(const int height) plannerModel->setSurfacePressure(pressure); } +void DivePlannerWidget::salinityChanged(const double salinity) +{ + /* Salinity is expressed in weight in grams per 10l */ + plannerModel->setSalinity(10000 * salinity); +} + void PlannerSettingsWidget::bottomSacChanged(const double bottomSac) { plannerModel->setBottomSac(bottomSac); @@ -786,6 +793,12 @@ void DivePlannerPointsModel::setSurfacePressure(int pressure) emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1)); } +void DivePlannerPointsModel::setSalinity(int salinity) +{ + diveplan.salinity = salinity; + emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1)); +} + int DivePlannerPointsModel::getSurfacePressure() { return diveplan.surface_pressure; diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h index c613ae210..bca0deb78 100644 --- a/qt-ui/diveplanner.h +++ b/qt-ui/diveplanner.h @@ -70,6 +70,7 @@ slots: void setGFLow(const int ghflow); void triggerGFLow(); void setSurfacePressure(int pressure); + void setSalinity(int salinity); int getSurfacePressure(); void setBottomSac(double sac); void setDecoSac(double sac); @@ -146,6 +147,7 @@ slots: void settingsChanged(); void atmPressureChanged(const int pressure); void heightChanged(const int height); + void salinityChanged(const double salinity); void printDecoPlan(); private: diff --git a/qt-ui/diveplanner.ui b/qt-ui/diveplanner.ui index 54abcc35a..0edd742fa 100644 --- a/qt-ui/diveplanner.ui +++ b/qt-ui/diveplanner.ui @@ -65,7 +65,7 @@ 2 - + @@ -81,7 +81,7 @@ - + @@ -110,7 +110,30 @@ + + + + + 0 + 0 + + + + true + + + + + + + 0 + 0 + + + + + @@ -123,33 +146,6 @@ - - - - - - - 0 - 0 - - - - true - - - - - - - - 0 - 0 - - - - - - @@ -164,8 +160,21 @@ + + + + Salinity + + + + + + 0 + 0 + + mbar @@ -179,6 +188,12 @@ + + + 0 + 0 + + m @@ -193,6 +208,31 @@ + + + + + 0 + 0 + + + + kg/ℓ + + + 1.000000000000000 + + + 1.050000000000000 + + + 0.010000000000000 + + + 1.030000000000000 + + +