From 5e0d2346938ebede83543d7e37ff6ff8fc907675 Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 13 Feb 2015 14:38:15 +0300 Subject: [PATCH] Issue #394 Undo-ing a Sketch element The realization for the NewGeom module --- src/ModuleBase/ModuleBase_IViewWindow.h | 3 +++ src/NewGeom/NewGeom_SalomeViewer.cpp | 7 +++++++ src/NewGeom/NewGeom_SalomeViewer.h | 3 +++ src/XGUI/XGUI_ViewerProxy.cpp | 28 +++++++++++++------------ src/XGUI/XGUI_ViewerProxy.h | 1 + 5 files changed, 29 insertions(+), 13 deletions(-) diff --git a/src/ModuleBase/ModuleBase_IViewWindow.h b/src/ModuleBase/ModuleBase_IViewWindow.h index 89929982e..756baa64a 100644 --- a/src/ModuleBase/ModuleBase_IViewWindow.h +++ b/src/ModuleBase/ModuleBase_IViewWindow.h @@ -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; }; diff --git a/src/NewGeom/NewGeom_SalomeViewer.cpp b/src/NewGeom/NewGeom_SalomeViewer.cpp index e68c971ec..3a7ee6c78 100644 --- a/src/NewGeom/NewGeom_SalomeViewer.cpp +++ b/src/NewGeom/NewGeom_SalomeViewer.cpp @@ -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(aMgr->getActiveView()); + return aWnd->getViewPort(); +} + //********************************************** //********************************************** //********************************************** diff --git a/src/NewGeom/NewGeom_SalomeViewer.h b/src/NewGeom/NewGeom_SalomeViewer.h index 1d471d1dc..4f8812803 100644 --- a/src/NewGeom/NewGeom_SalomeViewer.h +++ b/src/NewGeom/NewGeom_SalomeViewer.h @@ -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; } diff --git a/src/XGUI/XGUI_ViewerProxy.cpp b/src/XGUI/XGUI_ViewerProxy.cpp index 3352c318f..44cee80cd 100644 --- a/src/XGUI/XGUI_ViewerProxy.cpp +++ b/src/XGUI/XGUI_ViewerProxy.cpp @@ -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); diff --git a/src/XGUI/XGUI_ViewerProxy.h b/src/XGUI/XGUI_ViewerProxy.h index 2bc5497a4..2ee3ba216 100644 --- a/src/XGUI/XGUI_ViewerProxy.h +++ b/src/XGUI/XGUI_ViewerProxy.h @@ -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*); -- 2.39.2