Class: QgsLayoutNodesItem¶
An abstract layout item that provides generic methods for node based shapes such as polygon or polylines.
Class Hierarchy¶
Base classes¶
Base class for graphical items within a   | 
|
A base class for objects which belong to a layout.  | 
|
Abstract interface for generating an expression context.  | 
|
Interface for layout objects which support undo/redo commands.  | 
Subclasses¶
Layout item for node based polygon shapes.  | 
|
Layout item for node based polyline shapes.  | 
Methods
Add a node in current shape.  | 
|
Compute an euclidean distance between 2 nodes.  | 
|
Deselects any selected nodes.  | 
|
Moves a node to a new position.  | 
|
Search for the nearest node in the shape within a maximal area.  | 
|
Gets the position of a node in scene coordinates.  | 
|
Returns the nodes the shape consists of.  | 
|
Returns the number of nodes in the shape.  | 
|
Remove a node with specified index from the shape.  | 
|
Rescale the current shape according to the item's bounding box.  | 
|
Returns the currently selected node, or -1 if no node is selected.  | 
|
Set whether the item's nodes should be displayed.  | 
|
Sets the nodes the shape consists of.  | 
|
Selects a node by index.  | 
|
Called when the bounding rect of the item should recalculated.  | 
|
Update the current scene rectangle for this item.  | 
- class qgis.core.QgsLayoutNodesItem[source]¶
 Bases:
QgsLayoutItem- __init__(layout: QgsLayout | None)
 Constructor for QgsLayoutNodesItem, attached to the specified
layout.- Parameters:
 layout (Optional[QgsLayout])
- __init__(polygon: QPolygonF, layout: QgsLayout | None)
 Constructor for a QgsLayoutNodesItem with the given
polygonnodes, attached to the specifiedlayout.- Parameters:
 polygon (QPolygonF)
layout (Optional[QgsLayout])
- addNode(self, point: QPointF | QPoint, checkArea: bool = True, radius: float = 10) bool[source]¶
 Add a node in current shape.
- Parameters:
 point (Union[QPointF, QPoint]) – is the location of the new node (in scene coordinates)
checkArea (bool = True) – is a flag to indicate if there’s a space constraint.
radius (float = 10) – is the space constraint and is used only if checkArea is
True. Typically, if this flag isTrue, the new node has to be nearer than radius to the shape to be added.
- Return type:
 bool
- computeDistance(self, pt1: QPointF | QPoint, pt2: QPointF | QPoint) float[source]¶
 Compute an euclidean distance between 2 nodes.
- Parameters:
 pt1 (Union[QPointF, QPoint])
pt2 (Union[QPointF, QPoint])
- Return type:
 float
- moveNode(self, index: int, node: QPointF | QPoint) bool[source]¶
 Moves a node to a new position.
- Parameters:
 index (int) – the index of the node to move
node (Union[QPointF, QPoint]) – is the new position in scene coordinate
- Return type:
 bool
- nodeAtPosition(self, point: QPointF | QPoint, searchInRadius: bool = True, radius: float = 10) int[source]¶
 Search for the nearest node in the shape within a maximal area. Returns the index of the nearest node or -1 if no node was found.
- Parameters:
 point (Union[QPointF, QPoint]) – is the location to search for nodes from (in scene coordinates)
searchInRadius (bool = True) – is a flag to indicate if the area of research is limited in space.
radius (float = 10) – is only used if searchInRadius is
True
- Return type:
 int
- nodePosition(self, index: int, position: QPointF | QPoint) bool[source]¶
 Gets the position of a node in scene coordinates.
- Parameters:
 index (int) – of the node
position (Union[QPointF, QPoint]) – the position of the node
- Return type:
 bool
- Returns:
 Trueif the index is valid and the position is set,Falseotherwise
- nodes(self) QPolygonF[source]¶
 Returns the nodes the shape consists of.
See also
- Return type:
 QPolygonF
- removeNode(self, index: int) bool[source]¶
 Remove a node with specified
indexfrom the shape.- Parameters:
 index (int)
- Return type:
 bool
- rescaleToFitBoundingBox(self)[source]¶
 Rescale the current shape according to the item’s bounding box. Useful when the shape is resized thanks to the rubber band.
- selectedNode(self) int[source]¶
 Returns the currently selected node, or -1 if no node is selected.
- Return type:
 int
- setDisplayNodes(self, display: bool = True)[source]¶
 Set whether the item’s nodes should be displayed.
- Parameters:
 display (bool = True)
- setNodes(self, nodes: QPolygonF)[source]¶
 Sets the
nodesthe shape consists of.See also
- Parameters:
 nodes (QPolygonF)
- setSelectedNode(self, index: int) bool[source]¶
 Selects a node by
index.- Parameters:
 index (int)
- Return type:
 bool