[vtkusers] Improving interaction with a vtkMFCWindow

Mark Gooding mark.gooding at gmail.com
Thu Mar 9 10:13:44 EST 2006


Hello all,

Sorry for filling your inboxes - I figured it was best to send two
emails becuase my queries were largely unrelated.

Ok - so here's the situation: I writing an app using Visual Studio C++
using both MFC and VTK. Consquently I'm using the vtkMFCWindow to the
the vtk display. The project extends the vtkSDI example (which may
have a bearing on how things are done.)

I would like to be able to interact with the vtk window as already
happens, but it would also be nice to be able to use keyboard and
mouse interaction for other parts of the project.

To enable a context menu I created a subclass of the
vtkInteractorStyle which then sent the WM_CONTEXTMENU command when the
right mouse button was clicked (but not moved). This seemed an ok
solution, but isn't very extensible for other interactions. For
instance I would like to modify my document class when certain keys
are pressed, and it seems somewhat long winded for the interactor to
get the active document and call the appropriate routine, when it
would be better for the document to handle its own keypress routines.

As fas as I see it, the way the messages are handled is as follows;
the vtkMFCWindow implements a large number of the standard window
message functions. These are then the ones that respond to messages,
because the vtkMFCWindow generally has the focus. These functions then
call the appropriate function within the current windowInteractor.
Have I understood this right?

So what would be the best way to get the vtkMFCWindow to share the
messages?? Subclass the vtkMFCWindow and remove it's message handling
and then get the application to handle all messages and pass only the
interesting ones (to vtk) to the subclassed vtkMFCWindow? I think this
is primarily a problem for key presses, since the vtkMFCWindow only
responds to a small number and it would be nice to use other keys to
perform other operations within the application. Most mouse
interaction will probably relate to toolbar work or vtk interaction
anyway (i guess).

Any thoughts?

Cheers,

Mark



More information about the vtkusers mailing list