Open Inventor Release 2024.1.2
 
Loading...
Searching...
No Matches
SoEvent.h
1/*=======================================================================
2 * Copyright 1991-1996, Silicon Graphics, Inc.
3 * ALL RIGHTS RESERVED
4 *
5 * UNPUBLISHED -- Rights reserved under the copyright laws of the United
6 * States. Use of a copyright notice is precautionary only and does not
7 * imply publication or disclosure.
8 *
9 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
10 * Use, duplication or disclosure by the Government is subject to restrictions
11 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
12 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
13 * in similar or successor clauses in the FAR, or the DOD or NASA FAR
14 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
15 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
16 *
17 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
18 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
19 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
20 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
21 * GRAPHICS, INC.
22**=======================================================================*/
23/*=======================================================================
24** Author : David Mott (MMM yyyy)
25** Modified by : Gavin Bell (MMM yyyy)
26**=======================================================================*/
27/*=======================================================================
28 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
29 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
30 *** ***
31 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
32 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
33 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
34 *** ***
35 *** RESTRICTED RIGHTS LEGEND ***
36 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
37 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
38 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
39 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
40 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
41 *** ***
42 *** COPYRIGHT (C) 1996-2018 BY FEI S.A.S, ***
43 *** BORDEAUX, FRANCE ***
44 *** ALL RIGHTS RESERVED ***
45**=======================================================================*/
46/*=======================================================================
47** Modified by : VSG (MMM YYYY)
48**=======================================================================*/
49
50#ifndef _SO_EVENT_
51#define _SO_EVENT_
52
53#include <Inventor/SbBasic.h>
54#include <Inventor/SbViewportRegion.h>
55#include <Inventor/SbLinear.h>
56#include <Inventor/SbTime.h>
57#include <Inventor/SoTypedObject.h>
58
59class SbTrackerInfo;
60
116class SoEvent: public SoTypedObject {
117 public:
118
126 virtual ~SoEvent();
127
131 virtual SoType getTypeId() const;
132
137
141 virtual void setTime(SbTime t) { timestamp = t; }
145 SbTime getTime() const { return timestamp; }
146
152 virtual void setPosition(const SbVec2s &p) { position = p;
153 positionFloat[0] = (float)position[0];
154 positionFloat[1] = (float)position[1];}
155
160 virtual void setPosition(const SbVec2f &p) { positionFloat = p;
161 position[0] = (short)positionFloat[0];
162 position[1] = (short)positionFloat[1];}
163
164
174 const SbVec2s & getPosition() const { return position; }
175
185 const SbVec2f & getPositionFloat() const { return positionFloat; }
186
195 const SbVec2s & getPosition(const SbViewportRegion &vpRgn) const;
196
205 const SbVec2f & getPositionFloat(const SbViewportRegion &vpRgn) const;
206
215 const SbVec2f & getNormalizedPosition(const SbViewportRegion &vpRgn) const;
216
220 void setShiftDown(SbBool isDown) { shiftDown = isDown; }
224 void setCtrlDown(SbBool isDown) { ctrlDown = isDown; }
228 void setAltDown(SbBool isDown) { altDown = isDown; }
232 void setButton1Down(SbBool isDown) { button1Down = isDown; }
233
237 SbBool wasShiftDown() const { return shiftDown; }
241 SbBool wasCtrlDown() const { return ctrlDown; }
245 SbBool wasAltDown() const { return altDown; }
249 SbBool wasButton1Down() const { return button1Down; }
250
255 virtual const SbTrackerInfo *getTrackerInfo() const { return NULL; }
256
263
264 private:
265 // Initializes base event class
266 static void initClass();
267 static void exitClass();
268
269 // Initialize ALL Inventor event classes
270 static void initClasses();
271 static void exitClasses();
272
273 private:
274 // all of these are set according to when the event occurred
275 SbTime timestamp; // time the event occurred
276 SbBool shiftDown; // TRUE if shift key was down
277 SbBool ctrlDown; // TRUE if ctrl key was down
278 SbBool altDown; // TRUE if alt key was down
279 SbBool button1Down; // TRUE if first mouse button was down
280
281 SbVec2s position; // locator position when event occurred
282 SbVec2f positionFloat; // locator position when event occurred
283 SbVec2s viewportPos; // position relative to viewport
284 SbVec2f viewportPosFloat; // position relative to viewport
285 SbVec2f normalizedPos; // normalized position
286
287 static SoType classTypeId; // base typeId for all events
288};
289
291{
292 const ::SoEvent* constEvent = this;
293 return const_cast< ::SbTrackerInfo* >(constEvent->getTrackerInfo());
294}
295
296#endif /* _SO_EVENT_ */
297
Class for representation of a time.
Definition SbTime.h:91
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Class for repres...
2D vector class.
Definition SbVec.h:76
2D vector class.
Definition SbVec.h:700
Class for representing a viewport.
Base class for all events.
Definition SoEvent.h:116
SbBool wasButton1Down() const
Returns true if mouse button 1 was down when the event occurred.
Definition SoEvent.h:249
SbBool wasCtrlDown() const
Returns true if the CTRL key was down when the event occurred.
Definition SoEvent.h:241
SbBool wasAltDown() const
Returns true if the ALT key was down when the event occurred.
Definition SoEvent.h:245
static SoType getClassTypeId()
Returns the type id for the SoEvent class.
void setAltDown(SbBool isDown)
Sets whether the ALT key was down when the event occurred.
Definition SoEvent.h:228
virtual SoType getTypeId() const
Returns the type id for this event instance.
const SbVec2f & getPositionFloat(const SbViewportRegion &vpRgn) const
Gets the viewport pixel location of the cursor when the event occurred, relative to the origin of the...
const SbVec2s & getPosition() const
Returns the window pixel location of the cursor when the event occurred as integer values.
Definition SoEvent.h:174
virtual const SbTrackerInfo * getTrackerInfo() const
Gets whether an event object has associated tracker information.
Definition SoEvent.h:255
void setCtrlDown(SbBool isDown)
Sets whether the CTRL key was down when the event occurred.
Definition SoEvent.h:224
virtual ~SoEvent()
Destructor.
SbBool wasShiftDown() const
Returns true if the shift key was down when the event occurred.
Definition SoEvent.h:237
virtual void setPosition(const SbVec2s &p)
Sets the window pixel location of the cursor when the event occurred.
Definition SoEvent.h:152
SbTime getTime() const
Gets the time at which the event occurred.
Definition SoEvent.h:145
void setShiftDown(SbBool isDown)
Sets whether the shift key was down when the event occurred.
Definition SoEvent.h:220
virtual void setPosition(const SbVec2f &p)
Float version of setPosition(const SbVec2s &p).
Definition SoEvent.h:160
virtual void setTime(SbTime t)
Sets the time at which the event occurred.
Definition SoEvent.h:141
void setButton1Down(SbBool isDown)
Sets whether mouse Button 1 was down when the event occurred.
Definition SoEvent.h:232
const SbVec2f & getNormalizedPosition(const SbViewportRegion &vpRgn) const
Gets the normalized location of the cursor when the event occurred, relative to the specified viewpor...
const SbVec2s & getPosition(const SbViewportRegion &vpRgn) const
Gets the viewport pixel location of the cursor when the event occurred, relative to the origin of the...
SoEvent()
Constructor.
const SbVec2f & getPositionFloat() const
Returns the window pixel location of the cursor when the event occurred as float values.
Definition SoEvent.h:185
Stores runtime type information.
Definition SoType.h:98
Base class for object storing runtime type information.
int SbBool
Boolean type.
Definition SbBase.h:87