0024389: Invalid hilight of AIS dimension line in local selection
[occt.git] / src / Prs3d / Prs3d_DimensionAspect.cxx
1 // Copyright (c) 1998-1999 Matra Datavision
2 // Copyright (c) 1999-2013 OPEN CASCADE SAS
3 //
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.
8 //
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.
11 //
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.
18
19 #include <Prs3d_DimensionAspect.hxx>
20
21 #include <Prs3d_ArrowAspect.hxx>
22 #include <Prs3d_TextAspect.hxx>
23 #include <Prs3d_LineAspect.hxx>
24
25 #include <Aspect_TypeOfLine.hxx>
26 #include <Graphic3d_AspectText3d.hxx>
27 #include <Quantity_Color.hxx>
28
29 IMPLEMENT_STANDARD_HANDLE (Prs3d_DimensionAspect, Prs3d_BasicAspect)
30 IMPLEMENT_STANDARD_RTTIEXT (Prs3d_DimensionAspect, Prs3d_BasicAspect)
31
32 //=======================================================================
33 //function : Constructor
34 //purpose  : 
35 //=======================================================================
36
37 Prs3d_DimensionAspect::Prs3d_DimensionAspect()
38 {
39   myTextHPosition    = Prs3d_DTHP_Fit;
40   myTextVPosition    = Prs3d_DTVP_Center;
41   myArrowOrientation = Prs3d_DAO_Fit;
42
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;
54 }
55
56 //=======================================================================
57 //function : SetCommonColor
58 //purpose  : Sets the same color for all parts of dimension:
59 //           lines, arrows and text.
60 //=======================================================================
61
62 void Prs3d_DimensionAspect::SetCommonColor (const Quantity_Color& theColor)
63 {
64   myLineAspect->SetColor (theColor);
65   myTextAspect->SetColor (theColor);
66   myArrowAspect->SetColor (theColor);
67 }
68
69 //=======================================================================
70 //function : LineAspect
71 //purpose  : 
72 //=======================================================================
73
74 Handle(Prs3d_LineAspect) Prs3d_DimensionAspect::LineAspect () const
75 {
76   return myLineAspect;
77 }
78
79 //=======================================================================
80 //function : SetLineAspect
81 //purpose  : 
82 //=======================================================================
83
84 void Prs3d_DimensionAspect::SetLineAspect(const Handle(Prs3d_LineAspect)& theAspect)
85 {
86   myLineAspect = theAspect;
87 }
88
89 //=======================================================================
90 //function : TextAspect
91 //purpose  : 
92 //=======================================================================
93
94 Handle(Prs3d_TextAspect) Prs3d_DimensionAspect::TextAspect () const
95 {
96   return myTextAspect;
97 }
98
99 //=======================================================================
100 //function : SetTextAspect
101 //purpose  : 
102 //=======================================================================
103
104 void Prs3d_DimensionAspect::SetTextAspect (const Handle(Prs3d_TextAspect)& theAspect)
105 {
106   myTextAspect = theAspect;
107 }
108
109 //=======================================================================
110 //function : MakeArrows3D
111 //purpose  : 
112 //=======================================================================
113
114 void Prs3d_DimensionAspect::MakeArrows3d (const Standard_Boolean isArrows3d)
115 {
116   myIsArrows3d = isArrows3d;
117 }
118  
119 //=======================================================================
120 //function : IsArrows3D
121 //purpose  : 
122 //======================================================================= 
123 Standard_Boolean Prs3d_DimensionAspect::IsArrows3d () const
124 {
125   return myIsArrows3d;
126 }
127
128 //=======================================================================
129 //function : MakeText3D
130 //purpose  : 
131 //=======================================================================
132
133 void Prs3d_DimensionAspect::MakeText3d (const Standard_Boolean isText3d)
134 {
135   myIsText3d = isText3d;
136 }
137  
138 //=======================================================================
139 //function : IsText3D
140 //purpose  : 
141 //======================================================================= 
142 Standard_Boolean Prs3d_DimensionAspect::IsText3d () const
143 {
144   return myIsText3d;
145 }
146
147 //=======================================================================
148 //function : IsTextShaded
149 //purpose  : 
150 //======================================================================= 
151 Standard_Boolean Prs3d_DimensionAspect::IsTextShaded () const
152 {
153   return myIsTextShaded;
154 }
155
156 //=======================================================================
157 //function : MakeTextShaded
158 //purpose  : 
159 //=======================================================================
160
161 void Prs3d_DimensionAspect::MakeTextShaded (const Standard_Boolean isTextShaded)
162 {
163   myIsTextShaded = isTextShaded;
164 }
165
166 //=======================================================================
167 //function : SetArrowOrientation
168 //purpose  : 
169 //======================================================================= 
170
171 void Prs3d_DimensionAspect::SetArrowOrientation (const Prs3d_DimensionArrowOrientation theArrowOrient)
172 {
173   myArrowOrientation = theArrowOrient;
174 }
175
176 //=======================================================================
177 //function : GetArrowOrientation
178 //purpose  : 
179 //======================================================================= 
180
181 Prs3d_DimensionArrowOrientation Prs3d_DimensionAspect::ArrowOrientation() const
182 {
183   return myArrowOrientation;
184 }
185
186 //=======================================================================
187 //function : SetTextVerticalPosition
188 //purpose  :
189 //=======================================================================
190
191 void Prs3d_DimensionAspect::SetTextVerticalPosition (const Prs3d_DimensionTextVerticalPosition thePosition)
192 {
193   myTextVPosition = thePosition;
194 }
195
196 //=======================================================================
197 //function : TextVerticalPosition
198 //purpose  :
199 //======================================================================= 
200
201 Prs3d_DimensionTextVerticalPosition Prs3d_DimensionAspect::TextVerticalPosition() const
202 {
203   return myTextVPosition;
204 }
205
206 //=======================================================================
207 //function : SetTextHorizontalPosition
208 //purpose  : 
209 //=======================================================================
210
211 void Prs3d_DimensionAspect::SetTextHorizontalPosition (const Prs3d_DimensionTextHorizontalPosition thePosition)
212 {
213   myTextHPosition = thePosition;
214 }
215
216 //=======================================================================
217 //function : TextHorizontalPosition
218 //purpose  : 
219 //======================================================================= 
220
221 Prs3d_DimensionTextHorizontalPosition Prs3d_DimensionAspect::TextHorizontalPosition() const
222 {
223   return myTextHPosition;
224 }
225
226 //=======================================================================
227 //function : ArrowAspect
228 //purpose  : 
229 //=======================================================================
230
231 Handle(Prs3d_ArrowAspect) Prs3d_DimensionAspect::ArrowAspect () const
232 {
233   return myArrowAspect;
234 }
235
236 //=======================================================================
237 //function : SetArrowAspect
238 //purpose  : 
239 //=======================================================================
240
241 void Prs3d_DimensionAspect::SetArrowAspect (const Handle(Prs3d_ArrowAspect)& theAspect)
242 {
243   myArrowAspect = theAspect;
244 }
245
246 //=======================================================================
247 //function : SetExtensioSize
248 //purpose  : 
249 //=======================================================================
250
251 void Prs3d_DimensionAspect::SetExtensionSize (const Standard_Real theSize)
252 {
253   myExtensionSize = theSize;
254 }
255
256 //=======================================================================
257 //function : ExtensionSize
258 //purpose  : 
259 //=======================================================================
260
261 Standard_Real Prs3d_DimensionAspect::ExtensionSize() const
262 {
263   return myExtensionSize;
264 }