1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-18 14:27:39 +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

@@ -232,6 +232,7 @@ is
-- as assemblies (creates assembly structure).
-- NOTE: <makePrepare> replace components without location
-- in assmebly by located components to avoid some problems.
-- If AutoNaming() is True then automatically attaches names.
addShape (me:mutable; S: Shape from TopoDS;
makeAssembly: Boolean = Standard_True)
@@ -250,6 +251,23 @@ is
Init (me: mutable);
---Purpose: set hasComponents into false
SetAutoNaming (myclass; V: Boolean);
---Purpose: Sets auto-naming mode to <V>. If True then for added
-- shapes, links, assemblies and SHUO's, the TDataStd_Name attribute
-- is automatically added. For shapes it contains a shape type
-- (e.g. "SOLID", "SHELL", etc); for links it has a form
-- "=>[0:1:1:2]" (where a tag is a label containing a shape
-- without a location); for assemblies it is "ASSEMBLY", and
-- "SHUO" for SHUO's.
-- This setting is global; it cannot be made a member function
-- as it is used by static methods as well.
-- By default, auto-naming is enabled.
-- See also AutoNaming().
AutoNaming (myclass) returns Boolean;
---Purpose: Returns current auto-naming mode. See SetAutoNaming() for
-- description.
ComputeShapes (me: mutable; L: Label from TDF);
---Purpose: recursive

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