Do not plot dive handlers outside of the Plane area.

This patch makes the behavior of inserting new hanflers
correct. it can only be inserted now inside of the plane
defined by the Depth ruler and Time ruler.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This commit is contained in:
Tomaz Canabrava 2013-06-21 16:07:44 -03:00
parent 397a94fcd1
commit 1e4d360d0c
2 changed files with 20 additions and 4 deletions

View file

@ -206,10 +206,13 @@ void DivePlannerGraphics::moveActiveHandler(QPointF pos)
bool DivePlannerGraphics::isPointOutOfBoundaries(QPointF point)
{
if (point.x() > sceneRect().width()
|| point.x() < 0
|| point.y() < 0
|| point.y() > sceneRect().height())
double xpos = timeLine->valueAt(point);
double ypos = depthLine->valueAt(point);
if (xpos > timeLine->maximum()
|| xpos < timeLine->minimum()
|| ypos > depthLine->maximum()
|| ypos < depthLine->minimum())
{
return true;
}
@ -325,3 +328,14 @@ DivePlanner* DivePlanner::instance()
static DivePlanner *self = new DivePlanner();
return self;
}
double Ruler::maximum() const
{
return max;
}
double Ruler::minimum() const
{
return min;
}

View file

@ -22,6 +22,8 @@ public:
void setTickInterval(double interval);
void setOrientation(Qt::Orientation orientation);
void updateTicks();
double minimum() const;
double maximum() const;
qreal valueAt(const QPointF& p);
qreal posAtValue(qreal value);