#include "Model_Events.h"
#include "Model_Data.h"
+#include <GeomAPI_Shape.h>
+
#include <TDF_AttributeIterator.hxx>
#include <TDF_ChildIterator.hxx>
#include <TDF_RelocationTable.hxx>
+#include <TDF_DeltaOnAddition.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <BRep_Tool.hxx>
#include <TNaming_Builder.hxx>
#include <TNaming_Iterator.hxx>
+#include <TNaming_NamedShape.hxx>
#include <NCollection_List.hxx>
-using namespace std;
-
void Model_AttributeSelectionList::append(
const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape,
const bool theTemporarily)
int aNewTag = mySize->Get() + 1;
TDF_Label aNewLab = mySize->Label().FindChild(aNewTag);
- std::shared_ptr<Model_AttributeSelection> aNewAttr =
+ std::shared_ptr<Model_AttributeSelection> aNewAttr =
std::shared_ptr<Model_AttributeSelection>(new Model_AttributeSelection(aNewLab));
if (owner()) {
aNewAttr->setObject(owner());
+ aNewAttr->setParent(this);
}
aNewAttr->setID(id());
mySize->Set(aNewTag);
aNewAttr->setValue(theContext, theSubShape, theTemporarily);
if (theTemporarily)
myTmpAttr = aNewAttr;
- else
+ else
myTmpAttr.reset();
owner()->data()->sendAttributeUpdated(this);
}
int aNewTag = mySize->Get() + 1;
TDF_Label aNewLab = mySize->Label().FindChild(aNewTag);
- std::shared_ptr<Model_AttributeSelection> aNewAttr =
+ std::shared_ptr<Model_AttributeSelection> aNewAttr =
std::shared_ptr<Model_AttributeSelection>(new Model_AttributeSelection(aNewLab));
if (owner()) {
aNewAttr->setObject(owner());
+ aNewAttr->setParent(this);
}
aNewAttr->setID(id());
mySize->Set(aNewTag);
}
}
-void Model_AttributeSelectionList::removeLast()
+void Model_AttributeSelectionList::removeLast()
{
int anOldSize = mySize->Get();
if (anOldSize != 0) {
mySize->Set(anOldSize - 1);
TDF_Label aLab = mySize->Label().FindChild(anOldSize);
- std::shared_ptr<Model_AttributeSelection> aOldAttr =
+ std::shared_ptr<Model_AttributeSelection> aOldAttr =
std::shared_ptr<Model_AttributeSelection>(new Model_AttributeSelection(aLab));
aOldAttr->setObject(owner());
REMOVE_BACK_REF(aOldAttr->context());
}
}
-// copies named shapes: we need the implementation of this
+// copies named shapes: we need the implementation of this
static void CopyNS(const Handle(TNaming_NamedShape)& theFrom,
const Handle(TDF_Attribute)& theTo)
-{
+{
TDF_Label aLab = theTo->Label();
TNaming_Builder B(aLab);
case TNaming_GENERATED :
B.Generated(aOldIter.Value(), aNewIter.Value());
break;
- case TNaming_MODIFY :
+ case TNaming_MODIFY :
B.Modify(aOldIter.Value(), aNewIter.Value());
break;
- case TNaming_DELETE :
+ case TNaming_DELETE :
B.Delete (aOldIter.Value());
break;
case TNaming_SELECTED :
// for named shape copy exact shapes (in NamedShape Paste method the CopyTool is used)
Handle(TNaming_NamedShape) aNS = Handle(TNaming_NamedShape)::DownCast(anAttrIter.Value());
if (aNS.IsNull()) {
- // no relocation, empty map
- Handle(TDF_RelocationTable) aRelocTable = new TDF_RelocationTable();
+ // 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);
} else {
CopyNS(aNS, aTargetAttr);
}
} else { // this is removed, so remove everything from this label
TDF_Label aLab = mySize->Label().FindChild(aCurrent + 1);
- std::shared_ptr<Model_AttributeSelection> aOldAttr =
+ std::shared_ptr<Model_AttributeSelection> aOldAttr =
std::shared_ptr<Model_AttributeSelection>(new Model_AttributeSelection(aLab));
aOldAttr->setObject(owner());
REMOVE_BACK_REF(aOldAttr->context());
std::map<ResultPtr, std::list<std::shared_ptr<GeomAPI_Shape> > >::iterator aContext =
myCash.find(theContext);
if (aContext != myCash.end()) {
- // iterate shapes because "isEqual" method must be called for each shape
+ // iterate shapes because "isSame" method must be called for each shape
std::list<std::shared_ptr<GeomAPI_Shape> >::iterator aShapes = aContext->second.begin();
for(; aShapes != aContext->second.end(); aShapes++) {
if (!theSubShape.get()) {
if (!aShapes->get())
return true;
} else {
- if (theSubShape->isEqual(*aShapes))
+ // we need to call here isSame instead of isEqual to do not check shapes orientation
+ if (theSubShape->isSame(*aShapes))
return true;
}
}
return true;
}
} else {
- if (aValue->isEqual(theSubShape)) // shapes are equal
+ // we need to call here isSame instead of isEqual to do not check shapes orientation
+ if (aValue->isSame(theSubShape)) // shapes are equal
return true;
}
}
mySelectionType->Set(theType.c_str());
}
-std::shared_ptr<ModelAPI_AttributeSelection>
+std::shared_ptr<ModelAPI_AttributeSelection>
Model_AttributeSelectionList::value(const int theIndex)
{
if (myTmpAttr.get() && theIndex == size() - 1) {
// create a new attribute each time, by demand
// supporting of old attributes is too slow (synch each time) and buggy on redo
// (if attribute is deleted and created, the abort updates attriute and makes the Attr invalid)
- std::shared_ptr<Model_AttributeSelection> aNewAttr =
+ std::shared_ptr<Model_AttributeSelection> aNewAttr =
std::shared_ptr<Model_AttributeSelection>(new Model_AttributeSelection(aLabel));
aNewAttr->setID(id());
if (owner()) {
aNewAttr->setObject(owner());
+ aNewAttr->setParent(this);
}
return aNewAttr;
}
TDF_ChildIterator aSubIter(mySize->Label());
for(; aSubIter.More(); aSubIter.Next()) {
TDF_Label aLab = aSubIter.Value();
- std::shared_ptr<Model_AttributeSelection> aNewAttr =
+ std::shared_ptr<Model_AttributeSelection> aNewAttr =
std::shared_ptr<Model_AttributeSelection>(new Model_AttributeSelection(aLab));
if (owner()) {
aNewAttr->setObject(owner());
+ aNewAttr->setParent(this);
}
REMOVE_BACK_REF(aNewAttr->context());