#!/bin/perl -w
use Genesis;
use Tk;
$f = new Genesis;
use encoding 'euc_cn';
our $JOB=$ENV{JOB};
our $STEP = $ENV{STEP};
$f->INFO(entity_type => 'step',entity_path => "$JOB/$STEP",data_type => 'LAYERS_LIST');
our @list = @{$f -> {doinfo}{gLAYERS_LIST}};
$mw = MainWindow->new;
$mw->geometry("15x10");
$mw->Label(-text => '請選擇輸出的層',-highlightbackground => 'yellow',
-highlightthickness => 5, -takefocus => 1,
-borderwidth => 2,
-font => [-size => 12],-foreground => 'green')->pack;
$mv = $mw->Frame->pack(-side =>'bottom',-fill=>'y');
$mw->Frame->pack(-side =>'left',-fill=>'both');
my $box = $mw->Listbox(-relief=>'sunken',-height=>10,-width=>10,-setgrid=>8,
-selectmode =>'multiple',-borderwidth=>3,-font=>[size=>24]);
$scroll = $mw->Scrollbar(-command => ['yview', $box]);
$box->configure(-yscrollcommand => ['set', $scroll]);
$box->pack(-side => 'left', -fill => 'both', -expand =>1);
$scroll->pack(-side => 'right', -fill => 'y')->pack;
$mv->Button(-text => '執行',-command => sub {do_print()},
-font => [-size => 18],-foreground => 'blue')->pack(-side=>'left',-padx=>13);
$mv->Button(-text => '退出',-command => sub{exit},
-font => [-size => 18],-foreground => 'blue')->pack(-side=>'right',-padx=>13);
$box->insert('end', @list);
MainLoop;
sub do_print {
my @n = $box->curselection();
my @list1 = @list[@n];
#$f->PAUSE("@list1");
foreach (@list1){
$f->COM ('affected_layer',mode=>"all",affected=>"no");
$f->COM ('clear_layers');
$f->COM ('display_layer',name=>"$_",display=>"yes",number=>1);
$f->COM ('work_layer',name=>"$_");
$f->COM ("output_layer_reset");
$f->COM ("output_layer_set,layer=$_,angle=0,mirror=no,x_scale=1,y_scale=1,comp=0,polarity=positive,setupfile=,setupfiletmp=,line_units=inch,gscl_file=,step_scale=no");
$f->COM("output,job=$JOB,step=net,format=DXF,dir_path=D:/,prefix=,suffix=,break_sr=yes,break_symbols=yes,break_arc=no,scale_mode=all,surface_mode=contour,min_brush=1,units=inch,x_anchor=0,y_anchor=0,x_offset=0,y_offset=0,line_units=inch,override_online=yes,pads_2circles=no,draft=no,contour_to_hatch=no,pad_outline=no,output_files=multiple,file_ver=old");
}
}