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