Mercurial > hg > ccmieditor
view native/PhantomOmni/HapticManager.h @ 8:ea7885bd9bff tip
fixed bug : render solid line as dotted/dashed when moving the stylus from dotted/dashed to solid
author | ccmi-guest |
---|---|
date | Thu, 03 Jul 2014 16:12:20 +0100 |
parents | 9e67171477bc |
children |
line wrap: on
line source
#pragma once #include "stdAfx.h" #include <time.h> #include "HapticException.h" #include "CollectionsManager.h" #define NOVIBRATION /* The haptic manager draws the diagram openGL scene haptically. * * In order to get all the data about the diagram it's constructed * * passing a reference to the CollectionManager */ class HapticManager { enum AttractionStatus {START_ATTRACTION, DOING_ATTRACTION, NO_ATTRACTION, STOP_ATTRACTION}; enum SpringStatus { DRAGGING, RELEASED, START_DRAGGING, STOP_DRAGGING }; enum VibrationStatus { START_VIBRATION , DOING_VIBRATION , NO_VIBRATION, CAN_VIBRATE}; /* Haptic device and rendering context handles. */ HLuint wall1Id; HLuint wall2Id; HLuint frictionFX; HLuint vibrationFX; HLuint attractionFX; HLuint springFX; VibrationStatus vibrationStatus; AttractionStatus attractionStatus; SpringStatus springStatus; #ifdef VIBRATION static const HDdouble VIBRATION_AMPLITUDE; static const HDint VIBRATION_FREQUENCY; static const unsigned int VIBRATION_DURATION; #endif static const double EDGE_SHORTEND_VAL; static const double EDGE_SPEECH_DISTANCE_WHEN_LEAVING_NODE; static const unsigned int CLICK_INTERVAL; clock_t clickStart; clock_t vibrationEnd; HDdouble forceBeforeVibration[3]; CollectionsManager *collectionsManager; bool wall; jint attractToHapticId; bool alreadyTouchingAttractingElement; jdouble attractToCoord[3]; // this is needed to calulate the distance between the proxy and the last touched node HLdouble lastTouchedNodePosition[3]; HLint lastTouchedNodeID; HLint lastTouchedEdgeID; jint lastTouchedEdgeStipplePattern; HLint lastHighlightElementID; HLint draggedElementID; /* when dropping a node after moving it, unless one detouches and touches again the node, the hlGetShapeBooleanv(HL_PROXY_IS_TOUCHING) routine will return a false value when one tries to hook the node again. Even tough the touch and untouch callback are called correctly. this variable keeps track of the last moved element, setting it to HL_OBJECT_ANY on the detouch callback so that this "buggy" behaviour is worked around */ HLuint lastMovedElement; bool stillTouchingLastMovedElement; /* this variable is to workaround the HL_PROXY_IS_TOUCHNIG problem to fix issue of stipple pattern: when dropping a node after having picked it up, then the hlGetShapeBooleanv may return false for all the edges attached to a moved node or for a moved edge. Because of that the stipple pattern for dotted and dashed lines might not be enabled. The check is however necessary to stop the effect when actually untouching the node or when changing tab after the pick up and drop. The variable is set/unset in the touching callbacks which works fine. */ bool lastTouchedEdgeIsUntouched; HLdouble springStart[3]; GLuint displayList1; GLuint displayList2; bool frictionDisabled; bool doneOnce; bool secondClick; bool stickyMode; bool doubleClick; void drawPlane(float offset); void (*executeCommand)(const jchar cmd, const jint ID, const jdouble startx, const jdouble starty, const jdouble endx, const jdouble endy); static void HLCALLBACK hlButton1CB(HLenum event, HLuint object, HLenum thread, HLcache *cache, void *userdata); static void HLCALLBACK hlButton2CB(HLenum event, HLuint object, HLenum thread, HLcache *cache, void *userdata); static void HLCALLBACK hlTouchCB(HLenum event, HLuint object, HLenum thread, HLcache *cache, void *userdata); static void HLCALLBACK hlUntouchCB(HLenum event, HLuint object, HLenum thread, HLcache *cache, void *userdata); static void HLCALLBACK hlMotionCB(HLenum event, HLuint object, HLenum thread, HLcache *cache, void *userdata); #ifdef VIBRATION static void HLCALLBACK vibrationCB(HDdouble force[3], HLcache *cache, void *userdata); static void HLCALLBACK beforeVibrationCB(HLcache *cache, void *userdata); static void HLCALLBACK afterVibrationCB(HLcache *cache, void *userdata); #endif public: enum ClickStatus { NO_CLICK, ONE_CLICK, TWO_CLICK }; static HHD ghHD; static HHLRC ghHLRC; HapticManager(CollectionsManager * cManager, void (*func)(const jchar cmd, const jint ID, const jdouble startx, const jdouble starty, const jdouble endx, const jdouble endy)) : executeCommand(func), wall(true), collectionsManager(cManager), vibrationStatus(NO_VIBRATION), springStatus(RELEASED), alreadyTouchingAttractingElement(false), doneOnce(false), attractionStatus(NO_ATTRACTION), frictionDisabled(false), secondClick(false), clickStart(0), stickyMode(true), lastMovedElement(HL_OBJECT_ANY),stillTouchingLastMovedElement(false),lastTouchedEdgeIsUntouched(false){}; ~HapticManager(void) {} void init(void) throw(HapticException); void draw(void); void setAttractTo(jint hapticId); void pickUp(jint hapticId); bool wasAlreadyTouchingAttractingElement(void); void enableWall(void){ wall = true; } void disableWall(void){ wall = false; } bool isDraggingNode() const { return springStatus == DRAGGING && collectionsManager->isNode(draggedElementID); } bool isDraggingEdge() const { return springStatus == DRAGGING && collectionsManager->isEdge(draggedElementID); } ClickStatus getButton1Status(); void doButton1Click(bool doubleClick); };