Salome HOME
Make the PVViewer active again at ParaVIS activation to avoid a new RenderView being...
[modules/gui.git] / src / PVViewer / PVViewer_ViewWindow.cxx
index 4bb2b3c3db298a81e4fc802df0464dce1536d827..a724de9b834b30ed894b4cbaf04cba054a404f3d 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2010-2015  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2022  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 #include "PVViewer_GUIElements.h"
 #include "PVViewer_ViewManager.h"
 
-#include <SUIT_ViewManager.h>
-#include <SUIT_ResourceMgr.h>
-#include <SUIT_Session.h>
-#include <SUIT_Desktop.h>
+#include "SUIT_ViewManager.h"
+#include "SUIT_ResourceMgr.h"
+#include "SUIT_Session.h"
+#include "SUIT_Desktop.h"
+#include "SUIT_Application.h"
 
 #include <pqTabbedMultiViewWidget.h>
 #include <pqApplicationCore.h>
-
+#include "pqActiveObjects.h"
 
 /*!
   \class PVViewer_ViewWindow
@@ -49,19 +50,20 @@ PVViewer_ViewWindow::PVViewer_ViewWindow( SUIT_Desktop* theDesktop, PVViewer_Vie
   myDesktop = theDesktop;
   myModel = theModel;
   setViewManager(myModel->getViewManager());
+  // This may improve synchronization between PV3DViewer and PVViewer
+  // but this make the PVViewer not active when ParaVIS is launched,
+  // which results in a new RenderView being created when a dataset is displayed.
+  // So we comment it for now.
+  //pqActiveObjects::instance().setActiveView(nullptr);
   myPVMgr = qobject_cast<pqTabbedMultiViewWidget*>(pqApplicationCore::instance()->manager("MULTIVIEW_WIDGET"));
   if (myPVMgr) {
+    SUIT_Application* app = SUIT_Session::session()->activeApplication();
+    if ( app )
+      app->addPostRoutine(&PVViewer_ViewWindow::removePVMgr);
     myPVMgr->setParent( this );
     // This is mandatory, see setParent() method in Qt 4 documentation
     myPVMgr->show();
     setCentralWidget( myPVMgr );
-
-    // Finish ParaView set up: behaviors, connection and configurations.
-    const QString configPath(PVViewer_ViewManager::GetPVConfigPath());
-    PVViewer_Core::ParaviewInitBehaviors(true, theDesktop);
-    PVViewer_ViewManager::ConnectToExternalPVServer(theDesktop);
-    PVViewer_Core::ParaviewLoadConfigurations(configPath);
-
     // Hide toolbars
     PVViewer_GUIElements * pvge = PVViewer_GUIElements::GetInstance(myDesktop);
     pvge->setToolBarVisible(false);
@@ -88,6 +90,12 @@ PVViewer_ViewWindow::~PVViewer_ViewWindow()
   }
 }
 
+void PVViewer_ViewWindow::removePVMgr()
+{
+  pqTabbedMultiViewWidget* aPVMgr = qobject_cast<pqTabbedMultiViewWidget*>(pqApplicationCore::instance()->manager("MULTIVIEW_WIDGET"));
+  delete aPVMgr;
+}
+
 /*!
   \brief Get the visual parameters of the view window.
   \return visual parameters of this view window formatted to the string
@@ -106,7 +114,6 @@ void PVViewer_ViewWindow::setVisualParameters( const QString& parameters )
   SUIT_ViewWindow::setVisualParameters( parameters );
 }
 
-
 /*!
   \brief Returns the ParaView multi-view manager previously set with setMultiViewManager()
 */
@@ -114,8 +121,3 @@ pqTabbedMultiViewWidget* PVViewer_ViewWindow::getMultiViewManager() const
 {
   return myPVMgr;
 }
-
-//void PVViewer_ViewWindow::onEmulateApply()
-//{
-//  emit this->applyRequest();
-//}