From ab6aea73c17a10bfb934ba74fcda59cb916f278d Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 20 Jun 2013 13:20:41 -0300 Subject: Plots Lines and handles on the Planner This is still a bit bugged - the lines are going to the wrong end - most probaly I messed something on the math. I'll now fix the sizing issue then I'll try to make it behave in the proper way. Signed-off-by: Tomaz Canabrava --- qt-ui/diveplanner.cpp | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'qt-ui/diveplanner.cpp') 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 +#include 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; } -- cgit v1.2.3-70-g09d2