Skip to content
Permalink
Browse files
Fix dxf label export
  • Loading branch information
mhugent committed Jun 6, 2014
1 parent 0a491b5 commit 211399cec613c256e8a5f4e7bd5c3d0b51d9e7e0
Showing with 13 additions and 7 deletions.
  1. +2 −2 src/core/dxf/qgsdxfexport.cpp
  2. +10 −5 src/core/dxf/qgsdxfpallabeling.cpp
  3. +1 −0 src/core/dxf/qgsdxfpallabeling.h
@@ -585,7 +585,8 @@ void QgsDxfExport::writeEntities()

bool labelLayer = ( labelEngine.prepareLayer( vl, attributes, ctx ) != 0 );

if ( mSymbologyExport == QgsDxfExport::SymbolLayerSymbology && renderer->usingSymbolLevels() )
if ( mSymbologyExport == QgsDxfExport::SymbolLayerSymbology && ( renderer->capabilities() & QgsFeatureRendererV2::SymbolLevels ) &&
renderer->usingSymbolLevels() )
{
writeEntitiesSymbolLevels( vl );
renderer->stopRender( ctx );
@@ -652,7 +653,6 @@ void QgsDxfExport::writeEntities()
}

labelEngine.drawLabeling( ctx );

endSection();
}

@@ -29,15 +29,19 @@ using namespace pal;
QgsDxfPalLabeling::QgsDxfPalLabeling( QgsDxfExport* dxf, const QgsRectangle& bbox, double scale, QGis::UnitType mapUnits )
: QgsPalLabeling()
, mDxfExport( dxf )
, mImage( 0 )
, mPainter( 0 )
{
QgsMapSettings settings;
settings.setExtent( bbox );
mSettings = new QgsMapSettings;
mSettings->setMapUnits( mapUnits );
mSettings->setExtent( bbox );

int dpi = 96;
double factor = 1000 * dpi / scale / 25.4 * QGis::fromUnitToUnitFactor( mapUnits, QGis::Meters );
settings.setOutputSize( QSize( bbox.width() * factor, bbox.height() * factor ) );
settings.setOutputDpi( dpi );
init( settings );
mSettings->setOutputSize( QSize( bbox.width() * factor, bbox.height() * factor ) );
mSettings->setOutputDpi( dpi );
mSettings->setCrsTransformEnabled( false );
init( *mSettings );

mImage = new QImage( 10, 10, QImage::Format_ARGB32_Premultiplied );
mImage->setDotsPerMeterX( 96 / 25.4 * 1000 );
@@ -54,6 +58,7 @@ QgsDxfPalLabeling::~QgsDxfPalLabeling()
{
delete mPainter;
delete mImage;
delete mSettings;
}

void QgsDxfPalLabeling::drawLabel( pal::LabelPosition* label, QgsRenderContext& context, QgsPalLayerSettings& tmpLyr, DrawLabelType drawType, double dpiRatio )
@@ -40,6 +40,7 @@ class CORE_EXPORT QgsDxfPalLabeling: public QgsPalLabeling
//only used for render context
QImage* mImage;
QPainter* mPainter;
QgsMapSettings* mSettings;
};

#endif // QGSDXFPALLABELING_H

0 comments on commit 211399c

Please sign in to comment.