Skip to content
Permalink
Browse files

refixed 5949. fixed 5925

git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@322 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
volayaf
volayaf committed Jul 31, 2012
1 parent cfdbc2f commit 9599c20364aff0b825f007f60fa28c8b09b4ec98
@@ -111,7 +111,6 @@ def useLayerExtent(self):
extentsDict[layer.name()] = layer.extent()
item, ok = QtGui.QInputDialog.getItem(self, "Select extent", "Use extent from", extents, False)
if ok:
item = str(item)
self.setValueFromRect(extentsDict[item])

def selectOnCanvas(self):
@@ -20,6 +20,8 @@

class ModelerAlgorithm(GeoAlgorithm):

CANVAS_SIZE = 4000

def getCopy(self):
newone = ModelerAlgorithm()
newone.openModel(self.descriptionFile)
@@ -254,13 +256,26 @@ def getPositionForAlgorithmItem(self):
MARGIN = 20
BOX_WIDTH = 200
BOX_HEIGHT = 80
return QtCore.QPointF(MARGIN + BOX_WIDTH / 2 + len(self.algPos) * (BOX_WIDTH + MARGIN), BOX_HEIGHT + 2 * MARGIN + BOX_HEIGHT / 2 + len(self.algs) * (BOX_HEIGHT + MARGIN))
if len(self.algPos) != 0:
maxX = max([pos.x() for pos in self.algPos])
maxY = max([pos.y() for pos in self.algPos])
newX = min(MARGIN + BOX_WIDTH + maxX, self.CANVAS_SIZE - BOX_WIDTH)
newY = min(MARGIN + BOX_HEIGHT + maxY, self.CANVAS_SIZE - BOX_HEIGHT)
else:
newX = MARGIN + BOX_WIDTH / 2
newY = MARGIN * 2 + BOX_HEIGHT + BOX_HEIGHT / 2
return QtCore.QPointF(newX, newY)

def getPositionForParameterItem(self):
MARGIN = 20
BOX_WIDTH = 200
BOX_HEIGHT = 80
return QtCore.QPointF(MARGIN + BOX_WIDTH / 2 + len(self.paramPos) * (BOX_WIDTH + MARGIN), MARGIN + BOX_HEIGHT / 2)
if len(self.paramPos) != 0:
maxX = max([pos.x() for pos in self.paramPos])
newX = min(MARGIN + BOX_WIDTH + maxX, self.CANVAS_SIZE - BOX_WIDTH)
else:
newX = MARGIN + BOX_WIDTH / 2
return QtCore.QPointF(newX, MARGIN + BOX_HEIGHT / 2)

def serialize(self):
s="NAME:" + unicode(self.name) + "\n"
@@ -248,7 +248,7 @@ def openModel(self):

def repaintModel(self):
self.scene = ModelerScene()
self.scene.setSceneRect(QtCore.QRectF(0, 0, 4000, 4000))
self.scene.setSceneRect(QtCore.QRectF(0, 0, ModelerAlgorithm.CANVAS_SIZE, ModelerAlgorithm.CANVAS_SIZE))
self.scene.paintModel(self.alg)
self.view.setScene(self.scene)
#self.pythonText.setText(self.alg.getAsPythonCode())
@@ -62,6 +62,7 @@ def activateAlgorithm(self):
"The selected algorithm depends on other currently non-active algorithms.\nActivate them them before trying to activate it.")

def editElement(self):
self.model.setPositions(self.scene().getParameterPositions(), self.scene().getAlgorithmPositions())
if isinstance(self.element, Parameter):
dlg = ModelerParameterDefinitionDialog(self.model, param = self.element)
dlg.exec_()
@@ -203,7 +203,8 @@ def okPressed(self):
return
elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_STRING or isinstance(self.param, ParameterString):
self.param = ParameterString(name, description, str(self.defaultTextBox.text()))

elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_EXTENT or isinstance(self.param, ParameterExtent):
self.param = ParameterExtent(name, description)
self.close()

def cancelPressed(self):
@@ -166,6 +166,7 @@ def getExtents(self):
for param in params:
if isinstance(param, ParameterExtent):
extents.append(AlgorithmAndParameter(AlgorithmAndParameter.PARENT_MODEL_ALGORITHM, param.name, "", param.description))
return extents

def getNumbers(self):
numbers = []
@@ -316,7 +317,6 @@ def getWidgetFromParameter(self, param):
files = self.getFiles()
for f in files:
item.addItem(f.name(), f)
item.setEditText(str(param.default))
else:
item = QtGui.QLineEdit()
try:
@@ -31,4 +31,4 @@ def deserialize(self, s):
return ParameterTableField(tokens[0], tokens[1], tokens[2])

def __str__(self):
return self.name + " <" + self.__module__.split(".")[-1] +" from " + self.parent + ">"
return self.name + " <" + self.__module__.split(".")[-1] +" from " + self.parent + ">"

0 comments on commit 9599c20

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