QGIS API Documentation 3.99.0-Master (26c88405ac0)
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"
22
23#include <QGraphicsObject>
24#include <QPicture>
25
26class QgsModelGraphicsView;
28
30
31
38class GUI_EXPORT QgsModelDesignerFlatButtonGraphicItem : public QGraphicsObject
39{
40 Q_OBJECT
41 public:
48 QgsModelDesignerFlatButtonGraphicItem( QGraphicsItem *parent SIP_TRANSFERTHIS, const QPicture &picture, const QPointF &position, const QSizeF &size = QSizeF( 16, 16 ) );
49
50 void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr ) override;
51 QRectF boundingRect() const override;
52 void hoverEnterEvent( QGraphicsSceneHoverEvent *event ) override;
53 void hoverLeaveEvent( QGraphicsSceneHoverEvent *event ) override;
54 void mousePressEvent( QGraphicsSceneMouseEvent *event ) override;
55
56#ifndef SIP_RUN
57
61 virtual void modelHoverEnterEvent( QgsModelViewMouseEvent *event );
62
66 virtual void modelHoverLeaveEvent( QgsModelViewMouseEvent *event );
67
71 virtual void modelPressEvent( QgsModelViewMouseEvent *event );
72#endif
73
77 QPointF position() const { return mPosition; };
78
79
83 void setPosition( const QPointF &position );
84
88 QgsModelGraphicsView *view();
89
90 signals:
91
95 void clicked();
96
97 protected:
101 void setPicture( const QPicture &picture );
102 bool mHoverState = false;
103
104 private:
105 QPicture mPicture;
106 QPointF mPosition;
107 QSizeF mSize;
108};
109
110
117class GUI_EXPORT QgsModelDesignerFoldButtonGraphicItem : public QgsModelDesignerFlatButtonGraphicItem
118{
119 Q_OBJECT
120 public:
129 QgsModelDesignerFoldButtonGraphicItem( QGraphicsItem *parent SIP_TRANSFERTHIS, bool folded, const QPointF &position, const QSizeF &size = QSizeF( 11, 11 ) );
130
131 void mousePressEvent( QGraphicsSceneMouseEvent *event ) override;
132#ifndef SIP_RUN
133 void modelPressEvent( QgsModelViewMouseEvent *event ) override;
134#endif
135
136 signals:
137
143 void folded( bool folded );
144
145 private:
146 QPicture mPlusPicture;
147 QPicture mMinusPicture;
148 bool mFolded = false;
149};
150
151
158class GUI_EXPORT QgsModelDesignerSocketGraphicItem : public QgsModelDesignerFlatButtonGraphicItem
159{
160 Q_OBJECT
161 public:
170 QgsModelDesignerSocketGraphicItem( QgsModelComponentGraphicItem *parent SIP_TRANSFERTHIS, QgsProcessingModelComponent *component, int index, const QPointF &position, Qt::Edge edge, const QSizeF &size = QSizeF( 11, 11 ) );
171
172 void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr ) override;
173
178 int index() const { return mIndex; };
179
186 Qt::Edge edge() const { return mEdge; };
187
193 bool isInput() const { return mEdge == Qt::TopEdge; };
194
198 QgsProcessingModelComponent *component() { return mComponent; };
199
203 QgsModelComponentGraphicItem *componentItem() { return mComponentItem; };
204
205 /*
206 * Returns the color of the socket based on the type of data the param corresponds to.
207 * \since QGIS 4.0
208 */
209 QColor socketColor() const;
210
211 /*
212 * Returns TRUE if the parameter is set to the default parameter value.
213 * \since QGIS 4.0
214 */
215 bool isDefaultParameterValue() const;
216
217 signals:
218
219
220 private:
221 QgsModelComponentGraphicItem *mComponentItem = nullptr;
222 QgsProcessingModelComponent *mComponent = nullptr;
223 int mIndex = -1;
224 Qt::Edge mEdge = Qt::Edge::TopEdge;
225 float mSocketOutlineWidth = 1.5;
226};
227
229
230#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