Пример #1
0
//!  Update the widget that represents the curve on the legend
void QwtPolarCurve::updateLegend( QwtLegend *legend ) const
{
    if ( legend && testItemAttribute( QwtPolarCurve::Legend )
            && ( d_data->legendAttributes & QwtPolarCurve::LegendShowSymbol )
            && d_data->symbol
            && d_data->symbol->style() != QwtSymbol::NoSymbol )
    {
        QWidget *lgdItem = legend->find( this );
        if ( lgdItem == NULL )
        {
            lgdItem = legendItem();
            if ( lgdItem )
                legend->insert( this, lgdItem );
        }

        QwtLegendItem *l = qobject_cast<QwtLegendItem *>( lgdItem );
        if ( l )
        {
            QSize sz = d_data->symbol->boundingSize();
            sz += QSize( 2, 2 ); // margin

            if ( d_data->legendAttributes & QwtPolarCurve::LegendShowLine )
            {
                // Avoid, that the line is completely covered by the symbol

                int w = qCeil( 1.5 * sz.width() );
                if ( w % 2 )
                    w++;

                sz.setWidth( qMax( 8, w ) );
            }

            l->setIdentifierSize( sz );
        }
    }

    QwtPolarItem::updateLegend( legend );
}
Пример #2
0
/*!
   \brief Update the widget that represents the item on the legend

   \param legend Legend
   \sa drawLegendIdentifier(), legendItem(), itemChanged(), QwtLegend()
*/
void QwtPlotCurve::updateLegend( QwtLegend *legend ) const
{
    if ( legend && testItemAttribute( QwtPlotItem::Legend )
        && ( d_data->legendAttributes & QwtPlotCurve::LegendShowSymbol )
        && d_data->symbol
        && d_data->symbol->style() != QwtSymbol::NoSymbol )
    {
        QWidget *lgdItem = legend->find( this );
        if ( lgdItem == NULL )
        {
            lgdItem = legendItem();
            if ( lgdItem )
                legend->insert( this, lgdItem );
        }
        if ( lgdItem && lgdItem->inherits( "QwtLegendItem" ) )
        {
            QwtLegendItem *l = ( QwtLegendItem * )lgdItem;
            l->setIdentifierSize( d_data->symbol->boundingSize() );
        }
    }

    QwtPlotItem::updateLegend( legend );
}