mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-01 08:03:24 +00:00
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>
This commit is contained in:
parent
062515ba6f
commit
397a94fcd1
1 changed files with 12 additions and 3 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue