PDA

View Full Version : Curve legend doesn't show a symbol entirely



AnnaP
2nd February 2011, 14:15
Hello all,

I faced with a problem that using QwtPlotCurve::LegendShowSymbol doesn't show a symbol (a circle in my case) in a legend entirely:
5860

Here is an example code:


class TestPlot: public QwtPlot
{

public:

TestPlot(QWidget * parent = NULL);

private:

QwtPlotCurve _curve;

};

TestPlot::TestPlot(QWidget * parent) : QwtPlot(parent)
{

QwtSymbol *sym = new QwtSymbol(QwtSymbol::Ellipse);
sym->setSize(5);
sym->setPen(QColor(Qt::blue));

_curve.setSymbol(sym);
_curve.setStyle(QwtPlotCurve::NoCurve);
_curve.setTitle(tr ("Curve"));
_curve.setLegendAttribute(QwtPlotCurve::LegendShow Symbol);
_curve.attach(this);

QVector <double> x;

for (unsigned i = 0; i < 10; ++i)
{
x.push_back(i);
}

_curve.setSamples(x, x);

QwtLegend *legend = new QwtLegend(this);
insertLegend(legend, QwtPlot::BottomLegend);
}


If I change a symbol size from 5 to 10 everything looks nice:
5861

Does anybody know why this can happen?
Thanks for any help!

Uwe
3rd February 2011, 06:57
I can't confirm this on my box.

What version of Qwt/Qt on which platform do you have. Does it still happen with Qwt from SVN trunk ?

Uwe

AnnaP
3rd February 2011, 08:28
Yes, it happens with the last Qwt version from SVN trunk.

I use Qt 4.7.0 and platform is Windows 7 Professional.

AnnaP
4th February 2011, 14:33
I've figured it out!

The problem is in using even/odd QwtSymbol sizes.
E.g. it is better to set an even size using a circle (QwtSymbol::Ellipse), and odd size using QwtSymbol::Star1.

Uwe
4th February 2011, 21:51
Ah o.k. but then the odd size of the ellipse should be also bad on the plot itself ?

Unfortunately I had to rewrite much of the symbol code for Qwt 6 because of the floating point based render engine ( + symbols can be cached in a pixmap, what is sometimes faster ). So I might have introduced bugs in this version.

Uwe

AnnaP
7th February 2011, 08:38
The ellipse with an odd side looks ok by itself. But if I put a circle with an odd size in a circe with an even size there is a problem that the inner circle looks asymmetrical:

5872


QwtSymbol *sym1 = new QwtSymbol(QwtSymbol::Ellipse);
sym1->setSize(14);
sym1->setPen(QColor(Qt::blue));

_curve1.setSymbol(sym1);
_curve1.setStyle(QwtPlotCurve::NoCurve);
_curve1.attach(this);

QwtSymbol *sym2 = new QwtSymbol(QwtSymbol::Ellipse, Qt::black, QColor(Qt::black), QSize(7, 7));

_curve2.setSymbol(sym2);
_curve2.setStyle(QwtPlotCurve::NoCurve);
_curve2.attach(this);

QVector <double> x;

for (unsigned i = 0; i < 10; ++i)
{
x.push_back(i);
}

_curve1.setSamples(x, x);
_curve2.setSamples(x, x);