[chronojump] Encoder: cross variables graph done
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Encoder: cross variables graph done
- Date: Tue, 5 Jun 2012 19:15:45 +0000 (UTC)
commit a93c81627fa80d1899301895d120626167df58e8
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Jun 5 21:15:20 2012 +0200
Encoder: cross variables graph done
encoder/graph.R | 104 +++++++++++++++++-------------------------------
glade/chronojump.glade | 64 ++++++-----------------------
src/gui/encoder.cs | 99 ++++++++++++++++++++++++---------------------
3 files changed, 103 insertions(+), 164 deletions(-)
---
diff --git a/encoder/graph.R b/encoder/graph.R
index d2cee90..52c5610 100644
--- a/encoder/graph.R
+++ b/encoder/graph.R
@@ -409,58 +409,31 @@ paintPowerPeakPowerBars <- function(paf, myEccons) {
axis(4)
mtext("Time at peak power (s)", side=4, line=-1)
}
-
-paintLoadVSPower <- function (paf, option) {
- power=(paf[,3])
- peakPower=(paf[,4])
- x=(paf[,7]) #mass
-
- if(option == "mean") {
- y=power
- ylab="Power (W)"
- }
- else {
- y=peakPower
- ylab="Peak Power (W)"
- }
- #problem with balls is that two values two close looks bad
- #suboption="balls"
- suboption="side"
- if(suboption == "balls") {
- cexBalls = 3
- cexNums = 1
- adjHor = 0.5
- nums=as.character(1:length(x))
- } else if (suboption == "side") {
- cexBalls = 1.8
- cexNums = .8
- adjHor = 0
- nums=paste(" ",as.character(1:length(x)))
- }
-
- plot(x,y, xlab="Mass (Kg)", ylab=ylab,pch=21,col="blue",bg="lightblue",cex=cexBalls)
- text(x,y,nums,adj=c(adjHor,0.5),cex=cexNums)
- lines(smooth.spline(x,y),col="darkblue")
+#see paf for more info
+findPosInPaf <- function(var, option) {
+print("fPIP option")
+print(option)
+ pos = 0
+ if(var == "Speed")
+ pos = 1
+ else if(var == "Power")
+ pos = 3
+ else if(var == "Load") #or Mass
+ pos = 7
+ else if(var == "Force")
+ pos = 8
+ if( ( var == "Speed" || var == "Power" || var == "Force") & option == "max")
+ pos=pos+1
+ return(pos)
}
-
-paintForceVSSpeed <- function (paf,option) {
- meanSpeed=(paf[,1])
- maxSpeed=(paf[,2])
- meanForce=(paf[,8])
- maxForce=(paf[,9])
-
- if(option == "mean") {
- x=meanSpeed
- y=meanForce
- xlab="Mean speed (m/s)"
- ylab="Mean force (N)"
- } else {
- x=maxSpeed
- y=maxForce
- xlab="Max speed (m/s)"
- ylab="Max force (N)"
- }
+
+#option: mean or max
+paintCrossVariables <- function (paf, varX, varY, option) {
+print("pCV option")
+print(option)
+ x = (paf[,findPosInPaf(varX, option)])
+ y = (paf[,findPosInPaf(varY, option)])
#problem with balls is that two values two close looks bad
#suboption="balls"
@@ -477,10 +450,11 @@ paintForceVSSpeed <- function (paf,option) {
nums=paste(" ",as.character(1:length(x)))
}
- plot(x,y, xlab=xlab, ylab=ylab,pch=21,col="blue",bg="lightblue",cex=cexBalls)
- text(x,y,nums,adj=c(adjHor,0.5),cex=cexNums)
- lines(smooth.spline(x,y,spar=.5),col="darkblue")
+ plot(x,y, xlab=varX, ylab=varY, pch=21,col="blue",bg="lightblue",cex=cexBalls)
+ text(x,y,nums,adj=c(adjHor,.5),cex=cexNums)
+ lines(smooth.spline(x,y),col="darkblue")
}
+
find.mfrow <- function(n) {
if(n<=3) return(c(1,n))
else if(n<=6) return(c(2,ceiling(n/2)))
@@ -546,7 +520,7 @@ if(length(args) < 3) {
exercisePercentBodyWeight=as.numeric(args[6]) #was isJump=as.logical(args[6])
mass=as.numeric(args[7])
eccon=args[8]
- analysis=args[9]
+ analysis=args[9] #in cross comes as "cross.force.speed"
smoothingOne=args[10]
jump=args[11]
width=as.numeric(args[12])
@@ -753,12 +727,14 @@ if(length(args) < 3) {
par(new=F)
#print(knRanges)
}
-
+
+ print(analysis)
+ #analysis in cross variables comes as:
+ #"cross.Speed.Force.mean" #2nd is X, 3d is X. "mean" can also be "max"
+ analysisCross = unlist(strsplit(analysis, "\\."))
+ print(analysisCross)
if(
- analysis == "powerBars" ||
- analysis == "loadVSPowerMean" || analysis == "loadVSPowerPeak" ||
- analysis == "forceVSSpeedMean" || analysis == "forceVSSpeedMax" ||
- analysis == "curves")
+ analysis == "powerBars" || analysisCross[1] == "cross" || analysis == "curves")
{
paf = data.frame()
for(i in 1:n) {
@@ -776,14 +752,8 @@ if(length(args) < 3) {
if(analysis == "powerBars")
paintPowerPeakPowerBars(paf, curves[,8]) #myEccon
- else if(analysis == "loadVSPowerMean")
- paintLoadVSPower(paf,"mean")
- else if(analysis == "loadVSPowerPeak")
- paintLoadVSPower(paf,"peak")
- else if(analysis == "forceVSSpeedMean")
- paintForceVSSpeed(paf,"mean")
- else if(analysis == "forceVSSpeedMax")
- paintForceVSSpeed(paf,"max")
+ else if(analysisCross[1] == "cross")
+ paintCrossVariables(paf, analysisCross[3], analysisCross[2], analysisCross[4])
else if(analysis == "curves") {
paf=cbind(curves[,1],curves[,2]-curves[,1],rawdata.cumsum[curves[,2]]-curves[,3],paf)
colnames(paf)=c("start","width","height","meanSpeed","maxSpeed",
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 7defa5c..6a02839 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -25077,34 +25077,20 @@ Evaluator can use real name or nickname.</property>
</packing>
</child>
<child>
- <widget class="GtkRadioButton" id="radiobutton_encoder_analyze_load_vs_power">
- <property name="label" translatable="yes">Load / Power</property>
+ <widget class="GtkRadioButton" id="radiobutton_encoder_analyze_cross">
+ <property name="label" translatable="yes">Cross variables</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<property name="group">radiobutton_encoder_analyze_powerbars</property>
- <signal name="toggled" handler="on_radiobutton_encoder_analyze_load_vs_power_toggled"/>
+ <signal name="toggled" handler="on_radiobutton_encoder_analyze_cross_toggled"/>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
- <widget class="GtkRadioButton" id="radiobutton_encoder_analyze_force_vs_speed">
- <property name="label" translatable="yes">Force / Speed</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="draw_indicator">True</property>
- <property name="group">radiobutton_encoder_analyze_powerbars</property>
- <signal name="toggled" handler="on_radiobutton_encoder_analyze_force_vs_speed_toggled"/>
- </widget>
- <packing>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
<widget class="GtkRadioButton" id="radiobutton_encoder_analyze_side">
<property name="label" translatable="yes">Side compare</property>
<property name="visible">True</property>
@@ -25115,7 +25101,7 @@ Evaluator can use real name or nickname.</property>
<signal name="toggled" handler="on_radiobutton_encoder_analyze_side_toggled"/>
</widget>
<packing>
- <property name="position">3</property>
+ <property name="position">2</property>
</packing>
</child>
<child>
@@ -25129,7 +25115,7 @@ Evaluator can use real name or nickname.</property>
<signal name="toggled" handler="on_radiobutton_encoder_analyze_single_toggled"/>
</widget>
<packing>
- <property name="position">4</property>
+ <property name="position">3</property>
</packing>
</child>
</widget>
@@ -25167,6 +25153,7 @@ Evaluator can use real name or nickname.</property>
<child>
<widget class="GtkHBox" id="hbox92">
<property name="visible">True</property>
+ <property name="spacing">12</property>
<child>
<widget class="GtkHBox" id="hbox_encoder_analyze_curve_num">
<property name="spacing">6</property>
@@ -25203,33 +25190,9 @@ Evaluator can use real name or nickname.</property>
</packing>
</child>
<child>
- <widget class="GtkHBox" id="hbox_encoder_analyze_load_vs_power">
- <property name="spacing">6</property>
+ <widget class="GtkHBox" id="hbox_combo_encoder_analyze_cross">
<child>
- <widget class="GtkRadioButton" id="radiobutton_encoder_analyze_load_vs_power_mean">
- <property name="label" translatable="yes">Mean power</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="active">True</property>
- <property name="draw_indicator">True</property>
- </widget>
- <packing>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <widget class="GtkRadioButton" id="radiobutton_encoder_analyze_load_vs_power_peak">
- <property name="label" translatable="yes">Peak power</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="draw_indicator">True</property>
- <property name="group">radiobutton_encoder_analyze_load_vs_power_mean</property>
- </widget>
- <packing>
- <property name="position">1</property>
- </packing>
+ <placeholder/>
</child>
</widget>
<packing>
@@ -25237,10 +25200,10 @@ Evaluator can use real name or nickname.</property>
</packing>
</child>
<child>
- <widget class="GtkHBox" id="hbox_encoder_analyze_force_vs_speed">
+ <widget class="GtkHBox" id="hbox_encoder_analyze_mean_or_max">
<property name="spacing">6</property>
<child>
- <widget class="GtkRadioButton" id="radiobutton_encoder_analyze_force_vs_speed_mean">
+ <widget class="GtkRadioButton" id="radiobutton_encoder_analyze_mean">
<property name="label" translatable="yes">Mean values</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -25253,13 +25216,13 @@ Evaluator can use real name or nickname.</property>
</packing>
</child>
<child>
- <widget class="GtkRadioButton" id="radiobutton_encoder_analyze_force_vs_speed_max">
+ <widget class="GtkRadioButton" id="radiobutton_encoder_analyze_max">
<property name="label" translatable="yes">Max values</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
- <property name="group">radiobutton_encoder_analyze_force_vs_speed_mean</property>
+ <property name="group">radiobutton_encoder_analyze_mean</property>
</widget>
<packing>
<property name="position">1</property>
@@ -25281,7 +25244,7 @@ Evaluator can use real name or nickname.</property>
<child>
<widget class="GtkHBox" id="hbox74">
<property name="visible">True</property>
- <property name="spacing">12</property>
+ <property name="spacing">10</property>
<child>
<widget class="GtkButton" id="button_encoder_analyze">
<property name="label" translatable="yes">Analyze</property>
@@ -25297,7 +25260,6 @@ Evaluator can use real name or nickname.</property>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="padding">12</property>
<property name="position">0</property>
</packing>
</child>
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index ecd583a..8de7044 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -58,7 +58,8 @@ public partial class ChronoJumpWindow
[Widget] Gtk.ComboBox combo_encoder_eccon;
[Widget] Gtk.Box hbox_combo_encoder_laterality;
[Widget] Gtk.ComboBox combo_encoder_laterality;
-
+ [Widget] Gtk.Box hbox_combo_encoder_analyze_cross;
+ [Widget] Gtk.ComboBox combo_encoder_analyze_cross;
[Widget] Gtk.Button button_encoder_analyze;
[Widget] Gtk.Button button_encoder_analyze_cancel;
@@ -77,13 +78,9 @@ public partial class ChronoJumpWindow
[Widget] Gtk.Box hbox_encoder_analyze_curve_num;
[Widget] Gtk.SpinButton spin_encoder_analyze_curve_num;
- [Widget] Gtk.Box hbox_encoder_analyze_load_vs_power;
- [Widget] Gtk.RadioButton radiobutton_encoder_analyze_load_vs_power_mean;
- [Widget] Gtk.RadioButton radiobutton_encoder_analyze_load_vs_power_peak;
-
- [Widget] Gtk.Box hbox_encoder_analyze_force_vs_speed;
- [Widget] Gtk.RadioButton radiobutton_encoder_analyze_force_vs_speed_mean;
- [Widget] Gtk.RadioButton radiobutton_encoder_analyze_force_vs_speed_max;
+ [Widget] Gtk.Box hbox_encoder_analyze_mean_or_max;
+ [Widget] Gtk.RadioButton radiobutton_encoder_analyze_mean;
+ [Widget] Gtk.RadioButton radiobutton_encoder_analyze_max;
[Widget] Gtk.Viewport viewport_image_encoder_analyze;
[Widget] Gtk.Image image_encoder_analyze;
@@ -141,6 +138,8 @@ public partial class ChronoJumpWindow
//TODO: fix problem that on saving maybe dirs are not created
//
//TODO: on session load, show encoder stuff
+ //
+ //TODO: capture also with webcam an attach it to signal or curve
private void encoderInitializeStuff() {
@@ -581,21 +580,19 @@ public partial class ChronoJumpWindow
string dataFileName = "";
//use this send because we change it to send it to R
- //but we don't want to change encoderAnalysis because we want to know again if == "loadVSPower"
+ //but we don't want to change encoderAnalysis because we want to know again if == "cross"
string sendAnalysis = encoderAnalysis;
- if(sendAnalysis == "loadVSPower") {
- if(radiobutton_encoder_analyze_load_vs_power_mean.Active)
- sendAnalysis = "loadVSPowerMean";
+ if(sendAnalysis == "cross") {
+ string crossName = Util.FindOnArray(':',1,0,UtilGtk.ComboGetActive(combo_encoder_analyze_cross),
+ encoderAnalyzeCrossTranslation);
+ //convert: "Force / Speed" in: "cross.Force.Speed.mean"
+ string [] crossNameFull = crossName.Split(new char[] {' '});
+ sendAnalysis += "." + crossNameFull[0] + "." + crossNameFull[2]; //[1]=="/"
+ if(radiobutton_encoder_analyze_mean.Active)
+ sendAnalysis += ".mean";
else
- sendAnalysis = "loadVSPowerPeak";
- }
-
- if(sendAnalysis == "forceVSSpeed") {
- if(radiobutton_encoder_analyze_force_vs_speed_mean.Active)
- sendAnalysis = "forceVSSpeedMean";
- else
- sendAnalysis = "forceVSSpeedMax";
+ sendAnalysis += ".max";
}
if(radiobutton_encoder_analyze_data_user_curves.Active) {
@@ -690,8 +687,8 @@ public partial class ChronoJumpWindow
//show curve_num only on simple and superpose
private void on_radiobutton_encoder_analyze_single_toggled (object obj, EventArgs args) {
hbox_encoder_analyze_curve_num.Visible=true;
- hbox_encoder_analyze_load_vs_power.Visible=false;
- hbox_encoder_analyze_force_vs_speed.Visible=false;
+ hbox_combo_encoder_analyze_cross.Visible=false;
+ hbox_encoder_analyze_mean_or_max.Visible=false;
encoderAnalysis="single";
//together, mandatory
hbox_encoder_analyze_eccon.Sensitive=false;
@@ -701,8 +698,8 @@ public partial class ChronoJumpWindow
/*
private void on_radiobutton_encoder_analyze_superpose_toggled (object obj, EventArgs args) {
hbox_encoder_analyze_curve_num.Visible=true;
- hbox_encoder_analyze_load_vs_power.Visible=false;
- hbox_encoder_analyze_force_vs_speed.Visible=false;
+ hbox_combo_encoder_analyze_cross.Visible=false;
+ hbox_encoder_analyze_mean_or_max.Visible=false;
encoderAnalysis="superpose";
//together, mandatory
@@ -712,8 +709,8 @@ public partial class ChronoJumpWindow
*/
private void on_radiobutton_encoder_analyze_side_toggled (object obj, EventArgs args) {
hbox_encoder_analyze_curve_num.Visible=false;
- hbox_encoder_analyze_load_vs_power.Visible=false;
- hbox_encoder_analyze_force_vs_speed.Visible=false;
+ hbox_combo_encoder_analyze_cross.Visible=false;
+ hbox_encoder_analyze_mean_or_max.Visible=false;
encoderAnalysis="side";
//together, mandatory
@@ -722,34 +719,22 @@ public partial class ChronoJumpWindow
}
private void on_radiobutton_encoder_analyze_powerbars_toggled (object obj, EventArgs args) {
hbox_encoder_analyze_curve_num.Visible=false;
- hbox_encoder_analyze_load_vs_power.Visible=false;
- hbox_encoder_analyze_force_vs_speed.Visible=false;
+ hbox_combo_encoder_analyze_cross.Visible=false;
+ hbox_encoder_analyze_mean_or_max.Visible=false;
encoderAnalysis="powerBars";
hbox_encoder_analyze_eccon.Sensitive=true;
}
- private void on_radiobutton_encoder_analyze_load_vs_power_toggled (object obj, EventArgs args) {
+ private void on_radiobutton_encoder_analyze_cross_toggled (object obj, EventArgs args) {
hbox_encoder_analyze_curve_num.Visible=false;
- hbox_encoder_analyze_load_vs_power.Visible=true;
- hbox_encoder_analyze_force_vs_speed.Visible=false;
-
- //analyze button will check the mean, peak radios
- encoderAnalysis="loadVSPower";
-
- hbox_encoder_analyze_eccon.Sensitive=false;
- }
-
- private void on_radiobutton_encoder_analyze_force_vs_speed_toggled (object obj, EventArgs args) {
- hbox_encoder_analyze_curve_num.Visible=false;
- hbox_encoder_analyze_load_vs_power.Visible=false;
- hbox_encoder_analyze_force_vs_speed.Visible=true;
-
- //analyze button will check the mean, max radios
- encoderAnalysis="forceVSSpeed";
+ hbox_combo_encoder_analyze_cross.Visible=true;
+ hbox_encoder_analyze_mean_or_max.Visible=true;
+ encoderAnalysis="cross";
hbox_encoder_analyze_eccon.Sensitive=false;
}
+
private string findMass(bool includePerson) {
@@ -784,6 +769,7 @@ public partial class ChronoJumpWindow
string [] encoderExercisesTranslationAndBodyPWeight;
string [] encoderEcconTranslation;
string [] encoderLateralityTranslation;
+ string [] encoderAnalyzeCrossTranslation;
protected void createEncoderCombos() {
//create combo exercises
@@ -833,6 +819,22 @@ public partial class ChronoJumpWindow
combo_encoder_laterality.Active = UtilGtk.ComboMakeActive(combo_encoder_laterality,
Catalog.GetString(comboLateralityOptions[0]));
+ //create combo analyze cross (variables)
+ string [] comboAnalyzeCrossOptions = {
+ "Speed / Load", "Force / Load", "Power / Load", "Force / Speed", "Power / Speed" };
+ string [] comboAnalyzeCrossOptionsTranslated = {
+ Catalog.GetString("Speed / Load"), Catalog.GetString("Force / Load"),
+ Catalog.GetString("Power / Load"), Catalog.GetString("Force / Speed"),
+ Catalog.GetString("Power / Speed") };
+ encoderAnalyzeCrossTranslation = new String [comboAnalyzeCrossOptions.Length];
+ for(int j=0; j < 5 ; j++)
+ encoderAnalyzeCrossTranslation[j] =
+ comboAnalyzeCrossOptions[j] + ":" + comboAnalyzeCrossOptionsTranslated[j];
+ combo_encoder_analyze_cross = ComboBox.NewText ();
+ UtilGtk.ComboUpdate(combo_encoder_analyze_cross, comboAnalyzeCrossOptions, "");
+ combo_encoder_analyze_cross.Active = UtilGtk.ComboMakeActive(combo_encoder_analyze_cross,
+ Catalog.GetString(comboAnalyzeCrossOptions[0]));
+
//pack combos
hbox_combo_encoder_exercise.PackStart(combo_encoder_exercise, true, true, 0);
@@ -846,6 +848,11 @@ public partial class ChronoJumpWindow
hbox_combo_encoder_laterality.PackStart(combo_encoder_laterality, true, true, 0);
hbox_combo_encoder_laterality.ShowAll();
combo_encoder_laterality.Sensitive = true;
+
+ hbox_combo_encoder_analyze_cross.PackStart(combo_encoder_analyze_cross, true, true, 0);
+ hbox_combo_encoder_analyze_cross.ShowAll();
+ combo_encoder_analyze_cross.Sensitive = true;
+ hbox_combo_encoder_analyze_cross.Visible = false; //do not show hbox at start
}
void on_combo_encoder_eccon_changed (object o, EventArgs args)
@@ -1546,7 +1553,7 @@ public partial class ChronoJumpWindow
} else {
if(encoderProcessCancel) {
encoderProcessCancel = false;
- encoder_pulsebar_capture.Text = Catalog.GetString("Cancelled");
+ encoder_pulsebar_analyze.Text = Catalog.GetString("Cancelled");
} else {
//TODO pensar en si s'ha de fer 1er amb mida petita i despres amb gran (en el zoom),
//o si es una sola i fa alguna edicio
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]