From ad7015f1ad802035a80b47349ea1eca7891b7578 Mon Sep 17 00:00:00 2001 From: Michael Wiebusch Date: Fri, 16 Jan 2015 16:54:43 +0100 Subject: [PATCH] update on GUI --- user_interface/coral_scanner.css | 10 +++++ user_interface/coral_scanner.js | 2 + user_interface/coral_scanner.pm | 25 +++++++++--- .../{settings_subs.pm => has_settings.pm} | 22 ++++------- user_interface/pmt_ro.pm | 3 +- user_interface/table_control.pm | 38 +++++++++++-------- 6 files changed, 64 insertions(+), 36 deletions(-) rename user_interface/{settings_subs.pm => has_settings.pm} (79%) diff --git a/user_interface/coral_scanner.css b/user_interface/coral_scanner.css index e4df286..612bc16 100644 --- a/user_interface/coral_scanner.css +++ b/user_interface/coral_scanner.css @@ -16,6 +16,16 @@ } + +div.padded { + padding:10px; + +} + +div.settings_form{ + padding:10px; + padding-right:250px; +} div.header { font-size:13pt; diff --git a/user_interface/coral_scanner.js b/user_interface/coral_scanner.js index 7afa580..8602eb4 100644 --- a/user_interface/coral_scanner.js +++ b/user_interface/coral_scanner.js @@ -23,7 +23,9 @@ $(document).ready(function(){ timer = $.timer(function() { }); + unfolds($("#show_main_controls"),$("#main_controls_container")); unfolds($("#show_pmt_ro_settings"),$("#pmt_ro_settings_container")); + unfolds($("#show_table_control_settings"),$("#table_control_settings_container")); }); diff --git a/user_interface/coral_scanner.pm b/user_interface/coral_scanner.pm index 5cf8c72..6effc5f 100644 --- a/user_interface/coral_scanner.pm +++ b/user_interface/coral_scanner.pm @@ -12,8 +12,9 @@ use SVG; use CGI ':standard'; -use settings_subs; -# our @ISA = qw/has_settings/; # assimilate the methods of the has_settings class +# use settings_subs; +use has_settings; +our @ISA = qw/has_settings/; # assimilate the methods of the has_settings class use pmt_ro; @@ -54,7 +55,7 @@ sub new { bless($self, $class); $self->{pmt_ro} = pmt_ro->new(); - $self->{pmt_control} = table_control->new(); + $self->{table_control} = table_control->new(); return $self; } @@ -82,16 +83,30 @@ sub main_html { ] ); - + print h2 "Coral Scanner"; print "
"; + print "

main controls

"; + print "
"; + print ""; + $self->{table_control}->scan_pattern_to_svg(); + print ""; + print br; + print "some content!"; + print "
"; + + print "

pmt_ro settings

"; - print "
"; + print "
"; $self->{pmt_ro}->settings_form(); print "
"; + print "

table_control settings

"; + print "
"; + $self->{table_control}->settings_form(); + print "
"; print "
"; diff --git a/user_interface/settings_subs.pm b/user_interface/has_settings.pm similarity index 79% rename from user_interface/settings_subs.pm rename to user_interface/has_settings.pm index 8763611..f415a7c 100644 --- a/user_interface/settings_subs.pm +++ b/user_interface/has_settings.pm @@ -1,20 +1,9 @@ -package settings_subs; +package has_settings; use Storable qw(lock_store lock_retrieve); use misc_subs; -BEGIN { - require Exporter; - # set the version for version checking - our $VERSION = 1.00; - # Inherit from Exporter to export functions and variables - our @ISA = qw(Exporter); - # Functions and variables which are exported by default - our @EXPORT = qw(load_settings save_settings reset_settings settings_form); - # Functions and variables which can be optionally exported - #our @EXPORT_OK = qw($Var1 %Hashit func3); -} sub load_settings { @@ -52,15 +41,18 @@ sub reset_settings { sub settings_form { my $self=shift; + my %options=@_; my $settings = $self->load_settings(); my $settings_desc = $self->{settings_desc}; + + my $header=$options{header}; - printHeader('text/html'); + printHeader('text/html') if $header; print ' -
+
'; diff --git a/user_interface/pmt_ro.pm b/user_interface/pmt_ro.pm index 653d4ef..17d7a2d 100644 --- a/user_interface/pmt_ro.pm +++ b/user_interface/pmt_ro.pm @@ -9,8 +9,9 @@ use POSIX; use FileHandle; use regio; -use settings_subs; use misc_subs; +use has_settings; +our @ISA = qw/has_settings/; # assimilate the methods of the has_settings class ## methods diff --git a/user_interface/table_control.pm b/user_interface/table_control.pm index 6bbae0d..e26c22e 100644 --- a/user_interface/table_control.pm +++ b/user_interface/table_control.pm @@ -14,9 +14,9 @@ use CGI; # use has_settings; # our @ISA = qw/has_settings/; # assimilate the methods of the has_settings class -use settings_subs; use misc_subs; - +use has_settings; +our @ISA = qw/has_settings/; # assimilate the methods of the has_settings class ## methods @@ -51,7 +51,6 @@ sub new { sample_step_size => 1, sample_aperture_dia => 1, - scan_pattern_svg_file => "./scan_pattern.svg", scan_pattern_style => "meander" @@ -72,7 +71,6 @@ sub new { sample_step_size => "The step size/width for the scan pattern in mm", sample_aperture_dia => "Estimate of the radiation aperture in mm", - scan_pattern_svg_file => "Filename for the visualization (svg image) of the scan pattern", scan_pattern_style => "Defines the scan modus, available options are 'linebyline' and 'meander'" }; @@ -378,6 +376,8 @@ sub scan_pattern_to_svg { $self->require_run("load_settings"); + my $svg_file = $options{svg_file}; + my $scan_pattern = $self->scan_pattern(style => $style); @@ -391,6 +391,10 @@ sub scan_pattern_to_svg { my $mm2pix = 1; # pixels per mm # create an SVG object with a size of 40x40 pixels + + my $pic_width = 480; + my $pic_height = 260; + my $svg = SVG->new( -printerror => 1, -raiseerror => 0, @@ -401,11 +405,11 @@ sub scan_pattern_to_svg { #-namespace => 'mysvg', -inline => 1, id => 'document_element', - width => 800, - height => 600, + width => $pic_width, + height => $pic_height, ); - my $scale = 24; + my $scale = 12; my $scaler = $svg->group( transform => "scale($scale)" @@ -422,7 +426,7 @@ sub scan_pattern_to_svg { height => ($sample_rect_y2 - $sample_rect_y1)+$aperture_dia, style=>{ 'stroke'=>'black', - 'fill'=>'none', + 'fill'=>'white', 'stroke-width'=>5/$scale, } ); @@ -430,7 +434,8 @@ sub scan_pattern_to_svg { my $lastpoint; my $counter=0; for my $point (@$scan_pattern) { - last if ($counter++ > 600); + + last if (($point->{x} - $sample_rect_x1)*$scale > $pic_width); if(1){ @@ -469,13 +474,16 @@ sub scan_pattern_to_svg { } - - my $svgfile = $self->{settings}->{scan_pattern_svg_file}; + 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->xmlify; + } - open(SVGFILE, ">".$svgfile); - # now render the SVG object, implicitly use svg namespace - print SVGFILE $svg->xmlify; - close(SVGFILE); + return " "; } -- 2.43.0