[vtkusers] Re: interaction with vtkWindow
Aroosha Laghaee
s9738436 at sms.ed.ac.uk
Mon Apr 24 09:34:23 EDT 2006
Hi,
Sorry for the late reply. I think you need two things 1) to pass your
vtkRenderWindowInteractor to your execute function and 2) to get the
value of the key pressed using vtkRenderWindowInteractor::GetKeyCode().
So your Execute function will need to look something like this:
virtual void Execute (vtkObject *caller,unsigned long,void * )
{
vtkRenderWindowInteractor* iren =
reinterpret_cast<vtkRenderWindowInteractor*>(Object);
char key = iren->GetKeyCode();
if(key=='m'){
AfxMessageBox ("M is pressed.");
//etc.
}
}
Also try and use keys which are not already being used by
vtkRenderWindowInteractor already. C is already used.
I hope this helps,
Aroosha
> Hi Aroosha,
>
> I saw your post regarding interaction using
> vtkRenderWindowInteraction. I'm doing somehting similar.
>
> The problem i faced is i do not know how to specify the char pressed.
>
> For eg, i only want the message box to appear when i pressed 'c'.
> However, the message box will appear no matter which keys i pressed.
>
> I might have misunderstood the example codes somewhere. Can you offer
> some advice?
>
> Thanks!
>
> PS: Below is my codes
>
> class ChairmanCallback :public vtkCommand {
> public:
> static ChairmanCallback *New()
> {return new ChairmanCallback;}
> virtual void Execute (
> vtkObject *caller,
> unsigned long,
> void * )
> {
> AfxMessageBox ("C is pressed.");
> }
> protected:
> ChairmanCallback();
> ~ChairmanCallback();
> };
>
> ChairmanCallback *callback_1 = ChairmanCallback::New();
> irenMain->AddObserver (vtkCommand::CharEvent, callback_1, 0);
> irenMain->Initialize();
> irenMain->Start();
>
More information about the vtkusers
mailing list