node_graphics_view Module¶
A module containing Graphics View for NodeEditor
Constants¶
-
nodeeditor.node_graphics_view.MODE_NOOP= 1¶ Mode representing ready state
-
nodeeditor.node_graphics_view.MODE_EDGE_DRAG= 2¶ Mode representing when we drag edge state
-
nodeeditor.node_graphics_view.MODE_EDGE_CUT= 3¶ Mode representing when we draw a cutting edge
-
nodeeditor.node_graphics_view.MODE_EDGES_REROUTING= 4¶ Mode representing when we re-route existing edges
-
nodeeditor.node_graphics_view.EDGE_DRAG_START_THRESHOLD= 50¶ Distance when click on socket to enable Drag Edge
QDMGraphicsView class¶
-
class
nodeeditor.node_graphics_view.QDMGraphicsView(grScene: QDMGraphicsScene, parent: QWidget = None)¶ Bases:
PyQt5.QtWidgets.QGraphicsViewClass representing NodeEditor’s Graphics View
- Parameters
grScene (
QDMGraphicsScene) – reference to theQDMGraphicsSceneparent (
QWidget) – parent widget
- Instance Attributes
grScene - reference to the
QDMGraphicsScenemode - state of the Graphics View
zoomInFactor-
float- zoom step scaling, default 1.25zoomClamp -
bool- do we clamp zooming or is it infinite?zoom - current zoom step
zoomStep -
int- the relative zoom step when zooming in/outzoomRange -
[min, max]
-
scenePosChanged¶ pyqtSignal emitted when cursor position on the Scene has changed
-
initUI()¶ Set up this
QGraphicsView
-
isSnappingEnabled(event: Optional[PyQt5.QtGui.QInputEvent] = None) → bool¶ Returns
Trueif snapping is currently enabled
-
resetMode()¶ Helper function to re-set the grView’s State Machine state to the default
-
dragEnterEvent(event: PyQt5.QtGui.QDragEnterEvent)¶ Trigger our registered Drag Enter events
-
dropEvent(event: PyQt5.QtGui.QDropEvent)¶ Trigger our registered Drop events
-
addDragEnterListener(callback: function)¶ Register callback for Drag Enter event
- Parameters
callback – callback function
-
addDropListener(callback: function)¶ Register callback for Drop event
- Parameters
callback – callback function
-
mousePressEvent(event: PyQt5.QtGui.QMouseEvent)¶ Dispatch Qt’s mousePress event to corresponding function below
-
mouseReleaseEvent(event: PyQt5.QtGui.QMouseEvent)¶ Dispatch Qt’s mouseRelease event to corresponding function below
-
middleMouseButtonPress(event: PyQt5.QtGui.QMouseEvent)¶ When Middle mouse button was pressed
-
middleMouseButtonRelease(event: PyQt5.QtGui.QMouseEvent)¶ When Middle mouse button was released
-
leftMouseButtonPress(event: PyQt5.QtGui.QMouseEvent)¶ When Left mouse button was pressed
-
leftMouseButtonRelease(event: PyQt5.QtGui.QMouseEvent)¶ When Left mouse button was released
-
rightMouseButtonPress(event: PyQt5.QtGui.QMouseEvent)¶ When Right mouse button was pressed
-
rightMouseButtonRelease(event: PyQt5.QtGui.QMouseEvent)¶ When Right mouse button was release
-
mouseMoveEvent(event: PyQt5.QtGui.QMouseEvent)¶ Overriden Qt’s
mouseMoveEventhandling Scene/View logic
-
keyPressEvent(event: PyQt5.QtGui.QKeyEvent)¶ Note
This overridden Qt’s method was used for handling key shortcuts, before we implemented proper
QWindowwith Actions and Menu. Still the commented code serves as an example on how to handle key presses without Qt’s framework for Actions and shortcuts. There is also an example on how to solve the problem when a Node contains Text/LineEdit and we press the Delete key (also serving to delete Node)- Parameters
event (
QKeyEvent) – Qt’s Key event- Returns
-
cutIntersectingEdges()¶ Compare which Edges intersect with current Cut line and delete them safely
-
setSocketHighlights(scenepos: PyQt5.QtCore.QPointF, highlighted: bool = True, radius: float = 50)¶ Set/disable socket highlights in Scene area defined by scenepos and radius
-
deleteSelected()¶ Shortcut for safe deleting every object selected in the Scene.
-
debug_modifiers(event)¶ Helper function get string if we hold Ctrl, Shift or Alt modifier keys
-
getItemAtClick(event: PyQt5.QtCore.QEvent) → QGraphicsItem¶ Return the object on which we’ve clicked/release mouse button
- Parameters
event (
QEvent) – Qt’s mouse or key event- Returns
QGraphicsItemwhich the mouse event happened orNone
-
distanceBetweenClickAndReleaseIsOff(event: PyQt5.QtGui.QMouseEvent) → bool¶ Measures if we are too far from the last Mouse button click scene position. This is used for detection if we release too far after we clicked on a Socket
- Parameters
event (
QMouseEvent) – Qt’s mouse event- Returns
Trueif we released too far from where we clicked before
-
wheelEvent(event: PyQt5.QtGui.QWheelEvent)¶ overridden Qt’s
wheelEvent. This handles zooming