1 // Copyright (c) 2017-2018 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #ifndef _XCAFDoc_Note_HeaderFile
15 #define _XCAFDoc_Note_HeaderFile
17 #include <Standard.hxx>
18 #include <Standard_Type.hxx>
19 #include <TCollection_ExtendedString.hxx>
20 #include <OSD_File.hxx>
21 #include <TDF_Attribute.hxx>
22 #include <TDF_LabelSequence.hxx>
23 #include <XCAFNoteObjects_NoteObject.hxx>
26 class TDF_RelocationTable;
28 //! A base note attribute.
29 //! Any note contains the name of the user created the note
30 //! and the creation timestamp.
31 class XCAFDoc_Note : public TDF_Attribute
35 DEFINE_STANDARD_RTTIEXT(XCAFDoc_Note, TDF_Attribute)
37 //! Checks if the given label represents a note.
38 Standard_EXPORT static Standard_Boolean IsMine(const TDF_Label& theLabel);
40 //! Finds a reference attribute on the given label and returns it, if it is found
41 Standard_EXPORT static Handle(XCAFDoc_Note) Get(const TDF_Label& theLabel);
43 //! Sets the user name and the timestamp of the note.
44 //! \param [in] theUserName - the user associated with the note.
45 //! \param [in] theTimeStamp - timestamp of the note.
46 //! \return A handle to the attribute instance.
47 Standard_EXPORT void Set(const TCollection_ExtendedString& theUserName,
48 const TCollection_ExtendedString& theTimeStamp);
50 //! Returns the user name, who created the note.
51 const TCollection_ExtendedString& UserName() const { return myUserName; }
53 //! Returns the timestamp of the note.
54 const TCollection_ExtendedString& TimeStamp() const { return myTimeStamp; }
56 //! Checks if the note isn't linked to annotated items.
57 Standard_EXPORT Standard_Boolean IsOrphan() const;
59 //! Returns auxiliary data object
60 Standard_EXPORT Handle(XCAFNoteObjects_NoteObject) GetObject() const;
62 //! Updates auxiliary data
63 Standard_EXPORT void SetObject(const Handle(XCAFNoteObjects_NoteObject)& theObject);
67 // Overrides TDF_Attribute virtuals
68 Standard_EXPORT void Restore(const Handle(TDF_Attribute)& theAttrFrom) Standard_OVERRIDE;
69 Standard_EXPORT void Paste(const Handle(TDF_Attribute)& theAttrInto,
70 const Handle(TDF_RelocationTable)& theRT) const Standard_OVERRIDE;
71 Standard_EXPORT Standard_OStream& Dump(Standard_OStream& theOS) const Standard_OVERRIDE;
73 //! Dumps the content of me into the stream
74 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
78 //! Creates an empty note.
79 Standard_EXPORT XCAFDoc_Note();
83 TCollection_ExtendedString myUserName; ///< Name of the user, who created the note.
84 TCollection_ExtendedString myTimeStamp; ///< Timestamp, when the note was created.
87 DEFINE_STANDARD_HANDLE(XCAFDoc_Note, TDF_Attribute)
89 #endif // _XCAFDoc_Note_HeaderFile