OpenCOVER
coVRPlugin.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 COVR_PLUGIN_H
9#define COVR_PLUGIN_H
10
24#include <util/coExport.h>
25#include <osg/Matrix>
26#include <osg/Drawable>
27#include <cover/coVRDynLib.h>
28#include <cstdlib>
29
30namespace osg
31{
32class Node;
33class Group;
34}
35
36namespace vrui
37{
38class coMenuItem;
39}
40
41namespace covise
42{
43class Message;
44class UdpMessage;
45class DataHandle;
46}
47
48// use COVERPLUGIN(YourMainPluginClass) in your plugin implementation
49#define COVERPLUGIN(Plugin) \
50 extern "C" PLUGINEXPORT opencover::coVRPlugin *coVRPluginInit() \
51 { \
52 opencover::coVRPlugin *p = new Plugin; \
53 if (p) \
54 p->setName(#Plugin); \
55 return p; \
56 }
57
58namespace opencover
59{
60class RenderObject;
61class coInteractor;
62class Url;
63
69//
71
72class COVEREXPORT coVRPlugin
73{
74 friend class coVRPluginList;
75
76public:
81 Fatal
82 };
83
86
88 virtual ~coVRPlugin();
89
91 virtual bool init()
92 {
93 return true;
94 }
95
97 virtual bool init2()
98 {
99 return true;
100 }
101
103 virtual bool destroy()
104 {
105 return true;
106 }
107
109 const char *getName() const
110 {
111 return m_name.c_str();
112 }
113
115 void setName(const char *sn);
116
118 virtual void notify(NotificationLevel level, const char *text)
119 {
120 (void)level;
121 (void)text;
122 }
123
128 virtual void addNode(osg::Node *, const RenderObject * = NULL)
129 {
130 }
131
133 virtual void removeNode(osg::Node *, bool isGroup, osg::Node *realNode)
134 {
135 (void)isGroup;
136 }
137
139 virtual void addObject(const RenderObject *container, osg::Group *parent,
140 const RenderObject *geometry, const RenderObject *normals, const RenderObject *colors, const RenderObject *texture)
141 {
142 (void)container;
143 (void)parent;
144 (void)geometry;
145 (void)normals;
146 (void)colors;
147 (void)texture;
148 }
149
151 virtual void removeObject(const char *objName, bool replaceFlag)
152 {
153 (void)objName;
154 (void)replaceFlag;
155 }
156
158 virtual void newInteractor(const RenderObject *container, coInteractor *it)
159 {
160 (void)container;
161 (void)it;
162 }
163
165 virtual bool requestInteraction(coInteractor *inter, osg::Node *triggerNode, bool isMouse)
166 {
167 (void)inter;
168 (void)triggerNode;
169 (void)isMouse;
170 return false;
171 }
172
174 virtual void coviseError(const char *error)
175 {
176 (void)error;
177 }
178
180 virtual void guiToRenderMsg(const char *msg)
181 {
182 (void)(msg);
183 };
184
187 virtual bool update()
188 {
189 return false; // don't request that scene be re-rendered
190 }
191
193 virtual void preFrame()
194 {
195 }
196
198 virtual void postFrame()
199 {
200 }
201
203 virtual void preDraw(osg::RenderInfo &)
204 {
205 }
206
208 virtual void preSwapBuffers(int /*windowNumber*/)
209 {
210 }
211
213 virtual void clusterSyncDraw()
214 {
215 }
216
218 virtual void postSwapBuffers(int /*windowNumber*/)
219 {
220 }
221
223 virtual void param(const char *paramName, bool inMapLoading)
224 {
225 (void)paramName;
226 (void)inMapLoading;
227 }
228
230 virtual void key(int type, int keySym, int mod)
231 {
232 (void)type;
233 (void)keySym;
234 (void)mod;
235 }
236
238 virtual void userEvent(int mod)
239 {
240 (void)mod;
241 }
242
243 // this function is called if a message arrives
244 virtual void message(int toWhom, int type, int length, const void *data)
245 {
246 (void)toWhom;
247 (void)type;
248 (void)length;
249 (void)data;
250 }
251 // this function is called if a UDPmessage arrives
252 virtual void UDPmessage(covise::UdpMessage* msg)
253 {
254 (void)msg;
255 }
256
257
261 virtual void setTimestep(int t)
262 {
263 (void)t;
264 }
265
268 virtual void requestTimestep(int t)
269 {
270 commitTimestep(t);
271 }
272
274 virtual void getMatrix(int station, osg::Matrix &mat)
275 {
276 (void)station;
277 (void)mat;
278 }
279
281 virtual unsigned int button(int station)
282 {
283 (void)station;
284 return 0;
285 }
286
288 virtual int wheel(int station)
289 {
290 (void)station;
291 return 0;
292 }
293
295 virtual void requestQuit(bool killSession)
296 {
297 (void)killSession;
298 }
299
301 virtual bool sendVisMessage(const covise::Message *msg)
302 {
303 (void)msg;
304 return false;
305 }
306
309 {
310 return false;
311 }
312
314 virtual std::string collaborativeSessionId() const
315 {
316 return "";
317 }
318
319
321 virtual covise::Message *waitForVisMessage(int messageType)
322 {
323 (void)messageType;
324 return NULL;
325 }
326
328 virtual bool executeAll()
329 {
330 return false;
331 }
332
334 virtual void expandBoundingSphere(osg::BoundingSphere &bs)
335 {
336 (void)bs;
337 }
338
339 virtual bool windowCreate(int num)
340 {
341 (void)num;
342 return false;
343 }
344
345 virtual void windowCheckEvents(int num)
346 {
347 (void)num;
348 }
349
350 virtual void windowUpdateContents(int num)
351 {
352 (void)num;
353 }
354
355 virtual void windowDestroy(int num)
356 {
357 (void)num;
358 }
359
360 virtual void windowFullScreen(int num, bool state)
361 {
362 (void)num;
363 (void)state;
364 }
365
367 virtual bool updateViewer()
368 {
369 return false; // no update, no re-render required
370 }
371
372protected:
374 void commitTimestep(int t);
375
376private:
377 void requestTimestepWrapper(int t);
378
379 bool m_initDone;
380 std::string m_name;
381 CO_SHLIB_HANDLE handle;
382 int m_outstandingTimestep;
383};
384}
385#endif
dynamic library loading
void * CO_SHLIB_HANDLE
Definition: coVRDynLib.h:36
double OSGVRUIEXPORT mod(double a, double b)
Definition: ARToolKit.h:33
Definition: coClusterStat.h:29
Definition: coTabletUI.h:51
collaborative interface manager
Definition: coVRCommunication.h:41
@ Fatal
Definition: coVRPluginSupport.h:143
abstract feedback class for interacting with parameters of visualization modules (e....
Definition: coInteractor.h:37
make sure to clean up properly in the plugin's dtor
Definition: coVRPlugin.h:73
const char * getName() const
retrieve the plugin's name
Definition: coVRPlugin.h:109
virtual void postFrame()
this function is called from the main thread after a frame was rendered
Definition: coVRPlugin.h:198
virtual void removeObject(const char *objName, bool replaceFlag)
this function is called when a COVISE Object is removed
Definition: coVRPlugin.h:151
virtual void windowUpdateContents(int num)
Definition: coVRPlugin.h:350
virtual bool requestInteraction(coInteractor *inter, osg::Node *triggerNode, bool isMouse)
this function is called when COVER wants to enable interaction with an interactor,...
Definition: coVRPlugin.h:165
virtual void windowCheckEvents(int num)
Definition: coVRPlugin.h:345
virtual void postSwapBuffers(int)
this function is called from the draw thread after swapbuffers
Definition: coVRPlugin.h:218
virtual void requestTimestep(int t)
Definition: coVRPlugin.h:268
virtual void expandBoundingSphere(osg::BoundingSphere &bs)
allow plugin to expand bounding sphere
Definition: coVRPlugin.h:334
void commitTimestep(int t)
call as a response to requestTimestep(t) when timestep t is prepared
virtual std::string collaborativeSessionId() const
for visualisation system plugins: return string identifying collaborative session uniquely
Definition: coVRPlugin.h:314
virtual void windowDestroy(int num)
Definition: coVRPlugin.h:355
virtual bool init()
this function is called when COVER is up and running and the plugin is initialized
Definition: coVRPlugin.h:91
virtual void guiToRenderMsg(const char *msg)
this function is called if a message from the gui is received
Definition: coVRPlugin.h:180
virtual void clusterSyncDraw()
this function is called from the main thread after rendering has finished on all nodes and before any...
Definition: coVRPlugin.h:213
virtual bool windowCreate(int num)
Definition: coVRPlugin.h:339
virtual void windowFullScreen(int num, bool state)
Definition: coVRPlugin.h:360
NotificationLevel
Definition: coVRPlugin.h:77
@ Error
Definition: coVRPlugin.h:80
@ Info
Definition: coVRPlugin.h:78
@ Warning
Definition: coVRPlugin.h:79
virtual void preDraw(osg::RenderInfo &)
this function is called from the draw thread before drawing the scenegraph (after drawing the AR back...
Definition: coVRPlugin.h:203
virtual void getMatrix(int station, osg::Matrix &mat)
for Trackingsystem plugins: return the Matrix of device station
Definition: coVRPlugin.h:274
virtual void param(const char *paramName, bool inMapLoading)
this function is called whenever a module parameter of the renderer has changed
Definition: coVRPlugin.h:223
virtual void preSwapBuffers(int)
this function is called from the draw thread before swapbuffers
Definition: coVRPlugin.h:208
virtual bool destroy()
reimplement to do early cleanup work and return false to prevent unloading
Definition: coVRPlugin.h:103
coVRPlugin()
called early, if loaded from config, before COVER is fully initialized
virtual unsigned int button(int station)
for Trackingsystem plugins: return the button state of device station
Definition: coVRPlugin.h:281
virtual void removeNode(osg::Node *, bool isGroup, osg::Node *realNode)
this function is called if a node in the scene graph is removed
Definition: coVRPlugin.h:133
virtual bool updateViewer()
let the plugin that has a grab on viewer update viewer matrix
Definition: coVRPlugin.h:367
virtual void userEvent(int mod)
this functions is called when a user event arrives
Definition: coVRPlugin.h:238
virtual bool sendVisMessage(const covise::Message *msg)
for visualisation system plugins: send message to system - return true if delivered
Definition: coVRPlugin.h:301
virtual void addNode(osg::Node *, const RenderObject *=NULL)
Definition: coVRPlugin.h:128
virtual bool executeAll()
for visualisation system plugins: execute data flow network - return true if delivered
Definition: coVRPlugin.h:328
virtual bool becomeCollaborativeMaster()
for visualisation system plugins: request to become master - return true if delivered
Definition: coVRPlugin.h:308
virtual void requestQuit(bool killSession)
for visualisation system plugins: request to terminate COVER or COVISE session
Definition: coVRPlugin.h:295
virtual int wheel(int station)
for Trackingsystem plugins: return the wheel state of device station
Definition: coVRPlugin.h:288
void setName(const char *sn)
set the plugin's name
virtual void addObject(const RenderObject *container, osg::Group *parent, const RenderObject *geometry, const RenderObject *normals, const RenderObject *colors, const RenderObject *texture)
this function is called whenever a COVISE object is received
Definition: coVRPlugin.h:139
virtual ~coVRPlugin()
called before plugin is unloaded
virtual void preFrame()
this function is called from the main thread before rendering a frame
Definition: coVRPlugin.h:193
virtual void UDPmessage(covise::UdpMessage *msg)
Definition: coVRPlugin.h:252
virtual void newInteractor(const RenderObject *container, coInteractor *it)
this function is called when COVER gets a new COVISE object with feedback attributes
Definition: coVRPlugin.h:158
virtual void key(int type, int keySym, int mod)
this functions is called when a key is pressed or released
Definition: coVRPlugin.h:230
virtual covise::Message * waitForVisMessage(int messageType)
for visualisation system plugins: wait for message, return NULL if no such plugin
Definition: coVRPlugin.h:321
virtual bool update()
Definition: coVRPlugin.h:187
virtual bool init2()
this function is called when files have been loaded
Definition: coVRPlugin.h:97
virtual void coviseError(const char *error)
this function is called if a error message from the controller is received
Definition: coVRPlugin.h:174
virtual void notify(NotificationLevel level, const char *text)
this function is called when COVER wants to display a message to the user
Definition: coVRPlugin.h:118
virtual void message(int toWhom, int type, int length, const void *data)
Definition: coVRPlugin.h:244
virtual void setTimestep(int t)
Definition: coVRPlugin.h:261
Definition: coVRPluginList.h:53
base class for data received from visualization systems (e.g. COVISE or Vistle)
Definition: RenderObject.h:147