PDA

View Full Version : How to draw a line anywhere on qwtpolar plot



vishaal_sss
23rd December 2014, 07:23
Hi,
I am very new to using qt and qwt/ qwtpolar and I admit that I am really poor at mathematics :). I want to draw a line anywhere on qwtpolar plot with the two points being: point1 (radius1, angle1) and point2 (radius2, angle2). I have seen the example for spiral data plot in which the samples for radii and angles are calculated as show below:


class Data: public QwtSeriesData<QwtPointPolar>
{
public:
Data( const QwtInterval &radialInterval,
const QwtInterval &azimuthInterval, size_t size ):
d_radialInterval( radialInterval ),
d_azimuthInterval( azimuthInterval ),
d_size( size )
{
}

virtual size_t size() const
{
return d_size;
}

protected:
QwtInterval d_radialInterval;
QwtInterval d_azimuthInterval;
size_t d_size;
};

class SpiralData: public Data
{
public:
SpiralData( const QwtInterval &radialInterval,
const QwtInterval &azimuthInterval, size_t size ):
Data( radialInterval, azimuthInterval, size )
{
}

virtual QwtPointPolar sample( size_t i ) const
{
const double stepA = 4 * d_azimuthInterval.width() / d_size;
const double a = d_azimuthInterval.minValue() + i * stepA;

const double stepR = d_radialInterval.width() / d_size;
const double r = d_radialInterval.minValue() + i * stepR;

return QwtPointPolar( a, r );
}

virtual QRectF boundingRect() const
{
if ( d_boundingRect.width() < 0.0 )
d_boundingRect = qwtBoundingRect( *this );

return d_boundingRect;
}
};

How can I implement the function "virtual QwtPointPolar sample( size_t i ) const" for finding the points ( QwtPointPolar( a, r )) of a straight line between two points on qwtpolar plot. Or if you can suggest for getting it done with QwtPlotMarker is also fine.
Please help.

vishal.