aSelLab.ForgetAllAttributes(true);
TDataStd_UAttribute::Set(aSelLab, kPART_REF_ID);
selectPart(std::dynamic_pointer_cast<ModelAPI_Result>(theContext), theSubShape);
+ } else { // check the feature context: parent-Part of this feature should not be used
+ FeaturePtr aFeatureContext = std::dynamic_pointer_cast<ModelAPI_Feature>(theContext);
+ if (aFeatureContext.get()) {
+ if (owner()->document() != aFeatureContext->document()) {
+ aSelLab.ForgetAllAttributes(true);
+ myRef.setValue(ObjectPtr());
+ if (aToUnblock)
+ owner()->data()->blockSendAttributeUpdated(false);
+ return false;
+ }
+ }
}
owner()->data()->sendAttributeUpdated(this);
}
}
+TNaming_Builder* Model_BodyBuilder::builder(const int theTag)
+{
+ std::map<int, TNaming_Builder*>::iterator aFind = myBuilders.find(theTag);
+ if (aFind == myBuilders.end()) {
+ std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
+ myBuilders[theTag] = new TNaming_Builder(
+ theTag == 0 ? aData->shapeLab() : aData->shapeLab().FindChild(theTag));
+ aFind = myBuilders.find(theTag);
+ }
+ return aFind->second;
+}
+
void Model_BodyBuilder::storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
const std::shared_ptr<GeomAPI_Shape>& theNewShape, const int theDecomposeSolidsTag)
{
if (theDecomposeSolidsTag != -2)
clean();
// store the new shape as primitive
- TNaming_Builder aBuilder(aShapeLab);
+ TNaming_Builder* aBuilder = builder(0);
if (!theOldShape || !theNewShape)
return; // bad shape
TopoDS_Shape aShapeOld = theOldShape->impl<TopoDS_Shape>();
TopoDS_Shape aShapeNew = theNewShape->impl<TopoDS_Shape>();
if (aShapeNew.IsNull())
return; // null shape inside
- aBuilder.Modify(aShapeOld, aShapeNew);
- if(!aBuilder.NamedShape()->IsEmpty()) {
+ aBuilder->Modify(aShapeOld, aShapeNew);
+ if(!aBuilder->NamedShape()->IsEmpty()) {
Handle(TDataStd_Name) anAttr;
- if(aBuilder.NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(),anAttr)) {
+ if(aBuilder->NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(),anAttr)) {
std::string aName (TCollection_AsciiString(anAttr->Get()).ToCString());
if(!aName.empty()) {
std::shared_ptr<Model_Document> aDoc =
std::dynamic_pointer_cast<Model_Document>(document());
- aDoc->addNamingName(aBuilder.NamedShape()->Label(), aName);
+ aDoc->addNamingName(aBuilder->NamedShape()->Label(), aName);
}
}
}
clean();
}
-TNaming_Builder* Model_BodyBuilder::builder(const int theTag)
-{
- std::map<int, TNaming_Builder*>::iterator aFind = myBuilders.find(theTag);
- if (aFind == myBuilders.end()) {
- std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
- myBuilders[theTag] = new TNaming_Builder(
- theTag == 0 ? aData->shapeLab() : aData->shapeLab().FindChild(theTag));
- aFind = myBuilders.find(theTag);
- }
- return aFind->second;
-}
-
void Model_BodyBuilder::buildName(const int theTag, const std::string& theName)
{
std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(document());
// Store only in case if it does not have reference.
if (!aShapeLab.FindAttribute(TDF_Reference::GetID(), aRef)) {
if (theIsStoreAsGenerated) {
+ TNaming_Builder* aBuilder = builder(0);
+ if (!aBuilder->NamedShape().IsNull() &&
+ aBuilder->NamedShape()->Evolution() != TNaming_GENERATED) {
+ myBuilders.erase(0); // clear old builder to avoid different evolutions crash
+ }
builder(0)->Generated(aRoot, aNewShape);
} else {
+ TNaming_Builder* aBuilder = builder(0);
+ if (!aBuilder->NamedShape().IsNull() &&
+ aBuilder->NamedShape()->Evolution() != TNaming_MODIFY) {
+ myBuilders.erase(0); // clear old builder to avoid different evolutions crash
+ }
builder(0)->Modify(aRoot, aNewShape);
}
}
static const int TAG_EXTERNAL_CONSTRUCTIONS = 5;
Model_Document::Model_Document(const int theID, const std::string theKind)
- : myID(theID), myKind(theKind), myIsActive(false),
+ : myID(theID), myKind(theKind), myIsActive(false), myIsSetCurrentFeature(false),
myDoc(new TDocStd_Document("BinOcaf")) // binary OCAF format
{
#ifdef TINSPECTOR
void Model_Document::setCurrentFeature(
std::shared_ptr<ModelAPI_Feature> theCurrent, const bool theVisible)
{
+ if (myIsSetCurrentFeature)
+ return;
+ myIsSetCurrentFeature = true;
// blocks the flush signals to avoid each objects visualization in the viewer
// they should not be shown once after all modifications are performed
Events_Loop* aLoop = Events_Loop::loop();
std::shared_ptr<Model_Data> aData = std::static_pointer_cast<Model_Data>(theCurrent->data());
if (!aData.get() || !aData->isValid()) {
aLoop->activateFlushes(isActive);
+ myIsSetCurrentFeature = false;
return;
}
TDF_Label aFeatureLabel = aData->label().Father();
}
}
}
+ myIsSetCurrentFeature = false;
// unblock the flush signals and up them after this
aLoop->activateFlushes(isActive);
}