Class: QgsModelComponentGraphicItem¶
Base class for graphic items representing model components in the model designer.
Warning
Not stable API
Added in version 3.14.
Class Hierarchy¶
Base classes¶
Subclasses¶
A graphic item representing a child algorithm in the model designer. |
|
A graphic item representing a model comment in the model designer. |
|
A graphic item representing a group box in the model designer. |
|
A graphic item representing a model output in the model designer. |
|
A graphic item representing a model parameter (input) in the model designer. |
Methods
Returns the best link point to use for a link originating at a specified other item. |
|
Returns |
|
Returns the model component associated with this item. |
|
Called when the component should be deleted. |
|
Called when the comment attached to the item should be edited. |
|
Called when the component should be edited. |
|
Returns the fill color for the item for the specified state. |
|
Returns item flags. |
|
Returns the font used to render text in the item. |
|
Returns a QPicture version of the item's icon, if available. |
|
Returns a QPixmap version of the item's icon, if available. |
|
Returns the rectangle representing the body of the item. |
|
Returns the item's label text. |
|
Returns the location of the link point with the specified index on the specified edge. |
|
Returns the number of link points associated with the component on the specified edge. |
|
Returns the text to use for the link point with the specified index on the specified edge. |
|
Returns the model associated with this item. |
|
Moves the component by the specified dx and dy. |
|
Shows a preview of moving the item from its stored position by dx, dy. |
|
Sets the font used to render text in the item. |
|
Sets a new scene rect for the item. |
|
Returns the item's label text. |
|
Returns the item's current state. |
|
Returns the stroke color for the item for the specified state. |
|
Returns the stroke style to use while rendering the outline of the item. |
|
Returns the label text color for the item for the specified state. |
|
Returns the title alignment |
|
Truncates a text string so that it fits nicely within the item's width, accounting for margins and interactive buttons. |
|
Updates the item's button positions, based on the current item rect. |
|
Updates the position and size stored in the model for the associated comment |
|
Returns the associated view. |
Signals
Emitted when the definition of the associated component is about to be changed by the item. |
|
Emitted when the definition of the associated component is changed by the item. |
|
Emitted when item requests that all connected arrows are repainted. |
|
Emitted by the item to request a repaint of the parent model scene. |
|
Emitted when the item's size or position changes. |
|
Emitted when item requires that all connected arrow paths are recalculated. |
Attributes
- class qgis.gui.QgsModelComponentGraphicItem[source]¶
Bases:
QGraphicsObject
- __init__(component: QgsProcessingModelComponent | None, model: QgsProcessingModelAlgorithm | None, parent: QGraphicsItem | None)
Constructor for QgsModelComponentGraphicItem for the specified
component
, with the specifiedparent
item.The
model
argument specifies the associated processing model. Ownership ofmodel
is not transferred, and it must exist for the lifetime of this object.Ownership of
component
is transferred to the item.- Parameters:
component (Optional[QgsProcessingModelComponent])
model (Optional[QgsProcessingModelAlgorithm])
parent (Optional[QGraphicsItem])
- class Flag¶
Bases:
int
- class Flags¶
- class Flags(f: QgsModelComponentGraphicItem.Flags | QgsModelComponentGraphicItem.Flag)
- class Flags(a0: QgsModelComponentGraphicItem.Flags)
Bases:
object
- Hover = 2¶
- Normal = 0¶
- Selected = 1¶
- class State¶
Bases:
int
- Unused = 1¶
- signal aboutToChange(text: str, id: int = 0)[source]¶
Emitted when the definition of the associated component is about to be changed by the item.
The
text
argument gives the translated text describing the change about to occur, and the optionalid
can be used to group the associated undo commands.- Parameters:
text (str)
id (int = 0)
- calculateAutomaticLinkPoint(self, other: QgsModelComponentGraphicItem | None)[source]¶
Returns the best link point to use for a link originating at a specified
other
item.- Parameters:
other (Optional[QgsModelComponentGraphicItem]) -> (QPointF) – item at other end of link
- Returns:
calculated link point in item coordinates.
edge: item edge for calculated best link point
- calculateAutomaticLinkPoint(self, point: QPointF | QPoint)[source]
Returns the best link point to use for a link originating at a specified
other
point.- Parameters:
other – point for other end of link (in scene coordinates)
point (Union[QPointF, QPoint]) -> (QPointF)
- Returns:
calculated link point in item coordinates.
edge: item edge for calculated best link point
- canDeleteComponent(self) bool [source]¶
Returns
True
if the component can be deleted.- Return type:
bool
- signal changed[source]¶
Emitted when the definition of the associated component is changed by the item.
- component(self) QgsProcessingModelComponent | None [source]¶
Returns the model component associated with this item.
- Return type:
Optional[QgsProcessingModelComponent]
- deleteComponent(self)[source]¶
Called when the component should be deleted.
The default implementation does nothing.
- editComment(self)[source]¶
Called when the comment attached to the item should be edited.
The default implementation does nothing.
- editComponent(self)[source]¶
Called when the component should be edited.
The default implementation does nothing.
- fillColor(self, state: QgsModelComponentGraphicItem.State) QColor [source]¶
Returns the fill color for the item for the specified
state
.- Parameters:
- Return type:
QColor
- flags(self) QgsModelComponentGraphicItem.Flags [source]¶
Returns item flags.
- Return type:
- font(self) QFont [source]¶
Returns the font used to render text in the item.
See also
- Return type:
QFont
- iconPicture(self) QPicture [source]¶
Returns a QPicture version of the item’s icon, if available.
- Return type:
QPicture
- iconPixmap(self) QPixmap [source]¶
Returns a QPixmap version of the item’s icon, if available.
- Return type:
QPixmap
- itemRect(self, storedRect: bool = False) QRectF [source]¶
Returns the rectangle representing the body of the item.
- Parameters:
storedRect (bool = False)
- Return type:
QRectF
- linkPoint(self, edge: Qt.Edge, index: int, incoming: bool) QPointF [source]¶
Returns the location of the link point with the specified
index
on the specifiededge
.- Parameters:
edge (Qt.Edge)
index (int)
incoming (bool)
- Return type:
QPointF
- linkPointCount(self, edge: Qt.Edge) int [source]¶
Returns the number of link points associated with the component on the specified
edge
.- Parameters:
edge (Qt.Edge)
- Return type:
int
- linkPointText(self, edge: Qt.Edge, index: int) str [source]¶
Returns the text to use for the link point with the specified
index
on the specifiededge
.- Parameters:
edge (Qt.Edge)
index (int)
- Return type:
str
- model(self) QgsProcessingModelAlgorithm | None [source]¶
Returns the model associated with this item.
- Return type:
Optional[QgsProcessingModelAlgorithm]
- moveComponentBy(self, dx: float, dy: float)[source]¶
Moves the component by the specified
dx
anddy
.Warning
Call this method, not QGraphicsItem.moveBy!
- Parameters:
dx (float)
dy (float)
- previewItemMove(self, dx: float, dy: float)[source]¶
Shows a preview of moving the item from its stored position by
dx
,dy
.- Parameters:
dx (float)
dy (float)
- signal requestModelRepaint[source]¶
Emitted by the item to request a repaint of the parent model scene.
- setFont(self, font: QFont)[source]¶
Sets the
font
used to render text in the item.See also
- Parameters:
font (QFont)
- setItemRect(self, rect: QRectF)[source]¶
Sets a new scene
rect
for the item.- Parameters:
rect (QRectF)
- setLabel(self, label: str | None)[source]¶
Returns the item’s
label
text.See also
- Parameters:
label (Optional[str])
- state(self) QgsModelComponentGraphicItem.State [source]¶
Returns the item’s current state.
- Return type:
- strokeColor(self, state: QgsModelComponentGraphicItem.State) QColor [source]¶
Returns the stroke color for the item for the specified
state
.- Parameters:
- Return type:
QColor
- strokeStyle(self, state: QgsModelComponentGraphicItem.State) Qt.PenStyle [source]¶
Returns the stroke style to use while rendering the outline of the item.
- Parameters:
- Return type:
Qt.PenStyle
- textColor(self, state: QgsModelComponentGraphicItem.State) QColor [source]¶
Returns the label text color for the item for the specified
state
.- Parameters:
- Return type:
QColor
- truncatedTextForItem(self, text: str | None) str [source]¶
Truncates a
text
string so that it fits nicely within the item’s width, accounting for margins and interactive buttons.- Parameters:
text (Optional[str])
- Return type:
str
- signal updateArrowPaths[source]¶
Emitted when item requires that all connected arrow paths are recalculated.
- updateButtonPositions(self)[source]¶
Updates the item’s button positions, based on the current item rect.
- updateStoredComponentPosition(self, pos: QPointF | QPoint, size: QSizeF)[source]¶
Updates the position and size stored in the model for the associated comment
- Parameters:
pos (Union[QPointF, QPoint])
size (QSizeF)
- view(self) QgsModelGraphicsView | None [source]¶
Returns the associated view.
- Return type:
Optional[QgsModelGraphicsView]