summaryrefslogtreecommitdiff
path: root/src/IGESGraph/IGESGraph_ToolTextDisplayTemplate.cxx
blob: 092dd67c689e43dcbca1c78628f8f6325a3a1b94 (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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
//--------------------------------------------------------------------
//
//  File Name : IGESGraph_TextDisplayTemplate.cxx
//  Date      :
//  Author    : CKY / Contract Toubro-Larsen
//  Copyright : MATRA-DATAVISION 1993
//
//--------------------------------------------------------------------

#include <IGESGraph_ToolTextDisplayTemplate.ixx>
#include <IGESData_ParamCursor.hxx>
#include <gp_XYZ.hxx>
#include <gp_Pnt.hxx>
#include <gp_GTrsf.hxx>
#include <IGESGraph_TextFontDef.hxx>
#include <IGESData_Dump.hxx>
#include <Interface_Macros.hxx>


IGESGraph_ToolTextDisplayTemplate::IGESGraph_ToolTextDisplayTemplate ()    {  }


void IGESGraph_ToolTextDisplayTemplate::ReadOwnParams
  (const Handle(IGESGraph_TextDisplayTemplate)& ent,
   const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
{ 
  //Standard_Boolean              st; //szv#4:S4163:12Mar99 not needed

  Standard_Real                 boxWidth; 
  Standard_Real                 boxHeight; 
  Standard_Integer              fontCode; 
  Handle(IGESGraph_TextFontDef) fontEnt;
  Standard_Real                 slantAngle; 
  Standard_Real                 rotationAngle; 
  Standard_Integer              mirrorFlag; 
  Standard_Integer              rotateFlag; 
  gp_XYZ                        corner;

  // Reading boxWidth(Real)
  PR.ReadReal(PR.Current(), "Character box width", boxWidth); //szv#4:S4163:12Mar99 `st=` not needed

  // Reading boxHeight(Real)
  PR.ReadReal(PR.Current(), "Character box height", boxHeight); //szv#4:S4163:12Mar99 `st=` not needed

  Standard_Integer curnum = PR.CurrentNumber();
  if (PR.DefinedElseSkip())
    {
      // Reading fontCode(Integer, must be positive)
      PR.ReadInteger (PR.Current(), "Font Code", fontCode); //szv#4:S4163:12Mar99 `st=` not needed
      // Reading fontEnt(TextFontDef) ?
      if (fontCode < 0) {
	fontEnt = GetCasted(IGESGraph_TextFontDef,PR.ParamEntity (IR,curnum));
	if (fontEnt.IsNull()) PR.AddFail("Font Entity : incorrect reference");
      }
    }
  else
    fontCode = 1; // Default Value

  if (PR.DefinedElseSkip())
    // Reading slantAngle(Real)
    PR.ReadReal (PR.Current(), "Slant Angle", slantAngle); //szv#4:S4163:12Mar99 `st=` not needed
  else
    slantAngle = PI/2.0; // Default Value

  // Reading rotationAngle(Real)
  PR.ReadReal (PR.Current(), "Rotation Angle", rotationAngle); //szv#4:S4163:12Mar99 `st=` not needed

  // Reading mirrorFlag(Integer)
  PR.ReadInteger (PR.Current(), "Mirror Flag", mirrorFlag); //szv#4:S4163:12Mar99 `st=` not needed

  // Reading rotateFlag(Integer)
  PR.ReadInteger (PR.Current(), "Rotate Flag", rotateFlag); //szv#4:S4163:12Mar99 `st=` not needed

  // Reading corner(XYZ)
  PR.ReadXYZ( PR.CurrentList(1, 3), "Lower left coordinates/Increments", corner); //szv#4:S4163:12Mar99 `st=` not needed

  DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
  ent->Init
    (boxWidth, boxHeight, fontCode, fontEnt,
     slantAngle, rotationAngle, mirrorFlag, rotateFlag, corner);
}

void IGESGraph_ToolTextDisplayTemplate::WriteOwnParams
  (const Handle(IGESGraph_TextDisplayTemplate)& ent, IGESData_IGESWriter& IW)  const
{ 
  IW.Send( ent->BoxWidth() );
  IW.Send( ent->BoxHeight() );

  if ( ent->IsFontEntity() )
    IW.Send( ent->FontEntity(), Standard_True );  // negative
  else
    IW.Send( ent->FontCode() );

  IW.Send( ent->SlantAngle() );
  IW.Send( ent->RotationAngle() );
  IW.Send( ent->MirrorFlag() );
  IW.Send( ent->RotateFlag() );
  IW.Send( ent->StartingCorner().X() );
  IW.Send( ent->StartingCorner().Y() );
  IW.Send( ent->StartingCorner().Z() );
}

void  IGESGraph_ToolTextDisplayTemplate::OwnShared
  (const Handle(IGESGraph_TextDisplayTemplate)& ent, Interface_EntityIterator& iter) const
{
  if ( ent->IsFontEntity() )
    iter.GetOneItem( ent->FontEntity() );
}

void IGESGraph_ToolTextDisplayTemplate::OwnCopy
  (const Handle(IGESGraph_TextDisplayTemplate)& another,
   const Handle(IGESGraph_TextDisplayTemplate)& ent, Interface_CopyTool& TC) const
{ 
  Standard_Real                 boxWidth; 
  Standard_Real                 boxHeight; 
  Standard_Integer              fontCode=0; 
  Handle(IGESGraph_TextFontDef) fontEntity;
  Standard_Real                 slantAngle; 
  Standard_Real                 rotationAngle; 
  Standard_Integer              mirrorFlag; 
  Standard_Integer              rotateFlag; 
  gp_XYZ                        corner;

  boxWidth  = another->BoxWidth(); 
  boxHeight = another->BoxHeight(); 

  if ( another->IsFontEntity() )
    fontEntity = 
      Handle(IGESGraph_TextFontDef)::DownCast (TC.Transferred(another->FontEntity()));
  else
    fontCode = another->FontCode();

  slantAngle    = another->SlantAngle(); 
  rotationAngle = another->RotationAngle(); 
  mirrorFlag    = another->MirrorFlag(); 
  rotateFlag    = another->RotateFlag(); 
  corner        = another->StartingCorner().XYZ();

  ent->Init(boxWidth, boxHeight, fontCode, fontEntity,
	    slantAngle, rotationAngle, mirrorFlag, rotateFlag, corner);
}

IGESData_DirChecker IGESGraph_ToolTextDisplayTemplate::DirChecker
  (const Handle(IGESGraph_TextDisplayTemplate)& /*ent*/)  const
{ 
  IGESData_DirChecker DC (312, 0, 1);
  DC.Structure(IGESData_DefVoid);
  DC.LineFont(IGESData_DefVoid);
  DC.LineWeight(IGESData_DefVoid);
  DC.Color(IGESData_DefAny);
  DC.SubordinateStatusRequired(0);
  DC.UseFlagRequired(2);
  DC.HierarchyStatusRequired(0);
  return DC;
}

void IGESGraph_ToolTextDisplayTemplate::OwnCheck
  (const Handle(IGESGraph_TextDisplayTemplate)& /*ent*/,
   const Interface_ShareTool& , Handle(Interface_Check)& /*ach*/)  const
{
}

void IGESGraph_ToolTextDisplayTemplate::OwnDump
  (const Handle(IGESGraph_TextDisplayTemplate)& ent, const IGESData_IGESDumper& dumper,
   const Handle(Message_Messenger)& S, const Standard_Integer level)  const
{
  Standard_Integer sublevel = (level <= 4) ? 0 : 1;

  S << "IGESGraph_TextDisplayTemplate" << endl;

  S << "Character box width  : "  << ent->BoxWidth() << "  ";
  S << "Character box height : "  << ent->BoxHeight() << endl;
  if ( ent->IsFontEntity() )
    {
      S << "Font Entity : ";
      dumper.Dump(ent->FontEntity(),S, sublevel);
    }
  else
    S << "Font code : " << ent->FontCode();
  S << endl;
  S << "Slant angle    : "  << ent->SlantAngle() << "  ";
  S << "Rotation angle : "  << ent->RotationAngle() << endl;
  S << "Mirror flag    : "  << ent->MirrorFlag() << "  ";
  S << "Rotate flag    : "  << ent->RotateFlag() << endl;
  if ( ent->FormNumber() == 0 )
    S << "Lower Left Corner coordinates : ";
  else
    S << "Increments from coordinates : "; 
  IGESData_DumpXYZL(S,level, ent->StartingCorner(), ent->Location());
  S << endl;
}