Drawing lines on qwtpolarplot
Hi,
I am having some difficulties drawing multiple lines on my polar plot. I can create multiple qwtpolarmarkers on the plot but when I create a line of type qwtpolarcurve and attach it to the polar plot, only the last curve will be displayed.
pseudo code to illustrate:
Code:
QwtPolarMarker * polarmarker = new QwtPolarMarker();
polarmarker->setPosition(......);
polarmarker->attach(polarPlot);
polarPlot->replot(); //1st marker is displayed
QwtPolarMarker * polarmarker2 = new QwtPolarMarker();
polarmarker2->setPosition(......);
polarmarker2->attach(polarPlot);
polarPlot->replot(); //2nd marker is displayed
QwtPolarCurve * curve = new QwtPolarCurve();
curve->setData(......);
curve->attach(polarPlot);
polarPlot->replot(); // 1st line is displayed
QwtPolarCurve * curve2 = new QwtPolarCurve();
curve2->setData(......);
curve2->attach(polarPlot);
polarPlot->replot(); // 2nd line is displayed, 1st line disappears
I stepped through the codes and I can see that the 1st curve is plotted before disappearing on the last replot call. Any ideas on what I might be missing?
Re: Drawing lines on qwtpolarplot
Pseudo code is o.k. and of course it is possible to have more than one curve: see the examples.
Uwe
Re: Drawing lines on qwtpolarplot
Hi Uwe,
I realized that by calling replot on the polar plot anywhere in my program will cause any drawn qwtpolarcurve to disappear as well.
Could it be the way I do setdata?
Heres the code i used to pass into setdata:
Code:
class PolarData: public QwtSeriesData<QwtPointPolar>
{
public:
PolarData (const double* x, const double* y, size_t size) :
d_x (x),
d_y (y),
d_size (size) {}
virtual QRectF boundingRect
() const { if (d_boundingRect.width() < 0) {
d_boundingRect = qwtBoundingRect (*this);
}
return d_boundingRect;
}
virtual size_t size() const {
return d_size;
}
virtual QwtPointPolar sample (size_t i) const {
return QwtPointPolar (d_x[int (i)], d_y[int (i)]);
}
private:
const double* d_x;
const double* d_y;
size_t d_size;
};
Re: Drawing lines on qwtpolarplot
Depends on what happens to the memory d_x, d_y are pointing to.
Uwe