def WriterParametersProxy(self, writer, filename, freq): """Creates a client only proxy that will be synchronized with ParaView Live, allowing a user to set the filename and frequency. """ controller = servermanager.ParaViewPipelineController() # assume that a client only proxy with the same name as a writer # is available in "insitu_writer_paramters" # Since coprocessor sometimes pass writer as a custom object and not # a proxy, we need to handle that. Just creating any arbitrary writer # proxy to store the parameters it acceptable. So let's just do that # when the writer is not a proxy. writerIsProxy = isinstance(writer, servermanager.Proxy) helperName = writer.GetXMLName( ) if writerIsProxy else "XMLPImageDataWriter" proxy = servermanager.ProxyManager().NewProxy( "insitu_writer_parameters", helperName) controller.PreInitializeProxy(proxy) if writerIsProxy: # it's possible that the writer can take in multiple input connections # so we need to go through all of them. the try/except block seems # to be the best way to figure out if there are multipel input connections try: length = len(writer.Input) for i in range(length): proxy.GetProperty("Input").AddInputConnection( writer.Input[i].SMProxy, 0) except: proxy.GetProperty("Input").SetInputConnection( 0, writer.Input.SMProxy, 0) proxy.GetProperty("FileName").SetElement(0, filename) proxy.GetProperty("WriteFrequency").SetElement(0, freq) controller.PostInitializeProxy(proxy) controller.RegisterPipelineProxy(proxy) return proxy
def WriterParametersProxy(self, writer, filename, freq): """Creates a client only proxy that will be synchronized with ParaView Live, allowing a user to set the filename and frequency. """ controller = servermanager.ParaViewPipelineController() # assume that a client only proxy with the same name as a writer # is available in "insitu_writer_paramters" # Since coprocessor sometimes pass writer as a custom object and not # a proxy, we need to handle that. Just creating any arbitrary writer # proxy to store the parameters it acceptable. So let's just do that # when the writer is not a proxy. writerIsProxy = isinstance(writer, servermanager.Proxy) helperName = writer.GetXMLName( ) if writerIsProxy else "XMLPImageDataWriter" proxy = servermanager.ProxyManager().NewProxy( "insitu_writer_parameters", helperName) controller.PreInitializeProxy(proxy) if writerIsProxy: proxy.GetProperty("Input").SetInputConnection( 0, writer.Input.SMProxy, 0) proxy.GetProperty("FileName").SetElement(0, filename) proxy.GetProperty("WriteFrequency").SetElement(0, freq) controller.PostInitializeProxy(proxy) controller.RegisterPipelineProxy(proxy) return proxy
def CreateProducer(name): global ActiveDataDescription, ActivePythonPipelineModule assert IsInsituInput(name) module = ActivePythonPipelineModule if not hasattr(module, "_producer_map"): module._producer_map = {} if name in module._producer_map: return module[name] from paraview import servermanager dataDesc = ActiveDataDescription ipdesc = dataDesc.GetInputDescriptionByName(name) # eventually, we want the Catalyst C++ code to give use the vtkAlgorithm to # use; e.g. # servermanager._getPyProxy(ipdesc.GetProducer()) pxm = servermanager.ProxyManager() producer = servermanager._getPyProxy( pxm.NewProxy("sources", "PVTrivialProducer2")) controller = servermanager.ParaViewPipelineController() controller.InitializeProxy(producer) controller.RegisterPipelineProxy(producer, name) # since state file may have arbitrary properties being specified # on the original source, we ensure we ignore them producer.IgnoreUnknownSetRequests = True vtkobject = producer.GetClientSideObject() assert vtkobject vtkobject.SetWholeExtent(ipdesc.GetWholeExtent()) vtkobject.SetOutput(ipdesc.GetGrid()) module._producer_map[name] = producer return producer
def WriterParametersProxy(self, writer, filename, freq): """Creates a client only proxy that will be synchronized with ParaView Live, allowing a user to set filename and frequency. """ controller = servermanager.ParaViewPipelineController() # assume that a client only proxy with the same name as a writer # is available in "filters" proxy = servermanager.ProxyManager().NewProxy("filters", writer.GetXMLName()) controller.PreInitializeProxy(proxy) proxy.GetProperty("Input").SetInputConnection(0, writer.Input.SMProxy, 0) proxy.GetProperty("FileName").SetElement(0, filename) proxy.GetProperty("WriteFrequency").SetElement(0, freq) controller.PostInitializeProxy(proxy) controller.RegisterPipelineProxy(proxy) return proxy
#-------------------- Start testing -------------------------- print("Start PythonAnnotationFilter testing") options = servermanager.vtkProcessModule.GetProcessModule().GetOptions() dataToLoad = options.GetParaViewDataName() # Load data file reader = OpenDataFile(dataToLoad) reader.GlobalVariables = ['KE', 'XMOM', 'YMOM', 'ZMOM', 'NSTEPS', 'TMSTEP'] reader.UpdatePipeline() # Time management controller = servermanager.ParaViewPipelineController() timekeeper = controller.FindTimeKeeper(servermanager.ActiveConnection.Session) timesteps = timekeeper.TimestepValues time = timesteps[5] # Merge blocks ### Just skip the merge = MergeBlocks() # Annotation filter annotation = PythonAnnotation() annotation.Expression = '"%f %f %f" % (XMOM[t_index], YMOM[t_index], ZMOM[t_index])' # Update time and trigger pipeline execution time = timesteps[5] annotation.UpdatePipeline(time)