def __init__(self,viewer, master=None, root=None,
                 height=80,width=200,
                 currentFrameIndex=0,
                 startFrame=0, 
                 endFrame=0,
                 maxFrame=0,
                 stepSize=1, 
                 playMode=1,
                 titleStr='AnimPlayer',
                 counter = 1,
                 gui=1,framerate=15.):

        if master is None:
            master = Tkinter.Toplevel()

        # viewer from which we get the geom to animate
        self.viewer = viewer
        # frame list, is a list of geom .
        # each frame is made of n DejaVu object to be display
        # it a list of tuple, each tuple is a {} and []
        # {} is: {'objname':['geom1','geom2'],'objname':['geom1','geom2']}
        # [] is list of DejaVu object per frame
        self.framelist=[]

        Player.__init__(self, master=master,root=root,height=height,
                        width=width,currentFrameIndex=currentFrameIndex,
                        startFrame=startFrame,endFrame=endFrame,
                        maxFrame=maxFrame,stepSize=stepSize,
                        playMode=playMode,titleStr=titleStr,counter=counter,
                        gui=gui,framerate=framerate)
Ejemplo n.º 2
0
    def __init__(self,
                 viewer,
                 master=None,
                 root=None,
                 height=80,
                 width=200,
                 currentFrameIndex=0,
                 startFrame=0,
                 endFrame=0,
                 maxFrame=0,
                 stepSize=1,
                 playMode=1,
                 titleStr='AnimPlayer',
                 counter=1,
                 gui=1,
                 framerate=15.):

        if master is None:
            master = Tkinter.Toplevel()

        # viewer from which we get the geom to animate
        self.viewer = viewer
        # frame list, is a list of geom .
        # each frame is made of n DejaVu object to be display
        # it a list of tuple, each tuple is a {} and []
        # {} is: {'objname':['geom1','geom2'],'objname':['geom1','geom2']}
        # [] is list of DejaVu object per frame
        self.framelist = []

        Player.__init__(self,
                        master=master,
                        root=root,
                        height=height,
                        width=width,
                        currentFrameIndex=currentFrameIndex,
                        startFrame=startFrame,
                        endFrame=endFrame,
                        maxFrame=maxFrame,
                        stepSize=stepSize,
                        playMode=playMode,
                        titleStr=titleStr,
                        counter=counter,
                        gui=gui,
                        framerate=framerate)
Ejemplo n.º 3
0
    def __init__(self, director, **kw):
##                         master=None, root=None,
##                         height=80,width=200,
##                         currentFrameIndex=0,
##                         startFrame=0, 
##                         endFrame=0,
##                         maxFrame=0,
##                         stepSize=1, 
##                         playMode=0,
##                         ##afterDelay=50,
##                         titleStr='Player',
##                         gotoStartfile = 'go_to_start.gif',
##                         gotoEndfile = 'go_to_end.gif',
##                         ff_revfile = 'ff_rev.gif',
##                         ff_fwdfile = 'ff_fwd.gif',
##                         stopfile = 'stop.gif',
##                         playfile = 'play_fwd.gif',
##                         playRevfile = 'play_rev.gif',
##                         chmodfile = 'chmod.gif',
##                         closefile = 'close.gif',
##                         iconpath = None,
##                         counter = 1,
##                         form2=1, gui=1,framerate=15., hasSlider=False):

        assert isinstance(director, MAADirector)
        self.director = director
        kw['gui'] = 1
        kw['form2'] = 1
        kw['startFrame'] = 0
        kw['maxFrame'] = kw['endFrame'] = director.endFrame
        kw['buttonMask'] = {'setanimB':False, 'closeB':False}
        kw['currentFrameIndex'] = -1
        Player.__init__(self, **kw)
        if self.hasSlider:
            slider = self.form.descr.entryByName['slider']['widget']
            sliderkw = {'from': self.startFrame-1, 'to': self.maxFrame+1}
            slider.configure(sliderkw)
            slider.set(self.currentFrameIndex)
        self.form.ent2.delete(0,'end')
        self.form.ent2.insert(0, 'start')
        self.recording = False
        if sys.platform == 'darwin':
            self.codecType = 'mpeg1video'
        else:
            self.codecType = 'mpeg2video'
        self.filename = 'movie.mpg'
        self.fileTypes = [("MPG", ".mpg")]
        self.cameraSize=Tkinter.StringVar()
        self.cameraSize.set("current")
        root = self.root
        screenw, screenh = root.winfo_screenwidth(), root.winfo_screenheight()
        res = [(320, 240), (640, 480), (1280, 720), (1920, 1080)]
        self.resolutions = {}
        for w,h in res:
            if w <= screenw and h <=screenh:
                self.resolutions["%dx%d"%(w,h)] = (w, h)
        nb = self.director._animNB
        if nb:
            self.vf=nb().pmv
        else:
            self.vf=None

        self.recordDialog = self.createRecordDialog()
Ejemplo n.º 4
0
class FloodPlayer(Player):
    def __init__(self, command, file):
        master = command.vf.GUI.ROOT
        self.autoLigandCommand = command.vf.AutoLigandCommand
        self.autoLigandCommand.spheres.Set(visible=1)
        self.autoLigandCommand.halo.Set(visible=1)
        pkl_file = open(file, 'rb')
        self.floods = []
        try:
            data = cPickle.load(pkl_file)
        except Exception, inst:
            print "Error loading ", __file__, "\n", inst
        self.xcent = data[0]
        self.ycent = data[1]
        self.zcent = data[2]
        self.centerx = data[3]
        self.centery = data[4]
        self.centerz = data[5]
        self.spacing = data[6]
        self.centers = []
        data = cPickle.load(pkl_file)
        self.floods.append(data[1])
        try:
            while data:
                data = cPickle.load(pkl_file)
                flood = copy.copy(self.floods[-1])
                for item in data[0]:
                    flood.remove(item)
                for item in data[1]:
                    flood.append(item)
                self.floods.append(flood)
        except EOFError:
            pass
        pkl_file.close()
        fileName = os.path.splitext(os.path.split(file)[-1])[0]
        self.mol = Protein(fileName)
        self.mol.allAtoms = AtomSet([])
        chain = Chain()
        self.residue = Residue(type="UNK")
        chain.adopt(self.residue, setChildrenTop=1)
        self.mol.adopt(chain, setChildrenTop=1)
        self.mol.parser = None
        self.filename = file
        fl = self.floods[0][0]
        x = (fl[1] - self.xcent) * self.spacing + self.centerx
        y = (fl[2] - self.ycent) * self.spacing + self.centery
        z = (fl[3] - self.zcent) * self.spacing + self.centerz
        if fl[4] == 7:
            atomchr = 'P'
            # note, this will color the NA atom pink (the PDB color for Phosphorus)
            radius = AAradii[13][0]
        if fl[4] == 6:
            atomchr = 'S'
            radius = AAradii[13][0]
        if fl[4] == 5:
            atomchr = 'A'
            radius = AAradii[10][0]
        if fl[4] == 4:
            atomchr = 'O'
            radius = AAradii[1][0]
        if fl[4] == 3:
            atomchr = 'N'
            radius = AAradii[4][0]
        if fl[4] == 2:
            atomchr = 'C'
            radius = AAradii[10][0]
        if fl[4] == 1:
            atomchr = 'H'
            radius = AAradii[15][0]
        a = Atom(atomchr, self.residue, atomchr, top=self.mol)
        a._coords = [[x, y, z]]
        a._charges = {}
        a.hetatm = 1
        a.number = 0
        a.radius = radius
        self.mol.allAtoms = self.residue.atoms
        self.mol = self.autoLigandCommand.vf.addMolecule(self.mol, False)
        self.mol.levels = [Protein, Chain, Residue, Atom]
        self.autoLigandCommand.vf.displayCPK(self.mol, scaleFactor=0.4)
        self.autoLigandCommand.vf.colorByAtomType(self.mol, ['cpk'], log=0)
        self.autoLigandCommand.vf.displayLines(self.mol,
                                               negate=True,
                                               displayBO=False,
                                               lineWidth=2,
                                               log=0,
                                               only=False)
        self.colorKeys = a.colors.keys()
        maxLen = len(self.floods) - 1
        Player.__init__(self,
                        master=master,
                        endFrame=maxLen,
                        maxFrame=maxLen,
                        titleStr="AutoLigand Flood Player",
                        hasSlider=True)
        try:  # withdrew SetAnim button
            self.form.ifd.entryByName['setanimB']['widget'].grid_forget()
            self.form.autoSize()
        except:
            pass
        self.nextFrame(0)
        self.form.root.protocol('WM_DELETE_WINDOW', self.hide_cb)