Skip to content

Commit 9599c20

Browse files
author
volayaf
committed
refixed 5949. fixed 5925
git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@322 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
1 parent cfdbc2f commit 9599c20

7 files changed

+23
-7
lines changed

src/sextante/gui/ExtentSelectionPanel.py

-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ def useLayerExtent(self):
111111
extentsDict[layer.name()] = layer.extent()
112112
item, ok = QtGui.QInputDialog.getItem(self, "Select extent", "Use extent from", extents, False)
113113
if ok:
114-
item = str(item)
115114
self.setValueFromRect(extentsDict[item])
116115

117116
def selectOnCanvas(self):

src/sextante/modeler/ModelerAlgorithm.py

+17-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
class ModelerAlgorithm(GeoAlgorithm):
2222

23+
CANVAS_SIZE = 4000
24+
2325
def getCopy(self):
2426
newone = ModelerAlgorithm()
2527
newone.openModel(self.descriptionFile)
@@ -254,13 +256,26 @@ def getPositionForAlgorithmItem(self):
254256
MARGIN = 20
255257
BOX_WIDTH = 200
256258
BOX_HEIGHT = 80
257-
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))
259+
if len(self.algPos) != 0:
260+
maxX = max([pos.x() for pos in self.algPos])
261+
maxY = max([pos.y() for pos in self.algPos])
262+
newX = min(MARGIN + BOX_WIDTH + maxX, self.CANVAS_SIZE - BOX_WIDTH)
263+
newY = min(MARGIN + BOX_HEIGHT + maxY, self.CANVAS_SIZE - BOX_HEIGHT)
264+
else:
265+
newX = MARGIN + BOX_WIDTH / 2
266+
newY = MARGIN * 2 + BOX_HEIGHT + BOX_HEIGHT / 2
267+
return QtCore.QPointF(newX, newY)
258268

259269
def getPositionForParameterItem(self):
260270
MARGIN = 20
261271
BOX_WIDTH = 200
262272
BOX_HEIGHT = 80
263-
return QtCore.QPointF(MARGIN + BOX_WIDTH / 2 + len(self.paramPos) * (BOX_WIDTH + MARGIN), MARGIN + BOX_HEIGHT / 2)
273+
if len(self.paramPos) != 0:
274+
maxX = max([pos.x() for pos in self.paramPos])
275+
newX = min(MARGIN + BOX_WIDTH + maxX, self.CANVAS_SIZE - BOX_WIDTH)
276+
else:
277+
newX = MARGIN + BOX_WIDTH / 2
278+
return QtCore.QPointF(newX, MARGIN + BOX_HEIGHT / 2)
264279

265280
def serialize(self):
266281
s="NAME:" + unicode(self.name) + "\n"

src/sextante/modeler/ModelerDialog.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def openModel(self):
248248

249249
def repaintModel(self):
250250
self.scene = ModelerScene()
251-
self.scene.setSceneRect(QtCore.QRectF(0, 0, 4000, 4000))
251+
self.scene.setSceneRect(QtCore.QRectF(0, 0, ModelerAlgorithm.CANVAS_SIZE, ModelerAlgorithm.CANVAS_SIZE))
252252
self.scene.paintModel(self.alg)
253253
self.view.setScene(self.scene)
254254
#self.pythonText.setText(self.alg.getAsPythonCode())

src/sextante/modeler/ModelerGraphicItem.py

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def activateAlgorithm(self):
6262
"The selected algorithm depends on other currently non-active algorithms.\nActivate them them before trying to activate it.")
6363

6464
def editElement(self):
65+
self.model.setPositions(self.scene().getParameterPositions(), self.scene().getAlgorithmPositions())
6566
if isinstance(self.element, Parameter):
6667
dlg = ModelerParameterDefinitionDialog(self.model, param = self.element)
6768
dlg.exec_()

src/sextante/modeler/ModelerParameterDefinitionDialog.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ def okPressed(self):
203203
return
204204
elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_STRING or isinstance(self.param, ParameterString):
205205
self.param = ParameterString(name, description, str(self.defaultTextBox.text()))
206-
206+
elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_EXTENT or isinstance(self.param, ParameterExtent):
207+
self.param = ParameterExtent(name, description)
207208
self.close()
208209

209210
def cancelPressed(self):

src/sextante/modeler/ModelerParametersDialog.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ def getExtents(self):
166166
for param in params:
167167
if isinstance(param, ParameterExtent):
168168
extents.append(AlgorithmAndParameter(AlgorithmAndParameter.PARENT_MODEL_ALGORITHM, param.name, "", param.description))
169+
return extents
169170

170171
def getNumbers(self):
171172
numbers = []
@@ -316,7 +317,6 @@ def getWidgetFromParameter(self, param):
316317
files = self.getFiles()
317318
for f in files:
318319
item.addItem(f.name(), f)
319-
item.setEditText(str(param.default))
320320
else:
321321
item = QtGui.QLineEdit()
322322
try:

src/sextante/parameters/ParameterTableField.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ def deserialize(self, s):
3131
return ParameterTableField(tokens[0], tokens[1], tokens[2])
3232

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

0 commit comments

Comments
 (0)