2017-04-27 18:25:32 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2015-05-28 19:23:49 +00:00
|
|
|
#ifndef DIVEPLANNERMODEL_H
|
|
|
|
#define DIVEPLANNERMODEL_H
|
|
|
|
|
|
|
|
#include <QAbstractTableModel>
|
|
|
|
#include <QDateTime>
|
2022-02-19 10:58:36 +00:00
|
|
|
#include <vector>
|
2015-05-28 19:23:49 +00:00
|
|
|
|
2019-08-05 18:43:06 +00:00
|
|
|
#include "core/deco.h"
|
2022-11-06 16:10:37 +00:00
|
|
|
#include "core/divemode.h"
|
2019-08-05 18:43:06 +00:00
|
|
|
#include "core/planner.h"
|
2020-02-03 17:52:17 +00:00
|
|
|
#include "qt-models/cylindermodel.h"
|
2015-05-28 19:23:49 +00:00
|
|
|
|
|
|
|
class DivePlannerPointsModel : public QAbstractTableModel {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
static DivePlannerPointsModel *instance();
|
|
|
|
enum Sections {
|
|
|
|
REMOVE,
|
|
|
|
DEPTH,
|
|
|
|
DURATION,
|
|
|
|
RUNTIME,
|
|
|
|
GAS,
|
|
|
|
CCSETPOINT,
|
2018-03-28 20:50:28 +00:00
|
|
|
DIVEMODE,
|
2015-05-28 19:23:49 +00:00
|
|
|
COLUMNS
|
|
|
|
};
|
|
|
|
enum Mode {
|
|
|
|
NOTHING,
|
|
|
|
PLAN,
|
|
|
|
ADD
|
|
|
|
};
|
2018-09-29 20:13:44 +00:00
|
|
|
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
|
|
|
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
|
|
|
|
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
2017-10-11 20:03:03 +00:00
|
|
|
void gasChange(const QModelIndex &index, int newcylinderid);
|
2017-10-11 19:27:06 +00:00
|
|
|
void cylinderRenumber(int mapping[]);
|
2022-02-19 10:58:36 +00:00
|
|
|
void removeSelectedPoints(const std::vector<int> &rows);
|
2015-05-28 19:23:49 +00:00
|
|
|
void setPlanMode(Mode mode);
|
2021-01-23 10:28:19 +00:00
|
|
|
bool isPlanner() const;
|
2021-01-26 06:48:22 +00:00
|
|
|
void createSimpleDive(struct dive *d);
|
2015-05-28 19:23:49 +00:00
|
|
|
Mode currentMode() const;
|
2021-01-23 10:28:19 +00:00
|
|
|
bool tankInUse(int cylinderid) const;
|
2020-02-03 17:59:12 +00:00
|
|
|
CylindersModel *cylindersModel();
|
2020-01-19 17:19:14 +00:00
|
|
|
|
2021-01-23 10:28:19 +00:00
|
|
|
int ascrate75Display() const;
|
|
|
|
int ascrate50Display() const;
|
|
|
|
int ascratestopsDisplay() const;
|
|
|
|
int ascratelast6mDisplay() const;
|
|
|
|
int descrateDisplay() const;
|
|
|
|
int getSurfacePressure() const;
|
2024-01-25 12:18:26 +00:00
|
|
|
int gfLow() const;
|
|
|
|
int gfHigh() const;
|
2020-01-19 17:19:14 +00:00
|
|
|
|
2015-05-28 19:23:49 +00:00
|
|
|
/**
|
|
|
|
* @return the row number.
|
|
|
|
*/
|
|
|
|
void editStop(int row, divedatapoint newData);
|
2021-01-23 10:28:19 +00:00
|
|
|
divedatapoint at(int row) const;
|
2015-05-28 19:23:49 +00:00
|
|
|
struct diveplan &getDiveplan();
|
2017-11-24 13:17:01 +00:00
|
|
|
struct deco_state final_deco_state;
|
2015-05-28 19:23:49 +00:00
|
|
|
|
2022-05-21 20:08:46 +00:00
|
|
|
void loadFromDive(dive *d, int dcNr);
|
2021-02-27 18:42:42 +00:00
|
|
|
void addStop(int millimeters, int seconds);
|
2015-05-28 19:23:49 +00:00
|
|
|
public
|
|
|
|
slots:
|
2021-01-23 10:41:42 +00:00
|
|
|
void addDefaultStop();
|
2015-05-28 19:23:49 +00:00
|
|
|
void addCylinder_clicked();
|
|
|
|
void setGFHigh(const int gfhigh);
|
2017-12-19 18:15:53 +00:00
|
|
|
void setGFLow(const int gflow);
|
2016-09-24 08:02:07 +00:00
|
|
|
void setVpmbConservatism(int level);
|
2015-05-28 19:23:49 +00:00
|
|
|
void setSurfacePressure(int pressure);
|
|
|
|
void setSalinity(int salinity);
|
|
|
|
void setBottomSac(double sac);
|
|
|
|
void setDecoSac(double sac);
|
|
|
|
void setStartTime(const QTime &t);
|
|
|
|
void setStartDate(const QDate &date);
|
|
|
|
void setLastStop6m(bool value);
|
|
|
|
void setDropStoneMode(bool value);
|
|
|
|
void setVerbatim(bool value);
|
|
|
|
void setDisplayRuntime(bool value);
|
|
|
|
void setDisplayDuration(bool value);
|
|
|
|
void setDisplayTransitions(bool value);
|
2017-09-18 14:10:47 +00:00
|
|
|
void setDisplayVariations(bool value);
|
2015-07-03 21:07:58 +00:00
|
|
|
void setDecoMode(int mode);
|
2015-05-28 19:23:49 +00:00
|
|
|
void setSafetyStop(bool value);
|
|
|
|
void savePlan();
|
|
|
|
void saveDuplicatePlan();
|
|
|
|
void remove(const QModelIndex &index);
|
2021-03-02 09:54:36 +00:00
|
|
|
void removeControlPressed(const QModelIndex &index);
|
2015-05-28 19:23:49 +00:00
|
|
|
void cancelPlan();
|
2021-02-25 21:35:32 +00:00
|
|
|
void removeDeco();
|
2015-05-28 19:23:49 +00:00
|
|
|
void deleteTemporaryPlan();
|
|
|
|
void emitDataChanged();
|
|
|
|
void setRebreatherMode(int mode);
|
|
|
|
void setReserveGas(int reserve);
|
2015-06-22 11:48:42 +00:00
|
|
|
void setSwitchAtReqStop(bool value);
|
2015-06-19 10:25:03 +00:00
|
|
|
void setMinSwitchDuration(int duration);
|
2019-03-25 21:40:59 +00:00
|
|
|
void setSurfaceSegment(int duration);
|
2017-02-11 19:24:18 +00:00
|
|
|
void setSacFactor(double factor);
|
|
|
|
void setProblemSolvingTime(int minutes);
|
2020-01-20 09:48:31 +00:00
|
|
|
void setAscrate75Display(int rate);
|
|
|
|
void setAscrate50Display(int rate);
|
|
|
|
void setAscratestopsDisplay(int rate);
|
|
|
|
void setAscratelast6mDisplay(int rate);
|
|
|
|
void setDescrateDisplay(int rate);
|
2015-05-28 19:23:49 +00:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void planCreated();
|
|
|
|
void planCanceled();
|
|
|
|
void cylinderModelEdited();
|
|
|
|
void recreationChanged(bool);
|
2020-04-13 13:09:35 +00:00
|
|
|
void calculatedPlanNotes(QString);
|
2017-11-27 16:36:21 +00:00
|
|
|
void variationsComputed(QString);
|
2015-05-28 19:23:49 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
explicit DivePlannerPointsModel(QObject *parent = 0);
|
2021-01-25 20:45:29 +00:00
|
|
|
void clear();
|
2021-02-27 18:42:42 +00:00
|
|
|
int addStop(int millimeters, int seconds, int cylinderid_in, int ccpoint, bool entered, enum divemode_t);
|
2022-02-19 10:58:36 +00:00
|
|
|
void removePoints(const std::vector<int> &rows);
|
2021-01-19 20:20:01 +00:00
|
|
|
void setupStartTime();
|
|
|
|
void setupCylinders();
|
2021-01-23 10:28:19 +00:00
|
|
|
int lastEnteredPoint() const;
|
2021-01-19 20:20:01 +00:00
|
|
|
bool updateMaxDepth();
|
2015-05-28 19:23:49 +00:00
|
|
|
void createPlan(bool replanCopy);
|
2021-02-27 21:06:05 +00:00
|
|
|
void updateDiveProfile(); // Creates a temporary plan and updates the dive profile with it.
|
|
|
|
void createTemporaryPlan();
|
2015-05-28 19:23:49 +00:00
|
|
|
struct diveplan diveplan;
|
2017-11-27 16:36:21 +00:00
|
|
|
struct divedatapoint *cloneDiveplan(struct diveplan *plan_src, struct diveplan *plan_copy);
|
2020-04-13 12:46:15 +00:00
|
|
|
void computeVariationsDone(QString text);
|
2019-10-17 20:56:40 +00:00
|
|
|
void computeVariations(struct diveplan *diveplan, const struct deco_state *ds);
|
|
|
|
void computeVariationsFreeDeco(struct diveplan *diveplan, struct deco_state *ds);
|
2017-08-29 10:26:00 +00:00
|
|
|
int analyzeVariations(struct decostop *min, struct decostop *mid, struct decostop *max, const char *unit);
|
2021-01-26 06:48:22 +00:00
|
|
|
struct dive *d;
|
2022-05-21 20:08:46 +00:00
|
|
|
int dcNr;
|
2020-02-03 17:59:12 +00:00
|
|
|
CylindersModel cylinders;
|
2015-05-28 19:23:49 +00:00
|
|
|
Mode mode;
|
|
|
|
QVector<divedatapoint> divepoints;
|
|
|
|
QDateTime startTime;
|
2017-08-29 09:41:30 +00:00
|
|
|
int instanceCounter = 0;
|
2017-11-22 19:42:33 +00:00
|
|
|
struct deco_state ds_after_previous_dives;
|
2020-04-12 11:39:01 +00:00
|
|
|
duration_t preserved_until;
|
2015-05-28 19:23:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|