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