mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
applying patch from ticket #1714: adds option to perform geoprocessing and basic statistics functions on selected features
git-svn-id: http://svn.osgeo.org/qgis/trunk@10849 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
d37aae28a6
commit
f13f45e813
File diff suppressed because it is too large
Load Diff
@ -38,31 +38,42 @@ class VisualDialog( QDialog, Ui_Dialog ):
|
||||
if inputLayer != "":
|
||||
changedLayer = ftools_utils.getVectorLayerByName( inputLayer )
|
||||
changedField = changedLayer.dataProvider().fields()
|
||||
# for Basic statistics (with or without selection)
|
||||
if self.myFunction == 3:
|
||||
if changedLayer.selectedFeatureCount() != 0:
|
||||
self.useSelected.setCheckState( Qt.Checked )
|
||||
else:
|
||||
self.useSelected.setCheckState( Qt.Unchecked )
|
||||
# add all fields in combobox because now we can work with text fields too
|
||||
for i in changedField:
|
||||
if self.myFunction == 3:
|
||||
if changedField[i].type() == QVariant.Int or changedField[i].type() == QVariant.Double:
|
||||
self.cmbField.addItem( unicode( changedField[i].name() ) )
|
||||
else:
|
||||
self.cmbField.addItem( unicode( changedField[i].name() ) )
|
||||
self.cmbField.addItem( unicode( changedField[i].name() ) )
|
||||
|
||||
def accept( self ):
|
||||
if self.inShape.currentText() == "":
|
||||
QMessageBox.information( self, "Error!", self.tr( "Please specify input vector layer" ) )
|
||||
elif self.cmbField.isVisible() and self.cmbField.currentText() == "":
|
||||
QMessageBox.information( self, "Error!", self.tr( "Please specify input field" ) )
|
||||
else:
|
||||
self.visual( self.inShape.currentText(), self.cmbField.currentText() )
|
||||
self.visual( self.inShape.currentText(), self.cmbField.currentText(), self.useSelected.checkState() )
|
||||
|
||||
def manageGui( self ):
|
||||
if self.myFunction == 1: # Check geometry validity
|
||||
self.setWindowTitle( self.tr( "Check geometry validity" ) )
|
||||
self.cmbField.setVisible( False )
|
||||
self.label.setVisible( False )
|
||||
self.useSelected.setVisible( False )
|
||||
self.label_2.setText( self.tr( "Geometry errors" ) )
|
||||
self.label_4.setText( self.tr( "Total encountered errors" ) )
|
||||
elif self.myFunction == 2: # List unique values
|
||||
self.setWindowTitle( self.tr( "List unique values" ) )
|
||||
self.label_2.setText( self.tr( "Unique values" ) )
|
||||
self.label_4.setText(self.tr( "Total unique values" ) )
|
||||
self.useSelected.setVisible( False )
|
||||
elif self.myFunction == 3: # Basic statistics
|
||||
self.setWindowTitle( self.tr( "Basics statistics" ) )
|
||||
self.label_2.setText( self.tr( "Statistics output" ) )
|
||||
@ -73,6 +84,7 @@ class VisualDialog( QDialog, Ui_Dialog ):
|
||||
self.setWindowTitle( self.tr( "Nearest neighbour analysis" ) )
|
||||
self.cmbField.setVisible( False )
|
||||
self.label.setVisible( False )
|
||||
self.useSelected.setVisible( False )
|
||||
self.label_2.setText( self.tr( "Nearest neighbour statistics" ) )
|
||||
self.label_4.setVisible( False )
|
||||
self.lstCount.setVisible( False )
|
||||
@ -91,11 +103,11 @@ class VisualDialog( QDialog, Ui_Dialog ):
|
||||
#2: List unique values
|
||||
#3: Basic statistics
|
||||
#4: Nearest neighbour analysis
|
||||
def visual( self, myLayer, myField ):
|
||||
def visual( self, myLayer, myField, mySelection ):
|
||||
vlayer = ftools_utils.getVectorLayerByName( myLayer )
|
||||
self.lstUnique.clear()
|
||||
self.lstCount.clear()
|
||||
self.testThread = visualThread( self.iface.mainWindow(), self, self.myFunction, vlayer, myField )
|
||||
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 )
|
||||
QObject.connect( self.testThread, SIGNAL( "runRange(PyQt_PyObject)" ), self.runRangeFromThread )
|
||||
@ -122,13 +134,14 @@ class VisualDialog( QDialog, Ui_Dialog ):
|
||||
self.progressBar.setRange( range_vals[ 0 ], range_vals[ 1 ] )
|
||||
|
||||
class visualThread( QThread ):
|
||||
def __init__( self, parentThread, parentObject, function, vlayer, myField ):
|
||||
def __init__( self, parentThread, parentObject, function, vlayer, myField, mySelection ):
|
||||
QThread.__init__( self, parentThread )
|
||||
self.parent = parentObject
|
||||
self.running = False
|
||||
self.myFunction = function
|
||||
self.vlayer = vlayer
|
||||
self.myField = myField
|
||||
self.mySelection = mySelection
|
||||
# self.total = 0
|
||||
# self.currentCount = 0
|
||||
|
||||
@ -176,46 +189,127 @@ class visualThread( QThread ):
|
||||
feat = QgsFeature()
|
||||
sumVal = 0.0
|
||||
meanVal = 0.0
|
||||
stdVal = 0.0
|
||||
cvVal = 0.0
|
||||
nVal = 0.0
|
||||
values = []
|
||||
first = True
|
||||
nFeat = vprovider.featureCount()
|
||||
nElement = 0
|
||||
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
|
||||
self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
|
||||
while vprovider.nextFeature( feat ):
|
||||
atMap = feat.attributeMap()
|
||||
value = float( atMap[ index ].toDouble()[ 0 ] )
|
||||
if first:
|
||||
minVal = value
|
||||
maxVal = value
|
||||
first = False
|
||||
else:
|
||||
if value < minVal: minVal = value
|
||||
if value > maxVal: maxVal = value
|
||||
values.append( value )
|
||||
sumVal = float( sumVal + value )
|
||||
nElement += 1
|
||||
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
|
||||
nVal= float( len( values ) )
|
||||
if nVal > 0.00:
|
||||
meanVal = float( sumVal ) / nVal
|
||||
if not meanVal == 0.00:
|
||||
for val in values:
|
||||
stdVal += float( ( val - meanVal ) * ( val - meanVal ) )
|
||||
stdVal = float( math.sqrt( stdVal / nVal ) )
|
||||
cvVal = float( stdVal / meanVal )
|
||||
lstStats = []
|
||||
lstStats.append( "Mean : " + unicode( meanVal ) )
|
||||
lstStats.append( "StdDev : " + unicode( stdVal ) )
|
||||
lstStats.append( "Sum : " + unicode( sumVal) )
|
||||
lstStats.append( "Min : " + unicode( minVal ) )
|
||||
lstStats.append( "Max : " + unicode( maxVal ) )
|
||||
lstStats.append( "N : " + unicode( nVal ) )
|
||||
lstStats.append( "CV : " + unicode( cvVal ) )
|
||||
return ( lstStats, [] )
|
||||
# determine selected field type
|
||||
if ftools_utils.getFieldType( vlayer, myField ) == 'String':
|
||||
fillVal = 0
|
||||
emptyVal = 0
|
||||
if self.mySelection: # only selected features
|
||||
selection = vlayer.selectedFeatures()
|
||||
nFeat = vlayer.selectedFeatureCount()
|
||||
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
|
||||
self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
|
||||
for f in selection:
|
||||
atMap = f.attributeMap()
|
||||
lenVal = float( len( atMap[ index ].toString() ) )
|
||||
if first:
|
||||
minVal = lenVal
|
||||
maxVal = lenVal
|
||||
first = False
|
||||
else:
|
||||
if lenVal < minVal: minVal = lenVal
|
||||
if lenVal > maxVal: maxVal = lenVal
|
||||
if lenVal != 0.00:
|
||||
fillVal += 1
|
||||
else:
|
||||
emptyVal += 1
|
||||
values.append( lenVal )
|
||||
sumVal = sumVal + lenVal
|
||||
nElement += 1
|
||||
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
|
||||
else: # there is no selection, process the whole layer
|
||||
nFeat = vprovider.featureCount()
|
||||
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
|
||||
self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
|
||||
while vprovider.nextFeature( feat ):
|
||||
atMap = feat.attributeMap()
|
||||
lenVal = float( len( atMap[ index ].toString() ) )
|
||||
if first:
|
||||
minVal = lenVal
|
||||
maxVal = lenVal
|
||||
first = False
|
||||
else:
|
||||
if lenVal < minVal: minVal = lenVal
|
||||
if lenVal > maxVal: maxVal = lenVal
|
||||
if lenVal != 0.00:
|
||||
fillVal += 1
|
||||
else:
|
||||
emptyVal += 1
|
||||
values.append( lenVal )
|
||||
sumVal = sumVal + lenVal
|
||||
nElement += 1
|
||||
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
|
||||
nVal= float( len( values ) )
|
||||
if nVal > 0.00:
|
||||
meanVal = sumVal / nVal
|
||||
lstStats = []
|
||||
lstStats.append( QCoreApplication.translate( "statResult", "Max. len. : " ) + unicode( maxVal ) )
|
||||
lstStats.append( QCoreApplication.translate( "statResult", "Min. len. : " ) + unicode( minVal ) )
|
||||
lstStats.append( QCoreApplication.translate( "statResult", "Mean. len : " ) + unicode( meanVal ) )
|
||||
lstStats.append( QCoreApplication.translate( "statResult", "Filled : " ) + unicode( fillVal ) )
|
||||
lstStats.append( QCoreApplication.translate( "statResult", "Empty : " ) + unicode( emptyVal ) )
|
||||
lstStats.append( QCoreApplication.translate( "statResult", "N : " ) + unicode( nVal ) )
|
||||
return ( lstStats, [] )
|
||||
else: # numeric field
|
||||
stdVal = 0
|
||||
cvVal = 0
|
||||
if self.mySelection: # only selected features
|
||||
selection = vlayer.selectedFeatures()
|
||||
nFeat = vlayer.selectedFeatureCount()
|
||||
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
|
||||
self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
|
||||
for f in selection:
|
||||
atMap = f.attributeMap()
|
||||
value = float( atMap[ index ].toDouble()[ 0 ] )
|
||||
if first:
|
||||
minVal = value
|
||||
maxVal = value
|
||||
first = False
|
||||
else:
|
||||
if value < minVal: minVal = value
|
||||
if value > maxVal: maxVal = value
|
||||
values.append( value )
|
||||
sumVal = sumVal + value
|
||||
nElement += 1
|
||||
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
|
||||
else: # there is no selection, process the whole layer
|
||||
nFeat = vprovider.featureCount()
|
||||
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
|
||||
self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
|
||||
while vprovider.nextFeature( feat ):
|
||||
atMap = feat.attributeMap()
|
||||
value = float( atMap[ index ].toDouble()[ 0 ] )
|
||||
if first:
|
||||
minVal = value
|
||||
maxVal = value
|
||||
first = False
|
||||
else:
|
||||
if value < minVal: minVal = value
|
||||
if value > maxVal: maxVal = value
|
||||
values.append( value )
|
||||
sumVal = sumVal + value
|
||||
nElement += 1
|
||||
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
|
||||
nVal= float( len( values ) )
|
||||
if nVal > 0.00:
|
||||
meanVal = sumVal / nVal
|
||||
if meanVal != 0.00:
|
||||
for val in values:
|
||||
stdVal += ( ( val - meanVal ) * ( val - meanVal ) )
|
||||
stdVal = math.sqrt( stdVal / nVal )
|
||||
cvVal = stdVal / meanVal
|
||||
lstStats = []
|
||||
lstStats.append( "Mean : " + unicode( meanVal ) )
|
||||
lstStats.append( "StdDev : " + unicode( stdVal ) )
|
||||
lstStats.append( "Sum : " + unicode( sumVal) )
|
||||
lstStats.append( "Min : " + unicode( minVal ) )
|
||||
lstStats.append( "Max : " + unicode( maxVal ) )
|
||||
lstStats.append( "N : " + unicode( nVal ) )
|
||||
lstStats.append( "CV : " + unicode( cvVal ) )
|
||||
return ( lstStats, [] )
|
||||
|
||||
def nearest_neighbour_analysis( self, vlayer ):
|
||||
vprovider = vlayer.dataProvider()
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
# Form implementation generated from reading ui file 'frmGeoprocessing.ui'
|
||||
#
|
||||
# Created: Thu Nov 13 23:17:35 2008
|
||||
# by: PyQt4 UI code generator 4.3.3
|
||||
# Created: Tue May 26 19:00:00 2009
|
||||
# by: PyQt4 UI code generator 4.4.4
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
||||
@ -12,69 +12,54 @@ from PyQt4 import QtCore, QtGui
|
||||
class Ui_Dialog(object):
|
||||
def setupUi(self, Dialog):
|
||||
Dialog.setObjectName("Dialog")
|
||||
Dialog.resize(QtCore.QSize(QtCore.QRect(0,0,422,405).size()).expandedTo(Dialog.minimumSizeHint()))
|
||||
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum,QtGui.QSizePolicy.Preferred)
|
||||
Dialog.resize(422, 405)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Preferred)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(Dialog.sizePolicy().hasHeightForWidth())
|
||||
Dialog.setSizePolicy(sizePolicy)
|
||||
|
||||
self.gridlayout = QtGui.QGridLayout(Dialog)
|
||||
self.gridlayout.setObjectName("gridlayout")
|
||||
|
||||
self.gridLayout = QtGui.QGridLayout(Dialog)
|
||||
self.gridLayout.setObjectName("gridLayout")
|
||||
self.vboxlayout = QtGui.QVBoxLayout()
|
||||
self.vboxlayout.setObjectName("vboxlayout")
|
||||
|
||||
self.label_1 = QtGui.QLabel(Dialog)
|
||||
self.label_1.setObjectName("label_1")
|
||||
self.vboxlayout.addWidget(self.label_1)
|
||||
|
||||
self.inShapeA = QtGui.QComboBox(Dialog)
|
||||
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum,QtGui.QSizePolicy.Fixed)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.inShapeA.sizePolicy().hasHeightForWidth())
|
||||
self.inShapeA.setSizePolicy(sizePolicy)
|
||||
self.inShapeA.setObjectName("inShapeA")
|
||||
self.vboxlayout.addWidget(self.inShapeA)
|
||||
self.gridlayout.addLayout(self.vboxlayout,0,0,1,2)
|
||||
|
||||
self.gridLayout.addLayout(self.vboxlayout, 0, 0, 1, 2)
|
||||
self.vboxlayout1 = QtGui.QVBoxLayout()
|
||||
self.vboxlayout1.setObjectName("vboxlayout1")
|
||||
|
||||
self.label_2 = QtGui.QLabel(Dialog)
|
||||
self.label_2.setObjectName("label_2")
|
||||
self.vboxlayout1.addWidget(self.label_2)
|
||||
|
||||
self.inShapeB = QtGui.QComboBox(Dialog)
|
||||
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum,QtGui.QSizePolicy.Fixed)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.inShapeB.sizePolicy().hasHeightForWidth())
|
||||
self.inShapeB.setSizePolicy(sizePolicy)
|
||||
self.inShapeB.setObjectName("inShapeB")
|
||||
self.vboxlayout1.addWidget(self.inShapeB)
|
||||
self.gridlayout.addLayout(self.vboxlayout1,1,0,1,2)
|
||||
|
||||
self.gridLayout.addLayout(self.vboxlayout1, 3, 0, 1, 2)
|
||||
self.hboxlayout = QtGui.QHBoxLayout()
|
||||
self.hboxlayout.setObjectName("hboxlayout")
|
||||
|
||||
self.hboxlayout1 = QtGui.QHBoxLayout()
|
||||
self.hboxlayout1.setObjectName("hboxlayout1")
|
||||
|
||||
self.rdoBuffer = QtGui.QRadioButton(Dialog)
|
||||
self.rdoBuffer.setChecked(True)
|
||||
self.rdoBuffer.setObjectName("rdoBuffer")
|
||||
self.hboxlayout1.addWidget(self.rdoBuffer)
|
||||
self.hboxlayout.addLayout(self.hboxlayout1)
|
||||
|
||||
self.param = QtGui.QLineEdit(Dialog)
|
||||
self.param.setEnabled(True)
|
||||
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum,QtGui.QSizePolicy.Fixed)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.param.sizePolicy().hasHeightForWidth())
|
||||
@ -83,90 +68,85 @@ class Ui_Dialog(object):
|
||||
self.param.setCursorPosition(0)
|
||||
self.param.setObjectName("param")
|
||||
self.hboxlayout.addWidget(self.param)
|
||||
self.gridlayout.addLayout(self.hboxlayout,2,0,1,2)
|
||||
|
||||
self.gridLayout.addLayout(self.hboxlayout, 5, 0, 1, 2)
|
||||
self.vboxlayout2 = QtGui.QVBoxLayout()
|
||||
self.vboxlayout2.setObjectName("vboxlayout2")
|
||||
|
||||
self.hboxlayout2 = QtGui.QHBoxLayout()
|
||||
self.hboxlayout2.setObjectName("hboxlayout2")
|
||||
|
||||
self.rdoField = QtGui.QRadioButton(Dialog)
|
||||
self.rdoField.setObjectName("rdoField")
|
||||
self.hboxlayout2.addWidget(self.rdoField)
|
||||
|
||||
self.label_4 = QtGui.QLabel(Dialog)
|
||||
self.label_4.setObjectName("label_4")
|
||||
self.hboxlayout2.addWidget(self.label_4)
|
||||
|
||||
spacerItem = QtGui.QSpacerItem(40,20,QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Minimum)
|
||||
spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
self.hboxlayout2.addItem(spacerItem)
|
||||
self.vboxlayout2.addLayout(self.hboxlayout2)
|
||||
|
||||
self.attrib = QtGui.QComboBox(Dialog)
|
||||
self.attrib.setEnabled(False)
|
||||
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum,QtGui.QSizePolicy.Fixed)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.attrib.sizePolicy().hasHeightForWidth())
|
||||
self.attrib.setSizePolicy(sizePolicy)
|
||||
self.attrib.setObjectName("attrib")
|
||||
self.vboxlayout2.addWidget(self.attrib)
|
||||
self.gridlayout.addLayout(self.vboxlayout2,3,0,1,2)
|
||||
|
||||
self.gridLayout.addLayout(self.vboxlayout2, 6, 0, 1, 2)
|
||||
self.hboxlayout3 = QtGui.QHBoxLayout()
|
||||
self.hboxlayout3.setSpacing(6)
|
||||
self.hboxlayout3.setMargin(0)
|
||||
self.hboxlayout3.setObjectName("hboxlayout3")
|
||||
|
||||
self.mergeOutput = QtGui.QCheckBox(Dialog)
|
||||
self.mergeOutput.setEnabled(True)
|
||||
self.mergeOutput.setObjectName("mergeOutput")
|
||||
self.hboxlayout3.addWidget(self.mergeOutput)
|
||||
self.gridlayout.addLayout(self.hboxlayout3,4,0,1,1)
|
||||
|
||||
spacerItem1 = QtGui.QSpacerItem(20,40,QtGui.QSizePolicy.Minimum,QtGui.QSizePolicy.Expanding)
|
||||
self.gridlayout.addItem(spacerItem1,5,0,1,1)
|
||||
|
||||
self.gridLayout.addLayout(self.hboxlayout3, 7, 0, 1, 1)
|
||||
spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
|
||||
self.gridLayout.addItem(spacerItem1, 8, 0, 1, 1)
|
||||
self.vboxlayout3 = QtGui.QVBoxLayout()
|
||||
self.vboxlayout3.setObjectName("vboxlayout3")
|
||||
|
||||
self.label_5 = QtGui.QLabel(Dialog)
|
||||
self.label_5.setObjectName("label_5")
|
||||
self.vboxlayout3.addWidget(self.label_5)
|
||||
|
||||
self.hboxlayout4 = QtGui.QHBoxLayout()
|
||||
self.hboxlayout4.setObjectName("hboxlayout4")
|
||||
|
||||
self.outShape = QtGui.QLineEdit(Dialog)
|
||||
self.outShape.setReadOnly(True)
|
||||
self.outShape.setObjectName("outShape")
|
||||
self.hboxlayout4.addWidget(self.outShape)
|
||||
|
||||
self.btnBrowse = QtGui.QPushButton(Dialog)
|
||||
self.btnBrowse.setObjectName("btnBrowse")
|
||||
self.hboxlayout4.addWidget(self.btnBrowse)
|
||||
self.vboxlayout3.addLayout(self.hboxlayout4)
|
||||
self.gridlayout.addLayout(self.vboxlayout3,6,0,1,2)
|
||||
|
||||
self.gridLayout.addLayout(self.vboxlayout3, 9, 0, 1, 2)
|
||||
self.progressBar = QtGui.QProgressBar(Dialog)
|
||||
self.progressBar.setProperty("value",QtCore.QVariant(0))
|
||||
self.progressBar.setProperty("value", QtCore.QVariant(0))
|
||||
self.progressBar.setAlignment(QtCore.Qt.AlignCenter)
|
||||
self.progressBar.setOrientation(QtCore.Qt.Horizontal)
|
||||
self.progressBar.setObjectName("progressBar")
|
||||
self.gridlayout.addWidget(self.progressBar,7,0,1,1)
|
||||
|
||||
self.gridLayout.addWidget(self.progressBar, 10, 0, 1, 1)
|
||||
self.buttonBox_2 = QtGui.QDialogButtonBox(Dialog)
|
||||
self.buttonBox_2.setStandardButtons(QtGui.QDialogButtonBox.Close|QtGui.QDialogButtonBox.Ok)
|
||||
self.buttonBox_2.setObjectName("buttonBox_2")
|
||||
self.gridlayout.addWidget(self.buttonBox_2,7,1,1,1)
|
||||
self.gridLayout.addWidget(self.buttonBox_2, 10, 1, 1, 1)
|
||||
self.verticalLayout = QtGui.QVBoxLayout()
|
||||
self.verticalLayout.setObjectName("verticalLayout")
|
||||
self.useSelectedA = QtGui.QCheckBox(Dialog)
|
||||
self.useSelectedA.setObjectName("useSelectedA")
|
||||
self.verticalLayout.addWidget(self.useSelectedA)
|
||||
self.gridLayout.addLayout(self.verticalLayout, 2, 0, 1, 1)
|
||||
self.verticalLayout_2 = QtGui.QVBoxLayout()
|
||||
self.verticalLayout_2.setObjectName("verticalLayout_2")
|
||||
self.useSelectedB = QtGui.QCheckBox(Dialog)
|
||||
self.useSelectedB.setObjectName("useSelectedB")
|
||||
self.verticalLayout_2.addWidget(self.useSelectedB)
|
||||
self.gridLayout.addLayout(self.verticalLayout_2, 4, 0, 1, 1)
|
||||
|
||||
self.retranslateUi(Dialog)
|
||||
QtCore.QObject.connect(self.rdoField,QtCore.SIGNAL("toggled(bool)"),self.attrib.setEnabled)
|
||||
QtCore.QObject.connect(self.rdoBuffer,QtCore.SIGNAL("toggled(bool)"),self.param.setEnabled)
|
||||
QtCore.QObject.connect(self.buttonBox_2,QtCore.SIGNAL("rejected()"),Dialog.reject)
|
||||
QtCore.QObject.connect(self.buttonBox_2,QtCore.SIGNAL("accepted()"),Dialog.accept)
|
||||
QtCore.QObject.connect(self.rdoField, QtCore.SIGNAL("toggled(bool)"), self.attrib.setEnabled)
|
||||
QtCore.QObject.connect(self.rdoBuffer, QtCore.SIGNAL("toggled(bool)"), self.param.setEnabled)
|
||||
QtCore.QObject.connect(self.buttonBox_2, QtCore.SIGNAL("rejected()"), Dialog.reject)
|
||||
QtCore.QObject.connect(self.buttonBox_2, QtCore.SIGNAL("accepted()"), Dialog.accept)
|
||||
QtCore.QMetaObject.connectSlotsByName(Dialog)
|
||||
|
||||
def retranslateUi(self, Dialog):
|
||||
@ -179,4 +159,6 @@ class Ui_Dialog(object):
|
||||
self.mergeOutput.setText(QtGui.QApplication.translate("Dialog", "Dissolve buffer results", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.label_5.setText(QtGui.QApplication.translate("Dialog", "Output shapefile", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.btnBrowse.setText(QtGui.QApplication.translate("Dialog", "Browse", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.useSelectedA.setText(QtGui.QApplication.translate("Dialog", "Use only selected features", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.useSelectedB.setText(QtGui.QApplication.translate("Dialog", "Use only selected features", None, QtGui.QApplication.UnicodeUTF8))
|
||||
|
||||
|
@ -40,7 +40,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2" >
|
||||
<item row="3" column="0" colspan="2" >
|
||||
<layout class="QVBoxLayout" >
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2" >
|
||||
@ -61,7 +61,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2" >
|
||||
<item row="5" column="0" colspan="2" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
@ -101,7 +101,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2" >
|
||||
<item row="6" column="0" colspan="2" >
|
||||
<layout class="QVBoxLayout" >
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
@ -149,7 +149,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0" >
|
||||
<item row="7" column="0" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
@ -169,7 +169,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="5" column="0" >
|
||||
<item row="8" column="0" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -182,7 +182,7 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="2" >
|
||||
<item row="9" column="0" colspan="2" >
|
||||
<layout class="QVBoxLayout" >
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5" >
|
||||
@ -211,7 +211,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="7" column="0" >
|
||||
<item row="10" column="0" >
|
||||
<widget class="QProgressBar" name="progressBar" >
|
||||
<property name="value" >
|
||||
<number>0</number>
|
||||
@ -224,13 +224,35 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1" >
|
||||
<item row="10" column="1" >
|
||||
<widget class="QDialogButtonBox" name="buttonBox_2" >
|
||||
<property name="standardButtons" >
|
||||
<set>QDialogButtonBox::Close|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<layout class="QVBoxLayout" name="verticalLayout" >
|
||||
<item>
|
||||
<widget class="QCheckBox" name="useSelectedA" >
|
||||
<property name="text" >
|
||||
<string>Use only selected features</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0" >
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2" >
|
||||
<item>
|
||||
<widget class="QCheckBox" name="useSelectedB" >
|
||||
<property name="text" >
|
||||
<string>Use only selected features</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
# Form implementation generated from reading ui file 'frmVisual.ui'
|
||||
#
|
||||
# Created: Tue Apr 21 15:10:47 2009
|
||||
# by: PyQt4 UI code generator 4.4.3
|
||||
# Created: Tue May 26 18:55:54 2009
|
||||
# by: PyQt4 UI code generator 4.4.4
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
||||
@ -13,7 +13,7 @@ class Ui_Dialog(object):
|
||||
def setupUi(self, Dialog):
|
||||
Dialog.setObjectName("Dialog")
|
||||
Dialog.setWindowModality(QtCore.Qt.NonModal)
|
||||
Dialog.resize(374, 485)
|
||||
Dialog.resize(404, 485)
|
||||
Dialog.setSizeGripEnabled(True)
|
||||
self.gridLayout = QtGui.QGridLayout(Dialog)
|
||||
self.gridLayout.setObjectName("gridLayout")
|
||||
@ -34,7 +34,7 @@ class Ui_Dialog(object):
|
||||
self.cmbField = QtGui.QComboBox(Dialog)
|
||||
self.cmbField.setObjectName("cmbField")
|
||||
self.vboxlayout1.addWidget(self.cmbField)
|
||||
self.gridLayout.addLayout(self.vboxlayout1, 1, 0, 1, 2)
|
||||
self.gridLayout.addLayout(self.vboxlayout1, 4, 0, 1, 2)
|
||||
self.vboxlayout2 = QtGui.QVBoxLayout()
|
||||
self.vboxlayout2.setObjectName("vboxlayout2")
|
||||
self.label_2 = QtGui.QLabel(Dialog)
|
||||
@ -49,7 +49,7 @@ class Ui_Dialog(object):
|
||||
self.lstUnique.setSelectionRectVisible(True)
|
||||
self.lstUnique.setObjectName("lstUnique")
|
||||
self.vboxlayout2.addWidget(self.lstUnique)
|
||||
self.gridLayout.addLayout(self.vboxlayout2, 2, 0, 1, 2)
|
||||
self.gridLayout.addLayout(self.vboxlayout2, 5, 0, 1, 2)
|
||||
self.hboxlayout = QtGui.QHBoxLayout()
|
||||
self.hboxlayout.setObjectName("hboxlayout")
|
||||
self.label_4 = QtGui.QLabel(Dialog)
|
||||
@ -59,17 +59,23 @@ class Ui_Dialog(object):
|
||||
self.lstCount.setReadOnly(True)
|
||||
self.lstCount.setObjectName("lstCount")
|
||||
self.hboxlayout.addWidget(self.lstCount)
|
||||
self.gridLayout.addLayout(self.hboxlayout, 3, 0, 1, 2)
|
||||
self.gridLayout.addLayout(self.hboxlayout, 6, 0, 1, 2)
|
||||
self.progressBar = QtGui.QProgressBar(Dialog)
|
||||
self.progressBar.setProperty("value", QtCore.QVariant(24))
|
||||
self.progressBar.setAlignment(QtCore.Qt.AlignCenter)
|
||||
self.progressBar.setObjectName("progressBar")
|
||||
self.gridLayout.addWidget(self.progressBar, 4, 0, 1, 1)
|
||||
self.gridLayout.addWidget(self.progressBar, 7, 0, 1, 1)
|
||||
self.buttonBox_2 = QtGui.QDialogButtonBox(Dialog)
|
||||
self.buttonBox_2.setOrientation(QtCore.Qt.Horizontal)
|
||||
self.buttonBox_2.setStandardButtons(QtGui.QDialogButtonBox.Close|QtGui.QDialogButtonBox.Ok)
|
||||
self.buttonBox_2.setObjectName("buttonBox_2")
|
||||
self.gridLayout.addWidget(self.buttonBox_2, 4, 1, 1, 1)
|
||||
self.gridLayout.addWidget(self.buttonBox_2, 7, 1, 1, 1)
|
||||
self.verticalLayout = QtGui.QVBoxLayout()
|
||||
self.verticalLayout.setObjectName("verticalLayout")
|
||||
self.useSelected = QtGui.QCheckBox(Dialog)
|
||||
self.useSelected.setObjectName("useSelected")
|
||||
self.verticalLayout.addWidget(self.useSelected)
|
||||
self.gridLayout.addLayout(self.verticalLayout, 3, 0, 1, 1)
|
||||
|
||||
self.retranslateUi(Dialog)
|
||||
QtCore.QObject.connect(self.buttonBox_2, QtCore.SIGNAL("accepted()"), Dialog.accept)
|
||||
@ -83,4 +89,5 @@ class Ui_Dialog(object):
|
||||
self.label_2.setText(QtGui.QApplication.translate("Dialog", "Unique values list", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.lstUnique.setSortingEnabled(True)
|
||||
self.label_4.setText(QtGui.QApplication.translate("Dialog", "Unique value count", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.useSelected.setText(QtGui.QApplication.translate("Dialog", "Use only selected features", None, QtGui.QApplication.UnicodeUTF8))
|
||||
|
||||
|
@ -1,126 +1,138 @@
|
||||
<ui version="4.0" >
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Dialog</class>
|
||||
<widget class="QDialog" name="Dialog" >
|
||||
<property name="windowModality" >
|
||||
<widget class="QDialog" name="Dialog">
|
||||
<property name="windowModality">
|
||||
<enum>Qt::NonModal</enum>
|
||||
</property>
|
||||
<property name="geometry" >
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>374</width>
|
||||
<width>404</width>
|
||||
<height>485</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<property name="windowTitle">
|
||||
<string>List Unique Values</string>
|
||||
</property>
|
||||
<property name="sizeGripEnabled" >
|
||||
<property name="sizeGripEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout" >
|
||||
<item row="0" column="0" colspan="2" >
|
||||
<layout class="QVBoxLayout" >
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<layout class="QVBoxLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3" >
|
||||
<property name="text" >
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Input Vector Layer</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="inShape" />
|
||||
<widget class="QComboBox" name="inShape"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2" >
|
||||
<layout class="QVBoxLayout" >
|
||||
<item row="4" column="0" colspan="2">
|
||||
<layout class="QVBoxLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="text" >
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Target field</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cmbField" />
|
||||
<widget class="QComboBox" name="cmbField"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2" >
|
||||
<layout class="QVBoxLayout" >
|
||||
<item row="5" column="0" colspan="2">
|
||||
<layout class="QVBoxLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2" >
|
||||
<property name="text" >
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Unique values list</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="lstUnique" >
|
||||
<property name="editTriggers" >
|
||||
<widget class="QListWidget" name="lstUnique">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="showDropIndicator" stdset="0" >
|
||||
<property name="showDropIndicator" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="alternatingRowColors" >
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionMode" >
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior" >
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="selectionRectVisible" >
|
||||
<property name="selectionRectVisible">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sortingEnabled" >
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<item row="6" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4" >
|
||||
<property name="text" >
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Unique value count</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lstCount" >
|
||||
<property name="readOnly" >
|
||||
<widget class="QLineEdit" name="lstCount">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0" >
|
||||
<widget class="QProgressBar" name="progressBar" >
|
||||
<property name="value" >
|
||||
<item row="7" column="0">
|
||||
<widget class="QProgressBar" name="progressBar">
|
||||
<property name="value">
|
||||
<number>24</number>
|
||||
</property>
|
||||
<property name="alignment" >
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" >
|
||||
<widget class="QDialogButtonBox" name="buttonBox_2" >
|
||||
<property name="orientation" >
|
||||
<item row="7" column="1">
|
||||
<widget class="QDialogButtonBox" name="buttonBox_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons" >
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="useSelected">
|
||||
<property name="text">
|
||||
<string>Use only selected features</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
@ -131,11 +143,11 @@
|
||||
<receiver>Dialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<hint type="sourcelabel">
|
||||
<x>133</x>
|
||||
<y>276</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<hint type="destinationlabel">
|
||||
<x>215</x>
|
||||
<y>290</y>
|
||||
</hint>
|
||||
@ -147,11 +159,11 @@
|
||||
<receiver>Dialog</receiver>
|
||||
<slot>close()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<hint type="sourcelabel">
|
||||
<x>59</x>
|
||||
<y>276</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<hint type="destinationlabel">
|
||||
<x>132</x>
|
||||
<y>239</y>
|
||||
</hint>
|
||||
|
@ -19,6 +19,7 @@
|
||||
# addShapeToCanvas( QString *file path )
|
||||
# getUniqueValues( QgsVectorDataProvider, int *field id )
|
||||
# saveDialog( QWidget *parent )
|
||||
# getFieldType( QgsVectorLayer, QgsField.name() )
|
||||
#
|
||||
# -------------------------------------------------
|
||||
|
||||
@ -260,3 +261,9 @@ def saveDialog( parent ):
|
||||
settings.setValue("/UI/lastShapefileDir", QVariant( QFileInfo( unicode( files.first() ) ).absolutePath() ) )
|
||||
return ( unicode( files.first() ), unicode( fileDialog.encoding() ) )
|
||||
|
||||
# Return field type from it's name
|
||||
def getFieldType(vlayer, fieldName):
|
||||
fields = vlayer.dataProvider().fields()
|
||||
for name, field in fields.iteritems():
|
||||
if field.name() == fieldName:
|
||||
return field.typeName()
|
||||
|
Loading…
x
Reference in New Issue
Block a user