42cf5bc1 |
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 | #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; |
41 | |
42 | |
43 | //! This class gathers various informations used by Model Modifiers |
44 | //! apart from the target model itself, and the CopyTool which |
45 | //! must be passed directly. |
46 | //! |
47 | //! These informations 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). |
53 | //! |
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 |
57 | { |
58 | public: |
59 | |
60 | DEFINE_STANDARD_ALLOC |
61 | |
62 | |
63 | //! Prepares a ContextModif with these informations : |
64 | //! - the graph established from original model (target passed |
65 | //! directly to Modifier) |
66 | //! - the CopyTool which detains the CopyControl, which maps |
67 | //! starting (in original) and result (in target) entities |
68 | //! - an optional file name (for file output) |
69 | //! |
70 | //! Such a ContextModif is considered to be applied on all |
71 | //! transferred entities (no filter active) |
72 | Standard_EXPORT IFSelect_ContextModif(const Interface_Graph& graph, const Interface_CopyTool& TC, const Standard_CString filename = ""); |
73 | |
74 | //! Prepares a ContextModif with these informations : |
75 | //! - the graph established from original model (target passed |
76 | //! directly to Modifier) |
77 | //! - an optional file name (for file output) |
78 | //! Here, no CopyControl, hence all entities are considered equal |
79 | //! as starting and result |
80 | //! |
81 | //! Such a ContextModif is considered to be applied on all |
82 | //! transferred entities (no filter active) |
83 | Standard_EXPORT IFSelect_ContextModif(const Interface_Graph& graph, const Standard_CString filename = ""); |
84 | |
85 | //! This method requires ContextModif to be applied with a filter. |
86 | //! If a ModelModifier is defined with a Selection criterium, |
87 | //! the result of this Selection is used as a filter : |
88 | //! - if none of its items has been transferred, the modification |
89 | //! does not apply at all |
90 | //! - else, the Modifier can query for what entities were selected |
91 | //! and what are their results |
92 | //! - if this method is not called before working, the Modifier |
93 | //! has to work on the whole Model |
94 | Standard_EXPORT void Select (Interface_EntityIterator& list); |
95 | |
96 | //! Returns the original Graph (compared to OriginalModel, it |
97 | //! gives more query capabilitites) |
98 | Standard_EXPORT const Interface_Graph& OriginalGraph() const; |
99 | |
100 | //! Returns the original model |
101 | Standard_EXPORT Handle(Interface_InterfaceModel) OriginalModel() const; |
102 | |
103 | //! Allows to transmit a Protocol as part of a ContextModif |
104 | Standard_EXPORT void SetProtocol (const Handle(Interface_Protocol)& proto); |
105 | |
106 | //! Returns the Protocol (Null if not set) |
107 | Standard_EXPORT Handle(Interface_Protocol) Protocol() const; |
108 | |
109 | //! Returns True if a non empty file name has been defined |
110 | Standard_EXPORT Standard_Boolean HasFileName() const; |
111 | |
112 | //! Returns File Name (can be empty) |
113 | Standard_EXPORT Standard_CString FileName() const; |
114 | |
115 | //! Returns the map for a direct use, if required |
116 | Standard_EXPORT Handle(Interface_CopyControl) Control() const; |
117 | |
118 | //! Returns True if Select has determined that a Modifier may not |
119 | //! be run (filter defined and empty) |
120 | Standard_EXPORT Standard_Boolean IsForNone() const; |
121 | |
122 | //! Returns True if no filter is defined : a Modifier has to work |
123 | //! on all entities of the resulting (target) model |
124 | Standard_EXPORT Standard_Boolean IsForAll() const; |
125 | |
126 | //! Returns True if a starting item has been transferred |
127 | Standard_EXPORT Standard_Boolean IsTransferred (const Handle(Standard_Transient)& ent) const; |
128 | |
129 | //! Returns True if a starting item has been transferred and selected |
130 | Standard_EXPORT Standard_Boolean IsSelected (const Handle(Standard_Transient)& ent) const; |
131 | |
132 | //! Returns True if a starting entity has been transferred, and |
133 | //! the result is in <res>. Returns False else |
134 | //! (direct call to the map) |
135 | Standard_EXPORT Standard_Boolean Search (const Handle(Standard_Transient)& ent, Handle(Standard_Transient)& res) const; |
136 | |
137 | //! Returns the list of original selected items. |
138 | //! See also the iteration |
139 | Standard_EXPORT Interface_EntityIterator SelectedOriginal() const; |
140 | |
141 | //! Returns the list of resulting counterparts of selected items. |
142 | //! See also the iteration |
143 | Standard_EXPORT Interface_EntityIterator SelectedResult() const; |
144 | |
145 | //! Returns the count of selected and transferred items |
146 | Standard_EXPORT Standard_Integer SelectedCount() const; |
147 | |
148 | //! Starts an iteration on selected items. It takes into account |
149 | //! IsForAll/IsForNone, by really iterating on all selected items. |
150 | Standard_EXPORT void Start(); |
151 | |
152 | //! Returns True until the iteration has finished |
153 | Standard_EXPORT Standard_Boolean More() const; |
154 | |
155 | //! Advances the iteration |
156 | Standard_EXPORT void Next(); |
157 | |
158 | //! Returns the current selected item in the original model |
159 | Standard_EXPORT Handle(Standard_Transient) ValueOriginal() const; |
160 | |
161 | //! Returns the result counterpart of current selected item |
162 | //! (in the target model) |
163 | Standard_EXPORT Handle(Standard_Transient) ValueResult() const; |
164 | |
165 | //! Traces the application of a Modifier. Works with default trace |
166 | //! File and Level. Fills the trace if default trace level is at |
167 | //! least 1. Traces the Modifier (its Label) and its Selection if |
168 | //! there is one (its Label). |
169 | //! To be called after Select (because status IsForAll is printed) |
170 | //! Worths to trace a global modification. See also Trace below |
171 | Standard_EXPORT void TraceModifier (const Handle(IFSelect_GeneralModifier)& modif); |
172 | |
173 | //! Traces the modification of the current entity (see above, |
174 | //! ValueOriginal and ValueResult) for default trace level >= 2. |
175 | //! To be called on each indivudual entity really modified |
176 | //! <mess> is an optionnal additional message |
177 | Standard_EXPORT void Trace (const Standard_CString mess = ""); |
178 | |
179 | //! Adds a Check to the CheckList. If it is empty, nothing is done |
180 | //! If it concerns an Entity from the Original Model (by SetEntity) |
181 | //! to which another Check is attached, it is merged to it. |
182 | //! Else, it is added or merged as to GlobalCheck. |
183 | Standard_EXPORT void AddCheck (const Handle(Interface_Check)& check); |
184 | |
185 | //! Adds a Warning 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 AddWarning (const Handle(Standard_Transient)& start, const Standard_CString mess, const Standard_CString orig = ""); |
189 | |
190 | //! Adds a Fail Message for an Entity from the original Model |
191 | //! If <start> is not an Entity from the original model (e.g. the |
192 | //! model itself) this message is added to Global Check. |
193 | Standard_EXPORT void AddFail (const Handle(Standard_Transient)& start, const Standard_CString mess, const Standard_CString orig = ""); |
194 | |
195 | //! Returns a Check given an Entity number (in the original Model) |
196 | //! by default a Global Check. Creates it the first time. |
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 Standard_Integer num = 0); |
200 | |
201 | //! Returns a Check attached to an Entity from the original Model |
202 | //! It can then be acknowledged on the spot, in condition that the |
203 | //! caller works by reference ("Interface_Check& check = ...") |
204 | Standard_EXPORT Handle(Interface_Check) CCheck (const Handle(Standard_Transient)& start); |
205 | |
206 | //! Returns the complete CheckList |
207 | Standard_EXPORT Interface_CheckIterator CheckList() const; |
208 | |
209 | |
210 | |
211 | |
212 | protected: |
213 | |
214 | |
215 | |
216 | |
217 | |
218 | private: |
219 | |
220 | |
221 | |
222 | Interface_Graph thegraf; |
223 | Handle(Interface_Protocol) theprot; |
224 | Handle(Interface_CopyControl) themap; |
225 | TCollection_AsciiString thefile; |
226 | TCollection_AsciiString thelist; |
227 | Interface_CheckIterator thechek; |
228 | Standard_Boolean thesel; |
229 | Standard_Integer thecurr; |
230 | Standard_Integer thecurt; |
231 | |
232 | |
233 | }; |
234 | |
235 | |
236 | |
237 | |
238 | |
239 | |
240 | |
241 | #endif // _IFSelect_ContextModif_HeaderFile |