Index: trunk/util/pcblib-map/imgmap.sh =================================================================== --- trunk/util/pcblib-map/imgmap.sh (revision 393) +++ trunk/util/pcblib-map/imgmap.sh (nonexistent) @@ -1,116 +0,0 @@ -#!/bin/sh -png=map.png -pcb=map.pcb - -png_dims=`file $png | awk -F "[,]" '{ sub("x", " ", $2); print $2}'` - -awk -v "png_dims=$png_dims" -v "png_url=$png" ' -BEGIN { - q = "\"" - sub("^ *", "", png_dims) - sub(" *$", "", png_dims) - split(png_dims, A, " +") - png_sx = A[1] - png_sy = A[2] - ne = 0 -} - -function bump(idx, x, y) -{ - if ((E[idx, "minx"] == "") || (x < E[idx, "minx"])) - E[idx, "minx"] = x - if ((E[idx, "maxx"] == "") || (x > E[idx, "maxx"])) - E[idx, "maxx"] = x - if ((E[idx, "miny"] == "") || (y < E[idx, "miny"])) - E[idx, "miny"] = y - if ((E[idx, "maxy"] == "") || (y > E[idx, "maxy"])) - E[idx, "maxy"] = y -} - -# Element["" "rcy(150, bar-sign)" "C1" "acy150" 22500 95000 -2000 -4500 1 100 ""] -/^Element *[[]/ { - coords=$0 - sub("Element *[[]", "", coords) - for(n = 1; n <= 4; n++) { - match(coords, "[\"][^\"]*[\"]") - P[n] = substr(coords, RSTART+1, RLENGTH-2) - sub("[\"][^\"]*[\"]", "", coords) - } - split(coords, A, " ") - E[ne, "cmd"] = P[2] - E[ne, "cx"] = A[1] - E[ne, "cy"] = A[2] - ne++ - next -} - -#ElementLine [-11811 -13006 -11811 -11250 3937] -/^[ \t]*ElementLine *[[]/ { - sub("ElementLine *[[]", "", $0) - bump(ne-1, $1, $2) - bump(ne-1, $3, $4) - next -} - -#ElementArc [-11811 -13006 -11811 -11250 3937] -/^[ \t]*ElementArc *[[]/ { - sub("ElementArc *[[]", "", $0) - x = $1 - y = $2 - rx = $3 - ry = $4 - bump(ne-1, x-rx, y-ry) - bump(ne-1, x+rx, y+ry) - next -} - -#Via[260000 120000 7874 4000 0 3150 "" ""] -/^[ \t]*Via *[[]/ { - sub("Via *[[]", "", $0) - pcb_sx = $1 - pcb_sy = $2 - next -} - - -END { - scale_x = png_sx/pcb_sx - scale_y = png_sy/pcb_sy - - print "" - print "" - for(n = 0; n < ne; n++) { -# print E[n, "minx"], E[n, "maxx"], E[n, "miny"], E[n, "maxy"] - x1 = int((E[n, "minx"] + E[n, "cx"]) * scale_x) - x2 = int((E[n, "maxx"] + E[n, "cx"]) * scale_x) - y1 = int((E[n, "miny"] + E[n, "cy"]) * scale_y) - y2 = int((E[n, "maxy"] + E[n, "cy"]) * scale_y) - if (x1 < 0) - x1 = 0 - if (y1 < 0) - y1 = 0 - if (x1 > x2) { - tmp = x1 - x1 = x2 - x2 = tmp - } - if (y1 > y2) { - tmp = y1 - y1 = y2 - y2 = tmp - } - x1 -= 5 - y1 -= 5 - x2 += 5 - y2 += 5 -# print n, x1, y1, x2, y2, E[n, "cmd"] - url="http://igor2.repo.hu/cgi-bin/pcblib-param.cgi?cmd=" E[n, "cmd"] - gsub(" ", "+", url) - print " q E[n, " - } - print "" -} - -' < $pcb > a.html - - Property changes on: trunk/util/pcblib-map/imgmap.sh ___________________________________________________________________ Deleted: svn:executable ## -1 +0,0 ## -* \ No newline at end of property Index: trunk/util/pcblib-map/imgmap_fp.sh =================================================================== --- trunk/util/pcblib-map/imgmap_fp.sh (nonexistent) +++ trunk/util/pcblib-map/imgmap_fp.sh (revision 394) @@ -0,0 +1,116 @@ +#!/bin/sh +png=map.png +pcb=map.pcb + +png_dims=`file $png | awk -F "[,]" '{ sub("x", " ", $2); print $2}'` + +awk -v "png_dims=$png_dims" -v "png_url=$png" ' +BEGIN { + q = "\"" + sub("^ *", "", png_dims) + sub(" *$", "", png_dims) + split(png_dims, A, " +") + png_sx = A[1] + png_sy = A[2] + ne = 0 +} + +function bump(idx, x, y) +{ + if ((E[idx, "minx"] == "") || (x < E[idx, "minx"])) + E[idx, "minx"] = x + if ((E[idx, "maxx"] == "") || (x > E[idx, "maxx"])) + E[idx, "maxx"] = x + if ((E[idx, "miny"] == "") || (y < E[idx, "miny"])) + E[idx, "miny"] = y + if ((E[idx, "maxy"] == "") || (y > E[idx, "maxy"])) + E[idx, "maxy"] = y +} + +# Element["" "rcy(150, bar-sign)" "C1" "acy150" 22500 95000 -2000 -4500 1 100 ""] +/^Element *[[]/ { + coords=$0 + sub("Element *[[]", "", coords) + for(n = 1; n <= 4; n++) { + match(coords, "[\"][^\"]*[\"]") + P[n] = substr(coords, RSTART+1, RLENGTH-2) + sub("[\"][^\"]*[\"]", "", coords) + } + split(coords, A, " ") + E[ne, "cmd"] = P[2] + E[ne, "cx"] = A[1] + E[ne, "cy"] = A[2] + ne++ + next +} + +#ElementLine [-11811 -13006 -11811 -11250 3937] +/^[ \t]*ElementLine *[[]/ { + sub("ElementLine *[[]", "", $0) + bump(ne-1, $1, $2) + bump(ne-1, $3, $4) + next +} + +#ElementArc [-11811 -13006 -11811 -11250 3937] +/^[ \t]*ElementArc *[[]/ { + sub("ElementArc *[[]", "", $0) + x = $1 + y = $2 + rx = $3 + ry = $4 + bump(ne-1, x-rx, y-ry) + bump(ne-1, x+rx, y+ry) + next +} + +#Via[260000 120000 7874 4000 0 3150 "" ""] +/^[ \t]*Via *[[]/ { + sub("Via *[[]", "", $0) + pcb_sx = $1 + pcb_sy = $2 + next +} + + +END { + scale_x = png_sx/pcb_sx + scale_y = png_sy/pcb_sy + + print "" + print "" + for(n = 0; n < ne; n++) { +# print E[n, "minx"], E[n, "maxx"], E[n, "miny"], E[n, "maxy"] + x1 = int((E[n, "minx"] + E[n, "cx"]) * scale_x) + x2 = int((E[n, "maxx"] + E[n, "cx"]) * scale_x) + y1 = int((E[n, "miny"] + E[n, "cy"]) * scale_y) + y2 = int((E[n, "maxy"] + E[n, "cy"]) * scale_y) + if (x1 < 0) + x1 = 0 + if (y1 < 0) + y1 = 0 + if (x1 > x2) { + tmp = x1 + x1 = x2 + x2 = tmp + } + if (y1 > y2) { + tmp = y1 + y1 = y2 + y2 = tmp + } + x1 -= 5 + y1 -= 5 + x2 += 5 + y2 += 5 +# print n, x1, y1, x2, y2, E[n, "cmd"] + url="http://igor2.repo.hu/cgi-bin/pcblib-param.cgi?cmd=" E[n, "cmd"] + gsub(" ", "+", url) + print " q E[n, " + } + print "" +} + +' < $pcb > a.html + + Property changes on: trunk/util/pcblib-map/imgmap_fp.sh ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: trunk/util/pcblib-map/imgmap_page.sh =================================================================== --- trunk/util/pcblib-map/imgmap_page.sh (nonexistent) +++ trunk/util/pcblib-map/imgmap_page.sh (revision 394) @@ -0,0 +1,127 @@ +#!/bin/sh +png=map.png +pcb=map.pcb + +png_dims=`file $png | awk -F "[,]" '{ sub("x", " ", $2); print $2}'` + +awk -v "png_dims=$png_dims" -v "png_url=$png" ' +BEGIN { + q = "\"" + sub("^ *", "", png_dims) + sub(" *$", "", png_dims) + split(png_dims, A, " +") + png_sx = A[1] + png_sy = A[2] + ne = 0 + te = 0 +} + + +# Polygon("clearpoly") +# ( +# [5000 2500] [277500 2500] [277500 547500] [5000 547500] +# ) + +function bump(idx, x, y) +{ + if ((E[idx, "minx"] == "") || (x < E[idx, "minx"])) + E[idx, "minx"] = x + if ((E[idx, "maxx"] == "") || (x > E[idx, "maxx"])) + E[idx, "maxx"] = x + if ((E[idx, "miny"] == "") || (y < E[idx, "miny"])) + E[idx, "miny"] = y + if ((E[idx, "maxy"] == "") || (y > E[idx, "maxy"])) + E[idx, "maxy"] = y +} + +/^[ \t]*Polygon[(]/ { + getline + getline + gsub("[[\\]]", "", $0) + for(n = 1; n < NF; n+=2) + bump(ne, $n, $(n+1)) + ne++ + next +} + +# Text[296338 119704 0 670 "PARAMETRIC" "clearline"] +/^[ \t]*Text[[]/ { + sub("^[ \t]*Text[[]", "", $0) + T[te, "x"] = $1 + T[te, "y"] = $2 + T[te, "text"] = $5 + gsub("[\"]", "", T[te, "text"]) + te++ + next +} + +#Via[260000 120000 7874 4000 0 3150 "" ""] +/^[ \t]*Via *[[]/ { + sub("Via *[[]", "", $0) + pcb_sx = $1 + pcb_sy = $2 + next +} + + +END { + scale_x = png_sx/pcb_sx + scale_y = png_sy/pcb_sy + + print "" + print "" + for(n = 0; n < ne; n++) { + x1=(E[n, "minx"] + E[n, "cx"]) + x2=(E[n, "maxx"] + E[n, "cx"]) + y1=(E[n, "miny"] + E[n, "cy"]) + y2=(E[n, "maxy"] + E[n, "cy"]) + t = "" + + + for(i = 0; i < te; i++) { + x=T[i, "x"] + y=T[i, "y"] + if ((x>=x1) && (x<=x2) && (y>=y1) && (y<=y2)) { + t = i + break; + } + } +# print n, x1, y1, x2, y2, "|", t, T[t, "x"], T[t, "y"], T[t, "text"] > "/dev/stderr" + + x1 = int(x1 * scale_x) + x2 = int(x2 * scale_x) + y1 = int(y1 * scale_y) + y2 = int(y2 * scale_y) + if (x1 < 0) + x1 = 0 + if (y1 < 0) + y1 = 0 + if (x1 > x2) { + tmp = x1 + x1 = x2 + x2 = tmp + } + if (y1 > y2) { + tmp = y1 + y1 = y2 + y2 = tmp + } + x1 -= 5 + y1 -= 5 + x2 += 5 + y2 += 5 + if (x1 < 0) + x1 = 0 + if (y1 < 0) + y1 = 0 + url="http://igor2.repo.hu/pcblib/" tolower(T[t, "text"]) ".html" + gsub(" ", "+", url) + print " q T[t, " + T[t, "text"] = "-" + } + print "" +} + +' < $pcb > map.html + + Property changes on: trunk/util/pcblib-map/imgmap_page.sh ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property