示例#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
示例#2
0
def add_connection(output_id, output_port, input_id, input_port, 
                   controller=None):
    from core.vistrail.connection import Connection
    # FIXME add_module and add_connection should be analogous
    # add_connection currently works completely differently
    if controller is None:
        controller = get_current_controller()
    connection = Connection.fromPorts(output_port,
                                      input_port)
    connection.sourceId = output_id
    connection.destinationId = input_id
    connection.id = controller.current_pipeline.fresh_connection_id()
    result = controller.add_connection(connection)
    controller.current_pipeline_view.setupScene(controller.current_pipeline)
    return result
示例#3
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
示例#4
0
    def create_new_connection(controller, src_module, src_port, 
                              dst_module, dst_port):
        # spec -> name, type, signature
        output_port_id = controller.id_scope.getNewId(Port.vtType)
        if type(src_port) == type(""):
            output_port_spec = src_module.get_port_spec(src_port, 'output')
            output_port = Port(id=output_port_id,
                               spec=output_port_spec,
                               moduleId=src_module.id,
                               moduleName=src_module.name)
        else:
            output_port = Port(id=output_port_id,
                               name=src_port.name,
                               type=src_port.type,
                               signature=src_port.signature,
                               moduleId=src_module.id,
                               moduleName=src_module.name)

        input_port_id = controller.id_scope.getNewId(Port.vtType)
        if type(dst_port) == type(""):
            input_port_spec = dst_module.get_port_spec(dst_port, 'input')
            input_port = Port(id=input_port_id,
                              spec=input_port_spec,
                              moduleId=dst_module.id,
                              moduleName=dst_module.name)
        else:
            input_port = Port(id=input_port_id,
                              name=dst_port.name,
                              type=dst_port.type,
                              signature=dst_port.signature,
                              moduleId=dst_module.id,
                              moduleName=dst_module.name)
        conn_id = controller.id_scope.getNewId(Connection.vtType)
        connection = Connection(id=conn_id,
                                ports=[input_port, output_port])
        return connection
示例#5
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)