[vtkusers] vtkInteractorStyle

Walter Herrera walter at lncc.br
Mon Oct 7 07:56:28 EDT 2002


Jeremy,

the problem with your code is that the function :
SetLeftButtonPressMethodArgDelete()
is waiting for a NON class member function parameter
or if it is a class member function it must be STATIC.

>static void SliceView::get_mousePos(void *)
>{
>     ...
>}

and call the function as:

>     style->SetLeftButtonPressMethodArgDelete(SliceView::get_mousePos);

or

>     style->SetLeftButtonPressMethodArgDelete(get_mousePos);


My code is as follow:

class CTransferFunctionEditorDialog : public CDialog
{
    ...
    public:
       static CTransferFunctionEditorDialog* CurrentDialog;

       static void StaticButtonPress (void * p);
       void ButtonPress ();

    private:
       ...
       vtkInteractorStyleUser * OCFInteractorStyle;

    ...
}

CTransferFunctionEditorDialog* CTransferFunctionEditorDialog::CurrentDialog 
= NULL;

CTransferFunctionEditorDialog::CTransferFunctionEditorDialog(CWnd* pParent 
/*=NULL*/)
{
    ...
    this->OCFInteractorStyle = vtkInteractorStyleUser::New();
    this->OCFInteractorStyle->SetButtonPressMethod(StaticButtonPress,NULL);
    ...
}

BOOL CTransferFunctionEditorDialog::OnInitDialog()
{
    ...
    CurrentDialog = this;
    ...
}

void CTransferFunctionEditorDialog::StaticButtonPress (void * p)
{
    if (CurrentDialog == NULL) return;
    CurrentDialog->ButtonPress();
}

void CTransferFunctionEditorDialog::ButtonPress ()
{
    ...
}

Walter.


At 06:38 6/10/2002 -0400, you wrote:
>Jeremy Winston wrote:
>
> >Steffen Oeltze wrote:
> >
> >>Alan McIntyre wrote:
> >>
> >>>Steffen,
> >>>
> >>>As far as passing function pointers goes, there is a difference
> >>>between this:
> >>>    obj->SetSomething(my_function());
> >>>and this:
> >>>    obj->SetSomething(&my_function);
> >>>
> >>I receive an error during compiling saying that this is not a valid call
> >>for a member-function.
> >>
> >>obj->SetLeftButtonPressMethodArgDelete(&this->get_mousePos);
> >>
> >
> >Shouldn't it just be
> >
> >        "(this->get_mousePos)" ?
> >
> >(Versus "(&this->get_mousePos)"
> >     or "(this->get_mousePos())" ).
> >
>You are right but this doesn't work either. I have programed a slice
>viewer object which
>has a mapper, a render window and an interactor. Now, I'd like to define
>my own
>vtkInteractorStyleUser. My source code is:
>
>...
>vtkRenderWindowInteractor *intAct = vtkRenderWindowInteractor::New();
>vtkInteractorStyleUser *style = vtkInteractorStyleUser::New();
>     style->SetLeftButtonPressMethodArgDelete(this->get_mousePos);
>     intAct->SetInteractorStyle(style);
>...
>
>void SliceView::get_mousePos(void *)
>{
>     ...
>}
>
>The error I get is:
>
>coversion of parameter 1 from 'void (void *)' to 'void (__cdecl *) (void
>*)' is not possible




More information about the vtkusers mailing list