From a6321e4ee15cbc55b51c5f79d2c2a84637ad6723 Mon Sep 17 00:00:00 2001 From: abn Date: Wed, 1 Oct 2014 17:20:08 +0200 Subject: [PATCH] Now using 'salome_iapp.IN_SALOME_GUI' to detect where we are invoked from. --- src/PVGUI/PVGUI_Module.cxx | 8 ------ src/PVGUI/PVGUI_Module_actions.cxx | 10 +++---- src/PVGUI/PVGUI_Module_widgets.cxx | 6 ++-- src/PV_SWIG/no_wrap/pvsimple.py | 44 ++++++++++++++++-------------- 4 files changed, 32 insertions(+), 36 deletions(-) diff --git a/src/PVGUI/PVGUI_Module.cxx b/src/PVGUI/PVGUI_Module.cxx index 36fdf5e5..c7c8c7a7 100644 --- a/src/PVGUI/PVGUI_Module.cxx +++ b/src/PVGUI/PVGUI_Module.cxx @@ -1083,14 +1083,6 @@ void PVGUI_Module::onRestartTrace() startTrace(); } -/*! - \brief Show ParaView view. -*/ -void PVGUI_Module::onNewParaViewWindow() -{ - showView(true); -} - /*! \brief Save state under the module root object. */ diff --git a/src/PVGUI/PVGUI_Module_actions.cxx b/src/PVGUI/PVGUI_Module_actions.cxx index 0d3555a0..42adaf84 100644 --- a/src/PVGUI/PVGUI_Module_actions.cxx +++ b/src/PVGUI/PVGUI_Module_actions.cxx @@ -623,11 +623,11 @@ void PVGUI_Module::createActions() { QAction* anAction; - // New ParaView window - anAction = new QtxAction(tr("MEN_NEW_PV_VIEW"), tr("MEN_NEW_PV_VIEW"), 0, - this, false, "ParaViS:Create new ParaView view"); - connect(anAction, SIGNAL(triggered()), this, SLOT(onNewParaViewWindow())); - registerAction(ParaViewNewWindowId, anAction); +// // New ParaView window +// anAction = new QtxAction(tr("MEN_NEW_PV_VIEW"), tr("MEN_NEW_PV_VIEW"), 0, +// this, false, "ParaViS:Create new ParaView view"); +// connect(anAction, SIGNAL(triggered()), this, SLOT(onNewParaViewWindow())); +// registerAction(ParaViewNewWindowId, anAction); // Save state under the module root object anAction = new QAction(tr("MEN_SAVE_MULTI_STATE"), this); diff --git a/src/PVGUI/PVGUI_Module_widgets.cxx b/src/PVGUI/PVGUI_Module_widgets.cxx index b158fe35..8a5c7673 100644 --- a/src/PVGUI/PVGUI_Module_widgets.cxx +++ b/src/PVGUI/PVGUI_Module_widgets.cxx @@ -118,11 +118,10 @@ void PVGUI_Module::setupDockWidgets() // Properties dock (previously called OBJECT_INSPECTOR) QDockWidget* propertiesDock = new QDockWidget( tr( "TTL_OBJECT_INSPECTOR" ), desk ); propertiesDock->setObjectName("propertiesDock"); - propertiesDock->setAllowedAreas( Qt::LeftDockWidgetArea|Qt::NoDockWidgetArea|Qt::RightDockWidgetArea ); + propertiesDock->setAllowedAreas( Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea ); desk->addDockWidget( Qt::LeftDockWidgetArea, propertiesDock ); pqPropertiesPanel* propertiesPanel = guiElements->getPropertiesPanel(); - propertiesDock->setObjectName("propertiesPanel"); propertiesDock->setWidget(propertiesPanel); connect( propertiesPanel, SIGNAL( helpRequested(const QString&, const QString&) ), this, SLOT( showHelpForProxy(const QString&, const QString&) ) ); // hook delete to pqDeleteReaction. @@ -159,7 +158,8 @@ void PVGUI_Module::setupDockWidgets() desk->setTabPosition(Qt::LeftDockWidgetArea, QTabWidget::North); desk->tabifyDockWidget(informationDock, propertiesDock); - propertiesDock->raise(); + desk->tabifyDockWidget(propertiesDock, pipelineBrowserDock); + //propertiesDock->raise(); // Statistic View QDockWidget* statisticsViewDock = new QDockWidget( tr( "TTL_STATISTICS_VIEW" ), desk ); diff --git a/src/PV_SWIG/no_wrap/pvsimple.py b/src/PV_SWIG/no_wrap/pvsimple.py index b6c62bc6..87e0daba 100644 --- a/src/PV_SWIG/no_wrap/pvsimple.py +++ b/src/PV_SWIG/no_wrap/pvsimple.py @@ -23,21 +23,19 @@ On top of that it also establishes a connection to a valid PVServer whose addres is provided by the PARAVIS engine. """ +__DEBUG = 1 + def __my_log(msg): - print "[PARAVIS] %s" % msg + if __DEBUG: + print "[PARAVIS] %s" % msg def __getFromGUI(): - """ Identify if we are running inside SALOME's embedded console. + """ Identify if we are running inside SALOME's embedded interpreter. """ - fromGUI = False - try: - import salome - fromGUI = salome.fromEmbeddedConsole - except AttributeError: - pass - return fromGUI + import salome_iapp + return salome_iapp.IN_SALOME_GUI -def InitParaViewForGUI(): +def ShowParaviewView(): """ If the import is made from SALOME embedded console, the ParaView application needs to be instanciated to avoid a future crash. @@ -46,24 +44,22 @@ def InitParaViewForGUI(): __my_log("Initializing ParaView main elements, please be patient ...") import SalomePyQt sgPyQt = SalomePyQt.SalomePyQt() - sgPyQt.createView("ParaView") + viewIds = sgPyQt.findViews("ParaView") + if len(viewIds): + sgPyQt.setViewVisible(viewIds[0], True) + sgPyQt.activateView(viewIds[0]) + else: + sgPyQt.createView("ParaView") # Now let the GUI main loop process the initialization event posted above sgPyQt.processEvents() __my_log("ParaView initialized.") ## The below has to called BEFORE importing paraview!!! This is crazy, but it has to be. -InitParaViewForGUI() -del InitParaViewForGUI +ShowParaviewView() import paraview import paravis - -# Forward namespace of simple into current pvsimple: from paraview import simple -for name in dir(simple): - if not name.startswith("__"): - globals()[name] = getattr(simple, name) -del simple def SalomeConnectToPVServer(): """ @@ -81,7 +77,7 @@ def SalomeConnectToPVServer(): a = server_url.split(':') b = a[1].split('//') host, port = b[-1], int(a[-1]) - Connect(host, port) + simple.Connect(host, port) __my_log("Connected to %s!" % server_url) if __getFromGUI(): paravis.myParavisEngine.SetGUIConnected(True) @@ -93,3 +89,11 @@ def SalomeConnectToPVServer(): pass SalomeConnectToPVServer() +del SalomeConnectToPVServer + +# Forward namespace of simple into current pvsimple: +for name in dir(simple): + if not name.startswith("__"): + globals()[name] = getattr(simple, name) +del simple + -- 2.39.2