mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
0d45c77572
commit
ab6aea73c1
2 changed files with 38 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
||||||
#include "diveplanner.h"
|
#include "diveplanner.h"
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
#include <boost/graph/graph_concepts.hpp>
|
||||||
|
|
||||||
DivePlanner* DivePlanner::instance()
|
DivePlanner* DivePlanner::instance()
|
||||||
{
|
{
|
||||||
|
@ -16,7 +17,38 @@ DivePlanner::DivePlanner(QWidget* parent): QGraphicsView(parent)
|
||||||
void DivePlanner::mouseDoubleClickEvent(QMouseEvent* event)
|
void DivePlanner::mouseDoubleClickEvent(QMouseEvent* event)
|
||||||
{
|
{
|
||||||
QGraphicsEllipseItem *item = new QGraphicsEllipseItem(-10,-10,20,20);
|
QGraphicsEllipseItem *item = new QGraphicsEllipseItem(-10,-10,20,20);
|
||||||
item->setPos( mapToScene(event->pos()));
|
QPointF mappedPos = mapToScene(event->pos());
|
||||||
|
|
||||||
|
item->setPos( mappedPos );
|
||||||
scene()->addItem(item);
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,12 @@ public:
|
||||||
static DivePlanner *instance();
|
static DivePlanner *instance();
|
||||||
protected:
|
protected:
|
||||||
virtual void mouseDoubleClickEvent(QMouseEvent* event);
|
virtual void mouseDoubleClickEvent(QMouseEvent* event);
|
||||||
|
void clear_generated_deco();
|
||||||
|
void create_deco_stop();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DivePlanner(QWidget* parent = 0);
|
DivePlanner(QWidget* parent = 0);
|
||||||
|
QList<QGraphicsLineItem*> lines;
|
||||||
|
QList<QGraphicsEllipseItem*> handles;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue