]> OCCT Git - occt-copy.git/commitdiff
XCAF: assembly item ref extended to point on attributes and sub-shape indices
authorsnn <snn@opencascade.com>
Tue, 28 Feb 2017 07:16:38 +0000 (10:16 +0300)
committersnn <snn@opencascade.com>
Thu, 23 Aug 2018 09:04:26 +0000 (12:04 +0300)
src/XCAFDoc/XCAFDoc_AssemblyItemRef.cxx
src/XCAFDoc/XCAFDoc_NotesTool.hxx
src/XmlMXCAFDoc/XmlMXCAFDoc_AssemblyItemRefDriver.cxx

index 9059998e78a6b37a213f78e2677587eef360af2a..f666b962ddaab0136188e0ff9b7ef2c92e925faf 100644 (file)
@@ -246,6 +246,48 @@ XCAFDoc_AssemblyItemRef::ClearExtraRef()
   myExtraId.Clear();
 }
 
+void
+XCAFDoc_AssemblyItemRef::SetItem(const TColStd_ListOfAsciiString& thePath)
+{
+  Backup();
+  myItemId.Init(thePath);
+}
+
+void
+XCAFDoc_AssemblyItemRef::SetItem(const TCollection_AsciiString& theString)
+{
+  Backup();
+  myItemId.Init(theString);
+}
+
+void XCAFDoc_AssemblyItemRef::SetGUID(const Standard_GUID& theAttrGUID)
+{
+  Backup();
+  myExtraRef = ExtraRef_AttrGUID;
+  Standard_Character aGUIDStr[Standard_GUID_SIZE + 1];
+  theAttrGUID.ToCString(aGUIDStr); 
+  aGUIDStr[Standard_GUID_SIZE] = '\0';
+  myExtraId.Clear();
+  myExtraId.AssignCat(aGUIDStr);
+}
+
+void 
+XCAFDoc_AssemblyItemRef::SetSubshapeIndex(Standard_Integer theSubshapeIndex)
+{
+  Backup();
+  myExtraRef = ExtraRef_SubshapeIndex;
+  myExtraId.Clear();
+  myExtraId.AssignCat(theSubshapeIndex);
+}
+
+void 
+XCAFDoc_AssemblyItemRef::ClearExtraRef()
+{
+  Backup();
+  myExtraRef = ExtraRef_None;
+  myExtraId.Clear();
+}
+
 const Standard_GUID& 
 XCAFDoc_AssemblyItemRef::ID() const
 {
index 7480d134fd19ace3c85d8537cba670896f1bc4f3..fb6bfd082ee546d676e061d201835e5c78e55c1a 100644 (file)
@@ -285,6 +285,12 @@ public:
   //! \return a handle to the assembly reference attribute.
   Standard_EXPORT Handle(XCAFDoc_AssemblyItemRef) AddNote(const TDF_Label&              theNoteLabel,
                                                           const XCAFDoc_AssemblyItemId& theItemId);
+  Standard_EXPORT Handle(XCAFDoc_AssemblyItemRef) AddNoteToAttr(const TDF_Label&              theNoteLabel,
+                                                                const XCAFDoc_AssemblyItemId& theItemId,
+                                                                const Standard_GUID&          theGUID);
+  Standard_EXPORT Handle(XCAFDoc_AssemblyItemRef) AddNoteToSubshape(const TDF_Label&              theNoteLabel,
+                                                                    const XCAFDoc_AssemblyItemId& theItemId,
+                                                                    Standard_Integer              theSubshapeIndex);
 
   //! Adds the given note to the labeled item.
   //! \param [in] theNoteLabel - note label.
index 28cd41673d64c5a7101b357c3114b3ad83005983..378c71eda2ec66d5e5b47ea3974ada9f76f7c0ee 100644 (file)
@@ -22,6 +22,8 @@
 
 IMPLEMENT_STANDARD_RTTIEXT(XmlMXCAFDoc_AssemblyItemRefDriver, XmlMDF_ADriver)
 IMPLEMENT_DOMSTRING(Path, "path")
+IMPLEMENT_DOMSTRING(AttrGUID, "guid")
+IMPLEMENT_DOMSTRING(SubshapeIndex, "subshape_index")
 
 //=======================================================================
 //function :
@@ -59,7 +61,26 @@ Standard_Boolean XmlMXCAFDoc_AssemblyItemRefDriver::Paste(const XmlObjMgt_Persis
   if (aThis.IsNull())
     return Standard_False;
 
-  aThis->Set(aPath.GetString());
+  aThis->SetItem(aPath.GetString());
+
+  XmlObjMgt_DOMString anAttrGUID = anElement.getAttribute(::AttrGUID());
+  if (anAttrGUID != NULL)
+  {
+    Standard_GUID aGUID(anAttrGUID.GetString());
+    aThis->SetGUID(aGUID);
+    return Standard_True;
+  }
+
+  XmlObjMgt_DOMString aSubshapeIndex = anElement.getAttribute(::SubshapeIndex());
+  if (aSubshapeIndex != NULL)
+  {
+    Standard_Integer anIndex;
+    if (!aSubshapeIndex.GetInteger(anIndex))
+      return Standard_False;
+
+    aThis->SetSubshapeIndex(anIndex);
+    return Standard_True;
+  }
 
   return Standard_True;
 }
@@ -74,7 +95,23 @@ void XmlMXCAFDoc_AssemblyItemRefDriver::Paste(const Handle(TDF_Attribute)& theSo
 {
   Handle(XCAFDoc_AssemblyItemRef) aThis = Handle(XCAFDoc_AssemblyItemRef)::DownCast(theSource);
 
-  XmlObjMgt_DOMString aPath(aThis->Get().ToString().ToCString());
-
+  XmlObjMgt_DOMString aPath(aThis->GetItem().ToString().ToCString());
   theTarget.Element().setAttribute(::Path(), aPath);
+
+  if (aThis->IsGUID())
+  {
+    Standard_GUID aGUID = aThis->GetGUID();
+    Standard_Character aGUIDStr[Standard_GUID_SIZE + 1];
+    aGUID.ToCString(aGUIDStr);
+    aGUIDStr[Standard_GUID_SIZE] = '\0';
+    XmlObjMgt_DOMString anAttrGUID(aGUIDStr);
+    theTarget.Element().setAttribute(::AttrGUID(), anAttrGUID);
+  }
+  else if (aThis->IsSubshapeIndex())
+  {
+    TCollection_AsciiString aSubshapeIndexStr(aThis->GetSubshapeIndex());
+    XmlObjMgt_DOMString aSubshapeIndex(aSubshapeIndexStr.ToCString());
+    theTarget.Element().setAttribute(::SubshapeIndex(), aSubshapeIndex);
+  }
+
 }