1 // Copyright (c) 1998-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #include <Prs3d_DimensionAspect.hxx>
17 #include <Prs3d_ArrowAspect.hxx>
18 #include <Prs3d_TextAspect.hxx>
19 #include <Prs3d_LineAspect.hxx>
21 #include <Aspect_TypeOfLine.hxx>
22 #include <Graphic3d_AspectText3d.hxx>
23 #include <Quantity_Color.hxx>
26 //=======================================================================
27 //function : Constructor
29 //=======================================================================
31 Prs3d_DimensionAspect::Prs3d_DimensionAspect()
33 myTextHPosition = Prs3d_DTHP_Fit;
34 myTextVPosition = Prs3d_DTVP_Center;
35 myArrowOrientation = Prs3d_DAO_Fit;
37 myLineAspect = new Prs3d_LineAspect (Quantity_NOC_LAWNGREEN,Aspect_TOL_SOLID,1.);
38 myTextAspect = new Prs3d_TextAspect;
39 myTextAspect->Aspect()->SetTextZoomable (Standard_False);
40 myTextAspect->SetColor (Quantity_NOC_LAWNGREEN);
41 myTextAspect->SetHorizontalJustification (Graphic3d_HTA_CENTER);
42 myTextAspect->SetVerticalJustification (Graphic3d_VTA_CENTER);
43 myArrowAspect = new Prs3d_ArrowAspect;
44 myArrowAspect->SetColor (Quantity_NOC_LAWNGREEN);
45 myArrowAspect->SetAngle (M_PI * 12.0 / 180.0);
46 myArrowAspect->SetLength (6.0);
47 myExtensionSize = 6.0;
48 myArrowTailSize = 6.0;
49 myValueStringFormat = "%g";
50 myToDisplayUnits = Standard_False;
53 //=======================================================================
54 //function : SetCommonColor
55 //purpose : Sets the same color for all parts of dimension:
56 // lines, arrows and text.
57 //=======================================================================
58 void Prs3d_DimensionAspect::SetCommonColor (const Quantity_Color& theColor)
60 myLineAspect->SetColor (theColor);
61 myTextAspect->SetColor (theColor);
62 myArrowAspect->SetColor (theColor);
65 //=======================================================================
66 //function : LineAspect
68 //=======================================================================
69 Handle(Prs3d_LineAspect) Prs3d_DimensionAspect::LineAspect () const
74 //=======================================================================
75 //function : SetLineAspect
77 //=======================================================================
78 void Prs3d_DimensionAspect::SetLineAspect(const Handle(Prs3d_LineAspect)& theAspect)
80 myLineAspect = theAspect;
83 //=======================================================================
84 //function : TextAspect
86 //=======================================================================
87 Handle(Prs3d_TextAspect) Prs3d_DimensionAspect::TextAspect () const
92 //=======================================================================
93 //function : SetTextAspect
95 //=======================================================================
96 void Prs3d_DimensionAspect::SetTextAspect (const Handle(Prs3d_TextAspect)& theAspect)
98 myTextAspect = theAspect;
101 //=======================================================================
102 //function : MakeArrows3D
104 //=======================================================================
105 void Prs3d_DimensionAspect::MakeArrows3d (const Standard_Boolean isArrows3d)
107 myIsArrows3d = isArrows3d;
110 //=======================================================================
111 //function : IsArrows3D
113 //=======================================================================
114 Standard_Boolean Prs3d_DimensionAspect::IsArrows3d () const
119 //=======================================================================
120 //function : MakeText3D
122 //=======================================================================
123 void Prs3d_DimensionAspect::MakeText3d (const Standard_Boolean isText3d)
125 myIsText3d = isText3d;
128 //=======================================================================
129 //function : IsText3D
131 //=======================================================================
132 Standard_Boolean Prs3d_DimensionAspect::IsText3d () const
137 //=======================================================================
138 //function : IsUnitsDisplayed
140 //=======================================================================
141 Standard_Boolean Prs3d_DimensionAspect::IsUnitsDisplayed () const
143 return myToDisplayUnits;
146 //=======================================================================
147 //function : MakeUnitsDisplayed
149 //=======================================================================
150 void Prs3d_DimensionAspect::MakeUnitsDisplayed (const Standard_Boolean theIsDisplayed)
152 myToDisplayUnits = theIsDisplayed;
155 //=======================================================================
156 //function : IsTextShaded
158 //=======================================================================
159 Standard_Boolean Prs3d_DimensionAspect::IsTextShaded () const
161 return myIsTextShaded;
164 //=======================================================================
165 //function : MakeTextShaded
167 //=======================================================================
168 void Prs3d_DimensionAspect::MakeTextShaded (const Standard_Boolean isTextShaded)
170 myIsTextShaded = isTextShaded;
173 //=======================================================================
174 //function : SetArrowOrientation
176 //=======================================================================
177 void Prs3d_DimensionAspect::SetArrowOrientation (const Prs3d_DimensionArrowOrientation theArrowOrient)
179 myArrowOrientation = theArrowOrient;
182 //=======================================================================
183 //function : GetArrowOrientation
185 //=======================================================================
186 Prs3d_DimensionArrowOrientation Prs3d_DimensionAspect::ArrowOrientation() const
188 return myArrowOrientation;
191 //=======================================================================
192 //function : SetTextVerticalPosition
194 //=======================================================================
195 void Prs3d_DimensionAspect::SetTextVerticalPosition (const Prs3d_DimensionTextVerticalPosition thePosition)
197 myTextVPosition = thePosition;
200 //=======================================================================
201 //function : TextVerticalPosition
203 //=======================================================================
204 Prs3d_DimensionTextVerticalPosition Prs3d_DimensionAspect::TextVerticalPosition() const
206 return myTextVPosition;
209 //=======================================================================
210 //function : SetTextHorizontalPosition
212 //=======================================================================
213 void Prs3d_DimensionAspect::SetTextHorizontalPosition (const Prs3d_DimensionTextHorizontalPosition thePosition)
215 myTextHPosition = thePosition;
218 //=======================================================================
219 //function : TextHorizontalPosition
221 //=======================================================================
222 Prs3d_DimensionTextHorizontalPosition Prs3d_DimensionAspect::TextHorizontalPosition() const
224 return myTextHPosition;
227 //=======================================================================
228 //function : ArrowAspect
230 //=======================================================================
231 Handle(Prs3d_ArrowAspect) Prs3d_DimensionAspect::ArrowAspect () const
233 return myArrowAspect;
236 //=======================================================================
237 //function : SetArrowAspect
239 //=======================================================================
240 void Prs3d_DimensionAspect::SetArrowAspect (const Handle(Prs3d_ArrowAspect)& theAspect)
242 myArrowAspect = theAspect;
245 //=======================================================================
246 //function : SetExtensioSize
248 //=======================================================================
249 void Prs3d_DimensionAspect::SetExtensionSize (const Standard_Real theSize)
251 myExtensionSize = theSize;
254 //=======================================================================
255 //function : ExtensionSize
257 //=======================================================================
258 Standard_Real Prs3d_DimensionAspect::ExtensionSize() const
260 return myExtensionSize;
263 //=======================================================================
264 //function : SetShortExtensionSize
266 //=======================================================================
267 void Prs3d_DimensionAspect::SetArrowTailSize (const Standard_Real theSize)
269 myArrowTailSize = theSize;
272 //=======================================================================
273 //function : ShortExtensionSize
275 //=======================================================================
276 Standard_Real Prs3d_DimensionAspect::ArrowTailSize() const
278 return myArrowTailSize;
281 //=======================================================================
282 //function : SetValueStringFormat
284 //=======================================================================
285 void Prs3d_DimensionAspect::SetValueStringFormat (const TCollection_AsciiString& theFormat)
287 myValueStringFormat = theFormat;
290 //=======================================================================
291 //function : ValueStringFormat
293 //=======================================================================
294 TCollection_AsciiString Prs3d_DimensionAspect::ValueStringFormat() const
296 return myValueStringFormat;