Skip to content
Permalink
Browse files

Draw default point symbol if dxf export not supported by marker symbol

  • Loading branch information
mhugent committed Dec 6, 2013
1 parent 642b0d5 commit a75de2b81b8882b0d8bbb686b10707ca6bdb8758
@@ -700,7 +700,7 @@ void QgsDxfExport::endSection()
writeGroup( 0, "ENDSEC" );
}

void QgsDxfExport::writePoint( const QgsPoint& pt, const QString& layer, const QgsFeature* f, const QgsSymbolLayerV2* symbolLayer, const QgsSymbolV2* symbol )
void QgsDxfExport::writePoint( const QgsPoint& pt, const QString& layer, int color, const QgsFeature* f, const QgsSymbolLayerV2* symbolLayer, const QgsSymbolV2* symbol )
{
#if 0
//debug: draw rectangle for debugging
@@ -737,8 +737,12 @@ void QgsDxfExport::writePoint( const QgsPoint& pt, const QString& layer, const Q
{
QgsRenderContext ct;
QgsSymbolV2RenderContext ctx( ct, QgsSymbolV2::MapUnit, symbol->alpha(), false, symbol->renderHints(), f );
symbolLayer->writeDxf( *this, mapUnitScaleFactor( mSymbologyScaleDenominator, msl->sizeUnit(), mMapUnits ), layer, &ctx, f, QPointF( pt.x(), pt.y() ) );
if ( symbolLayer->writeDxf( *this, mapUnitScaleFactor( mSymbologyScaleDenominator, msl->sizeUnit(), mMapUnits ), layer, &ctx, f, QPointF( pt.x(), pt.y() ) ) )
{
return;
}
}
writePoint( layer, color, pt ); //write default point symbol
}
else
{
@@ -782,6 +786,16 @@ void QgsDxfExport::writeLine( const QgsPoint& pt1, const QgsPoint& pt2, const QS
writePolyline( line, layer, lineStyleName, color, width, false );
}

void QgsDxfExport::writePoint( const QString& layer, int color, const QgsPoint& pt )
{
writeGroup( 0, "POINT" );
writeGroup( 8, layer );
writeGroup( 62, color );
writeGroup( 10, pt.x() );
writeGroup( 20, pt.y() );
writeGroup( 30, 0.0 );
}

void QgsDxfExport::writeSolid( const QString& layer, int color, const QgsPoint& pt1, const QgsPoint& pt2, const QgsPoint& pt3, const QgsPoint& pt4 )
{
writeGroup( 0, "SOLID" );
@@ -837,15 +851,34 @@ void QgsDxfExport::addFeature( const QgsFeature& fet, const QString& layer, cons
QgsGeometry* geom = fet.geometry();
if ( geom )
{
int c = colorFromSymbolLayer( symbolLayer );
int c = 0;
if ( mSymbologyExport != NoSymbology )
{
c = colorFromSymbolLayer( symbolLayer );
}
double width = widthFromSymbolLayer( symbolLayer );
QString lineStyleName = lineStyleFromSymbolLayer( symbolLayer );
QString lineStyleName = "CONTINUOUS";
if ( mSymbologyExport != NoSymbology )
{
lineStyleFromSymbolLayer( symbolLayer );
}
QGis::WkbType geometryType = geom->wkbType();

//single point
if ( geometryType == QGis::WKBPoint || geometryType == QGis::WKBPoint25D )
{
writePoint( geom->asPoint(), layer, &fet, symbolLayer, symbol );
writePoint( geom->asPoint(), layer, c, &fet, symbolLayer, symbol );
}

//multipoint
if ( geometryType == QGis::WKBMultiPoint || geometryType == QGis::WKBMultiPoint25D )
{
QgsMultiPoint multiPoint = geom->asMultiPoint();
QgsMultiPoint::const_iterator it = multiPoint.constBegin();
for ( ; it != multiPoint.constEnd(); ++it )
{
writePoint( *it, layer, c, &fet, symbolLayer, symbol );
}
}

//single line
@@ -76,6 +76,8 @@ class QgsDxfExport
//write line (as a polyline)
void writeLine( const QgsPoint& pt1, const QgsPoint& pt2, const QString& layer, const QString& lineStyleName, int color, double width = -1 );

void writePoint( const QString& layer, int color, const QgsPoint& pt );

private:

QList< QgsMapLayer* > mLayers;
@@ -106,7 +108,7 @@ class QgsDxfExport
void startSection();
void endSection();

void writePoint( const QgsPoint& pt, const QString& layer, const QgsFeature* f, const QgsSymbolLayerV2* symbolLayer, const QgsSymbolV2* symbol );
void writePoint( const QgsPoint& pt, const QString& layer, int color, const QgsFeature* f, const QgsSymbolLayerV2* symbolLayer, const QgsSymbolV2* symbol );
void writeVertex( const QgsPoint& pt, const QString& layer );
void writeDefaultLinestyles();
void writeSymbolLayerLinestyle( const QgsSymbolLayerV2* symbolLayer );
@@ -702,7 +702,7 @@ void QgsSimpleMarkerSymbolLayerV2::drawMarker( QPainter* p, QgsSymbolV2RenderCon
}
}

void QgsSimpleMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFactor, const QString& layerName, const QgsSymbolV2RenderContext* context, const QgsFeature* f, const QPointF& shift ) const
bool QgsSimpleMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFactor, const QString& layerName, const QgsSymbolV2RenderContext* context, const QgsFeature* f, const QPointF& shift ) const
{
//data defined size?
double size = mSize;
@@ -805,6 +805,11 @@ void QgsSimpleMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitSc
QPointF pt4 = t.map( QPointF( halfSize, 0 ) );
e.writeSolid( layerName, colorIndex, QgsPoint( pt1.x(), pt1.y() ), QgsPoint( pt2.x(), pt2.y() ), QgsPoint( pt3.x(), pt3.y() ), QgsPoint( pt4.x(), pt4.y() ) );
}
else
{
return false;
}
return true;
}

//////////
@@ -1212,7 +1217,7 @@ QgsSymbolLayerV2* QgsSvgMarkerSymbolLayerV2::createFromSld( QDomElement &element
return m;
}

void QgsSvgMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFactor, const QString& layerName, const QgsSymbolV2RenderContext* context, const QgsFeature* f,
bool QgsSvgMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFactor, const QString& layerName, const QgsSymbolV2RenderContext* context, const QgsFeature* f,
const QPointF& shift ) const
{
Q_UNUSED( layerName );
@@ -1221,7 +1226,7 @@ void QgsSvgMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScale
QSvgRenderer r( mPath );
if ( !r.isValid() )
{
return;
return false;
}

QgsDxfPaintDevice pd( &e );
@@ -1296,6 +1301,7 @@ void QgsSvgMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScale
pd.setLayer( layerName );
r.render( &p );
p.end();
return true;
}

//////////
@@ -76,7 +76,7 @@ class CORE_EXPORT QgsSimpleMarkerSymbolLayerV2 : public QgsMarkerSymbolLayerV2
QgsSymbolV2::OutputUnit outlineWidthUnit() const { return mOutlineWidthUnit; }
void setOutlineWidthUnit( QgsSymbolV2::OutputUnit u ) { mOutlineWidthUnit = u; }

void writeDxf( QgsDxfExport& e, double mmMapUnitScaleFactor, const QString& layerName, const QgsSymbolV2RenderContext* context, const QgsFeature* f, const QPointF& shift = QPointF( 0.0, 0.0 ) ) const;
bool writeDxf( QgsDxfExport& e, double mmMapUnitScaleFactor, const QString& layerName, const QgsSymbolV2RenderContext* context, const QgsFeature* f, const QPointF& shift = QPointF( 0.0, 0.0 ) ) const;

protected:

@@ -159,7 +159,7 @@ class CORE_EXPORT QgsSvgMarkerSymbolLayerV2 : public QgsMarkerSymbolLayerV2
void setOutputUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit outputUnit() const;

void writeDxf( QgsDxfExport& e, double mmMapUnitScaleFactor, const QString& layerName, const QgsSymbolV2RenderContext* context, const QgsFeature* f, const QPointF& shift = QPointF( 0.0, 0.0 ) ) const;
bool writeDxf( QgsDxfExport& e, double mmMapUnitScaleFactor, const QString& layerName, const QgsSymbolV2RenderContext* context, const QgsFeature* f, const QPointF& shift = QPointF( 0.0, 0.0 ) ) const;

protected:
QString mPath;
@@ -94,8 +94,8 @@ class CORE_EXPORT QgsSymbolLayerV2
virtual void removeDataDefinedProperties();
bool hasDataDefinedProperties() const { return mDataDefinedProperties.size() > 0; }

virtual void writeDxf( QgsDxfExport& e, double mmMapUnitScaleFactor, const QString& layerName, const QgsSymbolV2RenderContext* context, const QgsFeature* f, const QPointF& shift = QPointF( 0.0, 0.0 ) ) const
{ Q_UNUSED( e ); Q_UNUSED( mmMapUnitScaleFactor ); Q_UNUSED( layerName ); Q_UNUSED( context ); Q_UNUSED( f ); Q_UNUSED( shift ); }
virtual bool writeDxf( QgsDxfExport& e, double mmMapUnitScaleFactor, const QString& layerName, const QgsSymbolV2RenderContext* context, const QgsFeature* f, const QPointF& shift = QPointF( 0.0, 0.0 ) ) const
{ Q_UNUSED( e ); Q_UNUSED( mmMapUnitScaleFactor ); Q_UNUSED( layerName ); Q_UNUSED( context ); Q_UNUSED( f ); Q_UNUSED( shift ); return false; }

protected:
QgsSymbolLayerV2( QgsSymbolV2::SymbolType type, bool locked = false )

0 comments on commit a75de2b

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