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