2013-06-20 15:33:26 +00:00
|
|
|
#ifndef DIVEPLANNER_H
|
|
|
|
#define DIVEPLANNER_H
|
|
|
|
|
|
|
|
#include <QGraphicsPathItem>
|
2013-08-26 12:14:19 +00:00
|
|
|
#include <QAbstractTableModel>
|
2014-11-04 11:15:27 +00:00
|
|
|
#include <QAbstractButton>
|
2014-06-28 15:07:28 +00:00
|
|
|
#include <QDateTime>
|
2013-08-26 16:18:21 +00:00
|
|
|
|
|
|
|
#include "dive.h"
|
2013-08-26 11:43:37 +00:00
|
|
|
|
2013-07-21 16:54:21 +00:00
|
|
|
class QListView;
|
|
|
|
class QModelIndex;
|
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
class DivePlannerPointsModel : public QAbstractTableModel {
|
2013-08-26 12:14:19 +00:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2014-02-28 04:09:57 +00:00
|
|
|
static DivePlannerPointsModel *instance();
|
|
|
|
enum Sections {
|
|
|
|
REMOVE,
|
|
|
|
DEPTH,
|
|
|
|
DURATION,
|
2014-04-17 08:54:55 +00:00
|
|
|
RUNTIME,
|
2014-02-28 04:09:57 +00:00
|
|
|
GAS,
|
|
|
|
CCSETPOINT,
|
|
|
|
COLUMNS
|
|
|
|
};
|
|
|
|
enum Mode {
|
|
|
|
NOTHING,
|
|
|
|
PLAN,
|
|
|
|
ADD
|
|
|
|
};
|
|
|
|
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
|
|
|
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
|
|
|
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
2013-08-26 16:18:21 +00:00
|
|
|
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
2014-02-28 04:09:57 +00:00
|
|
|
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
|
|
|
|
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
|
|
|
|
void removeSelectedPoints(const QVector<int> &rows);
|
2013-11-09 00:09:46 +00:00
|
|
|
void setPlanMode(Mode mode);
|
2013-09-19 02:33:53 +00:00
|
|
|
bool isPlanner();
|
2014-05-27 18:28:42 +00:00
|
|
|
void createSimpleDive();
|
2014-06-28 15:07:28 +00:00
|
|
|
void setupStartTime();
|
2013-11-09 00:09:46 +00:00
|
|
|
void clear();
|
|
|
|
Mode currentMode() const;
|
2014-04-17 08:54:55 +00:00
|
|
|
bool setRecalc(bool recalc);
|
|
|
|
bool recalcQ();
|
2013-11-13 12:45:54 +00:00
|
|
|
void tanksUpdated();
|
|
|
|
void rememberTanks();
|
2014-06-01 22:25:19 +00:00
|
|
|
bool tankInUse(struct gasmix gasmix);
|
2014-05-29 00:01:18 +00:00
|
|
|
void setupCylinders();
|
2013-08-26 16:18:21 +00:00
|
|
|
/**
|
|
|
|
* @return the row number.
|
|
|
|
*/
|
2014-02-28 04:09:57 +00:00
|
|
|
void editStop(int row, divedatapoint newData);
|
2013-08-26 17:17:39 +00:00
|
|
|
divedatapoint at(int row);
|
2013-09-22 18:01:18 +00:00
|
|
|
int size();
|
2014-05-22 18:40:22 +00:00
|
|
|
struct diveplan &getDiveplan();
|
2013-11-11 08:09:19 +00:00
|
|
|
QStringList &getGasList();
|
2013-12-24 12:18:56 +00:00
|
|
|
QVector<QPair<int, int> > collectGases(dive *d);
|
2014-04-17 08:54:55 +00:00
|
|
|
int lastEnteredPoint();
|
2014-04-24 14:42:10 +00:00
|
|
|
void removeDeco();
|
2014-04-17 08:54:55 +00:00
|
|
|
static bool addingDeco;
|
2013-11-13 12:45:54 +00:00
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
public
|
|
|
|
slots:
|
2014-06-02 19:36:05 +00:00
|
|
|
int addStop(int millimeters = 0, int seconds = 0, struct gasmix *gas = 0, int ccpoint = 0, bool entered = true);
|
2013-11-10 12:02:53 +00:00
|
|
|
void addCylinder_clicked();
|
2013-11-14 18:55:33 +00:00
|
|
|
void setGFHigh(const int gfhigh);
|
2014-08-05 15:06:17 +00:00
|
|
|
void triggerGFHigh();
|
2013-11-14 18:55:33 +00:00
|
|
|
void setGFLow(const int ghflow);
|
2014-08-05 15:06:17 +00:00
|
|
|
void triggerGFLow();
|
2013-08-26 16:18:21 +00:00
|
|
|
void setSurfacePressure(int pressure);
|
2014-11-12 22:33:40 +00:00
|
|
|
void setSalinity(int salinity);
|
2014-08-03 20:24:56 +00:00
|
|
|
int getSurfacePressure();
|
2014-08-19 16:13:55 +00:00
|
|
|
void setBottomSac(double sac);
|
|
|
|
void setDecoSac(double sac);
|
2014-02-28 04:09:57 +00:00
|
|
|
void setStartTime(const QTime &t);
|
2014-06-28 15:07:28 +00:00
|
|
|
void setStartDate(const QDate &date);
|
2013-08-26 16:18:21 +00:00
|
|
|
void setLastStop6m(bool value);
|
2014-06-23 17:21:29 +00:00
|
|
|
void setDropStoneMode(bool value);
|
2014-06-02 14:25:58 +00:00
|
|
|
void setVerbatim(bool value);
|
|
|
|
void setDisplayRuntime(bool value);
|
|
|
|
void setDisplayDuration(bool value);
|
|
|
|
void setDisplayTransitions(bool value);
|
2014-11-04 11:15:27 +00:00
|
|
|
void savePlan();
|
|
|
|
void saveDuplicatePlan();
|
2014-02-28 04:09:57 +00:00
|
|
|
void remove(const QModelIndex &index);
|
2013-09-19 02:33:53 +00:00
|
|
|
void cancelPlan();
|
|
|
|
void createTemporaryPlan();
|
|
|
|
void deleteTemporaryPlan();
|
2014-02-28 04:09:57 +00:00
|
|
|
void loadFromDive(dive *d);
|
2014-06-04 16:34:08 +00:00
|
|
|
void emitDataChanged();
|
2014-12-26 14:09:18 +00:00
|
|
|
void setRebreatherMode(QString mode);
|
2014-04-17 08:54:55 +00:00
|
|
|
|
2013-09-16 14:38:41 +00:00
|
|
|
signals:
|
|
|
|
void planCreated();
|
|
|
|
void planCanceled();
|
2014-04-18 02:48:00 +00:00
|
|
|
void cylinderModelEdited();
|
2014-06-28 15:07:28 +00:00
|
|
|
void startTimeChanged(QDateTime);
|
2014-02-28 04:09:57 +00:00
|
|
|
|
2013-08-26 12:14:19 +00:00
|
|
|
private:
|
2014-02-28 04:09:57 +00:00
|
|
|
explicit DivePlannerPointsModel(QObject *parent = 0);
|
2014-06-02 01:18:29 +00:00
|
|
|
bool addGas(struct gasmix mix);
|
2014-11-04 11:15:27 +00:00
|
|
|
void createPlan(bool replanCopy);
|
2013-08-26 16:18:21 +00:00
|
|
|
struct diveplan diveplan;
|
2013-11-09 00:09:46 +00:00
|
|
|
Mode mode;
|
2014-04-17 08:54:55 +00:00
|
|
|
bool recalc;
|
2013-08-26 16:18:21 +00:00
|
|
|
QVector<divedatapoint> divepoints;
|
2013-11-01 17:45:14 +00:00
|
|
|
QVector<sample> backupSamples; // For editing added dives.
|
2013-12-24 12:18:56 +00:00
|
|
|
QVector<QPair<int, int> > oldGases;
|
2014-06-28 15:07:28 +00:00
|
|
|
QDateTime startTime;
|
2014-08-05 15:06:17 +00:00
|
|
|
int tempGFHigh;
|
|
|
|
int tempGFLow;
|
2013-08-26 12:14:19 +00:00
|
|
|
};
|
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
class DiveHandler : public QObject, public QGraphicsEllipseItem {
|
|
|
|
Q_OBJECT
|
2013-06-20 17:29:32 +00:00
|
|
|
public:
|
2013-06-23 20:09:29 +00:00
|
|
|
DiveHandler();
|
2014-02-28 04:09:57 +00:00
|
|
|
|
2013-07-04 14:01:59 +00:00
|
|
|
protected:
|
2014-02-28 04:09:57 +00:00
|
|
|
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
|
2014-05-23 23:51:30 +00:00
|
|
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
2014-06-30 22:08:16 +00:00
|
|
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
|
|
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
2014-05-23 22:50:09 +00:00
|
|
|
signals:
|
|
|
|
void moved();
|
2014-06-30 22:08:16 +00:00
|
|
|
void clicked();
|
|
|
|
void released();
|
2013-11-19 22:42:05 +00:00
|
|
|
private:
|
|
|
|
int parentIndex();
|
2014-02-28 04:09:57 +00:00
|
|
|
public
|
|
|
|
slots:
|
2013-11-15 01:29:36 +00:00
|
|
|
void selfRemove();
|
2013-11-19 22:42:05 +00:00
|
|
|
void changeGas();
|
2013-06-20 17:29:32 +00:00
|
|
|
};
|
2013-06-20 18:52:27 +00:00
|
|
|
|
2013-10-05 07:29:09 +00:00
|
|
|
#include "ui_diveplanner.h"
|
|
|
|
|
2013-08-26 11:43:37 +00:00
|
|
|
class DivePlannerWidget : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2014-02-28 04:09:57 +00:00
|
|
|
explicit DivePlannerWidget(QWidget *parent = 0, Qt::WindowFlags f = 0);
|
2014-11-04 11:15:27 +00:00
|
|
|
void setReplanButton(bool replan);
|
2014-02-28 04:09:57 +00:00
|
|
|
public
|
|
|
|
slots:
|
2014-06-28 15:07:28 +00:00
|
|
|
void setupStartTime(QDateTime startTime);
|
2013-12-09 06:43:00 +00:00
|
|
|
void settingsChanged();
|
2014-06-26 15:04:39 +00:00
|
|
|
void atmPressureChanged(const int pressure);
|
|
|
|
void heightChanged(const int height);
|
2014-11-12 22:33:40 +00:00
|
|
|
void salinityChanged(const double salinity);
|
2014-06-03 08:06:18 +00:00
|
|
|
void printDecoPlan();
|
2014-02-28 04:09:57 +00:00
|
|
|
|
2013-08-26 11:43:37 +00:00
|
|
|
private:
|
2013-10-03 18:54:25 +00:00
|
|
|
Ui::DivePlanner ui;
|
2014-11-04 11:15:27 +00:00
|
|
|
QAbstractButton *replanButton;
|
2013-08-26 11:43:37 +00:00
|
|
|
};
|
|
|
|
|
2014-06-10 15:40:02 +00:00
|
|
|
#include "ui_plannerSettings.h"
|
|
|
|
|
|
|
|
class PlannerSettingsWidget : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit PlannerSettingsWidget(QWidget *parent = 0, Qt::WindowFlags f = 0);
|
2014-07-15 18:39:13 +00:00
|
|
|
virtual ~PlannerSettingsWidget();
|
2014-06-10 15:40:02 +00:00
|
|
|
public
|
|
|
|
slots:
|
|
|
|
void settingsChanged();
|
|
|
|
void atmPressureChanged(const QString &pressure);
|
2014-08-19 16:13:55 +00:00
|
|
|
void bottomSacChanged(const double bottomSac);
|
|
|
|
void decoSacChanged(const double decosac);
|
2014-06-10 15:40:02 +00:00
|
|
|
void printDecoPlan();
|
2014-06-24 22:08:36 +00:00
|
|
|
void setAscRate75(int rate);
|
|
|
|
void setAscRate50(int rate);
|
|
|
|
void setAscRateStops(int rate);
|
|
|
|
void setAscRateLast6m(int rate);
|
|
|
|
void setDescRate(int rate);
|
2014-06-25 12:00:03 +00:00
|
|
|
void setBottomPo2(double po2);
|
|
|
|
void setDecoPo2(double po2);
|
2014-07-02 20:07:38 +00:00
|
|
|
void setBackgasBreaks(bool dobreaks);
|
2014-06-10 15:40:02 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
Ui::plannerSettingsWidget ui;
|
2014-07-17 15:03:52 +00:00
|
|
|
void updateUnitsUI();
|
2014-06-10 15:40:02 +00:00
|
|
|
};
|
|
|
|
|
2014-05-22 02:31:26 +00:00
|
|
|
QString dpGasToStr(const divedatapoint &p);
|
|
|
|
|
2014-02-11 18:14:46 +00:00
|
|
|
#endif // DIVEPLANNER_H
|