Example #1
0
 def startFlashFeature(self, featureGeometry, layerCrs):
     geomType = QgsWkbTypes.geometryType(featureGeometry.wkbType())
     rb = QgsRubberBand(iface.mapCanvas(), geomType)
     rb.addGeometry( featureGeometry, layerCrs )
     flashes=3
     duration=500
     if geomType == QgsWkbTypes.LineGeometry or geomType == QgsWkbTypes.PointGeometry:
         rb.setWidth( 2 )
         rb.setSecondaryStrokeColor( QColor( 255, 255, 255 ) )
     if geomType == QgsWkbTypes.PointGeometry :
         rb.setIcon( QgsRubberBand.ICON_CIRCLE )
     startColor = QColor(255, 0, 0, 255)
     startColor.setAlpha( 255 )
     endColor = QColor(255, 0, 0, 0)
     endColor.setAlpha( 0 )
     self.animation = QVariantAnimation( iface.mapCanvas() )
     self.animation.finished.connect(lambda a=self.animation, b=rb: self.finishedAnimation(a, b))
     self.animation.valueChanged.connect(lambda value, a=self.animation, b=rb, c=geomType: self.valueChangedAnimation(value, a, b, c))
     self.animation.setDuration( duration * flashes )
     self.animation.setStartValue( endColor )
     midStep = 0.2 / flashes
     for i in range(flashes):
         start = float(i  / flashes)
         self.animation.setKeyValueAt( start + midStep, startColor )
         end = float(( i + 1 ) / flashes)
         if not(end == 1.0):
             self.animation.setKeyValueAt( end, endColor )
     self.animation.setEndValue( endColor )
     self.animation.start()
Example #2
0
 def getSnapRubberBand(self):
     rubberBand = QgsRubberBand(self.canvas,
                                geometryType=QgsWkbTypes.PointGeometry)
     rubberBand.setFillColor(QColor(255, 0, 0, 40))
     rubberBand.setSecondaryStrokeColor(QColor(255, 0, 0, 200))
     rubberBand.setWidth(2)
     rubberBand.setIcon(QgsRubberBand.ICON_X)
     return rubberBand
Example #3
0
 def getRubberBand(self):
     geomType = self.iface.activeLayer().geometryType()
     if geomType == QgsWkbTypes.PolygonGeometry:
         rubberBand = QgsRubberBand(self.canvas, True)
         rubberBand.setFillColor(QColor(255, 0, 0, 40))
     elif geomType == QgsWkbTypes.LineGeometry:
         rubberBand = QgsRubberBand(self.canvas, False)
     rubberBand.setSecondaryStrokeColor(QColor(255, 0, 0, 200))
     rubberBand.setWidth(2)
     return rubberBand