getCurveIdx() has been replaced with getCurve(). I now return the curve data itself, not the index

to it
This commit is contained in:
Dima Kogan 2010-10-23 14:44:55 -07:00
parent c11f8df99b
commit 61a1b2c2b8

View File

@ -401,7 +401,7 @@ sub mainThread {
my $point = $2; my $point = $2;
$haveNewData = 1; $haveNewData = 1;
pushPoint(getCurveIdx($1), pushPoint(getCurve($1),
[$xlast, $point]); [$xlast, $point]);
} }
} }
@ -411,7 +411,7 @@ sub mainThread {
foreach my $point (/$numRE/go) foreach my $point (/$numRE/go)
{ {
$haveNewData = 1; $haveNewData = 1;
pushPoint(getCurveIdx($id++), pushPoint(getCurve($id++),
[$xlast, $point]); [$xlast, $point]);
} }
} }
@ -515,9 +515,10 @@ sub updateCurveOptions
$curveoptions->{options} = "$curveoptions->{extraoptions} $titleoption"; $curveoptions->{options} = "$curveoptions->{extraoptions} $titleoption";
} }
sub getCurveIdx sub getCurve
{ {
# This function returns the curve index for a particular curve, creating a new curve if necessary # This function returns the curve corresponding to a particular label, creating a new curve if
# necessary
if(scalar @curves >= $options{maxcurves}) if(scalar @curves >= $options{maxcurves})
{ {
@ -535,35 +536,34 @@ sub getCurveIdx
updateCurveOptions($curves[$#curves][0]); updateCurveOptions($curves[$#curves][0]);
} }
return $curveIndices{$id}; return $curves[$curveIndices{$id}];
} }
sub addCurveOption sub addCurveOption
{ {
my ($id, $str) = @_; my ($id, $str) = @_;
my $idx = getCurveIdx($id); my $curve = getCurve($id);
$curves[$idx][0]{extraoptions} .= "$str "; $curve->[0]{extraoptions} .= "$str ";
updateCurveOptions($curves[$idx][0]); updateCurveOptions($curve->[0]);
} }
sub setCurveLabel sub setCurveLabel
{ {
my ($id, $str) = @_; my ($id, $str) = @_;
my $idx = getCurveIdx($id); my $curve = getCurve($id);
$curves[$idx][0]{title} = $str; $curve->[0]{title} = $str;
updateCurveOptions($curves[$idx][0]); updateCurveOptions($curve->[0]);
} }
# function to add a point to the plot. Assumes that the curve indexed by $idx already exists # function to add a point to the plot. Assumes that the curve indexed by $idx already exists
sub pushPoint sub pushPoint
{ {
my ($idx, $xy) = @_; my ($curve, $xy) = @_;
if($options{monotonic}) if($options{monotonic})
{ {
my $curve = $curves[$idx];
if( @$curve > 1 && $xy->[0] < $curve->[$#{$curve}][0] ) if( @$curve > 1 && $xy->[0] < $curve->[$#{$curve}][0] )
{ {
# the x-coordinate of the new point is in the past, so I wipe out all the data for this curve # the x-coordinate of the new point is in the past, so I wipe out all the data for this curve
@ -572,5 +572,5 @@ sub pushPoint
} }
} }
push @{$curves[$idx]}, $xy; push @$curve, $xy;
} }