@@ -417,7 +417,7 @@ void QgsDxfExport::writeTables()
417
417
writeGroup ( 2 , " TABLES" );
418
418
419
419
// iterate through all layers and get symbol layer pointers
420
- QList<QgsSymbolLayerV2*> slList;
420
+ QList< QPair< QgsSymbolLayerV2*, QgsSymbolV2*> > slList;
421
421
if ( mSymbologyExport != NoSymbology )
422
422
{
423
423
slList = symbolLayers ();
@@ -439,10 +439,10 @@ void QgsDxfExport::writeTables()
439
439
writeGroup ( 40 , 0.0 );
440
440
441
441
// add symbol layer linestyles
442
- QList<QgsSymbolLayerV2*>::const_iterator slIt = slList.constBegin ();
442
+ QList< QPair< QgsSymbolLayerV2*, QgsSymbolV2*> >::const_iterator slIt = slList.constBegin ();
443
443
for ( ; slIt != slList.constEnd (); ++slIt )
444
444
{
445
- writeSymbolLayerLinestyle ( * slIt );
445
+ writeSymbolLayerLinestyle ( slIt-> first );
446
446
}
447
447
448
448
writeGroup ( 0 , " ENDTAB" );
@@ -472,20 +472,24 @@ void QgsDxfExport::writeBlocks()
472
472
writeGroup ( 2 , " BLOCKS" );
473
473
474
474
// iterate through all layers and get symbol layer pointers
475
- QList<QgsSymbolLayerV2*> slList;
475
+ QList< QPair< QgsSymbolLayerV2*, QgsSymbolV2* > > slList;
476
476
if ( mSymbologyExport != NoSymbology )
477
477
{
478
478
slList = symbolLayers ();
479
479
}
480
480
481
- QList<QgsSymbolLayerV2*>::const_iterator slIt = slList.constBegin ();
481
+ QList< QPair< QgsSymbolLayerV2*, QgsSymbolV2* > >::const_iterator slIt = slList.constBegin ();
482
482
for ( ; slIt != slList.constEnd (); ++slIt )
483
483
{
484
484
// if point symbol layer and no data defined properties: write block
485
- QgsMarkerSymbolLayerV2* ml = dynamic_cast < QgsMarkerSymbolLayerV2*>( * slIt );
485
+ QgsMarkerSymbolLayerV2* ml = dynamic_cast < QgsMarkerSymbolLayerV2*>( slIt-> first );
486
486
if ( ml )
487
487
{
488
- // todo: find out if the marker symbol layer has data defined properties (in that case don't insert it)
488
+ // markers with data defined properties are inserted inline
489
+ if ( hasDataDefinedProperties ( ml, slIt->second ) )
490
+ {
491
+ continue ;
492
+ }
489
493
writeGroup ( 0 , " BLOCK" );
490
494
writeGroup ( 8 , 0 );
491
495
QString blockName = QString ( " symbolLayer%1" ).arg ( mBlockCounter );
@@ -501,7 +505,7 @@ void QgsDxfExport::writeBlocks()
501
505
writeGroup ( 30 , 0 );
502
506
writeGroup ( 3 , blockName );
503
507
504
- ml->writeDxf ( *this , mapUnitScaleFactor ( mSymbologyScaleDenominator , ml->sizeUnit (), mMapUnits ), " 0" ); // maplayer 0 -> block receives layer from INSERT statement
508
+ ml->writeDxf ( *this , mapUnitScaleFactor ( mSymbologyScaleDenominator , ml->sizeUnit (), mMapUnits ), " 0" , 0 , 0 ); // maplayer 0 -> block receives layer from INSERT statement
505
509
506
510
writeGroup ( 0 , " ENDBLK" );
507
511
writeGroup ( 8 , 0 );
@@ -548,7 +552,7 @@ void QgsDxfExport::writeEntities()
548
552
{
549
553
if ( mSymbologyExport == NoSymbology )
550
554
{
551
- addFeature ( fet, vl->name (), 0 ); // no symbology at all
555
+ addFeature ( fet, vl->name (), 0 , 0 ); // no symbology at all
552
556
}
553
557
else
554
558
{
@@ -568,7 +572,7 @@ void QgsDxfExport::writeEntities()
568
572
{
569
573
continue ;
570
574
}
571
- addFeature ( fet, vl->name (), s->symbolLayer ( 0 ) );
575
+ addFeature ( fet, vl->name (), s->symbolLayer ( 0 ), s );
572
576
}
573
577
}
574
578
}
@@ -652,7 +656,7 @@ void QgsDxfExport::writeEntitiesSymbolLevels( QgsVectorLayer* layer )
652
656
QList<QgsFeature>::iterator featureIt = featureList.begin ();
653
657
for ( ; featureIt != featureList.end (); ++featureIt )
654
658
{
655
- addFeature ( *featureIt, layer->name (), levelIt.key ()->symbolLayer ( llayer ) );
659
+ addFeature ( *featureIt, layer->name (), levelIt.key ()->symbolLayer ( llayer ), levelIt. key () );
656
660
}
657
661
}
658
662
}
@@ -674,7 +678,7 @@ void QgsDxfExport::endSection()
674
678
writeGroup ( 0 , " ENDSEC" );
675
679
}
676
680
677
- void QgsDxfExport::writePoint ( const QgsPoint& pt, const QString& layer, const QgsSymbolLayerV2* symbolLayer )
681
+ void QgsDxfExport::writePoint ( const QgsPoint& pt, const QString& layer, const QgsFeature* f, const QgsSymbolLayerV2* symbolLayer, const QgsSymbolV2* symbol )
678
682
{
679
683
#if 0
680
684
//debug: draw rectangle for debugging
@@ -706,10 +710,17 @@ void QgsDxfExport::writePoint( const QgsPoint& pt, const QString& layer, const Q
706
710
if ( !symbolLayer || blockIt == mPointSymbolBlocks .constEnd () )
707
711
{
708
712
// write symbol directly here
713
+ const QgsMarkerSymbolLayerV2* msl = dynamic_cast < const QgsMarkerSymbolLayerV2* >( symbolLayer );
714
+ if ( symbolLayer && symbol )
715
+ {
716
+ QgsRenderContext ct;
717
+ QgsSymbolV2RenderContext ctx ( ct, QgsSymbolV2::MapUnit, symbol->alpha (), false , symbol->renderHints (), f );
718
+ symbolLayer->writeDxf ( *this , mapUnitScaleFactor ( mSymbologyScaleDenominator , msl->sizeUnit (), mMapUnits ), layer, &ctx, f, QPointF ( pt.x (), pt.y () ) );
719
+ }
709
720
}
710
721
else
711
722
{
712
- // insert block
723
+ // insert block reference
713
724
writeGroup ( 0 , " INSERT" );
714
725
writeGroup ( 8 , layer );
715
726
writeGroup ( 2 , blockIt.value () );
@@ -799,7 +810,7 @@ QgsRectangle QgsDxfExport::dxfExtent() const
799
810
return extent;
800
811
}
801
812
802
- void QgsDxfExport::addFeature ( const QgsFeature& fet, const QString& layer, const QgsSymbolLayerV2* symbolLayer )
813
+ void QgsDxfExport::addFeature ( const QgsFeature& fet, const QString& layer, const QgsSymbolLayerV2* symbolLayer, const QgsSymbolV2* symbol )
803
814
{
804
815
QgsGeometry* geom = fet.geometry ();
805
816
if ( geom )
@@ -820,7 +831,7 @@ void QgsDxfExport::addFeature( const QgsFeature& fet, const QString& layer, cons
820
831
// single point
821
832
if ( geometryType == QGis::WKBPoint || geometryType == QGis::WKBPoint25D )
822
833
{
823
- writePoint ( geom->asPoint (), layer, symbolLayer );
834
+ writePoint ( geom->asPoint (), layer, &fet, symbolLayer, symbol );
824
835
}
825
836
826
837
// single line
@@ -1006,9 +1017,9 @@ double QgsDxfExport::mapUnitScaleFactor( double scaleDenominator, QgsSymbolV2::O
1006
1017
return 1.0 ;
1007
1018
}
1008
1019
1009
- QList<QgsSymbolLayerV2*> QgsDxfExport::symbolLayers ()
1020
+ QList< QPair< QgsSymbolLayerV2*, QgsSymbolV2* > > QgsDxfExport::symbolLayers ()
1010
1021
{
1011
- QList<QgsSymbolLayerV2*> symbolLayers;
1022
+ QList< QPair< QgsSymbolLayerV2*, QgsSymbolV2* > > symbolLayers;
1012
1023
1013
1024
QList< QgsMapLayer* >::iterator lIt = mLayers .begin ();
1014
1025
for ( ; lIt != mLayers .end (); ++lIt )
@@ -1039,7 +1050,7 @@ QList<QgsSymbolLayerV2*> QgsDxfExport::symbolLayers()
1039
1050
}
1040
1051
for ( int i = 0 ; i < maxSymbolLayers; ++i )
1041
1052
{
1042
- symbolLayers.append (( *symbolIt )->symbolLayer ( i ) ) ;
1053
+ symbolLayers.append ( qMakePair (( *symbolIt )->symbolLayer ( i ), *symbolIt ) ) ;
1043
1054
}
1044
1055
}
1045
1056
}
@@ -1069,13 +1080,13 @@ void QgsDxfExport::writeSymbolLayerLinestyle( const QgsSymbolLayerV2* symbolLaye
1069
1080
}
1070
1081
}
1071
1082
1072
- int QgsDxfExport::nLineTypes ( const QList<QgsSymbolLayerV2*>& symbolLayers )
1083
+ int QgsDxfExport::nLineTypes ( const QList< QPair< QgsSymbolLayerV2*, QgsSymbolV2* > >& symbolLayers )
1073
1084
{
1074
1085
int nLineTypes = 0 ;
1075
- QList<QgsSymbolLayerV2*>::const_iterator slIt = symbolLayers.constBegin ();
1086
+ QList< QPair< QgsSymbolLayerV2*, QgsSymbolV2*> >::const_iterator slIt = symbolLayers.constBegin ();
1076
1087
for ( ; slIt != symbolLayers.constEnd (); ++slIt )
1077
1088
{
1078
- const QgsSimpleLineSymbolLayerV2* simpleLine = dynamic_cast < const QgsSimpleLineSymbolLayerV2* >( * slIt );
1089
+ const QgsSimpleLineSymbolLayerV2* simpleLine = dynamic_cast < const QgsSimpleLineSymbolLayerV2* >( slIt-> first );
1079
1090
if ( simpleLine )
1080
1091
{
1081
1092
if ( simpleLine->useCustomDashPattern () )
@@ -1116,6 +1127,22 @@ void QgsDxfExport::writeLinestyle( const QString& styleName, const QVector<qreal
1116
1127
}
1117
1128
}
1118
1129
1130
+ bool QgsDxfExport::hasDataDefinedProperties ( const QgsSymbolLayerV2* sl, const QgsSymbolV2* symbol )
1131
+ {
1132
+ if ( !sl || !symbol )
1133
+ {
1134
+ return false ;
1135
+ }
1136
+
1137
+ if ( symbol->renderHints () | QgsSymbolV2::DataDefinedSizeScale ||
1138
+ symbol->renderHints () | QgsSymbolV2::DataDefinedRotation )
1139
+ {
1140
+ return true ;
1141
+ }
1142
+
1143
+ return sl->hasDataDefinedProperties ();
1144
+ }
1145
+
1119
1146
/* *****************************************************Test with AC_1018 methods***************************************************************/
1120
1147
1121
1148
void QgsDxfExport::writeHeaderAC1018 ( QTextStream& stream )
@@ -1256,7 +1283,7 @@ void QgsDxfExport::writeTablesAC1018( QTextStream& stream )
1256
1283
QList<QgsSymbolLayerV2*> slList;
1257
1284
if ( mSymbologyExport != NoSymbology )
1258
1285
{
1259
- slList = symbolLayers ();
1286
+ // slList = symbolLayers(); //todo...
1260
1287
}
1261
1288
1262
1289
// LTYPE
@@ -1270,7 +1297,7 @@ void QgsDxfExport::writeTablesAC1018( QTextStream& stream )
1270
1297
stream << " 100\n " ;
1271
1298
stream << " AcDbSymbolTable\n " ;
1272
1299
stream << " 70\n " ;
1273
- stream << QString ( " %1\n " ).arg ( nLineTypes ( slList ) + 1 ); // number of linetypes
1300
+ // stream << QString( "%1\n" ).arg( nLineTypes( slList ) + 1 ); //number of linetypes
1274
1301
1275
1302
// add continuous style as default
1276
1303
stream << " 0\n " ;
0 commit comments