OpenCOVER
coButton.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_BUTTON_H
9#define CO_BUTTON_H
10
11#include <OpenVRUI/coAction.h>
15
16namespace vrui
17{
18
19class coButton;
20class coCombinedButtonInteraction;
21
23class OPENVRUIEXPORT coButtonActor
24{
25public:
27 {
28 }
29 virtual void buttonEvent(coButton *button) = 0;
30};
31
36class OPENVRUIEXPORT coButton : public coAction, public coUIElement, public coUpdateable
37{
38public:
40 virtual ~coButton();
41
42 void setState(bool state, bool generateEvent = false);
43 bool getState() const;
44
46 bool isPressed() const;
47
48 void setPos(float x, float y, float z = 0);
49
50 virtual int hit(vruiHit *hit);
51 virtual void miss();
52
53 virtual void onPress();
54 virtual void onRelease();
55 virtual void setSize(float, float, float);
56 virtual void setSize(float);
57 virtual float getWidth() const;
58 virtual float getHeight() const;
59
60 virtual float getXpos() const
61 {
62 return myX;
63 }
64 virtual float getYpos() const
65 {
66 return myY;
67 }
68 virtual float getZpos() const
69 {
70 return myZ;
71 }
72
74
76 virtual const char *getClassName() const;
78 virtual bool isOfClassName(const char *) const;
79
80 virtual bool update();
82 virtual void setActive(bool a);
83
84protected:
85 virtual void createGeometry();
86 virtual void resizeGeometry();
87
92 float myX;
93 float myY;
94 float myZ;
97 bool active_;
98};
99
104class OPENVRUIEXPORT coPushButton : public coButton
105{
106public:
108 virtual ~coPushButton();
109 virtual void onPress();
110 virtual void onRelease();
111 virtual void miss();
112
114 virtual const char *getClassName() const;
116 virtual bool isOfClassName(const char *) const;
117};
118
124class OPENVRUIEXPORT coToggleButton : public coButton
125{
126public:
129 virtual void onPress();
130 virtual void onRelease();
131
133 virtual const char *getClassName() const;
135 virtual bool isOfClassName(const char *) const;
136
137protected:
139};
140}
141#endif
collaborative interface manager
Definition: coVRCommunication.h:41
Definition: coAction.h:26
Action listener for events triggered by coButton.
Definition: coButton.h:24
virtual void buttonEvent(coButton *button)=0
virtual ~coButtonActor()
Definition: coButton.h:26
Definition: coButton.h:37
bool pressState
true if the button is currently pressed
Definition: coButton.h:89
bool unregister
try to unregister interactions
Definition: coButton.h:96
virtual float getZpos() const
Definition: coButton.h:68
virtual float getXpos() const
Returns element x position.
Definition: coButton.h:60
virtual float getWidth() const
Returns element width.
virtual void setSize(float)
bool getState() const
virtual float getHeight() const
Returns element height.
void updateSwitch()
virtual void setSize(float, float, float)
virtual void setActive(bool a)
functions activates or deactivates the item
coCombinedButtonInteraction * interactionA
button interaction
Definition: coButton.h:95
float myY
button y position
Definition: coButton.h:93
coButtonGeometry * myGeometry
information about visual appearance
Definition: coButton.h:90
coButton(coButtonGeometry *geom, coButtonActor *actor)
void setPos(float x, float y, float z=0)
virtual int hit(vruiHit *hit)
bool active_
flag if button is active
Definition: coButton.h:97
virtual void createGeometry()
coButtonActor * myActor
action listener, triggered on button press
Definition: coButton.h:91
virtual float getYpos() const
Returns element y position.
Definition: coButton.h:64
float myZ
button z position
Definition: coButton.h:94
bool selectionState
true if button is selected by the user
Definition: coButton.h:88
virtual bool update()
virtual void onRelease()
void setState(bool state, bool generateEvent=false)
virtual ~coButton()
virtual void resizeGeometry()
virtual void miss()
float myX
button x position
Definition: coButton.h:92
virtual vruiTransformNode * getDCS()
virtual bool isOfClassName(const char *) const
check if the Element or any ancestor is this classname
virtual void onPress()
bool isPressed() const
virtual const char * getClassName() const
get the Element's classname
Definition: coButton.h:105
coPushButton(coButtonGeometry *geom, coButtonActor *actor)
virtual bool isOfClassName(const char *) const
check if the Element or any ancestor is this classname
virtual const char * getClassName() const
get the Element's classname
virtual ~coPushButton()
virtual void onPress()
virtual void onRelease()
virtual void miss()
Definition: coButton.h:125
coToggleButton(coButtonGeometry *geom, coButtonActor *actor)
virtual const char * getClassName() const
get the Element's classname
virtual void onPress()
virtual bool isOfClassName(const char *) const
check if the Element or any ancestor is this classname
virtual void onRelease()
bool wasReleased
Definition: coButton.h:138
virtual ~coToggleButton()
Definition: coButtonGeometry.h:27
Definition: coCombinedButtonInteraction.h:22
Definition: coUIElement.h:53
objects that are derived from this class are called once per frame
Definition: coUpdateManager.h:20
Definition: vruiHit.h:21
Definition: vruiTransformNode.h:18