Compound proxies in SM

From ParaQ Wiki
Revision as of 09:28, 6 January 2006 by Berk (talk | contribs)
Jump to navigationJump to search

Compound proxies support grouping of multiple proxies, saving their state and instantiating them. A compound proxy is created as follows:

compound = vtkSMCompoundProxy()
compound.AddProxy("first", shrink)
compound.AddProxy("second", clip)
compound.AddProxy("this", exodus)

Once a compound proxy is created, the proxies it contains can be obtained through the following methods:

  // Description:
  // Returns a sub-proxy. Returns 0 if sub-proxy does not exist.
  vtkSMProxy* GetProxy(const char* name);

  // Description:
  // Returns a sub-proxy. Returns 0 if sub-proxy does not exist.
  vtkSMProxy* GetProxy(unsigned int index);

  // Description:
  // Returns the name used to store sub-proxy. Returns 0 if sub-proxy does
  // not exist.
  const char* GetProxyName(unsigned int index);

  // Description:
  // Returns the number of sub-proxies.
  unsigned int GetNumberOfProxies();

A compound proxy is capable of saving it's description into a vtkPVXMLElement tree:

definition = compound.SaveDefinition(None)

The compound proxy definition has the same structure as SM state. All references to proxies that are not contained in the compound proxy are removed. Therefore, the compound proxy is self-contained. Compound proxy definition can be registered with the proxy manager:

pm.RegisterCompoundProxyDefinition("macro", compound.SaveDefinition(None))

Once a compound proxy definition is registered with the proxy manager, a new compound proxy can be instantiated with:

newCompound = pm.NewCompoundProxy("macro")

The compound proxy definition can also be saved to a stream with:

  // Description:
  // Serialize (as XML) in the given stream.
  void vtkPVXMLElement::PrintXML(ostream& os, vtkIndent indent);