[vtkusers] Re: How to subclass RenderWindow for use with GTK
Sean McInerney
seanm at nmr.mgh.harvard.edu
Tue Nov 12 14:08:01 EST 2002
I have done something similar to what you seek for use with FLTK due to
limitations found in the freely availible VTK/FLTK solutions. My
implementation, however, ranks toward the ugly and effortful side. In a
nutshell:
1a. Derive a new RenderWindow class from vtkOpenGLRenderWindow (e.g.
vtkGTKOpenGLRenderWindow). Using vtkXOpenGLRenderWindow as a model,
reimplement all the X and Xt calls with GDK and GTK calls.
1b. Similarly derive a new Interactor class from
vtkRenderWindowInteractor using vtkXRenderWindowInteractor as a model.
N.B. You MAY be able to implement all of you event handling code here as
vtkXRenderWindowInteractor does, though you may (and will probably) want
to use GDK/GTK's event handling via a sub-class of GTK's OpenGL window
widget (see item 3 below).
1c. (Optional) ... If you have an excess of free time, derive a
non-OpenGL RenderWindow class from vtkRenderWindow using
vtkXRenderWindow as a model.
2. Derive a new ObjectFactory class from vtkObjectFactory (e.g.
vtkGTKObjectFactory) so that creating the familiar parent objects
(vtkRenderWindow, etc.) actually instantiates your spiffy new
GTK-specialized sub-classes. Albeit, in use, you'll need a pointer to
your specialized sub-class to access any methods not found in the
ancestor (hint: use ...::SafeDownCast()).
3. (Maybe optional) Derive a new widget from GTK's OpenGL window widget
via GTK's object hierarchy mechanism (I am unable to be of much help
here). Your new specialized GTK object should then invoke event methods
of its associated Interactor within its handler method when it receives
an event (from GDK/GTK).
If you work continuously for a couple days, you should have a usable
(but probably buggy) implementation ready before you collapse.
-Sean
More information about the vtkusers
mailing list