From: Michael Wiebusch Date: Wed, 21 Jan 2015 16:44:44 +0000 (+0100) Subject: can display matrix plot of scan in browser X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=70e83ca32fea027bd0fa440a89950179a8d9e2d4;p=coral.git can display matrix plot of scan in browser --- diff --git a/user_interface/coral_scanner.pm b/user_interface/coral_scanner.pm index 4ea8d6a..87cf5af 100644 --- a/user_interface/coral_scanner.pm +++ b/user_interface/coral_scanner.pm @@ -107,6 +107,7 @@ sub main_html { print ''; print '
'; + $self->scan_to_svg(); print '
'; 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 "" if $html_tag; + print $svg->xmlify; + print "" if $html_tag; + } + + return " "; } + + + 1; diff --git a/user_interface/misc_subs.pm b/user_interface/misc_subs.pm index eda0f48..be35d85 100644 --- a/user_interface/misc_subs.pm +++ b/user_interface/misc_subs.pm @@ -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 diff --git a/user_interface/table_control.pm b/user_interface/table_control.pm index b12b1dd..a0bf1da 100644 --- a/user_interface/table_control.pm +++ b/user_interface/table_control.pm @@ -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();