[chronojump] Encoder: Fixed no curves analyzing



commit 8e3a3ececd1d6904795ac388d65478bca0b3cf44
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Jun 1 12:36:32 2012 +0200

    Encoder: Fixed no curves analyzing

 encoder/graph.R    |   23 +++++++++++++----------
 src/gui/encoder.cs |    6 +++++-
 2 files changed, 18 insertions(+), 11 deletions(-)
---
diff --git a/encoder/graph.R b/encoder/graph.R
index 7d9abb4..ed65498 100644
--- a/encoder/graph.R
+++ b/encoder/graph.R
@@ -24,7 +24,7 @@ library("EMD")
 findCurves <- function(rawdata, eccon, min_height, draw) {
 	a=cumsum(rawdata)
 	b=extrema(a)
-print(b)
+	
 	start=0; end=0; startH=0
 	tempStart=0; tempEnd=0;
 	#TODO: fer algo per si no es detecta el minindex previ al salt
@@ -414,6 +414,17 @@ find.yrange <- function(singleFile, rawdata, curves) {
 	}
 }
 
+quitIfNoData <- function(n, curves, outputData1) {
+	#if not found curves with this data, plot a "sorry" message and exit
+	if(n == 1 & curves[1,1] == 0 & curves[1,2] == 0) {
+		plot(0,0,type="n",axes=F,xlab="",ylab="")
+		text(x=0,y=0,"Sorry, no curves matched your criteria.",cex=1.5)
+		dev.off()
+		write("", outputData1)
+		quit()
+	}
+}
+
 #concentric, eccentric-concentric, repetitions of eccentric-concentric
 #currently only used "c" and "ec". no need of ec-rep because c and ec are repetitive
 #"ecS" is like ec but eccentric and concentric phases are separated, used in findCurves, this is good for treeview to know power... on the 2 phases
@@ -499,6 +510,7 @@ if(length(args) < 3) {
 		rownames(curves)=1:length(rownames(curves))
 		#print(curves)
 		n=length(curves[,1])
+		quitIfNoData(n, curves, outputData1)
 	} else {
 		rawdata=scan(file=file,sep=",")
 
@@ -516,15 +528,6 @@ if(length(args) < 3) {
 		#print(curves)
 		n=length(curves[,1])
 
-		#if not found curves with this data, plot a "sorry" message and exit
-		if(n == 1 & curves[1,1] == 0 & curves[1,2] == 0) {
-			plot(0,0,type="n",axes=F,xlab="",ylab="")
-			text(x=0,y=0,"Sorry, no curves matched your criteria.",cex=1.5)
-			dev.off()
-			write("", outputData1)
-			quit()
-		}
-
 		for(i in 1:n) { 
 			curves[i,1]=reduceCurveBySpeed(eccon, i, curves[i,1],rawdata[curves[i,1]:curves[i,2]], smoothingOne)
 		}
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 397ad6d..4498254 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -92,7 +92,7 @@ public partial class ChronoJumpWindow
 	//TODO: solve the problem of connecting two different chronopics
 	//
 	//TODO: analyze-user curves: create file with n lines: titlecurve,otherparams,...,filecurve and pass this file to graph.R. graph.R will know that this file is not a rawdata file because will be called chronojump-encoder-graph-input-multi.txt
-	//TODO: if user has no curves, has to stop, multi file gets generated with title row but no curves
+	//TODO: if user has no curves, has to stop, multi file gets generated with title row but no curves. Fixed, but need to (best) don't allow to analyze, or show a clear message, blanking the graphic
 	//TODO:put zoom,unzoom (at side of delete curve)  in capture curves (for every curve)
 	//TODO: treeview on analyze
 	//TODO: Add exercise. at capture add combobox of exercises or treeview that pop ups (maybe genericWin). squat, benchpress, jump. change weight bar, and jump radiobuttons to this combobox, addoption of others, and add them on sqlite
@@ -482,6 +482,10 @@ public partial class ChronoJumpWindow
 			double bodyMass = Convert.ToDouble(label_encoder_person_weight.Text);
 			ArrayList data = SqliteEncoder.Select(false, -1, 
 					currentPerson.UniqueID, currentSession.UniqueID, "curve");
+
+			//TODO: in the future plot a "no curves" message, or beter done allow to analyze if there's no curves
+			if(data.Count == 0)
+				return;
 		
 				
 			TextWriter writer = File.CreateText(dataFileName);



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