Salome HOME
First stage of the "0021793: [CEA 625] Clipping : from coordinates or from bounding...
[modules/gui.git] / src / SVTK / SVTK_RenderWindowInteractor.cxx
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  SALOME VTKViewer : build VTK viewer into Salome desktop
24 //  File   : 
25 //  Author : 
26
27 #include "SVTK_RenderWindowInteractor.h"
28
29 #include "SVTK_InteractorStyle.h"
30 #include "SVTK_Renderer.h"
31 #include "SVTK_Functor.h"
32 #include "SALOME_Actor.h"
33
34 // QT Includes
35 // Put Qt includes before the X11 includes which #define the symbol None
36 // (see SVTK_SpaceMouse.h) to avoid the compilation error.
37 #ifndef WIN32
38 # include <QX11Info>
39 #endif
40 #include <QMouseEvent>
41
42 #include "SVTK_SpaceMouse.h" 
43 #include "SVTK_Event.h" 
44
45 #include "VTKViewer_Algorithm.h"
46
47 // VTK Includes
48 #include <vtkObjectFactory.h>
49 #include <vtkRendererCollection.h>
50 #include <vtkRenderWindow.h>
51 #include <vtkGenericRenderWindowInteractor.h>
52 #include <vtkCallbackCommand.h>
53 #include <vtkCommand.h>
54 #include <vtkPicker.h>
55 #include <vtkCamera.h>
56
57 static bool GENERATE_SUIT_EVENTS = true;
58 static bool FOCUS_UNDER_MOUSE = false;
59
60
61 /*!
62   Constructor
63 */
64 QVTK_RenderWindowInteractor
65 ::QVTK_RenderWindowInteractor(QWidget* theParent, 
66                               const char* theName):
67   QWidget(theParent),
68   myRenderWindow(vtkRenderWindow::New())
69 {
70   setAttribute( Qt::WA_PaintOnScreen );
71   setAttribute( Qt::WA_NoSystemBackground );
72
73   setObjectName(theName);
74
75   setMouseTracking(true);
76
77   myRenderWindow->Delete();
78   myRenderWindow->DoubleBufferOn();
79
80 #ifndef WIN32
81   myRenderWindow->SetDisplayId((void*)QX11Info::display());
82 #endif
83   myRenderWindow->SetWindowId((void*)winId());
84 }
85
86 /*!
87   To initialize by vtkGenericRenderWindowInteractor instance
88 */
89 void 
90 QVTK_RenderWindowInteractor
91 ::Initialize(vtkGenericRenderWindowInteractor* theDevice)
92 {
93   if ( GetDevice() )
94     myDevice->SetRenderWindow( NULL );
95
96   myDevice = theDevice;
97
98   if ( theDevice )
99     theDevice->SetRenderWindow( getRenderWindow() );
100 }
101
102 /*!
103   Destructor
104 */
105 QVTK_RenderWindowInteractor
106 ::~QVTK_RenderWindowInteractor() 
107 {
108 #ifndef WIN32
109   SVTK_SpaceMouse* aSpaceMouse = SVTK_SpaceMouse::getInstance();
110   if ( aSpaceMouse && aSpaceMouse->isSpaceMouseOn() )
111     aSpaceMouse->close( QX11Info::display() );
112 #endif
113 }
114
115
116 /*!
117   \return corresponding render window interactor
118 */
119 vtkGenericRenderWindowInteractor* 
120 QVTK_RenderWindowInteractor
121 ::GetDevice()
122 {
123   return myDevice.GetPointer();
124 }
125
126 /*!
127   \return corresponding render window
128 */
129 vtkRenderWindow*
130 QVTK_RenderWindowInteractor
131 ::getRenderWindow()
132 {
133   return myRenderWindow.GetPointer();
134 }
135
136 /*!
137   Just to simplify usage of its device (vtkGenericRenderWindowInteractor)
138 */
139 void
140 QVTK_RenderWindowInteractor
141 ::InvokeEvent(unsigned long theEvent, void* theCallData)
142 {
143   GetDevice()->InvokeEvent(theEvent,theCallData);
144 }
145
146 /*!
147   Get paint engine for the scene
148 */
149 QPaintEngine* QVTK_RenderWindowInteractor::paintEngine() const
150 {
151   return 0;
152 }
153
154 /*!
155   Need for initial contents display on Win32
156 */
157 void
158 QVTK_RenderWindowInteractor
159 ::show()
160 {
161   QWidget::show();
162   update(); // needed for initial contents display on Win32
163 }
164
165 /*!
166   To implement final initialization, just before the widget is displayed
167 */
168 void
169 QVTK_RenderWindowInteractor
170 ::polish()
171 {
172   // Final initialization just before the widget is displayed
173   GetDevice()->SetSize(width(),height());
174   if(!GetDevice()->GetInitialized() && GetDevice()->GetRenderWindow()){
175     GetDevice()->Initialize();
176     GetDevice()->ConfigureEvent();
177   }
178 }
179
180 /*!
181   To adjust widget and vtkRenderWindow size
182 */
183 void
184 QVTK_RenderWindowInteractor
185 ::resize(int w, int h) 
186 {
187   GetDevice()->UpdateSize(w,h);
188 }
189
190 /*!
191   Custom paint event handler
192 */
193 void
194 QVTK_RenderWindowInteractor
195 ::paintEvent( QPaintEvent* theEvent ) 
196 {
197   GetDevice()->CreateTimer(VTKI_TIMER_FIRST);
198 }
199
200
201 /*!
202   Custom resize event handler
203 */
204 void
205 QVTK_RenderWindowInteractor
206 ::resizeEvent( QResizeEvent* theEvent )
207 {
208   int* aSize = getRenderWindow()->GetSize();
209   int aWidth = aSize[0];
210   int aHeight = aSize[1];
211
212   GetDevice()->UpdateSize(width(),height());
213
214   if(isVisible() && aWidth && aHeight){
215     if( aWidth != width() || aHeight != height() ) {
216       vtkRendererCollection * aRenderers = getRenderWindow()->GetRenderers();
217       aRenderers->InitTraversal();
218       double aCoeff = 1.0;
219       if(vtkRenderer *aRenderer = aRenderers->GetNextItem()) {
220         vtkCamera *aCamera = aRenderer->GetActiveCamera();
221         double aScale = aCamera->GetParallelScale();
222         if((aWidth - width())*(aHeight - height()) > 0)
223           aCoeff = sqrt(double(aWidth)/double(width())*double(height())/double(aHeight));
224         else
225           aCoeff = double(aWidth)/double(width());
226         aCamera->SetParallelScale(aScale*aCoeff);
227       }
228     }
229   }
230
231   update(); 
232 }
233
234
235
236 /*!
237   Custom context menu event handler
238 */
239 void
240 QVTK_RenderWindowInteractor
241 ::contextMenuEvent( QContextMenuEvent* event )
242 {}
243
244 /*!
245   Custom mouse move event handler
246 */
247 void
248 QVTK_RenderWindowInteractor
249 ::mouseMoveEvent( QMouseEvent* event ) 
250 {
251   GetDevice()->SetEventInformationFlipY(event->x(), 
252                                         event->y(),
253                                         event->modifiers() & Qt::ControlModifier,
254                                         event->modifiers() & Qt::ShiftModifier);
255   GetDevice()->MouseMoveEvent();
256 }
257
258
259 /*!
260   Custom mouse press event handler
261 */
262 void
263 QVTK_RenderWindowInteractor
264 ::mousePressEvent( QMouseEvent* event ) 
265 {
266   GetDevice()->SetEventInformationFlipY(event->x(), 
267                                         event->y(),
268                                         event->modifiers() & Qt::ControlModifier,
269                                         event->modifiers() & Qt::ShiftModifier);
270   if( event->button() & Qt::LeftButton )
271     GetDevice()->LeftButtonPressEvent();
272   else if( event->button() & Qt::MidButton )
273     GetDevice()->MiddleButtonPressEvent();
274   else if( event->button() & Qt::RightButton )
275     GetDevice()->RightButtonPressEvent();
276 }
277
278
279 /*!
280   Custom mouse release event handler
281 */
282 void
283 QVTK_RenderWindowInteractor
284 ::mouseReleaseEvent( QMouseEvent *event )
285 {
286   GetDevice()->SetEventInformationFlipY(event->x(), 
287                                         event->y(),
288                                         event->modifiers() & Qt::ControlModifier,
289                                         event->modifiers() & Qt::ShiftModifier);
290
291   if( event->button() & Qt::LeftButton )
292     GetDevice()->LeftButtonReleaseEvent();
293   else if( event->button() & Qt::MidButton )
294     GetDevice()->MiddleButtonReleaseEvent();
295   else if( event->button() & Qt::RightButton ) {
296     #ifndef Fix_Of_vtkImplicitPlaneWidget_bug
297     GetDevice()->SetEventInformationFlipY( -99999, -99999,
298                                            event->modifiers() & Qt::ControlModifier,
299                                            event->modifiers() & Qt::ShiftModifier);
300     GetDevice()->LeftButtonPressEvent();
301     GetDevice()->LeftButtonReleaseEvent();
302     GetDevice()->SetEventInformationFlipY(event->x(),
303                                           event->y(),
304                                           event->modifiers() & Qt::ControlModifier,
305                                           event->modifiers() & Qt::ShiftModifier);
306     #endif
307     GetDevice()->RightButtonReleaseEvent();
308   }
309 }
310
311
312 /*!
313   Custom mouse double click event handler
314 */
315 void
316 QVTK_RenderWindowInteractor
317 ::mouseDoubleClickEvent( QMouseEvent* event )
318 {}
319
320
321 /*!
322   Custom mouse wheel event handler
323 */
324 void
325 QVTK_RenderWindowInteractor
326 ::wheelEvent( QWheelEvent* event )
327 {
328   activateWindow();
329   setFocus();
330   GetDevice()->SetEventInformationFlipY(event->x(), 
331                                         event->y(),
332                                         event->modifiers() & Qt::ControlModifier,
333                                         event->modifiers() & Qt::ShiftModifier);
334   if ( event->delta()>0)
335     GetDevice()->MouseWheelForwardEvent();
336   else
337     GetDevice()->MouseWheelBackwardEvent();
338 }
339
340
341 /*!
342   Custom key press event handler
343 */
344 void
345 QVTK_RenderWindowInteractor
346 ::keyPressEvent( QKeyEvent* event ) 
347 {
348   GetDevice()->SetKeyEventInformation(event->modifiers() & Qt::ControlModifier,
349                                       event->modifiers() & Qt::ShiftModifier,
350                                       event->key());
351   GetDevice()->KeyPressEvent();
352   GetDevice()->CharEvent();
353 }
354
355 /*!
356   Custom key release event handler
357 */
358 void
359 QVTK_RenderWindowInteractor
360 ::keyReleaseEvent( QKeyEvent * event ) 
361 {
362   GetDevice()->SetKeyEventInformation(event->modifiers() & Qt::ControlModifier,
363                                       event->modifiers() & Qt::ShiftModifier,
364                                       event->key());
365   GetDevice()->KeyReleaseEvent();
366 }
367
368
369 /*!
370   Custom enter event handler
371 */
372 void  
373 QVTK_RenderWindowInteractor
374 ::enterEvent( QEvent* event )
375 {
376   if(FOCUS_UNDER_MOUSE){
377     activateWindow();
378     setFocus();
379   }
380   GetDevice()->EnterEvent();
381 }
382
383 /*!
384   Custom leave event handler
385 */
386 void  
387 QVTK_RenderWindowInteractor
388 ::leaveEvent( QEvent * )
389 {
390   GetDevice()->LeaveEvent();
391 }
392
393 /*!
394   Reimplemented from QWidget in order to set window - receiver
395   of space mouse events. 
396 */
397 void  
398 QVTK_RenderWindowInteractor
399 ::focusInEvent( QFocusEvent* event )
400 {
401   QWidget::focusInEvent( event );
402
403 #ifndef WIN32
404   // register set space mouse events receiver
405   SVTK_SpaceMouse* aSpaceMouse = SVTK_SpaceMouse::getInstance();
406
407   if ( aSpaceMouse )
408   {
409     if ( !aSpaceMouse->isSpaceMouseOn() )
410       // initialize 3D space mouse driver 
411       aSpaceMouse->initialize( QX11Info::display(), winId() );
412     else
413       aSpaceMouse->setWindow( QX11Info::display(), winId() );
414   }
415 #endif
416 }
417
418 /*!
419   Reimplemented from QWidget in order to set window - receiver
420   of space mouse events. 
421 */
422 void  
423 QVTK_RenderWindowInteractor
424 ::focusOutEvent ( QFocusEvent* event )
425 {
426   QWidget::focusOutEvent( event );
427
428 #ifndef WIN32
429   // unregister set space mouse events receiver
430   SVTK_SpaceMouse* aSpaceMouse = SVTK_SpaceMouse::getInstance();
431   if ( aSpaceMouse && aSpaceMouse->isSpaceMouseOn() )
432     aSpaceMouse->setWindow( QX11Info::display(), 0 );
433 #endif
434 }
435
436
437 #ifdef WIN32
438
439 /*!
440   To handle native Win32 events (from such devices as SpaceMouse)
441 */
442 bool QVTK_RenderWindowInteractor::winEvent( MSG* msg, long* result )
443 {
444   // TODO: Implement event handling for SpaceMouse
445   return QWidget::winEvent( msg, result);
446 }
447
448 #else
449
450 /*!
451   To handle native X11 events (from such devices as SpaceMouse)
452 */
453 bool 
454 QVTK_RenderWindowInteractor
455 ::x11Event( XEvent *xEvent )
456 {
457   // handle 3d space mouse events
458   if ( SVTK_SpaceMouse* aSpaceMouse = SVTK_SpaceMouse::getInstance() )
459   {
460     if ( aSpaceMouse->isSpaceMouseOn() && xEvent->type == ClientMessage )
461     {
462       SVTK_SpaceMouse::MoveEvent anEvent;
463       int type = aSpaceMouse->translateEvent( QX11Info::display(), xEvent, &anEvent, 1.0, 1.0 );
464       switch ( type )
465       {
466       case SVTK_SpaceMouse::SpaceMouseMove:
467               GetDevice()->InvokeEvent( SVTK::SpaceMouseMoveEvent, anEvent.data );
468               break;
469       case SVTK_SpaceMouse::SpaceButtonPress:
470               GetDevice()->InvokeEvent( SVTK::SpaceMouseButtonEvent, &anEvent.button );
471               break;
472       case SVTK_SpaceMouse::SpaceButtonRelease:
473               break;
474       }
475       return true; // stop handling the event
476     }
477   }
478
479   return QWidget::x11Event( xEvent );
480 }
481
482 #endif
483
484 /*!
485   Constructor
486 */
487 SVTK_RenderWindowInteractor
488 ::SVTK_RenderWindowInteractor(QWidget* theParent, 
489                                const char* theName):
490   QVTK_RenderWindowInteractor(theParent,theName),
491   myEventCallbackCommand(vtkCallbackCommand::New())
492 {
493   myEventCallbackCommand->Delete();
494
495   myEventCallbackCommand->SetClientData(this); 
496   myPriority = 0.0;
497
498   myEventCallbackCommand->SetCallback(SVTK_RenderWindowInteractor::ProcessEvents);
499 }
500
501 /*!
502   To initialize properly the class
503 */
504 void
505 SVTK_RenderWindowInteractor
506 ::Initialize(vtkGenericRenderWindowInteractor* theDevice,
507              SVTK_Renderer* theRenderer,
508              SVTK_Selector* theSelector)
509 {
510   QVTK_RenderWindowInteractor::Initialize(theDevice);
511   SetRenderer(theRenderer);
512   SetSelector(theSelector);
513 }
514
515 /*!
516   Destructor
517 */
518 SVTK_RenderWindowInteractor
519 ::~SVTK_RenderWindowInteractor() 
520 {
521   // Sequence of the destruction call are fixed and should be changed.
522   // vtkRenderWindow instance should be destroyed after all vtkRenderer's
523   GetDevice()->SetInteractorStyle(NULL); 
524   while(!myInteractorStyles.empty()){
525     const PInteractorStyle& aStyle = myInteractorStyles.top();
526     aStyle->SetInteractor(NULL);
527     myInteractorStyles.pop();
528   }
529
530   SetRenderer(NULL);
531
532   GetDevice()->SetRenderWindow(NULL);
533 }
534
535 /*!
536   To get corresponding SVTK_Renderer instance
537 */
538 SVTK_Renderer* 
539 SVTK_RenderWindowInteractor
540 ::GetRenderer()
541 {
542   return myRenderer.GetPointer();
543 }
544
545 /*!
546   To get corresponding SVTK_Renderer device (just to simplify collobaration with SVTK_Renderer)
547 */
548 vtkRenderer* 
549 SVTK_RenderWindowInteractor
550 ::getRenderer()
551 {
552   return GetRenderer()->GetDevice();
553 }
554
555 /*!
556   Changes renderer
557   \param theRenderer - new renderer
558 */
559 void
560 SVTK_RenderWindowInteractor
561 ::SetRenderer(SVTK_Renderer* theRenderer)
562 {
563   if(theRenderer == myRenderer.GetPointer())
564     return;
565
566   if(GetRenderer())
567     myRenderWindow->RemoveRenderer(getRenderer());
568
569   myRenderer = theRenderer;
570
571   if(GetRenderer())
572     myRenderWindow->AddRenderer(getRenderer());
573 }
574
575
576 /*!
577   Changes interactor style
578   \param theStyle - new interactor style
579 */
580 void
581 SVTK_RenderWindowInteractor
582 ::InitInteractorStyle(vtkInteractorStyle* theStyle)
583 {
584   GetDevice()->SetInteractorStyle(theStyle); 
585 }
586
587 /*!
588   To change current interactor style by pushing the new one into the container
589 */
590 void
591 SVTK_RenderWindowInteractor
592 ::PushInteractorStyle(vtkInteractorStyle* theStyle)
593 {
594   myInteractorStyles.push(PInteractorStyle(theStyle));
595   InitInteractorStyle(theStyle);
596 }
597
598 /*!
599   To restore previous interactor style
600 */
601 void
602 SVTK_RenderWindowInteractor
603 ::PopInteractorStyle()
604 {
605   if(GetInteractorStyle())
606     myInteractorStyles.pop();
607   
608   if(GetInteractorStyle()) 
609     InitInteractorStyle(GetInteractorStyle());
610 }
611
612 /*!
613   To get current interactor style
614 */
615 vtkInteractorStyle* 
616 SVTK_RenderWindowInteractor
617 ::GetInteractorStyle()
618 {
619   return myInteractorStyles.empty() ? 0 : myInteractorStyles.top().GetPointer();
620 }
621
622
623 /*!
624   To get current selector
625 */
626 SVTK_Selector* 
627 SVTK_RenderWindowInteractor
628 ::GetSelector() 
629
630   return mySelector.GetPointer(); 
631 }
632
633
634 /*!
635   Changes selector
636   \param theSelector - new selector
637 */
638 void
639 SVTK_RenderWindowInteractor
640 ::SetSelector(SVTK_Selector* theSelector)
641
642   if(mySelector.GetPointer())
643     mySelector->RemoveObserver(myEventCallbackCommand.GetPointer());
644
645   mySelector = theSelector; 
646
647   if(mySelector.GetPointer())
648     mySelector->AddObserver(vtkCommand::EndPickEvent, 
649                             myEventCallbackCommand.GetPointer(), 
650                             myPriority);
651 }
652
653 /*!
654   Main process VTK event method
655 */
656 void 
657 SVTK_RenderWindowInteractor
658 ::ProcessEvents(vtkObject* vtkNotUsed(theObject), 
659                 unsigned long theEvent,
660                 void* theClientData, 
661                 void* vtkNotUsed(theCallData))
662 {
663   SVTK_RenderWindowInteractor* self = reinterpret_cast<SVTK_RenderWindowInteractor*>(theClientData);
664
665   switch(theEvent){
666   case vtkCommand::EndPickEvent:
667     self->onEmitSelectionChanged();
668     break;
669   }
670 }
671
672 /*!
673   To change selection mode (just to simplify collobaration with SVTK_Selector)
674 */
675 void
676 SVTK_RenderWindowInteractor
677 ::SetSelectionMode(Selection_Mode theMode)
678 {
679   mySelector->SetSelectionMode(theMode);
680 }
681
682 /*!
683   To get current selection mode (just to simplify collobaration with SVTK_Selector)
684 */
685 Selection_Mode
686 SVTK_RenderWindowInteractor
687 ::SelectionMode() const
688 {
689   return mySelector->SelectionMode();
690 }
691
692
693 /*!
694   Emits signal selectionChanged()
695 */
696 void
697 SVTK_RenderWindowInteractor
698 ::onEmitSelectionChanged()
699 {
700   return emit selectionChanged();
701 }
702
703
704 /*!
705   Custom mouse move event handler
706 */
707 void
708 SVTK_RenderWindowInteractor
709 ::mouseMoveEvent( QMouseEvent* event ) 
710 {
711   QVTK_RenderWindowInteractor::mouseMoveEvent(event);
712
713   if(GENERATE_SUIT_EVENTS)
714     emit MouseMove( event );
715 }
716
717
718 /*!
719   Custom mouse press event handler
720 */
721 void
722 SVTK_RenderWindowInteractor
723 ::mousePressEvent( QMouseEvent* event ) 
724 {
725   QVTK_RenderWindowInteractor::mousePressEvent(event);
726
727   if(GENERATE_SUIT_EVENTS)
728     emit MouseButtonPressed( event );
729 }
730
731
732 /*!
733   Custom mouse release event handler
734 */
735 void
736 SVTK_RenderWindowInteractor
737 ::mouseReleaseEvent( QMouseEvent *event )
738 {
739   SVTK_InteractorStyle* style = 0;
740   bool aRightBtn = event->button() == Qt::RightButton;
741   bool isOperation = false;
742   bool isPolygonalSelection = false;
743   if( aRightBtn && GetInteractorStyle()) {
744     style = dynamic_cast<SVTK_InteractorStyle*>( GetInteractorStyle() );
745     if ( style )
746       isOperation = style->CurrentState() != VTK_INTERACTOR_STYLE_CAMERA_NONE;
747   }
748
749   QVTK_RenderWindowInteractor::mouseReleaseEvent(event);
750
751   if ( style ) {
752     isPolygonalSelection = style->GetPolygonState() == Finished;
753     style->SetPolygonState( Disable );
754   }
755
756   if ( aRightBtn && !isOperation && !isPolygonalSelection &&
757        !( event->modifiers() & Qt::ControlModifier ) &&
758        !( event->modifiers() & Qt::ShiftModifier ) ) {
759     QContextMenuEvent aEvent( QContextMenuEvent::Mouse,
760                               event->pos(), event->globalPos() );
761     emit contextMenuRequested( &aEvent );
762   }
763   if(GENERATE_SUIT_EVENTS)
764     emit MouseButtonReleased( event );
765 }
766
767
768 /*!
769   Custom mouse double click event handler
770 */
771 void
772 SVTK_RenderWindowInteractor
773 ::mouseDoubleClickEvent( QMouseEvent* event )
774 {
775   if( GetInteractorStyle() && event->button() == Qt::LeftButton ) {
776     SVTK_InteractorStyle* style = dynamic_cast<SVTK_InteractorStyle*>( GetInteractorStyle() );
777     if ( style )
778       style->OnMouseButtonDoubleClick();
779   }
780
781   QVTK_RenderWindowInteractor::mouseDoubleClickEvent(event);
782
783   if(GENERATE_SUIT_EVENTS)
784     emit MouseDoubleClicked( event );
785 }
786
787
788 /*!
789   Custom mouse wheel event handler
790 */
791 void
792 SVTK_RenderWindowInteractor
793 ::wheelEvent( QWheelEvent* event )
794 {
795   QVTK_RenderWindowInteractor::wheelEvent(event);
796
797   if(event->delta() > 0)
798     GetDevice()->InvokeEvent(SVTK::ZoomInEvent,NULL);
799   else
800     GetDevice()->InvokeEvent(SVTK::ZoomOutEvent,NULL);
801
802   if(GENERATE_SUIT_EVENTS)
803     emit WheelMoved( event );
804 }
805
806 /*!
807   Custom key press event handler
808 */
809 void
810 SVTK_RenderWindowInteractor
811 ::keyPressEvent( QKeyEvent* event ) 
812 {
813   QVTK_RenderWindowInteractor::keyPressEvent(event);
814
815   if(GENERATE_SUIT_EVENTS)
816     emit KeyPressed( event );
817 }
818
819 /*!
820   Custom key release event handler
821 */
822 void
823 SVTK_RenderWindowInteractor
824 ::keyReleaseEvent( QKeyEvent * event ) 
825 {
826   QVTK_RenderWindowInteractor::keyReleaseEvent(event);
827
828   if(GENERATE_SUIT_EVENTS)
829     emit KeyReleased( event );
830 }
831