1 // Created on: 2004-01-09
2 // Created by: Sergey KUUL
3 // Copyright (c) 2004-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 _XCAFDoc_DimTolTool_HeaderFile
17 #define _XCAFDoc_DimTolTool_HeaderFile
19 #include <Standard.hxx>
20 #include <Standard_Type.hxx>
22 #include <TDF_Attribute.hxx>
23 #include <Standard_Boolean.hxx>
24 #include <TDF_LabelSequence.hxx>
25 #include <Standard_Integer.hxx>
26 #include <TColStd_HArray1OfReal.hxx>
27 #include <TopoDS_Shape.hxx>
29 class XCAFDoc_ShapeTool;
32 class TCollection_HAsciiString;
34 class TDF_RelocationTable;
37 class XCAFDoc_DimTolTool;
38 DEFINE_STANDARD_HANDLE(XCAFDoc_DimTolTool, TDF_Attribute)
40 //! Attribute containing GD&T section of XCAF document.
41 //! Provide tools for GD&T section management.
42 class XCAFDoc_DimTolTool : public TDF_Attribute
48 Standard_EXPORT XCAFDoc_DimTolTool();
50 //! Creates (if not exist) DimTolTool attribute.
51 Standard_EXPORT static Handle(XCAFDoc_DimTolTool) Set (const TDF_Label& L);
53 //! Returns the standard GD&T tool GUID.
54 Standard_EXPORT static const Standard_GUID& GetID();
56 //! Returns the label under which GD&T table is stored.
57 Standard_EXPORT TDF_Label BaseLabel() const;
59 //! Returns internal XCAFDoc_ShapeTool tool
60 Standard_EXPORT const Handle(XCAFDoc_ShapeTool)& ShapeTool();
62 //! Returns True if the label belongs to a GD&T table and
63 //! is a Dimension definition.
64 Standard_EXPORT Standard_Boolean IsDimension (const TDF_Label& theLab) const;
66 //! Returns a sequence of Dimension labels currently stored
67 //! in the GD&T table.
68 Standard_EXPORT void GetDimensionLabels (TDF_LabelSequence& theLabels) const;
70 //! Sets a dimension to sequences target labels.
71 Standard_EXPORT void SetDimension (const TDF_LabelSequence& theFirstLS,
72 const TDF_LabelSequence& theSecondLS,
73 const TDF_Label& theDimL) const;
75 //! Sets a dimension to target labels.
76 Standard_EXPORT void SetDimension(const TDF_Label& theFirstL,
77 const TDF_Label& theSecondL,
78 const TDF_Label& theDimL) const;
80 //! Sets a dimension to the target label.
81 Standard_EXPORT void SetDimension (const TDF_Label& theL,
82 const TDF_Label& theDimL) const;
84 //! Returns all Dimension labels defined for theShapeL.
85 Standard_EXPORT Standard_Boolean GetRefDimensionLabels (const TDF_Label& theShapeL,
86 TDF_LabelSequence& theDimensions) const;
88 //! Adds a dimension definition to the GD&T table and returns its label.
89 Standard_EXPORT TDF_Label AddDimension() ;
91 //! Returns True if the label belongs to the GD&T table and is a dimension tolerance.
92 Standard_EXPORT Standard_Boolean IsGeomTolerance (const TDF_Label& theLab) const;
94 //! Returns a sequence of Tolerance labels currently stored in the GD&T table.
95 Standard_EXPORT void GetGeomToleranceLabels (TDF_LabelSequence& theLabels) const;
97 //! Sets a geometry tolerance from theGeomTolL to theL label.
98 //! Checks if theGeomTolL is a geometry tolerance definition first.
99 Standard_EXPORT void SetGeomTolerance (const TDF_Label& theL,
100 const TDF_Label& theGeomTolL) const;
102 //! Sets a geometry tolerance from theGeomTolL to sequence of labels theL.
103 //! Checks if theGeomTolL is a geometry tolerance definition first.
104 Standard_EXPORT void SetGeomTolerance(const TDF_LabelSequence& theL,
105 const TDF_Label& theGeomTolL) const;
107 //! Returns all GeomTolerance labels defined for theShapeL.
108 Standard_EXPORT Standard_Boolean GetRefGeomToleranceLabels (const TDF_Label& theShapeL,
109 TDF_LabelSequence& theDimTols) const;
111 //! Adds a GeomTolerance definition to the GD&T table and returns its label.
112 Standard_EXPORT TDF_Label AddGeomTolerance();
114 //! Returns True if theLab belongs to the GD&T table and is a dmension tolerance.
115 Standard_EXPORT Standard_Boolean IsDimTol(const TDF_Label& theLab) const;
117 //! Returns a sequence of D>s currently stored in the GD&T table.
118 Standard_EXPORT void GetDimTolLabels (TDF_LabelSequence& Labels) const;
120 //! Finds a dimension tolerance definition in the GD&T table
121 //! sutisfying the specified kind, values, name and description
122 //! and returns its label if found.
123 //! Returns False if dimension tolerance is not found in DGTtable.
124 Standard_EXPORT Standard_Boolean FindDimTol (const Standard_Integer theKind,
125 const Handle(TColStd_HArray1OfReal)& theVal,
126 const Handle(TCollection_HAsciiString)& theName,
127 const Handle(TCollection_HAsciiString)& theDescription,
128 TDF_Label& lab) const;
130 //! Finds a dimension tolerance in the GD&T table
131 //! sutisfying the specified kind, values, name and description
132 //! and returns its label if found (or Null label else).
133 Standard_EXPORT TDF_Label FindDimTol (const Standard_Integer theKind,
134 const Handle(TColStd_HArray1OfReal)& theVal,
135 const Handle(TCollection_HAsciiString)& theName,
136 const Handle(TCollection_HAsciiString)& theDescription) const;
138 //! Adds a a dimension tolerance definition with the specified
139 //! kind, value, name and description to the GD&T table and returns its label.
140 Standard_EXPORT TDF_Label AddDimTol (const Standard_Integer theKind,
141 const Handle(TColStd_HArray1OfReal)& theVal,
142 const Handle(TCollection_HAsciiString)& theName,
143 const Handle(TCollection_HAsciiString)& theDescription) const;
145 //! Sets existing dimension tolerance to theL label.
146 Standard_EXPORT void SetDimTol (const TDF_Label& theL,
147 const TDF_Label& theDimTolL) const;
149 //! Creates a dimension tolerance and sets it to theL label.
150 Standard_EXPORT TDF_Label SetDimTol (const TDF_Label& theL,
151 const Standard_Integer theKind,
152 const Handle(TColStd_HArray1OfReal)& theVal,
153 const Handle(TCollection_HAsciiString)& theName,
154 const Handle(TCollection_HAsciiString)& theDescription) const;
156 //! Gets all shape labels reffered by theL label of the GD&T table.
157 //! Returns False if there are no shape labels added to the sequences.
158 Standard_EXPORT Standard_Boolean GetRefShapeLabel (const TDF_Label& theL,
159 TDF_LabelSequence& theShapeLFirst,
160 TDF_LabelSequence& theShapeLSecond) const;
162 //! Returns dimension tolerance assigned to theDimTolL label.
163 //! Returns False if no such dimension tolerance is assigned.
164 Standard_EXPORT Standard_Boolean GetDimTol (const TDF_Label& theDimTolL,
165 Standard_Integer& theKind,
166 Handle(TColStd_HArray1OfReal)& theVal,
167 Handle(TCollection_HAsciiString)& theName,
168 Handle(TCollection_HAsciiString)& theDescription) const;
170 //! Returns True if label belongs to the GD&T table and
171 //! is a Datum definition.
172 Standard_EXPORT Standard_Boolean IsDatum (const TDF_Label& lab) const;
174 //! Returns a sequence of Datums currently stored
175 //! in the GD&T table.
176 Standard_EXPORT void GetDatumLabels (TDF_LabelSequence& Labels) const;
178 //! Finds a datum sutisfying the specified name, description and
179 //! identification and returns its label if found.
180 Standard_EXPORT Standard_Boolean FindDatum (const Handle(TCollection_HAsciiString)& theName,
181 const Handle(TCollection_HAsciiString)& theDescription,
182 const Handle(TCollection_HAsciiString)& theIdentification,
183 TDF_Label& lab) const;
185 //! Adds a datum definition to the GD&T table and returns its label.
186 Standard_EXPORT TDF_Label AddDatum (const Handle(TCollection_HAsciiString)& theName,
187 const Handle(TCollection_HAsciiString)& theDescription,
188 const Handle(TCollection_HAsciiString)& theIdentification) const;
190 //! Adds a datum definition to the GD&T table and returns its label.
191 Standard_EXPORT TDF_Label AddDatum() ;
193 //! Sets a datum to the sequence of shape labels.
194 Standard_EXPORT void SetDatum (const TDF_LabelSequence& theShapeLabels,
195 const TDF_Label& theDatumL) const;
197 //! Sets a datum to theL label and binds it with theTolerL label.
198 //! A datum with the specified name, description and identification
199 //! is created if it isn't found in the GD&T table.
200 Standard_EXPORT void SetDatum (const TDF_Label& theL,
201 const TDF_Label& theTolerL,
202 const Handle(TCollection_HAsciiString)& theName,
203 const Handle(TCollection_HAsciiString)& theDescription,
204 const Handle(TCollection_HAsciiString)& theIdentification) const;
206 //! Sets a datum from theDatumL label to theToletL label.
207 Standard_EXPORT void SetDatumToGeomTol (const TDF_Label& theDatumL,
208 const TDF_Label& theTolerL) const;
210 //! Returns datum assigned to theDatumL label.
211 //! Returns False if no such datum is assigned.
212 Standard_EXPORT Standard_Boolean GetDatum (const TDF_Label& theDatumL,
213 Handle(TCollection_HAsciiString)& theName,
214 Handle(TCollection_HAsciiString)& theDescription,
215 Handle(TCollection_HAsciiString)& theIdentification) const;
217 //! Returns all Datum labels defined for theDimTolL label.
218 Standard_EXPORT Standard_Boolean GetDatumOfTolerLabels (const TDF_Label& theDimTolL,
219 TDF_LabelSequence& theDatums) const;
221 //! Returns all Datum labels with XCAFDimTolObjects_DatumObject defined for label theDimTolL.
222 Standard_EXPORT Standard_Boolean GetDatumWithObjectOfTolerLabels (const TDF_Label& theDimTolL,
223 TDF_LabelSequence& theDatums) const;
225 //! Returns all GeomToleranses labels defined for theDatumL label.
226 Standard_EXPORT Standard_Boolean GetTolerOfDatumLabels (const TDF_Label& theDatumL,
227 TDF_LabelSequence& theTols) const;
229 //! Returns Datum label defined for theShapeL label.
230 Standard_EXPORT Standard_Boolean GetRefDatumLabel (const TDF_Label& theShapeL,
231 TDF_LabelSequence& theDatum) const;
233 //! Returns true if the given GDT is marked as locked.
234 Standard_EXPORT Standard_Boolean IsLocked(const TDF_Label& theViewL) const;
236 //! Mark the given GDT as locked.
237 Standard_EXPORT void Lock(const TDF_Label& theViewL) const;
239 //! Unlock the given GDT.
240 Standard_EXPORT void Unlock(const TDF_Label& theViewL) const;
242 Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
244 Standard_EXPORT void Restore (const Handle(TDF_Attribute)& with) Standard_OVERRIDE;
246 Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
248 Standard_EXPORT void Paste (const Handle(TDF_Attribute)& into, const Handle(TDF_RelocationTable)& RT) const Standard_OVERRIDE;
253 DEFINE_STANDARD_RTTIEXT(XCAFDoc_DimTolTool,TDF_Attribute)
263 Handle(XCAFDoc_ShapeTool) myShapeTool;
274 #endif // _XCAFDoc_DimTolTool_HeaderFile