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