]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #2867: Initialize SHAPER viewer if OCC viewer already exists in initialization...
authorvsv <vsv@opencascade.com>
Tue, 19 Feb 2019 09:18:05 +0000 (12:18 +0300)
committervsv <vsv@opencascade.com>
Tue, 19 Feb 2019 09:18:52 +0000 (12:18 +0300)
src/SHAPERGUI/SHAPERGUI.cpp
src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp
src/XGUI/XGUI_ViewerProxy.cpp

index 56f665801398467ea0463e9f877dc0028c832ec3..4b74af5ae33a5ee557e5b178c6c3b6968d73bf93 100644 (file)
@@ -33,6 +33,7 @@
 #include <XGUI_FacesPanel.h>
 #include <XGUI_SelectionActivate.h>
 #include <XGUI_InspectionPanel.h>
+#include <XGUI_ViewerProxy.h>
 
 #include <ModuleBase_Operation.h>
 #include <ModuleBase_Preferences.h>
 #include <LightApp_SelectionMgr.h>
 #include <LightApp_OCCSelector.h>
 #include <LightApp_Study.h>
+
 #include <OCCViewer_ViewModel.h>
+#include <OCCViewer_ViewPort3d.h>
 
 #include <SUIT_Selector.h>
 #include <SUIT_Desktop.h>
 #include <SUIT_ViewManager.h>
+#include <SUIT_ViewWindow.h>
 #include <SUIT_ResourceMgr.h>
 #include <SUIT_DataBrowser.h>
 
@@ -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<OCCViewer_ViewWindow*>(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());
+      }
+    }
+  }
 }
 
 //******************************************************
index e5fa66fba4a984e78bcd0d49d549b344d5c4c6b2..467f6a9b6f1fc5a41e40995823dc811cb43242d4 100644 (file)
@@ -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();
index a7a5b5ae21e91232786a5fea459d90c7c2ac068d..6105a6fb600a9df4cbfc6eb73aff2445314ab983 100644 (file)
@@ -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);
 }