Example #1
0
class DtFillGapAllLayers(DtSingleTool):
    '''Fill gaps between the polygons of all visible layers with new features'''
    def __init__(self, iface, toolBar):
        super().__init__(iface, toolBar,
            QtGui.QIcon(":/fillGapAll.png"),
            QtCore.QCoreApplication.translate("digitizingtools",
                "Fill gap between polygons of all visible layers with a new feature"),
            geometryTypes = [3, 6], dtName = "dtFillGapAll")

        self.tool = DtSelectGapTool(self.iface, True)
        self.tool.gapSelected.connect(self.gapFound)
        self.enable()

    def process(self):
        self.canvas.setMapTool(self.tool)
        self.act.setChecked(True)

    def gapFound(self, result):
        layer = self.iface.activeLayer()
        gap = result[0]
        defaultAttributeMap = dtutils.dtGetDefaultAttributeMap(layer)
        layer.beginEditCommand(QtCore.QCoreApplication.translate(
            "editcommand", "Fill gap"))

        if self.iface.vectorLayerTools().addFeature(layer,
                defaultValues = defaultAttributeMap, defaultGeometry = gap):
            layer.endEditCommand()
            self.canvas.refresh()
        else:
            layer.destroyEditCommand()

        self.tool.reset()
Example #2
0
    def __init__(self, iface, toolBar):
        super().__init__(
            iface,
            toolBar,
            QtGui.QIcon(":/fillGapAll.png"),
            QtCore.QCoreApplication.translate(
                "digitizingtools",
                "Fill gap between polygons of all visible layers with a new feature"
            ),
            geometryTypes=[3, 6],
            dtName="dtFillGapAll")

        self.tool = DtSelectGapTool(self.iface, True)
        self.tool.gapSelected.connect(self.gapFound)
        self.enable()
Example #3
0
    def __init__(self, iface, toolBar):
        super().__init__(iface, toolBar,
            QtGui.QIcon(":/fillGapAll.png"),
            QtCore.QCoreApplication.translate("digitizingtools",
                "Fill gap between polygons of all visible layers with a new feature"),
            geometryTypes = [3, 6], dtName = "dtFillGapAll")

        self.tool = DtSelectGapTool(self.iface, True)
        self.tool.gapSelected.connect(self.gapFound)
        self.enable()
Example #4
0
class DtFillGapAllLayers(DtSingleTool):
    '''Fill gaps between the polygons of all visible layers with new features'''
    def __init__(self, iface, toolBar):
        super().__init__(
            iface,
            toolBar,
            QtGui.QIcon(":/fillGapAll.png"),
            QtCore.QCoreApplication.translate(
                "digitizingtools",
                "Fill gap between polygons of all visible layers with a new feature"
            ),
            geometryTypes=[3, 6],
            dtName="dtFillGapAll")

        self.tool = DtSelectGapTool(self.iface, True)
        self.tool.gapSelected.connect(self.gapFound)
        self.enable()

    def process(self):
        self.canvas.setMapTool(self.tool)
        self.act.setChecked(True)

    def gapFound(self, result):
        layer = self.iface.activeLayer()
        gap = result[0]
        defaultAttributeMap = dtutils.dtGetDefaultAttributeMap(layer)
        layer.beginEditCommand(
            QtCore.QCoreApplication.translate("editcommand", "Fill gap"))

        if self.iface.vectorLayerTools().addFeature(
                layer, defaultValues=defaultAttributeMap, defaultGeometry=gap):
            layer.endEditCommand()
            self.canvas.refresh()
        else:
            layer.destroyEditCommand()

        self.tool.reset()