Class: QgsLayoutNodesItem

class qgis.core.QgsLayoutNodesItem(layout: QgsLayout)

Bases: qgis._core.QgsLayoutItem

Constructor for QgsLayoutNodesItem, attached to the specified layout.

QgsLayoutNodesItem(polygon: QPolygonF, layout: QgsLayout) Constructor for a QgsLayoutNodesItem with the given polygon nodes, attached to the specified layout.

An abstract layout item that provides generic methods for node based shapes such as polygon or polylines.

New in version 3.0: Enums

Methods

addNode

Add a node in current shape.

adjustPointForReferencePosition

applyDataDefinedSize

applyItemSizeConstraint

boundingRect

childEvent

computeDistance

Compute an euclidian distance between 2 nodes.

connectNotify

contextMenuEvent

customEvent

deselectNode

Deselects any selected nodes.

disconnectNotify

dragEnterEvent

dragLeaveEvent

dragMoveEvent

draw

drawBackground

drawDebugRect

drawFrame

dropEvent

estimatedFrameBleed

focusInEvent

focusOutEvent

hoverEnterEvent

hoverLeaveEvent

hoverMoveEvent

inputMethodEvent

inputMethodQuery

isSignalConnected

itemChange

keyPressEvent

keyReleaseEvent

mouseDoubleClickEvent

mouseMoveEvent

mousePressEvent

mouseReleaseEvent

moveNode

Moves a node to a new position.

nodeAtPosition

Search for the nearest node in the shape within a maximal area.

nodePosition

Gets the position of a node in scene coordinates.

nodes

Returns the nodes the shape consists of.

nodesSize

Returns the number of nodes in the shape.

positionAtReferencePoint

prepareGeometryChange

readObjectPropertiesFromElement

readPropertiesFromElement

receivers

refreshBackgroundColor

refreshBlendMode

refreshFrame

refreshItemPosition

refreshItemRotation

refreshItemSize

refreshOpacity

removeNode

Remove a node with specified index from the shape.

rescaleToFitBoundingBox

Rescale the current shape according to the item’s bounding box.

sceneEvent

sceneEventFilter

selectedNode

Returns the currently selected node, or -1 if no node is selected.

sender

senderSignalIndex

setDisplayNodes

Set whether the item’s nodes should be displayed.

setFixedSize

setMinimumSize

setNodes

Sets the nodes the shape consists of.

setSelectedNode

Selects a node by index.

timerEvent

topLeftToReferencePoint

updateBoundingRect

Called when the bounding rect of the item should recalculated.

updateMicroFocus

updateSceneRect

Update the current scene rectangle for this item.

wheelEvent

writeObjectPropertiesToElement

writePropertiesToElement

Signals

Attributes

addNode(self, point: Union[QPointF, QPoint], checkArea: bool = True, radius: float = 10) → bool

Add a node in current shape.

Parameters
  • point – is the location of the new node (in scene coordinates)

  • checkArea – is a flag to indicate if there’s a space constraint.

  • radius – is the space contraint and is used only if checkArea is true. Typically, if this flag is true, the new node has to be nearer than radius to the shape to be added.

adjustPointForReferencePosition()
applyDataDefinedSize()
applyItemSizeConstraint()
boundingRect(self) → QRectF
childEvent()
computeDistance(self, pt1: Union[QPointF, QPoint], pt2: Union[QPointF, QPoint]) → float

Compute an euclidian distance between 2 nodes.

connectNotify()
contextMenuEvent()
customEvent()
deselectNode(self)

Deselects any selected nodes.

disconnectNotify()
dragEnterEvent()
dragLeaveEvent()
dragMoveEvent()
draw(self, context: QgsLayoutItemRenderContext)
drawBackground()
drawDebugRect()
drawFrame()
dropEvent()
estimatedFrameBleed(self) → float
focusInEvent()
focusOutEvent()
hoverEnterEvent()
hoverLeaveEvent()
hoverMoveEvent()
inputMethodEvent()
inputMethodQuery()
isSignalConnected()
itemChange()
keyPressEvent()
keyReleaseEvent()
mouseDoubleClickEvent()
mouseMoveEvent()
mousePressEvent()
mouseReleaseEvent()
moveNode(self, index: int, node: Union[QPointF, QPoint]) → bool

Moves a node to a new position.

Parameters
  • index – the index of the node to move

  • node – is the new position in scene coordinate

nodeAtPosition(self, point: Union[QPointF, QPoint], searchInRadius: bool = True, radius: float = 10) → int

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 – is the location to search for nodes from (in scene coordinates)

  • searchInRadius – is a flag to indicate if the area of research is limited in space.

  • radius – is only used if searchInRadius is true

nodePosition(self, index: int, position: Union[QPointF, QPoint]) → bool

Gets the position of a node in scene coordinates.

Parameters
  • index – of the node

  • position – the position of the node

Returns

true if the index is valid and the position is set, false otherwise

nodes(self) → QPolygonF

Returns the nodes the shape consists of.

See also

setNodes()

nodesSize(self) → int

Returns the number of nodes in the shape.

positionAtReferencePoint()
prepareGeometryChange()
readObjectPropertiesFromElement()
readPropertiesFromElement(self, element: QDomElement, document: QDomDocument, context: QgsReadWriteContext) → bool
receivers()
refreshBackgroundColor()
refreshBlendMode()
refreshFrame()
refreshItemPosition()
refreshItemRotation()
refreshItemSize()
refreshOpacity()
removeNode(self, index: int) → bool

Remove a node with specified index from the shape.

rescaleToFitBoundingBox(self)

Rescale the current shape according to the item’s bounding box. Useful when the shape is resized thanks to the rubber band.

sceneEvent()
sceneEventFilter()
selectedNode(self) → int

Returns the currently selected node, or -1 if no node is selected.

sender()
senderSignalIndex()
setDisplayNodes(self, display: bool = True)

Set whether the item’s nodes should be displayed.

setFixedSize()
setMinimumSize()
setNodes(self, nodes: QPolygonF)

Sets the nodes the shape consists of.

See also

nodes()

setSelectedNode(self, index: int) → bool

Selects a node by index.

timerEvent()
topLeftToReferencePoint()
updateBoundingRect(self)

Called when the bounding rect of the item should recalculated. Subclasses should update currentRectangle in their implementations.

updateMicroFocus()
updateSceneRect(self)

Update the current scene rectangle for this item.

wheelEvent()
writeObjectPropertiesToElement()
writePropertiesToElement(self, element: QDomElement, document: QDomDocument, context: QgsReadWriteContext) → bool