]> Creatis software - cpPlugins.git/blob - lib/ivq/VTK/SeedWidget.cxx
be432059e3a4aac51cb0ca4db271919406389eaf
[cpPlugins.git] / lib / ivq / VTK / SeedWidget.cxx
1 /* =======================================================================
2  * @author: Leonardo Florez-Valencia
3  * @email: florez-l@javeriana.edu.co
4  * =======================================================================
5  */
6
7 #include <ivq/VTK/SeedWidget.h>
8
9 #include <vtkEvent.h>
10 #include <vtkRenderWindowInteractor.h>
11 #include <vtkWidgetCallbackMapper.h>
12 #include <vtkWidgetEvent.h>
13
14 // -------------------------------------------------------------------------
15 ivq::VTK::SeedWidget::
16 Self* ivq::VTK::SeedWidget::
17 New( )
18 {
19   return( new Self );
20 }
21
22 // -------------------------------------------------------------------------
23 ivq::VTK::SeedWidget::
24 SeedWidget( )
25   : Superclass( )
26 {
27   // These are the event callbacks supported by this widget
28   this->CallbackMapper->SetCallbackMethod(
29     vtkCommand::LeftButtonPressEvent,
30     vtkWidgetEvent::AddPoint,
31     this, Self::_AddPointAction
32     );
33   this->CallbackMapper->SetCallbackMethod(
34     vtkCommand::RightButtonPressEvent,
35     vtkWidgetEvent::Completed,
36     this, Self::_CompletedAction
37     );
38   this->CallbackMapper->SetCallbackMethod(
39     vtkCommand::MouseMoveEvent,
40     vtkWidgetEvent::Move,
41     this, Self::_MoveAction
42     );
43   this->CallbackMapper->SetCallbackMethod(
44     vtkCommand::LeftButtonReleaseEvent,
45     vtkWidgetEvent::EndSelect,
46     this, Self::_EndSelectAction
47     );
48   this->CallbackMapper->SetCallbackMethod(
49     vtkCommand::KeyPressEvent,
50     vtkEvent::NoModifier, 127, 1, "Delete",
51     vtkWidgetEvent::Delete,
52     this, Self::_DeleteAction
53     );
54 }
55
56 // -------------------------------------------------------------------------
57 ivq::VTK::SeedWidget::
58 ~SeedWidget( )
59 {
60 }
61
62 // -------------------------------------------------------------------------
63 void ivq::VTK::SeedWidget::
64 _AddPointAction( vtkAbstractWidget* wdg )
65 {
66   Self* self = dynamic_cast< Self* >( wdg );
67   if( self == NULL )
68     return;
69   vtkRenderWindowInteractor* iren = self->GetInteractor( );
70   if( iren == NULL )
71     return;
72   int shift = iren->GetShiftKey( );
73   if( shift == 1 )
74     Self::AddPointAction( wdg );
75 }
76
77 // -------------------------------------------------------------------------
78 void ivq::VTK::SeedWidget::
79 _CompletedAction( vtkAbstractWidget* wdg )
80 {
81   // Do nothing
82   Self::CompletedAction( wdg );
83 }
84
85 // -------------------------------------------------------------------------
86 void ivq::VTK::SeedWidget::
87 _MoveAction( vtkAbstractWidget* wdg )
88 {
89   // Do nothing
90   Self::MoveAction( wdg );
91 }
92
93 // -------------------------------------------------------------------------
94 void ivq::VTK::SeedWidget::
95 _EndSelectAction( vtkAbstractWidget* wdg )
96 {
97   // Do nothing
98   Self::EndSelectAction( wdg );
99 }
100
101 // -------------------------------------------------------------------------
102 void ivq::VTK::SeedWidget::
103 _DeleteAction( vtkAbstractWidget* wdg )
104 {
105   // Do nothing
106   Self::DeleteAction( wdg );
107 }
108
109 // eof - $RCSfile$