From fe914ab0f0814933a07c70bc8730bc646f722929 Mon Sep 17 00:00:00 2001 From: pin Date: Fri, 30 Jul 2010 16:34:59 +0000 Subject: [PATCH] Ajout de l'affichage des erreurs en fonction du temps. git-svn-id: https://svn.cri.ensmp.fr/svn/minwii/trunk@309 fe552daf-6dbe-4428-90eb-1537e0879342 --- src/minwii/loganalyse.py | 66 +++++++++++++++++++++++++++++++++++----- src/minwii/logapp.py | 33 +++++++++++++++----- 2 files changed, 84 insertions(+), 15 deletions(-) diff --git a/src/minwii/loganalyse.py b/src/minwii/loganalyse.py index ab8c819..f3e5e32 100755 --- a/src/minwii/loganalyse.py +++ b/src/minwii/loganalyse.py @@ -44,29 +44,41 @@ def statsresults(m) : computeList.__doc__ = m.__doc__ return computeList +def timebased(m) : + m.timebased = True + return m + class LogFileAnalyser(LogFileReader) : POSSIBLE_ANALYSES = {'BEGINNER' : ('songDuration', 'playingDuration', 'noteEndNoteOnLatency', 'realisationRate') + ,'EASY' : ('songDuration', 'playingDuration', 'noteEndNoteOnLatency', 'realisationRate', - 'missCount') + 'missCount', + 'getMissPerTimeFrame') + ,'NORMAL' : ('songDuration', 'playingDuration', 'realisationRate', - 'missCount') + 'missCount', + 'getMissPerTimeFrame') + ,'ADVANCED' : ('songDuration', 'playingDuration', 'realisationRate', - 'missCount') + 'missCount', + 'getMissPerTimeFrame') + ,'EXPERT' : ('songDuration', 'playingDuration', 'realisationRate', - 'missCount') + 'missCount', + 'getMissPerTimeFrame') } def analyse(self) : @@ -74,14 +86,14 @@ class LogFileAnalyser(LogFileReader) : try : self.mode = mode = self.getMode() - results.append(('Mode de jeu', PLAYING_MODES.get(mode, mode))) + results.append(('Mode de jeu', PLAYING_MODES.get(mode, mode), False)) self.songTitle = LogFileAnalyser.getSongTitle(self.getSongFile()) - results.append(('Chanson', self.songTitle)) + results.append(('Chanson', self.songTitle, False)) for name in self.POSSIBLE_ANALYSES[mode] : meth = getattr(self, name) - results.append((meth.__doc__, meth())) + results.append( (meth.__doc__, meth(), getattr(meth, 'timebased', False)) ) except : raise @@ -202,6 +214,46 @@ class LogFileAnalyser(LogFileReader) : miss = miss + 1 return miss + + @timebased + def getMissPerTimeFrame(self, timeFrame=10000) : + "Nombre d'erreurs en fonction du temps" + eIter = self.getEventsIterator() + firstTicks = self.getFirstEventTicks() + frames = [0] + + if self.mode in ('EASY', 'NORMAL') : + catchColUp = False + for ticks, eventName, message in eIter : + if ticks - firstTicks > timeFrame : + firstTicks = ticks + frames.append(0) + + if eventName == 'COLDOWN' : + colState = message.split(None, 2)[1] + colState = colState == 'True' + if colState : + catchColUp = False + continue + else : + catchColUp = True + elif eventName == 'NOTEON' : + catchColUp = False + elif eventName == 'COLUP' and catchColUp : + frames[-1] = frames[-1] + 1 + else : + for ticks, eventName, message in eIter : + if ticks - firstTicks > timeFrame : + firstTicks = ticks + frames.append(0) + + if eventName == 'COLDOWN' : + colState = message.split(None, 2)[1] + colState = colState == 'True' + if not colState : + frames[-1] = frames[-1] + 1 + + return frames diff --git a/src/minwii/logapp.py b/src/minwii/logapp.py index 1210bf6..1bbebd4 100755 --- a/src/minwii/logapp.py +++ b/src/minwii/logapp.py @@ -177,9 +177,6 @@ class Identification(Frame) : self.patientName = StringVar() self.createWidgets() - #def setFileName(self, name) : - # self.fileName.set(name) - def refresh(self, lfa) : filename = basename(lfa.logfile.name) self.fileName.set(filename) @@ -226,13 +223,33 @@ class ResultsFrame(Frame) : def layResults(self, lfa) : results = lfa.analyse() if results : - for i, kv in enumerate(results) : - k, v = kv + for i, kvt in enumerate(results) : + k, v, timeBased = kvt kl = Label(self, text='%s :' % k) kl.grid(row=i, column=0, sticky=E) - - vl = Label(self, text=v) - vl.grid(row=i, column=1, sticky=W) + + if not timeBased : + vl = Label(self, text=v) + vl.grid(row=i, column=1, sticky=W) + else : + maxv = max(v) + if maxv : + cw, ch = 200, 100 + c = Canvas(self, background='#fff', width=cw, height=ch) + rectW = int(float(cw) / len(v)) + unitRectH = float(ch) / maxv + for j, fv in enumerate(v) : + if not fv : continue + x0 = j * rectW + y0 = ch - int(unitRectH * fv) + x1 = (j + 1) * rectW + y1 = ch + c.create_rectangle(x0, y0, x1, y1, fill="#9085ba") + c.grid(row=i, column=1, sticky=W) + + else : + vl = Label(self, text='—') + vl.grid(row=i, column=1, sticky=W) else : msg = Label(self, text="Pas de données exploitables.") msg.grid() -- 2.20.1