@@ -472,16 +472,16 @@ void QgsSimpleMarkerSymbolLayerV2::renderPoint( const QPointF& point, QgsSymbolV
472
472
bool hasDataDefinedSize = context.renderHints () & QgsSymbolV2::DataDefinedSizeScale || hasDataDefinedProperty ( EXPR_SIZE );
473
473
474
474
double scaledSize = mSize ;
475
+ bool ok;
475
476
if ( hasDataDefinedSize )
476
477
{
477
478
if ( hasDataDefinedProperty ( EXPR_SIZE ) )
478
479
{
479
- scaledSize = evaluateDataDefinedProperty ( EXPR_SIZE, context.feature () ).toDouble ();
480
- }
481
-
482
- if ( mScaleMethod == QgsSymbolV2::ScaleArea )
483
- {
484
- scaledSize = sqrt ( scaledSize );
480
+ scaledSize = evaluateDataDefinedProperty ( EXPR_SIZE, context.feature (), mSize , &ok ).toDouble ();
481
+ if ( ok && mScaleMethod == QgsSymbolV2::ScaleArea )
482
+ {
483
+ scaledSize = sqrt ( scaledSize );
484
+ }
485
485
}
486
486
}
487
487
@@ -493,12 +493,14 @@ void QgsSimpleMarkerSymbolLayerV2::renderPoint( const QPointF& point, QgsSymbolV
493
493
494
494
// angle
495
495
double angle = mAngle ;
496
+ bool usingDataDefinedRotation = false ;
496
497
if ( hasDataDefinedProperty ( " angle" ) )
497
498
{
498
- angle = evaluateDataDefinedProperty ( " angle" , context.feature () ).toDouble ();
499
+ angle = evaluateDataDefinedProperty ( " angle" , context.feature (), mAngle , &ok ).toDouble ();
500
+ usingDataDefinedRotation = ok;
499
501
}
500
502
501
- bool hasDataDefinedRotation = context.renderHints () & QgsSymbolV2::DataDefinedRotation || hasDataDefinedProperty ( " angle " ) ;
503
+ bool hasDataDefinedRotation = context.renderHints () & QgsSymbolV2::DataDefinedRotation || usingDataDefinedRotation ;
502
504
if ( hasDataDefinedRotation )
503
505
{
504
506
// For non-point markers, "dataDefinedRotation" means following the
@@ -525,12 +527,15 @@ void QgsSimpleMarkerSymbolLayerV2::renderPoint( const QPointF& point, QgsSymbolV
525
527
bool createdNewPath = false ;
526
528
if ( hasDataDefinedProperty ( " name" ) )
527
529
{
528
- QString name = evaluateDataDefinedProperty ( " name" , context.feature () ).toString ();
529
- if ( ! prepareShape ( name ) ) // drawing as a polygon
530
+ QString name = evaluateDataDefinedProperty ( " name" , context.feature (), QVariant (), &ok ).toString ();
531
+ if ( ok )
530
532
{
531
- preparePath ( name ); // drawing as a painter path
533
+ if ( !prepareShape ( name ) ) // drawing as a polygon
534
+ {
535
+ preparePath ( name ); // drawing as a painter path
536
+ }
537
+ createdNewPath = true ;
532
538
}
533
- createdNewPath = true ;
534
539
}
535
540
536
541
if ( mUsingCache )
@@ -563,24 +568,36 @@ void QgsSimpleMarkerSymbolLayerV2::renderPoint( const QPointF& point, QgsSymbolV
563
568
564
569
if ( hasDataDefinedProperty ( " color" ) )
565
570
{
566
- mBrush .setColor ( QgsSymbolLayerV2Utils::decodeColor ( evaluateDataDefinedProperty ( " color" , context.feature () ).toString () ) );
571
+ QString colorString = evaluateDataDefinedProperty ( " color" , context.feature (), QVariant (), &ok ).toString ();
572
+ if ( ok )
573
+ mBrush .setColor ( QgsSymbolLayerV2Utils::decodeColor ( colorString ) );
567
574
}
568
575
if ( hasDataDefinedProperty ( " color_border" ) )
569
576
{
570
- mPen .setColor ( QgsSymbolLayerV2Utils::decodeColor ( evaluateDataDefinedProperty ( " color_border" , context.feature () ).toString () ) );
571
- mSelPen .setColor ( QgsSymbolLayerV2Utils::decodeColor ( evaluateDataDefinedProperty ( " color_border" , context.feature () ).toString () ) );
577
+ QString colorString = evaluateDataDefinedProperty ( " color_border" , context.feature (), QVariant (), &ok ).toString ();
578
+ if ( ok )
579
+ {
580
+ mPen .setColor ( QgsSymbolLayerV2Utils::decodeColor ( colorString ) );
581
+ mSelPen .setColor ( QgsSymbolLayerV2Utils::decodeColor ( colorString ) );
582
+ }
572
583
}
573
584
if ( hasDataDefinedProperty ( " outline_width" ) )
574
585
{
575
- double outlineWidth = evaluateDataDefinedProperty ( " outline_width" , context.feature () ).toDouble ();
576
- mPen .setWidthF ( outlineWidth * QgsSymbolLayerV2Utils::lineWidthScaleFactor ( context.renderContext (), mOutlineWidthUnit , mOutlineWidthMapUnitScale ) );
577
- mSelPen .setWidthF ( outlineWidth * QgsSymbolLayerV2Utils::lineWidthScaleFactor ( context.renderContext (), mOutlineWidthUnit , mOutlineWidthMapUnitScale ) );
586
+ double outlineWidth = evaluateDataDefinedProperty ( " outline_width" , context.feature (), QVariant (), &ok ).toDouble ();
587
+ if ( ok )
588
+ {
589
+ mPen .setWidthF ( outlineWidth * QgsSymbolLayerV2Utils::lineWidthScaleFactor ( context.renderContext (), mOutlineWidthUnit , mOutlineWidthMapUnitScale ) );
590
+ mSelPen .setWidthF ( outlineWidth * QgsSymbolLayerV2Utils::lineWidthScaleFactor ( context.renderContext (), mOutlineWidthUnit , mOutlineWidthMapUnitScale ) );
591
+ }
578
592
}
579
593
if ( hasDataDefinedProperty ( " outline_style" ) )
580
594
{
581
- QString outlineStyle = evaluateDataDefinedProperty ( " outline_style" , context.feature () ).toString ();
582
- mPen .setStyle ( QgsSymbolLayerV2Utils::decodePenStyle ( outlineStyle ) );
583
- mSelPen .setStyle ( QgsSymbolLayerV2Utils::decodePenStyle ( outlineStyle ) );
595
+ QString outlineStyle = evaluateDataDefinedProperty ( " outline_style" , context.feature (), QVariant (), &ok ).toString ();
596
+ if ( ok )
597
+ {
598
+ mPen .setStyle ( QgsSymbolLayerV2Utils::decodePenStyle ( outlineStyle ) );
599
+ mSelPen .setStyle ( QgsSymbolLayerV2Utils::decodePenStyle ( outlineStyle ) );
600
+ }
584
601
}
585
602
586
603
p->setBrush ( context.selected () ? mSelBrush : mBrush );
@@ -790,20 +807,24 @@ bool QgsSimpleMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitSc
790
807
}
791
808
792
809
// data defined size
810
+ bool ok = true ;
793
811
if ( hasDataDefinedSize )
794
812
{
795
813
if ( hasDataDefinedProperty ( " size" ) )
796
814
{
797
- size = evaluateDataDefinedProperty ( " size" , f ).toDouble ();
815
+ size = evaluateDataDefinedProperty ( " size" , f, mSize , &ok ).toDouble ();
798
816
}
799
817
800
- switch ( mScaleMethod )
818
+ if ( ok )
801
819
{
802
- case QgsSymbolV2::ScaleArea:
803
- size = sqrt ( size );
804
- break ;
805
- case QgsSymbolV2::ScaleDiameter:
806
- break ;
820
+ switch ( mScaleMethod )
821
+ {
822
+ case QgsSymbolV2::ScaleArea:
823
+ size = sqrt ( size );
824
+ break ;
825
+ case QgsSymbolV2::ScaleDiameter:
826
+ break ;
827
+ }
807
828
}
808
829
809
830
size *= QgsSymbolLayerV2Utils::lineWidthScaleFactor ( context->renderContext (), mSizeUnit , mSizeMapUnitScale );
@@ -819,7 +840,7 @@ bool QgsSimpleMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitSc
819
840
820
841
if ( context && hasDataDefinedProperty ( " outline_width" ) )
821
842
{
822
- outlineWidth = evaluateDataDefinedProperty ( " outline_width" , f ).toDouble ();
843
+ outlineWidth = evaluateDataDefinedProperty ( " outline_width" , f, mOutlineWidth ).toDouble ();
823
844
}
824
845
if ( mSizeUnit == QgsSymbolV2::MM )
825
846
{
@@ -831,11 +852,15 @@ bool QgsSimpleMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitSc
831
852
QColor bc = mBrush .color ();
832
853
if ( hasDataDefinedProperty ( " color" ) )
833
854
{
834
- bc = QgsSymbolLayerV2Utils::decodeColor ( evaluateDataDefinedProperty ( " color" , f ).toString () );
855
+ QString colorString = evaluateDataDefinedProperty ( " color" , f, QVariant (), &ok ).toString ();
856
+ if ( ok )
857
+ bc = QgsSymbolLayerV2Utils::decodeColor ( colorString );
835
858
}
836
859
if ( hasDataDefinedProperty ( " color_border" ) )
837
860
{
838
- pc = QgsSymbolLayerV2Utils::decodeColor ( evaluateDataDefinedProperty ( " color_border" , f ).toString () );
861
+ QString colorString = evaluateDataDefinedProperty ( " color_border" , f, QVariant (), &ok ).toString ();
862
+ if ( ok )
863
+ pc = QgsSymbolLayerV2Utils::decodeColor ( colorString );
839
864
}
840
865
841
866
// offset
@@ -851,7 +876,7 @@ bool QgsSimpleMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitSc
851
876
double angle = mAngle ;
852
877
if ( context && hasDataDefinedProperty ( " angle" ) )
853
878
{
854
- angle = evaluateDataDefinedProperty ( " angle" , f ).toDouble ();
879
+ angle = evaluateDataDefinedProperty ( " angle" , f, mAngle ).toDouble ();
855
880
}
856
881
857
882
angle = -angle; // rotation in Qt is counterclockwise
@@ -1212,12 +1237,13 @@ void QgsSvgMarkerSymbolLayerV2::renderPoint( const QPointF& point, QgsSymbolV2Re
1212
1237
1213
1238
bool hasDataDefinedSize = context.renderHints () & QgsSymbolV2::DataDefinedSizeScale || hasDataDefinedProperty ( " size" );
1214
1239
1240
+ bool ok = true ;
1215
1241
if ( hasDataDefinedProperty ( " size" ) )
1216
1242
{
1217
- scaledSize = evaluateDataDefinedProperty ( " size" , context.feature () ).toDouble ();
1243
+ scaledSize = evaluateDataDefinedProperty ( " size" , context.feature (), mSize , &ok ).toDouble ();
1218
1244
}
1219
1245
1220
- if ( hasDataDefinedSize )
1246
+ if ( hasDataDefinedSize && ok )
1221
1247
{
1222
1248
switch ( mScaleMethod )
1223
1249
{
@@ -1248,7 +1274,7 @@ void QgsSvgMarkerSymbolLayerV2::renderPoint( const QPointF& point, QgsSymbolV2Re
1248
1274
double angle = mAngle ;
1249
1275
if ( hasDataDefinedProperty ( " angle" ) )
1250
1276
{
1251
- angle = evaluateDataDefinedProperty ( " angle" , context.feature () ).toDouble ();
1277
+ angle = evaluateDataDefinedProperty ( " angle" , context.feature (), mAngle ).toDouble ();
1252
1278
}
1253
1279
1254
1280
bool hasDataDefinedRotation = context.renderHints () & QgsSymbolV2::DataDefinedRotation || hasDataDefinedProperty ( " angle" );
@@ -1282,25 +1308,29 @@ void QgsSvgMarkerSymbolLayerV2::renderPoint( const QPointF& point, QgsSymbolV2Re
1282
1308
QString path = mPath ;
1283
1309
if ( hasDataDefinedProperty ( " name" ) )
1284
1310
{
1285
- path = evaluateDataDefinedProperty ( " name" , context.feature () ).toString ();
1311
+ path = evaluateDataDefinedProperty ( " name" , context.feature (), mPath ).toString ();
1286
1312
}
1287
1313
1288
1314
double outlineWidth = mOutlineWidth ;
1289
1315
if ( hasDataDefinedProperty ( " outline_width" ) )
1290
1316
{
1291
- outlineWidth = evaluateDataDefinedProperty ( " outline_width" , context.feature () ).toDouble ();
1317
+ outlineWidth = evaluateDataDefinedProperty ( " outline_width" , context.feature (), mOutlineWidth ).toDouble ();
1292
1318
}
1293
1319
1294
1320
QColor fillColor = mFillColor ;
1295
1321
if ( hasDataDefinedProperty ( " fill" ) )
1296
1322
{
1297
- fillColor = QgsSymbolLayerV2Utils::decodeColor ( evaluateDataDefinedProperty ( " fill" , context.feature () ).toString () );
1323
+ QString colorString = evaluateDataDefinedProperty ( " fill" , context.feature (), QVariant (), &ok ).toString ();
1324
+ if ( ok )
1325
+ fillColor = QgsSymbolLayerV2Utils::decodeColor ( colorString );
1298
1326
}
1299
1327
1300
1328
QColor outlineColor = mOutlineColor ;
1301
1329
if ( hasDataDefinedProperty ( " outline" ) )
1302
1330
{
1303
- outlineColor = QgsSymbolLayerV2Utils::decodeColor ( evaluateDataDefinedProperty ( " outline" , context.feature () ).toString () );
1331
+ QString colorString = evaluateDataDefinedProperty ( " outline" , context.feature (), QVariant (), &ok ).toString ();
1332
+ if ( ok )
1333
+ outlineColor = QgsSymbolLayerV2Utils::decodeColor ( colorString );
1304
1334
}
1305
1335
1306
1336
bool fitsInCache = true ;
@@ -1529,12 +1559,13 @@ bool QgsSvgMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScale
1529
1559
1530
1560
bool hasDataDefinedSize = context->renderHints () & QgsSymbolV2::DataDefinedSizeScale || hasDataDefinedProperty ( " size" );
1531
1561
1562
+ bool ok = true ;
1532
1563
if ( hasDataDefinedProperty ( " size" ) )
1533
1564
{
1534
- size = evaluateDataDefinedProperty ( " size" , f ).toDouble ();
1565
+ size = evaluateDataDefinedProperty ( " size" , f, mSize , &ok ).toDouble ();
1535
1566
}
1536
1567
1537
- if ( hasDataDefinedSize )
1568
+ if ( hasDataDefinedSize && ok )
1538
1569
{
1539
1570
switch ( mScaleMethod )
1540
1571
{
@@ -1558,8 +1589,9 @@ bool QgsSvgMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScale
1558
1589
1559
1590
if ( hasDataDefinedProperty ( " offset" ) )
1560
1591
{
1561
- QString offsetString = evaluateDataDefinedProperty ( " offset" , f ).toString ();
1562
- offset = QgsSymbolLayerV2Utils::decodePoint ( offsetString );
1592
+ QString offsetString = evaluateDataDefinedProperty ( " offset" , f, QVariant (), &ok ).toString ();
1593
+ if ( ok )
1594
+ offset = QgsSymbolLayerV2Utils::decodePoint ( offsetString );
1563
1595
}
1564
1596
double offsetX = offset.x ();
1565
1597
double offsetY = offset.y ();
@@ -1574,7 +1606,7 @@ bool QgsSvgMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScale
1574
1606
double angle = mAngle ;
1575
1607
if ( hasDataDefinedProperty ( " angle" ) )
1576
1608
{
1577
- angle = evaluateDataDefinedProperty ( " angle" , f ).toDouble ();
1609
+ angle = evaluateDataDefinedProperty ( " angle" , f, mAngle ).toDouble ();
1578
1610
}
1579
1611
// angle = -angle; //rotation in Qt is counterclockwise
1580
1612
if ( angle )
1 commit comments
nirvn commentedon May 9, 2015
Ahhhhhh, bye bye black rectangle legend items!