From: abn Date: Tue, 9 Sep 2014 14:43:00 +0000 (+0200) Subject: Porting to PV4.2: first stage ready. X-Git-Tag: V7_5_0a1~1^2~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=71e226017e82285fdb81ab04ed32703cff1ba7f3;p=modules%2Fparavis.git Porting to PV4.2: first stage ready. * Basic functions OK * Trace OK * New Settings Panel: not integrated * Plugins: not ported. --- diff --git a/src/PVGUI/CMakeLists.txt b/src/PVGUI/CMakeLists.txt index fc2bcaba..26b900bf 100644 --- a/src/PVGUI/CMakeLists.txt +++ b/src/PVGUI/CMakeLists.txt @@ -64,7 +64,7 @@ SET(_moc_HEADERS PVGUI_ViewManager.h PVGUI_ViewModel.h PVGUI_ViewWindow.h - PVGUI_ParaViewSettingsPane.h + # PVGUI_ParaViewSettingsPane.h ) # header files / no moc processing @@ -136,7 +136,7 @@ SET(_other_SOURCES PVGUI_ViewWindow.cxx PVGUI_OutputWindowAdapter.cxx PVGUI_Tools.cxx - PVGUI_ParaViewSettingsPane.cxx +# PVGUI_ParaViewSettingsPane.cxx #PVGUI_MatplotlibMathTextUtilities.cxx PARAVIS_Gen_i.cc PV_Tools.cxx diff --git a/src/PVGUI/PVGUI_Module.cxx b/src/PVGUI/PVGUI_Module.cxx index caa1fa87..d2882e41 100644 --- a/src/PVGUI/PVGUI_Module.cxx +++ b/src/PVGUI/PVGUI_Module.cxx @@ -43,7 +43,7 @@ #include "PVGUI_ViewManager.h" #include "PVGUI_ViewWindow.h" #include "PVGUI_Tools.h" -#include "PVGUI_ParaViewSettingsPane.h" +//#include "PVGUI_ParaViewSettingsPane.h" #include "PVGUI_OutputWindowAdapter.h" #include @@ -122,11 +122,12 @@ #include #include #include -#include +//#include #include #include #include #include +#include #include #include @@ -143,22 +144,29 @@ #include #include #include -#include #include #include #include #include #include #include -#include #include -#include #include -#include #include +#include +#include +#include +#include + +#include #include +// Trace related +#include +#include +#include +#include //---------------------------------------------------------------------------- pqPVApplicationCore* PVGUI_Module::MyCoreApp = 0; @@ -406,10 +414,10 @@ void PVGUI_Module::initialize( CAM_Application* app ) //pqPluginManager* pgm = pqApplicationCore::instance()->getPluginManager(); pqInterfaceTracker* pgm = pqApplicationCore::instance()->interfaceTracker(); - // * adds support for standard paraview views. - pgm->addInterface(new pqStandardViewModules(pgm)); - //pgm->addInterface(new pqStandardSummaryPanelImplementation(pgm)); + // Register standard types of property widgets. pgm->addInterface(new pqStandardPropertyWidgetInterface(pgm)); + // Register standard types of view-frame actions. + pgm->addInterface(new pqStandardViewFrameActionsImplementation(pgm)); // Load plugins distributed with application. pqApplicationCore::instance()->loadDistributedPlugins(); @@ -417,27 +425,30 @@ void PVGUI_Module::initialize( CAM_Application* app ) // Define application behaviors. //new pqQtMessageHandlerBehavior(this); new pqDataTimeStepBehavior(this); - new pqViewFrameActionsBehavior(this); new pqSpreadSheetVisibilityBehavior(this); new pqPipelineContextMenuBehavior(this); - new pqObjectPickingBehavior(this); // NEW in 4.1 + new pqObjectPickingBehavior(this); new pqDefaultViewBehavior(this); - new pqAlwaysConnectedBehavior(this); - new pqPVNewSourceBehavior(this); - new pqDeleteBehavior(this); new pqUndoRedoBehavior(this); + new pqAlwaysConnectedBehavior(this); new pqCrashRecoveryBehavior(this); new pqAutoLoadPluginXMLBehavior(this); new pqPluginDockWidgetsBehavior(aDesktop); - //new pqVerifyRequiredPluginBehavior(this); + new pqVerifyRequiredPluginBehavior(this); new pqPluginActionGroupBehavior(aDesktop); - //new pqFixPathsInStateFilesBehavior(this); + new pqFixPathsInStateFilesBehavior(this); new pqCommandLineOptionsBehavior(this); new pqPersistentMainWindowStateBehavior(aDesktop); - new pqObjectPickingBehavior(aDesktop); new pqCollaborationBehavior(this); - //new pqMultiServerBehavior(this); new pqViewStreamingBehavior(this); + new pqPluginSettingsBehavior(this); + + pqApplyBehavior* applyBehavior = new pqApplyBehavior(this); + foreach (pqPropertiesPanel* ppanel, aDesktop->findChildren()) + { + applyBehavior->registerPanel(ppanel); + } + // Setup quick-launch shortcuts. QShortcut *ctrlSpace = new QShortcut(Qt::CTRL + Qt::Key_Space, aDesktop); @@ -455,13 +466,16 @@ void PVGUI_Module::initialize( CAM_Application* app ) } // Find Plugin Menus - QList currentMenus = aDesktop->findChildren(); - QList::iterator im; - for (im = currentMenus.begin(); im != currentMenus.end(); ++im) { - if(!activeMenus.contains(*im)) { - myMenus.append(*im); - } - } + // [ABN] TODO: fix this - triggers a SEGFAULT at deactivation() time. +// QList currentMenus = aDesktop->findChildren(); +// QList::iterator im; +// for (im = currentMenus.begin(); im != currentMenus.end(); ++im) { +// if(!activeMenus.contains(*im)) { +// QString s = (*im)->title(); +// std::cout << " MENU "<< s.toStdString() << std::endl; +// myMenus.append(*im); +// } +// } SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); QString aPath = resMgr->stringValue("resources", "PARAVIS", QString()); @@ -546,24 +560,24 @@ void PVGUI_Module::onFinishedAddingServer(pqServer* /*server*/) } void PVGUI_Module::onDataRepresentationCreated(pqDataRepresentation* data) { - if(!data) - return; - - if(!data->getLookupTable()) - return; - - SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr(); - if(!aResourceMgr) - return; - - bool visible = aResourceMgr->booleanValue( "PARAVIS", "show_color_legend", false ); - pqLookupTableManager* lut_mgr = pqApplicationCore::instance()->getLookupTableManager(); - - if(lut_mgr) { - lut_mgr->setScalarBarVisibility(data,visible); - } - - connect(data, SIGNAL(dataUpdated()), this, SLOT(onDataRepresentationUpdated())); +// if(!data) +// return; +// +// if(!data->getLookupTable()) +// return; +// +// SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr(); +// if(!aResourceMgr) +// return; +// +// bool visible = aResourceMgr->booleanValue( "PARAVIS", "show_color_legend", false ); +// pqLookupTableManager* lut_mgr = pqApplicationCore::instance()->getLookupTableManager(); +// +// if(lut_mgr) { +// lut_mgr->setScalarBarVisibility(data,visible); +// } +// +// connect(data, SIGNAL(dataUpdated()), this, SLOT(onDataRepresentationUpdated())); } void PVGUI_Module::onDataRepresentationUpdated() { @@ -614,54 +628,26 @@ void PVGUI_Module::onVariableChanged(pqVariableType t, const QString) { } } -void PVGUI_Module::execPythonCommand(const QString& cmd, bool inSalomeConsole) -{ - if ( inSalomeConsole ) { - if ( PyInterp_Dispatcher::Get()->IsBusy() ) return; - 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 - ( pqApplicationCore::instance()->manager( "PYTHON_MANAGER" ) ); - if ( manager ) - { - pqPythonDialog* pyDiag = manager->pythonShellDialog(); - if ( pyDiag ) - { - pqPythonShell* shell = pyDiag->shell(); - if ( shell ) { - shell->executeScript(cmd); - } - } - } - } -} - /*! \brief Launches a tracing of current server */ void PVGUI_Module::timerEvent(QTimerEvent* te ) { -#ifndef WNT - if ( PyInterp_Dispatcher::Get()->IsBusy() ) - { - // Reschedule for later - MESSAGE("interpreter busy -> rescheduling trace start."); - startTimer(500); - } - else - { +//#ifndef WNT +// if ( PyInterp_Dispatcher::Get()->IsBusy() ) +// { +// // Reschedule for later +// MESSAGE("interpreter busy -> rescheduling trace start."); +// startTimer(500); +// } +// else +// { MESSAGE("about to start trace...."); - execPythonCommand("from paraview import smtrace;smtrace.start_trace()", false); + startTrace(); MESSAGE("trace STARTED...."); - } +// } killTimer( te->timerId() ); -#endif +//#endif } /*! @@ -1058,6 +1044,36 @@ void PVGUI_Module::openFile(const char* theName) pqLoadDataReaction::loadData(aFiles); } +/**! + * Start trace invoking the newly introduced C++ API (PV 4.2) + * (inspired from pqTraceReaction::start()) + */ +void PVGUI_Module::startTrace() +{ + vtkSMSessionProxyManager* pxm = pqActiveObjects::instance().activeServer()->proxyManager(); + + vtkSmartPointer proxy; + proxy.TakeReference(pxm->NewProxy("pythontracing", "PythonTraceOptions")); + if (proxy) + { + vtkNew controller; + controller->InitializeProxy(proxy); + } + vtkSMTrace* trace = vtkSMTrace::StartTrace(); + if (proxy) + { + // Set manually the properties entered via the dialog box poping-up when requiring + // a trace start in PV4.2 (trace options) + trace->SetPropertiesToTraceOnCreate(vtkSMTrace::RECORD_USER_MODIFIED_PROPERTIES); + trace->SetFullyTraceSupplementalProxies(false); + } +} + +void PVGUI_Module::stopTrace() +{ + vtkSMTrace::StopTrace(); +} + void PVGUI_Module::executeScript(const char *script) { #ifndef WNT @@ -1102,24 +1118,13 @@ static const QString MYReplaceStr("paraview.simple"); static const QString MYReplaceImportStr("except: from pvsimple import *"); QString PVGUI_Module::getTraceString() { - QString traceString; -#ifndef WNT - { - PyLockWrapper lck; // Acquire GIL - - const char * code = "from paraview import smtrace;" - "__smtraceString = smtrace.get_trace_string()"; - PyRun_SimpleString(code); - // Now get the value of __smtraceString - PyObject* main_module = PyImport_AddModule((char*)"__main__"); - PyObject* global_dict = PyModule_GetDict(main_module); - PyObject* string_object = PyDict_GetItemString(global_dict, "__smtraceString"); - char* string_ptr = string_object ? PyString_AsString(string_object) : 0; - if (string_ptr) { - traceString = string_ptr; - } - } // release GIL + vtkSMTrace *tracer = vtkSMTrace::GetActiveTracer(); + if (!tracer) // trace is not started + return QString(""); + QString traceString(tracer->GetCurrentTrace()); + + // Replace import "paraview.simple" by "pvsimple" if ((!traceString.isNull()) && traceString.length() != 0) { int aPos = traceString.indexOf(MYReplaceStr); while (aPos != -1) { @@ -1132,7 +1137,7 @@ QString PVGUI_Module::getTraceString() traceString = traceString.replace(aImportPos, MYReplaceImportStr.length(), "except:\n import pvsimple\n from pvsimple import *"); } } -#endif + return traceString; } @@ -1192,7 +1197,7 @@ void PVGUI_Module::onImportFromVisu(QString theEntry) SalomeApp_Study* activeStudy = dynamic_cast(application()->activeStudy()); if(!activeStudy) return; - // get SALOMEDS client study + // get SALOMEDS client study _PTR(Study) aStudy = activeStudy->studyDS(); if(!aStudy) return; @@ -1267,9 +1272,9 @@ pqServer* PVGUI_Module::getActiveServer() void PVGUI_Module::createPreferences() { // Paraview settings tab - int aParaViewSettingsTab = addPreference( tr( "TIT_PVIEWSETTINGS" ) ); - int aPanel = addPreference(QString(), aParaViewSettingsTab, LightApp_Preferences::UserDefined, "PARAVIS", ""); - setPreferenceProperty(aPanel, "content", (qint64)(new PVGUI_ParaViewSettingsPane())); +// int aParaViewSettingsTab = addPreference( tr( "TIT_PVIEWSETTINGS" ) ); +// int aPanel = addPreference(QString(), aParaViewSettingsTab, LightApp_Preferences::UserDefined, "PARAVIS", ""); +// setPreferenceProperty(aPanel, "content", (qint64)(new PVGUI_ParaViewSettingsPane())); // Paravis settings tab int aParaVisSettingsTab = addPreference( tr( "TIT_PVISSETTINGS" ) ); @@ -1382,10 +1387,8 @@ void PVGUI_Module::onShowTrace() */ void PVGUI_Module::onRestartTrace() { - QString script = "from paraview import smtrace\n"; - script += "smtrace.stop_trace()\n"; - script += "smtrace.start_trace()\n"; - execPythonCommand(script, false); + stopTrace(); + startTrace(); } /*! diff --git a/src/PVGUI/PVGUI_Module.h b/src/PVGUI/PVGUI_Module.h index 0b30e767..9208709a 100644 --- a/src/PVGUI/PVGUI_Module.h +++ b/src/PVGUI/PVGUI_Module.h @@ -154,6 +154,8 @@ public: void clearParaviewState(); QString getTraceString(); + void startTrace(); + void stopTrace(); void saveTrace(const char* theName); pqServer* getActiveServer(); @@ -221,9 +223,6 @@ private: //! restore visibility of the common dockable windows (OB, PyConsole, ... etc.) void restoreCommonWindowsState(); - //! run Python command (either in SALOME's Python interpreter, or in ParaView's Python's interpreter) - void execPythonCommand(const QString& cmd, bool inSalomeConsole=false); - private slots: void showHelpForProxy( const QString&, const QString& ); diff --git a/src/PVGUI/PVGUI_Module_actions.cxx b/src/PVGUI/PVGUI_Module_actions.cxx index 638a3673..1fdefc33 100644 --- a/src/PVGUI/PVGUI_Module_actions.cxx +++ b/src/PVGUI/PVGUI_Module_actions.cxx @@ -41,8 +41,8 @@ #include // #include #include -#include -#include +//#include +//#include #include #include @@ -61,7 +61,7 @@ #include #include #include -#include +//#include #include #include #include @@ -255,11 +255,11 @@ void PVGUI_Module::pvCreateActions() new pqApplicationSettingsReaction(anAction);*/ // View Settings - anAction = new QAction(tr("MEN_VIEW_SETTINGS"), this); - anAction->setToolTip(tr("TOP_VIEW_SETTINGS")); - anAction->setStatusTip(tr("STB_VIEW_SETTINGS")); - registerAction(ViewSettingsId, anAction); - new pqViewSettingsReaction(anAction); +// anAction = new QAction(tr("MEN_VIEW_SETTINGS"), this); +// anAction->setToolTip(tr("TOP_VIEW_SETTINGS")); +// anAction->setStatusTip(tr("STB_VIEW_SETTINGS")); +// registerAction(ViewSettingsId, anAction); +// new pqViewSettingsReaction(anAction); // --- Menu "View" //pqViewManager* viewManager = qobject_cast( @@ -465,7 +465,7 @@ void PVGUI_Module::pvCreateMenus() createMenu( separator(), aPVMnu ); //createMenu( SettingsId, aPVMnu ); - createMenu( ViewSettingsId, aPVMnu ); + //createMenu( ViewSettingsId, aPVMnu ); createMenu( separator(), aPVMnu ); // --- Menu "View" diff --git a/src/PVGUI/PVGUI_Module_widgets.cxx b/src/PVGUI/PVGUI_Module_widgets.cxx index 76624da9..965b30b7 100644 --- a/src/PVGUI/PVGUI_Module_widgets.cxx +++ b/src/PVGUI/PVGUI_Module_widgets.cxx @@ -54,26 +54,11 @@ #include #include #include -#include -#include +//#include +#include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include -#include -#include -#include -#include #include #include #include @@ -107,7 +92,8 @@ protected: /*! \brief Create dock widgets for ParaView widgets such as object inspector, pipeline browser, etc. - ParaView pqMainWIndowCore class is fully responsible for these dock widgets' contents. + ParaView pqMainWindowCore class is fully responsible for these dock widgets' contents. + ==> To update this function, see the reference set up of ParaView in Application/Paraview/ParaviewMainWindow.ui */ void PVGUI_Module::setupDockWidgets() { @@ -126,40 +112,39 @@ void PVGUI_Module::setupDockWidgets() pipelineBrowserDock->setWidget(browser); myDockWidgets[pipelineBrowserDock] = true; - //Object inspector - QDockWidget* objectInspectorDock = new QDockWidget( tr( "TTL_OBJECT_INSPECTOR" ), desk ); - objectInspectorDock->setObjectName("objectInspectorDock"); - objectInspectorDock->setAllowedAreas( Qt::LeftDockWidgetArea|Qt::NoDockWidgetArea|Qt::RightDockWidgetArea ); - desk->addDockWidget( Qt::LeftDockWidgetArea, objectInspectorDock ); + // 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 ); + desk->addDockWidget( Qt::LeftDockWidgetArea, propertiesDock ); - pqObjectInspectorWidget* objectInspectorWidget = new pqObjectInspectorWidget(objectInspectorDock); - objectInspectorDock->setObjectName("objectInspectorWidget"); - objectInspectorWidget->setShowOnAccept(true); - objectInspectorDock->setWidget(objectInspectorWidget); - connect( objectInspectorWidget, SIGNAL( helpRequested(const QString&, const QString&) ), this, SLOT( showHelpForProxy(const QString&, const QString&) ) ); - myDockWidgets[objectInspectorDock] = true; + pqPropertiesPanel* propertiesPanel = new pqPropertiesPanel(propertiesDock); + propertiesDock->setObjectName("propertiesPanel"); + propertiesDock->setWidget(propertiesPanel); + connect( propertiesPanel, SIGNAL( helpRequested(const QString&, const QString&) ), this, SLOT( showHelpForProxy(const QString&, const QString&) ) ); + myDockWidgets[propertiesDock] = true; //Display Dock - QDockWidget* displayDock = new QDockWidget( tr( "TTL_DISPLAY" ), desk ); - displayDock->setObjectName("displayDock"); - QWidget* displayWidgetFrame = new QWidget(displayDock); - displayWidgetFrame->setObjectName("displayWidgetFrame"); - displayDock->setWidget(displayWidgetFrame); - - QScrollArea* displayScrollArea = new QScrollArea(displayWidgetFrame); - displayScrollArea->setObjectName("displayScrollArea"); - displayScrollArea->setWidgetResizable(true); - - QVBoxLayout* verticalLayout = new QVBoxLayout(displayWidgetFrame); - verticalLayout->setSpacing(0); - verticalLayout->setContentsMargins(0, 0, 0, 0); - - pqDisplayProxyEditorWidget* displayWidget = new pqDisplayProxyEditorWidget(displayDock); - displayWidget->setObjectName("displayWidget"); - displayScrollArea->setWidget(displayWidget); - verticalLayout->addWidget(displayScrollArea); - - myDockWidgets[displayDock] = true; +// QDockWidget* displayDock = new QDockWidget( tr( "TTL_DISPLAY" ), desk ); +// displayDock->setObjectName("displayDock"); +// QWidget* displayWidgetFrame = new QWidget(displayDock); +// displayWidgetFrame->setObjectName("displayWidgetFrame"); +// displayDock->setWidget(displayWidgetFrame); +// +// QScrollArea* displayScrollArea = new QScrollArea(displayWidgetFrame); +// displayScrollArea->setObjectName("displayScrollArea"); +// displayScrollArea->setWidgetResizable(true); +// +// QVBoxLayout* verticalLayout = new QVBoxLayout(displayWidgetFrame); +// verticalLayout->setSpacing(0); +// verticalLayout->setContentsMargins(0, 0, 0, 0); +// +// pqDisplayProxyEditorWidget* displayWidget = new pqDisplayProxyEditorWidget(displayDock); +// displayWidget->setObjectName("displayWidget"); +// displayScrollArea->setWidget(displayWidget); +// verticalLayout->addWidget(displayScrollArea); +// +// myDockWidgets[displayDock] = true; // information dock QDockWidget* informationDock = new QDockWidget(tr( "TTL_INFORMATION" ), desk); @@ -187,10 +172,8 @@ void PVGUI_Module::setupDockWidgets() myDockWidgets[informationDock] = true; desk->setTabPosition(Qt::LeftDockWidgetArea, QTabWidget::North); - desk->tabifyDockWidget(objectInspectorDock, displayDock); - desk->tabifyDockWidget(objectInspectorDock, informationDock); - objectInspectorDock->raise(); - + desk->tabifyDockWidget(propertiesDock, informationDock); + propertiesDock->raise(); // Statistic View QDockWidget* statisticsViewDock = new QDockWidget( tr( "TTL_STATISTICS_VIEW" ), desk ); diff --git a/src/Plugins/CMakeLists.txt b/src/Plugins/CMakeLists.txt index cba2bb54..d0aecd68 100755 --- a/src/Plugins/CMakeLists.txt +++ b/src/Plugins/CMakeLists.txt @@ -29,9 +29,9 @@ ENDIF() SET(_subdirs #Filter #ToolBar - MEDReader - TableReader - NavigationMode +# MEDReader +# TableReader +# NavigationMode ElevationSurface ScaleVector EllipseBuilder