From: sbh Date: Fri, 26 Dec 2014 13:40:58 +0000 (+0300) Subject: "Export to NewGeom" enabled only in SALOME mode. X-Git-Tag: V_0.7.0_rc1~40^2~1^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=841933dc4a26f84ee2f9ce32b27c8c8e5327faf1;p=modules%2Fshaper.git "Export to NewGeom" enabled only in SALOME mode. --- diff --git a/src/Config/Config_Common.cpp b/src/Config/Config_Common.cpp index 634a4337f..2da152dcc 100644 --- a/src/Config/Config_Common.cpp +++ b/src/Config/Config_Common.cpp @@ -130,8 +130,7 @@ std::string getProperty(xmlNodePtr theNode, const char* thePropName) bool getBooleanAttribute(xmlNodePtr theNode, const char* theAttributeName, bool theDefault) { - std::string prop = getProperty(theNode, theAttributeName); - std::transform(prop.begin(), prop.end(), prop.begin(), ::tolower); + std::string prop = normalize(getProperty(theNode, theAttributeName)); bool result = theDefault; if (prop == "true" || prop == "1") { result = true; @@ -140,3 +139,17 @@ bool getBooleanAttribute(xmlNodePtr theNode, const char* theAttributeName, bool } return result; } + +CONFIG_EXPORT std::string normalize(const char* theString) +{ + if (!theString) + return std::string(); + return normalize(std::string(theString)); +} + +CONFIG_EXPORT std::string normalize(const std::string& theString) +{ + std::string result = theString; + std::transform(result.begin(), result.end(), result.begin(), ::tolower); + return result; +} diff --git a/src/Config/Config_Common.h b/src/Config/Config_Common.h index 05e2024fd..a2cc78843 100644 --- a/src/Config/Config_Common.h +++ b/src/Config/Config_Common.h @@ -93,4 +93,11 @@ CONFIG_EXPORT bool getBooleanAttribute(xmlNodePtr theNode, const char* theAttributeName, bool theDefault); +/* + * Returns normalized (lower case) version of string. + * Should be used for case insensitive string matching. + */ +CONFIG_EXPORT std::string normalize(const char* theString); +CONFIG_EXPORT std::string normalize(const std::string& theString); + #endif diff --git a/src/Config/Config_Keywords.h b/src/Config/Config_Keywords.h index bc9f4e419..9fe94e769 100644 --- a/src/Config/Config_Keywords.h +++ b/src/Config/Config_Keywords.h @@ -84,5 +84,11 @@ const static char* PLUGINS_MODULE = "module"; const static char* PLUGIN_CONFIG = "configuration"; const static char* PLUGIN_LIBRARY = "library"; const static char* PLUGIN_SCRIPT = "script"; +const static char* PLUGIN_PLATFORM = "platform"; + +const static char* PLUGIN_PLATFORM_SALOME = "salome"; +const static char* PLUGIN_PLATFORM_NEWGEOM = "openparts"; + + #endif /* CONFIG_KEYWORDS_H_ */ diff --git a/src/Config/Config_ModuleReader.cpp b/src/Config/Config_ModuleReader.cpp index 21925af59..d0da80ba0 100644 --- a/src/Config/Config_ModuleReader.cpp +++ b/src/Config/Config_ModuleReader.cpp @@ -21,9 +21,11 @@ //Necessary for cerr #include +#include #ifdef WIN32 #include +#pragma warning(disable : 4996) // for getenv #else #include #endif @@ -34,6 +36,13 @@ Config_ModuleReader::Config_ModuleReader(const char* theEventGenerated) : Config_XMLReader(PLUGIN_FILE), myEventGenerated(theEventGenerated) { + myHaveSalome = false; + char* anEnv = getenv("SALOME_ROOT_DIR"); + std::string value = normalize(anEnv); + if (!value.empty()) { + myHaveSalome = true; + } + } Config_ModuleReader::~Config_ModuleReader() @@ -61,6 +70,9 @@ std::string Config_ModuleReader::getModuleName() void Config_ModuleReader::processNode(xmlNodePtr theNode) { if (isNode(theNode, NODE_PLUGIN, NULL)) { + bool isAvailable = isAvaliableOnThisPlatform(getProperty(theNode, PLUGIN_PLATFORM)); + if (!isAvailable) + return; std::string aPluginConf = getProperty(theNode, PLUGIN_CONFIG); std::string aPluginLibrary = getProperty(theNode, PLUGIN_LIBRARY); std::string aPluginScript = getProperty(theNode, PLUGIN_SCRIPT); @@ -111,8 +123,8 @@ std::string Config_ModuleReader::addPlugin(const std::string& aPluginLibrary, } if(!aPluginName.empty()) { myPluginTypes[aPluginName] = aType; - } + return aPluginName; } @@ -134,6 +146,29 @@ void Config_ModuleReader::loadPlugin(const std::string thePluginName) } } +bool Config_ModuleReader::isAvaliableOnThisPlatform(const std::string& thePluginPlatform) +{ + bool result = true; + PluginPlatform aPlatform = All; + std::string aPlatformName = normalize(thePluginPlatform) ; + if (aPlatformName == PLUGIN_PLATFORM_SALOME) { + aPlatform = Salome; + } else if (aPlatformName == PLUGIN_PLATFORM_NEWGEOM) { + aPlatform = OpenParts; + } else if (!thePluginPlatform.empty()) { + Events_Error::send("Unknown platform: " + thePluginPlatform); + } + if (aPlatform == All) { + result = true; + } else if (myHaveSalome) { + result = aPlatform == Salome; + } else { + result = aPlatform == OpenParts; + } + return result; + +} + void Config_ModuleReader::loadScript(const std::string theFileName) { /* aquire python thread */ diff --git a/src/Config/Config_ModuleReader.h b/src/Config/Config_ModuleReader.h index 2281eb5cd..c32eb37d9 100644 --- a/src/Config/Config_ModuleReader.h +++ b/src/Config/Config_ModuleReader.h @@ -24,6 +24,11 @@ class Config_ModuleReader : public Config_XMLReader Intrenal = 1, Python = 2 }; + enum PluginPlatform { + All = 0, + OpenParts = 1, + Salome = 2 + }; public: CONFIG_EXPORT Config_ModuleReader(const char* theEventGenerated = 0); @@ -43,6 +48,7 @@ class Config_ModuleReader : public Config_XMLReader void processNode(xmlNodePtr aNode); bool processChildren(xmlNodePtr aNode); + bool isAvaliableOnThisPlatform(const std::string& thePluginPlatform); std::list importPlugin(const std::string& thePluginLibrary, const std::string& thePluginFile); std::string addPlugin(const std::string& aPluginLibrary, @@ -53,6 +59,7 @@ class Config_ModuleReader : public Config_XMLReader std::map myFeaturesInFiles; static std::map myPluginTypes; const char* myEventGenerated; + bool myHaveSalome; }; diff --git a/src/Config/plugins.xml b/src/Config/plugins.xml index 00f45dba9..0f4a25586 100644 --- a/src/Config/plugins.xml +++ b/src/Config/plugins.xml @@ -6,7 +6,7 @@ - + diff --git a/src/ConnectorPlugin/plugin-Connector.xml b/src/ConnectorPlugin/plugin-Connector.xml index 2ba73b203..638d4ecb7 100644 --- a/src/ConnectorPlugin/plugin-Connector.xml +++ b/src/ConnectorPlugin/plugin-Connector.xml @@ -5,7 +5,7 @@ id="ExportToGEOM" title="Export to GEOM" tooltip="Exports all bodies into GEOM module" - icon=":pictures/part_ico.png"/> + icon=":icons/geom_export.png"/> \ No newline at end of file diff --git a/src/PartSet/PartSet_icons.qrc b/src/PartSet/PartSet_icons.qrc index b0bffcc5a..796ec88ef 100644 --- a/src/PartSet/PartSet_icons.qrc +++ b/src/PartSet/PartSet_icons.qrc @@ -28,5 +28,6 @@ icons/shape_group.png icons/fixed.png icons/placement.png + icons/geom_export.png diff --git a/src/PartSet/icons/geom_export.png b/src/PartSet/icons/geom_export.png new file mode 100644 index 000000000..07ec5ddcd Binary files /dev/null and b/src/PartSet/icons/geom_export.png differ