~ubuntu-branches/ubuntu/precise/pytrainer/precise

« back to all changes in this revision

Viewing changes to pytrainer/gui/drawArea.py

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2010-02-04 06:07:11 UTC
  • mfrom: (4.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20100204060711-25n5aw66w5egeiph
Tags: 1.7.1-1ubuntu1
* Merge from debian testing, remaining changes:
  - debian/control:
    + Replace Depends on iceweasel with firefox | abrowser.
    + Bump python-dev,debhelper build-dependencies.
    - Drop dependency on python-glade2 (libglade -> gtkbuilder transition).
  - debian/rules:
    + Append --install-laoyut=deb to setup.py install to prevent a build
      failure with Python 2.6.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
                        return False
45
45
                #logging.debug('xvalues: '+str(xvalues))
46
46
                #logging.debug('yvalues: '+str(yvalues))
47
 
                logging.debug("Type: "+type+" | title: "+str(title)+" | col: "+str(color)+" | xlabel: "+str(xlabel)+" | ylabel: "+str(ylabel))
 
47
                #logging.debug("Type: "+type+" | title: "+str(title)+" | col: "+str(color)+" | xlabel: "+str(xlabel)+" | ylabel: "+str(ylabel))
48
48
                if type == "bars":
49
49
                        self.drawBars(xvalues,yvalues,xlabel,ylabel,title,color)
50
50
                elif type == "plot":
55
55
 
56
56
        def drawBars(self,xvalues,yvalues,xlabel,ylabel,title,color):
57
57
                logging.debug('>>')     
 
58
                logging.debug("Type: bars | title: "+str(title)+" | col: "+str(color)+" | xlabel: "+str(xlabel)+" | ylabel: "+str(ylabel))
58
59
                self.removeVboxChildren()       
59
60
                figure = Figure(figsize=(6,4), dpi=72)
60
61
                numCols=len(xvalues[0])
129
130
 
130
131
        def getColor(self, x):
131
132
                colors=["b","g","r","c","m","y","k", "w"]
132
 
                if x > len(colors):
 
133
                if x >= len(colors):
133
134
                        x = x % len(colors)
134
135
                return colors[x]
135
136
        
272
273
 
273
274
                logging.debug('<<')
274
275
 
275
 
        def drawPlot(self,xvalues,yvalues,xlabel,ylabel,title,color,zones=None):
 
276
        def drawPlot(self,xvalues,yvalues,xlabel,ylabel,title,color,zones=None,xzones=None):
276
277
                logging.debug('>>')  
 
278
                logging.debug("Type: plot | title: "+str(title)+" | col: "+str(color)+" | xlabel: "+str(xlabel)+" | ylabel: "+str(ylabel))
277
279
                logging.debug('xlabel: '+str(xlabel)+' | ylabel: '+str(ylabel)+' | title: '+str(title))
278
280
                self.removeVboxChildren()
279
281
                figure = Figure()
286
288
                                        
287
289
                                axis.grid(True)
288
290
                                for tl in axis.get_yticklabels():
289
 
                                        tl.set_color('%s' %color[i])
 
291
                                        tl.set_color('%s' %color[i])
 
292
                                #Draw zones on graph, eg for each lap
 
293
                                if xzones is not None:
 
294
                                        for xzone in xzones:
 
295
                                                if xzones.index(xzone) % 2:
 
296
                                                        zonecolor='b'
 
297
                                                else:
 
298
                                                        zonecolor='g'
 
299
                                                axis.axvspan(xzone[0], xzone[1], alpha=0.25, facecolor=zonecolor)
 
300
                                maxX = max(xvalues[i])
290
301
                        if i>=1:
291
302
                                ax2 = axis.twinx()
292
303
                                ax2.plot(xvalues[i], yvalues[i], color=color[i])
293
304
                                for tl in ax2.get_yticklabels():
294
 
                                        tl.set_color('%s' %color[i])
 
305
                                        tl.set_color('%s' %color[i])
 
306
                                maxXt = max(xvalues[i])
 
307
                                if maxXt > maxX:
 
308
                                        maxX = maxXt
295
309
                        axis.set_xlabel(xlabel[i])
296
310
                        i+=1
297
 
                
 
311
                axis.set_xlim(0, maxX)
 
312
 
298
313
                if (len(xvalues)>1):
299
314
                        axis.set_title("%s vs %s" %(ylabel[0],ylabel[1]))
300
315
                else:
309
324
                for child in self.vbox.get_children():
310
325
                        logging.debug('Child available: '+str(child))
311
326
 
312
 
                if title[0] == 'Stage Profile':
313
 
                        figure.savefig('/tmp/stage.png', dpi=75)
314
 
                if title[0] == 'Heart Rate':
315
 
                        figure.savefig('/tmp/hr.png', dpi=75)
316
327
                logging.debug('<<')
317
328
        
318
329
        def drawPie(self,xvalues,yvalues,xlabel,ylabel,title,color,zones=None):
319
330
                logging.debug('>>')
 
331
                logging.debug("Type: pie | title: "+str(title)+" | col: "+str(color)+" | xlabel: "+str(xlabel)+" | ylabel: "+str(ylabel))
320
332
                self.removeVboxChildren()
321
333
                figure = Figure(figsize=(6,4), dpi=72)
322
334
                axis = figure.add_subplot(111)