1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0023595: XCAFDoc_ShapeTool extended with two methods - SetAutoNaming() and AutoNaming()

Adding new draw command
Adding test case for this fix
Small correction
Small correction
This commit is contained in:
Roman Lygin
2012-12-28 18:02:51 +04:00
parent a9da59ffb6
commit e6aad0ee24
4 changed files with 108 additions and 21 deletions

View File

@@ -58,7 +58,7 @@
#include <gp_Pnt.hxx>
#include <XCAFDoc_ShapeMapTool.hxx>
#define AUTONAMING // automatically set names for labels
static Standard_Boolean theAutoNaming = Standard_True;
// attribute methods //////////////////////////////////////////////////
@@ -141,7 +141,6 @@ void XCAFDoc_ShapeTool::Paste (const Handle(TDF_Attribute)& /*into*/,
{
}
#ifdef AUTONAMING
// Auxiliary methods //////////////////////////////////////////////////
//=======================================================================
@@ -189,7 +188,6 @@ static void SetLabelNameByShape(const TDF_Label L)
TDataStd_Name::Set(L, TCollection_ExtendedString(aName));
}
}
#endif
//=======================================================================
@@ -454,9 +452,8 @@ void XCAFDoc_ShapeTool::MakeReference (const TDF_Label &L,
refNode->Remove(); // abv: fix against bug in TreeNode::Append()
mainNode->Append(refNode);
#ifdef AUTONAMING
SetLabelNameByLink(L);
#endif
if (theAutoNaming)
SetLabelNameByLink(L);
}
//=======================================================================
@@ -496,18 +493,16 @@ TDF_Label XCAFDoc_ShapeTool::addShape (const TopoDS_Shape& S, const Standard_Boo
// }
A->SetShape(S);
#ifdef AUTONAMING
SetLabelNameByShape(ShapeLabel);
#endif
if (theAutoNaming)
SetLabelNameByShape(ShapeLabel);
// if shape is Compound and flag is set, create assembly
if ( makeAssembly && S.ShapeType() == TopAbs_COMPOUND ) {
// mark assembly by assigning UAttribute
Handle(TDataStd_UAttribute) Uattr;
Uattr = TDataStd_UAttribute::Set ( ShapeLabel, XCAFDoc::AssemblyGUID() );
#ifdef AUTONAMING
TDataStd_Name::Set(ShapeLabel, TCollection_ExtendedString("ASSEMBLY"));
#endif
if (theAutoNaming)
TDataStd_Name::Set(ShapeLabel, TCollection_ExtendedString("ASSEMBLY"));
// iterate on components
TopoDS_Iterator Iterator(S);
@@ -643,6 +638,28 @@ void XCAFDoc_ShapeTool::Init()
}
//=======================================================================
//function : SetAutoNaming
//purpose :
//=======================================================================
void XCAFDoc_ShapeTool::SetAutoNaming (const Standard_Boolean V)
{
theAutoNaming = V;
}
//=======================================================================
//function : AutoNaming
//purpose :
//=======================================================================
Standard_Boolean XCAFDoc_ShapeTool::AutoNaming()
{
return theAutoNaming;
}
//=======================================================================
//function : ComputeShapes
//purpose :
@@ -1384,10 +1401,10 @@ Standard_Boolean XCAFDoc_ShapeTool::SetSHUO (const TDF_LabelSequence& labels,
TDF_TagSource aTag;
TDF_Label UpperSubL = aTag.NewChild( labels( 1 ) );
#ifdef AUTONAMING
TCollection_ExtendedString Entry("SHUO");
TDataStd_Name::Set(UpperSubL, TCollection_ExtendedString( Entry ));
#endif
if (theAutoNaming) {
TCollection_ExtendedString Entry("SHUO");
TDataStd_Name::Set(UpperSubL, TCollection_ExtendedString( Entry ));
}
Handle(XCAFDoc_GraphNode) aUpperSHUO;
aUpperSHUO = XCAFDoc_GraphNode::Set( UpperSubL, XCAFDoc::SHUORefGUID() );
// init out argument by main upper usage SHUO
@@ -1395,11 +1412,11 @@ Standard_Boolean XCAFDoc_ShapeTool::SetSHUO (const TDF_LabelSequence& labels,
// add other next_usage occurrences.
for (i = 2; i <= labels.Length(); i++) {
TDF_Label NextSubL = aTag.NewChild( labels( i ) );
#ifdef AUTONAMING
TCollection_ExtendedString EntrySub("SHUO-");
EntrySub += i;
TDataStd_Name::Set(NextSubL, TCollection_ExtendedString( EntrySub ));
#endif
if (theAutoNaming) {
TCollection_ExtendedString EntrySub("SHUO-");
EntrySub += i;
TDataStd_Name::Set(NextSubL, TCollection_ExtendedString( EntrySub ));
}
Handle(XCAFDoc_GraphNode) aNextSHUO;
aNextSHUO = XCAFDoc_GraphNode::Set( NextSubL, XCAFDoc::SHUORefGUID() );
// set references