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_XYZ.hxx> |
42cf5bc1 |
20 | #include <IGESData_DirChecker.hxx> |
21 | #include <IGESData_Dump.hxx> |
22 | #include <IGESData_HArray1OfIGESEntity.hxx> |
23 | #include <IGESData_IGESDumper.hxx> |
7fd59977 |
24 | #include <IGESData_IGESEntity.hxx> |
42cf5bc1 |
25 | #include <IGESData_IGESReaderData.hxx> |
26 | #include <IGESData_IGESWriter.hxx> |
27 | #include <IGESData_ParamCursor.hxx> |
28 | #include <IGESData_ParamReader.hxx> |
7fd59977 |
29 | #include <IGESData_ViewKindEntity.hxx> |
42cf5bc1 |
30 | #include <IGESDimen_HArray1OfLeaderArrow.hxx> |
7fd59977 |
31 | #include <IGESDimen_LeaderArrow.hxx> |
32 | #include <IGESDraw_HArray1OfViewKindEntity.hxx> |
42cf5bc1 |
33 | #include <IGESDraw_LabelDisplay.hxx> |
7fd59977 |
34 | #include <IGESDraw_PerspectiveView.hxx> |
42cf5bc1 |
35 | #include <IGESDraw_ToolLabelDisplay.hxx> |
36 | #include <IGESDraw_View.hxx> |
37 | #include <Interface_Check.hxx> |
38 | #include <Interface_CopyTool.hxx> |
39 | #include <Interface_EntityIterator.hxx> |
7fd59977 |
40 | #include <Interface_Macros.hxx> |
42cf5bc1 |
41 | #include <Interface_ShareTool.hxx> |
42 | #include <Message_Messenger.hxx> |
43 | #include <Standard_DomainError.hxx> |
44 | #include <TColgp_HArray1OfXYZ.hxx> |
45 | #include <TColStd_HArray1OfInteger.hxx> |
7fd59977 |
46 | |
47 | IGESDraw_ToolLabelDisplay::IGESDraw_ToolLabelDisplay () { } |
48 | |
49 | |
50 | void IGESDraw_ToolLabelDisplay::ReadOwnParams |
51 | (const Handle(IGESDraw_LabelDisplay)& ent, |
52 | const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const |
53 | { |
54 | //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down |
55 | Standard_Integer nbval; |
56 | |
57 | Handle(IGESDraw_HArray1OfViewKindEntity) views; |
58 | Handle(TColgp_HArray1OfXYZ) textLocations; |
59 | Handle(IGESDimen_HArray1OfLeaderArrow) leaderEntities; |
60 | Handle(TColStd_HArray1OfInteger) labelLevels; |
61 | Handle(IGESData_HArray1OfIGESEntity) displayedEntities; |
62 | |
63 | // Reading nbval(No. of Label placements) |
64 | Standard_Boolean st = PR.ReadInteger(PR.Current(), "No. of Label placements", nbval); |
65 | if (st && nbval > 0) |
66 | { |
67 | views = new IGESDraw_HArray1OfViewKindEntity(1, nbval); |
68 | textLocations = new TColgp_HArray1OfXYZ(1, nbval); |
69 | leaderEntities = new IGESDimen_HArray1OfLeaderArrow(1, nbval); |
70 | labelLevels = new TColStd_HArray1OfInteger(1, nbval); |
71 | displayedEntities = new IGESData_HArray1OfIGESEntity(1, nbval); |
72 | |
73 | Handle(IGESData_ViewKindEntity) tempView; |
74 | gp_XYZ tempXYZ; |
75 | Handle(IGESDimen_LeaderArrow) tempLeaderArrow; |
76 | Standard_Integer tempLabel; |
77 | Handle(IGESData_IGESEntity) tempDisplayedEntity; |
78 | |
79 | for (Standard_Integer i = 1; i <= nbval; i++) |
80 | { |
81 | // Reading views(HArray1OfView) |
82 | //st = PR.ReadEntity (IR, PR.Current(), "Instance of views", |
83 | //STANDARD_TYPE(IGESData_ViewKindEntity), tempView); //szv#4:S4163:12Mar99 moved in if |
84 | if (PR.ReadEntity (IR, PR.Current(), "Instance of views", |
85 | STANDARD_TYPE(IGESData_ViewKindEntity), tempView)) |
86 | views->SetValue(i, tempView); |
87 | |
88 | // Reading textLocations(HArray1OfXYZ) |
89 | //st = PR.ReadXYZ(PR.CurrentList(1, 3), "array textLocations", tempXYZ); //szv#4:S4163:12Mar99 moved in if |
90 | if (PR.ReadXYZ(PR.CurrentList(1, 3), "array textLocations", tempXYZ)) |
91 | textLocations->SetValue(i, tempXYZ); |
92 | |
93 | // Reading leaderEntities(HArray1OfLeaderArrow) |
94 | //st = PR.ReadEntity (IR, PR.Current(), "Instance of LeaderArrow", |
95 | //STANDARD_TYPE(IGESDimen_LeaderArrow), tempLeaderArrow); //szv#4:S4163:12Mar99 moved in if |
96 | if (PR.ReadEntity (IR, PR.Current(), "Instance of LeaderArrow", |
97 | STANDARD_TYPE(IGESDimen_LeaderArrow), tempLeaderArrow)) |
98 | leaderEntities->SetValue(i, tempLeaderArrow); |
99 | |
100 | // Reading labelLevels(HArray1OfInteger) |
101 | //st = PR.ReadInteger(PR.Current(), "array labelLevels", tempLabel); //szv#4:S4163:12Mar99 moved in if |
102 | if (PR.ReadInteger(PR.Current(), "array labelLevels", tempLabel)) |
103 | labelLevels->SetValue(i, tempLabel); |
104 | |
105 | // Reading displayedEntities(HArray1OfIGESEntity) |
106 | //st = PR.ReadEntity (IR, PR.Current(), "displayedEntities entity", |
107 | //tempDisplayedEntity); //szv#4:S4163:12Mar99 moved in if |
108 | if (PR.ReadEntity (IR, PR.Current(), "displayedEntities entity", tempDisplayedEntity)) |
109 | displayedEntities->SetValue(i, tempDisplayedEntity); |
110 | } |
111 | } |
112 | else PR.AddFail("No. of Label placements : Not Positive"); |
113 | |
114 | DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent); |
115 | ent->Init |
116 | (views, textLocations, leaderEntities, labelLevels, displayedEntities); |
117 | } |
118 | |
119 | void IGESDraw_ToolLabelDisplay::WriteOwnParams |
120 | (const Handle(IGESDraw_LabelDisplay)& ent, IGESData_IGESWriter& IW) const |
121 | { |
122 | Standard_Integer Up = ent->NbLabels(); |
123 | IW.Send( Up ); |
124 | for ( Standard_Integer i = 1; i <= Up; i++) |
125 | { |
126 | IW.Send( ent->ViewItem(i) ); |
127 | IW.Send( (ent->TextLocation(i)).X() ); |
128 | IW.Send( (ent->TextLocation(i)).Y() ); |
129 | IW.Send( (ent->TextLocation(i)).Z() ); |
130 | IW.Send( ent->LeaderEntity(i) ); |
131 | IW.Send( ent->LabelLevel(i) ); |
132 | IW.Send( ent->DisplayedEntity(i) ); |
133 | } |
134 | } |
135 | |
136 | void IGESDraw_ToolLabelDisplay::OwnShared |
137 | (const Handle(IGESDraw_LabelDisplay)& ent, Interface_EntityIterator& iter) const |
138 | { |
139 | Standard_Integer Up = ent->NbLabels(); |
140 | for ( Standard_Integer i = 1; i <= Up; i++) |
141 | { |
142 | iter.GetOneItem( ent->ViewItem(i) ); |
143 | iter.GetOneItem( ent->LeaderEntity(i) ); |
144 | iter.GetOneItem( ent->DisplayedEntity(i) ); |
145 | } |
146 | } |
147 | |
148 | void IGESDraw_ToolLabelDisplay::OwnCopy |
149 | (const Handle(IGESDraw_LabelDisplay)& another, |
150 | const Handle(IGESDraw_LabelDisplay)& ent, Interface_CopyTool& TC) const |
151 | { |
152 | Standard_Integer nbval; |
153 | Handle(IGESDraw_HArray1OfViewKindEntity) views; |
154 | Handle(TColgp_HArray1OfXYZ) textLocations; |
155 | Handle(IGESDimen_HArray1OfLeaderArrow) leaderEntities; |
156 | Handle(TColStd_HArray1OfInteger) labelLevels; |
157 | Handle(IGESData_HArray1OfIGESEntity) displayedEntities; |
158 | |
159 | nbval = another->NbLabels(); |
160 | views = new IGESDraw_HArray1OfViewKindEntity(1, nbval); |
161 | textLocations = new TColgp_HArray1OfXYZ(1, nbval); |
162 | leaderEntities = new IGESDimen_HArray1OfLeaderArrow(1, nbval); |
163 | labelLevels = new TColStd_HArray1OfInteger(1, nbval); |
164 | displayedEntities = new IGESData_HArray1OfIGESEntity(1, nbval); |
165 | |
166 | for (Standard_Integer i = 1; i <= nbval; i++) |
167 | { |
168 | DeclareAndCast(IGESData_ViewKindEntity, tempView, |
169 | TC.Transferred(another->ViewItem(i))); |
170 | views->SetValue( i, tempView ); |
171 | |
172 | textLocations->SetValue( i, (another->TextLocation(i)).XYZ() ); |
173 | |
174 | DeclareAndCast(IGESDimen_LeaderArrow, tempArrow, |
175 | TC.Transferred(another->LeaderEntity(i))); |
176 | leaderEntities->SetValue( i, tempArrow ); |
177 | |
178 | labelLevels->SetValue( i, another->LabelLevel(i) ); |
179 | |
180 | DeclareAndCast(IGESData_IGESEntity, tempEntity, |
181 | TC.Transferred(another->DisplayedEntity(i))); |
182 | displayedEntities->SetValue( i, tempEntity ); |
183 | } |
184 | |
185 | ent->Init(views, textLocations, leaderEntities, |
186 | labelLevels, displayedEntities); |
187 | } |
188 | |
189 | IGESData_DirChecker IGESDraw_ToolLabelDisplay::DirChecker |
190 | (const Handle(IGESDraw_LabelDisplay)& /*ent*/) const |
191 | { |
192 | IGESData_DirChecker DC (402, 5); |
193 | DC.Structure(IGESData_DefVoid); |
194 | DC.HierarchyStatusIgnored(); |
195 | DC.BlankStatusIgnored(); |
196 | return DC; |
197 | } |
198 | |
199 | void IGESDraw_ToolLabelDisplay::OwnCheck |
200 | (const Handle(IGESDraw_LabelDisplay)& /*ent*/, |
201 | const Interface_ShareTool& , Handle(Interface_Check)& /*ach*/) const |
202 | { |
203 | } |
204 | |
205 | void IGESDraw_ToolLabelDisplay::OwnDump |
206 | (const Handle(IGESDraw_LabelDisplay)& ent, const IGESData_IGESDumper& dumper, |
0ebe5b0a |
207 | Standard_OStream& S, const Standard_Integer level) const |
7fd59977 |
208 | { |
209 | Standard_Integer sublevel = (level <= 4) ? 0 : 1; |
210 | |
0ebe5b0a |
211 | S << "IGESDraw_LabelDisplay\n" |
212 | << "View Entities :\n" |
213 | << "Text Locations :\n" |
214 | << "Leader Entities :\n" |
215 | << "Label Level Numbers :\n" |
216 | << "Displayed Entities : " |
217 | << "Count = " << ent->NbLabels() << "\n"; |
7fd59977 |
218 | if (level > 4) // Level = 4 : no Dump. Level = 5 & 6 : same Dump |
219 | { |
220 | Standard_Integer I; |
221 | Standard_Integer up = ent->NbLabels(); |
222 | for (I = 1; I <= up; I ++) |
223 | { |
0ebe5b0a |
224 | S << "[" << I << "]:\n" |
225 | << "View Entity : "; |
7fd59977 |
226 | dumper.Dump (ent->ViewItem(I),S, sublevel); |
0ebe5b0a |
227 | S << "\n" |
228 | << "Text Location in View : "; |
7fd59977 |
229 | IGESData_DumpXYZL(S,level, ent->TextLocation(I), ent->Location()); |
230 | S << " Leader Entity in View : "; |
231 | dumper.Dump (ent->LeaderEntity(I),S, sublevel); |
0ebe5b0a |
232 | S << "\n" |
233 | << "Entity Label Level Number : " |
234 | << ent->LabelLevel(I) << " " |
235 | << "Displayed Entity : "; |
7fd59977 |
236 | dumper.Dump (ent->DisplayedEntity(I),S, sublevel); |
0ebe5b0a |
237 | S << "\n"; |
7fd59977 |
238 | } |
239 | } |
0ebe5b0a |
240 | S << std::endl; |
7fd59977 |
241 | } |