Skip to content

Commit d99e9ca

Browse files
author
brushtyler
committed
[FEATURE] added GUI for gdaldem, to fix #3064
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15495 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 72d0b13 commit d99e9ca

File tree

7 files changed

+677
-26
lines changed

7 files changed

+677
-26
lines changed

python/plugins/GdalTools/GdalTools.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,16 @@ def initGui( self ):
198198
self.menu.addAction(self.rgb)
199199

200200
self.tileindex = QAction( QIcon( ":icons/tileindex.png" ), QCoreApplication.translate( "GdalTools", "Tile index" ), self.iface.mainWindow() )
201-
self.rgb.setStatusTip( QCoreApplication.translate( "GdalTools", "Build a shapefile as a raster tileindex" ) )
201+
self.tileindex.setStatusTip( QCoreApplication.translate( "GdalTools", "Build a shapefile as a raster tileindex" ) )
202202
QObject.connect( self.tileindex, SIGNAL( "triggered()" ), self.doTileIndex )
203203
self.menu.addAction(self.tileindex)
204204

205+
if self.GdalVersion >= "1.7":
206+
self.dem = QAction( QIcon( ":icons/dem.png" ), QCoreApplication.translate( "GdalTools", "DEM" ), self.iface.mainWindow() )
207+
self.dem.setStatusTip( QCoreApplication.translate( "GdalTools", "Tool to analyze and visualize DEMs" ) )
208+
QObject.connect( self.dem, SIGNAL( "triggered()" ), self.doDEM )
209+
self.menu.addAction(self.dem)
210+
205211
self.settings = QAction( QCoreApplication.translate( "GdalTools", "GdalTools settings" ), self.iface.mainWindow() )
206212
self.settings.setStatusTip( QCoreApplication.translate( "GdalTools", "Various settings for Gdal Tools" ) )
207213
QObject.connect( self.settings, SIGNAL( "triggered()" ), self.doSettings )
@@ -311,6 +317,11 @@ def doTileIndex( self ):
311317
d = TileIndex( self.iface )
312318
d.show_()
313319

320+
def doDEM( self ):
321+
from tools.doDEM import GdalToolsDialog as DEM
322+
d = DEM( self.iface )
323+
d.show_()
324+
314325
def doSettings( self ):
315326
from tools.doSettings import GdalToolsSettingsDialog as Settings
316327
d = Settings( self.iface )

python/plugins/GdalTools/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def name():
2222
def description():
2323
return "Integrate gdal tools into qgis"
2424
def version():
25-
return "Version 1.2.23"
25+
return "Version 1.2.24"
2626
def qgisMinimumVersion():
2727
return "1.0"
2828
def icon():
1.55 KB
Loading
+22-21
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
<RCC>
2-
<qresource>
3-
<file>icons/contour.png</file>
4-
<file>icons/merge.png</file>
5-
<file>icons/polygonize.png</file>
6-
<file>icons/rasterize.png</file>
7-
<file>icons/sieve.png</file>
8-
<file>icons/vrt.png</file>
9-
<file>icons/warp.png</file>
10-
<file>icons/proximity.png</file>
11-
<file>icons/nearblack.png</file>
12-
<file>icons/grid.png</file>
13-
<file>icons/translate.png</file>
14-
<file>icons/raster-info.png</file>
15-
<file>icons/projection-add.png</file>
16-
<file>icons/raster-overview.png</file>
17-
<file>icons/raster-clip.png</file>
18-
<file>icons/raster-paletted.png</file>
19-
<file>icons/raster-rgb.png</file>
20-
<file>icons/tileindex.png</file>
21-
<file>icons/about.png</file>
22-
</qresource>
2+
<qresource prefix="/" >
3+
<file>icons/contour.png</file>
4+
<file>icons/merge.png</file>
5+
<file>icons/polygonize.png</file>
6+
<file>icons/rasterize.png</file>
7+
<file>icons/sieve.png</file>
8+
<file>icons/vrt.png</file>
9+
<file>icons/warp.png</file>
10+
<file>icons/proximity.png</file>
11+
<file>icons/nearblack.png</file>
12+
<file>icons/grid.png</file>
13+
<file>icons/translate.png</file>
14+
<file>icons/raster-info.png</file>
15+
<file>icons/projection-add.png</file>
16+
<file>icons/raster-overview.png</file>
17+
<file>icons/raster-clip.png</file>
18+
<file>icons/raster-paletted.png</file>
19+
<file>icons/raster-rgb.png</file>
20+
<file>icons/tileindex.png</file>
21+
<file>icons/about.png</file>
22+
<file>icons/dem.png</file>
23+
</qresource>
2324
</RCC>
+144
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# -*- coding: utf-8 -*-
2+
from PyQt4.QtCore import *
3+
from PyQt4.QtGui import *
4+
from qgis.core import *
5+
from qgis.gui import *
6+
7+
from ui_widgetDEM import Ui_GdalToolsWidget as Ui_Widget
8+
from widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget
9+
import GdalTools_utils as Utils
10+
11+
class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
12+
13+
def __init__(self, iface):
14+
QWidget.__init__(self)
15+
self.iface = iface
16+
self.modes = ("hillshade", "slope", "aspect", "color-relief", "TRI", "TPI", "roughness")
17+
18+
self.setupUi(self)
19+
BasePluginWidget.__init__(self, self.iface, "gdaldem")
20+
21+
# set the default QSpinBoxes and QProgressBar value
22+
self.bandSpin.setValue(1)
23+
24+
self.hillshadeZFactorSpin.setValue(1)
25+
self.hillshadeScaleSpin.setValue(1)
26+
self.hillshadeAltitudeSpin.setValue(45.0)
27+
self.hillshadeAzimuthSpin.setValue(315.0)
28+
self.slopeScaleSpin.setValue(1)
29+
30+
self.outputFormat = Utils.fillRasterOutputFormat()
31+
32+
self.setParamsStatus(
33+
[
34+
(self.inputLayerCombo, [SIGNAL("currentIndexChanged(int)"), SIGNAL("editTextChanged(const QString &)")] ),
35+
(self.outputFileEdit, SIGNAL("textChanged(const QString &)")),
36+
(self.computeEdgesCheck, SIGNAL("stateChanged(int)"), None, "1.8.0"),
37+
(self.bandSpin, SIGNAL("valueChanged(int)"), self.bandCheck),
38+
(self.creationOptionsTable, [SIGNAL("cellValueChanged(int, int)"), SIGNAL("rowRemoved()")], self.creationGroupBox),
39+
(self.modeCombo, SIGNAL("currentIndexChanged(int)")),
40+
([self.hillshadeZFactorSpin, self.hillshadeScaleSpin, self.hillshadeAltitudeSpin, self.hillshadeAzimuthSpin], SIGNAL("valueChanged(double)")),
41+
(self.slopeScaleSpin, SIGNAL("valueChanged(double)")),
42+
(self.slopePercentCheck, SIGNAL("stateChanged(int)")),
43+
([self.aspectTrigonometricCheck, self.aspectZeroForFlatCheck], SIGNAL("stateChanged(int)")),
44+
(self.colorConfigFileEdit, SIGNAL("textChanged(const QString &)")),
45+
([self.colorExactRadio, self.colorNearestRadio], SIGNAL("toggled(bool)"), self.colorMatchGroupBox),
46+
(self.colorAlphaCheck, SIGNAL("stateChanged(int)"))
47+
]
48+
)
49+
50+
self.connect(self.selectInputFileButton, SIGNAL("clicked()"), self.fillInputFileEdit)
51+
self.connect(self.selectOutputFileButton, SIGNAL("clicked()"), self.fillOutputFileEdit)
52+
self.connect(self.colorSelectConfigFileButton, SIGNAL("clicked()"), self.fillColorConfigFileEdit)
53+
self.connect(self.modeCombo, SIGNAL("currentIndexChanged(int)"), self.showModeParams)
54+
55+
def showModeParams(self, index):
56+
self.stackedWidget.setVisible( index < 4 )
57+
58+
def onLayersChanged(self):
59+
self.fillInputLayerCombo()
60+
61+
def fillInputLayerCombo(self):
62+
self.inputLayerCombo.clear()
63+
( self.layers, names ) = Utils.LayerRegistry.instance().getRasterLayers()
64+
self.inputLayerCombo.addItems( names )
65+
66+
def fillInputFileEdit(self):
67+
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
68+
inputFile = Utils.FileDialog.getOpenFileName(self, self.tr( "Select the file for DEM" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter)
69+
if inputFile.isEmpty():
70+
return
71+
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
72+
73+
self.inputLayerCombo.setCurrentIndex(-1)
74+
self.inputLayerCombo.setEditText(inputFile)
75+
76+
def fillOutputFileEdit(self):
77+
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
78+
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr( "Select the raster file to save the results to" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter )
79+
if outputFile.isEmpty():
80+
return
81+
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
82+
83+
self.outputFormat = Utils.fillRasterOutputFormat( lastUsedFilter, outputFile )
84+
self.outputFileEdit.setText(outputFile)
85+
86+
def fillColorConfigFileEdit(self):
87+
configFile = Utils.FileDialog.getOpenFileName(self, self.tr( "Select the color configuration file" ), "*")
88+
if configFile.isEmpty():
89+
return
90+
91+
self.colorConfigFileEdit.setText(configFile)
92+
93+
def getArguments(self):
94+
mode = self.modes[ self.modeCombo.currentIndex() ]
95+
arguments = QStringList()
96+
arguments << mode
97+
arguments << self.getInputFileName()
98+
if mode == "color-relief":
99+
arguments << self.colorConfigFileEdit.text()
100+
arguments << self.outputFileEdit.text()
101+
if mode == "hillshade":
102+
arguments << "-z" << str(self.hillshadeZFactorSpin.value())
103+
arguments << "-s" << str(self.hillshadeScaleSpin.value())
104+
arguments << "-az" << str(self.hillshadeAzimuthSpin.value())
105+
arguments << "-alt" << str(self.hillshadeAltitudeSpin.value())
106+
elif mode == "slope":
107+
if self.slopePercentCheck.isChecked():
108+
arguments << "-p"
109+
arguments << "-s" << str(self.slopeScaleSpin.value())
110+
elif mode == "aspect":
111+
if self.aspectTrigonometricCheck.isChecked():
112+
arguments << "-trigonometric"
113+
if self.aspectZeroForFlatCheck.isChecked():
114+
arguments << "-zero_for_flat"
115+
elif mode == "color-relief":
116+
if self.colorAlphaCheck.isChecked():
117+
arguments << "-alpha"
118+
if self.colorMatchGroupBox.isChecked():
119+
if self.colorExactRadio.isChecked():
120+
arguments << "-exact_color_entry"
121+
elif self.colorNearestRadio.isChecked():
122+
arguments << "-nearest_color_entry"
123+
if self.computeEdgesCheck.isChecked():
124+
arguments << "-compute_edges"
125+
if self.bandCheck.isChecked():
126+
arguments << "-b" << str(self.bandSpin.value())
127+
if not self.outputFileEdit.text().isEmpty():
128+
arguments << "-of" << self.outputFormat
129+
if self.creationGroupBox.isChecked():
130+
for opt in self.creationOptionsTable.options():
131+
arguments << "-co" << opt
132+
return arguments
133+
134+
def getInputFileName(self):
135+
if self.inputLayerCombo.currentIndex() >= 0:
136+
return self.layers[self.inputLayerCombo.currentIndex()].source()
137+
return self.inputLayerCombo.currentText()
138+
139+
def getOutputFileName(self):
140+
return self.outputFileEdit.text()
141+
142+
def addLayerIntoCanvas(self, fileInfo):
143+
self.iface.addRasterLayer(fileInfo.filePath())
144+

python/plugins/GdalTools/tools/doGrid.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def __init__(self, iface):
3939
(self.outputFileEdit, SIGNAL("textChanged(const QString &)")),
4040
(self.zfieldCombo, SIGNAL("currentIndexChanged(int)"), self.zfieldCheck),
4141
(self.algorithmCombo, SIGNAL("currentIndexChanged(int)"), self.algorithmCheck),
42-
(self.stackedWidget, SIGNAL("currentChanged(int)"), self.algorithmCheck),
42+
(self.stackedWidget, None, self.algorithmCheck),
4343
([self.invdistPowerSpin, self.invdistSmothingSpin, self.invdistRadius1Spin, self.invdistRadius2Spin, self.invdistAngleSpin, self.invdistNoDataSpin], SIGNAL("valueChanged(double)")),
4444
([self.invdistMaxPointsSpin, self.invdistMinPointsSpin], SIGNAL("valueChanged(int)")),
4545
([self.averageRadius1Spin, self.averageRadius2Spin, self.averageAngleSpin, self.averageNoDataSpin], SIGNAL("valueChanged(double)")),
@@ -56,14 +56,14 @@ def __init__(self, iface):
5656
self.connect(self.selectInputFileButton, SIGNAL("clicked()"), self.fillInputFileEdit)
5757
self.connect(self.selectOutputFileButton, SIGNAL("clicked()"), self.fillOutputFileEdit)
5858
self.connect(self.inputLayerCombo, SIGNAL("currentIndexChanged(int)"), self.fillFieldsCombo)
59-
self.connect(self.extentGroup, SIGNAL("toggled(bool)"), self.onExtentCheckedChenged)
59+
self.connect(self.extentGroup, SIGNAL("toggled(bool)"), self.onExtentCheckedChanged)
6060

6161

6262
def onClosing(self):
6363
self.extentSelector.stop()
6464
BasePluginWidget.onClosing(self)
6565

66-
def onExtentCheckedChenged(self, enabled):
66+
def onExtentCheckedChanged(self, enabled):
6767
self.extentSelector.start() if enabled else self.extentSelector.stop()
6868

6969
def onLayersChanged(self):

0 commit comments

Comments
 (0)