]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #394 Undo-ing a Sketch element
authornds <natalia.donis@opencascade.com>
Fri, 13 Feb 2015 11:38:15 +0000 (14:38 +0300)
committernds <natalia.donis@opencascade.com>
Fri, 13 Feb 2015 11:38:15 +0000 (14:38 +0300)
The realization for the NewGeom module

src/ModuleBase/ModuleBase_IViewWindow.h
src/NewGeom/NewGeom_SalomeViewer.cpp
src/NewGeom/NewGeom_SalomeViewer.h
src/XGUI/XGUI_ViewerProxy.cpp
src/XGUI/XGUI_ViewerProxy.h

index 89929982ebe3367dfa04a8921fcadd677aa57c1a..756baa64a9682d1907325233b5906087659e35c2 100644 (file)
@@ -17,6 +17,9 @@ class ModuleBase_IViewWindow
 public:
   /// Returns OCCT object which contains 3d view object
   virtual Handle(V3d_View) v3dView() const = 0;
+
+  /// Returns the view window view port
+  virtual QWidget* viewPort() const = 0;
 };
 
 
index e68c971ec737c65036659610c2ba598e2caed995..3a7ee6c78163a14dc8d786be723f5e8c06cd77e4 100644 (file)
@@ -21,6 +21,13 @@ Handle(V3d_View) NewGeom_SalomeView::v3dView() const
   return aView;
 }
 
+QWidget* NewGeom_SalomeView::viewPort() const
+{
+  SUIT_ViewManager* aMgr = myViewer->getViewManager();
+  OCCViewer_ViewWindow* aWnd = static_cast<OCCViewer_ViewWindow*>(aMgr->getActiveView());
+  return aWnd->getViewPort();
+}
+
 //**********************************************
 //**********************************************
 //**********************************************
index 1d471d1dcc97ea11d04d0479e291c804aae2b6c6..4f8812803f6a6570ef39187a223ed4edf1a399e4 100644 (file)
@@ -33,6 +33,9 @@ public:
 
   virtual Handle(V3d_View) v3dView() const;
 
+  /// Returns the view window view port
+  virtual QWidget* viewPort() const;
+
   /// Set the current viewer
   /// \param theViewer a viewer instance
   void setViewer(OCCViewer_Viewer* theViewer) { myViewer = theViewer; }
index 3352c318f9d7c74b88235d94e1d87007b8d9d59a..44cee80cdc980b62a20667d057bfe53febca0944 100644 (file)
@@ -42,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)();
   }
 }
@@ -64,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();
   }
 }
 
@@ -81,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*)));
@@ -150,16 +150,11 @@ void XGUI_ViewerProxy::connectToViewer()
 
 bool XGUI_ViewerProxy::eventFilter(QObject *theObject, QEvent *theEvent)
 {
-  AppElements_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
-  bool isViewPort = theObject == aViewer->activeViewWindow()->viewPort();
-  if (isViewPort)
-  {
-    if (theEvent->type() == QEvent::Enter) {
-      emit enterViewPort();
-    }
-    else if (theEvent->type() == QEvent::Leave) {
-      emit leaveViewPort();
-    }
+  if (theEvent->type() == QEvent::Enter) {
+    emit enterViewPort();
+  }
+  else if (theEvent->type() == QEvent::Leave) {
+    emit leaveViewPort();
   }
   return ModuleBase_IViewer::eventFilter(theObject, theEvent);
 }
@@ -174,6 +169,13 @@ 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);
index 2bc5497a48117675a288241783dfea35477ff74e..2ee3ba2168b056cf93d5ab42099b0f7dcec21fde 100644 (file)
@@ -89,6 +89,7 @@ protected:
 private slots:
   void onTryCloseView(AppElements_ViewWindow*);
   void onDeleteView(AppElements_ViewWindow*);
+  void onViewCreated(ModuleBase_IViewWindow* theWnd);
   void onViewCreated(AppElements_ViewWindow*);
   void onActivated(AppElements_ViewWindow*);