QGIS API Documentation 4.3.0-Master (3b7b3208a79)
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
28#define SIP_NO_FILE
29
30class QgsModelGraphicsView;
32
34
35
42class GUI_EXPORT QgsModelDesignerFlatButtonGraphicItem : public QGraphicsObject
43{
44 Q_OBJECT
45 public:
52 QgsModelDesignerFlatButtonGraphicItem( QGraphicsItem *parent, const QPicture &picture, const QPointF &position, const QSizeF &size = QSizeF( 16, 16 ) );
53
54 void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr ) override;
55 QRectF boundingRect() const override;
56 void hoverEnterEvent( QGraphicsSceneHoverEvent *event ) override;
57 void hoverLeaveEvent( QGraphicsSceneHoverEvent *event ) override;
58 void mousePressEvent( QGraphicsSceneMouseEvent *event ) override;
59
63 virtual void modelHoverEnterEvent( QgsModelViewMouseEvent *event );
64
68 virtual void modelHoverLeaveEvent( QgsModelViewMouseEvent *event );
69
73 virtual void modelPressEvent( QgsModelViewMouseEvent *event );
74
78 QPointF position() const { return mPosition; };
79
80
84 void setPosition( const QPointF &position );
85
89 QgsModelGraphicsView *view();
90
91 signals:
92
96 void clicked();
97
98 protected:
102 void setPicture( const QPicture &picture );
103 bool mHoverState = false;
104
105 private:
106 QPicture mPicture;
107 QPointF mPosition;
108 QSizeF mSize;
109};
110
111
118class GUI_EXPORT QgsModelDesignerFoldButtonGraphicItem : public QgsModelDesignerFlatButtonGraphicItem
119{
120 Q_OBJECT
121 public:
130 QgsModelDesignerFoldButtonGraphicItem( QGraphicsItem *parent, bool folded, const QPointF &position, const QSizeF &size = QSizeF( 11, 11 ) );
131
132 void mousePressEvent( QGraphicsSceneMouseEvent *event ) override;
133 void modelPressEvent( QgsModelViewMouseEvent *event ) override;
134
135 signals:
136
142 void folded( bool folded );
143
144 private:
145 QPicture mPlusPicture;
146 QPicture mMinusPicture;
147 bool mFolded = false;
148};
149
150
157class GUI_EXPORT QgsModelDesignerSocketGraphicItem : public QgsModelDesignerFlatButtonGraphicItem
158{
159 Q_OBJECT
160 public:
169 QgsModelDesignerSocketGraphicItem(
170 QgsModelComponentGraphicItem *parent, QgsProcessingModelComponent *component, int index, const QPointF &position, Qt::Edge edge, const QSizeF &size = QSizeF( 11, 11 )
171 );
172
173 void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr ) override;
174 QRectF boundingRect() const 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
206 const QgsProcessingModelComponent *component() const SIP_SKIP { return mComponent; };
207
211 QgsModelComponentGraphicItem *componentItem() { return mComponentItem; };
212
213 /*
214 * Returns the color of the socket based on the type of data the param corresponds to.
215 * \since QGIS 4.0
216 */
217 QColor socketColor() const;
218
219 /*
220 * Returns TRUE if the parameter is set to the default parameter value.
221 * \since QGIS 4.0
222 */
223 bool isDefaultParameterValue() const;
224
225 signals:
226
227
228 private:
229 QgsModelComponentGraphicItem *mComponentItem = nullptr;
230 QgsProcessingModelComponent *mComponent = nullptr;
231 int mIndex = -1;
232 Qt::Edge mEdge = Qt::Edge::TopEdge;
233 float mSocketOutlineWidth = 1.5;
234};
235
236
238
239#endif // QGSMODELGRAPHICITEM_H
A mouse event which is the result of a user interaction with a QgsModelGraphicsView.
#define SIP_SKIP
Definition qgis_sip.h:138