Navigation Menu

Skip to content

Commit

Permalink
Fix some errors in graphical modeler
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 21, 2017
1 parent b01cae0 commit c36169a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 30 deletions.
2 changes: 1 addition & 1 deletion python/plugins/processing/modeler/ModelerGraphicItem.py
Expand Up @@ -374,7 +374,7 @@ def itemChange(self, change, value):
elif isinstance(self.element, QgsProcessingModelAlgorithm.ModelParameter):
self.model.parameterComponent(self.element.parameterName()).setPosition(self.pos())
elif isinstance(self.element, QgsProcessingModelAlgorithm.ModelOutput):
self.model.childAlgorithm(self.element.childId()).modelOutput(self.element.name()).setPosition(self.pos())
self.model.childAlgorithm(self.element.childId()).modelOutput(self.element.outputName()).setPosition(self.pos())

return value

Expand Down
59 changes: 31 additions & 28 deletions python/plugins/processing/modeler/ModelerParametersDialog.py
Expand Up @@ -36,21 +36,18 @@
from qgis.core import (QgsProcessingParameterDefinition,
QgsProcessingParameterPoint,
QgsProcessingParameterExtent,
QgsProcessingModelAlgorithm)
QgsProcessingModelAlgorithm,
QgsProcessingParameterFeatureSink,
QgsProcessingParameterRasterOutput,
QgsProcessingParameterFileOutput,
QgsProcessingParameterFolderOutput)

from qgis.gui import (QgsMessageBar,
QgsScrollArea)

from processing.gui.wrappers import WidgetWrapperFactory
from processing.gui.wrappers import InvalidParameterValue
from processing.gui.MultipleInputPanel import MultipleInputPanel
from processing.core.outputs import (OutputRaster,
OutputVector,
OutputTable,
OutputHTML,
OutputFile,
OutputDirectory)
from processing.core.parameters import ParameterPoint, ParameterExtent


class ModelerParametersDialog(QDialog):
Expand Down Expand Up @@ -149,19 +146,18 @@ def setupUi(self):
self.verticalLayout.addWidget(label)
self.verticalLayout.addWidget(widget)

# for output in self._alg.outputs:
# if output.flags() & QgsProcessingParameterDefinition.FlagHidden:
# continue
# if isinstance(output, (OutputRaster, OutputVector, OutputTable,
# OutputHTML, OutputFile, OutputDirectory)):
# label = QLabel(output.description() + '<' +
# output.__class__.__name__ + '>')
# item = QLineEdit()
# if hasattr(item, 'setPlaceholderText'):
# item.setPlaceholderText(ModelerParametersDialog.ENTER_NAME)
# self.verticalLayout.addWidget(label)
# self.verticalLayout.addWidget(item)
# self.valueItems[output.name] = item
for dest in self._alg.destinationParameterDefinitions():
if dest.flags() & QgsProcessingParameterDefinition.FlagHidden:
continue
if isinstance(dest, (QgsProcessingParameterRasterOutput, QgsProcessingParameterFeatureSink,
QgsProcessingParameterFileOutput, QgsProcessingParameterFolderOutput)):
label = QLabel(dest.description())
item = QLineEdit()
if hasattr(item, 'setPlaceholderText'):
item.setPlaceholderText(ModelerParametersDialog.ENTER_NAME)
self.verticalLayout.addWidget(label)
self.verticalLayout.addWidget(item)
self.valueItems[dest.name()] = item

label = QLabel(' ')
self.verticalLayout.addWidget(label)
Expand Down Expand Up @@ -309,7 +305,10 @@ def setPreviousValues(self):

def createAlgorithm(self):
alg = QgsProcessingModelAlgorithm.ChildAlgorithm(self._alg.id())
alg.generateChildId(self.model)
if not self._algName:
alg.generateChildId(self.model)
else:
alg.setChildId(self._algName)
alg.setDescription(self.descriptionBox.text())
for param in self._alg.parameterDefinitions():
if param.isDestination() or param.flags() & QgsProcessingParameterDefinition.FlagHidden:
Expand All @@ -332,12 +331,16 @@ def createAlgorithm(self):
else:
alg.addParameterSource(param.name(), QgsProcessingModelAlgorithm.ChildParameterSource.fromStaticValue(val))

# outputs = self._alg.outputDefinitions()
# for output in outputs:
# if not output.flags() & QgsProcessingParameterDefinition.FlagHidden:
# name = str(self.valueItems[output.name()].text())
# if name.strip() != '' and name != ModelerParametersDialog.ENTER_NAME:
# alg.outputs[output.name()] = QgsProcessingModelAlgorithm.ModelOutput(name)
outputs = {}
for dest in self._alg.destinationParameterDefinitions():
if not dest.flags() & QgsProcessingParameterDefinition.FlagHidden:
name = str(self.valueItems[dest.name()].text())
if name.strip() != '' and name != ModelerParametersDialog.ENTER_NAME:
output = QgsProcessingModelAlgorithm.ModelOutput(name)
output.setChildId(alg.childId())
output.setOutputName(dest.name())
outputs[dest.name()] = output
alg.setModelOutputs(outputs)

selectedOptions = self.dependenciesPanel.selectedoptions
availableDependencies = self.getAvailableDependencies() # spellok
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/modeler/ModelerScene.py
Expand Up @@ -143,7 +143,7 @@ def paintModel(self, model, controls=True):
if pos is None:
pos = (alg.position() + QPointF(ModelerGraphicItem.BOX_WIDTH, 0) +
self.algItems[alg.childId()].getLinkPointForOutput(idx))
item.setPosition(pos)
item.setPos(pos)
outputItems[key] = item
arrow = ModelerArrowItem(self.algItems[alg.childId()], idx, item,
-1)
Expand Down

0 comments on commit c36169a

Please sign in to comment.