Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
jef-n committed Mar 23, 2015
1 parent 45fbb3f commit 25e4e4d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 22 deletions.
4 changes: 3 additions & 1 deletion src/core/dxf/qgsdxfexport.cpp
Expand Up @@ -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;

Expand All @@ -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 );
Expand Down Expand Up @@ -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 )
Expand Down
36 changes: 16 additions & 20 deletions src/core/dxf/qgsdxfpaintengine.cpp
Expand Up @@ -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;
}
Expand All @@ -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 );
}
}

Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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() );
}
}

Expand All @@ -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
{
Expand Down
1 change: 0 additions & 1 deletion src/core/dxf/qgsdxfpaintengine.h
Expand Up @@ -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 );
Expand Down

0 comments on commit 25e4e4d

Please sign in to comment.