[chronojump] Graph margins customizable



commit 160688dfb276b4e9c8b6ad57d2cfe00ac5a293de
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Sep 7 20:30:54 2009 +0200

    Graph margins customizable

 TODO.txt                          |    2 -
 glade/chronojump.glade            |  351 ++++++++++++++++++++++++++++++++++---
 src/gui/chronojump.cs             |    1 -
 src/gui/stats.cs                  |   30 +++-
 src/stats/graphs/graphROptions.cs |   18 ++-
 src/stats/main.cs                 |    1 +
 6 files changed, 373 insertions(+), 30 deletions(-)
---
diff --git a/TODO.txt b/TODO.txt
index 098a008..6e466f9 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -1,7 +1,5 @@
 TODO: 
 
-do graph margins changeable
-
 continue with titles and subtitles for all graphs
 fix global, jumper, rjEvolution
 
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 9ef7096..60ac5a0 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -5912,29 +5912,6 @@ options</property>
 			      <property name="column_spacing">4</property>
 
 			      <child>
-				<widget class="GtkCheckButton" id="checkbutton_transposed">
-				  <property name="visible">True</property>
-				  <property name="tooltip" translatable="yes">Transpose</property>
-				  <property name="can_focus">True</property>
-				  <property name="label" translatable="yes">T</property>
-				  <property name="use_underline">True</property>
-				  <property name="relief">GTK_RELIEF_NORMAL</property>
-				  <property name="focus_on_click">True</property>
-				  <property name="active">False</property>
-				  <property name="inconsistent">False</property>
-				  <property name="draw_indicator">True</property>
-				</widget>
-				<packing>
-				  <property name="left_attach">7</property>
-				  <property name="right_attach">8</property>
-				  <property name="top_attach">1</property>
-				  <property name="bottom_attach">2</property>
-				  <property name="x_options">fill</property>
-				  <property name="y_options"></property>
-				</packing>
-			      </child>
-
-			      <child>
 				<widget class="GtkHBox" id="hbox_combo_graph_type">
 				  <property name="visible">True</property>
 				  <property name="homogeneous">False</property>
@@ -6294,6 +6271,334 @@ options</property>
 				  <property name="y_options">fill</property>
 				</packing>
 			      </child>
+
+			      <child>
+				<widget class="GtkHBox" id="hbox380">
+				  <property name="visible">True</property>
+				  <property name="homogeneous">False</property>
+				  <property name="spacing">0</property>
+
+				  <child>
+				    <widget class="GtkCheckButton" id="checkbutton_transposed">
+				      <property name="visible">True</property>
+				      <property name="tooltip" translatable="yes">Transpose</property>
+				      <property name="can_focus">True</property>
+				      <property name="label" translatable="yes">T</property>
+				      <property name="use_underline">True</property>
+				      <property name="relief">GTK_RELIEF_NORMAL</property>
+				      <property name="focus_on_click">True</property>
+				      <property name="active">False</property>
+				      <property name="inconsistent">False</property>
+				      <property name="draw_indicator">True</property>
+				    </widget>
+				    <packing>
+				      <property name="padding">0</property>
+				      <property name="expand">False</property>
+				      <property name="fill">False</property>
+				    </packing>
+				  </child>
+
+				  <child>
+				    <widget class="GtkCheckButton" id="checkbutton_margins">
+				      <property name="visible">True</property>
+				      <property name="tooltip" translatable="yes">Show/Hide margins</property>
+				      <property name="can_focus">True</property>
+				      <property name="label" translatable="yes">Margins</property>
+				      <property name="use_underline">True</property>
+				      <property name="relief">GTK_RELIEF_NORMAL</property>
+				      <property name="focus_on_click">True</property>
+				      <property name="active">False</property>
+				      <property name="inconsistent">False</property>
+				      <property name="draw_indicator">True</property>
+				      <signal name="clicked" handler="on_checkbutton_margins_clicked" last_modification_time="Mon, 07 Sep 2009 18:01:55 GMT"/>
+				    </widget>
+				    <packing>
+				      <property name="padding">0</property>
+				      <property name="expand">False</property>
+				      <property name="fill">False</property>
+				    </packing>
+				  </child>
+				</widget>
+				<packing>
+				  <property name="left_attach">7</property>
+				  <property name="right_attach">8</property>
+				  <property name="top_attach">1</property>
+				  <property name="bottom_attach">2</property>
+				  <property name="x_options">fill</property>
+				  <property name="y_options">fill</property>
+				</packing>
+			      </child>
+			    </widget>
+			    <packing>
+			      <property name="padding">0</property>
+			      <property name="expand">False</property>
+			      <property name="fill">False</property>
+			    </packing>
+			  </child>
+			</widget>
+			<packing>
+			  <property name="padding">0</property>
+			  <property name="expand">True</property>
+			  <property name="fill">True</property>
+			</packing>
+		      </child>
+
+		      <child>
+			<widget class="GtkHBox" id="hbox_graph_margins">
+			  <property name="visible">True</property>
+			  <property name="homogeneous">False</property>
+			  <property name="spacing">8</property>
+
+			  <child>
+			    <widget class="GtkHBox" id="hbox383">
+			      <property name="visible">True</property>
+			      <property name="homogeneous">False</property>
+			      <property name="spacing">4</property>
+
+			      <child>
+				<widget class="GtkHBox" id="hbox384">
+				  <property name="visible">True</property>
+				  <property name="homogeneous">False</property>
+				  <property name="spacing">0</property>
+
+				  <child>
+				    <widget class="GtkLabel" id="label777">
+				      <property name="visible">True</property>
+				      <property name="label" translatable="yes">Bottom</property>
+				      <property name="use_underline">False</property>
+				      <property name="use_markup">False</property>
+				      <property name="justify">GTK_JUSTIFY_LEFT</property>
+				      <property name="wrap">False</property>
+				      <property name="selectable">False</property>
+				      <property name="xalign">0.5</property>
+				      <property name="yalign">0.5</property>
+				      <property name="xpad">0</property>
+				      <property name="ypad">0</property>
+				      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+				      <property name="width_chars">-1</property>
+				      <property name="single_line_mode">False</property>
+				      <property name="angle">0</property>
+				    </widget>
+				    <packing>
+				      <property name="padding">0</property>
+				      <property name="expand">False</property>
+				      <property name="fill">False</property>
+				    </packing>
+				  </child>
+
+				  <child>
+				    <widget class="GtkSpinButton" id="spin_graph_margin_b">
+				      <property name="visible">True</property>
+				      <property name="can_focus">True</property>
+				      <property name="climb_rate">1</property>
+				      <property name="digits">0</property>
+				      <property name="numeric">True</property>
+				      <property name="update_policy">GTK_UPDATE_ALWAYS</property>
+				      <property name="snap_to_ticks">True</property>
+				      <property name="wrap">False</property>
+				      <property name="adjustment">5 1 20 1 1 1</property>
+				    </widget>
+				    <packing>
+				      <property name="padding">0</property>
+				      <property name="expand">False</property>
+				      <property name="fill">False</property>
+				    </packing>
+				  </child>
+				</widget>
+				<packing>
+				  <property name="padding">0</property>
+				  <property name="expand">True</property>
+				  <property name="fill">True</property>
+				</packing>
+			      </child>
+
+			      <child>
+				<widget class="GtkHBox" id="hbox385">
+				  <property name="visible">True</property>
+				  <property name="homogeneous">False</property>
+				  <property name="spacing">0</property>
+
+				  <child>
+				    <widget class="GtkLabel" id="label778">
+				      <property name="visible">True</property>
+				      <property name="label" translatable="yes">Left</property>
+				      <property name="use_underline">False</property>
+				      <property name="use_markup">False</property>
+				      <property name="justify">GTK_JUSTIFY_LEFT</property>
+				      <property name="wrap">False</property>
+				      <property name="selectable">False</property>
+				      <property name="xalign">0.5</property>
+				      <property name="yalign">0.5</property>
+				      <property name="xpad">0</property>
+				      <property name="ypad">0</property>
+				      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+				      <property name="width_chars">-1</property>
+				      <property name="single_line_mode">False</property>
+				      <property name="angle">0</property>
+				    </widget>
+				    <packing>
+				      <property name="padding">0</property>
+				      <property name="expand">False</property>
+				      <property name="fill">False</property>
+				    </packing>
+				  </child>
+
+				  <child>
+				    <widget class="GtkSpinButton" id="spin_graph_margin_l">
+				      <property name="visible">True</property>
+				      <property name="can_focus">True</property>
+				      <property name="climb_rate">1</property>
+				      <property name="digits">0</property>
+				      <property name="numeric">True</property>
+				      <property name="update_policy">GTK_UPDATE_ALWAYS</property>
+				      <property name="snap_to_ticks">True</property>
+				      <property name="wrap">False</property>
+				      <property name="adjustment">4 1 20 1 1 1</property>
+				    </widget>
+				    <packing>
+				      <property name="padding">0</property>
+				      <property name="expand">False</property>
+				      <property name="fill">False</property>
+				    </packing>
+				  </child>
+				</widget>
+				<packing>
+				  <property name="padding">0</property>
+				  <property name="expand">True</property>
+				  <property name="fill">True</property>
+				</packing>
+			      </child>
+
+			      <child>
+				<widget class="GtkHBox" id="hbox386">
+				  <property name="visible">True</property>
+				  <property name="homogeneous">False</property>
+				  <property name="spacing">0</property>
+
+				  <child>
+				    <widget class="GtkLabel" id="label779">
+				      <property name="visible">True</property>
+				      <property name="label" translatable="yes">Top</property>
+				      <property name="use_underline">False</property>
+				      <property name="use_markup">False</property>
+				      <property name="justify">GTK_JUSTIFY_LEFT</property>
+				      <property name="wrap">False</property>
+				      <property name="selectable">False</property>
+				      <property name="xalign">0.5</property>
+				      <property name="yalign">0.5</property>
+				      <property name="xpad">0</property>
+				      <property name="ypad">0</property>
+				      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+				      <property name="width_chars">-1</property>
+				      <property name="single_line_mode">False</property>
+				      <property name="angle">0</property>
+				    </widget>
+				    <packing>
+				      <property name="padding">0</property>
+				      <property name="expand">False</property>
+				      <property name="fill">False</property>
+				    </packing>
+				  </child>
+
+				  <child>
+				    <widget class="GtkSpinButton" id="spin_graph_margin_t">
+				      <property name="visible">True</property>
+				      <property name="can_focus">True</property>
+				      <property name="climb_rate">1</property>
+				      <property name="digits">0</property>
+				      <property name="numeric">True</property>
+				      <property name="update_policy">GTK_UPDATE_ALWAYS</property>
+				      <property name="snap_to_ticks">True</property>
+				      <property name="wrap">False</property>
+				      <property name="adjustment">4 1 20 1 1 1</property>
+				    </widget>
+				    <packing>
+				      <property name="padding">0</property>
+				      <property name="expand">False</property>
+				      <property name="fill">False</property>
+				    </packing>
+				  </child>
+				</widget>
+				<packing>
+				  <property name="padding">0</property>
+				  <property name="expand">True</property>
+				  <property name="fill">True</property>
+				</packing>
+			      </child>
+
+			      <child>
+				<widget class="GtkHBox" id="hbox387">
+				  <property name="visible">True</property>
+				  <property name="homogeneous">False</property>
+				  <property name="spacing">0</property>
+
+				  <child>
+				    <widget class="GtkLabel" id="label780">
+				      <property name="visible">True</property>
+				      <property name="label" translatable="yes">Right</property>
+				      <property name="use_underline">False</property>
+				      <property name="use_markup">False</property>
+				      <property name="justify">GTK_JUSTIFY_LEFT</property>
+				      <property name="wrap">False</property>
+				      <property name="selectable">False</property>
+				      <property name="xalign">0.5</property>
+				      <property name="yalign">0.5</property>
+				      <property name="xpad">0</property>
+				      <property name="ypad">0</property>
+				      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+				      <property name="width_chars">-1</property>
+				      <property name="single_line_mode">False</property>
+				      <property name="angle">0</property>
+				    </widget>
+				    <packing>
+				      <property name="padding">0</property>
+				      <property name="expand">False</property>
+				      <property name="fill">False</property>
+				    </packing>
+				  </child>
+
+				  <child>
+				    <widget class="GtkSpinButton" id="spin_graph_margin_r">
+				      <property name="visible">True</property>
+				      <property name="can_focus">True</property>
+				      <property name="climb_rate">1</property>
+				      <property name="digits">0</property>
+				      <property name="numeric">True</property>
+				      <property name="update_policy">GTK_UPDATE_ALWAYS</property>
+				      <property name="snap_to_ticks">True</property>
+				      <property name="wrap">False</property>
+				      <property name="adjustment">2 1 20 1 1 1</property>
+				    </widget>
+				    <packing>
+				      <property name="padding">0</property>
+				      <property name="expand">False</property>
+				      <property name="fill">False</property>
+				    </packing>
+				  </child>
+				</widget>
+				<packing>
+				  <property name="padding">0</property>
+				  <property name="expand">True</property>
+				  <property name="fill">True</property>
+				</packing>
+			      </child>
+			    </widget>
+			    <packing>
+			      <property name="padding">0</property>
+			      <property name="expand">True</property>
+			      <property name="fill">True</property>
+			    </packing>
+			  </child>
+
+			  <child>
+			    <widget class="GtkButton" id="button_graph_margin_default">
+			      <property name="visible">True</property>
+			      <property name="can_focus">True</property>
+			      <property name="label" translatable="yes">Default values</property>
+			      <property name="use_underline">True</property>
+			      <property name="relief">GTK_RELIEF_NORMAL</property>
+			      <property name="focus_on_click">True</property>
+			      <signal name="clicked" handler="on_button_graph_margin_default_clicked" last_modification_time="Mon, 07 Sep 2009 18:01:10 GMT"/>
 			    </widget>
 			    <packing>
 			      <property name="padding">0</property>
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 088aca7..a1bdd8b 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -2306,7 +2306,6 @@ public class ChronoJumpWindow
 	private void on_menuitem_view_stats_activate(object o, EventArgs args) {
 		statsWin = StatsWindow.Show(app1, currentSession, 
 				prefsDigitsNumber, weightPercentPreferred, heightPreferred, 
-				//prefsDigitsNumber, heightPreferred, 
 				report, reportWin);
 		createdStatsWin = true;
 		statsWin.InitializeSession(currentSession);
diff --git a/src/gui/stats.cs b/src/gui/stats.cs
index 175ceaf..95a0a5e 100644
--- a/src/gui/stats.cs
+++ b/src/gui/stats.cs
@@ -92,6 +92,13 @@ public class StatsWindow {
 	[Widget] Gtk.Label label_graph_legend;
 	[Widget] Gtk.Box hbox_combo_graph_legend;
 	[Widget] Gtk.ComboBox combo_graph_legend;
+	
+	[Widget] Gtk.CheckButton checkbutton_margins;
+	[Widget] Gtk.Box hbox_graph_margins;
+	[Widget] Gtk.SpinButton spin_graph_margin_b; //bottom
+	[Widget] Gtk.SpinButton spin_graph_margin_l; //left
+	[Widget] Gtk.SpinButton spin_graph_margin_t; //top
+	[Widget] Gtk.SpinButton spin_graph_margin_r; //right
 
 	int prefsDigitsNumber;
 	bool heightPreferred;
@@ -245,6 +252,7 @@ public class StatsWindow {
 			
 		spinbutton_mark_consecutives.Sensitive = false;
 		hbox_mark_consecutives.Hide();
+		hbox_graph_margins.Hide();
 		
 		//first graph type is boxplot, and it doesn't show transpose also colors are grey...
 		on_combo_graph_type_changed(new object(), new EventArgs());
@@ -415,7 +423,7 @@ public class StatsWindow {
 	}
 	
 	private void showTransposed(bool show) {
-		label_graph_options.Visible = show;
+		//label_graph_options.Visible = show;
 		checkbutton_transposed.Visible = show;
 	}
 
@@ -457,6 +465,20 @@ public class StatsWindow {
 			combo_graph_legend.Visible = true;
 		}
 	}
+	
+	private void on_checkbutton_margins_clicked(object o, EventArgs args) {
+		if(checkbutton_margins.Active)
+			hbox_graph_margins.Visible = true;
+		else
+			hbox_graph_margins.Visible = false;
+	}
+	
+	private void on_button_graph_margin_default_clicked(object o, EventArgs args) {
+		spin_graph_margin_b.Value = 5;
+		spin_graph_margin_l.Value = 4;
+		spin_graph_margin_t.Value = 4;
+		spin_graph_margin_r.Value = 2;
+	}
 
 	private void on_combo_select_checkboxes_changed(object o, EventArgs args) {
 		string myText = UtilGtk.ComboGetActive(combo_select_checkboxes);
@@ -635,7 +657,11 @@ public class StatsWindow {
 				checkbutton_transposed.Active,
 				Convert.ToInt32(UtilGtk.ComboGetActive(combo_graph_width)),
 				Convert.ToInt32(UtilGtk.ComboGetActive(combo_graph_height)),
-				UtilGtk.ComboGetActive(combo_graph_legend)
+				UtilGtk.ComboGetActive(combo_graph_legend),
+				Convert.ToInt32(spin_graph_margin_b.Value), 
+				Convert.ToInt32(spin_graph_margin_l.Value), 
+				Convert.ToInt32(spin_graph_margin_t.Value), 
+				Convert.ToInt32(spin_graph_margin_r.Value) 
 				);
 	}
 
diff --git a/src/stats/graphs/graphROptions.cs b/src/stats/graphs/graphROptions.cs
index 015e561..11b9ec0 100644
--- a/src/stats/graphs/graphROptions.cs
+++ b/src/stats/graphs/graphROptions.cs
@@ -34,9 +34,14 @@ public class GraphROptions
 	public int Width;
 	public int Height;
 	public string Legend;
+	public int MarginBottom;
+	public int MarginLeft;
+	public int MarginTop;
+	public int MarginRight;
 	
 	public GraphROptions(string Type, string VarX, string VarY, string Palette, bool Transposed, 
-			int Width, int Height, string Legend) {
+			int Width, int Height, string Legend,
+			int MarginBottom, int MarginLeft, int MarginTop, int MarginRight) {
 		this.Type = Type;
 		this.VarX = VarX;
 		this.VarY = VarY;
@@ -45,6 +50,10 @@ public class GraphROptions
 		this.Width = Width;
 		this.Height = Height;
 		this.Legend = Legend;
+		this.MarginBottom = MarginBottom;
+		this.MarginLeft = MarginLeft;
+		this.MarginTop = MarginTop;
+		this.MarginRight = MarginRight;
 	}
 	public GraphROptions() {
 	}
@@ -60,9 +69,14 @@ public class GraphROptions
 		this.Width = Convert.ToInt32(strFull[5]);
 		this.Height = Convert.ToInt32(strFull[6]);
 		this.Legend = strFull[7];
+		this.MarginBottom = Convert.ToInt32(strFull[8]);
+		this.MarginLeft = Convert.ToInt32(strFull[9]);
+		this.MarginTop = Convert.ToInt32(strFull[10]);
+		this.MarginRight = Convert.ToInt32(strFull[11]);
 	}
 
 	public override string ToString() {
-		return Type + ":" + VarX + ":" + VarY + ":" + Palette + ":" + Transposed + ":" + Width + ":" + Height + ":" + Legend;
+		return Type + ":" + VarX + ":" + VarY + ":" + Palette + ":" + Transposed + ":" + Width + ":" + Height + ":" + Legend + 
+			":" + MarginBottom + ":" + MarginLeft + ":" + MarginTop + ":" + MarginRight;
 	}
 }	
diff --git a/src/stats/main.cs b/src/stats/main.cs
index f524d72..c0bd5dc 100644
--- a/src/stats/main.cs
+++ b/src/stats/main.cs
@@ -1192,6 +1192,7 @@ public class Stat
 		string rString = "png(filename = '" + fileName + "'\n" + 
 			" , width = " + gRO.Width + ", height = " + gRO.Height + ", units = 'px'\n" +
 			" , pointsize = 12, bg = 'white', res = NA)\n";
+		rString += "par(mar=c(" + gRO.MarginBottom + "," + gRO.MarginLeft + "," + gRO.MarginTop + "," + gRO.MarginRight + "))\n";
 
 		if(gRO.Type == Constants.GraphTypeBoxplot) {
 			if(hasTwoAxis()) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]