Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-08 09:34:13

0001 // Created on: 1995-03-14
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 _XSDRAW_HeaderFile
0018 #define _XSDRAW_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Handle.hxx>
0022 
0023 #include <Draw_Interpretor.hxx>
0024 #include <Standard_Transient.hxx>
0025 #include <NCollection_Sequence.hxx>
0026 #include <NCollection_HSequence.hxx>
0027 #include <XSControl_WorkSession.hxx>
0028 #include <TopoDS_Shape.hxx>
0029 class IFSelect_SessionPilot;
0030 class XSControl_WorkSession;
0031 class XSControl_Controller;
0032 class Interface_Protocol;
0033 class Interface_InterfaceModel;
0034 class Standard_Transient;
0035 class Transfer_TransientProcess;
0036 class Transfer_FinderProcess;
0037 class XSControl_TransferReader;
0038 class TCollection_AsciiString;
0039 class TDocStd_Document;
0040 
0041 //! Basic package to work functions of X-STEP (IFSelect & Co)
0042 //! under control of DRAW
0043 //!
0044 //! Works with some "static" data : a SessionPilot (used to run)
0045 //! with its WorkSession and Model and TransferReader, a
0046 //! FinderProcess
0047 class XSDRAW
0048 {
0049 public:
0050   //! Takes variables to/from the DRAW session
0051   //! Implements ProgressIndicator for DRAW
0052   //! Changes the name under which a command of xstep is known by
0053   //! Draw. This allows to avoid collisions
0054   //! To be called before LoadDraw or any other xstep initialisation
0055   Standard_EXPORT static void ChangeCommand(const char* const oldname, const char* const newname);
0056 
0057   //! Removes a command from the interpretation list of Draw
0058   //! To be called before LoadDraw or any other xstep initialisation
0059   Standard_EXPORT static void RemoveCommand(const char* const oldname);
0060 
0061   //! Defines the basic context to work with a X-STEP Session :
0062   //! it performs the basic inits, also records the Controller
0063   //! If the Controller is not yet set, it must be set after
0064   //! (call to SetController)
0065   //! LoadSession is called by LoadDraw
0066   //! Returns True the first time, False if already called
0067   Standard_EXPORT static bool LoadSession();
0068 
0069   //! Defines the context for using a X-STEP Session under DRAW
0070   //! Once the various INITs have been done, a call to LoadDraw
0071   //! records the defined commands for the X-STEP SessionPilot,
0072   //! into the DRAW interpretation list.
0073   //! "Set" commands are accessed under command xset
0074   //! SDS>xset name command ...
0075   //! Other commands can be accessed directly or under command xstep
0076   //! SDS>command ... and SDS>xstep command ... are equivalent
0077   //!
0078   //! Only the command xinit is accessed directly only:
0079   //! SDS>xinit (from the already defined Controller)
0080   //! SDS>xinit iges (first defines the Controller as for "iges")
0081   //!
0082   //! It also records the function to be called by DRAW (not
0083   //! declared because specific).
0084   //! And it defines the context variables, i.e. a WorkSession, then
0085   //! it calls SetController with the currently defined Controller
0086   //! Remark : at least, the standard commands are recorded
0087   //!
0088   //! See also Controller : it is part of the Context, but it must
0089   //! be precised separately
0090   Standard_EXPORT static void LoadDraw(Draw_Interpretor& theCommands);
0091 
0092   //! Allows to execute a xstep-draw command from C++ program
0093   //! Fixed form: Execute("command args...");
0094   //! Form with a variable text part : add %s for the variable :
0095   //! Execute ("command args %s args..",var) [var is a CString]
0096   //! Returns the same value as returned by call from DRAW
0097   Standard_EXPORT static int Execute(const char* const command, const char* const var = "");
0098 
0099   //! Returns the SessionPilot (can be used for direct call)
0100   Standard_EXPORT static occ::handle<IFSelect_SessionPilot> Pilot();
0101 
0102   //! Updates the WorkSession defined in AddDraw (through Pilot)
0103   //! It is from XSControl, it brings functionalities for Transfers
0104   Standard_EXPORT static void SetSession(const occ::handle<XSControl_WorkSession>& theSession);
0105 
0106   //! Returns the WorkSession defined in AddDraw (through Pilot)
0107   //! It is from XSControl, it brings functionalities for Transfers
0108   Standard_EXPORT static const occ::handle<XSControl_WorkSession> Session();
0109 
0110   //! Defines a Controller for the command "xinit" and applies it
0111   //! (i.e. calls its method Customise)
0112   Standard_EXPORT static void SetController(const occ::handle<XSControl_Controller>& control);
0113 
0114   //! Returns the Controller, a Null Handle if not yet defined
0115   Standard_EXPORT static occ::handle<XSControl_Controller> Controller();
0116 
0117   //! Sets a norm by its name (controller recorded as <normname> )
0118   //! Returns True if done, False if this norm is unknown
0119   Standard_EXPORT static bool SetNorm(const char* const normname);
0120 
0121   //! Returns the actually defined Protocol
0122   Standard_EXPORT static occ::handle<Interface_Protocol> Protocol();
0123 
0124   //! Returns the Model of the Session (it is Session()->Model() )
0125   Standard_EXPORT static occ::handle<Interface_InterfaceModel> Model();
0126 
0127   //! Sets a Model in session (it is Session()->SetModel(model) )
0128   //! If <file> is defined, SetLoadedFile is also done
0129   Standard_EXPORT static void SetModel(const occ::handle<Interface_InterfaceModel>& model,
0130                                        const char* const                            file = "");
0131 
0132   //! Produces a new model (from the Controller), can be Null
0133   //! Does not set it in the session
0134   Standard_EXPORT static occ::handle<Interface_InterfaceModel> NewModel();
0135 
0136   //! Returns the entity n0 <num> of the Model of the Session
0137   //! (it is StartingEntity)
0138   //! Null Handle if <num> is not suitable
0139   Standard_EXPORT static occ::handle<Standard_Transient> Entity(const int num);
0140 
0141   //! Returns the number of an entity in the Model (StartingNumber)
0142   //! 0 if <ent> unknown in the model, or null
0143   Standard_EXPORT static int Number(const occ::handle<Standard_Transient>& ent);
0144 
0145   //! Sets a TransferProcess in order to analyse it (see Activator)
0146   //! It can be either a FinderProcess or a TransientProcess, in
0147   //! that case a new TransferReader is created on it
0148   Standard_EXPORT static void SetTransferProcess(const occ::handle<Standard_Transient>& TP);
0149 
0150   //! Returns the TransferProcess : TransientProcess detained by
0151   //! the TransferReader
0152   Standard_EXPORT static occ::handle<Transfer_TransientProcess> TransientProcess();
0153 
0154   //! Returns the FinderProcess, detained by the TransferWriter
0155   Standard_EXPORT static occ::handle<Transfer_FinderProcess> FinderProcess();
0156 
0157   //! Initialises a TransferReader, according to mode:
0158   //! 0 nullifies it, 1 clears it (not nullify)
0159   //! 2 sets it with TransientProcess & Model
0160   //! 3 idem plus roots of TransientProcess
0161   //! Remark : called with 0 at least at each SetModel/NewModel
0162   Standard_EXPORT static void InitTransferReader(const int mode);
0163 
0164   //! Returns the current TransferReader, can be null
0165   //! It detains the TransientProcess
0166   Standard_EXPORT static occ::handle<XSControl_TransferReader> TransferReader();
0167 
0168   //! Takes the name of an entity, either as argument, or (if <name>
0169   //! is empty) on keyboard, and returns the entity
0170   //! name can be a label or a number (in alphanumeric), it is
0171   //! searched by NumberFromLabel from WorkSession.
0172   //! If <name> doesn't match en entity, a Null Handle is returned
0173   Standard_EXPORT static occ::handle<Standard_Transient> GetEntity(const char* const name = "");
0174 
0175   //! Same as GetEntity, but returns the number in the model of the
0176   //! entity. Returns 0 for null handle
0177   Standard_EXPORT static int GetEntityNumber(const char* const name = "");
0178 
0179   //! Evaluates and returns a list of entity, from :
0180   //! keyboard if <first> and <second> are empty, see below
0181   //! first if second is empty : can be a number/label of an entity
0182   //! or the name of a selection to be evaluated (standard)
0183   //! first : name of a selection, evaluated from a list defined by
0184   //! second
0185   //! In case of failure, returns a Null Handle
0186   Standard_EXPORT static occ::handle<NCollection_HSequence<occ::handle<Standard_Transient>>>
0187     GetList(const char* const first = "", const char* const second = "");
0188 
0189   //! Analyses given file name and variable name, with a default
0190   //! name for variables. Returns resulting file name and variable
0191   //! name plus status "file to read"(True) or "already read"(False)
0192   //! In the latter case, empty resfile means no file available
0193   //!
0194   //! If <file> is null or empty or equates ".", considers Session
0195   //! and returned status is False
0196   //! Else, returns resfile = file and status is True
0197   //! If <var> is neither null nor empty, resvar = var
0198   //! Else, the root part of <resfile> is considered, if defined
0199   //! Else, <def> is taken
0200   Standard_EXPORT static bool FileAndVar(const char* const        file,
0201                                          const char* const        var,
0202                                          const char* const        def,
0203                                          TCollection_AsciiString& resfile,
0204                                          TCollection_AsciiString& resvar);
0205 
0206   //! Analyses a name as designating Shapes from DRAW variables or
0207   //! XSTEP transfer (last Transfer on Reading). <name> can be :
0208   //! "*" : all the root shapes produced by last Transfer (Read)
0209   //! i.e. considers roots of the TransientProcess
0210   //! a name : a name of a variable DRAW
0211   //!
0212   //! Returns the count of designated Shapes. Their list is put in
0213   //! <list>. If <list> is null, it is firstly created. Then it is
0214   //! completed (Append without Clear) by the Shapes found
0215   //! Returns 0 if no Shape could be found
0216   Standard_EXPORT static int MoreShapes(occ::handle<NCollection_HSequence<TopoDS_Shape>>& list,
0217                                         const char* const                                 name);
0218 
0219   //! Extracts length unit from the static interface or document.
0220   //! Document unit has the highest priority.
0221   //! @return length unit in MM. 1.0 by default
0222   Standard_EXPORT static double GetLengthUnit(
0223     const occ::handle<TDocStd_Document>& theDoc = nullptr);
0224 
0225   //! Returns available work sessions with their associated files.
0226   Standard_EXPORT static XSControl_WorkSessionMap& WorkSessionList();
0227 
0228   //! Binds session and name into map recursively.
0229   //! Recursively means extract sub-sessions from main session.
0230   //! @param[in] theWS the session object
0231   //! @param[in] theName the session file name
0232   //! @param[out] theMap collection to keep session info
0233   Standard_EXPORT static void CollectActiveWorkSessions(
0234     const occ::handle<XSControl_WorkSession>& theWS,
0235     const TCollection_AsciiString&            theName,
0236     XSControl_WorkSessionMap&                 theMap);
0237 
0238   //! Binds current session with input name.
0239   //! @param[in] theName the session file name
0240   Standard_EXPORT static void CollectActiveWorkSessions(const TCollection_AsciiString& theName);
0241 
0242   //! Loads all Draw commands of XSDRAW. Used for plugin.
0243   Standard_EXPORT static void Factory(Draw_Interpretor& theDI);
0244 };
0245 
0246 #endif // _XSDRAW_HeaderFile