]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Update history for the objects outside the folder (correction)
authorazv <azv@opencascade.com>
Thu, 23 Nov 2017 09:33:58 +0000 (12:33 +0300)
committerazv <azv@opencascade.com>
Thu, 23 Nov 2017 09:33:58 +0000 (12:33 +0300)
src/Model/Model_Objects.cpp
src/ModelAPI/Test/TestFolder_Create.py

index 1d37ddeeac4cc713080456236f145062819cbac8..a0c1640f3589644c21f0575ac3444f412691fae7 100644 (file)
@@ -456,7 +456,9 @@ void Model_Objects::createHistory(const std::string& theGroupID)
           // it may be a folder
           ObjectPtr aFolder = folder(aRefs->Value(a));
           if (aFolder.get()) {
-            aResultOutOfFolder.push_back(aFolder);
+            aResult.push_back(aFolder);
+            if (theGroupID != ModelAPI_Folder::group())
+              aResultOutOfFolder.push_back(aFolder);
 
             // get the last feature in the folder
             AttributeReferencePtr aLastFeatAttr =
@@ -558,8 +560,8 @@ ObjectPtr Model_Objects::object(const std::string& theGroupID,
 {
   if (theIndex == -1)
     return ObjectPtr();
+  createHistory(theGroupID);
   const std::string& aGroupID = groupNameFoldering(theGroupID, theAllowFolder);
-  createHistory(aGroupID);
   return myHistory[aGroupID][theIndex];
 }
 
@@ -620,8 +622,8 @@ const int Model_Objects::index(std::shared_ptr<ModelAPI_Object> theObject)
 
 int Model_Objects::size(const std::string& theGroupID, const bool theAllowFolder)
 {
+  createHistory(theGroupID);
   const std::string& aGroupID = groupNameFoldering(theGroupID, theAllowFolder);
-  createHistory(aGroupID);
   return int(myHistory[aGroupID].size());
 }
 
@@ -1237,6 +1239,7 @@ std::shared_ptr<ModelAPI_Folder> Model_Objects::createFolder(
   myFolders.Bind(aFolderLab, aFolder);
   // must be before the event sending: for OB the feature is already added
   updateHistory(ModelAPI_Folder::group());
+  updateHistory(ModelAPI_Feature::group());
 
   // must be after binding to the map because of "Box" macro feature that
   // creates other features in "initData"
index 492e73f1ec12c1cbc94299b7003d0b7312e8905a..36d429a6a8514732facc477677fd9abf00a32256 100644 (file)
@@ -51,12 +51,15 @@ aPoint1Data.real("z").setValue(0.)
 aPoint1Data.string("creation_method").setValue("by_xyz")
 aSession.finishOperation()
 
+assert(aPartSetDoc.size("Features") == 2), "Wrong number of features: {}".format(aPartSetDoc.size("Features"))
+
 # Folder before the feature
 aSession.startOperation()
 aFolder1 = aPartSetDoc.addFolder(aPoint1)
 aSession.finishOperation()
 
-assert(aPartSetDoc.size("Folders") == 1)
+assert(aPartSetDoc.size("Folders") == 1), "Wrong number of folders: {}".format(aPartSetDoc.size("Folders"))
+assert(aPartSetDoc.size("Features") == 3), "Wrong number of features: {}".format(aPartSetDoc.size("Features"))
 FOLDER_NAME_EXPECTED = "Folder_1"
 assert(aFolder1.name() == FOLDER_NAME_EXPECTED), "Actual name '{}', expected '{}'".format(aFolder1.name(), FOLDER_NAME_EXPECTED)
 
@@ -90,11 +93,14 @@ aPoint2Data.real("z").setValue(0.)
 aPoint2Data.string("creation_method").setValue("by_xyz")
 aSession.finishOperation()
 
+assert(aPartDoc.size("Features") == 1), "Wrong number of features: {}".format(aPartDoc.size("Features"))
+
 aSession.startOperation()
 aFolder2 = aPartDoc.addFolder(aPoint2)
 aSession.finishOperation()
 
-assert(aPartDoc.size("Folders") == 1)
+assert(aPartDoc.size("Folders") == 1), "Wrong number of folders: {}".format(aPartDoc.size("Folders"))
+assert(aPartDoc.size("Features") == 2), "Wrong number of features: {}".format(aPartDoc.size("Features"))
 FOLDER_NAME_EXPECTED = "Folder_1"
 assert(aFolder2.name() == FOLDER_NAME_EXPECTED), "Actual name '{}', expected '{}'".format(aFolder2.name(), FOLDER_NAME_EXPECTED)