class PlainGeometryEditor(): def __init__(self, iface): self.iface = iface self.mapCanvas = iface.mapCanvas() self.dlgs = [] def initGui(self): # help self.helpAction = QAction( QIcon(":/plugins/plaingeometryeditor/icons/help.svg"), "Help", self.iface.mainWindow()) self.helpAction.triggered.connect(lambda: QDesktopServices().openUrl( QUrl("http://3nids.github.io/plaingeometryeditor"))) self.iface.addPluginToMenu("&Plain Geometry Editor", self.helpAction) # map tool action self.mapToolAction = QAction( QIcon( ":/plugins/plaingeometryeditor/icons/plaingeometryeditor.svg"), "Plain Geometry Editor", self.iface.mainWindow()) self.mapToolAction.setCheckable(True) self.mapTool = IdentifyGeometry(self.mapCanvas) self.mapTool.geomIdentified.connect(self.editGeometry) self.mapTool.setAction(self.mapToolAction) self.mapToolAction.triggered.connect(self.setMapTool) self.iface.addToolBarIcon(self.mapToolAction) self.iface.addPluginToMenu("&Plain Geometry Editor", self.mapToolAction) def unload(self): self.iface.removePluginMenu("&Plain Geometry Editor", self.helpAction) self.iface.removePluginMenu("&Plain Geometry Editor", self.mapToolAction) self.iface.removeToolBarIcon(self.mapToolAction) def setMapTool(self): self.mapCanvas.setMapTool(self.mapTool) def editGeometry(self, layer, feature): dlg = GeomEditorDialog(layer, feature, self.mapCanvas, self.iface.mainWindow()) dlg.show() # save dlg so it does not get out of scope and layer is properly disconnect self.dlgs.append(dlg)
def initGui(self): # help self.helpAction = QAction( QIcon(":/plugins/plaingeometryeditor/icons/help.svg"), "Help", self.iface.mainWindow()) self.helpAction.triggered.connect(lambda: QDesktopServices().openUrl( QUrl("http://3nids.github.io/plaingeometryeditor"))) self.iface.addPluginToMenu("&Plain Geometry Editor", self.helpAction) # map tool action self.mapToolAction = QAction( QIcon( ":/plugins/plaingeometryeditor/icons/plaingeometryeditor.svg"), "Plain Geometry Editor", self.iface.mainWindow()) self.mapToolAction.setCheckable(True) self.mapTool = IdentifyGeometry(self.mapCanvas) self.mapTool.geomIdentified.connect(self.editGeometry) self.mapTool.setAction(self.mapToolAction) self.mapToolAction.triggered.connect(self.setMapTool) self.iface.addToolBarIcon(self.mapToolAction) self.iface.addPluginToMenu("&Plain Geometry Editor", self.mapToolAction)
def initGui(self): # help self.helpAction = QAction(QIcon(":/plugins/plaingeometryeditor/icons/help.svg"), "Help", self.iface.mainWindow()) self.helpAction.triggered.connect(lambda: QDesktopServices().openUrl(QUrl("http://3nids.github.io/plaingeometryeditor"))) self.iface.addPluginToMenu("&Plain Geometry Editor", self.helpAction) # map tool action self.mapToolAction = QAction(QIcon(":/plugins/plaingeometryeditor/icons/plaingeometryeditor.svg"), "Plain Geometry Editor", self.iface.mainWindow()) self.mapToolAction.setCheckable(True) self.mapTool = IdentifyGeometry(self.mapCanvas) self.mapTool.geomIdentified.connect(self.editGeometry) self.mapTool.setAction(self.mapToolAction) self.mapToolAction.triggered.connect(self.setMapTool) self.iface.addToolBarIcon(self.mapToolAction) self.iface.addPluginToMenu("&Plain Geometry Editor", self.mapToolAction)
class PlainGeometryEditor(): def __init__(self, iface): self.iface = iface self.mapCanvas = iface.mapCanvas() self.dlgs = [] def initGui(self): # help self.helpAction = QAction(QIcon(":/plugins/plaingeometryeditor/icons/help.svg"), "Help", self.iface.mainWindow()) self.helpAction.triggered.connect(lambda: QDesktopServices().openUrl(QUrl("http://3nids.github.io/plaingeometryeditor"))) self.iface.addPluginToMenu("&Plain Geometry Editor", self.helpAction) # map tool action self.mapToolAction = QAction(QIcon(":/plugins/plaingeometryeditor/icons/plaingeometryeditor.svg"), "Plain Geometry Editor", self.iface.mainWindow()) self.mapToolAction.setCheckable(True) self.mapTool = IdentifyGeometry(self.mapCanvas) self.mapTool.geomIdentified.connect(self.editGeometry) self.mapTool.setAction(self.mapToolAction) self.mapToolAction.triggered.connect(self.setMapTool) self.iface.addToolBarIcon(self.mapToolAction) self.iface.addPluginToMenu("&Plain Geometry Editor", self.mapToolAction) def unload(self): self.iface.removePluginMenu("&Plain Geometry Editor", self.helpAction) self.iface.removePluginMenu("&Plain Geometry Editor", self.mapToolAction) self.iface.removeToolBarIcon(self.mapToolAction) def setMapTool(self): self.mapCanvas.setMapTool(self.mapTool) def editGeometry(self, layer, feature): dlg = GeomEditorDialog(layer, feature, self.mapCanvas, self.iface.mainWindow()) dlg.show() # save dlg so it does not get out of scope and layer is properly disconnect self.dlgs.append(dlg)