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