7fd59977 |
1 | #include <Prs2d_Cylindric.ixx> |
2 | |
3 | Prs2d_Cylindric::Prs2d_Cylindric( const Handle(Graphic2d_GraphicObject)& aGO, |
4 | const Standard_Real aX, |
5 | const Standard_Real aY, |
6 | const Standard_Real aLength, |
7 | const Standard_Real anAngle ) |
8 | |
9 | : Prs2d_Tolerance( aGO, aX, aY, aLength, anAngle ) |
10 | { |
11 | } |
12 | |
13 | void Prs2d_Cylindric::Draw( const Handle(Graphic2d_Drawer)& aDrawer ) { |
14 | |
15 | Standard_Boolean IsIn = Standard_False; |
16 | |
17 | if ( !myGOPtr->IsTransformed() ) |
18 | IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY ); |
19 | else { |
20 | Standard_ShortReal minx, miny, maxx, maxy; |
21 | MinMax( minx, maxx, miny, maxy ); |
22 | IsIn = aDrawer->IsIn( minx, maxx, miny, maxy ); |
23 | } |
24 | |
25 | if ( IsIn ) { |
26 | DrawLineAttrib( aDrawer ); |
27 | |
28 | Standard_ShortReal X1 = Standard_ShortReal( myX - myLength/2 ), |
29 | Y1 = Standard_ShortReal( myY - myLength/2 ), |
30 | X4 = Standard_ShortReal( myX + myLength/2 ), |
31 | Y4 = Y1, |
32 | X2 = Standard_ShortReal( X1 + myLength/2 ), |
33 | Y2 = Standard_ShortReal( myY + myLength/2 ), |
34 | |
35 | X3 = Standard_ShortReal( X4 + myLength/2 ), |
36 | Y3 = Y2; |
37 | gp_Pnt2d thePnt1( X1, Y1); |
38 | gp_Vec2d theVec( thePnt1, gp_Pnt2d( X3, Y3 ) ); |
39 | theVec /= 2; |
40 | thePnt1.Translate( theVec ); |
41 | Standard_ShortReal theRad = Standard_ShortReal( myLength/2*Sin(Standard_PI / 3) ); |
42 | Standard_ShortReal Xc = Standard_ShortReal(thePnt1.X()), |
43 | Yc = Standard_ShortReal(thePnt1.Y()); |
44 | |
45 | gp_Pnt2d P1( X1, Y1 ), |
46 | P2( X2, Y2 ), |
47 | P3( X3, Y3 ), |
48 | P4( X4, Y4 ), |
49 | PC( Xc, Yc ), |
50 | PR( myX, myY ); |
51 | P1.Rotate( PR, myAngle ); |
52 | P2.Rotate( PR, myAngle ); |
53 | P3.Rotate( PR, myAngle ); |
54 | P4.Rotate( PR, myAngle ); |
55 | PC.Rotate( PR, myAngle ); |
56 | X1 = Standard_ShortReal( P1.X() ); |
57 | Y1 = Standard_ShortReal( P1.Y() ); |
58 | X2 = Standard_ShortReal( P2.X() ); |
59 | Y2 = Standard_ShortReal( P2.Y() ); |
60 | X3 = Standard_ShortReal( P3.X() ); |
61 | Y3 = Standard_ShortReal( P3.Y() ); |
62 | X4 = Standard_ShortReal( P4.X() ); |
63 | Y4 = Standard_ShortReal( P4.Y() ); |
64 | Xc = Standard_ShortReal( PC.X() ); |
65 | Yc = Standard_ShortReal( PC.Y() ); |
66 | if ( myGOPtr->IsTransformed () ) { |
67 | gp_GTrsf2d aTrsf = myGOPtr->Transform (); |
68 | Standard_Real a1, b1; |
69 | a1 = X1; |
70 | b1 = Y1; |
71 | aTrsf.Transforms( a1, b1 ); |
72 | X1 = Standard_ShortReal( a1 ); |
73 | Y1 = Standard_ShortReal( b1 ); |
74 | a1 = X2; |
75 | b1 = Y2; |
76 | aTrsf.Transforms( a1, b1 ); |
77 | X2 = Standard_ShortReal( a1 ); |
78 | Y2 = Standard_ShortReal( b1 ); |
79 | a1 = X3; |
80 | b1 = Y3; |
81 | aTrsf.Transforms( a1, b1 ); |
82 | X3 = Standard_ShortReal( a1 ); |
83 | Y3 = Standard_ShortReal( b1 ); |
84 | a1 = X4; |
85 | b1 = Y4; |
86 | aTrsf.Transforms( a1, b1 ); |
87 | X4 = Standard_ShortReal( a1 ); |
88 | Y4 = Standard_ShortReal( b1 ); |
89 | a1 = Xc; |
90 | b1 = Yc; |
91 | aTrsf.Transforms( a1, b1 ); |
92 | Xc = Standard_ShortReal( a1 ); |
93 | Yc = Standard_ShortReal( b1 ); |
94 | } |
95 | aDrawer->MapSegmentFromTo( X1, Y1, X2, Y2 ); |
96 | aDrawer->MapSegmentFromTo( X4, Y4, X3, Y3 ); |
97 | aDrawer->MapArcFromTo( Xc, Yc, theRad, 0.0, Standard_ShortReal( 2. * Standard_PI ) ); |
98 | } |
99 | } |
100 | |
101 | void Prs2d_Cylindric::Save(Aspect_FStream& aFStream) const |
102 | { |
103 | } |