NITE 1.5.1 - API Reference
|
00001 /******************************************************************************* 00002 * * 00003 * PrimeSense NITE 1.3 * 00004 * Copyright (C) 2010 PrimeSense Ltd. * 00005 * * 00006 *******************************************************************************/ 00007 00008 00009 #ifndef _XNV_SELECTABLE_SLIDER_2D_H_ 00010 #define _XNV_SELECTABLE_SLIDER_2D_H_ 00011 00012 #include <XnOpenNI.h> 00013 #include "XnVNiteDefs.h" 00014 #include "XnVPointControl.h" 00015 #include "XnVDirection.h" 00016 #include "XnVSlider2D.h" 00017 #include "XnVMultiItemHysteresis2D.h" 00018 #include "XnVSlider1D.h" 00019 #include "XnVMultiItemHysteresis1D.h" 00020 00021 class XnVBorderScrollController2D; 00022 class XnVIntIntSpecificEvent; 00023 class XnVFloatFloatSpecificEvent; 00024 class XnVFloatFloatSpecificEvent; 00025 class XnVItemSelectSpecificEvent; 00026 class XnVDirectionSpecificEvent; 00027 00034 class XNV_NITE_API XnVSelectableSlider2D : 00035 public XnVPointControl 00036 { 00037 public: 00041 typedef void (XN_CALLBACK_TYPE *ItemHoverCB)(XnInt32 nXIndex, XnInt32 nYIndex, void* pUserCxt); 00045 typedef void (XN_CALLBACK_TYPE *ItemSelectCB)(XnInt32 nXIndex, XnInt32 nYIndex, XnVDirection eDir, void* pUserCxt); 00049 typedef void (XN_CALLBACK_TYPE *OffAxisMovementCB)(XnVDirection eDir, void* pUserCxt); 00054 typedef void (XN_CALLBACK_TYPE *ValueChangeCB)(XnFloat fXValue, XnFloat fYValue, void* pUserCxt); 00059 typedef void (XN_CALLBACK_TYPE *ScrollCB)(XnFloat fXValue, XnFloat fYValue, void* pUserCxt); 00060 00072 XnVSelectableSlider2D(XnInt32 nXItems, XnInt32 nYItems, 00073 XnFloat fSliderSizeX = ms_fDefaultSliderSize, XnFloat fSliderSizeY = ms_fDefaultSliderSize, 00074 XnFloat fBorderWidth = 0, const XnChar* strName = "XnVSelectableSlider2D"); 00075 virtual ~XnVSelectableSlider2D(); 00076 00083 void OnPrimaryPointCreate(const XnVHandPointContext* pContext, const XnPoint3D& ptFocus); 00090 void OnPrimaryPointUpdate(const XnVHandPointContext* pContext); 00096 void OnPrimaryPointDestroy(XnUInt32 nID); 00097 00106 XnCallbackHandle RegisterItemHover(void* cxt, ItemHoverCB CB); 00115 XnCallbackHandle RegisterScroll(void* cxt, ScrollCB CB); 00124 XnCallbackHandle RegisterValueChange(void* cxt, ValueChangeCB CB); 00133 XnCallbackHandle RegisterItemSelect(void* cxt, ItemSelectCB CB); 00142 XnCallbackHandle RegisterOffAxisMovement(void* cxt, OffAxisMovementCB CB); 00143 00149 void UnregisterItemHover(XnCallbackHandle hCB); 00155 void UnregisterScroll(XnCallbackHandle hCB); 00161 void UnregisterValueChange(XnCallbackHandle hCB); 00167 void UnregisterItemSelect(XnCallbackHandle hCB); 00173 void UnregisterOffAxisMovement(XnCallbackHandle hCB); 00174 00175 static const XnFloat ms_fDefaultSliderSize; // = 450 00176 00182 void Reposition(const XnPoint3D& ptCenter); 00183 void GetCenter(XnPoint3D& ptCenter) const; 00184 00191 void GetSliderSize(XnFloat& fSliderXSize, XnFloat& fSliderYSize) const; 00198 void SetSliderSize(XnFloat fSliderXSize, XnFloat fSliderYSize); 00199 00205 XnUInt32 GetItemXCount() const; 00211 XnUInt32 GetItemYCount() const; 00218 void SetItemCount(XnUInt32 nItemXCount, XnUInt32 nItemYCount); 00224 void SetItemXCount(XnUInt32 nItemXCount); 00230 void SetItemYCount(XnUInt32 nItemYCount); 00231 00237 void SetValueChangeOnOffAxis(XnBool bReport); 00241 XnBool GetValueChangeOnOffAxis() const; 00242 00248 XnFloat GetBorderWidth() const; 00254 XnStatus SetBorderWidth(XnFloat fWidth); 00261 void SetHysteresisRatio(XnFloat fRatio); 00267 XnFloat GetHysteresisRatio() const; 00268 protected: 00269 void UpdateSlider(XnFloat fXValue, XnFloat fYValue); 00270 00271 void PointDeleted(XnBool bReason); 00272 void PointMoved(const XnPoint3D& pt, XnFloat fTime); 00273 00274 // Invoke events 00275 void ItemHover(XnInt32 nXIndex, XnInt32 nYIndex); 00276 void Scroll(XnFloat fXValue, XnFloat fYValue); 00277 void ValueChange(XnFloat fXValue, XnFloat fYValue); 00278 void ItemSelect(XnVDirection eDir); 00279 void OffAxisMovement(XnVDirection eDir); 00280 00281 // Callbacks 00282 static void XN_CALLBACK_TYPE Slider_ValueChange(XnFloat fXValue, XnFloat fYValue, void* pContext); 00283 static void XN_CALLBACK_TYPE Slider_OffAxis(XnVDirection eDir, void* cxt); 00284 static void XN_CALLBACK_TYPE Hysteresis_ItemSelected(XnInt32 nXItem, XnInt32 nYItem, void* pContext); 00285 static void XN_CALLBACK_TYPE Scroller2D_Scrolled(XnFloat fXValue, XnFloat fYValue, void *pContext); 00286 00287 static void XN_CALLBACK_TYPE SecondarySlider_OffAxisMovement(XnVDirection eDir, void* cxt); 00288 static void XN_CALLBACK_TYPE SecondarySlider_ValueChange(XnFloat fValue, void* cxt); 00289 static void XN_CALLBACK_TYPE OffAxisHysteresis_ItemSelected(XnInt32 nItem, void* cxt); 00290 00291 static const XnFloat ms_fSecondarySliderSize; 00292 XnBool m_bValueChangeWithoutBorders; 00293 00294 XnBool m_bPositioned; 00295 XnInt32 m_nXItems, m_nYItems; 00296 00297 XnBool m_bValueChangeOnOffAxis; 00298 00299 XnFloat m_fSliderSizeX; 00300 XnFloat m_fSliderSizeY; 00301 XnFloat m_fBorderWidth; 00302 XnVSlider2D* m_pSlider; 00303 XnVMultiItemHysteresis2D* m_pHysteresis; 00304 XnVBorderScrollController2D* m_pScroller; 00305 00306 XnBool m_bInOffAxis; 00307 XnVSlider1D* m_pSecondarySlider; 00308 XnVMultiItemHysteresis1D* m_pOffAxisHysteresis; 00309 00310 XnPoint3D m_ptCenter; 00311 00312 XnInt32 m_nXLastHover, m_nYLastHover; 00313 00314 XnCallbackHandle m_hHysteresisItemSelect; 00315 XnCallbackHandle m_hScrollerScroll; 00316 XnCallbackHandle m_hSliderValueChange; 00317 XnCallbackHandle m_hSliderOffAxis; 00318 00319 XnCallbackHandle m_hOffAxisHysteresisItemSelect; 00320 XnCallbackHandle m_hSecondarySliderValueChange; 00321 XnCallbackHandle m_hSecondarySliderOffAxis; 00322 00323 XnVIntIntSpecificEvent* m_pItemHoverCBs; 00324 XnVFloatFloatSpecificEvent* m_pScrollCBs; 00325 XnVFloatFloatSpecificEvent* m_pValueChangeCBs; 00326 XnVItemSelectSpecificEvent* m_pItemSelectCBs; 00327 XnVDirectionSpecificEvent* m_pOffAxisMovementCBs; 00328 }; 00329 00330 #endif // _XNV_SELECTABLE_SLIDER_2D_H_