Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to QGIS 3 #1

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# CONFIGURATION
PLUGIN_UPLOAD = $(CURDIR)/plugin_upload.py

QGISDIR=.qgis2
QGISDIR=.qgis3

# Makefile for a PyQGIS plugin

Expand Down Expand Up @@ -48,10 +48,10 @@ default: compile
compile: $(UI_FILES) $(RESOURCE_FILES)

%_rc.py : %.qrc
pyrcc4 -o $*_rc.py $<
pyrcc5 -o $*_rc.py $<

%.py : %.ui
pyuic4 -o $@ $<
pyuic5 -o $@ $<

%.qm : %.ts
lrelease $<
Expand Down Expand Up @@ -100,7 +100,7 @@ upload: zip
# transup
# update .ts translation files
transup:
pylupdate4 Makefile
pylupdate5 Makefile

# transcompile
# compile translation files into .qm binary format
Expand Down
5 changes: 0 additions & 5 deletions README~

This file was deleted.

2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@

def classFactory(iface):
# load BankFullDetection class from file BankFullDetection
from bankfulldetection import BankFullDetection
from .bankfulldetection import BankFullDetection
return BankFullDetection(iface)
Binary file removed __init__.pyc
Binary file not shown.
9 changes: 0 additions & 9 deletions bankfulldetection.pro~

This file was deleted.

9 changes: 5 additions & 4 deletions bankfulldetection.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@
***************************************************************************/
"""
# 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 *
from qgis.core import *
# Initialize Qt resources from file resources.py
import resources_rc
from . import resources_rc
# Import the code for the dialog
from bankfulldetectiondialog import BankFullDetectionDialog
from .bankfulldetectiondialog import BankFullDetectionDialog
import os.path


Expand Down
Binary file removed bankfulldetection.pyc
Binary file not shown.
35 changes: 18 additions & 17 deletions bankfulldetectiondialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
"""

import os
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from ui_bankfulldetection import Ui_BankFullDetection
from qgis.PyQt.QtCore import *
from qgis.PyQt.QtGui import *
from qgis.PyQt.QtWidgets import *
from .ui_bankfulldetection import Ui_BankFullDetection
from qgis.core import *
from tools.XSGenerator import *
from tools.profiler import ProfilerTool
from tools.BankElevationDetection import mainFun
from .tools.XSGenerator import *
from .tools.profiler import ProfilerTool
from .tools.BankElevationDetection import mainFun


class BankFullDetectionDialog(QDialog, Ui_BankFullDetection):
Expand All @@ -53,20 +54,20 @@ def __init__(self,iface):

#~ connections
#~ self.iface.clicked.connect(self.runXS)
QObject.connect(self.genXSbtn, SIGNAL( "clicked()" ), self.genXS)
QObject.connect(self.buttonProf, SIGNAL( "clicked()" ), self.runProfile)
QObject.connect(self.ShpSaveBtn, SIGNAL( "clicked()" ), self.writeLayer)
QObject.connect(self.selXS, SIGNAL( "clicked()" ), self.runProfileXS)
self.genXSbtn.clicked.connect(self.genXS)
self.buttonProf.clicked.connect(self.runProfile)
self.ShpSaveBtn.clicked.connect(self.writeLayer)
self.selXS.clicked.connect(self.runProfileXS)


def setup_gui(self):
""" Function to combos creation """
self.comboVector.clear()
self.comboDEM.clear()
curr_map_layers = QgsMapLayerRegistry.instance().mapLayers()
curr_map_layers = QgsProject.instance().mapLayers()
layerRasters = []
layerVectors = []
for name, layer in curr_map_layers.iteritems():
for layer in curr_map_layers.values():
if layer.type() == QgsMapLayer.VectorLayer:
layerVectors.append(unicode(layer.name()))
elif layer.type() == QgsMapLayer.RasterLayer:
Expand All @@ -75,7 +76,7 @@ def setup_gui(self):
self.comboVector.addItems( layerVectors )

def getLayerByName(self,LayerName):
layer = QgsMapLayerRegistry.instance().mapLayersByName(LayerName)[0]
layer = QgsProject.instance().mapLayersByName(LayerName)[0]
return layer


Expand Down Expand Up @@ -126,17 +127,17 @@ def runProfile(self):
vl = QgsVectorLayer("Polygon", self.vlName, "memory")
pr = vl.dataProvider()
fet = QgsFeature()
fet.setGeometry( QgsGeometry.fromPolygon( [ ringPoints ] ) )
fet.setGeometry( QgsGeometry.fromPolygonXY( [ ringPoints ] ) )
pr.addFeatures( [fet] )
QgsMapLayerRegistry.instance().addMapLayer(vl)
QgsProject.instance().addMapLayer(vl)

#check if output file is selected
shapefilename = self.ShpSaveLine.text()
if shapefilename == None:
QMessageBox.critical(self.iface.mainWindow(),QCoreApplication.translate( "message","Error"), QCoreApplication.translate( "message","You have to select output file first"))
else:
#~ save vector layer to shapefile
error = QgsVectorFileWriter.writeAsVectorFormat(vl, shapefilename, "CP1250", None, "ESRI Shapefile")
error = QgsVectorFileWriter.writeAsVectorFormat(vl, shapefilename, "CP1250", vl.sourceCrs(), "ESRI Shapefile")
if error == QgsVectorFileWriter.NoError:
QMessageBox.information( self.iface.mainWindow(),"Info",
str("File %s " %(str(unicode(vl.name())).upper())) + QCoreApplication.translate( "message","succesfully saved"))
Expand All @@ -153,7 +154,7 @@ def writeLayer(self):
self.vlName = os.path.splitext(base)[0]

def runProfileXS(self):
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg as NavigationToolbar
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar

#~ take input parameters fron GUI
rasterName = self.comboDEM.currentText()
Expand Down
Binary file removed bankfulldetectiondialog.pyc
Binary file not shown.
Binary file modified icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
146 changes: 16 additions & 130 deletions icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@


[general]
name=QFluvial
qgisMinimumVersion=2.0
description=Fluvial geomophological tool
name=Bankfull width detection
qgisMinimumVersion=3.0
description=Automatic bankfull width detection
version=0.1
author=Pierluigi De Rosa
[email protected]
Expand Down
Loading