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
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....
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
-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:
our $olu_textallowperc= $lmu_marktpt * 5.0/11;
our $pi= atan2(0,-1);
+our $output_layer= 5;
sub allwidth2 ($) {
my ($radius)= @_;
# $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='';
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 ($$) {
newctx();
$ctx->{CmdLog}= [ ];
$ctx->{InDefObj}= $id;
- $ctx->{Draw}= '';
+ $ctx->{Draw}= 'X';
}
sub cmd_enddef {
}
}
+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); }
N MNo
O MNO
m mnol);
-
-$ctx->{Draw}= 'RLMN';
our $quiet=0;
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 -$_";
}
select(STDOUT); $|=1;
}
+$ctx->{Draw}= '';
+
+@al= qw(layer 5);
+cmd__one();
+
while (<>) {
next if m/^\s*\#/;
chomp; s/^\s+//; s/\s+$//;