0023510: Integration of test grid "vis" into the new testing system
[occt.git] / src / Prs2d / Prs2d_SymCircular.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_SymCircular.ixx>
19
20Prs2d_SymCircular::Prs2d_SymCircular( const Handle(Graphic2d_GraphicObject)& aGO,
21 const Standard_Real aX,
22 const Standard_Real aY,
23 const Standard_Real aLength,
24 const Standard_Real anAngle )
25
26 : Prs2d_Tolerance( aGO, aX, aY, aLength, anAngle )
27{
28}
29
30void Prs2d_SymCircular::Draw( const Handle(Graphic2d_Drawer)& aDrawer ) {
31
32 Standard_Boolean IsIn = Standard_False;
33
34 if ( !myGOPtr->IsTransformed() )
35 IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY );
36 else {
37 Standard_ShortReal minx, miny, maxx, maxy;
38 MinMax( minx, maxx, miny, maxy );
39 IsIn = aDrawer->IsIn( minx, maxx, miny, maxy );
40 }
41
42 if ( IsIn ) {
43 DrawLineAttrib( aDrawer );
c6541a0c 44 const Standard_Real alpha = M_PI / 12;
7fd59977 45
46 Standard_ShortReal X1 = myX - myLength/2,
47 Y1 = myY - myLength/2,
c6541a0c 48 X2 = Standard_ShortReal(X1 + myLength * Cos( M_PI / 4 ) ),
7fd59977 49 Y2 = myY + myLength/2;
50
51
52 gp_Pnt2d P1( X2, Y2 );
53 gp_Vec2d V1( P1, gp_Pnt2d(X1, Y1) );
54 gp_Vec2d V2 = V1.Rotated( alpha );
55 gp_Vec2d V3 = V1.Rotated( -alpha );
56 V2 /= 2;
57 V3 /= 2;
58 gp_Pnt2d P2 = P1.Translated( V2 ),
59 P3 = P1.Translated( V3 );
60
61 Standard_ShortReal X3 = Standard_ShortReal( P2.X() ),
62 Y3 = Standard_ShortReal( P2.Y() ),
63 X4 = Standard_ShortReal( P3.X() ),
64 Y4 = Standard_ShortReal( P3.Y() );
65
66 gp_Pnt2d PP1( X1, Y1 ),
67 PP2( X2, Y2 ),
68 PP3( X3, Y3 ),
69 PP4( X4, Y4 ),
70 PPR( myX, myY );
71 PP1.Rotate( PPR, myAngle );
72 PP2.Rotate( PPR, myAngle );
73 PP3.Rotate( PPR, myAngle );
74 PP4.Rotate( PPR, myAngle );
75
76 X1 = Standard_ShortReal( PP1.X() );
77 Y1 = Standard_ShortReal( PP1.Y() );
78 X2 = Standard_ShortReal( PP2.X() );
79 Y2 = Standard_ShortReal( PP2.Y() );
80 X3 = Standard_ShortReal( PP3.X() );
81 Y3 = Standard_ShortReal( PP3.Y() );
82 X4 = Standard_ShortReal( PP4.X() );
83 Y4 = Standard_ShortReal( PP4.Y() );
84
85 if ( myGOPtr->IsTransformed () ) {
86 gp_GTrsf2d aTrsf = myGOPtr->Transform ();
87 Standard_Real a1, b1;
88 a1 = X1;
89 b1 = Y1;
90 aTrsf.Transforms( a1, b1 );
91 X1 = Standard_ShortReal( a1 );
92 Y1 = Standard_ShortReal( b1 );
93 a1 = X2;
94 b1 = Y2;
95 aTrsf.Transforms( a1, b1 );
96 X2 = Standard_ShortReal( a1 );
97 Y2 = Standard_ShortReal( b1 );
98 a1 = X3;
99 b1 = Y3;
100 aTrsf.Transforms( a1, b1 );
101 X3 = Standard_ShortReal( a1 );
102 Y3 = Standard_ShortReal( b1 );
103 a1 = X4;
104 b1 = Y4;
105 aTrsf.Transforms( a1, b1 );
106 X4 = Standard_ShortReal( a1 );
107 Y4 = Standard_ShortReal( b1 );
108 }
109 aDrawer->MapSegmentFromTo( X1, Y1, X2, Y2 );
110 aDrawer->MapSegmentFromTo( X2, Y2, X3, Y3 );
111 aDrawer->MapSegmentFromTo( X2, Y2, X4, Y4 );
112 aDrawer->MapSegmentFromTo( X4, Y4, X3, Y3 );
113 }
114
115}
116
117void Prs2d_SymCircular::Save(Aspect_FStream& aFStream) const
118{
119}