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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _IFSelect_ContextModif_HeaderFile
18 #define _IFSelect_ContextModif_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
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 #include <Standard_CString.hxx>
30 class Interface_Protocol;
31 class Interface_CopyControl;
32 class Interface_CopyTool;
33 class Interface_EntityIterator;
34 class Interface_InterfaceModel;
35 class Standard_Transient;
36 class IFSelect_GeneralModifier;
37 class Interface_Check;
40 //! This class gathers various information used by Model Modifiers
41 //! apart from the target model itself, and the CopyTool which
42 //! must be passed directly.
44 //! These information report to original data : model, entities,
45 //! and the selection list if there is one : it allows to query
46 //! about such or such starting entity, or result entity, or
47 //! iterate on selection list ...
48 //! Also data useful for file output are available (because some
49 //! Modifiers concern models produced for file output).
51 //! Furthermore, in return, ContextModif can record Checks, either
52 //! one for all, or one for each Entity. It supports trace too.
53 class IFSelect_ContextModif
59 //! Prepares a ContextModif with these information :
60 //! - the graph established from original model (target passed
61 //! directly to Modifier)
62 //! - the CopyTool which detains the CopyControl, which maps
63 //! starting (in original) and result (in target) entities
64 //! - an optional file name (for file output)
66 //! Such a ContextModif is considered to be applied on all
67 //! transferred entities (no filter active)
68 Standard_EXPORT IFSelect_ContextModif(const Interface_Graph& graph, const Interface_CopyTool& TC, const Standard_CString filename = "");
70 //! Prepares a ContextModif with these information :
71 //! - the graph established from original model (target passed
72 //! directly to Modifier)
73 //! - an optional file name (for file output)
74 //! Here, no CopyControl, hence all entities are considered equal
75 //! as starting and result
77 //! Such a ContextModif is considered to be applied on all
78 //! transferred entities (no filter active)
79 Standard_EXPORT IFSelect_ContextModif(const Interface_Graph& graph, const Standard_CString filename = "");
81 //! This method requires ContextModif to be applied with a filter.
82 //! If a ModelModifier is defined with a Selection criterium,
83 //! the result of this Selection is used as a filter :
84 //! - if none of its items has been transferred, the modification
85 //! does not apply at all
86 //! - else, the Modifier can query for what entities were selected
87 //! and what are their results
88 //! - if this method is not called before working, the Modifier
89 //! has to work on the whole Model
90 Standard_EXPORT void Select (Interface_EntityIterator& list);
92 //! Returns the original Graph (compared to OriginalModel, it
93 //! gives more query capabilitites)
94 Standard_EXPORT const Interface_Graph& OriginalGraph() const;
96 //! Returns the original model
97 Standard_EXPORT Handle(Interface_InterfaceModel) OriginalModel() const;
99 //! Allows to transmit a Protocol as part of a ContextModif
100 Standard_EXPORT void SetProtocol (const Handle(Interface_Protocol)& proto);
102 //! Returns the Protocol (Null if not set)
103 Standard_EXPORT Handle(Interface_Protocol) Protocol() const;
105 //! Returns True if a non empty file name has been defined
106 Standard_EXPORT Standard_Boolean HasFileName() const;
108 //! Returns File Name (can be empty)
109 Standard_EXPORT Standard_CString FileName() const;
111 //! Returns the map for a direct use, if required
112 Standard_EXPORT Handle(Interface_CopyControl) Control() const;
114 //! Returns True if Select has determined that a Modifier may not
115 //! be run (filter defined and empty)
116 Standard_EXPORT Standard_Boolean IsForNone() const;
118 //! Returns True if no filter is defined : a Modifier has to work
119 //! on all entities of the resulting (target) model
120 Standard_EXPORT Standard_Boolean IsForAll() const;
122 //! Returns True if a starting item has been transferred
123 Standard_EXPORT Standard_Boolean IsTransferred (const Handle(Standard_Transient)& ent) const;
125 //! Returns True if a starting item has been transferred and selected
126 Standard_EXPORT Standard_Boolean IsSelected (const Handle(Standard_Transient)& ent) const;
128 //! Returns True if a starting entity has been transferred, and
129 //! the result is in <res>. Returns False else
130 //! (direct call to the map)
131 Standard_EXPORT Standard_Boolean Search (const Handle(Standard_Transient)& ent, Handle(Standard_Transient)& res) const;
133 //! Returns the list of original selected items.
134 //! See also the iteration
135 Standard_EXPORT Interface_EntityIterator SelectedOriginal() const;
137 //! Returns the list of resulting counterparts of selected items.
138 //! See also the iteration
139 Standard_EXPORT Interface_EntityIterator SelectedResult() const;
141 //! Returns the count of selected and transferred items
142 Standard_EXPORT Standard_Integer SelectedCount() const;
144 //! Starts an iteration on selected items. It takes into account
145 //! IsForAll/IsForNone, by really iterating on all selected items.
146 Standard_EXPORT void Start();
148 //! Returns True until the iteration has finished
149 Standard_EXPORT Standard_Boolean More() const;
151 //! Advances the iteration
152 Standard_EXPORT void Next();
154 //! Returns the current selected item in the original model
155 Standard_EXPORT Handle(Standard_Transient) ValueOriginal() const;
157 //! Returns the result counterpart of current selected item
158 //! (in the target model)
159 Standard_EXPORT Handle(Standard_Transient) ValueResult() const;
161 //! Traces the application of a Modifier. Works with default trace
162 //! File and Level. Fills the trace if default trace level is at
163 //! least 1. Traces the Modifier (its Label) and its Selection if
164 //! there is one (its Label).
165 //! To be called after Select (because status IsForAll is printed)
166 //! Worths to trace a global modification. See also Trace below
167 Standard_EXPORT void TraceModifier (const Handle(IFSelect_GeneralModifier)& modif);
169 //! Traces the modification of the current entity (see above,
170 //! ValueOriginal and ValueResult) for default trace level >= 2.
171 //! To be called on each individual entity really modified
172 //! <mess> is an optional additional message
173 Standard_EXPORT void Trace (const Standard_CString mess = "");
175 //! Adds a Check to the CheckList. If it is empty, nothing is done
176 //! If it concerns an Entity from the Original Model (by SetEntity)
177 //! to which another Check is attached, it is merged to it.
178 //! Else, it is added or merged as to GlobalCheck.
179 Standard_EXPORT void AddCheck (const Handle(Interface_Check)& check);
181 //! Adds a Warning Message for an Entity from the original Model
182 //! If <start> is not an Entity from the original model (e.g. the
183 //! model itself) this message is added to Global Check.
184 Standard_EXPORT void AddWarning (const Handle(Standard_Transient)& start, const Standard_CString mess, const Standard_CString orig = "");
186 //! Adds a Fail Message for an Entity from the original Model
187 //! If <start> is not an Entity from the original model (e.g. the
188 //! model itself) this message is added to Global Check.
189 Standard_EXPORT void AddFail (const Handle(Standard_Transient)& start, const Standard_CString mess, const Standard_CString orig = "");
191 //! Returns a Check given an Entity number (in the original Model)
192 //! by default a Global Check. Creates it the first time.
193 //! It can then be acknowledged on the spot, in condition that the
194 //! caller works by reference ("Interface_Check& check = ...")
195 Standard_EXPORT Handle(Interface_Check) CCheck (const Standard_Integer num = 0);
197 //! Returns a Check attached to an Entity from the original Model
198 //! It can then be acknowledged on the spot, in condition that the
199 //! caller works by reference ("Interface_Check& check = ...")
200 Standard_EXPORT Handle(Interface_Check) CCheck (const Handle(Standard_Transient)& start);
202 //! Returns the complete CheckList
203 Standard_EXPORT Interface_CheckIterator CheckList() const;
207 Interface_Graph thegraf;
208 Handle(Interface_Protocol) theprot;
209 Handle(Interface_CopyControl) themap;
210 TCollection_AsciiString thefile;
211 TCollection_AsciiString thelist;
212 Interface_CheckIterator thechek;
213 Standard_Boolean thesel;
214 Standard_Integer thecurr;
215 Standard_Integer thecurt;
219 #endif // _IFSelect_ContextModif_HeaderFile