0032951: Coding - get rid of unused headers [GeomConvert to IGESBasic]
[occt.git] / src / IFSelect / IFSelect_ContextModif.hxx
1 // Created on: 1994-06-08
2 // Created by: Christian CAILLET
3 // Copyright (c) 1994-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifndef _IFSelect_ContextModif_HeaderFile
18 #define _IFSelect_ContextModif_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
24 #include <Interface_Graph.hxx>
25 #include <TCollection_AsciiString.hxx>
26 #include <Interface_CheckIterator.hxx>
27 #include <Standard_Boolean.hxx>
28 #include <Standard_Integer.hxx>
29 class Interface_Protocol;
30 class Interface_CopyControl;
31 class Interface_CopyTool;
32 class Interface_EntityIterator;
33 class Interface_InterfaceModel;
34 class Standard_Transient;
35 class IFSelect_GeneralModifier;
36 class Interface_Check;
37
38
39 //! This class gathers various information used by Model Modifiers
40 //! apart from the target model itself, and the CopyTool which
41 //! must be passed directly.
42 //!
43 //! These information report to original data : model, entities,
44 //! and the selection list if there is one : it allows to query
45 //! about such or such starting entity, or result entity, or
46 //! iterate on selection list ...
47 //! Also data useful for file output are available (because some
48 //! Modifiers concern models produced for file output).
49 //!
50 //! Furthermore, in return, ContextModif can record Checks, either
51 //! one for all, or one for each Entity. It supports trace too.
52 class IFSelect_ContextModif 
53 {
54 public:
55
56   DEFINE_STANDARD_ALLOC
57
58   //! Prepares a ContextModif with these information :
59   //! - the graph established from original model (target passed
60   //! directly to Modifier)
61   //! - the CopyTool which detains the CopyControl, which maps
62   //! starting (in original) and result (in target) entities
63   //! - an optional file name (for file output)
64   //!
65   //! Such a ContextModif is considered to be applied on all
66   //! transferred entities (no filter active)
67   Standard_EXPORT IFSelect_ContextModif(const Interface_Graph& graph, const Interface_CopyTool& TC, const Standard_CString filename = "");
68   
69   //! Prepares a ContextModif with these information :
70   //! - the graph established from original model (target passed
71   //! directly to Modifier)
72   //! - an optional file name (for file output)
73   //! Here, no CopyControl, hence all entities are considered equal
74   //! as starting and result
75   //!
76   //! Such a ContextModif is considered to be applied on all
77   //! transferred entities (no filter active)
78   Standard_EXPORT IFSelect_ContextModif(const Interface_Graph& graph, const Standard_CString filename = "");
79   
80   //! This method requires ContextModif to be applied with a filter.
81   //! If a ModelModifier is defined with a Selection criterium,
82   //! the result of this Selection is used as a filter :
83   //! - if none of its items has been transferred, the modification
84   //! does not apply at all
85   //! - else, the Modifier can query for what entities were selected
86   //! and what are their results
87   //! - if this method is not called before working, the Modifier
88   //! has to work on the whole Model
89   Standard_EXPORT void Select (Interface_EntityIterator& list);
90   
91   //! Returns the original Graph (compared to OriginalModel, it
92   //! gives more query capabilitites)
93   Standard_EXPORT const Interface_Graph& OriginalGraph() const;
94   
95   //! Returns the original model
96   Standard_EXPORT Handle(Interface_InterfaceModel) OriginalModel() const;
97   
98   //! Allows to transmit a Protocol as part of a ContextModif
99   Standard_EXPORT void SetProtocol (const Handle(Interface_Protocol)& proto);
100   
101   //! Returns the Protocol (Null if not set)
102   Standard_EXPORT Handle(Interface_Protocol) Protocol() const;
103   
104   //! Returns True if a non empty file name has been defined
105   Standard_EXPORT Standard_Boolean HasFileName() const;
106   
107   //! Returns File Name (can be empty)
108   Standard_EXPORT Standard_CString FileName() const;
109   
110   //! Returns the map for a direct use, if required
111   Standard_EXPORT Handle(Interface_CopyControl) Control() const;
112   
113   //! Returns True if Select has determined that a Modifier may not
114   //! be run (filter defined and empty)
115   Standard_EXPORT Standard_Boolean IsForNone() const;
116   
117   //! Returns True if no filter is defined : a Modifier has to work
118   //! on all entities of the resulting (target) model
119   Standard_EXPORT Standard_Boolean IsForAll() const;
120   
121   //! Returns True if a starting item has been transferred
122   Standard_EXPORT Standard_Boolean IsTransferred (const Handle(Standard_Transient)& ent) const;
123   
124   //! Returns True if a starting item has been transferred and selected
125   Standard_EXPORT Standard_Boolean IsSelected (const Handle(Standard_Transient)& ent) const;
126   
127   //! Returns True if a starting entity has been transferred, and
128   //! the result is in <res>. Returns False else
129   //! (direct call to the map)
130   Standard_EXPORT Standard_Boolean Search (const Handle(Standard_Transient)& ent, Handle(Standard_Transient)& res) const;
131   
132   //! Returns the list of original selected items.
133   //! See also the iteration
134   Standard_EXPORT Interface_EntityIterator SelectedOriginal() const;
135   
136   //! Returns the list of resulting counterparts of selected items.
137   //! See also the iteration
138   Standard_EXPORT Interface_EntityIterator SelectedResult() const;
139   
140   //! Returns the count of selected and transferred items
141   Standard_EXPORT Standard_Integer SelectedCount() const;
142   
143   //! Starts an iteration on selected items. It takes into account
144   //! IsForAll/IsForNone, by really iterating on all selected items.
145   Standard_EXPORT void Start();
146   
147   //! Returns True until the iteration has finished
148   Standard_EXPORT Standard_Boolean More() const;
149   
150   //! Advances the iteration
151   Standard_EXPORT void Next();
152   
153   //! Returns the current selected item in the original model
154   Standard_EXPORT Handle(Standard_Transient) ValueOriginal() const;
155   
156   //! Returns the result counterpart of current selected item
157   //! (in the target model)
158   Standard_EXPORT Handle(Standard_Transient) ValueResult() const;
159   
160   //! Traces the application of a Modifier. Works with default trace
161   //! File and Level. Fills the trace if default trace level is at
162   //! least 1. Traces the Modifier (its Label) and its Selection if
163   //! there is one (its Label).
164   //! To be called after Select (because status IsForAll is printed)
165   //! Worths to trace a global modification. See also Trace below
166   Standard_EXPORT void TraceModifier (const Handle(IFSelect_GeneralModifier)& modif);
167   
168   //! Traces the modification of the current entity (see above,
169   //! ValueOriginal and ValueResult) for default trace level >= 2.
170   //! To be called on each individual entity really modified
171   //! <mess> is an optional additional message
172   Standard_EXPORT void Trace (const Standard_CString mess = "");
173   
174   //! Adds a Check to the CheckList. If it is empty, nothing is done
175   //! If it concerns an Entity from the Original Model (by SetEntity)
176   //! to which another Check is attached, it is merged to it.
177   //! Else, it is added or merged as to GlobalCheck.
178   Standard_EXPORT void AddCheck (const Handle(Interface_Check)& check);
179   
180   //! Adds a Warning Message for an Entity from the original Model
181   //! If <start> is not an Entity from the original model (e.g. the
182   //! model itself) this message is added to Global Check.
183   Standard_EXPORT void AddWarning (const Handle(Standard_Transient)& start, const Standard_CString mess, const Standard_CString orig = "");
184   
185   //! Adds a Fail Message for an Entity from the original Model
186   //! If <start> is not an Entity from the original model (e.g. the
187   //! model itself) this message is added to Global Check.
188   Standard_EXPORT void AddFail (const Handle(Standard_Transient)& start, const Standard_CString mess, const Standard_CString orig = "");
189   
190   //! Returns a Check given an Entity number (in the original Model)
191   //! by default a Global Check. Creates it the first time.
192   //! It can then be acknowledged on the spot, in condition that the
193   //! caller works by reference ("Interface_Check& check = ...")
194   Standard_EXPORT Handle(Interface_Check) CCheck (const Standard_Integer num = 0);
195   
196   //! Returns a Check attached to an Entity from the original Model
197   //! It can then be acknowledged on the spot, in condition that the
198   //! caller works by reference ("Interface_Check& check = ...")
199   Standard_EXPORT Handle(Interface_Check) CCheck (const Handle(Standard_Transient)& start);
200   
201   //! Returns the complete CheckList
202   Standard_EXPORT Interface_CheckIterator CheckList() const;
203
204 private:
205
206   Interface_Graph thegraf;
207   Handle(Interface_Protocol) theprot;
208   Handle(Interface_CopyControl) themap;
209   TCollection_AsciiString thefile;
210   TCollection_AsciiString thelist;
211   Interface_CheckIterator thechek;
212   Standard_Boolean thesel;
213   Standard_Integer thecurr;
214   Standard_Integer thecurt;
215
216 };
217
218 #endif // _IFSelect_ContextModif_HeaderFile