]> jspc29.x-matter.uni-frankfurt.de Git - coral.git/commitdiff
can display matrix plot of scan in browser
authorMichael Wiebusch <m.wiebusch@gsi.de>
Wed, 21 Jan 2015 16:44:44 +0000 (17:44 +0100)
committerMichael Wiebusch <m.wiebusch@gsi.de>
Wed, 21 Jan 2015 16:44:44 +0000 (17:44 +0100)
user_interface/coral_scanner.pm
user_interface/misc_subs.pm
user_interface/table_control.pm

index 4ea8d6a37457e2c599bd00b553e3fc4d74e18515..87cf5af7fc3c52e713a01c98c2e84612d7fcc135 100644 (file)
@@ -107,6 +107,7 @@ sub main_html {
   print '</div>';
   
   print '<div id="scan_container" style="width: 600px; height: 270px; overflow-x: scroll;">';
+  $self->scan_to_svg();
   print '</div>';
   
   print br;
@@ -334,6 +335,9 @@ sub scan_to_svg {
   my $self = shift;
   my %options = @_;
   
+  my $html_tag = $options{html_tag};
+  my $svg_file = $options{svg_file};
+  
   my $tc = $self->{table_control};
   
   my $scan = $self->{scan_shm}->readShm();
@@ -366,11 +370,56 @@ sub scan_to_svg {
     height => $pic_height,
   );
   
+  my $step_size = $scan->{meta}->{step_size};
+  my $cols = $scan->{meta}->{cols};
+  my $rows = $scan->{meta}->{rows};
+  my $scale = 12;
   
-
+  my $scaler = $svg->group(
+      transform => "scale($scale)"
+  );
+  
+  my $tr1 = $scaler->group(
+      transform => "translate(0,0)"
+    );
+    
+  for (my $i=0; $i < $rows; $i++) {
+    for (my $j=0; $j < $cols; $j++) {
+      my $counts = $scan->{data}->[$i]->[$j];
+      my ($r,$g,$b) = false_color($counts,800,4000);
+      #= ($i*10,$j*10,$i*$j);
+      $tr1->rectangle(
+        x => $i*$step_size,
+        y => $j*$step_size,
+        width => $step_size*.9,
+        height => $step_size*.9,
+        title => $counts,
+        style =>{
+            'stroke'=>'none',
+            'fill'=>"rgb($r,$g,$b)",
+        });
+    }
+  }
+  
+  
+  if (defined($svg_file)){
+    open(SVGFILE, ">".$svg_file) or die "could not open $svg_file for writing!\n";
+    # now render the SVG object, implicitly use svg namespace
+    print SVGFILE $svg->xmlify;
+    close(SVGFILE);
+  } else {
+    print "<svg width=$pic_width height=$pic_height>" if $html_tag;
+    print $svg->xmlify;
+    print "</svg>" if $html_tag;
+  }
+  
+  return " ";
 
 }
 
 
 
+
+
+
 1;
index eda0f4819d3021affcf032ba11ce2923ef51e502..be35d851ed31bd3d7c059d0427476557574fc6dc 100644 (file)
@@ -8,7 +8,7 @@ BEGIN {
   # Inherit from Exporter to export functions and variables
   our @ISA = qw(Exporter);
   # Functions and variables which are exported by default
-  our @EXPORT = qw(printHeader min max echo require_run test hms_string daemonize);
+  our @EXPORT = qw(printHeader min max echo require_run test hms_string daemonize false_color);
   # Functions and variables which can be optionally exported
   #our @EXPORT_OK = qw($Var1 %Hashit func3);
 }
@@ -92,5 +92,15 @@ sub daemonize {
   umask 0;
 }
 
+sub false_color {
+  my $val = shift;
+  my $bot = shift;
+  my $top = shift;
+  
+  my $c = floor( abs($val/($top-$bot))*255);
+  return ($c,$c,$c);
+
+}
+
 
 1;
\ No newline at end of file
index b12b1ddd1514f72e0f3908804c2fd02b3ce70e49..a0bf1dadb912adfd98250faac78a204fa57e1201 100644 (file)
@@ -381,9 +381,6 @@ sub scan_pattern_to_svg {
   my $self = shift;
   my %options = @_;
   my $html_tag = $options{html_tag};
-  
-  #$self->require_run("load_settings");
-  
   my $svg_file = $options{svg_file};
   
   my $scan_pattern = $self->scan_pattern();