From: nds Date: Fri, 13 Feb 2015 12:31:07 +0000 (+0300) Subject: Issue #394 Undo-ing a Sketch element X-Git-Tag: V_1.1.0~192 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2b383cfe5eeaf0c5b9f3fdeed31f3404026c468f;p=modules%2Fshaper.git Issue #394 Undo-ing a Sketch element 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. --- diff --git a/src/NewGeom/NewGeom_SalomeViewer.cpp b/src/NewGeom/NewGeom_SalomeViewer.cpp index 3a7ee6c78..86e2d8f1b 100644 --- a/src/NewGeom/NewGeom_SalomeViewer.cpp +++ b/src/NewGeom/NewGeom_SalomeViewer.cpp @@ -12,20 +12,31 @@ #include #include +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(aMgr->getActiveView()); - Handle(V3d_View) aView = aWnd->getViewPort()->getView(); + Handle(V3d_View) aView; + if (myCurrentView) { + OCCViewer_ViewWindow* aWnd = static_cast(myCurrentView); + aView = aWnd->getViewPort()->getView(); + } return aView; } QWidget* NewGeom_SalomeView::viewPort() const { - SUIT_ViewManager* aMgr = myViewer->getViewManager(); - OCCViewer_ViewWindow* aWnd = static_cast(aMgr->getActiveView()); - return aWnd->getViewPort(); + QWidget* aViewPort = 0; + if (myCurrentView) { + OCCViewer_ViewWindow* aWnd = static_cast(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(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); } diff --git a/src/NewGeom/NewGeom_SalomeViewer.h b/src/NewGeom/NewGeom_SalomeViewer.h index 4f8812803..6dbd6b6df 100644 --- a/src/NewGeom/NewGeom_SalomeViewer.h +++ b/src/NewGeom/NewGeom_SalomeViewer.h @@ -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; };