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