Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-27 09:19:43

0001 // Created on: 1995-03-13
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_Controller_HeaderFile
0018 #define _XSControl_Controller_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <TCollection_AsciiString.hxx>
0024 #include <Standard_Transient.hxx>
0025 #include <NCollection_Sequence.hxx>
0026 #include <Standard_Integer.hxx>
0027 #include <TCollection_HAsciiString.hxx>
0028 #include <NCollection_Array1.hxx>
0029 #include <NCollection_HArray1.hxx>
0030 #include <NCollection_DynamicArray.hxx>
0031 #include <IFSelect_ReturnStatus.hxx>
0032 #include <NCollection_DataMap.hxx>
0033 #include <Message_ProgressRange.hxx>
0034 
0035 class IFSelect_WorkLibrary;
0036 class Interface_Protocol;
0037 class Transfer_ActorOfTransientProcess;
0038 class Transfer_ActorOfFinderProcess;
0039 class XSControl_WorkSession;
0040 class Interface_InterfaceModel;
0041 class Transfer_FinderProcess;
0042 class TopoDS_Shape;
0043 
0044 //! This class allows a general X-STEP engine to run generic
0045 //! functions on any interface norm, in the same way. It includes
0046 //! the transfer operations. I.e. it gathers the already available
0047 //! general modules, the engine has just to know it
0048 //!
0049 //! The important point is that a given X-STEP Controller is
0050 //! attached to a given couple made of an Interface Norm (such as
0051 //! IGES-5.1) and an application data model (CasCade Shapes for
0052 //! instance).
0053 //!
0054 //! Finally, Controller can be gathered in a general dictionary then
0055 //! retrieved later by a general call (method Recorded)
0056 //!
0057 //! It does not manage the produced data, but the Actors make the
0058 //! link between the norm and the application
0059 class XSControl_Controller : public Standard_Transient
0060 {
0061 public:
0062   //! Changes names
0063   //! if a name is empty, the formerly set one remains
0064   //! Remark : Does not call Record or AutoRecord
0065   Standard_EXPORT void SetNames(const char* const theLongName, const char* const theShortName);
0066 
0067   //! Records <me> is a general dictionary under Short and Long
0068   //! Names (see method Name)
0069   void AutoRecord() const
0070   {
0071     Record(Name(true));
0072     Record(Name(false));
0073   }
0074 
0075   //! Records <me> in a general dictionary under a name
0076   //! Error if <name> already used for another one
0077   Standard_EXPORT void Record(const char* const name) const;
0078 
0079   //! Returns the Controller attached to a given name
0080   //! Returns a Null Handle if <name> is unknown
0081   Standard_EXPORT static occ::handle<XSControl_Controller> Recorded(const char* const name);
0082 
0083   //! Returns a name, as given when initializing :
0084   //! rsc = False (D) : True Name attached to the Norm (long name)
0085   //! rsc = True : Name of the resource set (i.e. short name)
0086   const char* Name(const bool rsc = false) const
0087   {
0088     return (rsc ? myShortName.ToCString() : myLongName.ToCString());
0089   }
0090 
0091   //! Returns the Protocol attached to the Norm (from field)
0092   const occ::handle<Interface_Protocol>& Protocol() const { return myAdaptorProtocol; }
0093 
0094   //! Returns the SignType attached to the norm (from field)
0095   // szv:const occ::handle<IFSelect_Signature> & SignType1() const
0096   // szv:{ return mySignType; }
0097 
0098   //! Returns the WorkLibrary attached to the Norm. Remark that it
0099   //! has to be in phase with the Protocol (read from field)
0100   const occ::handle<IFSelect_WorkLibrary>& WorkLibrary() const { return myAdaptorLibrary; }
0101 
0102   //! Creates a new empty Model ready to receive data of the Norm
0103   //! Used to write data from Imagine to an interface file
0104   Standard_EXPORT virtual occ::handle<Interface_InterfaceModel> NewModel() const = 0;
0105 
0106   //! Returns the Actor for Read attached to the pair (norm,appli)
0107   //! It can be adapted for data of the input Model, as required
0108   //! Can be read from field then adapted with Model as required
0109   Standard_EXPORT virtual occ::handle<Transfer_ActorOfTransientProcess> ActorRead(
0110     const occ::handle<Interface_InterfaceModel>& model) const;
0111 
0112   //! Returns the Actor for Write attached to the pair (norm,appli)
0113   //! Read from field. Can be redefined
0114   Standard_EXPORT virtual occ::handle<Transfer_ActorOfFinderProcess> ActorWrite() const;
0115 
0116   //! Sets minimum and maximum values for modetrans (write)
0117   //! Erases formerly recorded bounds and values
0118   //! Actually only for shape
0119   //! Then, for each value a little help can be attached
0120   Standard_EXPORT void SetModeWrite(const int modemin, const int modemax, const bool shape = true);
0121 
0122   //! Attaches a short line of help to a value of modetrans (write)
0123   Standard_EXPORT void SetModeWriteHelp(const int         modetrans,
0124                                         const char* const help,
0125                                         const bool        shape = true);
0126 
0127   //! Returns recorded min and max values for modetrans (write)
0128   //! Actually only for shapes
0129   //! Returns True if bounds are set, False else (then, free value)
0130   Standard_EXPORT bool ModeWriteBounds(int& modemin, int& modemax, const bool shape = true) const;
0131 
0132   //! Tells if a value of <modetrans> is a good value(within bounds)
0133   //! Actually only for shapes
0134   Standard_EXPORT bool IsModeWrite(const int modetrans, const bool shape = true) const;
0135 
0136   //! Returns the help line recorded for a value of modetrans
0137   //! empty if help not defined or not within bounds or if values are free
0138   Standard_EXPORT const char* ModeWriteHelp(const int modetrans, const bool shape = true) const;
0139 
0140   //! Tells if <obj> (an application object) is a valid candidate
0141   //! for a transfer to a Model.
0142   //! By default, asks the ActorWrite if known (through a
0143   //! TransientMapper). Can be redefined
0144   Standard_EXPORT virtual bool RecognizeWriteTransient(const occ::handle<Standard_Transient>& obj,
0145                                                        const int modetrans = 0) const;
0146 
0147   //! Takes one Transient Object and transfers it to an
0148   //! InterfaceModel (already created, e.g. by NewModel)
0149   //! (result is recorded in the model by AddWithRefs)
0150   //! FP records produced results and checks
0151   //!
0152   //! Default uses ActorWrite; can be redefined as necessary
0153   //! Returned value is a status, as follows :
0154   //! 0  OK ,  1 No Result ,  2 Fail (e.g. exception raised)
0155   //! -1 bad conditions ,  -2 bad model or null model
0156   //! For type of object not recognized : should return 1
0157   Standard_EXPORT virtual IFSelect_ReturnStatus TransferWriteTransient(
0158     const occ::handle<Standard_Transient>&       obj,
0159     const occ::handle<Transfer_FinderProcess>&   FP,
0160     const occ::handle<Interface_InterfaceModel>& model,
0161     const int                                    modetrans   = 0,
0162     const Message_ProgressRange&                 theProgress = Message_ProgressRange()) const;
0163 
0164   //! Tells if a shape is valid for a transfer to a model
0165   //! Asks the ActorWrite (through a ShapeMapper)
0166   Standard_EXPORT virtual bool RecognizeWriteShape(const TopoDS_Shape& shape,
0167                                                    const int           modetrans = 0) const;
0168 
0169   //! Takes one Shape and transfers it to an
0170   //! InterfaceModel (already created, e.g. by NewModel)
0171   //! Default uses ActorWrite; can be redefined as necessary
0172   //! Returned value is a status, as follows :
0173   //! Done  OK ,  Void : No Result ,  Fail : Fail (e.g. exception)
0174   //! Error : bad conditions , bad model or null model
0175   Standard_EXPORT virtual IFSelect_ReturnStatus TransferWriteShape(
0176     const TopoDS_Shape&                          shape,
0177     const occ::handle<Transfer_FinderProcess>&   FP,
0178     const occ::handle<Interface_InterfaceModel>& model,
0179     const int                                    modetrans   = 0,
0180     const Message_ProgressRange&                 theProgress = Message_ProgressRange()) const;
0181 
0182   //! Records a Session Item, to be added for customisation of the Work Session.
0183   //! It must have a specific name.
0184   //! <setapplied> is used if <item> is a GeneralModifier, to decide
0185   //! If set to true, <item> will be applied to the hook list "send".
0186   //! Else, it is not applied to any hook list.
0187   //! Remark : this method is to be called at Create time,
0188   //! the recorded items will be used by Customise
0189   //! Warning : if <name> conflicts, the last recorded item is kept
0190   Standard_EXPORT void AddSessionItem(const occ::handle<Standard_Transient>& theItem,
0191                                       const char* const                      theName,
0192                                       const bool                             toApply = false);
0193 
0194   //! Returns an item given its name to record in a Session
0195   //! If <name> is unknown, returns a Null Handle
0196   Standard_EXPORT occ::handle<Standard_Transient> SessionItem(const char* const theName) const;
0197 
0198   //! Customises a WorkSession, by adding to it the recorded items (by AddSessionItem)
0199   Standard_EXPORT virtual void Customise(occ::handle<XSControl_WorkSession>& WS);
0200 
0201   const NCollection_DataMap<TCollection_AsciiString, occ::handle<Standard_Transient>>&
0202     AdaptorSession() const
0203   {
0204     return myAdaptorSession;
0205   }
0206 
0207   DEFINE_STANDARD_RTTIEXT(XSControl_Controller, Standard_Transient)
0208 
0209 protected:
0210   //! Initializing with names
0211   //! <theLongName>  is for the complete, official, long name
0212   //! <theShortName> is for the short name used for resources
0213   Standard_EXPORT XSControl_Controller(const char* const theLongName,
0214                                        const char* const theShortName);
0215 
0216   //! Records the name of a Static to be traced for a given use
0217   Standard_EXPORT void TraceStatic(const char* const theName, const int theUse);
0218 
0219   TCollection_AsciiString           myShortName;
0220   TCollection_AsciiString           myLongName;
0221   occ::handle<IFSelect_WorkLibrary> myAdaptorLibrary;
0222   occ::handle<Interface_Protocol>   myAdaptorProtocol;
0223   // szv:occ::handle<IFSelect_Signature> mySignType;
0224   occ::handle<Transfer_ActorOfTransientProcess>                                 myAdaptorRead;
0225   occ::handle<Transfer_ActorOfFinderProcess>                                    myAdaptorWrite;
0226   NCollection_DataMap<TCollection_AsciiString, occ::handle<Standard_Transient>> myAdaptorSession;
0227 
0228 private:
0229   NCollection_Sequence<occ::handle<Standard_Transient>>                   myAdaptorApplied;
0230   NCollection_DynamicArray<occ::handle<Standard_Transient>>               myParams;
0231   NCollection_DynamicArray<int>                                           myParamUses;
0232   occ::handle<NCollection_HArray1<occ::handle<TCollection_HAsciiString>>> myModeWriteShapeN;
0233 };
0234 
0235 #endif // _XSControl_Controller_HeaderFile