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 
25 class QTransform;
26 
31 class Q_DECL_EXPORT ArrowItem :
33 {
34 public:
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);
62  ArrowItem(const ArrowItem& a);
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();
90  void setPenWidth();
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 
113 protected:
115  virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
117  void setProperties();
118  bool m_doubleHeaded;
119  Symbol m_symbol;
120  double l2, lHead;
121  QPolygonF head;
122 };
123 
124 #endif
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void writePlo(KConfigGroup *plo, bool visible) const
Writes into plot file.
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)=0
Symbol
Symbol types.
Definition: kplitem.h:83
void setDoubleHeaded(bool b)
Sets doubleheaded mode.
Definition: arrowitem.h:86
void update(const QRectF &rect)
Symbol symbol() const
Returns line type.
Definition: arrowitem.h:102
Arrow item class.
Definition: arrowitem.h:31
bool doubleHeaded() const
Returns true for doubleheaded arrow.
Definition: arrowitem.h:76
virtual int type() const
Returns specific QGraphicsItem type number.
Definition: arrowitem.h:104
static QPixmap pixmap(Symbol symbol)
Returns black decoration pixmap of plot symbol for use in dialog GUI.
virtual QRectF boundingRect() const =0
Vector item class.
Definition: vectoritem.h:33
void setSymbol(Symbol symbol)
Sets line type.
Definition: arrowitem.h:100