summaryrefslogtreecommitdiff
path: root/inc/Prs2d_Length.lxx
blob: 0447f62126e9afdba10465f6c1413548eccc38c0 (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
inline void Prs2d_Length::CalcTxtPos(const Standard_Boolean theFromAbs) {
  
 if (!theFromAbs) 
 { 
   	  
   gp_Pnt2d thePnt1(myX1,myY1), thePnt2(myX2,myY2),theOrigine,theTmp;
   if ( (myX1==myX2 && myY1>myY2 ) || (myX1>myX2) )
   {
     theTmp  = thePnt1;
     thePnt1 = thePnt2;
     thePnt2 = theTmp;
   } 
   gp_Vec2d VX( 1., 0. ), theVecI,theVecJ,theVec(thePnt1,thePnt2),tmpVec;
   Standard_Real coeff=21.5/12;// this coefficient from font symbol size
   Standard_Real theTextLen=myText.Length()*myTextScale*coeff; 
   Standard_Real theDist=thePnt1.Distance(thePnt2);

   theVec.Normalize();
  
   theVecI = theVec*(theDist/2-theTextLen/2+myTextPosH);
   tmpVec  = theVec*(theDist/2+myTextPosH);
   theVecJ = theVec.Rotated(PI/2)*myTextPosV;
   
   theOrigine=thePnt1;
   theOrigine.Translate(tmpVec);
   theOrigine.Translate(theVecJ);
   
   theVec.Rotate(myTextAngle);
   
   thePnt1.Translate(theVecI);
   thePnt1.Translate(theVecJ);
   thePnt1.Rotate(theOrigine, myTextAngle);
   
   Standard_Real theTxtAngle = VX.Angle( theVec );
   gp_Pnt2d pntText=thePnt1;
   
   myAbsAngle=theTxtAngle;
   myAbsX=pntText.X();
   myAbsY=pntText.Y();
 }
}