예제 #1
0
const QPair<QPointF, QPointF> RingDiagram::calculateDataBoundaries () const
{
    if ( !checkInvariants( true ) ) return QPair<QPointF, QPointF>( QPointF( 0, 0 ), QPointF( 0, 0 ) );

    const PieAttributes attrs( pieAttributes( model()->index( 0, 0, rootIndex() ) ) );

    QPointF bottomLeft ( QPointF( 0, 0 ) );
    QPointF topRight;
    // If we explode, we need extra space for the pie slice that has
    // the largest explosion distance.
    if ( attrs.explode() ) {
    	const int rCount = rowCount();
        const int colCount = columnCount();
        qreal maxExplode = 0.0;
        for( int i = 0; i < rCount; ++i ){
        	qreal maxExplodeInThisRow = 0.0;
        	for( int j = 0; j < colCount; ++j ){
        		const PieAttributes columnAttrs( pieAttributes( model()->index( i, j, rootIndex() ) ) );
        		//qDebug() << columnAttrs.explodeFactor();
        		maxExplodeInThisRow = qMax( maxExplodeInThisRow, columnAttrs.explodeFactor() );
        	}
        	maxExplode += maxExplodeInThisRow;

        	// FIXME: What if explode factor of inner ring is > 1.0 ?
        	if ( !d->expandWhenExploded )
        		break;
        }
        // explode factor is relative to width (outer r - inner r) of one ring
        maxExplode /= ( rCount + 1);
        topRight = QPointF( 1.0+maxExplode, 1.0+maxExplode );
    }else{
        topRight = QPointF( 1.0, 1.0 );
    }
    return QPair<QPointF, QPointF> ( bottomLeft,  topRight );
}
예제 #2
0
const QPair<QPointF, QPointF> PieDiagram::calculateDataBoundaries () const
{
    if ( !checkInvariants( true ) ) return QPair<QPointF, QPointF>( QPointF( 0, 0 ), QPointF( 0, 0 ) );

    const PieAttributes attrs( pieAttributes( model()->index( 0, 0, rootIndex() ) ) );

    QPointF bottomLeft ( QPointF( 0, 0 ) );
    QPointF topRight;
    // If we explode, we need extra space for the pie slice that has
    // the largest explosion distance.
    if ( attrs.explode() ) {
        const int colCount = columnCount();
        qreal maxExplode = 0.0;
        for( int j = 0; j < colCount; ++j ){
            const PieAttributes columnAttrs( pieAttributes( model()->index( 0, j, rootIndex() ) ) );
            maxExplode = qMax( maxExplode, columnAttrs.explodeFactor() );
        }
        topRight = QPointF( 1.0+maxExplode, 1.0+maxExplode );
    }else{
        topRight = QPointF( 1.0, 1.0 );
    }
    return QPair<QPointF, QPointF> ( bottomLeft,  topRight );
}