def executeAlgorithm(self): item = self.algorithmTree.currentItem() if isinstance(item, TreeAlgorithmItem): alg = Processing.getAlgorithm(item.alg.commandLineName()) message = alg.checkBeforeOpeningParametersDialog() if message: dlg = MissingDependencyDialog(message) dlg.exec_() #QMessageBox.warning(self, self.tr("Warning"), message) return alg = alg.getCopy() dlg = alg.getCustomParametersDialog() if not dlg: dlg = ParametersDialog(alg) canvas = QGisLayers.iface.mapCanvas() prevMapTool = canvas.mapTool() dlg.show() dlg.exec_() if canvas.mapTool()!=prevMapTool: try: canvas.mapTool().reset() except: pass canvas.setMapTool(prevMapTool) if dlg.executed: showRecent = ProcessingConfig.getSetting(ProcessingConfig.SHOW_RECENT_ALGORITHMS) if showRecent: self.addRecentAlgorithms(True) if isinstance(item, TreeActionItem): action = item.action action.setData(self) action.execute()
def openCombine(self, num): folder = \ os.path.join(os.path.dirname(ModelerAlgorithmProvider.__file__), 'models') f = os.path.join(folder, 'combine_' + str(num) + 'vector.model') try: m = ModelerAlgorithm() m.openModel(f) self.alg = m self.alg.provider = Providers.providers['model'] dlg = ParametersDialog(self.alg) dlg.exec_() except Exception, e: QMessageBox.information(None,QCoreApplication.translate("PUR", "Combine planning unit layers"), \ QCoreApplication.translate("PUR","GRASS provider is not configured.\nPlease configure it before running this model.")) return
def runAlgorithm(self): alg = RAlgorithm(None, unicode(self.text.toPlainText())) alg.provider = Providers.providers['r'] dlg = alg.getCustomParametersDialog() if not dlg: dlg = ParametersDialog(alg) canvas = QGisLayers.iface.mapCanvas() prevMapTool = canvas.mapTool() dlg.show() dlg.exec_() if canvas.mapTool()!=prevMapTool: try: canvas.mapTool().reset() except: pass canvas.setMapTool(prevMapTool)
def runalg_parameters(self): dlg = self.alg.getCustomParametersDialog() if not dlg: dlg = ParametersDialog(self.alg) # hack to handle that hacky code... dlg.setParamValues = lambda: True dlg.show() dlg.accept() while (not dlg.executed): time.sleep(.5)
def runWorkflow(self): item = self.algorithmTree.currentItem() if isinstance(item, TreeAlgorithmItem): alg = Processing.getAlgorithm(item.alg.commandLineName()) message = alg.checkBeforeOpeningParametersDialog() if message: QtGui.QMessageBox.warning(self, self.tr("Warning"), message) return alg = alg.getCopy() dlg = alg.getCustomParametersDialog() if not dlg: dlg = ParametersDialog(alg) canvas = iface.mapCanvas() prevMapTool = canvas.mapTool() dlg.show() dlg.exec_() if canvas.mapTool()!=prevMapTool: try: canvas.mapTool().reset() except: pass canvas.setMapTool(prevMapTool)
def runAlgorithm(self): if self.algType == self.SCRIPT_PYTHON: alg = ScriptAlgorithm(None, unicode(self.editor.text())) alg.provider = Providers.providers["script"] if self.algType == self.SCRIPT_R: alg = RAlgorithm(None, unicode(self.editor.text())) alg.provider = Providers.providers["r"] dlg = alg.getCustomParametersDialog() if not dlg: dlg = ParametersDialog(alg) canvas = iface.mapCanvas() prevMapTool = canvas.mapTool() dlg.show() dlg.exec_() if canvas.mapTool() != prevMapTool: try: canvas.mapTool().reset() except: pass canvas.setMapTool(prevMapTool)
def runAlgorithm(self, alg): alg = alg.getCopy() message = alg.checkBeforeOpeningParametersDialog() if message: dlg = MissingDependencyDialog(message) dlg.exec_() return dlg = alg.getCustomParametersDialog() if not dlg: dlg = ParametersDialog(alg) canvas = iface.mapCanvas() prevMapTool = canvas.mapTool() dlg.show() dlg.exec_() if canvas.mapTool() != prevMapTool: try: canvas.mapTool().reset() except: pass canvas.setMapTool(prevMapTool)
def runAlgorithm(self): alg = RAlgorithm(None, unicode(self.text.text())) alg.provider = Providers.providers['r'] dlg = alg.getCustomParametersDialog() if not dlg: dlg = ParametersDialog(alg) canvas = QGisLayers.iface.mapCanvas() prevMapTool = canvas.mapTool() dlg.show() dlg.exec_() if canvas.mapTool() != prevMapTool: try: canvas.mapTool().reset() except: pass canvas.setMapTool(prevMapTool)
def runAlgorithm(self): if self.algType == self.SCRIPT_PYTHON: alg = ScriptAlgorithm(None, unicode(self.editor.text())) alg.provider = Providers.providers['script'] if self.algType == self.SCRIPT_R: alg = RAlgorithm(None, unicode(self.editor.text())) alg.provider = Providers.providers['r'] dlg = alg.getCustomParametersDialog() if not dlg: dlg = ParametersDialog(alg) canvas = interface.iface.mapCanvas() prevMapTool = canvas.mapTool() dlg.show() dlg.exec_() if canvas.mapTool() != prevMapTool: try: canvas.mapTool().reset() except: pass canvas.setMapTool(prevMapTool)
def __init__(self, alg, mainDialog, canEdit=True): self.alg = alg self.mainDialog = mainDialog self.goForward = False self.goBackward = False QtGui.QDialog.__init__(self) self.setWindowFlags(self.windowFlags() | QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowMinMaxButtonsHint) # create a tab for this algorithm self.tabLayout = QtGui.QGridLayout() self.algInstructions = QtGui.QTextEdit() self.algInstructions.setMinimumWidth(250) self.algInstructions.setMaximumWidth(250) self.algInstructions.setFontPointSize(10) if not canEdit: self.algInstructions.setReadOnly(True) self.normalModeDialog = alg.getCustomParametersDialog() if not self.normalModeDialog: self.normalModeDialog = ParametersDialog(alg) self.batchModeDialog = BatchProcessingDialog(alg) self.batchModeDialog.setHidden(True) self.normalModeDialog.buttonBox.button(QtGui.QDialogButtonBox.Close).hide() # forwardButton does this job self.batchModeDialog.buttonBox.button(QtGui.QDialogButtonBox.Close).hide() # forwardButton does this job if canEdit: self.normalModeDialog.progress.hide() self.normalModeDialog.buttonBox.hide() self.batchModeDialog.buttonBox.hide() self.batchModeDialog.progress.hide() self.normalModeDialog.connect(self.normalModeDialog, QtCore.SIGNAL("finished(int)"), self.forward) self.batchModeDialog.connect(self.batchModeDialog, QtCore.SIGNAL("finished(int)"), self.forward) self.tabLayout.addWidget(self.algInstructions,0,0) self.tabLayout.addWidget(self.normalModeDialog, 0, 1) self.tabLayout.addWidget(self.batchModeDialog, 0, 1) self.algMode = QtGui.QComboBox() self.algMode.addItems([NORMAL_MODE, BATCH_MODE]) if canEdit: self.algMode.connect(self.algMode, QtCore.SIGNAL("currentIndexChanged(QString)"), self.mainDialog.changeAlgMode) self.tabLayout.addWidget(self.algMode, 1, 1) else: self.buttonBox = QtGui.QDialogButtonBox() self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.backwardButton = QtGui.QPushButton() self.backwardButton.setText("< Previous step") self.buttonBox.addButton(self.backwardButton, QtGui.QDialogButtonBox.ActionRole) QtCore.QObject.connect(self.backwardButton, QtCore.SIGNAL("clicked()"), self.backward) self.forwardButton = QtGui.QPushButton() self.forwardButton.setText("Skip step >") self.buttonBox.addButton(self.forwardButton, QtGui.QDialogButtonBox.ActionRole) QtCore.QObject.connect(self.forwardButton, QtCore.SIGNAL("clicked()"), self.forward) self.closeButton = QtGui.QPushButton() self.closeButton.setText("Finish Workflow") self.buttonBox.addButton(self.closeButton, QtGui.QDialogButtonBox.ActionRole) QtCore.QObject.connect(self.closeButton, QtCore.SIGNAL("clicked()"), self.close) self.tabLayout.addWidget(self.buttonBox, 1, 1) self.setLayout(self.tabLayout) self.executed = self.normalModeDialog.executed
class StepDialog(QtGui.QDialog): def __init__(self, alg, mainDialog, canEdit=True): self.alg = alg self.mainDialog = mainDialog self.goForward = False self.goBackward = False QtGui.QDialog.__init__(self) self.setWindowFlags(self.windowFlags() | QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowMinMaxButtonsHint) # create a tab for this algorithm self.tabLayout = QtGui.QGridLayout() self.algInstructions = QtGui.QTextEdit() self.algInstructions.setMinimumWidth(250) self.algInstructions.setMaximumWidth(250) self.algInstructions.setFontPointSize(10) if not canEdit: self.algInstructions.setReadOnly(True) self.normalModeDialog = alg.getCustomParametersDialog() if not self.normalModeDialog: self.normalModeDialog = ParametersDialog(alg) self.batchModeDialog = BatchProcessingDialog(alg) self.batchModeDialog.setHidden(True) self.normalModeDialog.buttonBox.button(QtGui.QDialogButtonBox.Close).hide() # forwardButton does this job self.batchModeDialog.buttonBox.button(QtGui.QDialogButtonBox.Close).hide() # forwardButton does this job if canEdit: self.normalModeDialog.progress.hide() self.normalModeDialog.buttonBox.hide() self.batchModeDialog.buttonBox.hide() self.batchModeDialog.progress.hide() self.normalModeDialog.connect(self.normalModeDialog, QtCore.SIGNAL("finished(int)"), self.forward) self.batchModeDialog.connect(self.batchModeDialog, QtCore.SIGNAL("finished(int)"), self.forward) self.tabLayout.addWidget(self.algInstructions,0,0) self.tabLayout.addWidget(self.normalModeDialog, 0, 1) self.tabLayout.addWidget(self.batchModeDialog, 0, 1) self.algMode = QtGui.QComboBox() self.algMode.addItems([NORMAL_MODE, BATCH_MODE]) if canEdit: self.algMode.connect(self.algMode, QtCore.SIGNAL("currentIndexChanged(QString)"), self.mainDialog.changeAlgMode) self.tabLayout.addWidget(self.algMode, 1, 1) else: self.buttonBox = QtGui.QDialogButtonBox() self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.backwardButton = QtGui.QPushButton() self.backwardButton.setText("< Previous step") self.buttonBox.addButton(self.backwardButton, QtGui.QDialogButtonBox.ActionRole) QtCore.QObject.connect(self.backwardButton, QtCore.SIGNAL("clicked()"), self.backward) self.forwardButton = QtGui.QPushButton() self.forwardButton.setText("Skip step >") self.buttonBox.addButton(self.forwardButton, QtGui.QDialogButtonBox.ActionRole) QtCore.QObject.connect(self.forwardButton, QtCore.SIGNAL("clicked()"), self.forward) self.closeButton = QtGui.QPushButton() self.closeButton.setText("Finish Workflow") self.buttonBox.addButton(self.closeButton, QtGui.QDialogButtonBox.ActionRole) QtCore.QObject.connect(self.closeButton, QtCore.SIGNAL("clicked()"), self.close) self.tabLayout.addWidget(self.buttonBox, 1, 1) self.setLayout(self.tabLayout) self.executed = self.normalModeDialog.executed def forward(self): self.goForward = True self.close() def backward(self): self.goBackward = True self.close() def getMode(self): return self.algMode.currentText() def setMode(self, mode): if mode == NORMAL_MODE and not self.normalModeDialog.isVisible(): self.batchModeDialog.setHidden(True) self.normalModeDialog.setVisible(True) elif mode == BATCH_MODE and not self.batchModeDialog.isVisible(): self.normalModeDialog.setHidden(True) self.batchModeDialog.setVisible(True) self.resize(1050, 500) def getInstructions(self): return self.algInstructions.toPlainText() def setInstructions(self, instructions): self.algInstructions.setText(instructions) # not used for now def addRasterInputs(self, inputs): if self.getMode() == NORMAL_MODE: panelList = self.normalModeDialog.ui.paramTable.findChildren(InputLayerSelectorPanel) else: panelList = self.normalBatchDialog.ui.paramTable.findChildren(InputLayerSelectorPanel) for panel in panelList: comboBox = panel.text for myInput in inputs: comboBox.addItem(myInput, myInput)