1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
18 #include <IFSelect_ContextWrite.ixx>
19 #include <Standard_NoSuchObject.hxx>
22 //=======================================================================
23 //function : IFSelect_ContextWrite
25 //=======================================================================
27 IFSelect_ContextWrite::IFSelect_ContextWrite
28 (const Handle(Interface_InterfaceModel)& model,
29 const Handle(Interface_Protocol)& proto,
30 const Handle(IFSelect_AppliedModifiers)& applieds,
31 const Standard_CString filename)
32 : themodel (model) , theproto (proto) , thefile (filename) ,
33 theapply (applieds) , thenumod(0) , thenbent (0) , thecurr (0) { }
36 //=======================================================================
37 //function : IFSelect_ContextWrite
39 //=======================================================================
41 IFSelect_ContextWrite::IFSelect_ContextWrite
42 (const Handle(Interface_HGraph)& hgraph,
43 const Handle(Interface_Protocol)& proto,
44 const Handle(IFSelect_AppliedModifiers)& applieds,
45 const Standard_CString filename)
46 : themodel (hgraph->Graph().Model()) ,
47 theproto (proto) , thefile (filename) , theapply (applieds) ,
48 thehgraf (hgraph) , thenumod(0) , thenbent (0) , thecurr (0) { }
51 //=======================================================================
54 //=======================================================================
56 Handle(Interface_InterfaceModel) IFSelect_ContextWrite::Model () const
62 //=======================================================================
65 //=======================================================================
67 Handle(Interface_Protocol) IFSelect_ContextWrite::Protocol () const
73 //=======================================================================
76 //=======================================================================
78 Standard_CString IFSelect_ContextWrite::FileName () const
80 return thefile.ToCString();
84 //=======================================================================
85 //function : AppliedModifiers
87 //=======================================================================
89 Handle(IFSelect_AppliedModifiers) IFSelect_ContextWrite::AppliedModifiers () const
95 //=======================================================================
98 //=======================================================================
100 const Interface_Graph& IFSelect_ContextWrite::Graph ()
102 if (thehgraf.IsNull()) thehgraf = new Interface_HGraph(themodel,theproto);
103 return thehgraf->Graph();
107 //=======================================================================
108 //function : NbModifiers
110 //=======================================================================
112 Standard_Integer IFSelect_ContextWrite::NbModifiers () const
113 { return (theapply.IsNull() ? 0 : theapply->Count()); }
115 Standard_Boolean IFSelect_ContextWrite::SetModifier
116 (const Standard_Integer numod)
118 themodif.Nullify(); thenumod = thenbent = thecurr = 0;
119 if (theapply.IsNull()) return Standard_False;
120 if (numod < 1 || numod > theapply->Count()) return Standard_False;
121 theapply->Item(numod,themodif,thenbent);
122 return Standard_True;
126 //=======================================================================
127 //function : FileModifier
129 //=======================================================================
131 Handle(IFSelect_GeneralModifier) IFSelect_ContextWrite::FileModifier () const
137 //=======================================================================
138 //function : IsForNone
140 //=======================================================================
142 Standard_Boolean IFSelect_ContextWrite::IsForNone () const
144 return (thenbent == 0);
148 //=======================================================================
149 //function : IsForAll
151 //=======================================================================
153 Standard_Boolean IFSelect_ContextWrite::IsForAll () const
155 return theapply->IsForAll();
159 //=======================================================================
160 //function : NbEntities
162 //=======================================================================
164 Standard_Integer IFSelect_ContextWrite::NbEntities () const
170 //=======================================================================
173 //=======================================================================
175 void IFSelect_ContextWrite::Start ()
181 //=======================================================================
184 //=======================================================================
186 Standard_Boolean IFSelect_ContextWrite::More () const
188 return (thecurr <= thenbent);
192 //=======================================================================
195 //=======================================================================
197 void IFSelect_ContextWrite::Next ()
203 //=======================================================================
206 //=======================================================================
208 Handle(Standard_Transient) IFSelect_ContextWrite::Value() const
210 if (thecurr < 1 || thecurr > thenbent)
211 Standard_NoSuchObject::Raise("IFSelect_ContextWrite:Value");
212 Standard_Integer num = theapply->ItemNum (thecurr);
213 return themodel->Value(num);
217 //=======================================================================
218 //function : AddCheck
220 //=======================================================================
222 void IFSelect_ContextWrite::AddCheck (const Handle(Interface_Check)& check)
224 if (check->NbFails() + check->NbWarnings() == 0) return;
225 const Handle(Standard_Transient)& ent = check->Entity();
226 Standard_Integer num = themodel->Number(ent);
227 if (num == 0 && !ent.IsNull()) num = -1; // force enregistrement
228 thecheck.Add(check,num);
232 //=======================================================================
233 //function : AddWarning
235 //=======================================================================
237 void IFSelect_ContextWrite::AddWarning(const Handle(Standard_Transient)& start,
238 const Standard_CString mess,
239 const Standard_CString orig)
241 thecheck.CCheck(themodel->Number(start))->AddWarning(mess,orig);
245 //=======================================================================
248 //=======================================================================
250 void IFSelect_ContextWrite::AddFail(const Handle(Standard_Transient)& start,
251 const Standard_CString mess,
252 const Standard_CString orig)
254 thecheck.CCheck(themodel->Number(start))->AddFail(mess,orig);
258 //=======================================================================
261 //=======================================================================
263 Handle(Interface_Check) IFSelect_ContextWrite::CCheck (const Standard_Integer num)
265 Handle(Interface_Check) ach = thecheck.CCheck(num);
266 if (num > 0 && num <= themodel->NbEntities()) ach->SetEntity(themodel->Value(num));
271 //=======================================================================
274 //=======================================================================
276 Handle(Interface_Check) IFSelect_ContextWrite::CCheck(const Handle(Standard_Transient)& ent)
278 Standard_Integer num = themodel->Number(ent);
279 if (num == 0) num = -1; // force l enregistrement
280 Handle(Interface_Check) ach = thecheck.CCheck(num);
286 //=======================================================================
287 //function : CheckList
289 //=======================================================================
291 Interface_CheckIterator IFSelect_ContextWrite::CheckList () const