[vtkusers] giving renderwindow a name

michiel mentink michael.mentink at st-hughs.ox.ac.uk
Thu Jan 7 06:44:54 EST 2010


thanks guys, I've the title working now.

For a touch of perfection; is there a way to automatically set the window
coordinates so that the windows are aligned wherever you want them?
(i.e. next to each other?)


And one last question: after the first render window has been created, the
program waits for me to press 'q' to continue the program. Is
there a way for the program to continue without pressing 'q'?

I tried: renwindow->Finalize(); // doesn't do anything

windowinteractor->TerminateApp(); // this closes the application altogether
when 'q' is pressed

windowinteractor->UnRegister(); // error: no matching function call
                                               // note: candidates are:
virtual void vtkRenderWindowInteractor::UnRegister(vtkObjectBase*)

windowinteractor->CreateOneShotTimer(1); // doesn't release focus

I'd just like all windows to pop up as soon as possible and be able to
manipulate them with my mouse whenever I'd like to.
At this point I can manipulate all renderwindows fine, I'd just like the
windows to appear without having to press 'q'.

cheers, Michael

On Tue, Jan 5, 2010 at 10:42 PM, David Doria
<daviddoria+vtk at gmail.com<daviddoria%2Bvtk at gmail.com>
> wrote:

> On Tue, Jan 5, 2010 at 5:22 PM, Bryan P. Conrad <conrabp at ortho.ufl.edu>
> wrote:
> > I have only done this in python, not C++, but I think the trick is to use
> the method "SetWindowName" and it has to be called *after* the renderWindow
> is rendered the first time.  See the python code below (copied from David's
> C++ example), for a version that works on my machine.
> >
> > import vtk
> >
> > def main():
> >    #Create a sphere
> >    sphereSource = vtk.vtkSphereSource()
> >    sphereSource.SetCenter(0.0, 0.0, 0.0)
> >    sphereSource.SetRadius(5)
> >
> >    #Create a mapper and actor
> >    mapper = vtk.vtkPolyDataMapper()
> >    mapper.SetInputConnection(sphereSource.GetOutputPort())
> >    actor = vtk.vtkActor()
> >    actor.SetMapper(mapper)
> >
> >    # Setup a renderer, render window, and interactor
> >    renderer = vtk.vtkRenderer()
> >    renderWindow = vtk.vtkRenderWindow()
> >    #renderWindow.SetWindowName("Test")
> >
> >    renderWindow.AddRenderer(renderer);
> >    renderWindowInteractor = vtk.vtkRenderWindowInteractor()
> >    renderWindowInteractor.SetRenderWindow(renderWindow)
> >
> >    #Add the actor to the scene
> >    renderer.AddActor(actor)
> >    renderer.SetBackground(1,1,1) # Background color white
> >
> >    #Render and interact
> >    renderWindow.Render()
> >
> >    #*** SetWindowName after renderWindow.Render() is called***
> >    renderWindow.SetWindowName("Test")
> >
> >    renderWindowInteractor.Start()
> >
> >
> > if __name__ == '__main__':
> >    main()
> >
> > ____________________________
> > Bryan P. Conrad, Ph.D.
> > Senior Engineer
> >
> > Department of Orthopaedics and Rehabilitation
> > University of Florida
> > PO Box 112727
> > Gainesville, FL 32611
> > Phone: 352.273.7412
> > Fax: 352.273.7407
> >
> > -----Original Message-----
> > From: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] On
> Behalf Of David Doria
> > Sent: Tuesday, January 05, 2010 2:07 PM
> > Cc: vtkusers at vtk.org
> > Subject: Re: [vtkusers] giving renderwindow a name
> >
> > On Tue, Jan 5, 2010 at 11:25 AM, michiel mentink
> > <michael.mentink at st-hughs.ox.ac.uk> wrote:
> >> I'm trying to give a renderwindow a title.
> >>
> >> I'm using the following code to create a window. So far so good.
> >>
> >>   // create a renderer
> >>   vtkSmartPointer<vtkRenderer> renderer =
> >>     vtkSmartPointer<vtkRenderer>::New();
> >>   renderer->AddActor(actor);
> >>
> >>   // create a render window
> >>   vtkSmartPointer<vtkRenderWindow> renwin =
> >>     vtkSmartPointer<vtkRenderWindow>::New();
> >>   renwin->AddRenderer(renderer);
> >>
> >>
> >>   // create an interactor
> >>   vtkSmartPointer<vtkRenderWindowInteractor> iren =
> >>     vtkSmartPointer<vtkRenderWindowInteractor>::New();
> >>   iren->SetRenderWindow(renwin);
> >>     renwin->SetSize(640, 480);
> >>
> >>   iren->Initialize();
> >>   iren->Start();
> >>
> >>
> >> ///////////end code////////
> >>
> >> Before iren->initialize, I tried the following:
> >>
> >>       iren->SetWindowInfo( "window1" );
> >>      renwin->SetWindowInfo( "window1");
> >>
> >> and also ->SetWindowId("window1");
> >> and ->SetWindowName("window1");
> >>
> >> but it keeps giving me error messages upon compiling:
> >>
> >> 'class vtkRenderWindowInteractor' has no member named 'SetWindowInfo'
> >> or
> >> error: 'renWin' was not declared in this scope
> >>
> >>
> >> It's probably a simple mistake, but I'm still beginning to understand
> VTK.
> >> Can anybody point me in the right direction?
> >>
> >> Kind regards, Michael
> >>
> >>
> >
> > I setup an example if anyone cares to play with it to get it to work:
> > http://www.cmake.org/Wiki/VTK/Examples/WindowTitle
> >
> > Thanks,
> >
> > David
>
> Thanks Bryan, that did the trick.
>
> The example can be found here (c++):
> http://www.cmake.org/Wiki/VTK/Examples/WindowTitle
> and here(python):
> http://www.cmake.org/Wiki/VTK/Examples/Python/WindowTitle
>
> Thanks,
>
> David
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100107/0ce2ad97/attachment.htm>


More information about the vtkusers mailing list