def track_existing_helper_proxy(helper_proxy, parent_proxy_info): """Start tracking a helper proxy e.g. the implicit function for a Clip filter. This will create a new proxy_trace_info object for the implicit function so that any properties modified on it can be recorded.""" if not helper_proxy or not parent_proxy_info: raise Exception('Missing (or invalid) required arguments') # We need to create a proxy_trace_info object for the helper_proxy. # For that, we need to determine which property this helper proxy was # set to. itr = servermanager.PropertyIterator(parent_proxy_info.Proxy) for prop in itr: if prop.IsA("vtkSMProxyProperty") and prop.GetDomain("proxy_list") \ and prop.IsProxyAdded(helper_proxy): propInfo = prop_trace_info(parent_proxy_info, prop) helper_proxy_info = proxy_trace_info(helper_proxy, "helpers", "NotUsed") helper_proxy_info.ctor_traced = True trace_globals.known_proxies.append(helper_proxy_info) helper_proxy_info.PyVariable = propInfo.PyVariable helper_proxy_info.ParentProxyInfo = parent_proxy_info return helper_proxy_info return None
def get_property_value_from_list_domain(proxyInfo, propInfo): """Given a proxy and one of its proxyproperties (or inputproperty), get the value of the property as a string IF the property has a proxy list domain, else return None. For more information see the class method servermanager.ProxyProperty.GetAvailable. As a side effect of calling this method, the current property value (which is another proxy) may be tracked by adding it to trace_globals.registered_proxies.""" proxy = proxyInfo.Proxy prop = propInfo.Prop pythonProp = servermanager._wrap_property(proxy, prop) if len(pythonProp.Available) and prop.GetNumberOfProxies() == 1: proxyPropertyValue = prop.GetProxy(0) listdomain = prop.GetDomain('proxy_list') if listdomain: for i in xrange(listdomain.GetNumberOfProxies()): if listdomain.GetProxy(i) == proxyPropertyValue: info = get_proxy_info(proxyPropertyValue) if not info: info = proxy_trace_info(proxyPropertyValue, "helpers", pythonProp.Available[i]) info.PyVariable = propInfo.PyVariable info.ParentProxyInfo = proxyInfo info.ctor_traced = True trace_globals.registered_proxies.append(info) # If capture_all_properties, record all the properties of this proxy if trace_globals.capture_all_properties: itr = servermanager.PropertyIterator(proxyPropertyValue) for prop in itr: if prop.GetInformationOnly() or prop.GetIsInternal(): continue trace_property_modified(info, prop) return "\"%s\"" % pythonProp.Available[i] return None
def trace_proxy_registered(proxy, proxyGroup, proxyName): """Creates a new proxy_trace_info object if the proxy type is one that is followed for trace (not all proxy types are). Returns the new object or None.""" if trace_globals.verbose: print "Proxy '%s' registered in group '%s'" % (proxyName, proxyGroup) if not proxyGroup in trace_globals.traced_proxy_groups: return None info = proxy_trace_info(proxy, proxyGroup, proxyName) trace_globals.last_registered_proxies.append(info) if trace_globals.capture_all_properties or proxyGroup == "selection_sources": itr = servermanager.PropertyIterator(proxy) for prop in itr: if prop.GetInformationOnly() or prop.GetIsInternal(): continue trace_property_modified(info, prop) return info
def trace_proxy_properties(proxy_info): """Function used to trace all properties on a the proxy. This is useful to record properties on a newly registered proxy.""" proxy = proxy_info.Proxy proxyGroup = proxy_info.Group if trace_globals.capture_all_properties or proxyGroup == "selection_sources": itr = servermanager.PropertyIterator(proxy) for prop in itr: if prop.GetInformationOnly() or prop.GetIsInternal(): continue # skip saving properties which still have their default value # if capture_modified_properties is true if trace_globals.capture_modified_properties and prop.IsValueDefault( ): continue trace_property_modified(proxy_info, prop)
def get_all_inputs_registered(proxy): """Given a servermanager.Proxy, check if the proxy's Inputs have been registered with smtrace. Returns True if all inputs are registered or proxy does not have an Input property, else returns False.""" itr = servermanager.PropertyIterator(proxy.SMProxy) for prop in itr: if prop.IsA("vtkSMInputProperty"): # Don't worry about input properties with ProxyListDomains, # these input proxies do not need to be constructed by python. if prop.GetDomain("proxy_list") is not None: continue # Some representations have an InternalInput property which does # not need to be managed by python, so ignore these if proxy.GetPropertyName(prop).startswith("InternalInput"): continue for i in xrange(prop.GetNumberOfProxies()): input_proxy = prop.GetProxy(i) info = smtrace.get_proxy_info(input_proxy, search_existing=False) if not info: return False return True