@@ -1120,7 +1120,8 @@ QgsSymbolLayerV2* QgsLinePatternFillSymbolLayer::createFromSld( QDomElement &ele
1120
1120
// //////////////////////
1121
1121
1122
1122
QgsPointPatternFillSymbolLayer::QgsPointPatternFillSymbolLayer (): QgsImageFillSymbolLayer(), mMarkerSymbol( 0 ), mDistanceX( 15 ),
1123
- mDistanceY( 15 ), mDisplacementX( 0 ), mDisplacementY( 0 )
1123
+ mDistanceXUnit( QgsSymbolV2::MM ), mDistanceY( 15 ), mDistanceYUnit( QgsSymbolV2::MM ), mDisplacementX( 0 ), mDisplacementXUnit( QgsSymbolV2::MM ),
1124
+ mDisplacementY( 0 ), mDisplacementYUnit( QgsSymbolV2::MM )
1124
1125
{
1125
1126
mDistanceX = 15 ;
1126
1127
mDistanceY = 15 ;
@@ -1153,6 +1154,29 @@ QgsSymbolLayerV2* QgsPointPatternFillSymbolLayer::create( const QgsStringMap& pr
1153
1154
{
1154
1155
layer->setDisplacementY ( properties[" displacement_y" ].toDouble () );
1155
1156
}
1157
+
1158
+ /* propertyMap["distance_x_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mDistanceXUnit );
1159
+ propertyMap["distance_y_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mDistanceYUnit );
1160
+ propertyMap["displacement_x_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mDisplacementXUnit );
1161
+ propertyMap["displacement_y_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mDisplacementYUnit );*/
1162
+
1163
+ if ( properties.contains ( " distance_x_unit" ) )
1164
+ {
1165
+ layer->setDistanceXUnit ( QgsSymbolLayerV2Utils::decodeOutputUnit ( properties[" distance_x_unit" ] ) );
1166
+ }
1167
+ if ( properties.contains ( " distance_y_unit" ) )
1168
+ {
1169
+ layer->setDistanceYUnit ( QgsSymbolLayerV2Utils::decodeOutputUnit ( properties[" distance_y_unit" ] ) );
1170
+ }
1171
+ if ( properties.contains ( " displacement_x_unit" ) )
1172
+ {
1173
+ layer->setDisplacementXUnit ( QgsSymbolLayerV2Utils::decodeOutputUnit ( properties[" displacement_x_unit" ] ) );
1174
+ }
1175
+ if ( properties.contains ( " displacement_y_unit" ) )
1176
+ {
1177
+ layer->setDisplacementYUnit ( QgsSymbolLayerV2Utils::decodeOutputUnit ( properties[" displacement_y_unit" ] ) );
1178
+ }
1179
+
1156
1180
return layer;
1157
1181
}
1158
1182
@@ -1164,8 +1188,9 @@ QString QgsPointPatternFillSymbolLayer::layerType() const
1164
1188
void QgsPointPatternFillSymbolLayer::startRender ( QgsSymbolV2RenderContext& context )
1165
1189
{
1166
1190
// render 3 rows and columns in one go to easily incorporate displacement
1167
- double width = context.outputPixelSize ( mDistanceX ) * 2.0 ;
1168
- double height = context.outputPixelSize ( mDistanceY ) * 2.0 ;
1191
+ const QgsRenderContext& ctx = context.renderContext ();
1192
+ double width = mDistanceX * QgsSymbolLayerV2Utils::lineWidthScaleFactor ( ctx, mDistanceXUnit ) * 2.0 ;
1193
+ double height = mDistanceY * QgsSymbolLayerV2Utils::lineWidthScaleFactor ( ctx, mDistanceYUnit ) * 2.0 ;
1169
1194
1170
1195
if ( width > 10000 || height > 10000 ) // protect symbol layer from eating too much memory
1171
1196
{
@@ -1200,8 +1225,8 @@ void QgsPointPatternFillSymbolLayer::startRender( QgsSymbolV2RenderContext& cont
1200
1225
mMarkerSymbol ->renderPoint ( QPointF ( width, height ), context.feature (), pointRenderContext );
1201
1226
1202
1227
// render displaced points
1203
- double displacementPixelX = context. outputPixelSize ( mDisplacementX );
1204
- double displacementPixelY = context. outputPixelSize ( mDisplacementY );
1228
+ double displacementPixelX = mDisplacementX * QgsSymbolLayerV2Utils::lineWidthScaleFactor ( ctx, mDisplacementXUnit );
1229
+ double displacementPixelY = mDisplacementY * QgsSymbolLayerV2Utils::lineWidthScaleFactor ( ctx, mDisplacementYUnit );
1205
1230
mMarkerSymbol ->renderPoint ( QPointF ( width / 2.0 , -displacementPixelY ), context.feature (), pointRenderContext );
1206
1231
mMarkerSymbol ->renderPoint ( QPointF ( displacementPixelX, height / 2.0 ), context.feature (), pointRenderContext );
1207
1232
mMarkerSymbol ->renderPoint ( QPointF ( width / 2.0 + displacementPixelX, height / 2.0 - displacementPixelY ), context.feature (), pointRenderContext );
@@ -1246,16 +1271,24 @@ QgsStringMap QgsPointPatternFillSymbolLayer::properties() const
1246
1271
propertyMap[" distance_y" ] = QString::number ( mDistanceY );
1247
1272
propertyMap[" displacement_x" ] = QString::number ( mDisplacementX );
1248
1273
propertyMap[" displacement_y" ] = QString::number ( mDisplacementY );
1274
+ propertyMap[" distance_x_unit" ] = QgsSymbolLayerV2Utils::encodeOutputUnit ( mDistanceXUnit );
1275
+ propertyMap[" distance_y_unit" ] = QgsSymbolLayerV2Utils::encodeOutputUnit ( mDistanceYUnit );
1276
+ propertyMap[" displacement_x_unit" ] = QgsSymbolLayerV2Utils::encodeOutputUnit ( mDisplacementXUnit );
1277
+ propertyMap[" displacement_y_unit" ] = QgsSymbolLayerV2Utils::encodeOutputUnit ( mDisplacementYUnit );
1249
1278
return propertyMap;
1250
1279
}
1251
1280
1252
1281
QgsSymbolLayerV2* QgsPointPatternFillSymbolLayer::clone () const
1253
1282
{
1254
- QgsSymbolLayerV2 * clonedLayer = QgsPointPatternFillSymbolLayer::create ( properties () );
1283
+ QgsPointPatternFillSymbolLayer * clonedLayer = static_cast < QgsPointPatternFillSymbolLayer*>( QgsPointPatternFillSymbolLayer ::create ( properties () ) );
1255
1284
if ( mMarkerSymbol )
1256
1285
{
1257
1286
clonedLayer->setSubSymbol ( mMarkerSymbol ->clone () );
1258
1287
}
1288
+ clonedLayer->setDistanceXUnit ( mDistanceXUnit );
1289
+ clonedLayer->setDistanceYUnit ( mDistanceYUnit );
1290
+ clonedLayer->setDisplacementXUnit ( mDisplacementXUnit );
1291
+ clonedLayer->setDisplacementYUnit ( mDisplacementYUnit );
1259
1292
return clonedLayer;
1260
1293
}
1261
1294
0 commit comments