thank you,<br>that&#39;ll give me something to play with.<br><br>Michael<br><br><div class="gmail_quote">On Thu, Jan 7, 2010 at 7:16 PM, David Doria <span dir="ltr">&lt;<a href="mailto:daviddoria%2Bvtk@gmail.com">daviddoria+vtk@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="h5">On Thu, Jan 7, 2010 at 11:52 AM, Bryan P. Conrad &lt;<a href="mailto:conrabp@ortho.ufl.edu">conrabp@ortho.ufl.edu</a>&gt; wrote:<br>


&gt; Michael,<br>
&gt;<br>
&gt; I am not sure about how to programmatically align the renderwindows, but as<br>
&gt; for your question about displaying multiple render windows, I think the<br>
&gt; problem is that once you call windowinteractor.Start(), the render window<br>
&gt; will block the code from continuing until the interaction is terminated.<br>
&gt; You can work around this by calling Render() on each of the windows before<br>
&gt; you call Start().  Based on what it sounds like you are doing, it looks like<br>
&gt; you might be interested in looking at using one render window with multiple<br>
&gt; renderers in separate viewports.  This will allow you to display different<br>
&gt; scenes in each renderer, but you will only have to manage one render<br>
&gt; window.  I have attached examples of both scenarios below:<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; import vtk<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; def main():<br>
&gt;<br>
&gt;     &#39;&#39;&#39;multiple render windows&#39;&#39;&#39;<br>
&gt;<br>
&gt;     iren_list = []<br>
&gt;<br>
&gt;     for i in range(4):<br>
&gt;<br>
&gt;         rw = vtk.vtkRenderWindow()<br>
&gt;<br>
&gt;         ren = vtk.vtkRenderer()<br>
&gt;<br>
&gt;         rw.AddRenderer(ren)<br>
&gt;<br>
&gt;         iren = vtk.vtkRenderWindowInteractor()<br>
&gt;<br>
&gt;         iren.SetRenderWindow(rw)<br>
&gt;<br>
&gt;         rw.Render()<br>
&gt;<br>
&gt;         rw.SetWindowName(&#39;RW: &#39;+str(i))<br>
&gt;<br>
&gt;         iren_list.append(iren)<br>
&gt;<br>
&gt;         #Create a sphere<br>
&gt;<br>
&gt;         sphereSource = vtk.vtkSphereSource()<br>
&gt;<br>
&gt;         sphereSource.SetCenter(0.0, 0.0, 0.0)<br>
&gt;<br>
&gt;         sphereSource.SetRadius(5)<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;         #Create a mapper and actor<br>
&gt;<br>
&gt;         mapper = vtk.vtkPolyDataMapper()<br>
&gt;<br>
&gt;         mapper.SetInputConnection(sphereSource.GetOutputPort())<br>
&gt;<br>
&gt;         actor = vtk.vtkActor()<br>
&gt;<br>
&gt;         actor.SetMapper(mapper)<br>
&gt;<br>
&gt;         ren.AddActor(actor)<br>
&gt;<br>
&gt;         ren.ResetCamera()<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;     iren_list[-1].Start()<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; def main2():<br>
&gt;<br>
&gt;     &#39;&#39;&#39;One render window, multiple viewports&#39;&#39;&#39;<br>
&gt;<br>
&gt;     iren_list = []<br>
&gt;<br>
&gt;     rw = vtk.vtkRenderWindow()<br>
&gt;<br>
&gt;     iren = vtk.vtkRenderWindowInteractor()<br>
&gt;<br>
&gt;     iren.SetRenderWindow(rw)<br>
&gt;<br>
&gt;     # Define viewport ranges<br>
&gt;<br>
&gt;     xmins=[0,.5,0,.5]<br>
&gt;<br>
&gt;     xmaxs=[0.5,1,0.5,1]<br>
&gt;<br>
&gt;     ymins=[0,0,.5,.5]<br>
&gt;<br>
&gt;     ymaxs=[0.5,0.5,1,1]<br>
&gt;<br>
&gt;     for i in range(4):<br>
&gt;<br>
&gt;         ren = vtk.vtkRenderer()<br>
&gt;<br>
&gt;         rw.AddRenderer(ren)<br>
&gt;<br>
&gt;         ren.SetViewport(xmins[i],ymins[i],xmaxs[i],ymaxs[i])<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;         #Create a sphere<br>
&gt;<br>
&gt;         sphereSource = vtk.vtkSphereSource()<br>
&gt;<br>
&gt;         sphereSource.SetCenter(0.0, 0.0, 0.0)<br>
&gt;<br>
&gt;         sphereSource.SetRadius(5)<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;         #Create a mapper and actor<br>
&gt;<br>
&gt;         mapper = vtk.vtkPolyDataMapper()<br>
&gt;<br>
&gt;         mapper.SetInputConnection(sphereSource.GetOutputPort())<br>
&gt;<br>
&gt;         actor = vtk.vtkActor()<br>
&gt;<br>
&gt;         actor.SetMapper(mapper)<br>
&gt;<br>
&gt;         ren.AddActor(actor)<br>
&gt;<br>
&gt;         ren.ResetCamera()<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;     rw.Render()<br>
&gt;<br>
&gt;     rw.SetWindowName(&#39;RW: Multiple ViewPorts&#39;)<br>
&gt;<br>
&gt;     iren.Start()<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; if __name__ == &#39;__main__&#39;:<br>
&gt;<br>
&gt;     main()<br>
&gt;<br>
&gt;     main2()<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; ____________________________<br>
&gt;<br>
&gt; Bryan P. Conrad, Ph.D.<br>
&gt;<br>
&gt; Senior Engineer<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; Department of Orthopaedics and Rehabilitation<br>
&gt;<br>
&gt; University of Florida<br>
&gt;<br>
&gt; PO Box 112727<br>
&gt;<br>
&gt; Gainesville, FL 32611<br>
&gt;<br>
&gt; Phone: 352.273.7412<br>
&gt;<br>
&gt; Fax: 352.273.7407<br>
&gt;<br>
&gt; ________________________________<br>
&gt;<br>
&gt; From: <a href="mailto:vtkusers-bounces@vtk.org">vtkusers-bounces@vtk.org</a> [mailto:<a href="mailto:vtkusers-bounces@vtk.org">vtkusers-bounces@vtk.org</a>] On Behalf<br>
&gt; Of michiel mentink<br>
&gt; Sent: Thursday, January 07, 2010 6:45 AM<br>
&gt; To: David Doria<br>
&gt;<br>
&gt; Cc: <a href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a><br>
&gt; Subject: Re: [vtkusers] giving renderwindow a name<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; thanks guys, I&#39;ve the title working now.<br>
&gt;<br>
&gt; For a touch of perfection; is there a way to automatically set the window<br>
&gt; coordinates so that the windows are aligned wherever you want them?<br>
&gt; (i.e. next to each other?)<br>
&gt;<br>
&gt;<br>
&gt; And one last question: after the first render window has been created, the<br>
&gt; program waits for me to press &#39;q&#39; to continue the program. Is<br>
&gt; there a way for the program to continue without pressing &#39;q&#39;?<br>
&gt;<br>
&gt; I tried: renwindow-&gt;Finalize(); // doesn&#39;t do anything<br>
&gt;<br>
&gt; windowinteractor-&gt;TerminateApp(); // this closes the application altogether<br>
&gt; when &#39;q&#39; is pressed<br>
&gt;<br>
&gt; windowinteractor-&gt;UnRegister(); // error: no matching function call<br>
&gt;                                                // note: candidates are:<br>
&gt; virtual void vtkRenderWindowInteractor::UnRegister(vtkObjectBase*)<br>
&gt;<br>
&gt; windowinteractor-&gt;CreateOneShotTimer(1); // doesn&#39;t release focus<br>
&gt;<br>
&gt; I&#39;d just like all windows to pop up as soon as possible and be able to<br>
&gt; manipulate them with my mouse whenever I&#39;d like to.<br>
&gt; At this point I can manipulate all renderwindows fine, I&#39;d just like the<br>
&gt; windows to appear without having to press &#39;q&#39;.<br>
&gt;<br>
&gt; cheers, Michael<br>
&gt;<br>
&gt; On Tue, Jan 5, 2010 at 10:42 PM, David Doria &lt;<a href="mailto:daviddoria%2Bvtk@gmail.com">daviddoria+vtk@gmail.com</a>&gt;<br>
&gt; wrote:<br>
&gt;<br>
&gt; On Tue, Jan 5, 2010 at 5:22 PM, Bryan P. Conrad &lt;<a href="mailto:conrabp@ortho.ufl.edu">conrabp@ortho.ufl.edu</a>&gt;<br>
&gt; wrote:<br>
&gt;&gt; I have only done this in python, not C++, but I think the trick is to use<br>
&gt;&gt; the method &quot;SetWindowName&quot; and it has to be called *after* the renderWindow<br>
&gt;&gt; is rendered the first time.  See the python code below (copied from David&#39;s<br>
&gt;&gt; C++ example), for a version that works on my machine.<br>
&gt;&gt;<br>
&gt;&gt; import vtk<br>
&gt;&gt;<br>
&gt;&gt; def main():<br>
&gt;&gt;    #Create a sphere<br>
&gt;&gt;    sphereSource = vtk.vtkSphereSource()<br>
&gt;&gt;    sphereSource.SetCenter(0.0, 0.0, 0.0)<br>
&gt;&gt;    sphereSource.SetRadius(5)<br>
&gt;&gt;<br>
&gt;&gt;    #Create a mapper and actor<br>
&gt;&gt;    mapper = vtk.vtkPolyDataMapper()<br>
&gt;&gt;    mapper.SetInputConnection(sphereSource.GetOutputPort())<br>
&gt;&gt;    actor = vtk.vtkActor()<br>
&gt;&gt;    actor.SetMapper(mapper)<br>
&gt;&gt;<br>
&gt;&gt;    # Setup a renderer, render window, and interactor<br>
&gt;&gt;    renderer = vtk.vtkRenderer()<br>
&gt;&gt;    renderWindow = vtk.vtkRenderWindow()<br>
&gt;&gt;    #renderWindow.SetWindowName(&quot;Test&quot;)<br>
&gt;&gt;<br>
&gt;&gt;    renderWindow.AddRenderer(renderer);<br>
&gt;&gt;    renderWindowInteractor = vtk.vtkRenderWindowInteractor()<br>
&gt;&gt;    renderWindowInteractor.SetRenderWindow(renderWindow)<br>
&gt;&gt;<br>
&gt;&gt;    #Add the actor to the scene<br>
&gt;&gt;    renderer.AddActor(actor)<br>
&gt;&gt;    renderer.SetBackground(1,1,1) # Background color white<br>
&gt;&gt;<br>
&gt;&gt;    #Render and interact<br>
&gt;&gt;    renderWindow.Render()<br>
&gt;&gt;<br>
&gt;&gt;    #*** SetWindowName after renderWindow.Render() is called***<br>
&gt;&gt;    renderWindow.SetWindowName(&quot;Test&quot;)<br>
&gt;&gt;<br>
&gt;&gt;    renderWindowInteractor.Start()<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; if __name__ == &#39;__main__&#39;:<br>
&gt;&gt;    main()<br>
&gt;&gt;<br>
&gt;&gt; ____________________________<br>
&gt;&gt; Bryan P. Conrad, Ph.D.<br>
&gt;&gt; Senior Engineer<br>
&gt;&gt;<br>
&gt;&gt; Department of Orthopaedics and Rehabilitation<br>
&gt;&gt; University of Florida<br>
&gt;&gt; PO Box 112727<br>
&gt;&gt; Gainesville, FL 32611<br>
&gt;&gt; Phone: 352.273.7412<br>
&gt;&gt; Fax: 352.273.7407<br>
&gt;&gt;<br>
&gt;&gt; -----Original Message-----<br>
&gt;&gt; From: <a href="mailto:vtkusers-bounces@vtk.org">vtkusers-bounces@vtk.org</a> [mailto:<a href="mailto:vtkusers-bounces@vtk.org">vtkusers-bounces@vtk.org</a>] On Behalf<br>
&gt;&gt; Of David Doria<br>
&gt;&gt; Sent: Tuesday, January 05, 2010 2:07 PM<br>
&gt;&gt; Cc: <a href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a><br>
&gt;&gt; Subject: Re: [vtkusers] giving renderwindow a name<br>
&gt;&gt;<br>
&gt;&gt; On Tue, Jan 5, 2010 at 11:25 AM, michiel mentink<br>
&gt;&gt; &lt;<a href="mailto:michael.mentink@st-hughs.ox.ac.uk">michael.mentink@st-hughs.ox.ac.uk</a>&gt; wrote:<br>
&gt;&gt;&gt; I&#39;m trying to give a renderwindow a title.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I&#39;m using the following code to create a window. So far so good.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;   // create a renderer<br>
&gt;&gt;&gt;   vtkSmartPointer&lt;vtkRenderer&gt; renderer =<br>
&gt;&gt;&gt;     vtkSmartPointer&lt;vtkRenderer&gt;::New();<br>
&gt;&gt;&gt;   renderer-&gt;AddActor(actor);<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;   // create a render window<br>
&gt;&gt;&gt;   vtkSmartPointer&lt;vtkRenderWindow&gt; renwin =<br>
&gt;&gt;&gt;     vtkSmartPointer&lt;vtkRenderWindow&gt;::New();<br>
&gt;&gt;&gt;   renwin-&gt;AddRenderer(renderer);<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;   // create an interactor<br>
&gt;&gt;&gt;   vtkSmartPointer&lt;vtkRenderWindowInteractor&gt; iren =<br>
&gt;&gt;&gt;     vtkSmartPointer&lt;vtkRenderWindowInteractor&gt;::New();<br>
&gt;&gt;&gt;   iren-&gt;SetRenderWindow(renwin);<br>
&gt;&gt;&gt;     renwin-&gt;SetSize(640, 480);<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;   iren-&gt;Initialize();<br>
&gt;&gt;&gt;   iren-&gt;Start();<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; ///////////end code////////<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Before iren-&gt;initialize, I tried the following:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;       iren-&gt;SetWindowInfo( &quot;window1&quot; );<br>
&gt;&gt;&gt;      renwin-&gt;SetWindowInfo( &quot;window1&quot;);<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; and also -&gt;SetWindowId(&quot;window1&quot;);<br>
&gt;&gt;&gt; and -&gt;SetWindowName(&quot;window1&quot;);<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; but it keeps giving me error messages upon compiling:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; &#39;class vtkRenderWindowInteractor&#39; has no member named &#39;SetWindowInfo&#39;<br>
&gt;&gt;&gt; or<br>
&gt;&gt;&gt; error: &#39;renWin&#39; was not declared in this scope<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; It&#39;s probably a simple mistake, but I&#39;m still beginning to understand<br>
&gt;&gt;&gt; VTK.<br>
&gt;&gt;&gt; Can anybody point me in the right direction?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Kind regards, Michael<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; I setup an example if anyone cares to play with it to get it to work:<br>
&gt;&gt; <a href="http://www.cmake.org/Wiki/VTK/Examples/WindowTitle" target="_blank">http://www.cmake.org/Wiki/VTK/Examples/WindowTitle</a><br>
&gt;&gt;<br>
&gt;&gt; Thanks,<br>
&gt;&gt;<br>
&gt;&gt; David<br>
&gt;<br>
&gt; Thanks Bryan, that did the trick.<br>
&gt;<br>
&gt; The example can be found here (c++):<br>
&gt;<br>
&gt; <a href="http://www.cmake.org/Wiki/VTK/Examples/WindowTitle" target="_blank">http://www.cmake.org/Wiki/VTK/Examples/WindowTitle</a><br>
&gt;<br>
&gt; and here(python): <a href="http://www.cmake.org/Wiki/VTK/Examples/Python/WindowTitle" target="_blank">http://www.cmake.org/Wiki/VTK/Examples/Python/WindowTitle</a><br>
&gt;<br>
&gt; Thanks,<br>
&gt;<br>
&gt; David<br>
&gt; _______________________________________________<br>
&gt; Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
&gt;<br>
&gt; Visit other Kitware open-source projects at<br>
&gt; <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
&gt;<br>
&gt; Please keep messages on-topic and check the VTK FAQ at:<br>
&gt; <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
&gt;<br>
&gt; Follow this link to subscribe/unsubscribe:<br>
&gt; <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
&gt;<br>
&gt;<br>
<br>
</div></div>If anyone cares to demo multiple render windows or multiple viewports,<br>
I&#39;ve made a spot for them here:<br>
<br>
<a href="http://www.vtk.org/Wiki/VTK/Examples/MultipleRenderWindows" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/MultipleRenderWindows</a><br>
<a href="http://www.vtk.org/Wiki/VTK/Examples/MultipleViewports" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/MultipleViewports</a><br>
<div><div></div><div class="h5"><br>
Thanks,<br>
<br>
David<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 <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 VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</div></div></blockquote></div><br>