Skip to content

Commit 5e459d7

Browse files
authored
Merge pull request #3995 from nyalldawson/render_context
Remove rasterScaleFactor/setRasterScaleFactor from QgsRenderContext
2 parents 4941121 + 3274e19 commit 5e459d7

30 files changed

Lines changed: 182 additions & 222 deletions

‎doc/api_break.dox‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,6 +1532,9 @@ QgsRenderContext {#qgis_api_break_3_0_QgsRenderContext}
15321532
- coordinateTransform() now returns a QgsCoordinateTransform object, not a pointer. An invalid QgsCoordinateTransform will
15331533
be returned instead of a null pointer if no transformation is required.
15341534
- setCoordinateTransform() now takes a QgsCoordinateTransform reference, not a pointer. An invalid QgsCoordinateTransform should be used instead of a null pointer if no transformation is required.
1535+
- rasterScaleFactor() and setRasterScaleFactor() were removed. In QGIS 3.0 QPainter destinations should always be constructed so that 1 painter unit = 1 pixel.
1536+
- The constPainter() getter was removed. Const QPainters cannot be painted to or modified, so this
1537+
method was of little use.
15351538

15361539
QgsRendererRangeLabelFormat {#qgis_api_break_3_0_QgsRendererRangeLabelFormat}
15371540
---------------------------
@@ -1629,6 +1632,12 @@ QgsSvgCache {#qgis_api_break_3_0_QgsSvgCache}
16291632

16301633
- This class is no longer a singleton and instance() has been removed. Instead use QgsApplication::svgCache() to access an application-wide cache.
16311634
- containsParamsV2() was removed. Use containsParamsV3() instead.
1635+
- The rasterScaleFactor parameter was removed from all methods
1636+
1637+
QgsSvgCacheEntry {#qgis_api_break_3_0_QgsSvgCacheEntry}
1638+
----------------
1639+
1640+
- The rasterScaleFactor member was removed.
16321641

16331642
QgsStyle (renamed from QgsStyleV2) {#qgis_api_break_3_0_QgsStyle}
16341643
----------------------------------

‎python/core/qgsmapunitscale.sip‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class QgsMapUnitScale
1818
* @param minScale minimum allowed scale, or 0.0 if no minimum scale set
1919
* @param maxScale maximum allowed scale, or 0.0 if no maximum scale set
2020
*/
21-
QgsMapUnitScale( double minScale = 0.0, double maxScale = 0.0 );
21+
explicit QgsMapUnitScale( double minScale = 0.0, double maxScale = 0.0 );
2222

2323
/** The minimum scale, or 0.0 if unset */
2424
double minScale;

‎python/core/qgsrendercontext.sip‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ class QgsRenderContext
6262
//getters
6363

6464
QPainter* painter();
65-
const QPainter* constPainter() const;
6665

6766
/** Returns the current coordinate transform for the context, or an invalid
6867
* transform is no coordinate transformation is required.
@@ -75,8 +74,6 @@ class QgsRenderContext
7574

7675
double scaleFactor() const;
7776

78-
double rasterScaleFactor() const;
79-
8077
bool renderingStopped() const;
8178

8279
bool forceVectorOutput() const;
@@ -119,7 +116,6 @@ class QgsRenderContext
119116

120117
void setRenderingStopped( bool stopped );
121118
void setScaleFactor( double factor );
122-
void setRasterScaleFactor( double factor );
123119
void setRendererScale( double scale );
124120
void setPainter( QPainter* p );
125121

‎python/core/qgstextrenderer.sip‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,21 +1049,19 @@ class QgsTextRenderer
10491049
* @param size size to convert
10501050
* @param c rendercontext
10511051
* @param unit size units
1052-
* @param rasterfactor whether to consider oversampling
10531052
* @param mapUnitScale a mapUnitScale clamper
10541053
* @return font pixel size
10551054
*/
1056-
static int sizeToPixel( double size, const QgsRenderContext& c, QgsUnitTypes::RenderUnit unit, bool rasterfactor = false, const QgsMapUnitScale& mapUnitScale = QgsMapUnitScale() );
1055+
static int sizeToPixel( double size, const QgsRenderContext& c, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale& mapUnitScale = QgsMapUnitScale() );
10571056

10581057
/** Calculates size (considering output size should be in pixel or map units, scale factors and optionally oversampling)
10591058
* @param size size to convert
10601059
* @param c rendercontext
10611060
* @param unit size units
1062-
* @param rasterfactor whether to consider oversampling
10631061
* @param mapUnitScale a mapUnitScale clamper
10641062
* @return size that will render, as double
10651063
*/
1066-
static double scaleToPixelContext( double size, const QgsRenderContext& c, QgsUnitTypes::RenderUnit unit, bool rasterfactor = false, const QgsMapUnitScale& mapUnitScale = QgsMapUnitScale() );
1064+
static double scaleToPixelContext( double size, const QgsRenderContext& c, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale& mapUnitScale = QgsMapUnitScale() );
10671065

10681066
/** Draws text within a rectangle using the specified settings.
10691067
* @param rect destination rectangle for text

‎python/core/symbology-ng/qgssvgcache.sip‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class QgsSvgCacheEntry
1616
* @param outline color of outline
1717
* @param lookupKey the key string used in QgsSvgCache for quick lookup of this entry (relative or absolute path)
1818
*/
19-
QgsSvgCacheEntry( const QString& file, double size, double outlineWidth, double widthScaleFactor, double rasterScaleFactor, const QColor& fill, const QColor& outline, const QString& lookupKey = QString() );
19+
QgsSvgCacheEntry( const QString& file, double size, double outlineWidth, double widthScaleFactor, const QColor& fill, const QColor& outline, const QString& lookupKey = QString() );
2020
~QgsSvgCacheEntry();
2121

2222
//! Absolute path to SVG file
@@ -26,7 +26,6 @@ class QgsSvgCacheEntry
2626
double size; //size in pixels (cast to int for QImage)
2727
double outlineWidth;
2828
double widthScaleFactor;
29-
double rasterScaleFactor;
3029

3130
/** SVG viewbox size.
3231
* @note added in QGIS 2.14
@@ -80,7 +79,7 @@ class QgsSvgCache : QObject
8079
* @param fitsInCache
8180
*/
8281
QImage svgAsImage( const QString& file, double size, const QColor& fill, const QColor& outline, double outlineWidth,
83-
double widthScaleFactor, double rasterScaleFactor, bool& fitsInCache );
82+
double widthScaleFactor, bool& fitsInCache );
8483
/** Get SVG as QPicture&.
8584
* @param file Absolute or relative path to SVG file.
8685
* @param size size of cached image
@@ -92,7 +91,7 @@ class QgsSvgCache : QObject
9291
* @param forceVectorOutput
9392
*/
9493
QPicture svgAsPicture( const QString& file, double size, const QColor& fill, const QColor& outline, double outlineWidth,
95-
double widthScaleFactor, double rasterScaleFactor, bool forceVectorOutput = false );
94+
double widthScaleFactor, bool forceVectorOutput = false );
9695

9796
/** Calculates the viewbox size of a (possibly cached) SVG file.
9897
* @param file Absolute or relative path to SVG file.
@@ -106,7 +105,7 @@ class QgsSvgCache : QObject
106105
* @note added in QGIS 2.14
107106
*/
108107
QSizeF svgViewboxSize( const QString& file, double size, const QColor& fill, const QColor& outline, double outlineWidth,
109-
double widthScaleFactor, double rasterScaleFactor );
108+
double widthScaleFactor );
110109

111110
/** Tests if an svg file contains parameters for fill, outline color, outline width. If yes, possible default values are returned. If there are several
112111
default values in the svg file, only the first one is considered*/
@@ -145,7 +144,7 @@ class QgsSvgCache : QObject
145144

146145
/** Get SVG content*/
147146
QByteArray svgContent( const QString& file, double size, const QColor& fill, const QColor& outline, double outlineWidth,
148-
double widthScaleFactor, double rasterScaleFactor );
147+
double widthScaleFactor );
149148

150149
signals:
151150
/** Emit a signal to be caught by qgisapp and display a msg on status bar */
@@ -164,14 +163,14 @@ class QgsSvgCache : QObject
164163
* @param rasterScaleFactor raster scale factor
165164
*/
166165
QgsSvgCacheEntry* insertSVG( const QString& file, double size, const QColor& fill, const QColor& outline, double outlineWidth,
167-
double widthScaleFactor, double rasterScaleFactor );
166+
double widthScaleFactor );
168167

169168
void replaceParamsAndCacheSvg( QgsSvgCacheEntry* entry );
170169
void cacheImage( QgsSvgCacheEntry* entry );
171170
void cachePicture( QgsSvgCacheEntry* entry, bool forceVectorOutput = false );
172171
/** Returns entry from cache or creates a new entry if it does not exist already*/
173172
QgsSvgCacheEntry* cacheEntry( const QString& file, double size, const QColor& fill, const QColor& outline, double outlineWidth,
174-
double widthScaleFactor, double rasterScaleFactor );
173+
double widthScaleFactor );
175174

176175
/** Removes the least used items until the maximum size is under the limit*/
177176
void trimToMaximumSize();

‎src/app/composer/qgscomposerpicturewidget.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ QIcon QgsComposerPictureWidget::svgToIcon( const QString& filePath ) const
434434
outlineWidth = 0.6;
435435

436436
bool fitsInCache; // should always fit in cache at these sizes (i.e. under 559 px ^ 2, or half cache size)
437-
const QImage& img = QgsApplication::svgCache()->svgAsImage( filePath, 30.0, fill, outline, outlineWidth, 3.5 /*appr. 88 dpi*/, 1.0, fitsInCache );
437+
const QImage& img = QgsApplication::svgCache()->svgAsImage( filePath, 30.0, fill, outline, outlineWidth, 3.5 /*appr. 88 dpi*/, fitsInCache );
438438

439439
return QIcon( QPixmap::fromImage( img ) );
440440
}

‎src/app/qgsmaptoollabel.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ QFont QgsMapToolLabel::currentLabelFont()
242242
if ( sizeIndx != -1 )
243243
{
244244
font.setPixelSize( QgsTextRenderer::sizeToPixel( f.attribute( sizeIndx ).toDouble(),
245-
context, labelSettings.format().sizeUnit(), true,
245+
context, labelSettings.format().sizeUnit(),
246246
labelSettings.format().sizeMapUnitScale() ) );
247247
}
248248

‎src/core/composer/qgscomposerarrow.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ void QgsComposerArrow::drawSVGMarker( QPainter* p, MarkerType type, const QStrin
256256

257257
QSvgRenderer r;
258258
const QByteArray &svgContent = QgsApplication::svgCache()->svgContent( svgFileName, mArrowHeadWidth, mArrowHeadFillColor, mArrowHeadOutlineColor, mArrowHeadOutlineWidth,
259-
1.0, 1.0 );
259+
1.0 );
260260
r.load( svgContent );
261261

262262
p->save();

‎src/core/composer/qgscomposerpicture.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ void QgsComposerPicture::loadLocalPicture( const QString &path )
373373
{
374374
//try to open svg
375375
const QByteArray &svgContent = QgsApplication::svgCache()->svgContent( pic.fileName(), rect().width(), mSvgFillColor, mSvgBorderColor, mSvgBorderWidth,
376-
1.0, 1.0 );
376+
1.0 );
377377
mSVG.load( svgContent );
378378
if ( mSVG.isValid() )
379379
{

‎src/core/qgsmapunitscale.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class CORE_EXPORT QgsMapUnitScale
3939
* @param minScale minimum allowed scale, or 0.0 if no minimum scale set
4040
* @param maxScale maximum allowed scale, or 0.0 if no maximum scale set
4141
*/
42-
QgsMapUnitScale( double minScale = 0.0, double maxScale = 0.0 )
42+
explicit QgsMapUnitScale( double minScale = 0.0, double maxScale = 0.0 )
4343
: minScale( minScale )
4444
, maxScale( maxScale )
4545
, minSizeMMEnabled( false )

0 commit comments

Comments
 (0)