|
17 | 17 | ***************************************************************************
|
18 | 18 | """
|
19 | 19 |
|
| 20 | + |
20 | 21 | __author__ = 'Victor Olaya'
|
21 | 22 | __date__ = 'August 2012'
|
22 | 23 | __copyright__ = '(C) 2012, Victor Olaya'
|
|
32 | 33 | from PyQt.QtWidgets import QMenu, QAction, QTreeWidgetItem, QLabel, QMessageBox
|
33 | 34 | from qgis.utils import iface
|
34 | 35 |
|
| 36 | +from processing.gui.Postprocessing import handleAlgorithmResults |
35 | 37 | from processing.core.Processing import Processing
|
36 | 38 | from processing.core.ProcessingLog import ProcessingLog
|
37 | 39 | from processing.core.ProcessingConfig import ProcessingConfig
|
|
41 | 43 | from processing.gui.BatchAlgorithmDialog import BatchAlgorithmDialog
|
42 | 44 | from processing.gui.EditRenderingStylesDialog import EditRenderingStylesDialog
|
43 | 45 | from processing.gui.ConfigDialog import ConfigDialog
|
44 |
| - |
| 46 | +from processing.gui.MessageBarProgress import MessageBarProgress |
| 47 | +from processing.gui.AlgorithmExecutor import runalg |
45 | 48 |
|
46 | 49 | pluginPath = os.path.split(os.path.dirname(__file__))[0]
|
47 | 50 | WIDGET, BASE = uic.loadUiType(
|
@@ -194,11 +197,14 @@ def showPopupMenu(self, point):
|
194 | 197 | editRenderingStylesAction.triggered.connect(
|
195 | 198 | self.editRenderingStyles)
|
196 | 199 | popupmenu.addAction(editRenderingStylesAction)
|
| 200 | + |
| 201 | + if isinstance(item, (TreeAlgorithmItem, TreeActionItem)): |
| 202 | + data = item.alg if isinstance(item, TreeAlgorithmItem) else item.action |
197 | 203 | actions = Processing.contextMenuActions
|
198 | 204 | if len(actions) > 0:
|
199 | 205 | popupmenu.addSeparator()
|
200 | 206 | for action in actions:
|
201 |
| - action.setData(alg, self) |
| 207 | + action.setData(data, self) |
202 | 208 | if action.isEnabled():
|
203 | 209 | contextMenuAction = QAction(action.name,
|
204 | 210 | self.algorithmTree)
|
@@ -237,24 +243,30 @@ def executeAlgorithm(self):
|
237 | 243 | dlg.exec_()
|
238 | 244 | return
|
239 | 245 | alg = alg.getCopy()
|
240 |
| - dlg = alg.getCustomParametersDialog() |
241 |
| - if not dlg: |
242 |
| - dlg = AlgorithmDialog(alg) |
243 |
| - canvas = iface.mapCanvas() |
244 |
| - prevMapTool = canvas.mapTool() |
245 |
| - dlg.show() |
246 |
| - dlg.exec_() |
247 |
| - if canvas.mapTool() != prevMapTool: |
248 |
| - try: |
249 |
| - canvas.mapTool().reset() |
250 |
| - except: |
251 |
| - pass |
252 |
| - canvas.setMapTool(prevMapTool) |
253 |
| - if dlg.executed: |
254 |
| - showRecent = ProcessingConfig.getSetting( |
255 |
| - ProcessingConfig.SHOW_RECENT_ALGORITHMS) |
256 |
| - if showRecent: |
257 |
| - self.addRecentAlgorithms(True) |
| 246 | + if (alg.getVisibleParametersCount() + alg.getVisibleOutputsCount()) > 0: |
| 247 | + dlg = alg.getCustomParametersDialog() |
| 248 | + if not dlg: |
| 249 | + dlg = AlgorithmDialog(alg) |
| 250 | + canvas = iface.mapCanvas() |
| 251 | + prevMapTool = canvas.mapTool() |
| 252 | + dlg.show() |
| 253 | + dlg.exec_() |
| 254 | + if canvas.mapTool() != prevMapTool: |
| 255 | + try: |
| 256 | + canvas.mapTool().reset() |
| 257 | + except: |
| 258 | + pass |
| 259 | + canvas.setMapTool(prevMapTool) |
| 260 | + if dlg.executed: |
| 261 | + showRecent = ProcessingConfig.getSetting( |
| 262 | + ProcessingConfig.SHOW_RECENT_ALGORITHMS) |
| 263 | + if showRecent: |
| 264 | + self.addRecentAlgorithms(True) |
| 265 | + else: |
| 266 | + progress = MessageBarProgress() |
| 267 | + runalg(alg, progress) |
| 268 | + handleAlgorithmResults(alg, progress) |
| 269 | + progress.close() |
258 | 270 | if isinstance(item, TreeActionItem):
|
259 | 271 | action = item.action
|
260 | 272 | action.setData(self)
|
|
0 commit comments