* Isolated ParaView's GUI elements that need an early start, so that menu loads properly
* Translated preference to have the builtin pvserver used
* Fixed Python dump to "import pvsimple"
#include "PVViewer_ViewModel.h"
#include "PVGUI_Tools.h"
#include "PVGUI_ParaViewSettingsPane.h"
+#include "PVViewer_GUIElements.h"
// SALOME Includes
#include <SUIT_DataBrowser.h>
myTraceWindow(0),
myStateCounter(0),
myInitTimer(0),
- myPushTraceTimer(0)
+ myPushTraceTimer(0),
+ myGuiElements(0)
{
#ifdef HAS_PV_DOC
Q_INIT_RESOURCE( PVGUI );
// Initialize ParaView client and associated behaviors
// and connect to externally launched pvserver
PVViewer_ViewManager::ParaviewInitApp(aDesktop);
+ myGuiElements = PVViewer_GUIElements::GetInstance(aDesktop);
// Remember current state of desktop toolbars
QList<QToolBar*> foreignToolbars = aDesktop->findChildren<QToolBar*>();
bool isDone = SalomeApp_Module::activateModule( study );
if ( !isDone ) return false;
- showView( true ); // this will also trigger the connection to the server
- // and the instanciation of the relevant PV behaviors
+ showView( true );
if ( mySourcesMenuId != -1 ) menuMgr()->show(mySourcesMenuId);
if ( myFiltersMenuId != -1 ) menuMgr()->show(myFiltersMenuId);
- if ( myFiltersMenuId != -1 ) menuMgr()->show(myMacrosMenuId);
- if ( myFiltersMenuId != -1 ) menuMgr()->show(myToolbarsMenuId);
+ if ( myMacrosMenuId != -1 ) menuMgr()->show(myMacrosMenuId);
+ if ( myToolbarsMenuId != -1 ) menuMgr()->show(myToolbarsMenuId);
+
+ // Update the various menus with the content pre-loaded in myGuiElements
+ QMenu* srcMenu = menuMgr()->findMenu( mySourcesMenuId );
+ myGuiElements->updateSourcesMenu(srcMenu);
+ QMenu* filtMenu = menuMgr()->findMenu( myFiltersMenuId );
+ myGuiElements->updateFiltersMenu(filtMenu);
+ QMenu* macMenu = menuMgr()->findMenu( myMacrosMenuId );
+ myGuiElements->updateMacrosMenu(macMenu);
+
setMenuShown( true );
setToolShown( true );
\brief Returns trace string
*/
static const QString MYReplaceStr("paraview.simple");
-static const QString MYReplaceImportStr("except: from pvsimple import *");
QString PVGUI_Module::getTraceString()
{
vtkSMTrace *tracer = vtkSMTrace::GetActiveTracer();
return QString("");
QString traceString(tracer->GetCurrentTrace());
+ std::stringstream nl; nl << std::endl; // surely there is some Qt trick to do that in a portable way??
+ traceString = "import pvsimple" + QString(nl.str().c_str()) + traceString;
// Replace import "paraview.simple" by "pvsimple"
if ((!traceString.isNull()) && traceString.length() != 0) {
traceString = traceString.replace(aPos, MYReplaceStr.length(), "pvsimple");
aPos = traceString.indexOf(MYReplaceStr, aPos);
}
- int aImportPos = traceString.indexOf(MYReplaceImportStr);
- if(aImportPos != -1)
- {
- traceString = traceString.replace(aImportPos, MYReplaceImportStr.length(), "except:\n import pvsimple\n from pvsimple import *");
- }
}
return traceString;
class pqPVApplicationCore;
class pqDataRepresentation;
class pqRepresentation;
+class PVViewer_GUIElements;
class PVGUI_Module : public SalomeApp_Module
{
//! Timer used to regularly push the Python trace to the engine.
QTimer * myPushTraceTimer;
+
+ PVViewer_GUIElements * myGuiElements;
};
#endif // PVGUI_Module_H
//
#include "PVGUI_Module.h"
+#include <PVViewer_GUIElements.h>
#include <QtxAction.h>
#include <QtxActionMenuMgr.h>
QMenu* aMenu = menuMgr()->findMenu( myRecentMenuId );
pqRecentFilesMenu* aRecentFilesMenu = new pqRecentFilesMenu( *aMenu, getApp()->desktop() );
QList<QAction*> anActns = aMenu->actions();
- for (int i = 0; i < anActns.size(); ++i) {
- createMenu( anActns.at(i), myRecentMenuId );
- }
-
+ for (int i = 0; i < anActns.size(); ++i)
+ createMenu( anActns.at(i), myRecentMenuId );
createMenu( separator(), aPVMnu, -1, 5 );
createMenu( FullScreenId, aPVMnu );
// --- Menu "Sources"
-
// Install ParaView managers for "Sources" menu
QMenu* aRes = 0;
+ PVViewer_GUIElements * guiElements = PVViewer_GUIElements::GetInstance(desk);
mySourcesMenuId = createMenu( tr( "MEN_DESK_SOURCES" ), -1, -1, 60);
- if ( (aRes = getMenu( mySourcesMenuId )) ) {
- pqParaViewMenuBuilders::buildSourcesMenu(*aRes, desk);
- }
+ if ( (aRes = getMenu( mySourcesMenuId )) )
+ guiElements->updateSourcesMenu(aRes);
// --- Menu "Filters"
-
// Install ParaView managers for "Filters" menu
myFiltersMenuId = createMenu( tr( "MEN_DESK_FILTERS" ), -1, -1, 70 );
- if ( (aRes = getMenu( myFiltersMenuId )) ) {
- pqParaViewMenuBuilders::buildFiltersMenu(*aRes, desk);
- }
+ if ( (aRes = getMenu( myFiltersMenuId )) )
+ guiElements->updateFiltersMenu(aRes);
// --- Menu "Macros"
myMacrosMenuId = createMenu( tr( "MEN_MACROS" ), -1, -1, 80 );
- if ( (aRes = getMenu( myMacrosMenuId )) ) {
- pqParaViewMenuBuilders::buildMacrosMenu(*aRes);
- }
+ if ( (aRes = getMenu( myMacrosMenuId )) )
+ guiElements->updateMacrosMenu(aRes);
// --- Menu "Tools"
-
int aToolsMnu = createMenu( tr( "MEN_DESK_TOOLS" ), -1, -1, 90 );
createMenu( CreateCustomFilterId, aToolsMnu );
//
#include "PVGUI_Module.h"
+#include "PVViewer_ViewManager.h"
+#include "PVViewer_GUIElements.h"
#include <QtxActionToolMgr.h>
#include <LightApp_Application.h>
void PVGUI_Module::setupDockWidgets()
{
SUIT_Desktop* desk = application()->desktop();
+ PVViewer_GUIElements * guiElements = PVViewer_GUIElements::GetInstance(desk);
desk->setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
desk->setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
pipelineBrowserDock->setObjectName("pipelineBrowserDock");
pipelineBrowserDock->setAllowedAreas( Qt::LeftDockWidgetArea|Qt::NoDockWidgetArea|Qt::RightDockWidgetArea );
desk->addDockWidget( Qt::LeftDockWidgetArea, pipelineBrowserDock );
- pqPipelineBrowserWidget* browser = new pqPipelineBrowserWidget(pipelineBrowserDock);
- pqParaViewMenuBuilders::buildPipelineBrowserContextMenu(*browser);
+ pqPipelineBrowserWidget* browser = guiElements->getPipelineBrowserWidget();
pipelineBrowserDock->setWidget(browser);
myDockWidgets[pipelineBrowserDock] = true;
propertiesDock->setAllowedAreas( Qt::LeftDockWidgetArea|Qt::NoDockWidgetArea|Qt::RightDockWidgetArea );
desk->addDockWidget( Qt::LeftDockWidgetArea, propertiesDock );
- pqPropertiesPanel* propertiesPanel = new pqPropertiesPanel(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&) ) );
<source>PREF_STOP_TRACE</source>
<translation>Deactivate Trace (for next session only)</translation>
</message>
+ <message>
+ <source>PREF_NO_EXT_PVSERVER</source>
+ <translation>Do not use external PVServer (Warning: scripts running outside SALOME's GUI will be unusable!)</translation>
+ </message>
<message>
<source>PREF_SHOW_COLOR_LEGEND</source>
<translation>Show Color Legend</translation>
PVViewer_ViewModel.h
PVViewer_ViewWindow.h
PVViewer_Behaviors.h
+ PVViewer_GUIElements.h
)
# header files / no moc processing
PVViewer_ViewWindow.cxx
PVViewer_LogWindowAdapter.cxx
PVViewer_Behaviors.cxx
+ PVViewer_GUIElements.cxx
)
# sources / to compile
new pqCrashRecoveryBehavior(this);
new pqCommandLineOptionsBehavior(this);
- // Create a hidden pqPropertiesPanel()
- hiddenProp = new pqPropertiesPanel(desk);
-
BehaviorLoadingLevel = 1;
}
}
BehaviorLoadingLevel = 2;
}
}
-
-void PVViewer_Behaviors::onEmulateApply()
-{
- if (hiddenProp)
- hiddenProp->apply();
-}
PVViewer_Behaviors(SUIT_Desktop * parent);
void instanciateMinimalBehaviors(SUIT_Desktop * desk);
-
void instanciateAllBehaviors(SUIT_Desktop * desk);
virtual ~PVViewer_Behaviors() {}
-public slots:
- void onEmulateApply();
+//public slots:
+// void onEmulateApply();
private:
static int BehaviorLoadingLevel;
-
- pqPropertiesPanel * hiddenProp;
};
#endif /* PVGUIBEHAVIORS_H_ */
--- /dev/null
+// Copyright (C) 2010-2014 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author: Adrien Bruneton (CEA)
+
+#include "PVViewer_GUIElements.h"
+#include "SUIT_Desktop.h"
+
+#include <pqPropertiesPanel.h>
+#include <pqPipelineBrowserWidget.h>
+#include <pqParaViewMenuBuilders.h>
+
+#include <QMenu>
+#include <QList>
+#include <QAction>
+
+PVViewer_GUIElements * PVViewer_GUIElements::theInstance = 0;
+
+PVViewer_GUIElements::PVViewer_GUIElements(SUIT_Desktop* desk) :
+ propertiesPanel(0), pipelineBrowserWidget(0),
+ sourcesMenu(0)
+{
+ propertiesPanel = new pqPropertiesPanel(desk);
+ pipelineBrowserWidget = new pqPipelineBrowserWidget(desk);
+
+ sourcesMenu = new QMenu(desk);
+ pqParaViewMenuBuilders::buildSourcesMenu(*sourcesMenu, desk);
+
+ filtersMenu = new QMenu(desk);
+ pqParaViewMenuBuilders::buildFiltersMenu(*filtersMenu, desk);
+
+ macrosMenu = new QMenu(desk);
+ pqParaViewMenuBuilders::buildMacrosMenu(*macrosMenu);
+}
+
+PVViewer_GUIElements * PVViewer_GUIElements::GetInstance(SUIT_Desktop* desk)
+{
+ if (! theInstance)
+ theInstance = new PVViewer_GUIElements(desk);
+ return theInstance;
+}
+
+void PVViewer_GUIElements::updateSourcesMenu(QMenu *menu)
+{
+ if (menu)
+ {
+ menu->clear();
+ QList<QAction *> act_list = sourcesMenu->actions();
+ foreach(QAction * a, act_list)
+ {
+ menu->addAction(a);
+ }
+ }
+}
+
+void PVViewer_GUIElements::updateFiltersMenu(QMenu *menu)
+{
+ if (menu)
+ {
+ menu->clear();
+ QList<QAction *> act_list = filtersMenu->actions();
+ foreach(QAction * a, act_list)
+ {
+ menu->addAction(a);
+ }
+ }
+}
+
+void PVViewer_GUIElements::updateMacrosMenu(QMenu *menu)
+{
+ if (menu)
+ {
+ menu->clear();
+ QList<QAction *> act_list = macrosMenu->actions();
+ foreach(QAction * a, act_list)
+ {
+ menu->addAction(a);
+ }
+ }
+}
+
+
+void PVViewer_GUIElements::onEmulateApply()
+{
+ if (propertiesPanel)
+ propertiesPanel->apply();
+}
--- /dev/null
+// Copyright (C) 2010-2014 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author: Adrien Bruneton (CEA)
+
+#ifndef PVVIEWERGUIELEMENTS_H_
+#define PVVIEWERGUIELEMENTS_H_
+
+#include <QObject>
+
+class pqPropertiesPanel;
+class pqPipelineBrowserWidget;
+class SUIT_Desktop;
+class QMenu;
+
+/*!
+ * Some GUI elements of ParaView need to be instanciated in a proper order. This class
+ * holds all of them for the sake of clarity.
+ * For example sources menu should be built *before* loading ParaView's configuration, so that the
+ * list of sources gets properly populated.
+ */
+class PVViewer_GUIElements: public QObject
+{
+ Q_OBJECT
+
+public:
+ static PVViewer_GUIElements * GetInstance(SUIT_Desktop* desk);
+
+ pqPropertiesPanel * getPropertiesPanel() { return propertiesPanel; }
+ pqPipelineBrowserWidget * getPipelineBrowserWidget() { return pipelineBrowserWidget; }
+
+ // Update the sources menu from what was built in private member 'sourcesMenu'
+ void updateSourcesMenu(QMenu *);
+ void updateFiltersMenu(QMenu *);
+ void updateMacrosMenu(QMenu *);
+
+public slots:
+ void onEmulateApply(); // better use the slot from PVViewer_ViewManager if you want to trigger "Apply"
+
+private:
+ PVViewer_GUIElements(SUIT_Desktop* desk);
+ virtual ~PVViewer_GUIElements() {}
+
+ static PVViewer_GUIElements * theInstance;
+
+ // Widgets
+ pqPropertiesPanel * propertiesPanel;
+ pqPipelineBrowserWidget * pipelineBrowserWidget;
+
+ // Dummy QMenus receiving ParaView's reaction for automatic add when new sources are added
+ QMenu * sourcesMenu;
+ QMenu * filtersMenu;
+ QMenu * macrosMenu;
+};
+
+#endif /* PVVIEWERGUIELEMENTS_H_ */
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#include <PVViewer_ViewManager.h>
-#include <PVViewer_ViewModel.h>
-#include <PVViewer_ViewWindow.h>
-#include <PVViewer_Behaviors.h>
-#include <PVViewer_LogWindowAdapter.h>
+#include "PVViewer_ViewManager.h"
+#include "PVViewer_ViewModel.h"
+#include "PVViewer_ViewWindow.h"
+#include "PVViewer_LogWindowAdapter.h"
+#include "PVViewer_GUIElements.h"
+#include "PVViewer_Behaviors.h"
+
#include <utilities.h>
#include <SalomeApp_Application.h>
#include <SALOMEconfig.h>
#include <QApplication>
#include <QStringList>
#include <QDir>
+
#include <string>
#include <pqOptions.h>
#include <pqActiveObjects.h>
#include <pqServerConnectReaction.h>
+#include <pqParaViewMenuBuilders.h>
+#include <pqPipelineBrowserWidget.h>
+
//---------- Static init -----------------
pqPVApplicationCore* PVViewer_ViewManager::MyCoreApp = 0;
PARAVIS_ORB::PARAVIS_Gen_var PVViewer_ViewManager::MyEngine;
Constructor
*/
PVViewer_ViewManager::PVViewer_ViewManager( SUIT_Study* study, SUIT_Desktop* desk )
-: SUIT_ViewManager( study, desk, new PVViewer_Viewer() )
+: SUIT_ViewManager( study, desk, new PVViewer_Viewer() ),
+ desktop(desk)
{
MESSAGE("PARAVIS - view manager created ...")
setTitle( tr( "PARAVIEW_VIEW_TITLE" ) );
// Initialize minimal paraview stuff (if not already done)
ParaviewInitApp(desk);
- connect(this, SIGNAL(viewCreated(SUIT_ViewWindow*)), this, SLOT(onPVViewCreated(SUIT_ViewWindow*)));
+// connect(this, SIGNAL(viewCreated(SUIT_ViewWindow*)), this, SLOT(onPVViewCreated(SUIT_ViewWindow*)));
}
pqPVApplicationCore * PVViewer_ViewManager::GetPVApplication()
free(argv[i]);
delete[] argv;
}
-
+ // Initialize GUI elements if needed:
+ PVViewer_GUIElements::GetInstance(aDesktop);
return true;
}
{
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
QString aPath = resMgr->stringValue("resources", "PARAVIS", QString());
+ std::cout << "loading conf from: " << aPath.toStdString() << std::endl;
if (!aPath.isNull()) {
MyCoreApp->loadConfiguration(aPath + QDir::separator() + "ParaViewFilters.xml");
MyCoreApp->loadConfiguration(aPath + QDir::separator() + "ParaViewReaders.xml");
return true;
}
-void PVViewer_ViewManager::onPVViewCreated(SUIT_ViewWindow* w)
+//void PVViewer_ViewManager::onPVViewCreated(SUIT_ViewWindow* w)
+//{
+// PVViewer_ViewWindow * w2 = dynamic_cast<PVViewer_ViewWindow *>(w);
+// Q_ASSERT(w2 != NULL);
+// connect(w2, SIGNAL(applyRequest()), ParaviewBehaviors, SLOT(onEmulateApply()));
+//}
+
+void PVViewer_ViewManager::onEmulateApply()
{
- PVViewer_ViewWindow * w2 = dynamic_cast<PVViewer_ViewWindow *>(w);
- Q_ASSERT(w2 != NULL);
- connect(w2, SIGNAL(applyRequest()), ParaviewBehaviors, SLOT(onEmulateApply()));
+ PVViewer_GUIElements * guiElements = PVViewer_GUIElements::GetInstance(desktop);
+ guiElements->onEmulateApply();
}
class pqPVApplicationCore;
class PVViewer_Behaviors;
class pqPropertiesPanel;
+class pqPipelineBrowserWidget;
class PVViewer_ViewManager : public SUIT_ViewManager
{
static bool ConnectToExternalPVServer(SUIT_Desktop* aDesktop);
public slots:
- void onPVViewCreated(SUIT_ViewWindow*);
+// void onPVViewCreated(SUIT_ViewWindow*);
+ void onEmulateApply();
private:
static pqPVApplicationCore* MyCoreApp;
static PARAVIS_ORB::PARAVIS_Gen_var MyEngine;
static bool ConfigLoaded;
static PVViewer_Behaviors * ParaviewBehaviors;
+
+ SUIT_Desktop * desktop;
};
#endif
#include "PVViewer_ViewWindow.h"
#include "PVViewer_ViewManager.h"
+#include "PVViewer_GUIElements.h"
#include <SUIT_ViewManager.h>
#include <SUIT_ResourceMgr.h>
setCentralWidget( myPVMgr );
// Finish ParaView set up: behaviors, connection and configurations.
- // None of this is invoked in PARAVIS module case as it done earlier than View creation:
PVViewer_ViewManager::ParaviewInitBehaviors(true, theDesktop);
PVViewer_ViewManager::ConnectToExternalPVServer(theDesktop);
PVViewer_ViewManager::ParaviewLoadConfigurations();