[vtkusers] Closing VTK window before application exits

Clinton Stimpson clinton at elemtech.com
Tue Jun 26 11:06:16 EDT 2012


Try this:
  // Close the window
  renderer = NULL;
  renderWindow = NULL;
  renderWindowInteractor = NULL;

Your smart pointers need to let go of the window.

Clint

On Monday, June 18, 2012 05:55:21 AM sameermg wrote:
> Hi all,
> 
> I am learning VTK. I would like to know if there is a way to close the VTK
> window before an application exits. I've tried Delete, Finalize,
> TerminateApp and SetRenderWindow(NULL), but none of these functions seem to
> work until I the application exists. Am I missing something here? I am
> posting sample code below:
> 
> int main(int, char *[])
> {
> 
>   vtkSmartPointer<vtkRenderer> renderer =
> vtkSmartPointer<vtkRenderer>::New();
>   vtkSmartPointer<vtkRenderWindow> renderWindow =
> vtkSmartPointer<vtkRenderWindow>::New();
>   renderWindow->AddRenderer(renderer);
>   vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
> vtkSmartPointer<vtkRenderWindowInteractor>::New();
>   renderWindowInteractor->SetRenderWindow(renderWindow);
>    renderWindow->Render();
>   renderWindow->SetWindowName("First Window");
>   renderWindowInteractor->Start();
> 
>   // Close the window
>   renderWindowInteractor->GetRenderWindow()->Delete();
> 
>   // Stop the interactor
>   renderWindowInteractor->TerminateApp();
> 
>   while(1); //Window does not close because of this while(1). It just
> freezes
>                //If I remove while(1), application exits and window gets
> closed automatically.
>               //I've tried using Delete,Finalize,TerminateApp &
> SetRenderWindow(NULL) before while(1), but no call closes the  window
> 
>   return EXIT_SUCCESS;
> }
> 
> Any help is highly appreciated. Thanks for your time.
> 
> --
> View this message in context:
> http://vtk.1045678.n5.nabble.com/Closing-VTK-window-before-application-exit
> s-tp5713966.html Sent from the VTK - Users mailing list archive at
> Nabble.com.
> _______________________________________________
> 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
-- 
Clinton Stimpson
Elemental Technologies, Inc
Computational Simulation Software, LLC
www.csimsoft.com



More information about the vtkusers mailing list