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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _TPrsStd_AISPresentation_HeaderFile
18 #define _TPrsStd_AISPresentation_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
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 #include <TDataXtd_Presentation.hxx>
31 #include <AIS_InteractiveContext.hxx>
33 class AIS_InteractiveObject;
37 class TDF_RelocationTable;
38 class TDF_AttributeDelta;
40 class TPrsStd_AISPresentation;
41 DEFINE_STANDARD_HANDLE(TPrsStd_AISPresentation, TDF_Attribute)
43 //! An attribute to associate an
44 //! AIS_InteractiveObject to a label in an AIS viewer.
45 //! This attribute works in collaboration with TPrsStd_AISViewer.
46 //! Note that all the Set... and Unset... attribute
47 //! methods as well as the query methods for
48 //! visualization attributes and the HasOwn... test
49 //! methods are shortcuts to the respective
50 //! AIS_InteractiveObject settings.
51 class TPrsStd_AISPresentation : public TDF_Attribute
57 //! Returns the GUID for TPrsStd_AISPresentation attributes.
58 Standard_EXPORT static const Standard_GUID& GetID();
60 //! Creates or retrieves the presentation attribute on
61 //! the label L, and sets the GUID driver.
62 Standard_EXPORT static Handle(TPrsStd_AISPresentation) Set (const TDF_Label& L, const Standard_GUID& driver);
64 //! Delete (if exist) the presentation attribute associated to the label <L>.
65 Standard_EXPORT static void Unset (const TDF_Label& L);
67 //! Creates or retrieves the AISPresentation
68 //! attribute attached to master.
69 //! The GUID of the driver will be the GUID of master.
70 //! master is the attribute you want to display.
71 Standard_EXPORT static Handle(TPrsStd_AISPresentation) Set (const Handle(TDF_Attribute)& master);
73 Standard_EXPORT TPrsStd_AISPresentation();
75 Standard_EXPORT void SetDisplayed (const Standard_Boolean B);
77 //! Display presentation of object in AIS viewer.
78 //! If <update> = True then AISObject is recomputed and all
79 //! the visualization settings are applied
80 Standard_EXPORT void Display (const Standard_Boolean update = Standard_False);
82 //! Removes the presentation of this AIS
83 //! presentation attribute from the TPrsStd_AISViewer.
84 //! If remove is true, this AIS presentation attribute
85 //! is removed from the interactive context.
86 Standard_EXPORT void Erase (const Standard_Boolean remove = Standard_False);
88 //! Recompute presentation of object and apply the visualization settings
89 Standard_EXPORT void Update();
91 Standard_EXPORT Standard_GUID GetDriverGUID() const;
93 Standard_EXPORT void SetDriverGUID (const Standard_GUID& guid);
96 //! Returns true if this AIS presentation attribute is displayed.
97 Standard_EXPORT Standard_Boolean IsDisplayed() const;
99 //! Returns AIS_InteractiveObject stored in the presentation attribute
100 Standard_EXPORT Handle(AIS_InteractiveObject) GetAIS() const;
103 //! Returns the material setting for this presentation attribute.
104 Standard_EXPORT Graphic3d_NameOfMaterial Material() const;
106 //! Sets the material aName for this presentation attribute.
107 Standard_EXPORT void SetMaterial (const Graphic3d_NameOfMaterial aName);
109 //! Returns true if this presentation attribute already has a material setting.
110 Standard_EXPORT Standard_Boolean HasOwnMaterial() const;
112 //! Removes the material setting from this presentation attribute.
113 Standard_EXPORT void UnsetMaterial();
116 //! Sets the transparency value aValue for this
117 //! presentation attribute.
118 //! This value is 0.6 by default.
119 Standard_EXPORT void SetTransparency (const Standard_Real aValue = 0.6);
121 Standard_EXPORT Standard_Real Transparency() const;
123 //! Returns true if this presentation attribute already has a transparency setting.
124 Standard_EXPORT Standard_Boolean HasOwnTransparency() const;
126 //! Removes the transparency setting from this presentation attribute.
127 Standard_EXPORT void UnsetTransparency();
129 Standard_EXPORT Quantity_NameOfColor Color() const;
131 //! Sets the color aColor for this presentation attribute.
132 Standard_EXPORT void SetColor (const Quantity_NameOfColor aColor);
134 //! Returns true if this presentation attribute already has a color setting.
135 Standard_EXPORT Standard_Boolean HasOwnColor() const;
137 //! Removes the color setting from this presentation attribute.
138 Standard_EXPORT void UnsetColor();
140 Standard_EXPORT Standard_Real Width() const;
142 //! Sets the width aWidth for this presentation attribute.
143 Standard_EXPORT void SetWidth (const Standard_Real aWidth);
145 //! Returns true if this presentation attribute already has a width setting.
146 Standard_EXPORT Standard_Boolean HasOwnWidth() const;
148 //! Removes the width setting from this presentation attribute.
149 Standard_EXPORT void UnsetWidth();
151 Standard_EXPORT Standard_Integer Mode() const;
153 Standard_EXPORT void SetMode (const Standard_Integer theMode);
155 Standard_EXPORT Standard_Boolean HasOwnMode() const;
157 Standard_EXPORT void UnsetMode();
159 Standard_EXPORT Standard_Integer SelectionMode() const;
161 Standard_EXPORT void SetSelectionMode (const Standard_Integer theSelectionMode);
163 Standard_EXPORT Standard_Boolean HasOwnSelectionMode() const;
165 Standard_EXPORT void UnsetSelectionMode();
167 Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
169 Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
171 Standard_EXPORT void Restore (const Handle(TDF_Attribute)& with) Standard_OVERRIDE;
173 Standard_EXPORT void Paste (const Handle(TDF_Attribute)& into, const Handle(TDF_RelocationTable)& RT) const Standard_OVERRIDE;
175 Standard_EXPORT virtual Handle(TDF_Attribute) BackupCopy() const Standard_OVERRIDE;
177 Standard_EXPORT virtual void AfterAddition() Standard_OVERRIDE;
179 Standard_EXPORT virtual void BeforeRemoval() Standard_OVERRIDE;
181 Standard_EXPORT virtual void BeforeForget() Standard_OVERRIDE;
183 Standard_EXPORT virtual void AfterResume() Standard_OVERRIDE;
185 Standard_EXPORT virtual Standard_Boolean BeforeUndo (const Handle(TDF_AttributeDelta)& anAttDelta, const Standard_Boolean forceIt = Standard_False) Standard_OVERRIDE;
187 //! update AIS viewer according to delta
188 Standard_EXPORT virtual Standard_Boolean AfterUndo (const Handle(TDF_AttributeDelta)& anAttDelta, const Standard_Boolean forceIt = Standard_False) Standard_OVERRIDE;
190 DEFINE_STANDARD_RTTIEXT(TPrsStd_AISPresentation,TDF_Attribute)
194 //! Returns attribute storing presentation data
195 Standard_EXPORT virtual Handle(TDataXtd_Presentation) getData () const;
199 Handle(AIS_InteractiveContext) getAISContext() const;
201 //! Activates selection mode of the interactive object.
202 //! It is called internally on change of selection mode and AISUpdate().
203 void ActivateSelectionMode();
205 //! Updates AIS_InteractiveObject stored in the attribute
206 //! and applies the visualization settings
207 Standard_EXPORT void AISUpdate();
209 //! Displays AIS_InteractiveObject stored in the attribute
210 Standard_EXPORT void AISDisplay();
212 //! Erases AIS_InteractiveObject stored in the attribute in
213 //! the viewer; If <remove> = True then AISObject is removed
214 //! from AIS_InteractiveContext instead of simple erasing in the viewer
215 Standard_EXPORT void AISErase (const Standard_Boolean remove = Standard_False);
218 Handle(AIS_InteractiveObject) myAIS;
221 #endif // _TPrsStd_AISPresentation_HeaderFile