Open Inventor Reference
SoEvent.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * Further, this software is distributed without any warranty that it is
16  * free of the rightful claim of any third person regarding infringement
17  * or the like. Any license provided herein, whether implied or
18  * otherwise, applies only to this software file. Patent licenses, if
19  * any, provided herein do not apply to combinations of this program with
20  * other software, or any other product whatsoever.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with this library; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25  *
26  * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27  * Mountain View, CA 94043, or:
28  *
29  * http://www.sgi.com
30  *
31  * For further information regarding this notice, see:
32  *
33  * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34  *
35  */
36 
37 
38 /*
39  * Copyright (C) 1990,91,92 Silicon Graphics, Inc.
40  *
41  _______________________________________________________________________
42  ______________ S I L I C O N G R A P H I C S I N C . ____________
43  |
44  | $Revision: 1.1.1.1 $
45  |
46  | Classes:
47  | SoEvent
48  |
49  | Author(s): David Mott, Gavin Bell
50  |
51  ______________ S I L I C O N G R A P H I C S I N C . ____________
52  _______________________________________________________________________
53  */
54 
55 #ifndef _SO_EVENT_
56 #define _SO_EVENT_
57 
59 #include <Inventor/SbBasic.h>
61 #include <Inventor/SbLinear.h>
62 #include <Inventor/SbTime.h>
63 #include <Inventor/SoType.h>
64 
67 
83 
85  public:
86 
89  NO_MOUSEBUTTON_MASK = 0,
90  LEFT_MOUSEBUTTON_MASK = 1,
91  MIDDLE_MOUSEBUTTON_MASK = 2,
92  RIGHT_MOUSEBUTTON_MASK = 4,
93  ALL_MOUSEBUTTONS_MASK = LEFT_MOUSEBUTTON_MASK + MIDDLE_MOUSEBUTTON_MASK + RIGHT_MOUSEBUTTON_MASK
94  };
95 
99  virtual ~SoEvent();
100 
102  virtual SoType getTypeId() const;
103 
105  static SoType getClassTypeId() { return classTypeId; }
106 
109  bool isOfType(SoType type) const;
110 
112  void setTime(SbTime t) { timestamp = t; }
114  SbTime getTime() const { return timestamp; }
115 
119  void setPosition(const SbVec2s &p) { position = p; }
120 
122  const SbVec2s & getPosition() const { return position; }
123 
125  const SbVec2s & getPosition(const SbViewportRegion &vpRgn) const;
126 
130  const SbVec2f & getNormalizedPosition(const SbViewportRegion &vpRgn) const;
131 
133  void setShiftDown(bool isDown) { shiftDown = isDown; }
135  void setCtrlDown(bool isDown) { ctrlDown = isDown; }
137  void setAltDown(bool isDown) { altDown = isDown; }
138 
140  bool wasShiftDown() const { return shiftDown; }
142  bool wasCtrlDown() const { return ctrlDown; }
144  bool wasAltDown() const { return altDown; }
145 
147  void setMouseButtonMask(int mask) { mouseButtonMask = mask; }
149  int getMouseButtonMask() const { return mouseButtonMask; }
150 
151  SoINTERNAL public:
153  static void initClass();
154 
156  static void initClasses();
157 
158  private:
160  SbTime timestamp;
161  bool shiftDown;
162  bool ctrlDown;
163  bool altDown;
164 
165  int mouseButtonMask;
166 
167  SbVec2s position;
168  SbVec2s viewportPos;
169  SbVec2f normalizedPos;
170 
171  static SoType classTypeId;
172 };
173 
174 
175 #endif /* _SO_EVENT_ */
#define SoINTERNAL
Definition: SbBasic.h:155
#define INVENTOR_API
Disable some annoying warnings on MSVC 6.
Definition: SbSystem.h:81
Class for representation of a time.
Definition: SbTime.h:89
2D vector class.
Definition: SbLinear.h:246
2D vector class.
Definition: SbLinear.h:354
Class for representing a viewport.
Base class for all events.
Definition: SoEvent.h:84
bool wasShiftDown() const
Get whether the modifier keys were down when the event occurred.
Definition: SoEvent.h:140
static SoType getClassTypeId()
Return the type id for the SoEvent class.
Definition: SoEvent.h:105
void setShiftDown(bool isDown)
Set whether the modifier keys were down when the event occurred.
Definition: SoEvent.h:133
void setTime(SbTime t)
Set the time at which the event occurred.
Definition: SoEvent.h:112
virtual SoType getTypeId() const
Return the type id for this event instance.
virtual ~SoEvent()
Constructor and destructor.
void setPosition(const SbVec2s &p)
Set the window pixel location of the cursor when the event occurred.
Definition: SoEvent.h:119
const SbVec2s & getPosition() const
Get position in pixel coodinates.
Definition: SoEvent.h:122
void setAltDown(bool isDown)
Set whether the modifier keys were down when the event occurred.
Definition: SoEvent.h:137
bool isOfType(SoType type) const
This returns TRUE if the event is an instance of or derived from an event of the passed type.
void setMouseButtonMask(int mask)
Get which mouse buttons are currently pressed (as bit mask)
Definition: SoEvent.h:147
SbTime getTime() const
Get the time at which the event occurred.
Definition: SoEvent.h:114
void setCtrlDown(bool isDown)
Set whether the modifier keys were down when the event occurred.
Definition: SoEvent.h:135
static void initClass()
Initializes base event class.
MouseButtonsMask
This describes the bit mask values of setButtonMask and getButtonMask.
Definition: SoEvent.h:88
const SbVec2s & getPosition(const SbViewportRegion &vpRgn) const
Get position relative to the specified viewport bounds.
const SbVec2f & getNormalizedPosition(const SbViewportRegion &vpRgn) const
Get the normalized location of the cursor when the event occurred, relative to the specified viewport...
bool wasCtrlDown() const
Get whether the modifier keys were down when the event occurred.
Definition: SoEvent.h:142
bool wasAltDown() const
Get whether the modifier keys were down when the event occurred.
Definition: SoEvent.h:144
int getMouseButtonMask() const
Set which mouse buttons are currently pressed.
Definition: SoEvent.h:149
SoEvent()
Constructor and destructor.
static void initClasses()
Initialize ALL Inventor event classes.
SoType has no virtual functions to keep it small...
Definition: SoType.h:103