Skip to content

Commit e7d6fba

Browse files

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed
 

‎python/gui/qgsvertexmarker.sip

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ class QgsVertexMarker : QgsMapCanvasItem
2424

2525
void setIconSize(int iconSize);
2626

27+
void setColor(const QColor& color);
28+
29+
void setPenWidth(int width);
30+
2731
void paint(QPainter* p);
2832

2933
QRectF boundingRect() const;

‎src/gui/qgsvertexmarker.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ QgsVertexMarker::QgsVertexMarker(QgsMapCanvas* mapCanvas)
2424
{
2525
mIconSize = 10;
2626
mIconType = ICON_X;
27+
mColor = QColor(255,0,0);
28+
mPenWidth = 1;
2729
}
2830

2931
void QgsVertexMarker::setIconType(int type)
@@ -43,12 +45,24 @@ void QgsVertexMarker::setCenter(const QgsPoint& point)
4345
setPos(pt);
4446
}
4547

48+
void QgsVertexMarker::setColor(const QColor& color)
49+
{
50+
mColor = color;
51+
}
52+
53+
void QgsVertexMarker::setPenWidth(int width)
54+
{
55+
mPenWidth = width;
56+
}
4657

4758
void QgsVertexMarker::paint(QPainter* p)
4859
{
4960
qreal s = (mIconSize - 1) / 2;
5061

51-
p->setPen(QColor(255,0,0));
62+
QPen pen(mColor);
63+
pen.setWidth(mPenWidth);
64+
p->setPen(pen);
65+
5266
switch (mIconType)
5367
{
5468
case ICON_NONE:
@@ -76,7 +90,7 @@ void QgsVertexMarker::paint(QPainter* p)
7690

7791
QRectF QgsVertexMarker::boundingRect() const
7892
{
79-
qreal s = qreal(mIconSize + QPen(QColor(255,0,0)).width()) / 2.0;
93+
qreal s = qreal(mIconSize + mPenWidth) / 2.0;
8094
return QRectF(-s,-s,2.0*s,2.0*s);
8195
}
8296

‎src/gui/qgsvertexmarker.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ class GUI_EXPORT QgsVertexMarker : public QgsMapCanvasItem
4343

4444
void setIconSize(int iconSize);
4545

46+
void setColor(const QColor& color);
47+
48+
void setPenWidth(int width);
49+
4650
void paint(QPainter* p);
4751

4852
QRectF boundingRect() const;
@@ -59,6 +63,12 @@ class GUI_EXPORT QgsVertexMarker : public QgsMapCanvasItem
5963

6064
//! coordinates of the point in the center
6165
QgsPoint mCenter;
66+
67+
//! color of the marker
68+
QColor mColor;
69+
70+
//! pen width
71+
int mPenWidth;
6272
};
6373

6474
#endif

0 commit comments

Comments
 (0)
Please sign in to comment.