NITE 1.5.1 - API Reference

XnVSlider1D.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_1D_H_
00010 #define _XNV_SLIDER_1D_H_
00011 
00012 #include "XnVNiteDefs.h"
00013 #include "XnVDirection.h"
00014 
00015 class XnVPointBuffer;
00016 class XnVFloatSpecificEvent;
00017 class XnVDirectionSpecificEvent;
00018 
00027 class XNV_NITE_API XnVSlider1D
00028 {
00029 public:
00033     typedef void (XN_CALLBACK_TYPE* ValueChangeCB)(XnFloat fValue, void* cxt);
00037     typedef void (XN_CALLBACK_TYPE* OffAxisMovementCB)(XnVDirection eDir, void* cxt);
00038 
00051     XnVSlider1D(XnVAxis eAxis, const XnPoint3D& ptInitialPosition, XnPoint3D ptMinPoint, XnPoint3D ptMaxPoint,
00052         XnFloat fMinOutput, XnFloat fMaxOutput,
00053         XnFloat fOffAxisDetectionAngle = ms_fOffAxisDefaultDetectionAngle,
00054         XnFloat fOffAxisDetectionMinimumVelocity = ms_fDefaultMinimumOffAxisVelocity); 
00067     XnVSlider1D(XnVAxis eAxis, const XnPoint3D& ptInitialPosition, XnFloat fSliderLength, XnFloat fInitialValue,
00068         XnFloat fMinOutput, XnFloat fMaxOutput,
00069         XnFloat fOffAxisDetectionAngle = ms_fOffAxisDefaultDetectionAngle,
00070         XnFloat fOffAxisDetectionMinimumVelocity = ms_fDefaultMinimumOffAxisVelocity);
00071 
00072     ~XnVSlider1D();
00073 
00084     void Reinitialize(XnVAxis eAxis, const XnPoint3D& ptInitialPoint, const XnPoint3D& ptMinPoint,
00085         const XnPoint3D& ptMaxPoint, XnFloat fMinOutput, XnFloat fMaxOutput);
00096     void Reinitialize(XnVAxis eAxis, const XnPoint3D& ptInitialPoint, XnFloat fSliderLength,
00097         XnFloat fInitialValue, XnFloat fMinOutput, XnFloat fMaxOutput);
00098 
00102     XnFloat ValueAtPosition(const XnPoint3D& pt);
00103 
00111     XnStatus Update(const XnPoint3D& pt, XnFloat fTime, XnBool bCheckOffAxis = true);
00112 
00116     void LostPoint();
00117 
00126     XnCallbackHandle RegisterValueChange(void* cxt, ValueChangeCB CB);
00135     XnCallbackHandle RegisterOffAxisMovement(void* cxt, OffAxisMovementCB CB);
00136 
00142     void UnregisterValueChange(XnCallbackHandle hCB);
00148     void UnregisterOffAxisMovement(XnCallbackHandle hCB);
00149 
00150     XnFloat GetValue() const;
00151     const XnPoint3D& GetPosition() const;
00152     XnBool IsValid() const;
00153 
00159     XnVAxis GetAxis() const;
00160 
00166     XnFloat  GetOffAxisDetectionVelocity() const;
00172     XnFloat  GetOffAxisDetectionAngle() const;
00178     XnUInt32 GetOffAxisDetectionTime() const;
00179 
00185     void SetOffAxisDetectionVelocity(XnFloat fVelocity);
00191     void SetOffAxisDetectionAngle(XnFloat fAngle);
00197     void SetOffAxisDetectionTime(XnUInt32 nTime);
00198 protected:
00199     void ValueChange(XnFloat fValue);
00200     void OffAxisMovement(XnVDirection eDir);
00201 
00202     XnVSlider1D(XnVAxis eAxis, XnBool bDraggable, const XnPoint3D& ptInitialPosition, XnFloat fSliderLength,
00203         XnFloat fInitialValue, XnFloat fMinOutput, XnFloat fMaxOutput,
00204         XnFloat fOffAxisDetectionAngle = ms_fOffAxisDefaultDetectionAngle,
00205         XnFloat fOffAxisDetectionMinimumVelocity = ms_fDefaultMinimumOffAxisVelocity);
00206 
00207     void InitializeFromPoint(const XnPoint3D& ptInitialPosition, const XnPoint3D& ptMinPoint, const XnPoint3D& ptMaxPoint,
00208         XnBool bVertical, XnFloat& fSliderLength, XnFloat& fInitialValue);
00209     void Initialize(XnVAxis eAxis, XnBool bDraggable, const XnPoint3D& ptInitialPosition, XnFloat fSliderLength,
00210         XnFloat fInitialValue, XnFloat fMinOutput, XnFloat fMaxOutput, XnFloat fOffAxisDetectionAngle,
00211         XnFloat fOffAxisDetectionMinimumMovement);
00212 
00213     XnVDirection CheckForOffAxisMovement(const XnPoint3D& pt, XnFloat fTime);
00214     XnInt32 CheckOffAxis(XnFloat fPrimaryAxisDelta, XnFloat fOffAxisDelta);
00215 
00216 
00217     static const XnFloat ms_fDefaultMinimumOffAxisVelocity;     // = 0.15f m/s
00218     static const XnFloat ms_fOffAxisDefaultDetectionAngle;          // = 60.0f
00219     static const XnUInt32 ms_nDefaultTimeForOffAxisDetection;       // = 350 ms
00220 
00221     XnFloat m_fOffAxisDetectionMinimumVelocity;
00222     XnFloat m_fOffAxisDetectionAngle;
00223     XnUInt32 m_nOffAxisDetectionTime;
00224 
00225     XnVAxis m_eAxis;
00226     XnBool m_bIsDraggable;
00227 
00228     XnFloat m_fCurrentOutput;
00229     XnPoint3D m_ptCurrentPosition;
00230 
00231     XnFloat m_fOutputMinimum, m_fOutputMaximum;
00232     XnFloat m_fMaxOutputMajorAxisPosition, m_fMinOutputMajorAxisPosition;
00233 
00234     XnVPointBuffer* m_pPointBuffer;
00235 
00236     XnVFloatSpecificEvent* m_pValueChangeCBs;
00237     XnVDirectionSpecificEvent* m_pOffAxisMovementCBs;
00238 };
00239 
00240 #endif // _XNV_SLIDER_1D_H_