Skip to content

Commit 041acd6

Browse files
committedJun 5, 2014
Fix ellipse marker dxf export
1 parent a04ebf9 commit 041acd6

File tree

1 file changed

+41
-11
lines changed

1 file changed

+41
-11
lines changed
 

‎src/core/symbology-ng/qgsellipsesymbollayerv2.cpp

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -615,14 +615,24 @@ bool QgsEllipseSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFa
615615
outlineWidth *= outlineWidth;
616616
}
617617

618-
//color
619-
QColor c = mFillColor;
618+
//fill color
619+
QColor fc = mFillColor;
620620
QgsExpression* fillColorExpression = expression( "fill_color" );
621621
if ( fillColorExpression )
622622
{
623-
c = QColor( fillColorExpression->evaluate( const_cast<QgsFeature*>( context->feature() ) ).toString() );
623+
fc = QColor( fillColorExpression->evaluate( const_cast<QgsFeature*>( context->feature() ) ).toString() );
624624
}
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+
626636

627637
//symbol name
628638
QString symbolName = mSymbolName;
@@ -665,15 +675,35 @@ bool QgsEllipseSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFa
665675

666676
if ( symbolName == "circle" )
667677
{
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+
}
669699
}
670700
else if ( symbolName == "rectangle" )
671701
{
672702
QPointF pt1( t.map( QPointF( -halfWidth, -halfHeight ) ) );
673703
QPointF pt2( t.map( QPointF( halfWidth, -halfHeight ) ) );
674704
QPointF pt3( t.map( QPointF( -halfWidth, halfHeight ) ) );
675705
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() ) );
677707
return true;
678708
}
679709
else if ( symbolName == "cross" )
@@ -683,13 +713,13 @@ bool QgsEllipseSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFa
683713
QPointF pt2( t.map( QPointF( halfWidth, 0 ) ) );
684714
line1[0] = QgsPoint( pt1.x(), pt1.y() );
685715
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 );
687717
QgsPolyline line2( 2 );
688718
QPointF pt3( t.map( QPointF( 0, halfHeight ) ) );
689-
// QPointF pt4( t.map( QPointF( 0, -halfHeight ) ) );
719+
QPointF pt4( t.map( QPointF( 0, -halfHeight ) ) );
690720
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 );
693723
return true;
694724
}
695725
else if ( symbolName == "triangle" )
@@ -698,7 +728,7 @@ bool QgsEllipseSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFa
698728
QPointF pt2( t.map( QPointF( halfWidth, -halfHeight ) ) );
699729
QPointF pt3( t.map( QPointF( 0, halfHeight ) ) );
700730
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() ) );
702732
return true;
703733
}
704734

0 commit comments

Comments
 (0)
Please sign in to comment.