Ejemplo n.º 1
0
void CurveTracker::transition(const QEvent* event)
{
    QEvent::Type t = event->type();

    switch(event->type()) {
        case QEvent::MouseButtonPress:
        {
            const QMouseEvent *me =
                static_cast< const QMouseEvent * >( event );

            if(me->button() == Qt::RightButton)
                return;


            if(this->pickedPoints().count() > 0) {
                QPoint p = pickedPoints().at(0);
                int x1 = p.x();
                int x2 = me->pos().x();
                if(abs(x1 - x2) < 5)
                    QwtPlotPicker::transition(event);
            }



            break;
        }

        default: {
            QwtPlotPicker::transition(event);
        }
    }
}
Ejemplo n.º 2
0
void AdvPlotZoomer::drawRubberBand( QPainter *painter ) const
{
    if ( !isActive() || rubberBandPen().style() == Qt::NoPen )
        return;

    QwtPickerMachine::SelectionType selectionType =
        QwtPickerMachine::NoSelection;
    if ( stateMachine() )
        selectionType = stateMachine()->selectionType();

    if ( d_zoomConstrain == NoConstrain || rubberBand() != RectRubberBand ) {
        QwtPlotZoomer::drawRubberBand(painter);
        return;
    }
    const QRect &pRect = pickArea().boundingRect().toRect();
    const QPolygon &pa = pickedPoints();
    const int npa      = pa.count();

    switch ( d_zoomConstrain ) {
    case HZoomOnly:
        if ( npa >= 1 )
            QwtPainter::drawLine(painter, pa[0].x(), pRect.top(), pa[0].x(),
                pRect.bottom());
        if ( npa >= 2 )
            QwtPainter::drawLine(painter, pa[1].x(), pRect.top(), pa[1].x(),
                pRect.bottom());
        break;
    case VZoomOnly:
        if ( npa >= 1 )
            QwtPainter::drawLine(painter, pRect.left(), pa[0].y(),
                pRect.right(), pa[0].y());
        if ( npa >= 2 )
            QwtPainter::drawLine(painter, pRect.left(), pa[1].y(),
                pRect.right(), pa[1].y());
        break;
    default:
        // Nothing to be done here
        break;
    }
}