[Qgis-developer] unable to load plugin

Arpita Singh singarpita at gmail.com
Tue Feb 23 12:20:01 EST 2010


Skipped content of type multipart/alternative-------------- next part --------------
# -*- coding: utf-8 -*-
"""
/***************************************************************************
    Project: Image catalog from INPE - View and order to download
    IdentifyTool  - Classes to make logic for identify tool
                -------------------
    begin      : 2009-12-16
    copyright  : (C) 2009 by CENSIPAM
    author     : Luiz P. Motta
    email      : luiz _dot_ motta _at_ sipam.gov.br
    webpage    : www.sipam.gov.br
 ***************************************************************************/
/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/
 """

from PyQt4 import QtCore, QtGui
from qgis import core

import identifywidgettool

class IdentifyTool(QtCore.QObject):
  def __init__(self, iface):
    QtCore.QObject.__init__(self) # Need emit SIGNAL
    self.__iface = iface
    self.__mapTool = identifywidgettool.IdentifyTool(iface.mapCanvas())
    self.__mapTool_bk = None # set by Run()
    self.__lyr = None # set by Run()
    self.__nameSignalMaptools = self.__mapTool.nameSignal()
    self.__nameSignal = "IdentifyTool(PyQt_PyObject)"
    self.__setConnections()
    self.__isRun = False
  # Private
  def __runTools(self):
    mapCanvas = self.__iface.mapCanvas()
    self.__mapTool_bk = mapCanvas.mapTool()
    mapCanvas.setMapTool(self.__mapTool)
    QtCore.QObject.connect(self.__mapTool, QtCore.SIGNAL(self.__nameSignalMaptools),
                                      self.__signal_identify)
    self.__isRun = True
  def __exitTool(self):
    QtCore.QObject.disconnect(self.__mapTool, QtCore.SIGNAL(self.__nameSignalMaptools),
                                         self.__signal_identify)
    mapCanvas = self.__iface.mapCanvas()
    mapCanvas.unsetMapTool(self.__mapTool)
    mapCanvas.setMapTool(self.__mapTool_bk)
    self.__isRun = False
  # Signal
  def __signal_identify(self, event):
    # Connect by __runTools()
    if event.button() == QtCore.Qt.RightButton: # Stop Tools
      self.__exitTool()
      return
    x = event.pos().x()
    y = event.pos().y()
    transform = self.__iface.mapCanvas().getCoordinateTransform()
    pointMap = transform.toMapCoordinates(x, y)
    self.emit(QtCore.SIGNAL(self.__nameSignal), pointMap)
  def __setConnections(self):
    self.connect(self.__iface.mapCanvas(), QtCore.SIGNAL("mapToolSet(QgsMapTool *)"),
                                      self.__signal_mapToolSet)
    self.connect(self.__iface, QtCore.SIGNAL("currentLayerChanged (QgsMapLayer *)"),
                self.__signal_qgis_currentLayerChanged)
  def __signal_mapToolSet(self, mapTool):
    if self.__isRun:
      self.__exitTool()
  def __signal_qgis_currentLayerChanged(self, lyrID):
    self.__exitTool()
  # Public
  def run(self,  lyr):
    if not self.__isRun:
      self.__lyr = lyr
    self.__runTools()
  def nameSignal(self):
    return self.__nameSignal
-------------- next part --------------
# -*- coding: utf-8 -*-

from PyQt4 import QtCore, QtGui
from qgis import gui

# Identify Tool class
class IdentifyTool(gui.QgsMapTool):
  def __init__(self, canvas):
    gui.QgsMapTool.__init__(self, canvas)
    self.canvas = canvas
    self.__nameSignal = "IdentifyMapTool(PyQt_PyObject)"
    pixmap =[
"16 16 33 1 0 0",
"  c #000000",
"! c #FF0000",
"# c #88AA83",
"$ c #899784",
"% c #899A84",
"& c #889E85",
"' c #899986",
"( c #879A86",
") c #889A86",
"* c #889C86",
"+ c #889E86",
", c #8A9587",
"- c #8A9787",
". c #8A9987",
"/ c #869B87",
"0 c #899B87",
"1 c #89A687",
"2 c #88A987",
"3 c #879B88",
"4 c #889F88",
"5 c #899489",
"6 c #889F89",
"7 c #8E948B",
"8 c #8B968C",
"9 c #8EA38D",
": c #8B948E",
"; c #909A8F",
"< c #909B90",
"= c #9BA19E",
"> c #A19DA6",
"? c #AD98B0",
"@ c #FFFFFF",
"A c None",
"AAAAAA!!!!!!!!!!",
"AAAAAA!999=?#14!",
"AAAAAA!7778-26*!",
"AAAAAA!:::5.&)/!",
"AAAAAA!,,,$;3(*!",
"AAAAAA!'''%>0<+!",
"AAAAAA!,,,$;3(*!",
"AAAAAA!'''%>0<+!",
"AAA  A!'''%>0<+!",
"AAA  A!!!!!!!!!!",
"AAA  AAAAAAAAAAA",
"        AAAAAAAA",
"        AAAAAAAA",
"AAA  AAAAAAAAAAA",
"AAA  AAAAAAAAAAA",
"AAA  AAAAAAAAAAA"
]
    self.cursor = QtGui.QCursor(QtGui.QPixmap(pixmap))
  def canvasPressEvent(self,event):
    pass
  def canvasMoveEvent(self,event):
    pass
  def canvasReleaseEvent(self,event):
    self.emit(QtCore.SIGNAL(self.__nameSignal), event)
  def activate(self):
    gui.QgsMapTool.activate(self)
    self.canvas.setCursor(self.cursor)
  def deactivate(self):
    gui.QgsMapTool.deactivate(self)
  def isZoomTool(self):
    return False
  def nameSignal(self):
    return self.__nameSignal


More information about the Qgis-developer mailing list