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 $olu_top= 270 * $scale - $olu_bottom;
+our $olu_gap_x= 30;
+our $olu_gap_y= 30;
+our $olu_textheight= 15;
+our $olu_textallowperc= $lmu_marktpt * 5.0/11;
our $pi= atan2(0,-1);
return sqrt($xd*$xd + $yd*$yd);
}
+sub upd_min ($$) {
+ my ($limr,$now)=@_;
+ $$limr= $now unless defined $$limr && $$limr <= $now;
+}
+sub upd_max ($$) {
+ my ($limr,$now)=@_;
+ $$limr= $now unless defined $$limr && $$limr >= $now;
+}
+
sub canf ($$) {
my ($converter,$defaulter)=@_;
my ($spec,$v);
sub cmd__runobj ($) {
my ($obj_id)=@_;
- my ($c)
+ my ($c);
local (@al);
dv("cmd__runobj $obj_id ",'$ctx',$ctx);
foreach $c (@{ $objs{$obj_id}{CmdLog} }) {
}
}
-sub cmd_library {
+sub cmd_showlibrary {
my ($obj_id, $y, $x, $ctx_save, $width, $height);
- my ($max_x, $min_x, $max_y, $min_y);
+ my ($max_x, $min_x, $max_y, $min_y, $nxty, $obj, $loc, $pat, $got, $glob);
+ my ($adj);
$x=$olu_left; $y=$olu_bottom; undef $nxty;
$ctx_save= $ctx;
foreach $obj_id (sort keys %objs) {
+ $got= 1;
+ foreach $glob (@al) {
+ $pat= $glob;
+ $got= !($pat =~ s/^\!//);
+ die "bad pat" if $pat =~ m/[^0-9a-zA-Z_*?]/;
+ $pat =~ s/\*/\.*/g; $pat =~ s/\?/./g;
+ last if $obj_id =~ m/^$pat$/;
+ $got= !$got;
+ }
+ next unless $got;
$obj= $objs{$obj_id};
+ $max_x=$max_y=$min_x=$min_y=undef;
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})));
+ upd_min(\$min_x, $loc->{X} - abs($psu_allwidth * sin($loc->{A})));
+ upd_max(\$max_x, $loc->{X} + abs($psu_allwidth * sin($loc->{A})));
+ upd_min(\$min_y, $loc->{Y} - abs($psu_allwidth * cos($loc->{A})));
+ upd_max(\$max_y, $loc->{Y} + abs($psu_allwidth * cos($loc->{A})));
}
newctx();
+
for (;;) {
$width= $max_x - $min_x;
$height= $max_y - $min_y;
- if ($width > $height) {
+ if ($width < $height) {
$ctx->{Trans}{A}= 0;
$ctx->{Trans}{X}= $x - $min_x;
$ctx->{Trans}{Y}= $y - $min_y + $olu_textheight;
$ctx->{Trans}{X}= $x + $max_y;
$ctx->{Trans}{Y}= $y - $min_x + $olu_textheight;
}
- if (defined $nxty && $x + $width > $olu_right) {
+ $adj= length($obj_id) * $olu_textallowperc - $width;
+ $adj=0 if $adj<0;
+ $width += $adj;
+ $ctx->{Trans}{X} += 0.5 * $adj;
+ if ($x + $width > $olu_right && defined $nxty) {
$x= $olu_left;
$y= $nxty;
- }
- if ($y + $height > $olu_right) {
+ undef $nxty;
+ } elsif ($y + $height > $olu_top && $y > $olu_bottom) {
oflushpage();
- $x=$olu_left; $y=$olu_bottom; undef $nxty;
+ $x= $olu_left; $y= $olu_bottom;
+ undef $nxty;
+ } else {
+ last;
}
- $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;
}
+
+ $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;
+ upd_max(\$nxty, $y + $height + $olu_gap_y + $olu_textheight);
}
+ @al= ();
}
sub cmd__one {