0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / XCAFDoc / XCAFDoc_Note.hxx
1 // Copyright (c) 2017-2018 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
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.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14 #ifndef _XCAFDoc_Note_HeaderFile
15 #define _XCAFDoc_Note_HeaderFile
16
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>
24
25 class Standard_GUID;
26 class TDF_RelocationTable;
27
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
32 {
33 public:
34
35   DEFINE_STANDARD_RTTIEXT(XCAFDoc_Note, TDF_Attribute)
36
37   //! Checks if the given label represents a note.
38   Standard_EXPORT static Standard_Boolean IsMine(const TDF_Label& theLabel);
39
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);
42
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);
49
50   //! Returns the user name, who created the note.
51   const TCollection_ExtendedString& UserName() const { return myUserName; }
52
53   //! Returns the timestamp of the note.
54   const TCollection_ExtendedString& TimeStamp() const { return myTimeStamp; }
55
56   //! Checks if the note isn't linked to annotated items.
57   Standard_EXPORT Standard_Boolean IsOrphan() const;
58
59   //! Returns auxiliary data object
60   Standard_EXPORT Handle(XCAFNoteObjects_NoteObject) GetObject() const;
61
62   //! Updates auxiliary data
63   Standard_EXPORT void SetObject(const Handle(XCAFNoteObjects_NoteObject)& theObject);
64
65 public:
66
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;
72   
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;
75
76 protected:
77
78   //! Creates an empty note.
79   Standard_EXPORT XCAFDoc_Note();
80
81 private:
82
83   TCollection_ExtendedString myUserName;  ///< Name of the user, who created the note.
84   TCollection_ExtendedString myTimeStamp; ///< Timestamp, when the note was created.
85 };
86
87 DEFINE_STANDARD_HANDLE(XCAFDoc_Note, TDF_Attribute)
88
89 #endif // _XCAFDoc_Note_HeaderFile