0022627: Change OCCT memory management defaults
[occt.git] / src / IFSelect / IFSelect_ContextWrite.cxx
CommitLineData
7fd59977 1#include <IFSelect_ContextWrite.ixx>
2#include <Standard_NoSuchObject.hxx>
3
4
5//=======================================================================
6//function : IFSelect_ContextWrite
7//purpose :
8//=======================================================================
9
10IFSelect_ContextWrite::IFSelect_ContextWrite
11 (const Handle(Interface_InterfaceModel)& model,
12 const Handle(Interface_Protocol)& proto,
13 const Handle(IFSelect_AppliedModifiers)& applieds,
14 const Standard_CString filename)
15 : themodel (model) , theproto (proto) , thefile (filename) ,
16 theapply (applieds) , thenumod(0) , thenbent (0) , thecurr (0) { }
17
18
19//=======================================================================
20//function : IFSelect_ContextWrite
21//purpose :
22//=======================================================================
23
24IFSelect_ContextWrite::IFSelect_ContextWrite
25 (const Handle(Interface_HGraph)& hgraph,
26 const Handle(Interface_Protocol)& proto,
27 const Handle(IFSelect_AppliedModifiers)& applieds,
28 const Standard_CString filename)
29 : themodel (hgraph->Graph().Model()) ,
30 theproto (proto) , thefile (filename) , theapply (applieds) ,
31 thehgraf (hgraph) , thenumod(0) , thenbent (0) , thecurr (0) { }
32
33
34//=======================================================================
35//function : Model
36//purpose :
37//=======================================================================
38
39Handle(Interface_InterfaceModel) IFSelect_ContextWrite::Model () const
40{
41 return themodel;
42}
43
44
45//=======================================================================
46//function : Protocol
47//purpose :
48//=======================================================================
49
50Handle(Interface_Protocol) IFSelect_ContextWrite::Protocol () const
51{
52 return theproto;
53}
54
55
56//=======================================================================
57//function : FileName
58//purpose :
59//=======================================================================
60
61Standard_CString IFSelect_ContextWrite::FileName () const
62{
63 return thefile.ToCString();
64}
65
66
67//=======================================================================
68//function : AppliedModifiers
69//purpose :
70//=======================================================================
71
72Handle(IFSelect_AppliedModifiers) IFSelect_ContextWrite::AppliedModifiers () const
73{
74 return theapply;
75}
76
77
78//=======================================================================
79//function : Graph
80//purpose :
81//=======================================================================
82
83const Interface_Graph& IFSelect_ContextWrite::Graph ()
84{
85 if (thehgraf.IsNull()) thehgraf = new Interface_HGraph(themodel,theproto);
86 return thehgraf->Graph();
87}
88
89
90//=======================================================================
91//function : NbModifiers
92//purpose :
93//=======================================================================
94
95Standard_Integer IFSelect_ContextWrite::NbModifiers () const
96 { return (theapply.IsNull() ? 0 : theapply->Count()); }
97
98 Standard_Boolean IFSelect_ContextWrite::SetModifier
99 (const Standard_Integer numod)
100{
101 themodif.Nullify(); thenumod = thenbent = thecurr = 0;
102 if (theapply.IsNull()) return Standard_False;
103 if (numod < 1 || numod > theapply->Count()) return Standard_False;
104 theapply->Item(numod,themodif,thenbent);
105 return Standard_True;
106}
107
108
109//=======================================================================
110//function : FileModifier
111//purpose :
112//=======================================================================
113
114Handle(IFSelect_GeneralModifier) IFSelect_ContextWrite::FileModifier () const
115{
116 return themodif;
117}
118
119
120//=======================================================================
121//function : IsForNone
122//purpose :
123//=======================================================================
124
125Standard_Boolean IFSelect_ContextWrite::IsForNone () const
126{
127 return (thenbent == 0);
128}
129
130
131//=======================================================================
132//function : IsForAll
133//purpose :
134//=======================================================================
135
136Standard_Boolean IFSelect_ContextWrite::IsForAll () const
137{
138 return theapply->IsForAll();
139}
140
141
142//=======================================================================
143//function : NbEntities
144//purpose :
145//=======================================================================
146
147Standard_Integer IFSelect_ContextWrite::NbEntities () const
148{
149 return thenbent;
150}
151
152
153//=======================================================================
154//function : Start
155//purpose :
156//=======================================================================
157
158void IFSelect_ContextWrite::Start ()
159{
160 thecurr = 1;
161}
162
163
164//=======================================================================
165//function : More
166//purpose :
167//=======================================================================
168
169Standard_Boolean IFSelect_ContextWrite::More () const
170{
171 return (thecurr <= thenbent);
172}
173
174
175//=======================================================================
176//function : Next
177//purpose :
178//=======================================================================
179
180void IFSelect_ContextWrite::Next ()
181{
182 thecurr ++;
183}
184
185
186//=======================================================================
187//function : Value
188//purpose :
189//=======================================================================
190
191Handle(Standard_Transient) IFSelect_ContextWrite::Value() const
192{
193 if (thecurr < 1 || thecurr > thenbent)
194 Standard_NoSuchObject::Raise("IFSelect_ContextWrite:Value");
195 Standard_Integer num = theapply->ItemNum (thecurr);
196 return themodel->Value(num);
197}
198
199
200//=======================================================================
201//function : AddCheck
202//purpose :
203//=======================================================================
204
205void IFSelect_ContextWrite::AddCheck (const Handle(Interface_Check)& check)
206{
207 if (check->NbFails() + check->NbWarnings() == 0) return;
208 const Handle(Standard_Transient)& ent = check->Entity();
209 Standard_Integer num = themodel->Number(ent);
210 if (num == 0 && !ent.IsNull()) num = -1; // force enregistrement
211 thecheck.Add(check,num);
212}
213
214
215//=======================================================================
216//function : AddWarning
217//purpose :
218//=======================================================================
219
220void IFSelect_ContextWrite::AddWarning(const Handle(Standard_Transient)& start,
221 const Standard_CString mess,
222 const Standard_CString orig)
223{
224 thecheck.CCheck(themodel->Number(start))->AddWarning(mess,orig);
225}
226
227
228//=======================================================================
229//function : AddFail
230//purpose :
231//=======================================================================
232
233void IFSelect_ContextWrite::AddFail(const Handle(Standard_Transient)& start,
234 const Standard_CString mess,
235 const Standard_CString orig)
236{
237 thecheck.CCheck(themodel->Number(start))->AddFail(mess,orig);
238}
239
240
241//=======================================================================
242//function : CCheck
243//purpose :
244//=======================================================================
245
246Handle(Interface_Check) IFSelect_ContextWrite::CCheck (const Standard_Integer num)
247{
248 Handle(Interface_Check) ach = thecheck.CCheck(num);
249 if (num > 0 && num <= themodel->NbEntities()) ach->SetEntity(themodel->Value(num));
250 return ach;
251}
252
253
254//=======================================================================
255//function : CCheck
256//purpose :
257//=======================================================================
258
259Handle(Interface_Check) IFSelect_ContextWrite::CCheck(const Handle(Standard_Transient)& ent)
260{
261 Standard_Integer num = themodel->Number(ent);
262 if (num == 0) num = -1; // force l enregistrement
263 Handle(Interface_Check) ach = thecheck.CCheck(num);
264 ach->SetEntity(ent);
265 return ach;
266}
267
268
269//=======================================================================
270//function : CheckList
271//purpose :
272//=======================================================================
273
274Interface_CheckIterator IFSelect_ContextWrite::CheckList () const
275{
276 return thecheck;
277}