0030686: Visualization, SelectMgr_ViewerSelector - sorting issues of transformation...
[occt.git] / src / IGESDraw / IGESDraw_ToolNetworkSubfigureDef.cxx
CommitLineData
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_HArray1OfIGESEntity.hxx>
22#include <IGESData_IGESDumper.hxx>
23#include <IGESData_IGESEntity.hxx>
24#include <IGESData_IGESReaderData.hxx>
25#include <IGESData_IGESWriter.hxx>
7fd59977 26#include <IGESData_ParamCursor.hxx>
42cf5bc1 27#include <IGESData_ParamReader.hxx>
7fd59977 28#include <IGESDraw_ConnectPoint.hxx>
7fd59977 29#include <IGESDraw_HArray1OfConnectPoint.hxx>
42cf5bc1 30#include <IGESDraw_NetworkSubfigureDef.hxx>
31#include <IGESDraw_ToolNetworkSubfigureDef.hxx>
32#include <IGESGraph_TextDisplayTemplate.hxx>
33#include <Interface_Check.hxx>
34#include <Interface_CopyTool.hxx>
35#include <Interface_EntityIterator.hxx>
7fd59977 36#include <Interface_Macros.hxx>
42cf5bc1 37#include <Interface_ShareTool.hxx>
38#include <Message_Messenger.hxx>
39#include <Standard_DomainError.hxx>
40#include <TCollection_HAsciiString.hxx>
7fd59977 41
42IGESDraw_ToolNetworkSubfigureDef::IGESDraw_ToolNetworkSubfigureDef () { }
43
44
45void IGESDraw_ToolNetworkSubfigureDef::ReadOwnParams
46 (const Handle(IGESDraw_NetworkSubfigureDef)& ent,
47 const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
48{
49 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
50
51 Standard_Integer tempDepth, tempNbEntities1, tempTypeFlag, tempNbEntities2;
52 Handle(TCollection_HAsciiString) tempName, tempDesignator;
53 Handle(IGESGraph_TextDisplayTemplate) tempTemplate;
54 Handle(IGESData_HArray1OfIGESEntity) tempEntities;
55 Handle(IGESDraw_HArray1OfConnectPoint) tempPointEntities;
56
57 //szv#4:S4163:12Mar99 `st=` not needed
58 PR.ReadInteger(PR.Current(), "Depth Of Subfigure", tempDepth);
59 PR.ReadText(PR.Current(), "Subfigure Name", tempName);
60
61 //st = PR.ReadInteger(PR.Current(), "Number Of Child Entities", tempNbEntities1); //szv#4:S4163:12Mar99 moved in if
62 if (PR.ReadInteger(PR.Current(), "Number Of Child Entities", tempNbEntities1)) {
63 // Initialize HArray1 only if there is no error reading its Length
64 if (tempNbEntities1 < 0)
65 PR.AddFail("Number Of Child Entities : Not Positive");
66 else if (tempNbEntities1 > 0)
67 PR.ReadEnts(IR,PR.CurrentList(tempNbEntities1),"Child Entities",tempEntities); //szv#4:S4163:12Mar99 `st=` not needed
68// tempEntities = new IGESData_HArray1OfIGESEntity (1,tempNbEntities1);
69 }
70
71 // Read the HArray1 only if its Length was read without any Error
72/*
73 if (! tempEntities.IsNull()) {
74 Handle(IGESData_IGESEntity) tempEntity1;
75 Standard_Integer I;
76 for (I = 1; I <= tempNbEntities1; I++) {
77 st = PR.ReadEntity(IR, PR.Current(), "Associated Entity",
78 tempEntity1);
79 if (st) tempEntities->SetValue(I, tempEntity1);
80 }
81 }
82*/
83 PR.ReadInteger(PR.Current(), "Type Flag", tempTypeFlag); //szv#4:S4163:12Mar99 `st=` not needed
84
85 if (PR.DefinedElseSkip())
86 PR.ReadText(PR.Current(), "Primary Reference Designator", tempDesignator); //szv#4:S4163:12Mar99 `st=` not needed
87 else PR.AddWarning("Primary Reference Designator : Null");
88
89 Standard_Boolean st = PR.ReadEntity(IR, PR.Current(), "Primary Reference Designator",
90 STANDARD_TYPE(IGESGraph_TextDisplayTemplate), tempTemplate,
91 Standard_True);
92
93 if (PR.DefinedElseSkip())
94 st = PR.ReadInteger(PR.Current(), "Number Of Connect Points", tempNbEntities2);
95 else tempNbEntities2 = 0;
96 if (st) {
97 // Initialise HArray1 only if there is no error reading its Length
98 if (tempNbEntities2 < 0)
99 PR.AddFail("Number Of Connect Points : Less Than Zero");
100 else if (tempNbEntities2 > 0) tempPointEntities =
101 new IGESDraw_HArray1OfConnectPoint (1, tempNbEntities2);
102 }
103
104 // Read the HArray1 only if its Length was read without any Error
105 if (! tempPointEntities.IsNull()) {
106 Handle(IGESDraw_ConnectPoint) tempConnectPoint;
107 Standard_Integer I;
108 for (I = 1; I <= tempNbEntities2; I++) {
109 //st = PR.ReadEntity(IR, PR.Current(),"Associated Connect Point Entity",
110 //STANDARD_TYPE(IGESDraw_ConnectPoint), tempConnectPoint,
111 //Standard_True); //szv#4:S4163:12Mar99 moved in if
112 if (PR.ReadEntity(IR, PR.Current(),"Associated Connect Point Entity",
113 STANDARD_TYPE(IGESDraw_ConnectPoint), tempConnectPoint, Standard_True))
114 tempPointEntities->SetValue(I, tempConnectPoint);
115 }
116 }
117
118 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
119 ent->Init
120 (tempDepth, tempName, tempEntities, tempTypeFlag, tempDesignator,
121 tempTemplate, tempPointEntities);
122}
123
124void IGESDraw_ToolNetworkSubfigureDef::WriteOwnParams
125 (const Handle(IGESDraw_NetworkSubfigureDef)& ent, IGESData_IGESWriter& IW) const
126{
127 Standard_Integer up = ent->NbEntities();
128 IW.Send(ent->Depth());
129 IW.Send(ent->Name());
130 IW.Send(up);
131 Standard_Integer I;
132 for (I = 1; I <= up; I++)
133 IW.Send(ent->Entity(I));
134 IW.Send(ent->TypeFlag());
135 IW.Send(ent->Designator());
136 IW.Send(ent->DesignatorTemplate());
137 up = ent->NbPointEntities();
138 IW.Send(up);
139 for (I = 1; I <= up; I++)
140 IW.Send(ent->PointEntity(I));
141}
142
143void IGESDraw_ToolNetworkSubfigureDef::OwnShared
144 (const Handle(IGESDraw_NetworkSubfigureDef)& ent, Interface_EntityIterator& iter) const
145{
146 Standard_Integer I;
147 Standard_Integer up = ent->NbEntities();
148 for (I = 1; I <= up; I++)
149 iter.GetOneItem(ent->Entity(I));
150 up = ent->NbPointEntities();
151 for (I = 1; I <= up; I++)
152 iter.GetOneItem(ent->PointEntity(I));
153}
154
155void IGESDraw_ToolNetworkSubfigureDef::OwnCopy
156 (const Handle(IGESDraw_NetworkSubfigureDef)& another,
157 const Handle(IGESDraw_NetworkSubfigureDef)& ent, Interface_CopyTool& TC) const
158{
159 Standard_Integer tempDepth = another->Depth();
160 Handle(TCollection_HAsciiString) tempName =
161 new TCollection_HAsciiString(another->Name());
162 Handle(IGESData_HArray1OfIGESEntity) tempEntities;
163 Standard_Integer up = another->NbEntities();
164 if (up > 0) tempEntities = new IGESData_HArray1OfIGESEntity (1,up);
165 Standard_Integer I;
166 for (I = 1; I <= up; I++) {
167 DeclareAndCast(IGESData_IGESEntity, tempEntity,
168 TC.Transferred(another->Entity(I)));
169 tempEntities->SetValue(I, tempEntity);
170 }
171 Standard_Integer tempTypeFlag = another->TypeFlag();
172 Handle(TCollection_HAsciiString) tempDesignator;
173 if (!another->Designator().IsNull()) tempDesignator =
174 new TCollection_HAsciiString(another->Designator());
175 up = another->NbPointEntities();
176 Handle(IGESDraw_HArray1OfConnectPoint) tempPointEntities;
177 if (up > 0) tempPointEntities = new IGESDraw_HArray1OfConnectPoint (1,up);
178 for (I = 1; I <= up; I++) {
179 if (another->HasPointEntity(I)) {
180 DeclareAndCast(IGESDraw_ConnectPoint, tempPointEntity,
181 TC.Transferred(another->PointEntity(I)));
182 tempPointEntities->SetValue(I, tempPointEntity);
183 }
184 }
185 if (another->HasDesignatorTemplate()) {
186 DeclareAndCast(IGESGraph_TextDisplayTemplate, tempDesignatorTemplate,
187 TC.Transferred(another->DesignatorTemplate()));
188
189 ent->Init(tempDepth, tempName, tempEntities, tempTypeFlag,
190 tempDesignator, tempDesignatorTemplate, tempPointEntities);
191 }
192 else {
193 Handle(IGESGraph_TextDisplayTemplate) tempDesignatorTemplate;
194
195 ent->Init(tempDepth, tempName, tempEntities, tempTypeFlag,
196 tempDesignator, tempDesignatorTemplate, tempPointEntities);
197 }
198}
199
200IGESData_DirChecker IGESDraw_ToolNetworkSubfigureDef::DirChecker
201 (const Handle(IGESDraw_NetworkSubfigureDef)& /*ent*/) const
202{
203 IGESData_DirChecker DC(320, 0);
204 DC.Structure(IGESData_DefVoid);
205 DC.LineFont(IGESData_DefAny);
206 DC.LineWeight(IGESData_DefValue);
207 DC.BlankStatusIgnored();
208 DC.UseFlagRequired(2);
209 DC.GraphicsIgnored(1);
210
211 return DC;
212}
213
214void IGESDraw_ToolNetworkSubfigureDef::OwnCheck
215 (const Handle(IGESDraw_NetworkSubfigureDef)& ent,
216 const Interface_ShareTool& , Handle(Interface_Check)& ach) const
217{
218 if ((ent->TypeFlag() < 0) || (ent->TypeFlag() > 2))
219 ach->AddFail("TypeFlag has Invalid value");
220 if (ent->Designator().IsNull())
221 ach->AddFail("Primary Reference Designator : not defined");
222}
223
224void IGESDraw_ToolNetworkSubfigureDef::OwnDump
225 (const Handle(IGESDraw_NetworkSubfigureDef)& ent, const IGESData_IGESDumper& dumper,
226 const Handle(Message_Messenger)& S, const Standard_Integer level) const
227{
228 Standard_Integer tempSubLevel = (level <= 4) ? 0 : 1;
229
230 S << "IGESDraw_NetworkSubfigureDef" << endl;
231
232 S << "Depth Of Subfigure(Nesting) : " << ent->Depth() << endl;
233 S << "Name Of Subfigure : ";
234 IGESData_DumpString(S,ent->Name());
235 S << endl << "Associated Entities : ";
236 IGESData_DumpEntities(S,dumper ,level,1, ent->NbEntities(),ent->Entity);
237 S << endl << "Type Flag : " << ent->TypeFlag() << endl;
238 S << "Primary Reference Designator : ";
239 IGESData_DumpString(S,ent->Designator());
240 S << endl << "Text Display Template Entity : ";
241 dumper.Dump(ent->DesignatorTemplate(),S, tempSubLevel);
242 S << endl << "Connect Point Entities : ";
243 IGESData_DumpEntities(S,dumper ,level,1, ent->NbPointEntities(),ent->PointEntity);
244 S << endl;
245}