1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
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.
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.
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.
18 #include <Prs2d_Radius.ixx>
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)
27 Prs2d_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 )
38 : Prs2d_Dimension( aGO, aText, aTxtScale, anArrAngle,
39 anArrLength, anArrType, anArrow, IsRevArrow ),
46 gp_Pnt2d aPnt1 = anAttachPnt, aPnt2 = aCircle.Location();
47 Standard_Real U = ElCLib::Parameter( aCircle, aPnt1 );
48 gp_Pnt2d PTonCirc = ElCLib::Value( U, aCircle );
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;
55 if ( theDist < theRad ) {
58 inside = Standard_True;
61 Standard_Real X1, Y1, X2, Y2;
62 aPnt1.Coord( X1, Y1 );
63 aPnt2.Coord( X2, Y2 );
65 myX1 = Standard_ShortReal( X1 );
66 myY1 = Standard_ShortReal( Y1 );
67 myX2 = Standard_ShortReal( X2 );
68 myY2 = Standard_ShortReal( Y2 );
75 if ( myX2 < myMinX ) myMinX = myX2;
76 if ( myY2 < myMinY ) myMinY = myY2;
77 if ( myX2 > myMaxX ) myMaxX = myX2;
78 if ( myY2 > myMaxY ) myMaxY = myY2;
80 Standard_Real ArrAngle = M_PI/180.* anArrAngle, theAngle;
81 gp_Pnt2d theOrigine( 0., 0. ), P1, P2, P3;
82 gp_Vec2d VX( 1., 0. ), VDir;
84 if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) {
87 P2 = gp_Pnt2d( anArrLength, anArrLength*Tan( ArrAngle/2. ) );
88 P3 = gp_Pnt2d( anArrLength, -anArrLength*Tan( ArrAngle/2. ) );
90 VDir = gp_Vec2d( aPnt1, aPnt2 );
91 if ( IsRevArrow ) VDir.Reverse();
93 theAngle = VX.Angle( VDir );
95 P2.Rotate( theOrigine, theAngle );
96 P3.Rotate( theOrigine, theAngle );
98 P2.Translate( gp_Vec2d( theOrigine, P1 ) );
99 P3.Translate( gp_Vec2d( theOrigine, P1 ) );
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() );
108 for ( Standard_Integer i = 1; i <= 3; i++ ) {
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);
116 } // end if myArrow is FIRSTAR or BOTHAR
118 if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){
121 P2 = gp_Pnt2d( anArrLength, anArrLength*Tan( ArrAngle/2. ) );
122 P3 = gp_Pnt2d( anArrLength, -anArrLength*Tan( ArrAngle/2. ) );
124 VDir = gp_Vec2d( aPnt2, aPnt1 );
125 if ( IsRevArrow ) VDir.Reverse();
127 theAngle = VX.Angle( VDir );
129 P2.Rotate( theOrigine, theAngle );
130 P3.Rotate( theOrigine, theAngle );
132 P2.Translate( gp_Vec2d( theOrigine, P1 ) );
133 P3.Translate( gp_Vec2d( theOrigine, P1 ) );
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() );
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);
149 } // end if myArrow is FIRSTAR or BOTHAR
155 void Prs2d_Radius::Values( gp_Pnt2d& anAttPnt,gp_Circ2d& aCirc ) const {
160 void Prs2d_Radius::Draw( const Handle(Graphic2d_Drawer)& aDrawer ) {
162 Standard_Boolean IsIn = Standard_False;
164 if (! myGOPtr->IsTransformed ())
165 IsIn = aDrawer->IsIn (myMinX,myMaxX,myMinY,myMaxY);
167 Standard_ShortReal minx, miny, maxx, maxy;
168 MinMax(minx,maxx,miny,maxy);
169 IsIn = aDrawer->IsIn (minx,maxx,miny,maxy);
174 DrawLineAttrib( aDrawer );
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 );
181 if ( theTxtAngle >= 0 && theTxtAngle <= M_PI/2 )
182 pntText = thePnt2.Translated( (myArrowLen+d1)*theVec/(thePnt1.Distance(thePnt2)) );
183 else if ( theTxtAngle > M_PI/2 && theTxtAngle <= M_PI ) {
184 pntText = thePnt1.Translated( (myArrowLen+d1)*theVec.Reversed()/(thePnt1.Distance(thePnt2)) );
185 theTxtAngle = VX.Angle( theVec.Reversed() );
186 } else if ( theTxtAngle >= -M_PI/2 && theTxtAngle < 0 )
187 pntText = thePnt2.Translated( (myArrowLen+d1)*theVec/(thePnt1.Distance(thePnt2)) );
188 else if ( theTxtAngle >= -M_PI && theTxtAngle < -M_PI/2 ) {
189 pntText = thePnt1.Translated( (myArrowLen+d1)*theVec.Reversed()/(thePnt1.Distance(thePnt2)) );
190 theTxtAngle = VX.Angle( theVec.Reversed() );
193 Standard_Real theTxtX, theTxtY;
194 Standard_Real theSmbX = 0., theSmbY = 0.;
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 );
211 pntText.Coord( theTxtX, theTxtY );
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);
218 TShort_Array1OfShortReal Xpoint1( 1, 3 ), Ypoint1( 1, 3 ),
219 Xpoint2( 1, 3 ), Ypoint2( 1, 3 );
222 if ( myGOPtr->IsTransformed () ) {
223 gp_GTrsf2d aTrsf = myGOPtr->Transform ();
225 if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){
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);
235 } // end if myArrow is FIRSTAR ot BOTHAR
237 if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) {
239 Standard_Real ac1,ad1;
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);
248 } // end if myArrow is LASTAR ot BOTHAR
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 );
274 if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){
275 Xpoint1.Assign( myXVert1 );
276 Ypoint1.Assign( myYVert1 );
278 if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) {
279 Xpoint2.Assign( myXVert2 );
280 Ypoint2.Assign( myYVert2 );
283 } // end if GO is transformed
285 aDrawer->MapSegmentFromTo( a, b, c, d );
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 );
296 aDrawer->SetTextAttrib( myColorIndex, myTextFont, 0, Standard_ShortReal(myTextScale*aDrawer->Scale()),
297 Standard_ShortReal(myTextScale*aDrawer->Scale()), Standard_False );
299 aDrawer->MapTextFromTo( myText, t1, t2, Standard_ShortReal(theTxtAngle), 0., 0., Aspect_TOT_SOLID );
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 );
305 aDrawer->MapPolylineFromTo( Xpoint1, Ypoint1 );
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 );
313 aDrawer->MapPolylineFromTo( Xpoint2, Ypoint2 );
318 } // end if IsIn is true
322 void Prs2d_Radius::DrawElement( const Handle(Graphic2d_Drawer)& aDrawer,
323 const Standard_Integer anIndex ) {
325 Standard_Boolean IsIn = Standard_False;
327 if ( ! myGOPtr->IsTransformed() )
328 IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY );
330 Standard_ShortReal minx, miny, maxx, maxy;
331 MinMax( minx, maxx, miny, maxy );
332 IsIn = aDrawer->IsIn( minx, maxx, miny, maxy );
337 DrawLineAttrib( aDrawer );
338 // aDrawer->SetTextAttrib( myColorIndex, myTextFont, 0, myTextScale*aDrawer->Scale(),
339 // myTextScale*aDrawer->Scale(), Standard_False );
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 );
346 if ( theTxtAngle >= 0 && theTxtAngle <= M_PI/2 )
347 pntText = thePnt2.Translated( (myArrowLen+d1)*theVec/(thePnt1.Distance(thePnt2)) );
348 else if ( theTxtAngle > M_PI/2 && theTxtAngle <= M_PI ) {
349 pntText = thePnt1.Translated( (myArrowLen+d1)*theVec.Reversed()/(thePnt1.Distance(thePnt2)) );
350 theTxtAngle = VX.Angle( theVec.Reversed() );
351 } else if ( theTxtAngle >= -M_PI/2 && theTxtAngle < 0 )
352 pntText = thePnt2.Translated( (myArrowLen+d1)*theVec/(thePnt1.Distance(thePnt2)) );
353 else if ( theTxtAngle >= -M_PI && theTxtAngle < -M_PI/2 ) {
354 pntText = thePnt1.Translated( (myArrowLen+d1)*theVec.Reversed()/(thePnt1.Distance(thePnt2)) );
355 theTxtAngle = VX.Angle( theVec.Reversed() );
357 Standard_Real theTxtX, theTxtY;
358 pntText.Coord( theTxtX, theTxtY );
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 );
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 );
372 if ( myGOPtr->IsTransformed () ) {
373 gp_GTrsf2d aTrsf = myGOPtr->Transform ();
374 Standard_Real a1, b1, c1, ad1;
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 );
384 } else if ( anIndex == 2 ) {
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 );
393 } else if ( anIndex == 4 ) {
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 );
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);
415 if ( anIndex == 1 || anIndex == 2 )
416 if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) {
417 aDrawer->MapPolygonFromTo( Xpoint, Ypoint );
419 aDrawer->MapPolylineFromTo( Xpoint, Ypoint );
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 );
426 } // end if IsIn is true
430 void Prs2d_Radius::DrawVertex( const Handle(Graphic2d_Drawer)& aDrawer,
431 const Standard_Integer anIndex ) {
433 Standard_Boolean IsIn = Standard_False;
435 if ( ! myGOPtr->IsTransformed() )
436 IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY );
438 Standard_ShortReal minx, miny, maxx, maxy;
439 MinMax( minx, maxx, miny, maxy );
440 IsIn = aDrawer->IsIn( minx, maxx, miny, maxy );
443 if ( anIndex == 1 || anIndex == 2 ) {
444 Standard_ShortReal X=0., Y=0.;
445 if ( anIndex == 1 ) {
447 } else if ( anIndex == 2 ) {
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 );
458 aDrawer->MapMarkerFromTo(VERTEXMARKER,X,Y, DEFAULTMARKERSIZE,DEFAULTMARKERSIZE,0.0);
463 Standard_Boolean Prs2d_Radius::Pick( const Standard_ShortReal X,
464 const Standard_ShortReal Y,
465 const Standard_ShortReal aPrecision,
466 const Handle(Graphic2d_Drawer)& aDrawer ) {
468 Standard_ShortReal SRX = X, SRY = Y;
469 Standard_Boolean Result = Standard_False;
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);
480 if ( Graphic2d_Primitive::IsOn( SRX, SRY, myX1, myY1, aPrecision ) ) {
482 return Standard_True;
483 } else if ( Graphic2d_Primitive::IsOn( SRX, SRY, myX2, myY2, aPrecision ) ) {
485 return Standard_True;
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 ) ) {
492 return Standard_True;
495 if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED )
496 if ( IsIn( SRX, SRY, myXVert1, myYVert1, aPrecision ) ) {
498 return Standard_True;
500 } // end if myArrow == FIRSTAR or BOTHAR
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 ) ) {
506 return Standard_True;
509 if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED )
510 if ( IsIn( SRX, SRY, myXVert2, myYVert2, aPrecision ) ) {
512 return Standard_True;
514 } // end if myArrow == LASTAR or BOTHAR
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;
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.;
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 );
530 if ( theTxtAngle >= 0 && theTxtAngle <= M_PI/2 )
531 pntText = thePnt2.Translated( (myArrowLen+d1)*theVec/(thePnt1.Distance(thePnt2)) );
532 else if ( theTxtAngle > M_PI/2 && theTxtAngle <= M_PI ) {
533 pntText = thePnt1.Translated( (myArrowLen+d1)*theVec.Reversed()/(thePnt1.Distance(thePnt2)) );
534 theTxtAngle = VX.Angle( theVec.Reversed() );
535 } else if ( theTxtAngle >= -M_PI/2 && theTxtAngle < 0 )
536 pntText = thePnt2.Translated( (myArrowLen+d1)*theVec/(thePnt1.Distance(thePnt2)) );
537 else if ( theTxtAngle >= -M_PI && theTxtAngle < -M_PI/2 ) {
538 pntText = thePnt1.Translated( (myArrowLen+d1)*theVec.Reversed()/(thePnt1.Distance(thePnt2)) );
539 theTxtAngle = VX.Angle( theVec.Reversed() );
541 Standard_Real theTxtX, theTxtY;
542 pntText.Coord( theTxtX, theTxtY );
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));
551 Result = (x >= -aPrecision + xoffset)
552 && (x <= width + xoffset + aPrecision)
553 && (y >= -yoffset - aPrecision)
554 && (y <= height - yoffset + aPrecision);
558 return Standard_True;
561 if ( IsOn( SRX, SRY, myX1, myY1, myX2, myY2, aPrecision ) ) {
563 return Standard_True;
566 }// end if IsInMinMax is true
568 return Standard_False;
572 void Prs2d_Radius::Save(Aspect_FStream& aFStream) const