[chronojump] neuromuscular data to treeview



commit 113bf1ded7478db903627965600d364ab60e19dc
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Mar 25 01:21:58 2014 +0100

    neuromuscular data to treeview

 po/POTFILES.in              |    1 +
 src/Makefile.am             |    1 +
 src/encoder.cs              |  103 +++++-
 src/gui/encoder.cs          |  639 +-----------------------------
 src/gui/encoderTreeviews.cs |  915 +++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 1034 insertions(+), 625 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 861b008..cced056 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -24,6 +24,7 @@ src/gui/chronojump.cs
 src/gui/chronopic.cs
 src/gui/convertWeight.cs
 src/gui/encoder.cs
+src/gui/encoderTreeviews.cs
 src/gui/evaluator.cs
 src/gui/event.cs
 src/gui/eventExecute.cs
diff --git a/src/Makefile.am b/src/Makefile.am
index 2ff1c54..2798e80 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -9,6 +9,7 @@ SOURCES = \
        gui/chronopic.cs\
        gui/confirm.cs\
        gui/encoder.cs\
+       gui/encoderTreeviews.cs\
        gui/encoderConfiguration.cs\
        gui/error.cs\
        gui/eventExecute.cs\
diff --git a/src/encoder.cs b/src/encoder.cs
index e15053f..9d77f3d 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -191,7 +191,7 @@ public class EncoderStruct
        ~EncoderStruct() {}
 }
 
-//used on TreeView
+//used on TreeViews capture and analyze
 public class EncoderCurve
 {
        public EncoderCurve () {
@@ -270,6 +270,107 @@ public class EncoderCurve
        public string PP_PPT;
 }
 
+//used on TreeView
+public class EncoderNeuromuscularData
+{
+       public string n; //?
+       public int e1_range;
+       public int e1_t;
+       public double e1_fmax;
+       public double e1_rfd_avg;
+       public double e1_i;
+
+       public int ca_range;
+       public int cl_t;
+       public double cl_rfd_avg;
+       public double cl_i;
+
+       public double cl_f_avg;
+       public double cl_vf;
+       public double cl_f_max;
+
+       public double cl_s_avg;
+       public double cl_s_max;
+       public double cl_p_avg;
+       public double cl_p_max;
+
+       public int e2f_t;
+       public double e2f_f_max;
+       public int e2f_f_max_t;
+       public double e2f_rfd_max;
+
+       public EncoderNeuromuscularData () {
+       }
+
+       //used on TreeView analyze
+       public EncoderNeuromuscularData (
+                       string n, //?
+                       int e1_range, int e1_t, double e1_fmax, double e1_rfd_avg, double e1_i,
+                       int ca_range, int cl_t, double cl_rfd_avg, double cl_i, 
+                       double cl_f_avg, double cl_vf, double cl_f_max, 
+                       double cl_s_avg, double cl_s_max, double cl_p_avg, double cl_p_max, 
+                       int e2f_t, double e2f_f_max, int e2f_f_max_t, double e2f_rfd_max
+                       )
+       {
+               this.n = n; //?
+               this.e1_range = e1_range; 
+               this.e1_t = e1_t;
+               this.e1_fmax = e1_fmax;
+               this.e1_rfd_avg = e1_rfd_avg;
+               this.e1_i = e1_i;
+               this.ca_range = ca_range;
+               this.cl_t = cl_t;
+               this.cl_rfd_avg = cl_rfd_avg;
+               this.cl_i = cl_i;
+               this.cl_f_avg = cl_f_avg;
+               this.cl_vf = cl_vf;
+               this.cl_f_max = cl_f_max;
+               this.cl_s_avg = cl_s_avg;
+               this.cl_s_max = cl_s_max;
+               this.cl_p_avg = cl_p_avg;
+               this.cl_p_max = cl_p_max;
+               this.e2f_t = e2f_t;
+               this.e2f_f_max = e2f_f_max;
+               this.e2f_f_max_t = e2f_f_max_t;
+               this.e2f_rfd_max = e2f_rfd_max;
+       }
+
+       //reading contents file from graph.R
+       public EncoderNeuromuscularData (string [] cells)
+       {
+               //cell[0] is not converted because is string
+               for(int i = 1 ; i < cells.Length ;  i ++)
+                       cells[i] = 
Util.TrimDecimals(Convert.ToDouble(Util.ChangeDecimalSeparator(cells[i])),3);
+       
+               this.n = cells[0]; //?
+               this.e1_range   = Convert.ToInt32(cells[1]); 
+               this.e1_t       = Convert.ToInt32(cells[2]);
+               this.e1_fmax    = Convert.ToDouble(cells[3]);
+               this.e1_rfd_avg = Convert.ToDouble(cells[4]);
+               this.e1_i       = Convert.ToDouble(cells[5]);
+               this.ca_range   = Convert.ToInt32(cells[6]);
+               this.cl_t       = Convert.ToInt32(cells[7]);
+               this.cl_rfd_avg = Convert.ToDouble(cells[8]);
+               this.cl_i       = Convert.ToDouble(cells[9]);
+               this.cl_f_avg   = Convert.ToDouble(cells[10]);
+               this.cl_vf      = Convert.ToDouble(cells[11]);
+               this.cl_f_max   = Convert.ToDouble(cells[12]);
+               this.cl_s_avg   = Convert.ToDouble(cells[13]);
+               this.cl_s_max   = Convert.ToDouble(cells[14]);
+               this.cl_p_avg   = Convert.ToDouble(cells[15]);
+               this.cl_p_max   = Convert.ToDouble(cells[16]);
+               this.e2f_t      = Convert.ToInt32(cells[17]);
+               this.e2f_f_max  = Convert.ToDouble(cells[18]);
+               this.e2f_f_max_t = Convert.ToInt32(cells[19]);
+               this.e2f_rfd_max = Convert.ToDouble(cells[20]);
+       }
+
+       //TODO:
+       public string ToCSV() {
+               return "";
+       }
+}
+
 public class EncoderSQL
 {
        public string uniqueID;
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 02785b1..fa0da33 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -130,7 +130,7 @@ public partial class ChronoJumpWindow
 
        ArrayList encoderCaptureCurves;
         Gtk.ListStore encoderCaptureListStore;
-       Gtk.ListStore encoderAnalyzeListStore;
+       Gtk.ListStore encoderAnalyzeListStore; //can be EncoderCurves or EncoderNeuromuscularData
 
        Thread encoderThread;
        
@@ -606,13 +606,16 @@ public partial class ChronoJumpWindow
                encoderCaptureListStore = new Gtk.ListStore (typeof (EncoderCurve));
        }
 
-       private void treeviewEncoderAnalyzeRemoveColumns() {
+       private void treeviewEncoderAnalyzeRemoveColumns(bool curveOrNeuromuscular) {
                Gtk.TreeViewColumn [] myColumns = treeview_encoder_analyze_curves.Columns;
                foreach (Gtk.TreeViewColumn column in myColumns) 
                        treeview_encoder_analyze_curves.RemoveColumn (column);
 
                //blank the encoderAnalyzeListStore
-               encoderAnalyzeListStore = new Gtk.ListStore (typeof (EncoderCurve));
+               if(curveOrNeuromuscular)
+                       encoderAnalyzeListStore = new Gtk.ListStore (typeof (EncoderCurve));
+               else
+                       encoderAnalyzeListStore = new Gtk.ListStore (typeof (EncoderNeuromuscularData));
        }
 
 
@@ -3157,621 +3160,6 @@ Log.WriteLine(str);
        }
 
 
-       /* TreeView stuff */    
-
-       //returns curves num
-       //capture has single and multiple selection in order to save curves... Analyze only shows data.
-       private int createTreeViewEncoderCapture(string contents) {
-               bool showStartAndDuration = encoderCaptureOptionsWin.check_show_start_and_duration.Active;
-
-               string [] columnsString = {
-                       Catalog.GetString("Curve") + "\n",
-                       Catalog.GetString("Start") + "\n (s)",
-                       Catalog.GetString("Duration") + "\n (s)",
-                       Catalog.GetString("Range") + "\n (cm)",
-                       Catalog.GetString("MeanSpeed") + "\n (m/s)",
-                       Catalog.GetString("MaxSpeed") + "\n (m/s)",
-                       Catalog.GetString("MaxSpeedTime") + "\n (s)",
-                       Catalog.GetString("MeanPower") + "\n (W)",
-                       Catalog.GetString("PeakPower") + "\n (W)",
-                       Catalog.GetString("PeakPowerTime") + "\n (s)",
-                       Catalog.GetString("PeakPower/PPT") + "\n (W/s)"
-               };
-
-               encoderCaptureCurves = new ArrayList ();
-
-               string line;
-               int curvesCount = 0;
-               using (StringReader reader = new StringReader (contents)) {
-                       line = reader.ReadLine ();      //headers
-                       Log.WriteLine(line);
-                       do {
-                               line = reader.ReadLine ();
-                               Log.WriteLine(line);
-                               if (line == null)
-                                       break;
-
-                               curvesCount ++;
-
-                               string [] cells = line.Split(new char[] {','});
-                               cells = fixDecimals(cells);
-
-                               encoderCaptureCurves.Add (new EncoderCurve (
-                                                       cells[0],       //id 
-                                                       //cells[1],     //seriesName
-                                                       //cells[2],     //exerciseName
-                                                       //cells[3],     //massBody
-                                                       //cells[4],     //massExtra
-                                                       cells[5], cells[6], cells[7], 
-                                                       cells[8], cells[9], cells[10], 
-                                                       cells[11], cells[12], cells[13],
-                                                       cells[14]
-                                                       ));
-
-                       } while(true);
-               }
-
-               encoderCaptureListStore = new Gtk.ListStore (typeof (EncoderCurve));
-               foreach (EncoderCurve curve in encoderCaptureCurves) 
-                       encoderCaptureListStore.AppendValues (curve);
-
-               treeview_encoder_capture_curves.Model = encoderCaptureListStore;
-
-               if(ecconLast == "c")
-                       treeview_encoder_capture_curves.Selection.Mode = SelectionMode.Single;
-               else
-                       treeview_encoder_capture_curves.Selection.Mode = SelectionMode.Multiple;
-
-               treeview_encoder_capture_curves.HeadersVisible=true;
-
-               int i=0;
-               foreach(string myCol in columnsString) {
-                       Gtk.TreeViewColumn aColumn = new Gtk.TreeViewColumn ();
-                       CellRendererText aCell = new CellRendererText();
-                       aColumn.Title=myCol;
-                       aColumn.PackStart (aCell, true);
-
-                       //crt1.Foreground = "red";
-                       //crt1.Background = "blue";
-               
-                       switch(i){      
-                               case 0:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc (RenderN));
-                                       break;
-                               case 1:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderStart));
-                                       break;
-                               case 2:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderDuration));
-                                       break;
-                               case 3:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderHeight));
-                                       break;
-                               case 4:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMeanSpeed));
-                                       break;
-                               case 5:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMaxSpeed));
-                                       break;
-                               case 6:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMaxSpeedT));
-                                       break;
-                               case 7:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMeanPower));
-                                       break;
-                               case 8:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderPeakPower));
-                                       break;
-                               case 9:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderPeakPowerT));
-                                       break;
-                               case 10:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderPP_PPT));
-                                       break;
-                       }
-                                       
-                       if( ! ( (i == 1 || i == 2) && ! showStartAndDuration ) )
-                               treeview_encoder_capture_curves.AppendColumn (aColumn);
-                       i++;
-               }
-               return curvesCount;
-       }
-
-       string [] treeviewEncoderAnalyzeHeaders = {
-                       Catalog.GetString("Curve") + "\n",
-                       Catalog.GetString("Series") + "\n",
-                       Catalog.GetString("Exercise") + "\n",
-                       Catalog.GetString("Extra weight") + "\n (Kg)",
-                       Catalog.GetString("Displaced weight") + "\n (Kg)",
-                       Catalog.GetString("Start") + "\n (s)",
-                       Catalog.GetString("Duration") + "\n (s)",
-                       Catalog.GetString("Range") + "\n (cm)",
-                       Catalog.GetString("MeanSpeed") + "\n (m/s)",
-                       Catalog.GetString("MaxSpeed") + "\n (m/s)",
-                       Catalog.GetString("MaxSpeedTime") + "\n (s)",
-                       Catalog.GetString("MeanPower") + "\n (W)",
-                       Catalog.GetString("PeakPower") + "\n (W)",
-                       Catalog.GetString("PeakPowerTime") + "\n (s)",
-                       Catalog.GetString("PeakPower/PPT") + "\n (W/s)"
-               };
-
-       private int createTreeViewEncoderAnalyze(string contents) {
-               string [] columnsString = treeviewEncoderAnalyzeHeaders;
-
-               ArrayList encoderAnalyzeCurves = new ArrayList ();
-
-               //write exercise and extra weight data
-               ArrayList curvesData = new ArrayList();
-               string exerciseName = "";
-               double displacedMass = 0; 
-               if(radiobutton_encoder_analyze_data_user_curves.Active) {
-                       curvesData = SqliteEncoder.Select(
-                                       false, -1, currentPerson.UniqueID, currentSession.UniqueID, "curve", 
true);
-               } else {        //current signal
-                       exerciseName = UtilGtk.ComboGetActive(combo_encoder_exercise);
-                       displacedMass = findMass(Constants.MassType.DISPLACED);
-               }
-
-               string line;
-               int curvesCount = 0;
-               using (StringReader reader = new StringReader (contents)) {
-                       line = reader.ReadLine ();      //headers
-                       Log.WriteLine(line);
-                       do {
-                               line = reader.ReadLine ();
-                               Log.WriteLine(line);
-                               if (line == null)
-                                       break;
-
-                               curvesCount ++;
-
-                               string [] cells = line.Split(new char[] {','});
-                               cells = fixDecimals(cells);
-                               
-                               
-                               if(radiobutton_encoder_analyze_data_user_curves.Active) {
-                                       /*
-                                       EncoderSQL eSQL = (EncoderSQL) curvesData[curvesCount];
-                                       exerciseName = eSQL.exerciseName;
-                                       displacedMass = eSQL.extraWeight;
-                                       */
-                                       exerciseName = cells[2];
-                                       displacedMass = Convert.ToDouble(cells[4]);
-                               }
-
-                               encoderAnalyzeCurves.Add (new EncoderCurve (
-                                                       cells[0], 
-                                                       cells[1],       //seriesName 
-                                                       exerciseName,
-                                                       massWithoutPerson(displacedMass, exerciseName),
-                                                       displacedMass,
-                                                       cells[5], cells[6], cells[7], 
-                                                       cells[8], cells[9], cells[10], 
-                                                       cells[11], cells[12], cells[13],
-                                                       cells[14]
-                                                       ));
-
-                       } while(true);
-               }
-
-               encoderAnalyzeListStore = new Gtk.ListStore (typeof (EncoderCurve));
-               foreach (EncoderCurve curve in encoderAnalyzeCurves) 
-                       encoderAnalyzeListStore.AppendValues (curve);
-
-               treeview_encoder_analyze_curves.Model = encoderAnalyzeListStore;
-
-               treeview_encoder_analyze_curves.Selection.Mode = SelectionMode.None;
-
-               treeview_encoder_analyze_curves.HeadersVisible=true;
-
-               int i=0;
-               foreach(string myCol in columnsString) {
-                       Gtk.TreeViewColumn aColumn = new Gtk.TreeViewColumn ();
-                       CellRendererText aCell = new CellRendererText();
-                       aColumn.Title=myCol;
-                       aColumn.PackStart (aCell, true);
-
-                       //crt1.Foreground = "red";
-                       //crt1.Background = "blue";
-               
-               
-                       switch(i){      
-                               case 0:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderNAnalyze));
-                                       break;
-                               case 1:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderSeries));
-                                       break;
-                               case 2:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderExercise));
-                                       break;
-                               case 3:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderExtraWeight));
-                                       break;
-                               case 4:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderDisplacedWeight));
-                                       break;
-                               case 5:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderStart));
-                                       break;
-                               case 6:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderDuration));
-                                       break;
-                               case 7:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderHeight));
-                                       break;
-                               case 8:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMeanSpeed));
-                                       break;
-                               case 9:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMaxSpeed));
-                                       break;
-                               case 10:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMaxSpeedT));
-                                       break;
-                               case 11:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMeanPower));
-                                       break;
-                               case 12:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderPeakPower));
-                                       break;
-                               case 13:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderPeakPowerT));
-                                       break;
-                               case 14:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderPP_PPT));
-                                       break;
-                       }
-                       
-                       treeview_encoder_analyze_curves.AppendColumn (aColumn);
-                       i++;
-               }
-               return curvesCount;
-       }
-
-       /* rendering columns */
-       private string assignColor(double found, bool higherActive, bool lowerActive, double higherValue, 
double lowerValue) 
-       {
-               //more at System.Drawing.Color (Monodoc)
-               string colorGood= "ForestGreen"; 
-               string colorBad= "red";
-               string colorNothing= "";        
-               //colorNothing will use default color on system, previous I used black,
-               //but if the color of the users theme is not 000000, then it looked too different
-
-               if(higherActive && found >= higherValue)
-                       return colorGood;
-               else if(lowerActive && found <= lowerValue)
-                       return colorBad;
-               else
-                       return colorNothing;
-       }
-
-       private string assignColor(double found, bool higherActive, bool lowerActive, int higherValue, int 
lowerValue) 
-       {
-               return assignColor(found, higherActive, lowerActive, 
-                               Convert.ToDouble(higherValue), Convert.ToDouble(lowerValue));
-       }
-
-       private void RenderN (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
-       {
-               //do this in order to have ecconLast useful for RenderN when capturing
-               if(capturingCsharp == encoderCaptureProcess.CAPTURING)
-                       ecconLast = findEccon(false);
-
-               EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
-               if(ecconLast == "c")
-                       (cell as Gtk.CellRendererText).Text = 
-                               String.Format(UtilGtk.TVNumPrint(curve.N,1,0),Convert.ToInt32(curve.N));
-               else if (ecconLast=="ec" || ecconLast =="ecS") {
-                       string phase = "e";
-                       bool isEven = Util.IsEven(Convert.ToInt32(curve.N));
-                       if(isEven)
-                               phase = "c";
-                               
-                       (cell as Gtk.CellRendererText).Text = 
-                               decimal.Truncate((Convert.ToInt32(curve.N) +1) /2).ToString() + phase;
-               } else {        //(ecconLast=="ce" || ecconLast =="ceS") {
-                       string phase = "c";
-                       bool isEven = Util.IsEven(Convert.ToInt32(curve.N));
-                       if(isEven)
-                               phase = "e";
-                               
-                       (cell as Gtk.CellRendererText).Text = 
-                               decimal.Truncate((Convert.ToInt32(curve.N) +1) /2).ToString() + phase;
-               }
-       }
-       //from analyze, don't checks ecconLast
-       private void RenderNAnalyze (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
-       {
-               EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
-               
-               if(radiobutton_encoder_analyze_data_current_signal.Active && findEccon(false) == "ecS") 
-               {
-                       string phase = "e";
-                       bool isEven = Util.IsEven(Convert.ToInt32(curve.N));
-                       if(isEven)
-                               phase = "c";
-
-                       (cell as Gtk.CellRendererText).Text = 
-                               decimal.Truncate((Convert.ToInt32(curve.N) +1) /2).ToString() + phase;
-               }
-               else if(radiobutton_encoder_analyze_data_current_signal.Active && findEccon(false) == "ceS") 
-               {
-                       string phase = "c";
-                       bool isEven = Util.IsEven(Convert.ToInt32(curve.N));
-                       if(isEven)
-                               phase = "e";
-
-                       (cell as Gtk.CellRendererText).Text = 
-                               decimal.Truncate((Convert.ToInt32(curve.N) +1) /2).ToString() + phase;
-               } else
-                       (cell as Gtk.CellRendererText).Text = curve.N;
-       }
-
-       private void RenderSeries (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.Series;
-       }
-
-       private void RenderExercise (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.Exercise;
-       }
-
-       private void RenderExtraWeight (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel 
model, Gtk.TreeIter iter)
-       {
-               EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
-               (cell as Gtk.CellRendererText).Text = 
-                       
String.Format(UtilGtk.TVNumPrint(curve.ExtraWeight.ToString(),3,0),Convert.ToInt32(curve.ExtraWeight));
-       }
-
-       private void RenderDisplacedWeight (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel 
model, Gtk.TreeIter iter)
-       {
-               EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
-               (cell as Gtk.CellRendererText).Text = 
-                       
String.Format(UtilGtk.TVNumPrint(curve.DisplacedWeight.ToString(),3,0),Convert.ToInt32(curve.DisplacedWeight));
-       }
-
-       private void RenderStart (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
-       {
-               EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
-               double myStart = Convert.ToDouble(curve.Start)/1000; //ms->s
-               (cell as Gtk.CellRendererText).Text = 
-                       String.Format(UtilGtk.TVNumPrint(myStart.ToString(),6,3),myStart); 
-       }
-       
-       private void RenderDuration (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
-       {
-               EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
-               double myDuration = Convert.ToDouble(curve.Duration)/1000; //ms->s
-               (cell as Gtk.CellRendererText).Text = 
-                       String.Format(UtilGtk.TVNumPrint(myDuration.ToString(),5,3),myDuration); 
-       }
-       
-       private void RenderHeight (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
-       {
-               EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
-               string heightToCm = (Convert.ToDouble(curve.Height)/10).ToString();
-               string myColor = assignColor(
-                               Convert.ToDouble(heightToCm),
-                               repetitiveConditionsWin.EncoderHeightHigher, 
-                               repetitiveConditionsWin.EncoderHeightLower, 
-                               repetitiveConditionsWin.EncoderHeightHigherValue,
-                               repetitiveConditionsWin.EncoderHeightLowerValue);
-               if(myColor != "")
-                       (cell as Gtk.CellRendererText).Foreground = myColor;
-               else
-                       (cell as Gtk.CellRendererText).Foreground = null;       //will show default color
-
-               (cell as Gtk.CellRendererText).Text = 
-                       String.Format(UtilGtk.TVNumPrint(heightToCm,5,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);
-               string myColor = assignColor(
-                               Convert.ToDouble(curve.MeanSpeed),
-                               repetitiveConditionsWin.EncoderMeanSpeedHigher, 
-                               repetitiveConditionsWin.EncoderMeanSpeedLower, 
-                               repetitiveConditionsWin.EncoderMeanSpeedHigherValue,
-                               repetitiveConditionsWin.EncoderMeanSpeedLowerValue);
-               if(myColor != "")
-                       (cell as Gtk.CellRendererText).Foreground = myColor;
-               else
-                       (cell as Gtk.CellRendererText).Foreground = null;       //will show default color
-
-               //no need of UtilGtk.TVNumPrint, always has 1 digit on left of decimal
-               (cell as Gtk.CellRendererText).Text = 
-                       String.Format("{0,10: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);
-               string myColor = assignColor(
-                               Convert.ToDouble(curve.MaxSpeed),
-                               repetitiveConditionsWin.EncoderMaxSpeedHigher, 
-                               repetitiveConditionsWin.EncoderMaxSpeedLower, 
-                               repetitiveConditionsWin.EncoderMaxSpeedHigherValue,
-                               repetitiveConditionsWin.EncoderMaxSpeedLowerValue);
-               if(myColor != "")
-                       (cell as Gtk.CellRendererText).Foreground = myColor;
-               else
-                       (cell as Gtk.CellRendererText).Foreground = null;       //will show default color
-
-               //no need of UtilGtk.TVNumPrint, always has 1 digit on left of decimal
-               (cell as Gtk.CellRendererText).Text = 
-                       String.Format("{0,10:0.000}",Convert.ToDouble(curve.MaxSpeed));
-       }
-       
-       private void RenderMaxSpeedT (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
-       {
-               EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
-               double time = Convert.ToDouble(curve.MaxSpeedT)/1000; //ms->s
-               (cell as Gtk.CellRendererText).Text = 
-                       String.Format(UtilGtk.TVNumPrint(time.ToString(),7,3),time);
-       }
-
-       private void RenderMeanPower (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
-       {
-               EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
-               string myColor = assignColor(
-                               Convert.ToDouble(curve.MeanPower),
-                               repetitiveConditionsWin.EncoderPowerHigher, 
-                               repetitiveConditionsWin.EncoderPowerLower, 
-                               repetitiveConditionsWin.EncoderPowerHigherValue,
-                               repetitiveConditionsWin.EncoderPowerLowerValue);
-               if(myColor != "")
-                       (cell as Gtk.CellRendererText).Foreground = myColor;
-               else
-                       (cell as Gtk.CellRendererText).Foreground = null;       //will show default color
-
-               (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)
-       {
-               EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
-               string myColor = assignColor(
-                               Convert.ToDouble(curve.PeakPower),
-                               repetitiveConditionsWin.EncoderPeakPowerHigher, 
-                               repetitiveConditionsWin.EncoderPeakPowerLower, 
-                               repetitiveConditionsWin.EncoderPeakPowerHigherValue,
-                               repetitiveConditionsWin.EncoderPeakPowerLowerValue);
-               if(myColor != "")
-                       (cell as Gtk.CellRendererText).Foreground = myColor;
-               else
-                       (cell as Gtk.CellRendererText).Foreground = null;       //will show default color
-
-               (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);
-               double myPPT = Convert.ToDouble(curve.PeakPowerT)/1000; //ms->s
-               (cell as Gtk.CellRendererText).Text = 
-                       String.Format(UtilGtk.TVNumPrint(myPPT.ToString(),7,3),myPPT);
-       }
-
-       private void RenderPP_PPT (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
-       {
-               EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
-               (cell as Gtk.CellRendererText).Text = 
-                       String.Format(UtilGtk.TVNumPrint(curve.PP_PPT,6,1),Convert.ToDouble(curve.PP_PPT));
-       }
-
-       /* end of rendering cols */
-       
-       
-       private string [] fixDecimals(string [] cells) {
-               //start, width, height
-               for(int i=5; i <= 7; i++)
-                       cells[i] = 
Util.TrimDecimals(Convert.ToDouble(Util.ChangeDecimalSeparator(cells[i])),1);
-               
-               //meanSpeed,maxSpeed,maxSpeedT, meanPower,peakPower,peakPowerT
-               for(int i=8; i <= 13; i++)
-                       cells[i] = 
Util.TrimDecimals(Convert.ToDouble(Util.ChangeDecimalSeparator(cells[i])),3);
-               
-               //pp/ppt
-               int pp_ppt = 14;
-               cells[pp_ppt] = 
Util.TrimDecimals(Convert.ToDouble(Util.ChangeDecimalSeparator(cells[pp_ppt])),1); 
-               return cells;
-       }
-       
-       //the bool is for ecc-concentric
-       //there two rows are selected
-       //if user clicks on 2n row, and bool is true, first row is the returned curve
-       private EncoderCurve treeviewEncoderCaptureCurvesGetCurve(int row, bool onEccConTakeFirst) 
-       {
-               if(onEccConTakeFirst && ecconLast != "c") {
-                       bool isEven = (row % 2 == 0); //check if it's even (in spanish "par")
-                       if(isEven)
-                               row --;
-               }
-
-               TreeIter iter = new TreeIter();
-               bool iterOk = encoderCaptureListStore.GetIterFirst(out iter);
-               if(iterOk) {
-                       int count=1;
-                       do {
-                               if(count==row) 
-                                       return (EncoderCurve) treeview_encoder_capture_curves.Model.GetValue 
(iter, 0);
-                               count ++;
-                       } while (encoderCaptureListStore.IterNext (ref iter));
-               }
-               EncoderCurve curve = new EncoderCurve();
-               return curve;
-       }
-
-       private int treeviewEncoderCaptureCurvesEventSelectedID() {
-               TreeIter iter = new TreeIter();
-               TreeModel myModel = treeview_encoder_capture_curves.Model;
-               
-               if(ecconLast == "c") {
-                       if (treeview_encoder_capture_curves.Selection.GetSelected (out myModel, out iter)) 
-                               return Convert.ToInt32(((EncoderCurve) 
(treeview_encoder_capture_curves.Model.GetValue (iter, 0))).N); //this return an int, also in ec
-               } else {
-                       int selectedLength = 
treeview_encoder_capture_curves.Selection.GetSelectedRows().Length;
-                       if(selectedLength == 1 || selectedLength == 2) { 
-                               TreePath path = 
treeview_encoder_capture_curves.Selection.GetSelectedRows()[0];
-                               myModel.GetIter(out iter, path);
-                               return Convert.ToInt32(((EncoderCurve) 
(treeview_encoder_capture_curves.Model.GetValue (iter, 0))).N);
-                       }
-               }
-               return 0;
-       }
-       
-       private void on_treeview_encoder_capture_curves_cursor_changed (object o, EventArgs args) 
-       {
-               int lineNum = treeviewEncoderCaptureCurvesEventSelectedID();
-               encoderButtonsSensitive(encoderSensEnum.DONENOSIGNAL);
-               
-               //on ecc-con select both lines
-               if(ecconLast == "c") {
-                       if (lineNum > 0)
-                               encoderButtonsSensitive(encoderSensEnum.SELECTEDCURVE);
-               } else {
-                       TreeIter iter = new TreeIter();
-
-                       treeview_encoder_capture_curves.CursorChanged -= 
on_treeview_encoder_capture_curves_cursor_changed; 
-
-                       if (treeview_encoder_capture_curves.Selection.GetSelectedRows().Length == 1) 
-                       {
-                               treeview_encoder_capture_curves.Selection.UnselectAll();
-
-                               //on even, select also previous row
-                               //on odd, select also next row
-                               treeview_encoder_capture_curves.Model.GetIterFirst ( out iter ) ;
-                               bool isEven = (lineNum % 2 == 0); //check if it's even (in spanish "par")
-                               int start = lineNum;
-                               if(isEven) 
-                                       start = lineNum-1;
-
-                               //select 1st row
-                               for(int i=1; i < start; i++)
-                                       treeview_encoder_capture_curves.Model.IterNext (ref iter);
-                               treeview_encoder_capture_curves.Selection.SelectIter(iter);
-
-                               //select 2nd row
-                               treeview_encoder_capture_curves.Model.IterNext (ref iter);
-                               treeview_encoder_capture_curves.Selection.SelectIter(iter);
-                               
-                               if (treeview_encoder_capture_curves.Selection.GetSelectedRows().Length == 2) 
-                                       encoderButtonsSensitive(encoderSensEnum.SELECTEDCURVE);
-                       }
-                       treeview_encoder_capture_curves.CursorChanged += 
on_treeview_encoder_capture_curves_cursor_changed; 
-               }
-       }
-       
-       /* end of TreeView stuff */     
-
        /* sensitivity stuff */ 
                        
        //called when a person changes
@@ -4930,12 +4318,16 @@ Log.WriteLine(str);
                                image_encoder_analyze.Pixbuf = pixbuf;
                                encoder_pulsebar_analyze.Text = "";
 
-                               //Currently don't show neuromuscular profile because needs his own treeview 
structure
-                               if( ! radiobutton_encoder_analyze_neuromuscular_profile.Active ) {
-                                       string contents = 
Util.ReadFile(UtilEncoder.GetEncoderAnalyzeTableTempFileName(), false);
-                                       if (contents != null && contents != "") {
-                                               treeviewEncoderAnalyzeRemoveColumns();
+                               string contents = 
Util.ReadFile(UtilEncoder.GetEncoderAnalyzeTableTempFileName(), false);
+                               if (contents != null && contents != "") {
+                                       if(radiobutton_encoder_analyze_neuromuscular_profile.Active) {
+                                               treeviewEncoderAnalyzeRemoveColumns(false);     
//neuromuscular
+                                               createTreeViewEncoderAnalyzeNeuromuscular(contents);
+                                               button_encoder_analyze_table_save.Sensitive = false;
+                                       } else {
+                                               treeviewEncoderAnalyzeRemoveColumns(true);      //curves
                                                createTreeViewEncoderAnalyze(contents);
+                                               button_encoder_analyze_table_save.Sensitive = true;
                                        }
                                }
                        }
@@ -4946,7 +4338,6 @@ Log.WriteLine(str);
                        treeview_encoder_analyze_curves.Sensitive = true;
                        
                        button_encoder_analyze_image_save.Sensitive = true;
-                       button_encoder_analyze_table_save.Sensitive = true;
                        
                        string crossName = 
Util.FindOnArray(':',1,0,UtilGtk.ComboGetActive(combo_encoder_analyze_cross),
                                                encoderAnalyzeCrossTranslation);
diff --git a/src/gui/encoderTreeviews.cs b/src/gui/encoderTreeviews.cs
new file mode 100644
index 0000000..094bdd8
--- /dev/null
+++ b/src/gui/encoderTreeviews.cs
@@ -0,0 +1,915 @@
+/*
+ * This file is part of ChronoJump
+ *
+ * ChronoJump is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or   
+ *    (at your option) any later version.
+ *    
+ * ChronoJump is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ *    GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ *  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-2014   Xavier de Blas <xaviblas gmail com> 
+ */
+
+using System;
+using System.IO; 
+using System.IO.Ports;
+using Gtk;
+using Gdk;
+using Glade;
+using System.Collections;
+using Mono.Unix;
+
+
+public partial class ChronoJumpWindow 
+{
+
+       /* TreeView stuff */    
+
+       //returns curves num
+       //capture has single and multiple selection in order to save curves... Analyze only shows data.
+       private int createTreeViewEncoderCapture(string contents) {
+               bool showStartAndDuration = encoderCaptureOptionsWin.check_show_start_and_duration.Active;
+
+               string [] columnsString = {
+                       Catalog.GetString("Curve") + "\n",
+                       Catalog.GetString("Start") + "\n (s)",
+                       Catalog.GetString("Duration") + "\n (s)",
+                       Catalog.GetString("Range") + "\n (cm)",
+                       Catalog.GetString("MeanSpeed") + "\n (m/s)",
+                       Catalog.GetString("MaxSpeed") + "\n (m/s)",
+                       Catalog.GetString("MaxSpeedTime") + "\n (s)",
+                       Catalog.GetString("MeanPower") + "\n (W)",
+                       Catalog.GetString("PeakPower") + "\n (W)",
+                       Catalog.GetString("PeakPowerTime") + "\n (s)",
+                       Catalog.GetString("PeakPower/PPT") + "\n (W/s)"
+               };
+
+               encoderCaptureCurves = new ArrayList ();
+
+               string line;
+               int curvesCount = 0;
+               using (StringReader reader = new StringReader (contents)) {
+                       line = reader.ReadLine ();      //headers
+                       Log.WriteLine(line);
+                       do {
+                               line = reader.ReadLine ();
+                               Log.WriteLine(line);
+                               if (line == null)
+                                       break;
+
+                               curvesCount ++;
+
+                               string [] cells = line.Split(new char[] {','});
+                               cells = fixDecimals(cells);
+
+                               encoderCaptureCurves.Add (new EncoderCurve (
+                                                       cells[0],       //id 
+                                                       //cells[1],     //seriesName
+                                                       //cells[2],     //exerciseName
+                                                       //cells[3],     //massBody
+                                                       //cells[4],     //massExtra
+                                                       cells[5], cells[6], cells[7], 
+                                                       cells[8], cells[9], cells[10], 
+                                                       cells[11], cells[12], cells[13],
+                                                       cells[14]
+                                                       ));
+
+                       } while(true);
+               }
+
+               encoderCaptureListStore = new Gtk.ListStore (typeof (EncoderCurve));
+               foreach (EncoderCurve curve in encoderCaptureCurves) 
+                       encoderCaptureListStore.AppendValues (curve);
+
+               treeview_encoder_capture_curves.Model = encoderCaptureListStore;
+
+               if(ecconLast == "c")
+                       treeview_encoder_capture_curves.Selection.Mode = SelectionMode.Single;
+               else
+                       treeview_encoder_capture_curves.Selection.Mode = SelectionMode.Multiple;
+
+               treeview_encoder_capture_curves.HeadersVisible=true;
+
+               int i=0;
+               foreach(string myCol in columnsString) {
+                       Gtk.TreeViewColumn aColumn = new Gtk.TreeViewColumn ();
+                       CellRendererText aCell = new CellRendererText();
+                       aColumn.Title=myCol;
+                       aColumn.PackStart (aCell, true);
+
+                       //crt1.Foreground = "red";
+                       //crt1.Background = "blue";
+               
+                       switch(i){      
+                               case 0:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc (RenderN));
+                                       break;
+                               case 1:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderStart));
+                                       break;
+                               case 2:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderDuration));
+                                       break;
+                               case 3:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderHeight));
+                                       break;
+                               case 4:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMeanSpeed));
+                                       break;
+                               case 5:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMaxSpeed));
+                                       break;
+                               case 6:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMaxSpeedT));
+                                       break;
+                               case 7:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMeanPower));
+                                       break;
+                               case 8:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderPeakPower));
+                                       break;
+                               case 9:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderPeakPowerT));
+                                       break;
+                               case 10:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderPP_PPT));
+                                       break;
+                       }
+                                       
+                       if( ! ( (i == 1 || i == 2) && ! showStartAndDuration ) )
+                               treeview_encoder_capture_curves.AppendColumn (aColumn);
+                       i++;
+               }
+               return curvesCount;
+       }
+
+       string [] treeviewEncoderAnalyzeHeaders = {
+               Catalog.GetString("Curve") + "\n",
+               Catalog.GetString("Series") + "\n",
+               Catalog.GetString("Exercise") + "\n",
+               Catalog.GetString("Extra weight") + "\n (Kg)",
+               Catalog.GetString("Displaced weight") + "\n (Kg)",
+               Catalog.GetString("Start") + "\n (s)",
+               Catalog.GetString("Duration") + "\n (s)",
+               Catalog.GetString("Range") + "\n (cm)",
+               Catalog.GetString("MeanSpeed") + "\n (m/s)",
+               Catalog.GetString("MaxSpeed") + "\n (m/s)",
+               Catalog.GetString("MaxSpeedTime") + "\n (s)",
+               Catalog.GetString("MeanPower") + "\n (W)",
+               Catalog.GetString("PeakPower") + "\n (W)",
+               Catalog.GetString("PeakPowerTime") + "\n (s)",
+               Catalog.GetString("PeakPower/PPT") + "\n (W/s)"
+       };
+
+       private int createTreeViewEncoderAnalyze(string contents) {
+               string [] columnsString = treeviewEncoderAnalyzeHeaders;
+
+               ArrayList encoderAnalyzeCurves = new ArrayList ();
+
+               //write exercise and extra weight data
+               ArrayList curvesData = new ArrayList();
+               string exerciseName = "";
+               double displacedMass = 0; 
+               if(radiobutton_encoder_analyze_data_user_curves.Active) {
+                       curvesData = SqliteEncoder.Select(
+                                       false, -1, currentPerson.UniqueID, currentSession.UniqueID, "curve", 
true);
+               } else {        //current signal
+                       exerciseName = UtilGtk.ComboGetActive(combo_encoder_exercise);
+                       displacedMass = findMass(Constants.MassType.DISPLACED);
+               }
+
+               string line;
+               int curvesCount = 0;
+               using (StringReader reader = new StringReader (contents)) {
+                       line = reader.ReadLine ();      //headers
+                       Log.WriteLine(line);
+                       do {
+                               line = reader.ReadLine ();
+                               Log.WriteLine(line);
+                               if (line == null)
+                                       break;
+
+                               curvesCount ++;
+
+                               string [] cells = line.Split(new char[] {','});
+                               cells = fixDecimals(cells);
+                               
+                               
+                               if(radiobutton_encoder_analyze_data_user_curves.Active) {
+                                       /*
+                                       EncoderSQL eSQL = (EncoderSQL) curvesData[curvesCount];
+                                       exerciseName = eSQL.exerciseName;
+                                       displacedMass = eSQL.extraWeight;
+                                       */
+                                       exerciseName = cells[2];
+                                       displacedMass = Convert.ToDouble(cells[4]);
+                               }
+
+                               encoderAnalyzeCurves.Add (new EncoderCurve (
+                                                       cells[0], 
+                                                       cells[1],       //seriesName 
+                                                       exerciseName,
+                                                       massWithoutPerson(displacedMass, exerciseName),
+                                                       displacedMass,
+                                                       cells[5], cells[6], cells[7], 
+                                                       cells[8], cells[9], cells[10], 
+                                                       cells[11], cells[12], cells[13],
+                                                       cells[14]
+                                                       ));
+
+                       } while(true);
+               }
+
+               encoderAnalyzeListStore = new Gtk.ListStore (typeof (EncoderCurve));
+               foreach (EncoderCurve curve in encoderAnalyzeCurves) 
+                       encoderAnalyzeListStore.AppendValues (curve);
+
+               treeview_encoder_analyze_curves.Model = encoderAnalyzeListStore;
+
+               treeview_encoder_analyze_curves.Selection.Mode = SelectionMode.None;
+
+               treeview_encoder_analyze_curves.HeadersVisible=true;
+
+               int i=0;
+               foreach(string myCol in columnsString) {
+                       Gtk.TreeViewColumn aColumn = new Gtk.TreeViewColumn ();
+                       CellRendererText aCell = new CellRendererText();
+                       aColumn.Title=myCol;
+                       aColumn.PackStart (aCell, true);
+
+                       //crt1.Foreground = "red";
+                       //crt1.Background = "blue";
+               
+               
+                       switch(i){      
+                               case 0:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderNAnalyze));
+                                       break;
+                               case 1:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderSeries));
+                                       break;
+                               case 2:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderExercise));
+                                       break;
+                               case 3:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderExtraWeight));
+                                       break;
+                               case 4:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderDisplacedWeight));
+                                       break;
+                               case 5:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderStart));
+                                       break;
+                               case 6:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderDuration));
+                                       break;
+                               case 7:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderHeight));
+                                       break;
+                               case 8:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMeanSpeed));
+                                       break;
+                               case 9:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMaxSpeed));
+                                       break;
+                               case 10:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMaxSpeedT));
+                                       break;
+                               case 11:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMeanPower));
+                                       break;
+                               case 12:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderPeakPower));
+                                       break;
+                               case 13:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderPeakPowerT));
+                                       break;
+                               case 14:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderPP_PPT));
+                                       break;
+                       }
+                       
+                       treeview_encoder_analyze_curves.AppendColumn (aColumn);
+                       i++;
+               }
+               return curvesCount;
+       }
+
+       string [] treeviewEncoderAnalyzeNeuromuscularHeaders = {
+               "n" + "\n",
+               "e1 range" + "\n (cm)",
+               "e1 t" + "\n (ms)",
+               "e1 fmax" + "\n (N)",
+               "e1 rfd avg" + "\n ()",
+               "e1 i" + "\n ()",
+               "ca range" + "\n (cm)",
+               "cl t" + "\n (ms)",
+               "cl rfd avg" + "\n ()",
+               "cl i" + "\n ()",
+               "cl f avg" + "\n (N)",
+               "cl vf" + "\n ()",
+               "cl f max" + "\n (N)",
+               "cl s avg" + "\n (m/s)",
+               "cl s max" + "\n (m/s)",
+               "cl p avg" + "\n (W)",
+               "cl p max" + "\n (W)",
+               "e2f t" + "\n (ms)",
+               "e2f f fmax" + "\n (N)",
+               "e2f f fmax t" + "\n (ms)",
+               "e2f rfd max" + "\n ()"
+       };
+
+       private int createTreeViewEncoderAnalyzeNeuromuscular(string contents) {
+               string [] columnsString = treeviewEncoderAnalyzeNeuromuscularHeaders;
+
+               ArrayList encoderAnalyzeNm = new ArrayList ();
+
+               string line;
+               int curvesCount = 0;
+               using (StringReader reader = new StringReader (contents)) {
+                       line = reader.ReadLine ();      //headers
+                       Log.WriteLine(line);
+                       do {
+                               line = reader.ReadLine ();
+                               Log.WriteLine(line);
+                               if (line == null)
+                                       break;
+
+                               curvesCount ++;
+
+                               string [] cells = line.Split(new char[] {','});
+                               encoderAnalyzeNm.Add (new EncoderNeuromuscularData (cells));
+
+                       } while(true);
+               }
+
+               encoderAnalyzeListStore = new Gtk.ListStore (typeof (EncoderNeuromuscularData));
+               foreach (EncoderNeuromuscularData nm in encoderAnalyzeNm) 
+                       encoderAnalyzeListStore.AppendValues (nm);
+
+               treeview_encoder_analyze_curves.Model = encoderAnalyzeListStore;
+
+               treeview_encoder_analyze_curves.Selection.Mode = SelectionMode.None;
+
+               treeview_encoder_analyze_curves.HeadersVisible=true;
+
+               int i=0;
+               foreach(string myCol in columnsString) {
+                       
+                       Gtk.TreeViewColumn aColumn = new Gtk.TreeViewColumn ();
+                       CellRendererText aCell = new CellRendererText();
+                       aColumn.Title=myCol;
+                       aColumn.PackStart (aCell, true);
+
+                       //crt1.Foreground = "red";
+                       //crt1.Background = "blue";
+               
+                       switch(i){      
+                               case 1:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(Render_e1_range));
+                                       break;
+                               case 2:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(Render_e1_t));
+                                       break;
+                               case 3:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(Render_e1_fmax));
+                                       break;
+                               case 4:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(Render_e1_rfd_avg));
+                                       break;
+                               case 5:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(Render_e1_i));
+                                       break;
+                               case 6:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(Render_ca_range));
+                                       break;
+                               case 7:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(Render_cl_t));
+                                       break;
+                               case 8:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(Render_cl_rfd_avg));
+                                       break;
+                               case 9:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(Render_cl_i));
+                                       break;
+                               case 10:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(Render_cl_f_avg));
+                                       break;
+                               case 11:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(Render_cl_vf));
+                                       break;
+                               case 12:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(Render_cl_f_max));
+                                       break;
+                               case 13:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(Render_cl_s_avg));
+                                       break;
+                               case 14:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(Render_cl_s_max));
+                                       break;
+                               case 15:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(Render_cl_p_avg));
+                                       break;
+                               case 16:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(Render_cl_p_max));
+                                       break;
+                               case 17:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(Render_e2f_t));
+                                       break;
+                               case 18:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(Render_e2f_f_max));
+                                       break;
+                               case 19:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(Render_e2f_f_max_t));
+                                       break;
+                               case 20:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(Render_e2f_rfd_max));
+                                       break;
+                       }
+                       
+                       treeview_encoder_analyze_curves.AppendColumn (aColumn);
+                       i++;
+               }
+               return curvesCount;
+       }
+
+
+
+       /* start rendering capture and analyze cols */
+
+       private string assignColor(double found, bool higherActive, bool lowerActive, double higherValue, 
double lowerValue) 
+       {
+               //more at System.Drawing.Color (Monodoc)
+               string colorGood= "ForestGreen"; 
+               string colorBad= "red";
+               string colorNothing= "";        
+               //colorNothing will use default color on system, previous I used black,
+               //but if the color of the users theme is not 000000, then it looked too different
+
+               if(higherActive && found >= higherValue)
+                       return colorGood;
+               else if(lowerActive && found <= lowerValue)
+                       return colorBad;
+               else
+                       return colorNothing;
+       }
+
+       private string assignColor(double found, bool higherActive, bool lowerActive, int higherValue, int 
lowerValue) 
+       {
+               return assignColor(found, higherActive, lowerActive, 
+                               Convert.ToDouble(higherValue), Convert.ToDouble(lowerValue));
+       }
+
+       private void RenderN (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
+       {
+               //do this in order to have ecconLast useful for RenderN when capturing
+               if(capturingCsharp == encoderCaptureProcess.CAPTURING)
+                       ecconLast = findEccon(false);
+
+               EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
+               if(ecconLast == "c")
+                       (cell as Gtk.CellRendererText).Text = 
+                               String.Format(UtilGtk.TVNumPrint(curve.N,1,0),Convert.ToInt32(curve.N));
+               else if (ecconLast=="ec" || ecconLast =="ecS") {
+                       string phase = "e";
+                       bool isEven = Util.IsEven(Convert.ToInt32(curve.N));
+                       if(isEven)
+                               phase = "c";
+                               
+                       (cell as Gtk.CellRendererText).Text = 
+                               decimal.Truncate((Convert.ToInt32(curve.N) +1) /2).ToString() + phase;
+               } else {        //(ecconLast=="ce" || ecconLast =="ceS") {
+                       string phase = "c";
+                       bool isEven = Util.IsEven(Convert.ToInt32(curve.N));
+                       if(isEven)
+                               phase = "e";
+                               
+                       (cell as Gtk.CellRendererText).Text = 
+                               decimal.Truncate((Convert.ToInt32(curve.N) +1) /2).ToString() + phase;
+               }
+       }
+       //from analyze, don't checks ecconLast
+       private void RenderNAnalyze (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
+       {
+               EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
+               
+               if(radiobutton_encoder_analyze_data_current_signal.Active && findEccon(false) == "ecS") 
+               {
+                       string phase = "e";
+                       bool isEven = Util.IsEven(Convert.ToInt32(curve.N));
+                       if(isEven)
+                               phase = "c";
+
+                       (cell as Gtk.CellRendererText).Text = 
+                               decimal.Truncate((Convert.ToInt32(curve.N) +1) /2).ToString() + phase;
+               }
+               else if(radiobutton_encoder_analyze_data_current_signal.Active && findEccon(false) == "ceS") 
+               {
+                       string phase = "c";
+                       bool isEven = Util.IsEven(Convert.ToInt32(curve.N));
+                       if(isEven)
+                               phase = "e";
+
+                       (cell as Gtk.CellRendererText).Text = 
+                               decimal.Truncate((Convert.ToInt32(curve.N) +1) /2).ToString() + phase;
+               } else
+                       (cell as Gtk.CellRendererText).Text = curve.N;
+       }
+
+       private void RenderSeries (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.Series;
+       }
+
+       private void RenderExercise (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.Exercise;
+       }
+
+       private void RenderExtraWeight (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel 
model, Gtk.TreeIter iter)
+       {
+               EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
+               (cell as Gtk.CellRendererText).Text = 
+                       
String.Format(UtilGtk.TVNumPrint(curve.ExtraWeight.ToString(),3,0),Convert.ToInt32(curve.ExtraWeight));
+       }
+
+       private void RenderDisplacedWeight (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel 
model, Gtk.TreeIter iter)
+       {
+               EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
+               (cell as Gtk.CellRendererText).Text = 
+                       
String.Format(UtilGtk.TVNumPrint(curve.DisplacedWeight.ToString(),3,0),Convert.ToInt32(curve.DisplacedWeight));
+       }
+
+       private void RenderStart (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
+       {
+               EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
+               double myStart = Convert.ToDouble(curve.Start)/1000; //ms->s
+               (cell as Gtk.CellRendererText).Text = 
+                       String.Format(UtilGtk.TVNumPrint(myStart.ToString(),6,3),myStart); 
+       }
+       
+       private void RenderDuration (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
+       {
+               EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
+               double myDuration = Convert.ToDouble(curve.Duration)/1000; //ms->s
+               (cell as Gtk.CellRendererText).Text = 
+                       String.Format(UtilGtk.TVNumPrint(myDuration.ToString(),5,3),myDuration); 
+       }
+       
+       private void RenderHeight (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
+       {
+               EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
+               string heightToCm = (Convert.ToDouble(curve.Height)/10).ToString();
+               string myColor = assignColor(
+                               Convert.ToDouble(heightToCm),
+                               repetitiveConditionsWin.EncoderHeightHigher, 
+                               repetitiveConditionsWin.EncoderHeightLower, 
+                               repetitiveConditionsWin.EncoderHeightHigherValue,
+                               repetitiveConditionsWin.EncoderHeightLowerValue);
+               if(myColor != "")
+                       (cell as Gtk.CellRendererText).Foreground = myColor;
+               else
+                       (cell as Gtk.CellRendererText).Foreground = null;       //will show default color
+
+               (cell as Gtk.CellRendererText).Text = 
+                       String.Format(UtilGtk.TVNumPrint(heightToCm,5,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);
+               string myColor = assignColor(
+                               Convert.ToDouble(curve.MeanSpeed),
+                               repetitiveConditionsWin.EncoderMeanSpeedHigher, 
+                               repetitiveConditionsWin.EncoderMeanSpeedLower, 
+                               repetitiveConditionsWin.EncoderMeanSpeedHigherValue,
+                               repetitiveConditionsWin.EncoderMeanSpeedLowerValue);
+               if(myColor != "")
+                       (cell as Gtk.CellRendererText).Foreground = myColor;
+               else
+                       (cell as Gtk.CellRendererText).Foreground = null;       //will show default color
+
+               //no need of UtilGtk.TVNumPrint, always has 1 digit on left of decimal
+               (cell as Gtk.CellRendererText).Text = 
+                       String.Format("{0,10: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);
+               string myColor = assignColor(
+                               Convert.ToDouble(curve.MaxSpeed),
+                               repetitiveConditionsWin.EncoderMaxSpeedHigher, 
+                               repetitiveConditionsWin.EncoderMaxSpeedLower, 
+                               repetitiveConditionsWin.EncoderMaxSpeedHigherValue,
+                               repetitiveConditionsWin.EncoderMaxSpeedLowerValue);
+               if(myColor != "")
+                       (cell as Gtk.CellRendererText).Foreground = myColor;
+               else
+                       (cell as Gtk.CellRendererText).Foreground = null;       //will show default color
+
+               //no need of UtilGtk.TVNumPrint, always has 1 digit on left of decimal
+               (cell as Gtk.CellRendererText).Text = 
+                       String.Format("{0,10:0.000}",Convert.ToDouble(curve.MaxSpeed));
+       }
+       
+       private void RenderMaxSpeedT (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
+       {
+               EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
+               double time = Convert.ToDouble(curve.MaxSpeedT)/1000; //ms->s
+               (cell as Gtk.CellRendererText).Text = 
+                       String.Format(UtilGtk.TVNumPrint(time.ToString(),7,3),time);
+       }
+
+       private void RenderMeanPower (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
+       {
+               EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
+               string myColor = assignColor(
+                               Convert.ToDouble(curve.MeanPower),
+                               repetitiveConditionsWin.EncoderPowerHigher, 
+                               repetitiveConditionsWin.EncoderPowerLower, 
+                               repetitiveConditionsWin.EncoderPowerHigherValue,
+                               repetitiveConditionsWin.EncoderPowerLowerValue);
+               if(myColor != "")
+                       (cell as Gtk.CellRendererText).Foreground = myColor;
+               else
+                       (cell as Gtk.CellRendererText).Foreground = null;       //will show default color
+
+               (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)
+       {
+               EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
+               string myColor = assignColor(
+                               Convert.ToDouble(curve.PeakPower),
+                               repetitiveConditionsWin.EncoderPeakPowerHigher, 
+                               repetitiveConditionsWin.EncoderPeakPowerLower, 
+                               repetitiveConditionsWin.EncoderPeakPowerHigherValue,
+                               repetitiveConditionsWin.EncoderPeakPowerLowerValue);
+               if(myColor != "")
+                       (cell as Gtk.CellRendererText).Foreground = myColor;
+               else
+                       (cell as Gtk.CellRendererText).Foreground = null;       //will show default color
+
+               (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);
+               double myPPT = Convert.ToDouble(curve.PeakPowerT)/1000; //ms->s
+               (cell as Gtk.CellRendererText).Text = 
+                       String.Format(UtilGtk.TVNumPrint(myPPT.ToString(),7,3),myPPT);
+       }
+
+       private void RenderPP_PPT (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
+       {
+               EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
+               (cell as Gtk.CellRendererText).Text = 
+                       String.Format(UtilGtk.TVNumPrint(curve.PP_PPT,6,1),Convert.ToDouble(curve.PP_PPT));
+       }
+       
+       /* end of rendering capture and analyze cols */
+
+       /* start rendering neuromuscular cols */
+
+       private void Render_e1_range (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
+       {
+               EncoderNeuromuscularData nm = (EncoderNeuromuscularData) model.GetValue (iter, 0);
+               (cell as Gtk.CellRendererText).Text = nm.e1_range.ToString();
+       }
+
+       private void Render_e1_t (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
+       {
+               EncoderNeuromuscularData nm = (EncoderNeuromuscularData) model.GetValue (iter, 0);
+               (cell as Gtk.CellRendererText).Text = nm.e1_t.ToString();
+       }
+
+       private void Render_e1_fmax (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
+       {
+               EncoderNeuromuscularData nm = (EncoderNeuromuscularData) model.GetValue (iter, 0);
+               (cell as Gtk.CellRendererText).Text = nm.e1_fmax.ToString();
+       }
+
+       private void Render_e1_rfd_avg (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel 
model, Gtk.TreeIter iter)
+       {
+               EncoderNeuromuscularData nm = (EncoderNeuromuscularData) model.GetValue (iter, 0);
+               (cell as Gtk.CellRendererText).Text = nm.e1_rfd_avg.ToString();
+       }
+
+       private void Render_e1_i (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
+       {
+               EncoderNeuromuscularData nm = (EncoderNeuromuscularData) model.GetValue (iter, 0);
+               (cell as Gtk.CellRendererText).Text = nm.e1_i.ToString();
+       }
+
+       private void Render_ca_range (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
+       {
+               EncoderNeuromuscularData nm = (EncoderNeuromuscularData) model.GetValue (iter, 0);
+               (cell as Gtk.CellRendererText).Text = nm.ca_range.ToString();
+       }
+
+       private void Render_cl_t (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
+       {
+               EncoderNeuromuscularData nm = (EncoderNeuromuscularData) model.GetValue (iter, 0);
+               (cell as Gtk.CellRendererText).Text = nm.cl_t.ToString();
+       }
+
+       private void Render_cl_rfd_avg (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel 
model, Gtk.TreeIter iter)
+       {
+               EncoderNeuromuscularData nm = (EncoderNeuromuscularData) model.GetValue (iter, 0);
+               (cell as Gtk.CellRendererText).Text = nm.cl_rfd_avg.ToString();
+       }
+
+       private void Render_cl_i (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
+       {
+               EncoderNeuromuscularData nm = (EncoderNeuromuscularData) model.GetValue (iter, 0);
+               (cell as Gtk.CellRendererText).Text = nm.cl_i.ToString();
+       }
+
+       private void Render_cl_f_avg (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
+       {
+               EncoderNeuromuscularData nm = (EncoderNeuromuscularData) model.GetValue (iter, 0);
+               (cell as Gtk.CellRendererText).Text = nm.cl_f_avg.ToString();
+       }
+
+       private void Render_cl_vf (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
+       {
+               EncoderNeuromuscularData nm = (EncoderNeuromuscularData) model.GetValue (iter, 0);
+               (cell as Gtk.CellRendererText).Text = nm.cl_vf.ToString();
+       }
+
+       private void Render_cl_f_max (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
+       {
+               EncoderNeuromuscularData nm = (EncoderNeuromuscularData) model.GetValue (iter, 0);
+               (cell as Gtk.CellRendererText).Text = nm.cl_f_max.ToString();
+       }
+
+       private void Render_cl_s_avg (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
+       {
+               EncoderNeuromuscularData nm = (EncoderNeuromuscularData) model.GetValue (iter, 0);
+               (cell as Gtk.CellRendererText).Text = nm.cl_s_avg.ToString();
+       }
+
+       private void Render_cl_s_max (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
+       {
+               EncoderNeuromuscularData nm = (EncoderNeuromuscularData) model.GetValue (iter, 0);
+               (cell as Gtk.CellRendererText).Text = nm.cl_s_max.ToString();
+       }
+
+       private void Render_cl_p_avg (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
+       {
+               EncoderNeuromuscularData nm = (EncoderNeuromuscularData) model.GetValue (iter, 0);
+               (cell as Gtk.CellRendererText).Text = nm.cl_p_avg.ToString();
+       }
+
+       private void Render_cl_p_max (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
+       {
+               EncoderNeuromuscularData nm = (EncoderNeuromuscularData) model.GetValue (iter, 0);
+               (cell as Gtk.CellRendererText).Text = nm.cl_p_max.ToString();
+       }
+       
+       private void Render_e2f_t (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
+       {
+               EncoderNeuromuscularData nm = (EncoderNeuromuscularData) model.GetValue (iter, 0);
+               (cell as Gtk.CellRendererText).Text = nm.e2f_t.ToString();
+       }
+
+       private void Render_e2f_f_max (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
+       {
+               EncoderNeuromuscularData nm = (EncoderNeuromuscularData) model.GetValue (iter, 0);
+               (cell as Gtk.CellRendererText).Text = nm.e2f_f_max.ToString();
+       }
+
+       private void Render_e2f_f_max_t (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel 
model, Gtk.TreeIter iter)
+       {
+               EncoderNeuromuscularData nm = (EncoderNeuromuscularData) model.GetValue (iter, 0);
+               (cell as Gtk.CellRendererText).Text = nm.e2f_f_max_t.ToString();
+       }
+
+       private void Render_e2f_rfd_max (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel 
model, Gtk.TreeIter iter)
+       {
+               EncoderNeuromuscularData nm = (EncoderNeuromuscularData) model.GetValue (iter, 0);
+               (cell as Gtk.CellRendererText).Text = nm.e2f_rfd_max.ToString();
+       }
+
+
+       /* end of rendering neuromuscular cols */
+       
+       
+       private string [] fixDecimals(string [] cells) {
+               //start, width, height
+               for(int i=5; i <= 7; i++)
+                       cells[i] = 
Util.TrimDecimals(Convert.ToDouble(Util.ChangeDecimalSeparator(cells[i])),1);
+               
+               //meanSpeed,maxSpeed,maxSpeedT, meanPower,peakPower,peakPowerT
+               for(int i=8; i <= 13; i++)
+                       cells[i] = 
Util.TrimDecimals(Convert.ToDouble(Util.ChangeDecimalSeparator(cells[i])),3);
+               
+               //pp/ppt
+               int pp_ppt = 14;
+               cells[pp_ppt] = 
Util.TrimDecimals(Convert.ToDouble(Util.ChangeDecimalSeparator(cells[pp_ppt])),1); 
+               return cells;
+       }
+       
+       //the bool is for ecc-concentric
+       //there two rows are selected
+       //if user clicks on 2n row, and bool is true, first row is the returned curve
+       private EncoderCurve treeviewEncoderCaptureCurvesGetCurve(int row, bool onEccConTakeFirst) 
+       {
+               if(onEccConTakeFirst && ecconLast != "c") {
+                       bool isEven = (row % 2 == 0); //check if it's even (in spanish "par")
+                       if(isEven)
+                               row --;
+               }
+
+               TreeIter iter = new TreeIter();
+               bool iterOk = encoderCaptureListStore.GetIterFirst(out iter);
+               if(iterOk) {
+                       int count=1;
+                       do {
+                               if(count==row) 
+                                       return (EncoderCurve) treeview_encoder_capture_curves.Model.GetValue 
(iter, 0);
+                               count ++;
+                       } while (encoderCaptureListStore.IterNext (ref iter));
+               }
+               EncoderCurve curve = new EncoderCurve();
+               return curve;
+       }
+
+       private int treeviewEncoderCaptureCurvesEventSelectedID() {
+               TreeIter iter = new TreeIter();
+               TreeModel myModel = treeview_encoder_capture_curves.Model;
+               
+               if(ecconLast == "c") {
+                       if (treeview_encoder_capture_curves.Selection.GetSelected (out myModel, out iter)) 
+                               return Convert.ToInt32(((EncoderCurve) 
(treeview_encoder_capture_curves.Model.GetValue (iter, 0))).N); //this return an int, also in ec
+               } else {
+                       int selectedLength = 
treeview_encoder_capture_curves.Selection.GetSelectedRows().Length;
+                       if(selectedLength == 1 || selectedLength == 2) { 
+                               TreePath path = 
treeview_encoder_capture_curves.Selection.GetSelectedRows()[0];
+                               myModel.GetIter(out iter, path);
+                               return Convert.ToInt32(((EncoderCurve) 
(treeview_encoder_capture_curves.Model.GetValue (iter, 0))).N);
+                       }
+               }
+               return 0;
+       }
+       
+       private void on_treeview_encoder_capture_curves_cursor_changed (object o, EventArgs args) 
+       {
+               int lineNum = treeviewEncoderCaptureCurvesEventSelectedID();
+               encoderButtonsSensitive(encoderSensEnum.DONENOSIGNAL);
+               
+               //on ecc-con select both lines
+               if(ecconLast == "c") {
+                       if (lineNum > 0)
+                               encoderButtonsSensitive(encoderSensEnum.SELECTEDCURVE);
+               } else {
+                       TreeIter iter = new TreeIter();
+
+                       treeview_encoder_capture_curves.CursorChanged -= 
on_treeview_encoder_capture_curves_cursor_changed; 
+
+                       if (treeview_encoder_capture_curves.Selection.GetSelectedRows().Length == 1) 
+                       {
+                               treeview_encoder_capture_curves.Selection.UnselectAll();
+
+                               //on even, select also previous row
+                               //on odd, select also next row
+                               treeview_encoder_capture_curves.Model.GetIterFirst ( out iter ) ;
+                               bool isEven = (lineNum % 2 == 0); //check if it's even (in spanish "par")
+                               int start = lineNum;
+                               if(isEven) 
+                                       start = lineNum-1;
+
+                               //select 1st row
+                               for(int i=1; i < start; i++)
+                                       treeview_encoder_capture_curves.Model.IterNext (ref iter);
+                               treeview_encoder_capture_curves.Selection.SelectIter(iter);
+
+                               //select 2nd row
+                               treeview_encoder_capture_curves.Model.IterNext (ref iter);
+                               treeview_encoder_capture_curves.Selection.SelectIter(iter);
+                               
+                               if (treeview_encoder_capture_curves.Selection.GetSelectedRows().Length == 2) 
+                                       encoderButtonsSensitive(encoderSensEnum.SELECTEDCURVE);
+                       }
+                       treeview_encoder_capture_curves.CursorChanged += 
on_treeview_encoder_capture_curves_cursor_changed; 
+               }
+       }
+       
+       /* end of TreeView stuff */     
+
+}


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