[vtkusers] Re: vtkFLTK eventloop (A J)

A J lost_bits1110 at hotmail.com
Mon Jun 14 10:27:08 EDT 2004


Thanks very much..! thats great


>From: Sean McInerney <seanm at nmr.mgh.harvard.edu>
>Reply-To: seanm at nmr.mgh.harvard.edu
>To: vtkusers at vtk.org, lost_bits1110 at hotmail.com
>Subject: [vtkusers] Re: vtkFLTK eventloop (A J)
>Date: Sun, 13 Jun 2004 14:16:40 -0400
>
>AJ,
>
>   1. Look at vtkFLTK/Examples to find the answers you seek.
>
>   2. Just use vtkRenderWindowInteractor (instantiation of
>      vtkFLTKRenderWindowInteractor is handled by the ObjectFactory
>      which is registered by the Fl_VTK_Window initializer).
>
>   3. Start the FLTK event loop with Fl::run().
>
>   4. Below is a simple example animating via a timeout.
>      Be sure to read the comments.
>
>   Note that regular interaction remains enabled.
>
>-Sean
>
>// VTK Graphics
>#include "vtkConeSource.h"
>// VTK Rendering
>#include "vtkPolyDataMapper.h"
>#include "vtkActor.h"
>#include "vtkCamera.h"
>// FLTK (needed for the call to Fl::run())
>#include <FL/Fl.H>
>// vtkFLTK
>#include "Fl_VTK_Window.H"
>
>void
>timer_callback (void* a)
>{
>   Fl_VTK_Window* window = reinterpret_cast<Fl_VTK_Window*>(a);
>   vtkCamera*     camera = window->GetDefaultCamera();
>
>   camera->Roll(0.2);
>   window->Update();
>
>   // Repeat timeout at 1/30th of a second from when the system call
>   // elapsed that caused this timeout.
>   Fl::repeat_timeout(1.0 / 30.0, timer_callback, a);
>}
>
>int
>main (int argc, char* argv[])
>{
>   // Set up a top level window and a Fl_VTK_Window to be its child.
>   Fl_Window*     mainWindow    = new Fl_Window(400,100, 256,256);
>   // Create the child window (wrapped within is the RenderWindow).
>   Fl_VTK_Window* vtkfltkWindow = new Fl_VTK_Window(8,8, 240,240);
>
>   // If 'mainWindow' is resized, 'vtkfltkWindow' should resize with it.
>   mainWindow->resizable(vtkfltkWindow);
>   // End populating the mainWindow.
>   mainWindow->end();
>
>   // Set up the VTK rendering pipeline creating an actor and giving it
>   // some cone geometry. The references to the VTK pipeline can be
>   // deleted along the way as the objects themselves will stick around
>   // until the Fl_VTK_Window is deleted.
>   vtkActor*          coneActor  = vtkActor::New();
>   vtkPolyDataMapper* coneMapper = vtkPolyDataMapper::New();
>   vtkConeSource*     coneSource = vtkConeSource::New();
>
>   // Connect the Source to the Mapper and decrement its reference count.
>   coneMapper->SetInput(coneSource->GetOutput());
>   coneSource->Delete();
>   // Connect the Mapper to the Actor and decrement its reference count.
>   coneActor->SetMapper(coneMapper);
>   coneMapper->Delete();
>   // Add Actor to default renderer and decrement its reference count.
>   vtkfltkWindow->AddProp(coneActor);
>   coneActor->Delete();
>
>   // Show the main Fl_Window.
>   mainWindow->show();
>
>   // Add a timeout to be called as soon as the event loop starts.
>   Fl::add_timeout(0, timer_callback, vtkfltkWindow);
>
>   // Start the FLTK event loop.
>   int fl_ret = Fl::run();
>
>   // After the FLTK event loop returns, delete the interface windows.
>   //     N.B.: When we delete 'mainWindow', its Fl_VTK_Window
>   //           child is also destroyed. When the Fl_VTK_Window is
>   //           destroyed, it invokes Delete() on its associated
>   //           vtkRenderWindowInteractor. Once this is done, the
>   //           rest of the VTK pipeline will also be destroyed.
>   delete mainWindow;
>
>   return fl_ret;
>}
>
>
>>
>>Hi,
>>
>>Can someone give me a small basic example on how to start the event loop 
>>and have a call back associated with the timer that drives the event loop
>>and is there a way to set the timer to be called every x number of 
>>milliseconds..?
>>
>>Right now im on c++ using vtk and just got the vtkFLTK library
>>So far I render with vtkRenderWindowInteractor
>>
>>but now I guess I should change this to vtkFLTKRenderWindowInteractor..?
>>
>>so what do I call to initiate the event loop?
>>
>>thanks..
>>aj
>>
>_______________________________________________
>This is the private VTK discussion list. Please keep messages on-topic. 
>Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
>Follow this link to subscribe/unsubscribe:
>http://www.vtk.org/mailman/listinfo/vtkusers

_________________________________________________________________
Stop worrying about overloading your inbox - get MSN Hotmail Extra Storage! 
http://join.msn.click-url.com/go/onm00200362ave/direct/01/




More information about the vtkusers mailing list