Skip to content

Commit

Permalink
QgsVertexMarker: added possibility to change color and pen width
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@6901 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Apr 20, 2007
1 parent 8ba6859 commit f8ba39d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
4 changes: 4 additions & 0 deletions python/gui/qgsvertexmarker.sip
Expand Up @@ -24,6 +24,10 @@ class QgsVertexMarker : QgsMapCanvasItem

void setIconSize(int iconSize);

void setColor(const QColor& color);

void setPenWidth(int width);

void paint(QPainter* p);

QRectF boundingRect() const;
Expand Down
18 changes: 16 additions & 2 deletions src/gui/qgsvertexmarker.cpp
Expand Up @@ -24,6 +24,8 @@ QgsVertexMarker::QgsVertexMarker(QgsMapCanvas* mapCanvas)
{
mIconSize = 10;
mIconType = ICON_X;
mColor = QColor(255,0,0);
mPenWidth = 1;
}

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

void QgsVertexMarker::setColor(const QColor& color)
{
mColor = color;
}

void QgsVertexMarker::setPenWidth(int width)
{
mPenWidth = width;
}

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

p->setPen(QColor(255,0,0));
QPen pen(mColor);
pen.setWidth(mPenWidth);
p->setPen(pen);

switch (mIconType)
{
case ICON_NONE:
Expand Down Expand Up @@ -76,7 +90,7 @@ void QgsVertexMarker::paint(QPainter* p)

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

Expand Down
10 changes: 10 additions & 0 deletions src/gui/qgsvertexmarker.h
Expand Up @@ -43,6 +43,10 @@ class GUI_EXPORT QgsVertexMarker : public QgsMapCanvasItem

void setIconSize(int iconSize);

void setColor(const QColor& color);

void setPenWidth(int width);

void paint(QPainter* p);

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

//! coordinates of the point in the center
QgsPoint mCenter;

//! color of the marker
QColor mColor;

//! pen width
int mPenWidth;
};

#endif

0 comments on commit f8ba39d

Please sign in to comment.