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 <IGESGraph_ToolTextFontDef.ixx>
20 #include <IGESData_ParamCursor.hxx>
21 #include <gp_GTrsf.hxx>
23 #include <gp_Pnt2d.hxx>
24 #include <TCollection_HAsciiString.hxx>
25 #include <IGESGraph_TextFontDef.hxx>
26 #include <TColStd_HArray1OfInteger.hxx>
27 #include <TColgp_HArray1OfXY.hxx>
28 #include <TColStd_HArray1OfInteger.hxx>
29 #include <IGESBasic_HArray1OfHArray1OfInteger.hxx>
30 #include <IGESBasic_HArray1OfHArray1OfXY.hxx>
31 #include <IGESData_Dump.hxx>
32 #include <Interface_Macros.hxx>
35 IGESGraph_ToolTextFontDef::IGESGraph_ToolTextFontDef () { }
38 void IGESGraph_ToolTextFontDef::ReadOwnParams
39 (const Handle(IGESGraph_TextFontDef)& ent,
40 const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
42 //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down
43 Standard_Integer nbval;
45 Standard_Integer fontCode;
46 Handle(TCollection_HAsciiString) fontName;
47 Standard_Integer supersededFont;
48 Handle(IGESGraph_TextFontDef) supersededEntity;
49 Standard_Integer scale;
50 Handle(TColStd_HArray1OfInteger) aSCIICodes;
51 Handle(TColStd_HArray1OfInteger) nextCharX, nextCharY;
52 Handle(TColStd_HArray1OfInteger) penMotions;
53 Handle(IGESBasic_HArray1OfHArray1OfInteger) penFlags;
54 Handle(IGESBasic_HArray1OfHArray1OfInteger) movePenX, movePenY;
56 Standard_Integer tempCode, tempNextX,tempNextY;
57 Standard_Integer tempMotion;
58 Standard_Integer tempFlag, tempMoveX,tempMoveY;
60 // Reading fontCode(Integer)
61 PR.ReadInteger (PR.Current(), "Font Code", fontCode); //szv#4:S4163:12Mar99 `st=` not needed
63 // Reading fontName(String)
64 PR.ReadText (PR.Current(), "Font Name", fontName); //szv#4:S4163:12Mar99 `st=` not needed
66 if ( PR.IsParamEntity(PR.CurrentNumber()) )
70 // Reading supersededEntity(TextFontDef)
71 PR.ReadEntity (IR, PR.Current(), "Text Definition Entity",
72 STANDARD_TYPE(IGESGraph_TextFontDef), supersededEntity); //szv#4:S4163:12Mar99 `st=` not needed
75 // Reading supersededFont(Integer)
76 PR.ReadInteger(PR.Current(), "No. of superseded font", supersededFont); //szv#4:S4163:12Mar99 `st=` not needed
78 // Reading scale(Integer)
79 PR.ReadInteger(PR.Current(), "Grid units eqvt to one text height", scale); //szv#4:S4163:12Mar99 `st=` not needed
81 // Reading nbval(Integer)
82 Standard_Boolean st = PR.ReadInteger(PR.Current(), "No. of characters in this defn", nbval);
85 aSCIICodes = new TColStd_HArray1OfInteger(1, nbval);
86 nextCharX = new TColStd_HArray1OfInteger(1, nbval);
87 nextCharY = new TColStd_HArray1OfInteger(1, nbval);
88 penMotions = new TColStd_HArray1OfInteger(1, nbval);
89 penFlags = new IGESBasic_HArray1OfHArray1OfInteger(1, nbval);
90 movePenX = new IGESBasic_HArray1OfHArray1OfInteger(1, nbval);
91 movePenY = new IGESBasic_HArray1OfHArray1OfInteger(1, nbval);
93 for ( Standard_Integer i = 1; i <= nbval; i++ )
95 // Reading aSCIICodes(HArray1OfInteger)
96 if (PR.ReadInteger(PR.Current(), "array aSCIICodes", tempCode)) //szv#4:S4163:12Mar99 `st=` not needed
97 aSCIICodes->SetValue(i, tempCode);
99 // Reading nextChars(HArray1OfInteger*2)
100 if (PR.ReadInteger(PR.Current(), "array nextChar X", tempNextX)) //szv#4:S4163:12Mar99 `st=` not needed
101 nextCharX->SetValue(i, tempNextX);
102 if (PR.ReadInteger(PR.Current(), "array nextChar Y", tempNextY)) //szv#4:S4163:12Mar99 `st=` not needed
103 nextCharY->SetValue(i, tempNextY);
105 // Reading penMotions(HArray1OfInteger)
106 if (PR.ReadInteger(PR.Current(), "array penMotions", tempMotion)) { //szv#4:S4163:12Mar99 `st=` not needed
107 penMotions->SetValue(i, tempMotion);
108 if (tempMotion > 0) {
109 Handle(TColStd_HArray1OfInteger) intarray, xarray, yarray;
111 intarray = new TColStd_HArray1OfInteger(1, tempMotion);
112 xarray = new TColStd_HArray1OfInteger(1, tempMotion);
113 yarray = new TColStd_HArray1OfInteger(1, tempMotion);
115 for ( Standard_Integer j = 1; j <= tempMotion; j++ ) {
116 if (PR.DefinedElseSkip()) {
117 // Reading penFlags(HArray1OfHArray1OfInteger)
118 if (PR.ReadInteger(PR.Current(), "array penFlags", tempFlag)) //szv#4:S4163:12Mar99 `st=` not needed
119 intarray->SetValue(j, tempFlag);
121 else intarray->SetValue(j, 0); // Default Value
123 // Reading movePenTo(HArray1OfHArray1OfInteger*2)
124 if (PR.ReadInteger(PR.Current(), "array movePenTo X", tempMoveX)) //szv#4:S4163:12Mar99 `st=` not needed
125 xarray->SetValue(j, tempMoveX);
126 if (PR.ReadInteger(PR.Current(), "array movePenTo Y", tempMoveY)) //szv#4:S4163:12Mar99 `st=` not needed
127 yarray->SetValue(j, tempMoveY);
129 penFlags->SetValue(i, intarray);
130 movePenX->SetValue(i, xarray);
131 movePenY->SetValue(i, yarray);
134 else PR.AddFail("Count of Pen motions : Not Positive");
138 else PR.AddFail ("Count of characters in this defn : Not Positive");
140 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
142 (fontCode, fontName, supersededFont, supersededEntity,
143 scale, aSCIICodes, nextCharX, nextCharY,
144 penMotions, penFlags, movePenX, movePenY);
147 void IGESGraph_ToolTextFontDef::WriteOwnParams
148 (const Handle(IGESGraph_TextFontDef)& ent, IGESData_IGESWriter& IW) const
150 Standard_Integer IX,IY;
151 IW.Send( ent->FontCode() );
152 IW.Send( ent->FontName() );
154 if ( ent->IsSupersededFontEntity() )
155 IW.Send( ent->SupersededFontEntity(), Standard_True ); // negative
157 IW.Send( ent->SupersededFontCode() );
159 IW.Send( ent->Scale() );
161 Standard_Integer Up = ent->NbCharacters();
163 for ( Standard_Integer i = 1; i <= Up; i++)
165 IW.Send( ent->ASCIICode(i) );
166 ent->NextCharOrigin (i,IX,IY);
169 IW.Send( ent->NbPenMotions(i) );
170 for ( Standard_Integer j = 1; j <= ent->NbPenMotions(i); j ++)
172 IW.SendBoolean( ent->IsPenUp(i,j) );
173 ent->NextPenPosition (i,j, IX,IY);
180 void IGESGraph_ToolTextFontDef::OwnShared
181 (const Handle(IGESGraph_TextFontDef)& ent, Interface_EntityIterator& iter) const
183 if ( ent->IsSupersededFontEntity() )
184 iter.GetOneItem( ent->SupersededFontEntity() );
187 void IGESGraph_ToolTextFontDef::OwnCopy
188 (const Handle(IGESGraph_TextFontDef)& another,
189 const Handle(IGESGraph_TextFontDef)& ent, Interface_CopyTool& TC) const
191 Standard_Integer nbval;
192 Standard_Integer fontCode;
193 Handle(TCollection_HAsciiString) fontName;
194 Standard_Integer supersededFont=0;
195 Handle(IGESGraph_TextFontDef) supersededEntity;
196 Standard_Integer scale;
197 Handle(TColStd_HArray1OfInteger) aSCIICodes, nextCharX,nextCharY;
198 Handle(TColStd_HArray1OfInteger) penMotions;
199 Handle(IGESBasic_HArray1OfHArray1OfInteger) penFlags,movePenX,movePenY;
201 Standard_Integer tempMotion;
202 Handle(TColStd_HArray1OfInteger) intarray,xarray,yarray;
204 nbval = another->NbCharacters();
205 aSCIICodes = new TColStd_HArray1OfInteger(1, nbval);
206 nextCharX = new TColStd_HArray1OfInteger(1, nbval);
207 nextCharY = new TColStd_HArray1OfInteger(1, nbval);
208 penMotions = new TColStd_HArray1OfInteger(1, nbval);
209 penFlags = new IGESBasic_HArray1OfHArray1OfInteger(1, nbval);
210 movePenX = new IGESBasic_HArray1OfHArray1OfInteger(1, nbval);
211 movePenY = new IGESBasic_HArray1OfHArray1OfInteger(1, nbval);
213 fontCode = another->FontCode();
214 fontName = new TCollection_HAsciiString(another->FontName());
216 if ( another->IsSupersededFontEntity() )
218 Handle(IGESGraph_TextFontDef)::DownCast (TC.Transferred(another->SupersededFontEntity()));
220 supersededFont = another->SupersededFontCode();
222 scale = another->Scale();
224 Standard_Integer j, IX,IY;
226 for (Standard_Integer i = 1; i <= nbval; i++)
228 aSCIICodes->SetValue( i, another->ASCIICode(i) );
229 ent->NextCharOrigin (i,IX,IY);
230 nextCharX->SetValue ( i, IX);
231 nextCharY->SetValue ( i, IY);
233 tempMotion = another->NbPenMotions(i);
234 penMotions->SetValue( i, tempMotion );
236 intarray = new TColStd_HArray1OfInteger(1, tempMotion);
237 xarray = new TColStd_HArray1OfInteger(1, tempMotion);
238 yarray = new TColStd_HArray1OfInteger(1, tempMotion);
240 for (j = 1; j <= tempMotion; j++)
242 if ( another->IsPenUp(i, j) ) intarray->SetValue(j, 1);
243 else intarray->SetValue(j, 0);
245 another->NextPenPosition(i, j, IX,IY);
246 xarray->SetValue(j, IX);
247 yarray->SetValue(j, IY);
249 penFlags->SetValue(i, intarray);
250 movePenX->SetValue(i, xarray);
251 movePenY->SetValue(i, yarray);
254 ent->Init(fontCode, fontName, supersededFont, supersededEntity,
255 scale, aSCIICodes, nextCharX, nextCharY, penMotions,
256 penFlags, movePenX, movePenY);
259 IGESData_DirChecker IGESGraph_ToolTextFontDef::DirChecker
260 (const Handle(IGESGraph_TextFontDef)& /*ent*/) const
262 IGESData_DirChecker DC (310, 0);
263 DC.Structure(IGESData_DefVoid);
264 DC.LineFont(IGESData_DefVoid);
265 DC.LineWeight(IGESData_DefVoid);
266 DC.Color(IGESData_DefVoid);
267 DC.BlankStatusIgnored();
268 DC.SubordinateStatusRequired(0);
269 DC.UseFlagRequired(2);
270 DC.HierarchyStatusIgnored();
274 void IGESGraph_ToolTextFontDef::OwnCheck
275 (const Handle(IGESGraph_TextFontDef)& /*ent*/,
276 const Interface_ShareTool& , Handle(Interface_Check)& /*ach*/) const
280 void IGESGraph_ToolTextFontDef::OwnDump
281 (const Handle(IGESGraph_TextFontDef)& ent, const IGESData_IGESDumper& dumper,
282 const Handle(Message_Messenger)& S, const Standard_Integer level) const
284 Standard_Integer sublevel = (level <= 4) ? 0 : 1;
285 Standard_Integer nbchars = ent->NbCharacters();
287 S << "IGESGraph_TextFontDef" << endl;
289 S << "Font Code : " << ent->FontCode() << endl;
291 IGESData_DumpString(S,ent->FontName());
293 if ( ent->IsSupersededFontEntity() ) {
294 S << "Text Definition Entity : ";
295 dumper.Dump(ent->SupersededFontEntity(),S, sublevel);
297 else S << "Superseding Font Number : " << ent->SupersededFontCode();
299 S << "No. of Grid Units eqvt to 1 Text Height : " << ent->Scale() << endl;
300 S << "ASCII Codes : " << endl
301 << "Grid Locations of next character origins : " << endl
302 << "Pen Motions : " << endl
303 << "Pen Positions : " << endl
304 << "Grid Locations the pen moves to : ";
305 S << "Count = " << nbchars << endl;
306 IGESData_DumpVals(S,-level,1,nbchars,ent->ASCIICode);
310 Handle(TColgp_HArray1OfXY) arrXY;
311 Standard_Integer I, J, nbmotions;
312 for (I = 1; I <= nbchars; I++)
314 Standard_Integer IX,IY;
315 S << "[" << I << "]: ";
316 S << "ASCII Code : " << ent->ASCIICode(I) << endl;
317 S << "Grid Location of next character's origin : ";
318 ent->NextCharOrigin(I,IX,IY);
319 S << "X=" << IX << " Y=" << IY;
320 nbmotions = ent->NbPenMotions(I);
321 S << " No. of Pen Motions : " << nbmotions;
322 if (level <= 5) S << " [ ask level > 5 for Details ]" << endl;
325 for (J = 1; J <= nbmotions; J++)
327 S << "Pen up(1) / down(0) flag : " << (Standard_Integer)ent->IsPenUp(I,J);
328 S << " Next Pen Position : ";
329 ent->NextPenPosition(I,J, IX,IY);
330 S << " X="<<IX<<" Y="<<IY;