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 //--------------------------------------------------------------------
21 #include <IGESData_DirChecker.hxx>
22 #include <IGESData_Dump.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 <IGESDraw_ConnectPoint.hxx>
30 #include <IGESDraw_ToolConnectPoint.hxx>
31 #include <IGESGraph_TextDisplayTemplate.hxx>
32 #include <Interface_Check.hxx>
33 #include <Interface_CopyTool.hxx>
34 #include <Interface_EntityIterator.hxx>
35 #include <Interface_Macros.hxx>
36 #include <Interface_ShareTool.hxx>
37 #include <Message_Messenger.hxx>
38 #include <Standard_DomainError.hxx>
39 #include <TCollection_HAsciiString.hxx>
41 IGESDraw_ToolConnectPoint::IGESDraw_ToolConnectPoint () { }
44 void IGESDraw_ToolConnectPoint::ReadOwnParams
45 (const Handle(IGESDraw_ConnectPoint)& ent,
46 const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
48 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
51 Standard_Integer tempTypeFlag, tempFunctionFlag;
52 Standard_Integer tempPointIdentifier, tempFunctionCode, tempSwapFlag;
53 Handle(IGESData_IGESEntity) tempDisplaySymbol, tempOwnerSubfigure;
54 Handle(TCollection_HAsciiString) tempFunctionIdentifier, tempFunctionName;
55 Handle(IGESGraph_TextDisplayTemplate) tempFunctionTemplate;
56 Handle(IGESGraph_TextDisplayTemplate) tempIdentifierTemplate;
58 PR.ReadXYZ(PR.CurrentList(1, 3), "Connect Point Coordinate", tempPoint); //szv#4:S4163:12Mar99 `st=` not needed
60 PR.ReadEntity(IR, PR.Current(), "Display Symbol Geometry Entity",
61 tempDisplaySymbol,Standard_True); //szv#4:S4163:12Mar99 `st=` not needed
63 PR.ReadInteger(PR.Current(), "Type Flag", tempTypeFlag); //szv#4:S4163:12Mar99 `st=` not needed
65 PR.ReadInteger(PR.Current(), "Function Flag", tempFunctionFlag); //szv#4:S4163:12Mar99 `st=` not needed
67 PR.ReadText(PR.Current(), "Function Identifier",
68 tempFunctionIdentifier); //szv#4:S4163:12Mar99 `st=` not needed
70 PR.ReadEntity(IR, PR.Current(), "Text Display Identifier Template",
71 STANDARD_TYPE(IGESGraph_TextDisplayTemplate), tempIdentifierTemplate,
72 Standard_True); //szv#4:S4163:12Mar99 `st=` not needed
74 PR.ReadText(PR.Current(), "Connect Point Function Name",
75 tempFunctionName); //szv#4:S4163:12Mar99 `st=` not needed
77 PR.ReadEntity(IR, PR.Current(), "Text Display Function Template",
78 STANDARD_TYPE(IGESGraph_TextDisplayTemplate), tempFunctionTemplate,
79 Standard_True); //szv#4:S4163:12Mar99 `st=` not needed
81 PR.ReadInteger(PR.Current(), "Unique Connect Point Identifier",
82 tempPointIdentifier); //szv#4:S4163:12Mar99 `st=` not needed
84 PR.ReadInteger(PR.Current(), "Connect Point Function Code",
85 tempFunctionCode); //szv#4:S4163:12Mar99 `st=` not needed
87 if (PR.DefinedElseSkip())
88 PR.ReadInteger(PR.Current(), "Swap Flag", tempSwapFlag); //szv#4:S4163:12Mar99 `st=` not needed
89 else tempSwapFlag = 0; // default
91 PR.ReadEntity(IR, PR.Current(), "Owner Network Subfigure Entity",
92 tempOwnerSubfigure,Standard_True); //szv#4:S4163:12Mar99 `st=` not needed
94 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
96 (tempPoint, tempDisplaySymbol, tempTypeFlag, tempFunctionFlag,
97 tempFunctionIdentifier, tempIdentifierTemplate, tempFunctionName,
98 tempFunctionTemplate, tempPointIdentifier, tempFunctionCode,
99 tempSwapFlag, tempOwnerSubfigure);
102 void IGESDraw_ToolConnectPoint::WriteOwnParams
103 (const Handle(IGESDraw_ConnectPoint)& ent, IGESData_IGESWriter& IW) const
105 IW.Send(ent->Point().X());
106 IW.Send(ent->Point().Y());
107 IW.Send(ent->Point().Z());
108 IW.Send(ent->DisplaySymbol());
109 IW.Send(ent->TypeFlag());
110 IW.Send(ent->FunctionFlag());
111 IW.Send(ent->FunctionIdentifier());
112 IW.Send(ent->IdentifierTemplate());
113 IW.Send(ent->FunctionName());
114 IW.Send(ent->FunctionTemplate());
115 IW.Send(ent->PointIdentifier());
116 IW.Send(ent->FunctionCode());
117 IW.SendBoolean(ent->SwapFlag());
118 IW.Send(ent->OwnerSubfigure());
121 void IGESDraw_ToolConnectPoint::OwnShared
122 (const Handle(IGESDraw_ConnectPoint)& ent, Interface_EntityIterator& iter) const
124 iter.GetOneItem(ent->DisplaySymbol());
125 iter.GetOneItem(ent->IdentifierTemplate());
126 iter.GetOneItem(ent->FunctionTemplate());
127 iter.GetOneItem(ent->OwnerSubfigure());
130 void IGESDraw_ToolConnectPoint::OwnCopy
131 (const Handle(IGESDraw_ConnectPoint)& another,
132 const Handle(IGESDraw_ConnectPoint)& ent, Interface_CopyTool& TC) const
134 gp_XYZ tempPoint = (another->Point()).XYZ();
135 DeclareAndCast(IGESData_IGESEntity, tempDisplaySymbol,
136 TC.Transferred(another->DisplaySymbol()));
137 Standard_Integer tempTypeFlag = another->TypeFlag();
138 Standard_Integer tempFunctionFlag = another->FunctionFlag();
139 Handle(TCollection_HAsciiString) tempFunctionIdentifier =
140 new TCollection_HAsciiString(another->FunctionIdentifier());
141 DeclareAndCast(IGESGraph_TextDisplayTemplate, tempIdentifierTemplate,
142 TC.Transferred(another->FunctionTemplate()));
143 Handle(TCollection_HAsciiString) tempFunctionName =
144 new TCollection_HAsciiString(another->FunctionName());
145 DeclareAndCast(IGESGraph_TextDisplayTemplate, tempFunctionTemplate,
146 TC.Transferred(another->FunctionTemplate()));
147 Standard_Integer tempPointIdentifier = another->PointIdentifier();
148 Standard_Integer tempFunctionCode = another->FunctionCode();
149 Standard_Integer tempSwapFlag = (another->SwapFlag() ? 1 : 0);
150 DeclareAndCast(IGESData_IGESEntity, tempOwnerSubfigure,
151 TC.Transferred(another->OwnerSubfigure()));
153 ent->Init(tempPoint, tempDisplaySymbol, tempTypeFlag, tempFunctionFlag,
154 tempFunctionIdentifier, tempIdentifierTemplate, tempFunctionName,
155 tempFunctionTemplate, tempPointIdentifier, tempFunctionCode,
156 tempSwapFlag, tempOwnerSubfigure);
159 IGESData_DirChecker IGESDraw_ToolConnectPoint::DirChecker
160 (const Handle(IGESDraw_ConnectPoint)& ent ) const
162 IGESData_DirChecker DC(132, 0);
163 DC.Structure(IGESData_DefVoid);
164 DC.Color(IGESData_DefAny);
165 DC.UseFlagRequired(4);
166 if (!ent->DisplaySymbol().IsNull()) {
167 DC.LineFont(IGESData_DefAny);
168 DC.LineWeight(IGESData_DefAny);
171 // Note : If ent->DisplaySymbol() is NULL Handle; ignore Line Font, Weight
172 // and Hierarchy Status
173 DC.LineFont(IGESData_DefVoid);
174 DC.LineWeight(IGESData_DefVoid);
175 DC.HierarchyStatusIgnored();
181 void IGESDraw_ToolConnectPoint::OwnCheck
182 (const Handle(IGESDraw_ConnectPoint)& ent,
183 const Interface_ShareTool& , Handle(Interface_Check)& ach) const
185 if ((ent->TypeFlag() < 0) || (ent->TypeFlag() > 9999) ||
186 ((ent->TypeFlag() > 2) && (ent->TypeFlag() < 101)) ||
187 ((ent->TypeFlag() > 104) && (ent->TypeFlag() < 201)) ||
188 ((ent->TypeFlag() > 203) && (ent->TypeFlag() < 5001)))
189 ach->AddFail("TypeFlag has Invalid value");
191 if ((ent->FunctionFlag() < 0) || (ent->FunctionFlag() > 2))
192 ach->AddFail("FunctionFlag has Invalid value");
194 if ((ent->FunctionCode() < 0) || (ent->FunctionCode() > 9999) ||
195 ((ent->FunctionCode() > 49) && (ent->FunctionCode() < 98)) ||
196 ((ent->FunctionCode() > 99) && (ent->FunctionCode() < 5001)))
197 ach->AddFail("FunctionCode has Invalid value");
199 //if ((ent->SwapFlag() < 0) || (ent->SwapFlag() > 1)) //szv#4:S4163:12Mar99 SGI warns
200 if ((ent->SwapFlag() != 0) && (ent->SwapFlag() != 1))
201 ach->AddFail("SwapFlag has Invalid value");
204 void IGESDraw_ToolConnectPoint::OwnDump
205 (const Handle(IGESDraw_ConnectPoint)& ent, const IGESData_IGESDumper& dumper,
206 Standard_OStream& S, const Standard_Integer level) const
208 Standard_Integer tempSubLevel = (level <= 4) ? 0 : 1;
210 S << "IGESDraw_ConnectPoint\n"
211 << "Connection Point Coordinate : ";
212 IGESData_DumpXYZL(S, level, ent->Point(), ent->Location());
213 S << "Display Symbol Geometry Entity : ";
214 dumper.Dump(ent->DisplaySymbol(),S, tempSubLevel);
216 << "Type Flag : " << ent->TypeFlag() << " "
217 << "Function Flag : " << ent->FunctionFlag() << "\n"
218 << "Function Identifier : ";
219 IGESData_DumpString(S,ent->FunctionIdentifier());
220 S << "\nText Display Template Entity for CID : ";
221 dumper.Dump(ent->IdentifierTemplate(),S, tempSubLevel);
222 S << "\nFunction Name : ";
223 IGESData_DumpString(S,ent->FunctionName());
224 S << "\nText Display Template Entity for CFN : ";
225 dumper.Dump(ent->FunctionTemplate(),S, tempSubLevel);
227 << "Point Identifier : " << ent->PointIdentifier() << "\n"
228 << "Function Code : " << ent->FunctionCode()
229 << "Swap Flag : " << ( ent->SwapFlag() ? "True" : "False" ) << "\n"
230 << "Owner Subfigure Entity : ";
231 dumper.Dump(ent->OwnerSubfigure(),S, tempSubLevel);