b311480e |
1 | // Created by: CKY / Contract Toubro-Larsen |
2 | // Copyright (c) 1993-1999 Matra Datavision |
973c2be1 |
3 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
7fd59977 |
6 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
7fd59977 |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
b311480e |
15 | |
16 | //-------------------------------------------------------------------- |
7fd59977 |
17 | //-------------------------------------------------------------------- |
18 | |
7fd59977 |
19 | #include <gp_GTrsf.hxx> |
42cf5bc1 |
20 | #include <gp_Pnt.hxx> |
21 | #include <gp_XYZ.hxx> |
22 | #include <IGESData_DirChecker.hxx> |
7fd59977 |
23 | #include <IGESData_Dump.hxx> |
42cf5bc1 |
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> |
7fd59977 |
35 | #include <Interface_Macros.hxx> |
42cf5bc1 |
36 | #include <Interface_ShareTool.hxx> |
37 | #include <Message_Messenger.hxx> |
38 | #include <Standard_DomainError.hxx> |
7fd59977 |
39 | |
40 | IGESGraph_ToolTextDisplayTemplate::IGESGraph_ToolTextDisplayTemplate () { } |
41 | |
42 | |
43 | void IGESGraph_ToolTextDisplayTemplate::ReadOwnParams |
44 | (const Handle(IGESGraph_TextDisplayTemplate)& ent, |
45 | const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const |
46 | { |
47 | //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed |
48 | |
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; |
57 | gp_XYZ corner; |
58 | |
59 | // Reading boxWidth(Real) |
60 | PR.ReadReal(PR.Current(), "Character box width", boxWidth); //szv#4:S4163:12Mar99 `st=` not needed |
61 | |
62 | // Reading boxHeight(Real) |
63 | PR.ReadReal(PR.Current(), "Character box height", boxHeight); //szv#4:S4163:12Mar99 `st=` not needed |
64 | |
65 | Standard_Integer curnum = PR.CurrentNumber(); |
66 | if (PR.DefinedElseSkip()) |
67 | { |
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) ? |
71 | if (fontCode < 0) { |
72 | fontEnt = GetCasted(IGESGraph_TextFontDef,PR.ParamEntity (IR,curnum)); |
73 | if (fontEnt.IsNull()) PR.AddFail("Font Entity : incorrect reference"); |
74 | } |
75 | } |
76 | else |
77 | fontCode = 1; // Default Value |
78 | |
79 | if (PR.DefinedElseSkip()) |
80 | // Reading slantAngle(Real) |
81 | PR.ReadReal (PR.Current(), "Slant Angle", slantAngle); //szv#4:S4163:12Mar99 `st=` not needed |
82 | else |
c6541a0c |
83 | slantAngle = M_PI/2.0; // Default Value |
7fd59977 |
84 | |
85 | // Reading rotationAngle(Real) |
86 | PR.ReadReal (PR.Current(), "Rotation Angle", rotationAngle); //szv#4:S4163:12Mar99 `st=` not needed |
87 | |
88 | // Reading mirrorFlag(Integer) |
89 | PR.ReadInteger (PR.Current(), "Mirror Flag", mirrorFlag); //szv#4:S4163:12Mar99 `st=` not needed |
90 | |
91 | // Reading rotateFlag(Integer) |
92 | PR.ReadInteger (PR.Current(), "Rotate Flag", rotateFlag); //szv#4:S4163:12Mar99 `st=` not needed |
93 | |
94 | // Reading corner(XYZ) |
95 | PR.ReadXYZ( PR.CurrentList(1, 3), "Lower left coordinates/Increments", corner); //szv#4:S4163:12Mar99 `st=` not needed |
96 | |
97 | DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent); |
98 | ent->Init |
99 | (boxWidth, boxHeight, fontCode, fontEnt, |
100 | slantAngle, rotationAngle, mirrorFlag, rotateFlag, corner); |
101 | } |
102 | |
103 | void IGESGraph_ToolTextDisplayTemplate::WriteOwnParams |
104 | (const Handle(IGESGraph_TextDisplayTemplate)& ent, IGESData_IGESWriter& IW) const |
105 | { |
106 | IW.Send( ent->BoxWidth() ); |
107 | IW.Send( ent->BoxHeight() ); |
108 | |
109 | if ( ent->IsFontEntity() ) |
110 | IW.Send( ent->FontEntity(), Standard_True ); // negative |
111 | else |
112 | IW.Send( ent->FontCode() ); |
113 | |
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() ); |
121 | } |
122 | |
123 | void IGESGraph_ToolTextDisplayTemplate::OwnShared |
124 | (const Handle(IGESGraph_TextDisplayTemplate)& ent, Interface_EntityIterator& iter) const |
125 | { |
126 | if ( ent->IsFontEntity() ) |
127 | iter.GetOneItem( ent->FontEntity() ); |
128 | } |
129 | |
130 | void IGESGraph_ToolTextDisplayTemplate::OwnCopy |
131 | (const Handle(IGESGraph_TextDisplayTemplate)& another, |
132 | const Handle(IGESGraph_TextDisplayTemplate)& ent, Interface_CopyTool& TC) const |
133 | { |
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; |
142 | gp_XYZ corner; |
143 | |
144 | boxWidth = another->BoxWidth(); |
145 | boxHeight = another->BoxHeight(); |
146 | |
147 | if ( another->IsFontEntity() ) |
148 | fontEntity = |
149 | Handle(IGESGraph_TextFontDef)::DownCast (TC.Transferred(another->FontEntity())); |
150 | else |
151 | fontCode = another->FontCode(); |
152 | |
153 | slantAngle = another->SlantAngle(); |
154 | rotationAngle = another->RotationAngle(); |
155 | mirrorFlag = another->MirrorFlag(); |
156 | rotateFlag = another->RotateFlag(); |
157 | corner = another->StartingCorner().XYZ(); |
158 | |
159 | ent->Init(boxWidth, boxHeight, fontCode, fontEntity, |
160 | slantAngle, rotationAngle, mirrorFlag, rotateFlag, corner); |
161 | } |
162 | |
163 | IGESData_DirChecker IGESGraph_ToolTextDisplayTemplate::DirChecker |
164 | (const Handle(IGESGraph_TextDisplayTemplate)& /*ent*/) const |
165 | { |
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); |
174 | return DC; |
175 | } |
176 | |
177 | void IGESGraph_ToolTextDisplayTemplate::OwnCheck |
178 | (const Handle(IGESGraph_TextDisplayTemplate)& /*ent*/, |
179 | const Interface_ShareTool& , Handle(Interface_Check)& /*ach*/) const |
180 | { |
181 | } |
182 | |
183 | void IGESGraph_ToolTextDisplayTemplate::OwnDump |
184 | (const Handle(IGESGraph_TextDisplayTemplate)& ent, const IGESData_IGESDumper& dumper, |
185 | const Handle(Message_Messenger)& S, const Standard_Integer level) const |
186 | { |
187 | Standard_Integer sublevel = (level <= 4) ? 0 : 1; |
188 | |
04232180 |
189 | S << "IGESGraph_TextDisplayTemplate" << Message_EndLine; |
7fd59977 |
190 | |
191 | S << "Character box width : " << ent->BoxWidth() << " "; |
04232180 |
192 | S << "Character box height : " << ent->BoxHeight() << Message_EndLine; |
7fd59977 |
193 | if ( ent->IsFontEntity() ) |
194 | { |
195 | S << "Font Entity : "; |
196 | dumper.Dump(ent->FontEntity(),S, sublevel); |
197 | } |
198 | else |
199 | S << "Font code : " << ent->FontCode(); |
04232180 |
200 | S << Message_EndLine; |
7fd59977 |
201 | S << "Slant angle : " << ent->SlantAngle() << " "; |
04232180 |
202 | S << "Rotation angle : " << ent->RotationAngle() << Message_EndLine; |
7fd59977 |
203 | S << "Mirror flag : " << ent->MirrorFlag() << " "; |
04232180 |
204 | S << "Rotate flag : " << ent->RotateFlag() << Message_EndLine; |
7fd59977 |
205 | if ( ent->FormNumber() == 0 ) |
206 | S << "Lower Left Corner coordinates : "; |
207 | else |
208 | S << "Increments from coordinates : "; |
209 | IGESData_DumpXYZL(S,level, ent->StartingCorner(), ent->Location()); |
04232180 |
210 | S << Message_EndLine; |
7fd59977 |
211 | } |