@@ -615,14 +615,24 @@ bool QgsEllipseSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFa
615
615
outlineWidth *= outlineWidth;
616
616
}
617
617
618
- // color
619
- QColor c = mFillColor ;
618
+ // fill color
619
+ QColor fc = mFillColor ;
620
620
QgsExpression* fillColorExpression = expression ( " fill_color" );
621
621
if ( fillColorExpression )
622
622
{
623
- c = QColor ( fillColorExpression->evaluate ( const_cast <QgsFeature*>( context->feature () ) ).toString () );
623
+ fc = QColor ( fillColorExpression->evaluate ( const_cast <QgsFeature*>( context->feature () ) ).toString () );
624
624
}
625
- int colorIndex = e.closestColorMatch ( c.rgb () );
625
+ int fillColorIndex = e.closestColorMatch ( fc.rgb () );
626
+
627
+ // outline color
628
+ QColor oc = mOutlineColor ;
629
+ QgsExpression* outlineColorExpression = expression ( " outline_color" );
630
+ if ( outlineColorExpression )
631
+ {
632
+ oc = QColor ( outlineColorExpression->evaluate ( const_cast <QgsFeature*>( context->feature () ) ).toString () );
633
+ }
634
+ int outlineColorIndex = e.closestColorMatch ( oc.rgb () );
635
+
626
636
627
637
// symbol name
628
638
QString symbolName = mSymbolName ;
@@ -665,15 +675,35 @@ bool QgsEllipseSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFa
665
675
666
676
if ( symbolName == " circle" )
667
677
{
668
- // soon...
678
+ if ( qgsDoubleNear ( halfWidth, halfHeight ) )
679
+ {
680
+ QPointF pt ( t.map ( QPointF ( 0 , 0 ) ) );
681
+ e.writeCircle ( layerName, outlineColorIndex, QgsPoint ( pt.x (), pt.y () ), halfWidth );
682
+ }
683
+ else
684
+ {
685
+ QgsPolyline line;
686
+ double stepsize = 2 * M_PI / 40 ;
687
+ for ( int i = 0 ; i < 39 ; ++i )
688
+ {
689
+ double angle = stepsize * i;
690
+ double x = halfWidth * cos ( angle );
691
+ double y = halfHeight * sin ( angle );
692
+ QPointF pt ( t.map ( QPointF ( x, y ) ) );
693
+ line.push_back ( QgsPoint ( pt.x (), pt.y () ) );
694
+ }
695
+ // close ellipse with first point
696
+ line.push_back ( line.at ( 0 ) );
697
+ e.writePolyline ( line, layerName, " solid" , outlineColorIndex, outlineWidth, true );
698
+ }
669
699
}
670
700
else if ( symbolName == " rectangle" )
671
701
{
672
702
QPointF pt1 ( t.map ( QPointF ( -halfWidth, -halfHeight ) ) );
673
703
QPointF pt2 ( t.map ( QPointF ( halfWidth, -halfHeight ) ) );
674
704
QPointF pt3 ( t.map ( QPointF ( -halfWidth, halfHeight ) ) );
675
705
QPointF pt4 ( t.map ( QPointF ( halfWidth, halfHeight ) ) );
676
- e.writeSolid ( layerName, colorIndex , QgsPoint ( pt1.x (), pt1.y () ), QgsPoint ( pt2.x (), pt2.y () ), QgsPoint ( pt3.x (), pt3.y () ), QgsPoint ( pt4.x (), pt4.y () ) );
706
+ e.writeSolid ( layerName, fillColorIndex , QgsPoint ( pt1.x (), pt1.y () ), QgsPoint ( pt2.x (), pt2.y () ), QgsPoint ( pt3.x (), pt3.y () ), QgsPoint ( pt4.x (), pt4.y () ) );
677
707
return true ;
678
708
}
679
709
else if ( symbolName == " cross" )
@@ -683,13 +713,13 @@ bool QgsEllipseSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFa
683
713
QPointF pt2 ( t.map ( QPointF ( halfWidth, 0 ) ) );
684
714
line1[0 ] = QgsPoint ( pt1.x (), pt1.y () );
685
715
line1[1 ] = QgsPoint ( pt2.x (), pt2.y () );
686
- e.writePolyline ( line1, layerName, " CONTINUOUS" , colorIndex , outlineWidth, false );
716
+ e.writePolyline ( line1, layerName, " CONTINUOUS" , outlineColorIndex , outlineWidth, false );
687
717
QgsPolyline line2 ( 2 );
688
718
QPointF pt3 ( t.map ( QPointF ( 0 , halfHeight ) ) );
689
- // QPointF pt4( t.map( QPointF( 0, -halfHeight ) ) );
719
+ QPointF pt4 ( t.map ( QPointF ( 0 , -halfHeight ) ) );
690
720
line2[0 ] = QgsPoint ( pt3.x (), pt3.y () );
691
- line2[1 ] = QgsPoint ( pt3 .x (), pt3 .y () );
692
- e.writePolyline ( line2, layerName, " CONTINUOUS" , colorIndex , outlineWidth, false );
721
+ line2[1 ] = QgsPoint ( pt4 .x (), pt4 .y () );
722
+ e.writePolyline ( line2, layerName, " CONTINUOUS" , outlineColorIndex , outlineWidth, false );
693
723
return true ;
694
724
}
695
725
else if ( symbolName == " triangle" )
@@ -698,7 +728,7 @@ bool QgsEllipseSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFa
698
728
QPointF pt2 ( t.map ( QPointF ( halfWidth, -halfHeight ) ) );
699
729
QPointF pt3 ( t.map ( QPointF ( 0 , halfHeight ) ) );
700
730
QPointF pt4 ( t.map ( QPointF ( 0 , halfHeight ) ) );
701
- e.writeSolid ( layerName, colorIndex , QgsPoint ( pt1.x (), pt1.y () ), QgsPoint ( pt2.x (), pt2.y () ), QgsPoint ( pt3.x (), pt3.y () ), QgsPoint ( pt4.x (), pt4.y () ) );
731
+ e.writeSolid ( layerName, fillColorIndex , QgsPoint ( pt1.x (), pt1.y () ), QgsPoint ( pt2.x (), pt2.y () ), QgsPoint ( pt3.x (), pt3.y () ), QgsPoint ( pt4.x (), pt4.y () ) );
702
732
return true ;
703
733
}
704
734
0 commit comments