chiark / gitweb /
new matrix processing for plan overlay registration
authorian <ian>
Sun, 1 Jun 2008 18:27:59 +0000 (18:27 +0000)
committerian <ian>
Sun, 1 Jun 2008 18:27:59 +0000 (18:27 +0000)
layout/.cvsignore
layout/Makefile
layout/genoverlayinfo [new file with mode: 0755]
layout/informat.txt
layout/layout
layout/make-dgram-make
layout/matrix-demonstrate.ps [new file with mode: 0644]
layout/redactgraph.c

index bf50641248768de5a1b073c928f650139446d9ab..25ac19a1121d911c3752539d658b9b3eea52f594 100644 (file)
@@ -17,6 +17,7 @@ tmp.*
 ui-plan-*.ppm
 ui-plan-*.crop-info
 ui-plan-*.overlay-info
+ui-plan-*.matrix-info
 parts.ps
 *-a.ps
 ours.graph.c
@@ -26,6 +27,7 @@ ours.raw.neato
 ours.redacted.neato.ps
 ours.redacted.neato
 ours.redacted.forsafety
+ours.redacted.for-ui
 ours.redacted.shellvars
 ours.layout-data.c
 detectors.pin-info
index e7c74fe60829e936cb7d90aa32e025db378125f4..5c7c5547e05f658911021b62bfb623673cbab4e3 100644 (file)
@@ -3,7 +3,8 @@ include ../common.make
 
 M4INCS=                parts.i4
 
-LAYOUT=                ./layout -R270
+ROTATE=                270
+LAYOUT=                ./layout -R$(ROTATE)
 
 E_TRACK=       ArsCLMNo
 LAYOUTOPTS_ALL=        -ep=*Cm
@@ -14,6 +15,8 @@ XLAYOUTOPTS_LAYER= -e'=5AN' -E'*~=5rsm' -e'p~=5r' -e'*~=9C' -e'*=*l' \
                $(LAYOUTOPTS_PS)
 
 PLANUI_PSDPI= 72
+PLANUI_WIDTH= 595
+PLANUI_HEIGHT= 842
 
 LAYOUTOPTS_SEGS= '-e*=*rm' -Lsubseglwm=80 -Lsubseglwe=150 -Lsubseglwq=50
 
@@ -29,8 +32,6 @@ LPAGES=        $(foreach x, 0 1 2 3 4 5 6, $(foreach y, 1 2 3 4 5, ours-p4-$xx$y.ps))
 
 CPROGS=                subseg2display compose-segenco
 
-CPPFLAGS +=    -DPLANUI_PSDPI=$(PLANUI_PSDPI)
-
 default:       $(CPROGS) for-test-ui layers extras
 all:           default lpages
 for-pic:       ours+pindata.asm
@@ -130,7 +131,8 @@ compose-segenco: compose-segenco.o
 
 %.segenco.ppm: %.segenco.ps Makefile
                gs -dNOPAUSE -dBATCH -dSAFER -q \
-                       -sDEVICE=ppmraw -r$(PLANUI_PSDPI) -g595x842 \
+                       -sDEVICE=ppmraw -r$(PLANUI_PSDPI) \
+                       -g$(PLANUI_WIDTH)x$(PLANUI_HEIGHT) \
                        -sOutputFile=$@.new $< && mv -f $@.new $@
 
 ours.graph.c:  extractgraph ours.dgram-bot.p0.segenco.ps
@@ -170,7 +172,13 @@ parts.ps:  showlib.d4 layout
 t.ppm:         ours.dgram-bot.pa.segenco.ppm x.gdb subseg2display
                gdb -x x.gdb
 
-ui-plan-%.ppm: ours.dgram-%.pa.segenco.ppm Makefile
+ui-plan-%.matrix-info: ours.dgram-%.p0.segenco.ps matrix-demonstrate.ps
+               sed -n '1,/^%L matrix here/p' matrix-demonstrate.ps >$@.ps.new
+               sed -n '/^%L matrix begin/,/^%L matrix end/p' $< >>$@.ps.new
+               sed -e '1,/^%L matrix here/d' matrix-demonstrate.ps >>$@.ps.new
+               gs -sDEVICE=nullpage -dBATCH=1 -q $@.ps.new $o
+
+ui-plan-%.ppm: ours.dgram-%.pa.segenco.ppm
                pnmcrop -verbose 2>&1 <$< >$@.1.new | tee ui-plan-$*.crop-info
                pnmflip <$@.1.new -ccw >$@.2.new
                pnmpad <$@.2.new -white -l5 -r5 -t5 -b5 $o
@@ -178,12 +186,9 @@ ui-plan-%.ppm:     ours.dgram-%.pa.segenco.ppm Makefile
 ui-plan-%.crop-info: ui-plan-%.ppm
                @:
 
-ui-plan-%.overlay-info: ui-plan-%.crop-info ours.redacted.for-ui Makefile
-               perl -ne 'm/^pnmcrop: cropping (\d+) \w+ off the (\w+)$$/' \
-                     -e ' and print "layout-dgram-cropped $$2 $$1\n";' \
-                       <ui-plan-$*.crop-info >$@.new
-               egrep '^[^#]' <ours.redacted.for-ui >>$@.new
-               mv -f $@.new $@
+ui-plan-%.overlay-info: genoverlayinfo \
+       ui-plan-%.crop-info ours.redacted.for-ui ui-plan-%.matrix-info
+               ./$^ $(PLANUI_HEIGHT) $(PLANUI_PSDPI) $o
 
 subseg2display.o compose-segenco.o: segcmap.h
 
diff --git a/layout/genoverlayinfo b/layout/genoverlayinfo
new file mode 100755 (executable)
index 0000000..69574ea
--- /dev/null
@@ -0,0 +1,60 @@
+#!/usr/bin/perl
+
+use IO::Handle;
+
+@ARGV==5 or die;
+($cropinfo,$forui,$matrixinfo, $height,$psdpi)=@ARGV;
+
+open M, $matrixinfo or die $!;
+$!=0; @matrix= <M>;
+@matrix==6 or die $!;
+map { die "$_ ?" unless m/^[-0-9.]+$/; } @matrix;
+M->error and die $!;
+close M or die $!;
+
+# inverting the matrix ??
+$d= 0;
+for ($i=0; $i<4; $i+=2) {
+    $d += $matrix[$i]*$matrix[$i];
+}
+$d= 1/$d;
+for ($i=0; $i<4; $i++) {
+    $matrix[$i] *= $d;
+}
+$matrix[1] *= -1;
+$matrix[2] *= -1;
+
+print STDERR join("\n",@matrix),"\n";
+
+open C, $cropinfo or die $!;
+while (<C>) {
+    next unless m/^pnmcrop: cropping (\d+) \w+ off the (\w+)$/;
+    $crop{$2}= $1;
+}
+C->error and die $!;
+close C or die $!;
+
+open U, $forui or die $!;
+while (<U>) {
+    chomp;
+    next unless m/^[^\#]/;
+    m/^(layout-subseg-end \w+ \w \w) ([0-9.]+) ([0-9.]+)$/ or die "$_ ?";
+    ($lhs, $xup,$yup) = ($1,$2,$3);
+
+    $xup -= $matrix[4];
+    $yup -= $matrix[5];
+
+    $x = $xup*$matrix[0] + $yup*$matrix[2];
+    $y = $xup*$matrix[1] + $yup*$matrix[3];
+
+    $x *= $psdpi / 72.0;
+    $y *= $psdpi / 72.0;
+
+    $y= $height - $y;
+#    $x -= $crop{'left'};
+#    $y -= $crop{'top'};
+
+    printf "%s %d %d\n", $lhs, $x, $y or die $!;
+}
+U->error and die $!;
+close U or die $!;
index 834a3034c51692635b22cada46867bcdbe6dbade..6b329defb054b4124edd467b45a537306939504b 100644 (file)
@@ -324,6 +324,8 @@ Special comments in PostScript:
        from the loc X0,Y0,A0 to X1,Y1,A1.  I is a counter which starts
        at 0 and is simply there to help cross-reference between
        various programs and formats.
+  %L matrix begin
+  %L matrix end
 
  Scope S is
    O!    when defining object or part O
index f131517fabbe767c808d1114ed3d6cd0cac9c504..1186a7884508e576fbb4c86a4d8c9a05359e58a8 100755 (executable)
@@ -1757,6 +1757,7 @@ sub cmd__one {
 o("%!\n".
   "  /lf /Courier-New findfont $lmu_marktpt scalefont def\n".
   "  /sf /Courier-Bold findfont $lmu_segtpt scalefont def\n".
+  "%L matrix begin\n".
   "$shiftrotate".
   "  gsave\n");
 
@@ -1768,6 +1769,8 @@ if ($page_x || $page_y) {
 o("  -$ps_page_xmul $page_x mul  -$ps_page_ymul $page_y mul  translate\n".
   "  $ptscale $ptscale scale\n");
 
+o("%L matrix end\n");
+
 newctx();
 
 open DEBUG, ($debug ? ">&2" : ">/dev/null") or die $!;
index 44c90029e717d5ef6d1b840baa547fe0b1ed969e..18d0b2d0377694b5c9b9f7d5d50e1420725f02dc 100755 (executable)
@@ -8,5 +8,15 @@ $stem.dgram-$dgram.run-layout: $stem.d4 layout $stem.dgram.m
        printf '#!/bin/sh -ex\n\$(LAYOUT) "\$\$@" %s \$<\n' "$args" >\$@.new
        chmod +x \$@.new && mv -f \$@.new \$@
 
+$stem.dgram-$dgram.matrix-info: \
+  ours.dgram-%.p0.segenco.ps matrix-demonstrate.ps
+END
+       cat <<'END'
+               sed -n '1,/^%L matrix here/p' matrix-demonstrate.ps >$@.ps.new
+               sed -n '/^%L matrix begin/,/^%L matrix end/p' $< >>$@.ps.new
+               sed -e '1,/^%L matrix here/d' matrix-demonstrate.ps >>$@.ps.new
+               gs -sDEVICE=nullpage -dBATCH=1 -q $@.ps.new $o
+
+
 END
 done
diff --git a/layout/matrix-demonstrate.ps b/layout/matrix-demonstrate.ps
new file mode 100644 (file)
index 0000000..afec16c
--- /dev/null
@@ -0,0 +1,22 @@
+%!
+
+% Hideous linear algebra
+% may or may not be right but hacked until it worked
+% with genoverlayinfo
+
+/printflt { (......................) cvs print (\n) print } bind def
+
+ 0 0 transform
+ 0 1 dtransform
+ 1 0 dtransform
+
+%L matrix here
+
+     idtransform
+     exch printflt printflt
+
+     idtransform
+     exch printflt printflt
+
+     itransform
+     exch printflt printflt
index f7a351f6fa48c47af69c25c8f68885ec4f4996f0..2f38ebc94d2bc91f32634b063dd816ce0fe576f3 100644 (file)
@@ -875,8 +875,7 @@ static void printforui(void) {
             edgeend->edge->subseg->segment->segname,
             edgeend->edge->subseg->movfeat,
             edgeend->edge->movpos,
-            node->x * 72.0 / PLANUI_PSDPI,
-            node->y * 72.0 / PLANUI_PSDPI);
+            node->x, node->y);
     }
   }
 }