-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgeneticsimplifierdialog.py
66 lines (56 loc) · 2.88 KB
/
geneticsimplifierdialog.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
# -*- coding: utf-8 -*-
"""
/***************************************************************************
GeneticSimplifierDialog
A QGIS plugin
Line simplification tool using genetic algorithms
-------------------
begin : 2014-09-11
copyright : (C) 2014 by Luiz Andrade
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 import QtCore, QtGui
from ui_geneticsimplifier import Ui_GeneticSimplifier
# create the dialog for zoom to point
# Specific imports
import Types
from qgis.core import *
class GeneticSimplifierDialog(QtGui.QDialog, Ui_GeneticSimplifier):
def __init__(self):
QtGui.QDialog.__init__(self)
# Set up the user interface from Designer.
# After setupUI you can access any designer object by doing
# self.<objectname>, and you can use autoconnect slots - see
# http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html
# #widgets-and-dialogs-with-auto-connect
self.ui = Ui_GeneticSimplifier()
self.ui.setupUi(self)
# Get the available mate types
self.ui.mateCombo.addItems(Types.MateTypes)
# Connecting SIGNAL/SLOTS for the Output button
QtCore.QObject.connect(self.ui.inputLayerCombo, QtCore.SIGNAL("currentIndexChanged (int)"), self.updateFeatureCount)
self.layers = []
self.currentLayer = None
def updateFeatureCount(self, index):
self.currentLayer = self.layers[index]
count = self.currentLayer.featureCount()
self.ui.featureCountEdit.setText(str(count))
def saveOutputFile(self):
fileName = QtGui.QFileDialog.getSaveFileName(self, 'Save output file', '', "ShapeFile (*.shp)")
#fileName = QtGui.QFileDialog.getSaveFileName(self, 'Save output file', '', "Vector Files (*.shp *.geojson *.gml *.kml *.bna *.gdb)")
if fileName:
self.ui.outputEdit.setText(fileName)
def insertLineLayers(self, layers):
self.layers = layers
self.ui.inputLayerCombo.clear()
for layer in layers:
self.ui.inputLayerCombo.addItem(layer.name(), layer.id())