0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / XSDRAW / XSDRAW.hxx
CommitLineData
42cf5bc1 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
5//
6// This file is part of Open CASCADE Technology software library.
7//
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.
13//
14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
16
17#ifndef _XSDRAW_HeaderFile
18#define _XSDRAW_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_DefineAlloc.hxx>
22#include <Standard_Handle.hxx>
23
24#include <Standard_CString.hxx>
25#include <Standard_Boolean.hxx>
26#include <Draw_Interpretor.hxx>
27#include <Standard_Integer.hxx>
28#include <TColStd_HSequenceOfTransient.hxx>
29#include <TopTools_HSequenceOfShape.hxx>
30class IFSelect_SessionPilot;
31class XSControl_WorkSession;
32class XSControl_Controller;
33class Interface_Protocol;
34class Interface_InterfaceModel;
35class Standard_Transient;
36class Transfer_TransientProcess;
37class Transfer_FinderProcess;
38class XSControl_TransferReader;
39class TCollection_AsciiString;
40class XSDRAW_Functions;
41class XSDRAW_Vars;
42
43
44//! Basic package to work functions of X-STEP (IFSelect & Co)
45//! under control of DRAW
46//!
47//! Works with some "static" data : a SessionPilot (used to run)
48//! with its WorkSession and Model and TransferReader, a
49//! FinderProcess
50class XSDRAW
51{
52public:
53
54 DEFINE_STANDARD_ALLOC
55
56
57 //! Takes variables to/from the DRAW session
58 //! Implements ProgressIndicator for DRAW
59 //! Changes the name under which a command of xstep is known by
60 //! Draw. This allows to avoid collisions
61 //! To be called before LoadDraw or any other xstep initialisation
62 Standard_EXPORT static void ChangeCommand (const Standard_CString oldname, const Standard_CString newname);
63
64 //! Removes a command from the interpretation list of Draw
65 //! To be called before LoadDraw or any other xstep initialisation
66 Standard_EXPORT static void RemoveCommand (const Standard_CString oldname);
67
68 //! Defines the basic context to work with a X-STEP Session :
69 //! it performs the basic inits, also records the Controller
70 //! If the Controller is not yet set, it must be set after
71 //! (call to SetController)
72 //! LoadSession is called by LoadDraw
73 //! Returns True the first time, False if already called
74 Standard_EXPORT static Standard_Boolean LoadSession();
75
76 //! Defines the context for using a X-STEP Session under DRAW
77 //! Once the various INITs have been done, a call to LoadDraw
78 //! records the defined commands for the X-STEP SessionPilot,
79 //! into the DRAW interpretation list.
80 //! "Set" commands are accessed under command xset
81 //! SDS>xset name command ...
82 //! Other commands can be accessed directly or under command xstep
83 //! SDS>command ... and SDS>xstep command ... are equivalent
84 //!
85 //! Only the command xinit is accessed directly only :
86 //! SDS>xinit (from the already defined Controller)
87 //! SDS>xinit iges (first defines the Controller as for "iges")
88 //!
89 //! It also records the function to be called by DRAW (not
90 //! declared because specific).
91 //! And it defines the context variables, i.e. a WorkSession, then
92 //! it calls SetController with the currently defined Controller
93 //! Remark : at least, the standard commands are recorded
94 //!
95 //! See also Controller : it is part of the Context, but it must
96 //! be precised separately
97 Standard_EXPORT static void LoadDraw (Draw_Interpretor& theCommands);
98
99 //! Allows to execute a xstep-draw command from C++ program
100 //! Fixed form : Execute("command args...");
101 //! Form with a variable text part : add %s for the variable :
102 //! Execute ("command args %s args..",var) [var is a CString]
103 //! Returns the same value as returned by call from DRAW
104 Standard_EXPORT static Standard_Integer Execute (const Standard_CString command, const Standard_CString var = "");
105
106 //! Returns the SessionPilot (can be used for direct call)
107 Standard_EXPORT static Handle(IFSelect_SessionPilot) Pilot();
108
109 //! Returns the WorkSession defined in AddDraw (through Pilot)
110 //! It is from XSControl, it brings functionnalities for Transfers
111 Standard_EXPORT static Handle(XSControl_WorkSession) Session();
112
113 //! Defines a Controller for the command "xinit" and applies it
114 //! (i.e. calls its method Customise)
115 Standard_EXPORT static void SetController (const Handle(XSControl_Controller)& control);
116
117 //! Returns the Controller, a Null Handle if not yet defined
118 Standard_EXPORT static Handle(XSControl_Controller) Controller();
119
120 //! Sets a norm by its name (controller recorded as <normname> )
121 //! Returns True if done, False if this norm is unknown
122 //! If <profile> is given, also sets the norm to <profile>
123 //! (if <profile> is undefined for <normname>, it is ignored)
124 Standard_EXPORT static Standard_Boolean SetNorm (const Standard_CString normname, const Standard_CString profile = "");
125
126 //! Returns the actually defined Protocol
127 Standard_EXPORT static Handle(Interface_Protocol) Protocol();
128
129 //! Returns the Model of the Session (it is Session()->Model() )
130 Standard_EXPORT static Handle(Interface_InterfaceModel) Model();
131
132 //! Sets a Model in session (it is Session()->SetModel(model) )
133 //! If <file> is defined, SetLoadedFile is also done
134 Standard_EXPORT static void SetModel (const Handle(Interface_InterfaceModel)& model, const Standard_CString file = "");
135
136 //! Produces a new model (from the Controller), can be Null
137 //! Does not set it in the session
138 Standard_EXPORT static Handle(Interface_InterfaceModel) NewModel();
139
140 //! Returns the entity n0 <num> of the Model of the Session
141 //! (it is StartingEntity)
142 //! Null Handle if <num> is not suitable
143 Standard_EXPORT static Handle(Standard_Transient) Entity (const Standard_Integer num);
144
145 //! Returns the number of an entity in the Model (StartingNumber)
146 //! 0 if <ent> unknown in the model, or null
147 Standard_EXPORT static Standard_Integer Number (const Handle(Standard_Transient)& ent);
148
149 //! Sets a TransferProcess in order to analyse it (see Activator)
150 //! It can be either a FinderProcess or a TransientProcess, in
151 //! that case a new TransferReader is created on it
152 Standard_EXPORT static void SetTransferProcess (const Handle(Standard_Transient)& TP);
153
154 //! Returns the TransferProcess : TransientProcess detained by
155 //! the TransferReader
156 Standard_EXPORT static Handle(Transfer_TransientProcess) TransientProcess();
157
158 //! Returns the FinderProcess, detained by the TransferWriter
159 Standard_EXPORT static Handle(Transfer_FinderProcess) FinderProcess();
160
161 //! Initialises a TransferReader, according to mode :
162 //! 0 nullifies it, 1 clears it (not nullify)
163 //! 2 sets it with TransientProcess & Model
164 //! 3 idem plus roots of TransientProcess
165 //! Remark : called with 0 at least at each SetModel/NewModel
166 Standard_EXPORT static void InitTransferReader (const Standard_Integer mode);
167
168 //! Returns the current TransferReader, can be null
169 //! It detains the TransientProcess
170 Standard_EXPORT static Handle(XSControl_TransferReader) TransferReader();
171
172 //! Takes the name of an entity, either as argument, or (if <name>
173 //! is empty) on keybord, and returns the entity
174 //! name can be a label or a number (in alphanumeric), it is
175 //! searched by NumberFromLabel from WorkSession.
176 //! If <name> doesn't match en entity, a Null Handle is returned
177 Standard_EXPORT static Handle(Standard_Transient) GetEntity (const Standard_CString name = "");
178
179 //! Same as GetEntity, but returns the number in the model of the
180 //! entity. Returns 0 for null handle
181 Standard_EXPORT static Standard_Integer GetEntityNumber (const Standard_CString name = "");
182
183 //! Evaluates and returns a list of entity, from :
184 //! keyboard if <first> and <second> are empty, see below
185 //! first if second is empty : can be a number/label of an entity
186 //! or the name of a selection to be evaluated (standard)
187 //! first : name of a selection, evaluated from a list defined by
188 //! second
189 //! In case of failure, returns a Null Handle
190 Standard_EXPORT static Handle(TColStd_HSequenceOfTransient) GetList (const Standard_CString first = "", const Standard_CString second = "");
191
192 //! Analyses given file name and variable name, with a default
193 //! name for variables. Returns resulting file name and variable
194 //! name plus status "file to read"(True) or "already read"(False)
195 //! In the latter case, empty resfile means no file available
196 //!
197 //! If <file> is null or empty or equates ".", considers Session
198 //! and returned status is False
199 //! Else, returns resfile = file and status is True
200 //! If <var> is neither null nor empty, resvar = var
201 //! Else, the root part of <resfile> is considered, if defined
202 //! Else, <def> is taken
203 Standard_EXPORT static Standard_Boolean FileAndVar (const Standard_CString file, const Standard_CString var, const Standard_CString def, TCollection_AsciiString& resfile, TCollection_AsciiString& resvar);
204
205 //! Analyses a name as designating Shapes from DRAW variables or
206 //! XSTEP transfer (last Transfer on Reading). <name> can be :
207 //! "*" : all the root shapes produced by last Transfer (Read)
208 //! i.e. considers roots of the TransientProcess
209 //! a name : a name of a variable DRAW
210 //!
211 //! Returns the count of designated Shapes. Their list is put in
212 //! <list>. If <list> is null, it is firstly created. Then it is
213 //! completed (Append without Clear) by the Shapes found
214 //! Returns 0 if no Shape could be found
215 Standard_EXPORT static Standard_Integer MoreShapes (Handle(TopTools_HSequenceOfShape)& list, const Standard_CString name);
216
217
218
219
220protected:
221
222
223
224
225
226private:
227
228
229
230
231friend class XSDRAW_Functions;
232friend class XSDRAW_Vars;
233
234};
235
236
237
238
239
240
241
242#endif // _XSDRAW_HeaderFile