libkpl  5.0
A Library for Graphical Presentation of Data Sets and Functions
arrowitem.h
1/***************************************************************************
2 arrowitem.h - description
3 -------------------
4 begin : Sat Apr 14 2001
5 copyright : (C) 2017 by Werner Stille
6 email : kpl@werner-stille.de
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef ARROWITEM_H
19#define ARROWITEM_H
20
21#include <QAbstractGraphicsShapeItem>
22#include <QPolygonF>
23#include "vectoritem.h"
24
25class QTransform;
26
31class Q_DECL_EXPORT ArrowItem :
32 public VectorItem, public QAbstractGraphicsShapeItem
33{
34public:
36 enum {Type = UserType + Arrow
40 };
54 ArrowItem(double x0 = 0, double y0 = 0, unsigned color = 0,
55 QGraphicsItem* parent = 0, double length = 1, bool visible = true,
56 bool doubleHeaded = false, Symbol symbol = SolidLine,
57 double relSize = 1, double dir = 0);
69 ArrowItem(const KConfigGroup* plo, unsigned color = 0,
70 QGraphicsItem* parent = 0);
72 virtual ~ArrowItem();
74 virtual QRectF boundingRect() const;
76 inline bool doubleHeaded() const { return m_doubleHeaded; };
78 virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
79 QWidget* widget = 0);
81 QPixmap pixmap() const;
86 inline void setDoubleHeaded(bool b) { m_doubleHeaded = b; };
88 void setHead();
95 void setProperties(const QTransform& m);
100 inline void setSymbol(Symbol symbol) { m_symbol = symbol; };
102 inline Symbol symbol() const { return m_symbol; };
104 virtual int type() const { return Type; };
106 void update();
111 void writePlo(KConfigGroup* plo) const;
112
113protected:
115 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
118 bool m_doubleHeaded;
119 Symbol m_symbol;
120 double l2, lHead;
121 QPolygonF head;
122};
123
124#endif
Arrow item class.
Definition: arrowitem.h:33
virtual ~ArrowItem()
Destructor.
virtual QRectF boundingRect() const
Calculates bounding rectangle.
void setDoubleHeaded(bool b)
Sets doubleheaded mode.
Definition: arrowitem.h:86
ArrowItem(const ArrowItem &a)
Copy constructor.
void setPenWidth()
Sets pen width.
void writePlo(KConfigGroup *plo) const
Writes into plot file.
QPixmap pixmap() const
Returns decoration pixmap for item list.
ArrowItem(const KConfigGroup *plo, unsigned color=0, QGraphicsItem *parent=0)
Constructor.
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)
Paints item.
Symbol symbol() const
Returns line type.
Definition: arrowitem.h:102
bool doubleHeaded() const
Returns true for doubleheaded arrow.
Definition: arrowitem.h:76
void setHead()
Sets head shape.
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
Updates position.
void setProperties()
Sets properties according to transformation matrix.
void update()
Applies changes and forces redrawing.
void setProperties(const QTransform &m)
Sets properties according to transformation matrix.
virtual int type() const
Returns specific QGraphicsItem type number.
Definition: arrowitem.h:104
ArrowItem(double x0=0, double y0=0, unsigned color=0, QGraphicsItem *parent=0, double length=1, bool visible=true, bool doubleHeaded=false, Symbol symbol=SolidLine, double relSize=1, double dir=0)
Constructor.
void setSymbol(Symbol symbol)
Sets line type.
Definition: arrowitem.h:100
Symbol
Symbol types.
Definition: kplitem.h:83
Vector item class.
Definition: vectoritem.h:34