636 changes: 52 additions & 584 deletions src/core/symbology-ng/qgsfillsymbollayerv2.cpp

Large diffs are not rendered by default.

46 changes: 0 additions & 46 deletions src/core/symbology-ng/qgsfillsymbollayerv2.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,6 @@ class CORE_EXPORT QgsSimpleFillSymbolLayerV2 : public QgsFillSymbolLayerV2
void setOutputUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit outputUnit() const;

const QgsExpression* dataDefinedProperty( const QString& property ) const;
QString dataDefinedPropertyString( const QString& property ) const;
void setDataDefinedProperty( const QString& property, const QString& expressionString );
void removeDataDefinedProperty( const QString& property );
void removeDataDefinedProperties();

QSet<QString> usedAttributes() const;

protected:
QBrush mBrush;
QBrush mSelBrush;
Expand All @@ -105,14 +97,8 @@ class CORE_EXPORT QgsSimpleFillSymbolLayerV2 : public QgsFillSymbolLayerV2
QPointF mOffset;
QgsSymbolV2::OutputUnit mOffsetUnit;

//data defined properties
QgsExpression* mColorExpression;
QgsExpression* mColorBorderExpression;
QgsExpression* mWidthBorderExpression;

private:
//helper functions for data defined symbology
void prepareExpressions( const QgsVectorLayer* vl );
void applyDataDefinedSymbology( QgsSymbolV2RenderContext& context, QBrush& brush, QPen& pen, QPen& selPen );
};

Expand Down Expand Up @@ -190,14 +176,6 @@ class CORE_EXPORT QgsSVGFillSymbolLayer: public QgsImageFillSymbolLayer
void setOutputUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit outputUnit() const;

const QgsExpression* dataDefinedProperty( const QString& property ) const;
QString dataDefinedPropertyString( const QString& property ) const;
void setDataDefinedProperty( const QString& property, const QString& expressionString );
void removeDataDefinedProperty( const QString& property );
void removeDataDefinedProperties();

QSet<QString> usedAttributes() const;

protected:
/**Width of the pattern (in output units)*/
double mPatternWidth;
Expand All @@ -220,22 +198,13 @@ class CORE_EXPORT QgsSVGFillSymbolLayer: public QgsImageFillSymbolLayer
double mSvgOutlineWidth;
QgsSymbolV2::OutputUnit mSvgOutlineWidthUnit;

//data defined properties
QgsExpression* mWidthExpression;
QgsExpression* mSvgFileExpression;
QgsExpression* mAngleExpression;
QgsExpression* mFillColorExpression;
QgsExpression* mOutlineColorExpression;
QgsExpression* mOutlineWidthExpression;

void applyDataDefinedSettings( const QgsSymbolV2RenderContext& context );

private:
/**Helper function that gets the view box from the byte array*/
void storeViewBox();
void setDefaultSvgParams(); //fills mSvgFillColor, mSvgOutlineColor, mSvgOutlineWidth with default values for mSvgFilePath

void prepareExpressions( const QgsVectorLayer* vl );
/**Applies the svg pattern to the brush*/
void applyPattern( QBrush& brush, const QString& svgFilePath, double patternWidth, QgsSymbolV2::OutputUnit patternWidthUnit, const QColor& svgFillColor, const QColor& svgOutlineColor,
double svgOutlineWidth, QgsSymbolV2::OutputUnit svgOutlineWidthUnit, const QgsSymbolV2RenderContext& context );
Expand Down Expand Up @@ -288,14 +257,6 @@ class CORE_EXPORT QgsLinePatternFillSymbolLayer: public QgsImageFillSymbolLayer
void setOutputUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit outputUnit() const;

const QgsExpression* dataDefinedProperty( const QString& property ) const;
QString dataDefinedPropertyString( const QString& property ) const;
void setDataDefinedProperty( const QString& property, const QString& expressionString );
void removeDataDefinedProperty( const QString& property );
void removeDataDefinedProperties();

QSet<QString> usedAttributes() const;

protected:
/**Distance (in mm or map units) between lines*/
double mDistance;
Expand All @@ -310,16 +271,9 @@ class CORE_EXPORT QgsLinePatternFillSymbolLayer: public QgsImageFillSymbolLayer
double mOffset;
QgsSymbolV2::OutputUnit mOffsetUnit;

//data defined properties
QgsExpression* mLineAngleExpression;
QgsExpression* mDistanceExpression;
QgsExpression* mLineWidthExpression;
QgsExpression* mColorExpression;

void applyDataDefinedSettings( const QgsSymbolV2RenderContext& context );

private:
void prepareExpressions( const QgsVectorLayer* vl );
/**Applies the svg pattern to the brush*/
void applyPattern( const QgsSymbolV2RenderContext& context, QBrush& brush, double lineAngle, double distance, double lineWidth, const QColor& color );
};
Expand Down
375 changes: 34 additions & 341 deletions src/core/symbology-ng/qgslinesymbollayerv2.cpp

Large diffs are not rendered by default.

36 changes: 0 additions & 36 deletions src/core/symbology-ng/qgslinesymbollayerv2.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ class CORE_EXPORT QgsSimpleLineSymbolLayerV2 : public QgsLineSymbolLayerV2
double width = DEFAULT_SIMPLELINE_WIDTH,
Qt::PenStyle penStyle = DEFAULT_SIMPLELINE_PENSTYLE );

~QgsSimpleLineSymbolLayerV2();

// static stuff

static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
Expand Down Expand Up @@ -91,14 +89,6 @@ class CORE_EXPORT QgsSimpleLineSymbolLayerV2 : public QgsLineSymbolLayerV2
QVector<qreal> customDashVector() const { return mCustomDashVector; }
void setCustomDashVector( const QVector<qreal>& vector ) { mCustomDashVector = vector; }

const QgsExpression* dataDefinedProperty( const QString& property ) const;
QString dataDefinedPropertyString( const QString& property ) const;
void setDataDefinedProperty( const QString& property, const QString& expressionString );
void removeDataDefinedProperty( const QString& property );
void removeDataDefinedProperties();

QSet<QString> usedAttributes() const;

protected:
Qt::PenStyle mPenStyle;
Qt::PenJoinStyle mPenJoinStyle;
Expand All @@ -115,17 +105,8 @@ class CORE_EXPORT QgsSimpleLineSymbolLayerV2 : public QgsLineSymbolLayerV2
/**Vector with an even number of entries for the */
QVector<qreal> mCustomDashVector;

//data defined properties
QgsExpression* mStrokeColorExpression;
QgsExpression* mStrokeWidthExpression;
QgsExpression* mLineOffsetExpression;
QgsExpression* mDashPatternExpression;
QgsExpression* mJoinStyleExpression;
QgsExpression* mCapStyleExpression;

private:
//helper functions for data defined symbology
void prepareExpressions( const QgsVectorLayer* vl );
void applyDataDefinedSymbology( QgsSymbolV2RenderContext& context, QPen& pen, QPen& selPen, double& offset );
};

Expand Down Expand Up @@ -203,14 +184,6 @@ class CORE_EXPORT QgsMarkerLineSymbolLayerV2 : public QgsLineSymbolLayerV2
void setOutputUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit outputUnit() const;

const QgsExpression* dataDefinedProperty( const QString& property ) const;
QString dataDefinedPropertyString( const QString& property ) const;
void setDataDefinedProperty( const QString& property, const QString& expressionString );
void removeDataDefinedProperty( const QString& property );
void removeDataDefinedProperties();

QSet<QString> usedAttributes() const;

protected:

void renderPolylineInterval( const QPolygonF& points, QgsSymbolV2RenderContext& context );
Expand All @@ -224,15 +197,6 @@ class CORE_EXPORT QgsMarkerLineSymbolLayerV2 : public QgsLineSymbolLayerV2
double mOffset;
QgsSymbolV2::OutputUnit mOffsetUnit;
Placement mPlacement;

//data defined properties
QgsExpression* mIntervalExpression;
QgsExpression* mOffsetExpression;
QgsExpression* mPlacementExpression;

private:
//helper functions for data defined symbology
void prepareExpressions( const QgsVectorLayer* vl );
};

/////////
Expand Down
23 changes: 2 additions & 21 deletions src/core/symbology-ng/qgsmarkersymbollayerv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,16 +587,7 @@ QgsSymbolLayerV2* QgsSimpleMarkerSymbolLayerV2::clone() const
m->setOffsetUnit( mOffsetUnit );
m->setOutlineWidth( mOutlineWidth );
m->setOutlineWidthUnit( mOutlineWidthUnit );

QMap< QString, QgsExpression* >::const_iterator ddIt = mDataDefinedProperties.constBegin();
for ( ; ddIt != mDataDefinedProperties.constEnd(); ++ddIt )
{
if ( ddIt.value() )
{
m->setDataDefinedProperty( ddIt.key(), ddIt.value()->dump() );
}
}

copyDataDefinedProperties( m );
return m;
}

Expand Down Expand Up @@ -1040,17 +1031,7 @@ QgsSymbolLayerV2* QgsSvgMarkerSymbolLayerV2::clone() const
m->setOffset( mOffset );
m->setOffsetUnit( mOffsetUnit );
m->setSizeUnit( mSizeUnit );

//data defined properties
QMap< QString, QgsExpression* >::const_iterator ddIt = mDataDefinedProperties.constBegin();
for ( ; ddIt != mDataDefinedProperties.constEnd(); ++ddIt )
{
if ( ddIt.value() )
{
m->setDataDefinedProperty( ddIt.key(), ddIt.value()->dump() );
}
}

copyDataDefinedProperties( m );
return m;
}

Expand Down
18 changes: 18 additions & 0 deletions src/core/symbology-ng/qgssymbollayerv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,24 @@ void QgsSymbolLayerV2::saveDataDefinedProperties( QgsStringMap& stringMap ) cons
}
}

void QgsSymbolLayerV2::copyDataDefinedProperties( QgsSymbolLayerV2* destLayer ) const
{
if ( !destLayer )
{
return;
}
destLayer->removeDataDefinedProperties();

QMap< QString, QgsExpression* >::const_iterator ddIt = mDataDefinedProperties.constBegin();
for ( ; ddIt != mDataDefinedProperties.constEnd(); ++ddIt )
{
if ( ddIt.value() )
{
destLayer->setDataDefinedProperty( ddIt.key(), ddIt.value()->dump() );
}
}
}


QgsMarkerSymbolLayerV2::QgsMarkerSymbolLayerV2( bool locked )
: QgsSymbolLayerV2( QgsSymbolV2::Marker, locked ), mSizeUnit( QgsSymbolV2::MM ), mOffsetUnit( QgsSymbolV2::MM )
Expand Down
4 changes: 3 additions & 1 deletion src/core/symbology-ng/qgssymbollayerv2.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class CORE_EXPORT QgsSymbolLayerV2
virtual void setColor( const QColor& color ) { mColor = color; }
virtual QColor color() const { return mColor; }

virtual ~QgsSymbolLayerV2() {}
virtual ~QgsSymbolLayerV2() { removeDataDefinedProperties(); }

virtual QString layerType() const = 0;

Expand Down Expand Up @@ -106,6 +106,8 @@ class CORE_EXPORT QgsSymbolLayerV2
virtual QgsExpression* expression( const QString& property );
/**Saves data defined properties to string map*/
void saveDataDefinedProperties( QgsStringMap& stringMap ) const;
/**Copies data defined properties of this layer to another symbol layer*/
void copyDataDefinedProperties( QgsSymbolLayerV2* destLayer ) const;
};

//////////////////////
Expand Down