Exemplo n.º 1
0
    def trace_ctor(self, ctor, filter, ctor_args=None, skip_assignment=False):
        xmlElement = self.get_object().GetHints().FindNestedElementByName(
            "WriterProxy")
        xmlgroup = xmlElement.GetAttribute("group")
        xmlname = xmlElement.GetAttribute("name")
        write_frequency = self.get_object().GetProperty(
            "WriteFrequency").GetElement(0)
        filename = self.get_object().GetProperty("FileName").GetElement(0)
        padding_amount = self.get_object().GetProperty(
            "PaddingAmount").GetElement(0)
        ctor = self.get_proxy_label(xmlgroup, xmlname)
        original_trace = smtrace.RealProxyAccessor.trace_ctor(\
            self, ctor, WriterFilter(), ctor_args, skip_assignment)

        trace = smtrace.TraceOutput(original_trace)
        trace.append_separated([
            "# register the writer with coprocessor",
            "# and provide it with information such as the filename to use,",
            "# how frequently to write the data, etc."
        ])
        trace.append("coprocessor.RegisterWriter(%s, filename='%s', freq=%s, paddingamount=%s)" % \
                     (self, filename, write_frequency, padding_amount))

        trace.append_separator()
        return trace.raw_data()
Exemplo n.º 2
0
    def trace_ctor(self, ctor, filter, ctor_args=None, skip_assignment=False):
        trace = smtrace.TraceOutput()
        trace.append("# create a producer from a simulation input")
        trace.append("%s = coprocessor.CreateProducer(datadescription, '%s')" % \
            (self, self.SimulationInputName))

        # TODO, review whether this Accessor should also export arrays.
        return trace.raw_data()
Exemplo n.º 3
0
 def trace_ctor(self, ctor, filter, ctor_args=None, skip_assignment=False):
     original_trace = smtrace.RealProxyAccessor.trace_ctor(\
         self, ctor, filter, ctor_args, skip_assignment)
     trace = smtrace.TraceOutput(original_trace)
     if cpstate_globals.cinema_tracks and self.varname in cpstate_globals.cinema_tracks:
         valrange = cpstate_globals.cinema_tracks[self.varname]
         trace.append_separated(["# register the filter with the coprocessor's cinema generator"])
         trace.append(["coprocessor.RegisterCinemaTrack('slice', %s, 'SliceOffsetValues', %s)" % (self, valrange)])
         trace.append_separator()
     return trace.raw_data()
Exemplo n.º 4
0
    def trace_ctor(self, ctor, filter, ctor_args = None, skip_assignment = False):
        original_trace = smtrace.RealProxyAccessor.trace_ctor( \
            self, ctor, filter, ctor_args, skip_assignment)

        trace = smtrace.TraceOutput(original_trace)
        if self.varname in cpstate_globals.cinema_arrays:
            arrays = cpstate_globals.cinema_arrays[self.varname]
            trace.append_separated(["# define target arrays of filters."])
            trace.append(["coprocessor.AddArraysToCinemaTrack(%s, 'arraySelection', %s)" % (self, arrays)])
            trace.append_separator()
        return trace.raw_data()
Exemplo n.º 5
0
    def trace_ctor(self, ctor, filter, ctor_args=None, skip_assignment=False):
        trace = smtrace.TraceOutput()
        trace.append("# create a producer from a simulation input")
        trace.append("%s = coprocessor.CreateProducer(datadescription, '%s')" % \
            (self, self.SimulationInputName))

        if self.varname in cpstate_globals.cinema_arrays:
            arrays = cpstate_globals.cinema_arrays[self.varname]
            trace.append_separated(["# define target arrays of filters."])
            trace.append(["coprocessor.AddArraysToCinemaTrack(%s, 'arraySelection', %s)" % (self, arrays)])
            trace.append_separator()
        return trace.raw_data()
Exemplo n.º 6
0
    def trace_ctor(self, ctor, filter, ctor_args=None, skip_assignment=False):
        # FIXME: ensures thate FileName doesn't get traced.

        # change to call STP.CreateReader instead.
        ctor_args = "%s, fileInfo='%s'" % (ctor, self.FileNameGlob)
        ctor = "STP.CreateReader"
        original_trace = smtrace.RealProxyAccessor.trace_ctor(\
            self, ctor, ReaderFilter(), ctor_args, skip_assignment)

        trace = smtrace.TraceOutput()
        trace.append(original_trace)
        trace.append(\
            "timeSteps = %s.TimestepValues if len(%s.TimestepValues) != 0 else [0]" % (self, self))
        return trace.raw_data()
Exemplo n.º 7
0
    def trace_ctor(self, ctor, filter, ctor_args = None, skip_assignment = False):
        original_trace = smtrace.RealProxyAccessor.trace_ctor( \
            self, ctor, filter, ctor_args, skip_assignment)
        trace = smtrace.TraceOutput(original_trace)
        if cpstate_globals.cinema_tracks and self.varname  in cpstate_globals.cinema_tracks:
            valrange = cpstate_globals.cinema_tracks[self.varname]
            trace.append_separated(["# register the filter with the coprocessor's cinema generator"])
            trace.append(["coprocessor.RegisterCinemaTrack('clip', %s, 'OffsetValues', %s)" % (self, valrange)])

        if self.varname in cpstate_globals.cinema_arrays:
            arrays = cpstate_globals.cinema_arrays[self.varname]
            trace.append_separated(["# define target arrays of filters."])
            trace.append(["coprocessor.AddArraysToCinemaTrack(%s, 'arraySelection', %s)" % (self, arrays)])
            trace.append_separator()
        return trace.raw_data()
Exemplo n.º 8
0
 def trace_ctor(self, ctor, filter, ctor_args=None, skip_assignment=False):
     original_trace = smtrace.RealProxyAccessor.trace_ctor(\
         self, ctor, filter, ctor_args, skip_assignment)
     trace = smtrace.TraceOutput(original_trace)
     trace.append_separated(["# register the view with coprocessor",
       "# and provide it with information such as the filename to use,",
       "# how frequently to write the images, etc."])
     params = self.ScreenshotInfo
     assert len(params) == 4
     trace.append([
         "STP.RegisterView(%s," % self,
         "    filename='%s', magnification=%s, width=%s, height=%s, tp_views=tp_views)" %\
             (params[0], params[1], params[2], params[3])])
     trace.append_separator()
     return trace.raw_data()
Exemplo n.º 9
0
    def trace_ctor(self, ctor, filter, ctor_args=None, skip_assignment=False):
        trace = smtrace.TraceOutput()
        trace.append("# create a producer from a simulation input")
        trace.append("%s = coprocessor.CreateProducer(datadescription, '%s')" % \
            (self, self.SimulationInputName))

        # self.varname has .'s and *'s stripped. Knowing this, the key in cpstate_globals.cinema_arrays
        # should also be stripped of .'s and *'s. Refers to /Qt/ApplicationComponents/pqExportCatalystScript.cxx
        cpstate_globals = get_globals()
        if self.varname in cpstate_globals.cinema_arrays:
            arrays = cpstate_globals.cinema_arrays[self.varname]
            trace.append_separated(["# define target arrays of filters."])
            trace.append(["coprocessor.AddArraysToCinemaTrack(%s, 'arraySelection', %s)" % (self, arrays)])
            trace.append_separator()
        return trace.raw_data()
Exemplo n.º 10
0
 def trace_ctor(self, ctor, filter, ctor_args=None, skip_assignment=False):
     original_trace = smtrace.RealProxyAccessor.trace_ctor(\
         self, ctor, filter, ctor_args, skip_assignment)
     trace = smtrace.TraceOutput(original_trace)
     if self.ProxyName in cpstate_globals.screenshot_info:
        trace.append_separated(["# register the view with coprocessor",
       "# and provide it with information such as the filename to use,",
       "# how frequently to write the images, etc."])
        params = cpstate_globals.screenshot_info[self.ProxyName]
        assert len(params) == 7
        trace.append([
           "coprocessor.RegisterView(%s," % self,
           "    filename='%s', freq=%s, fittoscreen=%s, magnification=%s, width=%s, height=%s, cinema=%s)" %\
               (params[0], params[1], params[2], params[3], params[4], params[5], params[6])])
        trace.append_separator()
     return trace.raw_data()
Exemplo n.º 11
0
    def trace_ctor(self, ctor, filter, ctor_args=None, skip_assignment=False):
        xmlElement = self.get_object().GetHints().FindNestedElementByName("WriterProxy")
        xmlgroup = xmlElement.GetAttribute("group")
        xmlname = xmlElement.GetAttribute("name")

        filename = self.get_object().FileName
        ctor = self.get_proxy_label(xmlgroup, xmlname)
        original_trace = smtrace.RealProxyAccessor.trace_ctor(\
            self, ctor, filter, ctor_args, skip_assignment)

        trace = smtrace.TraceOutput(original_trace)
        trace.append_separated(["# register the writer with STP",
          "# and provide it with information such as the filename to use"])
        trace.append("STP.RegisterWriter(%s, '%s', tp_writers)" % \
            (self, filename))
        trace.append_separator()
        return trace.raw_data()
Exemplo n.º 12
0
def get_state(options=None, source_set=[], filter=None, raw=False):
    """Returns the state string"""
    if options:
        options = sm._getPyProxy(options)
        propertiesToTraceOnCreate = options.PropertiesToTraceOnCreate
        skipHiddenRepresentations = options.SkipHiddenDisplayProperties
        skipRenderingComponents = options.SkipRenderingComponents
    else:
        propertiesToTraceOnCreate = RECORD_MODIFIED_PROPERTIES
        skipHiddenRepresentations = True
        skipRenderingComponents = False

    # essential to ensure any obsolete accessors don't linger - can cause havoc
    # when saving state following a Python trace session
    # (paraview/paraview#18994)
    import gc
    gc.collect()

    if sm.vtkSMTrace.GetActiveTracer():
        raise RuntimeError ("Cannot generate Python state when tracing is active.")

    if filter is None:
        filter = visible_representations() if skipHiddenRepresentations else supported_proxies()

    # build a set of proxies of interest
    if source_set:
        start_set = source_set
    else:
        # if nothing is specified, we save all views and sources.
        start_set = [x for x in simple.GetSources().values()] + simple.GetViews()
    start_set = [x for x in start_set if filter(x)]

    # now, locate dependencies for the start_set, pruning irrelevant branches
    consumers = set(start_set)
    for proxy in start_set:
        get_consumers(proxy, filter, consumers)

    producers = set()
    for proxy in consumers:
        get_producers(proxy, filter, producers)

    # proxies_of_interest is set of all proxies that we should trace.
    proxies_of_interest = producers.union(consumers)
    #print ("proxies_of_interest", proxies_of_interest)

    trace_config = smtrace.start_trace(preamble="")
    # this ensures that lookup tables/scalar bars etc. are fully traced.
    trace_config.SetFullyTraceSupplementalProxies(True)
    trace_config.SetSkipRenderingComponents(skipRenderingComponents)

    trace = smtrace.TraceOutput()
    trace.append("# state file generated using %s" % simple.GetParaViewSourceVersion())
    trace.append_separated(smtrace.get_current_trace_output_and_reset(raw=True))

    #--------------------------------------------------------------------------
    # We trace the views and layouts, if any.
    if skipRenderingComponents:
        views = []
    else:
        views = [x for x in proxies_of_interest if smtrace.Trace.get_registered_name(x, "views")]

    if views:
        # sort views by their names, so the state has some structure to it.
        views = sorted(views, key=lambda x:\
                smtrace.Trace.get_registered_name(x, "views"))
        trace.append_separated([\
            "# ----------------------------------------------------------------",
            "# setup views used in the visualization",
            "# ----------------------------------------------------------------"])
        for view in views:
            # FIXME: save view camera positions and size.
            traceitem = smtrace.RegisterViewProxy(view)
            traceitem.finalize()
            del traceitem
        trace.append_separated(smtrace.get_current_trace_output_and_reset(raw=True))
        trace.append_separated(["SetActiveView(None)"])

    # from views,  build the list of layouts of interest.
    layouts = set()
    for aview in views:
        l = simple.GetLayout(aview)
        if l:
            layouts.add(simple.GetLayout(aview))

    # trace create of layouts
    if layouts:
        layouts = sorted(layouts, key=lambda x:\
                  smtrace.Trace.get_registered_name(x, "layouts"))
        trace.append_separated([\
            "# ----------------------------------------------------------------",
            "# setup view layouts",
            "# ----------------------------------------------------------------"])
        for layout in layouts:
            traceitem = smtrace.RegisterLayoutProxy(layout)
            traceitem.finalize(filter=lambda x: x in views)
            del traceitem
        trace.append_separated(smtrace.get_current_trace_output_and_reset(raw=True))

    if views:
        # restore the active view after the layouts have been created.
        trace.append_separated([\
            "# ----------------------------------------------------------------",
            "# restore active view",
            "SetActiveView(%s)" % smtrace.Trace.get_accessor(simple.GetActiveView()),
            "# ----------------------------------------------------------------"])

    #--------------------------------------------------------------------------
    # Next, trace data processing pipelines.
    sorted_proxies_of_interest = __toposort(proxies_of_interest)
    sorted_sources = [x for x in sorted_proxies_of_interest \
        if smtrace.Trace.get_registered_name(x, "sources")]
    if sorted_sources:
        trace.append_separated([\
            "# ----------------------------------------------------------------",
            "# setup the data processing pipelines",
            "# ----------------------------------------------------------------"])
        for source in sorted_sources:
            traceitem = smtrace.RegisterPipelineProxy(source)
            traceitem.finalize()
            del traceitem
        trace.append_separated(smtrace.get_current_trace_output_and_reset(raw=True))

    #--------------------------------------------------------------------------
    # Can't decide if the representations should be saved with the pipeline
    # objects or afterwards, opting for afterwards for now since the topological
    # sort doesn't guarantee that the representations will follow their sources
    # anyways.
    sorted_representations = [x for x in sorted_proxies_of_interest \
        if smtrace.Trace.get_registered_name(x, "representations")]
    scalarbar_representations = [x for x in sorted_proxies_of_interest\
        if smtrace.Trace.get_registered_name(x, "scalar_bars")]
    # print ("sorted_representations", sorted_representations)
    # print ("scalarbar_representations", scalarbar_representations)
    if not skipRenderingComponents and (sorted_representations or scalarbar_representations):
        for view in views:
            view_representations = [x for x in view.Representations if x in sorted_representations]
            view_scalarbars = [x for x in view.Representations if x in scalarbar_representations]
            if view_representations or view_scalarbars:
                trace.append_separated([\
                    "# ----------------------------------------------------------------",
                    "# setup the visualization in view '%s'" % smtrace.Trace.get_accessor(view),
                    "# ----------------------------------------------------------------"])
            for rep in view_representations:
                try:
                    producer = rep.Input
                    port = rep.Input.Port
                    traceitem = smtrace.Show(producer, port, view, rep,
                        comment="show data from %s" % smtrace.Trace.get_accessor(producer))
                    traceitem.finalize()
                    del traceitem
                    trace.append_separated(smtrace.get_current_trace_output_and_reset(raw=True))

                    if rep.UseSeparateColorMap:
                        trace.append_separated([\
                            "# set separate color map",
                            "%s.UseSeparateColorMap = True" % (\
                                smtrace.Trace.get_accessor(rep))])

                except AttributeError: pass
            # save the scalar bar properties themselves.
            if view_scalarbars:
                trace.append_separated("# setup the color legend parameters for each legend in this view")
                for rep in view_scalarbars:
                    smtrace.Trace.get_accessor(rep)
                    trace.append_separated(smtrace.get_current_trace_output_and_reset(raw=True))
                    trace.append_separated([\
                      "# set color bar visibility", "%s.Visibility = %s" % (\
                    smtrace.Trace.get_accessor(rep), rep.Visibility)])


            for rep in view_representations:
                try:
                    producer = rep.Input
                    port = rep.Input.Port

                    if rep.IsScalarBarVisible(view):
                        # FIXME: this will save this multiple times, right now,
                        # if two representations use the same LUT.
                        trace.append_separated([\
                            "# show color legend",
                            "%s.SetScalarBarVisibility(%s, True)" % (\
                                smtrace.Trace.get_accessor(rep),
                                smtrace.Trace.get_accessor(view))])

                    if not rep.Visibility:
                      traceitem = smtrace.Hide(producer, port, view)
                      traceitem.finalize()
                      del traceitem
                      trace.append_separated(smtrace.get_current_trace_output_and_reset(raw=True))

                except AttributeError: pass

    #--------------------------------------------------------------------------
    # Now, trace the transfer functions (color maps and opacity maps) used.
    ctfs = set([x for x in proxies_of_interest \
        if smtrace.Trace.get_registered_name(x, "lookup_tables")])
    if not skipRenderingComponents and ctfs:
        trace.append_separated([\
            "# ----------------------------------------------------------------",
            "# setup color maps and opacity mapes used in the visualization",
            "# note: the Get..() functions create a new object, if needed",
            "# ----------------------------------------------------------------"])
        for ctf in ctfs:
            smtrace.Trace.get_accessor(ctf)
            if ctf.ScalarOpacityFunction in proxies_of_interest:
                smtrace.Trace.get_accessor(ctf.ScalarOpacityFunction)
        trace.append_separated(smtrace.get_current_trace_output_and_reset(raw=True))

    # Trace extract generators.
    exgens = set([x for x in proxies_of_interest \
            if smtrace.Trace.get_registered_name(x, "extract_generators")])
    if exgens:
        trace.append_separated([\
            "# ----------------------------------------------------------------",
            "# setup extract generators",
            "# ----------------------------------------------------------------"])
        for exgen in exgens:
            # FIXME: this currently doesn't handle multiple output ports
            # correctly.
            traceitem = smtrace.CreateExtractGenerator(\
                    xmlname=exgen.Writer.GetXMLName(),
                    producer=exgen.Producer,
                    generator=exgen,
                    registrationName=smtrace.Trace.get_registered_name(exgen, "extract_generators"))
            traceitem.finalize()
            del traceitem
        trace.append_separated(smtrace.get_current_trace_output_and_reset(raw=True))

    # restore the active source since the order in which the pipeline is created
    # in the state file can end up changing the active source to be different
    # than what it was when the state is being saved.
    trace.append_separated([\
            "# ----------------------------------------------------------------",
            "# restore active source",
            "SetActiveSource(%s)" % smtrace.Trace.get_accessor(simple.GetActiveSource()),
            "# ----------------------------------------------------------------"])

    if options:
        # add coda about extracts generation.
        trace.append_separated(["",
            "if __name__ == '__main__':",
            "    # generate extracts",
            "    SaveExtracts(ExtractsOutputDirectory='%s')" % options.ExtractsOutputDirectory])
    del trace_config
    smtrace.stop_trace()
    #print (trace)
    return str(trace) if not raw else trace.raw_data()
Exemplo n.º 13
0
 def trace_ctor(self, ctor, filter, ctor_args=None, skip_assignment=False):
     trace = smtrace.TraceOutput()
     trace.append("# create a producer from a simulation input")
     trace.append("%s = coprocessor.CreateProducer(datadescription, '%s')" % \
         (self, self.SimulationInputName))
     return trace.raw_data()
Exemplo n.º 14
0
def get_state(
        propertiesToTraceOnCreate=1,  # sm.vtkSMTrace.RECORD_MODIFIED_PROPERTIES,
        skipHiddenRepresentations=True,
        source_set=[],
        filter=None,
        raw=False):
    """Returns the state string"""
    if sm.vtkSMTrace.GetActiveTracer():
        raise RuntimeError(
            "Cannot generate Python state when tracing is active.")

    if filter is None:
        filter = visible_representations(
        ) if skipHiddenRepresentations else supported_proxies()

    # build a set of proxies of interest
    if source_set:
        start_set = source_set
    else:
        # if nothing is specified, we save all views and sources.
        start_set = [x for x in simple.GetSources().values()
                     ] + simple.GetViews()
    start_set = [x for x in start_set if filter(x)]

    # now, locate dependencies for the start_set, pruning irrelevant branches
    consumers = set(start_set)
    for proxy in start_set:
        get_consumers(proxy, filter, consumers)

    producers = set()
    for proxy in consumers:
        get_producers(proxy, filter, producers)

    # proxies_of_interest is set of all proxies that we should trace.
    proxies_of_interest = producers.union(consumers)
    #print ("proxies_of_interest", proxies_of_interest)

    trace_config = smtrace.start_trace()
    # this ensures that lookup tables/scalar bars etc. are fully traced.
    trace_config.SetFullyTraceSupplementalProxies(True)

    trace = smtrace.TraceOutput()
    trace.append("# state file generated using %s" %
                 simple.GetParaViewSourceVersion())

    #--------------------------------------------------------------------------
    # First, we trace the views and layouts, if any.
    # TODO: add support for layouts.
    views = [
        x for x in proxies_of_interest
        if smtrace.Trace.get_registered_name(x, "views")
    ]
    if views:
        # sort views by their names, so the state has some structure to it.
        views = sorted(views, key=lambda x:\
                smtrace.Trace.get_registered_name(x, "views"))
        trace.append_separated([\
            "# ----------------------------------------------------------------",
            "# setup views used in the visualization",
            "# ----------------------------------------------------------------"])
        for view in views:
            # FIXME: save view camera positions and size.
            traceitem = smtrace.RegisterViewProxy(view)
            traceitem.finalize()
            del traceitem
        trace.append_separated(
            smtrace.get_current_trace_output_and_reset(raw=True))
        trace.append_separated([\
            "# ----------------------------------------------------------------",
            "# restore active view",
            "SetActiveView(%s)" % smtrace.Trace.get_accessor(simple.GetActiveView()),
            "# ----------------------------------------------------------------"])

    #--------------------------------------------------------------------------
    # Next, trace data processing pipelines.
    sorted_proxies_of_interest = __toposort(proxies_of_interest)
    sorted_sources = [x for x in sorted_proxies_of_interest \
        if smtrace.Trace.get_registered_name(x, "sources")]
    if sorted_sources:
        trace.append_separated([\
            "# ----------------------------------------------------------------",
            "# setup the data processing pipelines",
            "# ----------------------------------------------------------------"])
        for source in sorted_sources:
            traceitem = smtrace.RegisterPipelineProxy(source)
            traceitem.finalize()
            del traceitem
        trace.append_separated(
            smtrace.get_current_trace_output_and_reset(raw=True))

    #--------------------------------------------------------------------------
    # Can't decide if the representations should be saved with the pipeline
    # objects or afterwords, opting for afterwords for now since the topological
    # sort doesn't guarantee that the representations will follow their sources
    # anyways.
    sorted_representations = [x for x in sorted_proxies_of_interest \
        if smtrace.Trace.get_registered_name(x, "representations")]
    scalarbar_representations = [x for x in sorted_proxies_of_interest\
        if smtrace.Trace.get_registered_name(x, "scalar_bars")]
    # print ("sorted_representations", sorted_representations)
    # print ("scalarbar_representations", scalarbar_representations)
    if sorted_representations or scalarbar_representations:
        for view in views:
            view_representations = [
                x for x in view.Representations if x in sorted_representations
            ]
            view_scalarbars = [
                x for x in view.Representations
                if x in scalarbar_representations
            ]
            if view_representations or view_scalarbars:
                trace.append_separated([\
                    "# ----------------------------------------------------------------",
                    "# setup the visualization in view '%s'" % smtrace.Trace.get_accessor(view),
                    "# ----------------------------------------------------------------"])
            for rep in view_representations:
                try:
                    producer = rep.Input
                    port = rep.Input.Port
                    traceitem = smtrace.Show(
                        producer,
                        port,
                        view,
                        rep,
                        comment="show data from %s" %
                        smtrace.Trace.get_accessor(producer))
                    traceitem.finalize()
                    del traceitem
                    trace.append_separated(
                        smtrace.get_current_trace_output_and_reset(raw=True))

                    if rep.UseSeparateColorMap:
                        trace.append_separated([\
                            "# set separate color map",
                            "%s.UseSeparateColorMap = True" % (\
                                smtrace.Trace.get_accessor(rep))])

                except AttributeError:
                    pass
            # save the scalar bar properties themselves.
            if view_scalarbars:
                trace.append_separated(
                    "# setup the color legend parameters for each legend in this view"
                )
                for rep in view_scalarbars:
                    smtrace.Trace.get_accessor(rep)
                    trace.append_separated(
                        smtrace.get_current_trace_output_and_reset(raw=True))
                    trace.append_separated([\
                      "# set color bar visibility", "%s.Visibility = %s" % (\
                    smtrace.Trace.get_accessor(rep), rep.Visibility)])

            for rep in view_representations:
                try:
                    producer = rep.Input
                    port = rep.Input.Port

                    if rep.IsScalarBarVisible(view):
                        # FIXME: this will save this multiple times, right now,
                        # if two representations use the same LUT.
                        trace.append_separated([\
                            "# show color legend",
                            "%s.SetScalarBarVisibility(%s, True)" % (\
                                smtrace.Trace.get_accessor(rep),
                                smtrace.Trace.get_accessor(view))])

                    if not rep.Visibility:
                        traceitem = smtrace.Hide(producer, port, view)
                        traceitem.finalize()
                        del traceitem
                        trace.append_separated(
                            smtrace.get_current_trace_output_and_reset(
                                raw=True))

                except AttributeError:
                    pass

    #--------------------------------------------------------------------------
    # Now, trace the transfer functions (color maps and opacity maps) used.
    ctfs = set([x for x in proxies_of_interest \
        if smtrace.Trace.get_registered_name(x, "lookup_tables")])
    if ctfs:
        trace.append_separated([\
            "# ----------------------------------------------------------------",
            "# setup color maps and opacity mapes used in the visualization",
            "# note: the Get..() functions create a new object, if needed",
            "# ----------------------------------------------------------------"])
        for ctf in ctfs:
            smtrace.Trace.get_accessor(ctf)
            if ctf.ScalarOpacityFunction in proxies_of_interest:
                smtrace.Trace.get_accessor(ctf.ScalarOpacityFunction)
        trace.append_separated(
            smtrace.get_current_trace_output_and_reset(raw=True))

    # restore the active source since the order in which the pipeline is created
    # in the state file can end up changing the active source to be different
    # than what it was when the state is being saved.
    trace.append_separated([\
            "# ----------------------------------------------------------------",
            "# finally, restore active source",
            "SetActiveSource(%s)" % smtrace.Trace.get_accessor(simple.GetActiveSource()),
            "# ----------------------------------------------------------------"])
    del trace_config
    smtrace.stop_trace()
    #print (trace)
    return str(trace) if not raw else trace.raw_data()