Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Cleanup model algorithm parameter definition dialog
- Loading branch information
|
@@ -588,17 +588,17 @@ def _addAlgorithm(self, alg, pos=None): |
|
|
pass |
|
|
if not dlg: |
|
|
dlg = ModelerParametersDialog(alg, self.model) |
|
|
dlg.exec_() |
|
|
if dlg.alg is not None: |
|
|
if dlg.exec_(): |
|
|
alg = dlg.createAlgorithm() |
|
|
if pos is None: |
|
|
dlg.alg.setPosition(self.getPositionForAlgorithmItem()) |
|
|
alg.setPosition(self.getPositionForAlgorithmItem()) |
|
|
else: |
|
|
dlg.alg.setPosition(pos) |
|
|
alg.setPosition(pos) |
|
|
from processing.modeler.ModelerGraphicItem import ModelerGraphicItem |
|
|
for i, out in enumerate(dlg.alg.modelOutputs()): |
|
|
dlg.alg.modelOutput(out).setPosition(dlg.alg.position() + QPointF(ModelerGraphicItem.BOX_WIDTH, (i + 1.5) * |
|
|
for i, out in enumerate(alg.modelOutputs()): |
|
|
alg.modelOutput(out).setPosition(alg.position() + QPointF(ModelerGraphicItem.BOX_WIDTH, (i + 1.5) * |
|
|
ModelerGraphicItem.BOX_HEIGHT)) |
|
|
self.model.addChildAlgorithm(dlg.alg) |
|
|
self.model.addChildAlgorithm(alg) |
|
|
self.repaintModel() |
|
|
self.hasChanged = True |
|
|
|
|
|
|
@@ -210,10 +210,10 @@ def editElement(self): |
|
|
pass |
|
|
if not dlg: |
|
|
dlg = ModelerParametersDialog(self.element.algorithm(), self.model, self.element.childId()) |
|
|
dlg.exec_() |
|
|
if dlg.alg is not None: |
|
|
dlg.alg.setChildId(self.element.childId()) |
|
|
self.updateAlgorithm(dlg.alg) |
|
|
if dlg.exec_(): |
|
|
alg = dlg.createAlgorithm() |
|
|
alg.setChildId(self.element.childId()) |
|
|
self.updateAlgorithm(alg) |
|
|
self.scene.dialog.repaintModel() |
|
|
|
|
|
def updateAlgorithm(self, alg): |
|
|
|
@@ -70,8 +70,6 @@ def __init__(self, alg, model, algName=None): |
|
|
self.setModal(True) |
|
|
# The algorithm to define in this dialog. It is an instance of GeoAlgorithm |
|
|
self._alg = alg |
|
|
# The resulting algorithm after the user clicks on OK. it is an instance of the container Algorithm class |
|
|
self.alg = None |
|
|
# The model this algorithm is going to be added to |
|
|
self.model = model |
|
|
# The name of the algorithm in the model, in case we are editing it and not defining it for the first time |
|
@@ -348,21 +346,20 @@ def createAlgorithm(self): |
|
|
dep_ids.append(availableDependencies[selected].childId()) # spellok |
|
|
alg.setDependencies(dep_ids) |
|
|
|
|
|
try: |
|
|
self._alg.processBeforeAddingToModeler(alg, self.model) |
|
|
except: |
|
|
pass |
|
|
#try: |
|
|
# self._alg.processBeforeAddingToModeler(alg, self.model) |
|
|
#except: |
|
|
# pass |
|
|
|
|
|
return alg |
|
|
|
|
|
def okPressed(self): |
|
|
self.alg = self.createAlgorithm() |
|
|
if self.alg is not None: |
|
|
self.close() |
|
|
alg = self.createAlgorithm() |
|
|
if alg is not None: |
|
|
self.accept() |
|
|
|
|
|
def cancelPressed(self): |
|
|
self.alg = None |
|
|
self.close() |
|
|
self.reject() |
|
|
|
|
|
def openHelp(self): |
|
|
algHelp = self._alg.help() |
|
|