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 //! Returns semantic name
58 Standard_EXPORT Handle(TCollection_HAsciiString) GetSemanticName() const;
60 //! Sets semantic name
61 Standard_EXPORT void SetSemanticName(const Handle(TCollection_HAsciiString)& theName);
63 //! Sets dimension qualifier as min., max. or average.
64 Standard_EXPORT void SetQualifier (const XCAFDimTolObjects_DimensionQualifier theQualifier);
66 //! Returns dimension qualifier.
67 Standard_EXPORT XCAFDimTolObjects_DimensionQualifier GetQualifier() const;
69 //! Returns True if the object has dimension qualifier.
70 Standard_EXPORT Standard_Boolean HasQualifier() const;
72 //! Sets a specific type of dimension.
73 Standard_EXPORT void SetType (const XCAFDimTolObjects_DimensionType theTyupe);
75 //! Returns dimension type.
76 Standard_EXPORT XCAFDimTolObjects_DimensionType GetType() const;
78 //! Returns the main dimension value.
79 //! It will be the middle value in case of range dimension.
80 Standard_EXPORT Standard_Real GetValue() const;
82 //! Returns raw array of dimension values
83 Standard_EXPORT Handle(TColStd_HArray1OfReal) GetValues() const;
85 //! Sets the main dimension value.
86 //! Overwrites previous values.
87 Standard_EXPORT void SetValue (const Standard_Real theValue);
89 //! Replaces current raw array of dimension values with theValues array.
90 Standard_EXPORT void SetValues (const Handle(TColStd_HArray1OfReal)& theValue);
92 //! Returns True if the dimension is of range kind.
93 //! Dimension is of range kind if its values array contains two elements
94 //! defining lower and upper bounds.
95 Standard_EXPORT Standard_Boolean IsDimWithRange() const;
97 //! Sets the upper bound of the range dimension, otherwise
98 //! resets it to an empty range with the specified upper bound.
99 Standard_EXPORT void SetUpperBound (const Standard_Real theUpperBound);
101 //! Sets the lower bound of the range dimension, otherwise
102 //! resets it to an empty range with the specified lower bound.
103 Standard_EXPORT void SetLowerBound(const Standard_Real theLowerBound);
105 //! Returns the upper bound of the range dimension, otherwise - zero.
106 Standard_EXPORT Standard_Real GetUpperBound() const;
108 //! Returns the lower bound of the range dimension, otherwise - zero.
109 Standard_EXPORT Standard_Real GetLowerBound() const;
111 //! Returns True if the dimension is of +/- tolerance kind.
112 //! Dimension is of +/- tolerance kind if its values array contains three elements
113 //! defining the main value and the lower/upper tolerances.
114 Standard_EXPORT Standard_Boolean IsDimWithPlusMinusTolerance() const;
116 //! Sets the upper value of the toleranced dimension, otherwise
117 //! resets a simple dimension to toleranced one with the specified lower/upper tolerances.
118 //! Returns False in case of range dimension.
119 Standard_EXPORT Standard_Boolean SetUpperTolValue(const Standard_Real theUperTolValue);
121 //! Sets the lower value of the toleranced dimension, otherwise
122 //! resets a simple dimension to toleranced one with the specified lower/upper tolerances.
123 //! Returns False in case of range dimension.
124 Standard_EXPORT Standard_Boolean SetLowerTolValue(const Standard_Real theLowerTolValue);
126 //! Returns the lower value of the toleranced dimension, otherwise - zero.
127 Standard_EXPORT Standard_Real GetUpperTolValue() const;
129 //! Returns the upper value of the toleranced dimension, otherwise - zero.
130 Standard_EXPORT Standard_Real GetLowerTolValue() const;
132 //! Returns True if the form variance was set to not XCAFDimTolObjects_DimensionFormVariance_None value.
133 Standard_EXPORT Standard_Boolean IsDimWithClassOfTolerance() const;
135 //! Sets tolerance class of the dimension.
136 //! \param theHole - True if the tolerance applies to an internal feature
137 //! \param theFormVariance - represents the fundamental deviation or "position letter"
138 //! of the ISO 286 limits-and-fits tolerance classification.
139 //! \param theGrade - represents the quality or the accuracy grade of a tolerance.
140 Standard_EXPORT void SetClassOfTolerance (const Standard_Boolean theHole,
141 const XCAFDimTolObjects_DimensionFormVariance theFormVariance,
142 const XCAFDimTolObjects_DimensionGrade theGrade);
144 //! Retrieves tolerance class parameters of the dimension.
145 //! Returns True if the dimension is toleranced.
146 Standard_EXPORT Standard_Boolean GetClassOfTolerance (Standard_Boolean& theHole,
147 XCAFDimTolObjects_DimensionFormVariance& theFormVariance,
148 XCAFDimTolObjects_DimensionGrade& theGrade) const;
150 //! Sets the number of places to the left and right of the decimal point respectively.
151 Standard_EXPORT void SetNbOfDecimalPlaces (const Standard_Integer theL, const Standard_Integer theR);
153 //! Returns the number of places to the left and right of the decimal point respectively.
154 Standard_EXPORT void GetNbOfDecimalPlaces(Standard_Integer& theL, Standard_Integer& theR) const;
156 //! Returns a sequence of modifiers of the dimension.
157 Standard_EXPORT XCAFDimTolObjects_DimensionModifiersSequence GetModifiers() const;
159 //! Sets new sequence of dimension modifiers.
160 Standard_EXPORT void SetModifiers (const XCAFDimTolObjects_DimensionModifiersSequence& theModifiers);
162 //! Adds a modifier to the dimension sequence of modifiers.
163 Standard_EXPORT void AddModifier (const XCAFDimTolObjects_DimensionModif theModifier);
165 //! Returns a 'curve' along which the dimension is measured.
166 Standard_EXPORT TopoDS_Edge GetPath() const;
168 //! Sets a 'curve' along which the dimension is measured.
169 Standard_EXPORT void SetPath (const TopoDS_Edge& thePath);
171 //! Returns the orientation of the dimension in annotation plane.
172 Standard_EXPORT Standard_Boolean GetDirection (gp_Dir& theDir) const;
174 //! Sets an orientation of the dimension in annotation plane.
175 Standard_EXPORT Standard_Boolean SetDirection (const gp_Dir& theDir);
177 //! Sets position of the dimension text.
178 void SetPointTextAttach (const gp_Pnt& thePntText)
180 myPntText = thePntText;
181 myHasPntText = Standard_True;
184 //! Returns position of the dimension text.
185 const gp_Pnt& GetPointTextAttach() const { return myPntText; }
187 //! Returns True if the position of dimension text is specified.
188 Standard_Boolean HasTextPoint() const
193 //! Sets annotation plane.
194 void SetPlane (const gp_Ax2& thePlane)
197 myHasPlane = Standard_True;
200 //! Returns annotation plane.
201 const gp_Ax2& GetPlane() const { return myPlane; }
203 //! Returns True if the object has annotation plane.
204 Standard_Boolean HasPlane() const { return myHasPlane; }
206 //! Returns true, if connection point exists (for dimesional_size),
207 //! if connection point for the first shape exists (for dimensional_location).
208 Standard_Boolean HasPoint() const { return myHasPoint1; }
210 // Returns true, if connection point for the second shape exists (for dimensional_location only).
211 Standard_Boolean HasPoint2() const { return myHasPoint2; }
213 //! Set connection point (for dimesional_size),
214 //! Set connection point for the first shape (for dimensional_location).
215 void SetPoint(const gp_Pnt thePnt) {
217 myHasPoint1 = Standard_True;
220 // Set connection point for the second shape (for dimensional_location only).
221 void SetPoint2(const gp_Pnt thePnt) {
223 myHasPoint2 = Standard_True;
226 //! Get connection point (for dimesional_size),
227 //! Get connection point for the first shape (for dimensional_location).
228 gp_Pnt GetPoint() const {
232 // Get connection point for the second shape (for dimensional_location only).
233 gp_Pnt GetPoint2() const {
237 //! Set graphical presentation for the object.
238 void SetPresentation(const TopoDS_Shape& thePresentation,
239 const Handle(TCollection_HAsciiString)& thePresentationName)
241 myPresentation = thePresentation;
242 myPresentationName = thePresentationName;
245 //! Returns graphical presentation of the object.
246 TopoDS_Shape GetPresentation() const
248 return myPresentation;
251 //! Returns graphical presentation of the object
252 Standard_EXPORT Handle(TCollection_HAsciiString) GetPresentationName() const
254 return myPresentationName;
257 //! Returns true, if the object has descriptions.
258 Standard_Boolean HasDescriptions() const
260 return (myDescriptions.Length() > 0);
263 //! Returns number of descriptions.
264 Standard_Integer NbDescriptions() const
266 return myDescriptions.Length();
269 //! Returns description with the given number.
270 Handle(TCollection_HAsciiString) GetDescription(const Standard_Integer theNumber) const
272 if (theNumber < myDescriptions.Lower() || theNumber > myDescriptions.Upper())
273 return new TCollection_HAsciiString();
274 return myDescriptions.Value(theNumber);
277 //! Returns name of description with the given number.
278 Handle(TCollection_HAsciiString) GetDescriptionName(const Standard_Integer theNumber) const
280 if (theNumber < myDescriptions.Lower() || theNumber > myDescriptions.Upper())
281 return new TCollection_HAsciiString();
282 return myDescriptionNames.Value(theNumber);
285 //! Remove description with the given number.
286 Standard_EXPORT void RemoveDescription(const Standard_Integer theNumber);
288 //! Add new description.
289 void AddDescription(const Handle(TCollection_HAsciiString) theDescription, const Handle(TCollection_HAsciiString) theName)
291 myDescriptions.Append(theDescription);
292 myDescriptionNames.Append(theName);
295 DEFINE_STANDARD_RTTIEXT(XCAFDimTolObjects_DimensionObject,Standard_Transient)
299 XCAFDimTolObjects_DimensionType myType;
300 Handle(TColStd_HArray1OfReal) myVal;
301 XCAFDimTolObjects_DimensionQualifier myQualifier;
302 Standard_Boolean myIsHole;
303 XCAFDimTolObjects_DimensionFormVariance myFormVariance;
304 XCAFDimTolObjects_DimensionGrade myGrade;
305 Standard_Integer myL;
306 Standard_Integer myR;
307 XCAFDimTolObjects_DimensionModifiersSequence myModifiers;
310 gp_Pnt myPnt1, myPnt2;
311 Standard_Boolean myHasPoint1, myHasPoint2;
313 Standard_Boolean myHasPlane;
314 Standard_Boolean myHasPntText;
316 TopoDS_Shape myPresentation;
317 Handle(TCollection_HAsciiString) mySemanticName;
318 Handle(TCollection_HAsciiString) myPresentationName;
319 NCollection_Vector<Handle(TCollection_HAsciiString)> myDescriptions;
320 NCollection_Vector<Handle(TCollection_HAsciiString)> myDescriptionNames;
324 #endif // _XCAFDimTolObjects_DimensionObject_HeaderFile