1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 //--------------------------------------------------------------------
17 //--------------------------------------------------------------------
19 #include <gp_GTrsf.hxx>
22 #include <IGESData_DirChecker.hxx>
23 #include <IGESData_Dump.hxx>
24 #include <IGESData_IGESDumper.hxx>
25 #include <IGESData_IGESReaderData.hxx>
26 #include <IGESData_IGESWriter.hxx>
27 #include <IGESData_ParamCursor.hxx>
28 #include <IGESData_ParamReader.hxx>
29 #include <IGESGraph_TextDisplayTemplate.hxx>
30 #include <IGESGraph_TextFontDef.hxx>
31 #include <IGESGraph_ToolTextDisplayTemplate.hxx>
32 #include <Interface_Check.hxx>
33 #include <Interface_CopyTool.hxx>
34 #include <Interface_EntityIterator.hxx>
35 #include <Interface_Macros.hxx>
36 #include <Interface_ShareTool.hxx>
37 #include <Message_Messenger.hxx>
38 #include <Standard_DomainError.hxx>
40 IGESGraph_ToolTextDisplayTemplate::IGESGraph_ToolTextDisplayTemplate () { }
43 void IGESGraph_ToolTextDisplayTemplate::ReadOwnParams
44 (const Handle(IGESGraph_TextDisplayTemplate)& ent,
45 const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
47 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
49 Standard_Real boxWidth;
50 Standard_Real boxHeight;
51 Standard_Integer fontCode;
52 Handle(IGESGraph_TextFontDef) fontEnt;
53 Standard_Real slantAngle;
54 Standard_Real rotationAngle;
55 Standard_Integer mirrorFlag;
56 Standard_Integer rotateFlag;
59 // Reading boxWidth(Real)
60 PR.ReadReal(PR.Current(), "Character box width", boxWidth); //szv#4:S4163:12Mar99 `st=` not needed
62 // Reading boxHeight(Real)
63 PR.ReadReal(PR.Current(), "Character box height", boxHeight); //szv#4:S4163:12Mar99 `st=` not needed
65 Standard_Integer curnum = PR.CurrentNumber();
66 if (PR.DefinedElseSkip())
68 // Reading fontCode(Integer, must be positive)
69 PR.ReadInteger (PR.Current(), "Font Code", fontCode); //szv#4:S4163:12Mar99 `st=` not needed
70 // Reading fontEnt(TextFontDef) ?
72 fontEnt = GetCasted(IGESGraph_TextFontDef,PR.ParamEntity (IR,curnum));
73 if (fontEnt.IsNull()) PR.AddFail("Font Entity : incorrect reference");
77 fontCode = 1; // Default Value
79 if (PR.DefinedElseSkip())
80 // Reading slantAngle(Real)
81 PR.ReadReal (PR.Current(), "Slant Angle", slantAngle); //szv#4:S4163:12Mar99 `st=` not needed
83 slantAngle = M_PI/2.0; // Default Value
85 // Reading rotationAngle(Real)
86 PR.ReadReal (PR.Current(), "Rotation Angle", rotationAngle); //szv#4:S4163:12Mar99 `st=` not needed
88 // Reading mirrorFlag(Integer)
89 PR.ReadInteger (PR.Current(), "Mirror Flag", mirrorFlag); //szv#4:S4163:12Mar99 `st=` not needed
91 // Reading rotateFlag(Integer)
92 PR.ReadInteger (PR.Current(), "Rotate Flag", rotateFlag); //szv#4:S4163:12Mar99 `st=` not needed
94 // Reading corner(XYZ)
95 PR.ReadXYZ( PR.CurrentList(1, 3), "Lower left coordinates/Increments", corner); //szv#4:S4163:12Mar99 `st=` not needed
97 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
99 (boxWidth, boxHeight, fontCode, fontEnt,
100 slantAngle, rotationAngle, mirrorFlag, rotateFlag, corner);
103 void IGESGraph_ToolTextDisplayTemplate::WriteOwnParams
104 (const Handle(IGESGraph_TextDisplayTemplate)& ent, IGESData_IGESWriter& IW) const
106 IW.Send( ent->BoxWidth() );
107 IW.Send( ent->BoxHeight() );
109 if ( ent->IsFontEntity() )
110 IW.Send( ent->FontEntity(), Standard_True ); // negative
112 IW.Send( ent->FontCode() );
114 IW.Send( ent->SlantAngle() );
115 IW.Send( ent->RotationAngle() );
116 IW.Send( ent->MirrorFlag() );
117 IW.Send( ent->RotateFlag() );
118 IW.Send( ent->StartingCorner().X() );
119 IW.Send( ent->StartingCorner().Y() );
120 IW.Send( ent->StartingCorner().Z() );
123 void IGESGraph_ToolTextDisplayTemplate::OwnShared
124 (const Handle(IGESGraph_TextDisplayTemplate)& ent, Interface_EntityIterator& iter) const
126 if ( ent->IsFontEntity() )
127 iter.GetOneItem( ent->FontEntity() );
130 void IGESGraph_ToolTextDisplayTemplate::OwnCopy
131 (const Handle(IGESGraph_TextDisplayTemplate)& another,
132 const Handle(IGESGraph_TextDisplayTemplate)& ent, Interface_CopyTool& TC) const
134 Standard_Real boxWidth;
135 Standard_Real boxHeight;
136 Standard_Integer fontCode=0;
137 Handle(IGESGraph_TextFontDef) fontEntity;
138 Standard_Real slantAngle;
139 Standard_Real rotationAngle;
140 Standard_Integer mirrorFlag;
141 Standard_Integer rotateFlag;
144 boxWidth = another->BoxWidth();
145 boxHeight = another->BoxHeight();
147 if ( another->IsFontEntity() )
149 Handle(IGESGraph_TextFontDef)::DownCast (TC.Transferred(another->FontEntity()));
151 fontCode = another->FontCode();
153 slantAngle = another->SlantAngle();
154 rotationAngle = another->RotationAngle();
155 mirrorFlag = another->MirrorFlag();
156 rotateFlag = another->RotateFlag();
157 corner = another->StartingCorner().XYZ();
159 ent->Init(boxWidth, boxHeight, fontCode, fontEntity,
160 slantAngle, rotationAngle, mirrorFlag, rotateFlag, corner);
163 IGESData_DirChecker IGESGraph_ToolTextDisplayTemplate::DirChecker
164 (const Handle(IGESGraph_TextDisplayTemplate)& /*ent*/) const
166 IGESData_DirChecker DC (312, 0, 1);
167 DC.Structure(IGESData_DefVoid);
168 DC.LineFont(IGESData_DefVoid);
169 DC.LineWeight(IGESData_DefVoid);
170 DC.Color(IGESData_DefAny);
171 DC.SubordinateStatusRequired(0);
172 DC.UseFlagRequired(2);
173 DC.HierarchyStatusRequired(0);
177 void IGESGraph_ToolTextDisplayTemplate::OwnCheck
178 (const Handle(IGESGraph_TextDisplayTemplate)& /*ent*/,
179 const Interface_ShareTool& , Handle(Interface_Check)& /*ach*/) const
183 void IGESGraph_ToolTextDisplayTemplate::OwnDump
184 (const Handle(IGESGraph_TextDisplayTemplate)& ent, const IGESData_IGESDumper& dumper,
185 Standard_OStream& S, const Standard_Integer level) const
187 Standard_Integer sublevel = (level <= 4) ? 0 : 1;
189 S << "IGESGraph_TextDisplayTemplate\n"
190 << "Character box width : " << ent->BoxWidth() << " "
191 << "Character box height : " << ent->BoxHeight() << "\n";
192 if ( ent->IsFontEntity() )
194 S << "Font Entity : ";
195 dumper.Dump(ent->FontEntity(),S, sublevel);
198 S << "Font code : " << ent->FontCode();
201 << "Slant angle : " << ent->SlantAngle() << " "
202 << "Rotation angle : " << ent->RotationAngle() << "\n"
203 << "Mirror flag : " << ent->MirrorFlag() << " "
204 << "Rotate flag : " << ent->RotateFlag() << "\n";
205 if ( ent->FormNumber() == 0 )
206 S << "Lower Left Corner coordinates : ";
208 S << "Increments from coordinates : ";
209 IGESData_DumpXYZL(S,level, ent->StartingCorner(), ent->Location());