1 // Copyright (c) 1998-1999 Matra Datavision
2 // Copyright (c) 1999-2013 OPEN CASCADE SAS
4 // The content of this file is subject to the Open CASCADE Technology Public
5 // License Version 6.5 (the "License"). You may not use the content of this file
6 // except in compliance with the License. Please obtain a copy of the License
7 // at http://www.opencascade.org and read it completely before using this file.
9 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 // The Original Code and all software distributed under the License is
13 // distributed on an "AS IS" basis, without warranty of any kind, and the
14 // Initial Developer hereby disclaims all such warranties, including without
15 // limitation, any warranties of merchantability, fitness for a particular
16 // purpose or non-infringement. Please see the License for the specific terms
17 // and conditions governing the rights and limitations under the License.
19 #include <Prs3d_DimensionAspect.hxx>
21 #include <Prs3d_ArrowAspect.hxx>
22 #include <Prs3d_TextAspect.hxx>
23 #include <Prs3d_LineAspect.hxx>
25 #include <Aspect_TypeOfLine.hxx>
26 #include <Graphic3d_AspectText3d.hxx>
27 #include <Quantity_Color.hxx>
29 IMPLEMENT_STANDARD_HANDLE (Prs3d_DimensionAspect, Prs3d_BasicAspect)
30 IMPLEMENT_STANDARD_RTTIEXT (Prs3d_DimensionAspect, Prs3d_BasicAspect)
32 //=======================================================================
33 //function : Constructor
35 //=======================================================================
37 Prs3d_DimensionAspect::Prs3d_DimensionAspect()
39 myTextHPosition = Prs3d_DTHP_Fit;
40 myTextVPosition = Prs3d_DTVP_Center;
41 myArrowOrientation = Prs3d_DAO_Fit;
43 myLineAspect = new Prs3d_LineAspect (Quantity_NOC_LAWNGREEN,Aspect_TOL_SOLID,1.);
44 myTextAspect = new Prs3d_TextAspect;
45 myTextAspect->Aspect()->SetTextZoomable (Standard_False);
46 myTextAspect->SetColor (Quantity_NOC_LAWNGREEN);
47 myTextAspect->SetHorizontalJustification (Graphic3d_HTA_CENTER);
48 myTextAspect->SetVerticalJustification (Graphic3d_VTA_CENTER);
49 myArrowAspect = new Prs3d_ArrowAspect;
50 myArrowAspect->SetColor (Quantity_NOC_LAWNGREEN);
51 myArrowAspect->SetAngle (M_PI * 20.0 / 180.0);
52 myArrowAspect->SetLength (6.0);
53 myExtensionSize = 6.0;
56 //=======================================================================
57 //function : SetCommonColor
58 //purpose : Sets the same color for all parts of dimension:
59 // lines, arrows and text.
60 //=======================================================================
62 void Prs3d_DimensionAspect::SetCommonColor (const Quantity_Color& theColor)
64 myLineAspect->SetColor (theColor);
65 myTextAspect->SetColor (theColor);
66 myArrowAspect->SetColor (theColor);
69 //=======================================================================
70 //function : LineAspect
72 //=======================================================================
74 Handle(Prs3d_LineAspect) Prs3d_DimensionAspect::LineAspect () const
79 //=======================================================================
80 //function : SetLineAspect
82 //=======================================================================
84 void Prs3d_DimensionAspect::SetLineAspect(const Handle(Prs3d_LineAspect)& theAspect)
86 myLineAspect = theAspect;
89 //=======================================================================
90 //function : TextAspect
92 //=======================================================================
94 Handle(Prs3d_TextAspect) Prs3d_DimensionAspect::TextAspect () const
99 //=======================================================================
100 //function : SetTextAspect
102 //=======================================================================
104 void Prs3d_DimensionAspect::SetTextAspect (const Handle(Prs3d_TextAspect)& theAspect)
106 myTextAspect = theAspect;
109 //=======================================================================
110 //function : MakeArrows3D
112 //=======================================================================
114 void Prs3d_DimensionAspect::MakeArrows3d (const Standard_Boolean isArrows3d)
116 myIsArrows3d = isArrows3d;
119 //=======================================================================
120 //function : IsArrows3D
122 //=======================================================================
123 Standard_Boolean Prs3d_DimensionAspect::IsArrows3d () const
128 //=======================================================================
129 //function : MakeText3D
131 //=======================================================================
133 void Prs3d_DimensionAspect::MakeText3d (const Standard_Boolean isText3d)
135 myIsText3d = isText3d;
138 //=======================================================================
139 //function : IsText3D
141 //=======================================================================
142 Standard_Boolean Prs3d_DimensionAspect::IsText3d () const
147 //=======================================================================
148 //function : IsTextShaded
150 //=======================================================================
151 Standard_Boolean Prs3d_DimensionAspect::IsTextShaded () const
153 return myIsTextShaded;
156 //=======================================================================
157 //function : MakeTextShaded
159 //=======================================================================
161 void Prs3d_DimensionAspect::MakeTextShaded (const Standard_Boolean isTextShaded)
163 myIsTextShaded = isTextShaded;
166 //=======================================================================
167 //function : SetArrowOrientation
169 //=======================================================================
171 void Prs3d_DimensionAspect::SetArrowOrientation (const Prs3d_DimensionArrowOrientation theArrowOrient)
173 myArrowOrientation = theArrowOrient;
176 //=======================================================================
177 //function : GetArrowOrientation
179 //=======================================================================
181 Prs3d_DimensionArrowOrientation Prs3d_DimensionAspect::ArrowOrientation() const
183 return myArrowOrientation;
186 //=======================================================================
187 //function : SetTextVerticalPosition
189 //=======================================================================
191 void Prs3d_DimensionAspect::SetTextVerticalPosition (const Prs3d_DimensionTextVerticalPosition thePosition)
193 myTextVPosition = thePosition;
196 //=======================================================================
197 //function : TextVerticalPosition
199 //=======================================================================
201 Prs3d_DimensionTextVerticalPosition Prs3d_DimensionAspect::TextVerticalPosition() const
203 return myTextVPosition;
206 //=======================================================================
207 //function : SetTextHorizontalPosition
209 //=======================================================================
211 void Prs3d_DimensionAspect::SetTextHorizontalPosition (const Prs3d_DimensionTextHorizontalPosition thePosition)
213 myTextHPosition = thePosition;
216 //=======================================================================
217 //function : TextHorizontalPosition
219 //=======================================================================
221 Prs3d_DimensionTextHorizontalPosition Prs3d_DimensionAspect::TextHorizontalPosition() const
223 return myTextHPosition;
226 //=======================================================================
227 //function : ArrowAspect
229 //=======================================================================
231 Handle(Prs3d_ArrowAspect) Prs3d_DimensionAspect::ArrowAspect () const
233 return myArrowAspect;
236 //=======================================================================
237 //function : SetArrowAspect
239 //=======================================================================
241 void Prs3d_DimensionAspect::SetArrowAspect (const Handle(Prs3d_ArrowAspect)& theAspect)
243 myArrowAspect = theAspect;
246 //=======================================================================
247 //function : SetExtensioSize
249 //=======================================================================
251 void Prs3d_DimensionAspect::SetExtensionSize (const Standard_Real theSize)
253 myExtensionSize = theSize;
256 //=======================================================================
257 //function : ExtensionSize
259 //=======================================================================
261 Standard_Real Prs3d_DimensionAspect::ExtensionSize() const
263 return myExtensionSize;