00001 /*======================================================================= 00002 * Copyright 1991-1996, Silicon Graphics, Inc. 00003 * ALL RIGHTS RESERVED 00004 * 00005 * UNPUBLISHED -- Rights reserved under the copyright laws of the United 00006 * States. Use of a copyright notice is precautionary only and does not 00007 * imply publication or disclosure. 00008 * 00009 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND: 00010 * Use, duplication or disclosure by the Government is subject to restrictions 00011 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights 00012 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or 00013 * in similar or successor clauses in the FAR, or the DOD or NASA FAR 00014 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc., 00015 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311. 00016 * 00017 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY 00018 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION, 00019 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY 00020 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON 00021 * GRAPHICS, INC. 00022 **=======================================================================*/ 00023 /*======================================================================= 00024 ** Author : David Mott (MMM yyyy) 00025 ** Modified by : Gavin Bell (MMM yyyy) 00026 **=======================================================================*/ 00027 /*======================================================================= 00028 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00029 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00030 *** *** 00031 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00032 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00033 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00034 *** *** 00035 *** RESTRICTED RIGHTS LEGEND *** 00036 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00037 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00038 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00039 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00040 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00041 *** *** 00042 *** COPYRIGHT (C) 1996-2018 BY FEI S.A.S, *** 00043 *** BORDEAUX, FRANCE *** 00044 *** ALL RIGHTS RESERVED *** 00045 **=======================================================================*/ 00046 /*======================================================================= 00047 ** Modified by : VSG (MMM YYYY) 00048 **=======================================================================*/ 00049 00050 #ifndef _SO_EVENT_ 00051 #define _SO_EVENT_ 00052 00053 #include <Inventor/SbBasic.h> 00054 #include <Inventor/SbViewportRegion.h> 00055 #include <Inventor/SbLinear.h> 00056 #include <Inventor/SbTime.h> 00057 #include <Inventor/SoTypedObject.h> 00058 00059 class SbTrackerInfo; 00060 00116 class SoEvent: public SoTypedObject { 00117 public: 00118 00122 SoEvent(); 00126 virtual ~SoEvent(); 00127 00131 virtual SoType getTypeId() const; 00132 00136 static SoType getClassTypeId(); 00137 00141 virtual void setTime(SbTime t) { timestamp = t; } 00145 SbTime getTime() const { return timestamp; } 00146 00152 virtual void setPosition(const SbVec2s &p) { position = p; 00153 positionFloat[0] = (float)position[0]; 00154 positionFloat[1] = (float)position[1];} 00155 00160 virtual void setPosition(const SbVec2f &p) { positionFloat = p; 00161 position[0] = (short)positionFloat[0]; 00162 position[1] = (short)positionFloat[1];} 00163 00164 00174 const SbVec2s & getPosition() const { return position; } 00175 00185 const SbVec2f & getPositionFloat() const { return positionFloat; } 00186 00195 const SbVec2s & getPosition(const SbViewportRegion &vpRgn) const; 00196 00205 const SbVec2f & getPositionFloat(const SbViewportRegion &vpRgn) const; 00206 00215 const SbVec2f & getNormalizedPosition(const SbViewportRegion &vpRgn) const; 00216 00220 void setShiftDown(SbBool isDown) { shiftDown = isDown; } 00224 void setCtrlDown(SbBool isDown) { ctrlDown = isDown; } 00228 void setAltDown(SbBool isDown) { altDown = isDown; } 00232 void setButton1Down(SbBool isDown) { button1Down = isDown; } 00233 00237 SbBool wasShiftDown() const { return shiftDown; } 00241 SbBool wasCtrlDown() const { return ctrlDown; } 00245 SbBool wasAltDown() const { return altDown; } 00249 SbBool wasButton1Down() const { return button1Down; } 00250 00255 virtual const SbTrackerInfo *getTrackerInfo() const { return NULL; } 00256 00262 inline SbTrackerInfo* getTrackerInfo(); 00263 00264 private: 00265 // Initializes base event class 00266 static void initClass(); 00267 static void exitClass(); 00268 00269 // Initialize ALL Inventor event classes 00270 static void initClasses(); 00271 static void exitClasses(); 00272 00273 private: 00274 // all of these are set according to when the event occurred 00275 SbTime timestamp; // time the event occurred 00276 SbBool shiftDown; // TRUE if shift key was down 00277 SbBool ctrlDown; // TRUE if ctrl key was down 00278 SbBool altDown; // TRUE if alt key was down 00279 SbBool button1Down; // TRUE if first mouse button was down 00280 00281 SbVec2s position; // locator position when event occurred 00282 SbVec2f positionFloat; // locator position when event occurred 00283 SbVec2s viewportPos; // position relative to viewport 00284 SbVec2f viewportPosFloat; // position relative to viewport 00285 SbVec2f normalizedPos; // normalized position 00286 00287 static SoType classTypeId; // base typeId for all events 00288 }; 00289 00290 SbTrackerInfo* SoEvent::getTrackerInfo() 00291 { 00292 const ::SoEvent* constEvent = this; 00293 return const_cast< ::SbTrackerInfo* >(constEvent->getTrackerInfo()); 00294 } 00295 00296 #endif /* _SO_EVENT_ */ 00297 00298