QwtPolarMarker and QwtLegend
Hi,
I use a QwtPolarMarker but it does not appear in the legend. I have looked at the documentation but have found nothing about this. Try to use legend->insert but dont'know which widget I should pass to this method.
Any help would be welcome.
Thank you.
Re: QwtPolarMarker and QwtLegend
Code:
marker->setItemAttribute( QwtPolarItem::Legend, true );
Uwe
Re: QwtPolarMarker and QwtLegend
Thank you.
And note for myself, read completely the documentation...
So, I have the marker in the legend but the associated symbol is not displayed in the legend.
Probably an other option that I haven't read in the documentation or is ti normal ?
Thanks.
Re: QwtPolarMarker and QwtLegend
The default representation of a plot item on the legend is its title and QwtPolarMarker has no special implementation - probably it should have one.
With Qwt 5.x and QwtPolar 1.0 you have to implement something like this:
Code:
virtual void YourMarker
::updateLegend(QwtLegend *legend
) const {
QwtPolarMarker::updateLegend( legend );
dynamic_cast<QwtLegendItem *>( legend->find(this) );
if ( label )
{
label->setSymbol( symbol() );
label->setIdentifierMode(
}
}
With Qwt 6.x + QwtPolar from SVN trunk you have to implement something like this:
Code:
virtual void YourMarker::drawLegendIdentifier(
{
QSize symbolSize
= symbol
()->boundingSize
();
symbolSize
-= QSize( 2,
2 );
// scale the symbol size down if it doesn't fit into rect.
double xRatio = 1.0;
if ( rect.width() < symbolSize.width() )
xRatio = rect.width() / symbolSize.width();
double yRatio = 1.0;
if ( rect.height() < symbolSize.height() )
yRatio = rect.height() / symbolSize.height();
const double ratio = qMin( xRatio, yRatio );
painter->save();
painter->scale( ratio, ratio );
symbol()->drawSymbol( painter, rect.center() / ratio );
painter->restore();
}
Uwe
Re: QwtPolarMarker and QwtLegend
Hi,
That perfectly works !
Thank you.