コード例 #1
0
class QvFormNovaMapificacio(QvFormBaseMapificacio):
    def __init__(self, llegenda, amplada=500, mapificacio=None, simple=True):
        super().__init__(llegenda, amplada)

        self.fCSV = mapificacio
        self.simple = simple
        self.taulaMostra = None

        self.setWindowTitle('Afegir capa amb mapa simbòlic')

        self.layout = QVBoxLayout()
        self.layout.setSpacing(14)
        self.setLayout(self.layout)

        if self.fCSV is None:
            self.arxiu = QgsFileWidget()
            self.arxiu.setStorageMode(QgsFileWidget.GetFile)
            self.arxiu.setDialogTitle('Selecciona fitxer de dades…')
            self.arxiu.setDefaultRoot(RUTA_LOCAL)
            self.arxiu.setFilter('Arxius CSV (*.csv)')
            self.arxiu.setSelectedFilter('Arxius CSV (*.csv)')
            self.arxiu.lineEdit().setReadOnly(True)
            self.arxiu.fileChanged.connect(self.arxiuSeleccionat)

        self.zona = QComboBox(self)
        self.zona.setEditable(False)
        self.zona.addItem('Selecciona zona…')
        self.zona.currentIndexChanged.connect(self.canviaZona)

        self.mapa = QComboBox(self)
        self.mapa.setEditable(False)
        self.mapa.setIconSize(QSize(126, 126))
        self.mapa.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding)
        self.mapa.setSizeAdjustPolicy(QComboBox.AdjustToContents)
        self.mapa.addItem(QIcon(os.path.join(imatgesDir, 'Àrees.PNG')), 'Àrees')
        self.mapa.addItem(QIcon(os.path.join(imatgesDir, 'Cercles.PNG')), 'Cercles')

        self.capa = QLineEdit(self)
        self.capa.setMaxLength(40)

        self.tipus = QComboBox(self)
        self.tipus.setEditable(False)
        self.tipus.addItem('Selecciona tipus…')
        self.tipus.addItems(mv.MAP_AGREGACIO.keys())
        self.tipus.currentIndexChanged.connect(self.canviaTipus)

        self.distribucio = QComboBox(self)
        self.distribucio.setEditable(False)
        self.distribucio.addItem(next(iter(mv.MAP_DISTRIBUCIO.keys())))

        self.calcul = QvComboBoxCamps(self)
        self.filtre = QvComboBoxCamps(self, multiple=True)

        self.color = QComboBox(self)
        self.color.setEditable(False)
        self.comboColors(self.color)

        self.metode = QComboBox(self)
        self.metode.setEditable(False)
        self.metode.addItems(mv.MAP_METODES.keys())

        self.intervals = QSpinBox(self)
        self.intervals.setMinimum(2)
        self.intervals.setMaximum(mv.MAP_MAX_CATEGORIES)
        self.intervals.setSingleStep(1)
        self.intervals.setValue(4)
        self.intervals.setSuffix("  (depèn del mètode)")
        # self.intervals.valueChanged.connect(self.deselectValue)

        self.bTaula = QPushButton('Veure arxiu')
        self.bTaula.setEnabled(False)
        self.bTaula.clicked.connect(self.veureArxiu)

        self.buttons = QDialogButtonBox()
        self.buttons.addButton(QDialogButtonBox.Ok)
        self.buttons.accepted.connect(self.accept)
        self.buttons.addButton(QDialogButtonBox.Cancel)
        self.buttons.rejected.connect(self.cancel)
        self.buttons.addButton(self.bTaula, QDialogButtonBox.ResetRole)

        self.gDades = QGroupBox('Agregació de dades')
        self.lDades = QFormLayout()
        self.lDades.setSpacing(14)
        self.gDades.setLayout(self.lDades)

        if self.fCSV is None:
            self.lDades.addRow('Arxiu de dades:', self.arxiu)
        self.lDades.addRow('Zona:', self.zona)
        self.lDades.addRow("Tipus d'agregació:", self.tipus)
        self.lDades.addRow('Camp de càlcul:', self.calcul)
        if self.simple:
            self.filtre.setVisible(False)
            self.distribucio.setVisible(False)
        else:
            self.lDades.addRow('Filtre:', self.filtre)
            self.lDades.addRow('Distribució:', self.distribucio)

        self.gMapa = QGroupBox('Definició del mapa simbòlic')
        self.lMapa = QFormLayout()
        self.lMapa.setSpacing(14)
        self.gMapa.setLayout(self.lMapa)

        self.lMapa.addRow('Nom de capa:', self.capa)
        self.lMapa.addRow('Tipus de mapa:', self.mapa)

        self.gSimb = QGroupBox('Simbologia del mapa')
        self.lSimb = QFormLayout()
        self.lSimb.setSpacing(14)
        self.gSimb.setLayout(self.lSimb)

        self.lSimb.addRow('Color base:', self.color)
        self.lSimb.addRow('Mètode classificació:', self.metode)
        self.lSimb.addRow("Nombre d'intervals:", self.intervals)

        self.layout.addWidget(self.gDades)
        self.layout.addWidget(self.gMapa)
        if self.simple:
            self.gSimb.setVisible(False)
        else:
            self.layout.addWidget(self.gSimb)
        self.layout.addWidget(self.buttons)

        self.adjustSize()

        self.nouArxiu()

    def exec(self):
        # La mapificación solo funciona si está instalado el módulo pandas
        if PANDAS_ENABLED:
            return super().exec()
        else:
            self.msgError(PANDAS_ERROR)
            return QDialog.Rejected

    @pyqtSlot()
    def veureArxiu(self):
        if self.taulaMostra is not None:
            self.taulaMostra.show()
            self.taulaMostra.activateWindow()

    def campsDB(self, nom):
        res = []
        if nom != '':
            fich = RUTA_DADES + mv.MAP_ZONES_DB
            if os.path.isfile(fich):
                conn = sqlite3.connect('file:' + fich + '?mode=ro', uri=True)
                conn.row_factory = sqlite3.Row
                c = conn.cursor()
                c.execute('select * from ' + nom)   # nom.split('.')[0])
                row = c.fetchone()
                # res = [i[0].upper() for i in c.description]
                res = [i.upper() for i in row.keys()]
                conn.close()
        return res

    def soloPrimerItem(self, combo):
        combo.setCurrentIndex(0)
        ultimo = combo.count() - 1
        for n in range(ultimo, 0, -1):
            combo.removeItem(n)

    @pyqtSlot()
    def canviaZona(self):
        self.distribucio.setCurrentIndex(0)
        self.soloPrimerItem(self.distribucio)
        if self.zona.currentIndex() > 0:
            z = self.zona.currentText()
            campsZona = self.campsDB(mv.MAP_ZONES[z][1])
            # Carga combo con distribuciones si el campo correspondiente está en la BBDD
            for dist, campo in mv.MAP_DISTRIBUCIO.items():
                if campo != '' and campo in campsZona:
                    self.distribucio.addItem(dist)

    @pyqtSlot()
    def canviaTipus(self):
        if self.tipus.currentText() == 'Recompte':
            self.calcul.setCurrentIndex(-1)
            self.calcul.setEnabled(False)
        else:
            self.calcul.setEnabled(True)

    def borrarArxiu(self):
        if self.taulaMostra is not None:
            self.taulaMostra.hide()
            self.taulaMostra = None
        self.bTaula.setEnabled(False)
        self.tipus.setCurrentIndex(0)
        self.soloPrimerItem(self.zona)
        self.calcul.clear()
        self.filtre.clear()

    def nouArxiu(self):
        if self.fCSV is None:
            return

        # Carga combo con zonas si el campo correspondiente está en el fichero CSV
        num = 0
        for zona, val in mv.MAP_ZONES.items():
            if val[1] != '' and self.fCSV.prefixe + QvSqlite.getAlias(val[0]) in self.fCSV.camps:
                self.zona.addItem(zona)
                num = num + 1

        # Comprobar si la extensión del mapa está limitada
        if num > 0:
            extensio = self.fCSV.testExtensioArxiu(mv.MAP_EXTENSIO)
            if extensio:  # Mapa limitado
                self.comboDelete(self.zona, mv.MAP_TRUE_EXTENSIO)
            else:  # Mapa completo
                self.comboDelete(self.zona, mv.MAP_FALSE_EXTENSIO)

        # Ajustar combo de zonas
        if num == 0:
            self.msgInfo("El fitxer " + self.fCSV.fZones + " no té cap camp de zona")
            if hasattr(self, 'arxiu'):
                self.arxiu.lineEdit().clear()
                self.arxiu.setFocus()
            return
        if num == 1:
            self.zona.setCurrentIndex(1)
            self.capa.setFocus()
        else:
            self.zona.setFocus()

        self.taulaMostra = QvEditorCsv(self.fCSV.fZones, [], 'utf-8', self.fCSV.separador, self)
        self.taulaMostra.setWindowTitle("Vista prèvia d'arxiu geocodificat")
        self.taulaMostra.setReadOnly(True)

        self.bTaula.setEnabled(True)
        self.calcul.setItems(self.fCSV.camps, primer='')
        self.filtre.setItems(self.fCSV.camps)

    @pyqtSlot(str)
    def arxiuSeleccionat(self, nom):
        if nom == '':
            return
        self.borrarArxiu()
        self.fCSV = QvMapificacio(nom)
        self.nouArxiu()

    def validaSortida(self, nom):
        fSalida = self.fCSV.nomArxiuSortida(self.fCSV.netejaString(nom, True))
        return self.msgSobreescriure(fSalida)

    def valida(self):
        ok = False
        if hasattr(self, 'arxiu') and self.arxiu.filePath() == '':
            self.msgInfo("S'ha de seleccionar un arxiu de dades")
            self.arxiu.setFocus()
        elif self.zona.currentIndex() <= 0:
            self.msgInfo("S'ha de seleccionar una zona")
            self.zona.setFocus()
        elif self.capa.text().strip() == '':
            self.msgInfo("S'ha de introduir un nom de capa")
            self.capa.setFocus()
        elif self.tipus.currentIndex() <= 0:
            self.msgInfo("S'ha de seleccionar un tipus d'agregació")
            self.tipus.setFocus()
        elif self.calcul.currentText().strip() == '' and self.tipus.currentText() != 'Recompte':
            self.msgInfo("S'ha de introduir un cálcul per fer l'agregació")
            self.calcul.setFocus()
        elif self.fCSV is None:
            return self.msgInfo("No hi ha cap fitxer seleccionat")
        elif not self.validaSortida(self.capa.text().strip()):
            self.capa.setFocus()
        else:
            ok = True
        return ok

    def setRenderParams(self):
        self.renderParams = QvMapRendererParams(self.mapa.currentText())
        if self.simple:
            self.renderParams.colorBase = mv.MAP_COLORS[self.renderParams.colorBase]
        else:
            self.renderParams.colorBase = mv.MAP_COLORS[self.color.currentText()]
        if self.renderParams.colorContorn is None or self.renderParams.colorContorn == 'Base':
            self.renderParams.colorContorn = self.renderParams.colorBase
        else:
            self.renderParams.colorContorn = mv.MAP_CONTORNS[self.renderParams.colorContorn]
        if self.tipus.currentText().startswith('Recompte') and \
           self.distribucio.currentText() == "Total":
            self.renderParams.numDecimals = 0
        else:
            self.renderParams.numDecimals = 2
        if self.renderParams.tipusMapa == 'Àrees':
            self.renderParams.modeCategories = mv.MAP_METODES[self.metode.currentText()]
            self.renderParams.numCategories = self.intervals.value()
        if self.renderParams.tipusMapa == 'Cercles':
            zona = self.zona.currentText()
            if zona == 'Districte':
                self.renderParams.increase = 8
            elif zona == 'Barri':
                self.renderParams.increase = 4
            elif zona == 'Àrea estadística bàsica':
                self.renderParams.increase = 3
            elif zona == 'Secció censal':
                self.renderParams.increase = 2
            else:
                self.renderParams.increase = 1

    def procesa(self):
        if self.taulaMostra is not None:
            self.taulaMostra.hide()
        self.setRenderParams()
        ok = self.fCSV.agregacio(self.llegenda, self.capa.text().strip(),
                                 self.zona.currentText(), self.tipus.currentText(),
                                 self.renderParams,
                                 campAgregat=self.calcul.currentText().strip(),
                                 simple=self.simple,
                                 filtre=self.filtre.currentText().strip(),
                                 tipusDistribucio=self.distribucio.currentText(),
                                 form=self)
        if ok:
            return ''
        else:
            return self.fCSV.msgError
コード例 #2
0
class Ui_dlg_form_auth_prompt(object):
    def setupUi(self, dlg_form_auth_prompt):
        dlg_form_auth_prompt.setObjectName(_fromUtf8("dlg_form_auth_prompt"))
        dlg_form_auth_prompt.resize(800, 400)
        dlg_form_auth_prompt.setMinimumSize(QtCore.QSize(800, 400))
        dlg_form_auth_prompt.setMaximumSize(QtCore.QSize(800, 400))
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/plugins/Isogeo/resources/users.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        dlg_form_auth_prompt.setWindowIcon(icon)
        dlg_form_auth_prompt.setLocale(QtCore.QLocale(QtCore.QLocale.English, QtCore.QLocale.UnitedStates))
        dlg_form_auth_prompt.setModal(False)
        self.verticalLayout = QtGui.QVBoxLayout(dlg_form_auth_prompt)
        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
        self.grb_connection_ready = QtGui.QGroupBox(dlg_form_auth_prompt)
        self.grb_connection_ready.setMinimumSize(QtCore.QSize(500, 150))
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.grb_connection_ready.setFont(font)
        self.grb_connection_ready.setAutoFillBackground(True)
        self.grb_connection_ready.setLocale(QtCore.QLocale(QtCore.QLocale.English, QtCore.QLocale.UnitedStates))
        self.grb_connection_ready.setFlat(True)
        self.grb_connection_ready.setObjectName(_fromUtf8("grb_connection_ready"))
        self.gridLayout_2 = QtGui.QGridLayout(self.grb_connection_ready)
        self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2"))
        self.lbl_app_secret = QtGui.QLabel(self.grb_connection_ready)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lbl_app_secret.sizePolicy().hasHeightForWidth())
        self.lbl_app_secret.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setBold(False)
        font.setWeight(50)
        self.lbl_app_secret.setFont(font)
        self.lbl_app_secret.setAutoFillBackground(True)
        self.lbl_app_secret.setLocale(QtCore.QLocale(QtCore.QLocale.English, QtCore.QLocale.UnitedStates))
        self.lbl_app_secret.setScaledContents(True)
        self.lbl_app_secret.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
        self.lbl_app_secret.setObjectName(_fromUtf8("lbl_app_secret"))
        self.gridLayout_2.addWidget(self.lbl_app_secret, 3, 1, 1, 1)
        spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.gridLayout_2.addItem(spacerItem, 3, 4, 1, 1)
        self.ent_app_secret = QtGui.QLineEdit(self.grb_connection_ready)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.ent_app_secret.sizePolicy().hasHeightForWidth())
        self.ent_app_secret.setSizePolicy(sizePolicy)
        self.ent_app_secret.setMinimumSize(QtCore.QSize(475, 25))
        self.ent_app_secret.setMaximumSize(QtCore.QSize(800, 30))
        font = QtGui.QFont()
        font.setBold(False)
        font.setWeight(50)
        self.ent_app_secret.setFont(font)
        self.ent_app_secret.setFocusPolicy(QtCore.Qt.NoFocus)
        self.ent_app_secret.setAutoFillBackground(True)
        self.ent_app_secret.setText(_fromUtf8(""))
        self.ent_app_secret.setMaxLength(64)
        self.ent_app_secret.setEchoMode(QtGui.QLineEdit.PasswordEchoOnEdit)
        self.ent_app_secret.setReadOnly(True)
        self.ent_app_secret.setPlaceholderText(_fromUtf8("*******************************************"))
        self.ent_app_secret.setObjectName(_fromUtf8("ent_app_secret"))
        self.gridLayout_2.addWidget(self.ent_app_secret, 3, 3, 1, 1)
        self.chb_isogeo_editor = QtGui.QCheckBox(self.grb_connection_ready)
        self.chb_isogeo_editor.setMinimumSize(QtCore.QSize(300, 20))
        font = QtGui.QFont()
        font.setBold(False)
        font.setWeight(50)
        self.chb_isogeo_editor.setFont(font)
        self.chb_isogeo_editor.setLayoutDirection(QtCore.Qt.LeftToRight)
        self.chb_isogeo_editor.setAutoFillBackground(True)
        icon1 = QtGui.QIcon()
        icon1.addPixmap(QtGui.QPixmap(_fromUtf8(":/plugins/Isogeo/resources/authentication/user.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.chb_isogeo_editor.setIcon(icon1)
        self.chb_isogeo_editor.setTristate(False)
        self.chb_isogeo_editor.setObjectName(_fromUtf8("chb_isogeo_editor"))
        self.gridLayout_2.addWidget(self.chb_isogeo_editor, 5, 3, 1, 1)
        self.ent_app_id = QtGui.QLineEdit(self.grb_connection_ready)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(1)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.ent_app_id.sizePolicy().hasHeightForWidth())
        self.ent_app_id.setSizePolicy(sizePolicy)
        self.ent_app_id.setMinimumSize(QtCore.QSize(475, 25))
        self.ent_app_id.setMaximumSize(QtCore.QSize(800, 30))
        font = QtGui.QFont()
        font.setBold(False)
        font.setWeight(50)
        self.ent_app_id.setFont(font)
        self.ent_app_id.setToolTip(_fromUtf8(""))
        self.ent_app_id.setAutoFillBackground(True)
        self.ent_app_id.setText(_fromUtf8(""))
        self.ent_app_id.setMaxLength(100)
        self.ent_app_id.setFrame(True)
        self.ent_app_id.setReadOnly(True)
        self.ent_app_id.setCursorMoveStyle(QtCore.Qt.LogicalMoveStyle)
        self.ent_app_id.setObjectName(_fromUtf8("ent_app_id"))
        self.gridLayout_2.addWidget(self.ent_app_id, 2, 3, 1, 1)
        spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.gridLayout_2.addItem(spacerItem1, 0, 4, 1, 1)
        self.btn_ok_cancel = QtGui.QDialogButtonBox(self.grb_connection_ready)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(1)
        sizePolicy.setVerticalStretch(1)
        sizePolicy.setHeightForWidth(self.btn_ok_cancel.sizePolicy().hasHeightForWidth())
        self.btn_ok_cancel.setSizePolicy(sizePolicy)
        self.btn_ok_cancel.setMinimumSize(QtCore.QSize(30, 30))
        self.btn_ok_cancel.setMaximumSize(QtCore.QSize(16777215, 100))
        font = QtGui.QFont()
        font.setBold(False)
        font.setWeight(50)
        self.btn_ok_cancel.setFont(font)
        self.btn_ok_cancel.setAutoFillBackground(True)
        self.btn_ok_cancel.setOrientation(QtCore.Qt.Horizontal)
        self.btn_ok_cancel.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Save)
        self.btn_ok_cancel.setCenterButtons(True)
        self.btn_ok_cancel.setObjectName(_fromUtf8("btn_ok_cancel"))
        self.gridLayout_2.addWidget(self.btn_ok_cancel, 6, 0, 1, 8)
        self.lbl_app_id = QtGui.QLabel(self.grb_connection_ready)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lbl_app_id.sizePolicy().hasHeightForWidth())
        self.lbl_app_id.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setBold(False)
        font.setWeight(50)
        self.lbl_app_id.setFont(font)
        self.lbl_app_id.setAutoFillBackground(True)
        self.lbl_app_id.setLocale(QtCore.QLocale(QtCore.QLocale.English, QtCore.QLocale.UnitedStates))
        self.lbl_app_id.setScaledContents(True)
        self.lbl_app_id.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
        self.lbl_app_id.setObjectName(_fromUtf8("lbl_app_id"))
        self.gridLayout_2.addWidget(self.lbl_app_id, 2, 1, 1, 1)
        self.btn_check_auth = QtGui.QPushButton(self.grb_connection_ready)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.btn_check_auth.sizePolicy().hasHeightForWidth())
        self.btn_check_auth.setSizePolicy(sizePolicy)
        self.btn_check_auth.setMinimumSize(QtCore.QSize(0, 50))
        self.btn_check_auth.setMaximumSize(QtCore.QSize(16777215, 16777215))
        font = QtGui.QFont()
        font.setBold(False)
        font.setWeight(50)
        self.btn_check_auth.setFont(font)
        self.btn_check_auth.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
        icon2 = QtGui.QIcon()
        icon2.addPixmap(QtGui.QPixmap(_fromUtf8(":/plugins/Isogeo/resources/authentication/sign-in.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.btn_check_auth.setIcon(icon2)
        self.btn_check_auth.setDefault(True)
        self.btn_check_auth.setObjectName(_fromUtf8("btn_check_auth"))
        self.gridLayout_2.addWidget(self.btn_check_auth, 2, 5, 2, 1)
        self.lbl_browse_credentials = QtGui.QLabel(self.grb_connection_ready)
        font = QtGui.QFont()
        font.setBold(False)
        font.setWeight(50)
        self.lbl_browse_credentials.setFont(font)
        self.lbl_browse_credentials.setAutoFillBackground(True)
        self.lbl_browse_credentials.setScaledContents(True)
        self.lbl_browse_credentials.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
        self.lbl_browse_credentials.setObjectName(_fromUtf8("lbl_browse_credentials"))
        self.gridLayout_2.addWidget(self.lbl_browse_credentials, 0, 1, 1, 1)
        self.btn_browse_credentials = QgsFileWidget(self.grb_connection_ready)
        self.btn_browse_credentials.setEnabled(True)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.btn_browse_credentials.sizePolicy().hasHeightForWidth())
        self.btn_browse_credentials.setSizePolicy(sizePolicy)
        self.btn_browse_credentials.setMinimumSize(QtCore.QSize(475, 30))
        self.btn_browse_credentials.setMaximumSize(QtCore.QSize(800, 30))
        font = QtGui.QFont()
        font.setBold(False)
        font.setWeight(50)
        self.btn_browse_credentials.setFont(font)
        self.btn_browse_credentials.setFocusPolicy(QtCore.Qt.StrongFocus)
        self.btn_browse_credentials.setAcceptDrops(False)
        self.btn_browse_credentials.setFileWidgetButtonVisible(True)
        self.btn_browse_credentials.setUseLink(False)
        self.btn_browse_credentials.setFullUrl(False)
        self.btn_browse_credentials.setFilter(_fromUtf8("*.json;*.ini"))
        self.btn_browse_credentials.setDefaultRoot(_fromUtf8(""))
        self.btn_browse_credentials.setObjectName(_fromUtf8("btn_browse_credentials"))
        self.gridLayout_2.addWidget(self.btn_browse_credentials, 0, 3, 1, 1)
        spacerItem2 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.gridLayout_2.addItem(spacerItem2, 2, 4, 1, 1)
        spacerItem3 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
        self.gridLayout_2.addItem(spacerItem3, 1, 3, 1, 1)
        self.lbl_api_url = QtGui.QLabel(self.grb_connection_ready)
        font = QtGui.QFont()
        font.setBold(False)
        font.setWeight(50)
        self.lbl_api_url.setFont(font)
        self.lbl_api_url.setAutoFillBackground(True)
        self.lbl_api_url.setScaledContents(True)
        self.lbl_api_url.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
        self.lbl_api_url.setObjectName(_fromUtf8("lbl_api_url"))
        self.gridLayout_2.addWidget(self.lbl_api_url, 4, 1, 1, 1)
        self.lbl_api_url_value = QtGui.QLabel(self.grb_connection_ready)
        font = QtGui.QFont()
        font.setBold(False)
        font.setItalic(False)
        font.setWeight(50)
        font.setKerning(True)
        self.lbl_api_url_value.setFont(font)
        self.lbl_api_url_value.setCursor(QtGui.QCursor(QtCore.Qt.IBeamCursor))
        self.lbl_api_url_value.setAutoFillBackground(True)
        self.lbl_api_url_value.setFrameShape(QtGui.QFrame.NoFrame)
        self.lbl_api_url_value.setText(_fromUtf8("https://v1.api.isogeo.com/"))
        self.lbl_api_url_value.setOpenExternalLinks(True)
        self.lbl_api_url_value.setObjectName(_fromUtf8("lbl_api_url_value"))
        self.gridLayout_2.addWidget(self.lbl_api_url_value, 4, 3, 1, 1)
        self.verticalLayout.addWidget(self.grb_connection_ready)
        self.grb_need_account = QtGui.QGroupBox(dlg_form_auth_prompt)
        self.grb_need_account.setMinimumSize(QtCore.QSize(200, 150))
        self.grb_need_account.setMaximumSize(QtCore.QSize(16777215, 200))
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.grb_need_account.setFont(font)
        self.grb_need_account.setAutoFillBackground(True)
        self.grb_need_account.setLocale(QtCore.QLocale(QtCore.QLocale.English, QtCore.QLocale.UnitedStates))
        self.grb_need_account.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter)
        self.grb_need_account.setFlat(True)
        self.grb_need_account.setObjectName(_fromUtf8("grb_need_account"))
        self.gridLayout = QtGui.QGridLayout(self.grb_need_account)
        self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
        self.btn_account_new = QtGui.QPushButton(self.grb_need_account)
        self.btn_account_new.setMinimumSize(QtCore.QSize(200, 30))
        self.btn_account_new.setMaximumSize(QtCore.QSize(700, 50))
        font = QtGui.QFont()
        font.setBold(False)
        font.setWeight(50)
        self.btn_account_new.setFont(font)
        self.btn_account_new.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
        self.btn_account_new.setAutoFillBackground(True)
        icon3 = QtGui.QIcon()
        icon3.addPixmap(QtGui.QPixmap(_fromUtf8(":/plugins/Isogeo/resources/authentication/send-o.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.btn_account_new.setIcon(icon3)
        self.btn_account_new.setDefault(True)
        self.btn_account_new.setObjectName(_fromUtf8("btn_account_new"))
        self.gridLayout.addWidget(self.btn_account_new, 1, 0, 1, 1)
        self.lbl_access_conditions = QtGui.QLabel(self.grb_need_account)
        self.lbl_access_conditions.setMaximumSize(QtCore.QSize(700, 16777215))
        font = QtGui.QFont()
        font.setBold(False)
        font.setWeight(50)
        self.lbl_access_conditions.setFont(font)
        self.lbl_access_conditions.setTextFormat(QtCore.Qt.RichText)
        self.lbl_access_conditions.setObjectName(_fromUtf8("lbl_access_conditions"))
        self.gridLayout.addWidget(self.lbl_access_conditions, 0, 0, 1, 1)
        self.verticalLayout.addWidget(self.grb_need_account)

        self.retranslateUi(dlg_form_auth_prompt)
        QtCore.QObject.connect(self.btn_ok_cancel, QtCore.SIGNAL(_fromUtf8("accepted()")), dlg_form_auth_prompt.accept)
        QtCore.QObject.connect(self.btn_ok_cancel, QtCore.SIGNAL(_fromUtf8("rejected()")), dlg_form_auth_prompt.reject)
        QtCore.QMetaObject.connectSlotsByName(dlg_form_auth_prompt)

    def retranslateUi(self, dlg_form_auth_prompt):
        dlg_form_auth_prompt.setWindowTitle(_translate("dlg_form_auth_prompt", "Isogeo authentication settings", None))
        self.grb_connection_ready.setTitle(_translate("dlg_form_auth_prompt", "I already have Isogeo ID and SECRET for this application", None))
        self.lbl_app_secret.setText(_translate("dlg_form_auth_prompt", "Application SECRET:", None))
        self.chb_isogeo_editor.setToolTip(_translate("dlg_form_auth_prompt", "I\'ve got the power hey yeah heh!", None))
        self.chb_isogeo_editor.setText(_translate("dlg_form_auth_prompt", "I\'ve got edition rights on app.isogeo.com", None))
        self.ent_app_id.setPlaceholderText(_translate("dlg_form_auth_prompt", "plugin-qgis-org-a1b23c4d5f6g7h8i9j10kl11mn13op14", None))
        self.lbl_app_id.setText(_translate("dlg_form_auth_prompt", "Application ID:", None))
        self.btn_check_auth.setToolTip(_translate("dlg_form_auth_prompt", "Check access validity", None))
        self.btn_check_auth.setText(_translate("dlg_form_auth_prompt", "Check", None))
        self.lbl_browse_credentials.setText(_translate("dlg_form_auth_prompt", "From a file:", None))
        self.btn_browse_credentials.setToolTip(_translate("dlg_form_auth_prompt", "Pick your credentials file", None))
        self.btn_browse_credentials.setDialogTitle(_translate("dlg_form_auth_prompt", "Locate the Isogeo API credentials file", None))
        self.lbl_api_url.setToolTip(_translate("dlg_form_auth_prompt", "Only for information, the Isogeo API base URL", None))
        self.lbl_api_url.setText(_translate("dlg_form_auth_prompt", "API location:", None))
        self.grb_need_account.setTitle(_translate("dlg_form_auth_prompt", "Don\'t have an account yet ?", None))
        self.btn_account_new.setText(_translate("dlg_form_auth_prompt", "Request plugin access", None))
        self.lbl_access_conditions.setText(_translate("dlg_form_auth_prompt", "<!DOCTYPE html>\n"
"<html>\n"
"<body>\n"
"\n"
"<ul>\n"
"    <li>Completely free to access generic Open Data</li>\n"
"    <li>Completely free to work with 20 of your geographic data and services (Isogeo account required)</li>\n"
"    <li>Ask for our annual plans to work with your whole geographic data and services !</li>\n"
"</ul> \n"
"\n"
"</body>\n"
"</html>\n"
"", None))
コード例 #3
0
class Ui_Dialog(object):
    def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(433, 261)
        self.groupBox = QtWidgets.QGroupBox(Dialog)
        self.groupBox.setGeometry(QtCore.QRect(10, 10, 411, 241))
        self.groupBox.setAutoFillBackground(True)
        self.groupBox.setTitle("")
        self.groupBox.setAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft
                                   | QtCore.Qt.AlignTop)
        self.groupBox.setFlat(False)
        self.groupBox.setCheckable(False)
        self.groupBox.setObjectName("groupBox")
        self.panImage = QgsFileWidget(self.groupBox)
        self.panImage.setGeometry(QtCore.QRect(210, 50, 171, 27))
        self.panImage.setAccessibleName("")
        self.panImage.setObjectName("panImage")
        self.multImage = QgsFileWidget(self.groupBox)
        self.multImage.setEnabled(True)
        self.multImage.setGeometry(QtCore.QRect(210, 100, 171, 27))
        self.multImage.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu)
        self.multImage.setLayoutDirection(QtCore.Qt.LeftToRight)
        self.multImage.setFileWidgetButtonVisible(True)
        self.multImage.setFullUrl(True)
        self.multImage.setFilter("")
        self.multImage.setDefaultRoot("")
        self.multImage.setObjectName("multImage")
        self.panImageLabel = QtWidgets.QLabel(self.groupBox)
        self.panImageLabel.setGeometry(QtCore.QRect(30, 50, 161, 20))
        self.panImageLabel.setObjectName("panImageLabel")
        self.multImageLabel = QtWidgets.QLabel(self.groupBox)
        self.multImageLabel.setEnabled(True)
        self.multImageLabel.setGeometry(QtCore.QRect(30, 100, 161, 20))
        self.multImageLabel.setAcceptDrops(False)
        self.multImageLabel.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.multImageLabel.setFrameShadow(QtWidgets.QFrame.Plain)
        self.multImageLabel.setLineWidth(1)
        self.multImageLabel.setWordWrap(False)
        self.multImageLabel.setObjectName("multImageLabel")
        self.btnPansharpen = QtWidgets.QPushButton(self.groupBox)
        self.btnPansharpen.setGeometry(QtCore.QRect(230, 160, 91, 31))
        self.btnPansharpen.setTabletTracking(False)
        self.btnPansharpen.setObjectName("btnPansharpen")

        self.retranslateUi(Dialog)
        QtCore.QMetaObject.connectSlotsByName(Dialog)

    def retranslateUi(self, Dialog):
        _translate = QtCore.QCoreApplication.translate
        Dialog.setWindowTitle(_translate("Dialog", "Qgis Pansharpen Plugin"))
        self.panImage.setDialogTitle(_translate("Dialog", "arquivo"))
        self.multImage.setDialogTitle(_translate("Dialog", "arquivo"))
        self.panImageLabel.setText(
            _translate("Dialog", "Panchromatic Image (.tiff)"))
        self.multImageLabel.setText(
            _translate("Dialog", "Multispectral Image (.tiff)"))
        self.btnPansharpen.setText(_translate("Dialog", "Pansharpen"))

    def panImageFile(self):
        return self.panImage.filePath()

    def multImageFile(self):
        return self.multImage.filePath()

    def GdalClass(self):
        return gdalClass.GdalClass()

    def onClick(self):
        print('botão funcionou')
        print(self.panImageFile())
        print(self.multImageFile())
        self.GdalClass().testando()
        nameOutput = os.path.basename(
            self.panImageFile()) + '-' + os.path.basename(
                self.multImageFile()) + '.tiff'
        output = os.path.join(os.path.dirname(self.panImageFile()), nameOutput)
        print(output)
        self.GdalClass().pansharpening(self.panImageFile(),
                                       self.multImageFile(), output)