]> jspc29.x-matter.uni-frankfurt.de Git - daqtools.git/commitdiff
copied changes from Hades
authorMichael Traxler <M.Traxler@gsi.de>
Fri, 14 Nov 2014 16:32:10 +0000 (17:32 +0100)
committerMichael Traxler <M.Traxler@gsi.de>
Fri, 14 Nov 2014 16:32:10 +0000 (17:32 +0100)
tools/HPlot.pm

index 83b4e69a008f58d854b29acf2f3f639ba546a427..f1c73d436af2d033c848d635b093e7c10f020680 100755 (executable)
@@ -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]});