[vtkusers] vtkFlRenderWindowInteractor issues
tirawat
tirawat.b at chula.ac.th
Thu Jan 30 06:23:53 EST 2003
Hi,
It was because you do "Render" before the creation of GUI window.
This makes vtk to build stand-alone window aside the FlRenderWindow
Tirawat
-----Original Message-----
From: vtkusers-admin at public.kitware.com
[mailto:vtkusers-admin at public.kitware.com] On Behalf Of Wahid Alizada
Sent: Thursday, January 30, 2003 11:16 AM
To: vtkusers at public.kitware.com
Subject: [vtkusers] vtkFlRenderWindowInteractor issues
Hi,
I've been using vtkFlRenderWindowInteractor and
so far its been working great. I have a problem right now, which
I'm not sure if its my lack of knowledge in terms of how I'm doing
something or its vtkFlRenderWindowInteractor.
Whenever I issue a renWindow->Render() a new window
pops up with my visualization, instead of the animation sequence occuring
in the vtkFlRenderWindowInteractor window. Once the sequence is done, both
the new window and the vtkFlRenderWindow window are non-interactive.
I don't know why this behavior is occuring.
To illustrate the problem, I've included the Cone3 example that
comes with vtkFlRenderWindowInteractor with modifications. Please look at
the end of the code to see my changes. My own application has this problem
but showing Cone3.cxx is much more simpler.
Thanks for any help,
Wahid
--------------------------------------------------------------------------
// Cone3.cxx adapted to illustrate the use of vtkFlRenderWindowInteractor
// $Id: Cone3.cxx,v 1.6 2002/06/24 13:20:30 cpbotha Exp $
// Study this example carefully. Study it again. Repeat.
// here we have all the usual VTK stuff that we need for our pipeline
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkConeSource.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
// and here we have the famous vtkFlRenderWindowInteractor class
#include <vtkFlRenderWindowInteractor.h>
// and of course some fltk stuff
#include <Fl/Fl_Box.h>
#include <Fl/Fl_Button.h>
// this is a callback for the quit button
void quit_cb(Fl_Widget*, void*)
{
exit(0);
}
int main( int argc, char *argv[] )
{
// set up main FLTK window
Fl_Window* main_window = new Fl_Window(300,330,"Cone3.cxx");
// and instantiate vtkFlRenderWindowInteractor (here it acts like a
FLTK window,
// i.e. you could also instantiate it as child of a Fl_Group in a
window)
vtkFlRenderWindowInteractor* fl_vtk_window = new
vtkFlRenderWindowInteractor(5,5,290,260,NULL);
// this will result in a little message under the rendering
Fl_Box* box = new Fl_Box(5,261,290,34,"3 = stereo, j = joystick, t =
trackball, w = wireframe, s = surface, p = pick; you can also resize the
window");
box->labelsize(10);
box->align(FL_ALIGN_WRAP);
// we want a button with which the user can quit the application
Fl_Button* quit_button = new Fl_Button(100,300,100,25,"quit");
quit_button->callback(quit_cb,NULL);
// we're done populating the main_window
main_window->end();
// if the main window gets resized, the vtk window should resize with
it
main_window->resizable(fl_vtk_window);
// these two steps are VERY IMPORTANT, you have to show() the fltk
window
// containing the vtkFlRenderWindowInteractor, and then the
// vtkFlRenderWindowInteractor itself
main_window->show();
fl_vtk_window->show();
// now we get to setup our VTK rendering pipeline
// create a rendering window and renderer
vtkRenderer *ren = vtkRenderer::New();
vtkRenderWindow *renWindow = vtkRenderWindow::New();
renWindow->AddRenderer(ren);
// uncomment the statement below if things aren't rendering 100% on
your
// configuration; the debug output could give you clues as to why
//renWindow->DebugOn();
// NB: here we treat the vtkFlRenderWindowInteractor just like any
other
// old vtkRenderWindowInteractor
fl_vtk_window->SetRenderWindow(renWindow);
// just like with any other vtkRenderWindowInteractor(), you HAVE to
call
// Initialize() before the interactor will function. See the docs in
// vtkRenderWindowInteractor.h
fl_vtk_window->Initialize();
// create an actor and give it cone geometry
vtkConeSource *cone = vtkConeSource::New();
cone->SetResolution(8);
vtkPolyDataMapper *coneMapper = vtkPolyDataMapper::New();
coneMapper->SetInput(cone->GetOutput());
vtkActor *coneActor = vtkActor::New();
coneActor->SetMapper(coneMapper);
// assign our actor to the renderer
ren->AddActor(coneActor);
///////////////////////////////////////////////////
///////////////////////////////////////////////////
// my addition
for( int i = 0; i < 45; i++)
{
ren->GetActiveCamera()->Azimuth(i);
renWindow->Render();
}
// end of my addition
////////////////////////////////////////////////
/////////////////////////////////////////////////
/////////////////////////////////////////////////
// We can now delete all our references to the VTK pipeline (except for
// our reference to the vtkFlRenderWindowInteractor) as the objects
// themselves will stick around until we dereference fl_vtk_window
ren->Delete();
renWindow->Delete();
cone->Delete();
coneMapper->Delete();
coneActor->Delete();
// this is the standard way of "starting" a fltk application
int fl_ret = Fl::run();
// very huge NB: note that we ->Delete() the
vtkFlRenderWindowInteractor
// once we do this, the rest of the vtk pipeline will really disappear
fl_vtk_window->Delete();
// and after we've done that, we can delete the main_window
delete main_window;
return fl_ret;
}
_______________________________________________
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://public.kitware.com/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list