Skip to content
Permalink
Browse files

Merge branch 'master' into delimited_text_bug_fixes

  • Loading branch information
ccrook committed Apr 17, 2013
2 parents cd24f54 + e0732a0 commit 2873d6a7ce484a8dab61a6c2a65710ac4fff78b1
@@ -82,7 +82,6 @@
<file>themes/default/console/imgHelpConsole.png</file>
<file>themes/default/console/imgHelpDialog.png</file>
<file>themes/default/console/imgHelpMenu.png</file>
<file>themes/default/console/iconHideToolConsole.png</file>
<file>themes/default/console/iconTabEditorConsole.png</file>
<file>themes/default/console/iconNewTabEditorConsole.png</file>
<file>themes/default/console/iconCloseTabEditorConsole.png</file>
@@ -391,8 +391,7 @@ def __init__(self, parent=None):
self.mainLayout.setMargin(0)
self.mainLayout.setSpacing(0)
self.mainLayout.addWidget(self.widgetButton, 0, 0, 1, 1)
self.mainLayout.addWidget(self.widgetButtonEditor, 0, 1, 1, 1)
self.mainLayout.addWidget(self.splitterEditor, 0, 2, 1, 1)
self.mainLayout.addWidget(self.splitterEditor, 0, 1, 1, 1)

self.layoutEditor = QGridLayout(self.widgetEditor)
self.layoutEditor.setMargin(0)
@@ -655,14 +655,17 @@ def delaunay_triangulation( self ):
indicies = list( triangle )
indicies.append( indicies[ 0 ] )
polygon = []
attrs = []
step = 0
for index in indicies:
vprovider.getFeatures( QgsFeatureRequest().setFilterFid( ptDict[ ids[ index ] ] ) ).nextFeature( inFeat )
geom = QgsGeometry( inFeat.geometry() )
point = QgsPoint( geom.asPoint() )
polygon.append( point )
if step <= 3: feat.setAttribute( step, QVariant( ids[ index ] ) )
if step <= 3:
attrs.append(QVariant( ids[ index ] ) )
step += 1
feat.setAttributes(attrs)
geometry = QgsGeometry().fromPolygon( [ polygon ] )
feat.setGeometry( geometry )
writer.addFeature( feat )
@@ -169,7 +169,7 @@ def run(self):
fieldList = ftools_utils.getFieldList(self.layerPoly)
index = polyProvider.fieldNameIndex(unicode(self.fieldName))
if index == -1:
index = polyProvider.fieldCount()
index = polyProvider.fields().count()
fieldList.append( QgsField(unicode(self.fieldName), QVariant.Double, "real", 24, 15, self.tr("point count field")) )

sRs = polyProvider.crs()
@@ -218,7 +218,8 @@ def run(self):
interrupted = True
break

outFeat.setAttribute(index, QVariant(count))
atMap.append(QVariant(count))
outFeat.setAttributes(atMap)
writer.addFeature(outFeat)

self.emit( SIGNAL( "updateProgress()" ) )
@@ -906,15 +906,12 @@ def processAlgorithm(self, progress):
i += 1
spokex = spokepoint.geometry().boundingBox().center().x()
spokey = spokepoint.geometry().boundingBox().center().y()
spokeid = unicode(spokepoint.attributeMap()[spokeindex].toString())
spokeid = unicode(spokepoint.attributes()[spokeindex].toString())
progress.setPercentage(float(i) / len(spokepoints) * 100)
# Scan hub points to find first matching hub
hubpoint = QgsFeature()
hublayer.dataProvider().select(hublayer.dataProvider().attributeIndexes())
hublayer.dataProvider().rewind()
# Scan hub points to find first matching hub
hubpoints = QGisLayers.features(hublayer)
for hubpoint in hubpoints:
hubid = unicode(hubpoint.attributeMap()[hubindex].toString())
hubid = unicode(hubpoint.attributes()[hubindex].toString())
if hubid == spokeid:
hubx = hubpoint.geometry().boundingBox().center().x()
huby = hubpoint.geometry().boundingBox().center().y()
@@ -49,12 +49,18 @@ def exportVectorLayer(layer):
It also export to a new file if the original one contains non-ascii characters'''
settings = QSettings()
systemEncoding = settings.value( "/UI/encoding", "System" ).toString()

filename = os.path.basename(unicode(layer.source()))
idx = filename.rfind(".")
if idx != -1:
filename = filename[:idx]
output = SextanteUtils.getTempFilenameInTempFolder(filename + ".shp")
#output = SextanteUtils.getTempFilename("shp")

filename = str(layer.name())
validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:"
filename = ''.join(c for c in filename if c in validChars)
if len(filename) == 0:
filename = "layer"
output = SextanteUtils.getTempFilenameInTempFolder(filename + ".shp")
provider = layer.dataProvider()
useSelection = SextanteConfig.getSetting(SextanteConfig.USE_SELECTED)
if useSelection and layer.selectedFeatureCount() != 0:
@@ -213,36 +213,27 @@ def accept(self):
return
msg = self.alg.checkParameterValuesBeforeExecuting()
if msg:
#===============================================================
# if keepOpen or useThread:
# self.setInfo("Unable to execute algorithm: %s" % msg, True)
# self.tabWidget.setCurrentIndex(1) # log tab
# else:
#===============================================================
QMessageBox.critical(self, "Unable to execute algorithm", msg)
return
self.buttonBox.button(QtGui.QDialogButtonBox.Ok).setEnabled(False)
self.buttonBox.button(QtGui.QDialogButtonBox.Close).setEnabled(False)
buttons = self.paramTable.iterateButtons
iterateParam = None
self.iterateParam = None

for i in range(len(buttons.values())):
button = buttons.values()[i]
if button.isChecked():
iterateParam = buttons.keys()[i]
self.iterateParam = buttons.keys()[i]
break

self.progress.setMaximum(0)
self.progressLabel.setText("Processing algorithm...")
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
if useThread:
if iterateParam:
self.algEx = AlgorithmExecutor(self.alg, iterateParam)
else:
command = self.alg.getAsCommand()
if command:
SextanteLog.addToLog(SextanteLog.LOG_ALGORITHM, command)
self.algEx = AlgorithmExecutor(self.alg)
if useThread and not self.iterateParam: #iterative execution on separate thread is still not working fine...
command = self.alg.getAsCommand()
if command:
SextanteLog.addToLog(SextanteLog.LOG_ALGORITHM, command)
self.algEx = AlgorithmExecutor(self.alg)
self.algEx.algExecuted.connect(self.finish)
self.algEx.error.connect(self.error)
self.algEx.percentageChanged.connect(self.setPercentage)
@@ -258,8 +249,8 @@ def accept(self):
self.buttonBox.button(QtGui.QDialogButtonBox.Cancel).setEnabled(True)
else:
self.setInfo("<b>Algorithm %s starting...</b>" % self.alg.name)
if iterateParam:
if UnthreadedAlgorithmExecutor.runalgIterating(self.alg, iterateParam, self):
if self.iterateParam:
if UnthreadedAlgorithmExecutor.runalgIterating(self.alg, self.iterateParam, self):
self.finish()
else:
QApplication.restoreOverrideCursor()
@@ -294,7 +285,8 @@ def accept(self):
@pyqtSlot()
def finish(self):
keepOpen = SextanteConfig.getSetting(SextanteConfig.KEEP_DIALOG_OPEN)
SextantePostprocessing.handleAlgorithmResults(self.alg, self, not keepOpen)
if self.iterateParam is None:
SextantePostprocessing.handleAlgorithmResults(self.alg, self, not keepOpen)
self.executed = True
self.setInfo("Algorithm %s finished" % self.alg.name)
QApplication.restoreOverrideCursor()
@@ -306,8 +298,7 @@ def finish(self):
self.setInfo("HTML output has been generated by this algorithm.\nOpen the SEXTANTE results dialog to check it.")

@pyqtSlot(str)
def error(self, msg):
#self.algEx.finished.disconnect()
def error(self, msg):
QApplication.restoreOverrideCursor()
keepOpen = SextanteConfig.getSetting(SextanteConfig.KEEP_DIALOG_OPEN)
self.setInfo(msg, True)
@@ -316,7 +307,7 @@ def error(self, msg):
self.close()
else:
self.resetGUI()
self.setInfo(msg, True)
#self.setInfo(msg, True)
self.tabWidget.setCurrentIndex(1) # log tab

@pyqtSlot(int)
@@ -29,6 +29,9 @@
from sextante.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
from sextante.core.QGisLayers import QGisLayers
from sextante.core.SextanteUtils import SextanteUtils
from sextante.tools.vector import getfeatures
from sextante.gui.SextantePostprocessing import SextantePostprocessing
import sextante
import sys

class AlgorithmExecutor(QThread):
@@ -74,11 +77,9 @@ def setConsoleInfo(self, info):
layerfile = alg.getParameterValue(self.parameterToIterate)
layer = QGisLayers.getObjectFromUri(layerfile, False)
provider = layer.dataProvider()
allAttrs = provider.attributeIndexes()
provider.select( allAttrs )
feat = QgsFeature()
features = getfeatures(layer)
self.filelist = []
while provider.nextFeature(feat):
for feat in features:
output = SextanteUtils.getTempFilename("shp")
self.filelist.append(output)
writer = QgsVectorFileWriter(output, systemEncoding,provider.fields(), provider.geometryType(), layer.crs() )
@@ -94,7 +95,8 @@ def raiseInternalError(self, error):
def runalg(self):
try:
self.algorithm.execute(self.progress)
self.algExecuted.emit()
if not self.parameterToIterate:
self.algExecuted.emit()
except GeoAlgorithmExecutionException, e :
self.error.emit(e.msg)
except BaseException, e:
@@ -123,8 +125,10 @@ def runalgIterating(self):
self.progress.setText("Executing iteration " + str(i) + "/" + str(len(self.filelist)) + "...")
self.progress.setPercentage((i * 100) / len(self.filelist))
self.runalg()
SextantePostprocessing.handleAlgorithmResults(self.algorithm, self.progress, False)
self.iterated.emit(i)
i += 1
self.algExecuted.emit()
except BaseException, e:
self.error.emit(str(e))
print "Error iterating " + str(e)
@@ -279,7 +279,7 @@ def fillTreeUsingCategories(self):
if (text != ""):
self.algorithmTree.expandAll()

def fillTreeUsingProviders(self):
def fillTreeUsingProviders(self):
self.algorithmTree.clear()
text = unicode(self.searchBox.text())
for providerName in Sextante.algs.keys():
@@ -16,6 +16,7 @@
* *
***************************************************************************
"""
from sextante.tools.vector import getfeatures

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
@@ -55,17 +56,16 @@ def runalgIterating(alg,paramToIter,progress):
settings = QSettings()
systemEncoding = settings.value( "/UI/encoding", "System" ).toString()
layerfile = alg.getParameterValue(paramToIter)
layer = QGisLayers.getObjectFromUri(layerfile, False)
provider = layer.dataProvider()
allAttrs = provider.attributeIndexes()
provider.select( allAttrs )
layer = QGisLayers.getObjectFromUri(layerfile, False)
feat = QgsFeature()
filelist = []
outputs = {}
while provider.nextFeature(feat):
provider = layer.dataProvider()
features = getfeatures(layer)
for feat in features:
output = SextanteUtils.getTempFilename("shp")
filelist.append(output)
writer = QgsVectorFileWriter(output, systemEncoding,provider.fields(), provider.geometryType(), layer.crs() )
writer = QgsVectorFileWriter(output, systemEncoding, provider.fields(), provider.geometryType(), layer.crs() )
writer.addFeature(feat)
del writer

@@ -187,7 +187,7 @@ def setupUi(self):
self.defaultTextBox = QtGui.QLineEdit()
self.defaultTextBox.setText("0")
if self.param is not None:
self.defaultTextBox.setText(self.param.default)
self.defaultTextBox.setText(str(self.param.default))
self.horizontalLayout3.addWidget(self.defaultTextBox)
self.verticalLayout.addLayout(self.horizontalLayout3)
elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_STRING \
@@ -206,16 +206,17 @@ def setupUi(self):
self.fileFolderCombo.addItem("Folder")
self.horizontalLayout2.addWidget(self.fileFolderCombo)
if self.param is not None:
self.fileFolderCombo.setCurrentIndex(1 if self.param.isFolder else 0)
self.fileFolderCombo.setCurrentIndex(1 if self.param.isFolder else 0)

self.buttonBox = QtGui.QDialogButtonBox(self)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
self.buttonBox.setObjectName("buttonBox")
QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), self.okPressed)
QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), self.cancelPressed)

self.verticalLayout.addWidget(self.buttonBox)

self.setLayout(self.verticalLayout)


@@ -55,7 +55,7 @@ def setValue(self, field):

def serialize(self):
return self.__module__.split(".")[-1] + "|" + self.name + "|" + self.description +\
"|" + str(self.parent) + "|" + str(self.datatype)
"|" + str(self.parent) + "|" + str(self.datatype) + "|" + str(self.optional)

def deserialize(self, s):
tokens = s.split("|")
@@ -58,7 +58,7 @@ def setValue(self, obj):
self.value = unicode(obj)
layers = QGisLayers.getVectorLayers(self.shapetype)
for layer in layers:
if layer.name() == self.value:
if layer.name() == self.value or layer.source() == self.value:
self.value = unicode(layer.source())
return True
return os.path.exists(self.value)
@@ -281,10 +281,10 @@ def getImportCommands(self):
commands.append(
'tryCatch(find.package("rgdal"), error=function(e) install.packages("rgdal", dependencies=TRUE, lib="%s"))' % rLibDir)
commands.append("library(\"rgdal\")");
if not self.useRasterPackage or self.passFileNames:
commands.append(
#if not self.useRasterPackage or self.passFileNames:
commands.append(
'tryCatch(find.package("raster"), error=function(e) install.packages("raster", dependencies=TRUE, lib="%s"))' % rLibDir)
commands.append("library(\"raster\")");
commands.append("library(\"raster\")");

for param in self.parameters:
if isinstance(param, ParameterRaster):
@@ -102,7 +102,8 @@ void QgsComposerItemWidget::on_mBackgroundColorButton_colorChanged( const QColor
// QColor newColor( newBackgroundColor );
mItem->beginCommand( tr( "Background color changed" ) );
// newColor.setAlpha( 255 - ( mTransparencySpinBox->value() * 2.55 ) );
mItem->setBrush( QBrush( QColor( newBackgroundColor ), Qt::SolidPattern ) );
mItem->setBackgroundColor( newBackgroundColor );

//if the item is a composer map, we need to regenerate the map image
//because it usually is cached
QgsComposerMap* cm = dynamic_cast<QgsComposerMap *>( mItem );
@@ -248,6 +249,15 @@ void QgsComposerItemWidget::on_mBackgroundGroupBox_toggled( bool state )

mItem->beginCommand( tr( "Item background toggled" ) );
mItem->setBackgroundEnabled( state );

//if the item is a composer map, we need to regenerate the map image
//because it usually is cached
QgsComposerMap* cm = dynamic_cast<QgsComposerMap *>( mItem );
if ( cm )
{
cm->cache();
}

mItem->update();
mItem->endCommand();
}
@@ -203,15 +203,16 @@ QgsFieldsProperties::QgsFieldsProperties( QgsVectorLayer *layer, QWidget* parent
leEditForm->setText( layer->editForm() );
leEditFormInit->setText( layer->editFormInit() );

mEditorLayoutComboBox->setCurrentIndex( layer->editorLayout() );

loadAttributeEditorTree();
updateButtons();
}

void QgsFieldsProperties::init()
{
loadRows();

mEditorLayoutComboBox->setCurrentIndex( mLayer->editorLayout() );

loadAttributeEditorTree();
}

void QgsFieldsProperties::onAttributeSelectionChanged()

0 comments on commit 2873d6a

Please sign in to comment.
You can’t perform that action at this time.