1 -- Created on: 1995-03-14
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.
19 ---Purpose : Basic package to work functions of X-STEP (IFSelect & Co)
20 -- under control of DRAW
22 -- Works with some "static" data : a SessionPilot (used to run)
23 -- with its WorkSession and Model and TransferReader, a
26 uses TCollection, TColStd, TopTools,
27 gp, Geom, Geom2d, TopoDS, MoniTool,
28 Interface, Transfer, IFSelect, XSControl, Draw, SWDRAW, Message
33 ---Purpose : Gathers general commands for XSDRAW : initialisation control,
34 -- also commands to analyse the result of a transfer
35 -- (it is an appendix made of user callable functions)
40 ---Purpose : Takes variables to/from the DRAW session
42 --class ProgressIndicator;
43 ---Purpose : Implements ProgressIndicator for DRAW
45 -- Linking with DRAW function set
47 ChangeCommand (oldname,newname : CString);
48 ---Purpose : Changes the name under which a command of xstep is known by
49 -- Draw. This allows to avoid collisions
50 -- To be called before LoadDraw or any other xstep initialisation
52 RemoveCommand (oldname : CString);
53 ---Purpose : Removes a command from the interpretation list of Draw
54 -- To be called before LoadDraw or any other xstep initialisation
56 LoadSession returns Boolean;
57 ---Purpose : Defines the basic context to work with a X-STEP Session :
58 -- it performs the basic inits, also records the Controller
59 -- If the Controller is not yet set, it must be set after
60 -- (call to SetController)
61 -- LoadSession is called by LoadDraw
62 -- Returns True the first time, False if already called
64 LoadDraw (theCommands : in out Interpretor from Draw);
65 ---Purpose : Defines the context for using a X-STEP Session under DRAW
66 -- Once the various INITs have been done, a call to LoadDraw
67 -- records the defined commands for the X-STEP SessionPilot,
68 -- into the DRAW interpretation list.
69 -- "Set" commands are accessed under command xset
70 -- SDS>xset name command ...
71 -- Other commands can be accessed directly or under command xstep
72 -- SDS>command ... and SDS>xstep command ... are equivalent
74 -- Only the command xinit is accessed directly only :
75 -- SDS>xinit (from the already defined Controller)
76 -- SDS>xinit iges (first defines the Controller as for "iges")
78 -- It also records the function to be called by DRAW (not
79 -- declared because specific).
80 -- And it defines the context variables, i.e. a WorkSession, then
81 -- it calls SetController with the currently defined Controller
82 -- Remark : at least, the standard commands are recorded
84 -- See also Controller : it is part of the Context, but it must
85 -- be precised separately
87 Execute (command : CString; var : CString = "") returns Integer;
88 ---Purpose : Allows to execute a xstep-draw command from C++ program
89 -- Fixed form : Execute("command args...");
90 -- Form with a variable text part : add %s for the variable :
91 -- Execute ("command args %s args..",var) [var is a CString]
92 -- Returns the same value as returned by call from DRAW
94 Pilot returns mutable SessionPilot from IFSelect;
95 ---Purpose : Returns the SessionPilot (can be used for direct call)
97 Session returns mutable WorkSession from XSControl;
98 ---Purpose : Returns the WorkSession defined in AddDraw (through Pilot)
99 -- It is from XSControl, it brings functionnalities for Transfers
101 SetController (control : Controller from XSControl);
102 ---Purpose : Defines a Controller for the command "xinit" and applies it
103 -- (i.e. calls its method Customise)
105 Controller returns Controller from XSControl;
106 ---Purpose : Returns the Controller, a Null Handle if not yet defined
108 SetNorm (normname : CString; profile : CString = "") returns Boolean;
109 ---Purpose : Sets a norm by its name (controller recorded as <normname> )
110 -- Returns True if done, False if this norm is unknown
111 -- If <profile> is given, also sets the norm to <profile>
112 -- (if <profile> is undefined for <normname>, it is ignored)
114 -- Additionnal access to XSTEP data
116 Protocol returns Protocol from Interface;
117 ---Purpose : Returns the actually defined Protocol
119 Model returns mutable InterfaceModel from Interface;
120 ---Purpose : Returns the Model of the Session (it is Session()->Model() )
122 SetModel (model : mutable InterfaceModel from Interface; file : CString = "");
123 ---Purpose : Sets a Model in session (it is Session()->SetModel(model) )
124 -- If <file> is defined, SetLoadedFile is also done
126 NewModel returns InterfaceModel from Interface;
127 ---Purpose : Produces a new model (from the Controller), can be Null
128 -- Does not set it in the session
130 Entity (num : Integer) returns Transient;
131 ---Purpose : Returns the entity n0 <num> of the Model of the Session
132 -- (it is StartingEntity)
133 -- Null Handle if <num> is not suitable
135 Number (ent : Transient) returns Integer;
136 ---Purpose : Returns the number of an entity in the Model (StartingNumber)
137 -- 0 if <ent> unknown in the model, or null
139 SetTransferProcess (TP : mutable Transient);
140 ---Purpose : Sets a TransferProcess in order to analyse it (see Activator)
141 -- It can be either a FinderProcess or a TransientProcess, in
142 -- that case a new TransferReader is created on it
144 TransientProcess returns TransientProcess from Transfer;
145 ---Purpose : Returns the TransferProcess : TransientProcess detained by
146 -- the TransferReader
148 FinderProcess returns FinderProcess from Transfer;
149 ---Purpose : Returns the FinderProcess, detained by the TransferWriter
152 InitTransferReader (mode : Integer);
153 ---Purpose : Initialises a TransferReader, according to mode :
154 -- 0 nullifies it, 1 clears it (not nullify)
155 -- 2 sets it with TransientProcess & Model
156 -- 3 idem plus roots of TransientProcess
157 -- Remark : called with 0 at least at each SetModel/NewModel
159 TransferReader returns TransferReader from XSControl;
160 ---Purpose : Returns the current TransferReader, can be null
161 -- It detains the TransientProcess
163 -- Some useful functions
166 GetEntity (name : CString = "") returns Transient;
167 ---Purpose : Takes the name of an entity, either as argument, or (if <name>
168 -- is empty) on keybord, and returns the entity
169 -- name can be a label or a number (in alphanumeric), it is
170 -- searched by NumberFromLabel from WorkSession.
171 -- If <name> doesn't match en entity, a Null Handle is returned
173 GetEntityNumber (name : CString = "") returns Integer;
174 ---Purpose : Same as GetEntity, but returns the number in the model of the
175 -- entity. Returns 0 for null handle
177 GetList (first : CString = ""; second : CString = "")
178 returns HSequenceOfTransient from TColStd;
179 ---Purpose : Evaluates and returns a list of entity, from :
180 -- keyboard if <first> and <second> are empty, see below
181 -- first if second is empty : can be a number/label of an entity
182 -- or the name of a selection to be evaluated (standard)
183 -- first : name of a selection, evaluated from a list defined by
185 -- In case of failure, returns a Null Handle
187 FileAndVar (file, var, def : CString;
188 resfile, resvar : out AsciiString from TCollection)
190 ---Purpose : Analyses given file name and variable name, with a default
191 -- name for variables. Returns resulting file name and variable
192 -- name plus status "file to read"(True) or "already read"(False)
193 -- In the latter case, empty resfile means no file available
195 -- If <file> is null or empty or equates ".", considers Session
196 -- and returned status is False
197 -- Else, returns resfile = file and status is True
198 -- If <var> is neither null nor empty, resvar = var
199 -- Else, the root part of <resfile> is considered, if defined
200 -- Else, <def> is taken
202 MoreShapes (list : in out mutable HSequenceOfShape from TopTools;
203 name : CString) returns Integer;
204 ---Purpose : Analyses a name as designating Shapes from DRAW variables or
205 -- XSTEP transfer (last Transfer on Reading). <name> can be :
206 -- "*" : all the root shapes produced by last Transfer (Read)
207 -- i.e. considers roots of the TransientProcess
208 -- a name : a name of a variable DRAW
210 -- Returns the count of designated Shapes. Their list is put in
211 -- <list>. If <list> is null, it is firstly created. Then it is
212 -- completed (Append without Clear) by the Shapes found
213 -- Returns 0 if no Shape could be found