OGS
QArrow.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5
6#include <QGraphicsItem>
7#include <QPen>
8
9const double PI = 3.14159265;
10
14class QArrow : public QGraphicsItem
15{
16public:
17 QArrow(qreal l, qreal a, qreal hl, qreal hw, QPen& pen,
18 QGraphicsItem* parent = nullptr);
19 QArrow(qreal l, qreal a, QPen& pen, QGraphicsItem* parent = nullptr);
20 ~QArrow() override;
21
22 double getLength();
23 double getAngle();
24 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
25 QWidget* widget) override;
26 QRectF boundingRect() const override;
27 void setAngle(qreal a);
28 void setLength(qreal l);
29
30private:
31 double calcCos(double angle);
32 double calcSin(double angle);
33
39};
const double PI
Definition QArrow.h:9
~QArrow() override
QPen _arrowPen
Definition QArrow.h:38
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
Definition QArrow.cpp:84
qreal _arrowAngle
Definition QArrow.h:35
void setLength(qreal l)
Changes the length of the arrow.
Definition QArrow.cpp:119
QArrow(qreal l, qreal a, qreal hl, qreal hw, QPen &pen, QGraphicsItem *parent=nullptr)
Definition QArrow.cpp:19
QRectF boundingRect() const override
The bounding box of the arrow.
Definition QArrow.cpp:59
qreal _headLength
Definition QArrow.h:36
double getLength()
Returns the length of the arrow.
Definition QArrow.cpp:68
double calcSin(double angle)
Definition QArrow.cpp:53
qreal _headWidth
Definition QArrow.h:37
double calcCos(double angle)
Definition QArrow.cpp:48
double getAngle()
Returns the orientation of the arrow.
Definition QArrow.cpp:74
void setAngle(qreal a)
Changes orientation of the arrow.
Definition QArrow.cpp:113
qreal _arrowLength
Definition QArrow.h:34