Krita Source Code Documentation
Loading...
Searching...
No Matches
Ruler Class Reference

#include <Ruler.h>

Public Member Functions

const QPointF & point1 () const
 
const QPointF & point2 () const
 
QPointF project (const QPointF &)
 
 Ruler ()
 
void setPoint1 (const QPointF &p)
 
void setPoint2 (const QPointF &p)
 
 ~Ruler ()
 

Private Attributes

QPointF p1
 
QPointF p2
 

Detailed Description

Definition at line 12 of file Ruler.h.

Constructor & Destructor Documentation

◆ Ruler()

Ruler::Ruler ( )

Definition at line 9 of file Ruler.cc.

9 : p1(QPointF(10, 10)), p2(QPointF(100, 190))
10{
11}
QPointF p2
Definition Ruler.h:28
QPointF p1
Definition Ruler.h:27

◆ ~Ruler()

Ruler::~Ruler ( )

Definition at line 13 of file Ruler.cc.

14{
15}

Member Function Documentation

◆ point1()

const QPointF & Ruler::point1 ( ) const

Definition at line 31 of file Ruler.cc.

32{
33 return p1;
34}

References p1.

◆ point2()

const QPointF & Ruler::point2 ( ) const

Definition at line 36 of file Ruler.cc.

37{
38 return p2;
39}

References p2.

◆ project()

QPointF Ruler::project ( const QPointF & pt)

Definition at line 17 of file Ruler.cc.

18{
19 double x1 = p1.x();
20 double y1 = p1.y();
21 double x2 = p2.x();
22 double y2 = p2.y();
23 double a1 = (y2 - y1) / (x2 - x1);
24 double b1 = y1 - x1 * a1;
25 double a2 = (x2 - x1) / (y1 - y2);
26 double b2 = pt.y() - a2 * pt.x();
27 double xm = (b2 - b1) / (a1 - a2);
28 return QPointF(xm, xm * a1 + b1);
29}

References p1, and p2.

◆ setPoint1()

void Ruler::setPoint1 ( const QPointF & p)
inline

Definition at line 19 of file Ruler.h.

19 {
20 p1 = p;
21 }
const Params2D p

References p, and p1.

◆ setPoint2()

void Ruler::setPoint2 ( const QPointF & p)
inline

Definition at line 23 of file Ruler.h.

23 {
24 p2 = p;
25 }

References p, and p2.

Member Data Documentation

◆ p1

QPointF Ruler::p1
private

Definition at line 27 of file Ruler.h.

◆ p2

QPointF Ruler::p2
private

Definition at line 28 of file Ruler.h.


The documentation for this class was generated from the following files: