Advertisement
Guest User

Untitled

a guest
Jul 15th, 2019
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. from qgis.gui import QgsHighlight
  2. from PyQt4.QtCore import QTimer
  3. from PyQt4.QtGui import QColor
  4.  
  5. timer = QTimer( iface.mapCanvas() )
  6. lstHighlights = []
  7.  
  8. def flashFeatures( featureIds ):
  9. global lstHighlights
  10. for f in iface.activeLayer().getFeatures( QgsFeatureRequest().setFilterFids(featureIds) ):
  11. h = QgsHighlight( iface.mapCanvas(), f.geometry(), iface.activeLayer() )
  12. h.setColor( QColor( 255,0,0,255 ) )
  13. h.setWidth( 5 )
  14. h.setFillColor( QColor( 255,0,0,100 ) )
  15. lstHighlights.append( h )
  16. timer.start( 500 ) # Milliseconds before finishing the flash
  17.  
  18. def finishFlash():
  19. timer.stop()
  20. global lstHighlights
  21. lstHighlights = []
  22.  
  23. timer.timeout.connect( finishFlash )
  24.  
  25. flashFeatures( iface.activeLayer().selectedFeaturesIds() )
  26.  
  27. iface.activeLayer().selectionChanged.connect( flashFeatures )
  28.  
  29. canvas = iface.mapCanvas()
  30. layer = iface.activeLayer()
  31. my_features_ids = [42, 43, 45]
  32. canvas.flashFeatureIds(layer, my_feature_ids)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement