Skip to content
Permalink
Browse files

dxf export:

* switch to rgb colors only (fixes black/white issues)
* fix drawing of polygon outlines
* distiguish polygon outlines from filled polygons in paint engine
  (fixes #12368)

(cherry picked from commit 25e4e4d)
  • Loading branch information
jef-n committed Mar 20, 2015
1 parent 81f9c73 commit ae954e8f37a78a5c045d80cf13b2ce7debd73f6d
Showing with 19 additions and 22 deletions.
  1. +3 −1 src/core/dxf/qgsdxfexport.cpp
  2. +16 −20 src/core/dxf/qgsdxfpaintengine.cpp
  3. +0 −1 src/core/dxf/qgsdxfpaintengine.h
@@ -418,6 +418,7 @@ void QgsDxfExport::writeGroup( int code, const QgsPoint &p, double z, bool skipz

void QgsDxfExport::writeGroup( QColor color, int exactMatchCode, int rgbCode, int transparencyCode )
{
#if 0
int minDistAt = -1;
int minDist = INT_MAX;

@@ -437,6 +438,7 @@ void QgsDxfExport::writeGroup( QColor color, int exactMatchCode, int rgbCode, in
// exact full opaque match
return;
}
#endif

int c = ( color.red() & 0xff ) * 0x10000 + ( color.green() & 0xff ) * 0x100 + ( color.blue() & 0xff );
writeGroup( rgbCode, c );
@@ -3694,7 +3696,7 @@ void QgsDxfExport::addFeature( const QgsSymbolV2RenderContext& ctx, const QStrin
QgsPolygon::const_iterator polyIt = polygon.constBegin();
for ( ; polyIt != polygon.constEnd(); ++polyIt ) // iterate over rings
{
writePolyline( geom->asPolyline(), layer, lineStyleName, penColor, width, false );
writePolyline( *polyIt, layer, lineStyleName, penColor, width, false );
}

if ( offsetPolygon != geom )
@@ -84,12 +84,19 @@ void QgsDxfPaintEngine::drawPolygon( const QPointF *points, int pointCount, Poly
polyline[i] = toDxfCoordinates( points[i] );
}

mDxf->writePolygon( polygon, mLayer, "SOLID", currentColor() );
if ( mode == QPaintEngine::PolylineMode )
{
mDxf->writePolyline( polyline, mLayer, "CONTINUOUS", mPen.color(), currentWidth(), true );
}
else
{
mDxf->writePolygon( polygon, mLayer, "SOLID", mBrush.color() );
}
}

void QgsDxfPaintEngine::drawRects( const QRectF* rects, int rectCount )
{
if ( !mDxf || !mPaintDevice || !rects )
if ( !mDxf || !mPaintDevice || !rects || mBrush.style() == Qt::NoBrush )
{
return;
}
@@ -104,7 +111,7 @@ void QgsDxfPaintEngine::drawRects( const QRectF* rects, int rectCount )
QgsPoint pt2 = toDxfCoordinates( QPointF( right, bottom ) );
QgsPoint pt3 = toDxfCoordinates( QPointF( left, top ) );
QgsPoint pt4 = toDxfCoordinates( QPointF( right, top ) );
mDxf->writeSolid( mLayer, currentColor(), pt1, pt2, pt3, pt4 );
mDxf->writeSolid( mLayer, mBrush.color(), pt1, pt2, pt3, pt4 );
}
}

@@ -162,7 +169,10 @@ void QgsDxfPaintEngine::endPolygon()
{
if ( mCurrentPolygon.size() > 1 )
{
drawPolygon( mCurrentPolygon.constData(), mCurrentPolygon.size(), QPaintEngine::OddEvenMode );
if ( mPen.style() != Qt::NoPen )
drawPolygon( mCurrentPolygon.constData(), mCurrentPolygon.size(), QPaintEngine::PolylineMode );
if ( mBrush.style() != Qt::NoBrush )
drawPolygon( mCurrentPolygon.constData(), mCurrentPolygon.size(), QPaintEngine::OddEvenMode );
}
mCurrentPolygon.clear();
}
@@ -198,7 +208,7 @@ void QgsDxfPaintEngine::endCurve()

void QgsDxfPaintEngine::drawLines( const QLineF* lines, int lineCount )
{
if ( !mDxf || !mPaintDevice || !lines )
if ( !mDxf || !mPaintDevice || !lines || mPen.style() == Qt::NoPen )
{
return;
}
@@ -207,7 +217,7 @@ void QgsDxfPaintEngine::drawLines( const QLineF* lines, int lineCount )
{
QgsPoint pt1 = toDxfCoordinates( lines[i].p1() );
QgsPoint pt2 = toDxfCoordinates( lines[i].p2() );
mDxf->writeLine( pt1, pt2, mLayer, "CONTINUOUS", currentColor(), currentWidth() );
mDxf->writeLine( pt1, pt2, mLayer, "CONTINUOUS", mPen.color(), currentWidth() );
}
}

@@ -222,20 +232,6 @@ QgsPoint QgsDxfPaintEngine::toDxfCoordinates( const QPointF& pt ) const
return QgsPoint( dxfPt.x(), dxfPt.y() );
}

QColor QgsDxfPaintEngine::currentColor() const
{
if ( !mDxf )
{
return QColor();
}

QColor c = mPen.color();
if ( mPen.style() == Qt::NoPen )
{
c = mBrush.color();
}
return c;
}

double QgsDxfPaintEngine::currentWidth() const
{
@@ -61,7 +61,6 @@ class CORE_EXPORT QgsDxfPaintEngine: public QPaintEngine
QList<QPointF> mCurrentCurve;

QgsPoint toDxfCoordinates( const QPointF& pt ) const;
QColor currentColor() const;
double currentWidth() const;

void moveTo( double dx, double dy );

0 comments on commit ae954e8

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