// PARAVIS : ParaView wrapper SALOME module
//
-// Copyright (C) 2010-2012 CEA/DEN, EDF R&D
+// 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.
+// 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
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
#include <SUIT_OverrideCursor.h>
+#include <SUIT_ExceptionHandler.h>
// SALOME Includes
#include "SALOME_LifeCycleCORBA.hxx"
#include <SALOME_ListIO.hxx>
#include <SALOMEDS_Tool.hxx>
#include <PyInterp_Dispatcher.h>
+#include <PyConsole_Console.h>
#include <QtxActionMenuMgr.h>
#include <QtxActionToolMgr.h>
#include <pqPipelineSource.h>
#include <pqActiveObjects.h>
#include <vtkProcessModule.h>
+#include <vtkSMSession.h>
+#include <vtkPVSession.h>
+#include <vtkPVProgressHandler.h>
#include <pqParaViewBehaviors.h>
#include <pqHelpReaction.h>
#include <vtkOutputWindow.h>
#include <pqPythonDialog.h>
#include <pqPythonManager.h>
#include <pqPythonShell.h>
-#include <pqBrandPluginsLoader.h>
+//#include <pqBrandPluginsLoader.h>
#include <pqLoadDataReaction.h>
#include <vtkEventQtSlotConnect.h>
#include <pqPythonScriptEditor.h>
#include <pqPipelineRepresentation.h>
#include <pqLookupTableManager.h>
#include <pqDisplayColorWidget.h>
+#include <pqColorToolbar.h>
+#include <pqScalarBarVisibilityReaction.h>
+#include <pqStandardPropertyWidgetInterface.h>
+#include <pqMultiServerBehavior.h>
+#include <pqViewStreamingBehavior.h>
#include <PARAVIS_version.h>
#include <vtkPVConfig.h>
+#include <PVGUI_MatplotlibMathTextUtilities.h>
+
#include CORBA_SERVER_HEADER(SALOME_ModuleCatalog)
/*
* collect.
*/
-#include <vtkCommonInstantiator.h>
-#include <vtkFilteringInstantiator.h>
-#include <vtkGenericFilteringInstantiator.h>
-#include <vtkIOInstantiator.h>
-#include <vtkImagingInstantiator.h>
-#include <vtkInfovisInstantiator.h>
-#include <vtkGraphicsInstantiator.h>
+//#include <vtkCommonInstantiator.h>
+//#include <vtkFilteringInstantiator.h>
+//#include <vtkGenericFilteringInstantiator.h>
+//#include <vtkIOInstantiator.h>
+//#include <vtkImagingInstantiator.h>
+//#include <vtkInfovisInstantiator.h>
+//#include <vtkGraphicsInstantiator.h>
-#include <vtkRenderingInstantiator.h>
-#include <vtkVolumeRenderingInstantiator.h>
-#include <vtkHybridInstantiator.h>
-#include <vtkParallelInstantiator.h>
+//#include <vtkRenderingInstantiator.h>
+//#include <vtkVolumeRenderingInstantiator.h>
+//#include <vtkHybridInstantiator.h>
+//#include <vtkParallelInstantiator.h>
#include <pqAlwaysConnectedBehavior.h>
#include <pqApplicationCore.h>
return aSComponent;
}
+/*!
+ Clean up function; used to stop ParaView progress events when
+ exception is caught by global exception handler.
+*/
+void paravisCleanUp()
+{
+ if ( pqApplicationCore::instance() ) {
+ pqServer* s = pqApplicationCore::instance()->getActiveServer();
+ if ( s ) s->session()->GetProgressHandler()->CleanupPendingProgress();
+ }
+}
+
/*!
\brief Constructor. Sets the default name for the module.
*/
PVGUI_Module::PVGUI_Module()
: SalomeApp_Module( "PARAVIS" ),
- LightApp_Module( "PARAVIS" ),
// Implementation( 0 ),
mySelectionControlsTb( -1 ),
mySourcesMenuId( -1 ),
#endif
ParavisModule = this;
- // Clear old macros
+ // Clear old copies of embedded macros files
QString aDestPath = QString( "%1/.config/%2/Macros" ).arg( QDir::homePath() ).arg( QApplication::applicationName() );
QStringList aFilter;
aFilter << "*.py";
QDir aDestDir(aDestPath);
QStringList aDestFiles = aDestDir.entryList(aFilter, QDir::Files);
- foreach (QString aStr, aDestFiles) {
- aDestDir.remove(aStr);
+ foreach (QString aMacrosPath, getEmbeddedMacrosList()) {
+ QString aMacrosName = QFileInfo(aMacrosPath).fileName();
+ if (aDestFiles.contains(aMacrosName)) {
+ aDestDir.remove(aMacrosName);
+ }
}
}
*/
void PVGUI_Module::initialize( CAM_Application* app )
{
+ //VTN: Disable conflict with python initialization for MatPlot.
+ PVGUI_MatplotlibMathTextUtilities::Disable();
+
SalomeApp_Module::initialize( app );
// Create ParaViS actions
pvCreateToolBars();
pvCreateMenus();
+ QList<QDockWidget*> activeDocks = aDesktop->findChildren<QDockWidget*>();
+ QList<QMenu*> activeMenus = aDesktop->findChildren<QMenu*>();
+
// new pqParaViewBehaviors(anApp->desktop(), this);
// Has to be replaced in order to exclude using of pqQtMessageHandlerBehaviour
// Start pqParaViewBehaviors
// * adds support for standard paraview views.
pgm->addInterface(new pqStandardViewModules(pgm));
pgm->addInterface(new pqStandardSummaryPanelImplementation(pgm));
+ pgm->addInterface(new pqStandardPropertyWidgetInterface(pgm));
// Load plugins distributed with application.
pqApplicationCore::instance()->loadDistributedPlugins();
new pqPersistentMainWindowStateBehavior(aDesktop);
new pqObjectPickingBehavior(aDesktop);
new pqCollaborationBehavior(this);
+ new pqMultiServerBehavior(this);
+ new pqViewStreamingBehavior(this);
// Setup quick-launch shortcuts.
QShortcut *ctrlSpace = new QShortcut(Qt::CTRL + Qt::Key_Space, aDesktop);
QObject::connect(ctrlSpace, SIGNAL(activated()),
pqApplicationCore::instance(), SLOT(quickLaunch()));
- QShortcut *altSpace = new QShortcut(Qt::ALT + Qt::Key_Space, aDesktop);
- QObject::connect(altSpace, SIGNAL(activated()),
- pqApplicationCore::instance(), SLOT(quickLaunch()));
- // End pqParaViewBehaviors
+ // Find Plugin Dock Widgets
+ QList<QDockWidget*> currentDocks = aDesktop->findChildren<QDockWidget*>();
+ QList<QDockWidget*>::iterator i;
+ for (i = currentDocks.begin(); i != currentDocks.end(); ++i) {
+ if(!activeDocks.contains(*i)) {
+ myDockWidgets[*i] = false; // hidden by default
+ (*i)->hide();
+ }
+ }
+
+ // Find Plugin Menus
+ QList<QMenu*> currentMenus = aDesktop->findChildren<QMenu*>();
+ QList<QMenu*>::iterator im;
+ for (im = currentMenus.begin(); im != currentMenus.end(); ++im) {
+ if(!activeMenus.contains(*im)) {
+ myMenus.append(*im);
+ }
+ }
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
QString aPath = resMgr->stringValue("resources", "PARAVIS", QString());
bool isStop = aResourceMgr->booleanValue( "PARAVIS", "stop_trace", false );
// start timer to activate trace in a proper moment
if(!isStop)
- startTimer( 50 );
+ startTimer( 1000 );
this->VTKConnect = vtkEventQtSlotConnect::New();
+
vtkProcessModule* pm = vtkProcessModule::GetProcessModule();
-
- this->VTKConnect->Connect(pm, vtkCommand::StartEvent,
- this, SLOT(onStartProgress()));
- this->VTKConnect->Connect(pm, vtkCommand::EndEvent,
- this, SLOT(onEndProgress()));
-
+ if(pm) {
+ vtkPVSession* pvs = dynamic_cast<vtkPVSession*>(pm->GetSession());
+ if(pvs) {
+ vtkPVProgressHandler* ph = pvs->GetProgressHandler();
+ if(ph) {
+ this->VTKConnect->Connect(ph, vtkCommand::StartEvent,
+ this, SLOT(onStartProgress()));
+ this->VTKConnect->Connect(ph, vtkCommand::EndEvent,
+ this, SLOT(onEndProgress()));
+ }
+ }
+ }
+
connect(&pqActiveObjects::instance(),
SIGNAL(representationChanged(pqRepresentation*)),
this, SLOT(onRepresentationChanged(pqRepresentation*)));
SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
bool isStop = aResourceMgr->booleanValue( "PARAVIS", "stop_trace", false );
if(!isStop)
- startTimer( 50 );
+ startTimer( 500 );
}
void PVGUI_Module::onDataRepresentationCreated(pqDataRepresentation* data) {
if(lut_mgr) {
lut_mgr->setScalarBarVisibility(data,visible);
}
+
+ connect(data, SIGNAL(dataUpdated()), this, SLOT(onDataRepresentationUpdated()));
+}
+
+void PVGUI_Module::onDataRepresentationUpdated() {
+ SalomeApp_Study* activeStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
+ if(!activeStudy) return;
+
+ activeStudy->Modified();
}
void PVGUI_Module::onVariableChanged(pqVariableType t, const QString) {
if( t == VARIABLE_TYPE_NONE )
return;
- pqDataRepresentation* data = colorWidget->getRepresentation();
-
- if( !data->getLookupTable() )
- return;
-
SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
if(!aResourceMgr)
if(!visible)
return;
+ /*//VTN: getRepresentation is protected
+ pqDataRepresentation* data = colorWidget->getRepresentation();
+
+ if( !data->getLookupTable() )
+ return;
+
pqLookupTableManager* lut_mgr = pqApplicationCore::instance()->getLookupTableManager();
if(lut_mgr) {
lut_mgr->setScalarBarVisibility(data,visible);
}
-
-}
+ */
+ pqColorToolbar* colorTooBar = qobject_cast<pqColorToolbar*>(colorWidget->parent());
+ if( !colorTooBar )
+ return;
+ pqScalarBarVisibilityReaction* scalarBarVisibility = colorTooBar->findChild<pqScalarBarVisibilityReaction *>();
+ if(scalarBarVisibility) {
+ scalarBarVisibility->setScalarBarVisibility(visible);
+ }
+}
-/*!
- \brief Launches a tracing of current server
-*/
-void PVGUI_Module::timerEvent(QTimerEvent* te )
+void PVGUI_Module::execPythonCommand(const QString& cmd, bool inSalomeConsole)
{
-#ifndef WNT
- PyInterp_Dispatcher* aDispatcher = PyInterp_Dispatcher::Get();
- if ( !aDispatcher->IsBusy() ) {
+ if ( PyInterp_Dispatcher::Get()->IsBusy() ) return;
+ if ( inSalomeConsole ) {
+ SalomeApp_Application* app =
+ dynamic_cast< SalomeApp_Application* >(SUIT_Session::session()->activeApplication());
+ PyConsole_Console* pyConsole = app->pythonConsole();
+ if (pyConsole)
+ pyConsole->exec(cmd);
+ }
+ else {
pqPythonManager* manager = qobject_cast<pqPythonManager*>
( pqApplicationCore::instance()->manager( "PYTHON_MANAGER" ) );
if ( manager ) {
if ( pyDiag ) {
pqPythonShell* shell = pyDiag->shell();
if ( shell ) {
- QString script = "from paraview import smtrace\nsmtrace.start_trace()\n";
- shell->executeScript(script);
- killTimer( te->timerId() );
+ shell->executeScript(cmd);
}
}
}
}
+}
+
+/*!
+ \brief Launches a tracing of current server
+*/
+void PVGUI_Module::timerEvent(QTimerEvent* te )
+{
+#ifndef WNT
+ execPythonCommand("from paraview import smtrace\nsmtrace.start_trace()\n", false);
+ killTimer( te->timerId() );
#endif
}
-void PVGUI_Module::updateMacros()
+/*!
+ \brief Get list of embedded macros files
+*/
+QStringList PVGUI_Module::getEmbeddedMacrosList()
{
- pqPythonManager* aPythonManager = pqPVApplicationCore::instance()->pythonManager();
- if(!aPythonManager) {
- return;
- }
-
QString aRootDir = getenv("PARAVIS_ROOT_DIR");
QString aSourcePath = aRootDir + "/bin/salome/Macro";
QDir aSourceDir(aSourcePath);
QStringList aSourceFiles = aSourceDir.entryList(aFilter, QDir::Files);
- foreach (QString aStr, aSourceFiles) {
- aPythonManager->addMacro(aSourcePath + "/" + aStr);
+ QStringList aFullPathSourceFiles;
+ foreach (QString aMacrosName, aSourceFiles) {
+ aFullPathSourceFiles << aSourceDir.absoluteFilePath(aMacrosName);
+ }
+ return aFullPathSourceFiles;
+}
+
+void PVGUI_Module::updateMacros()
+{
+ pqPythonManager* aPythonManager = pqPVApplicationCore::instance()->pythonManager();
+ if(!aPythonManager) {
+ return;
+ }
+
+ foreach (QString aStr, getEmbeddedMacrosList()) {
+ aPythonManager->addMacro(aStr);
}
}
return false;
}
+ /* VTN: Looks like trash. For porting see branded_paraview_initializer.cxx.in
// Not sure why this is needed. Andy added this ages ago with comment saying
// needed for Mac apps. Need to check that it's indeed still required.
QDir dir(QApplication::applicationDirPath());
plugin_string = "";
plugin_list = plugin_string.split(';',QString::SkipEmptyParts);
loader.loadPlugins(plugin_list, true); //quietly skip not-found plugins.
-
+ */
// End of Initializer code
vtkOutputWindow::SetInstance(PVGUI_OutputWindowAdapter::New());
bool PVGUI_Module::activateModule( SUIT_Study* study )
{
myOldMsgHandler = qInstallMsgHandler(ParavisMessageOutput);
+
+ SUIT_ExceptionHandler::addCleanUpRoutine( paravisCleanUp );
+
+ storeCommonWindowsState();
bool isDone = SalomeApp_Module::activateModule( study );
if ( !isDone ) return false;
restoreDockWidgetsState();
- QMenu* aMenu = menuMgr()->findMenu( myRecentMenuId );
- if(aMenu) {
- QList<QAction*> anActns = aMenu->actions();
- for (int i = 0; i < anActns.size(); ++i) {
- QAction* a = anActns.at(i);
- if(a)
- a->setVisible(true);
- }
+ QMenu* aMenu = menuMgr()->findMenu( myRecentMenuId );
+ if(aMenu) {
+ QList<QAction*> anActns = aMenu->actions();
+ for (int i = 0; i < anActns.size(); ++i) {
+ QAction* a = anActns.at(i);
+ if(a)
+ a->setVisible(true);
}
+ }
+
+ QList<QMenu*>::iterator it;
+ for (it = myMenus.begin(); it != myMenus.end(); ++it) {
+ QAction* a = (*it)->menuAction();
+ if(a)
+ a->setVisible(true);
+ }
if ( myRecentMenuId != -1 ) menuMgr()->show(myRecentMenuId);
*/
bool PVGUI_Module::deactivateModule( SUIT_Study* study )
{
- QMenu* aMenu = menuMgr()->findMenu( myRecentMenuId );
- if(aMenu) {
- QList<QAction*> anActns = aMenu->actions();
- for (int i = 0; i < anActns.size(); ++i) {
- QAction* a = anActns.at(i);
- if(a)
- a->setVisible(false);
- }
+ QMenu* aMenu = menuMgr()->findMenu( myRecentMenuId );
+ if(aMenu) {
+ QList<QAction*> anActns = aMenu->actions();
+ for (int i = 0; i < anActns.size(); ++i) {
+ QAction* a = anActns.at(i);
+ if(a)
+ a->setVisible(false);
}
+ }
+
+ QList<QMenu*>::iterator it;
+ for (it = myMenus.begin(); it != myMenus.end(); ++it) {
+ QAction* a = (*it)->menuAction();
+ if(a)
+ a->setVisible(false);
+ }
QList<QDockWidget*> aStreamingViews = application()->desktop()->findChildren<QDockWidget*>("pqStreamingControls");
foreach(QDockWidget* aView, aStreamingViews) {
saveDockWidgetsState();
+ SUIT_ExceptionHandler::removeCleanUpRoutine( paravisCleanUp );
+
if (myOldMsgHandler)
qInstallMsgHandler(myOldMsgHandler);
+ restoreCommonWindowsState();
+
return SalomeApp_Module::deactivateModule( study );
}
}
}
+/*!
+ \brief. Show ParaView python trace.
+*/
void PVGUI_Module::onShowTrace()
{
if (!myTraceWindow) {
myTraceWindow->activateWindow();
}
+
+/*!
+ \brief. Re-initialize ParaView python trace.
+*/
+void PVGUI_Module::onRestartTrace()
+{
+ QString script = "from paraview import smtrace\n";
+ script += "smtrace.stop_trace()\n";
+ script += "smtrace.start_trace()\n";
+ execPythonCommand(script, false);
+}
+
/*!
\brief Show ParaView view.
*/