2 // Created on: 2015-08-06
3 // Created by: Ilya Novikov
4 // Copyright (c) 2004-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.
18 #ifndef _XCAFDimTolObjects_DimensionObject_HeaderFile
19 #define _XCAFDimTolObjects_DimensionObject_HeaderFile
21 #include <Standard.hxx>
22 #include <Standard_Type.hxx>
24 #include <XCAFDimTolObjects_DimensionObjectSequence.hxx>
25 #include <XCAFDimTolObjects_DimensionType.hxx>
26 #include <TColStd_HArray1OfReal.hxx>
27 #include <XCAFDimTolObjects_DimensionQualifier.hxx>
28 #include <Standard_Boolean.hxx>
29 #include <XCAFDimTolObjects_DimensionFormVariance.hxx>
30 #include <XCAFDimTolObjects_DimensionGrade.hxx>
31 #include <Standard_Integer.hxx>
32 #include <XCAFDimTolObjects_DimensionModifiersSequence.hxx>
33 #include <TopoDS_Edge.hxx>
36 #include <TColgp_HArray1OfPnt.hxx>
37 #include <Standard_Transient.hxx>
38 #include <Standard_Real.hxx>
39 #include <XCAFDimTolObjects_DimensionModif.hxx>
40 #include <TCollection_HAsciiString.hxx>
41 #include <NCollection_Vector.hxx>
42 #include <TColStd_HArray1OfExtendedString.hxx>
44 class XCAFDimTolObjects_DimensionObject;
45 DEFINE_STANDARD_HANDLE(XCAFDimTolObjects_DimensionObject, Standard_Transient)
47 //! Access object to store dimension data
48 class XCAFDimTolObjects_DimensionObject : public Standard_Transient
53 Standard_EXPORT XCAFDimTolObjects_DimensionObject();
55 Standard_EXPORT XCAFDimTolObjects_DimensionObject(const Handle(XCAFDimTolObjects_DimensionObject)& theObj);
57 //! Sets dimension qualifier as min., max. or average.
58 Standard_EXPORT void SetQualifier (const XCAFDimTolObjects_DimensionQualifier theQualifier);
60 //! Returns dimension qualifier.
61 Standard_EXPORT XCAFDimTolObjects_DimensionQualifier GetQualifier() const;
63 //! Returns True if the object has dimension qualifier.
64 Standard_EXPORT Standard_Boolean HasQualifier() const;
66 //! Sets a specific type of dimension.
67 Standard_EXPORT void SetType (const XCAFDimTolObjects_DimensionType theTyupe);
69 //! Returns dimension type.
70 Standard_EXPORT XCAFDimTolObjects_DimensionType GetType() const;
72 //! Returns the main dimension value.
73 //! It will be the middle value in case of range dimension.
74 Standard_EXPORT Standard_Real GetValue() const;
76 //! Returns raw array of dimension values
77 Standard_EXPORT Handle(TColStd_HArray1OfReal) GetValues() const;
79 //! Sets the main dimension value.
80 //! Overwrites previous values.
81 Standard_EXPORT void SetValue (const Standard_Real theValue);
83 //! Replaces current raw array of dimension values with theValues array.
84 Standard_EXPORT void SetValues (const Handle(TColStd_HArray1OfReal)& theValue);
86 //! Returns True if the dimension is of range kind.
87 //! Dimension is of range kind if its values array contains two elements
88 //! defining lower and upper bounds.
89 Standard_EXPORT Standard_Boolean IsDimWithRange() const;
91 //! Sets the upper bound of the range dimension, otherwise
92 //! resets it to an empty range with the specified upper bound.
93 Standard_EXPORT void SetUpperBound (const Standard_Real theUpperBound);
95 //! Sets the lower bound of the range dimension, otherwise
96 //! resets it to an empty range with the specified lower bound.
97 Standard_EXPORT void SetLowerBound(const Standard_Real theLowerBound);
99 //! Returns the upper bound of the range dimension, otherwise - zero.
100 Standard_EXPORT Standard_Real GetUpperBound() const;
102 //! Returns the lower bound of the range dimension, otherwise - zero.
103 Standard_EXPORT Standard_Real GetLowerBound() const;
105 //! Returns True if the dimension is of +/- tolerance kind.
106 //! Dimension is of +/- tolerance kind if its values array contains three elements
107 //! defining the main value and the lower/upper tolerances.
108 Standard_EXPORT Standard_Boolean IsDimWithPlusMinusTolerance() const;
110 //! Sets the upper value of the toleranced dimension, otherwise
111 //! resets a simple dimension to toleranced one with the specified lower/upper tolerances.
112 //! Returns False in case of range dimension.
113 Standard_EXPORT Standard_Boolean SetUpperTolValue(const Standard_Real theUperTolValue);
115 //! Sets the lower value of the toleranced dimension, otherwise
116 //! resets a simple dimension to toleranced one with the specified lower/upper tolerances.
117 //! Returns False in case of range dimension.
118 Standard_EXPORT Standard_Boolean SetLowerTolValue(const Standard_Real theLowerTolValue);
120 //! Returns the lower value of the toleranced dimension, otherwise - zero.
121 Standard_EXPORT Standard_Real GetUpperTolValue() const;
123 //! Returns the upper value of the toleranced dimension, otherwise - zero.
124 Standard_EXPORT Standard_Real GetLowerTolValue() const;
126 //! Returns True if the form variance was set to not XCAFDimTolObjects_DimensionFormVariance_None value.
127 Standard_EXPORT Standard_Boolean IsDimWithClassOfTolerance() const;
129 //! Sets tolerance class of the dimension.
130 //! \param theHole - True if the tolerance applies to an internal feature
131 //! \param theFormVariance - represents the fundamental deviation or "position letter"
132 //! of the ISO 286 limits-and-fits tolerance classification.
133 //! \param theGrade - represents the quality or the accuracy grade of a tolerance.
134 Standard_EXPORT void SetClassOfTolerance (const Standard_Boolean theHole,
135 const XCAFDimTolObjects_DimensionFormVariance theFormVariance,
136 const XCAFDimTolObjects_DimensionGrade theGrade);
138 //! Retrieves tolerance class parameters of the dimension.
139 //! Returns True if the dimension is toleranced.
140 Standard_EXPORT Standard_Boolean GetClassOfTolerance (Standard_Boolean& theHole,
141 XCAFDimTolObjects_DimensionFormVariance& theFormVariance,
142 XCAFDimTolObjects_DimensionGrade& theGrade) const;
144 //! Sets the number of places to the left and right of the decimal point respectively.
145 Standard_EXPORT void SetNbOfDecimalPlaces (const Standard_Integer theL, const Standard_Integer theR);
147 //! Returns the number of places to the left and right of the decimal point respectively.
148 Standard_EXPORT void GetNbOfDecimalPlaces(Standard_Integer& theL, Standard_Integer& theR) const;
150 //! Returns a sequence of modifiers of the dimension.
151 Standard_EXPORT XCAFDimTolObjects_DimensionModifiersSequence GetModifiers() const;
153 //! Sets new sequence of dimension modifiers.
154 Standard_EXPORT void SetModifiers (const XCAFDimTolObjects_DimensionModifiersSequence& theModifiers);
156 //! Adds a modifier to the dimension sequence of modifiers.
157 Standard_EXPORT void AddModifier (const XCAFDimTolObjects_DimensionModif theModifier);
159 //! Returns a 'curve' along which the dimension is measured.
160 Standard_EXPORT TopoDS_Edge GetPath() const;
162 //! Sets a 'curve' along which the dimension is measured.
163 Standard_EXPORT void SetPath (const TopoDS_Edge& thePath);
165 //! Returns the orientation of the dimension in annotation plane.
166 Standard_EXPORT Standard_Boolean GetDirection (gp_Dir& theDir) const;
168 //! Sets an orientation of the dimension in annotation plane.
169 Standard_EXPORT Standard_Boolean SetDirection (const gp_Dir& theDir);
171 //! Sets position of the dimension text.
172 Standard_EXPORT void SetPointTextAttach (const gp_Pnt& thePntText)
174 myPntText = thePntText;
175 myHasPntText = Standard_True;
178 //! Returns position of the dimension text.
179 Standard_EXPORT const gp_Pnt& GetPointTextAttach() const { return myPntText; }
181 //! Returns True if the position of dimension text is specified.
182 Standard_EXPORT Standard_Boolean HasTextPoint() const
187 //! Sets annotation plane.
188 Standard_EXPORT void SetPlane (const gp_Ax2& thePlane)
191 myHasPlane = Standard_True;
194 //! Returns annotation plane.
195 Standard_EXPORT const gp_Ax2& GetPlane() const { return myPlane; }
197 //! Returns True if the object has annotation plane.
198 Standard_EXPORT Standard_Boolean HasPlane() const { return myHasPlane; }
200 //! Returns true, if connection point exists (for dimesional_size),
201 //! if connection point for the first shape exists (for dimensional_location).
202 Standard_EXPORT Standard_Boolean HasPoint() const { return myHasPoint1; }
204 // Returns true, if connection point for the second shape exists (for dimensional_location only).
205 Standard_EXPORT Standard_Boolean HasPoint2() const { return myHasPoint2; }
207 //! Set connection point (for dimesional_size),
208 //! Set connection point for the first shape (for dimensional_location).
209 Standard_EXPORT void SetPoint(const gp_Pnt thePnt) {
211 myHasPoint1 = Standard_True;
214 // Set connection point for the second shape (for dimensional_location only).
215 Standard_EXPORT void SetPoint2(const gp_Pnt thePnt) {
217 myHasPoint2 = Standard_True;
220 //! Get connection point (for dimesional_size),
221 //! Get connection point for the first shape (for dimensional_location).
222 Standard_EXPORT gp_Pnt GetPoint() const {
226 // Get connection point for the second shape (for dimensional_location only).
227 Standard_EXPORT gp_Pnt GetPoint2() const {
231 //! Set graphical presentation for the object.
232 Standard_EXPORT void SetPresentation(const TopoDS_Shape& thePresentation,
233 const Handle(TCollection_HAsciiString)& thePresentationName)
235 myPresentation = thePresentation;
236 myPresentationName = thePresentationName;
239 //! Returns graphical presentation of the object.
240 Standard_EXPORT TopoDS_Shape GetPresentation() const
242 return myPresentation;
245 //! Returns graphical presentation name of the object.
246 Standard_EXPORT Handle(TCollection_HAsciiString) GetPresentationName() const
248 return myPresentationName;
251 //! Returns true, if the object has descriptions.
252 Standard_EXPORT Standard_Boolean HasDescriptions() const
254 return (myDescriptions.Length() > 0);
257 //! Returns number of descriptions.
258 Standard_EXPORT Standard_Integer NbDescriptions() const
260 return myDescriptions.Length();
263 //! Returns description with the given number.
264 Standard_EXPORT Handle(TCollection_HAsciiString) GetDescription(const Standard_Integer theNumber) const
266 if (theNumber < myDescriptions.Lower() || theNumber > myDescriptions.Upper())
267 return new TCollection_HAsciiString();
268 return myDescriptions.Value(theNumber);
271 //! Returns name of description with the given number.
272 Standard_EXPORT Handle(TCollection_HAsciiString) GetDescriptionName(const Standard_Integer theNumber) const
274 if (theNumber < myDescriptions.Lower() || theNumber > myDescriptions.Upper())
275 return new TCollection_HAsciiString();
276 return myDescriptionNames.Value(theNumber);
279 //! Remove description with the given number.
280 Standard_EXPORT void RemoveDescription(const Standard_Integer theNumber);
282 //! Add new description.
283 Standard_EXPORT void AddDescription(const Handle(TCollection_HAsciiString) theDescription, const Handle(TCollection_HAsciiString) theName)
285 myDescriptions.Append(theDescription);
286 myDescriptionNames.Append(theName);
289 DEFINE_STANDARD_RTTIEXT(XCAFDimTolObjects_DimensionObject,Standard_Transient)
293 XCAFDimTolObjects_DimensionType myType;
294 Handle(TColStd_HArray1OfReal) myVal;
295 XCAFDimTolObjects_DimensionQualifier myQualifier;
296 Standard_Boolean myIsHole;
297 XCAFDimTolObjects_DimensionFormVariance myFormVariance;
298 XCAFDimTolObjects_DimensionGrade myGrade;
299 Standard_Integer myL;
300 Standard_Integer myR;
301 XCAFDimTolObjects_DimensionModifiersSequence myModifiers;
304 gp_Pnt myPnt1, myPnt2;
305 Standard_Boolean myHasPoint1, myHasPoint2;
307 Standard_Boolean myHasPlane;
308 Standard_Boolean myHasPntText;
310 TopoDS_Shape myPresentation;
311 Handle(TCollection_HAsciiString) myPresentationName;
312 NCollection_Vector<Handle(TCollection_HAsciiString)> myDescriptions;
313 NCollection_Vector<Handle(TCollection_HAsciiString)> myDescriptionNames;
317 #endif // _XCAFDimTolObjects_DimensionObject_HeaderFile