shamantou blog site

shamantou@gmail.com

导航

vtkMFCWindow
在使用vtkMFCWindow进行vtk+VC MFC开发,重新书写MedPlant程序,目前遇到的问题有:
1.如何选择三维场景中的坐标点,已解决,via vtkCellPicker类,
2.如何进行三维空间的面裁剪,有待解决;
3.vtkMFCWindow好像接收了界面的消息,然后但是并没有share these messages with other windows, such as view frame. in my opinion, one solution is that re-program vtkMFCWindow, for I have the resouce of vtkMFCWindow, but it's not a good idea, for vtkMFCWindow is a standarded C++ class, I should not crack it's intergrality.
Second solution is make a subclass of vtkMFCWindow, then remove the msg handle from vtkMFCWindow, make some of mine.

Following is some FAQs from VTK forum:
-------------------------------------------------------------------------



Kitware Inc - Leaders in Visualization Technology Search

[vtkusers] Improving interaction with a vtkMFCWindow
Mark Gooding mark.gooding at gmail.com
Thu Mar 9 10:13:44 EST 2006

Previous message: [vtkusers] vtkMFCWindow causing crash in release mode with visual studio
Next message: [vtkusers] vtk-paraview
Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

--------------------------------------------------------------------------------

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


--------------------------------------------------------------------------------


Previous message: [vtkusers] vtkMFCWindow causing crash in release mode with visual studio
Next message: [vtkusers] vtk-paraview
Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

--------------------------------------------------------------------------------
More information about the vtkusers mailing list

--------------------------------------------------------------------------------------
Kitware Inc - Leaders in Visualization Technology Search

[vtkusers] Improving interaction with a vtkMFCWindow
de Boer Ingo I.deBoer at polytec.de
Thu Mar 9 10:31:37 EST 2006

Previous message: [vtkusers] vtkMFCWindow causing crash in release mode with visualstudio
Next message: [vtkusers] Improving interaction with a vtkMFCWindow
Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

--------------------------------------------------------------------------------

Hi,

> To enable a context menu I created a subclass of the
> vtkInteractorStyle which then sent the WM_CONTEXTMENU command
Why not creating a context menu via the view class ?

> interactions. For instance I would like to modify my document
> class when certain keys are pressed, and it seems somewhat
Why not use the OnKey/OnChar from the view class ?

> that respond to messages, because the vtkMFCWindow generally
> has the focus. These functions then call the appropriate
The focus depends on your programm. Eg, a mouse click sets
a focus to a window.

> So what would be the best way to get the vtkMFCWindow to
> share the messages?? Subclass the vtkMFCWindow and remove
The messages are also send to the view, so they share them already


greets
Ingo

---
Dr.-Ing. Ingo H. de Boer

Polytec GmbH
Polytec-Platz 1-7, 76337 Waldbronn, Germany
phone: ++49 7243 604 106
fax : ++49 7243 604 255


--------------------------------------------------------------------------------


Previous message: [vtkusers] vtkMFCWindow causing crash in release mode with visualstudio
Next message: [vtkusers] Improving interaction with a vtkMFCWindow
Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

--------------------------------------------------------------------------------
More information about the vtkusers mailing list


有人写的一个解决方案如下:
From: John Platt dsl.pipex.com>
Subject: RE: Enabling use a ContextMenu with vtk and MFC (mouse-clickdetection)
Newsgroups: gmane.comp.lib.vtk.user
Date: 2006-02-27 22:29:02 GMT (42 weeks, 12 hours and 43 minutes ago)

Hi Mark,

Have you tried adding an observer to your interactor for the right
button press event, something like this in your CView derived class ....

MyView.h

vtkCallbackCommand* m_vtkMouseEventCBC;
static void ProcessMouseEvents( vtkObject* object, unsigned long
event, void* clientdata, void*
calldata );

MyView.cpp

m_vtkMouseEventCBC = vtkCallbackCommand::New();
m_vtkMouseEventCBC->SetCallback( CMyView::ProcessMouseEvents );
m_vtkMouseEventCBC->SetClientData( this );

m_vtkInteractor->AddObserver( vtkCommand::RightButtonPressEvent,
m_vtkMouseEventCBC, 0.5 );

void CMyView::ProcessMouseEvents(vtkObject* vtkNotUsed(object),
unsigned long event,
void* clientdata,
void* callData )
{
CMyView* self = reinterpret_cast< CMyView*>( clientdata );
switch( event )
{
case vtkCommand::RightButtonPressEvent:
TRACE("Right Button Down.\n" );
self->DoSomeStuff();

// Prevent others from handling this event.
self->m_vtkMouseEventCBC->SetAbortFlag(1);
break;
}
}

HTH

John.

-----Original Message-----
From: vtkusers-bounces+jcplatt=dsl.pipex.com vtk.org
[mailto:vtkusers-bounces+jcplatt=dsl.pipex.com vtk.org] On Behalf Of
Mark Gooding
Sent: 27 February 2006 10:13
To: vtkusers
Subject: [vtkusers] Enabling use a ContextMenu with vtk and MFC
(mouse-clickdetection)

Hello all,

A while ago I emailed about trying to set up a ContextMenu when the
right mouse button is clicked on the vtkWindow in MFC. The problem was
that the vtkMFCWindow does not respond to the clicks (despite the
example having a function within it that appears to suggest it
should), instead the mouse action seems to passed directly to the
vtkWindowInteractor.

To solve this problem I think I should be subclassing
vtkWindowInteractorStyle, so that I can either remove the handling of
right mouse click (so that the window handles it) or modify it to pass
clicks directly to the CView class.

Does this sound like a sensible approach? Or is there a better/more
standard solution? I didn't want to set off programming without at
least knowing that I heading in the right direction!

Cheers,

Mark
_______________________________________________
<< History of Tcl转载一个很cool的opengl soft 水波形制作 >>

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

最近发表

Powered By Z-Blog 1.8 Arwen Build 81206 Copyright 2006-2009 | ooplab.org | shamantou@gmail.com | 沪ICP备08011244号 | Some Rights Reserved.