0032612: Data Exchange, RWGltf_CafReader - lost hierarchy of two nested compounds
[occt.git] / src / XDEDRAW / XDEDRAW_Shapes.cxx
index 4096d6b..e8614d8 100644 (file)
@@ -998,6 +998,42 @@ static Standard_Integer XGetProperties(Draw_Interpretor& di, Standard_Integer ar
   return 0;
 }
 
+static Standard_Integer XAutoNaming (Draw_Interpretor& theDI,
+                                     Standard_Integer theNbArgs,
+                                     const char** theArgVec)
+{
+  if (theNbArgs != 2 && theNbArgs != 3)
+  {
+    theDI << "Syntax error: wrong number of arguments";
+    return 1;
+  }
+
+  Handle(TDocStd_Document) aDoc;
+  DDocStd::GetDocument (theArgVec[1], aDoc);
+  if (aDoc.IsNull())
+  {
+    theDI << "Syntax error: '" << theArgVec[1] << "' is not a document";
+    return 1;
+  }
+
+  Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main());
+  if (theNbArgs == 2)
+  {
+    theDI << (aShapeTool->AutoNaming() ? "1" : "0");
+    return 0;
+  }
+
+  bool toEnable = true;
+  if (!Draw::ParseOnOff (theArgVec[2], toEnable))
+  {
+    theDI << "Syntax error at '" << theArgVec[2] << "'";
+    return 1;
+  }
+
+  aShapeTool->SetAutoNaming (toEnable);
+  return 0;
+}
+
 //=======================================================================
 //function : InitCommands
 //purpose  : 
@@ -1113,4 +1149,7 @@ void XDEDRAW_Shapes::InitCommands(Draw_Interpretor& di)
 
   di.Add("XGetProperties", "Doc Label \t: prints named properties assigned to the Label",
          __FILE__, XGetProperties, g);
+
+  di.Add ("XAutoNaming","Doc [0|1]\t: Disable/enable autonaming to Document",
+          __FILE__, XAutoNaming, g);
 }