[vtkusers] vtkInteractorStyle

Alan McIntyre fusion at thuule.pair.com
Fri Oct 4 19:48:58 EDT 2002


As far as passing function pointers goes, there is a difference between 


and this:


The first one passes the result of a call to function() into the 
SetSomething method, while the second one passes the address of the 
'my_function' function into the SetSomething method.  I think the '&' in 
the second example isn't necessary in the eyes of some (most?) 
compilers, but having it there doesn't do any harm as far as I know. 
The second example is the one you want in your particular case.

As for passing a C++ class method in as the parameter to 
SetLeftButtonPressMethodArgDelete, I'm not exactly sure about the 
'proper' way to do that, since it appears to be expecting a plain C 
function.  What kind of compiler error are you getting?

I don't have the VTK source on my machine here at home right now, so I'm 
kind of in the dark as to the usage/behavior of 
SetLeftButtonPressMethodArgDelete, but I'm wondering if the reason the 
it expects a pointer to a function with a void* parameter is so that 
class methods can be given to it.  If I recall correctly, isn't the 
pointer to the object pushed onto the stack (kind of like an invisible 
first parameter) when calling class methods?   If that's the case, 
perhaps the get_mousePos(void*) method in Steffen's example could be 
passed if it was declared like this:

	void get_MousePos();

Somebody please let me know if I'm totally clueless here; I don't want 
to give Steffen any bad info.


Steffen Oeltze wrote:
> Alan McIntyre wrote:
>> Steffen,
>> The "void(*f)(void *)" parameter is a pointer to a C function that 
>> looks like this:
>> void func(void *);
>> How much that helps you out I don't know. If you could post some more 
>> code I can try to help, even though I haven't done much with VTK in C++.
> The function I use is:
> void SliceView::get_mousePos(void *)
> {
>    ..................
> }
> The function declaration is:
> void get_mousePos(void *);
> The assignment (which doesn't work) of the function:
> interactorStyle->SetLeftButtonPressMethodArgDelete(get_mousePos());
> _______________________________________________
> This is the private VTK discussion list. Please keep messages on-topic. 
> Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers

More information about the vtkusers mailing list