use strict;
no strict 'subs';
-our $ptscale= 72/25.4 / 7.0;
+our $scale= 7.0;
+our $ptscale= 72/25.4 / $scale;
our $psu_ulen= 4.5;
our $psu_edgelw= 0.5;
our $lmu_txtboxoff= $lmu_marklw / 2;
our $lmu_txtboxlw= 1;
+our $olu_left= 10 * $scale;
+our $olu_right= 217 * $scale - $olu_left;
+our $olu_bottom= 20 * $scale;
+our $olu_top= 270 * $scale - $olu_top;
+our $olu_textheight= 20;
+our $olu_gap_x= 5;
+our $olu_gap_y= 5;
+
our $pi= atan2(0,-1);
our $draw_t_def= '1';
sub o ($) { $o .= $_[0]; }
sub ol ($) { $ol .= $_[0]; }
+sub oflushpage () {
+ print $o, $ol, " showpage\n"
+ or die $!;
+ $o=$ol='';
+}
our $o_path_verb;
$defobj_save= undef;
}
+sub cmd__runobj ($) {
+ my ($obj_id)=@_;
+ my ($c)
+ local (@al);
+ dv("cmd__runobj $obj_id ",'$ctx',$ctx);
+ foreach $c (@{ $objs{$obj_id}{CmdLog} }) {
+ @al= @$c;
+ next if $al[0] eq 'enddefobj';
+ cmd__one();
+ }
+}
+
sub cmd_obj { cmd__obj(1); }
sub cmd_objflip { cmd__obj(-1); }
sub cmd__obj ($) {
my ($flipsignum)=@_;
my ($obj_id, $ctx_save, $pfx, $actual, $formal_id, $formal, $formcv);
- my ($c, $ctx_inobj, $obj, $id, $newid, $newpt);
+ my ($ctx_inobj, $obj, $id, $newid, $newpt);
$obj_id= can(\&cva_idstr);
$actual= can(\&cva_idex);
$formal_id= can(\&cva_idstr);
$ctx->{Draw}{T}= $ctx_save->{Draw}{T};
$ctx->{Draw}{L}= $ctx_save->{Draw}{L};
$ctx->{Draw}{L} =~ s/L//;
-dv("cmd__obj $obj_id ",'$ctx',$ctx);
- {
- local (@al);
- foreach $c (@{ $obj->{CmdLog} }) {
- @al= @$c;
- next if $al[0] eq 'enddefobj';
- cmd__one();
- }
- };
+ cmd__runobj($obj_id);
if (@al && $al[0] eq '=') {
$pfx= ''; shift @al;
} else {
}
}
+sub cmd_library {
+ my ($obj_id, $y, $x, $ctx_save, $width, $height);
+ my ($max_x, $min_x, $max_y, $min_y);
+ $x=$olu_left; $y=$olu_bottom; undef $nxty;
+ $ctx_save= $ctx;
+ foreach $obj_id (sort keys %objs) {
+ $obj= $objs{$obj_id};
+ foreach $loc (values %{ $obj->{Loc} }) {
+ upd_min(\$min_x, $loc->{X} - abs($psu_allwidth * cos($loc->{A})));
+ upd_max(\$max_x, $loc->{X} + abs($psu_allwidth * cos($loc->{A})));
+ upd_min(\$min_y, $loc->{Y} - abs($psu_allwidth * sin($loc->{A})));
+ upd_max(\$max_y, $loc->{Y} + abs($psu_allwidth * sin($loc->{A})));
+ }
+ newctx();
+ for (;;) {
+ $width= $max_x - $min_x;
+ $height= $max_y - $min_y;
+ if ($width > $height) {
+ $ctx->{Trans}{A}= 0;
+ $ctx->{Trans}{X}= $x - $min_x;
+ $ctx->{Trans}{Y}= $y - $min_y + $olu_textheight;
+ } else {
+ ($width,$height)=($height,$width);
+ $ctx->{Trans}{A}= 0.5 * $pi;
+ $ctx->{Trans}{X}= $x + $max_y;
+ $ctx->{Trans}{Y}= $y - $min_x + $olu_textheight;
+ }
+ if (defined $nxty && $x + $width > $olu_right) {
+ $x= $olu_left;
+ $y= $nxty;
+ }
+ if ($y + $height > $olu_right) {
+ oflushpage();
+ $x=$olu_left; $y=$olu_bottom; undef $nxty;
+ }
+ $ctx->{InRunObj}= $ctx_save->{InRunObj}."${obj_id}//";
+ $ctx->{Draw}= $ctx_save->{Draw};
+ cmd__runobj($obj_id);
+ ol(" gsave\n".
+ " /s ($obj_id) def\n".
+ " lf setfont\n ".
+ ($x + 0.5*$width)." ".($y - $olu_textheight)." moveto\n".
+ " s stringwidth pop 0.5 mul 0 rmoveto\n".
+ " s show grestore\n");
+ $x += $width + $olu_gap_x;
+ $yy= $y + $height + $olu_gap_y;
+ $nxty= $yy unless defined $nxty && $nxty >= $yy;
+ }
+ }
+}
+
sub cmd__one {
cmd__do();
}
cmd__one();
}
-print $o, $ol, " showpage\n"
- or die $!;
+oflushpage();