jchanvfx / NodeGraphQt

Node graph framework that can be re-implemented into applications that supports PySide2
http://chantonic.com/NodeGraphQt/
MIT License
1.29k stars 264 forks source link

NodeGraph.center_on and NodeViewer.center_selection issues. #279

Closed Gaspounet closed 1 year ago

Gaspounet commented 2 years ago

Hello!

I just started using your NodeGraphQt (and so far, it's really cool and I think I'll try to build a project from it!) Just found a few bugs with the NodeGraph.center_on and NodeViewer.center_selection method:

NodeGraph.center_on fails when nodes=None, as it's trying to iterate through None Traceback (most recent call last): File "C:\Users\gaspa\PycharmProjects\nopipe\main.py", line 33, in <module> graph.center_on() File "C:\Users\gaspa\PycharmProjects\nopipe\venv\lib\site-packages\NodeGraphQt\base\graph.py", line 1020, in center_on self._viewer.center_selection([n.view for n in nodes]) TypeError: 'NoneType' object is not iterable

NodeViewer.center_selection fails when passing a single node as it's passing a node as argument to QGraphicsView.centerOn while it's expecting a point or 2 floats: Traceback (most recent call last): File "C:\Users\gaspa\PycharmProjects\nopipe\main.py", line 33, in <module> viewer.center_selection([node_a]) File "C:\Users\gaspa\PycharmProjects\nopipe\venv\lib\site-packages\NodeGraphQt\widgets\viewer.py", line 1193, in center_selection self.centerOn(nodes[0]) TypeError: 'PySide2.QtWidgets.QGraphicsView.centerOn' called with wrong argument types: PySide2.QtWidgets.QGraphicsView.centerOn(MyNode) Supported signatures: PySide2.QtWidgets.QGraphicsView.centerOn(PySide2.QtWidgets.QGraphicsItem) PySide2.QtWidgets.QGraphicsView.centerOn(PySide2.QtCore.QPointF) PySide2.QtWidgets.QGraphicsView.centerOn(float, float)

Even with all this, once trying viewer.centerOn(node_a.x_pos(), node_a.y_pos()) , it isn't doing anything

Cheers Gasp

jchanvfx commented 1 year ago

Hi @Gaspounet,

I've just made a new release v0.5.6 with the fix to the NodeGraph.center_on function.

Cheers, Johnny