]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
"Internal" feature XML procesing. Fixes #40
authorsbh <sergey.belash@opencascade.com>
Wed, 21 May 2014 13:58:10 +0000 (17:58 +0400)
committersbh <sergey.belash@opencascade.com>
Wed, 21 May 2014 13:58:10 +0000 (17:58 +0400)
src/Config/Config_FeatureMessage.cpp
src/Config/Config_FeatureMessage.h
src/Config/Config_FeatureReader.cpp
src/Config/Config_FeatureReader.h
src/Config/Config_Keywords.h
src/Config/Config_ModuleReader.cpp
src/ConstructionPlugin/plugin-Construction.xml
src/ModelAPI/ModelAPI_PluginManager.cpp
src/SketchPlugin/plugin-Sketch.xml
src/XGUI/XGUI_Workshop.cpp

index 9408522e6a9f90c4ce1fcbead4f96ff3cf7217b8..7b0f603371f6c7823df85b0e33fb086efefe7322 100644 (file)
@@ -14,6 +14,11 @@ Config_FeatureMessage::Config_FeatureMessage(const Events_ID theId, const void*
 
   myGroupId = "";
   myWorkbenchId = "";
+  myPluginLibrary = "";
+
+  myInternal = false;
+  myUseInput = false;
+  myNestedFeatures = "";
 }
 
 const std::string& Config_FeatureMessage::icon() const
@@ -101,11 +106,21 @@ bool Config_FeatureMessage::isUseInput() const
   return myUseInput;
 }
 
+bool Config_FeatureMessage::isInternal() const
+{
+  return myInternal;
+}
+
 void Config_FeatureMessage::setUseInput(bool isUseInput)
 {
   myUseInput = isUseInput;
 }
 
+void Config_FeatureMessage::setInternal(bool isInternal)
+{
+  myInternal = isInternal;
+}
+
 const std::string& Config_FeatureMessage::nestedFeatures() const
 {
   return myNestedFeatures;
index 99116d707e0f9be53ace04483b9d9c3b627d5dc8..9328e0690775df4e1fb7bdc44ba625477bb3a846 100644 (file)
@@ -27,6 +27,7 @@ class Config_FeatureMessage: public Events_Message
   std::string myPluginLibrary;  //Name of feature's library\r
 \r
   bool myUseInput; //Action is being checked until user commit the operation\r
+  bool myInternal; //Internal feature without GUI representation\r
   std::string myNestedFeatures;\r
 \r
 public:\r
@@ -45,6 +46,7 @@ public:
   CONFIG_EXPORT const std::string& pluginLibrary() const;\r
   CONFIG_EXPORT const std::string& nestedFeatures() const;\r
   CONFIG_EXPORT bool isUseInput() const;\r
+  CONFIG_EXPORT bool isInternal() const;\r
 \r
   CONFIG_EXPORT void setIcon(const std::string& icon);\r
   CONFIG_EXPORT void setId(const std::string& id);\r
@@ -56,6 +58,7 @@ public:
   CONFIG_EXPORT void setPluginLibrary(const std::string& thePluginLibrary);\r
   CONFIG_EXPORT void setNestedFeatures(const std::string& theNestedFeatures);\r
   CONFIG_EXPORT void setUseInput(bool isUseInput);\r
+  CONFIG_EXPORT void setInternal(bool isInternal);\r
 };\r
 \r
 #endif // CONFIG_MESSAGE_H\r
index 78e485e912d1b5e294d160c57b380e57273aff39..6e6bbb85f6f7abdbb656619f58b35bce114f308c 100644 (file)
@@ -17,6 +17,7 @@
 #include <libxml/xmlstring.h>
 
 #include <string>
+#include <algorithm>
 
 #ifdef _DEBUG
 #include <iostream>
@@ -72,12 +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);
-  outFtMessage.setNestedFeatures(getProperty(theRoot, FEATURE_NESTED));
+}
+
+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;
 }
index e4e7c63db8590674f4feb7c61fe0688083a1c7e8..1add8438d464da227b792435783df3907af2ce2c 100644 (file)
@@ -31,6 +31,7 @@ protected:
   bool processChildren(xmlNodePtr aNode);
 
   void fillFeature(xmlNodePtr theRoot, Config_FeatureMessage& outFeatureMessage);
+  bool isInternalFeature(xmlNodePtr theRoot);
 
 private:
   std::string myLastWorkbench;
index 281248f858314326cc871cef581e3d655f054355..25433ffa9ad55ca8143bb309167cb368645e9919 100644 (file)
@@ -39,6 +39,7 @@ const static char* FEATURE_TOOLTIP = "tooltip";
 const static char* FEATURE_ICON = "icon";
 const static char* FEATURE_KEYSEQUENCE = "keysequence";
 const static char* FEATURE_NESTED = "nested";
+const static char* FEATURE_INTERNAL = "internal";
 const static char* SOURCE_FILE = "path";
 
 
index 0291b83b4db3039eb1fe97a22d37c8153e66bb6f..9d9a78a021bff806585e244192c4236934a69ddb 100644 (file)
@@ -84,9 +84,6 @@ std::list<std::string> Config_ModuleReader::importPlugin(const std::string& theP
 
 void Config_ModuleReader::loadLibrary(const std::string theLibName)
 {
-#ifdef _DEBUG
-  std::cout << "Config_ModuleReader::loading library... "  << theLibName.c_str() << std::endl;
-#endif
   std::string aFileName = library(theLibName);
   if (aFileName.empty())
     return;
index 912d04e0ca636ce6e2acd9dfd7598ccde8300029..26a27bc83ef32f3b901e92ccc6d691dbe96bd10b 100644 (file)
@@ -4,8 +4,8 @@
       <feature id="Point" text="Point" tooltip="Create a new point" icon=":icons/point.png">
         <source path="point_widget.xml"/>
       </feature>
-      <feature id="Axis" text="Axis" tooltip="Create a new axis" icon=":icons/axis.png" keysequence=""/>
-      <feature id="Plane" text="Plane" tooltip="Create a new plane" icon=":icons/plane.png" keysequence=""/>
+      <feature id="Axis" text="Axis" tooltip="Create a new axis" icon=":icons/axis.png" keysequence="" internal="true"/>
+      <feature id="Plane" text="Plane" tooltip="Create a new plane" icon=":icons/plane.png" keysequence="" internal="true"/>
     </group>
   </workbench>  
 </plugin>
index a8d497c7c6986d6146148f7d525e83c54b09374d..eb79b9d03d3a7e0c32e119be73a8b43204bc353c 100644 (file)
@@ -49,9 +49,6 @@ void ModelAPI_PluginManager::SetPluginManager(
 boost::shared_ptr<ModelAPI_PluginManager> ModelAPI_PluginManager::get()
 {
   if (!MY_MANAGER) { // import Model library that implements this interface of ModelAPI
-    #ifdef _DEBUG
-    std::cout << "ModelAPI_PluginManager::get: " << "Model library has not been loaded from xml." << std::endl;
-    #endif
     Config_ModuleReader::loadLibrary("Model");
   }
   return MY_MANAGER;
index 29cf61b04a16a7c8ad45c3e60295d10fdf4c4dcf..5f100983e57b9645a43805fb5f94d5269709c26b 100644 (file)
@@ -5,12 +5,12 @@
         <label text="Select a plane on which to create a sketch" tooltip="Select a plane on which to create a sketch"/> 
       <!--icon=":pictures/x_point.png"-->
       </feature>
-      <feature id="SketchPoint" text="Point" tooltip="Create a new point" icon=":icons/point.png" />
+      <feature id="SketchPoint" text="Point" tooltip="Create a new point" icon=":icons/point.png"/>
       <feature id="SketchLine" text="Line" tooltip="Create a new line" icon=":icons/line.png">
         <point_selector id="StartPoint" title="Start point" tooltip="Start point of the line"/>
         <point_selector id="EndPoint" title="End point" tooltip="End point of the line"/>
       </feature>
-      <feature id="SketchConstraintCoincidence" text="Points coincidence" tooltip="Create constraint for the coincidence of two points" icon="" />
+      <feature id="SketchConstraintCoincidence" text="Points coincidence" tooltip="Create constraint for the coincidence of two points" internal="1"/>
     </group>
   </workbench>
 </plugin>
index 85046a2db26f5ded3eb2a860dfcbd747ee9d7a83..cb7a3c790f8dc44558b5cab53359f64736428bbb 100644 (file)
@@ -200,7 +200,9 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage)
   static Events_ID aFeatureLoadedId = Events_Loop::loop()->eventByName(EVENT_FEATURE_LOADED);
   if (theMessage->eventID() == aFeatureLoadedId) {
     const Config_FeatureMessage* aFeatureMsg = dynamic_cast<const Config_FeatureMessage*>(theMessage);
-    addFeature(aFeatureMsg);
+    if(!aFeatureMsg->isInternal()) {
+      addFeature(aFeatureMsg);
+    }
     return;
   }
   //Update property panel on corresponding message. If there is no current operation (no