mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
dxf export: add support for expression contexts and rotated symbols (fixes #14495)
This commit is contained in:
parent
f19a35c34e
commit
c30f71ac73
@ -21,7 +21,7 @@ class QgsEllipseSymbolLayerV2 : QgsMarkerSymbolLayerV2
|
||||
void toSld( QDomDocument& doc, QDomElement &element, const QgsStringMap& props ) const;
|
||||
void writeSldMarker( QDomDocument& doc, QDomElement &element, const QgsStringMap& props ) const;
|
||||
|
||||
bool writeDxf( QgsDxfExport& e, double mmMapUnitScaleFactor, const QString& layerName, QgsSymbolV2RenderContext* context, const QgsFeature* f, QPointF shift = QPointF( 0.0, 0.0 ) ) const;
|
||||
bool writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolV2RenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) ) const;
|
||||
|
||||
void setSymbolName( const QString& name );
|
||||
QString symbolName() const;
|
||||
|
@ -93,7 +93,7 @@ class QgsSimpleMarkerSymbolLayerV2 : QgsMarkerSymbolLayerV2
|
||||
void setOutlineWidthMapUnitScale( const QgsMapUnitScale& scale);
|
||||
const QgsMapUnitScale& outlineWidthMapUnitScale() const;
|
||||
|
||||
bool writeDxf( QgsDxfExport& e, double mmMapUnitScaleFactor, const QString& layerName, QgsSymbolV2RenderContext* context, const QgsFeature* f, QPointF shift = QPointF( 0.0, 0.0 ) ) const;
|
||||
bool writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolV2RenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) ) const;
|
||||
|
||||
void setOutputUnit( QgsSymbolV2::OutputUnit unit );
|
||||
QgsSymbolV2::OutputUnit outputUnit() const;
|
||||
@ -172,7 +172,7 @@ class QgsSvgMarkerSymbolLayerV2 : QgsMarkerSymbolLayerV2
|
||||
void setMapUnitScale( const QgsMapUnitScale& scale );
|
||||
QgsMapUnitScale mapUnitScale() const;
|
||||
|
||||
bool writeDxf( QgsDxfExport& e, double mmMapUnitScaleFactor, const QString& layerName, QgsSymbolV2RenderContext* context, const QgsFeature* f, QPointF shift = QPointF( 0.0, 0.0 ) ) const;
|
||||
bool writeDxf( QgsDxfExport& e, double mmMapUnitScaleFactor, const QString& layerName, QgsSymbolV2RenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) ) const;
|
||||
|
||||
QRectF bounds( QPointF point, QgsSymbolV2RenderContext& context );
|
||||
};
|
||||
|
@ -252,17 +252,13 @@ class QgsSymbolLayerV2
|
||||
*/
|
||||
virtual QVariant evaluateDataDefinedProperty( const QString& property, const QgsSymbolV2RenderContext& context, const QVariant& defaultVal = QVariant(), bool *ok = 0 ) const;
|
||||
|
||||
virtual bool writeDxf( QgsDxfExport& e,
|
||||
double mmMapUnitScaleFactor,
|
||||
const QString& layerName,
|
||||
QgsSymbolV2RenderContext* context,
|
||||
const QgsFeature* f,
|
||||
QPointF shift = QPointF( 0.0, 0.0 ) ) const;
|
||||
virtual bool writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolV2RenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) ) const;
|
||||
|
||||
virtual double dxfWidth( const QgsDxfExport& e, QgsSymbolV2RenderContext& context ) const;
|
||||
virtual double dxfOffset( const QgsDxfExport& e, QgsSymbolV2RenderContext& context ) const;
|
||||
|
||||
virtual QColor dxfColor( QgsSymbolV2RenderContext& context ) const;
|
||||
virtual double dxfAngle( QgsSymbolV2RenderContext& context ) const;
|
||||
|
||||
virtual QVector<qreal> dxfCustomDashPattern( QgsSymbolV2::OutputUnit& unit ) const;
|
||||
virtual Qt::PenStyle dxfPenStyle() const;
|
||||
|
@ -870,7 +870,7 @@ void QgsDxfExport::writeBlocks()
|
||||
writeGroup( 1, "" );
|
||||
|
||||
// maplayer 0 -> block receives layer from INSERT statement
|
||||
ml->writeDxf( *this, mapUnitScaleFactor( mSymbologyScaleDenominator, ml->sizeUnit(), mMapUnits ), "0", &ctx, nullptr );
|
||||
ml->writeDxf( *this, mapUnitScaleFactor( mSymbologyScaleDenominator, ml->sizeUnit(), mMapUnits ), "0", ctx );
|
||||
|
||||
writeGroup( 0, "ENDBLK" );
|
||||
writeHandle();
|
||||
@ -984,7 +984,7 @@ void QgsDxfExport::writeEntities()
|
||||
continue;
|
||||
}
|
||||
|
||||
QgsFeatureRequest freq = QgsFeatureRequest().setSubsetOfAttributes( attributes, vl->fields() );
|
||||
QgsFeatureRequest freq = QgsFeatureRequest().setSubsetOfAttributes( attributes, vl->fields() ).setExpressionContext( ctx.expressionContext() );
|
||||
if ( !mExtent.isEmpty() )
|
||||
{
|
||||
freq.setFilterRect( mExtent );
|
||||
@ -3329,7 +3329,7 @@ void QgsDxfExport::endSection()
|
||||
writeGroup( 0, "ENDSEC" );
|
||||
}
|
||||
|
||||
void QgsDxfExport::writePoint( const QgsPoint& pt, const QString& layer, const QColor& color, const QgsFeature* f, const QgsSymbolLayerV2* symbolLayer, const QgsSymbolV2* symbol )
|
||||
void QgsDxfExport::writePoint( const QgsPoint& pt, const QString& layer, const QColor& color, QgsSymbolV2RenderContext &ctx, const QgsSymbolLayerV2* symbolLayer, const QgsSymbolV2* symbol, double angle )
|
||||
{
|
||||
#if 0
|
||||
// debug: draw rectangle for debugging
|
||||
@ -3356,9 +3356,7 @@ void QgsDxfExport::writePoint( const QgsPoint& pt, const QString& layer, const Q
|
||||
const QgsMarkerSymbolLayerV2* msl = dynamic_cast< const QgsMarkerSymbolLayerV2* >( symbolLayer );
|
||||
if ( msl && symbol )
|
||||
{
|
||||
QgsRenderContext ct;
|
||||
QgsSymbolV2RenderContext ctx( ct, QgsSymbolV2::MapUnit, symbol->alpha(), false, symbol->renderHints(), f );
|
||||
if ( 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, QPointF( pt.x(), pt.y() ) ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -3374,6 +3372,7 @@ void QgsDxfExport::writePoint( const QgsPoint& pt, const QString& layer, const Q
|
||||
writeGroup( 100, "AcDbBlockReference" );
|
||||
writeGroup( 8, layer );
|
||||
writeGroup( 2, blockIt.value() ); // Block name
|
||||
writeGroup( 50, angle ); // angle
|
||||
writeGroup( 0, pt ); // Insertion point (in OCS)
|
||||
}
|
||||
}
|
||||
@ -3659,10 +3658,12 @@ void QgsDxfExport::addFeature( QgsSymbolV2RenderContext& ctx, const QString& lay
|
||||
Qt::BrushStyle brushStyle( Qt::NoBrush );
|
||||
double width = -1;
|
||||
double offset = 0.0;
|
||||
double angle = 0.0;
|
||||
if ( mSymbologyExport != NoSymbology && symbolLayer )
|
||||
{
|
||||
width = symbolLayer->dxfWidth( *this, ctx );
|
||||
offset = symbolLayer->dxfOffset( *this, ctx );
|
||||
angle = symbolLayer->dxfAngle( ctx );
|
||||
penStyle = symbolLayer->dxfPenStyle();
|
||||
brushStyle = symbolLayer->dxfBrushStyle();
|
||||
|
||||
@ -3679,7 +3680,7 @@ void QgsDxfExport::addFeature( QgsSymbolV2RenderContext& ctx, const QString& lay
|
||||
// single point
|
||||
if ( geometryType == QGis::WKBPoint || geometryType == QGis::WKBPoint25D )
|
||||
{
|
||||
writePoint( geom->asPoint(), layer, penColor, fet, symbolLayer, symbol );
|
||||
writePoint( geom->asPoint(), layer, penColor, ctx, symbolLayer, symbol, angle );
|
||||
return;
|
||||
}
|
||||
|
||||
@ -3690,7 +3691,7 @@ void QgsDxfExport::addFeature( QgsSymbolV2RenderContext& ctx, const QString& lay
|
||||
QgsMultiPoint::const_iterator it = multiPoint.constBegin();
|
||||
for ( ; it != multiPoint.constEnd(); ++it )
|
||||
{
|
||||
writePoint( *it, layer, penColor, fet, symbolLayer, symbol );
|
||||
writePoint( *it, layer, penColor, ctx, symbolLayer, symbol, angle );
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -327,7 +327,7 @@ class CORE_EXPORT QgsDxfExport
|
||||
void startSection();
|
||||
void endSection();
|
||||
|
||||
void writePoint( const QgsPoint &pt, const QString &layer, const QColor& color, const QgsFeature *f, const QgsSymbolLayerV2 *symbolLayer, const QgsSymbolV2 *symbol );
|
||||
void writePoint( const QgsPoint &pt, const QString &layer, const QColor& color, QgsSymbolV2RenderContext &ctx, const QgsSymbolLayerV2 *symbolLayer, const QgsSymbolV2 *symbol, double angle );
|
||||
void writeVertex( const QgsPoint &pt, const QString &layer );
|
||||
void writeDefaultLinetypes();
|
||||
void writeSymbolLayerLinetype( const QgsSymbolLayerV2 *symbolLayer );
|
||||
|
@ -719,17 +719,17 @@ QRectF QgsEllipseSymbolLayerV2::bounds( QPointF point, QgsSymbolV2RenderContext&
|
||||
return symbolBounds;
|
||||
}
|
||||
|
||||
bool QgsEllipseSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFactor, const QString& layerName, QgsSymbolV2RenderContext *context, const QgsFeature*, QPointF shift ) const
|
||||
bool QgsEllipseSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFactor, const QString& layerName, QgsSymbolV2RenderContext &context, QPointF shift ) const
|
||||
{
|
||||
//width
|
||||
double symbolWidth = mSymbolWidth;
|
||||
|
||||
if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_WIDTH ) ) //1. priority: data defined setting on symbol layer le
|
||||
{
|
||||
context->setOriginalValueVariable( mSymbolWidth );
|
||||
symbolWidth = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_WIDTH, *context, mSymbolWidth ).toDouble();
|
||||
context.setOriginalValueVariable( mSymbolWidth );
|
||||
symbolWidth = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_WIDTH, context, mSymbolWidth ).toDouble();
|
||||
}
|
||||
else if ( context->renderHints() & QgsSymbolV2::DataDefinedSizeScale ) //2. priority: is data defined size on symbol level
|
||||
else if ( context.renderHints() & QgsSymbolV2::DataDefinedSizeScale ) //2. priority: is data defined size on symbol level
|
||||
{
|
||||
symbolWidth = mSize;
|
||||
}
|
||||
@ -742,10 +742,10 @@ bool QgsEllipseSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFa
|
||||
double symbolHeight = mSymbolHeight;
|
||||
if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_HEIGHT ) ) //1. priority: data defined setting on symbol layer level
|
||||
{
|
||||
context->setOriginalValueVariable( mSymbolHeight );
|
||||
symbolHeight = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_HEIGHT, *context, mSymbolHeight ).toDouble();
|
||||
context.setOriginalValueVariable( mSymbolHeight );
|
||||
symbolHeight = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_HEIGHT, context, mSymbolHeight ).toDouble();
|
||||
}
|
||||
else if ( context->renderHints() & QgsSymbolV2::DataDefinedSizeScale ) //2. priority: is data defined size on symbol level
|
||||
else if ( context.renderHints() & QgsSymbolV2::DataDefinedSizeScale ) //2. priority: is data defined size on symbol level
|
||||
{
|
||||
symbolHeight = mSize;
|
||||
}
|
||||
@ -759,8 +759,8 @@ bool QgsEllipseSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFa
|
||||
|
||||
if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_WIDTH ) )
|
||||
{
|
||||
context->setOriginalValueVariable( mOutlineWidth );
|
||||
outlineWidth = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_WIDTH, *context, mOutlineWidth ).toDouble();
|
||||
context.setOriginalValueVariable( mOutlineWidth );
|
||||
outlineWidth = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_WIDTH, context, mOutlineWidth ).toDouble();
|
||||
}
|
||||
if ( mOutlineWidthUnit == QgsSymbolV2::MM )
|
||||
{
|
||||
@ -772,8 +772,8 @@ bool QgsEllipseSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFa
|
||||
QColor fc = mColor;
|
||||
if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_FILL_COLOR ) )
|
||||
{
|
||||
context->setOriginalValueVariable( QgsSymbolLayerV2Utils::encodeColor( mColor ) );
|
||||
QString colorString = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_FILL_COLOR, *context, QVariant(), &ok ).toString();
|
||||
context.setOriginalValueVariable( QgsSymbolLayerV2Utils::encodeColor( mColor ) );
|
||||
QString colorString = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_FILL_COLOR, context, QVariant(), &ok ).toString();
|
||||
if ( ok )
|
||||
fc = QgsSymbolLayerV2Utils::decodeColor( colorString );
|
||||
}
|
||||
@ -782,8 +782,8 @@ bool QgsEllipseSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFa
|
||||
QColor oc = mOutlineColor;
|
||||
if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_COLOR ) )
|
||||
{
|
||||
context->setOriginalValueVariable( QgsSymbolLayerV2Utils::encodeColor( mOutlineColor ) );
|
||||
QString colorString = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_COLOR, *context, QVariant(), &ok ).toString();
|
||||
context.setOriginalValueVariable( QgsSymbolLayerV2Utils::encodeColor( mOutlineColor ) );
|
||||
QString colorString = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_COLOR, context, QVariant(), &ok ).toString();
|
||||
if ( ok )
|
||||
oc = QgsSymbolLayerV2Utils::decodeColor( colorString );
|
||||
}
|
||||
@ -792,22 +792,22 @@ bool QgsEllipseSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFa
|
||||
QString symbolName = mSymbolName;
|
||||
if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_SYMBOL_NAME ) )
|
||||
{
|
||||
context->setOriginalValueVariable( mSymbolName );
|
||||
symbolName = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_SYMBOL_NAME, *context, mSymbolName ).toString();
|
||||
context.setOriginalValueVariable( mSymbolName );
|
||||
symbolName = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_SYMBOL_NAME, context, mSymbolName ).toString();
|
||||
}
|
||||
|
||||
//offset
|
||||
double offsetX = 0;
|
||||
double offsetY = 0;
|
||||
markerOffset( *context, offsetX, offsetY );
|
||||
markerOffset( context, offsetX, offsetY );
|
||||
QPointF off( offsetX, offsetY );
|
||||
|
||||
//priority for rotation: 1. data defined symbol level, 2. symbol layer rotation (mAngle)
|
||||
double rotation = 0.0;
|
||||
if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_ROTATION ) )
|
||||
{
|
||||
context->setOriginalValueVariable( mAngle );
|
||||
rotation = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_ROTATION, *context, mAngle ).toDouble() + mLineAngle;
|
||||
context.setOriginalValueVariable( mAngle );
|
||||
rotation = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_ROTATION, context, mAngle ).toDouble() + mLineAngle;
|
||||
}
|
||||
else if ( !qgsDoubleNear( mAngle + mLineAngle, 0.0 ) )
|
||||
{
|
||||
|
@ -42,7 +42,7 @@ class CORE_EXPORT QgsEllipseSymbolLayerV2: public QgsMarkerSymbolLayerV2
|
||||
void toSld( QDomDocument& doc, QDomElement &element, const QgsStringMap& props ) const override;
|
||||
void writeSldMarker( QDomDocument& doc, QDomElement &element, const QgsStringMap& props ) const override;
|
||||
|
||||
bool writeDxf( QgsDxfExport& e, double mmMapUnitScaleFactor, const QString& layerName, QgsSymbolV2RenderContext* context, const QgsFeature* f, QPointF shift = QPointF( 0.0, 0.0 ) ) const override;
|
||||
bool writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolV2RenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) ) const override;
|
||||
|
||||
void setSymbolName( const QString& name ) { mSymbolName = name; }
|
||||
QString symbolName() const { return mSymbolName; }
|
||||
|
@ -422,6 +422,17 @@ QColor QgsSimpleFillSymbolLayerV2::dxfColor( QgsSymbolV2RenderContext &context )
|
||||
return mBorderColor;
|
||||
}
|
||||
|
||||
double QgsSimpleFillSymbolLayerV2::dxfAngle( QgsSymbolV2RenderContext &context ) const
|
||||
{
|
||||
double angle = mAngle;
|
||||
if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_ANGLE ) )
|
||||
{
|
||||
context.setOriginalValueVariable( mAngle );
|
||||
angle = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_ANGLE, context, mAngle ).toDouble();
|
||||
}
|
||||
return angle;
|
||||
}
|
||||
|
||||
Qt::PenStyle QgsSimpleFillSymbolLayerV2::dxfPenStyle() const
|
||||
{
|
||||
return mBorderStyle;
|
||||
|
@ -118,6 +118,8 @@ class CORE_EXPORT QgsSimpleFillSymbolLayerV2 : public QgsFillSymbolLayerV2
|
||||
|
||||
double dxfWidth( const QgsDxfExport& e, QgsSymbolV2RenderContext& context ) const override;
|
||||
QColor dxfColor( QgsSymbolV2RenderContext& context ) const override;
|
||||
double dxfAngle( QgsSymbolV2RenderContext& context ) const override;
|
||||
|
||||
Qt::PenStyle dxfPenStyle() const override;
|
||||
QColor dxfBrushColor( QgsSymbolV2RenderContext &context ) const override;
|
||||
Qt::BrushStyle dxfBrushStyle() const override;
|
||||
@ -562,14 +564,15 @@ class CORE_EXPORT QgsImageFillSymbolLayer: public QgsFillSymbolLayerV2
|
||||
void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
|
||||
QgsSymbolV2::OutputUnit outputUnit() const override;
|
||||
|
||||
void setMapUnitScale( const QgsMapUnitScale& scale ) override;
|
||||
void setMapUnitScale( const QgsMapUnitScale &scale ) override;
|
||||
QgsMapUnitScale mapUnitScale() const override;
|
||||
|
||||
virtual double estimateMaxBleed() const override;
|
||||
|
||||
virtual double dxfWidth( const QgsDxfExport& e, QgsSymbolV2RenderContext& context ) const override;
|
||||
virtual QColor dxfColor( QgsSymbolV2RenderContext& context ) const override;
|
||||
virtual Qt::PenStyle dxfPenStyle() const override;
|
||||
double dxfWidth( const QgsDxfExport& e, QgsSymbolV2RenderContext& context ) const override;
|
||||
QColor dxfColor( QgsSymbolV2RenderContext& context ) const override;
|
||||
|
||||
Qt::PenStyle dxfPenStyle() const override;
|
||||
|
||||
QSet<QString> usedAttributes() const override;
|
||||
|
||||
|
@ -937,16 +937,12 @@ void QgsSimpleMarkerSymbolLayerV2::drawMarker( QPainter* p, QgsSymbolV2RenderCon
|
||||
}
|
||||
}
|
||||
|
||||
bool QgsSimpleMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFactor, const QString& layerName, QgsSymbolV2RenderContext *context, const QgsFeature*, QPointF shift ) const
|
||||
bool QgsSimpleMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFactor, const QString& layerName, QgsSymbolV2RenderContext &context, QPointF shift ) const
|
||||
{
|
||||
//data defined size?
|
||||
double size = mSize;
|
||||
|
||||
bool hasDataDefinedSize = false;
|
||||
if ( context )
|
||||
{
|
||||
hasDataDefinedSize = context->renderHints() & QgsSymbolV2::DataDefinedSizeScale || hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_SIZE );
|
||||
}
|
||||
bool hasDataDefinedSize = context.renderHints() & QgsSymbolV2::DataDefinedSizeScale || hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_SIZE );
|
||||
|
||||
//data defined size
|
||||
bool ok = true;
|
||||
@ -954,8 +950,8 @@ bool QgsSimpleMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitSc
|
||||
{
|
||||
if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_SIZE ) )
|
||||
{
|
||||
context->setOriginalValueVariable( mSize );
|
||||
size = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_SIZE, *context, mSize, &ok ).toDouble();
|
||||
context.setOriginalValueVariable( mSize );
|
||||
size = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_SIZE, context, mSize, &ok ).toDouble();
|
||||
}
|
||||
|
||||
if ( ok )
|
||||
@ -970,7 +966,7 @@ bool QgsSimpleMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitSc
|
||||
}
|
||||
}
|
||||
|
||||
size = QgsSymbolLayerV2Utils::convertToPainterUnits( context->renderContext(), size, mSizeUnit, mSizeMapUnitScale );
|
||||
size = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), size, mSizeUnit, mSizeMapUnitScale );
|
||||
}
|
||||
if ( mSizeUnit == QgsSymbolV2::MM )
|
||||
{
|
||||
@ -981,10 +977,10 @@ bool QgsSimpleMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitSc
|
||||
//outlineWidth
|
||||
double outlineWidth = mOutlineWidth;
|
||||
|
||||
if ( context && hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_WIDTH ) )
|
||||
if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_WIDTH ) )
|
||||
{
|
||||
context->setOriginalValueVariable( mOutlineWidth );
|
||||
outlineWidth = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_WIDTH, *context, mOutlineWidth ).toDouble();
|
||||
context.setOriginalValueVariable( mOutlineWidth );
|
||||
outlineWidth = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_WIDTH, context, mOutlineWidth ).toDouble();
|
||||
}
|
||||
if ( mSizeUnit == QgsSymbolV2::MM )
|
||||
{
|
||||
@ -994,17 +990,17 @@ bool QgsSimpleMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitSc
|
||||
//color
|
||||
QColor pc = mPen.color();
|
||||
QColor bc = mBrush.color();
|
||||
if ( context && hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_COLOR ) )
|
||||
if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_COLOR ) )
|
||||
{
|
||||
context->setOriginalValueVariable( QgsSymbolLayerV2Utils::encodeColor( mColor ) );
|
||||
QString colorString = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_COLOR, *context, QVariant(), &ok ).toString();
|
||||
context.setOriginalValueVariable( QgsSymbolLayerV2Utils::encodeColor( mColor ) );
|
||||
QString colorString = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_COLOR, context, QVariant(), &ok ).toString();
|
||||
if ( ok )
|
||||
bc = QgsSymbolLayerV2Utils::decodeColor( colorString );
|
||||
}
|
||||
if ( context && hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_COLOR_BORDER ) )
|
||||
if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_COLOR_BORDER ) )
|
||||
{
|
||||
context->setOriginalValueVariable( QgsSymbolLayerV2Utils::encodeColor( mBorderColor ) );
|
||||
QString colorString = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_COLOR_BORDER, *context, QVariant(), &ok ).toString();
|
||||
context.setOriginalValueVariable( QgsSymbolLayerV2Utils::encodeColor( mBorderColor ) );
|
||||
QString colorString = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_COLOR_BORDER, context, QVariant(), &ok ).toString();
|
||||
if ( ok )
|
||||
pc = QgsSymbolLayerV2Utils::decodeColor( colorString );
|
||||
}
|
||||
@ -1012,25 +1008,23 @@ bool QgsSimpleMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitSc
|
||||
//offset
|
||||
double offsetX = 0;
|
||||
double offsetY = 0;
|
||||
if ( context )
|
||||
{
|
||||
markerOffset( *context, offsetX, offsetY );
|
||||
}
|
||||
markerOffset( context, offsetX, offsetY );
|
||||
|
||||
QPointF off( offsetX, offsetY );
|
||||
|
||||
//angle
|
||||
double angle = mAngle + mLineAngle;
|
||||
if ( context && hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_ANGLE ) )
|
||||
if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_ANGLE ) )
|
||||
{
|
||||
context->setOriginalValueVariable( mAngle );
|
||||
angle = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_ANGLE, *context, mAngle ).toDouble() + mLineAngle;
|
||||
context.setOriginalValueVariable( mAngle );
|
||||
angle = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_ANGLE, context, mAngle ).toDouble() + mLineAngle;
|
||||
}
|
||||
|
||||
QString name( mName );
|
||||
if ( context && hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_NAME ) )
|
||||
if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_NAME ) )
|
||||
{
|
||||
context->setOriginalValueVariable( mName );
|
||||
name = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_NAME, *context, QVariant(), &ok ).toString();
|
||||
context.setOriginalValueVariable( mName );
|
||||
name = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_NAME, context, QVariant(), &ok ).toString();
|
||||
}
|
||||
|
||||
angle = -angle; //rotation in Qt is counterclockwise
|
||||
@ -1761,8 +1755,7 @@ QgsSymbolLayerV2* QgsSvgMarkerSymbolLayerV2::createFromSld( QDomElement &element
|
||||
return m;
|
||||
}
|
||||
|
||||
bool QgsSvgMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFactor, const QString& layerName, QgsSymbolV2RenderContext *context, const QgsFeature*,
|
||||
QPointF shift ) const
|
||||
bool QgsSvgMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFactor, const QString& layerName, QgsSymbolV2RenderContext &context, QPointF shift ) const
|
||||
{
|
||||
Q_UNUSED( layerName );
|
||||
Q_UNUSED( shift ); //todo...
|
||||
@ -1770,13 +1763,13 @@ bool QgsSvgMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScale
|
||||
//size
|
||||
double size = mSize;
|
||||
|
||||
bool hasDataDefinedSize = context->renderHints() & QgsSymbolV2::DataDefinedSizeScale || hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_SIZE );
|
||||
bool hasDataDefinedSize = context.renderHints() & QgsSymbolV2::DataDefinedSizeScale || hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_SIZE );
|
||||
|
||||
bool ok = true;
|
||||
if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_SIZE ) )
|
||||
{
|
||||
context->setOriginalValueVariable( mSize );
|
||||
size = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_SIZE, *context, mSize, &ok ).toDouble();
|
||||
context.setOriginalValueVariable( mSize );
|
||||
size = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_SIZE, context, mSize, &ok ).toDouble();
|
||||
}
|
||||
|
||||
if ( hasDataDefinedSize && ok )
|
||||
@ -1803,8 +1796,8 @@ bool QgsSvgMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScale
|
||||
|
||||
if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_OFFSET ) )
|
||||
{
|
||||
context->setOriginalValueVariable( QgsSymbolLayerV2Utils::encodePoint( mOffset ) );
|
||||
QString offsetString = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_OFFSET, *context, QVariant(), &ok ).toString();
|
||||
context.setOriginalValueVariable( QgsSymbolLayerV2Utils::encodePoint( mOffset ) );
|
||||
QString offsetString = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_OFFSET, context, QVariant(), &ok ).toString();
|
||||
if ( ok )
|
||||
offset = QgsSymbolLayerV2Utils::decodePoint( offsetString );
|
||||
}
|
||||
@ -1821,8 +1814,8 @@ bool QgsSvgMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScale
|
||||
double angle = mAngle + mLineAngle;
|
||||
if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_ANGLE ) )
|
||||
{
|
||||
context->setOriginalValueVariable( mAngle );
|
||||
angle = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_ANGLE, *context, mAngle ).toDouble() + mLineAngle;
|
||||
context.setOriginalValueVariable( mAngle );
|
||||
angle = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_ANGLE, context, mAngle ).toDouble() + mLineAngle;
|
||||
}
|
||||
//angle = -angle; //rotation in Qt is counterclockwise
|
||||
if ( angle )
|
||||
@ -1831,23 +1824,23 @@ bool QgsSvgMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScale
|
||||
QString path = mPath;
|
||||
if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_NAME ) )
|
||||
{
|
||||
context->setOriginalValueVariable( mPath );
|
||||
path = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_NAME, *context, mPath ).toString();
|
||||
context.setOriginalValueVariable( mPath );
|
||||
path = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_NAME, context, mPath ).toString();
|
||||
}
|
||||
|
||||
double outlineWidth = mOutlineWidth;
|
||||
if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_WIDTH ) )
|
||||
{
|
||||
context->setOriginalValueVariable( mOutlineWidth );
|
||||
outlineWidth = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_WIDTH, *context, mOutlineWidth ).toDouble();
|
||||
context.setOriginalValueVariable( mOutlineWidth );
|
||||
outlineWidth = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_WIDTH, context, mOutlineWidth ).toDouble();
|
||||
}
|
||||
outlineWidth = QgsSymbolLayerV2Utils::convertToPainterUnits( context->renderContext(), outlineWidth, mOutlineWidthUnit, mOutlineWidthMapUnitScale );
|
||||
outlineWidth = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), outlineWidth, mOutlineWidthUnit, mOutlineWidthMapUnitScale );
|
||||
|
||||
QColor fillColor = mColor;
|
||||
if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_FILL ) )
|
||||
{
|
||||
context->setOriginalValueVariable( QgsSymbolLayerV2Utils::encodeColor( mColor ) );
|
||||
QString colorString = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_FILL, *context, QVariant(), &ok ).toString();
|
||||
context.setOriginalValueVariable( QgsSymbolLayerV2Utils::encodeColor( mColor ) );
|
||||
QString colorString = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_FILL, context, QVariant(), &ok ).toString();
|
||||
if ( ok )
|
||||
fillColor = QgsSymbolLayerV2Utils::decodeColor( colorString );
|
||||
}
|
||||
@ -1855,15 +1848,15 @@ bool QgsSvgMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScale
|
||||
QColor outlineColor = mOutlineColor;
|
||||
if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE ) )
|
||||
{
|
||||
context->setOriginalValueVariable( QgsSymbolLayerV2Utils::encodeColor( mOutlineColor ) );
|
||||
QString colorString = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE, *context, QVariant(), &ok ).toString();
|
||||
context.setOriginalValueVariable( QgsSymbolLayerV2Utils::encodeColor( mOutlineColor ) );
|
||||
QString colorString = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE, context, QVariant(), &ok ).toString();
|
||||
if ( ok )
|
||||
outlineColor = QgsSymbolLayerV2Utils::decodeColor( colorString );
|
||||
}
|
||||
|
||||
const QByteArray &svgContent = QgsSvgCache::instance()->svgContent( path, size, fillColor, outlineColor, outlineWidth,
|
||||
context->renderContext().scaleFactor(),
|
||||
context->renderContext().rasterScaleFactor() );
|
||||
context.renderContext().scaleFactor(),
|
||||
context.renderContext().rasterScaleFactor() );
|
||||
|
||||
//if current entry image is 0: cache image for entry
|
||||
// checks to see if image will fit into cache
|
||||
|
@ -123,7 +123,7 @@ class CORE_EXPORT QgsSimpleMarkerSymbolLayerV2 : public QgsMarkerSymbolLayerV2
|
||||
void setOutlineWidthMapUnitScale( const QgsMapUnitScale& scale ) { mOutlineWidthMapUnitScale = scale; }
|
||||
const QgsMapUnitScale& outlineWidthMapUnitScale() const { return mOutlineWidthMapUnitScale; }
|
||||
|
||||
bool writeDxf( QgsDxfExport& e, double mmMapUnitScaleFactor, const QString& layerName, QgsSymbolV2RenderContext* context, const QgsFeature* f, QPointF shift = QPointF( 0.0, 0.0 ) ) const override;
|
||||
bool writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolV2RenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) ) const override;
|
||||
|
||||
void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
|
||||
QgsSymbolV2::OutputUnit outputUnit() const override;
|
||||
@ -230,7 +230,7 @@ class CORE_EXPORT QgsSvgMarkerSymbolLayerV2 : public QgsMarkerSymbolLayerV2
|
||||
void setMapUnitScale( const QgsMapUnitScale& scale ) override;
|
||||
QgsMapUnitScale mapUnitScale() const override;
|
||||
|
||||
bool writeDxf( QgsDxfExport& e, double mmMapUnitScaleFactor, const QString& layerName, QgsSymbolV2RenderContext* context, const QgsFeature* f, QPointF shift = QPointF( 0.0, 0.0 ) ) const override;
|
||||
bool writeDxf( QgsDxfExport& e, double mmMapUnitScaleFactor, const QString& layerName, QgsSymbolV2RenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) ) const override;
|
||||
|
||||
QRectF bounds( QPointF point, QgsSymbolV2RenderContext& context ) override;
|
||||
|
||||
|
@ -256,18 +256,12 @@ QVariant QgsSymbolLayerV2::evaluateDataDefinedProperty( const QString& property,
|
||||
return defaultVal;
|
||||
}
|
||||
|
||||
bool QgsSymbolLayerV2::writeDxf( QgsDxfExport& e,
|
||||
double mmMapUnitScaleFactor,
|
||||
const QString& layerName,
|
||||
QgsSymbolV2RenderContext *context,
|
||||
const QgsFeature* f,
|
||||
QPointF shift ) const
|
||||
bool QgsSymbolLayerV2::writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolV2RenderContext &context, QPointF shift ) const
|
||||
{
|
||||
Q_UNUSED( e );
|
||||
Q_UNUSED( mmMapUnitScaleFactor );
|
||||
Q_UNUSED( layerName );
|
||||
Q_UNUSED( context );
|
||||
Q_UNUSED( f );
|
||||
Q_UNUSED( shift );
|
||||
return false;
|
||||
}
|
||||
@ -292,6 +286,12 @@ QColor QgsSymbolLayerV2::dxfColor( QgsSymbolV2RenderContext &context ) const
|
||||
return color();
|
||||
}
|
||||
|
||||
double QgsSymbolLayerV2::dxfAngle( QgsSymbolV2RenderContext &context ) const
|
||||
{
|
||||
Q_UNUSED( context );
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
QVector<qreal> QgsSymbolLayerV2::dxfCustomDashPattern( QgsSymbolV2::OutputUnit& unit ) const
|
||||
{
|
||||
Q_UNUSED( unit );
|
||||
|
@ -235,17 +235,13 @@ class CORE_EXPORT QgsSymbolLayerV2
|
||||
*/
|
||||
virtual QVariant evaluateDataDefinedProperty( const QString& property, const QgsSymbolV2RenderContext& context, const QVariant& defaultVal = QVariant(), bool *ok = nullptr ) const;
|
||||
|
||||
virtual bool writeDxf( QgsDxfExport& e,
|
||||
double mmMapUnitScaleFactor,
|
||||
const QString& layerName,
|
||||
QgsSymbolV2RenderContext* context,
|
||||
const QgsFeature* f,
|
||||
QPointF shift = QPointF( 0.0, 0.0 ) ) const;
|
||||
virtual bool writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolV2RenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) ) const;
|
||||
|
||||
virtual double dxfWidth( const QgsDxfExport& e, QgsSymbolV2RenderContext& context ) const;
|
||||
virtual double dxfOffset( const QgsDxfExport& e, QgsSymbolV2RenderContext& context ) const;
|
||||
|
||||
virtual QColor dxfColor( QgsSymbolV2RenderContext& context ) const;
|
||||
virtual double dxfAngle( QgsSymbolV2RenderContext& context ) const;
|
||||
|
||||
virtual QVector<qreal> dxfCustomDashPattern( QgsSymbolV2::OutputUnit& unit ) const;
|
||||
virtual Qt::PenStyle dxfPenStyle() const;
|
||||
|
@ -469,8 +469,11 @@ void QgsSymbolV2::startRender( QgsRenderContext& context, const QgsFields* field
|
||||
void QgsSymbolV2::stopRender( QgsRenderContext& context )
|
||||
{
|
||||
Q_UNUSED( context )
|
||||
Q_FOREACH ( QgsSymbolLayerV2* layer, mLayers )
|
||||
layer->stopRender( *mSymbolRenderContext );
|
||||
if ( mSymbolRenderContext )
|
||||
{
|
||||
Q_FOREACH ( QgsSymbolLayerV2* layer, mLayers )
|
||||
layer->stopRender( *mSymbolRenderContext );
|
||||
}
|
||||
|
||||
delete mSymbolRenderContext;
|
||||
mSymbolRenderContext = nullptr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user