From: mpv Date: Tue, 1 Jul 2014 07:41:29 +0000 (+0400) Subject: Moved the model messages from Model to ModelAPI and removed dependencies on Model X-Git-Tag: V_0.4.4~214^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=421560a1b77974341c08898dd4eb32c283584a22;p=modules%2Fshaper.git Moved the model messages from Model to ModelAPI and removed dependencies on Model --- diff --git a/src/Model/Model_Data.cpp b/src/Model/Model_Data.cpp index 80eba05b0..5b3a944c9 100644 --- a/src/Model/Model_Data.cpp +++ b/src/Model/Model_Data.cpp @@ -49,8 +49,7 @@ void Model_Data::setName(string theName) } if (isModified) { static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED); - Model_FeatureUpdatedMessage aMsg(myFeature, anEvent); - Events_Loop::loop()->send(aMsg, false); + ModelAPI_EventCreator::get()->sendUpdated(myFeature, anEvent, false); } } @@ -223,8 +222,7 @@ void Model_Data::sendAttributeUpdated(ModelAPI_Attribute* theAttr) { theAttr->setInitialized(); static const Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED); - Model_FeatureUpdatedMessage aMsg(myFeature, anEvent); - Events_Loop::loop()->send(aMsg); + ModelAPI_EventCreator::get()->sendUpdated(myFeature, anEvent); } #include diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index e17a14af5..95cc5a9d1 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -386,8 +386,7 @@ void Model_Document::addFeature(const FeaturePtr theFeature) // event: feature is added static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_CREATED); - Model_FeatureUpdatedMessage aMsg(theFeature, anEvent); - Events_Loop::loop()->send(aMsg); + ModelAPI_EventCreator::get()->sendUpdated(theFeature, anEvent); } /// Appenad to the array of references a new referenced label. @@ -444,8 +443,7 @@ void Model_Document::removeFeature(FeaturePtr theFeature) RemoveFromRefArray(groupLabel(FEATURES_GROUP), aData->label()); // event: feature is added - Model_FeatureDeletedMessage aMsg(theFeature->document(), theFeature->getGroup()); - Events_Loop::loop()->send(aMsg); + ModelAPI_EventCreator::get()->sendDeleted(theFeature->document(), theFeature->getGroup()); } FeaturePtr Model_Document::feature(TDF_Label& theLabel) @@ -607,11 +605,9 @@ void Model_Document::synchronizeFeatures(const bool theMarkUpdated) aFIter = myFeatures.erase(aFIter); // event: model is updated if (aFeature->isInHistory()) { - Model_FeatureDeletedMessage aMsg1(aThis, FEATURES_GROUP); - Events_Loop::loop()->send(aMsg1); + ModelAPI_EventCreator::get()->sendDeleted(aThis, FEATURES_GROUP); } - Model_FeatureDeletedMessage aMsg2(aThis, aFeature->getGroup()); - Events_Loop::loop()->send(aMsg2); + ModelAPI_EventCreator::get()->sendDeleted(aThis, aFeature->getGroup()); } else if (aDSTag < aFeatureTag) { // a new feature is inserted // create a feature FeaturePtr aFeature = ModelAPI_PluginManager::get()->createFeature( @@ -635,12 +631,10 @@ void Model_Document::synchronizeFeatures(const bool theMarkUpdated) // event: model is updated static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_CREATED); - Model_FeatureUpdatedMessage aMsg1(aFeature, anEvent); - Events_Loop::loop()->send(aMsg1); + ModelAPI_EventCreator::get()->sendUpdated(aFeature, anEvent); FeaturePtr anObj = objectByFeature(aFeature); if (anObj) { - Model_FeatureUpdatedMessage aMsg2(anObj, anEvent); - Events_Loop::loop()->send(aMsg2); + ModelAPI_EventCreator::get()->sendUpdated(anObj, anEvent); } // feature for this label is added, so go to the next label @@ -648,8 +642,7 @@ void Model_Document::synchronizeFeatures(const bool theMarkUpdated) } else { // nothing is changed, both iterators are incremented if (theMarkUpdated) { static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED); - Model_FeatureUpdatedMessage aMsg(*aFIter, anEvent); - Events_Loop::loop()->send(aMsg); + ModelAPI_EventCreator::get()->sendUpdated(*aFIter, anEvent); } aFIter++; aFLabIter.Next(); diff --git a/src/Model/Model_Events.cpp b/src/Model/Model_Events.cpp index 538305efb..fb94001b8 100644 --- a/src/Model/Model_Events.cpp +++ b/src/Model/Model_Events.cpp @@ -5,31 +5,82 @@ #include #include -// DELETED methods -//Events_MessageGroup* Model_FeatureDeletedMessage::newEmpty() { -// return new Model_FeatureDeletedMessage(myDoc, ""); -//} -// -//Model_FeatureDeletedMessage::Model_FeatureDeletedMessage( -// const boost::shared_ptr& theDoc, const std::string& theGroup) -// : Events_MessageGroup(messageId(), 0), myDoc(theDoc) -// -//{ -// if (!theGroup.empty()) -// myGroups.insert(theGroup); -//} -// -//const Events_ID Model_FeatureDeletedMessage::messageId() -//{ -// static Events_ID MY_ID = Events_Loop::eventByName(EVENT_FEATURE_DELETED); -// return MY_ID; -//} -// -//void Model_FeatureDeletedMessage::Join(Events_MessageGroup& theJoined) -//{ -// Model_FeatureDeletedMessage* aJoined = dynamic_cast(&theJoined); -// std::set::iterator aGIter = aJoined->myGroups.begin(); -// for(; aGIter != aJoined->myGroups.end(); aGIter++) { -// myGroups.insert(*aGIter); -// } -//} +/// Alone instance of the creator per application +Model_EventCreator MY_CREATOR; + +/////////////////////// CREATOR ///////////////////////////// +void Model_EventCreator::sendUpdated( + const FeaturePtr& theFeature, const Events_ID& theEvent, const bool isGroupped) const +{ + Model_FeatureUpdatedMessage aMsg(theFeature, theEvent); + Events_Loop::loop()->send(aMsg, isGroupped); +} + +void Model_EventCreator::sendDeleted( + const boost::shared_ptr& theDoc, const std::string& theGroup) const +{ + Model_FeatureDeletedMessage aMsg(theDoc, theGroup); + Events_Loop::loop()->send(aMsg, true); +} + +Model_EventCreator::Model_EventCreator() +{ + ModelAPI_EventCreator::set(this); +} + +/////////////////////// UPDATED MESSAGE ///////////////////////////// +Model_FeatureUpdatedMessage::Model_FeatureUpdatedMessage( + const FeaturePtr& theFeature, + const Events_ID& theEvent) : ModelAPI_FeatureUpdatedMessage(theEvent, 0) +{ + if (theFeature) myFeatures.insert(theFeature); +} + +std::set Model_FeatureUpdatedMessage::features() const +{ + return myFeatures; +} + +Events_MessageGroup* Model_FeatureUpdatedMessage::newEmpty() +{ + FeaturePtr anEmptyFeature; + return new Model_FeatureUpdatedMessage(anEmptyFeature, eventID()); +} + +void Model_FeatureUpdatedMessage::Join(Events_MessageGroup& theJoined) +{ + Model_FeatureUpdatedMessage* aJoined = dynamic_cast(&theJoined); + std::set::iterator aFIter = aJoined->myFeatures.begin(); + for(; aFIter != aJoined->myFeatures.end(); aFIter++) { + myFeatures.insert(*aFIter); + } +} + +/////////////////////// DELETED MESSAGE ///////////////////////////// +Model_FeatureDeletedMessage::Model_FeatureDeletedMessage( + const boost::shared_ptr& theDoc, const std::string& theGroup) + : ModelAPI_FeatureDeletedMessage(messageId(), 0), myDoc(theDoc) +{ + if (!theGroup.empty()) + myGroups.insert(theGroup); +} + +Events_MessageGroup* Model_FeatureDeletedMessage::newEmpty() +{ + return new Model_FeatureDeletedMessage(myDoc, ""); +} + +const Events_ID Model_FeatureDeletedMessage::messageId() +{ + static Events_ID MY_ID = Events_Loop::eventByName(EVENT_FEATURE_DELETED); + return MY_ID; +} + +void Model_FeatureDeletedMessage::Join(Events_MessageGroup& theJoined) +{ + Model_FeatureDeletedMessage* aJoined = dynamic_cast(&theJoined); + std::set::iterator aGIter = aJoined->myGroups.begin(); + for(; aGIter != aJoined->myGroups.end(); aGIter++) { + myGroups.insert(*aGIter); + } +} diff --git a/src/Model/Model_Events.h b/src/Model/Model_Events.h index 68b277b94..a4912648d 100644 --- a/src/Model/Model_Events.h +++ b/src/Model/Model_Events.h @@ -6,105 +6,68 @@ #define Model_Events_HeaderFile #include -#include -#include -#include -#include -#include +#include -#include "ModelAPI_Feature.h" - -class ModelAPI_Document; - -/// Event ID that feature is created (comes with Model_FeatureUpdatedMessage) -static const char * EVENT_FEATURE_CREATED = "FeatureCreated"; -/// Event ID that data of feature is updated (comes with Model_FeatureUpdatedMessage) -static const char * EVENT_FEATURE_UPDATED = "FeatureUpdated"; -/// Event ID that data of feature is deleted (comes with Model_FeatureDeletedMessage) -static const char * EVENT_FEATURE_DELETED = "FeatureDeleted"; -/// Event ID that data of feature is updated (comes with Model_FeaturesMovedMessage) -static const char * EVENT_FEATURE_MOVED = "FeaturesMoved"; +/// Allovs to create ModelAPI messages +class Model_EventCreator : public ModelAPI_EventCreator { +public: + /// creates created, updated or moved messages and sends to the loop + virtual void sendUpdated( + const FeaturePtr& theFeature, const Events_ID& theEvent, const bool isGroupped = true) const; + /// creates deleted message and sends to the loop + virtual void sendDeleted( + const boost::shared_ptr& theDoc, const std::string& theGroup) const; + + /// must be one per application, the constructor for internal usage only + Model_EventCreator(); +}; /// Message that feature was changed (used for Object Browser update): moved, updated and deleted -class Model_FeatureUpdatedMessage : public Events_MessageGroup { - std::set myFeatures; ///< which feature is changed -public: - /// sender is not important, all information is located in the feature +class Model_FeatureUpdatedMessage : public ModelAPI_FeatureUpdatedMessage { + std::set myFeatures; ///< which feature is changed + + /// Sender is not important, all information is located in the feature. + /// Use ModelAPI for creation of this event. Used for creation, movement and edition events. Model_FeatureUpdatedMessage( const FeaturePtr& theFeature, - const Events_ID& theEvent) : Events_MessageGroup(theEvent, 0) - {if (theFeature) myFeatures.insert(theFeature);} + const Events_ID& theEvent); + + friend class Model_EventCreator; +public: /// Returns the feature that has been updated - std::set features() const {return myFeatures;} + virtual std::set features() const; //! Creates a new empty group (to store it in the loop before flush) - virtual Events_MessageGroup* newEmpty() { - FeaturePtr anEmptyFeature; - return new Model_FeatureUpdatedMessage(anEmptyFeature, eventID()); - } + virtual Events_MessageGroup* newEmpty(); //! Allows to join the given message with the current one - virtual void Join(Events_MessageGroup& theJoined) { - Model_FeatureUpdatedMessage* aJoined = dynamic_cast(&theJoined); - std::set::iterator aFIter = aJoined->myFeatures.begin(); - for(; aFIter != aJoined->myFeatures.end(); aFIter++) { - myFeatures.insert(*aFIter); - } - } + virtual void Join(Events_MessageGroup& theJoined); }; /// Message that feature was deleted (used for Object Browser update) -class Model_FeatureDeletedMessage : public Events_MessageGroup { +class Model_FeatureDeletedMessage : public ModelAPI_FeatureDeletedMessage { boost::shared_ptr myDoc; ///< document owner of the feature std::set myGroups; ///< group identifiers that contained the deleted feature -public: - /// creates a message by initialization of fields -// Model_FeatureDeletedMessage(const boost::shared_ptr& theDoc, -// const std::string& theGroup); - /// Returns the ID of this message (EVENT_FEATURE_DELETED) -// static const Events_ID messageId(); + /// Use ModelAPI for creation of this event. + Model_FeatureDeletedMessage( + const boost::shared_ptr& theDoc, const std::string& theGroup); + friend class Model_EventCreator; +public: /// Returns the feature that has been updated - boost::shared_ptr document() const {return myDoc;} + virtual boost::shared_ptr document() const {return myDoc;} /// Returns the group where the feature was deleted - const std::set& groups() const {return myGroups;} + virtual const std::set& groups() const {return myGroups;} - //! Creates a new empty group (to store it in the loop before flush) -// virtual Events_MessageGroup* newEmpty(); + virtual Events_MessageGroup* newEmpty(); - //! Allows to join the given message with the current one -// virtual void Join(Events_MessageGroup& theJoined); - Events_MessageGroup* newEmpty() { - return new Model_FeatureDeletedMessage(myDoc, ""); - } + virtual const Events_ID messageId(); - Model_FeatureDeletedMessage( - const boost::shared_ptr& theDoc, const std::string& theGroup) - : Events_MessageGroup(messageId(), 0), myDoc(theDoc) - - { - if (!theGroup.empty()) - myGroups.insert(theGroup); - } - - const Events_ID messageId() - { - static Events_ID MY_ID = Events_Loop::eventByName(EVENT_FEATURE_DELETED); - return MY_ID; - } - - void Join(Events_MessageGroup& theJoined) - { - Model_FeatureDeletedMessage* aJoined = dynamic_cast(&theJoined); - std::set::iterator aGIter = aJoined->myGroups.begin(); - for(; aGIter != aJoined->myGroups.end(); aGIter++) { - myGroups.insert(*aGIter); - } - } + virtual void Join(Events_MessageGroup& theJoined); }; #endif diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index 595579b08..e1f52a9bb 100644 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -6,9 +6,10 @@ #include #include #include -#include +#include #include #include +#include using namespace std; @@ -21,8 +22,8 @@ Model_Update::Model_Update() void Model_Update::processEvent(const Events_Message* theMessage) { - const Model_FeatureUpdatedMessage* aMsg = - dynamic_cast(theMessage); + const ModelAPI_FeatureUpdatedMessage* aMsg = + dynamic_cast(theMessage); myInitial = aMsg->features(); // collect all documents involved into the update set > aDocs; diff --git a/src/ModelAPI/CMakeLists.txt b/src/ModelAPI/CMakeLists.txt index 981d5567d..3fd7da3a0 100644 --- a/src/ModelAPI/CMakeLists.txt +++ b/src/ModelAPI/CMakeLists.txt @@ -17,6 +17,7 @@ SET(PROJECT_HEADERS ModelAPI_AttributeRefAttr.h ModelAPI_AttributeRefList.h ModelAPI_AttributeBoolean.h + ModelAPI_Events.h ) SET(PROJECT_SOURCES @@ -33,7 +34,7 @@ SET_TARGET_PROPERTIES(ModelAPI PROPERTIES LINKER_LANGUAGE CXX) TARGET_LINK_LIBRARIES(ModelAPI ${PROJECT_LIBRARIES}) INCLUDE_DIRECTORIES( - ../Config + ../Config ../Events ) SET(CMAKE_SWIG_FLAGS "") diff --git a/src/ModelAPI/ModelAPI_Events.h b/src/ModelAPI/ModelAPI_Events.h new file mode 100644 index 000000000..5ab3df1dc --- /dev/null +++ b/src/ModelAPI/ModelAPI_Events.h @@ -0,0 +1,81 @@ +// File: ModelAPI_Events.h +// Created: 10 Apr 2014 +// Author: Mikhail PONIKAROV + +#ifndef ModelAPI_Events_HeaderFile +#define ModelAPI_Events_HeaderFile + +#include +#include +#include +#include +#include + +#include "ModelAPI_Feature.h" + +class ModelAPI_Document; + +/// Event ID that feature is created (comes with Model_FeatureUpdatedMessage) +static const char * EVENT_FEATURE_CREATED = "FeatureCreated"; +/// Event ID that data of feature is updated (comes with Model_FeatureUpdatedMessage) +static const char * EVENT_FEATURE_UPDATED = "FeatureUpdated"; +/// Event ID that data of feature is deleted (comes with Model_FeatureDeletedMessage) +static const char * EVENT_FEATURE_DELETED = "FeatureDeleted"; +/// Event ID that data of feature is updated (comes with Model_FeaturesMovedMessage) +static const char * EVENT_FEATURE_MOVED = "FeaturesMoved"; + +/// Message that feature was changed (used for Object Browser update): moved, updated and deleted +class ModelAPI_FeatureUpdatedMessage : public Events_MessageGroup { +protected: + ModelAPI_FeatureUpdatedMessage(const Events_ID theID, const void* theSender = 0) + : Events_MessageGroup(theID, theSender) {} + +public: + /// Returns the feature that has been updated + virtual std::set features() const = 0; + + //! Creates a new empty group (to store it in the loop before flush) + virtual Events_MessageGroup* newEmpty() = 0; + + //! Allows to join the given message with the current one + virtual void Join(Events_MessageGroup& theJoined) = 0; +}; + +/// Message that feature was deleted (used for Object Browser update) +class ModelAPI_FeatureDeletedMessage : public Events_MessageGroup { +protected: + ModelAPI_FeatureDeletedMessage(const Events_ID theID, const void* theSender = 0) + : Events_MessageGroup(theID, theSender) {} + +public: + /// Returns the feature that has been updated + virtual boost::shared_ptr document() const = 0; + + /// Returns the group where the feature was deleted + virtual const std::set& groups() const = 0; + + virtual Events_MessageGroup* newEmpty() = 0; + + virtual const Events_ID messageId() = 0; + + virtual void Join(Events_MessageGroup& theJoined) = 0; +}; + +/// Allows to create ModelAPI messages +class MODELAPI_EXPORT ModelAPI_EventCreator { +public: + /// creates created, updated or moved messages and sends to the loop + virtual void sendUpdated(const FeaturePtr& theFeature, const Events_ID& theEvent, + const bool isGroupped = true) const = 0; + /// creates deleted message and sends to the loop + virtual void sendDeleted( + const boost::shared_ptr& theDoc, const std::string& theGroup) const = 0; + + /// returns the creator instance + static const ModelAPI_EventCreator* get(); + + /// sets the creator instance + static void set(const ModelAPI_EventCreator* theCreator); +}; + +#endif diff --git a/src/ModelAPI/ModelAPI_PluginManager.cpp b/src/ModelAPI/ModelAPI_PluginManager.cpp index 4cf100d5c..766590a2e 100644 --- a/src/ModelAPI/ModelAPI_PluginManager.cpp +++ b/src/ModelAPI/ModelAPI_PluginManager.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include @@ -54,3 +55,18 @@ boost::shared_ptr ModelAPI_PluginManager::get() } return MY_MANAGER; } + +const ModelAPI_EventCreator* MY_CREATOR = 0; ///< instance of the events creator, one pre application + +const ModelAPI_EventCreator* ModelAPI_EventCreator::get() +{ + if (!MY_CREATOR) { // import Model library that implements this interface of ModelAPI + Config_ModuleReader::loadLibrary("Model"); + } + return MY_CREATOR; +} + +void ModelAPI_EventCreator::set(const ModelAPI_EventCreator* theCreator) +{ + MY_CREATOR = theCreator; +} diff --git a/src/PartSet/CMakeLists.txt b/src/PartSet/CMakeLists.txt index a111f8161..9a90b72f7 100644 --- a/src/PartSet/CMakeLists.txt +++ b/src/PartSet/CMakeLists.txt @@ -66,7 +66,6 @@ SOURCE_GROUP ("Resource Files" FILES ${PROJECT_RESOURCES}) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/XGUI ${CMAKE_SOURCE_DIR}/src/Config ${CMAKE_SOURCE_DIR}/src/Events - ${CMAKE_SOURCE_DIR}/src/Model ${CMAKE_SOURCE_DIR}/src/ModuleBase ${CMAKE_SOURCE_DIR}/src/ModelAPI ${CMAKE_SOURCE_DIR}/src/GeomDataAPI @@ -86,7 +85,7 @@ ADD_LIBRARY(PartSet SHARED ) # The Qt5Widgets_LIBRARIES variable also includes QtGui and QtCore -TARGET_LINK_LIBRARIES(PartSet ${PROJECT_LIBRARIES} XGUI ModelAPI Model GeomAlgoAPI) +TARGET_LINK_LIBRARIES(PartSet ${PROJECT_LIBRARIES} XGUI ModelAPI GeomAlgoAPI) ADD_DEPENDENCIES(PartSet ModuleBase) diff --git a/src/PartSet/PartSet_Listener.cpp b/src/PartSet/PartSet_Listener.cpp index 1f3505ee7..0a8a6e9d4 100644 --- a/src/PartSet/PartSet_Listener.cpp +++ b/src/PartSet/PartSet_Listener.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include @@ -39,8 +39,8 @@ void PartSet_Listener::processEvent(const Events_Message* theMessage) if (aType == EVENT_FEATURE_UPDATED || aType == EVENT_FEATURE_CREATED) { - const Model_FeatureUpdatedMessage* aUpdMsg = dynamic_cast - (theMessage); + const ModelAPI_FeatureUpdatedMessage* aUpdMsg = + dynamic_cast(theMessage); std::set aFeatures = aUpdMsg->features(); std::set::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end(); for (; anIt != aLast; anIt++) { @@ -56,7 +56,8 @@ void PartSet_Listener::processEvent(const Events_Message* theMessage) } if (aType == EVENT_FEATURE_DELETED) { - const Model_FeatureDeletedMessage* aDelMsg = dynamic_cast(theMessage); + const ModelAPI_FeatureDeletedMessage* aDelMsg = + dynamic_cast(theMessage); boost::shared_ptr aDoc = aDelMsg->document(); std::set aGroups = aDelMsg->groups(); diff --git a/src/PartSet/PartSet_OperationFeatureEdit.cpp b/src/PartSet/PartSet_OperationFeatureEdit.cpp index 6ab6edf95..07f077d2b 100644 --- a/src/PartSet/PartSet_OperationFeatureEdit.cpp +++ b/src/PartSet/PartSet_OperationFeatureEdit.cpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include @@ -19,7 +19,7 @@ #include #include -#include +#include #include @@ -198,9 +198,7 @@ void PartSet_OperationFeatureEdit::sendFeatures() static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_MOVED); FeaturePtr aFeature = feature(); - - Model_FeatureUpdatedMessage aMessage(aFeature, anEvent); - Events_Loop::loop()->send(aMessage); + ModelAPI_EventCreator::get()->sendUpdated(aFeature, anEvent); Events_Loop::loop()->flush(anEvent); flushUpdated(); diff --git a/src/PartSet/PartSet_OperationFeatureEditMulti.cpp b/src/PartSet/PartSet_OperationFeatureEditMulti.cpp index 89928ccde..e5feef62d 100644 --- a/src/PartSet/PartSet_OperationFeatureEditMulti.cpp +++ b/src/PartSet/PartSet_OperationFeatureEditMulti.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include #include @@ -16,7 +16,7 @@ #include #include -#include +#include #include @@ -190,8 +190,7 @@ void PartSet_OperationFeatureEditMulti::sendFeatures() if (!aFeature) continue; - Model_FeatureUpdatedMessage aMessage(aFeature, anEvent); - Events_Loop::loop()->send(aMessage); + ModelAPI_EventCreator::get()->sendUpdated(aFeature, anEvent); } Events_Loop::loop()->flush(anEvent); flushUpdated(); diff --git a/src/SketchSolver/SketchSolver_ConstraintGroup.cpp b/src/SketchSolver/SketchSolver_ConstraintGroup.cpp index 1e0905031..2f7931f9b 100644 --- a/src/SketchSolver/SketchSolver_ConstraintGroup.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintGroup.cpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include @@ -1148,8 +1148,7 @@ void SketchSolver_ConstraintGroup::updateRelatedConstraints( if (isUpd) { static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED); - Model_FeatureUpdatedMessage aMsg(aConstrIter->first, anEvent); - Events_Loop::loop()->send(aMsg, true); + ModelAPI_EventCreator::get()->sendUpdated(aConstrIter->first, anEvent); break; } } @@ -1175,8 +1174,7 @@ void SketchSolver_ConstraintGroup::updateRelatedConstraints( if (aRefAttr && aRefAttr->isFeature() && aRefAttr->feature() == theFeature) { static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED); - Model_FeatureUpdatedMessage aMsg(aConstrIter->first, anEvent); - Events_Loop::loop()->send(aMsg, true); + ModelAPI_EventCreator::get()->sendUpdated(aConstrIter->first, anEvent); break; } } diff --git a/src/SketchSolver/SketchSolver_ConstraintManager.cpp b/src/SketchSolver/SketchSolver_ConstraintManager.cpp index 0e39b5a42..ff571878b 100644 --- a/src/SketchSolver/SketchSolver_ConstraintManager.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintManager.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include @@ -63,10 +63,12 @@ void SketchSolver_ConstraintManager::processEvent(const Events_Message* theMessa theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_UPDATED) || theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_MOVED)) { - const Model_FeatureUpdatedMessage* anUpdateMsg = dynamic_cast(theMessage); + const ModelAPI_FeatureUpdatedMessage* anUpdateMsg = + dynamic_cast(theMessage); std::set< FeaturePtr > aFeatures = anUpdateMsg->features(); - bool isModifiedEvt = theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_MOVED); + bool isModifiedEvt = + theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_MOVED); if (!isModifiedEvt) { std::set< FeaturePtr >::iterator aFeatIter; @@ -102,7 +104,8 @@ void SketchSolver_ConstraintManager::processEvent(const Events_Message* theMessa } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_DELETED)) { - const Model_FeatureDeletedMessage* aDeleteMsg = dynamic_cast(theMessage); + const ModelAPI_FeatureDeletedMessage* aDeleteMsg = + dynamic_cast(theMessage); const std::set& aFeatureGroups = aDeleteMsg->groups(); // Find SKETCH_KIND in groups. The constraint groups should be updated when an object removed from Sketch