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:
virtual void YourMarker
::updateLegend(QwtLegend *legend
) const {
QwtPolarMarker::updateLegend( legend );
dynamic_cast<QwtLegendItem *>( legend->find(this) );
if ( label )
{
label->setSymbol( symbol() );
label->setIdentifierMode(
}
}
virtual void YourMarker::updateLegend(QwtLegend *legend) const
{
QwtPolarMarker::updateLegend( legend );
QwtLegendItem *label =
dynamic_cast<QwtLegendItem *>( legend->find(this) );
if ( label )
{
label->setSymbol( symbol() );
label->setIdentifierMode(
QwtLegendItem::ShowSymbol | QwtLegendItem::ShowText );
}
}
To copy to clipboard, switch view to plain text mode
With Qwt 6.x + QwtPolar from SVN trunk you have to implement something like this:
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();
}
virtual void YourMarker::drawLegendIdentifier(
QPainter *painter, const QRectF &rect ) const
{
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();
}
To copy to clipboard, switch view to plain text mode
Uwe
Bookmarks