[Paraview] Utilisation of plugin ParaView in ParaViewWeb

Alex tuanha_it0306 at yahoo.com
Mon Jun 18 11:26:24 EDT 2012


Seb,
   I'm sorry, I don't really good in English so .....
   Well, about your question: 
severmanager.ActiveConnection.Modules.filters.SimpleImageThreshold() is recognized in Python Shell.

   
    So, what do we have to write in SimpleImageThreshod.py?

   def SimpleImageThreshold(proxy)
    ?????.SimpleImageThreshold(proxy)

   What is your advice in replace these ????
   
   Thank you very much, Seb.


________________________________
 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 4:51 PM
Subject: Re: [Paraview] Utilisation of plugin ParaView in ParaViewWeb
 
Hi Alex,

sorry to say that but you did not properly read what I wrote...

I've ask you if the following line worked in ParaView python:

severmanager.ActiveConnection.Modules.filters.SimpleImageThreshold()

Anyway, to solve the issue related to the number of arguments, you
should be able to do that:

var reader2 = ST.SimpleImageThreshold( [reader] );

And all that is assuming your initial issue where your proxy defined
inside your plugin is finally properly found. Which I still don't know
if it is the case or not.

Seb


On Mon, Jun 18, 2012 at 10:33 AM, Alex <tuanha_it0306 at yahoo.com> wrote:
> 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/b7ffcfb9/attachment-0001.htm>


More information about the ParaView mailing list