NITE 1.5.1 - API Reference

XnVSlider2D.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002 *                                                                              *
00003 *   PrimeSense NITE 1.3                                                        *
00004 *   Copyright (C) 2010 PrimeSense Ltd.                                         *
00005 *                                                                              *
00006 *******************************************************************************/
00007 
00008 
00009 #ifndef _XNV_SLIDER_2D_H_
00010 #define _XNV_SLIDER_2D_H_
00011 
00012 #include "XnVNiteDefs.h"
00013 #include "XnVDirection.h"
00014 
00015 class XnVPointBuffer;
00016 class XnVFloatFloatSpecificEvent;
00017 class XnVDirectionSpecificEvent;
00018 
00026 class XNV_NITE_API XnVSlider2D
00027 {
00028 public:
00032     typedef void (XN_CALLBACK_TYPE *ValueChangeCB)(XnFloat fXValue, XnFloat fYValue, void* pUserCxt);
00036     typedef void (XN_CALLBACK_TYPE *OffAxisMovementCB)(XnVDirection eDir, void* pUserCxt);
00037 
00044     XnVSlider2D(const XnPoint3D& ptMin ,const XnPoint3D& ptMax);
00054     XnVSlider2D(const XnPoint3D& ptInitialPosition, XnFloat fSliderXLength, XnFloat fSliderYLength,
00055                 XnFloat fInitialXValue, XnFloat fInitialYValue);
00056 
00057     ~XnVSlider2D();
00065     XnStatus Update(const XnPoint3D& pt, XnFloat fTime, XnBool bCheckOffAxis = true);
00066 
00075     XnCallbackHandle RegisterValueChange(void* cxt, ValueChangeCB CB); // Add CB to list
00084     XnCallbackHandle RegisterOffAxisMovement(void* cxt, OffAxisMovementCB CB); 
00090     void UnregisterValueChange(XnCallbackHandle hCB);
00096     void UnregisterOffAxisMovement(XnCallbackHandle hCB);
00097 
00098     XnPoint3D GetPosition() const {return m_ptCurrentPosition;}
00099 
00105     XnFloat  GetOffAxisDetectionVelocity() const;
00111     XnFloat  GetOffAxisDetectionAngle() const;
00117     XnUInt32 GetOffAxisDetectionTime() const;
00118 
00124     void SetOffAxisDetectionVelocity(XnFloat fVelocity);
00130     void SetOffAxisDetectionAngle(XnFloat fAngle);
00136     void SetOffAxisDetectionTime(XnUInt32 nTime);
00137 protected:
00138     XnInt32 CheckForOffAxisMovement(const XnPoint3D& pt, XnFloat fTime);
00139 
00140     XnPoint3D m_ptMin, m_ptMax;
00141     XnFloat m_fSizeX, m_fSizeY;
00142 
00143     XnVPointBuffer* m_pPointBuffer;
00144 
00145     XnPoint3D m_ptCurrentPosition;
00146 
00147     // Event broadcast
00148     void ValueChange(XnFloat fXValue, XnFloat fYValue); // go over list and call all functions
00149     void OffAxisMovement(XnVDirection eDir);
00150 
00151     XnVFloatFloatSpecificEvent* m_pValueChangeCBs;
00152     XnVDirectionSpecificEvent* m_pOffAxisMovementCBs;
00153 
00154     static const XnFloat ms_fOffAxisDefaultMininumVelocity; // = 0.17 m/s
00155     static const XnFloat ms_fOffAxisDefaultDetectionAngle;      // = 60.0f
00156     static const XnUInt32 ms_nDefaultTimeForOffAxisDetection;   // = 350 ms
00157 
00158     XnFloat m_fOffAxisDetectionVelocity;
00159     XnFloat m_fOffAxisDetectionAngle;
00160     XnUInt32 m_nOffAxisDetectionTime;
00161 };
00162 
00163 
00164 #endif // _XNV_SLIDER_2D_H_