QGIS API Documentation 3.99.0-Master (09f76ad7019)
Loading...
Searching...
No Matches
qgsmodelgraphicitem.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmodelgraphicitem.h
3 ----------------------------------
4 Date : February 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 QGSMODELGRAPHICITEM_H
17#define QGSMODELGRAPHICITEM_H
18
19#include "qgis.h"
20#include "qgis_gui.h"
21#include "qgsmodelarrowitem.h"
23
24#include <QGraphicsObject>
25#include <QGraphicsTextItem>
26#include <QPicture>
27
28class QgsModelGraphicsView;
30
32
33
40class GUI_EXPORT QgsModelDesignerFlatButtonGraphicItem : public QGraphicsObject
41{
42 Q_OBJECT
43 public:
50 QgsModelDesignerFlatButtonGraphicItem( QGraphicsItem *parent SIP_TRANSFERTHIS, const QPicture &picture, const QPointF &position, const QSizeF &size = QSizeF( 16, 16 ) );
51
52 void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr ) override;
53 QRectF boundingRect() const override;
54 void hoverEnterEvent( QGraphicsSceneHoverEvent *event ) override;
55 void hoverLeaveEvent( QGraphicsSceneHoverEvent *event ) override;
56 void mousePressEvent( QGraphicsSceneMouseEvent *event ) override;
57
58#ifndef SIP_RUN
59
63 virtual void modelHoverEnterEvent( QgsModelViewMouseEvent *event );
64
68 virtual void modelHoverLeaveEvent( QgsModelViewMouseEvent *event );
69
73 virtual void modelPressEvent( QgsModelViewMouseEvent *event );
74#endif
75
79 QPointF position() const { return mPosition; };
80
81
85 void setPosition( const QPointF &position );
86
90 QgsModelGraphicsView *view();
91
92 signals:
93
97 void clicked();
98
99 protected:
103 void setPicture( const QPicture &picture );
104 bool mHoverState = false;
105
106 private:
107 QPicture mPicture;
108 QPointF mPosition;
109 QSizeF mSize;
110};
111
112
119class GUI_EXPORT QgsModelDesignerFoldButtonGraphicItem : public QgsModelDesignerFlatButtonGraphicItem
120{
121 Q_OBJECT
122 public:
131 QgsModelDesignerFoldButtonGraphicItem( QGraphicsItem *parent SIP_TRANSFERTHIS, bool folded, const QPointF &position, const QSizeF &size = QSizeF( 11, 11 ) );
132
133 void mousePressEvent( QGraphicsSceneMouseEvent *event ) override;
134#ifndef SIP_RUN
135 void modelPressEvent( QgsModelViewMouseEvent *event ) override;
136#endif
137
138 signals:
139
145 void folded( bool folded );
146
147 private:
148 QPicture mPlusPicture;
149 QPicture mMinusPicture;
150 bool mFolded = false;
151};
152
153
160class GUI_EXPORT QgsModelDesignerSocketGraphicItem : public QgsModelDesignerFlatButtonGraphicItem
161{
162 Q_OBJECT
163 public:
172 QgsModelDesignerSocketGraphicItem( QgsModelComponentGraphicItem *parent SIP_TRANSFERTHIS, QgsProcessingModelComponent *component, int index, const QPointF &position, Qt::Edge edge, const QSizeF &size = QSizeF( 11, 11 ) );
173
174 void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr ) override;
175
180 int index() const { return mIndex; };
181
188 Qt::Edge edge() const { return mEdge; };
189
195 bool isInput() const { return mEdge == Qt::TopEdge; };
196
200 QgsProcessingModelComponent *component() { return mComponent; };
201
205 QgsModelComponentGraphicItem *componentItem() { return mComponentItem; };
206
207 /*
208 * Returns the color of the socket based on the type of data the param corresponds to.
209 * \since QGIS 4.0
210 */
211 QColor socketColor() const;
212
213 /*
214 * Returns TRUE if the parameter is set to the default parameter value.
215 * \since QGIS 4.0
216 */
217 bool isDefaultParameterValue() const;
218
219 signals:
220
221
222 private:
223 QgsModelComponentGraphicItem *mComponentItem = nullptr;
224 QgsProcessingModelComponent *mComponent = nullptr;
225 int mIndex = -1;
226 Qt::Edge mEdge = Qt::Edge::TopEdge;
227 float mSocketOutlineWidth = 1.5;
228};
229
236class GUI_EXPORT QgsModelDesignerFeatureCountGraphicItem : public QGraphicsTextItem SIP_SKIP
237{
238 Q_OBJECT
239 public:
240 QgsModelDesignerFeatureCountGraphicItem( QgsModelArrowItem *link SIP_TRANSFERTHIS, const QString &text );
241
242 void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr ) override;
243
244 protected:
248 void setPosition();
249
250 private:
251 QgsModelArrowItem *mLink = nullptr;
252 static constexpr int FONT_SIZE = 10; // Font size for the feature count text
253};
255
256#endif // QGSMODELGRAPHICITEM_H
A mouse event which is the result of a user interaction with a QgsModelGraphicsView.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_SKIP
Definition qgis_sip.h:134