my $version="Analyzer 20020429";
my %bases;
-my $first_file;
-my $last_file;
-my $fileno;
+my $first_file=undef;
+my $last_file=undef;
+my $fileno=0;
my @panel_labels;
my @panel_ones;
my$onecrop;
my$twocrop;
-$temp=$graph_shell->Checkbutton(text=>"rescale",-variable=>\$onecrop,
+my$oneresize=$temp=$graph_shell->Checkbutton(text=>"rescale",-variable=>\$onecrop,
-command=>[sub{draw_graph();}])->
place(-x=>5,-y=>5,-anchor=>'nw');
-x=>5,-y=>5+$temp->reqheight,-anchor=>'nw');
-$temp=$graph_shell->Checkbutton(text=>"rescale",-variable=>\$twocrop,
+my$tworesize=$temp=$graph_shell->Checkbutton(text=>"rescale",-variable=>\$twocrop,
-command=>[sub{draw_graph();}])->
place(-rely=>1.,-y=>5,-anchor=>'nw',-in=>$one);
my$two=$graph_shell->Canvas()->
$graph_slider->configure(-command=>[sub{load_graph()}]);
load_graph();
-$toplevel->bind('MainWindow','<Configure>',[sub{$toplevel->update();draw_graph()}]);
+$toplevel->bind('MainWindow','<Configure>',[sub{$toplevel->update();
+ draw_graph()}]);
Tk::MainLoop();
if($graph->{"vars"}->[$i]){
if(defined($data[$i])){
if(!defined($graph->{"minx"})){
- $data[$i]->[0]=~m/(-?\d*)[ ,]+(-?\d*)/;
+ $data[$i]->[0]=~m/^\s*(-?[0-9\.]*)[ ,]+(-?[0-9\.]*)/;
$graph->{"maxx"}=$1;
$graph->{"minx"}=$1;
$graph->{"maxy"}=$2;
}
for(my$j=0;$j<=$#{$data[$i]};$j++){
- $data[$i]->[$j]=~m/(-?\d*)[ ,]+(-?\d*)/;
+ $data[$i]->[$j]=~m/^\s*(-?[0-9\.]*)[ ,]+(-?[0-9\.]*)/;
$rescale=1 if($1>$graph->{"maxx"});
$rescale=1 if($1<$graph->{"minx"});
$rescale=1 if($2>$graph->{"maxy"});
my$width=$w->width();
my$height=$w->height();
+ $rescale=1 if(!defined($graph->{"width"}) ||
+ $width!=$graph->{"width"} ||
+ $height!=$graph->{"height"});
+
+ $graph->{"width"}=$width;
+ $graph->{"height"}=$height;
+
if(defined($graph->{"maxx"})){
# draw axes, labels
# look for appropriate axis scales
my$yscale=1.;
my$xscale=1.;
- while(($graph->{"maxx"}-$graph->{"minx"})*$xscale>15){$xscale*=.1;}
- while(($graph->{"maxy"}-$graph->{"miny"})*$yscale>15){$yscale*=.1;}
+ my$iyscale=1.;
+ my$ixscale=1.;
+ while(($graph->{"maxx"}-$graph->{"minx"})*$xscale>15){$xscale*=.1;$ixscale*=10.;}
+ while(($graph->{"maxy"}-$graph->{"miny"})*$yscale>15){$yscale*=.1;$iyscale*=10.;}
- while(($graph->{"maxx"}-$graph->{"minx"})*$xscale<3){$xscale*=10.;}
- while(($graph->{"maxy"}-$graph->{"miny"})*$yscale<3){$yscale*=10.;}
+ while(($graph->{"maxx"}-$graph->{"minx"})*$xscale<3){$xscale*=10.;$ixscale*=.1;}
+ while(($graph->{"maxy"}-$graph->{"miny"})*$yscale<3){$yscale*=10.;$iyscale*=.1;}
# how tall are the x axis labels?
$w->createText(-1,-1,-anchor=>'se',-tags=>['foo'],-text=>"0123456789.");
# place y axis labels at proper spacing/height
my$lasty=-$maxlabelheight/2;
- my$topyval=int($graph->{"maxy"}*$yscale+1.)/$yscale;
+ my$topyval=int($graph->{"maxy"}*$yscale+1.)*$iyscale;
for(my$i=0;;$i++){
- my$yval= $topyval-$i/$yscale;
+ my$yval= $topyval-$i*$iyscale;
my$y= ($graph->{"maxy"}-$yval)*$pixelpery;
last if($y>$useabley);
if($y-$maxlabelheight>=$lasty){
# draw y tix
$lasty=-$maxlabelheight/2;
for(my$i=0;;$i++){
- my$yval= $topyval-$i/$yscale;
+ my$yval= $topyval-$i*$iyscale;
my$y= ($graph->{"maxy"}-$yval)*$pixelpery;
last if($y>$useabley);
if($yval==0){
}
# place x axis labels at proper spacing
- my$topxval=int($graph->{"maxx"}*$xscale+1.)/$xscale;
+ my$topxval=int($graph->{"maxx"}*$xscale+1.)*$ixscale;
my$pixelperx=$useablex/($graph->{"maxx"}-$graph->{"minx"});
for(my$i=0;;$i++){
- my$xval= $topxval-$i/$xscale;
+ my$xval= $topxval-$i*$ixscale;
my$x= $width-($graph->{"maxx"}-$xval)*$pixelperx;
last if($x<$beginx);
my$lastx=$width;
for(my$i=0;;$i++){
- my$xval= $topxval-$i/$xscale;
+ my$xval= $topxval-$i*$ixscale;
my$x= $width-($graph->{"maxx"}-$xval)*$pixelperx;
- last if($x-$maxxlabelwidth/2<0);
+ last if($x-$maxxlabelwidth/2<0 || $x<$beginx);
if($xval==0 && $x<$width){
$w->createLine($x,0,$x,$useabley,-tags=>['axes'],-width=>1);
}
$legendy+=$graph->{"labelheight"};
# plot the lines
- my$d=$data[$i];
- my$pair;
- my$lastx=undef;
- my$lasty=undef;
- foreach $pair (@{$data[$i]}){
- if($pair=~m/(-?\d*)[ ,]+(-?\d*)/){
- my$x=($1-$graph->{"minx"})*$graph->{"ppx"}+$graph->{"xo"};
- my$y=(-$2+$graph->{"maxy"})*$graph->{"ppy"};
-
- if(defined($lastx)){
- $w->createLine($x,$y,$lastx,$lasty,-fill=>$color,
- -tags=>['lines']);
- }
- $lastx=$x;
- $lasty=$y;
- }
- }
+ my@pairs=map{if(/^\s*(-?[0-9\.]*)[ ,]+(-?[0-9\.]*)/){
+ (($1-$graph->{"minx"})*$graph->{"ppx"}+$graph->{"xo"},
+ (-$2+$graph->{"maxy"})*$graph->{"ppy"})}} (@{$data[$i]});
+
+ $w->createLine((@pairs),-fill=>$color,-tags=>['lines']);
}
}
}
$twostate{"maxy"}=undef;
}
- graphhelper(\%onestate);
- graphhelper(\%twostate);
+ for(my$i=0;$i<$panel_count;$i++){
+ if($twostate{"vars"}->[$i]){
+
+ #re-place the canvases
+
+ $oneresize->place(-x=>5,-y=>5,-anchor=>'nw');
+
+ $one->place(-relwidth=>1.,-width=>-10,-relheight=>.5,
+ -height=>($graphy/2)-5-$oneresize->reqheight(),
+ -x=>5,-y=>5+$oneresize->reqheight,-anchor=>'nw');
+
+ $tworesize->place(-rely=>1.,-y=>5,-anchor=>'nw',-in=>$one);
+ $two->place(-relwidth=>1.,-relheight=>1.,-rely=>1.,
+ -y=>5+$tworesize->reqheight(),-anchor=>'nw',-in=>$one);
+ graphhelper(\%onestate);
+ graphhelper(\%twostate);
+ return;
+ }
+ }
+
+ $oneresize->place(-x=>5,-y=>5,-anchor=>'nw');
+
+ $one->place(-relwidth=>1.,-width=>-10,-relheight=>1.,
+ -height=>$graphy-5-$oneresize->reqheight(),
+ -x=>5,-y=>5+$oneresize->reqheight,-anchor=>'nw');
+
+ $tworesize->placeForget();
+ $two->placeForget();
+
+ graphhelper(\%onestate);
}
sub depopulate_panel{
my $i=0;
foreach $key (sort (keys %bases)){
$panel_keys[$i]=$key;
- $panel_onevars[$i]=0;
- $panel_twovars[$i]=0;
+ if(!defined($panel_onevars[$i])){
+ $panel_onevars[$i]=0;
+ $panel_twovars[$i]=0;
+ }
my $temp=$panel_twos[$i]=$panel_shell->
Checkbutton(-variable=>\$panel_twovars[$i],-command=>['main::draw_graph'],text=>'2')->
Status("Done Reading: $count files");
depopulate_panel();
populate_panel();
- $fileno=$first_file;
+
+ $fileno=$first_file if($fileno<$first_file);
+ $fileno=$last_file if($fileno>$last_file);
$graph_slider->configure(-from=>$first_file,-to=>$last_file);