[processing] renamed Input and Output classes in modeler, to avoid confusion

This commit is contained in:
volaya 2014-08-14 10:56:08 +02:00
parent e02f0040d6
commit 8a2f1505d5
4 changed files with 18 additions and 21 deletions

View File

@ -39,15 +39,11 @@ from processing.core.GeoAlgorithmExecutionException import \
GeoAlgorithmExecutionException GeoAlgorithmExecutionException
from processing.gui.Help2Html import getHtmlFromHelpFile from processing.gui.Help2Html import getHtmlFromHelpFile
from processing.modeler.ModelerUtils import ModelerUtils from processing.modeler.ModelerUtils import ModelerUtils
from processing.core.parameters import ParameterRaster from processing.core.parameters import *
from processing.core.parameters import ParameterDataObject
from processing.core.parameters import ParameterExtent
from processing.core.parameters import ParameterMultipleInput
from processing.core.parameters import ParameterVector
from processing.tools import dataobjects from processing.tools import dataobjects
class Input(): class ModelerParameter():
def __init__(self, param=None, pos=None): def __init__(self, param=None, pos=None):
self.param = param self.param = param
@ -58,10 +54,10 @@ class Input():
@staticmethod @staticmethod
def fromdict(d): def fromdict(d):
return Input(d["param"], d["pos"]) return ModelerParameter(d["param"], d["pos"])
class Output(): class ModelerOutput():
def __init__(self, description=""): def __init__(self, description=""):
self.description = description self.description = description

View File

@ -36,7 +36,7 @@ from processing.gui.HelpEditionDialog import HelpEditionDialog
from processing.gui.ParametersDialog import ParametersDialog from processing.gui.ParametersDialog import ParametersDialog
from processing.gui.AlgorithmClassification import AlgorithmDecorator from processing.gui.AlgorithmClassification import AlgorithmDecorator
from processing.modeler.ModelerParameterDefinitionDialog import ModelerParameterDefinitionDialog from processing.modeler.ModelerParameterDefinitionDialog import ModelerParameterDefinitionDialog
from processing.modeler.ModelerAlgorithm import ModelerAlgorithm, Input from processing.modeler.ModelerAlgorithm import ModelerAlgorithm, ModelerParameter
from processing.modeler.ModelerParametersDialog import ModelerParametersDialog from processing.modeler.ModelerParametersDialog import ModelerParametersDialog
from processing.modeler.ModelerUtils import ModelerUtils from processing.modeler.ModelerUtils import ModelerUtils
from processing.modeler.ModelerScene import ModelerScene from processing.modeler.ModelerScene import ModelerScene
@ -365,7 +365,7 @@ class ModelerDialog(QDialog, Ui_DlgModeler):
pos = self.getPositionForParameterItem() pos = self.getPositionForParameterItem()
if isinstance(pos, QPoint): if isinstance(pos, QPoint):
pos = QPointF(pos) pos = QPointF(pos)
self.alg.addParameter(Input(dlg.param, pos)) self.alg.addParameter(ModelerParameter(dlg.param, pos))
self.repaintModel() self.repaintModel()
#self.view.ensureVisible(self.scene.getLastParameterItem()) #self.view.ensureVisible(self.scene.getLastParameterItem())
self.hasChanged = True self.hasChanged = True

View File

@ -28,7 +28,7 @@ __revision__ = '$Format:%H$'
import os import os
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from processing.modeler.ModelerAlgorithm import Input, Algorithm, Output from processing.modeler.ModelerAlgorithm import ModelerParameter, Algorithm, ModelerOutput
from processing.modeler.ModelerParameterDefinitionDialog import \ from processing.modeler.ModelerParameterDefinitionDialog import \
ModelerParameterDefinitionDialog ModelerParameterDefinitionDialog
from processing.modeler.ModelerParametersDialog import ModelerParametersDialog from processing.modeler.ModelerParametersDialog import ModelerParametersDialog
@ -43,12 +43,13 @@ class ModelerGraphicItem(QtGui.QGraphicsItem):
super(ModelerGraphicItem, self).__init__(None, None) super(ModelerGraphicItem, self).__init__(None, None)
self.model = model self.model = model
self.element = element self.element = element
if isinstance(element, Input): print element.__class__
if isinstance(element, ModelerParameter):
icon = QtGui.QIcon(os.path.dirname(__file__) icon = QtGui.QIcon(os.path.dirname(__file__)
+ '/../images/input.png') + '/../images/input.png')
self.pixmap = icon.pixmap(20, 20, state=QtGui.QIcon.On) self.pixmap = icon.pixmap(20, 20, state=QtGui.QIcon.On)
self.text = element.param.description self.text = element.param.description
elif isinstance(element, Output): elif isinstance(element, ModelerOutput):
# Output name # Output name
icon = QtGui.QIcon(os.path.dirname(__file__) icon = QtGui.QIcon(os.path.dirname(__file__)
+ '/../images/output.png') + '/../images/output.png')
@ -63,7 +64,7 @@ class ModelerGraphicItem(QtGui.QGraphicsItem):
self.setFlag(QtGui.QGraphicsItem.ItemSendsGeometryChanges, True) self.setFlag(QtGui.QGraphicsItem.ItemSendsGeometryChanges, True)
self.setZValue(1000) self.setZValue(1000)
if not isinstance(element, Output): if not isinstance(element, ModelerOutput):
icon = QtGui.QIcon(os.path.dirname(__file__) icon = QtGui.QIcon(os.path.dirname(__file__)
+ '/../images/edit.png') + '/../images/edit.png')
pt = QtCore.QPointF(ModelerGraphicItem.BOX_WIDTH / 2 pt = QtCore.QPointF(ModelerGraphicItem.BOX_WIDTH / 2
@ -132,7 +133,7 @@ class ModelerGraphicItem(QtGui.QGraphicsItem):
self.editElement() self.editElement()
def contextMenuEvent(self, event): def contextMenuEvent(self, event):
if isinstance(self.element, Output): if isinstance(self.element, ModelerOutput):
return return
popupmenu = QtGui.QMenu() popupmenu = QtGui.QMenu()
removeAction = popupmenu.addAction('Remove') removeAction = popupmenu.addAction('Remove')
@ -161,7 +162,7 @@ class ModelerGraphicItem(QtGui.QGraphicsItem):
'Activate them them before trying to activate it.') 'Activate them them before trying to activate it.')
def editElement(self): def editElement(self):
if isinstance(self.element, Input): if isinstance(self.element, ModelerParameter):
dlg = ModelerParameterDefinitionDialog(self.model, dlg = ModelerParameterDefinitionDialog(self.model,
param=self.element.param) param=self.element.param)
dlg.exec_() dlg.exec_()
@ -181,7 +182,7 @@ class ModelerGraphicItem(QtGui.QGraphicsItem):
self.model.updateModelerView() self.model.updateModelerView()
def removeElement(self): def removeElement(self):
if isinstance(self.element, Input): if isinstance(self.element, ModelerParameter):
if not self.model.removeParameter(self.element.param.name): if not self.model.removeParameter(self.element.param.name):
QtGui.QMessageBox.warning(None, 'Could not remove element', QtGui.QMessageBox.warning(None, 'Could not remove element',
'Other elements depend on the selected one.\n' 'Other elements depend on the selected one.\n'
@ -217,7 +218,7 @@ class ModelerGraphicItem(QtGui.QGraphicsItem):
ModelerGraphicItem.BOX_HEIGHT + 2) ModelerGraphicItem.BOX_HEIGHT + 2)
painter.setPen(QtGui.QPen(QtCore.Qt.gray, 1)) painter.setPen(QtGui.QPen(QtCore.Qt.gray, 1))
color = QtGui.QColor(125, 232, 232) color = QtGui.QColor(125, 232, 232)
if isinstance(self.element, Input): if isinstance(self.element, ModelerParameter):
color = QtGui.QColor(179, 179, 255) color = QtGui.QColor(179, 179, 255)
elif isinstance(self.element, Algorithm): elif isinstance(self.element, Algorithm):
color = QtCore.Qt.white color = QtCore.Qt.white

View File

@ -29,7 +29,7 @@ from PyQt4.QtCore import *
from PyQt4.QtGui import * from PyQt4.QtGui import *
from PyQt4 import QtCore, QtGui, QtWebKit from PyQt4 import QtCore, QtGui, QtWebKit
from processing.modeler.ModelerAlgorithm import ValueFromInput,\ from processing.modeler.ModelerAlgorithm import ValueFromInput,\
ValueFromOutput, Algorithm, Output ValueFromOutput, Algorithm, ModelerOutput
from processing.gui.CrsSelectionPanel import CrsSelectionPanel from processing.gui.CrsSelectionPanel import CrsSelectionPanel
from processing.gui.MultipleInputPanel import MultipleInputPanel from processing.gui.MultipleInputPanel import MultipleInputPanel
from processing.gui.FixedTablePanel import FixedTablePanel from processing.gui.FixedTablePanel import FixedTablePanel
@ -165,7 +165,7 @@ class ModelerParametersDialog(QtGui.QDialog):
self.webView = QtWebKit.QWebView() self.webView = QtWebKit.QWebView()
html = None html = None
url = None url = None
isText, help = self._alg.help() isText, help = self._alg.help()
if help is not None: if help is not None:
if isText: if isText:
@ -467,7 +467,7 @@ class ModelerParametersDialog(QtGui.QDialog):
if not output.hidden: if not output.hidden:
name = unicode(self.valueItems[output.name].text()) name = unicode(self.valueItems[output.name].text())
if name.strip() != '' and name != ModelerParametersDialog.ENTER_NAME: if name.strip() != '' and name != ModelerParametersDialog.ENTER_NAME:
alg.outputs[output.name] = Output(name) alg.outputs[output.name] = ModelerOutput(name)
selectedOptions = self.dependenciesPanel.selectedoptions selectedOptions = self.dependenciesPanel.selectedoptions
availableDependencies = self.getAvailableDependencies() availableDependencies = self.getAvailableDependencies()