@@ -320,27 +320,27 @@ void QgsSimpleMarkerSymbolLayerV2::stopRender( QgsSymbolV2RenderContext& context
320
320
321
321
bool QgsSimpleMarkerSymbolLayerV2::prepareShape ( QString name )
322
322
{
323
- mPolygon .clear ();
323
+ return prepareShape ( name.isNull () ? mName : name, mPolygon );
324
+ }
324
325
325
- if ( name.isNull () )
326
- {
327
- name = mName ;
328
- }
326
+ bool QgsSimpleMarkerSymbolLayerV2::prepareShape ( QString name, QPolygonF &polygon ) const
327
+ {
328
+ polygon.clear ();
329
329
330
330
if ( name == " square" || name == " rectangle" )
331
331
{
332
- mPolygon = QPolygonF ( QRectF ( QPointF ( -1 , -1 ), QPointF ( 1 , 1 ) ) );
332
+ polygon = QPolygonF ( QRectF ( QPointF ( -1 , -1 ), QPointF ( 1 , 1 ) ) );
333
333
return true ;
334
334
}
335
335
else if ( name == " diamond" )
336
336
{
337
- mPolygon << QPointF ( -1 , 0 ) << QPointF ( 0 , 1 )
337
+ polygon << QPointF ( -1 , 0 ) << QPointF ( 0 , 1 )
338
338
<< QPointF ( 1 , 0 ) << QPointF ( 0 , -1 );
339
339
return true ;
340
340
}
341
341
else if ( name == " pentagon" )
342
342
{
343
- mPolygon << QPointF ( sin ( DEG2RAD ( 288.0 ) ), - cos ( DEG2RAD ( 288.0 ) ) )
343
+ polygon << QPointF ( sin ( DEG2RAD ( 288.0 ) ), - cos ( DEG2RAD ( 288.0 ) ) )
344
344
<< QPointF ( sin ( DEG2RAD ( 216.0 ) ), - cos ( DEG2RAD ( 216.0 ) ) )
345
345
<< QPointF ( sin ( DEG2RAD ( 144.0 ) ), - cos ( DEG2RAD ( 144.0 ) ) )
346
346
<< QPointF ( sin ( DEG2RAD ( 72.0 ) ), - cos ( DEG2RAD ( 72.0 ) ) )
@@ -349,12 +349,12 @@ bool QgsSimpleMarkerSymbolLayerV2::prepareShape( QString name )
349
349
}
350
350
else if ( name == " triangle" )
351
351
{
352
- mPolygon << QPointF ( -1 , 1 ) << QPointF ( 1 , 1 ) << QPointF ( 0 , -1 );
352
+ polygon << QPointF ( -1 , 1 ) << QPointF ( 1 , 1 ) << QPointF ( 0 , -1 );
353
353
return true ;
354
354
}
355
355
else if ( name == " equilateral_triangle" )
356
356
{
357
- mPolygon << QPointF ( sin ( DEG2RAD ( 240.0 ) ), - cos ( DEG2RAD ( 240.0 ) ) )
357
+ polygon << QPointF ( sin ( DEG2RAD ( 240.0 ) ), - cos ( DEG2RAD ( 240.0 ) ) )
358
358
<< QPointF ( sin ( DEG2RAD ( 120.0 ) ), - cos ( DEG2RAD ( 120.0 ) ) )
359
359
<< QPointF ( 0 , -1 );
360
360
return true ;
@@ -363,7 +363,7 @@ bool QgsSimpleMarkerSymbolLayerV2::prepareShape( QString name )
363
363
{
364
364
double sixth = 1.0 / 3 ;
365
365
366
- mPolygon << QPointF ( 0 , -1 )
366
+ polygon << QPointF ( 0 , -1 )
367
367
<< QPointF ( -sixth, -sixth )
368
368
<< QPointF ( -1 , -sixth )
369
369
<< QPointF ( -sixth, 0 )
@@ -379,7 +379,7 @@ bool QgsSimpleMarkerSymbolLayerV2::prepareShape( QString name )
379
379
{
380
380
double inner_r = cos ( DEG2RAD ( 72.0 ) ) / cos ( DEG2RAD ( 36.0 ) );
381
381
382
- mPolygon << QPointF ( inner_r * sin ( DEG2RAD ( 324.0 ) ), - inner_r * cos ( DEG2RAD ( 324.0 ) ) ) // 324
382
+ polygon << QPointF ( inner_r * sin ( DEG2RAD ( 324.0 ) ), - inner_r * cos ( DEG2RAD ( 324.0 ) ) ) // 324
383
383
<< QPointF ( sin ( DEG2RAD ( 288.0 ) ), - cos ( DEG2RAD ( 288 ) ) ) // 288
384
384
<< QPointF ( inner_r * sin ( DEG2RAD ( 252.0 ) ), - inner_r * cos ( DEG2RAD ( 252.0 ) ) ) // 252
385
385
<< QPointF ( sin ( DEG2RAD ( 216.0 ) ), - cos ( DEG2RAD ( 216.0 ) ) ) // 216
@@ -393,8 +393,7 @@ bool QgsSimpleMarkerSymbolLayerV2::prepareShape( QString name )
393
393
}
394
394
else if ( name == " arrow" )
395
395
{
396
- mPolygon
397
- << QPointF ( 0 , -1 )
396
+ polygon << QPointF ( 0 , -1 )
398
397
<< QPointF ( 0.5 , -0.5 )
399
398
<< QPointF ( 0.25 , -0.5 )
400
399
<< QPointF ( 0.25 , 1 )
@@ -405,7 +404,7 @@ bool QgsSimpleMarkerSymbolLayerV2::prepareShape( QString name )
405
404
}
406
405
else if ( name == " filled_arrowhead" )
407
406
{
408
- mPolygon << QPointF ( 0 , 0 ) << QPointF ( -1 , 1 ) << QPointF ( -1 , -1 );
407
+ polygon << QPointF ( 0 , 0 ) << QPointF ( -1 , 1 ) << QPointF ( -1 , -1 );
409
408
return true ;
410
409
}
411
410
@@ -883,6 +882,12 @@ bool QgsSimpleMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitSc
883
882
angle = evaluateDataDefinedProperty ( QgsSymbolLayerV2::EXPR_ANGLE, f, mAngle ).toDouble () + mLineAngle ;
884
883
}
885
884
885
+ QString name ( mName );
886
+ if ( hasDataDefinedProperty ( QgsSymbolLayerV2::EXPR_NAME ) )
887
+ {
888
+ name = evaluateDataDefinedProperty ( QgsSymbolLayerV2::EXPR_NAME, f, QVariant (), &ok ).toString ();
889
+ }
890
+
886
891
angle = -angle; // rotation in Qt is counterclockwise
887
892
if ( angle )
888
893
off = _rotatedOffset ( off, angle );
@@ -898,75 +903,42 @@ bool QgsSimpleMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitSc
898
903
if ( angle != 0 )
899
904
t.rotate ( angle );
900
905
901
- // data defined symbol name
902
-
903
- if ( mName == " circle" )
906
+ QPolygonF polygon;
907
+ if ( prepareShape ( name, polygon ) )
904
908
{
905
- if ( mBrush .style () != Qt::NoBrush )
906
- e.writeFilledCircle ( layerName, bc, shift, halfSize );
907
- if ( mPen .style () != Qt::NoPen )
908
- e.writeCircle ( layerName, pc, shift, halfSize, " CONTINUOUS" , outlineWidth );
909
- }
910
- else if ( mName == " square" || mName == " rectangle" )
911
- {
912
- QgsPolygon p ( 1 );
913
- p[0 ].resize ( 5 );
914
- p[0 ][0 ] = t.map ( QPointF ( -halfSize, -halfSize ) );
915
- p[0 ][1 ] = t.map ( QPointF ( -halfSize, halfSize ) );
916
- p[0 ][2 ] = t.map ( QPointF ( halfSize, halfSize ) );
917
- p[0 ][3 ] = t.map ( QPointF ( halfSize, -halfSize ) );
918
- p[0 ][4 ] = p[0 ][0 ];
909
+ t.scale ( halfSize, -halfSize );
910
+
911
+ polygon = t.map ( polygon );
919
912
920
- if ( mBrush .style () != Qt::NoBrush )
921
- e.writePolygon ( p, layerName, " SOLID" , bc );
922
- if ( mPen .style () != Qt::NoPen )
923
- e.writePolyline ( p[0 ], layerName, " CONTINUOUS" , pc, outlineWidth );
924
- }
925
- else if ( mName == " diamond" )
926
- {
927
913
QgsPolygon p ( 1 );
928
- p[ 0 ] .resize ( 5 );
929
- p[0 ][ 0 ] = t. map ( QPointF ( -halfSize, 0 ) );
930
- p[ 0 ][ 1 ] = t. map ( QPointF ( 0 , halfSize ) ) ;
931
- p[ 0 ][ 3 ] = t. map ( QPointF ( halfSize, 0 ) );
932
- p[0 ][1 ] = t. map ( QPointF ( 0 , -halfSize ) ) ;
933
- p[0 ][4 ] = p[0 ][0 ];
914
+ p.resize ( 1 );
915
+ p[0 ]. resize ( polygon. size () + 1 );
916
+ int i = 0 ;
917
+ for ( i = 0 ; i < polygon. size (); i++ )
918
+ p[0 ][i ] = polygon[i] ;
919
+ p[0 ][i ] = p[0 ][0 ];
934
920
935
921
if ( mBrush .style () != Qt::NoBrush )
936
922
e.writePolygon ( p, layerName, " SOLID" , bc );
937
923
if ( mPen .style () != Qt::NoPen )
938
924
e.writePolyline ( p[0 ], layerName, " CONTINUOUS" , pc, outlineWidth );
939
925
}
940
- else if ( mName == " triangle " )
926
+ else if ( name == " circle " )
941
927
{
942
- QgsPolygon p ( 1 );
943
- p[0 ].resize ( 4 );
944
- p[0 ][0 ] = t.map ( QPointF ( -halfSize, -halfSize ) );
945
- p[0 ][1 ] = t.map ( QPointF ( halfSize, -halfSize ) );
946
- p[0 ][1 ] = t.map ( QPointF ( 0 , halfSize ) );
947
- p[0 ][2 ] = p[0 ][0 ];
948
-
949
928
if ( mBrush .style () != Qt::NoBrush )
950
- e.writePolygon ( p, layerName, " SOLID" , bc );
951
-
929
+ e.writeFilledCircle ( layerName, bc, shift, halfSize );
952
930
if ( mPen .style () != Qt::NoPen )
953
- e.writePolyline ( p[0 ], layerName, " CONTINUOUS" , pc, outlineWidth );
954
- }
955
- #if 0
956
- else if ( mName == "equilateral_triangle" )
957
- {
958
-
931
+ e.writeCircle ( layerName, pc, shift, halfSize, " CONTINUOUS" , outlineWidth );
959
932
}
960
- #endif
961
- else if ( mName == " line" )
933
+ else if ( name == " line" )
962
934
{
963
- QPointF pt1 = t.map ( QPointF ( 0 , halfSize ) );
964
- QPointF pt2 = t.map ( QPointF ( 0 , - halfSize ) );
935
+ QPointF pt1 = t.map ( QPointF ( 0 , - halfSize ) );
936
+ QPointF pt2 = t.map ( QPointF ( 0 , halfSize ) );
965
937
966
938
if ( mPen .style () != Qt::NoPen )
967
939
e.writeLine ( pt1, pt2, layerName, " CONTINUOUS" , pc, outlineWidth );
968
940
}
969
- else if ( mName == " cross" )
941
+ else if ( name == " cross" )
970
942
{
971
943
if ( mPen .style () != Qt::NoPen )
972
944
{
@@ -979,20 +951,20 @@ bool QgsSimpleMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitSc
979
951
e.writeLine ( pt3, pt4, layerName, " CONTINUOUS" , pc, outlineWidth );
980
952
}
981
953
}
982
- else if ( mName == " x" || mName == " cross2" )
954
+ else if ( name == " x" || name == " cross2" )
983
955
{
984
956
if ( mPen .style () != Qt::NoPen )
985
957
{
986
958
QPointF pt1 = t.map ( QPointF ( -halfSize, -halfSize ) );
987
959
QPointF pt2 = t.map ( QPointF ( halfSize, halfSize ) );
988
- QPointF pt3 = t.map ( QPointF ( - halfSize, halfSize ) );
989
- QPointF pt4 = t.map ( QPointF ( halfSize, - halfSize ) );
960
+ QPointF pt3 = t.map ( QPointF ( halfSize, - halfSize ) );
961
+ QPointF pt4 = t.map ( QPointF ( - halfSize, halfSize ) );
990
962
991
963
e.writeLine ( pt1, pt2, layerName, " CONTINUOUS" , pc, outlineWidth );
992
964
e.writeLine ( pt3, pt4, layerName, " CONTINUOUS" , pc, outlineWidth );
993
965
}
994
966
}
995
- else if ( mName == " arrowhead" )
967
+ else if ( name == " arrowhead" )
996
968
{
997
969
if ( mPen .style () != Qt::NoPen )
998
970
{
@@ -1004,21 +976,9 @@ bool QgsSimpleMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitSc
1004
976
e.writeLine ( pt3, pt2, layerName, " CONTINUOUS" , pc, outlineWidth );
1005
977
}
1006
978
}
1007
- else if ( mName == " filled_arrowhead" )
1008
- {
1009
- if ( mBrush .style () != Qt::NoBrush )
1010
- {
1011
- QgsPolygon p ( 1 );
1012
- p[0 ].resize ( 4 );
1013
- p[0 ][0 ] = t.map ( QPointF ( -halfSize, halfSize ) );
1014
- p[0 ][1 ] = t.map ( QPointF ( 0 , 0 ) );
1015
- p[0 ][2 ] = t.map ( QPointF ( -halfSize, -halfSize ) );
1016
- p[0 ][3 ] = p[0 ][0 ];
1017
- e.writePolygon ( p, layerName, " SOLID" , bc );
1018
- }
1019
- }
1020
979
else
1021
980
{
981
+ QgsDebugMsg ( QString ( " Unsupported dxf marker name %1" ).arg ( name ) );
1022
982
return false ;
1023
983
}
1024
984
0 commit comments