Skip to content

Commit

Permalink
updates for sip api v2 (qnd qgis 2.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
etiennesky committed Jun 13, 2013
1 parent 41c5577 commit 55113e6
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 89 deletions.
26 changes: 13 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,26 @@ compile: $(UI_FILES) $(RESOURCE_FILES)

# The deploy target only works on unix like operating system where
# the Python plugin directory is located at:
# $HOME/.qgis/python/plugins
# $HOME/.qgis2/python/plugins
deploy: all
mkdir -p $(HOME)/.qgis/python/plugins/$(PLUGINNAME)
mkdir -p $(HOME)/.qgis/python/plugins/$(PLUGINNAME)/tools
mkdir -p $(HOME)/.qgis/python/plugins/$(PLUGINNAME)/icons
cp -vf $(PY_FILES) $(HOME)/.qgis/python/plugins/$(PLUGINNAME)
cp -vf $(UI_FILES1) $(HOME)/.qgis/python/plugins/$(PLUGINNAME)/tools
cp -vf $(RESOURCE_FILES) $(HOME)/.qgis/python/plugins/$(PLUGINNAME)
# cp -vf $(RC_FILES) $(HOME)/.qgis/python/plugins/$(PLUGINNAME)
cp -vf $(EXTRAS) $(HOME)/.qgis/python/plugins/$(PLUGINNAME)
cp -rvf $(TOOL_DIR) $(HOME)/.qgis/python/plugins/$(PLUGINNAME)
cp -rvf $(ICONS_DIR) $(HOME)/.qgis/python/plugins/$(PLUGINNAME)
mkdir -p $(HOME)/.qgis2/python/plugins/$(PLUGINNAME)
mkdir -p $(HOME)/.qgis2/python/plugins/$(PLUGINNAME)/tools
mkdir -p $(HOME)/.qgis2/python/plugins/$(PLUGINNAME)/icons
cp -vf $(PY_FILES) $(HOME)/.qgis2/python/plugins/$(PLUGINNAME)
cp -vf $(UI_FILES1) $(HOME)/.qgis2/python/plugins/$(PLUGINNAME)/tools
cp -vf $(RESOURCE_FILES) $(HOME)/.qgis2/python/plugins/$(PLUGINNAME)
# cp -vf $(RC_FILES) $(HOME)/.qgis2/python/plugins/$(PLUGINNAME)
cp -vf $(EXTRAS) $(HOME)/.qgis2/python/plugins/$(PLUGINNAME)
cp -rvf $(TOOL_DIR) $(HOME)/.qgis2/python/plugins/$(PLUGINNAME)
cp -rvf $(ICONS_DIR) $(HOME)/.qgis2/python/plugins/$(PLUGINNAME)

# The dclean target removes compiled python files from plugin directory
# also delets any .svn entry
dclean:
find $(HOME)/.qgis/python/plugins/$(PLUGINNAME) -iname "*.pyc" -delete
find $(HOME)/.qgis2/python/plugins/$(PLUGINNAME) -iname "*.pyc" -delete

# The zip target deploys the plugin and creates a zip file with the deployed
# content. You can then upload the zip file on http://plugins.qgis.org
zip: deploy dclean
rm -f $(PLUGINNAME).zip
cd $(HOME)/.qgis/python/plugins; zip -9r $(CURDIR)/$(PLUGINNAME).zip $(PLUGINNAME)
cd $(HOME)/.qgis2/python/plugins; zip -9r $(CURDIR)/$(PLUGINNAME).zip $(PLUGINNAME)
25 changes: 0 additions & 25 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,6 @@
#
#---------------------------------------------------------------------

def name():
return "Profile Tool"

def description():
return "Plots terrain profile"

def version():
return "Version 3.5.4"

def qgisMinimumVersion():
return '1.6'

def icon():
return "icons/profileIcon.png"

def authorName():
return 'Borys Jurgiel - Patrice Verchere - Etienne Tourigny'
def author():
return 'Borys Jurgiel - Patrice Verchere - Etienne Tourigny'
def email():
return '[email protected]'

def homepage():
return 'http://hub.qgis.org/projects/profiletool/wiki'

def classFactory(iface):
from profileplugin import ProfilePlugin
return ProfilePlugin(iface)
7 changes: 4 additions & 3 deletions metadata.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
; the next section is mandatory
[general]
name=Profile tool
qgisMinimumVersion=1.0
qgisMinimumVersion=2.0
description=Plots terrain profile
category=Raster
version=version 3.5.4
version=version 3.6.0
author=Borys Jurgiel - Patrice Verchere - Etienne Tourigny
[email protected]
; end of mandatory metadata

; start of optional metadata
changelog=
3.6.0 : update to sip api v2 (and qgis 2.0)
3.5.4 : fix color bugs #6870
3.5.3 : fix bugs with new api 2.0
3.5.2 : fix bugs #6679 and #6680
Expand Down Expand Up @@ -40,7 +41,7 @@ repository=http://hub.qgis.org/projects/profiletool/repository
icon=icons/profileIcon.png

; experimental flag
experimental=True
experimental=False

; deprecated flag (applies to the whole plugin and not only to the uploaded version)
deprecated=False
14 changes: 7 additions & 7 deletions profileplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ def run(self):
self.lastClicked = [[-9999999999.9,9999999999.9]]
#Help about what doing
if self.selectionmethod == 0:
self.iface.mainWindow().statusBar().showMessage(QString(self.textquit0))
self.iface.mainWindow().statusBar().showMessage(self.textquit0)
elif self.selectionmethod == 1:
self.iface.mainWindow().statusBar().showMessage(QString(self.textquit1))
self.iface.mainWindow().statusBar().showMessage(self.textquit1)



Expand Down Expand Up @@ -182,7 +182,7 @@ def leftClicked(self,position): #Add point to analyse
self.previousLayer = result[2]
self.doprofile.calculateProfil(self.pointstoDraw, self.mdl,self.plotlibrary, False)
self.pointstoDraw = []
self.iface.mainWindow().statusBar().showMessage(QString(self.textquit1))
self.iface.mainWindow().statusBar().showMessage(self.textquit1)

def doubleClicked(self,position):
if self.selectionmethod == 0:
Expand All @@ -197,7 +197,7 @@ def doubleClicked(self,position):
self.pointstoDraw = []
#temp point to distinct leftclick and dbleclick
self.dblclktemp = newPoints
self.iface.mainWindow().statusBar().showMessage(QString(self.textquit0))
self.iface.mainWindow().statusBar().showMessage(self.textquit0)
if self.selectionmethod == 1:
return

Expand Down Expand Up @@ -237,7 +237,7 @@ def deactivate(self): #enable clean exit of the plugin
QObject.disconnect(self.tool, SIGNAL("rightClicked"), self.rightClicked)
QObject.disconnect(self.tool, SIGNAL("doubleClicked"), self.doubleClicked)
self.rubberband.reset(self.polygon)
self.iface.mainWindow().statusBar().showMessage(QString(""))
self.iface.mainWindow().statusBar().showMessage("")

def cleaning(self): #used on right click
try:
Expand Down Expand Up @@ -275,9 +275,9 @@ def selectionMethod(self,item):
self.canvas.setMapTool(self.tool)
self.connectTool()
if self.selectionmethod == 0:
self.iface.mainWindow().statusBar().showMessage(QString(self.textquit0))
self.iface.mainWindow().statusBar().showMessage(self.textquit0)
elif self.selectionmethod == 1:
self.iface.mainWindow().statusBar().showMessage(QString(self.textquit1))
self.iface.mainWindow().statusBar().showMessage(self.textquit1)

def changePlotLibrary(self, item):
self.plotlibrary = self.wdg.comboBox_2.itemText(item)
Expand Down
6 changes: 3 additions & 3 deletions tools/dataReaderTool.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def dataReaderTool(self, iface1,tool1, profile1, pointstoDraw1, fullresolution1)
#if ident is not None and ident.has_key(choosenBand+1):
if ident is not None and (choosenBand+1 in ident.results()):
#attr = ident[choosenBand+1].toDouble()[0]
attr = ident.results()[choosenBand+1].toDouble()[0]
attr = ident.results()[choosenBand+1]
#if layer.dataProvider().isNoDataValue ( choosenBand+1, attr ):
#attr = 0
else:
Expand All @@ -138,13 +138,13 @@ def dataReaderTool(self, iface1,tool1, profile1, pointstoDraw1, fullresolution1)
temp = n
if n % stepp == 0:
progress += "|"
self.iface.mainWindow().statusBar().showMessage(QString(progress))
self.iface.mainWindow().statusBar().showMessage(progress)
lbefore = l[len(l)-1]
#End of polyline analysis
#filling the main data dictionary "profiles"
self.profiles["l"] = l
self.profiles["z"] = z
self.iface.mainWindow().statusBar().showMessage(QString(""))
self.iface.mainWindow().statusBar().showMessage("")

return self.profiles

Expand Down
16 changes: 8 additions & 8 deletions tools/doprofile.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ def calculateProfil(self, points1, model1, library, vertline = True):

#creating the plots of profiles
for i in range(0 , model1.rowCount()):
self.profiles.append( {"layer": model1.item(i,4).data(Qt.EditRole).toPyObject() } )
self.profiles[i]["band"] = model1.item(i,3).data(Qt.EditRole).toPyObject() - 1
self.profiles.append( {"layer": model1.item(i,4).data(Qt.EditRole) } )
self.profiles[i]["band"] = model1.item(i,3).data(Qt.EditRole) - 1
self.profiles[i] = DataReaderTool().dataReaderTool(self.iface, self.tool, self.profiles[i], self.pointstoDraw, self.dockwidget.checkBox.isChecked())
PlottingTool().attachCurves(self.dockwidget, self.profiles, model1, library)
PlottingTool().reScalePlot(self.dockwidget.scaleSlider.value(), self.dockwidget, self.profiles, library)
Expand Down Expand Up @@ -105,20 +105,20 @@ def calculateProfil(self, points1, model1, library, vertline = True):
self.groupBox[i].setMinimumSize(QSize(0, 150))
self.groupBox[i].setMaximumSize(QSize(16777215, 150))
self.groupBox[i].setTitle(QApplication.translate("GroupBox" + str(i), self.profiles[i]["layer"].name(), None, QApplication.UnicodeUTF8))
self.groupBox[i].setObjectName(QString.fromUtf8("groupBox" + str(i)))
self.groupBox[i].setObjectName("groupBox" + str(i))

self.verticalLayout.append( QVBoxLayout(self.groupBox[i]) )
self.verticalLayout[i].setObjectName(QString.fromUtf8("verticalLayout"))
self.verticalLayout[i].setObjectName("verticalLayout")
#The table
self.tableView.append( QTableView(self.groupBox[i]) )
self.tableView[i].setObjectName(QString.fromUtf8("tableView" + str(i)))
self.tableView[i].setObjectName("tableView" + str(i))
font = QFont("Arial", 8)
column = len(self.profiles[i]["l"])
self.mdl = QStandardItemModel(2, column)
for j in range(len(self.profiles[i]["l"])):
self.mdl.setData(self.mdl.index(0, j, QModelIndex()) ,QVariant(self.profiles[i]["l"][j]))
self.mdl.setData(self.mdl.index(0, j, QModelIndex()) ,self.profiles[i]["l"][j])
self.mdl.setData(self.mdl.index(0, j, QModelIndex()) ,font ,Qt.FontRole)
self.mdl.setData(self.mdl.index(1, j, QModelIndex()) ,QVariant(self.profiles[i]["z"][j]))
self.mdl.setData(self.mdl.index(1, j, QModelIndex()) ,self.profiles[i]["z"][j])
self.mdl.setData(self.mdl.index(1, j, QModelIndex()) ,font ,Qt.FontRole)
self.tableView[i].verticalHeader().setDefaultSectionSize(18)
self.tableView[i].horizontalHeader().setDefaultSectionSize(60)
Expand All @@ -132,7 +132,7 @@ def calculateProfil(self, points1, model1, library, vertline = True):
sizePolicy.setHeightForWidth(self.pushButton[i].sizePolicy().hasHeightForWidth())
self.pushButton[i].setSizePolicy(sizePolicy)
self.pushButton[i].setText(QApplication.translate("GroupBox", "Copy to clipboard", None, QApplication.UnicodeUTF8))
self.pushButton[i].setObjectName(QString.fromUtf8( str(i)) )
self.pushButton[i].setObjectName(str(i))
self.verticalLayout[i].addWidget(self.pushButton[i])
self.VLayout.addWidget(self.groupBox[i])
QObject.connect(self.pushButton[i], SIGNAL("clicked()"), self.copyTable)
Expand Down
24 changes: 12 additions & 12 deletions tools/plottingtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ def attachCurves(self, wdg, profiles, model1, library):
for i in range(0 , model1.rowCount()):
curve = QwtPlotCurve(profiles[i]["layer"].name())
curve.setData(profiles[i]["l"], profiles[i]["z"])
curve.setPen(QPen(model1.item(i,1).data(Qt.BackgroundRole).toPyObject(), 3))
curve.setPen(QPen(model1.item(i,1).data(Qt.BackgroundRole), 3))
curve.attach(wdg.plotWdg)
if model1.item(i,0).data(Qt.CheckStateRole).toPyObject():
if model1.item(i,0).data(Qt.CheckStateRole):
curve.setVisible(True)
else:
curve.setVisible(False)
Expand All @@ -150,11 +150,11 @@ def attachCurves(self, wdg, profiles, model1, library):
elif library == "Matplotlib" and has_mpl:
for i in range(0 , model1.rowCount()):

if model1.item(i,0).data(Qt.CheckStateRole).toPyObject():
if model1.item(i,0).data(Qt.CheckStateRole):
wdg.plotWdg.figure.get_axes()[0].plot(profiles[i]["l"], profiles[i]["z"], gid = profiles[i]["layer"].name(), linewidth = 3, visible = True)
else:
wdg.plotWdg.figure.get_axes()[0].plot(profiles[i]["l"], profiles[i]["z"], gid = profiles[i]["layer"].name(), linewidth = 3, visible = False)
self.changeColor(wdg, "Matplotlib", model1.item(i,1).data(Qt.BackgroundRole).toPyObject(), profiles[i]["layer"].name())
self.changeColor(wdg, "Matplotlib", model1.item(i,1).data(Qt.BackgroundRole), profiles[i]["layer"].name())
try:
self.reScalePlot(self.dockwidget.scaleSlider.value())
wdg.plotWdg.figure.get_axes()[0].set_xbound( 0, max(self.profiles[len(self.profiles) - 1]["l"]) )
Expand Down Expand Up @@ -274,8 +274,8 @@ def manageMatplotlibAxe(self, axe1):

def outPrint(self, iface, wdg, mdl, library): # Postscript file rendering doesn't work properly yet.
for i in range (0,mdl.rowCount()):
if mdl.item(i,0).data(Qt.CheckStateRole).toPyObject():
name = str(mdl.item(i,2).data(Qt.EditRole).toPyObject())
if mdl.item(i,0).data(Qt.CheckStateRole):
name = str(mdl.item(i,2).data(Qt.EditRole))
#return
fileName = QFileDialog.getSaveFileName(iface.mainWindow(), "Save As","Profile of " + name + ".ps","PostScript Format (*.ps)")
if not fileName.isEmpty():
Expand All @@ -295,8 +295,8 @@ def outPrint(self, iface, wdg, mdl, library): # Postscript file rendering doesn'

def outPDF(self, iface, wdg, mdl, library):
for i in range (0,mdl.rowCount()):
if mdl.item(i,0).data(Qt.CheckStateRole).toPyObject():
name = str(mdl.item(i,2).data(Qt.EditRole).toPyObject())
if mdl.item(i,0).data(Qt.CheckStateRole):
name = str(mdl.item(i,2).data(Qt.EditRole))
break
fileName = QFileDialog.getSaveFileName(iface.mainWindow(), "Save As","Profile of " + name + ".pdf","Portable Document Format (*.pdf)")
if not fileName.isEmpty():
Expand All @@ -314,8 +314,8 @@ def outPDF(self, iface, wdg, mdl, library):

def outSVG(self, iface, wdg, mdl, library):
for i in range (0,mdl.rowCount()):
if mdl.item(i,0).data(Qt.CheckStateRole).toPyObject():
name = str(mdl.item(i,2).data(Qt.EditRole).toPyObject())
if mdl.item(i,0).data(Qt.CheckStateRole):
name = str(mdl.item(i,2).data(Qt.EditRole))
#return
fileName = QFileDialog.getSaveFileName(iface.mainWindow(), "Save As","Profile of " + name + ".svg","Scalable Vector Graphics (*.svg)")
if not fileName.isEmpty():
Expand All @@ -329,8 +329,8 @@ def outSVG(self, iface, wdg, mdl, library):

def outPNG(self, iface, wdg, mdl, library):
for i in range (0,mdl.rowCount()):
if mdl.item(i,0).data(Qt.CheckStateRole).toPyObject():
name = str(mdl.item(i,2).data(Qt.EditRole).toPyObject())
if mdl.item(i,0).data(Qt.CheckStateRole):
name = str(mdl.item(i,2).data(Qt.EditRole))
#return
fileName = QFileDialog.getSaveFileName(iface.mainWindow(), "Save As","Profile of " + name + ".png","Portable Network Graphics (*.png)")
if not fileName.isEmpty():
Expand Down
4 changes: 2 additions & 2 deletions tools/selectlinetool.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,11 @@ def getPointTableFromSelectedLine(self, iface, tool, newPoints, layerindex, prev

if QGis.QGIS_VERSION_INT >= 10900:
previousLayer = layer
iface.mainWindow().statusBar().showMessage(QString("selectline"))
iface.mainWindow().statusBar().showMessage("selectline")
layer.removeSelection()
else:
previousLayer = layer
iface.mainWindow().statusBar().showMessage(QString("selectline"))
iface.mainWindow().statusBar().showMessage("selectline")
layer.removeSelection( False )
#closest
#closestFeature = layer.getFeatures(QgsFeatureRequest(featureId)).next()
Expand Down
26 changes: 13 additions & 13 deletions tools/tableviewtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def addLayer(self , iface, mdl, layer1 = None):
layer = iface.mapCanvas().layer(i)
if layer.type() == layer.RasterLayer:
for j in range(0, mdl.rowCount()):
if str(mdl.item(j,2).data(Qt.EditRole).toPyObject()) == str(layer.name()):
if str(mdl.item(j,2).data(Qt.EditRole)) == str(layer.name()):
donothing = True
else:
donothing = True
Expand Down Expand Up @@ -79,13 +79,13 @@ def addLayer(self , iface, mdl, layer1 = None):
#Complete the tableview
row = mdl.rowCount()
mdl.insertRow(row)
mdl.setData( mdl.index(row, 0, QModelIndex()) ,QVariant(True), Qt.CheckStateRole)
mdl.setData( mdl.index(row, 0, QModelIndex()) ,True, Qt.CheckStateRole)
mdl.item(row,0).setFlags(Qt.ItemIsSelectable)
mdl.setData( mdl.index(row, 1, QModelIndex()) ,QVariant(QColor(Qt.red)) , Qt.BackgroundRole)
mdl.setData( mdl.index(row, 1, QModelIndex()) ,QColor(Qt.red) , Qt.BackgroundRole)
mdl.item(row,1).setFlags(Qt.NoItemFlags)
mdl.setData( mdl.index(row, 2, QModelIndex()) ,QVariant(layer2.name()))
mdl.setData( mdl.index(row, 2, QModelIndex()) ,layer2.name())
mdl.item(row,2).setFlags(Qt.NoItemFlags)
mdl.setData( mdl.index(row, 3, QModelIndex()) ,QVariant(choosenBand + 1))
mdl.setData( mdl.index(row, 3, QModelIndex()) ,choosenBand + 1)
mdl.item(row,3).setFlags(Qt.NoItemFlags)
mdl.setData( mdl.index(row, 4, QModelIndex()) ,layer2)
mdl.item(row,4).setFlags(Qt.NoItemFlags)
Expand All @@ -99,29 +99,29 @@ def removeLayer(self, iface, mdl):

list1 = []
for i in range(0,mdl.rowCount()):
list1.append(str(i +1) + " : " + mdl.item(i,2).data(Qt.EditRole).toPyObject())
list1.append(str(i +1) + " : " + mdl.item(i,2).data(Qt.EditRole))
testqt, ok = QInputDialog.getItem(iface.mainWindow(), "Layer selector", "Choose the Layer", list1, False)
if ok:
for i in range(0,mdl.rowCount()):
if testqt == (str(i+1) + " : " + mdl.item(i,2).data(Qt.EditRole).toPyObject()):
if testqt == (str(i+1) + " : " + mdl.item(i,2).data(Qt.EditRole)):
mdl.removeRow(i)
break

def onClick(self, iface, wdg, mdl, plotlibrary, index1): #action when clicking the tableview
temp = mdl.itemFromIndex(index1)
if index1.column() == 1: #modifying color
name = mdl.item(index1.row(),2).data(Qt.EditRole).toPyObject()
color = QColorDialog().getColor(temp.data(Qt.BackgroundRole).toPyObject())
mdl.setData( mdl.index(temp.row(), 1, QModelIndex()) ,QVariant(color) , Qt.BackgroundRole)
name = mdl.item(index1.row(),2).data(Qt.EditRole)
color = QColorDialog().getColor(temp.data(Qt.BackgroundRole))
mdl.setData( mdl.index(temp.row(), 1, QModelIndex()) ,color , Qt.BackgroundRole)
PlottingTool().changeColor(wdg, plotlibrary, color, name)
elif index1.column() == 0: #modifying checkbox
name = mdl.item(index1.row(),2).data(Qt.EditRole).toPyObject()
booltemp = temp.data(Qt.CheckStateRole).toPyObject()
name = mdl.item(index1.row(),2).data(Qt.EditRole)
booltemp = temp.data(Qt.CheckStateRole)
if booltemp == True:
booltemp = False
else:
booltemp = True
mdl.setData( mdl.index(temp.row(), 0, QModelIndex()) ,QVariant(booltemp), Qt.CheckStateRole)
mdl.setData( mdl.index(temp.row(), 0, QModelIndex()) ,booltemp, Qt.CheckStateRole)
PlottingTool().changeAttachCurve(wdg, plotlibrary, booltemp, name)
else:
return
Expand Down
6 changes: 3 additions & 3 deletions ui/ui_dlgabout.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ def __init__(self, parent=None):
fp = os.path.join( os.path.abspath(os.path.join(os.path.dirname(__file__),"..")) , "metadata.txt")

iniText = QSettings(fp, QSettings.IniFormat)
verno = iniText.value("version").toString()
name = iniText.value("name").toString()
description = iniText.value("description").toString()
verno = iniText.value("version")
name = iniText.value("name")
description = iniText.value("description")

self.title.setText( name )
self.description.setText( description + " - " + verno)
Expand Down

0 comments on commit 55113e6

Please sign in to comment.