1 2 // Created on: 2015-08-06 3 // Created by: Ilya Novikov 4 // Copyright (c) 2004-2014 OPEN CASCADE SAS 5 // 6 // This file is part of Open CASCADE Technology software library. 7 // 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. 13 // 14 // Alternatively, this file may be used under the terms of Open CASCADE 15 // commercial license or contractual agreement. 16 17 18 #ifndef _XCAFDimTolObjects_DimensionObject_HeaderFile 19 #define _XCAFDimTolObjects_DimensionObject_HeaderFile 20 21 #include <Standard.hxx> 22 #include <Standard_Type.hxx> 23 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> 34 #include <gp_Dir.hxx> 35 #include <gp_Ax2.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> 43 44 class XCAFDimTolObjects_DimensionObject; 45 DEFINE_STANDARD_HANDLE(XCAFDimTolObjects_DimensionObject, Standard_Transient) 46 47 //! Access object to store dimension data 48 class XCAFDimTolObjects_DimensionObject : public Standard_Transient 49 { 50 51 public: 52 53 Standard_EXPORT XCAFDimTolObjects_DimensionObject(); 54 55 Standard_EXPORT XCAFDimTolObjects_DimensionObject(const Handle(XCAFDimTolObjects_DimensionObject)& theObj); 56 57 //! Returns semantic name 58 Standard_EXPORT Handle(TCollection_HAsciiString) GetSemanticName() const; 59 60 //! Sets semantic name 61 Standard_EXPORT void SetSemanticName(const Handle(TCollection_HAsciiString)& theName); 62 63 //! Sets dimension qualifier as min., max. or average. 64 Standard_EXPORT void SetQualifier (const XCAFDimTolObjects_DimensionQualifier theQualifier); 65 66 //! Returns dimension qualifier. 67 Standard_EXPORT XCAFDimTolObjects_DimensionQualifier GetQualifier() const; 68 69 //! Returns True if the object has dimension qualifier. 70 Standard_EXPORT Standard_Boolean HasQualifier() const; 71 72 //! Sets a specific type of dimension. 73 Standard_EXPORT void SetType (const XCAFDimTolObjects_DimensionType theTyupe); 74 75 //! Returns dimension type. 76 Standard_EXPORT XCAFDimTolObjects_DimensionType GetType() const; 77 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; 81 82 //! Returns raw array of dimension values 83 Standard_EXPORT Handle(TColStd_HArray1OfReal) GetValues() const; 84 85 //! Sets the main dimension value. 86 //! Overwrites previous values. 87 Standard_EXPORT void SetValue (const Standard_Real theValue); 88 89 //! Replaces current raw array of dimension values with theValues array. 90 Standard_EXPORT void SetValues (const Handle(TColStd_HArray1OfReal)& theValue); 91 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; 96 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); 100 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); 104 105 //! Returns the upper bound of the range dimension, otherwise - zero. 106 Standard_EXPORT Standard_Real GetUpperBound() const; 107 108 //! Returns the lower bound of the range dimension, otherwise - zero. 109 Standard_EXPORT Standard_Real GetLowerBound() const; 110 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; 115 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); 120 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); 125 126 //! Returns the lower value of the toleranced dimension, otherwise - zero. 127 Standard_EXPORT Standard_Real GetUpperTolValue() const; 128 129 //! Returns the upper value of the toleranced dimension, otherwise - zero. 130 Standard_EXPORT Standard_Real GetLowerTolValue() const; 131 132 //! Returns True if the form variance was set to not XCAFDimTolObjects_DimensionFormVariance_None value. 133 Standard_EXPORT Standard_Boolean IsDimWithClassOfTolerance() const; 134 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); 143 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; 149 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); 152 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; 155 156 //! Returns a sequence of modifiers of the dimension. 157 Standard_EXPORT XCAFDimTolObjects_DimensionModifiersSequence GetModifiers() const; 158 159 //! Sets new sequence of dimension modifiers. 160 Standard_EXPORT void SetModifiers (const XCAFDimTolObjects_DimensionModifiersSequence& theModifiers); 161 162 //! Adds a modifier to the dimension sequence of modifiers. 163 Standard_EXPORT void AddModifier (const XCAFDimTolObjects_DimensionModif theModifier); 164 165 //! Returns a 'curve' along which the dimension is measured. 166 Standard_EXPORT TopoDS_Edge GetPath() const; 167 168 //! Sets a 'curve' along which the dimension is measured. 169 Standard_EXPORT void SetPath (const TopoDS_Edge& thePath); 170 171 //! Returns the orientation of the dimension in annotation plane. 172 Standard_EXPORT Standard_Boolean GetDirection (gp_Dir& theDir) const; 173 174 //! Sets an orientation of the dimension in annotation plane. 175 Standard_EXPORT Standard_Boolean SetDirection (const gp_Dir& theDir); 176 177 //! Sets position of the dimension text. SetPointTextAttach(const gp_Pnt & thePntText)178 void SetPointTextAttach (const gp_Pnt& thePntText) 179 { 180 myPntText = thePntText; 181 myHasPntText = Standard_True; 182 } 183 184 //! Returns position of the dimension text. GetPointTextAttach() const185 const gp_Pnt& GetPointTextAttach() const { return myPntText; } 186 187 //! Returns True if the position of dimension text is specified. HasTextPoint() const188 Standard_Boolean HasTextPoint() const 189 { 190 return myHasPntText; 191 } 192 193 //! Sets annotation plane. SetPlane(const gp_Ax2 & thePlane)194 void SetPlane (const gp_Ax2& thePlane) 195 { 196 myPlane = thePlane; 197 myHasPlane = Standard_True; 198 } 199 200 //! Returns annotation plane. GetPlane() const201 const gp_Ax2& GetPlane() const { return myPlane; } 202 203 //! Returns True if the object has annotation plane. HasPlane() const204 Standard_Boolean HasPlane() const { return myHasPlane; } 205 206 //! Returns true, if connection point exists (for dimesional_size), 207 //! if connection point for the first shape exists (for dimensional_location). HasPoint() const208 Standard_Boolean HasPoint() const { return myHasPoint1; } 209 210 // Returns true, if connection point for the second shape exists (for dimensional_location only). HasPoint2() const211 Standard_Boolean HasPoint2() const { return myHasPoint2; } 212 213 //! Set connection point (for dimesional_size), 214 //! Set connection point for the first shape (for dimensional_location). SetPoint(const gp_Pnt thePnt)215 void SetPoint(const gp_Pnt thePnt) { 216 myPnt1 = thePnt; 217 myHasPoint1 = Standard_True; 218 } 219 220 // Set connection point for the second shape (for dimensional_location only). SetPoint2(const gp_Pnt thePnt)221 void SetPoint2(const gp_Pnt thePnt) { 222 myPnt2 = thePnt; 223 myHasPoint2 = Standard_True; 224 } 225 226 //! Get connection point (for dimesional_size), 227 //! Get connection point for the first shape (for dimensional_location). GetPoint() const228 gp_Pnt GetPoint() const { 229 return myPnt1; 230 } 231 232 // Get connection point for the second shape (for dimensional_location only). GetPoint2() const233 gp_Pnt GetPoint2() const { 234 return myPnt2; 235 } 236 237 //! Set graphical presentation for the object. SetPresentation(const TopoDS_Shape & thePresentation,const Handle (TCollection_HAsciiString)& thePresentationName)238 void SetPresentation(const TopoDS_Shape& thePresentation, 239 const Handle(TCollection_HAsciiString)& thePresentationName) 240 { 241 myPresentation = thePresentation; 242 myPresentationName = thePresentationName; 243 } 244 245 //! Returns graphical presentation of the object. GetPresentation() const246 TopoDS_Shape GetPresentation() const 247 { 248 return myPresentation; 249 } 250 251 //! Returns graphical presentation of the object Handle(TCollection_HAsciiString)252 Standard_EXPORT Handle(TCollection_HAsciiString) GetPresentationName() const 253 { 254 return myPresentationName; 255 } 256 257 //! Returns true, if the object has descriptions. HasDescriptions() const258 Standard_Boolean HasDescriptions() const 259 { 260 return (myDescriptions.Length() > 0); 261 } 262 263 //! Returns number of descriptions. NbDescriptions() const264 Standard_Integer NbDescriptions() const 265 { 266 return myDescriptions.Length(); 267 } 268 269 //! Returns description with the given number. GetDescription(const Standard_Integer theNumber) const270 Handle(TCollection_HAsciiString) GetDescription(const Standard_Integer theNumber) const 271 { 272 if (theNumber < myDescriptions.Lower() || theNumber > myDescriptions.Upper()) 273 return new TCollection_HAsciiString(); 274 return myDescriptions.Value(theNumber); 275 } 276 277 //! Returns name of description with the given number. GetDescriptionName(const Standard_Integer theNumber) const278 Handle(TCollection_HAsciiString) GetDescriptionName(const Standard_Integer theNumber) const 279 { 280 if (theNumber < myDescriptions.Lower() || theNumber > myDescriptions.Upper()) 281 return new TCollection_HAsciiString(); 282 return myDescriptionNames.Value(theNumber); 283 } 284 285 //! Remove description with the given number. 286 Standard_EXPORT void RemoveDescription(const Standard_Integer theNumber); 287 288 //! Add new description. AddDescription(const Handle (TCollection_HAsciiString)theDescription,const Handle (TCollection_HAsciiString)theName)289 void AddDescription(const Handle(TCollection_HAsciiString) theDescription, const Handle(TCollection_HAsciiString) theName) 290 { 291 myDescriptions.Append(theDescription); 292 myDescriptionNames.Append(theName); 293 } 294 295 //! Dumps the content of me into the stream 296 Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const; 297 298 DEFINE_STANDARD_RTTIEXT(XCAFDimTolObjects_DimensionObject,Standard_Transient) 299 300 private: 301 302 XCAFDimTolObjects_DimensionType myType; 303 Handle(TColStd_HArray1OfReal) myVal; 304 XCAFDimTolObjects_DimensionQualifier myQualifier; 305 Standard_Boolean myIsHole; 306 XCAFDimTolObjects_DimensionFormVariance myFormVariance; 307 XCAFDimTolObjects_DimensionGrade myGrade; 308 Standard_Integer myL; 309 Standard_Integer myR; 310 XCAFDimTolObjects_DimensionModifiersSequence myModifiers; 311 TopoDS_Edge myPath; 312 gp_Dir myDir; 313 gp_Pnt myPnt1, myPnt2; 314 Standard_Boolean myHasPoint1, myHasPoint2; 315 gp_Ax2 myPlane; 316 Standard_Boolean myHasPlane; 317 Standard_Boolean myHasPntText; 318 gp_Pnt myPntText; 319 TopoDS_Shape myPresentation; 320 Handle(TCollection_HAsciiString) mySemanticName; 321 Handle(TCollection_HAsciiString) myPresentationName; 322 NCollection_Vector<Handle(TCollection_HAsciiString)> myDescriptions; 323 NCollection_Vector<Handle(TCollection_HAsciiString)> myDescriptionNames; 324 325 }; 326 327 #endif // _XCAFDimTolObjects_DimensionObject_HeaderFile 328