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
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 _XSControl_WorkSession_HeaderFile
18 #define _XSControl_WorkSession_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
23 #include <Standard_Integer.hxx>
24 #include <IFSelect_WorkSession.hxx>
25 #include <Standard_Boolean.hxx>
26 #include <Standard_CString.hxx>
27 #include <IFSelect_ReturnStatus.hxx>
28 class XSControl_Controller;
29 class XSControl_TransferReader;
30 class XSControl_TransferWriter;
31 class Dico_DictionaryOfTransient;
33 class Message_Messenger;
34 class Transfer_TransientProcess;
35 class Standard_Transient;
36 class Interface_InterfaceModel;
37 class Transfer_FinderProcess;
39 class Interface_CheckIterator;
42 class XSControl_WorkSession;
43 DEFINE_STANDARD_HANDLE(XSControl_WorkSession, IFSelect_WorkSession)
45 //! This WorkSession completes the basic one, by adding :
46 //! - use of Controller, with norm selection...
47 //! - management of transfers (both ways) with auxiliary classes
48 //! TransferReader and TransferWriter
49 //! -> these transfers may work with a Context List : its items
50 //! are given by the user, according to the transfer to be
51 //! i.e. it is interpreted by the Actors
52 //! Each item is accessed by a Name
53 class XSControl_WorkSession : public IFSelect_WorkSession
59 Standard_EXPORT XSControl_WorkSession();
61 //! In addition to basic ClearData, clears Transfer and Management
62 //! for interactive use, for mode = 0,1,2 and over 4
63 //! Plus : mode = 5 to clear Transfers (both ways) only
64 //! mode = 6 to clear enforced results
65 //! mode = 7 to clear transfers, results
66 Standard_EXPORT virtual void ClearData (const Standard_Integer mode) Standard_OVERRIDE;
68 //! Selects a Norm defined by its name.
69 //! A Norm is described and handled by a Controller
70 //! Returns True if done, False if <normname> is unknown
72 //! A Profile may be set too. If no Profile is provided, the
73 //! current Profile for this Norm is taken
74 //! If the asked Profile is not defined for this Norm, it remains
75 //! in current Profile, returned value is True
76 Standard_EXPORT Standard_Boolean SelectNorm (const Standard_CString normname, const Standard_CString profile = "");
78 //! Sets a Profile as current for the current Norm
79 //! Returns True if done, False if <profile> is unknown for this norm
81 //! For more infos on Profile, query the Profile of the Controller
82 Standard_EXPORT Standard_Boolean SelectProfile (const Standard_CString profile);
84 //! Selects a Norm defined by its Controller itself
85 Standard_EXPORT void SetController (const Handle(XSControl_Controller)& ctl);
87 //! This method is called once a new norm has been successfully
88 //! selected. It can be redefined, default does nothing
89 Standard_EXPORT virtual void AdaptNorm();
91 //! Returns the name of the last Selected Norm. If none is
92 //! defined, returns an empty string
93 //! By default, returns the complete name of the norm
94 //! If <rsc> is True, returns the short name used for resource
95 Standard_EXPORT Standard_CString SelectedNorm (const Standard_Boolean rsc = Standard_False) const;
97 //! Returns the norm controller itself
98 Standard_EXPORT Handle(XSControl_Controller) NormAdaptor() const;
100 //! Returns the current Context List, Null if not defined
101 //! The Context is given to the TransientProcess for TransferRead
102 Standard_EXPORT Handle(Dico_DictionaryOfTransient) Context() const;
104 //! Sets the current Context List, as a whole
105 //! Sets it to the TransferReader
106 Standard_EXPORT void SetAllContext (const Handle(Dico_DictionaryOfTransient)& context);
108 //! Clears the whole current Context (nullifies it)
109 Standard_EXPORT void ClearContext();
111 //! Prints the transfer status of a transferred item, as beeing
112 //! the Mapped n0 <num>, from MapWriter if <wri> is True, or
113 //! from MapReader if <wri> is False
114 //! Returns True when done, False else (i.e. num out of range)
115 Standard_EXPORT Standard_Boolean PrintTransferStatus (const Standard_Integer num, const Standard_Boolean wri, const Handle(Message_Messenger)& S) const;
117 //! Sets a Transfer Reader, by internal ways, according mode :
118 //! 0 recreates it clear, 1 clears it (does not recreate)
119 //! 2 aligns Roots of TransientProcess from final Results
120 //! 3 aligns final Results from Roots of TransientProcess
121 //! 4 begins a new transfer (by BeginTransfer)
122 //! 5 recreates TransferReader then begins a new transfer
123 Standard_EXPORT void InitTransferReader (const Standard_Integer mode);
125 //! Sets a Transfer Reader, which manages transfers on reading
126 Standard_EXPORT void SetTransferReader (const Handle(XSControl_TransferReader)& TR);
128 //! Returns the Transfer Reader, Null if not set
129 Standard_EXPORT Handle(XSControl_TransferReader) TransferReader() const;
131 //! Returns the TransientProcess(internal data for TransferReader)
132 Standard_EXPORT Handle(Transfer_TransientProcess) MapReader() const;
134 //! Changes the Map Reader, i.e. considers that the new one
135 //! defines the relevant read results (forgets the former ones)
136 //! Returns True when done, False in case of bad definition, i.e.
137 //! if Model from TP differs from that of Session
138 Standard_EXPORT Standard_Boolean SetMapReader (const Handle(Transfer_TransientProcess)& TP);
140 //! Returns the result attached to a starting entity
141 //! If <mode> = 0, returns Final Result
142 //! If <mode> = 1, considers Last Result
143 //! If <mode> = 2, considers Final, else if absent, Last
144 //! returns it as Transient, if result is not transient returns
146 //! <mode> = 10,11,12 idem but returns the Binder itself
147 //! (if it is not, e.g. Shape, returns the Binder)
148 //! <mode> = 20, returns the ResultFromModel
149 Standard_EXPORT Handle(Standard_Transient) Result (const Handle(Standard_Transient)& ent, const Standard_Integer mode) const;
151 //! Commands the transfer of, either one entity, or a list
152 //! I.E. calls the TransferReader after having analysed <ents>
153 //! It is cumulated from the last BeginTransfer
154 //! <ents> is processed by GiveList, hence :
155 //! - <ents> a Selection : its SelectionResult
156 //! - <ents> a HSequenceOfTransient : this list
157 //! - <ents> the Model : in this specific case, all the roots,
158 //! with no cumulation of former transfers (TransferReadRoots)
159 Standard_EXPORT Standard_Integer TransferReadOne (const Handle(Standard_Transient)& ents);
161 //! Commands the transfer of all the root entities of the model
162 //! i.e. calls TransferRoot from the TransferReader with the Graph
163 //! No cumulation with former calls to TransferReadOne
164 Standard_EXPORT Standard_Integer TransferReadRoots();
166 //! produces and returns a new Model well conditionned
167 //! It is produced by the Norm Controller
168 //! It can be Null (if this function is not implemented)
169 Standard_EXPORT Handle(Interface_InterfaceModel) NewModel();
171 //! Returns the Transfer Reader, Null if not set
172 Standard_EXPORT Handle(XSControl_TransferWriter) TransferWriter() const;
174 //! Returns the FinderProcess (internal data for TransferWriter)
175 Standard_EXPORT Handle(Transfer_FinderProcess) MapWriter() const;
177 //! Changes the Map Reader, i.e. considers that the new one
178 //! defines the relevant read results (forgets the former ones)
179 //! Returns True when done, False if <FP> is Null
180 Standard_EXPORT Standard_Boolean SetMapWriter (const Handle(Transfer_FinderProcess)& FP);
182 //! Sets a mode to transfer Shapes from CasCade to entities of the
183 //! current norm, which interprets it (see various Controllers)
184 //! This call form could be later replaced by a more general one
185 Standard_EXPORT void SetModeWriteShape (const Standard_Integer mode);
187 //! Records the current Mode to Write Shapes
188 Standard_EXPORT Standard_Integer ModeWriteShape() const;
190 //! Transfers a Shape from CasCade to a model of current norm,
191 //! according to the last call to SetModeWriteShape
192 //! Returns status :Done if OK, Fail if error during transfer,
193 //! Error if transfer badly initialised
194 Standard_EXPORT IFSelect_ReturnStatus TransferWriteShape (const TopoDS_Shape& shape, const Standard_Boolean compgraph = Standard_True);
196 //! Returns the check-list of last transfer (write)
197 //! It is recorded in the FinderProcess, but it must be bound with
198 //! resulting entities (in the resulting file model) rather than
199 //! with original objects (in fact, their mappers)
200 Standard_EXPORT Interface_CheckIterator TransferWriteCheckList() const;
202 Standard_EXPORT Handle(XSControl_Vars) Vars() const;
204 Standard_EXPORT void SetVars (const Handle(XSControl_Vars)& newvars);
207 Standard_EXPORT void ClearBinders();
209 Standard_EXPORT void Destroy();
210 ~XSControl_WorkSession()
217 DEFINE_STANDARD_RTTIEXT(XSControl_WorkSession,IFSelect_WorkSession)
227 Handle(XSControl_Controller) theController;
228 Handle(XSControl_TransferReader) theTransferRead;
229 Handle(XSControl_TransferWriter) theTransferWrite;
230 Handle(Dico_DictionaryOfTransient) theContext;
231 Standard_Integer theModeWriteShape;
232 Handle(XSControl_Vars) theVars;
243 #endif // _XSControl_WorkSession_HeaderFile