chiark / gitweb /
library
authorian <ian>
Thu, 29 Jan 2004 19:14:37 +0000 (19:14 +0000)
committerian <ian>
Thu, 29 Jan 2004 19:14:37 +0000 (19:14 +0000)
dumplib.i4 [deleted file]
layout/layout
layout/showlib.m4 [new file with mode: 0644]

diff --git a/dumplib.i4 b/dumplib.i4
deleted file mode 100644 (file)
index 1d43018..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-include(`parts.i4')
-library
index 5f3adee0c5b6cc02ed25585be45cf1a7d3344745..4657c3559d6fdd72beea35f17d4707826dcdd4b6 100755 (executable)
@@ -30,10 +30,11 @@ 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 $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);
 
@@ -158,6 +159,15 @@ sub v_dist ($$) {
     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);
@@ -661,7 +671,7 @@ sub cmd_enddefobj {
 
 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} }) {
@@ -760,24 +770,37 @@ dv("cmd__do $ctx @al ",'$ctx',$ctx);
     }
 }
 
-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;
@@ -787,28 +810,36 @@ sub cmd_library {
                $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 {
diff --git a/layout/showlib.m4 b/layout/showlib.m4
new file mode 100644 (file)
index 0000000..fcba8c2
--- /dev/null
@@ -0,0 +1,3 @@
+include(`parts.i4')
+#showlibrary pt_peco_c* pt_peco_l* pt_peco_s* cross_peco_s
+showlibrary