Salome HOME
Bugfix and set Point to the Construction groups
authormpv <mikhail.ponikarov@opencascade.com>
Mon, 7 Apr 2014 07:36:12 +0000 (11:36 +0400)
committermpv <mikhail.ponikarov@opencascade.com>
Mon, 7 Apr 2014 07:36:12 +0000 (11:36 +0400)
src/Model/Model_Document.cxx
src/Model/Model_Document.h
src/ModelAPI/ModelAPI_Document.h
src/PartSetPlugin/PartSetPlugin_Plugin.cxx

index 8ae42585b7e73eb99630932d8d5b60f7501ba501..38f05c85ff473d0440a845ce5be0cbfff1642533 100644 (file)
@@ -207,6 +207,11 @@ shared_ptr<ModelAPI_Feature> Model_Document::feature(const string& theGroupID, c
   return anIter->current();
 }
 
+const vector<string>& Model_Document::getGroups() const
+{
+  return myGroupsNames;
+}
+
 Model_Document::Model_Document(const std::string theID)
     : myID(theID), myDoc(new TDocStd_Document("BinOcaf")) // binary OCAF format
 {
@@ -218,6 +223,7 @@ TDF_Label Model_Document::groupLabel(const string theGroup)
 {
   if (myGroups.find(theGroup) == myGroups.end()) {
     myGroups[theGroup] = myDoc->Main().FindChild(TAG_OBJECTS).NewChild();
+    myGroupsNames.push_back(theGroup);
   }
   return myGroups[theGroup];
 }
index d96aa15dd039747a06d2fb7113adab3947353a7d..b1e863e3f26eb4e9ae2a5ee573e7f27d57b5d3fb 100644 (file)
@@ -82,6 +82,9 @@ public:
   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Feature> 
     feature(const std::string& theGroupID, const int theIndex);
 
+  ///! Returns the vector of groups already added to the document
+  MODEL_EXPORT virtual const std::vector<std::string>& getGroups() const;
+
 protected:
 
   //! Returns (creates if needed) the group label
@@ -102,6 +105,7 @@ private:
   Handle_TDocStd_Document myDoc; ///< OCAF document
   int myTransactionsAfterSave; ///< number of transactions after the last "save" call, used for "IsModified" method
   std::map<std::string, TDF_Label> myGroups; ///< root labels of the features groups identified by names
+  std::vector<std::string> myGroupsNames; ///< names of added groups to the document
 };
 
 #endif
index b06dd889997d872e9ebdaaa491e68860bae476a7..e2be71f9e21e30baf0d17d51c9be4e1ec5eb978c 100644 (file)
@@ -8,6 +8,7 @@
 #include <ModelAPI.h>
 #include <string>
 #include <memory>
+#include <vector>
 
 class ModelAPI_Feature;
 class ModelAPI_Iterator;
@@ -89,6 +90,9 @@ public:
   MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Feature> 
     feature(const std::string& theGroupID, const int theIndex) = 0;
 
+  ///! Returns the vector of groups already added to the document
+  MODELAPI_EXPORT virtual const std::vector<std::string>& getGroups() const = 0;
+
 protected:
   /// Only for SWIG wrapping it is here
   MODELAPI_EXPORT ModelAPI_Document()
index 89f7084fa432843c489f66fee7f0eb7608c21687..7992ef085bb86ed6fcc48b299938d516cc2db310 100644 (file)
@@ -20,11 +20,14 @@ std::shared_ptr<ModelAPI_Feature> PartSetPlugin_Plugin::createFeature(
 {
   std::shared_ptr<ModelAPI_Feature> aCreated;
   bool isCurrent = true; // to create a feature in the current document
+  std::string aGroup;
   if (theFeatureID == "Part") {
     aCreated = std::shared_ptr<ModelAPI_Feature>(new PartSetPlugin_Part);
     isCurrent = false; // allways create in the root document
+    aGroup = PARTS_GROUP;
   } else if (theFeatureID == "Point") {
     aCreated = std::shared_ptr<ModelAPI_Feature>(new PartSetPlugin_Point);
+    aGroup = CONSTRUCTIONS_GROUP;
   }
 
   // add to a root document for the current moment
@@ -32,7 +35,7 @@ std::shared_ptr<ModelAPI_Feature> PartSetPlugin_Plugin::createFeature(
     shared_ptr<ModelAPI_Document> aDoc = isCurrent ? 
       ModelAPI_PluginManager::get()->currentDocument() :
       ModelAPI_PluginManager::get()->rootDocument();
-    aDoc->addFeature(aCreated, PARTS_GROUP);
+    aDoc->addFeature(aCreated, aGroup);
   }
   // feature of such kind is not found
   return aCreated;