当前位置: 首页>>代码示例>>Python>>正文


Python ModelerGraphicItem.setFlag方法代码示例

本文整理汇总了Python中processing.modeler.ModelerGraphicItem.ModelerGraphicItem.setFlag方法的典型用法代码示例。如果您正苦于以下问题:Python ModelerGraphicItem.setFlag方法的具体用法?Python ModelerGraphicItem.setFlag怎么用?Python ModelerGraphicItem.setFlag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在processing.modeler.ModelerGraphicItem.ModelerGraphicItem的用法示例。


在下文中一共展示了ModelerGraphicItem.setFlag方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: paintModel

# 需要导入模块: from processing.modeler.ModelerGraphicItem import ModelerGraphicItem [as 别名]
# 或者: from processing.modeler.ModelerGraphicItem.ModelerGraphicItem import setFlag [as 别名]
    def paintModel(self, model, controls=True):
        self.model = model
        # Inputs
        for inp in list(model.inputs.values()):
            item = ModelerGraphicItem(inp, model, controls)
            item.setFlag(QGraphicsItem.ItemIsMovable, True)
            item.setFlag(QGraphicsItem.ItemIsSelectable, True)
            self.addItem(item)
            item.setPos(inp.pos.x(), inp.pos.y())
            self.paramItems[inp.param.name] = item

        # We add the algs
        for alg in list(model.algs.values()):
            item = ModelerGraphicItem(alg, model, controls)
            item.setFlag(QGraphicsItem.ItemIsMovable, True)
            item.setFlag(QGraphicsItem.ItemIsSelectable, True)
            self.addItem(item)
            item.setPos(alg.pos.x(), alg.pos.y())
            self.algItems[alg.modeler_name] = item

        # And then the arrows
        for alg in list(model.algs.values()):
            idx = 0
            for parameter in alg.algorithm.parameters:
                if not parameter.hidden:
                    if parameter.name in alg.params:
                        value = alg.params[parameter.name]
                    else:
                        value = None
                    sourceItems = self.getItemsFromParamValue(value)
                    for sourceItem, sourceIdx in sourceItems:
                        arrow = ModelerArrowItem(sourceItem, sourceIdx, self.algItems[alg.modeler_name], idx)
                        sourceItem.addArrow(arrow)
                        self.algItems[alg.modeler_name].addArrow(arrow)
                        arrow.updatePath()
                        self.addItem(arrow)
                    idx += 1
            for depend in alg.dependencies:
                arrow = ModelerArrowItem(self.algItems[depend], -1,
                                         self.algItems[alg.modeler_name], -1)
                self.algItems[depend].addArrow(arrow)
                self.algItems[alg.modeler_name].addArrow(arrow)
                arrow.updatePath()
                self.addItem(arrow)

        # And finally the outputs
        for alg in list(model.algs.values()):
            outputs = alg.outputs
            outputItems = {}
            idx = 0
            for key in outputs:
                out = outputs[key]
                if out is not None:
                    item = ModelerGraphicItem(out, model, controls)
                    item.setFlag(QGraphicsItem.ItemIsMovable, True)
                    item.setFlag(QGraphicsItem.ItemIsSelectable, True)
                    self.addItem(item)
                    pos = alg.outputs[key].pos
                    if pos is None:
                        pos = (alg.pos + QPointF(ModelerGraphicItem.BOX_WIDTH, 0) +
                               self.algItems[alg.modeler_name].getLinkPointForOutput(idx))
                    item.setPos(pos)
                    outputItems[key] = item
                    arrow = ModelerArrowItem(self.algItems[alg.modeler_name], idx, item,
                                             -1)
                    self.algItems[alg.modeler_name].addArrow(arrow)
                    item.addArrow(arrow)
                    arrow.updatePath()
                    self.addItem(arrow)
                    idx += 1
                else:
                    outputItems[key] = None
            self.outputItems[alg.modeler_name] = outputItems
开发者ID:cayetanobv,项目名称:QGIS,代码行数:75,代码来源:ModelerScene.py

示例2: paintModel

# 需要导入模块: from processing.modeler.ModelerGraphicItem import ModelerGraphicItem [as 别名]
# 或者: from processing.modeler.ModelerGraphicItem.ModelerGraphicItem import setFlag [as 别名]
    def paintModel(self, model, controls=True):
        self.model = model
        context = createContext()
        # Inputs
        for inp in list(model.parameterComponents().values()):
            item = ModelerGraphicItem(inp, model, controls, scene=self)
            item.setFlag(QGraphicsItem.ItemIsMovable, True)
            item.setFlag(QGraphicsItem.ItemIsSelectable, True)
            self.addItem(item)
            item.setPos(inp.position().x(), inp.position().y())
            self.paramItems[inp.parameterName()] = item

        # Input dependency arrows
        for input_name in list(model.parameterComponents().keys()):
            idx = 0
            parameter_def = model.parameterDefinition(input_name)
            if hasattr(parameter_def, 'parentLayerParameterName') and parameter_def.parentLayerParameterName():
                parent_name = parameter_def.parentLayerParameterName()
                if input_name in self.paramItems and parent_name in self.paramItems:
                    input_item = self.paramItems[input_name]
                    parent_item = self.paramItems[parent_name]
                    arrow = ModelerArrowItem(parent_item, -1, input_item, -1)
                    input_item.addArrow(arrow)
                    parent_item.addArrow(arrow)
                    arrow.setPenStyle(Qt.DotLine)
                    arrow.updatePath()
                    self.addItem(arrow)

        # We add the algs
        for alg in list(model.childAlgorithms().values()):
            item = ModelerGraphicItem(alg, model, controls, scene=self)
            item.setFlag(QGraphicsItem.ItemIsMovable, True)
            item.setFlag(QGraphicsItem.ItemIsSelectable, True)
            self.addItem(item)
            item.setPos(alg.position().x(), alg.position().y())
            self.algItems[alg.childId()] = item

        # And then the arrows

        for alg in list(model.childAlgorithms().values()):
            idx = 0
            for parameter in alg.algorithm().parameterDefinitions():
                if not parameter.isDestination() and not parameter.flags() & QgsProcessingParameterDefinition.FlagHidden:
                    if parameter.name() in alg.parameterSources():
                        sources = alg.parameterSources()[parameter.name()]
                    else:
                        sources = []
                    for source in sources:
                        sourceItems = self.getItemsFromParamValue(source, alg.childId(), context)
                        for sourceItem, sourceIdx in sourceItems:
                            arrow = ModelerArrowItem(sourceItem, sourceIdx, self.algItems[alg.childId()], idx)
                            sourceItem.addArrow(arrow)
                            self.algItems[alg.childId()].addArrow(arrow)
                            arrow.updatePath()
                            self.addItem(arrow)
                        idx += 1
            for depend in alg.dependencies():
                arrow = ModelerArrowItem(self.algItems[depend], -1,
                                         self.algItems[alg.childId()], -1)
                self.algItems[depend].addArrow(arrow)
                self.algItems[alg.childId()].addArrow(arrow)
                arrow.updatePath()
                self.addItem(arrow)

        # And finally the outputs
        for alg in list(model.childAlgorithms().values()):
            outputs = alg.modelOutputs()
            outputItems = {}
            idx = 0
            for key, out in outputs.items():
                if out is not None:
                    item = ModelerGraphicItem(out, model, controls, scene=self)
                    item.setFlag(QGraphicsItem.ItemIsMovable, True)
                    item.setFlag(QGraphicsItem.ItemIsSelectable, True)
                    self.addItem(item)
                    pos = out.position()
                    if pos is None:
                        pos = (alg.position() + QPointF(ModelerGraphicItem.BOX_WIDTH, 0) +
                               self.algItems[alg.childId()].getLinkPointForOutput(idx))
                    item.setPos(pos)
                    outputItems[key] = item
                    arrow = ModelerArrowItem(self.algItems[alg.childId()], idx, item,
                                             -1)
                    self.algItems[alg.childId()].addArrow(arrow)
                    item.addArrow(arrow)
                    arrow.updatePath()
                    self.addItem(arrow)
                    idx += 1
                else:
                    outputItems[key] = None
            self.outputItems[alg.childId()] = outputItems
开发者ID:vmora,项目名称:QGIS,代码行数:93,代码来源:ModelerScene.py

示例3: paintModel

# 需要导入模块: from processing.modeler.ModelerGraphicItem import ModelerGraphicItem [as 别名]
# 或者: from processing.modeler.ModelerGraphicItem.ModelerGraphicItem import setFlag [as 别名]
    def paintModel(self, model):
        self.model = model
        i = 0

        # Inputs
        for param in model.parameters:
            item = ModelerGraphicItem(param, i, model)
            item.setFlag(QtGui.QGraphicsItem.ItemIsMovable, True)
            item.setFlag(QtGui.QGraphicsItem.ItemIsSelectable, True)
            self.addItem(item)
            item.setPos(model.paramPos[i])
            self.paramItems.append(item)
            i += 1

        # We add the algs
        iAlg = 0
        for alg in model.algs:
            item = ModelerGraphicItem(alg, iAlg, model)
            item.setFlag(QtGui.QGraphicsItem.ItemIsMovable, True)
            item.setFlag(QtGui.QGraphicsItem.ItemIsSelectable, True)
            self.addItem(item)
            item.setPos(model.algPos[iAlg])
            self.algItems.append(item)
            iAlg += 1

        # And then the arrows
        iAlg = 0
        for alg in model.algs:
            params = model.algParameters[iAlg]
            idx = 0
            for parameter in alg.parameters:
                if not parameter.hidden:
                    param = params[parameter.name]
                    if param:
                        sourceItems = self.getItemsFromAAP(param,
                                isinstance(alg.getParameterFromName(parameter.name), ParameterMultipleInput))
                        for sourceItem in sourceItems:
                            arrow = ModelerArrowItem(sourceItem[0], sourceItem[1], self.algItems[iAlg], idx)
                            self.addItem(arrow)
                    idx += 1
            for depend in model.dependencies[iAlg]:
                arrow = ModelerArrowItem(self.algItems[depend], -1,
                        self.algItems[iAlg], -1)
                self.addItem(arrow)
            iAlg += 1

        # And finally the outputs
        for (iAlg, alg) in enumerate(model.algs):
            outputs = model.algOutputs[iAlg]
            outputItems = {}
            for (idx, key) in enumerate(outputs.keys()):
                out = outputs[key]
                if out is not None:
                    item = ModelerGraphicItem(out, idx, model)
                    item.setFlag(QtGui.QGraphicsItem.ItemIsMovable, True)
                    item.setFlag(QtGui.QGraphicsItem.ItemIsSelectable, True)
                    self.addItem(item)
                    pos = model.outputPos[iAlg][key]
                    if pos is None:
                        pos = self.algItems[iAlg].pos() \
                            + QtCore.QPointF(ModelerGraphicItem.BOX_WIDTH, 0) \
                            + self.algItems[iAlg].getLinkPointForOutput(idx)
                    item.setPos(pos)
                    outputItems[key] = item
                    arrow = ModelerArrowItem(self.algItems[iAlg], idx, item,
                            -1)
                    self.addItem(arrow)
                else:
                    outputItems[key] = None
            self.outputItems.append(outputItems)
开发者ID:Jokenbol,项目名称:QGIS,代码行数:72,代码来源:ModelerScene.py


注:本文中的processing.modeler.ModelerGraphicItem.ModelerGraphicItem.setFlag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。