ParaViewWeb misc JavaScript script
From KitwarePublic
PWService testing
On the web page http://localhost:8080/PWService/test/index.jsp execute the following script
var serverURL = 'http://localhost:8080/PWService'; var paraview = new Paraview(serverURL); paraview.createSession('testing','basic-test'); var activeView = paraview.CreateIfNeededRenderView(); paraview.Sphere(); paraview.Show(); var renderers = {}; renderers.js = new JavaScriptRenderer("js", serverUrl); renderers.js.init(paraview.sessionId, activeView.__selfid__); renderers.js.setSize('200','200'); renderers.js.bindToElementId("container-1"); renderers.js.start(); renderers.java = new HttpAppletRenderer("java", serverUrl); renderers.java.init(paraview.sessionId, activeView.__selfid__); renderers.java.setSize('200','200'); renderers.java.bindToElementId("container-2"); renderers.java.start(); renderers.flash = new FlashRenderer("flash", serverUrl); renderers.flash.init(paraview.sessionId, activeView.__selfid__); renderers.flash.setSize('200','200'); renderers.flash.bindToElementId("container-3"); renderers.flash.start();
PWApp using manta renderering
For wireframe representation use solid color and rise the line width
paraview.GetDisplayProperties({proxy: pipeline.dataset}).setLineWidth(200) paraview.GetDisplayProperties({proxy: pipeline.iso}).setLineWidth(200) paraview.GetDisplayProperties({proxy: pipeline.slice}).setLineWidth(200) paraview.GetDisplayProperties({proxy: pipeline.clip}).setLineWidth(200) paraview.GetDisplayProperties({proxy: pipeline.stream}).setLineWidth(200)
Python scripting for handeling selection
from paraview.simple import * from paraview import vtk def Select(region=[0, 0, 100, 100]): view = GetActiveView() representations = vtk.vtkCollection() selection_sources = vtk.vtkCollection() if not view.SelectSurfaceCells(region, representations, selection_sources): return (None, None)
# this is the representation that got selected. If we are showing labels, we # should toggle the labels on this proxy selected_representation = \ servermanager._getPyProxy(representations.GetItemAsObject(0)) # this is a source that tells us what cell ids/point ids got selected. ie. a # source that produces a "selection" selection_source = \ servermanager._getPyProxy(selection_sources.GetItemAsObject(0))
return (selected_representation, selection_source) Sphere() Show() Render() sel_repr , sel_source = Select([0, 0, 200,200]) if sel_repr and sel_source: sel_repr.Input.SetSelectionInput(0, sel_source.SMProxy, 0) Render() raw_input()