diff --git a/ORStools/utils/maptools.py b/ORStools/utils/maptools.py index ac3e088c..ce9f94ef 100644 --- a/ORStools/utils/maptools.py +++ b/ORStools/utils/maptools.py @@ -48,7 +48,7 @@ def __init__(self, canvas): self.canvas = canvas QgsMapToolEmitPoint.__init__(self, self.canvas) - self.rubberBand = QgsRubberBand(self.canvas, False) + self.rubberBand = QgsRubberBand(mapCanvas=self.canvas, geometryType=QgsWkbTypes.LineGeometry) self.rubberBand.setStrokeColor(QColor(DEFAULT_COLOR)) self.rubberBand.setWidth(3) @@ -61,9 +61,10 @@ def reset(self): """reset rubber band and captured points.""" self.points = [] - self.rubberBand.reset(QgsWkbTypes.LineGeometry) + self.rubberBand.reset(geometryType=QgsWkbTypes.LineGeometry) pointDrawn = pyqtSignal(["QgsPointXY", "int"]) + def canvasReleaseEvent(self, e): """Add marker to canvas and shows line.""" new_point = self.toMapCoordinates(e.pos()) @@ -75,7 +76,7 @@ def canvasReleaseEvent(self, e): def showLine(self): """Builds rubber band from all points and adds it to the map canvas.""" - self.rubberBand.reset(QgsWkbTypes.LineGeometry) + self.rubberBand.reset(geometryType=QgsWkbTypes.LineGeometry) for point in self.points: if point == self.points[-1]: self.rubberBand.addPoint(point, True) @@ -94,39 +95,3 @@ def canvasDoubleClickEvent(self, e): def deactivate(self): super(LineTool, self).deactivate() self.deactivated.emit() - - -# class PointTool(QgsMapToolEmitPoint): -# """Point Map tool to capture mapped coordinates.""" -# -# def __init__(self, canvas, button): -# """ -# :param canvas: current map canvas -# :type: QgsMapCanvas -# -# :param button: name of 'Map!' button pressed. -# :type button: str -# """ -# -# QgsMapToolEmitPoint.__init__(self, canvas) -# self.canvas = canvas -# self.button = button -# self.cursor = QCursor(QPixmap(RESOURCE_PREFIX + 'icon_locate.png').scaledToWidth(48), 24, 24) -# -# canvasClicked = pyqtSignal(['QgsPointXY', 'QString']) -# def canvasReleaseEvent(self, event): -# #Get the click and emit a transformed point -# -# crsSrc = self.canvas.mapSettings().destinationCrs() -# -# point_oldcrs = event.mapPoint() -# -# xform = transform.transformToWGS(crsSrc) -# point_newcrs = xform.transform(point_oldcrs) -# -# QApplication.restoreOverrideCursor() -# -# self.canvasClicked.emit(point_newcrs, self.button) -# -# def activate(self): -# QApplication.setOverrideCursor(self.cursor)