18 |
18 |
self.progressBar.setValue( 0 )
|
19 |
19 |
self.partProgressBar.setValue( 0 )
|
20 |
20 |
self.partProgressBar.setEnabled( False )
|
21 |
|
|
|
21 |
|
22 |
22 |
def keyPressEvent( self, e ):
|
23 |
23 |
'''
|
24 |
24 |
Reimplemented key press event:
|
... | ... | |
53 |
53 |
# add all fields in combobox because now we can work with text fields too
|
54 |
54 |
for i in changedField:
|
55 |
55 |
self.cmbField.addItem( unicode( changedField[i].name() ) )
|
56 |
|
|
|
56 |
|
57 |
57 |
def accept( self ):
|
58 |
58 |
if self.inShape.currentText() == "":
|
59 |
59 |
QMessageBox.information( self, self.tr("Error!"), self.tr( "Please specify input vector layer" ) )
|
60 |
60 |
elif self.cmbField.isVisible() and self.cmbField.currentText() == "":
|
61 |
61 |
QMessageBox.information( self, self.tr("Error!"), self.tr( "Please specify input field" ) )
|
|
62 |
elif self.useSelected.isChecked() and len( ftools_utils.getVectorLayerByName( self.inShape.currentText() ).selectedFeatures() ) == 0:
|
|
63 |
QMessageBox.warning( self, self.tr("Geoprocessing"), self.tr( "No features selected, please uncheck 'Use selected' or make a selection" ) )
|
62 |
64 |
else:
|
63 |
65 |
self.visual( self.inShape.currentText(), self.cmbField.currentText(), self.useSelected.checkState() )
|
64 |
|
|
|
66 |
|
65 |
67 |
def manageGui( self ):
|
66 |
68 |
if self.myFunction == 1: # Check geometry validity
|
67 |
69 |
self.setWindowTitle( self.tr( "Check geometry validity" ) )
|
... | ... | |
96 |
98 |
elif self.myFunction == 4:
|
97 |
99 |
myList = ftools_utils.getLayerNames( [ QGis.Point ] )
|
98 |
100 |
else:
|
99 |
|
myList = ftools_utils.getLayerNames( [ QGis.Point, QGis.Line, QGis.Polygon ] )
|
|
101 |
myList = ftools_utils.getLayerNames( [ QGis.Point, QGis.Line, QGis.Polygon ] )
|
100 |
102 |
self.inShape.addItems( myList )
|
101 |
103 |
return
|
102 |
104 |
|
... | ... | |
122 |
124 |
|
123 |
125 |
def cancelThread( self ):
|
124 |
126 |
self.testThread.stop()
|
125 |
|
|
|
127 |
|
126 |
128 |
def runFinishedFromThread( self, output ):
|
127 |
129 |
self.testThread.stop()
|
128 |
|
|
|
130 |
|
129 |
131 |
result = output[ 0 ]
|
130 |
132 |
numRows = len( result )
|
131 |
133 |
self.tblUnique.setRowCount( numRows )
|
... | ... | |
147 |
149 |
self.tblUnique.horizontalHeader().show()
|
148 |
150 |
self.tblUnique.horizontalHeader().setResizeMode( 0, QHeaderView.Stretch )
|
149 |
151 |
self.tblUnique.resizeRowsToContents()
|
150 |
|
|
|
152 |
|
151 |
153 |
self.lstCount.insert( unicode( output[ 1 ] ) )
|
152 |
154 |
self.cancel_close.setText( "Close" )
|
153 |
155 |
QObject.disconnect( self.cancel_close, SIGNAL( "clicked()" ), self.cancelThread )
|
154 |
156 |
return True
|
155 |
|
|
|
157 |
|
156 |
158 |
def runStatusFromThread( self, status ):
|
157 |
159 |
self.progressBar.setValue( status )
|
158 |
|
|
|
160 |
|
159 |
161 |
def runRangeFromThread( self, range_vals ):
|
160 |
162 |
self.progressBar.setRange( range_vals[ 0 ], range_vals[ 1 ] )
|
161 |
163 |
|
... | ... | |
163 |
165 |
self.partProgressBar.setValue( status )
|
164 |
166 |
if status >= self.part_max:
|
165 |
167 |
self.partProgressBar.setEnabled( False )
|
166 |
|
|
|
168 |
|
167 |
169 |
def runPartRangeFromThread( self, range_vals ):
|
168 |
170 |
self.part_max = range_vals[ 1 ]
|
169 |
171 |
self.partProgressBar.setEnabled( True )
|
170 |
172 |
self.partProgressBar.setRange( range_vals[ 0 ], range_vals[ 1 ] )
|
171 |
|
|
|
173 |
|
172 |
174 |
class visualThread( QThread ):
|
173 |
175 |
def __init__( self, parentThread, parentObject, function, vlayer, myField, mySelection ):
|
174 |
176 |
QThread.__init__( self, parentThread )
|
... | ... | |
195 |
197 |
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
|
196 |
198 |
|
197 |
199 |
def stop(self):
|
198 |
|
self.running = False
|
|
200 |
self.running = False
|
199 |
201 |
|
200 |
202 |
def list_unique_values( self, vlayer, myField ):
|
201 |
203 |
vprovider = vlayer.dataProvider()
|
... | ... | |
297 |
299 |
if self.mySelection: # only selected features
|
298 |
300 |
selection = vlayer.selectedFeatures()
|
299 |
301 |
nFeat = vlayer.selectedFeatureCount()
|
300 |
|
uniqueVal = ftools_utils.getUniqueValuesCount( vlayer, index, True )
|
|
302 |
uniqueVal = ftools_utils.getUniqueValuesCount( vlayer, index, True )
|
301 |
303 |
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
|
302 |
304 |
self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
|
303 |
305 |
for f in selection:
|
... | ... | |
316 |
318 |
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
|
317 |
319 |
else: # there is no selection, process the whole layer
|
318 |
320 |
nFeat = vprovider.featureCount()
|
319 |
|
uniqueVal = ftools_utils.getUniqueValuesCount( vlayer, index, False )
|
|
321 |
uniqueVal = ftools_utils.getUniqueValuesCount( vlayer, index, False )
|
320 |
322 |
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
|
321 |
323 |
self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
|
322 |
324 |
while vprovider.nextFeature( feat ):
|
... | ... | |
430 |
432 |
if not self.isCorrectOrientation( polygon ):
|
431 |
433 |
lstErrors.append( self.tr( "Feature %1 has incorrect node ordering" ).arg( unicode( feat.id() ) ) )
|
432 |
434 |
count += 1
|
433 |
|
|
|
435 |
|
434 |
436 |
else:
|
435 |
437 |
geom = geom.asPolygon()
|
436 |
438 |
if not self.isHoleNested( geom ):
|