QgsVertexMarker: added possibility to change color and pen width

git-svn-id: http://svn.osgeo.org/qgis/trunk@6901 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
wonder 2007-04-20 10:11:08 +00:00
parent 8ba6859a2b
commit f8ba39dc6a
3 changed files with 30 additions and 2 deletions

View File

@ -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;

View File

@ -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)
@ -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:
@ -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);
}

View File

@ -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;
@ -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