@@ -222,7 +222,13 @@ void QgsQuickPrint::printMap()
222
222
int myLegendHeightPercent = 65 ;
223
223
int myLogoWidthPercent = 23 ;
224
224
int myLogoHeightPercent = 17 ;
225
- int mySymbolScalingAmount = myPrintResolutionDpi / myScreenResolutionDpi;
225
+ //
226
+ // Remember the size and dpi of the maprender
227
+ // so we can restore it properly
228
+ //
229
+ int myOriginalDpi = mpMapRender->outputDpi ();
230
+ QSize myOriginalSize = mpMapRender->outputSize ();
231
+ int mySymbolScalingAmount = myPrintResolutionDpi / myOriginalDpi;
226
232
227
233
// define the font sizes and family
228
234
int myMapTitleFontSize = 24 ;
@@ -337,12 +343,6 @@ void QgsQuickPrint::printMap()
337
343
myMapPixmap.fill ( mMapBackgroundColour );
338
344
QPainter myMapPainter;
339
345
myMapPainter.begin ( &myMapPixmap );
340
- //
341
- // Remember the size and dpi of the maprender
342
- // so we can restore it properly
343
- //
344
- int myOriginalDpi = mpMapRender->outputDpi ();
345
- QSize myOriginalSize = mpMapRender->outputSize ();
346
346
// Now resize for print
347
347
mpMapRender->setOutputSize (
348
348
QSize ( myMapDimensionX, myMapDimensionY ), myPrinter.resolution () );
@@ -795,7 +795,6 @@ void QgsQuickPrint::renderPrintScaleBar(QPainter * thepPainter,
795
795
bool mySnappingFlag = true ;
796
796
QColor mColour = Qt::black;
797
797
// Hard coded sizes
798
- int myMajorTickSize=10 ;
799
798
int myTextOffsetX=0 ;
800
799
int myTextOffsetY=5 ;
801
800
int myXMargin=20 ;
@@ -935,14 +934,14 @@ void QgsQuickPrint::renderPrintScaleBar(QPainter * thepPainter,
935
934
myStops << QGradientStop (1.0 ,QColor (" #656565" ));
936
935
// draw again with the brush in the revers direction to complete teh glossiness
937
936
QLinearGradient myReverseGlossyBrush (
938
- QPointF (myOriginX,myOriginY + myMajorTickSize *3 ),
937
+ QPointF (myOriginX,myOriginY + myFontHeight *3 ),
939
938
QPointF (myOriginX,myOriginY));
940
939
thepPainter->setBrush (myReverseGlossyBrush);
941
940
thepPainter->drawRect (
942
941
myOriginX,
943
942
myOriginY,
944
943
myOriginX + myScaleBarWidthInt,
945
- myOriginY + myMajorTickSize
944
+ myOriginY + myFontHeight
946
945
);
947
946
948
947
//
@@ -953,7 +952,6 @@ void QgsQuickPrint::renderPrintScaleBar(QPainter * thepPainter,
953
952
// Draw the minimum label buffer
954
953
thepPainter->setPen ( myBackColor );
955
954
myFontWidth = myFontMetrics.width ( " 0" );
956
- myFontHeight = myFontMetrics.height ();
957
955
958
956
for (int i = 0 -myBufferSize; i <= myBufferSize; i++)
959
957
{
@@ -1003,22 +1001,21 @@ void QgsQuickPrint::renderPrintScaleBar(QPainter * thepPainter,
1003
1001
//
1004
1002
thepPainter->setPen ( myBackColor );
1005
1003
myFontWidth = myFontMetrics.width ( myScaleBarUnitLabel );
1006
- myFontHeight = myFontMetrics.height ();
1007
1004
// first the buffer
1008
1005
for (int i = 0 -myBufferSize; i <= myBufferSize; i++)
1009
1006
{
1010
1007
for (int j = 0 -myBufferSize; j <= myBufferSize; j++)
1011
1008
{
1012
1009
thepPainter->drawText ( i + (myOriginX+myScaleBarWidthInt+myTextOffsetX),
1013
- j + myOriginY + myMajorTickSize + (myFontHeight*2.5 ) + myTextOffsetY,
1010
+ j + myOriginY + myFontHeight + (myFontHeight*2.5 ) + myTextOffsetY,
1014
1011
myScaleBarUnitLabel);
1015
1012
}
1016
1013
}
1017
1014
// then the text itself
1018
1015
thepPainter->setPen ( myForeColor );
1019
1016
thepPainter->drawText (
1020
1017
myOriginX + myScaleBarWidthInt + myTextOffsetX,
1021
- myOriginY + myMajorTickSize + (myFontHeight*2.5 ) + myTextOffsetY,
1018
+ myOriginY + myFontHeight + (myFontHeight*2.5 ) + myTextOffsetY,
1022
1019
myScaleBarUnitLabel
1023
1020
);
1024
1021
}
0 commit comments