Skip to content

Commit

Permalink
fixed bug in deepcopy of ModelAlgorithm
Browse files Browse the repository at this point in the history
other small bugs
Added number checking for numerical settings

git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@32 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
volayaf@gmail.com committed Mar 9, 2012
1 parent 7e93081 commit 93aacbc
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 9 deletions.
12 changes: 10 additions & 2 deletions src/sextante/gui/ConfigDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def __init__(self, toolbox):

def setupUi(self):
self.setObjectName("ConfigDialog")
self.resize(400, 500)
self.resize(700, 500)
self.setWindowTitle("SEXTANTE options")
self.verticalLayout = QtGui.QVBoxLayout()
self.verticalLayout.setSpacing(2)
Expand Down Expand Up @@ -63,12 +63,20 @@ def fillTree(self):
self.tree.addTopLevelItem(groupItem)
if text != "":
groupItem.setExpanded(True)

self.tree.sortItems(0, Qt.AscendingOrder)

def okPressed(self):
for setting in self.items.keys():
if isinstance(setting.value,bool):
setting.value = (self.items[setting].checkState(1) == QtCore.Qt.Checked)
elif isinstance(setting.value, (float,int, long)):
value = str(self.items[setting].text(1))
try:
value = float(value)
setting.value = value
except ValueError:
QtGui.QMessageBox.critical(self, "Wrong value","Wrong parameter value:\n" + value)
return
else:
setting.value = str(self.items[setting].text(1))
SextanteConfig.addSetting(setting)
Expand Down
2 changes: 1 addition & 1 deletion src/sextante/gui/OutputSelectionPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, output, alg):
self.horizontalLayout.setObjectName("hLayout")
self.text = QtGui.QLineEdit()
self.text.setObjectName("label")
self.text.setText(OutputSelectionPanel.SAVE_TO_TEMP_FILE)
self.text.setPlaceholderText(OutputSelectionPanel.SAVE_TO_TEMP_FILE)
self.text.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
self.horizontalLayout.addWidget(self.text)
self.pushButton = QtGui.QPushButton()
Expand Down
11 changes: 11 additions & 0 deletions src/sextante/modeler/ModelerAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@

class ModelerAlgorithm(GeoAlgorithm):

def __deepcopy__(self,memo):
newone = ModelerAlgorithm()
#newone.__dict__.update(self.__dict__)
newone.algs = copy.deepcopy(self.algs, memo)
newone.algParameters = copy.deepcopy(self.algParameters,memo)
newone.algOutputs = copy.deepcopy(self.algOutputs,memo)
newone.paramValues = copy.deepcopy(self.paramValues,memo)
newone.parameters = copy.deepcopy(self.parameters, memo)
newone.outputs = copy.deepcopy(self.outputs, memo)
return newone

def __init__(self):
GeoAlgorithm.__init__(self)
self.descriptionFile = None
Expand Down
8 changes: 4 additions & 4 deletions src/sextante/modeler/ModelerDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ def setupUi(self):
#right hand side part
#==================================
self.textName = QtGui.QLineEdit()
self.textName.setText("[Enter model name here]")
self.textName.setPlaceholderText("[Enter model name here]")
self.textGroup = QtGui.QLineEdit()
self.textGroup.setText("[Enter group name here]")
self.textGroup.setPlaceholderText("[Enter group name here]")
self.horizontalLayoutNames = QtGui.QHBoxLayout()
self.horizontalLayoutNames.setSpacing(2)
self.horizontalLayoutNames.setMargin(0)
Expand Down Expand Up @@ -134,7 +134,7 @@ def setupUi(self):


def saveModel(self):
if str(self.textGroup.text()) == "[Enter group name here]" or str(self.textName.text()) == "[Enter model name here]":
if str(self.textGroup.text()).strip() == "" or str(self.textName.text()).strip() == "":
QMessageBox.warning(self, "Warning", "Please enter group and model names before saving")
return
self.alg.setPositions(self.scene.getParameterPositions(), self.scene.getAlgorithmPositions())
Expand Down Expand Up @@ -174,7 +174,7 @@ def repaintModel(self):
self.scene.setSceneRect(QtCore.QRectF(0, 0, 1000, 1000))
self.scene.paintModel(self.alg)
self.view.setScene(self.scene)
self.pythonText.setText(self.alg.getAsPythonCode())
self.pythonText.setText("This feature is not yet available... we are still working on it ;-)")#self.alg.getAsPythonCode())


def addInput(self):
Expand Down
3 changes: 2 additions & 1 deletion src/sextante/modeler/ModelerParametersDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from sextante.outputs.OutputTable import OutputTable
from sextante.modeler.ModelerAlgorithm import AlgorithmAndParameter
from sextante.parameters.ParameterRange import ParameterRange
from sextante.gui.RangePanel import RangePanel

class ModelerParametersDialog(QtGui.QDialog):

Expand Down Expand Up @@ -251,7 +252,7 @@ def setTableContent(self):
item.setFlags(QtCore.Qt.ItemIsEnabled)
self.tableWidget.setItem(i,0, item)
item = QLineEdit()
item.setText(ModelerParametersDialog.ENTER_NAME)
item.setPlaceholderText(ModelerParametersDialog.ENTER_NAME)
self.valueItems[output.name] = item
self.tableWidget.setCellWidget(i,1, item)
self.tableWidget.setRowHeight(i,22)
Expand Down
2 changes: 1 addition & 1 deletion src/sextante/saga/SagaAlgorithmProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self):
SextanteConfig.addSetting(Setting("SAGA", SagaUtils.SAGA_RESAMPLING_REGION_XMIN, "Resampling region min x", 0))
SextanteConfig.addSetting(Setting("SAGA", SagaUtils.SAGA_RESAMPLING_REGION_YMIN, "Resampling region min y", 0))
SextanteConfig.addSetting(Setting("SAGA", SagaUtils.SAGA_RESAMPLING_REGION_XMAX, "Resampling region max x", 1000))
SextanteConfig.addSetting(Setting("SAGA", SagaUtils.SAGA_RESAMPLING_REGION_XMAX, "Resampling region max y", 1000))
SextanteConfig.addSetting(Setting("SAGA", SagaUtils.SAGA_RESAMPLING_REGION_YMAX, "Resampling region max y", 1000))
SextanteConfig.addSetting(Setting("SAGA", SagaUtils.SAGA_RESAMPLING_REGION_CELLSIZE, "Resampling region cellsize", 1))

def _loadAlgorithms(self):
Expand Down

0 comments on commit 93aacbc

Please sign in to comment.