]> Creatis software - cpPlugins.git/blob - lib/cpExtensions/Visualization/BaseInteractorStyle.cxx
Minor refactoring and errors solved
[cpPlugins.git] / lib / cpExtensions / Visualization / BaseInteractorStyle.cxx
1 #include <cpExtensions/Visualization/BaseInteractorStyle.h>
2
3 #include <cmath>
4
5 #include <vtkCallbackCommand.h>
6 #include <vtkCamera.h>
7 #include <vtkRenderer.h>
8 #include <vtkRenderWindowInteractor.h>
9
10 // -------------------------------------------------------------------------
11 long cpExtensions::Visualization::BaseInteractorStyle::_TMouseButtonEvent::
12 MaxDoubleClick = 200; // ms
13
14 // -------------------------------------------------------------------------
15 void cpExtensions::Visualization::BaseInteractorStyle::
16 AddMouseMoveCommand( TMouseCommand command, void* data )
17 {
18   this->m_MouseMoveCommands.push_back(
19     std::pair< TMouseCommand, void* >( command, data )
20     );
21   this->Modified( );
22 }
23
24 // -------------------------------------------------------------------------
25 void cpExtensions::Visualization::BaseInteractorStyle::
26 AddMouseClickCommand( TMouseCommand command, void* data )
27 {
28   this->m_MouseClickCommands.push_back(
29     std::pair< TMouseCommand, void* >( command, data )
30     );
31   this->Modified( );
32 }
33
34 // -------------------------------------------------------------------------
35 void cpExtensions::Visualization::BaseInteractorStyle::
36 AddMouseDoubleClickCommand( TMouseCommand command, void* data )
37 {
38   this->m_MouseDoubleClickCommands.push_back(
39     std::pair< TMouseCommand, void* >( command, data )
40     );
41   this->Modified( );
42 }
43
44 // -------------------------------------------------------------------------
45 void cpExtensions::Visualization::BaseInteractorStyle::
46 AddMouseWheelCommand( TMouseWheelCommand command, void* data )
47 {
48   this->m_MouseWheelCommands.push_back(
49     std::pair< TMouseWheelCommand, void* >( command, data )
50     );
51   this->Modified( );
52 }
53
54 // -------------------------------------------------------------------------
55 void cpExtensions::Visualization::BaseInteractorStyle::
56 AddKeyCommand( TKeyCommand command, void* data )
57 {
58   this->m_KeyCommands.push_back(
59     std::pair< TKeyCommand, void* >( command, data )
60     );
61   this->Modified( );
62 }
63
64 // -------------------------------------------------------------------------
65 void cpExtensions::Visualization::BaseInteractorStyle::
66 AddExposeCommand( TVoidCommand command, void* data )
67 {
68   this->m_ExposeCommands.push_back(
69     std::pair< TVoidCommand, void* >( command, data )
70     );
71   this->Modified( );
72 }
73
74 // -------------------------------------------------------------------------
75 void cpExtensions::Visualization::BaseInteractorStyle::
76 AddConfigureCommand( TVoidCommand command, void* data )
77 {
78   this->m_ConfigureCommands.push_back(
79     std::pair< TVoidCommand, void* >( command, data )
80     );
81   this->Modified( );
82 }
83
84 // -------------------------------------------------------------------------
85 void cpExtensions::Visualization::BaseInteractorStyle::
86 AddEnterCommand( TVoidCommand command, void* data )
87 {
88   this->m_EnterCommands.push_back(
89     std::pair< TVoidCommand, void* >( command, data )
90     );
91   this->Modified( );
92 }
93
94 // -------------------------------------------------------------------------
95 void cpExtensions::Visualization::BaseInteractorStyle::
96 AddLeaveCommand( TVoidCommand command, void* data )
97 {
98   this->m_LeaveCommands.push_back(
99     std::pair< TVoidCommand, void* >( command, data )
100     );
101   this->Modified( );
102 }
103
104 // -------------------------------------------------------------------------
105 void cpExtensions::Visualization::BaseInteractorStyle::
106 DelegateTDxEvent( unsigned long event, void* calldata )
107 {
108   // TODO
109   std::cerr << "No TDx support at this time!" << std::endl;
110   std::exit( 1 );
111 }
112
113 // -------------------------------------------------------------------------
114 void cpExtensions::Visualization::BaseInteractorStyle::
115 OnMouseMove( )
116 {
117   // Get current position on the associated actors
118   vtkRenderWindowInteractor* rwi = this->GetInteractor( );
119   if( rwi == NULL )
120     return;
121
122   // Get modifiers
123   bool alt = ( rwi->GetAltKey( ) == 1 );
124   bool ctr = ( rwi->GetControlKey( ) == 1 );
125   bool sft = ( rwi->GetShiftKey( ) == 1 );
126   ButtonID button = this->GetButtonID( );
127
128   // Invoke possible generic events
129   if( button == Self::ButtonID_Right )
130   {
131     if( !alt && !ctr && !sft )
132     {
133       this->FindPokedRenderer(
134         rwi->GetEventPosition( )[ 0 ],
135         rwi->GetEventPosition( )[ 1 ]
136         );
137       this->Dolly( );
138
139     } // fi
140   }
141   else if( button == Self::ButtonID_Middle )
142   {
143     if( !alt && !ctr && !sft )
144     {
145       this->FindPokedRenderer(
146         rwi->GetEventPosition( )[ 0 ],
147         rwi->GetEventPosition( )[ 1 ]
148         );
149       this->Pan( );
150
151     } // fi
152
153   } // fi
154
155   // Get mouse pointer position
156   double pos[ 3 ];
157   if( !( this->_PickPosition( pos ) ) )
158     return;
159
160   // Invoke possible specialized events
161   for( unsigned int i = 0; i < this->m_MouseMoveCommands.size( ); ++i )
162     this->m_MouseMoveCommands[ i ].first(
163       this->m_MouseMoveCommands[ i ].second, button, pos, alt, ctr, sft
164       );
165 }
166
167 // -------------------------------------------------------------------------
168 void cpExtensions::Visualization::BaseInteractorStyle::
169 OnMouseWheelForward( )
170 {
171   vtkRenderWindowInteractor* rwi = this->GetInteractor( );
172   if( rwi == NULL )
173     return;
174
175   // Invoke possible events
176   for( unsigned int i = 0; i < this->m_MouseWheelCommands.size( ); ++i )
177     this->m_MouseWheelCommands[ i ].first(
178       this->m_MouseWheelCommands[ i ].second, 1,
179       rwi->GetAltKey( ) == 1,
180       rwi->GetControlKey( ) == 1,
181       rwi->GetShiftKey( ) == 1
182       );
183 }
184
185 // -------------------------------------------------------------------------
186 void cpExtensions::Visualization::BaseInteractorStyle::
187 OnMouseWheelBackward( )
188 {
189   vtkRenderWindowInteractor* rwi = this->GetInteractor( );
190   if( rwi == NULL )
191     return;
192
193   // Invoke possible events
194   for( unsigned int i = 0; i < this->m_MouseWheelCommands.size( ); ++i )
195     this->m_MouseWheelCommands[ i ].first(
196       this->m_MouseWheelCommands[ i ].second, -1,
197       rwi->GetAltKey( ) == 1,
198       rwi->GetControlKey( ) == 1,
199       rwi->GetShiftKey( ) == 1
200       );
201 }
202
203 // -------------------------------------------------------------------------
204 void cpExtensions::Visualization::BaseInteractorStyle::
205 OnLeftButtonDown( )
206 {
207   this->m_ActiveButton = Self::ButtonID_Left;
208 }
209
210 // -------------------------------------------------------------------------
211 void cpExtensions::Visualization::BaseInteractorStyle::
212 OnLeftButtonUp( )
213 {
214   this->m_ActiveButton = Self::ButtonID_None;
215 }
216
217 // -------------------------------------------------------------------------
218 void cpExtensions::Visualization::BaseInteractorStyle::
219 OnMiddleButtonDown( )
220 {
221   this->m_ActiveButton = Self::ButtonID_Middle;
222
223   // Get current position on the associated actors
224   vtkRenderWindowInteractor* rwi = this->GetInteractor( );
225   if( rwi == NULL )
226     return;
227
228   // Get modifiers
229   bool alt = ( rwi->GetAltKey( ) == 1 );
230   bool ctr = ( rwi->GetControlKey( ) == 1 );
231   bool sft = ( rwi->GetShiftKey( ) == 1 );
232
233   if( !alt && !ctr && !sft )
234     this->StartPan( );
235 }
236
237 // -------------------------------------------------------------------------
238 void cpExtensions::Visualization::BaseInteractorStyle::
239 OnMiddleButtonUp( )
240 {
241   this->m_ActiveButton = Self::ButtonID_None;
242
243   // Get current position on the associated actors
244   vtkRenderWindowInteractor* rwi = this->GetInteractor( );
245   if( rwi == NULL )
246     return;
247
248   // Get modifiers
249   bool alt = ( rwi->GetAltKey( ) == 1 );
250   bool ctr = ( rwi->GetControlKey( ) == 1 );
251   bool sft = ( rwi->GetShiftKey( ) == 1 );
252
253   switch( this->State )
254   {
255   case VTKIS_PAN:
256     this->EndPan( );
257     break;
258   default:
259     break;
260   } // hctiws
261 }
262
263 // -------------------------------------------------------------------------
264 void cpExtensions::Visualization::BaseInteractorStyle::
265 OnRightButtonDown( )
266 {
267   this->m_ActiveButton = Self::ButtonID_Right;
268
269   // Get current position on the associated actors
270   vtkRenderWindowInteractor* rwi = this->GetInteractor( );
271   if( rwi == NULL )
272     return;
273
274   // Get modifiers
275   bool alt = ( rwi->GetAltKey( ) == 1 );
276   bool ctr = ( rwi->GetControlKey( ) == 1 );
277   bool sft = ( rwi->GetShiftKey( ) == 1 );
278
279   if( !alt && !ctr && !sft )
280     this->StartDolly( );
281 }
282
283 // -------------------------------------------------------------------------
284 void cpExtensions::Visualization::BaseInteractorStyle::
285 OnRightButtonUp( )
286 {
287   this->m_ActiveButton = Self::ButtonID_None;
288
289   // Get current position on the associated actors
290   vtkRenderWindowInteractor* rwi = this->GetInteractor( );
291   if( rwi == NULL )
292     return;
293
294   // Get modifiers
295   bool alt = ( rwi->GetAltKey( ) == 1 );
296   bool ctr = ( rwi->GetControlKey( ) == 1 );
297   bool sft = ( rwi->GetShiftKey( ) == 1 );
298
299   switch( this->State )
300   {
301   case VTKIS_DOLLY:
302     this->EndDolly( );
303     break;
304   default:
305     break;
306   } // hctiws
307 }
308
309 // -------------------------------------------------------------------------
310 void cpExtensions::Visualization::BaseInteractorStyle::
311 OnLeftClick( )
312 {
313   // Get current position on the associated actors
314   vtkRenderWindowInteractor* rwi = this->GetInteractor( );
315   if( rwi == NULL )
316     return;
317
318   // Get mouse pointer position
319   double pos[ 3 ];
320   if( !( this->_PickPosition( pos ) ) )
321     return;
322
323   // Invoke possible events
324   for( unsigned int i = 0; i < this->m_MouseClickCommands.size( ); ++i )
325     this->m_MouseClickCommands[ i ].first(
326       this->m_MouseClickCommands[ i ].second,
327       Self::ButtonID_Left,
328       pos,
329       rwi->GetAltKey( ) == 1,
330       rwi->GetControlKey( ) == 1,
331       rwi->GetShiftKey( ) == 1
332       );
333 }
334
335 // -------------------------------------------------------------------------
336 void cpExtensions::Visualization::BaseInteractorStyle::
337 OnLeftDoubleClick( )
338 {
339   // Get current position on the associated actors
340   vtkRenderWindowInteractor* rwi = this->GetInteractor( );
341   if( rwi == NULL )
342     return;
343
344   // Get mouse pointer position
345   double pos[ 3 ];
346   if( !( this->_PickPosition( pos ) ) )
347     return;
348
349   // Invoke possible events
350   for( unsigned int i = 0; i < this->m_MouseClickCommands.size( ); ++i )
351     this->m_MouseDoubleClickCommands[ i ].first(
352       this->m_MouseDoubleClickCommands[ i ].second,
353       Self::ButtonID_Left,
354       pos,
355       rwi->GetAltKey( ) == 1,
356       rwi->GetControlKey( ) == 1,
357       rwi->GetShiftKey( ) == 1
358       );
359 }
360
361 // -------------------------------------------------------------------------
362 void cpExtensions::Visualization::BaseInteractorStyle::
363 OnMiddleClick( )
364 {
365   // Get current position on the associated actors
366   vtkRenderWindowInteractor* rwi = this->GetInteractor( );
367   if( rwi == NULL )
368     return;
369
370   // Get mouse pointer position
371   double pos[ 3 ];
372   if( !( this->_PickPosition( pos ) ) )
373     return;
374
375   // Invoke possible events
376   for( unsigned int i = 0; i < this->m_MouseClickCommands.size( ); ++i )
377     this->m_MouseClickCommands[ i ].first(
378       this->m_MouseClickCommands[ i ].second,
379       Self::ButtonID_Middle,
380       pos,
381       rwi->GetAltKey( ) == 1,
382       rwi->GetControlKey( ) == 1,
383       rwi->GetShiftKey( ) == 1
384       );
385 }
386
387 // -------------------------------------------------------------------------
388 void cpExtensions::Visualization::BaseInteractorStyle::
389 OnMiddleDoubleClick( )
390 {
391   // Get current position on the associated actors
392   vtkRenderWindowInteractor* rwi = this->GetInteractor( );
393   if( rwi == NULL )
394     return;
395
396   // Get mouse pointer position
397   double pos[ 3 ];
398   if( !( this->_PickPosition( pos ) ) )
399     return;
400
401   // Invoke possible events
402   for( unsigned int i = 0; i < this->m_MouseClickCommands.size( ); ++i )
403     this->m_MouseDoubleClickCommands[ i ].first(
404       this->m_MouseDoubleClickCommands[ i ].second,
405       Self::ButtonID_Middle,
406       pos,
407       rwi->GetAltKey( ) == 1,
408       rwi->GetControlKey( ) == 1,
409       rwi->GetShiftKey( ) == 1
410       );
411 }
412
413 // -------------------------------------------------------------------------
414 void cpExtensions::Visualization::BaseInteractorStyle::
415 OnRightClick( )
416 {
417   // Get current position on the associated actors
418   vtkRenderWindowInteractor* rwi = this->GetInteractor( );
419   if( rwi == NULL )
420     return;
421
422   // Get mouse pointer position
423   double pos[ 3 ];
424   if( !( this->_PickPosition( pos ) ) )
425     return;
426
427   // Invoke possible events
428   for( unsigned int i = 0; i < this->m_MouseClickCommands.size( ); ++i )
429     this->m_MouseClickCommands[ i ].first(
430       this->m_MouseClickCommands[ i ].second,
431       Self::ButtonID_Right,
432       pos,
433       rwi->GetAltKey( ) == 1,
434       rwi->GetControlKey( ) == 1,
435       rwi->GetShiftKey( ) == 1
436       );
437 }
438
439 // -------------------------------------------------------------------------
440 void cpExtensions::Visualization::BaseInteractorStyle::
441 OnRightDoubleClick( )
442 {
443   // Get current position on the associated actors
444   vtkRenderWindowInteractor* rwi = this->GetInteractor( );
445   if( rwi == NULL )
446     return;
447
448   // Get mouse pointer position
449   double pos[ 3 ];
450   if( !( this->_PickPosition( pos ) ) )
451     return;
452
453   // Invoke possible events
454   for( unsigned int i = 0; i < this->m_MouseClickCommands.size( ); ++i )
455     this->m_MouseDoubleClickCommands[ i ].first(
456       this->m_MouseDoubleClickCommands[ i ].second,
457       Self::ButtonID_Right,
458       pos,
459       rwi->GetAltKey( ) == 1,
460       rwi->GetControlKey( ) == 1,
461       rwi->GetShiftKey( ) == 1
462       );
463 }
464
465 // -------------------------------------------------------------------------
466 void cpExtensions::Visualization::BaseInteractorStyle::
467 OnChar( )
468 {
469   vtkRenderWindowInteractor* rwi = this->GetInteractor( );
470   if( rwi == NULL )
471     return;
472
473   // Invoke possible events
474   for( unsigned int i = 0; i < this->m_KeyCommands.size( ); ++i )
475     this->m_KeyCommands[ i ].first(
476       this->m_KeyCommands[ i ].second,
477       rwi->GetKeyCode( )
478       );
479 }
480
481 // -------------------------------------------------------------------------
482 void cpExtensions::Visualization::BaseInteractorStyle::
483 OnKeyDown( )
484 {
485 }
486
487 // -------------------------------------------------------------------------
488 void cpExtensions::Visualization::BaseInteractorStyle::
489 OnKeyUp( )
490 {
491 }
492
493 // -------------------------------------------------------------------------
494 void cpExtensions::Visualization::BaseInteractorStyle::
495 OnKeyPress( )
496 {
497 }
498
499 // -------------------------------------------------------------------------
500 void cpExtensions::Visualization::BaseInteractorStyle::
501 OnKeyRelease( )
502 {
503 }
504
505 // -------------------------------------------------------------------------
506 void cpExtensions::Visualization::BaseInteractorStyle::
507 OnExpose( )
508 {
509   vtkRenderWindowInteractor* rwi = this->GetInteractor( );
510   if( rwi == NULL )
511     return;
512
513   // Invoke possible events
514   for( unsigned int i = 0; i < this->m_ExposeCommands.size( ); ++i )
515     this->m_ExposeCommands[ i ].first( this->m_ExposeCommands[ i ].second );
516 }
517
518 // -------------------------------------------------------------------------
519 void cpExtensions::Visualization::BaseInteractorStyle::
520 OnConfigure( )
521 {
522   vtkRenderWindowInteractor* rwi = this->GetInteractor( );
523   if( rwi == NULL )
524     return;
525
526   // Invoke possible events
527   for( unsigned int i = 0; i < this->m_ConfigureCommands.size( ); ++i )
528     this->m_ConfigureCommands[ i ].first(
529       this->m_ConfigureCommands[ i ].second
530       );
531 }
532
533 // -------------------------------------------------------------------------
534 void cpExtensions::Visualization::BaseInteractorStyle::
535 OnEnter( )
536 {
537   vtkRenderWindowInteractor* rwi = this->GetInteractor( );
538   if( rwi == NULL )
539     return;
540
541   // Invoke possible events
542   for( unsigned int i = 0; i < this->m_EnterCommands.size( ); ++i )
543     this->m_EnterCommands[ i ].first( this->m_EnterCommands[ i ].second );
544 }
545
546 // -------------------------------------------------------------------------
547 void cpExtensions::Visualization::BaseInteractorStyle::
548 OnLeave( )
549 {
550   vtkRenderWindowInteractor* rwi = this->GetInteractor( );
551   if( rwi == NULL )
552     return;
553
554   // Invoke possible events
555   for( unsigned int i = 0; i < this->m_LeaveCommands.size( ); ++i )
556     this->m_LeaveCommands[ i ].first( this->m_LeaveCommands[ i ].second );
557 }
558
559 // -------------------------------------------------------------------------
560 void cpExtensions::Visualization::BaseInteractorStyle::
561 Dolly( )
562 {
563   if( this->CurrentRenderer == NULL )
564     return;
565
566   vtkRenderWindowInteractor* rwi = this->GetInteractor( );
567   double *center = this->CurrentRenderer->GetCenter( );
568   int dy = rwi->GetEventPosition( )[ 1 ] - rwi->GetLastEventPosition( )[ 1 ];
569   double dyf = this->m_MotionFactor * dy / center[ 1 ];
570   this->_Dolly( std::pow( 1.1, dyf ) );
571 }
572
573 // -------------------------------------------------------------------------
574 void cpExtensions::Visualization::BaseInteractorStyle::
575 Pan( )
576 {
577   if( this->CurrentRenderer == NULL )
578     return;
579
580   vtkRenderWindowInteractor* rwi = this->Interactor;
581   double viewFocus[ 4 ], focalDepth, viewPoint[ 3 ];
582   double newPickPoint[ 4 ], oldPickPoint[ 4 ], motionVector[ 3 ];
583
584   // Calculate the focal depth since we'll be using it a lot
585   vtkCamera* camera = this->CurrentRenderer->GetActiveCamera( );
586   camera->GetFocalPoint( viewFocus );
587   this->ComputeWorldToDisplay(
588     viewFocus[ 0 ], viewFocus[ 1 ], viewFocus[ 2 ], viewFocus
589     );
590   focalDepth = viewFocus[ 2 ];
591   this->ComputeDisplayToWorld(
592     rwi->GetEventPosition( )[ 0 ],
593     rwi->GetEventPosition( )[ 1 ],
594     focalDepth,
595     newPickPoint
596     );
597
598   // Has to recalc old mouse point since the viewport has moved,
599   // so can't move it outside the loop
600   this->ComputeDisplayToWorld(
601     rwi->GetLastEventPosition( )[ 0 ],
602     rwi->GetLastEventPosition( )[ 1 ],
603     focalDepth,
604     oldPickPoint
605     );
606
607   // Camera motion is reversed
608   motionVector[ 0 ] = oldPickPoint[ 0 ] - newPickPoint[ 0 ];
609   motionVector[ 1 ] = oldPickPoint[ 1 ] - newPickPoint[ 1 ];
610   motionVector[ 2 ] = oldPickPoint[ 2 ] - newPickPoint[ 2 ];
611
612   camera->GetFocalPoint( viewFocus );
613   camera->GetPosition( viewPoint );
614   camera->SetFocalPoint(
615     motionVector[ 0 ] + viewFocus[ 0 ],
616     motionVector[ 1 ] + viewFocus[ 1 ],
617     motionVector[ 2 ] + viewFocus[ 2 ]
618     );
619   camera->SetPosition(
620     motionVector[ 0 ] + viewPoint[ 0 ],
621     motionVector[ 1 ] + viewPoint[ 1 ],
622     motionVector[ 2 ] + viewPoint[ 2 ]
623     );
624   if( rwi->GetLightFollowCamera( ) )
625     this->CurrentRenderer->UpdateLightsGeometryToFollowCamera( );
626   rwi->Render( );
627 }
628
629 // -------------------------------------------------------------------------
630 cpExtensions::Visualization::BaseInteractorStyle::
631 BaseInteractorStyle( )
632   : Superclass( ),
633     m_MotionFactor( double( 10 ) )
634 {
635   this->m_LeftButtonEvent.Reset( );
636   this->m_MiddleButtonEvent.Reset( );
637   this->m_RightButtonEvent.Reset( );
638   this->m_ActiveButton = Self::ButtonID_None;
639
640   this->EventCallbackCommand->SetCallback( Self::_ProcessEvents );
641 }
642
643 // -------------------------------------------------------------------------
644 cpExtensions::Visualization::BaseInteractorStyle::
645 ~BaseInteractorStyle( )
646 {
647 }
648
649 // -------------------------------------------------------------------------
650 void cpExtensions::Visualization::BaseInteractorStyle::
651 _Dolly( double factor )
652 {
653   if( this->CurrentRenderer == NULL )
654     return;
655
656   vtkCamera* camera = this->CurrentRenderer->GetActiveCamera( );
657   if( camera->GetParallelProjection( ) == 0 )
658   {
659     camera->Dolly( factor );
660     if( this->AutoAdjustCameraClippingRange )
661       this->CurrentRenderer->ResetCameraClippingRange( );
662   }
663   else
664     camera->SetParallelScale( camera->GetParallelScale( ) / factor );
665   if( this->Interactor->GetLightFollowCamera( ) )
666     this->CurrentRenderer->UpdateLightsGeometryToFollowCamera( );
667   this->Interactor->Render( );
668 }
669
670 // -------------------------------------------------------------------------
671 void cpExtensions::Visualization::BaseInteractorStyle::
672 _ProcessEvents(
673   vtkObject* object,
674   unsigned long event,
675   void* clientdata,
676   void* calldata
677   )
678 {
679   // Get active style and interactor
680   Self* s = reinterpret_cast< Self* >( clientdata );
681   if( s == NULL )
682     return;
683
684   // Process events
685   switch( event )
686   {
687   case vtkCommand::MouseMoveEvent:
688   {
689     s->OnMouseMove( );
690   }
691   break;
692   case vtkCommand::LeftButtonPressEvent:
693   {
694     unsigned char nc = s->m_LeftButtonEvent.Clicks( );
695     if( nc == 2 )
696       s->OnLeftDoubleClick( );
697     else if( nc == 1 )
698       s->OnLeftClick( );
699     s->OnLeftButtonDown( );
700   }
701   break;
702   case vtkCommand::LeftButtonReleaseEvent:
703   {
704     s->m_LeftButtonEvent.Release( );
705     s->OnLeftButtonUp( );
706   }
707   break;
708   case vtkCommand::MiddleButtonPressEvent:
709   {
710     unsigned char nc = s->m_MiddleButtonEvent.Clicks( );
711     if( nc == 2 )
712       s->OnMiddleDoubleClick( );
713     else if( nc == 1 )
714       s->OnMiddleClick( );
715     s->OnMiddleButtonDown( );
716   }
717   break;
718   case vtkCommand::MiddleButtonReleaseEvent:
719   {
720     s->m_MiddleButtonEvent.Release( );
721     s->OnMiddleButtonUp( );
722   }
723   break;
724   case vtkCommand::RightButtonPressEvent:
725   {
726     unsigned char nc = s->m_RightButtonEvent.Clicks( );
727     if( nc == 2 )
728       s->OnRightDoubleClick( );
729     else if( nc == 1 )
730       s->OnRightClick( );
731     s->OnRightButtonDown( );
732   }
733   break;
734   case vtkCommand::RightButtonReleaseEvent:
735   {
736     s->m_RightButtonEvent.Release( );
737     s->OnRightButtonUp( );
738   }
739   break;
740   case vtkCommand::MouseWheelForwardEvent:
741   {
742     s->OnMouseWheelForward( );
743   }
744   break;
745   case vtkCommand::MouseWheelBackwardEvent:
746   {
747     s->OnMouseWheelBackward( );
748   }
749   break;
750   case vtkCommand::KeyPressEvent:
751   {
752     s->OnKeyDown( );
753     s->OnKeyPress( );
754   }
755   break;
756   case vtkCommand::KeyReleaseEvent:
757   {
758     s->OnKeyUp( );
759     s->OnKeyRelease( );
760   }
761   break;
762   case vtkCommand::CharEvent:
763   {
764     s->OnChar( );
765   }
766   break;
767   case vtkCommand::ExposeEvent:
768   {
769     s->OnExpose( );
770   }
771   break;
772   case vtkCommand::ConfigureEvent:
773   {
774     s->OnConfigure( );
775   }
776   break;
777   case vtkCommand::EnterEvent:
778   {
779     s->OnEnter( );
780   }
781   break;
782   case vtkCommand::LeaveEvent:
783   {
784     s->OnLeave( );
785   }
786   break;
787   case vtkCommand::TimerEvent:
788   {
789     // Do nothing
790   }
791   break;
792   case vtkCommand::DeleteEvent:
793   {
794     s->SetInteractor( 0 );
795   }
796   break;
797   case vtkCommand::TDxMotionEvent:
798   case vtkCommand::TDxButtonPressEvent:
799   case vtkCommand::TDxButtonReleaseEvent:
800   {
801     s->DelegateTDxEvent( event, calldata );
802   }
803   break;
804   default:
805     break;
806   } // hctiws
807 }
808
809 // eof - $RCSfile$