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-2020 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 00117 class SoEvent: public SoTypedObject { 00118 public: 00119 00123 SoEvent(); 00127 virtual ~SoEvent(); 00128 00132 virtual SoType getTypeId() const; 00133 00137 static SoType getClassTypeId(); 00138 00142 void setTime(SbTime t) { timestamp = t; } 00146 SbTime getTime() const { return timestamp; } 00147 00153 void setPosition(const SbVec2s &p) { position = p; 00154 positionFloat[0] = (float)position[0]; 00155 positionFloat[1] = (float)position[1];} 00156 00161 void setPosition(const SbVec2f &p) { positionFloat = p; 00162 position[0] = (short)positionFloat[0]; 00163 position[1] = (short)positionFloat[1];} 00164 00165 00175 const SbVec2s & getPosition() const { return position; } 00176 00186 const SbVec2f & getPositionFloat() const { return positionFloat; } 00187 00196 const SbVec2s & getPosition(const SbViewportRegion &vpRgn) const; 00197 00206 const SbVec2f & getPositionFloat(const SbViewportRegion &vpRgn) const; 00207 00216 const SbVec2f & getNormalizedPosition(const SbViewportRegion &vpRgn) const; 00217 00221 void setShiftDown(SbBool isDown) { shiftDown = isDown; } 00225 void setCtrlDown(SbBool isDown) { ctrlDown = isDown; } 00229 void setAltDown(SbBool isDown) { altDown = isDown; } 00233 void setButton1Down(SbBool isDown) { button1Down = isDown; } 00234 00238 SbBool wasShiftDown() const { return shiftDown; } 00242 SbBool wasCtrlDown() const { return ctrlDown; } 00246 SbBool wasAltDown() const { return altDown; } 00250 SbBool wasButton1Down() const { return button1Down; } 00251 00256 virtual const SbTrackerInfo *getTrackerInfo() const { return NULL; } 00257 00263 inline SbTrackerInfo* getTrackerInfo(); 00264 00265 private: 00266 // Initializes base event class 00267 static void initClass(); 00268 static void exitClass(); 00269 00270 // Initialize ALL Inventor event classes 00271 static void initClasses(); 00272 static void exitClasses(); 00273 00274 private: 00275 // all of these are set according to when the event occurred 00276 SbTime timestamp; // time the event occurred 00277 SbBool shiftDown; // TRUE if shift key was down 00278 SbBool ctrlDown; // TRUE if ctrl key was down 00279 SbBool altDown; // TRUE if alt key was down 00280 SbBool button1Down; // TRUE if first mouse button was down 00281 00282 SbVec2s position; // locator position when event occurred 00283 SbVec2f positionFloat; // locator position when event occurred 00284 SbVec2s viewportPos; // position relative to viewport 00285 SbVec2f viewportPosFloat; // position relative to viewport 00286 SbVec2f normalizedPos; // normalized position 00287 00288 static SoType classTypeId; // base typeId for all events 00289 }; 00290 00291 SbTrackerInfo* SoEvent::getTrackerInfo() 00292 { 00293 const ::SoEvent* constEvent = this; 00294 return const_cast< ::SbTrackerInfo* >(constEvent->getTrackerInfo()); 00295 } 00296 00297 #endif /* _SO_EVENT_ */ 00298 00299