#endif /* HAVE_TBB */
+#include <TDocStd_Application.hxx>
+#include <XCAFApp_Application.hxx>
+#include <TDocStd_Document.hxx>
+#include <XCAFDoc_ShapeTool.hxx>
+#include <XCAFDoc_DocumentTool.hxx>
+#include <TDF_Label.hxx>
+#include <TDataStd_Name.hxx>
+
+static Standard_Integer OCC23595 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char **argv)
+{
+ const Handle(TDocStd_Application)& anApp = XCAFApp_Application::GetApplication();
+ Handle(TDocStd_Document) aDoc;
+ anApp->NewDocument ("XmlXCAF", aDoc);
+ QCOMPARE (!aDoc.IsNull(), Standard_True);
+
+ Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main());
+
+ //check default value
+ Standard_Boolean aValue = XCAFDoc_ShapeTool::AutoNaming();
+ QCOMPARE (aValue, Standard_True);
+
+ //true
+ XCAFDoc_ShapeTool::SetAutoNaming (Standard_True);
+ TopoDS_Shape aShape = BRepPrimAPI_MakeBox (100., 200., 300.).Shape();
+ TDF_Label aLabel = aShTool->AddShape (aShape);
+ Handle(TDataStd_Name) anAttr;
+ QCOMPARE (aLabel.FindAttribute (TDataStd_Name::GetID(), anAttr), Standard_True);
+
+ //false
+ XCAFDoc_ShapeTool::SetAutoNaming (Standard_False);
+ aShape = BRepPrimAPI_MakeBox (300., 200., 100.).Shape();
+ aLabel = aShTool->AddShape (aShape);
+ QCOMPARE (!aLabel.FindAttribute (TDataStd_Name::GetID(), anAttr), Standard_True);
+
+ //restore
+ XCAFDoc_ShapeTool::SetAutoNaming (aValue);
+
+ return 0;
+}
+
void QABugs::Commands_19(Draw_Interpretor& theCommands) {
const char *group = "QABugs";
theCommands.Add ("OCC23361", "OCC23361", __FILE__, OCC23361, group);
theCommands.Add ("OCC23237", "OCC23237", __FILE__, OCC23237, group);
theCommands.Add ("OCC22980", "OCC22980", __FILE__, OCC22980, group);
+ theCommands.Add ("OCC23595", "OCC23595", __FILE__, OCC23595, group);
return;
}
-- 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)
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
#include <gp_Pnt.hxx>
#include <XCAFDoc_ShapeMapTool.hxx>
-#define AUTONAMING // automatically set names for labels
+static Standard_Boolean theAutoNaming = Standard_True;
// attribute methods //////////////////////////////////////////////////
{
}
-#ifdef AUTONAMING
// Auxiliary methods //////////////////////////////////////////////////
//=======================================================================
TDataStd_Name::Set(L, TCollection_ExtendedString(aName));
}
}
-#endif
//=======================================================================
refNode->Remove(); // abv: fix against bug in TreeNode::Append()
mainNode->Append(refNode);
-#ifdef AUTONAMING
- SetLabelNameByLink(L);
-#endif
+ if (theAutoNaming)
+ SetLabelNameByLink(L);
}
//=======================================================================
// }
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);
}
+//=======================================================================
+//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 :
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
// 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
--- /dev/null
+puts "============"
+puts "OCC23595"
+puts "============"
+puts ""
+#######################################################################
+# XCAFDoc_ShapeTool extended with two methods - SetAutoNaming() and AutoNaming()
+#######################################################################
+
+pload QAcommands
+
+OCC23595