def updateVistrail(self): """ updateVistrail() -> None Update Vistrail to contain changes in the port table """ old_registry = self.module.registry newPorts = self.newInputPorts() (deletePorts, addPorts) = self.registryChanges(old_registry, newPorts) # Remove any connections or functions related to delete ports for (cid, c) in self.controller.current_pipeline.connections.items(): if ((c.sourceId==self.module.id and any([c.source.name==p[1] for p in deletePorts])) or (c.destinationId==self.module.id and any([c.destination.name==p[1] for p in deletePorts]))): self.controller.delete_connection(cid) for p in deletePorts: module = self.controller.current_pipeline.modules[self.module.id] ids = [] for fid in range(module.getNumFunctions()): if module.functions[fid].name==p[1]: ids.append(fid) for i in ids: self.controller.delete_method(i, self.module.id) for p in deletePorts: self.controller.delete_module_port(self.module.id, p) # Add all addPorts for p in addPorts: self.controller.add_module_port(self.module.id, p) # If output spec change, remove all connections spec = [p[2][1:-1] for p in newPorts] if len(deletePorts)+len(addPorts)>0: for (cid, c) in self.controller.current_pipeline.connections.items(): if (c.sourceId==self.module.id and c.source.name=='value'): self.controller.delete_connection(cid) tpl = ('output', 'value') if self.controller.has_module_port(self.module.id, tpl): # Remove the current output port and add a new one self.controller.delete_module_port(self.module.id, tpl) spec = '('+','.join(spec)+')' self.controller.add_module_port(self.module.id, ('output', 'value', spec))
def updateActionsHandler(self, controller): oldRegistry = self.module.registry newPorts = self.newInputOutputPorts() (deletePorts, addPorts) = self.registryChanges(oldRegistry, newPorts) for (cid, c) in controller.current_pipeline.connections.items(): if ((c.sourceId==self.module.id and any([c.source.name==p[1] for p in deletePorts])) or (c.destinationId==self.module.id and any([c.destination.name==p[1] for p in deletePorts]))): controller.delete_connection(cid) for p in deletePorts: controller.delete_module_port(self.module.id, p) for p in addPorts: controller.add_module_port(self.module.id, p) if self.codeEditor.document().isModified(): code = urllib.quote(str(self.codeEditor.toPlainText())) fid = self.findSourceFunction() # FIXME make sure that this makes sense if fid==-1: # do add function fid = self.module.getNumFunctions() f = ModuleFunction(pos=fid, name='source') param = ModuleParam(type='String', val=code, alias='', name='<no description>', pos=0) f.addParameter(param) controller.add_method(self.module.id, f) else: # do change parameter paramList = [(code, 'String', None, 'edu.utah.sci.vistrails.basic', '')] controller.replace_method(self.module, fid, paramList)
def compute(self): # Skips the check if it's a vtkImageReader or vtkPLOT3DReader, because # it has other ways of specifying files, like SetFilePrefix for # multiple files if any( issubclass(self.vtkClass, x) for x in [ vtk.vtkBYUReader, vtk.vtkImageReader, vtk.vtkPLOT3DReader, vtk.vtkDICOMImageReader, vtk.vtkTIFFReader ]): old_compute(self) return if self.hasInputFromPort('SetFileName'): name = self.getInputFromPort('SetFileName') elif self.hasInputFromPort('SetFile'): name = self.getInputFromPort('SetFile').name else: raise ModuleError(self, 'Missing filename') if not os.path.isfile(name): raise ModuleError(self, 'File does not exist') old_compute(self)
def compute(self): # Skips the check if it's a vtkImageReader or vtkPLOT3DReader, because # it has other ways of specifying files, like SetFilePrefix for # multiple files if any(issubclass(self.vtkClass, x) for x in [vtksnl.vtkBYUReader, vtksnl.vtkImageReader, vtksnl.vtkPLOT3DReader, vtksnl.vtkDICOMImageReader, vtksnl.vtkTIFFReader]): old_compute(self) return if self.hasInputFromPort('SetFileName'): name = self.getInputFromPort('SetFileName') elif self.hasInputFromPort('SetFile'): name = self.getInputFromPort('SetFile').name else: raise ModuleError(self, 'Missing filename') if not os.path.isfile(name): raise ModuleError(self, 'File does not exist') old_compute(self)
def new_move_test(): return (new_action and any(new_action.operations, lambda x: x.what == 'location' and x.vtType == 'change'))
def new_addition_test(): return (new_action and any(new_action.operations, lambda x: x.vtType == 'add'))
def old_deletion_test(): return (old_action and any(old_action.operations, lambda x: x.vtType == 'delete'))