disable_ok_button.diff
| python/plugins/fTools/tools/doJoinAttributes.py (working copy) | ||
|---|---|---|
| 53 | 53 |
QObject.connect(self.rdoTable, SIGNAL("clicked()"), self.updateTableFields)
|
| 54 | 54 |
QObject.connect(self.rdoVector, SIGNAL("clicked()"), self.jupdate)
|
| 55 | 55 |
self.setWindowTitle( self.tr("Join attributes") )
|
| 56 |
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) |
|
| 56 | 57 |
# populate layer list |
| 57 | 58 |
self.progressBar.setValue(0) |
| 58 | 59 |
mapCanvas = self.iface.mapCanvas() |
| ... | ... | |
| 77 | 78 |
self.joinField.addItem(unicode(changedField[i].name())) |
| 78 | 79 |
|
| 79 | 80 |
def accept(self): |
| 81 |
self.buttonOk.setEnabled( False ) |
|
| 80 | 82 |
if self.inShape.currentText() == "": |
| 81 | 83 |
QMessageBox.information(self, self.tr("Join Attributes"), self.tr("Please specify target vector layer"))
|
| 82 | 84 |
elif self.outShape.text() == "": |
| ... | ... | |
| 112 | 114 |
QMessageBox.warning( self, self.tr("Geoprocessing"), self.tr( "Error loading output shapefile:\n%1" )
|
| 113 | 115 |
.arg( unicode( outPath ) )) |
| 114 | 116 |
self.progressBar.setValue(0) |
| 117 |
self.buttonOk.setEnabled( True ) |
|
| 115 | 118 | |
| 116 | 119 |
def outFile(self): |
| 117 | 120 |
self.outShape.clear() |
| python/plugins/fTools/tools/doGeoprocessing.py (working copy) | ||
|---|---|---|
| 22 | 22 |
self.manageGui() |
| 23 | 23 |
self.success = False |
| 24 | 24 |
self.cancel_close = self.buttonBox_2.button( QDialogButtonBox.Close ) |
| 25 |
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) |
|
| 25 | 26 |
self.progressBar.setValue (0 ) |
| 26 | 27 |
|
| 27 | 28 |
def checkA( self ): |
| ... | ... | |
| 180 | 181 |
if not QgsVectorFileWriter.deleteShapeFile( self.shapefileName ): |
| 181 | 182 |
QMessageBox.warning( self, self.tr("Geoprocessing"), self.tr( "Unable to delete existing shapefile." ) )
|
| 182 | 183 |
return |
| 184 |
self.buttonOk.setEnabled( False ) |
|
| 183 | 185 |
self.testThread = geoprocessingThread( self.iface.mainWindow(), self, self.myFunction, myLayerA, |
| 184 | 186 |
myLayerB, myParam, myMerge, mySelectionA, mySelectionB, self.shapefileName, self.encoding ) |
| 185 | 187 |
QObject.connect( self.testThread, SIGNAL( "runFinished(PyQt_PyObject)" ), self.runFinishedFromThread ) |
| ... | ... | |
| 192 | 194 |
|
| 193 | 195 |
def cancelThread( self ): |
| 194 | 196 |
self.testThread.stop() |
| 197 |
self.buttonOk.setEnabled( True ) |
|
| 195 | 198 |
|
| 196 | 199 |
def runFinishedFromThread( self, results ): |
| 197 | 200 |
self.testThread.stop() |
| 201 |
self.buttonOk.setEnabled( True ) |
|
| 198 | 202 |
self.cancel_close.setText( self.tr("Close") )
|
| 199 | 203 |
QObject.disconnect( self.cancel_close, SIGNAL( "clicked()" ), self.cancelThread ) |
| 200 | 204 |
out_text = "" |
| python/plugins/fTools/tools/doSpatialJoin.py (working copy) | ||
|---|---|---|
| 48 | 48 |
self.setupUi(self) |
| 49 | 49 |
QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile)
|
| 50 | 50 |
self.setWindowTitle( self.tr("Join attributes by location") )
|
| 51 |
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) |
|
| 51 | 52 |
# populate layer list |
| 52 | 53 |
self.progressBar.setValue(0) |
| 53 | 54 |
mapCanvas = self.iface.mapCanvas() |
| ... | ... | |
| 56 | 57 |
self.joinShape.addItems(layers) |
| 57 | 58 |
|
| 58 | 59 |
def accept(self): |
| 60 |
self.buttonOk.setEnabled( False ) |
|
| 59 | 61 |
if self.inShape.currentText() == "": |
| 60 | 62 |
QMessageBox.information(self, self.tr("Spatial Join"), self.tr("Please specify target vector layer") )
|
| 61 | 63 |
elif self.outShape.text() == "": |
| ... | ... | |
| 96 | 98 |
self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr") |
| 97 | 99 |
QgsMapLayerRegistry.instance().addMapLayer(self.vlayer) |
| 98 | 100 |
self.progressBar.setValue(0) |
| 101 |
self.buttonOk.setEnabled( True ) |
|
| 99 | 102 | |
| 100 | 103 |
def outFile(self): |
| 101 | 104 |
self.outShape.clear() |
| python/plugins/fTools/tools/doVectorSplit.py (working copy) | ||
|---|---|---|
| 45 | 45 |
QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile)
|
| 46 | 46 |
QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.update)
|
| 47 | 47 |
self.setWindowTitle(self.tr("Split vector layer"))
|
| 48 |
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) |
|
| 48 | 49 |
# populate layer list |
| 49 | 50 |
self.progressBar.setValue(0) |
| 50 | 51 |
mapCanvas = self.iface.mapCanvas() |
| ... | ... | |
| 59 | 60 |
self.inField.addItem(unicode(changedField[i].name())) |
| 60 | 61 | |
| 61 | 62 |
def accept(self): |
| 63 |
self.buttonOk.setEnabled( False ) |
|
| 62 | 64 |
if self.inShape.currentText() == "": |
| 63 | 65 |
QMessageBox.information(self, self.tr("Vector Split"), self.tr("No input shapefile specified"))
|
| 64 | 66 |
elif self.outShape.text() == "": |
| ... | ... | |
| 77 | 79 |
self.progressBar.setValue(100) |
| 78 | 80 |
self.outShape.clear() |
| 79 | 81 |
QMessageBox.information(self, self.tr("Vector Split"), self.tr("Created output shapefiles in folder:\n%1").arg( outPath))
|
| 80 |
self.progressBar.setValue(0) |
|
| 82 |
self.progressBar.setValue(0) |
|
| 83 |
self.buttonOk.setEnabled( True ) |
|
| 81 | 84 | |
| 82 | 85 |
def outFile(self): |
| 83 |
fileDialog = QFileDialog() |
|
| 84 |
settings = QSettings() |
|
| 85 |
dirName = settings.value("/UI/lastShapefileDir").toString()
|
|
| 86 |
fileDialog.setDirectory(dirName) |
|
| 87 |
encodingBox = QComboBox() |
|
| 88 |
l = QLabel("Encoding:",fileDialog)
|
|
| 89 |
fileDialog.layout().addWidget(l) |
|
| 90 |
fileDialog.layout().addWidget(encodingBox) |
|
| 91 |
encodingBox.addItem("BIG5")
|
|
| 92 |
encodingBox.addItem("BIG5-HKSCS")
|
|
| 93 |
encodingBox.addItem("EUCJP")
|
|
| 94 |
encodingBox.addItem("EUCKR")
|
|
| 95 |
encodingBox.addItem("GB2312")
|
|
| 96 |
encodingBox.addItem("GBK")
|
|
| 97 |
encodingBox.addItem("GB18030")
|
|
| 98 |
encodingBox.addItem("JIS7")
|
|
| 99 |
encodingBox.addItem("SHIFT-JIS")
|
|
| 100 |
encodingBox.addItem("TSCII")
|
|
| 101 |
encodingBox.addItem("UTF-8")
|
|
| 102 |
encodingBox.addItem("UTF-16")
|
|
| 103 |
encodingBox.addItem("KOI8-R")
|
|
| 104 |
encodingBox.addItem("KOI8-U")
|
|
| 105 |
encodingBox.addItem("ISO8859-1")
|
|
| 106 |
encodingBox.addItem("ISO8859-2")
|
|
| 107 |
encodingBox.addItem("ISO8859-3")
|
|
| 108 |
encodingBox.addItem("ISO8859-4")
|
|
| 109 |
encodingBox.addItem("ISO8859-5")
|
|
| 110 |
encodingBox.addItem("ISO8859-6")
|
|
| 111 |
encodingBox.addItem("ISO8859-7")
|
|
| 112 |
encodingBox.addItem("ISO8859-8")
|
|
| 113 |
encodingBox.addItem("ISO8859-8-I")
|
|
| 114 |
encodingBox.addItem("ISO8859-9")
|
|
| 115 |
encodingBox.addItem("ISO8859-10")
|
|
| 116 |
encodingBox.addItem("ISO8859-13")
|
|
| 117 |
encodingBox.addItem("ISO8859-14")
|
|
| 118 |
encodingBox.addItem("ISO8859-15")
|
|
| 119 |
encodingBox.addItem("IBM 850")
|
|
| 120 |
encodingBox.addItem("IBM 866")
|
|
| 121 |
encodingBox.addItem("CP874")
|
|
| 122 |
encodingBox.addItem("CP1250")
|
|
| 123 |
encodingBox.addItem("CP1251")
|
|
| 124 |
encodingBox.addItem("CP1252")
|
|
| 125 |
encodingBox.addItem("CP1253")
|
|
| 126 |
encodingBox.addItem("CP1254")
|
|
| 127 |
encodingBox.addItem("CP1255")
|
|
| 128 |
encodingBox.addItem("CP1256")
|
|
| 129 |
encodingBox.addItem("CP1257")
|
|
| 130 |
encodingBox.addItem("CP1258")
|
|
| 131 |
encodingBox.addItem("Apple Roman")
|
|
| 132 |
encodingBox.addItem("TIS-620")
|
|
| 133 |
encodingBox.setItemText(encodingBox.currentIndex(), QString(QTextCodec.codecForLocale().name())) |
|
| 134 |
fileDialog.setAcceptMode(QFileDialog.AcceptSave) |
|
| 135 |
fileDialog.setFileMode(QFileDialog.DirectoryOnly) |
|
| 136 |
fileDialog.setConfirmOverwrite(False) |
|
| 137 |
if not fileDialog.exec_() == 1: |
|
| 138 |
return |
|
| 139 |
folders = fileDialog.selectedFiles() |
|
| 140 |
self.folderName = unicode(folders.first()) |
|
| 141 |
self.encoding = unicode(encodingBox.currentText()) |
|
| 142 | 86 |
self.outShape.clear() |
| 143 |
self.outShape.insert(self.folderName) |
|
| 87 |
( self.shapefileName, self.encoding ) = ftools_utils.saveDialog( self ) |
|
| 88 |
if self.shapefileName is None or self.encoding is None: |
|
| 89 |
return |
|
| 90 |
self.outShape.setText( QString( self.shapefileName ) ) |
|
| 144 | 91 | |
| 145 | 92 |
def split(self, vlayer, outPath, inField, progressBar): |
| 146 | 93 |
provider = vlayer.dataProvider() |
| python/plugins/fTools/tools/doDefineProj.py (working copy) | ||
|---|---|---|
| 19 | 19 |
self.label_2.setVisible(False) |
| 20 | 20 |
self.label_2.setEnabled(False) |
| 21 | 21 |
self.setWindowTitle(self.tr("Define current projection"))
|
| 22 |
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) |
|
| 22 | 23 |
QObject.connect(self.btnProjection, SIGNAL("clicked()"), self.outProjFile)
|
| 23 | 24 |
QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.updateProj1)
|
| 24 | 25 |
QObject.connect(self.cmbLayer, SIGNAL("currentIndexChanged(QString)"), self.updateProj2)
|
| ... | ... | |
| 42 | 43 |
self.outRef.insert(unicode(crs)) |
| 43 | 44 | |
| 44 | 45 |
def accept(self): |
| 46 |
self.buttonOk.setEnabled( False ) |
|
| 45 | 47 |
if self.inShape.currentText() == "": |
| 46 | 48 |
QMessageBox.information(self, self.tr("Define current projection"), self.tr("No input shapefile specified"))
|
| 47 | 49 |
elif self.txtProjection.text() == "" and self.rdoProjection.isChecked(): |
| ... | ... | |
| 103 | 105 |
self.progressBar.setValue(100) |
| 104 | 106 |
QMessageBox.information(self, self.tr("Define current projection"), self.tr("Defined Projection For:\n%1.shp").arg( inPath ) )
|
| 105 | 107 |
self.progressBar.setValue(0) |
| 108 |
self.buttonOk.setEnabled( True ) |
|
| 106 | 109 | |
| 107 | 110 |
def outProjFile(self): |
| 108 | 111 |
format = QString( "<h2>%1</h2>%2 <br/> %3" ) |
| python/plugins/fTools/tools/doMeanCoords.py (working copy) | ||
|---|---|---|
| 15 | 15 |
self.updateUi() |
| 16 | 16 |
QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile)
|
| 17 | 17 |
QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.update)
|
| 18 |
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) |
|
| 18 | 19 | |
| 19 | 20 |
# populate layer list |
| 20 | 21 |
self.progressBar.setValue(0) |
| ... | ... | |
| 44 | 45 |
self.uniqueField.addItem(unicode(changedField[i].name())) |
| 45 | 46 | |
| 46 | 47 |
def accept(self): |
| 48 |
self.buttonOk.setEnabled( False ) |
|
| 47 | 49 |
if self.inShape.currentText() == "": |
| 48 | 50 |
QMessageBox.information(self, self.tr("Coordinate statistics"), self.tr("No input vector layer specified"))
|
| 49 | 51 |
elif self.outShape.text() == "": |
| ... | ... | |
| 74 | 76 |
render.addSymbol(symbol) |
| 75 | 77 |
self.vlayer.setRenderer(render) |
| 76 | 78 |
QgsMapLayerRegistry.instance().addMapLayer(self.vlayer) |
| 77 |
self.progressBar.setValue(0) |
|
| 79 |
self.progressBar.setValue(0) |
|
| 80 |
self.buttonOk.setEnabled( True ) |
|
| 78 | 81 | |
| 79 | 82 |
def outFile(self): |
| 80 | 83 |
self.outShape.clear() |
| ... | ... | |
| 137 | 140 |
else: |
| 138 | 141 |
weight = float(feat.attributeMap()[weightIndex].toDouble()[0]) |
| 139 | 142 |
geom = QgsGeometry(feat.geometry()) |
| 140 |
geom = self.extract(geom)
|
|
| 143 |
geom = ftools_utils.extractPoints(geom)
|
|
| 141 | 144 |
for i in geom: |
| 142 | 145 |
cx += i.x() |
| 143 | 146 |
cy += i.y() |
| ... | ... | |
| 180 | 183 |
if single: |
| 181 | 184 |
break |
| 182 | 185 |
del writer |
| 183 | ||
| 184 |
def extract(self, geom): |
|
| 185 |
multi_geom = QgsGeometry() |
|
| 186 |
temp_geom = [] |
|
| 187 |
if geom.type() == 0: # it's a point |
|
| 188 |
if geom.isMultipart(): |
|
| 189 |
temp_geom = geom.asMultiPoint() |
|
| 190 |
else: |
|
| 191 |
temp_geom.append(geom.asPoint()) |
|
| 192 |
if geom.type() == 1: # it's a line |
|
| 193 |
if geom.isMultipart(): |
|
| 194 |
multi_geom = geom.asMultiPolyline() #multi_geog is a multiline |
|
| 195 |
for i in multi_geom: #i is a line |
|
| 196 |
temp_geom.extend(i) |
|
| 197 |
else: |
|
| 198 |
temp_geom = geom.asPolyline() |
|
| 199 |
elif geom.type() == 2: # it's a polygon |
|
| 200 |
if geom.isMultipart(): |
|
| 201 |
multi_geom = geom.asMultiPolygon() #multi_geom is a multipolygon |
|
| 202 |
for i in multi_geom: #i is a polygon |
|
| 203 |
for j in i: #j is a line |
|
| 204 |
temp_geom.extend(j) |
|
| 205 |
else: |
|
| 206 |
multi_geom = geom.asPolygon() #multi_geom is a polygon |
|
| 207 |
for i in multi_geom: #i is a line |
|
| 208 |
temp_geom.extend(i) |
|
| 209 |
return temp_geom |
|
| 210 | ||
| python/plugins/fTools/tools/doSelectByLocation.py (working copy) | ||
|---|---|---|
| 12 | 12 |
self.iface = iface |
| 13 | 13 |
# Set up the user interface from Designer. |
| 14 | 14 |
self.setupUi(self) |
| 15 |
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) |
|
| 15 | 16 | |
| 16 | 17 |
# populate layer list |
| 17 | 18 |
self.progressBar.setValue(0) |
| ... | ... | |
| 41 | 42 |
self.resize(381, 100) |
| 42 | 43 | |
| 43 | 44 |
def accept(self): |
| 45 |
self.buttonOk.setEnabled( False ) |
|
| 44 | 46 |
if self.inPolygon.currentText() == "": |
| 45 | 47 |
QMessageBox.information(self, self.tr("Select by location"), self.tr( "Please specify input layer"))
|
| 46 | 48 |
elif self.inPoint.currentText() == "": |
| ... | ... | |
| 50 | 52 |
inPts = self.inPoint.currentText() |
| 51 | 53 |
self.compute(inPoly, inPts, self.cmbModify.currentText()) |
| 52 | 54 |
self.progressBar.setValue(0) |
| 55 |
self.buttonOk.setEnabled( True ) |
|
| 53 | 56 | |
| 54 | 57 |
def compute(self, inPoly, inPts, modify): |
| 55 | 58 |
inputLayer = ftools_utils.getVectorLayerByName(inPoly) |
| python/plugins/fTools/tools/doSubsetSelect.py (working copy) | ||
|---|---|---|
| 45 | 45 |
self.setupUi(self) |
| 46 | 46 |
QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.update)
|
| 47 | 47 |
self.setWindowTitle(self.tr("Random selection within subsets"))
|
| 48 |
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) |
|
| 48 | 49 |
# populate layer list |
| 49 | 50 |
self.progressBar.setValue(0) |
| 50 | 51 |
mapCanvas = self.iface.mapCanvas() |
| ... | ... | |
| 61 | 62 |
self.spnNumber.setMaximum( maxFeatures ) |
| 62 | 63 | |
| 63 | 64 |
def accept(self): |
| 65 |
self.buttonOk.setEnabled( False ) |
|
| 64 | 66 |
if self.inShape.currentText() == "": |
| 65 | 67 |
QMessageBox.information(self, self.tr("Random selection within subsets"), self.tr("Please specify input vector layer"))
|
| 66 | 68 |
elif self.inField.currentText() == "": |
| ... | ... | |
| 77 | 79 |
self.compute(inVect, uidField, value, perc, self.progressBar) |
| 78 | 80 |
self.progressBar.setValue(100) |
| 79 | 81 |
self.progressBar.setValue(0) |
| 82 |
self.buttonOk.setEnabled( True ) |
|
| 80 | 83 | |
| 81 |
def outFile(self): |
|
| 82 |
self.outShape.clear() |
|
| 83 |
fileDialog = QFileDialog() |
|
| 84 |
fileDialog.setConfirmOverwrite(False) |
|
| 85 |
outName = fileDialog.getSaveFileName(self, self.tr("Output Shapefile"),".", self.tr("Shapefiles (*.shp)"))
|
|
| 86 |
fileCheck = QFile(outName) |
|
| 87 |
if fileCheck.exists(): |
|
| 88 |
QMessageBox.warning(self, self.tr("Random selection within subsets"), self.tr("Cannot overwrite existing shapefile..."))
|
|
| 89 |
else: |
|
| 90 |
filePath = QFileInfo(outName).absoluteFilePath() |
|
| 91 |
if filePath.right(4) != ".shp": filePath = filePath + ".shp" |
|
| 92 |
if not outName.isEmpty(): |
|
| 93 |
self.outShape.clear() |
|
| 94 |
self.outShape.insert(filePath) |
|
| 95 | ||
| 96 | 84 |
def compute(self, inVect, inField, value, perc, progressBar): |
| 97 | 85 |
vlayer = ftools_utils.getVectorLayerByName(inVect) |
| 98 | 86 |
vprovider = vlayer.dataProvider() |
| 99 |
mlayer = self.getMapLayerByName(inVect)
|
|
| 87 |
mlayer = ftools_utils.getMapLayerByName(inVect)
|
|
| 100 | 88 |
allAttrs = vprovider.attributeIndexes() |
| 101 | 89 |
vprovider.select(allAttrs) |
| 102 | 90 |
index = vprovider.fieldNameIndex(inField) |
| ... | ... | |
| 129 | 117 |
mlayer.setSelectedFeatures(selran) |
| 130 | 118 |
else: |
| 131 | 119 |
mlayer.setSelectedFeatures(range(0, mlayer.featureCount())) |
| 132 | ||
| 133 |
def getMapLayerByName(self, myName): |
|
| 134 |
mc = self.iface.mapCanvas() |
|
| 135 |
nLayers = mc.layerCount() |
|
| 136 |
for l in range(nLayers): |
|
| 137 |
layer = mc.layer(l) |
|
| 138 |
if layer.name() == unicode(myName,'latin1'): |
|
| 139 |
return layer |
|
| python/plugins/fTools/tools/doVectorGrid.py (working copy) | ||
|---|---|---|
| 46 | 46 |
#QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.updateInput)
|
| 47 | 47 |
QObject.connect(self.btnUpdate, SIGNAL("clicked()"), self.updateLayer)
|
| 48 | 48 |
QObject.connect(self.btnCanvas, SIGNAL("clicked()"), self.updateCanvas)
|
| 49 |
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) |
|
| 49 | 50 |
self.setWindowTitle(self.tr("Vector grid"))
|
| 50 | 51 |
self.xMin.setValidator(QDoubleValidator(self.xMin)) |
| 51 | 52 |
self.xMax.setValidator(QDoubleValidator(self.xMax)) |
| ... | ... | |
| 78 | 79 |
self.yMax.setText( unicode( boundBox.yMaximum() ) ) |
| 79 | 80 | |
| 80 | 81 |
def accept(self): |
| 82 |
self.buttonOk.setEnabled( False ) |
|
| 81 | 83 |
if self.xMin.text() == "" or self.xMax.text() == "" or self.yMin.text() == "" or self.yMax.text() == "": |
| 82 | 84 |
QMessageBox.information(self, self.tr("Vector grid"), self.tr("Please specify valid extent coordinates"))
|
| 83 | 85 |
elif self.outShape.text() == "": |
| ... | ... | |
| 100 | 102 |
addToTOC = QMessageBox.question(self, self.tr("Generate Vector Grid"), self.tr("Created output shapefile:\n%1\n\nWould you like to add the new layer to the TOC?").arg(unicode(self.shapefileName)), QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton)
|
| 101 | 103 |
if addToTOC == QMessageBox.Yes: |
| 102 | 104 |
ftools_utils.addShapeToCanvas( self.shapefileName ) |
| 103 |
self.progressBar.setValue( 0 ) |
|
| 105 |
self.progressBar.setValue( 0 ) |
|
| 106 |
self.buttonOk.setEnabled( True ) |
|
| 104 | 107 | |
| 105 | 108 |
def compute( self, bound, xOffset, yOffset, polygon ): |
| 106 | 109 |
crs = self.iface.mapCanvas().mapRenderer().destinationSrs() |
| python/plugins/fTools/tools/doRegPoints.py (working copy) | ||
|---|---|---|
| 50 | 50 |
self.yMax.setValidator(QDoubleValidator(self.yMax)) |
| 51 | 51 |
QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile)
|
| 52 | 52 |
self.setWindowTitle( self.tr("Regular points") )
|
| 53 |
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) |
|
| 53 | 54 |
self.progressBar.setValue(0) |
| 54 | 55 |
self.mapCanvas = self.iface.mapCanvas() |
| 55 | 56 |
layers = ftools_utils.getLayerNames("all")
|
| 56 | 57 |
self.inShape.addItems(layers) |
| 57 | 58 | |
| 58 | 59 |
def accept(self): |
| 60 |
self.buttonOk.setEnabled( False ) |
|
| 59 | 61 |
if not self.rdoCoordinates.isChecked() and self.inShape.currentText() == "": |
| 60 | 62 |
QMessageBox.information(self, self.tr("Generate Regular Points"), self.tr("Please specify input layer"))
|
| 61 | 63 |
elif self.rdoCoordinates.isChecked() and (self.xMin.text() == "" or self.xMax.text() == "" or self.yMin.text() == "" or self.yMax.text() == ""): |
| ... | ... | |
| 90 | 92 |
if addToTOC == QMessageBox.Yes: |
| 91 | 93 |
self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr") |
| 92 | 94 |
QgsMapLayerRegistry.instance().addMapLayer(self.vlayer) |
| 93 |
self.progressBar.setValue(0) |
|
| 95 |
self.progressBar.setValue(0) |
|
| 96 |
self.buttonOk.setEnabled( True ) |
|
| 94 | 97 | |
| 95 | 98 |
def outFile(self): |
| 96 | 99 |
self.outShape.clear() |
| ... | ... | |
| 99 | 102 |
return |
| 100 | 103 |
self.outShape.setText( QString( self.shapefileName ) ) |
| 101 | 104 |
|
| 102 |
# Generate list of random points
|
|
| 105 |
# Generate list of random points |
|
| 103 | 106 |
def simpleRandom(self, n, bound, xmin, xmax, ymin, ymax): |
| 104 | 107 |
seed() |
| 105 | 108 |
points = [] |
| python/plugins/fTools/tools/doPointsInPolygon.py (working copy) | ||
|---|---|---|
| 46 | 46 |
self.setupUi(self) |
| 47 | 47 |
QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile)
|
| 48 | 48 |
self.setWindowTitle(self.tr("Count Points in Polygon"))
|
| 49 |
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) |
|
| 49 | 50 |
# populate layer list |
| 50 | 51 |
self.progressBar.setValue(0) |
| 51 | 52 |
mapCanvas = self.iface.mapCanvas() |
| ... | ... | |
| 55 | 56 |
self.inPoint.addItems(layers) |
| 56 | 57 |
|
| 57 | 58 |
def accept(self): |
| 59 |
self.buttonOk.setEnabled( False ) |
|
| 58 | 60 |
if self.inPolygon.currentText() == "": |
| 59 | 61 |
QMessageBox.information(self, self.tr("Count Points In Polygon"), self.tr("Please specify input polygon vector layer"))
|
| 60 | 62 |
elif self.outShape.text() == "": |
| ... | ... | |
| 81 | 83 |
self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr") |
| 82 | 84 |
QgsMapLayerRegistry.instance().addMapLayer(self.vlayer) |
| 83 | 85 |
self.progressBar.setValue(0) |
| 86 |
self.buttonOk.setEnabled( True ) |
|
| 84 | 87 | |
| 85 | 88 |
def outFile(self): |
| 86 | 89 |
self.outShape.clear() |
| python/plugins/fTools/tools/doRandom.py (working copy) | ||
|---|---|---|
| 21 | 21 |
self.inShape.addItems(layers) |
| 22 | 22 |
|
| 23 | 23 |
def changed(self, inputLayer): |
| 24 |
changedLayer = ftools_utils.getVectorLayerByName(inputLayer)
|
|
| 25 |
changedProvider = changedLayer.dataProvider()
|
|
| 26 |
upperVal = changedProvider.featureCount()
|
|
| 27 |
self.spnNumber.setMaximum(upperVal)
|
|
| 24 |
changedLayer = ftools_utils.getVectorLayerByName(inputLayer)
|
|
| 25 |
changedProvider = changedLayer.dataProvider()
|
|
| 26 |
upperVal = changedProvider.featureCount()
|
|
| 27 |
self.spnNumber.setMaximum(upperVal)
|
|
| 28 | 28 | |
| 29 | 29 |
def accept(self): |
| 30 |
if self.inShape.currentText() == "": |
|
| 31 |
QMessageBox.information(self, self.tr("Random Selection Tool"), self.tr("No input shapefile specified"))
|
|
| 32 |
else: |
|
| 30 |
self.buttonOk.setEnabled( False ) |
|
| 31 |
if self.inShape.currentText() == "": |
|
| 32 |
QMessageBox.information(self, self.tr("Random Selection Tool"), self.tr("No input shapefile specified"))
|
|
| 33 |
else: |
|
| 33 | 34 |
self.progressBar.setValue(10) |
| 34 | 35 |
inName = self.inShape.currentText() |
| 35 |
self.progressBar.setValue(20) |
|
| 36 |
layer = ftools_utils.getVectorLayerByName(inName) |
|
| 37 |
self.progressBar.setValue(30) |
|
| 38 |
if self.rdoNumber.isChecked(): |
|
| 39 |
value = self.spnNumber.value() |
|
| 40 |
self.progressBar.setValue(60) |
|
| 41 |
else: |
|
| 42 |
value = self.spnPercent.value() |
|
| 43 |
self.progressBar.setValue(50) |
|
| 44 |
value = int(round((value / 100.0000), 4) * layer.featureCount()) |
|
| 45 |
self.progressBar.setValue(60) |
|
| 46 |
selran = random.sample(xrange(0, layer.featureCount()), value) |
|
| 47 |
self.progressBar.setValue(70) |
|
| 48 |
self.progressBar.setValue(80) |
|
| 49 |
self.progressBar.setValue(90) |
|
| 50 |
self.progressBar.setValue(100) |
|
| 51 |
layer.setSelectedFeatures(selran) |
|
| 52 |
self.progressBar.setValue(0) |
|
| 36 |
self.progressBar.setValue(20) |
|
| 37 |
layer = ftools_utils.getVectorLayerByName(inName) |
|
| 38 |
self.progressBar.setValue(30) |
|
| 39 |
if self.rdoNumber.isChecked(): |
|
| 40 |
value = self.spnNumber.value() |
|
| 41 |
self.progressBar.setValue(60) |
|
| 42 |
else: |
|
| 43 |
value = self.spnPercent.value() |
|
| 44 |
self.progressBar.setValue(50) |
|
| 45 |
value = int(round((value / 100.0000), 4) * layer.featureCount()) |
|
| 46 |
self.progressBar.setValue(60) |
|
| 47 |
selran = random.sample(xrange(0, layer.featureCount()), value) |
|
| 48 |
self.progressBar.setValue(70) |
|
| 49 |
self.progressBar.setValue(80) |
|
| 50 |
self.progressBar.setValue(90) |
|
| 51 |
self.progressBar.setValue(100) |
|
| 52 |
layer.setSelectedFeatures(selran) |
|
| 53 |
self.progressBar.setValue(0) |
|
| 54 |
self.buttonOk.setEnabled( True ) |
|
| python/plugins/fTools/tools/doRandPoints.py (working copy) | ||
|---|---|---|
| 48 | 48 |
QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.update)
|
| 49 | 49 |
self.progressBar.setValue(0) |
| 50 | 50 |
self.setWindowTitle(self.tr("Random Points"))
|
| 51 |
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) |
|
| 51 | 52 |
self.mapCanvas = self.iface.mapCanvas() |
| 52 | 53 |
layers = ftools_utils.getLayerNames([QGis.Polygon, "Raster"]) |
| 53 | 54 |
self.inShape.addItems(layers) |
| 54 | 55 | |
| 55 |
# If input layer is changed, update field list
|
|
| 56 |
# If input layer is changed, update field list |
|
| 56 | 57 |
def update(self, inputLayer): |
| 57 | 58 |
self.cmbField.clear() |
| 58 | 59 |
changedLayer = ftools_utils.getMapLayerByName(unicode(inputLayer)) |
| ... | ... | |
| 75 | 76 |
self.cmbField.setEnabled(False) |
| 76 | 77 |
self.label_4.setEnabled(False) |
| 77 | 78 | |
| 78 |
# when 'OK' button is pressed, gather required inputs, and initiate random points generation
|
|
| 79 |
# when 'OK' button is pressed, gather required inputs, and initiate random points generation |
|
| 79 | 80 |
def accept(self): |
| 81 |
self.buttonOk.setEnabled( False ) |
|
| 80 | 82 |
if self.inShape.currentText() == "": |
| 81 | 83 |
QMessageBox.information(self, self.tr("Random Points"), self.tr("No input layer specified"))
|
| 82 | 84 |
elif self.outShape.text() == "": |
| ... | ... | |
| 127 | 129 |
if addToTOC == QMessageBox.Yes: |
| 128 | 130 |
self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr") |
| 129 | 131 |
QgsMapLayerRegistry.instance().addMapLayer(self.vlayer) |
| 130 |
self.progressBar.setValue(0) |
|
| 132 |
self.progressBar.setValue(0) |
|
| 133 |
self.buttonOk.setEnabled( True ) |
|
| 131 | 134 | |
| 132 | 135 |
def outFile(self): |
| 133 | 136 |
self.outShape.clear() |
| ... | ... | |
| 136 | 139 |
return |
| 137 | 140 |
self.outShape.setText( QString( self.shapefileName ) ) |
| 138 | 141 |
|
| 139 |
# combine all polygons in layer to create single polygon (slow for complex polygons)
|
|
| 142 |
# combine all polygons in layer to create single polygon (slow for complex polygons) |
|
| 140 | 143 |
def createSinglePolygon(self, vlayer): |
| 141 | 144 |
provider = vlayer.dataProvider() |
| 142 | 145 |
allAttrs = provider.attributeIndexes() |
| ... | ... | |
| 157 | 160 |
self.progressBar.setValue(count) |
| 158 | 161 |
return geom |
| 159 | 162 |
|
| 160 |
# Generate list of random points
|
|
| 163 |
# Generate list of random points |
|
| 161 | 164 |
def simpleRandom(self, n, bound, xmin, xmax, ymin, ymax): |
| 162 | 165 |
seed() |
| 163 | 166 |
points = [] |
| python/plugins/fTools/tools/doIntersectLines.py (working copy) | ||
|---|---|---|
| 48 | 48 |
QObject.connect(self.inLine1, SIGNAL("currentIndexChanged(QString)"), self.update1)
|
| 49 | 49 |
QObject.connect(self.inLine2, SIGNAL("currentIndexChanged(QString)"), self.update2)
|
| 50 | 50 |
self.setWindowTitle( self.tr("Line intersections") )
|
| 51 |
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) |
|
| 51 | 52 |
# populate layer list |
| 52 | 53 |
self.progressBar.setValue(0) |
| 53 | 54 |
mapCanvas = self.iface.mapCanvas() |
| ... | ... | |
| 70 | 71 |
self.inField2.addItem(unicode(changedField[i].name())) |
| 71 | 72 | |
| 72 | 73 |
def accept(self): |
| 74 |
self.buttonOk.setEnabled( False ) |
|
| 73 | 75 |
if self.inLine1.currentText() == "": |
| 74 | 76 |
QMessageBox.information(self, self.tr("Locate Line Intersections"), self.tr("Please specify input line layer") )
|
| 75 | 77 |
elif self.outShape.text() == "": |
| ... | ... | |
| 94 | 96 |
if not ftools_utils.addShapeToCanvas( unicode( outPath ) ): |
| 95 | 97 |
QMessageBox.warning( self, self.tr("Geoprocessing"), self.tr( "Error loading output shapefile:\n%1" ).arg( unicode( outPath ) ))
|
| 96 | 98 |
self.progressBar.setValue(0) |
| 99 |
self.buttonOk.setEnabled( True ) |
|
| 97 | 100 | |
| 98 | 101 |
def outFile(self): |
| 99 | 102 |
self.outShape.clear() |
| python/plugins/fTools/tools/doGeometry.py (working copy) | ||
|---|---|---|
| 14 | 14 |
self.iface = iface |
| 15 | 15 |
self.setupUi(self) |
| 16 | 16 |
self.myFunction = function |
| 17 |
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) |
|
| 17 | 18 |
QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile)
|
| 18 | 19 |
if self.myFunction == 1: |
| 19 | 20 |
QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.update)
|
| ... | ... | |
| 126 | 127 |
elif self.myFunction == 9: |
| 127 | 128 |
myList = ftools_utils.getLayerNames( "all" ) |
| 128 | 129 |
else: |
| 129 |
myList = ftools_utils.getLayerNames( [ QGis.Point, QGis.Line, QGis.Polygon ] )
|
|
| 130 |
myList = ftools_utils.getLayerNames( [ QGis.Point, QGis.Line, QGis.Polygon ] ) |
|
| 130 | 131 |
self.inShape.addItems( myList ) |
| 131 | 132 |
return |
| 132 | 133 | |
| ... | ... | |
| 151 | 152 |
if not QgsVectorFileWriter.deleteShapeFile( self.shapefileName ): |
| 152 | 153 |
QMessageBox.warning( self, self.tr("Geoprocessing"), self.tr( "Unable to delete existing shapefile." ) )
|
| 153 | 154 |
return |
| 155 |
self.buttonOk.setEnabled( False ) |
|
| 154 | 156 |
self.testThread = geometryThread( self.iface.mainWindow(), self, self.myFunction, vlayer, myParam, |
| 155 | 157 |
myField, self.shapefileName, self.encoding ) |
| 156 | 158 |
QObject.connect( self.testThread, SIGNAL( "runFinished(PyQt_PyObject)" ), self.runFinishedFromThread ) |
| ... | ... | |
| 162 | 164 | |
| 163 | 165 |
def cancelThread( self ): |
| 164 | 166 |
self.testThread.stop() |
| 167 |
self.buttonOk.setEnabled( True ) |
|
| 165 | 168 |
|
| 166 | 169 |
def runFinishedFromThread( self, success ): |
| 167 | 170 |
self.testThread.stop() |
| 171 |
self.buttonOk.setEnabled( True ) |
|
| 168 | 172 |
if success == "math_error": |
| 169 | 173 |
QMessageBox.warning( self, self.tr("Geometry"), self.tr("Error processing specified tolerance!\nPlease choose larger tolerance...") )
|
| 170 | 174 |
if not QgsVectorFileWriter.deleteShapeFile( self.shapefileName ): |
| python/plugins/fTools/tools/doReProject.py (working copy) | ||
|---|---|---|
| 18 | 18 |
QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.updateProj1)
|
| 19 | 19 |
QObject.connect(self.cmbLayer, SIGNAL("currentIndexChanged(QString)"), self.updateProj2)
|
| 20 | 20 |
self.setWindowTitle( self.tr("Export to new projection") )
|
| 21 |
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) |
|
| 21 | 22 |
self.progressBar.setValue(0) |
| 22 | 23 |
mapCanvas = self.iface.mapCanvas() |
| 23 | 24 |
layers = ftools_utils.getLayerNames([QGis.Point, QGis.Line, QGis.Polygon]) |
| ... | ... | |
| 37 | 38 |
self.outRef.insert(unicode(crs)) |
| 38 | 39 | |
| 39 | 40 |
def accept(self): |
| 41 |
self.buttonOk.setEnabled( False ) |
|
| 40 | 42 |
if self.inShape.currentText() == "": |
| 41 | 43 |
QMessageBox.information(self, self.tr("Export to new projection"), self.tr("No input layer specified"))
|
| 42 | 44 |
elif self.outShape.text() == "": |
| ... | ... | |
| 64 | 66 |
self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr") |
| 65 | 67 |
QgsMapLayerRegistry.instance().addMapLayer(self.vlayer) |
| 66 | 68 |
self.progressBar.setValue(0) |
| 69 |
self.buttonOk.setEnabled( True ) |
|
| 67 | 70 | |
| 68 | 71 |
def outProjFile(self): |
| 69 | 72 |
format = QString( "<h2>%1</h2>%2 <br/> %3" ) |
| python/plugins/fTools/tools/doSumLines.py (working copy) | ||
|---|---|---|
| 46 | 46 |
self.setupUi(self) |
| 47 | 47 |
QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile)
|
| 48 | 48 |
self.setWindowTitle(self.tr("Sum line lengths"))
|
| 49 |
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) |
|
| 49 | 50 |
# populate layer list |
| 50 | 51 |
self.progressBar.setValue(0) |
| 51 | 52 |
mapCanvas = self.iface.mapCanvas() |
| ... | ... | |
| 55 | 56 |
self.inPolygon.addItems(layers) |
| 56 | 57 |
|
| 57 | 58 |
def accept(self): |
| 59 |
self.buttonOk.setEnabled( False ) |
|
| 58 | 60 |
if self.inPolygon.currentText() == "": |
| 59 | 61 |
QMessageBox.information(self, self.tr("Sum Line Lengths In Polyons"), self.tr("Please specify input polygon vector layer"))
|
| 60 | 62 |
elif self.outShape.text() == "": |
| ... | ... | |
| 81 | 83 |
self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr") |
| 82 | 84 |
QgsMapLayerRegistry.instance().addMapLayer(self.vlayer) |
| 83 | 85 |
self.progressBar.setValue(0) |
| 86 |
self.buttonOk.setEnabled( True ) |
|
| 84 | 87 | |
| 85 | 88 |
def outFile(self): |
| 86 | 89 |
self.outShape.clear() |
| python/plugins/fTools/tools/doVisual.py (working copy) | ||
|---|---|---|
| 16 | 16 |
QObject.connect( self.inShape, SIGNAL( "currentIndexChanged(QString)" ), self.update ) |
| 17 | 17 |
self.manageGui() |
| 18 | 18 |
self.cancel_close = self.buttonBox_2.button( QDialogButtonBox.Close ) |
| 19 |
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) |
|
| 19 | 20 |
self.progressBar.setValue( 0 ) |
| 20 | 21 |
self.partProgressBar.setValue( 0 ) |
| 21 | 22 |
self.partProgressBar.setVisible( False ) |
| ... | ... | |
| 110 | 111 |
self.tblUnique.clearContents() |
| 111 | 112 |
self.tblUnique.setRowCount( 0 ) |
| 112 | 113 |
self.lstCount.clear() |
| 114 |
self.buttonOk.setEnabled( False ) |
|
| 113 | 115 |
self.testThread = visualThread( self.iface.mainWindow(), self, self.myFunction, vlayer, myField, mySelection ) |
| 114 | 116 |
QObject.connect( self.testThread, SIGNAL( "runFinished(PyQt_PyObject)" ), self.runFinishedFromThread ) |
| 115 | 117 |
QObject.connect( self.testThread, SIGNAL( "runStatus(PyQt_PyObject)" ), self.runStatusFromThread ) |
| ... | ... | |
| 123 | 125 | |
| 124 | 126 |
def cancelThread( self ): |
| 125 | 127 |
self.testThread.stop() |
| 128 |
self.buttonOk.setEnabled( True ) |
|
| 126 | 129 |
|
| 127 | 130 |
def runFinishedFromThread( self, output ): |
| 128 | 131 |
self.testThread.stop() |
| 132 |
self.buttonOk.setEnabled( True ) |
|
| 129 | 133 |
result = output[ 0 ] |
| 130 | 134 |
numRows = len( result ) |
| 131 | 135 |
self.tblUnique.setRowCount( numRows ) |
| ... | ... | |
| 195 | 199 |
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 ) |
| 196 | 200 | |
| 197 | 201 |
def stop(self): |
| 198 |
self.running = False
|
|
| 202 |
self.running = False |
|
| 199 | 203 | |
| 200 | 204 |
def list_unique_values( self, vlayer, myField ): |
| 201 | 205 |
vprovider = vlayer.dataProvider() |
| python/plugins/fTools/tools/doPointDistance.py (working copy) | ||
|---|---|---|
| 85 | 85 |
QObject.connect(self.btnFile, SIGNAL("clicked()"), self.saveFile)
|
| 86 | 86 |
QObject.connect(self.inPoint1, SIGNAL("currentIndexChanged(QString)"), self.update1)
|
| 87 | 87 |
QObject.connect(self.inPoint2, SIGNAL("currentIndexChanged(QString)"), self.update2)
|
| 88 |
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) |
|
| 88 | 89 |
# populate layer list |
| 89 | 90 |
self.setWindowTitle(self.tr("Distance matrix"))
|
| 90 | 91 |
self.progressBar.setValue(0) |
| ... | ... | |
| 112 | 113 |
self.inField2.addItem(unicode(changedField[i].name())) |
| 113 | 114 | |
| 114 | 115 |
def accept(self): |
| 116 |
self.buttonOk.setEnabled( False ) |
|
| 115 | 117 |
if self.inPoint1.currentText() == "": |
| 116 | 118 |
QMessageBox.information(self, self.tr("Create Point Distance Matrix"), self.tr("Please specify input point layer"))
|
| 117 | 119 |
elif self.outFile.text() == "": |
| ... | ... | |
| 144 | 146 |
self.progressBar.setValue(100) |
| 145 | 147 |
addToTOC = QMessageBox.information(self, "Create Point Distance Matrix", self.tr("Created output matrix:\n") + outPath)
|
| 146 | 148 |
self.progressBar.setValue(0) |
| 149 |
self.buttonOk.setEnabled( True ) |
|
| 147 | 150 | |
| 148 | 151 |
def saveFile(self): |
| 149 | 152 |
self.outFile.clear() |