forked from etiennesky/gridoverlay
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgridoverlay.py
More file actions
70 lines (58 loc) · 2.7 KB
/
gridoverlay.py
File metadata and controls
70 lines (58 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"""
/***************************************************************************
Grid Overlay
A QGIS plugin
Overlays a user-definable grid on the map.
-------------------
begin : 2012-05-11
copyright : (C) 2012 by John Donovan
email : mersey.viking@gmail.com
***************************************************************************/
/***************************************************************************
* *
* 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 QtGui
from qgis import core
from gridpropertiesdialog import GridPropertiesDialog
from gridpluginlayertype import GridPluginLayerType
from gridpluginlayer import GridPluginLayer
import resources
class GridOverlay:
'''
The main entry-point class.
'''
def __init__(self, iface):
# Save reference to the QGIS interface
self.iface = iface
self.action_newGrid = None
def initGui(self):
'''
Sets this up as a Quantum GIS plug-in.
'''
# Create action_newGrid that will start plugin configuration
self.action_newGrid = QtGui.QAction(
QtGui.QIcon(":/icons/icon.png"),
"Add Grid Overlay...", self.iface.mainWindow())
# Add toolbar button and menu item
self.iface.addToolBarIcon(self.action_newGrid)
self.iface.insertAddLayerAction(self.action_newGrid)
self.action_newGrid.triggered.connect(self.run)
core.QgsPluginLayerRegistry.instance().addPluginLayerType(GridPluginLayerType(self.iface))
def unload(self):
'''
Removes the plug-in menu item and icon.
'''
self.iface.removeAddLayerAction(self.action_newGrid)
self.iface.removeToolBarIcon(self.action_newGrid)
core.QgsPluginLayerRegistry.instance().removePluginLayerType(GridPluginLayer.LAYER_TYPE)
def run(self):
layer = GridPluginLayer(self.iface)
layer.showDialog()
if layer.isValid():
core.QgsMapLayerRegistry.instance().addMapLayer(layer)