Skip to content

Commit f13f45e

Browse files
author
cfarmer
committedMay 26, 2009
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
1 parent d37aae2 commit f13f45e

File tree

7 files changed

+1091
-451
lines changed

7 files changed

+1091
-451
lines changed
 

‎python/plugins/fTools/tools/doGeoprocessing.py‎

Lines changed: 805 additions & 289 deletions
Large diffs are not rendered by default.

‎python/plugins/fTools/tools/doVisual.py‎

Lines changed: 134 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -38,31 +38,42 @@ def update( self ):
3838
if inputLayer != "":
3939
changedLayer = ftools_utils.getVectorLayerByName( inputLayer )
4040
changedField = changedLayer.dataProvider().fields()
41+
# for Basic statistics (with or without selection)
42+
if self.myFunction == 3:
43+
if changedLayer.selectedFeatureCount() != 0:
44+
self.useSelected.setCheckState( Qt.Checked )
45+
else:
46+
self.useSelected.setCheckState( Qt.Unchecked )
47+
# add all fields in combobox because now we can work with text fields too
4148
for i in changedField:
4249
if self.myFunction == 3:
4350
if changedField[i].type() == QVariant.Int or changedField[i].type() == QVariant.Double:
4451
self.cmbField.addItem( unicode( changedField[i].name() ) )
4552
else:
4653
self.cmbField.addItem( unicode( changedField[i].name() ) )
54+
self.cmbField.addItem( unicode( changedField[i].name() ) )
55+
4756
def accept( self ):
4857
if self.inShape.currentText() == "":
4958
QMessageBox.information( self, "Error!", self.tr( "Please specify input vector layer" ) )
5059
elif self.cmbField.isVisible() and self.cmbField.currentText() == "":
5160
QMessageBox.information( self, "Error!", self.tr( "Please specify input field" ) )
5261
else:
53-
self.visual( self.inShape.currentText(), self.cmbField.currentText() )
62+
self.visual( self.inShape.currentText(), self.cmbField.currentText(), self.useSelected.checkState() )
5463

5564
def manageGui( self ):
5665
if self.myFunction == 1: # Check geometry validity
5766
self.setWindowTitle( self.tr( "Check geometry validity" ) )
5867
self.cmbField.setVisible( False )
5968
self.label.setVisible( False )
69+
self.useSelected.setVisible( False )
6070
self.label_2.setText( self.tr( "Geometry errors" ) )
6171
self.label_4.setText( self.tr( "Total encountered errors" ) )
6272
elif self.myFunction == 2: # List unique values
6373
self.setWindowTitle( self.tr( "List unique values" ) )
6474
self.label_2.setText( self.tr( "Unique values" ) )
6575
self.label_4.setText(self.tr( "Total unique values" ) )
76+
self.useSelected.setVisible( False )
6677
elif self.myFunction == 3: # Basic statistics
6778
self.setWindowTitle( self.tr( "Basics statistics" ) )
6879
self.label_2.setText( self.tr( "Statistics output" ) )
@@ -73,6 +84,7 @@ def manageGui( self ):
7384
self.setWindowTitle( self.tr( "Nearest neighbour analysis" ) )
7485
self.cmbField.setVisible( False )
7586
self.label.setVisible( False )
87+
self.useSelected.setVisible( False )
7688
self.label_2.setText( self.tr( "Nearest neighbour statistics" ) )
7789
self.label_4.setVisible( False )
7890
self.lstCount.setVisible( False )
@@ -91,11 +103,11 @@ def manageGui( self ):
91103
#2: List unique values
92104
#3: Basic statistics
93105
#4: Nearest neighbour analysis
94-
def visual( self, myLayer, myField ):
106+
def visual( self, myLayer, myField, mySelection ):
95107
vlayer = ftools_utils.getVectorLayerByName( myLayer )
96108
self.lstUnique.clear()
97109
self.lstCount.clear()
98-
self.testThread = visualThread( self.iface.mainWindow(), self, self.myFunction, vlayer, myField )
110+
self.testThread = visualThread( self.iface.mainWindow(), self, self.myFunction, vlayer, myField, mySelection )
99111
QObject.connect( self.testThread, SIGNAL( "runFinished(PyQt_PyObject)" ), self.runFinishedFromThread )
100112
QObject.connect( self.testThread, SIGNAL( "runStatus(PyQt_PyObject)" ), self.runStatusFromThread )
101113
QObject.connect( self.testThread, SIGNAL( "runRange(PyQt_PyObject)" ), self.runRangeFromThread )
@@ -122,13 +134,14 @@ def runRangeFromThread( self, range_vals ):
122134
self.progressBar.setRange( range_vals[ 0 ], range_vals[ 1 ] )
123135

124136
class visualThread( QThread ):
125-
def __init__( self, parentThread, parentObject, function, vlayer, myField ):
137+
def __init__( self, parentThread, parentObject, function, vlayer, myField, mySelection ):
126138
QThread.__init__( self, parentThread )
127139
self.parent = parentObject
128140
self.running = False
129141
self.myFunction = function
130142
self.vlayer = vlayer
131143
self.myField = myField
144+
self.mySelection = mySelection
132145
# self.total = 0
133146
# self.currentCount = 0
134147

@@ -176,46 +189,127 @@ def basic_statistics( self, vlayer, myField ):
176189
feat = QgsFeature()
177190
sumVal = 0.0
178191
meanVal = 0.0
179-
stdVal = 0.0
180-
cvVal = 0.0
181192
nVal = 0.0
182193
values = []
183194
first = True
184-
nFeat = vprovider.featureCount()
185195
nElement = 0
186-
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
187-
self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
188-
while vprovider.nextFeature( feat ):
189-
atMap = feat.attributeMap()
190-
value = float( atMap[ index ].toDouble()[ 0 ] )
191-
if first:
192-
minVal = value
193-
maxVal = value
194-
first = False
195-
else:
196-
if value < minVal: minVal = value
197-
if value > maxVal: maxVal = value
198-
values.append( value )
199-
sumVal = float( sumVal + value )
200-
nElement += 1
201-
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
202-
nVal= float( len( values ) )
203-
if nVal > 0.00:
204-
meanVal = float( sumVal ) / nVal
205-
if not meanVal == 0.00:
206-
for val in values:
207-
stdVal += float( ( val - meanVal ) * ( val - meanVal ) )
208-
stdVal = float( math.sqrt( stdVal / nVal ) )
209-
cvVal = float( stdVal / meanVal )
210-
lstStats = []
211-
lstStats.append( "Mean : " + unicode( meanVal ) )
212-
lstStats.append( "StdDev : " + unicode( stdVal ) )
213-
lstStats.append( "Sum : " + unicode( sumVal) )
214-
lstStats.append( "Min : " + unicode( minVal ) )
215-
lstStats.append( "Max : " + unicode( maxVal ) )
216-
lstStats.append( "N : " + unicode( nVal ) )
217-
lstStats.append( "CV : " + unicode( cvVal ) )
218-
return ( lstStats, [] )
196+
# determine selected field type
197+
if ftools_utils.getFieldType( vlayer, myField ) == 'String':
198+
fillVal = 0
199+
emptyVal = 0
200+
if self.mySelection: # only selected features
201+
selection = vlayer.selectedFeatures()
202+
nFeat = vlayer.selectedFeatureCount()
203+
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
204+
self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
205+
for f in selection:
206+
atMap = f.attributeMap()
207+
lenVal = float( len( atMap[ index ].toString() ) )
208+
if first:
209+
minVal = lenVal
210+
maxVal = lenVal
211+
first = False
212+
else:
213+
if lenVal < minVal: minVal = lenVal
214+
if lenVal > maxVal: maxVal = lenVal
215+
if lenVal != 0.00:
216+
fillVal += 1
217+
else:
218+
emptyVal += 1
219+
values.append( lenVal )
220+
sumVal = sumVal + lenVal
221+
nElement += 1
222+
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
223+
else: # there is no selection, process the whole layer
224+
nFeat = vprovider.featureCount()
225+
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
226+
self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
227+
while vprovider.nextFeature( feat ):
228+
atMap = feat.attributeMap()
229+
lenVal = float( len( atMap[ index ].toString() ) )
230+
if first:
231+
minVal = lenVal
232+
maxVal = lenVal
233+
first = False
234+
else:
235+
if lenVal < minVal: minVal = lenVal
236+
if lenVal > maxVal: maxVal = lenVal
237+
if lenVal != 0.00:
238+
fillVal += 1
239+
else:
240+
emptyVal += 1
241+
values.append( lenVal )
242+
sumVal = sumVal + lenVal
243+
nElement += 1
244+
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
245+
nVal= float( len( values ) )
246+
if nVal > 0.00:
247+
meanVal = sumVal / nVal
248+
lstStats = []
249+
lstStats.append( QCoreApplication.translate( "statResult", "Max. len. : " ) + unicode( maxVal ) )
250+
lstStats.append( QCoreApplication.translate( "statResult", "Min. len. : " ) + unicode( minVal ) )
251+
lstStats.append( QCoreApplication.translate( "statResult", "Mean. len : " ) + unicode( meanVal ) )
252+
lstStats.append( QCoreApplication.translate( "statResult", "Filled : " ) + unicode( fillVal ) )
253+
lstStats.append( QCoreApplication.translate( "statResult", "Empty : " ) + unicode( emptyVal ) )
254+
lstStats.append( QCoreApplication.translate( "statResult", "N : " ) + unicode( nVal ) )
255+
return ( lstStats, [] )
256+
else: # numeric field
257+
stdVal = 0
258+
cvVal = 0
259+
if self.mySelection: # only selected features
260+
selection = vlayer.selectedFeatures()
261+
nFeat = vlayer.selectedFeatureCount()
262+
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
263+
self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
264+
for f in selection:
265+
atMap = f.attributeMap()
266+
value = float( atMap[ index ].toDouble()[ 0 ] )
267+
if first:
268+
minVal = value
269+
maxVal = value
270+
first = False
271+
else:
272+
if value < minVal: minVal = value
273+
if value > maxVal: maxVal = value
274+
values.append( value )
275+
sumVal = sumVal + value
276+
nElement += 1
277+
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
278+
else: # there is no selection, process the whole layer
279+
nFeat = vprovider.featureCount()
280+
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
281+
self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
282+
while vprovider.nextFeature( feat ):
283+
atMap = feat.attributeMap()
284+
value = float( atMap[ index ].toDouble()[ 0 ] )
285+
if first:
286+
minVal = value
287+
maxVal = value
288+
first = False
289+
else:
290+
if value < minVal: minVal = value
291+
if value > maxVal: maxVal = value
292+
values.append( value )
293+
sumVal = sumVal + value
294+
nElement += 1
295+
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
296+
nVal= float( len( values ) )
297+
if nVal > 0.00:
298+
meanVal = sumVal / nVal
299+
if meanVal != 0.00:
300+
for val in values:
301+
stdVal += ( ( val - meanVal ) * ( val - meanVal ) )
302+
stdVal = math.sqrt( stdVal / nVal )
303+
cvVal = stdVal / meanVal
304+
lstStats = []
305+
lstStats.append( "Mean : " + unicode( meanVal ) )
306+
lstStats.append( "StdDev : " + unicode( stdVal ) )
307+
lstStats.append( "Sum : " + unicode( sumVal) )
308+
lstStats.append( "Min : " + unicode( minVal ) )
309+
lstStats.append( "Max : " + unicode( maxVal ) )
310+
lstStats.append( "N : " + unicode( nVal ) )
311+
lstStats.append( "CV : " + unicode( cvVal ) )
312+
return ( lstStats, [] )
219313

220314
def nearest_neighbour_analysis( self, vlayer ):
221315
vprovider = vlayer.dataProvider()

‎python/plugins/fTools/tools/frmGeoprocessing.py‎

Lines changed: 40 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
# Form implementation generated from reading ui file 'frmGeoprocessing.ui'
44
#
5-
# Created: Thu Nov 13 23:17:35 2008
6-
# by: PyQt4 UI code generator 4.3.3
5+
# Created: Tue May 26 19:00:00 2009
6+
# by: PyQt4 UI code generator 4.4.4
77
#
88
# WARNING! All changes made in this file will be lost!
99

@@ -12,69 +12,54 @@
1212
class Ui_Dialog(object):
1313
def setupUi(self, Dialog):
1414
Dialog.setObjectName("Dialog")
15-
Dialog.resize(QtCore.QSize(QtCore.QRect(0,0,422,405).size()).expandedTo(Dialog.minimumSizeHint()))
16-
17-
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum,QtGui.QSizePolicy.Preferred)
15+
Dialog.resize(422, 405)
16+
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Preferred)
1817
sizePolicy.setHorizontalStretch(0)
1918
sizePolicy.setVerticalStretch(0)
2019
sizePolicy.setHeightForWidth(Dialog.sizePolicy().hasHeightForWidth())
2120
Dialog.setSizePolicy(sizePolicy)
22-
23-
self.gridlayout = QtGui.QGridLayout(Dialog)
24-
self.gridlayout.setObjectName("gridlayout")
25-
21+
self.gridLayout = QtGui.QGridLayout(Dialog)
22+
self.gridLayout.setObjectName("gridLayout")
2623
self.vboxlayout = QtGui.QVBoxLayout()
2724
self.vboxlayout.setObjectName("vboxlayout")
28-
2925
self.label_1 = QtGui.QLabel(Dialog)
3026
self.label_1.setObjectName("label_1")
3127
self.vboxlayout.addWidget(self.label_1)
32-
3328
self.inShapeA = QtGui.QComboBox(Dialog)
34-
35-
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum,QtGui.QSizePolicy.Fixed)
29+
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
3630
sizePolicy.setHorizontalStretch(0)
3731
sizePolicy.setVerticalStretch(0)
3832
sizePolicy.setHeightForWidth(self.inShapeA.sizePolicy().hasHeightForWidth())
3933
self.inShapeA.setSizePolicy(sizePolicy)
4034
self.inShapeA.setObjectName("inShapeA")
4135
self.vboxlayout.addWidget(self.inShapeA)
42-
self.gridlayout.addLayout(self.vboxlayout,0,0,1,2)
43-
36+
self.gridLayout.addLayout(self.vboxlayout, 0, 0, 1, 2)
4437
self.vboxlayout1 = QtGui.QVBoxLayout()
4538
self.vboxlayout1.setObjectName("vboxlayout1")
46-
4739
self.label_2 = QtGui.QLabel(Dialog)
4840
self.label_2.setObjectName("label_2")
4941
self.vboxlayout1.addWidget(self.label_2)
50-
5142
self.inShapeB = QtGui.QComboBox(Dialog)
52-
53-
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum,QtGui.QSizePolicy.Fixed)
43+
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
5444
sizePolicy.setHorizontalStretch(0)
5545
sizePolicy.setVerticalStretch(0)
5646
sizePolicy.setHeightForWidth(self.inShapeB.sizePolicy().hasHeightForWidth())
5747
self.inShapeB.setSizePolicy(sizePolicy)
5848
self.inShapeB.setObjectName("inShapeB")
5949
self.vboxlayout1.addWidget(self.inShapeB)
60-
self.gridlayout.addLayout(self.vboxlayout1,1,0,1,2)
61-
50+
self.gridLayout.addLayout(self.vboxlayout1, 3, 0, 1, 2)
6251
self.hboxlayout = QtGui.QHBoxLayout()
6352
self.hboxlayout.setObjectName("hboxlayout")
64-
6553
self.hboxlayout1 = QtGui.QHBoxLayout()
6654
self.hboxlayout1.setObjectName("hboxlayout1")
67-
6855
self.rdoBuffer = QtGui.QRadioButton(Dialog)
6956
self.rdoBuffer.setChecked(True)
7057
self.rdoBuffer.setObjectName("rdoBuffer")
7158
self.hboxlayout1.addWidget(self.rdoBuffer)
7259
self.hboxlayout.addLayout(self.hboxlayout1)
73-
7460
self.param = QtGui.QLineEdit(Dialog)
7561
self.param.setEnabled(True)
76-
77-
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum,QtGui.QSizePolicy.Fixed)
62+
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
7863
sizePolicy.setHorizontalStretch(0)
7964
sizePolicy.setVerticalStretch(0)
8065
sizePolicy.setHeightForWidth(self.param.sizePolicy().hasHeightForWidth())
@@ -83,90 +68,85 @@ def setupUi(self, Dialog):
8368
self.param.setCursorPosition(0)
8469
self.param.setObjectName("param")
8570
self.hboxlayout.addWidget(self.param)
86-
self.gridlayout.addLayout(self.hboxlayout,2,0,1,2)
87-
71+
self.gridLayout.addLayout(self.hboxlayout, 5, 0, 1, 2)
8872
self.vboxlayout2 = QtGui.QVBoxLayout()
8973
self.vboxlayout2.setObjectName("vboxlayout2")
90-
9174
self.hboxlayout2 = QtGui.QHBoxLayout()
9275
self.hboxlayout2.setObjectName("hboxlayout2")
93-
9476
self.rdoField = QtGui.QRadioButton(Dialog)
9577
self.rdoField.setObjectName("rdoField")
9678
self.hboxlayout2.addWidget(self.rdoField)
97-
9879
self.label_4 = QtGui.QLabel(Dialog)
9980
self.label_4.setObjectName("label_4")
10081
self.hboxlayout2.addWidget(self.label_4)
101-
102-
spacerItem = QtGui.QSpacerItem(40,20,QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Minimum)
82+
spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
10383
self.hboxlayout2.addItem(spacerItem)
10484
self.vboxlayout2.addLayout(self.hboxlayout2)
105-
10685
self.attrib = QtGui.QComboBox(Dialog)
10786
self.attrib.setEnabled(False)
108-
109-
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum,QtGui.QSizePolicy.Fixed)
87+
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
11088
sizePolicy.setHorizontalStretch(0)
11189
sizePolicy.setVerticalStretch(0)
11290
sizePolicy.setHeightForWidth(self.attrib.sizePolicy().hasHeightForWidth())
11391
self.attrib.setSizePolicy(sizePolicy)
11492
self.attrib.setObjectName("attrib")
11593
self.vboxlayout2.addWidget(self.attrib)
116-
self.gridlayout.addLayout(self.vboxlayout2,3,0,1,2)
117-
94+
self.gridLayout.addLayout(self.vboxlayout2, 6, 0, 1, 2)
11895
self.hboxlayout3 = QtGui.QHBoxLayout()
11996
self.hboxlayout3.setSpacing(6)
12097
self.hboxlayout3.setMargin(0)
12198
self.hboxlayout3.setObjectName("hboxlayout3")
122-
12399
self.mergeOutput = QtGui.QCheckBox(Dialog)
124100
self.mergeOutput.setEnabled(True)
125101
self.mergeOutput.setObjectName("mergeOutput")
126102
self.hboxlayout3.addWidget(self.mergeOutput)
127-
self.gridlayout.addLayout(self.hboxlayout3,4,0,1,1)
128-
129-
spacerItem1 = QtGui.QSpacerItem(20,40,QtGui.QSizePolicy.Minimum,QtGui.QSizePolicy.Expanding)
130-
self.gridlayout.addItem(spacerItem1,5,0,1,1)
131-
103+
self.gridLayout.addLayout(self.hboxlayout3, 7, 0, 1, 1)
104+
spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
105+
self.gridLayout.addItem(spacerItem1, 8, 0, 1, 1)
132106
self.vboxlayout3 = QtGui.QVBoxLayout()
133107
self.vboxlayout3.setObjectName("vboxlayout3")
134-
135108
self.label_5 = QtGui.QLabel(Dialog)
136109
self.label_5.setObjectName("label_5")
137110
self.vboxlayout3.addWidget(self.label_5)
138-
139111
self.hboxlayout4 = QtGui.QHBoxLayout()
140112
self.hboxlayout4.setObjectName("hboxlayout4")
141-
142113
self.outShape = QtGui.QLineEdit(Dialog)
143114
self.outShape.setReadOnly(True)
144115
self.outShape.setObjectName("outShape")
145116
self.hboxlayout4.addWidget(self.outShape)
146-
147117
self.btnBrowse = QtGui.QPushButton(Dialog)
148118
self.btnBrowse.setObjectName("btnBrowse")
149119
self.hboxlayout4.addWidget(self.btnBrowse)
150120
self.vboxlayout3.addLayout(self.hboxlayout4)
151-
self.gridlayout.addLayout(self.vboxlayout3,6,0,1,2)
152-
121+
self.gridLayout.addLayout(self.vboxlayout3, 9, 0, 1, 2)
153122
self.progressBar = QtGui.QProgressBar(Dialog)
154-
self.progressBar.setProperty("value",QtCore.QVariant(0))
123+
self.progressBar.setProperty("value", QtCore.QVariant(0))
155124
self.progressBar.setAlignment(QtCore.Qt.AlignCenter)
156125
self.progressBar.setOrientation(QtCore.Qt.Horizontal)
157126
self.progressBar.setObjectName("progressBar")
158-
self.gridlayout.addWidget(self.progressBar,7,0,1,1)
159-
127+
self.gridLayout.addWidget(self.progressBar, 10, 0, 1, 1)
160128
self.buttonBox_2 = QtGui.QDialogButtonBox(Dialog)
161129
self.buttonBox_2.setStandardButtons(QtGui.QDialogButtonBox.Close|QtGui.QDialogButtonBox.Ok)
162130
self.buttonBox_2.setObjectName("buttonBox_2")
163-
self.gridlayout.addWidget(self.buttonBox_2,7,1,1,1)
131+
self.gridLayout.addWidget(self.buttonBox_2, 10, 1, 1, 1)
132+
self.verticalLayout = QtGui.QVBoxLayout()
133+
self.verticalLayout.setObjectName("verticalLayout")
134+
self.useSelectedA = QtGui.QCheckBox(Dialog)
135+
self.useSelectedA.setObjectName("useSelectedA")
136+
self.verticalLayout.addWidget(self.useSelectedA)
137+
self.gridLayout.addLayout(self.verticalLayout, 2, 0, 1, 1)
138+
self.verticalLayout_2 = QtGui.QVBoxLayout()
139+
self.verticalLayout_2.setObjectName("verticalLayout_2")
140+
self.useSelectedB = QtGui.QCheckBox(Dialog)
141+
self.useSelectedB.setObjectName("useSelectedB")
142+
self.verticalLayout_2.addWidget(self.useSelectedB)
143+
self.gridLayout.addLayout(self.verticalLayout_2, 4, 0, 1, 1)
164144

165145
self.retranslateUi(Dialog)
166-
QtCore.QObject.connect(self.rdoField,QtCore.SIGNAL("toggled(bool)"),self.attrib.setEnabled)
167-
QtCore.QObject.connect(self.rdoBuffer,QtCore.SIGNAL("toggled(bool)"),self.param.setEnabled)
168-
QtCore.QObject.connect(self.buttonBox_2,QtCore.SIGNAL("rejected()"),Dialog.reject)
169-
QtCore.QObject.connect(self.buttonBox_2,QtCore.SIGNAL("accepted()"),Dialog.accept)
146+
QtCore.QObject.connect(self.rdoField, QtCore.SIGNAL("toggled(bool)"), self.attrib.setEnabled)
147+
QtCore.QObject.connect(self.rdoBuffer, QtCore.SIGNAL("toggled(bool)"), self.param.setEnabled)
148+
QtCore.QObject.connect(self.buttonBox_2, QtCore.SIGNAL("rejected()"), Dialog.reject)
149+
QtCore.QObject.connect(self.buttonBox_2, QtCore.SIGNAL("accepted()"), Dialog.accept)
170150
QtCore.QMetaObject.connectSlotsByName(Dialog)
171151

172152
def retranslateUi(self, Dialog):
@@ -179,4 +159,6 @@ def retranslateUi(self, Dialog):
179159
self.mergeOutput.setText(QtGui.QApplication.translate("Dialog", "Dissolve buffer results", None, QtGui.QApplication.UnicodeUTF8))
180160
self.label_5.setText(QtGui.QApplication.translate("Dialog", "Output shapefile", None, QtGui.QApplication.UnicodeUTF8))
181161
self.btnBrowse.setText(QtGui.QApplication.translate("Dialog", "Browse", None, QtGui.QApplication.UnicodeUTF8))
162+
self.useSelectedA.setText(QtGui.QApplication.translate("Dialog", "Use only selected features", None, QtGui.QApplication.UnicodeUTF8))
163+
self.useSelectedB.setText(QtGui.QApplication.translate("Dialog", "Use only selected features", None, QtGui.QApplication.UnicodeUTF8))
182164

‎python/plugins/fTools/tools/frmGeoprocessing.ui‎

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
</item>
4141
</layout>
4242
</item>
43-
<item row="1" column="0" colspan="2" >
43+
<item row="3" column="0" colspan="2" >
4444
<layout class="QVBoxLayout" >
4545
<item>
4646
<widget class="QLabel" name="label_2" >
@@ -61,7 +61,7 @@
6161
</item>
6262
</layout>
6363
</item>
64-
<item row="2" column="0" colspan="2" >
64+
<item row="5" column="0" colspan="2" >
6565
<layout class="QHBoxLayout" >
6666
<item>
6767
<layout class="QHBoxLayout" >
@@ -101,7 +101,7 @@
101101
</item>
102102
</layout>
103103
</item>
104-
<item row="3" column="0" colspan="2" >
104+
<item row="6" column="0" colspan="2" >
105105
<layout class="QVBoxLayout" >
106106
<item>
107107
<layout class="QHBoxLayout" >
@@ -149,7 +149,7 @@
149149
</item>
150150
</layout>
151151
</item>
152-
<item row="4" column="0" >
152+
<item row="7" column="0" >
153153
<layout class="QHBoxLayout" >
154154
<property name="spacing" >
155155
<number>6</number>
@@ -169,7 +169,7 @@
169169
</item>
170170
</layout>
171171
</item>
172-
<item row="5" column="0" >
172+
<item row="8" column="0" >
173173
<spacer>
174174
<property name="orientation" >
175175
<enum>Qt::Vertical</enum>
@@ -182,7 +182,7 @@
182182
</property>
183183
</spacer>
184184
</item>
185-
<item row="6" column="0" colspan="2" >
185+
<item row="9" column="0" colspan="2" >
186186
<layout class="QVBoxLayout" >
187187
<item>
188188
<widget class="QLabel" name="label_5" >
@@ -211,7 +211,7 @@
211211
</item>
212212
</layout>
213213
</item>
214-
<item row="7" column="0" >
214+
<item row="10" column="0" >
215215
<widget class="QProgressBar" name="progressBar" >
216216
<property name="value" >
217217
<number>0</number>
@@ -224,13 +224,35 @@
224224
</property>
225225
</widget>
226226
</item>
227-
<item row="7" column="1" >
227+
<item row="10" column="1" >
228228
<widget class="QDialogButtonBox" name="buttonBox_2" >
229229
<property name="standardButtons" >
230230
<set>QDialogButtonBox::Close|QDialogButtonBox::Ok</set>
231231
</property>
232232
</widget>
233233
</item>
234+
<item row="2" column="0" >
235+
<layout class="QVBoxLayout" name="verticalLayout" >
236+
<item>
237+
<widget class="QCheckBox" name="useSelectedA" >
238+
<property name="text" >
239+
<string>Use only selected features</string>
240+
</property>
241+
</widget>
242+
</item>
243+
</layout>
244+
</item>
245+
<item row="4" column="0" >
246+
<layout class="QVBoxLayout" name="verticalLayout_2" >
247+
<item>
248+
<widget class="QCheckBox" name="useSelectedB" >
249+
<property name="text" >
250+
<string>Use only selected features</string>
251+
</property>
252+
</widget>
253+
</item>
254+
</layout>
255+
</item>
234256
</layout>
235257
</widget>
236258
<resources/>

‎python/plugins/fTools/tools/frmVisual.py‎

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
# Form implementation generated from reading ui file 'frmVisual.ui'
44
#
5-
# Created: Tue Apr 21 15:10:47 2009
6-
# by: PyQt4 UI code generator 4.4.3
5+
# Created: Tue May 26 18:55:54 2009
6+
# by: PyQt4 UI code generator 4.4.4
77
#
88
# WARNING! All changes made in this file will be lost!
99

@@ -13,7 +13,7 @@ class Ui_Dialog(object):
1313
def setupUi(self, Dialog):
1414
Dialog.setObjectName("Dialog")
1515
Dialog.setWindowModality(QtCore.Qt.NonModal)
16-
Dialog.resize(374, 485)
16+
Dialog.resize(404, 485)
1717
Dialog.setSizeGripEnabled(True)
1818
self.gridLayout = QtGui.QGridLayout(Dialog)
1919
self.gridLayout.setObjectName("gridLayout")
@@ -34,7 +34,7 @@ def setupUi(self, Dialog):
3434
self.cmbField = QtGui.QComboBox(Dialog)
3535
self.cmbField.setObjectName("cmbField")
3636
self.vboxlayout1.addWidget(self.cmbField)
37-
self.gridLayout.addLayout(self.vboxlayout1, 1, 0, 1, 2)
37+
self.gridLayout.addLayout(self.vboxlayout1, 4, 0, 1, 2)
3838
self.vboxlayout2 = QtGui.QVBoxLayout()
3939
self.vboxlayout2.setObjectName("vboxlayout2")
4040
self.label_2 = QtGui.QLabel(Dialog)
@@ -49,7 +49,7 @@ def setupUi(self, Dialog):
4949
self.lstUnique.setSelectionRectVisible(True)
5050
self.lstUnique.setObjectName("lstUnique")
5151
self.vboxlayout2.addWidget(self.lstUnique)
52-
self.gridLayout.addLayout(self.vboxlayout2, 2, 0, 1, 2)
52+
self.gridLayout.addLayout(self.vboxlayout2, 5, 0, 1, 2)
5353
self.hboxlayout = QtGui.QHBoxLayout()
5454
self.hboxlayout.setObjectName("hboxlayout")
5555
self.label_4 = QtGui.QLabel(Dialog)
@@ -59,17 +59,23 @@ def setupUi(self, Dialog):
5959
self.lstCount.setReadOnly(True)
6060
self.lstCount.setObjectName("lstCount")
6161
self.hboxlayout.addWidget(self.lstCount)
62-
self.gridLayout.addLayout(self.hboxlayout, 3, 0, 1, 2)
62+
self.gridLayout.addLayout(self.hboxlayout, 6, 0, 1, 2)
6363
self.progressBar = QtGui.QProgressBar(Dialog)
6464
self.progressBar.setProperty("value", QtCore.QVariant(24))
6565
self.progressBar.setAlignment(QtCore.Qt.AlignCenter)
6666
self.progressBar.setObjectName("progressBar")
67-
self.gridLayout.addWidget(self.progressBar, 4, 0, 1, 1)
67+
self.gridLayout.addWidget(self.progressBar, 7, 0, 1, 1)
6868
self.buttonBox_2 = QtGui.QDialogButtonBox(Dialog)
6969
self.buttonBox_2.setOrientation(QtCore.Qt.Horizontal)
7070
self.buttonBox_2.setStandardButtons(QtGui.QDialogButtonBox.Close|QtGui.QDialogButtonBox.Ok)
7171
self.buttonBox_2.setObjectName("buttonBox_2")
72-
self.gridLayout.addWidget(self.buttonBox_2, 4, 1, 1, 1)
72+
self.gridLayout.addWidget(self.buttonBox_2, 7, 1, 1, 1)
73+
self.verticalLayout = QtGui.QVBoxLayout()
74+
self.verticalLayout.setObjectName("verticalLayout")
75+
self.useSelected = QtGui.QCheckBox(Dialog)
76+
self.useSelected.setObjectName("useSelected")
77+
self.verticalLayout.addWidget(self.useSelected)
78+
self.gridLayout.addLayout(self.verticalLayout, 3, 0, 1, 1)
7379

7480
self.retranslateUi(Dialog)
7581
QtCore.QObject.connect(self.buttonBox_2, QtCore.SIGNAL("accepted()"), Dialog.accept)
@@ -83,4 +89,5 @@ def retranslateUi(self, Dialog):
8389
self.label_2.setText(QtGui.QApplication.translate("Dialog", "Unique values list", None, QtGui.QApplication.UnicodeUTF8))
8490
self.lstUnique.setSortingEnabled(True)
8591
self.label_4.setText(QtGui.QApplication.translate("Dialog", "Unique value count", None, QtGui.QApplication.UnicodeUTF8))
92+
self.useSelected.setText(QtGui.QApplication.translate("Dialog", "Use only selected features", None, QtGui.QApplication.UnicodeUTF8))
8693

‎python/plugins/fTools/tools/frmVisual.ui‎

Lines changed: 60 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,126 +1,138 @@
1-
<ui version="4.0" >
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
23
<class>Dialog</class>
3-
<widget class="QDialog" name="Dialog" >
4-
<property name="windowModality" >
4+
<widget class="QDialog" name="Dialog">
5+
<property name="windowModality">
56
<enum>Qt::NonModal</enum>
67
</property>
7-
<property name="geometry" >
8+
<property name="geometry">
89
<rect>
910
<x>0</x>
1011
<y>0</y>
11-
<width>374</width>
12+
<width>404</width>
1213
<height>485</height>
1314
</rect>
1415
</property>
15-
<property name="windowTitle" >
16+
<property name="windowTitle">
1617
<string>List Unique Values</string>
1718
</property>
18-
<property name="sizeGripEnabled" >
19+
<property name="sizeGripEnabled">
1920
<bool>true</bool>
2021
</property>
21-
<layout class="QGridLayout" name="gridLayout" >
22-
<item row="0" column="0" colspan="2" >
23-
<layout class="QVBoxLayout" >
22+
<layout class="QGridLayout" name="gridLayout">
23+
<item row="0" column="0" colspan="2">
24+
<layout class="QVBoxLayout">
2425
<item>
25-
<widget class="QLabel" name="label_3" >
26-
<property name="text" >
26+
<widget class="QLabel" name="label_3">
27+
<property name="text">
2728
<string>Input Vector Layer</string>
2829
</property>
2930
</widget>
3031
</item>
3132
<item>
32-
<widget class="QComboBox" name="inShape" />
33+
<widget class="QComboBox" name="inShape"/>
3334
</item>
3435
</layout>
3536
</item>
36-
<item row="1" column="0" colspan="2" >
37-
<layout class="QVBoxLayout" >
37+
<item row="4" column="0" colspan="2">
38+
<layout class="QVBoxLayout">
3839
<item>
39-
<widget class="QLabel" name="label" >
40-
<property name="text" >
40+
<widget class="QLabel" name="label">
41+
<property name="text">
4142
<string>Target field</string>
4243
</property>
4344
</widget>
4445
</item>
4546
<item>
46-
<widget class="QComboBox" name="cmbField" />
47+
<widget class="QComboBox" name="cmbField"/>
4748
</item>
4849
</layout>
4950
</item>
50-
<item row="2" column="0" colspan="2" >
51-
<layout class="QVBoxLayout" >
51+
<item row="5" column="0" colspan="2">
52+
<layout class="QVBoxLayout">
5253
<item>
53-
<widget class="QLabel" name="label_2" >
54-
<property name="text" >
54+
<widget class="QLabel" name="label_2">
55+
<property name="text">
5556
<string>Unique values list</string>
5657
</property>
5758
</widget>
5859
</item>
5960
<item>
60-
<widget class="QListWidget" name="lstUnique" >
61-
<property name="editTriggers" >
61+
<widget class="QListWidget" name="lstUnique">
62+
<property name="editTriggers">
6263
<set>QAbstractItemView::NoEditTriggers</set>
6364
</property>
64-
<property name="showDropIndicator" stdset="0" >
65+
<property name="showDropIndicator" stdset="0">
6566
<bool>false</bool>
6667
</property>
67-
<property name="alternatingRowColors" >
68+
<property name="alternatingRowColors">
6869
<bool>true</bool>
6970
</property>
70-
<property name="selectionMode" >
71+
<property name="selectionMode">
7172
<enum>QAbstractItemView::ExtendedSelection</enum>
7273
</property>
73-
<property name="selectionBehavior" >
74+
<property name="selectionBehavior">
7475
<enum>QAbstractItemView::SelectRows</enum>
7576
</property>
76-
<property name="selectionRectVisible" >
77+
<property name="selectionRectVisible">
7778
<bool>true</bool>
7879
</property>
79-
<property name="sortingEnabled" >
80+
<property name="sortingEnabled">
8081
<bool>true</bool>
8182
</property>
8283
</widget>
8384
</item>
8485
</layout>
8586
</item>
86-
<item row="3" column="0" colspan="2" >
87-
<layout class="QHBoxLayout" >
87+
<item row="6" column="0" colspan="2">
88+
<layout class="QHBoxLayout">
8889
<item>
89-
<widget class="QLabel" name="label_4" >
90-
<property name="text" >
90+
<widget class="QLabel" name="label_4">
91+
<property name="text">
9192
<string>Unique value count</string>
9293
</property>
9394
</widget>
9495
</item>
9596
<item>
96-
<widget class="QLineEdit" name="lstCount" >
97-
<property name="readOnly" >
97+
<widget class="QLineEdit" name="lstCount">
98+
<property name="readOnly">
9899
<bool>true</bool>
99100
</property>
100101
</widget>
101102
</item>
102103
</layout>
103104
</item>
104-
<item row="4" column="0" >
105-
<widget class="QProgressBar" name="progressBar" >
106-
<property name="value" >
105+
<item row="7" column="0">
106+
<widget class="QProgressBar" name="progressBar">
107+
<property name="value">
107108
<number>24</number>
108109
</property>
109-
<property name="alignment" >
110+
<property name="alignment">
110111
<set>Qt::AlignCenter</set>
111112
</property>
112113
</widget>
113114
</item>
114-
<item row="4" column="1" >
115-
<widget class="QDialogButtonBox" name="buttonBox_2" >
116-
<property name="orientation" >
115+
<item row="7" column="1">
116+
<widget class="QDialogButtonBox" name="buttonBox_2">
117+
<property name="orientation">
117118
<enum>Qt::Horizontal</enum>
118119
</property>
119-
<property name="standardButtons" >
120+
<property name="standardButtons">
120121
<set>QDialogButtonBox::Close|QDialogButtonBox::Ok</set>
121122
</property>
122123
</widget>
123124
</item>
125+
<item row="3" column="0">
126+
<layout class="QVBoxLayout" name="verticalLayout">
127+
<item>
128+
<widget class="QCheckBox" name="useSelected">
129+
<property name="text">
130+
<string>Use only selected features</string>
131+
</property>
132+
</widget>
133+
</item>
134+
</layout>
135+
</item>
124136
</layout>
125137
</widget>
126138
<resources/>
@@ -131,11 +143,11 @@
131143
<receiver>Dialog</receiver>
132144
<slot>accept()</slot>
133145
<hints>
134-
<hint type="sourcelabel" >
146+
<hint type="sourcelabel">
135147
<x>133</x>
136148
<y>276</y>
137149
</hint>
138-
<hint type="destinationlabel" >
150+
<hint type="destinationlabel">
139151
<x>215</x>
140152
<y>290</y>
141153
</hint>
@@ -147,11 +159,11 @@
147159
<receiver>Dialog</receiver>
148160
<slot>close()</slot>
149161
<hints>
150-
<hint type="sourcelabel" >
162+
<hint type="sourcelabel">
151163
<x>59</x>
152164
<y>276</y>
153165
</hint>
154-
<hint type="destinationlabel" >
166+
<hint type="destinationlabel">
155167
<x>132</x>
156168
<y>239</y>
157169
</hint>

‎python/plugins/fTools/tools/ftools_utils.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
# addShapeToCanvas( QString *file path )
2020
# getUniqueValues( QgsVectorDataProvider, int *field id )
2121
# saveDialog( QWidget *parent )
22+
# getFieldType( QgsVectorLayer, QgsField.name() )
2223
#
2324
# -------------------------------------------------
2425

@@ -260,3 +261,9 @@ def saveDialog( parent ):
260261
settings.setValue("/UI/lastShapefileDir", QVariant( QFileInfo( unicode( files.first() ) ).absolutePath() ) )
261262
return ( unicode( files.first() ), unicode( fileDialog.encoding() ) )
262263

264+
# Return field type from it's name
265+
def getFieldType(vlayer, fieldName):
266+
fields = vlayer.dataProvider().fields()
267+
for name, field in fields.iteritems():
268+
if field.name() == fieldName:
269+
return field.typeName()

0 commit comments

Comments
 (0)
Please sign in to comment.