Salome HOME
Issue #394 Undo-ing a Sketch element
[modules/shaper.git] / src / XGUI / XGUI_ViewerProxy.cpp
index ec70496183d244a53a2d071c79e4f23bf9f9f130..44cee80cdc980b62a20667d057bfe53febca0944 100644 (file)
@@ -10,6 +10,8 @@
 #include <AppElements_ViewWindow.h>
 #include <AppElements_Viewer.h>
 
+#include <QEvent>
+
 XGUI_ViewerProxy::XGUI_ViewerProxy(XGUI_Workshop* theParent)
     : ModuleBase_IViewer(theParent),
       myWorkshop(theParent)
@@ -40,7 +42,7 @@ Handle(V3d_View) XGUI_ViewerProxy::activeView() const
     return myWorkshop->salomeConnector()->viewer()->activeView();
   } else {
     AppElements_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
-    return (aViewer->activeViewWindow()) ? aViewer->activeViewWindow()->viewPort()->getView() :
+    return (aViewer->activeViewWindow()) ? aViewer->activeViewWindow()->viewPortApp()->getView() :
     Handle(V3d_View)();
   }
 }
@@ -62,7 +64,7 @@ void XGUI_ViewerProxy::fitAll()
   } else {
     AppElements_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
     if (aViewer->activeViewWindow())
-      aViewer->activeViewWindow()->viewPort()->fitAll();
+      aViewer->activeViewWindow()->viewPortApp()->fitAll();
   }
 }
 
@@ -79,7 +81,7 @@ void XGUI_ViewerProxy::connectToViewer()
       this, SIGNAL(deleteView(ModuleBase_IViewWindow*)));
 
     connect(aViewer, SIGNAL(viewCreated(ModuleBase_IViewWindow*)), 
-      this, SIGNAL(viewCreated(ModuleBase_IViewWindow*)));
+      this, SLOT(onViewCreated(ModuleBase_IViewWindow*)));
 
     connect(aViewer, SIGNAL(activated(ModuleBase_IViewWindow*)), 
       this, SIGNAL(activated(ModuleBase_IViewWindow*)));
@@ -105,7 +107,6 @@ void XGUI_ViewerProxy::connectToViewer()
     connect(aViewer, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
     connect(aViewer, SIGNAL(contextMenuRequested(QContextMenuEvent*)), this,
             SIGNAL(contextMenuRequested(QContextMenuEvent*)));
-
   } else {
     AppElements_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
 
@@ -147,6 +148,16 @@ void XGUI_ViewerProxy::connectToViewer()
   }
 }
 
+bool XGUI_ViewerProxy::eventFilter(QObject *theObject, QEvent *theEvent)
+{
+  if (theEvent->type() == QEvent::Enter) {
+    emit enterViewPort();
+  }
+  else if (theEvent->type() == QEvent::Leave) {
+    emit leaveViewPort();
+  }
+  return ModuleBase_IViewer::eventFilter(theObject, theEvent);
+}
 
 void XGUI_ViewerProxy::onTryCloseView(AppElements_ViewWindow* theWnd)
 {
@@ -158,8 +169,17 @@ void XGUI_ViewerProxy::onDeleteView(AppElements_ViewWindow* theWnd)
   emit deleteView(theWnd);
 }
 
+void XGUI_ViewerProxy::onViewCreated(ModuleBase_IViewWindow* theWnd)
+{
+  theWnd->viewPort()->installEventFilter(this);
+
+  emit viewCreated(theWnd);
+}
+
 void XGUI_ViewerProxy::onViewCreated(AppElements_ViewWindow* theWnd)
 {
+  theWnd->viewPort()->installEventFilter(this);
+
   emit viewCreated(theWnd);
 }
 
@@ -273,4 +293,4 @@ bool XGUI_ViewerProxy::canDragByMouse() const
   } else {
     return true;
   }
-}
\ No newline at end of file
+}