<div>Hi Seb, </div><div><br></div>The first option will not scale. We will<div>have a growing number of tissue samples </div><div>to be visualized and this option will be </div><div>infeasible soon. </div><div><br></div><div>
I am already re-initializing the renderer </div><div>with the new activeview. The minimal </div><div>example illustrating the issue is here</div><div><br></div><div><div>var renderers = {};</div><div>var paraview;</div><div>
var activeView;</div><div>var basePath = 'data/';</div><div>var dataFile = 'sphere.pvsm';</div><div><br></div><div>paraview = new Paraview(serverUrl);</div><div>paraview.createSession("Shuttle", "", "default");</div>
<div> </div><div>function start(){</div><div> paraview.LoadState({filename: basePath + dataFile});</div><div> activeView = paraview.CreateIfNeededRenderView();</div><div> paraview.ResetCamera();</div><div>
activeView.setCenterOfRotation(activeView.getCameraFocalPoint());</div><div><br></div><div> paraview.updateConfiguration(true, "JPEG", "WebGL");</div><div> renderers.webgl = new WebGLRenderer("webglRenderer", serverUrl);</div>
<div> renderers.webgl.init(paraview.sessionId, activeView.__selfid__);</div><div><br></div><div> // Use webgl as default</div><div> renderers.current = renderers.webgl;</div><div> renderers.current.bindToElementId("renderercontainer");</div>
<div> renderers.current.start();</div><div><br></div><div> // Update render size</div><div> updateSize();</div><div>}</div><div>...</div><div>function switchData(){</div><div> dataFile = 'cone.pvsm';</div><div>
start();</div><div>}</div><div><br></div><div>This script successfully loads the sphere but </div><div>does not switch to cone. If I move the </div></div><div><div>paraview.createSession("Shuttle", "", "default");</div>
</div><div>in to start function, things start working as expected:</div><div>Sphere is visualized first, and cone is loaded and</div><div>visualized when the button is clicked at the cost of </div><div>an unnecessary session. I am trying to do things </div>
<div>cleanly, and do not want to have dangling sessions </div><div>for no reason. </div><div><br></div><div>Thank you for your help, </div><div>Cagatay</div><div><br><div class="gmail_quote">On Thu, May 3, 2012 at 3:15 PM, Sebastien Jourdain <span dir="ltr"><<a href="mailto:sebastien.jourdain@kitware.com" target="_blank">sebastien.jourdain@kitware.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Well there is several way to deal with what you want to achieve.<br>
<br>
1) if all the data that you are interested are kind of small then you<br>
can all load them and just call "paraview.Show({proxy: objA})" or<br>
"paraview.Hide({proxy: objA})"<br>
<br>
To get the proper references of objA, objB, ..., from the state file,<br>
you can query ParaView for that like that:<br>
<br>
var objA = paraview.FindSource( { name: "nameInPipelineBrowserInParaView" });<br>
<br>
2) if you really want to load and unload them, you will have to<br>
re-init the renderers as I was saying in one of my previous mail. Just<br>
let me know if you want to take that route, I can try to explain more.<br>
<br>
Hope that give you enough hints,<br>
<br>
Seb<br>
<div class="HOEnZb"><div class="h5"><br>
On Thu, May 3, 2012 at 5:40 PM, Cagatay Bilgin <<a href="mailto:bilgincc@gmail.com">bilgincc@gmail.com</a>> wrote:<br>
> It only re-initializes if I create another session like this<br>
> paraview.createSession("Shuttle", "", "default");<br>
> but I think I shouldn't be creating a new session<br>
> just to see a different object.<br>
><br>
> I am completely ok with using different file formats. All<br>
> I am trying to do is to minimize the paraviewweb-js-python<br>
> scripting part as I have very limited experience there. That's<br>
> why I was using state files. Is it better to use something else ?<br>
><br>
> Thank you,<br>
> Cagatay<br>
><br>
> On Thu, May 3, 2012 at 2:09 PM, Sebastien Jourdain<br>
> <<a href="mailto:sebastien.jourdain@kitware.com">sebastien.jourdain@kitware.com</a>> wrote:<br>
>><br>
>> Normally loading a state file should re-initialize everything, so the<br>
>><br>
>> activeView = paraview.CreateIfNeededRenderView();<br>
>> paraview.ResetCamera();<br>
>> activeView.setCenterOfRotation(activeView.getCameraFocalPoint());<br>
>><br>
>> should be redone and all the renderer should be re-init with the new view<br>
>> id.<br>
>><br>
>> Seb<br>
>><br>
>><br>
>> On Thu, May 3, 2012 at 5:02 PM, Sebastien Jourdain<br>
>> <<a href="mailto:sebastien.jourdain@kitware.com">sebastien.jourdain@kitware.com</a>> wrote:<br>
>> > Hi Cagatay,<br>
>> ><br>
>> > does your data needs to be a ParaView state file, our would it be<br>
>> > better if it was some other VTK compatible file ?<br>
>> ><br>
>> > Seb<br>
>> ><br>
>> > On Thu, May 3, 2012 at 3:18 PM, Cagatay Bilgin <<a href="mailto:bilgincc@gmail.com">bilgincc@gmail.com</a>><br>
>> > wrote:<br>
>> >> I am trying to build a web application that<br>
>> >> can visualize different objects by the use<br>
>> >> of a drop down bar. I do not want to create<br>
>> >> new connections or sessions every time the<br>
>> >> user changes object to be visualized. I've<br>
>> >> been trying the whole morning and could not<br>
>> >> figure out how to i) delete the current view,<br>
>> >> ii) set it to the view view and iii) refresh the<br>
>> >> page. Here is what I have so far.<br>
>> >><br>
>> >><br>
>> >><br>
>> >> var renderers = {};<br>
>> >> var paraview;<br>
>> >> var activeView;<br>
>> >> var basePath =<br>
>> >><br>
>> >> '/bioimaging/home/ccbilgin/opt/apache-tomcat-6.0.35/webapps/PWShuttle/data/';<br>
>> >> var dataFile = 'tmp.pvsm';<br>
>> >> * paraview = new Paraview(serverUrl);<br>
>> >> * paraview.createSession("Shuttle", "", "default");<br>
>> >><br>
>> >> function start(){<br>
>> >> //paraview.LoadState({filename: basePath +<br>
>> >> '/state.pvsm'});<br>
>> >> paraview.updateConfiguration(true, "JPEG", "-");<br>
>> >> paraview.LoadState({filename: basePath +<br>
>> >> dataFile});<br>
>> >> activeView = paraview.CreateIfNeededRenderView();<br>
>> >> paraview.ResetCamera();<br>
>> >><br>
>> >> activeView.setCenterOfRotation(activeView.getCameraFocalPoint());<br>
>> >><br>
>> >> // Create renderers<br>
>> >> renderers.java = new<br>
>> >> HttpAppletRenderer("javaRenderer",<br>
>> >> serverUrl);<br>
>> >> renderers.java.init(paraview.sessionId,<br>
>> >> activeView.__selfid__);<br>
>> >> renderers.java.setSize("1","1");<br>
>> >><br>
>> >> renderers.flash = new<br>
>> >> FlashRenderer("flashRenderer",<br>
>> >> serverUrl);<br>
>> >> renderers.flash.init(paraview.sessionId,<br>
>> >> activeView.__selfid__);<br>
>> >><br>
>> >> renderers.js = new JavaScriptRenderer("jsRenderer",<br>
>> >> serverUrl);<br>
>> >> renderers.js.init(paraview.sessionId,<br>
>> >> activeView.__selfid__);<br>
>> >><br>
>> >> paraview.updateConfiguration(true, "JPEG",<br>
>> >> "WebGL");<br>
>> >> renderers.webgl = new<br>
>> >> WebGLRenderer("webglRenderer",<br>
>> >> serverUrl);<br>
>> >> renderers.webgl.init(paraview.sessionId,<br>
>> >> activeView.__selfid__);<br>
>> >><br>
>> >> // Remove Java when use in IE<br>
>> >> if (navigator.appName.indexOf ('Microsoft') != -1)<br>
>> >> {<br>
>> >> var e = document.getElementById("java")<br>
>> >> var parent = e.parentNode;<br>
>> >> if(e){<br>
>> >> parent.removeChild(e);<br>
>> >> }<br>
>> >> }<br>
>> >><br>
>> >> // Use webgl as default<br>
>> >> renderers.current = renderers.webgl;<br>
>> >><br>
>> >> renderers.current.bindToElementId("renderercontainer");<br>
>> >> renderers.current.start();<br>
>> >><br>
>> >> // Update render size<br>
>> >> updateSize();<br>
>> >><br>
>> >> // Action images<br>
>> >> updateActionButtons(true);<br>
>> >> }<br>
>> >><br>
>> >> ....<br>
>> >><br>
>> >> function switchData(){<br>
>> >> var type =<br>
>> >> document.getElementById("data-type").value;<br>
>> >> dataFile = 'cone.pvsm';<br>
>> >> start();<br>
>> >> }<br>
>> >><br>
>> >> ....<br>
>> >><br>
>> >> <select id="data-type" name="data-type"<br>
>> >> style="z-index: 5;width: 100px; position: absolute;<br>
>> >> right:<br>
>> >> 40px; top: 30px;"<br>
>> >> onchange="switchData()" ><br>
>> >> <option value="1">1.mhd</option><br>
>> >> <option value="2">2.mhd</option><br>
>> >> <option value="3">3.mhd</option><br>
>> >> </select><br>
>> >><br>
>> >><br>
>> >> _______________________________________________<br>
>> >> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
>> >><br>
>> >> Visit other Kitware open-source projects at<br>
>> >> <a 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:<br>
>> >> <a href="http://paraview.org/Wiki/ParaView" target="_blank">http://paraview.org/Wiki/ParaView</a><br>
>> >><br>
>> >> Follow this link to subscribe/unsubscribe:<br>
>> >> <a href="http://www.paraview.org/mailman/listinfo/paraview" target="_blank">http://www.paraview.org/mailman/listinfo/paraview</a><br>
>> >><br>
><br>
><br>
</div></div></blockquote></div><br></div>