]> 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 12:31:07 +0000 (15:31 +0300)
committernds <natalia.donis@opencascade.com>
Fri, 13 Feb 2015 12:31:07 +0000 (15:31 +0300)
Current view in the SALOME viewer is created.
It is not correct to return viewport of the activeView because by viewCreated signal the active view is not set.
May be myCurrentView should be updated by the SUIT_ViewWindow destroyed signal.

src/NewGeom/NewGeom_SalomeViewer.cpp
src/NewGeom/NewGeom_SalomeViewer.h

index 3a7ee6c78163a14dc8d786be723f5e8c06cd77e4..86e2d8f1b2e5b61d42ce62c760279ed70a5676a8 100644 (file)
 #include <QMouseEvent>
 #include <QContextMenuEvent>
 
+NewGeom_SalomeView::NewGeom_SalomeView(OCCViewer_Viewer* theViewer)
+: ModuleBase_IViewWindow(), myCurrentView(0)
+{
+  myViewer = theViewer;
+}
+
 
 Handle(V3d_View) NewGeom_SalomeView::v3dView() const
 {
-  SUIT_ViewManager* aMgr = myViewer->getViewManager();
-  OCCViewer_ViewWindow* aWnd = static_cast<OCCViewer_ViewWindow*>(aMgr->getActiveView());
-  Handle(V3d_View) aView = aWnd->getViewPort()->getView();
+  Handle(V3d_View) aView;
+  if (myCurrentView) {
+    OCCViewer_ViewWindow* aWnd = static_cast<OCCViewer_ViewWindow*>(myCurrentView);
+    aView = aWnd->getViewPort()->getView();
+  }
   return aView;
 }
 
 QWidget* NewGeom_SalomeView::viewPort() const
 {
-  SUIT_ViewManager* aMgr = myViewer->getViewManager();
-  OCCViewer_ViewWindow* aWnd = static_cast<OCCViewer_ViewWindow*>(aMgr->getActiveView());
-  return aWnd->getViewPort();
+  QWidget* aViewPort = 0;
+  if (myCurrentView) {
+    OCCViewer_ViewWindow* aWnd = static_cast<OCCViewer_ViewWindow*>(myCurrentView);
+    aViewPort = aWnd->getViewPort();
+  }
+  return aViewPort;
 }
 
 //**********************************************
@@ -134,14 +145,16 @@ void NewGeom_SalomeViewer::onSelectionChanged()
 }
 
 //**********************************************
-void NewGeom_SalomeViewer::onMousePress(SUIT_ViewWindow*, QMouseEvent* theEvent)
+void NewGeom_SalomeViewer::onMousePress(SUIT_ViewWindow* theView, QMouseEvent* theEvent)
 {
+  myView->setCurrentView(theView);
   emit mousePress(myView, theEvent);
 }
 
 //**********************************************
-void NewGeom_SalomeViewer::onMouseRelease(SUIT_ViewWindow*, QMouseEvent* theEvent)
+void NewGeom_SalomeViewer::onMouseRelease(SUIT_ViewWindow* theView, QMouseEvent* theEvent)
 {
+  myView->setCurrentView(theView);
   emit mouseRelease(myView, theEvent);
   if (myIsSelectionChanged) {
     emit selectionChanged();
@@ -150,14 +163,16 @@ void NewGeom_SalomeViewer::onMouseRelease(SUIT_ViewWindow*, QMouseEvent* theEven
 }
 
 //**********************************************
-void NewGeom_SalomeViewer::onMouseDoubleClick(SUIT_ViewWindow*, QMouseEvent* theEvent)
+void NewGeom_SalomeViewer::onMouseDoubleClick(SUIT_ViewWindow* theView, QMouseEvent* theEvent)
 {
+  myView->setCurrentView(theView);
   emit mouseDoubleClick(myView, theEvent);
 }
 
 //**********************************************
 void NewGeom_SalomeViewer::onMouseMove(SUIT_ViewWindow* theView, QMouseEvent* theEvent)
 {
+  myView->setCurrentView(theView);
   OCCViewer_ViewWindow* aViewWnd = dynamic_cast<OCCViewer_ViewWindow*>(theView);
   Handle(AIS_InteractiveContext) aContext = AISContext();
   if (aContext->HasDetected()) // Set focus to provide key events in the view
@@ -213,8 +228,9 @@ void NewGeom_SalomeViewer::onDeleteView(SUIT_ViewWindow*)
 }
 
 //**********************************************
-void NewGeom_SalomeViewer::onViewCreated(SUIT_ViewWindow*)
+void NewGeom_SalomeViewer::onViewCreated(SUIT_ViewWindow* theView)
 {
+  myView->setCurrentView(theView);
   emit viewCreated(myView);
 }
 
index 4f8812803f6a6570ef39187a223ed4edf1a399e4..6dbd6b6df9846cecda9d3c9fd5392706e7a87576 100644 (file)
@@ -29,7 +29,7 @@ class NewGeom_SalomeView: public ModuleBase_IViewWindow
 public:
   /// Constructor
   /// \param theViewer a reference to a viewer
-  NewGeom_SalomeView(OCCViewer_Viewer* theViewer) { myViewer = theViewer; }
+  NewGeom_SalomeView(OCCViewer_Viewer* theViewer);
 
   virtual Handle(V3d_View) v3dView() const;
 
@@ -43,9 +43,13 @@ public:
   /// Returns current viewer
   OCCViewer_Viewer* viewer() const { return myViewer; }
 
+  /// Sets the current view
+  void setCurrentView(SUIT_ViewWindow* theView) { myCurrentView = theView; }
+
 private:
   /// A reference to a viewer
   OCCViewer_Viewer* myViewer;
+  SUIT_ViewWindow* myCurrentView;
 };