0029119: Documentation for PMI in XCAF
[occt.git] / src / XCAFDoc / XCAFDoc_DimTolTool.hxx
1 // Created on: 2004-01-09
2 // Created by: Sergey KUUL
3 // Copyright (c) 2004-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef _XCAFDoc_DimTolTool_HeaderFile
17 #define _XCAFDoc_DimTolTool_HeaderFile
18
19 #include <Standard.hxx>
20 #include <Standard_Type.hxx>
21
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>
28
29 class XCAFDoc_ShapeTool;
30 class TDF_Label;
31 class Standard_GUID;
32 class TCollection_HAsciiString;
33 class TDF_Attribute;
34 class TDF_RelocationTable;
35
36
37 class XCAFDoc_DimTolTool;
38 DEFINE_STANDARD_HANDLE(XCAFDoc_DimTolTool, TDF_Attribute)
39
40 //! Attribute containing GD&T section of XCAF document.
41 //! Provide tools for GD&T section management.
42 class XCAFDoc_DimTolTool : public TDF_Attribute
43 {
44
45 public:
46
47   
48   Standard_EXPORT XCAFDoc_DimTolTool();
49   
50   //! Creates (if not exist) DimTolTool attribute.
51   Standard_EXPORT static Handle(XCAFDoc_DimTolTool) Set (const TDF_Label& L);
52   
53   //! Returns the standard GD&T tool GUID.
54   Standard_EXPORT static const Standard_GUID& GetID();
55   
56   //! Returns the label under which GD&T table is stored.
57   Standard_EXPORT TDF_Label BaseLabel() const;
58   
59   //! Returns internal XCAFDoc_ShapeTool tool
60   Standard_EXPORT const Handle(XCAFDoc_ShapeTool)& ShapeTool();
61
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;
65   
66   //! Returns a sequence of Dimension labels currently stored
67   //! in the GD&T table.
68   Standard_EXPORT void GetDimensionLabels (TDF_LabelSequence& theLabels) const;
69   
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;
74
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;
79   
80   //! Sets a dimension to the target label.
81   Standard_EXPORT void SetDimension (const TDF_Label& theL, 
82                                      const TDF_Label& theDimL) const;
83   
84   //! Returns all Dimension labels defined for theShapeL.
85   Standard_EXPORT Standard_Boolean GetRefDimensionLabels (const TDF_Label& theShapeL, 
86                                                           TDF_LabelSequence& theDimensions) const;
87   
88   //! Adds a dimension definition to the GD&T table and returns its label.
89   Standard_EXPORT TDF_Label AddDimension() ;
90   
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;
93   
94   //! Returns a sequence of Tolerance labels currently stored in the GD&T table.
95   Standard_EXPORT void GetGeomToleranceLabels (TDF_LabelSequence& theLabels) const;
96   
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;
101
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;
106   
107   //! Returns all GeomTolerance labels defined for theShapeL.
108   Standard_EXPORT Standard_Boolean GetRefGeomToleranceLabels (const TDF_Label& theShapeL, 
109                                                               TDF_LabelSequence& theDimTols) const;
110   
111   //! Adds a GeomTolerance definition to the GD&T table and returns its label.
112   Standard_EXPORT TDF_Label AddGeomTolerance();
113   
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;
116   
117   //! Returns a sequence of D&GTs currently stored in the GD&T table.
118   Standard_EXPORT void GetDimTolLabels (TDF_LabelSequence& Labels) const;
119   
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;
129   
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;
137   
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;
144   
145   //! Sets existing dimension tolerance to theL label.
146   Standard_EXPORT void SetDimTol (const TDF_Label& theL, 
147                                   const TDF_Label& theDimTolL) const;
148   
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;
155   
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;
161   
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;
169   
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;
173   
174   //! Returns a sequence of Datums currently stored
175   //! in the GD&T table.
176   Standard_EXPORT void GetDatumLabels (TDF_LabelSequence& Labels) const;
177   
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;
184   
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;
189
190   //! Adds a datum definition to the GD&T table and returns its label.
191   Standard_EXPORT TDF_Label AddDatum() ;
192   
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;
196   
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;
205
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;
209   
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;
216   
217   //! Returns all Datum labels defined for theDimTolL label.
218   Standard_EXPORT Standard_Boolean GetDatumOfTolerLabels (const TDF_Label& theDimTolL, 
219                                                           TDF_LabelSequence& theDatums) const;
220
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;
224
225   //! Returns all GeomToleranses labels defined for theDatumL label.
226   Standard_EXPORT Standard_Boolean GetTolerOfDatumLabels (const TDF_Label& theDatumL, 
227                                                           TDF_LabelSequence& theTols)  const;
228
229   //! Returns Datum label defined for theShapeL label.
230   Standard_EXPORT Standard_Boolean GetRefDatumLabel (const TDF_Label& theShapeL, 
231                                                      TDF_LabelSequence& theDatum)  const;
232
233   //! Returns true if the given GDT is marked as locked.
234   Standard_EXPORT Standard_Boolean IsLocked(const TDF_Label& theViewL) const;
235
236   //! Mark the given GDT as locked.
237   Standard_EXPORT void Lock(const TDF_Label& theViewL) const;
238
239   //! Unlock the given GDT.
240   Standard_EXPORT void Unlock(const TDF_Label& theViewL) const;
241     
242   Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
243   
244   Standard_EXPORT void Restore (const Handle(TDF_Attribute)& with) Standard_OVERRIDE;
245   
246   Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
247   
248   Standard_EXPORT void Paste (const Handle(TDF_Attribute)& into, const Handle(TDF_RelocationTable)& RT) const Standard_OVERRIDE;
249
250
251
252
253   DEFINE_STANDARD_RTTIEXT(XCAFDoc_DimTolTool,TDF_Attribute)
254
255 protected:
256
257
258
259
260 private:
261
262
263   Handle(XCAFDoc_ShapeTool) myShapeTool;
264
265
266 };
267
268
269
270
271
272
273
274 #endif // _XCAFDoc_DimTolTool_HeaderFile