From: Michael Traxler Date: Fri, 14 Nov 2014 16:32:10 +0000 (+0100) Subject: copied changes from Hades X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=61c8e954e229bae83782c48f1ca04523e175d41d;p=daqtools.git copied changes from Hades --- diff --git a/tools/HPlot.pm b/tools/HPlot.pm index 83b4e69..f1c73d4 100755 --- a/tools/HPlot.pm +++ b/tools/HPlot.pm @@ -36,6 +36,18 @@ sub makeTimeString{ return strftime("set label 100 \"%H:%M:%S\" at screen 0.02,0.02 left tc rgb \"#000044\" font \"monospace,8\"\n", localtime()) } +sub setranges { + my ($fh,$name,$min,$max) = @_; + if(defined $min && defined $max) { + plot_write($fh,"set $name [$min:$max]"); + } + elsif(defined $max) { + plot_write($fh,"set $name [:$max]"); + } + elsif(defined $min) { + plot_write($fh,"set $name [$min:]"); + } + } sub PlotInit { my ($c) = @_; @@ -104,29 +116,11 @@ sub PlotInit { plot_write($fh,"set xlabel \"".$p->{$name}->{xlabel}."\"") if $p->{$name}->{xlabel}; plot_write($fh,"set ylabel \"".$p->{$name}->{ylabel}."\"") if $p->{$name}->{ylabel}; - if(defined $p->{$name}->{ymin} && defined $p->{$name}->{ymax}) { - plot_write($fh,"set yrange [".$p->{$name}->{ymin}.":".$p->{$name}->{ymax}."]"); - } - elsif(defined $p->{$name}->{ymax}) { - plot_write($fh,"set yrange [:".$p->{$name}->{ymax}."]"); - } - elsif(defined $p->{$name}->{ymin}) { - plot_write($fh,"set yrange [".$p->{$name}->{ymin}.":]"); - } - - if(defined $p->{$name}->{xmin} && defined $p->{$name}->{xmax}) { - plot_write($fh,"set xrange [".$p->{$name}->{xmin}.":".$p->{$name}->{xmax}."]"); - } - elsif(defined $p->{$name}->{xmax}) { - plot_write($fh,"set xrange [:".$p->{$name}->{xmax}."]"); - } - elsif(defined $p->{$name}->{xmin}) { - plot_write($fh,"set xrange [".$p->{$name}->{xmin}.":]"); - } + setranges($fh,'xrange',$p->{$name}->{xmin},$p->{$name}->{xmax}); + setranges($fh,'yrange',$p->{$name}->{ymin},$p->{$name}->{ymax}); + setranges($fh,'zrange',$p->{$name}->{zmin},$p->{$name}->{zmax}); + setranges($fh,'cbrange',$p->{$name}->{cbmin},$p->{$name}->{cbmax}); - if($p->{$name}->{addCmd} && $p->{$name}->{addCmd} ne "") { - plot_write($fh,$p->{$name}->{addCmd}); - } if($p->{$name}->{type} == TYPE_HISTORY) { if($p->{$name}->{fill}) { @@ -185,6 +179,7 @@ sub PlotInit { } else { plot_write($fh,"plot '-' matrix with image, '-' matrix using 1:2:(sprintf('%i', \$3)) with labels tc rgb \"#ffffff\" font ',10'"); +# plot_write($fh,"plot '-' matrix with image, '-' matrix using 1:2:(sprintf('%i', \$3)):3 with labels tc palette font ',10'"); } } else { @@ -212,7 +207,7 @@ sub PlotDraw { plot_write($p->{$name}->{fh},($i/$p->{$name}->{xscale})." ".$p->{$name}->{value}->[$j]->[$i]); } else { - plot_write($p->{$name}->{fh},(($i-$p->{$name}->{entries})/$p->{$name}->{xscale})." ".$p->{$name}->{value}->[$j]->[$i]); + plot_write($p->{$name}->{fh},(($i-$p->{$name}->{entries})/($p->{$name}->{xscale}||1))." ".($p->{$name}->{value}->[$j]->[$i]||0)); } } plot_write($p->{$name}->{fh},"e"); @@ -230,17 +225,8 @@ sub PlotDraw { } - if($p->{$name}->{type} == TYPE_HEATMAP) { - if($p->{$name}->{showvalues}) { - for(my $j=0; $j<$p->{$name}->{curves}; $j++) { - for(my $i=0; $i< $p->{$name}->{entries}; $i++) { - plot_write($p->{$name}->{fh},($p->{$name}->{value}->[$j]->[$i]||0)." ",1); - } - plot_write($p->{$name}->{fh}," ",0); - } - plot_write($p->{$name}->{fh},"e"); - plot_write($p->{$name}->{fh},"e"); - } + if($p->{$name}->{type} == TYPE_HEATMAP) { + if($p->{$name}->{showvalues}) { for(my $j=0; $j<$p->{$name}->{curves}; $j++) { for(my $i=0; $i< $p->{$name}->{entries}; $i++) { plot_write($p->{$name}->{fh},($p->{$name}->{value}->[$j]->[$i]||0)." ",1); @@ -249,6 +235,16 @@ sub PlotDraw { } plot_write($p->{$name}->{fh},"e"); plot_write($p->{$name}->{fh},"e"); + } + + for(my $j=0; $j<$p->{$name}->{curves}; $j++) { + for(my $i=0; $i< $p->{$name}->{entries}; $i++) { + plot_write($p->{$name}->{fh},($p->{$name}->{value}->[$j]->[$i]||0)." ",1); + } + plot_write($p->{$name}->{fh}," ",0); + } + plot_write($p->{$name}->{fh},"e"); + plot_write($p->{$name}->{fh},"e"); } @@ -265,7 +261,6 @@ sub PlotDraw { sub PlotAdd { my($name,$value,$curve) = @_; $curve = 0 unless $curve; - push(@{$p->{$name}->{value}->[$curve]},$value||0); shift(@{$p->{$name}->{value}->[$curve]});