aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-06-20 13:20:41 -0300
committerGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-06-20 13:20:41 -0300
commitab6aea73c17a10bfb934ba74fcda59cb916f278d (patch)
treeac96f2afad814879127d80f508f2133a454f2cf1 /qt-ui
parent0d45c775725f23e96b018df4e23c2776a3186030 (diff)
downloadsubsurface-ab6aea73c17a10bfb934ba74fcda59cb916f278d.tar.gz
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 <tcanabrava@kde.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/diveplanner.cpp34
-rw-r--r--qt-ui/diveplanner.h6
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