Coin Logo http://www.sim.no
http://www.coin3d.org

SoEventCallback.h

00001 #ifndef COIN_SOEVENTCALLBACK_H
00002 #define COIN_SOEVENTCALLBACK_H
00003 
00004 /**************************************************************************\
00005  *
00006  *  This file is part of the Coin 3D visualization library.
00007  *  Copyright (C) 1998-2007 by Systems in Motion.  All rights reserved.
00008  *
00009  *  This library is free software; you can redistribute it and/or
00010  *  modify it under the terms of the GNU General Public License
00011  *  ("GPL") version 2 as published by the Free Software Foundation.
00012  *  See the file LICENSE.GPL at the root directory of this source
00013  *  distribution for additional information about the GNU GPL.
00014  *
00015  *  For using Coin with software that can not be combined with the GNU
00016  *  GPL, and for taking advantage of the additional benefits of our
00017  *  support services, please contact Systems in Motion about acquiring
00018  *  a Coin Professional Edition License.
00019  *
00020  *  See http://www.coin3d.org/ for more information.
00021  *
00022  *  Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY.
00023  *  http://www.sim.no/  sales@sim.no  coin-support@coin3d.org
00024  *
00025 \**************************************************************************/
00026 
00027 #include <Inventor/nodes/SoSubNode.h>
00028 #include <Inventor/lists/SbList.h>
00029 
00030 #ifndef COIN_INTERNAL
00031 // Added for Inventor compliance
00032 #include <Inventor/actions/SoHandleEventAction.h>
00033 #endif // !COIN_INTERNAL
00034 
00035 class SoEventCallback;
00036 class SoPath;
00037 class SoEvent;
00038 class SoPickedPoint;
00039 class SoHandleEventAction;
00040 
00041 typedef void SoEventCallbackCB(void * userdata, SoEventCallback * node);
00042 
00043 class COIN_DLL_API SoEventCallback : public SoNode {
00044   typedef SoNode inherited;
00045 
00046   SO_NODE_HEADER(SoEventCallback);
00047 
00048 public:
00049   static void initClass(void);
00050   SoEventCallback(void);
00051 
00052   void setPath(SoPath * path);
00053   const SoPath * getPath(void);
00054 
00055   void addEventCallback(SoType eventtype, SoEventCallbackCB * f,
00056                         void * userdata = NULL);
00057   void removeEventCallback(SoType eventtype, SoEventCallbackCB * f,
00058                            void * userdata = NULL);
00059 
00060   SoHandleEventAction * getAction(void) const;
00061   const SoEvent * getEvent(void) const;
00062   const SoPickedPoint * getPickedPoint(void) const;
00063 
00064   void setHandled(void);
00065   SbBool isHandled(void) const;
00066 
00067   void grabEvents(void);
00068   void releaseEvents(void);
00069 
00070 protected:
00071   virtual ~SoEventCallback();
00072 
00073   virtual void handleEvent(SoHandleEventAction * action);
00074 
00075 private:
00076 
00077   struct CallbackInfo {
00078     SoEventCallbackCB * func;
00079     SoType eventtype;
00080     void * userdata;
00081 
00082     // AIX native compiler xlC needs equality and inequality operators
00083     // to compile templates where these operators are referenced (even
00084     // if they are actually never used).
00085 
00086     SbBool operator==(const CallbackInfo & cbi) {
00087       return this->func == cbi.func && this->eventtype == cbi.eventtype && this->userdata == cbi.userdata;
00088     }
00089     SbBool operator!=(const CallbackInfo & cbi) {
00090       return !(*this == cbi);
00091     }
00092   };
00093 
00094   SbList<CallbackInfo> callbacks;
00095   SoHandleEventAction * heaction;
00096   SoPath * path;
00097 
00098 };
00099 
00100 #endif // !COIN_SOEVENTCALLBACK_H

Copyright © 1998-2007 by Systems in Motion AS. All rights reserved.

Generated on Mon Feb 23 16:33:16 2009 for Coin by Doxygen. 1.5.8