42cf5bc1 |
1 | // Created on: 1995-06-01 |
2 | // Created by: Christian CAILLET |
3 | // Copyright (c) 1995-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 _XSControl_WorkSession_HeaderFile |
18 | #define _XSControl_WorkSession_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_Type.hxx> |
22 | |
42cf5bc1 |
23 | #include <IFSelect_WorkSession.hxx> |
42cf5bc1 |
24 | #include <IFSelect_ReturnStatus.hxx> |
7f56eba8 |
25 | #include <XSControl_TransferWriter.hxx> |
42cf5bc1 |
26 | class XSControl_Controller; |
27 | class XSControl_TransferReader; |
42cf5bc1 |
28 | class XSControl_Vars; |
42cf5bc1 |
29 | class Transfer_TransientProcess; |
42cf5bc1 |
30 | class Interface_InterfaceModel; |
31 | class Transfer_FinderProcess; |
32 | class TopoDS_Shape; |
33 | class Interface_CheckIterator; |
34 | |
35 | |
36 | class XSControl_WorkSession; |
37 | DEFINE_STANDARD_HANDLE(XSControl_WorkSession, IFSelect_WorkSession) |
38 | |
bd651bbb |
39 | using XSControl_WorkSessionMap = NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)>; |
40 | |
42cf5bc1 |
41 | //! This WorkSession completes the basic one, by adding : |
42 | //! - use of Controller, with norm selection... |
43 | //! - management of transfers (both ways) with auxiliary classes |
44 | //! TransferReader and TransferWriter |
45 | //! -> these transfers may work with a Context List : its items |
46 | //! are given by the user, according to the transfer to be |
47 | //! i.e. it is interpreted by the Actors |
48 | //! Each item is accessed by a Name |
49 | class XSControl_WorkSession : public IFSelect_WorkSession |
50 | { |
7f56eba8 |
51 | public: |
42cf5bc1 |
52 | |
53 | Standard_EXPORT XSControl_WorkSession(); |
54 | |
7f56eba8 |
55 | ~XSControl_WorkSession() |
56 | { ClearBinders(); } |
57 | |
42cf5bc1 |
58 | //! In addition to basic ClearData, clears Transfer and Management |
59 | //! for interactive use, for mode = 0,1,2 and over 4 |
60 | //! Plus : mode = 5 to clear Transfers (both ways) only |
61 | //! mode = 6 to clear enforced results |
62 | //! mode = 7 to clear transfers, results |
7f56eba8 |
63 | Standard_EXPORT virtual void ClearData (const Standard_Integer theMode) Standard_OVERRIDE; |
42cf5bc1 |
64 | |
65 | //! Selects a Norm defined by its name. |
66 | //! A Norm is described and handled by a Controller |
67 | //! Returns True if done, False if <normname> is unknown |
68 | //! |
7f56eba8 |
69 | //! The current Profile for this Norm is taken. |
70 | Standard_EXPORT Standard_Boolean SelectNorm (const Standard_CString theNormName); |
42cf5bc1 |
71 | |
72 | //! Selects a Norm defined by its Controller itself |
7f56eba8 |
73 | Standard_EXPORT void SetController (const Handle(XSControl_Controller)& theCtl); |
42cf5bc1 |
74 | |
75 | //! Returns the name of the last Selected Norm. If none is |
76 | //! defined, returns an empty string |
77 | //! By default, returns the complete name of the norm |
78 | //! If <rsc> is True, returns the short name used for resource |
7f56eba8 |
79 | Standard_EXPORT Standard_CString SelectedNorm (const Standard_Boolean theRsc = Standard_False) const; |
42cf5bc1 |
80 | |
81 | //! Returns the norm controller itself |
7f56eba8 |
82 | const Handle(XSControl_Controller) & NormAdaptor() const |
83 | { return myController; } |
42cf5bc1 |
84 | |
85 | //! Returns the current Context List, Null if not defined |
86 | //! The Context is given to the TransientProcess for TransferRead |
bd651bbb |
87 | const XSControl_WorkSessionMap& Context() const |
7f56eba8 |
88 | { return myContext; } |
42cf5bc1 |
89 | |
90 | //! Sets the current Context List, as a whole |
91 | //! Sets it to the TransferReader |
bd651bbb |
92 | Standard_EXPORT void SetAllContext (const XSControl_WorkSessionMap& theContext); |
42cf5bc1 |
93 | |
94 | //! Clears the whole current Context (nullifies it) |
95 | Standard_EXPORT void ClearContext(); |
96 | |
4551e1be |
97 | //! Prints the transfer status of a transferred item, as being |
42cf5bc1 |
98 | //! the Mapped n0 <num>, from MapWriter if <wri> is True, or |
99 | //! from MapReader if <wri> is False |
100 | //! Returns True when done, False else (i.e. num out of range) |
0ebe5b0a |
101 | Standard_EXPORT Standard_Boolean PrintTransferStatus (const Standard_Integer theNum, const Standard_Boolean theWri, Standard_OStream& theS) const; |
42cf5bc1 |
102 | |
103 | //! Sets a Transfer Reader, by internal ways, according mode : |
104 | //! 0 recreates it clear, 1 clears it (does not recreate) |
105 | //! 2 aligns Roots of TransientProcess from final Results |
106 | //! 3 aligns final Results from Roots of TransientProcess |
107 | //! 4 begins a new transfer (by BeginTransfer) |
108 | //! 5 recreates TransferReader then begins a new transfer |
7f56eba8 |
109 | Standard_EXPORT void InitTransferReader (const Standard_Integer theMode); |
42cf5bc1 |
110 | |
111 | //! Sets a Transfer Reader, which manages transfers on reading |
7f56eba8 |
112 | Standard_EXPORT void SetTransferReader (const Handle(XSControl_TransferReader)& theTR); |
42cf5bc1 |
113 | |
114 | //! Returns the Transfer Reader, Null if not set |
7f56eba8 |
115 | const Handle(XSControl_TransferReader) & TransferReader () const |
116 | { return myTransferReader; } |
8d0b8649 |
117 | |
118 | //! Returns the TransientProcess(internal data for TransferReader) |
119 | Standard_EXPORT Handle(Transfer_TransientProcess) MapReader() const; |
120 | |
42cf5bc1 |
121 | //! Changes the Map Reader, i.e. considers that the new one |
122 | //! defines the relevant read results (forgets the former ones) |
123 | //! Returns True when done, False in case of bad definition, i.e. |
124 | //! if Model from TP differs from that of Session |
7f56eba8 |
125 | Standard_EXPORT Standard_Boolean SetMapReader (const Handle(Transfer_TransientProcess)& theTP); |
42cf5bc1 |
126 | |
127 | //! Returns the result attached to a starting entity |
128 | //! If <mode> = 0, returns Final Result |
129 | //! If <mode> = 1, considers Last Result |
130 | //! If <mode> = 2, considers Final, else if absent, Last |
131 | //! returns it as Transient, if result is not transient returns |
132 | //! the Binder |
133 | //! <mode> = 10,11,12 idem but returns the Binder itself |
134 | //! (if it is not, e.g. Shape, returns the Binder) |
135 | //! <mode> = 20, returns the ResultFromModel |
7f56eba8 |
136 | Standard_EXPORT Handle(Standard_Transient) Result (const Handle(Standard_Transient)& theEnt, const Standard_Integer theMode) const; |
42cf5bc1 |
137 | |
138 | //! Commands the transfer of, either one entity, or a list |
139 | //! I.E. calls the TransferReader after having analysed <ents> |
140 | //! It is cumulated from the last BeginTransfer |
141 | //! <ents> is processed by GiveList, hence : |
142 | //! - <ents> a Selection : its SelectionResult |
143 | //! - <ents> a HSequenceOfTransient : this list |
144 | //! - <ents> the Model : in this specific case, all the roots, |
145 | //! with no cumulation of former transfers (TransferReadRoots) |
7e785937 |
146 | Standard_EXPORT Standard_Integer TransferReadOne (const Handle(Standard_Transient)& theEnts, |
147 | const Message_ProgressRange& theProgress = Message_ProgressRange()); |
42cf5bc1 |
148 | |
149 | //! Commands the transfer of all the root entities of the model |
150 | //! i.e. calls TransferRoot from the TransferReader with the Graph |
151 | //! No cumulation with former calls to TransferReadOne |
7e785937 |
152 | Standard_EXPORT Standard_Integer TransferReadRoots(const Message_ProgressRange& theProgress = Message_ProgressRange()); |
42cf5bc1 |
153 | |
4551e1be |
154 | //! produces and returns a new Model well conditioned |
42cf5bc1 |
155 | //! It is produced by the Norm Controller |
156 | //! It can be Null (if this function is not implemented) |
157 | Standard_EXPORT Handle(Interface_InterfaceModel) NewModel(); |
158 | |
159 | //! Returns the Transfer Reader, Null if not set |
7f56eba8 |
160 | const Handle(XSControl_TransferWriter) & TransferWriter() const |
161 | { return myTransferWriter; } |
42cf5bc1 |
162 | |
163 | //! Changes the Map Reader, i.e. considers that the new one |
164 | //! defines the relevant read results (forgets the former ones) |
165 | //! Returns True when done, False if <FP> is Null |
7f56eba8 |
166 | Standard_Boolean SetMapWriter (const Handle(Transfer_FinderProcess)& theFP) |
167 | { |
168 | if (theFP.IsNull()) return Standard_False; |
169 | myTransferWriter->SetFinderProcess(theFP); |
170 | return Standard_True; |
171 | } |
42cf5bc1 |
172 | |
173 | //! Transfers a Shape from CasCade to a model of current norm, |
174 | //! according to the last call to SetModeWriteShape |
175 | //! Returns status :Done if OK, Fail if error during transfer, |
176 | //! Error if transfer badly initialised |
7e785937 |
177 | Standard_EXPORT IFSelect_ReturnStatus TransferWriteShape |
178 | (const TopoDS_Shape& theShape, |
179 | const Standard_Boolean theCompGraph = Standard_True, |
180 | const Message_ProgressRange& theProgress = Message_ProgressRange()); |
42cf5bc1 |
181 | |
182 | //! Returns the check-list of last transfer (write) |
183 | //! It is recorded in the FinderProcess, but it must be bound with |
184 | //! resulting entities (in the resulting file model) rather than |
185 | //! with original objects (in fact, their mappers) |
186 | Standard_EXPORT Interface_CheckIterator TransferWriteCheckList() const; |
187 | |
7f56eba8 |
188 | const Handle(XSControl_Vars) & Vars() const |
189 | { return myVars; } |
42cf5bc1 |
190 | |
7f56eba8 |
191 | void SetVars (const Handle(XSControl_Vars)& theVars) |
192 | { myVars = theVars; } |
42cf5bc1 |
193 | |
92efcf78 |
194 | DEFINE_STANDARD_RTTIEXT(XSControl_WorkSession,IFSelect_WorkSession) |
42cf5bc1 |
195 | |
7f56eba8 |
196 | private: |
197 | |
198 | //! Clears binders |
199 | Standard_EXPORT void ClearBinders(); |
42cf5bc1 |
200 | |
7f56eba8 |
201 | Handle(XSControl_Controller) myController; |
202 | Handle(XSControl_TransferReader) myTransferReader; |
203 | Handle(XSControl_TransferWriter) myTransferWriter; |
bd651bbb |
204 | XSControl_WorkSessionMap myContext; |
7f56eba8 |
205 | Handle(XSControl_Vars) myVars; |
42cf5bc1 |
206 | }; |
207 | |
42cf5bc1 |
208 | #endif // _XSControl_WorkSession_HeaderFile |