Esempio n. 1
0
 def AddPoint(self, x, y):
     print "adding point", x, Track.PositionToTime(x)
     # work out which track is clicked and then pass on the event
     # to that track
     i = y / self.track_height
     if (i < len(self.tracks) and x > self.name_length):
         self.LastClickedTrack = self.tracks[i]
         self.tracks[i].AddPoint(Track.PositionToTime(x - self.name_length))
         # if the track clicked on is the currently playing track
         # reload it so that any changes are taken account of
         if i == self.selectedTrack:
             self.PlayTrack(i)
         self.Refresh()
Esempio n. 2
0
    def PCA(self):
        if self.pcs == None:
            print "CANNOT DO PCA, scipy isn't loaded"
        print "doing pca"
        motion = self.tracks[self.selectedTrack].GetMotion()
        splits = self.tracks[self.selectedTrack].GetSplits()
        if len(splits) > 0:
            motions = [
                Piavca.SubMotion(motion, split.GetStart(), split.GetEnd())
                for split in splits
            ]
        else:
            motions = [motion]
        splits = [(0, split.GetStart(), split.GetEnd()) for split in splits]
        length = Track.PositionToTime(
            self.track_length) * Track.frames_per_second
        #self.pcs.do_pca([motion], splits, length, Track.frames_per_second)
        self.pcs.addMotions(motions)
        self.pcs.setFramesPerSecond(Track.frames_per_second)
        self.pcs.create()
        #self.pcs.setMotion(motion)

        # load the PCAs into the avatar to play them
        Piavca.Core.getCore().setCurrentTime(0)
        #self.avatar.playMotionDirect(Piavca.PyMotion(self.pcs))
        self.avatar.playMotionDirect(self.pcs)
        Piavca.Core.getCore().setCurrentTime(self.time)
Esempio n. 3
0
 def OnLeftClick(self, x, y):
     print "OnLeftClick"
     self.restartPlaying = 0
     if x < self.name_length:
         i = y / self.track_height
         if (i < len(self.tracks)):
             self.SelectTrack(i)
     else:
         self.SetTime(Track.PositionToTime(x - self.name_length))
         # restart playing to get make sure it plays from the new time
         if self.playing:
             self.Stop()
             self.restartPlaying = 1
         else:
             self.restartPlaying = 0
Esempio n. 4
0
 def OnMouseMove(self, x, y):
     self.SetTime(Track.PositionToTime(x - self.name_length))
Esempio n. 5
0
 def AdvanceTime(self):
     if (self.playing):
         newtime = Piavca.Core.getCore().getSystemTime() - self.startTime
         while newtime > Track.PositionToTime(self.track_length):
             newtime -= Track.PositionToTime(self.track_length)
         self.SetTime(newtime)
Esempio n. 6
0
    def SlowSubspace(self):
        if self.pcs == None:
            print "CANNOT DO PCA, scipy isn't loaded"
        print "doing slow subspace"
        motion = self.tracks[self.selectedTrack].GetMotion()
        splits = self.tracks[self.selectedTrack].GetSplits()
        if len(splits) > 0:
            motions = [
                Piavca.SubMotion(motion, split.GetStart(), split.GetEnd())
                for split in splits
            ]
        else:
            motions = [motion]
        splits = [(0, split.GetStart(), split.GetEnd()) for split in splits]
        length = Track.PositionToTime(
            self.track_length) * Track.frames_per_second

        #self.pcs.do_pca([motion], splits, length, Track.frames_per_second)
        self.pcs.addMotions(motions)
        print "doing sub space on motions", motions
        self.pcs.setFramesPerSecond(Track.frames_per_second)

        ssa = SlowSubSpace.SlowSubSpace()

        val = None
        dialog_return = textEntryDialog(
            None,
            message="enter slow subspace trade off (alpha)",
            defaultText="0.2")
        val = float(dialog_return.text.encode("latin-1"))
        #dialog.SetValue("0.2")
        # The user pressed the "OK" button in the dialog
        #if dialog.ShowModal() == wxID_OK:
        #	print 'Position of selection:', dialog.GetValue()
        #	val = float(dialog.GetValue())
        #	print val
        #else:
        #	path = None
        #	print 'You did not select anything.'
        #dialog.Destroy()
        if val != None:
            ssa.setAlpha(val)

        val = None
        dialog_return = textEntryDialog(None,
                                        message="enter percentage to keep",
                                        defaultText="0.99")
        val = float(dialog_return.text.encode("latin-1"))
        #dialog = wxTextEntryDialog ( None, message="enter percentage to keep" )
        #dialog.SetValue("0.99")
        # The user pressed the "OK" button in the dialog
        #if dialog.ShowModal() == wxID_OK:
        #	print 'Position of selection:', dialog.GetValue()
        #	val = float(dialog.GetValue())
        #	print val
        #else:
        #	path = None
        #	print 'You did not select anything.'
        #dialog.Destroy()
        if val != None:
            ssa.setPercentageToKeep(val)

        self.pcs.setAnalysis(ssa)
        self.pcs.create()
        #self.pcs.setMotion(motion)

        # load the PCAs into the avatar to play them
        Piavca.Core.getCore().setCurrentTime(0)
        #self.avatar.playMotionDirect(Piavca.PyMotion(self.pcs))
        self.avatar.playMotionDirect(self.pcs)
        Piavca.Core.getCore().setCurrentTime(self.time)