[QGIS Commit] r10849 - trunk/qgis/python/plugins/fTools/tools

svn_qgis at osgeo.org svn_qgis at osgeo.org
Tue May 26 14:07:37 EDT 2009


Author: cfarmer
Date: 2009-05-26 14:07:37 -0400 (Tue, 26 May 2009)
New Revision: 10849

Modified:
   trunk/qgis/python/plugins/fTools/tools/doGeoprocessing.py
   trunk/qgis/python/plugins/fTools/tools/doVisual.py
   trunk/qgis/python/plugins/fTools/tools/frmGeoprocessing.py
   trunk/qgis/python/plugins/fTools/tools/frmGeoprocessing.ui
   trunk/qgis/python/plugins/fTools/tools/frmVisual.py
   trunk/qgis/python/plugins/fTools/tools/frmVisual.ui
   trunk/qgis/python/plugins/fTools/tools/ftools_utils.py
Log:
applying patch from ticket #1714: adds option to perform geoprocessing and basic statistics functions on selected features

Modified: trunk/qgis/python/plugins/fTools/tools/doGeoprocessing.py
===================================================================
--- trunk/qgis/python/plugins/fTools/tools/doGeoprocessing.py	2009-05-25 21:05:34 UTC (rev 10848)
+++ trunk/qgis/python/plugins/fTools/tools/doGeoprocessing.py	2009-05-26 18:07:37 UTC (rev 10849)
@@ -13,13 +13,33 @@
 		self.setupUi( self )
 		self.myFunction = function
 		QObject.connect( self.btnBrowse, SIGNAL( "clicked()" ), self.outFile )
+		QObject.connect( self.inShapeA, SIGNAL( "currentIndexChanged(QString)" ), self.checkA )
+		QObject.connect( self.inShapeB, SIGNAL( "currentIndexChanged(QString)" ), self.checkB )
 		if function == 4 or function == 1 or function == 2:
 			QObject.connect( self.inShapeA, SIGNAL( "currentIndexChanged(QString)" ), self.update )
 		self.manageGui()
 		self.success = False
 		self.cancel_close = self.buttonBox_2.button( QDialogButtonBox.Close )
 		self.progressBar.setValue (0 )
-		
+	
+	def checkA( self ):
+		inputLayer = unicode( self.inShapeA.currentText() )
+		if inputLayer != "":
+			changedLayer = ftools_utils.getVectorLayerByName( inputLayer )
+			if changedLayer.selectedFeatureCount() != 0:
+				self.useSelectedA.setCheckState( Qt.Checked )
+			else:
+				self.useSelectedA.setCheckState( Qt.Unchecked )
+	
+	def checkB( self ):
+		inputLayer = unicode( self.inShapeB.currentText() )
+		if inputLayer != "":
+			changedLayer = ftools_utils.getVectorLayerByName( inputLayer )
+			if changedLayer.selectedFeatureCount() != 0:
+				self.useSelectedB.setCheckState( Qt.Checked )
+			else:
+				self.useSelectedB.setCheckState( Qt.Unchecked )
+	
 	def update( self ):
 		self.attrib.clear()
 		inputLayer = unicode( self.inShapeA.currentText() )
@@ -30,56 +50,69 @@
 				self.attrib.addItem( unicode( changedField[i].name() ) )
 			if self.myFunction == 4:
 				self.attrib.addItem( "--- " + self.tr( "Dissolve all" ) + " ---" )
-
+	
 	def accept( self ):
 		if self.inShapeA.currentText() == "":
-			QMessageBox.warning( self,  "Geoprocessing", self.tr( "Please specify an input layer" ) )		
+			QMessageBox.warning( self, "Geoprocessing", self.tr( "Please specify an input layer" ) )
 		elif self.inShapeB.isVisible() and self.inShapeB.currentText() == "":
-			QMessageBox.warning( self,  "Geoprocessing", self.tr( "Please specify a difference/intersect/union layer" ) )
+			QMessageBox.warning( self, "Geoprocessing", self.tr( "Please specify a difference/intersect/union layer" ) )
 		elif self.param.isEnabled() and self.param.isVisible() and self.param.text() == "":
 			QMessageBox.warning( self, "Geoprocessing", self.tr( "Please specify valid buffer value" ) )
 		elif self.attrib.isEnabled() and self.attrib.isVisible() and self.attrib.currentText() == "":
 			QMessageBox.warning( self, "Geoprocessing", self.tr( "Please specify dissolve field" ) )
 		elif self.outShape.text() == "":
 			QMessageBox.warning( self, "Geoprocessing", self.tr( "Please specify output shapefile" ) )
-		else: 
-			self.outShape.clear()
-			if self.attrib.isEnabled():
-				self.geoprocessing( self.inShapeA.currentText(), self.inShapeB.currentText(), 
-				unicode( self.attrib.currentText() ), self.mergeOutput.checkState() )
+		else:
+			changedLayerA = ftools_utils.getVectorLayerByName( self.inShapeA.currentText() )
+			changedLayerB = ftools_utils.getVectorLayerByName( self.inShapeB.currentText() )
+			# check for selection in layer A
+			if self.useSelectedA.isChecked() and changedLayerA.selectedFeatureCount() == 0:
+				QMessageBox.warning( self, "Geoprocessing", self.tr( "No features selected, please uncheck 'Use selected' or make a selection" ) )
+			# check for selection in layer B
+			elif self.inShapeB.isVisible() and self.useSelectedB.isChecked() and changedLayerB.selectedFeatureCount() == 0:
+				QMessageBox.warning( self, "Geoprocessing", self.tr( "No features selected, please uncheck 'Use selected' or make a selection" ) )
 			else:
-				if self.param.isEnabled() and self.param.isVisible():
-					parameter = float( self.param.text() )
+				self.outShape.clear()
+				if self.attrib.isEnabled():
+					self.geoprocessing( self.inShapeA.currentText(), self.inShapeB.currentText(), 
+					unicode( self.attrib.currentText() ), self.mergeOutput.checkState(), self.useSelectedA.checkState(),
+					self.useSelectedB.checkState() )
 				else:
-					parameter = None
-				self.geoprocessing( self.inShapeA.currentText(), self.inShapeB.currentText(), 
-				parameter, self.mergeOutput.checkState() )
-  
+					if self.param.isEnabled() and self.param.isVisible():
+						parameter = float( self.param.text() )
+					else:
+						parameter = None
+					self.geoprocessing( self.inShapeA.currentText(), self.inShapeB.currentText(), 
+					parameter, self.mergeOutput.checkState(), self.useSelectedA.checkState(), self.useSelectedB.checkState() )
+	
 	def outFile( self ):
 		self.outShape.clear()
 		( self.shapefileName, self.encoding ) = ftools_utils.saveDialog( self )
 		if self.shapefileName is None or self.encoding is None:
 			return
 		self.outShape.setText( QString( self.shapefileName ) )
-
+	
 	def manageGui( self ):
 		if self.myFunction == 1:  # Buffer
 			self.label_2.hide()
 			self.inShapeB.hide()
+			self.useSelectedB.hide()
 			self.label_4.hide()
 			self.setWindowTitle( self.tr( "Buffer(s)" ) )
 		elif self.myFunction == 2: # Convex hull
 			self.label_2.hide()
 			self.inShapeB.hide()
+			self.useSelectedB.hide()
 			self.rdoBuffer.setText( self.tr( "Create single minimum convex hull" ) )
 			self.rdoField.setText( self.tr( "Create convex hulls based on input field" ) )
 			self.label_4.hide()
 			self.param.hide()
-			self.setWindowTitle( self.tr( "Convex hull(s)" ) )    
+			self.setWindowTitle( self.tr( "Convex hull(s)" ) )
 			self.mergeOutput.hide()
 		elif self.myFunction == 4: # Dissolve
 			self.label_2.hide()
 			self.inShapeB.hide()
+			self.useSelectedB.hide()
 			self.rdoBuffer.hide()
 			self.attrib.setEnabled( True )
 			self.param.hide()
@@ -112,19 +145,19 @@
 		myListA = []
 		myListB = []
 		self.inShapeA.clear()
-		self.inShapeB.clear() 
-        
+		self.inShapeB.clear()
+		
 		if self.myFunction == 5 or self.myFunction == 8 or self.myFunction == 3:
-			myListA = ftools_utils.getLayerNames( [ QGis.Point, QGis.Line, QGis.Polygon ] )    
-			myListB = ftools_utils.getLayerNames( [ QGis.Polygon ] )    
+			myListA = ftools_utils.getLayerNames( [ QGis.Point, QGis.Line, QGis.Polygon ] )
+			myListB = ftools_utils.getLayerNames( [ QGis.Polygon ] )
 		elif self.myFunction == 7 or self.myFunction == 6:
 			myListA = ftools_utils.getLayerNames( [ QGis.Polygon ] )
-			myListB = ftools_utils.getLayerNames( [ QGis.Polygon ] )                 
+			myListB = ftools_utils.getLayerNames( [ QGis.Polygon ] )
 		elif self.myFunction == 4:
-			myListA = ftools_utils.getLayerNames( [ QGis.Polygon ] )                
+			myListA = ftools_utils.getLayerNames( [ QGis.Polygon ] )
 			myListB = []
 		else:
-			myListA = ftools_utils.getLayerNames( [ QGis.Point, QGis.Line, QGis.Polygon ] )    
+			myListA = ftools_utils.getLayerNames( [ QGis.Point, QGis.Line, QGis.Polygon ] )
 			myListB = ftools_utils.getLayerNames( [ QGis.Point, QGis.Line, QGis.Polygon ] )
 		self.inShapeA.addItems( myListA )
 		self.inShapeB.addItems( myListB )
@@ -139,14 +172,14 @@
 #7: Symetrical Difference
 #8: Clip
 
-	def geoprocessing( self,  myLayerA,  myLayerB,  myParam,  myMerge ):
+	def geoprocessing( self,  myLayerA,  myLayerB,  myParam,  myMerge, mySelectionA, mySelectionB ):
 		check = QFile( self.shapefileName )
 		if check.exists():
 			if not QgsVectorFileWriter.deleteShapeFile( self.shapefileName ):
 				QMessageBox.warning( self, "Geoprocessing", self.tr( "Unable to delete existing shapefile." ) )
 				return
 		self.testThread = geoprocessingThread( self.iface.mainWindow(), self, self.myFunction, myLayerA, 
-		myLayerB, myParam, myMerge, self.shapefileName, self.encoding )
+		myLayerB, myParam, myMerge, mySelectionA, mySelectionB, self.shapefileName, self.encoding )
 		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 )
@@ -154,10 +187,10 @@
 		QObject.connect( self.cancel_close, SIGNAL( "clicked()" ), self.cancelThread )
 		self.testThread.start()
 		return True
-
+	
 	def cancelThread( self ):
 		self.testThread.stop()
-		
+	
 	def runFinishedFromThread( self, results ):
 		self.testThread.stop()
 		self.cancel_close.setText( "Close" )
@@ -183,13 +216,13 @@
 		
 	def runStatusFromThread( self, status ):
 		self.progressBar.setValue( status )
-        
+	
 	def runRangeFromThread( self, range_vals ):
 		self.progressBar.setRange( range_vals[ 0 ], range_vals[ 1 ] )
-		
+	
 class geoprocessingThread( QThread ):
 	def __init__( self, parentThread, parentObject, function, myLayerA, myLayerB, 
-	myParam, myMerge, myName, myEncoding ):
+	myParam, myMerge, mySelectionA, mySelectionB, myName, myEncoding ):
 		QThread.__init__( self, parentThread )
 		self.parent = parentObject
 		self.running = False
@@ -198,9 +231,11 @@
 		self.myLayerB = myLayerB
 		self.myParam = myParam
 		self.myMerge = myMerge
+		self.mySelectionA = mySelectionA
+		self.mySelectionB = mySelectionB
 		self.myName = myName
 		self.myEncoding = myEncoding
-
+	
 	def run( self ):
 		self.running = True
 		self.vlayerA = ftools_utils.getVectorLayerByName( self.myLayerA )
@@ -221,16 +256,16 @@
 				geos, feature, match = self.intersect()
 			elif self.myFunction == 6:
 				geos, feature, match = self.union()
-			elif self.myFunction == 7:    
+			elif self.myFunction == 7:
 				geos, feature, match = self.symetrical_difference()
-			elif self.myFunction == 8:    
+			elif self.myFunction == 8:
 				geos, feature, match = self.clip()
 		self.emit( SIGNAL( "runFinished(PyQt_PyObject)" ), (geos, feature, match) )
 		self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
-
+	
 	def stop(self):
 		self.running = False
-
+	
 	def buffering( self, useField ):
 		GEOS_EXCEPT = True
 		FEATURE_EXCEPT = True
@@ -244,68 +279,130 @@
 		inFeat = QgsFeature()
 		inGeom = QgsGeometry()
 		outGeom = QgsGeometry()
-		nFeat = vproviderA.featureCount()
 		nElement = 0
-		self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0)
-		self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
-		if self.myMerge:
-			first = True
-			vproviderA.rewind()
-			add = True
-			while vproviderA.nextFeature( inFeat ):
-				atMap = inFeat.attributeMap()
-				if useField:
-					value = atMap[ self.myParam ].toDouble()[ 0 ]
-				else:
-					value = self.myParam
-				inGeom = QgsGeometry( inFeat.geometry() )
+		# there is selection in input layer
+		if self.mySelectionA:
+			nFeat = self.vlayerA.selectedFeatureCount()
+			selectionA = self.vlayerA.selectedFeatures()
+			self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
+			self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
+			# with dissolve
+			if self.myMerge:
+				first = True
+				for inFeat in selectionA:
+					atMap = inFeat.attributeMap()
+					if useField:
+						value = atMap[ self.myParam ].doDouble()[ 0 ]
+					else:
+						value = self.myParam
+					inGeom = QgsGeometry( inFeat.geometry() )
+					try:
+						outGeom = inGeom.buffer( float( value ), 5 )
+						if first:
+							tempGeom = QgsGeometry( outGeom )
+							first = False
+						else:
+							try:
+								tempGeom = tempGeom.combine( outGeom )
+							except:
+								GEOS_EXCEPT = False
+								continue
+					except:
+						GEOS_EXCEPT = False
+						continue
+					nElement += 1
+					self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
 				try:
-					outGeom = inGeom.buffer( float( value ), 5 )
-					if first:
-						tempGeom = QgsGeometry( outGeom )
-						first = False
+					outFeat.setGeometry( tempGeom )
+					writer.addFeature( outFeat )
+				except:
+					FEATURE_EXCEPT = False
+			# without dissolve
+			else:
+				for inFeat in selectionA:
+					atMap = inFeat.attributeMap()
+					if useField:
+						value = atMap[ self.myParam ].toDouble()[ 0 ]
 					else:
+						value = self.myParam
+					inGeom = QgsGeometry( inFeat.geometry() )
+					try:
+						outGeom = inGeom.buffer( float( value ), 5 )
 						try:
-							tempGeom = tempGeom.combine( outGeom )
+							outFeat.setGeometry( outGeom )
+							outFeat.setAttributeMap( atMap )
+							writer.addFeature( outFeat )
 						except:
-							GEOS_EXCEPT = False
+							FEATURE_EXCEPT = False
 							continue
-				except:
-					GEOS_EXCEPT = False
-					continue
-				nElement += 1
-				self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
-			try:
-				outFeat.setGeometry( tempGeom )
-				writer.addFeature( outFeat )
-			except:
-				FEATURE_EXCEPT = False
+					except:
+						GEOS_EXCEPT = False
+						continue
+					nElement += 1
+					self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
+		# there is no selection in input layer
 		else:
-			vproviderA.rewind()
-			while vproviderA.nextFeature( inFeat ):
-				atMap = inFeat.attributeMap()
-				if useField:
-					value = atMap[ self.myParam ].toDouble()[ 0 ]
-				else:
-					value = self.myParam
-				inGeom = QgsGeometry( inFeat.geometry() )
+			nFeat = vproviderA.featureCount()
+			self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
+			self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
+			# with dissolve
+			if self.myMerge:
+				first = True
+				while vproviderA.nextFeature( inFeat ):
+					atMap = inFeat.attributeMap()
+					if useField:
+						value = atMap[ self.myParam ].toDouble()[ 0 ]
+					else:
+						value = self.myParam
+					inGeom = QgsGeometry( inFeat.geometry() )
+					try:
+						outGeom = inGeom.buffer( float( value ), 5 )
+						if first:
+							tempGeom = QgsGeometry( outGeom )
+							first = False
+						else:
+							try:
+								tempGeom = tempGeom.combine( outGeom )
+							except:
+								GEOS_EXCEPT = False
+								continue
+					except:
+						GEOS_EXCEPT = False
+						continue
+					nElement += 1
+					self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
 				try:
-					outGeom = inGeom.buffer( float( value ), 5 )
+					outFeat.setGeometry( tempGeom )
+					writer.addFeature( outFeat )
+				except:
+					FEATURE_EXCEPT = False
+			# without dissolve
+			else:
+				vproviderA.rewind()
+				while vproviderA.nextFeature( inFeat ):
+					atMap = inFeat.attributeMap()
+					if useField:
+						value = atMap[ self.myParam ].toDouble()[ 0 ]
+					else:
+						value = self.myParam
+					inGeom = QgsGeometry( inFeat.geometry() )
 					try:
-						outFeat.setGeometry( outGeom )
-						outFeat.setAttributeMap( atMap )
-						writer.addFeature( outFeat )
+						outGeom = inGeom.buffer( float( value ), 5 )
+						try:
+							outFeat.setGeometry( outGeom )
+							outFeat.setAttributeMap( atMap )
+							writer.addFeature( outFeat )
+						except:
+							FEATURE_EXCEPT = False
+							continue
 					except:
-						FEATURE_EXCEPT = False
+						GEOS_EXCEPT = False
 						continue
-				except:
-					GEOS_EXCEPT = False
-					continue
-				nElement += 1
-				self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ),  nElement )
+					nElement += 1
+					self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
 		del writer
 		return GEOS_EXCEPT, FEATURE_EXCEPT, True
-
+	
 	def convex_hull(self, useField ):
 		GEOS_EXCEPT = True
 		FEATURE_EXCEPT = True
@@ -318,66 +415,122 @@
 		outFeat = QgsFeature()
 		inGeom = QgsGeometry()
 		outGeom = QgsGeometry()
-		if useField:
-			unique = ftools_utils.getUniqueValues( vproviderA, self.myParam )
-			nFeat = vproviderA.featureCount() * len( unique )
-			nElement = 0
-			self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0)
-			self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
-			for i in unique:
+		nElement = 0
+		# there is selection in input layer
+		if self.mySelectionA:
+			nFeat = self.vlayerA.selectedFeatureCount()
+			selectionA = self.vlayerA.selectedFeatures()
+			if useField:
+				unique = ftools_utils.getUniqueValues( vproviderA, self.myParam )
+				nFeat = nFeat * len( unique )
+				self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
+				self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
+				for i in unique:
+					hull = []
+					first = True
+					outID = 0
+					for inFeat in selectionA:
+						atMap = inFeat.attributeMap()
+						idVar = atMap[ self.myParam ]
+						if idVar.toString().trimmed() == i.toString().trimmed():
+							if first:
+								outID = idVar
+								first = False
+							inGeom = QgsGeometry( inFeat.geometry() )
+							points = ftools_utils.extractPoints( inGeom )
+							hull.extend( points )
+						nElement += 1
+						self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
+					if len( hull ) >= 3:
+						tmpGeom = QgsGeometry( outGeom.fromMultiPoint( hull ) )
+						try:
+							outGeom = tmpGeom.convexHull()
+							outFeat.setGeometry( outGeom )
+							(area, perim) = self.simpleMeasure( outGeom )
+							outFeat.addAttribute( 0, QVariant( outID ) )
+							outFeat.addAttribute( 1, QVariant( area ) )
+							outFeat.addAttribute( 2, QVariant( perim ) )
+							writer.addFeature( outFeat )
+						except:
+							GEOS_EXCEPT = False
+							continue
+			else:
+				self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
+				self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
 				hull = []
-				first = True
-				outID = 0
-				vproviderA.select( allAttrsA )
+				for inFeat in selectionA:
+					inGeom = QgsGeometry( inFeat.geometry() )
+					points = ftools_utils.extractPoints( inGeom )
+					hull.extend( points )
+					nElement += 1
+					self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
+				tmpGeom = QgsGeometry( outGeom.fromMultiPoint( hull ) )
+				try:
+					outGeom = tmpGeom.convexHull()
+					outFeat.setGeometry( outGeom )
+					writer.addFeature( outFeat )
+				except:
+					GEOS_EXCEPT = False
+		# there is no selection in input layer
+		else:
+			nFeat = vproviderA.featureCount()
+			if useField:
+				unique = ftools_utils.getUniqueValues( vproviderA, self.myParam )
+				nFeat = nFeat * len( unique )
+				self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
+				self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
+				for i in unique:
+					hull = []
+					first = True
+					outID = 0
+					vproviderA.select( allAttrsA )
+					vproviderA.rewind()
+					while vproviderA.nextFeature( inFeat ):
+						atMap = inFeat.attributeMap()
+						idVar = atMap[ self.myParam ]
+						if idVar.toString().trimmed() == i.toString().trimmed():
+							if first:
+								outID = idVar
+								first = False
+							inGeom = QgsGeometry( inFeat.geometry() )
+							points = ftools_utils.extractPoints( inGeom )
+							hull.extend( points )
+						nElement += 1
+						self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
+					if len( hull ) >= 3:
+						tmpGeom = QgsGeometry( outGeom.fromMultiPoint( hull ) )
+						try:
+							outGeom = tmpGeom.convexHull()
+							outFeat.setGeometry( outGeom )
+							(area, perim) = self.simpleMeasure( outGeom )
+							outFeat.addAttribute( 0, QVariant( outID ) )
+							outFeat.addAttribute( 1, QVariant( area ) )
+							outFeat.addAttribute( 2, QVariant( perim ) )
+							writer.addFeature( outFeat )
+						except:
+							GEOS_EXCEPT = False
+							continue
+			else:
+				self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
+				self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
+				hull = []
 				vproviderA.rewind()
 				while vproviderA.nextFeature( inFeat ):
-					atMap = inFeat.attributeMap()
-					idVar = atMap[ self.myParam ]
-					if idVar.toString().trimmed() == i.toString().trimmed():
-						if first:
-							outID = idVar
-							first = False
-						inGeom = QgsGeometry( inFeat.geometry() )
-						points = ftools_utils.extractPoints( inGeom )
-						hull.extend( points )
+					inGeom = QgsGeometry( inFeat.geometry() )
+					points = ftools_utils.extractPoints( inGeom )
+					hull.extend( points )
 					nElement += 1
-					self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ),  nElement )
-				if len( hull ) >= 3:
-					tmpGeom = QgsGeometry( outGeom.fromMultiPoint( hull ) )
-					try:
-						outGeom = tmpGeom.convexHull()
-						outFeat.setGeometry( outGeom )
-						(area, perim) = self.simpleMeasure( outGeom )
-						outFeat.addAttribute( 0, QVariant( outID ) )
-						outFeat.addAttribute( 1, QVariant( area ) )
-						outFeat.addAttribute( 2, QVariant( perim ) )
-						writer.addFeature( outFeat )
-					except:
-						GEOS_EXCEPT = False
-						continue
-		else:
-			hull = []
-			vproviderA.rewind()
-			nFeat = vproviderA.featureCount()
-			nElement = 0
-			self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0)
-			self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
-			while vproviderA.nextFeature( inFeat ):
-				inGeom = QgsGeometry( inFeat.geometry() )
-				points = ftools_utils.extractPoints( inGeom )
-				hull.extend( points )
-				nElement += 1
-				self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ),  nElement )
-			tmpGeom = QgsGeometry( outGeom.fromMultiPoint( hull ) )
-			try:
-				outGeom = tmpGeom.convexHull()
-				outFeat.setGeometry( outGeom )
-				writer.addFeature( outFeat )
-			except:
-				GEOS_EXCEPT = False
+					self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
+				tmpGeom = QgsGeometry( outGeom.fromMultiPoint( hull ) )
+				try:
+					outGeom = tmpGeom.convexHull()
+					outFeat.setGeometry( outGeom )
+					writer.addFeature( outFeat )
+				except:
+					GEOS_EXCEPT = False
 		del writer
 		return GEOS_EXCEPT, FEATURE_EXCEPT, True
-
+	
 	def dissolve( self, useField ):
 		GEOS_EXCEPT = True
 		FEATURE_EXCEPT = True
@@ -389,69 +542,132 @@
 		inFeat = QgsFeature()
 		outFeat = QgsFeature()
 		vproviderA.rewind()
-		nFeat = vproviderA.featureCount()
 		nElement = 0
-		if not useField:
-			self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0)
-			self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
-			first = True
-			add = True
-			while vproviderA.nextFeature( inFeat ):
-				nElement += 1
-				self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ),  nElement )
-				if first:
-					attrs = inFeat.attributeMap()
-					tmpInGeom = QgsGeometry( inFeat.geometry() )
-					outFeat.setGeometry( tmpInGeom )
-					first = False
-				else:
-					tmpInGeom = QgsGeometry( inFeat.geometry() )
-					tmpOutGeom = QgsGeometry( outFeat.geometry() )
-					try:
-						tmpOutGeom = QgsGeometry( tmpOutGeom.combine( tmpInGeom ) )
-						outFeat.setGeometry( tmpOutGeom )
-					except:
-						GEOS_EXCEPT = False
-						continue
-			outFeat.setAttributeMap( attrs )
-			writer.addFeature( outFeat )
+		# there is selection in input layer
+		if self.mySelectionA:
+			nFeat = self.vlayerA.selectedFeatureCount()
+			selectionA = self.vlayerA.selectedFeatures()
+			if not useField:
+				self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
+				self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
+				first = True
+				for inFeat in selectionA:
+					nElement += 1
+					self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
+					if first:
+						attrs = inFeat.attributeMap()
+						tmpInGeom = QgsGeometry( inFeat.geometry() )
+						outFeat.setGeometry( tmpInGeom )
+						first = False
+					else:
+						tmpInGeom = QgsGeometry( inFeat.geometry() )
+						tmpOutGeom = QgsGeometry( outFeat.geometry() )
+						try:
+							tmpOutGeom = QgsGeometry( tmpOutGeom.combine( tmpInGeom ) )
+							outFeat.setGeometry( tmpOutGeom )
+						except:
+							GEOS_EXCEPT = False
+							continue
+				outFeat.setAttributeMap( attrs )
+				writer.addFeature( outFeat )
+			else:
+				unique = vproviderA.uniqueValues( int( self.myParam ) )
+				nFeat = nFeat * len( unique )
+				self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
+				self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
+				for item in unique:
+					first = True
+					add = False
+					vproviderA.select( allAttrsA )
+					vproviderA.rewind()
+					for inFeat in selectionA:
+						nElement += 1
+						self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
+						atMap = inFeat.attributeMap()
+						tempItem = atMap[ self.myParam ]
+						if tempItem.toString().trimmed() == item.toString().trimmed():
+							add = True
+							if first:
+								QgsGeometry( inFeat.geometry() )
+								tmpInGeom = QgsGeometry( inFeat.geometry() )
+								outFeat.setGeometry( tmpInGeom )
+								first = False
+								attrs = inFeat.attributeMap()
+							else:
+								tmpInGeom = QgsGeometry( inFeat.geometry() )
+								tmpOutGeom = QgsGeometry( outFeat.geometry() )
+								try:
+									tmpOutGeom = QgsGeometry( tmpOutGeom.combine( tmpInGeom ) )
+									outFeat.setGeometry( tmpOutGeom )
+								except:
+									GEOS_EXCEPT = False
+									add = False
+					if add:
+						outFeat.setAttributeMap( attrs )
+						writer.addFeature( outFeat )
+		# there is no selection in input layer
 		else:
-			unique = vproviderA.uniqueValues( int( self.myParam ) )
-			nFeat = nFeat * len( unique )
-			self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0)
-			self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
-			for item in unique:
+			nFeat = vproviderA.featureCount()
+			if not useField:
+				self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0)
+				self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
 				first = True
-				add = True
-				vproviderA.select( allAttrsA )
-				vproviderA.rewind()
 				while vproviderA.nextFeature( inFeat ):
 					nElement += 1
 					self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ),  nElement )
-					atMap = inFeat.attributeMap()
-					tempItem = atMap[ self.myParam ]
-					if tempItem.toString().trimmed() == item.toString().trimmed():
-						if first:
-							QgsGeometry( inFeat.geometry() )
-							tmpInGeom = QgsGeometry( inFeat.geometry() )
-							outFeat.setGeometry( tmpInGeom )
-							first = False
-							attrs = inFeat.attributeMap()
-						else:
-							tmpInGeom = QgsGeometry( inFeat.geometry() )
-							tmpOutGeom = QgsGeometry( outFeat.geometry() )
-							try:
-								tmpOutGeom = QgsGeometry( tmpOutGeom.combine( tmpInGeom ) )
-								outFeat.setGeometry( tmpOutGeom )
-							except:
-								GEOS_EXCEPT = False
-								add = False
-				if add:
-					outFeat.setAttributeMap( attrs )
-					writer.addFeature( outFeat )
+					if first:
+						attrs = inFeat.attributeMap()
+						tmpInGeom = QgsGeometry( inFeat.geometry() )
+						outFeat.setGeometry( tmpInGeom )
+						first = False
+					else:
+						tmpInGeom = QgsGeometry( inFeat.geometry() )
+						tmpOutGeom = QgsGeometry( outFeat.geometry() )
+						try:
+							tmpOutGeom = QgsGeometry( tmpOutGeom.combine( tmpInGeom ) )
+							outFeat.setGeometry( tmpOutGeom )
+						except:
+							GEOS_EXCEPT = False
+							continue
+				outFeat.setAttributeMap( attrs )
+				writer.addFeature( outFeat )
+			else:
+				unique = vproviderA.uniqueValues( int( self.myParam ) )
+				nFeat = nFeat * len( unique )
+				self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0)
+				self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
+				for item in unique:
+					first = True
+					add = True
+					vproviderA.select( allAttrsA )
+					vproviderA.rewind()
+					while vproviderA.nextFeature( inFeat ):
+						nElement += 1
+						self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ),  nElement )
+						atMap = inFeat.attributeMap()
+						tempItem = atMap[ self.myParam ]
+						if tempItem.toString().trimmed() == item.toString().trimmed():
+							if first:
+								QgsGeometry( inFeat.geometry() )
+								tmpInGeom = QgsGeometry( inFeat.geometry() )
+								outFeat.setGeometry( tmpInGeom )
+								first = False
+								attrs = inFeat.attributeMap()
+							else:
+								tmpInGeom = QgsGeometry( inFeat.geometry() )
+								tmpOutGeom = QgsGeometry( outFeat.geometry() )
+								try:
+									tmpOutGeom = QgsGeometry( tmpOutGeom.combine( tmpInGeom ) )
+									outFeat.setGeometry( tmpOutGeom )
+								except:
+									GEOS_EXCEPT = False
+									add = False
+					if add:
+						outFeat.setAttributeMap( attrs )
+						writer.addFeature( outFeat )
 		del writer
 		return GEOS_EXCEPT, FEATURE_EXCEPT, True
-
+	
 	def difference( self ):
 		GEOS_EXCEPT = True
 		FEATURE_EXCEPT = True
@@ -470,40 +686,140 @@
 		inFeatB = QgsFeature()
 		outFeat = QgsFeature()
 		index = ftools_utils.createIndex( vproviderB )
-		nFeat = vproviderA.featureCount()
 		nElement = 0
-		self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0)
-		self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
-		vproviderA.rewind()
-		while vproviderA.nextFeature( inFeatA ):
-			nElement += 1
-			add  = True
-			self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ),  nElement )
-			geom = QgsGeometry( inFeatA.geometry() )
-			diff_geom = QgsGeometry( geom )
-			atMap = inFeatA.attributeMap()
-			intersects = index.intersects( geom.boundingBox() )
-			for id in intersects:
-				vproviderB.featureAtId( int( id ), inFeatB , True, allAttrsB )
-				tmpGeom = QgsGeometry( inFeatB.geometry() )
-				try:
-					if diff_geom.intersects( tmpGeom ):
-						diff_geom = QgsGeometry( diff_geom.difference( tmpGeom ) )
-				except:
-					GEOS_EXCEPT = False
-					add = False
-					break
-			if add:
-				try:
-					outFeat.setGeometry( diff_geom )
-					outFeat.setAttributeMap( atMap )
-					writer.addFeature( outFeat )
-				except:
-					FEATURE_EXCEPT = False
-					continue
+		# there is selection in input layer
+		if self.mySelectionA:
+			nFeat = self.vlayerA.selectedFeatureCount()
+			selectionA = self.vlayerA.selectedFeatures()
+			self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0)
+			self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
+			# we have selection in overlay layer
+			if self.mySelectionB:
+				selectionB = self.vlayerB.selectedFeaturesIds()
+				for inFeatA in selectionA:
+					nElement += 1
+					self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
+					add = True
+					geom = QgsGeometry( inFeatA.geometry() )
+					diff_geom = QgsGeometry( geom )
+					atMap = inFeatA.attributeMap()
+					intersects = index.intersects( geom.boundingBox() )
+					for id in intersects:
+						# is intersect feature in selection
+						if id in selectionB:
+							vproviderB.featureAtId( int( id ), inFeatB , True, allAttrsB )
+							tmpGeom = QgsGeometry( inFeatB.geometry() )
+							try:
+								if diff_geom.intersects( tmpGeom ):
+									diff_geom = QgsGeometry( diff_geom.difference( tmpGeom ) )
+							except:
+								GEOS_EXCEPT = False
+								add = False
+								break
+					if add:
+						try:
+							outFeat.setGeometry( diff_geom )
+							outFeat.setAttributeMap( atMap )
+							writer.addFeature( outFeat )
+						except:
+							FEATURE_EXCEPT = False
+							continue
+			# we have no selection in overlay layer
+			else:
+				for inFeatA in selectionA:
+					nElement += 1
+					self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
+					add = True
+					geom = QgsGeometry( inFeatA.geometry() )
+					diff_geom = QgsGeometry( geom )
+					atMap = inFeatA.attributeMap()
+					intersects = index.intersects( geom.boundingBox() )
+					for id in intersects:
+						vproviderB.featureAtId( int( id ), inFeatB , True, allAttrsB )
+						tmpGeom = QgsGeometry( inFeatB.geometry() )
+						try:
+							if diff_geom.intersects( tmpGeom ):
+								diff_geom = QgsGeometry( diff_geom.difference( tmpGeom ) )
+						except:
+							GEOS_EXCEPT = False
+							add = False
+							break
+					if add:
+						try:
+							outFeat.setGeometry( diff_geom )
+							outFeat.setAttributeMap( atMap )
+							writer.addFeature( outFeat )
+						except:
+							FEATURE_EXCEPT = False
+							continue
+		# there is no selection in input layer
+		else:
+			nFeat = vproviderA.featureCount()
+			self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
+			self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
+			vproviderA.rewind()
+			# we have selection in overlay layer
+			if self.mySelectionB:
+				selectionB = self.vlayerB.selectedFeaturesIds()
+				while vproviderA.nextFeature( inFeatA ):
+					nElement += 1
+					add = True
+					self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
+					geom = QgsGeometry( inFeatA.geometry() )
+					diff_geom = QgsGeometry( geom )
+					atMap = inFeatA.attributeMap()
+					intersects = index.intersects( geom.boundingBox() )
+					for id in intersects:
+						# now check if id in selection
+						if id in selectionB:
+							vproviderB.featureAtId( int( id ), inFeatB , True, allAttrsB )
+							tmpGeom = QgsGeometry( inFeatB.geometry() )
+							try:
+								if diff_geom.intersects( tmpGeom ):
+									diff_geom = QgsGeometry( diff_geom.difference( tmpGeom ) )
+							except:
+								GEOS_EXCEPT = False
+								add = False
+								break
+					if add:
+						try:
+							outFeat.setGeometry( diff_geom )
+							outFeat.setAttributeMap( atMap )
+							writer.addFeature( outFeat )
+						except:
+							FEATURE_EXCEPT = False
+							continue
+			# we have no selection in overlay layer
+			else:
+				while vproviderA.nextFeature( inFeatA ):
+					nElement += 1
+					add = True
+					self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
+					geom = QgsGeometry( inFeatA.geometry() )
+					diff_geom = QgsGeometry( geom )
+					atMap = inFeatA.attributeMap()
+					intersects = index.intersects( geom.boundingBox() )
+					for id in intersects:
+						vproviderB.featureAtId( int( id ), inFeatB , True, allAttrsB )
+						tmpGeom = QgsGeometry( inFeatB.geometry() )
+						try:
+							if diff_geom.intersects( tmpGeom ):
+								diff_geom = QgsGeometry( diff_geom.difference( tmpGeom ) )
+						except:
+							GEOS_EXCEPT = False
+							add = False
+							break
+					if add:
+						try:
+							outFeat.setGeometry( diff_geom )
+							outFeat.setAttributeMap( atMap )
+							writer.addFeature( outFeat )
+						except:
+							FEATURE_EXCEPT = False
+							continue
 		del writer
 		return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match
-
+	
 	def intersect( self ):
 		GEOS_EXCEPT = True
 		FEATURE_EXCEPT = True
@@ -522,41 +838,142 @@
 		inFeatB = QgsFeature()
 		outFeat = QgsFeature()
 		index = ftools_utils.createIndex( vproviderB )
-		nFeat = vproviderA.featureCount()
 		nElement = 0
-		self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0)
-		self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
-		vproviderA.rewind()
-		while vproviderA.nextFeature( inFeatA ):
-			nElement += 1
-			self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ),  nElement )
-			geom = QgsGeometry( inFeatA.geometry() )
-			atMapA = inFeatA.attributeMap()    
-			intersects = index.intersects( geom.boundingBox() )
-			for id in intersects: 
-				vproviderB.featureAtId( int( id ), inFeatB , True, allAttrsB )
-				tmpGeom = QgsGeometry( inFeatB.geometry() )
-				try:
-					if geom.intersects( tmpGeom ):
-						atMapB = inFeatB.attributeMap()
-						int_geom = QgsGeometry( geom.intersection( tmpGeom ) )
-						if int_geom.wkbType() == 7:
-							int_com = geom.combine( tmpGeom )
-							int_sym = geom.symDifference( tmpGeom )
-							int_geom = QgsGeometry( int_com.difference( int_sym ) )
+		# there is selection in input layer
+		if self.mySelectionA:
+			nFeat = self.vlayerA.selectedFeatureCount()
+			selectionA = self.vlayerA.selectedFeatures()
+			self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0)
+			self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
+			# we have selection in overlay layer
+			if self.mySelectionB:
+				selectionB = self.vlayerB.selectedFeaturesIds()
+				for inFeatA in selectionA:
+					nElement += 1
+					self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
+					geom = QgsGeometry( inFeatA.geometry() )
+					atMapA = inFeatA.attributeMap()
+					intersects = index.intersects( geom.boundingBox() )
+					for id in intersects:
+						if id in selectionB:
+							vproviderB.featureAtId( int( id ), inFeatB , True, allAttrsB )
+							tmpGeom = QgsGeometry( inFeatB.geometry() )
+							try:
+								if geom.intersects( tmpGeom ):
+									atMapB = inFeatB.attributeMap()
+									int_geom = QgsGeometry( geom.intersection( tmpGeom ) )
+									if int_geom.wkbType() == 7:
+										int_com = geom.combine( tmpGeom )
+										int_sym = geom.symDifference( tmpGeom )
+										int_geom = QgsGeometry( int_com.difference( int_sym ) )
+									try:
+										outFeat.setGeometry( int_geom )
+										outFeat.setAttributeMap( ftools_utils.combineVectorAttributes( atMapA, atMapB ) )
+										writer.addFeature( outFeat )
+									except:
+										FEATURE_EXCEPT = False
+										continue
+							except:
+								GEOS_EXCEPT = False
+								break
+			# we don't have selection in overlay layer
+			else:
+				for inFeatA in selectionA:
+					nElement += 1
+					self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
+					geom = QgsGeometry( inFeatA.geometry() )
+					atMapA = inFeatA.attributeMap()
+					intersects = index.intersects( geom.boundingBox() )
+					for id in intersects:
+						vproviderB.featureAtId( int( id ), inFeatB , True, allAttrsB )
+						tmpGeom = QgsGeometry( inFeatB.geometry() )
 						try:
-							outFeat.setGeometry( int_geom )
-							outFeat.setAttributeMap( ftools_utils.combineVectorAttributes( atMapA, atMapB ) )
-							writer.addFeature( outFeat )
+							if geom.intersects( tmpGeom ):
+								atMapB = inFeatB.attributeMap()
+								int_geom = QgsGeometry( geom.intersection( tmpGeom ) )
+								if int_geom.wkbType() == 7:
+									int_com = geom.combine( tmpGeom )
+									int_sym = geom.symDifference( tmpGeom )
+									int_geom = QgsGeometry( int_com.difference( int_sym ) )
+								try:
+									outFeat.setGeometry( int_geom )
+									outFeat.setAttributeMap( ftools_utils.combineVectorAttributes( atMapA, atMapB ) )
+									writer.addFeature( outFeat )
+								except:
+									EATURE_EXCEPT = False
+									continue
 						except:
-							FEATURE_EXCEPT = False
-							continue
-				except:
-					GEOS_EXCEPT = False
-					break
+							GEOS_EXCEPT = False
+							break
+		# there is no selection in input layer
+		else:
+			nFeat = vproviderA.featureCount()
+			self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0)
+			self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
+			vproviderA.rewind()
+			# we have selection in overlay layer
+			if self.mySelectionB:
+				selectionB = self.vlayerB.selectedFeaturesIds()
+				while vproviderA.nextFeature( inFeatA ):
+					nElement += 1
+					self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
+					geom = QgsGeometry( inFeatA.geometry() )
+					atMapA = inFeatA.attributeMap()
+					intersects = index.intersects( geom.boundingBox() )
+					for id in intersects:
+						if id in selectionB:
+							vproviderB.featureAtId( int( id ), inFeatB , True, allAttrsB )
+							tmpGeom = QgsGeometry( inFeatB.geometry() )
+							try:
+								if geom.intersects( tmpGeom ):
+									atMapB = inFeatB.attributeMap()
+									int_geom = QgsGeometry( geom.intersection( tmpGeom ) )
+									if int_geom.wkbType() == 7:
+										int_com = geom.combine( tmpGeom )
+										int_sym = geom.symDifference( tmpGeom )
+										int_geom = QgsGeometry( int_com.difference( int_sym ) )
+									try:
+										outFeat.setGeometry( int_geom )
+										outFeat.setAttributeMap( ftools_utils.combineVectorAttributes( atMapA, atMapB ) )
+										writer.addFeature( outFeat )
+									except:
+										FEATURE_EXCEPT = False
+										continue
+							except:
+								GEOS_EXCEPT = False
+								break
+			# we have no selection in overlay layer
+			else:
+				while vproviderA.nextFeature( inFeatA ):
+					nElement += 1
+					self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
+					geom = QgsGeometry( inFeatA.geometry() )
+					atMapA = inFeatA.attributeMap()
+					intersects = index.intersects( geom.boundingBox() )
+					for id in intersects: 
+						vproviderB.featureAtId( int( id ), inFeatB , True, allAttrsB )
+						tmpGeom = QgsGeometry( inFeatB.geometry() )
+						try:
+							if geom.intersects( tmpGeom ):
+								atMapB = inFeatB.attributeMap()
+								int_geom = QgsGeometry( geom.intersection( tmpGeom ) )
+								if int_geom.wkbType() == 7:
+									int_com = geom.combine( tmpGeom )
+									int_sym = geom.symDifference( tmpGeom )
+									int_geom = QgsGeometry( int_com.difference( int_sym ) )
+								try:
+									outFeat.setGeometry( int_geom )
+									outFeat.setAttributeMap( ftools_utils.combineVectorAttributes( atMapA, atMapB ) )
+									writer.addFeature( outFeat )
+								except:
+									FEATURE_EXCEPT = False
+									continue
+						except:
+							GEOS_EXCEPT = False
+							break
 		del writer
 		return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match
-		
+	
 	def union( self ):
 		GEOS_EXCEPT = True
 		FEATURE_EXCEPT = True
@@ -582,7 +999,7 @@
 		self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
 		vproviderA.rewind()
 		while vproviderA.nextFeature( inFeatA ):
-			self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ),  nElement )
+			self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
 			nElement += 1
 			found = False
 			geom = QgsGeometry( inFeatA.geometry() )
@@ -672,7 +1089,7 @@
 			nElement += 1
 		del writer
 		return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match
-
+	
 	def symetrical_difference( self ):
 		GEOS_EXCEPT = True
 		FEATURE_EXCEPT = True
@@ -699,7 +1116,7 @@
 		vproviderA.rewind()
 		while vproviderA.nextFeature( inFeatA ):
 			nElement += 1
-			self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ),  nElement )
+			self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
 			add = True
 			geom = QgsGeometry( inFeatA.geometry() )
 			diff_geom = QgsGeometry( geom )
@@ -727,7 +1144,7 @@
 		vproviderB.rewind()
 		while vproviderB.nextFeature( inFeatA ):
 			nElement += 1
-			self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ),  nElement )
+			self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
 			add = True
 			geom = QgsGeometry( inFeatA.geometry() )
 			diff_geom = QgsGeometry( geom )
@@ -754,7 +1171,7 @@
 					continue
 		del writer
 		return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match
-
+	
 	def clip( self ):
 		GEOS_EXCEPT = True
 		FEATURE_EXCEPT = True
@@ -773,37 +1190,136 @@
 		inFeatB = QgsFeature()
 		outFeat = QgsFeature()
 		index = ftools_utils.createIndex( vproviderB )
-		nFeat = vproviderA.featureCount()
+		vproviderA.rewind()
 		nElement = 0
-		self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
-		self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
-		vproviderA.rewind()
-		while vproviderA.nextFeature( inFeatA ):
-			nElement += 1
-			self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ),  nElement )
-			geom = QgsGeometry( inFeatA.geometry() )
-			atMap = inFeatA.attributeMap()    
-			intersects = index.intersects( geom.boundingBox() )
-			for id in intersects:
-				vproviderB.featureAtId( int( id ), inFeatB , True, allAttrsB )
-				tmpGeom = QgsGeometry( inFeatB.geometry() )
-				try:
-					if geom.intersects( tmpGeom ):  
-						int_geom = QgsGeometry( geom.intersection( tmpGeom ) )
-						if int_geom.wkbType() == 7:
-							int_com = geom.combine( tmpGeom )
-							int_sym = geom.symDifference( tmpGeom )
-							int_geom = QgsGeometry( int_com.difference( int_sym ) )
+		# there is selection in input layer
+		if self.mySelectionA:
+			nFeat = self.vlayerA.selectedFeatureCount()
+			selectionA = self.vlayerA.selectedFeatures()
+			self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0)
+			self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
+			# we have selection in overlay layer
+			if self.mySelectionB:
+				selectionB = self.vlayerB.selectedFeaturesIds()
+				for inFeatA in selectionA:
+					nElement += 1
+					self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
+					geom = QgsGeometry( inFeatA.geometry() )
+					atMap = inFeatA.attributeMap()
+					intersects = index.intersects( geom.boundingBox() )
+					for id in intersects:
+						if id in selectionB:
+							vproviderB.featureAtId( int( id ), inFeatB , True, allAttrsB )
+							tmpGeom = QgsGeometry( inFeatB.geometry() )
+							try:
+								if geom.intersects( tmpGeom ):
+									int_geom = QgsGeometry( geom.intersection( tmpGeom ) )
+									if int_geom.wkbType() == 7:
+										int_com = geom.combine( tmpGeom )
+										int_sym = geom.symDifference( tmpGeom )
+										int_geom = QgsGeometry( int_com.difference( int_sym ) )
+									try:
+										outFeat.setGeometry( int_geom )
+										outFeat.setAttributeMap( atMap )
+										writer.addFeature( outFeat )
+									except:
+										FEATURE_EXCEPT = False
+										continue
+							except:
+								GEOS_EXCEPT = False
+								break
+			# we have no selection in overlay layer
+			else:
+				for inFeatA in selectionA:
+					nElement += 1
+					self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
+					geom = QgsGeometry( inFeatA.geometry() )
+					atMap = inFeatA.attributeMap()
+					intersects = index.intersects( geom.boundingBox() )
+					for id in intersects:
+						vproviderB.featureAtId( int( id ), inFeatB , True, allAttrsB )
+						tmpGeom = QgsGeometry( inFeatB.geometry() )
 						try:
-							outFeat.setGeometry( int_geom )
-							outFeat.setAttributeMap( atMap )
-							writer.addFeature( outFeat )
+							if geom.intersects( tmpGeom ):
+								int_geom = QgsGeometry( geom.intersection( tmpGeom ) )
+								if int_geom.wkbType() == 7:
+									int_com = geom.combine( tmpGeom )
+									int_sym = geom.symDifference( tmpGeom )
+									int_geom = QgsGeometry( int_com.difference( int_sym ) )
+								try:
+									outFeat.setGeometry( int_geom )
+									outFeat.setAttributeMap( atMap )
+									writer.addFeature( outFeat )
+								except:
+									FEATURE_EXCEPT = False
+									continue
 						except:
-							FEATURE_EXCEPT = False
-							continue
-				except:
-					GEOS_EXCEPT = False
-					break
+							GEOS_EXCEPT = False
+							break
+			
+		# there is no selection in input layer
+		else:
+			nFeat = vproviderA.featureCount()
+			self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0)
+			self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
+			# we have selection in overlay layer
+			if self.mySelectionB:
+				selectionB = self.vlayerB.selectedFeaturesIds()
+				while vproviderA.nextFeature( inFeatA ):
+					nElement += 1
+					self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
+					geom = QgsGeometry( inFeatA.geometry() )
+					atMap = inFeatA.attributeMap()
+					intersects = index.intersects( geom.boundingBox() )
+					for id in intersects:
+						if id in selectionB:
+							vproviderB.featureAtId( int( id ), inFeatB , True, allAttrsB )
+							tmpGeom = QgsGeometry( inFeatB.geometry() )
+							try:
+								if geom.intersects( tmpGeom ):
+									int_geom = QgsGeometry( geom.intersection( tmpGeom ) )
+									if int_geom.wkbType() == 7:
+										int_com = geom.combine( tmpGeom )
+										int_sym = geom.symDifference( tmpGeom )
+										int_geom = QgsGeometry( int_com.difference( int_sym ) )
+									try:
+										outFeat.setGeometry( int_geom )
+										outFeat.setAttributeMap( atMap )
+										writer.addFeature( outFeat )
+									except:
+										FEATURE_EXCEPT = False
+										continue
+							except:
+								GEOS_EXCEPT = False
+								break
+			# we have no selection in overlay layer
+			else:
+				while vproviderA.nextFeature( inFeatA ):
+					nElement += 1
+					self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
+					geom = QgsGeometry( inFeatA.geometry() )
+					atMap = inFeatA.attributeMap()
+					intersects = index.intersects( geom.boundingBox() )
+					for id in intersects:
+						vproviderB.featureAtId( int( id ), inFeatB , True, allAttrsB )
+						tmpGeom = QgsGeometry( inFeatB.geometry() )
+						try:
+							if geom.intersects( tmpGeom ):
+								int_geom = QgsGeometry( geom.intersection( tmpGeom ) )
+								if int_geom.wkbType() == 7:
+									int_com = geom.combine( tmpGeom )
+									int_sym = geom.symDifference( tmpGeom )
+									int_geom = QgsGeometry( int_com.difference( int_sym ) )
+								try:
+									outFeat.setGeometry( int_geom )
+									outFeat.setAttributeMap( atMap )
+									writer.addFeature( outFeat )
+								except:
+									FEATURE_EXCEPT = False
+									continue
+						except:
+							GEOS_EXCEPT = False
+							break
 		del writer
 		return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match
 
@@ -850,7 +1366,7 @@
 			attr2 = pt.y()
 		else:
 			measure = QgsDistanceArea()
-			attr1 = measure.measure(inGeom)      
+			attr1 = measure.measure(inGeom)
 			if inGeom.type() == QGis.Polygon:
 				attr2 = self.perimMeasure( inGeom, measure )
 			else:

Modified: trunk/qgis/python/plugins/fTools/tools/doVisual.py
===================================================================
--- trunk/qgis/python/plugins/fTools/tools/doVisual.py	2009-05-25 21:05:34 UTC (rev 10848)
+++ trunk/qgis/python/plugins/fTools/tools/doVisual.py	2009-05-26 18:07:37 UTC (rev 10849)
@@ -38,31 +38,42 @@
     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 @@
       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 @@
 #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 @@
     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 @@
     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()

Modified: trunk/qgis/python/plugins/fTools/tools/frmGeoprocessing.py
===================================================================
--- trunk/qgis/python/plugins/fTools/tools/frmGeoprocessing.py	2009-05-25 21:05:34 UTC (rev 10848)
+++ trunk/qgis/python/plugins/fTools/tools/frmGeoprocessing.py	2009-05-26 18:07:37 UTC (rev 10849)
@@ -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 @@
 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 @@
         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 @@
         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))
 

Modified: trunk/qgis/python/plugins/fTools/tools/frmGeoprocessing.ui
===================================================================
--- trunk/qgis/python/plugins/fTools/tools/frmGeoprocessing.ui	2009-05-25 21:05:34 UTC (rev 10848)
+++ trunk/qgis/python/plugins/fTools/tools/frmGeoprocessing.ui	2009-05-26 18:07:37 UTC (rev 10849)
@@ -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/>

Modified: trunk/qgis/python/plugins/fTools/tools/frmVisual.py
===================================================================
--- trunk/qgis/python/plugins/fTools/tools/frmVisual.py	2009-05-25 21:05:34 UTC (rev 10848)
+++ trunk/qgis/python/plugins/fTools/tools/frmVisual.py	2009-05-26 18:07:37 UTC (rev 10849)
@@ -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 @@
     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 @@
         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 @@
         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 @@
         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 @@
         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))
 

Modified: trunk/qgis/python/plugins/fTools/tools/frmVisual.ui
===================================================================
--- trunk/qgis/python/plugins/fTools/tools/frmVisual.ui	2009-05-25 21:05:34 UTC (rev 10848)
+++ trunk/qgis/python/plugins/fTools/tools/frmVisual.ui	2009-05-26 18:07:37 UTC (rev 10849)
@@ -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>

Modified: trunk/qgis/python/plugins/fTools/tools/ftools_utils.py
===================================================================
--- trunk/qgis/python/plugins/fTools/tools/ftools_utils.py	2009-05-25 21:05:34 UTC (rev 10848)
+++ trunk/qgis/python/plugins/fTools/tools/ftools_utils.py	2009-05-26 18:07:37 UTC (rev 10849)
@@ -19,6 +19,7 @@
 # addShapeToCanvas( QString *file path )
 # getUniqueValues( QgsVectorDataProvider, int *field id )
 # saveDialog( QWidget *parent )
+# getFieldType( QgsVectorLayer, QgsField.name() )
 #
 # -------------------------------------------------
 
@@ -260,3 +261,9 @@
 	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()



More information about the QGIS-commit mailing list