Hi everyone,
I'm writing a python panel that should have a behaviour similar to a SceneGraph Tree view - it should display the most relevant state of the stage for the currently selected node.
Pypanel's OnNodePathChanged() method does it job when I select different nodes, but I also need to catch stage updates when I modify parameters on the single node. ParmTupleChanged() callback doesn't work in this case because looks like it is called right after I've changed the parameter but before stage is cooked. As a result I'm alwaus getting the state of the stage as is it was before I've made a change. It is funny how it is lagging one step behind - when I edit parameters - on every parameter change my panel updates to the previous state of the stage. The same thing is also with InputDataChanged callback as well. It looks like any node event is happening before stage state is recalculated.
Is there any other callback I could hook to that will allow me to trigger panel update if something has changed in the state of the stage for the currently selected node? I mean after stage's been re-cooked?
Thanks in advance.
How to catch stage update in a python_panel in Solaris?
234 2 0- alexandr.sknarin
- Member
- 4 posts
- Joined: May 2023
- Offline
- mtucker
- Staff
- 4444 posts
- Joined: July 2005
- Offline
My best advice would be to look at how the scene graph details pane is doing it... To describe it at a high level:
1. OnNodePathChanged triggers an update and sets up a bunch of node event callbacks.
2. Triggering of those callbacks checks if there are any unhandled updates outstanding. If so, do nothing and return. If not, set a flag indicating that there are outstanding unhandled updates, and use hdefereval to cause an "update" function to be called when control returns to the UI event queue.
3. The deferred update function updates the panel, and turns off the flag indicating that there are outstanding unhandled updates.
The use of hdefereval is critical for two reasons:
1. It prevents massive over-updating of the panel UI
2. It allows us to follow the rule (that I have been trying to publicize a lot recently): Do Not Cook Nodes in Node Event Callbacks!
My best guess for why your panel is "one cook behind" is because you are violating the rule in (2)?
1. OnNodePathChanged triggers an update and sets up a bunch of node event callbacks.
2. Triggering of those callbacks checks if there are any unhandled updates outstanding. If so, do nothing and return. If not, set a flag indicating that there are outstanding unhandled updates, and use hdefereval to cause an "update" function to be called when control returns to the UI event queue.
3. The deferred update function updates the panel, and turns off the flag indicating that there are outstanding unhandled updates.
The use of hdefereval is critical for two reasons:
1. It prevents massive over-updating of the panel UI
2. It allows us to follow the rule (that I have been trying to publicize a lot recently): Do Not Cook Nodes in Node Event Callbacks!
My best guess for why your panel is "one cook behind" is because you are violating the rule in (2)?
- alexandr.sknarin
- Member
- 4 posts
- Joined: May 2023
- Offline
-
- Quick Links