bool Gazetteer::ReadPlaces(const char *fname) { // safety checks if (!fname) return false; if (*fname == 0) return false; FILE *fp = vtFileOpen(fname, "rb"); if (!fp) return false; char buf[999]; while (fgets(buf, 999, fp) != NULL) { Place p; p.m_state = Grab(buf, 0, 2); p.m_name = Grab(buf, 9, 60); p.m_name.TrimRight(); if (p.m_name.Right(10) == " (balance)") p.m_name = p.m_name.Left(p.m_name.GetLength() - 10); if (p.m_name.Right(5) == " city") p.m_name = p.m_name.Left(p.m_name.GetLength() - 5); else if (p.m_name.Right(5) == " town") p.m_name = p.m_name.Left(p.m_name.GetLength() - 5); else if (p.m_name.Right(4) == " CDP") p.m_name = p.m_name.Left(p.m_name.GetLength() - 4); else if (p.m_name.Right(13) == " municipality") p.m_name = p.m_name.Left(p.m_name.GetLength() - 13); else if (p.m_name.Right(17) == " city and borough") p.m_name = p.m_name.Left(p.m_name.GetLength() - 17); else if (p.m_name.Right(8) == " borough") p.m_name = p.m_name.Left(p.m_name.GetLength() - 8); else if (p.m_name.Right(8) == " village") p.m_name = p.m_name.Left(p.m_name.GetLength() - 8); else if (p.m_name.Right(10) == " comunidad") p.m_name = p.m_name.Left(p.m_name.GetLength() - 10); else if (p.m_name.Right(12) == " zona urbana") p.m_name = p.m_name.Left(p.m_name.GetLength() - 12); else if (p.m_name.Right(7) == " urbana") p.m_name = p.m_name.Left(p.m_name.GetLength() - 7); else { int foo = 1; } double x = atof(buf+153); double y = atof(buf+143); p.geo.Set(x, y); m_places.push_back(p); } fclose(fp); return true; }
bool ApplicationCenter::Reinitialize() { m_volumeData->Drop();// = new VolumeData<unsigned char>(); for(int i=0;i<(int)m_processorList.size();i++) { m_processorList[i]->Drop(); } m_processorList.clear(); for(int i=0;i<(int)m_rendererList.size();i++) { m_rendererList[i]->Drop(); } m_rendererList.clear(); #if 0 //re initialize m_volumeData = new VolumeData<unsigned char>(); //第一步 auto dataToFloatProcessor = new CDataToFloatProcessor(); auto dotRenderer = new CDotRenderer(); //dot m_processorList.push_back(dataToFloatProcessor); m_rendererList.push_back(dotRenderer); //marching cube m_processorList.push_back(new CMarchingCubeProcessor()); m_rendererList.push_back(new CMarchingCubeRenderer()); //raycast type1 m_processorList.push_back(dataToFloatProcessor); m_rendererList.push_back(new CRayCastRenderer(0)); dataToFloatProcessor->Grab(); //raycast type2 m_processorList.push_back(dataToFloatProcessor); m_rendererList.push_back(new CRayCastRenderer(1)); dataToFloatProcessor->Grab(); //CPU Depth //dot m_processorList.push_back(new CCpuDepthProcessor()); m_rendererList.push_back(dotRenderer); dotRenderer->Grab(); #else Initialize(); #endif return true; }
bool ApplicationCenter::Initialize() { if(!m_cam) { ShowMessage("摄像机没有设定到Application中来"); return false; } //初始化渲染设备 DrawingWrapper::Initialize(); m_volumeData = new VolumeData<unsigned char>(); //第一步 auto dataToFloatProcessor = new CDataToFloatProcessor(); auto dotRenderer = new CDotRenderer(); //dot m_processorList.push_back(dataToFloatProcessor); m_rendererList.push_back(dotRenderer); //marching cube m_processorList.push_back(new CMarchingCubeProcessor()); m_rendererList.push_back(new CMarchingCubeRenderer()); //raycast type1 m_processorList.push_back(dataToFloatProcessor); m_rendererList.push_back(new CRayCastRenderer(0)); dataToFloatProcessor->Grab(); //raycast type2 m_processorList.push_back(dataToFloatProcessor); m_rendererList.push_back(new CRayCastRenderer(1)); dataToFloatProcessor->Grab(); //CPU Depth //dot m_processorList.push_back(new CCpuDepthProcessor()); m_rendererList.push_back(new CCpuDepthRenderer()); //m_dataProcessor = new CMarchingCubeProcessor(); //m_dataRenderer = new CMarchingCubeRenderer(); //m_dataRenderer = new CRayCastRenderer(0); for(int i=0;i<(int)m_rendererList.size();i++) { m_rendererList[i]->SetCamera(m_cam); } return true; }
/// @brief Performs upkeep logic /// @param bPressed If true, there is a press void Widget::Upkeep (bool bPressed) { IssueEvent(ePreUpkeep); // Perform leave logic. Leave(); // If the widget is signaled, perform enter logic; on a press, perform grab logic. if (IsSignaled()) { Enter(); if (bPressed) Grab(); } // If there is no press, perform drop logic. if (!bPressed) Drop(); // If the widget remains chosen, post-process it; otherwise, abandon it. if (!IsSignaled() && !IsChosen()) { mState->ClearChoice(); IssueEvent(eAbandon); } else IssueEvent(ePostUpkeep); }
bool Gazetteer::ReadZips(const char *fname) { // safety checks if (!fname) return false; if (*fname == 0) return false; FILE *fp = vtFileOpen(fname, "rb"); if (!fp) return false; vtString str; char buf[999]; while (fgets(buf, 999, fp) != NULL) { Zip p; str = Grab(buf, 2, 5); if (str[4] == 'H' || str[4] == 'X') continue; p.m_zip = atoi(str); double x = atof(buf+146); double y = atof(buf+136); p.geo.Set(x, y); m_zips.push_back(p); } fclose(fp); return true; }
//-------------------------------------------------------------------------------- // @ MouseLook::Toggle() //-------------------------------------------------------------------------------- // Grab/Release toggle //-------------------------------------------------------------------------------- void MouseLook::Toggle(WindowManager* window) { if (state == 'r') Grab(window); else if (state == 'a' || state == 'i') Release(window); } //End: MouseLook::Toggle()
bool nuiWindow::MouseClicked (nuiSize X, nuiSize Y, nglMouseInfo::Flags Button) { // OUT("MouseClicked %d - %d\n",X,Y); if (Button == nglMouseInfo::ButtonLeft) { LocalToLocal(GetParent(), X,Y); mClickX = X; mClickY = Y; nuiRect _Rect = GetRect(); _Rect.Transform(GetMatrix()); nuiTheme* pTheme = GetTheme(); NGL_ASSERT(pTheme); mClickPos = pTheme->GetWindowPart(_Rect, X, Y, GetFlags(), false); pTheme->Release(); nuiRect wRect = GetRect(); nuiRect woriginal = wRect; switch (mClickPos) { case nuiCenter: if (mNoMove) { mMoving = eNoMove; return true; } break; case nuiTopLeft: case nuiBottomLeft: case nuiLeft: case nuiTopRight: case nuiBottomRight: case nuiRight: case nuiTop: case nuiBottom: if (mNoResize) mMoving = eNoMove; break; default: return true; break; } mMoving = ePreMove; SetAlpha(0.5f); Invalidate(); Grab(); return true; } return true; }
/// @brief Performs choose logic /// @param bPressed If true, there is a press void Widget::Choose (bool bPressed) { IssueEvent(ePreChoose); Enter(); if (bPressed) Grab(); IssueEvent(ePostChoose); }
bool KinectGrabber::GrabAndNotify() { if(can_grab_) { can_grab_ = Grab(); } if(can_grab_) { Notify(); } return can_grab_; }
bool nuiHyperLink::MouseClicked(nuiSize X, nuiSize Y, nglMouseInfo::Flags Button) { if (Button & nglMouseInfo::ButtonLeft) { mClicked++; Grab(); return true; } return false; }
/* -------------------------------------------------------------------------------------------- * Copy assignment operator. */ ManagerHnd & operator = (const ManagerHnd & o) { if (m_Hnd != o.m_Hnd) { Drop(); m_Hnd = o.m_Hnd; Grab(); } return *this; }
/* -------------------------------------------------------------------------------------------- * Copy assignment operator. */ DocumentRef & operator = (const DocumentRef & o) { if (m_Ptr != o.m_Ptr) { Drop(); m_Ptr = o.m_Ptr; m_Ref = o.m_Ref; Grab(); } return *this; }
//-------------------------------------------------------- void CDistortLayer::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent) { cocos2d::CCTouch* pTouch = (cocos2d::CCTouch*)pTouches->anyObject(); cocos2d::CCPoint touchLocation = pTouch->getLocation(); touchLocation = this->convertToNodeSpace(touchLocation); m_fMouseX = touchLocation.x; m_fMouseY = touchLocation.y; m_nGrab = Grab( touchLocation.x, touchLocation.y ); }
// virtual bool nuiPadGestureRecognizer::MouseClicked(nuiSize X, nuiSize Y, nglMouseInfo::Flags Button) { bool res = nuiGestureRecognizer::MouseClicked(X, Y, Button); mRecognizedDirection = nuiGestureDirectionNull; mClicked = true; mLastX = X; mLastY = Y; Grab(); return false; }
void nuiSlider::HookMouse() { mClicked = true; mThumbClicked = true; mInteractiveValueChanged = true; Grab(); Invalidate(); mClickValue = mRange.GetValue(); nglMouseInfo info; GetTopLevel()->GetMouseInfo(info); mClickX = info.X; mClickY = info.Y; GlobalToLocal(mClickX, mClickY); }
// virtual bool nuiSwipeGestureRecognizer::MouseClicked(nuiSize X, nuiSize Y, nglMouseInfo::Flags Button) { bool res = nuiGestureRecognizer::MouseClicked(X, Y, Button); mRecognizedDirection = nuiGestureDirectionNull; mClicked = true; mTime = nglTime(); mInitiatedTime = 0; mStartX = X; mStartY = Y; Grab(); return false; }
/// @brief Handles situation where the slider becomes the widget of choice /// @param fCursorX Cursor x coordinate, in [0,1] /// @param fCursorY Cursor y coordinate, in [0,1] /// @param bPressed If true, the cursor is pressed /// @param pContext [in-out] User-defined context parameter /// @note Tested void Slider::Choose (float fCursorX, float fCursorY, bool bPressed, void * pContext) { assert(mStatus[eUnder]); assert(!mStatus[eIn]); assert(!mStatus[eHeld]); assert(!mStatus[eThumbIn]); assert(!mStatus[eThumbHeld]); assert(!mStatus[eThumbCaught]); ////////////////////////////////////////////////////////////////////////////////////// // We enter the slider. If the thumb is under the cursor, we enter the thumb. We then // check for presses. ////////////////////////////////////////////////////////////////////////////////////// Enter(pContext); if (mStatus[eThumbUnder]) EnterThumb(pContext); if (bPressed) { /////////////////////////////////////////////////////////////////////////////// // If the thumb was under the cursor during a press, we grab the thumb; if the // thumb is draggable, we catch the thumb. /////////////////////////////////////////////////////////////////////////////// if (mStatus[eThumbUnder]) { GrabThumb(pContext); if (!mStatus[eThumbCannotDrag]) CatchThumb(fCursorX, fCursorY, pContext); } /////////////////////////////////////////////////////////////////////////////////// // Otherwise, we grab the slider. If the slider is snappable, we check what offset // the cursor coordinates fit. If this offset varies from the current offset, we // adjust it and emit a snap thumb event. /////////////////////////////////////////////////////////////////////////////////// else { Grab(pContext); if (!mStatus[eThumbCannotSnap]) { float fOffset = GetOffset(fCursorX, fCursorY, pContext); if (mOffset - fOffset != 0.0f) SnapThumb(fOffset, pContext); } } } }
// Received Mouse events: bool nuiKnob::MouseClicked(nuiSize X, nuiSize Y, nglMouseInfo::Flags Button) { mClickX = X; mClickY = Y; if ((Button & nglMouseInfo::ButtonLeft) && (Button & nglMouseInfo::ButtonDoubleClick)) { return false; } else if (Button & nglMouseInfo::ButtonLeft) { mClicked = true; Grab(); Invalidate(); mClickValue = mRange.GetValue(); return true; } else if (Button & nglMouseInfo::ButtonWheelUp) { if (IsKeyDown(mFineSensitivityKey)) { mRange.SetValue(mRange.GetValue() + mRange.GetIncrement() / mFineSensitivityRatio); } else { mRange.Increment(); } InteractiveValueChanged(); ActivateToolTip(this, true); return true; } else if (Button & nglMouseInfo::ButtonWheelDown) { if (IsKeyDown(mFineSensitivityKey)) { mRange.SetValue(mRange.GetValue() - mRange.GetIncrement() / mFineSensitivityRatio); } else { mRange.Decrement(); } InteractiveValueChanged(); ActivateToolTip(this, true); return true; } return false; }
// Received Mouse events: bool nuiToggleButton::MouseClicked (nuiSize X, nuiSize Y, nglMouseInfo::Flags Button) { if (IsDisabled()) return false; if (Button & nglMouseInfo::ButtonLeft) { mClicked = true; mWasPressed = IsPressed(); SetPressed(!mWasPressed); Grab(); Invalidate(); return true; } return false; }
void keyboard (unsigned char key, int x, int y) { if (key == ' ') { // stand still speed = 0.0; } else if (key == 'j') { if (pose != 6) { // for jump initialization MD2MSetLoop (yoshi, GL_FALSE); oldpose = pose; // save the current pose: stand or walk pose = 6; MD2MSetAnimation (yoshi, pose); } hit = Grab (point); cout << "hit: " << hit << endl; if (hit >= 0) { teapots[hit].status = 0; total_score += teapots[hit].score; } } }
void GrabBlock(){ MoveServo1_Degrees(0); debounce(1); OC2R = 0x115; debounce(1); MoveServo5_Degrees(5); MoveServo4_Degrees(65); debounce(10); MoveServo4_Degrees(50); debounce(10); MoveServo4_Degrees(5); debounce(50); Grab(); debounce(100); OC4R =0x2F6; debounce(50); MoveServo1_Degrees(90); MoveServo3_Degrees(45); OC2R = 0x115; MoveServo4_Degrees(45); MoveServo3_Degrees(0); MoveServo4_Degrees(0); debounce(200); OC5R =0x485; MoveServo4_Degrees(80); OC2R= 0x250; OC3R =0x250; MoveServo2_Degrees(140); debounce(200); MoveServo4_Degrees(90); LetGo(); debounce(200); OC4R =0x10E; debounce(100); SetTo90(); debounce(50); SetToInitial(); }
void Control::Select() { Highlight(true); Open(); Grab(); }
/* -------------------------------------------------------------------------------------------- * Handle constructor. */ ManagerHnd(Handle * hnd) : m_Hnd(hnd) { Grab(); }
bool nuiMatrixView::MouseClicked(nuiSize X, nuiSize Y, nglMouseInfo::Flags Button) { //*********************************************************** // // LEFT BUTTON // //*********************************************************** if (Button & nglMouseInfo::ButtonLeft) { uint col,row; // you did'nt clicked in a cell if (!GetCellCoord(X, Y, col, row)) { // it may be a "deselect all" action if (!IsKeyDown (mGrabMouseKey)) { DeselectAll(); Invalidate(); } return false; } // retrieve the targeted cell nuiWidget* pWidget = nuiGrid::GetCell(col, row); // if the cell is disabled, don't do anything if (!pWidget || !pWidget->IsEnabled()) { // it may be a "deselect all" action if (!IsKeyDown (mGrabMouseKey)) { DeselectAll(); Invalidate(); } return false; } // if the cell is not a matrixview item, don't do anything nuiMatrixViewItem* item = dynamic_cast<nuiMatrixViewItem*>(pWidget); if (!item) { // it may be a "deselect all" action if (!IsKeyDown (mGrabMouseKey)) { DeselectAll(); Invalidate(); } return false; } mClickedItem = item; // if the item is supposed to be hidden, make it silent if (!mClickedItem->IsVisible()) { // it may be a "deselect all" action if (!IsKeyDown (mGrabMouseKey)) { DeselectAll(); Invalidate(); } } // double click <=> rename the targeted cell (or the selected cells) if (Button & nglMouseInfo::ButtonDoubleClick) { bool res = MouseDoubleClicked(col, row); return res; } mClicked=true; Grab (); mClickPos[0] = X; mClickPos[1] = Y; // selection key is pressed if (IsKeyDown (mGrabMouseKey)) { bool res = Selected(col, row); Invalidate(); return res; } // is the targeted cell selected already? std::map<nuiMatrixViewItem*, bool>::iterator it = mSelectedItems.find(mClickedItem); // no ==> deselect all, select this single cell and prepare it to be modified if (it == mSelectedItems.end()) { DeselectAll(); Selected(col, row); mCanChange = true; } // yes => do nothing but preparing the cell to be modified else mCanChange = true; } //*********************************************************** // // WHEEL UP AND DOWN // //*********************************************************** if ((Button & nglMouseInfo::ButtonWheelUp) || (Button & nglMouseInfo::ButtonWheelDown)) { uint col,row; if (!GetCellCoord(X, Y, col, row)) return false; // retrieve the targeted cell nuiWidget* pWidget = nuiGrid::GetCell(col, row); // if the cell is disabled, don't do anything if (!pWidget || !pWidget->IsEnabled()) return false; // if the cell is not a matrixview item, don't do anything nuiMatrixViewItem* item = dynamic_cast<nuiMatrixViewItem*>(pWidget); if (!item) return false; // one single selected cell or more? uint nbSelectedCells = mSelectedItems.size(); if (nbSelectedCells <= 1) { DeselectAll(); Selected(col, row); } int32 delta; if (IsKeyDown(mFineSensitivityKey)) { if (Button & nglMouseInfo::ButtonWheelUp) delta = 1; else delta = -1; } else { if (Button & nglMouseInfo::ButtonWheelUp) delta = 5; else delta = -5; } double valueOfReference = item->GetValue(); valueOfReference += delta; // apply value modification on all selected items if (IsKeyDown(mRelativeKey)) { std::map<nuiMatrixViewItem*, bool>::iterator it; for (it = mSelectedItems.begin(); it != mSelectedItems.end(); ++it) { nuiMatrixViewItem* item = it->first; item->SetRelativeValue(delta); } } else { std::map<nuiMatrixViewItem*, bool>::iterator it; for (it = mSelectedItems.begin(); it != mSelectedItems.end(); ++it) { nuiMatrixViewItem* item = it->first; item->SetValue(valueOfReference); } } InteractiveValueChanged(); nglTimer::Start(false, true); } Invalidate(); return true; }
/* -------------------------------------------------------------------------------------------- * Copy constructor. */ ManagerHnd(const ManagerHnd & o) : m_Hnd(o.m_Hnd) { Grab(); }
bool nuiScrollView::MouseClicked(nuiSize X, nuiSize Y, nglMouseInfo::Flags Button) { bool res = false; bool autoHideScrollbars = true; bool v = IsKeyDown(NK_LSHIFT) || IsKeyDown(NK_RSHIFT); if (Button & nglMouseInfo::ButtonWheelUp) { if (v) { if (mpHorizontal && !mForceNoHorizontal) { mpHorizontal->GetRange().Decrement(); res = true; } else if (mpVertical && !mForceNoVertical) { mpVertical->GetRange().Decrement(); res = true; } } else { if (mpVertical && !mForceNoVertical) { mpVertical->GetRange().Decrement(); res = true; } else if (mpHorizontal && !mForceNoHorizontal && !mForceNoSmartScroll) { mpHorizontal->GetRange().Decrement(); res = true; } } } else if (Button & nglMouseInfo::ButtonWheelDown) { if (v) { if (mpHorizontal && !mForceNoHorizontal) { mpHorizontal->GetRange().Increment(); res = true; } else if (mpVertical && !mForceNoVertical) { mpVertical->GetRange().Increment(); res = true; } } else { if (mpVertical && !mForceNoVertical) { mpVertical->GetRange().Increment(); res = true; } else if (mpHorizontal && !mForceNoHorizontal && !mForceNoSmartScroll) { mpHorizontal->GetRange().Increment(); res = true; } } } else if (Button & nglMouseInfo::ButtonWheelLeft) { if (mpHorizontal && !mForceNoHorizontal) { mpHorizontal->GetRange().Decrement(); res = true; } } else if (Button & nglMouseInfo::ButtonWheelRight) { if (mpHorizontal && !mForceNoHorizontal) { mpHorizontal->GetRange().Increment(); res = true; } } else if (Button & nglMouseInfo::ButtonLeft && mDragEnabled) { Grab(); mLeftClick = true; mClickX = X; mClickY = Y; mLastX = X; mLastY = Y; mClickValueH = GetRange(nuiHorizontal)->GetValue(); mClickValueV = GetRange(nuiVertical)->GetValue(); if (mHideScrollBars) { ShowScrollBars(); } res = true; autoHideScrollbars = false; mLastTime = nglTime(); } if (res && mHideScrollBars) { ShowScrollBars(autoHideScrollbars); } return res; }
void Cubes (void) { if (Side == 0) { //Right of Botguy //keep offense in box until scorer gets into position //start with claw facing out ForwardTouch(); //until it hits luggage DOES BAR TOUCH SENSOR REGISTER LUGGAGE TOUCH? TurnCCW(); //turn left -- now facing airplanes CenterCamera(); //move forwards and center the camera on the blocks -- now facing airplanes and in front of blocks TurnCCW(); //turn left to face blocks with claw -- now in front of and facing blocks ForwardTouch(); //move forward until it hits blocks Grab(); //grab blocks /*create_drive_straight(100); sleep(2);//to avoid crashing with our luggage carts create_stop(); TurnCCW();*/ //OFFENSE SHOULD BE OUT OF STARTING BOX BY NOW //FORWARD BAR SENSOR SHOULD NOT BE OBSTRUCTED //CREATE SHOULD DRIVE BACKWARDS GotoBox(); create_drive_straight(200); sleep(1); create_stop(); TurnCW(); create_drive_straight(-300); sleep(1); create_stop(); TurnCW(); CenterCamera(); TurnCCW(); ForwardTouch(); Grab(); TurnCCW(); create_drive_straight(-500); sleep(2.2352); TurnCW(); GotoBox(); Release(); } if (Side == 1) //Left of Botguy. START WITH CREATE FACING OUT { ForwardTouch(); //Switch to distance TurnCW(); ForwardTouch(); create_drive_straight(50); sleep(1); create_stop(); TurnCW(); CenterCamera(); TurnCCW(); ForwardTouch(); Grab(); TurnCCW(); /*create_drive_straight(100); sleep(1); create_stop(); TurnCW();*/ while (get_create_lbump(.1) == 0 && get_create_rbump(.1) == 0) { create_drive_straight(200); //unless arm is strong enough to hold } ClearWall(); TurnCW(); ForwardTouch(); create_drive_straight(132); //one cube length (5 inches) + 5 mm safety sleep(1); create_stop(); create_drive_straight(-75); sleep(1); create_stop(); Release(); } }
bool nuiZoomBar::MouseClicked(nuiSize X, nuiSize Y, nglMouseInfo::Flags Button) { mClickX = X; mClickY = Y; if (Button & nglMouseInfo::ButtonLeft) { mClicked = true; Grab(); Invalidate(); mThumbClicked = false; mPageUpClicked = false; mPageDownClicked = false; if (mOrientation == nuiHorizontal) { if (X < mThumbRect.Left()) // PageUp { mTimer.Start(true,true); mPageUpClicked = true; } else if (X > mThumbRect.Right()) // PageDown { mTimer.Start(true,true); mPageDownClicked = true; } else if (X < mThumbRect.Left() + mThumbSideSize ) // Change Left { mClickValue = mpRange->GetValue(); mLeftSideClicked = true; } else if ( X > mThumbRect.Right() - mThumbSideSize) // Change Right { mClickValue = mpRange->GetValue(); mRightSideClicked = true; } else { mClickValue = mpRange->GetValue(); mThumbClicked = true; } } else { if (Y < mThumbRect.Top()) // PageUp { mTimer.Start(true,true); mPageUpClicked = true; } else if (Y > mThumbRect.Bottom()) // PageDown { mTimer.Start(true,true); mPageDownClicked = true; } else if (Y < mThumbRect.Top() + mThumbSideSize ) // Change Top { mClickValue = mpRange->GetValue(); mRightSideClicked = true; } else if ( Y > mThumbRect.Bottom() - mThumbSideSize) // Change Bottom { mClickValue = mpRange->GetValue(); mLeftSideClicked = true; } else { mClickValue = mpRange->GetValue(); mThumbClicked = true; ThumbPressed(); } } return true; } else if (Button & nglMouseInfo::ButtonWheelUp) { mpRange->Decrement(); return true; } else if (Button & nglMouseInfo::ButtonWheelDown) { mpRange->Increment(); return true; } return false; }
//--------------------------------------------------------------------------------- // Updates the Rubik's Cube, called once per frame. The general workhorse function // of the class. Handles Grabbing/Twisting, and calls the Draw() function. //--------------------------------------------------------------------------------- void RubiksCube::Update(bool moving, touchPosition touchXY, VECTOR touchVector, bool painting, int colour) { Painting=painting; paintColour=colour; if(!painting) { undoQueue.numEntries=0; undoQueue.currentEntry=-1; } // somehow stumbled onto a good way to handle Twisting using states // F**K TOP-DOWN PLANNING; PROTOTYPING FTW! if (moving && !Grabbing && !Twisting) { Picking=true; } if(!moving) { if(Twisting) { if(Twist.rotation%90>=45) Twist.direction=true; else Twist.direction=false; TwistAgain(); } Picking=false; Grabbing=false; Twisting=false; } if(AutoTwisting) TwistAgain(); if((!AutoTwisting) && Scrambling) { //printf("(!AutoTwisting) && Scrambling\n"); AutoTwist(rand()%3, rand()%3, !(!(rand()%2))); } if((!AutoTwisting) && Solving) { int tmp = solver.mov[0]-solvecount; AutoTwist(solution[tmp][0], solution[tmp][1], (!(!solution[tmp][2]))); } if(Twisting) { int32 touchVf32[3]; int32 twistVf32[3]; touchVf32[0]=floattof32(touchVector.X*twistSensitivity); touchVf32[1]=floattof32(touchVector.Y*twistSensitivity); touchVf32[2]=0; twistVf32[0]=Twist.vector[0]; twistVf32[1]=Twist.vector[1]; twistVf32[2]=0; int32 twistyness = dotf32(twistVf32, touchVf32); Twist.rotation+=f32toint(twistyness); if (Twist.rotation<0) Twist.rotation+=360; } //move the cube glRotateX(ry); glRotateY(rx); if(Grabbing) Grab(touchVector); Draw(touchXY); }
////// Private event management: bool nuiContainer::DispatchMouseClick(const nglMouseInfo& rInfo) { CheckValid(); nuiAutoRef; if (!mMouseEventEnabled || mTrashed) return false; bool hasgrab = HasGrab(rInfo.TouchId); if (IsDisabled() && !hasgrab) return false; nglMouseInfo info(rInfo); GlobalToLocal(info.X, info.Y); // Get a chance to preempt the mouse event before the children get it: if (PreMouseClicked(info)) { Grab(); return true; } if (IsInsideFromRoot(rInfo.X, rInfo.Y) || hasgrab) { if (!hasgrab) { IteratorPtr pIt; for (pIt = GetLastChild(false); pIt && pIt->IsValid(); GetPreviousChild(pIt)) { nuiWidgetPtr pItem = pIt->GetWidget(); if (pItem) { if (IsEnabled() && !HasGrab(rInfo.TouchId)) { if (pItem->DispatchMouseClick(rInfo)) { delete pIt; return true; } } } } delete pIt; } nglMouseInfo info(rInfo); GlobalToLocal(info.X, info.Y); if (PreClicked(info)) { Grab(); return true; } bool ret = MouseClicked(info); ret |= Clicked(info); ret = ret | (!mClickThru); if (ret) Grab(); return ret; } return false; }