Hi giovanni.
Thank you for your reply.
After I adjust it to QGIS 1.7, I will consider.
But still not work....
(2011/06/20 18:21), Giovanni Manghi wrote:
Hi,
if the plugin can be useful for the qgis users please consider
contributing it.
cheers
-- Giovanni --
On Mon, 2011-06-20 at 16:40 +0900, ASAHI Kosuke wrote:
Dear All,
I made features select plugin used rubberband class and extended
QgsMapTool class.
It work fine in QGIS 1.6, But not work in QGIS 1.7.
After rubberBand.movePoint() in canvasMoveEvent(), it was crashed.
Please give me any advice. Is this a bug in QGIS 1.7?
All sources are here.
http://d.hatena.ne.jp/waigani/files/sweepselect_test2.zip
I use rubberband class like this.
====================================
class QgsMapToolSweepSelect(QgsMapTool):
def __init__(self, canvas):
QgsMapTool.__init__(self, canvas)
self.canvas = canvas
self.rubberBand = QgsRubberBand(canvas, True)
self.pressed = False
def canvasPressEvent(self, event):
self.center = self.toMapCoordinates(QPoint(event.pos().x(),
event.pos().y()))
for cnt in range(0,359):
self.rubberBand.addPoint(self.center, False)
self.rubberBand.addPoint(self.center, True)
self.pressed = True
def canvasMoveEvent(self, event):
if self.pressed == True:
cpos = self.toMapCoordinates(QPoint(event.pos().x(),
event.pos().y()))
len = math.sqrt((self.center.x()-cpos.x())**2 +
(self.center.y()-cpos.y())**2)
for cnt in range(0,361):
x = math.cos(math.radians(cnt)) * len + self.center.x()
y = math.sin(math.radians(cnt)) * len + self.center.y()
self.rubberBand.movePoint(cnt, QgsPoint(x,y))
def canvasReleaseEvent(self, event):
layer = self.canvas.currentLayer()
if layer == None or layer.type() != QgsMapLayer.VectorLayer:
self.rubberBand.reset()
self.pressed = False
return
layer.removeSelection()
circle = self.rubberBand.asGeometry()
fid = []
provider = layer.dataProvider()
provider.select([], circle.boundingBox(), True, True)
feat = QgsFeature()
while provider.nextFeature(feat):
if circle.intersects(feat.geometry()):
fid.append(feat.id())
for id in fid:
layer.select(id)
self.rubberBand.reset(True)
self.pressed = False
--
ASAHI Kosuke
_______________________________________________
Qgis-user mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/qgis-user