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-06-21 19:44:38 +00:00
|
|
|
class Button : public QObject, public QGraphicsPixmapItem {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit Button(QObject* parent = 0);
|
|
|
|
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-20 17:29:32 +00:00
|
|
|
class DiveHandler : public QGraphicsEllipseItem{
|
|
|
|
public:
|
2013-06-23 20:09:29 +00:00
|
|
|
DiveHandler();
|
2013-06-20 17:29:32 +00:00
|
|
|
QGraphicsLineItem *from;
|
|
|
|
QGraphicsLineItem *to;
|
2013-06-24 01:04:35 +00:00
|
|
|
int sec;
|
|
|
|
int mm;
|
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-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-06-20 21:25:03 +00:00
|
|
|
qreal posAtValue(qreal value);
|
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-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 clearGeneratedDeco();
|
|
|
|
void createDecoStops();
|
2013-06-21 19:28:17 +00:00
|
|
|
bool isPointOutOfBoundaries(const QPointF& point);
|
2013-06-21 19:51:13 +00:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void increaseTime();
|
|
|
|
void increaseDepth();
|
|
|
|
|
2013-06-20 15:33:26 +00:00
|
|
|
private:
|
2013-06-20 21:40:59 +00:00
|
|
|
|
2013-06-23 20:09:29 +00:00
|
|
|
void moveActiveHandler(const QPointF& pos);
|
2013-06-20 16:20:41 +00:00
|
|
|
QList<QGraphicsLineItem*> lines;
|
2013-06-20 17:29:32 +00:00
|
|
|
QList<DiveHandler *> handles;
|
2013-06-20 16:53:12 +00:00
|
|
|
QGraphicsLineItem *verticalLine;
|
|
|
|
QGraphicsLineItem *horizontalLine;
|
2013-06-20 17:46:40 +00:00
|
|
|
DiveHandler *activeDraggedHandler;
|
2013-06-20 19:48:24 +00:00
|
|
|
|
|
|
|
Ruler *timeLine;
|
2013-06-20 20:54:36 +00:00
|
|
|
QGraphicsSimpleTextItem *timeString;
|
|
|
|
|
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-06-21 19:44:38 +00:00
|
|
|
Button *plusTime;
|
|
|
|
Button *plusDepth;
|
|
|
|
Button *lessTime;
|
|
|
|
Button *lessDepth;
|
|
|
|
|
2013-06-27 13:38:12 +00:00
|
|
|
QPointF lastValidPos;
|
2013-06-20 15:33:26 +00:00
|
|
|
};
|
2013-06-20 21:40:59 +00:00
|
|
|
|
|
|
|
namespace Ui{
|
|
|
|
class DivePlanner;
|
|
|
|
}
|
|
|
|
|
|
|
|
class DivePlanner : public QDialog{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
static DivePlanner *instance();
|
|
|
|
struct dive* getDive();
|
|
|
|
|
|
|
|
private:
|
|
|
|
DivePlanner();
|
|
|
|
Ui::DivePlanner *ui;
|
|
|
|
};
|
2013-06-20 15:33:26 +00:00
|
|
|
#endif
|