New warning when creating empty multipart layer; Ok button disabled on all functions while running; General bug fixes. Fixes #2260, #2057, and #1986. Another great patch from alexbruy :-)

git-svn-id: http://svn.osgeo.org/qgis/trunk@13481 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
cfarmer 2010-05-13 22:55:59 +00:00
parent 7f7a5ac29c
commit f4760f23bf
16 changed files with 95 additions and 89 deletions

View File

@ -19,6 +19,7 @@ class Dialog(QDialog, Ui_Dialog):
self.label_2.setVisible(False)
self.label_2.setEnabled(False)
self.setWindowTitle(self.tr("Define current projection"))
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok )
QObject.connect(self.btnProjection, SIGNAL("clicked()"), self.outProjFile)
QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.updateProj1)
QObject.connect(self.cmbLayer, SIGNAL("currentIndexChanged(QString)"), self.updateProj2)
@ -42,6 +43,7 @@ class Dialog(QDialog, Ui_Dialog):
self.outRef.insert(unicode(crs))
def accept(self):
self.buttonOk.setEnabled( False )
if self.inShape.currentText() == "":
QMessageBox.information(self, self.tr("Define current projection"), self.tr("No input shapefile specified"))
elif self.txtProjection.text() == "" and self.rdoProjection.isChecked():
@ -103,6 +105,7 @@ class Dialog(QDialog, Ui_Dialog):
self.progressBar.setValue(100)
QMessageBox.information(self, self.tr("Define current projection"), self.tr("Defined Projection For:\n%1.shp").arg( inPath ) )
self.progressBar.setValue(0)
self.buttonOk.setEnabled( True )
def outProjFile(self):
format = QString( "<h2>%1</h2>%2 <br/> %3" )

View File

@ -14,6 +14,7 @@ class GeometryDialog(QDialog, Ui_Dialog):
self.iface = iface
self.setupUi(self)
self.myFunction = function
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok )
QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile)
if self.myFunction == 1:
QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.update)
@ -126,7 +127,7 @@ class GeometryDialog(QDialog, Ui_Dialog):
elif self.myFunction == 9:
myList = ftools_utils.getLayerNames( "all" )
else:
myList = ftools_utils.getLayerNames( [ QGis.Point, QGis.Line, QGis.Polygon ] )
myList = ftools_utils.getLayerNames( [ QGis.Point, QGis.Line, QGis.Polygon ] )
self.inShape.addItems( myList )
return
@ -151,6 +152,7 @@ class GeometryDialog(QDialog, Ui_Dialog):
if not QgsVectorFileWriter.deleteShapeFile( self.shapefileName ):
QMessageBox.warning( self, self.tr("Geoprocessing"), self.tr( "Unable to delete existing shapefile." ) )
return
self.buttonOk.setEnabled( False )
self.testThread = geometryThread( self.iface.mainWindow(), self, self.myFunction, vlayer, myParam,
myField, self.shapefileName, self.encoding )
QObject.connect( self.testThread, SIGNAL( "runFinished(PyQt_PyObject)" ), self.runFinishedFromThread )
@ -162,13 +164,19 @@ class GeometryDialog(QDialog, Ui_Dialog):
def cancelThread( self ):
self.testThread.stop()
self.buttonOk.setEnabled( True )
def runFinishedFromThread( self, success ):
self.testThread.stop()
self.buttonOk.setEnabled( True )
if success == "math_error":
QMessageBox.warning( self, self.tr("Geometry"), self.tr("Error processing specified tolerance!\nPlease choose larger tolerance...") )
if not QgsVectorFileWriter.deleteShapeFile( self.shapefileName ):
QMessageBox.warning( self, self.tr("Geometry"), self.tr( "Unable to delete incomplete shapefile." ) )
elif success == "attr_error":
QMessageBox.warning( self, self.tr("Geometry"), self.tr("At least two features must have same attribute value!\nPlease choose another field...") )
if not QgsVectorFileWriter.deleteShapeFile( self.shapefileName ):
QMessageBox.warning( self, self.tr("Geometry"), self.tr( "Unable to delete incomplete shapefile." ) )
else:
self.cancel_close.setText( "Close" )
QObject.disconnect( self.cancel_close, SIGNAL( "clicked()" ), self.cancelThread )
@ -267,6 +275,8 @@ class geometryThread( QThread ):
outFeat.setGeometry( outGeom )
writer.addFeature( outFeat )
del writer
else:
return "attr_error"
return True
def multi_to_single( self ):

View File

@ -22,6 +22,7 @@ class GeoprocessingDialog( QDialog, Ui_Dialog ):
self.manageGui()
self.success = False
self.cancel_close = self.buttonBox_2.button( QDialogButtonBox.Close )
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok )
self.progressBar.setValue (0 )
def checkA( self ):
@ -180,6 +181,7 @@ class GeoprocessingDialog( QDialog, Ui_Dialog ):
if not QgsVectorFileWriter.deleteShapeFile( self.shapefileName ):
QMessageBox.warning( self, self.tr("Geoprocessing"), self.tr( "Unable to delete existing shapefile." ) )
return
self.buttonOk.setEnabled( False )
self.testThread = geoprocessingThread( self.iface.mainWindow(), self, self.myFunction, myLayerA,
myLayerB, myParam, myMerge, mySelectionA, mySelectionB, self.shapefileName, self.encoding )
QObject.connect( self.testThread, SIGNAL( "runFinished(PyQt_PyObject)" ), self.runFinishedFromThread )
@ -192,9 +194,11 @@ class GeoprocessingDialog( QDialog, Ui_Dialog ):
def cancelThread( self ):
self.testThread.stop()
self.buttonOk.setEnabled( True )
def runFinishedFromThread( self, results ):
self.testThread.stop()
self.buttonOk.setEnabled( True )
self.cancel_close.setText( self.tr("Close") )
QObject.disconnect( self.cancel_close, SIGNAL( "clicked()" ), self.cancelThread )
out_text = ""

View File

@ -48,6 +48,7 @@ class Dialog(QDialog, Ui_Dialog):
QObject.connect(self.inLine1, SIGNAL("currentIndexChanged(QString)"), self.update1)
QObject.connect(self.inLine2, SIGNAL("currentIndexChanged(QString)"), self.update2)
self.setWindowTitle( self.tr("Line intersections") )
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok )
# populate layer list
self.progressBar.setValue(0)
mapCanvas = self.iface.mapCanvas()
@ -70,6 +71,7 @@ class Dialog(QDialog, Ui_Dialog):
self.inField2.addItem(unicode(changedField[i].name()))
def accept(self):
self.buttonOk.setEnabled( False )
if self.inLine1.currentText() == "":
QMessageBox.information(self, self.tr("Locate Line Intersections"), self.tr("Please specify input line layer") )
elif self.outShape.text() == "":
@ -94,6 +96,7 @@ class Dialog(QDialog, Ui_Dialog):
if not ftools_utils.addShapeToCanvas( unicode( outPath ) ):
QMessageBox.warning( self, self.tr("Geoprocessing"), self.tr( "Error loading output shapefile:\n%1" ).arg( unicode( outPath ) ))
self.progressBar.setValue(0)
self.buttonOk.setEnabled( True )
def outFile(self):
self.outShape.clear()

View File

@ -15,6 +15,7 @@ class Dialog(QDialog, Ui_Dialog):
self.updateUi()
QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile)
QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.update)
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok )
# populate layer list
self.progressBar.setValue(0)
@ -44,6 +45,7 @@ class Dialog(QDialog, Ui_Dialog):
self.uniqueField.addItem(unicode(changedField[i].name()))
def accept(self):
self.buttonOk.setEnabled( False )
if self.inShape.currentText() == "":
QMessageBox.information(self, self.tr("Coordinate statistics"), self.tr("No input vector layer specified"))
elif self.outShape.text() == "":
@ -74,7 +76,8 @@ class Dialog(QDialog, Ui_Dialog):
render.addSymbol(symbol)
self.vlayer.setRenderer(render)
QgsMapLayerRegistry.instance().addMapLayer(self.vlayer)
self.progressBar.setValue(0)
self.progressBar.setValue(0)
self.buttonOk.setEnabled( True )
def outFile(self):
self.outShape.clear()
@ -137,7 +140,7 @@ class Dialog(QDialog, Ui_Dialog):
else:
weight = float(feat.attributeMap()[weightIndex].toDouble()[0])
geom = QgsGeometry(feat.geometry())
geom = self.extract(geom)
geom = ftools_utils.extractPoints(geom)
for i in geom:
cx += i.x()
cy += i.y()
@ -180,31 +183,3 @@ class Dialog(QDialog, Ui_Dialog):
if single:
break
del writer
def extract(self, geom):
multi_geom = QgsGeometry()
temp_geom = []
if geom.type() == 0: # it's a point
if geom.isMultipart():
temp_geom = geom.asMultiPoint()
else:
temp_geom.append(geom.asPoint())
if geom.type() == 1: # it's a line
if geom.isMultipart():
multi_geom = geom.asMultiPolyline() #multi_geog is a multiline
for i in multi_geom: #i is a line
temp_geom.extend(i)
else:
temp_geom = geom.asPolyline()
elif geom.type() == 2: # it's a polygon
if geom.isMultipart():
multi_geom = geom.asMultiPolygon() #multi_geom is a multipolygon
for i in multi_geom: #i is a polygon
for j in i: #j is a line
temp_geom.extend(j)
else:
multi_geom = geom.asPolygon() #multi_geom is a polygon
for i in multi_geom: #i is a line
temp_geom.extend(i)
return temp_geom

View File

@ -46,6 +46,7 @@ class Dialog(QDialog, Ui_Dialog):
self.setupUi(self)
QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile)
self.setWindowTitle(self.tr("Count Points in Polygon"))
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok )
# populate layer list
self.progressBar.setValue(0)
mapCanvas = self.iface.mapCanvas()
@ -55,6 +56,7 @@ class Dialog(QDialog, Ui_Dialog):
self.inPoint.addItems(layers)
def accept(self):
self.buttonOk.setEnabled( False )
if self.inPolygon.currentText() == "":
QMessageBox.information(self, self.tr("Count Points In Polygon"), self.tr("Please specify input polygon vector layer"))
elif self.outShape.text() == "":
@ -81,6 +83,7 @@ class Dialog(QDialog, Ui_Dialog):
self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
QgsMapLayerRegistry.instance().addMapLayer(self.vlayer)
self.progressBar.setValue(0)
self.buttonOk.setEnabled( True )
def outFile(self):
self.outShape.clear()

View File

@ -48,11 +48,12 @@ class Dialog(QDialog, Ui_Dialog):
QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.update)
self.progressBar.setValue(0)
self.setWindowTitle(self.tr("Random Points"))
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok )
self.mapCanvas = self.iface.mapCanvas()
layers = ftools_utils.getLayerNames([QGis.Polygon, "Raster"])
self.inShape.addItems(layers)
# If input layer is changed, update field list
# If input layer is changed, update field list
def update(self, inputLayer):
self.cmbField.clear()
changedLayer = ftools_utils.getMapLayerByName(unicode(inputLayer))
@ -75,8 +76,9 @@ class Dialog(QDialog, Ui_Dialog):
self.cmbField.setEnabled(False)
self.label_4.setEnabled(False)
# when 'OK' button is pressed, gather required inputs, and initiate random points generation
# when 'OK' button is pressed, gather required inputs, and initiate random points generation
def accept(self):
self.buttonOk.setEnabled( False )
if self.inShape.currentText() == "":
QMessageBox.information(self, self.tr("Random Points"), self.tr("No input layer specified"))
elif self.outShape.text() == "":
@ -127,7 +129,8 @@ class Dialog(QDialog, Ui_Dialog):
if addToTOC == QMessageBox.Yes:
self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
QgsMapLayerRegistry.instance().addMapLayer(self.vlayer)
self.progressBar.setValue(0)
self.progressBar.setValue(0)
self.buttonOk.setEnabled( True )
def outFile(self):
self.outShape.clear()
@ -136,7 +139,7 @@ class Dialog(QDialog, Ui_Dialog):
return
self.outShape.setText( QString( self.shapefileName ) )
# combine all polygons in layer to create single polygon (slow for complex polygons)
# combine all polygons in layer to create single polygon (slow for complex polygons)
def createSinglePolygon(self, vlayer):
provider = vlayer.dataProvider()
allAttrs = provider.attributeIndexes()
@ -157,7 +160,7 @@ class Dialog(QDialog, Ui_Dialog):
self.progressBar.setValue(count)
return geom
# Generate list of random points
# Generate list of random points
def simpleRandom(self, n, bound, xmin, xmax, ymin, ymax):
seed()
points = []

View File

@ -17,36 +17,39 @@ class Dialog(QDialog, Ui_Dialog):
# populate layer list
self.progressBar.setValue(0)
mapCanvas = self.iface.mapCanvas()
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok )
layers = ftools_utils.getLayerNames([QGis.Point, QGis.Line, QGis.Polygon])
self.inShape.addItems(layers)
def changed(self, inputLayer):
changedLayer = ftools_utils.getVectorLayerByName(inputLayer)
changedProvider = changedLayer.dataProvider()
upperVal = changedProvider.featureCount()
self.spnNumber.setMaximum(upperVal)
changedLayer = ftools_utils.getVectorLayerByName(inputLayer)
changedProvider = changedLayer.dataProvider()
upperVal = changedProvider.featureCount()
self.spnNumber.setMaximum(upperVal)
def accept(self):
if self.inShape.currentText() == "":
QMessageBox.information(self, self.tr("Random Selection Tool"), self.tr("No input shapefile specified"))
else:
self.buttonOk.setEnabled( False )
if self.inShape.currentText() == "":
QMessageBox.information(self, self.tr("Random Selection Tool"), self.tr("No input shapefile specified"))
else:
self.progressBar.setValue(10)
inName = self.inShape.currentText()
self.progressBar.setValue(20)
layer = ftools_utils.getVectorLayerByName(inName)
self.progressBar.setValue(30)
if self.rdoNumber.isChecked():
value = self.spnNumber.value()
self.progressBar.setValue(60)
else:
value = self.spnPercent.value()
self.progressBar.setValue(50)
value = int(round((value / 100.0000), 4) * layer.featureCount())
self.progressBar.setValue(60)
selran = random.sample(xrange(0, layer.featureCount()), value)
self.progressBar.setValue(70)
self.progressBar.setValue(80)
self.progressBar.setValue(90)
self.progressBar.setValue(100)
layer.setSelectedFeatures(selran)
self.progressBar.setValue(0)
self.progressBar.setValue(20)
layer = ftools_utils.getVectorLayerByName(inName)
self.progressBar.setValue(30)
if self.rdoNumber.isChecked():
value = self.spnNumber.value()
self.progressBar.setValue(60)
else:
value = self.spnPercent.value()
self.progressBar.setValue(50)
value = int(round((value / 100.0000), 4) * layer.featureCount())
self.progressBar.setValue(60)
selran = random.sample(xrange(0, layer.featureCount()), value)
self.progressBar.setValue(70)
self.progressBar.setValue(80)
self.progressBar.setValue(90)
self.progressBar.setValue(100)
layer.setSelectedFeatures(selran)
self.progressBar.setValue(0)
self.buttonOk.setEnabled( True )

View File

@ -18,6 +18,7 @@ class Dialog(QDialog, Ui_Dialog):
QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.updateProj1)
QObject.connect(self.cmbLayer, SIGNAL("currentIndexChanged(QString)"), self.updateProj2)
self.setWindowTitle( self.tr("Export to new projection") )
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok )
self.progressBar.setValue(0)
mapCanvas = self.iface.mapCanvas()
layers = ftools_utils.getLayerNames([QGis.Point, QGis.Line, QGis.Polygon])
@ -37,6 +38,7 @@ class Dialog(QDialog, Ui_Dialog):
self.outRef.insert(unicode(crs))
def accept(self):
self.buttonOk.setEnabled( False )
if self.inShape.currentText() == "":
QMessageBox.information(self, self.tr("Export to new projection"), self.tr("No input layer specified"))
elif self.outShape.text() == "":
@ -64,6 +66,7 @@ class Dialog(QDialog, Ui_Dialog):
self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
QgsMapLayerRegistry.instance().addMapLayer(self.vlayer)
self.progressBar.setValue(0)
self.buttonOk.setEnabled( True )
def outProjFile(self):
format = QString( "<h2>%1</h2>%2 <br/> %3" )

View File

@ -50,12 +50,14 @@ class Dialog(QDialog, Ui_Dialog):
self.yMax.setValidator(QDoubleValidator(self.yMax))
QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile)
self.setWindowTitle( self.tr("Regular points") )
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok )
self.progressBar.setValue(0)
self.mapCanvas = self.iface.mapCanvas()
layers = ftools_utils.getLayerNames("all")
self.inShape.addItems(layers)
def accept(self):
self.buttonOk.setEnabled( False )
if not self.rdoCoordinates.isChecked() and self.inShape.currentText() == "":
QMessageBox.information(self, self.tr("Generate Regular Points"), self.tr("Please specify input layer"))
elif self.rdoCoordinates.isChecked() and (self.xMin.text() == "" or self.xMax.text() == "" or self.yMin.text() == "" or self.yMax.text() == ""):
@ -90,7 +92,8 @@ class Dialog(QDialog, Ui_Dialog):
if addToTOC == QMessageBox.Yes:
self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
QgsMapLayerRegistry.instance().addMapLayer(self.vlayer)
self.progressBar.setValue(0)
self.progressBar.setValue(0)
self.buttonOk.setEnabled( True )
def outFile(self):
self.outShape.clear()
@ -99,7 +102,7 @@ class Dialog(QDialog, Ui_Dialog):
return
self.outShape.setText( QString( self.shapefileName ) )
# Generate list of random points
# Generate list of random points
def simpleRandom(self, n, bound, xmin, xmax, ymin, ymax):
seed()
points = []

View File

@ -12,6 +12,7 @@ class Dialog(QDialog, Ui_Dialog):
self.iface = iface
# Set up the user interface from Designer.
self.setupUi(self)
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok )
# populate layer list
self.progressBar.setValue(0)
@ -41,6 +42,7 @@ class Dialog(QDialog, Ui_Dialog):
self.resize(381, 100)
def accept(self):
self.buttonOk.setEnabled( False )
if self.inPolygon.currentText() == "":
QMessageBox.information(self, self.tr("Select by location"), self.tr( "Please specify input layer"))
elif self.inPoint.currentText() == "":
@ -50,6 +52,7 @@ class Dialog(QDialog, Ui_Dialog):
inPts = self.inPoint.currentText()
self.compute(inPoly, inPts, self.cmbModify.currentText())
self.progressBar.setValue(0)
self.buttonOk.setEnabled( True )
def compute(self, inPoly, inPts, modify):
inputLayer = ftools_utils.getVectorLayerByName(inPoly)

View File

@ -48,6 +48,7 @@ class Dialog(QDialog, Ui_Dialog):
self.setupUi(self)
QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile)
self.setWindowTitle( self.tr("Join attributes by location") )
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok )
# populate layer list
self.progressBar.setValue(0)
mapCanvas = self.iface.mapCanvas()
@ -56,6 +57,7 @@ class Dialog(QDialog, Ui_Dialog):
self.joinShape.addItems(layers)
def accept(self):
self.buttonOk.setEnabled( False )
if self.inShape.currentText() == "":
QMessageBox.information(self, self.tr("Spatial Join"), self.tr("Please specify target vector layer") )
elif self.outShape.text() == "":
@ -96,6 +98,7 @@ class Dialog(QDialog, Ui_Dialog):
self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
QgsMapLayerRegistry.instance().addMapLayer(self.vlayer)
self.progressBar.setValue(0)
self.buttonOk.setEnabled( True )
def outFile(self):
self.outShape.clear()

View File

@ -45,6 +45,7 @@ class Dialog(QDialog, Ui_Dialog):
self.setupUi(self)
QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.update)
self.setWindowTitle(self.tr("Random selection within subsets"))
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok )
# populate layer list
self.progressBar.setValue(0)
mapCanvas = self.iface.mapCanvas()
@ -61,6 +62,7 @@ class Dialog(QDialog, Ui_Dialog):
self.spnNumber.setMaximum( maxFeatures )
def accept(self):
self.buttonOk.setEnabled( False )
if self.inShape.currentText() == "":
QMessageBox.information(self, self.tr("Random selection within subsets"), self.tr("Please specify input vector layer"))
elif self.inField.currentText() == "":
@ -77,26 +79,12 @@ class Dialog(QDialog, Ui_Dialog):
self.compute(inVect, uidField, value, perc, self.progressBar)
self.progressBar.setValue(100)
self.progressBar.setValue(0)
def outFile(self):
self.outShape.clear()
fileDialog = QFileDialog()
fileDialog.setConfirmOverwrite(False)
outName = fileDialog.getSaveFileName(self, self.tr("Output Shapefile"),".", self.tr("Shapefiles (*.shp)"))
fileCheck = QFile(outName)
if fileCheck.exists():
QMessageBox.warning(self, self.tr("Random selection within subsets"), self.tr("Cannot overwrite existing shapefile..."))
else:
filePath = QFileInfo(outName).absoluteFilePath()
if filePath.right(4) != ".shp": filePath = filePath + ".shp"
if not outName.isEmpty():
self.outShape.clear()
self.outShape.insert(filePath)
self.buttonOk.setEnabled( True )
def compute(self, inVect, inField, value, perc, progressBar):
vlayer = ftools_utils.getVectorLayerByName(inVect)
vprovider = vlayer.dataProvider()
mlayer = self.getMapLayerByName(inVect)
mlayer = ftools_utils.getMapLayerByName(inVect)
allAttrs = vprovider.attributeIndexes()
vprovider.select(allAttrs)
index = vprovider.fieldNameIndex(inField)
@ -129,11 +117,3 @@ class Dialog(QDialog, Ui_Dialog):
mlayer.setSelectedFeatures(selran)
else:
mlayer.setSelectedFeatures(range(0, mlayer.featureCount()))
def getMapLayerByName(self, myName):
mc = self.iface.mapCanvas()
nLayers = mc.layerCount()
for l in range(nLayers):
layer = mc.layer(l)
if layer.name() == unicode(myName,'latin1'):
return layer

View File

@ -46,6 +46,7 @@ class Dialog(QDialog, Ui_Dialog):
self.setupUi(self)
QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile)
self.setWindowTitle(self.tr("Sum line lengths"))
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok )
# populate layer list
self.progressBar.setValue(0)
mapCanvas = self.iface.mapCanvas()
@ -55,6 +56,7 @@ class Dialog(QDialog, Ui_Dialog):
self.inPolygon.addItems(layers)
def accept(self):
self.buttonOk.setEnabled( False )
if self.inPolygon.currentText() == "":
QMessageBox.information(self, self.tr("Sum Line Lengths In Polyons"), self.tr("Please specify input polygon vector layer"))
elif self.outShape.text() == "":
@ -81,6 +83,7 @@ class Dialog(QDialog, Ui_Dialog):
self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
QgsMapLayerRegistry.instance().addMapLayer(self.vlayer)
self.progressBar.setValue(0)
self.buttonOk.setEnabled( True )
def outFile(self):
self.outShape.clear()

View File

@ -46,6 +46,7 @@ class Dialog(QDialog, Ui_Dialog):
#QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.updateInput)
QObject.connect(self.btnUpdate, SIGNAL("clicked()"), self.updateLayer)
QObject.connect(self.btnCanvas, SIGNAL("clicked()"), self.updateCanvas)
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok )
self.setWindowTitle(self.tr("Vector grid"))
self.xMin.setValidator(QDoubleValidator(self.xMin))
self.xMax.setValidator(QDoubleValidator(self.xMax))
@ -78,6 +79,7 @@ class Dialog(QDialog, Ui_Dialog):
self.yMax.setText( unicode( boundBox.yMaximum() ) )
def accept(self):
self.buttonOk.setEnabled( False )
if self.xMin.text() == "" or self.xMax.text() == "" or self.yMin.text() == "" or self.yMax.text() == "":
QMessageBox.information(self, self.tr("Vector grid"), self.tr("Please specify valid extent coordinates"))
elif self.outShape.text() == "":
@ -100,7 +102,8 @@ class Dialog(QDialog, Ui_Dialog):
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)
if addToTOC == QMessageBox.Yes:
ftools_utils.addShapeToCanvas( self.shapefileName )
self.progressBar.setValue( 0 )
self.progressBar.setValue( 0 )
self.buttonOk.setEnabled( True )
def compute( self, bound, xOffset, yOffset, polygon ):
crs = self.iface.mapCanvas().mapRenderer().destinationSrs()

View File

@ -16,6 +16,7 @@ class VisualDialog( QDialog, Ui_Dialog ):
QObject.connect( self.inShape, SIGNAL( "currentIndexChanged(QString)" ), self.update )
self.manageGui()
self.cancel_close = self.buttonBox_2.button( QDialogButtonBox.Close )
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok )
self.progressBar.setValue( 0 )
self.partProgressBar.setValue( 0 )
self.partProgressBar.setVisible( False )
@ -110,6 +111,7 @@ class VisualDialog( QDialog, Ui_Dialog ):
self.tblUnique.clearContents()
self.tblUnique.setRowCount( 0 )
self.lstCount.clear()
self.buttonOk.setEnabled( False )
self.testThread = visualThread( self.iface.mainWindow(), self, self.myFunction, vlayer, myField, mySelection )
QObject.connect( self.testThread, SIGNAL( "runFinished(PyQt_PyObject)" ), self.runFinishedFromThread )
QObject.connect( self.testThread, SIGNAL( "runStatus(PyQt_PyObject)" ), self.runStatusFromThread )
@ -123,9 +125,11 @@ class VisualDialog( QDialog, Ui_Dialog ):
def cancelThread( self ):
self.testThread.stop()
self.buttonOk.setEnabled( True )
def runFinishedFromThread( self, output ):
self.testThread.stop()
self.buttonOk.setEnabled( True )
result = output[ 0 ]
numRows = len( result )
self.tblUnique.setRowCount( numRows )
@ -195,7 +199,7 @@ class visualThread( QThread ):
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
def stop(self):
self.running = False
self.running = False
def list_unique_values( self, vlayer, myField ):
vprovider = vlayer.dataProvider()