OpenCOVER
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
30 namespace osg
31 {
32 class Node;
33 class Group;
34 }
35 
36 namespace vrui
37 {
38 class coMenuItem;
39 }
40 
41 namespace covise
42 {
43 class Message;
44 }
45 
46 // use COVERPLUGIN(YourMainPluginClass) in your plugin implementation
47 #define COVERPLUGIN(Plugin) \
48  extern "C" PLUGINEXPORT opencover::coVRPlugin *coVRPluginInit() \
49  { \
50  opencover::coVRPlugin *p = new Plugin; \
51  if (p) \
52  p->setName(#Plugin); \
53  return p; \
54  }
55 
56 namespace opencover
57 {
58 class RenderObject;
59 class coInteractor;
60 class Url;
61 
67 //
69 
70 class COVEREXPORT coVRPlugin
71 {
72  friend class coVRPluginList;
73 
74 public:
80  };
81 
83  coVRPlugin();
84 
86  virtual ~coVRPlugin();
87 
89  virtual bool init()
90  {
91  return true;
92  }
93 
95  virtual bool init2()
96  {
97  return true;
98  }
99 
101  virtual bool destroy()
102  {
103  return true;
104  }
105 
107  const char *getName() const
108  {
109  return m_name.c_str();
110  }
111 
113  void setName(const char *sn);
114 
116  virtual void notify(NotificationLevel level, const char *text)
117  {
118  (void)level;
119  (void)text;
120  }
121 
126  virtual void addNode(osg::Node *, const RenderObject * = NULL)
127  {
128  }
129 
131  virtual void removeNode(osg::Node *, bool isGroup, osg::Node *realNode)
132  {
133  (void)isGroup;
134  }
135 
137  virtual void addObject(const RenderObject *container, osg::Group *parent,
138  const RenderObject *geometry, const RenderObject *normals, const RenderObject *colors, const RenderObject *texture)
139  {
140  (void)container;
141  (void)parent;
142  (void)geometry;
143  (void)normals;
144  (void)colors;
145  (void)texture;
146  }
147 
149  virtual void removeObject(const char *objName, bool replaceFlag)
150  {
151  (void)objName;
152  (void)replaceFlag;
153  }
154 
156  virtual void newInteractor(const RenderObject *container, coInteractor *it)
157  {
158  (void)container;
159  (void)it;
160  }
161 
163  virtual bool requestInteraction(coInteractor *inter, osg::Node *triggerNode, bool isMouse)
164  {
165  (void)inter;
166  (void)triggerNode;
167  (void)isMouse;
168  return false;
169  }
170 
172  virtual void coviseError(const char *error)
173  {
174  (void)error;
175  }
176 
178  virtual void guiToRenderMsg(const char *msg)
179  {
180  (void)(msg);
181  };
182 
185  virtual bool update()
186  {
187  return false; // don't request that scene be re-rendered
188  }
189 
191  virtual void preFrame()
192  {
193  }
194 
196  virtual void postFrame()
197  {
198  }
199 
201  virtual void preDraw(osg::RenderInfo &)
202  {
203  }
204 
206  virtual void preSwapBuffers(int /*windowNumber*/)
207  {
208  }
209 
211  virtual void clusterSyncDraw()
212  {
213  }
214 
216  virtual void postSwapBuffers(int /*windowNumber*/)
217  {
218  }
219 
221  virtual void param(const char *paramName, bool inMapLoading)
222  {
223  (void)paramName;
224  (void)inMapLoading;
225  }
226 
228  virtual void key(int type, int keySym, int mod)
229  {
230  (void)type;
231  (void)keySym;
232  (void)mod;
233  }
234 
236  virtual void userEvent(int mod)
237  {
238  (void)mod;
239  }
240 
241  // this function is called if a message arrives
242  virtual void message(int toWhom, int type, int length, const void *data)
243  {
244  (void)toWhom;
245  (void)type;
246  (void)length;
247  (void)data;
248  }
249 
253  virtual void setTimestep(int t)
254  {
255  (void)t;
256  }
257 
260  virtual void requestTimestep(int t)
261  {
262  commitTimestep(t);
263  }
264 
266  virtual void getMatrix(int station, osg::Matrix &mat)
267  {
268  (void)station;
269  (void)mat;
270  }
271 
273  virtual unsigned int button(int station)
274  {
275  (void)station;
276  return 0;
277  }
278 
280  virtual int wheel(int station)
281  {
282  (void)station;
283  return 0;
284  }
285 
287  virtual void requestQuit(bool killSession)
288  {
289  (void)killSession;
290  }
291 
293  virtual bool sendVisMessage(const covise::Message *msg)
294  {
295  (void)msg;
296  return false;
297  }
298 
301  {
302  return false;
303  }
304 
306  virtual covise::Message *waitForVisMessage(int messageType)
307  {
308  (void)messageType;
309  return NULL;
310  }
311 
313  virtual bool executeAll()
314  {
315  return false;
316  }
317 
319  virtual void expandBoundingSphere(osg::BoundingSphere &bs)
320  {
321  (void)bs;
322  }
323 
324  virtual bool windowCreate(int num)
325  {
326  (void)num;
327  return false;
328  }
329 
330  virtual void windowCheckEvents(int num)
331  {
332  (void)num;
333  }
334 
335  virtual void windowUpdateContents(int num)
336  {
337  (void)num;
338  }
339 
340  virtual void windowDestroy(int num)
341  {
342  (void)num;
343  }
344 
345  virtual void windowFullScreen(int num, bool state)
346  {
347  (void)num;
348  (void)state;
349  }
350 
352  virtual bool updateViewer()
353  {
354  return false; // no update, no re-render required
355  }
356 
357 protected:
359  void commitTimestep(int t);
360 
361 private:
362  void requestTimestepWrapper(int t);
363 
364  bool m_initDone;
365  std::string m_name;
366  CO_SHLIB_HANDLE handle;
367  int m_outstandingTimestep;
368 };
369 }
370 #endif
virtual void windowUpdateContents(int num)
Definition: coVRPlugin.h:335
NotificationLevel
Definition: coVRPlugin.h:75
virtual bool updateViewer()
let the plugin that has a grab on viewer update viewer matrix
Definition: coVRPlugin.h:352
virtual unsigned int button(int station)
for Trackingsystem plugins: return the button state of device station
Definition: coVRPlugin.h:273
base class for data received from visualization systems (e.g. COVISE or Vistle)
Definition: RenderObject.h:146
virtual covise::Message * waitForVisMessage(int messageType)
for visualisation system plugins: wait for message, return NULL if no such plugin ...
Definition: coVRPlugin.h:306
abstract feedback class for interacting with parameters of visualization modules (e.g. COVISE or Vistle)
Definition: coInteractor.h:36
virtual bool executeAll()
for visualisation system plugins: execute data flow network - return true if delivered ...
Definition: coVRPlugin.h:313
virtual int wheel(int station)
for Trackingsystem plugins: return the wheel state of device station
Definition: coVRPlugin.h:280
virtual void userEvent(int mod)
this functions is called when a user event arrives
Definition: coVRPlugin.h:236
Definition: coVRPluginList.h:45
virtual void expandBoundingSphere(osg::BoundingSphere &bs)
allow plugin to expand bounding sphere
Definition: coVRPlugin.h:319
virtual void removeObject(const char *objName, bool replaceFlag)
this function is called when a COVISE Object is removed
Definition: coVRPlugin.h:149
virtual void postSwapBuffers(int)
this function is called from the draw thread after swapbuffers
Definition: coVRPlugin.h:216
virtual bool init2()
this function is called when files have been loaded
Definition: coVRPlugin.h:95
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:137
virtual void param(const char *paramName, bool inMapLoading)
this function is called whenever a module parameter of the renderer has changed
Definition: coVRPlugin.h:221
virtual bool requestInteraction(coInteractor *inter, osg::Node *triggerNode, bool isMouse)
this function is called when COVER wants to enable interaction with an interactor, return true if plugin accepts request
Definition: coVRPlugin.h:163
virtual bool sendVisMessage(const covise::Message *msg)
for visualisation system plugins: send message to system - return true if delivered ...
Definition: coVRPlugin.h:293
dynamic library loading
virtual bool destroy()
reimplement to do early cleanup work and return false to prevent unloading
Definition: coVRPlugin.h:101
virtual void preFrame()
this function is called from the main thread before rendering a frame
Definition: coVRPlugin.h:191
virtual void key(int type, int keySym, int mod)
this functions is called when a key is pressed or released
Definition: coVRPlugin.h:228
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:116
virtual void windowCheckEvents(int num)
Definition: coVRPlugin.h:330
virtual void coviseError(const char *error)
this function is called if a error message from the controller is received
Definition: coVRPlugin.h:172
double OSGVRUIEXPORT mod(double a, double b)
virtual bool update()
Definition: coVRPlugin.h:185
make sure to clean up properly in the plugin&#39;s dtor
Definition: coVRPlugin.h:70
virtual bool windowCreate(int num)
Definition: coVRPlugin.h:324
Definition: coVRPlugin.h:77
Definition: coVRPluginSupport.h:143
virtual void preSwapBuffers(int)
this function is called from the draw thread before swapbuffers
Definition: coVRPlugin.h:206
virtual void clusterSyncDraw()
this function is called from the main thread after rendering has finished on all nodes and before any...
Definition: coVRPlugin.h:211
void * CO_SHLIB_HANDLE
Definition: coVRDynLib.h:36
virtual void setTimestep(int t)
Definition: coVRPlugin.h:253
virtual void getMatrix(int station, osg::Matrix &mat)
for Trackingsystem plugins: return the Matrix of device station
Definition: coVRPlugin.h:266
virtual void guiToRenderMsg(const char *msg)
this function is called if a message from the gui is received
Definition: coVRPlugin.h:178
virtual void requestTimestep(int t)
Definition: coVRPlugin.h:260
virtual void message(int toWhom, int type, int length, const void *data)
Definition: coVRPlugin.h:242
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:156
virtual void windowDestroy(int num)
Definition: coVRPlugin.h:340
virtual void addNode(osg::Node *, const RenderObject *=NULL)
Definition: coVRPlugin.h:126
const char * getName() const
retrieve the plugin&#39;s name
Definition: coVRPlugin.h:107
virtual void postFrame()
this function is called from the main thread after a frame was rendered
Definition: coVRPlugin.h:196
virtual bool init()
this function is called when COVER is up and running and the plugin is initialized ...
Definition: coVRPlugin.h:89
virtual void requestQuit(bool killSession)
for visualisation system plugins: request to terminate COVER or COVISE session
Definition: coVRPlugin.h:287
Definition: coVRPlugin.h:76
virtual bool becomeCollaborativeMaster()
for visualisation system plugins: request to become master - return true if delivered ...
Definition: coVRPlugin.h:300
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:131
Definition: coVRPlugin.h:78
virtual void windowFullScreen(int num, bool state)
Definition: coVRPlugin.h:345
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:201