def patternchangedCB(self, *args): # select the files that match self.filechooser.unselect_all() items = os.listdir(self.filechooser.get_current_folder()) for item in items: if utils.matchvtkpattern(self.pattern_entry.get_text(), item): self.filechooser.select_filename(os.path.join(self.filechooser.get_current_folder(),item)) self.sensitize()
def patternchangedCB(self, *args): # select the files that match self.filechooser.unselect_all() items = os.listdir(self.filechooser.get_current_folder()) for item in items: if utils.matchvtkpattern(self.pattern_entry.get_text(), item): self.filechooser.select_filename( os.path.join(self.filechooser.get_current_folder(), item)) self.sensitize()
def readImage(filepattern, **kwargs): # We make the basename the name of the first # image, we also use this in OOFImage3D to probe the image type # using ImageMagick. dirname = os.path.dirname(filepattern) numfiles = utils.countmatches(filepattern, dirname, utils.matchvtkpattern) if numfiles == 0: raise ooferror.ErrUserError("No files match pattern: "+filepattern) # return something? else: items = os.listdir(dirname) for item in items: if utils.matchvtkpattern(filepattern, item): basename = item firstimagename = os.path.join(dirname, basename) # vtk wants a file pattern with some string that includes # integers. The pattern must be sprintf style with '%i' where the # integers belong. pattern = string.replace(filepattern, "*", "%i") image = OOFImage3D(os.path.basename(filepattern), firstimagename, pattern, numfiles) # set physical size of image pixelsize = image.sizeInPixels() given_height = 'height' in kwargs given_width = 'width' in kwargs given_depth = 'depth' in kwargs ## if not (given_height or given_width or given_depth): ## width = float(pixelsize.x) ## height = float(pixelsize.y) ## depth = float(pixelsize.z) ## elif given_height and given_width and given_depth: ## width = float(kwargs['width']) ## height = float(kwargs['height']) ## depth = float(kwargs['depth']) ## else: ## #aspect = float(pixelsize.x)/pixelsize.y ## if given_width: ## width = float(kwargs['width']) ## height = width/aspect ## elif given_height: ## height = float(kwargs['height']) ## width = height*aspect # for now, this works differently from the 2d version. Any # dimension not explicity set gets set to 1. TODO: figure out the # aspect ratio stuff. Should it just use the largest of the ones # that are set? if given_width: width = float(kwargs['width']) else: width = float(pixelsize.x) if given_height: height = float(kwargs['height']) else: height = float(pixelsize.y) if given_depth: depth = float(kwargs['depth']) else: depth = float(pixelsize.z) image.setSize(primitives.Point(width, height, depth)) return image