On Tue, Sep 14, 2010 at 11:29 AM, Paolo Cavallini <[email protected]> wrote:
>
> Hi all.
> we're using the very nice FH plugin, and we encountered the following
> issues:
>
> - when clicking (a single click) on the canvas, with simplification
> parameter >0, we get an error:
This patch will fix the problem with single click to canvas. Please
test attached file or patch.
Ivan
# -*- coding: utf-8 -*-
#-----------------------------------------------------------
#
# Freehand Editing
# Copyright (C) 2010 Pavol Kapusta
# [email protected]
#
# Code adopted/adapted from:
#
# 'CadTools Plugin', Copyright (C) Stefan Ziegler
# 'Select Plus Plugin', Copyright (C) Barry Rowlingson
# 'Numerical Vertex Edit Plugin', Copyright (C) Cédric Möri
#
#-----------------------------------------------------------
#
# licensed under the terms of GNU GPL 2
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#---------------------------------------------------------------------
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.core import *
from qgis.gui import *
# Tool class
class FreehandEditingTool(QgsMapTool):
def __init__(self, canvas):
QgsMapTool.__init__(self,canvas)
self.canvas=canvas
self.rb=None
self.layer=None
#our own fancy cursor
self.cursor = QCursor(QPixmap(["16 16 3 1",
" c None",
". c #FF0000",
"+ c #faed55",
" ",
" +.+ ",
" ++.++ ",
" +.....+ ",
" +. . .+ ",
" +. . .+ ",
" +. . .+ ",
" ++. . .++",
" ... ...+... ...",
" ++. . .++",
" +. . .+ ",
" +. . .+ ",
" ++. . .+ ",
" ++.....+ ",
" ++.++ ",
" +.+ "]))
def canvasPressEvent(self,event):
color = QColor(255,0,0)
self.rb = QgsRubberBand(self.canvas, False)
self.rb.setColor(color)
self.rb.setWidth(1)
if self.rb:
return
self.layer = self.canvas.currentLayer()
p=self.toLayerCoordinates(self.layer,event.pos())
self.rb.addPoint(self.toMapCoordinates(self.layer, p))
def canvasMoveEvent(self,event):
if not self.rb:
return
self.layer = self.canvas.currentLayer()
p=self.toLayerCoordinates(self.layer,event.pos())
self.rb.addPoint(self.toMapCoordinates(self.layer, p))
def canvasReleaseEvent(self,event):
coords = []
if not self.rb:
return
if self.rb.numberOfVertices() > 2:
[coords.append(self.rb.getPoint(0, i)) for i in range(self.rb.numberOfVertices())]
self.emit(SIGNAL("rbFinished(PyQt_PyObject)"), coords)
self.rb.reset()
self.rb=None
# reset rubberband and refresh the canvas
if self.type == 1:
self.isPolygon = False
else:
self.isPolygon = True
self.canvas.refresh()
def showSettingsWarning(self):
pass
def activate(self):
self.canvas.setCursor(self.cursor)
# Check whether Geometry is a Line or a Polygon
mc = self.canvas
layer = mc.currentLayer()
self.type = layer.geometryType()
self.isPolygon = True
if self.type == 1:
self.isPolygon = False
else:
self.isPolygon = True
def deactivate(self):
pass
def isZoomTool(self):
return False
def isTransient(self):
return False
def isEditTool(self):
return True
# HG changeset patch
# User Ivan Mincik
# Date 1284662261 -7200
# Node ID 3809bdb9470fb2d17dfa626633ae6e768219c9af
# Parent 0020b18800258e770fb56e6967359acb578027db
* Fixing problem with error on left click to canvas.
diff -r 0020b1880025 -r 3809bdb9470f freehandeditingtool.py
--- a/freehandeditingtool.py Thu Sep 16 20:37:26 2010 +0200
+++ b/freehandeditingtool.py Thu Sep 16 20:37:41 2010 +0200
@@ -96,7 +96,7 @@
return
if self.rb.numberOfVertices() > 2:
[coords.append(self.rb.getPoint(0, i)) for i in range(self.rb.numberOfVertices())]
- self.emit(SIGNAL("rbFinished(PyQt_PyObject)"), coords)
+ self.emit(SIGNAL("rbFinished(PyQt_PyObject)"), coords)
self.rb.reset()
self.rb=None
_______________________________________________
Qgis-developer mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/qgis-developer