0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / TNaming / TNaming_UsedShapes.hxx
1 // Created on: 1997-02-05
2 // Created by: Yves FRICAUD
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifndef _TNaming_UsedShapes_HeaderFile
18 #define _TNaming_UsedShapes_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
22
23 #include <TNaming_DataMapOfShapePtrRefShape.hxx>
24 #include <TDF_Attribute.hxx>
25 #include <Standard_Boolean.hxx>
26 #include <Standard_OStream.hxx>
27 class TNaming_Builder;
28 class Standard_GUID;
29 class TDF_Attribute;
30 class TDF_AttributeDelta;
31 class TDF_DeltaOnAddition;
32 class TDF_DeltaOnRemoval;
33 class TDF_RelocationTable;
34 class TDF_DataSet;
35
36
37 class TNaming_UsedShapes;
38 DEFINE_STANDARD_HANDLE(TNaming_UsedShapes, TDF_Attribute)
39
40 //! Global attribute located under root label to store all
41 //! the shapes handled by the framework
42 //! Set of Shapes Used in a Data from TDF
43 //! Only one instance by Data, it always
44 //! Stored as Attribute of The Root.
45 class TNaming_UsedShapes : public TDF_Attribute
46 {
47
48 public:
49
50   
51   Standard_EXPORT void Destroy();
52 ~TNaming_UsedShapes()
53 {
54   Destroy();
55 }
56   
57     TNaming_DataMapOfShapePtrRefShape& Map();
58   
59   //! Returns the ID of the attribute.
60     const Standard_GUID& ID() const Standard_OVERRIDE;
61   
62   //! Returns the ID: 2a96b614-ec8b-11d0-bee7-080009dc3333.
63   Standard_EXPORT static const Standard_GUID& GetID();
64   
65   //! Copies  the attribute  contents into  a  new other
66   //! attribute. It is used by Backup().
67   Standard_EXPORT virtual Handle(TDF_Attribute) BackupCopy() const Standard_OVERRIDE;
68   
69   //! Restores the contents from <anAttribute> into this
70   //! one. It is used when aborting a transaction.
71   Standard_EXPORT virtual void Restore (const Handle(TDF_Attribute)& anAttribute) Standard_OVERRIDE;
72   
73   //! Clears the table.
74   Standard_EXPORT virtual void BeforeRemoval() Standard_OVERRIDE;
75   
76   //! Something to do after applying <anAttDelta>.
77   Standard_EXPORT virtual Standard_Boolean AfterUndo (const Handle(TDF_AttributeDelta)& anAttDelta, const Standard_Boolean forceIt = Standard_False) Standard_OVERRIDE;
78   
79   //! this method returns a null handle (no delta).
80   Standard_EXPORT virtual Handle(TDF_DeltaOnAddition) DeltaOnAddition() const Standard_OVERRIDE;
81   
82   //! this method returns a null handle (no delta).
83   Standard_EXPORT virtual Handle(TDF_DeltaOnRemoval) DeltaOnRemoval() const Standard_OVERRIDE;
84   
85   //! Returns an new empty attribute from the good end
86   //! type. It is used by the copy algorithm.
87   Standard_EXPORT virtual Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
88   
89   //! This method is different from the "Copy" one,
90   //! because it is used when copying an attribute from
91   //! a source structure into a target structure. This
92   //! method pastes the current attribute to the label
93   //! corresponding to the insertor. The pasted
94   //! attribute may be a brand new one or a new version
95   //! of the previous one.
96   Standard_EXPORT virtual void Paste (const Handle(TDF_Attribute)& intoAttribute, const Handle(TDF_RelocationTable)& aRelocTationable) const Standard_OVERRIDE;
97   
98   //! Adds the directly referenced attributes and labels
99   //! to <aDataSet>. "Directly" means we have only to
100   //! look at the first level of references.
101   //!
102   //! For this, use only the AddLabel() & AddAttribute()
103   //! from DataSet and do not try to modify information
104   //! previously stored in <aDataSet>.
105   Standard_EXPORT virtual void References (const Handle(TDF_DataSet)& aDataSet) const Standard_OVERRIDE;
106   
107   //! Dumps the attribute on <aStream>.
108   Standard_EXPORT virtual Standard_OStream& Dump (Standard_OStream& anOS) const Standard_OVERRIDE;
109   
110   //! Dumps the content of me into the stream
111   Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
112
113 friend class TNaming_Builder;
114
115
116   DEFINE_STANDARD_RTTIEXT(TNaming_UsedShapes,TDF_Attribute)
117
118 protected:
119
120
121
122
123 private:
124
125   
126   Standard_EXPORT TNaming_UsedShapes();
127
128   TNaming_DataMapOfShapePtrRefShape myMap;
129
130
131 };
132
133
134 #include <TNaming_UsedShapes.lxx>
135
136
137
138
139
140 #endif // _TNaming_UsedShapes_HeaderFile