Changeset 169
- Timestamp:
- 01/24/08 00:33:58 (1 year ago)
- Files:
-
- pytrainer/trunk/pytrainer/gui/drawArea.py (modified) (5 diffs)
- pytrainer/trunk/pytrainer/heartrategraph.py (modified) (2 diffs)
- pytrainer/trunk/pytrainer/profile.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
pytrainer/trunk/pytrainer/gui/drawArea.py
r148 r169 23 23 from matplotlib.backends.backend_gtk import FigureCanvasGTK, NavigationToolbar 24 24 from matplotlib.numerix import * 25 from pylab import * 25 26 26 27 class DrawArea: … … 32 33 self.drawDefault() 33 34 34 def stadistics(self,type,xvalues,yvalues,xlabel,ylabel,title,color ):35 def stadistics(self,type,xvalues,yvalues,xlabel,ylabel,title,color,zones=None): 35 36 if len(xvalues[0]) < 1: 36 37 self.drawDefault() … … 39 40 self.drawBars(xvalues,yvalues,xlabel,ylabel,title,color) 40 41 elif type == "plot": 41 self.drawPlot(xvalues,yvalues,xlabel,ylabel,title,color )42 self.drawPlot(xvalues,yvalues,xlabel,ylabel,title,color,zones) 42 43 43 44 def drawBars(self,xvalues,yvalues,xlabel,ylabel,title,color): … … 58 59 59 60 p1 = self.axis.bar(xvalues[i], yvalues[i], width, color=color[i]) 60 61 p = axvspan(1.25, 100.55, facecolor='g', alpha=0.5) 61 62 self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea 62 63 self.canvas.show() 63 64 self.vbox.pack_start(self.canvas, True, True) 64 65 65 def drawPlot(self,xvalues,yvalues,xlabel,ylabel,title,color ):66 def drawPlot(self,xvalues,yvalues,xlabel,ylabel,title,color,zones=None): 66 67 self.canvas.destroy() 67 68 self.figure = Figure(figsize=(6,4), dpi=72) 68 69 self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea 69 70 self.axis.clear() 70 for i in range(0,len(xvalues)): 71 i = 0 72 for value in xvalues: 71 73 if len(xvalues) == 1: 72 74 self.axis = self.figure.add_subplot(111) … … 78 80 self.axis.grid(True) 79 81 self.axis.plot(xvalues[i],yvalues[i], color=color[i]) 80 82 i+=1 83 if zones!=None: 84 for zone in zones: 85 p = self.axis.axhspan(zone[0], zone[1], facecolor=zone[2], alpha=0.5, label=zone[3]) 86 l = self.axis.legend(loc='lower right') 81 87 self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea 82 88 self.canvas.show() pytrainer/trunk/pytrainer/heartrategraph.py
r153 r169 18 18 19 19 from gui.drawArea import DrawArea 20 from lib.system import checkConf 21 from lib.xmlUtils import XMLParser 20 22 21 23 class HeartRateGraph: 22 24 def __init__(self, vbox = None): 23 25 self.drawarea = DrawArea(vbox) 26 self.conf = checkConf() 27 self.filename = self.conf.getValue("conffile") 28 self.configuration = XMLParser(self.filename) 24 29 25 30 def drawgraph(self,values): 31 maxhr = int(self.configuration.getValue("pytraining","prf_maxhr")) 32 resthr = int(self.configuration.getValue("pytraining","prf_minhr")) 33 if self.configuration.getValue("pytraining","prf_hrzones_karvonen")=="True": 34 #if karvonen method 35 targethr1 = ((maxhr - resthr) * 0.50) + resthr 36 targethr2 = ((maxhr - resthr) * 0.60) + resthr 37 targethr3 = ((maxhr - resthr) * 0.70) + resthr 38 targethr4 = ((maxhr - resthr) * 0.80) + resthr 39 targethr5 = ((maxhr - resthr) * 0.90) + resthr 40 targethr6 = maxhr 41 else: 42 #if not karvonen method 43 targethr1 = maxhr * 0.50 44 targethr2 = maxhr * 0.60 45 targethr3 = maxhr * 0.70 46 targethr4 = maxhr * 0.80 47 targethr5 = maxhr * 0.90 48 targethr6 = maxhr 49 50 zone1 = (targethr1,targethr2,"#ffff99","Moderate activity") 51 zone2 = (targethr2,targethr3,"#ffcc00","Weight Control") 52 zone3 = (targethr3,targethr4,"#ff9900","Aerobic") 53 zone4 = (targethr4,targethr5,"#ff6600","Anaerobic") 54 zone5 = (targethr5,targethr6,"#ff0000","VO2 MAX") 55 56 zones = [zone5,zone4,zone3,zone2,zone1] 57 26 58 value_selected = -1 27 59 if value_selected < 0: … … 30 62 xvalues, yvalues = self.get_values(values,value_selected) 31 63 xlabel,ylabel,title,color = self.get_value_params(value_selected) 32 self.drawarea.stadistics("plot",[xvalues],[yvalues],[xlabel],[ylabel],[title],[color] )64 self.drawarea.stadistics("plot",[xvalues],[yvalues],[xlabel],[ylabel],[title],[color],zones) 33 65 34 66 def get_value_params(self,value): pytrainer/trunk/pytrainer/profile.py
r160 r169 30 30 self.conf = checkConf() 31 31 self.filename = self.conf.getValue("conffile") 32 self.configuration = XMLParser(self.filename) 32 33 33 34 def isProfileConfigured(self):
