How to catch stage update in a python_panel in Solaris?

   208   2   0
User Avatar
Member
4 posts
Joined: May 2023
Online
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.
Edited by alexandr.sknarin - April 17, 2024 17:59:57
Alex Sknarin
Lighting Technical Supervisor
DNEG
User Avatar
Staff
4439 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)?
User Avatar
Member
4 posts
Joined: May 2023
Online
Thanks so much! scene graph details looks like perfect example.
Alex Sknarin
Lighting Technical Supervisor
DNEG
  • Quick Links