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

SoEventCallback.h
1 #ifndef COIN_SOEVENTCALLBACK_H
2 #define COIN_SOEVENTCALLBACK_H
3 
4 /**************************************************************************\
5  *
6  * This file is part of the Coin 3D visualization library.
7  * Copyright (C) 1998-2007 by Systems in Motion. All rights reserved.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * ("GPL") version 2 as published by the Free Software Foundation.
12  * See the file LICENSE.GPL at the root directory of this source
13  * distribution for additional information about the GNU GPL.
14  *
15  * For using Coin with software that can not be combined with the GNU
16  * GPL, and for taking advantage of the additional benefits of our
17  * support services, please contact Systems in Motion about acquiring
18  * a Coin Professional Edition License.
19  *
20  * See http://www.coin3d.org/ for more information.
21  *
22  * Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY.
23  * http://www.sim.no/ sales@sim.no coin-support@coin3d.org
24  *
25 \**************************************************************************/
26 
27 #include <Inventor/nodes/SoSubNode.h>
28 #include <Inventor/lists/SbList.h>
29 
30 #ifndef COIN_INTERNAL
31 // Added for Inventor compliance
32 #include <Inventor/actions/SoHandleEventAction.h>
33 #endif // !COIN_INTERNAL
34 
35 class SoEventCallback;
36 class SoPath;
37 class SoEvent;
38 class SoPickedPoint;
40 
41 typedef void SoEventCallbackCB(void * userdata, SoEventCallback * node);
42 
43 class COIN_DLL_API SoEventCallback : public SoNode {
44  typedef SoNode inherited;
45 
46  SO_NODE_HEADER(SoEventCallback);
47 
48 public:
49  static void initClass(void);
50  SoEventCallback(void);
51 
52  void setPath(SoPath * path);
53  const SoPath * getPath(void);
54 
55  void addEventCallback(SoType eventtype, SoEventCallbackCB * f,
56  void * userdata = NULL);
57  void removeEventCallback(SoType eventtype, SoEventCallbackCB * f,
58  void * userdata = NULL);
59 
60  SoHandleEventAction * getAction(void) const;
61  const SoEvent * getEvent(void) const;
62  const SoPickedPoint * getPickedPoint(void) const;
63 
64  void setHandled(void);
65  SbBool isHandled(void) const;
66 
67  void grabEvents(void);
68  void releaseEvents(void);
69 
70 protected:
71  virtual ~SoEventCallback();
72 
73  virtual void handleEvent(SoHandleEventAction * action);
74 
75 private:
76 
77  struct CallbackInfo {
78  SoEventCallbackCB * func;
79  SoType eventtype;
80  void * userdata;
81 
82  // AIX native compiler xlC needs equality and inequality operators
83  // to compile templates where these operators are referenced (even
84  // if they are actually never used).
85 
86  SbBool operator==(const CallbackInfo & cbi) {
87  return this->func == cbi.func && this->eventtype == cbi.eventtype && this->userdata == cbi.userdata;
88  }
89  SbBool operator!=(const CallbackInfo & cbi) {
90  return !(*this == cbi);
91  }
92  };
93 
94  SbList<CallbackInfo> callbacks;
95  SoHandleEventAction * heaction;
96  SoPath * path;
97 
98 };
99 
100 #endif // !COIN_SOEVENTCALLBACK_H
SoEventCallback::getPath
const SoPath * getPath(void)
Definition: SoEventCallback.cpp:152
SoHandleEventAction::setGrabber
void setGrabber(SoNode *node)
Definition: SoHandleEventAction.cpp:237
SoEventCallback::getEvent
const SoEvent * getEvent(void) const
Definition: SoEventCallback.cpp:217
SoEventCallback::addEventCallback
void addEventCallback(SoType eventtype, SoEventCallbackCB *f, void *userdata=NULL)
Definition: SoEventCallback.cpp:164
SoEventCallback::setPath
void setPath(SoPath *path)
Definition: SoEventCallback.cpp:128
SoEventCallback::SoEventCallback
SoEventCallback(void)
Definition: SoEventCallback.cpp:95
SoEventCallback::getPickedPoint
const SoPickedPoint * getPickedPoint(void) const
Definition: SoEventCallback.cpp:229
SoDebugError::postWarning
static void postWarning(const char *const source, const char *const format,...)
Definition: SoDebugError.cpp:324
SbList::append
void append(const Type item)
Definition: SbList.h:98
SoEventCallback::releaseEvents
void releaseEvents(void)
Definition: SoEventCallback.cpp:307
SoPath::containsPath
SbBool containsPath(const SoPath *const path) const
Definition: SoPath.cpp:611
SoType::isDerivedFrom
SbBool isDerivedFrom(const SoType type) const
Definition: SoType.cpp:687
SoHandleEventAction::setHandled
void setHandled(void)
Definition: SoHandleEventAction.cpp:211
SoBase::unref
void unref(void) const
Definition: SoBase.cpp:627
SoEvent::getTypeId
virtual SoType getTypeId(void) const
Definition: SoEvent.cpp:55
SoPath
The SoPath class is a container class for traversal path descriptions.
Definition: SoPath.h:43
SoBase::getRefCount
int32_t getRefCount(void) const
Definition: SoBase.cpp:686
SoHandleEventAction::isHandled
SbBool isHandled(void) const
Definition: SoHandleEventAction.cpp:223
SoType
The SoType class is the basis for the run-time type system in Coin.
Definition: SoType.h:50
SbList< CallbackInfo >
SbList::getLength
int getLength(void) const
Definition: SbList.h:145
SoBase
The SoBase class is the top-level superclass for a number of class-hierarchies.
Definition: SoBase.h:41
SoBase::ref
void ref(void) const
Definition: SoBase.cpp:574
SoEventCallback
The SoEventCallback class provides functionality for catching events.
Definition: SoEventCallback.h:43
SoPath::copy
SoPath * copy(const int startfromnodeindex=0, int numnodes=0) const
Definition: SoPath.cpp:673
SbList::remove
void remove(const int index)
Definition: SbList.h:129
SoEventCallback::isHandled
SbBool isHandled(void) const
Definition: SoEventCallback.cpp:269
SoEventCallback::getAction
SoHandleEventAction * getAction(void) const
Definition: SoEventCallback.cpp:203
SoPickedPoint
The SoPickedPoint class is used for specifying picked points.
Definition: SoPickedPoint.h:39
SoEventCallback::grabEvents
void grabEvents(void)
Definition: SoEventCallback.cpp:288
SoNode::handleEvent
virtual void handleEvent(SoHandleEventAction *action)
Definition: SoNode.cpp:1031
SoHandleEventAction::releaseGrabber
void releaseGrabber(void)
Definition: SoHandleEventAction.cpp:257
SoEventCallback::handleEvent
virtual void handleEvent(SoHandleEventAction *action)
Definition: SoEventCallback.cpp:324
SoHandleEventAction::getEvent
const SoEvent * getEvent(void) const
Definition: SoHandleEventAction.cpp:196
SoHandleEventAction::getPickedPoint
const SoPickedPoint * getPickedPoint(void)
Definition: SoHandleEventAction.cpp:315
SoNode
The SoNode class is the base class for nodes used in scene graphs.
Definition: SoNode.h:47
SoHandleEventAction
The SoHandleEventAction class distributes user events to the scene.
Definition: SoHandleEventAction.h:36
SoEventCallback::removeEventCallback
void removeEventCallback(SoType eventtype, SoEventCallbackCB *f, void *userdata=NULL)
Definition: SoEventCallback.cpp:179
SoEventCallback::setHandled
void setHandled(void)
Definition: SoEventCallback.cpp:251
SoEvent
The SoEvent class is the base class for all Coin events.
Definition: SoEvent.h:34
SoEventCallback::~SoEventCallback
virtual ~SoEventCallback()
Definition: SoEventCallback.cpp:106
SoPickedPoint::getPath
SoPath * getPath() const
Definition: SoPickedPoint.cpp:178

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

Generated on Wed Jul 24 2019 for Coin by Doxygen. 1.8.17