PDA

View Full Version : Draw line in PolarPlot



juancaa
21st October 2015, 04:05
Hi! Ive been trying to implement some code to draw a line from the origin to a given point in a polar plot but I couldnt do it, is there someone who can help me or give me some tips?

Thanks!

Uwe
21st October 2015, 06:46
IMO QwtPolarMarker should be extended to offer to draw a line to the origin - but for the moment you have to use QwtPolarCurve ( with 2 points ) for this.
Alternatively you could overload QwtPolarMarker::draw like this:


void YourPolarMarker::draw( QPainter *painter,
const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
const QPointF &pole, double radius,
const QRectF &canvasRect ) const
{
const double r = radialMap.transform( position().radius() );
const double a = azimuthMap.transform( position().azimuth() );

const QPointF pos = qwtPolar2Pos( pole, r, a );

painter->setPen( ... );
painter->drawLine( pole, pos );

QwtPolarMarker::draw( painter, ... );
}

Uwe