Skip to content

Commit bc95d0b

Browse files
committed
[Feature]: anchor points for marker symbols
1 parent 4cad8ba commit bc95d0b

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/core/symbology-ng/qgssymbollayerv2.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,14 @@ void QgsMarkerSymbolLayerV2::markerOffset( QgsSymbolV2RenderContext& context, do
190190

191191
offsetX *= QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mOffsetUnit );
192192
offsetY *= QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mOffsetUnit );
193+
194+
//consider anchor point corrections
195+
if( mHorizontalAnchorPoint == HCenter && mVerticalAnchorPoint == VCenter )
196+
{
197+
return;
198+
}
199+
200+
193201
}
194202

195203
QPointF QgsMarkerSymbolLayerV2::_rotatedOffset( const QPointF& offset, double angle )

src/core/symbology-ng/qgssymbollayerv2.h

+18
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,21 @@ class CORE_EXPORT QgsSymbolLayerV2
121121
class CORE_EXPORT QgsMarkerSymbolLayerV2 : public QgsSymbolLayerV2
122122
{
123123
public:
124+
125+
enum HorizontalAnchorPoint
126+
{
127+
Left,
128+
HCenter,
129+
Right
130+
};
131+
132+
enum VerticalAnchorPoint
133+
{
134+
Top,
135+
VCenter,
136+
Bottom
137+
};
138+
124139
virtual void renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context ) = 0;
125140

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

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

@@ -162,6 +178,8 @@ class CORE_EXPORT QgsMarkerSymbolLayerV2 : public QgsSymbolLayerV2
162178
QPointF mOffset;
163179
QgsSymbolV2::OutputUnit mOffsetUnit;
164180
QgsSymbolV2::ScaleMethod mScaleMethod;
181+
HorizontalAnchorPoint mHorizontalAnchorPoint;
182+
VerticalAnchorPoint mVerticalAnchorPoint;
165183
};
166184

167185
class CORE_EXPORT QgsLineSymbolLayerV2 : public QgsSymbolLayerV2

0 commit comments

Comments
 (0)