0023510: Integration of test grid "vis" into the new testing system
[occt.git] / src / Prs2d / Prs2d_Angularity.cxx
... / ...
CommitLineData
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
18#include <Prs2d_Angularity.ixx>
19
20Prs2d_Angularity::Prs2d_Angularity( 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}
30
31void Prs2d_Angularity::Draw( const Handle(Graphic2d_Drawer)& aDrawer ) {
32
33 Standard_Boolean IsIn = Standard_False;
34
35 if ( !myGOPtr->IsTransformed() )
36 IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY );
37 else {
38 Standard_ShortReal minx, miny, maxx, maxy;
39 MinMax( minx, maxx, miny, maxy );
40 IsIn = aDrawer->IsIn( minx, maxx, miny, maxy );
41 }
42
43 if ( IsIn ) {
44
45 DrawLineAttrib( aDrawer );
46 Standard_ShortReal X1 = Standard_ShortReal( myX - myLength/2 ),
47 Y1 = Standard_ShortReal( myY - myLength/2 ),
48 X2 = Standard_ShortReal( myX + myLength/2 ),
49 Y2 = Y1,
50 X3 = Standard_ShortReal( X1 + myLength * Cos( M_PI / 4 ) ),
51 Y3 = Standard_ShortReal( myY + myLength/2 );
52
53 gp_Pnt2d P1( X1, Y1 ),
54 P2( X2, Y2 ),
55 P3( X3, Y3 ),
56 PR( myX, myY );
57 P1.Rotate( PR, myAngle );
58 P2.Rotate( PR, myAngle );
59 P3.Rotate( PR, myAngle );
60
61 X1 = Standard_ShortReal( P1.X() );
62 Y1 = Standard_ShortReal( P1.Y() );
63 X2 = Standard_ShortReal( P2.X() );
64 Y2 = Standard_ShortReal( P2.Y() );
65 X3 = Standard_ShortReal( P3.X() );
66 Y3 = Standard_ShortReal( P3.Y() );
67
68 if ( myGOPtr->IsTransformed () ) {
69 gp_GTrsf2d aTrsf = myGOPtr->Transform ();
70 Standard_Real a1, b1;
71 a1 = X1;
72 b1 = Y1;
73 aTrsf.Transforms( a1, b1 );
74 X1 = Standard_ShortReal( a1 );
75 Y1 = Standard_ShortReal( b1 );
76 a1 = X2;
77 b1 = Y2;
78 aTrsf.Transforms( a1, b1 );
79 X2 = Standard_ShortReal( a1 );
80 Y2 = Standard_ShortReal( b1 );
81 a1 = X3;
82 b1 = Y3;
83 aTrsf.Transforms( a1, b1 );
84 X3 = Standard_ShortReal( a1 );
85 Y3 = Standard_ShortReal( b1 );
86 }
87 aDrawer->MapSegmentFromTo( X1, Y1, X2, Y2 );
88 aDrawer->MapSegmentFromTo( X1, Y1, X3, Y3 );
89 }
90}
91
92void Prs2d_Angularity::Save(Aspect_FStream& aFStream) const
93{
94}