summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-06-21 15:53:20 -0300
committerGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-06-21 15:53:20 -0300
commit397a94fcd1deb56240403a6e33e61f49460cc1c8 (patch)
treef1d6ca2bc3acc6acdbd3da8df4f56fa18ef143e4 /qt-ui
parent062515ba6f92fa7b4d72403ed195b28ad6d996f7 (diff)
downloadsubsurface-397a94fcd1deb56240403a6e33e61f49460cc1c8.tar.gz
Created the posAtValue method for the ruler
Created the posAtValue method for the ruler, you enter a value, and it will return the coordinates in double ( coordinate system of a QGraphicsScene is double based ) this is not the best name for the function, but I couldn't find any better suitable name. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/diveplanner.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 51d018a90..21d134d04 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -289,18 +289,27 @@ void Ruler::setTickInterval(double i)
qreal Ruler::valueAt(const QPointF& p)
{
QLineF m = line();
- return orientation == Qt::Horizontal
+ double retValue = orientation == Qt::Horizontal
? max * (p.x() - m.x1()) / (m.x2() - m.x1())
: max * (p.y() - m.y1()) / (m.y2() - m.y1());
+ return retValue;
}
qreal Ruler::posAtValue(qreal value)
{
QLineF m = line();
- // I need to finish this later. hungry as hell.
+ double size = max - min;
+ double percent = value / size;
+ double realSize = orientation == Qt::Horizontal
+ ? m.x2() - m.x1()
+ : m.y2() - m.y1();
+ double retValue = realSize * percent;
+ retValue = (orientation == Qt::Horizontal)
+ ? retValue + m.x1()
+ : retValue + m.y1();
+ return retValue;
}
-
DivePlanner::DivePlanner() : ui(new Ui::DivePlanner())
{
ui->setupUi(this);