1 #include <Prs2d_Angle.ixx>
2 #include <gp_Vec2d.hxx>
5 #define DEFAULTMARKERSIZE 3.0
6 #define XROTATE(x,y) ((x)*cosa - (y)*sina)
7 #define YROTATE(x,y) ((y)*cosa + (x)*sina)
10 Prs2d_Angle::Prs2d_Angle( const Handle(Graphic2d_GraphicObject)& aGO,
11 const gp_Pnt2d& anAttachPnt1,
12 const gp_Pnt2d& anAttachPnt2,
13 const gp_Pnt2d& anAttachPnt3,
14 const Quantity_Length aRadius,
15 const TCollection_ExtendedString& aText,
16 const Standard_Real aTxtScale,
17 const Standard_Real anArrAngle,
18 const Standard_Real anArrLength,
19 const Prs2d_TypeOfArrow anArrType,
20 const Prs2d_ArrowSide anArrow,
21 const Standard_Boolean IsRevArrow )
23 : Prs2d_Dimension( aGO, aText, aTxtScale, anArrAngle,
24 anArrLength, anArrType, anArrow, IsRevArrow ),
25 myCentX( Standard_ShortReal( anAttachPnt1.X() ) ),
26 myCentY( Standard_ShortReal( anAttachPnt1.Y() ) ),
27 myRad( Standard_ShortReal( aRadius ) )
31 gp_Vec2d V1( anAttachPnt1, anAttachPnt2 );
32 gp_Vec2d V2( anAttachPnt1, anAttachPnt3 );
33 gp_Vec2d VX( 1., 0. );
34 myFAngle = Standard_ShortReal( VX.Angle(V1) );
35 mySAngle = Standard_ShortReal( VX.Angle(V2) );
37 //myRad = Standard_ShortReal(anAttachPnt1.Distance( anOffsetPoint ));
38 if ( myRad <= ShortRealEpsilon ())
39 Graphic2d_CircleDefinitionError::Raise ("The radius = 0." );
41 Standard_ShortReal TwoPI = Standard_ShortReal(2. * M_PI);
42 while( myFAngle < 0. ) myFAngle += TwoPI;
43 while( myFAngle > 2. * M_PI ) myFAngle -= TwoPI;
44 while( mySAngle < 0. ) mySAngle += TwoPI;
45 while( mySAngle > 2. * M_PI ) mySAngle -= TwoPI;
46 if ( mySAngle < myFAngle ) mySAngle += TwoPI;
48 if ( ( mySAngle - myFAngle < ShortRealEpsilon() ) ||
49 ( mySAngle - myFAngle >= TwoPI ) ) {
52 myMinX = myCentX - myRad;
53 myMinY = myCentY - myRad;
54 myMaxX = myCentX + myRad;
55 myMaxY = myCentY + myRad;
57 Standard_ShortReal Acur,Xcur,Ycur,Xsav;
58 myMinX = myMaxX = Standard_ShortReal(Cos(myFAngle));
59 myMinY = myMaxY = Standard_ShortReal(Sin(myFAngle));
60 Xcur = Standard_ShortReal(Cos(mySAngle));
61 Ycur = Standard_ShortReal(Sin(mySAngle));
62 myMinX = myMinX < Xcur ? myMinX : Xcur;
63 myMinY = myMinY < Ycur ? myMinY : Ycur;
64 myMaxX = myMaxX > Xcur ? myMaxX : Xcur;
65 myMaxY = myMaxY > Ycur ? myMaxY : Ycur;
67 for ( Acur = 0., Xcur = 1., Ycur = 0.;
68 Acur < mySAngle; Acur += Standard_ShortReal(M_PI / 2.)) {
69 if ( Acur > myFAngle ) {
70 myMinX = ( myMinX < Xcur ? myMinX : Xcur );
71 myMaxX = ( myMaxX < Xcur ? Xcur : myMaxX );
72 myMinY = ( myMinY < Ycur ? myMinY : Ycur );
73 myMaxY = ( myMaxY < Ycur ? Ycur : myMaxY );
75 Xsav = Xcur; Xcur = -Ycur; Ycur = Xsav;
77 myMinX = myCentX + myRad * myMinX;
78 myMaxX = myCentX + myRad * myMaxX;
79 myMinY = myCentY + myRad * myMinY;
80 myMaxY = myCentY + myRad * myMaxY;
85 Standard_Real ArrAngle = M_PI/180.*anArrAngle;
87 gp_Pnt2d theOrigine(0.,0.);
90 Standard_Real theAngle;
92 if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) {
93 P1 = gp_Pnt2d( myCentX + myRad * Cos(myFAngle),
94 myCentY + myRad * Sin(myFAngle) );
96 P2 = gp_Pnt2d( anArrLength, anArrLength*Tan( ArrAngle/2. ) );
97 P3 = gp_Pnt2d( anArrLength, -anArrLength*Tan( ArrAngle/2. ) );
99 VDir = V1.Rotated(M_PI/2);
100 theAngle = VX.Angle( VDir );
101 P2.Rotate( theOrigine, theAngle );
102 P3.Rotate( theOrigine, theAngle );
104 P2.Translate( gp_Vec2d( theOrigine, P1 ) );
105 P3.Translate( gp_Vec2d( theOrigine, P1 ) );
107 myXVert1(1) = Standard_ShortReal( P2.X() );
108 myYVert1(1) = Standard_ShortReal( P2.Y() );
109 myXVert1(2) = Standard_ShortReal( P1.X() );
110 myYVert1(2) = Standard_ShortReal( P1.Y() );
111 myXVert1(3) = Standard_ShortReal( P3.X() );
112 myYVert1(3) = Standard_ShortReal( P3.Y() );
114 for ( Standard_Integer i = 1; i <= 3; i++ ) {
115 if ( myXVert1(i) < myMinX ) myMinX = myXVert1(i);
116 if ( myYVert1(i) < myMinY ) myMinY = myYVert1(i);
117 if ( myXVert1(i) > myMaxX ) myMaxX = myXVert1(i);
118 if ( myYVert1(i) > myMaxY ) myMaxY = myYVert1(i);
121 } // end if myArrow is FIRSTAR or BOTHAR
123 if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){
124 P1 = gp_Pnt2d ( myCentX + myRad * Cos(mySAngle),
125 myCentY + myRad * Sin(mySAngle) );
127 P2 = gp_Pnt2d( anArrLength, anArrLength*Tan( ArrAngle/2. ) );
128 P3 = gp_Pnt2d( anArrLength, -anArrLength*Tan( ArrAngle/2. ) );
130 VDir = V2.Rotated(-M_PI/2);
131 theAngle = VX.Angle( VDir );
133 P2.Rotate( theOrigine, theAngle );
134 P3.Rotate( theOrigine, theAngle );
136 P2.Translate( gp_Vec2d( theOrigine, P1 ) );
137 P3.Translate( gp_Vec2d( theOrigine, P1 ) );
139 myXVert2(1) = Standard_ShortReal( P2.X() );
140 myYVert2(1) = Standard_ShortReal( P2.Y() );
141 myXVert2(2) = Standard_ShortReal( P1.X() );
142 myYVert2(2) = Standard_ShortReal( P1.Y() );
143 myXVert2(3) = Standard_ShortReal( P3.X() );
144 myYVert2(3) = Standard_ShortReal( P3.Y() );
146 for ( Standard_Integer i = 1; i <= 3; i++ ) {
147 if ( myXVert2(i) < myMinX ) myMinX = myXVert2(i);
148 if ( myYVert2(i) < myMinY ) myMinY = myYVert2(i);
149 if ( myXVert2(i) > myMaxX ) myMaxX = myXVert2(i);
150 if ( myYVert2(i) > myMaxY ) myMaxY = myYVert2(i);
153 } // end if myArrow is FIRSTAR or BOTHAR
160 void Prs2d_Angle::Values( gp_Pnt2d & aPnt1,
163 Quantity_Length & aRad ) const {
165 aPnt1.SetCoord( myCentX, myCentY );
166 gp_Vec2d VX( myRad, 0. ), V2, V3;
167 V2 = VX.Rotated( myFAngle );
168 aPnt2 = aPnt1.Translated( V2 );
169 V3 = VX.Rotated( mySAngle );
170 aPnt3 = aPnt1.Translated( V3 );
174 void Prs2d_Angle::Draw( const Handle(Graphic2d_Drawer)& aDrawer ) {
176 Standard_Boolean IsIn = Standard_False;
178 if ( !myGOPtr->IsTransformed() )
179 IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY );
181 Standard_ShortReal minx, miny, maxx, maxy;
182 MinMax( minx, maxx, miny, maxy );
183 IsIn = aDrawer->IsIn( minx, maxx, miny, maxy );
188 DrawLineAttrib(aDrawer);
189 Standard_ShortReal theScale = Standard_ShortReal(myTextScale*aDrawer->Scale());
190 aDrawer->SetTextAttrib( myColorIndex, myTextFont, 0.0, theScale, theScale, Standard_False );
193 /*Standard_ShortReal dxx = aDrawer->Convert(ADDPIX);
194 gp_Pnt2d P1 = gp_Pnt2d( myCentX + ( dxx + myRad ) * Cos(myFAngle),
195 myCentY + ( dxx + myRad ) * Sin(myFAngle) );
197 gp_Pnt2d P2 = gp_Pnt2d( myCentX + ( dxx + myRad ) * Cos(mySAngle),
198 myCentY + ( dxx + myRad ) * Sin(mySAngle) );
201 gp_Pnt2d theCent(myCentX, myCentY);
202 gp_Vec2d V1( theCent, P1), V2( theCent, P2), VX(1., 0.);
203 Standard_Real delta = V1.Angle(V2);
204 gp_Vec2d textV1 = V1.Rotated( delta/2 );
205 Standard_Real theAngle = VX.Angle(textV1);
206 gp_Pnt2d pntText = theCent.Translated(textV1);
207 Standard_Real txtX, txtY;
208 pntText.Coord(txtX, txtY);
209 Standard_ShortReal txtAngle = Standard_ShortReal( theAngle + 3*M_PI/2);
211 Standard_ShortReal ws, hs;
212 aDrawer->GetTextSize( myText, ws, hs );
213 Standard_Real theSmbX, theSmbY;
214 Standard_ShortReal ddd = aDrawer->Convert(2);
215 gp_Vec2d theVec = VX.Rotated( txtAngle );
216 theVec *= ( ws + ddd );
217 gp_Pnt2d pntSymb = pntText.Translated( theVec );
218 pntSymb.Coord( theSmbX, theSmbY );*/ //correct by enk Fri Nov 29 15:17 2002
220 /////////////////////////////////////////
221 Standard_ShortReal txtAngle=Standard_ShortReal(myAbsAngle);
222 Standard_Real theSmbX,theSmbY;
225 /////////////////////////////////////////
226 Standard_ShortReal a = myCentX, b = myCentY, c = myRad, e = myFAngle, f = mySAngle,
227 t1 = Standard_ShortReal(myAbsX), t2 = Standard_ShortReal(myAbsY),
228 ts1 = Standard_ShortReal(theSmbX), ts2 = Standard_ShortReal(theSmbY);
230 TShort_Array1OfShortReal Xpoint1( 1, 3 ), Ypoint1( 1, 3 ),
231 Xpoint2( 1, 3 ), Ypoint2( 1, 3 );
233 if ( myGOPtr->IsTransformed () ) {
235 gp_GTrsf2d aTrsf = myGOPtr->Transform ();
237 if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){
239 Standard_Real a1, b1;
240 for ( Standard_Integer j = 1; j <= 3; j++ ) {
241 a1 = Standard_Real( myXVert1(j) );
242 b1 = Standard_Real( myYVert1(j) );
243 aTrsf.Transforms (a1, b1);
244 Xpoint1(j) = Standard_ShortReal(a1);
245 Ypoint1(j) = Standard_ShortReal(b1);
247 } // end if myArrow is FIRSTAR ot BOTHAR
249 if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) {
251 Standard_Real c1, d1;
253 for ( Standard_Integer j = 1; j <= 3; j++ ) {
254 c1 = Standard_Real( myXVert2(j) );
255 d1 = Standard_Real( myYVert2(j) );
256 aTrsf.Transforms (c1, d1);
257 Xpoint2(j) = Standard_ShortReal(c1);
258 Ypoint2(j) = Standard_ShortReal(d1);
260 } // end if myArrow is LASTAR ot BOTHAR
262 Standard_Real A, B, E, F,
263 X0, Y0, X1, Y1, X2, Y2, T1, T2;
264 A = Standard_Real( a );
265 B = Standard_Real( b );
266 E = Standard_Real( e );
267 F = Standard_Real( f );
268 T1 = Standard_Real( t1 );
269 T2 = Standard_Real( t2);
270 aTrsf.Transforms( A, B );
271 aTrsf.Transforms( T1, T2 );
272 a = Standard_ShortReal( A );
273 b = Standard_ShortReal( B );
274 t1 = Standard_ShortReal( T1 );
275 t2 = Standard_ShortReal( T2 );
276 A = Standard_Real( ts1 );
277 B = Standard_Real( ts2 );
278 aTrsf.Transforms( A, B );
279 ts1 = Standard_ShortReal( A );
280 ts2 = Standard_ShortReal( B );
282 if ( Abs(f-e) < Standard_ShortReal(2. * M_PI) ) {
283 aTrsf.SetValue( 1, 3, 0.0 );
284 aTrsf.SetValue( 2, 3, 0.0 );
290 aTrsf.Transforms( X1, Y1 );
291 aTrsf.Transforms( X2, Y2 );
293 aTrsf.Transforms( X0, Y0 );
298 c = myRad * Standard_ShortReal( Sqrt(X1*X1 + Y1*Y1) );
299 e = Standard_ShortReal( atan2(Y1,X1) );
300 f = Standard_ShortReal( atan2(Y2,X2) );
301 if ( aTrsf.IsNegative() ) {
302 Standard_ShortReal t = e; e = f; f = t;
304 } // end if Abs(f-e) < 2PI
307 if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){
308 Xpoint1.Assign( myXVert1 );
309 Ypoint1.Assign( myYVert1 );
311 if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) {
312 Xpoint2.Assign( myXVert2 );
313 Ypoint2.Assign( myYVert2 );
316 } // end if GO is transformed
318 aDrawer->MapArcFromTo( a, b, c, e, f );
319 aDrawer->MapTextFromTo( myText, t1, t2, txtAngle, 0., 0., Aspect_TOT_SOLID );
322 aDrawer->SetTextAttrib( myColorIndex, mySymbFont, 0, Standard_ShortReal(myTextScale*aDrawer->Scale()),
323 Standard_ShortReal(myTextScale*aDrawer->Scale()), Standard_False );
324 // TCollection_ExtendedString txtSymb( char( SymbolCode() ) );
325 Standard_Character code = SymbolCode();
326 TCollection_ExtendedString txtSymb( code );
327 Standard_ShortReal dx=0.,dy=0.;
328 aDrawer->MapTextFromTo( txtSymb, ts1, ts2, txtAngle, dx, dy, Aspect_TOT_SOLID );
332 if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){
333 if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) {
334 aDrawer->MapPolygonFromTo( Xpoint1, Ypoint1 );
336 aDrawer->MapPolylineFromTo( Xpoint1, Ypoint1 );
340 if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){
341 if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) {
342 aDrawer->MapPolygonFromTo( Xpoint2, Ypoint2 );
344 aDrawer->MapPolylineFromTo( Xpoint2, Ypoint2 );
348 } // end if IsIn is true
351 void Prs2d_Angle::DrawElement( const Handle(Graphic2d_Drawer)& aDrawer,
352 const Standard_Integer anIndex) {
353 Standard_Boolean IsIn = Standard_False;
355 if ( ! myGOPtr->IsTransformed() )
356 IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY );
358 Standard_ShortReal minx, miny, maxx, maxy;
359 MinMax( minx, maxx, miny, maxy );
360 IsIn = aDrawer->IsIn( minx, maxx, miny, maxy );
365 DrawLineAttrib( aDrawer );
366 // aDrawer->SetTextAttrib( myColorIndex, myTextFont, 0, myTextScale*aDrawer->Scale(),
367 // myTextScale*aDrawer->Scale(), Standard_False );
371 Standard_ShortReal dxx = aDrawer->Convert(ADDPIX);
372 gp_Pnt2d P1 = gp_Pnt2d( myCentX + ( dxx + myRad ) * Cos(myFAngle),
373 myCentY + ( dxx + myRad ) * Sin(myFAngle) );
375 gp_Pnt2d P2 = gp_Pnt2d( myCentX + ( dxx + myRad ) * Cos(mySAngle),
376 myCentY + ( dxx + myRad ) * Sin(mySAngle) );
379 gp_Pnt2d theCent(myCentX, myCentY);
380 gp_Vec2d V1( theCent, P1), V2( theCent, P2), VX(1, 0);
381 Standard_Real delta = V1.Angle(V2);
382 gp_Vec2d textV1 = V1.Rotated( delta/2 );
383 Standard_Real theAngle = VX.Angle(textV1);
384 gp_Pnt2d pntText = theCent.Translated(textV1);
385 Standard_Real txtX, txtY;
386 pntText.Coord(txtX, txtY);
387 Standard_ShortReal txtAngle = Standard_ShortReal( theAngle + 3*M_PI/2);*/
388 //correct by enk Mon Dec 2 11:39 2002
391 /////////////////////////////////////////
392 Standard_ShortReal txtAngle=Standard_ShortReal(myAbsAngle);
393 Standard_Real theSmbX,theSmbY;
396 /////////////////////////////////////////
397 Standard_ShortReal a = myCentX, b = myCentY, c = myRad, e = myFAngle,
398 f = mySAngle,t1 = Standard_ShortReal( myAbsX ),
399 t2 = Standard_ShortReal( myAbsY );
400 TShort_Array1OfShortReal Xpoint( 1, 3 ), Ypoint( 1, 3 );
402 if ( anIndex == 1 ) {
403 Xpoint.Assign( myXVert1 );
404 Ypoint.Assign( myYVert1 );
405 } else if ( anIndex == 2 ) {
406 Xpoint.Assign( myXVert2 );
407 Ypoint.Assign( myYVert2 );
410 if ( myGOPtr->IsTransformed () ) {
411 gp_GTrsf2d aTrsf = myGOPtr->Transform ();
412 Standard_Real a1, b1;
414 if ( anIndex == 1 ) {
415 for ( Standard_Integer j = 1; j <= 3; j++ ) {
416 a1 = Standard_Real( Xpoint(j) );
417 b1 = Standard_Real( Xpoint(j) );
418 aTrsf.Transforms( a1, b1 );
419 Xpoint(j) = Standard_ShortReal( a1 );
420 Ypoint(j) = Standard_ShortReal( b1 );
422 } else if ( anIndex == 2 ) {
424 for ( Standard_Integer j = 1; j <= 3; j++ ) {
425 a1 = Standard_Real( Xpoint(j) );
426 b1 = Standard_Real( Xpoint(j) );
427 aTrsf.Transforms( a1, b1 );
428 Xpoint(j) = Standard_ShortReal( a1 );
429 Ypoint(j) = Standard_ShortReal( b1 );
431 } else if ( anIndex == 4 ) {
433 Standard_Real A, B, E, F,
434 X0, Y0, X1, Y1, X2, Y2;
435 A = Standard_Real( a );
436 B = Standard_Real( b );
437 E = Standard_Real( e );
438 F = Standard_Real( f );
439 aTrsf.Transforms( A, B );
440 a = Standard_ShortReal( A );
441 b = Standard_ShortReal( B );
443 if ( Abs(f-e) < Standard_ShortReal(2. * M_PI) ) {
444 aTrsf.SetValue( 1, 3, 0.0 );
445 aTrsf.SetValue( 2, 3, 0.0 );
450 aTrsf.Transforms( X1, Y1 );
451 aTrsf.Transforms( X2, Y2 );
453 aTrsf.Transforms( X0, Y0 );
458 c = myRad * Standard_ShortReal( Sqrt(X1*X1 + Y1*Y1) );
459 e = Standard_ShortReal( atan2(Y1,X1) );
460 f = Standard_ShortReal( atan2(Y2,X2) );
461 if ( aTrsf.IsNegative() ) {
462 Standard_ShortReal t = e; e = f; f = t;
464 } // end if Abs(f-e) < 2PI
466 } else if ( anIndex == 3 ) {
467 a1 = Standard_Real( t1 );
468 b1 = Standard_Real( t2);
469 aTrsf.Transforms( a1, b1 );
470 t1 = Standard_ShortReal( a1 );
471 t2 = Standard_ShortReal( b1);
475 if ( anIndex == 1 || anIndex == 2 )
476 if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) {
477 aDrawer->MapPolygonFromTo( Xpoint, Ypoint );
479 aDrawer->MapPolylineFromTo( Xpoint, Ypoint );
481 else if ( anIndex == 4 )
482 aDrawer->MapArcFromTo( a, b, c, e, f );
483 else if ( anIndex == 3 )
484 aDrawer->MapTextFromTo( myText, t1, t2, txtAngle, 0., 0., Aspect_TOT_SOLID );
486 } // end if IsIn is true
490 void Prs2d_Angle::DrawVertex (const Handle(Graphic2d_Drawer)& aDrawer,
491 const Standard_Integer anIndex) {
493 Standard_Boolean IsIn = Standard_False;
495 if ( ! myGOPtr->IsTransformed() )
496 IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY );
498 Standard_ShortReal minx, miny, maxx, maxy;
499 MinMax( minx, maxx, miny, maxy );
500 IsIn = aDrawer->IsIn( minx, maxx, miny, maxy );
504 if ( anIndex > 0 && anIndex < 4 ) {
505 DrawMarkerAttrib( aDrawer );
506 Standard_ShortReal X=0.,Y=0.;
507 if ( anIndex == 1 ) {
508 X = myCentX; Y = myCentY;
509 } else if ( anIndex == 2 ) {
510 X = Standard_ShortReal(myCentX + myRad *Cos( myFAngle ));
511 Y = Standard_ShortReal(myCentY + myRad *Sin( myFAngle ));
512 } else if ( anIndex == 3 ) {
513 X = Standard_ShortReal( myCentX + myRad *Cos( mySAngle ) );
514 Y = Standard_ShortReal( myCentY + myRad *Sin( mySAngle ) );
516 if ( myGOPtr->IsTransformed() ) {
517 gp_GTrsf2d aTrsf = myGOPtr->Transform ();
519 A = Standard_Real( X );
520 B = Standard_Real( Y );
521 aTrsf.Transforms (A, B);
522 X = Standard_ShortReal( A );
523 Y = Standard_ShortReal( B );
525 aDrawer->MapMarkerFromTo( VERTEXMARKER, X, Y,
526 DEFAULTMARKERSIZE,DEFAULTMARKERSIZE, 0.0 );
528 } // end if IsIn is true
532 Standard_Boolean Prs2d_Angle::Pick( const Standard_ShortReal X,
533 const Standard_ShortReal Y,
534 const Standard_ShortReal aPrecision,
535 const Handle(Graphic2d_Drawer)& aDrawer) {
537 Standard_Boolean Result = Standard_False;
538 Standard_ShortReal SRX = X, SRY = Y;
540 if ( IsInMinMax( X, Y, aPrecision ) ) {
542 if ( myGOPtr->IsTransformed() ) {
543 gp_GTrsf2d aTrsf = ( myGOPtr->Transform() ).Inverted ();
544 Standard_Real RX = Standard_Real( SRX ), RY = Standard_Real( SRY );
545 aTrsf.Transforms( RX, RY );
546 SRX = Standard_ShortReal( RX );
547 SRY = Standard_ShortReal( RY );
549 Standard_ShortReal x1 = Standard_ShortReal(myRad *Cos( myFAngle ) + myCentX),
550 y1 = Standard_ShortReal(myRad *Sin( myFAngle ) + myCentY),
551 x2 = Standard_ShortReal(myRad *Cos( mySAngle ) + myCentX),
552 y2 = Standard_ShortReal(myRad *Sin( mySAngle ) + myCentY);
555 if ( Graphic2d_Primitive::IsOn( SRX, SRY, myCentX, myCentY, aPrecision ) ) {
557 return Standard_True;
558 } else if ( Graphic2d_Primitive::IsOn( SRX, SRY, x1, y1, aPrecision ) ) {
560 return Standard_True;
561 } else if ( Graphic2d_Primitive::IsOn( SRX, SRY, x2, y2, aPrecision ) ) {
563 return Standard_True;
566 if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) {
567 for ( Standard_Integer i = 1; i < 3 ; i++)
568 if ( IsOn( SRX, SRY, myXVert1(i), myYVert1(i), myXVert1(i+1), myYVert1( i+1 ), aPrecision ) ) {
570 return Standard_True;
573 if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED )
574 if ( IsIn( SRX, SRY, myXVert1, myYVert1, aPrecision ) ) {
576 return Standard_True;
578 } // end if myArrow == FIRSTAR or BOTHAR
580 if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){
581 for ( Standard_Integer i = 1; i < 3 ; i++)
582 if ( IsOn( SRX, SRY, myXVert2(i), myYVert2(i), myXVert2(i+1), myYVert2( i+1 ), aPrecision ) ) {
584 return Standard_True;
587 if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED )
588 if ( IsIn( SRX, SRY, myXVert2, myYVert2, aPrecision ) ) {
590 return Standard_True;
592 } // end if myArrow == LASTAR or BOTHAR
594 Standard_ShortReal width,height,xoffset,yoffset;
595 Standard_ShortReal hscale = Standard_ShortReal(myTextScale*aDrawer->Scale()),
596 wscale = Standard_ShortReal(myTextScale*aDrawer->Scale());
597 Standard_ShortReal TX = X, TY = Y;
599 aDrawer->SetTextAttrib( myColorIndex, myTextFont, 0, hscale, wscale, Standard_False );
600 if ( !aDrawer->GetTextSize( myText, width, height, xoffset, yoffset ) ) {
601 width = height = xoffset = yoffset = 0.;
604 /*Standard_ShortReal dxx = aDrawer->Convert(ADDPIX);
605 gp_Pnt2d P1 = gp_Pnt2d( myCentX + ( dxx + myRad ) * Cos(myFAngle),
606 myCentY + ( dxx + myRad ) * Sin(myFAngle) );
608 gp_Pnt2d P2 = gp_Pnt2d( myCentX + ( dxx + myRad ) * Cos(mySAngle),
609 myCentY + ( dxx + myRad ) * Sin(mySAngle) );
612 gp_Pnt2d theCent(myCentX, myCentY);
613 gp_Vec2d V1( theCent, P1), V2( theCent, P2), VX(1, 0);
614 Standard_Real delta = V1.Angle(V2);
615 gp_Vec2d textV1 = V1.Rotated( delta/2 );
616 Standard_Real theAngle = VX.Angle(textV1);
617 gp_Pnt2d pntText = theCent.Translated(textV1);
618 Standard_Real txtX, txtY;
619 pntText.Coord(txtX, txtY);
620 Standard_ShortReal txtAngle = Standard_ShortReal( theAngle + 3*M_PI/2);*/
621 //correct by enk Mon Dec 2 11:41 2002
623 /////////////////////////////////////////
624 Standard_Real txtX,txtY,txtA;
628 Standard_ShortReal txtAngle=Standard_ShortReal(txtA);
629 /////////////////////////////////////////
631 Standard_ShortReal cosa = Standard_ShortReal(Cos( -txtAngle )),
632 sina = Standard_ShortReal(Sin( -txtAngle )),
633 dx = TX - Standard_ShortReal(txtX),
634 dy = TY - Standard_ShortReal(txtY),
638 Result = (x >= -aPrecision + xoffset)
639 && (x <= width + xoffset + aPrecision)
640 && (y >= -yoffset - aPrecision)
641 && (y <= height - yoffset + aPrecision);
645 return Standard_True;
648 if ( Abs( Sqrt( (myCentX - SRX)*(myCentX - SRX) +
649 (myCentY - SRY)*(myCentY - SRY) ) - myRad ) < aPrecision ) {
651 return Standard_True;
654 } // end if IsInMinMax is true
656 return Standard_False;
659 void Prs2d_Angle::Save(Aspect_FStream& aFStream) const