Skip to content
Permalink
Browse files

Merge branch 'print-diagram'

  • Loading branch information
m-kuhn committed Aug 29, 2012
2 parents 4e914c6 + 244e7d1 commit 6f97d1eb591766248cb95d1a49313b715e67781e
@@ -30,12 +30,24 @@ void QgsDiagram::setPenWidth( QPen& pen, const QgsDiagramSettings& s, const QgsR
}
}

QSizeF QgsDiagram::sizeForPAL( const QSizeF& size, const QgsDiagramSettings& s, const QgsRenderContext& c )
{
if ( s.sizeType == QgsDiagramSettings::MM )
{
return QSizeF( size.width() / c.rasterScaleFactor(), size.height() / c.rasterScaleFactor() );
}
else
{
return QSizeF( size );
}
}

QSizeF QgsDiagram::sizePainterUnits( const QSizeF& size, const QgsDiagramSettings& s, const QgsRenderContext& c )
{
Q_UNUSED( size );
if ( s.sizeType == QgsDiagramSettings::MM )
{
return QSizeF( s.size.width() * c.scaleFactor(), s.size.height() * c.scaleFactor() );
return QSizeF( s.size.width() * c.scaleFactor() * c.rasterScaleFactor(), s.size.height() * c.scaleFactor() * c.rasterScaleFactor());
}
else
{
@@ -44,6 +44,7 @@ class CORE_EXPORT QgsDiagram
protected:
void setPenWidth( QPen& pen, const QgsDiagramSettings& s, const QgsRenderContext& c );
QSizeF sizePainterUnits( const QSizeF& size, const QgsDiagramSettings& s, const QgsRenderContext& c );
QSizeF sizeForPAL( const QSizeF& size, const QgsDiagramSettings& s, const QgsRenderContext& c );
float sizePainterUnits( float l, const QgsDiagramSettings& s, const QgsRenderContext& c );
QFont scaledFont( const QgsDiagramSettings& s, const QgsRenderContext& c );
};
@@ -32,6 +32,7 @@ QgsHistogramDiagram::~QgsHistogramDiagram()
QSizeF QgsHistogramDiagram::diagramSize( const QgsAttributeMap& attributes, const QgsRenderContext& c, const QgsDiagramSettings& s, const QgsDiagramInterpolationSettings& is )
{
Q_UNUSED( c );
QSize size;
QgsAttributeMap::const_iterator attIt = attributes.constBegin();
if ( attIt == attributes.constEnd() )
{
@@ -56,20 +57,24 @@ QSizeF QgsHistogramDiagram::diagramSize( const QgsAttributeMap& attributes, cons
case QgsDiagramSettings::Up:
case QgsDiagramSettings::Down:
mScaleFactor = ( ( is.upperSize.width() - is.lowerSize.height() ) / ( is.upperValue - is.lowerValue ) );
return QSizeF( s.barWidth * attributes.size(), maxValue * mScaleFactor );
size.scale( s.barWidth * attributes.size(), maxValue * mScaleFactor, Qt::IgnoreAspectRatio );
break;

case QgsDiagramSettings::Right:
case QgsDiagramSettings::Left:
mScaleFactor = ( ( is.upperSize.width() - is.lowerSize.width() ) / ( is.upperValue - is.lowerValue ) );
return QSizeF( maxValue * mScaleFactor, s.barWidth * attributes.size() );
size.scale( maxValue * mScaleFactor, s.barWidth * attributes.size(), Qt::IgnoreAspectRatio );
break;
}

return QSizeF();
QSizeF scaledSize = sizeForPAL( size, s, c );
return scaledSize;
}

QSizeF QgsHistogramDiagram::diagramSize( const QgsAttributeMap& attributes, const QgsRenderContext& c, const QgsDiagramSettings& s )
{
Q_UNUSED( c );
QSizeF size;

QgsAttributeMap::const_iterator attIt = attributes.constBegin();
if ( attIt == attributes.constEnd() )
{
@@ -88,15 +93,19 @@ QSizeF QgsHistogramDiagram::diagramSize( const QgsAttributeMap& attributes, cons
case QgsDiagramSettings::Up:
case QgsDiagramSettings::Down:
mScaleFactor = maxValue / s.size.height();
return QSizeF( s.barWidth * attributes.size(), s.size.height() );
size.scale( s.barWidth * attributes.size(), s.size.height(), Qt::IgnoreAspectRatio );
break;

case QgsDiagramSettings::Right:
case QgsDiagramSettings::Left:
default: // just in case...
mScaleFactor = maxValue / s.size.width();
return QSizeF( s.size.width(), s.barWidth * attributes.size() );
size.scale( s.size.width(), s.barWidth * attributes.size(), Qt::IgnoreAspectRatio );
break;
}

return QSizeF();
QSizeF scaledSize = sizeForPAL( size, s, c );
return scaledSize;
}

void QgsHistogramDiagram::renderDiagram( const QgsAttributeMap& att, QgsRenderContext& c, const QgsDiagramSettings& s, const QPointF& position )
@@ -69,14 +69,18 @@ QSizeF QgsPieDiagram::diagramSize( const QgsAttributeMap& attributes, const QgsR
size.scale( s.minimumSize, s.minimumSize, Qt::KeepAspectRatio );
}

return size;
QSizeF scaledSize = sizeForPAL( size, s, c );
return scaledSize;
}

QSizeF QgsPieDiagram::diagramSize( const QgsAttributeMap& attributes, const QgsRenderContext& c, const QgsDiagramSettings& s )
{
return s.size;
QSizeF scaledSize = sizeForPAL( s.size, s, c );
return scaledSize;
}

int QgsPieDiagram::sCount = 0;

void QgsPieDiagram::renderDiagram( const QgsAttributeMap& att, QgsRenderContext& c, const QgsDiagramSettings& s, const QPointF& position )
{
QPainter* p = c.painter();
@@ -43,6 +43,8 @@ class CORE_EXPORT QgsPieDiagram: public QgsDiagram
private:
QBrush mCategoryBrush;
QPen mPen;

static int sCount;
};

#endif // QGSPIEDIAGRAM_H
@@ -70,12 +70,14 @@ QSizeF QgsTextDiagram::diagramSize( const QgsAttributeMap& attributes, const Qgs
size.scale( s.minimumSize, s.minimumSize, Qt::KeepAspectRatio );
}

return size;
QSizeF scaledSize = sizeForPAL( size, s, c );
return scaledSize;
}

QSizeF QgsTextDiagram::diagramSize( const QgsAttributeMap& attributes, const QgsRenderContext& c, const QgsDiagramSettings& s )
{
return s.size;
QSizeF scaledSize = sizeForPAL( s.size, s, c );
return scaledSize;
}

void QgsTextDiagram::renderDiagram( const QgsAttributeMap& att, QgsRenderContext& c, const QgsDiagramSettings& s, const QPointF& position )

0 comments on commit 6f97d1e

Please sign in to comment.
You can’t perform that action at this time.