本文整理汇总了Python中qgis.core.QgsProcessingModelChildParameterSource类的典型用法代码示例。如果您正苦于以下问题:Python QgsProcessingModelChildParameterSource类的具体用法?Python QgsProcessingModelChildParameterSource怎么用?Python QgsProcessingModelChildParameterSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QgsProcessingModelChildParameterSource类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _expressionValues
def _expressionValues(self, text):
strings = self.dialog.getAvailableValuesOfType(
[QgsProcessingParameterString, QgsProcessingParameterNumber], [])
model_params = [(self.dialog.resolveValueDescription(s), s) for s in strings]
variables = QgsExpression.referencedVariables(text)
# replace description by parameter's name (diverging after model save)
descriptions = QgsExpression.referencedVariables(text)
for k, v in model_params:
if k in descriptions:
text = text.replace('[% @{} %]'.format(k), '[% @{} %]'.format(v.parameterName()))
src = QgsProcessingModelChildParameterSource.fromExpressionText(text)
# add parameters currently used by the expression
expression_values = []
expression_values.append(src)
for k, v in model_params:
if k in variables:
expression_values.append(v)
return expression_values
开发者ID:mbernasocchi,项目名称:QGIS,代码行数:25,代码来源:ExecuteSQLWidget.py
示例2: getValue
def getValue(self):
value = self.leText.text()
for param in self.modelParametersDialog.model.parameterDefinitions():
if isinstance(param, QgsProcessingParameterNumber):
if "@" + param.name() == value.strip():
return QgsProcessingModelChildParameterSource.fromModelParameter(param.name())
for alg in list(self.modelParametersDialog.model.childAlgorithms().values()):
for out in alg.algorithm().outputDefinitions():
if isinstance(out, QgsProcessingOutputNumber) and "@%s_%s" % (alg.childId(), out.name()) == value.strip():
return QgsProcessingModelChildParameterSource.fromChildOutput(alg.childId(), out.outputName())
try:
return float(value.strip())
except:
return QgsProcessingModelChildParameterSource.fromExpression(self.leText.text())
开发者ID:borysiasty,项目名称:QGIS,代码行数:16,代码来源:NumberInputPanel.py
示例3: createAlgorithm
def createAlgorithm(self):
alg = QgsProcessingModelChildAlgorithm(self._alg.id())
if not self.childId:
alg.generateChildId(self.model)
else:
alg.setChildId(self.childId)
alg.setDescription(self.descriptionBox.text())
for param in self._alg.parameterDefinitions():
if param.isDestination() or param.flags() & QgsProcessingParameterDefinition.FlagHidden:
continue
try:
val = self.wrappers[param.name()].value()
except InvalidParameterValue:
self.bar.pushMessage(self.tr("Error"),
self.tr("Wrong or missing value for parameter '{}'").format(param.description()),
level=Qgis.Warning)
return None
if isinstance(val, QgsProcessingModelChildParameterSource):
val = [val]
elif not (isinstance(val, list) and all(
[isinstance(subval, QgsProcessingModelChildParameterSource) for subval in val])):
val = [QgsProcessingModelChildParameterSource.fromStaticValue(val)]
for subval in val:
if (isinstance(subval, QgsProcessingModelChildParameterSource) and
subval.source() == QgsProcessingModelChildParameterSource.StaticValue and
not param.checkValueIsAcceptable(subval.staticValue())) \
or (subval is None and not param.flags() & QgsProcessingParameterDefinition.FlagOptional):
self.bar.pushMessage(self.tr("Error"), self.tr("Wrong or missing value for parameter '{}'").format(
param.description()),
level=Qgis.Warning)
return None
alg.addParameterSources(param.name(), val)
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 = QgsProcessingModelOutput(name, name)
output.setChildId(alg.childId())
output.setChildOutputName(dest.name())
outputs[name] = output
alg.setModelOutputs(outputs)
selectedOptions = self.dependenciesPanel.selectedoptions
availableDependencies = self.getAvailableDependencies() # spellok
dep_ids = []
for selected in selectedOptions:
dep_ids.append(availableDependencies[selected].childId()) # spellok
alg.setDependencies(dep_ids)
#try:
# self._alg.processBeforeAddingToModeler(alg, self.model)
#except:
# pass
return alg
开发者ID:Cracert,项目名称:Quantum-GIS,代码行数:58,代码来源:ModelerParametersDialog.py
示例4: _expressionValues
def _expressionValues(self, text):
strings = self.dialog.getAvailableValuesOfType(
[QgsProcessingParameterString, QgsProcessingParameterNumber], [])
model_params = [(self.dialog.resolveValueDescription(s), s) for s in strings]
variables = QgsExpression.referencedVariables(text)
expression_values = []
expression_values.append(QgsProcessingModelChildParameterSource.fromExpressionText(text))
for k, v in model_params:
if k in variables:
expression_values.append(v)
return expression_values
开发者ID:pigreco,项目名称:QGIS,代码行数:14,代码来源:ExecuteSQLWidget.py
示例5: setPreviousValues
def setPreviousValues(self):
if self.childId is not None:
alg = self.model.childAlgorithm(self.childId)
self.descriptionBox.setText(alg.description())
for param in alg.algorithm().parameterDefinitions():
if param.isDestination() or param.flags() & QgsProcessingParameterDefinition.FlagHidden:
continue
value = None
if param.name() in alg.parameterSources():
value = alg.parameterSources()[param.name()]
if isinstance(value, list) and len(value) == 1:
value = value[0]
elif isinstance(value, list) and len(value) == 0:
value = None
wrapper = self.wrappers[param.name()]
if issubclass(wrapper.__class__, QgsProcessingModelerParameterWidget):
if value is None:
value = QgsProcessingModelChildParameterSource.fromStaticValue(param.defaultValue())
wrapper.setWidgetValue(value)
else:
if value is None:
value = param.defaultValue()
if isinstance(value,
QgsProcessingModelChildParameterSource) and value.source() == QgsProcessingModelChildParameterSource.StaticValue:
value = value.staticValue()
wrapper.setValue(value)
for name, out in alg.modelOutputs().items():
if out.childOutputName() in self.valueItems:
self.valueItems[out.childOutputName()].setText(out.name())
selected = []
dependencies = self.getAvailableDependencies() # spellok
for idx, dependency in enumerate(dependencies):
if dependency.childId() in alg.dependencies():
selected.append(idx)
self.dependenciesPanel.setSelectedItems(selected)
开发者ID:havatv,项目名称:QGIS,代码行数:41,代码来源:ModelerParametersDialog.py
注:本文中的qgis.core.QgsProcessingModelChildParameterSource类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论