summaryrefslogtreecommitdiff
path: root/inc/Prs2d_Diameter.lxx
blob: a3a59e01a9d2fa6adf6edd0b822e6133103d0cad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
inline void Prs2d_Diameter::CalcTxtPos(const Standard_Boolean theFromAbs) {

 if (!theFromAbs) { 
  
  gp_Pnt2d thePnt1(myAppX1,myAppY1), thePnt2(myAppX2,myAppY2);

  if (myInside) 
  {
    thePnt1.SetCoord(myX1,myY1);
    thePnt2.SetCoord(myX2,myY2);
  }
    
  gp_Vec2d VX( 1., 0. ), theVecI,theVecJ,theVec(thePnt2,thePnt1);
  Standard_Real theDist=thePnt1.Distance(thePnt2);
  
  theVec.Normalized();
  
  theVecI = theVec.Reversed()*myTextPosH/theDist;
  theVecJ = theVec.Reversed().Rotated(PI/2)*myTextPosV/theDist;
  
  theVec.Rotate(-myTextAngle);
  
  thePnt2.Translate(theVecI);
  thePnt2.Translate(theVecJ);
  thePnt1.Translate(theVecI);
  thePnt1.Translate(theVecJ);
  
  Standard_Real theTxtAngle = VX.Angle( theVec );
  gp_Pnt2d pntText;
  
  
  if ( theTxtAngle >= 0 && theTxtAngle <= PI/2 )
        pntText = thePnt2.Translated(theVec/theDist);
  else if ( theTxtAngle > PI/2 && theTxtAngle <= PI ) {
        pntText = thePnt1.Translated(theVec.Reversed()/theDist) ;
	theTxtAngle = VX.Angle( theVec.Reversed() );
  } else if ( theTxtAngle >= -PI/2 && theTxtAngle < 0 )  
        pntText = thePnt2.Translated(theVec/theDist);
  else if ( theTxtAngle >= -PI && theTxtAngle < -PI/2 ) {
        pntText = thePnt1.Translated(theVec.Reversed()/theDist);
        theTxtAngle = VX.Angle( theVec.Reversed() );
  }
  
  myAbsAngle=theTxtAngle;
  myAbsX=pntText.X();
  myAbsY=pntText.Y();
  

 } 
}