ParaViewWeb Plugins: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
(Created page with 'ParaViewWeb ---- == On the server side == The user can add plugin on the server side in order to ease the work of the web developer. To do that, you can add any number of p…')
 
Line 58: Line 58:
== On the client side ==
== On the client side ==


   var paraview = new Paraview("name", "comment");
   var paraview = new Paraview(serverUrl);
  paraview.createSession("name", "comment");
   paraview.loadPlugins();
   paraview.loadPlugins();
   calc = paraview.plugins.calc;
   calc = paraview.plugins.calc;

Revision as of 12:57, 3 February 2011

ParaViewWeb


On the server side

The user can add plugin on the server side in order to ease the work of the web developer. To do that, you can add any number of python file in the plugin directory that you set in your pw-config.properties file with the pw.plugins.default or pw.plugins.???? property.

The following scripts provides some sample code for plugins:

MantaLoader.py

 import pwsimple
 import os
 import threading
 
 buildDir = 'ParaView-build/bin'
 
 class StartServerThread ( threading.Thread ):
   def run( self ):
     os.system(buildDir + '/pvserver')
 
 def startServer():
   Start pvserver
   StartServerThread().start();
 
 def connectToServer():
   Connect to pvserver
   pwsimple.Connect("localhost")
 
 def loadManta():
   Load manta plugins
   pwsimple.LoadPlugin(buildDir+"/libMantaView.so", False)# client
   pwsimple.LoadPlugin(buildDir+"/libMantaView.so", True) # server
 
 def createMantaView():
   Configure the manta view
   view = pwsimple._create_view("MantaIceTDesktopRenderView")
   view.Threads = 8
   view.ViewSize = [1024,1024]
   return view

Calc.py

 def add(a,b):
   return a+b
 
 def minus(a,b):
   return a-b
 
 def mul(a,b):
   return a*b
 
 def div(a,b):
   return a/b


On the client side

 var paraview = new Paraview(serverUrl);
 paraview.createSession("name", "comment");
 paraview.loadPlugins();
 calc = paraview.plugins.calc;
 calc.add(5,2);
 mantaLoader = paraview.plugins.MantaLoader;
 view = mantaLoader.createMantaView();