Example #1
0
  def __init__(self, proxyTraceInfo, prop):

    self.Prop = prop
    # Determine python variable name
    self.PyVariable = prop.GetXMLLabel()
    # For non-self properties, use the xml name instead of xml label:
    if prop.GetParent() != proxyTraceInfo.Proxy:
      self.PyVariable = proxyTraceInfo.Proxy.GetPropertyName(prop)
    self.PyVariable = servermanager._make_name_valid(self.PyVariable)
Example #2
0
    def __init__(self, proxyTraceInfo, prop):

        self.Prop = prop
        # Determine python variable name
        self.PyVariable = prop.GetXMLLabel()
        # For non-self properties, use the xml name instead of xml label:
        if prop.GetParent() != proxyTraceInfo.Proxy:
            self.PyVariable = proxyTraceInfo.Proxy.GetPropertyName(prop)
        self.PyVariable = servermanager._make_name_valid(self.PyVariable)
Example #3
0
def append_trace():

  # Get the list of last registered proxies in sorted order
  modified_proxies = sort_proxy_info_by_group(trace_globals.last_registered_proxies)

  # Now append the existing proxies to the list
  for p in trace_globals.registered_proxies: modified_proxies.append(p)

  for info in modified_proxies:
    traceOutput = ""
    deferredProperties = []

    # Generate list of tuples : (propName, propValue)
    propNameValues = list_of_tuples()
    for propName, propValue in info.ModifiedProps.iteritems():
      if propIsIgnored(info, propName): continue

      # Note, the 'Input' property is ignored for representations, so we are
      # only dealing with filter proxies here.  If the 'Input' property is a
      # single value (not a multi-input filter), then ensure the input is
      # the active source and leave the 'Input' property out of the
      # propNameValues list.
      if propName == "Input" and propValue.find("[") == -1:
        inputProxyInfo = get_proxy_info(propValue)
        ensure_active_source(inputProxyInfo)
        continue

      if property_references_untraced_proxy(propName, propValue, info.Props.values()):
        deferredProperties.append((propName, propValue))
      else:
        propNameValues.append((propName, propValue))

    # Clear the modified prop list
    info.ModifiedProps.clear()

    # If info is in the last_registered_proxies list, then we need to add the
    # proxy's constructor call to the trace
    if info in trace_globals.last_registered_proxies and not info.ctor_traced:

      # Determine the function call to construct the proxy
      setPropertiesInCtor = True
      ctorArgs = []
      extraCtorCommands = ""
      ctorMethod = servermanager._make_name_valid(info.Proxy.GetXMLLabel())
      if info.Group == "sources":
        # track it as the last active source now
        trace_globals.last_active_source = info.Proxy
        # maybe append the guiName property
        if trace_globals.use_gui_name:
          ctorArgs.append("guiName=\"%s\"" % info.ProxyName)

      if info.Group == "representations":
        ctorMethod = "Show"
        setPropertiesInCtor = False
        # Ensure the input proxy is the active source:
        input_proxy_info = get_input_proxy_info_for_rep(info)
        if input_proxy_info:
          ensure_active_source(input_proxy_info)
        # Ensure the view is the active view:
        view_proxy_info = get_view_proxy_info_for_rep(info)
        if view_proxy_info:
          ensure_active_view(view_proxy_info)

      if info.Group == "scalar_bars":
        ctorMethod = "CreateScalarBar"
        extraCtorCommands = "GetRenderView().Representations.append(%s)\n" % info.PyVariable
        # Ensure the view is the active view:
        view_proxy_info = get_view_proxy_info_for_rep(info)
        if view_proxy_info:
          ensure_active_view(view_proxy_info)

      if info.Group == "views":
        if info.Proxy.GetXMLLabel() == "XYChartView":
          ctorMethod = "CreateXYPlotView"
        elif info.Proxy.GetXMLLabel() == "XYBarChartView":
          ctorMethod = "CreateBarChartView"
        elif info.Proxy.GetXMLName() == "ComparativeRenderView":
          ctorMethod = "CreateComparativeRenderView"
        elif info.Proxy.GetXMLName() == "ComparativeXYPlotView":
          ctorMethod = "CreateComparativeXYPlotView"
        elif info.Proxy.GetXMLName() == "ComparativeBarChartView":
          ctorMethod = "CreateComparativeBarChartView"
        elif info.Proxy.GetXMLName() == "ParallelCoordinatesChartView":
          ctorMethod = "CreateParallelCoordinatesChartView"
        elif info.Proxy.GetXMLName() == "2DRenderView":
          ctorMethod = "Create2DRenderView"
        else:
          ctorMethod = "CreateRenderView"

        # Now track it as the last active view
        trace_globals.last_active_view = info.Proxy
        setPropertiesInCtor = False
      if info.Group == "lookup_tables":
        match = re.match("(\d)\.([^.]+)\.PVLookupTable", info.ProxyName)
        if match:
          ctorMethod = "GetLookupTableForArray"
          ctorArgs.append("\"%s\"" % match.group(2))
          ctorArgs.append(match.group(1))
        else:
          # This is not a standard LUT created by the GUI--how in the world?
          # We'll just handle it as if it's a stray LUT.
          ctorMethod = "CreateLookupTable"

      if info.Group == "piecewise_functions":
        ctorMethod = "CreatePiecewiseFunction"

      if info.Group == "animation":
        if info.Proxy.GetXMLName() == "KeyFrameAnimationCue":
          ctorMethod = "GetAnimationTrack"
          propname = None
          index = None
          if propNameValues.has_key("AnimatedPropertyName"):
            propname = propNameValues.get_value("AnimatedPropertyName")
            propNameValues = propNameValues.purge("AnimatedPropertyName")
          if propNameValues.has_key("AnimatedElement"):
            index = propNameValues.get_value("AnimatedElement")
            propNameValues = propNameValues.purge("AnimatedElement")
          propNameValues = propNameValues.purge("AnimatedProxy")
          animated_proxy_info = get_animated_proxy_info(info)
          ctorArgs.append(propname)
          if index != None:
            ctorArgs.append(index)
          if animated_proxy_info:
            if not animated_proxy_info.ParentProxyInfo:
              ensure_active_source(animated_proxy_info)
            else:
              ctorArgs.append("proxy=%s.%s" % (animated_proxy_info.ParentProxyInfo.PyVariable,
                                               animated_proxy_info.PyVariable))
          setPropertiesInCtor = False
        elif info.Proxy.GetXMLName() == "CameraAnimationCue":
          view_proxy_info = get_animated_proxy_info(info)
          if view_proxy_info:
            ensure_active_view(view_proxy_info)
          ctorMethod = "GetCameraTrack"
          propNameValues = propNameValues.purge("AnimatedProxy")
          propNameValues = propNameValues.purge("AnimatedPropertyName")
          setPropertiesInCtor = False
        elif info.Proxy.GetXMLName() == "TimeAnimationCue":
          ctorMethod = "GetTimeTrack"
          propNameValues = propNameValues.purge("AnimatedProxy")
          propNameValues = propNameValues.purge("AnimatedPropertyName")
          setPropertiesInCtor = False

      if setPropertiesInCtor:
        for propName, propValue in propNameValues:
          if not "." in propName:
              ctorArgs.append("%s=%s" % (propName, propValue))
          else:
              # This line handles properties like:  my_slice.SliceType.Normal = [1, 0, 0]
              extraCtorCommands += "%s.%s = %s\n" % (info.PyVariable, propName, propValue)
        propNameValues = list_of_tuples()

      if trace_globals.proxy_ctor_hook:
        ctorMethod, ctorArgs, extraCtorCommands = trace_globals.proxy_ctor_hook(info,
          ctorMethod, ctorArgs, extraCtorCommands)

      ctorArgString = make_comma_separated_string(ctorArgs)
      traceOutput = "%s = %s(%s)\n%s" % (info.PyVariable, ctorMethod, ctorArgString, extraCtorCommands)
      info.ctor_traced = True

    # Set properties on the proxy
    for propName, propValue in propNameValues:
      traceOutput += "%s.%s = %s\n" % (info.PyVariable, propName, propValue)

    if traceOutput:
      trace_globals.trace_output.append(traceOutput)

    if deferredProperties:
      modified_proxies.append(info)
      for pair in deferredProperties:
        info.ModifiedProps[pair[0]] = pair[1]

  trace_globals.registered_proxies += trace_globals.last_registered_proxies
  del trace_globals.last_registered_proxies[:]
Example #4
0
def pyvariable_from_proxy_name(proxy_name):
  return servermanager._make_name_valid(proxy_name.replace(".", "_"))
Example #5
0
def append_trace():

    # Get the list of last registered proxies in sorted order
    modified_proxies = sort_proxy_info_by_group(
        trace_globals.last_registered_proxies)

    # Now append the existing proxies to the list
    for p in trace_globals.registered_proxies:
        modified_proxies.append(p)

    for info in modified_proxies:
        traceOutput = ""
        deferredProperties = []

        # Generate list of tuples : (propName, propValue)
        propNameValues = list_of_tuples()
        for propName, propValue in info.ModifiedProps.iteritems():
            if propIsIgnored(info, propName): continue

            # Note, the 'Input' property is ignored for representations, so we are
            # only dealing with filter proxies here.  If the 'Input' property is a
            # single value (not a multi-input filter), then ensure the input is
            # the active source and leave the 'Input' property out of the
            # propNameValues list.
            if propName == "Input" and propValue.find("[") == -1:
                inputProxyInfo = get_proxy_info(propValue)
                ensure_active_source(inputProxyInfo)
                continue

            if property_references_untraced_proxy(propName, propValue,
                                                  info.Props.values()):
                deferredProperties.append((propName, propValue))
            else:
                propNameValues.append((propName, propValue))

        # Clear the modified prop list
        info.ModifiedProps.clear()

        # If info is in the last_registered_proxies list, then we need to add the
        # proxy's constructor call to the trace
        if info in trace_globals.last_registered_proxies and not info.ctor_traced:

            # Determine the function call to construct the proxy
            setPropertiesInCtor = True
            ctorArgs = []
            extraCtorCommands = ""
            ctorMethod = servermanager._make_name_valid(
                info.Proxy.GetXMLLabel())
            if info.Group == "sources":
                # track it as the last active source now
                trace_globals.last_active_source = info.Proxy
                # maybe append the guiName property
                if trace_globals.use_gui_name:
                    ctorArgs.append("guiName=\"%s\"" % info.ProxyName)

            if info.Group == "representations":
                ctorMethod = "Show"
                setPropertiesInCtor = False
                # Ensure the input proxy is the active source:
                input_proxy_info = get_input_proxy_info_for_rep(info)
                if input_proxy_info:
                    ensure_active_source(input_proxy_info)
                # Ensure the view is the active view:
                view_proxy_info = get_view_proxy_info_for_rep(info)
                if view_proxy_info:
                    ensure_active_view(view_proxy_info)

            if info.Group == "scalar_bars":
                ctorMethod = "CreateScalarBar"
                extraCtorCommands = "GetRenderView().Representations.append(%s)\n" % info.PyVariable
                # Ensure the view is the active view:
                view_proxy_info = get_view_proxy_info_for_rep(info)
                if view_proxy_info:
                    ensure_active_view(view_proxy_info)

            if info.Group == "views":
                if info.Proxy.GetXMLLabel() == "XYChartView":
                    ctorMethod = "CreateXYPlotView"
                elif info.Proxy.GetXMLLabel() == "XYBarChartView":
                    ctorMethod = "CreateBarChartView"
                elif info.Proxy.GetXMLName() == "ComparativeRenderView":
                    ctorMethod = "CreateComparativeRenderView"
                elif info.Proxy.GetXMLName() == "ComparativeXYPlotView":
                    ctorMethod = "CreateComparativeXYPlotView"
                elif info.Proxy.GetXMLName() == "ComparativeBarChartView":
                    ctorMethod = "CreateComparativeBarChartView"
                elif info.Proxy.GetXMLName() == "ParallelCoordinatesChartView":
                    ctorMethod = "CreateParallelCoordinatesChartView"
                elif info.Proxy.GetXMLName() == "2DRenderView":
                    ctorMethod = "Create2DRenderView"
                else:
                    ctorMethod = "CreateRenderView"

                # Now track it as the last active view
                trace_globals.last_active_view = info.Proxy
                setPropertiesInCtor = False
            if info.Group == "lookup_tables":
                match = re.match("(\d)\.([^.]+)\.PVLookupTable",
                                 info.ProxyName)
                if match:
                    ctorMethod = "GetLookupTableForArray"
                    ctorArgs.append("\"%s\"" % match.group(2))
                    ctorArgs.append(match.group(1))
                else:
                    # This is not a standard LUT created by the GUI--how in the world?
                    # We'll just handle it as if it's a stray LUT.
                    ctorMethod = "CreateLookupTable"

            if info.Group == "piecewise_functions":
                ctorMethod = "CreatePiecewiseFunction"

            if info.Group == "animation":
                if info.Proxy.GetXMLName() == "KeyFrameAnimationCue":
                    ctorMethod = "GetAnimationTrack"
                    propname = None
                    index = None
                    if propNameValues.has_key("AnimatedPropertyName"):
                        propname = propNameValues.get_value(
                            "AnimatedPropertyName")
                        propNameValues = propNameValues.purge(
                            "AnimatedPropertyName")
                    if propNameValues.has_key("AnimatedElement"):
                        index = propNameValues.get_value("AnimatedElement")
                        propNameValues = propNameValues.purge(
                            "AnimatedElement")
                    propNameValues = propNameValues.purge("AnimatedProxy")
                    animated_proxy_info = get_animated_proxy_info(info)
                    ctorArgs.append(propname)
                    if index != None:
                        ctorArgs.append(index)
                    if animated_proxy_info:
                        if not animated_proxy_info.ParentProxyInfo:
                            ensure_active_source(animated_proxy_info)
                        else:
                            ctorArgs.append("proxy=%s.%s" % (
                                animated_proxy_info.ParentProxyInfo.PyVariable,
                                animated_proxy_info.PyVariable))
                    setPropertiesInCtor = False
                elif info.Proxy.GetXMLName() == "CameraAnimationCue":
                    view_proxy_info = get_animated_proxy_info(info)
                    if view_proxy_info:
                        ensure_active_view(view_proxy_info)
                    ctorMethod = "GetCameraTrack"
                    propNameValues = propNameValues.purge("AnimatedProxy")
                    propNameValues = propNameValues.purge(
                        "AnimatedPropertyName")
                    setPropertiesInCtor = False
                elif info.Proxy.GetXMLName() == "TimeAnimationCue":
                    ctorMethod = "GetTimeTrack"
                    propNameValues = propNameValues.purge("AnimatedProxy")
                    propNameValues = propNameValues.purge(
                        "AnimatedPropertyName")
                    setPropertiesInCtor = False

            if setPropertiesInCtor:
                for propName, propValue in propNameValues:
                    if not "." in propName:
                        ctorArgs.append("%s=%s" % (propName, propValue))
                    else:
                        # This line handles properties like:  my_slice.SliceType.Normal = [1, 0, 0]
                        extraCtorCommands += "%s.%s = %s\n" % (
                            info.PyVariable, propName, propValue)
                propNameValues = list_of_tuples()

            if trace_globals.proxy_ctor_hook:
                ctorMethod, ctorArgs, extraCtorCommands = trace_globals.proxy_ctor_hook(
                    info, ctorMethod, ctorArgs, extraCtorCommands)

            ctorArgString = make_comma_separated_string(ctorArgs)
            traceOutput = "%s = %s(%s)\n%s" % (
                info.PyVariable, ctorMethod, ctorArgString, extraCtorCommands)
            info.ctor_traced = True

        # Set properties on the proxy
        for propName, propValue in propNameValues:
            traceOutput += "%s.%s = %s\n" % (info.PyVariable, propName,
                                             propValue)

        if traceOutput:
            trace_globals.trace_output.append(traceOutput)

        if deferredProperties:
            modified_proxies.append(info)
            for pair in deferredProperties:
                info.ModifiedProps[pair[0]] = pair[1]

    trace_globals.registered_proxies += trace_globals.last_registered_proxies
    del trace_globals.last_registered_proxies[:]
Example #6
0
def pyvariable_from_proxy_name(proxy_name):
    return servermanager._make_name_valid(proxy_name.replace(".", "_"))
Example #7
0
def determine_ctor(info, propNameValues):
  """Determines the contructor to use for the proxy_info in trace.
  propNameValues is an instance of list_of_tuples with (propname, propvalue) pairs.
  Returns a tuple:
    (method_name, list-of-ctor-args, set-properties-in-ctor-flag, extracmds_list)
  """
  if not isinstance(info, proxy_trace_info):
    raise TypeError("Invalid argument. Was expecting an instance of proxy_trace_info")
  if not isinstance(propNameValues, list_of_tuples):
    raise TypeError("Invalid argument. Was expected an instance of list_of_tuples")

  extraCtorCommands = []
  ctorMethod = info.ctor_method.name
  ctorArgs = info.ctor_method.args[:]
  setPropertiesInCtor = info.ctor_method.setPropertiesInCtor
  if ctorMethod:
    return (ctorMethod, ctorArgs, setPropertiesInCtor, extraCtorCommands)

  ctorMethod = servermanager._make_name_valid(info.Proxy.GetXMLLabel())
  if info.Group == "sources":
    # track it as the last active source now
    trace_globals.last_active_source = info.Proxy
    # maybe append the guiName property
    if trace_globals.use_gui_name:
      ctorArgs.append("guiName=\"%s\"" % info.ProxyName)

  if info.Group == "representations":
    ctorMethod = "Show"
    setPropertiesInCtor = False
    # Ensure the input proxy is the active source:
    input_proxy_info = get_input_proxy_info_for_rep(info)
    if input_proxy_info:
      ensure_active_source(input_proxy_info)
    # Ensure the view is the active view:
    view_proxy_info = get_view_proxy_info_for_rep(info)
    if view_proxy_info:
      ensure_active_view(view_proxy_info)

  if info.Group == "scalar_bars":
    ctorMethod = "CreateScalarBar"
    extraCtorCommands.append("GetRenderView().Representations.append(%s)" % info.PyVariable)
    # Ensure the view is the active view:
    view_proxy_info = get_view_proxy_info_for_rep(info)
    if view_proxy_info:
      ensure_active_view(view_proxy_info)

  if info.Group == "views":
    if info.Proxy.GetXMLLabel() == "XYChartView":
      ctorMethod = "CreateXYPlotView"
    elif info.Proxy.GetXMLLabel() == "XYBarChartView":
      ctorMethod = "CreateBarChartView"
    elif info.Proxy.GetXMLName() == "ComparativeRenderView":
      ctorMethod = "CreateComparativeRenderView"
    elif info.Proxy.GetXMLName() == "ComparativeXYPlotView":
      ctorMethod = "CreateComparativeXYPlotView"
    elif info.Proxy.GetXMLName() == "ComparativeBarChartView":
      ctorMethod = "CreateComparativeBarChartView"
    elif info.Proxy.GetXMLName() == "ParallelCoordinatesChartView":
      ctorMethod = "CreateParallelCoordinatesChartView"
    elif info.Proxy.GetXMLName() == "2DRenderView":
      ctorMethod = "Create2DRenderView"
    elif info.Proxy.GetXMLName() == "RenderView":
      ctorMethod = "CreateRenderView"
    else:
      # use the generic method to create this view.
      ctorMethod = "CreateView"
      ctorArgs.append('"%s"' % info.Proxy.GetXMLName())

    # Now track it as the last active view
    trace_globals.last_active_view = info.Proxy
    setPropertiesInCtor = False
  if info.Group == "lookup_tables":
    match = re.match("(\d)\.([^.]+)\.PVLookupTable", info.ProxyName)
    if match:
      ctorMethod = "GetLookupTableForArray"
      ctorArgs.append("\"%s\"" % match.group(2))
      ctorArgs.append(match.group(1))
    else:
      # This is not a standard LUT created by the GUI--how in the world?
      # We'll just handle it as if it's a stray LUT.
      ctorMethod = "CreateLookupTable"

  if info.Group == "piecewise_functions":
    ctorMethod = "CreatePiecewiseFunction"

  if info.Group == "animation":
    if info.Proxy.GetXMLName() == "AnimationScene":
      ctorMethod = "GetAnimationScene"
      setPropertiesInCtor = False

    elif info.Proxy.GetXMLName() == "KeyFrameAnimationCue":
      ctorMethod = "GetAnimationTrack"
      propname = None
      index = None
      if propNameValues.has_key("AnimatedPropertyName"):
        propname = propNameValues.get_value("AnimatedPropertyName")
        propNameValues = propNameValues.purge("AnimatedPropertyName")
      if propNameValues.has_key("AnimatedElement"):
        index = propNameValues.get_value("AnimatedElement")
        propNameValues = propNameValues.purge("AnimatedElement")
      propNameValues = propNameValues.purge("AnimatedProxy")
      animated_proxy_info = get_animated_proxy_info(info)
      ctorArgs.append(propname)
      if index != None:
        ctorArgs.append(index)
      if animated_proxy_info:
        if not animated_proxy_info.ParentProxyInfo:
          ensure_active_source(animated_proxy_info)
        else:
          ctorArgs.append("proxy=%s.%s" % (animated_proxy_info.ParentProxyInfo.PyVariable,
                                           animated_proxy_info.PyVariable))
      setPropertiesInCtor = False
    elif info.Proxy.GetXMLName() == "CameraAnimationCue":
      view_proxy_info = get_animated_proxy_info(info)
      if view_proxy_info:
        ensure_active_view(view_proxy_info)
      ctorMethod = "GetCameraTrack"
      propNameValues = propNameValues.purge("AnimatedProxy")
      propNameValues = propNameValues.purge("AnimatedPropertyName")
      setPropertiesInCtor = False
    elif info.Proxy.GetXMLName() == "TimeAnimationCue":
      ctorMethod = "GetTimeTrack"
      propNameValues = propNameValues.purge("AnimatedProxy")
      propNameValues = propNameValues.purge("AnimatedPropertyName")
      setPropertiesInCtor = False
  return (ctorMethod, ctorArgs, setPropertiesInCtor, extraCtorCommands)
Example #8
0
def determine_ctor(info, propNameValues):
    """Determines the contructor to use for the proxy_info in trace.
  propNameValues is an instance of list_of_tuples with (propname, propvalue) pairs.
  Returns a tuple:
    (method_name, list-of-ctor-args, set-properties-in-ctor-flag, extracmds_list)
  """
    if not isinstance(info, proxy_trace_info):
        raise TypeError(
            "Invalid argument. Was expecting an instance of proxy_trace_info")
    if not isinstance(propNameValues, list_of_tuples):
        raise TypeError(
            "Invalid argument. Was expected an instance of list_of_tuples")

    extraCtorCommands = []
    ctorMethod = info.ctor_method.name
    ctorArgs = info.ctor_method.args[:]
    setPropertiesInCtor = info.ctor_method.setPropertiesInCtor
    if ctorMethod:
        return (ctorMethod, ctorArgs, setPropertiesInCtor, extraCtorCommands)

    ctorMethod = servermanager._make_name_valid(info.Proxy.GetXMLLabel())
    if info.Group == "sources":
        # track it as the last active source now
        trace_globals.last_active_source = info.Proxy
        # maybe append the guiName property
        if trace_globals.use_gui_name:
            ctorArgs.append("guiName=\"%s\"" % info.ProxyName)

    if info.Group == "representations":
        ctorMethod = "Show"
        setPropertiesInCtor = False
        # Ensure the input proxy is the active source:
        input_proxy_info = get_input_proxy_info_for_rep(info)
        if input_proxy_info:
            ensure_active_source(input_proxy_info)
        # Ensure the view is the active view:
        view_proxy_info = get_view_proxy_info_for_rep(info)
        if view_proxy_info:
            ensure_active_view(view_proxy_info)

    if info.Group == "scalar_bars":
        ctorMethod = "CreateScalarBar"
        extraCtorCommands.append("GetRenderView().Representations.append(%s)" %
                                 info.PyVariable)
        # Ensure the view is the active view:
        view_proxy_info = get_view_proxy_info_for_rep(info)
        if view_proxy_info:
            ensure_active_view(view_proxy_info)

    if info.Group == "views":
        if info.Proxy.GetXMLLabel() == "XYChartView":
            ctorMethod = "CreateXYPlotView"
        elif info.Proxy.GetXMLLabel() == "XYBarChartView":
            ctorMethod = "CreateBarChartView"
        elif info.Proxy.GetXMLName() == "ComparativeRenderView":
            ctorMethod = "CreateComparativeRenderView"
        elif info.Proxy.GetXMLName() == "ComparativeXYPlotView":
            ctorMethod = "CreateComparativeXYPlotView"
        elif info.Proxy.GetXMLName() == "ComparativeBarChartView":
            ctorMethod = "CreateComparativeBarChartView"
        elif info.Proxy.GetXMLName() == "ParallelCoordinatesChartView":
            ctorMethod = "CreateParallelCoordinatesChartView"
        elif info.Proxy.GetXMLName() == "2DRenderView":
            ctorMethod = "Create2DRenderView"
        elif info.Proxy.GetXMLName() == "RenderView":
            ctorMethod = "CreateRenderView"
        else:
            # use the generic method to create this view.
            ctorMethod = "CreateView"
            ctorArgs.append('"%s"' % info.Proxy.GetXMLName())

        # Now track it as the last active view
        trace_globals.last_active_view = info.Proxy
        setPropertiesInCtor = False
    if info.Group == "lookup_tables":
        match = re.match("(\d)\.([^.]+)\.PVLookupTable", info.ProxyName)
        if match:
            ctorMethod = "GetLookupTableForArray"
            ctorArgs.append("\"%s\"" % match.group(2))
            ctorArgs.append(match.group(1))
        else:
            # This is not a standard LUT created by the GUI--how in the world?
            # We'll just handle it as if it's a stray LUT.
            ctorMethod = "CreateLookupTable"

    if info.Group == "piecewise_functions":
        ctorMethod = "CreatePiecewiseFunction"

    if info.Group == "animation":
        if info.Proxy.GetXMLName() == "AnimationScene":
            ctorMethod = "GetAnimationScene"
            setPropertiesInCtor = False

        elif info.Proxy.GetXMLName() == "KeyFrameAnimationCue":
            ctorMethod = "GetAnimationTrack"
            propname = None
            index = None
            if propNameValues.has_key("AnimatedPropertyName"):
                propname = propNameValues.get_value("AnimatedPropertyName")
                propNameValues = propNameValues.purge("AnimatedPropertyName")
            if propNameValues.has_key("AnimatedElement"):
                index = propNameValues.get_value("AnimatedElement")
                propNameValues = propNameValues.purge("AnimatedElement")
            propNameValues = propNameValues.purge("AnimatedProxy")
            animated_proxy_info = get_animated_proxy_info(info)
            ctorArgs.append(propname)
            if index != None:
                ctorArgs.append(index)
            if animated_proxy_info:
                if not animated_proxy_info.ParentProxyInfo:
                    ensure_active_source(animated_proxy_info)
                else:
                    ctorArgs.append(
                        "proxy=%s.%s" %
                        (animated_proxy_info.ParentProxyInfo.PyVariable,
                         animated_proxy_info.PyVariable))
            setPropertiesInCtor = False
        elif info.Proxy.GetXMLName() == "CameraAnimationCue":
            view_proxy_info = get_animated_proxy_info(info)
            if view_proxy_info:
                ensure_active_view(view_proxy_info)
            ctorMethod = "GetCameraTrack"
            propNameValues = propNameValues.purge("AnimatedProxy")
            propNameValues = propNameValues.purge("AnimatedPropertyName")
            setPropertiesInCtor = False
        elif info.Proxy.GetXMLName() == "TimeAnimationCue":
            ctorMethod = "GetTimeTrack"
            propNameValues = propNameValues.purge("AnimatedProxy")
            propNameValues = propNameValues.purge("AnimatedPropertyName")
            setPropertiesInCtor = False
    return (ctorMethod, ctorArgs, setPropertiesInCtor, extraCtorCommands)
def append_trace():

  # Get the list of last registered proxies in sorted order
  modified_proxies = sort_proxy_info_by_group(trace_globals.last_registered_proxies)

  # Now append the existing proxies to the list
  for p in trace_globals.registered_proxies: modified_proxies.append(p)

  for info in modified_proxies:
    traceOutput = ""

    # Generate list of tuples : (propName, propValue)
    propNameValues = []
    for propName, propValue in info.ModifiedProps.iteritems():
      if propIsIgnored(info, propName): continue

      # Note, the 'Input' property is ignored for representations, so we are
      # only dealing with filter proxies here.  If the 'Input' property is a
      # single value (not a multi-input filter), then ensure the input is
      # the active source and leave the 'Input' property out of the
      # propNameValues list.
      if propName == "Input" and propValue.find("[") == -1:
        inputProxyInfo = get_proxy_info(propValue)
        ensure_active_source(inputProxyInfo)
        continue
      propNameValues.append( (propName,propValue) )

    # Clear the modified prop list
    info.ModifiedProps.clear()

    # If info is in the last_registered_proxies list, then we need to add the
    # proxy's constructor call to the trace
    if info in trace_globals.last_registered_proxies:

      # Determine the function call to construct the proxy
      setPropertiesInCtor = True
      ctorArgs = []
      extraCtorCommands = ""
      ctorMethod = servermanager._make_name_valid(info.Proxy.GetXMLLabel())
      if info.Group == "sources":
        # track it as the last active source now
        trace_globals.last_active_source = info.Proxy
        # maybe append the guiName property
        if trace_globals.use_gui_name:
          ctorArgs.append("guiName=\"%s\"" % info.ProxyName)

      if info.Group == "representations":
        ctorMethod = "Show"
        setPropertiesInCtor = False
        # Ensure the input proxy is the active source:
        input_proxy_info = get_input_proxy_info_for_rep(info)
        if input_proxy_info:
          ensure_active_source(input_proxy_info)
        # Ensure the view is the active view:
        view_proxy_info = get_view_proxy_info_for_rep(info)
        if view_proxy_info:
          ensure_active_view(view_proxy_info)

      if info.Group == "scalar_bars":
        ctorMethod = "CreateScalarBar"
        extraCtorCommands = "GetRenderView().Representations.append(%s)" % info.PyVariable

      if info.Group == "views":
        if info.Proxy.GetXMLLabel() == "XYPlotView":
          ctorMethod = "CreateXYPlotView"
        elif info.Proxy.GetXMLLabel() == "BarChartView":
          ctorMethod = "CreateBarChartView"
        else:
          ctorMethod = "CreateRenderView"

        # Now track it as the last active view
        trace_globals.last_active_view = info.Proxy
        setPropertiesInCtor = False
      if info.Group == "lookup_tables":
        ctorMethod = "CreateLookupTable"

      if info.Group == "piecewise_functions":
        ctorMethod = "CreatePiecewiseFunction"


      if setPropertiesInCtor:
        for propName, propValue in propNameValues:
          ctorArgs.append("%s=%s"%(propName, propValue))
        propNameValues = []

      ctorArgString = make_comma_separated_string(ctorArgs)
      traceOutput = "%s = %s(%s)\n%s" % (info.PyVariable, ctorMethod, ctorArgString, extraCtorCommands)

    # Set properties on the proxy
    for propName, propValue in propNameValues:
      traceOutput += "%s.%s = %s\n" % (info.PyVariable, propName, propValue)

    if (len(traceOutput)):
      trace_globals.trace_output.append(traceOutput)
  for p in trace_globals.last_registered_proxies:
    trace_globals.registered_proxies.append(p)
  while (len(trace_globals.last_registered_proxies)):
    trace_globals.last_registered_proxies.pop()
Example #10
0
def append_trace():

    # Get the list of last registered proxies in sorted order
    modified_proxies = sort_proxy_info_by_group(
        trace_globals.last_registered_proxies)

    # Now append the existing proxies to the list
    for p in trace_globals.registered_proxies:
        modified_proxies.append(p)

    for info in modified_proxies:
        traceOutput = ""

        # Generate list of tuples : (propName, propValue)
        propNameValues = []
        for propName, propValue in info.ModifiedProps.iteritems():
            if propIsIgnored(info, propName): continue

            # Note, the 'Input' property is ignored for representations, so we are
            # only dealing with filter proxies here.  If the 'Input' property is a
            # single value (not a multi-input filter), then ensure the input is
            # the active source and leave the 'Input' property out of the
            # propNameValues list.
            if propName == "Input" and propValue.find("[") == -1:
                inputProxyInfo = get_proxy_info(propValue)
                ensure_active_source(inputProxyInfo)
                continue
            propNameValues.append((propName, propValue))

        # Clear the modified prop list
        info.ModifiedProps.clear()

        # If info is in the last_registered_proxies list, then we need to add the
        # proxy's constructor call to the trace
        if info in trace_globals.last_registered_proxies:

            # Determine the function call to construct the proxy
            setPropertiesInCtor = True
            ctorArgs = []
            extraCtorCommands = ""
            ctorMethod = servermanager._make_name_valid(
                info.Proxy.GetXMLLabel())
            if info.Group == "sources":
                # track it as the last active source now
                trace_globals.last_active_source = info.Proxy
                # maybe append the guiName property
                if trace_globals.use_gui_name:
                    ctorArgs.append("guiName=\"%s\"" % info.ProxyName)

            if info.Group == "representations":
                ctorMethod = "Show"
                setPropertiesInCtor = False
                # Ensure the input proxy is the active source:
                input_proxy_info = get_input_proxy_info_for_rep(info)
                if input_proxy_info:
                    ensure_active_source(input_proxy_info)
                # Ensure the view is the active view:
                view_proxy_info = get_view_proxy_info_for_rep(info)
                if view_proxy_info:
                    ensure_active_view(view_proxy_info)

            if info.Group == "scalar_bars":
                ctorMethod = "CreateScalarBar"
                extraCtorCommands = "GetRenderView().Representations.append(%s)" % info.PyVariable

            if info.Group == "views":
                if info.Proxy.GetXMLLabel() == "XYPlotView":
                    ctorMethod = "CreateXYPlotView"
                elif info.Proxy.GetXMLLabel() == "BarChartView":
                    ctorMethod = "CreateBarChartView"
                else:
                    ctorMethod = "CreateRenderView"

                # Now track it as the last active view
                trace_globals.last_active_view = info.Proxy
                setPropertiesInCtor = False
            if info.Group == "lookup_tables":
                match = re.match("(\d)\.([^.]+)\.PVLookupTable",
                                 info.ProxyName)
                if match:
                    ctorMethod = "GetLookupTableForArray"
                    ctorArgs.append("\"%s\"" % match.group(2))
                    ctorArgs.append(match.group(1))
                else:
                    # This is not a standard LUT created by the GUI--how in the world?
                    # We'll just handle it as if it's a stray LUT.
                    ctorMethod = "CreateLookupTable"

            if info.Group == "piecewise_functions":
                ctorMethod = "CreatePiecewiseFunction"

            if setPropertiesInCtor:
                for propName, propValue in propNameValues:
                    ctorArgs.append("%s=%s" % (propName, propValue))
                propNameValues = []

            if trace_globals.proxy_ctor_hook:
                ctorMethod, ctorArgs, extraCtorCommands = trace_globals.proxy_ctor_hook(
                    info, ctorMethod, ctorArgs, extraCtorCommands)

            ctorArgString = make_comma_separated_string(ctorArgs)
            traceOutput = "%s = %s(%s)\n%s" % (
                info.PyVariable, ctorMethod, ctorArgString, extraCtorCommands)

        # Set properties on the proxy
        for propName, propValue in propNameValues:
            traceOutput += "%s.%s = %s\n" % (info.PyVariable, propName,
                                             propValue)

        if (len(traceOutput)):
            trace_globals.trace_output.append(traceOutput)
    for p in trace_globals.last_registered_proxies:
        trace_globals.registered_proxies.append(p)
    while (len(trace_globals.last_registered_proxies)):
        trace_globals.last_registered_proxies.pop()