1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #include <IFSelect_ContextWrite.ixx>
15 #include <Standard_NoSuchObject.hxx>
18 //=======================================================================
19 //function : IFSelect_ContextWrite
21 //=======================================================================
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) { }
32 //=======================================================================
33 //function : IFSelect_ContextWrite
35 //=======================================================================
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) { }
47 //=======================================================================
50 //=======================================================================
52 Handle(Interface_InterfaceModel) IFSelect_ContextWrite::Model () const
58 //=======================================================================
61 //=======================================================================
63 Handle(Interface_Protocol) IFSelect_ContextWrite::Protocol () const
69 //=======================================================================
72 //=======================================================================
74 Standard_CString IFSelect_ContextWrite::FileName () const
76 return thefile.ToCString();
80 //=======================================================================
81 //function : AppliedModifiers
83 //=======================================================================
85 Handle(IFSelect_AppliedModifiers) IFSelect_ContextWrite::AppliedModifiers () const
91 //=======================================================================
94 //=======================================================================
96 const Interface_Graph& IFSelect_ContextWrite::Graph ()
98 if (thehgraf.IsNull()) thehgraf = new Interface_HGraph(themodel,theproto);
99 return thehgraf->Graph();
103 //=======================================================================
104 //function : NbModifiers
106 //=======================================================================
108 Standard_Integer IFSelect_ContextWrite::NbModifiers () const
109 { return (theapply.IsNull() ? 0 : theapply->Count()); }
111 Standard_Boolean IFSelect_ContextWrite::SetModifier
112 (const Standard_Integer numod)
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;
122 //=======================================================================
123 //function : FileModifier
125 //=======================================================================
127 Handle(IFSelect_GeneralModifier) IFSelect_ContextWrite::FileModifier () const
133 //=======================================================================
134 //function : IsForNone
136 //=======================================================================
138 Standard_Boolean IFSelect_ContextWrite::IsForNone () const
140 return (thenbent == 0);
144 //=======================================================================
145 //function : IsForAll
147 //=======================================================================
149 Standard_Boolean IFSelect_ContextWrite::IsForAll () const
151 return theapply->IsForAll();
155 //=======================================================================
156 //function : NbEntities
158 //=======================================================================
160 Standard_Integer IFSelect_ContextWrite::NbEntities () const
166 //=======================================================================
169 //=======================================================================
171 void IFSelect_ContextWrite::Start ()
177 //=======================================================================
180 //=======================================================================
182 Standard_Boolean IFSelect_ContextWrite::More () const
184 return (thecurr <= thenbent);
188 //=======================================================================
191 //=======================================================================
193 void IFSelect_ContextWrite::Next ()
199 //=======================================================================
202 //=======================================================================
204 Handle(Standard_Transient) IFSelect_ContextWrite::Value() const
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);
213 //=======================================================================
214 //function : AddCheck
216 //=======================================================================
218 void IFSelect_ContextWrite::AddCheck (const Handle(Interface_Check)& check)
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);
228 //=======================================================================
229 //function : AddWarning
231 //=======================================================================
233 void IFSelect_ContextWrite::AddWarning(const Handle(Standard_Transient)& start,
234 const Standard_CString mess,
235 const Standard_CString orig)
237 thecheck.CCheck(themodel->Number(start))->AddWarning(mess,orig);
241 //=======================================================================
244 //=======================================================================
246 void IFSelect_ContextWrite::AddFail(const Handle(Standard_Transient)& start,
247 const Standard_CString mess,
248 const Standard_CString orig)
250 thecheck.CCheck(themodel->Number(start))->AddFail(mess,orig);
254 //=======================================================================
257 //=======================================================================
259 Handle(Interface_Check) IFSelect_ContextWrite::CCheck (const Standard_Integer num)
261 Handle(Interface_Check) ach = thecheck.CCheck(num);
262 if (num > 0 && num <= themodel->NbEntities()) ach->SetEntity(themodel->Value(num));
267 //=======================================================================
270 //=======================================================================
272 Handle(Interface_Check) IFSelect_ContextWrite::CCheck(const Handle(Standard_Transient)& ent)
274 Standard_Integer num = themodel->Number(ent);
275 if (num == 0) num = -1; // force l enregistrement
276 Handle(Interface_Check) ach = thecheck.CCheck(num);
282 //=======================================================================
283 //function : CheckList
285 //=======================================================================
287 Interface_CheckIterator IFSelect_ContextWrite::CheckList () const