def add_paraview_module(name, proxy, module_type, ns, hide=False, pvFunction=None): mod = new_module(module_type, name) mod.pvSpace = ns.lower() mod.pvClass = name if pvFunction != None: mod.pvFunction = pvFunction if name == 'ProgrammableFilter': add_module(mod, name=name, namespace=ns, configureWidgetType=ProgrammableFilterConfigurationWidget) else: add_module(mod, name=name, namespace=ns) for prop in proxy.ListProperties(): optional = False if hide and prop != "Input": optional = True p = proxy.GetProperty(prop) if isinstance(p, sm.ProxyProperty): add_input_port(mod, prop, PVBase.PVModule, optional) continue if isinstance(p, sm.EnumerationProperty): add_input_port(mod, prop, core.modules.basic_modules.String, optional) continue if isinstance(p, sm.VectorProperty): params = [] typ = None if p.IsA("vtkSMDoubleVectorProperty"): typ = core.modules.basic_modules.Float elif p.IsA("vtkSMIntVectorProperty"): typ = core.modules.basic_modules.Integer elif p.IsA("vtkSMStringVectorProperty"): typ = core.modules.basic_modules.String elif p.IsA("vtkSMIdTypeVectorProperty"): typ = core.modules.basic_modules.Integer nel = len(p) if nel > 0: for i in range(nel): params.append(typ) else: params.append(typ) add_input_port(mod, prop, params, optional) add_output_port(mod, "Output", module_type)
def add_paraview_module(name, proxy, module_type, ns, hide=False, pvFunction=None): mod = new_module(module_type, name) mod.pvSpace = ns.lower() mod.pvClass = name if pvFunction != None: mod.pvFunction = pvFunction if name=='ProgrammableFilter': add_module(mod, name = name, namespace=ns, configureWidgetType=ProgrammableFilterConfigurationWidget) else: add_module(mod, name = name, namespace=ns) for prop in proxy.ListProperties(): optional = False if hide and prop != "Input": optional = True p = proxy.GetProperty(prop) if isinstance(p, sm.ProxyProperty): add_input_port(mod, prop, PVBase.PVModule, optional) continue if isinstance(p, sm.EnumerationProperty): add_input_port(mod, prop, core.modules.basic_modules.String, optional) continue if isinstance(p, sm.VectorProperty): params = [] typ = None if p.IsA("vtkSMDoubleVectorProperty"): typ = core.modules.basic_modules.Float elif p.IsA("vtkSMIntVectorProperty"): typ = core.modules.basic_modules.Integer elif p.IsA("vtkSMStringVectorProperty"): typ = core.modules.basic_modules.String elif p.IsA("vtkSMIdTypeVectorProperty"): typ = core.modules.basic_modules.Integer nel = len(p) if nel > 0: for i in range(nel): params.append(typ) else: params.append(typ) add_input_port(mod, prop, params, optional) add_output_port(mod, "Output", module_type)
def initialize(*args, **keywords): reg = core.modules.module_registry basic = core.modules.basic_modules add_module(PVBase.PVModule, namespace='base') mod_dict = {} mlist = [("Sources", sm.sources), ("Filters", sm.filters), ("Animation", sm.animation), ("Writers", sm.writers)] for ns, m in mlist: dt = m.__dict__ for key in dt.keys(): if forbidden.__contains__(key): continue if key.__contains__('Base'): continue cl = dt[key] if not isinstance(cl, str): if paraview.simple._func_name_valid(key): add_paraview_module(key, m.__dict__[key](no_update=True), PVBase.PVModule, ns) add_paraview_module("GeometryRepresentation", sm.rendering.GeometryRepresentation(no_update=True), PVBase.PVModule, "Rendering", True, sm.rendering.GeometryRepresentation) add_paraview_module("PVLookupTable", sm.rendering.PVLookupTable(no_update=True), PVBase.PVModule, "Rendering", False, sm.rendering.PVLookupTable) add_paraview_module( "ScalarBarWidgetRepresentation", sm.rendering.ScalarBarWidgetRepresentation(no_update=True), PVBase.PVModule, "Rendering", True, sm.rendering.ScalarBarWidgetRepresentation) add_module(PVServerPythonSource, name="PVServerPythonSource", configureWidgetType=PVServerPythonSourceConfigurationWidget) add_input_port(PVServerPythonSource, "Script", (core.modules.basic_modules.String, ""), True) add_output_port(PVServerPythonSource, "self", PVServerPythonSource) add_module(PVClientFetch, name="PVClientFetch", configureWidgetType=PythonSourceConfigurationWidget) add_input_port(PVClientFetch, "ServerModule", (PVServerPythonSource, "")) add_input_port(PVClientFetch, "source", (core.modules.basic_modules.String, "")) import pvcell pvcell.registerSelf() global pvConfigWindow pvConfigWindow = QPVConfigWindow(proc_num=configuration.num_proc, port=configuration.port) #pvConfigWindow.show() if configuration.start_server == True: pvConfigWindow.togglePVServer()
def initialize(*args, **keywords): reg = core.modules.module_registry basic = core.modules.basic_modules add_module(PVBase.PVModule, namespace='base') mod_dict = {} mlist = [("Sources", sm.sources), ("Filters", sm.filters), ("Animation", sm.animation), ("Writers", sm.writers)] for ns, m in mlist: dt = m.__dict__ for key in dt.keys(): if forbidden.__contains__(key): continue if key.__contains__('Base'): continue cl = dt[key] if not isinstance(cl, str): if paraview.simple._func_name_valid(key): add_paraview_module(key, m.__dict__[key](no_update=True), PVBase.PVModule, ns) add_paraview_module("GeometryRepresentation", sm.rendering.GeometryRepresentation(no_update=True), PVBase.PVModule, "Rendering", True, sm.rendering.GeometryRepresentation) add_paraview_module("PVLookupTable", sm.rendering.PVLookupTable(no_update=True), PVBase.PVModule, "Rendering", False, sm.rendering.PVLookupTable) add_paraview_module("ScalarBarWidgetRepresentation", sm.rendering.ScalarBarWidgetRepresentation(no_update=True), PVBase.PVModule, "Rendering", True, sm.rendering.ScalarBarWidgetRepresentation) add_module(PVServerPythonSource, name = "PVServerPythonSource", configureWidgetType=PVServerPythonSourceConfigurationWidget) add_input_port(PVServerPythonSource, "Script", (core.modules.basic_modules.String, ""), True) add_output_port(PVServerPythonSource, "self", PVServerPythonSource) add_module(PVClientFetch, name = "PVClientFetch", configureWidgetType=PythonSourceConfigurationWidget) add_input_port(PVClientFetch, "ServerModule", (PVServerPythonSource, "")) add_input_port(PVClientFetch, "source", (core.modules.basic_modules.String, "")) import pvcell pvcell.registerSelf() global pvConfigWindow pvConfigWindow = QPVConfigWindow(proc_num=configuration.num_proc, port=configuration.port) #pvConfigWindow.show() if configuration.start_server == True: pvConfigWindow.togglePVServer()