]> OCCT Git - occt-copy.git/commitdiff
refs #1050: Add possibility to attach multiple files to notes
authorsnn <snn@opencascade.com>
Thu, 13 Jun 2019 11:39:29 +0000 (14:39 +0300)
committerdbv <dmitry.bobylev@opencascade.com>
Thu, 19 Sep 2019 10:50:05 +0000 (13:50 +0300)
35 files changed:
src/BinMXCAFDoc/BinMXCAFDoc.cxx
src/BinMXCAFDoc/BinMXCAFDoc_NoteBalloonDriver.cxx
src/BinMXCAFDoc/BinMXCAFDoc_NoteBalloonDriver.hxx
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_NoteBalloonDriver.cxx
src/XmlMXCAFDoc/XmlMXCAFDoc_NoteBalloonDriver.hxx
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 28b13c5abbaf35186dc921c8260bc0f955a1858c..a04776bd7f0166f192378c04f230efc2cfe86f75 100644 (file)
@@ -35,8 +35,6 @@
 #include <BinMXCAFDoc_MaterialToolDriver.hxx>
 #include <BinMXCAFDoc_NoteDriver.hxx>
 #include <BinMXCAFDoc_NoteBalloonDriver.hxx>
-#include <BinMXCAFDoc_NoteBinDataDriver.hxx>
-#include <BinMXCAFDoc_NoteCommentDriver.hxx>
 #include <BinMXCAFDoc_NotesToolDriver.hxx>
 #include <BinMXCAFDoc_ShapeToolDriver.hxx>
 #include <BinMXCAFDoc_ViewDriver.hxx>
@@ -78,8 +76,7 @@ void BinMXCAFDoc::AddDrivers(const Handle(BinMDF_ADriverTable)& theDriverTable,
   theDriverTable->AddDriver( new BinMXCAFDoc_DimTolDriver      (theMsgDrv));
   theDriverTable->AddDriver( new BinMXCAFDoc_MaterialDriver    (theMsgDrv));
   theDriverTable->AddDriver( new BinMXCAFDoc_NoteBalloonDriver (theMsgDrv));
-  theDriverTable->AddDriver( new BinMXCAFDoc_NoteBinDataDriver (theMsgDrv));
-  theDriverTable->AddDriver( new BinMXCAFDoc_NoteCommentDriver (theMsgDrv));
+  theDriverTable->AddDriver( new BinMXCAFDoc_NoteDriver        (theMsgDrv)); 
   theDriverTable->AddDriver( new BinMXCAFDoc_ViewDriver        (theMsgDrv));
 
   theDriverTable->AddDriver( new BinMXCAFDoc_ColorToolDriver   (theMsgDrv));
index cf7bf921808b83beadc920a4ff3865ffbe15481c..cdcaefa3be47847f00d6b4539544dd21b8837eb9 100644 (file)
 #include <BinMXCAFDoc_NoteBalloonDriver.hxx>
 #include <XCAFDoc_NoteBalloon.hxx>
 
-IMPLEMENT_STANDARD_RTTIEXT(BinMXCAFDoc_NoteBalloonDriver, BinMXCAFDoc_NoteCommentDriver)
+IMPLEMENT_STANDARD_RTTIEXT(BinMXCAFDoc_NoteBalloonDriver, BinMXCAFDoc_NoteDriver)
 
 //=======================================================================
 //function :
 //purpose  : 
 //=======================================================================
 BinMXCAFDoc_NoteBalloonDriver::BinMXCAFDoc_NoteBalloonDriver(const Handle(Message_Messenger)& theMsgDriver)
-  : BinMXCAFDoc_NoteCommentDriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_NoteBalloon)->Name())
+  : BinMXCAFDoc_NoteDriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_NoteBalloon)->Name())
 {
 }
 
@@ -40,13 +40,52 @@ Handle(TDF_Attribute) BinMXCAFDoc_NoteBalloonDriver::NewEmpty() const
   return new XCAFDoc_NoteBalloon();
 }
 
+//=======================================================================
+//function :
+//purpose  : 
+//=======================================================================
+Standard_Boolean BinMXCAFDoc_NoteBalloonDriver::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_NoteBalloon) aNote = Handle(XCAFDoc_NoteBalloon)::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_NoteBalloonDriver::Paste(const Handle(TDF_Attribute)& theSource,
+                                          BinObjMgt_Persistent&        theTarget,
+                                          BinObjMgt_SRelocationTable&  theRelocTable) const
+{
+  BinMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable);
+
+  Handle(XCAFDoc_NoteBalloon) aNote = Handle(XCAFDoc_NoteBalloon)::DownCast(theSource);
+  if (!aNote.IsNull())
+    theTarget << aNote->Get();
+}
+
 //=======================================================================
 //function :
 //purpose  : 
 //=======================================================================
 BinMXCAFDoc_NoteBalloonDriver::BinMXCAFDoc_NoteBalloonDriver(const Handle(Message_Messenger)& theMsgDriver,
                                                              Standard_CString                 theName)
-  : BinMXCAFDoc_NoteCommentDriver(theMsgDriver, theName)
+  : BinMXCAFDoc_NoteDriver(theMsgDriver, theName)
 {
 
 }
index 516f3a7f0412bff74e20fe7bc7150c1bd7fd0d3f..d57a8cf6663b7e33eb7e63e829d724de444a33c8 100644 (file)
 #ifndef _BinMXCAFDoc_NoteBalloonDriver_HeaderFile
 #define _BinMXCAFDoc_NoteBalloonDriver_HeaderFile
 
-#include <BinMXCAFDoc_NoteCommentDriver.hxx>
+#include <BinMXCAFDoc_NoteDriver.hxx>
 
 class BinMXCAFDoc_NoteBalloonDriver;
-DEFINE_STANDARD_HANDLE(BinMXCAFDoc_NoteBalloonDriver, BinMXCAFDoc_NoteCommentDriver)
+DEFINE_STANDARD_HANDLE(BinMXCAFDoc_NoteBalloonDriver, BinMXCAFDoc_NoteDriver)
 
-class BinMXCAFDoc_NoteBalloonDriver : public BinMXCAFDoc_NoteCommentDriver
+class BinMXCAFDoc_NoteBalloonDriver : public BinMXCAFDoc_NoteDriver
 {
 public:
   
   Standard_EXPORT BinMXCAFDoc_NoteBalloonDriver(const Handle(Message_Messenger)& theMsgDriver);
   
   Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
-  
-  DEFINE_STANDARD_RTTIEXT(BinMXCAFDoc_NoteBalloonDriver, BinMXCAFDoc_NoteCommentDriver)
+
+  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_NoteBalloonDriver, BinMXCAFDoc_NoteDriver)
 
 
 protected:
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 cd756fb05986fa81a522418216297d4c3456f018..19755159f38fbadf87607ba9ca9ad81985819e71 100644 (file)
@@ -39,10 +39,6 @@ BinMXCAFDoc_NoteDriver.cxx
 BinMXCAFDoc_NoteDriver.hxx
 BinMXCAFDoc_NoteBalloonDriver.cxx
 BinMXCAFDoc_NoteBalloonDriver.hxx
-BinMXCAFDoc_NoteCommentDriver.cxx
-BinMXCAFDoc_NoteCommentDriver.hxx
-BinMXCAFDoc_NoteBinDataDriver.cxx
-BinMXCAFDoc_NoteBinDataDriver.hxx
 BinMXCAFDoc_NotesToolDriver.cxx
 BinMXCAFDoc_NotesToolDriver.hxx
 BinMXCAFDoc_ShapeToolDriver.cxx
index 032ce30e82102212ba53c2603c0cddd55f94fb01..bd6a1d623602f3ad52cd156b0b047d0e2c1121d4 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>
 
 XCAFDoc_AssemblyItemId::XCAFDoc_AssemblyItemId()
@@ -122,3 +123,15 @@ XCAFDoc_AssemblyItemId::ToString() const
   aStr.Remove(1, 1);
   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;
+}
index 67a4024830ddd6df0fec8b0a8252695d4920d284..da41dc66b9763737232a9480a26848628e183117 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 
@@ -77,6 +78,9 @@ public:
   //! Returns the full pass as a formatted string.
   Standard_EXPORT TCollection_AsciiString ToString() const;
 
+  //! Returns the last label in the path
+  Standard_EXPORT TDF_Label GetLabel(const Handle(TDF_Data)& aDF) const;
+
   struct Hasher
   {
 
index 9059998e78a6b37a213f78e2677587eef360af2a..bf7b0ae3664e06c7312930c470de0f190d345b15 100644 (file)
@@ -176,6 +176,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 9f4eb60540778a202036948135dccc613707c06b..82474ab4305c728d218c4e9e1fd8764835ec9244 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 f4ab611c878f16cfdbc5e6f48f237c0a0ac65747..7373e719af1238b092962de30ebb72a33b855cae 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 16a77fa929a4540f094ff631822bb00ae0feb413..0f11b59ad714c2417dad8a0a11dbd317979a6615 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,19 +76,27 @@ 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;
   Standard_EXPORT Standard_OStream& Dump(Standard_OStream& theOS) 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 559d4eaffc60eba7aefe422dc89fb1f1bd6e3d8a..3d20ae545b992c422fc5486048047c993754ef29 100644 (file)
@@ -15,7 +15,7 @@
 #include <TDF_Label.hxx>
 #include <XCAFDoc_NoteBalloon.hxx>
 
-IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_NoteBalloon, XCAFDoc_NoteComment)
+IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_NoteBalloon, XCAFDoc_Note)
 
 // =======================================================================
 // function : GetID
@@ -55,7 +55,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;
@@ -69,6 +69,18 @@ XCAFDoc_NoteBalloon::XCAFDoc_NoteBalloon()
 {
 }
 
+// =======================================================================
+// function : Set
+// purpose  :
+// =======================================================================
+void
+XCAFDoc_NoteBalloon::Set(const TCollection_ExtendedString& theComment)
+{
+  Backup();
+
+  myComment = theComment;
+}
+
 // =======================================================================
 // function : ID
 // purpose  :
index 7a48c1686fcf2408ec57f8b2798ca688c6c727fc..35b482432f10e3d229247d212fae2d855997e3cc 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_STANDARD_RTTIEXT(XCAFDoc_NoteBalloon, XCAFDoc_NoteComment)
+  DEFINE_STANDARD_RTTIEXT(XCAFDoc_NoteBalloon, XCAFDoc_Note)
 
   //! Returns default attribute GUID
   Standard_EXPORT static const Standard_GUID& GetID();
@@ -43,12 +43,22 @@ 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;
   Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
 
+private:
+
+  TCollection_ExtendedString myComment;
+
 };
 
 DEFINE_STANDARD_HANDLE(XCAFDoc_NoteBalloon, XCAFDoc_NoteComment)
index c8bb3e3f980d041a067da8bf3e4619906b7879d3..61efed9b2c0d283fef236dd6f80a2f3538f2bb3d 100644 (file)
 // commercial license or contractual agreement.
 
 #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>
 #include <XCAFDoc_NoteBinData.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  :
@@ -36,9 +198,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);
 }
 
 // =======================================================================
@@ -47,23 +219,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);
 }
 
 // =======================================================================
@@ -72,28 +250,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)
 {
 }
 
@@ -106,22 +287,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;
 }
@@ -135,83 +312,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 1d1cb99e421a805ddcb36b20f0f3faee9bcd0ba0..7e4501cd5148140edc85554b1541b817d07cc000 100644 (file)
 // commercial license or contractual agreement.
 
 #include <Standard_GUID.hxx>
-#include <TDF_Label.hxx>
+#include <TDataStd_Comment.hxx>
+#include <XCAFDoc_Note.hxx>
 #include <XCAFDoc_NoteComment.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
@@ -35,9 +25,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);
 }
 
 // =======================================================================
@@ -46,26 +41,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)
 {
 }
 
@@ -76,70 +65,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 fe971ac8eb5874c83fdfea0f5d69ba91aba2a698..0a7aae76d0fa0048edb86b29e5f6c869d7c30cd1 100644 (file)
 #include <TDF_LabelSequence.hxx>
 #include <TDF_Tool.hxx>
 #include <XCAFDoc.hxx>
+#include <XCAFDoc_AssemblyItemRef.hxx>
 #include <XCAFDoc_GraphNode.hxx>
+#include <XCAFDoc_Note.hxx>
 #include <XCAFDoc_NotesTool.hxx>
-#include <XCAFDoc_NoteBalloon.hxx>
 #include <XCAFDoc_NoteComment.hxx>
+#include <XCAFDoc_NoteBalloon.hxx>
 #include <XCAFDoc_NoteBinData.hxx>
-#include <XCAFDoc_AssemblyItemRef.hxx>
 
 namespace {
 
@@ -142,11 +143,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 : GetNotes
+// 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() && !anItemRef->HasExtraRef())
+      {
+        TDF_Label anAnnotatedLabel = anItemRef->GetItemLabel();
+        if (!anAnnotatedLabel.IsNull() && !XCAFDoc_Note::IsMine(anAnnotatedLabel))
+        {
+          theNoteLabels.Append(aLabel);
+          break;
+        }
+      }
+    }
+  }
+}
+
 // =======================================================================
 // function : GetAnnotatedItems
 // purpose  :
@@ -180,6 +225,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  :
@@ -265,50 +320,67 @@ XCAFDoc_NotesTool::FindAnnotatedItemSubshape(const TDF_Label& theItemLabel,
 }
 
 // =======================================================================
-// function : CreateComment
+// 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::CreateComment(const TCollection_ExtendedString& theUserName,
-                                 const TCollection_ExtendedString& theTimeStamp,
-                                 const TCollection_ExtendedString& theComment)
+XCAFDoc_NotesTool::Create(const TCollection_ExtendedString& theUserName,
+                          const TCollection_ExtendedString& theTimeStamp)
 {
   TDF_Label aNoteLabel;
   TDF_TagSource aTag;
   aNoteLabel = aTag.NewChild(GetNotesLabel());
-  return XCAFDoc_NoteComment::Set(aNoteLabel, theUserName, theTimeStamp, theComment);
+  return XCAFDoc_Note::Set(aNoteLabel, theUserName, theTimeStamp);
 }
 
 // =======================================================================
-// function : CreateBalloon
+// function : CreateComment
 // purpose  :
 // =======================================================================
 Handle(XCAFDoc_Note)
-XCAFDoc_NotesTool::CreateBalloon(const TCollection_ExtendedString& theUserName,
+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_NoteBalloon::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;
 }
 
 // =======================================================================
-// function : CreateBinData
+// function : CreateBalloon
 // purpose  :
 // =======================================================================
 Handle(XCAFDoc_Note)
-XCAFDoc_NotesTool::CreateBinData(const TCollection_ExtendedString& theUserName,
+XCAFDoc_NotesTool::CreateBalloon(const TCollection_ExtendedString& theUserName,
                                  const TCollection_ExtendedString& theTimeStamp,
-                                 const TCollection_ExtendedString& theTitle,
-                                 const TCollection_AsciiString&    theMIMEtype,
-                                 OSD_File&                         theFile)
+                                 const TCollection_ExtendedString& theComment)
 {
   TDF_Label aNoteLabel;
   TDF_TagSource aTag;
   aNoteLabel = aTag.NewChild(GetNotesLabel());
-  return XCAFDoc_NoteBinData::Set(aNoteLabel, theUserName, theTimeStamp, theTitle, theMIMEtype, theFile);
+  return XCAFDoc_NoteBalloon::Set(aNoteLabel, theUserName, theTimeStamp, theComment);
 }
 
 // =======================================================================
@@ -316,16 +388,23 @@ XCAFDoc_NotesTool::CreateBinData(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,
-                                 const Handle(TColStd_HArray1OfByte)& theData)
+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, theData);
+  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;
 }
 
 // =======================================================================
@@ -354,6 +433,17 @@ XCAFDoc_NotesTool::GetNotes(const XCAFDoc_AssemblyItemId& theItemId,
   return theNoteLabels.Length();
 }
 
+// =======================================================================
+// 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;
+}
+
 // =======================================================================
 // function : GetNotes
 // purpose  :
@@ -493,6 +583,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  :
@@ -673,6 +774,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  :
@@ -817,6 +930,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  :
index 7480d134fd19ace3c85d8537cba670896f1bc4f3..3a92795bca216887589f865894613618a558ae26 100644 (file)
@@ -105,6 +105,12 @@ public:
   //! \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.
@@ -120,6 +126,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 +144,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 +182,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 +211,13 @@ 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).
-  //! \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);
-
-  //! 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).
+  //! 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     - 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);
+  Standard_EXPORT Handle(XCAFDoc_Note) CreateBinDataContainer(const TCollection_ExtendedString& theUserName,
+                                                              const TCollection_ExtendedString& theTimeStamp);
 
   //! @}
 
@@ -241,6 +242,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 +303,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 +352,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 +363,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 +373,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 +398,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 +411,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 +424,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 +454,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 42a90f4d8919100f7b40a592f1db62e8742909b1..e40a0d6e805e5cff2c6d02b77939b8f91a165cf3 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 65a07bf988fa4b0ddecf370b46a5b3d14583678d..dc54a7ae871007215ca900a18655c454df5ae7b5 100644 (file)
@@ -35,10 +35,6 @@ XmlMXCAFDoc_NoteDriver.cxx
 XmlMXCAFDoc_NoteDriver.hxx
 XmlMXCAFDoc_NoteBalloonDriver.cxx
 XmlMXCAFDoc_NoteBalloonDriver.hxx
-XmlMXCAFDoc_NoteCommentDriver.cxx
-XmlMXCAFDoc_NoteCommentDriver.hxx
-XmlMXCAFDoc_NoteBinDataDriver.cxx
-XmlMXCAFDoc_NoteBinDataDriver.hxx
 XmlMXCAFDoc_NotesToolDriver.cxx
 XmlMXCAFDoc_NotesToolDriver.hxx
 XmlMXCAFDoc_ShapeToolDriver.cxx
index 0ffa311b088acbc8a3db3ac748404d73ac7dc622..6d8c501ff8b61d7980fdebdddc6066a708e41955 100644 (file)
 #include <XmlMXCAFDoc_LayerToolDriver.hxx>
 #include <XmlMXCAFDoc_LocationDriver.hxx>
 #include <XmlMXCAFDoc_MaterialDriver.hxx>
+#include <XmlMXCAFDoc_NoteDriver.hxx>
 #include <XmlMXCAFDoc_NotesToolDriver.hxx>
 #include <XmlMXCAFDoc_NoteBalloonDriver.hxx>
-#include <XmlMXCAFDoc_NoteCommentDriver.hxx>
-#include <XmlMXCAFDoc_NoteBinDataDriver.hxx>
 #include <XmlMXCAFDoc_MaterialToolDriver.hxx>
 #include <XmlMXCAFDoc_ShapeToolDriver.hxx>
 #include <XmlMXCAFDoc_ViewToolDriver.hxx>
@@ -73,8 +72,7 @@ void XmlMXCAFDoc::AddDrivers (const Handle(XmlMDF_ADriverTable)& aDriverTable,
   aDriverTable -> AddDriver (new XmlMXCAFDoc_DimTolDriver     (anMsgDrv));
   aDriverTable -> AddDriver (new XmlMXCAFDoc_MaterialDriver   (anMsgDrv));
   aDriverTable -> AddDriver (new XmlMXCAFDoc_NoteBalloonDriver(anMsgDrv));
-  aDriverTable -> AddDriver (new XmlMXCAFDoc_NoteCommentDriver(anMsgDrv));
-  aDriverTable -> AddDriver (new XmlMXCAFDoc_NoteBinDataDriver(anMsgDrv));
+  aDriverTable -> AddDriver (new XmlMXCAFDoc_NoteDriver       (anMsgDrv));
 
   aDriverTable -> AddDriver (new XmlMXCAFDoc_ColorToolDriver    (anMsgDrv));
   aDriverTable -> AddDriver (new XmlMXCAFDoc_DocumentToolDriver (anMsgDrv));
index 3e3ccec86c5e5aaabd7e1ac3d1b49cb83b9cb0d7..2a4a55cb8d3ccc7c37f455d8652a28d676286e0a 100644 (file)
 #include <XmlMXCAFDoc_NoteBalloonDriver.hxx>
 #include <XmlObjMgt_Persistent.hxx>
 
-IMPLEMENT_STANDARD_RTTIEXT(XmlMXCAFDoc_NoteBalloonDriver, XmlMXCAFDoc_NoteCommentDriver)
+IMPLEMENT_STANDARD_RTTIEXT(XmlMXCAFDoc_NoteBalloonDriver, XmlMXCAFDoc_NoteDriver)
+IMPLEMENT_DOMSTRING(Comment, "comment")
 
 //=======================================================================
 //function :
 //purpose  : 
 //=======================================================================
 XmlMXCAFDoc_NoteBalloonDriver::XmlMXCAFDoc_NoteBalloonDriver(const Handle(Message_Messenger)& theMsgDriver)
-  : XmlMXCAFDoc_NoteCommentDriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_NoteBalloon)->Name())
+  : XmlMXCAFDoc_NoteDriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_NoteBalloon)->Name())
 {
 }
 
@@ -40,13 +41,55 @@ Handle(TDF_Attribute) XmlMXCAFDoc_NoteBalloonDriver::NewEmpty() const
   return new XCAFDoc_NoteBalloon();
 }
 
+//=======================================================================
+//function :
+//purpose  : 
+//=======================================================================
+Standard_Boolean XmlMXCAFDoc_NoteBalloonDriver::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_NoteBalloon) aNote = Handle(XCAFDoc_NoteBalloon)::DownCast(theTarget);
+  if (aNote.IsNull())
+    return Standard_False;
+
+  aNote->Set(aComment.GetString());
+
+  return Standard_True;
+}
+
+//=======================================================================
+//function :
+//purpose  : 
+//=======================================================================
+void XmlMXCAFDoc_NoteBalloonDriver::Paste(const Handle(TDF_Attribute)& theSource,
+                                          XmlObjMgt_Persistent&        theTarget,
+                                          XmlObjMgt_SRelocationTable&  theRelocTable) const
+{
+  XmlMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable);
+
+  Handle(XCAFDoc_NoteBalloon) aNote = Handle(XCAFDoc_NoteBalloon)::DownCast(theSource);
+
+  XmlObjMgt_DOMString aComment(TCollection_AsciiString(aNote->TimeStamp()).ToCString());
+
+  theTarget.Element().setAttribute(::Comment(), aComment);
+}
+
 //=======================================================================
 //function :
 //purpose  : 
 //=======================================================================
 XmlMXCAFDoc_NoteBalloonDriver::XmlMXCAFDoc_NoteBalloonDriver(const Handle(Message_Messenger)& theMsgDriver,
                                                              Standard_CString                 theName)
-  : XmlMXCAFDoc_NoteCommentDriver(theMsgDriver, theName)
+  : XmlMXCAFDoc_NoteDriver(theMsgDriver, theName)
 {
 
 }
index 576c6c1725e1e72e5e8df2fc68a07c1213de03c2..1ca0fc1b896f5a35bb19e6e899007e2184dac3e8 100644 (file)
 #ifndef _XmlMXCAFDoc_NoteBalloonDriver_HeaderFile
 #define _XmlMXCAFDoc_NoteBalloonDriver_HeaderFile
 
-#include <XmlMXCAFDoc_NoteCommentDriver.hxx>
+#include <XmlMXCAFDoc_NoteDriver.hxx>
 
 class XmlMXCAFDoc_NoteBalloonDriver;
-DEFINE_STANDARD_HANDLE(XmlMXCAFDoc_NoteBalloonDriver, XmlMXCAFDoc_NoteCommentDriver)
+DEFINE_STANDARD_HANDLE(XmlMXCAFDoc_NoteBalloonDriver, XmlMXCAFDoc_NoteDriver)
 
 //! Attribute Driver.
-class XmlMXCAFDoc_NoteBalloonDriver : public XmlMXCAFDoc_NoteCommentDriver
+class XmlMXCAFDoc_NoteBalloonDriver : public XmlMXCAFDoc_NoteDriver
 {
 public:
 
@@ -30,7 +30,15 @@ public:
 
   Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
 
-  DEFINE_STANDARD_RTTIEXT(XmlMXCAFDoc_NoteBalloonDriver, XmlMXCAFDoc_NoteCommentDriver)
+  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_NoteBalloonDriver, XmlMXCAFDoc_NoteDriver)
 
 protected:
 
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)