mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
Make skeleton of 'create_deco_stop'.
This is a skeleton of 'create_deco_stop' plus a bit of code cleanup. I'v commented the create_deco_stop so that the other developers can help me a bit here - since I don't know too well the internals of subsurface. In the original GTK code - a new dive was created every time a user changed something on the dive, I don't know if this will be needed, I jusst need two things: the correct time of dive calculated by the app, and the points to put the decompression lines. The usability of the widget right now is 'ok', nothing to be proud of, it's ugly as hell too, and the Rules are in the wrong position ( they are 'inside' the area where the lines are being drawn, but htis is easily fixable. ) Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This commit is contained in:
parent
0539a5fab6
commit
8fcd465a65
2 changed files with 36 additions and 18 deletions
|
@ -82,18 +82,8 @@ void DivePlanner::mouseDoubleClickEvent(QMouseEvent* event)
|
||||||
scene()->addItem(line);
|
scene()->addItem(line);
|
||||||
create_deco_stop();
|
create_deco_stop();
|
||||||
}
|
}
|
||||||
item->setTime(timeLine->valueAt(mappedPos));
|
item->time = (timeLine->valueAt(mappedPos));
|
||||||
item->setDepth(depthLine->valueAt(mappedPos));
|
item->depth = (depthLine->valueAt(mappedPos));
|
||||||
}
|
|
||||||
|
|
||||||
void DiveHandler::setDepth(qreal d)
|
|
||||||
{
|
|
||||||
depth = d;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DiveHandler::setTime(qreal t)
|
|
||||||
{
|
|
||||||
time =t;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivePlanner::clear_generated_deco()
|
void DivePlanner::clear_generated_deco()
|
||||||
|
@ -107,6 +97,30 @@ void DivePlanner::clear_generated_deco()
|
||||||
|
|
||||||
void DivePlanner::create_deco_stop()
|
void DivePlanner::create_deco_stop()
|
||||||
{
|
{
|
||||||
|
// This needs to be done in the following steps:
|
||||||
|
// Get the user-input and calculate the dive info
|
||||||
|
Q_FOREACH(DiveHandler *h, handles){
|
||||||
|
// use this somewhere.
|
||||||
|
h->time;
|
||||||
|
h->depth;
|
||||||
|
}
|
||||||
|
// create the dive info here.
|
||||||
|
|
||||||
|
// set the new 'end time' of the dive.
|
||||||
|
// note that this is not the user end,
|
||||||
|
// but the real end of the dive.
|
||||||
|
timeLine->setMaximum(60);
|
||||||
|
timeLine->updateTicks();
|
||||||
|
|
||||||
|
// Re-position the user generated dive handlers
|
||||||
|
Q_FOREACH(DiveHandler *h, handles){
|
||||||
|
// uncomment this as soon as the posAtValue is implemented.
|
||||||
|
// h->setPos( timeLine->posAtValue(h->time),
|
||||||
|
// depthLine->posAtValue(h->depth));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create all 'deco' GraphicsLineItems and put it on the canvas.This following three lines will
|
||||||
|
// most probably need to enter on a loop.
|
||||||
QGraphicsLineItem *item = new QGraphicsLineItem(handles.last()->x(), handles.last()->y(), 100, 0);
|
QGraphicsLineItem *item = new QGraphicsLineItem(handles.last()->x(), handles.last()->y(), 100, 0);
|
||||||
scene()->addItem(item);
|
scene()->addItem(item);
|
||||||
lines << item;
|
lines << item;
|
||||||
|
@ -222,8 +236,8 @@ void DivePlanner::mouseReleaseEvent(QMouseEvent* event)
|
||||||
{
|
{
|
||||||
if (activeDraggedHandler){
|
if (activeDraggedHandler){
|
||||||
QPointF mappedPos = mapToScene(event->pos());
|
QPointF mappedPos = mapToScene(event->pos());
|
||||||
activeDraggedHandler->setTime(timeLine->valueAt(mappedPos));
|
activeDraggedHandler->time = (timeLine->valueAt(mappedPos));
|
||||||
activeDraggedHandler->setDepth(depthLine->valueAt(mappedPos));
|
activeDraggedHandler->depth = (depthLine->valueAt(mappedPos));
|
||||||
activeDraggedHandler->setBrush(QBrush());
|
activeDraggedHandler->setBrush(QBrush());
|
||||||
activeDraggedHandler = 0;
|
activeDraggedHandler = 0;
|
||||||
}
|
}
|
||||||
|
@ -284,3 +298,10 @@ qreal Ruler::valueAt(const QPointF& p)
|
||||||
? max * (p.x() - m.x1()) / (m.x2() - m.x1())
|
? max * (p.x() - m.x1()) / (m.x2() - m.x1())
|
||||||
: max * (p.y() - m.y1()) / (m.y2() - m.y1());
|
: max * (p.y() - m.y1()) / (m.y2() - m.y1());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qreal Ruler::posAtValue(qreal value)
|
||||||
|
{
|
||||||
|
QLineF m = line();
|
||||||
|
// I need to finish this later. hungry as hell.
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -7,12 +7,8 @@
|
||||||
class DiveHandler : public QGraphicsEllipseItem{
|
class DiveHandler : public QGraphicsEllipseItem{
|
||||||
public:
|
public:
|
||||||
DiveHandler();
|
DiveHandler();
|
||||||
void setTime(qreal t);
|
|
||||||
void setDepth(qreal d);
|
|
||||||
|
|
||||||
QGraphicsLineItem *from;
|
QGraphicsLineItem *from;
|
||||||
QGraphicsLineItem *to;
|
QGraphicsLineItem *to;
|
||||||
private:
|
|
||||||
qreal time;
|
qreal time;
|
||||||
qreal depth;
|
qreal depth;
|
||||||
};
|
};
|
||||||
|
@ -26,6 +22,7 @@ public:
|
||||||
void setOrientation(Qt::Orientation orientation);
|
void setOrientation(Qt::Orientation orientation);
|
||||||
void updateTicks();
|
void updateTicks();
|
||||||
qreal valueAt(const QPointF& p);
|
qreal valueAt(const QPointF& p);
|
||||||
|
qreal posAtValue(qreal value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Qt::Orientation orientation;
|
Qt::Orientation orientation;
|
||||||
|
|
Loading…
Add table
Reference in a new issue