def convert(_function): if _function.__class__ == ModuleFunction: return _function.__class__ = ModuleFunction for _parameter in _function.db_get_parameters(): ModuleParam.convert(_parameter) _function.returnType = "void"
def test_constructor(self): m1_param = ModuleParam(val="1.2", type="Float", alias="", ) m1_function = ModuleFunction(name="value", parameters=[m1_param], ) m1 = Module(id=0, name='Float', functions=[m1_function], ) m2 = Module() m2.name = "Float" m2.id = 0 f = ModuleFunction() f.name = "value" m2.functions.append(f) param = ModuleParam() param.strValue = "1.2" param.type = "Float" param.alias = "" f.params.append(param) assert m1 == m2
def convert(_function): if _function.__class__ == ModuleFunction: return _function.__class__ = ModuleFunction for _parameter in _function.db_get_parameters(): ModuleParam.convert(_parameter) _function.set_defaults()
def from_destination_port(): f = ModuleFunction() f.name = self.name for descriptor in self._descriptors: p = ModuleParam() p.identifier = descriptor.identifier p.namespace = descriptor.namespace p.type = descriptor.name p.name = '<no description>' f.addParameter(p) return f
def testIncorrectURL_2(self): import core.vistrail from core.db.locator import XMLFileLocator from core.vistrail.module import Module from core.vistrail.module_function import ModuleFunction from core.vistrail.module_param import ModuleParam import core.interpreter p = core.vistrail.pipeline.Pipeline() m_param = ModuleParam( type='String', val='http://neitherodesthisohrly', ) m_function = ModuleFunction( name='url', parameters=[m_param], ) p.add_module( Module( name='HTTPFile', package=identifier, version=version, id=0, functions=[m_function], )) interpreter = core.interpreter.default.get_default_interpreter() kwargs = { 'locator': XMLFileLocator('foo'), 'current_version': 1L, 'view': DummyView(), }
def create_action(self, id_scope=None): from core.vistrail.action import Action from core.vistrail.module import Module from core.vistrail.module_function import ModuleFunction from core.vistrail.module_param import ModuleParam from core.vistrail.operation import AddOp from db.domain import IdScope from datetime import datetime if id_scope is None: id_scope = IdScope() param = ModuleParam(id=id_scope.getNewId(ModuleParam.vtType), type='Integer', val='1') function = ModuleFunction(id=id_scope.getNewId(ModuleFunction.vtType), name='value', parameters=[param]) m = Module(id=id_scope.getNewId(Module.vtType), name='Float', package='edu.utah.sci.vistrails.basic', functions=[function]) add_op = AddOp(id=id_scope.getNewId('operation'), what='module', objectId=m.id, data=m) action = Action(id=id_scope.getNewId(Action.vtType), prevId=0, date=datetime(2007, 11, 18), operations=[add_op]) return action
def create_function(self, id_scope=IdScope()): param = ModuleParam(id=id_scope.getNewId(ModuleParam.vtType), pos=2, type='Int', val='1') function = ModuleFunction(id=id_scope.getNewId(ModuleFunction.vtType), pos=0, name='value', parameters=[param]) return function
def perform(self, pipeline, step): """ perform(pipeline: VisPipeline, step: int) -> None This will takes a pipeline and apply the interpolated values at step 'step' to the pipeline. Then return the updated pipeline """ m = pipeline.modules[self.module.id] f = ModuleFunction() f.name = self.function f.returnType = 'void' value = self.values[step] for v in value: p = ModuleParam() convert = {'int':'Integer', 'str':'String', 'float':'Float', 'double':'Float'} p.type = convert[type(v).__name__] p.strValue = str(v) f.params.append(p) m.functions.append(f)
def test_tuple(self): from core.vistrail.module_param import ModuleParam from core.vistrail.module_function import ModuleFunction from core.utils import DummyView from core.vistrail.module import Module import db.domain id_scope = db.domain.IdScope() interpreter = core.interpreter.default.get_default_interpreter() v = DummyView() p = core.vistrail.pipeline.Pipeline() params = [ ModuleParam( id=id_scope.getNewId(ModuleParam.vtType), pos=0, type='Float', val='2.0', ), ModuleParam( id=id_scope.getNewId(ModuleParam.vtType), pos=1, type='Float', val='2.0', ) ] function = ModuleFunction(id=id_scope.getNewId(ModuleFunction.vtType), name='input') function.add_parameters(params) module = Module(id=id_scope.getNewId(Module.vtType), name='TestTupleExecution', package='edu.utah.sci.vistrails.console_mode_test', version='0.9.0') module.add_function(function) p.add_module(module) kwargs = { 'locator': XMLFileLocator('foo'), 'current_version': 1L, 'view': v, }
def setTuvok(self, pipeline, module, dimensions, position): functionList = module._get_functions() frustumFunction = None for function in functionList: if function.name == "frustum": frustumFunction = function fullFrustum = (frustumFunction.params[0].value(), frustumFunction.params[1].value(), frustumFunction.params[2].value(), frustumFunction.params[3].value(), frustumFunction.params[4].value(), frustumFunction.params[5].value()) incX = screenX / (screenX + mullionX) incY = screenY / (screenY + mullionY) localFrustum = (fullFrustum[0] + ((fullFrustum[1] - fullFrustum[0]) / float(dimensions[2])) * position[0], fullFrustum[0] + ((fullFrustum[1] - fullFrustum[0]) / float(dimensions[2])) * (position[0]+incX), fullFrustum[2] + ((fullFrustum[3] - fullFrustum[2]) / float(dimensions[3])) * position[1], fullFrustum[2] + ((fullFrustum[3] - fullFrustum[2]) / float(dimensions[3])) * (position[1]+incY), fullFrustum[4], fullFrustum[5]) print position, localFrustum action_list = [] paramList = [] paramList.append((str(localFrustum[0]), frustumFunction.params[0].type, frustumFunction.params[0].namespace, frustumFunction.params[0].identifier, None)) paramList.append((str(localFrustum[1]), frustumFunction.params[1].type, frustumFunction.params[1].namespace, frustumFunction.params[1].identifier, None)) paramList.append((str(localFrustum[2]), frustumFunction.params[2].type, frustumFunction.params[2].namespace, frustumFunction.params[2].identifier, None)) paramList.append((str(localFrustum[3]), frustumFunction.params[3].type, frustumFunction.params[3].namespace, frustumFunction.params[3].identifier, None)) paramList.append((str(localFrustum[4]), frustumFunction.params[4].type, frustumFunction.params[4].namespace, frustumFunction.params[4].identifier, None)) paramList.append((str(localFrustum[5]), frustumFunction.params[5].type, frustumFunction.params[5].namespace, frustumFunction.params[5].identifier, None)) for i in range(len(paramList)): (p_val, p_type, p_namespace, p_identifier, p_alias) = paramList[i] function = frustumFunction old_param = function.params[i] param_id = pipeline.get_tmp_id(ModuleParam.vtType) new_param = ModuleParam(id=param_id, pos=i, name='<no description>', alias=p_alias, val=p_val, type=p_type, identifier=p_identifier, namespace=p_namespace,) action_list.append(('change', old_param, new_param, function.vtType, function.real_id)) action = create_action(action_list) pipeline.perform_action(action) serializedPipeline = serialize(pipeline) result = ((dimensions[0]+position[0], dimensions[1]+position[1]), serializedPipeline) return result pass
def test_constructor(self): m1_param = ModuleParam( val="1.2", type="Float", alias="", ) m1_function = ModuleFunction( name="value", parameters=[m1_param], ) m1 = Module( id=0, name='Float', functions=[m1_function], ) m2 = Module() m2.name = "Float" m2.id = 0 f = ModuleFunction() f.name = "value" m2.functions.append(f) param = ModuleParam() param.strValue = "1.2" param.type = "Float" param.alias = "" f.params.append(param) assert m1 == m2
def __init__(self, descriptor, var_strValue="", parent=None): """ QVariableInputForm(descriptor: ModuleDescriptor, var_strValue: str, parent: QWidget) -> QVariableInputForm Initialize with a vertical layout """ QtGui.QGroupBox.__init__(self, parent) self.setLayout(QtGui.QGridLayout()) self.layout().setMargin(5) self.layout().setSpacing(5) self.setFocusPolicy(QtCore.Qt.ClickFocus) self.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) self.palette().setColor(QtGui.QPalette.Window, CurrentTheme.METHOD_SELECT_COLOR) # Create widget for editing variable p = ModuleParam(type=descriptor.name, identifier=descriptor.identifier, namespace=descriptor.namespace) p.strValue = var_strValue widget_type = get_widget_class(descriptor.module) self.widget = widget_type(p, self) self.label = QDragVariableLabel(p.type) self.layout().addWidget(self.label, 0, 0) self.layout().addWidget(self.widget, 0, 1) self.updateMethod()
def create_ops(self, id_scope=IdScope()): from core.vistrail.module import Module from core.vistrail.module_function import ModuleFunction from core.vistrail.module_param import ModuleParam from core.vistrail.annotation import Annotation if id_scope is None: id_scope = IdScope( remap={ AddOp.vtType: 'operation', ChangeOp.vtType: 'operation', DeleteOp.vtType: 'operation' }) m = Module(id=id_scope.getNewId(Module.vtType), name='Float', package='edu.utah.sci.vistrails.basic') add_op = AddOp(id=id_scope.getNewId(AddOp.vtType), what=Module.vtType, objectId=m.id, data=m) function = ModuleFunction(id=id_scope.getNewId(ModuleFunction.vtType), name='value') change_op = ChangeOp(id=id_scope.getNewId(ChangeOp.vtType), what=ModuleFunction.vtType, oldObjId=2, newObjId=function.real_id, parentObjId=m.id, parentObjType=Module.vtType, data=function) param = ModuleParam(id=id_scope.getNewId(ModuleParam.vtType), type='Float', val='1.0') delete_op = DeleteOp(id=id_scope.getNewId(DeleteOp.vtType), what=ModuleParam.vtType, objectId=param.real_id, parentObjId=function.real_id, parentObjType=ModuleFunction.vtType) annotation = Annotation(id=id_scope.getNewId(Annotation.vtType), key='foo', value='bar') add_annotation = AddOp(id=id_scope.getNewId(AddOp.vtType), what=Annotation.vtType, objectId=m.id, data=annotation) return [add_op, change_op, delete_op, add_annotation]
def test_str(self): m = Module( id=0, name='Float', functions=[ ModuleFunction( name='value', parameters=[ModuleParam( type='Int', val='1', )], ) ], ) str(m)
def perform(self, pipeline, step): """ perform(pipeline: VisPipeline, step: int) -> None This will takes a pipeline and apply the interpolated values at step 'step' to the pipeline. Then return the updated pipeline """ m = pipeline.modules[self.module.id] f = ModuleFunction() f.name = self.function f.returnType = 'void' value = self.values[step] for v in value: p = ModuleParam() convert = { 'int': 'Integer', 'str': 'String', 'float': 'Float', 'double': 'Float' } p.type = convert[type(v).__name__] p.strValue = str(v) f.params.append(p) m.functions.append(f)
def create_module(self, id_scope=None): from db.domain import IdScope if id_scope is None: id_scope = IdScope() params = [ ModuleParam(id=id_scope.getNewId(ModuleParam.vtType), type='Int', val='1') ] functions = [ ModuleFunction(id=id_scope.getNewId(ModuleFunction.vtType), name='value', parameters=params) ] module = Module(id=id_scope.getNewId(Module.vtType), name='Float', package='edu.utah.sci.vistrails.basic', functions=functions) return module
def create_group(self, id_scope=IdScope()): from core.vistrail.location import Location from core.vistrail.module_function import ModuleFunction from core.vistrail.module_param import ModuleParam params = [ ModuleParam(id=id_scope.getNewId(ModuleParam.vtType), type='Int', val='1') ] functions = [ ModuleFunction(id=id_scope.getNewId(ModuleFunction.vtType), name='value', parameters=params) ] location = Location(id=id_scope.getNewId(Location.vtType), x=12.342, y=-19.432) module = \ Group(id=id_scope.getNewId(Group.vtType), location=location, functions=functions, ) return module
def setViSUSRange(self, pipeline, module, dimensions, position): functionList = module._get_functions() rangeFunction = None for function in functionList: if function.name == "Range": rangeFunction = function fullRange = (rangeFunction.params[0].value(), rangeFunction.params[1].value(), rangeFunction.params[2].value(), rangeFunction.params[3].value()) print 'in range', fullRange rw = fullRange[1]-fullRange[0] rh = fullRange[3]-fullRange[2] aspectRatio = float(rw) / rh # aspectRatio = (dimensions[2]-dimensions[0])*2560.0/((dimensions[3]-dimensions[1])*1600) nw = int(rh*aspectRatio) fullRange = (fullRange[0]-(nw-rw)/2, fullRange[1]+(nw-rw)/2, fullRange[2], fullRange[3]) print 'out range', fullRange incX = screenX / (screenX + mullionX) incY = screenY / (screenY + mullionY) localRange = (fullRange[0] + ((fullRange[1] - fullRange[0]) / (dimensions[2]-dimensions[0])) * position[0], int(fullRange[0] + ((fullRange[1] - fullRange[0]) / (dimensions[2]-dimensions[0])) * (position[0] + incX)), fullRange[2] + ((fullRange[3] - fullRange[2]) / (dimensions[3]-dimensions[1])) * position[1], int(fullRange[2] + ((fullRange[3] - fullRange[2]) / (dimensions[3]-dimensions[1])) * (position[1] + incY))) # localRange = (fullRange[0] + ((fullRange[1] - fullRange[0]) / dimensions[2]) * position[0], # int(fullRange[0] + ((fullRange[1] - fullRange[0]) / dimensions[2]) * (position[0] + incX)), # fullRange[0] + ((fullRange[3] - fullRange[2]) / dimensions[3]) * position[1], # int(fullRange[0] + ((fullRange[3] - fullRange[2]) / dimensions[3]) * (position[1] + incY))) print position, localRange action_list = [] paramList = [] paramList.append((str(localRange[0]), rangeFunction.params[0].type, rangeFunction.params[0].namespace, rangeFunction.params[0].identifier, None)) paramList.append((str(localRange[1]), rangeFunction.params[1].type, rangeFunction.params[1].namespace, rangeFunction.params[1].identifier, None)) paramList.append((str(localRange[2]), rangeFunction.params[2].type, rangeFunction.params[2].namespace, rangeFunction.params[2].identifier, None)) paramList.append((str(localRange[3]), rangeFunction.params[3].type, rangeFunction.params[3].namespace, rangeFunction.params[3].identifier, None)) for i in range(len(paramList)): (p_val, p_type, p_namespace, p_identifier, p_alias) = paramList[i] function = rangeFunction old_param = function.params[i] param_id = pipeline.get_tmp_id(ModuleParam.vtType) new_param = ModuleParam(id=param_id, pos=i, name='<no description>', alias=p_alias, val=p_val, type=p_type, identifier=p_identifier, namespace=p_namespace,) action_list.append(('change', old_param, new_param, function.vtType, function.real_id)) action = create_action(action_list) pipeline.perform_action(action) serializedPipeline = serialize(pipeline) result = ((dimensions[0]+position[0], dimensions[1]+position[1]), serializedPipeline) return result
def test_str(self): f = ModuleFunction(name='value', parameters=[ModuleParam(type='Float', val='1.2')], ) str(f)
def testComparisonOperators(self): f = ModuleFunction() f.name = "value" param = ModuleParam() param.strValue = "1.2" param.type = "Float" param.alias = "" f.addParameter(param) g = ModuleFunction() g.name = "value" param = ModuleParam() param.strValue = "1.2" param.type = "Float" param.alias = "" g.addParameter(param) assert f == g param = ModuleParam() param.strValue = "1.2" param.type = "Float" param.alias = "" g.addParameter(param) assert f != g
def collectParameterActions(self): """ collectParameterActions() -> list Return a list of action lists corresponding to each dimension """ if not self.pipeline: return None reg = get_module_registry() parameterValues = [[], [], [], []] counts = self.label.getCounts() for i in xrange(self.layout().count()): pEditor = self.layout().itemAt(i).widget() if pEditor and type(pEditor)==QParameterSetEditor: for paramWidget in pEditor.paramWidgets: editor = paramWidget.editor interpolator = editor.stackedEditors.currentWidget() paramInfo = paramWidget.param dim = paramWidget.getDimension() if dim in [0, 1, 2, 3]: count = counts[dim] values = interpolator.get_values(count) if not values: return None pId = paramInfo.id pType = paramInfo.dbtype parentType = paramInfo.parent_dbtype parentId = paramInfo.parent_id function = self.pipeline.db_get_object(parentType, parentId) fName = function.name old_param = self.pipeline.db_get_object(pType,pId) pName = old_param.name pAlias = old_param.alias pIdentifier = old_param.identifier actions = [] tmp_id = -1L for v in values: getter = reg.get_descriptor_by_name desc = getter(paramInfo.identifier, paramInfo.type, paramInfo.namespace) if type(v) != str: str_value = desc.module.translate_to_string(v) else: str_value = v new_param = ModuleParam(id=tmp_id, pos=old_param.pos, name=pName, alias=pAlias, val=str_value, type=paramInfo.type, identifier=pIdentifier ) action_spec = ('change', old_param, new_param, parentType, function.real_id) action = core.db.action.create_action([action_spec]) actions.append(action) parameterValues[dim].append(actions) tmp_id -= 1 return [zip(*p) for p in parameterValues]
def addCellLocation(self, vtkCell, pipeline, position, dimensions, deviceDimensions): """addCellLocation(vtkCell: Module, pipeline: Pipeline, position: (Int, Int)) -> None This method adds a CellLocation module to the vtkCell to ensure that it is sent to the right spreadsheet cell in the display wall. This is done according to the tuple in position""" print "Device Dimensions", deviceDimensions ### Adds the CellLocation Module # We need to make sure we create the Cell Location Module using # the current spreadsheet version version = self.getPackageVersion("edu.utah.sci.vistrails.spreadsheet") cellLocation = Module(id=pipeline.fresh_module_id(), name="CellLocation", package="edu.utah.sci.vistrails.spreadsheet", version=version) action = create_action([('add',cellLocation)]) pipeline.perform_action(action) cellLocation = pipeline.get_module_by_id(cellLocation.id) vtkCell = pipeline.get_module_by_id(vtkCell.id) src = registry.get_port_spec('edu.utah.sci.vistrails.spreadsheet','CellLocation', None, 'self','output') dst = registry.get_port_spec('edu.utah.sci.vistrails.vtk','VTKCell', None, 'Location','input') ### Connects the CellLocation module to the vtkCell inputPort = Port(id=pipeline.get_tmp_id(Port.vtType), spec=dst, moduleId=vtkCell.id, moduleName=vtkCell.name) outputPort = Port(id=pipeline.get_tmp_id(Port.vtType), spec=src, moduleId=cellLocation.id, moduleName=cellLocation.name) connection = Connection(id=pipeline.fresh_connection_id(), ports=[inputPort,outputPort]) action = create_action([('add',connection)]) pipeline.perform_action(action) action_list = [] ### Creates the Column function spec = registry.get_port_spec('edu.utah.sci.vistrails.spreadsheet','CellLocation',None, 'Column','input') columnFunction = spec.create_module_function() columnFunction.real_id = pipeline.get_tmp_id(ModuleFunction.vtType) columnFunction.db_parameters[0].db_id = pipeline.get_tmp_id(ModuleParam.vtType) columnFunction.db_parameters_id_index[columnFunction.db_parameters[0].db_id] = columnFunction.db_parameters[0] action_list.append(('add',columnFunction, cellLocation.vtType, cellLocation.id)) ### Creates the Row function spec = registry.get_port_spec('edu.utah.sci.vistrails.spreadsheet','CellLocation',None, 'Row','input') rowFunction = spec.create_module_function() rowFunction.real_id = pipeline.get_tmp_id(ModuleFunction.vtType) rowFunction.db_parameters[0].db_id = pipeline.get_tmp_id(ModuleParam.vtType) rowFunction.db_parameters_id_index[rowFunction.db_parameters[0].db_id] = rowFunction.db_parameters[0] action_list.append(('add',rowFunction, cellLocation.vtType, cellLocation.id)) action = create_action(action_list) pipeline.perform_action(action) cellLocation = pipeline.get_module_by_id(cellLocation.id) columnFunction = [x for x in cellLocation._get_functions() if x.name == "Column"][0] rowFunction = [x for x in cellLocation._get_functions() if x.name == "Row"][0] ### Sets the value of columnFunction and rowFunction paramList = [] # columnValue = (dimensions[0] + position[0]) % 2 + 1 # rowValue = (dimensions[1] + position[1]) % 2 + 1 gPos = (dimensions[0] + position[0], dimensions[1] + position[1]) columnValue = (gPos[0]-deviceDimensions[0]) % deviceDimensions[2] + 1 rowValue = (gPos[1]-deviceDimensions[1]) % deviceDimensions[3] + 1 print (columnValue, rowValue) ### changes the Column function paramList.append((str(columnValue), columnFunction.params[0].type, columnFunction.params[0].namespace, columnFunction.params[0].identifier, None)) ### changes the Row function paramList.append((str(rowValue), rowFunction.params[0].type, rowFunction.params[0].namespace, rowFunction.params[0].identifier, None)) action_list = [] for i in xrange(len(paramList)): (p_val, p_type, p_namespace, p_identifier, p_alias) = paramList[i] function = columnFunction if i == 0 else rowFunction old_param = function.params[0] param_id = pipeline.get_tmp_id(ModuleParam.vtType) new_param = ModuleParam(id=param_id, pos=i, name='<no description>', alias=p_alias, val=p_val, type=p_type, identifier=p_identifier, namespace=p_namespace, ) action_list.append(('change', old_param, new_param, function.vtType, function.real_id)) action = create_action(action_list) pipeline.perform_action(action)
def setCamera(self, vtkCell, camera, pipeline, position, dimensions, doZoom): """ setCamera(vtkCell: Module, camera: Module, pipeline: Pipeline, position: (Int, Int), dimensions: (Int, Int), doZoom: Bool) -> Pipeline This method modifies the received camera in the received pipeline to have it match the requirements for the display wall """ functionList = camera._get_functions() windowCenterFunction = None zoomFunction = None for function in functionList: if function.name == "SetWindowCenter": windowCenterFunction = function if function.name == "Zoom": zoomFunction = function action_list = [] if windowCenterFunction is None: spec = registry.get_port_spec('edu.utah.sci.vistrails.vtk','vtkCamera', None, 'SetWindowCenter','input') windowCenterFunction = spec.create_module_function() windowCenterFunction.real_id = pipeline.get_tmp_id(ModuleFunction.vtType) windowCenterFunction.db_parameters[0].db_id = pipeline.get_tmp_id(ModuleParam.vtType) windowCenterFunction.db_parameters[1].db_id = pipeline.get_tmp_id(ModuleParam.vtType) windowCenterFunction.db_parameters_id_index[windowCenterFunction.db_parameters[0].db_id] = windowCenterFunction.db_parameters[0] windowCenterFunction.db_parameters_id_index[windowCenterFunction.db_parameters[1].db_id] = windowCenterFunction.db_parameters[1] action_list.append(('add', windowCenterFunction, camera.vtType, camera.id)) if zoomFunction is None: spec = registry.get_port_spec('edu.utah.sci.vistrails.vtk','vtkCamera', None, 'Zoom','input') zoomFunction = spec.create_module_function() zoomFunction.real_id = pipeline.get_tmp_id(ModuleFunction.vtType) zoomFunction.db_parameters[0].db_id = pipeline.get_tmp_id(ModuleParam.vtType) zoomFunction.db_parameters_id_index[zoomFunction.db_parameters[0].db_id] = zoomFunction.db_parameters[0] action_list.append(('add', zoomFunction, camera.vtType, camera.id)) action = create_action(action_list) pipeline.perform_action(action) camera = pipeline.get_module_by_id(camera.id) functionList = camera._get_functions() windowCenterFunction = [x for x in camera._get_functions() if x.name == "SetWindowCenter"][0] if doZoom: zoomFunction = [x for x in camera._get_functions() if x.name == "Zoom"][0] columnCenter = - dimensions[2] + (position[0]*2+1); rowCenter = dimensions[3] - (position[1]*2+1); zoom = min(dimensions[2], dimensions[3]) # zoom = min(dimensions[2] - dimensions[0]+1, dimensions[3] - dimensions[1]+1) paramList = [] ### changes the setWindowCenter function paramList.append((str(columnCenter), windowCenterFunction.params[0].type, windowCenterFunction.params[0].namespace, windowCenterFunction.params[0].identifier, None)) paramList.append((str(rowCenter), windowCenterFunction.params[1].type, windowCenterFunction.params[1].namespace, windowCenterFunction.params[1].identifier, None)) if doZoom: ### changes the zoom function paramList.append((str(zoom), zoomFunction.params[0].type, zoomFunction.params[0].namespace, zoomFunction.params[0].identifier, None)) action_list = [] for i in xrange(len(paramList)): (p_val, p_type, p_namespace, p_identifier, p_alias) = paramList[i] function = windowCenterFunction if i == 0 or i == 1 else zoomFunction old_param = function.params[i] if i == 0 or i == 1 else function.params[0] param_id = pipeline.get_tmp_id(ModuleParam.vtType) new_param = ModuleParam(id=param_id, pos=i, name='<no description>', alias=p_alias, val=p_val, type=p_type, identifier=p_identifier, namespace=p_namespace,) action_list.append(('change', old_param, new_param, function.vtType, function.real_id)) action = create_action(action_list) pipeline.perform_action(action) serializedPipeline = serialize(pipeline) result = ((dimensions[0]+position[0], dimensions[1]+position[1]), serializedPipeline) return result
def setMistViewport(self, pipeline, module, dimensions, position): functionList = module._get_functions() viewportFunction = None for function in functionList: if function.name == "Viewport": viewportFunction = function fullRange = (viewportFunction.params[0].value(), viewportFunction.params[1].value(), viewportFunction.params[2].value(), viewportFunction.params[3].value()) print 'in range', fullRange print 'dimension:', dimensions rw = fullRange[2]-fullRange[0] rh = fullRange[3]-fullRange[1] centerFunction = None for function in functionList: if function.name == "GlobalCenter": centerFunction = function centerX = rw*0.5 + fullRange[0] centerY = rh*0.5 + fullRange[1] aspectRatio = float(rw) / rh nw = int(rh*aspectRatio) fullRange = (fullRange[0]-(nw-rw)/2, fullRange[1], fullRange[2]+(nw-rw)/2, fullRange[3]) print 'out range', fullRange print 'position:', position incX = screenX / (screenX + mullionX) incY = screenY / (screenY + mullionY) localRange = ( (rw)*position[0], (rh)*position[1], (rw)*(position[0]+1), (rh)*(position[1]+1)) print position, localRange action_list = [] paramList = [] paramList.append((viewportFunction, str(localRange[0]), viewportFunction.params[0].type, viewportFunction.params[0].namespace, viewportFunction.params[0].identifier, None, 0)) paramList.append((viewportFunction, str(localRange[1]), viewportFunction.params[1].type, viewportFunction.params[1].namespace, viewportFunction.params[1].identifier, None, 1)) paramList.append((viewportFunction, str(localRange[2]), viewportFunction.params[2].type, viewportFunction.params[2].namespace, viewportFunction.params[2].identifier, None, 2)) paramList.append((viewportFunction, str(localRange[3]), viewportFunction.params[3].type, viewportFunction.params[3].namespace, viewportFunction.params[3].identifier, None, 3)) paramList.append((centerFunction, str(centerX), centerFunction.params[0].type, centerFunction.params[0].namespace, centerFunction.params[0].identifier, None, 0)) paramList.append((centerFunction, str(centerY), centerFunction.params[1].type, centerFunction.params[1].namespace, centerFunction.params[1].identifier, None, 1)) print "Params: ", paramList for i in range(len(paramList)): (function, p_val, p_type, p_namespace, p_identifier, p_alias, pos) = paramList[i] # function = viewportFunction#rangeFunction print i, function, p_val, p_type, p_namespace, p_identifier, p_alias, pos old_param = function.params[pos] param_id = pipeline.get_tmp_id(ModuleParam.vtType) new_param = ModuleParam(id=param_id, pos=i, name='<no description>', alias=p_alias, val=p_val, type=p_type, identifier=p_identifier, namespace=p_namespace,) action_list.append(('change', old_param, new_param, function.vtType, function.real_id)) action = create_action(action_list) pipeline.perform_action(action) serializedPipeline = serialize(pipeline) result = ((dimensions[0]+position[0], dimensions[1]+position[1]), serializedPipeline) return result