Skip to content

Commit

Permalink
Fix dxf label export
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Jun 6, 2014
1 parent 0a491b5 commit 211399c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/core/dxf/qgsdxfexport.cpp
Expand Up @@ -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 );
Expand Down Expand Up @@ -652,7 +653,6 @@ void QgsDxfExport::writeEntities()
}

labelEngine.drawLabeling( ctx );

endSection();
}

Expand Down
15 changes: 10 additions & 5 deletions src/core/dxf/qgsdxfpallabeling.cpp
Expand Up @@ -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 );
Expand All @@ -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 )
Expand Down
1 change: 1 addition & 0 deletions src/core/dxf/qgsdxfpallabeling.h
Expand Up @@ -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.