[chronojump] ForceSensor export with file selection dialog to select the name
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] ForceSensor export with file selection dialog to select the name
- Date: Tue, 9 Feb 2021 17:44:05 +0000 (UTC)
commit 5ba875879905110e39c37d73e542d90f20875c61
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Feb 9 18:43:38 2021 +0100
ForceSensor export with file selection dialog to select the name
glade/app1.glade | 7 +++--
src/constants.cs | 1 +
src/forceSensor.cs | 34 +++++++++++++----------
src/gui/app1/encoder.cs | 56 +++++++++++++++++++++++++++++++-------
src/gui/app1/forceSensorAnalyze.cs | 9 +++++-
src/utilEncoder.cs | 1 +
6 files changed, 80 insertions(+), 28 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index bf6213af..9e2c6ac6 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -24336,9 +24336,10 @@ Concentric</property>
<widget class="GtkHBox" id="hbox456">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="spacing">6</property>
<child>
<widget class="GtkProgressBar"
id="progressbar_force_sensor_export">
- <property name="width_request">50</property>
+ <property name="width_request">100</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
</widget>
@@ -24363,8 +24364,8 @@ Concentric</property>
</child>
</widget>
<packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
diff --git a/src/constants.cs b/src/constants.cs
index f480eade..af33fe96 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -1112,6 +1112,7 @@ public class Constants
ENCODER_ANALYZE_SAVE_AB, ENCODER_ANALYZE_SAVE_TABLE,
FORCESENSOR_SAVE_IMAGE_SIGNAL, FORCESENSOR_SAVE_IMAGE_RFD_AUTO,
FORCESENSOR_SAVE_IMAGE_RFD_MANUAL, FORCESENSOR_ANALYZE_SAVE_AB,
+ FORCESENSOR_EXPORT_INDIVIDUAL_CURRENT_SESSION, FORCESENSOR_EXPORT_GROUPAL_CURRENT_SESSION,
RUNENCODER_SAVE_IMAGE, RUNENCODER_SAVE_TABLE
}
diff --git a/src/forceSensor.cs b/src/forceSensor.cs
index 9bb00a33..8e70fea4 100644
--- a/src/forceSensor.cs
+++ b/src/forceSensor.cs
@@ -2262,6 +2262,7 @@ public class ForceSensorExport
//passed variables
private Gtk.Notebook notebook;
private Gtk.ProgressBar progressbar;
+ private string exportFilename;
private bool isWindows;
private int personID; // -1: all
private int sessionID;
@@ -2270,11 +2271,11 @@ public class ForceSensorExport
private int duration;
private int durationPercent;
private double forceSensorElasticEccMinDispl;
- public int forceSensorNotElasticEccMinForce;
- public double forceSensorElasticConMinDispl;
- public int forceSensorNotElasticConMinForce;
- public bool forceSensorStartEndOptimized;
- public string CSVExportDecimalSeparator;
+ private int forceSensorNotElasticEccMinForce;
+ private double forceSensorElasticConMinDispl;
+ private int forceSensorNotElasticConMinForce;
+ private bool forceSensorStartEndOptimized;
+ private string CSVExportDecimalSeparator;
private static Thread thread;
private static bool cancel;
@@ -2320,8 +2321,10 @@ public class ForceSensorExport
}
///public method
- public void Start()
+ public void Start(string exportFilename)
{
+ this.exportFilename = exportFilename;
+
cancel = false;
pulseFraction= 0;
progressbar.Fraction = 0;
@@ -2354,8 +2357,9 @@ public class ForceSensorExport
new DialogMessage(Constants.MessageTypes.INFO,
Catalog.GetString("Cancelled."));
else
new DialogMessage(Constants.MessageTypes.INFO,
- string.Format("Exported to {0}",
- UtilEncoder.GetmifCSVFileName()));
+ string.Format("Exported to {0}", exportFilename) +
+ Constants.GetSpreadsheetString(CSVExportDecimalSeparator)
+ );
return false;
}
@@ -2478,10 +2482,10 @@ public class ForceSensorExport
/*
//copy file to tmp to be written readed by R
File.Copy(fs.FullURL, UtilEncoder.GetmifCSVFileName(), true); //can be overwritten
+ */
//delete result file
Util.FileDelete(UtilEncoder.GetmifExportFileName());
- */
foreach(ForceSensorRepetition rep in fsAI.ForceSensorRepetition_l)
{
@@ -2495,11 +2499,6 @@ public class ForceSensorExport
//TODO: or check cancel when there is a thread, also R should write something blank
if there is any problem
//also the problem with this code is: if R code fails for any reason (bad data), will
exit R code and this file will never be created
- /*
- LogB.Information("Waiting creation of file... ");
- while ( ! ( Util.FileReadable(UtilEncoder.GetmifExportFileName())))
- ;
- */
/*
// 6) write exportedRFDs (includes impulse)
if(File.Exists(UtilEncoder.GetmifExportFileName()))
@@ -2536,6 +2535,13 @@ public class ForceSensorExport
bool success = fsg.CallR(imageWidth -5, imageHeight -5, false);
}
+
+ LogB.Information("Waiting creation of file... ");
+ while ( ! ( Util.FileReadable(UtilEncoder.GetmifExportFileName())))
+ ;
+
+ File.Copy(UtilEncoder.GetmifExportFileName(), exportFilename, true);
+
/*
ForceSensorGraph fsg = new ForceSensorGraph(
//fs.CaptureOption,
diff --git a/src/gui/app1/encoder.cs b/src/gui/app1/encoder.cs
index 87a4273d..ab7d557f 100644
--- a/src/gui/app1/encoder.cs
+++ b/src/gui/app1/encoder.cs
@@ -2086,14 +2086,21 @@ public partial class ChronoJumpWindow
exportString = Catalog.GetString ("Save image");
else if(checkFileOp == Constants.CheckFileOp.ENCODER_ANALYZE_SAVE_AB)
exportString = Catalog.GetString ("Export repetition in CSV format");
- else if(checkFileOp == Constants.CheckFileOp.FORCESENSOR_ANALYZE_SAVE_AB)
+ else if(checkFileOp == Constants.CheckFileOp.FORCESENSOR_ANALYZE_SAVE_AB ||
+ checkFileOp ==
Constants.CheckFileOp.FORCESENSOR_EXPORT_INDIVIDUAL_CURRENT_SESSION ||
+ checkFileOp ==
Constants.CheckFileOp.FORCESENSOR_EXPORT_GROUPAL_CURRENT_SESSION)
exportString = Catalog.GetString ("Export data in CSV format");
else if(checkFileOp == Constants.CheckFileOp.ENCODER_ANALYZE_SAVE_TABLE ||
checkFileOp == Constants.CheckFileOp.RUNENCODER_SAVE_TABLE)
exportString = Catalog.GetString ("Save table");
+ // 2) write the name of the file: nameString
+
string nameString = currentPerson.Name + "_" + currentSession.DateShortAsSQL;
+ if(checkFileOp == Constants.CheckFileOp.FORCESENSOR_EXPORT_GROUPAL_CURRENT_SESSION)
+ nameString = currentSession.DateShortAsSQL;
+
//on encoder analyze save image, show analysis on filename
if(
( checkFileOp == Constants.CheckFileOp.ENCODER_ANALYZE_SAVE_IMAGE ||
@@ -2157,11 +2164,17 @@ public partial class ChronoJumpWindow
nameString += "_encoder_repetition_export.csv";
else if(checkFileOp == Constants.CheckFileOp.FORCESENSOR_ANALYZE_SAVE_AB)
nameString += "_forcesensor_analyze_AB_export.csv";
+ else if(
+ checkFileOp ==
Constants.CheckFileOp.FORCESENSOR_EXPORT_INDIVIDUAL_CURRENT_SESSION ||
+ checkFileOp ==
Constants.CheckFileOp.FORCESENSOR_EXPORT_GROUPAL_CURRENT_SESSION)
+ nameString += "_forcesensor_export.csv";
else if(checkFileOp == Constants.CheckFileOp.ENCODER_ANALYZE_SAVE_TABLE)
nameString += "_encoder_curves_table.csv";
else if(checkFileOp == Constants.CheckFileOp.RUNENCODER_SAVE_TABLE)
nameString += "_raceAnalyzer_table.csv";
-
+
+ // 3) prepare and Run the dialog
+
Gtk.FileChooserDialog fc=
new Gtk.FileChooserDialog(exportString,
app1,
@@ -2178,6 +2191,8 @@ public partial class ChronoJumpWindow
if(checkFileOp == Constants.CheckFileOp.ENCODER_CAPTURE_EXPORT_ALL ||
checkFileOp == Constants.CheckFileOp.ENCODER_ANALYZE_SAVE_AB ||
checkFileOp == Constants.CheckFileOp.FORCESENSOR_ANALYZE_SAVE_AB ||
+ checkFileOp ==
Constants.CheckFileOp.FORCESENSOR_EXPORT_INDIVIDUAL_CURRENT_SESSION ||
+ checkFileOp ==
Constants.CheckFileOp.FORCESENSOR_EXPORT_GROUPAL_CURRENT_SESSION ||
checkFileOp == Constants.CheckFileOp.ENCODER_ANALYZE_SAVE_TABLE ||
checkFileOp == Constants.CheckFileOp.RUNENCODER_SAVE_TABLE)
exportFileName = Util.AddCsvIfNeeded(exportFileName);
@@ -2241,6 +2256,10 @@ public partial class ChronoJumpWindow
else if(checkFileOp ==
Constants.CheckFileOp.FORCESENSOR_ANALYZE_SAVE_AB)
confirmWin.Button_accept.Clicked +=
new
EventHandler(on_overwrite_file_forcesensor_save_AB_accepted);
+ else if(checkFileOp ==
Constants.CheckFileOp.FORCESENSOR_EXPORT_INDIVIDUAL_CURRENT_SESSION ||
+ checkFileOp ==
Constants.CheckFileOp.FORCESENSOR_EXPORT_GROUPAL_CURRENT_SESSION)
+ confirmWin.Button_accept.Clicked +=
+ new
EventHandler(on_overwrite_file_forcesensor_export_accepted);
else if(checkFileOp == Constants.CheckFileOp.RUNENCODER_SAVE_IMAGE)
confirmWin.Button_accept.Clicked +=
new
EventHandler(on_overwrite_file_runencoder_image_save_accepted);
@@ -2279,18 +2298,26 @@ public partial class ChronoJumpWindow
on_button_forcesensor_save_image_rfd_manual_file_selected
(exportFileName);
else if(checkFileOp ==
Constants.CheckFileOp.FORCESENSOR_ANALYZE_SAVE_AB)
on_button_force_sensor_save_AB_file_selected (exportFileName);
+ else if(checkFileOp ==
Constants.CheckFileOp.FORCESENSOR_EXPORT_INDIVIDUAL_CURRENT_SESSION ||
+ checkFileOp ==
Constants.CheckFileOp.FORCESENSOR_EXPORT_GROUPAL_CURRENT_SESSION)
+ on_button_force_sensor_export_file_selected (exportFileName);
else if(checkFileOp == Constants.CheckFileOp.RUNENCODER_SAVE_IMAGE)
on_button_run_encoder_image_save_selected (exportFileName);
else if(checkFileOp == Constants.CheckFileOp.RUNENCODER_SAVE_TABLE)
on_button_raceAnalyzer_save_table_file_selected
(exportFileName);
- string myString = string.Format(Catalog.GetString("Saved to {0}"),
- exportFileName);
- if(checkFileOp == Constants.CheckFileOp.ENCODER_CAPTURE_EXPORT_ALL ||
- checkFileOp ==
Constants.CheckFileOp.ENCODER_ANALYZE_SAVE_AB ||
- checkFileOp ==
Constants.CheckFileOp.FORCESENSOR_ANALYZE_SAVE_AB)
- myString +=
Constants.GetSpreadsheetString(preferences.CSVExportDecimalSeparator);
- new DialogMessage(Constants.MessageTypes.INFO, myString);
+ //show message, but not in long processes managed by a thread
+ if(checkFileOp !=
Constants.CheckFileOp.FORCESENSOR_EXPORT_INDIVIDUAL_CURRENT_SESSION &&
+ checkFileOp !=
Constants.CheckFileOp.FORCESENSOR_EXPORT_GROUPAL_CURRENT_SESSION)
+ {
+ string myString = string.Format(Catalog.GetString("Saved to
{0}"),
+ exportFileName);
+ if(checkFileOp ==
Constants.CheckFileOp.ENCODER_CAPTURE_EXPORT_ALL ||
+ checkFileOp ==
Constants.CheckFileOp.ENCODER_ANALYZE_SAVE_AB ||
+ checkFileOp ==
Constants.CheckFileOp.FORCESENSOR_ANALYZE_SAVE_AB)
+ myString +=
Constants.GetSpreadsheetString(preferences.CSVExportDecimalSeparator);
+ new DialogMessage(Constants.MessageTypes.INFO, myString);
+ }
}
} catch {
string myString = string.Format(
@@ -2356,7 +2383,16 @@ public partial class ChronoJumpWindow
exportFileName) +
Constants.GetSpreadsheetString(preferences.CSVExportDecimalSeparator);
new DialogMessage(Constants.MessageTypes.INFO, myString);
}
-
+ private void on_overwrite_file_forcesensor_export_accepted(object o, EventArgs args)
+ {
+ on_button_force_sensor_export_file_selected (exportFileName);
+
+ /*
+ string myString = string.Format(Catalog.GetString("Saved to {0}"),
+ exportFileName) +
Constants.GetSpreadsheetString(preferences.CSVExportDecimalSeparator);
+ new DialogMessage(Constants.MessageTypes.INFO, myString);
+ */
+ }
void on_button_encoder_delete_signal_clicked (object o, EventArgs args)
{
diff --git a/src/gui/app1/forceSensorAnalyze.cs b/src/gui/app1/forceSensorAnalyze.cs
index fa6a7f19..5e634a62 100644
--- a/src/gui/app1/forceSensorAnalyze.cs
+++ b/src/gui/app1/forceSensorAnalyze.cs
@@ -761,7 +761,14 @@ public partial class ChronoJumpWindow
preferences.forceSensorStartEndOptimized,
preferences.CSVExportDecimalSeparator);
- forceSensorExport.Start();
+ if(personID == -1)
+ checkFile(Constants.CheckFileOp.FORCESENSOR_EXPORT_GROUPAL_CURRENT_SESSION);
+ else
+ checkFile(Constants.CheckFileOp.FORCESENSOR_EXPORT_INDIVIDUAL_CURRENT_SESSION);
+ }
+ private void on_button_force_sensor_export_file_selected (string selectedFileName)
+ {
+ forceSensorExport.Start(selectedFileName);
}
private void on_button_force_sensor_export_cancel_clicked (object o, EventArgs args)
diff --git a/src/utilEncoder.cs b/src/utilEncoder.cs
index cde19960..94cf3caf 100644
--- a/src/utilEncoder.cs
+++ b/src/utilEncoder.cs
@@ -266,6 +266,7 @@ public class UtilEncoder
public static string GetmifTempFileName() {
return Path.Combine(Path.GetTempPath(), "cj_mif_Graph.png");
}
+ //R exports here, then C# move it and rename it
public static string GetmifExportFileName() {
return Path.Combine(Path.GetTempPath(), "cj_mif_export.csv");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]