Hi all,<br><br>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)<br><br>How can I delete a Marker from the map ?<br>I try to delete the QgsVertexMarker object using "del" in python but it free the memory but the icon is ever over the map.<br>
My actual solution is to "hide" the marker using no custom icon but this method still paints something (not visible) on the screen.<br><br>any suggestions<br clear="all">?<br><br>Thanks in advance<br>Luca<br><br>
<br><br><br><br><br>I have made a py plugin that plot points at a given position over an underlying map.<br>At a given rate (1 time per second for example) the points change position and move over the map.<br>I have used QgsVertexMarker to do this.<br>
<br>Now I am trying to plot instead of the "icon" make available by QgsVertexMarker class, a custom image loaded from a file.<br>SO I modified the class in the following way:<br><br><ul><li>add ICON_CUSTOM to the enum</li>
</ul><br>enum IconType<br> {<br> ICON_NONE,<br> ICON_CROSS,<br> ICON_X,<br> ICON_BOX,<br> ICON_CUSTOM<br> };<br><br><ul><li>add the method </li></ul>void QgsVertexMarker::<div id=":12f" class="ii gt">
setIconFileName (QString fname)<br>
{<br> mFileName=fname; <br><br>}<br><br><ul><li>modify the QgsVertexMarker::paint</li></ul>void QgsVertexMarker::paint( QPainter* p )<br>{<br> qreal s = ( mIconSize - 1 ) / 2;<br><br> QPen pen( mColor );<br> pen.setWidth( mPenWidth );<br>
p->setPen( pen );<br><br> switch ( mIconType )<br> {<br> case ICON_NONE:<br> break;<br><br> case ICON_CROSS:<br> p->drawLine( QLineF( -s, 0, s, 0 ) );<br> p->drawLine( QLineF( 0, -s, 0, s ) );<br>
break;<br><br> case ICON_X:<br> p->drawLine( QLineF( -s, -s, s, s ) );<br> p->drawLine( QLineF( -s, s, s, -s ) );<br> break;<br><br> case ICON_BOX:<br> p->drawLine( QLineF( -s, -s, s, -s ) );<br>
p->drawLine( QLineF( s, -s, s, s ) );<br> p->drawLine( QLineF( s, s, -s, s ) );<br> p->drawLine( QLineF( -s, s, -s, -s ) );<br> break;<br> case ICON_CUSTOM:<br> <br> QPixmap pixmap(QSize(22,22));<br>
pixmap.load(mFileName);<br> p->drawPixmap(0,0,pixmap);<br> break;<br> }<br>}<br><br><br><ul><li>update the binding file .sip</li></ul></div><br>