Skip to content

Commit 023fc00

Browse files
committedJun 12, 2014
Merge pull request #1389 from radosuav/small_processing_fixes
[processing] Small fixes
2 parents fa88eb2 + 2ef7dcf commit 023fc00

File tree

11 files changed

+110
-44
lines changed

11 files changed

+110
-44
lines changed
 
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
r.slope.aspect
2+
r.slope - Generates raster maps of slope from a elevation raster map.
3+
Raster (r.*)
4+
ParameterRaster|elevation|Name of elevation raster map|False
5+
ParameterSelection|format|Format for reporting the slope|degrees;percent
6+
ParameterSelection|prec|Type of output aspect and slope maps|float;double;int
7+
ParameterNumber|zfactor|Multiplicative factor to convert elevation units to meters|None|None|1.0
8+
ParameterNumber|min_slp_allowed|Minimum slope val. (in percent) for which aspect is computed|None|None|0.0
9+
ParameterBoolean|-a|Do not align the current region to the elevation layer|True
10+
OutputRaster|slope|Name for output slope raster map
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<root>
2+
<key>SplitImage</key>
3+
<exec>otbcli_SplitImage</exec>
4+
<longname>Split Image</longname>
5+
<group>Image Manipulation</group>
6+
<description>Rescale the image between two given values.</description>
7+
<parameter>
8+
<parameter_type source_parameter_type="ParameterType_InputImage">ParameterRaster</parameter_type>
9+
<key>in</key>
10+
<name>Input Image</name>
11+
<description>Input image to be split into individual images.</description>
12+
<optional>False</optional>
13+
</parameter>
14+
<parameter>
15+
<parameter_type source_parameter_type="ParameterType_OutputImage">OutputFile</parameter_type>
16+
<key>out</key>
17+
<name>Output Image</name>
18+
<description>The base filename of the split images.</description>
19+
</parameter>
20+
<parameter>
21+
<parameter_type source_parameter_type="ParameterType_RAM">ParameterNumber</parameter_type>
22+
<key>ram</key>
23+
<name>Available RAM (Mb)</name>
24+
<description>Available memory for processing (in MB)</description>
25+
<minValue />
26+
<maxValue />
27+
<default>128</default>
28+
</parameter>
29+
</root>

‎python/plugins/processing/algs/r/RAlgorithm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def processAlgorithm(self, progress):
239239
if self.showPlots:
240240
htmlfilename = self.getOutputValue(RAlgorithm.RPLOTS)
241241
f = open(htmlfilename, 'w')
242-
f.write('<img src="' + self.plotsFilename + '"/>')
242+
f.write('<html><img src="' + self.plotsFilename + '"/></html>')
243243
f.close()
244244
if self.showConsoleOutput:
245245
htmlfilename = self.getOutputValue(RAlgorithm.R_CONSOLE_OUTPUT)

‎python/plugins/processing/algs/r/RAlgorithmProvider.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,17 @@ def _loadAlgorithms(self):
8888
def loadFromFolder(self, folder):
8989
if not os.path.exists(folder):
9090
return
91-
for descriptionFile in os.listdir(folder):
92-
if descriptionFile.endswith('rsx'):
93-
try:
94-
fullpath = os.path.join(folder, descriptionFile)
95-
alg = RAlgorithm(fullpath)
96-
if alg.name.strip() != '':
97-
self.algs.append(alg)
98-
except WrongScriptException, e:
99-
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, e.msg)
100-
except Exception, e:
101-
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
102-
'Could not load R script:' + descriptionFile + '\n'
103-
+ unicode(e))
91+
for path, subdirs, files in os.walk(folder):
92+
for descriptionFile in files:
93+
if descriptionFile.endswith('rsx'):
94+
try:
95+
fullpath = os.path.join(path, descriptionFile)
96+
alg = RAlgorithm(fullpath)
97+
if alg.name.strip() != '':
98+
self.algs.append(alg)
99+
except WrongScriptException, e:
100+
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, e.msg)
101+
except Exception, e:
102+
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
103+
'Could not load R script:' + descriptionFile + '\n'
104+
+ unicode(e))

‎python/plugins/processing/core/Processing.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ class Processing:
6565
listeners = []
6666
providers = []
6767

68+
toolbox = None
69+
6870
# A dictionary of algorithms. Keys are names of providers
6971
# and values are list with all algorithms from that provider
7072
algs = {}
@@ -77,6 +79,10 @@ class Processing:
7779

7880
modeler = ModelerAlgorithmProvider()
7981

82+
@staticmethod
83+
def setToolbox(toolbox):
84+
Processing.toolbox = toolbox
85+
8086
@staticmethod
8187
def addProvider(provider, updateList=False):
8288
"""Use this method to add algorithms from external providers.
@@ -89,8 +95,8 @@ def addProvider(provider, updateList=False):
8995
provider.initializeSettings()
9096
Processing.providers.append(provider)
9197
ProcessingConfig.readSettings()
92-
if updateList:
93-
Processing.updateAlgsList()
98+
if updateList and Processing.toolbox:
99+
Processing.toolbox.updateTree()
94100
except:
95101
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
96102
'Could not load provider:'
@@ -109,7 +115,8 @@ def removeProvider(provider):
109115
provider.unload()
110116
Processing.providers.remove(provider)
111117
ProcessingConfig.readSettings()
112-
Processing.updateAlgsList()
118+
if Processing.toolbox:
119+
Processing.toolbox.updateTree()
113120
except:
114121
# This try catch block is here to avoid problems if the
115122
# plugin with a provider is unloaded after the Processing

‎python/plugins/processing/gui/AlgorithmExecutionDialog.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,11 @@ def accept(self):
248248
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
249249

250250
self.setInfo('<b>Algorithm %s starting...</b>' % self.alg.name)
251+
# make sure the log tab is visible before executing the algorithm
252+
try:
253+
self.repaint()
254+
except:
255+
pass
251256
if self.iterateParam:
252257
if UnthreadedAlgorithmExecutor.runalgIterating(self.alg,
253258
self.iterateParam, self):

‎python/plugins/processing/gui/BatchProcessingDialog.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,11 @@ def accept(self):
200200
for (i, alg) in enumerate(self.algs):
201201
self.setBaseText('Processing algorithm ' + str(i + 1) + '/'
202202
+ str(len(self.algs)) + '...')
203+
# make sure the log tab is visible before executing the algorithm
204+
try:
205+
self.repaint()
206+
except:
207+
pass
203208
if UnthreadedAlgorithmExecutor.runalg(alg, self) \
204209
and not self.canceled:
205210
if self.load[i]:

‎python/plugins/processing/gui/ProcessingToolbox.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ def __init__(self):
7272
if hasattr(self.searchBox, 'setPlaceholderText'):
7373
self.searchBox.setPlaceholderText(self.tr('Search...'))
7474

75+
Processing.setToolbox(self)
7576
self.fillTree()
7677

7778
def textChanged(self):

‎python/plugins/processing/modeler/ModelerAlgorithmProvider.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,17 @@ def _loadAlgorithms(self):
8181
def loadFromFolder(self, folder):
8282
if not os.path.exists(folder):
8383
return
84-
for descriptionFile in os.listdir(folder):
85-
if descriptionFile.endswith('model'):
86-
try:
87-
alg = ModelerAlgorithm()
88-
fullpath = os.path.join(folder, descriptionFile)
89-
alg.openModel(fullpath)
90-
if alg.name.strip() != '':
91-
alg.provider = self
92-
self.algs.append(alg)
93-
except WrongModelException, e:
94-
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
95-
'Could not load model ' + descriptionFile + '\n'
96-
+ e.msg)
84+
for path, subdirs, files in os.walk(folder):
85+
for descriptionFile in files:
86+
if descriptionFile.endswith('model'):
87+
try:
88+
alg = ModelerAlgorithm()
89+
fullpath = os.path.join(path, descriptionFile)
90+
alg.openModel(fullpath)
91+
if alg.name.strip() != '':
92+
alg.provider = self
93+
self.algs.append(alg)
94+
except WrongModelException, e:
95+
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
96+
'Could not load model ' + descriptionFile + '\n'
97+
+ e.msg)

‎python/plugins/processing/outputs/OutputRaster.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@ class OutputRaster(Output):
3535
compatible = None
3636

3737
def getFileFilter(self, alg):
38-
exts = dataobjects.getSupportedOutputRasterLayerExtensions()
38+
providerExts = alg.provider.getSupportedOutputRasterLayerExtensions()
39+
if providerExts == ['tif']:
40+
# use default extensions
41+
exts = dataobjects.getSupportedOutputRasterLayerExtensions()
42+
else:
43+
# use extensions given by the algorithm provider
44+
exts = providerExts
3945
for i in range(len(exts)):
4046
exts[i] = exts[i].upper() + ' files(*.' + exts[i].lower() + ')'
4147
return ';;'.join(exts)

‎python/plugins/processing/script/ScriptAlgorithmProvider.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,17 @@ def _loadAlgorithms(self):
8383
def loadFromFolder(self, folder):
8484
if not os.path.exists(folder):
8585
return
86-
for descriptionFile in os.listdir(folder):
87-
if descriptionFile.endswith('py'):
88-
try:
89-
fullpath = os.path.join(folder, descriptionFile)
90-
alg = ScriptAlgorithm(fullpath)
91-
if alg.name.strip() != '':
92-
self.algs.append(alg)
93-
except WrongScriptException, e:
94-
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, e.msg)
95-
except Exception, e:
96-
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
97-
'Could not load script:' + descriptionFile + '\n'
98-
+ unicode(e))
86+
for path, subdirs, files in os.walk(folder):
87+
for descriptionFile in files:
88+
if descriptionFile.endswith('py'):
89+
try:
90+
fullpath = os.path.join(path, descriptionFile)
91+
alg = ScriptAlgorithm(fullpath)
92+
if alg.name.strip() != '':
93+
self.algs.append(alg)
94+
except WrongScriptException, e:
95+
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, e.msg)
96+
except Exception, e:
97+
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
98+
'Could not load script:' + descriptionFile + '\n'
99+
+ unicode(e))

0 commit comments

Comments
 (0)
Please sign in to comment.