def copy_pipeline_to_other_location(pipeline, controller, sheetName, row, col,plot_type, cell):
        pip_str = core.db.io.serialize(pipeline)
        controller.change_selected_version(cell.current_parent_version)

        modules = controller.paste_modules_and_connections(pip_str, (0.0,0.0))
        cell.current_parent_version = controller.current_version
        pipeline = controller.current_pipeline

        reg = get_module_registry()
        cell_locations = CDMSPipelineHelper.find_modules_by_type(pipeline, [CellLocation])
        cell_modules = CDMSPipelineHelper.find_modules_by_type(pipeline, [SpreadsheetCell])

        #// We assume that there is only one CellLocation and one SpreadsheetCell
        #// delete location and create another one with the right locations
        action = controller.delete_module_list([cell_locations[0].id])
        cell.current_parent_version = action.id

        loc_module = controller.create_module_from_descriptor(
            reg.get_descriptor_by_name('edu.utah.sci.vistrails.spreadsheet',
                                       'CellLocation'))
        functions = controller.create_functions(loc_module,
            [('Row', [str(row+1)]), ('Column', [str(col+1)])])
        for f in functions:
            loc_module.add_function(f)
        loc_conn = controller.create_connection(loc_module, 'self',
                                                cell_modules[0], 'Location')
        ops = [('add', loc_module),
               ('add', loc_conn)]

        action = core.db.action.create_action(ops)
        controller.change_selected_version(cell.current_parent_version)
        controller.add_new_action(action)
        controller.perform_action(action)
        cell.current_parent_version = action.id

        #// Update project controller cell information
        pipeline = controller.vistrail.getPipeline(action.id)
        plot_modules = CDMSPipelineHelper.find_modules_by_type(pipeline, [CDMSPlot])
        for plot in cell.plots:
            plot.variables =[]
        #for plot in plot_modules:
        #    vars = CDMSPipelineHelper.find_variables_connected_to_plot_module(controller,
        #                                                               pipeline,
        #                                                               plot.id)
        #    for var in vars:
        #        cell.variables.append(CDMSPipelineHelper.get_variable_name_from_module(var))

        #FIXME: This does not consider if the workflow has more than one plot
        #gmName = CDMSPipelineHelper.get_graphics_method_name_from_module(plot_modules[0])
        #ptype = CDMSPipelineHelper.get_plot_type_from_module(plot_modules[0])
        #cell.plot = get_plot_manager().get_plot(plot_type, ptype, gmName)
        return action
    def load_pipeline_in_location(pipeline, controller, sheetName, row, col,plot_type, cell):
       cell_locations = CDMSPipelineHelper.find_modules_by_type(pipeline, [CellLocation])
       cell_modules = CDMSPipelineHelper.find_modules_by_type(pipeline, [SpreadsheetCell])
#       plot_modules = CDMSPipelineHelper.find_modules_by_type(pipeline, [CDMSPlot])

       #// we assume that there is only one CellLocation and one SpreadsheetCell
       #// update location values in place.
       loc_module = cell_locations[0]
       for i in xrange(loc_module.getNumFunctions()):
           if loc_module.functions[i].name == 'Row':
               loc_module.functions[i].params[0].strValue = str(row+1)
           elif loc_module.functions[i].name == "Column":
               loc_module.functions[i].params[0].strValue = str(col+1)
 def show_configuration_widget(controller, version, plot_obj=None):
     pipeline = controller.vt_controller.vistrail.getPipeline(version)
     #print pipeline
     #plots = VisItPipelineHelper.find_plot_modules(pipeline)
     cell = CDMSPipelineHelper.find_modules_by_type(pipeline,[visitcell.VisItCell])
     vars = CDMSPipelineHelper.find_modules_by_type(pipeline,
                                                    [CDMSVariable,
                                                     CDMSVariableOperation])
     if len(cell) == 0:
         return visitcell.VisItCellConfigurationWidget(None,controller)
     else:
         vcell = cell[0].module_descriptor.module()
         #print "cellWidget should not be None", vcell, vcell.cellWidget
         return visitcell.VisItCellConfigurationWidget(cell[0],controller)
Beispiel #4
0
 def show_configuration_widget(controller, version, plot_obj=None):
     pipeline = controller.vt_controller.vistrail.getPipeline(version)
     #print pipeline
     #plots = VisItPipelineHelper.find_plot_modules(pipeline)
     cell = CDMSPipelineHelper.find_modules_by_type(pipeline,
                                                    [visitcell.VisItCell])
     vars = CDMSPipelineHelper.find_modules_by_type(
         pipeline, [CDMSVariable, CDMSVariableOperation])
     if len(cell) == 0:
         return visitcell.VisItCellConfigurationWidget(None, controller)
     else:
         vcell = cell[0].module_descriptor.module()
         #print "cellWidget should not be None", vcell, vcell.cellWidget
         return visitcell.VisItCellConfigurationWidget(cell[0], controller)
    def show_configuration_widget(controller, version, plot_obj=None):
        #// Grab the pipeline
        pipeline = controller.vt_controller.vistrail.getPipeline(version)

        #// Find the cell
        cell = CDMSPipelineHelper.find_modules_by_type(pipeline,[PVGenericCell])

        PVClimatePipelineHelper.find_plot_representation(pipeline, PVClimatePipelineHelper.find_plot_modules(pipeline)[0])

        #// @todo: Remove this hack
        if len(cell) == 0:
          print >> sys.stderr, 'cell is empty'
          return None

        if len(cell) == 0:
            widget = PVGenericCellConfigurationWidget(None, controller.vt_controller)
            widget.init(pipeline, version)
            return widget
        else:
            pvcell = cell[0].module_descriptor.module()
            #// Create child widgets
            #// Attach it to the parent widget
            widget = PVGenericCellConfigurationWidget(cell[0], controller.vt_controller)
            widget.init(pipeline, version)
            return widget
Beispiel #6
0
    def add_project(self, view):
        """ add_project(view: QVistrailView) -> None
        vistrails calls this when a project is opened/created/saved
        Items and spreadsheets are updated
        """
        try:
            if id(view) not in self.viewToItem:
                if self.currentProject:
                    self.setBold(self.currentProject, False)
                p_name = "Project %i" % self.numProjects
                item = QProjectItem(view, p_name)
                self.currentProject = item
                self.current_controller = item.controller
                self.viewToItem[id(view)] = item
                self.treeProjects.addTopLevelItem(item)
                item.setExpanded(True)
                item.namedPipelines.setExpanded(True)
                self.numProjects += 1
                self.emit(QtCore.SIGNAL("project_added"), item.controller.name)
                self.state_changed(view)
                # add sheets from vistrail actionAnnotations
                tc = self.spreadsheetWindow.get_current_tab_controller()
                for annotation in view.controller.vistrail.action_annotations:
                    if annotation.db_key != 'uvcdatCell':
                        continue
                    cell = fromAnnotation(annotation.db_value)
                    plot_type = view.controller.vistrail.get_action_annotation(
                        annotation.db_action_id, "uvcdatType")
                    if cell[0] not in item.sheet_to_item:
                        rows, cols = self.currentProject.sheetSize(cell[0])
                        tc.setCurrentIndex(
                            tc.addTabWidget(StandardWidgetSheetTab(tc),
                                            cell[0]))
                        tab = tc.currentWidget()
                        tab.sheet.stretchCells()
                        tab.setDimension(rows, cols)
                        tab.sheet.setRowCount(rows)
                        tab.sheet.setColumnCount(cols)
                        tab.sheet.stretchCells()
                        tab.displayPrompt()
                        tab.setEditingMode(tab.tabWidget.editingMode)
                    else:
                        tab = item.sheet_to_tab[cell[0]]
                        self.spreadsheetWindow.get_current_tab_controller(
                        ).setCurrentWidget(tab)
                    # Add cell

                    if len(cell) < 5:
                        item.controller.vis_was_dropped(
                            (view.controller, annotation.db_action_id, cell[0],
                             int(cell[1]), int(cell[2]), plot_type.value))
                        item.update_cell(cell[0], int(cell[1]), int(cell[2]),
                                         None, None, plot_type.value,
                                         annotation.db_action_id, False)
                    else:
                        item.controller.vis_was_dropped(
                            (view.controller, annotation.db_action_id, cell[0],
                             int(cell[1]), int(cell[2]), plot_type.value))
                        item.update_cell(cell[0], int(cell[1]), int(cell[2]),
                                         int(cell[3]), int(cell[4]),
                                         plot_type.value,
                                         annotation.db_action_id, False)
                if not len(item.sheet_to_item):
                    tc.create_first_sheet()
                self.connect(item.controller, QtCore.SIGNAL("update_cell"),
                             item.update_cell)
                self.connect(item.controller,
                             QtCore.SIGNAL("sheet_size_changed"),
                             item.sheetSizeChanged)
                self.connect(item.controller, QtCore.SIGNAL("show_provenance"),
                             item.show_provenance)

                # add any variables that weren't automatically added above
                # by checking leaf nodes of the version tree
                from packages.uvcdat_cdms.init import CDMSVariable, CDMSVariableOperation
                from packages.uvcdat_cdms.pipeline_helper import CDMSPipelineHelper
                fullTree = view.controller.vistrail.tree.getVersionTree()
                pipelinesToSearch = []
                for version in fullTree.iter_vertices():
                    if fullTree.out_degree(version) == 0:
                        view.controller.change_selected_version(version)
                        pipeline = view.controller._get_current_pipeline()
                        found = False
                        for module in CDMSPipelineHelper.find_modules_by_type(
                                pipeline, [CDMSVariable]):
                            if module.name not in self.current_controller.defined_variables:
                                found = True
                                break

                        if not found:
                            for module in CDMSPipelineHelper.find_modules_by_type(
                                    pipeline, [CDMSVariableOperation]):
                                if module.varname not in self.current_controller.computed_variables:
                                    found = True
                                    break

                        if found:
                            pipelinesToSearch.append(pipeline)

                #perform this outside above loop because it changes the version tree that
                #is being iterated over
                for pipeline in pipelinesToSearch:
                    self.current_controller.search_and_emit_variables(
                        pipeline, CDMSPipelineHelper)

            if view.controller.locator:
                name = view.controller.locator.short_name
                self.viewToItem[id(view)].setText(0, name)
            self.treeProjects.setCurrentItem(self.viewToItem[id(view)])

        except Exception, err:
            print "Error adding project: ", str(err)
            traceback.print_exc(100, sys.stderr)
Beispiel #7
0
 def add_project(self, view):
     """ add_project(view: QVistrailView) -> None
     vistrails calls this when a project is opened/created/saved
     Items and spreadsheets are updated
     """
     try:
         if id(view) not in self.viewToItem:
             if self.currentProject:
                 self.setBold(self.currentProject, False)
             p_name = "Project %i" % self.numProjects
             item = QProjectItem(view, p_name)
             self.currentProject = item
             self.current_controller = item.controller
             self.viewToItem[id(view)] = item
             self.treeProjects.addTopLevelItem(item)
             item.setExpanded(True)
             item.namedPipelines.setExpanded(True)
             self.numProjects += 1
             self.emit(QtCore.SIGNAL("project_added"), item.controller.name)
             self.state_changed(view)
             # add sheets from vistrail actionAnnotations
             tc = self.spreadsheetWindow.get_current_tab_controller()
             for annotation in view.controller.vistrail.action_annotations:
                 if annotation.db_key != 'uvcdatCell':
                     continue
                 cell = fromAnnotation(annotation.db_value)
                 plot_type = view.controller.vistrail.get_action_annotation(
                                 annotation.db_action_id, "uvcdatType")
                 if cell[0] not in item.sheet_to_item:
                     rows, cols = self.currentProject.sheetSize(cell[0])
                     tc.setCurrentIndex(tc.addTabWidget(
                                          StandardWidgetSheetTab(tc), cell[0]))
                     tab = tc.currentWidget()
                     tab.sheet.stretchCells()
                     tab.setDimension(rows, cols)
                     tab.sheet.setRowCount(rows)
                     tab.sheet.setColumnCount(cols)
                     tab.sheet.stretchCells()
                     tab.displayPrompt()
                     tab.setEditingMode(tab.tabWidget.editingMode)
                 else:
                     tab = item.sheet_to_tab[cell[0]]
                     self.spreadsheetWindow.get_current_tab_controller(
                                                        ).setCurrentWidget(tab)
                 # Add cell
                
                 if len(cell)<5:
                     item.controller.vis_was_dropped((view.controller, 
                                  annotation.db_action_id, cell[0],
                                  int(cell[1]), int(cell[2]), plot_type.value))
                     item.update_cell(cell[0], int(cell[1]), int(cell[2]),
                                      None, None, plot_type.value,
                                      annotation.db_action_id, False)
                 else:
                     item.controller.vis_was_dropped((view.controller,
                                  annotation.db_action_id, cell[0],
                                  int(cell[1]), int(cell[2]), plot_type.value))
                     item.update_cell(cell[0], int(cell[1]), int(cell[2]),
                                      int(cell[3]), int(cell[4]),
                                      plot_type.value,
                                      annotation.db_action_id, False)
             if not len(item.sheet_to_item):
                 tc.create_first_sheet()
             self.connect(item.controller, QtCore.SIGNAL("update_cell"),
                      item.update_cell)
             self.connect(item.controller, QtCore.SIGNAL("sheet_size_changed"),
                      item.sheetSizeChanged)
             self.connect(item.controller, QtCore.SIGNAL("show_provenance"),
                          item.show_provenance)
             
             # add any variables that weren't automatically added above
             # by checking leaf nodes of the version tree
             from packages.uvcdat_cdms.init import CDMSVariable, CDMSVariableOperation
             from packages.uvcdat_cdms.pipeline_helper import CDMSPipelineHelper
             fullTree = view.controller.vistrail.tree.getVersionTree()
             pipelinesToSearch = []
             for version in fullTree.iter_vertices():
                 if fullTree.out_degree(version) == 0:
                     view.controller.change_selected_version(version)
                     pipeline = view.controller._get_current_pipeline()
                     found = False
                     for module in CDMSPipelineHelper.find_modules_by_type(
                             pipeline, [CDMSVariable]):
                         if module.name not in self.current_controller.defined_variables:
                             found = True
                             break
                         
                     if not found:
                         for module in CDMSPipelineHelper.find_modules_by_type(
                                 pipeline, [CDMSVariableOperation]):
                             if module.varname not in self.current_controller.computed_variables:
                                 found = True
                                 break
                             
                     if found:
                         pipelinesToSearch.append(pipeline)
             
             #perform this outside above loop because it changes the version tree that 
             #is being iterated over
             for pipeline in pipelinesToSearch:
                 self.current_controller.search_and_emit_variables(pipeline, CDMSPipelineHelper)
  
         if view.controller.locator:
             name = view.controller.locator.short_name
             self.viewToItem[id(view)].setText(0, name)
         self.treeProjects.setCurrentItem(self.viewToItem[id(view)])
         
         
         
     except Exception, err:
         print "Error adding project: ", str(err)
         traceback.print_exc( 100, sys.stderr )