[QGIS Commit] r12408 - trunk/qgis/python/plugins/fTools/tools
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Fri Dec 11 10:46:21 EST 2009
Author: jef
Date: 2009-12-11 10:46:21 -0500 (Fri, 11 Dec 2009)
New Revision: 12408
Modified:
trunk/qgis/python/plugins/fTools/tools/doVisual.py
trunk/qgis/python/plugins/fTools/tools/frmVisual.ui
Log:
speed up geometry validation in fTools (self-intersection detection; fixes #2262)
Modified: trunk/qgis/python/plugins/fTools/tools/doVisual.py
===================================================================
--- trunk/qgis/python/plugins/fTools/tools/doVisual.py 2009-12-11 15:44:48 UTC (rev 12407)
+++ trunk/qgis/python/plugins/fTools/tools/doVisual.py 2009-12-11 15:46:21 UTC (rev 12408)
@@ -16,6 +16,8 @@
self.manageGui()
self.cancel_close = self.buttonBox_2.button( QDialogButtonBox.Close )
self.progressBar.setValue( 0 )
+ self.partProgressBar.setValue( 0 )
+ self.partProgressBar.setEnabled( False )
def keyPressEvent( self, e ):
'''
@@ -111,6 +113,8 @@
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 )
+ QObject.connect( self.testThread, SIGNAL( "runPartRange(PyQt_PyObject)" ), self.runPartRangeFromThread )
+ QObject.connect( self.testThread, SIGNAL( "runPartStatus(PyQt_PyObject)" ), self.runPartStatusFromThread )
self.cancel_close.setText( "Cancel" )
QObject.connect( self.cancel_close, SIGNAL( "clicked()" ), self.cancelThread )
self.testThread.start()
@@ -154,6 +158,16 @@
def runRangeFromThread( self, range_vals ):
self.progressBar.setRange( range_vals[ 0 ], range_vals[ 1 ] )
+
+ def runPartStatusFromThread( self, status ):
+ self.partProgressBar.setValue( status )
+ if status >= self.part_max:
+ self.partProgressBar.setEnabled( False )
+
+ def runPartRangeFromThread( self, range_vals ):
+ self.part_max = range_vals[ 1 ]
+ self.partProgressBar.setEnabled( True )
+ self.partProgressBar.setRange( range_vals[ 0 ], range_vals[ 1 ] )
class visualThread( QThread ):
def __init__( self, parentThread, parentObject, function, vlayer, myField, mySelection ):
@@ -431,6 +445,7 @@
if not self.isCorrectOrientation( geom ):
lstErrors.append( self.tr( "Feature %1 has incorrect node ordering" ).arg( unicode( feat.id() ) ) )
count += 1
+ self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nFeat )
return ( lstErrors, count )
def isHoleNested( self, polygon ):
@@ -459,16 +474,29 @@
return True
def isSelfIntersecting( self, polygon ):
+ cPart = 0
for h in polygon:
- count = 0
- size = range( 0, len (h )- 1 )
- for i in size:
+ cPart += len(h)
+
+ self.emit( SIGNAL( "runPartRange(PyQt_PyObject)" ), ( 0, cPart ) )
+
+ nPart = 0
+ for h in polygon:
+ for i in range( 0, len(h)-1 ):
+ self.emit( SIGNAL( "runPartStatus(PyQt_PyObject)" ), nPart )
+
count = 0
- for j in size:
+ for j in range( i+1, len(h)-1 ):
if QgsGeometry().fromPolyline( [ h[ i ], h[ i + 1 ] ] ).intersects( QgsGeometry().fromPolyline( [ h[ j ], h[ j + 1 ] ] ) ):
count += 1
- if count > 3:
+ if count > 2:
+ self.emit( SIGNAL( "runPartStatus(PyQt_PyObject)" ), cPart )
return True
+
+ nPart += 1
+
+ self.emit( SIGNAL( "runPartStatus(PyQt_PyObject)" ), cPart )
+
return False
def isCorrectOrientation( self, polygon ):
Modified: trunk/qgis/python/plugins/fTools/tools/frmVisual.ui
===================================================================
--- trunk/qgis/python/plugins/fTools/tools/frmVisual.ui 2009-12-11 15:44:48 UTC (rev 12407)
+++ trunk/qgis/python/plugins/fTools/tools/frmVisual.ui 2009-12-11 15:46:21 UTC (rev 12408)
@@ -114,7 +114,28 @@
</item>
</layout>
</item>
- <item row="7" column="0">
+ <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>
+ <item row="8" column="1" rowspan="2">
+ <widget class="QDialogButtonBox" name="buttonBox_2">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Close|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ <item row="9" column="0">
<widget class="QProgressBar" name="progressBar">
<property name="value">
<number>24</number>
@@ -124,27 +145,19 @@
</property>
</widget>
</item>
- <item row="7" column="1">
- <widget class="QDialogButtonBox" name="buttonBox_2">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
+ <item row="8" column="0">
+ <widget class="QProgressBar" name="partProgressBar">
+ <property name="enabled">
+ <bool>false</bool>
</property>
- <property name="standardButtons">
- <set>QDialogButtonBox::Close|QDialogButtonBox::Ok</set>
+ <property name="value">
+ <number>24</number>
</property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</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/>
More information about the QGIS-commit
mailing list