예제 #1
0
    def sensitize(self):
        debug.mainthreadTest()
        valid = self.table is None or self.table.isValid()
        # If we're opening an existing file, check to see if it's
        # really there.  If we're opening a new file, it would be nice
        # to check to see if the file entry widget has text in it, but
        # there seems to be no way to do that.  There's no way to call
        # this function after every keystroke, since the Entry widget
        # inside the FileChooserWidget isn't accessible and we can't
        # connect to it.
        if valid and \
               self.filechooser.get_action() == gtk.FILE_CHOOSER_ACTION_OPEN:
            if not self.pattern:
                filename = self.filechooser.get_filename()
                valid = filename is not None and os.path.isfile(filename)
            # check that there are files that fit the pattern
            else:
                matchcount = utils.countmatches(
                    self.pattern_entry.get_text(),
                    self.filechooser.get_current_folder(),
                    utils.matchvtkpattern)
                valid = valid and self.pattern_entry.get_text(
                ) != "*" and matchcount

        self.dialog.set_response_sensitive(self.OK, valid)
예제 #2
0
    def sensitize(self):
        debug.mainthreadTest()
        valid = self.table is None or self.table.isValid()
        # If we're opening an existing file, check to see if it's
        # really there.  If we're opening a new file, it would be nice
        # to check to see if the file entry widget has text in it, but
        # there seems to be no way to do that.  There's no way to call
        # this function after every keystroke, since the Entry widget
        # inside the FileChooserWidget isn't accessible and we can't
        # connect to it.
        if valid and \
               self.filechooser.get_action() == gtk.FILE_CHOOSER_ACTION_OPEN:
            if not self.pattern:
                filename = self.filechooser.get_filename()
                valid = filename is not None and os.path.isfile(filename)
            # check that there are files that fit the pattern
            else:                
                matchcount = utils.countmatches(self.pattern_entry.get_text(), self.filechooser.get_current_folder(), utils.matchvtkpattern)
                valid = valid and self.pattern_entry.get_text() != "*" and matchcount

        self.dialog.set_response_sensitive(self.OK, valid)
예제 #3
0
파일: oofimage3d.py 프로젝트: song2001/OOF2
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