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;
#$panel->resizable("FALSE","FALSE");
-my $panel_shell=$panel->Label(Name=>"shell",borderwidth=>1,relief=>'raised')->
+my $panel_shell=$panel->Label(Name=>"shell",-borderwidth=>1,-relief=>'raised')->
place(-x=>10,-y=>36,-relwidth=>1.0,-relheight=>1.0,
-width=>-20,-height=>-46,-anchor=>'nw');
-my $panel_quit=$panel_shell->Button(-class=>"Exit",text=>"quit",-command=>[sub{Shutdown()}])->
+my $panel_quit=$panel_shell->Button(-class=>"Exit",-text=>"quit",-command=>[sub{Shutdown()}])->
place(-x=>-1,-y=>-1,-relx=>1.0,-rely=>1.0,-anchor=>'se');
-$panel->Label(Name=>"logo text",-class=>"Panel",text=>$version)->
+$panel->Label(Name=>"logo text",-class=>"Panel",-text=>$version)->
place(-x=>5,-y=>5,-anchor=>'nw');
-my $graph_shell=$toplevel->Label(Name=>"shell",borderwidth=>1,relief=>'raised')->
+my $graph_shell=$toplevel->Label(Name=>"shell",-borderwidth=>1,-relief=>'raised')->
place(-x=>10,-y=>36,-relwidth=>1.0,-relheight=>1.0,
-width=>-20,-height=>-46,-anchor=>'nw');
-my $graph_status=$toplevel->Label(Name=>"logo text",-class=>"Panel",text=>"Starting up")->
+my $graph_status=$toplevel->Label(Name=>"logo text",-class=>"Panel",-text=>"Starting up")->
place(-x=>5,-y=>5,-anchor=>'nw');
my $panely=5;
-my $panel_rescan=$panel_shell->Button(text=>"rescan",command=>[sub{scan_directory()}])->
+my $panel_rescan=$panel_shell->Button(-text=>"rescan",-command=>[sub{scan_directory()}])->
place(-x=>-5,-relx=>1.,-y=>$panely,-anchor=>'ne');
$panely+=$panel_rescan->reqheight()+6;
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')->
+ Checkbutton(-variable=>\$panel_twovars[$i],-command=>['main::draw_graph'],-text=>'2')->
place(-y=>$localy,-x=>-5,-anchor=>"ne",-relx=>1.);
my $oney=$temp->reqheight();
my $onex=$temp->reqwidth()+15;
$temp=$panel_ones[$i]=$panel_shell->
- Checkbutton(-variable=>\$panel_onevars[$i],-command=>['main::draw_graph'],text=>'1')->
+ Checkbutton(-variable=>\$panel_onevars[$i],-command=>['main::draw_graph'],-text=>'1')->
place(-y=>0,-x=>0,-anchor=>"ne",-in=>$temp,-bordermode=>'outside');
$oney=$temp->reqheight() if ($oney<$temp->reqheight());
$onex+=$temp->reqwidth();
- $temp=$panel_labels[$i]=$panel_shell->Label(-text=>$key,-class=>'Field',justify=>'left')->
+ $temp=$panel_labels[$i]=$panel_shell->Label(-text=>$key,-class=>'Field',-justify=>'left')->
place(-y=>$localy,-x=>5,-anchor=>"nw",-relwidth=>1.,-width=>-$onex,
-bordermode=>'outside');
$oney=$temp->reqheight() if ($oney<$temp->reqheight());
sub Status{
my$text=shift @_;
- $graph_status->configure(text=>"$text");
+ $graph_status->configure(-text=>"$text");
$toplevel->update();
}
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);