OpenCOVER
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>
14
15#ifdef _WIN32
16typedef unsigned char uchar;
17typedef unsigned short ushort;
18typedef unsigned int uint;
19typedef unsigned long ulong;
20typedef signed char schar;
21typedef signed short sshort;
22typedef signed int sint;
23typedef signed long slong;
24#endif
25#undef ACTION_BUTTON
26#undef DRIVE_BUTTON
27#undef XFORM_BUTTON
28
29#include <string>
30
31namespace vrui
32{
33
34class coTextureRectBackground;
35class vruiHit;
36
40class OPENVRUIEXPORT coTextureRectBackgroundActor
41{
42public:
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);
51};
52
59class OPENVRUIEXPORT coTextureRectBackground
60 : public coBackground,
61 public coAction
62{
63public:
64 coTextureRectBackground(const std::string &normalTexture, coTextureRectBackgroundActor *actor = 0);
65 coTextureRectBackground(uint *normalImage, int comp, int ns, int nt, int nr,
68
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
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
175protected:
177
178private:
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 int uint
abbreviation for unsigned int
Definition: rel_mcast-old.h:77
unsigned long ulong
abbreviation for unsigned long
Definition: rel_mcast-old.h:78
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
collaborative interface manager
Definition: coVRCommunication.h:41
Definition: coAction.h:26
Definition: coBackground.h:23
Definition: coTextureRectBackground.h:41
virtual void texturePointerMoved(coTextureRectBackground *, float, float)
virtual void texturePointerClicked(coTextureRectBackground *, float, float)
virtual ~coTextureRectBackgroundActor()
Definition: coTextureRectBackground.h:43
virtual void texturePointerDragged(coTextureRectBackground *, float, float)
virtual void texturePointerLeft(coTextureRectBackground *)
virtual void texturePointerReleased(coTextureRectBackground *, float, float)
Definition: coTextureRectBackground.h:62
virtual int hit(vruiHit *hit)
coTextureRectBackground(const std::string &normalTexture, coTextureRectBackgroundActor *actor=0)
const std::string & getNormalTexName() const
Definition: coTextureRectBackground.h:170
bool getUpdated()
returns whether
Definition: coTextureRectBackground.h:129
float getTexXSize() const
returns the width of the texture
Definition: coTextureRectBackground.h:138
float getTexYSize() const
returns the height of the texture
Definition: coTextureRectBackground.h:144
virtual const char * getClassName() const
get the Element's classname
virtual void setHighlighted(bool hl)
set this widget to highlighted
coTextureRectBackgroundActor * myActor
action listener, triggered on pointer intersections
Definition: coTextureRectBackground.h:176
coTextureRectBackground(uint *normalImage, int comp, int ns, int nt, int nr, coTextureRectBackgroundActor *actor=0)
void setUpdated(bool update)
Definition: coTextureRectBackground.h:123
TextureSet * getCurrentTextures()
Definition: coTextureRectBackground.h:165
virtual bool isOfClassName(const char *) const
check if the Element or any ancestor is this classname
void setTexSize(float, float)
set the texture dimensions (need to be pixel-exact)
void setImage(uint *normalImage, int comp, int ns, int nt, int nr)
bool getRepeat() const
get texture repeat state (deprecated!)
void setRepeat(bool repeat)
set texture repeat (deprecated!)
virtual void setEnabled(bool en)
set this widget to enabled
Definition: coTextureRectBackground.h:70
int s
Definition: coTextureRectBackground.h:86
TextureSet(uint *nt, int comp, int s, int t, int r)
Definition: coTextureRectBackground.h:73
uint * normalTextureImage
Definition: coTextureRectBackground.h:84
TexCoord end
Definition: coTextureRectBackground.h:102
int t
Definition: coTextureRectBackground.h:87
int r
Definition: coTextureRectBackground.h:88
TexCoord start
Definition: coTextureRectBackground.h:101
int comp
Definition: coTextureRectBackground.h:85
Definition: coTextureRectBackground.h:91
float y
Definition: coTextureRectBackground.h:98
float x
Definition: coTextureRectBackground.h:97
TexCoord(float xv, float yv)
Definition: coTextureRectBackground.h:92
Definition: vruiHit.h:21