2017-04-27 20:26:05 +02:00
|
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2016-04-04 22:02:03 -07:00
|
|
|
|
#include "desktop-widgets/diveplanner.h"
|
|
|
|
|
#include "desktop-widgets/modeldelegates.h"
|
|
|
|
|
#include "desktop-widgets/mainwindow.h"
|
|
|
|
|
#include "core/planner.h"
|
2018-06-03 22:15:19 +02:00
|
|
|
|
#include "core/qthelper.h"
|
2019-05-15 18:39:29 +02:00
|
|
|
|
#include "core/units.h"
|
2018-08-15 11:56:17 +02:00
|
|
|
|
#include "core/settings/qPrefDivePlanner.h"
|
2018-06-17 08:48:54 +02:00
|
|
|
|
#include "core/gettextfromc.h"
|
2016-08-26 16:21:42 -03:00
|
|
|
|
|
2016-04-04 22:02:03 -07:00
|
|
|
|
#include "qt-models/cylindermodel.h"
|
|
|
|
|
#include "qt-models/models.h"
|
2015-09-03 15:56:37 -03:00
|
|
|
|
#include "profile-widget/profilewidget2.h"
|
2016-04-04 22:02:03 -07:00
|
|
|
|
#include "qt-models/diveplannermodel.h"
|
2013-08-30 07:14:30 -03:00
|
|
|
|
|
2013-07-02 14:36:52 -03:00
|
|
|
|
#include <QGraphicsSceneMouseEvent>
|
2013-07-04 12:58:11 -03:00
|
|
|
|
#include <QMessageBox>
|
2018-08-29 03:08:47 -07:00
|
|
|
|
#include <QSettings>
|
2014-06-03 15:26:06 -07:00
|
|
|
|
#include <QShortcut>
|
2013-06-20 12:33:26 -03:00
|
|
|
|
|
2013-06-27 22:10:03 +08:00
|
|
|
|
#define TIME_INITIAL_MAX 30
|
|
|
|
|
|
2013-09-22 12:37:49 -07:00
|
|
|
|
#define MAX_DEPTH M_OR_FT(150, 450)
|
|
|
|
|
#define MIN_DEPTH M_OR_FT(20, 60)
|
2013-07-02 14:14:09 -03:00
|
|
|
|
|
2014-06-25 00:08:36 +02:00
|
|
|
|
#define UNIT_FACTOR ((prefs.units.length == units::METERS) ? 1000.0 / 60.0 : feet_to_mm(1.0) / 60.0)
|
|
|
|
|
|
2015-05-28 16:23:49 -03:00
|
|
|
|
static DivePlannerPointsModel* plannerModel = DivePlannerPointsModel::instance();
|
2013-06-20 12:37:41 -03:00
|
|
|
|
|
2014-02-27 20:09:57 -08:00
|
|
|
|
DiveHandler::DiveHandler() : QGraphicsEllipseItem()
|
2013-06-20 14:29:32 -03:00
|
|
|
|
{
|
2014-02-27 20:09:57 -08:00
|
|
|
|
setRect(-5, -5, 10, 10);
|
2014-05-23 19:50:09 -03:00
|
|
|
|
setFlags(ItemIgnoresTransformations | ItemIsSelectable | ItemIsMovable | ItemSendsGeometryChanges);
|
2013-06-27 19:52:58 -03:00
|
|
|
|
setBrush(Qt::white);
|
|
|
|
|
setZValue(2);
|
2015-01-18 14:34:00 -02:00
|
|
|
|
t.start();
|
2013-06-20 14:29:32 -03:00
|
|
|
|
}
|
2013-07-04 11:01:59 -03:00
|
|
|
|
|
2013-11-19 20:42:05 -02:00
|
|
|
|
int DiveHandler::parentIndex()
|
|
|
|
|
{
|
2014-05-23 22:39:51 -03:00
|
|
|
|
ProfileWidget2 *view = qobject_cast<ProfileWidget2 *>(scene()->views().first());
|
2013-11-19 20:42:05 -02:00
|
|
|
|
return view->handles.indexOf(this);
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-27 20:09:57 -08:00
|
|
|
|
void DiveHandler::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
2013-11-14 23:29:36 -02:00
|
|
|
|
{
|
|
|
|
|
QMenu m;
|
2015-09-11 15:54:17 +02:00
|
|
|
|
// Don't have a gas selection for the last point
|
2017-12-30 08:33:30 +01:00
|
|
|
|
emit released();
|
2015-09-11 15:54:17 +02:00
|
|
|
|
QModelIndex index = plannerModel->index(parentIndex(), DivePlannerPointsModel::GAS);
|
|
|
|
|
if (index.sibling(index.row() + 1, index.column()).isValid()) {
|
|
|
|
|
GasSelectionModel *model = GasSelectionModel::instance();
|
|
|
|
|
model->repopulate();
|
|
|
|
|
int rowCount = model->rowCount();
|
|
|
|
|
for (int i = 0; i < rowCount; i++) {
|
|
|
|
|
QAction *action = new QAction(&m);
|
|
|
|
|
action->setText(model->data(model->index(i, 0), Qt::DisplayRole).toString());
|
2016-07-06 22:40:28 +10:00
|
|
|
|
action->setData(i);
|
2015-09-11 15:54:17 +02:00
|
|
|
|
connect(action, SIGNAL(triggered(bool)), this, SLOT(changeGas()));
|
|
|
|
|
m.addAction(action);
|
|
|
|
|
}
|
2013-11-19 20:42:05 -02:00
|
|
|
|
}
|
2014-07-15 03:29:43 -07:00
|
|
|
|
// don't allow removing the last point
|
2015-05-28 16:23:49 -03:00
|
|
|
|
if (plannerModel->rowCount() > 1) {
|
2014-07-15 03:29:43 -07:00
|
|
|
|
m.addSeparator();
|
2018-07-03 16:52:20 +02:00
|
|
|
|
m.addAction(gettextFromC::tr("Remove this point"), this, SLOT(selfRemove()));
|
2014-07-15 03:29:43 -07:00
|
|
|
|
m.exec(event->screenPos());
|
|
|
|
|
}
|
2013-11-14 23:29:36 -02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DiveHandler::selfRemove()
|
|
|
|
|
{
|
|
|
|
|
setSelected(true);
|
2014-05-23 22:39:51 -03:00
|
|
|
|
ProfileWidget2 *view = qobject_cast<ProfileWidget2 *>(scene()->views().first());
|
2013-11-14 23:29:36 -02:00
|
|
|
|
view->keyDeleteAction();
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-19 20:42:05 -02:00
|
|
|
|
void DiveHandler::changeGas()
|
|
|
|
|
{
|
2014-02-27 20:09:57 -08:00
|
|
|
|
QAction *action = qobject_cast<QAction *>(sender());
|
2013-11-19 20:42:05 -02:00
|
|
|
|
QModelIndex index = plannerModel->index(parentIndex(), DivePlannerPointsModel::GAS);
|
2017-10-11 22:03:03 +02:00
|
|
|
|
plannerModel->gasChange(index.sibling(index.row() + 1, index.column()), action->data().toInt());
|
2013-11-19 20:42:05 -02:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-23 20:51:30 -03:00
|
|
|
|
void DiveHandler::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
2013-07-04 11:01:59 -03:00
|
|
|
|
{
|
2015-01-18 14:34:00 -02:00
|
|
|
|
if (t.elapsed() < 40)
|
|
|
|
|
return;
|
|
|
|
|
t.start();
|
|
|
|
|
|
2014-05-23 20:51:30 -03:00
|
|
|
|
ProfileWidget2 *view = qobject_cast<ProfileWidget2*>(scene()->views().first());
|
|
|
|
|
if(view->isPointOutOfBoundaries(event->scenePos()))
|
|
|
|
|
return;
|
2015-01-18 14:34:00 -02:00
|
|
|
|
|
2014-05-23 20:51:30 -03:00
|
|
|
|
QGraphicsEllipseItem::mouseMoveEvent(event);
|
|
|
|
|
emit moved();
|
2013-07-04 11:01:59 -03:00
|
|
|
|
}
|
2013-06-20 15:52:27 -03:00
|
|
|
|
|
2014-06-30 19:08:16 -03:00
|
|
|
|
void DiveHandler::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|
|
|
|
{
|
|
|
|
|
QGraphicsItem::mousePressEvent(event);
|
|
|
|
|
emit clicked();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DiveHandler::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|
|
|
|
{
|
|
|
|
|
QGraphicsItem::mouseReleaseEvent(event);
|
|
|
|
|
emit released();
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-27 20:09:57 -08:00
|
|
|
|
DivePlannerWidget::DivePlannerWidget(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f)
|
2013-10-03 11:54:25 -07:00
|
|
|
|
{
|
|
|
|
|
ui.setupUi(this);
|
2015-10-29 16:57:43 -07:00
|
|
|
|
ui.dateEdit->setDisplayFormat(prefs.date_format);
|
2014-07-11 00:06:46 +01:00
|
|
|
|
ui.tableWidget->setTitle(tr("Dive planner points"));
|
2015-05-28 16:23:49 -03:00
|
|
|
|
ui.tableWidget->setModel(plannerModel);
|
|
|
|
|
plannerModel->setRecalc(true);
|
2013-10-03 11:54:25 -07:00
|
|
|
|
ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::GAS, new AirTypesDelegate(this));
|
2018-05-08 17:26:48 +02:00
|
|
|
|
ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::DIVEMODE, new DiveTypesDelegate(this));
|
2014-07-11 00:06:46 +01:00
|
|
|
|
ui.cylinderTableWidget->setTitle(tr("Available gases"));
|
2017-03-11 11:42:50 +01:00
|
|
|
|
ui.cylinderTableWidget->setBtnToolTip(tr("Add cylinder"));
|
2013-11-10 07:06:26 +09:00
|
|
|
|
ui.cylinderTableWidget->setModel(CylindersModel::instance());
|
2018-02-10 23:28:05 +01:00
|
|
|
|
ui.waterType->setItemData(0, FRESHWATER_SALINITY);
|
|
|
|
|
ui.waterType->setItemData(1, SEAWATER_SALINITY);
|
|
|
|
|
ui.waterType->setItemData(2, EN13319_SALINITY);
|
|
|
|
|
waterTypeUpdateTexts();
|
2019-01-10 21:18:53 +01:00
|
|
|
|
|
2013-11-12 17:57:33 -02:00
|
|
|
|
QTableView *view = ui.cylinderTableWidget->view();
|
|
|
|
|
view->setColumnHidden(CylindersModel::START, true);
|
|
|
|
|
view->setColumnHidden(CylindersModel::END, true);
|
2014-03-22 15:13:58 +01:00
|
|
|
|
view->setColumnHidden(CylindersModel::DEPTH, false);
|
2014-01-15 18:52:42 +01:00
|
|
|
|
view->setItemDelegateForColumn(CylindersModel::TYPE, new TankInfoDelegate(this));
|
2015-05-28 16:23:49 -03:00
|
|
|
|
connect(ui.cylinderTableWidget, SIGNAL(addButtonClicked()), plannerModel, SLOT(addCylinder_clicked()));
|
|
|
|
|
connect(ui.tableWidget, SIGNAL(addButtonClicked()), plannerModel, SLOT(addStop()));
|
2013-11-14 17:39:35 -02:00
|
|
|
|
|
2014-02-27 20:09:57 -08:00
|
|
|
|
connect(CylindersModel::instance(), SIGNAL(dataChanged(QModelIndex, QModelIndex)),
|
2013-11-14 17:39:35 -02:00
|
|
|
|
GasSelectionModel::instance(), SLOT(repopulate()));
|
2014-02-27 20:09:57 -08:00
|
|
|
|
connect(CylindersModel::instance(), SIGNAL(rowsInserted(QModelIndex, int, int)),
|
2013-11-14 17:39:35 -02:00
|
|
|
|
GasSelectionModel::instance(), SLOT(repopulate()));
|
2014-02-27 20:09:57 -08:00
|
|
|
|
connect(CylindersModel::instance(), SIGNAL(rowsRemoved(QModelIndex, int, int)),
|
2013-11-14 17:39:35 -02:00
|
|
|
|
GasSelectionModel::instance(), SLOT(repopulate()));
|
2016-07-06 22:40:28 +10:00
|
|
|
|
connect(CylindersModel::instance(), SIGNAL(dataChanged(QModelIndex, QModelIndex)),
|
|
|
|
|
plannerModel, SLOT(emitDataChanged()));
|
2014-04-17 21:48:00 -05:00
|
|
|
|
connect(CylindersModel::instance(), SIGNAL(dataChanged(QModelIndex, QModelIndex)),
|
2014-05-21 21:38:26 -03:00
|
|
|
|
plannerModel, SIGNAL(cylinderModelEdited()));
|
2014-04-17 10:54:55 +02:00
|
|
|
|
connect(CylindersModel::instance(), SIGNAL(rowsInserted(QModelIndex, int, int)),
|
2014-05-21 21:38:26 -03:00
|
|
|
|
plannerModel, SIGNAL(cylinderModelEdited()));
|
2014-04-17 10:54:55 +02:00
|
|
|
|
connect(CylindersModel::instance(), SIGNAL(rowsRemoved(QModelIndex, int, int)),
|
2014-05-21 21:38:26 -03:00
|
|
|
|
plannerModel, SIGNAL(cylinderModelEdited()));
|
2015-06-16 14:37:02 +02:00
|
|
|
|
connect(plannerModel, SIGNAL(calculatedPlanNotes()), MainWindow::instance(), SLOT(setPlanNotes()));
|
|
|
|
|
|
2013-11-14 17:39:35 -02:00
|
|
|
|
|
2014-07-11 00:06:46 +01:00
|
|
|
|
ui.tableWidget->setBtnToolTip(tr("Add dive data point"));
|
2013-11-14 19:55:35 +01:00
|
|
|
|
connect(ui.startTime, SIGNAL(timeChanged(QTime)), plannerModel, SLOT(setStartTime(QTime)));
|
2014-06-28 08:07:28 -07:00
|
|
|
|
connect(ui.dateEdit, SIGNAL(dateChanged(QDate)), plannerModel, SLOT(setStartDate(QDate)));
|
2014-06-26 17:04:39 +02:00
|
|
|
|
connect(ui.ATMPressure, SIGNAL(valueChanged(int)), this, SLOT(atmPressureChanged(int)));
|
|
|
|
|
connect(ui.atmHeight, SIGNAL(valueChanged(int)), this, SLOT(heightChanged(int)));
|
2018-02-10 23:28:05 +01:00
|
|
|
|
connect(ui.waterType, SIGNAL(currentIndexChanged(int)), this, SLOT(waterTypeChanged(int)));
|
|
|
|
|
connect(ui.customSalinity, SIGNAL(valueChanged(double)), this, SLOT(customSalinityChanged(double)));
|
2015-05-28 16:23:49 -03:00
|
|
|
|
connect(plannerModel, SIGNAL(startTimeChanged(QDateTime)), this, SLOT(setupStartTime(QDateTime)));
|
2013-09-09 07:18:22 -03:00
|
|
|
|
|
2014-05-27 15:27:53 -07:00
|
|
|
|
// Creating (and canceling) the plan
|
2014-11-10 22:41:18 +00:00
|
|
|
|
replanButton = ui.buttonBox->addButton(tr("Save new"), QDialogButtonBox::ActionRole);
|
2014-11-04 12:15:27 +01:00
|
|
|
|
connect(replanButton, SIGNAL(clicked()), plannerModel, SLOT(saveDuplicatePlan()));
|
|
|
|
|
connect(ui.buttonBox, SIGNAL(accepted()), plannerModel, SLOT(savePlan()));
|
2013-10-03 11:54:25 -07:00
|
|
|
|
connect(ui.buttonBox, SIGNAL(rejected()), plannerModel, SLOT(cancelPlan()));
|
2014-06-03 15:26:06 -07:00
|
|
|
|
QShortcut *closeKey = new QShortcut(QKeySequence(Qt::Key_Escape), this);
|
|
|
|
|
connect(closeKey, SIGNAL(activated()), plannerModel, SLOT(cancelPlan()));
|
2013-09-16 11:38:41 -03:00
|
|
|
|
|
2014-07-11 17:42:43 -03:00
|
|
|
|
// This makes shure the spinbox gets a setMinimum(0) on it so we can't have negative time or depth.
|
2014-07-12 14:24:25 +02:00
|
|
|
|
ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::DEPTH, new SpinBoxDelegate(0, INT_MAX, 1, this));
|
|
|
|
|
ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::RUNTIME, new SpinBoxDelegate(0, INT_MAX, 1, this));
|
|
|
|
|
ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::DURATION, new SpinBoxDelegate(0, INT_MAX, 1, this));
|
2014-07-12 14:24:26 +02:00
|
|
|
|
ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::CCSETPOINT, new DoubleSpinBoxDelegate(0, 2, 0.1, this));
|
2014-07-11 17:42:43 -03:00
|
|
|
|
|
2013-09-09 07:18:22 -03:00
|
|
|
|
/* set defaults. */
|
2014-06-26 17:04:39 +02:00
|
|
|
|
ui.ATMPressure->setValue(1013);
|
|
|
|
|
ui.atmHeight->setValue(0);
|
2013-09-26 18:14:09 -03:00
|
|
|
|
|
|
|
|
|
setMinimumWidth(0);
|
|
|
|
|
setMinimumHeight(0);
|
2013-08-28 07:48:46 -03:00
|
|
|
|
}
|
|
|
|
|
|
2014-11-04 12:15:27 +01:00
|
|
|
|
void DivePlannerWidget::setReplanButton(bool replan)
|
|
|
|
|
{
|
|
|
|
|
replanButton->setVisible(replan);
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-28 08:07:28 -07:00
|
|
|
|
void DivePlannerWidget::setupStartTime(QDateTime startTime)
|
|
|
|
|
{
|
|
|
|
|
ui.startTime->setTime(startTime.time());
|
|
|
|
|
ui.dateEdit->setDate(startTime.date());
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-15 23:02:32 +01:00
|
|
|
|
void DivePlannerWidget::setSurfacePressure(int surface_pressure)
|
|
|
|
|
{
|
|
|
|
|
ui.ATMPressure->setValue(surface_pressure);
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-19 08:05:28 +02:00
|
|
|
|
void PlannerSettingsWidget::setDiveMode(int mode)
|
|
|
|
|
{
|
|
|
|
|
ui.rebreathermode->setCurrentIndex(mode);
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-15 23:02:32 +01:00
|
|
|
|
void DivePlannerWidget::setSalinity(int salinity)
|
|
|
|
|
{
|
2018-02-10 23:28:05 +01:00
|
|
|
|
bool mapped = false;
|
|
|
|
|
for (int i = 0; i < ui.waterType->count(); i++) {
|
|
|
|
|
if (salinity == ui.waterType->itemData(i).toInt()) {
|
|
|
|
|
mapped = true;
|
|
|
|
|
ui.waterType->setCurrentIndex(i);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!mapped) {
|
|
|
|
|
/* Assign to last element "custom" in combo box */
|
|
|
|
|
ui.waterType->setItemData(ui.waterType->count()-1, salinity);
|
|
|
|
|
ui.waterType->setCurrentIndex(ui.waterType->count()-1);
|
|
|
|
|
ui.customSalinity->setEnabled(true);
|
|
|
|
|
ui.customSalinity->setValue(salinity / 10000.0);
|
|
|
|
|
}
|
|
|
|
|
plannerModel->setSalinity(salinity);
|
2016-12-15 23:02:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-12-09 07:43:00 +01:00
|
|
|
|
void DivePlannerWidget::settingsChanged()
|
|
|
|
|
{
|
2014-06-27 11:43:11 +02:00
|
|
|
|
// Adopt units
|
|
|
|
|
if (get_units()->length == units::FEET) {
|
|
|
|
|
ui.atmHeight->setSuffix("ft");
|
2017-02-13 22:16:03 +01:00
|
|
|
|
ui.atmHeight->setMinimum(-300);
|
|
|
|
|
ui.atmHeight->setMaximum(10000);
|
2014-06-27 11:43:11 +02:00
|
|
|
|
} else {
|
|
|
|
|
ui.atmHeight->setSuffix(("m"));
|
2017-02-13 22:16:03 +01:00
|
|
|
|
ui.atmHeight->setMinimum(-100);
|
|
|
|
|
ui.atmHeight->setMaximum(3000);
|
2014-06-27 11:43:11 +02:00
|
|
|
|
}
|
2014-08-03 22:24:56 +02:00
|
|
|
|
ui.atmHeight->blockSignals(true);
|
2019-05-15 18:39:29 +02:00
|
|
|
|
ui.atmHeight->setValue((int) get_depth_units((int) pressure_to_altitude(plannerModel->getSurfacePressure()), NULL,NULL));
|
2014-08-03 22:24:56 +02:00
|
|
|
|
ui.atmHeight->blockSignals(false);
|
2013-12-09 07:43:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-26 17:04:39 +02:00
|
|
|
|
void DivePlannerWidget::atmPressureChanged(const int pressure)
|
2013-08-26 13:18:21 -03:00
|
|
|
|
{
|
2014-06-26 17:04:39 +02:00
|
|
|
|
plannerModel->setSurfacePressure(pressure);
|
|
|
|
|
ui.atmHeight->blockSignals(true);
|
2019-05-15 18:39:29 +02:00
|
|
|
|
ui.atmHeight->setValue((int) get_depth_units((int) pressure_to_altitude(pressure), NULL,NULL));
|
2014-06-26 17:04:39 +02:00
|
|
|
|
ui.atmHeight->blockSignals(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DivePlannerWidget::heightChanged(const int height)
|
2019-05-15 18:39:29 +02:00
|
|
|
|
{ // height is in ft or in meters
|
|
|
|
|
int pressure = (int) (altitude_to_pressure(units_to_depth((double) height).mm));
|
2014-06-26 17:04:39 +02:00
|
|
|
|
ui.ATMPressure->blockSignals(true);
|
|
|
|
|
ui.ATMPressure->setValue(pressure);
|
|
|
|
|
ui.ATMPressure->blockSignals(false);
|
|
|
|
|
plannerModel->setSurfacePressure(pressure);
|
2013-08-26 13:18:21 -03:00
|
|
|
|
}
|
|
|
|
|
|
2018-02-10 23:28:05 +01:00
|
|
|
|
void DivePlannerWidget::waterTypeUpdateTexts()
|
|
|
|
|
{
|
|
|
|
|
double density;
|
|
|
|
|
/* Do not set text in last/custom element */
|
|
|
|
|
for (int i = 0; i < ui.waterType->count()-1; i++) {
|
|
|
|
|
if (ui.waterType->itemData(i) != QVariant::Invalid) {
|
|
|
|
|
QString densityText = ui.waterType->itemText(i).split("(")[0].trimmed();
|
|
|
|
|
density = ui.waterType->itemData(i).toInt() / 10000.0;
|
|
|
|
|
densityText.append(QString(" (%L1%2)").arg(density, 0, 'f', 2).arg(tr("kg/ℓ")));
|
|
|
|
|
ui.waterType->setItemText(i, densityText);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DivePlannerWidget::waterTypeChanged(const int index)
|
|
|
|
|
{
|
|
|
|
|
ui.customSalinity->setEnabled(index == ui.waterType->count() - 1);
|
|
|
|
|
ui.customSalinity->setValue(ui.waterType->itemData(index).toInt() / 10000.0);
|
|
|
|
|
plannerModel->setSalinity(ui.waterType->itemData(index).toInt());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DivePlannerWidget::customSalinityChanged(double density)
|
2014-11-12 23:33:40 +01:00
|
|
|
|
{
|
2018-02-10 23:28:05 +01:00
|
|
|
|
if (ui.customSalinity->isEnabled()) {
|
|
|
|
|
int newSalinity = (int)(density * 10000.0);
|
|
|
|
|
ui.waterType->setItemData(ui.waterType->count() - 1, newSalinity);
|
|
|
|
|
plannerModel->setSalinity(newSalinity);
|
|
|
|
|
}
|
2014-11-12 23:33:40 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-08-19 11:13:55 -05:00
|
|
|
|
void PlannerSettingsWidget::bottomSacChanged(const double bottomSac)
|
2013-08-26 13:18:21 -03:00
|
|
|
|
{
|
2014-06-20 13:43:09 +02:00
|
|
|
|
plannerModel->setBottomSac(bottomSac);
|
2013-08-26 13:18:21 -03:00
|
|
|
|
}
|
|
|
|
|
|
2014-08-19 11:13:55 -05:00
|
|
|
|
void PlannerSettingsWidget::decoSacChanged(const double decosac)
|
2013-08-26 13:18:21 -03:00
|
|
|
|
{
|
2014-06-20 13:43:09 +02:00
|
|
|
|
plannerModel->setDecoSac(decosac);
|
2013-08-26 13:18:21 -03:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-15 15:16:51 +02:00
|
|
|
|
void PlannerSettingsWidget::disableDecoElements(int mode)
|
2015-04-26 21:40:36 +02:00
|
|
|
|
{
|
2015-08-15 15:16:51 +02:00
|
|
|
|
if (mode == RECREATIONAL) {
|
2017-11-02 20:39:58 +01:00
|
|
|
|
ui.label_gflow->setDisabled(false);
|
|
|
|
|
ui.label_gfhigh->setDisabled(false);
|
2015-08-15 15:16:51 +02:00
|
|
|
|
ui.gflow->setDisabled(false);
|
|
|
|
|
ui.gfhigh->setDisabled(false);
|
|
|
|
|
ui.lastStop->setDisabled(true);
|
|
|
|
|
ui.backgasBreaks->setDisabled(true);
|
2017-11-24 21:06:42 +01:00
|
|
|
|
ui.backgasBreaks->blockSignals(true);
|
|
|
|
|
ui.backgasBreaks->setChecked(false);
|
|
|
|
|
ui.backgasBreaks->blockSignals(false);
|
2019-01-10 21:18:53 +01:00
|
|
|
|
ui.bailout->setDisabled(true);
|
|
|
|
|
ui.bailout->blockSignals(true);
|
|
|
|
|
ui.bailout->setChecked(false);
|
|
|
|
|
ui.bailout->blockSignals(false);
|
2017-03-06 20:27:09 +01:00
|
|
|
|
ui.bottompo2->setDisabled(false);
|
2015-08-15 15:16:51 +02:00
|
|
|
|
ui.decopo2->setDisabled(true);
|
2017-11-02 20:39:58 +01:00
|
|
|
|
ui.safetystop->setDisabled(false);
|
|
|
|
|
ui.label_reserve_gas->setDisabled(false);
|
2015-08-15 15:16:51 +02:00
|
|
|
|
ui.reserve_gas->setDisabled(false);
|
2017-11-02 20:39:58 +01:00
|
|
|
|
ui.label_vpmb_conservatism->setDisabled(true);
|
2016-09-24 18:02:08 +10:00
|
|
|
|
ui.vpmb_conservatism->setDisabled(true);
|
2015-08-22 19:40:20 +02:00
|
|
|
|
ui.switch_at_req_stop->setDisabled(true);
|
|
|
|
|
ui.min_switch_duration->setDisabled(true);
|
2019-03-25 22:40:59 +01:00
|
|
|
|
ui.surface_segment->setDisabled(true);
|
2017-11-24 21:06:42 +01:00
|
|
|
|
ui.label_min_switch_duration->setDisabled(true);
|
2017-03-06 21:46:05 +01:00
|
|
|
|
ui.sacfactor->setDisabled(true);
|
|
|
|
|
ui.problemsolvingtime->setDisabled(true);
|
|
|
|
|
ui.sacfactor->blockSignals(true);
|
|
|
|
|
ui.problemsolvingtime->blockSignals(true);
|
|
|
|
|
ui.sacfactor->setValue(2.0);
|
|
|
|
|
ui.problemsolvingtime->setValue(0);
|
|
|
|
|
ui.sacfactor->blockSignals(false);
|
|
|
|
|
ui.problemsolvingtime->blockSignals(false);
|
2017-12-01 09:06:46 +11:00
|
|
|
|
ui.display_variations->setDisabled(true);
|
2015-07-07 20:29:37 +02:00
|
|
|
|
}
|
2015-08-15 15:16:51 +02:00
|
|
|
|
else if (mode == VPMB) {
|
2017-11-02 20:39:58 +01:00
|
|
|
|
ui.label_gflow->setDisabled(true);
|
|
|
|
|
ui.label_gfhigh->setDisabled(true);
|
2015-08-15 15:16:51 +02:00
|
|
|
|
ui.gflow->setDisabled(true);
|
|
|
|
|
ui.gfhigh->setDisabled(true);
|
|
|
|
|
ui.lastStop->setDisabled(false);
|
2017-11-24 21:06:42 +01:00
|
|
|
|
if (prefs.last_stop) {
|
|
|
|
|
ui.backgasBreaks->setDisabled(false);
|
|
|
|
|
ui.backgasBreaks->blockSignals(true);
|
|
|
|
|
ui.backgasBreaks->setChecked(prefs.doo2breaks);
|
|
|
|
|
ui.backgasBreaks->blockSignals(false);
|
|
|
|
|
} else {
|
|
|
|
|
ui.backgasBreaks->setDisabled(true);
|
|
|
|
|
ui.backgasBreaks->blockSignals(true);
|
|
|
|
|
ui.backgasBreaks->setChecked(false);
|
|
|
|
|
ui.backgasBreaks->blockSignals(false);
|
|
|
|
|
}
|
2019-01-10 21:18:53 +01:00
|
|
|
|
ui.bailout->setDisabled(!(displayed_dive.dc.divemode == CCR || displayed_dive.dc.divemode == PSCR));
|
2015-08-15 15:16:51 +02:00
|
|
|
|
ui.bottompo2->setDisabled(false);
|
|
|
|
|
ui.decopo2->setDisabled(false);
|
2017-11-02 20:39:58 +01:00
|
|
|
|
ui.safetystop->setDisabled(true);
|
|
|
|
|
ui.label_reserve_gas->setDisabled(true);
|
2015-08-15 15:16:51 +02:00
|
|
|
|
ui.reserve_gas->setDisabled(true);
|
2017-11-02 20:39:58 +01:00
|
|
|
|
ui.label_vpmb_conservatism->setDisabled(false);
|
2016-09-24 18:02:08 +10:00
|
|
|
|
ui.vpmb_conservatism->setDisabled(false);
|
2015-08-22 19:40:20 +02:00
|
|
|
|
ui.switch_at_req_stop->setDisabled(false);
|
|
|
|
|
ui.min_switch_duration->setDisabled(false);
|
2019-03-25 22:40:59 +01:00
|
|
|
|
ui.surface_segment->setDisabled(false);
|
2017-11-24 21:06:42 +01:00
|
|
|
|
ui.label_min_switch_duration->setDisabled(false);
|
2017-03-06 21:46:05 +01:00
|
|
|
|
ui.sacfactor->setDisabled(false);
|
|
|
|
|
ui.problemsolvingtime->setDisabled(false);
|
|
|
|
|
ui.sacfactor->setValue(prefs.sacfactor / 100.0);
|
|
|
|
|
ui.problemsolvingtime->setValue(prefs.problemsolvingtime);
|
2017-12-01 09:06:46 +11:00
|
|
|
|
ui.display_variations->setDisabled(false);
|
2015-07-07 20:29:37 +02:00
|
|
|
|
}
|
2015-08-15 15:16:51 +02:00
|
|
|
|
else if (mode == BUEHLMANN) {
|
2017-11-02 20:39:58 +01:00
|
|
|
|
ui.label_gflow->setDisabled(false);
|
|
|
|
|
ui.label_gfhigh->setDisabled(false);
|
2015-08-15 15:16:51 +02:00
|
|
|
|
ui.gflow->setDisabled(false);
|
|
|
|
|
ui.gfhigh->setDisabled(false);
|
|
|
|
|
ui.lastStop->setDisabled(false);
|
2017-11-24 21:06:42 +01:00
|
|
|
|
if (prefs.last_stop) {
|
|
|
|
|
ui.backgasBreaks->setDisabled(false);
|
|
|
|
|
ui.backgasBreaks->blockSignals(true);
|
|
|
|
|
ui.backgasBreaks->setChecked(prefs.doo2breaks);
|
|
|
|
|
ui.backgasBreaks->blockSignals(false);
|
|
|
|
|
} else {
|
|
|
|
|
ui.backgasBreaks->setDisabled(true);
|
|
|
|
|
ui.backgasBreaks->blockSignals(true);
|
|
|
|
|
ui.backgasBreaks->setChecked(false);
|
|
|
|
|
ui.backgasBreaks->blockSignals(false);
|
|
|
|
|
}
|
2019-01-10 21:18:53 +01:00
|
|
|
|
ui.bailout->setDisabled(!(displayed_dive.dc.divemode == CCR || displayed_dive.dc.divemode == PSCR));
|
2015-08-15 15:16:51 +02:00
|
|
|
|
ui.bottompo2->setDisabled(false);
|
|
|
|
|
ui.decopo2->setDisabled(false);
|
2017-11-02 20:39:58 +01:00
|
|
|
|
ui.safetystop->setDisabled(true);
|
|
|
|
|
ui.label_reserve_gas->setDisabled(true);
|
2015-08-15 15:16:51 +02:00
|
|
|
|
ui.reserve_gas->setDisabled(true);
|
2017-11-02 20:39:58 +01:00
|
|
|
|
ui.label_vpmb_conservatism->setDisabled(true);
|
2016-09-24 18:02:08 +10:00
|
|
|
|
ui.vpmb_conservatism->setDisabled(true);
|
2015-08-22 19:40:20 +02:00
|
|
|
|
ui.switch_at_req_stop->setDisabled(false);
|
|
|
|
|
ui.min_switch_duration->setDisabled(false);
|
2019-03-25 22:40:59 +01:00
|
|
|
|
ui.surface_segment->setDisabled(false);
|
2017-11-24 21:06:42 +01:00
|
|
|
|
ui.label_min_switch_duration->setDisabled(false);
|
2017-03-06 21:46:05 +01:00
|
|
|
|
ui.sacfactor->setDisabled(false);
|
|
|
|
|
ui.problemsolvingtime->setDisabled(false);
|
|
|
|
|
ui.sacfactor->setValue(prefs.sacfactor / 100.0);
|
|
|
|
|
ui.problemsolvingtime->setValue(prefs.problemsolvingtime);
|
2017-12-01 09:06:46 +11:00
|
|
|
|
ui.display_variations->setDisabled(false);
|
2015-07-07 20:29:37 +02:00
|
|
|
|
}
|
2015-04-26 21:40:36 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-02 21:00:54 +01:00
|
|
|
|
void PlannerSettingsWidget::disableBackgasBreaks(bool enabled)
|
|
|
|
|
{
|
2017-11-24 21:06:42 +01:00
|
|
|
|
if (prefs.planner_deco_mode == RECREATIONAL)
|
|
|
|
|
return;
|
|
|
|
|
|
2017-11-02 21:00:54 +01:00
|
|
|
|
if (enabled) {
|
|
|
|
|
ui.backgasBreaks->setDisabled(false);
|
|
|
|
|
ui.backgasBreaks->blockSignals(true);
|
|
|
|
|
ui.backgasBreaks->setChecked(prefs.doo2breaks);
|
|
|
|
|
ui.backgasBreaks->blockSignals(false);
|
|
|
|
|
} else {
|
|
|
|
|
ui.backgasBreaks->setDisabled(true);
|
|
|
|
|
ui.backgasBreaks->blockSignals(true);
|
|
|
|
|
ui.backgasBreaks->setChecked(false);
|
|
|
|
|
ui.backgasBreaks->blockSignals(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-03 10:06:18 +02:00
|
|
|
|
void DivePlannerWidget::printDecoPlan()
|
|
|
|
|
{
|
|
|
|
|
MainWindow::instance()->printPlan();
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-10 17:40:02 +02:00
|
|
|
|
PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f)
|
|
|
|
|
{
|
|
|
|
|
ui.setupUi(this);
|
2016-08-26 16:01:31 -03:00
|
|
|
|
|
2014-08-26 11:23:50 -07:00
|
|
|
|
plannerModel->getDiveplan().bottomsac = prefs.bottomsac;
|
|
|
|
|
plannerModel->getDiveplan().decosac = prefs.decosac;
|
2014-07-15 15:39:13 -03:00
|
|
|
|
|
2014-07-17 08:03:52 -07:00
|
|
|
|
updateUnitsUI();
|
2015-03-24 11:57:22 -10:00
|
|
|
|
ui.lastStop->setChecked(prefs.last_stop);
|
|
|
|
|
ui.verbatim_plan->setChecked(prefs.verbatim_plan);
|
|
|
|
|
ui.display_duration->setChecked(prefs.display_duration);
|
|
|
|
|
ui.display_runtime->setChecked(prefs.display_runtime);
|
|
|
|
|
ui.display_transitions->setChecked(prefs.display_transitions);
|
2017-09-18 16:10:47 +02:00
|
|
|
|
ui.display_variations->setChecked(prefs.display_variations);
|
2015-04-02 10:32:14 +02:00
|
|
|
|
ui.safetystop->setChecked(prefs.safetystop);
|
2017-02-11 20:24:18 +01:00
|
|
|
|
ui.sacfactor->setValue(prefs.sacfactor / 100.0);
|
|
|
|
|
ui.problemsolvingtime->setValue(prefs.problemsolvingtime);
|
2014-06-25 14:00:03 +02:00
|
|
|
|
ui.bottompo2->setValue(prefs.bottompo2 / 1000.0);
|
|
|
|
|
ui.decopo2->setValue(prefs.decopo2 / 1000.0);
|
2014-07-02 22:07:38 +02:00
|
|
|
|
ui.backgasBreaks->setChecked(prefs.doo2breaks);
|
2019-01-10 21:18:53 +01:00
|
|
|
|
setBailout(false);
|
|
|
|
|
setBailoutVisibility(false);
|
2014-07-16 17:32:06 -10:00
|
|
|
|
ui.drop_stone_mode->setChecked(prefs.drop_stone_mode);
|
2015-06-22 21:48:42 +10:00
|
|
|
|
ui.switch_at_req_stop->setChecked(prefs.switch_at_req_stop);
|
2015-06-19 20:25:03 +10:00
|
|
|
|
ui.min_switch_duration->setValue(prefs.min_switch_duration / 60);
|
2019-03-25 22:40:59 +01:00
|
|
|
|
ui.surface_segment->setValue(prefs.surface_segment / 60);
|
2017-01-07 03:11:19 +01:00
|
|
|
|
ui.recreational_deco->setChecked(prefs.planner_deco_mode == RECREATIONAL);
|
|
|
|
|
ui.buehlmann_deco->setChecked(prefs.planner_deco_mode == BUEHLMANN);
|
|
|
|
|
ui.vpmb_deco->setChecked(prefs.planner_deco_mode == VPMB);
|
|
|
|
|
disableDecoElements((int) prefs.planner_deco_mode);
|
2015-07-03 23:07:58 +02:00
|
|
|
|
|
2015-01-16 15:05:00 +01:00
|
|
|
|
// should be the same order as in dive_comp_type!
|
2018-07-13 18:45:58 +02:00
|
|
|
|
QStringList rebreather_modes = QStringList();
|
|
|
|
|
for (int i = 0; i < FREEDIVE; i++)
|
2018-06-17 17:55:47 +02:00
|
|
|
|
rebreather_modes.append(gettextFromC::tr(divemode_text_ui[i]));
|
2015-07-24 21:42:12 +10:00
|
|
|
|
ui.rebreathermode->insertItems(0, rebreather_modes);
|
2014-06-25 00:08:36 +02:00
|
|
|
|
|
2015-07-03 23:07:58 +02:00
|
|
|
|
modeMapper = new QSignalMapper(this);
|
|
|
|
|
connect(modeMapper, SIGNAL(mapped(int)) , plannerModel, SLOT(setDecoMode(int)));
|
|
|
|
|
modeMapper->setMapping(ui.recreational_deco, int(RECREATIONAL));
|
|
|
|
|
modeMapper->setMapping(ui.buehlmann_deco, int(BUEHLMANN));
|
|
|
|
|
modeMapper->setMapping(ui.vpmb_deco, int(VPMB));
|
2015-09-03 15:56:37 -03:00
|
|
|
|
|
2015-07-03 23:07:58 +02:00
|
|
|
|
connect(ui.recreational_deco, SIGNAL(clicked()), modeMapper, SLOT(map()));
|
|
|
|
|
connect(ui.buehlmann_deco, SIGNAL(clicked()), modeMapper, SLOT(map()));
|
|
|
|
|
connect(ui.vpmb_deco, SIGNAL(clicked()), modeMapper, SLOT(map()));
|
2015-09-03 15:56:37 -03:00
|
|
|
|
|
2014-06-10 17:40:02 +02:00
|
|
|
|
connect(ui.lastStop, SIGNAL(toggled(bool)), plannerModel, SLOT(setLastStop6m(bool)));
|
2017-11-02 21:00:54 +01:00
|
|
|
|
connect(ui.lastStop, SIGNAL(toggled(bool)), this, SLOT(disableBackgasBreaks(bool)));
|
2014-06-10 17:40:02 +02:00
|
|
|
|
connect(ui.verbatim_plan, SIGNAL(toggled(bool)), plannerModel, SLOT(setVerbatim(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_transitions, SIGNAL(toggled(bool)), plannerModel, SLOT(setDisplayTransitions(bool)));
|
2017-09-18 16:10:47 +02:00
|
|
|
|
connect(ui.display_variations, SIGNAL(toggled(bool)), plannerModel, SLOT(setDisplayVariations(bool)));
|
2015-04-02 10:32:14 +02:00
|
|
|
|
connect(ui.safetystop, SIGNAL(toggled(bool)), plannerModel, SLOT(setSafetyStop(bool)));
|
2015-04-09 17:41:41 +02:00
|
|
|
|
connect(ui.reserve_gas, SIGNAL(valueChanged(int)), plannerModel, SLOT(setReserveGas(int)));
|
2017-10-03 10:06:15 +02:00
|
|
|
|
connect(ui.ascRate75, SIGNAL(valueChanged(int)), plannerModel, SLOT(setAscrate75(int)));
|
|
|
|
|
connect(ui.ascRate50, SIGNAL(valueChanged(int)), plannerModel, SLOT(setAscrate50(int)));
|
|
|
|
|
connect(ui.ascRateStops, SIGNAL(valueChanged(int)), plannerModel, SLOT(setAscratestops(int)));
|
|
|
|
|
connect(ui.ascRateLast6m, SIGNAL(valueChanged(int)), plannerModel, SLOT(setAscratelast6m(int)));
|
|
|
|
|
connect(ui.descRate, SIGNAL(valueChanged(int)), plannerModel, SLOT(setDescrate(int)));
|
2014-06-26 17:04:39 +02:00
|
|
|
|
connect(ui.drop_stone_mode, SIGNAL(toggled(bool)), plannerModel, SLOT(setDropStoneMode(bool)));
|
|
|
|
|
connect(ui.gfhigh, SIGNAL(valueChanged(int)), plannerModel, SLOT(setGFHigh(int)));
|
|
|
|
|
connect(ui.gflow, SIGNAL(valueChanged(int)), plannerModel, SLOT(setGFLow(int)));
|
2016-09-24 18:02:08 +10:00
|
|
|
|
connect(ui.vpmb_conservatism, SIGNAL(valueChanged(int)), plannerModel, SLOT(setVpmbConservatism(int)));
|
2014-07-02 22:07:38 +02:00
|
|
|
|
connect(ui.backgasBreaks, SIGNAL(toggled(bool)), this, SLOT(setBackgasBreaks(bool)));
|
2019-01-10 21:18:53 +01:00
|
|
|
|
connect(ui.bailout, SIGNAL(toggled(bool)), this, SLOT(setBailout(bool)));
|
2015-06-22 21:48:42 +10:00
|
|
|
|
connect(ui.switch_at_req_stop, SIGNAL(toggled(bool)), plannerModel, SLOT(setSwitchAtReqStop(bool)));
|
2015-06-19 20:25:03 +10:00
|
|
|
|
connect(ui.min_switch_duration, SIGNAL(valueChanged(int)), plannerModel, SLOT(setMinSwitchDuration(int)));
|
2019-03-25 22:40:59 +01:00
|
|
|
|
connect(ui.surface_segment, SIGNAL(valueChanged(int)), plannerModel, SLOT(setSurfaceSegment(int)));
|
2015-01-16 15:05:00 +01:00
|
|
|
|
connect(ui.rebreathermode, SIGNAL(currentIndexChanged(int)), plannerModel, SLOT(setRebreatherMode(int)));
|
2019-01-10 21:18:53 +01:00
|
|
|
|
connect(ui.rebreathermode, SIGNAL(currentIndexChanged(int)), this, SLOT(setBailoutVisibility(int)));
|
2016-08-26 16:04:34 -03:00
|
|
|
|
|
2017-02-21 14:37:18 +01:00
|
|
|
|
connect(ui.bottompo2, SIGNAL(valueChanged(double)), CylindersModel::instance(), SLOT(updateBestMixes()));
|
|
|
|
|
connect(ui.bestmixEND, SIGNAL(valueChanged(int)), CylindersModel::instance(), SLOT(updateBestMixes()));
|
2016-08-26 16:04:34 -03:00
|
|
|
|
|
2015-08-15 15:16:51 +02:00
|
|
|
|
connect(modeMapper, SIGNAL(mapped(int)), this, SLOT(disableDecoElements(int)));
|
2017-10-03 10:06:15 +02:00
|
|
|
|
connect(ui.ascRate75, SIGNAL(valueChanged(int)), this, SLOT(setAscrate75(int)));
|
|
|
|
|
connect(ui.ascRate50, SIGNAL(valueChanged(int)), this, SLOT(setAscrate50(int)));
|
|
|
|
|
connect(ui.descRate, SIGNAL(valueChanged(int)), this, SLOT(setDescrate(int)));
|
|
|
|
|
connect(ui.ascRateStops, SIGNAL(valueChanged(int)), this, SLOT(setAscratestops(int)));
|
|
|
|
|
connect(ui.ascRateLast6m, SIGNAL(valueChanged(int)), this, SLOT(setAscratelast6m(int)));
|
2017-02-11 20:24:18 +01:00
|
|
|
|
connect(ui.sacfactor, SIGNAL(valueChanged(double)), this, SLOT(sacFactorChanged(double)));
|
|
|
|
|
connect(ui.problemsolvingtime, SIGNAL(valueChanged(int)), this, SLOT(problemSolvingTimeChanged(int)));
|
2016-08-26 16:04:34 -03:00
|
|
|
|
connect(ui.bottompo2, SIGNAL(valueChanged(double)), this, SLOT(setBottomPo2(double)));
|
|
|
|
|
connect(ui.decopo2, SIGNAL(valueChanged(double)), this, SLOT(setDecoPo2(double)));
|
|
|
|
|
connect(ui.bestmixEND, SIGNAL(valueChanged(int)), this, SLOT(setBestmixEND(int)));
|
|
|
|
|
connect(ui.bottomSAC, SIGNAL(valueChanged(double)), this, SLOT(bottomSacChanged(double)));
|
|
|
|
|
connect(ui.decoStopSAC, SIGNAL(valueChanged(double)), this, SLOT(decoSacChanged(double)));
|
2015-04-26 21:40:36 +02:00
|
|
|
|
|
2014-08-19 11:13:55 -05:00
|
|
|
|
settingsChanged();
|
2014-06-26 17:04:39 +02:00
|
|
|
|
ui.gflow->setValue(prefs.gflow);
|
|
|
|
|
ui.gfhigh->setValue(prefs.gfhigh);
|
2016-09-24 18:02:08 +10:00
|
|
|
|
ui.vpmb_conservatism->setValue(prefs.vpmb_conservatism);
|
2014-06-10 17:40:02 +02:00
|
|
|
|
|
2017-10-07 12:50:10 +02:00
|
|
|
|
ui.ascRate75->setKeyboardTracking(false);
|
|
|
|
|
ui.ascRate50->setKeyboardTracking(false);
|
|
|
|
|
ui.ascRateLast6m->setKeyboardTracking(false);
|
|
|
|
|
ui.ascRateStops->setKeyboardTracking(false);
|
|
|
|
|
ui.descRate->setKeyboardTracking(false);
|
|
|
|
|
ui.gfhigh->setKeyboardTracking(false);
|
|
|
|
|
ui.gflow->setKeyboardTracking(false);
|
|
|
|
|
|
2014-06-10 17:40:02 +02:00
|
|
|
|
setMinimumWidth(0);
|
|
|
|
|
setMinimumHeight(0);
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-17 08:03:52 -07:00
|
|
|
|
void PlannerSettingsWidget::updateUnitsUI()
|
|
|
|
|
{
|
2017-03-08 13:41:41 +07:00
|
|
|
|
ui.ascRate75->setValue(lrint(prefs.ascrate75 / UNIT_FACTOR));
|
|
|
|
|
ui.ascRate50->setValue(lrint(prefs.ascrate50 / UNIT_FACTOR));
|
|
|
|
|
ui.ascRateStops->setValue(lrint(prefs.ascratestops / UNIT_FACTOR));
|
|
|
|
|
ui.ascRateLast6m->setValue(lrint(prefs.ascratelast6m / UNIT_FACTOR));
|
|
|
|
|
ui.descRate->setValue(lrint(prefs.descrate / UNIT_FACTOR));
|
|
|
|
|
ui.bestmixEND->setValue(lrint(get_depth_units(prefs.bestmixend.mm, NULL, NULL)));
|
2014-07-17 08:03:52 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-15 15:39:13 -03:00
|
|
|
|
PlannerSettingsWidget::~PlannerSettingsWidget()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-10 17:40:02 +02:00
|
|
|
|
void PlannerSettingsWidget::settingsChanged()
|
|
|
|
|
{
|
2014-07-17 09:43:58 +04:00
|
|
|
|
QString vs;
|
2014-08-19 11:13:55 -05:00
|
|
|
|
// don't recurse into setting the value from the ui when setting the ui from the value
|
|
|
|
|
ui.bottomSAC->blockSignals(true);
|
|
|
|
|
ui.decoStopSAC->blockSignals(true);
|
2014-06-27 11:43:11 +02:00
|
|
|
|
if (get_units()->length == units::FEET) {
|
2014-07-17 09:43:58 +04:00
|
|
|
|
vs.append(tr("ft/min"));
|
2014-06-27 11:43:11 +02:00
|
|
|
|
ui.lastStop->setText(tr("Last stop at 20ft"));
|
2014-07-17 19:45:55 +02:00
|
|
|
|
ui.asc50to6->setText(tr("50% avg. depth to 20ft"));
|
|
|
|
|
ui.asc6toSurf->setText(tr("20ft to surface"));
|
2016-05-21 20:14:23 +10:00
|
|
|
|
ui.bestmixEND->setSuffix(tr("ft"));
|
2014-06-27 11:43:11 +02:00
|
|
|
|
} else {
|
2014-07-17 09:43:58 +04:00
|
|
|
|
vs.append(tr("m/min"));
|
2014-06-27 11:43:11 +02:00
|
|
|
|
ui.lastStop->setText(tr("Last stop at 6m"));
|
2014-07-17 19:45:55 +02:00
|
|
|
|
ui.asc50to6->setText(tr("50% avg. depth to 6m"));
|
|
|
|
|
ui.asc6toSurf->setText(tr("6m to surface"));
|
2016-05-21 20:14:23 +10:00
|
|
|
|
ui.bestmixEND->setSuffix(tr("m"));
|
2014-06-27 11:43:11 +02:00
|
|
|
|
}
|
2014-08-06 10:16:12 +02:00
|
|
|
|
if(get_units()->volume == units::CUFT) {
|
|
|
|
|
ui.bottomSAC->setSuffix(tr("cuft/min"));
|
|
|
|
|
ui.decoStopSAC->setSuffix(tr("cuft/min"));
|
2014-08-19 11:13:55 -05:00
|
|
|
|
ui.bottomSAC->setDecimals(2);
|
|
|
|
|
ui.bottomSAC->setSingleStep(0.1);
|
|
|
|
|
ui.decoStopSAC->setDecimals(2);
|
|
|
|
|
ui.decoStopSAC->setSingleStep(0.1);
|
|
|
|
|
ui.bottomSAC->setValue(ml_to_cuft(prefs.bottomsac));
|
|
|
|
|
ui.decoStopSAC->setValue(ml_to_cuft(prefs.decosac));
|
2014-08-06 10:16:12 +02:00
|
|
|
|
} else {
|
|
|
|
|
ui.bottomSAC->setSuffix(tr("ℓ/min"));
|
|
|
|
|
ui.decoStopSAC->setSuffix(tr("ℓ/min"));
|
2014-08-19 11:13:55 -05:00
|
|
|
|
ui.bottomSAC->setDecimals(0);
|
|
|
|
|
ui.bottomSAC->setSingleStep(1);
|
|
|
|
|
ui.decoStopSAC->setDecimals(0);
|
|
|
|
|
ui.decoStopSAC->setSingleStep(1);
|
|
|
|
|
ui.bottomSAC->setValue((double) prefs.bottomsac / 1000.0);
|
|
|
|
|
ui.decoStopSAC->setValue((double) prefs.decosac / 1000.0);
|
2014-08-06 10:16:12 +02:00
|
|
|
|
}
|
2016-03-22 23:44:59 +01:00
|
|
|
|
if(get_units()->pressure == units::BAR) {
|
|
|
|
|
ui.reserve_gas->setSuffix(tr("bar"));
|
|
|
|
|
ui.reserve_gas->setSingleStep(1);
|
|
|
|
|
ui.reserve_gas->setValue(prefs.reserve_gas / 1000);
|
2016-03-23 16:59:18 +01:00
|
|
|
|
ui.reserve_gas->setMaximum(300);
|
2016-03-22 23:44:59 +01:00
|
|
|
|
} else {
|
|
|
|
|
ui.reserve_gas->setSuffix(tr("psi"));
|
|
|
|
|
ui.reserve_gas->setSingleStep(10);
|
2016-03-23 16:59:18 +01:00
|
|
|
|
ui.reserve_gas->setMaximum(5000);
|
2016-03-22 23:44:59 +01:00
|
|
|
|
ui.reserve_gas->setValue(mbar_to_PSI(prefs.reserve_gas));
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-19 11:13:55 -05:00
|
|
|
|
ui.bottomSAC->blockSignals(false);
|
|
|
|
|
ui.decoStopSAC->blockSignals(false);
|
2014-07-17 08:03:52 -07:00
|
|
|
|
updateUnitsUI();
|
2014-07-17 09:43:58 +04:00
|
|
|
|
ui.ascRate75->setSuffix(vs);
|
|
|
|
|
ui.ascRate50->setSuffix(vs);
|
|
|
|
|
ui.ascRateStops->setSuffix(vs);
|
|
|
|
|
ui.ascRateLast6m->setSuffix(vs);
|
|
|
|
|
ui.descRate->setSuffix(vs);
|
2014-06-10 17:40:02 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PlannerSettingsWidget::printDecoPlan()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-03 10:06:15 +02:00
|
|
|
|
void PlannerSettingsWidget::setAscrate75(int rate)
|
2014-06-25 00:08:36 +02:00
|
|
|
|
{
|
2018-08-01 21:41:42 +02:00
|
|
|
|
qPrefDivePlanner::instance()->set_ascrate75(lrint(rate * UNIT_FACTOR));
|
2014-06-25 00:08:36 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-03 10:06:15 +02:00
|
|
|
|
void PlannerSettingsWidget::setAscrate50(int rate)
|
2014-06-25 00:08:36 +02:00
|
|
|
|
{
|
2018-08-01 21:41:42 +02:00
|
|
|
|
qPrefDivePlanner::instance()->set_ascrate50(lrint(rate * UNIT_FACTOR));
|
2014-06-25 00:08:36 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-03 10:06:15 +02:00
|
|
|
|
void PlannerSettingsWidget::setAscratestops(int rate)
|
2014-06-25 00:08:36 +02:00
|
|
|
|
{
|
2018-08-01 21:41:42 +02:00
|
|
|
|
qPrefDivePlanner::instance()->set_ascratestops(lrint(rate * UNIT_FACTOR));
|
2014-06-25 00:08:36 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-03 10:06:15 +02:00
|
|
|
|
void PlannerSettingsWidget::setAscratelast6m(int rate)
|
2014-06-25 00:08:36 +02:00
|
|
|
|
{
|
2018-08-01 21:41:42 +02:00
|
|
|
|
qPrefDivePlanner::instance()->set_ascratelast6m(lrint(rate * UNIT_FACTOR));
|
2014-06-25 00:08:36 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-03 10:06:15 +02:00
|
|
|
|
void PlannerSettingsWidget::setDescrate(int rate)
|
2014-06-25 00:08:36 +02:00
|
|
|
|
{
|
2018-08-01 21:41:42 +02:00
|
|
|
|
qPrefDivePlanner::instance()->set_descrate(lrint(rate * UNIT_FACTOR));
|
2014-06-25 00:08:36 +02:00
|
|
|
|
}
|
2014-06-10 17:40:02 +02:00
|
|
|
|
|
2017-02-11 20:24:18 +01:00
|
|
|
|
void PlannerSettingsWidget::sacFactorChanged(const double factor)
|
|
|
|
|
{
|
2017-05-27 11:05:38 -07:00
|
|
|
|
plannerModel->setSacFactor(factor);
|
2017-02-11 20:24:18 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PlannerSettingsWidget::problemSolvingTimeChanged(const int minutes)
|
|
|
|
|
{
|
|
|
|
|
plannerModel->setProblemSolvingTime(minutes);
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-25 14:00:03 +02:00
|
|
|
|
void PlannerSettingsWidget::setBottomPo2(double po2)
|
|
|
|
|
{
|
2018-08-01 21:41:42 +02:00
|
|
|
|
qPrefDivePlanner::instance()->set_bottompo2((int) (po2 * 1000.0));
|
2014-06-25 14:00:03 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PlannerSettingsWidget::setDecoPo2(double po2)
|
|
|
|
|
{
|
2016-07-06 22:40:30 +10:00
|
|
|
|
pressure_t olddecopo2;
|
|
|
|
|
olddecopo2.mbar = prefs.decopo2;
|
2018-08-01 21:41:42 +02:00
|
|
|
|
qPrefDivePlanner::instance()->set_decopo2((int) (po2 * 1000.0));
|
2016-07-06 22:40:30 +10:00
|
|
|
|
CylindersModel::instance()->updateDecoDepths(olddecopo2);
|
2014-06-25 14:00:03 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-05-21 20:14:23 +10:00
|
|
|
|
void PlannerSettingsWidget::setBestmixEND(int depth)
|
2016-05-21 19:32:09 +10:00
|
|
|
|
{
|
2018-09-08 16:44:51 +02:00
|
|
|
|
qPrefDivePlanner::instance()->set_bestmixend(units_to_depth(depth).mm);
|
2016-05-21 19:32:09 +10:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-02 22:07:38 +02:00
|
|
|
|
void PlannerSettingsWidget::setBackgasBreaks(bool dobreaks)
|
|
|
|
|
{
|
2018-08-01 21:41:42 +02:00
|
|
|
|
qPrefDivePlanner::instance()->set_doo2breaks(dobreaks);
|
2014-07-09 15:02:15 +02:00
|
|
|
|
plannerModel->emitDataChanged();
|
2014-07-02 22:07:38 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-10 21:18:53 +01:00
|
|
|
|
void PlannerSettingsWidget::setBailout(bool dobailout)
|
|
|
|
|
{
|
|
|
|
|
qPrefDivePlanner::instance()->set_dobailout(dobailout);
|
|
|
|
|
plannerModel->emitDataChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PlannerSettingsWidget::setBailoutVisibility(int mode)
|
|
|
|
|
{
|
|
|
|
|
ui.bailout->setDisabled(!(mode == CCR || mode == PSCR));
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-09 16:37:26 -02:00
|
|
|
|
PlannerDetails::PlannerDetails(QWidget *parent) : QWidget(parent)
|
|
|
|
|
{
|
|
|
|
|
ui.setupUi(this);
|
|
|
|
|
}
|