Skip to content
Permalink
Browse files

dxf export: fix detection of close polylines

  • Loading branch information
jef-n committed May 11, 2015
1 parent 2863f20 commit 74f10b9b0302e6fde6ec4a752d68310d415ba7d5
@@ -66,8 +66,7 @@ class QgsDxfExport
int writeHandle( int code = 5, int handle = 0 );

//draw dxf primitives
void writePolyline( const QgsPolyline &line, const QString &layer, const QString &lineStyleName, QColor color,
double width = -1, bool polygon = false );
void writePolyline( const QgsPolyline &line, const QString &layer, const QString &lineStyleName, QColor color, double width = -1 );

void writePolygon( const QgsPolygon &polygon, const QString &layer, const QString &hatchPattern, QColor color );

@@ -3338,8 +3338,7 @@ void QgsDxfExport::writePoint( const QgsPoint& pt, const QString& layer, QColor
}
}

void QgsDxfExport::writePolyline( const QgsPolyline& line, const QString& layer, const QString& lineStyleName, QColor color,
double width, bool polygon )
void QgsDxfExport::writePolyline( const QgsPolyline& line, const QString& layer, const QString& lineStyleName, QColor color, double width )
{
writeGroup( 0, "LWPOLYLINE" );
writeHandle();
@@ -3349,16 +3348,17 @@ void QgsDxfExport::writePolyline( const QgsPolyline& line, const QString& layer,
writeGroup( 6, lineStyleName );
writeGroup( color );

writeGroup( 90, line.size() );
bool polygon = line[0] == line[ line.size() - 1 ];
int n = line.size();
if ( polygon )
--n;

writeGroup( 90, n );
writeGroup( 70, polygon ? 1 : 0 );
writeGroup( 43, width );

QgsPolyline::const_iterator lineIt = line.constBegin();
for ( ; lineIt != line.constEnd(); ++lineIt )
{
writeGroup( 0, *lineIt );
}
for ( int i = 0; i < n; i++ )
writeGroup( 0, line[i] );
}

void QgsDxfExport::writePolygon( const QgsPolygon& polygon, const QString& layer, const QString& hatchPattern, QColor color )
@@ -3405,7 +3405,7 @@ void QgsDxfExport::writeLine( const QgsPoint& pt1, const QgsPoint& pt2, const QS
QgsPolyline line( 2 );
line[0] = pt1;
line[1] = pt2;
writePolyline( line, layer, lineStyleName, color, width, false );
writePolyline( line, layer, lineStyleName, color, width );
}

void QgsDxfExport::writePoint( const QString& layer, QColor color, const QgsPoint& pt )
@@ -3652,7 +3652,7 @@ void QgsDxfExport::addFeature( const QgsSymbolV2RenderContext& ctx, const QStrin
if ( !offsetLine )
offsetLine = nonConstGeom;

writePolyline( offsetLine->asPolyline(), layer, lineStyleName, penColor, width, false );
writePolyline( offsetLine->asPolyline(), layer, lineStyleName, penColor, width );

if ( offsetLine != nonConstGeom )
delete offsetLine;
@@ -3671,7 +3671,7 @@ void QgsDxfExport::addFeature( const QgsSymbolV2RenderContext& ctx, const QStrin
QgsMultiPolyline::const_iterator lIt = multiLine.constBegin();
for ( ; lIt != multiLine.constEnd(); ++lIt )
{
writePolyline( *lIt, layer, lineStyleName, penColor, width, false );
writePolyline( *lIt, layer, lineStyleName, penColor, width );
}

if ( offsetLine != nonConstGeom )
@@ -3691,7 +3691,7 @@ void QgsDxfExport::addFeature( const QgsSymbolV2RenderContext& ctx, const QStrin
QgsPolygon::const_iterator polyIt = polygon.constBegin();
for ( ; polyIt != polygon.constEnd(); ++polyIt ) // iterate over rings
{
writePolyline( *polyIt, layer, lineStyleName, penColor, width, false );
writePolyline( *polyIt, layer, lineStyleName, penColor, width );
}

if ( offsetPolygon != nonConstGeom )
@@ -3714,7 +3714,7 @@ void QgsDxfExport::addFeature( const QgsSymbolV2RenderContext& ctx, const QStrin
QgsPolygon::const_iterator polyIt = mpIt->constBegin();
for ( ; polyIt != mpIt->constEnd(); ++polyIt )
{
writePolyline( *polyIt, layer, lineStyleName, penColor, width, true );
writePolyline( *polyIt, layer, lineStyleName, penColor, width );
}
}

@@ -79,8 +79,7 @@ class CORE_EXPORT QgsDxfExport
int writeHandle( int code = 5, int handle = 0 );

//! draw dxf primitives
void writePolyline( const QgsPolyline &line, const QString &layer, const QString &lineStyleName, QColor color,
double width = -1, bool polygon = false );
void writePolyline( const QgsPolyline &line, const QString &layer, const QString &lineStyleName, QColor color, double width = -1 );

void writePolygon( const QgsPolygon &polygon, const QString &layer, const QString &hatchPattern, QColor color );

@@ -86,7 +86,7 @@ void QgsDxfPaintEngine::drawPolygon( const QPointF *points, int pointCount, Poly

if ( mode == QPaintEngine::PolylineMode )
{
mDxf->writePolyline( polyline, mLayer, "CONTINUOUS", mPen.color(), currentWidth(), true );
mDxf->writePolyline( polyline, mLayer, "CONTINUOUS", mPen.color(), currentWidth() );
}
else
{
@@ -670,7 +670,7 @@ bool QgsEllipseSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFa
}
//close ellipse with first point
line.push_back( line.at( 0 ) );
e.writePolyline( line, layerName, "SOLID", oc, outlineWidth, true );
e.writePolyline( line, layerName, "SOLID", oc, outlineWidth );
}
}
else if ( symbolName == "rectangle" )
@@ -689,13 +689,13 @@ bool QgsEllipseSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFa
QPointF pt2( t.map( QPointF( halfWidth, 0 ) ) );
line1[0] = pt1;
line1[1] = pt2;
e.writePolyline( line1, layerName, "CONTINUOUS", oc, outlineWidth, false );
e.writePolyline( line1, layerName, "CONTINUOUS", oc, outlineWidth );
QgsPolyline line2( 2 );
QPointF pt3( t.map( QPointF( 0, halfHeight ) ) );
QPointF pt4( t.map( QPointF( 0, -halfHeight ) ) );
line2[0] = pt3;
line2[1] = pt4;
e.writePolyline( line2, layerName, "CONTINUOUS", oc, outlineWidth, false );
e.writePolyline( line2, layerName, "CONTINUOUS", oc, outlineWidth );
return true;
}
else if ( symbolName == "triangle" )

0 comments on commit 74f10b9

Please sign in to comment.
You can’t perform that action at this time.