Events_Loop::loop()->send(aMsg, true);
}
+void Model_EventCreator::sendReordered(const std::shared_ptr<ModelAPI_Document>& theDoc,
+ const std::string& theGroup) const
+{
+ std::shared_ptr<Model_OrderUpdatedMessage> aMsg(
+ new Model_OrderUpdatedMessage(theDoc, theGroup));
+ Events_Loop::loop()->send(aMsg, true);
+}
+
Model_EventCreator::Model_EventCreator()
{
ModelAPI_EventCreator::set(this);
myGroups.insert(*aGIter);
}
}
+
+/////////////////////// REORDERED MESSAGE /////////////////////////////
+Model_OrderUpdatedMessage::Model_OrderUpdatedMessage(
+ const std::shared_ptr<ModelAPI_Document>& theDoc, const std::string& theGroup)
+ : ModelAPI_OrderUpdatedMessage(messageId(), 0),
+ myDoc(theDoc)
+{
+ if (!theGroup.empty())
+ myGroups.insert(theGroup);
+}
+
+std::shared_ptr<Events_MessageGroup> Model_OrderUpdatedMessage::newEmpty()
+{
+ return std::shared_ptr<Model_OrderUpdatedMessage>(new Model_OrderUpdatedMessage(myDoc, ""));
+}
+
+const Events_ID Model_OrderUpdatedMessage::messageId()
+{
+ static Events_ID MY_ID = Events_Loop::eventByName(EVENT_ORDER_UPDATED);
+ return MY_ID;
+}
+
+void Model_OrderUpdatedMessage::Join(const std::shared_ptr<Events_MessageGroup>& theJoined)
+{
+ std::shared_ptr<Model_OrderUpdatedMessage> aJoined =
+ std::dynamic_pointer_cast<Model_OrderUpdatedMessage>(theJoined);
+ std::set<std::string>::iterator aGIter = aJoined->myGroups.begin();
+ for (; aGIter != aJoined->myGroups.end(); aGIter++) {
+ myGroups.insert(*aGIter);
+ }
+}
virtual void sendDeleted(const std::shared_ptr<ModelAPI_Document>& theDoc,
const std::string& theGroup) const;
+ /// creates reordered message and sends to the loop
+ virtual void sendReordered(const std::shared_ptr<ModelAPI_Document>& theDoc,
+ const std::string& theGroup) const;
+
/// must be one per application, the constructor for internal usage only
Model_EventCreator();
};
friend class Model_EventCreator;
public:
- /// Returns the feature that has been updated
+ /// 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
+ {
+ return myGroups;
+ }
+
+ /// Returns the new empty message of this type
+ virtual std::shared_ptr<Events_MessageGroup> newEmpty();
+
+ /// Returns the identifier of this message
+ virtual const Events_ID messageId();
+
+ /// Appends to this message the given one
+ virtual void Join(const std::shared_ptr<Events_MessageGroup>& theJoined);
+};
+
+/// Message that feature was deleted (used for Object Browser update)
+class Model_OrderUpdatedMessage : public ModelAPI_OrderUpdatedMessage
+{
+ std::shared_ptr<ModelAPI_Document> myDoc; ///< document owner of the feature
+ std::set<std::string> myGroups; ///< group identifiers that contained the deleted feature
+
+ /// Use ModelAPI for creation of this event.
+ Model_OrderUpdatedMessage(const std::shared_ptr<ModelAPI_Document>& theDoc,
+ const std::string& theGroup);
+
+ 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 feature was deleted
+ /// Returns the group where the objects were reordered
virtual const std::set<std::string>& groups() const
{
return myGroups;
theMoved->data()->setUpdateID(0);
static Events_ID EVENT_UPD = Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED);
ModelAPI_EventCreator::get()->sendUpdated(theMoved, EVENT_UPD);
+ ModelAPI_EventCreator::get()->sendReordered(theMoved->document(), theMoved->groupName());
}
void Model_Objects::clearHistory(ObjectPtr theObj)
}
+ModelAPI_OrderUpdatedMessage::ModelAPI_OrderUpdatedMessage(const Events_ID theID,
+ const void* theSender)
+ : Events_MessageGroup(theID, theSender)
+{
+
+}
+
+ModelAPI_OrderUpdatedMessage::~ModelAPI_OrderUpdatedMessage()
+{
+
+}
+
ModelAPI_FeatureStateMessage::ModelAPI_FeatureStateMessage(const Events_ID theID,
const void* theSender)
: Events_Message(theID, theSender)
static const char * EVENT_SOLVER_FAILED = "SolverFailed";
static const char * EVENT_SOLVER_REPAIRED = "SolverRepaired";
+/// Event ID that order of objects in group is changed, so, tree must be fully rectreated (movement of feature)
+static const char * EVENT_ORDER_UPDATED = "OrderUpdated";
+
/// Message that feature was changed (used for Object Browser update): moved, updated and deleted
class MODELAPI_EXPORT ModelAPI_ObjectUpdatedMessage : public Events_MessageGroup
{
virtual ~ModelAPI_ObjectDeletedMessage();
public:
- /// Returns the feature that has been updated
+ /// 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;
+
+ /// Creates the new empty message of this kind
+ virtual std::shared_ptr<Events_MessageGroup> newEmpty() = 0;
+
+ /// Returns the identifier of the kind of a message
+ virtual const Events_ID messageId() = 0;
+
+ /// Appenad to this message the given one.
+ virtual void Join(const std::shared_ptr<Events_MessageGroup>& theJoined) = 0;
+};
+
+/// Message that order changed (used for Object Browser update)
+class MODELAPI_EXPORT ModelAPI_OrderUpdatedMessage : public Events_MessageGroup
+{
+protected:
+ /// Creates an empty message
+ ModelAPI_OrderUpdatedMessage(const Events_ID theID, const void* theSender = 0);
+ /// The virtual destructor
+ virtual ~ModelAPI_OrderUpdatedMessage();
+
+public:
+ /// Returns the document that has been updated
virtual std::shared_ptr<ModelAPI_Document> document() const = 0;
- /// Returns the group where the feature was deleted
+ /// Returns the groups where the objects were reordered
virtual const std::set<std::string>& groups() const = 0;
/// Creates the new empty message of this kind
/// creates deleted message and sends to the loop
virtual void sendDeleted(const std::shared_ptr<ModelAPI_Document>& theDoc,
const std::string& theGroup) const = 0;
+ /// creates reordered message and sends to the loop
+ virtual void sendReordered(const std::shared_ptr<ModelAPI_Document>& theDoc,
+ const std::string& theGroup) const = 0;
/// returns the creator instance
static const ModelAPI_EventCreator* get();