1 // Created on: 2009-04-06
2 // Created by: Sergey ZARITCHNY
3 // Copyright (c) 2009-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _TDataXtd_Presentation_HeaderFile
17 #define _TDataXtd_Presentation_HeaderFile
19 #include <Standard.hxx>
20 #include <Standard_Type.hxx>
21 #include <Standard_GUID.hxx>
24 #include <TDF_Attribute.hxx>
25 #include <Quantity_NameOfColor.hxx>
26 #include <TColStd_ListOfInteger.hxx>
32 class TDF_RelocationTable;
35 class TDataXtd_Presentation;
36 DEFINE_STANDARD_HANDLE(TDataXtd_Presentation, TDF_Attribute)
38 //! Attribute containing parameters of presentation of the shape,
39 //! e.g. the shape attached to the same label and displayed using
40 //! TPrsStd tools (see TPrsStd_AISPresentation).
41 class TDataXtd_Presentation : public TDF_Attribute
44 //!@name Attribute mechanics
47 Standard_EXPORT TDataXtd_Presentation();
49 //! Create if not found the TDataXtd_Presentation attribute and set its driver GUID
50 Standard_EXPORT static Handle(TDataXtd_Presentation) Set(const TDF_Label& theLabel, const Standard_GUID& theDriverId);
52 //! Remove attribute of this type from the label
53 Standard_EXPORT static void Unset(const TDF_Label& theLabel);
55 //! Returns the ID of the attribute.
56 Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
58 //! Returns the ID of the attribute.
59 Standard_EXPORT static const Standard_GUID& GetID();
61 //! Restores the contents from <anAttribute> into this
62 //! one. It is used when aborting a transaction.
63 Standard_EXPORT virtual void Restore (const Handle(TDF_Attribute)& anAttribute) Standard_OVERRIDE;
65 //! Returns an new empty attribute from the good end
66 //! type. It is used by the copy algorithm.
67 Standard_EXPORT virtual Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
69 //! This method is different from the "Copy" one,
70 //! because it is used when copying an attribute from
71 //! a source structure into a target structure. This
72 //! method pastes the current attribute to the label
73 //! corresponding to the insertor. The pasted
74 //! attribute may be a brand new one or a new version
75 //! of the previous one.
76 Standard_EXPORT virtual void Paste (const Handle(TDF_Attribute)& intoAttribute,
77 const Handle(TDF_RelocationTable)& aRelocTationable) const Standard_OVERRIDE;
79 Standard_EXPORT Handle(TDF_Attribute) BackupCopy() const Standard_OVERRIDE;
81 DEFINE_STANDARD_RTTIEXT(TDataXtd_Presentation,TDF_Attribute)
84 //!@name Access to data
86 //! Returns the GUID of the driver managing display of associated AIS object
87 Standard_EXPORT Standard_GUID GetDriverGUID() const;
89 //! Sets the GUID of the driver managing display of associated AIS object
90 Standard_EXPORT void SetDriverGUID(const Standard_GUID& theGUID);
92 Standard_EXPORT Standard_Boolean IsDisplayed() const;
94 Standard_EXPORT Standard_Boolean HasOwnMaterial() const;
96 Standard_EXPORT Standard_Boolean HasOwnTransparency() const;
98 Standard_EXPORT Standard_Boolean HasOwnColor() const;
100 Standard_EXPORT Standard_Boolean HasOwnWidth() const;
102 Standard_EXPORT Standard_Boolean HasOwnMode() const;
104 Standard_EXPORT Standard_Boolean HasOwnSelectionMode() const;
106 Standard_EXPORT void SetDisplayed(const Standard_Boolean theIsDisplayed);
108 Standard_EXPORT void SetMaterialIndex(const Standard_Integer theMaterialIndex);
110 Standard_EXPORT void SetTransparency(const Standard_Real theValue);
112 Standard_EXPORT void SetColor(const Quantity_NameOfColor theColor);
114 Standard_EXPORT void SetWidth(const Standard_Real theWidth);
116 Standard_EXPORT void SetMode(const Standard_Integer theMode);
118 //! Returns the number of selection modes of the attribute.
119 //! It starts with 1 .. GetNbSelectionModes().
120 Standard_EXPORT Standard_Integer GetNbSelectionModes() const;
122 //! Sets selection mode.
123 //! If "theTransaction" flag is OFF, modification of the attribute doesn't influence the transaction mechanism
124 //! (the attribute doesn't participate in undo/redo because of this modification).
125 //! Certainly, if any other data of the attribute is modified (display mode, color, ...),
126 //! the attribute will be included into undo/redo.
127 Standard_EXPORT void SetSelectionMode(const Standard_Integer theSelectionMode, const Standard_Boolean theTransaction = Standard_True);
128 Standard_EXPORT void AddSelectionMode(const Standard_Integer theSelectionMode, const Standard_Boolean theTransaction = Standard_True);
130 Standard_EXPORT Standard_Integer MaterialIndex() const;
132 Standard_EXPORT Standard_Real Transparency() const;
134 Standard_EXPORT Quantity_NameOfColor Color() const;
136 Standard_EXPORT Standard_Real Width() const;
138 Standard_EXPORT Standard_Integer Mode() const;
140 Standard_EXPORT Standard_Integer SelectionMode(const int index = 1) const;
142 Standard_EXPORT void UnsetMaterial();
144 Standard_EXPORT void UnsetTransparency();
146 Standard_EXPORT void UnsetColor();
148 Standard_EXPORT void UnsetWidth();
150 Standard_EXPORT void UnsetMode();
152 Standard_EXPORT void UnsetSelectionMode();
155 //! Convert values of old Quantity_NameOfColor to new enumeration for reading old documents
156 //! after #0030969 (Coding Rules - refactor Quantity_Color.cxx color table definition).
157 Standard_EXPORT static Quantity_NameOfColor getColorNameFromOldEnum (Standard_Integer theOld);
159 //! Convert Quantity_NameOfColor to old enumeration value for writing documents in compatible format.
160 Standard_EXPORT static Standard_Integer getOldColorNameFromNewEnum (Quantity_NameOfColor theNew);
163 Standard_GUID myDriverGUID;
164 Quantity_NameOfColor myColor;
165 Standard_Integer myMaterialIndex;
166 Standard_Integer myMode;
167 TColStd_ListOfInteger mySelectionModes;
168 Standard_Real myTransparency;
169 Standard_Real myWidth;
170 Standard_Boolean myIsDisplayed;
171 Standard_Boolean myHasOwnColor;
172 Standard_Boolean myHasOwnMaterial;
173 Standard_Boolean myHasOwnTransparency;
174 Standard_Boolean myHasOwnWidth;
175 Standard_Boolean myHasOwnMode;
176 Standard_Boolean myHasOwnSelectionMode;
178 //! Checks a list of selection modes.
179 Standard_Boolean HasSelectionMode(const Standard_Integer theSelectionMode) const;
182 #endif // _TDataXtd_Presentation_HeaderFile