]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
To provide a SUIT way of event dispatching
authorapo <apo@opencascade.com>
Fri, 19 Aug 2005 06:42:56 +0000 (06:42 +0000)
committerapo <apo@opencascade.com>
Fri, 19 Aug 2005 06:42:56 +0000 (06:42 +0000)
src/SVTK/SVTK_RenderWindow.h
src/SVTK/SVTK_RenderWindowInteractor.cxx
src/SVTK/SVTK_RenderWindowInteractor.h
src/SVTK/SVTK_View.h
src/SVTK/SVTK_ViewWindow.cxx
src/SVTK/SVTK_ViewWindow.h

index b974ccc226ade401d10651bad1c29bd2a095f2ba..b2cd961d94275ec00f4564667f07274f7c254ad6 100644 (file)
@@ -75,8 +75,6 @@ class SVTK_EXPORT SVTK_RenderWindow : public QMainWindow
   //apply existing transformation on adding SALOME_Actor
   void SetScale( double theScale[3] );
   void GetScale( double theScale[3] );
-  //void AddActor( VTKViewer_Actor*, bool update = false );
-  //void RemoveActor(VTKViewer_Actor*, bool update = false);
 
  public slots:
   virtual void activateZoom();
index 92bd0354208e136a95051ee77dc55daccdb1c1fa..30df0835314425a080cfc18c2fcaa62412529846 100644 (file)
@@ -247,6 +247,16 @@ SVTK_RenderWindowInteractor
 }
 
 
+//----------------------------------------------------------------------------
+void
+SVTK_RenderWindowInteractor
+::contextMenuEvent( QContextMenuEvent* event )
+{
+  if( !( event->state() & KeyButtonMask ) )
+    emit contextMenuRequested( event );
+}
+
+
 //----------------------------------------------------------------------------
 void
 SVTK_RenderWindowInteractor
@@ -256,6 +266,8 @@ SVTK_RenderWindowInteractor
                                     ( event->state() & ControlButton ),
                                     ( event->state() & ShiftButton ) );
   myInteractor->MouseMoveEvent();
+
+  emit MouseMove( event );
 }
 
 
@@ -273,6 +285,8 @@ SVTK_RenderWindowInteractor
     myInteractor->MiddleButtonPressEvent();
   else if( event->button() & RightButton )
     myInteractor->RightButtonPressEvent();
+
+  emit MouseButtonPressed( event );
 }
 
 
@@ -291,6 +305,8 @@ SVTK_RenderWindowInteractor
     myInteractor->MiddleButtonReleaseEvent();
   else if( event->button() & RightButton )
     myInteractor->RightButtonReleaseEvent();
+
+  emit MouseButtonReleased( event );
 }
 
 
@@ -298,14 +314,18 @@ SVTK_RenderWindowInteractor
 void
 SVTK_RenderWindowInteractor
 ::mouseDoubleClickEvent( QMouseEvent* event )
-{}
+{
+  emit MouseDoubleClicked( event );
+}
 
 
 //----------------------------------------------------------------------------
 void
 SVTK_RenderWindowInteractor
 ::wheelEvent( QWheelEvent* event )
-{}
+{
+  emit WheelMoved( event );
+}
 
 
 //----------------------------------------------------------------------------
@@ -317,6 +337,8 @@ SVTK_RenderWindowInteractor
                                        ( event->state() & ShiftButton ),
                                        0 );
   myInteractor->KeyPressEvent();
+
+  emit KeyPressed( event );
 }
 
 //----------------------------------------------------------------------------
@@ -328,36 +350,11 @@ SVTK_RenderWindowInteractor
                                        ( event->state() & ShiftButton ),
                                        0 );
   myInteractor->KeyReleaseEvent();
-}
 
-
-//----------------------------------------------------------------------------
-bool 
-SVTK_RenderWindowInteractor
-::x11Event( XEvent *xEvent )
-{
-  // handle 3d space mouse events
-  SVTK_SpaceMouse* sm = SVTK_SpaceMouse::getInstance();
-  if ( sm->isSpaceMouseOn() && xEvent->type == ClientMessage ) {
-    SVTK_SpaceMouse::MoveEvent spaceMouseEvent;
-    int type = sm->translateEvent( x11Display(), xEvent, &spaceMouseEvent, 1.0, 1.0 );
-    switch ( type )
-    {
-    case SVTK_SpaceMouse::SpaceMouseMove : 
-      myInteractor->InvokeEvent( SpaceMouseMoveEvent, spaceMouseEvent.data );
-      break;
-    case SVTK_SpaceMouse::SpaceButtonPress :
-      myInteractor->InvokeEvent( SpaceMouseButtonEvent, &spaceMouseEvent.button );
-      break;
-    case SVTK_SpaceMouse::SpaceButtonRelease :
-      break;
-    }
-    return true; // stop handling the event
-  }
-
-  return SVTK_RenderWindow::x11Event( xEvent );
+  emit KeyReleased( event );
 }
 
+
 //----------------------------------------------------------------------------
 void  
 SVTK_RenderWindowInteractor
@@ -374,6 +371,8 @@ SVTK_RenderWindowInteractor
   }
   else
     SVTK_SpaceMouse::getInstance()->setWindow( x11Display(), winId() );
+
+  myInteractor->EnterEvent();
 }
 
 //----------------------------------------------------------------------------
@@ -385,18 +384,37 @@ SVTK_RenderWindowInteractor
   // unregister set space mouse events receiver
   if ( SVTK_SpaceMouse::getInstance()->isSpaceMouseOn() )
     SVTK_SpaceMouse::getInstance()->setWindow( x11Display(), 0 );
+
+  myInteractor->LeaveEvent();
 }
 
 
 //----------------------------------------------------------------------------
-void
+bool 
 SVTK_RenderWindowInteractor
-::contextMenuEvent( QContextMenuEvent* event )
+::x11Event( XEvent *xEvent )
 {
-  if( !( event->state() & KeyButtonMask ) )
-    emit contextMenuRequested( event );
-}
+  // handle 3d space mouse events
+  SVTK_SpaceMouse* sm = SVTK_SpaceMouse::getInstance();
+  if ( sm->isSpaceMouseOn() && xEvent->type == ClientMessage ) {
+    SVTK_SpaceMouse::MoveEvent spaceMouseEvent;
+    int type = sm->translateEvent( x11Display(), xEvent, &spaceMouseEvent, 1.0, 1.0 );
+    switch ( type )
+    {
+    case SVTK_SpaceMouse::SpaceMouseMove : 
+      myInteractor->InvokeEvent( SpaceMouseMoveEvent, spaceMouseEvent.data );
+      break;
+    case SVTK_SpaceMouse::SpaceButtonPress :
+      myInteractor->InvokeEvent( SpaceMouseButtonEvent, &spaceMouseEvent.button );
+      break;
+    case SVTK_SpaceMouse::SpaceButtonRelease :
+      break;
+    }
+    return true; // stop handling the event
+  }
 
+  return SVTK_RenderWindow::x11Event( xEvent );
+}
 
 //----------------------------------------------------------------------------
 int
index 5667ef03849e84251cfa89d840d7925d26817503..c3d6e7241961235afb810b47277ea0aafc0a1823 100644 (file)
@@ -111,6 +111,7 @@ class SVTK_EXPORT SVTK_RenderWindowInteractor: public SVTK_RenderWindow
 
   virtual void paintEvent( QPaintEvent* );
   virtual void resizeEvent( QResizeEvent* );
+  virtual void contextMenuEvent( QContextMenuEvent * e );
 
   virtual void mouseMoveEvent( QMouseEvent* );
   virtual void mousePressEvent( QMouseEvent* );
@@ -120,19 +121,27 @@ class SVTK_EXPORT SVTK_RenderWindowInteractor: public SVTK_RenderWindow
   virtual void keyPressEvent( QKeyEvent* );
   virtual void keyReleaseEvent( QKeyEvent* );
 
-  virtual bool x11Event( XEvent *e );
   // reimplemented from QWidget in order to set window - receiver
   // of space mouse events. 
   virtual void focusInEvent ( QFocusEvent* );
   virtual void focusOutEvent( QFocusEvent* );
 
-  virtual void contextMenuEvent( QContextMenuEvent * e );
+  virtual bool x11Event( XEvent *e );
 
+ public:
  signals:
+  void MouseMove( QMouseEvent* );
+  void MouseButtonPressed( QMouseEvent* );
+  void MouseButtonReleased( QMouseEvent* );
+  void MouseDoubleClicked( QMouseEvent* );
+  void WheelMoved( QWheelEvent* );
+  void ButtonPressed(const QMouseEvent *event);
+  void ButtonReleased(const QMouseEvent *event);
+  void KeyPressed( QKeyEvent* );
+  void KeyReleased( QKeyEvent* );
   void contextMenuRequested( QContextMenuEvent *e );
 
  public:
-
   /* Selection Management */
   bool isInViewer( const Handle(SALOME_InteractiveObject)& IObject);
   bool isVisible( const Handle(SALOME_InteractiveObject)& IObject);
index 276793b620f9d3750ce68111c317fbacf84e1251..9cff5031db9bf999ee4c38b89b223b046c92f4e3 100644 (file)
@@ -104,15 +104,7 @@ public slots:
   virtual void activatePanning(); 
   virtual void activateGlobalPanning(); 
 
-protected slots:
-  void onKeyPressed(QKeyEvent* event);
-  void onKeyReleased(QKeyEvent* event);
-  void onMousePressed(QMouseEvent* event);
-  void onMouseDoubleClicked(QMouseEvent* event);
-  void onMouseReleased(QMouseEvent* event);
-  void onMouseMoving(QMouseEvent* event);
-
-private:
+protected:
   void InitialSetup();
   void InsertActor( VTKViewer_Actor* theActor,
                     bool theMoveInternalActors = false );
index 907010801d5ffa120d61e39f719568118db8a259..8b5dc9bb49edda1d3e60b6ee1d4ceb61773b7c22 100755 (executable)
@@ -75,8 +75,20 @@ SVTK_ViewWindow
   myView->setFocusPolicy( StrongFocus );
   myView->setFocus();
 
+  connect( myView, SIGNAL(KeyPressed( QKeyEvent* )),
+           this,   SLOT(onKeyPressed( QKeyEvent* )) );
+  connect( myView, SIGNAL(KeyReleased( QKeyEvent* )),
+           this,   SLOT(onKeyReleased( QKeyEvent* )) );
+  connect( myView, SIGNAL(MouseButtonPressed( QMouseEvent* )),
+           this,   SLOT(onMousePressed( QMouseEvent* )) );
+  connect( myView, SIGNAL(MouseButtonReleased( QMouseEvent* )),
+           this,   SLOT(onMouseReleased( QMouseEvent* )) );
+  connect( myView, SIGNAL(MouseDoubleClicked( QMouseEvent* )),
+           this,   SLOT(onMouseDoubleClicked( QMouseEvent* )) );
+  connect( myView, SIGNAL(MouseMove( QMouseEvent* )),
+           this,   SLOT(onMouseMoving( QMouseEvent* )) );
   connect( myView, SIGNAL(contextMenuRequested( QContextMenuEvent * )),
-           this, SIGNAL(contextMenuRequested( QContextMenuEvent * )) );
+           this,   SIGNAL(contextMenuRequested( QContextMenuEvent * )) );
 
   onResetView();
 
index ff2ebada8ae82ec4a0b461b9f47c0ee8dbb1a40b..c985c2108e6d87fc942c04651ea8291c40c31b80 100755 (executable)
@@ -83,8 +83,6 @@ public:
   void RemoveActor(VTKViewer_Actor*, bool update = false);
 
   void AdjustTrihedrons( const bool forced );
-  //merge with V2_2_0_VISU_improvements:bool ComputeTrihedronSize( double& theNewSize,
-  //merge with V2_2_0_VISU_improvements:                          double& theOldSize );
 
   VTKViewer_Trihedron*  GetTrihedron();
   SVTK_CubeAxesActor2D* GetCubeAxes();