Loading state from XML

From ParaQ Wiki
Jump to navigationJump to search

Tomorrow, I will commit my first pass at loading state from XML. Currently, the state loader recognizes:

  • All proxy types
  • All property types

It does not recognize:

  • Domains

Loading the state of domains from XML is not commonly used so it should not impact anything ParaQ currently does. Here is a simple pythong script that I used to test the loader:

 parser = vtkPVXMLParser()
 parser.SetFileName("/home/berk/exodus.pvsm")
 parser.Parse()

 loader = vtkSMStateLoader()
 loader.LoadState(parser.GetRootElement())

 pm = vtkSMObject.GetProxyManager()

 print "Updating sources"
 pm.UpdateRegisteredProxies("sources", 0)
 pm.UpdateRegisteredProxies("filters", 0)

 print "Updating displays"
 pm.UpdateRegisteredProxies("displays", 0)

 print "Updating rest"
 pm.UpdateRegisteredProxies(0)

 pm.GetProxy("rendermodules", "RenderModule0").StillRender()

exodus.pvsm was create by dumping SM state from paraview. Currently, state dumped from ParaQ will not work. For state to work, all proxies have to be registered with the proxy manager after they are created. Here is what I recommend:

  • Once a proxy is created, register it with the proxy manager and release it's reference count. This way, proxy manager is managing the object. Whatevery GUI object has to reference the proxy can either keep the group/registered names or a pointer without a reference. If it is absolutely necessary to keep a reference to a proxy, make sure that it is release when the GUI object goes away.
  • When a proxy has to be deleted, unregister it from the proxy manager. Proxy manager will then invoke an event all interested parties should listen to. These GUI objects should then clear their proxy pointer or names.

The current code assumes to a certain extent that:

  • All sources/readers/filters are registered with the "sources" group
  • All displays are registered with the "displays" group

Once ParaQ follows these guidelines, it should be able to save/load SM state.