QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
qgsmodelarrowitem.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmodelarrowitem.h
3 ----------------------------------
4 Date : March 2020
5 Copyright : (C) 2020 Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSMODELARROWITEM_H
17#define QGSMODELARROWITEM_H
18
19#include "qgis.h"
20#include "qgis_gui.h"
21#include <QGraphicsPathItem>
22#include <QObject>
23
24class QgsModelComponentGraphicItem;
25
27
28
35class GUI_EXPORT QgsModelArrowItem : public QObject, public QGraphicsPathItem
36{
37 Q_OBJECT
38 public:
39
40 enum Marker
41 {
42 Circle,
43 ArrowHead,
44 };
45
52 QgsModelArrowItem( QgsModelComponentGraphicItem *startItem, Qt::Edge startEdge, int startIndex, bool startIsOutgoing, Marker startMarker,
53 QgsModelComponentGraphicItem *endItem, Qt::Edge endEdge, int endIndex, bool endIsIncoming, Marker endMarker );
54
61 QgsModelArrowItem( QgsModelComponentGraphicItem *startItem, Qt::Edge startEdge, int startIndex, Marker startMarker,
62 QgsModelComponentGraphicItem *endItem, Marker endMarker );
63
70 QgsModelArrowItem( QgsModelComponentGraphicItem *startItem, Marker startMarker,
71 QgsModelComponentGraphicItem *endItem, Qt::Edge endEdge, int endIndex, Marker endMarker );
72
78 QgsModelArrowItem( QgsModelComponentGraphicItem *startItem, Marker startMarker,
79 QgsModelComponentGraphicItem *endItem, Marker endMarker );
80
81 void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr ) override;
82
86 void setPenStyle( Qt::PenStyle style );
87
88 public slots:
89
93 void updatePath();
94
95 private:
96
97 QPointF bezierPointForCurve( const QPointF &point, Qt::Edge edge, bool incoming, bool hasSpecificDirectionalFlow ) const;
98
99 void drawArrowHead( QPainter *painter, const QPointF &point, const QPointF &vector );
100
101 QgsModelComponentGraphicItem *mStartItem = nullptr;
102 Qt::Edge mStartEdge = Qt::LeftEdge;
103 int mStartIndex = -1;
104 bool mStartIsOutgoing = true;
105 Marker mStartMarker;
106
107 QgsModelComponentGraphicItem *mEndItem = nullptr;
108 Qt::Edge mEndEdge = Qt::LeftEdge;
109 int mEndIndex = -1;
110 bool mEndIsIncoming = false;
111 Marker mEndMarker;
112
113 QPointF mStartPoint;
114 QPointF mEndPoint;
115
116 QColor mColor;
117};
118
120
121#endif // QGSMODELARROWITEM_H