/*! Print the legend item into a given rectangle. \param painter Painter \param widget Widget representing a legend item \param rect Bounding rectangle \note When widget is not derived from QwtLegendItem renderLegendItem does nothing and needs to be overloaded */ void QwtPolarRenderer::renderLegendItem( QPainter *painter, const QWidget *widget, const QRectF &rect ) const { const QwtLegendItem *item = qobject_cast<const QwtLegendItem *>( widget ); if ( item ) { const QSize sz = item->identifierSize(); const QRectF identifierRect( rect.x() + item->margin(), rect.center().y() - 0.5 * sz.height(), sz.width(), sz.height() ); QwtLegendItemManager *itemManger = d_data->plot->legend()->find( item ); if ( itemManger ) { painter->save(); painter->setClipRect( identifierRect, Qt::IntersectClip ); itemManger->drawLegendIdentifier( painter, identifierRect ); painter->restore(); } // Label QRectF titleRect = rect; titleRect.setX( identifierRect.right() + 2 * item->spacing() ); painter->setFont( item->font() ); item->text().draw( painter, titleRect ); } }
/*! Print the legend item into a given rectangle. \param plot Plot widget \param painter Painter \param widget Widget representing a legend item \param rect Bounding rectangle \note When widget is not derived from QwtLegendItem renderLegendItem does nothing and needs to be overloaded */ void QwtPlotRenderer::renderLegendItem( const QwtPlot *plot, QPainter *painter, const QWidget *widget, const QRectF &rect ) const { const QwtLegendItem *item = qobject_cast<const QwtLegendItem *>( widget ); if ( item ) { const QRect identifierRect( rect.x() + item->margin(), rect.y(), item->identifierSize().width(), rect.height() ); QwtLegendItemManager *itemManger = plot->legend()->find( item ); if ( itemManger ) { painter->save(); itemManger->drawLegendIdentifier( painter, identifierRect ); painter->restore(); } // Label QRectF titleRect = rect; titleRect.setX( identifierRect.right() + 2 * item->spacing() ); painter->setFont( item->font() ); item->text().draw( painter, titleRect ); } }
/*! Render the legend item into a given rectangle. \param plot Plot widget \param painter Painter \param widget Widget representing a legend item \param rect Bounding rectangle \note When widget is not derived from QwtLegendItem renderLegendItem does nothing and needs to be overloaded */ void QwtPlotRenderer::renderLegendItem( const QwtPlot *plot, QPainter *painter, const QWidget *widget, const QRectF &rect ) const { if ( !( d_data->discardFlags & DiscardBackground ) ) { if ( widget->autoFillBackground() || widget->testAttribute( Qt::WA_StyledBackground ) ) { qwtRenderBackground( painter, rect, widget ); } } const QwtLegendItem *item = qobject_cast<const QwtLegendItem *>( widget ); if ( item ) { const QSize sz = item->identifierSize(); const QRectF identifierRect( rect.x() + item->margin(), rect.center().y() - 0.5 * sz.height(), sz.width(), sz.height() ); QwtLegendItemManager *itemManger = plot->legend()->find( item ); if ( itemManger ) { painter->save(); painter->setClipRect( identifierRect, Qt::IntersectClip ); itemManger->drawLegendIdentifier( painter, identifierRect ); painter->restore(); } // Label QRectF titleRect = rect; titleRect.setX( identifierRect.right() + 2 * item->spacing() ); painter->setFont( item->font() ); item->text().draw( painter, titleRect ); } }