[chronojump] Jumps profile 95% (need to fix notebook tabs)



commit b9d0412f7ed886d4d888d6c20f401e9a08501f61
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Jun 28 17:53:51 2016 +0200

    Jumps profile 95% (need to fix notebook tabs)

 glade/chronojump.glade  |  149 ++++++++++++++++++++++++++++++++++++++++++++---
 src/gui/chronojump.cs   |   32 +++++++---
 src/gui/jumpsProfile.cs |   94 +++++++++++++++++++++++-------
 3 files changed, 235 insertions(+), 40 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 1325075..77a8607 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -2543,12 +2543,13 @@
                                       </packing>
                                     </child>
                                     <child>
-                                      <widget class="GtkNotebook" id="notebook_30">
+                                      <widget class="GtkNotebook" id="notebook_capture_analyze">
                                         <property name="visible">True</property>
                                         <property name="can_focus">True</property>
                                         <property name="show_border">False</property>
                                         <property name="tab_hborder">10</property>
                                         <property name="tab_vborder">4</property>
+                                        <signal name="switch_page" 
handler="on_notebook_capture_analyze_switch_page" swapped="no"/>
                                         <child>
                                           <widget class="GtkVBox" id="vbox9">
                                             <property name="visible">True</property>
@@ -11975,10 +11976,32 @@ on current Chronojump version.</property>
                                             <property name="visible">True</property>
                                             <property name="can_focus">False</property>
                                             <child>
-                                              <widget class="GtkLabel" id="label168">
+                                              <widget class="GtkHBox" id="hbox198">
                                                 <property name="visible">True</property>
                                                 <property name="can_focus">False</property>
-                                                <property name="label">Chronojump Jumps Profile</property>
+                                                <child>
+                                                  <widget class="GtkLabel" id="label168">
+                                                    <property name="visible">True</property>
+                                                    <property name="can_focus">False</property>
+                                                    <property name="label">Chronojump Jumps 
Profile</property>
+                                                  </widget>
+                                                  <packing>
+                                                    <property name="expand">True</property>
+                                                    <property name="fill">True</property>
+                                                    <property name="position">0</property>
+                                                  </packing>
+                                                </child>
+                                                <child>
+                                                  <widget class="GtkLabel" id="label_jumps_profile_person">
+                                                    <property name="visible">True</property>
+                                                    <property name="can_focus">False</property>
+                                                  </widget>
+                                                  <packing>
+                                                    <property name="expand">True</property>
+                                                    <property name="fill">True</property>
+                                                    <property name="position">1</property>
+                                                  </packing>
+                                                </child>
                                               </widget>
                                               <packing>
                                                 <property name="expand">False</property>
@@ -16767,6 +16790,12 @@ on current Chronojump version.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -21486,6 +21515,12 @@ by you</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -22686,6 +22721,12 @@ by you</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -24378,6 +24419,12 @@ by you</property>
               <placeholder/>
             </child>
             <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
               <widget class="GtkButton" id="button_video_url">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
@@ -25127,6 +25174,12 @@ by you</property>
             <child>
               <placeholder/>
             </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
           </widget>
           <packing>
             <property name="expand">True</property>
@@ -38279,6 +38332,42 @@ options</property>
                             <child>
                               <placeholder/>
                             </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
                           </widget>
                         </child>
                       </widget>
@@ -41042,6 +41131,30 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
@@ -42264,12 +42377,6 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
                                       <placeholder/>
                                     </child>
                                     <child>
-                                      <placeholder/>
-                                    </child>
-                                    <child>
-                                      <placeholder/>
-                                    </child>
-                                    <child>
                                       <widget class="GtkLabel" id="label218">
                                         <property name="visible">True</property>
                                         <property name="can_focus">False</property>
@@ -43469,6 +43576,12 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
                                     <child>
                                       <placeholder/>
                                     </child>
+                                    <child>
+                                      <placeholder/>
+                                    </child>
+                                    <child>
+                                      <placeholder/>
+                                    </child>
                                   </widget>
                                 </child>
                               </widget>
@@ -47555,6 +47668,12 @@ It starts before and arrives there with some speed.</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                       <packing>
                         <property name="left_attach">2</property>
@@ -48419,6 +48538,12 @@ It starts before and arrives there with some speed.</property>
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
@@ -49298,6 +49423,12 @@ It starts before and arrives there with some speed.</property>
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 4817684..04b720c 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -56,6 +56,8 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Notebook notebook_sup;
        [Widget] Gtk.Notebook notebook_sup_contacts;
        [Widget] Gtk.Notebook notebook_capture_graph_table;
+       [Widget] Gtk.Notebook notebook_capture_analyze; //not encoder
+
        
        [Widget] Gtk.Label label_version;
        [Widget] Gtk.Image image_logo;
@@ -193,6 +195,7 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Button button_jumps_rj_result_help_stiffness;
        
        [Widget] Gtk.DrawingArea drawingarea_jumps_profile;
+       [Widget] Gtk.Label label_jumps_profile_person;
        
        
        //runs
@@ -1170,8 +1173,12 @@ public partial class ChronoJumpWindow
 
        private void personChanged() {
                //1) change on jumps, runs, pulse capture graph
-               if(radio_mode_jumps_small.Active) 
+               if(radio_mode_jumps_small.Active) {
                        updateGraphJumpsSimple();
+
+                       if(notebook_capture_analyze.CurrentPage == 2) //Jumps Profile
+                               jumpsProfileDo(true); //calculate data
+               }
                else if(radio_mode_runs_small.Active) 
                        updateGraphRunsSimple();
                else if(radio_mode_reaction_times_small.Active) 
@@ -6508,25 +6515,32 @@ LogB.Debug("X");
        }
        
        JumpsProfileGraph jumpsProfileGraph;
-       private void jumpsProfileDo (bool calculateData, DrawingArea area) 
+       private void jumpsProfileDo (bool calculateData)
        {
                if(currentPerson == null || currentSession == null)
                        return;
                
-               if(jumpsProfileGraph == null)
+               if(jumpsProfileGraph == null) {
                        jumpsProfileGraph = new JumpsProfileGraph();
+                       calculateData = true;
+               }
 
-
-               if(calculateData)
+               if(calculateData) {
                        jumpsProfileGraph.Calculate(currentPerson.UniqueID, currentSession.UniqueID);
+                       label_jumps_profile_person.Text = currentPerson.Name;
+               }
 
-               jumpsProfileGraph.Graph(area);
+               jumpsProfileGraph.Graph(drawingarea_jumps_profile);
        }
        private void on_drawingarea_jumps_profile_expose_event (object o, ExposeEventArgs args) 
        {
-               DrawingArea area = (DrawingArea) o;
-               //jumpsProfileDo(false); //do not calculate data
-               jumpsProfileDo(true, area); //do not calculate data
+               jumpsProfileDo(false); //do not calculate data
+               //data is calculated on switch page (at notebook_capture_analyze) or on change person
+       }
+       
+       private void on_notebook_capture_analyze_switch_page (object o, SwitchPageArgs args) {
+               if(notebook_capture_analyze.CurrentPage == 2)
+                       jumpsProfileDo(true);
        }
 
 
diff --git a/src/gui/jumpsProfile.cs b/src/gui/jumpsProfile.cs
index 7e9b3a2..e901141 100644
--- a/src/gui/jumpsProfile.cs
+++ b/src/gui/jumpsProfile.cs
@@ -43,50 +43,80 @@ public class JumpsProfileGraph
                index3 = l[2];
                index4 = l[3];
                index5 = l[4];
+
+               //indexes cannot be below 0. They ruin the graph
+               //eg: SJ higher than CMJ
+               if(index1 < 0)
+                       index1 = 0;
+               if(index2 < 0)
+                       index2 = 0;
+               if(index3 < 0)
+                       index3 = 0;
+               if(index4 < 0)
+                       index4 = 0;
+               if(index5 < 0)
+                       index5 = 0;
        }
 
        public void Graph (DrawingArea area) 
        {
                Cairo.Context g = Gdk.CairoHelper.Create (area.GdkWindow);
+               
+               //clear (white)
+               g.SetSourceRGB(1,1,1);
+               g.Paint();
 
-               //TODO: delete this             
-               plotArc(100, 100, 50, 0, 0.25, g, new Cairo.Color(1,0,0));
-               plotArc(100, 100, 50, .25, .75, g, new Cairo.Color(0,1,0));
-               plotArc(100, 100, 50, .75, 2, g, new Cairo.Color(0,0,1));
-       
                //palette: http://www.colourlovers.com/palette/7991/%28not_so%29_still_life     
                Cairo.Color color1 = colorFromRGB(90,68,102);
                Cairo.Color color2 = colorFromRGB(240,57,43);
                Cairo.Color color3 = colorFromRGB(254,176,20);
                Cairo.Color color4 = colorFromRGB(250,209,7);
                Cairo.Color color5 = colorFromRGB(235,235,207);
+
+               double sum = index1 + index2 + index3 + index4 + index5;
+               if(sum == 0)
+                       return;
+
+               double acc = 0; //accumulated
                
-               //TODO: use indexes
-               plotArc(300, 200, 150, 0, 0.25, g, color1);
-               plotArc(300, 200, 150, .25, .75, g, color2);
-               plotArc(300, 200, 150, .75, 1.25, g, color3);
-               plotArc(300, 200, 150, 1.25, 1.5, g, color4);
-               plotArc(300, 200, 150, 1.5, 2, g, color5);
+               double percent = 2 * index1 / sum; //*2 to be in range 0*pi - 2*pi
+               plotArc(200, 200, 150, acc, acc + percent, g, color1);
+
+               acc += percent;
+               percent = 2 * index2 / sum; //*2 to be in range 0*pi - 2*pi
+               plotArc(200, 200, 150, acc, acc + percent, g, color2);
+
+               acc += percent;
+               percent = 2 * index3 / sum; //*2 to be in range 0*pi - 2*pi
+               plotArc(200, 200, 150, acc, acc + percent, g, color3);
+
+               acc += percent;
+               percent = 2 * index4 / sum; //*2 to be in range 0*pi - 2*pi
+               plotArc(200, 200, 150, acc, acc + percent, g, color4);
+
+               acc += percent;
+               percent = 2 * index5 / sum; //*2 to be in range 0*pi - 2*pi
+               plotArc(200, 200, 150, acc, acc + percent, g, color5);
 
                int width = 40;
                int height = 24;
                //R seq(from=50,to=(350-24),length.out=5)
                //[1] 50 119 188 257 326 
-               drawRoundedRectangle (500,  50, width, height, 3, g, color1);
-               drawRoundedRectangle (500, 119, width, height, 4, g, color2);
-               drawRoundedRectangle (500, 188, width, height, 5, g, color3);
-               drawRoundedRectangle (500, 257, width, height, 6, g, color4);
-               drawRoundedRectangle (500, 326, width, height, 7, g, color5);
+               drawRoundedRectangle (400,  50, width, height, 3, g, color1);
+               drawRoundedRectangle (400, 119, width, height, 4, g, color2);
+               drawRoundedRectangle (400, 188, width, height, 5, g, color3);
+               drawRoundedRectangle (400, 257, width, height, 6, g, color4);
+               drawRoundedRectangle (400, 326, width, height, 7, g, color5);
        
                g.SelectFontFace("Helvetica", Cairo.FontSlant.Normal, Cairo.FontWeight.Normal);
                int textHeight = 12;
                g.SetFontSize(textHeight);
                
-               printText(560,  50, height, textHeight, "Index 1", g);
-               printText(560, 119, height, textHeight, "Index 2", g);
-               printText(560, 188, height, textHeight, "Index 3", g);
-               printText(560, 257, height, textHeight, "Index 4", g);
-               printText(560, 326, height, textHeight, "Index 5", g);
+               printText(460,  50, height, textHeight, Util.TrimDecimals((100 * index1 / sum),1) + "% F. 
Maximum (SJ100%)", g);
+               printText(460, 119, height, textHeight, Util.TrimDecimals((100 * index2 / sum),1) + "% F. 
Explosive (SJ - SJ100%)", g);
+               printText(460, 188, height, textHeight, Util.TrimDecimals((100 * index3 / sum),1) + "% Hab. 
Elastic (CMJ - SJ)", g);
+               printText(460, 257, height, textHeight, Util.TrimDecimals((100 * index4 / sum),1) + "% Hab. 
Arms (ABK - CMJ)", g);
+               printText(460, 326, height, textHeight, Util.TrimDecimals((100 * index5 / sum),1) + "% F. 
Reactive-reflex (DJa)", g);
 
                g.GetTarget().Dispose ();
                g.Dispose ();
@@ -150,6 +180,26 @@ public class JumpsProfileGraph
        }
 
        private Cairo.Color colorFromRGB(int red, int green, int blue) {
-               return new Cairo.Color(red/255.0, green/255.0, blue/255.0);
+               return new Cairo.Color(red/256.0, green/256.0, blue/256.0);
        }
+
+       //save to png with http://www.mono-project.com/docs/tools+libraries/libraries/Mono.Cairo/tutorial/ 
stroke
+       /*
+       ImageSurface surface = new ImageSurface(Format.ARGB32, 120, 120);
+       Context cr = new Context(surface);
+       // Examples are in 1.0 x 1.0 coordinate space
+       cr.Scale(120, 120);
+
+       // Drawing code goes here
+       cr.LineWidth = 0.1;
+
+       //cr.Color = new Color(0, 0, 0); #deprecated, use this:
+       cr.SetSourceRGBA(0, 0, 0, 1);
+
+       cr.Rectangle(0.25, 0.25, 0.5, 0.5);
+       cr.Stroke();
+
+       surface.WriteToPng("stroke.png");
+       */
+
 }


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