From: akl Date: Mon, 31 Mar 2014 10:21:11 +0000 (+0400) Subject: Fix of 0022530: [CEA 1108] The new macros are deleted at Paravis launch X-Git-Tag: V7_4_0a1~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=426d802b883d87c37928df9f874497c26518c56b;p=modules%2Fparavis.git Fix of 0022530: [CEA 1108] The new macros are deleted at Paravis launch --- diff --git a/src/Macro/CMakeLists.txt b/src/Macro/CMakeLists.txt index 2a8ad152..33bced28 100644 --- a/src/Macro/CMakeLists.txt +++ b/src/Macro/CMakeLists.txt @@ -21,4 +21,24 @@ SET(_PYFILES_TO_INSTALL modes.py ) -INSTALL_AND_COMPILE_PYTHON_FILE("${_PYFILES_TO_INSTALL}" ${SALOME_INSTALL_SCRIPT_PYTHON}/Macro) +# Add warning message into scripts to be installed +INSTALL(CODE " + SET(warning_str \"\# DO NOT MAKE CHANGES to this file, it will be rewrote +\# on activation of SALOME PARAVIS module. +\# Modify the source file instead.\") + + FOREACH(file ${_PYFILES_TO_INSTALL}) + SET(tmp_file tmp/\${file}) + FILE(READ ${CMAKE_CURRENT_SOURCE_DIR}/\${file} tmp_string) + STRING(REPLACE \"\# Do not touch this anchor comment\" \"\${warning_str}\" new_tmp_string \${tmp_string}) + FILE(WRITE \${tmp_file} \${new_tmp_string}) + ENDFOREACH() +") + +# Install of the modified scripts +FOREACH(file ${_PYFILES_TO_INSTALL}) + INSTALL_AND_COMPILE_PYTHON_FILE(${CMAKE_CURRENT_BINARY_DIR}/tmp/\${file} ${SALOME_INSTALL_SCRIPT_PYTHON}/Macro) +ENDFOREACH() + +SET(MAKE_CLEAN_FILES tmp) +SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${MAKE_CLEAN_FILES}") diff --git a/src/Macro/modes.py b/src/Macro/modes.py index eaf168fb..731f6aea 100644 --- a/src/Macro/modes.py +++ b/src/Macro/modes.py @@ -17,6 +17,10 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # +# +# Do not touch this anchor comment +# + try: paraview.simple except: from paraview.simple import * paraview.simple._DisableFirstRenderCameraReset() diff --git a/src/PVGUI/PVGUI_Module.cxx b/src/PVGUI/PVGUI_Module.cxx index 3555f9ad..dcf2a702 100644 --- a/src/PVGUI/PVGUI_Module.cxx +++ b/src/PVGUI/PVGUI_Module.cxx @@ -351,15 +351,18 @@ PVGUI_Module::PVGUI_Module() #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); + } } } @@ -672,13 +675,11 @@ void PVGUI_Module::timerEvent(QTimerEvent* te ) #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"; @@ -688,8 +689,22 @@ void PVGUI_Module::updateMacros() 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); } } diff --git a/src/PVGUI/PVGUI_Module.h b/src/PVGUI/PVGUI_Module.h index fef41de7..e55567c1 100644 --- a/src/PVGUI/PVGUI_Module.h +++ b/src/PVGUI/PVGUI_Module.h @@ -208,6 +208,9 @@ private: //! Load selected state void loadSelectedState(bool toClear); + //! Get list of embedded macros files + QStringList getEmbeddedMacrosList(); + //! update macros state void updateMacros();