|
24 | 24 | #include <math.h>
|
25 | 25 | #endif
|
26 | 26 |
|
27 |
| -QgsResidualPlotItem::QgsResidualPlotItem( QgsComposition* c ): QgsComposerItem( c ), mConvertScaleToMapUnits( false ), mPixelToMapUnits( 1.0 ) |
| 27 | +QgsResidualPlotItem::QgsResidualPlotItem( QgsComposition* c ): QgsComposerItem( c ), mConvertScaleToMapUnits( false ) |
28 | 28 | {
|
29 | 29 |
|
30 | 30 | }
|
@@ -109,32 +109,21 @@ void QgsResidualPlotItem::paint( QPainter* painter, const QStyleOptionGraphicsIt
|
109 | 109 |
|
110 | 110 | //draw scale bar
|
111 | 111 | 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; |
124 | 113 |
|
125 | 114 | 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 ) ); |
127 | 116 | 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 ) ); |
129 | 118 | QFont scaleBarFont;
|
130 | 119 | scaleBarFont.setPointSize( 9 );
|
131 | 120 | if ( mConvertScaleToMapUnits )
|
132 | 121 | {
|
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() ); |
134 | 123 | }
|
135 | 124 | else
|
136 | 125 | {
|
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() ); |
138 | 127 | }
|
139 | 128 |
|
140 | 129 | drawFrame( painter );
|
|
0 commit comments