From 1f5d2c57d3af724cb6e63d7a880d1aad810fe1cd Mon Sep 17 00:00:00 2001 From: vsv Date: Tue, 19 Feb 2019 12:18:05 +0300 Subject: [PATCH] Issue #2867: Initialize SHAPER viewer if OCC viewer already exists in initialization moment. --- src/SHAPERGUI/SHAPERGUI.cpp | 22 ++++++++++++++++++++++ src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp | 2 +- src/XGUI/XGUI_ViewerProxy.cpp | 3 +-- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/SHAPERGUI/SHAPERGUI.cpp b/src/SHAPERGUI/SHAPERGUI.cpp index 56f665801..4b74af5ae 100644 --- a/src/SHAPERGUI/SHAPERGUI.cpp +++ b/src/SHAPERGUI/SHAPERGUI.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -43,11 +44,14 @@ #include #include #include + #include +#include #include #include #include +#include #include #include @@ -185,6 +189,24 @@ void SHAPERGUI::initialize(CAM_Application* theApp) tr("Edit toolbars..."), aTip, QKeySequence(), aDesk, false, this, SLOT(onEditToolbars())); int aEditMenu = createMenu(tr("MEN_DESK_EDIT"), -1, -1, 30); int aEditItem = createMenu(aId, aEditMenu); + + // Initialize viewer proxy if OCC viewer is already exist + ViewManagerList aOCCViewManagers; + application()->viewManagers(OCCViewer_Viewer::Type(), aOCCViewManagers); + if (aOCCViewManagers.size() > 0) { + SUIT_ViewManager* aMgr = aOCCViewManagers.first(); + SUIT_ViewWindow* aWnd = aMgr->getActiveView(); + if (aWnd) { + OCCViewer_ViewWindow* aOccWnd = static_cast(aWnd); + OCCViewer_ViewPort3d* aViewPort = aOccWnd->getViewPort(); + if (aViewPort) { + XGUI_ViewerProxy* aViewer = myWorkshop->viewer(); + aViewPort->installEventFilter(aViewer); + Handle(V3d_View) aView = aViewPort->getView(); + aViewer->SetScale(aView, aView->Camera()->Scale()); + } + } + } } //****************************************************** diff --git a/src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp b/src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp index e5fa66fba..467f6a9b6 100644 --- a/src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp +++ b/src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp @@ -119,7 +119,7 @@ Handle(V3d_View) SHAPERGUI_SalomeViewer::activeView() const //********************************************** QWidget* SHAPERGUI_SalomeViewer::activeViewPort() const { - QWidget* aViewPort; + QWidget* aViewPort = 0; if (mySelector) { OCCViewer_Viewer* aViewer = mySelector->viewer(); SUIT_ViewManager* aMgr = aViewer->getViewManager(); diff --git a/src/XGUI/XGUI_ViewerProxy.cpp b/src/XGUI/XGUI_ViewerProxy.cpp index a7a5b5ae2..6105a6fb6 100644 --- a/src/XGUI/XGUI_ViewerProxy.cpp +++ b/src/XGUI/XGUI_ViewerProxy.cpp @@ -186,6 +186,7 @@ void XGUI_ViewerProxy::connectToViewer() connect(aViewer, SIGNAL(contextMenuRequested(QContextMenuEvent*)), this, SIGNAL(contextMenuRequested(QContextMenuEvent*))); + #else AppElements_Viewer* aViewer = myWorkshop->mainWindow()->viewer(); @@ -241,9 +242,7 @@ bool XGUI_ViewerProxy::eventFilter(QObject *theObject, QEvent *theEvent) void XGUI_ViewerProxy::onViewCreated(ModuleBase_IViewWindow* theWnd) { theWnd->viewPort()->installEventFilter(this); - myWindowScale.insert (theWnd->v3dView(), theWnd->v3dView()->Camera()->Scale()); - emit viewCreated(theWnd); } -- 2.39.2