Navigation Menu

Skip to content

Commit

Permalink
Cleanup model algorithm parameter definition dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Sep 12, 2017
1 parent 88c8c71 commit 4a974ea
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 22 deletions.
14 changes: 7 additions & 7 deletions python/plugins/processing/modeler/ModelerDialog.py 100644 → 100755
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions python/plugins/processing/modeler/ModelerGraphicItem.py 100644 → 100755
Expand Up @@ -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):
Expand Down
19 changes: 8 additions & 11 deletions python/plugins/processing/modeler/ModelerParametersDialog.py 100644 → 100755
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 4a974ea

Please sign in to comment.