[chronojump] Moving to DB 1.06:"connect signal with curves" 98%
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Moving to DB 1.06:"connect signal with curves" 98%
- Date: Mon, 19 May 2014 08:01:02 +0000 (UTC)
commit f0f56eaa7adf13e1d8208d60fa34a818f0ae2011
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon May 19 09:59:47 2014 +0200
Moving to DB 1.06:"connect signal with curves" 98%
glade/chronojump.glade | 39 +--------------
src/gui/encoder.cs | 112 +++++++++++++++++++++----------------------
src/gui/encoderTreeviews.cs | 71 +++++++++++++++++++++------
src/sqlite/encoder.cs | 43 +++++++++++-----
src/sqlite/main.cs | 6 +-
src/sqlite/personSession.cs | 5 +-
src/sqlite/session.cs | 5 +-
7 files changed, 150 insertions(+), 131 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 06f570b..567353d 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -12366,49 +12366,14 @@ on current Chronojump version.</property>
</packing>
</child>
<child>
- <widget class="GtkEntry"
id="entry_encoder_curve_comment">
- <property name="width_request">100</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="has_tooltip">True</property>
- <property name="tooltip" translatable="yes">Add
a comment</property>
- <property name="invisible_char">●</property>
- <property
name="invisible_char_set">True</property>
- <property
name="primary_icon_activatable">False</property>
- <property
name="secondary_icon_activatable">False</property>
- <property
name="primary_icon_sensitive">True</property>
- <property
name="secondary_icon_sensitive">True</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <widget class="GtkButton"
id="button_encoder_save_curve">
- <property name="label">Save selected</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property
name="use_action_appearance">False</property>
- <signal name="clicked"
handler="on_button_encoder_save_clicked" swapped="no"/>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel"
id="label_encoder_save_curve">
+ <widget class="GtkLabel"
id="label_encoder_curve_action">
<property name="visible">True</property>
<property name="can_focus">False</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">3</property>
+ <property name="position">1</property>
</packing>
</child>
</widget>
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 6364198..5dc4561 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -58,10 +58,10 @@ public partial class ChronoJumpWindow
[Widget] Gtk.Image image_encoder_capture_open;
[Widget] Gtk.ProgressBar encoder_pulsebar_capture;
//[Widget] Gtk.Entry entry_encoder_signal_comment;
- [Widget] Gtk.Entry entry_encoder_curve_comment;
- [Widget] Gtk.Button button_encoder_save_curve;
+ //[Widget] Gtk.Entry entry_encoder_curve_comment;
+ //[Widget] Gtk.Button button_encoder_save_curve;
[Widget] Gtk.Button button_encoder_export_all_curves;
- [Widget] Gtk.Label label_encoder_save_curve;
+ [Widget] Gtk.Label label_encoder_curve_action;
[Widget] Gtk.Button button_encoder_delete_signal;
[Widget] Gtk.Notebook notebook_encoder_sup;
@@ -753,7 +753,8 @@ public partial class ChronoJumpWindow
void on_button_encoder_analyze_data_select_curves_clicked (object o, EventArgs args)
{
ArrayList data = SqliteEncoder.Select(
- false, -1, currentPerson.UniqueID, currentSession.UniqueID, "curve", false);
+ false, -1, currentPerson.UniqueID, currentSession.UniqueID, "curve",
+ false, true);
ArrayList dataPrint = new ArrayList();
string [] checkboxes = new string[data.Count]; //to store active or inactive status of curves
@@ -846,7 +847,8 @@ public partial class ChronoJumpWindow
string [] checkboxes = genericWin.GetCheckboxesStatus(1, false);
ArrayList data = SqliteEncoder.Select(
- false, -1, currentPerson.UniqueID, currentSession.UniqueID, "curve", false);
+ false, -1, currentPerson.UniqueID, currentSession.UniqueID, "curve",
+ false, true);
//update on database the curves that have been selected/deselected
int count = 0;
@@ -890,7 +892,7 @@ public partial class ChronoJumpWindow
Log.WriteLine("row edit apply at show curves");
int curveID = genericWin.TreeviewSelectedUniqueID;
- EncoderSQL eSQL = (EncoderSQL) SqliteEncoder.Select(false, curveID, 0, 0, "", false)[0];
+ EncoderSQL eSQL = (EncoderSQL) SqliteEncoder.Select(false, curveID, 0, 0, "", false, true)[0];
//if changed comment, update SQL, and update treeview
//first remove conflictive characters
@@ -937,14 +939,15 @@ public partial class ChronoJumpWindow
void delete_encoder_curve(int uniqueID) {
Log.WriteLine(uniqueID.ToString());
- EncoderSQL eSQL = (EncoderSQL) SqliteEncoder.Select(false, uniqueID, 0, 0, "", false)[0];
+ EncoderSQL eSQL = (EncoderSQL) SqliteEncoder.Select(false, uniqueID, 0, 0, "", false,
true)[0];
//remove the file
bool deletedOk = Util.FileDelete(eSQL.GetFullURL(false)); //don't convertPathToR
if(deletedOk) {
Sqlite.Delete(false, Constants.EncoderTable, Convert.ToInt32(uniqueID));
ArrayList escArray = SqliteEncoder.SelectSignalCurve(false,
- -1, Convert.ToInt32(uniqueID)); //signal, curve
+ -1, Convert.ToInt32(uniqueID), //signal, curve
+ -1, -1); //msStart, msEnd
SqliteEncoder.DeleteSignalCurveWithCurveID(false,
Convert.ToInt32(eSQL.uniqueID)); //delete by curveID on SignalCurve
table
//if deleted curve is from current signal, uncheck it in encoderCaptureCurves
@@ -980,7 +983,8 @@ public partial class ChronoJumpWindow
foreach(Person p in dataPre) {
if(p.UniqueID != currentPerson.UniqueID) {
ArrayList eSQLarray = SqliteEncoder.Select(
- false, -1, p.UniqueID, currentSession.UniqueID, "curve",
false);
+ false, -1, p.UniqueID, currentSession.UniqueID, "curve",
+ false, true);
string [] s = { p.UniqueID.ToString(), "", p.Name,
getActiveCurvesNum(eSQLarray).ToString(), eSQLarray.Count.ToString()
};
@@ -1166,7 +1170,8 @@ public partial class ChronoJumpWindow
void on_button_encoder_load_signal_clicked (object o, EventArgs args)
{
ArrayList data = SqliteEncoder.Select(
- false, -1, currentPerson.UniqueID, currentSession.UniqueID, "signal", false);
+ false, -1, currentPerson.UniqueID, currentSession.UniqueID, "signal",
+ false, true);
ArrayList dataPrint = new ArrayList();
int count = 1;
@@ -1235,7 +1240,8 @@ public partial class ChronoJumpWindow
genericWin.HideAndNull();
ArrayList data = SqliteEncoder.Select(
- false, uniqueID, currentPerson.UniqueID, currentSession.UniqueID, "signal",
false);
+ false, uniqueID, currentPerson.UniqueID, currentSession.UniqueID, "signal",
+ false, true);
bool success = false;
foreach(EncoderSQL eSQL in data) { //it will run only one time
@@ -1282,7 +1288,7 @@ public partial class ChronoJumpWindow
Log.WriteLine("row edit apply at load signal");
int curveID = genericWin.TreeviewSelectedUniqueID;
- EncoderSQL eSQL = (EncoderSQL) SqliteEncoder.Select(false, curveID, 0, 0, "", false)[0];
+ EncoderSQL eSQL = (EncoderSQL) SqliteEncoder.Select(false, curveID, 0, 0, "", false, true)[0];
//if changed comment, update SQL, and update treeview
//first remove conflictive characters
@@ -1325,7 +1331,8 @@ public partial class ChronoJumpWindow
if(uniqueID == Convert.ToInt32(encoderSignalUniqueID))
on_button_encoder_delete_signal_accepted (o, args);
else {
- EncoderSQL eSQL = (EncoderSQL) SqliteEncoder.Select(false, uniqueID, 0, 0, "",
false)[0];
+ EncoderSQL eSQL = (EncoderSQL) SqliteEncoder.Select(
+ false, uniqueID, 0, 0, "", false, true)[0];
//remove the file
bool deletedOk = Util.FileDelete(eSQL.GetFullURL(false)); //don't convertPathToR
if(deletedOk)
@@ -1518,7 +1525,7 @@ public partial class ChronoJumpWindow
void on_button_encoder_delete_signal_accepted (object o, EventArgs args)
{
EncoderSQL eSQL = (EncoderSQL) SqliteEncoder.Select(
- false, Convert.ToInt32(encoderSignalUniqueID), 0, 0, "", false)[0];
+ false, Convert.ToInt32(encoderSignalUniqueID), 0, 0, "", false, true)[0];
//remove the file
bool deletedOk = Util.FileDelete(eSQL.GetFullURL(false)); //don't convertPathToR
if(deletedOk) {
@@ -1533,33 +1540,6 @@ public partial class ChronoJumpWindow
}
}
-
- void on_button_encoder_save_clicked (object o, EventArgs args)
- {
- /*
- int i = 1;
- TreeIter iter;
- bool iterOk = encoderCaptureListStore.GetIterFirst(out iter);
- while(iterOk) {
- //checked?
- if(((EncoderCurve) encoderCaptureListStore.GetValue (iter, 0)).Record)
- label_encoder_save_curve.Text = encoderSaveSignalOrCurve("curve", i);
-
- i ++;
- iterOk = encoderCaptureListStore.IterNext (ref iter);
-
- //if is not "c", then there are two rows, but pass only the odd rows
- //then if IsEven, do not use it, use the next
- if(iterOk && ecconLast != "c" && Util.IsEven(i)) {
- i ++;
- iterOk = encoderCaptureListStore.IterNext (ref iter);
- }
- }
-
- updateUserCurvesLabelsAndCombo();
- */
- }
-
private int getActiveCurvesNum(ArrayList curvesArray) {
int countActiveCurves = 0;
foreach(EncoderSQL es in curvesArray)
@@ -1571,11 +1551,14 @@ public partial class ChronoJumpWindow
private void updateUserCurvesLabelsAndCombo() {
ArrayList data = SqliteEncoder.Select(
- false, -1, currentPerson.UniqueID, currentSession.UniqueID, "curve", false);
+ false, -1, currentPerson.UniqueID, currentSession.UniqueID, "curve",
+ false, true);
int activeCurvesNum = getActiveCurvesNum(data);
label_encoder_user_curves_active_num.Text = activeCurvesNum.ToString();
label_encoder_user_curves_all_num.Text = data.Count.ToString();
updateComboEncoderAnalyzeCurveNum(data, activeCurvesNum);
+
+ button_encoder_analyze_sensitiveness();
}
private string [] getActiveCheckboxesList(string [] checkboxes, int activeCurvesNum) {
@@ -1673,7 +1656,8 @@ public partial class ChronoJumpWindow
}
}
- desc = Util.RemoveTildeAndColonAndDot(entry_encoder_curve_comment.Text.ToString());
+ //desc = Util.RemoveTildeAndColonAndDot(entry_encoder_curve_comment.Text.ToString());
+ desc = "";
Log.WriteLine(curveStart + "->" + duration);
int curveIDMax = Sqlite.Max(Constants.EncoderTable, "uniqueID", false);
@@ -1682,6 +1666,11 @@ public partial class ChronoJumpWindow
inertialCheckStart, inertialCheckDuration, (ecconLast == "c"),
currentSession.UniqueID, currentPerson.UniqueID,
currentPerson.Name, encoderTimeStamp, curveIDMax);
+
+ SqliteEncoder.SignalCurveInsert(false,
+ Convert.ToInt32(encoderSignalUniqueID), curveIDMax +1,
+ Convert.ToInt32(curveStart + (duration /2)));
+
path = UtilEncoder.GetEncoderSessionDataCurveDir(currentSession.UniqueID);
} else { //signal
//desc = Util.RemoveTildeAndColonAndDot(entry_encoder_signal_comment.Text.ToString());
@@ -1703,6 +1692,8 @@ public partial class ChronoJumpWindow
eSQL.filename = fileSaved;
eSQL.url = path;
eSQL.description = desc;
+ if(mode == "curve")
+ eSQL.status = "active";
eSQL.encoderConfiguration = encoderConfigurationCurrent;
@@ -1757,7 +1748,8 @@ public partial class ChronoJumpWindow
if( ! check_encoder_analyze_signal_or_curves.Active) //saved curves
{
ArrayList data = SqliteEncoder.Select(
- false, -1, currentPerson.UniqueID, currentSession.UniqueID, "curve",
false);
+ false, -1, currentPerson.UniqueID, currentSession.UniqueID, "curve",
+ false, true);
if(data.Count == 0) {
new DialogMessage(Constants.MessageTypes.WARNING,
Catalog.GetString("Sorry, no curves selected."));
@@ -2147,7 +2139,8 @@ public partial class ChronoJumpWindow
//onlyActive is false to have all the curves
//this is a need for "single" to select on display correct curve
data = SqliteEncoder.Select(
- false, -1, currentPerson.UniqueID, currentSession.UniqueID, "curve", false);
+ false, -1, currentPerson.UniqueID, currentSession.UniqueID, "curve",
+ false, true);
//if compare persons, select curves for other persons and add
if(Util.FindOnArray(':',1,0,UtilGtk.ComboGetActive(combo_encoder_analyze_data_compare),
@@ -2157,8 +2150,8 @@ public partial class ChronoJumpWindow
dataPre = SqliteEncoder.Select(
false, -1,
Util.FetchID(encoderCompareInterperson[i].ToString()),
- currentSession.UniqueID,
- "curve", true);
+ currentSession.UniqueID, "curve",
+ true, true);
//this curves are added to data, data included currentPerson,
currentSession
foreach(EncoderSQL eSQL in dataPre)
data.Add(eSQL);
@@ -2171,7 +2164,7 @@ public partial class ChronoJumpWindow
false, -1,
currentPerson.UniqueID,
Util.FetchID(encoderCompareIntersession[i].ToString()),
- "curve", true);
+ "curve", true, true);
//this curves are added to data, data included currentPerson,
currentSession
foreach(EncoderSQL eSQL in dataPre)
data.Add(eSQL);
@@ -2402,7 +2395,8 @@ Log.WriteLine(str);
else {
if(currentPerson != null) {
ArrayList data = SqliteEncoder.Select(
- false, -1, currentPerson.UniqueID, currentSession.UniqueID,
"curve", false);
+ false, -1, currentPerson.UniqueID, currentSession.UniqueID,
+ "curve", false, true);
int activeCurvesNum = getActiveCurvesNum(data);
updateComboEncoderAnalyzeCurveNum(data, activeCurvesNum);
}
@@ -2779,18 +2773,18 @@ Log.WriteLine(str);
Catalog.GetString(comboLateralityOptions[0]));
//create combo capure save curve
- string [] comboEncoderCaptureSaveOptions = { Constants.All, Constants.None, Constants.Invert,
Constants.Selected };
+ string [] comboEncoderCaptureSaveOptions = { Constants.All, Constants.None,
Constants.Selected };
string [] comboEncoderCaptureSaveOptionsTranslated = {
Catalog.GetString(Constants.All), Catalog.GetString(Constants.None),
- Catalog.GetString(Constants.Invert), Catalog.GetString(Constants.Selected) };
+ Catalog.GetString(Constants.Selected) };
encoderCaptureSaveTranslation = new String [comboEncoderCaptureSaveOptions.Length];
- for(int j=0; j < 4 ; j++)
+ for(int j=0; j < 3 ; j++)
encoderCaptureSaveTranslation[j] =
comboEncoderCaptureSaveOptions[j] + ":" +
comboEncoderCaptureSaveOptionsTranslated[j];
combo_encoder_capture_save_curve = ComboBox.NewText();
UtilGtk.ComboUpdate(combo_encoder_capture_save_curve,
comboEncoderCaptureSaveOptionsTranslated, "");
combo_encoder_capture_save_curve.Active =
UtilGtk.ComboMakeActive(combo_encoder_capture_save_curve,
- Catalog.GetString(comboEncoderCaptureSaveOptionsTranslated[1])); //None
+ Catalog.GetString(comboEncoderCaptureSaveOptionsTranslated[2])); //SELECTED
combo_encoder_capture_save_curve.Changed +=
new EventHandler(on_combo_encoder_capture_save_curve_changed );
@@ -3242,7 +3236,8 @@ Log.WriteLine(str);
//called when a person changes
private void encoderPersonChanged() {
ArrayList data = SqliteEncoder.Select(
- false, -1, currentPerson.UniqueID, currentSession.UniqueID, "curve", false);
+ false, -1, currentPerson.UniqueID, currentSession.UniqueID, "curve",
+ false, true);
int activeCurvesNum = getActiveCurvesNum(data);
label_encoder_user_curves_active_num.Text = activeCurvesNum.ToString();
@@ -3296,7 +3291,7 @@ Log.WriteLine(str);
//c3 hbox_combo_encoder_capture_save_curve, button_encoder_export_all_curves,
// button_encoder_delete_signal, entry_encoder_signal_comment,
// and images: image_encoder_capture , image_encoder_analyze.Sensitive. Update: both NOT
managed here
- //c4 button_encoder_save_curve, entry_encoder_curve_comment
+ //UNUSED c4 button_encoder_save_curve, entry_encoder_curve_comment
//c5 button_encoder_analyze
//c6 hbox_encoder_user_curves
//c7 button_encoder_capture_cancel (on capture and analyze)
@@ -3361,8 +3356,8 @@ Log.WriteLine(str);
//image_encoder_capture.Sensitive = Util.IntToBool(table[3]);
//image_encoder_analyze.Sensitive = Util.IntToBool(table[3]);
- button_encoder_save_curve.Sensitive = Util.IntToBool(table[4]);
- entry_encoder_curve_comment.Sensitive = Util.IntToBool(table[4]);
+ //button_encoder_save_curve.Sensitive = Util.IntToBool(table[4]);
+ //entry_encoder_curve_comment.Sensitive = Util.IntToBool(table[4]);
bool analyze_sensitive =
(
@@ -4488,7 +4483,8 @@ Log.WriteLine(str);
//find the saved curves
ArrayList linkedCurves = SqliteEncoder.SelectSignalCurve(false,
- Convert.ToInt32(encoderSignalUniqueID), -1); //signal, curve
+ Convert.ToInt32(encoderSignalUniqueID), //signal
+ -1, -1, -1); //curve, msStart,msEnd
Log.WriteLine("SAVED CURVES FOUND");
foreach(EncoderSignalCurve esc in linkedCurves)
Log.WriteLine(esc.ToString());
diff --git a/src/gui/encoderTreeviews.cs b/src/gui/encoderTreeviews.cs
index c58d982..ae981bb 100644
--- a/src/gui/encoderTreeviews.cs
+++ b/src/gui/encoderTreeviews.cs
@@ -112,7 +112,7 @@ public partial class ChronoJumpWindow
crt.Toggled += ItemToggled;
Gtk.TreeViewColumn column = new Gtk.TreeViewColumn ();
- column.Title="";
+ column.Title = Catalog.GetString("Saved");
column.PackStart (crt, true);
column.SetCellDataFunc (crt, new Gtk.TreeCellDataFunc (RenderRecord));
treeview_encoder_capture_curves.AppendColumn (column);
@@ -166,11 +166,40 @@ public partial class ChronoJumpWindow
}
return curvesCount;
}
+
+ //rowNum starts at zero
+ void saveOrDeleteCurveFromCaptureTreeView(int rowNum, EncoderCurve curve, bool save)
+ {
+ if(save)
+ label_encoder_curve_action.Text = encoderSaveSignalOrCurve("curve", rowNum +1);
+ else {
+ if(ecconLast == "c" || Util.IsEven(rowNum)) {
+ double msStart = Convert.ToDouble(curve.Start);
+ double msEnd = -1;
+ if(ecconLast == "c")
+ msEnd = Convert.ToDouble(curve.Start) +
+ Convert.ToDouble(curve.Duration);
+ else {
+ EncoderCurve curveNext =
+ treeviewEncoderCaptureCurvesGetCurve(rowNum +2,false);
+ msEnd = Convert.ToDouble(curveNext.Start) +
+ Convert.ToDouble(curveNext.Duration);
+ }
+
+ ArrayList signalCurves = SqliteEncoder.SelectSignalCurve(false,
+ Convert.ToInt32(encoderSignalUniqueID), -1,
+ msStart, msEnd);
+ foreach(EncoderSignalCurve esc in signalCurves)
+ delete_encoder_curve(esc.curveID);
+
+ label_encoder_curve_action.Text = Catalog.GetString("Removed");
+ }
+ }
+ }
void ItemToggled(object o, ToggledArgs args) {
TreeIter iter;
int column = 0;
- int i = 1;
if (encoderCaptureListStore.GetIterFromString (out iter, args.Path))
{
EncoderCurve curve = (EncoderCurve) encoderCaptureListStore.GetValue (iter, column);
@@ -181,12 +210,10 @@ public partial class ChronoJumpWindow
//this changes value, but checkbox will be changed on RenderRecord. Was impossible to
do here.
((EncoderCurve) encoderCaptureListStore.GetValue (iter, column)).Record = ! val;
- //save the curve
- if(! val)
- label_encoder_save_curve.Text = encoderSaveSignalOrCurve("curve", i++);
-// else
-//TODO delete_encoder_curve(curve.uniqueID);
-
+ //save or delete the curve
+ int rowNum = Convert.ToInt32(args.Path); //starts at zero
+ saveOrDeleteCurveFromCaptureTreeView(rowNum, curve, ! val);
+
//on ec, ecS need to [un]select another row
if (ecconLast=="ec" || ecconLast =="ecS") {
TreePath path = new TreePath(args.Path);
@@ -212,8 +239,10 @@ public partial class ChronoJumpWindow
combo_encoder_capture_save_curve,
Catalog.GetString(Constants.Selected));
- combo_encoder_capture_show_save_curve_button();
+ //combo_encoder_capture_show_save_curve_button();
+ updateUserCurvesLabelsAndCombo();
+
callPlotCurvesGraphDoPlot();
}
}
@@ -226,23 +255,30 @@ public partial class ChronoJumpWindow
if(toSelect == Catalog.GetString(Constants.None))
val = false;
+ int i = 0;
TreeIter iter;
bool iterOk = encoderCaptureListStore.GetIterFirst(out iter);
while(iterOk) {
TreePath path = encoderCaptureListStore.GetPath(iter);
- if(toSelect == Catalog.GetString(Constants.Invert))
- val = ! ((EncoderCurve) encoderCaptureListStore.GetValue (iter, 0)).Record;
+ //invert disabled
+ //if(toSelect == Catalog.GetString(Constants.Invert))
+ // val = ! ((EncoderCurve) encoderCaptureListStore.GetValue (iter, 0)).Record;
//change value
((EncoderCurve) encoderCaptureListStore.GetValue (iter, 0)).Record = val;
//this makes RenderRecord work on changed row without having to put mouse there
encoderCaptureListStore.EmitRowChanged(path,iter);
+
+ EncoderCurve curve = (EncoderCurve) encoderCaptureListStore.GetValue (iter, 0);
+ saveOrDeleteCurveFromCaptureTreeView(i++, curve, val);
iterOk = encoderCaptureListStore.IterNext (ref iter);
}
- combo_encoder_capture_show_save_curve_button();
+ //combo_encoder_capture_show_save_curve_button();
+
+ updateUserCurvesLabelsAndCombo();
callPlotCurvesGraphDoPlot();
}
@@ -287,13 +323,14 @@ public partial class ChronoJumpWindow
iterOk = encoderCaptureListStore.IterNext (ref iter);
}
- combo_encoder_capture_show_save_curve_button();
+ //combo_encoder_capture_show_save_curve_button();
callPlotCurvesGraphDoPlot();
}
-
+
+ /*
void combo_encoder_capture_show_save_curve_button () {
- label_encoder_save_curve.Text = "";
+ label_encoder_curve_action.Text = "";
TreeIter iter;
bool iterOk = encoderCaptureListStore.GetIterFirst(out iter);
@@ -306,6 +343,7 @@ public partial class ChronoJumpWindow
}
encoderButtonsSensitive(encoderSensEnum.DONEYESSIGNAL);
}
+ */
@@ -343,7 +381,8 @@ public partial class ChronoJumpWindow
totalMass = findMass(Constants.MassType.DISPLACED);
} else { //user curves
curvesData = SqliteEncoder.Select(
- false, -1, currentPerson.UniqueID, currentSession.UniqueID, "curve",
true);
+ false, -1, currentPerson.UniqueID, currentSession.UniqueID,
+ "curve", true, true);
}
string line;
diff --git a/src/sqlite/encoder.cs b/src/sqlite/encoder.cs
index f6c41e6..6791629 100644
--- a/src/sqlite/encoder.cs
+++ b/src/sqlite/encoder.cs
@@ -145,8 +145,13 @@ class SqliteEncoder : Sqlite
//personID can be -1 to get all on that session
//sessionID can be -1 to get all sessions
//signalOrCurve can be "all"
+
+ //orderIDascendent is good for all the situations except when we want to convert from 1.05 to 1.06
+ //in that conversion, we want first the last ones, and later the previous
+ // (to delete them if they are old copies)
public static ArrayList Select (bool dbconOpened,
- int uniqueID, int personID, int sessionID, string signalOrCurve, bool onlyActive)
+ int uniqueID, int personID, int sessionID, string signalOrCurve,
+ bool onlyActive, bool orderIDascendent)
{
if(! dbconOpened)
dbcon.Open();
@@ -177,6 +182,10 @@ class SqliteEncoder : Sqlite
if(onlyActive)
onlyActiveString = " AND " + Constants.EncoderTable + ".status = 'active' ";
+ string orderIDstr = "";
+ if(! orderIDascendent)
+ orderIDstr = " DESC";
+
dbcmd.CommandText = "SELECT " +
Constants.EncoderTable + ".*, " + Constants.EncoderExerciseTable + ".name FROM " +
Constants.EncoderTable + ", " + Constants.EncoderExerciseTable +
@@ -184,7 +193,8 @@ class SqliteEncoder : Sqlite
andString + Constants.EncoderTable + ".exerciseID = " +
Constants.EncoderExerciseTable + ".uniqueID " +
onlyActiveString +
- " ORDER BY substr(filename,-23,19), uniqueID DESC "; //'filename,-23,19' contains the
date of capture signal
+ " ORDER BY substr(filename,-23,19), " + //'filename,-23,19' has the date of capture
signal
+ "uniqueID " + orderIDstr;
Log.WriteLine(dbcmd.CommandText.ToString());
@@ -318,7 +328,7 @@ class SqliteEncoder : Sqlite
dbcmd.CommandText = "INSERT INTO " + Constants.EncoderSignalCurveTable +
" (uniqueID, signalID, curveID, msCentral, future1) " +
"VALUES (NULL, " + signalID + ", " + curveID + ", " + msCentral + ", '')";
- //Log.WriteLine(dbcmd.CommandText.ToString());
+ Log.WriteLine(dbcmd.CommandText.ToString());
dbcmd.ExecuteNonQuery();
if(! dbconOpened)
@@ -328,31 +338,38 @@ class SqliteEncoder : Sqlite
//signalID == -1 (any signal)
//curveID == -1 (any curve)
- public static ArrayList SelectSignalCurve (bool dbconOpened, int signalID, int curveID)
+ //if msStart and msEnd != -1 (means find a curve with msCentral contained between both values)
+ public static ArrayList SelectSignalCurve (bool dbconOpened, int signalID, int curveID, double
msStart, double msEnd)
{
if(! dbconOpened)
dbcon.Open();
+ string whereStr = "";
+ if(signalID != -1 || curveID != -1 || msStart != -1)
+ whereStr = " WHERE ";
+
string signalIDstr = "";
if(signalID != -1)
signalIDstr = " signalID == " + signalID;
string curveIDstr = "";
- if(curveID != -1)
+ if(curveID != -1) {
curveIDstr = " curveID == " + curveID;
+ if(signalID != -1)
+ curveIDstr = " AND" + curveIDstr;
+ }
- string whereStr = "";
- if(signalID != -1 || curveID != -1)
- whereStr = " WHERE ";
-
- string andStr = "";
- if(signalID != -1 && curveID != -1)
- andStr = " AND ";
+ string msCentralstr = "";
+ if(msStart != -1) {
+ msCentralstr = " msCentral >= " + msStart + " AND msCentral <= " + msEnd;
+ if(signalID != -1 || curveID != -1)
+ msCentralstr = " AND" + msCentralstr;
+ }
dbcmd.CommandText =
"SELECT uniqueID, signalID, curveID, msCentral " +
" FROM " + Constants.EncoderSignalCurveTable +
- whereStr + signalIDstr + andStr + curveIDstr;
+ whereStr + signalIDstr + curveIDstr + msCentralstr;
Log.WriteLine(dbcmd.CommandText.ToString());
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index 66125da..6589a24 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -1497,8 +1497,8 @@ class Sqlite
SqliteEncoder.createTableEncoderSignalCurve();
- ArrayList signals = SqliteEncoder.Select(true, -1, -1, -1, "signal", false);
- ArrayList curves = SqliteEncoder.Select(true, -1, -1, -1, "curve", false);
+ ArrayList signals = SqliteEncoder.Select(true, -1, -1, -1, "signal", false,
false);
+ ArrayList curves = SqliteEncoder.Select(true, -1, -1, -1, "curve", false,
false);
int signalID;
conversionRateTotal = signals.Count;
conversionRate = 1;
@@ -1534,7 +1534,7 @@ class Sqlite
* except the curves of the first kind, that we know
exactly that they are duplicated
*/
- //curves come sorted by UniqueID DESC
+ //curves come sorted by UniqueID DESC (selected with
orderIDascendent = false)
//if does not exist: insert in encoderSignalCurve
bool exists = false;
foreach(int ms in curvesStored)
diff --git a/src/sqlite/personSession.cs b/src/sqlite/personSession.cs
index 3228c56..0d7390f 100644
--- a/src/sqlite/personSession.cs
+++ b/src/sqlite/personSession.cs
@@ -424,7 +424,7 @@ class SqlitePersonSession : Sqlite
//delete encoder signal and curves (and it's videos)
ArrayList encoderArray = SqliteEncoder.Select(true, -1,
- Convert.ToInt32(personID), Convert.ToInt32(sessionID), "signal", false);
+ Convert.ToInt32(personID), Convert.ToInt32(sessionID), "signal", false, true);
foreach(EncoderSQL eSQL in encoderArray) {
Util.FileDelete(eSQL.GetFullURL(false)); //signal, don't convertPathToR
if(eSQL.future2 != "")
@@ -432,7 +432,7 @@ class SqlitePersonSession : Sqlite
Sqlite.Delete(true, Constants.EncoderTable, Convert.ToInt32(eSQL.uniqueID));
}
encoderArray = SqliteEncoder.Select(true, -1,
- Convert.ToInt32(personID), Convert.ToInt32(sessionID), "curve", false);
+ Convert.ToInt32(personID), Convert.ToInt32(sessionID), "curve", false, true);
foreach(EncoderSQL eSQL in encoderArray) {
Util.FileDelete(eSQL.GetFullURL(false)); //don't convertPathToR
/* commented: curve has no video
@@ -440,6 +440,7 @@ class SqlitePersonSession : Sqlite
Util.FileDelete(eSQL.future2);
*/
Sqlite.Delete(true, Constants.EncoderTable, Convert.ToInt32(eSQL.uniqueID));
+ SqliteEncoder.DeleteSignalCurveWithCurveID(true, Convert.ToInt32(eSQL.uniqueID));
}
diff --git a/src/sqlite/session.cs b/src/sqlite/session.cs
index ef5b055..0d3a9c8 100644
--- a/src/sqlite/session.cs
+++ b/src/sqlite/session.cs
@@ -630,7 +630,7 @@ class SqliteSession : Sqlite
//delete encoder signal and curves (and it's videos)
ArrayList encoderArray = SqliteEncoder.Select(true, -1, -1,
- Convert.ToInt32(uniqueID), "signal", false);
+ Convert.ToInt32(uniqueID), "signal", false, true);
foreach(EncoderSQL eSQL in encoderArray) {
Util.FileDelete(eSQL.GetFullURL(false)); //signal, don't convertPathToR
if(eSQL.future2 != "")
@@ -638,7 +638,7 @@ class SqliteSession : Sqlite
Sqlite.Delete(true, Constants.EncoderTable, Convert.ToInt32(eSQL.uniqueID));
}
encoderArray = SqliteEncoder.Select(true, -1, -1,
- Convert.ToInt32(uniqueID), "curve", false);
+ Convert.ToInt32(uniqueID), "curve", false, true);
foreach(EncoderSQL eSQL in encoderArray) {
Util.FileDelete(eSQL.GetFullURL(false)); //don't convertPathToR
/* commented: curve has no video
@@ -646,6 +646,7 @@ class SqliteSession : Sqlite
Util.FileDelete(eSQL.future2);
*/
Sqlite.Delete(true, Constants.EncoderTable, Convert.ToInt32(eSQL.uniqueID));
+ SqliteEncoder.DeleteSignalCurveWithCurveID(true, Convert.ToInt32(eSQL.uniqueID));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]