0023510: Integration of test grid "vis" into the new testing system
[occt.git] / src / Prs2d / Prs2d_Cylindric.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_Cylindric.ixx>
19
20Prs2d_Cylindric::Prs2d_Cylindric( 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_Cylindric::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 );
44
45 Standard_ShortReal X1 = Standard_ShortReal( myX - myLength/2 ),
46 Y1 = Standard_ShortReal( myY - myLength/2 ),
47 X4 = Standard_ShortReal( myX + myLength/2 ),
48 Y4 = Y1,
49 X2 = Standard_ShortReal( X1 + myLength/2 ),
50 Y2 = Standard_ShortReal( myY + myLength/2 ),
51
52 X3 = Standard_ShortReal( X4 + myLength/2 ),
53 Y3 = Y2;
54 gp_Pnt2d thePnt1( X1, Y1);
55 gp_Vec2d theVec( thePnt1, gp_Pnt2d( X3, Y3 ) );
56 theVec /= 2;
57 thePnt1.Translate( theVec );
c6541a0c 58 Standard_ShortReal theRad = Standard_ShortReal( myLength/2*Sin(M_PI / 3) );
7fd59977 59 Standard_ShortReal Xc = Standard_ShortReal(thePnt1.X()),
60 Yc = Standard_ShortReal(thePnt1.Y());
61
62 gp_Pnt2d P1( X1, Y1 ),
63 P2( X2, Y2 ),
64 P3( X3, Y3 ),
65 P4( X4, Y4 ),
66 PC( Xc, Yc ),
67 PR( myX, myY );
68 P1.Rotate( PR, myAngle );
69 P2.Rotate( PR, myAngle );
70 P3.Rotate( PR, myAngle );
71 P4.Rotate( PR, myAngle );
72 PC.Rotate( PR, myAngle );
73 X1 = Standard_ShortReal( P1.X() );
74 Y1 = Standard_ShortReal( P1.Y() );
75 X2 = Standard_ShortReal( P2.X() );
76 Y2 = Standard_ShortReal( P2.Y() );
77 X3 = Standard_ShortReal( P3.X() );
78 Y3 = Standard_ShortReal( P3.Y() );
79 X4 = Standard_ShortReal( P4.X() );
80 Y4 = Standard_ShortReal( P4.Y() );
81 Xc = Standard_ShortReal( PC.X() );
82 Yc = Standard_ShortReal( PC.Y() );
83 if ( myGOPtr->IsTransformed () ) {
84 gp_GTrsf2d aTrsf = myGOPtr->Transform ();
85 Standard_Real a1, b1;
86 a1 = X1;
87 b1 = Y1;
88 aTrsf.Transforms( a1, b1 );
89 X1 = Standard_ShortReal( a1 );
90 Y1 = Standard_ShortReal( b1 );
91 a1 = X2;
92 b1 = Y2;
93 aTrsf.Transforms( a1, b1 );
94 X2 = Standard_ShortReal( a1 );
95 Y2 = Standard_ShortReal( b1 );
96 a1 = X3;
97 b1 = Y3;
98 aTrsf.Transforms( a1, b1 );
99 X3 = Standard_ShortReal( a1 );
100 Y3 = Standard_ShortReal( b1 );
101 a1 = X4;
102 b1 = Y4;
103 aTrsf.Transforms( a1, b1 );
104 X4 = Standard_ShortReal( a1 );
105 Y4 = Standard_ShortReal( b1 );
106 a1 = Xc;
107 b1 = Yc;
108 aTrsf.Transforms( a1, b1 );
109 Xc = Standard_ShortReal( a1 );
110 Yc = Standard_ShortReal( b1 );
111 }
112 aDrawer->MapSegmentFromTo( X1, Y1, X2, Y2 );
113 aDrawer->MapSegmentFromTo( X4, Y4, X3, Y3 );
c6541a0c 114 aDrawer->MapArcFromTo( Xc, Yc, theRad, 0.0, Standard_ShortReal( 2. * M_PI ) );
7fd59977 115 }
116}
117
118void Prs2d_Cylindric::Save(Aspect_FStream& aFStream) const
119{
120}