Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0
[modules/shaper.git] / src / XGUI / XGUI_ViewerProxy.cpp
index 7d2122da77b8323dcee9f835d56775e3a4788364..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)();
   }
 }
@@ -50,7 +52,7 @@ void XGUI_ViewerProxy::setViewProjection(double theX, double theY, double theZ)
   Handle(V3d_View) aView3d = activeView();
   if (!aView3d.IsNull()) {
     aView3d->SetProj(theX, theY, theZ);
-    aView3d->FitAll(0.01, true, true);
+    aView3d->FitAll(0.01, true);
     aView3d->SetZSize(0.);
   }
 }
@@ -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);
 }
 
@@ -257,3 +277,20 @@ void XGUI_ViewerProxy::clearSelectionFilters()
 {
   myWorkshop->displayer()->removeFilters();
 }
+
+//***************************************
+void XGUI_ViewerProxy::update()
+{
+  myWorkshop->displayer()->updateViewer();
+}
+
+//***************************************
+bool XGUI_ViewerProxy::canDragByMouse() const
+{
+  if (myWorkshop->isSalomeMode()) {
+    ModuleBase_IViewer* aViewer = myWorkshop->salomeConnector()->viewer();
+    return aViewer->canDragByMouse();
+  } else {
+    return true;
+  }
+}