]> OCCT Git - occt-copy.git/commitdiff
XCAF: comment and bin data note attributes added
authorsnn <snn@opencascade.com>
Mon, 13 Feb 2017 14:38:09 +0000 (17:38 +0300)
committersnn <snn@opencascade.com>
Thu, 16 Feb 2017 06:34:54 +0000 (09:34 +0300)
19 files changed:
src/BinMXCAFDoc/BinMXCAFDoc.cxx
src/BinMXCAFDoc/BinMXCAFDoc_NoteBinDataDriver.cxx [new file with mode: 0644]
src/BinMXCAFDoc/BinMXCAFDoc_NoteBinDataDriver.hxx [new file with mode: 0644]
src/BinMXCAFDoc/BinMXCAFDoc_NoteCommentDriver.cxx [new file with mode: 0644]
src/BinMXCAFDoc/BinMXCAFDoc_NoteCommentDriver.hxx [new file with mode: 0644]
src/BinMXCAFDoc/BinMXCAFDoc_NoteDriver.cxx
src/BinMXCAFDoc/BinMXCAFDoc_NoteDriver.hxx
src/BinMXCAFDoc/FILES
src/XCAFDoc/FILES
src/XCAFDoc/XCAFDoc.cxx
src/XCAFDoc/XCAFDoc.hxx
src/XCAFDoc/XCAFDoc_Note.cxx
src/XCAFDoc/XCAFDoc_Note.hxx
src/XCAFDoc/XCAFDoc_NoteBinData.cxx [new file with mode: 0644]
src/XCAFDoc/XCAFDoc_NoteBinData.hxx [new file with mode: 0644]
src/XCAFDoc/XCAFDoc_NoteComment.cxx [new file with mode: 0644]
src/XCAFDoc/XCAFDoc_NoteComment.hxx [new file with mode: 0644]
src/XCAFDoc/XCAFDoc_NotesTool.cxx
src/XCAFDoc/XCAFDoc_NotesTool.hxx

index 5e9c340dc66f88024910fcb4e7dc51759e653832..5a978706575287cd0fb54197e2cccad41d9b0560 100644 (file)
@@ -33,6 +33,8 @@
 #include <BinMXCAFDoc_MaterialDriver.hxx>
 #include <BinMXCAFDoc_MaterialToolDriver.hxx>
 #include <BinMXCAFDoc_NoteDriver.hxx>
+#include <BinMXCAFDoc_NoteBinDataDriver.hxx>
+#include <BinMXCAFDoc_NoteCommentDriver.hxx>
 #include <BinMXCAFDoc_NotesToolDriver.hxx>
 #include <BinMXCAFDoc_ShapeToolDriver.hxx>
 #include <BinMXCAFDoc_ViewDriver.hxx>
@@ -73,7 +75,9 @@ void BinMXCAFDoc::AddDrivers(const Handle(BinMDF_ADriverTable)& theDriverTable,
   theDriverTable->AddDriver( new BinMXCAFDoc_DimTolDriver      (theMsgDrv));
   theDriverTable->AddDriver( new BinMXCAFDoc_MaterialDriver    (theMsgDrv));
   theDriverTable->AddDriver( new BinMXCAFDoc_NoteDriver        (theMsgDrv));
-  theDriverTable->AddDriver(new BinMXCAFDoc_ViewDriver         (theMsgDrv));
+  theDriverTable->AddDriver( new BinMXCAFDoc_NoteBinDataDriver (theMsgDrv));
+  theDriverTable->AddDriver( new BinMXCAFDoc_NoteCommentDriver (theMsgDrv));
+  theDriverTable->AddDriver (new BinMXCAFDoc_ViewDriver        (theMsgDrv));
 
   theDriverTable->AddDriver( new BinMXCAFDoc_ColorToolDriver   (theMsgDrv));
   theDriverTable->AddDriver( new BinMXCAFDoc_DocumentToolDriver(theMsgDrv));
diff --git a/src/BinMXCAFDoc/BinMXCAFDoc_NoteBinDataDriver.cxx b/src/BinMXCAFDoc/BinMXCAFDoc_NoteBinDataDriver.cxx
new file mode 100644 (file)
index 0000000..f7dce26
--- /dev/null
@@ -0,0 +1,85 @@
+// 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 <CDM_MessageDriver.hxx>
+#include <Standard_Type.hxx>
+#include <TDF_Attribute.hxx>
+#include <TCollection_HAsciiString.hxx>
+#include <BinMXCAFDoc_NoteBinDataDriver.hxx>
+#include <XCAFDoc_NoteBinData.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(BinMXCAFDoc_NoteBinDataDriver, BinMXCAFDoc_NoteDriver)
+
+//=======================================================================
+//function :
+//purpose  : 
+//=======================================================================
+BinMXCAFDoc_NoteBinDataDriver::BinMXCAFDoc_NoteBinDataDriver(const Handle(CDM_MessageDriver)& 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) aNoteBinData = Handle(XCAFDoc_NoteBinData)::DownCast(theTarget);
+
+  TCollection_AsciiString aData, aMIMEtype;
+  if (!(theSource >> aData >> aMIMEtype))
+    return Standard_False;
+
+  aNoteBinData->Set(new TCollection_HAsciiString(aData), 
+                    new TCollection_HAsciiString(aMIMEtype));
+
+  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) aNoteBinData = Handle(XCAFDoc_NoteBinData)::DownCast(theSource);
+
+  Handle(TCollection_HAsciiString) aData = aNoteBinData->Data();
+  Handle(TCollection_HAsciiString) aMIMEtype = aNoteBinData->MIMEtype();
+  theTarget
+    << (aData ? aData->String() : TCollection_AsciiString(""))
+    << (aMIMEtype ? aMIMEtype->String() : TCollection_AsciiString(""))
+    ;
+}
diff --git a/src/BinMXCAFDoc/BinMXCAFDoc_NoteBinDataDriver.hxx b/src/BinMXCAFDoc/BinMXCAFDoc_NoteBinDataDriver.hxx
new file mode 100644 (file)
index 0000000..422f797
--- /dev/null
@@ -0,0 +1,44 @@
+// 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(CDM_MessageDriver)& 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
new file mode 100644 (file)
index 0000000..d1e9fc1
--- /dev/null
@@ -0,0 +1,81 @@
+// 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 <CDM_MessageDriver.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(CDM_MessageDriver)& 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) aNoteComment = Handle(XCAFDoc_NoteComment)::DownCast(theTarget);
+
+  TCollection_ExtendedString aComment;
+  if (!(theSource >> aComment))
+    return Standard_False;
+
+  aNoteComment->Set(new TCollection_HExtendedString(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) aNoteComment = Handle(XCAFDoc_NoteComment)::DownCast(theSource);
+
+  Handle(TCollection_HExtendedString) aComment = aNoteComment->TimeStamp();
+  theTarget
+    << (aComment ? aComment->String() : TCollection_ExtendedString(""))
+    ;
+}
diff --git a/src/BinMXCAFDoc/BinMXCAFDoc_NoteCommentDriver.hxx b/src/BinMXCAFDoc/BinMXCAFDoc_NoteCommentDriver.hxx
new file mode 100644 (file)
index 0000000..730735e
--- /dev/null
@@ -0,0 +1,44 @@
+// 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(CDM_MessageDriver)& 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)
+
+};
+
+#endif // _BinMXCAFDoc_NoteCommentDriver_HeaderFile
index c950ecca65e95444bf016d5ec7c35c006bb9dbeb..64e3a55bd89b057ae1e0da521916653e206d8ba3 100644 (file)
@@ -31,6 +31,17 @@ BinMXCAFDoc_NoteDriver::BinMXCAFDoc_NoteDriver(const Handle(CDM_MessageDriver)&
 {
 }
 
+//=======================================================================
+//function :
+//purpose  : 
+//=======================================================================
+BinMXCAFDoc_NoteDriver::BinMXCAFDoc_NoteDriver(const Handle(CDM_MessageDriver)& theMsgDriver,
+                                               Standard_CString                 theName)
+  : BinMDF_ADriver(theMsgDriver, theName)
+{
+
+}
+
 //=======================================================================
 //function :
 //purpose  : 
@@ -44,10 +55,19 @@ Handle(TDF_Attribute) BinMXCAFDoc_NoteDriver::NewEmpty() const
 //function :
 //purpose  : 
 //=======================================================================
-Standard_Boolean BinMXCAFDoc_NoteDriver::Paste(const BinObjMgt_Persistent&  /*theSource*/,
-                                               const Handle(TDF_Attribute)& /*theTarget*/,
+Standard_Boolean BinMXCAFDoc_NoteDriver::Paste(const BinObjMgt_Persistent&  theSource,
+                                               const Handle(TDF_Attribute)& theTarget,
                                                BinObjMgt_RRelocationTable&  /*theRelocTable*/) const
 {
+  Handle(XCAFDoc_Note) aNote = Handle(XCAFDoc_Note)::DownCast(theTarget);
+  
+  TCollection_ExtendedString aUserName, aTimeStamp;
+  if (!(theSource >> aUserName >> aTimeStamp))
+    return Standard_False;
+
+  aNote->Set(new TCollection_HExtendedString(aUserName),
+             new TCollection_HExtendedString(aTimeStamp));
+
   return Standard_True;
 }
 
@@ -55,8 +75,15 @@ Standard_Boolean BinMXCAFDoc_NoteDriver::Paste(const BinObjMgt_Persistent&  /*th
 //function :
 //purpose  : 
 //=======================================================================
-void BinMXCAFDoc_NoteDriver::Paste(const Handle(TDF_Attribute)& /*theSource*/,
-                                                                BinObjMgt_Persistent&        /*theTarget*/,
+void BinMXCAFDoc_NoteDriver::Paste(const Handle(TDF_Attribute)& theSource,
+                                                                BinObjMgt_Persistent&        theTarget,
                                                                 BinObjMgt_SRelocationTable&  /*theRelocTable*/) const
 {
+  Handle(XCAFDoc_Note) aNote = Handle(XCAFDoc_Note)::DownCast(theSource);
+  Handle(TCollection_HExtendedString) aUserName = aNote->UserName();
+  Handle(TCollection_HExtendedString) aTimeStamp = aNote->TimeStamp();
+  theTarget 
+    << (aUserName ? aUserName->String() : TCollection_ExtendedString(""))
+    << (aTimeStamp ? aTimeStamp->String() : TCollection_ExtendedString(""))
+    ;
 }
index 18b94160c59f429248fed4538ec2bb85019d4b9f..8dc1b75c2dbc5d92e388dc4edb7a30eac5b29fbd 100644 (file)
@@ -49,6 +49,11 @@ public:
 
   DEFINE_STANDARD_RTTIEXT(BinMXCAFDoc_NoteDriver, BinMDF_ADriver)
 
+protected:
+
+  Standard_EXPORT BinMXCAFDoc_NoteDriver(const Handle(CDM_MessageDriver)& theMsgDriver,
+                                         Standard_CString                 theName);
+
 };
 
 #endif // _BinMXCAFDoc_NoteDriver_HeaderFile
index aa1a13087e3f41a9957007c77ea1725f985b9a24..2e3210ec5731efe5b355ef184b283e16972cffc3 100644 (file)
@@ -35,6 +35,10 @@ BinMXCAFDoc_MaterialToolDriver.cxx
 BinMXCAFDoc_MaterialToolDriver.hxx
 BinMXCAFDoc_NoteDriver.cxx
 BinMXCAFDoc_NoteDriver.hxx
+BinMXCAFDoc_NoteCommentDriver.cxx
+BinMXCAFDoc_NoteCommentDriver.hxx
+BinMXCAFDoc_NoteBinDataDriver.cxx
+BinMXCAFDoc_NoteBinDataDriver.hxx
 BinMXCAFDoc_NotesToolDriver.cxx
 BinMXCAFDoc_NotesToolDriver.hxx
 BinMXCAFDoc_ShapeToolDriver.cxx
index 820b8ef31fbdcb7c65b9ea0a0b8fb2be19c985b2..eb566e35be47e7a8552fbdeb063d9f2859927bd2 100755 (executable)
@@ -42,6 +42,10 @@ XCAFDoc_MaterialTool.cxx
 XCAFDoc_MaterialTool.hxx
 XCAFDoc_Note.cxx
 XCAFDoc_Note.hxx
+XCAFDoc_NoteComment.cxx
+XCAFDoc_NoteComment.hxx
+XCAFDoc_NoteBinData.cxx
+XCAFDoc_NoteBinData.hxx
 XCAFDoc_NotesTool.cxx
 XCAFDoc_NotesTool.hxx
 XCAFDoc_ShapeMapTool.cxx
index 2299ae329319d850d4d7cccb92e3e36f6b53ec95..37490006d589d82f016793b29f7a4dddb356988a 100644 (file)
@@ -172,6 +172,17 @@ Standard_GUID XCAFDoc::MaterialRefGUID ()
 }
 
 
+//=======================================================================
+//function : NoteRefGUID
+//purpose  : 
+//=======================================================================
+
+Standard_GUID XCAFDoc::NoteRefGUID()
+{
+  static Standard_GUID ID ("F3599E50-F84A-493e-8D1B-1284E79322F1");
+  return ID;
+}
+
 //=======================================================================
 //function : InvisibleGUID
 //purpose  : 
index 1812029d9ea7c964b7a0afe2c6499d4da53a95e2..9532983eb156dbf63d1dfe662d86c21dd5cc424f 100644 (file)
@@ -97,7 +97,10 @@ public:
   Standard_EXPORT static Standard_GUID LayerRefGUID();
   
   Standard_EXPORT static Standard_GUID MaterialRefGUID();
-  
+
+  //! Return GUIDs for TreeNode representing types of Note
+  Standard_EXPORT static Standard_GUID NoteRefGUID();
+
   Standard_EXPORT static Standard_GUID InvisibleGUID();
   
   //! Returns GUID for UAttribute identifying external reference on no-step file
index f912eea9f989d094412ab0f7c045567ee37a86f8..2fe5b76623257fab3c5c6cf526aec619f97127d4 100644 (file)
@@ -25,21 +25,49 @@ const Standard_GUID& XCAFDoc_Note::GetID()
   return s_ID;
 }
 
-Handle(XCAFDoc_Note) XCAFDoc_Note::Set(const TDF_Label& theLabel)
+Standard_Boolean XCAFDoc_Note::IsMine(const TDF_Label& theLabel)
 {
-  Handle(XCAFDoc_Note) aTool;
-  if (!theLabel.FindAttribute(XCAFDoc_Note::GetID(), aTool))
+  Handle(XCAFDoc_Note) anAttr;
+  return (!theLabel.IsNull() && theLabel.FindAttribute(XCAFDoc_Note::GetID(), anAttr));
+}
+
+Handle(XCAFDoc_Note) XCAFDoc_Note::Set(const TDF_Label&                  theLabel,
+                                       const Handle(TCollection_HExtendedString)& theUserName,
+                                       const Handle(TCollection_HExtendedString)& theTimeStamp)
+{
+  Handle(XCAFDoc_Note) aNote;
+  if (!theLabel.IsNull() && !theLabel.FindAttribute(XCAFDoc_Note::GetID(), aNote))
   {
-    aTool = new XCAFDoc_Note();
-    theLabel.AddAttribute(aTool);
+    aNote = new XCAFDoc_Note();
+    aNote->Set(theUserName, theTimeStamp);
+    theLabel.AddAttribute(aNote);
   }
-  return aTool;
+  return aNote;
 }
 
 XCAFDoc_Note::XCAFDoc_Note()
 {
 }
 
+void XCAFDoc_Note::Set(const Handle(TCollection_HExtendedString)& theUserName,
+                       const Handle(TCollection_HExtendedString)& theTimeStamp)
+{
+  Backup();
+
+  myUserName = theUserName;
+  myTimeStamp = theTimeStamp;
+}
+
+Handle(TCollection_HExtendedString) XCAFDoc_Note::UserName() const
+{
+  return myUserName;
+}
+
+Handle(TCollection_HExtendedString) XCAFDoc_Note::TimeStamp() const
+{
+  return myTimeStamp;
+}
+
 const Standard_GUID& XCAFDoc_Note::ID() const
 {
   return GetID();
@@ -50,11 +78,25 @@ Handle(TDF_Attribute) XCAFDoc_Note::NewEmpty() const
   return new XCAFDoc_Note();
 }
 
-void XCAFDoc_Note::Restore(const Handle(TDF_Attribute)& /*theAttr*/)
+void XCAFDoc_Note::Restore(const Handle(TDF_Attribute)& theAttr)
 {
+  myUserName = Handle(XCAFDoc_Note)::DownCast(theAttr)->myUserName;
+  myTimeStamp = Handle(XCAFDoc_Note)::DownCast(theAttr)->myTimeStamp;
 }
 
-void XCAFDoc_Note::Paste(const Handle(TDF_Attribute)&       /*theAttrInto*/,
+void XCAFDoc_Note::Paste(const Handle(TDF_Attribute)&       theAttrInto,
                          const Handle(TDF_RelocationTable)& /*theRT*/) const
 {
+  Handle(XCAFDoc_Note)::DownCast(theAttrInto)->Set(myUserName, myTimeStamp);
+}
+
+Standard_OStream& XCAFDoc_Note::Dump(Standard_OStream& theOS) const
+{
+  theOS 
+    << "Note : " 
+    << (myUserName ? myUserName->String() : "<anonymous>")
+    << " on "
+    << (myTimeStamp ? myTimeStamp->String() : "<unknown>")
+    ;
+  return theOS;
 }
index c23e29ce607c1e106bb0225d37b7060261b5624d..3102721411e3e9bcd0049db4dfc1e8a5d9baf796 100644 (file)
@@ -18,6 +18,8 @@
 
 #include <Standard.hxx>
 #include <Standard_Type.hxx>
+#include <TCollection_HExtendedString.hxx>
+#include <OSD_File.hxx>
 #include <TDF_Attribute.hxx>
 
 class Standard_GUID;
@@ -32,14 +34,23 @@ public:
 
   DEFINE_STANDARD_RTTIEXT(XCAFDoc_Note, TDF_Attribute)
 
-    Standard_EXPORT static const Standard_GUID& GetID();
+  Standard_EXPORT static const Standard_GUID& GetID();
 
-  //! Create (if not exist) NotesTool from XCAFDoc on <L>.
-  Standard_EXPORT static Handle(XCAFDoc_Note) Set(const TDF_Label& theLabel);
+  Standard_EXPORT static Standard_Boolean IsMine(const TDF_Label& theLabel);
+
+  Standard_EXPORT static Handle(XCAFDoc_Note) Set(const TDF_Label&                           theLabel,
+                                                  const Handle(TCollection_HExtendedString)& theUserName,
+                                                  const Handle(TCollection_HExtendedString)& theTimeStamp);
 
-  //! Creates an empty tool
   Standard_EXPORT XCAFDoc_Note();
 
+  Standard_EXPORT void Set(const Handle(TCollection_HExtendedString)& theUserName,
+                           const Handle(TCollection_HExtendedString)& theTimeStamp);
+
+  Standard_EXPORT Handle(TCollection_HExtendedString) UserName() const;
+
+  Standard_EXPORT Handle(TCollection_HExtendedString) TimeStamp() const;
+
 public:
 
   Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
@@ -51,6 +62,12 @@ public:
   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:
+
+  Handle(TCollection_HExtendedString) myUserName;
+  Handle(TCollection_HExtendedString) myTimeStamp;
 };
 
 #endif // _XCAFDoc_Note_HeaderFile
diff --git a/src/XCAFDoc/XCAFDoc_NoteBinData.cxx b/src/XCAFDoc/XCAFDoc_NoteBinData.cxx
new file mode 100644 (file)
index 0000000..d4875e5
--- /dev/null
@@ -0,0 +1,128 @@
+// Created on: 2017-02-13
+// Created by: Sergey NIKONOV
+// Copyright (c) 2000-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 <OSD_File.hxx>
+#include <Standard_GUID.hxx>
+#include <TCollection_HAsciiString.hxx>
+#include <TDF_Label.hxx>
+#include <XCAFDoc_NoteBinData.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_NoteBinData, XCAFDoc_Note)
+
+const Standard_GUID& XCAFDoc_NoteBinData::GetID()
+{
+  static Standard_GUID s_ID("E9055501-F0FC-4864-BE4B-284FDA7DDEAC");
+  return s_ID;
+}
+
+Standard_Boolean XCAFDoc_NoteBinData::IsMine(const TDF_Label& theLabel)
+{
+  Handle(XCAFDoc_NoteBinData) anAttr;
+  return (!theLabel.IsNull() && theLabel.FindAttribute(XCAFDoc_NoteBinData::GetID(), anAttr));
+}
+
+Handle(XCAFDoc_NoteBinData) XCAFDoc_NoteBinData::Set(const TDF_Label&                           theLabel,
+                                                     const Handle(TCollection_HExtendedString)& theUserName,
+                                                     const Handle(TCollection_HExtendedString)& theTimeStamp,
+                                                     OSD_File&                                  theFile,
+                                                     const Handle(TCollection_HAsciiString)&    theMIMEtype)
+{
+  Handle(XCAFDoc_NoteBinData) aNoteBinData;
+  if (!theLabel.IsNull() && !theLabel.FindAttribute(XCAFDoc_Note::GetID(), aNoteBinData))
+  {
+    aNoteBinData = new XCAFDoc_NoteBinData();
+    aNoteBinData->XCAFDoc_Note::Set(theUserName, theTimeStamp);
+    aNoteBinData->Set(theFile, theMIMEtype);
+    theLabel.AddAttribute(aNoteBinData);
+  }
+  return aNoteBinData;
+}
+
+XCAFDoc_NoteBinData::XCAFDoc_NoteBinData()
+{
+}
+
+void XCAFDoc_NoteBinData::Set(OSD_File&                               theFile,
+                              const Handle(TCollection_HAsciiString)& theMIMEtype)
+{
+  if (!theFile.IsOpen() || !theFile.IsReadable())
+    return;
+
+  TCollection_AsciiString aStr;
+  theFile.Read(aStr, theFile.Size());
+
+  Backup();
+
+  myData.reset(new TCollection_HAsciiString(aStr));
+  myMIMEtype = theMIMEtype;
+}
+
+void XCAFDoc_NoteBinData::Set(const Handle(TCollection_HAsciiString)& theData,
+                              const Handle(TCollection_HAsciiString)& theMIMEtype)
+{
+  Backup();
+
+  myData = theData;
+  myMIMEtype = theMIMEtype;
+}
+
+Handle(TCollection_HAsciiString) XCAFDoc_NoteBinData::Data() const
+{
+  return myData;
+}
+
+Handle(TCollection_HAsciiString) XCAFDoc_NoteBinData::MIMEtype() const
+{
+  return myMIMEtype;
+}
+
+const Standard_GUID& XCAFDoc_NoteBinData::ID() const
+{
+  return GetID();
+}
+
+Handle(TDF_Attribute) XCAFDoc_NoteBinData::NewEmpty() const
+{
+  return new XCAFDoc_Note();
+}
+
+void XCAFDoc_NoteBinData::Restore(const Handle(TDF_Attribute)& theAttr)
+{
+  XCAFDoc_Note::Restore(theAttr);
+  myData = Handle(XCAFDoc_NoteBinData)::DownCast(theAttr)->myData;
+  myMIMEtype = Handle(XCAFDoc_NoteBinData)::DownCast(theAttr)->myMIMEtype;
+}
+
+void XCAFDoc_NoteBinData::Paste(const Handle(TDF_Attribute)&       theAttrInto,
+                                const Handle(TDF_RelocationTable)& theRT) const
+{
+  XCAFDoc_Note::Paste(theAttrInto, theRT);
+  Handle(XCAFDoc_NoteBinData)::DownCast(theAttrInto)->Set(myData, myMIMEtype);
+}
+
+Standard_OStream& XCAFDoc_NoteBinData::Dump(Standard_OStream& theOS) const
+{
+  XCAFDoc_Note::Dump(theOS);
+  theOS
+    << "\n"
+    << "MIME type : "
+    << (myMIMEtype ? myMIMEtype->String() : "<none>")
+    << "\n"
+    << "<BEGIN>"
+    << (myData ? myData->String() : "")
+    << "<END>"
+    ;
+  return theOS;
+}
diff --git a/src/XCAFDoc/XCAFDoc_NoteBinData.hxx b/src/XCAFDoc/XCAFDoc_NoteBinData.hxx
new file mode 100644 (file)
index 0000000..64c6ce7
--- /dev/null
@@ -0,0 +1,73 @@
+// Created on: 2017-02-13
+// Created by: Sergey NIKONOV
+// Copyright (c) 2000-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 _XCAFDoc_NoteBinData_HeaderFile
+#define _XCAFDoc_NoteBinData_HeaderFile
+
+#include <XCAFDoc_Note.hxx>
+
+class OSD_File;
+class TCollection_HAsciiString;
+
+class XCAFDoc_NoteBinData;
+DEFINE_STANDARD_HANDLE(XCAFDoc_NoteBinData, XCAFDoc_Note)
+
+class XCAFDoc_NoteBinData : public XCAFDoc_Note
+{
+public:
+
+  DEFINE_STANDARD_RTTIEXT(XCAFDoc_NoteBinData, XCAFDoc_Note)
+
+  Standard_EXPORT static const Standard_GUID& GetID();
+
+  Standard_EXPORT static Standard_Boolean IsMine(const TDF_Label& theLabel);
+
+  Standard_EXPORT static Handle(XCAFDoc_NoteBinData) Set(const TDF_Label&                           theLabel,
+                                                         const Handle(TCollection_HExtendedString)& theUserName,
+                                                         const Handle(TCollection_HExtendedString)& theTimeStamp,
+                                                         OSD_File&                                  theFile,
+                                                         const Handle(TCollection_HAsciiString)&    theMIMEtype);
+
+  Standard_EXPORT XCAFDoc_NoteBinData();
+
+  Standard_EXPORT void Set(OSD_File&                               theFile,
+                           const Handle(TCollection_HAsciiString)& theMIMEtype);
+
+  Standard_EXPORT void Set(const Handle(TCollection_HAsciiString)& theData,
+                           const Handle(TCollection_HAsciiString)& theMIMEtype);
+
+  Standard_EXPORT Handle(TCollection_HAsciiString) Data() const;
+  Standard_EXPORT Handle(TCollection_HAsciiString) MIMEtype() const;
+
+public:
+
+  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:
+
+  Handle(TCollection_HAsciiString) myData;
+  Handle(TCollection_HAsciiString) myMIMEtype;
+};
+
+#endif // _XCAFDoc_NoteBinData_HeaderFile
diff --git a/src/XCAFDoc/XCAFDoc_NoteComment.cxx b/src/XCAFDoc/XCAFDoc_NoteComment.cxx
new file mode 100644 (file)
index 0000000..23e9f56
--- /dev/null
@@ -0,0 +1,98 @@
+// Created on: 2017-02-13
+// Created by: Sergey NIKONOV
+// Copyright (c) 2000-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 <Standard_GUID.hxx>
+#include <TDF_Label.hxx>
+#include <XCAFDoc_NoteComment.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_NoteComment, XCAFDoc_Note)
+
+const Standard_GUID& XCAFDoc_NoteComment::GetID()
+{
+  static Standard_GUID s_ID("FDEA4C52-0F54-484c-B590-579E18F7B5D4");
+  return s_ID;
+}
+
+Standard_Boolean XCAFDoc_NoteComment::IsMine(const TDF_Label& theLabel)
+{
+  Handle(XCAFDoc_NoteComment) anAttr;
+  return (!theLabel.IsNull() && theLabel.FindAttribute(XCAFDoc_NoteComment::GetID(), anAttr));
+}
+
+Handle(XCAFDoc_NoteComment) XCAFDoc_NoteComment::Set(const TDF_Label&                           theLabel,
+                                                     const Handle(TCollection_HExtendedString)& theUserName,
+                                                     const Handle(TCollection_HExtendedString)& theTimeStamp,
+                                                     const Handle(TCollection_HExtendedString)& theComment)
+{
+  Handle(XCAFDoc_NoteComment) aNoteComment;
+  if (!theLabel.IsNull() && !theLabel.FindAttribute(XCAFDoc_Note::GetID(), aNoteComment))
+  {
+    aNoteComment = new XCAFDoc_NoteComment();
+    aNoteComment->XCAFDoc_Note::Set(theUserName, theTimeStamp);
+    aNoteComment->Set(theComment);
+    theLabel.AddAttribute(aNoteComment);
+  }
+  return aNoteComment;
+}
+
+XCAFDoc_NoteComment::XCAFDoc_NoteComment()
+{
+}
+
+void XCAFDoc_NoteComment::Set(const Handle(TCollection_HExtendedString)& theComment)
+{
+  Backup();
+
+  myComment = theComment;
+}
+
+Handle(TCollection_HExtendedString) XCAFDoc_NoteComment::Comment() const
+{
+  return myComment;
+}
+
+const Standard_GUID& XCAFDoc_NoteComment::ID() const
+{
+  return GetID();
+}
+
+Handle(TDF_Attribute) XCAFDoc_NoteComment::NewEmpty() const
+{
+  return new XCAFDoc_Note();
+}
+
+void XCAFDoc_NoteComment::Restore(const Handle(TDF_Attribute)& theAttr)
+{
+  XCAFDoc_Note::Restore(theAttr);
+  myComment = Handle(XCAFDoc_NoteComment)::DownCast(theAttr)->myComment;
+}
+
+void XCAFDoc_NoteComment::Paste(const Handle(TDF_Attribute)&       theAttrInto,
+                                const Handle(TDF_RelocationTable)& theRT) const
+{
+  XCAFDoc_Note::Paste(theAttrInto, theRT);
+  Handle(XCAFDoc_NoteComment)::DownCast(theAttrInto)->Set(myComment);
+}
+
+Standard_OStream& XCAFDoc_NoteComment::Dump(Standard_OStream& theOS) const
+{
+  XCAFDoc_Note::Dump(theOS);
+  theOS
+    << "\n"
+    << "Comment : "
+    << (myComment ? myComment->String() : "<empty>")
+    ;
+  return theOS;
+}
diff --git a/src/XCAFDoc/XCAFDoc_NoteComment.hxx b/src/XCAFDoc/XCAFDoc_NoteComment.hxx
new file mode 100644 (file)
index 0000000..99c9363
--- /dev/null
@@ -0,0 +1,63 @@
+// Created on: 2017-02-13
+// Created by: Sergey NIKONOV
+// Copyright (c) 2000-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 _XCAFDoc_NoteComment_HeaderFile
+#define _XCAFDoc_NoteComment_HeaderFile
+
+#include <XCAFDoc_Note.hxx>
+
+class XCAFDoc_NoteComment;
+DEFINE_STANDARD_HANDLE(XCAFDoc_NoteComment, XCAFDoc_Note)
+
+class XCAFDoc_NoteComment : public XCAFDoc_Note
+{
+public:
+
+  DEFINE_STANDARD_RTTIEXT(XCAFDoc_NoteComment, XCAFDoc_Note)
+
+  Standard_EXPORT static const Standard_GUID& GetID();
+
+  Standard_EXPORT static Standard_Boolean IsMine(const TDF_Label& theLabel);
+
+  Standard_EXPORT static Handle(XCAFDoc_NoteComment) Set(const TDF_Label&                           theLabel,
+                                                         const Handle(TCollection_HExtendedString)& theUserName,
+                                                         const Handle(TCollection_HExtendedString)& theTimeStamp,
+                                                         const Handle(TCollection_HExtendedString)& theComment);
+
+  Standard_EXPORT XCAFDoc_NoteComment();
+
+  Standard_EXPORT void Set(const Handle(TCollection_HExtendedString)& theComment);
+
+  Standard_EXPORT Handle(TCollection_HExtendedString) Comment() const;
+
+public:
+
+  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:
+
+  Handle(TCollection_HExtendedString) myComment;
+};
+
+#endif // _XCAFDoc_NoteComment_HeaderFile
index df087fc3032a9f7f39f10e1d1b10cacf44e5d5df..6dfcb387bd5b8e93f6c79661eaf7eebf08d78c25 100644 (file)
 
 #include <Standard_GUID.hxx>
 #include <TDF_Label.hxx>
+#include <TDF_ChildIterator.hxx>
+#include <TDF_LabelSequence.hxx>
+#include <XCAFDoc.hxx>
+#include <XCAFDoc_GraphNode.hxx>
 #include <XCAFDoc_NotesTool.hxx>
+#include <XCAFDoc_Note.hxx>
 
 IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_NotesTool, TDF_Attribute)
 
@@ -40,6 +45,28 @@ XCAFDoc_NotesTool::XCAFDoc_NotesTool()
 {
 }
 
+void XCAFDoc_NotesTool::GetNotes(TDF_LabelSequence& theNoteLabels) const
+{
+  theNoteLabels.Clear();
+  for (TDF_ChildIterator anIter(Label()); anIter.More(); anIter.Next()) 
+  {
+    const TDF_Label aLabel = anIter.Value();
+    if (XCAFDoc_Note::IsMine(aLabel))
+    {
+      theNoteLabels.Append(aLabel);
+    }
+  }
+}
+
+Handle(XCAFDoc_Note) XCAFDoc_NotesTool::AddNote(const Handle(TCollection_HExtendedString)& theUserName,
+                                                const Handle(TCollection_HExtendedString)& theTimeStamp)
+{
+  TDF_Label aNoteLabel;
+  TDF_TagSource aTag;
+  aNoteLabel = aTag.NewChild(Label());
+  return XCAFDoc_Note::Set(aNoteLabel, theUserName, theTimeStamp);
+}
+
 const Standard_GUID& XCAFDoc_NotesTool::ID() const
 {
   return GetID();
index 78521cb7467f4e04216e95b8a2bf18ffe1ed51ca..0ba2e14d2a708ec5e54e52b92731835b560f19f0 100644 (file)
 #include <Standard.hxx>
 #include <Standard_Type.hxx>
 #include <TDF_Attribute.hxx>
+#include <TDF_LabelSequence.hxx>
 
 class Standard_GUID;
+class TCollection_HExtendedString;
 class TDF_RelocationTable;
+class XCAFDoc_Note;
 
 class XCAFDoc_NotesTool;
 DEFINE_STANDARD_HANDLE(XCAFDoc_NotesTool, TDF_Attribute)
@@ -40,14 +43,19 @@ public:
   //! Creates an empty tool
   Standard_EXPORT XCAFDoc_NotesTool();
 
+  //! Returns a sequence of note labels currently stored in the tool table
+  Standard_EXPORT void GetNotes(TDF_LabelSequence& theNoteLabels) const;
+
+  //! Adds a new note and returns a handle to it
+  Standard_EXPORT Handle(XCAFDoc_Note) AddNote(const Handle(TCollection_HExtendedString)& theUserName,
+                                               const Handle(TCollection_HExtendedString)& theTimeStamp);
+
 public:
 
+  // Overrides TDF_Attribute pure 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;