OpenCOVER
coVRPluginList.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_LIST_H
9#define COVR_PLUGIN_LIST_H
10
24#include "coVRDynLib.h"
25#include "coVRPlugin.h"
26#include <osg/Drawable>
27#include <vrb/client/SharedState.h>
28#include <map>
29
30namespace vrb
31{
32 class UdpMessage;
33}
34
35namespace covise
36{
37class Message;
38class DataHandle;
39}
40
41namespace osg
42{
43class Node;
44class Group;
45}
46
47namespace opencover
48{
49class RenderObject;
50class coInteractor;
51
52class COVEREXPORT coVRPluginList
53{
54 friend class coVRPluginSupport;
55 friend class OpenCOVER;
56
57public:
59 {
64 NumPluginDomains // keep last
65 };
66
67 // plugin management functions
72
74 coVRPlugin *getPlugin(const char *name) const;
75
77 coVRPlugin *addPlugin(const char *name, PluginDomain domain=Default);
78
81
82 //
83 // methods forwarded to plugins
84
86 void notify(int level, const char *text) const;
87
89 void addNode(osg::Node *, const RenderObject *o = NULL, coVRPlugin *addingPlugin = NULL) const;
90
92 void addObject(const RenderObject *container, osg::Group *root,
93 const RenderObject *geometry, const RenderObject *normals, const RenderObject *colors, const RenderObject *texture) const;
94
96 void newInteractor(const RenderObject *container, coInteractor *it) const;
97
99 bool requestInteraction(coInteractor *inter, osg::Node *triggerNode, bool isMouse);
100
102 void coviseError(const char *error) const;
103
105 void guiToRenderMsg(const char *msg) const;
106
108 void removeObject(const char *objName, bool replaceFlag) const;
110 void removeNode(osg::Node *node, bool isGroup = false, osg::Node *realNode = NULL) const;
112 bool update() const;
114 void preFrame();
116 void postFrame() const;
118 void preDraw(osg::RenderInfo &renderInfo) const;
120 void preSwapBuffers(int windowNumber) const;
122 void clusterSyncDraw() const;
124 void postSwapBuffers(int windowNumber) const;
126 void param(const char *paramName, bool inMapLoading) const;
128 bool key(int type, int keySym, int mod) const;
130 bool userEvent(int mod) const;
132 void requestTimestep(int timestep);
134 void setTimestep(int timestep);
136 void message(int toWhom, int t, int l, const void *b) const;
138 void UDPmessage(covise::UdpMessage* msg) const;
141 void forwardMessage(const covise::DataHandle &dh) const;
143 void requestQuit(bool killSession) const;
145 bool sendVisMessage(const covise::Message *msg) const;
149 covise::Message *waitForVisMessage(int messageType) const;
151 bool executeAll() const;
153 void expandBoundingSphere(osg::BoundingSphere &bs) const;
154
156 void commitTimestep(int t, coVRPlugin *caller);
157
158 void unloadAllPlugins(PluginDomain domain=Default);
159
160private:
163 coVRPluginList(const coVRPluginList &) = delete;
164 coVRPluginList(coVRPluginList &&) = delete;
165 coVRPluginList &operator=(const coVRPluginList &) = delete;
166 coVRPluginList &operator=(coVRPluginList &&) = delete;
168 void init();
170 void init2();
172 void unloadQueued();
174 void manage(coVRPlugin *plug, PluginDomain domain);
176 void unmanage(coVRPlugin *plug);
177
179 coVRPlugin *loadPlugin(const char *name, bool showErrors = true);
180
181 void grabKeyboard(coVRPlugin *);
182 coVRPlugin *keyboardGrabber() const
183 {
184 return keyboardPlugin;
185 }
186 int pointerGrabbed;
187 coVRPlugin *keyboardPlugin;
188
189 void grabViewer(coVRPlugin *);
190 coVRPlugin *viewerGrabber() const;
191 coVRPlugin *viewerPlugin = nullptr;
192
193 static coVRPluginList *singleton;
194 void updateState();
195
196 typedef std::map<std::string, coVRPlugin *> PluginMap;
197 PluginMap m_plugins;
198 std::vector<coVRPlugin *> m_loadedPlugins[NumPluginDomains];
199 std::map<std::string, std::unique_ptr<vrb::SharedState<bool>>> m_sharedPlugins;
200 typedef std::vector<CO_SHLIB_HANDLE> HandleList;
201 HandleList m_unloadNext, m_unloadQueue;
202 int m_numOutstandingTimestepPlugins = 0;
203 int m_requestedTimestep = -1;
204 int m_currentTimestep = 0;
205
206};
207}
208#endif
OpenCOVER plugin interface, derive plugins from coVRPlugin.
dynamic library loading
double OSGVRUIEXPORT mod(double a, double b)
Definition: ARToolKit.h:33
Definition: coClusterStat.h:29
Definition: coTabletUI.h:51
Definition: coTabletUI.h:59
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
Definition: coVRPluginList.h:53
void postFrame() const
call postFrame method of all plugins
bool becomeCollaborativeMaster() const
request to become master of a collaborative session - return true if delivered
bool userEvent(int mod) const
call userEvent method of all plugins
void preSwapBuffers(int windowNumber) const
call preSwapBuffers method of all plugins
void expandBoundingSphere(osg::BoundingSphere &bs) const
allow plugins to expand scene bounding sphere
void commitTimestep(int t, coVRPlugin *caller)
called by plugin's commitTimestep method when timestep is prepared
void forwardMessage(const covise::DataHandle &dh) const
bool sendVisMessage(const covise::Message *msg) const
send a message to COVISE/visualisation system - delivered via only one plugin
coVRPlugin * addPlugin(const char *name, PluginDomain domain=Default)
load a plugin, call init, add to list of managed plugins
void newInteractor(const RenderObject *container, coInteractor *it) const
call newInteractor method of all plugins
void unload(coVRPlugin *m)
mark plugin for unloading
void unloadAllPlugins(PluginDomain domain=Default)
covise::Message * waitForVisMessage(int messageType) const
for visualisation system plugins: wait for message, return NULL if no such plugin
void addNode(osg::Node *, const RenderObject *o=NULL, coVRPlugin *addingPlugin=NULL) const
call addNode method of all plugins
coVRPlugin * getPlugin(const char *name) const
returns the plugin called name
void UDPmessage(covise::UdpMessage *msg) const
send a UDPmessage to all plugins
void message(int toWhom, int t, int l, const void *b) const
send a message to all plugins
void coviseError(const char *error) const
call coviseError method of all plugins
PluginDomain
Definition: coVRPluginList.h:59
@ Input
Definition: coVRPluginList.h:63
@ Window
Definition: coVRPluginList.h:62
@ Vis
Definition: coVRPluginList.h:61
@ Default
Definition: coVRPluginList.h:60
void requestQuit(bool killSession) const
request to terminate COVER or COVISE session
void guiToRenderMsg(const char *msg) const
call guiToRenderMsg method of all plugins
bool executeAll() const
for visualisation system plugins: execute data flow network - return true if delivered
void preDraw(osg::RenderInfo &renderInfo) const
call preDraw method of all plugins
void setTimestep(int timestep)
call setTimestep method of all plugins
void removeNode(osg::Node *node, bool isGroup=false, osg::Node *realNode=NULL) const
call removeNode method of all plugins
void clusterSyncDraw() const
call clusterSyncDraw() method of all plugins
void removeObject(const char *objName, bool replaceFlag) const
call removeObject method of all plugins
void notify(int level, const char *text) const
call notify method of all plugins
void postSwapBuffers(int windowNumber) const
call postSwapBuffers method of all plugins
void addObject(const RenderObject *container, osg::Group *root, const RenderObject *geometry, const RenderObject *normals, const RenderObject *colors, const RenderObject *texture) const
call addObject method of all plugins
bool update() const
call update method of all plugins
void loadDefault()
load configured plugins
void preFrame()
call preFrame method of all plugins
void requestTimestep(int timestep)
call requestTimestep method of all plugins
void param(const char *paramName, bool inMapLoading) const
call param method of all plugins
bool key(int type, int keySym, int mod) const
call key method of all plugins
bool requestInteraction(coInteractor *inter, osg::Node *triggerNode, bool isMouse)
call enableInteraction method of all plugins until one is accepting the request
static coVRPluginList * instance()
singleton
Definition: coVRPluginSupport.h:192
Definition: OpenCOVER.h:61
base class for data received from visualization systems (e.g. COVISE or Vistle)
Definition: RenderObject.h:147