diff options
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/diveplanner.cpp | 34 | ||||
-rw-r--r-- | qt-ui/diveplanner.h | 6 |
2 files changed, 38 insertions, 2 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 46147bfc7..90d677177 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -1,5 +1,6 @@ #include "diveplanner.h" #include <QMouseEvent> +#include <boost/graph/graph_concepts.hpp> DivePlanner* DivePlanner::instance() { @@ -16,7 +17,38 @@ DivePlanner::DivePlanner(QWidget* parent): QGraphicsView(parent) void DivePlanner::mouseDoubleClickEvent(QMouseEvent* event) { QGraphicsEllipseItem *item = new QGraphicsEllipseItem(-10,-10,20,20); - item->setPos( mapToScene(event->pos())); + QPointF mappedPos = mapToScene(event->pos()); + + item->setPos( mappedPos ); scene()->addItem(item); + handles << item; + + if (lines.empty()){ + QGraphicsLineItem *first = new QGraphicsLineItem(0,0, mappedPos.x(), mappedPos.y()); + lines << first; + create_deco_stop(); + scene()->addItem(first); + }else{ + clear_generated_deco(); + create_deco_stop(); + } +} + +void DivePlanner::clear_generated_deco() +{ + for(int i = handles.count(); i < lines.count(); i++){ + scene()->removeItem(lines.last()); + delete lines.last(); + lines.removeLast(); + } +} + +void DivePlanner::create_deco_stop() +{ + // this needs to create everything + // for the calculated deco. + QGraphicsLineItem *item = new QGraphicsLineItem(handles.last()->x(), handles.last()->y(), 100, 0); + scene()->addItem(item); + lines << item; } diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h index 6e73db718..fc9575cfa 100644 --- a/qt-ui/diveplanner.h +++ b/qt-ui/diveplanner.h @@ -10,8 +10,12 @@ public: static DivePlanner *instance(); protected: virtual void mouseDoubleClickEvent(QMouseEvent* event); - + void clear_generated_deco(); + void create_deco_stop(); + private: DivePlanner(QWidget* parent = 0); + QList<QGraphicsLineItem*> lines; + QList<QGraphicsEllipseItem*> handles; }; #endif |