Skip to content

Commit

Permalink
Merge pull request #1858 from vmora/symbol_list_refacto
Browse files Browse the repository at this point in the history
line symbol layer refacto to avoid code duplication
  • Loading branch information
nyalldawson committed Feb 7, 2015
2 parents b60221a + 2612715 commit 4def416
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 46 deletions.
18 changes: 0 additions & 18 deletions python/core/symbology-ng/qgslinesymbollayerv2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,6 @@ class QgsSimpleLineSymbolLayerV2 : QgsLineSymbolLayerV2
Qt::PenCapStyle penCapStyle() const;
void setPenCapStyle( Qt::PenCapStyle style );

double offset() const;
void setOffset( double offset );

void setOffsetUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit offsetUnit() const;

void setOffsetMapUnitScale( const QgsMapUnitScale& scale);
const QgsMapUnitScale& offsetMapUnitScale() const;

bool useCustomDashPattern() const;
void setUseCustomDashPattern( bool b );

Expand Down Expand Up @@ -152,9 +143,6 @@ class QgsMarkerLineSymbolLayerV2 : QgsLineSymbolLayerV2
double interval() const;
void setInterval( double interval );

double offset() const;
void setOffset( double offset );

Placement placement() const;
void setPlacement( Placement p );

Expand Down Expand Up @@ -213,12 +201,6 @@ class QgsMarkerLineSymbolLayerV2 : QgsLineSymbolLayerV2
void setIntervalMapUnitScale( const QgsMapUnitScale& scale );
const QgsMapUnitScale& intervalMapUnitScale() const;

void setOffsetUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit offsetUnit() const;

void setOffsetMapUnitScale( const QgsMapUnitScale& scale );
const QgsMapUnitScale& offsetMapUnitScale() const;

void setOutputUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit outputUnit() const;

Expand Down
9 changes: 9 additions & 0 deletions python/core/symbology-ng/qgssymbollayerv2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,21 @@ class QgsLineSymbolLayerV2 : QgsSymbolLayerV2
virtual void setWidth( double width );
virtual double width() const;

double offset() const;
void setOffset( double offset );

void setWidthUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit widthUnit() const;

void setWidthMapUnitScale( const QgsMapUnitScale& scale);
const QgsMapUnitScale& widthMapUnitScale() const;

void setOffsetUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit offsetUnit() const;

void setOffsetMapUnitScale( const QgsMapUnitScale& scale );
const QgsMapUnitScale& offsetMapUnitScale() const;

void setOutputUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit outputUnit() const;

Expand Down
4 changes: 0 additions & 4 deletions src/core/symbology-ng/qgslinesymbollayerv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ QgsSimpleLineSymbolLayerV2::QgsSimpleLineSymbolLayerV2( QColor color, double wid
: mPenStyle( penStyle )
, mPenJoinStyle( DEFAULT_SIMPLELINE_JOINSTYLE )
, mPenCapStyle( DEFAULT_SIMPLELINE_CAPSTYLE )
, mOffset( 0 )
, mOffsetUnit( QgsSymbolV2::MM )
, mUseCustomDashPattern( false )
, mCustomDashPatternUnit( QgsSymbolV2::MM )
, mDrawInsidePolygon( false )
Expand Down Expand Up @@ -692,8 +690,6 @@ QgsMarkerLineSymbolLayerV2::QgsMarkerLineSymbolLayerV2( bool rotateMarker, doubl
mInterval = interval;
mIntervalUnit = QgsSymbolV2::MM;
mMarker = NULL;
mOffset = 0;
mOffsetUnit = QgsSymbolV2::MM;
mPlacement = Interval;
mOffsetAlongLine = 0;
mOffsetAlongLineUnit = QgsSymbolV2::MM;
Expand Down
24 changes: 0 additions & 24 deletions src/core/symbology-ng/qgslinesymbollayerv2.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,6 @@ class CORE_EXPORT QgsSimpleLineSymbolLayerV2 : public QgsLineSymbolLayerV2
Qt::PenCapStyle penCapStyle() const { return mPenCapStyle; }
void setPenCapStyle( Qt::PenCapStyle style ) { mPenCapStyle = style; }

double offset() const { return mOffset; }
void setOffset( double offset ) { mOffset = offset; }

void setOffsetUnit( QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; }
QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; }

void setOffsetMapUnitScale( const QgsMapUnitScale& scale ) { mOffsetMapUnitScale = scale; }
const QgsMapUnitScale& offsetMapUnitScale() const { return mOffsetMapUnitScale; }

bool useCustomDashPattern() const { return mUseCustomDashPattern; }
void setUseCustomDashPattern( bool b ) { mUseCustomDashPattern = b; }

Expand Down Expand Up @@ -121,9 +112,6 @@ class CORE_EXPORT QgsSimpleLineSymbolLayerV2 : public QgsLineSymbolLayerV2
Qt::PenCapStyle mPenCapStyle;
QPen mPen;
QPen mSelPen;
double mOffset;
QgsSymbolV2::OutputUnit mOffsetUnit;
QgsMapUnitScale mOffsetMapUnitScale;

//use a custom dash dot pattern instead of the predefined ones
bool mUseCustomDashPattern;
Expand Down Expand Up @@ -204,9 +192,6 @@ class CORE_EXPORT QgsMarkerLineSymbolLayerV2 : public QgsLineSymbolLayerV2
double interval() const { return mInterval; }
void setInterval( double interval ) { mInterval = interval; }

double offset() const { return mOffset; }
void setOffset( double offset ) { mOffset = offset; }

Placement placement() const { return mPlacement; }
void setPlacement( Placement p ) { mPlacement = p; }

Expand Down Expand Up @@ -265,12 +250,6 @@ class CORE_EXPORT QgsMarkerLineSymbolLayerV2 : public QgsLineSymbolLayerV2
void setIntervalMapUnitScale( const QgsMapUnitScale& scale ) { mIntervalMapUnitScale = scale; }
const QgsMapUnitScale& intervalMapUnitScale() const { return mIntervalMapUnitScale; }

void setOffsetUnit( QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; }
QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; }

void setOffsetMapUnitScale( const QgsMapUnitScale& scale ) { mOffsetMapUnitScale = scale; }
const QgsMapUnitScale& offsetMapUnitScale() const { return mOffsetMapUnitScale; }

void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
QgsSymbolV2::OutputUnit outputUnit() const override;

Expand All @@ -289,9 +268,6 @@ class CORE_EXPORT QgsMarkerLineSymbolLayerV2 : public QgsLineSymbolLayerV2
QgsSymbolV2::OutputUnit mIntervalUnit;
QgsMapUnitScale mIntervalMapUnitScale;
QgsMarkerSymbolV2* mMarker;
double mOffset;
QgsSymbolV2::OutputUnit mOffsetUnit;
QgsMapUnitScale mOffsetMapUnitScale;
Placement mPlacement;
double mOffsetAlongLine; //distance to offset along line before marker is drawn
QgsSymbolV2::OutputUnit mOffsetAlongLineUnit; //unit for offset along line
Expand Down
2 changes: 2 additions & 0 deletions src/core/symbology-ng/qgssymbollayerv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ QgsMarkerSymbolLayerV2::QgsMarkerSymbolLayerV2( bool locked )
QgsLineSymbolLayerV2::QgsLineSymbolLayerV2( bool locked )
: QgsSymbolLayerV2( QgsSymbolV2::Line, locked )
, mWidthUnit( QgsSymbolV2::MM )
, mOffset( 0 )
, mOffsetUnit( QgsSymbolV2::MM )
{
}

Expand Down
12 changes: 12 additions & 0 deletions src/core/symbology-ng/qgssymbollayerv2.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,21 @@ class CORE_EXPORT QgsLineSymbolLayerV2 : public QgsSymbolLayerV2
virtual void setWidth( double width ) { mWidth = width; }
virtual double width() const { return mWidth; }

double offset() const { return mOffset; }
void setOffset( double offset ) { mOffset = offset; }

void setWidthUnit( QgsSymbolV2::OutputUnit unit ) { mWidthUnit = unit; }
QgsSymbolV2::OutputUnit widthUnit() const { return mWidthUnit; }

void setWidthMapUnitScale( const QgsMapUnitScale& scale ) { mWidthMapUnitScale = scale; }
const QgsMapUnitScale& widthMapUnitScale() const { return mWidthMapUnitScale; }

void setOffsetUnit( QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; }
QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; }

void setOffsetMapUnitScale( const QgsMapUnitScale& scale ) { mOffsetMapUnitScale = scale; }
const QgsMapUnitScale& offsetMapUnitScale() const { return mOffsetMapUnitScale; }

void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
QgsSymbolV2::OutputUnit outputUnit() const override;

Expand All @@ -291,6 +300,9 @@ class CORE_EXPORT QgsLineSymbolLayerV2 : public QgsSymbolLayerV2
double mWidth;
QgsSymbolV2::OutputUnit mWidthUnit;
QgsMapUnitScale mWidthMapUnitScale;
double mOffset;
QgsSymbolV2::OutputUnit mOffsetUnit;
QgsMapUnitScale mOffsetMapUnitScale;
};

class CORE_EXPORT QgsFillSymbolLayerV2 : public QgsSymbolLayerV2
Expand Down
3 changes: 3 additions & 0 deletions src/core/symbology-ng/qgssymbolv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,7 @@ QgsSymbolV2* QgsMarkerSymbolV2::clone() const
{
QgsSymbolV2* cloneSymbol = new QgsMarkerSymbolV2( cloneLayers() );
cloneSymbol->setAlpha( mAlpha );
cloneSymbol->setLayer( mLayer );
return cloneSymbol;
}

Expand Down Expand Up @@ -671,6 +672,7 @@ QgsSymbolV2* QgsLineSymbolV2::clone() const
{
QgsSymbolV2* cloneSymbol = new QgsLineSymbolV2( cloneLayers() );
cloneSymbol->setAlpha( mAlpha );
cloneSymbol->setLayer( mLayer );
return cloneSymbol;
}

Expand Down Expand Up @@ -722,6 +724,7 @@ QgsSymbolV2* QgsFillSymbolV2::clone() const
{
QgsSymbolV2* cloneSymbol = new QgsFillSymbolV2( cloneLayers() );
cloneSymbol->setAlpha( mAlpha );
cloneSymbol->setLayer( mLayer );
return cloneSymbol;
}

Expand Down

0 comments on commit 4def416

Please sign in to comment.