Node Editor Tutorial 09: Positioning Edges and Debugging

preview_player
Показать описание

In this Node Editor tutorial we will start placing edges into the correct sockets. Our codebase is slowly growing so we will start to talk about debugging and set up our first debugging system.
Рекомендации по теме
Комментарии
Автор

Thank you for the great tutorials! How do you get code completion suggestions from classes that are not present or imported in the current Python file? Like the Scene class here, for example 6:47 . I can't get my Pycharm to do that. It doesn't know that the scene argument requires an object of Scene type. I have to explicitly import the scene class on top to get the suggestions you are getting. If you have any idea why this is happening, I will appreciate it. Thank you in advance!

ivayloyanev
Автор

When zooming in and moving a Node, the destination edge position become incorrect.

dirkschiller
Автор

Why are some methods are camel case like `Edge.updatePositions()` and some snake case like `Edge.remove_from_socket()` ?

dirkschiller
Автор

logging would be useful for debugging purposes

MrIanFu
Автор

I really dislike the high coupling that is introduced in this series. When following the series I make several tweaks to avoid these.
Some example couplings are:
Edge both uses Scene and GraphicsScene -- let Scene handle the graphics object when adding/removing an edge
Socket does not need to know about the node, only its graphics object does -- getSocketPosition can simply do:
return self.grSocket.scenePos()
The Socket also does not need to know its index or position type. Just pass an x and y value to it, and it can position the graphics item once and then not care anymore.

I do also disapprove of your debugging method. Using prints is generally the "poor-man" alternative of debugging. If you use the debugging tool itself you can step each line of code and also inject own variables or call functions manually.
If you really want to print the logs, use logging.Logger instead of print, that'll at least give the possibility to change the logging level with a single line of code.

Other than these two issues (which can be adjusted at the same time as following the series) I find this series very helpful when making a node editor system.

SimonK