973c2be1 |
1 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
2 | // |
973c2be1 |
3 | // This file is part of Open CASCADE Technology software library. |
b311480e |
4 | // |
d5f74e42 |
5 | // This library is free software; you can redistribute it and/or modify it under |
6 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
7 | // by the Free Software Foundation, with special exception defined in the file |
8 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
9 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
10 | // |
973c2be1 |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
b311480e |
13 | |
7fd59977 |
14 | |
42cf5bc1 |
15 | #include <IFSelect_AppliedModifiers.hxx> |
16 | #include <IFSelect_ContextWrite.hxx> |
17 | #include <IFSelect_GeneralModifier.hxx> |
18 | #include <Interface_Check.hxx> |
19 | #include <Interface_CheckIterator.hxx> |
20 | #include <Interface_Graph.hxx> |
21 | #include <Interface_HGraph.hxx> |
22 | #include <Interface_InterfaceModel.hxx> |
23 | #include <Interface_Protocol.hxx> |
24 | #include <Standard_NoSuchObject.hxx> |
25 | #include <Standard_Transient.hxx> |
7fd59977 |
26 | |
27 | //======================================================================= |
28 | //function : IFSelect_ContextWrite |
29 | //purpose : |
30 | //======================================================================= |
7fd59977 |
31 | IFSelect_ContextWrite::IFSelect_ContextWrite |
32 | (const Handle(Interface_InterfaceModel)& model, |
33 | const Handle(Interface_Protocol)& proto, |
34 | const Handle(IFSelect_AppliedModifiers)& applieds, |
35 | const Standard_CString filename) |
36 | : themodel (model) , theproto (proto) , thefile (filename) , |
37 | theapply (applieds) , thenumod(0) , thenbent (0) , thecurr (0) { } |
38 | |
39 | |
40 | //======================================================================= |
41 | //function : IFSelect_ContextWrite |
42 | //purpose : |
43 | //======================================================================= |
44 | |
45 | IFSelect_ContextWrite::IFSelect_ContextWrite |
46 | (const Handle(Interface_HGraph)& hgraph, |
47 | const Handle(Interface_Protocol)& proto, |
48 | const Handle(IFSelect_AppliedModifiers)& applieds, |
49 | const Standard_CString filename) |
50 | : themodel (hgraph->Graph().Model()) , |
51 | theproto (proto) , thefile (filename) , theapply (applieds) , |
52 | thehgraf (hgraph) , thenumod(0) , thenbent (0) , thecurr (0) { } |
53 | |
54 | |
55 | //======================================================================= |
56 | //function : Model |
57 | //purpose : |
58 | //======================================================================= |
59 | |
60 | Handle(Interface_InterfaceModel) IFSelect_ContextWrite::Model () const |
61 | { |
62 | return themodel; |
63 | } |
64 | |
65 | |
66 | //======================================================================= |
67 | //function : Protocol |
68 | //purpose : |
69 | //======================================================================= |
70 | |
71 | Handle(Interface_Protocol) IFSelect_ContextWrite::Protocol () const |
72 | { |
73 | return theproto; |
74 | } |
75 | |
76 | |
77 | //======================================================================= |
78 | //function : FileName |
79 | //purpose : |
80 | //======================================================================= |
81 | |
82 | Standard_CString IFSelect_ContextWrite::FileName () const |
83 | { |
84 | return thefile.ToCString(); |
85 | } |
86 | |
87 | |
88 | //======================================================================= |
89 | //function : AppliedModifiers |
90 | //purpose : |
91 | //======================================================================= |
92 | |
93 | Handle(IFSelect_AppliedModifiers) IFSelect_ContextWrite::AppliedModifiers () const |
94 | { |
95 | return theapply; |
96 | } |
97 | |
98 | |
99 | //======================================================================= |
100 | //function : Graph |
101 | //purpose : |
102 | //======================================================================= |
103 | |
104 | const Interface_Graph& IFSelect_ContextWrite::Graph () |
105 | { |
106 | if (thehgraf.IsNull()) thehgraf = new Interface_HGraph(themodel,theproto); |
107 | return thehgraf->Graph(); |
108 | } |
109 | |
110 | |
111 | //======================================================================= |
112 | //function : NbModifiers |
113 | //purpose : |
114 | //======================================================================= |
115 | |
116 | Standard_Integer IFSelect_ContextWrite::NbModifiers () const |
117 | { return (theapply.IsNull() ? 0 : theapply->Count()); } |
118 | |
119 | Standard_Boolean IFSelect_ContextWrite::SetModifier |
120 | (const Standard_Integer numod) |
121 | { |
122 | themodif.Nullify(); thenumod = thenbent = thecurr = 0; |
123 | if (theapply.IsNull()) return Standard_False; |
124 | if (numod < 1 || numod > theapply->Count()) return Standard_False; |
125 | theapply->Item(numod,themodif,thenbent); |
126 | return Standard_True; |
127 | } |
128 | |
129 | |
130 | //======================================================================= |
131 | //function : FileModifier |
132 | //purpose : |
133 | //======================================================================= |
134 | |
135 | Handle(IFSelect_GeneralModifier) IFSelect_ContextWrite::FileModifier () const |
136 | { |
137 | return themodif; |
138 | } |
139 | |
140 | |
141 | //======================================================================= |
142 | //function : IsForNone |
143 | //purpose : |
144 | //======================================================================= |
145 | |
146 | Standard_Boolean IFSelect_ContextWrite::IsForNone () const |
147 | { |
148 | return (thenbent == 0); |
149 | } |
150 | |
151 | |
152 | //======================================================================= |
153 | //function : IsForAll |
154 | //purpose : |
155 | //======================================================================= |
156 | |
157 | Standard_Boolean IFSelect_ContextWrite::IsForAll () const |
158 | { |
159 | return theapply->IsForAll(); |
160 | } |
161 | |
162 | |
163 | //======================================================================= |
164 | //function : NbEntities |
165 | //purpose : |
166 | //======================================================================= |
167 | |
168 | Standard_Integer IFSelect_ContextWrite::NbEntities () const |
169 | { |
170 | return thenbent; |
171 | } |
172 | |
173 | |
174 | //======================================================================= |
175 | //function : Start |
176 | //purpose : |
177 | //======================================================================= |
178 | |
179 | void IFSelect_ContextWrite::Start () |
180 | { |
181 | thecurr = 1; |
182 | } |
183 | |
184 | |
185 | //======================================================================= |
186 | //function : More |
187 | //purpose : |
188 | //======================================================================= |
189 | |
190 | Standard_Boolean IFSelect_ContextWrite::More () const |
191 | { |
192 | return (thecurr <= thenbent); |
193 | } |
194 | |
195 | |
196 | //======================================================================= |
197 | //function : Next |
198 | //purpose : |
199 | //======================================================================= |
200 | |
201 | void IFSelect_ContextWrite::Next () |
202 | { |
203 | thecurr ++; |
204 | } |
205 | |
206 | |
207 | //======================================================================= |
208 | //function : Value |
209 | //purpose : |
210 | //======================================================================= |
211 | |
212 | Handle(Standard_Transient) IFSelect_ContextWrite::Value() const |
213 | { |
214 | if (thecurr < 1 || thecurr > thenbent) |
215 | Standard_NoSuchObject::Raise("IFSelect_ContextWrite:Value"); |
216 | Standard_Integer num = theapply->ItemNum (thecurr); |
217 | return themodel->Value(num); |
218 | } |
219 | |
220 | |
221 | //======================================================================= |
222 | //function : AddCheck |
223 | //purpose : |
224 | //======================================================================= |
225 | |
226 | void IFSelect_ContextWrite::AddCheck (const Handle(Interface_Check)& check) |
227 | { |
228 | if (check->NbFails() + check->NbWarnings() == 0) return; |
229 | const Handle(Standard_Transient)& ent = check->Entity(); |
230 | Standard_Integer num = themodel->Number(ent); |
231 | if (num == 0 && !ent.IsNull()) num = -1; // force enregistrement |
232 | thecheck.Add(check,num); |
233 | } |
234 | |
235 | |
236 | //======================================================================= |
237 | //function : AddWarning |
238 | //purpose : |
239 | //======================================================================= |
240 | |
241 | void IFSelect_ContextWrite::AddWarning(const Handle(Standard_Transient)& start, |
242 | const Standard_CString mess, |
243 | const Standard_CString orig) |
244 | { |
245 | thecheck.CCheck(themodel->Number(start))->AddWarning(mess,orig); |
246 | } |
247 | |
248 | |
249 | //======================================================================= |
250 | //function : AddFail |
251 | //purpose : |
252 | //======================================================================= |
253 | |
254 | void IFSelect_ContextWrite::AddFail(const Handle(Standard_Transient)& start, |
255 | const Standard_CString mess, |
256 | const Standard_CString orig) |
257 | { |
258 | thecheck.CCheck(themodel->Number(start))->AddFail(mess,orig); |
259 | } |
260 | |
261 | |
262 | //======================================================================= |
263 | //function : CCheck |
264 | //purpose : |
265 | //======================================================================= |
266 | |
267 | Handle(Interface_Check) IFSelect_ContextWrite::CCheck (const Standard_Integer num) |
268 | { |
269 | Handle(Interface_Check) ach = thecheck.CCheck(num); |
270 | if (num > 0 && num <= themodel->NbEntities()) ach->SetEntity(themodel->Value(num)); |
271 | return ach; |
272 | } |
273 | |
274 | |
275 | //======================================================================= |
276 | //function : CCheck |
277 | //purpose : |
278 | //======================================================================= |
279 | |
280 | Handle(Interface_Check) IFSelect_ContextWrite::CCheck(const Handle(Standard_Transient)& ent) |
281 | { |
282 | Standard_Integer num = themodel->Number(ent); |
283 | if (num == 0) num = -1; // force l enregistrement |
284 | Handle(Interface_Check) ach = thecheck.CCheck(num); |
285 | ach->SetEntity(ent); |
286 | return ach; |
287 | } |
288 | |
289 | |
290 | //======================================================================= |
291 | //function : CheckList |
292 | //purpose : |
293 | //======================================================================= |
294 | |
295 | Interface_CheckIterator IFSelect_ContextWrite::CheckList () const |
296 | { |
297 | return thecheck; |
298 | } |