[chronojump] Encoder treeview aligned data
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Encoder treeview aligned data
- Date: Wed, 4 Apr 2012 09:59:28 +0000 (UTC)
commit 70fe1a7d337a0b673fd08cd77040d322e81eefdc
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed Apr 4 16:23:15 2012 +0800
Encoder treeview aligned data
src/constants.cs | 2 +-
src/gui/chronojump.cs | 2 --
src/gui/encoder.cs | 41 +++++++++++++++++++++++------------------
src/utilGtk.cs | 26 ++++++++++++++++++++++++++
4 files changed, 50 insertions(+), 21 deletions(-)
---
diff --git a/src/constants.cs b/src/constants.cs
index 5fa09c2..3167cd1 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -15,7 +15,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * Copyright (C) 2004-2009 Xavier de Blas <xaviblas gmail com>
+ * Copyright (C) 2004-2012 Xavier de Blas <xaviblas gmail com>
*/
using System;
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 52f1fcb..cda6e5c 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -5077,8 +5077,6 @@ Console.WriteLine("X");
}
private void on_repetitive_conditions_closed(object o, EventArgs args) {
- //repetitiveConditionsWin.FakeButtonClose.Clicked += new EventHandler
- Log.WriteLine("UPDATING ENCODER TV");
EncoderUpdateThings(false);
}
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index de17964..4fa1f27 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -61,6 +61,8 @@ public partial class ChronoJumpWindow
private string encoderAnalysis="powerBars";
+ //TODO: add encoder info of wade on about
+ //TODO: improve message if chronopic is not connected
//TODO: campanes a l'encoder pq mostri colors i sons en funcio del que passa. Falten els sons des de python
//TODO: store encoder data: auto save, and show on a treeview. Put button to delete current (or should be called "last")
@@ -68,9 +70,6 @@ public partial class ChronoJumpWindow
//TODO: put chronopic detection in a generic place. Done But:
//TODO: solve the problem of connecting two different chronopics
-
-
- //TODO: improve formatting of data.ataany column show same number of digits at left of dec point
//TODO: in ec, curves and powerBars have to be different on ec than on c
//TODO: smaller zoom button on analysis
@@ -358,31 +357,39 @@ public partial class ChronoJumpWindow
private void RenderN (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
{
EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
- (cell as Gtk.CellRendererText).Text = curve.N;
+ (cell as Gtk.CellRendererText).Text =
+ String.Format(UtilGtk.TVNumPrint(curve.N,1,0),Convert.ToInt32(curve.N));
}
private void RenderWidth (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
{
EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
- (cell as Gtk.CellRendererText).Text = curve.Width;
+ (cell as Gtk.CellRendererText).Text =
+ String.Format(UtilGtk.TVNumPrint(curve.Width,8,1),Convert.ToDouble(curve.Width));
}
private void RenderHeight (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
{
EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
- (cell as Gtk.CellRendererText).Text = (Convert.ToDouble(curve.Height)/10).ToString(); //mm -> cm
+ string heightToCm = (Convert.ToDouble(curve.Height)/10).ToString();
+ (cell as Gtk.CellRendererText).Text =
+ String.Format(UtilGtk.TVNumPrint(heightToCm,8,1),Convert.ToDouble(heightToCm));
}
private void RenderMeanSpeed (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
{
EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
- (cell as Gtk.CellRendererText).Text = curve.MeanSpeed;
+ //no need of UtilGtk.TVNumPrint, always has 1 digit on left of decimal
+ (cell as Gtk.CellRendererText).Text =
+ String.Format("{0,12:0.000}",Convert.ToDouble(curve.MeanSpeed));
}
private void RenderMaxSpeed (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
{
EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
- (cell as Gtk.CellRendererText).Text = curve.MaxSpeed;
+ //no need of UtilGtk.TVNumPrint, always has 1 digit on left of decimal
+ (cell as Gtk.CellRendererText).Text =
+ String.Format("{0,12:0.000}",Convert.ToDouble(curve.MaxSpeed));
}
-
+
private void RenderMeanPower (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
{
EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
@@ -392,7 +399,9 @@ public partial class ChronoJumpWindow
repetitiveConditionsWin.EncoderPowerLower,
repetitiveConditionsWin.EncoderPowerHigherValue,
repetitiveConditionsWin.EncoderPowerLowerValue);
- (cell as Gtk.CellRendererText).Text = curve.MeanPower;
+
+ (cell as Gtk.CellRendererText).Text =
+ String.Format(UtilGtk.TVNumPrint(curve.MeanPower,9,3),Convert.ToDouble(curve.MeanPower));
}
private void RenderPeakPower (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
@@ -404,19 +413,15 @@ public partial class ChronoJumpWindow
repetitiveConditionsWin.EncoderPeakPowerLower,
repetitiveConditionsWin.EncoderPeakPowerHigherValue,
repetitiveConditionsWin.EncoderPeakPowerLowerValue);
- (cell as Gtk.CellRendererText).Text = curve.PeakPower;
+ (cell as Gtk.CellRendererText).Text =
+ String.Format(UtilGtk.TVNumPrint(curve.PeakPower,9,3),Convert.ToDouble(curve.PeakPower));
}
private void RenderPeakPowerT (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
{
EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
- /*
- if (Convert.ToDouble(curve.PeakPowerT) <= 100)
- (cell as Gtk.CellRendererText).Foreground = colorGood;
- else
- (cell as Gtk.CellRendererText).Foreground = colorBad;
- */
- (cell as Gtk.CellRendererText).Text = curve.PeakPowerT;
+ (cell as Gtk.CellRendererText).Text =
+ String.Format(UtilGtk.TVNumPrint(curve.PeakPowerT,8,0),Convert.ToInt32(curve.PeakPowerT));
}
/* end of rendering cols */
diff --git a/src/utilGtk.cs b/src/utilGtk.cs
index 4197567..19de071 100644
--- a/src/utilGtk.cs
+++ b/src/utilGtk.cs
@@ -240,4 +240,30 @@ public class UtilGtk
return tb;
}
+ //Done because align to the right on TreeView is not working
+ public static string TVNumPrint (string num, int start, int dec) {
+ string decS="}";
+ if(dec==1)
+ decS = ".0}";
+ else if(dec==2)
+ decS = ".00}";
+ else if(dec==3)
+ decS = ".000}";
+
+ int inc;
+ if(Convert.ToDouble(num) >= 10000)
+ inc = 0;
+ else if(Convert.ToDouble(num) >= 1000)
+ inc = 1;
+ else if(Convert.ToDouble(num) >= 100)
+ inc = 2;
+ else if(Convert.ToDouble(num) >= 10)
+ inc = 3;
+ else
+ inc = 4;
+
+ return "{0," + (start + inc).ToString() + ":0" + decS;
+ }
+
+
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]