COVISE Core
coModule.h
Go to the documentation of this file.
1/* This file is part of COVISE.
2
3 You can use it under the terms of the GNU Lesser General Public License
4 version 2.1 or later, see lgpl-2.1.txt.
5
6 * License: LGPL 2+ */
7
8#ifndef _CO_FEATURE_MODULE_H_
9#define _CO_FEATURE_MODULE_H_
10
11// 15.09.99
12
13#include <do/coDoPolygons.h>
14#include <appl/ApplInterface.h>
15#include "coBooleanParam.h"
16#include "coFileBrowserParam.h"
17#include "coChoiceParam.h"
18#include "coMaterialParam.h"
20#include "coColormapParam.h"
21#include "coColorParam.h"
22#include "coFloatParam.h"
23#include "coFloatSliderParam.h"
24#include "coFloatVectorParam.h"
25#include "coIntScalarParam.h"
26#include "coIntSliderParam.h"
27#include "coIntVectorParam.h"
28#include "coStringParam.h"
29#include "coTimerParam.h"
30#include "coInputPort.h"
31#include "coOutputPort.h"
32
33// forward declarations for pointers only
34
35namespace covise
36{
37
38class coUifElem;
39class coPort;
40class coUifSwitch;
41class coUifSwitchCase;
42
48{
49
50private:
52 enum
53 {
54 MAX_LEVELS = 64
55 };
56
58 enum
59 {
60 MAX_SOCKET = 256
61 };
62
64 coModule(const coModule &);
65
67 coModule &operator=(const coModule &);
68
69 // if we are in an open case : pointer to active case
70 coUifSwitchCase *d_actCase[MAX_LEVELS];
72
73 // if we are in an open switch : pointer to active case
74 coUifSwitch *d_actSwitch[MAX_LEVELS];
76
77 // list of registered sockets, number in list and handler Obj
78 int d_socket[MAX_SOCKET];
80
81 // static stubs for callback
82 static void quitCallback(void *userData, void *callbackData);
83 static void computeCallback(void *userData, void *callbackData);
84 static void paramCallback(bool inMapLoading, void *userData, void *callbackData);
85 static void feedbackCallback(void *userData, int len, const char *data);
86 static void portCallback(void *userData, void *callbackData);
87 static void addObjCallback(void *userData, void *callbackData);
88
89 // our internal callback for changed parameters
90 void localParam(bool inMapLoading, void *callbackData);
91 // our internal callback connection changing ports
92 void localPort(void *callbackData);
93
94 // whether we automatically fire up all parameters first to secure the order
96
97 // When this flag has been set, fire an EXEC message after returning
98 // from this event
100
101 // 'Grace period' to wait after self-exec to prevent overrinning next module
103
104 // Title of the module
105 char *d_title;
106
107 // initial Title of the module
109
110 //send description to controller and UIF's
111 void initDescription();
112
113protected:
114 // register a parameter port at the module: return 0 if ok, -1 on error
115 int add_port(coPort *param);
116
117 //should the module's name
118 //be propagated as attribute?
120
121 // find element by name : derived classes might access directly
122 coUifElem *findElem(const char *name);
123
124 // list of all UIF Elements and number of Elements in list
127
128 // our internal 'pre-compute' sets all non-immediate parameters
129 virtual void localCompute(void *callbackData);
130
131 // internal callback called if ADD_OBJECT messages arrive
132 virtual void localAddObject(void *callbackData);
133
134public:
136 enum
137 {
138 FAIL = -1,
140 STOP_PIPELINE = -1,
141 CONTINUE_PIPELINE = 0
142 };
143
144 // ------------------ Constructor / destructor --------------------------
145
147 coModule(int argc, char *argv[], const char *desc = NULL, bool propagate = false);
148
150 virtual ~coModule();
151
152 // --------------------- Utility functions ------------------------------
153
154 bool GoodOctTrees(const coDistributedObject *grid, const coDistributedObject *otree);
155
157 void selfExec();
158
160 void setExecGracePeriod(float gracePeriod);
161
162 // --------------------- Parameter switching ----------------------------
163
165 coChoiceParam *paraSwitch(const char *name, const char *desc);
166
168 int paraEndSwitch();
169
171 int paraCase(const char *name);
172
174 int paraCaseAdd(coPort *param);
175
177 int paraEndCase();
178
180 void autoInitParam(int value = 0);
181
182 // -------------------- add a socket to listen to -----------------------
183
185 void addSocket(int socket);
186
188 void removeSocket(int socket);
189
190 // --------------------- Covise Main-Loop et al -------------------------
191
193 virtual void init(int argc, char *argv[]);
194
196 virtual void start(int argc, char *argv[]);
197
199 // return either SUCCESS or FAIL
200 virtual int compute(const char *port);
201
203 // return either SUCCESS or FAIL
204 virtual int addObject(const char *objectNameToAdd, const char *objectNameToDelete);
205
207 virtual void param(const char *paramName, bool inMapLoading);
208
210 virtual void sockData(int sockNo);
211
213 virtual void feedback(int len, const char *data);
214
216 virtual void quit(void);
217
219 virtual void postInst();
220
223 virtual float idle();
224
226 virtual void handleMessages(float time);
227
229 virtual void mainLoop();
230
232 void stopPipeline();
233
234 // --------------------- Covise Main-Loop et al -------------------------
235
237 coBooleanParam *addBooleanParam(const char *name, const char *desc);
238
240 coFileBrowserParam *addFileBrowserParam(const char *name, const char *desc);
241
243 coChoiceParam *addChoiceParam(const char *name, const char *desc);
244
246 coColormapChoiceParam *addColormapChoiceParam(const char *name, const char *desc);
247
249 coMaterialParam *addMaterialParam(const char *name, const char *desc);
250
252 coColormapParam *addColormapParam(const char *name, const char *desc);
253
255 coColorParam *addColorParam(const char *name, const char *desc);
256
258 coFloatParam *addFloatParam(const char *name, const char *desc);
259
261 coFloatSliderParam *addFloatSliderParam(const char *name, const char *desc);
262
264 coFloatVectorParam *addFloatVectorParam(const char *name, const char *desc, int length = 3);
265
267 coIntScalarParam *addInt32Param(const char *name, const char *desc);
268
270 coIntSliderParam *addIntSliderParam(const char *name, const char *desc);
271
273 coIntVectorParam *addInt32VectorParam(const char *name, const char *desc, int length = 3);
274
276 coStringParam *addStringParam(const char *name, const char *desc);
277
279 coTimerParam *addTimerParam(const char *name, const char *desc);
280
282 coInputPort *addInputPort(const char *name, const char *types, const char *desc);
283
285 coOutputPort *addOutputPort(const char *name, const char *types, const char *desc);
286
287 // ------------------------------ Mapeditor message
289 void setInfo(const char *value) const;
290
292 void setTitle(const char *value);
294 {
295 return (strcmp(d_title, d_init_title) != 0);
296 };
297 const char *getTitle()
298 {
299 return d_title;
300 };
301};
302
304{
305public:
307 coFunctionModule(int argc, char *argv[], const char *desc = NULL, bool propagate = false)
308 : coModule(argc, argv, desc, propagate)
309 {
310 }
311
314 {
315 }
316};
317
318#define MODULE_MAIN(Category, Module) \
319 int main(int argc, char *argv[]) \
320 { \
321 coModule *app = new Module(argc, argv); \
322 app->start(argc, argv); \
323 }
324
325#define COMODULE
326}
327#endif
#define APIEXPORT
Definition: coExport.h:275
#define NULL
Definition: covise_list.h:22
GLuint start
Definition: khronos-glext.h:6343
GLsizei const GLfloat * value
Definition: khronos-glext.h:6760
GLsizei GLenum GLenum * types
Definition: khronos-glext.h:8471
GLuint const GLchar * name
Definition: khronos-glext.h:6722
GLfloat param
Definition: khronos-glext.h:6531
GLenum GLsizei len
Definition: khronos-glext.h:7440
GLenum GLuint GLenum GLsizei length
Definition: khronos-glext.h:6279
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: khronos-glext.h:6354
#define SUCCESS
Definition: coColors.cpp:27
#define FAIL
Definition: coColors.cpp:26
list of all chemical elements
Definition: coConfig.h:27
Definition: ApplInterface.h:49
@ MAX_PORTS
Definition: CoviseBase.h:72
Definition: coDistributedObject.h:296
Boolean value parameter.
Definition: coBooleanParam.h:30
parameter to choose values from a list
Definition: coChoiceParam.h:30
parameter to choose values from a list
Definition: coColormapChoiceParam.h:25
File browser parameter.
Definition: coColormapParam.h:31
Multiple float parameters.
Definition: coColorParam.h:25
File browser parameter.
Definition: coFileBrowserParam.h:30
single float parameter
Definition: coFloatParam.h:30
float slider parameter
Definition: coFloatSliderParam.h:30
Multiple float parameters.
Definition: coFloatVectorParam.h:30
Data input Port.
Definition: coInputPort.h:28
single integer parameter
Definition: coIntScalarParam.h:30
Integer slider parameter.
Definition: coIntSliderParam.h:30
Parameter for multiple integers.
Definition: coIntVectorParam.h:30
parameter to choose values from a list
Definition: coMaterialParam.h:25
Definition: coModule.h:48
int d_autoParamInit
Definition: coModule.h:95
int d_numElem
Definition: coModule.h:126
const char * getTitle()
Definition: coModule.h:297
int d_numActSwitch
Definition: coModule.h:75
bool _propagateObjectName
Definition: coModule.h:119
char * d_init_title
Definition: coModule.h:108
int d_execFlag
Definition: coModule.h:99
float d_execGracePeriod
Definition: coModule.h:102
char * d_title
Definition: coModule.h:105
int d_numSocket
Definition: coModule.h:79
int d_numActCase
Definition: coModule.h:71
bool titleChanged()
Definition: coModule.h:293
Definition: coModule.h:304
virtual ~coFunctionModule()
Destructor : virtual in case we derive objects.
Definition: coModule.h:313
coFunctionModule(int argc, char *argv[], const char *desc=NULL, bool propagate=false)
YAC-compatible constructor.
Definition: coModule.h:307
Definition: coOutputPort.h:27
Definition: coPort.h:25
Implements Covise string parameters.
Definition: coStringParam.h:30
Integer slider parameter.
Definition: coTimerParam.h:30
Definition: coUifElem.h:21
Definition: coUifSwitch.h:26
Definition: coUifSwitchCase.h:24