Hi Raj,<div><br></div><div>Python trace provide mostly a state of your action which already give you some hints on the properties involved and the values that you need.</div><div>Although, I agree that it doesn't do the whole work for you, but it's definitely a good start. If you are really expecting to have an API for the proxies you can give a look at the following pages that list all the filters available with their properties. But once again, you should write your code in an interactive manner inside the JavaScript console in order to validate each peace of it.</div>
<div><br></div><div><a href="http://www.paraview.org/Wiki/ParaView/Users_Guide/Sources">http://www.paraview.org/Wiki/ParaView/Users_Guide/Sources</a></div><div><a href="http://www.paraview.org/Wiki/ParaView/Users_Guide/List_of_filters">http://www.paraview.org/Wiki/ParaView/Users_Guide/List_of_filters</a></div>
<div><br></div><div>After that I agree that developing your own application on top of ParaView do require some skills on the ParaView framework itself.</div><div><br></div><div>Regarding the PlaceWidget() question, this is based on VTK (as ParaView rely on VTK). It allow the widget to stick to a given location based on bounds that are used to draw the bounding box with the plane inside it.</div>
<div><br></div><div>Seb</div><div><br></div><div>PS: I've paste a simple code that do what you want I believe.</div><div><br></div><div><div><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "<a href="http://www.w3.org/TR/html4/loose.dtd">http://www.w3.org/TR/html4/loose.dtd</a>"></div>
<div><html></div><div> <head></div><div> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></div><div><br></div><div> <script src="/PWService/js/ParaViewWeb.js" type="text/javascript"></script></div>
<div><br></div><div> <title>Load state and show all views</title></div><div> </head></div><div> <body onUnload="pv.disconnect();"></div><div> <div id="page"></div>
<div> </div></div><div><br></div><div> <script type="text/javascript"></div><div> // Set the web service base URL</div><div> var serverUrl = "/PWService";</div>
<div><br></div><div> // Create a paraview proxy</div><div> var pv = new Paraview(serverUrl);</div><div> pv.createSession("PropertyBind-widget", "testing-webapp");</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span> log = pv.getPlugin("log");</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span> // Create pipeline</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span> var wavelet = pv.Wavelet();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> var dataInfo = pv.GetDataInformation({proxy:wavelet});</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span> var view1 = pv.CreateIfNeededRenderView();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> pv.Render();</div><div><br></div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span> var sliceFilter = pv.Slice({Input : wavelet});</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> var plan = sliceFilter.getSliceType();</div>
<div> plan.setNormal(0,0,1);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> plan.setOrigin(0,0,0);</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span> var sr = pv.CreateBindedWidget({proxy : plan, view : view1});</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span> sr.setPlaceWidget(dataInfo.Bounds);</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span> sr.setEnabled(1);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span> sr.setVisibility(1);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> </div><div><span class="Apple-tab-span" style="white-space:pre">        </span> var dataRep1 = pv.Show({proxy : sliceFilter});</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span> </div><div><span class="Apple-tab-span" style="white-space:pre">        </span> // ---- For JavaScript ----</div><div> var rendererJs1 = new JavaScriptRenderer("jsRenderer-1", serverUrl);</div>
<div> rendererJs1.init(pv.sessionId, view1.__selfid__);</div><div> rendererJs1.setSize('500','500');</div><div> rendererJs1.bindToElementId("page");</div><div> rendererJs1.start();</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span> pv.ResetCamera();</div><div><br></div><div><br></div><div> </script></div><div> </body></div><div></html></div>
</div><div><br></div><div><br><br><div class="gmail_quote">On Mon, May 2, 2011 at 6:16 PM, Rajvikram Singh <span dir="ltr"><<a href="mailto:rajvikrams@yahoo.com">rajvikrams@yahoo.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td valign="top" style="font:inherit"><div><table style="width:526px;min-height:2834px" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-size-adjust:inherit;font-stretch:inherit;font-family:arial;font-size:10pt">
<br>Hi Sebastien<br> Thanks once again for the prompt response. I realize I should not make assumptions about properties but the whole Javascript model makes it difficult to debug. This is my first Javascript experience and I'm guessing that is my biggest problem :)<br>
<br>Also there is an inherent problem with the Python trace in Paraview. In theory it sounds wonderful but when I use it from the UI, it seems to miss some important information which makes it feel
like it cannot be trusted. As a simple example, if I create a cone source and apply the slice filter to it and click the "Show Widget" check box on and off, the python trace I get is as follows : <br> <br>
<p style="margin:0px 0px 0px 40px;text-indent:0px;font-style:italic;color:rgb(0, 0, 255)">try: paraview.simple</p>
<p style="margin:0px 0px 0px 40px;text-indent:0px;font-style:italic;color:rgb(0, 0, 255)">except: from paraview.simple import *</p>
<p style="margin:0px 0px 0px 40px;text-indent:0px;font-style:italic;color:rgb(0, 0, 255)">paraview.simple._DisableFirstRenderCameraReset()</p>
<p style="margin:0px 0px 0px 40px;text-indent:0px;font-style:italic;color:rgb(0, 0, 255)"></p>
<p style="margin:0px 0px 0px 40px;text-indent:0px;font-style:italic;color:rgb(0, 0, 255)">Cone2 = Cone()</p>
<p style="margin:0px 0px 0px 40px;text-indent:0px;font-style:italic;color:rgb(0, 0, 255)"></p>
<p style="margin:0px 0px 0px 40px;text-indent:0px;font-style:italic;color:rgb(0, 0, 255)">RenderView1 = GetRenderView()</p>
<p style="margin:0px 0px 0px 40px;text-indent:0px;font-style:italic;color:rgb(0, 0, 255)">DataRepresentation5 = Show()</p>
<p style="margin:0px 0px 0px 40px;text-indent:0px;font-style:italic;color:rgb(0, 0, 255)">DataRepresentation5.EdgeColor = [0.0, 0.0, 0.50000762951094835]</p>
<p style="margin:0px 0px 0px 40px;text-indent:0px;font-style:italic;color:rgb(0, 0, 255)"></p>
<p style="margin:0px 0px 0px 40px;text-indent:0px;font-style:italic;color:rgb(0, 0, 255)">Slice3 = Slice( SliceType="Plane" )</p>
<p style="margin:0px 0px 0px 40px;text-indent:0px;font-style:italic;color:rgb(0, 0, 255)"></p>
<p style="margin:0px 0px 0px 40px;text-indent:0px;font-style:italic;color:rgb(0, 0, 255)">RenderView1.CameraPosition = [-<a href="tel:0.8662633794" value="+18662633794" target="_blank">0.8662633794</a>3852127, -2.9008214092444833, 1.047837071997098]</p>
<p style="margin:0px 0px 0px 40px;text-indent:0px;font-style:italic;color:rgb(0, 0, 255)">RenderView1.CameraClippingRange = <a href="tel:%5B1.7197276063" value="+17197276063" target="_blank">[1.7197276063</a>743807, 5.0792474812948285]</p>
<p style="margin:0px 0px 0px 40px;text-indent:0px;font-style:italic;color:rgb(0, 0, 255)"></p>
<p style="margin:0px 0px 0px 40px;text-indent:0px;font-style:italic;color:rgb(0, 0, 255)">Slice3.SliceOffsetValues = [0.0]</p>
<p style="margin:0px 0px 0px 40px;text-indent:0px;font-style:italic;color:rgb(0, 0, 255)">Slice3.SliceType = "Plane"</p>
<p style="margin:0px 0px 0px 40px;text-indent:0px;font-style:italic;color:rgb(0, 0, 255)"></p>
<p style="margin:0px 0px 0px 40px;text-indent:0px;font-style:italic;color:rgb(0, 0, 255)">DataRepresentation6 = Show()</p>
<p style="margin:0px 0px 0px 40px;text-indent:0px;font-style:italic;color:rgb(0, 0, 255)">DataRepresentation6.EdgeColor = [0.0, 0.0, 0.50000762951094835]</p>
<p style="margin:0px 0px 0px 40px;text-indent:0px;font-style:italic;color:rgb(0, 0, 255)"></p>
<p style="margin:0px 0px 0px 40px;text-indent:0px;font-style:italic;color:rgb(0, 0, 255)">RenderView1.CameraViewUp = [-0.05160914336948845, <a href="tel:0.3512370908" value="+13512370908" target="_blank">0.3512370908</a>5212862, 0.93486309282718028]</p>
<p style="margin:0px 0px 0px 40px;text-indent:0px;font-style:italic;color:rgb(0, 0, 255)">RenderView1.CameraPosition = [0.96899222199550616, -2.8404682287153862, 1.1206845835066597]</p>
<p style="margin:0px 0px 0px 40px;text-indent:0px;font-style:italic;color:rgb(0, 0, 255)">RenderView1.CameraClippingRange = [1.3773762963261489, 5.5101972459535187]</p>
<p style="margin:0px 0px 0px 40px;text-indent:0px;font-style:italic;color:rgb(0, 0, 255)"></p>
<p style="margin:0px 0px 0px 40px;text-indent:0px;font-style:italic;color:rgb(0, 0, 255)">DataRepresentation5.Visibility = 0</p>
<p style="margin:0px 0px 0px 40px;text-indent:0px;font-style:italic;color:rgb(0, 0, 255)"></p>
<p style="margin:0px 0px 0px 40px;text-indent:0px;font-style:italic;color:rgb(0, 0, 255)">RenderView1.CameraClippingRange = <a href="tel:%5B1.3258836594" value="+13258836594" target="_blank">[1.3258836594</a>339682, 5.702986199114493]</p>
<p style="margin:0px 0px 0px 40px;text-indent:0px;font-style:italic;color:rgb(0, 0, 255)"></p>
<p style="margin:0px 0px 0px 40px;text-indent:0px;font-style:italic;color:rgb(0, 0, 255)">Slice3.SliceType.Origin = [-0.36490894792831258, 0.0, 0.0]</p>
<p style="margin:0px 0px 0px 40px;text-indent:0px;font-style:italic;color:rgb(0, 0, 255)"></p>
<p style="margin:0px 0px 0px 40px;text-indent:0px;font-style:italic;color:rgb(0, 0, 255)">Render()</p>
<p style="margin:0px;text-indent:0px"></p><br>Notice there is no record of the 'Show Widget' or 'Hide Widget' property being set.<br><br>Also translating this to Javascript shows a slice of a cone .. but there is no interaction plane to adjust the slicing .. like in Paraview. I guess this is where we are supposed to look at the source code to figure out what's missing .. which takes a lot of trial and error without documentation. I some cases I can't tell what the property is supposed to actually do.<br>
<br>I've been looking at the ParaviewWeb.js file for a while and it provides useful hints but no definite answers. For e.g I noticed from the file that I need to set the PlaceWidget property for the slice filter but I don't really know what it's supposed to do. When I set it, on one of my data sets I saw the interactive widget .. and then on another it disappeared. Very confusing.<br>
<br>Raj<br><br><br>--- On <b>Tue, 3/5/11, Sebastien Jourdain
<i><<a href="mailto:sebastien.jourdain@kitware.com" target="_blank">sebastien.jourdain@kitware.com</a>></i></b> wrote:<br><blockquote style="border-left:2px solid rgb(16, 16, 255);margin-left:5px;padding-left:5px">
<br>From: Sebastien Jourdain <<a href="mailto:sebastien.jourdain@kitware.com" target="_blank">sebastien.jourdain@kitware.com</a>><br>Subject: Re: [Paraview] ParaviewWeb : Adding interactive slice filter to pipeline<br>
To: "Rajvikram Singh" <<a href="mailto:rajvikrams@yahoo.com" target="_blank">rajvikrams@yahoo.com</a>><br>Cc: <a href="mailto:paraview@paraview.org" target="_blank">paraview@paraview.org</a><br>Date: Tuesday, 3 May, 2011, 1:29 AM<div>
<div></div><div class="h5"><br><br><div>Hi Raj,<div><br></div><div>Another thing. You should do that to set origin and normal.</div><div><br></div><div>var plan = sliceFilter.getSliceType();</div><div>plan.setOrigin(0,0,0);</div>
<div>plan.setNormal(1,0,0);</div>
<div><br></div><div>in fact the methods SetSliceOrigin/Normal are helper methods on python objects and not properties. You can notice it because of the capital S in the set. This must come from the python trace. If it was a property in python it would have been written:</div>
<div><br></div><div>sliceFilter.SliceNormal = [1,0,0];</div><div><br></div><div>Hope this help you to understand how it is working underneath and how to easily convert Python generated code into similar JavaScript one.</div>
<div><br></div><div>Seb<br><div><br><div>On Mon, May 2, 2011 at 8:59 AM, Sebastien Jourdain <span dir="ltr"><<a rel="nofollow">sebastien.jourdain@kitware.com</a>></span> wrote:<br>
<blockquote style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">Hi Raj,<div><br></div><div>You are not getting the propers bounds when you directly access them like that:</div><div>
<br>
</div><div><span style="font-size:medium;font-style:italic">> reader.Bounds</span><br>
<br></div><div>In fact, if you validate each line that you wrote inside the JavaScript console of your browser, you could have seen that Bounds was not part of the reader proxy. Moreover, it goes against the idea that Proxy do not have methods/fields but only properties that can be set/get based on their name. So eventually, it could have been reader.getBounds(). Although, bounds is not a property of the reader.</div>
<div>In order to get the right informations, you do need to do call a method on ParaView:</div><div><br></div><div>> var dataInfo = pv.GetDataInformation({proxy:reader});</div><div><br></div><div>The returned value is not a proxy, it's just a data structure with all the data informations of the given proxy. (Fields name, Time, scalar range, bounds, memory consumption on the server...)</div>
<div><br></div><div>Then you can do :</div><div>> sr.setPlaceWidget(dataInfo.Bounds);</div><div><br></div><div>I do believe that you look at the file ParaWebFunctions.js inside the PWApp to get that close. If not, it could provide you some help on how to handle some common actions.</div>
<div><br></div><div>Thanks,</div><div><br></div><div>Seb</div><div><br><div><div><div></div><div>On Fri, Apr 29, 2011 at 7:25 PM, Rajvikram Singh <span dir="ltr"><<a rel="nofollow">rajvikrams@yahoo.com</a>></span> wrote:<br>
</div></div><blockquote style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex"><div><div></div><div><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font:inherit" valign="top">
Hi<br> I am trying to add a simple slice filter to a ParaviewWeb client that users could use interact with a volume. The bundled PWApp application does this already and so I tried to go through the code and looked at some Python examples. I was able to get an interactive widget to render but it shows a blank slice. Also the bounds are not correct since the volume is 'flat' and what I see is a cube. <br>
<br>Here's the code I'm using :<br><br><div style="margin-left:40px;font-style:italic">var reader = pv.OpenDataFile({filename : "test.vtk"}); <br> var view1 = pv.CreateIfNeededRenderView();<br> pv.Render();<br>
<br> var sliceFilter = pv.Slice({Input : reader});<br> sliceFilter.SetSliceNormal = [0,0,1]; // sliec along Z<br>
sliceFilter.SetSliceOrigin = [0,0,0];<br> sliceFilter.SetSliceType = 'Plane';<br>// sliceFilter.SetInputBounds = pv.GetDataInformation.Bounds;<br><br> var sr = pv.CreateBindedWidget({proxy : sliceFilter.getSliceType(), view : view1});<br>
sr.setPlaceWidget(reader.Bounds);<br> sr.setEnabled(1);<br> sr.setVisibility(1);<br><br> var dataRep1 = pv.Show({proxy : sliceFilter});<br> <br><br> pv.SetDisplayProperties( {<br> proxy : sliceFilter,<br>
view : view1,<br> Representation : 'Surface',<br> } );<br><br></div>I'm attaching a screenshot of what's rendered in my browser. I'm obviously not setting some property correctly .. I just can't tell which one.<br>
<br>Thanks in advance<br>Raj<br><div style="font-style:italic"><br></div></td></tr></tbody></table><br></div></div>_______________________________________________<br>
Powered by <a rel="nofollow" href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a rel="nofollow" href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the ParaView Wiki at: <a rel="nofollow" href="http://paraview.org/Wiki/ParaView" target="_blank">http://paraview.org/Wiki/ParaView</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a rel="nofollow" href="http://www.paraview.org/mailman/listinfo/paraview" target="_blank">http://www.paraview.org/mailman/listinfo/paraview</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div></div>
</div></div></div></blockquote></td></tr></tbody></table></div></td></tr></tbody></table></blockquote></div><br></div>