\r
bool getBooleanAttribute(xmlNodePtr theNode, const char* theAttributeName, bool theDefault)\r
{\r
- std::string prop = getProperty(theNode, theAttributeName);\r
- std::transform(prop.begin(), prop.end(), prop.begin(), ::tolower);\r
+ std::string prop = normalize(getProperty(theNode, theAttributeName));\r
bool result = theDefault;\r
if (prop == "true" || prop == "1") {\r
result = true;\r
}\r
return result;\r
}\r
+\r
+CONFIG_EXPORT std::string normalize(const char* theString)\r
+{\r
+ if (!theString)\r
+ return std::string();\r
+ return normalize(std::string(theString));\r
+}\r
+\r
+CONFIG_EXPORT std::string normalize(const std::string& theString)\r
+{\r
+ std::string result = theString;\r
+ std::transform(result.begin(), result.end(), result.begin(), ::tolower);\r
+ return result;\r
+}\r
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
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_ */
//Necessary for cerr
#include <iostream>
+#include <algorithm>
#ifdef WIN32
#include <windows.h>
+#pragma warning(disable : 4996) // for getenv
#else
#include <dlfcn.h>
#endif
: 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()
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);
}
if(!aPluginName.empty()) {
myPluginTypes[aPluginName] = aType;
-
}
+
return aPluginName;
}
}
}
+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 */
Intrenal = 1,
Python = 2
};
+ enum PluginPlatform {
+ All = 0,
+ OpenParts = 1,
+ Salome = 2
+ };
public:
CONFIG_EXPORT Config_ModuleReader(const char* theEventGenerated = 0);
void processNode(xmlNodePtr aNode);
bool processChildren(xmlNodePtr aNode);
+ bool isAvaliableOnThisPlatform(const std::string& thePluginPlatform);
std::list<std::string> importPlugin(const std::string& thePluginLibrary,
const std::string& thePluginFile);
std::string addPlugin(const std::string& aPluginLibrary,
std::map<std::string, std::string> myFeaturesInFiles;
static std::map<std::string, PluginType> myPluginTypes;
const char* myEventGenerated;
+ bool myHaveSalome;
};
<plugin library="ConstructionPlugin" configuration="plugin-Construction.xml"/>
<plugin library="FeaturesPlugin" configuration="plugin-Features.xml"/>
<plugin library="ExchangePlugin" configuration="plugin-Exchange.xml"/>
- <plugin script="ConnectorPlugin" configuration="plugin-Connector.xml"/>
+ <plugin script="ConnectorPlugin" configuration="plugin-Connector.xml" platform="Salome"/>
<plugin library="SketchSolver"/>
<plugin library="GeomValidators"/>
<plugin library="DFBrowser" internal="true"/>
id="ExportToGEOM"
title="Export to GEOM"
tooltip="Exports all bodies into GEOM module"
- icon=":pictures/part_ico.png"/>
+ icon=":icons/geom_export.png"/>
</group>
</workbench>
</plugin>
\ No newline at end of file
<file>icons/shape_group.png</file>
<file>icons/fixed.png</file>
<file>icons/placement.png</file>
+ <file>icons/geom_export.png</file>
</qresource>
</RCC>