[chronojump] Jumps profile shows person, date, better radius lines, ...



commit 74c9a2b7cbd8cb286db26ec1ba65cbf9a0f75148
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Jun 5 12:45:05 2018 +0200

    Jumps profile shows person, date, better radius lines, ...

 glade/app1.glade        | 61 +++++++++++++++++++++----------------------------
 src/gui/chronojump.cs   |  2 +-
 src/gui/jumpsProfile.cs | 52 ++++++++++++++++++++++-------------------
 3 files changed, 56 insertions(+), 59 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 786e463f..985c46d3 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -1743,6 +1743,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>
@@ -14634,26 +14637,30 @@ on current Chronojump version.</property>
                                                     <property name="visible">True</property>
                                                     <property name="can_focus">False</property>
                                                     <child>
-                                                      <widget class="GtkHBox" 
id="hbox_jumps_profile_jumps_done">
+                                                      <widget class="GtkAlignment" id="alignment26">
                                                         <property name="visible">True</property>
                                                         <property name="can_focus">False</property>
-                                                        <property name="border_width">10</property>
-                                                        <property name="spacing">20</property>
+                                                        <property name="top_padding">12</property>
+                                                        <property name="left_padding">50</property>
                                                         <child>
-                                                          <widget class="GtkLabel" id="label373">
+                                                          <widget class="GtkHBox" 
id="hbox_jumps_profile_jumps_done">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="spacing">20</property>
+                                                            <child>
+                                                            <widget class="GtkLabel" id="label373">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="label" 
translatable="yes">Jumps</property>
-                                                          </widget>
-                                                          <packing>
+                                                            </widget>
+                                                            <packing>
                                                             <property name="expand">False</property>
                                                             <property name="fill">False</property>
-                                                            <property name="padding">40</property>
                                                             <property name="position">0</property>
-                                                          </packing>
-                                                        </child>
-                                                        <child>
-                                                          <widget class="GtkTable" id="table9">
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkTable" id="table9">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="n_rows">2</property>
@@ -14880,12 +14887,14 @@ on current Chronojump version.</property>
                                                             <property name="bottom_attach">2</property>
                                                             </packing>
                                                             </child>
-                                                          </widget>
-                                                          <packing>
+                                                            </widget>
+                                                            <packing>
                                                             <property name="expand">False</property>
                                                             <property name="fill">False</property>
                                                             <property name="position">1</property>
-                                                          </packing>
+                                                            </packing>
+                                                            </child>
+                                                          </widget>
                                                         </child>
                                                       </widget>
                                                       <packing>
@@ -19566,27 +19575,6 @@ Concentric</property>
                                                             <placeholder/>
                                                             </child>
                                                             <child>
-                                                            <placeholder/>
-                                                            </child>
-                                                            <child>
-                                                            <placeholder/>
-                                                            </child>
-                                                            <child>
-                                                            <placeholder/>
-                                                            </child>
-                                                            <child>
-                                                            <placeholder/>
-                                                            </child>
-                                                            <child>
-                                                            <placeholder/>
-                                                            </child>
-                                                            <child>
-                                                            <placeholder/>
-                                                            </child>
-                                                            <child>
-                                                            <placeholder/>
-                                                            </child>
-                                                            <child>
                                                             <widget class="GtkLabel" 
id="label_force_sensor_ai_rfd_a">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
@@ -27972,6 +27960,9 @@ then click this button.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index f4870bd6..9a9eab2b 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -7169,7 +7169,7 @@ LogB.Debug("X");
                }
 
                JumpsProfileGraph.Do(jumpsProfile.GetIndexes(), drawingarea_jumps_profile,
-                               currentPerson.Name + "(" + currentSession.DateShort + ")");
+                               currentPerson.Name, currentSession.DateShort);
        }
        private void on_drawingarea_jumps_profile_expose_event (object o, ExposeEventArgs args) 
        {
diff --git a/src/gui/jumpsProfile.cs b/src/gui/jumpsProfile.cs
index 43a32422..45804e18 100644
--- a/src/gui/jumpsProfile.cs
+++ b/src/gui/jumpsProfile.cs
@@ -1,14 +1,4 @@
-/*
-Que hi hagi caselles del que falta a dalt de la imatge de jumps profile
-aixi si guarden la imatge no sortira
-o que estiguin en la imatge si falten salts
-
-i a la part superior de la imatge que surti la persona i la data
 
-i canviar els fors al pintar
-posar un missatge si falten totes les dades
-i si hi ha dades que hi hagi un for per cada capacitat i que es cridi a una funcio que posi el text, la 
barra, missatge d'error si cal
-*/
 /*
  * This file is part of ChronoJump
  *
@@ -63,7 +53,7 @@ public static class JumpsProfileGraph
                }
        }
 
-       public static void Do (List<JumpsProfileIndex> l_jpi, DrawingArea area, string title)
+       public static void Do (List<JumpsProfileIndex> l_jpi, DrawingArea area, string title, string date)
        {
                //1 create context
                Cairo.Context g = Gdk.CairoHelper.Create (area.GdkWindow);
@@ -86,7 +76,8 @@ public static class JumpsProfileGraph
                if(sum == 0)
                {
                        g.SetSourceRGB(0,0,0);
-                       printText(100, 100, 24, textHeight, "Please, perform the needed jumps marked in red 
above.", g);
+                       g.SetFontSize(16);
+                       printText(100, 100, 24, textHeight, "Please, perform the needed jumps marked in red 
above.", g, false);
                        g.GetTarget().Dispose ();
                        g.Dispose ();
                        return;
@@ -104,28 +95,34 @@ public static class JumpsProfileGraph
                                        acc += percent;
                                }
                        }
+                       //fix last radius line, because ClosePath has been disabled
+                       g.MoveTo (200,50);
+                       g.LineTo (200, 200);
+                       g.LineWidth = 2;
+                       g.Stroke ();
                }
 
                //6 draw legend at right
                int legendX = findLegendTextXPos(l_jpi, sum, 400);
                int y = 40;
-               LogB.Information(string.Format("legendX: {0}, textHeight: {1}", legendX, textHeight));
                //R seq(from=50,to=(350-24),length.out=5)
                //[1] 50 119 188 257 326 #difference is 69
                //g.SelectFontFace("Helvetica", Cairo.FontSlant.Normal, Cairo.FontWeight.Bold);
                foreach(JumpsProfileIndex jpi in l_jpi)
                {
                        double percent = 100 * Util.DivideSafe(jpi.Result, sum);
-                       LogB.Information("percent: " + percent.ToString());
-                       LogB.Information("jpi.Text: " + jpi.Text);
-
-
-                       printText(legendX,  y, 24, textHeight, Util.TrimDecimals(percent, 1) + jpi.Text, g);
+                       printText(legendX,  y, 24, textHeight, Util.TrimDecimals(percent, 1) + jpi.Text, g, 
false);
                        if(percent != 0)
                                drawRoundedRectangle (legendX,  y+30 , Convert.ToInt32(2 * percent), 20, 4, 
g, jpi.Color);
 
                        y += 69;
                }
+               //print title and date
+               g.SetFontSize(18);
+               printText(200, y, 0, textHeight, title, g, true);
+               g.SetFontSize(textHeight);
+               printText(200, y+20, 0, textHeight, "Chronojump profile (" + date + ")", g, true);
+
                //g.SelectFontFace("Helvetica", Cairo.FontSlant.Normal, Cairo.FontWeight.Normal);
        
                //7 print errors (if any)
@@ -133,7 +130,7 @@ public static class JumpsProfileGraph
                y = 70;
                foreach(JumpsProfileIndex jpi in l_jpi) {
                        if(jpi.ErrorMessage != "")
-                               printText(legendX +12,  y, 24, textHeight, jpi.ErrorMessage, g);
+                               printText(legendX +12,  y, 24, textHeight, jpi.ErrorMessage, g, false);
                        y += 69;
                }
                
@@ -148,7 +145,9 @@ public static class JumpsProfileGraph
                //pie chart
                g.MoveTo (centerx,  centery);
                g.Arc(centerx, centery, radius, start * Math.PI, end * Math.PI);
-               g.ClosePath();
+
+               //commented because gets ugly on last radius line (specially if angle is low)
+               //g.ClosePath();
                g.SetSourceRGB(color.R, color.G, color.B);
                g.FillPreserve ();
 
@@ -156,10 +155,17 @@ public static class JumpsProfileGraph
                g.LineWidth = 2;
                g.Stroke ();
        }
-       
-       private static void printText (int x, int y, int height, int textHeight, string text, Cairo.Context 
g) 
+
+       private static void printText (int x, int y, int height, int textHeight, string text, Cairo.Context 
g, bool centered)
        {
-               g.MoveTo(x, ((y+y+height)/2) + textHeight/2.0);
+               int moveToLeft = 0;
+               if(centered)
+               {
+                       Cairo.TextExtents te;
+                       te = g.TextExtents(text);
+                       moveToLeft = Convert.ToInt32(te.Width/2);
+               }
+               g.MoveTo( x - moveToLeft, ((y+y+height)/2) + textHeight/2 );
                g.ShowText(text);
        }
 


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