/////////////////////// DELETED MESSAGE /////////////////////////////
Model_ObjectDeletedMessage::Model_ObjectDeletedMessage(
const std::shared_ptr<ModelAPI_Document>& theDoc, const std::string& theGroup)
- : ModelAPI_ObjectDeletedMessage(messageId(), 0),
- myDoc(theDoc)
+ : ModelAPI_ObjectDeletedMessage(messageId(), 0)
{
- if (!theGroup.empty())
- myGroups.insert(theGroup);
+ if (!theGroup.empty()) {
+ myGroups.push_back(
+ std::pair<std::shared_ptr<ModelAPI_Document>, std::string>(theDoc, theGroup));
+ }
}
std::shared_ptr<Events_MessageGroup> Model_ObjectDeletedMessage::newEmpty()
{
- return std::shared_ptr<Model_ObjectDeletedMessage>(new Model_ObjectDeletedMessage(myDoc, ""));
+ static const std::shared_ptr<ModelAPI_Document> anEmpty;
+ return std::shared_ptr<Model_ObjectDeletedMessage>(new Model_ObjectDeletedMessage(anEmpty, ""));
}
const Events_ID Model_ObjectDeletedMessage::messageId()
{
std::shared_ptr<Model_ObjectDeletedMessage> aJoined =
std::dynamic_pointer_cast<Model_ObjectDeletedMessage>(theJoined);
- std::set<std::string>::iterator aGIter = aJoined->myGroups.begin();
- for (; aGIter != aJoined->myGroups.end(); aGIter++) {
- myGroups.insert(*aGIter);
+
+ const std::list<std::pair<std::shared_ptr<ModelAPI_Document>, std::string>>& aJGroups =
+ aJoined->groups();
+
+ std::list<std::pair<std::shared_ptr<ModelAPI_Document>, std::string>>::iterator aGIter;
+ std::list<std::pair<std::shared_ptr<ModelAPI_Document>, std::string>>::const_iterator aJIter;
+ for (aJIter = aJGroups.cbegin(); aJIter != aJGroups.cend(); aJIter++) {
+ for (aGIter = myGroups.begin(); aGIter != myGroups.end(); aGIter++) {
+ if (aGIter->first == aJIter->first && aGIter->second == aJIter->second)
+ break; // exists, so no need to insert
+ }
+ if (aGIter == myGroups.end())
+ myGroups.push_back(*aJIter);
}
}
/// Message that feature was deleted (used for Object Browser update)
class Model_ObjectDeletedMessage : public ModelAPI_ObjectDeletedMessage
{
- std::shared_ptr<ModelAPI_Document> myDoc; ///< document owner of the feature
- std::set<std::string> myGroups; ///< group identifiers that contained the deleted feature
+ ///< group identifiers that contained the deleted feature and document where they are deleted
+ std::list<std::pair<std::shared_ptr<ModelAPI_Document>, std::string> > myGroups;
/// Use ModelAPI for creation of this event.
Model_ObjectDeletedMessage(const std::shared_ptr<ModelAPI_Document>& theDoc,
friend class Model_EventCreator;
public:
- /// Returns the document that has been updated
- virtual std::shared_ptr<ModelAPI_Document> document() const
- {
- return myDoc;
- }
-
/// Returns the group where the objects were deleted
- virtual const std::set<std::string>& groups() const
+ virtual const std::list<std::pair<std::shared_ptr<ModelAPI_Document>, std::string> >&
+ groups() const
{
return myGroups;
}
if (theMessage->eventID() == kDeletedEvent) {
std::shared_ptr<ModelAPI_ObjectDeletedMessage> aDeleted =
std::dynamic_pointer_cast<ModelAPI_ObjectDeletedMessage>(theMessage);
- if (aDeleted &&
- aDeleted->groups().find(ModelAPI_ResultPart::group()) != aDeleted->groups().end())
+
+ std::list<std::pair<std::shared_ptr<ModelAPI_Document>, std::string>>::const_iterator
+ aGIter = aDeleted->groups().cbegin();
+ for (; aGIter != aDeleted->groups().cend(); aGIter++) {
+ if (aGIter->second == ModelAPI_ResultPart::group())
+ break;
+ }
+ if (aGIter != aDeleted->groups().cend())
{
// check that the current feature of the session is still the active Part (even disabled)
bool aFound = false;
virtual ~ModelAPI_ObjectDeletedMessage();
public:
- /// Returns the document that has been updated
- virtual std::shared_ptr<ModelAPI_Document> document() const = 0;
-
/// Returns the groups where the objects were deleted
- virtual const std::set<std::string>& groups() const = 0;
+ virtual const std::list<std::pair<std::shared_ptr<ModelAPI_Document>, std::string> >&
+ groups() const = 0;
/// Creates the new empty message of this kind
virtual std::shared_ptr<Events_MessageGroup> newEmpty() = 0;
} else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) {
std::shared_ptr<ModelAPI_ObjectDeletedMessage> aDeleteMsg =
std::dynamic_pointer_cast<ModelAPI_ObjectDeletedMessage>(theMessage);
- const std::set<std::string>& aFeatureGroups = aDeleteMsg->groups();
+ const std::list<std::pair<std::shared_ptr<ModelAPI_Document>, std::string>>& aFeatureGroups =
+ aDeleteMsg->groups();
// Find SketchPlugin_Sketch::ID() in groups.
// The constraint groups should be updated when an object removed from Sketch
- std::set<std::string>::const_iterator aFGrIter;
+ std::list<std::pair<std::shared_ptr<ModelAPI_Document>, std::string>>::const_iterator aFGrIter;
for (aFGrIter = aFeatureGroups.begin(); aFGrIter != aFeatureGroups.end(); aFGrIter++)
- if (aFGrIter->compare(ModelAPI_ResultConstruction::group()) == 0 ||
- aFGrIter->compare(ModelAPI_Feature::group()) == 0)
+ if (aFGrIter->second == ModelAPI_ResultConstruction::group() ||
+ aFGrIter->second == ModelAPI_Feature::group())
break;
if (aFGrIter != aFeatureGroups.end()) {
else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) {
std::shared_ptr<ModelAPI_ObjectDeletedMessage> aUpdMsg =
std::dynamic_pointer_cast<ModelAPI_ObjectDeletedMessage>(theMessage);
- DocumentPtr aDoc = aUpdMsg->document();
- std::set<std::string> aMsgGroups = aUpdMsg->groups();
- std::set<std::string>::const_iterator aIt;
+ const std::list<std::pair<std::shared_ptr<ModelAPI_Document>, std::string>>& aMsgGroups =
+ aUpdMsg->groups();
+ std::list<std::pair<std::shared_ptr<ModelAPI_Document>, std::string>>::const_iterator aIt;
for (aIt = aMsgGroups.cbegin(); aIt != aMsgGroups.cend(); aIt++)
- QTreeNodesList aList = myRoot->objectsDeleted(aDoc, (*aIt).c_str());
+ QTreeNodesList aList = myRoot->objectsDeleted(aIt->first, aIt->second.c_str());
rebuildDataTree();
}
else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) {