OpenCOVER
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
31 namespace opencover
32 {
33 class RenderObject;
34 
36 class COVEREXPORT coInteractor
37 {
38 public:
39  coInteractor();
40  virtual ~coInteractor();
41 
43  int refCount() const;
44 
46  void incRefCount();
47 
49  void decRefCount();
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 num, const char *const *list, int pos) = 0;
117 
119  virtual void setFileBrowserParam(const char *name, const char *val) = 0;
120 
121  // name of the covise data object which has feedback attributes
122  virtual const char *getObjName() = 0;
123 
124  // the covise data object which has feedback attributes
125  virtual RenderObject *getObject() = 0;
126 
127  // get the name of the module which created the data object
128  virtual const char *getPluginName() = 0;
129 
130  // get the name of the module which created the data object
131  virtual const char *getModuleName() = 0;
132 
133  // get the instance number of the module which created the data object
134  virtual int getModuleInstance() = 0;
135 
136  // get the hostname of the module which created the data object
137  virtual const char *getModuleHost() = 0;
138 
139  // -- The following functions only works for coFeedback attributes
141  virtual int getNumParam() const = 0;
142 
144  virtual int getNumUser() const = 0;
145 
146  // get a User-supplied string
147  virtual const char *getString(unsigned int i) const = 0;
148 
149 private:
150  int d_refCount;
151 };
152 
153 class COVEREXPORT InteractorReference: public osg::Referenced
154 {
155 public:
157  : m_interactor(inter)
158  {
159  if (m_interactor)
160  m_interactor->incRefCount();
161  }
162 
164  {
165  if (m_interactor)
166  m_interactor->decRefCount();
167  }
168 
170  {
171  return m_interactor;
172  }
173 
174 private:
175  opencover::coInteractor *m_interactor = nullptr;
176 };
177 
178 }
179 #endif
base class for data received from visualization systems (e.g. COVISE or Vistle)
Definition: RenderObject.h:146
abstract feedback class for interacting with parameters of visualization modules (e.g. COVISE or Vistle)
Definition: coInteractor.h:36
InteractorReference(opencover::coInteractor *inter)
Definition: coInteractor.h:156
Definition: coInteractor.h:153
~InteractorReference()
Definition: coInteractor.h:163
opencover::coInteractor * interactor() const
Definition: coInteractor.h:169