Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:36

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