[Qgis-developer] QgsVertexMarker modified class: Plot moving points
over a map at fixed rate
Luca Pascale
pascale.luca.it at gmail.com
Tue Jul 7 10:41:04 EDT 2009
Hi all,
I have modified the class QgsVertexMarker and the plugin to plot at a fixed
rate some points over the map with a custom icon. (previous mail below)
How can I delete a Marker from the map ?
I try to delete the QgsVertexMarker object using "del" in python but it free
the memory but the icon is ever over the map.
My actual solution is to "hide" the marker using no custom icon but this
method still paints something (not visible) on the screen.
any suggestions
?
Thanks in advance
Luca
I have made a py plugin that plot points at a given position over an
underlying map.
At a given rate (1 time per second for example) the points change position
and move over the map.
I have used QgsVertexMarker to do this.
Now I am trying to plot instead of the "icon" make available by
QgsVertexMarker class, a custom image loaded from a file.
SO I modified the class in the following way:
- add ICON_CUSTOM to the enum
enum IconType
{
ICON_NONE,
ICON_CROSS,
ICON_X,
ICON_BOX,
ICON_CUSTOM
};
- add the method
void QgsVertexMarker::setIconFileName (QString fname)
{
mFileName=fname;
}
- modify the QgsVertexMarker::paint
void QgsVertexMarker::paint( QPainter* p )
{
qreal s = ( mIconSize - 1 ) / 2;
QPen pen( mColor );
pen.setWidth( mPenWidth );
p->setPen( pen );
switch ( mIconType )
{
case ICON_NONE:
break;
case ICON_CROSS:
p->drawLine( QLineF( -s, 0, s, 0 ) );
p->drawLine( QLineF( 0, -s, 0, s ) );
break;
case ICON_X:
p->drawLine( QLineF( -s, -s, s, s ) );
p->drawLine( QLineF( -s, s, s, -s ) );
break;
case ICON_BOX:
p->drawLine( QLineF( -s, -s, s, -s ) );
p->drawLine( QLineF( s, -s, s, s ) );
p->drawLine( QLineF( s, s, -s, s ) );
p->drawLine( QLineF( -s, s, -s, -s ) );
break;
case ICON_CUSTOM:
QPixmap pixmap(QSize(22,22));
pixmap.load(mFileName);
p->drawPixmap(0,0,pixmap);
break;
}
}
- update the binding file .sip
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20090707/bd7c458e/attachment.html
More information about the Qgis-developer
mailing list