[chronojump] force sensor signal file can be saved



commit 71cdc877a27742cb5a1bd5deda475ebf42f62f44
Author: Xavier de Blas <xaviblas gmail com>
Date:   Sat Oct 28 12:25:14 2017 +0200

    force sensor signal file can be saved

 glade/app1.glade       |   80 ++++++++++++++++++++++++++++++++++++++++++++++-
 src/constants.cs       |    2 +-
 src/gui/encoder.cs     |   24 +++++++++-----
 src/gui/forceSensor.cs |   70 +++++++++++++++++++++++++++++------------
 4 files changed, 144 insertions(+), 32 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 0e6f824..04057e3 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -1411,6 +1411,9 @@
                                                             <placeholder/>
                                                             </child>
                                                             <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
                                                             <widget class="GtkLabel" 
id="label_start_selector_jumps">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
@@ -10866,6 +10869,11 @@ after time</property>
                                                             <property name="can_focus">True</property>
                                                             <property name="position">400</property>
                                                             <child>
+                                                            <widget class="GtkHBox" id="hbox17">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="spacing">6</property>
+                                                            <child>
                                                             <widget class="GtkVBox" id="vbox110">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
@@ -11050,6 +11058,71 @@ after time</property>
                                                             </child>
                                                             </widget>
                                                             <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkVBox" id="vbox72">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <child>
+                                                            <widget class="GtkButton" 
id="button_force_sensor_image_save_signal">
+                                                            <property name="visible">True</property>
+                                                            <property name="sensitive">False</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property name="receives_default">True</property>
+                                                            <property name="tooltip" translatable="yes">Save 
image</property>
+                                                            <signal name="clicked" 
handler="on_button_force_sensor_image_save_signal_clicked" swapped="no"/>
+                                                            <child>
+                                                            <widget class="GtkVBox" id="vbox111">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="spacing">4</property>
+                                                            <child>
+                                                            <widget class="GtkImage" 
id="image_forcesensor_analyze_image_save1">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property 
name="stock">gtk-missing-image</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkImage" 
id="image_forcesensor_analyze_image_save3">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="stock">gtk-save</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="pack_type">end</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
                                                             <property name="resize">True</property>
                                                             <property name="shrink">False</property>
                                                             </packing>
@@ -11092,13 +11165,13 @@ after time</property>
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
                                                             <child>
-                                                            <widget class="GtkButton" 
id="button_force_sensor_image_save">
+                                                            <widget class="GtkButton" 
id="button_force_sensor_image_save_rfd">
                                                             <property name="visible">True</property>
                                                             <property name="sensitive">False</property>
                                                             <property name="can_focus">True</property>
                                                             <property name="receives_default">True</property>
                                                             <property name="tooltip" translatable="yes">Save 
image</property>
-                                                            <signal name="clicked" 
handler="on_button_force_sensor_image_save_clicked" swapped="no"/>
+                                                            <signal name="clicked" 
handler="on_button_force_sensor_image_save_rfd_clicked" swapped="no"/>
                                                             <child>
                                                             <widget class="GtkVBox" id="vbox108">
                                                             <property name="visible">True</property>
@@ -21635,6 +21708,9 @@ then click this button.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
diff --git a/src/constants.cs b/src/constants.cs
index 8da0b2f..75a3a22 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -792,7 +792,7 @@ public class Constants
        public enum CheckFileOp {
                ENCODER_CAPTURE_EXPORT_ALL, ENCODER_ANALYZE_SAVE_IMAGE,
                ENCODER_ANALYZE_SAVE_AB, ENCODER_ANALYZE_SAVE_TABLE,
-               FORCESENSOR_SAVE_IMAGE
+               FORCESENSOR_SAVE_IMAGE_SIGNAL, FORCESENSOR_SAVE_IMAGE_RFD
        }
 
        public static double EncoderErrorCode = -1;
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index db7f753..f6fccec 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -1913,7 +1913,8 @@ public partial class ChronoJumpWindow
                if(checkFileOp == Constants.CheckFileOp.ENCODER_CAPTURE_EXPORT_ALL)
                        exportString = Catalog.GetString ("Export set in CSV format");
                else if(checkFileOp == Constants.CheckFileOp.ENCODER_ANALYZE_SAVE_IMAGE ||
-                       checkFileOp == Constants.CheckFileOp.FORCESENSOR_SAVE_IMAGE)
+                       checkFileOp == Constants.CheckFileOp.FORCESENSOR_SAVE_IMAGE_SIGNAL ||
+                       checkFileOp == Constants.CheckFileOp.FORCESENSOR_SAVE_IMAGE_RFD)
                        exportString = Catalog.GetString ("Save image");
                else if(checkFileOp == Constants.CheckFileOp.ENCODER_ANALYZE_SAVE_AB)
                        exportString = Catalog.GetString ("Export repetition in CSV format");
@@ -1923,7 +1924,8 @@ public partial class ChronoJumpWindow
                string nameString = currentPerson.Name + "_" + currentSession.DateShortAsSQL;
 
                //at force sensor we can graph a different person than selected person, so use graph-file 
loaded
-               if(checkFileOp == Constants.CheckFileOp.FORCESENSOR_SAVE_IMAGE)
+               if(checkFileOp == Constants.CheckFileOp.FORCESENSOR_SAVE_IMAGE_SIGNAL ||
+                               checkFileOp == Constants.CheckFileOp.FORCESENSOR_SAVE_IMAGE_RFD)
                {
                        if(lastForceSensorFile == null || lastForceSensorFile == "")
                                nameString = "unnamed";
@@ -1934,7 +1936,8 @@ public partial class ChronoJumpWindow
                if(checkFileOp == Constants.CheckFileOp.ENCODER_CAPTURE_EXPORT_ALL)
                        nameString += "_encoder_set_export.csv";
                else if(checkFileOp == Constants.CheckFileOp.ENCODER_ANALYZE_SAVE_IMAGE ||
-                       checkFileOp == Constants.CheckFileOp.FORCESENSOR_SAVE_IMAGE)
+                       checkFileOp == Constants.CheckFileOp.FORCESENSOR_SAVE_IMAGE_SIGNAL ||
+                       checkFileOp == Constants.CheckFileOp.FORCESENSOR_SAVE_IMAGE_RFD)
                        nameString += ".png";
                else if(checkFileOp == Constants.CheckFileOp.ENCODER_ANALYZE_SAVE_AB)
                        nameString += "_encoder_repetition_export.csv";
@@ -1958,7 +1961,7 @@ public partial class ChronoJumpWindow
                                        checkFileOp == Constants.CheckFileOp.ENCODER_ANALYZE_SAVE_AB ||
                                        checkFileOp == Constants.CheckFileOp.ENCODER_ANALYZE_SAVE_TABLE)
                                exportFileName = Util.AddCsvIfNeeded(exportFileName);
-                       else //ENCODER_ANALYZE_SAVE_IMAGE, FORCESENSOR_SAVE_IMAGE
+                       else //ENCODER_ANALYZE_SAVE_IMAGE, FORCESENSOR_SAVE_IMAGE_SIGNAL, 
FORCESENSOR_SAVE_IMAGE_RFD
                                exportFileName = Util.AddPngIfNeeded(exportFileName);
                        try {
                                if (File.Exists(exportFileName)) {
@@ -1984,9 +1987,12 @@ public partial class ChronoJumpWindow
                                        else if(checkFileOp == 
Constants.CheckFileOp.ENCODER_ANALYZE_SAVE_TABLE)
                                                confirmWin.Button_accept.Clicked += 
                                                        new 
EventHandler(on_overwrite_file_encoder_save_table_accepted);
-                                       else if(checkFileOp == Constants.CheckFileOp.FORCESENSOR_SAVE_IMAGE)
+                                       else if(checkFileOp == 
Constants.CheckFileOp.FORCESENSOR_SAVE_IMAGE_SIGNAL)
                                                confirmWin.Button_accept.Clicked +=
-                                                       new 
EventHandler(on_overwrite_file_forcesensor_save_image_accepted);
+                                                       new 
EventHandler(on_overwrite_file_forcesensor_save_image_signal_accepted);
+                                       else if(checkFileOp == 
Constants.CheckFileOp.FORCESENSOR_SAVE_IMAGE_RFD)
+                                               confirmWin.Button_accept.Clicked +=
+                                                       new 
EventHandler(on_overwrite_file_forcesensor_save_image_rfd_accepted);
 
                                } else {
                                        if(checkFileOp == Constants.CheckFileOp.ENCODER_CAPTURE_EXPORT_ALL)
@@ -1997,8 +2003,10 @@ public partial class ChronoJumpWindow
                                                on_button_encoder_save_AB_file_selected (exportFileName);
                                        else if(checkFileOp == 
Constants.CheckFileOp.ENCODER_ANALYZE_SAVE_TABLE)
                                                on_button_encoder_save_table_file_selected (exportFileName);
-                                       else if(checkFileOp == Constants.CheckFileOp.FORCESENSOR_SAVE_IMAGE)
-                                               on_button_forcesensor_save_image_file_selected 
(exportFileName);
+                                       else if(checkFileOp == 
Constants.CheckFileOp.FORCESENSOR_SAVE_IMAGE_SIGNAL)
+                                               on_button_forcesensor_save_image_signal_file_selected 
(exportFileName);
+                                       else if(checkFileOp == 
Constants.CheckFileOp.FORCESENSOR_SAVE_IMAGE_RFD)
+                                               on_button_forcesensor_save_image_rfd_file_selected 
(exportFileName);
 
                                        string myString = string.Format(Catalog.GetString("Saved to {0}"), 
                                                        exportFileName);
diff --git a/src/gui/forceSensor.cs b/src/gui/forceSensor.cs
index 0e83299..f97894a 100644
--- a/src/gui/forceSensor.cs
+++ b/src/gui/forceSensor.cs
@@ -23,6 +23,7 @@ using System.IO;
 using System.IO.Ports;
 using System.Threading;
 using Gtk;
+using Gdk;
 using Glade;
 using System.Text; //StringBuilder
 using System.Collections.Generic; //List<T>
@@ -40,7 +41,8 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Viewport viewport_force_sensor_graph;
        [Widget] Gtk.Image image_force_sensor_graph;
        [Widget] Gtk.SpinButton spin_force_sensor_calibration_kg_value;
-       [Widget] Gtk.Button button_force_sensor_image_save;
+       [Widget] Gtk.Button button_force_sensor_image_save_signal;
+       [Widget] Gtk.Button button_force_sensor_image_save_rfd;
        [Widget] Gtk.DrawingArea force_capture_drawingarea;
        Gdk.Pixmap force_capture_pixmap = null;
        
@@ -77,14 +79,15 @@ public partial class ChronoJumpWindow
        Gdk.GC pen_red_force_capture;
        Gdk.GC pen_gray_force_capture;
        Pango.Layout layout_force_text;
+       Gdk.Colormap colormapForce = Gdk.Colormap.System;
 
 
        private void force_graphs_init()
        {
-               Gdk.Colormap colormap = Gdk.Colormap.System;
-               colormap.AllocColor (ref UtilGtk.BLACK,true,true);
-               colormap.AllocColor (ref UtilGtk.GRAY,true,true);
-               colormap.AllocColor (ref UtilGtk.RED_PLOTS,true,true);
+               colormapForce = Gdk.Colormap.System;
+               colormapForce.AllocColor (ref UtilGtk.BLACK,true,true);
+               colormapForce.AllocColor (ref UtilGtk.GRAY,true,true);
+               colormapForce.AllocColor (ref UtilGtk.RED_PLOTS,true,true);
 
                pen_black_force_capture = new Gdk.GC(force_capture_drawingarea.GdkWindow);
                pen_black_force_capture.Foreground = UtilGtk.BLACK;
@@ -516,15 +519,17 @@ LogB.Information(" fc C ");
                        } else if(forceProcessCancel)
                        {
                                event_execute_label_message.Text = "Cancelled.";
-                               button_force_sensor_image_save.Sensitive = false;
+                               button_force_sensor_image_save_signal.Sensitive = false;
+                               button_force_sensor_image_save_rfd.Sensitive = false;
                        }
                        else
                                event_execute_label_message.Text = "";
 
-               LogB.Information(" fc D ");
+LogB.Information(" fc D ");
                        LogB.ThreadEnded(); 
 
                        forceSensorButtonsSensitive(true);
+                       button_force_sensor_image_save_signal.Sensitive = true;
 
                        //finish, cancel: sensitive = false
                        hideButtons();
@@ -734,8 +739,8 @@ LogB.Information(" fc R ");
                        lastForceSensorFile = 
Util.RemoveExtension(Util.GetLastPartOfPath(filechooser.Filename));
                        File.Copy(filechooser.Filename, UtilEncoder.GetmifCSVFileName(), true); //can be 
overwritten
 
-                       forceSensorDoRFDGraph();
                        forceSensorDoSignalGraph();
+                       forceSensorDoRFDGraph();
                }
                filechooser.Destroy ();
        }
@@ -763,7 +768,7 @@ LogB.Information(" fc R ");
                                imagePath,
                                image_force_sensor_graph);
                image_force_sensor_graph.Sensitive = true;
-               button_force_sensor_image_save.Sensitive = true;
+               button_force_sensor_image_save_rfd.Sensitive = true;
        }
 
        void forceSensorDoSignalGraph()
@@ -867,6 +872,7 @@ LogB.Information(" fc R ");
                label_force_sensor_value.Text = lastForce.ToString();
                label_force_sensor_value_max.Text = maxForce.ToString();
                label_force_sensor_value_min.Text = minForce.ToString();
+               button_force_sensor_image_save_signal.Sensitive = true;
        }
 
        private void forcePaintTimeValue(int time)
@@ -900,23 +906,45 @@ LogB.Information(" fc R ");
                                fscPoints.GetTimeInPx(0) - textWidth -4, yPx - textHeight/2, 
layout_force_text);
        }
 
-       private void on_button_force_sensor_image_save_clicked (object o, EventArgs args)
+       private void on_button_force_sensor_image_save_signal_clicked (object o, EventArgs args)
        {
-               checkFile(Constants.CheckFileOp.FORCESENSOR_SAVE_IMAGE);
+               checkFile(Constants.CheckFileOp.FORCESENSOR_SAVE_IMAGE_SIGNAL);
        }
-       void on_button_forcesensor_save_image_file_selected (string destination)
+       private void on_button_force_sensor_image_save_rfd_clicked (object o, EventArgs args)
        {
-               try {
-                       File.Copy(UtilEncoder.GetmifTempFileName(), destination, true);
-               } catch {
-                       string myString = string.Format(
-                                       Catalog.GetString("Cannot save file {0} "), destination);
-                       new DialogMessage(Constants.MessageTypes.WARNING, myString);
-               }
+               checkFile(Constants.CheckFileOp.FORCESENSOR_SAVE_IMAGE_RFD);
+       }
+
+       void on_button_forcesensor_save_image_signal_file_selected (string destination)
+       {
+               LogB.Information("CREATING PIXBUF");
+               LogB.Information("force_capture_pixmap is null == " + (force_capture_pixmap == null));
+               LogB.Information("colormapForce is null == " + (colormapForce == null));
+               LogB.Information("force_capture_drawingarea is null == " + (force_capture_drawingarea == 
null));
+               int pixmapW = 0;
+               int pixmapH = 0;
+               force_capture_pixmap.GetSize(out pixmapW, out pixmapH);
+               Gdk.Pixbuf pixbuf = Pixbuf.FromDrawable(force_capture_pixmap, colormapForce,
+                               0, 0, 0, 0, pixmapW, pixmapH);
+
+               LogB.Information("Saving");
+               pixbuf.Save(destination,"png");
+       }
+       private void on_overwrite_file_forcesensor_save_image_signal_accepted(object o, EventArgs args)
+       {
+               on_button_forcesensor_save_image_signal_file_selected (exportFileName);
+
+               string myString = string.Format(Catalog.GetString("Saved to {0}"), exportFileName);
+               new DialogMessage(Constants.MessageTypes.INFO, myString);
+       }
+
+       void on_button_forcesensor_save_image_rfd_file_selected (string destination)
+       {
+               File.Copy(UtilEncoder.GetmifTempFileName(), destination, true);
        }
-       private void on_overwrite_file_forcesensor_save_image_accepted(object o, EventArgs args)
+       private void on_overwrite_file_forcesensor_save_image_rfd_accepted(object o, EventArgs args)
        {
-               on_button_forcesensor_save_image_file_selected (exportFileName);
+               on_button_forcesensor_save_image_rfd_file_selected (exportFileName);
 
                string myString = string.Format(Catalog.GetString("Saved to {0}"), exportFileName);
                new DialogMessage(Constants.MessageTypes.INFO, myString);


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