[vtkusers] Ask for help on GUI problem

Dai Chong ascdai at yahoo.com
Mon Aug 28 10:30:59 EDT 2000


Hi all,

I try to build an interface (parents node) with
buttons using FLTK (GNU Fast Light toolkit) and call
the rendering program (child node) which use vtk.  

The problem that I have is upon calling the rendering
program using vtk, with "vtkRenderWindowInteractor",
it seems like this program (the child) take over the
control which suppose to be handled by the interface
program (the parent). I try to click on the buttons
again on the interface program and they are no longer
available, even though the window frame for the
interface is still there. When I closed the rendering
window (the child), the system quit entirely together
with interface (the parent).

When I removed the "vtkRenderWindowInteractor" and
only use the "vtkRenderWindow", the system works fine
(meaning that I can create multiple child nodes).
However, those rendering windows cannot be refreshed.

Is there any solution where I can create multiple
rendering windows (with interactive mode and ability
to refresh) and control with a single interface
program (the parent)?

Besides using tcl/tk, I need to use C++ to solve the
problem due to some requirements. Is there any
solution for this matter using C++?

Enclosed is the attached program for everyone
reference.

Thanks
Dai Chong

//
// "$Id: button.cxx,v 1.4.2.3 2000/06/05 21:21:16 mike
Exp $"
//
// Button/callback test program for the Fast Light
Tool Kit (FLTK).
//
// Copyright 1998-2000 by Bill Spitzak and others.
//
// This library is free software; you can redistribute
it and/or
// modify it under the terms of the GNU Library
General Public
// License as published by the Free Software
Foundation; either
// version 2 of the License, or (at your option) any
later version.
//
// This library is distributed in the hope that it
will be useful,
// but WITHOUT ANY WARRANTY; without even the implied
warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.  See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library
General Public
// License along with this library; if not, write to
the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307
// USA.
//
// Please report all bugs and problems to
"fltk-bugs at fltk.org".
//

#include <stdlib.h>
#include <stdio.h>
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Button.H>

#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkConeSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"

#include "SaveImage.h"

//put Cone3.cxx codes into callback function of FLTK
void beepcb(Fl_Widget *, void *) {

  //the followings are codes from Cone3.cxx
  // create a rendering window and renderer
  vtkRenderer *ren = vtkRenderer::New();
  vtkRenderWindow *renWindow = vtkRenderWindow::New();
    renWindow->AddRenderer(ren);
  vtkRenderWindowInteractor *iren =
vtkRenderWindowInteractor::New();
    iren->SetRenderWindow(renWindow);
  renWindow->SetSize( 300, 300 );

  // 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);

  // draw the resulting scene
  renWindow->Render();

  //SAVEIMAGE( renWindow );

  renWindow->Start(); // my added code here
  //  Begin mouse interaction
  //iren->Start(); 

  // Clean up
  ren->Delete();
  renWindow->Delete();
  iren->Delete();
  cone->Delete();
  coneMapper->Delete();
  coneActor->Delete();

 // printf("\007"); fflush(stdout);
}

void exitcb(Fl_Widget *, void *) {
  exit(0);
}

#if 0
// test Fl::add_fd()...
void stdin_cb(int, void*) {
  char buf[1000];
  gets(buf);
  printf("stdin callback\n");
}
#endif

int main(int argc, char ** argv) {
  Fl_Window *window = new Fl_Window(320,65);
  Fl_Button *b1 = new Fl_Button(20, 20, 80, 25,
"&Beep");
  b1->callback(beepcb,0);
  /*Fl_Button *b2 =*/ new Fl_Button(120,20, 80, 25,
"&no op");
  Fl_Button *b3 = new Fl_Button(220,20, 80, 25,
"E&xit");
  b3->callback(exitcb,0);
  window->end();
  window->show(argc,argv);
#if 0
  Fl::add_fd(0, stdin_cb);
#endif
  return Fl::run();
}

//
// End of "$Id: button.cxx,v 1.4.2.3 2000/06/05
21:21:16 mike Exp $".
//


__________________________________________________
Do You Yahoo!?
Yahoo! Mail - Free email you can access from anywhere!
http://mail.yahoo.com/




More information about the vtkusers mailing list