42cf5bc1 |
1 | // Created on: 1998-09-30 |
2 | // Created by: Denis PASCAL |
3 | // Copyright (c) 1998-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 _TPrsStd_AISPresentation_HeaderFile |
18 | #define _TPrsStd_AISPresentation_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_Type.hxx> |
22 | |
23 | #include <Standard_GUID.hxx> |
24 | #include <Standard_Real.hxx> |
25 | #include <Quantity_NameOfColor.hxx> |
26 | #include <Graphic3d_NameOfMaterial.hxx> |
27 | #include <Standard_Integer.hxx> |
28 | #include <Standard_Boolean.hxx> |
29 | #include <TDF_Attribute.hxx> |
30 | class AIS_InteractiveObject; |
31 | class Standard_GUID; |
32 | class TDF_Label; |
33 | class TDF_Attribute; |
34 | class TDF_RelocationTable; |
35 | class TDF_AttributeDelta; |
36 | |
37 | |
38 | class TPrsStd_AISPresentation; |
39 | DEFINE_STANDARD_HANDLE(TPrsStd_AISPresentation, TDF_Attribute) |
40 | |
41 | //! An attribute to associate an |
42 | //! AIS_InteractiveObject to a label in an AIS viewer. |
43 | //! This attribute works in collaboration with TPrsStd_AISViewer. |
44 | //! Note that all the Set... and Unset... attribute |
45 | //! methods as well as the query methods for |
46 | //! visualization attributes and the HasOwn... test |
47 | //! methods are shortcuts to the respective |
48 | //! AIS_InteractiveObject settings. |
49 | class TPrsStd_AISPresentation : public TDF_Attribute |
50 | { |
51 | |
52 | public: |
53 | |
54 | |
55 | //! Returns the GUID for TPrsStd_AISPresentation attributes. |
56 | Standard_EXPORT static const Standard_GUID& GetID(); |
57 | |
58 | //! Creates or retrieves the presentation attribute on |
59 | //! the label L, and sets the GUID driver. |
60 | Standard_EXPORT static Handle(TPrsStd_AISPresentation) Set (const TDF_Label& L, const Standard_GUID& driver); |
61 | |
62 | //! Delete (if exist) the presentation attribute associated to the label <L>. |
63 | Standard_EXPORT static void Unset (const TDF_Label& L); |
64 | |
65 | //! Creates or retrieves the AISPresentation |
66 | //! attribute attached to master. |
67 | //! The GUID of the driver will be the GUID of master. |
68 | //! master is the attribute you want to display. |
69 | Standard_EXPORT static Handle(TPrsStd_AISPresentation) Set (const Handle(TDF_Attribute)& master); |
70 | |
71 | Standard_EXPORT TPrsStd_AISPresentation(); |
72 | |
73 | Standard_EXPORT void SetDisplayed (const Standard_Boolean B); |
74 | |
75 | //! Display presentation of object in AIS viewer. |
76 | //! If <update> = True then AISObject is recomputed and all |
77 | //! the visualization settings are applied |
78 | Standard_EXPORT void Display (const Standard_Boolean update = Standard_False); |
79 | |
80 | //! Removes the presentation of this AIS |
81 | //! presentation attribute from the TPrsStd_AISViewer. |
82 | //! If remove is true, this AIS presentation attribute |
83 | //! is removed from the interactive context. |
84 | Standard_EXPORT void Erase (const Standard_Boolean remove = Standard_False); |
85 | |
86 | //! Recompute presentation of object and apply the visualization settings |
87 | Standard_EXPORT void Update(); |
88 | |
89 | Standard_EXPORT Standard_GUID GetDriverGUID() const; |
90 | |
91 | Standard_EXPORT void SetDriverGUID (const Standard_GUID& guid); |
92 | |
93 | |
94 | //! Returns true if this AIS presentation attribute is displayed. |
95 | Standard_EXPORT Standard_Boolean IsDisplayed() const; |
96 | |
97 | //! Returns AIS_InteractiveObject stored in the presentation attribute |
98 | Standard_EXPORT Handle(AIS_InteractiveObject) GetAIS() const; |
99 | |
100 | |
101 | //! Returns the material setting for this presentation attribute. |
102 | Standard_EXPORT Graphic3d_NameOfMaterial Material() const; |
103 | |
104 | //! Sets the material aName for this presentation attribute. |
105 | Standard_EXPORT void SetMaterial (const Graphic3d_NameOfMaterial aName); |
106 | |
107 | //! Returns true if this presentation attribute already has a material setting. |
108 | Standard_EXPORT Standard_Boolean HasOwnMaterial() const; |
109 | |
110 | //! Removes the material setting from this presentation attribute. |
111 | Standard_EXPORT void UnsetMaterial(); |
112 | |
113 | |
114 | //! Sets the transparency value aValue for this |
115 | //! presentation attribute. |
116 | //! This value is 0.6 by default. |
117 | Standard_EXPORT void SetTransparency (const Standard_Real aValue = 0.6); |
118 | |
119 | Standard_EXPORT Standard_Real Transparency() const; |
120 | |
121 | //! Returns true if this presentation attribute already has a transparency setting. |
122 | Standard_EXPORT Standard_Boolean HasOwnTransparency() const; |
123 | |
124 | //! Removes the transparency setting from this presentation attribute. |
125 | Standard_EXPORT void UnsetTransparency(); |
126 | |
127 | Standard_EXPORT Quantity_NameOfColor Color() const; |
128 | |
129 | //! Sets the color aColor for this presentation attribute. |
130 | Standard_EXPORT void SetColor (const Quantity_NameOfColor aColor); |
131 | |
132 | //! Returns true if this presentation attribute already has a color setting. |
133 | Standard_EXPORT Standard_Boolean HasOwnColor() const; |
134 | |
135 | //! Removes the color setting from this presentation attribute. |
136 | Standard_EXPORT void UnsetColor(); |
137 | |
138 | Standard_EXPORT Standard_Real Width() const; |
139 | |
140 | //! Sets the width aWidth for this presentation attribute. |
141 | Standard_EXPORT void SetWidth (const Standard_Real aWidth); |
142 | |
143 | //! Returns true if this presentation attribute already has a width setting. |
144 | Standard_EXPORT Standard_Boolean HasOwnWidth() const; |
145 | |
146 | //! Removes the width setting from this presentation attribute. |
147 | Standard_EXPORT void UnsetWidth(); |
148 | |
149 | Standard_EXPORT Standard_Integer Mode() const; |
150 | |
151 | Standard_EXPORT void SetMode (const Standard_Integer theMode); |
152 | |
153 | Standard_EXPORT Standard_Boolean HasOwnMode() const; |
154 | |
155 | Standard_EXPORT void UnsetMode(); |
156 | |
157 | Standard_EXPORT Standard_Integer SelectionMode() const; |
158 | |
159 | Standard_EXPORT void SetSelectionMode (const Standard_Integer theSelectionMode); |
160 | |
161 | Standard_EXPORT Standard_Boolean HasOwnSelectionMode() const; |
162 | |
163 | Standard_EXPORT void UnsetSelectionMode(); |
164 | |
79104795 |
165 | Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE; |
42cf5bc1 |
166 | |
79104795 |
167 | Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE; |
42cf5bc1 |
168 | |
79104795 |
169 | Standard_EXPORT void Restore (const Handle(TDF_Attribute)& with) Standard_OVERRIDE; |
42cf5bc1 |
170 | |
79104795 |
171 | Standard_EXPORT void Paste (const Handle(TDF_Attribute)& into, const Handle(TDF_RelocationTable)& RT) const Standard_OVERRIDE; |
42cf5bc1 |
172 | |
173 | Standard_EXPORT virtual Handle(TDF_Attribute) BackupCopy() const Standard_OVERRIDE; |
174 | |
175 | Standard_EXPORT virtual void AfterAddition() Standard_OVERRIDE; |
176 | |
177 | Standard_EXPORT virtual void BeforeRemoval() Standard_OVERRIDE; |
178 | |
179 | Standard_EXPORT virtual void BeforeForget() Standard_OVERRIDE; |
180 | |
181 | Standard_EXPORT virtual void AfterResume() Standard_OVERRIDE; |
182 | |
183 | Standard_EXPORT virtual Standard_Boolean BeforeUndo (const Handle(TDF_AttributeDelta)& anAttDelta, const Standard_Boolean forceIt = Standard_False) Standard_OVERRIDE; |
184 | |
185 | //! update AIS viewer according to delta |
186 | Standard_EXPORT virtual Standard_Boolean AfterUndo (const Handle(TDF_AttributeDelta)& anAttDelta, const Standard_Boolean forceIt = Standard_False) Standard_OVERRIDE; |
187 | |
188 | |
189 | |
190 | |
191 | DEFINE_STANDARD_RTTI(TPrsStd_AISPresentation,TDF_Attribute) |
192 | |
193 | protected: |
194 | |
195 | |
196 | |
197 | |
198 | private: |
199 | |
200 | |
201 | //! Updates AIS_InteractiveObject stored in the attribute |
202 | //! and applies the visualization settings |
203 | Standard_EXPORT void AISUpdate(); |
204 | |
205 | //! Displays AIS_InteractiveObject stored in the attribute |
206 | Standard_EXPORT void AISDisplay(); |
207 | |
208 | //! Erases AIS_InteractiveObject stored in the attribute in |
209 | //! the viewer; If <remove> = True then AISObject is removed |
210 | //! from AIS_InteractiveContext instead of simple erasing in the viewer |
211 | Standard_EXPORT void AISErase (const Standard_Boolean remove = Standard_False); |
212 | |
213 | Standard_GUID myDriverGUID; |
214 | Standard_Real myTransparency; |
215 | Quantity_NameOfColor myColor; |
216 | Graphic3d_NameOfMaterial myMaterial; |
217 | Standard_Real myWidth; |
218 | Standard_Integer myMode; |
219 | Standard_Integer mySelectionMode; |
220 | Standard_Boolean isDisplayed; |
221 | Standard_Boolean hasOwnColor; |
222 | Standard_Boolean hasOwnMaterial; |
223 | Standard_Boolean hasOwnTransparency; |
224 | Standard_Boolean hasOwnWidth; |
225 | Standard_Boolean hasOwnMode; |
226 | Standard_Boolean hasOwnSelectionMode; |
227 | Handle(AIS_InteractiveObject) myAIS; |
228 | |
229 | |
230 | }; |
231 | |
232 | |
233 | |
234 | |
235 | |
236 | |
237 | |
238 | #endif // _TPrsStd_AISPresentation_HeaderFile |