Compound proxies in SM

From ParaQ Wiki
Revision as of 09:31, 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);

Currently, compound proxy definitions are not saved with SM state. I will implement this soon.

Here is the documentation of vtkSMCompoundProxy:

// vtkSMCompoundProxy is a proxy that allows grouping of multiple proxies.
// vtkSMProxy has also this capability since a proxy can have sub-proxies.
// However, vtkSMProxy does not allow public access to these proxies. The
// only access is through exposed properties. The main reason behind this
// is consistency. There are proxies that will not work if the program
// accesses the sub-proxies directly. The main purpose of
// vtkSMCompoundProxy is to provide an interface to access the
// sub-proxies. It contains a main proxy and all the proxies that are added
// to the compound proxy are actually added to this proxy. This way, the
// main proxy can be any proxy type (for example a vtkSMSourceProxy). The
// compound proxy is used to access sub-proxies whereas the main proxy is
// used to access properties that are exposed by the group.

I am working on an interface to expose properties that should be shown for the compound proxy. Currently, accessing a property requires getting a sub-proxy from the compound proxy and accessing the property directly.