@@ -175,10 +175,6 @@ QgsPalLayerSettings::QgsPalLayerSettings()
175
175
obstacleType = PolygonInterior;
176
176
zIndex = 0.0 ;
177
177
178
- // scale factors
179
- vectorScaleFactor = 1.0 ;
180
- rasterCompressFactor = 1.0 ;
181
-
182
178
// data defined string and old-style index values
183
179
// NOTE: in QPair use -1 for second value (other values are for old-style layer properties migration)
184
180
@@ -390,9 +386,6 @@ QgsPalLayerSettings& QgsPalLayerSettings::operator=( const QgsPalLayerSettings &
390
386
}
391
387
mDataDefinedNames = s.mDataDefinedNames ;
392
388
393
- // scale factors
394
- vectorScaleFactor = s.vectorScaleFactor ;
395
- rasterCompressFactor = s.rasterCompressFactor ;
396
389
return *this ;
397
390
}
398
391
@@ -1431,7 +1424,7 @@ void QgsPalLayerSettings::calculateLabelSize( const QFontMetricsF* fm, QString t
1431
1424
double labelHeight = fm->ascent () + fm->descent (); // ignore +1 for baseline
1432
1425
1433
1426
h += fm->height () + static_cast < double >(( lines - 1 ) * labelHeight * multilineH );
1434
- h /= rasterCompressFactor ;
1427
+ h /= context-> rasterScaleFactor () ;
1435
1428
1436
1429
for ( int i = 0 ; i < lines; ++i )
1437
1430
{
@@ -1441,7 +1434,7 @@ void QgsPalLayerSettings::calculateLabelSize( const QFontMetricsF* fm, QString t
1441
1434
w = width;
1442
1435
}
1443
1436
}
1444
- w /= rasterCompressFactor ;
1437
+ w /= context-> rasterScaleFactor () ;
1445
1438
1446
1439
#if 0 // XXX strk
1447
1440
QgsPoint ptSize = xform->toMapCoordinatesF( w, h );
@@ -2252,7 +2245,7 @@ void QgsPalLayerSettings::registerFeature( QgsFeature& f, QgsRenderContext &cont
2252
2245
double topMargin = qMax ( 0.25 * labelFontMetrics->ascent (), 0.0 );
2253
2246
double bottomMargin = 1.0 + labelFontMetrics->descent ();
2254
2247
QgsLabelFeature::VisualMargin vm ( topMargin, 0.0 , bottomMargin, 0.0 );
2255
- vm *= xform->mapUnitsPerPixel () / rasterCompressFactor ;
2248
+ vm *= xform->mapUnitsPerPixel () / context. rasterScaleFactor () ;
2256
2249
( *labelFeature )->setVisualMargin ( vm );
2257
2250
2258
2251
// store the label's calculated font for later use during painting
@@ -2262,7 +2255,7 @@ void QgsPalLayerSettings::registerFeature( QgsFeature& f, QgsRenderContext &cont
2262
2255
// TODO: only for placement which needs character info
2263
2256
// account for any data defined font metrics adjustments
2264
2257
lf->calculateInfo ( placement == QgsPalLayerSettings::Curved || placement == QgsPalLayerSettings::PerimeterCurved,
2265
- labelFontMetrics.data (), xform, rasterCompressFactor , maxcharanglein, maxcharangleout );
2258
+ labelFontMetrics.data (), xform, context. rasterScaleFactor () , maxcharanglein, maxcharangleout );
2266
2259
// for labelFeature the LabelInfo is passed to feat when it is registered
2267
2260
2268
2261
// TODO: allow layer-wide feature dist in PAL...?
@@ -2297,7 +2290,7 @@ void QgsPalLayerSettings::registerFeature( QgsFeature& f, QgsRenderContext &cont
2297
2290
}
2298
2291
else // mm
2299
2292
{
2300
- distance *= vectorScaleFactor ;
2293
+ distance *= context. scaleFactor () ;
2301
2294
}
2302
2295
2303
2296
// when using certain placement modes, we force a tiny minimum distance. This ensures that
@@ -4082,11 +4075,10 @@ void QgsPalLabeling::drawLabelCandidateRect( pal::LabelPosition* lp, QPainter* p
4082
4075
4083
4076
void QgsPalLabeling::drawLabelBuffer ( QgsRenderContext& context,
4084
4077
const QgsLabelComponent& component,
4085
- const QgsPalLayerSettings& tmpLyr )
4078
+ const QgsTextFormat& format )
4086
4079
{
4087
4080
QPainter* p = context.painter ();
4088
4081
4089
- QgsTextFormat format = tmpLyr.format ();
4090
4082
QgsTextBufferSettings buffer = format.buffer ();
4091
4083
4092
4084
double penSize = QgsTextRenderer::scaleToPixelContext ( buffer.size (), context,
@@ -4120,7 +4112,7 @@ void QgsPalLabeling::drawLabelBuffer( QgsRenderContext& context,
4120
4112
bufferComponent.setOrigin ( QgsPoint ( 0.0 , 0.0 ) );
4121
4113
bufferComponent.setPicture ( &buffPict );
4122
4114
bufferComponent.setPictureBuffer ( penSize / 2.0 );
4123
- drawLabelShadow ( context, bufferComponent, tmpLyr );
4115
+ drawLabelShadow ( context, bufferComponent, format );
4124
4116
}
4125
4117
4126
4118
p->save ();
@@ -4141,9 +4133,8 @@ void QgsPalLabeling::drawLabelBuffer( QgsRenderContext& context,
4141
4133
4142
4134
void QgsPalLabeling::drawLabelBackground ( QgsRenderContext& context,
4143
4135
QgsLabelComponent component,
4144
- const QgsPalLayerSettings& tmpLyr )
4136
+ const QgsTextFormat& format )
4145
4137
{
4146
- QgsTextFormat format = tmpLyr.format ();
4147
4138
QgsTextBackgroundSettings background = format.background ();
4148
4139
4149
4140
QPainter* p = context.painter ();
@@ -4274,7 +4265,7 @@ void QgsPalLabeling::drawLabelBackground( QgsRenderContext& context,
4274
4265
p->rotate ( component.rotationOffset () );
4275
4266
p->translate ( -svgSize / 2 , svgSize / 2 );
4276
4267
4277
- drawLabelShadow ( context, component, tmpLyr );
4268
+ drawLabelShadow ( context, component, format );
4278
4269
p->restore ();
4279
4270
4280
4271
delete svgShdwM;
@@ -4415,7 +4406,7 @@ void QgsPalLabeling::drawLabelBackground( QgsRenderContext& context,
4415
4406
4416
4407
component.setSize ( QgsPoint ( rect.width (), rect.height () ) );
4417
4408
component.setOffset ( QgsPoint ( rect.width () / 2 , -rect.height () / 2 ) );
4418
- drawLabelShadow ( context, component, tmpLyr );
4409
+ drawLabelShadow ( context, component, format );
4419
4410
}
4420
4411
4421
4412
p->setOpacity ( background.opacity () );
@@ -4434,15 +4425,14 @@ void QgsPalLabeling::drawLabelBackground( QgsRenderContext& context,
4434
4425
4435
4426
void QgsPalLabeling::drawLabelShadow ( QgsRenderContext& context,
4436
4427
const QgsLabelComponent& component,
4437
- const QgsPalLayerSettings& tmpLyr )
4428
+ const QgsTextFormat& format )
4438
4429
{
4430
+ QgsTextShadowSettings shadow = format.shadow ();
4431
+
4439
4432
// incoming component sizes should be multiplied by rasterCompressFactor, as
4440
4433
// this allows shadows to be created at paint device dpi (e.g. high resolution),
4441
4434
// then scale device painter by 1.0 / rasterCompressFactor for output
4442
4435
4443
- QgsTextFormat format = tmpLyr.format ();
4444
- QgsTextShadowSettings shadow = format.shadow ();
4445
-
4446
4436
QPainter* p = context.painter ();
4447
4437
double componentWidth = component.size ().x (), componentHeight = component.size ().y ();
4448
4438
double xOffset = component.offset ().x (), yOffset = component.offset ().y ();
@@ -4451,7 +4441,7 @@ void QgsPalLabeling::drawLabelShadow( QgsRenderContext& context,
4451
4441
// generate pixmap representation of label component drawing
4452
4442
bool mapUnits = shadow.blurRadiusUnit () == QgsUnitTypes::RenderMapUnits;
4453
4443
double radius = QgsTextRenderer::scaleToPixelContext ( shadow.blurRadius (), context, shadow.blurRadiusUnit (), !mapUnits, shadow.blurRadiusMapUnitScale () );
4454
- radius /= ( mapUnits ? tmpLyr. vectorScaleFactor / component.dpiRatio () : 1 );
4444
+ radius /= ( mapUnits ? context. scaleFactor () / component.dpiRatio () : 1 );
4455
4445
radius = static_cast < int >( radius + 0.5 );
4456
4446
4457
4447
// TODO: add labeling gui option to adjust blurBufferClippingScale to minimize pixels, or
0 commit comments