Skip to content

Commit cda4fc9

Browse files
author
mhugent
committedJun 12, 2010
Fix bug with georef pdf report scale bar units
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13719 c8812cc2-4d05-0410-92ff-de0c093fc19c

File tree

3 files changed

+8
-31
lines changed

3 files changed

+8
-31
lines changed
 

‎src/plugins/georeferencer/qgsgeorefplugingui.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,15 +1403,8 @@ bool QgsGeorefPluginGui::writePDFReportFile( const QString& fileName, const QgsG
14031403
resPlotItem->setExtent( composerMap->extent() );
14041404
resPlotItem->setGCPList( mPoints );
14051405

1406-
//convert residual scale bar plot to map units if scaling is equal in x- and y-direction (e.g. helmert)
1407-
if ( wldTransform )
1408-
{
1409-
if ( doubleNear( scaleX, scaleX ) )
1410-
{
1411-
resPlotItem->setPixelToMapUnits( scaleX );
1412-
resPlotItem->setConvertScaleToMapUnits( true );
1413-
}
1414-
}
1406+
//necessary for the correct scale bar unit label
1407+
resPlotItem->setConvertScaleToMapUnits( residualUnits == tr( "map units" ) );
14151408

14161409
QgsComposerTextTable* gcpTable = new QgsComposerTextTable( composition );
14171410
gcpTable->setHeaderFont( tableHeaderFont );

‎src/plugins/georeferencer/qgsresidualplotitem.cpp

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include <math.h>
2525
#endif
2626

27-
QgsResidualPlotItem::QgsResidualPlotItem( QgsComposition* c ): QgsComposerItem( c ), mConvertScaleToMapUnits( false ), mPixelToMapUnits( 1.0 )
27+
QgsResidualPlotItem::QgsResidualPlotItem( QgsComposition* c ): QgsComposerItem( c ), mConvertScaleToMapUnits( false )
2828
{
2929

3030
}
@@ -109,32 +109,21 @@ void QgsResidualPlotItem::paint( QPainter* painter, const QStyleOptionGraphicsIt
109109

110110
//draw scale bar
111111
double initialScaleBarWidth = rect().width() / 5;
112-
int nUnits;
113-
double scaleBarWidth;
114-
if ( mConvertScaleToMapUnits ) //map units
115-
{
116-
nUnits = initialScaleBarWidth / minMMPixelRatio * mPixelToMapUnits;
117-
scaleBarWidth = nUnits * minMMPixelRatio / mPixelToMapUnits;
118-
}
119-
else //pixels
120-
{
121-
nUnits = initialScaleBarWidth / minMMPixelRatio;
122-
scaleBarWidth = nUnits * minMMPixelRatio;
123-
}
112+
double scaleBarWidthUnits = rect().width() / 5 / minMMPixelRatio;
124113

125114
painter->setPen( QColor( 0, 0, 0 ) );
126-
painter->drawLine( QPointF( 5, rect().height() - 5 ), QPointF( 5 + scaleBarWidth, rect().height() - 5 ) );
115+
painter->drawLine( QPointF( 5, rect().height() - 5 ), QPointF( 5 + initialScaleBarWidth, rect().height() - 5 ) );
127116
painter->drawLine( QPointF( 5, rect().height() - 5 ), QPointF( 5, rect().height() - 7 ) );
128-
painter->drawLine( QPointF( 5 + scaleBarWidth, rect().height() - 5 ), QPointF( 5 + scaleBarWidth, rect().height() - 7 ) );
117+
painter->drawLine( QPointF( 5 + initialScaleBarWidth, rect().height() - 5 ), QPointF( 5 + initialScaleBarWidth, rect().height() - 7 ) );
129118
QFont scaleBarFont;
130119
scaleBarFont.setPointSize( 9 );
131120
if ( mConvertScaleToMapUnits )
132121
{
133-
drawText( painter, 5, rect().height() - 4 + fontAscentMillimeters( scaleBarFont ), QString( "%1 map units" ).arg( nUnits ), QFont() );
122+
drawText( painter, 5, rect().height() - 4 + fontAscentMillimeters( scaleBarFont ), QString( "%1 map units" ).arg( scaleBarWidthUnits ), QFont() );
134123
}
135124
else
136125
{
137-
drawText( painter, 5, rect().height() - 4 + fontAscentMillimeters( scaleBarFont ), QString( "%1 pixels" ).arg( nUnits ), QFont() );
126+
drawText( painter, 5, rect().height() - 4 + fontAscentMillimeters( scaleBarFont ), QString( "%1 pixels" ).arg( scaleBarWidthUnits ), QFont() );
138127
}
139128

140129
drawFrame( painter );

‎src/plugins/georeferencer/qgsresidualplotitem.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ class QgsResidualPlotItem: public QgsComposerItem
3939
void setExtent( const QgsRectangle& rect ) { mExtent = rect;}
4040
QgsRectangle extent() const { return mExtent; }
4141

42-
void setPixelToMapUnits( double d ) { mPixelToMapUnits = d; }
43-
double pixelToMapUnits() const { return mPixelToMapUnits; }
44-
4542
void setConvertScaleToMapUnits( bool convert ) { mConvertScaleToMapUnits = convert; }
4643
bool convertScaleToMapUnits() const { return mConvertScaleToMapUnits; }
4744

@@ -55,8 +52,6 @@ class QgsResidualPlotItem: public QgsComposerItem
5552
QgsRectangle mExtent;
5653
/**True if the scale bar units should be converted to map units. This can be done for transformation where the scaling in all directions is the same (helmert)*/
5754
bool mConvertScaleToMapUnits;
58-
/**Scale factor from pixels to map units*/
59-
double mPixelToMapUnits;
6055

6156
/**Calculates maximal possible mm to pixel ratio such that the residual arrow is still inside the frame*/
6257
double maxMMToPixelRatioForGCP( const QgsGeorefDataPoint* p, double pixelXMM, double pixelYMM );

0 commit comments

Comments
 (0)
Please sign in to comment.