OpenCOVER
coInteractor.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_INTERACTOR_H
9#define CO_INTERACTOR_H
10
24#include <util/coExport.h>
25
26#include <cstring>
27#include <cstdio>
28#include <string>
29#include <osg/Referenced>
30
31namespace opencover
32{
33class RenderObject;
34
36class COVEREXPORT coInteractor
37{
38public:
40 virtual ~coInteractor();
41
43 int refCount() const;
44
47
50
51 virtual void removedObject() = 0;
52
54 virtual bool isSameModule(coInteractor *i) const = 0;
55
57 virtual bool isSame(coInteractor *i) const = 0;
58
60 virtual void executeModule() = 0;
61
63 virtual void copyModule() = 0;
64
66 virtual void copyModuleExec() = 0;
67
69 virtual void deleteModule() = 0;
70
71 // --- all getParameter Functions
72 // - return -1 on fail (illegal type requested), 0 if ok
73 // - only work for coFeedback created parameter messages
74 // - do not change the value fields if type incorrect
75
76 virtual int getBooleanParam(const std::string &paraName, int &value) const = 0;
77 virtual int getIntScalarParam(const std::string &paraName, int &value) const = 0;
78 virtual int getFloatScalarParam(const std::string &paraName, float &value) const = 0;
79 virtual int getIntSliderParam(const std::string &paraName, int &min, int &max, int &val) const = 0;
80 virtual int getFloatSliderParam(const std::string &paraName, float &min, float &max, float &val) const = 0;
81 virtual int getIntVectorParam(const std::string &paraName, int &numElem, int *&val) const = 0;
82 virtual int getFloatVectorParam(const std::string &paraName, int &numElem, float *&val) const = 0;
83 virtual int getStringParam(const std::string &paraName, const char *&val) const = 0;
84 virtual int getChoiceParam(const std::string &paraName, int &num, char **&labels, int &active) const = 0;
85 virtual int getFileBrowserParam(const std::string &paraName, char *&val) const = 0;
86
87 // --- set-Functions:
88
90 virtual void setBooleanParam(const char *name, int val) = 0;
91
93 virtual void setScalarParam(const char *name, float val) = 0;
94
96 virtual void setScalarParam(const char *name, int val) = 0;
97
99 virtual void setSliderParam(const char *name, float min, float max, float value) = 0;
100
102 virtual void setSliderParam(const char *name, int min, int max, int value) = 0;
103
105 virtual void setVectorParam(const char *name, int numElem, float *field) = 0;
106 virtual void setVectorParam(const char *name, float u, float v, float w) = 0;
107
109 virtual void setVectorParam(const char *name, int numElem, int *field) = 0;
110 virtual void setVectorParam(const char *name, int u, int v, int w) = 0;
111
113 virtual void setStringParam(const char *name, const char *val) = 0;
114
116 virtual void setChoiceParam(const char *name, int pos) = 0;
117 virtual void setChoiceParam(const char *name, int num, const char *const *list, int pos) = 0;
118
120 virtual void setFileBrowserParam(const char *name, const char *val) = 0;
121
122 // name of the covise data object which has feedback attributes
123 virtual const char *getObjName() = 0;
124
125 // the covise data object which has feedback attributes
126 virtual RenderObject *getObject() = 0;
127
128 // get the name of the module which created the data object
129 virtual const char *getPluginName() = 0;
130
131 // get the name of the module which created the data object
132 virtual const char *getModuleName() = 0;
133
134 // get the instance number of the module which created the data object
135 virtual int getModuleInstance() = 0;
136
137 // get the hostname of the module which created the data object
138 virtual const char *getModuleHost() = 0;
139
140 // -- The following functions only works for coFeedback attributes
142 virtual int getNumParam() const = 0;
143
145 virtual int getNumUser() const = 0;
146
147 // get a User-supplied string
148 virtual const char *getString(unsigned int i) const = 0;
149
150private:
151 int d_refCount;
152};
153
154class COVEREXPORT InteractorReference: public osg::Referenced
155{
156public:
158 : m_interactor(inter)
159 {
160 if (m_interactor)
161 m_interactor->incRefCount();
162 }
163
165 {
166 if (m_interactor)
167 m_interactor->decRefCount();
168 }
169
171 {
172 return m_interactor;
173 }
174
175private:
176 opencover::coInteractor *m_interactor = nullptr;
177};
178
179}
180#endif
Definition: ARToolKit.h:33
abstract feedback class for interacting with parameters of visualization modules (e....
Definition: coInteractor.h:37
virtual void setVectorParam(const char *name, float u, float v, float w)=0
virtual bool isSameModule(coInteractor *i) const =0
returns true, if Interactor comes from same Module as intteractor i;
void decRefCount()
if you don't need the interactor any more use ...
virtual const char * getObjName()=0
virtual void setVectorParam(const char *name, int numElem, int *field)=0
set int vector parameter
virtual int getBooleanParam(const std::string &paraName, int &value) const =0
virtual void setChoiceParam(const char *name, int num, const char *const *list, int pos)=0
virtual const char * getModuleHost()=0
virtual int getIntSliderParam(const std::string &paraName, int &min, int &max, int &val) const =0
virtual void setSliderParam(const char *name, int min, int max, int value)=0
set int slider parameter
virtual const char * getPluginName()=0
virtual void deleteModule()=0
delete the Module
virtual void setFileBrowserParam(const char *name, const char *val)=0
set browser parameter
virtual void setChoiceParam(const char *name, int pos)=0
set choice parameter, pos starts with 0
virtual int getNumParam() const =0
Get the number of Parameters.
void incRefCount()
if you get an interactor and you want to keep it use ...
virtual void setScalarParam(const char *name, float val)=0
set float scalar parameter
virtual int getFloatSliderParam(const std::string &paraName, float &min, float &max, float &val) const =0
virtual void setVectorParam(const char *name, int u, int v, int w)=0
virtual int getFloatScalarParam(const std::string &paraName, float &value) const =0
virtual bool isSame(coInteractor *i) const =0
returns true, if Interactor is exactly the same as interactor i;
virtual int getIntVectorParam(const std::string &paraName, int &numElem, int *&val) const =0
virtual void removedObject()=0
virtual int getChoiceParam(const std::string &paraName, int &num, char **&labels, int &active) const =0
virtual int getStringParam(const std::string &paraName, const char *&val) const =0
virtual RenderObject * getObject()=0
virtual int getFloatVectorParam(const std::string &paraName, int &numElem, float *&val) const =0
virtual void setBooleanParam(const char *name, int val)=0
set Boolean Parameter
virtual int getNumUser() const =0
Get the number of User Strings.
virtual void setStringParam(const char *name, const char *val)=0
set string parameter
virtual void copyModuleExec()=0
copy the Module to same host and execute the copied one
virtual void setVectorParam(const char *name, int numElem, float *field)=0
set float Vector Param
virtual int getFileBrowserParam(const std::string &paraName, char *&val) const =0
virtual int getModuleInstance()=0
virtual const char * getString(unsigned int i) const =0
virtual const char * getModuleName()=0
virtual int getIntScalarParam(const std::string &paraName, int &value) const =0
int refCount() const
return no. of users
virtual void setScalarParam(const char *name, int val)=0
set int scalar parameter
virtual void executeModule()=0
execute the Module
virtual void copyModule()=0
copy the Module to same host
virtual void setSliderParam(const char *name, float min, float max, float value)=0
set float slider parameter
Definition: coInteractor.h:155
~InteractorReference()
Definition: coInteractor.h:164
InteractorReference(opencover::coInteractor *inter)
Definition: coInteractor.h:157
opencover::coInteractor * interactor() const
Definition: coInteractor.h:170
base class for data received from visualization systems (e.g. COVISE or Vistle)
Definition: RenderObject.h:147