TDF_LabelList aNoUpdated;
synchronizeFeatures(aNoUpdated, true, false, true, true);
myHistory.clear();
+ myHistoryMap.clear();
}
Model_Objects::~Model_Objects()
myFolders.UnBind(aFoldersIter.Key());
}
myHistory.clear();
+ myHistoryMap.clear();
aLoop->activateFlushes(isActive);
// erase update, because features are destroyed and update should not performed for them anywhere
aLoop->eraseMessages(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
kCreator->sendDeleted(myDoc, ModelAPI_Feature::group());
myFeatures.Clear(); // just remove features without modification of DS
myHistory.clear();
+ myHistoryMap.clear();
}
void Model_Objects::moveFeature(FeaturePtr theMoved, FeaturePtr theAfterThis)
myHistory.find(aResultGroup);
if (aHIter != myHistory.end())
myHistory.erase(aHIter); // erase from map => this means that it is not synchronized
+ std::map<std::string, std::map<ObjectPtr, int> >::iterator aHIterMap =
+ myHistoryMap.find(aResultGroup);
+ if (aHIterMap != myHistoryMap.end())
+ myHistoryMap.erase(aHIterMap); // erase from map => this means that it is not synchronized
}
}
}
void Model_Objects::createHistory(const std::string& theGroupID)
{
- std::map<std::string, std::vector<ObjectPtr> >::iterator aHIter = myHistory.find(theGroupID);
+ std::map<std::string, std::vector<ObjectPtr> >::iterator aHIter =
+ myHistory.find(theGroupID);
+ std::map<std::string, std::map<ObjectPtr, int> >::iterator aHIterMap =
+ myHistoryMap.find(theGroupID);
if (aHIter == myHistory.end()) {
std::vector<ObjectPtr> aResult;
std::vector<ObjectPtr> aResultOutOfFolder;
+ std::map<ObjectPtr, int> aResultMap;
+ std::map<ObjectPtr, int> aResultOutOfFolderMap;
+ int aResultCounter = 0;
+ int aResultOutOfFolderCounter = 0;
FeaturePtr aLastFeatureInFolder;
// iterate the array of references and get feature by feature from the array
bool isFeature = theGroupID == ModelAPI_Feature::group();
if (isFeature) { // here may be also disabled features
if (!isSub && aFeature->isInHistory()) {
aResult.push_back(aFeature);
+ aResultMap[aFeature] = aResultCounter++;
// the feature is out of the folders
if (aLastFeatureInFolder.get() == NULL)
aResultOutOfFolder.push_back(aFeature);
+ aResultOutOfFolderMap[aFeature] = aResultOutOfFolderCounter++;
}
} else if (!aFeature->isDisabled()) { // iterate all results of not-disabled feature
// construction results of sub-features should not be in the tree
if (aRes->groupName() != theGroupID) break; // feature have only same group results
if (!aRes->isDisabled() && aRes->isInHistory() && !aRes->isConcealed()) {
aResult.push_back(*aRIter);
+ aResultMap[*aRIter] = aResultCounter++;
}
}
}
// store folder information for the Features group only
if (isFeature || isFolder) {
aResult.push_back(aFolder);
- if (!isFolder)
+ aResultMap[aFolder] = aResultCounter++;
+ if (!isFolder) {
aResultOutOfFolder.push_back(aFolder);
+ aResultOutOfFolderMap[aFolder] = aResultOutOfFolderCounter++;
+ }
}
// get the last feature in the folder
// to be sure that isConcealed did not update the history (issue 1089) during the iteration
if (myHistory.find(theGroupID) == myHistory.end()) {
myHistory[theGroupID] = aResult;
+ myHistoryMap[theGroupID] = aResultMap;
// store the features placed out of any folder
const std::string& anOutOfFolderGroupID = groupNameFoldering(theGroupID, true);
- if (!anOutOfFolderGroupID.empty())
+ if (!anOutOfFolderGroupID.empty()) {
myHistory[anOutOfFolderGroupID] = aResultOutOfFolder;
+ myHistoryMap[anOutOfFolderGroupID] = aResultOutOfFolderMap;
+ }
}
}
}
if (!anOutOfFolderGroupID.empty())
myHistory.erase(anOutOfFolderGroupID);
}
+ std::map<std::string, std::map<ObjectPtr, int> >::iterator aHIterMap = myHistoryMap.find(theGroup);
+ if (aHIterMap != myHistoryMap.end()) {
+ myHistoryMap.erase(aHIterMap); // erase from map => this means that it is not synchronized
+
+ // erase history for the group of objects placed out of any folder
+ const std::string& anOutOfFolderGroupID = groupNameFoldering(theGroup, true);
+ if (!anOutOfFolderGroupID.empty())
+ myHistoryMap.erase(anOutOfFolderGroupID);
+ }
}
const ObjectPtr& Model_Objects::folder(TDF_Label theLabel) const
if (theAllowFolder && !groupNameFoldering(aGroup, theAllowFolder).empty())
aGroup = groupNameFoldering(aGroup, theAllowFolder);
- std::vector<ObjectPtr>& allObjs = myHistory[aGroup];
- std::vector<ObjectPtr>::iterator anObjIter = allObjs.begin(); // iterate to search object
- for(int anIndex = 0; anObjIter != allObjs.end(); anObjIter++, anIndex++) {
- if ((*anObjIter) == theObject)
- return anIndex;
- }
+ std::map<ObjectPtr, int>& allObjs = myHistoryMap[aGroup];
+ std::map<ObjectPtr, int>::const_iterator aFound = allObjs.find(theObject);
+ if (aFound != allObjs.end())
+ return (*aFound).second;
// not found
return -1;
}
if (!theUpdated.IsEmpty()) {
// this means there is no control what was modified => remove history cash
myHistory.clear();
+ myHistoryMap.clear();
}
if (!theExecuteFeatures)