OGS
QArrow.h
Go to the documentation of this file.
1
15#pragma once
16
17#include <QGraphicsItem>
18#include <QPen>
19
20const double PI = 3.14159265;
21
25class QArrow : public QGraphicsItem
26{
27public:
28 QArrow(qreal l, qreal a, qreal hl, qreal hw, QPen& pen,
29 QGraphicsItem* parent = nullptr);
30 QArrow(qreal l, qreal a, QPen& pen, QGraphicsItem* parent = nullptr);
31 ~QArrow() override;
32
33 double getLength();
34 double getAngle();
35 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
36 QWidget* widget) override;
37 QRectF boundingRect() const override;
38 void setAngle(qreal a);
39 void setLength(qreal l);
40
41private:
42 double calcCos(double angle);
43 double calcSin(double angle);
44
50};
const double PI
Definition QArrow.h:20
An arrow as a QGraphicsObject.
Definition QArrow.h:26
~QArrow() override
QPen _arrowPen
Definition QArrow.h:49
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
Definition QArrow.cpp:95
qreal _arrowAngle
Definition QArrow.h:46
void setLength(qreal l)
Changes the length of the arrow.
Definition QArrow.cpp:130
QArrow(qreal l, qreal a, qreal hl, qreal hw, QPen &pen, QGraphicsItem *parent=nullptr)
Definition QArrow.cpp:30
QRectF boundingRect() const override
The bounding box of the arrow.
Definition QArrow.cpp:70
qreal _headLength
Definition QArrow.h:47
double getLength()
Returns the length of the arrow.
Definition QArrow.cpp:79
double calcSin(double angle)
Definition QArrow.cpp:64
qreal _headWidth
Definition QArrow.h:48
double calcCos(double angle)
Definition QArrow.cpp:59
double getAngle()
Returns the orientation of the arrow.
Definition QArrow.cpp:85
void setAngle(qreal a)
Changes orientation of the arrow.
Definition QArrow.cpp:124
qreal _arrowLength
Definition QArrow.h:45