]> OCCT Git - occt-copy.git/commitdiff
0030988: Add possibility to attach multiple files to notes
authorsnn <snn@opencascade.com>
Thu, 13 Jun 2019 11:39:29 +0000 (14:39 +0300)
committersnn <sergey.nikonov@opencascade.com>
Wed, 19 May 2021 14:30:36 +0000 (17:30 +0300)
- Implemented
- Swap child/father in RemoveFromGroup method of NotesTool.

(cherry picked from commit 7c0ec2e2146660677992d9cdee4e93276e362bf9)
(cherry picked from commit cfb3c08a2c40ab36dfa70ce8d333039e9b2859f8)

31 files changed:
src/BinMXCAFDoc/BinMXCAFDoc.cxx
src/BinMXCAFDoc/BinMXCAFDoc_NoteBinDataDriver.cxx [deleted file]
src/BinMXCAFDoc/BinMXCAFDoc_NoteBinDataDriver.hxx [deleted file]
src/BinMXCAFDoc/BinMXCAFDoc_NoteCommentDriver.cxx [deleted file]
src/BinMXCAFDoc/BinMXCAFDoc_NoteCommentDriver.hxx [deleted file]
src/BinMXCAFDoc/BinMXCAFDoc_NoteDriver.cxx
src/BinMXCAFDoc/BinMXCAFDoc_NoteDriver.hxx
src/BinMXCAFDoc/FILES
src/XCAFDoc/XCAFDoc_AssemblyItemId.cxx
src/XCAFDoc/XCAFDoc_AssemblyItemId.hxx
src/XCAFDoc/XCAFDoc_AssemblyItemRef.cxx
src/XCAFDoc/XCAFDoc_AssemblyItemRef.hxx
src/XCAFDoc/XCAFDoc_Note.cxx
src/XCAFDoc/XCAFDoc_Note.hxx
src/XCAFDoc/XCAFDoc_NoteBalloon.cxx
src/XCAFDoc/XCAFDoc_NoteBalloon.hxx
src/XCAFDoc/XCAFDoc_NoteBinData.cxx
src/XCAFDoc/XCAFDoc_NoteBinData.hxx
src/XCAFDoc/XCAFDoc_NoteComment.cxx
src/XCAFDoc/XCAFDoc_NoteComment.hxx
src/XCAFDoc/XCAFDoc_NotesTool.cxx
src/XCAFDoc/XCAFDoc_NotesTool.hxx
src/XDEDRAW/XDEDRAW_Notes.cxx
src/XmlMXCAFDoc/FILES
src/XmlMXCAFDoc/XmlMXCAFDoc.cxx
src/XmlMXCAFDoc/XmlMXCAFDoc_NoteBinDataDriver.cxx [deleted file]
src/XmlMXCAFDoc/XmlMXCAFDoc_NoteBinDataDriver.hxx [deleted file]
src/XmlMXCAFDoc/XmlMXCAFDoc_NoteCommentDriver.cxx [deleted file]
src/XmlMXCAFDoc/XmlMXCAFDoc_NoteCommentDriver.hxx [deleted file]
src/XmlMXCAFDoc/XmlMXCAFDoc_NoteDriver.cxx
src/XmlMXCAFDoc/XmlMXCAFDoc_NoteDriver.hxx

index b458ebe82dd4ebe5bd248e29fed381a696bbb7d3..c14bc0d63631b166f1db6c7270fed13ed34846b9 100644 (file)
@@ -26,8 +26,6 @@
 #include <BinMXCAFDoc_LocationDriver.hxx>
 #include <BinMXCAFDoc_MaterialDriver.hxx>
 #include <BinMXCAFDoc_NoteDriver.hxx>
-#include <BinMXCAFDoc_NoteBinDataDriver.hxx>
-#include <BinMXCAFDoc_NoteCommentDriver.hxx>
 #include <BinMXCAFDoc_VisMaterialDriver.hxx>
 #include <BinMXCAFDoc_VisMaterialToolDriver.hxx>
 #include <Message_Messenger.hxx>
@@ -62,7 +60,6 @@ void BinMXCAFDoc::AddDrivers(const Handle(BinMDF_ADriverTable)& theDriverTable,
   theDriverTable->AddDriver( new BinMXCAFDoc_DimTolDriver      (theMsgDrv));
   theDriverTable->AddDriver( new BinMXCAFDoc_MaterialDriver    (theMsgDrv));
   theDriverTable->AddDriver( new BinMXCAFDoc_VisMaterialDriver (theMsgDrv));
-  theDriverTable->AddDriver( new BinMXCAFDoc_NoteBinDataDriver (theMsgDrv));
-  theDriverTable->AddDriver( new BinMXCAFDoc_NoteCommentDriver (theMsgDrv));
+  theDriverTable->AddDriver( new BinMXCAFDoc_NoteDriver        (theMsgDrv)); 
   theDriverTable->AddDriver( new BinMXCAFDoc_VisMaterialToolDriver(theMsgDrv));
 }
diff --git a/src/BinMXCAFDoc/BinMXCAFDoc_NoteBinDataDriver.cxx b/src/BinMXCAFDoc/BinMXCAFDoc_NoteBinDataDriver.cxx
deleted file mode 100644 (file)
index c37709d..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-// Created on: 2017-02-13
-// Created by: Eugeny NIKONOV
-// Copyright (c) 2005-2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <BinObjMgt_Persistent.hxx>
-#include <Message_Messenger.hxx>
-#include <Standard_Type.hxx>
-#include <TDF_Attribute.hxx>
-#include <TColStd_HArray1OfByte.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <TCollection_ExtendedString.hxx>
-#include <BinMXCAFDoc_NoteBinDataDriver.hxx>
-#include <XCAFDoc_NoteBinData.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(BinMXCAFDoc_NoteBinDataDriver, BinMXCAFDoc_NoteDriver)
-
-//=======================================================================
-//function :
-//purpose  : 
-//=======================================================================
-BinMXCAFDoc_NoteBinDataDriver::BinMXCAFDoc_NoteBinDataDriver(const Handle(Message_Messenger)& theMsgDriver)
-  : BinMXCAFDoc_NoteDriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_NoteBinData)->Name())
-{
-}
-
-//=======================================================================
-//function :
-//purpose  : 
-//=======================================================================
-Handle(TDF_Attribute) BinMXCAFDoc_NoteBinDataDriver::NewEmpty() const
-{
-  return new XCAFDoc_NoteBinData();
-}
-
-//=======================================================================
-//function :
-//purpose  : 
-//=======================================================================
-Standard_Boolean BinMXCAFDoc_NoteBinDataDriver::Paste(const BinObjMgt_Persistent&  theSource,
-                                                      const Handle(TDF_Attribute)& theTarget,
-                                                      BinObjMgt_RRelocationTable&  theRelocTable) const
-{
-  if (!BinMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable))
-    return Standard_False;
-
-  Handle(XCAFDoc_NoteBinData) aNote = Handle(XCAFDoc_NoteBinData)::DownCast(theTarget);
-  if (aNote.IsNull())
-    return Standard_False;
-
-  TCollection_ExtendedString aTitle;
-  TCollection_AsciiString aMIMEtype;
-  Standard_Integer nbSize;
-  if (!(theSource >> aTitle >> aMIMEtype >> nbSize))
-    return Standard_False;
-
-  Handle(TColStd_HArray1OfByte) aData;
-  if (nbSize > 0)
-  {
-    aData.reset(new TColStd_HArray1OfByte(1, nbSize));
-    theSource.GetByteArray(&aData->ChangeFirst(), nbSize);
-  }
-
-  aNote->Set(aTitle, aMIMEtype, aData);
-
-  return Standard_True;
-}
-
-//=======================================================================
-//function :
-//purpose  : 
-//=======================================================================
-void BinMXCAFDoc_NoteBinDataDriver::Paste(const Handle(TDF_Attribute)& theSource,
-                                                       BinObjMgt_Persistent&        theTarget,
-                                                       BinObjMgt_SRelocationTable&  theRelocTable) const
-{
-  BinMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable);
-
-  Handle(XCAFDoc_NoteBinData) aNote = Handle(XCAFDoc_NoteBinData)::DownCast(theSource);
-  if (!aNote.IsNull())
-  {
-    theTarget << aNote->Title() << aNote->MIMEtype() << aNote->Size();
-    if (aNote->Size() > 0)
-      theTarget.PutByteArray(&aNote->Data()->ChangeFirst(), aNote->Size());
-  }
-}
diff --git a/src/BinMXCAFDoc/BinMXCAFDoc_NoteBinDataDriver.hxx b/src/BinMXCAFDoc/BinMXCAFDoc_NoteBinDataDriver.hxx
deleted file mode 100644 (file)
index 1ca25c4..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-// Created on: 2017-02-13
-// Created by: Sergey NIKONOV
-// Copyright (c) 2005-2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _BinMXCAFDoc_NoteBinDataDriver_HeaderFile
-#define _BinMXCAFDoc_NoteBinDataDriver_HeaderFile
-
-#include <BinMXCAFDoc_NoteDriver.hxx>
-
-class BinMXCAFDoc_NoteBinDataDriver;
-DEFINE_STANDARD_HANDLE(BinMXCAFDoc_NoteBinDataDriver, BinMXCAFDoc_NoteDriver)
-
-class BinMXCAFDoc_NoteBinDataDriver : public BinMXCAFDoc_NoteDriver
-{
-public:
-  
-  Standard_EXPORT BinMXCAFDoc_NoteBinDataDriver(const Handle(Message_Messenger)& theMsgDriver);
-  
-  Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
-  
-  Standard_EXPORT Standard_Boolean Paste (const BinObjMgt_Persistent&  theSource, 
-                                          const Handle(TDF_Attribute)& theTarget, 
-                                          BinObjMgt_RRelocationTable&  theRelocTable) const Standard_OVERRIDE;
-  
-  Standard_EXPORT void Paste (const Handle(TDF_Attribute)& theSource, 
-                              BinObjMgt_Persistent&        theTarget, 
-                              BinObjMgt_SRelocationTable&  theRelocTable) const Standard_OVERRIDE;
-
-  DEFINE_STANDARD_RTTIEXT(BinMXCAFDoc_NoteBinDataDriver, BinMXCAFDoc_NoteDriver)
-
-};
-
-#endif // _BinMXCAFDoc_NoteBinDataDriver_HeaderFile
diff --git a/src/BinMXCAFDoc/BinMXCAFDoc_NoteCommentDriver.cxx b/src/BinMXCAFDoc/BinMXCAFDoc_NoteCommentDriver.cxx
deleted file mode 100644 (file)
index 14e00cf..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-// Created on: 2017-02-13
-// Created by: Eugeny NIKONOV
-// Copyright (c) 2005-2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <BinObjMgt_Persistent.hxx>
-#include <Message_Messenger.hxx>
-#include <Standard_Type.hxx>
-#include <TDF_Attribute.hxx>
-#include <BinMXCAFDoc_NoteCommentDriver.hxx>
-#include <XCAFDoc_NoteComment.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(BinMXCAFDoc_NoteCommentDriver, BinMXCAFDoc_NoteDriver)
-
-//=======================================================================
-//function :
-//purpose  : 
-//=======================================================================
-BinMXCAFDoc_NoteCommentDriver::BinMXCAFDoc_NoteCommentDriver(const Handle(Message_Messenger)& theMsgDriver)
-  : BinMXCAFDoc_NoteDriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_NoteComment)->Name())
-{
-}
-
-//=======================================================================
-//function :
-//purpose  : 
-//=======================================================================
-Handle(TDF_Attribute) BinMXCAFDoc_NoteCommentDriver::NewEmpty() const
-{
-  return new XCAFDoc_NoteComment();
-}
-
-//=======================================================================
-//function :
-//purpose  : 
-//=======================================================================
-Standard_Boolean BinMXCAFDoc_NoteCommentDriver::Paste(const BinObjMgt_Persistent&  theSource,
-                                                      const Handle(TDF_Attribute)& theTarget,
-                                                      BinObjMgt_RRelocationTable&  theRelocTable) const
-{
-  if (!BinMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable))
-    return Standard_False;
-
-  Handle(XCAFDoc_NoteComment) aNote = Handle(XCAFDoc_NoteComment)::DownCast(theTarget);
-  if (aNote.IsNull())
-    return Standard_False;
-
-  TCollection_ExtendedString aComment;
-  if (!(theSource >> aComment))
-    return Standard_False;
-
-  aNote->Set(aComment);
-
-  return Standard_True;
-}
-
-//=======================================================================
-//function :
-//purpose  : 
-//=======================================================================
-void BinMXCAFDoc_NoteCommentDriver::Paste(const Handle(TDF_Attribute)& theSource,
-                                          BinObjMgt_Persistent&        theTarget,
-                                          BinObjMgt_SRelocationTable&  theRelocTable) const
-{
-  BinMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable);
-
-  Handle(XCAFDoc_NoteComment) aNote = Handle(XCAFDoc_NoteComment)::DownCast(theSource);
-  if (!aNote.IsNull())
-    theTarget << aNote->Comment();
-}
-
-//=======================================================================
-//function :
-//purpose  : 
-//=======================================================================
-BinMXCAFDoc_NoteCommentDriver::BinMXCAFDoc_NoteCommentDriver(const Handle(Message_Messenger)& theMsgDriver,
-                                                             Standard_CString                 theName)
-  : BinMXCAFDoc_NoteDriver(theMsgDriver, theName)
-{
-
-}
diff --git a/src/BinMXCAFDoc/BinMXCAFDoc_NoteCommentDriver.hxx b/src/BinMXCAFDoc/BinMXCAFDoc_NoteCommentDriver.hxx
deleted file mode 100644 (file)
index 8ae85f4..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-// Created on: 2017-02-13
-// Created by: Sergey NIKONOV
-// Copyright (c) 2005-2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _BinMXCAFDoc_NoteCommentDriver_HeaderFile
-#define _BinMXCAFDoc_NoteCommentDriver_HeaderFile
-
-#include <BinMXCAFDoc_NoteDriver.hxx>
-
-class BinMXCAFDoc_NoteCommentDriver;
-DEFINE_STANDARD_HANDLE(BinMXCAFDoc_NoteCommentDriver, BinMXCAFDoc_NoteDriver)
-
-class BinMXCAFDoc_NoteCommentDriver : public BinMXCAFDoc_NoteDriver
-{
-public:
-  
-  Standard_EXPORT BinMXCAFDoc_NoteCommentDriver(const Handle(Message_Messenger)& theMsgDriver);
-  
-  Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
-  
-  Standard_EXPORT Standard_Boolean Paste (const BinObjMgt_Persistent&  theSource, 
-                                          const Handle(TDF_Attribute)& theTarget, 
-                                          BinObjMgt_RRelocationTable&  theRelocTable) const Standard_OVERRIDE;
-  
-  Standard_EXPORT void Paste (const Handle(TDF_Attribute)& theSource, 
-                              BinObjMgt_Persistent&        theTarget, 
-                              BinObjMgt_SRelocationTable&  theRelocTable) const Standard_OVERRIDE;
-
-  DEFINE_STANDARD_RTTIEXT(BinMXCAFDoc_NoteCommentDriver, BinMXCAFDoc_NoteDriver)
-
-protected:
-
-  BinMXCAFDoc_NoteCommentDriver(const Handle(Message_Messenger)& theMsgDriver,
-                                Standard_CString                 theName);
-
-};
-
-#endif // _BinMXCAFDoc_NoteCommentDriver_HeaderFile
index 477f153fa747aea52b498b46d653574913fbcca4..813ab5f2cdcf0e77629ebf011b321cd4db77ce73 100644 (file)
 
 IMPLEMENT_STANDARD_RTTIEXT(BinMXCAFDoc_NoteDriver, BinMDF_ADriver)
 
+//=======================================================================
+//function :
+//purpose  : 
+//=======================================================================
+BinMXCAFDoc_NoteDriver::BinMXCAFDoc_NoteDriver(const Handle(Message_Messenger)& theMsgDriver)
+: BinMDF_ADriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_Note)->Name())
+{
+}
+
+//=======================================================================
+//function :
+//purpose  : 
+//=======================================================================
+Handle(TDF_Attribute) BinMXCAFDoc_NoteDriver::NewEmpty() const
+{
+  return new XCAFDoc_Note();
+}
+
 //=======================================================================
 //function :
 //purpose  : 
index 10be389d91bc50b872db5571593d4c1dbb190af3..689e73ec405ce5a7154578a8fcc901522bf5bfbc 100644 (file)
@@ -35,6 +35,10 @@ class BinMXCAFDoc_NoteDriver : public BinMDF_ADriver
 {
 public:
   
+  Standard_EXPORT BinMXCAFDoc_NoteDriver(const Handle(Message_Messenger)& theMsgDriver);
+
+  Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
+
   Standard_EXPORT Standard_Boolean Paste (const BinObjMgt_Persistent&  theSource, 
                                           const Handle(TDF_Attribute)& theTarget, 
                                           BinObjMgt_RRelocationTable&  theRelocTable) const Standard_OVERRIDE;
index 72d2a290f12a28548532a16f346a671988ecc76b..54517c3b59502bfedc67864d044d0304b373e7f0 100644 (file)
@@ -19,10 +19,6 @@ BinMXCAFDoc_MaterialDriver.cxx
 BinMXCAFDoc_MaterialDriver.hxx
 BinMXCAFDoc_NoteDriver.cxx
 BinMXCAFDoc_NoteDriver.hxx
-BinMXCAFDoc_NoteCommentDriver.cxx
-BinMXCAFDoc_NoteCommentDriver.hxx
-BinMXCAFDoc_NoteBinDataDriver.cxx
-BinMXCAFDoc_NoteBinDataDriver.hxx
 BinMXCAFDoc_VisMaterialDriver.cxx
 BinMXCAFDoc_VisMaterialDriver.hxx
 BinMXCAFDoc_VisMaterialToolDriver.cxx
index 2a727a161552fab2a198d86d8124ee27da339d09..97048a5040137a930cc3844118c037a657bd5cf6 100644 (file)
@@ -13,6 +13,7 @@
 // Alternatively, this file may be used under the terms of Open CASCADE
 // commercial license or contractual agreement.
 
+#include <TDF_Tool.hxx>
 #include <XCAFDoc_AssemblyItemId.hxx>
 
 #include <Standard_Dump.hxx>
@@ -125,6 +126,18 @@ XCAFDoc_AssemblyItemId::ToString() const
   return aStr;
 }
 
+TDF_Label 
+XCAFDoc_AssemblyItemId::GetLabel(const Handle(TDF_Data)& aDF) const
+{
+  TDF_Label aLabel;
+  if (!myPath.IsEmpty())
+  {
+    TCollection_AsciiString anEntry = myPath.Last();
+    TDF_Tool::Label(aDF, anEntry, aLabel, Standard_False);
+  }
+  return aLabel;
+}
+
 //=======================================================================
 //function : DumpJson
 //purpose  : 
index 2d30806f021d15e3adde8060ac87ffc1d7a7a3c4..181b33e22ba4359d970ad19b1817947f9c51ab6e 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <Standard_GUID.hxx>
 #include <TColStd_ListOfAsciiString.hxx>
+#include <TDF_Label.hxx>
 
 //! Unique item identifier in the hierarchical product structure.
 //! A full path to an assembly component in the "part-of" graph starting from 
@@ -80,6 +81,9 @@ public:
   //! Dumps the content of me into the stream
   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
 
+  //! Returns the last label in the path
+  Standard_EXPORT TDF_Label GetLabel(const Handle(TDF_Data)& aDF) const;
+
   struct Hasher
   {
 
index 73fb97f360dc1e788f37fd263a479168ed38848e..025672e4b7e657ac8523a8719c393dba2329e027 100644 (file)
@@ -178,6 +178,12 @@ XCAFDoc_AssemblyItemRef::GetItem() const
   return myItemId;
 }
 
+TDF_Label 
+XCAFDoc_AssemblyItemRef::GetItemLabel() const
+{
+  return !Label().IsNull() ? myItemId.GetLabel(Label().Data()) : TDF_Label();
+}
+
 Standard_GUID 
 XCAFDoc_AssemblyItemRef::GetGUID() const
 {
index 62586bf0b9eec32d3c73e2a3120a202618300676..0180d7768abd36d85bfd8e645a4cf327760f4516 100644 (file)
@@ -102,6 +102,9 @@ public:
 
   //! Returns the assembly item ID that the reference points to.
   Standard_EXPORT const XCAFDoc_AssemblyItemId& GetItem() const;
+
+  //! Returns the last label in the item's path
+  Standard_EXPORT TDF_Label GetItemLabel() const;
   
   //! @name Set reference data functions.
   //! @{
index 0a474df07ed38f87571603fefe02e94687e0c676..4ac5d5011bb8a3d1cd9ef5f1a61c0c812d0bb233 100644 (file)
 
 IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_Note, TDF_Attribute)
 
-enum ChildLab
-{
-  ChildLab_PntText = 1,
-  ChildLab_Plane,
-  ChildLab_Pnt,
-  ChildLab_Presentation
-};
-
 // =======================================================================
 // function : IsMine
 // purpose  :
@@ -44,7 +36,18 @@ enum ChildLab
 Standard_Boolean
 XCAFDoc_Note::IsMine(const TDF_Label& theLabel)
 {
-  return !Get(theLabel).IsNull();
+  return !theLabel.IsNull() && !Get(theLabel).IsNull();
+}
+
+// =======================================================================
+// function : GetID
+// purpose  :
+// =======================================================================
+const Standard_GUID&
+XCAFDoc_Note::GetID()
+{
+  static Standard_GUID s_ID("A379384E-8412-4e34-BC26-097D503E2622");
+  return s_ID;
 }
 
 // =======================================================================
@@ -63,11 +66,25 @@ Handle(XCAFDoc_Note)
 XCAFDoc_Note::Get(const TDF_Label& theLabel)
 {
   Handle(XCAFDoc_Note) aNote;
-  for (TDF_AttributeIterator anIt(theLabel); anIt.More(); anIt.Next())
+  theLabel.FindAttribute(XCAFDoc_Note::GetID(), aNote);
+  return aNote;
+}
+
+// =======================================================================
+// function : Set
+// purpose  :
+// =======================================================================
+Handle(XCAFDoc_Note) 
+XCAFDoc_Note::Set(const TDF_Label&                  theLabel,
+                  const TCollection_ExtendedString& theUserName,
+                  const TCollection_ExtendedString& theTimeStamp)
+{
+  Handle(XCAFDoc_Note) aNote;
+  if (!theLabel.IsNull() && !theLabel.FindAttribute(XCAFDoc_Note::GetID(), aNote))
   {
-    aNote = Handle(XCAFDoc_Note)::DownCast(anIt.Value());
-    if (!aNote.IsNull())
-      break;
+    aNote = new XCAFDoc_Note();
+    aNote->XCAFDoc_Note::Set(theUserName, theTimeStamp);
+    theLabel.AddAttribute(aNote);
   }
   return aNote;
 }
@@ -157,10 +174,11 @@ void XCAFDoc_Note::SetObject (const Handle(XCAFNoteObjects_NoteObject)& theObjec
 {
   Backup();
 
-  for (TDF_ChildIterator anIter(Label()); anIter.More(); anIter.Next())
-  {
-    anIter.Value().ForgetAllAttributes();
-  }
+  TDF_Label aChLabel;
+  aChLabel = Label().FindChild(ChildLab_PntText,      Standard_False); if (!aChLabel.IsNull()) aChLabel.ForgetAllAttributes();
+  aChLabel = Label().FindChild(ChildLab_Plane,        Standard_False); if (!aChLabel.IsNull()) aChLabel.ForgetAllAttributes();
+  aChLabel = Label().FindChild(ChildLab_Pnt,          Standard_False); if (!aChLabel.IsNull()) aChLabel.ForgetAllAttributes();
+  aChLabel = Label().FindChild(ChildLab_Presentation, Standard_False); if (!aChLabel.IsNull()) aChLabel.ForgetAllAttributes();
 
   if (theObject->HasPoint())
   {
@@ -191,6 +209,26 @@ void XCAFDoc_Note::SetObject (const Handle(XCAFNoteObjects_NoteObject)& theObjec
   }
 }
 
+// =======================================================================
+// function : ID
+// purpose  :
+// =======================================================================
+const Standard_GUID&
+XCAFDoc_Note::ID() const
+{
+  return GetID();
+}
+
+// =======================================================================
+// function : NewEmpty
+// purpose  :
+// =======================================================================
+Handle(TDF_Attribute)
+XCAFDoc_Note::NewEmpty() const
+{
+  return new XCAFDoc_Note();
+}
+
 // =======================================================================
 // function : Restore
 // purpose  :
index a48c99cf77bdbf4a89f609082055a2428c90976c..c190b0bc19a92780de133197725c913ccfc2ef4c 100644 (file)
@@ -37,9 +37,23 @@ public:
   //! Checks if the given label represents a note.
   Standard_EXPORT static Standard_Boolean IsMine(const TDF_Label& theLabel);
 
+  //! Returns default attribute GUID
+  Standard_EXPORT static const Standard_GUID& GetID();
+
   //! Finds a reference attribute on the given label and returns it, if it is found
   Standard_EXPORT static Handle(XCAFDoc_Note) Get(const TDF_Label& theLabel);
 
+  //! Create (if not exist) a note on the given label.
+  //! \param [in] theLabel     - note label.
+  //! \param [in] theUserName  - the name of the user, who created the note.
+  //! \param [in] theTimeStamp - creation timestamp of the note.
+  Standard_EXPORT static Handle(XCAFDoc_Note) Set(const TDF_Label&                  theLabel,
+                                                  const TCollection_ExtendedString& theUserName,
+                                                  const TCollection_ExtendedString& theTimeStamp);
+
+  //! Creates an empty note.
+  Standard_EXPORT XCAFDoc_Note();
+
   //! Sets the user name and the timestamp of the note.
   //! \param [in] theUserName  - the user associated with the note.
   //! \param [in] theTimeStamp - timestamp of the note.
@@ -62,9 +76,22 @@ public:
   //! Updates auxiliary data
   Standard_EXPORT void SetObject(const Handle(XCAFNoteObjects_NoteObject)& theObject);
 
+  //! 
+  enum ChildLab
+  {
+    ChildLab_PntText = 1,
+    ChildLab_Plane,
+    ChildLab_Pnt,
+    ChildLab_Presentation,
+    ChildLab_BinDataContainer,
+    ChildLab_Custom
+  };
+
 public:
 
   // Overrides TDF_Attribute virtuals
+  Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
+  Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
   Standard_EXPORT void Restore(const Handle(TDF_Attribute)& theAttrFrom) Standard_OVERRIDE;
   Standard_EXPORT void Paste(const Handle(TDF_Attribute)&       theAttrInto,
                              const Handle(TDF_RelocationTable)& theRT) const Standard_OVERRIDE;
@@ -73,11 +100,6 @@ public:
   //! Dumps the content of me into the stream
   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
 
-protected:
-
-  //! Creates an empty note.
-  Standard_EXPORT XCAFDoc_Note();
-
 private:
 
   TCollection_ExtendedString myUserName;  ///< Name of the user, who created the note.
index 4648f9883ccb7f404b46138b05a8decb74a82799..ec601e7552e9edd830316e0cb98b276c6055625d 100644 (file)
@@ -16,7 +16,7 @@
 #include <Standard_GUID.hxx>
 #include <TDF_Label.hxx>
 
-IMPLEMENT_DERIVED_ATTRIBUTE(XCAFDoc_NoteBalloon, XCAFDoc_NoteComment)
+IMPLEMENT_DERIVED_ATTRIBUTE(XCAFDoc_NoteBalloon, XCAFDoc_Note)
 
 // =======================================================================
 // function : GetID
@@ -56,7 +56,7 @@ XCAFDoc_NoteBalloon::Set(const TDF_Label&                  theLabel,
   {
     aNoteBalloon = new XCAFDoc_NoteBalloon();
     aNoteBalloon->XCAFDoc_Note::Set(theUserName, theTimeStamp);
-    aNoteBalloon->XCAFDoc_NoteComment::Set(theComment);
+    aNoteBalloon->Set(theComment);
     theLabel.AddAttribute(aNoteBalloon);
   }
   return aNoteBalloon;
@@ -70,6 +70,18 @@ XCAFDoc_NoteBalloon::XCAFDoc_NoteBalloon()
 {
 }
 
+// =======================================================================
+// function : Set
+// purpose  :
+// =======================================================================
+void
+XCAFDoc_NoteBalloon::Set(const TCollection_ExtendedString& theComment)
+{
+  Backup();
+
+  myComment = theComment;
+}
+
 // =======================================================================
 // function : ID
 // purpose  :
index eabd03111e88535f9fadffd5fc0740f099068794..28808ac5790d7f1e02cc82fee016a0ccafdb93e1 100644 (file)
 #ifndef _XCAFDoc_NoteBalloon_HeaderFile
 #define _XCAFDoc_NoteBalloon_HeaderFile
 
-#include <XCAFDoc_NoteComment.hxx>
+#include <XCAFDoc_Note.hxx>
 
 //! A comment note attribute.
 //! Contains a textual comment.
-class XCAFDoc_NoteBalloon : public XCAFDoc_NoteComment
+class XCAFDoc_NoteBalloon : public XCAFDoc_Note
 {
 public:
 
-  DEFINE_DERIVED_ATTRIBUTE(XCAFDoc_NoteBalloon, XCAFDoc_NoteComment)
+  DEFINE_DERIVED_ATTRIBUTE(XCAFDoc_NoteBalloon, XCAFDoc_Note)
 
   //! Returns default attribute GUID
   Standard_EXPORT static const Standard_GUID& GetID();
@@ -43,10 +43,20 @@ public:
   //! Creates an empty comment note.
   Standard_EXPORT XCAFDoc_NoteBalloon();
 
+  //! Sets the comment text.
+  Standard_EXPORT void Set(const TCollection_ExtendedString& theComment);
+
+  //! Returns the comment text.
+  const TCollection_ExtendedString& Get() const { return myComment; }
+
 public:
 
   // Overrides TDF_Attribute virtuals
   Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
+private:
+
+  TCollection_ExtendedString myComment;
+
 };
 
 DEFINE_STANDARD_HANDLE(XCAFDoc_NoteBalloon, XCAFDoc_NoteComment)
index bbb92e3e81ce6d201f555bc5bb6c313ad85ba553..474f4012de61e50d75a603f2fd00d700d93d2e0b 100644 (file)
 #include <XCAFDoc_NoteBinData.hxx>
 
 #include <OSD_File.hxx>
-#include <Standard_GUID.hxx>
+#include <TDataStd_AsciiString.hxx>
+#include <TDataStd_ByteArray.hxx>
+#include <TDataStd_Name.hxx>
+#include <TDataStd_ReferenceList.hxx>
+#include <TDF_ChildIterator.hxx>
 #include <TDF_Label.hxx>
+#include <XCAFDoc_Note.hxx>
 
-IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_NoteBinData, XCAFDoc_Note)
+IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_NoteBinDataContainer, Standard_Transient)
+IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_NoteBinData, Standard_Transient)
 
 // =======================================================================
-// function : GetID
+// function : getID
 // purpose  :
 // =======================================================================
-const Standard_GUID&
-XCAFDoc_NoteBinData::GetID()
+const Standard_GUID& 
+XCAFDoc_NoteBinDataContainer::getID()
 {
-  static Standard_GUID s_ID("E9055501-F0FC-4864-BE4B-284FDA7DDEAC");
+  static Standard_GUID s_ID("91CFB5D9-737C-4ab9-933A-15E28DBBD1CF");
   return s_ID;
 }
 
+// =======================================================================
+// function : XCAFDoc_NoteBinDataContainer
+// purpose  :
+// =======================================================================
+XCAFDoc_NoteBinDataContainer::XCAFDoc_NoteBinDataContainer(const Handle(TDataStd_ReferenceList)& theList)
+  : myList(theList)
+{
+
+}
+
+// =======================================================================
+// function : Get
+// purpose  :
+// =======================================================================
+Handle(XCAFDoc_NoteBinDataContainer)
+XCAFDoc_NoteBinDataContainer::Get(const TDF_Label& theLabel)
+{
+  if (!XCAFDoc_Note::IsMine(theLabel))
+  {
+    return NULL;
+  }
+
+  TDF_Label aLabel = theLabel.FindChild(XCAFDoc_Note::ChildLab_BinDataContainer, Standard_False);
+  Handle(TDataStd_ReferenceList) aList;
+  if (!aLabel.IsNull() && aLabel.FindAttribute(getID(), aList) && !aList.IsNull())
+  {
+    return new XCAFDoc_NoteBinDataContainer(aList);
+  }
+
+  return NULL;
+}
+
+// =======================================================================
+// function : Set
+// purpose  :
+// =======================================================================
+Handle(XCAFDoc_NoteBinDataContainer)
+XCAFDoc_NoteBinDataContainer::Set(const TDF_Label& theLabel)
+{
+  if (!XCAFDoc_Note::IsMine(theLabel))
+  {
+    return NULL;
+  }
+
+  TDF_Label aLabel = theLabel.FindChild(XCAFDoc_Note::ChildLab_BinDataContainer);
+  return new XCAFDoc_NoteBinDataContainer(TDataStd_ReferenceList::Set(aLabel, getID()));
+}
+
+// =======================================================================
+// function : Size
+// purpose  :
+// =======================================================================
+Standard_Integer
+XCAFDoc_NoteBinDataContainer::Size() const
+{
+  return myList->List().Size();
+}
+
+// =======================================================================
+// function : Content
+// purpose  :
+// =======================================================================
+const TDF_LabelList&
+XCAFDoc_NoteBinDataContainer::Content() const
+{
+  return myList->List();
+}
+
+// =======================================================================
+// function : Add
+// purpose  :
+// =======================================================================
+Handle(XCAFDoc_NoteBinData)
+XCAFDoc_NoteBinDataContainer::Add(const TCollection_ExtendedString& theTitle,
+                                  const TCollection_AsciiString&    theMIMEtype,
+                                  OSD_File&                         theFile)
+{
+  TDF_Label aLabel;
+  for (TDF_ChildIterator anIt(myList->Label()); anIt.More(); anIt.Next())
+  {
+    if (!anIt.Value().HasAttribute())
+    {
+      aLabel = anIt.Value();
+      break;
+    }
+  }
+  if (aLabel.IsNull())
+  {
+    aLabel = myList->Label().NewChild();
+  }
+  myList->Append(aLabel);
+  return XCAFDoc_NoteBinData::Set(aLabel, theTitle, theMIMEtype, theFile);
+}
+
+// =======================================================================
+// function : Add
+// purpose  :
+// =======================================================================
+Handle(XCAFDoc_NoteBinData)
+XCAFDoc_NoteBinDataContainer::Add(const TCollection_ExtendedString&    theTitle,
+                                  const TCollection_AsciiString&       theMIMEtype,
+                                  const Handle(TColStd_HArray1OfByte)& theData)
+{
+  TDF_Label aLabel;
+  for (TDF_ChildIterator anIt(myList->Label()); anIt.More(); anIt.Next())
+  {
+    if (!anIt.Value().HasAttribute())
+    {
+      aLabel = anIt.Value();
+      break;
+    }
+  }
+  if (aLabel.IsNull())
+  {
+    aLabel = myList->Label().NewChild();
+  }
+  myList->Append(aLabel);
+  return XCAFDoc_NoteBinData::Set(aLabel, theTitle, theMIMEtype, theData);
+}
+
+// =======================================================================
+// function : Remove
+// purpose  :
+// =======================================================================
+Standard_Boolean
+XCAFDoc_NoteBinDataContainer::Remove(TDF_Label& theLabel)
+{
+  theLabel.ForgetAllAttributes();
+  return myList->Remove(theLabel);
+}
+
+// =======================================================================
+// function : Clear
+// purpose  :
+// =======================================================================
+void
+XCAFDoc_NoteBinDataContainer::Clear()
+{
+  const TDF_LabelList& aList = myList->List();
+  for (TDF_LabelList::Iterator anIt(aList); anIt.More(); anIt.Next())
+  {
+    anIt.ChangeValue().ForgetAllAttributes();
+  }
+  myList->Clear();
+}
+
+// =======================================================================
+// function : Label
+// purpose  :
+// =======================================================================
+TDF_Label
+XCAFDoc_NoteBinDataContainer::Label() const
+{
+  return !myList.IsNull() ? myList->Label() : TDF_Label();
+}
+
 // =======================================================================
 // function : Get
 // purpose  :
@@ -37,9 +199,19 @@ XCAFDoc_NoteBinData::GetID()
 Handle(XCAFDoc_NoteBinData)
 XCAFDoc_NoteBinData::Get(const TDF_Label& theLabel)
 {
-  Handle(XCAFDoc_NoteBinData) aThis;
-  theLabel.FindAttribute(XCAFDoc_NoteBinData::GetID(), aThis);
-  return aThis;
+  if (theLabel.IsNull() || theLabel.Father().IsNull() || theLabel.Father().Father().IsNull() ||
+      !XCAFDoc_Note::IsMine(theLabel.Father().Father()))
+    return NULL;
+
+  Handle(TDataStd_Name) aTitle;
+  Handle(TDataStd_AsciiString) aMIMEType;
+  Handle(TDataStd_ByteArray) aData;
+  if (!theLabel.FindAttribute(TDataStd_Name::GetID(), aTitle) ||
+      !theLabel.FindAttribute(TDataStd_AsciiString::GetID(), aMIMEType) || 
+      !theLabel.FindAttribute(TDataStd_ByteArray::GetID(), aData))
+    return NULL;
+
+  return new XCAFDoc_NoteBinData(aTitle, aMIMEType, aData);
 }
 
 // =======================================================================
@@ -48,23 +220,29 @@ XCAFDoc_NoteBinData::Get(const TDF_Label& theLabel)
 // =======================================================================
 Handle(XCAFDoc_NoteBinData)
 XCAFDoc_NoteBinData::Set(const TDF_Label&                  theLabel,
-                         const TCollection_ExtendedString& theUserName,
-                         const TCollection_ExtendedString& theTimeStamp,
                          const TCollection_ExtendedString& theTitle,
                          const TCollection_AsciiString&    theMIMEtype,
                          OSD_File&                         theFile)
 {
-  Handle(XCAFDoc_NoteBinData) aNoteBinData;
-  if (!theLabel.IsNull() && !theLabel.FindAttribute(XCAFDoc_NoteBinData::GetID(), aNoteBinData))
+  if (theLabel.IsNull() || theLabel.Father().IsNull() || theLabel.Father().Father().IsNull() ||
+      !XCAFDoc_Note::IsMine(theLabel.Father().Father()))
+    return NULL;
+
+  if (!theFile.IsOpen() || !theFile.IsReadable() || theFile.Size() > (Standard_Size)IntegerLast())
+    return NULL;
+
+  Handle(TDataStd_ByteArray) aData = TDataStd_ByteArray::Set(theLabel, 1, (Standard_Integer)theFile.Size());
+  Standard_Integer nbReadBytes = 0;
+  theFile.Read((Standard_Address)&aData->InternalArray()->First(), aData->Length(), nbReadBytes);
+  if (nbReadBytes < aData->Length())
   {
-    aNoteBinData = new XCAFDoc_NoteBinData();
-    aNoteBinData->XCAFDoc_Note::Set(theUserName, theTimeStamp);
-    if (aNoteBinData->Set(theTitle, theMIMEtype, theFile))
-      theLabel.AddAttribute(aNoteBinData);
-    else
-      aNoteBinData.Nullify();
+    theLabel.ForgetAttribute(aData);
+    return NULL;
   }
-  return aNoteBinData;
+
+  return new XCAFDoc_NoteBinData(TDataStd_Name::Set(theLabel, theTitle),
+                                 TDataStd_AsciiString::Set(theLabel, theMIMEtype),
+                                 aData);
 }
 
 // =======================================================================
@@ -73,28 +251,31 @@ XCAFDoc_NoteBinData::Set(const TDF_Label&                  theLabel,
 // =======================================================================
 Handle(XCAFDoc_NoteBinData)
 XCAFDoc_NoteBinData::Set(const TDF_Label&                     theLabel,
-                         const TCollection_ExtendedString&    theUserName,
-                         const TCollection_ExtendedString&    theTimeStamp,
                          const TCollection_ExtendedString&    theTitle,
                          const TCollection_AsciiString&       theMIMEtype,
                          const Handle(TColStd_HArray1OfByte)& theData)
 {
-  Handle(XCAFDoc_NoteBinData) aNoteBinData;
-  if (!theLabel.IsNull() && !theLabel.FindAttribute(XCAFDoc_NoteBinData::GetID(), aNoteBinData))
-  {
-    aNoteBinData = new XCAFDoc_NoteBinData();
-    aNoteBinData->XCAFDoc_Note::Set(theUserName, theTimeStamp);
-    aNoteBinData->Set(theTitle, theMIMEtype, theData);
-    theLabel.AddAttribute(aNoteBinData);
-  }
-  return aNoteBinData;
+  if (theLabel.IsNull() || theLabel.Father().IsNull() || theLabel.Father().Father().IsNull() ||
+      !XCAFDoc_Note::IsMine(theLabel.Father().Father()))
+    return NULL;
+
+  Handle(TDataStd_ByteArray) aData = TDataStd_ByteArray::Set(theLabel, 1, 2);
+  aData->ChangeArray(theData);
+  return new XCAFDoc_NoteBinData(TDataStd_Name::Set(theLabel, theTitle),
+                                 TDataStd_AsciiString::Set(theLabel, theMIMEtype),
+                                 aData);
 }
 
 // =======================================================================
 // function : XCAFDoc_NoteBinData
 // purpose  :
 // =======================================================================
-XCAFDoc_NoteBinData::XCAFDoc_NoteBinData()
+XCAFDoc_NoteBinData::XCAFDoc_NoteBinData(const Handle(TDataStd_Name)& theTitle,
+                                         const Handle(TDataStd_AsciiString)& theMIMEType,
+                                         const Handle(TDataStd_ByteArray)& theData)
+  : myTitle(theTitle)
+  , myMIMEtype(theMIMEType)
+  , myData(theData)
 {
 }
 
@@ -107,22 +288,18 @@ XCAFDoc_NoteBinData::Set(const TCollection_ExtendedString& theTitle,
                          const TCollection_AsciiString&    theMIMEtype,
                          OSD_File&                         theFile)
 {
-  if (!theFile.IsOpen() || !theFile.IsReadable())
-    return Standard_False;
-
-  Backup();
-
-  if (theFile.Size() > (Standard_Size)IntegerLast())
+  if (!theFile.IsOpen() || !theFile.IsReadable() || theFile.Size() > (Standard_Size)IntegerLast())
     return Standard_False;
 
-  myData.reset(new TColStd_HArray1OfByte(1, (Standard_Integer)theFile.Size()));
+  Handle(TColStd_HArray1OfByte) aData(new TColStd_HArray1OfByte(1, (Standard_Integer)theFile.Size()));
   Standard_Integer nbReadBytes = 0;
-  theFile.Read((Standard_Address)&myData->First(), myData->Length(), nbReadBytes);
-  if (nbReadBytes < myData->Length())
+  theFile.Read((Standard_Address)&aData->First(), aData->Length(), nbReadBytes);
+  if (nbReadBytes < aData->Length())
     return Standard_False;
 
-  myTitle = theTitle;
-  myMIMEtype = theMIMEtype;
+  myData->ChangeArray(aData);
+  myTitle->Set(theTitle);
+  myMIMEtype->Set(theMIMEtype);
 
   return Standard_True;
 }
@@ -136,83 +313,57 @@ XCAFDoc_NoteBinData::Set(const TCollection_ExtendedString&    theTitle,
                          const TCollection_AsciiString&       theMIMEtype,
                          const Handle(TColStd_HArray1OfByte)& theData)
 {
-  Backup();
-
-  myData = theData;
-  myTitle = theTitle;
-  myMIMEtype = theMIMEtype;
+  myTitle->Set(theTitle);
+  myMIMEtype->Set(theMIMEtype);
+  myData->ChangeArray(theData);
 }
 
 // =======================================================================
-// function : ID
+// function : Title
 // purpose  :
 // =======================================================================
-const
-Standard_GUID& XCAFDoc_NoteBinData::ID() const
+const TCollection_ExtendedString&
+XCAFDoc_NoteBinData::Title() const
 {
-  return GetID();
+  return myTitle->Get();
 }
 
 // =======================================================================
-// function : NewEmpty
+// function : MIMEtype
 // purpose  :
 // =======================================================================
-Handle(TDF_Attribute)
-XCAFDoc_NoteBinData::NewEmpty() const
+const TCollection_AsciiString&
+XCAFDoc_NoteBinData::MIMEtype() const
 {
-  return new XCAFDoc_NoteBinData();
+  return myMIMEtype->Get();
 }
 
 // =======================================================================
-// function : Restore
+// function : Size
 // purpose  :
 // =======================================================================
-void
-XCAFDoc_NoteBinData::Restore(const Handle(TDF_Attribute)& theAttr)
+Standard_Integer
+XCAFDoc_NoteBinData::Size() const
 {
-  XCAFDoc_Note::Restore(theAttr);
-
-  Handle(XCAFDoc_NoteBinData) aMine = Handle(XCAFDoc_NoteBinData)::DownCast(theAttr);
-  if (!aMine.IsNull())
-  {
-    myTitle = aMine->myTitle;
-    myMIMEtype = aMine->myMIMEtype;
-    myData = aMine->myData;
-  }
+  return myData->Length();
 }
 
 // =======================================================================
-// function : Paste
+// function : Data
 // purpose  :
 // =======================================================================
-void
-XCAFDoc_NoteBinData::Paste(const Handle(TDF_Attribute)&       theAttrInto,
-                           const Handle(TDF_RelocationTable)& theRT) const
+const Handle(TColStd_HArray1OfByte)&
+XCAFDoc_NoteBinData::Data() const
 {
-  XCAFDoc_Note::Paste(theAttrInto, theRT);
-
-  Handle(XCAFDoc_NoteBinData) aMine = Handle(XCAFDoc_NoteBinData)::DownCast(theAttrInto);
-  if (!aMine.IsNull())
-    aMine->Set(myTitle, myMIMEtype, myData);
+  return myData->InternalArray();
 }
 
 // =======================================================================
-// function : Dump
+// function : Label
 // purpose  :
 // =======================================================================
-Standard_OStream&
-XCAFDoc_NoteBinData::Dump(Standard_OStream& theOS) const
+TDF_Label
+XCAFDoc_NoteBinData::Label() const
 {
-  XCAFDoc_Note::Dump(theOS);
-  theOS << "\n"
-    << "Title : " << (!myTitle.IsEmpty() ? myMIMEtype : "<untitled>") << "\n"
-    << "MIME type : " << (!myMIMEtype.IsEmpty() ? myMIMEtype : "<none>") << "\n"
-    << "Size : " << Size() << " bytes" << "\n"
-    ;
-  if (!myData.IsNull())
-  {
-    for (Standard_Integer i = myData->Lower(); i <= myData->Upper(); ++i)
-      theOS << myData->Value(i);
-  }
-  return theOS;
+  return !myData.IsNull() ? myData->Label() : TDF_Label();
 }
index 1ae51c522cdd7bee1f134fc77b1b0cce3526c4a1..ba33f8aa9378c4364b2f57fb4bb59e7ec466f9c6 100644 (file)
 #ifndef _XCAFDoc_NoteBinData_HeaderFile
 #define _XCAFDoc_NoteBinData_HeaderFile
 
-#include <XCAFDoc_Note.hxx>
-#include <TColStd_HArray1OfByte.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <TCollection_ExtendedString.hxx>
+#include <Standard_Handle.hxx>
+#include <Standard_Transient.hxx>
+#include <TDF_Label.hxx>
+#include <TDF_LabelList.hxx>
 
 class OSD_File;
-
-class XCAFDoc_NoteBinData : public XCAFDoc_Note
+class Standard_GUID;
+class TColStd_HArray1OfByte;
+class TDataStd_AsciiString;
+class TDataStd_ByteArray; 
+class TDataStd_Name;
+class TDataStd_ReferenceList;
+class XCAFDoc_NoteBinData;
+
+class XCAFDoc_NoteBinDataContainer : public Standard_Transient
 {
 public:
 
-  DEFINE_STANDARD_RTTIEXT(XCAFDoc_NoteBinData, XCAFDoc_Note)
+  DEFINE_STANDARD_RTTIEXT(XCAFDoc_NoteBinDataContainer, Standard_Transient)
 
-  //! Returns default attribute GUID
-  Standard_EXPORT static const Standard_GUID& GetID();
+  //! Finds a reference attribute on the given label and returns a proxy instance if it is found
+  Standard_EXPORT static Handle(XCAFDoc_NoteBinDataContainer) Get(const TDF_Label& theLabel);
 
-  //! Finds a binary data attribute on the given label and returns it, if it is found
-  Standard_EXPORT static Handle(XCAFDoc_NoteBinData) Get(const TDF_Label& theLabel);
+  //! Create (if not exist) a binary data container on the given note label.
+  //! \param [in] theLabel   - note label.
+  Standard_EXPORT static Handle(XCAFDoc_NoteBinDataContainer) Set(const TDF_Label& theLabel);
 
-  //! @name Set attribute functions.
-  //! @{
+  Standard_EXPORT Standard_Integer Size() const;
+  Standard_EXPORT const TDF_LabelList& Content() const;
 
-  //! Create (if not exist) a binary note with data loaded from a binary file.
-  //! \param [in] theLabel     - label to add the attribute.
-  //! \param [in] theUserName  - the name of the user, who created the note.
-  //! \param [in] theTimeStamp - creation timestamp of the note.
-  //! \param [in] theTitle     - file title.
-  //! \param [in] theMIMEtype  - MIME type of the file.
-  //! \param [in] theFile      - input binary file.
-  //! \return A handle to the attribute instance.
-  Standard_EXPORT static Handle(XCAFDoc_NoteBinData) Set(const TDF_Label&                  theLabel,
-                                                         const TCollection_ExtendedString& theUserName,
-                                                         const TCollection_ExtendedString& theTimeStamp,
-                                                         const TCollection_ExtendedString& theTitle,
-                                                         const TCollection_AsciiString&    theMIMEtype,
-                                                         OSD_File&                         theFile);
-
-  //! Create (if not exist) a binary note byte data array.
-  //! \param [in] theLabel     - label to add the attribute.
-  //! \param [in] theUserName  - the name of the user, who created the note.
-  //! \param [in] theTimeStamp - creation timestamp of the note.
-  //! \param [in] theTitle     - data title.
-  //! \param [in] theMIMEtype  - MIME type of data.
-  //! \param [in] theData      - byte data array.
-  //! \return A handle to the attribute instance.
-  Standard_EXPORT static Handle(XCAFDoc_NoteBinData) Set(const TDF_Label&                     theLabel,
-                                                         const TCollection_ExtendedString&    theUserName,
-                                                         const TCollection_ExtendedString&    theTimeStamp,
-                                                         const TCollection_ExtendedString&    theTitle,
-                                                         const TCollection_AsciiString&       theMIMEtype,
-                                                         const Handle(TColStd_HArray1OfByte)& theData);
+  Standard_EXPORT Handle(XCAFDoc_NoteBinData) Add(const TCollection_ExtendedString& theTitle,
+                                                  const TCollection_AsciiString&    theMIMEtype,
+                                                  OSD_File&                         theFile);
 
-  //! @}
+  Standard_EXPORT Handle(XCAFDoc_NoteBinData) Add(const TCollection_ExtendedString&    theTitle,
+                                                  const TCollection_AsciiString&       theMIMEtype,
+                                                  const Handle(TColStd_HArray1OfByte)& theData);
+
+  Standard_EXPORT Standard_Boolean Remove(TDF_Label& theLabel);
+
+  Standard_EXPORT void Clear();
+
+  Standard_EXPORT TDF_Label Label() const;
+
+private:
+
+  XCAFDoc_NoteBinDataContainer(const Handle(TDataStd_ReferenceList)& theList);
+
+  static const Standard_GUID& getID();
+
+  Handle(TDataStd_ReferenceList) myList;
+};
 
-  //! Creates an empty binary data note.
-  Standard_EXPORT XCAFDoc_NoteBinData();
+DEFINE_STANDARD_HANDLE(XCAFDoc_NoteBinDataContainer, Standard_Transient)
+
+class XCAFDoc_NoteBinData : public Standard_Transient
+{
+  friend class XCAFDoc_NoteBinDataContainer;
+
+public:
+
+  DEFINE_STANDARD_RTTIEXT(XCAFDoc_NoteBinData, Standard_Transient)
+
+  //! Finds a binary data attribute on the given label and returns it, if it is found
+  Standard_EXPORT static Handle(XCAFDoc_NoteBinData) Get(const TDF_Label& theLabel);
 
   //! @name Set attribute data functions.
   //! @{
 
   //! Sets title, MIME type and data from a binary file.
-  //! \param [in] theTitle     - file title.
-  //! \param [in] theMIMEtype  - MIME type of the file.
-  //! \param [in] theFile      - input binary file.
+  //! \param [in] theTitle    - file title.
+  //! \param [in] theMIMEtype - MIME type of the file.
+  //! \param [in] theFile     - input binary file.
   Standard_EXPORT Standard_Boolean Set(const TCollection_ExtendedString& theTitle,
                                        const TCollection_AsciiString&    theMIMEtype,
                                        OSD_File&                         theFile);
 
   //! Sets title, MIME type and data from a byte array.
-  //! \param [in] theTitle     - data title.
-  //! \param [in] theMIMEtype  - MIME type of data.
-  //! \param [in] theData      - byte data array.
+  //! \param [in] theTitle    - data title.
+  //! \param [in] theMIMEtype - MIME type of data.
+  //! \param [in] theData     - byte data array.
   Standard_EXPORT void Set(const TCollection_ExtendedString&    theTitle,
                            const TCollection_AsciiString&       theMIMEtype,
                            const Handle(TColStd_HArray1OfByte)& theData);
@@ -93,35 +102,44 @@ public:
   //! @}
 
   //! Returns the note title.
-  const TCollection_ExtendedString& Title() const { return myTitle; }
+  Standard_EXPORT const TCollection_ExtendedString& Title() const;
 
   //! Returns data MIME type.
-  const TCollection_AsciiString& MIMEtype() const { return myMIMEtype;  }
+  Standard_EXPORT const TCollection_AsciiString& MIMEtype() const;
 
   //! Size of data in bytes.
-  Standard_Integer Size() const { return (!myData.IsNull() ? myData->Length() : 0); }
+  Standard_EXPORT Standard_Integer Size() const;
 
   //! Returns byte data array.
-  const Handle(TColStd_HArray1OfByte)& Data() const { return myData; }
+  Standard_EXPORT const Handle(TColStd_HArray1OfByte)& Data() const;
 
-public:
+  //! Returns label
+  Standard_EXPORT TDF_Label Label() const;
+
+private:
+
+  XCAFDoc_NoteBinData(const Handle(TDataStd_Name)& theTitle,
+                      const Handle(TDataStd_AsciiString)& theMIMEType,
+                      const Handle(TDataStd_ByteArray)& theData);
+
+  static Handle(XCAFDoc_NoteBinData) Set(const TDF_Label&                  theLabel,
+                                         const TCollection_ExtendedString& theTitle,
+                                         const TCollection_AsciiString&    theMIMEtype,
+                                         OSD_File&                         theFile);
 
-  // Overrides TDF_Attribute virtuals
-  Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
-  Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
-  Standard_EXPORT void Restore(const Handle(TDF_Attribute)& theAttrFrom) Standard_OVERRIDE;
-  Standard_EXPORT void Paste(const Handle(TDF_Attribute)&       theAttrInto,
-                             const Handle(TDF_RelocationTable)& theRT) const Standard_OVERRIDE;
-  Standard_EXPORT Standard_OStream& Dump(Standard_OStream& theOS) const Standard_OVERRIDE;
+  static Handle(XCAFDoc_NoteBinData) Set(const TDF_Label&                     theLabel,
+                                         const TCollection_ExtendedString&    theTitle,
+                                         const TCollection_AsciiString&       theMIMEtype,
+                                         const Handle(TColStd_HArray1OfByte)& theData);
 
-protected:
+private:
 
-  TCollection_ExtendedString    myTitle;    ///< Note title.
-  TCollection_AsciiString       myMIMEtype; ///< MIME type of data.
-  Handle(TColStd_HArray1OfByte) myData;     ///< Byte data array.
+  Handle(TDataStd_Name)        myTitle;    ///< Data title.
+  Handle(TDataStd_AsciiString) myMIMEtype; ///< MIME type of data.
+  Handle(TDataStd_ByteArray)   myData;     ///< Byte data array.
 
 };
 
-DEFINE_STANDARD_HANDLE(XCAFDoc_NoteBinData, XCAFDoc_Note)
+DEFINE_STANDARD_HANDLE(XCAFDoc_NoteBinData, Standard_Transient)
 
 #endif // _XCAFDoc_NoteBinData_HeaderFile
index 7d93f70d838b13daf47755f50c581b37be536b8c..bb1ed7b3f2182a63b622adcd9c109cfd20b30905 100644 (file)
 #include <XCAFDoc_NoteComment.hxx>
 
 #include <Standard_GUID.hxx>
-#include <TDF_Label.hxx>
+#include <TDataStd_Comment.hxx>
+#include <XCAFDoc_Note.hxx>
 
-IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_NoteComment, XCAFDoc_Note)
-
-// =======================================================================
-// function : GetID
-// purpose  :
-// =======================================================================
-const Standard_GUID&
-XCAFDoc_NoteComment::GetID()
-{
-  static Standard_GUID s_ID("FDEA4C52-0F54-484c-B590-579E18F7B5D4");
-  return s_ID;
-}
+IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_NoteComment, Standard_Transient)
 
 // =======================================================================
 // function : Get
@@ -36,9 +26,14 @@ XCAFDoc_NoteComment::GetID()
 Handle(XCAFDoc_NoteComment)
 XCAFDoc_NoteComment::Get(const TDF_Label& theLabel)
 {
-  Handle(XCAFDoc_NoteComment) aThis;
-  theLabel.FindAttribute(XCAFDoc_NoteComment::GetID(), aThis);
-  return aThis;
+  if (!XCAFDoc_Note::IsMine(theLabel))
+    return NULL;
+
+  Handle(TDataStd_Comment) aComment;
+  if (!theLabel.FindAttribute(TDataStd_Comment::GetID(), aComment))
+    return NULL;
+
+  return new XCAFDoc_NoteComment(aComment);
 }
 
 // =======================================================================
@@ -47,26 +42,20 @@ XCAFDoc_NoteComment::Get(const TDF_Label& theLabel)
 // =======================================================================
 Handle(XCAFDoc_NoteComment)
 XCAFDoc_NoteComment::Set(const TDF_Label&                  theLabel,
-                         const TCollection_ExtendedString& theUserName,
-                         const TCollection_ExtendedString& theTimeStamp,
                          const TCollection_ExtendedString& theComment)
 {
-  Handle(XCAFDoc_NoteComment) aNoteComment;
-  if (!theLabel.IsNull() && !theLabel.FindAttribute(XCAFDoc_NoteComment::GetID(), aNoteComment))
-  {
-    aNoteComment = new XCAFDoc_NoteComment();
-    aNoteComment->XCAFDoc_Note::Set(theUserName, theTimeStamp);
-    aNoteComment->Set(theComment);
-    theLabel.AddAttribute(aNoteComment);
-  }
-  return aNoteComment;
+  return XCAFDoc_Note::IsMine(theLabel) 
+    ? new XCAFDoc_NoteComment(TDataStd_Comment::Set(theLabel, theComment))
+    : NULL
+    ;
 }
 
 // =======================================================================
 // function : XCAFDoc_NoteComment
 // purpose  :
 // =======================================================================
-XCAFDoc_NoteComment::XCAFDoc_NoteComment()
+XCAFDoc_NoteComment::XCAFDoc_NoteComment(const Handle(TDataStd_Comment)& theComment)
+  : myComment(theComment)
 {
 }
 
@@ -77,70 +66,26 @@ XCAFDoc_NoteComment::XCAFDoc_NoteComment()
 void
 XCAFDoc_NoteComment::Set(const TCollection_ExtendedString& theComment)
 {
-  Backup();
-
-  myComment = theComment;
-}
-
-// =======================================================================
-// function : ID
-// purpose  :
-// =======================================================================
-const Standard_GUID&
-XCAFDoc_NoteComment::ID() const
-{
-  return GetID();
-}
-
-// =======================================================================
-// function : NewEmpty
-// purpose  :
-// =======================================================================
-Handle(TDF_Attribute)
-XCAFDoc_NoteComment::NewEmpty() const
-{
-  return new XCAFDoc_NoteComment();
+  if (!myComment.IsNull())
+    myComment->Set(theComment);
 }
 
 // =======================================================================
-// function : Restore
-// purpose  :
-// =======================================================================
-void
-XCAFDoc_NoteComment::Restore(const Handle(TDF_Attribute)& theAttr)
-{
-  XCAFDoc_Note::Restore(theAttr);
-
-  Handle(XCAFDoc_NoteComment) aMine = Handle(XCAFDoc_NoteComment)::DownCast(theAttr);
-  if (!aMine.IsNull())
-    myComment = aMine->myComment;
-}
-
-// =======================================================================
-// function : Paste
+// function : Get
 // purpose  :
 // =======================================================================
-void
-XCAFDoc_NoteComment::Paste(const Handle(TDF_Attribute)&       theAttrInto,
-                           const Handle(TDF_RelocationTable)& theRT) const
+const TCollection_ExtendedString& 
+XCAFDoc_NoteComment::Get() const
 {
-  XCAFDoc_Note::Paste(theAttrInto, theRT);
-
-  Handle(XCAFDoc_NoteComment) aMine = Handle(XCAFDoc_NoteComment)::DownCast(theAttrInto);
-  if (!aMine.IsNull())
-    aMine->Set(myComment);
+  return myComment->Get();
 }
 
 // =======================================================================
-// function : Dump
+// function : Label
 // purpose  :
 // =======================================================================
-Standard_OStream&
-XCAFDoc_NoteComment::Dump(Standard_OStream& theOS) const
+TDF_Label
+XCAFDoc_NoteComment::Label() const
 {
-  XCAFDoc_Note::Dump(theOS);
-  theOS << "\n"
-    << "Comment : " << (!myComment.IsEmpty() ? myComment : "<empty>")
-    ;
-  return theOS;
+  return !myComment.IsNull() ? myComment->Label() : TDF_Label();
 }
index 53386d06b697c06fb60fc3544d1c4bbeacf354bd..1ec490c6651260cc5b0ad487267164a6206e1c24 100644 (file)
 #ifndef _XCAFDoc_NoteComment_HeaderFile
 #define _XCAFDoc_NoteComment_HeaderFile
 
-#include <XCAFDoc_Note.hxx>
+#include <Standard_Handle.hxx>
+#include <Standard_Transient.hxx>
+#include <TDF_Label.hxx>
 
-//! A comment note attribute.
-//! Contains a textual comment.
-class XCAFDoc_NoteComment : public XCAFDoc_Note
+class TDataStd_Comment;
+
+//! Comment note proxy.
+//! Handles a textual comment of the note.
+class XCAFDoc_NoteComment : public Standard_Transient
 {
 public:
 
-  DEFINE_STANDARD_RTTIEXT(XCAFDoc_NoteComment, XCAFDoc_Note)
-
-  //! Returns default attribute GUID
-  Standard_EXPORT static const Standard_GUID& GetID();
+  DEFINE_STANDARD_RTTIEXT(XCAFDoc_NoteComment, Standard_Transient)
 
-  //! Finds a reference attribute on the given label and returns it, if it is found
+  //! Finds a reference attribute on the given label and returns a proxy instance if it is found
   Standard_EXPORT static Handle(XCAFDoc_NoteComment) Get(const TDF_Label& theLabel);
 
-  //! Create (if not exist) a comment note on the given label.
-  //! \param [in] theLabel     - note label.
-  //! \param [in] theUserName  - the name of the user, who created the note.
-  //! \param [in] theTimeStamp - creation timestamp of the note.
-  //! \param [in] theComment   - comment text.
+  //! Create (if not exist) a comment on the given note label.
+  //! \param [in] theLabel   - note label.
+  //! \param [in] theComment - comment text.
   Standard_EXPORT static Handle(XCAFDoc_NoteComment) Set(const TDF_Label&                  theLabel,
-                                                         const TCollection_ExtendedString& theUserName,
-                                                         const TCollection_ExtendedString& theTimeStamp,
                                                          const TCollection_ExtendedString& theComment);
 
-  //! Creates an empty comment note.
-  Standard_EXPORT XCAFDoc_NoteComment();
-
   //! Sets the comment text.
   Standard_EXPORT void Set(const TCollection_ExtendedString& theComment);
 
   //! Returns the comment text.
-  const TCollection_ExtendedString& Comment() const { return myComment; }
+  Standard_EXPORT const TCollection_ExtendedString& Get() const;
 
-public:
+  //! Returns label
+  Standard_EXPORT TDF_Label Label() const;
 
-  // Overrides TDF_Attribute virtuals
-  Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
-  Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
-  Standard_EXPORT void Restore(const Handle(TDF_Attribute)& theAttrFrom) Standard_OVERRIDE;
-  Standard_EXPORT void Paste(const Handle(TDF_Attribute)&       theAttrInto,
-                             const Handle(TDF_RelocationTable)& theRT) const Standard_OVERRIDE;
-  Standard_EXPORT Standard_OStream& Dump(Standard_OStream& theOS) const Standard_OVERRIDE;
+private:
 
-protected:
+  XCAFDoc_NoteComment(const Handle(TDataStd_Comment)& theComment);
 
-  TCollection_ExtendedString myComment; ///< Comment text.
+  Handle(TDataStd_Comment) myComment; ///< Comment attribute.
 
 };
 
-DEFINE_STANDARD_HANDLE(XCAFDoc_NoteComment, XCAFDoc_Note)
+DEFINE_STANDARD_HANDLE(XCAFDoc_NoteComment, Standard_Transient)
 
 #endif // _XCAFDoc_NoteComment_HeaderFile
index 45e3bb9619d3ee6e47fb11e20176924e3b3b2158..deb3554a0c91c3143a833f1fc61bf4575faea0c0 100644 (file)
 #include <Standard_GUID.hxx>
 #include <NCollection_Map.hxx>
 #include <TColStd_HArray1OfByte.hxx>
+#include <TDataStd_Name.hxx>
 #include <TDF_Label.hxx>
 #include <TDF_LabelMapHasher.hxx>
 #include <TDF_ChildIDIterator.hxx>
 #include <TDF_LabelSequence.hxx>
 #include <TDF_Tool.hxx>
 #include <XCAFDoc.hxx>
+#include <XCAFDoc_AssemblyItemRef.hxx>
 #include <XCAFDoc_GraphNode.hxx>
-#include <XCAFDoc_NoteBalloon.hxx>
+#include <XCAFDoc_Note.hxx>
 #include <XCAFDoc_NoteComment.hxx>
+#include <XCAFDoc_NoteBalloon.hxx>
 #include <XCAFDoc_NoteBinData.hxx>
-#include <XCAFDoc_AssemblyItemRef.hxx>
 
 namespace {
 
@@ -44,7 +46,8 @@ IMPLEMENT_DERIVED_ATTRIBUTE(XCAFDoc_NotesTool, XCAFDoc_NoteComment)
 enum NotesTool_RootLabels
 {
   NotesTool_NotesRoot = 1,
-  NotesTool_AnnotatedItemsRoot
+  NotesTool_AnnotatedItemsRoot,
+  NotesTool_NoteGroupsRoot
 };
 
 // =======================================================================
@@ -101,6 +104,15 @@ TDF_Label XCAFDoc_NotesTool::GetAnnotatedItemsLabel() const
   return Label().FindChild(NotesTool_AnnotatedItemsRoot);
 }
 
+// =======================================================================
+// function : GetNoteGroupsLabel
+// purpose  :
+// =======================================================================
+TDF_Label XCAFDoc_NotesTool::GetGroupsLabel() const
+{
+  return Label().FindChild(NotesTool_NoteGroupsRoot);
+}
+
 // =======================================================================
 // function : NbNotes
 // purpose  :
@@ -133,6 +145,21 @@ XCAFDoc_NotesTool::NbAnnotatedItems() const
   return nbItems;
 }
 
+// =======================================================================
+// function : NbNoteGroups
+// purpose  :
+// =======================================================================
+Standard_Integer
+XCAFDoc_NotesTool::NbGroups() const
+{
+  Standard_Integer nbGroups = 0;
+  for (TDF_ChildIterator anIter(GetGroupsLabel()); anIter.More(); anIter.Next())
+  {
+    ++nbGroups;
+  }
+  return nbGroups;
+}
+
 // =======================================================================
 // function : GetNotes
 // purpose  :
@@ -143,11 +170,55 @@ XCAFDoc_NotesTool::GetNotes(TDF_LabelSequence& theNoteLabels) const
   for (TDF_ChildIterator anIter(GetNotesLabel()); anIter.More(); anIter.Next())
   {
     const TDF_Label aLabel = anIter.Value();
-    if (!XCAFDoc_Note::Get(aLabel).IsNull())
+    if (XCAFDoc_Note::IsMine(aLabel))
       theNoteLabels.Append(aLabel);
   }
 }
 
+// =======================================================================
+// function : GetTopNotes
+// purpose  :
+// =======================================================================
+void 
+XCAFDoc_NotesTool::GetTopNotes(TDF_LabelSequence& theNoteLabels) const
+{
+  for (TDF_ChildIterator anIter(GetNotesLabel()); anIter.More(); anIter.Next())
+  {
+    const TDF_Label aLabel = anIter.Value();
+    if (!XCAFDoc_Note::IsMine(aLabel))
+      continue;
+
+    Handle(XCAFDoc_GraphNode) aFather;
+    if (!aLabel.FindAttribute(XCAFDoc::NoteRefGUID(), aFather) || aFather.IsNull())
+    {
+      theNoteLabels.Append(aLabel);
+      continue;
+    }
+
+    Standard_Integer nbChildren = aFather->NbChildren();
+    if (nbChildren == 0)
+    {
+      theNoteLabels.Append(aLabel);
+      continue;
+    }
+
+    for (Standard_Integer iChild = 1; iChild <= nbChildren; ++iChild)
+    {
+      Handle(XCAFDoc_GraphNode) aChild = aFather->GetChild(iChild);
+      Handle(XCAFDoc_AssemblyItemRef) anItemRef = XCAFDoc_AssemblyItemRef::Get(aChild->Label());
+      if (!anItemRef.IsNull())
+      {
+        TDF_Label anAnnotatedLabel = anItemRef->GetItemLabel();
+        if (!anAnnotatedLabel.IsNull() && !XCAFDoc_Note::IsMine(anAnnotatedLabel))
+        {
+          theNoteLabels.Append(aLabel);
+          break;
+        }
+      }
+    }
+  }
+}
+
 // =======================================================================
 // function : GetAnnotatedItems
 // purpose  :
@@ -161,6 +232,19 @@ XCAFDoc_NotesTool::GetAnnotatedItems(TDF_LabelSequence& theItemLabels) const
   }
 }
 
+// =======================================================================
+// function : GetNoteGroups
+// purpose  :
+// =======================================================================
+void
+XCAFDoc_NotesTool::GetGroups(TDF_LabelSequence& theNoteGroupLabels) const
+{
+  for (TDF_ChildIterator anIter(GetGroupsLabel()); anIter.More(); anIter.Next())
+  {
+    theNoteGroupLabels.Append(anIter.Value());
+  }
+}
+
 // =======================================================================
 // function : IsAnnotatedItem
 // purpose  :
@@ -181,6 +265,16 @@ XCAFDoc_NotesTool::IsAnnotatedItem(const TDF_Label& theItemLabel) const
   return IsAnnotatedItem(labeledItem(theItemLabel));
 }
 
+// =======================================================================
+// function : IsAnnotatedNote
+// purpose  :
+// =======================================================================
+Standard_Boolean 
+XCAFDoc_NotesTool::IsAnnotatedItem(const Handle(XCAFDoc_Note)& theNote) const
+{
+  return !theNote.IsNull() && IsAnnotatedItem(theNote->Label());
+}
+
 // =======================================================================
 // function : FindAnnotatedItem
 // purpose  :
@@ -194,6 +288,7 @@ XCAFDoc_NotesTool::FindAnnotatedItem(const XCAFDoc_AssemblyItemId& theItemId) co
     if (!anItemRef.IsNull() && anItemRef->GetItem().IsEqual(theItemId) && !anItemRef->HasExtraRef())
       return anItemRef->Label();
   }
+
   return TDF_Label();
 }
 
@@ -222,6 +317,7 @@ XCAFDoc_NotesTool::FindAnnotatedItemAttr(const XCAFDoc_AssemblyItemId& theItemId
       anItemRef->HasExtraRef() && anItemRef->GetGUID() == theGUID)
       return anItemRef->Label();
   }
+
   return TDF_Label();
 }
 
@@ -251,6 +347,7 @@ XCAFDoc_NotesTool::FindAnnotatedItemSubshape(const XCAFDoc_AssemblyItemId& theIt
       anItemRef->HasExtraRef() && anItemRef->GetSubshapeIndex() == theSubshapeIndex)
       return anItemRef->Label();
   }
+
   return TDF_Label();
 }
 
@@ -265,6 +362,30 @@ XCAFDoc_NotesTool::FindAnnotatedItemSubshape(const TDF_Label& theItemLabel,
   return FindAnnotatedItemSubshape(labeledItem(theItemLabel), theSubshapeIndex);
 }
 
+// =======================================================================
+// function : FindAnnotatedNote
+// purpose  :
+// =======================================================================
+TDF_Label 
+XCAFDoc_NotesTool::FindAnnotatedItem(const Handle(XCAFDoc_Note)& theNote) const
+{
+  return !theNote.IsNull() ? FindAnnotatedItem(theNote->Label()) : TDF_Label();
+}
+
+// =======================================================================
+// function : Create
+// purpose  :
+// =======================================================================
+Handle(XCAFDoc_Note)
+XCAFDoc_NotesTool::Create(const TCollection_ExtendedString& theUserName,
+                          const TCollection_ExtendedString& theTimeStamp)
+{
+  TDF_Label aNoteLabel;
+  TDF_TagSource aTag;
+  aNoteLabel = aTag.NewChild(GetNotesLabel());
+  return XCAFDoc_Note::Set(aNoteLabel, theUserName, theTimeStamp);
+}
+
 // =======================================================================
 // function : CreateComment
 // purpose  :
@@ -274,10 +395,20 @@ XCAFDoc_NotesTool::CreateComment(const TCollection_ExtendedString& theUserName,
                                  const TCollection_ExtendedString& theTimeStamp,
                                  const TCollection_ExtendedString& theComment)
 {
-  TDF_Label aNoteLabel;
+  TDF_Label aLabel;
   TDF_TagSource aTag;
-  aNoteLabel = aTag.NewChild(GetNotesLabel());
-  return XCAFDoc_NoteComment::Set(aNoteLabel, theUserName, theTimeStamp, theComment);
+  aLabel = aTag.NewChild(GetNotesLabel());
+  Handle(XCAFDoc_Note) aNote = XCAFDoc_Note::Set(aLabel, theUserName, theTimeStamp);
+  if (!aNote.IsNull())
+  {
+    Handle(XCAFDoc_NoteComment) aComment = XCAFDoc_NoteComment::Set(aLabel, theComment);
+    if (aComment.IsNull())
+    {
+      aLabel.ForgetAllAttributes();
+      return NULL;
+    }
+  }
+  return aNote;
 }
 
 // =======================================================================
@@ -300,33 +431,361 @@ XCAFDoc_NotesTool::CreateBalloon(const TCollection_ExtendedString& theUserName,
 // purpose  :
 // =======================================================================
 Handle(XCAFDoc_Note)
-XCAFDoc_NotesTool::CreateBinData(const TCollection_ExtendedString& theUserName,
-                                 const TCollection_ExtendedString& theTimeStamp,
-                                 const TCollection_ExtendedString& theTitle,
-                                 const TCollection_AsciiString&    theMIMEtype,
-                                 OSD_File&                         theFile)
+XCAFDoc_NotesTool::CreateBinDataContainer(const TCollection_ExtendedString& theUserName,
+                                          const TCollection_ExtendedString& theTimeStamp)
 {
-  TDF_Label aNoteLabel;
+  TDF_Label aLabel;
   TDF_TagSource aTag;
-  aNoteLabel = aTag.NewChild(GetNotesLabel());
-  return XCAFDoc_NoteBinData::Set(aNoteLabel, theUserName, theTimeStamp, theTitle, theMIMEtype, theFile);
+  aLabel = aTag.NewChild(GetNotesLabel());
+  Handle(XCAFDoc_Note) aNote = XCAFDoc_Note::Set(aLabel, theUserName, theTimeStamp);
+  if (!aNote.IsNull())
+  {
+    Handle(XCAFDoc_NoteBinDataContainer) aBinDataCnt = XCAFDoc_NoteBinDataContainer::Set(aLabel);
+    if (aBinDataCnt.IsNull())
+    {
+      aLabel.ForgetAllAttributes();
+      return NULL;
+    }
+  }
+  return aNote;
 }
 
 // =======================================================================
-// function : CreateBinData
+// function : IsGroup
 // purpose  :
 // =======================================================================
-Handle(XCAFDoc_Note)
-XCAFDoc_NotesTool::CreateBinData(const TCollection_ExtendedString&    theUserName,
-                                 const TCollection_ExtendedString&    theTimeStamp,
-                                 const TCollection_ExtendedString&    theTitle,
-                                 const TCollection_AsciiString&       theMIMEtype,
-                                 const Handle(TColStd_HArray1OfByte)& theData)
+Standard_Boolean
+XCAFDoc_NotesTool::IsGroup(const TDF_Label& theLabel) const
+{
+  return !theLabel.IsNull() && !theLabel.Father().IsNull() 
+    && theLabel.Father().IsEqual(GetGroupsLabel());
+}
+
+// =======================================================================
+// function : CreateGroup
+// purpose  :
+// =======================================================================
+TDF_Label
+XCAFDoc_NotesTool::CreateGroup(const TCollection_ExtendedString& theGroupName)
 {
-  TDF_Label aNoteLabel;
   TDF_TagSource aTag;
-  aNoteLabel = aTag.NewChild(GetNotesLabel());
-  return XCAFDoc_NoteBinData::Set(aNoteLabel, theUserName, theTimeStamp, theTitle, theMIMEtype, theData);
+  TDF_Label aGroupLabel = aTag.NewChild(GetGroupsLabel());
+  if (!aGroupLabel.IsNull())
+  {
+    if (TDataStd_Name::Set(aGroupLabel, theGroupName).IsNull())
+      aGroupLabel.Nullify();
+  }
+  return aGroupLabel;
+}
+
+// =======================================================================
+// function : AddToGroup
+// purpose  :
+// =======================================================================
+Standard_Boolean
+XCAFDoc_NotesTool::GetGroupName(const TDF_Label& theGroupLabel,
+                                TCollection_ExtendedString& theGroupName)
+{
+  if (!IsGroup(theGroupLabel))
+    return Standard_False;
+
+  Handle(TDataStd_Name) aName;
+  if (!theGroupLabel.FindAttribute(TDataStd_Name::GetID(), aName))
+    return Standard_False;
+
+  theGroupName = aName->Get();
+  return Standard_True;
+}
+
+// =======================================================================
+// function : NbGroupNotes
+// purpose  :
+// =======================================================================
+Standard_Integer
+XCAFDoc_NotesTool::NbGroupNotes(const TDF_Label& theGroupLabel) const
+{
+  if (!IsGroup(theGroupLabel))
+    return 0;
+
+  Standard_Integer aNbNotes = 0;
+
+  Handle(XCAFDoc_GraphNode) aFather;
+  if (theGroupLabel.FindAttribute(XCAFDoc::NoteRefGUID(), aFather) && !aFather.IsNull())
+  {
+    aNbNotes = aFather->NbChildren();
+  }
+
+  return aNbNotes;
+}
+
+// =======================================================================
+// function : AddToGroup
+// purpose  :
+// =======================================================================
+Standard_Boolean
+XCAFDoc_NotesTool::AddToGroup(const TDF_Label& theGroupLabel,
+                              const Handle(XCAFDoc_Note)& theNote)
+{
+  return !theNote.IsNull() && AddToGroup(theGroupLabel, theNote->Label());
+}
+
+// =======================================================================
+// function : AddToGroup
+// purpose  :
+// =======================================================================
+Standard_Boolean
+XCAFDoc_NotesTool::AddToGroup(const TDF_Label& theGroupLabel,
+                              const TDF_Label& theNoteLabel)
+{
+  if (!XCAFDoc_Note::IsMine(theNoteLabel))
+    return Standard_False;
+
+  Handle(XCAFDoc_GraphNode) aFather;
+  if (!theGroupLabel.FindAttribute(XCAFDoc::NoteRefGUID(), aFather))
+  {
+    aFather = XCAFDoc_GraphNode::Set(theGroupLabel, XCAFDoc::NoteRefGUID());
+    if (aFather.IsNull())
+      return Standard_False;
+  }
+
+  Handle(XCAFDoc_GraphNode) aChild;
+  if (!theNoteLabel.FindAttribute(XCAFDoc::NoteRefGUID(), aChild))
+  {
+    aChild = XCAFDoc_GraphNode::Set(theNoteLabel, XCAFDoc::NoteRefGUID());
+    if (aChild.IsNull())
+      return Standard_False;
+  }
+
+  aFather->SetChild(aChild);
+  aChild->SetFather(aFather);
+
+  return Standard_True;
+}
+
+// =======================================================================
+// function : AddToGroup
+// purpose  :
+// =======================================================================
+Standard_Integer
+XCAFDoc_NotesTool::AddToGroup(const TDF_Label& theGroupLabel,
+                              const TDF_LabelSequence& theNoteLabels)
+{
+  Standard_Integer aNbAdded = 0;
+  for (TDF_LabelSequence::Iterator anIter(theNoteLabels); anIter.More(); anIter.Next())
+  {
+    if (AddToGroup(theGroupLabel, anIter.Value()))
+      ++aNbAdded;
+  }
+  return aNbAdded;
+}
+
+// =======================================================================
+// function : RemoveFromGroup
+// purpose  :
+// =======================================================================
+Standard_Boolean
+XCAFDoc_NotesTool::RemoveFromGroup(const TDF_Label& theGroupLabel,
+                                   const Handle(XCAFDoc_Note)& theNote)
+{
+  return !theNote.IsNull() && RemoveFromGroup(theGroupLabel, theNote->Label());
+}
+
+// =======================================================================
+// function : RemoveFromGroup
+// purpose  :
+// =======================================================================
+Standard_Boolean
+XCAFDoc_NotesTool::RemoveFromGroup(const TDF_Label& theGroupLabel,
+                                   const TDF_Label& theNoteLabel)
+{
+  if (!IsGroup(theGroupLabel))
+    return Standard_False;
+
+  Handle(XCAFDoc_GraphNode) aChild;
+  if (theNoteLabel.FindAttribute(XCAFDoc::NoteRefGUID(), aChild) && !aChild.IsNull())
+  {
+    Standard_Integer nbFathers = aChild->NbFathers();
+    for (Standard_Integer iFather = 1; iFather <= nbFathers; ++iFather)
+    {
+      Handle(XCAFDoc_GraphNode) aFather = aChild->GetFather(iFather);
+      if (!aFather.IsNull() && theGroupLabel.IsEqual(aFather->Label()))
+      {
+        aChild->UnSetFather(aFather);
+        return Standard_True;
+      }
+    }
+  }
+
+  return Standard_False;
+}
+
+// =======================================================================
+// function : RemoveFromGroup
+// purpose  :
+// =======================================================================
+Standard_Integer
+XCAFDoc_NotesTool::RemoveFromGroup(const TDF_Label& theGroupLabel,
+                                   const TDF_LabelSequence& theNoteLabels)
+{
+  Standard_Integer aNbRemoved = 0;
+  for (TDF_LabelSequence::Iterator anIter(theNoteLabels); anIter.More(); anIter.Next())
+  {
+    if (RemoveFromGroup(theGroupLabel, anIter.Value()))
+      ++aNbRemoved;
+  }
+  return aNbRemoved;
+}
+
+// =======================================================================
+// function : ClearGroup
+// purpose  :
+// =======================================================================
+Standard_Boolean
+XCAFDoc_NotesTool::ClearGroup(const TDF_Label& theGroupLabel,
+                              Standard_Boolean theDeleteNotes)
+{
+  if (!IsGroup(theGroupLabel))
+    return Standard_False;
+
+  Handle(XCAFDoc_GraphNode) aFather;
+  if (theGroupLabel.FindAttribute(XCAFDoc::NoteRefGUID(), aFather) && !aFather.IsNull())
+  {
+    while (aFather->NbChildren() > 0)
+    {
+      Handle(XCAFDoc_GraphNode) aChild = aFather->GetChild(1);
+      if (!aChild.IsNull())
+        aFather->UnSetChild(aChild);
+      if (theDeleteNotes)
+        DeleteNote(aChild->Label());
+    }
+  }
+
+  return Standard_True;
+}
+
+// =======================================================================
+// function : GetGroupNotes
+// purpose  :
+// =======================================================================
+Standard_Integer
+XCAFDoc_NotesTool::GetGroupNotes(const TDF_Label& theGroupLabel,
+                                 TDF_LabelSequence& theNoteLabels) const
+{
+  if (!IsGroup(theGroupLabel))
+    return 0;
+
+  Standard_Integer aNbNotes = 0;
+
+  Handle(XCAFDoc_GraphNode) aFather;
+  if (theGroupLabel.FindAttribute(XCAFDoc::NoteRefGUID(), aFather) && !aFather.IsNull())
+  {
+    Standard_Integer nbChildren = aFather->NbChildren();
+    for (Standard_Integer iChild = 1; iChild <= nbChildren; ++iChild)
+    {
+      Handle(XCAFDoc_GraphNode) aChild = aFather->GetChild(iChild);
+      theNoteLabels.Append(aChild->Label());
+    }
+  }
+
+  return aNbNotes;
+}
+
+// =======================================================================
+// function : GetUngropedNotes
+// purpose  :
+// =======================================================================
+Standard_Integer 
+XCAFDoc_NotesTool::GetUngropedNotes(TDF_LabelSequence& theNoteLabels) const
+{
+  TDF_LabelSequence aNotes;
+  GetNotes(aNotes);
+  if (aNotes.IsEmpty())
+    return 0;
+
+  Standard_Integer nbNotes = 0;
+  for (TDF_LabelSequence::Iterator anIter(aNotes); anIter.More(); anIter.Next())
+  {
+    TDF_LabelSequence aGroups;
+    if (GetNoteGroups(anIter.Value(), aGroups) == 0)
+    {
+      theNoteLabels.Append(anIter.Value());
+      ++nbNotes;
+    }
+  }
+  return nbNotes;
+}
+
+// =======================================================================
+// function : GetNoteGroups
+// purpose  :
+// =======================================================================
+Standard_Integer
+XCAFDoc_NotesTool::GetNoteGroups(const Handle(XCAFDoc_Note)& theNote,
+                                 TDF_LabelSequence& theGroupLabels) const
+{
+  return !theNote.IsNull() ? GetNoteGroups(theNote->Label(), theGroupLabels) : 0;
+}
+
+// =======================================================================
+// function : GetNoteGroups
+// purpose  :
+// =======================================================================
+Standard_Integer
+XCAFDoc_NotesTool::GetNoteGroups(const TDF_Label& theNoteLabel,
+                                 TDF_LabelSequence& theGroupLabels) const
+{
+  if (!XCAFDoc_Note::IsMine(theNoteLabel))
+    return 0;
+
+  Standard_Integer nbGroups = 0;
+  Handle(XCAFDoc_GraphNode) aChild;
+  if (theNoteLabel.FindAttribute(XCAFDoc::NoteRefGUID(), aChild) && !aChild.IsNull())
+  {
+    Standard_Integer nbFathers = aChild->NbFathers();
+    for (Standard_Integer iFather = 1; iFather <= nbFathers; ++iFather)
+    {
+      Handle(XCAFDoc_GraphNode) aFather = aChild->GetFather(iFather);
+      if (IsGroup(aFather->Label()))
+      {
+        theGroupLabels.Append(aFather->Label());
+        ++nbGroups;
+      }
+    }
+  }
+  return nbGroups;
+}
+
+// =======================================================================
+// function : DeleteGroup
+// purpose  :
+// =======================================================================
+Standard_Boolean
+XCAFDoc_NotesTool::DeleteGroup(const TDF_Label& theGroupLabel, 
+                               Standard_Boolean theDeleteNotes)
+{
+  if (ClearGroup(theGroupLabel, theDeleteNotes))
+  {
+    theGroupLabel.ForgetAllAttributes();
+    return Standard_True;
+  }
+
+  return Standard_False;
+}
+
+// =======================================================================
+// function : DeleteAllGroups
+// purpose  :
+// =======================================================================
+Standard_Integer
+XCAFDoc_NotesTool::DeleteAllGroups(Standard_Boolean theDeleteNotes)
+{
+  Standard_Integer nbGroups = 0;
+  for (TDF_ChildIterator anIter(GetGroupsLabel()); anIter.More(); anIter.Next())
+  {
+    if (DeleteGroup(anIter.Value(), theDeleteNotes))
+      ++nbGroups;
+  }
+  return nbGroups;
 }
 
 // =======================================================================
@@ -345,14 +804,27 @@ XCAFDoc_NotesTool::GetNotes(const XCAFDoc_AssemblyItemId& theItemId,
   if (!anAnnotatedItem.FindAttribute(XCAFDoc::NoteRefGUID(), aChild))
     return 0;
 
+  Standard_Integer nbNotes = 0;
   Standard_Integer nbFathers = aChild->NbFathers();
   for (Standard_Integer iFather = 1; iFather <= nbFathers; ++iFather)
   {
     Handle(XCAFDoc_GraphNode) aFather = aChild->GetFather(iFather);
     theNoteLabels.Append(aFather->Label());
+    ++nbNotes;
   }
 
-  return theNoteLabels.Length();
+  return nbNotes;
+}
+
+// =======================================================================
+// function : GetNotes
+// purpose  :
+// =======================================================================
+Standard_Integer
+XCAFDoc_NotesTool::GetNotes(const Handle(XCAFDoc_Note)& theNote,
+                            TDF_LabelSequence&          theNoteLabels) const
+{
+  return !theNote.IsNull() ? GetNotes(theNote->Label(), theNoteLabels) : 0;
 }
 
 // =======================================================================
@@ -383,14 +855,16 @@ XCAFDoc_NotesTool::GetAttrNotes(const XCAFDoc_AssemblyItemId& theItemId,
   if (!anAnnotatedItem.FindAttribute(XCAFDoc::NoteRefGUID(), aChild))
     return 0;
 
+  Standard_Integer nbNotes = 0;
   Standard_Integer nbFathers = aChild->NbFathers();
   for (Standard_Integer iFather = 1; iFather <= nbFathers; ++iFather)
   {
     Handle(XCAFDoc_GraphNode) aFather = aChild->GetFather(iFather);
     theNoteLabels.Append(aFather->Label());
+    ++nbNotes;
   }
 
-  return theNoteLabels.Length();
+  return nbNotes;
 }
 
 // =======================================================================
@@ -422,14 +896,16 @@ XCAFDoc_NotesTool::GetSubshapeNotes(const XCAFDoc_AssemblyItemId& theItemId,
   if (!anAnnotatedItem.FindAttribute(XCAFDoc::NoteRefGUID(), aChild))
     return 0;
 
+  Standard_Integer nbNotes = 0;
   Standard_Integer nbFathers = aChild->NbFathers();
   for (Standard_Integer iFather = 1; iFather <= nbFathers; ++iFather)
   {
     Handle(XCAFDoc_GraphNode) aFather = aChild->GetFather(iFather);
     theNoteLabels.Append(aFather->Label());
+    ++nbNotes;
   }
 
-  return theNoteLabels.Length();
+  return nbNotes;
 }
 
 // =======================================================================
@@ -445,7 +921,6 @@ XCAFDoc_NotesTool::AddNote(const TDF_Label&              theNoteLabel,
   if (!XCAFDoc_Note::IsMine(theNoteLabel))
     return anItemRef;
 
-  Handle(XCAFDoc_GraphNode) aChild;
   TDF_Label anAnnotatedItem = FindAnnotatedItem(theItemId);
   if (anAnnotatedItem.IsNull())
   {
@@ -455,6 +930,7 @@ XCAFDoc_NotesTool::AddNote(const TDF_Label&              theNoteLabel,
       return anItemRef;
   }
 
+  Handle(XCAFDoc_GraphNode) aChild;
   if (!anAnnotatedItem.FindAttribute(XCAFDoc::NoteRefGUID(), aChild))
   {
     aChild = XCAFDoc_GraphNode::Set(anAnnotatedItem, XCAFDoc::NoteRefGUID());
@@ -494,6 +970,17 @@ XCAFDoc_NotesTool::AddNote(const TDF_Label& theNoteLabel,
   return AddNote(theNoteLabel, labeledItem(theItemLabel));
 }
 
+// =======================================================================
+// function : AddNote
+// purpose  :
+// =======================================================================
+Handle(XCAFDoc_AssemblyItemRef)
+XCAFDoc_NotesTool::AddNote(const TDF_Label&            theNoteLabel,
+                           const Handle(XCAFDoc_Note)& theAnnotatedNote)
+{
+  return !theAnnotatedNote.IsNull() ? AddNote(theNoteLabel, theAnnotatedNote->Label()) : NULL;
+}
+
 // =======================================================================
 // function : AddNoteToAttr
 // purpose  :
@@ -674,6 +1161,18 @@ XCAFDoc_NotesTool::RemoveNote(const TDF_Label& theNoteLabel,
   return RemoveNote(theNoteLabel, labeledItem(theItemLabel), theDelIfOrphan);
 }
 
+// =======================================================================
+// function : RemoveNote
+// purpose  :
+// =======================================================================
+Standard_Boolean 
+XCAFDoc_NotesTool::RemoveNote(const TDF_Label&            theNoteLabel,
+                              const Handle(XCAFDoc_Note)& theNote,
+                              Standard_Boolean            theDelIfOrphan)
+{
+  return !theNote.IsNull() ? RemoveNote(theNoteLabel, theNote->Label(), theDelIfOrphan) : Standard_False;
+}
+
 // =======================================================================
 // function : RemoveSubshapeNote
 // purpose  :
@@ -818,6 +1317,17 @@ XCAFDoc_NotesTool::RemoveAllNotes(const TDF_Label& theItemLabel,
   return RemoveAllNotes(labeledItem(theItemLabel), theDelIfOrphan);
 }
 
+// =======================================================================
+// function : RemoveAllNotes
+// purpose  :
+// =======================================================================
+Standard_Boolean 
+XCAFDoc_NotesTool::RemoveAllNotes(const Handle(XCAFDoc_Note)& theNote,
+                                  Standard_Boolean            theDelIfOrphan)
+{
+  return !theNote.IsNull() ? RemoveAllNotes(theNote->Label(), theDelIfOrphan) : Standard_False;
+}
+
 // =======================================================================
 // function : RemoveAllSubshapeNotes
 // purpose  :
@@ -916,10 +1426,10 @@ XCAFDoc_NotesTool::DeleteNote(const TDF_Label& theNoteLabel)
         Handle(XCAFDoc_GraphNode) aChild = aFather->GetChild(1);
         aFather->UnSetChild(aChild);
         if (aChild->NbFathers() == 0)
-          aChild->Label().ForgetAllAttributes(Standard_True);
+          aChild->Label().ForgetAllAttributes();
       }
     }
-    theNoteLabel.ForgetAllAttributes(Standard_True);
+    theNoteLabel.ForgetAllAttributes();
     return Standard_True;
   }
   return Standard_False;
index 77a03834a1a57af635be87a68bc43243893dcdc6..2841ee5843d169cea16f77ae39d4702bb2ce3173 100644 (file)
@@ -17,6 +17,7 @@
 #include <Standard.hxx>
 #include <Standard_Type.hxx>
 #include <TDataStd_GenericEmpty.hxx>
+#include <TDF_AttributeMap.hxx>
 #include <TDF_LabelSequence.hxx>
 
 class OSD_File;
@@ -48,17 +49,23 @@ class XCAFDoc_AssemblyItemRef;
 //! |         0:1:9        |
 //! ------------------------
 //!             |1
-//!             |   -------------------     ---------------------------
-//!             +___|      Notes      |-----|       XCAFDoc_Note      |
-//!             |  1|     0:1:9:1     |1   *|         0:1:9:1:*       |
-//!             |   -------------------     ---------------------------
-//!             |                                        !*
-//!             |                              { XCAFDoc_GraphNode }
-//!             |                                       *!
-//!             |   -------------------     ---------------------------
-//!             +___| Annotated items |-----| XCAFDoc_AssemblyItemRef |
-//!                1|     0:1:9:2     |1   *|         0:1:9:2:*       |
-//!                 -------------------     ---------------------------
+//!             |   -------------------      ---------------------------
+//!             +___|      Notes      |------|       XCAFDoc_Note      |
+//!             |  1|     0:1:9:1     |1    *|         0:1:9:1:*       |
+//!             |   -------------------      ---------------------------
+//!             |                                     [C] * [F]
+//!             |            --- { XCAFDoc_GraphNode } ---|
+//!             |       [F] *                             |
+//!             |   -------------------                   |
+//!             +___|   Note groups   |         { XCAFDoc_GraphNode }
+//!             |  1|     0:1:9:3     |                   |  
+//!             |   -------------------                   |
+//!             |                                         |
+//!             |                                         * [C]
+//!             |   -------------------      ---------------------------
+//!             +___| Annotated items |------| XCAFDoc_AssemblyItemRef |
+//!                1|     0:1:9:2     |1    *|         0:1:9:2:*       |
+//!                 -------------------      ---------------------------
 //!
 //! A typical annotation procedure is illustrated by the code example below:
 //! \code{.c++}
@@ -94,22 +101,39 @@ public:
   //! Returns the label of the annotated items hive.
   Standard_EXPORT TDF_Label GetAnnotatedItemsLabel() const;
 
+  //! Returns the label of the note groups hive.
+  Standard_EXPORT TDF_Label GetGroupsLabel() const;
+
   //! Returns the number of labels in the notes hive.
   Standard_EXPORT Standard_Integer NbNotes() const;
 
   //! Returns the number of labels in the annotated items hive.
   Standard_EXPORT Standard_Integer NbAnnotatedItems() const;
 
+  //! Returns the number of labels in the note groups hive.
+  Standard_EXPORT Standard_Integer NbGroups() const;
+
   //! Returns all labels from the notes hive.
   //! The label sequence isn't cleared beforehand.
   //! \param [out] theNoteLabels - sequence of labels.
   Standard_EXPORT void GetNotes(TDF_LabelSequence& theNoteLabels) const;
 
+  //! Returns all labels corresponding to top notes from the notes hive.
+  //! A top note annotates any atem excepting other notes.
+  //! The label sequence isn't cleared beforehand.
+  //! \param [out] theNoteLabels - sequence of labels.
+  Standard_EXPORT void GetTopNotes(TDF_LabelSequence& theNoteLabels) const;
+
   //! Returns all labels from the annotated items hive.
   //! The label sequence isn't cleared beforehand.
   //! \param [out] theNoteLabels - sequence of labels.
   Standard_EXPORT void GetAnnotatedItems(TDF_LabelSequence& theLabels) const;
 
+  //! Returns all labels from the note groups hive.
+  //! The label sequence isn't cleared beforehand.
+  //! \param [out] theGroupLabels - sequence of labels.
+  Standard_EXPORT void GetGroups(TDF_LabelSequence& theGroupLabels) const;
+
   //! Checks if the given assembly item is annotated.
   //! \param [in] theItemId - assembly item ID.
   //! \return true if the item is annotated, otherwise - false.
@@ -120,6 +144,11 @@ public:
   //! \return true if the item is annotated, otherwise - false.
   Standard_EXPORT Standard_Boolean IsAnnotatedItem(const TDF_Label& theItemLabel) const;
 
+  //! Checks if the given note is annotated.
+  //! \param [in] theNote - note attribute.
+  //! \return true if the note is annotated, otherwise - false.
+  Standard_EXPORT Standard_Boolean IsAnnotatedItem(const Handle(XCAFDoc_Note)& theNote) const;
+
   //! @name Find annotated item functions
   //! @{
 
@@ -133,6 +162,11 @@ public:
   //! \return annotated item label if it is found, otherwise - null label.
   Standard_EXPORT TDF_Label FindAnnotatedItem(const TDF_Label& theItemLabel) const;
 
+  //! Finds a label of the given note in the annotated items hive.
+  //! \param [in] theNote - note attribute.
+  //! \return annotated note label if it is found, otherwise - null label.
+  Standard_EXPORT TDF_Label FindAnnotatedItem(const Handle(XCAFDoc_Note)& theNote) const;
+
   //! Finds a label of the given assembly item's attribute in the annotated items hive.
   //! \param [in] theItemId - assembly item ID.
   //! \param [in] theGUID   - assembly item's attribute GUID.
@@ -166,9 +200,16 @@ public:
   //! @name Note creation functions
   //! @{
 
+  //! Create a note.
+  //! Creates a new label under the notes hive and attaches \ref XCAFDoc_Note attribute.
+  //! \param [in] theUserName  - the user associated with the note.
+  //! \param [in] theTimeStamp - timestamp of the note.
+  //! \return a handle to the base note attribute.
+  Standard_EXPORT Handle(XCAFDoc_Note) Create(const TCollection_ExtendedString& theUserName,
+                                              const TCollection_ExtendedString& theTimeStamp);
+
   //! Create a new comment note.
-  //! Creates a new label under the notes hive and attaches \ref XCAFDoc_NoteComment 
-  //! attribute (derived ftom \ref XCAFDoc_Note).
+  //! Creates a new label under the notes hive and attaches \ref XCAFDoc_Note attribute.
   //! \param [in] theUserName  - the user associated with the note.
   //! \param [in] theTimeStamp - timestamp of the note.
   //! \param [in] theComment   - textual comment.
@@ -188,35 +229,127 @@ public:
                                                      const TCollection_ExtendedString& theTimeStamp,
                                                      const TCollection_ExtendedString& theComment);
 
-  //! Create a new note with data loaded from a binary file.
-  //! Creates a new label under the notes hive and attaches \ref XCAFDoc_NoteComment 
-  //! attribute (derived ftom \ref XCAFDoc_Note).
+  //! Create a new note for a binary data container.
+  //! Creates a new label under the notes hive and attaches \ref XCAFDoc_Note attribute.
   //! \param [in] theUserName  - the user associated with the note.
   //! \param [in] theTimeStamp - timestamp of the note.
-  //! \param [in] theTitle     - file title.
-  //! \param [in] theMIMEtype  - MIME type of the file.
-  //! \param [in] theFile      - input binary file.
   //! \return a handle to the base note attribute.
-  Standard_EXPORT Handle(XCAFDoc_Note) CreateBinData(const TCollection_ExtendedString& theUserName,
-                                                     const TCollection_ExtendedString& theTimeStamp,
-                                                     const TCollection_ExtendedString& theTitle,
-                                                     const TCollection_AsciiString&    theMIMEtype,
-                                                     OSD_File&                         theFile);
+  Standard_EXPORT Handle(XCAFDoc_Note) CreateBinDataContainer(const TCollection_ExtendedString& theUserName,
+                                                              const TCollection_ExtendedString& theTimeStamp);
 
-  //! Create a new note with data loaded from a byte data array.
-  //! Creates a new label under the notes hive and attaches \ref XCAFDoc_NoteComment 
-  //! attribute (derived ftom \ref XCAFDoc_Note).
-  //! \param [in] theUserName  - the user associated with the note.
-  //! \param [in] theTimeStamp - timestamp of the note.
-  //! \param [in] theTitle     - data title.
-  //! \param [in] theMIMEtype  - MIME type of the file.
-  //! \param [in] theData      - byte data array.
-  //! \return a handle to the base note attribute.
-  Standard_EXPORT Handle(XCAFDoc_Note) CreateBinData(const TCollection_ExtendedString&    theUserName,
-                                                     const TCollection_ExtendedString&    theTimeStamp,
-                                                     const TCollection_ExtendedString&    theTitle,
-                                                     const TCollection_AsciiString&       theMIMEtype,
-                                                     const Handle(TColStd_HArray1OfByte)& theData);
+  //! @}
+
+  //! @name Note groups functions
+  //! @{
+
+  //! Checks if the label is a note group.
+  //! \param [in] theLabel - label.
+  //! \return true if the label is a child of the note groups hive, otherwise - false.
+  Standard_EXPORT Standard_Boolean IsGroup(const TDF_Label& theLabel) const;
+
+  //! Create a new note group.
+  //! \param [in] theGroupName - the user associated with the note.
+  //! \return new group label.
+  Standard_EXPORT TDF_Label CreateGroup(const TCollection_ExtendedString& theGroupName);
+
+  //! Get group name.
+  //! \param [in] theGroupLabel - group label.
+  //! \param [out] theGroupName - group name.
+  //! \return true if the label is group, otherwise - false.
+  Standard_EXPORT Standard_Boolean GetGroupName(const TDF_Label& theGroupLabel,
+                                                TCollection_ExtendedString& theGroupName);
+
+  //! Returns the number of notes in the group.
+  //! \param [in] theGroupLabel - group label.
+  Standard_EXPORT Standard_Integer NbGroupNotes(const TDF_Label& theGroupLabel) const;
+
+  //! Adds note to group.
+  //! \param [in] theGroupLabel - group label.
+  //! \param [in] theNote       - attribute identifying the note.
+  //! \return true if theNote was successfully added to the specified group, otherwise - false.
+  Standard_EXPORT Standard_Boolean AddToGroup(const TDF_Label& theGroupLabel,
+                                              const Handle(XCAFDoc_Note)& theNote);
+
+  //! Adds note to group.
+  //! \param [in] theGroupLabel - group label.
+  //! \param [in] theNoteLabel  - note label.
+  //! \return true if theNote was successfully added to the specified group, otherwise - false.
+  Standard_EXPORT Standard_Boolean AddToGroup(const TDF_Label& theGroupLabel,
+                                              const TDF_Label& theNoteLabel);
+
+  //! Adds notes to group.
+  //! \param [in] theGroupLabel - group label.
+  //! \param [in] theNoteLabels - note label sequence.
+  //! \return the number of notes added to the group.
+  Standard_EXPORT Standard_Integer AddToGroup(const TDF_Label& theGroupLabel,
+                                              const TDF_LabelSequence& theNoteLabels);
+
+  //! Removes note from the group.
+  //! \param [in] theGroupLabel - group label.
+  //! \param [in] theNote       - attribute identifying the note.
+  //! \return true if the note was successfully from the group, otherwise - false.
+  Standard_EXPORT Standard_Boolean RemoveFromGroup(const TDF_Label& theGroupLabel,
+                                                   const Handle(XCAFDoc_Note)& theNote);
+
+  //! Removes note from the group.
+  //! \param [in] theGroupLabel - group label.
+  //! \param [in] theNoteLabel  - note label.
+  //! \return true if the note was successfully from the group, otherwise - false.
+  Standard_EXPORT Standard_Boolean RemoveFromGroup(const TDF_Label& theGroupLabel,
+                                                   const TDF_Label& theNoteLabel);
+
+  //! Removes notes from the group.
+  //! \param [in] theGroupLabel - group label.
+  //! \param [in] theNoteLabels - note label sequence.
+  //! \return the number of removed notes.
+  Standard_EXPORT Standard_Integer RemoveFromGroup(const TDF_Label& theGroupLabel,
+                                                   const TDF_LabelSequence& theNoteLabels);
+  
+  //! Removes all notes from the group.
+  //! \param [in] theGroupLabel - group label.
+  //! \return the number of removed notes.
+  Standard_EXPORT Standard_Boolean ClearGroup(const TDF_Label& theGroupLabel,
+                                              Standard_Boolean theDeleteNotes = Standard_False);
+
+  //! Retrieves notes from group.
+  //! Out label sequence isn't cleared.
+  //! \param [in] theGroupLabel  - group label.
+  //! \param [out] theNoteLabels - note label sequence.
+  //! \return the number of retrieved notes.
+  Standard_EXPORT Standard_Integer GetGroupNotes(const TDF_Label& theGroupLabel,
+                                                 TDF_LabelSequence& theNoteLabels) const;
+
+  //! Retrieves groups, to which the note belongs.
+  //! Out label sequence isn't cleared.
+  //! \param [in] theNote         - attribute identifying the note.
+  //! \param [out] theGroupLabels - group label sequence.
+  //! \return the number of retrieved groups.
+  Standard_EXPORT Standard_Integer GetNoteGroups(const Handle(XCAFDoc_Note)& theNote,
+                                                 TDF_LabelSequence& theGroupLabels) const;
+
+  //! Retrieves groups, to which the note belongs.
+  //! Out label sequence isn't cleared.
+  //! \param [in] theNoteLabel    - note label.
+  //! \param [out] theGroupLabels - group label sequence.
+  //! \return the number of retrieved groups.
+  Standard_EXPORT Standard_Integer GetNoteGroups(const TDF_Label& theNoteLabel,
+                                                 TDF_LabelSequence& theGroupLabels) const;
+
+  //! Retrieves notes, which don't belong to any group.
+  //! Out label sequence isn't cleared.
+  //! \param [out] theNoteLabels - note label sequence.
+  //! \return the number of retrieved notes.
+  Standard_EXPORT Standard_Integer GetUngropedNotes(TDF_LabelSequence& theNoteLabels) const;
+
+  //! Delete group.
+  //! \param [in] theGroupLabel - group label.
+  //! \return true if the group was successfully deleted, otherwise - false.
+  Standard_EXPORT Standard_Boolean DeleteGroup(const TDF_Label& theGroupLabel,
+                                               Standard_Boolean theDeleteNotes = Standard_False);
+
+  //! Delete all groups.
+  //! \return the number of deleted groups.
+  Standard_EXPORT Standard_Integer DeleteAllGroups(Standard_Boolean theDeleteNotes = Standard_False);
 
   //! @}
 
@@ -241,6 +374,15 @@ public:
   Standard_EXPORT Standard_Integer GetNotes(const TDF_Label&   theItemLabel,
                                             TDF_LabelSequence& theNoteLabels) const;
 
+  //! Gets all note labels of the note.
+  //! Notes linked to item's attributes aren't
+  //! taken into account. The label sequence isn't cleared beforehand.
+  //! \param [in] theNote        - note attribute.
+  //! \param [out] theNoteLabels - sequence of labels.
+  //! \return number of added labels.
+  Standard_EXPORT Standard_Integer GetNotes(const Handle(XCAFDoc_Note)& theNote,
+                                            TDF_LabelSequence&          theNoteLabels) const;
+
   //! Gets all note labels of the assembly item's attribute.
   //! Notes linked to the item itself or to item's subshapes
   //! aren't taken into account. The label sequence isn't cleared beforehand.
@@ -293,6 +435,13 @@ public:
   Standard_EXPORT Handle(XCAFDoc_AssemblyItemRef) AddNote(const TDF_Label& theNoteLabel,
                                                           const TDF_Label& theItemLabel);
 
+  //! Adds the given note to other note.
+  //! \param [in] theNoteLabel     - note label.
+  //! \param [in] theAnnotatedNote - other note attribute.
+  //! \return a handle to the assembly reference attribute.
+  Standard_EXPORT Handle(XCAFDoc_AssemblyItemRef) AddNote(const TDF_Label&            theNoteLabel,
+                                                          const Handle(XCAFDoc_Note)& theAnnotatedNote);
+
   //! Adds the given note to the assembly item's attribute.
   //! \param [in] theNoteLabel - note label.
   //! \param [in] theItemId    - assembly item ID.
@@ -335,7 +484,7 @@ public:
   //! @{
 
   //! Removes the given note from the assembly item.
-  //! \param [in] theNoteLabel   - note label.
+  //! \param [in] theNoteLabel   - label of the note to be removed.
   //! \param [in] theItemId      - assembly item ID.
   //! \param [in] theDelIfOrphan - deletes the note from the notes hive 
   //!                              if there are no more assembly items
@@ -346,7 +495,7 @@ public:
                                               Standard_Boolean              theDelIfOrphan = Standard_False);
 
   //! Removes the given note from the labeled item.
-  //! \param [in] theNoteLabel   - note label.
+  //! \param [in] theNoteLabel   - label of the note to be removed.
   //! \param [in] theItemLabel   - item label.
   //! \param [in] theDelIfOrphan - deletes the note from the notes hive 
   //!                              if there are no more labeled items
@@ -356,8 +505,19 @@ public:
                                               const TDF_Label& theItemLabel,
                                               Standard_Boolean theDelIfOrphan = Standard_False);
 
+  //! Removes the given note from other note.
+  //! \param [in] theNoteLabel    - label of the note to be removed.
+  //! \param [in] theNote         - note attribute.
+  //! \param [in] theDelIfOrphan  - deletes the note from the notes hive 
+  //!                               if there are no more labeled items
+  //!                               linked with the note.
+  //! \return true if the note is removed, otherwise - false.
+  Standard_EXPORT Standard_Boolean RemoveNote(const TDF_Label&            theNoteLabel,
+                                              const Handle(XCAFDoc_Note)& theNote,
+                                              Standard_Boolean            theDelIfOrphan = Standard_False);
+
   //! Removes the given note from the assembly item's subshape.
-  //! \param [in] theNoteLabel     - note label.
+  //! \param [in] theNoteLabel     - label of the note to be removed.
   //! \param [in] theItemId        - assembly item ID.
   //! \param [in] theSubshapeIndex - assembly item's subshape index.
   //! \param [in] theDelIfOrphan   - deletes the note from the notes hive 
@@ -370,7 +530,7 @@ public:
                                                       Standard_Boolean              theDelIfOrphan = Standard_False);
 
   //! Removes the given note from the labeled item's subshape.
-  //! \param [in] theNoteLabel     - note label.
+  //! \param [in] theNoteLabel     - label of the note to be removed.
   //! \param [in] theItemLabel     - item label.
   //! \param [in] theSubshapeIndex - labeled item's subshape index.
   //! \param [in] theDelIfOrphan   - deletes the note from the notes hive 
@@ -383,7 +543,7 @@ public:
                                                       Standard_Boolean theDelIfOrphan = Standard_False);
 
   //! Removes a note from the assembly item's attribute.
-  //! \param [in] theNoteLabel   - note label.
+  //! \param [in] theNoteLabel   - label of the note to be removed.
   //! \param [in] theItemId      - assembly item ID.
   //! \param [in] theGUID        - assembly item's attribute GUID.
   //! \param [in] theDelIfOrphan - deletes the note from the notes hive 
@@ -396,7 +556,7 @@ public:
                                                   Standard_Boolean              theDelIfOrphan = Standard_False);
 
   //! Removes a note from the labeled item's attribute.
-  //! \param [in] theNoteLabel   - note label.
+  //! \param [in] theNoteLabel   - label of the note to be removed.
   //! \param [in] theItemLabel   - item label.
   //! \param [in] theGUID        - labeled item's attribute GUID.
   //! \param [in] theDelIfOrphan - deletes the note from the notes hive 
@@ -426,6 +586,15 @@ public:
   Standard_EXPORT Standard_Boolean RemoveAllNotes(const TDF_Label& theItemLabel,
                                                   Standard_Boolean theDelIfOrphan = Standard_False);
 
+  //! Removes all notes from other note.
+  //! \param [in] theNote        - note attribute.
+  //! \param [in] theDelIfOrphan - deletes removed notes from the notes
+  //!                              hive if there are no more annotated items
+  //!                              linked with the notes.
+  //! \return true if the notes are removed, otherwise - false.
+  Standard_EXPORT Standard_Boolean RemoveAllNotes(const Handle(XCAFDoc_Note)& theNote,
+                                                  Standard_Boolean            theDelIfOrphan = Standard_False);
+
   //! Removes all notes from the assembly item's subshape.
   //! \param [in] theItemId        - assembly item ID.
   //! \param [in] theSubshapeIndex - assembly item's subshape index.
index 21ee24349ec8fba61a9ee4899e60ecccf7b5bb25..6b0f4696e17f4797b93acde601b131c7f95657f7 100644 (file)
@@ -16,6 +16,7 @@
 #include <DDocStd.hxx>
 #include <OSD_File.hxx>
 #include <OSD_Protection.hxx>
+#include <TColStd_HArray1OfByte.hxx>
 #include <TDocStd_Document.hxx>
 #include <TDF_Tool.hxx>
 #include <XCAFDoc_AssemblyItemRef.hxx>
@@ -417,11 +418,15 @@ noteCreateBinData(Draw_Interpretor& di, Standard_Integer argc, const char** argv
     OSD_Path aPath(aFilename);
     OSD_File aFile(aPath);
     aFile.Open(OSD_ReadOnly, OSD_Protection());
-    aNote = aNotesTool->CreateBinData(aUsername, aTimestamp, aTitle, aMIMEtype, aFile);
+    aNote = aNotesTool->CreateBinDataContainer(aUsername, aTimestamp);
+    Handle(XCAFDoc_NoteBinDataContainer) aCnt = XCAFDoc_NoteBinDataContainer::Get(aNote->Label());
+    aCnt->Add(aTitle, aMIMEtype, aFile);
   }
   else if (aFromData)
   {
-    aNote = aNotesTool->CreateBinData(aUsername, aTimestamp, aTitle, aMIMEtype, aData);
+    aNote = aNotesTool->CreateBinDataContainer(aUsername, aTimestamp);
+    Handle(XCAFDoc_NoteBinDataContainer) aCnt = XCAFDoc_NoteBinDataContainer::Get(aNote->Label());
+    aCnt->Add(aTitle, aMIMEtype, aData);
   }
   else
   {
@@ -1234,15 +1239,15 @@ noteDump(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
   di << "Username  : " << aNote->UserName() << "\n";
   di << "Timestamp : " << aNote->TimeStamp() << "\n";
   di << "Type      : " << aNote->get_type_name() << "\n";
-  if (Handle(XCAFDoc_NoteComment) aComment = Handle(XCAFDoc_NoteComment)::DownCast(aNote))
+  if (Handle(XCAFDoc_NoteComment) aComment = XCAFDoc_NoteComment::Get(aNote->Label()))
   {
-    di << "Comment   : " << aComment->Comment() << "\n";
+    di << "Comment   : " << aComment->Get() << "\n";
   }
-  else if (Handle(XCAFDoc_NoteBalloon) aBalloon = Handle(XCAFDoc_NoteBalloon)::DownCast(aNote))
+  else if (Handle(XCAFDoc_NoteBalloon) aBalloon = XCAFDoc_NoteBalloon::Get(aNote->Label()))
   {
-    di << "Comment   : " << aBalloon->Comment() << "\n";
+    di << "Comment   : " << aBalloon->Get() << "\n";
   }
-  else if (Handle(XCAFDoc_NoteBinData) aBinData = Handle(XCAFDoc_NoteBinData)::DownCast(aNote))
+  else if (Handle(XCAFDoc_NoteBinData) aBinData = XCAFDoc_NoteBinData::Get(aNote->Label()))
   {
     di << "Title     : " << aBinData->Title() << "\n";
     di << "MIME type : " << aBinData->MIMEtype() << "\n";
index 51f2d0f322bdd78c20390d956faa96523affac41..625a925e876b3fce205d86700de941a55395d773 100644 (file)
@@ -19,10 +19,6 @@ XmlMXCAFDoc_MaterialDriver.cxx
 XmlMXCAFDoc_MaterialDriver.hxx
 XmlMXCAFDoc_NoteDriver.cxx
 XmlMXCAFDoc_NoteDriver.hxx
-XmlMXCAFDoc_NoteCommentDriver.cxx
-XmlMXCAFDoc_NoteCommentDriver.hxx
-XmlMXCAFDoc_NoteBinDataDriver.cxx
-XmlMXCAFDoc_NoteBinDataDriver.hxx
 XmlMXCAFDoc_VisMaterialDriver.cxx
 XmlMXCAFDoc_VisMaterialDriver.hxx
 XmlMXCAFDoc_VisMaterialToolDriver.cxx
index 4d4cc1204eb09da2a1dcbd718ec76914d4c89ca1..5bed0d2dab6d8a6fee49cbf5caf7c4a3047573de 100644 (file)
@@ -28,8 +28,7 @@
 #include <XmlMXCAFDoc_LocationDriver.hxx>
 #include <XmlMXCAFDoc_MaterialDriver.hxx>
 #include <XmlMXCAFDoc_VisMaterialDriver.hxx>
-#include <XmlMXCAFDoc_NoteCommentDriver.hxx>
-#include <XmlMXCAFDoc_NoteBinDataDriver.hxx>
+#include <XmlMXCAFDoc_NoteDriver.hxx>
 #include <XmlMXCAFDoc_VisMaterialToolDriver.hxx>
 
 //=======================================================================
@@ -61,7 +60,6 @@ void XmlMXCAFDoc::AddDrivers (const Handle(XmlMDF_ADriverTable)& aDriverTable,
   aDriverTable -> AddDriver (new XmlMXCAFDoc_DimTolDriver     (anMsgDrv));
   aDriverTable -> AddDriver (new XmlMXCAFDoc_MaterialDriver   (anMsgDrv));
   aDriverTable -> AddDriver (new XmlMXCAFDoc_VisMaterialDriver(anMsgDrv));
-  aDriverTable -> AddDriver (new XmlMXCAFDoc_NoteCommentDriver(anMsgDrv));
-  aDriverTable -> AddDriver (new XmlMXCAFDoc_NoteBinDataDriver(anMsgDrv));
+  aDriverTable -> AddDriver (new XmlMXCAFDoc_NoteDriver       (anMsgDrv));
   aDriverTable -> AddDriver (new XmlMXCAFDoc_VisMaterialToolDriver (anMsgDrv));
 }
diff --git a/src/XmlMXCAFDoc/XmlMXCAFDoc_NoteBinDataDriver.cxx b/src/XmlMXCAFDoc/XmlMXCAFDoc_NoteBinDataDriver.cxx
deleted file mode 100644 (file)
index c7d64dd..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-// Created on: 2017-02-14
-// Created by: Sergey NIKONOV
-// Copyright (c) 2008-2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <Message_Messenger.hxx>
-#include <Standard_Type.hxx>
-#include <TDF_Attribute.hxx>
-#include <XCAFDoc_NoteBinData.hxx>
-#include <XmlObjMgt.hxx>
-#include <XmlMXCAFDoc_NoteBinDataDriver.hxx>
-#include <XmlObjMgt_Persistent.hxx>
-#include <LDOM_OSStream.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(XmlMXCAFDoc_NoteBinDataDriver, XmlMXCAFDoc_NoteDriver)
-IMPLEMENT_DOMSTRING(Title, "title")
-IMPLEMENT_DOMSTRING(MIMEtype, "mime_type")
-IMPLEMENT_DOMSTRING(Size, "size")
-
-//=======================================================================
-//function :
-//purpose  : 
-//=======================================================================
-XmlMXCAFDoc_NoteBinDataDriver::XmlMXCAFDoc_NoteBinDataDriver(const Handle(Message_Messenger)& theMsgDriver)
-  : XmlMXCAFDoc_NoteDriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_NoteBinData)->Name())
-{
-}
-
-//=======================================================================
-//function :
-//purpose  : 
-//=======================================================================
-Handle(TDF_Attribute) XmlMXCAFDoc_NoteBinDataDriver::NewEmpty() const
-{
-  return new XCAFDoc_NoteBinData();
-}
-
-//=======================================================================
-//function :
-//purpose  : 
-//=======================================================================
-Standard_Boolean XmlMXCAFDoc_NoteBinDataDriver::Paste(const XmlObjMgt_Persistent&  theSource,
-                                                      const Handle(TDF_Attribute)& theTarget,
-                                                      XmlObjMgt_RRelocationTable&  theRelocTable) const
-{
-  XmlMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable);
-
-  const XmlObjMgt_Element& anElement = theSource;
-
-  XmlObjMgt_DOMString aTitle = anElement.getAttribute(::Title());
-  XmlObjMgt_DOMString aMIMEtype = anElement.getAttribute(::MIMEtype());
-  XmlObjMgt_DOMString aSize = anElement.getAttribute(::Size());
-  if (aTitle == NULL || aMIMEtype == NULL || aSize == NULL)
-    return Standard_False;
-
-  Handle(XCAFDoc_NoteBinData) aNote = Handle(XCAFDoc_NoteBinData)::DownCast(theTarget);
-  if (aNote.IsNull())
-    return Standard_False;
-
-  Standard_Integer nbSize = 0;
-  if (!aSize.GetInteger(nbSize))
-    return Standard_False;
-
-  XmlObjMgt_DOMString aDataStr = XmlObjMgt::GetStringValue(theSource);
-  Standard_SStream anSS(aDataStr.GetString());
-
-  Handle(TColStd_HArray1OfByte) aData = new TColStd_HArray1OfByte(1, nbSize);
-  for (Standard_Integer i = 1; i <= nbSize; ++i)
-  {
-    Standard_Byte aValue;
-    anSS >> aValue;
-    aData->ChangeValue(i) = aValue;
-  }
-
-  aNote->Set(aTitle.GetString(), aMIMEtype.GetString(), aData);
-
-  return Standard_True;
-}
-
-//=======================================================================
-//function :
-//purpose  : 
-//=======================================================================
-void XmlMXCAFDoc_NoteBinDataDriver::Paste(const Handle(TDF_Attribute)& theSource,
-                                          XmlObjMgt_Persistent&        theTarget,
-                                          XmlObjMgt_SRelocationTable&  theRelocTable) const
-{
-  XmlMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable);
-
-  Handle(XCAFDoc_NoteBinData) aNote = Handle(XCAFDoc_NoteBinData)::DownCast(theSource);
-
-  XmlObjMgt_DOMString aTitle(TCollection_AsciiString(aNote->Title()).ToCString());
-  XmlObjMgt_DOMString aMIMEtype(aNote->MIMEtype().ToCString());
-
-  theTarget.Element().setAttribute(::Title(), aTitle);
-  theTarget.Element().setAttribute(::MIMEtype(), aMIMEtype);
-  theTarget.Element().setAttribute(::Size(), aNote->Size());
-
-  if (aNote->Size() > 0)
-  {
-    const Handle(TColStd_HArray1OfByte)& aData = aNote->Data();
-    LDOM_OSStream anOSS(aNote->Size());
-    for (Standard_Integer i = aData->Lower(); i <= aData->Upper(); ++i)
-    {
-      anOSS << std::hex << aData->Value(i);
-    }
-    Standard_Character* dump = (Standard_Character*)anOSS.str(); // copying! Don't forget to delete it.
-    XmlObjMgt::SetStringValue(theTarget, dump, Standard_True);
-    delete[] dump;
-  }
-}
diff --git a/src/XmlMXCAFDoc/XmlMXCAFDoc_NoteBinDataDriver.hxx b/src/XmlMXCAFDoc/XmlMXCAFDoc_NoteBinDataDriver.hxx
deleted file mode 100644 (file)
index c2d12f5..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-// Created on: 2017-02-14
-// Created by: Sergey NIKONOV
-// Copyright (c) 2008-2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _XmlMXCAFDoc_NoteBinDataDriver_HeaderFile
-#define _XmlMXCAFDoc_NoteBinDataDriver_HeaderFile
-
-#include <XmlMXCAFDoc_NoteDriver.hxx>
-
-class XmlMXCAFDoc_NoteBinDataDriver;
-DEFINE_STANDARD_HANDLE(XmlMXCAFDoc_NoteBinDataDriver, XmlMXCAFDoc_NoteDriver)
-
-//! Attribute Driver.
-class XmlMXCAFDoc_NoteBinDataDriver : public XmlMXCAFDoc_NoteDriver
-{
-public:
-
-  Standard_EXPORT XmlMXCAFDoc_NoteBinDataDriver(const Handle(Message_Messenger)& theMessageDriver);
-
-  Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
-
-  Standard_EXPORT Standard_Boolean Paste(const XmlObjMgt_Persistent&  theSource,
-                                         const Handle(TDF_Attribute)& theTarget,
-                                         XmlObjMgt_RRelocationTable&  theRelocTable) const Standard_OVERRIDE;
-
-  Standard_EXPORT void Paste(const Handle(TDF_Attribute)& theSource,
-                             XmlObjMgt_Persistent&        theTarget,
-                             XmlObjMgt_SRelocationTable&  theRelocTable) const Standard_OVERRIDE;
-
-  DEFINE_STANDARD_RTTIEXT(XmlMXCAFDoc_NoteBinDataDriver, XmlMXCAFDoc_NoteDriver)
-
-};
-
-#endif // _XmlMXCAFDoc_NoteBinDataDriver_HeaderFile
diff --git a/src/XmlMXCAFDoc/XmlMXCAFDoc_NoteCommentDriver.cxx b/src/XmlMXCAFDoc/XmlMXCAFDoc_NoteCommentDriver.cxx
deleted file mode 100644 (file)
index 8acb765..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-// Created on: 2017-02-14
-// Created by: Sergey NIKONOV
-// Copyright (c) 2008-2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <Message_Messenger.hxx>
-#include <Standard_Type.hxx>
-#include <TDF_Attribute.hxx>
-#include <XCAFDoc_NoteComment.hxx>
-#include <XmlMXCAFDoc_NoteCommentDriver.hxx>
-#include <XmlObjMgt_Persistent.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(XmlMXCAFDoc_NoteCommentDriver, XmlMXCAFDoc_NoteDriver)
-IMPLEMENT_DOMSTRING(Comment, "comment")
-
-//=======================================================================
-//function :
-//purpose  : 
-//=======================================================================
-XmlMXCAFDoc_NoteCommentDriver::XmlMXCAFDoc_NoteCommentDriver(const Handle(Message_Messenger)& theMsgDriver)
-  : XmlMXCAFDoc_NoteDriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_NoteComment)->Name())
-{
-}
-
-//=======================================================================
-//function :
-//purpose  : 
-//=======================================================================
-Handle(TDF_Attribute) XmlMXCAFDoc_NoteCommentDriver::NewEmpty() const
-{
-  return new XCAFDoc_NoteComment();
-}
-
-//=======================================================================
-//function :
-//purpose  : 
-//=======================================================================
-Standard_Boolean XmlMXCAFDoc_NoteCommentDriver::Paste(const XmlObjMgt_Persistent&  theSource,
-                                                      const Handle(TDF_Attribute)& theTarget,
-                                                      XmlObjMgt_RRelocationTable&  theRelocTable) const
-{
-  XmlMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable);
-
-  const XmlObjMgt_Element& anElement = theSource;
-
-  XmlObjMgt_DOMString aComment = anElement.getAttribute(::Comment());
-  if (aComment == NULL)
-    return Standard_False;
-
-  Handle(XCAFDoc_NoteComment) aNote = Handle(XCAFDoc_NoteComment)::DownCast(theTarget);
-  if (aNote.IsNull())
-    return Standard_False;
-
-  aNote->Set(aComment.GetString());
-
-  return Standard_True;
-}
-
-//=======================================================================
-//function :
-//purpose  : 
-//=======================================================================
-void XmlMXCAFDoc_NoteCommentDriver::Paste(const Handle(TDF_Attribute)& theSource,
-                                          XmlObjMgt_Persistent&        theTarget,
-                                          XmlObjMgt_SRelocationTable&  theRelocTable) const
-{
-  XmlMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable);
-
-  Handle(XCAFDoc_NoteComment) aNote = Handle(XCAFDoc_NoteComment)::DownCast(theSource);
-
-  XmlObjMgt_DOMString aComment(TCollection_AsciiString(aNote->TimeStamp()).ToCString());
-
-  theTarget.Element().setAttribute(::Comment(), aComment);
-}
-
-//=======================================================================
-//function :
-//purpose  : 
-//=======================================================================
-XmlMXCAFDoc_NoteCommentDriver::XmlMXCAFDoc_NoteCommentDriver(const Handle(Message_Messenger)& theMsgDriver,
-                                                             Standard_CString                 theName)
-  : XmlMXCAFDoc_NoteDriver(theMsgDriver, theName)
-{
-
-}
diff --git a/src/XmlMXCAFDoc/XmlMXCAFDoc_NoteCommentDriver.hxx b/src/XmlMXCAFDoc/XmlMXCAFDoc_NoteCommentDriver.hxx
deleted file mode 100644 (file)
index cfeaa74..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-// Created on: 2017-02-14
-// Created by: Sergey NIKONOV
-// Copyright (c) 2008-2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _XmlMXCAFDoc_NoteCommentDriver_HeaderFile
-#define _XmlMXCAFDoc_NoteCommentDriver_HeaderFile
-
-#include <XmlMXCAFDoc_NoteDriver.hxx>
-
-class XmlMXCAFDoc_NoteCommentDriver;
-DEFINE_STANDARD_HANDLE(XmlMXCAFDoc_NoteCommentDriver, XmlMXCAFDoc_NoteDriver)
-
-//! Attribute Driver.
-class XmlMXCAFDoc_NoteCommentDriver : public XmlMXCAFDoc_NoteDriver
-{
-public:
-
-  Standard_EXPORT XmlMXCAFDoc_NoteCommentDriver(const Handle(Message_Messenger)& theMessageDriver);
-
-  Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
-
-  Standard_EXPORT Standard_Boolean Paste(const XmlObjMgt_Persistent&  theSource,
-                                         const Handle(TDF_Attribute)& theTarget,
-                                         XmlObjMgt_RRelocationTable&  theRelocTable) const Standard_OVERRIDE;
-
-  Standard_EXPORT void Paste(const Handle(TDF_Attribute)& theSource,
-                             XmlObjMgt_Persistent&        theTarget,
-                             XmlObjMgt_SRelocationTable&  theRelocTable) const Standard_OVERRIDE;
-
-  DEFINE_STANDARD_RTTIEXT(XmlMXCAFDoc_NoteCommentDriver, XmlMXCAFDoc_NoteDriver)
-
-protected:
-
-  XmlMXCAFDoc_NoteCommentDriver(const Handle(Message_Messenger)& theMsgDriver,
-                                Standard_CString                 theName);
-
-};
-
-#endif // _XmlMXCAFDoc_NoteCommentDriver_HeaderFile
index 450806e7e6e31c5916aded8fcc0ec0e735c568f4..7db29fa57629ffcfbd03ba621511ec45ddc88763 100644 (file)
@@ -24,6 +24,24 @@ IMPLEMENT_STANDARD_RTTIEXT(XmlMXCAFDoc_NoteDriver, XmlMDF_ADriver)
 IMPLEMENT_DOMSTRING(UserName, "user_name")
 IMPLEMENT_DOMSTRING(TimeStamp, "time_stamp")
 
+//=======================================================================
+//function :
+//purpose  : 
+//=======================================================================
+XmlMXCAFDoc_NoteDriver::XmlMXCAFDoc_NoteDriver(const Handle(Message_Messenger)& theMsgDriver)
+: XmlMDF_ADriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_Note)->Name())
+{
+}
+
+//=======================================================================
+//function :
+//purpose  : 
+//=======================================================================
+Handle(TDF_Attribute) XmlMXCAFDoc_NoteDriver::NewEmpty() const
+{
+  return new XCAFDoc_Note();
+}
+
 //=======================================================================
 //function :
 //purpose  : 
index 3f8231b57fdc61afbec3d40e4cea7f2d5b687b94..b0411ba79fe8e4bc96e560ec380ee8b634a6777f 100644 (file)
@@ -36,13 +36,17 @@ class XmlMXCAFDoc_NoteDriver : public XmlMDF_ADriver
 {
 public:
 
+  Standard_EXPORT XmlMXCAFDoc_NoteDriver(const Handle(Message_Messenger)& theMessageDriver);
+
+  Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
+
   Standard_EXPORT Standard_Boolean Paste(const XmlObjMgt_Persistent&  theSource,
-    const Handle(TDF_Attribute)& theTarget,
-    XmlObjMgt_RRelocationTable&  theRelocTable) const Standard_OVERRIDE;
+                                         const Handle(TDF_Attribute)& theTarget,
+                                         XmlObjMgt_RRelocationTable&  theRelocTable) const Standard_OVERRIDE;
 
   Standard_EXPORT void Paste(const Handle(TDF_Attribute)& theSource,
-    XmlObjMgt_Persistent&        theTarget,
-    XmlObjMgt_SRelocationTable&  theRelocTable) const Standard_OVERRIDE;
+                             XmlObjMgt_Persistent&        theTarget,
+                             XmlObjMgt_SRelocationTable&  theRelocTable) const Standard_OVERRIDE;
 
   DEFINE_STANDARD_RTTIEXT(XmlMXCAFDoc_NoteDriver, XmlMDF_ADriver)