[chronojump] Encoder: analyze image can be saevd
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Encoder: analyze image can be saevd
- Date: Sat, 13 Apr 2013 14:21:01 +0000 (UTC)
commit fb75f817f93f4e3dee00884828cda5d00c58e264
Author: Xavier de Blas <xaviblas gmail com>
Date: Sat Apr 13 16:20:37 2013 +0200
Encoder: analyze image can be saevd
glade/chronojump.glade | 16 +++++++---
src/constants.cs | 2 ++
src/gui/chronojump.cs | 6 ++--
src/gui/encoder.cs | 86 +++++++++++++++++++++++++++++++++++++++++++-------
4 files changed, 91 insertions(+), 19 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 1f58446..8efd86a 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -12118,9 +12118,6 @@ on current Chronojump version.</property>
</packing>
</child>
<child>
- <placeholder/>
- </child>
- <child>
<widget class="GtkSpinButton"
id="spin_encoder_extra_weight">
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -12143,6 +12140,9 @@ on current Chronojump version.</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
@@ -13663,17 +13663,23 @@ on current Chronojump version.</property>
</child>
<child>
<widget class="GtkVBox" id="vbox89">
+ <property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <widget class="GtkButton"
id="button_encoder_analyze_zoom">
+ <widget class="GtkButton"
id="button_encoder_analyze_image_save">
+ <property name="visible">True</property>
+ <property name="sensitive">False</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_analyze_image_save_clicked" swapped="no"/>
<accelerator key="z" signal="clicked"/>
<child>
- <widget class="GtkImage"
id="image_encoder_analyze_zoom">
+ <widget class="GtkImage"
id="image_encoder_analyze_image_save">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="tooltip" translatable="yes">Save
image</property>
+ <property name="stock">gtk-save</property>
</widget>
</child>
</widget>
diff --git a/src/constants.cs b/src/constants.cs
index 3172ac2..d3ae47f 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -594,6 +594,8 @@ public class Constants
//if this name changes, change it in encoder/graph.R
public static string EncoderGraphInputMulti = "chronojump-encoder-graph-input-multi.csv";
+ public enum EncoderCheckFileOp { ANALYZE_EXPORT_ALL_CURVES, ANALYZE_SAVE_IMAGE}
+
public enum DoubleContact {
FIRST, AVERAGE, LAST
}
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 9d02dc3..283d43c 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -250,7 +250,7 @@ public partial class ChronoJumpWindow
//encoder
[Widget] Gtk.Image image_encoder_capture_zoom;
- [Widget] Gtk.Image image_encoder_analyze_zoom;
+ //[Widget] Gtk.Image image_encoder_analyze_zoom;
[Widget] Gtk.Image image_encoder_analyze_stats;
[Widget] Gtk.Image image_encoder_signal_delete;
@@ -745,8 +745,8 @@ public partial class ChronoJumpWindow
image_multi_chronopic_zoom.Pixbuf = pixbuf;
//encoder
- pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameZoomInIcon);
- image_encoder_analyze_zoom.Pixbuf = pixbuf;
+ //pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameZoomInIcon);
+ //image_encoder_analyze_zoom.Pixbuf = pixbuf;
pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "gpm-statistics.png");
image_encoder_analyze_stats.Pixbuf = pixbuf;
pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "stock_delete.png");
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index d20dbd3..2685e98 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -78,6 +78,8 @@ public partial class ChronoJumpWindow
[Widget] Gtk.Box hbox_encoder_analyze_data_compare;
[Widget] Gtk.ComboBox combo_encoder_analyze_data_compare;
[Widget] Gtk.Button button_encoder_analyze_data_compare;
+
+ [Widget] Gtk.Button button_encoder_analyze_image_save;
[Widget] Gtk.RadioButton radiobutton_encoder_analyze_powerbars;
[Widget] Gtk.RadioButton radiobutton_encoder_analyze_cross;
@@ -916,7 +918,7 @@ public partial class ChronoJumpWindow
void on_button_encoder_export_all_curves_clicked (object o, EventArgs args)
{
- checkFile();
+ checkFile(Constants.EncoderCheckFileOp.ANALYZE_EXPORT_ALL_CURVES);
}
void on_button_encoder_export_all_curves_file_selected (string selectedFileName)
@@ -962,9 +964,19 @@ public partial class ChronoJumpWindow
}
string exportFileName;
- protected void checkFile ()
+ protected void checkFile (Constants.EncoderCheckFileOp checkFileOp)
{
- string exportString = Catalog.GetString ("Export session in format CSV");
+ string exportString = "";
+ if(checkFileOp == Constants.EncoderCheckFileOp.ANALYZE_EXPORT_ALL_CURVES)
+ exportString = Catalog.GetString ("Export session in format CSV");
+ else if(checkFileOp == Constants.EncoderCheckFileOp.ANALYZE_SAVE_IMAGE)
+ exportString = Catalog.GetString ("Save image");
+
+ string nameString = "";
+ if(checkFileOp == Constants.EncoderCheckFileOp.ANALYZE_EXPORT_ALL_CURVES)
+ nameString = "encoder_export.csv";
+ else if(checkFileOp == Constants.EncoderCheckFileOp.ANALYZE_SAVE_IMAGE)
+ nameString = "encoder_image.png";
Gtk.FileChooserDialog fc=
new Gtk.FileChooserDialog(exportString,
@@ -973,12 +985,14 @@ public partial class ChronoJumpWindow
Catalog.GetString("Cancel"),ResponseType.Cancel,
Catalog.GetString("Export"),ResponseType.Accept
);
+ fc.CurrentName = nameString;
if (fc.Run() == (int)ResponseType.Accept)
{
exportFileName = fc.Filename;
//add ".csv" if needed
- exportFileName = Util.AddCsvIfNeeded(exportFileName);
+ if(checkFileOp == Constants.EncoderCheckFileOp.ANALYZE_EXPORT_ALL_CURVES)
+ exportFileName = Util.AddCsvIfNeeded(exportFileName);
try {
if (File.Exists(exportFileName)) {
Log.WriteLine(string.Format(
@@ -990,18 +1004,30 @@ public partial class ChronoJumpWindow
ConfirmWindow confirmWin = ConfirmWindow.Show(Catalog.GetString(
"Are you sure you want to overwrite file: "),
"",
exportFileName);
- confirmWin.Button_accept.Clicked += new
EventHandler(on_overwrite_file_accepted);
+
+ if(checkFileOp ==
Constants.EncoderCheckFileOp.ANALYZE_EXPORT_ALL_CURVES)
+ confirmWin.Button_accept.Clicked +=
+ new
EventHandler(on_overwrite_file_export_all_curves_accepted);
+ else if(checkFileOp ==
Constants.EncoderCheckFileOp.ANALYZE_SAVE_IMAGE)
+ confirmWin.Button_accept.Clicked +=
+ new
EventHandler(on_overwrite_file_encoder_save_image_accepted);
+
} else {
- on_button_encoder_export_all_curves_file_selected (exportFileName);
+ if(checkFileOp ==
Constants.EncoderCheckFileOp.ANALYZE_EXPORT_ALL_CURVES)
+ on_button_encoder_export_all_curves_file_selected
(exportFileName);
+ else if(checkFileOp ==
Constants.EncoderCheckFileOp.ANALYZE_SAVE_IMAGE)
+ on_button_encoder_save_image_file_selected (exportFileName);
- string myString = string.Format(Catalog.GetString("Exported to {0}"),
- exportFileName) + Constants.SpreadsheetString;
+ string myString = string.Format(Catalog.GetString("Saved to {0}"),
+ exportFileName);
+ if(checkFileOp ==
Constants.EncoderCheckFileOp.ANALYZE_EXPORT_ALL_CURVES)
+ myString += Constants.SpreadsheetString;
new DialogMessage(Constants.MessageTypes.INFO, myString);
}
}
catch {
string myString = string.Format(
- Catalog.GetString("Cannot export to file {0} "),
exportFileName);
+ Catalog.GetString("Cannot save file {0} "), exportFileName);
new DialogMessage(Constants.MessageTypes.WARNING, myString);
}
}
@@ -1018,14 +1044,22 @@ public partial class ChronoJumpWindow
return;
}
- private void on_overwrite_file_accepted(object o, EventArgs args)
+ private void on_overwrite_file_export_all_curves_accepted(object o, EventArgs args)
{
on_button_encoder_export_all_curves_file_selected (exportFileName);
- string myString = string.Format(Catalog.GetString("Exported to {0}"),
+ string myString = string.Format(Catalog.GetString("Saved to {0}"),
exportFileName) + Constants.SpreadsheetString;
new DialogMessage(Constants.MessageTypes.INFO, myString);
}
+ private void on_overwrite_file_encoder_save_image_accepted(object o, EventArgs args)
+ {
+ on_button_encoder_save_image_file_selected (exportFileName);
+
+ string myString = string.Format(Catalog.GetString("Saved to {0}"), exportFileName);
+ new DialogMessage(Constants.MessageTypes.INFO, myString);
+ }
+
void on_button_encoder_delete_signal_clicked (object o, EventArgs args)
{
@@ -1971,6 +2005,28 @@ Log.WriteLine(str);
check_encoder_analyze_eccon_together.Sensitive = true;
}
}
+
+ void on_button_encoder_analyze_image_save_clicked (object o, EventArgs args)
+ {
+ /* file is in:
+ * /tmp/chronojump-last-encoder-graph.png
+ * but if a capture curves has done, file is named the same
+ * make unsensitive the capture image after loading or capturing a new signal
+ * or changing person, loading session, ...
+ */
+
+ checkFile(Constants.EncoderCheckFileOp.ANALYZE_SAVE_IMAGE);
+ }
+ void on_button_encoder_save_image_file_selected (string destination)
+ {
+ try {
+ File.Copy(Util.GetEncoderGraphTempFileName(), destination, true);
+ } catch {
+ string myString = string.Format(
+ Catalog.GetString("Cannot save file {0} "), destination);
+ new DialogMessage(Constants.MessageTypes.WARNING, myString);
+ }
+ }
void on_button_encoder_exercise_info_clicked (object o, EventArgs args)
{
@@ -2707,6 +2763,7 @@ Log.Write("l");
image_encoder_capture.Sensitive = false;
image_encoder_analyze.Sensitive = false;
treeview_encoder_analyze_curves.Sensitive = false;
+ button_encoder_analyze_image_save.Sensitive = false;
//put some data just in case user doesn't click on compare button
encoderCompareInitialize();
@@ -3007,7 +3064,10 @@ Log.Write("l");
encoderThreadR = new Thread(new ThreadStart(analyze));
GLib.Idle.Add (new GLib.IdleHandler (pulseGTKEncoderAnalyze));
+
encoderButtonsSensitive(encoderSensEnum.PROCESSINGR);
+ button_encoder_analyze_image_save.Sensitive = false;
+
encoderThreadR.Start();
}
}
@@ -3168,6 +3228,9 @@ Log.Write("l");
}
encoder_pulsebar_capture.Fraction = 1;
+ //analyze_image_save only has not to be sensitive now because capture graph will be
saved
+ image_encoder_analyze.Sensitive = false;
+ button_encoder_analyze_image_save.Sensitive = false;
} else { //ANALYZE
if(encoderProcessCancel) {
@@ -3189,6 +3252,7 @@ Log.Write("l");
encoder_pulsebar_analyze.Fraction = 1;
encoderButtonsSensitive(encoderSensEnumStored);
image_encoder_analyze.Sensitive = true;
+ button_encoder_analyze_image_save.Sensitive = true;
treeview_encoder_analyze_curves.Sensitive = true;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]