42cf5bc1 |
1 | // Created on: 1993-07-27 |
2 | // Created by: Christian CAILLET |
3 | // Copyright (c) 1993-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 _IFSelect_Activator_HeaderFile |
18 | #define _IFSelect_Activator_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_Type.hxx> |
22 | |
23 | #include <TCollection_AsciiString.hxx> |
24 | #include <MMgt_TShared.hxx> |
25 | #include <Standard_Integer.hxx> |
26 | #include <Standard_CString.hxx> |
27 | #include <Standard_Boolean.hxx> |
28 | #include <TColStd_HSequenceOfAsciiString.hxx> |
29 | #include <IFSelect_ReturnStatus.hxx> |
30 | class Standard_DomainError; |
31 | class TCollection_AsciiString; |
32 | class IFSelect_SessionPilot; |
33 | |
34 | |
35 | class IFSelect_Activator; |
36 | DEFINE_STANDARD_HANDLE(IFSelect_Activator, MMgt_TShared) |
37 | |
38 | //! Defines the general frame for working with a SessionPilot. |
39 | //! Each Activator treats a set of Commands. Commands are given as |
40 | //! alphanumeric strings. They can be of two main forms : |
41 | //! - classic, to list, evaluate, enrich the session (by itself) : |
42 | //! no specific remark, its complete execution must be described |
43 | //! - creation of a new item : instead of creatinf it plus adding |
44 | //! it to the session (which is a classic way), it is possible |
45 | //! to create it and make it recorded by the SessionPilot : |
46 | //! then, the Pilot will add it to the session; this way allows |
47 | //! the Pilot to manage itself named items |
48 | //! |
49 | //! In order to make easier the use of Activator, this class |
50 | //! provides a simple way to Select an Actor for a Command : |
51 | //! each sub-class of SectionActor defines the command titles it |
52 | //! recognizes, plus attaches a Number, unique for this sub-class, |
53 | //! to each distinct command title. |
54 | //! |
55 | //! Each time an action is required, the corresponding Number |
56 | //! can then be given to help the selection of the action to do. |
57 | //! |
58 | //! The result of an Execution must indicate if it is worth to be |
59 | //! recorded or not : see method Do |
60 | class IFSelect_Activator : public MMgt_TShared |
61 | { |
62 | |
63 | public: |
64 | |
65 | |
66 | //! Records, in a Dictionary available for all the Activators, |
67 | //! the command title an Activator can process, attached with |
68 | //! its number, proper for this Activator |
69 | //! <mode> allows to distinguish various execution modes |
70 | //! 0: default mode; 1 : for xset |
71 | Standard_EXPORT static void Adding (const Handle(IFSelect_Activator)& actor, const Standard_Integer number, const Standard_CString command, const Standard_Integer mode); |
72 | |
73 | //! Allows a self-definition by an Activator of the Commands it |
74 | //! processes, call the class method Adding (mode 0) |
75 | Standard_EXPORT void Add (const Standard_Integer number, const Standard_CString command) const; |
76 | |
77 | //! Same as Add but specifies that this command is candidate for |
78 | //! xset (creation of items, xset : named items; mode 1) |
79 | Standard_EXPORT void AddSet (const Standard_Integer number, const Standard_CString command) const; |
80 | |
81 | //! Removes a Command, if it is recorded (else, does nothing) |
82 | Standard_EXPORT static void Remove (const Standard_CString command); |
83 | |
42cf5bc1 |
84 | //! Selects, for a Command given by its title, an actor with its |
85 | //! command number. Returns True if found, False else |
86 | Standard_EXPORT static Standard_Boolean Select (const Standard_CString command, Standard_Integer& number, Handle(IFSelect_Activator)& actor); |
87 | |
88 | //! Returns mode recorded for a command. -1 if not found |
89 | Standard_EXPORT static Standard_Integer Mode (const Standard_CString command); |
90 | |
91 | //! Returns, for a root of command title, the list of possible |
92 | //! commands. |
93 | //! <mode> : -1 (D) for all commands if <commands> is empty |
94 | //! -1 + command : about a Group , >= 0 see Adding |
95 | //! By default, it returns the whole list of known commands. |
96 | Standard_EXPORT static Handle(TColStd_HSequenceOfAsciiString) Commands (const Standard_Integer mode = -1, const Standard_CString command = ""); |
97 | |
98 | //! Tries to execute a Command Line. <number> is the number of the |
99 | //! command for this Activator. It Must forecast to record the |
100 | //! result of the execution, for need of Undo-Redo |
101 | //! Must Returns : 0 for a void command (not to be recorded), |
102 | //! 1 if execution OK, -1 if command incorrect, -2 if error |
103 | //! on execution |
104 | Standard_EXPORT virtual IFSelect_ReturnStatus Do (const Standard_Integer number, const Handle(IFSelect_SessionPilot)& pilot) = 0; |
105 | |
106 | //! Sends a short help message for a given command identified by |
107 | //! it number for this Activator (must take one line max) |
108 | Standard_EXPORT virtual Standard_CString Help (const Standard_Integer number) const = 0; |
109 | |
110 | Standard_EXPORT Standard_CString Group() const; |
111 | |
112 | Standard_EXPORT Standard_CString File() const; |
113 | |
114 | //! Group and SetGroup define a "Group of commands" which |
115 | //! correspond to an Activator. Default is "XSTEP" |
116 | //! Also a file may be attached |
117 | Standard_EXPORT void SetForGroup (const Standard_CString group, const Standard_CString file = ""); |
118 | |
119 | |
120 | |
121 | |
92efcf78 |
122 | DEFINE_STANDARD_RTTIEXT(IFSelect_Activator,MMgt_TShared) |
42cf5bc1 |
123 | |
124 | protected: |
125 | |
126 | |
127 | //! Sets the default values |
128 | Standard_EXPORT IFSelect_Activator(); |
129 | |
130 | |
131 | |
132 | private: |
133 | |
134 | |
135 | TCollection_AsciiString thegroup; |
136 | TCollection_AsciiString thefile; |
137 | |
138 | |
139 | }; |
140 | |
141 | |
142 | |
143 | |
144 | |
145 | |
146 | |
147 | #endif // _IFSelect_Activator_HeaderFile |