[vtkusers] obtaining reference to calling class in KeyPressInteractorStyle class
Liam Kurmos
quantum.leaf at googlemail.com
Thu Feb 11 18:38:44 EST 2010
I gave up trying to implement a seperate KeyPressInteractorStyle class
to detect keypresses as i couldn't get a reference to the calling
class.
instead I looked at
http://vtk.org/Wiki/VTK/Examples/KeypressObserver
and trying to make a local call back function in my class. The example
doesn't use classes so i adapted it by making the callback function a
local function in my class.
However when i do this i get a compile error:
In member function ‘void vasFrame::interact()’:
/home/zoizoi/sunLoom/psyforge/VAS/vasFrame.cpp:432: error: no matching
function for call to ‘vtkCallbackCommand::SetCallback(<unresolved
overloaded function type>)’
/usr/local/include/vtk-5.4/vtkCallbackCommand.h:61: note: candidates
are: virtual void vtkCallbackCommand::SetCallback(void (*)(vtkObject*,
long unsigned int, void*, void*))
from the line:
keypressCallback->SetCallback ( this->KeypressCallbackFunction );
i can't see whats wrong with my call back function, why it is deemed
'<unresolved overloaded function type>' it's the same as the example
except it's now a class method called with this->
Can anyone help?
if this is a general c++ issue any guidance on what to google would be
appreciated too.
Liam
On Tue, Feb 9, 2010 at 7:34 PM, Liam Kurmos <quantum.leaf at googlemail.com> wrote:
> Hi All,
>
> I'm trying to implement key press detection.
>
> I followed http://vtk.org/Wiki/VTK/Examples/Interaction/KeypressEvents
> and made an external class KeyPressInteractorStyle.
>
> I have no problem getting the OnKeyPress event to fire as per the
> example, but I can't seem to get a reference to the calling class (i
> want to change an isovalue on keypress).
>
> I can't include the calling class (#include "vasFrame.h") as this
> would create a cyclic dependency, so I tried making a forward
> declaration of the class and using a function to pass the value.
>
> class vasFrame;
> class KeyPressInteractorStyle : public vtkInteractorStyleTrackballCamera
> {
> public:
> static KeyPressInteractorStyle* New();
> virtual void OnKeyPress();
> void passFrameRef(vasFrame* frame);
> vasFrame* frame;
> };
>
> But this class won't compile, complaining of a forward declaration to
> incomplete struct vasFrame.
>
> This is probably trivial and a straight forward c++ pattern but i
> can't seem to get.
> Can anyone tell me the normal vtk way to do this?
>
> regards,
>
> Liam
>
More information about the vtkusers
mailing list