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 //--------------------------------------------------------------------
20 #include <IGESData_DirChecker.hxx>
21 #include <IGESData_Dump.hxx>
22 #include <IGESData_HArray1OfIGESEntity.hxx>
23 #include <IGESData_IGESDumper.hxx>
24 #include <IGESData_IGESEntity.hxx>
25 #include <IGESData_IGESReaderData.hxx>
26 #include <IGESData_IGESWriter.hxx>
27 #include <IGESData_ParamCursor.hxx>
28 #include <IGESData_ParamReader.hxx>
29 #include <IGESData_ViewKindEntity.hxx>
30 #include <IGESDimen_HArray1OfLeaderArrow.hxx>
31 #include <IGESDimen_LeaderArrow.hxx>
32 #include <IGESDraw_HArray1OfViewKindEntity.hxx>
33 #include <IGESDraw_LabelDisplay.hxx>
34 #include <IGESDraw_PerspectiveView.hxx>
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>
40 #include <Interface_Macros.hxx>
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>
47 IGESDraw_ToolLabelDisplay::IGESDraw_ToolLabelDisplay () { }
50 void IGESDraw_ToolLabelDisplay::ReadOwnParams
51 (const Handle(IGESDraw_LabelDisplay)& ent,
52 const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
54 //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down
55 Standard_Integer nbval;
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;
63 // Reading nbval(No. of Label placements)
64 Standard_Boolean st = PR.ReadInteger(PR.Current(), "No. of Label placements", nbval);
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);
73 Handle(IGESData_ViewKindEntity) tempView;
75 Handle(IGESDimen_LeaderArrow) tempLeaderArrow;
76 Standard_Integer tempLabel;
77 Handle(IGESData_IGESEntity) tempDisplayedEntity;
79 for (Standard_Integer i = 1; i <= nbval; i++)
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);
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);
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);
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);
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);
112 else PR.AddFail("No. of Label placements : Not Positive");
114 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
116 (views, textLocations, leaderEntities, labelLevels, displayedEntities);
119 void IGESDraw_ToolLabelDisplay::WriteOwnParams
120 (const Handle(IGESDraw_LabelDisplay)& ent, IGESData_IGESWriter& IW) const
122 Standard_Integer Up = ent->NbLabels();
124 for ( Standard_Integer i = 1; i <= Up; i++)
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) );
136 void IGESDraw_ToolLabelDisplay::OwnShared
137 (const Handle(IGESDraw_LabelDisplay)& ent, Interface_EntityIterator& iter) const
139 Standard_Integer Up = ent->NbLabels();
140 for ( Standard_Integer i = 1; i <= Up; i++)
142 iter.GetOneItem( ent->ViewItem(i) );
143 iter.GetOneItem( ent->LeaderEntity(i) );
144 iter.GetOneItem( ent->DisplayedEntity(i) );
148 void IGESDraw_ToolLabelDisplay::OwnCopy
149 (const Handle(IGESDraw_LabelDisplay)& another,
150 const Handle(IGESDraw_LabelDisplay)& ent, Interface_CopyTool& TC) const
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;
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);
166 for (Standard_Integer i = 1; i <= nbval; i++)
168 DeclareAndCast(IGESData_ViewKindEntity, tempView,
169 TC.Transferred(another->ViewItem(i)));
170 views->SetValue( i, tempView );
172 textLocations->SetValue( i, (another->TextLocation(i)).XYZ() );
174 DeclareAndCast(IGESDimen_LeaderArrow, tempArrow,
175 TC.Transferred(another->LeaderEntity(i)));
176 leaderEntities->SetValue( i, tempArrow );
178 labelLevels->SetValue( i, another->LabelLevel(i) );
180 DeclareAndCast(IGESData_IGESEntity, tempEntity,
181 TC.Transferred(another->DisplayedEntity(i)));
182 displayedEntities->SetValue( i, tempEntity );
185 ent->Init(views, textLocations, leaderEntities,
186 labelLevels, displayedEntities);
189 IGESData_DirChecker IGESDraw_ToolLabelDisplay::DirChecker
190 (const Handle(IGESDraw_LabelDisplay)& /*ent*/) const
192 IGESData_DirChecker DC (402, 5);
193 DC.Structure(IGESData_DefVoid);
194 DC.HierarchyStatusIgnored();
195 DC.BlankStatusIgnored();
199 void IGESDraw_ToolLabelDisplay::OwnCheck
200 (const Handle(IGESDraw_LabelDisplay)& /*ent*/,
201 const Interface_ShareTool& , Handle(Interface_Check)& /*ach*/) const
205 void IGESDraw_ToolLabelDisplay::OwnDump
206 (const Handle(IGESDraw_LabelDisplay)& ent, const IGESData_IGESDumper& dumper,
207 const Handle(Message_Messenger)& S, const Standard_Integer level) const
209 Standard_Integer sublevel = (level <= 4) ? 0 : 1;
211 S << "IGESDraw_LabelDisplay" << endl;
213 S << "View Entities : " << endl
214 << "Text Locations : " << endl
215 << "Leader Entities : " << endl
216 << "Label Level Numbers : " << endl
217 << "Displayed Entities : ";
218 S << "Count = " << ent->NbLabels() << endl;
219 if (level > 4) // Level = 4 : no Dump. Level = 5 & 6 : same Dump
222 Standard_Integer up = ent->NbLabels();
223 for (I = 1; I <= up; I ++)
225 S << "[" << I << "]:" << endl;
226 S << "View Entity : ";
227 dumper.Dump (ent->ViewItem(I),S, sublevel);
229 S << "Text Location in View : ";
230 IGESData_DumpXYZL(S,level, ent->TextLocation(I), ent->Location());
231 S << " Leader Entity in View : ";
232 dumper.Dump (ent->LeaderEntity(I),S, sublevel);
234 S << "Entity Label Level Number : ";
235 S << ent->LabelLevel(I) << " ";
236 S << "Displayed Entity : ";
237 dumper.Dump (ent->DisplayedEntity(I),S, sublevel);