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