2 #include <vtkSmartPointer.h>
4 #include <vtkRenderer.h>
5 #include <vtkRenderWindow.h>
6 #include <vtkRenderWindowInteractor.h>
7 #include <cpExtensions/Interaction/BaseInteractorStyle.h>
9 // -------------------------------------------------------------------------
10 #define example_BaseInteractorStyle_Macro( x ) \
11 virtual void On##x( ) \
12 { std::cout << "On" << #x << "( )" << std::endl; }
14 // -------------------------------------------------------------------------
15 class example_BaseInteractorStyle
16 : public cpExtensions::Interaction::BaseInteractorStyle
19 typedef example_BaseInteractorStyle Self;
21 example_BaseInteractorStyle,
22 cpExtensions::Interaction::BaseInteractorStyle
27 { return( new Self ); }
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 );
56 example_BaseInteractorStyle( )
59 virtual ~example_BaseInteractorStyle( )
62 virtual bool _PickPosition( int idx[ 2 ], double pos[ 3 ] )
64 return( true ); // Just testing...
68 // Purposely not implemented
69 example_BaseInteractorStyle( const Self& );
70 Self& operator=( const Self& );
73 // -------------------------------------------------------------------------
74 int main( int argc, char* argv[] )
76 // Configure visualization objects
77 vtkSmartPointer< vtkRenderer > renderer =
78 vtkSmartPointer< vtkRenderer >::New( );
79 renderer->SetBackground( 0.1, 0.3, 0.5 );
81 vtkSmartPointer< vtkRenderWindow > window =
82 vtkSmartPointer< vtkRenderWindow >::New( );
83 window->AddRenderer( renderer );
84 window->SetSize( 600, 600 );
86 // Set up interaction style
87 vtkSmartPointer< example_BaseInteractorStyle > style =
88 vtkSmartPointer< example_BaseInteractorStyle >::New( );
90 // Set up the interaction
91 vtkSmartPointer< vtkRenderWindowInteractor > interactor =
92 vtkSmartPointer< vtkRenderWindowInteractor >::New( );
93 interactor->SetInteractorStyle( style );
94 window->SetInteractor( interactor );