X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FPVGUI%2FPVGUI_Module.cxx;h=d417e1a5b675f7f308ead541e92d6693746d71e0;hb=1d6fe1344be14cbab6bff5cfca040709ac56d51b;hp=8b57095616b160e65f6e3e3ca3921745d700b6c2;hpb=ad6e045970a90f251e67dfeea07127548723b13f;p=modules%2Fparavis.git diff --git a/src/PVGUI/PVGUI_Module.cxx b/src/PVGUI/PVGUI_Module.cxx index 8b570956..d417e1a5 100644 --- a/src/PVGUI/PVGUI_Module.cxx +++ b/src/PVGUI/PVGUI_Module.cxx @@ -19,7 +19,6 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // File : PVGUI_Module.cxx -// Author : Julia DOROVSKIKH #include // E.A. must be included before Python.h to fix compilation on windows #ifdef HAVE_FINITE @@ -32,7 +31,8 @@ # include "PARAVIS_Gen_i.hh" #endif -//#include "PV_Tools.h" +#include CORBA_SERVER_HEADER(SALOME_ModuleCatalog) +#include CORBA_SERVER_HEADER(SALOMEDS) #include "PVGUI_ViewModel.h" #include "PVGUI_ViewManager.h" @@ -119,23 +119,52 @@ #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 +#include +#include +#include #include +#include +#include +#include +#include + +#include + #include #include -#include - -#include CORBA_SERVER_HEADER(SALOME_ModuleCatalog) +// Trace related +#include +#include +#include +#include //---------------------------------------------------------------------------- pqPVApplicationCore* PVGUI_Module::MyCoreApp = 0; @@ -211,25 +240,6 @@ PARAVIS_ORB::PARAVIS_Gen_var PVGUI_Module::myEngine; SALOME module wrapping ParaView GUI. */ - -/* - Fix for the issue 21730: [CEA 596] Slice of polyhedron in PARAVIS returns no cell. - Wrap vtkEDFCutter filter. -*/ - -extern "C" void vtkEDFCutterCS_Initialize(vtkClientServerInterpreter*); -static void vtkEDFHelperInit(); - -void vtkEDFHelperInit(vtkClientServerInterpreter* interp){ - vtkEDFCutterCS_Initialize(interp); -} - -void vtkEDFHelperInit() { - vtkClientServerInterpreterInitializer::GetInitializer()-> - RegisterCallback(&vtkEDFHelperInit); -} - - _PTR(SComponent) ClientFindOrCreateParavisComponent(_PTR(Study) theStudyDocument) { @@ -407,14 +417,17 @@ 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); - } - } + // Find Plugin Menus + // [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()); @@ -552,24 +565,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() { @@ -620,39 +633,6 @@ 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 - { - SalomeApp_Application* app = - dynamic_cast< SalomeApp_Application* >(SUIT_Session::session()->activeApplication()); - PyConsole_Interp* pyInterp = app->pythonConsole()->getInterp(); - PyLockWrapper aGil; - pyInterp->run(cmd.toStdString().c_str()); -// 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 Initialisation timer event - fired only once, after the GUI loop is ready. See creation in initialize(). @@ -662,25 +642,6 @@ void PVGUI_Module::onInitTimer() #ifndef PARAVIS_WITH_FULL_CORBA connectToExternalPVServer(); #endif - -#ifndef WNT -// if ( PyInterp_Dispatcher::Get()->IsBusy() ) -// { -// // Reschedule for later -// MESSAGE("interpreter busy -> rescheduling trace start."); -// startTimer(500); -// } -// else -// { - MESSAGE("timerEvent(): About to start trace...."); - execPythonCommand("from paraview import smtrace;smtrace.start_trace()", false); - MESSAGE("timerEvent(): Trace STARTED...."); -// } -#endif - - MESSAGE("initialize(): Initializing PARAVIS's Python context ..."); - execPythonCommand("import paraview.servermanager as sm; sm.fromGUI=True", false); - MESSAGE("initialize(): Initialized."); } /*! @@ -782,6 +743,8 @@ bool PVGUI_Module::pvInit() */ // End of Initializer code + MyCoreApp->settings(); + vtkOutputWindow::SetInstance(PVGUI_OutputWindowAdapter::New()); new pqTabbedMultiViewWidget(); // it registers as "MULTIVIEW_WIDGET on creation @@ -1091,6 +1054,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 @@ -1135,24 +1128,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) { @@ -1165,7 +1147,7 @@ QString PVGUI_Module::getTraceString() traceString = traceString.replace(aImportPos, MYReplaceImportStr.length(), "except:\n import pvsimple\n from pvsimple import *"); } } -#endif + return traceString; } @@ -1249,8 +1231,9 @@ void PVGUI_Module::createPreferences() setPreferenceProperty(aSaveType, "indexes", aIndices); //rnv: imp 21712: [CEA 581] Preference to display legend by default - int aDispColoreLegend = addPreference( tr( "PREF_SHOW_COLOR_LEGEND" ), aParaVisSettingsTab, - LightApp_Preferences::Bool, "PARAVIS", "show_color_legend"); + // [ABN]: now fixed in ParaView. +// int aDispColoreLegend = addPreference( tr( "PREF_SHOW_COLOR_LEGEND" ), aParaVisSettingsTab, +// LightApp_Preferences::Bool, "PARAVIS", "show_color_legend"); } /*! @@ -1343,10 +1326,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(); } /*! @@ -1650,10 +1631,10 @@ extern "C" { bool flag = false; PVGUI_EXPORT CAM_Module* createModule() { - if(!flag) { - vtkEDFHelperInit(); - flag = true; - } +// if(!flag) { +// vtkEDFHelperInit(); +// flag = true; +// } return new PVGUI_Module(); }