OpenCOVER
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
coTexturedBackground.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_TEXTURED_BACKGROUND_H
10 #define CO_TEXTURED_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 coTexturedBackground;
35 class vruiHit;
36 
40 class OPENVRUIEXPORT coTexturedBackgroundActor
41 {
42 public:
44  {
45  }
46  virtual void texturePointerClicked(coTexturedBackground *, float, float);
47  virtual void texturePointerReleased(coTexturedBackground *, float, float);
48  virtual void texturePointerDragged(coTexturedBackground *, float, float);
49  virtual void texturePointerMoved(coTexturedBackground *, float, float);
50  virtual void texturePointerLeft(coTexturedBackground *);
51 };
52 
59 class OPENVRUIEXPORT coTexturedBackground
60  : public coBackground,
61  public coAction
62 {
63 public:
64  coTexturedBackground(const std::string &normalTexture, const std::string &highlightTexture,
65  const std::string &disabledTexture, coTexturedBackgroundActor *actor = 0);
66  coTexturedBackground(uint *normalImage, uint *highlightImage,
67  uint *disabledImage, int comp, int ns, int nt, int nr,
68  coTexturedBackgroundActor *actor = 0);
69  virtual ~coTexturedBackground();
70 
71  class TextureSet
72  {
73 
74  public:
75  TextureSet(uint *nt, uint *ht, uint *dt, int comp, int s, int t, int r)
76  : start(0.0f, 0.0f)
77  , end(1.0f, 1.0f)
78  {
79  normalTextureImage = nt;
80  highlightedTextureImage = ht;
81  disabledTextureImage = dt;
82  this->comp = comp;
83  this->s = s;
84  this->t = t;
85  this->r = r;
86  }
87 
91  int comp;
92  int s;
93  int t;
94  int r;
95 
96  struct TexCoord
97  {
98  TexCoord(float xv, float yv)
99  : x(xv)
100  , y(yv)
101  {
102  }
103  float x;
104  float y;
105  };
106 
109  };
110 
111  virtual int hit(vruiHit *hit);
112  virtual void miss();
113 
114  virtual void setEnabled(bool en);
115  virtual void setHighlighted(bool hl);
117  virtual void setActive(bool a);
118 
119  virtual void shrinkToMin();
120 
121  //void createGeode();
122  void setRepeat(bool repeat);
123  bool getRepeat() const;
124 
125  void setUpdated(bool update)
126  {
127  updated = update;
128  }
129  bool getUpdated()
130  {
131  return updated;
132  }
133 
134  void setTexSize(float, float); // size of the texture, ==0 is fit to Background
135 
136  float getTexXSize() const
137  {
138  return texXSize;
139  }
140  float getTexYSize() const
141  {
142  return texYSize;
143  }
144 
145  void setImage(uint *normalImage, uint *highlightImage,
146  uint *disabledImage, int comp, int ns, int nt, int nr);
147 
149  virtual const char *getClassName() const;
151  virtual bool isOfClassName(const char *) const;
152 
154  {
155  return currentTextures;
156  }
157 
158  inline const std::string &getNormalTexName() const
159  {
160  return normalTexName;
161  }
162  inline const std::string &getHighlightTexName() const
163  {
164  return highlightTexName;
165  }
166  inline const std::string &getDisabledTexName() const
167  {
168  return disabledTexName;
169  }
170 
171  void setScale(float s);
172  float getScale();
173 
174 protected:
176 
177 private:
178  std::string normalTexName;
179  std::string highlightTexName;
180  std::string disabledTexName;
181 
182  TextureSet *currentTextures;
183 
184  float texXSize;
185  float texYSize;
186 
187  bool repeat;
188  bool active_;
189  float myScale;
190 
191  // Pinkowski, 20.09.2007
192  bool updated;
193 };
194 }
195 #endif
unsigned long ulong
abbreviation for unsigned long
Definition: rel_mcast-old.h:78
Definition: coTexturedBackground.h:40
const std::string & getHighlightTexName() const
Definition: coTexturedBackground.h:162
bool getUpdated()
Definition: coTexturedBackground.h:129
Definition: vruiHit.h:20
uint * disabledTextureImage
Definition: coTexturedBackground.h:90
const std::string & getNormalTexName() const
Definition: coTexturedBackground.h:158
float x
Definition: coTexturedBackground.h:103
Definition: coBackground.h:22
Definition: coTexturedBackground.h:59
unsigned int uint
abbreviation for unsigned int
Definition: rel_mcast-old.h:77
Definition: coAction.h:25
int r
Definition: coTexturedBackground.h:94
float getTexXSize() const
Definition: coTexturedBackground.h:136
uint * highlightedTextureImage
Definition: coTexturedBackground.h:89
uint * normalTextureImage
Definition: coTexturedBackground.h:88
Definition: coTexturedBackground.h:96
coTexturedBackgroundActor * myActor
action listener, triggered on pointer intersections
Definition: coTexturedBackground.h:175
int t
Definition: coTexturedBackground.h:93
float y
Definition: coTexturedBackground.h:104
TexCoord end
Definition: coTexturedBackground.h:108
TextureSet * getCurrentTextures()
Definition: coTexturedBackground.h:153
float getTexYSize() const
Definition: coTexturedBackground.h:140
const std::string & getDisabledTexName() const
Definition: coTexturedBackground.h:166
int comp
Definition: coTexturedBackground.h:91
Definition: coTexturedBackground.h:71
void setUpdated(bool update)
Definition: coTexturedBackground.h:125
TextureSet(uint *nt, uint *ht, uint *dt, int comp, int s, int t, int r)
Definition: coTexturedBackground.h:75
TexCoord(float xv, float yv)
Definition: coTexturedBackground.h:98
int s
Definition: coTexturedBackground.h:92
unsigned char uchar
abbreviation for unsigned char
Definition: rel_mcast-old.h:75
TexCoord start
Definition: coTexturedBackground.h:107
unsigned short ushort
abbreviation for unsigned short
Definition: rel_mcast-old.h:76
virtual ~coTexturedBackgroundActor()
Definition: coTexturedBackground.h:43