Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-05 08:35:25

0001 // Created on: 1995-06-01
0002 // Created by: Christian CAILLET
0003 // Copyright (c) 1995-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _XSControl_WorkSession_HeaderFile
0018 #define _XSControl_WorkSession_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <IFSelect_WorkSession.hxx>
0024 #include <IFSelect_ReturnStatus.hxx>
0025 #include <XSControl_TransferWriter.hxx>
0026 class XSControl_Controller;
0027 class XSControl_TransferReader;
0028 class XSControl_Vars;
0029 class Transfer_TransientProcess;
0030 class Interface_InterfaceModel;
0031 class Transfer_FinderProcess;
0032 class TopoDS_Shape;
0033 class Interface_CheckIterator;
0034 
0035 class XSControl_WorkSession;
0036 DEFINE_STANDARD_HANDLE(XSControl_WorkSession, IFSelect_WorkSession)
0037 
0038 using XSControl_WorkSessionMap =
0039   NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)>;
0040 
0041 //! This WorkSession completes the basic one, by adding :
0042 //! - use of Controller, with norm selection...
0043 //! - management of transfers (both ways) with auxiliary classes
0044 //! TransferReader and TransferWriter
0045 //! -> these transfers may work with a Context List : its items
0046 //! are given by the user, according to the transfer to be
0047 //! i.e. it is interpreted by the Actors
0048 //! Each item is accessed by a Name
0049 class XSControl_WorkSession : public IFSelect_WorkSession
0050 {
0051 public:
0052   Standard_EXPORT XSControl_WorkSession();
0053 
0054   ~XSControl_WorkSession() { ClearBinders(); }
0055 
0056   //! In addition to basic ClearData, clears Transfer and Management
0057   //! for interactive use, for mode = 0,1,2 and over 4
0058   //! Plus : mode = 5 to clear Transfers (both ways) only
0059   //! mode = 6 to clear enforced results
0060   //! mode = 7 to clear transfers, results
0061   Standard_EXPORT virtual void ClearData(const Standard_Integer theMode) Standard_OVERRIDE;
0062 
0063   //! Selects a Norm defined by its name.
0064   //! A Norm is described and handled by a Controller
0065   //! Returns True if done, False if <normname> is unknown
0066   //!
0067   //! The current Profile for this Norm is taken.
0068   Standard_EXPORT Standard_Boolean SelectNorm(const Standard_CString theNormName);
0069 
0070   //! Selects a Norm defined by its Controller itself
0071   Standard_EXPORT void SetController(const Handle(XSControl_Controller)& theCtl);
0072 
0073   //! Returns the name of the last Selected Norm. If none is
0074   //! defined, returns an empty string
0075   //! By default, returns the complete name of the norm
0076   //! If <rsc> is True, returns the short name used for resource
0077   Standard_EXPORT Standard_CString
0078     SelectedNorm(const Standard_Boolean theRsc = Standard_False) const;
0079 
0080   //! Returns the norm controller itself
0081   const Handle(XSControl_Controller)& NormAdaptor() const { return myController; }
0082 
0083   //! Returns the current Context List, Null if not defined
0084   //! The Context is given to the TransientProcess for TransferRead
0085   const XSControl_WorkSessionMap& Context() const { return myContext; }
0086 
0087   //! Sets the current Context List, as a whole
0088   //! Sets it to the TransferReader
0089   Standard_EXPORT void SetAllContext(const XSControl_WorkSessionMap& theContext);
0090 
0091   //! Clears the whole current Context (nullifies it)
0092   Standard_EXPORT void ClearContext();
0093 
0094   //! Prints the transfer status of a transferred item, as being
0095   //! the Mapped n0 <num>, from MapWriter if <wri> is True, or
0096   //! from MapReader if <wri> is False
0097   //! Returns True when done, False else (i.e. num out of range)
0098   Standard_EXPORT Standard_Boolean PrintTransferStatus(const Standard_Integer theNum,
0099                                                        const Standard_Boolean theWri,
0100                                                        Standard_OStream&      theS) const;
0101 
0102   //! Sets a Transfer Reader, by internal ways, according mode :
0103   //! 0 recreates it clear,  1 clears it (does not recreate)
0104   //! 2 aligns Roots of TransientProcess from final Results
0105   //! 3 aligns final Results from Roots of TransientProcess
0106   //! 4 begins a new transfer (by BeginTransfer)
0107   //! 5 recreates TransferReader then begins a new transfer
0108   Standard_EXPORT void InitTransferReader(const Standard_Integer theMode);
0109 
0110   //! Sets a Transfer Reader, which manages transfers on reading
0111   Standard_EXPORT void SetTransferReader(const Handle(XSControl_TransferReader)& theTR);
0112 
0113   //! Returns the Transfer Reader, Null if not set
0114   const Handle(XSControl_TransferReader)& TransferReader() const { return myTransferReader; }
0115 
0116   //! Returns the TransientProcess(internal data for TransferReader)
0117   Standard_EXPORT Handle(Transfer_TransientProcess) MapReader() const;
0118 
0119   //! Changes the Map Reader, i.e. considers that the new one
0120   //! defines the relevant read results (forgets the former ones)
0121   //! Returns True when done, False in case of bad definition, i.e.
0122   //! if Model from TP differs from that of Session
0123   Standard_EXPORT Standard_Boolean SetMapReader(const Handle(Transfer_TransientProcess)& theTP);
0124 
0125   //! Returns the result attached to a starting entity
0126   //! If <mode> = 0, returns Final Result
0127   //! If <mode> = 1, considers Last Result
0128   //! If <mode> = 2, considers Final, else if absent, Last
0129   //! returns it as Transient, if result is not transient returns
0130   //! the Binder
0131   //! <mode> = 10,11,12 idem but returns the Binder itself
0132   //! (if it is not, e.g. Shape, returns the Binder)
0133   //! <mode> = 20, returns the ResultFromModel
0134   Standard_EXPORT Handle(Standard_Transient) Result(const Handle(Standard_Transient)& theEnt,
0135                                                     const Standard_Integer theMode) const;
0136 
0137   //! Commands the transfer of, either one entity, or a list
0138   //! I.E. calls the TransferReader after having analysed <ents>
0139   //! It is cumulated from the last BeginTransfer
0140   //! <ents> is processed by GiveList, hence :
0141   //! - <ents> a Selection : its SelectionResult
0142   //! - <ents> a HSequenceOfTransient : this list
0143   //! - <ents> the Model : in this specific case, all the roots,
0144   //! with no cumulation of former transfers (TransferReadRoots)
0145   Standard_EXPORT Standard_Integer
0146     TransferReadOne(const Handle(Standard_Transient)& theEnts,
0147                     const Message_ProgressRange&      theProgress = Message_ProgressRange());
0148 
0149   //! Commands the transfer of all the root entities of the model
0150   //! i.e. calls TransferRoot from the TransferReader with the Graph
0151   //! No cumulation with former calls to TransferReadOne
0152   Standard_EXPORT Standard_Integer
0153     TransferReadRoots(const Message_ProgressRange& theProgress = Message_ProgressRange());
0154 
0155   //! produces and returns a new Model well conditioned
0156   //! It is produced by the Norm Controller
0157   //! It can be Null (if this function is not implemented)
0158   Standard_EXPORT Handle(Interface_InterfaceModel) NewModel();
0159 
0160   //! Returns the Transfer Reader, Null if not set
0161   const Handle(XSControl_TransferWriter)& TransferWriter() const { return myTransferWriter; }
0162 
0163   //! Changes the Map Reader, i.e. considers that the new one
0164   //! defines the relevant read results (forgets the former ones)
0165   //! Returns True when done, False if <FP> is Null
0166   Standard_Boolean SetMapWriter(const Handle(Transfer_FinderProcess)& theFP)
0167   {
0168     if (theFP.IsNull())
0169       return Standard_False;
0170     myTransferWriter->SetFinderProcess(theFP);
0171     return Standard_True;
0172   }
0173 
0174   //! Transfers a Shape from CasCade to a model of current norm,
0175   //! according to the last call to SetModeWriteShape
0176   //! Returns status :Done if OK, Fail if error during transfer,
0177   //! Error if transfer badly initialised
0178   Standard_EXPORT IFSelect_ReturnStatus
0179     TransferWriteShape(const TopoDS_Shape&          theShape,
0180                        const Standard_Boolean       theCompGraph = Standard_True,
0181                        const Message_ProgressRange& theProgress  = Message_ProgressRange());
0182 
0183   //! Returns the check-list of last transfer (write)
0184   //! It is recorded in the FinderProcess, but it must be bound with
0185   //! resulting entities (in the resulting file model) rather than
0186   //! with original objects (in fact, their mappers)
0187   Standard_EXPORT Interface_CheckIterator TransferWriteCheckList() const;
0188 
0189   const Handle(XSControl_Vars)& Vars() const { return myVars; }
0190 
0191   void SetVars(const Handle(XSControl_Vars)& theVars) { myVars = theVars; }
0192 
0193   DEFINE_STANDARD_RTTIEXT(XSControl_WorkSession, IFSelect_WorkSession)
0194 
0195 private:
0196   //! Clears binders
0197   Standard_EXPORT void ClearBinders();
0198 
0199 private:
0200   Handle(XSControl_Controller)     myController;
0201   Handle(XSControl_TransferReader) myTransferReader;
0202   Handle(XSControl_TransferWriter) myTransferWriter;
0203   XSControl_WorkSessionMap         myContext;
0204   Handle(XSControl_Vars)           myVars;
0205 };
0206 
0207 #endif // _XSControl_WorkSession_HeaderFile