Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Feature]: anchor points for marker symbols
  • Loading branch information
mhugent committed Sep 10, 2013
1 parent 4cad8ba commit bc95d0b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/core/symbology-ng/qgssymbollayerv2.cpp
Expand Up @@ -190,6 +190,14 @@ void QgsMarkerSymbolLayerV2::markerOffset( QgsSymbolV2RenderContext& context, do

offsetX *= QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mOffsetUnit );
offsetY *= QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mOffsetUnit );

//consider anchor point corrections
if( mHorizontalAnchorPoint == HCenter && mVerticalAnchorPoint == VCenter )
{
return;
}


}

QPointF QgsMarkerSymbolLayerV2::_rotatedOffset( const QPointF& offset, double angle )
Expand Down
18 changes: 18 additions & 0 deletions src/core/symbology-ng/qgssymbollayerv2.h
Expand Up @@ -121,6 +121,21 @@ class CORE_EXPORT QgsSymbolLayerV2
class CORE_EXPORT QgsMarkerSymbolLayerV2 : public QgsSymbolLayerV2
{
public:

enum HorizontalAnchorPoint
{
Left,
HCenter,
Right
};

enum VerticalAnchorPoint
{
Top,
VCenter,
Bottom
};

virtual void renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context ) = 0;

void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size );
Expand Down Expand Up @@ -153,6 +168,7 @@ class CORE_EXPORT QgsMarkerSymbolLayerV2 : public QgsSymbolLayerV2

protected:
QgsMarkerSymbolLayerV2( bool locked = false );
//handles marker offset and anchor point shift together
void markerOffset( QgsSymbolV2RenderContext& context, double& offsetX, double& offsetY );
static QPointF _rotatedOffset( const QPointF& offset, double angle );

Expand All @@ -162,6 +178,8 @@ class CORE_EXPORT QgsMarkerSymbolLayerV2 : public QgsSymbolLayerV2
QPointF mOffset;
QgsSymbolV2::OutputUnit mOffsetUnit;
QgsSymbolV2::ScaleMethod mScaleMethod;
HorizontalAnchorPoint mHorizontalAnchorPoint;
VerticalAnchorPoint mVerticalAnchorPoint;
};

class CORE_EXPORT QgsLineSymbolLayerV2 : public QgsSymbolLayerV2
Expand Down

0 comments on commit bc95d0b

Please sign in to comment.