void motion(int x, int y) { switch(currentState) { case panning: updatePan(x,y); break; case zooming: updateZoom(x,y); break; } xlast=x; ylast=y; }
/*! \internal */ void QDeclarativeGeoMapGestureArea::panStateMachine() { PanState lastState = panState_; // Transitions switch (panState_) { case panInactive: if (canStartPan()) { // Update startCoord_ to ensure smooth start for panning when going over startDragDistance QGeoCoordinate newStartCoord = map_->screenPositionToCoordinate(QDoubleVector2D(lastPos_), false); startCoord_.setLongitude(newStartCoord.longitude()); startCoord_.setLatitude(newStartCoord.latitude()); panState_ = panActive; } break; case panActive: if (touchPoints_.count() == 0) { panState_ = panFlick; if (!tryStartFlick()) { panState_ = panInactive; // mark as inactive for use by camera if (pinchState_ == pinchInactive) emit movementStopped(); } } break; case panFlick: if (touchPoints_.count() > 0) { // re touched before movement ended endFlick(); panState_ = panActive; } break; } // Update switch (panState_) { case panInactive: // do nothing break; case panActive: updatePan(); // this ensures 'panStarted' occurs after the pan has actually started if (lastState != panActive) emit panStarted(); break; case panFlick: break; } }
/*! \internal */ void QDeclarativeGeoMapGestureArea::panStateMachine() { PanState lastState = panState_; // Transitions switch (panState_) { case panInactive: if (canStartPan()) panState_ = panActive; break; case panActive: if (touchPoints_.count() == 0) { panState_ = panFlick; if (!tryStartFlick()) { panState_ = panInactive; // mark as inactive for use by camera if (pinchState_ == pinchInactive) emit movementStopped(); } } break; case panFlick: if (touchPoints_.count() > 0) { // re touched before movement ended endFlick(); panState_ = panActive; } break; } // Update switch (panState_) { case panInactive: // do nothing break; case panActive: updatePan(); // this ensures 'panStarted' occurs after the pan has actually started if (lastState != panActive) emit panStarted(); break; case panFlick: break; } }
//-------------------------------------------------------------------------------------------------- /// The window coordinates are in OpenGL style coordinates, which means a right handed /// coordinate system with the origin in the lower left corner of the window. //-------------------------------------------------------------------------------------------------- bool LocatorPanWalkRotate::update(int x, int y) { CVF_ASSERT(m_camera.notNull()); if (x == m_lastPosX && y == m_lastPosY) return false; const double vpPixSizeX = m_camera->viewport()->width(); const double vpPixSizeY = m_camera->viewport()->height(); if (vpPixSizeX <= 0 || vpPixSizeY <= 0) return false; // Normalized movement in screen plane const double tx = (x - m_lastPosX)/vpPixSizeX; const double ty = (y - m_lastPosY)/vpPixSizeY; Vec3d oldPos = m_pos; if (m_operation == PAN) { updatePan(tx, ty); } else if (m_operation == WALK) { updateWalk(ty); } m_lastPosX = x; m_lastPosY = y; if (m_pos == oldPos) { return false; } else { return true; } }