// 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<AttributePtr>::iterator aRefsIter = myRefsToMe.begin();
- for(; aRefsIter != myRefsToMe.end(); aRefsIter++) {
- if (aRefsIter->get()) {
- FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>((*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<ModelAPI_Result> aRes =
- std::dynamic_pointer_cast<ModelAPI_Result>(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();
}
}
}
}
+void Model_Data::updateConcealmentFlag()
+{
+ std::set<AttributePtr>::iterator aRefsIter = myRefsToMe.begin();
+ for(; aRefsIter != myRefsToMe.end(); aRefsIter++) {
+ if (aRefsIter->get()) {
+ FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>((*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<ModelAPI_Result> aRes =
+ std::dynamic_pointer_cast<ModelAPI_Result>(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<std::pair<std::string, std::list<ObjectPtr> > >& theRefs)
{
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.
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;
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<std::shared_ptr<ModelAPI_Result> >& aResList = anIter->results();
+ std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aRes = aResList.begin();
+ for(; aRes != aResList.end(); aRes++) {
+ if ((*aRes).get() && (*aRes)->data()->isValid() && !(*aRes)->isDisabled())
+ std::dynamic_pointer_cast<Model_Data>((*aRes)->data())->updateConcealmentFlag();
+ }
+
}
}
// unblock the flush signals and up them after this
int aNewVal = transactionID() - 1;
TDataStd_Integer::Set(generalLabel().FindChild(TAG_CURRENT_TRANSACTION), aNewVal);
}
+
+bool Model_Document::isOpened()
+{
+ return myObjs && !myDoc.IsNull();
+}
/// 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;
{
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<ModelAPI_Feature>(aDoc->object(
ModelAPI_Feature::group(), aDoc->size(ModelAPI_Feature::group()) - 1));
if (theFinish) {
// the hardcode (DBC asked): hide the sketch referenced by extrusion on apply
std::set<std::shared_ptr<ModelAPI_Object> >::iterator aFIter;
- for(aFIter = myJustUpdated.begin(); aFIter != myJustUpdated.end(); aFIter++)
+ for(aFIter = myWaitForFinish.begin(); aFIter != myWaitForFinish.end(); aFIter++)
{
FeaturePtr aF = std::dynamic_pointer_cast<ModelAPI_Feature>(*aFIter);
if (aF && aF->data()->isValid() && aF->getKind() == "Extrusion") {
}
}
}
+ myWaitForFinish.clear();
}
// perform update of everything if needed
if (!myIsExecuted) {
aState = ModelAPI_StateExecFailed;
} else {
aState = ModelAPI_StateDone;
+ myWaitForFinish.insert(theFeature);
}
} catch(...) {
aState = ModelAPI_StateExecFailed;
{
/// updated features during this transaction: must be updated immediately
std::set<std::shared_ptr<ModelAPI_Object> > myJustUpdated;
+ /// features that must be additionally processed after execution of finish operation
+ std::set<std::shared_ptr<ModelAPI_Object> > myWaitForFinish;
/// to know that all next updates are caused by this execution
bool myIsExecuted;
/// to know execute or not automatically all update
//! 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();