コード例 #1
0
    def initGui(self):
        if mgrsOk:
            self.mapTool = MGRSMapTool(self.iface.mapCanvas())
            self.iface.mapCanvas().mapToolSet.connect(self.unsetTool)

        mapToolIcon = QIcon(os.path.join(os.path.dirname(__file__),
                                         "mgrs.svg"))
        self.toolAction = QAction(mapToolIcon, "MGRS map tool",
                                  self.iface.mainWindow())
        self.toolAction.triggered.connect(self.setTool)
        self.toolAction.setCheckable(True)
        self.iface.addToolBarIcon(self.toolAction)
        self.iface.addPluginToMenu("MGRS", self.toolAction)

        zoomToIcon = QIcon(':/images/themes/default/mActionZoomIn.svg')
        self.zoomToAction = QAction(zoomToIcon, "Zoom to MGRS coordinate",
                                    self.iface.mainWindow())
        self.zoomToAction.triggered.connect(self.zoomTo)
        self.iface.addPluginToMenu("MGRS", self.zoomToAction)

        if mgrsOk:
            self.zoomToDialog = MGRSCoordInputDialog(self.iface.mapCanvas(),
                                                     self.iface.mainWindow())
            self.iface.addDockWidget(Qt.TopDockWidgetArea, self.zoomToDialog)
            self.zoomToDialog.hide()
コード例 #2
0
ファイル: mgrstools.py プロジェクト: kailIII/mgrs-tools
class MGRSTools:

    def __init__(self, iface):
        self.iface = iface

    def initGui(self):
        self.mapTool = MGRSMapTool(self.iface.mapCanvas())
        
        self.menu = QMenu(self.iface.mainWindow().menuBar())        
        self.menu.setTitle("MGRS Tools")

        self.toolAction = QAction("MGRS map tool",
                                     self.iface.mainWindow())        
        self.toolAction.triggered.connect(self.setTool)
        self.toolAction.setCheckable(True)
        self.menu.addAction(self.toolAction)

        self.zoomToAction = QAction("Zoom to MGRS coordinate",
                                     self.iface.mainWindow())        
        self.zoomToAction.triggered.connect(self.zoomTo)
        self.menu.addAction(self.zoomToAction)

        menuBar = self.iface.mainWindow().menuBar()
        menuBar.insertMenu(
            self.iface.firstRightStandardMenu().menuAction(), self.menu)

        self.iface.mapCanvas().mapToolSet.connect(self.unsetTool)

        self.zoomTo = MGRSCoordInputDialog(self.iface.mapCanvas(), self.iface.mainWindow())
        self.iface.addDockWidget(Qt.TopDockWidgetArea, self.zoomTo)
        self.zoomTo.hide()

    def zoomTo(self):
        self.zoomTo.show()

    def unsetTool(self, tool):
        try:
            if not isinstance(tool, MGRSMapTool):
                self.toolAction.setChecked(False)
        except:
            pass
            #ignore exceptions thrown when unloading plugin, since map tool class might not exist already


    def setTool(self):
        self.toolAction.setChecked(True)
        self.iface.mapCanvas().setMapTool(self.mapTool)

    def unload(self):
        self.menu.deleteLater()
コード例 #3
0
ファイル: mgrstools.py プロジェクト: tay7-git/mgrs-tools
class MGRSTools:

    def __init__(self, iface):
        self.iface = iface

    def initGui(self):
        self.mapTool = MGRSMapTool(self.iface.mapCanvas())

        mapToolIcon = QIcon(os.path.join(os.path.dirname(__file__), "mgrs.svg"))
        self.toolAction = QAction(mapToolIcon, "MGRS map tool",
                                     self.iface.mainWindow())        
        self.toolAction.triggered.connect(self.setTool)
        self.toolAction.setCheckable(True)
        self.iface.addToolBarIcon(self.toolAction)
        self.iface.addPluginToMenu("MGRS", self.toolAction)

        zoomToIcon = QIcon(':/images/themes/default/mActionZoomIn.svg')
        self.zoomToAction = QAction(zoomToIcon, "Zoom to MGRS coordinate",
                                     self.iface.mainWindow())        
        self.zoomToAction.triggered.connect(self.zoomTo)
        self.iface.addPluginToMenu("MGRS", self.zoomToAction)

        self.iface.mapCanvas().mapToolSet.connect(self.unsetTool)

        self.zoomTo = MGRSCoordInputDialog(self.iface.mapCanvas(), self.iface.mainWindow())
        self.iface.addDockWidget(Qt.TopDockWidgetArea, self.zoomTo)
        self.zoomTo.hide()

    def zoomTo(self):
        self.zoomTo.show()

    def unsetTool(self, tool):
        try:
            if not isinstance(tool, MGRSMapTool):
                self.toolAction.setChecked(False)
        except:
            pass
            #ignore exceptions thrown when unloading plugin, since map tool class might not exist already


    def setTool(self):
        self.toolAction.setChecked(True)
        self.iface.mapCanvas().setMapTool(self.mapTool)

    def unload(self):
        self.iface.mapCanvas().unsetMapTool(self.mapTool)
        self.iface.removeToolBarIcon(self.toolAction)
        self.iface.removePluginMenu("MGRS", self.toolAction)
        self.iface.removePluginMenu("MGRS", self.zoomToAction)
コード例 #4
0
ファイル: mgrstools.py プロジェクト: kailIII/mgrs-tools
    def initGui(self):
        self.mapTool = MGRSMapTool(self.iface.mapCanvas())
        
        self.menu = QMenu(self.iface.mainWindow().menuBar())        
        self.menu.setTitle("MGRS Tools")

        self.toolAction = QAction("MGRS map tool",
                                     self.iface.mainWindow())        
        self.toolAction.triggered.connect(self.setTool)
        self.toolAction.setCheckable(True)
        self.menu.addAction(self.toolAction)

        self.zoomToAction = QAction("Zoom to MGRS coordinate",
                                     self.iface.mainWindow())        
        self.zoomToAction.triggered.connect(self.zoomTo)
        self.menu.addAction(self.zoomToAction)

        menuBar = self.iface.mainWindow().menuBar()
        menuBar.insertMenu(
            self.iface.firstRightStandardMenu().menuAction(), self.menu)

        self.iface.mapCanvas().mapToolSet.connect(self.unsetTool)

        self.zoomTo = MGRSCoordInputDialog(self.iface.mapCanvas(), self.iface.mainWindow())
        self.iface.addDockWidget(Qt.TopDockWidgetArea, self.zoomTo)
        self.zoomTo.hide()
コード例 #5
0
ファイル: mgrstools.py プロジェクト: tay7-git/mgrs-tools
    def initGui(self):
        self.mapTool = MGRSMapTool(self.iface.mapCanvas())

        mapToolIcon = QIcon(os.path.join(os.path.dirname(__file__), "mgrs.svg"))
        self.toolAction = QAction(mapToolIcon, "MGRS map tool",
                                     self.iface.mainWindow())        
        self.toolAction.triggered.connect(self.setTool)
        self.toolAction.setCheckable(True)
        self.iface.addToolBarIcon(self.toolAction)
        self.iface.addPluginToMenu("MGRS", self.toolAction)

        zoomToIcon = QIcon(':/images/themes/default/mActionZoomIn.svg')
        self.zoomToAction = QAction(zoomToIcon, "Zoom to MGRS coordinate",
                                     self.iface.mainWindow())        
        self.zoomToAction.triggered.connect(self.zoomTo)
        self.iface.addPluginToMenu("MGRS", self.zoomToAction)

        self.iface.mapCanvas().mapToolSet.connect(self.unsetTool)

        self.zoomTo = MGRSCoordInputDialog(self.iface.mapCanvas(), self.iface.mainWindow())
        self.iface.addDockWidget(Qt.TopDockWidgetArea, self.zoomTo)
        self.zoomTo.hide()
コード例 #6
0
class MGRSTools:
    def __init__(self, iface):
        self.iface = iface
        try:
            from tests import testerplugin
            from qgistester.tests import addTestModule
            addTestModule(testerplugin, "MGRS tools")
        except:
            pass

    def initGui(self):
        if mgrsOk:
            self.mapTool = MGRSMapTool(self.iface.mapCanvas())
            self.iface.mapCanvas().mapToolSet.connect(self.unsetTool)

        mapToolIcon = QIcon(os.path.join(os.path.dirname(__file__),
                                         "mgrs.svg"))
        self.toolAction = QAction(mapToolIcon, "MGRS map tool",
                                  self.iface.mainWindow())
        self.toolAction.triggered.connect(self.setTool)
        self.toolAction.setCheckable(True)
        self.iface.addToolBarIcon(self.toolAction)
        self.iface.addPluginToMenu("MGRS", self.toolAction)

        zoomToIcon = QIcon(':/images/themes/default/mActionZoomIn.svg')
        self.zoomToAction = QAction(zoomToIcon, "Zoom to MGRS coordinate",
                                    self.iface.mainWindow())
        self.zoomToAction.triggered.connect(self.zoomTo)
        self.iface.addPluginToMenu("MGRS", self.zoomToAction)

        if mgrsOk:
            self.zoomToDialog = MGRSCoordInputDialog(self.iface.mapCanvas(),
                                                     self.iface.mainWindow())
            self.iface.addDockWidget(Qt.TopDockWidgetArea, self.zoomToDialog)
            self.zoomToDialog.hide()

    def zoomTo(self):
        if mgrsOk:
            self.zoomToDialog.show()
        else:
            QMessageBox.warning(
                self.iface.mainWindow(), "MRGS Tools",
                "Cannot load mgrs library.\nOnly OSX and Win32 systems supported."
            )

    def unsetTool(self, tool):
        try:
            if not isinstance(tool, MGRSMapTool):
                self.toolAction.setChecked(False)
        except:
            pass
            #ignore exceptions thrown when unloading plugin, since map tool class might not exist already

    def setTool(self):
        if mgrsOk:
            self.toolAction.setChecked(True)
            self.iface.mapCanvas().setMapTool(self.mapTool)
        else:
            QMessageBox.warning(
                self.iface.mainWindow(), "MRGS Tools",
                "Cannot load mgrs library.\nOnly OSX and Win32 systems supported."
            )

    def unload(self):
        if mgrsOk:
            self.iface.mapCanvas().unsetMapTool(self.mapTool)
            self.iface.removeDockWidget(self.zoomToDialog)
            self.zoomToDialog = None
        self.iface.removeToolBarIcon(self.toolAction)
        self.iface.removePluginMenu("MGRS", self.toolAction)
        self.iface.removePluginMenu("MGRS", self.zoomToAction)