Beispiel #1
0
    def __init__(self, iface):
        """Constructor.

        :param iface: An interface instance that will be passed to
            this class, providing the hook to manipulate the QGIS
            application at run time.
        :type iface: QgsInterface
        """
        # Save the reference to the QGIS interface
        self.iface = iface

        # initialize the locale
        locale: str = QgsSettings().value("locale/userLocale",
                                          QLocale().name())[0:2]
        locale_path: Path = (
            DIR_PLUGIN_ROOT /
            f"resources/i18n/qgis_resource_sharing_{locale}.qm")

        if locale_path.exists():
            self.translator = QTranslator()
            self.translator.load(str(locale_path.resolve()))
            QCoreApplication.installTranslator(self.translator)

        # Create the dialog (after translation) and keep reference
        self.dlg = ResourceSharingDialog()

        # Declare instance attributes
        self.actions = []
        self.menuName = self.tr("&Resource Sharing")
        # TODO: We may let the user set this up
        self.toolbar = self.iface.addToolBar(self.menuName)
        self.toolbar.setObjectName("Resource Sharing")
    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',
            'SpeciesExplorer_{}.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)

        # Create the dialog (after translation) and keep reference
        self.dlg = SpeciesExplorerDialog()

        # Declare instance attributes
        self.actions = []
        self.menu = self.tr(u'&Species Explorer')
        # TODO: We are going to let the user set this up in a future iteration
        self.toolbar = self.iface.addToolBar(u'SpeciesExplorer')
        self.toolbar.setObjectName(u'SpeciesExplorer')
Beispiel #3
0
    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',
                                   'Nomenclator_{}.qm'.format(locale))

        if os.path.exists(locale_path):
            self.translator = QTranslator()
            self.translator.load(locale_path)
            QCoreApplication.installTranslator(self.translator)

        # Declare instance attributes
        self.actions = []
        self.menu = self.tr(u'&Nomenclator Toponìmic Valencià')
        # TODO: We are going to let the user set this up in a future iteration
        self.toolbar = self.iface.addToolBar(u'Nomenclator')
        self.toolbar.setObjectName(u'Nomenclator')

        #print "** INITIALIZING Nomenclator"

        self.pluginIsActive = False
        self.dockwidget = None
Beispiel #4
0
    def __init__(self, iface):
        self.iface = iface
        self.canvas = iface.mapCanvas()
        self.settingsDialog = None
        self.xyLineDialog = None
        self.geodesicDensifyDialog = None
        self.azDigitizerTool = None
        self.lineDigitizerTool = None
        self.previousLayer = None
        self.toolbar = self.iface.addToolBar('Shape Tools Toolbar')
        self.toolbar.setObjectName('ShapeToolsToolbar')
        self.provider = ShapeToolsProvider()
        # Initialize the plugin path directory
        self.plugin_dir = os.path.dirname(__file__)

        # initialize locale
        try:
            locale = QSettings().value("locale/userLocale", "en",
                                       type=str)[0:2]
        except Exception:
            locale = "en"
        locale_path = os.path.join(self.plugin_dir, 'i18n',
                                   'shapeTools_{}.qm'.format(locale))
        if os.path.exists(locale_path):
            self.translator = QTranslator()
            self.translator.load(locale_path)
            QCoreApplication.installTranslator(self.translator)
Beispiel #5
0
    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
        self.map = self.iface.mapCanvas()
        self.clickTool = QgsMapToolEmitPoint(self.map)
        # 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',
            'ReverseFlow_{}.qm'.format(locale))

        if os.path.exists(locale_path):
            self.translator = QTranslator()
            self.translator.load(locale_path)
            QCoreApplication.installTranslator(self.translator)

        # Declare instance attributes
        self.actions = []
        self.menu = self.tr(u'&Reverse Flow Direction')

        # Check if plugin was started the first time in current QGIS session
        # Must be set in initGui() to survive plugin reloads
        self.first_start = None
Beispiel #6
0
    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',
                                   'qgisSpectre_{}.qm'.format(locale))

        if os.path.exists(locale_path):
            self.translator = QTranslator()
            self.translator.load(locale_path)
            QCoreApplication.installTranslator(self.translator)

        # Declare instance attributes
        self.actions = []
        self.menu = self.tr(u'&Spectre Viewer')
        self.toolbar = self.iface.addToolBar(u'Spectre viewer')
        self.toolbar.setObjectName(u'Spectre viewer')
        self.pluginname = "mortensickel_Spectrumviewer"

        self.view = MouseReadGraphicsView(self.iface)
        self.pluginIsActive = False
Beispiel #7
0
    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',
            'QuickPrintLayoutCreator_{}.qm'.format(locale))

        if os.path.exists(locale_path):
            self.translator = QTranslator()
            self.translator.load(locale_path)
            QCoreApplication.installTranslator(self.translator)

        # Declare instance attributes
        self.actions = []
        self.menu = self.tr(u'&Quick Print Layout Creator and Exporter')

        # Check if plugin was started the first time in current QGIS session
        # Must be set in initGui() to survive plugin reloads
        self.first_start = None

        # init the layout manager
        self.layoutManager = QgsProject.instance().layoutManager()
        self.dlg = QuickPrintLayoutCreatorDialog()
Beispiel #8
0
    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',
            'PuntosSigmena_{}.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)

        self.dlg = PuntosSigmenaDialog()

        # Declare instance attributes
        self.actions = []
        self.menu = self.tr(u'&Sigmena')
        
       
        self.first_start = None
    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',
                                   'MapExport_{}.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)

        # Create the dialog (after translation) and keep reference
        self.dlg = MapExportDialog()
        self.arret = False
Beispiel #10
0
    def __init__(self, iface):

        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',
            '{0}Plugin_{1}.qm'.format(PE, locale)
        )

        if os.path.exists(locale_path):
            self.translator = QTranslator()
            self.translator.load(locale_path)
            QCoreApplication.installTranslator(self.translator)

        # Declare instance attributes
        self.actions = []
        self.menu = self.tr('&{0}'.format(P_E))
        self.toolbar = None

        # noinspection PyTypeChecker
        self.explorer_dock_widget = None
        self._terms_browser = None

        readSettings()

        if is_segments_write_key_valid():
            analytics.write_key = segments_write_key()
        if is_sentry_dsn_valid():
            sentry_sdk.init(sentry_dsn(), default_integrations=False)

        self.qgis_hook = sys.excepthook

        def plugin_hook(t, value, tb):
            trace = "".join(traceback.format_exception(t, value, tb))
            if PLUGIN_NAMESPACE in trace.lower():
                try:
                    sentry_sdk.capture_exception(value)
                except:
                    pass # we swallow all exceptions here, to avoid entering an endless loop
            self.qgis_hook(t, value, tb)

        sys.excepthook = plugin_hook

        metadataFile = os.path.join(os.path.dirname(__file__), "metadata.txt")
        cp = configparser.ConfigParser()
        with codecs.open(metadataFile, "r", "utf8") as f:
            cp.read_file(f)

        if is_sentry_dsn_valid():
            version = cp["general"]["version"]
            with sentry_sdk.configure_scope() as scope:
                scope.set_context("plugin_version", version)
                scope.set_context("qgis_version", Qgis.QGIS_VERSION)
    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",
            "numericalDigitize_{}.qm".format(locale))

        if os.path.exists(locale_path):
            self.translator = QTranslator()
            self.translator.load(locale_path)
            QCoreApplication.installTranslator(self.translator)

        # Declare instance attributes
        # Action button, only one for this version
        self.actions = []
        self.menu = self.translate_str("&Numerical Digitize")

        # Check if plugin was started the first time in current QGIS session
        # Must be set in initGui() to survive plugin reloads
        self.first_start = None
        self.first_start_edit = None

        # Coordinate system for used coordinates
        self.crsId = None

        # Map Canvas reference
        self.canvas = self.iface.mapCanvas()
        self.EditFeatureMapTool = None
        self.prevMapTool = None

        # Main dialog's references
        self.__dlg = None
        self.__dlgEdit = None
        self.__dlgChooser = None

        # Current layer and it't parameters
        self.__layer = None
        self.__layergeometryType = None
        self.__layerwkbType = None
        self.__hasZ = False
        self.__hasM = False
        self.__isMultiType = False
        self.__isEditMode = False
    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: QgisInterface
        """
        # Save reference to the QGIS interface
        self.iface = iface

        #        QgsMapTool.__init(self, self.iface.mapCanvas())
        self.canvas = self.iface.mapCanvas()
        self.canvas.setMouseTracking(True)

        # 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',
                                   'CandRRedistrict_{}.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)

        # Declare instance attributes
        self.actions = []
        self.menu = self.tr(u'&Arrowsmith Redistricter')
        # TODO: We are going to let the user set this up in a future iteration
        self.toolbar = self.iface.addToolBar(u'CandRRedistrict')
        self.toolbar.setObjectName(u'CandRRedistrict')

        #print "** INITIALIZING CandRRedistrict"

        # variables to initialise
        self.pluginIsActive = False
        self.dockwidget = None  #variable for the main dock
        self.attrdockwidget = None  #variable for the attribute table dock
        self.dlgparameters = None  #variable for the parameters dialog
        self.dlgtoolbox = None  #variable for the toolbox dialog
        self.dlgelectorates = None  #variable for the electorates dialog
        self.featIdentTool = None  #make sure we can use the identify tool in the code

        self.districts = None  #number of districts in the tool
        self.activedistrict = '1'  #which district is active. We use string literals
        self.activeLayer = None  #which layer is active - which layer we're reapportioning
        self.popfield = None  #the population field in the database
        self.distfield = None  #the district field in the database
        self.totalpop = 0  #the total population
        self.targetpop = 0  #the target population
        self.targetpoppct = 0  #target population percentage tolerance
        self.targetpoplower = 0  #target pop lower bound
        self.targetpophigher = 0  #target pop upper bound
Beispiel #13
0
    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',
            'OD_{}.qm'.format(locale))

        if os.path.exists(locale_path):
            self.translator = QTranslator()
            self.translator.load(locale_path)
            QCoreApplication.installTranslator(self.translator)
            
            
        self.dlg = ODDialog()
        
        self.dlg.bt_inici.clicked.connect(self.on_click_Inici)
        self.dlg.bt_sortir.clicked.connect(self.on_click_Sortir)
        self.dlg.btnCarregar.clicked.connect(self.on_click_Carregar)
        self.dlg.btnVeure.clicked.connect(self.on_click_Veure)
        self.dlg.radio_ws.toggled.connect(self.on_toggled_radio_ws)
        self.dlg.radio_geom.toggled.connect(self.on_toggled_radio_geom)
        self.dlg.radio_latlng.toggled.connect(self.on_toggled_radio_latlng)
        self.dlg.radio_nogeom.toggled.connect(self.on_toggled_radio_nogeom)
        self.dlg.checkbox_tots.stateChanged.connect(self.on_click_checkbox_tots)
        self.dlg.btnCrs.clicked.connect(self.selectcrs)
        self.dlg.btnBorrar.clicked.connect(self.on_click_Borrar)
        self.dlg.btnBorrar.setToolTip('Esborra la url seleccionada')


        # Declare instance attributes
        self.actions = []
        self.menu = self.tr(u'&CCU')

        
        trobat=False
        for x in iface.mainWindow().findChildren(QToolBar,'CCU'): 
            self.toolbar = x
            trobat=True
        
        if not trobat:
            self.toolbar = self.iface.addToolBar('CCU')
            self.toolbar.setObjectName('CCU')

        # Check if plugin was started the first time in current QGIS session
        # Must be set in initGui() to survive plugin reloads
        self.first_start = None
Beispiel #14
0
    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 = CompatPy.get_dirname(__file__)

        # initialize locale
        locale = QSettings().value('locale/userLocale')[0:2]
        locale_path = path.join(self.plugin_dir, 'i18n',
                                'nextgis_connect_{}.qm'.format(locale))

        if path.exists(locale_path):
            self.plugin_translator = QTranslator()
            self.plugin_translator.load(locale_path)

            self.ngw_translator = QTranslator()
            self.ngw_translator.load(
                path.join(path.dirname(qgis.__file__), "i18n",
                          "qgis_ngw_api_{}.qm".format(locale)))

            if qVersion() > '4.3.3':
                QCoreApplication.installTranslator(self.plugin_translator)
                QCoreApplication.installTranslator(self.ngw_translator)

        # Declare instance attributes
        self.actions = []
        self.menu = self.tr('&NextGIS Connect')
        self.toolbar = self.iface.addToolBar(self.tr('NextGIS Connect'))
        self.toolbar.setObjectName('NextGISConnectPluginToolbar')

        # Enable debug mode.
        debug_mode = PluginSettings.debug_mode()
        PluginSettings.set_debug_mode(debug_mode)  # create at first time
        if debug_mode:
            setDebugEnabled(True)
            QgsMessageLog.logMessage('Debug mode enabled',
                                     PluginSettings._product,
                                     level=CompatQgisMsgLogLevel.Info)
Beispiel #15
0
    def carregaIdioma(self, app, idioma='ca'):
        if app is None:
            return
        self.appQgis = app
        self.idioma = self.paramCfg('Idioma', idioma)
        self.qtTranslator = QTranslator()
        self.qgisTranslator = QTranslator()

        path = QLibraryInfo.location(QLibraryInfo.TranslationsPath)
        self.qtTranslator.load("qt_" + idioma, path)
        app.installTranslator(self.qtTranslator)

        path = app.i18nPath()
        path = path.replace('/./', '/')
        self.qgisTranslator.load("qgis_" + idioma, path)
        app.installTranslator(self.qgisTranslator)

        self.locale = QLocale(self.idioma + "-ES")
Beispiel #16
0
    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',
                                   'selec_cidades_{}.qm'.format(locale))

        if os.path.exists(locale_path):
            self.translator = QTranslator()
            self.translator.load(locale_path)
            QCoreApplication.installTranslator(self.translator)

        # Declare instance attributes
        self.actions = []
        self.menu = self.tr(u'&Seleciona Cidades')

        # Check if plugin was started the first time in current QGIS session
        # Must be set in initGui() to survive plugin reloads
        self.first_start = None

        # Adicao das camadas
        uri = QgsDataSourceUri()
        uri.setConnection("localhost", "5432", "pyqgis", "postgres",
                          "postgres")
        uri.setDataSource("public", "mun_sirgas", "geom", "")
        layer1 = QgsVectorLayer(uri.uri(), "mun_sirgas", "postgres")
        # Adicionando layer ao prj
        QgsProject.instance().addMapLayer(layer1)
        # Atribuindo a simbologia
        symbol = QgsFillSymbol.createSimple({
            'border_width_map_unit_scale': '3x:0,0,0,0,0,0',
            'color': '244,226,196,255',
            'joinstyle': 'bevel',
            'offset': '0,0',
            'offset_map_unit_scale': '3x:0,0,0,0,0,0',
            'offset_unit': 'MM',
            'outline_color': '175,179,138,255',
            'outline_style': 'solid',
            'outline_width': '0.26',
            'outline_width_unit': 'MM',
            'style': 'solid'
        })
        layer1.renderer().setSymbol(symbol)
        # mostrar as mudancas
        layer1.triggerRepaint()
        iface.layerTreeView().refreshLayerSymbology(layer1.id())
    def init_translations(self):
        userLocale = QSettings().value("locale/userLocale")[0:2]
        locale_path = os.path.join(
            self.plugin_dir, "i18n",
            "{:s}_{:s}.qm".format(self.PLUGIN_NAME, userLocale))

        if os.path.exists(locale_path):
            self.translator = QTranslator()
            self.translator.load(locale_path)
            QCoreApplication.installTranslator(self.translator)
Beispiel #18
0
    def __init__(self, iface):
        self.iface = iface

        locale = QgsApplication.locale()
        qmPath = "{}/i18n/photo2shape_{}.qm".format(pluginPath, locale)

        if os.path.exists(qmPath):
            self.translator = QTranslator()
            self.translator.load(qmPath)
            QCoreApplication.installTranslator(self.translator)
    def __init__(self, iface, CFG, UTI):
        """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',
                                   'busquedadireccion_{}.qm'.format(locale))

        if os.path.exists(locale_path):
            self.translator = QTranslator()
            self.translator.load(locale_path)
            QCoreApplication.installTranslator(self.translator)

        # Declare instance attributes
        self.actions = []
        self.menu = self.tr(u'&busquedadireccion')
        self.CFG = CFG
        self.UTI = UTI
        self.pluginIsActive = False
        self.dockwidget = busquedadireccionDialog(parent=iface.mainWindow())
        self.vialidad_id = None
        self.idPredios = []

        #llenamos los combos
        self.obtenerMunicipios()
        self.obtenerColonias()

        #comportamiento tablas
        self.dockwidget.twNumerosExteriores.hideColumn(4)
        self.dockwidget.twVias.hideColumn(1)

        self.dockwidget.twNumerosExteriores.setSelectionBehavior(
            QAbstractItemView.SelectRows)

        #eventos
        self.dockwidget.btBusqueda.clicked.connect(self.getVias)
        self.dockwidget.twNumerosExteriores.itemSelectionChanged.connect(
            self.setIdPredio)
        self.dockwidget.btLocalizar.clicked.connect(self.pintarPredios)
        self.dockwidget.btCerrar.clicked.connect(self.closeIt)
        self.dockwidget.btDetalle.clicked.connect(self.abrirDetallePredio)

        # Check if plugin was started the first time in current QGIS session
        # Must be set in initGui() to survive plugin reloads
        self.first_start = None
Beispiel #20
0
    def __init__(self, iface):
        """
        Constructor of SelvanGeo. References to the
        """
        yaml_file = open(os.path.dirname(os.path.abspath(__file__)) + \
            "\\selvansgeo.yaml", 'r')
        self.conf = yaml.load(yaml_file)['vars']
        yaml_file.close()

        # Get reference to the QGIS interface
        self.iface = iface

        # A reference to our map canvas
        self.canvas = self.iface.mapCanvas()

        # Get reference to legend interface
        self.legendInterface = None  #self.iface.legendInterface()

        # Get reference to the legend interface
        self.layerRegistry = QgsProject.instance()

        # Create the GUI Dialog
        self.dlg = SelvansGeoDialog()

        # Initialize plugin directory
        self.plugin_dir = os.path.dirname(__file__)

        # Get the QGIS message bar
        self.messageBar = self.iface.messageBar()

        # Initialize locale
        locale = QSettings().value("locale/userLocale")[0:2]
        localePath = os.path.join(self.plugin_dir, 'i18n',
                                  'selvansgeo_{}.qm'.format(locale))

        # Globals
        self.currentRole = "init"
        self.credentialInstance = QgsCredentials.instance()
        self.readerPwd = self.conf['pg']['password']

        # Project paths
        self.defaultProjectPath = currentPath + "/qgisprj/" + \
            self.conf['default_project_qgis3']

        print(self.defaultProjectPath)
        s = QSettings()
        self.customProjectPath = s.value("SelvansGeo/customProject",
                                         self.defaultProjectPath)

        if self.customProjectPath == "":
            self.customProjectPath = self.defaultProjectPath

        if os.path.exists(localePath):
            self.translator = QTranslator()
            self.translator.load(localePath)
Beispiel #21
0
    def __init__(self, iface):
        super(Plugin, self).__init__()
        self.iface = iface

        locale = QSettings().value('locale/userLocale')[0:2]
        locale_path = os.path.join(self.i18nPath,
                                   'plugin_{}.qm'.format(locale))
        if os.path.exists(locale_path):
            self.translator = QTranslator()
            self.translator.load(locale_path)
            QCoreApplication.installTranslator(self.translator)
Beispiel #22
0
    def __init__(self, iface):
        self.iface = iface
        self._win = iface.mainWindow()

        self.main_dialog = None
        self.action_publish = None
        self.action_help = None
        self.action_styleviewer = None
        self.widget_styleviewer = StyleviewerWidget()
        self.widget_styleviewer.hideEvent = partial(self.styleviewerHidden)
        self.widget_styleviewer.showEvent = partial(self.styleviewerShown)

        self._layerSignals = LayerStyleEventManager()

        # Load server configuration from QSettings
        manager.loadConfiguredServers()

        self.name = meta.getAppName()
        self.provider = None
        self.locale = QSettings().value("locale/userLocale")[0:2]
        locale_path = files.getLocalePath(f"bridge_{self.locale}")

        self.translator = QTranslator()
        if os.path.exists(locale_path):
            self.translator.load(locale_path)
            QCoreApplication.installTranslator(self.translator)

        self.qgis_hook = sys.excepthook

        def plugin_hook(t, value, tb):
            """ Exception handling (catch all) """
            error_list = traceback.format_exception(t, value, tb)
            trace = "".join(error_list)
            if meta.PLUGIN_NAMESPACE in trace.lower():
                try:
                    # Show error report dialog
                    handleError(error_list)
                except Exception as err:
                    # Swallow all exceptions here, to avoid entering an endless loop
                    feedback.logWarning(
                        f"A failure occurred while handling an exception: {err}"
                    )
                # TODO: Once Bridge is more mature, the code below should be uncommented
                # try:
                #     # Close/disable the plugin to avoid messing up things
                #     self.unload()
                # except Exception as err:
                #     feedback.logWarning(f"A failure occurred while unloading the Bridge plugin: {err}")
            else:
                # Handle regular QGIS exception
                self.qgis_hook(t, value, tb)

        sys.excepthook = plugin_hook
    def __init__(self):
        self.provider = None

        self.plugin_dir = os.path.dirname(__file__)
        locale = QSettings().value("locale/userLocale")[0:2]
        locale_path = os.path.join(self.plugin_dir, "i18n",
                                   "opengxt_{}.qm".format(locale))

        if os.path.exists(locale_path):
            self.translator = QTranslator()
            self.translator.load(locale_path)
            QCoreApplication.installTranslator(self.translator)
    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__)
        self.dlg = ConstIdentificacionDialog(parent=iface.mainWindow())
        # initialize locale
        locale = QSettings().value('locale/userLocale')[0:2]
        locale_path = os.path.join(self.plugin_dir, 'i18n',
                                   'ConstIdentificacion_{}.qm'.format(locale))

        if os.path.exists(locale_path):
            self.translator = QTranslator()
            self.translator.load(locale_path)
            QCoreApplication.installTranslator(self.translator)

        # Declare instance attributes
        self.actions = []
        self.menu = self.tr(u'&Constancia Identificacion')
        self.abrePredio5 = False
        self.directorioAGuardar5 = None
        self.cve_catastral5 = None

        self.canvas = iface.mapCanvas()

        # eventos
        self.dlg.btnBrowse_4.clicked.connect(self.selectDirectory4)
        self.dlg.btnGenerar_4.clicked.connect(self.generarDoc4)
        self.dlg.btnSeleccionar_4.clicked.connect(self.activarSeleccion4)
        self.dlg.exit_signal.connect(self.closeEvent)

        self.dlg.fldCveCat_4.textChanged.connect(self.lineEditToUpper4)

        #validaciones
        rx = QRegExp("[a-zA-Z0-9]{31}")
        val = QRegExpValidator(rx)
        self.dlg.fldCveCat_4.setValidator(val)

        rx = QRegExp("[a-zA-ZÀ-ÿ ]{255}")
        val = QRegExpValidator(rx)
        self.dlg.fldNomSolic.setValidator(val)

        self.onlyInt = QIntValidator()
        self.dlg.fldNumSolucitud.setValidator(self.onlyInt)

        self.dlg.dateEdit_2.setDate(QDate.currentDate())
    def test_qgis_translations(self):
        """Test that translations work."""
        parent_path = os.path.join(__file__, os.path.pardir, os.path.pardir)
        dir_path = os.path.abspath(parent_path)
        file_path = os.path.join(dir_path, 'i18n', 'af.qm')
        translator = QTranslator()
        translator.load(file_path)
        QCoreApplication.installTranslator(translator)

        expected_message = 'Goeie more'
        real_message = QCoreApplication.translate("@default", 'Good morning')
        self.assertEqual(real_message, expected_message)
Beispiel #26
0
    def __init__(self, iface, predios, manzana, construcciones, restantes):
        """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
        # Init canvas
        self.canvas = self.iface.mapCanvas()
        # Init click tool
        self.clickTool = QgsMapToolEmitPoint(self.canvas)
        # 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',
            'errores_topologicos_{}.qm'.format(locale))

        if os.path.exists(locale_path):
            self.translator = QTranslator()
            self.translator.load(locale_path)
            QCoreApplication.installTranslator(self.translator)

        # Declare instance attributes
        self.actions = []
        self.menu = self.tr(u'&errores_topologicos')
        self.dockwidget = errores_topologicosDialog(parent=iface.mainWindow())
        self.erroresPredio = predios
        self.erroresManzana = manzana
        self.erroresRestantes = restantes
        self.erroresConstrucciones = construcciones

        self.dockwidget.labelManzana.setText("Manzanas "+ str(len(self.erroresManzana))+ " errores");
        self.dockwidget.labelPredio.setText("Predios "+ str(len(self.erroresPredio))+ " errores");
        #self.dockwidget.labelHorizontal.setText("Cons Horizo "+ str(len(self.erroresHorizonatales))+ " errores");
        self.dockwidget.labelConstruccion_2.setText("Restantes "+ str(len(self.erroresRestantes))+ " errores");
        self.dockwidget.labelConstruccion.setText("Construcciones "+ str(len(self.erroresConstrucciones))+ " errores");

        self.dockwidget.listWidgetPredio.addItems(self.erroresPredio)
        self.dockwidget.listWidgetManzana.addItems(self.erroresManzana)
        self.dockwidget.listWidgetConstruccion.addItems(self.erroresConstrucciones)
        self.dockwidget.btLocalizarErrorPredio.clicked.connect(self.localiZarErrorPredio)
        self.dockwidget.btLocalizarErrorManzana.clicked.connect(self.localiZarErrorManzana)
        self.dockwidget.btLocalizarErrorConstruccion.clicked.connect(self.localiZarErrorConstruccion)
        self.dockwidget.btLocalizarErrorRestante.clicked.connect(self.localiZarErrorRestante)
        # Check if plugin was started the first time in current QGIS session
        # Must be set in initGui() to survive plugin reloads
        self.first_start = None
    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
        self.canvas = self.iface.mapCanvas()

        # 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',
            'CircleCraters_{}.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)

        # Create the dialog (after translation) and keep reference
        self.export_dlg = ExportDialog()
        self.export_dlg.selected.connect(self.export)

        self.choose_counting_dlg = ChooseCountingLayerDialog()
        self.choose_counting_dlg.selected.connect(self.on_counting_layer_select)

        self.choose_raster_dlg = ChooseRasterLayerDialog()
        self.choose_raster_dlg.selected.connect(self.on_raster_layer_select)

        # Declare instance attributes
        self.actions = []
        self.menu = self.tr(u'&Circle Craters')

        self.toolbar = self.iface.addToolBar(u'CircleCraters')
        self.toolbar.setObjectName(u'CircleCraters')

        self.tool = QgsMapToolEmitPoint(self.canvas)
        self.tool.canvasClicked.connect(self.handle_click)
        self.tool.deactivated.connect(self.reset_clicks)
        self.clicks = []

        self.layer = None
        self.raster_layer = None
Beispiel #28
0
    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',
            'Mappy_{}.qm'.format(locale))

        if os.path.exists(locale_path):
            self.translator = QTranslator()
            self.translator.load(locale_path)
            QCoreApplication.installTranslator(self.translator)

        # Declare instance attributes
        self.actions = []
        self.menu = self.tr(u'&Mappy')
        # TODO: We are going to let the user set this up in a future iteration
        self.toolbar = self.iface.addToolBar(u'Mappy')
        self.toolbar.setObjectName(u'Mappy')

        # print "** INITIALIZING Mappy"

        self.pluginIsActive = False
        self.dockwidget = None

        self.provider = None
        self.info_text = load_mappy_info_text()

        self.config_dock = MappyDockWidget()
        self.config_dock.closingPlugin.connect(self.close_config)
        # print(f"setting infobox text to {self.info_text}")
        self.config_dock.infobox.setHtml(self.info_text)
        self.iface.addDockWidget(Qt.RightDockWidgetArea, self.config_dock)

        v = self.getVersion()

        self.log_message(f"Mappy version: {v}")

        Mappy.instance = self
Beispiel #29
0
    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(plugin_name())

        locale, file_path = setup_translation(
            folder=plugin_path("i18n"), file_pattern="quickosm_{}.qm")
        if file_path:
            # LOGGER.info('Translation to {}'.format(file_path))
            self.translator = QTranslator()
            self.translator.load(file_path)
            QCoreApplication.installTranslator(self.translator)
        else:
            # LOGGER.info('Translation not found: {}'.format(locale))
            pass

        preset_translation_path = join(resources_path(), 'i18n')
        if not os.path.isdir(preset_translation_path):
            if os.path.isfile(preset_translation_path + '.zip'):
                result = QgsZipUtils.unzip(preset_translation_path + '.zip', resources_path())
                if not result[0]:
                    os.mkdir(preset_translation_path)
                else:
                    LOGGER.info('Preset translations have been loaded and unzipped.')
                    files = os.listdir(preset_translation_path)
                    for file in files:
                        file_path = join(preset_translation_path, file)
                        if '-r' in file:
                            new_file_path = join(preset_translation_path, file.replace('-r', '_'))
                            os.rename(file_path, new_file_path)
                        elif '-' in file:
                            new_file_path = join(preset_translation_path, file.replace('-', '_'))
                            os.rename(file_path, new_file_path)
            else:
                os.mkdir(preset_translation_path)

        self.provider = None

        self.toolbar = None
        self.help_action = None
        self.quickosm_menu = None
        self.vector_menu = None
        self.main_window_action = None
        self.josm_action = None
    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',
            'PotentialSlopeFailure_{}.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)

        self.dlg = PotentialSlopeFailureDialog(self.iface)
        self.dlg.runButton.clicked.connect(self.start_progress)
        self.dlg.pushButtonHelp.clicked.connect(self.help)
        self.dlg.pushButtonSave.clicked.connect(self.folder_path)
        self.fileDialog = QFileDialog()
        self.fileDialog.setFileMode(QFileDialog.Directory)
        self.fileDialog.setOption(QFileDialog.ShowDirsOnly, True)

        # Declare instance attributes
        #self.actions = []
        #self.menu = self.tr(u'&Potential Slope Failure')
        # TODO: We are going to let the user set this up in a future iteration
        #self.toolbar = self.iface.addToolBar(u'PotentialSlopeFailure')
        #self.toolbar.setObjectName(u'PotentialSlopeFailure')

        # self.layerComboManagerDEM = RasterLayerCombo(self.dlg.comboBoxDem)
        # RasterLayerCombo(self.dlg.comboBoxDem, initLayer="")
        # self.layerComboManagerSOIL = RasterLayerCombo(self.dlg.comboBoxSoil)
        # RasterLayerCombo(self.dlg.comboBoxSoil, initLayer="")
        self.layerComboManagerDEM = QgsMapLayerComboBox(self.dlg.widgetDEM)
        self.layerComboManagerDEM.setFilters(QgsMapLayerProxyModel.RasterLayer)
        self.layerComboManagerDEM.setFixedWidth(175)
        self.layerComboManagerSOIL = QgsMapLayerComboBox(self.dlg.widgetSOIL)
        self.layerComboManagerSOIL.setFilters(
            QgsMapLayerProxyModel.RasterLayer)
        self.layerComboManagerSOIL.setFixedWidth(175)
        self.folderPath = 'None'