From: azv Date: Thu, 23 Nov 2017 09:33:58 +0000 (+0300) Subject: Update history for the objects outside the folder (correction) X-Git-Tag: V_2.10.0RC~123^2~27 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b582ec2b0127eda3cbf3b981ddda26caeb9469e6;p=modules%2Fshaper.git Update history for the objects outside the folder (correction) --- diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index 1d37ddeea..a0c1640f3 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -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 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 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" diff --git a/src/ModelAPI/Test/TestFolder_Create.py b/src/ModelAPI/Test/TestFolder_Create.py index 492e73f1e..36d429a6a 100644 --- a/src/ModelAPI/Test/TestFolder_Create.py +++ b/src/ModelAPI/Test/TestFolder_Create.py @@ -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)