QGIS API Documentation 4.3.0-Master (0d5b841b09e)
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
179 int index() const { return mIndex; };
180
187 Qt::Edge edge() const { return mEdge; };
188
194 bool isInput() const { return mEdge == Qt::TopEdge; };
195
199 QgsProcessingModelComponent *component() { return mComponent; };
200
204 QgsModelComponentGraphicItem *componentItem() { return mComponentItem; };
205
206 /*
207 * Returns the color of the socket based on the type of data the param corresponds to.
208 * \since QGIS 4.0
209 */
210 QColor socketColor() const;
211
212 /*
213 * Returns TRUE if the parameter is set to the default parameter value.
214 * \since QGIS 4.0
215 */
216 bool isDefaultParameterValue() const;
217
218 signals:
219
220
221 private:
222 QgsModelComponentGraphicItem *mComponentItem = nullptr;
223 QgsProcessingModelComponent *mComponent = nullptr;
224 int mIndex = -1;
225 Qt::Edge mEdge = Qt::Edge::TopEdge;
226 float mSocketOutlineWidth = 1.5;
227};
228
229
231
232#endif // QGSMODELGRAPHICITEM_H
A mouse event which is the result of a user interaction with a QgsModelGraphicsView.