[Paraview] Utilisation of plugin ParaView in ParaViewWeb

Alex tuanha_it0306 at yahoo.com
Mon Jun 18 05:34:25 EDT 2012


Hi, thank you very much for your reply. I'm sorry to reply so late, I was in my Holiday last week.
In deed, I use your advice and I succeeded in writing those .py file. However, there is a problem:

My SimleImageThreshold.py
from paraview.simple import *
import os
import threading

def loadSimpleThreshold():
   # Load Simple Image Threshold plugins
   LoadPlugin('.../vtkSimpleImageThreshold/bin/libSimpleImageThresholdSMPlugin.so',False)# client
   LoadPlugin('.../vtkSimpleImageThreshold/bin/libSimpleImageThresholdSMPlugin.so',True) # server

def SimpleImageThreshold():
   servermanager.ActiveConnection.Modules.filters.SimpleImageThreshold() 

and, I used the JavaSript in PWConsole:

paraview.loadPlugins();
ST = paraview.plugins.SimpleImageThreshold;
ST.loadSimpleThreshold();
ST.SimpleImageThreshold();

When I saw the log file in PWService/admin, I had:
Traceback (most recent call last): File "<jsonrpc>", line 146, in handle_request File ".../workdir/plugins/SimpleImageThreshold.py", line 11, in SimpleImageThreshold servermanager.ActiveConnection.Modules.filters.SimpleImageThreshold()
AttributeError: 'PVModule' object has no attribute 'SimpleImageThreshold'
So may be there is a problem with my XML Server Manager file? I doubt because I use SimpleImageThreshold() without any problem in Python Shell.

And, one more question. How can we define SimpleImageThreshold() in .py file so that they can act like a real filter? Take in an image, do his work, and we have an image thresholded as ouput?
Reason : when I called reader2 = ST.SimpleImageThreshold({proxy}); log file : 
Traceback (most recent call last): File "<jsonrpc>", line 144, in handle_request
TypeError: SimpleImageThreshold() takes no arguments (1 given)
You are my savers !!! Thanks a lot.

Alex



________________________________
 From: Sebastien Jourdain <sebastien.jourdain at kitware.com>
To: Alex <tuanha_it0306 at yahoo.com> 
Cc: "paraview at paraview.org" <paraview at paraview.org> 
Sent: Thursday, June 14, 2012 3:53 PM
Subject: Re: [Paraview] Utilisation of plugin ParaView in ParaViewWeb
 
Hi Alex,

there is two ways to achieve your goal.

Solution 1:
Inside the pw-config.properties file, instead of calling the PWServer
executable right away, you can call a shell script which will call
PWServer underneath with some extra arguments such as an
initialization python script (--batch-file=/.../loadPlugins.py).
Basically that script will load your plugin.
Once that's achieved, normally when the JavaScript ask for the
ParaView available methods, you should see your plugin. And have
access to everything on the JavaScript side. (You can read that part
in the wiki here:
http://www.paraview.org/Wiki/ParaViewWeb_Manta_setting)

Solution 2:
Create a ParaViewWeb plugin, that will load the plugin and provide a
method to create an instance of your plugin filter. (like in
http://www.paraview.org/Wiki/ParaViewWeb_Plugins). Maybe the
definition of your plugin won't properly be updated in the simple
context. Therefore, you might need to use the full filter path to
create it by calling
"severmanager.ActiveConnection.Modules.filters.MyFilter()" instead of
just "simple.MyFilter()".

Seb

On Thu, Jun 14, 2012 at 3:32 AM, Alex <tuanha_it0306 at yahoo.com> wrote:
> Hi everybody,
>     I'm really new in ParaView. I have a question about utilisation of
> ParaView's plugin in ParaViewWeb:
> - My plugin has been imported to ParaView and work with ParaView. I did a
> simple image threshold filter (1 input and 1 output,derived de
> SimpleToSimpleImageFilter) and it works as I imagined in ParaView, I
> succeeded in calling it in Python Shell as well (all the steps are
> respected, including .xml, CMakeLists, etc.)
> - Now I want to use it in ParaView. I found in "simple.py" a command
> LoadPlugin, and I use this without any problem (no error in Chrome's error
> console, nothing abnormal in log at PWService/admin). But I don't have the
> right syntax to call this plugin.
>
> => So all I want to know is how to call my filter. name MyImageThreshod. Do
> you have any idea?
> Thank you very much indeed.
>
> PS: I tried
> paraview.LoadPlugin('path/to/myPlugin.so',false);
> paraview.MyImageThreshold() => ParaView has no methode named
> MyImageThreshold
> paraview.plugins.MyImageThreshold => always the same error.
>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ParaView Wiki at:
> http://paraview.org/Wiki/ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://www.paraview.org/mailman/listinfo/paraview
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20120618/7f7b7320/attachment.htm>


More information about the ParaView mailing list