[chronojump] analyze compare curves main gui 90%



commit 5fe0e5ad1f7e18fa16f9d61e30e2a4196937076b
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Mar 6 14:51:02 2013 +0100

    analyze compare curves main gui 90%

 src/gui/encoder.cs       |   79 ++++++++++++++++++++++++++++++++++++++++++++-
 src/gui/genericWindow.cs |   47 ++++++++++++++++++---------
 src/sqlite/encoder.cs    |    7 +++-
 src/treeViewPerson.cs    |    1 -
 src/util.cs              |   16 ++++++---
 5 files changed, 125 insertions(+), 25 deletions(-)
---
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index f4447a1..b0ca6c7 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -434,7 +434,8 @@ public partial class ChronoJumpWindow
                                string.Format(Catalog.GetString("Saved curves of athlete {0} on this 
session."), 
                                        currentPerson.Name), bigArray);
 
-               genericWin.SetTreeview(columnsString, true, dataPrint);
+               genericWin.CreateComboAllNoneSelected();
+               genericWin.SetTreeview(columnsString, true, dataPrint, new ArrayList());
                genericWin.MarkActiveCurves(checkboxes);
                genericWin.ShowButtonCancel(false);
                genericWin.SetButtonAcceptSensitive(true);
@@ -488,8 +489,82 @@ public partial class ChronoJumpWindow
        
        void on_button_encoder_analyze_data_compare_clicked (object o, EventArgs args) 
        {
+               //find all persons except current person
+               ArrayList dataPre = SqlitePersonSession.SelectCurrentSessionPersons(currentSession.UniqueID); 
+               ArrayList data = new ArrayList();
+               ArrayList nonSensitiveRows = new ArrayList();
+               int i = 0;      //list of persons
+               int j = 0;      //list of added persons
+               foreach(Person p in dataPre) {
+                       if(p.UniqueID != currentPerson.UniqueID) {
+                               ArrayList eSQLarray = SqliteEncoder.Select(
+                                               false, -1, p.UniqueID, currentSession.UniqueID, "curve", 
false); 
+                               string [] s = { p.UniqueID.ToString(), p.Name,
+                                       getActiveCurvesNum(eSQLarray).ToString(), eSQLarray.Count.ToString()
+                               };
+                               data.Add(s);
+                               if(getActiveCurvesNum(eSQLarray) == 0)
+                                       nonSensitiveRows.Add(j);
+                               j++;
+                       }
+                       i ++;
+               }
+               
+               string [] checkboxes = new string[data.Count]; //to store active or inactive status
+
+               string [] columnsString = {
+                       Catalog.GetString("ID"),
+                       Catalog.GetString("Name"),
+                       Catalog.GetString("Selected\ncurves"),
+                       Catalog.GetString("All\ncurves")
+               };
+
+               ArrayList bigArray = new ArrayList();
+               ArrayList a1 = new ArrayList();
+               ArrayList a2 = new ArrayList();
+               
+               //0 is the widgget to show; 1 is the editable; 2 id default value
+               a1.Add(Constants.GenericWindowShow.COMBOALLNONESELECTED); a1.Add(true); a1.Add("ALL");
+               bigArray.Add(a1);
+               
+               a2.Add(Constants.GenericWindowShow.TREEVIEW); a2.Add(true); a2.Add("");
+               bigArray.Add(a2);
+               
+               genericWin = GenericWindow.Show(false,  //don't show now
+                               string.Format(Catalog.GetString("Select persons to compare to {0}."), 
+                                       currentPerson.Name), bigArray);
+
+               genericWin.CreateComboAllNoneSelected();
+               genericWin.SetTreeview(columnsString, true, data, nonSensitiveRows);
+
+
+               genericWin.MarkActiveCurves(checkboxes);
+               genericWin.ShowButtonCancel(false);
+               genericWin.SetButtonAcceptSensitive(true);
+               //manage selected, unselected curves
+               genericWin.Button_accept.Clicked += new EventHandler(on_encoder_analyze_data_compare_done);
+
+               //used when we don't need to read data, 
+               //and we want to ensure next window will be created at needed size
+               //genericWin.DestroyOnAccept=true;
+               //here is comented because we are going to read the checkboxes
+
+               genericWin.ShowNow();
+       }
+
+       void on_encoder_analyze_data_compare_done (object o, EventArgs args) {
+               genericWin.Button_accept.Clicked -= new EventHandler(on_encoder_analyze_data_compare_done);
+               
+               genericWin.HideAndNull();
+               
+               Log.WriteLine("done");
        }
 
+
+
+
+
+
        void on_button_encoder_load_signal_clicked (object o, EventArgs args) 
        {
                ArrayList data = SqliteEncoder.Select(
@@ -514,7 +589,7 @@ public partial class ChronoJumpWindow
                                string.Format(Catalog.GetString("Select signal of athlete {0} on this 
session."), 
                                        currentPerson.Name), Constants.GenericWindowShow.TREEVIEW);
 
-               genericWin.SetTreeview(columnsString, false, dataPrint);
+               genericWin.SetTreeview(columnsString, false, dataPrint, new ArrayList());
                genericWin.ShowButtonCancel(true);
                genericWin.SetButtonAcceptLabel(Catalog.GetString("Load"));
                genericWin.SetButtonAcceptSensitive(false);
diff --git a/src/gui/genericWindow.cs b/src/gui/genericWindow.cs
index a450220..866f92e 100644
--- a/src/gui/genericWindow.cs
+++ b/src/gui/genericWindow.cs
@@ -61,6 +61,8 @@ public class GenericWindow
        [Widget] Gtk.Box hbox_entry3;
        [Widget] Gtk.Label label_entry3;
        [Widget] Gtk.Entry entry3;
+       
+       private ArrayList nonSensitiveRows;
 
        static GenericWindow GenericWindowBox;
        
@@ -73,7 +75,7 @@ public class GenericWindow
        //used when we don't need to read data, 
        //and we want to ensure next window will be created at needed size
        public bool DestroyOnAccept;
-       
+
        public GenericWindow ()
        {
                Glade.XML gladeXML;
@@ -175,9 +177,9 @@ public class GenericWindow
                        hbox_height_metric.Show();
                }
                else if(stuff == Constants.GenericWindowShow.COMBOALLNONESELECTED) {
-                       createComboAllNoneSelected();
-                       combo_all_none_selected.Active = 
-                               UtilGtk.ComboMakeActive(comboAllNoneSelectedOptions, 
Catalog.GetString("Selected"));
+                       //createComboAllNoneSelected();
+                       //combo_all_none_selected.Active = 
+                       //      UtilGtk.ComboMakeActive(comboAllNoneSelectedOptions, 
Catalog.GetString("Selected"));
                        hbox_combo_all_none_selected.Show();
                        hbox_all_none_selected.Show();
                }
@@ -230,7 +232,7 @@ public class GenericWindow
                Catalog.GetString("Selected"),
        };
 
-       protected void createComboAllNoneSelected() {
+       public void CreateComboAllNoneSelected() {
                combo_all_none_selected = ComboBox.NewText ();
                UtilGtk.ComboUpdate(combo_all_none_selected, comboAllNoneSelectedOptions, "");
                
@@ -240,6 +242,9 @@ public class GenericWindow
                hbox_combo_all_none_selected.PackStart(combo_all_none_selected, true, true, 0);
                hbox_combo_all_none_selected.ShowAll();
                combo_all_none_selected.Sensitive = true;
+                       
+               combo_all_none_selected.Active = 
+                       UtilGtk.ComboMakeActive(comboAllNoneSelectedOptions, Catalog.GetString("Selected"));
        }
        
        protected void on_combo_all_none_selected_changed(object o, EventArgs args) {
@@ -258,9 +263,12 @@ public class GenericWindow
                Gtk.TreeIter iter;
                bool okIter = store.GetIterFirst(out iter);
                if(okIter) {
+                       int i=0;
                        if(selected == Catalog.GetString("All")) {
                                do {
-                                       store.SetValue (iter, 0, true);
+                                       if(! Util.FoundInArrayList(nonSensitiveRows, i))
+                                               store.SetValue (iter, 0, true);
+                                       i++;
                                } while ( store.IterNext(ref iter) );
                        } else if(selected == Catalog.GetString("None")) {
                                do {
@@ -282,7 +290,8 @@ public class GenericWindow
        }
        
        //data is an ArrayList of strings[], each string [] is a row, each of its strings is a column
-       public void SetTreeview(string [] columnsString, bool addCheckbox, ArrayList data) 
+       public void SetTreeview(string [] columnsString, bool addCheckbox, 
+                       ArrayList data, ArrayList myNonSensitiveRows) 
        {
                //adjust window to be bigger
                generic_window.Resizable = true;
@@ -292,6 +301,8 @@ public class GenericWindow
                store = getStore(columnsString.Length, addCheckbox); 
                treeview.Model = store;
                prepareHeaders(columnsString, addCheckbox);
+
+               nonSensitiveRows = myNonSensitiveRows;
                
                if(addCheckbox)
                        createCheckboxes(treeview);
@@ -405,21 +416,25 @@ public class GenericWindow
        }
 
        protected void ItemToggled(object o, ToggledArgs args) {
-               //Log.WriteLine("Toggled");
-
                int column = 0;
                TreeIter iter;
                if (store.GetIter (out iter, new TreePath(args.Path))) 
                {
-                       bool val = (bool) store.GetValue (iter, column);
-                       //Log.WriteLine (string.Format("toggled {0} with value {1}", args.Path, !val));
+                       //Log.WriteLine(args.Path);
+                       if(! Util.FoundInArrayList(nonSensitiveRows, 
+                                               Convert.ToInt32(args.Path))) {
+                               bool val = (bool) store.GetValue (iter, column);
+                               //Log.WriteLine (string.Format("toggled {0} with value {1}", args.Path, 
!val));
 
-                       store.SetValue (iter, column, !val);
-               
-                       combo_all_none_selected.Active = UtilGtk.ComboMakeActive(comboAllNoneSelectedOptions, 
Catalog.GetString("Selected"));
+                               store.SetValue (iter, column, !val);
 
-                       //check if there are rows checked for having sensitive or not
-                       //buttonRecuperateChangeSensitiveness();
+                               combo_all_none_selected.Active =
+                                       UtilGtk.ComboMakeActive(
+                                                       comboAllNoneSelectedOptions, 
Catalog.GetString("Selected"));
+
+                               //check if there are rows checked for having sensitive or not
+                               //buttonRecuperateChangeSensitiveness();
+                       }
                }
        }
        
diff --git a/src/sqlite/encoder.cs b/src/sqlite/encoder.cs
index 3ceeefa..e8a6048 100644
--- a/src/sqlite/encoder.cs
+++ b/src/sqlite/encoder.cs
@@ -134,17 +134,22 @@ class SqliteEncoder : Sqlite
        //EncoderSQL eSQL = (EncoderSQL) SqliteEncoder.Select(false, myUniqueID, 0, 0, "")[0];
        //or
        //pass uniqueID==-1 and personID, sessionID, signalOrCurve values, and will return some records
+       //personID can be -1 to get all on that session
        public static ArrayList Select (bool dbconOpened, 
                        int uniqueID, int personID, int sessionID, string signalOrCurve, bool onlyActive)
        {
                if(! dbconOpened)
                        dbcon.Open();
 
+               string personIDStr = "";
+               if(personID != -1)
+                       personIDStr = "personID = " + personID + " AND ";
+
                string selectStr = "";
                if(uniqueID != -1)
                        selectStr = Constants.EncoderTable + ".uniqueID = " + uniqueID;
                else
-                       selectStr = "personID = " + personID + " AND sessionID = " + sessionID + 
+                       selectStr = personIDStr + " sessionID = " + sessionID + 
                        " AND signalOrCurve = '" + signalOrCurve + "'";
 
                string onlyActiveString = "";
diff --git a/src/treeViewPerson.cs b/src/treeViewPerson.cs
index ffd6a92..0f9e5d1 100644
--- a/src/treeViewPerson.cs
+++ b/src/treeViewPerson.cs
@@ -132,7 +132,6 @@ public class TreeViewPersons
                return found;
        }
 
-               
        public void SelectNextRow(int personID)
        {
                SelectRow(FindRow(personID) +1);
diff --git a/src/util.cs b/src/util.cs
index 77c6c1a..60e1c18 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -1494,15 +1494,21 @@ public class Util
                return myArrayList;
        }
 
-       public static bool FoundInArrayList(ArrayList myArrayList, string str) {
-               bool found = false;
-               foreach (string str2 in myArrayList)
+       public static bool FoundInArrayList(ArrayList a, string str) {
+               foreach (string str2 in a)
                        if(str2 == str)
-                               found = true;
+                               return true;
 
-               return found;
+               return false;
        }
 
+       public static bool FoundInArrayList(ArrayList a, int i) {
+               foreach (int j in a)
+                       if(i == j)
+                               return true;
+
+               return false;
+       }
 
 
        /*


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