Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / Config / Config_FeatureReader.cpp
index b9454e04d26d1ade98511b4daa5edb76bc2ea6c9..6e6bbb85f6f7abdbb656619f58b35bce114f308c 100644 (file)
@@ -9,14 +9,15 @@
 #include <Config_Common.h>
 #include <Config_FeatureMessage.h>
 #include <Config_FeatureReader.h>
-#include <Event_Message.h>
-#include <Event_Loop.h>
+#include <Events_Message.h>
+#include <Events_Loop.h>
 
 #include <libxml/parser.h>
 #include <libxml/tree.h>
 #include <libxml/xmlstring.h>
 
 #include <string>
+#include <algorithm>
 
 #ifdef _DEBUG
 #include <iostream>
@@ -28,7 +29,7 @@ Config_FeatureReader::Config_FeatureReader(const std::string& theXmlFile,
                                            const char* theEventGenerated)
     : Config_XMLReader(theXmlFile),
       myLibraryName(theLibraryName),
-      myEventGenerated(theEventGenerated ? theEventGenerated : "FeatureEvent")
+      myEventGenerated(theEventGenerated ? theEventGenerated : EVENT_FEATURE_LOADED)
 {
 }
 
@@ -43,9 +44,9 @@ std::list<std::string> Config_FeatureReader::features() const
 
 void Config_FeatureReader::processNode(xmlNodePtr theNode)
 {
-  Event_ID aMenuItemEvent = Event_Loop::eventByName(myEventGenerated);
+  Events_ID aMenuItemEvent = Events_Loop::eventByName(myEventGenerated);
   if (isNode(theNode, NODE_FEATURE, NULL)) {
-    Event_Loop* aEvLoop = Event_Loop::loop();
+    Events_Loop* aEvLoop = Events_Loop::loop();
     Config_FeatureMessage aMessage(aMenuItemEvent, this);
     fillFeature(theNode, aMessage);
     myFeatures.push_back(getProperty(theNode, _ID));
@@ -60,6 +61,8 @@ void Config_FeatureReader::processNode(xmlNodePtr theNode)
   if (isNode(theNode, NODE_WORKBENCH, NULL)) {
     myLastWorkbench = getProperty(theNode, _ID);
   }
+  //Process SOURCE nodes.
+  Config_XMLReader::processNode(theNode);
 }
 
 bool Config_FeatureReader::processChildren(xmlNodePtr theNode)
@@ -70,11 +73,28 @@ bool Config_FeatureReader::processChildren(xmlNodePtr theNode)
 void Config_FeatureReader::fillFeature(xmlNodePtr theRoot, Config_FeatureMessage& outFtMessage)
 {
   outFtMessage.setId(getProperty(theRoot, _ID));
+  outFtMessage.setPluginLibrary(myLibraryName);
+  outFtMessage.setNestedFeatures(getProperty(theRoot, FEATURE_NESTED));
+  bool isFtInternal = isInternalFeature(theRoot);
+  outFtMessage.setInternal(isFtInternal);
+  if(isFtInternal) {
+    //Internal feature has no visual representation.
+    return;
+  }
   outFtMessage.setText(getProperty(theRoot, FEATURE_TEXT));
   outFtMessage.setTooltip(getProperty(theRoot, FEATURE_TOOLTIP));
   outFtMessage.setIcon(getProperty(theRoot, FEATURE_ICON));
   outFtMessage.setKeysequence(getProperty(theRoot, FEATURE_KEYSEQUENCE));
   outFtMessage.setGroupId(myLastGroup);
   outFtMessage.setWorkbenchId(myLastWorkbench);
-  outFtMessage.setPluginLibrary(myLibraryName);
+}
+
+bool Config_FeatureReader::isInternalFeature(xmlNodePtr theRoot)
+{
+  std::string prop = getProperty(theRoot, FEATURE_INTERNAL);
+  std::transform(prop.begin(), prop.end(), prop.begin(), ::tolower);
+  if(prop.empty() || prop == "false" || prop == "0") {
+    return false;
+  }
+  return true;
 }