QGIS API Documentation 4.1.0-Master (5bf3c20f3c9)
Loading...
Searching...
No Matches
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
22#include <QGraphicsPathItem>
23#include <QObject>
24
25class QgsModelComponentGraphicItem;
26
28
29
36class GUI_EXPORT QgsModelArrowItem : public QObject, public QGraphicsPathItem
37{
38 Q_OBJECT
39 public:
40 enum Marker
41 {
42 Circle,
43 ArrowHead,
44 NoMarker
45 };
46
53 QgsModelArrowItem(
54 QgsModelComponentGraphicItem *startItem,
55 Qt::Edge startEdge,
56 int startIndex,
57 bool startIsOutgoing,
58 Marker startMarker,
59 QgsModelComponentGraphicItem *endItem,
60 Qt::Edge endEdge,
61 int endIndex,
62 bool endIsIncoming,
63 Marker endMarker
64 );
65
72 QgsModelArrowItem( QgsModelComponentGraphicItem *startItem, Qt::Edge startEdge, int startIndex, Marker startMarker, QgsModelComponentGraphicItem *endItem, Marker endMarker );
73
80 QgsModelArrowItem( QgsModelComponentGraphicItem *startItem, Marker startMarker, QgsModelComponentGraphicItem *endItem, Qt::Edge endEdge, int endIndex, Marker endMarker );
81
87 QgsModelArrowItem( QgsModelComponentGraphicItem *startItem, Marker startMarker, QgsModelComponentGraphicItem *endItem, Marker endMarker );
88
89 void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr ) override;
90
94 void setPenStyle( Qt::PenStyle style );
95
96 signals:
97
103 void painterPathUpdated();
104
105 public slots:
106
110 void updatePath();
111
112 private:
113 QPointF bezierPointForCurve( const QPointF &point, Qt::Edge edge, bool incoming, bool hasSpecificDirectionalFlow ) const;
114
115 void drawArrowHead( QPainter *painter, const QPointF &point, const QPointF &vector );
116
117 QgsModelComponentGraphicItem *mStartItem = nullptr;
118 Qt::Edge mStartEdge = Qt::LeftEdge;
119 int mStartIndex = -1;
120 bool mStartIsOutgoing = true;
121 Marker mStartMarker;
122
123 QgsModelComponentGraphicItem *mEndItem = nullptr;
124 Qt::Edge mEndEdge = Qt::LeftEdge;
125 int mEndIndex = -1;
126 bool mEndIsIncoming = false;
127 Marker mEndMarker;
128
129 QPointF mStartPoint;
130 QPointF mEndPoint;
131
132 QColor mColor;
133};
134
136
137#endif // QGSMODELARROWITEM_H