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>
20 #include <gp_Pnt2d.hxx>
22 #include <IGESBasic_HArray1OfHArray1OfInteger.hxx>
23 #include <IGESData_DirChecker.hxx>
24 #include <IGESData_Dump.hxx>
25 #include <IGESData_IGESDumper.hxx>
26 #include <IGESData_IGESReaderData.hxx>
27 #include <IGESData_IGESWriter.hxx>
28 #include <IGESData_ParamReader.hxx>
29 #include <IGESGraph_TextFontDef.hxx>
30 #include <IGESGraph_ToolTextFontDef.hxx>
31 #include <Interface_Check.hxx>
32 #include <Interface_CopyTool.hxx>
33 #include <Interface_EntityIterator.hxx>
34 #include <Interface_ShareTool.hxx>
35 #include <Message_Messenger.hxx>
36 #include <Standard_DomainError.hxx>
37 #include <TColgp_HArray1OfXY.hxx>
38 #include <TCollection_HAsciiString.hxx>
39 #include <TColStd_HArray1OfInteger.hxx>
41 IGESGraph_ToolTextFontDef::IGESGraph_ToolTextFontDef () { }
44 void IGESGraph_ToolTextFontDef::ReadOwnParams
45 (const Handle(IGESGraph_TextFontDef)& ent,
46 const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
48 //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down
49 Standard_Integer nbval;
51 Standard_Integer fontCode;
52 Handle(TCollection_HAsciiString) fontName;
53 Standard_Integer supersededFont;
54 Handle(IGESGraph_TextFontDef) supersededEntity;
55 Standard_Integer scale;
56 Handle(TColStd_HArray1OfInteger) aSCIICodes;
57 Handle(TColStd_HArray1OfInteger) nextCharX, nextCharY;
58 Handle(TColStd_HArray1OfInteger) penMotions;
59 Handle(IGESBasic_HArray1OfHArray1OfInteger) penFlags;
60 Handle(IGESBasic_HArray1OfHArray1OfInteger) movePenX, movePenY;
62 Standard_Integer tempCode, tempNextX,tempNextY;
63 Standard_Integer tempMotion;
64 Standard_Integer tempFlag, tempMoveX,tempMoveY;
66 // Reading fontCode(Integer)
67 PR.ReadInteger (PR.Current(), "Font Code", fontCode); //szv#4:S4163:12Mar99 `st=` not needed
69 // Reading fontName(String)
70 PR.ReadText (PR.Current(), "Font Name", fontName); //szv#4:S4163:12Mar99 `st=` not needed
72 if ( PR.IsParamEntity(PR.CurrentNumber()) )
76 // Reading supersededEntity(TextFontDef)
77 PR.ReadEntity (IR, PR.Current(), "Text Definition Entity",
78 STANDARD_TYPE(IGESGraph_TextFontDef), supersededEntity); //szv#4:S4163:12Mar99 `st=` not needed
81 // Reading supersededFont(Integer)
82 PR.ReadInteger(PR.Current(), "No. of superseded font", supersededFont); //szv#4:S4163:12Mar99 `st=` not needed
84 // Reading scale(Integer)
85 PR.ReadInteger(PR.Current(), "Grid units eqvt to one text height", scale); //szv#4:S4163:12Mar99 `st=` not needed
87 // Reading nbval(Integer)
88 Standard_Boolean st = PR.ReadInteger(PR.Current(), "No. of characters in this defn", nbval);
91 aSCIICodes = new TColStd_HArray1OfInteger(1, nbval);
92 nextCharX = new TColStd_HArray1OfInteger(1, nbval);
93 nextCharY = new TColStd_HArray1OfInteger(1, nbval);
94 penMotions = new TColStd_HArray1OfInteger(1, nbval);
95 penFlags = new IGESBasic_HArray1OfHArray1OfInteger(1, nbval);
96 movePenX = new IGESBasic_HArray1OfHArray1OfInteger(1, nbval);
97 movePenY = new IGESBasic_HArray1OfHArray1OfInteger(1, nbval);
99 for ( Standard_Integer i = 1; i <= nbval; i++ )
101 // Reading aSCIICodes(HArray1OfInteger)
102 if (PR.ReadInteger(PR.Current(), "array aSCIICodes", tempCode)) //szv#4:S4163:12Mar99 `st=` not needed
103 aSCIICodes->SetValue(i, tempCode);
105 // Reading nextChars(HArray1OfInteger*2)
106 if (PR.ReadInteger(PR.Current(), "array nextChar X", tempNextX)) //szv#4:S4163:12Mar99 `st=` not needed
107 nextCharX->SetValue(i, tempNextX);
108 if (PR.ReadInteger(PR.Current(), "array nextChar Y", tempNextY)) //szv#4:S4163:12Mar99 `st=` not needed
109 nextCharY->SetValue(i, tempNextY);
111 // Reading penMotions(HArray1OfInteger)
112 if (PR.ReadInteger(PR.Current(), "array penMotions", tempMotion)) { //szv#4:S4163:12Mar99 `st=` not needed
113 penMotions->SetValue(i, tempMotion);
114 if (tempMotion > 0) {
115 Handle(TColStd_HArray1OfInteger) intarray, xarray, yarray;
117 intarray = new TColStd_HArray1OfInteger(1, tempMotion);
118 xarray = new TColStd_HArray1OfInteger(1, tempMotion);
119 yarray = new TColStd_HArray1OfInteger(1, tempMotion);
121 for ( Standard_Integer j = 1; j <= tempMotion; j++ ) {
122 if (PR.DefinedElseSkip()) {
123 // Reading penFlags(HArray1OfHArray1OfInteger)
124 if (PR.ReadInteger(PR.Current(), "array penFlags", tempFlag)) //szv#4:S4163:12Mar99 `st=` not needed
125 intarray->SetValue(j, tempFlag);
127 else intarray->SetValue(j, 0); // Default Value
129 // Reading movePenTo(HArray1OfHArray1OfInteger*2)
130 if (PR.ReadInteger(PR.Current(), "array movePenTo X", tempMoveX)) //szv#4:S4163:12Mar99 `st=` not needed
131 xarray->SetValue(j, tempMoveX);
132 if (PR.ReadInteger(PR.Current(), "array movePenTo Y", tempMoveY)) //szv#4:S4163:12Mar99 `st=` not needed
133 yarray->SetValue(j, tempMoveY);
135 penFlags->SetValue(i, intarray);
136 movePenX->SetValue(i, xarray);
137 movePenY->SetValue(i, yarray);
140 else PR.AddFail("Count of Pen motions : Not Positive");
144 else PR.AddFail ("Count of characters in this defn : Not Positive");
146 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
148 (fontCode, fontName, supersededFont, supersededEntity,
149 scale, aSCIICodes, nextCharX, nextCharY,
150 penMotions, penFlags, movePenX, movePenY);
153 void IGESGraph_ToolTextFontDef::WriteOwnParams
154 (const Handle(IGESGraph_TextFontDef)& ent, IGESData_IGESWriter& IW) const
156 Standard_Integer IX,IY;
157 IW.Send( ent->FontCode() );
158 IW.Send( ent->FontName() );
160 if ( ent->IsSupersededFontEntity() )
161 IW.Send( ent->SupersededFontEntity(), Standard_True ); // negative
163 IW.Send( ent->SupersededFontCode() );
165 IW.Send( ent->Scale() );
167 Standard_Integer Up = ent->NbCharacters();
169 for ( Standard_Integer i = 1; i <= Up; i++)
171 IW.Send( ent->ASCIICode(i) );
172 ent->NextCharOrigin (i,IX,IY);
175 IW.Send( ent->NbPenMotions(i) );
176 for ( Standard_Integer j = 1; j <= ent->NbPenMotions(i); j ++)
178 IW.SendBoolean( ent->IsPenUp(i,j) );
179 ent->NextPenPosition (i,j, IX,IY);
186 void IGESGraph_ToolTextFontDef::OwnShared
187 (const Handle(IGESGraph_TextFontDef)& ent, Interface_EntityIterator& iter) const
189 if ( ent->IsSupersededFontEntity() )
190 iter.GetOneItem( ent->SupersededFontEntity() );
193 void IGESGraph_ToolTextFontDef::OwnCopy
194 (const Handle(IGESGraph_TextFontDef)& another,
195 const Handle(IGESGraph_TextFontDef)& ent, Interface_CopyTool& TC) const
197 Standard_Integer nbval;
198 Standard_Integer fontCode;
199 Handle(TCollection_HAsciiString) fontName;
200 Standard_Integer supersededFont=0;
201 Handle(IGESGraph_TextFontDef) supersededEntity;
202 Standard_Integer scale;
203 Handle(TColStd_HArray1OfInteger) aSCIICodes, nextCharX,nextCharY;
204 Handle(TColStd_HArray1OfInteger) penMotions;
205 Handle(IGESBasic_HArray1OfHArray1OfInteger) penFlags,movePenX,movePenY;
207 Standard_Integer tempMotion;
208 Handle(TColStd_HArray1OfInteger) intarray,xarray,yarray;
210 nbval = another->NbCharacters();
211 aSCIICodes = new TColStd_HArray1OfInteger(1, nbval);
212 nextCharX = new TColStd_HArray1OfInteger(1, nbval);
213 nextCharY = new TColStd_HArray1OfInteger(1, nbval);
214 penMotions = new TColStd_HArray1OfInteger(1, nbval);
215 penFlags = new IGESBasic_HArray1OfHArray1OfInteger(1, nbval);
216 movePenX = new IGESBasic_HArray1OfHArray1OfInteger(1, nbval);
217 movePenY = new IGESBasic_HArray1OfHArray1OfInteger(1, nbval);
219 fontCode = another->FontCode();
220 fontName = new TCollection_HAsciiString(another->FontName());
222 if ( another->IsSupersededFontEntity() )
224 Handle(IGESGraph_TextFontDef)::DownCast (TC.Transferred(another->SupersededFontEntity()));
226 supersededFont = another->SupersededFontCode();
228 scale = another->Scale();
230 Standard_Integer j, IX,IY;
232 for (Standard_Integer i = 1; i <= nbval; i++)
234 aSCIICodes->SetValue( i, another->ASCIICode(i) );
235 ent->NextCharOrigin (i,IX,IY);
236 nextCharX->SetValue ( i, IX);
237 nextCharY->SetValue ( i, IY);
239 tempMotion = another->NbPenMotions(i);
240 penMotions->SetValue( i, tempMotion );
242 intarray = new TColStd_HArray1OfInteger(1, tempMotion);
243 xarray = new TColStd_HArray1OfInteger(1, tempMotion);
244 yarray = new TColStd_HArray1OfInteger(1, tempMotion);
246 for (j = 1; j <= tempMotion; j++)
248 if ( another->IsPenUp(i, j) ) intarray->SetValue(j, 1);
249 else intarray->SetValue(j, 0);
251 another->NextPenPosition(i, j, IX,IY);
252 xarray->SetValue(j, IX);
253 yarray->SetValue(j, IY);
255 penFlags->SetValue(i, intarray);
256 movePenX->SetValue(i, xarray);
257 movePenY->SetValue(i, yarray);
260 ent->Init(fontCode, fontName, supersededFont, supersededEntity,
261 scale, aSCIICodes, nextCharX, nextCharY, penMotions,
262 penFlags, movePenX, movePenY);
265 IGESData_DirChecker IGESGraph_ToolTextFontDef::DirChecker
266 (const Handle(IGESGraph_TextFontDef)& /*ent*/) const
268 IGESData_DirChecker DC (310, 0);
269 DC.Structure(IGESData_DefVoid);
270 DC.LineFont(IGESData_DefVoid);
271 DC.LineWeight(IGESData_DefVoid);
272 DC.Color(IGESData_DefVoid);
273 DC.BlankStatusIgnored();
274 DC.SubordinateStatusRequired(0);
275 DC.UseFlagRequired(2);
276 DC.HierarchyStatusIgnored();
280 void IGESGraph_ToolTextFontDef::OwnCheck
281 (const Handle(IGESGraph_TextFontDef)& /*ent*/,
282 const Interface_ShareTool& , Handle(Interface_Check)& /*ach*/) const
286 void IGESGraph_ToolTextFontDef::OwnDump
287 (const Handle(IGESGraph_TextFontDef)& ent, const IGESData_IGESDumper& dumper,
288 Standard_OStream& S, const Standard_Integer level) const
290 Standard_Integer sublevel = (level <= 4) ? 0 : 1;
291 Standard_Integer nbchars = ent->NbCharacters();
293 S << "IGESGraph_TextFontDef\n"
294 << "Font Code : " << ent->FontCode() << "\n"
296 IGESData_DumpString(S,ent->FontName());
298 if ( ent->IsSupersededFontEntity() ) {
299 S << "Text Definition Entity : ";
300 dumper.Dump(ent->SupersededFontEntity(),S, sublevel);
302 else S << "Superseding Font Number : " << ent->SupersededFontCode();
304 << "No. of Grid Units eqvt to 1 Text Height : " << ent->Scale() << "\n"
306 << "Grid Locations of next character origins :\n"
308 << "Pen Positions :\n"
309 << "Grid Locations the pen moves to : "
310 << "Count = " << nbchars << "\n";
311 IGESData_DumpVals(S,-level,1,nbchars,ent->ASCIICode);
315 Handle(TColgp_HArray1OfXY) arrXY;
316 Standard_Integer I, J, nbmotions;
317 for (I = 1; I <= nbchars; I++)
319 Standard_Integer IX,IY;
320 S << "[" << I << "]: "
321 << "ASCII Code : " << ent->ASCIICode(I) << "\n"
322 << "Grid Location of next character's origin : ";
323 ent->NextCharOrigin(I,IX,IY);
324 S << "X=" << IX << " Y=" << IY;
325 nbmotions = ent->NbPenMotions(I);
326 S << " No. of Pen Motions : " << nbmotions;
327 if (level <= 5) S << " [ ask level > 5 for Details ]\n";
330 for (J = 1; J <= nbmotions; J++)
332 S << "Pen up(1) / down(0) flag : " << (Standard_Integer)ent->IsPenUp(I,J)
333 << " Next Pen Position : ";
334 ent->NextPenPosition(I,J, IX,IY);
335 S << " X="<<IX<<" Y="<<IY << "\n";