forked from clusterpy/clusterpy_qgis_plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clusterpy_light.py
79 lines (66 loc) · 3.15 KB
/
clusterpy_light.py
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
71
72
73
74
75
76
77
78
79
# -*- coding: utf-8 -*-
"""
/***************************************************************************
clusterpy_light
A QGIS plugin
Clusterpy plugin version for QGIS
-------------------
begin : 2014-01-24
copyright : (C) 2014 by RISE Group Universidad EAFIT
email : [email protected]
***************************************************************************/
/***************************************************************************
* *
* 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.QtCore import *
from PyQt4.QtGui import *
from qgis.core import *
import resources_rc
from clusterpy_lightdialog import maxpDialog, aboutDialog
import os.path
class clusterpy_light:
CLSP_MENU = u"&Clusterpy - Spatially constrained clustering"
def __init__(self, iface):
self.iface = iface
self.plugin_dir = os.path.dirname(__file__)
locale = QSettings().value("locale/userLocale")[0:2]
localePath = os.path.join(self.plugin_dir,
'i18n',
'clusterpy_light_{}.qm'.format(locale))
if os.path.exists(localePath):
self.translator = QTranslator()
self.translator.load(localePath)
if qVersion() > '4.3.3':
QCoreApplication.installTranslator(self.translator)
self.mc = self.iface.mapCanvas()
self.maxpdlg = maxpDialog()
self.maxpdlg.mc = self.mc
self.maxpdlg.iface = self.iface
self.aboutdlg = aboutDialog()
def initGui(self):
default_icon = QIcon(":/uifiles/clusterpy.png")
rise_icon = QIcon(":/uifiles/rise1.png")
self.maxpaction = QAction(default_icon, u"Max-p Algorithm",
self.iface.mainWindow())
self.maxpaction.triggered.connect(self.maxp)
self.aboutaction = QAction(rise_icon, u"About RISE",
self.iface.mainWindow())
self.aboutaction.triggered.connect(self.about)
self.iface.addPluginToMenu(self.CLSP_MENU, self.maxpaction)
self.iface.addPluginToMenu(self.CLSP_MENU, self.aboutaction)
def unload(self):
self.iface.removePluginMenu(self.CLSP_MENU, self.maxpaction)
self.iface.removePluginMenu(self.CLSP_MENU, self.aboutaction)
def about(self):
self.aboutdlg.show()
def maxp(self):
self.maxpdlg.show()
self.maxpdlg.layer_combo.clear()
self.maxpdlg.layer_combo.addItems([x.name() for x in self.mc.layers()])
self.maxpdlg.exec_()