From: <jb...@us...> - 2010-04-14 10:59:33
|
Revision: 563 http://pytrainer.svn.sourceforge.net/pytrainer/?rev=563&view=rev Author: jblance Date: 2010-04-14 10:59:25 +0000 (Wed, 14 Apr 2010) Log Message: ----------- Allow Y1 axis customisation - min, max, line color and line weight Modified Paths: -------------- pytrainer/trunk/glade/pytrainer.glade pytrainer/trunk/pytrainer/gui/drawArea.py pytrainer/trunk/pytrainer/gui/windowmain.py pytrainer/trunk/pytrainer/main.py pytrainer/trunk/pytrainer/recordgraph.py Modified: pytrainer/trunk/glade/pytrainer.glade =================================================================== --- pytrainer/trunk/glade/pytrainer.glade 2010-04-14 08:56:33 UTC (rev 562) +++ pytrainer/trunk/glade/pytrainer.glade 2010-04-14 10:59:25 UTC (rev 563) @@ -1188,107 +1188,325 @@ <property name="can_focus">True</property> <property name="position_set">True</property> <child> - <widget class="GtkTable" id="tableConfig"> + <widget class="GtkVBox" id="vboxGraphYConfig"> <property name="visible">True</property> - <property name="n_rows">5</property> - <property name="n_columns">3</property> + <property name="orientation">vertical</property> <child> - <widget class="GtkLabel" id="labelY1Axis"> + <widget class="GtkLabel" id="labelGraphConfig"> <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes"><small>Y Axis</small></property> + <property name="label" translatable="yes"><small>Graph Display Options</small></property> <property name="use_markup">True</property> </widget> <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options"></property> - <property name="y_options"></property> + <property name="expand">False</property> + <property name="position">0</property> </packing> </child> <child> - <widget class="GtkSpinButton" id="spinbuttonY1Min"> + <widget class="GtkFrame" id="frameYAxisLimits"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="invisible_char">●</property> - <property name="width_chars">4</property> - <property name="adjustment">0 -500 1000 1 10 0</property> - <signal name="value_changed" handler="on_spinbuttonY1_value_changed"/> + <property name="label_xalign">0</property> + <child> + <widget class="GtkAlignment" id="alignment3"> + <property name="visible">True</property> + <property name="left_padding">10</property> + <child> + <widget class="GtkTable" id="tableConfig"> + <property name="visible">True</property> + <property name="n_rows">4</property> + <property name="n_columns">3</property> + <child> + <widget class="GtkLabel" id="labelY1AxisLimits"> + <property name="visible">True</property> + <property name="xalign">1</property> + <property name="xpad">1</property> + <property name="label" translatable="yes"><small>Limits</small></property> + <property name="use_markup">True</property> + </widget> + <packing> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="y_options"></property> + </packing> + </child> + <child> + <widget class="GtkLabel" id="labelYMin"> + <property name="visible">True</property> + <property name="label" translatable="yes"><small>Min</small></property> + <property name="use_markup">True</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="y_options"></property> + </packing> + </child> + <child> + <widget class="GtkLabel" id="labelYMax"> + <property name="visible">True</property> + <property name="label" translatable="yes"><small>Max</small></property> + <property name="use_markup">True</property> + </widget> + <packing> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + <property name="y_options"></property> + </packing> + </child> + <child> + <widget class="GtkSpinButton" id="spinbuttonY1Min"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">●</property> + <property name="width_chars">4</property> + <property name="adjustment">0 -500 1000 1 10 0</property> + <signal name="value_changed" handler="on_spinbuttonY1_value_changed"/> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options">GTK_SHRINK</property> + <property name="y_options">GTK_SHRINK</property> + </packing> + </child> + <child> + <widget class="GtkSpinButton" id="spinbuttonY1Max"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">●</property> + <property name="width_chars">4</property> + <property name="adjustment">0 -500 1000 1 10 0</property> + <signal name="value_changed" handler="on_spinbuttonY1_value_changed"/> + </widget> + <packing> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options">GTK_SHRINK</property> + <property name="y_options">GTK_SHRINK</property> + </packing> + </child> + <child> + <widget class="GtkLabel" id="labelY1LineColor"> + <property name="visible">True</property> + <property name="xalign">1</property> + <property name="label" translatable="yes"><small>Line Color</small></property> + <property name="use_markup">True</property> + </widget> + <packing> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="y_options"></property> + </packing> + </child> + <child> + <widget class="GtkColorButton" id="colorbuttonY1LineColor"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="xalign">0</property> + <property name="color">#000000000000</property> + <signal name="color_set" handler="on_colorbuttonY1LineColor_color_set"/> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">3</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="x_options">GTK_SHRINK</property> + <property name="y_options">GTK_SHRINK</property> + </packing> + </child> + <child> + <widget class="GtkLabel" id="labelY1LineWeight"> + <property name="visible">True</property> + <property name="xalign">1</property> + <property name="label" translatable="yes"><small>Line Weight</small></property> + <property name="use_markup">True</property> + </widget> + <packing> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + <property name="y_options"></property> + </packing> + </child> + <child> + <widget class="GtkSpinButton" id="spinbuttonY1LineWeight"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="max_length">2</property> + <property name="invisible_char">●</property> + <property name="adjustment">1 0 10 1 1 0</property> + <signal name="value_changed" handler="on_spinbuttonY1LineWeight_value_changed"/> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">3</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + <property name="x_options">GTK_SHRINK</property> + <property name="y_options">GTK_SHRINK</property> + </packing> + </child> + <child> + <placeholder/> + </child> + </widget> + </child> + </widget> + </child> + <child> + <widget class="GtkLabel" id="labelY1Axis"> + <property name="visible">True</property> + <property name="label" translatable="yes"><small>Y1 Axis</small></property> + <property name="use_markup">True</property> + </widget> + <packing> + <property name="type">label_item</property> + </packing> + </child> </widget> <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">GTK_SHRINK</property> - <property name="y_options">GTK_SHRINK</property> + <property name="position">1</property> </packing> </child> <child> - <widget class="GtkSpinButton" id="spinbuttonY1Max"> + <widget class="GtkFrame" id="frameY2Axis"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="invisible_char">●</property> - <property name="width_chars">4</property> - <property name="adjustment">0 -500 1000 1 10 0</property> - <signal name="value_changed" handler="on_spinbuttonY1_value_changed"/> + <property name="sensitive">False</property> + <property name="label_xalign">0</property> + <child> + <widget class="GtkAlignment" id="alignment5"> + <property name="visible">True</property> + <property name="left_padding">10</property> + <child> + <widget class="GtkTable" id="tableConfig1"> + <property name="visible">True</property> + <property name="n_rows">3</property> + <property name="n_columns">3</property> + <child> + <widget class="GtkLabel" id="labelY1AxisLimits1"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="label" translatable="yes"><small>Limits</small></property> + <property name="use_markup">True</property> + </widget> + <packing> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options"></property> + <property name="y_options"></property> + </packing> + </child> + <child> + <widget class="GtkLabel" id="labelYMin1"> + <property name="visible">True</property> + <property name="label" translatable="yes"><small>Min</small></property> + <property name="use_markup">True</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="y_options"></property> + </packing> + </child> + <child> + <widget class="GtkLabel" id="labelYMax1"> + <property name="visible">True</property> + <property name="label" translatable="yes"><small>Max</small></property> + <property name="use_markup">True</property> + </widget> + <packing> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + <property name="y_options"></property> + </packing> + </child> + <child> + <widget class="GtkSpinButton" id="spinbuttonY1Min2"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">●</property> + <property name="width_chars">4</property> + <property name="adjustment">0 -500 1000 1 10 0</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options">GTK_SHRINK</property> + <property name="y_options">GTK_SHRINK</property> + </packing> + </child> + <child> + <widget class="GtkSpinButton" id="spinbuttonY1Max2"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">●</property> + <property name="width_chars">4</property> + <property name="adjustment">0 -500 1000 1 10 0</property> + </widget> + <packing> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options">GTK_SHRINK</property> + <property name="y_options">GTK_SHRINK</property> + </packing> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + </widget> + </child> + </widget> + </child> + <child> + <widget class="GtkLabel" id="labelY2Axis"> + <property name="visible">True</property> + <property name="label" translatable="yes"><small>Y2 Axis</small></property> + <property name="use_markup">True</property> + </widget> + <packing> + <property name="type">label_item</property> + </packing> + </child> </widget> <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">GTK_SHRINK</property> - <property name="y_options">GTK_SHRINK</property> + <property name="position">2</property> </packing> </child> <child> - <widget class="GtkLabel" id="labelGraphConfig"> - <property name="visible">True</property> - <property name="label" translatable="yes"><small>Graph Display Options</small></property> - <property name="use_markup">True</property> - </widget> - <packing> - <property name="right_attach">3</property> - <property name="y_options"></property> - </packing> - </child> - <child> <widget class="GtkButton" id="buttonResetGraph"> <property name="label" translatable="yes">Reset Graph</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> - <property name="tooltip" translatable="yes">Reset Graph display to original settings</property> + <property name="has_tooltip">True</property> <property name="yalign">1</property> <signal name="clicked" handler="on_buttonResetGraph_clicked"/> </widget> <packing> - <property name="right_attach">3</property> - <property name="top_attach">4</property> - <property name="bottom_attach">5</property> - <property name="x_options"></property> - <property name="y_options">GTK_EXPAND</property> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="pack_type">end</property> + <property name="position">3</property> </packing> </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> </widget> <packing> <property name="resize">False</property> Modified: pytrainer/trunk/pytrainer/gui/drawArea.py =================================================================== --- pytrainer/trunk/pytrainer/gui/drawArea.py 2010-04-14 08:56:33 UTC (rev 562) +++ pytrainer/trunk/pytrainer/gui/drawArea.py 2010-04-14 10:59:25 UTC (rev 563) @@ -273,7 +273,7 @@ logging.debug('<<') - def drawPlot(self,xvalues,yvalues,xlabel,ylabel,title,color,zones=None,xzones=None, ylimits=None): + def drawPlot(self,xvalues,yvalues,xlabel,ylabel,title,color,zones=None,xzones=None, ylimits=None, y1_linewidth=None): logging.debug('>>') logging.debug("Type: plot | title: "+str(title)+" | col: "+str(color)+" | xlabel: "+str(xlabel)+" | ylabel: "+str(ylabel)) logging.debug('xlabel: '+str(xlabel)+' | ylabel: '+str(ylabel)+' | title: '+str(title)) @@ -284,7 +284,10 @@ for value in xvalues: if i<1: axis = figure.add_subplot(111) - axis.plot(xvalues[i],yvalues[i], color=color[i]) + line = axis.plot(xvalues[i],yvalues[i], color=color[i]) + if y1_linewidth is not None: + line[0].set_linewidth(y1_linewidth) + linewidth = line[0].get_linewidth() axis.grid(True) for tl in axis.get_yticklabels(): @@ -334,7 +337,7 @@ logging.debug('Child available: '+str(child)) logging.debug('<<') - return (ylim_min, ylim_max) + return {'y1_min': ylim_min, 'y1_max': ylim_max, 'y1_linewidth': linewidth} def drawPie(self,xvalues,yvalues,xlabel,ylabel,title,color,zones=None): logging.debug('>>') Modified: pytrainer/trunk/pytrainer/gui/windowmain.py =================================================================== --- pytrainer/trunk/pytrainer/gui/windowmain.py 2010-04-14 08:56:33 UTC (rev 562) +++ pytrainer/trunk/pytrainer/gui/windowmain.py 2010-04-14 10:59:25 UTC (rev 563) @@ -55,6 +55,9 @@ self.gpxDir = gpxDir self.record_list = None self.laps = None + self.y1_limits = None + self.y1_color = None + self.y1_linewidth = 1 def new(self): self.testimport = self.pytrainer_main.startup_options.testimport @@ -809,10 +812,10 @@ def createWaypointEditor(self,WaypointEditor,waypoint, parent=None): self.waypointeditor = WaypointEditor(self.data_path, self.waypointvbox,waypoint,parent) - def zoom_graph(self, ylimits=None): + def zoom_graph(self, y1limits=None, y1color=None, y1_linewidth=1): logging.debug(">>") - logging.debug("Reseting graph Y axis with ylimits: %s" % str(ylimits) ) - self.drawarearecord.drawgraph(self.record_list,self.laps, ylimits=ylimits) + logging.debug("Reseting graph Y axis with ylimits: %s" % str(y1limits) ) + self.drawarearecord.drawgraph(self.record_list,self.laps, y1limits=y1limits, y1color=y1color, y1_linewidth=y1_linewidth) logging.debug("<<") ###################### @@ -820,18 +823,34 @@ ###################### def on_spinbuttonY1_value_changed(self, widget): - ymin = self.spinbuttonY1Min.get_value() - ymax = self.spinbuttonY1Max.get_value() + y1min = self.spinbuttonY1Min.get_value() + y1max = self.spinbuttonY1Max.get_value() #Check to see if the min and max have the same... - if ymin == ymax: + if y1min == y1max: if widget.get_name() == "spinbuttonY1Min": #User was changing the min spinbutton, so move max up - ymax += 1 + y1max += 1 else: #Move min down - ymin -= 1 - self.zoom_graph(ylimits=(ymin, ymax)) + y1min -= 1 + self.y1_limits=(y1min, y1max) + self.zoom_graph(y1limits=self.y1_limits, y1color=self.y1_color, y1_linewidth=self.y1_linewidth) def on_buttonResetGraph_clicked(self, widget): + #self.zoom_graph() + #Reset stored values + self.y1_limits = None + self.y1_color = None + self.y1_linewidth = 1 self.zoom_graph() + + def on_colorbuttonY1LineColor_color_set(self, widget): + y1color = widget.get_color() + cs = y1color.to_string() + self.y1_color = cs[0:3] + cs[5:7] + cs[9:11] + self.drawarearecord.drawgraph(self.record_list,self.laps, y1limits=self.y1_limits, y1color=self.y1_color, y1_linewidth=self.y1_linewidth) + + def on_spinbuttonY1LineWeight_value_changed(self, widget): + self.y1_linewidth = self.spinbuttonY1LineWeight.get_value_as_int() + self.drawarearecord.drawgraph(self.record_list,self.laps, y1limits=self.y1_limits, y1color=self.y1_color, y1_linewidth=self.y1_linewidth) def on_edit_clicked(self,widget): selected,iter = self.recordTreeView.get_selection().get_selected() Modified: pytrainer/trunk/pytrainer/main.py =================================================================== --- pytrainer/trunk/pytrainer/main.py 2010-04-14 08:56:33 UTC (rev 562) +++ pytrainer/trunk/pytrainer/main.py 2010-04-14 10:59:25 UTC (rev 563) @@ -59,7 +59,7 @@ class pyTrainer: def __init__(self,filename = None, data_path = None): #Version constants - self.version ="1.7.2_svn#562" + self.version ="1.7.2_svn#563" self.DB_version = 3 #Process command line options self.startup_options = self.get_options() Modified: pytrainer/trunk/pytrainer/recordgraph.py =================================================================== --- pytrainer/trunk/pytrainer/recordgraph.py 2010-04-14 08:56:33 UTC (rev 562) +++ pytrainer/trunk/pytrainer/recordgraph.py 2010-04-14 10:59:25 UTC (rev 563) @@ -30,7 +30,7 @@ self.config_table = tableConfig logging.debug("<<") - def drawgraph(self,values,laps=None, ylimits=None): + def drawgraph(self,values,laps=None, y1limits=None, y1color=None, y1_linewidth=1): logging.debug(">>") #Get the config options for child in self.config_table.get_children(): @@ -38,6 +38,11 @@ spinbuttonY1Max = child elif child.get_name() == "spinbuttonY1Min": spinbuttonY1Min = child + elif child.get_name() == "colorbuttonY1LineColor": + colorbuttonY1LineColor = child + elif child.get_name() == "spinbuttonY1LineWeight": + spinbuttonY1LineWeight = child + xval = [] yval = [] xlab = [] @@ -72,6 +77,11 @@ max_yvalue = max(yvalues) min_yvalue = min(yvalues) xlabel,ylabel,title,color = self.get_value_params(value_selected) + if y1color is not None: + _color = gtk.gdk.Color(y1color) + color = y1color + else: + _color = gtk.gdk.Color(color) xval.append(xvalues) yval.append(yvalues) @@ -83,6 +93,9 @@ tit.append(title) col.append(color) + #_color = gtk.gdk.Color(color) + colorbuttonY1LineColor.set_color(_color) + if value_selected2 > 0: value_selected2 = value_selected2-1 xlabel,ylabel,title,color = self.get_value_params(value_selected2) @@ -97,7 +110,10 @@ col.append(color) logging.info("To show: tit: "+str(tit)+" | col: "+str(col)+" | xlab: "+str(xlab)+" | ylab: "+str(ylab)) #self.drawPlot(xvalues,yvalues,xlabel,ylabel,title,color,zones) - ymin, ymax = self.drawarea.drawPlot(xval,yval,xlab,ylab,tit,col,None,lapValues, ylimits=ylimits) + plot_stats = self.drawarea.drawPlot(xval,yval,xlab,ylab,tit,col,None,lapValues, ylimits=y1limits, y1_linewidth=y1_linewidth) + ymin = plot_stats['y1_min'] + ymax = plot_stats['y1_max'] + y1_linewidth = plot_stats['y1_linewidth'] max_yvalue = max(max_yvalue, ymax) min_yvalue = min(min_yvalue, ymin) @@ -107,6 +123,8 @@ spinbuttonY1Max.set_adjustment(adjY1Max) spinbuttonY1Min.set_value(ymin) spinbuttonY1Max.set_value(ymax) + spinbuttonY1LineWeight.set_value(y1_linewidth) + logging.debug("<<") def get_value_params(self,value): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |