From 0a2226594a5bd7fccea2a3d4cdf636e78d8a7d77 Mon Sep 17 00:00:00 2001 From: Dima Kogan Date: Wed, 4 Nov 2009 18:20:51 -0800 Subject: [PATCH] fixed a bug in the drivegnuplot scripts. when a new curve is added, they now make sure to add all the curves leading up to those. So if I'm trying to create curve 5, it'll create 0,1,2,3,4 if they aren't there --- driveGnuPlots.pl | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/driveGnuPlots.pl b/driveGnuPlots.pl index bde67df..493c0c1 100755 --- a/driveGnuPlots.pl +++ b/driveGnuPlots.pl @@ -182,7 +182,7 @@ sub mainThread { } else { - newCurve("", $str); + newCurve("", $str, undef, $y2idx); } } @@ -208,11 +208,7 @@ sub mainThread { my $idx = $1; my $point = $2; - # if this curve index doesn't exist, create curve up-to this index - while(!exists $curves[$idx]) - { - newCurve("", ""); - } + newCurve("", "", undef, $idx); push @{$curves[$idx]}, [$xlast, $point]; } @@ -304,20 +300,43 @@ sub plotStoredData sub newCurve() { - my ($title, $opts, $newpoint) = @_; + my ($title, $opts, $newpoint, $idx) = @_; + + # if this curve index doesn't exist, create curve up-to this index + if(defined $idx) + { + while(!exists $curves[$idx]) + { + pushNewEmptyCurve(); + } + } + else + { + # if we're not given an index, create a new one at the end, and fill it in + pushNewEmptyCurve(); + $idx = $#curves; + } + if($title) { $opts = "title \"$title\" $opts" } else { $opts = "notitle $opts" } if( defined $newpoint ) { - push @curves, [" $opts", $newpoint]; + $curves[$idx] = [" $opts", $newpoint]; } else { - push @curves, [" $opts"]; + $curves[$idx] = [" $opts"]; } } +sub pushNewEmptyCurve +{ + my $opts = "notitle "; + push @curves, [" $opts"]; +} + + sub usage { print "Usage: $0 \n"; print <