OpenCOVER
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
coTextureRectBackground.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 //-*-c++-*-
9 #ifndef CO_TEXTURERECT_BACKGROUND_H
10 #define CO_TEXTURERECT_BACKGROUND_H
11 
12 #include <OpenVRUI/coAction.h>
13 #include <OpenVRUI/coBackground.h>
14 
15 #ifdef _WIN32
16 typedef unsigned char uchar;
17 typedef unsigned short ushort;
18 typedef unsigned int uint;
19 typedef unsigned long ulong;
20 typedef signed char schar;
21 typedef signed short sshort;
22 typedef signed int sint;
23 typedef signed long slong;
24 #endif
25 #undef ACTION_BUTTON
26 #undef DRIVE_BUTTON
27 #undef XFORM_BUTTON
28 
29 #include <string>
30 
31 namespace vrui
32 {
33 
34 class coTextureRectBackground;
35 class vruiHit;
36 
40 class OPENVRUIEXPORT coTextureRectBackgroundActor
41 {
42 public:
44  {
45  }
46  virtual void texturePointerClicked(coTextureRectBackground *, float, float);
47  virtual void texturePointerReleased(coTextureRectBackground *, float, float);
48  virtual void texturePointerDragged(coTextureRectBackground *, float, float);
49  virtual void texturePointerMoved(coTextureRectBackground *, float, float);
50  virtual void texturePointerLeft(coTextureRectBackground *);
51 };
52 
59 class OPENVRUIEXPORT coTextureRectBackground
60  : public coBackground,
61  public coAction
62 {
63 public:
64  coTextureRectBackground(const std::string &normalTexture, coTextureRectBackgroundActor *actor = 0);
65  coTextureRectBackground(uint *normalImage, int comp, int ns, int nt, int nr,
66  coTextureRectBackgroundActor *actor = 0);
67  virtual ~coTextureRectBackground();
68 
69  class TextureSet
70  {
71 
72  public:
73  TextureSet(uint *nt, int comp, int s, int t, int r)
74  : start(0.0f, 0.0f)
75  , end(1.0f, 1.0f)
76  {
77  normalTextureImage = nt;
78  this->comp = comp;
79  this->s = s;
80  this->t = t;
81  this->r = r;
82  }
83 
85  int comp;
86  int s;
87  int t;
88  int r;
89 
90  struct TexCoord
91  {
92  TexCoord(float xv, float yv)
93  : x(xv)
94  , y(yv)
95  {
96  }
97  float x;
98  float y;
99  };
100 
103  };
104 
105  virtual int hit(vruiHit *hit);
106  virtual void miss();
107 
109  virtual void setEnabled(bool en);
110 
112  virtual void setHighlighted(bool hl);
113 
115  void setRepeat(bool repeat);
116 
118  bool getRepeat() const;
119 
123  void setUpdated(bool update)
124  {
125  this->updated = update;
126  }
127 
129  bool getUpdated()
130  {
131  return updated;
132  }
133 
135  void setTexSize(float, float);
136 
138  float getTexXSize() const
139  {
140  return texXSize;
141  }
142 
144  float getTexYSize() const
145  {
146  return texYSize;
147  }
148 
158  void setImage(uint *normalImage, int comp, int ns, int nt, int nr);
159 
161  virtual const char *getClassName() const;
163  virtual bool isOfClassName(const char *) const;
164 
166  {
167  return currentTextures;
168  }
169 
170  inline const std::string &getNormalTexName() const
171  {
172  return normalTexName;
173  }
174 
175 protected:
177 
178 private:
179  std::string normalTexName;
180  TextureSet *currentTextures;
181  int comp;
182  int s, t, r;
183 
184  float texXSize;
185  float texYSize;
186 
187  bool repeat;
188 
189  bool updated;
190 };
191 }
192 #endif
unsigned long ulong
abbreviation for unsigned long
Definition: rel_mcast-old.h:78
Definition: coTextureRectBackground.h:40
uint * normalTextureImage
Definition: coTextureRectBackground.h:84
Definition: vruiHit.h:20
float y
Definition: coTextureRectBackground.h:98
int r
Definition: coTextureRectBackground.h:88
Definition: coTextureRectBackground.h:59
Definition: coBackground.h:22
TextureSet(uint *nt, int comp, int s, int t, int r)
Definition: coTextureRectBackground.h:73
unsigned int uint
abbreviation for unsigned int
Definition: rel_mcast-old.h:77
TexCoord end
Definition: coTextureRectBackground.h:102
Definition: coAction.h:25
coTextureRectBackgroundActor * myActor
action listener, triggered on pointer intersections
Definition: coTextureRectBackground.h:176
int comp
Definition: coTextureRectBackground.h:85
Definition: coTextureRectBackground.h:90
virtual ~coTextureRectBackgroundActor()
Definition: coTextureRectBackground.h:43
TexCoord start
Definition: coTextureRectBackground.h:101
int t
Definition: coTextureRectBackground.h:87
void setUpdated(bool update)
Definition: coTextureRectBackground.h:123
bool getUpdated()
returns whether
Definition: coTextureRectBackground.h:129
int s
Definition: coTextureRectBackground.h:86
float getTexYSize() const
returns the height of the texture
Definition: coTextureRectBackground.h:144
const std::string & getNormalTexName() const
Definition: coTextureRectBackground.h:170
TextureSet * getCurrentTextures()
Definition: coTextureRectBackground.h:165
float x
Definition: coTextureRectBackground.h:97
float getTexXSize() const
returns the width of the texture
Definition: coTextureRectBackground.h:138
TexCoord(float xv, float yv)
Definition: coTextureRectBackground.h:92
unsigned char uchar
abbreviation for unsigned char
Definition: rel_mcast-old.h:75
unsigned short ushort
abbreviation for unsigned short
Definition: rel_mcast-old.h:76
Definition: coTextureRectBackground.h:69