1 #include <cpExtensions/Interaction/SeedWidget.h>
3 #include <vtkCallbackCommand.h>
4 #include <vtkCommand.h>
5 #include <vtkRenderWindowInteractor.h>
6 #include <vtkSeedRepresentation.h>
7 #include <vtkWidgetEventTranslator.h>
8 #include <vtkWidgetRepresentation.h>
10 // -------------------------------------------------------------------------
11 cpExtensions::Interaction::SeedWidget::
12 Self* cpExtensions::Interaction::SeedWidget::
18 // -------------------------------------------------------------------------
19 void cpExtensions::Interaction::SeedWidget::
20 SetInteractor( vtkRenderWindowInteractor* rwi )
22 this->Superclass::SetInteractor( rwi );
26 dynamic_cast< TBaseStyle* >( rwi->GetInteractorStyle( ) );
29 s->AddMouseClickCommand( Self::_Click, this );
30 s->AddMouseDoubleClickCommand( Self::_DoubleClick, this );
37 // -------------------------------------------------------------------------
38 cpExtensions::Interaction::SeedWidget::
42 // Remove default translations
43 vtkWidgetEventTranslator* t = this->GetEventTranslator( );
44 t->RemoveTranslation( vtkCommand::LeftButtonPressEvent );
45 t->RemoveTranslation( vtkCommand::MiddleButtonPressEvent );
46 t->RemoveTranslation( vtkCommand::RightButtonPressEvent );
49 // -------------------------------------------------------------------------
50 cpExtensions::Interaction::SeedWidget::
55 // -------------------------------------------------------------------------
56 void cpExtensions::Interaction::SeedWidget::
58 void* data, const TBaseStyle::ButtonID& button,
59 int* idx, double* pos, bool alt, bool ctr, bool sft
62 SeedWidget* self = reinterpret_cast< SeedWidget* >( data );
65 if( self->WidgetState == vtkSeedWidget::MovingSeed )
68 int st = self->WidgetRep->ComputeInteractionState( idx[ 0 ], idx[ 1 ] );
69 if( st == vtkSeedRepresentation::NearSeed )
71 self->WidgetState = vtkSeedWidget::MovingSeed;
73 // Invoke an event on ourself for the handles
74 self->InvokeEvent( vtkCommand::LeftButtonPressEvent, NULL );
75 self->Superclass::StartInteraction( );
76 self->InvokeEvent( vtkCommand::StartInteractionEvent, NULL );
77 self->EventCallbackCommand->SetAbortFlag( 1 );
83 // -------------------------------------------------------------------------
84 void cpExtensions::Interaction::SeedWidget::
86 void* data, const TBaseStyle::ButtonID& button,
87 int* idx, double* pos, bool alt, bool ctr, bool sft
90 Self::AddPointAction( reinterpret_cast< vtkAbstractWidget* >( data ) );