当前位置: 首页>>代码示例>>C++>>正文


C++ QPoint::manhattanLength方法代码示例

本文整理汇总了C++中QPoint::manhattanLength方法的典型用法代码示例。如果您正苦于以下问题:C++ QPoint::manhattanLength方法的具体用法?C++ QPoint::manhattanLength怎么用?C++ QPoint::manhattanLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QPoint的用法示例。


在下文中一共展示了QPoint::manhattanLength方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: wheelEvent

void MapWidget::wheelEvent(QWheelEvent* event)
{

    QPoint numPixels = event->pixelDelta();
    QPoint numDegrees = event->angleDelta() / 8;
    int steps = 0;

   if (!numPixels.isNull()) {
        steps = numPixels.y()>0 ? numPixels.manhattanLength() : -numPixels.manhattanLength();

    } else if (!numDegrees.isNull()) {
        QPoint numSteps = numDegrees / 15;
        steps = numSteps.y()>0 ? numSteps.manhattanLength() : -numSteps.manhattanLength();
    }

    if(steps==0){
        return;
    }
    if (steps>=0) {
        zoomIn(std::max(1.01,0.2*steps));
    }
    else {
        zoomOut(std::max(1.01,0.2*steps));
    }

    event->accept();
}
开发者ID:camiloMS,项目名称:libosmscout,代码行数:27,代码来源:MapWidget.cpp

示例2: timerEvent

void SmoothImageMover::timerEvent(QTimerEvent * ev)
{
    if ( ev->timerId() == m_moveTimerId ) {
        int dt = m_timer.elapsed();
        m_velocity *= 0.8;
        m_timer.start();
        QPoint delta = (m_velocity*dt).toPoint();

        if ( !m_haveTargetPos && !m_allowedRect.contains(m_pos) ) { //get out of allowed area
            m_haveTargetPos = true;
            m_targetPos = m_pos;
            m_targetPos.setX( qBound( m_allowedRect.left(), m_pos.x(), m_allowedRect.right() ) );
            m_targetPos.setY( qBound( m_allowedRect.top(), m_pos.y(), m_allowedRect.bottom() ) );
        }

        if ( !m_allowedRect.contains(m_pos) ) {
            QPoint distance = m_targetPos - m_pos;
            if ( !distance.isNull() ) {
                QPointF gravitation = QPointF(distance)/distance.manhattanLength()/50;
                m_velocity += gravitation*dt;

                delta = (m_velocity * dt).toPoint();
                if ( delta.manhattanLength() > distance.manhattanLength() ) {
                    delta = distance/2;
                    m_velocity = QPointF(distance/2)/dt;
                }
            } else {
                delta = QPoint();
                m_velocity = QPointF();
            }
        }

        m_pos += delta;
        bool finished = false;

        if ( delta.manhattanLength() < 4 ) {
            if ( !m_haveTargetPos )
                finished = true;
            else {
                if ( (m_pos-m_targetPos).manhattanLength() < 16 ) {
                    m_pos = m_targetPos;
                    finished = true;
                }
            }
        }

        if ( finished ) {
            m_velocity = QPointF(0,0);
            killTimer(m_moveTimerId);
            m_moveTimerId = -1;
        }

        emit positionChanged( m_pos );
    }
}
开发者ID:Camelek,项目名称:qtmoko,代码行数:55,代码来源:smoothimagemover.cpp

示例3: handleMouseButtonRelease

bool RoutingLayerPrivate::handleMouseButtonRelease( QMouseEvent *e )
{
    if ( e->button() != Qt::LeftButton ) {
        return false;
    }

    if ( m_movingIndex >= 0 ) {
        m_movingIndex = -1;
        clearStopOver();
        m_marbleWidget->model()->routingManager()->retrieveRoute();
        return true;
    }

    if ( !m_dropStopOver.isNull() && !m_dragStopOver.isNull() ) {
        QPoint moved = e->pos() - m_dragStopOver;
        if ( moved.manhattanLength() < 10 ) {
            return false;
        }

        qreal lon( 0.0 ), lat( 0.0 );
        if ( m_dragStopOverRightIndex >= 0 && m_dragStopOverRightIndex <= m_routeRequest->size()
                && m_marbleWidget->geoCoordinates( m_dropStopOver.x(), m_dropStopOver.y(), lon, lat, GeoDataCoordinates::Radian ) ) {
            GeoDataCoordinates position( lon, lat );
            m_dragStopOverRightIndex = viaInsertPosition( e->modifiers() );
            m_routeRequest->insert( m_dragStopOverRightIndex, position );
            clearStopOver();
            m_marbleWidget->model()->routingManager()->retrieveRoute();
            return true;
        }
    }

    return false;
}
开发者ID:calincru,项目名称:marble,代码行数:33,代码来源:RoutingLayer.cpp

示例4: mouseMoveEvent

void MrmlViewItem::mouseMoveEvent( QMouseEvent *e )
{
    if ( hitsPixmap( e->pos() ) ) {
        if ( !ownCursor() ) { // nice hacklet :)
            setCursor( KCursor::handCursor() );
            emit view()->onItem( m_url );
        }
    }
    else {
        if ( ownCursor() ) {
            unsetCursor();
            emit view()->onItem( KURL() );
        }
    }

    if ( (e->state() & LeftButton) && !pressedPos.isNull() ) {
        QPoint dist = e->pos() - pressedPos;
        if ( dist.manhattanLength() > KGlobalSettings::dndEventDelay() ) {
            // start drag here
            KURL::List urls;
            // ### support multiple files?
            urls.append( m_url );
            KURLDrag *drag = new KURLDrag( urls, this );
            drag->setPixmap( KMimeType::pixmapForURL( m_url ) );
            drag->drag();
        }
    }
}
开发者ID:serghei,项目名称:kde3-kdegraphics,代码行数:28,代码来源:mrml_view.cpp

示例5: call

  KJS::Value Point::call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args ) {
    if( !JSProxy::checkType(self, JSProxy::ValueProxy, "QPoint") ) return KJS::Value();
    JSValueProxy *vp = JSProxy::toValueProxy( self.imp() );
    KJS::Value retValue = KJS::Value();
    QPoint val = vp->toVariant().toPoint();

    switch ( mid ) { 
      case Methodx:
	retValue = KJS::Number(val.x());
       break;
      case MethodsetX:
	val.setX(extractInt(exec,args,0));
	break;
      case  Methody:
	retValue = KJS::Number(val.y());
	break;
      case  MethodsetY:
	val.setY(extractInt(exec,args,0));
	break;
      case  MethodmanhattanLength:
	retValue = KJS::Number(val.manhattanLength());
	break;
      default:
	QString msg = i18n( "Point has no method %1" ).arg(mid);
  return throwError(exec, msg);
	break;
    }

    vp->setValue(val);
    return retValue;
  }
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:31,代码来源:point_imp.cpp

示例6: mouseMoveEvent

void ThemeContentItemSourceLabel::mouseMoveEvent( QMouseEvent * e )
{
  if ( e->buttons() & Qt::LeftButton )
  {
    QPoint diff = mMousePressPoint - e->pos();
    if ( diff.manhattanLength() > 4 )
      startDrag();
  }
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:9,代码来源:themeeditor.cpp

示例7: mouseReleaseEvent

void MrmlViewItem::mouseReleaseEvent( QMouseEvent *e )
{
    if ( hitsPixmap( e->pos() )) {
        QPoint dist = e->pos() - pressedPos;
        if ( dist.manhattanLength() < KGlobalSettings::dndEventDelay() ) {
            emit view()->activated( m_url, e->button() );
        }
    }
}
开发者ID:serghei,项目名称:kde3-kdegraphics,代码行数:9,代码来源:mrml_view.cpp

示例8: mouseMoveEvent

void AbstractScopeWidget::mouseMoveEvent(QMouseEvent *event)
{
    m_mousePos = event->pos();
    m_mouseWithinWidget = true;
    emit signalMousePositionChanged();

    QPoint movement = event->pos()-m_rescaleStartPoint;

    if (m_rescaleActive) {
        if (m_rescalePropertiesLocked) {
            // Direction is known, now adjust parameters

            // Reset the starting point to make the next moveEvent relative to the current one
            m_rescaleStartPoint = event->pos();


            if (!m_rescaleFirstRescaleDone) {
                // We have just learned the desired direction; Normalize the movement to one pixel
                // to avoid a jump by m_rescaleMinDist

                if (movement.x() != 0) {
                    movement.setX(movement.x() / abs(movement.x()));
                }
                if (movement.y() != 0) {
                    movement.setY(movement.y() / abs(movement.y()));
                }

                m_rescaleFirstRescaleDone = true;
            }

            handleMouseDrag(movement, m_rescaleDirection, m_rescaleModifiers);



        } else {
            // Detect the movement direction here.
            // This algorithm relies on the aspect ratio of dy/dx (size and signum).
            if (movement.manhattanLength() > m_rescaleMinDist) {
                float diff = ((float) movement.y())/movement.x();

                if (fabs(diff) > m_rescaleVerticalThreshold || movement.x() == 0) {
                    m_rescaleDirection = North;
                } else if (fabs(diff) < 1/m_rescaleVerticalThreshold) {
                    m_rescaleDirection = East;
                } else if (diff < 0) {
                    m_rescaleDirection = Northeast;
                } else {
                    m_rescaleDirection = Southeast;
                }
#ifdef DEBUG_ASW
                qDebug() << "Diff is " << diff << "; chose " << directions[m_rescaleDirection] << " as direction";
#endif
                m_rescalePropertiesLocked = true;
            }
        }
    }
}
开发者ID:JongHong,项目名称:kdenlive,代码行数:57,代码来源:abstractscopewidget.cpp

示例9: isBottomRight

bool Screen::isBottomRight(const Screen &screen) const
{
    QPoint distancePoint = m_geometry.topLeft() - screen.getGeometry().bottomRight();
    
    if (distancePoint.manhattanLength() < MaximumDistanceInBetween)
    {
        return true;
    }
    return false;
}
开发者ID:151706061,项目名称:starviewer,代码行数:10,代码来源:screen.cpp

示例10: mouseMoveEvent

void CMapWidget::mouseMoveEvent(QMouseEvent *event) {
	if (!m_map || !m_patches)
		return;

	event->accept();

	// Figure out the hovered position
	const QPoint &rawScreenPos = event->pos();
	CMapPoint newHover = calculateClickedPosition(rawScreenPos);

	// If it hasn't changed, do nothing!
	if (!(hovered == newHover)) {
		// Mark the old position as modified, if it was valid
		if (isHovering)
			updateTile(hovered, CEditableMap::HighlightUpdate);

		bool newFlag = m_map->positionValid(newHover);

		// before we clobber "hovered", call the tool's hoverstatus
		emit hoverStatusChanged(isHovering, hovered, newFlag, newHover, event);
		m_currentTool->hoverStatusChanged(isHovering, hovered, newFlag, newHover, event);

		// now update + write the new position's info
		isHovering = newFlag;
		hovered = newHover;

		if (newFlag)
			updateTile(newHover, CEditableMap::HighlightUpdate);
	}



	// Now, do drag processing!

	if (m_isDraggingMap && m_scrollArea) {
		// translate this position to the one clicked on-screen,
		// not the position in "world space" ... this is a bad explanation
		// oh well
		QPoint scrollOffset = QPoint(m_scrollArea->horizontalScrollBar()->value(), m_scrollArea->verticalScrollBar()->value());
		QPoint newPos = rawScreenPos - scrollOffset;

		// now that they're both on the same base, the delta is easy to figure
		// out
		QPoint delta = newPos - m_dragStart;
		delta *= 1.5f;
		m_roughDragDistance += delta.manhattanLength();

		QPoint newOffset = scrollOffset - delta;

		m_scrollArea->horizontalScrollBar()->setValue(newOffset.x());
		m_scrollArea->verticalScrollBar()->setValue(newOffset.y());

		m_dragStart = newPos;
	}
}
开发者ID:TravisNoles,项目名称:CMap,代码行数:55,代码来源:cmapwidget.cpp

示例11: mouseReleaseEvent

//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RiuViewer::mouseReleaseEvent(QMouseEvent* event)
{
    m_mouseState.updateFromMouseEvent(event);

    if (!this->canRender()) return;

    // Picking
    if (event->button() == Qt::LeftButton)
    {
        handlePickAction(event->x(), event->y());
        return;
    }
    else if (event->button() == Qt::RightButton)
    {
        m_currentGridIdx = cvf::UNDEFINED_SIZE_T;
        m_currentCellIndex = cvf::UNDEFINED_SIZE_T;

        QPoint diffPoint = event->pos() - m_lastMousePressPosition;
        if (diffPoint.manhattanLength() > 3)
        {
            // We are possibly in navigation mode, only clean press event will launch
            return;
        }

        int winPosX = event->x();
        int winPosY = event->y();

        uint faceIndex = cvf::UNDEFINED_UINT;
        cvf::Vec3d localIntersectionPoint(cvf::Vec3d::ZERO);

        cvf::Part * firstHitPart = NULL;
        firstHitPart = pickPointAndFace(winPosX, winPosY, &faceIndex, &localIntersectionPoint);
        if (firstHitPart)
        {
            if (faceIndex != cvf::UNDEFINED_UINT)
            {
                if (firstHitPart->sourceInfo())
                {
                    const cvf::Array<size_t>* cellIndices = dynamic_cast<const cvf::Array<size_t>*>(firstHitPart->sourceInfo());
                    if (cellIndices)
                    {
                        m_currentGridIdx = firstHitPart->id();
                        m_currentCellIndex = cellIndices->get(faceIndex);

                        QMenu menu;
                        menu.addAction(QString("I-slice range filter"), this, SLOT(slotRangeFilterI()));
                        menu.addAction(QString("J-slice range filter"), this, SLOT(slotRangeFilterJ()));
                        menu.addAction(QString("K-slice range filter"), this, SLOT(slotRangeFilterK()));
                        menu.exec(event->globalPos());
                    }
                }
            }
        }
    }
}
开发者ID:PETECLAM,项目名称:ResInsight,代码行数:58,代码来源:RiuViewer.cpp

示例12: switch

QGestureRecognizer::Result
QTapAndHoldGestureRecognizer::recognize(QGesture *state, QObject *object,
                                        QEvent *event)
{
    QTapAndHoldGesture *q = static_cast<QTapAndHoldGesture *>(state);
    QTapAndHoldGesturePrivate *d = q->d_func();

    if (object == state && event->type() == QEvent::Timer) {
        q->killTimer(d->timerId);
        d->timerId = 0;
        return QGestureRecognizer::Ignore | QGestureRecognizer::ConsumeEventHint;
    }

    const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);

    QGestureRecognizer::Result result = QGestureRecognizer::CancelGesture;

    enum { TimerInterval = 2000 };
    enum { TapRadius = 40 };

    switch (event->type()) {
    case QEvent::TouchBegin:
        d->position = ev->touchPoints().at(0).pos();
        if (d->timerId)
            q->killTimer(d->timerId);
        d->timerId = q->startTimer(TimerInterval);
        result = QGestureRecognizer::TriggerGesture;
        break;
    case QEvent::TouchEnd:
        if (d->timerId)
            result = QGestureRecognizer::CancelGesture;
        else
            result = QGestureRecognizer::FinishGesture;
        break;
    case QEvent::TouchUpdate:
        if (q->state() != Qt::NoGesture && ev->touchPoints().size() == 1) {
            QTouchEvent::TouchPoint p = ev->touchPoints().at(0);
            QPoint delta = p.pos().toPoint() - p.startPos().toPoint();
            if (delta.manhattanLength() <= TapRadius)
                result = QGestureRecognizer::TriggerGesture;
        }
        break;
    case QEvent::MouseButtonPress:
    case QEvent::MouseMove:
    case QEvent::MouseButtonRelease:
        result = QGestureRecognizer::Ignore;
        break;
    default:
        result = QGestureRecognizer::Ignore;
        break;
    }
    return result;
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:53,代码来源:qstandardgestures.cpp

示例13: switch

QGestureRecognizer::Result
WebosTapAndHoldGestureRecognizer::recognize(QGesture *state, QObject *object,
                                        QEvent *event)
{
    QGestureRecognizer::Result result = QGestureRecognizer::CancelGesture;
    WebosTapAndHoldGesture *q = static_cast<WebosTapAndHoldGesture *>(state);

    if (object == state && event->type() == QEvent::Timer) {
        q->stopTapTimer();
        if (q->state() != Qt::NoGesture && q->state() != Qt::GestureCanceled) {
            result = QGestureRecognizer::FinishGesture;
        }
        return result | QGestureRecognizer::ConsumeEventHint;
    }

    const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);

    //Todo Here use a const value to set up the timer interval but maybe need to use the Timeout value
    //enum { TimerInterval = 700 };
    enum { TapRadius = 40 };
    switch (event->type()) {
    case QEvent::TouchBegin:
        q->setPosition(ev->touchPoints().at(0).startScreenPos());
        q->setHotSpot(q->position());
        q->stopTapTimer();
        q->startTapTimer();
        return QGestureRecognizer::TriggerGesture;
    case QEvent::TouchEnd:
        result = QGestureRecognizer::CancelGesture;
        q->stopTapTimer();
        break;
    case QEvent::TouchUpdate:
        if (q->tapTimerId() && ev->touchPoints().size() == 1) {
            QTouchEvent::TouchPoint p = ev->touchPoints().at(0);
            QPoint delta = p.pos().toPoint() - p.startPos().toPoint();
            if (delta.manhattanLength() > TapRadius) {
                result = QGestureRecognizer::CancelGesture;
                q->stopTapTimer();
            } else {
                result = QGestureRecognizer::Ignore;
            }
        } else if (ev->touchPoints().size() > 1) {
            result = QGestureRecognizer::CancelGesture;
            q->stopTapTimer();
        } else {
            result = QGestureRecognizer::Ignore;
        }
        break;
    default:
        return QGestureRecognizer::Ignore;
    }
    return result;
}
开发者ID:ctbrowser,项目名称:luna-sysmgr,代码行数:53,代码来源:WebosTapAndHoldGestureRecognizer.cpp

示例14: mouseMoveEvent

void CSMonitorClient::mouseMoveEvent(QMouseEvent *event)
{
	if(m_bPressed)
	{
		QPoint movePos = event->globalPos() - m_movePoint;
		int distance = movePos.manhattanLength();
		bool bMoved =  distance > QApplication::startDragDistance() ? true : false;
		if(bMoved)
		{
			this->move(movePos);
		}
	}
}
开发者ID:ray-x,项目名称:SMonitor,代码行数:13,代码来源:CSMonitorClient.cpp

示例15: mouseReleaseEvent

void CQCustomInputHandler::mouseReleaseEvent(QMouseEvent * event, const QPoint & mousePos)
{
  mState = CQCustomInputHandler::StateNormal;

  if (event->button() == Qt::RightButton)
    {
      QPoint diff = mousePos - mPosDown;

      if (diff.manhattanLength() < 5)
        emit signalShowContextMenu(mousePos);
    }

  Q3DInputHandler::mouseReleaseEvent(event, mousePos);
}
开发者ID:copasi,项目名称:COPASI,代码行数:14,代码来源:CQ3DBarsModifier.cpp


注:本文中的QPoint::manhattanLength方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。