summaryrefslogtreecommitdiff
path: root/src/IGESDraw/IGESDraw_ToolConnectPoint.cxx
blob: 3a3f22ef18fd10d30e2fc7eed6ab83a9c9a873db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
//--------------------------------------------------------------------
//
//  File Name : IGESDraw_ConnectPoint.cxx
//  Date      :
//  Author    : CKY / Contract Toubro-Larsen
//  Copyright : MATRA-DATAVISION 1993
//
//--------------------------------------------------------------------

#include <IGESDraw_ToolConnectPoint.ixx>
#include <IGESData_ParamCursor.hxx>
#include <gp_XYZ.hxx>
#include <gp_Pnt.hxx>
#include <IGESData_IGESEntity.hxx>
#include <IGESGraph_TextDisplayTemplate.hxx>
#include <TCollection_HAsciiString.hxx>
#include <IGESData_Dump.hxx>
#include <Interface_Macros.hxx>


IGESDraw_ToolConnectPoint::IGESDraw_ToolConnectPoint ()    {  }


void IGESDraw_ToolConnectPoint::ReadOwnParams
  (const Handle(IGESDraw_ConnectPoint)& ent,
   const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
{
  //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed

  gp_XYZ tempPoint;
  Standard_Integer tempTypeFlag, tempFunctionFlag;
  Standard_Integer tempPointIdentifier, tempFunctionCode, tempSwapFlag;
  Handle(IGESData_IGESEntity) tempDisplaySymbol, tempOwnerSubfigure;
  Handle(TCollection_HAsciiString) tempFunctionIdentifier, tempFunctionName;
  Handle(IGESGraph_TextDisplayTemplate) tempFunctionTemplate;
  Handle(IGESGraph_TextDisplayTemplate) tempIdentifierTemplate;

  PR.ReadXYZ(PR.CurrentList(1, 3), "Connect Point Coordinate", tempPoint); //szv#4:S4163:12Mar99 `st=` not needed

  PR.ReadEntity(IR, PR.Current(), "Display Symbol Geometry Entity",
		tempDisplaySymbol,Standard_True); //szv#4:S4163:12Mar99 `st=` not needed

  PR.ReadInteger(PR.Current(), "Type Flag", tempTypeFlag); //szv#4:S4163:12Mar99 `st=` not needed

  PR.ReadInteger(PR.Current(), "Function Flag", tempFunctionFlag); //szv#4:S4163:12Mar99 `st=` not needed

  PR.ReadText(PR.Current(), "Function Identifier",
	      tempFunctionIdentifier); //szv#4:S4163:12Mar99 `st=` not needed

  PR.ReadEntity(IR, PR.Current(), "Text Display Identifier Template",
		STANDARD_TYPE(IGESGraph_TextDisplayTemplate), tempIdentifierTemplate,
		Standard_True); //szv#4:S4163:12Mar99 `st=` not needed

  PR.ReadText(PR.Current(), "Connect Point Function Name",
	      tempFunctionName); //szv#4:S4163:12Mar99 `st=` not needed

  PR.ReadEntity(IR, PR.Current(), "Text Display Function Template",
		STANDARD_TYPE(IGESGraph_TextDisplayTemplate), tempFunctionTemplate,
		Standard_True); //szv#4:S4163:12Mar99 `st=` not needed

  PR.ReadInteger(PR.Current(), "Unique Connect Point Identifier",
		 tempPointIdentifier); //szv#4:S4163:12Mar99 `st=` not needed

  PR.ReadInteger(PR.Current(), "Connect Point Function Code",
		 tempFunctionCode); //szv#4:S4163:12Mar99 `st=` not needed

  if (PR.DefinedElseSkip())
    PR.ReadInteger(PR.Current(), "Swap Flag", tempSwapFlag); //szv#4:S4163:12Mar99 `st=` not needed
  else tempSwapFlag = 0;  // default

  PR.ReadEntity(IR, PR.Current(), "Owner Network Subfigure Entity",
		tempOwnerSubfigure,Standard_True); //szv#4:S4163:12Mar99 `st=` not needed

  DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
  ent->Init
    (tempPoint, tempDisplaySymbol, tempTypeFlag, tempFunctionFlag,
     tempFunctionIdentifier, tempIdentifierTemplate, tempFunctionName,
     tempFunctionTemplate, tempPointIdentifier, tempFunctionCode,
     tempSwapFlag, tempOwnerSubfigure);
}

void IGESDraw_ToolConnectPoint::WriteOwnParams
  (const Handle(IGESDraw_ConnectPoint)& ent, IGESData_IGESWriter& IW)  const
{
  IW.Send(ent->Point().X());
  IW.Send(ent->Point().Y());
  IW.Send(ent->Point().Z());
  IW.Send(ent->DisplaySymbol());
  IW.Send(ent->TypeFlag());
  IW.Send(ent->FunctionFlag());
  IW.Send(ent->FunctionIdentifier());
  IW.Send(ent->IdentifierTemplate());
  IW.Send(ent->FunctionName());
  IW.Send(ent->FunctionTemplate());
  IW.Send(ent->PointIdentifier());
  IW.Send(ent->FunctionCode());
  IW.SendBoolean(ent->SwapFlag());
  IW.Send(ent->OwnerSubfigure());
}

void  IGESDraw_ToolConnectPoint::OwnShared
  (const Handle(IGESDraw_ConnectPoint)& ent, Interface_EntityIterator& iter) const
{
  iter.GetOneItem(ent->DisplaySymbol());
  iter.GetOneItem(ent->IdentifierTemplate());
  iter.GetOneItem(ent->FunctionTemplate());
  iter.GetOneItem(ent->OwnerSubfigure());
}

void IGESDraw_ToolConnectPoint::OwnCopy
  (const Handle(IGESDraw_ConnectPoint)& another,
   const Handle(IGESDraw_ConnectPoint)& ent, Interface_CopyTool& TC) const
{
  gp_XYZ tempPoint = (another->Point()).XYZ();
  DeclareAndCast(IGESData_IGESEntity, tempDisplaySymbol,
                 TC.Transferred(another->DisplaySymbol()));
  Standard_Integer tempTypeFlag     = another->TypeFlag();
  Standard_Integer tempFunctionFlag = another->FunctionFlag();
  Handle(TCollection_HAsciiString) tempFunctionIdentifier =
    new TCollection_HAsciiString(another->FunctionIdentifier());
  DeclareAndCast(IGESGraph_TextDisplayTemplate, tempIdentifierTemplate,
                 TC.Transferred(another->FunctionTemplate()));
  Handle(TCollection_HAsciiString) tempFunctionName =
    new TCollection_HAsciiString(another->FunctionName());
  DeclareAndCast(IGESGraph_TextDisplayTemplate, tempFunctionTemplate,
                 TC.Transferred(another->FunctionTemplate()));
  Standard_Integer tempPointIdentifier = another->PointIdentifier();
  Standard_Integer tempFunctionCode    = another->FunctionCode();
  Standard_Integer tempSwapFlag        = (another->SwapFlag() ? 1 : 0);
  DeclareAndCast(IGESData_IGESEntity, tempOwnerSubfigure,
                 TC.Transferred(another->OwnerSubfigure()));

  ent->Init(tempPoint, tempDisplaySymbol, tempTypeFlag, tempFunctionFlag,
	    tempFunctionIdentifier, tempIdentifierTemplate, tempFunctionName,
	    tempFunctionTemplate, tempPointIdentifier, tempFunctionCode,
	    tempSwapFlag, tempOwnerSubfigure);
}

IGESData_DirChecker IGESDraw_ToolConnectPoint::DirChecker
  (const Handle(IGESDraw_ConnectPoint)& ent )  const
{
  IGESData_DirChecker DC(132, 0);
  DC.Structure(IGESData_DefVoid);
  DC.Color(IGESData_DefAny);
  DC.UseFlagRequired(4);
  if (!ent->DisplaySymbol().IsNull()) {
    DC.LineFont(IGESData_DefAny);
    DC.LineWeight(IGESData_DefAny);
  }
  else {
    // Note : If ent->DisplaySymbol() is NULL Handle; ignore Line Font, Weight
    //        and Hierarchy Status
    DC.LineFont(IGESData_DefVoid);
    DC.LineWeight(IGESData_DefVoid);
    DC.HierarchyStatusIgnored();
  }

  return DC;
}

void IGESDraw_ToolConnectPoint::OwnCheck
  (const Handle(IGESDraw_ConnectPoint)& ent,
   const Interface_ShareTool& , Handle(Interface_Check)& ach)  const
{
  if ((ent->TypeFlag() <   0) || (ent->TypeFlag() > 9999)  ||
      ((ent->TypeFlag() >   2) && (ent->TypeFlag() <  101)) ||
      ((ent->TypeFlag() > 104) && (ent->TypeFlag() <  201)) ||
      ((ent->TypeFlag() > 203) && (ent->TypeFlag() < 5001)))
    ach->AddFail("TypeFlag has Invalid value");

  if ((ent->FunctionFlag() < 0) || (ent->FunctionFlag() > 2))
    ach->AddFail("FunctionFlag has Invalid value");

  if ((ent->FunctionCode() <  0) || (ent->FunctionCode() > 9999)  ||
      ((ent->FunctionCode() > 49) && (ent->FunctionCode() <   98)) ||
      ((ent->FunctionCode() > 99) && (ent->FunctionCode() < 5001)))
    ach->AddFail("FunctionCode has Invalid value");

  //if ((ent->SwapFlag() < 0) || (ent->SwapFlag() > 1)) //szv#4:S4163:12Mar99 SGI warns
  if ((ent->SwapFlag() != 0) && (ent->SwapFlag() != 1))
    ach->AddFail("SwapFlag has Invalid value");
}

void IGESDraw_ToolConnectPoint::OwnDump
  (const Handle(IGESDraw_ConnectPoint)& ent, const IGESData_IGESDumper& dumper,
   const Handle(Message_Messenger)& S, const Standard_Integer level)  const
{
  Standard_Integer tempSubLevel = (level <= 4) ? 0 : 1;

  S << "IGESDraw_ConnectPoint" << endl;

  S << "Connection Point Coordinate : ";
  IGESData_DumpXYZL(S, level, ent->Point(), ent->Location());
  S << "Display Symbol Geometry Entity : ";
  dumper.Dump(ent->DisplaySymbol(),S, tempSubLevel);
  S << endl;
  S << "Type Flag : "     << ent->TypeFlag() << "  "
    << "Function Flag : " << ent->FunctionFlag() << endl;
  S << "Function Identifier : ";
  IGESData_DumpString(S,ent->FunctionIdentifier());
  S << endl << "Text Display Template Entity for CID : ";
  dumper.Dump(ent->IdentifierTemplate(),S, tempSubLevel);
  S << endl << "Function Name : ";
  IGESData_DumpString(S,ent->FunctionName());
  S << endl << "Text Display Template Entity for CFN : ";
  dumper.Dump(ent->FunctionTemplate(),S, tempSubLevel);
  S << endl;
  S << "Point Identifier : " << ent->PointIdentifier() << endl
    << "Function Code : "    << ent->FunctionCode()
    << "Swap Flag : "        << ( ent->SwapFlag() ? "True" : "False" ) << endl;
  S << "Owner Subfigure Entity : ";
  dumper.Dump(ent->OwnerSubfigure(),S, tempSubLevel);
  S << endl;
}