]> Creatis software - cpPlugins.git/blob - example_BaseInteractorStyle.cxx
922511abed03b96da51e24dc9006ebd61179b326
[cpPlugins.git] / example_BaseInteractorStyle.cxx
1
2 #include <vtkSmartPointer.h>
3
4 #include <vtkRenderer.h>
5 #include <vtkRenderWindow.h>
6 #include <vtkRenderWindowInteractor.h>
7 #include <cpExtensions/Visualization/BaseInteractorStyle.h>
8
9 // -------------------------------------------------------------------------
10 #define example_BaseInteractorStyle_Macro( x )  \
11   virtual void On##x( )                         \
12   { std::cout << "On" << #x << "( )" << std::endl; }
13
14 // -------------------------------------------------------------------------
15 class example_BaseInteractorStyle
16   : public cpExtensions::Visualization::BaseInteractorStyle
17 {
18 public:
19   typedef example_BaseInteractorStyle Self;
20   vtkTypeMacro(
21     example_BaseInteractorStyle,
22     cpExtensions::Visualization::BaseInteractorStyle
23     );
24
25 public:
26   static Self* New( )
27     { return( new Self ); }
28
29   // Possible events
30   example_BaseInteractorStyle_Macro( MouseMove );
31   example_BaseInteractorStyle_Macro( MouseWheelForward );
32   example_BaseInteractorStyle_Macro( MouseWheelBackward );
33   example_BaseInteractorStyle_Macro( LeftButtonDown );
34   example_BaseInteractorStyle_Macro( LeftButtonUp );
35   example_BaseInteractorStyle_Macro( LeftClick );
36   example_BaseInteractorStyle_Macro( LeftDoubleClick );
37   example_BaseInteractorStyle_Macro( MiddleButtonDown );
38   example_BaseInteractorStyle_Macro( MiddleButtonUp );
39   example_BaseInteractorStyle_Macro( MiddleClick );
40   example_BaseInteractorStyle_Macro( MiddleDoubleClick );
41   example_BaseInteractorStyle_Macro( RightButtonDown );
42   example_BaseInteractorStyle_Macro( RightButtonUp );
43   example_BaseInteractorStyle_Macro( RightClick );
44   example_BaseInteractorStyle_Macro( RightDoubleClick );
45   example_BaseInteractorStyle_Macro( Char );
46   example_BaseInteractorStyle_Macro( KeyDown );
47   example_BaseInteractorStyle_Macro( KeyUp );
48   example_BaseInteractorStyle_Macro( KeyPress );
49   example_BaseInteractorStyle_Macro( KeyRelease );
50   example_BaseInteractorStyle_Macro( Expose );
51   example_BaseInteractorStyle_Macro( Configure );
52   example_BaseInteractorStyle_Macro( Enter );
53   example_BaseInteractorStyle_Macro( Leave );
54
55 protected:
56   example_BaseInteractorStyle( )
57     : Superclass( )
58     { }
59   virtual ~example_BaseInteractorStyle( )
60     { }
61
62 private:
63   // Purposely not implemented
64   example_BaseInteractorStyle( const Self& );
65   Self& operator=( const Self& );
66 };
67
68 // -------------------------------------------------------------------------
69 int main( int argc, char* argv[] )
70 {
71   // Configure visualization objects
72   vtkSmartPointer< vtkRenderer > renderer =
73     vtkSmartPointer< vtkRenderer >::New( );
74   renderer->SetBackground( 0.1, 0.3, 0.5 );
75
76   vtkSmartPointer< vtkRenderWindow > window =
77     vtkSmartPointer< vtkRenderWindow >::New( );
78   window->AddRenderer( renderer );
79   window->SetSize( 600, 600 );
80
81   // Set up interaction style
82   vtkSmartPointer< example_BaseInteractorStyle > style =
83     vtkSmartPointer< example_BaseInteractorStyle >::New( );
84
85   // Set up the interaction
86   vtkSmartPointer< vtkRenderWindowInteractor > interactor =
87     vtkSmartPointer< vtkRenderWindowInteractor >::New( );
88   interactor->SetInteractorStyle( style );
89   window->SetInteractor( interactor );
90
91   // Begin interaction
92   window->Render( );
93   interactor->Start( );
94
95   return( 0 );
96 }
97
98 // eof - $RCSfile$