Skip to content

Commit

Permalink
[processing] renamed Input and Output classes in modeler, to avoid co…
Browse files Browse the repository at this point in the history
…nfusion
  • Loading branch information
volaya committed Aug 14, 2014
1 parent e02f004 commit 8a2f150
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 21 deletions.
12 changes: 4 additions & 8 deletions python/plugins/processing/modeler/ModelerAlgorithm.py
Expand Up @@ -39,15 +39,11 @@
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
Expand All @@ -58,10 +54,10 @@ def todict(self):


@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
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/modeler/ModelerDialog.py
Expand Up @@ -36,7 +36,7 @@
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
Expand Down Expand Up @@ -365,7 +365,7 @@ def addInputOfType(self, paramType, pos=None):
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
Expand Down
17 changes: 9 additions & 8 deletions python/plugins/processing/modeler/ModelerGraphicItem.py
Expand Up @@ -28,7 +28,7 @@


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
Expand All @@ -43,12 +43,13 @@ def __init__(self, element, model):
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')
Expand All @@ -63,7 +64,7 @@ def __init__(self, element, model):
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
Expand Down Expand Up @@ -132,7 +133,7 @@ def mouseDoubleClickEvent(self, event):
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')
Expand Down Expand Up @@ -161,7 +162,7 @@ def activateAlgorithm(self):
'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_()
Expand All @@ -181,7 +182,7 @@ def editElement(self):
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'
Expand Down Expand Up @@ -217,7 +218,7 @@ def paint(self, painter, option, widget=None):
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
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/processing/modeler/ModelerParametersDialog.py
Expand Up @@ -29,7 +29,7 @@
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
Expand Down Expand Up @@ -165,7 +165,7 @@ def setupUi(self):
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:
Expand Down Expand Up @@ -467,7 +467,7 @@ def createAlgorithm(self):
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()
Expand Down

0 comments on commit 8a2f150

Please sign in to comment.