// PARAVIS : ParaView wrapper SALOME module
//
-// Copyright (C) 2010-2015 CEA/DEN, EDF R&D
+// Copyright (C) 2010-2016 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
#include "PVViewer_ViewModel.h"
#include "PVGUI_ParaViewSettingsPane.h"
#include "PVViewer_GUIElements.h"
-#include "PVViewer_EngineWrapper.h"
+#include "PVServer_ServiceWrapper.h"
#include "PVGUI_DataModel.h"
// SALOME Includes
/*!
\class PVGUI_Module
- \brief Implementation
+ \brief Implementation
SALOME module wrapping ParaView GUI.
*/
: LightApp_Module( PARAVIS_MODULE_NAME ),
mySourcesMenuId( -1 ),
myFiltersMenuId( -1 ),
+#ifdef PVCATALYST_ENABLED
+ myCatalystMenuId(-1),
+#endif
myMacrosMenuId(-1),
myRecentMenuId(-1),
myOldMsgHandler(0),
by the PVViewer code in GUI (class PVViewer_EngineWrapper).
\sa GetCPPEngine()
*/
-PVViewer_EngineWrapper* PVGUI_Module::GetEngine()
+PVServer_ServiceWrapper* PVGUI_Module::GetEngine()
{
- return PVViewer_EngineWrapper::GetInstance();
+ return PVServer_ServiceWrapper::GetInstance();
}
/*!
}
updateMacros();
-
+
SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
bool isStop = aResourceMgr->booleanValue( PARAVIS_MODULE_NAME, "stop_trace", false );
if(!isStop)
}
this->VTKConnect = vtkEventQtSlotConnect::New();
-
+
vtkProcessModule* pm = vtkProcessModule::GetProcessModule();
if(pm) {
vtkPVSession* pvs = dynamic_cast<vtkPVSession*>(pm->GetSession());
}
}
}
+ connect( application(), SIGNAL( appClosed() ), this, SLOT( onStopTrace() ) );
}
/*!
void PVGUI_Module::onDataRepresentationUpdated() {
LightApp_Study* activeStudy = dynamic_cast<LightApp_Study*>(application()->activeStudy());
if(!activeStudy) return;
-
+
activeStudy->Modified();
}
{
startTrace();
}
-
+
/*!
\brief Get list of embedded macros files
*/
if(!aPythonManager) {
return;
}
-
+
foreach (QString aStr, getEmbeddedMacrosList()) {
aPythonManager->addMacro(aStr);
}
// this also connects to the pvserver and instantiates relevant PV behaviors
}
- pvWnd->setShown( toShow );
+ pvWnd->setVisible( toShow );
if ( toShow ) pvWnd->setFocus();
}
{
QApplication::restoreOverrideCursor();
}
-
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
/*!
\brief Handler method for the output of messages.
*/
break;
}
}
-
+#else
+/*!
+ \brief Handler method for the output of messages.
+*/
+static void ParavisMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
+{
+ switch(type)
+ {
+ case QtDebugMsg:
+ vtkOutputWindow::GetInstance()->DisplayText(msg.toLatin1().constData());
+ break;
+ case QtWarningMsg:
+ vtkOutputWindow::GetInstance()->DisplayErrorText(msg.toLatin1().constData());
+ break;
+ case QtCriticalMsg:
+ vtkOutputWindow::GetInstance()->DisplayErrorText(msg.toLatin1().constData());
+ break;
+ case QtFatalMsg:
+ vtkOutputWindow::GetInstance()->DisplayErrorText(msg.toLatin1().constData());
+ break;
+ }
+}
+#endif
/*!
\brief Activate module.
\param study current study
*/
bool PVGUI_Module::activateModule( SUIT_Study* study )
{
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
myOldMsgHandler = qInstallMsgHandler(ParavisMessageOutput);
-
+#else
+ myOldMsgHandler = qInstallMessageHandler(ParavisMessageOutput);
+#endif
SUIT_ExceptionHandler::addCleanUpRoutine( paravisCleanUp );
storeCommonWindowsState();
showView( true );
if ( mySourcesMenuId != -1 ) menuMgr()->show(mySourcesMenuId);
if ( myFiltersMenuId != -1 ) menuMgr()->show(myFiltersMenuId);
+#ifdef PVCATALYST_ENABLED
+ if ( myCatalystMenuId != -1 ) menuMgr()->show(myCatalystMenuId);
+#endif
if ( myMacrosMenuId != -1 ) menuMgr()->show(myMacrosMenuId);
// Update the various menus with the content pre-loaded in myGuiElements
// myGuiElements->updateSourcesMenu(srcMenu);
// QMenu* filtMenu = menuMgr()->findMenu( myFiltersMenuId );
// myGuiElements->updateFiltersMenu(filtMenu);
+//#ifdef PVCATALYST_ENABLED
+// QMenu* catalystMenu = menuMgr()->findMenu( myCatalystMenuId );
+// myGuiElements->updateCatalystMenu(catalystMenu);
+//#endif
// QMenu* macMenu = menuMgr()->findMenu( myMacrosMenuId );
// myGuiElements->updateMacrosMenu(macMenu);
}
if ( myRecentMenuId != -1 ) menuMgr()->show(myRecentMenuId);
-
+
return isDone;
}
menuMgr()->hide(myRecentMenuId);
menuMgr()->hide(mySourcesMenuId);
menuMgr()->hide(myFiltersMenuId);
+#ifdef PVCATALYST_ENABLED
+ menuMgr()->hide(myCatalystMenuId);
+#endif
menuMgr()->hide(myMacrosMenuId);
setMenuShown( false );
setToolShown( false );
SUIT_ExceptionHandler::removeCleanUpRoutine( paravisCleanUp );
if (myOldMsgHandler)
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
qInstallMsgHandler(myOldMsgHandler);
-
+#else
+ qInstallMessageHandler(myOldMsgHandler);
+#endif
restoreCommonWindowsState();
-
+
return LightApp_Module::deactivateModule( study );
}
{
showView(false); // VSR: this seems to be not needed (all views are automatically closed)
clearParaviewState();
- //Re-start trace
+ //Re-start trace
onRestartTrace();
LightApp_Module::studyClosed(study);
/*!
\brief Starts Python trace.
-
+
Start trace invoking the newly introduced C++ API (PV 4.2)
(inspired from pqTraceReaction::start())
*/
if ( manager ) {
pqPythonDialog* pyDiag = manager->pythonShellDialog();
if ( pyDiag ) {
- pyDiag->runString(script);
+ pyDiag->runString(script);
}
}
#endif
}
// Save camera position to, which is no longer output by the tracer ...
- VTK_PY_GIL_ENSURE
- PyObject * mods(PySys_GetObject(const_cast<char*>("modules")));
- PyObject * trace_mod(PyDict_GetItemString(mods, "paraview.smtrace")); // module was already (really) imported by vtkSMTrace
- if (PyModule_Check(trace_mod)) {
- vtkSmartPyObject save_cam(PyObject_GetAttrString(trace_mod, const_cast<char*>("SaveCameras")));
- vtkSmartPyObject camera_trace(PyObject_CallMethod(save_cam, const_cast<char*>("get_trace"), NULL));
- // Convert to a single string
- vtkSmartPyObject ret(PyString_FromString(end_line.toStdString().c_str()));
- vtkSmartPyObject final_string(PyObject_CallMethod(ret, const_cast<char*>("join"),
- const_cast<char*>("O"), (PyObject*)camera_trace));
- if (PyString_CheckExact(final_string))
- {
- QString camera_qs(PyString_AsString(final_string)); // deep copy
- traceString = traceString + end_line + end_line + QString("#### saving camera placements for all active views")
- + end_line + end_line + camera_qs + end_line;
- }
- }
- VTK_PY_GIL_RELEASE
+ {
+ vtkPythonScopeGilEnsurer psge;
+ PyObject * mods(PySys_GetObject(const_cast<char*>("modules")));
+ PyObject * trace_mod(PyDict_GetItemString(mods, "paraview.smtrace")); // module was already (really) imported by vtkSMTrace
+ if (PyModule_Check(trace_mod)) {
+ vtkSmartPyObject save_cam(PyObject_GetAttrString(trace_mod, const_cast<char*>("SaveCameras")));
+ vtkSmartPyObject camera_trace(PyObject_CallMethod(save_cam, const_cast<char*>("get_trace"), NULL));
+ // Convert to a single string
+ vtkSmartPyObject ret(PyString_FromString(end_line.toStdString().c_str()));
+ vtkSmartPyObject final_string(PyObject_CallMethod(ret, const_cast<char*>("join"),
+ const_cast<char*>("O"), (PyObject*)camera_trace));
+ if (PyString_CheckExact(final_string))
+ {
+ QString camera_qs(PyString_AsString(final_string)); // deep copy
+ traceString = traceString + end_line + end_line + QString("#### saving camera placements for all active views")
+ + end_line + end_line + camera_qs + end_line;
+ }
+ }
+ }
return traceString;
}
/*!
\brief Saves ParaView state to a disk file
*/
-void PVGUI_Module::saveParaviewState( const char* theFileName )
+void PVGUI_Module::saveParaviewState( const QString& theFileName )
{
- pqApplicationCore::instance()->saveState( theFileName );
+ pqApplicationCore::instance()->saveState( theFileName.toStdString().c_str() );
}
/*!
/*!
\brief Restores ParaView state from a disk file
*/
-void PVGUI_Module::loadParaviewState( const char* theFileName )
+void PVGUI_Module::loadParaviewState( const QString& theFileName )
{
- pqApplicationCore::instance()->loadState( theFileName, getActiveServer() );
+ pqApplicationCore::instance()->loadState( theFileName.toStdString().c_str(), getActiveServer() );
}
/*!
// Paravis settings tab
int aParaVisSettingsTab = addPreference( tr( "TIT_PVISSETTINGS" ) );
- addPreference( tr( "PREF_NO_EXT_PVSERVER" ), aParaVisSettingsTab,
+ addPreference( tr( "PREF_NO_EXT_PVSERVER" ), aParaVisSettingsTab,
LightApp_Preferences::Bool, PARAVIS_MODULE_NAME, "no_ext_pv_server" );
- /* VSR: not used
int aSaveType = addPreference( tr( "PREF_SAVE_TYPE_LBL" ), aParaVisSettingsTab,
LightApp_Preferences::Selector,
PARAVIS_MODULE_NAME, "savestate_type" );
aStrings << tr("PREF_SAVE_TYPE_0") << tr("PREF_SAVE_TYPE_1") << tr("PREF_SAVE_TYPE_2");
setPreferenceProperty( aSaveType, "strings", aStrings );
setPreferenceProperty( aSaveType, "indexes", aIndices );
- */
// ... "Language" group <<start>>
int traceGroup = addPreference( tr( "PREF_GROUP_TRACE" ), aParaVisSettingsTab );
- int stopTrace = addPreference( tr( "PREF_STOP_TRACE" ), traceGroup,
+ int stopTrace = addPreference( tr( "PREF_STOP_TRACE" ), traceGroup,
LightApp_Preferences::Bool, PARAVIS_MODULE_NAME, "stop_trace" );
setPreferenceProperty( stopTrace, "restart", true );
startTrace();
}
+/*!
+ \brief. Close ParaView python trace.
+*/
+void PVGUI_Module::onStopTrace()
+{
+ stopTrace();
+}
/*!
\brief Called when view manager is added
*/
void PVGUI_Module::onViewManagerAdded( SUIT_ViewManager* vm )
{
if ( PVViewer_ViewManager* pvvm = dynamic_cast<PVViewer_ViewManager*>( vm ) ) {
- connect( pvvm, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
+ connect( pvvm, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
this, SLOT( onPVViewCreated( SUIT_ViewWindow* ) ) );
connect( pvvm, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
this, SLOT( onPVViewDelete( SUIT_ViewWindow* ) ) );
PVGUI_EXPORT CAM_Module* createModule() {
return new PVGUI_Module();
}
-
+
PVGUI_EXPORT char* getModuleVersion() {
return (char*)PARAVIS_VERSION_STR;
}