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 <IGESData_DirChecker.hxx>
20 #include <IGESData_Dump.hxx>
21 #include <IGESData_IGESDumper.hxx>
22 #include <IGESData_IGESReaderData.hxx>
23 #include <IGESData_IGESWriter.hxx>
24 #include <IGESData_ParamCursor.hxx>
25 #include <IGESData_ParamReader.hxx>
26 #include <IGESDimen_DimensionDisplayData.hxx>
27 #include <IGESDimen_ToolDimensionDisplayData.hxx>
28 #include <Interface_Check.hxx>
29 #include <Interface_CopyTool.hxx>
30 #include <Interface_EntityIterator.hxx>
31 #include <Interface_Macros.hxx>
32 #include <Interface_ShareTool.hxx>
33 #include <Message_Messenger.hxx>
34 #include <Standard_DomainError.hxx>
35 #include <TCollection_HAsciiString.hxx>
36 #include <TColStd_HArray1OfInteger.hxx>
38 IGESDimen_ToolDimensionDisplayData::IGESDimen_ToolDimensionDisplayData () { }
41 void IGESDimen_ToolDimensionDisplayData::ReadOwnParams
42 (const Handle(IGESDimen_DimensionDisplayData)& ent,
43 const Handle(IGESData_IGESReaderData)& /* IR */, IGESData_ParamReader& PR) const
45 //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down
46 Standard_Integer tempDimType;
47 Standard_Integer tempLabelPos;
48 Standard_Integer tempCharSet;
49 Handle(TCollection_HAsciiString) tempLString;
50 Standard_Real tempWitLineAng;
51 Standard_Integer tempDeciSymb;
52 Standard_Integer tempTextAlign;
53 Standard_Integer tempTextLevel;
54 Standard_Integer tempTextPlace;
55 Standard_Integer tempArrHeadOrient;
56 Standard_Real tempInitVal;
57 Standard_Integer tempNbProps;
58 Handle(TColStd_HArray1OfInteger) tempSuppleNotes;
59 Handle(TColStd_HArray1OfInteger) tempStartInd;
60 Handle(TColStd_HArray1OfInteger) tempEndInd;
62 //szv#4:S4163:12Mar99 `st=` not needed
63 PR.ReadInteger(PR.Current(),"Number of Properties",tempNbProps);
64 PR.ReadInteger(PR.Current(),"Dimension Type", tempDimType);
65 PR.ReadInteger(PR.Current(),"Label Position", tempLabelPos);
66 if (PR.DefinedElseSkip())
67 PR.ReadInteger(PR.Current(),"Character Set", tempCharSet); //szv#4:S4163:12Mar99 `st=` not needed
71 //szv#4:S4163:12Mar99 `st=` not needed
72 PR.ReadText(PR.Current(),"L String", tempLString);
73 PR.ReadInteger(PR.Current(),"Decimal Symbol",tempDeciSymb);
74 if (PR.DefinedElseSkip())
75 PR.ReadReal(PR.Current(),"Witness Line Angle",tempWitLineAng); //szv#4:S4163:12Mar99 `st=` not needed
77 tempWitLineAng = M_PI / 2;
79 PR.ReadInteger(PR.Current(),"Text Alignment",tempTextAlign); //szv#4:S4163:12Mar99 `st=` not needed
80 if (PR.DefinedElseSkip())
81 PR.ReadInteger(PR.Current(),"Text Level",tempTextLevel); //szv#4:S4163:12Mar99 `st=` not needed
85 if (PR.DefinedElseSkip())
86 PR.ReadInteger(PR.Current(),"Text Place",tempTextPlace); //szv#4:S4163:12Mar99 `st=` not needed
90 //szv#4:S4163:12Mar99 `st=` not needed
91 PR.ReadInteger(PR.Current(),"ArrowHeadOrientation",tempArrHeadOrient);
92 PR.ReadReal(PR.Current(),"Initial Value",tempInitVal);
93 Standard_Integer tempnbval;
94 Standard_Boolean st = PR.ReadInteger( PR.Current(), "No. of supplementary notes", tempnbval);
95 if (st && tempnbval > 0)
97 tempSuppleNotes = new TColStd_HArray1OfInteger(1,tempnbval);
98 tempStartInd = new TColStd_HArray1OfInteger(1,tempnbval);
99 tempEndInd = new TColStd_HArray1OfInteger(1,tempnbval);
100 for (Standard_Integer i = 1; i <= tempnbval; i++)
102 Standard_Integer anote,astart,anend;
103 //st = PR.ReadInteger(PR.Current(), "Supplementary Notes", anote); //szv#4:S4163:12Mar99 moved in if
104 if (PR.ReadInteger(PR.Current(), "Supplementary Notes", anote))
105 tempSuppleNotes->SetValue(i,anote);
106 //st = PR.ReadInteger(PR.Current(),"Start Index", astart); //szv#4:S4163:12Mar99 moved in if
107 if (PR.ReadInteger(PR.Current(),"Start Index", astart))
108 tempStartInd->SetValue(i,astart);
109 //st = PR.ReadInteger(PR.Current(),"End Index",anend); //szv#4:S4163:12Mar99 moved in if
110 if (PR.ReadInteger(PR.Current(),"End Index",anend))
111 tempEndInd->SetValue(i,anend);
115 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
117 (tempNbProps, tempDimType, tempLabelPos, tempCharSet, tempLString,
118 tempDeciSymb, tempWitLineAng, tempTextAlign, tempTextLevel,
119 tempTextPlace, tempArrHeadOrient, tempInitVal, tempSuppleNotes,
120 tempStartInd, tempEndInd );
123 void IGESDimen_ToolDimensionDisplayData::WriteOwnParams
124 (const Handle(IGESDimen_DimensionDisplayData)& ent, IGESData_IGESWriter& IW)
127 IW.Send(ent->NbPropertyValues());
128 IW.Send(ent->DimensionType());
129 IW.Send(ent->LabelPosition());
130 IW.Send(ent->CharacterSet());
131 IW.Send(ent->LString());
132 IW.Send(ent->DecimalSymbol());
133 IW.Send(ent->WitnessLineAngle());
134 IW.Send(ent->TextAlignment());
135 IW.Send(ent->TextLevel());
136 IW.Send(ent->TextPlacement());
137 IW.Send(ent->ArrowHeadOrientation());
138 IW.Send(ent->InitialValue());
140 Standard_Integer nbval = ent->NbSupplementaryNotes();
142 for (Standard_Integer i = 1; i <= nbval; i++)
144 IW.Send(ent->SupplementaryNote(i));
145 IW.Send(ent->StartIndex(i));
146 IW.Send(ent->EndIndex(i));
150 void IGESDimen_ToolDimensionDisplayData::OwnShared
151 (const Handle(IGESDimen_DimensionDisplayData)& /* ent */, Interface_EntityIterator& /* iter */) const
155 void IGESDimen_ToolDimensionDisplayData::OwnCopy
156 (const Handle(IGESDimen_DimensionDisplayData)& another,
157 const Handle(IGESDimen_DimensionDisplayData)& ent, Interface_CopyTool& /* TC */) const
159 Handle(TColStd_HArray1OfInteger) EndList;
160 Handle(TColStd_HArray1OfInteger) StartList;
161 Handle(TColStd_HArray1OfInteger) NotesList;
163 Standard_Integer upper = another->NbSupplementaryNotes();
166 EndList = new TColStd_HArray1OfInteger(1,upper);
167 StartList = new TColStd_HArray1OfInteger(1,upper);
168 NotesList = new TColStd_HArray1OfInteger(1,upper);
169 for (Standard_Integer i = 1;i <= upper;i++)
171 EndList->SetValue(i,another->EndIndex(i));
172 StartList->SetValue(i,another->StartIndex(i));
173 NotesList->SetValue(i,another->SupplementaryNote(i));
176 Standard_Integer tempNbPropertyValues = another->NbPropertyValues();
177 Standard_Integer tempDimensionType = another->DimensionType();
178 Standard_Integer tempLabelPos = another->LabelPosition();
179 Standard_Integer tempCharSet = another->CharacterSet();
180 Handle(TCollection_HAsciiString) tempLS =
181 new TCollection_HAsciiString(another->LString());
182 Standard_Integer tempSymbol = another->DecimalSymbol();
183 Standard_Real tempAngle = another->WitnessLineAngle();
184 Standard_Integer tempAlign = another->TextAlignment();
185 Standard_Integer tempLevel = another->TextLevel();
186 Standard_Integer tempPlacement = another->TextPlacement();
187 Standard_Integer tempArrowHead = another->ArrowHeadOrientation();
188 Standard_Real tempInitial = another->InitialValue();
190 ent->Init(tempNbPropertyValues, tempDimensionType,tempLabelPos,tempCharSet,
191 tempLS,tempSymbol,tempAngle,tempAlign,tempLevel,tempPlacement,
192 tempArrowHead,tempInitial,NotesList,StartList,EndList);
195 Standard_Boolean IGESDimen_ToolDimensionDisplayData::OwnCorrect
196 (const Handle(IGESDimen_DimensionDisplayData)& ent) const
198 Standard_Boolean res = (ent->NbPropertyValues() != 14);
199 if (!res) return res;
200 Handle(TColStd_HArray1OfInteger) EndList;
201 Handle(TColStd_HArray1OfInteger) StartList;
202 Handle(TColStd_HArray1OfInteger) NotesList;
204 Standard_Integer upper = ent->NbSupplementaryNotes();
207 EndList = new TColStd_HArray1OfInteger(1,upper);
208 StartList = new TColStd_HArray1OfInteger(1,upper);
209 NotesList = new TColStd_HArray1OfInteger(1,upper);
210 for (Standard_Integer i = 1;i <= upper;i++)
212 EndList->SetValue (i,ent->EndIndex(i));
213 StartList->SetValue(i,ent->StartIndex(i));
214 NotesList->SetValue(i,ent->SupplementaryNote(i));
218 (14, ent->DimensionType(),ent->LabelPosition(),ent->CharacterSet(),
219 ent->LString(), ent->DecimalSymbol(),ent->WitnessLineAngle(),
220 ent->TextAlignment(),ent->TextLevel(), ent->TextPlacement(),
221 ent->ArrowHeadOrientation(),ent->InitialValue(),
222 NotesList,StartList,EndList);
223 return res; // nbpropertyvalues=14
226 IGESData_DirChecker IGESDimen_ToolDimensionDisplayData::DirChecker
227 (const Handle(IGESDimen_DimensionDisplayData)& /* ent */ ) const
229 IGESData_DirChecker DC(406,30); // type=406, Form no. = 30
230 DC.Structure(IGESData_DefVoid);
231 DC.GraphicsIgnored();
232 DC.BlankStatusIgnored();
233 DC.SubordinateStatusRequired(02);
234 DC.UseFlagRequired(02);
235 DC.HierarchyStatusIgnored();
239 void IGESDimen_ToolDimensionDisplayData::OwnCheck
240 (const Handle(IGESDimen_DimensionDisplayData)& ent,
241 const Interface_ShareTool& , Handle(Interface_Check)& ach) const
243 if (ent->NbPropertyValues() != 14)
244 ach->AddFail("The No. of property values != 14 ");
245 if (ent->DimensionType() < 0 || ent->DimensionType() > 2)
246 ach->AddFail("Incorrect Dimension Type");
247 if (ent->LabelPosition() < 0 || ent->LabelPosition() > 4)
248 ach->AddFail("Incorrect Preferred Label Position");
249 if (!(ent->CharacterSet() == 1 || ent->CharacterSet() == 1001 ||
250 ent->CharacterSet() == 1002 || ent->CharacterSet() == 1003))
251 ach->AddFail("Incorrect Character Set");
252 if (ent->DecimalSymbol() != 0 && ent->DecimalSymbol() != 1)
253 ach->AddFail("Incorrect Decimal Symbol");
254 if (ent->TextAlignment() != 0 && ent->TextAlignment() != 1)
255 ach->AddFail("Incorrect Text Alignment");
256 if (ent->TextLevel() < 0 || ent->TextLevel() > 2)
257 ach->AddFail("Incorrect Text Level");
258 if (ent->TextPlacement() < 0 || ent->TextPlacement() > 2)
259 ach->AddFail("Incorrect Text Placement");
260 if (ent->ArrowHeadOrientation() != 0 && ent->ArrowHeadOrientation() != 1)
261 ach->AddFail("Incorrect ArrowHead Orientation");
262 for (Standard_Integer upper = ent->NbSupplementaryNotes(), i = 1;
264 if (ent->SupplementaryNote(i) < 1 ||
265 ent->SupplementaryNote(i) > 4)
266 ach->AddFail("Incorrect First supplement note");
270 void IGESDimen_ToolDimensionDisplayData::OwnDump
271 (const Handle(IGESDimen_DimensionDisplayData)& ent, const IGESData_IGESDumper& /* dumper */,
272 const Handle(Message_Messenger)& S, const Standard_Integer level) const
274 S << "IGESDimen_DimensionDisplayData" << Message_EndLine;
276 S << "No. of property values : " << ent->NbPropertyValues() << Message_EndLine;
278 S << "DimensionType : " << ent->DimensionType() ;
279 switch (ent->DimensionType()) {
280 case 0 : S << " (Ordinary)" << Message_EndLine; break;
281 case 1 : S << " (Reference)" << Message_EndLine; break;
282 case 2 : S << " (Basic)" << Message_EndLine; break;
283 default : S << " (Incorrect Value)" << Message_EndLine; break;
286 S << "Preferred Label Position : " << ent->LabelPosition();
287 switch (ent->LabelPosition()) {
288 case 0 : S << " (Does not exist)" << Message_EndLine; break;
289 case 1 : S << " (Before Measurement)" << Message_EndLine; break;
290 case 2 : S << " (After Measurement)" << Message_EndLine; break;
291 case 3 : S << " (Above Measurement)" << Message_EndLine; break;
292 case 4 : S << " (Below Measurement)" << Message_EndLine; break;
293 default : S << " (Incorrect Value)" << Message_EndLine; break;
296 S << "Character set interpretation : " << ent->CharacterSet() ;
297 switch (ent->CharacterSet())
299 case 1 : S << " (Standard ASCII)" << Message_EndLine; break;
300 case 1001 : S << " (Symbol Font 1)" << Message_EndLine; break;
301 case 1002 : S << " (Symbol Font 2)" << Message_EndLine; break;
302 case 1003 : S << " (Drafting Font)" << Message_EndLine; break;
303 default : S << " (Not meaningful)" << Message_EndLine; break;
307 IGESData_DumpString(S,ent->LString());
308 S << Message_EndLine;
310 S << "Decimal Symbol : ";
311 if (ent->DecimalSymbol() == 0) S << "0 (.)" << Message_EndLine;
312 else S << "1 (,)" << Message_EndLine;
314 S << "Witness Line Angle : " << ent->WitnessLineAngle() << Message_EndLine;
315 S << "Text Alignment : " ;
316 if (ent->TextAlignment() == 0 ) S << "0 (Horizontal)" << Message_EndLine;
317 else if (ent->TextAlignment() == 1 ) S << "1 (Parallel)" << Message_EndLine;
318 else S << ent->TextAlignment() << " (Incorrect Value)" << Message_EndLine;
320 S << "Text Level : " << ent->TextLevel();
321 switch (ent->TextLevel()) {
322 case 0 : S << " (Neither above nor below)" << Message_EndLine; break;
323 case 1 : S << " (Above)" << Message_EndLine; break;
324 case 2 : S << " (Below)" << Message_EndLine; break;
325 default : S << " (Incorrect Value)" << Message_EndLine; break;
328 S << "Preferred Text placement : " << ent->TextPlacement();
329 switch (ent->TextPlacement()) {
330 case 0 : S << " (Between witness lines)" << Message_EndLine; break;
331 case 1 : S << " (Outside near the first witness line)" << Message_EndLine; break;
332 case 2 : S << " (Outside near second witness line)" << Message_EndLine; break;
333 default : S << " (Incorrect Value)" << Message_EndLine; break;
336 S << "Arrow Head Orientation : " << ent->ArrowHeadOrientation();
337 if (ent->ArrowHeadOrientation() == 0) S << " (In, pointing out)" <<Message_EndLine;
338 else if (ent->ArrowHeadOrientation() == 1) S << " (Out, pointing in)" <<Message_EndLine;
339 else S << " (Incorrect Value)" << Message_EndLine;
341 Standard_Integer nbnotes = ent->NbSupplementaryNotes();
342 S << " Primary Dimension Value : " << ent->InitialValue() << Message_EndLine;
343 S << " Number of Supplementary Notes : " << nbnotes <<Message_EndLine;
344 S << "Supplementary Notes , ";
345 S << " Start Index , ";
346 S << " End Index : " << Message_EndLine;
347 IGESData_DumpVals(S,-level,1, nbnotes,ent->EndIndex);
348 S << Message_EndLine;
350 for (Standard_Integer i = 1; i <= nbnotes; i ++)
352 S << "[" << i << "]: " << Message_EndLine;
353 S << "Supplementary Note : " << ent->SupplementaryNote(i);
354 S << ", Start Index : " << ent->StartIndex(i);
355 S << ", End Index : " << ent->EndIndex(i) << Message_EndLine;
357 S << Message_EndLine;