Exemplo n.º 1
0
 def canvasReleaseEvent(self, e):
     super(MapToolInteractive, self).canvasReleaseEvent(e)
     e.ignore()
     if (e.button() == Qt.LeftButton):
         if self._dragging:
             # Pan map mode
             self.canvas().panActionEnd(e.pos())
             self.setCursor(CapturePointCursor)
             self._dragging = False
             e.accept()
     elif (e.button() == Qt.RightButton):
         if self._dragging:
             # Zoom mode
             self._zoomRect.setBottomRight(e.pos())
             if (self._zoomRect.topLeft() != self._zoomRect.bottomRight()):
                 coordinateTransform = self.canvas().getCoordinateTransform(
                 )
                 ll = coordinateTransform.toMapCoordinates(
                     self._zoomRect.left(), self._zoomRect.bottom())
                 ur = coordinateTransform.toMapCoordinates(
                     self._zoomRect.right(), self._zoomRect.top())
                 r = QgsRectangle()
                 r.setXMinimum(ll.x())
                 r.setYMinimum(ll.y())
                 r.setXMaximum(ur.x())
                 r.setYMaximum(ur.y())
                 r.normalize()
                 if (r.width() != 0 and r.height() != 0):
                     self.canvas().setExtent(r)
                     self.canvas().refresh()
             self._dragging = False
             if (self._zoomRubberBand is not None):
                 self.canvas().scene().removeItem(self._zoomRubberBand)
                 self._zoomRubberBand = None
             e.accept()