本文整理汇总了Python中qgis.gui.QgsMapTool类的典型用法代码示例。如果您正苦于以下问题:Python QgsMapTool类的具体用法?Python QgsMapTool怎么用?Python QgsMapTool使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QgsMapTool类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, canvas, drawLineButton, showProfileButton): #buttonShowProf
QgsMapTool.__init__(self, canvas)
self.canvas = canvas
self.cursor = QCursor(Qt.CrossCursor)
# Red line
self.rubberband = QgsRubberBand(self.canvas)
self.rubberband.setWidth(3)
self.rubberband.setColor(QColor(231, 28, 35))
# Buttons from main dialog
self.drawLineButton = drawLineButton
self.buttonShowProf = showProfileButton
# Coordinates of drawn line points
self.pointsToDraw = []
# Temporary save double clicks
self.dblclktemp = None
# Drawn line geometry
self.drawnLine = None
# Point markers on each end of the line
self.markers = []
# Backup the last active Tool before the pofile tool became active
self.savedTool = self.canvas.mapTool()
示例2: __init__
def __init__(self, plugin):
QgsMapTool.__init__(self, plugin.iface.mapCanvas())
self.plugin = plugin
self.iface = plugin.iface
self.cursor = QCursor(QPixmap([
"16 16 3 1",
" c None",
". c #FF0000",
"+ c #FFFFFF",
" ",
" +.+ ",
" ++.++ ",
" +.....+ ",
" +. .+ ",
" +. . .+ ",
" +. . .+ ",
" ++. . .++",
" ... ...+... ...",
" ++. . .++",
" +. . .+ ",
" +. . .+ ",
" ++. .+ ",
" ++.....+ ",
" ++.++ ",
" +.+ "
]))
self.areaMarkerLayer = None
示例3: __init__
def __init__(self, canvas, iface):
"""
Tool Behaviours: (all behaviours start edition, except for rectangle one)
1- Left Click: Clears previous selection, selects feature, sets feature layer as active layer.
The selection is done with the following priority: Point, Line then Polygon.
Selection is only done in visible layer.
2- Control + Left Click: Adds to selection selected feature. This selection follows the priority in item 1.
3- Right Click: Opens feature form
4- Control + Right Click: clears selection and set feature's layer as activeLayer. activeLayer's definition
follows priority of item 1;
5- Shift + drag and drop: draws a rectangle, then features that intersect this rectangl'e are added to selection
"""
self.iface = iface
self.canvas = canvas
self.toolAction = None
QgsMapTool.__init__(self, self.canvas)
self.rubberBand = QgsRubberBand(self.canvas, QGis.Polygon)
self.hoverRubberBand = QgsRubberBand(self.canvas, QGis.Polygon)
mFillColor = QColor( 254, 178, 76, 63 )
self.rubberBand.setColor(mFillColor)
self.hoverRubberBand.setColor(QColor( 255, 0, 0, 90 ))
self.rubberBand.setWidth(1)
self.reset()
self.blackList = self.getBlackList()
self.cursorChanged = False
self.cursorChangingHotkey = QtCore.Qt.Key_Alt
self.menuHovered = False # indicates hovering actions over context menu
示例4: activate
def activate(self):
QgsMapTool.activate(self)
self.lineRubber.setWidth(self.settings.value("rubberWidth"))
self.lineRubber.setColor(self.settings.value("rubberColor"))
layerid = self.settings.value("dimension"+self.observationType+"Layer")
layer = QgsMapLayerRegistry.instance().mapLayer(layerid)
if layer is None:
self.iface.messageBar().pushMessage("Intersect It", "Dimension layer must defined.",
QgsMessageBar.WARNING, 3)
self.mapCanvas.unsetMapTool(self)
return
if not layer.isEditable():
self.iface.messageBar().pushMessage("Intersect It", "Dimension layer must be editable to edit arcs.",
QgsMessageBar.WARNING, 3)
self.mapCanvas.unsetMapTool(self)
return
# unset this tool if the layer is removed
layer.layerDeleted.connect(self.unsetMapTool)
# create snapper for this layer
self.snapLayer = QgsSnapper.SnapLayer()
self.snapLayer.mLayer = layer
self.snapLayer.mSnapTo = QgsSnapper.SnapToVertexAndSegment
self.snapLayer.mTolerance = self.settings.value("selectTolerance")
if self.settings.value("selectUnits") == "map":
self.snapLayer.mUnitType = QgsTolerance.MapUnits
else:
self.snapLayer.mUnitType = QgsTolerance.Pixels
self.editing = False
self.drawObject = None
示例5: activate
def activate(self):
"""
Gets called when the tool is activated
"""
QgsMapTool.activate(self)
self.canvas.setCursor(self.cursor)
self.button.setChecked(True)
示例6: __init__
def __init__(self, canvas, layerfrom, layerto,
mapping, validation_method):
"""
mapping - A dict of field - field mapping with values to
copy to the new layer
"""
QgsMapTool.__init__(self, canvas)
self.layerfrom = layerfrom
self.layerto = layerto
self.fields = mapping
self.validation_method = validation_method
self.band = QgsRubberBand(canvas, QGis.Polygon )
self.band.setColor(QColor.fromRgb(255,0,0, 65))
self.band.setWidth(5)
self.cursor = QCursor(QPixmap(["16 16 3 1",
" c None",
". c #FF0000",
"+ c #FFFFFF",
" ",
" +.+ ",
" ++.++ ",
" +.....+ ",
" +. .+ ",
" +. . .+ ",
" +. . .+ ",
" ++. . .++",
" ... ...+... ...",
" ++. . .++",
" +. . .+ ",
" +. . .+ ",
" ++. .+ ",
" ++.....+ ",
" ++.++ ",
" +.+ "]))
示例7: __init__
def __init__(self, iface):
"""
Constructor
:param iface: interface
"""
QgsMapTool.__init__(self, iface.mapCanvas())
self.__iface = iface
self.icon_path = ':/plugins/VDLTools/icons/drawdown_icon.png'
self.text = QCoreApplication.translate("VDLTools", "Drawdown")
self.setCursor(Qt.ArrowCursor)
self.__isChoosed = False
self.__lastFeatureId = None
self.__lastFeature = None
self.__dockWdg = None
self.__adjDlg = None
self.__editDlg = None
self.__confDlg = None
self.__points = None
self.__layers = None
self.__altitudes = None
self.__extras = None
self.__adjustments = None
self.__inSelection = False
self.__selectedIds = None
self.__renderedIds = None
self.__selectedStarts = None
self.__selectedDirections = None
self.__startVertex = None
self.__endVertex = None
self.ownSettings = None
self.__usedMnts = None
self.__isfloating = False
self.__dockGeom = None
self.__rendered = False
示例8: __init__
def __init__(self, iface):
"""
Constructor
:param iface: interface
"""
QgsMapTool.__init__(self, iface.mapCanvas())
self.__iface = iface
self.icon_path = ':/plugins/VDLTools/icons/profile_icon.png'
self.text = QCoreApplication.translate("VDLTools", "Profile of a line")
self.__lineLayer = None
self.setCursor(Qt.ArrowCursor)
self.__isChoosed = False
self.__lastFeatureId = None
self.__lastFeature = None
self.__dockWdg = None
self.__layDlg = None
self.__msgDlg = None
self.__confDlg = None
self.__zeroDlg = None
self.__points = None
self.__layers = None
self.__features = None
self.__inSelection = False
self.__selectedIds = None
self.__selectedStarts = None
self.__selectedDirections = None
self.__startVertex = None
self.__endVertex = None
self.__rubberSit = None
self.__rubberDif = None
self.ownSettings = None
self.__usedMnts = None
self.__isfloating = False
self.__dockGeom = None
示例9: deactivate
def deactivate(self):
self.initVariable()
if self.toolAction:
self.toolAction.setChecked(False)
if self is not None:
QgsMapTool.deactivate(self)
self.canvas.unsetMapTool(self)
示例10: deactivate
def deactivate(self):
"""
When the action is deselected
"""
if self.__dockWdg is not None:
self.__dockWdg.close()
QgsMapTool.deactivate(self)
示例11: deactivate
def deactivate(self):
"""
Disable the tool.
"""
self.rubber_band.reset(QGis.Polygon)
QgsMapTool.deactivate(self)
self.deactivated.emit()
示例12: __init__
def __init__(self, iface, settings, action, index_action):
""" Class constructor """
self.iface = iface
self.canvas = self.iface.mapCanvas()
self.settings = settings
self.show_help = bool(int(self.settings.value("status/show_help", 1)))
self.index_action = index_action
self.layer_arc = None
self.layer_connec = None
self.layer_node = None
self.schema_name = None
self.controller = None
self.dao = None
# Call superclass constructor and set current action
QgsMapTool.__init__(self, self.canvas)
self.setAction(action)
# Snapper
self.snapperManager = SnappingConfigManager(self.iface)
self.snapper = QgsMapCanvasSnapper(self.canvas)
# Change map tool cursor
self.cursor = QCursor()
self.cursor.setShape(Qt.CrossCursor)
# Get default cursor
self.stdCursor = self.parent().cursor()
示例13: __init__
def __init__(self, canvas, layer):
""" Constructor.
"""
QgsMapTool.__init__(self, canvas)
self.canvas = canvas
self.layer = layer
self.setCursor(Qt.CrossCursor)
示例14: __init__
def __init__(self, canvas, layer,Parent):
QgsMapTool.__init__(self,canvas)
self.Parent = Parent
self.canvas=canvas
self.layer = layer
self.geom = None
self.rb = None
self.x0 = None
self.y0 = None
#our own fancy cursor
self.cursor = QCursor(QPixmap(["16 16 3 1",
" c None",
". c #FF0000",
"+ c #17a51a",
" ",
" +.+ ",
" ++.++ ",
" +.....+ ",
" +. . .+ ",
" +. . .+ ",
" +. . .+ ",
" ++. . .++",
" ... ...+... ...",
" ++. . .++",
" +. . .+ ",
" +. . .+ ",
" ++. . .+ ",
" ++.....+ ",
" ++.++ ",
" +.+ "]))
示例15: deactivate
def deactivate(self):
"""
Disable the tool.
"""
self.rubber_band.reset(QgsWkbTypes.PolygonGeometry)
QgsMapTool.deactivate(self)
self.deactivated.emit()