[Paraview] Utilisation of plugin ParaView in ParaViewWeb

Alex tuanha_it0306 at yahoo.com
Mon Jun 18 10:33:55 EDT 2012


Thank you Seb,
For your first question : Yes, I succeeded in using my SimpleImageThreshold in Python Shell.
Here is my script in Python Shell:

reader = OpenDataFile('/path/to/my/file.mhd');
GetDisplayProperties();
ColorAttributeType ='POINT_DATA';
SetDisplayProperties(Representation='Volume',ColorArrayName='MetaImage');
Render();

reader2=SimpleImageThreshold(reader);
SetDisplayProperties(Representation='Volume',ColorArrayName='ImageScalars');
Render();

For the second part :
I have the following errors when I tried in different ways:
var reader = paraview.OpenDataFile('path/to/my/file.mhd');
ST = paraview.plugins.SimpleImageThreshold;

ST.SimpleImageThreshold(proxy) : 
error : proxy not defined

ST.SimpleImageThreshold(reader)
error:Traceback (most recent call last): File "<jsonrpc>", line 146, in handle_request
TypeError: SimpleImageThreshold() takes exactly 1 argument (3 given)
ST.SimpleImageThreshold({proxy:reader});
Error: Traceback (most recent call last): File "<jsonrpc>", line 144, in handle_request File "/home/thtran/PV/workdir/plugins/SimpleImageThreshold.py", line 11, in SimpleImageThreshold servermanager.ActiveConnection.Modules.filters.SimpleImageThreshold(proxy)
AttributeError: 'PVModule' object has no attribute 'SimpleImageThreshold'when I use : 
var reader2 = ST.SimpleImageThreshold(proxy);
var reader2 = ST.SimpleImageThreshold(reader);
var reader2 = ST.SimpleImageThreshold({proxy:reader});

Same errors as above.
I think that I have to be more precise in SimpleImageThreshold.py but I don't have any clue.
Thank you very much Seb


I followed your advice. Here is my SimpleImageThreshold.py to be sure :

from paraview.simple import *
import os
import threading

def SimpleImageThreshold(proxy):
   servermanager.ActiveConnection.Modules.filters.SimpleImageThreshold(proxy)
   
def createSimpleThresholdView():
   global dp
   dp = GetDisplayProperties()
   dp.LookupTable = MakeBlueToRedLT(37.35,276)
   dp.ColorAttributeType = 'POINT_DATA'




________________________________
 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: Monday, June 18, 2012 1:46 PM
Subject: Re: [Paraview] Utilisation of plugin ParaView in ParaViewWeb
 
Hi Alex,

First of all, you should be able to remove those lines, they are not
needed in your case.

> import os
> import threading
>
>  LoadPlugin('.../vtkSimpleImageThreshold/bin/libSimpleImageThresholdSMPlugin.so',True)
> # server

Then my question will be: Did you managed inside the Python shell of
ParaView to call manually the load plugin and to instantiate your
filter the way you are doing it in ParaViewWeb ?

> 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)

to solve that issue you need to change your python plugin so the
method will look like that:

def SimpleImageThreshold(proxy):
    ....SimpleImageThreshold(proxy)

and in JavaScript that will be

ST.SimpleImageThreshold(proxy);

note that I've removed the {}.

Seb
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20120618/6e081d3f/attachment-0001.htm>


More information about the ParaView mailing list