Skip to content

Commit

Permalink
Consider PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent authored and nyalldawson committed Jun 17, 2018
1 parent 49cce29 commit e76ca64
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion python/core/auto_generated/dxf/qgsdxfexport.sip.in
Expand Up @@ -397,7 +397,7 @@ Write mtext (MTEXT)
.. versionadded:: 2.15
%End

static double mapUnitScaleFactor( double scaleDenominator, QgsUnitTypes::RenderUnit symbolUnits, QgsUnitTypes::DistanceUnit mapUnits, double mapUnitsPerPixel = 1.0 );
static double mapUnitScaleFactor( double scale, QgsUnitTypes::RenderUnit symbolUnits, QgsUnitTypes::DistanceUnit mapUnits, double mapUnitsPerPixel = 1.0 );
%Docstring
Returns scale factor for conversion to map units

Expand Down
17 changes: 10 additions & 7 deletions src/core/dxf/qgsdxfexport.cpp
Expand Up @@ -999,7 +999,12 @@ void QgsDxfExport::writeEntities()
continue;
}

ctx.expressionContext().appendScope( QgsExpressionContextUtils::layerScope( ml ) );
auto scopePopper = [&ctx]( QgsExpressionContextScope * scope )
{
delete ctx.expressionContext().popScope();
};
std::unique_ptr<QgsExpressionContextScope, decltype( scopePopper ) > layerScope( QgsExpressionContextUtils::layerScope( ml ), scopePopper );
ctx.expressionContext().appendScope( layerScope.get() );
QgsSymbolRenderContext sctx( ctx, QgsUnitTypes::RenderMillimeters, 1.0, false, nullptr, nullptr );

std::unique_ptr< QgsFeatureRenderer > renderer( vl->renderer()->clone() );
Expand Down Expand Up @@ -1048,7 +1053,6 @@ void QgsDxfExport::writeEntities()
writeEntitiesSymbolLevels( vl );
renderer->stopRender( ctx );

delete ctx.expressionContext().popScope();
continue;
}

Expand Down Expand Up @@ -1089,7 +1093,7 @@ void QgsDxfExport::writeEntities()
continue;
}

bool isGeometryGenerator = ( sl->layerType() == "GeometryGenerator" );
bool isGeometryGenerator = ( sl->layerType() == QLatin1String( "GeometryGenerator" ) );
if ( isGeometryGenerator )
{
addGeometryGeneratorSymbolLayer( sctx, ct, lName, sl, true );
Expand All @@ -1110,7 +1114,7 @@ void QgsDxfExport::writeEntities()
continue;
}

if ( s->symbolLayer( 0 )->layerType() == "GeometryGenerator" )
if ( s->symbolLayer( 0 )->layerType() == QLatin1String( "GeometryGenerator" ) )
{
addGeometryGeneratorSymbolLayer( sctx, ct, lName, s->symbolLayer( 0 ), false );
}
Expand All @@ -1132,7 +1136,6 @@ void QgsDxfExport::writeEntities()
}

renderer->stopRender( ctx );
delete ctx.expressionContext().popScope();
}

engine.run( ctx );
Expand Down Expand Up @@ -3989,15 +3992,15 @@ QgsRenderContext QgsDxfExport::renderContext() const
return context;
}

double QgsDxfExport::mapUnitScaleFactor( double scaleDenominator, QgsUnitTypes::RenderUnit symbolUnits, QgsUnitTypes::DistanceUnit mapUnits, double mapUnitsPerPixel )
double QgsDxfExport::mapUnitScaleFactor( double scale, QgsUnitTypes::RenderUnit symbolUnits, QgsUnitTypes::DistanceUnit mapUnits, double mapUnitsPerPixel )
{
if ( symbolUnits == QgsUnitTypes::RenderMapUnits )
{
return 1.0;
}
else if ( symbolUnits == QgsUnitTypes::RenderMillimeters )
{
return ( scaleDenominator * QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::DistanceMeters, mapUnits ) / 1000.0 );
return ( scale * QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::DistanceMeters, mapUnits ) / 1000.0 );
}
else if ( symbolUnits == QgsUnitTypes::RenderPixels )
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/dxf/qgsdxfexport.h
Expand Up @@ -391,7 +391,7 @@ class CORE_EXPORT QgsDxfExport
* \param mapUnits the map units
* \param mapUnitsPerPixel Map units per pixel
*/
static double mapUnitScaleFactor( double scaleDenominator, QgsUnitTypes::RenderUnit symbolUnits, QgsUnitTypes::DistanceUnit mapUnits, double mapUnitsPerPixel = 1.0 );
static double mapUnitScaleFactor( double scale, QgsUnitTypes::RenderUnit symbolUnits, QgsUnitTypes::DistanceUnit mapUnits, double mapUnitsPerPixel = 1.0 );

/**
* Clips value to scale minimum/maximum
Expand Down
1 change: 0 additions & 1 deletion src/core/dxf/qgsdxfpaintengine.cpp
Expand Up @@ -24,7 +24,6 @@ QgsDxfPaintEngine::QgsDxfPaintEngine( const QgsDxfPaintDevice *dxfDevice, QgsDxf
: QPaintEngine( QPaintEngine::AllFeatures /*QPaintEngine::PainterPaths | QPaintEngine::PaintOutsidePaintEvent*/ )
, mPaintDevice( dxfDevice )
, mDxf( dxf )
, mOpacity( 1.0 )
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/dxf/qgsdxfpaintengine.h
Expand Up @@ -65,7 +65,7 @@ class CORE_EXPORT QgsDxfPaintEngine: public QPaintEngine
QPen mPen;
QBrush mBrush;
//! Opacity
double mOpacity;
double mOpacity = 1.0;
QString mLayer;
QPointF mShift;
QgsRingSequence mPolygon;
Expand Down

0 comments on commit e76ca64

Please sign in to comment.