2013-06-20 15:33:26 +00:00
|
|
|
#ifndef DIVEPLANNER_H
|
|
|
|
#define DIVEPLANNER_H
|
|
|
|
|
|
|
|
#include <QGraphicsView>
|
|
|
|
#include <QGraphicsPathItem>
|
2013-06-20 21:40:59 +00:00
|
|
|
#include <QDialog>
|
2013-06-20 15:33:26 +00:00
|
|
|
|
2013-07-21 16:54:21 +00:00
|
|
|
class QListView;
|
|
|
|
class QStringListModel;
|
|
|
|
class QModelIndex;
|
|
|
|
|
2013-06-27 19:45:58 +00:00
|
|
|
class Button : public QObject, public QGraphicsRectItem {
|
2013-06-21 19:44:38 +00:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit Button(QObject* parent = 0);
|
2013-06-27 19:45:58 +00:00
|
|
|
void setText(const QString& text);
|
|
|
|
void setPixmap(const QPixmap& pixmap);
|
|
|
|
|
2013-06-21 19:44:38 +00:00
|
|
|
protected:
|
2013-06-23 20:09:29 +00:00
|
|
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent* event);
|
2013-06-21 19:44:38 +00:00
|
|
|
signals:
|
|
|
|
void clicked();
|
2013-06-27 19:45:58 +00:00
|
|
|
private:
|
|
|
|
QGraphicsPixmapItem *icon;
|
|
|
|
QGraphicsSimpleTextItem *text;
|
2013-06-21 19:44:38 +00:00
|
|
|
};
|
|
|
|
|
2013-06-20 17:29:32 +00:00
|
|
|
class DiveHandler : public QGraphicsEllipseItem{
|
|
|
|
public:
|
2013-06-23 20:09:29 +00:00
|
|
|
DiveHandler();
|
2013-06-24 01:04:35 +00:00
|
|
|
int sec;
|
|
|
|
int mm;
|
2013-07-04 14:01:59 +00:00
|
|
|
protected:
|
|
|
|
void mousePressEvent(QGraphicsSceneMouseEvent* event);
|
2013-06-20 17:29:32 +00:00
|
|
|
};
|
2013-06-20 18:52:27 +00:00
|
|
|
|
2013-06-20 19:48:24 +00:00
|
|
|
class Ruler : public QGraphicsLineItem{
|
2013-06-20 18:52:27 +00:00
|
|
|
public:
|
2013-06-23 20:09:29 +00:00
|
|
|
Ruler();
|
2013-06-20 18:52:27 +00:00
|
|
|
void setMinimum(double minimum);
|
|
|
|
void setMaximum(double maximum);
|
|
|
|
void setTickInterval(double interval);
|
|
|
|
void setOrientation(Qt::Orientation orientation);
|
2013-07-02 14:12:15 +00:00
|
|
|
void setTickSize(qreal size);
|
2013-06-20 19:48:24 +00:00
|
|
|
void updateTicks();
|
2013-06-21 19:07:44 +00:00
|
|
|
double minimum() const;
|
|
|
|
double maximum() const;
|
2013-06-20 20:34:42 +00:00
|
|
|
qreal valueAt(const QPointF& p);
|
2013-07-02 16:31:25 +00:00
|
|
|
qreal percentAt(const QPointF& p);
|
2013-06-20 21:25:03 +00:00
|
|
|
qreal posAtValue(qreal value);
|
2013-07-02 15:01:47 +00:00
|
|
|
void setColor(const QColor& color);
|
2013-06-20 18:52:27 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
Qt::Orientation orientation;
|
|
|
|
QList<QGraphicsLineItem*> ticks;
|
|
|
|
double min;
|
|
|
|
double max;
|
2013-06-20 19:48:24 +00:00
|
|
|
double interval;
|
2013-06-20 18:52:27 +00:00
|
|
|
double posBegin;
|
|
|
|
double posEnd;
|
2013-07-02 14:12:15 +00:00
|
|
|
double tickSize;
|
2013-06-20 18:52:27 +00:00
|
|
|
};
|
|
|
|
|
2013-06-20 21:40:59 +00:00
|
|
|
class DivePlannerGraphics : public QGraphicsView {
|
2013-06-20 15:33:26 +00:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2013-06-20 21:40:59 +00:00
|
|
|
DivePlannerGraphics(QWidget* parent = 0);
|
2013-06-20 15:37:41 +00:00
|
|
|
protected:
|
2013-06-23 20:09:29 +00:00
|
|
|
virtual void mouseDoubleClickEvent(QMouseEvent* event);
|
|
|
|
virtual void showEvent(QShowEvent* event);
|
|
|
|
virtual void resizeEvent(QResizeEvent* event);
|
|
|
|
virtual void mouseMoveEvent(QMouseEvent* event);
|
|
|
|
virtual void mousePressEvent(QMouseEvent* event);
|
|
|
|
virtual void mouseReleaseEvent(QMouseEvent* event);
|
|
|
|
|
|
|
|
void createDecoStops();
|
2013-06-21 19:28:17 +00:00
|
|
|
bool isPointOutOfBoundaries(const QPointF& point);
|
2013-06-27 20:31:10 +00:00
|
|
|
void deleteTemporaryDivePlan(struct divedatapoint* dp);
|
2013-07-02 13:53:08 +00:00
|
|
|
qreal fromPercent(qreal percent, Qt::Orientation orientation);
|
2013-06-21 19:51:13 +00:00
|
|
|
private slots:
|
2013-07-04 14:06:28 +00:00
|
|
|
void keyEscAction();
|
2013-07-04 14:16:42 +00:00
|
|
|
void keyDeleteAction();
|
2013-07-04 14:28:39 +00:00
|
|
|
void keyUpAction();
|
|
|
|
void keyDownAction();
|
2013-07-04 15:30:05 +00:00
|
|
|
void keyLeftAction();
|
|
|
|
void keyRightAction();
|
2013-06-21 19:51:13 +00:00
|
|
|
void increaseTime();
|
|
|
|
void increaseDepth();
|
2013-07-21 12:27:04 +00:00
|
|
|
void decreaseTime();
|
|
|
|
void decreaseDepth();;
|
2013-06-27 19:45:58 +00:00
|
|
|
void okClicked();
|
|
|
|
void cancelClicked();
|
2013-07-21 16:54:21 +00:00
|
|
|
void prepareSelectGas();
|
|
|
|
void selectGas(const QModelIndex& index);
|
2013-06-21 19:51:13 +00:00
|
|
|
|
2013-06-20 15:33:26 +00:00
|
|
|
private:
|
2013-06-23 20:09:29 +00:00
|
|
|
void moveActiveHandler(const QPointF& pos);
|
2013-07-02 13:53:08 +00:00
|
|
|
|
|
|
|
/* This are the lines of the plotted dive. */
|
2013-06-20 16:20:41 +00:00
|
|
|
QList<QGraphicsLineItem*> lines;
|
2013-07-02 13:53:08 +00:00
|
|
|
|
|
|
|
/* This is the user-entered handles. */
|
2013-06-20 17:29:32 +00:00
|
|
|
QList<DiveHandler *> handles;
|
2013-07-02 13:53:08 +00:00
|
|
|
|
2013-07-21 15:12:31 +00:00
|
|
|
/* this is the user-entered gases.
|
|
|
|
This must be a button, so the
|
|
|
|
user cna click to choose a new gas.
|
|
|
|
*/
|
|
|
|
QList<Button*> gases;
|
2013-07-21 16:54:21 +00:00
|
|
|
QListView *gasListView;
|
|
|
|
QStringListModel *gasChoices;
|
|
|
|
Button *currentGasChoice;
|
2013-07-21 15:12:31 +00:00
|
|
|
|
2013-07-02 13:53:08 +00:00
|
|
|
/* those are the lines that follows the mouse. */
|
2013-06-20 16:53:12 +00:00
|
|
|
QGraphicsLineItem *verticalLine;
|
|
|
|
QGraphicsLineItem *horizontalLine;
|
2013-07-02 13:53:08 +00:00
|
|
|
|
|
|
|
/* This is the handler that's being dragged. */
|
2013-06-20 17:46:40 +00:00
|
|
|
DiveHandler *activeDraggedHandler;
|
2013-07-02 13:53:08 +00:00
|
|
|
|
2013-07-04 13:29:28 +00:00
|
|
|
// When we start to move the handler, this pos is saved.
|
|
|
|
// so we can revert it later.
|
|
|
|
QPointF originalHandlerPos;
|
2013-07-02 13:53:08 +00:00
|
|
|
|
|
|
|
/* this is the background of the dive, the blue-gradient. */
|
2013-06-27 22:52:58 +00:00
|
|
|
QGraphicsPolygonItem *diveBg;
|
2013-07-02 13:53:08 +00:00
|
|
|
|
|
|
|
/* This is the bottom ruler - the x axis, and it's associated text */
|
2013-06-20 19:48:24 +00:00
|
|
|
Ruler *timeLine;
|
2013-06-20 20:54:36 +00:00
|
|
|
QGraphicsSimpleTextItem *timeString;
|
|
|
|
|
2013-07-02 13:53:08 +00:00
|
|
|
/* this is the left ruler, the y axis, and it's associated text. */
|
2013-06-20 19:48:24 +00:00
|
|
|
Ruler *depthLine;
|
2013-06-20 20:54:36 +00:00
|
|
|
QGraphicsSimpleTextItem *depthString;
|
2013-06-20 19:48:24 +00:00
|
|
|
|
2013-07-02 13:53:08 +00:00
|
|
|
/* Buttons */
|
|
|
|
Button *plusTime; // adds 10 minutes to the time ruler.
|
|
|
|
Button *plusDepth; // adds 10 meters to the depth ruler.
|
|
|
|
Button *lessTime; // remove 10 minutes to the time ruler.
|
|
|
|
Button *lessDepth; // remove 10 meters to the depth ruler.
|
|
|
|
Button *okBtn; // accepts, and creates a new dive based on the plan.
|
|
|
|
Button *cancelBtn; // rejects, and clears the dive plan.
|
2013-07-02 17:36:52 +00:00
|
|
|
|
|
|
|
int minMinutes; // this holds the minimum duration of the dive.
|
2013-07-21 12:44:52 +00:00
|
|
|
int dpMaxTime; // this is the time of the dive calculated by the deco.
|
2013-06-20 15:33:26 +00:00
|
|
|
};
|
2013-06-20 21:40:59 +00:00
|
|
|
|
2013-06-20 15:33:26 +00:00
|
|
|
#endif
|