def initGui(self): # Create action that will start plugin configuration self.action = QAction(QIcon(":/plugins/wps/images/wps-add.png"), "WPS-Client", self.iface.mainWindow()) QObject.connect(self.action, SIGNAL("triggered()"), self.run) self.actionAbout = QAction("About", self.iface.mainWindow()) QObject.connect(self.actionAbout, SIGNAL("triggered()"), self.doAbout) # Add toolbar button and menu item self.iface.addToolBarIcon(self.action) if hasattr(self.iface, "addPluginToWebMenu"): self.iface.addPluginToWebMenu("WPS-Client", self.action) self.iface.addPluginToWebMenu("WPS-Client", self.actionAbout) else: self.iface.addPluginToMenu("WPS", self.action) self.iface.addPluginToWebMenu("WPS", self.action) self.myDockWidget = QgsWpsDockWidget(self.iface) self.myDockWidget.setWindowTitle('WPS') self.iface.addDockWidget(Qt.LeftDockWidgetArea, self.myDockWidget) self.myDockWidget.show() if PROCESSING_SUPPORT: self.provider = WpsAlgorithmProvider(self.myDockWidget) else: self.provider = None if self.provider: try: Processing.addProvider(self.provider, True) #Force tree update except TypeError: Processing.addProvider(self.provider)
def initGui(self): icon = QtGui.QIcon(os.path.dirname(__file__) + "/images/geoserver.png") self.explorerAction = QtGui.QAction(icon, "GeoServer Explorer", self.iface.mainWindow()) self.explorerAction.triggered.connect(self.openExplorer) self.iface.addPluginToWebMenu(u"GeoServer", self.explorerAction) settings = QtCore.QSettings() self.explorer = GeoServerExplorer() self.iface.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.explorer) if not settings.value("/GeoServer/Settings/General/ExplorerVisible", False, bool): self.explorer.hide() self.explorer.visibilityChanged.connect( self._explorerVisibilityChanged) icon = QtGui.QIcon(os.path.dirname(__file__) + "/images/config.png") self.configAction = QtGui.QAction(icon, "GeoServer Explorer settings", self.iface.mainWindow()) self.configAction.triggered.connect(self.openSettings) self.iface.addPluginToWebMenu(u"GeoServer", self.configAction) icon = QtGui.QIcon(os.path.dirname(__file__) + "/images/help.png") self.helpAction = QtGui.QAction(icon, "GeoServer Explorer help", self.iface.mainWindow()) self.helpAction.triggered.connect(self.showHelp) self.iface.addPluginToWebMenu(u"GeoServer", self.helpAction) if processingOk: Processing.addProvider(self.provider) layerwatcher.connectLayerWasAdded(self.explorer)
def initGui(self): """Create the menu entries and toolbar icons inside the QGIS GUI.""" """ icon_path = ':/plugins/dzetsaka/img/icon.png' self.add_action( icon_path, text=self.tr(u'dzetsaka : Classification tool'), callback=self.loadWidget, parent=self.iface.mainWindow()) """ # add icon to toolbar self.add_action(':/plugins/dzetsaka/img/icon.png', text=self.tr(u'dzetsaka'), callback=self.loadWidget, parent=self.iface.mainWindow()) # load in processing Processing.addProvider(self.provider) # load default classification widget self.loadWidget() # load dzetsaka menu self.loadMenu()
def __init__(self, iface): """Constructor. :param iface: An interface instance that will be passed to this class which provides the hook by which you can manipulate the QGIS application at run time. :type iface: QgsInterface """ # Save reference to the QGIS interface self.iface = iface # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale = QSettings().value("locale/userLocale")[0:2] locale_path = os.path.join( self.plugin_dir, 'i18n', 'QuickOSM_{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) #Add to processing self.provider = QuickOSMAlgorithmProvider() Processing.addProvider(self.provider, True)
def __init__(self, iface): self.iface = iface self.plugin_dir = dirname(__file__) # initialize locale locale = QSettings().value("locale/userLocale")[0:2] locale_path = join( self.plugin_dir, 'i18n', 'GeoHealth_{}.qm'.format(locale)) if exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': # noinspection PyCallByClass,PyTypeChecker,PyArgumentList QCoreApplication.installTranslator(self.translator) self.plugin_menu = None self.geohealth_menu = None self.main_action = None self.xy_action = None self.blur_action = None self.incidence_action = None self.density_action = None self.histogram_action = None # Add to processing self.provider = Provider() Processing.addProvider(self.provider, True)
def initGui(self): icon = QtGui.QIcon(os.path.dirname(__file__) + "/images/geoserver.png") self.explorerAction = QtGui.QAction(icon, "GeoServer Explorer", self.iface.mainWindow()) self.explorerAction.triggered.connect(self.openExplorer) self.iface.addPluginToWebMenu(u"GeoServer", self.explorerAction) settings = QtCore.QSettings() self.explorer = GeoServerExplorer() self.iface.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.explorer) if not settings.value("/GeoServer/Settings/General/ExplorerVisible", False, bool): self.explorer.hide() self.explorer.visibilityChanged.connect(self._explorerVisibilityChanged) icon = QtGui.QIcon(os.path.dirname(__file__) + "/images/config.png") self.configAction = QtGui.QAction(icon, "GeoServer Explorer settings", self.iface.mainWindow()) self.configAction.triggered.connect(self.openSettings) self.iface.addPluginToWebMenu(u"GeoServer", self.configAction) icon = QtGui.QIcon(os.path.dirname(__file__) + "/images/help.png") self.helpAction = QtGui.QAction(icon, "GeoServer Explorer help", self.iface.mainWindow()) self.helpAction.triggered.connect(self.showHelp) self.iface.addPluginToWebMenu(u"GeoServer", self.helpAction) Processing.addProvider(self.provider) layerwatcher.connectLayerWasAdded(self.explorer)
def __init__(self, iface): self.iface = iface self.plugin_dir = dirname(__file__) # initialize locale locale = QSettings().value("locale/userLocale")[0:2] locale_path = join(self.plugin_dir, 'i18n', 'GeoHealth_{}.qm'.format(locale)) if exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': # noinspection PyCallByClass,PyTypeChecker,PyArgumentList QCoreApplication.installTranslator(self.translator) self.plugin_menu = None self.geohealth_menu = None self.main_action = None self.xy_action = None self.blur_action = None self.incidence_action = None self.density_action = None self.histogram_action = None # Add to processing self.provider = Provider() Processing.addProvider(self.provider, True)
def initGui(self): mapToolIcon = QIcon(os.path.join(os.path.dirname(__file__), "w3w.png")) self.toolAction = QAction(mapToolIcon, "what3words map tool", self.iface.mainWindow()) self.toolAction.triggered.connect(self.setTool) self.toolAction.setCheckable(True) self.iface.addToolBarIcon(self.toolAction) self.iface.addPluginToMenu("what3words", self.toolAction) zoomToIcon = QIcon(':/images/themes/default/mActionZoomIn.svg') self.zoomToAction = QAction(zoomToIcon, "Zoom to 3 word address", self.iface.mainWindow()) self.zoomToAction.triggered.connect(self.zoomTo) self.iface.addPluginToMenu("what3words", self.zoomToAction) self.apikeyAction = QAction("Set API key", self.iface.mainWindow()) self.apikeyAction.triggered.connect(askForApiKey) self.iface.addPluginToMenu("what3words", self.apikeyAction) self.iface.mapCanvas().mapToolSet.connect(self.unsetTool) self.zoomToDialog = W3WCoordInputDialog(self.iface.mapCanvas(), self.iface.mainWindow()) self.iface.addDockWidget(Qt.TopDockWidgetArea, self.zoomToDialog) self.zoomToDialog.hide() if processingOk: Processing.addProvider(self.provider)
def initGui(self): # Create action that will start plugin configuration self.action = QAction( QIcon(":/resources/icon"), u"Blurring", self.iface.mainWindow()) # connect the action to the run method self.action.triggered.connect(self.run) # Add toolbar button and menu item self.iface.addToolBarIcon(self.action) self.iface.addPluginToVectorMenu(u"&Blurring", self.action) #Variables self.mapLayerRegistry = QgsMapLayerRegistry.instance() #Height and widht self.minWidth = 425 self.maxWidth = 786 self.height = 357 #Connectors QObject.connect(self.dlg.checkBox_envelope, SIGNAL("clicked()"), self.enableEnvelope) QObject.connect(self.dlg.pushButton_help, SIGNAL("clicked()"), self.displayHelp) QObject.connect(self.dlg.pushButton_browseFolder, SIGNAL('clicked()'), self.selectFile) QObject.connect(self.dlg.pushButton_ok, SIGNAL("clicked()"), self.compute) QObject.connect(self.dlg.pushButton_cancel, SIGNAL("clicked()"), self.cancel) QObject.connect(self.dlg.pushButton_advanced, SIGNAL("clicked()"), self.advanced) QObject.connect(QgsMapLayerRegistry.instance(), SIGNAL("layerRemoved(QString)"), self.layerDeleted) QObject.connect(QgsMapLayerRegistry.instance(), SIGNAL("layerWasAdded(QgsMapLayer*)"), self.layerAdded) #Add the plugin to processing Processing.addProvider(self.provider, True)
def initGui(self): """Create the menu entries and toolbar icons inside the QGIS GUI.""" self.push_action = self.add_action(':/plugins/qfieldsync/refresh.png', text=self.tr(u'Package for QField'), callback=self.show_package_dialog, parent=self.iface.mainWindow()) self.add_action(':/plugins/qfieldsync/refresh-reverse.png', text=self.tr(u'Synchronize from QField'), callback=self.show_synchronize_dialog, parent=self.iface.mainWindow()) self.add_action(':/plugins/qfieldsync/icon.png', text=self.tr(u'Project Configuration'), callback=self.show_project_configuration_dialog, parent=self.iface.mainWindow(), add_to_toolbar=False) self.add_action(':/plugins/qfieldsync/icon.png', text=self.tr(u'Preferences'), callback=self.show_preferences_dialog, parent=self.iface.mainWindow(), add_to_toolbar=False) self.processing_provider = QFieldProcessingProvider() Processing.addProvider(self.processing_provider) self.update_button_enabled_status()
def initGui(self): self.mapTool = MGRSMapTool(self.iface.mapCanvas()) self.iface.mapCanvas().mapToolSet.connect(self.unsetTool) self.toolAction = QAction(QIcon(os.path.join(pluginPath, 'icons', 'mgrs.svg')), 'MGRS map tool', self.iface.mainWindow()) self.toolAction.setCheckable(True) self.iface.addToolBarIcon(self.toolAction) self.iface.addPluginToMenu('MGRS', self.toolAction) self.toolAction.triggered.connect(self.setTool) zoomToIcon = QIcon(':/images/themes/default/mActionZoomIn.svg') self.zoomToAction = QAction(zoomToIcon, 'Zoom to MGRS coordinate', self.iface.mainWindow()) self.iface.addPluginToMenu('MGRS', self.zoomToAction) self.zoomToAction.triggered.connect(self.zoomTo) addHelpMenu("MGRS", self.iface.addPluginToMenu) addAboutMenu("MGRS", self.iface.addPluginToMenu) self.mgrsDock = MgrsDockWidget(self.iface.mapCanvas(), self.iface.mainWindow()) self.iface.addDockWidget(Qt.TopDockWidgetArea, self.mgrsDock) self.mgrsDock.hide() if processingOk: Processing.addProvider(self.provider) try: from lessons import addLessonsFolder, addGroup folder = os.path.join(os.path.dirname(__file__), "_lessons") addLessonsFolder(folder, "MGRS tools") except: pass
def initGui(self): """Create the menu entries and toolbar icons inside the QGIS GUI.""" icon_path = ':/plugins/PostTelemac/icons/posttelemac.png' self.add_action( icon_path, text=self.tr(u'PostTelemac'), callback=self.run, parent=self.iface.mainWindow()) self.add_action( icon_path, text=self.tr(u'PostTelemac Help'), add_to_toolbar=False, callback=self.showHelp, parent=self.iface.mainWindow()) self.add_action( icon_path, text=self.tr(u'PostTelemac About'), add_to_toolbar=False, callback=self.showAbout, parent=self.iface.mainWindow()) #Processing thing if DOPROCESSING : Processing.addProvider(self.provider)
def initGui(self): Processing.addProvider(self.processing_provider, updateList=True) self.action = QAction(QIcon(':plugins/qgisconefor/assets/icon.png'), self._plugin_name, self.iface.mainWindow()) QObject.connect(self.action, SIGNAL('triggered()'), self.run) self.iface.addPluginToVectorMenu('&%s' % self._plugin_name, self.action) self.iface.addVectorToolBarIcon(self.action)
def initGui(self): Processing.addProvider(self.provider) self.action = QAction(QIcon(":/plugins/qgis2web/icons/qgis2web.png"), u"Create web map", self.iface.mainWindow()) self.action.triggered.connect(self.run) self.iface.addPluginToWebMenu(u"&qgis2web", self.action) self.iface.addToolBarIcon(self.action)
def initGui(self): """Create the menu entries and toolbar icons inside the QGIS GUI.""" icon_path = ':/plugins/urbanPlannersNetworkAnalysis/icon.png' self.add_action(icon_path, text=self.tr(u'Urban Planners Network Analysis'), callback=self.run, parent=self.iface.mainWindow()) Processing.addProvider(self.provider)
def initGui(self): Processing.addProvider(self.provider) self.profilAction = QAction(QIcon(os.path.dirname(__file__) + "/icons/iconProvider.png"), "Ajouter un profil", self.iface.mainWindow()) self.profilAction.setObjectName("dirnoAction") self.profilAction.setWhatsThis("Dirno plugin") self.profilAction.setStatusTip("This is status tip") #QObject.connect(self.profilAction, SIGNAL("triggered()"), self.run) # add toolbar button and menu item #self.iface.addToolBarIcon(self.profilAction) self.iface.addPluginToMenu("&Dirno scripts", self.profilAction) self.profilAction.triggered.connect(self.launchDirnoAlgorithProfilDialog)
def __init__(self, iface): """Constructor. :param iface: An interface instance that will be passed to this class which provides the hook by which you can manipulate the QGIS application at run time. :type iface: QgsInterface """ # Save reference to the QGIS interface self.iface = iface setup_logger('QuickOSM') # initialize plugin directory self.plugin_dir = dirname(__file__) # initialize locale locale = QSettings().value('locale/userLocale')[0:2] locale_path = join( self.plugin_dir, 'i18n', 'QuickOSM_{0}.qm'.format(locale)) if exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': # noinspection PyTypeChecker QCoreApplication.installTranslator(self.translator) # Create the folder if it does not exist. get_user_query_folder(over_write=True) # Add to processing self.provider = QuickOSMAlgorithmProvider() Processing.addProvider(self.provider, True) # Add the toolbar self.toolbar = self.iface.addToolBar('QuickOSM') self.toolbar.setObjectName('QuickOSM') self.quickosm_menu = None self.dock_menu = None self.vector_menu = None self.mainWindowAction = None self.osmFileAction = None self.osmFileDockWidget = None self.myQueriesAction = None self.myQueriesDockWidget = None self.queryAction = None self.queryDockWidget = None self.quickQueryAction = None self.quickQueryDockWidget = None
def initGui(self): # Create action that will start plugin configuration self.action = QAction( QIcon(":/plugins/bufferbypercentage/icon.svg"), "Buffer by percentage", self.iface.mainWindow()) # connect the action to the run method self.action.triggered.connect(self.run) # Add toolbar button and menu item self.iface.addToolBarIcon(self.action) self.iface.addPluginToVectorMenu("&Buffer by Percentage", self.action) Processing.addProvider(self.provider)
def initGui(self): # Create action that will start plugin configuration self.action = QAction( QIcon(":/plugins/interlis/icon.png"), u"Interlis", self.iface.mainWindow()) # connect the action to the run method self.action.triggered.connect(self.run) # Add toolbar button and menu item self.iface.addToolBarIcon(self.action) self.iface.addPluginToMenu(u"&Interlis", self.action) Processing.addProvider(self.provider)
def __init__(self, iface): """Constructor. :param iface: An interface instance that will be passed to this class which provides the hook by which you can manipulate the QGIS application at run time. :type iface: QgsInterface """ # Save reference to the QGIS interface self.iface = iface # initialize plugin directory self.plugin_dir = dirname(__file__) # initialize locale locale = QSettings().value('locale/userLocale')[0:2] locale_path = join( self.plugin_dir, 'i18n', 'QuickOSM_{0}.qm'.format(locale)) if exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': # noinspection PyTypeChecker QCoreApplication.installTranslator(self.translator) # Create the folder if it does not exist. get_user_query_folder(over_write=True) # Add to processing self.provider = QuickOSMAlgorithmProvider() Processing.addProvider(self.provider, True) # Add the toolbar self.toolbar = self.iface.addToolBar('QuickOSM') self.toolbar.setObjectName('QuickOSM') self.quickosm_menu = None self.dock_menu = None self.web_menu = None self.mainWindowAction = None self.osmFileAction = None self.osmFileDockWidget = None self.myQueriesAction = None self.myQueriesDockWidget = None self.queryAction = None self.queryDockWidget = None self.quickQueryAction = None self.quickQueryDockWidget = None
def initGui(self): Processing.addProvider(self.provider) self.action = QAction( QIcon(":/plugins/squad-plugin/SQUAD_icon_v2_32x32.png"), "SQUAD plugin", self.iface.mainWindow()) self.action.setObjectName("squadAction") self.action.setWhatsThis("Spatial Quality and Anomalies Diagnosis") self.action.setStatusTip("...") QObject.connect(self.action, SIGNAL("triggered()"), self.run) # add toolbar button and menu item self.iface.addToolBarIcon(self.action) self.iface.addPluginToMenu("&SQUAD", self.action)
def initGui(self): self.actions.append( QAction(QIcon(os.path.dirname(__file__) + "/timeplot.svg"), u"timeplot", self.iface.mainWindow())) self.actions[-1].setWhatsThis("timeplot") self.actions[-1].triggered.connect(self.timeplot) for a in self.actions: self.iface.addToolBarIcon(a) self.epanetAlgoProvider = EpanetAlgorithmProvider() Processing.addProvider(self.epanetAlgoProvider, True) QgsMapLayerRegistry.instance().layersAdded.connect(self.layerAdded)
def initGui(self): self.actions.append( QAction( QIcon(os.path.dirname(__file__) + "/timeplot.svg"), u"timeplot", self.iface.mainWindow()) ) self.actions[-1].setWhatsThis("timeplot") self.actions[-1].triggered.connect(self.timeplot) for a in self.actions: self.iface.addToolBarIcon(a) self.epanetAlgoProvider = EpanetAlgorithmProvider() Processing.addProvider(self.epanetAlgoProvider, True) QgsMapLayerRegistry.instance().layersAdded.connect( self.layerAdded )
def initGui(self): """ Create action that will start plugin configuration """ self.action = QAction( QIcon(":/plugins/atmCorrection/icon.png"), u"Atmospheric Correction", self.iface.mainWindow()) # connect the action to the run method self.action.triggered.connect(self.run) # Add toolbar button and menu item self.iface.addToolBarIcon(self.action) self.iface.addPluginToVectorMenu(u"&Atmospheric Correction", self.action) # Add algorithms to Processing Toolbox Processing.addProvider(self.provider)
def initGui(self): ''' Here wew add the main menu entry, used to enable the map tool to capture coordinates ''' mapToolIcon = QIcon( os.path.join(os.path.dirname(__file__), "icons", "w3w.png")) self.toolAction = QAction(mapToolIcon, "what3words map tool", iface.mainWindow()) self.toolAction.triggered.connect(self.setTool) #checkable = true, so it indicates whether the maptool is active or not self.toolAction.setCheckable(True) iface.addToolBarIcon(self.toolAction) iface.addPluginToMenu("what3words", self.toolAction) '''And here we add another tool to zoom to a w3w address''' zoomToIcon = QIcon(':/images/themes/default/mActionZoomIn.svg') self.zoomToAction = QAction(zoomToIcon, "Zoom to 3 word address", iface.mainWindow()) self.zoomToAction.triggered.connect(self.zoomTo) iface.addPluginToMenu("what3words", self.zoomToAction) #Standard plugin menus provided by the qgiscommons library addSettingsMenu("what3words", iface.addPluginToMenu) addHelpMenu("what3words", iface.addPluginToMenu) addAboutMenu("what3words", iface.addPluginToMenu) ''' This plugin uses a maptool. When another maptool is selected, our plugin maptool will be disconnected, and we need to update the menu entry, so it does not show itself as enabled. When the new tool is set, it will fire a signal. We connect it to our unsetTool method, which will handle this. ''' iface.mapCanvas().mapToolSet.connect(self.unsetTool) ''' We use a docked widget. We create it here and hide it, so when it is called by the user, it is just set to visible and will be displayed in its corresponding location in the app window. ''' self.zoomToDialog = W3WCoordInputDialog(iface.mapCanvas(), iface.mainWindow()) iface.addDockWidget(Qt.TopDockWidgetArea, self.zoomToDialog) self.zoomToDialog.hide() '''Add the Processing provider if Processing is availabel and loaded''' if processingOk: Processing.addProvider(self.provider)
def initSextante(self): # Try to import Sextante try: from processing.core.Processing import Processing except ImportError: self.sex_load = False if self.sex_load: # Add folder to sys.path cmd_folder = os.path.split(inspect.getfile( inspect.currentframe() ))[0] if cmd_folder not in sys.path: sys.path.insert(0, cmd_folder) # Load Lecos Sextante Provider from lecos_sextanteprov import LecoSAlgorithmsProv self.provider = LecoSAlgorithmsProv() # Load LecoS Algorithm Provider Processing.addProvider(self.provider,updateList=True)
def initGui(self): # Initialize the create shape menu item icon = QIcon(os.path.dirname(__file__) + '/images/shapes.png') self.shapeAction = QAction(icon, u'Create Shapes', self.iface.mainWindow()) self.shapeAction.triggered.connect(self.shapeTool) self.iface.addPluginToVectorMenu(u'Shape Tools', self.shapeAction) self.toolbar.addAction(self.shapeAction) # Initialize the XY to Line menu item icon = QIcon(os.path.dirname(__file__) + '/images/xyline.png') self.xyLineAction = QAction(icon, u'XY to Line', self.iface.mainWindow()) self.xyLineAction.triggered.connect(self.xyLineTool) self.iface.addPluginToVectorMenu(u'Shape Tools', self.xyLineAction) self.toolbar.addAction(self.xyLineAction) # Initialize the Geodesic Densifier menu item icon = QIcon(os.path.dirname(__file__) + '/images/geodesicDensifier.png') self.geodesicDensifyAction = QAction(icon, u'Geodesic Shape Densifier', self.iface.mainWindow()) self.geodesicDensifyAction.triggered.connect(self.geodesicDensifyTool) self.iface.addPluginToVectorMenu(u'Shape Tools', self.geodesicDensifyAction) self.toolbar.addAction(self.geodesicDensifyAction) # Initialize Geodesic Measure Tool self.geodesicMeasureTool = GeodesicMeasureTool(self.iface, self.iface.mainWindow()) self.canvas.mapToolSet.connect(self.unsetTool) icon = QIcon(os.path.dirname(__file__) + '/images/measure.png') self.measureAction = QAction(icon, u'Geodesic Measure Tool', self.iface.mainWindow()) self.measureAction.triggered.connect(self.measureTool) self.measureAction.setCheckable(True) self.iface.addPluginToVectorMenu(u'Shape Tools', self.measureAction) self.toolbar.addAction(self.measureAction) # Settings icon = QIcon(os.path.dirname(__file__) + '/images/settings.png') self.settingsAction = QAction(icon, u'Settings', self.iface.mainWindow()) self.settingsAction.triggered.connect(self.settings) self.iface.addPluginToVectorMenu(u'Shape Tools', self.settingsAction) # Help icon = QIcon(os.path.dirname(__file__) + '/images/help.png') self.helpAction = QAction(icon, u'Shape Tools Help', self.iface.mainWindow()) self.helpAction.triggered.connect(self.help) self.iface.addPluginToVectorMenu(u'Shape Tools', self.helpAction) if processingOk: Processing.addProvider(self.provider)
def initSextante(self): # Try to import Sextante try: from processing.core.Processing import Processing except ImportError: self.sex_load = False if self.sex_load: # Add folder to sys.path cmd_folder = os.path.split(inspect.getfile( inspect.currentframe() ))[0] if cmd_folder not in sys.path: sys.path.insert(0, cmd_folder) # Load Lecos Sextante Provider from lecos_sextanteprov import LecoSAlgorithmsProv self.provider = LecoSAlgorithmsProv() # Load LecoS Algorithm Provider Processing.addProvider(self.provider)
def initGui(self): icon = QtGui.QIcon(os.path.dirname(__file__) + "/images/geoserver.png") self.explorerAction = QtGui.QAction(icon, "GeoServer Explorer", self.iface.mainWindow()) self.explorerAction.triggered.connect(self.openExplorer) self.iface.addPluginToWebMenu(u"GeoServer", self.explorerAction) self.explorer = GeoServerExplorer() self.iface.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.explorer) if not pluginSetting("ExplorerVisible"): self.explorer.hide() self.explorer.visibilityChanged.connect(self._explorerVisibilityChanged) addSettingsMenu("GeoServer", self.iface.addPluginToWebMenu) addHelpMenu("GeoServer", self.iface.addPluginToWebMenu) addAboutMenu("GeoServer", self.iface.addPluginToWebMenu) if processingOk: Processing.addProvider(self.provider) layerwatcher.connectLayerWasAdded(self.explorer)
def initGui(self): mapToolIcon = QIcon(os.path.join(os.path.dirname(__file__), "icons", "w3w.png")) self.toolAction = QAction(mapToolIcon, "what3words map tool", self.iface.mainWindow()) self.toolAction.triggered.connect(self.setTool) self.toolAction.setCheckable(True) self.iface.addToolBarIcon(self.toolAction) self.iface.addPluginToMenu("what3words", self.toolAction) zoomToIcon = QIcon(':/images/themes/default/mActionZoomIn.svg') self.zoomToAction = QAction(zoomToIcon, "Zoom to 3 word address", self.iface.mainWindow()) self.zoomToAction.triggered.connect(self.zoomTo) self.iface.addPluginToMenu("what3words", self.zoomToAction) addSettingsMenu( "what3words", self.iface.addPluginToMenu) addHelpMenu( "what3words", self.iface.addPluginToMenu) addAboutMenu( "what3words", self.iface.addPluginToMenu) self.iface.mapCanvas().mapToolSet.connect(self.unsetTool) self.zoomToDialog = W3WCoordInputDialog(self.iface.mapCanvas(), self.iface.mainWindow()) self.iface.addDockWidget(Qt.TopDockWidgetArea, self.zoomToDialog) self.zoomToDialog.hide() if processingOk: Processing.addProvider(self.provider) try: from lessons import addLessonsFolder, addGroup folder = os.path.join(os.path.dirname(__file__), "_lessons") addLessonsFolder(folder, "what3words") except: pass
def initGui(self): if processing_installed: Processing.addProvider(self.provider)
def initGui(self): Processing.addProvider(self.provider)
def initGui(self): # Create action that will show the about page self.aboutAction = QAction( QIcon(":/plugins/crayfish/images/crayfish.png"), "About", self.iface.mainWindow()) QObject.connect(self.aboutAction, SIGNAL("triggered()"), self.about) # Create action for upload self.uploadAction = QAction( QIcon(":/plugins/illuvis/illuvis_u_32w.png"), "Upload to illuvis ...", self.iface.mainWindow()) QObject.connect(self.uploadAction, SIGNAL("triggered()"), self.upload) # Add menu items self.menu = self.iface.pluginMenu().addMenu( QIcon(":/plugins/crayfish/images/crayfish.png"), "Crayfish") self.menu.addAction(self.aboutAction) self.menu.addAction(self.uploadAction) if not ensure_library_installed(): return self.crayfishLibFound = True # Create action that will load a layer to view self.action = QAction( QIcon(":/plugins/crayfish/images/crayfish_viewer_add_layer.png"), "Add Crayfish Layer", self.iface.mainWindow()) QObject.connect(self.action, SIGNAL("triggered()"), self.addCrayfishLayer) self.actionExportGrid = QAction( QIcon(":/plugins/crayfish/images/crayfish_export_raster.png"), "Export to Raster Grid ...", self.iface.mainWindow()) QObject.connect(self.actionExportGrid, SIGNAL("triggered()"), self.exportGrid) self.actionExportContours = QAction( QIcon(":/plugins/crayfish/images/contour.png"), "Export Contours ...", self.iface.mainWindow()) QObject.connect(self.actionExportContours, SIGNAL("triggered()"), self.exportContours) self.actionExportAnimation = QAction( QIcon(":/plugins/crayfish/images/icon_video.png"), "Export Animation ...", self.iface.mainWindow()) QObject.connect(self.actionExportAnimation, SIGNAL("triggered()"), self.exportAnimation) self.actionPlot = QAction( QgsApplication.getThemeIcon("/histogram.png"), "Plot", self.iface.mainWindow()) self.actionHelp = QAction( QgsApplication.getThemeIcon("/mActionHelpContents.svg"), "Help", self.iface.mainWindow()) QObject.connect(self.actionHelp, SIGNAL("triggered()"), self.help) # Add toolbar button and menu item layerTB = self.iface.layerToolBar() layerTB.insertAction(self.iface.actionAddPgLayer(), self.action) # Add menu item self.menu.addAction(self.action) self.menu.addAction(self.actionExportGrid) self.menu.addAction(self.actionExportContours) self.menu.addAction(self.actionExportAnimation) self.menu.addAction(self.actionPlot) self.menu.addAction(self.actionHelp) # Register plugin layer type self.lt = CrayfishPluginLayerType() QgsPluginLayerRegistry.instance().addPluginLayerType(self.lt) # Register actions for context menu self.iface.legendInterface().addLegendLayerAction( self.actionExportGrid, '', '', QgsMapLayer.PluginLayer, False) self.iface.legendInterface().addLegendLayerAction( self.actionExportContours, '', '', QgsMapLayer.PluginLayer, False) self.iface.legendInterface().addLegendLayerAction( self.uploadAction, '', '', QgsMapLayer.PluginLayer, False) self.iface.legendInterface().addLegendLayerAction( self.actionExportAnimation, '', '', QgsMapLayer.PluginLayer, False) # Make connections QObject.connect(self.lr, SIGNAL("layersWillBeRemoved(QStringList)"), self.layersRemoved) QObject.connect(self.lr, SIGNAL("layerWillBeRemoved(QString)"), self.layerRemoved) QObject.connect(self.lr, SIGNAL("layerWasAdded(QgsMapLayer*)"), self.layerWasAdded) # Create the dock widget self.dock = CrayfishDock(self.iface) self.iface.addDockWidget(Qt.LeftDockWidgetArea, self.dock) self.dock.hide() # do not show the dock by default QObject.connect(self.dock, SIGNAL("visibilityChanged(bool)"), self.dockVisibilityChanged) custom_actions = [ self.actionExportGrid, self.actionExportContours, self.uploadAction, self.actionExportAnimation ] self.dock.treeDataSets.setCustomActions(custom_actions) self.actionPlot.triggered.connect(self.dock.plot) # Register data items provider (if possible - since 2.10) self.dataItemsProvider = None if 'QgsDataItemProvider' in globals(): self.dataItemsProvider = CrayfishDataItemProvider() QgsDataItemProviderRegistry.instance().addProvider( self.dataItemsProvider) # Processing toolbox try: from processing.core.Processing import Processing from .algs import CrayfishProcessingProvider self.processing_provider = CrayfishProcessingProvider() Processing.addProvider(self.processing_provider, updateList=True) except ImportError: pass
def initGui(self): Processing.addProvider(self.provider, updateList=True)
def initGui(self): Processing.addProvider(self.provider) Processing.updateAlgsList() # until a better way is found
def initGui(self): self.algListener = WorkflowAlgListListner(self.provider) Processing.addAlgListListener(self.algListener) Processing.addProvider(self.provider, True)
def __init__(self): self.provider = ProcessingProvider() Processing.addProvider(self.provider, True)
def initGui(self): """ Called to setup the plugin GUI """ self.network_layer_notifier = QgepLayerNotifier( self.iface.mainWindow(), ['vw_network_node', 'vw_network_segment']) self.wastewater_networkelement_layer_notifier = QgepLayerNotifier( self.iface.mainWindow(), ['vw_wastewater_node', 'vw_qgep_reach']) self.toolbarButtons = [] # Create toolbar button self.profileAction = QAction( QIcon(":/plugins/qgepplugin/icons/wastewater-profile.svg"), self.tr("Profile"), self.iface.mainWindow()) self.profileAction.setWhatsThis(self.tr("Reach trace")) self.profileAction.setEnabled(False) self.profileAction.setCheckable(True) self.profileAction.triggered.connect(self.profileToolClicked) self.downstreamAction = QAction( QIcon(":/plugins/qgepplugin/icons/wastewater-downstream.svg"), self.tr("Downstream"), self.iface.mainWindow()) self.downstreamAction.setWhatsThis(self.tr("Downstream reaches")) self.downstreamAction.setEnabled(False) self.downstreamAction.setCheckable(True) self.downstreamAction.triggered.connect(self.downstreamToolClicked) self.upstreamAction = QAction( QIcon(":/plugins/qgepplugin/icons/wastewater-upstream.svg"), self.tr("Upstream"), self.iface.mainWindow()) self.upstreamAction.setWhatsThis(self.tr("Upstream reaches")) self.upstreamAction.setEnabled(False) self.upstreamAction.setCheckable(True) self.upstreamAction.triggered.connect(self.upstreamToolClicked) self.wizardAction = QAction( QIcon(":/plugins/qgepplugin/icons/wizard.svg"), "Wizard", self.iface.mainWindow()) self.wizardAction.setWhatsThis( self.tr("Create new manholes and reaches")) self.wizardAction.setEnabled(False) self.wizardAction.setCheckable(True) self.wizardAction.triggered.connect(self.wizard) self.connectNetworkElementsAction = QAction( QIcon( ":/plugins/qgepplugin/icons/link-wastewater-networkelement.svg" ), QApplication.translate('qgepplugin', 'Connect wastewater networkelements'), self.iface.mainWindow()) self.connectNetworkElementsAction.setEnabled(False) self.connectNetworkElementsAction.setCheckable(True) self.connectNetworkElementsAction.triggered.connect( self.connectNetworkElements) self.refreshNetworkTopologyAction = QAction( QIcon(":/plugins/qgepplugin/icons/refresh-network.svg"), "Refresh network topology", self.iface.mainWindow()) self.refreshNetworkTopologyAction.setWhatsThis( self.tr("Refresh network topology")) self.refreshNetworkTopologyAction.setEnabled(False) self.refreshNetworkTopologyAction.setCheckable(False) self.refreshNetworkTopologyAction.triggered.connect( self.refreshNetworkTopologyActionClicked) self.aboutAction = QAction(self.tr('About'), self.iface.mainWindow()) self.aboutAction.triggered.connect(self.about) self.settingsAction = QAction(self.tr('Settings'), self.iface.mainWindow()) self.settingsAction.triggered.connect(self.showSettings) # Add toolbar button and menu item self.toolbar = QToolBar(QApplication.translate('qgepplugin', 'QGEP')) self.toolbar.addAction(self.profileAction) self.toolbar.addAction(self.upstreamAction) self.toolbar.addAction(self.downstreamAction) self.toolbar.addAction(self.wizardAction) self.toolbar.addAction(self.refreshNetworkTopologyAction) self.toolbar.addAction(self.connectNetworkElementsAction) self.iface.addPluginToMenu("&QGEP", self.profileAction) self.iface.addPluginToMenu("&QGEP", self.settingsAction) self.iface.addPluginToMenu("&QGEP", self.aboutAction) self.iface.addToolBar(self.toolbar) # Local array of buttons to enable / disable based on context self.toolbarButtons.append(self.profileAction) self.toolbarButtons.append(self.upstreamAction) self.toolbarButtons.append(self.downstreamAction) self.toolbarButtons.append(self.wizardAction) self.toolbarButtons.append(self.refreshNetworkTopologyAction) self.network_layer_notifier.layersAvailable.connect( self.onLayersAvailable) self.network_layer_notifier.layersUnavailable.connect( self.onLayersUnavailable) # Init the object maintaining the network self.network_analyzer = QgepGraphManager(self.iface) # Create the map tool for profile selection self.profile_tool = QgepProfileMapTool(self.iface, self.profileAction, self.network_analyzer) self.profile_tool.profileChanged.connect(self.onProfileChanged) self.upstream_tree_tool = QgepTreeMapTool(self.iface, self.upstreamAction, self.network_analyzer) self.upstream_tree_tool.setDirection("upstream") self.upstream_tree_tool.treeChanged.connect(self.onTreeChanged) self.downstream_tree_tool = QgepTreeMapTool(self.iface, self.downstreamAction, self.network_analyzer) self.downstream_tree_tool.setDirection("downstream") self.downstream_tree_tool.treeChanged.connect(self.onTreeChanged) self.maptool_connect_networkelements = QgepMapToolConnectNetworkElements( self.iface, self.connectNetworkElementsAction) self.wastewater_networkelement_layer_notifier.layersAvailableChanged.connect( self.connectNetworkElementsAction.setEnabled) self.processing_provider = QgepProcessingProvider() Processing.addProvider(self.processing_provider)
def qgis_runalg(algorithm, *args, **kwargs): """Run QGIS Processing algorithm Parameters ---------- algorithm : str algorithm name e.g. script:myscript args : positional arguments passed to processing.runalg kwargs : keword arguments passed to processing.runalg Logging ------- if 'logger' in kwargs: write info to that logger. """ # Initialize QGIS and Processing if running as a subprocess # First find paths of QGIS Python libraries and of Processing # Assumes OsGeo4W installation qgisPath = os.path.dirname(os.path.dirname(sys.executable)) qgisPath = os.path.join(qgisPath, "apps", "qgis", "python") sys.path.append(qgisPath) # Check if processing plugin is in the user directory (priority) or # QGIS directory (backup) if os.path.isdir( os.path.join(os.path.expanduser("~"), ".qgis2", "python", "plugins", "processing")): processingPath = os.path.join(os.path.expanduser("~"), ".qgis2", "python", "plugins") else: processingPath = os.path.join(qgisPath, "plugins") sys.path.append(processingPath) # logging logger = kwargs.pop('logger', None) if logger is None: logger = logging.getLogger(__name__) logger.setLevel(logging.DEBUG) # Initialise QGIS from qgis.core import QgsApplication app = QgsApplication([], True) app.setPrefixPath(os.path.dirname(qgisPath)) app.initQgis() # Import Processing import processing from processing.core.Processing import Processing # Initialise Processing Processing.initialize() # Try to add SNAP and BEAM try: from processing_gpf.BEAMAlgorithmProvider import BEAMAlgorithmProvider from processing_gpf.SNAPAlgorithmProvider import SNAPAlgorithmProvider bp = BEAMAlgorithmProvider() sp = SNAPAlgorithmProvider() Processing.addProvider(bp, True) Processing.addProvider(sp, True) logger.debug('Successfully loaded SNAP and BEAM algorithm providers.') except ImportError: logger.debug('SNAP and BEAM not found. These algorithms ' 'will not be available.') pass # Set progress to be displayed in the command prompt progress = CmdProgress() # Run the algorithm return processing.runalg(algorithm, *args, progress=progress, **kwargs)