/*! Draw lines from the pole \param painter Painter \param canvasRect Contents rect of the canvas in painter coordinates \param pole Position of the pole in painter coordinates \param radius Length of the lines in painter coordinates \param azimuthMap Maps azimuth values to values related to 0.0, M_2PI \param values Azimuth values, indicating the direction of the lines */ void QwtPolarGrid::drawRays( QPainter *painter, const QwtDoubleRect &canvasRect, const QwtDoublePoint &pole, double radius, const QwtScaleMap &azimuthMap, const QwtValueList &values ) const { for ( int i = 0; i < int( values.size() ); i++ ) { double azimuth = azimuthMap.xTransform( values[i] ); azimuth = ::fmod( azimuth, 2 * M_PI ); bool skipLine = false; if ( testDisplayFlag( SmartScaleDraw ) ) { const QwtAbstractScaleDraw::ScaleComponent bone = QwtAbstractScaleDraw::Backbone; if ( isClose( azimuth, 0.0 ) ) { const AxisData &axis = d_data->axisData[QwtPolar::AxisRight]; if ( axis.isVisible && axis.scaleDraw->hasComponent( bone ) ) skipLine = true; } else if ( isClose( azimuth, M_PI / 2 ) ) { const AxisData &axis = d_data->axisData[QwtPolar::AxisTop]; if ( axis.isVisible && axis.scaleDraw->hasComponent( bone ) ) skipLine = true; } else if ( isClose( azimuth, M_PI ) ) { const AxisData &axis = d_data->axisData[QwtPolar::AxisLeft]; if ( axis.isVisible && axis.scaleDraw->hasComponent( bone ) ) skipLine = true; } else if ( isClose( azimuth, 3 * M_PI / 2.0 ) ) { const AxisData &axis = d_data->axisData[QwtPolar::AxisBottom]; if ( axis.isVisible && axis.scaleDraw->hasComponent( bone ) ) skipLine = true; } } if ( !skipLine ) { const QwtDoublePoint pos = qwtPolar2Pos( pole, radius, azimuth ); /* Qt4 is horrible slow, when painting primitives, with coordinates far outside the visible area. */ QwtPolygon pa( 2 ); pa.setPoint( 0, pole.toPoint() ); pa.setPoint( 1, pos.toPoint() ); if ( testDisplayFlag( ClipGridLines ) ) pa = QwtClipper::clipPolygon( canvasRect.toRect(), pa ); QwtPainter::drawPolyline( painter, pa ); } } }
/** * This overrides the base class trackerText() function so that we can * continuously emit a signal as the mouse is moved. * * @param pos The current mouse location. */ QwtText TrackingPicker::trackerText(const QwtDoublePoint &pos) const { emit mouseMoved(pos.toPoint()); if (m_hideReadout) { return QwtText(); } else // call super class trackerText { // so the tracker text still works return QwtPlotPicker::trackerText(pos); } }
/*! Update the axis scale draw geometries \param azimuthMap Maps azimuth values to values related to 0.0, M_2PI \param radialMap Maps radius values into painter coordinates. \param pole Position of the pole in painter coordinates \param radius Radius of the complete plot area in painter coordinates \sa updateScaleDiv() */ void QwtPolarGrid::updateScaleDraws( const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap, const QwtDoublePoint &pole, double radius ) const { const QPoint p = pole.toPoint(); const QwtDoubleInterval interval = d_data->gridData[QwtPolar::ScaleRadius].scaleDiv.interval(); const int min = radialMap.transform( interval.minValue() ); const int max = radialMap.transform( interval.maxValue() ); const int l = max - min; for ( int axisId = 0; axisId < QwtPolar::AxesCount; axisId++ ) { AxisData &axis = d_data->axisData[axisId]; if ( axisId == QwtPolar::AxisAzimuth ) { QwtRoundScaleDraw *scaleDraw = ( QwtRoundScaleDraw * )axis.scaleDraw; scaleDraw->setRadius( qRound( radius ) ); scaleDraw->moveCenter( p ); double from = ::fmod( 90.0 - azimuthMap.p1() * 180.0 / M_PI, 360.0 ); if ( from < 0.0 ) from += 360.0; scaleDraw->setAngleRange( from, from - 360.0 ); scaleDraw->setTransformation( azimuthMap.transformation()->copy() ); } else { QwtScaleDraw *scaleDraw = ( QwtScaleDraw * )axis.scaleDraw; switch ( axisId ) { case QwtPolar::AxisLeft: { scaleDraw->move( p.x() - min, p.y() ); scaleDraw->setLength( -l ); break; } case QwtPolar::AxisRight: { scaleDraw->move( p.x() + min, p.y() ); scaleDraw->setLength( l ); break; } case QwtPolar::AxisTop: { scaleDraw->move( p.x(), p.y() - max ); scaleDraw->setLength( l ); break; } case QwtPolar::AxisBottom: { scaleDraw->move( p.x(), p.y() + max ); scaleDraw->setLength( -l ); break; } } scaleDraw->setTransformation( radialMap.transformation()->copy() ); } } }