Exemplo n.º 1
0
    def getClearPipelines(self, dimensions, clientDimensions):
        result = []
        for row in range(dimensions[3]):
            for column in range(dimensions[2]):
                localPipeline = Pipeline()
                vtkversion = self.getPackageVersion("edu.utah.sci.vistrails.vtk")
                vtkCell = Module(id=localPipeline.fresh_module_id(), name="VTKCell", 
                                 package="edu.utah.sci.vistrails.vtk",
                                 version=vtkversion)
                action = create_action([('add',vtkCell)])
                localPipeline.perform_action(action) 

                vtkRenderer = Module(id=localPipeline.fresh_module_id(), 
                                     name="vtkRenderer", 
                                     package="edu.utah.sci.vistrails.vtk",
                                     version=vtkversion)
                action = create_action([('add',vtkRenderer)])
                localPipeline.perform_action(action)

                src = registry.get_port_spec('edu.utah.sci.vistrails.vtk','vtkRenderer', None, 'self','output')
                dst = registry.get_port_spec('edu.utah.sci.vistrails.vtk','VTKCell', None, 'AddRenderer','input')
                inputPort = Port(id=localPipeline.get_tmp_id(Port.vtType), spec=dst, moduleId=vtkCell.id, moduleName=vtkCell.name)
                outputPort = Port(id=localPipeline.get_tmp_id(Port.vtType), spec=src, moduleId=vtkRenderer.id, moduleName=vtkRenderer.name)
                connection = Connection(id=localPipeline.fresh_connection_id(), ports=[inputPort,outputPort])
                action = create_action([('add',connection)])
                localPipeline.perform_action(action)        

                cellLocation = self.getCellLocationModule(vtkCell, localPipeline)
                if not cellLocation is None:
                    self.deleteModule(cellLocation, localPipeline)
                dim = clientDimensions[(column+dimensions[0], row+dimensions[1])]
                self.addCellLocation(vtkCell, localPipeline, (column, row), dimensions, dim)

                result.append(((dimensions[0]+column,dimensions[1]+row), serialize(localPipeline)))
        return result
Exemplo n.º 2
0
 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(),
     }
Exemplo n.º 3
0
    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
Exemplo n.º 4
0
    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,
        }
Exemplo n.º 5
0
    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_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,
               }
Exemplo n.º 7
0
 def addVTKCameraToRenderer(self, vtkRenderer, pipeline):
     """addVTKCameraToRenderer(renderer: Module, pipeline: Pipeline) -> Module
     Adds a vtkCamera module to the received vtkRenderer. If a camera already exists, it
     returns this camera"""
     vtkCamera = self.findUpstreamModuleByClass(vtkRenderer, self.getModuleClassByName('edu.utah.sci.vistrails.vtk','vtkCamera'), pipeline)
     if not vtkCamera is None:
         ### If a camera is already connected to the renderer, just return it
         return vtkCamera
     # Making sure we create the vtkCamera module using the current version of
     # the vtk package
     version = self.getPackageVersion("edu.utah.sci.vistrails.vtk")
     vtkCamera = Module(id=pipeline.fresh_module_id(), name="vtkCamera", 
                        package="edu.utah.sci.vistrails.vtk", version=version)
     action = create_action([('add',vtkCamera)])
     pipeline.perform_action(action)
             
     src = registry.get_port_spec('edu.utah.sci.vistrails.vtk','vtkCamera', None, 'self','output')
     dst = registry.get_port_spec('edu.utah.sci.vistrails.vtk','vtkRenderer', None, 'SetActiveCamera','input')
     inputPort = Port(id=pipeline.get_tmp_id(Port.vtType), spec=dst, moduleId=vtkRenderer.id, moduleName=vtkRenderer.name)
     outputPort = Port(id=pipeline.get_tmp_id(Port.vtType), spec=src, moduleId=vtkCamera.id, moduleName=vtkCamera.name)
     connection = Connection(id=pipeline.fresh_connection_id(), ports=[inputPort,outputPort])
     action = create_action([('add',connection)])
     pipeline.perform_action(action)
     return vtkCamera
Exemplo n.º 8
0
    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)
Exemplo n.º 9
0
    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 set_defaults(self, other=None):
     Module.set_defaults(self, other)
     self._is_latest_version = True
     self.check_latest_version()
Exemplo n.º 11
0
 def set_defaults(self, other=None):
     Module.set_defaults(self, other)
     self._is_latest_version = True
     self.check_latest_version()
Exemplo n.º 12
0
 def set_defaults(self, other=None):
     Module.set_defaults(self, other)
Exemplo n.º 13
0
 def _get_output_port_specs(self):
     if self._port_specs is None:
         self.make_port_specs()
     return Module._get_output_port_specs(self)