From 7a2548dc3e5e536f6325d0e8c9913c7fd53da4e3 Mon Sep 17 00:00:00 2001 From: vsv Date: Tue, 15 Jul 2014 16:27:17 +0400 Subject: [PATCH] Adaptation to a new ModelAPI architecture --- src/Model/Model_Events.cpp | 2 +- src/Model/Model_Events.h | 2 +- src/Model/Model_Update.cpp | 2 +- src/ModelAPI/ModelAPI_Events.h | 2 +- src/PartSet/PartSet_Listener.cpp | 2 +- .../SketchSolver_ConstraintManager.cpp | 2 +- src/XGUI/XGUI_DocumentDataModel.cpp | 18 +++++++++++------- src/XGUI/XGUI_PartDataModel.cpp | 2 +- src/XGUI/XGUI_Workshop.cpp | 8 ++++---- 9 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/Model/Model_Events.cpp b/src/Model/Model_Events.cpp index 2def67f43..4096dd65e 100644 --- a/src/Model/Model_Events.cpp +++ b/src/Model/Model_Events.cpp @@ -36,7 +36,7 @@ Model_ObjectUpdatedMessage::Model_ObjectUpdatedMessage( if (theObject) myObjects.insert(theObject); } -std::set Model_ObjectUpdatedMessage::features() const +std::set Model_ObjectUpdatedMessage::objects() const { return myObjects; } diff --git a/src/Model/Model_Events.h b/src/Model/Model_Events.h index 56e4b141f..4125cf81c 100644 --- a/src/Model/Model_Events.h +++ b/src/Model/Model_Events.h @@ -36,7 +36,7 @@ class Model_ObjectUpdatedMessage : public ModelAPI_ObjectUpdatedMessage { public: /// Returns the feature that has been updated - virtual std::set features() const; + virtual std::set objects() const; //! Creates a new empty group (to store it in the loop before flush) virtual Events_MessageGroup* newEmpty(); diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index 28048664e..25ecbbeb5 100644 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -24,7 +24,7 @@ void Model_Update::processEvent(const Events_Message* theMessage) { const ModelAPI_ObjectUpdatedMessage* aMsg = dynamic_cast(theMessage); - myInitial = aMsg->features(); + myInitial = aMsg->objects(); // collect all documents involved into the update set > aDocs; set >::iterator aFIter = myInitial.begin(); diff --git a/src/ModelAPI/ModelAPI_Events.h b/src/ModelAPI/ModelAPI_Events.h index 773d20b41..143f45e91 100644 --- a/src/ModelAPI/ModelAPI_Events.h +++ b/src/ModelAPI/ModelAPI_Events.h @@ -36,7 +36,7 @@ protected: public: /// Returns the feature that has been updated - virtual std::set features() const = 0; + virtual std::set objects() const = 0; //! Creates a new empty group (to store it in the loop before flush) virtual Events_MessageGroup* newEmpty() = 0; diff --git a/src/PartSet/PartSet_Listener.cpp b/src/PartSet/PartSet_Listener.cpp index efbc1a706..dcddad607 100644 --- a/src/PartSet/PartSet_Listener.cpp +++ b/src/PartSet/PartSet_Listener.cpp @@ -42,7 +42,7 @@ void PartSet_Listener::processEvent(const Events_Message* theMessage) { const ModelAPI_ObjectUpdatedMessage* aUpdMsg = dynamic_cast(theMessage); - std::set aFeatures = aUpdMsg->features(); + std::set aFeatures = aUpdMsg->objects(); std::set::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end(); for (; anIt != aLast; anIt++) { ObjectPtr aObject = *anIt; diff --git a/src/SketchSolver/SketchSolver_ConstraintManager.cpp b/src/SketchSolver/SketchSolver_ConstraintManager.cpp index 3bc8bb085..a31366813 100644 --- a/src/SketchSolver/SketchSolver_ConstraintManager.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintManager.cpp @@ -65,7 +65,7 @@ void SketchSolver_ConstraintManager::processEvent(const Events_Message* theMessa { const ModelAPI_ObjectUpdatedMessage* anUpdateMsg = dynamic_cast(theMessage); - std::set< ObjectPtr > aFeatures = anUpdateMsg->features(); + std::set< ObjectPtr > aFeatures = anUpdateMsg->objects(); bool isModifiedEvt = theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_MOVED); diff --git a/src/XGUI/XGUI_DocumentDataModel.cpp b/src/XGUI/XGUI_DocumentDataModel.cpp index 24b422421..254a2de41 100644 --- a/src/XGUI/XGUI_DocumentDataModel.cpp +++ b/src/XGUI/XGUI_DocumentDataModel.cpp @@ -50,14 +50,18 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage) // Created object event ******************* if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) { const Model_ObjectUpdatedMessage* aUpdMsg = dynamic_cast(theMessage); - std::set aFeatures = aUpdMsg->features(); + std::set aObjects = aUpdMsg->objects(); std::set::const_iterator aIt; - for (aIt = aFeatures.begin(); aIt != aFeatures.end(); ++aIt) { - ObjectPtr aFeature = (*aIt); - DocumentPtr aDoc = aFeature->document(); + for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) { + ObjectPtr aObject = (*aIt); + FeaturePtr aFeature = boost::dynamic_pointer_cast(aObject); + if (aFeature && (!aFeature->isInHistory())) + continue; + + DocumentPtr aDoc = aObject->document(); if (aDoc == aRootDoc) { // If root objects - if (aFeature->groupName().compare(ModelAPI_ResultPart::group()) == 0) { // Update only Parts group + if (aObject->groupName() == ModelAPI_ResultPart::group()) { // Update only Parts group // Add a new part int aStart = myPartModels.size(); XGUI_PartDataModel* aModel = new XGUI_PartDataModel(this); @@ -65,7 +69,7 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage) myPartModels.append(aModel); insertRow(aStart, partFolderNode()); } else { // Update top groups (other except parts - QModelIndex aIndex = myModel->findParent(aFeature); + QModelIndex aIndex = myModel->findParent(aObject); int aStart = myModel->rowCount(aIndex) - 1; aIndex = createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex)); insertRow(aStart, aIndex); @@ -80,7 +84,7 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage) } } if (aPartModel) { - QModelIndex aIndex = aPartModel->findParent(aFeature); + QModelIndex aIndex = aPartModel->findParent(aObject); int aStart = aPartModel->rowCount(aIndex) - 1; aIndex = createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex)); insertRow(aStart, aIndex); diff --git a/src/XGUI/XGUI_PartDataModel.cpp b/src/XGUI/XGUI_PartDataModel.cpp index b77297f54..bfc6dea68 100644 --- a/src/XGUI/XGUI_PartDataModel.cpp +++ b/src/XGUI/XGUI_PartDataModel.cpp @@ -391,7 +391,7 @@ DocumentPtr XGUI_PartDataModel::partDocument() const { DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), myId); - return aObject->data()->docRef("PartDocument")->value(); + return aObject->document(); } ObjectPtr XGUI_PartDataModel::object(const QModelIndex& theIndex) const diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index dddd97fb6..436803e09 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -274,7 +274,7 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage) //****************************************************** void XGUI_Workshop::onFeatureUpdatedMsg(const Model_ObjectUpdatedMessage* theMsg) { - std::set aFeatures = theMsg->features(); + std::set aFeatures = theMsg->objects(); if (myOperationMgr->hasOperation()) { FeaturePtr aCurrentFeature = myOperationMgr->currentOperation()->feature(); @@ -292,10 +292,10 @@ void XGUI_Workshop::onFeatureUpdatedMsg(const Model_ObjectUpdatedMessage* theMsg //****************************************************** void XGUI_Workshop::onFeatureRedisplayMsg(const Model_ObjectUpdatedMessage* theMsg) { - std::set aFeatures = theMsg->features(); + std::set aObjects = theMsg->objects(); std::set::const_iterator aIt; bool isDisplayed = false; - for (aIt = aFeatures.begin(); aIt != aFeatures.end(); ++aIt) { + for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) { ResultPtr aRes = boost::dynamic_pointer_cast(*aIt); if (aRes) { isDisplayed = myDisplayer->redisplay(aRes, false); @@ -308,7 +308,7 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const Model_ObjectUpdatedMessage* theM //****************************************************** void XGUI_Workshop::onFeatureCreatedMsg(const Model_ObjectUpdatedMessage* theMsg) { - std::set aFeatures = theMsg->features(); + std::set aFeatures = theMsg->objects(); std::set::const_iterator aIt; bool aHasPart = false; -- 2.39.2