Showing with 8 additions and 5 deletions.
  1. +2 −2 python/plugins/fTools/tools/doRandPoints.py
  2. +2 −2 python/plugins/fTools/tools/doRegPoints.py
  3. +4 −1 src/app/legend/qgslegend.cpp
4 changes: 2 additions & 2 deletions python/plugins/fTools/tools/doRandPoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,11 @@ def createSinglePolygon(self, vlayer):
provider = vlayer.dataProvider()
feat = QgsFeature()
geom = QgsGeometry()
#geom2 = QgsGeometry()
fit = provider.getFeatures()
fit.nextFeature(feat)
geom = QgsGeometry(feat.geometry())
count = 10.00
add = ( 40.00 - 10.00 ) / provider.featureCount()
#geom = QgsGeometry(feat.geometry())
while fit.nextFeature(feat):
geom = geom.combine(QgsGeometry( feat.geometry() ))
count = count + add
Expand Down Expand Up @@ -202,6 +200,7 @@ def vectorRandom(self, n, layer, xmin, xmax, ymin, ymax):

def randomize(self, inLayer, outPath, minimum, design, value):
outFeat = QgsFeature()
outFeat.initAttributes(1)
if design == self.tr("unstratified"):
ext = inLayer.extent()
if inLayer.type() == inLayer.RasterLayer:
Expand All @@ -215,6 +214,7 @@ def randomize(self, inLayer, outPath, minimum, design, value):
if not crs.isValid(): crs = None
fields = QgsFields()
fields.append( QgsField("ID", QVariant.Int) )
outFeat.setFields(fields)
check = QFile(self.shapefileName)
if check.exists():
if not QgsVectorFileWriter.deleteShapeFile(self.shapefileName):
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/fTools/tools/doRegPoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,15 @@ def regularize(self, bound, outPath, offset, value, gridType, inset, crs):
# Calculate grid spacing
pointSpacing = sqrt(area / value)
outFeat = QgsFeature()
outFeat.initAttributes(1)
fields = QgsFields()
fields.append( QgsField("ID", QVariant.Int) )
outFeat.setFields( fields )
check = QFile(self.shapefileName)
if check.exists():
if not QgsVectorFileWriter.deleteShapeFile(self.shapefileName):
return
writer = QgsVectorFileWriter(self.shapefileName, self.encoding, fields, QGis.WKBPoint, crs)
#writer = QgsVectorFileWriter(unicode(outPath), "CP1250", fields, QGis.WKBPoint, None)
idVar = 0
count = 10.00
add = 90.00 / (area / pointSpacing)
Expand All @@ -156,4 +157,3 @@ def regularize(self, bound, outPath, offset, value, gridType, inset, crs):
self.progressBar.setValue(count)
y = y - pointSpacing
del writer

5 changes: 4 additions & 1 deletion src/app/legend/qgslegend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2775,7 +2775,10 @@ void QgsLegend::legendLayerStretchUsingCurrentExtent()
layer->setContrastEnhancementAlgorithm( "StretchToMinimumMaximum" );
}

layer->setMinimumMaximumUsingLastExtent();
QgsRectangle myRectangle;
myRectangle = mMapCanvas->mapRenderer()->outputExtentToLayerExtent( layer, mMapCanvas->extent() );
layer->setContrastEnhancementAlgorithm( layer->contrastEnhancementAlgorithm(), QgsRasterLayer::ContrastEnhancementMinMax, myRectangle );

layer->setCacheImage( NULL );
refreshLayerSymbology( layer->id() );
mMapCanvas->refresh();
Expand Down