chiark / gitweb /
layers and kinds
authorian <ian>
Mon, 2 Feb 2004 00:38:58 +0000 (00:38 +0000)
committerian <ian>
Mon, 2 Feb 2004 00:38:58 +0000 (00:38 +0000)
.cvsignore
layout/informat.txt
layout/layout
layout/ours.m4
pcb/Makefile [new file with mode: 0644]
pic.make [new file with mode: 0644]
spice/Makefile [new file with mode: 0644]

index 36333db26654b7c123ede83c95cfea965a07522b..258a92a56234a327efd24b6364c0135aa3935fe4 100644 (file)
@@ -3,3 +3,5 @@ qs
 t
 u
 testjoin
+*.ps
+*.d4
index 147be4389f1b4dcf5bd18d36181ce412c79a5959..80bf23c3338a73b18684bc286ee1e26e874f882b 100644 (file)
@@ -33,6 +33,18 @@ Commands
   Defines loc T: start at loc F, go forward L, translate right R,
   turn left A (defaults are all 0).
 
+ layer KL
+  K is layer kind (letters and `_', may be empty), L is a layer depth
+  (digits).  Controls drawing style, by selecting appropriate parts of
+  the track and locs to draw, according to element selection rules.
+  Default outcomes:
+    K       L        result (description)     result (element letters)
+    any     other    nothing                  -
+    empty   current  default track            RLMNasco
+    `s'     current  nothing (`silent')       -
+    `l'     current  centrelines only         CLMNarso
+    other   current  everything               ARSCLMNO
+
  extend F T len L [R]        length L
  extend F T upto U [R]       s.t. perpendicular at T passes through U
  extend F T ang A R          subtending directionally A
@@ -101,9 +113,11 @@ Commands
 Command-line options
 
  -D       turn on debug (level 1)  } currently only debug levels are
- -Dnnn    set debug level to nnn   }  0 (none) and 1 (some)
+ -Dnnn    set debug level to nnn   }  0 (none) and 1 (some), default=0
+
+ -lL      output for layer L (default: 5)
 
- -e[ARSCcLlMNOm]...
+ -e<layersel>[ARSCcLlMNOm]...
           Turn on and off drawing of elements in groups.
           These are abbreviations for various -E... options.
            track                                                 -E....
@@ -120,8 +134,8 @@ Command-line options
              N  bars for top-level locs and those in obj's         MNo
              O  bars for everything, including those inside parts  MNO
              m  no bars (turns off labelling too)                  mnol
-            
- -E[ARSCLMNOarsclmno]...
+
+ -E<layersel>[ARSCLMNOarsclmno]...
           enable (capitals) or disable (lowercase) drawing of
          individual elements
              A  draw track swept area, with ticks
@@ -136,7 +150,23 @@ Command-line options
  -q       quiet: do not print info to stderr
           (default: prints bounding box, at the moment)
 
- Default is -d0, -EaRscLMNo, not quiet.
+<layersel> (for -e and -E) works as follows:
+
+ When file says `layer KL', default drawing element set is set
+ depending on K and L (see description of `layer' command), using last
+ specified -l layer.  Then all -e/-E options are scanned, in order,
+ and each one that matches modifies the drawing element set.
+
+ <layersel> is GN[D][C].  It matches `layer KL' iff the glob pattern G
+ (which may be empty) matches the whole of K, and layer restriction
+ N[D]C matches L.  C is several identical `=', `+' or `-'; D+ matches
+ L iff L>=D; D++ iff L>D; D+++ iff L>D+1 and so on; D- matches L iff
+ L<=D; D-- iff L<D; etc.; D= matches L iff L==D; D== iff D-1<=L<=D+1;
+ D=== iff D-2<=L<=D+2; etc.  If D is omitted the current layer (from
+ the most recent -l option) is used.  N may be empty or `~'; the
+ latter simply inverts the sense of the match.  If C is omitted then
+ `=' is assumed.
+
 
 Special comments in PostScript:
 
index 041bfc41c38f958838d3387f2558349a970f1425..f40e690a7ad90500a389714290b0703fdda16d2d 100755 (executable)
@@ -36,6 +36,7 @@ our $olu_textheight= 15;
 our $olu_textallowperc= $lmu_marktpt * 5.0/11;
 
 our $pi= atan2(0,-1);
+our $output_layer= 5;
 
 sub allwidth2 ($) {
     my ($radius)= @_;
@@ -63,13 +64,19 @@ our $allwidthmin= allwidth(undef);
 #  $ctx->{Trans}{A}       # not at plot-time)
 #  $ctx->{Trans}{R}       # but multiply all y coords by this!
 #  $ctx->{Draw}           # sequence of one or more chrs from uc $drawers
+#                         #  or X meaning never draw anything (eg in defobj)
 #
 #  $objs{$id}{CmdLog}
 #  $objs{$id}{Loc}
 #  $objs{$id}{Part}       # 1 iff object is a part
+#
+#  $eopts[]{GlobRe}       # regexp for K
+#  $eopts[]{LayerCheck}   # =$fn where &$fn($l) is true iff layer matches
+#  $eopts[]{DrawMods}     # modifier chars for drawing
 
 our $ctx;
 our %objs;
+our @eopts;
 our @al; # current cmd
 
 our $o='';
@@ -201,6 +208,7 @@ our %units_len= qw(- mm  mm 1  cm 10  m 1000);
 our %units_ang= qw(- d   r 1); $units_ang{'d'}= 2*$pi / 360;
 
 sub cva_len ($) { my ($sp)=@_; cva_units($sp,\%units_len); }
+sub cva_identity ($) { my ($sp)=@_; $sp; }
 sub cva_ang ($) { my ($sp)=@_; cva_units($sp,\%units_ang); }
 sub cva_absang ($) { input_absang(cva_ang($_[0])) }
 sub cva_units ($$) {
@@ -697,7 +705,7 @@ sub cmd__defobj ($) {
     newctx();
     $ctx->{CmdLog}= [ ];
     $ctx->{InDefObj}= $id;
-    $ctx->{Draw}= '';
+    $ctx->{Draw}= 'X';
 }
 
 sub cmd_enddef {
@@ -724,6 +732,38 @@ sub cmd__runobj ($) {
     }
 }
 
+sub cmd_layer {
+    my ($kl, $k,$l, $eo,$cc);
+    return if $ctx->{Draw} =~ m/X/;
+    $kl= can(\&cva_identity);
+    $kl =~ m/^([A-Za-z_]*)(\d+)$/ or die "invalid layer spec";
+    ($k,$l)=($1,$2);
+    if ($l != $output_layer) {
+       $ctx->{Draw} = '';
+    } elsif ($k eq '') {
+       $ctx->{Draw}= 'RLMN';
+    } elsif ($k eq 's') {
+       $ctx->{Draw}= '';
+    } elsif ($k eq 'l') {
+       $ctx->{Draw}= 'CLMN';
+    } else {
+       $ctx->{Draw}= 'ARSCLMNO';
+    }
+    print STDERR "layer $k $l drawdef |$ctx->{Draw}|\n";
+    foreach $eo (@eopts) {
+    print STDERR "layer $k $l eo $eo->{GlobRe}\n";
+       next unless $k =~ m/^$eo->{GlobRe}$/;
+    print STDERR "layer $k $l lc $eo->{LayerCheck}\n";
+       next unless &{ $eo->{LayerCheck} }($l);
+    print STDERR "layer $k $l dm $eo->{DrawMods}\n";
+       foreach $cc (split //, $eo->{DrawMods}) {
+           $ctx->{Draw} =~ s/$cc//ig;
+           $ctx->{Draw} .= $cc if $cc =~ m/[A-Z]/;
+       }
+    }
+    print STDERR "layer $k $l drawing |$ctx->{Draw}|\n";
+}    
+
 sub cmd_part { cmd__obj(Part); }
 sub cmd_obj { cmd__obj(1); }
 sub cmd_objflip { cmd__obj(-1); }
@@ -953,8 +993,6 @@ our %chdraw_emap= qw(A ARSc
                     N MNo
                     O MNO
                     m mnol);
-                    
-$ctx->{Draw}= 'RLMN';
 
 our $quiet=0;
 
@@ -967,22 +1005,38 @@ while (@ARGV && $ARGV[0] =~ m/^\-/) {
        if (s/^D(\d+)//) { $debug= $1; }
        elsif (s/^D//) { $debug++; }
        elsif (s/^q//) { $quiet=1; }
-       elsif (s/^([Ee])([a-zA-Z]+)//) {
-           my ($ee,$c,@c,$cc);
-           $ee= $1;
-           foreach $c (split //, $2) {
+       elsif (s/^(e)
+              ((?:[a-z]|\*|\?|\[[a-z][-a-z]*\])*?)
+              (\~?) (\d*) (\=*|\-+|\++)
+              ([a-z]+)//ix) {
+           my ($ee,$g,$n,$d,$c,$cc) = ($1,$2,$3,$4,$5,$6);
+           my ($eo, $invert, $lfn, $ccc, $sense,$limit);
+           $g =~ s/[?*]/\\$&/g;
+           $d= $output_layer if !length $d;
+           $invert= length $n;
+           if ($c =~ m/^[-+]/) {
+               $sense= ($c.'1') + 0;
+               $limit= ($sense * $d) + length($c) - 1;
+               $lfn= sub { $_[0] * $sense >= $limit xor $invert };
+           } else {
+               $limit= length($c) - 1;
+               $limit=0 if $limit<0;
+               $lfn= sub { abs($_[0] - $d) <= $limit xor $invert };
+           }
+           $ccc= '';
+           foreach $c (split //, $cc) {
                if ($ee eq 'e') {
                    die "bad -e option $c" unless defined $chdraw_emap{$c};
-                   @c= split //, $chdraw_emap{$c};
+                   $ccc .=  $chdraw_emap{$c};
                } else {
                    die "bad -E option $c" unless $c =~ m/[$drawers]/i;
-                   @c= ($c);
-               }
-               foreach $cc (@c) {
-                   $ctx->{Draw} =~ s/$cc//ig;
-                   $ctx->{Draw} .= $cc if $cc =~ m/[A-Z]/;
+                   $ccc .= $c;
                }
            }
+           $eo->{GlobRe}= $g;
+           $eo->{LayerCheck}= $lfn;
+           $eo->{DrawMods}= $ccc;
+           push @eopts, $eo;
        } else {
            die "unknown option -$_";
        }
@@ -996,6 +1050,11 @@ if ($debug) {
     select(STDOUT); $|=1;
 }
 
+$ctx->{Draw}= '';
+
+@al= qw(layer 5);
+cmd__one();
+
 while (<>) {
     next if m/^\s*\#/;
     chomp; s/^\s+//; s/\s+$//;
index 87221cb42fc772de4a943ea870cb7c3549d57ce7..ec6717f5760e57223a6687c4b970efbc144a12a3 100644 (file)
@@ -70,7 +70,7 @@ part l23_dj ^dualjn_peco_r ic
 
 extend l23_dj_oa l3_sh uptoang 180 -315
 
-#thinlines:
+layer l5
 extend l3_pbl sq_bl_o upto l3_lst
 rel sq_bl_o sq_bl_i 0 0 -90
 
@@ -84,7 +84,9 @@ extend sq_tr_i sq_br_o upto sq_bl_i
 rel sq_br_o sq_br_i 0 0 -90
 
 extend sq_br_i sq_bl_o2 upto sq_bl_o
-#endthinlines
+
+layer 5
+
 
 rel sq_tl_i l4_ct 352 37 180
 rel l4_ct l5_ct 0 37
diff --git a/pcb/Makefile b/pcb/Makefile
new file mode 100644 (file)
index 0000000..41e08b2
--- /dev/null
@@ -0,0 +1,19 @@
+
+M4INCS=                parts.i4
+
+LAYOUTOPTS=    -EArC
+
+all:           ours-l0.ps \
+               ours-l10.ps \
+               ours-l20.ps
+
+o=>$@.new && mv -f $@.new $@
+
+%.d4:          %.m4 $(M4INCS)
+               m4 -s <$< $o
+
+ours-l%.ps:    ours.d4 layout
+               ./layout <$< $(LAYOUTOPTS) $o
+
+clean:
+               -rm -f -- *.d4 *.ps
diff --git a/pic.make b/pic.make
new file mode 100644 (file)
index 0000000..41e08b2
--- /dev/null
+++ b/pic.make
@@ -0,0 +1,19 @@
+
+M4INCS=                parts.i4
+
+LAYOUTOPTS=    -EArC
+
+all:           ours-l0.ps \
+               ours-l10.ps \
+               ours-l20.ps
+
+o=>$@.new && mv -f $@.new $@
+
+%.d4:          %.m4 $(M4INCS)
+               m4 -s <$< $o
+
+ours-l%.ps:    ours.d4 layout
+               ./layout <$< $(LAYOUTOPTS) $o
+
+clean:
+               -rm -f -- *.d4 *.ps
diff --git a/spice/Makefile b/spice/Makefile
new file mode 100644 (file)
index 0000000..41e08b2
--- /dev/null
@@ -0,0 +1,19 @@
+
+M4INCS=                parts.i4
+
+LAYOUTOPTS=    -EArC
+
+all:           ours-l0.ps \
+               ours-l10.ps \
+               ours-l20.ps
+
+o=>$@.new && mv -f $@.new $@
+
+%.d4:          %.m4 $(M4INCS)
+               m4 -s <$< $o
+
+ours-l%.ps:    ours.d4 layout
+               ./layout <$< $(LAYOUTOPTS) $o
+
+clean:
+               -rm -f -- *.d4 *.ps