nexxT.services.gui.GraphEditor module

This module provides the graph editor GUI service of the nexxT service.

class nexxT.services.gui.GraphEditor.BaseGraphScene(parent)[source]

Bases: QGraphicsScene

Basic graph display and manipulation scene. Generic base class intended to be overwritten.

class ConnectionItem(portFrom, portTo)[source]

Bases: QGraphicsPathItem

This item corresponds with a connection between an output and an input port.

__init__(self, path: PySide6.QtGui.QPainterPath, /, parent: PySide6.QtWidgets.QGraphicsItem | None = None) None[source]
__init__(self, /, parent: PySide6.QtWidgets.QGraphicsItem | None = None) None

Initialize self. See help(type(self)) for accurate signature.

hoverEnterEvent(event)[source]

override for hover enter events

Parameters:

event – the QT event

Returns:

hoverLeaveEvent(event)[source]

override for hover leave events

Parameters:

event – the QT event

Returns:

static itemTypeName()[source]

Returns an identificytion string.

Returns:

shape()[source]

Unsure if this is needed, but it may give better hover positions

Returns:

sync()[source]

Synchronizes the view with the model.

Returns:

KEY_ITEM = 0
class NodeItem(name)[source]

Bases: QGraphicsItemGroup

An item which represents a node in the graph. The item group is also used for grouping the port items.

__init__(self, /, parent: PySide6.QtWidgets.QGraphicsItem | None = None) None[source]

Initialize self. See help(type(self)) for accurate signature.

addInPortItem(name)[source]

Adds a new input port to the node

Parameters:

name – the port name

Returns:

addOutPortItem(name)[source]

Adds a new output port to the node

Parameters:

name – the port name

Returns:

getInPortItem(name)[source]

Searches for the input port named by name

Parameters:

name – a string instance

Returns:

a PortItem instance

getOutPortItem(name)[source]

Searches for the output port named by name

Parameters:

name – a string instance

Returns:

a PortItem instance

hoverEnter()[source]

Slot called on hover enter

Returns:

hoverLeave()[source]

Slot called on hover leave.

Returns:

itemChange(change, value)[source]

overwritten from QGraphicsItem

Parameters:
  • change – the thing that has changed

  • value – the new value

Returns:

static itemTypeName()[source]

return a class identification name.

Returns:

nodeHeight()[source]
Returns:

the node height in pixels including spacing.

nodeWidth()[source]
Returns:

the node width in pixels including spacing.

paint(painter, option, widget)[source]

Overwritten from base class to prevent drawing the selection rectangle

Parameters:
  • painter – a QPainter instance

  • option – a QStyleOptionGraphicsItem instance

  • widget – a QWidget instance or None

Returns:

sync()[source]

synchronize the item with the model (also the ports)

Returns:

class PortItem(name, nodeItem)[source]

Bases: object

This class represents a port in a node.

__init__(name, nodeItem)[source]
hoverEnter()[source]

Slot called on hover enter

Returns:

hoverLeave()[source]

Slot called on hover leave.

Returns:

static itemTypeName()[source]

Returns a class identification string.

Returns:

remove()[source]

Removes this port from its item group.

Returns:

scenePosChanged(value)[source]

Slot called on scene position changes, need to synchronize connections.

Parameters:

value

Returns:

setPos(x, y, isOutput)[source]

Sets the position of this item to the given coordinates, assigns output / input property.

Parameters:
  • x – the x coordinate

  • y – the y coordinate

  • isOutput – a boolean

Returns:

sync()[source]

Synchronizes the item to the model.

Returns:

STYLE_ROLE_BRUSH = 2
STYLE_ROLE_HSPACING = 5
STYLE_ROLE_PEN = 1
STYLE_ROLE_RRRADIUS = 3
STYLE_ROLE_SIZE = 0
STYLE_ROLE_TEXT_BRUSH = 6
STYLE_ROLE_VSPACING = 4
__init__(self, sceneRect: PySide6.QtCore.QRectF, /, parent: PySide6.QtCore.QObject | None = None, *, backgroundBrush: PySide6.QtGui.QBrush | None = None, foregroundBrush: PySide6.QtGui.QBrush | None = None, itemIndexMethod: PySide6.QtWidgets.QGraphicsScene.ItemIndexMethod | None = None, bspTreeDepth: int | None = None, palette: PySide6.QtGui.QPalette | None = None, font: PySide6.QtGui.QFont | None = None, stickyFocus: bool | None = None, minimumRenderSize: float | None = None, focusOnTouch: bool | None = None) None[source]
__init__(self, /, parent: PySide6.QtCore.QObject | None = None, *, backgroundBrush: PySide6.QtGui.QBrush | None = None, foregroundBrush: PySide6.QtGui.QBrush | None = None, itemIndexMethod: PySide6.QtWidgets.QGraphicsScene.ItemIndexMethod | None = None, sceneRect: PySide6.QtCore.QRectF | None = None, bspTreeDepth: int | None = None, palette: PySide6.QtGui.QPalette | None = None, font: PySide6.QtGui.QFont | None = None, stickyFocus: bool | None = None, minimumRenderSize: float | None = None, focusOnTouch: bool | None = None) None
__init__(self, x: float, y: float, width: float, height: float, /, parent: PySide6.QtCore.QObject | None = None, *, backgroundBrush: PySide6.QtGui.QBrush | None = None, foregroundBrush: PySide6.QtGui.QBrush | None = None, itemIndexMethod: PySide6.QtWidgets.QGraphicsScene.ItemIndexMethod | None = None, sceneRect: PySide6.QtCore.QRectF | None = None, bspTreeDepth: int | None = None, palette: PySide6.QtGui.QPalette | None = None, font: PySide6.QtGui.QFont | None = None, stickyFocus: bool | None = None, minimumRenderSize: float | None = None, focusOnTouch: bool | None = None) None

Initialize self. See help(type(self)) for accurate signature.

addConnection(nodeFrom, portFrom, nodeTo, portTo)[source]

Add a connection to the graph

Parameters:
  • nodeFrom – the start node’s name

  • portFrom – the start node’s port

  • nodeTo – the end node’s name

  • portTo – the end node’s port

Returns:

addInPort(node, name)[source]

add an input port to a node

Parameters:
  • node – the node name

  • name – the port name

Returns:

addNode(name)[source]

Add a named node to the graph

Parameters:

name – a string instance

Returns:

addOutPort(node, name)[source]

Adds an output port to a node

Parameters:
  • node – the node name

  • name – the port name

Returns:

autoLayout()[source]

Automatic layout of nodes using a heuristic layering algorithm.

Returns:

connectionAddRequest
static getData(item, role)[source]

returns render-relevant information about the specified item can be overriden in concrete editor instances

Parameters:
  • item – an instance of BaseGraphScene.NodeItem, BaseGraphScene.PortItem or BaseGraphScene.ConnectionItem

  • role – one of STYLE_ROLE_SIZE, STYLE_ROLE_PEN, STYLE_ROLE_BRUSH, STYLE_ROLE_RRRADIUS, STYLE_ROLE_VSPACING, STYLE_ROLE_HSPACING

Returns:

the expected item related to the role

graphItemAt(scenePos)[source]

Returns the graph item at the specified scene position

Parameters:

scenePos – a QPoint instance

Returns:

a NodeItem, PortItem or ConnectionItem instance

mouseMoveEvent(event)[source]

Override from QGraphicsScene (used for dragging connections)

Parameters:

event – the QT event

Returns:

mousePressEvent(event)[source]

Override from QGraphicsScene (used for dragging connections)

Parameters:

event – the QT event

Returns:

mouseReleaseEvent(event)[source]

Override from QGraphicsScene (used for dragging connections)

Parameters:

event – the QT event

Returns:

removeConnection(nodeFrom, portFrom, nodeTo, portTo)[source]

Removes a connection from the graph

Parameters:
  • nodeFrom – the start node’s name

  • portFrom – the start node’s port

  • nodeTo – the end node’s name

  • portTo – the end node’s port

Returns:

removeInPort(node, name)[source]

Remove an input port from a node

Parameters:
  • node – the node name

  • name – the port name

Returns:

removeNode(name)[source]

Remove a node from the graph

Parameters:

name – the node name

Returns:

removeOutPort(node, name)[source]

Remove an output port from a node

Parameters:
  • node – the node name

  • name – the port name

Returns:

renameInPort(node, oldName, newName)[source]

Rename an input port from a node

Parameters:
  • node – the node name

  • oldName – the old port name

  • newName – the new port name

Returns:

renameNode(oldName, newName)[source]

Rename a node in the graph

Parameters:
  • oldName – the old name

  • newName – the new name

Returns:

renameOutPort(node, oldName, newName)[source]

Rename an output port from a node

Parameters:
  • node – the node name

  • oldName – the old port name

  • newName – the new port name

Returns:

staticMetaObject = PySide6.QtCore.QMetaObject("BaseGraphScene" inherits "QGraphicsScene": Methods:   #21 type=Signal, signature=connectionAddRequest(QString,QString,QString,QString), parameters=QString, QString, QString, QString )
class nexxT.services.gui.GraphEditor.GraphScene(graph, parent)[source]

Bases: BaseGraphScene

Concrete class interacting with a BaseGraph or FilterGraph instance

__init__(self, sceneRect: PySide6.QtCore.QRectF, /, parent: PySide6.QtCore.QObject | None = None, *, backgroundBrush: PySide6.QtGui.QBrush | None = None, foregroundBrush: PySide6.QtGui.QBrush | None = None, itemIndexMethod: PySide6.QtWidgets.QGraphicsScene.ItemIndexMethod | None = None, bspTreeDepth: int | None = None, palette: PySide6.QtGui.QPalette | None = None, font: PySide6.QtGui.QFont | None = None, stickyFocus: bool | None = None, minimumRenderSize: float | None = None, focusOnTouch: bool | None = None) None[source]
__init__(self, /, parent: PySide6.QtCore.QObject | None = None, *, backgroundBrush: PySide6.QtGui.QBrush | None = None, foregroundBrush: PySide6.QtGui.QBrush | None = None, itemIndexMethod: PySide6.QtWidgets.QGraphicsScene.ItemIndexMethod | None = None, sceneRect: PySide6.QtCore.QRectF | None = None, bspTreeDepth: int | None = None, palette: PySide6.QtGui.QPalette | None = None, font: PySide6.QtGui.QFont | None = None, stickyFocus: bool | None = None, minimumRenderSize: float | None = None, focusOnTouch: bool | None = None) None
__init__(self, x: float, y: float, width: float, height: float, /, parent: PySide6.QtCore.QObject | None = None, *, backgroundBrush: PySide6.QtGui.QBrush | None = None, foregroundBrush: PySide6.QtGui.QBrush | None = None, itemIndexMethod: PySide6.QtWidgets.QGraphicsScene.ItemIndexMethod | None = None, sceneRect: PySide6.QtCore.QRectF | None = None, bspTreeDepth: int | None = None, palette: PySide6.QtGui.QPalette | None = None, font: PySide6.QtGui.QFont | None = None, stickyFocus: bool | None = None, minimumRenderSize: float | None = None, focusOnTouch: bool | None = None) None

Initialize self. See help(type(self)) for accurate signature.

addFilterFromEntryPoint()[source]

Add a filter from its corresponding entry point (the entry point is deduced from the sender action’s data()).

Returns:

addInputPort()[source]

Adds an input port to a node

Returns:

addOutputPort()[source]

Adds an output port to a node

Returns:

compositeFilters()[source]

Get a list of names of composite filters.

Returns:

a list of strings

contextMenuEvent(event)[source]

Overwritten from QGraphicsScene.

getData(item, role)[source]

returns render-relevant information about the specified item can be overriden in concrete editor instances

Parameters:
  • item – an instance of BaseGraphScene.NodeItem, BaseGraphScene.PortItem or BaseGraphScene.ConnectionItem

  • role – one of STYLE_ROLE_SIZE, STYLE_ROLE_PEN, STYLE_ROLE_BRUSH, STYLE_ROLE_RRRADIUS, STYLE_ROLE_VSPACING, STYLE_ROLE_HSPACING

Returns:

the expected item related to the role

onAddComposite()[source]

Called when the user wants to add a new composite filter to this graph.

Returns:

onAddFilterFromFile()[source]

Called when the user wants to add a new filter from a file (FilterGraph variant). Opens a dialog to select the file.

Returns:

onAddFilterFromMod()[source]

Called when the user wants to add a new filter from a python module.

Returns:

onAddNode()[source]

Called when the user wants to add a new node. (Generic variant)

Returns:

onConnSetBlocking()[source]

Sets the conmnection to blocking mode.

Returns:

onConnSetCustom()[source]

Sets the connection to a custom width.

Returns:

onConnSetNonBlocking()[source]

Sets the conmnection to non blocking mode.

Returns:

onConnectionRemove()[source]

Removes a connection

Returns:

onSuggestDynamicPorts()[source]

Called when the user wants to add dynamic ports based on the filter’s suggestions.

Returns:

removeDialog()[source]

Opens a dialog for removing an item (Node or Port)

Returns:

renameDialog()[source]

Opens a dialog for renamign an item (node or port)

Returns:

setThread()[source]

Opens a dialog to enter the new thread of the node.

Returns:

staticMetaObject = PySide6.QtCore.QMetaObject("GraphScene" inherits "BaseGraphScene": )
class nexxT.services.gui.GraphEditor.MyGraphicsPathItem(*args, **kw)[source]

Bases: QGraphicsPathItem, QObject

Little subclass for receiving hover events and scene position changes outside the items

__init__(self, path: PySide6.QtGui.QPainterPath, /, parent: PySide6.QtWidgets.QGraphicsItem | None = None) None[source]
__init__(self, /, parent: PySide6.QtWidgets.QGraphicsItem | None = None) None

Initialize self. See help(type(self)) for accurate signature.

hoverEnter
hoverEnterEvent(event)[source]

emit corresponding singal

Parameters:

event – the qt event

Returns:

hoverLeave
hoverLeaveEvent(event)[source]

emit corresponding signal

Parameters:

event – the qt event

Returns:

itemChange(change, value)[source]

in case of scene position changes, emit the corresponding signal

Parameters:
  • change – what has changed

  • value – the new value

Returns:

scenePosChanged
staticMetaObject = PySide6.QtCore.QMetaObject("MyGraphicsPathItem" inherits "QObject": Methods:   #4 type=Signal, signature=hoverEnter()   #5 type=Signal, signature=hoverLeave()   #6 type=Signal, signature=scenePosChanged(QPointF), parameters=QPointF )
class nexxT.services.gui.GraphEditor.MySimpleTextItem(*args, **kw)[source]

Bases: QGraphicsSimpleTextItem

QGraphicsSimpleTextItem with a background brush

__init__(self, text: str, /, parent: PySide6.QtWidgets.QGraphicsItem | None = None) None[source]
__init__(self, /, parent: PySide6.QtWidgets.QGraphicsItem | None = None) None

Initialize self. See help(type(self)) for accurate signature.

paint(painter, option, widget)[source]

first paint the background and afterwards use standard paint method

Parameters:
  • painter – a QPainter instance

  • option – unused

  • widget – unused

Returns:

setBackgroundBrush(brush)[source]

set the background brush

Parameters:

brush – a QBrush instance

Returns:

class nexxT.services.gui.GraphEditor.PortSelectorDialog(parent, inputPorts, outputPorts, graph, nodeName)[source]

Bases: QDialog

Dialog for selecting the ports which shall be created.

__init__(parent, inputPorts, outputPorts, graph, nodeName)[source]

Constructor

Parameters:
  • parent – this dialog’s parent widget

  • inputPorts – the list of input port names

  • outputPorts – the list of output port names

  • graph – the corresponding BaseGraph instance

  • nodeName – the name of the corresponding node

accept()[source]

Accepts user selection.

static getSelectedPorts(parent, inputPorts, outputPorts, graph, nodeName)[source]

Convenience function for executing the dialog.

Parameters:
  • parent – this dialog’s parent widget

  • inputPorts – the list of input port names

  • outputPorts – the list of output port names

  • graph – the corresponding BaseGraph instance

  • nodeName – the name of the corresponding node

reject()[source]

Rejects user selection.

staticMetaObject = PySide6.QtCore.QMetaObject("PortSelectorDialog" inherits "QDialog": )