}
void Model_Document::setCurrentFeature(std::shared_ptr<ModelAPI_Feature> theCurrent,
- const bool theVisible)
+ const bool theVisible, const bool theFlushUpdates)
{
// blocks the flush signals to avoid each objects visualization in the viewer
// they should not be shown once after all modifications are performed
// unblock the flush signals and up them after this
aLoop->activateFlushes(isActive);
- aLoop->flush(aCreateEvent);
- aLoop->flush(aRedispEvent);
- aLoop->flush(aDeleteEvent);
+ if (theFlushUpdates) {
+ aLoop->flush(aCreateEvent);
+ aLoop->flush(aRedispEvent);
+ aLoop->flush(aDeleteEvent);
+ }
}
void Model_Document::setCurrentFeatureUp()
FeaturePtr aCurrent = currentFeature(false);
if (aCurrent.get()) { // if not, do nothing because null is the upper
FeaturePtr aPrev = myObjs->nextFeature(aCurrent, true);
- setCurrentFeature(aPrev, false);
+ // do not flush: it is called only on remove, it will be flushed in the end of transaction
+ setCurrentFeature(aPrev, false, false);
}
}
//! \param theCurrent the selected feature as current: blow it everythin become disabled
//! \param theVisible use visible features only: flag is true for Object Browser functionality
MODEL_EXPORT virtual void setCurrentFeature(std::shared_ptr<ModelAPI_Feature> theCurrent,
- const bool theVisible);
+ const bool theVisible, const bool theFlushUpdates = true);
//! Makes the current feature one feature upper
MODEL_EXPORT virtual void setCurrentFeatureUp();
//! will be appended after this one.
//! \param theCurrent the selected feature as current: blow it everythin become disabled
//! \param theVisible use visible features only: flag is true for Object Browser functionality
+ //! \param theFlushUpdates if it is true (default) it flashes creation/redisplay/delete messages
virtual void setCurrentFeature(std::shared_ptr<ModelAPI_Feature> theCurrent,
- const bool theVisible) = 0;
+ const bool theVisible, const bool theFlushUpdates = true) = 0;
//! Makes the current feature one feature upper
virtual void setCurrentFeatureUp() = 0;
//**************************************************************
void refsToFeatureInAllDocuments(const ObjectPtr& theSourceObject, const ObjectPtr& theObject,
- std::set<FeaturePtr>& theDirectRefFeatures, std::set<FeaturePtr>& theIndirectRefFeatures)
+ std::set<FeaturePtr>& theDirectRefFeatures,
+ std::set<FeaturePtr>& theIndirectRefFeatures,
+ std::set<FeaturePtr>& theAlreadyProcessed)
{
FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
if (!aFeature.get())
return;
+ if (theAlreadyProcessed.find(aFeature) != theAlreadyProcessed.end())
+ return;
+ theAlreadyProcessed.insert(aFeature);
// 1. find references in the current document
std::set<FeaturePtr> aRefFeatures;
// Run recursion. It is possible recursive dependency, like the following: plane, extrusion uses plane,
// axis is built on extrusion. Delete of a plane should check the dependency from the axis also.
- std::set<FeaturePtr> aRecursiveRefFeatures;
std::set<FeaturePtr>::const_iterator aFeatureIt = theDirectRefFeatures.begin();
for (; aFeatureIt != theDirectRefFeatures.end(); ++aFeatureIt) {
- refsToFeatureInAllDocuments(theSourceObject, *aFeatureIt, aRecursiveRefFeatures, aRecursiveRefFeatures);
- }
- theIndirectRefFeatures.insert(aRecursiveRefFeatures.begin(), aRecursiveRefFeatures.end());
+ std::set<FeaturePtr> aRecursiveRefFeatures;
+ refsToFeatureInAllDocuments(theSourceObject, *aFeatureIt,
+ aRecursiveRefFeatures, aRecursiveRefFeatures, theAlreadyProcessed);
+ theIndirectRefFeatures.insert(aRecursiveRefFeatures.begin(), aRecursiveRefFeatures.end());
+ }
}
}
which has the object as a sub object.
\param theSourceObject an object, which references are searched
\param theObject an intermediate recursive object, should be set in the source object
+ \param theAlreadyProcessed set of processed elements, used for optimization (do not reanalyse processed)
\return a boolean value
*/
void XGUI_EXPORT refsToFeatureInAllDocuments(const ObjectPtr& theSourceObject,
const ObjectPtr& theObject,
std::set<FeaturePtr>& theDirectRefFeatures,
- std::set<FeaturePtr>& theIndirectRefFeatures);
+ std::set<FeaturePtr>& theIndirectRefFeatures,
+ std::set<FeaturePtr>& theAlreadyProcessed);
};
#endif
// 1. find all referenced features
std::set<FeaturePtr> aDirectRefFeatures, aIndirectRefFeatures;
foreach (ObjectPtr aDeletedObj, theList) {
- XGUI_Tools::refsToFeatureInAllDocuments(aDeletedObj, aDeletedObj, aDirectRefFeatures, aIndirectRefFeatures);
+ std::set<FeaturePtr> alreadyProcessed;
+ XGUI_Tools::refsToFeatureInAllDocuments(
+ aDeletedObj, aDeletedObj, aDirectRefFeatures, aIndirectRefFeatures, alreadyProcessed);
std::set<FeaturePtr> aDifference;
std::set_difference(aIndirectRefFeatures.begin(), aIndirectRefFeatures.end(),
aDirectRefFeatures.begin(), aDirectRefFeatures.end(),