[chronojump] encoder analyze side lot better
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] encoder analyze side lot better
- Date: Tue, 15 Jan 2013 16:36:33 +0000 (UTC)
commit 90b50ac1881856720c6683e2b1a20cb80c920be5
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Jan 15 17:35:50 2013 +0100
encoder analyze side lot better
encoder/graph.R | 70 +++++++++++++++++++++++++++++++++---------------
glade/chronojump.glade | 11 +++++++
src/gui/encoder.cs | 61 +++++++++++++++++++++++++++++++++++++----
3 files changed, 114 insertions(+), 28 deletions(-)
---
diff --git a/encoder/graph.R b/encoder/graph.R
index 7c95f81..63b42eb 100644
--- a/encoder/graph.R
+++ b/encoder/graph.R
@@ -184,13 +184,11 @@ kinematicRanges <- function(singleFile,rawdata,curves,mass,smoothingOne,g) {
}
paint <- function(rawdata, eccon, xmin, xmax, yrange, knRanges, superpose, highlight,
- startX, startH, smoothing, mass, title, draw, labels, axesAndTitle, legend) {
+ startX, startH, smoothing, mass, title, draw, showLabels, marShrink, showAxes, legend) {
#eccons ec and ec-rep is the same here (only show one curve)
#receive data as cumulative sum
lty=c(1,1,1)
-#xmin=xmin-500
-
rawdata=rawdata[xmin:xmax]
a=cumsum(rawdata)
a=a+startH
@@ -201,20 +199,20 @@ paint <- function(rawdata, eccon, xmin, xmax, yrange, knRanges, superpose, highl
if(draw) {
#three vertical axis inspired on http://www.r-bloggers.com/multiple-y-axis-in-a-r-plot/
par(mar=c(5, 4, 4, 8))
+ if(marShrink) #used on "side" compare
+ par(mar=c(1, 1, 4, 1))
#plot distance
#plot(a,type="h",xlim=c(xmin,xmax),xlab="time (ms)",ylab="Left: distance (mm); Right: speed (m/s), accelration (m/s^2)",col="gray", axes=F) #this shows background on distance (nice when plotting distance and speed, but confusing when there are more variables)
xlab="";ylab="";
- if(labels) {
+ if(showLabels) {
xlab="time (ms)"
ylab="Left: distance (mm); Right: speed (m/s), force (N), power (W)"
}
ylim=yrange
if(ylim[1]=="undefined") { ylim=NULL }
- if(!axesAndTitle)
- title=""
plot(a-min(a),type="n",xlim=c(1,length(a)),ylim=ylim,xlab=xlab, ylab=ylab, col="gray", axes=F, main=title)
- if(axesAndTitle) {
+ if(showAxes) {
axis(1) #can be added xmin
axis(2)
}
@@ -249,7 +247,7 @@ paint <- function(rawdata, eccon, xmin, xmax, yrange, knRanges, superpose, highl
plot(startX:length(speed$y),speed$y[startX:length(speed$y)],type="l",xlim=c(1,length(a)),ylim=ylim,xlab="",ylab="",col=cols[1],lty=lty[1],lwd=1,axes=F)
else
plot(startX:length(speed$y),speed$y[startX:length(speed$y)],type="l",xlim=c(1,length(a)),ylim=ylim,xlab="",ylab="",col="darkgreen",lty=2,lwd=3,axes=F)
- if(axesAndTitle) {
+ if(showAxes) {
axis(4, col=cols[1], lty=lty[1], line=0, padj=-.5)
abline(h=0,lty=3,col="black")
}
@@ -347,7 +345,7 @@ paint <- function(rawdata, eccon, xmin, xmax, yrange, knRanges, superpose, highl
abline(v=propulsiveEnds,lty=3,col="magenta")
points(propulsiveEnds, -g, col="magenta")
- if(axesAndTitle)
+ if(showAxes)
axis(4, col="magenta", lty=lty[1], line=2, padj=-.5)
#mtext(text=paste("max accel:",round(max(accel$y),3)),side=3,at=which(accel$y == max(accel$y)),cex=.8,col=cols[1],line=2)
}
@@ -369,7 +367,7 @@ paint <- function(rawdata, eccon, xmin, xmax, yrange, knRanges, superpose, highl
plot(startX:length(force),force[startX:length(force)],type="l",xlim=c(1,length(a)),ylim=ylim,xlab="",ylab="",col=cols[2],lty=lty[2],lwd=1,axes=F)
else
plot(startX:length(force),force[startX:length(force)],type="l",xlim=c(1,length(a)),ylim=ylim,xlab="",ylab="",col="darkblue",lty=2,lwd=3,axes=F)
- if(axesAndTitle)
+ if(showAxes)
axis(4, col=cols[2], lty=lty[2], line=4, padj=-.5)
}
@@ -415,7 +413,7 @@ paint <- function(rawdata, eccon, xmin, xmax, yrange, knRanges, superpose, highl
plot(startX:length(power),power[startX:length(power)],type="l",xlim=c(1,length(a)),ylim=ylim,xlab="",ylab="",col=cols[3],lty=lty[3],lwd=2,axes=F)
else
plot(startX:length(power),power[startX:length(power)],type="l",xlim=c(1,length(a)),ylim=ylim,xlab="",ylab="",col="darkred",lty=2,lwd=3,axes=F)
- if(axesAndTitle)
+ if(showAxes)
axis(4, col=cols[3], lty=lty[3], line=6, lwd=2, padj=-.5)
}
@@ -456,7 +454,7 @@ paint <- function(rawdata, eccon, xmin, xmax, yrange, knRanges, superpose, highl
#legend, axes and title
if(draw) {
- if(legend & axesAndTitle) {
+ if(legend & showAxes) {
legendPos = "bottom"
par(xpd=T)
legend(legendPos, xjust=1, legend=c("Distance","","Speed","Accel.","Force","Power"), lty=c(1,0,1,1,1,1),
@@ -464,8 +462,10 @@ paint <- function(rawdata, eccon, xmin, xmax, yrange, knRanges, superpose, highl
par(xpd=F)
#mtext(text="[ESC: Quit; mouse left: Zoom in; mouse right: Zoom out]",side=3)
}
- mtext("time (ms) ",side=1,adj=1,line=-1,cex=.9)
- mtext("height (mm) ",side=2,adj=1,line=-1,cex=.9)
+ if(showLabels) {
+ mtext("time (ms) ",side=1,adj=1,line=-1,cex=.9)
+ mtext("height (mm) ",side=2,adj=1,line=-1,cex=.9)
+ }
}
}
@@ -590,7 +590,6 @@ paintCrossVariables <- function (paf, varX, varY, option, isAlone, title) {
find.mfrow <- function(n) {
if(n<=3) return(c(1,n))
- else if(n<=6) return(c(2,ceiling(n/2)))
else if(n<=8) return(c(2,ceiling(n/2)))
else return(c(3, ceiling(n/3)))
}
@@ -598,7 +597,13 @@ find.mfrow <- function(n) {
find.yrange <- function(singleFile, rawdata, curves) {
if(singleFile) {
a=cumsum(rawdata)
- return (c(min(a),max(a)))
+ y.max = max(a)
+ y.min = min(a)
+ if(y.min < 0) {
+ y.max = y.max + -1*y.min
+ y.min = 0
+ }
+ return (c(y.min,y.max))
} else {
n=length(curves[,1])
y.max = 0
@@ -609,7 +614,6 @@ find.yrange <- function(singleFile, rawdata, curves) {
y.max = max(y.current)
if(min(y.current) < y.min)
y.min = min(y.current)
-
}
return (c(y.min,y.max))
}
@@ -677,7 +681,7 @@ if(length(args) < 3) {
Title=gsub('-',' ',Title)
}
- titleType = "execution"
+ titleType = "n"
#if(isJump)
# titleType="jump"
@@ -853,8 +857,14 @@ if(length(args) < 3) {
}
paint(rawdata, myEccon, myStart, myEnd,"undefined","undefined",FALSE,FALSE,
1,curves[jump,3],mySmoothingOne,myMass,
- paste(Title, " ", analysis, " ", myEccon, " ", titleType, " ", jump," (smoothing: ",mySmoothingOne,")",sep=""),
- TRUE,FALSE,TRUE,TRUE)
+ paste(Title, " ", analysis, " ", myEccon, " ", titleType, " ", jump,
+ " (smoothing: ",mySmoothingOne,")",sep=""),
+ TRUE, #draw
+ TRUE, #showLabels
+ FALSE, #marShrink
+ TRUE, #showAxes
+ TRUE #legend
+ )
}
}
@@ -878,7 +888,13 @@ if(length(args) < 3) {
myEccon = curves[i,8]
}
paint(rawdata, myEccon, curves[i,1],curves[i,2],yrange,knRanges,FALSE,FALSE,
- 1,curves[i,3],mySmoothingOne,myMass,paste(Title, " ", titleType,rownames(curves)[i]),TRUE,FALSE,TRUE,FALSE)
+ 1,curves[i,3],mySmoothingOne,myMass,paste(Title, " ", titleType,rownames(curves)[i]),
+ TRUE, #draw
+ FALSE, #showLabels
+ TRUE, #marShrink
+ FALSE, #showAxes
+ FALSE #legend
+ )
}
par(mfrow=c(1,1))
}
@@ -901,8 +917,18 @@ if(length(args) < 3) {
#but line maybe don't start on the absolute left
#this is controled by startX
startX = curves[i,1]-(curves[i,2]-wide)+1;
+ myTitle = "";
+ if(i==1)
+ myTitle = paste(titleType,jump);
+
paint(rawdata, eccon, curves[i,2]-wide,curves[i,2],yrange,knRanges,TRUE,(i==jump),
- startX,curves[i,3],smoothingOne,Mass,paste(titleType,jump),TRUE,FALSE,(i==1),TRUE)
+ startX,curves[i,3],smoothingOne,Mass,myTitle,
+ TRUE, #draw
+ TRUE, #showLabels
+ FALSE, #marShrink
+ (i==1), #showAxes
+ TRUE #legend
+ )
par(new=T)
}
par(new=F)
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 2fd330c..61ed0eb 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -13285,6 +13285,17 @@ on current Chronojump version.</property>
<property name="position">3</property>
</packing>
</child>
+ <child>
+ <widget class="GtkLabel" id="label_encoder_analyze_side_max">
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Side compare allows a maximum of 12 graphs.</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="left_attach">1</property>
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 65e7194..7d42c05 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -83,6 +83,7 @@ public partial class ChronoJumpWindow
[Widget] Gtk.Box hbox_encoder_analyze_curve_num;
[Widget] Gtk.Box hbox_combo_encoder_analyze_curve_num_combo;
[Widget] Gtk.ComboBox combo_encoder_analyze_curve_num_combo;
+ [Widget] Gtk.Label label_encoder_analyze_side_max;
[Widget] Gtk.Box hbox_encoder_analyze_mean_or_max;
[Widget] Gtk.RadioButton radiobutton_encoder_analyze_mean;
@@ -415,6 +416,8 @@ public partial class ChronoJumpWindow
UtilGtk.ComboMakeActive(combo_encoder_analyze_curve_num_combo, activeCurvesList[0]);
genericWin.HideAndNull();
+
+ encoderButtonsSensitive(encoderSensEnumStored);
}
@@ -475,6 +478,8 @@ public partial class ChronoJumpWindow
on_button_encoder_recalculate_clicked (o, args);
radiobutton_encoder_analyze_data_current_signal.Active = true;
+
+ encoderButtonsSensitive(encoderSensEnumStored);
}
void on_button_encoder_export_all_curves_clicked (object o, EventArgs args)
@@ -864,7 +869,14 @@ public partial class ChronoJumpWindow
int rows = UtilGtk.CountRows(encoderListStore);
//button_encoder_analyze.Sensitive = encoderTimeStamp != null;
- button_encoder_analyze.Sensitive = (rows > 0);
+
+ bool analyze_sensitive = (rows > 0);
+ if(analyze_sensitive && radiobutton_encoder_analyze_side.Active) {
+ analyze_sensitive = curvesNumOkToSideCompare();
+ label_encoder_analyze_side_max.Visible = ! analyze_sensitive;
+ }
+ button_encoder_analyze.Sensitive = analyze_sensitive;
+
button_encoder_analyze_data_show_user_curves.Sensitive = false;
hbox_encoder_user_curves_num.Sensitive = false;
@@ -892,8 +904,14 @@ public partial class ChronoJumpWindow
updateComboEncoderAnalyzeCurveNum(data, activeCurvesNum);
}
- button_encoder_analyze.Sensitive = (currentPerson != null &&
+ bool analyze_sensitive = (currentPerson != null &&
UtilGtk.ComboGetActive(combo_encoder_analyze_curve_num_combo) != "");
+ if(analyze_sensitive && radiobutton_encoder_analyze_side.Active) {
+ analyze_sensitive = curvesNumOkToSideCompare();
+ label_encoder_analyze_side_max.Visible = ! analyze_sensitive;
+ }
+ button_encoder_analyze.Sensitive = analyze_sensitive;
+
button_encoder_analyze_data_show_user_curves.Sensitive = currentPerson != null;
hbox_encoder_user_curves_num.Sensitive = currentPerson != null;
@@ -910,6 +928,9 @@ public partial class ChronoJumpWindow
//together, mandatory
hbox_encoder_analyze_eccon.Visible=false;
radiobutton_encoder_eccon_together.Active = true;
+ label_encoder_analyze_side_max.Visible = false;
+
+ encoderButtonsSensitive(encoderSensEnumStored);
}
/*
@@ -923,6 +944,8 @@ public partial class ChronoJumpWindow
//together, mandatory
hbox_encoder_analyze_eccon.Visible=false;
radiobutton_encoder_eccon_together.Active = true;
+
+ encoderButtonsSensitive(encoderSensEnumStored);
}
*/
private void on_radiobutton_encoder_analyze_side_toggled (object obj, EventArgs args) {
@@ -935,6 +958,8 @@ public partial class ChronoJumpWindow
//together, mandatory
hbox_encoder_analyze_eccon.Visible=false;
radiobutton_encoder_eccon_together.Active = true;
+
+ encoderButtonsSensitive(encoderSensEnumStored);
}
private void on_radiobutton_encoder_analyze_powerbars_toggled (object obj, EventArgs args) {
hbox_encoder_analyze_curve_num.Visible=false;
@@ -944,6 +969,9 @@ public partial class ChronoJumpWindow
encoderAnalysis="powerBars";
hbox_encoder_analyze_eccon.Visible=true;
+ label_encoder_analyze_side_max.Visible = false;
+
+ encoderButtonsSensitive(encoderSensEnumStored);
}
private void on_radiobutton_encoder_analyze_cross_toggled (object obj, EventArgs args) {
@@ -954,9 +982,22 @@ public partial class ChronoJumpWindow
encoderAnalysis="cross";
hbox_encoder_analyze_eccon.Visible=false;
+ label_encoder_analyze_side_max.Visible = false;
+
+ encoderButtonsSensitive(encoderSensEnumStored);
}
+ private bool curvesNumOkToSideCompare() {
+ if(radiobutton_encoder_analyze_data_current_signal.Active &&
+ UtilGtk.CountRows(encoderListStore) <= 12)
+ return true;
+ else if(radiobutton_encoder_analyze_data_user_curves.Active &&
+ Convert.ToInt32(label_encoder_user_curves_active_num.Text) <= 12)
+ return true;
+
+ return false;
+ }
private string findMass(bool includePerson) {
double mass = spin_encoder_extra_weight.Value;
@@ -1624,7 +1665,7 @@ public partial class ChronoJumpWindow
//c3 button_encoder_save_all_curves, button_encoder_export_all_curves,
// button_encoder_update_signal,
// button_encoder_delete_signal, entry_encoder_signal_comment,
- // and images: image_encoder_capture , image_encoder_analyze.Sensitive
+ // and images: image_encoder_capture , image_encoder_analyze.Sensitive. Update: both NOT managed here
//c4 button_encoder_delete_curve , button_encoder_save_curve, entry_encoder_curve_comment
//c5 button_encoder_analyze
//c6 button_encoder_analyze_data_show_user_curves
@@ -1683,18 +1724,25 @@ public partial class ChronoJumpWindow
button_encoder_update_signal.Sensitive = Util.IntToBool(table[3]);
button_encoder_delete_signal.Sensitive = Util.IntToBool(table[3]);
entry_encoder_signal_comment.Sensitive = Util.IntToBool(table[3]);
- image_encoder_capture.Sensitive = Util.IntToBool(table[3]);
- image_encoder_analyze.Sensitive = Util.IntToBool(table[3]);
+ //image_encoder_capture.Sensitive = Util.IntToBool(table[3]);
+ //image_encoder_analyze.Sensitive = Util.IntToBool(table[3]);
button_encoder_delete_curve.Sensitive = Util.IntToBool(table[4]);
button_encoder_save_curve.Sensitive = Util.IntToBool(table[4]);
entry_encoder_curve_comment.Sensitive = Util.IntToBool(table[3]);
bool signal = radiobutton_encoder_analyze_data_current_signal.Active;
- button_encoder_analyze.Sensitive =
+
+ bool analyze_sensitive =
(Util.IntToBool(table[5]) &&
(signal && UtilGtk.CountRows(encoderListStore) > 0 ||
(! signal && Convert.ToInt32(label_encoder_user_curves_all_num.Text) >0)));
+ if(analyze_sensitive && radiobutton_encoder_analyze_side.Active) {
+ analyze_sensitive = curvesNumOkToSideCompare();
+ label_encoder_analyze_side_max.Visible = ! analyze_sensitive;
+ } else
+ label_encoder_analyze_side_max.Visible = false;
+ button_encoder_analyze.Sensitive = analyze_sensitive;
button_encoder_analyze_data_show_user_curves.Sensitive =
(Util.IntToBool(table[6]) && ! radiobutton_encoder_analyze_data_current_signal.Active);
@@ -1811,6 +1859,7 @@ public partial class ChronoJumpWindow
Pixbuf pixbuf = new Pixbuf (Util.GetEncoderGraphTempFileName()); //from a file
image_encoder_capture.Pixbuf = pixbuf;
encoderUpdateTreeView();
+ image_encoder_capture.Sensitive = true;
//autosave signal (but not in recalculate or load)
if(mode == encoderModes.CAPTURE)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]