0023510: Integration of test grid "vis" into the new testing system
[occt.git] / src / Prs2d / Prs2d_Radius.cxx
CommitLineData
b311480e 1// Copyright (c) 1999-2012 OPEN CASCADE SAS
2//
3// The content of this file is subject to the Open CASCADE Technology Public
4// License Version 6.5 (the "License"). You may not use the content of this file
5// except in compliance with the License. Please obtain a copy of the License
6// at http://www.opencascade.org and read it completely before using this file.
7//
8// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
10//
11// The Original Code and all software distributed under the License is
12// distributed on an "AS IS" basis, without warranty of any kind, and the
13// Initial Developer hereby disclaims all such warranties, including without
14// limitation, any warranties of merchantability, fitness for a particular
15// purpose or non-infringement. Please see the License for the specific terms
16// and conditions governing the rights and limitations under the License.
17
7fd59977 18#include <Prs2d_Radius.ixx>
19#include <ElCLib.hxx>
20
21#define VERTEXMARKER 2
22#define DEFAULTMARKERSIZE 3.0
23#define XROTATE(x,y) ((x)*cosa - (y)*sina)
24#define YROTATE(x,y) ((y)*cosa + (x)*sina)
25#define ADDPIX 17
26
27Prs2d_Radius::Prs2d_Radius( const Handle(Graphic2d_GraphicObject) & aGO,
28 const gp_Pnt2d & anAttachPnt,
29 const gp_Circ2d & aCircle,
30 const TCollection_ExtendedString & aText,
31 const Standard_Real aTxtScale,
32 const Standard_Real anArrAngle,
33 const Standard_Real anArrLength,
34 const Prs2d_TypeOfArrow anArrType,
35 const Prs2d_ArrowSide anArrow,
36 const Standard_Boolean IsRevArrow )
37
38 : Prs2d_Dimension( aGO, aText, aTxtScale, anArrAngle,
39 anArrLength, anArrType, anArrow, IsRevArrow ),
40
41 myPnt( anAttachPnt ),
42 myCirc( aCircle )
43
44{
45 SetSymbolCode( 198 );
46 gp_Pnt2d aPnt1 = anAttachPnt, aPnt2 = aCircle.Location();
47 Standard_Real U = ElCLib::Parameter( aCircle, aPnt1 );
48 gp_Pnt2d PTonCirc = ElCLib::Value( U, aCircle );
49
50// gp_Vec2d theVec( PTonCirc, aPnt2 );
51 Standard_Real theDist = aPnt2.Distance( aPnt1 );
52 Standard_Real theRad = aCircle.Radius();
53 Standard_Boolean inside = Standard_False;
54
55 if ( theDist < theRad ) {
56 aPnt1 = PTonCirc;
57 theDist = theRad;
58 inside = Standard_True;
59 }
60
61 Standard_Real X1, Y1, X2, Y2;
62 aPnt1.Coord( X1, Y1 );
63 aPnt2.Coord( X2, Y2 );
64
65 myX1 = Standard_ShortReal( X1 );
66 myY1 = Standard_ShortReal( Y1 );
67 myX2 = Standard_ShortReal( X2 );
68 myY2 = Standard_ShortReal( Y2 );
69
70 myMinX = myX1;
71 myMinY = myY1;
72 myMaxX = myX1;
73 myMaxY = myY1;
74
75 if ( myX2 < myMinX ) myMinX = myX2;
76 if ( myY2 < myMinY ) myMinY = myY2;
77 if ( myX2 > myMaxX ) myMaxX = myX2;
78 if ( myY2 > myMaxY ) myMaxY = myY2;
79
c6541a0c 80 Standard_Real ArrAngle = M_PI/180.* anArrAngle, theAngle;
7fd59977 81 gp_Pnt2d theOrigine( 0., 0. ), P1, P2, P3;
82 gp_Vec2d VX( 1., 0. ), VDir;
83
84 if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) {
85 P1 = aPnt1;
86
87 P2 = gp_Pnt2d( anArrLength, anArrLength*Tan( ArrAngle/2. ) );
88 P3 = gp_Pnt2d( anArrLength, -anArrLength*Tan( ArrAngle/2. ) );
89
90 VDir = gp_Vec2d( aPnt1, aPnt2 );
91 if ( IsRevArrow ) VDir.Reverse();
92
93 theAngle = VX.Angle( VDir );
94
95 P2.Rotate( theOrigine, theAngle );
96 P3.Rotate( theOrigine, theAngle );
97
98 P2.Translate( gp_Vec2d( theOrigine, P1 ) );
99 P3.Translate( gp_Vec2d( theOrigine, P1 ) );
100
101 myXVert1(1) = Standard_ShortReal( P2.X() );
102 myYVert1(1) = Standard_ShortReal( P2.Y() );
103 myXVert1(2) = Standard_ShortReal( P1.X() );
104 myYVert1(2) = Standard_ShortReal( P1.Y() );
105 myXVert1(3) = Standard_ShortReal( P3.X() );
106 myYVert1(3) = Standard_ShortReal( P3.Y() );
107
108 for ( Standard_Integer i = 1; i <= 3; i++ ) {
109
110 if ( myXVert1(i) < myMinX ) myMinX = myXVert1(i);
111 if ( myYVert1(i) < myMinY ) myMinY = myYVert1(i);
112 if ( myXVert1(i) > myMaxX ) myMaxX = myXVert1(i);
113 if ( myYVert1(i) > myMaxY ) myMaxY = myYVert1(i);
114
115 }
116 } // end if myArrow is FIRSTAR or BOTHAR
117
118 if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){
119 P1 = aPnt2;
120
121 P2 = gp_Pnt2d( anArrLength, anArrLength*Tan( ArrAngle/2. ) );
122 P3 = gp_Pnt2d( anArrLength, -anArrLength*Tan( ArrAngle/2. ) );
123
124 VDir = gp_Vec2d( aPnt2, aPnt1 );
125 if ( IsRevArrow ) VDir.Reverse();
126
127 theAngle = VX.Angle( VDir );
128
129 P2.Rotate( theOrigine, theAngle );
130 P3.Rotate( theOrigine, theAngle );
131
132 P2.Translate( gp_Vec2d( theOrigine, P1 ) );
133 P3.Translate( gp_Vec2d( theOrigine, P1 ) );
134
135 myXVert2(1) = Standard_ShortReal( P2.X() );
136 myYVert2(1) = Standard_ShortReal( P2.Y() );
137 myXVert2(2) = Standard_ShortReal( P1.X() );
138 myYVert2(2) = Standard_ShortReal( P1.Y() );
139 myXVert2(3) = Standard_ShortReal( P3.X() );
140 myYVert2(3) = Standard_ShortReal( P3.Y() );
141
142 for ( Standard_Integer i = 1; i <= 3; i++ ) {
143 if ( myXVert2(i) < myMinX ) myMinX = myXVert2(i);
144 if ( myYVert2(i) < myMinY ) myMinY = myYVert2(i);
145 if ( myXVert2(i) > myMaxX ) myMaxX = myXVert2(i);
146 if ( myYVert2(i) > myMaxY ) myMaxY = myYVert2(i);
147
148 }
149 } // end if myArrow is FIRSTAR or BOTHAR
150 myNumOfElem = 4;
151 myNumOfVert = 2;
152
153}
154
155void Prs2d_Radius::Values( gp_Pnt2d& anAttPnt,gp_Circ2d& aCirc ) const {
156 anAttPnt = myPnt;
157 aCirc = myCirc;
158}
159
160void Prs2d_Radius::Draw( const Handle(Graphic2d_Drawer)& aDrawer ) {
161
162 Standard_Boolean IsIn = Standard_False;
163
164 if (! myGOPtr->IsTransformed ())
165 IsIn = aDrawer->IsIn (myMinX,myMaxX,myMinY,myMaxY);
166 else {
167 Standard_ShortReal minx, miny, maxx, maxy;
168 MinMax(minx,maxx,miny,maxy);
169 IsIn = aDrawer->IsIn (minx,maxx,miny,maxy);
170 }
171
172 if ( IsIn ) {
173
174 DrawLineAttrib( aDrawer );
175
176 Standard_ShortReal d1 = aDrawer->Convert(ADDPIX);
177 gp_Pnt2d thePnt1(myX1,myY1+d1), thePnt2(myX2,myY2+d1);
178 gp_Vec2d VX( 1., 0. ), theVec(thePnt2, thePnt1);
179 Standard_Real theTxtAngle = VX.Angle( theVec );
180 gp_Pnt2d pntText;
c6541a0c 181 if ( theTxtAngle >= 0 && theTxtAngle <= M_PI/2 )
7fd59977 182 pntText = thePnt2.Translated( (myArrowLen+d1)*theVec/(thePnt1.Distance(thePnt2)) );
c6541a0c 183 else if ( theTxtAngle > M_PI/2 && theTxtAngle <= M_PI ) {
7fd59977 184 pntText = thePnt1.Translated( (myArrowLen+d1)*theVec.Reversed()/(thePnt1.Distance(thePnt2)) );
185 theTxtAngle = VX.Angle( theVec.Reversed() );
c6541a0c 186 } else if ( theTxtAngle >= -M_PI/2 && theTxtAngle < 0 )
7fd59977 187 pntText = thePnt2.Translated( (myArrowLen+d1)*theVec/(thePnt1.Distance(thePnt2)) );
c6541a0c 188 else if ( theTxtAngle >= -M_PI && theTxtAngle < -M_PI/2 ) {
7fd59977 189 pntText = thePnt1.Translated( (myArrowLen+d1)*theVec.Reversed()/(thePnt1.Distance(thePnt2)) );
190 theTxtAngle = VX.Angle( theVec.Reversed() );
191 }
192
193 Standard_Real theTxtX, theTxtY;
194 Standard_Real theSmbX = 0., theSmbY = 0.;
195
196 if ( myIsSymbol ) {
197 aDrawer->SetTextAttrib( myColorIndex, mySymbFont, 0, Standard_ShortReal(myTextScale*aDrawer->Scale()),
198 Standard_ShortReal(myTextScale*aDrawer->Scale()), Standard_False );
199// TCollection_ExtendedString txtSymb( char( SymbolCode() ) );
200 Standard_Character code = SymbolCode();
201 TCollection_ExtendedString txtSymb( code );
202 pntText.Coord( theSmbX, theSmbY );
203 Standard_ShortReal ws=0., hs=0.;
204 aDrawer->GetTextSize( txtSymb, ws, hs );
205 Standard_ShortReal ddd = aDrawer->Convert(2);
206 theVec = VX.Rotated( theTxtAngle );
207 theVec *= ( ws + ddd );
208 gp_Pnt2d pntSymb = pntText.Translated( theVec );
209 pntSymb.Coord( theTxtX, theTxtY );
210 } else {
211 pntText.Coord( theTxtX, theTxtY );
212 }
213
214 Standard_ShortReal a = myX1, b = myY1, c = myX2, d = myY2,
215 t1 = Standard_ShortReal(theTxtX), t2 = Standard_ShortReal(theTxtY),
216 ts1 = Standard_ShortReal(theSmbX), ts2 = Standard_ShortReal(theSmbY);
217
218 TShort_Array1OfShortReal Xpoint1( 1, 3 ), Ypoint1( 1, 3 ),
219 Xpoint2( 1, 3 ), Ypoint2( 1, 3 );
220
221
222 if ( myGOPtr->IsTransformed () ) {
223 gp_GTrsf2d aTrsf = myGOPtr->Transform ();
224
225 if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){
226
227 Standard_Real a1, b1;
228 for ( Standard_Integer j = 1; j <= 3; j++ ) {
229 a1 = Standard_Real( myXVert1(j) );
230 b1 = Standard_Real( myYVert1(j) );
231 aTrsf.Transforms (a1, b1);
232 Xpoint1(j) = Standard_ShortReal(a1);
233 Ypoint1(j) = Standard_ShortReal(b1);
234 }
235 } // end if myArrow is FIRSTAR ot BOTHAR
236
237 if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) {
238
239 Standard_Real ac1,ad1;
240
241 for ( Standard_Integer j = 1; j <= 3; j++ ) {
242 ac1 = Standard_Real( myXVert2(j) );
243 ad1 = Standard_Real( myYVert2(j) );
244 aTrsf.Transforms (ac1, ad1);
245 Xpoint2(j) = Standard_ShortReal(ac1);
246 Ypoint2(j) = Standard_ShortReal(ad1);
247 }
248 } // end if myArrow is LASTAR ot BOTHAR
249
250 Standard_Real A, B;
251 A = Standard_Real( a );
252 B = Standard_Real( b );
253 aTrsf.Transforms( A, B );
254 a = Standard_ShortReal( A );
255 b = Standard_ShortReal( B );
256 A = Standard_Real( c );
257 B = Standard_Real( d );
258 aTrsf.Transforms( A, B );
259 c = Standard_ShortReal( A );
260 d = Standard_ShortReal( B );
261 A = Standard_Real( t1 );
262 B = Standard_Real( t2);
263 aTrsf.Transforms( A, B );
264 t1 = Standard_ShortReal( A );
265 t2 = Standard_ShortReal( B );
266 A = Standard_Real( ts1 );
267 B = Standard_Real( ts2 );
268 aTrsf.Transforms( A, B );
269 ts1 = Standard_ShortReal( A );
270 ts2 = Standard_ShortReal( B );
271
272 } else {
273
274 if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){
275 Xpoint1.Assign( myXVert1 );
276 Ypoint1.Assign( myYVert1 );
277 }
278 if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) {
279 Xpoint2.Assign( myXVert2 );
280 Ypoint2.Assign( myYVert2 );
281 }
282
283 } // end if GO is transformed
284
285 aDrawer->MapSegmentFromTo( a, b, c, d );
286
287 if ( myIsSymbol ) {
288// TCollection_ExtendedString txtSymb( char( SymbolCode() ) );
289 Standard_Character code = SymbolCode();
290 TCollection_ExtendedString txtSymb( code );
291 Standard_ShortReal dx=0.,dy=0.;
292 aDrawer->MapTextFromTo( txtSymb, ts1, ts2, Standard_ShortReal(theTxtAngle), dx, dy, Aspect_TOT_SOLID );
293
294 }
295
296 aDrawer->SetTextAttrib( myColorIndex, myTextFont, 0, Standard_ShortReal(myTextScale*aDrawer->Scale()),
297 Standard_ShortReal(myTextScale*aDrawer->Scale()), Standard_False );
298
299 aDrawer->MapTextFromTo( myText, t1, t2, Standard_ShortReal(theTxtAngle), 0., 0., Aspect_TOT_SOLID );
300
301 if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){
302 if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) {
303 aDrawer->MapPolygonFromTo( Xpoint1, Ypoint1 );
304 } else {
305 aDrawer->MapPolylineFromTo( Xpoint1, Ypoint1 );
306 }
307 }
308
309 if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){
310 if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) {
311 aDrawer->MapPolygonFromTo( Xpoint2, Ypoint2 );
312 } else {
313 aDrawer->MapPolylineFromTo( Xpoint2, Ypoint2 );
314 }
315 }
316
317
318 } // end if IsIn is true
319
320}
321
322void Prs2d_Radius::DrawElement( const Handle(Graphic2d_Drawer)& aDrawer,
323 const Standard_Integer anIndex ) {
324
325 Standard_Boolean IsIn = Standard_False;
326
327 if ( ! myGOPtr->IsTransformed() )
328 IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY );
329 else {
330 Standard_ShortReal minx, miny, maxx, maxy;
331 MinMax( minx, maxx, miny, maxy );
332 IsIn = aDrawer->IsIn( minx, maxx, miny, maxy );
333 }
334
335 if ( IsIn ) {
336
337 DrawLineAttrib( aDrawer );
338 // aDrawer->SetTextAttrib( myColorIndex, myTextFont, 0, myTextScale*aDrawer->Scale(),
339 // myTextScale*aDrawer->Scale(), Standard_False );
340
341 Standard_ShortReal d1 = aDrawer->Convert(ADDPIX);
342 gp_Pnt2d thePnt1(myX1,myY1+d1), thePnt2(myX2,myY2+d1);
343 gp_Vec2d VX( 1., 0. ), theVec(thePnt2, thePnt1);
344 Standard_Real theTxtAngle = VX.Angle( theVec );
345 gp_Pnt2d pntText;
c6541a0c 346 if ( theTxtAngle >= 0 && theTxtAngle <= M_PI/2 )
7fd59977 347 pntText = thePnt2.Translated( (myArrowLen+d1)*theVec/(thePnt1.Distance(thePnt2)) );
c6541a0c 348 else if ( theTxtAngle > M_PI/2 && theTxtAngle <= M_PI ) {
7fd59977 349 pntText = thePnt1.Translated( (myArrowLen+d1)*theVec.Reversed()/(thePnt1.Distance(thePnt2)) );
350 theTxtAngle = VX.Angle( theVec.Reversed() );
c6541a0c 351 } else if ( theTxtAngle >= -M_PI/2 && theTxtAngle < 0 )
7fd59977 352 pntText = thePnt2.Translated( (myArrowLen+d1)*theVec/(thePnt1.Distance(thePnt2)) );
c6541a0c 353 else if ( theTxtAngle >= -M_PI && theTxtAngle < -M_PI/2 ) {
7fd59977 354 pntText = thePnt1.Translated( (myArrowLen+d1)*theVec.Reversed()/(thePnt1.Distance(thePnt2)) );
355 theTxtAngle = VX.Angle( theVec.Reversed() );
356 }
357 Standard_Real theTxtX, theTxtY;
358 pntText.Coord( theTxtX, theTxtY );
359
360 Standard_ShortReal a = myX1, b = myY1, c = myX2, d = myY2,
361 t1 = Standard_ShortReal(theTxtX), t2 = Standard_ShortReal(theTxtY);
362 TShort_Array1OfShortReal Xpoint( 1, 3 ), Ypoint( 1, 3 );
363
364 if ( anIndex == 1 ) {
365 Xpoint.Assign( myXVert1 );
366 Ypoint.Assign( myYVert1 );
367 } else if ( anIndex == 2 ) {
368 Xpoint.Assign( myXVert2 );
369 Ypoint.Assign( myYVert2 );
370 }
371
372 if ( myGOPtr->IsTransformed () ) {
373 gp_GTrsf2d aTrsf = myGOPtr->Transform ();
374 Standard_Real a1, b1, c1, ad1;
375
376 if ( anIndex == 1 ) {
377 for ( Standard_Integer j = 1; j <= 3; j++ ) {
378 a1 = Standard_Real( Xpoint(j) );
379 b1 = Standard_Real( Xpoint(j) );
380 aTrsf.Transforms( a1, b1 );
381 Xpoint(j) = Standard_ShortReal( a1 );
382 Ypoint(j) = Standard_ShortReal( b1 );
383 }
384 } else if ( anIndex == 2 ) {
385
386 for ( Standard_Integer j = 1; j <= 3; j++ ) {
387 a1 = Standard_Real( Xpoint(j) );
388 b1 = Standard_Real( Xpoint(j) );
389 aTrsf.Transforms( a1, b1 );
390 Xpoint(j) = Standard_ShortReal( a1 );
391 Ypoint(j) = Standard_ShortReal( b1 );
392 }
393 } else if ( anIndex == 4 ) {
394
395 a1 = Standard_Real( a );
396 b1 = Standard_Real( b );
397 c1 = Standard_Real( c );
398 ad1 = Standard_Real( d );
399 aTrsf.Transforms( a1, b1 );
400 aTrsf.Transforms( c1, ad1 );
401 a = Standard_ShortReal( a1 );
402 b = Standard_ShortReal( b1 );
403 c = Standard_ShortReal( c1 );
404 d = Standard_ShortReal( ad1 );
405
406 } else if ( anIndex == 3 ) {
407 a1 = Standard_Real( t1 );
408 b1 = Standard_Real( t2);
409 aTrsf.Transforms( a1, b1 );
410 t1 = Standard_ShortReal( a1 );
411 t2 = Standard_ShortReal( b1);
412 }
413 }
414
415 if ( anIndex == 1 || anIndex == 2 )
416 if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) {
417 aDrawer->MapPolygonFromTo( Xpoint, Ypoint );
418 } else {
419 aDrawer->MapPolylineFromTo( Xpoint, Ypoint );
420 }
421 else if ( anIndex == 4 )
422 aDrawer->MapSegmentFromTo( a, b, c, d );
423 else if ( anIndex == 3 )
424 aDrawer->MapTextFromTo( myText, t1, t2, Standard_ShortReal(theTxtAngle), 0., 0., Aspect_TOT_SOLID );
425
426 } // end if IsIn is true
427
428}
429
430void Prs2d_Radius::DrawVertex( const Handle(Graphic2d_Drawer)& aDrawer,
431 const Standard_Integer anIndex ) {
432
433 Standard_Boolean IsIn = Standard_False;
434
435 if ( ! myGOPtr->IsTransformed() )
436 IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY );
437 else {
438 Standard_ShortReal minx, miny, maxx, maxy;
439 MinMax( minx, maxx, miny, maxy );
440 IsIn = aDrawer->IsIn( minx, maxx, miny, maxy );
441 }
442 if ( IsIn ) {
443 if ( anIndex == 1 || anIndex == 2 ) {
444 Standard_ShortReal X=0., Y=0.;
445 if ( anIndex == 1 ) {
446 X = myX1; Y = myY1;
447 } else if ( anIndex == 2 ) {
448 X = myX2; Y = myY2;
449 }
450 DrawMarkerAttrib( aDrawer );
451 if ( myGOPtr->IsTransformed() ) {
452 gp_GTrsf2d aTrsf = myGOPtr->Transform();
453 Standard_Real A = Standard_Real( X ), B = Standard_Real( Y );
454 aTrsf.Transforms( A, B );
455 X = Standard_ShortReal( A );
456 Y = Standard_ShortReal( B );
457 }
458 aDrawer->MapMarkerFromTo(VERTEXMARKER,X,Y, DEFAULTMARKERSIZE,DEFAULTMARKERSIZE,0.0);
459 }
460 }
461}
462
463Standard_Boolean Prs2d_Radius::Pick( const Standard_ShortReal X,
464 const Standard_ShortReal Y,
465 const Standard_ShortReal aPrecision,
466 const Handle(Graphic2d_Drawer)& aDrawer ) {
467
468 Standard_ShortReal SRX = X, SRY = Y;
469 Standard_Boolean Result = Standard_False;
470
471 if ( IsInMinMax( X, Y, aPrecision ) ) {
472 if ( myGOPtr->IsTransformed () ) {
473 gp_GTrsf2d aTrsf = ( myGOPtr->Transform() ).Inverted();
474 Standard_Real RX = Standard_Real(SRX), RY = Standard_Real(SRY);
475 aTrsf.Transforms(RX, RY);
476 SRX = Standard_ShortReal(RX);
477 SRY = Standard_ShortReal(RY);
478 }
479
480 if ( Graphic2d_Primitive::IsOn( SRX, SRY, myX1, myY1, aPrecision ) ) {
481 SetPickedIndex(-1);
482 return Standard_True;
483 } else if ( Graphic2d_Primitive::IsOn( SRX, SRY, myX2, myY2, aPrecision ) ) {
484 SetPickedIndex(-2);
485 return Standard_True;
486 }
487
488 if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) {
489 for ( Standard_Integer i = 1; i < 3 ; i++)
490 if ( IsOn( SRX, SRY, myXVert1(i), myYVert1(i), myXVert1(i+1), myYVert1( i+1 ), aPrecision ) ) {
491 SetPickedIndex(1);
492 return Standard_True;
493 }
494
495 if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED )
496 if ( IsIn( SRX, SRY, myXVert1, myYVert1, aPrecision ) ) {
497 SetPickedIndex(1);
498 return Standard_True;
499 }
500 } // end if myArrow == FIRSTAR or BOTHAR
501
502 if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){
503 for ( Standard_Integer i = 1; i < 3 ; i++)
504 if ( IsOn( SRX, SRY, myXVert2(i), myYVert2(i), myXVert2(i+1), myYVert2( i+1 ), aPrecision ) ) {
505 SetPickedIndex(2);
506 return Standard_True;
507 }
508
509 if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED )
510 if ( IsIn( SRX, SRY, myXVert2, myYVert2, aPrecision ) ) {
511 SetPickedIndex(2);
512 return Standard_True;
513 }
514 } // end if myArrow == LASTAR or BOTHAR
515
516 Standard_ShortReal width,height,xoffset,yoffset;
517 Standard_ShortReal hscale = Standard_ShortReal(myTextScale*aDrawer->Scale()),
518 wscale = Standard_ShortReal(myTextScale*aDrawer->Scale());
519 Standard_ShortReal TX = X, TY = Y;
520
521 aDrawer->SetTextAttrib( myColorIndex, myTextFont, 0, hscale, wscale, Standard_False );
522 if ( !aDrawer->GetTextSize( myText, width, height, xoffset, yoffset ) ) {
523 width = height = xoffset = yoffset = 0.;
524 }
525 Standard_ShortReal d1 = aDrawer->Convert(ADDPIX);
526 gp_Pnt2d thePnt1(myX1,myY1+d1), thePnt2(myX2,myY2+d1);
527 gp_Vec2d VX( 1., 0. ), theVec(thePnt2, thePnt1);
528 Standard_Real theTxtAngle = VX.Angle( theVec );
529 gp_Pnt2d pntText;
c6541a0c 530 if ( theTxtAngle >= 0 && theTxtAngle <= M_PI/2 )
7fd59977 531 pntText = thePnt2.Translated( (myArrowLen+d1)*theVec/(thePnt1.Distance(thePnt2)) );
c6541a0c 532 else if ( theTxtAngle > M_PI/2 && theTxtAngle <= M_PI ) {
7fd59977 533 pntText = thePnt1.Translated( (myArrowLen+d1)*theVec.Reversed()/(thePnt1.Distance(thePnt2)) );
534 theTxtAngle = VX.Angle( theVec.Reversed() );
c6541a0c 535 } else if ( theTxtAngle >= -M_PI/2 && theTxtAngle < 0 )
7fd59977 536 pntText = thePnt2.Translated( (myArrowLen+d1)*theVec/(thePnt1.Distance(thePnt2)) );
c6541a0c 537 else if ( theTxtAngle >= -M_PI && theTxtAngle < -M_PI/2 ) {
7fd59977 538 pntText = thePnt1.Translated( (myArrowLen+d1)*theVec.Reversed()/(thePnt1.Distance(thePnt2)) );
539 theTxtAngle = VX.Angle( theVec.Reversed() );
540 }
541 Standard_Real theTxtX, theTxtY;
542 pntText.Coord( theTxtX, theTxtY );
543
544 Standard_ShortReal cosa = Standard_ShortReal(Cos( -theTxtAngle )),
545 sina = Standard_ShortReal(Sin( -theTxtAngle )),
546 dx = TX-Standard_ShortReal(theTxtX),
547 dy = TY-Standard_ShortReal(theTxtY),
548 x = Standard_ShortReal(XROTATE(dx,dy)),
549 y = Standard_ShortReal(YROTATE(dx,dy));
550
551 Result = (x >= -aPrecision + xoffset)
552 && (x <= width + xoffset + aPrecision)
553 && (y >= -yoffset - aPrecision)
554 && (y <= height - yoffset + aPrecision);
555
556 if ( Result ) {
557 SetPickedIndex(3);
558 return Standard_True;
559 }
560
561 if ( IsOn( SRX, SRY, myX1, myY1, myX2, myY2, aPrecision ) ) {
562 SetPickedIndex( 4 );
563 return Standard_True;
564 }
565
566 }// end if IsInMinMax is true
567
568 return Standard_False;
569
570}
571
572void Prs2d_Radius::Save(Aspect_FStream& aFStream) const
573{
574}