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}")
#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);
+ }
}
}
#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);
}
}