[vtkusers] How to catch events from vtkContourWidget?
Massimo Bortolato
massimo.bortolato at gmail.com
Mon Dec 10 02:36:21 EST 2012
Hi Alex,
thank you, it works!
I had already taken a look at the source code of vtkContourWidget, but what
I
initially tried to do was to sniff those events in a manner like this:
vtkContourWidget *countour = vtkContourWidget::New();
do smth...
contour->addObserver(vtkWidgetEvent::Select, myCallback);
but it didn't work (and I still can't understand why...)
Instead your way works fine!
Thanks again,
Massimo
Message: 1
Date: Fri, 7 Dec 2012 14:28:20 -0800
From: Alex Malyushytskyy <alexmalvtk at gmail.com>
Subject: Re: [vtkusers] How to catch events from vtkContourWidget?
To: vtkusers at vtk.org
Message-ID:
<CAHR9pJ3SzWMsP=+uN39_rM-zwUj8YbLSaqbCX+R55+EFEhZYRQ at mail.gmail.com>
Content-Type: text/plain; charset=windows-1252
all events vtkContourWidget handles can be found in the source code
constructor
You can see related vtkCommand and vtkWidgetEvent below.
// These are the event callbacks supported by this widget
this->CallbackMapper->SetCallbackMethod(vtkCommand::LeftButtonPressEvent,
vtkWidgetEvent::Select,
this,
vtkContourWidget::SelectAction);
this->CallbackMapper->SetCallbackMethod(vtkCommand::RightButtonPressEvent,
vtkWidgetEvent::AddFinalPoint,
this,
vtkContourWidget::AddFinalPointAction);
this->CallbackMapper->SetCallbackMethod(vtkCommand::MouseMoveEvent,
vtkWidgetEvent::Move,
this,
vtkContourWidget::MoveAction);
this->CallbackMapper->SetCallbackMethod(vtkCommand::LeftButtonReleaseEvent,
vtkWidgetEvent::EndSelect,
this,
vtkContourWidget::EndSelectAction);
this->CallbackMapper->SetCallbackMethod(vtkCommand::KeyPressEvent,
vtkEvent::NoModifier, 127,
1, "Delete",
vtkWidgetEvent::Delete,
this,
vtkContourWidget::DeleteAction);
this->CallbackMapper->SetCallbackMethod(vtkCommand::KeyPressEvent,
vtkEvent::ShiftModifier,
127, 1, "Delete",
vtkWidgetEvent::Reset,
this,
vtkContourWidget::ResetAction);
this->CallbackMapper->SetCallbackMethod(vtkCommand::MiddleButtonPressEvent,
vtkWidgetEvent::Translate,
this,
vtkContourWidget::TranslateContourAction);
this->CallbackMapper->SetCallbackMethod(vtkCommand::MiddleButtonReleaseEvent,
vtkWidgetEvent::EndTranslate,
this,
vtkContourWidget::EndSelectAction);
this->CallbackMapper->SetCallbackMethod(vtkCommand::RightButtonPressEvent,
vtkWidgetEvent::Scale,
this,
vtkContourWidget::ScaleContourAction);
this->CallbackMapper->SetCallbackMethod(vtkCommand::RightButtonReleaseEvent,
vtkWidgetEvent::EndScale,
this,
vtkContourWidget::EndSelectAction);
I have not done this, so it might be better ways, but
I would probably just subclass and add my own even handler doing extra
things you need to be done and call original vtkContourWidget
static class methods if necessary.
In constructor:
this->CallbackMapper->SetCallbackMethod(vtkCommand::LeftButtonPressEvent,
vtkWidgetEvent::Select,
this,
myVtkContourWidget::MySelectAction);
void myVtkContourWidgetSelectAction( vtkAbstractWidget *w )
{
.... doo smth
vtkContourWidget::SelectAction( w );
.... doo smth
}
On Fri, Dec 7, 2012 at 8:35 AM, Massimo Bortolato
<massimo.bortolato at gmail.com> wrote:
> Hi all,
>
> I need to dynamically compute (and display) the perimeter of a
> vtkContourWidget, basically the same way as vtkDistanceWidget works.
> So I?d like to sniff the events generated by the widget, but it seems that
> there aren?t specific events associated with vtkContourWidget, or
> vtkContourRepresentation.
>
> Does anyones of you know how I can do?
>
> Thanks in advance
> Massimo
More information about the vtkusers
mailing list