From: mpv Date: Wed, 1 Jul 2015 14:50:40 +0000 (+0300) Subject: Make correct management of concealed on history position changes (on edit, manual... X-Git-Tag: V_1.3.0~130 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=510f47f9aa419d3893ed69d48f0c7df7aebf9ef7;p=modules%2Fshaper.git Make correct management of concealed on history position changes (on edit, manual change, etc.) --- diff --git a/src/Model/Model_Data.cpp b/src/Model/Model_Data.cpp index ae09db9b0..12f79ae5d 100644 --- a/src/Model/Model_Data.cpp +++ b/src/Model/Model_Data.cpp @@ -324,27 +324,7 @@ void Model_Data::removeBackReference(FeaturePtr theFeature, std::string theAttrI // remove concealment immideately: on deselection it must be posible to reselect in GUI the same if (ModelAPI_Session::get()->validators()->isConcealed(theFeature->getKind(), theAttrID)) { - std::set::iterator aRefsIter = myRefsToMe.begin(); - for(; aRefsIter != myRefsToMe.end(); aRefsIter++) { - if (aRefsIter->get()) { - FeaturePtr aFeature = std::dynamic_pointer_cast((*aRefsIter)->owner()); - if (aFeature.get()) { - if (ModelAPI_Session::get()->validators()->isConcealed( - aFeature->getKind(), (*aRefsIter)->id())) { - return; // it is still concealed, nothing to do - } - } - } - } - // thus, no concealment references anymore => make not-concealed - std::shared_ptr aRes = - std::dynamic_pointer_cast(myObject); - if (aRes.get()) { - aRes->setIsConcealed(false); - static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED); - ModelAPI_EventCreator::get()->sendUpdated(aRes, anEvent); - Events_Loop::loop()->flush(anEvent); - } + updateConcealmentFlag(); } } @@ -370,6 +350,31 @@ void Model_Data::addBackReference(FeaturePtr theFeature, std::string theAttrID, } } +void Model_Data::updateConcealmentFlag() +{ + std::set::iterator aRefsIter = myRefsToMe.begin(); + for(; aRefsIter != myRefsToMe.end(); aRefsIter++) { + if (aRefsIter->get()) { + FeaturePtr aFeature = std::dynamic_pointer_cast((*aRefsIter)->owner()); + if (aFeature.get() && !aFeature->isDisabled()) { + if (ModelAPI_Session::get()->validators()->isConcealed( + aFeature->getKind(), (*aRefsIter)->id())) { + return; // it is still concealed, nothing to do + } + } + } + } + // thus, no concealment references anymore => make not-concealed + std::shared_ptr aRes = + std::dynamic_pointer_cast(myObject); + if (aRes.get()) { + aRes->setIsConcealed(false); + static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED); + ModelAPI_EventCreator::get()->sendUpdated(aRes, anEvent); + Events_Loop::loop()->flush(anEvent); + } +} + void Model_Data::referencesToObjects( std::list > >& theRefs) { diff --git a/src/Model/Model_Data.h b/src/Model/Model_Data.h index 9b46312b8..5e51c9d50 100644 --- a/src/Model/Model_Data.h +++ b/src/Model/Model_Data.h @@ -222,6 +222,9 @@ private: void addBackReference(FeaturePtr theFeature, std::string theAttrID, const bool theApplyConcealment = true); + /// Makes the concealment flag up to date for this object-owner. + MODEL_EXPORT virtual void updateConcealmentFlag(); + /// Returns true if object must be displayed in the viewer: flag is stored in the /// data model, so on undo/redo, open/save or recreation of object by history-playing it keeps /// the original state i nthe current transaction. diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index a18375f86..62e27bdd0 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -723,6 +723,7 @@ void Model_Document::setCurrentFeature(std::shared_ptr theCurr bool aPassed = false; // flag that the current object is already passed in cycle FeaturePtr anIter = myObjs->lastFeature(); + bool aWasChanged = false; for(; anIter.get(); anIter = myObjs->nextFeature(anIter, true)) { // check this before passed become enabled: the current feature is enabled! if (anIter == theCurrent) aPassed = true; @@ -738,6 +739,17 @@ void Model_Document::setCurrentFeature(std::shared_ptr theCurr ModelAPI_EventCreator::get()->sendUpdated(anIter, anUpdateEvent); // flush is in the end of this method ModelAPI_EventCreator::get()->sendUpdated(anIter, aRedispEvent /*, false*/); + aWasChanged = true; + } + // update for everyone the concealment flag immideately: on edit feature in the midle of history + if (aWasChanged) { + const std::list >& aResList = anIter->results(); + std::list >::const_iterator aRes = aResList.begin(); + for(; aRes != aResList.end(); aRes++) { + if ((*aRes).get() && (*aRes)->data()->isValid() && !(*aRes)->isDisabled()) + std::dynamic_pointer_cast((*aRes)->data())->updateConcealmentFlag(); + } + } } // unblock the flush signals and up them after this @@ -885,3 +897,8 @@ void Model_Document::decrementTransactionID() int aNewVal = transactionID() - 1; TDataStd_Integer::Set(generalLabel().FindChild(TAG_CURRENT_TRANSACTION), aNewVal); } + +bool Model_Document::isOpened() +{ + return myObjs && !myDoc.IsNull(); +} diff --git a/src/Model/Model_Document.h b/src/Model/Model_Document.h index 1aaca02ac..586d50a28 100644 --- a/src/Model/Model_Document.h +++ b/src/Model/Model_Document.h @@ -179,6 +179,9 @@ class Model_Document : public ModelAPI_Document /// Decreases the transaction ID MODEL_EXPORT virtual void decrementTransactionID(); + /// Returns true if document is opened and valid + MODEL_EXPORT virtual bool isOpened(); + protected: //! Returns (creates if needed) the general label TDF_Label generalLabel() const; diff --git a/src/Model/Model_ResultPart.cpp b/src/Model/Model_ResultPart.cpp index 5216e6107..a376cc88f 100644 --- a/src/Model/Model_ResultPart.cpp +++ b/src/Model/Model_ResultPart.cpp @@ -78,7 +78,7 @@ bool Model_ResultPart::setDisabled(std::shared_ptr theThis, { if (ModelAPI_ResultPart::setDisabled(theThis, theFlag)) { DocumentPtr aDoc = Model_ResultPart::partDoc(); - if (aDoc.get()) { + if (aDoc.get() && aDoc->isOpened()) { // make the current feature the last in any case: to update shapes defore deactivation too FeaturePtr aLastFeature = std::dynamic_pointer_cast(aDoc->object( ModelAPI_Feature::group(), aDoc->size(ModelAPI_Feature::group()) - 1)); diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index e3e9f548b..7e592744b 100644 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -148,7 +148,7 @@ void Model_Update::processOperation(const bool theTotalUpdate, const bool theFin if (theFinish) { // the hardcode (DBC asked): hide the sketch referenced by extrusion on apply std::set >::iterator aFIter; - for(aFIter = myJustUpdated.begin(); aFIter != myJustUpdated.end(); aFIter++) + for(aFIter = myWaitForFinish.begin(); aFIter != myWaitForFinish.end(); aFIter++) { FeaturePtr aF = std::dynamic_pointer_cast(*aFIter); if (aF && aF->data()->isValid() && aF->getKind() == "Extrusion") { @@ -163,6 +163,7 @@ void Model_Update::processOperation(const bool theTotalUpdate, const bool theFin } } } + myWaitForFinish.clear(); } // perform update of everything if needed if (!myIsExecuted) { @@ -444,6 +445,7 @@ void Model_Update::executeFeature(FeaturePtr theFeature) aState = ModelAPI_StateExecFailed; } else { aState = ModelAPI_StateDone; + myWaitForFinish.insert(theFeature); } } catch(...) { aState = ModelAPI_StateExecFailed; diff --git a/src/Model/Model_Update.h b/src/Model/Model_Update.h index 56a16cbd2..1ae12eb09 100644 --- a/src/Model/Model_Update.h +++ b/src/Model/Model_Update.h @@ -25,6 +25,8 @@ class Model_Update : public Events_Listener { /// updated features during this transaction: must be updated immediately std::set > myJustUpdated; + /// features that must be additionally processed after execution of finish operation + std::set > myWaitForFinish; /// to know that all next updates are caused by this execution bool myIsExecuted; /// to know execute or not automatically all update diff --git a/src/ModelAPI/ModelAPI_Document.h b/src/ModelAPI/ModelAPI_Document.h index b1aa60c7b..2a97982b0 100644 --- a/src/ModelAPI/ModelAPI_Document.h +++ b/src/ModelAPI/ModelAPI_Document.h @@ -134,6 +134,10 @@ public: //! Returns true if this document is currently active virtual bool isActive() const = 0; + /// Returns true if document is opened and valid + virtual bool isOpened() = 0; + + protected: //! Only for SWIG wrapping it is here MODELAPI_EXPORT ModelAPI_Document();