NITE 1.5.1 - API Reference

XnVSelectableSlider1D.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_SELECTABLE_SLIDER_1D_H_
00010 #define _XNV_SELECTABLE_SLIDER_1D_H_
00011 
00012 #include "XnVPointControl.h"
00013 #include "XnVMultiItemHysteresis1D.h"
00014 #include "XnVSlider1D.h"
00015 
00016 class XnVBorderScrollController1D;
00017 
00018 class XnVIntSpecificEvent;
00019 class XnVIntDirectionSpecificEvent;
00020 class XnVFloatSpecificEvent;
00021 class XnVDirectionSpecificEvent;
00022 
00029 class XNV_NITE_API XnVSelectableSlider1D :
00030     public XnVPointControl
00031 {
00032 public:
00036     typedef void (XN_CALLBACK_TYPE *ItemHoverCB)(XnInt32 nItemIndex, void* pUserCxt);
00040     typedef void (XN_CALLBACK_TYPE *ItemSelectCB)(XnInt32 nItemIndex, XnVDirection nDirection, void* pUserCxt);
00045     typedef void (XN_CALLBACK_TYPE *ScrollCB)(XnFloat fScrollValue, void* pUserCxt);
00050     typedef void (XN_CALLBACK_TYPE *ValueChangeCB)(XnFloat fValue, void* pUserCxt);
00054     typedef void (XN_CALLBACK_TYPE *OffAxisMovementCB)(XnVDirection dir, void* pUserCxt);
00055 
00069     XnVSelectableSlider1D(XnInt32 nCount, XnFloat fBorderWidth = 0, XnVAxis eAxis = AXIS_X,
00070         XnBool bRecenter = TRUE, 
00071         XnFloat fHysteresisRatio = XnVMultiItemHysteresis1D::ms_fDefaultHysteresisRatio,
00072         XnFloat fPrimarySliderSize = ms_fDefaultPrimarySliderSize, XnFloat fFirstValue = 0.5,
00073         const XnChar* strName = "XnVSelectableSlider1D");
00074 
00075     ~XnVSelectableSlider1D();
00076 
00083     void OnPrimaryPointCreate(const XnVHandPointContext* pContext, const XnPoint3D& ptFocus);
00090     void OnPrimaryPointUpdate(const XnVHandPointContext* pContext);
00096     void OnPrimaryPointDestroy(XnUInt32 nID);
00097 
00098     static const XnFloat ms_fDefaultPrimarySliderSize;  // = 250
00099 
00108     XnCallbackHandle RegisterItemHover(void* cxt, ItemHoverCB pCB);
00117     XnCallbackHandle RegisterItemSelect(void* cxt, ItemSelectCB pCB);
00126     XnCallbackHandle RegisterScroll(void* cxt, ScrollCB pCB);
00135     XnCallbackHandle RegisterValueChange(void* cxt, ValueChangeCB pCB);
00144     XnCallbackHandle RegisterOffAxisMovement(void* cxt, OffAxisMovementCB pCB);
00145 
00151     void UnregisterItemHover(XnCallbackHandle handle);
00157     void UnregisterItemSelect(XnCallbackHandle handle);
00163     void UnregisterScroll(XnCallbackHandle handle);
00169     void UnregisterValueChange(XnCallbackHandle handle);
00175     void UnregisterOffAxisMovement(XnCallbackHandle handle);
00176 
00182     void ItemHover(XnInt32 nItemIndex);
00188     void ItemSelect(XnVDirection nDirection);
00194     void Scroll(XnFloat fScrollValue);
00195 
00201     void Reposition(const XnPoint3D& ptCenter);
00202     void GetCenter(XnPoint3D& ptCenter) const;
00203 
00209     XnUInt32 GetItemCount() const;
00215     void SetItemCount(XnUInt32 nItems);
00216 
00222     XnFloat GetBorderWidth() const;
00228     XnStatus SetBorderWidth(XnFloat fWidth);
00229 
00235     XnFloat GetSliderSize() const;
00241     void SetSliderSize(XnFloat fSliderSize);
00242 
00248     void SetValueChangeOnOffAxis(XnBool bReport);
00252     XnBool GetValueChangeOnOffAxis() const;
00253 
00260     void SetHysteresisRatio(XnFloat fRatio);
00266     XnFloat GetHysteresisRatio() const;
00267 protected:
00268     XnFloat GetFirstValue() const;
00269 
00270     XnFloat GetLeftScrollRegionEnd() const;
00271     XnFloat GetRightScrollRegionEnd() const;
00272 
00273     void PointCreated(const XnPoint3D& ptPos);
00274     void PointDeleted(XnBool bReason);
00275     void PointMoved(const XnPoint3D& ptPos, XnFloat fTime);
00276 
00277     void SetFirstValue(XnFloat fValue);
00278 
00279     void InternalCreateSlider(XnBool bPrimaryAxis, XnVAxis eAxis, const XnPoint3D& ptInitialPoint, XnFloat fInitialValue);
00280 
00281     // Is this needed public?
00282     void ValueChange(XnFloat fValue);
00283     void OffAxisMovement(XnVDirection dir);
00284 
00285     static void XN_CALLBACK_TYPE PrimarySlider_OffAxisMovement(XnVDirection eDir, void* pContext);
00286     static void XN_CALLBACK_TYPE PrimarySlider_ValueChange(XnFloat fValue, void* pContext);
00287     static void XN_CALLBACK_TYPE SecondarySlider_OffAxisMovement(XnVDirection eDir, void* pContext);
00288     static void XN_CALLBACK_TYPE SecondarySlider_ValueChange(XnFloat fValue, void* pContext);
00289     static void XN_CALLBACK_TYPE Hysteresis_ItemSelected(XnInt32 nItem, void* pContext);
00290     static void XN_CALLBACK_TYPE OffAxisHysteresis_ItemSelected(XnInt32 nItem, void* pContext);
00291     static void XN_CALLBACK_TYPE Scroller_Scrolled(XnFloat fScrollValue, void* pContext);
00292 
00293     void PrimarySlider_OffAxisMovement(XnVDirection eDir);
00294     void SecondarySlider_OffAxisMovement(XnVDirection eDir);
00295     void UpdatePrimarySlider(XnFloat fVal);
00296     void UpdateSecondarySlider(XnFloat fVal);
00297     void OffAxisHysteresis_ItemSelected(XnInt32 nItem);
00298 
00299     static const XnFloat ms_fSecondarySliderSize;   // = 150
00300 
00301     XnVMultiItemHysteresis1D* m_pHysteresis;
00302     XnVMultiItemHysteresis1D* m_pOffAxisHysteresis;
00303     XnVBorderScrollController1D* m_pScroller;
00304 
00305     XnBool m_bPositioned;
00306     XnBool m_bRecenter;
00307 
00308     XnBool m_bValueChangeOnOffAxis;
00309 
00310     XnVSlider1D* m_pSlider;             // Pointer to current active
00311     XnVSlider1D* m_pPrimarySlider;
00312     XnVSlider1D* m_pSecondarySlider;
00313 
00314     //Events this object is registered to:
00315     XnUInt32 m_nOffAxisHandle;
00316     XnUInt32 m_nValueChangeHandle;
00317 
00318     XnFloat m_fPrimarySliderSize;
00319     XnFloat m_fPrimarySliderValueAtChange;
00320 
00321     XnFloat m_fFirstValue;
00322     XnBool m_bFirstPointCreated;
00323 
00324     XnVAxis m_ePrimaryAxisDirection;
00325     XnUInt32 m_nItemCount;
00326 
00327     XnInt32 m_nLastHover;
00328 
00329     XnPoint3D m_ptCenter;
00330 
00331     XnCallbackHandle m_hPrimaryHysteresisItemSelect;
00332     XnCallbackHandle m_hSecondaryHysteresisItemSelect;
00333     XnCallbackHandle m_hScrollerScroll;
00334 
00335     XnCallbackHandle m_hPrimarySliderOffAxis;
00336     XnCallbackHandle m_hPrimarySliderValueChange;
00337     XnCallbackHandle m_hSecondarySliderOffAxis;
00338     XnCallbackHandle m_hSecondarySliderValueChange;
00339 
00340     XnVIntSpecificEvent* m_pItemHoverCBs;
00341     XnVIntDirectionSpecificEvent* m_pItemSelectCBs;
00342     XnVFloatSpecificEvent* m_pScrollCBs;
00343     XnVFloatSpecificEvent* m_pValueChangeCBs;
00344     XnVDirectionSpecificEvent* m_pOffAxisMovementCBs;
00345 }; // XnVSelectableSlider1D
00346 
00347 #endif // _XNV_SELECTABLE_SLIDER_1D_H_