Exemple #1
0
    Zoomer(int xAxis, int yAxis, QWidget *canvas):
#else
    Zoomer(int xAxis, int yAxis, QwtPlotCanvas *canvas):
#endif
        QwtPlotZoomer(xAxis, yAxis, canvas)
    {
#if QWT_VERSION >= 0x060000
        setStateMachine(new QwtPickerDragRectMachine());
#else
        setSelectionFlags(QwtPicker::DragSelection | QwtPicker::CornerToCorner);
#endif
	//	setTrackerMode(QwtPlotZoomer::AlwaysOn);
	//        setTrackerMode(QwtPicker::AlwaysOff);
	//        setRubberBand(QwtPicker::NoRubberBand);
	QPen pen = rubberBandPen();
	pen.setColor(Qt::black);
	setRubberBandPen(pen);
	setTrackerPen(pen);
        // RightButton: zoom out by 1
        // Ctrl+RightButton: zoom out to full size

        setMousePattern(QwtEventPattern::MouseSelect2,
            Qt::RightButton, Qt::ControlModifier);
        setMousePattern(QwtEventPattern::MouseSelect3,
            Qt::RightButton);
    }
Exemple #2
0
int QwtPicker::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: activated((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 1: selected((*reinterpret_cast< const QPolygon(*)>(_a[1]))); break;
        case 2: appended((*reinterpret_cast< const QPoint(*)>(_a[1]))); break;
        case 3: moved((*reinterpret_cast< const QPoint(*)>(_a[1]))); break;
        case 4: removed((*reinterpret_cast< const QPoint(*)>(_a[1]))); break;
        case 5: changed((*reinterpret_cast< const QPolygon(*)>(_a[1]))); break;
        case 6: setEnabled((*reinterpret_cast< bool(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 7;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< bool*>(_v) = isEnabled(); break;
        case 1: *reinterpret_cast< ResizeMode*>(_v) = resizeMode(); break;
        case 2: *reinterpret_cast< DisplayMode*>(_v) = trackerMode(); break;
        case 3: *reinterpret_cast< QPen*>(_v) = trackerPen(); break;
        case 4: *reinterpret_cast< QFont*>(_v) = trackerFont(); break;
        case 5: *reinterpret_cast< RubberBand*>(_v) = rubberBand(); break;
        case 6: *reinterpret_cast< QPen*>(_v) = rubberBandPen(); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setEnabled(*reinterpret_cast< bool*>(_v)); break;
        case 1: setResizeMode(*reinterpret_cast< ResizeMode*>(_v)); break;
        case 2: setTrackerMode(*reinterpret_cast< DisplayMode*>(_v)); break;
        case 3: setTrackerPen(*reinterpret_cast< QPen*>(_v)); break;
        case 4: setTrackerFont(*reinterpret_cast< QFont*>(_v)); break;
        case 5: setRubberBand(*reinterpret_cast< RubberBand*>(_v)); break;
        case 6: setRubberBandPen(*reinterpret_cast< QPen*>(_v)); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 7;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Exemple #3
0
void QwtPicker::updateDisplay()
{
    QWidget *w = parentWidget();

    bool showRubberband = false;
    bool showTracker = false;
    if ( w && w->isVisible() && d_data->enabled )
    {
        if ( rubberBand() != NoRubberBand && isActive() &&
            rubberBandPen().style() != Qt::NoPen )
        {
            showRubberband = true;
        }

        if ( trackerMode() == AlwaysOn ||
            (trackerMode() == ActiveOnly && isActive() ) )
        {
            if ( trackerPen() != Qt::NoPen )
                showTracker = true;
        }
    }

#if QT_VERSION < 0x040000
    QGuardedPtr<PrivateData::PickerWidget> &rw = d_data->rubberBandWidget;
#else
    QPointer<PrivateData::PickerWidget> &rw = d_data->rubberBandWidget;
#endif
    if ( showRubberband )
    {
        if ( rw.isNull() )
        {
            rw = new PrivateData::PickerWidget(
                this, w, PrivateData::PickerWidget::RubberBand);
            rw->resize(w->size());
        }
        rw->updateMask();
    }
    else
        delete rw;

#if QT_VERSION < 0x040000
    QGuardedPtr<PrivateData::PickerWidget> &tw = d_data->textLabelWidget;
#else
    QPointer<PrivateData::PickerWidget> &tw = d_data->textLabelWidget;
#endif
    if ( showTracker )
    {
        if ( tw.isNull() )
        {
            tw = new PrivateData::PickerWidget(
                this, w, PrivateData::PickerWidget::Text);
            tw->resize(w->size());
        }
        tw->updateMask();
    }
    else
        delete tw;
}
int QwtPicker::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 4)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 4;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< int*>(_v) = selectionFlags(); break;
        case 1: *reinterpret_cast< DisplayMode*>(_v) = trackerMode(); break;
        case 2: *reinterpret_cast< QFont*>(_v) = trackerFont(); break;
        case 3: *reinterpret_cast< RubberBand*>(_v) = rubberBand(); break;
        case 4: *reinterpret_cast< ResizeMode*>(_v) = resizeMode(); break;
        case 5: *reinterpret_cast< bool*>(_v) = isEnabled(); break;
        case 6: *reinterpret_cast< QPen*>(_v) = trackerPen(); break;
        case 7: *reinterpret_cast< QPen*>(_v) = rubberBandPen(); break;
        }
        _id -= 8;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setSelectionFlags(*reinterpret_cast< int*>(_v)); break;
        case 1: setTrackerMode(*reinterpret_cast< DisplayMode*>(_v)); break;
        case 2: setTrackerFont(*reinterpret_cast< QFont*>(_v)); break;
        case 3: setRubberBand(*reinterpret_cast< RubberBand*>(_v)); break;
        case 4: setResizeMode(*reinterpret_cast< ResizeMode*>(_v)); break;
        case 5: setEnabled(*reinterpret_cast< bool*>(_v)); break;
        case 6: setTrackerPen(*reinterpret_cast< QPen*>(_v)); break;
        case 7: setRubberBandPen(*reinterpret_cast< QPen*>(_v)); break;
        }
        _id -= 8;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 8;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Exemple #5
0
//! Update the state of rubberband and tracker label
void QwtPicker::updateDisplay()
{
    QWidget *w = parentWidget();

    bool showRubberband = false;
    bool showTracker = false;
    if ( w && w->isVisible() && d_data->enabled )
    {
        if ( rubberBand() != NoRubberBand && isActive() &&
            rubberBandPen().style() != Qt::NoPen )
        {
            showRubberband = true;
        }

        if ( trackerMode() == AlwaysOn ||
            ( trackerMode() == ActiveOnly && isActive() ) )
        {
            if ( trackerPen() != Qt::NoPen )
                showTracker = true;
        }
    }

    QPointer<PickerWidget> &rw = d_data->rubberBandWidget;
    if ( showRubberband )
    {
        if ( rw.isNull() )
        {
            rw = new PickerWidget( this, w, PickerWidget::RubberBand );
            rw->setObjectName( "PickerRubberBand" );
            rw->resize( w->size() );
        }
        rw->updateMask();
        rw->update(); // Needed, when the mask doesn't change
    }
    else
        delete rw;

    QPointer<PickerWidget> &tw = d_data->trackerWidget;
    if ( showTracker )
    {
        if ( tw.isNull() )
        {
            tw = new PickerWidget( this, w, PickerWidget::Text );
            tw->setObjectName( "PickerTracker" );
            tw->resize( w->size() );
        }
        tw->setFont( d_data->trackerFont );
        tw->updateMask();
        tw->update(); // Needed, when the mask doesn't change
    }
    else
        delete tw;
}
    OrdinationSelection(QwtPlotCanvas *canvas, SamplesPtr samples)
			:QwtPlotPicker(canvas), m_canvas(canvas), m_samples(samples), m_bAddToSelection(false)
    {
		m_stateMachine = new OrdinationSelectionMachine();
		setStateMachine(m_stateMachine);
		setTrackerMode(QwtPicker::AlwaysOn);
		setRubberBand(QwtPicker::RectRubberBand);

		QPen rubberBandPen(QPen(QColor(150, 190, 240)));
		rubberBandPen.setStyle(Qt::DashLine);
		rubberBandPen.setWidth(2);
		setRubberBandPen(rubberBandPen);

		setEnabled(true);

		QObject::connect(this, SIGNAL(selected(const QRectF&)), this, SLOT(ProcessRect(const QRectF&)));
    }
Exemple #7
0
    virtual QwtText trackerTextF( const QPointF &pos ) const
    {
        const QDateTime dt = QwtDate::toDateTime( pos.x() );

        QString s;
        s += QwtDate::toString( QwtDate::toDateTime( pos.x() ),
            "MMM dd hh:mm ", QwtDate::FirstThursday );

        QwtText text( s );
        text.setColor( Qt::white );

        QColor c = rubberBandPen().color();
        text.setBorderPen( QPen( c ) );
        text.setBorderRadius( 6 );
        c.setAlpha( 170 );
        text.setBackgroundBrush( c );

        return text;
    }
Exemple #8
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;
    }
}
void QwtCustomPlotZoomer::drawRubberBand(QPainter* painter) const
{
	if ( rubberBand() < UserRubberBand )
		QwtPlotPicker::drawRubberBand( painter );
	else
	{
		if ( !isActive() || rubberBandPen().style() == Qt::NoPen )
			return;

		QPolygon p = selection();

		if ( p.count() < 2 )
			return;

		const QPoint& pt1 = p[0];
		const QPoint& pt2 = p[1];

		const int end = canvas()->size().height();
		painter->drawLine(pt1.x(), 0, pt1.x(), end);
		painter->drawLine(pt2.x(), 0, pt2.x(), end);
		painter->fillRect(QRect(pt1.x(), 0, pt2.x() - pt1.x(), end), QBrush(QColor("black"), Qt::Dense7Pattern));
	}
}
Exemple #10
0
void QwtPicker::drawRubberBand(QPainter *painter) const
{
    if ( !isActive() || rubberBand() == NoRubberBand || 
        rubberBandPen().style() == Qt::NoPen )
    {
        return;
    }

    const QRect &pRect = pickRect();
    const SelectedPoints &pa = d_data->selection;

    if ( selectionFlags() & PointSelection )
    {
        if ( pa.count() < 1 )
            return;

        const QPoint pos = pa[0];

        switch(rubberBand())
        {
            case VLineRubberBand:
                QwtPainter::drawLine(painter, pos.x(),
                    pRect.top(), pos.x(), pRect.bottom());
                break;

            case HLineRubberBand:
                QwtPainter::drawLine(painter, pRect.left(), 
                    pos.y(), pRect.right(), pos.y());
                break;

            case CrossRubberBand:
                QwtPainter::drawLine(painter, pos.x(),
                    pRect.top(), pos.x(), pRect.bottom());
                QwtPainter::drawLine(painter, pRect.left(), 
                    pos.y(), pRect.right(), pos.y());
                break;
            default:
                break;
        }
    }

    else if ( selectionFlags() & RectSelection )
    {
        if ( pa.count() < 2 )
            return;

        QPoint p1 = pa[0];
        QPoint p2 = pa[int(pa.count() - 1)];

        if ( selectionFlags() & CenterToCorner )
        {
            p1.setX(p1.x() - (p2.x() - p1.x()));
            p1.setY(p1.y() - (p2.y() - p1.y()));
        }
        else if ( selectionFlags() & CenterToRadius )
        {
            const int radius = qwtMax(qwtAbs(p2.x() - p1.x()), 
                qwtAbs(p2.y() - p1.y()));
            p2.setX(p1.x() + radius);
            p2.setY(p1.y() + radius);
            p1.setX(p1.x() - radius);
            p1.setY(p1.y() - radius);
        }

#if QT_VERSION < 0x040000
        const QRect rect = QRect(p1, p2).normalize();
#else
        const QRect rect = QRect(p1, p2).normalized();
#endif
        switch(rubberBand())
        {
            case EllipseRubberBand:
                QwtPainter::drawEllipse(painter, rect);
                break;
            case RectRubberBand:
                QwtPainter::drawRect(painter, rect);
                break;
            default:
                break;
        }
    }
    else if ( selectionFlags() & PolygonSelection )
    {
        if ( rubberBand() == PolygonRubberBand )
            painter->drawPolyline(pa);
    }
}
Exemple #11
0
void QwtPicker::drawRubberBand( QPainter *painter ) const
{
    if ( !isActive() || rubberBand() == NoRubberBand ||
        rubberBandPen().style() == Qt::NoPen )
    {
        return;
    }

    const QPolygon pa = adjustedPoints( d_data->pickedPoints );

    QwtPickerMachine::SelectionType selectionType =
        QwtPickerMachine::NoSelection;

    if ( d_data->stateMachine )
        selectionType = d_data->stateMachine->selectionType();

    switch ( selectionType )
    {
        case QwtPickerMachine::NoSelection:
        case QwtPickerMachine::PointSelection:
        {
            if ( pa.count() < 1 )
                return;

            const QPoint pos = pa[0];

            const QRect pRect = pickArea().boundingRect().toRect();
            switch ( rubberBand() )
            {
                case VLineRubberBand:
                {
                    QwtPainter::drawLine( painter, pos.x(),
                        pRect.top(), pos.x(), pRect.bottom() );
                    break;
                }
                case HLineRubberBand:
                {
                    QwtPainter::drawLine( painter, pRect.left(),
                        pos.y(), pRect.right(), pos.y() );
                    break;
                }
                case CrossRubberBand:
                {
                    QwtPainter::drawLine( painter, pos.x(),
                        pRect.top(), pos.x(), pRect.bottom() );
                    QwtPainter::drawLine( painter, pRect.left(),
                        pos.y(), pRect.right(), pos.y() );
                    break;
                }
                default:
                    break;
            }
            break;
        }
        case QwtPickerMachine::RectSelection:
        {
            if ( pa.count() < 2 )
                return;

            const QRect rect = QRect( pa.first(), pa.last() ).normalized();
            switch ( rubberBand() )
            {
                case EllipseRubberBand:
                {
                    QwtPainter::drawEllipse( painter, rect );
                    break;
                }
                case RectRubberBand:
                {
                    QwtPainter::drawRect( painter, rect );
                    break;
                }
                default:
                    break;
            }
            break;
        }
        case QwtPickerMachine::PolygonSelection:
        {
            if ( rubberBand() == PolygonRubberBand )
                painter->drawPolyline( pa );
            break;
        }
        default:
            break;
    }
}
Exemple #12
0
/*!
  Calculate the mask for the rubber band overlay

  \return Region for the mask
  \sa QWidget::setMask()
 */
QRegion QwtPicker::rubberBandMask() const
{
    QRegion mask;

    if ( !isActive() || rubberBand() == NoRubberBand ||
        rubberBandPen().style() == Qt::NoPen )
    {
        return mask;
    }

    const QPolygon pa = adjustedPoints( d_data->pickedPoints );

    QwtPickerMachine::SelectionType selectionType =
        QwtPickerMachine::NoSelection;

    if ( d_data->stateMachine )
        selectionType = d_data->stateMachine->selectionType();

    switch ( selectionType )
    {
        case QwtPickerMachine::NoSelection:
        case QwtPickerMachine::PointSelection:
        {
            if ( pa.count() < 1 )
                return mask;

            const QPoint pos = pa[0];
            const int pw = rubberBandPen().width();

            const QRect pRect = pickArea().boundingRect().toRect();
            switch ( rubberBand() )
            {
                case VLineRubberBand:
                {
                    mask += qwtMaskRegion( QLine( pos.x(), pRect.top(),
                        pos.x(), pRect.bottom() ), pw );
                    break;
                }
                case HLineRubberBand:
                {
                    mask += qwtMaskRegion( QLine( pRect.left(), pos.y(),
                        pRect.right(), pos.y() ), pw );
                    break;
                }
                case CrossRubberBand:
                {
                    mask += qwtMaskRegion( QLine( pos.x(), pRect.top(),
                        pos.x(), pRect.bottom() ), pw );
                    mask += qwtMaskRegion( QLine( pRect.left(), pos.y(),
                        pRect.right(), pos.y() ), pw );
                    break;
                }
                default:
                    break;
            }
            break;
        }
        case QwtPickerMachine::RectSelection:
        {
            if ( pa.count() < 2 )
                return mask;

            const int pw = rubberBandPen().width();

            switch ( rubberBand() )
            {
                case RectRubberBand:
                {
                    const QRect r = QRect( pa.first(), pa.last() );
                    mask = qwtMaskRegion( r.normalized(), pw );
                    break;
                }
                case EllipseRubberBand:
                {
                    const QRect r = QRect( pa.first(), pa.last() );
                    mask += r.adjusted( -pw, -pw, pw, pw );
                    break;
                }
                default:
                    break;
            }
            break;
        }
        case QwtPickerMachine::PolygonSelection:
        {
            const int pw = rubberBandPen().width();
            if ( pw <= 1 )
            {
                // because of the join style we better
                // return a mask for a pen width <= 1 only

                const int off = 2 * pw;
                const QRect r = pa.boundingRect();
                mask += r.adjusted( -off, -off, off, off );
            }
            break;
        }
        default:
            break;
    }

    return mask;
}
Exemple #13
0
//! Update the state of rubber band and tracker label
void QwtPicker::updateDisplay()
{
    QWidget *w = parentWidget();

    bool showRubberband = false;
    bool showTracker = false;

    if ( w && w->isVisible() && d_data->enabled )
    {
        if ( rubberBand() != NoRubberBand && isActive() &&
            rubberBandPen().style() != Qt::NoPen )
        {
            showRubberband = true;
        }

        if ( trackerMode() == AlwaysOn ||
            ( trackerMode() == ActiveOnly && isActive() ) )
        {
            if ( trackerPen() != Qt::NoPen
                && !trackerRect( QFont() ).isEmpty() )
            {
                showTracker = true;
            }
        }
    }

    QPointer< QwtPickerRubberband > &rw = d_data->rubberBandOverlay;
    if ( showRubberband )
    {
        if ( rw.isNull() )
        {
            rw = new QwtPickerRubberband( this, NULL ); // NULL -> no extra event filter
            rw->setObjectName( "PickerRubberBand" );
            rw->setParent( w );
            rw->resize( w->size() );
        }

        if ( d_data->rubberBand <= RectRubberBand )
            rw->setMaskMode( QwtWidgetOverlay::MaskHint );
        else
            rw->setMaskMode( QwtWidgetOverlay::AlphaMask );

        rw->updateOverlay();
    }
    else
    {
        if ( d_data->openGL )
        {
            // Qt 4.8 crashes for a delete
            if ( !rw.isNull() )
            {
                rw->hide();
                rw->deleteLater();
                rw = NULL;
            }
        }
        else
        {
            delete rw;
        }
    }

    QPointer< QwtPickerTracker > &tw = d_data->trackerOverlay;
    if ( showTracker )
    {
        if ( tw.isNull() )
        {
            tw = new QwtPickerTracker( this, NULL ); // NULL -> no extra event filter
            tw->setObjectName( "PickerTracker" );
            tw->setParent( w );
            tw->resize( w->size() );
        }
        tw->setFont( d_data->trackerFont );
        tw->updateOverlay();
    }
    else
    {
        if ( d_data->openGL )
        {
            // Qt 4.8 crashes for a delete
            if ( !tw.isNull() )
            {
                tw->hide();
                tw->deleteLater();
                tw = NULL;
            }
        }
        else
        {
            delete tw;
        }
    }
}
void QwtCustomPlotPicker::drawRubberBand(QPainter* painter) const
{
	if ( rubberBand() < UserRubberBand )
		QwtPlotPicker::drawRubberBand( painter );
	else
	{
		if ( !isActive() || rubberBandPen().style() == Qt::NoPen )
			return;

		QPolygon p = selection();

		if ( p.count() != 1 )
			return;

		const QPoint& pt1 = p[0];
		const double x_val = plot()->invTransform(QwtPlot::xBottom,pt1.x()); // determine x value (time or dist)
		
		// Draw vertical line where curser is
		const int bot = 400;
		const int top = 0;
		painter->drawLine(pt1.x(), bot, pt1.x(), top); 

		// Set pen and fond for all coming text
		painter->setPen(QColor(Qt::black));
		painter->setFont(QFont("Helvetica", 8, QFont::Bold));
		
		// Compute the index based on the x value
		int idx;
		if (_x_axis_units == TimeAxis)
		{
			painter->drawText(QPoint(pt1.x()-65, 10), "time: " + DataProcessing::minsFromSecs(x_val));
			idx = _data_log->indexFromTime(x_val);
		}
		else if (_x_axis_units == DistAxis)
		{
			painter->drawText(QPoint(pt1.x()-60, 10), "dist: " + DataProcessing::kmFromMeters(x_val,2));
			idx = _data_log->indexFromDist(x_val);
		}
		
		// Using the index, determine the curve values
		const double hr = (int)_data_log->heartRateFltd(idx);
		const QPoint pt1_hr(pt1.x(),plot()->transform(QwtPlot::yLeft,hr));
		const double speed = _data_log->speedFltd(idx);
		const QPoint pt1_speed(pt1.x(),plot()->transform(QwtPlot::yLeft,speed));
		const double alt = (int)_data_log->altFltd(idx);
		const QPoint pt1_alt(pt1.x(),plot()->transform(QwtPlot::yRight,alt));
		const double cadence = (int)_data_log->cadenceFltd(idx);
		const QPoint pt1_cadence(pt1.x(),plot()->transform(QwtPlot::yLeft,cadence));
		const double power = _data_log->powerFltd(idx);
		const QPoint pt1_power(pt1.x(),plot()->transform(QwtPlot::yLeft,power));
		const double temp = _data_log->temp(idx);
		const QPoint pt1_temp(pt1.x(),plot()->transform(QwtPlot::yLeft,temp));

		// Draw highlights on all curves
		const QPoint offset(8,-5);
		const QwtPlotItemList item_list = plot()->itemList(QwtPlotCurve::Rtti_PlotCurve);
		for (int i = 0; i < item_list.size(); ++i) 
		{
			if (item_list.at(i)->title().text() == "Heart Rate" && item_list.at(i)->isVisible())
			{
				painter->drawLine(pt1_hr.x(), pt1_hr.y(), pt1_hr.x()+6, pt1_hr.y());
				painter->drawText(pt1_hr + offset, QString::number(hr,'g',3));
			}
			if (item_list.at(i)->title().text() == "Speed" && item_list.at(i)->isVisible())
			{
				painter->drawLine(pt1_speed.x(), pt1_speed.y(), pt1_speed.x()+6, pt1_speed.y());
				painter->drawText(pt1_speed + offset, QString::number(speed,'g',3));
			}
			if (item_list.at(i)->title().text() == "Elevation" && item_list.at(i)->isVisible())
			{
				painter->drawLine(pt1_alt.x(), pt1_alt.y(), pt1_alt.x()+6, pt1_alt.y());
				painter->drawText(pt1_alt + offset, QString::number(alt,'g',4));
			}
			if (item_list.at(i)->title().text() == "Cadence" && item_list.at(i)->isVisible())
			{
				painter->drawLine(pt1_cadence.x(), pt1_cadence.y(), pt1_cadence.x()+6, pt1_cadence.y());
				painter->drawText(pt1_cadence + offset, QString::number(cadence,'g',3));
			}
			if (item_list.at(i)->title().text() == "Power" && item_list.at(i)->isVisible())
			{
				painter->drawLine(pt1_power.x(), pt1_power.y(), pt1_power.x()+6, pt1_power.y());
				painter->drawText(pt1_power + offset, QString::number(power,'g',3));
			}
			if (item_list.at(i)->title().text() == "Temp" && item_list.at(i)->isVisible())
			{
				painter->drawLine(pt1_temp.x(), pt1_temp.y(), pt1_temp.x()+6, pt1_temp.y());
				painter->drawText(pt1_temp + offset, QString::number(temp,'g',3));
			}

			// Draw current values on graph labels
			if (_hr_cb->isChecked())
				_hr_cb->setText("Heart Rate " + QString::number(hr,'g',3).leftJustified(3,' ') + " bpm");
			else
				_hr_cb->setText("Heart Rate");
			if (_speed_cb->isChecked())
				_speed_cb->setText("Speed " + QString::number(speed,'g',3) + " km/h");
			else
				_speed_cb->setText("Speed");
			if (_alt_cb->isChecked())
				_alt_cb->setText("Elevation " + QString::number(alt,'g',4).leftJustified(4,' ') + " m");
			else
				_alt_cb->setText("Elevation");
			if (_cadence_cb->isChecked())
				_cadence_cb->setText("Cadence " + QString::number(cadence,'g',3) + " rpm");
			else
				_cadence_cb->setText("Cadence");
			if (_power_cb->isChecked())
				_power_cb->setText("Power " + QString::number(power,'g',3) + " W");
			else
				_power_cb->setText("Power");
			if (_temp_cb->isChecked())
				_temp_cb->setText("Temp " + QString::number(temp,'g',3) + " C");
			else
				_temp_cb->setText("Temp");
		}
	}
}