X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FModel%2FModel_Data.cpp;h=e5641930e1b1253ab05e0a83f5afbd1ab8c34137;hb=c942db5a30da5f57a89e6d4835187d64a74f89ca;hp=16355161ada949afd7e3fa07fdec8783dde6c755;hpb=0b7860f6ea3d1b8389227f337ec507833cbadb06;p=modules%2Fshaper.git diff --git a/src/Model/Model_Data.cpp b/src/Model/Model_Data.cpp index 16355161a..e5641930e 100644 --- a/src/Model/Model_Data.cpp +++ b/src/Model/Model_Data.cpp @@ -35,6 +35,9 @@ #include #include #include +#include +#include + #include #include #include @@ -43,7 +46,6 @@ #include #include #include -#include #include #include @@ -56,13 +58,8 @@ #include #include -#include #include -#include -#include -#include #include -#include #include @@ -240,6 +237,21 @@ AttributePtr Model_Data::addFloatingAttribute( int anIndex; TDF_Label aLab; if (myLab.IsAttribute(TDF_TagSource::GetID())) { + // check this is re-init of attributes, so, check attribute with this name already there + TDF_ChildIDIterator anIter(myLab, kGroupAttributeID, false); + for(; anIter.More(); anIter.Next()) { + TCollection_AsciiString aThisName(Handle(TDataStd_Name)::DownCast(anIter.Value())->Get()); + if (theID == aThisName.ToCString()) { + TDF_Label aLab = anIter.Value()->Label(); + Handle(TDataStd_Name) aGName; + if (aLab.FindAttribute(kGroupAttributeGroupID, aGName)) { + TCollection_AsciiString aGroupName(aGName->Get()); + if (theGroup == aGroupName.ToCString()) { + return addAttribute(theGroup + "__" + theID, theAttrType, aLab.Tag()); + } + } + } + } aLab = myLab.NewChild(); // already exists a floating attribute, create the next anIndex = aLab.Tag(); } else { // put the first floating attribute, quite far from other standard attributes @@ -289,11 +301,12 @@ void Model_Data::removeAttributes(const std::string& theGroup) Handle(TDataStd_Name) aGroupID = Handle(TDataStd_Name)::DownCast(aGroup.Value()); if (aGroupID->Get().IsEqual(theGroup.c_str())) { Handle(TDataStd_Name) anID; - if (aGroup.Value()->Label().FindAttribute(kGroupAttributeID, anID)) { - TCollection_AsciiString anAsciiID(aGroupID->Get() + "__" + anID->Get()); - myAttrs.erase(anAsciiID.ToCString()); + if (!aGroup.Value()->Label().IsNull() && + aGroup.Value()->Label().FindAttribute(kGroupAttributeID, anID)) { aLabsToRemove.Append(aGroup.Value()->Label()); } + TCollection_AsciiString anAsciiID(aGroupID->Get() + "__" + anID->Get()); + myAttrs.erase(anAsciiID.ToCString()); } } for(TDF_LabelList::Iterator aLab(aLabsToRemove); aLab.More(); aLab.Next()) { @@ -301,6 +314,12 @@ void Model_Data::removeAttributes(const std::string& theGroup) } } +void Model_Data::clearAttributes() +{ + myAttrs.clear(); +} + + // macro for the generic returning of the attribute by the ID #define GET_ATTRIBUTE_BY_ID(ATTR_TYPE, METHOD_NAME) \ @@ -412,7 +431,8 @@ void Model_Data::sendAttributeUpdated(ModelAPI_Attribute* theAttr) } } else { // trim: need to redisplay or set color in the python script - if (myObject && (theAttr->attributeType() == "Point2D" || theAttr->id() == "Color")) { + if (myObject && (theAttr->attributeType() == "Point2D" || theAttr->id() == "Color" || + theAttr->id() == "Transparency" || theAttr->id() == "Deflection")) { static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY); ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent); } @@ -775,31 +795,10 @@ void Model_Data::referencesToObjects( } } -/// makes copy of all attributes on the given label and all sub-labels -static void copyAttrs(TDF_Label theSource, TDF_Label theDestination) { - TDF_AttributeIterator anAttrIter(theSource); - for(; anAttrIter.More(); anAttrIter.Next()) { - Handle(TDF_Attribute) aTargetAttr; - if (!theDestination.FindAttribute(anAttrIter.Value()->ID(), aTargetAttr)) { - // create a new attribute if not yet exists in the destination - aTargetAttr = anAttrIter.Value()->NewEmpty(); - theDestination.AddAttribute(aTargetAttr); - } - // no special relocation, empty map, but self-relocation is on: copy references w/o changes - Handle(TDF_RelocationTable) aRelocTable = new TDF_RelocationTable(Standard_True); - anAttrIter.Value()->Paste(aTargetAttr, aRelocTable); - } - // copy the sub-labels content - TDF_ChildIterator aSubLabsIter(theSource); - for(; aSubLabsIter.More(); aSubLabsIter.Next()) { - copyAttrs(aSubLabsIter.Value(), theDestination.FindChild(aSubLabsIter.Value().Tag())); - } -} - void Model_Data::copyTo(std::shared_ptr theTarget) { TDF_Label aTargetRoot = std::dynamic_pointer_cast(theTarget)->label(); - copyAttrs(myLab, aTargetRoot); + Model_Tools::copyAttrs(myLab, aTargetRoot); // reinitialize Model_Attributes by TDF_Attributes set std::shared_ptr aTData = std::dynamic_pointer_cast(theTarget); aTData->myAttrs.clear();