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 | |
42cf5bc1 |
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> |
7fd59977 |
24 | #include <IGESData_ParamCursor.hxx> |
42cf5bc1 |
25 | #include <IGESData_ParamReader.hxx> |
26 | #include <IGESDefs_MacroDef.hxx> |
27 | #include <IGESDefs_ToolMacroDef.hxx> |
28 | #include <Interface_Check.hxx> |
29 | #include <Interface_CopyTool.hxx> |
30 | #include <Interface_EntityIterator.hxx> |
7fd59977 |
31 | #include <Interface_HArray1OfHAsciiString.hxx> |
7fd59977 |
32 | #include <Interface_Macros.hxx> |
42cf5bc1 |
33 | #include <Interface_ShareTool.hxx> |
34 | #include <Message_Messenger.hxx> |
35 | #include <Standard_DomainError.hxx> |
36 | #include <TCollection_HAsciiString.hxx> |
7fd59977 |
37 | |
38 | IGESDefs_ToolMacroDef::IGESDefs_ToolMacroDef () { } |
39 | |
40 | |
41 | void IGESDefs_ToolMacroDef::ReadOwnParams |
42 | (const Handle(IGESDefs_MacroDef)& ent, |
43 | const Handle(IGESData_IGESReaderData)& /* IR */, IGESData_ParamReader& PR) const |
44 | { |
45 | //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed |
46 | |
47 | Handle(TCollection_HAsciiString) macro; |
48 | Standard_Integer entityTypeID; |
49 | Handle(Interface_HArray1OfHAsciiString) langStatements; |
50 | Handle(TCollection_HAsciiString) endMacro; |
51 | |
52 | PR.ReadText(PR.Current(), "MACRO", macro); //szv#4:S4163:12Mar99 `st=` not needed |
53 | |
54 | PR.ReadInteger(PR.Current(), "Entity Type ID", entityTypeID); //szv#4:S4163:12Mar99 `st=` not needed |
55 | |
56 | Standard_Integer tempCurrent = PR.CurrentNumber(); |
57 | // Counting the no. of language statements. |
58 | Standard_Integer nbval; // svv Jan 10 2000 : porting on DEC |
59 | for (nbval = 0; PR.CurrentNumber() != PR.NbParams(); |
60 | nbval++, PR.SetCurrentNumber(PR.CurrentNumber() + 1)); |
61 | |
62 | PR.SetCurrentNumber(tempCurrent); |
63 | if (nbval > 0) langStatements = |
64 | new Interface_HArray1OfHAsciiString(1, nbval); |
65 | else PR.AddFail("Number of Lang. Stats. : Not Positive"); |
66 | |
67 | if (! langStatements.IsNull()) |
68 | { |
69 | for (Standard_Integer i = 1; i <= nbval; i++) |
70 | { |
71 | Handle(TCollection_HAsciiString) langStat; |
72 | //st = PR.ReadText(PR.Current(), "Language Statement", langStat); //szv#4:S4163:12Mar99 moved in if |
73 | if (PR.ReadText(PR.Current(), "Language Statement", langStat)) |
74 | langStatements->SetValue(i, langStat); |
75 | } |
76 | } |
77 | |
78 | PR.ReadText(PR.Current(), "END MACRO", endMacro); //szv#4:S4163:12Mar99 `st=` not needed |
79 | |
80 | DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent); |
81 | ent->Init (macro, entityTypeID, langStatements, endMacro); |
82 | } |
83 | |
84 | void IGESDefs_ToolMacroDef::WriteOwnParams |
85 | (const Handle(IGESDefs_MacroDef)& ent, IGESData_IGESWriter& IW) const |
86 | { |
87 | IW.Send(ent->MACRO()); |
88 | IW.Send(ent->EntityTypeID()); |
89 | Standard_Integer upper = ent->NbStatements(); |
90 | for (Standard_Integer i = 1; i <= upper; i++) |
91 | IW.Send(ent->LanguageStatement(i)); |
92 | IW.Send(ent->ENDMACRO()); |
93 | } |
94 | |
95 | void IGESDefs_ToolMacroDef::OwnShared |
96 | (const Handle(IGESDefs_MacroDef)& /* ent */, Interface_EntityIterator& /* iter */) const |
97 | { |
98 | } |
99 | |
100 | void IGESDefs_ToolMacroDef::OwnCopy |
101 | (const Handle(IGESDefs_MacroDef)& another, |
102 | const Handle(IGESDefs_MacroDef)& ent, Interface_CopyTool& /* TC */) const |
103 | { |
104 | |
105 | Handle(TCollection_HAsciiString) macro = |
106 | new TCollection_HAsciiString(another->MACRO()); |
107 | Standard_Integer entityTypeID = another->EntityTypeID(); |
108 | Handle(TCollection_HAsciiString) endMacro = |
109 | new TCollection_HAsciiString(another->ENDMACRO()); |
110 | Handle(Interface_HArray1OfHAsciiString) langStatements; |
111 | Standard_Integer nbval = another->NbStatements(); |
112 | langStatements = new Interface_HArray1OfHAsciiString(1, nbval); |
113 | |
114 | for (Standard_Integer i = 1; i <= nbval; i++) |
115 | { |
116 | Handle(TCollection_HAsciiString) langStat = |
117 | new TCollection_HAsciiString(another->LanguageStatement(i)); |
118 | langStatements->SetValue(i, langStat); |
119 | } |
120 | ent->Init(macro, entityTypeID, langStatements, endMacro); |
121 | } |
122 | |
123 | IGESData_DirChecker IGESDefs_ToolMacroDef::DirChecker |
124 | (const Handle(IGESDefs_MacroDef)& /* ent */ ) const |
125 | { |
126 | IGESData_DirChecker DC (306, 0); |
127 | DC.Structure(IGESData_DefVoid); |
128 | DC.LineFont(IGESData_DefVoid); |
129 | DC.LineWeight(IGESData_DefVoid); |
130 | DC.Color(IGESData_DefVoid); |
131 | DC.BlankStatusIgnored(); |
132 | DC.SubordinateStatusRequired(0); |
133 | DC.UseFlagRequired(2); |
134 | DC.HierarchyStatusIgnored(); |
135 | return DC; |
136 | } |
137 | |
138 | void IGESDefs_ToolMacroDef::OwnCheck |
139 | (const Handle(IGESDefs_MacroDef)& /* ent */, |
140 | const Interface_ShareTool& , Handle(Interface_Check)& /* ach */) const |
141 | { |
142 | } |
143 | |
144 | void IGESDefs_ToolMacroDef::OwnDump |
145 | (const Handle(IGESDefs_MacroDef)& ent, const IGESData_IGESDumper& /* dumper */, |
146 | const Handle(Message_Messenger)& S, const Standard_Integer level) const |
147 | { |
148 | S << "IGESDefs_MacroDef" << endl; |
149 | S << "MACRO : "; |
150 | IGESData_DumpString(S,ent->MACRO()); |
151 | S << endl; |
152 | S << "Entity Type ID : " << ent->EntityTypeID() << endl; |
153 | S << "Language Statement : "; |
154 | IGESData_DumpStrings(S ,level,1, ent->NbStatements(),ent->LanguageStatement); |
155 | S << "END MACRO : "; |
156 | IGESData_DumpString(S,ent->ENDMACRO()); |
157 | S << endl; |
158 | } |