summaryrefslogtreecommitdiff
path: root/src/IGESDimen/IGESDimen_FlagNote.cxx
blob: b4d849fbcb13f341f2f92ddaccf3b58702f0d31b (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//--------------------------------------------------------------------
//
//  File Name : IGESDimen_FlagNote.cxx
//  Date      :
//  Author    : CKY / Contract Toubro-Larsen
//  Copyright : MATRA-DATAVISION 1993
//
//--------------------------------------------------------------------

#include <IGESDimen_FlagNote.ixx>
#include <Standard_DimensionMismatch.hxx>
#include <gp_GTrsf.hxx>


    IGESDimen_FlagNote::IGESDimen_FlagNote ()    {  }

    void  IGESDimen_FlagNote::Init
  (const gp_XYZ& leftCorner, const Standard_Real anAngle,
   const Handle(IGESDimen_GeneralNote)& aNote,
   const Handle(IGESDimen_HArray1OfLeaderArrow)& someLeaders)
{
  if (!someLeaders.IsNull())
    if (someLeaders->Lower() != 1)
      Standard_DimensionMismatch::Raise("IGESDimen_FlagNote : Init");
  theLowerLeftcorner = leftCorner;
  theAngle           = anAngle;
  theNote            = aNote;
  theLeaders         = someLeaders;
  InitTypeAndForm(208,0);
}

    gp_Pnt  IGESDimen_FlagNote::LowerLeftCorner () const 
{
  gp_Pnt lowerleft(theLowerLeftcorner);
  return lowerleft;
}

    gp_Pnt  IGESDimen_FlagNote::TransformedLowerLeftCorner () const 
{
  gp_XYZ tempXYZ = theLowerLeftcorner;
  if (HasTransf()) Location().Transforms(tempXYZ);
  return gp_Pnt(tempXYZ);
}

    Standard_Real  IGESDimen_FlagNote::Angle () const 
{
  return theAngle;
}

    Handle(IGESDimen_GeneralNote)  IGESDimen_FlagNote::Note () const 
{
  return theNote;
}

    Standard_Integer  IGESDimen_FlagNote::NbLeaders () const 
{
  return (theLeaders.IsNull() ? 0 : theLeaders->Length() );
}

    Handle(IGESDimen_LeaderArrow)  IGESDimen_FlagNote::Leader
  (const Standard_Integer Index) const 
{
  return theLeaders->Value(Index);
}

    Standard_Real  IGESDimen_FlagNote::Height () const 
{
  return (2 * CharacterHeight());
}

    Standard_Real  IGESDimen_FlagNote::CharacterHeight () const 
{
  Standard_Real Max = theNote->BoxHeight(1);
  for(Standard_Integer i = 2; i <= theNote->NbStrings(); i++)
    {
      if (Max < theNote->BoxHeight(i))
	Max = theNote->BoxHeight(i);
    }
  return (Max);
}

    Standard_Real  IGESDimen_FlagNote::Length () const 
{
  return (TextWidth() + (0.4 * CharacterHeight()));
}

    Standard_Real  IGESDimen_FlagNote::TextWidth () const 
{
  Standard_Real width = 0;
  for(Standard_Integer i = 1; i <= theNote->NbStrings(); i++)
    width += theNote->BoxWidth(i);
  return (width);
}

    Standard_Real  IGESDimen_FlagNote::TipLength () const 
{
  return (0.5 * (Height()/Tan((35./180.)*PI)));
}