summaryrefslogtreecommitdiff
path: root/src/Prs2d/Prs2d_Angle.cxx
blob: 1e2c8ecd78053e91f91bebc0fd589827ff6c9199 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
#include <Prs2d_Angle.ixx>
#include <gp_Vec2d.hxx>

#define VERTEXMARKER 2
#define DEFAULTMARKERSIZE 3.0
#define XROTATE(x,y) ((x)*cosa - (y)*sina)
#define YROTATE(x,y) ((y)*cosa + (x)*sina)
#define ADDPIX 7

Prs2d_Angle::Prs2d_Angle( const Handle(Graphic2d_GraphicObject)& aGO,
			  const gp_Pnt2d&                   anAttachPnt1,
			  const gp_Pnt2d&                   anAttachPnt2,
			  const gp_Pnt2d&                   anAttachPnt3,
			  const Quantity_Length             aRadius,
                          const TCollection_ExtendedString& aText,
                          const Standard_Real               aTxtScale,
                          const Standard_Real               anArrAngle,
			  const Standard_Real               anArrLength,
	                  const Prs2d_TypeOfArrow           anArrType,
                          const Prs2d_ArrowSide             anArrow,
                          const Standard_Boolean            IsRevArrow ) 
  
 :     Prs2d_Dimension( aGO, aText, aTxtScale, anArrAngle, 
                       anArrLength, anArrType, anArrow, IsRevArrow ),
       myCentX( Standard_ShortReal( anAttachPnt1.X() ) ),
       myCentY( Standard_ShortReal( anAttachPnt1.Y() ) ),
       myRad( Standard_ShortReal( aRadius ) ) 
{
   
  SetSymbolCode( 176 );
  gp_Vec2d V1( anAttachPnt1, anAttachPnt2 );
  gp_Vec2d V2( anAttachPnt1, anAttachPnt3 );
  gp_Vec2d VX( 1., 0. );
  myFAngle = Standard_ShortReal( VX.Angle(V1) );
  mySAngle = Standard_ShortReal( VX.Angle(V2) );
  
  //myRad = Standard_ShortReal(anAttachPnt1.Distance( anOffsetPoint ));
  if ( myRad <= ShortRealEpsilon ())
     Graphic2d_CircleDefinitionError::Raise ("The radius = 0." );

  Standard_ShortReal TwoPI = Standard_ShortReal(2.* Standard_PI);
  while( myFAngle < 0. ) myFAngle += TwoPI;
  while( myFAngle > 2.* Standard_PI ) myFAngle -= TwoPI;
  while( mySAngle < 0. ) mySAngle += TwoPI;
  while( mySAngle > 2.* Standard_PI ) mySAngle -= TwoPI;
  if ( mySAngle < myFAngle ) mySAngle += TwoPI;

  if ( ( mySAngle - myFAngle < ShortRealEpsilon() ) || 
       ( mySAngle - myFAngle >= TwoPI ) ) {
	 myFAngle = 0.;
	 mySAngle = TwoPI;
  	 myMinX = myCentX - myRad;
  	 myMinY = myCentY - myRad;
  	 myMaxX = myCentX + myRad;
  	 myMaxY = myCentY + myRad;
  } else {
	 Standard_ShortReal Acur,Xcur,Ycur,Xsav;
         myMinX = myMaxX = Standard_ShortReal(Cos(myFAngle));
         myMinY = myMaxY = Standard_ShortReal(Sin(myFAngle));
	 Xcur = Standard_ShortReal(Cos(mySAngle));
	 Ycur = Standard_ShortReal(Sin(mySAngle));
         myMinX = myMinX < Xcur ? myMinX : Xcur;
         myMinY = myMinY < Ycur ? myMinY : Ycur;
         myMaxX = myMaxX > Xcur ? myMaxX : Xcur;
         myMaxY = myMaxY > Ycur ? myMaxY : Ycur;

     for ( Acur = 0., Xcur = 1., Ycur = 0.; 
	   Acur < mySAngle; Acur += Standard_ShortReal(Standard_PI/2.)) {
	   if ( Acur > myFAngle ) {
           myMinX = ( myMinX < Xcur ? myMinX : Xcur );
           myMaxX = ( myMaxX < Xcur ? Xcur : myMaxX );
           myMinY = ( myMinY < Ycur ? myMinY : Ycur );
           myMaxY = ( myMaxY < Ycur ? Ycur : myMaxY );
	    }
        Xsav = Xcur; Xcur = -Ycur; Ycur = Xsav;
	 }
       myMinX = myCentX + myRad * myMinX;
       myMaxX = myCentX + myRad * myMaxX;
       myMinY = myCentY + myRad * myMinY;
       myMaxY = myCentY + myRad * myMaxY;
  }

  // Arrows

  Standard_Real ArrAngle = PI/180.*anArrAngle;
     
  gp_Pnt2d theOrigine(0.,0.);
  gp_Pnt2d P1, P2, P3;
  gp_Vec2d VDir;
  Standard_Real theAngle;

  if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) {
    P1 = gp_Pnt2d( myCentX + myRad * Cos(myFAngle),
               myCentY + myRad * Sin(myFAngle) );
  
    P2 = gp_Pnt2d( anArrLength,  anArrLength*Tan( ArrAngle/2. ) );
    P3 = gp_Pnt2d( anArrLength, -anArrLength*Tan( ArrAngle/2. ) );
  
    VDir = V1.Rotated(PI/2);
    theAngle = VX.Angle( VDir );
    P2.Rotate( theOrigine, theAngle );
    P3.Rotate( theOrigine, theAngle );
  
    P2.Translate( gp_Vec2d( theOrigine, P1 ) );
    P3.Translate( gp_Vec2d( theOrigine, P1 ) );
  
    myXVert1(1) = Standard_ShortReal( P2.X() );
    myYVert1(1) = Standard_ShortReal( P2.Y() );
    myXVert1(2) = Standard_ShortReal( P1.X() );
    myYVert1(2) = Standard_ShortReal( P1.Y() );
    myXVert1(3) = Standard_ShortReal( P3.X() );
    myYVert1(3) = Standard_ShortReal( P3.Y() );

    for ( Standard_Integer i = 1; i <= 3; i++ ) {
	  if ( myXVert1(i) < myMinX ) myMinX = myXVert1(i);
          if ( myYVert1(i) < myMinY ) myMinY = myYVert1(i);
          if ( myXVert1(i) > myMaxX ) myMaxX = myXVert1(i);
	  if ( myYVert1(i) > myMaxY ) myMaxY = myYVert1(i);
	  
    }
  } // end if myArrow is FIRSTAR or BOTHAR
 
  if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){
    P1 = gp_Pnt2d ( myCentX + myRad * Cos(mySAngle),
                    myCentY + myRad * Sin(mySAngle) );
  
    P2 = gp_Pnt2d( anArrLength,  anArrLength*Tan( ArrAngle/2. ) );
    P3 = gp_Pnt2d( anArrLength, -anArrLength*Tan( ArrAngle/2. ) );
  
    VDir = V2.Rotated(-PI/2);
    theAngle = VX.Angle( VDir );

    P2.Rotate( theOrigine, theAngle );
    P3.Rotate( theOrigine, theAngle );
  
    P2.Translate( gp_Vec2d( theOrigine, P1 ) );
    P3.Translate( gp_Vec2d( theOrigine, P1 ) );
  
    myXVert2(1) = Standard_ShortReal( P2.X() );
    myYVert2(1) = Standard_ShortReal( P2.Y() );
    myXVert2(2) = Standard_ShortReal( P1.X() );
    myYVert2(2) = Standard_ShortReal( P1.Y() );
    myXVert2(3) = Standard_ShortReal( P3.X() );
    myYVert2(3) = Standard_ShortReal( P3.Y() );

    for ( Standard_Integer i = 1; i <= 3; i++ ) {
	  if ( myXVert2(i) < myMinX ) myMinX = myXVert2(i);
          if ( myYVert2(i) < myMinY ) myMinY = myYVert2(i);
          if ( myXVert2(i) > myMaxX ) myMaxX = myXVert2(i);
	  if ( myYVert2(i) > myMaxY ) myMaxY = myYVert2(i);
	  
    }
 } // end if myArrow is FIRSTAR or BOTHAR

  myNumOfElem = 4;
  myNumOfVert = 3;

}

void Prs2d_Angle::Values( gp_Pnt2d        & aPnt1,
                          gp_Pnt2d        & aPnt2,
                          gp_Pnt2d        & aPnt3,
                          Quantity_Length & aRad ) const {

   aPnt1.SetCoord( myCentX, myCentY );
   gp_Vec2d VX( myRad, 0. ), V2, V3;
   V2 = VX.Rotated( myFAngle );  
   aPnt2 = aPnt1.Translated( V2 );
   V3 = VX.Rotated( mySAngle ); 
   aPnt3 = aPnt1.Translated( V3 );
   aRad = myRad;
}

void Prs2d_Angle::Draw( const Handle(Graphic2d_Drawer)& aDrawer ) {

  Standard_Boolean IsIn = Standard_False;

  if ( !myGOPtr->IsTransformed() )
    IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY );
  else {
    Standard_ShortReal minx, miny, maxx, maxy;
    MinMax( minx, maxx, miny, maxy );
    IsIn = aDrawer->IsIn( minx, maxx, miny, maxy );
  }

  if ( IsIn ) {

    DrawLineAttrib(aDrawer);
    Standard_ShortReal theScale = Standard_ShortReal(myTextScale*aDrawer->Scale());
    aDrawer->SetTextAttrib( myColorIndex, myTextFont, 0.0, theScale, theScale, Standard_False );
    
    // Text 
    /*Standard_ShortReal dxx = aDrawer->Convert(ADDPIX);
    gp_Pnt2d P1 = gp_Pnt2d( myCentX + ( dxx + myRad ) * Cos(myFAngle),
                            myCentY + ( dxx + myRad ) * Sin(myFAngle) );
  
    gp_Pnt2d P2 = gp_Pnt2d( myCentX + ( dxx + myRad ) * Cos(mySAngle),
                            myCentY + ( dxx + myRad ) * Sin(mySAngle) );
  

    gp_Pnt2d theCent(myCentX, myCentY);
    gp_Vec2d V1( theCent, P1), V2( theCent, P2), VX(1., 0.);
    Standard_Real delta = V1.Angle(V2);
    gp_Vec2d textV1 = V1.Rotated( delta/2 );
    Standard_Real theAngle = VX.Angle(textV1);
    gp_Pnt2d pntText = theCent.Translated(textV1);
    Standard_Real txtX, txtY;
    pntText.Coord(txtX, txtY);
    Standard_ShortReal txtAngle = Standard_ShortReal( theAngle + 3*PI/2);
    
    Standard_ShortReal ws, hs;
    aDrawer->GetTextSize( myText, ws, hs );
    Standard_Real theSmbX, theSmbY;
    Standard_ShortReal ddd = aDrawer->Convert(2);
    gp_Vec2d theVec = VX.Rotated( txtAngle );
    theVec *= ( ws + ddd );
    gp_Pnt2d pntSymb = pntText.Translated( theVec );
    pntSymb.Coord( theSmbX, theSmbY );*/ //correct by enk Fri Nov 29 15:17 2002
    
    /////////////////////////////////////////
    Standard_ShortReal txtAngle=Standard_ShortReal(myAbsAngle);
    Standard_Real theSmbX,theSmbY;
    theSmbX=myAbsX;
    theSmbY=myAbsY;
    /////////////////////////////////////////
    Standard_ShortReal a = myCentX, b = myCentY, c = myRad, e = myFAngle, f = mySAngle,
                       t1 = Standard_ShortReal(myAbsX), t2 = Standard_ShortReal(myAbsY),
                       ts1 = Standard_ShortReal(theSmbX), ts2 = Standard_ShortReal(theSmbY);
    
    TShort_Array1OfShortReal Xpoint1( 1, 3 ), Ypoint1( 1, 3 ), 
                             Xpoint2( 1, 3 ), Ypoint2( 1, 3 );

    if ( myGOPtr->IsTransformed () ) {

      gp_GTrsf2d aTrsf = myGOPtr->Transform ();
      
      if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){
    
        Standard_Real a1, b1;
        for ( Standard_Integer j = 1; j <= 3; j++ ) {
		     a1 = Standard_Real( myXVert1(j) );
		     b1 = Standard_Real( myYVert1(j) );
                     aTrsf.Transforms (a1, b1);
                     Xpoint1(j) = Standard_ShortReal(a1);
		     Ypoint1(j) = Standard_ShortReal(b1);
         }
      } // end if myArrow is FIRSTAR ot BOTHAR
   
      if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) {
        
        Standard_Real c1, d1;

        for ( Standard_Integer j = 1; j <= 3; j++ ) {
                     c1 = Standard_Real( myXVert2(j) );
		     d1 = Standard_Real( myYVert2(j) );
                     aTrsf.Transforms (c1, d1);
                     Xpoint2(j) = Standard_ShortReal(c1);
		     Ypoint2(j) = Standard_ShortReal(d1);
         }
      } // end if myArrow is LASTAR ot BOTHAR   

      Standard_Real A, B, E, F, 
                    X0, Y0, X1, Y1, X2, Y2, T1, T2;
      A = Standard_Real( a ); 
      B = Standard_Real( b );
      E = Standard_Real( e ); 
      F = Standard_Real( f );
      T1 = Standard_Real( t1 );
      T2 = Standard_Real( t2);
          aTrsf.Transforms( A, B );
          aTrsf.Transforms( T1, T2 );
      a = Standard_ShortReal( A ); 
      b = Standard_ShortReal( B );
      t1 = Standard_ShortReal( T1 ); 
      t2 = Standard_ShortReal( T2 );
      A = Standard_Real( ts1 );
      B = Standard_Real( ts2 );	   
          aTrsf.Transforms( A, B );
      ts1 = Standard_ShortReal( A );
      ts2 = Standard_ShortReal( B );

	  if ( Abs(f-e) < Standard_ShortReal(2.*Standard_PI) ) {
	    aTrsf.SetValue( 1, 3, 0.0 );
	    aTrsf.SetValue( 2, 3, 0.0 );

	    X1 = Cos(E); 
            Y1 = Sin(E );
	    X2 = Cos(F); 
            Y2 = Sin(F );
	    aTrsf.Transforms( X1, Y1 ); 
	    aTrsf.Transforms( X2, Y2 ); 
            X0 = Y0 = 0.;
	    aTrsf.Transforms( X0, Y0 );
	    X1 -= X0; 
            Y1 -= Y0;
	    X2 -= X0; 
            Y2 -= Y0;
            c = myRad * Standard_ShortReal( Sqrt(X1*X1 + Y1*Y1) );
            e = Standard_ShortReal( atan2(Y1,X1) );
            f = Standard_ShortReal( atan2(Y2,X2) );
            if ( aTrsf.IsNegative() ) {
              Standard_ShortReal t = e; e = f; f = t; 
            }
          } // end if Abs(f-e) < 2PI
   } else {
   
    if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){
      Xpoint1.Assign( myXVert1 );
      Ypoint1.Assign( myYVert1 );
    }
    if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) {
      Xpoint2.Assign( myXVert2 );
      Ypoint2.Assign( myYVert2 );
    }
        
   } // end if GO is transformed

   aDrawer->MapArcFromTo( a, b, c, e, f );
   aDrawer->MapTextFromTo( myText, t1, t2, txtAngle, 0., 0., Aspect_TOT_SOLID );

   if ( myIsSymbol ) {
      aDrawer->SetTextAttrib( myColorIndex, mySymbFont, 0, Standard_ShortReal(myTextScale*aDrawer->Scale()), 
                              Standard_ShortReal(myTextScale*aDrawer->Scale()), Standard_False );
//      TCollection_ExtendedString txtSymb( char( SymbolCode() ) );
      Standard_Character code = (Standard_Character) SymbolCode();
      TCollection_ExtendedString txtSymb( code );
      Standard_ShortReal dx=0.,dy=0.;
      aDrawer->MapTextFromTo( txtSymb, ts1, ts2, txtAngle, dx, dy, Aspect_TOT_SOLID );
    }


   if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){
     if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) {
       aDrawer->MapPolygonFromTo( Xpoint1, Ypoint1 );
     } else {
       aDrawer->MapPolylineFromTo( Xpoint1, Ypoint1 );
     } 
   }

   if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){
     if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) {
       aDrawer->MapPolygonFromTo( Xpoint2, Ypoint2 );
     } else {
       aDrawer->MapPolylineFromTo( Xpoint2, Ypoint2 );
     } 
   }
   
  } // end if IsIn is true
}

void Prs2d_Angle::DrawElement( const Handle(Graphic2d_Drawer)& aDrawer,
                               const Standard_Integer anIndex) {
  Standard_Boolean IsIn = Standard_False;

  if ( ! myGOPtr->IsTransformed() )
    IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY );
  else {
    Standard_ShortReal minx, miny, maxx, maxy;
    MinMax( minx, maxx, miny, maxy );
    IsIn = aDrawer->IsIn( minx, maxx, miny, maxy );
  }

  if ( IsIn ) {

    DrawLineAttrib( aDrawer );
    //  aDrawer->SetTextAttrib( myColorIndex, myTextFont, 0, myTextScale*aDrawer->Scale(), 
    //                          myTextScale*aDrawer->Scale(), Standard_False );
    
    // Text 
    /*
    Standard_ShortReal dxx = aDrawer->Convert(ADDPIX);
    gp_Pnt2d P1 = gp_Pnt2d( myCentX + ( dxx + myRad ) * Cos(myFAngle),
                            myCentY + ( dxx + myRad ) * Sin(myFAngle) );
  
    gp_Pnt2d P2 = gp_Pnt2d( myCentX + ( dxx + myRad ) * Cos(mySAngle),
                            myCentY + ( dxx + myRad ) * Sin(mySAngle) );
  

    gp_Pnt2d theCent(myCentX, myCentY);
    gp_Vec2d V1( theCent, P1), V2( theCent, P2), VX(1, 0);
    Standard_Real delta = V1.Angle(V2);
    gp_Vec2d textV1 = V1.Rotated( delta/2 );
    Standard_Real theAngle = VX.Angle(textV1);
    gp_Pnt2d pntText = theCent.Translated(textV1);
    Standard_Real txtX, txtY;
    pntText.Coord(txtX, txtY);
    Standard_ShortReal txtAngle = Standard_ShortReal( theAngle + 3*PI/2);*/
    //correct by enk Mon Dec 2 11:39 2002
    
    
    /////////////////////////////////////////
    Standard_ShortReal txtAngle=Standard_ShortReal(myAbsAngle);
    /////////////////////////////////////////
    Standard_ShortReal a = myCentX, b = myCentY, c = myRad, e = myFAngle, 
                       f = mySAngle,t1 = Standard_ShortReal( myAbsX ),
                       t2 = Standard_ShortReal( myAbsY );
    TShort_Array1OfShortReal Xpoint( 1, 3 ), Ypoint( 1, 3 ); 

    if ( anIndex == 1 ) {
     Xpoint.Assign( myXVert1 );
     Ypoint.Assign( myYVert1 );
    } else if ( anIndex == 2 ) {
     Xpoint.Assign( myXVert2 );
     Ypoint.Assign( myYVert2 );    
    } 

    if ( myGOPtr->IsTransformed () ) {
      gp_GTrsf2d aTrsf = myGOPtr->Transform ();
      Standard_Real a1, b1;
      
      if ( anIndex == 1 ) {      
        for ( Standard_Integer j = 1; j <= 3; j++ ) {
		     a1 = Standard_Real( Xpoint(j) );
		     b1 = Standard_Real( Xpoint(j) );
                     aTrsf.Transforms( a1, b1 );
                     Xpoint(j) = Standard_ShortReal( a1 );
		     Ypoint(j) = Standard_ShortReal( b1 );
         }
      } else if ( anIndex == 2 ) {

        for ( Standard_Integer j = 1; j <= 3; j++ ) {
                     a1 = Standard_Real( Xpoint(j) );
		     b1 = Standard_Real( Xpoint(j) );
                     aTrsf.Transforms( a1, b1 );
                     Xpoint(j) = Standard_ShortReal( a1 );
		     Ypoint(j) = Standard_ShortReal( b1 );
         }
      } else if ( anIndex == 4 ) {

          Standard_Real A, B, E, F, 
                    X0, Y0, X1, Y1, X2, Y2;
	  A = Standard_Real( a ); 
          B = Standard_Real( b );
	  E = Standard_Real( e ); 
          F = Standard_Real( f );
          aTrsf.Transforms( A, B );
          a = Standard_ShortReal( A ); 
          b = Standard_ShortReal( B );
      
	      if ( Abs(f-e) < Standard_ShortReal(2.*Standard_PI) ) {
	        aTrsf.SetValue( 1, 3, 0.0 );
	        aTrsf.SetValue( 2, 3, 0.0 );
	        X1 = Cos(E); 
                Y1 = Sin(E );
	        X2 = Cos(F); 
                Y2 = Sin(F );
	        aTrsf.Transforms( X1, Y1 ); 
	        aTrsf.Transforms( X2, Y2 ); 
                X0 = Y0 = 0.;
	        aTrsf.Transforms( X0, Y0 );
	        X1 -= X0; 
                Y1 -= Y0;
	        X2 -= X0; 
                Y2 -= Y0;
                c = myRad * Standard_ShortReal( Sqrt(X1*X1 + Y1*Y1) );
                e = Standard_ShortReal( atan2(Y1,X1) );
                f = Standard_ShortReal( atan2(Y2,X2) );
                if ( aTrsf.IsNegative() ) {
                  Standard_ShortReal t = e; e = f; f = t; 
                }
              } // end if Abs(f-e) < 2PI
         
        } else if ( anIndex == 3 ) {
                 a1 = Standard_Real( t1 );
                 b1 = Standard_Real( t2);
                 aTrsf.Transforms( a1, b1 );
                 t1 = Standard_ShortReal( a1 );
                 t2 = Standard_ShortReal( b1);
      }
    } 

    if ( anIndex == 1 || anIndex == 2 ) 
      if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) {
	    aDrawer->MapPolygonFromTo( Xpoint, Ypoint );
      } else {
        aDrawer->MapPolylineFromTo( Xpoint, Ypoint );
      } 
    else if ( anIndex == 4 )
        aDrawer->MapArcFromTo( a, b, c, e, f );
    else if ( anIndex == 3 )
        aDrawer->MapTextFromTo( myText, t1, t2, txtAngle, 0., 0., Aspect_TOT_SOLID );
  
  } // end if IsIn is true 

}

void Prs2d_Angle::DrawVertex (const Handle(Graphic2d_Drawer)& aDrawer,
                              const Standard_Integer anIndex) {

  Standard_Boolean IsIn = Standard_False;

  if ( ! myGOPtr->IsTransformed() )
    IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY );
  else {
    Standard_ShortReal minx, miny, maxx, maxy;
    MinMax( minx, maxx, miny, maxy );
    IsIn = aDrawer->IsIn( minx, maxx, miny, maxy );
  }
  
  if ( IsIn  ) {
   if ( anIndex > 0 && anIndex < 4 ) {
    DrawMarkerAttrib( aDrawer );
    Standard_ShortReal X=0.,Y=0.;
    if ( anIndex == 1 ) {
        X = myCentX; Y = myCentY; 
    } else if ( anIndex == 2 ) {
        X = Standard_ShortReal(myCentX + myRad *Cos( myFAngle ));
        Y = Standard_ShortReal(myCentY + myRad *Sin( myFAngle ));
    } else if ( anIndex == 3 ) {
        X = Standard_ShortReal( myCentX + myRad *Cos( mySAngle ) );
        Y = Standard_ShortReal( myCentY + myRad *Sin( mySAngle ) );
    }
    if ( myGOPtr->IsTransformed() ) {
        gp_GTrsf2d aTrsf = myGOPtr->Transform ();
        Standard_Real A, B;
        A = Standard_Real( X );
        B = Standard_Real( Y );
        aTrsf.Transforms (A, B);
        X = Standard_ShortReal( A );
        Y = Standard_ShortReal( B );
    } 
     aDrawer->MapMarkerFromTo( VERTEXMARKER, X, Y,
			DEFAULTMARKERSIZE,DEFAULTMARKERSIZE, 0.0 );
    }
  }  // end if IsIn is true         

}

Standard_Boolean Prs2d_Angle::Pick( const Standard_ShortReal X,
	                            const Standard_ShortReal Y,
				    const Standard_ShortReal aPrecision,
				    const Handle(Graphic2d_Drawer)& aDrawer) {

  Standard_Boolean Result = Standard_False;
  Standard_ShortReal SRX = X, SRY = Y;

  if ( IsInMinMax( X, Y, aPrecision ) ) {

    if ( myGOPtr->IsTransformed() ) {
          gp_GTrsf2d aTrsf = ( myGOPtr->Transform() ).Inverted ();
          Standard_Real RX = Standard_Real( SRX ), RY = Standard_Real( SRY );
	  aTrsf.Transforms( RX, RY );
	  SRX = Standard_ShortReal( RX ); 
          SRY = Standard_ShortReal( RY );
    }
    Standard_ShortReal x1 = Standard_ShortReal(myRad *Cos( myFAngle ) + myCentX),
                       y1 = Standard_ShortReal(myRad *Sin( myFAngle ) + myCentY),
                       x2 = Standard_ShortReal(myRad *Cos( mySAngle ) + myCentX),
                       y2 = Standard_ShortReal(myRad *Sin( mySAngle ) + myCentY);


     if ( Graphic2d_Primitive::IsOn( SRX, SRY, myCentX, myCentY, aPrecision ) ) {
         SetPickedIndex(-1);    
         return Standard_True;
      } else if ( Graphic2d_Primitive::IsOn( SRX, SRY, x1, y1, aPrecision ) ) {
         SetPickedIndex(-2);    
         return Standard_True;
      } else if ( Graphic2d_Primitive::IsOn( SRX, SRY, x2, y2, aPrecision ) ) {
         SetPickedIndex(-3);    
         return Standard_True;
      }

      if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) {
       for ( Standard_Integer i = 1; i < 3 ; i++)
         if ( IsOn( SRX, SRY, myXVert1(i), myYVert1(i), myXVert1(i+1), myYVert1( i+1 ), aPrecision ) ) {
           SetPickedIndex(1);
           return Standard_True;
        }
	
 	   if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) 
	    if ( IsIn( SRX, SRY,  myXVert1, myYVert1, aPrecision ) ) {
	       SetPickedIndex(1);
	       return Standard_True;
        }
      } // end if myArrow == FIRSTAR or BOTHAR

    if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){
      for ( Standard_Integer i = 1; i < 3 ; i++)
	    if ( IsOn( SRX, SRY, myXVert2(i), myYVert2(i), myXVert2(i+1), myYVert2( i+1 ), aPrecision ) ) {
	       SetPickedIndex(2);
	       return Standard_True;
	    }
	
	  if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) 
       if ( IsIn( SRX, SRY, myXVert2, myYVert2, aPrecision ) ) {
	      SetPickedIndex(2);
	      return Standard_True;
       }
    } // end if myArrow == LASTAR or BOTHAR

    Standard_ShortReal width,height,xoffset,yoffset;
    Standard_ShortReal hscale = Standard_ShortReal(myTextScale*aDrawer->Scale()),
                       wscale = Standard_ShortReal(myTextScale*aDrawer->Scale());
    Standard_ShortReal TX = X, TY = Y;
    
    aDrawer->SetTextAttrib( myColorIndex, myTextFont, 0, hscale, wscale, Standard_False );
    if ( !aDrawer->GetTextSize( myText, width, height, xoffset, yoffset ) ) {
      width = height = xoffset = yoffset = 0.;
    }
    // Text 
    /*Standard_ShortReal dxx = aDrawer->Convert(ADDPIX);
    gp_Pnt2d P1 = gp_Pnt2d( myCentX + ( dxx + myRad ) * Cos(myFAngle),
                            myCentY + ( dxx + myRad ) * Sin(myFAngle) );
  
    gp_Pnt2d P2 = gp_Pnt2d( myCentX + ( dxx + myRad ) * Cos(mySAngle),
                            myCentY + ( dxx + myRad ) * Sin(mySAngle) );
  

    gp_Pnt2d theCent(myCentX, myCentY);
    gp_Vec2d V1( theCent, P1), V2( theCent, P2), VX(1, 0);
    Standard_Real delta = V1.Angle(V2);
    gp_Vec2d textV1 = V1.Rotated( delta/2 );
    Standard_Real theAngle = VX.Angle(textV1);
    gp_Pnt2d pntText = theCent.Translated(textV1);
    Standard_Real txtX, txtY;
    pntText.Coord(txtX, txtY);
    Standard_ShortReal txtAngle = Standard_ShortReal( theAngle + 3*PI/2);*/
    //correct by enk Mon Dec 2 11:41 2002

    /////////////////////////////////////////
    Standard_Real txtX,txtY,txtA;
    txtX=myAbsX;
    txtY=myAbsY;
    txtA=myAbsAngle;
    Standard_ShortReal txtAngle=Standard_ShortReal(txtA);
    /////////////////////////////////////////   
    
    Standard_ShortReal cosa = Standard_ShortReal(Cos( -txtAngle )),
                       sina = Standard_ShortReal(Sin( -txtAngle )),
                       dx = TX - Standard_ShortReal(txtX),
                       dy = TY - Standard_ShortReal(txtY), 
                       x = XROTATE(dx,dy),
                       y = YROTATE(dx,dy);

    Result   =   (x >= -aPrecision + xoffset)            
            &&   (x <= width + xoffset + aPrecision)
            &&   (y >= -yoffset - aPrecision) 
            &&   (y <= height - yoffset + aPrecision);
  
    if ( Result ) {
      SetPickedIndex(3);
      return Standard_True;
    }

    if ( Abs( Sqrt( (myCentX - SRX)*(myCentX - SRX) + 
        (myCentY - SRY)*(myCentY - SRY) ) - myRad ) < aPrecision ) {
      SetPickedIndex(4);
      return Standard_True;
    }
    
  }	// end if IsInMinMax is true 

  return Standard_False;
}

void Prs2d_Angle::Save(Aspect_FStream& aFStream) const
{
}