diff --git a/GeomorphicFloodIndex/GeomorphicFloodIndex.py b/GeomorphicFloodIndex/GeomorphicFloodIndex.py index 1d73758..7dbfff9 100644 --- a/GeomorphicFloodIndex/GeomorphicFloodIndex.py +++ b/GeomorphicFloodIndex/GeomorphicFloodIndex.py @@ -22,15 +22,16 @@ """ # Import the PyQt and QGIS libraries -from PyQt4.QtCore import * -from PyQt4.QtGui import * +from qgis.PyQt.QtCore import * +from qgis.PyQt.QtGui import * +from qgis.PyQt.QtWidgets import QAction from qgis.core import * # Initialize Qt resources from file resources.py -import resources +from .resources import * # Import the code for the dialog #from FlowPathDown_BBDialog import FlowPathDown_BBDialog -from Ui_GeomorphicFloodIndex import Ui_GeomorphicFloodIndex -import doGeomorphicFloodIndex +from .Ui_GeomorphicFloodIndex import Ui_GeomorphicFloodIndex +from .doGeomorphicFloodIndex import * class GeomorphicFloodIndex: @@ -44,7 +45,8 @@ def initGui(self): "GeomorphicFloodArea", self.iface.mainWindow()) # connect the action to the run method - QObject.connect(self.action, SIGNAL("activated()"), self.run) + # QObject.connect(self.action, SIGNAL("activated()"), self.run) + self.action.triggered.connect(self.run) # Add toolbar button and menu item self.iface.addToolBarIcon(self.action) @@ -54,11 +56,12 @@ def initGui(self): def unload(self): # Remove the plugin menu item and icon self.iface.removePluginMenu("GFA",self.action) + self.iface.removeToolBarIcon(self.action) # run method that performs all the real work def run(self): - dlg = doGeomorphicFloodIndex.GeomorphicFloodIndexDialog(self.iface) + dlg = GeomorphicFloodIndexDialog(self.iface) dlg.exec_() diff --git a/GeomorphicFloodIndex/Ui_GeomorphicFloodIndex.py b/GeomorphicFloodIndex/Ui_GeomorphicFloodIndex.py index ac00ce8..46675cc 100644 --- a/GeomorphicFloodIndex/Ui_GeomorphicFloodIndex.py +++ b/GeomorphicFloodIndex/Ui_GeomorphicFloodIndex.py @@ -7,7 +7,7 @@ # # WARNING! All changes made in this file will be lost! -from PyQt4 import QtCore, QtGui +from qgis.PyQt import QtCore, QtGui, QtWidgets try: _fromUtf8 = QtCore.QString.fromUtf8 @@ -16,171 +16,171 @@ def _fromUtf8(s): return s try: - _encoding = QtGui.QApplication.UnicodeUTF8 + _encoding = QtWidgets.QApplication.UnicodeUTF8 def _translate(context, text, disambig): - return QtGui.QApplication.translate(context, text, disambig, _encoding) + return QtWidgets.QApplication.translate(context, text, disambig, _encoding) except AttributeError: def _translate(context, text, disambig): - return QtGui.QApplication.translate(context, text, disambig) + return QtWidgets.QApplication.translate(context, text, disambig) class Ui_GeomorphicFloodIndex(object): def setupUi(self, GeomorphicFloodIndex): GeomorphicFloodIndex.setObjectName(_fromUtf8("GeomorphicFloodIndex")) GeomorphicFloodIndex.resize(900, 700) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(GeomorphicFloodIndex.sizePolicy().hasHeightForWidth()) GeomorphicFloodIndex.setSizePolicy(sizePolicy) GeomorphicFloodIndex.setMinimumSize(QtCore.QSize(900, 700)) GeomorphicFloodIndex.setMaximumSize(QtCore.QSize(900, 700)) - self.groupBox_2 = QtGui.QGroupBox(GeomorphicFloodIndex) + self.groupBox_2 = QtWidgets.QGroupBox(GeomorphicFloodIndex) self.groupBox_2.setGeometry(QtCore.QRect(9, 360, 881, 341)) self.groupBox_2.setObjectName(_fromUtf8("groupBox_2")) - self.groupBox_4 = QtGui.QGroupBox(self.groupBox_2) + self.groupBox_4 = QtWidgets.QGroupBox(self.groupBox_2) self.groupBox_4.setGeometry(QtCore.QRect(480, 10, 201, 61)) self.groupBox_4.setStyleSheet(_fromUtf8("border-color: rgb(4, 4, 4);")) self.groupBox_4.setObjectName(_fromUtf8("groupBox_4")) - self.progressBar = QtGui.QProgressBar(self.groupBox_4) + self.progressBar = QtWidgets.QProgressBar(self.groupBox_4) self.progressBar.setGeometry(QtCore.QRect(13, 20, 159, 25)) self.progressBar.setProperty("value", 0) self.progressBar.setAlignment(QtCore.Qt.AlignCenter) self.progressBar.setObjectName(_fromUtf8("progressBar")) - self.groupBox_3 = QtGui.QGroupBox(self.groupBox_2) + self.groupBox_3 = QtWidgets.QGroupBox(self.groupBox_2) self.groupBox_3.setGeometry(QtCore.QRect(0, 210, 361, 91)) self.groupBox_3.setObjectName(_fromUtf8("groupBox_3")) - self.textEdit = QtGui.QTextEdit(self.groupBox_3) + self.textEdit = QtWidgets.QTextEdit(self.groupBox_3) self.textEdit.setGeometry(QtCore.QRect(10, 20, 331, 61)) self.textEdit.setObjectName(_fromUtf8("textEdit")) - self.checkBoxWD = QtGui.QCheckBox(self.groupBox_2) + self.checkBoxWD = QtWidgets.QCheckBox(self.groupBox_2) self.checkBoxWD.setGeometry(QtCore.QRect(70, 120, 127, 17)) self.checkBoxWD.setObjectName(_fromUtf8("checkBoxWD")) - self.checkBoxFM = QtGui.QCheckBox(self.groupBox_2) + self.checkBoxFM = QtWidgets.QCheckBox(self.groupBox_2) self.checkBoxFM.setGeometry(QtCore.QRect(70, 70, 351, 17)) self.checkBoxFM.setObjectName(_fromUtf8("checkBoxFM")) - self.checkBoxDebug = QtGui.QCheckBox(self.groupBox_2) + self.checkBoxDebug = QtWidgets.QCheckBox(self.groupBox_2) self.checkBoxDebug.setGeometry(QtCore.QRect(20, 190, 311, 17)) self.checkBoxDebug.setObjectName(_fromUtf8("checkBoxDebug")) - self.checkBoxAdd = QtGui.QCheckBox(self.groupBox_2) + self.checkBoxAdd = QtWidgets.QCheckBox(self.groupBox_2) self.checkBoxAdd.setGeometry(QtCore.QRect(20, 170, 311, 17)) self.checkBoxAdd.setObjectName(_fromUtf8("checkBoxAdd")) - self.btnOutput = QtGui.QToolButton(self.groupBox_2) + self.btnOutput = QtWidgets.QToolButton(self.groupBox_2) self.btnOutput.setGeometry(QtCore.QRect(20, 30, 42, 25)) self.btnOutput.setMinimumSize(QtCore.QSize(0, 25)) self.btnOutput.setMaximumSize(QtCore.QSize(16777215, 25)) self.btnOutput.setObjectName(_fromUtf8("btnOutput")) - self.lineOutput = QtGui.QLineEdit(self.groupBox_2) + self.lineOutput = QtWidgets.QLineEdit(self.groupBox_2) self.lineOutput.setGeometry(QtCore.QRect(70, 30, 401, 25)) self.lineOutput.setMinimumSize(QtCore.QSize(280, 25)) self.lineOutput.setObjectName(_fromUtf8("lineOutput")) - self.lblSlope_7 = QtGui.QLabel(self.groupBox_2) + self.lblSlope_7 = QtWidgets.QLabel(self.groupBox_2) self.lblSlope_7.setGeometry(QtCore.QRect(70, 10, 197, 19)) self.lblSlope_7.setObjectName(_fromUtf8("lblSlope_7")) - self.btnOutputBin = QtGui.QToolButton(self.groupBox_2) + self.btnOutputBin = QtWidgets.QToolButton(self.groupBox_2) self.btnOutputBin.setGeometry(QtCore.QRect(20, 90, 42, 25)) self.btnOutputBin.setMinimumSize(QtCore.QSize(0, 25)) self.btnOutputBin.setMaximumSize(QtCore.QSize(16777215, 25)) self.btnOutputBin.setObjectName(_fromUtf8("btnOutputBin")) - self.lineOutputBin = QtGui.QLineEdit(self.groupBox_2) + self.lineOutputBin = QtWidgets.QLineEdit(self.groupBox_2) self.lineOutputBin.setGeometry(QtCore.QRect(70, 90, 401, 25)) self.lineOutputBin.setMinimumSize(QtCore.QSize(280, 25)) self.lineOutputBin.setObjectName(_fromUtf8("lineOutputBin")) - self.buttonBox = QtGui.QDialogButtonBox(self.groupBox_2) + self.buttonBox = QtWidgets.QDialogButtonBox(self.groupBox_2) self.buttonBox.setGeometry(QtCore.QRect(160, 300, 251, 27)) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) - self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Help|QtGui.QDialogButtonBox.Ok) + self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Help|QtWidgets.QDialogButtonBox.Ok) self.buttonBox.setObjectName(_fromUtf8("buttonBox")) - self.lblSlope_3 = QtGui.QLabel(self.groupBox_2) + self.lblSlope_3 = QtWidgets.QLabel(self.groupBox_2) self.lblSlope_3.setGeometry(QtCore.QRect(440, 210, 281, 16)) self.lblSlope_3.setObjectName(_fromUtf8("lblSlope_3")) - self.cmbSlopeType = QtGui.QComboBox(self.groupBox_2) + self.cmbSlopeType = QtWidgets.QComboBox(self.groupBox_2) self.cmbSlopeType.setGeometry(QtCore.QRect(540, 210, 85, 20)) self.cmbSlopeType.setEditable(False) self.cmbSlopeType.setModelColumn(0) self.cmbSlopeType.setObjectName(_fromUtf8("cmbSlopeType")) - self.btnOutputWD = QtGui.QToolButton(self.groupBox_2) + self.btnOutputWD = QtWidgets.QToolButton(self.groupBox_2) self.btnOutputWD.setGeometry(QtCore.QRect(20, 140, 42, 25)) self.btnOutputWD.setMinimumSize(QtCore.QSize(0, 25)) self.btnOutputWD.setMaximumSize(QtCore.QSize(16777215, 25)) self.btnOutputWD.setObjectName(_fromUtf8("btnOutputWD")) - self.lineOutputWD = QtGui.QLineEdit(self.groupBox_2) + self.lineOutputWD = QtWidgets.QLineEdit(self.groupBox_2) self.lineOutputWD.setGeometry(QtCore.QRect(70, 140, 401, 25)) self.lineOutputWD.setMinimumSize(QtCore.QSize(280, 25)) self.lineOutputWD.setObjectName(_fromUtf8("lineOutputWD")) - self.groupBox = QtGui.QGroupBox(GeomorphicFloodIndex) + self.groupBox = QtWidgets.QGroupBox(GeomorphicFloodIndex) self.groupBox.setGeometry(QtCore.QRect(9, 30, 881, 161)) self.groupBox.setObjectName(_fromUtf8("groupBox")) - self.cmbDemVoid = QtGui.QComboBox(self.groupBox) + self.cmbDemVoid = QtWidgets.QComboBox(self.groupBox) self.cmbDemVoid.setGeometry(QtCore.QRect(203, 55, 600, 25)) self.cmbDemVoid.setMinimumSize(QtCore.QSize(280, 25)) self.cmbDemVoid.setMaximumSize(QtCore.QSize(600, 25)) self.cmbDemVoid.setLayoutDirection(QtCore.Qt.LeftToRight) self.cmbDemVoid.setObjectName(_fromUtf8("cmbDemVoid")) - self.cmbDemCon = QtGui.QComboBox(self.groupBox) + self.cmbDemCon = QtWidgets.QComboBox(self.groupBox) self.cmbDemCon.setGeometry(QtCore.QRect(203, 24, 600, 25)) self.cmbDemCon.setMinimumSize(QtCore.QSize(280, 25)) self.cmbDemCon.setMaximumSize(QtCore.QSize(600, 25)) self.cmbDemCon.setLayoutDirection(QtCore.Qt.LeftToRight) self.cmbDemCon.setObjectName(_fromUtf8("cmbDemCon")) - self.lblFlowDir = QtGui.QLabel(self.groupBox) + self.lblFlowDir = QtWidgets.QLabel(self.groupBox) self.lblFlowDir.setGeometry(QtCore.QRect(11, 88, 181, 16)) self.lblFlowDir.setObjectName(_fromUtf8("lblFlowDir")) - self.lblTRIGGER = QtGui.QLabel(self.groupBox) + self.lblTRIGGER = QtWidgets.QLabel(self.groupBox) self.lblTRIGGER.setGeometry(QtCore.QRect(11, 57, 171, 16)) self.lblTRIGGER.setObjectName(_fromUtf8("lblTRIGGER")) - self.cmbFlowDir = QtGui.QComboBox(self.groupBox) + self.cmbFlowDir = QtWidgets.QComboBox(self.groupBox) self.cmbFlowDir.setGeometry(QtCore.QRect(203, 86, 600, 25)) self.cmbFlowDir.setMinimumSize(QtCore.QSize(280, 25)) self.cmbFlowDir.setMaximumSize(QtCore.QSize(600, 25)) self.cmbFlowDir.setLayoutDirection(QtCore.Qt.LeftToRight) self.cmbFlowDir.setObjectName(_fromUtf8("cmbFlowDir")) - self.lblFLOWACC = QtGui.QLabel(self.groupBox) + self.lblFLOWACC = QtWidgets.QLabel(self.groupBox) self.lblFLOWACC.setGeometry(QtCore.QRect(11, 119, 181, 16)) self.lblFLOWACC.setObjectName(_fromUtf8("lblFLOWACC")) - self.lblDEMCON = QtGui.QLabel(self.groupBox) + self.lblDEMCON = QtWidgets.QLabel(self.groupBox) self.lblDEMCON.setGeometry(QtCore.QRect(11, 26, 100, 16)) self.lblDEMCON.setMaximumSize(QtCore.QSize(100, 20)) self.lblDEMCON.setAutoFillBackground(False) self.lblDEMCON.setMargin(1) self.lblDEMCON.setObjectName(_fromUtf8("lblDEMCON")) - self.cmbFlowAcc = QtGui.QComboBox(self.groupBox) + self.cmbFlowAcc = QtWidgets.QComboBox(self.groupBox) self.cmbFlowAcc.setGeometry(QtCore.QRect(203, 117, 600, 25)) self.cmbFlowAcc.setMinimumSize(QtCore.QSize(280, 25)) self.cmbFlowAcc.setMaximumSize(QtCore.QSize(600, 25)) self.cmbFlowAcc.setLayoutDirection(QtCore.Qt.LeftToRight) self.cmbFlowAcc.setObjectName(_fromUtf8("cmbFlowAcc")) - self.toolButtonDemCon = QtGui.QToolButton(self.groupBox) + self.toolButtonDemCon = QtWidgets.QToolButton(self.groupBox) self.toolButtonDemCon.setGeometry(QtCore.QRect(840, 30, 25, 19)) self.toolButtonDemCon.setObjectName(_fromUtf8("toolButtonDemCon")) - self.toolButtonDemVoid = QtGui.QToolButton(self.groupBox) + self.toolButtonDemVoid = QtWidgets.QToolButton(self.groupBox) self.toolButtonDemVoid.setGeometry(QtCore.QRect(840, 60, 25, 19)) self.toolButtonDemVoid.setObjectName(_fromUtf8("toolButtonDemVoid")) - self.toolButtonFlowDir = QtGui.QToolButton(self.groupBox) + self.toolButtonFlowDir = QtWidgets.QToolButton(self.groupBox) self.toolButtonFlowDir.setGeometry(QtCore.QRect(840, 90, 25, 19)) self.toolButtonFlowDir.setObjectName(_fromUtf8("toolButtonFlowDir")) - self.toolButtonFlowAcc = QtGui.QToolButton(self.groupBox) + self.toolButtonFlowAcc = QtWidgets.QToolButton(self.groupBox) self.toolButtonFlowAcc.setGeometry(QtCore.QRect(840, 120, 25, 19)) self.toolButtonFlowAcc.setObjectName(_fromUtf8("toolButtonFlowAcc")) - self.groupBox_5 = QtGui.QGroupBox(GeomorphicFloodIndex) + self.groupBox_5 = QtWidgets.QGroupBox(GeomorphicFloodIndex) self.groupBox_5.setGeometry(QtCore.QRect(10, 190, 411, 151)) self.groupBox_5.setObjectName(_fromUtf8("groupBox_5")) - self.layoutWidget = QtGui.QWidget(self.groupBox_5) - self.layoutWidget.setGeometry(QtCore.QRect(290, 10, 99, 126)) + self.layoutWidget = QtWidgets.QWidget(self.groupBox_5) + self.layoutWidget.setGeometry(QtCore.QRect(290, 20, 99, 126)) self.layoutWidget.setObjectName(_fromUtf8("layoutWidget")) - self.verticalLayout = QtGui.QVBoxLayout(self.layoutWidget) + self.verticalLayout = QtWidgets.QVBoxLayout(self.layoutWidget) self.verticalLayout.setMargin(0) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) - self.cmbFlowDirCoding = QtGui.QComboBox(self.layoutWidget) + self.cmbFlowDirCoding = QtWidgets.QComboBox(self.layoutWidget) self.cmbFlowDirCoding.setEditable(False) self.cmbFlowDirCoding.setModelColumn(0) self.cmbFlowDirCoding.setObjectName(_fromUtf8("cmbFlowDirCoding")) self.verticalLayout.addWidget(self.cmbFlowDirCoding) - self.cmbChannelType = QtGui.QComboBox(self.layoutWidget) + self.cmbChannelType = QtWidgets.QComboBox(self.layoutWidget) self.cmbChannelType.setEditable(False) self.cmbChannelType.setModelColumn(0) self.cmbChannelType.setObjectName(_fromUtf8("cmbChannelType")) self.verticalLayout.addWidget(self.cmbChannelType) - self.doubleSpinBoxThesholdChannel = QtGui.QDoubleSpinBox(self.layoutWidget) + self.doubleSpinBoxThesholdChannel = QtWidgets.QDoubleSpinBox(self.layoutWidget) self.doubleSpinBoxThesholdChannel.setDecimals(2) self.doubleSpinBoxThesholdChannel.setMinimum(0.0) self.doubleSpinBoxThesholdChannel.setMaximum(1000000000.0) @@ -188,7 +188,7 @@ def setupUi(self, GeomorphicFloodIndex): self.doubleSpinBoxThesholdChannel.setProperty("value", 10000.0) self.doubleSpinBoxThesholdChannel.setObjectName(_fromUtf8("doubleSpinBoxThesholdChannel")) self.verticalLayout.addWidget(self.doubleSpinBoxThesholdChannel) - self.doubleSpinBoxN = QtGui.QDoubleSpinBox(self.layoutWidget) + self.doubleSpinBoxN = QtWidgets.QDoubleSpinBox(self.layoutWidget) self.doubleSpinBoxN.setDecimals(4) self.doubleSpinBoxN.setMinimum(0.0) self.doubleSpinBoxN.setMaximum(100000.0) @@ -196,22 +196,22 @@ def setupUi(self, GeomorphicFloodIndex): self.doubleSpinBoxN.setProperty("value", 0.4057) self.doubleSpinBoxN.setObjectName(_fromUtf8("doubleSpinBoxN")) self.verticalLayout.addWidget(self.doubleSpinBoxN) - self.lblSlope_4 = QtGui.QLabel(self.groupBox_5) + self.lblSlope_4 = QtWidgets.QLabel(self.groupBox_5) self.lblSlope_4.setGeometry(QtCore.QRect(10, 60, 281, 16)) self.lblSlope_4.setObjectName(_fromUtf8("lblSlope_4")) - self.lblSlope_5 = QtGui.QLabel(self.groupBox_5) + self.lblSlope_5 = QtWidgets.QLabel(self.groupBox_5) self.lblSlope_5.setGeometry(QtCore.QRect(10, 90, 291, 16)) self.lblSlope_5.setObjectName(_fromUtf8("lblSlope_5")) - self.lblSlope_6 = QtGui.QLabel(self.groupBox_5) + self.lblSlope_6 = QtWidgets.QLabel(self.groupBox_5) self.lblSlope_6.setGeometry(QtCore.QRect(11, 121, 291, 16)) self.lblSlope_6.setObjectName(_fromUtf8("lblSlope_6")) - self.lblSlope_2 = QtGui.QLabel(self.groupBox_5) + self.lblSlope_2 = QtWidgets.QLabel(self.groupBox_5) self.lblSlope_2.setGeometry(QtCore.QRect(10, 30, 271, 16)) self.lblSlope_2.setObjectName(_fromUtf8("lblSlope_2")) - self.groupBox_6 = QtGui.QGroupBox(GeomorphicFloodIndex) + self.groupBox_6 = QtWidgets.QGroupBox(GeomorphicFloodIndex) self.groupBox_6.setGeometry(QtCore.QRect(430, 190, 461, 151)) self.groupBox_6.setObjectName(_fromUtf8("groupBox_6")) - self.doubleSpinBoxTheshold = QtGui.QDoubleSpinBox(self.groupBox_6) + self.doubleSpinBoxTheshold = QtWidgets.QDoubleSpinBox(self.groupBox_6) self.doubleSpinBoxTheshold.setGeometry(QtCore.QRect(400, 20, 51, 20)) self.doubleSpinBoxTheshold.setDecimals(2) self.doubleSpinBoxTheshold.setMinimum(-5.0) @@ -219,27 +219,27 @@ def setupUi(self, GeomorphicFloodIndex): self.doubleSpinBoxTheshold.setSingleStep(1e-05) self.doubleSpinBoxTheshold.setProperty("value", -0.53) self.doubleSpinBoxTheshold.setObjectName(_fromUtf8("doubleSpinBoxTheshold")) - self.cmbSFM = QtGui.QComboBox(self.groupBox_6) + self.cmbSFM = QtWidgets.QComboBox(self.groupBox_6) self.cmbSFM.setGeometry(QtCore.QRect(10, 110, 381, 25)) self.cmbSFM.setMinimumSize(QtCore.QSize(280, 25)) self.cmbSFM.setMaximumSize(QtCore.QSize(600, 25)) self.cmbSFM.setLayoutDirection(QtCore.Qt.LeftToRight) self.cmbSFM.setObjectName(_fromUtf8("cmbSFM")) - self.toolButtonSFM = QtGui.QToolButton(self.groupBox_6) + self.toolButtonSFM = QtWidgets.QToolButton(self.groupBox_6) self.toolButtonSFM.setGeometry(QtCore.QRect(410, 110, 25, 19)) self.toolButtonSFM.setObjectName(_fromUtf8("toolButtonSFM")) - self.checkBoxCalibration = QtGui.QCheckBox(self.groupBox_6) + self.checkBoxCalibration = QtWidgets.QCheckBox(self.groupBox_6) self.checkBoxCalibration.setGeometry(QtCore.QRect(11, 73, 351, 17)) self.checkBoxCalibration.setObjectName(_fromUtf8("checkBoxCalibration")) - self.lblDEMCON_2 = QtGui.QLabel(self.groupBox_6) + self.lblDEMCON_2 = QtWidgets.QLabel(self.groupBox_6) self.lblDEMCON_2.setGeometry(QtCore.QRect(100, 90, 261, 16)) self.lblDEMCON_2.setAutoFillBackground(False) self.lblDEMCON_2.setMargin(1) self.lblDEMCON_2.setObjectName(_fromUtf8("lblDEMCON_2")) - self.lblSlope = QtGui.QLabel(self.groupBox_6) + self.lblSlope = QtWidgets.QLabel(self.groupBox_6) self.lblSlope.setGeometry(QtCore.QRect(220, 20, 181, 16)) self.lblSlope.setObjectName(_fromUtf8("lblSlope")) - self.checkBoxManualSet = QtGui.QCheckBox(self.groupBox_6) + self.checkBoxManualSet = QtWidgets.QCheckBox(self.groupBox_6) self.checkBoxManualSet.setGeometry(QtCore.QRect(10, 20, 181, 17)) self.checkBoxManualSet.setObjectName(_fromUtf8("checkBoxManualSet")) diff --git a/GeomorphicFloodIndex/Ui_GeomorphicFloodIndex.ui b/GeomorphicFloodIndex/Ui_GeomorphicFloodIndex.ui index 8d6c2fe..10a271e 100644 --- a/GeomorphicFloodIndex/Ui_GeomorphicFloodIndex.ui +++ b/GeomorphicFloodIndex/Ui_GeomorphicFloodIndex.ui @@ -605,7 +605,7 @@ 290 - 10 + 20 99 126 diff --git a/GeomorphicFloodIndex/__init__.py b/GeomorphicFloodIndex/__init__.py index 43d7246..03947e5 100644 --- a/GeomorphicFloodIndex/__init__.py +++ b/GeomorphicFloodIndex/__init__.py @@ -23,5 +23,5 @@ def classFactory(iface): - from GeomorphicFloodIndex import GeomorphicFloodIndex + from .GeomorphicFloodIndex import GeomorphicFloodIndex return GeomorphicFloodIndex(iface) diff --git a/GeomorphicFloodIndex/doGeomorphicFloodIndex.py b/GeomorphicFloodIndex/doGeomorphicFloodIndex.py index f142d37..455a998 100644 --- a/GeomorphicFloodIndex/doGeomorphicFloodIndex.py +++ b/GeomorphicFloodIndex/doGeomorphicFloodIndex.py @@ -20,17 +20,17 @@ ***************************************************************************/ This script initializes the plugin, making it known to QGIS. """ -from PyQt4.QtCore import * -from PyQt4.QtGui import * +from qgis.PyQt.QtCore import * +from qgis.PyQt.QtGui import * from qgis.core import * import qgis.utils -from Ui_GeomorphicFloodIndex import Ui_GeomorphicFloodIndex -from PyQt4.QtGui import QProgressBar +from .Ui_GeomorphicFloodIndex import * +from qgis.PyQt.QtWidgets import QProgressBar, QDialog, QMessageBox, QFileDialog import os, sys, time, math from osgeo import gdal, ogr from osgeo.gdalconst import * from scipy import ndimage -import osr +from osgeo import osr import numpy #from sklearn import metrics import matplotlib.pyplot as plt @@ -55,22 +55,36 @@ def __init__(self, iface): self.NOVALUE=-340282346638528859811704183484516925440.000000 self.checkBoxManualSet.setChecked(True) self.checkBoxCalibration.setChecked(False) - self.connect(self.toolButtonDemCon, SIGNAL("clicked()"), self.demconFile) - self.connect(self.toolButtonDemVoid, SIGNAL("clicked()"), self.demvoidFile) - self.connect(self.toolButtonFlowDir, SIGNAL("clicked()"), self.flowdirFile) - self.connect(self.toolButtonFlowAcc, SIGNAL("clicked()"), self.flowaccFile) - self.connect(self.toolButtonSFM, SIGNAL("clicked()"), self.sfmFile) - - self.connect(self.checkBoxCalibration,SIGNAL("clicked()"),self.calibration_clicked) - self.connect(self.checkBoxManualSet,SIGNAL("clicked()"),self.manualset_clicked) - - self.connect(self.btnOutput, SIGNAL("clicked()"), self.outFile) - self.connect(self.btnOutputBin, SIGNAL("clicked()"), self.outFileBin) - self.connect(self.btnOutputWD, SIGNAL("clicked()"), self.outFileWD) - - self.connect(self.buttonBox, SIGNAL("accepted()"),self.accept) - QObject.connect(self.buttonBox, SIGNAL("rejected()"),self, SLOT("reject()")) - QObject.connect(self.buttonBox, SIGNAL("helpRequested()"),self.call_help) + # self.connect(self.toolButtonDemCon, SIGNAL("clicked()"), self.demconFile) + self.toolButtonDemCon.clicked.connect(self.demconFile) + # self.connect(self.toolButtonDemVoid, SIGNAL("clicked()"), self.demvoidFile) + self.toolButtonDemVoid.clicked.connect(self.demvoidFile) + # self.connect(self.toolButtonFlowDir, SIGNAL("clicked()"), self.flowdirFile) + self.toolButtonFlowDir.clicked.connect(self.flowdirFile) + # self.connect(self.toolButtonFlowAcc, SIGNAL("clicked()"), self.flowaccFile) + self.toolButtonFlowAcc.clicked.connect(self.flowaccFile) + # self.connect(self.toolButtonSFM, SIGNAL("clicked()"), self.sfmFile) + self.toolButtonSFM.clicked.connect(self.sfmFile) + + # self.connect(self.checkBoxCalibration,SIGNAL("clicked()"),self.calibration_clicked) + # self.checkBoxCalibration.stateChanged.connect(self.calibration_clicked) + # self.connect(self.checkBoxManualSet,SIGNAL("clicked()"),self.manualset_clicked) + # self.checkBoxManualSet.stateChanged.connect(self.manualset_clicked) + + # self.connect(self.btnOutput, SIGNAL("clicked()"), self.outFile) + self.btnOutput.clicked.connect(self.outFile) + # self.connect(self.btnOutputBin, SIGNAL("clicked()"), self.outFileBin) + self.btnOutputBin.clicked.connect(self.outFileBin) + # self.connect(self.btnOutputWD, SIGNAL("clicked()"), self.outFileWD) + self.btnOutputWD.clicked.connect(self.outFileWD) + + # self.connect(self.buttonBox, SIGNAL("accepted()"),self.accept) + self.buttonBox.accepted.connect(self.accept) + + # QObject.connect(self.buttonBox, SIGNAL("rejected()"),self, SLOT("reject()")) + self.buttonBox.rejected.connect(self.reject) + # QObject.connect(self.buttonBox, SIGNAL("helpRequested()"),self.call_help) + self.buttonBox.helpRequested.connect(self.call_help) mapCanvas = self.iface.mapCanvas() # init dictionaries of items: @@ -139,7 +153,7 @@ def call_help(self): def outFile(self): "Display file dialog for output file" self.lineOutput.clear() - outName = QFileDialog.getSaveFileName(self, "GFI output file",".", "GeoTiff (*.tif)") + outName, filter_string = QFileDialog.getSaveFileName(self, "GFI output file",".", "GeoTiff (*.tif)") if len(outName)>0: self.lineOutput.clear() @@ -149,7 +163,7 @@ def outFile(self): def outFileBin(self): "Display file dialog for output file" self.lineOutputBin.clear() - outNameBin = QFileDialog.getSaveFileName(self, "GFI output file",".", "GeoTiff (*.tif)") + outNameBin, filter_string = QFileDialog.getSaveFileName(self, "GFI output file",".", "GeoTiff (*.tif)") if len(outNameBin)>0: self.lineOutputBin.clear() @@ -160,7 +174,7 @@ def outFileBin(self): def outFileWD(self): "Display file dialog for output file" self.lineOutputWD.clear() - outNameWD = QFileDialog.getSaveFileName(self, "WD output file",".", "GeoTiff (*.tif)") + outNameWD, filter_string = QFileDialog.getSaveFileName(self, "WD output file",".", "GeoTiff (*.tif)") if len(outNameWD)>0: self.lineOutputWD.clear() @@ -169,49 +183,49 @@ def outFileWD(self): return outNameWD def demconFile(self): - "Display file dialog for output file" - demconName = QFileDialog.getOpenFileName(self, "FILL Dem input file",".", "ESRI ascii (*.txt);; GeoTiff (*.tif);;All files (*.*)") + "Display file dialog for input file" + demconName, filter_string = QFileDialog.getOpenFileName(self, "FILL Dem input file",".", "ESRI ascii (*.txt);; GeoTiff (*.tif);;All files (*.*)") if len(demconName)>0: self.cmbDemCon.insertItem (0, demconName) self.cmbDemCon.setCurrentIndex(0) return demconName def demvoidFile(self): - "Display file dialog for output file" - demvoidName = QFileDialog.getOpenFileName(self, "Dem input file",".", "ESRI ascii (*.txt);; GeoTiff (*.tif);;All files (*.*)") + "Display file dialog for input file" + demvoidName, filter_string = QFileDialog.getOpenFileName(self, "Dem input file",".", "ESRI ascii (*.txt);; GeoTiff (*.tif);;All files (*.*)") if len(demvoidName)>0: self.cmbDemVoid.insertItem (0, demvoidName) self.cmbDemVoid.setCurrentIndex(0) return demvoidName def flowdirFile(self): - "Display file dialog for output file" - flowdirName = QFileDialog.getOpenFileName(self, "Flowdir input file",".", "ESRI ascii (*.txt);; GeoTiff (*.tif);;All files (*.*)") + "Display file dialog for input file" + flowdirName, filter_string = QFileDialog.getOpenFileName(self, "Flowdir input file",".", "ESRI ascii (*.txt);; GeoTiff (*.tif);;All files (*.*)") if len(flowdirName)>0: self.cmbFlowDir.insertItem (0, flowdirName) self.cmbFlowDir.setCurrentIndex(0) return flowdirName def flowaccFile(self): - "Display file dialog for output file" - flowaccName = QFileDialog.getOpenFileName(self, "Flowacc input file",".", "ESRI ascii (*.txt);; GeoTiff (*.tif);;All files (*.*)") + "Display file dialog for input file" + flowaccName, filter_string = QFileDialog.getOpenFileName(self, "Flowacc input file",".", "ESRI ascii (*.txt);; GeoTiff (*.tif);;All files (*.*)") if len(flowaccName)>0: self.cmbFlowAcc.insertItem (0, flowaccName) self.cmbFlowAcc.setCurrentIndex(0) return flowaccName def sfmFile(self): - "Display file dialog for output file" - sfmName = QFileDialog.getOpenFileName(self, "Standard Flood Map calibration file",".", "ESRI ascii (*.txt);; GeoTiff (*.tif);;All files (*.*)") + "Display file dialog for input file" + sfmName, filter_string = QFileDialog.getOpenFileName(self, "Standard Flood Map calibration file",".", "ESRI ascii (*.txt);; GeoTiff (*.tif);;All files (*.*)") if len(sfmName)>0: self.cmbSFM.insertItem (0, sfmName) self.cmbSFM.setCurrentIndex(0) return sfmName - def calibration_clicked(self): - self.checkBoxManualSet.nextCheckState() - def manualset_clicked(self): - self.checkBoxCalibration.nextCheckState() + # def calibration_clicked(self, state): + # self.checkBoxManualSet.nextCheckState() + # def manualset_clicked(self): + # self.checkBoxCalibration.nextCheckState() ########################################################################################### def from_flowacc_to_stream(self,tab_flowacc,threshold_cell): @@ -394,8 +408,7 @@ def writeOutputGeoTiff(self,arrayData, transform, prj,rows, cols, outFile): format = "GTiff" driver = gdal.GetDriverByName( format ) metadata = driver.GetMetadata() - if metadata.has_key(gdal.DCAP_CREATE) \ - and metadata[gdal.DCAP_CREATE] == 'YES': + if gdal.DCAP_CREATE in metadata and metadata[gdal.DCAP_CREATE] == 'YES': pass else: QMessageBox.information(None,"info","Driver %s does not support Create() method." % format) @@ -947,9 +960,9 @@ def accept(self): n_ok=len(id_ok) ln_hronHbin=numpy.zeros((rows,cols)) for ct_ok in range(0,n_ok): - print ct_ok + print(ct_ok) ct_label=id_ok[ct_ok] - print ct_label + print(ct_label) ln_hronHbin[label_im==ct_label] = 1 diff --git a/GeomorphicFloodIndex/metadata.txt b/GeomorphicFloodIndex/metadata.txt index 73a7a96..dd9c222 100644 --- a/GeomorphicFloodIndex/metadata.txt +++ b/GeomorphicFloodIndex/metadata.txt @@ -13,9 +13,9 @@ name=GeomorphicFloodArea description=GFA - tool is an open-source QGIS plug-in to realize a fast and cost-effective delineation of the floodplains in the contexts where the available data is scarce to carry out hydrological/hydraulic analyses. about=Samela, C., Albano, R., Sole, A., Manfreda, S. (2018). Geomorphic Flood Area (GFA): a QGIS tool for a cost-effective delineation of the flood-prone areas, Computers, Environment and Urban Systems, (doi: 10.1016/j.compenvurbsys.2018.01.013) category=Plugins -version=2.0 -qgisMinimumVersion=2.0 -qgisMaximumVersion=2.99 +version=3.0.0 +qgisMinimumVersion=3.16 +qgisMaximumVersion=3.99 author= Raffaele ALbano, Caterina Samela, Salvatore Manfreda, Aurelia Sole email= raffaele.albano@unibas.it icon=icona.png @@ -25,7 +25,9 @@ icon=icona.png # Optional items: # Uncomment the following line and add your changelog entries: -# changelog= +changelog= + 3.0.0 - initial port to QGIS 3, by Andrea Giudiceandrea + 2.0 - original version 2.0 # tags are comma separated with spaces allowed tags= diff --git a/GeomorphicFloodIndex/resources.py b/GeomorphicFloodIndex/resources.py index 4f3ae4e..84e25d7 100644 --- a/GeomorphicFloodIndex/resources.py +++ b/GeomorphicFloodIndex/resources.py @@ -7,9 +7,9 @@ # # WARNING! All changes made in this file will be lost! -from PyQt4 import QtCore +from qgis.PyQt import QtCore -qt_resource_data = "\ +qt_resource_data = b"\ \x00\x01\x8e\xb5\ \x89\ \x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\ @@ -6394,7 +6394,7 @@ \xae\x42\x60\x82\ " -qt_resource_name = "\ +qt_resource_name = b"\ \x00\x07\ \x07\x3b\xe0\xb3\ \x00\x70\ @@ -6410,7 +6410,7 @@ \x00\x63\x00\x6f\x00\x6e\x00\x61\x00\x2e\x00\x70\x00\x6e\x00\x67\ " -qt_resource_struct = "\ +qt_resource_struct = b"\ \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\ \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\ \x00\x00\x00\x14\x00\x02\x00\x00\x00\x01\x00\x00\x00\x03\ diff --git a/README.md b/README.md index 245887f..d3758a6 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -**GFA v.2.0** +**GFA v.3.0** ---------- ### Geomorphic Flood Area