diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2024-07-03 10:19:49 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2024-07-03 10:19:49 +0200 |
commit | 8dc8048d2cd4996825470bbfcb1e09e2a2630035 (patch) | |
tree | 9804282102f8c40d27407b9c94119b35eeb5013c /app/bin | |
parent | c9d0740841fbe0539e42e66d3865672bfcd3ac02 (diff) | |
parent | b6bd52cd7330a90fc0e44dbe6022551a8dd768a1 (diff) |
Merge branch 'feature/upstream' into develop
Diffstat (limited to 'app/bin')
-rw-r--r-- | app/bin/CMakeLists.txt | 631 | ||||
-rw-r--r-- | app/bin/acclkeys.h | 4 | ||||
-rw-r--r-- | app/bin/appdefaults.c | 349 | ||||
-rw-r--r-- | app/bin/archive.c | 477 | ||||
-rw-r--r-- | app/bin/archive.h | 6 | ||||
-rw-r--r-- | app/bin/bdf2xtp.c | 620 | ||||
-rw-r--r-- | app/bin/bitmaps/16pix/bridge.png | bin | 209 -> 0 bytes | |||
-rw-r--r-- | app/bin/bitmaps/CMakeLists.txt | 100 | ||||
-rw-r--r-- | app/bin/bitmaps/Info.xpm | 116 | ||||
-rw-r--r-- | app/bin/bitmaps/SVG/NotUsed/ease-broad.svg | 66 | ||||
-rw-r--r-- | app/bin/bitmaps/SVG/NotUsed/ease-cornu.svg | 61 | ||||
-rw-r--r-- | app/bin/bitmaps/SVG/NotUsed/ease-gt-broad.svg | 69 | ||||
-rw-r--r-- | app/bin/bitmaps/SVG/NotUsed/ease-gt-sharp.svg | 66 | ||||
-rw-r--r-- | app/bin/bitmaps/SVG/NotUsed/ease-lt-broad.svg | 67 | ||||
-rw-r--r-- | app/bin/bitmaps/SVG/NotUsed/ease-lt-sharp.svg | 66 | ||||
-rw-r--r-- | app/bin/bitmaps/SVG/NotUsed/ease-none.svg | 66 | ||||
-rw-r--r-- | app/bin/bitmaps/SVG/NotUsed/ease-normal.svg | 66 | ||||
-rw-r--r-- | app/bin/bitmaps/SVG/NotUsed/ease-sharp.svg | 66 | ||||
-rw-r--r-- | app/bin/bitmaps/background.xpm | 157 | ||||
-rw-r--r-- | app/bin/bitmaps/benchwork.xpm | 112 | ||||
-rw-r--r-- | app/bin/bitmaps/bezier-line.xpm | 98 | ||||
-rw-r--r-- | app/bin/bitmaps/bezier-track.xpm | 130 | ||||
-rw-r--r-- | app/bin/bitmaps/block.xpm | 138 | ||||
-rw-r--r-- | app/bin/bitmaps/bottom.xpm | 101 | ||||
-rw-r--r-- | app/bin/bitmaps/box.xpm | 93 | ||||
-rw-r--r-- | app/bin/bitmaps/bridge.xpm | 105 | ||||
-rw-r--r-- | app/bin/bitmaps/building.xpm | 125 | ||||
-rw-r--r-- | app/bin/bitmaps/car-inventory.xpm | 103 | ||||
-rw-r--r-- | app/bin/bitmaps/change-grid.xpm | 118 | ||||
-rw-r--r-- | app/bin/bitmaps/circle-center.xpm | 114 | ||||
-rw-r--r-- | app/bin/bitmaps/circle-filled-center.xpm | 145 | ||||
-rw-r--r-- | app/bin/bitmaps/circle-filled-tangent.xpm | 148 | ||||
-rw-r--r-- | app/bin/bitmaps/circle-line-center.xpm | 93 | ||||
-rw-r--r-- | app/bin/bitmaps/circle-line-tangent.xpm | 93 | ||||
-rw-r--r-- | app/bin/bitmaps/circle-line.xpm | 95 | ||||
-rw-r--r-- | app/bin/bitmaps/circle-tangent.xpm | 110 | ||||
-rw-r--r-- | app/bin/bitmaps/circle.xpm | 115 | ||||
-rw-r--r-- | app/bin/bitmaps/connect.xpm | 116 | ||||
-rw-r--r-- | app/bin/bitmaps/control.xpm | 129 | ||||
-rw-r--r-- | app/bin/bitmaps/convert-from.xpm | 99 | ||||
-rw-r--r-- | app/bin/bitmaps/convert-to.xpm | 99 | ||||
-rw-r--r-- | app/bin/bitmaps/copy.xpm | 95 | ||||
-rw-r--r-- | app/bin/bitmaps/cornu.xpm | 117 | ||||
-rw-r--r-- | app/bin/bitmaps/curved-chord.xpm | 109 | ||||
-rw-r--r-- | app/bin/bitmaps/curved-end.xpm | 107 | ||||
-rw-r--r-- | app/bin/bitmaps/curved-line-chord.xpm | 92 | ||||
-rw-r--r-- | app/bin/bitmaps/curved-line-end.xpm | 94 | ||||
-rw-r--r-- | app/bin/bitmaps/curved-line-middle.xpm | 95 | ||||
-rw-r--r-- | app/bin/bitmaps/curved-line-tangent.xpm | 98 | ||||
-rw-r--r-- | app/bin/bitmaps/curved-middle.xpm | 108 | ||||
-rw-r--r-- | app/bin/bitmaps/curved-tangent.xpm | 116 | ||||
-rw-r--r-- | app/bin/bitmaps/cut.xpm | 92 | ||||
-rw-r--r-- | app/bin/bitmaps/delete.xpm | 114 | ||||
-rw-r--r-- | app/bin/bitmaps/describe.xpm | 111 | ||||
-rw-r--r-- | app/bin/bitmaps/description.xpm | 101 | ||||
-rw-r--r-- | app/bin/bitmaps/dimension.xpm | 94 | ||||
-rw-r--r-- | app/bin/bitmaps/doc-export-bmap.xpm | 162 | ||||
-rw-r--r-- | app/bin/bitmaps/doc-export-dxf.xpm | 100 | ||||
-rw-r--r-- | app/bin/bitmaps/doc-export-svg.xpm | 114 | ||||
-rw-r--r-- | app/bin/bitmaps/doc-export-xtc.xpm | 108 | ||||
-rw-r--r-- | app/bin/bitmaps/doc-export.xpm | 119 | ||||
-rw-r--r-- | app/bin/bitmaps/doc-import-xtc.xpm | 123 | ||||
-rw-r--r-- | app/bin/bitmaps/doc-import.xpm | 123 | ||||
-rw-r--r-- | app/bin/bitmaps/doc-new.xpm | 127 | ||||
-rw-r--r-- | app/bin/bitmaps/doc-open.xpm | 136 | ||||
-rw-r--r-- | app/bin/bitmaps/doc-print.xpm | 108 | ||||
-rw-r--r-- | app/bin/bitmaps/doc-revert.xpm | 134 | ||||
-rw-r--r-- | app/bin/bitmaps/doc-save-as.xpm | 135 | ||||
-rw-r--r-- | app/bin/bitmaps/doc-save.xpm | 116 | ||||
-rw-r--r-- | app/bin/bitmaps/doc-setup.xpm | 110 | ||||
-rw-r--r-- | app/bin/bitmaps/down.xpm | 89 | ||||
-rw-r--r-- | app/bin/bitmaps/ease-broad.xpm | 89 | ||||
-rw-r--r-- | app/bin/bitmaps/ease-cornu.xpm | 96 | ||||
-rw-r--r-- | app/bin/bitmaps/ease-gt-broad.xpm | 89 | ||||
-rw-r--r-- | app/bin/bitmaps/ease-gt-sharp.xpm | 89 | ||||
-rw-r--r-- | app/bin/bitmaps/ease-lt-broad.xpm | 89 | ||||
-rw-r--r-- | app/bin/bitmaps/ease-lt-sharp.xpm | 89 | ||||
-rw-r--r-- | app/bin/bitmaps/ease-none.xpm | 89 | ||||
-rw-r--r-- | app/bin/bitmaps/ease-normal.xpm | 89 | ||||
-rw-r--r-- | app/bin/bitmaps/ease-sharp.xpm | 89 | ||||
-rw-r--r-- | app/bin/bitmaps/elevation.xpm | 117 | ||||
-rw-r--r-- | app/bin/bitmaps/exit.xpm | 94 | ||||
-rw-r--r-- | app/bin/bitmaps/extend.xpm | 143 | ||||
-rw-r--r-- | app/bin/bitmaps/filled-box.xpm | 120 | ||||
-rw-r--r-- | app/bin/bitmaps/filled-polygon.xpm | 121 | ||||
-rw-r--r-- | app/bin/bitmaps/go.xpm | 135 | ||||
-rw-r--r-- | app/bin/bitmaps/helix.xpm | 95 | ||||
-rw-r--r-- | app/bin/bitmaps/join-line.xpm | 99 | ||||
-rw-r--r-- | app/bin/bitmaps/join.xpm | 117 | ||||
-rw-r--r-- | app/bin/bitmaps/l1.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l10.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l11.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l12.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l13.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l14.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l15.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l16.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l17.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l18.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l19.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l2.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l20.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l21.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l22.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l23.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l24.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l25.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l26.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l27.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l28.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l29.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l3.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l30.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l31.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l32.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l33.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l34.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l35.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l36.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l37.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l38.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l39.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l4.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l40.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l41.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l42.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l43.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l44.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l45.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l46.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l47.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l48.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l49.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l5.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l50.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l51.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l52.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l53.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l54.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l55.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l56.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l57.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l58.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l59.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l6.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l60.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l61.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l62.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l63.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l64.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l65.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l66.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l67.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l68.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l69.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l7.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l70.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l71.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l72.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l73.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l74.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l75.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l76.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l77.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l78.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l79.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l8.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l80.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l81.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l82.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l83.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l84.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l85.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l86.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l87.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l88.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l89.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l9.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l90.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l91.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l92.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l93.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l94.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l95.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l96.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l97.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l98.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/l99.xbm | 78 | ||||
-rw-r--r-- | app/bin/bitmaps/layer_num.inc | 515 | ||||
-rw-r--r-- | app/bin/bitmaps/layers.xpm | 110 | ||||
-rw-r--r-- | app/bin/bitmaps/loosen.xpm | 183 | ||||
-rw-r--r-- | app/bin/bitmaps/magnet.xpm | 139 | ||||
-rw-r--r-- | app/bin/bitmaps/manage.xpm | 110 | ||||
-rw-r--r-- | app/bin/bitmaps/map.xpm | 169 | ||||
-rw-r--r-- | app/bin/bitmaps/move.xpm | 119 | ||||
-rw-r--r-- | app/bin/bitmaps/new-car.xpm | 100 | ||||
-rw-r--r-- | app/bin/bitmaps/ok.xpm | 92 | ||||
-rw-r--r-- | app/bin/bitmaps/pan-zoom.xpm | 94 | ||||
-rw-r--r-- | app/bin/bitmaps/parallel-line.xpm | 108 | ||||
-rw-r--r-- | app/bin/bitmaps/parallel.xpm | 116 | ||||
-rw-r--r-- | app/bin/bitmaps/parameter.xpm | 104 | ||||
-rw-r--r-- | app/bin/bitmaps/paste.xpm | 107 | ||||
-rw-r--r-- | app/bin/bitmaps/png/circle-center16.png (renamed from app/bin/bitmaps/16pix/circle-center.png) | bin | 249 -> 249 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/circle-tangent16.png (renamed from app/bin/bitmaps/16pix/circle-tangent.png) | bin | 244 -> 244 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/circle16.png (renamed from app/bin/bitmaps/16pix/circle.png) | bin | 242 -> 242 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/curved-chord16.png (renamed from app/bin/bitmaps/16pix/curved-chord.png) | bin | 244 -> 244 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/curved-end16.png (renamed from app/bin/bitmaps/16pix/curved-end.png) | bin | 239 -> 239 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/curved-middle16.png (renamed from app/bin/bitmaps/16pix/curved-middle.png) | bin | 239 -> 239 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/curved-tangent16.png (renamed from app/bin/bitmaps/16pix/curved-tangent.png) | bin | 241 -> 241 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/description16.png (renamed from app/bin/bitmaps/16pix/description.png) | bin | 228 -> 228 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/description24.png (renamed from app/bin/bitmaps/24pix/description.png) | bin | 253 -> 253 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/down16.png | bin | 0 -> 170 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/down24.png | bin | 0 -> 180 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/ease-broad16.png | bin | 0 -> 263 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/ease-broad24.png | bin | 0 -> 332 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/ease-broad32.png | bin | 0 -> 389 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/ease-cornu16.png | bin | 0 -> 322 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/ease-cornu24.png | bin | 0 -> 378 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/ease-cornu32.png | bin | 0 -> 481 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/ease-gt-broad16.png | bin | 0 -> 275 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/ease-gt-broad24.png | bin | 0 -> 342 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/ease-gt-broad32.png | bin | 0 -> 422 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/ease-gt-sharp16.png | bin | 0 -> 276 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/ease-gt-sharp24.png | bin | 0 -> 346 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/ease-gt-sharp32.png | bin | 0 -> 407 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/ease-lt-broad16.png | bin | 0 -> 275 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/ease-lt-broad24.png | bin | 0 -> 344 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/ease-lt-broad32.png | bin | 0 -> 420 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/ease-lt-sharp16.png | bin | 0 -> 274 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/ease-lt-sharp24.png | bin | 0 -> 346 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/ease-lt-sharp32.png | bin | 0 -> 407 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/ease-none16.png | bin | 0 -> 260 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/ease-none24.png | bin | 0 -> 318 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/ease-none32.png | bin | 0 -> 371 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/ease-normal16.png | bin | 0 -> 268 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/ease-normal24.png | bin | 0 -> 326 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/ease-normal32.png | bin | 0 -> 384 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/ease-sharp16.png | bin | 0 -> 267 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/ease-sharp24.png | bin | 0 -> 336 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/ease-sharp32.png | bin | 0 -> 393 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/elevation16.png (renamed from app/bin/bitmaps/16pix/elevation.png) | bin | 216 -> 216 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/exit16.png (renamed from app/bin/bitmaps/16pix/exit.png) | bin | 203 -> 203 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/exit24.png (renamed from app/bin/bitmaps/24pix/exit.png) | bin | 236 -> 236 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/extend16.png | bin | 0 -> 165 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/palette.png (renamed from app/bin/bitmaps/16pix/palette.png) | bin | 179 -> 179 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/pan-zoom16.png (renamed from app/bin/bitmaps/16pix/pan-zoom.png) | bin | 229 -> 229 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/pan-zoom24.png (renamed from app/bin/bitmaps/24pix/pan-zoom.png) | bin | 273 -> 273 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/ruler16.png | bin | 0 -> 134 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/select16.png (renamed from app/bin/bitmaps/16pix/select.png) | bin | 220 -> 220 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/snap-curs16.png (renamed from app/bin/bitmaps/16pix/snap-curs.png) | bin | 222 -> 222 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/snap-curs24.png (renamed from app/bin/bitmaps/24pix/snap-curs.png) | bin | 265 -> 265 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/snap-grid16.png (renamed from app/bin/bitmaps/16pix/snap-grid.png) | bin | 191 -> 191 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/snap-grid24.png (renamed from app/bin/bitmaps/24pix/snap-grid.png) | bin | 183 -> 183 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/straight16.png | bin | 0 -> 155 bytes | |||
-rw-r--r-- | app/bin/bitmaps/png/turntable16.png | bin | 0 -> 132 bytes | |||
-rw-r--r-- | app/bin/bitmaps/polygon.xpm | 89 | ||||
-rw-r--r-- | app/bin/bitmaps/polyline.xpm | 92 | ||||
-rw-r--r-- | app/bin/bitmaps/profile.xpm | 121 | ||||
-rw-r--r-- | app/bin/bitmaps/protractor.xpm | 99 | ||||
-rw-r--r-- | app/bin/bitmaps/redo.xpm | 104 | ||||
-rw-r--r-- | app/bin/bitmaps/reflect.xpm | 115 | ||||
-rw-r--r-- | app/bin/bitmaps/rotate.xpm | 148 | ||||
-rw-r--r-- | app/bin/bitmaps/ruler.xpm | 89 | ||||
-rw-r--r-- | app/bin/bitmaps/select.xpm | 106 | ||||
-rw-r--r-- | app/bin/bitmaps/sensor.xpm | 138 | ||||
-rw-r--r-- | app/bin/bitmaps/signal.xpm | 106 | ||||
-rw-r--r-- | app/bin/bitmaps/snap-curs.xpm | 102 | ||||
-rw-r--r-- | app/bin/bitmaps/snap-grid.xpm | 92 | ||||
-rw-r--r-- | app/bin/bitmaps/split-draw.xpm | 95 | ||||
-rw-r--r-- | app/bin/bitmaps/split.xpm | 107 | ||||
-rw-r--r-- | app/bin/bitmaps/sticky-doc.xpm | 130 | ||||
-rw-r--r-- | app/bin/bitmaps/sticky-link.xpm | 138 | ||||
-rw-r--r-- | app/bin/bitmaps/sticky-note.xpm | 124 | ||||
-rw-r--r-- | app/bin/bitmaps/stop.xpm | 128 | ||||
-rw-r--r-- | app/bin/bitmaps/straight-line.xpm | 96 | ||||
-rw-r--r-- | app/bin/bitmaps/straight.xpm | 133 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/background.svg (renamed from app/bin/bitmaps/SVG/background.svg) | 2 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/benchwork.svg (renamed from app/bin/bitmaps/SVG/benchwork.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/bezier-line.svg (renamed from app/bin/bitmaps/SVG/bezier-line.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/bezier-track.svg (renamed from app/bin/bitmaps/SVG/bezier-track.svg) | 0 | ||||
-rwxr-xr-x | app/bin/bitmaps/svg/block.svg (renamed from app/bin/bitmaps/SVG/block.svg) | 0 | ||||
-rwxr-xr-x | app/bin/bitmaps/svg/blockdel.svg (renamed from app/bin/bitmaps/SVG/blockdel.svg) | 0 | ||||
-rwxr-xr-x | app/bin/bitmaps/svg/blockedit.svg (renamed from app/bin/bitmaps/SVG/blockedit.svg) | 0 | ||||
-rwxr-xr-x | app/bin/bitmaps/svg/blocknew.svg (renamed from app/bin/bitmaps/SVG/blocknew.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/bottom.svg (renamed from app/bin/bitmaps/SVG/bottom.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/box.svg (renamed from app/bin/bitmaps/SVG/box.svg) | 36 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/bridge.svg (renamed from app/bin/bitmaps/SVG/bridge.svg) | 38 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/building.svg (renamed from app/bin/bitmaps/SVG/building.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/car-inventory.svg (renamed from app/bin/bitmaps/SVG/car-inventory.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/change-grid.svg (renamed from app/bin/bitmaps/SVG/change-grid.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/circle-center.svg (renamed from app/bin/bitmaps/SVG/circle-center.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/circle-filled-center.svg (renamed from app/bin/bitmaps/SVG/circle-filled-center.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/circle-filled-tangent.svg (renamed from app/bin/bitmaps/SVG/circle-filled-tangent.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/circle-line-center.svg (renamed from app/bin/bitmaps/SVG/circle-line-center.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/circle-line-tangent.svg (renamed from app/bin/bitmaps/SVG/circle-line-tangent.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/circle-line.svg (renamed from app/bin/bitmaps/SVG/circle-line.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/circle-tangent.svg (renamed from app/bin/bitmaps/SVG/circle-tangent.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/circle.svg (renamed from app/bin/bitmaps/SVG/circle.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/clone.svg (renamed from app/bin/bitmaps/SVG/doc-export-xtc.svg) | 43 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/connect.svg (renamed from app/bin/bitmaps/SVG/connect.svg) | 37 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/control.svg (renamed from app/bin/bitmaps/SVG/control.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/convert-from.svg (renamed from app/bin/bitmaps/SVG/convert-from.svg) | 32 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/convert-to.svg (renamed from app/bin/bitmaps/SVG/convert-to.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/copy.svg (renamed from app/bin/bitmaps/SVG/copy.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/cornu.svg (renamed from app/bin/bitmaps/SVG/cornu.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/curved-chord.svg (renamed from app/bin/bitmaps/SVG/curved-chord.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/curved-end.svg (renamed from app/bin/bitmaps/SVG/curved-end.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/curved-line-chord.svg (renamed from app/bin/bitmaps/SVG/curved-line-chord.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/curved-line-end.svg (renamed from app/bin/bitmaps/SVG/curved-line-end.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/curved-line-middle.svg (renamed from app/bin/bitmaps/SVG/curved-line-middle.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/curved-line-tangent.svg (renamed from app/bin/bitmaps/SVG/curved-line-tangent.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/curved-middle.svg (renamed from app/bin/bitmaps/SVG/curved-middle.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/curved-tangent.svg (renamed from app/bin/bitmaps/SVG/curved-tangent.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/cut.svg (renamed from app/bin/bitmaps/SVG/cut.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/delete.svg (renamed from app/bin/bitmaps/SVG/delete.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/describe.svg (renamed from app/bin/bitmaps/SVG/describe.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/description.svg (renamed from app/bin/bitmaps/SVG/description.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/dimension.svg (renamed from app/bin/bitmaps/SVG/dimension.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/doc-export-bmap.svg (renamed from app/bin/bitmaps/SVG/doc-export-bmap.svg) | 24 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/doc-export-dxf.svg (renamed from app/bin/bitmaps/SVG/doc-export-dxf.svg) | 17 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/doc-export-svg.svg (renamed from app/bin/bitmaps/SVG/doc-export-svg.svg) | 18 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/doc-export.svg (renamed from app/bin/bitmaps/SVG/doc-export.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/doc-import-mod.svg (renamed from app/bin/bitmaps/SVG/doc-import.svg) | 10 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/doc-import.svg (renamed from app/bin/bitmaps/SVG/doc-import-xtc.svg) | 6 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/doc-new.svg (renamed from app/bin/bitmaps/SVG/doc-new.svg) | 10 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/doc-open.svg (renamed from app/bin/bitmaps/SVG/doc-open.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/doc-print.svg (renamed from app/bin/bitmaps/SVG/doc-print.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/doc-recent.svg | 63 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/doc-revert.svg (renamed from app/bin/bitmaps/SVG/doc-revert.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/doc-save-as.svg (renamed from app/bin/bitmaps/SVG/doc-save-as.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/doc-save.svg (renamed from app/bin/bitmaps/SVG/doc-save.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/doc-setup.svg (renamed from app/bin/bitmaps/SVG/doc-setup.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/down.svg (renamed from app/bin/bitmaps/SVG/down.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/elevation.svg (renamed from app/bin/bitmaps/SVG/elevation.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/exit.svg (renamed from app/bin/bitmaps/SVG/exit.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/extend.svg (renamed from app/bin/bitmaps/SVG/extend.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/filled-box.svg (renamed from app/bin/bitmaps/SVG/filled-box.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/filled-polygon.svg (renamed from app/bin/bitmaps/SVG/filled-polygon.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/go.svg (renamed from app/bin/bitmaps/SVG/go.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/grid.svg (renamed from app/bin/bitmaps/SVG/grid.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/helix.svg (renamed from app/bin/bitmaps/SVG/helix.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/info.svg (renamed from app/bin/bitmaps/SVG/Info.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/join-line.svg (renamed from app/bin/bitmaps/SVG/join-line.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/join.svg (renamed from app/bin/bitmaps/SVG/join.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/layers.svg (renamed from app/bin/bitmaps/SVG/layers.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/loosen.svg | 146 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/magnet.svg (renamed from app/bin/bitmaps/SVG/magnet.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/manage.svg (renamed from app/bin/bitmaps/SVG/manage.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/map.svg (renamed from app/bin/bitmaps/SVG/map.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/move.svg (renamed from app/bin/bitmaps/SVG/move.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/new-car.svg (renamed from app/bin/bitmaps/SVG/new-car.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/ok.svg (renamed from app/bin/bitmaps/SVG/ok.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/pan-zoom.svg (renamed from app/bin/bitmaps/SVG/pan-zoom.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/parallel-line.svg (renamed from app/bin/bitmaps/SVG/parallel-line.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/parallel.svg (renamed from app/bin/bitmaps/SVG/parallel.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/parameter.svg (renamed from app/bin/bitmaps/SVG/parameter.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/paste.svg (renamed from app/bin/bitmaps/SVG/paste.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/polygon.svg (renamed from app/bin/bitmaps/SVG/polygon.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/polyline.svg (renamed from app/bin/bitmaps/SVG/polyline.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/profile.svg (renamed from app/bin/bitmaps/SVG/profile.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/protractor.svg (renamed from app/bin/bitmaps/SVG/protractor.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/redo.svg (renamed from app/bin/bitmaps/SVG/redo.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/reflect.svg (renamed from app/bin/bitmaps/SVG/reflect.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/roadbed.svg | 121 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/rotate.svg (renamed from app/bin/bitmaps/SVG/rotate.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/ruler.svg (renamed from app/bin/bitmaps/SVG/ruler.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/select.svg (renamed from app/bin/bitmaps/SVG/select.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/sensor.svg (renamed from app/bin/bitmaps/SVG/sensor.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/signal.svg (renamed from app/bin/bitmaps/SVG/signal.svg) | 36 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/snap-curs.svg (renamed from app/bin/bitmaps/SVG/snap-curs.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/snap-grid.svg (renamed from app/bin/bitmaps/SVG/snap-grid.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/split-draw.svg (renamed from app/bin/bitmaps/SVG/split-draw.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/split.svg (renamed from app/bin/bitmaps/SVG/split.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/star.svg (renamed from app/bin/bitmaps/SVG/star.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/sticky-doc.svg (renamed from app/bin/bitmaps/SVG/sticky-doc.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/sticky-link.svg (renamed from app/bin/bitmaps/SVG/sticky-link.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/sticky-note.svg (renamed from app/bin/bitmaps/SVG/sticky-note.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/stop.svg (renamed from app/bin/bitmaps/SVG/stop.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/straight-line.svg (renamed from app/bin/bitmaps/SVG/straight-line.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/straight.svg (renamed from app/bin/bitmaps/SVG/straight.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/switch-motor.svg (renamed from app/bin/bitmaps/SVG/switch-ai.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/switchm.svg (renamed from app/bin/bitmaps/SVG/switchm.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/switchmdel.svg (renamed from app/bin/bitmaps/SVG/switchmdel.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/switchmedit.svg (renamed from app/bin/bitmaps/SVG/switchmedit.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/switchmnew.svg (renamed from app/bin/bitmaps/SVG/switchmnew.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/table-edge.svg (renamed from app/bin/bitmaps/SVG/table-edge.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/text.svg (renamed from app/bin/bitmaps/SVG/text.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/ties.svg | 97 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/tipofday.svg (renamed from app/bin/bitmaps/SVG/tipofday.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/top.svg (renamed from app/bin/bitmaps/SVG/top.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/train.svg (renamed from app/bin/bitmaps/SVG/train.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/trim.svg (renamed from app/bin/bitmaps/SVG/trim.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/tunnel.svg (renamed from app/bin/bitmaps/SVG/tunnel.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/turnout-design.svg (renamed from app/bin/bitmaps/SVG/turnout-designer.svg) | 24 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/turnout.svg (renamed from app/bin/bitmaps/SVG/turnout.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/turntable.svg (renamed from app/bin/bitmaps/SVG/turntable.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/undo.svg (renamed from app/bin/bitmaps/SVG/undo.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/zoom-choose.svg (renamed from app/bin/bitmaps/SVG/zoom-choose.svg) | 77 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/zoom-extent.svg (renamed from app/bin/bitmaps/SVG/zoom-extent.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/zoom-in.svg (renamed from app/bin/bitmaps/SVG/zoom-in.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/svg/zoom-out.svg (renamed from app/bin/bitmaps/SVG/zoom-out.svg) | 0 | ||||
-rw-r--r-- | app/bin/bitmaps/switch-ai.xpm | 96 | ||||
-rw-r--r-- | app/bin/bitmaps/switchm.xpm | 30 | ||||
-rw-r--r-- | app/bin/bitmaps/table-edge.xpm | 114 | ||||
-rw-r--r-- | app/bin/bitmaps/text.xpm | 89 | ||||
-rw-r--r-- | app/bin/bitmaps/top.xpm | 111 | ||||
-rw-r--r-- | app/bin/bitmaps/train.xpm | 118 | ||||
-rw-r--r-- | app/bin/bitmaps/trim.xpm | 99 | ||||
-rw-r--r-- | app/bin/bitmaps/tunnel.xpm | 118 | ||||
-rw-r--r-- | app/bin/bitmaps/turnout-designer.xpm | 129 | ||||
-rw-r--r-- | app/bin/bitmaps/turnout.xpm | 107 | ||||
-rw-r--r-- | app/bin/bitmaps/turntable.xpm | 133 | ||||
-rw-r--r-- | app/bin/bitmaps/undo.xpm | 103 | ||||
-rw-r--r-- | app/bin/bitmaps/zoom-choose.xpm | 127 | ||||
-rw-r--r-- | app/bin/bitmaps/zoom-extent.xpm | 125 | ||||
-rw-r--r-- | app/bin/bitmaps/zoom-in.xpm | 128 | ||||
-rw-r--r-- | app/bin/bitmaps/zoom-out.xpm | 127 | ||||
-rwxr-xr-x | app/bin/cJSON.c | 2932 | ||||
-rwxr-xr-x | app/bin/cJSON.h | 285 | ||||
-rw-r--r-- | app/bin/cbezier.c | 1066 | ||||
-rw-r--r-- | app/bin/cbezier.h | 12 | ||||
-rw-r--r-- | app/bin/cblock.c | 641 | ||||
-rw-r--r-- | app/bin/ccontrol.c | 785 | ||||
-rw-r--r-- | app/bin/ccornu.c | 2151 | ||||
-rw-r--r-- | app/bin/ccornu.h | 9 | ||||
-rw-r--r-- | app/bin/ccurve.c | 655 | ||||
-rw-r--r-- | app/bin/ccurve.h | 29 | ||||
-rw-r--r-- | app/bin/cdraw.c | 2932 | ||||
-rw-r--r-- | app/bin/celev.c | 181 | ||||
-rw-r--r-- | app/bin/cgroup.c | 984 | ||||
-rw-r--r-- | app/bin/chndldto.c | 155 | ||||
-rw-r--r-- | app/bin/chotbar.c | 365 | ||||
-rw-r--r-- | app/bin/cjoin.c | 1020 | ||||
-rw-r--r-- | app/bin/cjoin.h | 29 | ||||
-rw-r--r-- | app/bin/cmisc.c | 890 | ||||
-rw-r--r-- | app/bin/cmodify.c | 585 | ||||
-rw-r--r-- | app/bin/cnote.c | 113 | ||||
-rw-r--r-- | app/bin/cnvdsgn.c | 54 | ||||
-rw-r--r-- | app/bin/command.c | 800 | ||||
-rw-r--r-- | app/bin/command.h | 150 | ||||
-rw-r--r-- | app/bin/common-ui.h | 4 | ||||
-rw-r--r-- | app/bin/common.h | 125 | ||||
-rw-r--r-- | app/bin/compound.c | 828 | ||||
-rw-r--r-- | app/bin/compound.h | 167 | ||||
-rw-r--r-- | app/bin/cparalle.c | 363 | ||||
-rw-r--r-- | app/bin/cprint.c | 975 | ||||
-rw-r--r-- | app/bin/cprofile.c | 2161 | ||||
-rw-r--r-- | app/bin/cpull.c | 331 | ||||
-rw-r--r-- | app/bin/cruler.c | 142 | ||||
-rw-r--r-- | app/bin/cselect.c | 2828 | ||||
-rw-r--r-- | app/bin/cselect.h | 11 | ||||
-rw-r--r-- | app/bin/csensor.c | 720 | ||||
-rw-r--r-- | app/bin/csignal.c | 1242 | ||||
-rw-r--r-- | app/bin/csnap.c | 351 | ||||
-rw-r--r-- | app/bin/csplit.c | 185 | ||||
-rw-r--r-- | app/bin/cstraigh.c | 112 | ||||
-rw-r--r-- | app/bin/cstraigh.h | 12 | ||||
-rw-r--r-- | app/bin/cstruct.c | 609 | ||||
-rw-r--r-- | app/bin/cswitchmotor.c | 612 | ||||
-rw-r--r-- | app/bin/ctext.c | 105 | ||||
-rw-r--r-- | app/bin/ctie.c | 53 | ||||
-rw-r--r-- | app/bin/ctodesgn.c | 2898 | ||||
-rw-r--r-- | app/bin/ctrain.c | 4851 | ||||
-rw-r--r-- | app/bin/ctrain.h | 32 | ||||
-rw-r--r-- | app/bin/cturnout.c | 3581 | ||||
-rw-r--r-- | app/bin/cturntbl.c | 548 | ||||
-rw-r--r-- | app/bin/cundo.c | 499 | ||||
-rw-r--r-- | app/bin/cundo.h | 7 | ||||
-rw-r--r-- | app/bin/custom.c | 102 | ||||
-rw-r--r-- | app/bin/custom.h | 32 | ||||
-rw-r--r-- | app/bin/dbench.c | 202 | ||||
-rw-r--r-- | app/bin/dbitmap.c | 11 | ||||
-rw-r--r-- | app/bin/dcar.c | 3088 | ||||
-rw-r--r-- | app/bin/dcmpnd.c | 294 | ||||
-rw-r--r-- | app/bin/dcontmgm.c | 208 | ||||
-rw-r--r-- | app/bin/dcustmgm.c | 197 | ||||
-rw-r--r-- | app/bin/dease.c | 97 | ||||
-rw-r--r-- | app/bin/denum.c | 83 | ||||
-rw-r--r-- | app/bin/directory.c | 172 | ||||
-rw-r--r-- | app/bin/directory.h | 8 | ||||
-rw-r--r-- | app/bin/dlayer.c | 4161 | ||||
-rw-r--r-- | app/bin/dlayer.h | 69 | ||||
-rw-r--r-- | app/bin/doption.c | 216 | ||||
-rw-r--r-- | app/bin/dpricels.c | 63 | ||||
-rw-r--r-- | app/bin/dprmfile.c | 348 | ||||
-rw-r--r-- | app/bin/draw.c | 2498 | ||||
-rw-r--r-- | app/bin/draw.h | 87 | ||||
-rw-r--r-- | app/bin/drawgeom.c | 2589 | ||||
-rw-r--r-- | app/bin/drawgeom.h | 128 | ||||
-rw-r--r-- | app/bin/dxfformat.c | 246 | ||||
-rw-r--r-- | app/bin/dxfformat.h | 20 | ||||
-rw-r--r-- | app/bin/dxfoutput.c | 264 | ||||
-rw-r--r-- | app/bin/elev.c | 513 | ||||
-rw-r--r-- | app/bin/file2uri.c | 51 | ||||
-rw-r--r-- | app/bin/file2uri.h | 47 | ||||
-rw-r--r-- | app/bin/fileio.c | 711 | ||||
-rw-r--r-- | app/bin/fileio.h | 23 | ||||
-rw-r--r-- | app/bin/filenoteui.c | 237 | ||||
-rw-r--r-- | app/bin/helphelper.c | 123 | ||||
-rw-r--r-- | app/bin/i18n.c | 16 | ||||
-rw-r--r-- | app/bin/i18n.h | 26 | ||||
-rw-r--r-- | app/bin/include/dirent.h | 1655 | ||||
-rw-r--r-- | app/bin/include/levenshtein.h | 3 | ||||
-rw-r--r-- | app/bin/include/paramfile.h | 52 | ||||
-rw-r--r-- | app/bin/include/paramfilelist.h | 62 | ||||
-rw-r--r-- | app/bin/include/partcatalog.h | 67 | ||||
-rw-r--r-- | app/bin/include/problemrep.h | 37 | ||||
-rw-r--r-- | app/bin/include/stringxtc.h | 9 | ||||
-rw-r--r-- | app/bin/include/svgformat.h | 4 | ||||
-rw-r--r-- | app/bin/include/utf8convert.h | 2 | ||||
-rw-r--r-- | app/bin/layout.c | 847 | ||||
-rw-r--r-- | app/bin/layout.h | 14 | ||||
-rw-r--r-- | app/bin/levenshtein.c | 95 | ||||
-rw-r--r-- | app/bin/linknoteui.c | 209 | ||||
-rw-r--r-- | app/bin/lprintf.c | 31 | ||||
-rw-r--r-- | app/bin/macro.c | 772 | ||||
-rw-r--r-- | app/bin/manifest.c | 84 | ||||
-rw-r--r-- | app/bin/manifest.h | 8 | ||||
-rw-r--r-- | app/bin/menu.c | 1486 | ||||
-rw-r--r-- | app/bin/menu.h | 69 | ||||
-rw-r--r-- | app/bin/misc.c | 2814 | ||||
-rw-r--r-- | app/bin/misc.h | 444 | ||||
-rw-r--r-- | app/bin/misc2.c | 898 | ||||
-rw-r--r-- | app/bin/misc2.h | 124 | ||||
-rw-r--r-- | app/bin/note.h | 72 | ||||
-rw-r--r-- | app/bin/param.c | 2201 | ||||
-rw-r--r-- | app/bin/param.h | 203 | ||||
-rw-r--r-- | app/bin/paramfile.c | 102 | ||||
-rw-r--r-- | app/bin/paramfilelist.c | 549 | ||||
-rw-r--r-- | app/bin/paramfilesearch_ui.c | 369 | ||||
-rw-r--r-- | app/bin/partcatalog.c | 1209 | ||||
-rw-r--r-- | app/bin/paths.c | 165 | ||||
-rw-r--r-- | app/bin/paths.h | 2 | ||||
-rw-r--r-- | app/bin/problemrep.c | 635 | ||||
-rw-r--r-- | app/bin/problemrepui.c | 109 | ||||
-rw-r--r-- | app/bin/scale.c | 1154 | ||||
-rw-r--r-- | app/bin/scale.h | 63 | ||||
-rw-r--r-- | app/bin/shortentext.c | 52 | ||||
-rw-r--r-- | app/bin/shortentext.h | 38 | ||||
-rw-r--r-- | app/bin/shrtpath.c | 187 | ||||
-rw-r--r-- | app/bin/shrtpath.h | 21 | ||||
-rw-r--r-- | app/bin/smalldlg.c | 134 | ||||
-rw-r--r-- | app/bin/smalldlg.h | 6 | ||||
-rw-r--r-- | app/bin/stringxtc.c | 241 | ||||
-rw-r--r-- | app/bin/svgformat.c | 559 | ||||
-rw-r--r-- | app/bin/svgoutput.c | 462 | ||||
-rw-r--r-- | app/bin/tbezier.c | 1726 | ||||
-rw-r--r-- | app/bin/tbezier.h | 52 | ||||
-rw-r--r-- | app/bin/tcornu.c | 1123 | ||||
-rw-r--r-- | app/bin/tcornu.h | 66 | ||||
-rw-r--r-- | app/bin/tcurve.c | 1061 | ||||
-rw-r--r-- | app/bin/tease.c | 1147 | ||||
-rw-r--r-- | app/bin/textnoteui.c | 210 | ||||
-rw-r--r-- | app/bin/track.c | 2289 | ||||
-rw-r--r-- | app/bin/track.h | 600 | ||||
-rw-r--r-- | app/bin/trackx.h | 39 | ||||
-rw-r--r-- | app/bin/trkendpt.c | 648 | ||||
-rw-r--r-- | app/bin/trkendpt.h | 54 | ||||
-rw-r--r-- | app/bin/trkendptx.h (renamed from app/bin/cmisc2.c) | 63 | ||||
-rw-r--r-- | app/bin/trknote.c | 478 | ||||
-rw-r--r-- | app/bin/trkseg.c | 1699 | ||||
-rw-r--r-- | app/bin/trkseg.h | 252 | ||||
-rw-r--r-- | app/bin/tstraigh.c | 669 | ||||
-rw-r--r-- | app/bin/turnout.c | 2157 | ||||
-rw-r--r-- | app/bin/unittest/CMakeLists.txt | 78 | ||||
-rw-r--r-- | app/bin/unittest/catalogtest.c | 63 | ||||
-rw-r--r-- | app/bin/unittest/defaultstest.c | 18 | ||||
-rw-r--r-- | app/bin/unittest/dxfformattest.c | 40 | ||||
-rw-r--r-- | app/bin/unittest/pathstest.c | 56 | ||||
-rw-r--r-- | app/bin/unittest/shortentest.c | 8 | ||||
-rw-r--r-- | app/bin/utf8convert.c | 40 | ||||
-rw-r--r-- | app/bin/uthash.h | 102 | ||||
-rw-r--r-- | app/bin/utility.c | 328 | ||||
-rw-r--r-- | app/bin/utility.h | 11 | ||||
-rw-r--r-- | app/bin/validator.c | 8 | ||||
-rw-r--r-- | app/bin/validator.h | 22 | ||||
-rw-r--r-- | app/bin/version.h | 20 | ||||
-rw-r--r-- | app/bin/xtrkcad.ico | bin | 22486 -> 22486 bytes | |||
-rw-r--r-- | app/bin/xtrkcad.rc | 14 |
579 files changed, 50875 insertions, 66149 deletions
diff --git a/app/bin/CMakeLists.txt b/app/bin/CMakeLists.txt index 8d28205..48a0b72 100644 --- a/app/bin/CMakeLists.txt +++ b/app/bin/CMakeLists.txt @@ -1,18 +1,64 @@ +project(xtrkcad-lib) + include( CheckSymbolExists ) +# +# Create line symbols for turnouts from src definitions +# +# 1. Build converter cnvdsgn +# 2. define target "lines" for all symols +# 3. create .lin-files using converter +# 4. add individual .lin-files as dependency to "lines" +# + +# build GA or Beta executable +set( XTRKCAD_BIN "xtrkcad${XTRKCAD_BETA}" ) + +add_subdirectory(bitmaps) + +add_executable(cnvdsgn cnvdsgn.c utility.c) + +target_link_libraries(cnvdsgn xtrkcad-wlib) + +if(NOT WIN32) + target_link_libraries(cnvdsgn m) +endif() + +add_custom_target(lines + DEPENDS cnvdsgn +) + +# +# macro to copy DLLs into build directory +# eases debugging on Windows +# +if(WIN32) + macro(COPYDLLTOBUILD dllname) + add_custom_command( + TARGET xtrkcad POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${dllname} + ${CMAKE_CURRENT_BINARY_DIR} + ) + endmacro(COPYDLLTOBUILD) +endif() -ADD_EXECUTABLE(cnvdsgn cnvdsgn.c utility.c) -IF(NOT WIN32) - TARGET_LINK_LIBRARIES(cnvdsgn m) -ENDIF(NOT WIN32) +# +# macro creates lin files and adds the result as dependency +# -MACRO(GENERATE_LIN lin_name) - ADD_CUSTOM_COMMAND( +macro(GENERATE_LIN lin_name) + add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${lin_name}.lin - DEPENDS cnvdsgn ${CMAKE_CURRENT_SOURCE_DIR}/${lin_name}.src + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${lin_name}.src COMMAND cnvdsgn < ${CMAKE_CURRENT_SOURCE_DIR}/${lin_name}.src > ${CMAKE_CURRENT_BINARY_DIR}/${lin_name}.lin - ) -ENDMACRO(GENERATE_LIN) + ) + + target_sources(lines + PRIVATE + ${CMAKE_CURRENT_BINARY_DIR}/${lin_name}.lin + ) +endmacro(GENERATE_LIN) GENERATE_LIN(to3way) GENERATE_LIN(tocrv) @@ -30,314 +76,341 @@ GENERATE_LIN(tocornu) GENERATE_LIN(tocornuwye) GENERATE_LIN(tocornu3way) -SET(LIN_SOURCES - ${CMAKE_CURRENT_BINARY_DIR}/to3way.lin - ${CMAKE_CURRENT_BINARY_DIR}/tocrv.lin - ${CMAKE_CURRENT_BINARY_DIR}/tocrvsct.lin - ${CMAKE_CURRENT_BINARY_DIR}/todcross.lin - ${CMAKE_CURRENT_BINARY_DIR}/todslip.lin - ${CMAKE_CURRENT_BINARY_DIR}/tolcross.lin - ${CMAKE_CURRENT_BINARY_DIR}/torcross.lin - ${CMAKE_CURRENT_BINARY_DIR}/toreg.lin - ${CMAKE_CURRENT_BINARY_DIR}/tosslip.lin - ${CMAKE_CURRENT_BINARY_DIR}/tostrsct.lin - ${CMAKE_CURRENT_BINARY_DIR}/towye.lin - ${CMAKE_CURRENT_BINARY_DIR}/toxing.lin - ${CMAKE_CURRENT_BINARY_DIR}/tocornu.lin - ${CMAKE_CURRENT_BINARY_DIR}/tocornuwye.lin - ${CMAKE_CURRENT_BINARY_DIR}/tocornu3way.lin - ) - -ADD_CUSTOM_COMMAND( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/bllnhlp.c - DEPENDS genhelp ${help_SOURCE_DIR}/genhelp.json - COMMAND genhelp ${GENHELP_OPTS} ${help_SOURCE_DIR}/genhelp.json ${CMAKE_CURRENT_BINARY_DIR}/bllnhlp.c - ) - -ADD_EXECUTABLE(xtrkcad WIN32 - misc.c - xtrkcad.rc +# put these targets into the folder LineSymbols +set_target_properties(lines cnvdsgn PROPERTIES FOLDER LineSymbols) + +add_library(xtrkcad-lib "") + +target_sources(xtrkcad-lib + PRIVATE + appdefaults.c + archive.c + archive.h + cbezier.c + cbezier.h + cblock.c + ccornu.c + ccornu.h + ccurve.c + ccurve.h + ccontrol.c + cdraw.c + celev.c + cgroup.c + chndldto.c + chotbar.c + cjoin.c + cjoin.h + cmisc.c + cmodify.c + cnote.c + command.c + command.h + common.h + common-ui.h + compound.c + compound.h + cparalle.c + cprint.c + cprofile.c + cpull.c + cruler.c + cselect.c + cselect.h + csensor.c + csnap.c + csplit.c + csignal.c + cstraigh.c + cstraigh.h + cstruct.c + cswitchmotor.c + ctext.c + ctodesgn.c + ctrain.c + ctrain.h + cturnout.c + cturntbl.c + cundo.c + cundo.h + custom.c + custom.h + dbench.c + dbitmap.c + dcar.c + dcmpnd.c + dcustmgm.c + dcontmgm.c + dease.c + denum.c + directory.c + directory.h + dlayer.c + dlayer.h + doption.c + dpricels.c + dprmfile.c + draw.c + draw.h + drawgeom.c + drawgeom.h + dxfformat.c + dxfformat.h + dxfoutput.c + elev.c + file2uri.c + file2uri.h + fileio.c + fileio.h + filenoteui.c + i18n.c + layout.c + layout.h + levenshtein.c + linknoteui.c + lprintf.c + macro.c + manifest.c + manifest.h + menu.h + menu.c + misc.c + misc.h + note.h + param.c + param.h + paramfile.c + paramfilelist.c + paramfilesearch_ui.c + partcatalog.c + paths.c + paths.h + problemrep.c + problemrepui.c + scale.c + scale.h + shortentext.c + shortentext.h + shrtpath.c + shrtpath.h + smalldlg.c + smalldlg.h + stringxtc.c + tbezier.c + tbezier.h + tcornu.c + tcornu.h + tcurve.c + tease.c + textnoteui.c + track.c + track.h + trackx.h + trkendpt.c + trkendpt.h + trkendptx.h + trknote.c + trkseg.h + trkseg.c + tstraigh.c + turnout.c + uthash.h + utility.c + utility.h + validator.c + validator.h + include/dirent.h + include/levenshtein.h + include/paramfile.h + include/paramfilelist.h + include/partcatalog.h + include/problemrep.h + include/stringxtc.h + include/utlist.h ) -SET(SOURCES - ${LIN_SOURCES} - appdefaults.c - archive.c - archive.h - bllnhlp.c - cbezier.c - cbezier.h - cblock.c - ccornu.c - ccornu.h - ccurve.c - ccurve.h - ccontrol.c - cdraw.c - celev.c - cgroup.c - chndldto.c - chotbar.c - cjoin.c - cjoin.h - cmisc.c - cmodify.c - cnote.c - common.h - common-ui.h - compound.c - compound.h - cparalle.c - cprint.c - cprofile.c - cpull.c - cruler.c - cselect.c - cselect.h - csensor.c - csnap.c - csplit.c - csignal.c - cstraigh.c - cstraigh.h - cstruct.c - cswitchmotor.c - ctext.c - ctodesgn.c - ctrain.c - cturnout.c - cturntbl.c - cundo.c - custom.c - custom.h - dbench.c - dbitmap.c - dcar.c - dcmpnd.c - dcustmgm.c - dcontmgm.c - dease.c - denum.c - directory.c - dlayer.c - doption.c - dpricels.c - dprmfile.c - draw.c - draw.h - drawgeom.c - dxfformat.c - dxfformat.h - dxfoutput.c - elev.c - file2uri.c - file2uri.h - fileio.c - filenoteui.c - i18n.c - layout.c - layout.h - levenshtein.c - linknoteui.c - lprintf.c - macro.c - manifest.c - misc.c - misc.h - misc2.c - param.c - paramfile.c - paramfilelist.c - paramfilesearch_ui.c - partcatalog.c - paths.c - shortentext.c - shrtpath.c - smalldlg.c - stringxtc.c - tbezier.c - tcornu.c - tcurve.c - tease.c - textnoteui.c - track.c - track.h - trackx.h - trknote.c - trkseg.c - tstraigh.c - utility.c - utility.h - validator.c - cJSON.c - archive.h - directory.h - manifest.h - validator.h - ) - # add UTF-8 conversion utilities on Windows + if(WIN32) - set( SOURCES - ${SOURCES} - utf8convert.c - include/utf8convert.h + target_sources(xtrkcad-lib + PRIVATE + utf8convert.c + include/utf8convert.h ) -endif(WIN32) - -set (SOURCES - ${SOURCES} - include/dirent.h - include/levenshtein.h - include/paramfile.h - include/paramfilelist.h - include/partcatalog.h - include/stringxtc.h - include/utlist.h +endif() + +# This ensures that messages.h has been generated before we build xtrkcad-lib +add_dependencies(xtrkcad-lib + msgfiles + lines + genbitmaps ) -if(XTRKCAD_CREATE_SVG) - set (SOURCES - ${SOURCES} - svgformat.c - svgoutput.c - ) - include_directories(${MINIXML_INCLUDE_PATH}) - if(WIN32) - add_custom_command( - TARGET xtrkcad POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${MINIXML_SHAREDLIB} - ${CMAKE_CURRENT_BINARY_DIR} - ) +target_include_directories(xtrkcad-lib + PUBLIC + ${messagefile_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} +) - # add dll to install package - install(FILES ${MINIXML_SHAREDLIB} - DESTINATION ${XTRKCAD_BIN_INSTALL_DIR} - ) - endif(WIN32) +target_link_libraries(xtrkcad-lib + PRIVATE + cJSON + dynstring + xtrkcad-cornu + xtrkcad-wlib +) -endif(XTRKCAD_CREATE_SVG) +if(UNIX AND NOT APPLE) + target_link_libraries(xtrkcad-lib PRIVATE ${LIBZIP_LIBRARY} ${LIBZIP_LIBRARIES} ${ZLIB_LIBRARY}) +else() + target_link_libraries(xtrkcad-lib + PRIVATE + Libzip::Libzip + FreeImage::FreeImage + Zlib::Zlib) +endif() -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) -INCLUDE_DIRECTORIES(${XTrkCAD_BINARY_DIR}) -INCLUDE_DIRECTORIES(${help_BINARY_DIR}) -INCLUDE_DIRECTORIES(${wlib_SOURCE_DIR}/include) -include_directories(${FREEIMAGE_INCLUDE_PATH}) -INCLUDE_DIRECTORIES(${LIBZIP_INCLUDE_DIR_ZIP}) -INCLUDE_DIRECTORIES(${CJSON_INCLUDE}) +# +# Start building the main program itself +# +add_executable(${XTRKCAD_BIN} WIN32 "" ) -LINK_DIRECTORIES(${GTK_LIBRARY_DIRS}) -LINK_DIRECTORIES(${GTK_WEBKIT_LIBRARY_DIRS}) -LINK_DIRECTORIES(${LIBZIP_LIBZIP_LIBRARY}) +# if SVG export is built and source files and dependency on MiniXML -ADD_LIBRARY(xtrkcad-lib ${SOURCES}) +if(XTRKCAD_CREATE_SVG) + target_sources(xtrkcad-lib + PRIVATE + svgformat.c + svgoutput.c + ) -# This ensures that messages.h has been generated before we build xtrkcad-lib -ADD_DEPENDENCIES(xtrkcad-lib Help) + if(WIN32) + target_link_libraries(xtrkcad-lib + PRIVATE + MiniXML::mxml + ) + endif() + if(UNIX) + if (APPLE OR NOT ${MINIXML_STATIC_LIBRARY}) + target_link_libraries(xtrkcad-lib + PRIVATE + MiniXML::mxml + ) + else() + target_link_libraries(xtrkcad ${MINIXML_STATIC_LIBRARY}) + target_link_libraries(xtrkcad "pthread") + endif() + endif() +endif() -TARGET_LINK_LIBRARIES(xtrkcad xtrkcad-lib) -TARGET_LINK_LIBRARIES(xtrkcad xtrkcad-wlib) -TARGET_LINK_LIBRARIES(xtrkcad xtrkcad-cornu) -TARGET_LINK_LIBRARIES(xtrkcad dynstring) -if(XTRKCAD_CREATE_SVG) -IF(UNIX) - if (NOT APPLE) - target_link_libraries(xtrkcad ${MINIXML_STATIC_LIBRARY}) - target_link_libraries(xtrkcad "pthread") - else(NOT APPLE) - target_link_libraries(xtrkcad ${MINIXML_LIBRARY}) - endif(NOT APPLE) -ELSE(UNIX) - target_link_libraries(xtrkcad ${MINIXML_STATIC_LIBRARY}) -ENDIF(UNIX) -endif(XTRKCAD_CREATE_SVG) - -IF(UNIX AND NOT APPLE) -target_link_libraries(xtrkcad ${LIBZIP_LIBRARY} ${LIBZIP_LIBRARIES} ${ZLIB_LIBRARY}) -ELSE(UNIX AND NOT APPLE) -target_link_libraries(xtrkcad ${LIBZIP_LIBRARY} ${LIBZIP_LIBRARIES}) -ENDIF(UNIX AND NOT APPLE) - -ADD_EXECUTABLE(mkturnout - ${LIN_SOURCES} - ctodesgn.c +target_sources(${XTRKCAD_BIN} + PRIVATE + misc.c + ${messagefile_BINARY_DIR}/bllnhlp.c + xtrkcad.rc +) +add_dependencies(${XTRKCAD_BIN} + balloonhelp + msgfiles + genbitmaps) + +target_include_directories(${XTRKCAD_BIN} + PRIVATE + ${messagefile_BINARY_DIR} +) + +target_link_libraries(${XTRKCAD_BIN} + PRIVATE + xtrkcad-wlib + xtrkcad-lib +) + +# +# Create mkturnout utility +# +add_executable(mkturnout + ctodesgn.c utility.c + trkendpt.c +) +set_target_properties(mkturnout PROPERTIES COMPILE_FLAGS -DMKTURNOUT) +set_target_properties(mkturnout PROPERTIES FOLDER "Param Files" ) - ) -SET_TARGET_PROPERTIES(mkturnout PROPERTIES COMPILE_FLAGS -DMKTURNOUT) +target_include_directories(mkturnout + PRIVATE + ${messagefile_BINARY_DIR} +) -TARGET_LINK_LIBRARIES(mkturnout xtrkcad-cornu) +target_link_libraries(mkturnout + PRIVATE + xtrkcad-wlib +) -IF(NOT WIN32) - TARGET_LINK_LIBRARIES(mkturnout m) - TARGET_LINK_LIBRARIES(xtrkcad m) +add_dependencies(mkturnout + msgfiles + lines +) + +if(NOT WIN32) + target_link_libraries(mkturnout + PRIVATE + m + ) + target_link_libraries(${XTRKCAD_BIN} + PRIVATE + m + ) # Link libintl for systems where it is a separate library find_library( INTL_LIBRARY intl ) if(INTL_LIBRARY) - target_link_libraries( mkturnout ${INTL_LIBRARY} ) - endif(INTL_LIBRARY) -ELSE(NOT WIN32) - TARGET_LINK_LIBRARIES(mkturnout xtrkcad-wlib) - + target_link_libraries( mkturnout + PRIVATE + ${INTL_LIBRARY} + ) + endif() +else() # copy dlls into the build dir for easier debugging - add_custom_command( - TARGET xtrkcad POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${FREEIMAGE_SHAREDLIB} - ${CMAKE_CURRENT_BINARY_DIR} - ) - - add_custom_command( - TARGET xtrkcad POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBZIP_SHAREDLIB} - ${CMAKE_CURRENT_BINARY_DIR} - ) - - add_custom_command( - TARGET xtrkcad POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${ZLIB_SHAREDLIB} - ${CMAKE_CURRENT_BINARY_DIR} - ) - + COPYDLLTOBUILD(${FREEIMAGE_SHAREDLIB}) +# COPYDLLTOBUILD(${LIBZIP_SHAREDLIB}) +# COPYDLLTOBUILD(${ZLIB_SHAREDLIB}) + set(ENV{path} "${CMAKE_CURRENT_BINARY_DIR};$ENV{PATH}") # add dll to install package - INSTALL( - FILES - ${LIBZIP_SHAREDLIB} + install( + FILES ${LIBZIP_SHAREDLIB} DESTINATION ${XTRKCAD_BIN_INSTALL_DIR} ) - INSTALL(FILES - ${ZLIB_SHAREDLIB} + install( + FILES ${ZLIB_SHAREDLIB} DESTINATION ${XTRKCAD_BIN_INSTALL_DIR} ) - # Copy program PDB file - INSTALL( - FILES $<TARGET_PDB_FILE:xtrkcad> - DESTINATION ${XTRKCAD_BIN_INSTALL_DIR} OPTIONAL + # Copy program PDB file + install( + FILES $<TARGET_PDB_FILE:xtrkcad> + DESTINATION ${XTRKCAD_BIN_INSTALL_DIR} + OPTIONAL ) -ENDIF(NOT WIN32) +endif() # for testing only, should be IF(APPLE) ... -IF(APPLE) - ADD_EXECUTABLE( helphelper helphelper.c ) - FIND_LIBRARY(COREFOUNDATION_LIBRARY CoreFoundation) - FIND_LIBRARY(CARBON_LIBRARY Carbon) - TARGET_lINK_LIBRARIES(helphelper ${COREFOUNDATION_LIBRARY} ${CARBON_LIBRARY}) - INSTALL( +if(APPLE) + add_executable( helphelper helphelper.c ) + find_library(COREFOUNDATION_LIBRARY CoreFoundation) + find_library(CARBON_LIBRARY Carbon) + target_link_libraries(helphelper ${COREFOUNDATION_LIBRARY} ${CARBON_LIBRARY}) + install( TARGETS helphelper RUNTIME DESTINATION ${XTRKCAD_BIN_INSTALL_DIR} ) -ENDIF(APPLE) +endif() -INSTALL( - TARGETS xtrkcad +install( + TARGETS ${XTRKCAD_BIN} RUNTIME DESTINATION ${XTRKCAD_BIN_INSTALL_DIR} - ) +) if(XTRKCAD_TESTING AND CMOCKA_FOUND) add_subdirectory( unittest ) diff --git a/app/bin/acclkeys.h b/app/bin/acclkeys.h index d8c59d3..48ef6bb 100644 --- a/app/bin/acclkeys.h +++ b/app/bin/acclkeys.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* @@ -62,6 +62,7 @@ #define ACCL_DELETE (WCTL+'d') #define ACCL_TUNNEL (WCTL+WSHIFT+'t') #define ACCL_BRIDGE (0) +#define ACCL_ROADBED (0) #define ACCL_TIES (0) #define ACCL_HNDLDTO (WCTL+WSHIFT+'i') #define ACCL_TEXT (WCTL+WSHIFT+'x') @@ -124,6 +125,7 @@ #define ACCL_IMPORT (WALT+WCTL+'i') #define ACCL_IMPORT_MOD (0) #define ACCL_EXPORTDXF (0) +#define ACCL_EXPORTSVG (0) #define ACCL_LOOSEN (WCTL+WSHIFT+'k') #define ACCL_GROUP (WCTL+WSHIFT+'g') #define ACCL_UNGROUP (WCTL+WSHIFT+'u') diff --git a/app/bin/appdefaults.c b/app/bin/appdefaults.c index e5cff8b..0e1898d 100644 --- a/app/bin/appdefaults.c +++ b/app/bin/appdefaults.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <wchar.h> @@ -28,28 +28,28 @@ #include "paths.h" enum defaultTypes { - INTEGERCONSTANT, - FLOATCONSTANT, - STRINGCONSTANT, - INTEGERFUNCTION, - FLOATFUNCTION, - STRINGFUNCTION + INTEGERCONSTANT, + FLOATCONSTANT, + STRINGCONSTANT, + INTEGERFUNCTION, + FLOATFUNCTION, + STRINGFUNCTION }; struct appDefault { - char *defaultKey; /**< the key used to access the value */ - bool wasUsed; /**< value has already been used on this run */ - enum defaultTypes - valueType; /**< type of default, constant or pointer to a function */ - union { - int intValue; - double floatValue; - char *stringValue; - int (*intFunction)(struct appDefault *, void *); - double (*floatFunction)(struct appDefault *, void *); - char *(*stringFunction)(struct appDefault *, void *); - } defaultValue; - void *additionalData; + char *defaultKey; /**< the key used to access the value */ + bool wasUsed; /**< value has already been used on this run */ + enum defaultTypes + valueType; /**< type of default, constant or pointer to a function */ + union { + int intValue; + double floatValue; + char *stringValue; + int (*intFunction)(struct appDefault *, void *); + double (*floatFunction)(struct appDefault *, void *); + char *(*stringFunction)(struct appDefault *, void *); + } defaultValue; + void *additionalData; }; static int GetLocalMeasureSystem(struct appDefault *ptrDefault, @@ -63,7 +63,7 @@ static double GetLocalRoomSize(struct appDefault *ptrDefault, static char *GetParamFullPath(struct appDefault *ptrDefault, void *additionalData); static char *GetParamPrototype(struct appDefault *ptrDefault, - void *additionalData); + void *additionalData); /** * List of application default settings. As this is searched by binary search, the list has to be kept sorted @@ -73,46 +73,51 @@ static char *GetParamPrototype(struct appDefault *ptrDefault, struct appDefault xtcDefaults[] = { { "DialogItem.cmdopt-preselect", 0, INTEGERCONSTANT,{ .intValue = 1 } }, /**< default command is select */ - { "DialogItem.cmdopt-rightclickmode", 0, INTEGERCONSTANT,{ .intValue = 1 } }, /**< swap default to context */ + { "DialogItem.cmdopt-rightclickmode", 0, INTEGERCONSTANT,{ .intValue = 1 } }, /**< swap default to context */ { "DialogItem.cmdopt-selectmode", 0, INTEGERCONSTANT,{ .intValue = 0 } }, /**< 'Only' mode */ { "DialogItem.cmdopt-selectzero", 0, INTEGERCONSTANT,{ .intValue = 1 } }, /**< 'On' mode */ { "DialogItem.grid-horzenable", 0, INTEGERCONSTANT, { .intValue = 0 }}, { "DialogItem.grid-vertenable", 0, INTEGERCONSTANT,{ .intValue = 0 } }, { "DialogItem.pref-dstfmt", 0, INTEGERFUNCTION,{ .intFunction = GetLocalDistanceFormat } }, /**< number format for distances */ - { "DialogItem.pref-units", 0, INTEGERFUNCTION,{ .intFunction = GetLocalMeasureSystem } }, /**< default unit depends on region */ + { "DialogItem.pref-units", 0, INTEGERFUNCTION,{ .intFunction = GetLocalMeasureSystem } }, /**< default unit depends on region */ { "DialogItem.rgbcolor-exception", 0, INTEGERCONSTANT, { .intValue = 15923462 }}, /**< rich yellow as exception color */ { "Parameter File Map.British stock", 0, STRINGFUNCTION,{ .stringFunction = GetParamFullPath }, "br.xtp" }, { "Parameter File Map.European stock", 0, STRINGFUNCTION,{ .stringFunction = GetParamFullPath }, "eu.xtp" }, - { "Parameter File Map.NMRA RP12-25 Feb 2015 O scale Turnouts", 0, STRINGFUNCTION,{ .stringFunction = GetParamFullPath }, "nmra-o.xtp" }, - { "Parameter File Map.NMRA RP12-27 Feb 2015 S Scale Turnouts", 0, STRINGFUNCTION,{ .stringFunction = GetParamFullPath }, "nmra-s.xtp" }, - { "Parameter File Map.NMRA RP12-31 Feb 2015 HO Scale Turnouts", 0, STRINGFUNCTION,{ .stringFunction = GetParamFullPath }, "nmra-ho.xtp" }, - { "Parameter File Map.NMRA RP12-33 Feb 2015 TT Scale Turnouts", 0, STRINGFUNCTION,{ .stringFunction = GetParamFullPath }, "nmra-tt.xtp" }, - { "Parameter File Map.NMRA RP12-35 Feb 2015 N Scale Turnouts", 0, STRINGFUNCTION,{ .stringFunction = GetParamFullPath }, "nmra-n.xtp" }, - { "Parameter File Map.NMRA RP12-37 Feb 2015 Z scale Turnouts", 0, STRINGFUNCTION,{ .stringFunction = GetParamFullPath }, "nmra-z.xtp" }, + { "Parameter File Map.NMRA RP-12.25 Feb 2015 O scale Turnouts", 0, STRINGFUNCTION,{ .stringFunction = GetParamFullPath }, "nmra-o.xtp" }, + { "Parameter File Map.NMRA RP-12.27 Feb 2015 S Scale Turnouts", 0, STRINGFUNCTION,{ .stringFunction = GetParamFullPath }, "nmra-s.xtp" }, + { "Parameter File Map.NMRA RP-12.31 Feb 2015 HO Scale Turnouts", 0, STRINGFUNCTION,{ .stringFunction = GetParamFullPath }, "nmra-ho.xtp" }, + { "Parameter File Map.NMRA RP-12.33 Feb 2015 TT Scale Turnouts", 0, STRINGFUNCTION,{ .stringFunction = GetParamFullPath }, "nmra-tt.xtp" }, + { "Parameter File Map.NMRA RP-12.35 Feb 2015 N Scale Turnouts", 0, STRINGFUNCTION,{ .stringFunction = GetParamFullPath }, "nmra-n.xtp" }, + { "Parameter File Map.NMRA RP-12.37 Feb 2015 Z scale Turnouts", 0, STRINGFUNCTION,{ .stringFunction = GetParamFullPath }, "nmra-z.xtp" }, { "Parameter File Map.North American Prototypes", 0, STRINGFUNCTION,{ .stringFunction = GetParamFullPath }, "protoam.xtp" }, - { "Parameter File Map.Trees", 0, STRINGFUNCTION,{ .stringFunction = GetParamFullPath } , "trees.xtp" }, + { "Parameter File Map.Trees", 0, STRINGFUNCTION,{ .stringFunction = GetParamFullPath }, "trees.xtp" }, { "Parameter File Names.File1", 0, STRINGFUNCTION,{ .stringFunction = GetParamPrototype }}, { "Parameter File Names.File2", 0, STRINGCONSTANT,{ .stringValue = "Trees" } }, - { "Parameter File Names.File3", 0, STRINGCONSTANT,{ .stringValue = "NMRA RP12-37 Feb 2015 Z scale Turnouts" } }, - { "Parameter File Names.File4", 0, STRINGCONSTANT,{ .stringValue = "NMRA RP12-35 Feb 2015 N Scale Turnouts" } }, - { "Parameter File Names.File5", 0, STRINGCONSTANT,{ .stringValue = "NMRA RP12-33 Feb 2015 TT Scale Turnouts" } }, - { "Parameter File Names.File6", 0, STRINGCONSTANT,{ .stringValue = "NMRA RP12-31 Feb 2015 HO Scale Turnouts" } }, - { "Parameter File Names.File7", 0, STRINGCONSTANT,{ .stringValue = "NMRA RP12-27 Feb 2015 S Scale Turnouts" } }, - { "Parameter File Names.File8", 0, STRINGCONSTANT,{ .stringValue = "NMRA RP12-25 Feb 2015 O scale Turnouts" } }, - { "draw.roomsizeX", 0, FLOATFUNCTION, {.floatFunction = GetLocalRoomSize }}, /**< layout width */ - { "draw.roomsizeY", 0, FLOATFUNCTION,{ .floatFunction = GetLocalRoomSize } }, /**< layout depth */ - { "misc.scale", 0, STRINGFUNCTION, { .stringFunction = GetLocalPopularScale}}, /**< the (probably) most popular scale for a region */ + { "Parameter File Names.File3", 0, STRINGCONSTANT,{ .stringValue = "NMRA RP-12.37 Feb 2015 Z scale Turnouts" } }, + { "Parameter File Names.File4", 0, STRINGCONSTANT,{ .stringValue = "NMRA RP-12.35 Feb 2015 N Scale Turnouts" } }, + { "Parameter File Names.File5", 0, STRINGCONSTANT,{ .stringValue = "NMRA RP-12.33 Feb 2015 TT Scale Turnouts" } }, + { "Parameter File Names.File6", 0, STRINGCONSTANT,{ .stringValue = "NMRA RP-12.31 Feb 2015 HO Scale Turnouts" } }, + { "Parameter File Names.File7", 0, STRINGCONSTANT,{ .stringValue = "NMRA RP-12.27 Feb 2015 S Scale Turnouts" } }, + { "Parameter File Names.File8", 0, STRINGCONSTANT,{ .stringValue = "NMRA RP-12.25 Feb 2015 O scale Turnouts" } }, + { "draw.roomsizeX", 0, FLOATFUNCTION, {.floatFunction = GetLocalRoomSize }}, /**< layout width */ + { "draw.roomsizeY", 0, FLOATFUNCTION,{ .floatFunction = GetLocalRoomSize } }, /**< layout depth */ + { "misc.scale", 0, STRINGFUNCTION, { .stringFunction = GetLocalPopularScale}}, /**< the (probably) most popular scale for a region */ }; #define DEFAULTCOUNT COUNT(xtcDefaults) static long bFirstRun; /**< TRUE if appl is run the first time */ -static char regionCode[3]; /**< will be initialized to the locale's region code */ +static char +regionCode[3]; /**< will be initialized to the locale's region code */ -static wBool_t(*GetIntegerPref)(const char *, const char *, long *, long) = wPrefGetIntegerExt; /**< pointer to active integer pref getter */ -static wBool_t(*GetFloatPref)(const char *, const char *, double *, double) = wPrefGetFloatExt; /**< pointer to active float pref getter */ -static char *(*GetStringPref)(const char *, const char *) = wPrefGetStringExt; /**< pointer to active string pref getter */ +static wBool_t(*GetIntegerPref)(const char *, const char *, long *, + long) = wPrefGetIntegerExt; /**< pointer to active integer pref getter */ +static wBool_t(*GetFloatPref)(const char *, const char *, double *, + double) = wPrefGetFloatExt; /**< pointer to active float pref getter */ +static char *(*GetStringPref)(const char *, + const char *) = + wPrefGetStringExt; /**< pointer to active string pref getter */ /** * A recursive binary search function. It returns location of x in @@ -128,32 +133,32 @@ static char *(*GetStringPref)(const char *, const char *) = wPrefGetStringExt; static int binarySearch(struct appDefault arr[], int l, int r, char *key) { - if (r >= l) { - int mid = l + (r - l) / 2; - int res = strcmp(key, arr[mid].defaultKey); - - // If the element is present at the middle itself - if (!res) { - return mid; - } - - // If the array size is 1 - if (r == 0) { - return -1; - } - - // If element is smaller than mid, then it can only be present - // in left subarray - if (res < 0) { - return binarySearch(arr, l, mid - 1, key); - } - - // Else the element can only be present in right subarray - return binarySearch(arr, mid + 1, r, key); - } - - // We reach here when element is not present in array - return -1; + if (r >= l) { + int mid = l + (r - l) / 2; + int res = strcmp(key, arr[mid].defaultKey); + + // If the element is present at the middle itself + if (!res) { + return mid; + } + + // If the array size is 1 + if (r == 0) { + return -1; + } + + // If element is smaller than mid, then it can only be present + // in left subarray + if (res < 0) { + return binarySearch(arr, l, mid - 1, key); + } + + // Else the element can only be present in right subarray + return binarySearch(arr, mid + 1, r, key); + } + + // We reach here when element is not present in array + return -1; } /** @@ -168,20 +173,20 @@ struct appDefault * FindDefault(struct appDefault *defaultValues, const char *section, const char *name) { - char *searchString = malloc(strlen(section) + strlen(name) + - 2); //includes separator and terminating \0 - int res; - sprintf(searchString, "%s.%s", section, name); - - res = binarySearch(defaultValues, 0, DEFAULTCOUNT-1, searchString); - free(searchString); - - if (res != -1 && defaultValues[res].wasUsed == FALSE) { - defaultValues[res].wasUsed = TRUE; - return (defaultValues + res); - } else { - return (NULL); - } + char *searchString = malloc(strlen(section) + strlen(name) + + 2); //includes separator and terminating \0 + int res; + sprintf(searchString, "%s.%s", section, name); + + res = binarySearch(defaultValues, 0, DEFAULTCOUNT-1, searchString); + free(searchString); + + if (res != -1 && defaultValues[res].wasUsed == FALSE) { + defaultValues[res].wasUsed = TRUE; + return (defaultValues + res); + } else { + return (NULL); + } } /** * Get the application's default region code. On Windows, the system's API is used. @@ -191,32 +196,32 @@ FindDefault(struct appDefault *defaultValues, const char *section, static void InitializeRegionCode(void) { - strcpy(regionCode, "US"); + strcpy(regionCode, "US"); // TODO Move this to wlib #ifdef WINDOWS - { - LCID lcid; - char iso3166[10]; - - lcid = GetThreadLocale(); - GetLocaleInfo(lcid, LOCALE_SISO3166CTRYNAME, iso3166, sizeof(iso3166)); - strncpy(regionCode, iso3166, 2); - } + { + LCID lcid; + char iso3166[10]; + + lcid = GetThreadLocale(); + GetLocaleInfo(lcid, LOCALE_SISO3166CTRYNAME, iso3166, sizeof(iso3166)); + strncpy(regionCode, iso3166, 2); + } #else - { - char *pLang; - pLang = getenv("LANG"); - - if (pLang) { - char *ptr; - ptr = strpbrk(pLang, "_-"); - - if (ptr) { - strncpy(regionCode, ptr + 1, 2); - } - } - } + { + char *pLang; + pLang = getenv("LANG"); + + if (pLang) { + char *ptr; + ptr = strpbrk(pLang, "_-"); + + if (ptr) { + strncpy(regionCode, ptr + 1, 2); + } + } + } #endif } @@ -226,7 +231,7 @@ InitializeRegionCode(void) static bool UseMetric() { return ( strcmp( regionCode, "US" ) != 0 && - strcmp( regionCode, "CA" ) != 0 ); + strcmp( regionCode, "CA" ) != 0 ); } /** * For the US the classical 4x8 sheet is used as default size. in the metric world 1,25x2,0m is used. @@ -235,15 +240,15 @@ static bool UseMetric() static double GetLocalRoomSize(struct appDefault *ptrDefault, void *data) { - if (!strcmp(ptrDefault->defaultKey, "draw.roomsizeY")) { - return (UseMetric() ? 125.0/2.54 : 48); - } + if (!strcmp(ptrDefault->defaultKey, "draw.roomsizeY")) { + return (UseMetric() ? 125.0/2.54 : 48); + } - if (!strcmp(ptrDefault->defaultKey, "draw.roomsizeX")) { - return (UseMetric() ? 200.0 / 2.54 : 96); - } + if (!strcmp(ptrDefault->defaultKey, "draw.roomsizeX")) { + return (UseMetric() ? 200.0 / 2.54 : 96); + } - return (0.0); // should never get here + return (0.0); // should never get here } /** @@ -253,7 +258,7 @@ GetLocalRoomSize(struct appDefault *ptrDefault, void *data) static char * GetLocalPopularScale(struct appDefault *ptrDefault, void *data) { - return (strcmp(regionCode, "GB") ? "HO" : "OO"); + return (strcmp(regionCode, "GB") ? "HO" : "OO"); } /** @@ -262,7 +267,7 @@ GetLocalPopularScale(struct appDefault *ptrDefault, void *data) static int GetLocalMeasureSystem(struct appDefault *ptrDefault, void *data) { - return (UseMetric() ? 1 : 0); + return (UseMetric() ? 1 : 0); } /** @@ -271,18 +276,19 @@ GetLocalMeasureSystem(struct appDefault *ptrDefault, void *data) static int GetLocalDistanceFormat(struct appDefault *ptrDefault, void *data) { - return (UseMetric() ? 8 : 4); + return (UseMetric() ? 8 : 4); } /** -* Prototype definitions currently only exist for US and British. So US -* is assumed to be the default. +* Prototype definitions currently only exist for US and British. So US +* is assumed to be the default. */ static char* GetParamPrototype(struct appDefault *ptrDefault, void *additionalData) { - return (strcmp(regionCode, "GB") ? "North American Prototypes" : "British stock"); + return (strcmp(regionCode, + "GB") ? "North American Prototypes" : "British stock"); } /** @@ -291,9 +297,9 @@ GetParamPrototype(struct appDefault *ptrDefault, void *additionalData) static char * GetParamFullPath(struct appDefault *ptrDefault, void *additionalData) { - char *str; - MakeFullpath(&str, libDir, PARAM_SUBDIR, (char*)additionalData, I2VP(0)); - return str; + char *str; + MakeFullpath(&str, libDir, PARAM_SUBDIR, (char*)additionalData, I2VP(0)); + return str; } @@ -302,19 +308,21 @@ GetParamFullPath(struct appDefault *ptrDefault, void *additionalData) * allows to switch from the extended default version to the basic implementation. */ -wBool_t -wPrefGetInteger(const char *section, const char *name, long *result, long defaultValue) +wBool_t +wPrefGetInteger(const char *section, const char *name, long *result, + long defaultValue) { return GetIntegerPref(section, name, result, defaultValue); } wBool_t -wPrefGetFloat(const char *section, const char *name, double *result, double defaultValue) +wPrefGetFloat(const char *section, const char *name, double *result, + double defaultValue) { return GetFloatPref(section, name, result, defaultValue); } -char * +char * wPrefGetString(const char *section, const char *name) { return GetStringPref(section, name); @@ -334,20 +342,20 @@ wBool_t wPrefGetIntegerExt(const char *section, const char *name, long *result, long defaultValue) { - struct appDefault *thisDefault; + struct appDefault *thisDefault; - thisDefault = FindDefault(xtcDefaults, section, name); + thisDefault = FindDefault(xtcDefaults, section, name); - if (thisDefault) { - if (thisDefault->valueType == INTEGERCONSTANT) { - defaultValue = thisDefault->defaultValue.intValue; - } else { - defaultValue = (thisDefault->defaultValue.intFunction)(thisDefault, - thisDefault->additionalData); - } - } + if (thisDefault) { + if (thisDefault->valueType == INTEGERCONSTANT) { + defaultValue = thisDefault->defaultValue.intValue; + } else { + defaultValue = (thisDefault->defaultValue.intFunction)(thisDefault, + thisDefault->additionalData); + } + } - return (wPrefGetIntegerBasic(section, name, result, defaultValue)); + return (wPrefGetIntegerBasic(section, name, result, defaultValue)); } /** @@ -365,20 +373,20 @@ wBool_t wPrefGetFloatExt(const char *section, const char *name, double *result, double defaultValue) { - struct appDefault *thisDefault; + struct appDefault *thisDefault; - thisDefault = FindDefault(xtcDefaults, section, name); + thisDefault = FindDefault(xtcDefaults, section, name); - if (thisDefault) { - if (thisDefault->valueType == FLOATCONSTANT) { - defaultValue = thisDefault->defaultValue.floatValue; - } else { - defaultValue = (thisDefault->defaultValue.floatFunction)(thisDefault, - thisDefault->additionalData); - } - } + if (thisDefault) { + if (thisDefault->valueType == FLOATCONSTANT) { + defaultValue = thisDefault->defaultValue.floatValue; + } else { + defaultValue = (thisDefault->defaultValue.floatFunction)(thisDefault, + thisDefault->additionalData); + } + } - return (wPrefGetFloatBasic(section, name, result, defaultValue)); + return (wPrefGetFloatBasic(section, name, result, defaultValue)); } /** @@ -392,37 +400,38 @@ wPrefGetFloatExt(const char *section, const char *name, double *result, char * wPrefGetStringExt(const char *section, const char *name) { - struct appDefault *thisDefault; - - thisDefault = FindDefault(xtcDefaults, section, name); - - if (thisDefault) { - char *prefString; - char *defaultValue; - - if (thisDefault->valueType == STRINGCONSTANT) { - defaultValue = thisDefault->defaultValue.stringValue; - } else { - defaultValue = (thisDefault->defaultValue.stringFunction)(thisDefault, - thisDefault->additionalData); - } - - prefString = (char *)wPrefGetStringBasic(section, name); - return (prefString ? prefString : defaultValue); - } else { - return ((char *)wPrefGetStringBasic(section, name)); - } + struct appDefault *thisDefault; + + thisDefault = FindDefault(xtcDefaults, section, name); + + if ( thisDefault == NULL ) { + // Either we don't have a default value or we've already fetched it + return ((char *)wPrefGetStringBasic(section, name)); + } + + char *prefString; + char *defaultValue; + + if (thisDefault->valueType == STRINGCONSTANT) { + defaultValue = thisDefault->defaultValue.stringValue; + } else { + defaultValue = (thisDefault->defaultValue.stringFunction)(thisDefault, + thisDefault->additionalData); + } + // Next call will get value from Prefs + wPrefSetString( section, name, defaultValue ); + return (defaultValue); } /** * Initialize the application default system. The flag firstrun is used to find * out whether the application was run before. This is accomplished by trying - * to read it from the configuration file. As it is only written after this + * to read it from the configuration file. As it is only written after this * test, it can never be found on the first run of the application ie. when the * configuration file does not exist yet. */ -void +void InitAppDefaults(void) { wPrefGetIntegerBasic( "misc", "firstrun", &bFirstRun, TRUE); diff --git a/app/bin/archive.c b/app/bin/archive.c index 430db49..7b9d0e5 100644 --- a/app/bin/archive.c +++ b/app/bin/archive.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <fcntl.h> @@ -28,10 +28,10 @@ #include "directory.h" #include "dynstring.h" #include "misc.h" -#include "misc2.h" #include "paths.h" #include "include/utf8convert.h" #include "common-ui.h" +#include "fileio.h" int log_zip = 0; @@ -45,7 +45,7 @@ int log_zip = 0; // char *tempBuffer = MyMalloc( cnt ); // char *destBuffer = MyMalloc( cnt ); // -// //// find the +// //// find the // //cnt = MultiByteToWideChar(CP_ACP, // // 0, // // nativeString, @@ -91,33 +91,33 @@ int log_zip = 0; char * GetZipDirectoryName(enum ArchiveOps op) { - char *opDesc; - char *directory; - DynString zipDirectory; + char *opDesc; + char *directory; + DynString zipDirectory; DynStringMalloc(&zipDirectory, 0); - switch (op) { - case ARCHIVE_READ: - opDesc = "in"; - break; - case ARCHIVE_WRITE: - opDesc = "out"; - break; - default: - opDesc = "err"; - break; - } - - DynStringPrintf(&zipDirectory, - "%s" FILE_SEP_CHAR "zip_%s.%d", - workingDir, - opDesc, - getpid()); - - directory = strdup(DynStringToCStr(&zipDirectory)); - DynStringFree(&zipDirectory); - return (directory); + switch (op) { + case ARCHIVE_READ: + opDesc = "in"; + break; + case ARCHIVE_WRITE: + opDesc = "out"; + break; + default: + opDesc = "err"; + break; + } + + DynStringPrintf(&zipDirectory, + "%s" FILE_SEP_CHAR "zip_%s.%d", + workingDir, + opDesc, + getpid()); + + directory = strdup(DynStringToCStr(&zipDirectory)); + DynStringFree(&zipDirectory); + return (directory); } /***************************************************************************** @@ -131,76 +131,76 @@ GetZipDirectoryName(enum ArchiveOps op) */ BOOL_T AddDirectoryToArchive( - struct zip * za, - const char * dir_path, - const char * prefix) + struct zip * za, + const char * dir_path, + const char * prefix) { - char *full_path; - char *arch_path; - DIR *dir; - const char * buf; - struct stat stat_path, stat_entry; - struct dirent *entry; - - zip_source_t * zt; - - // stat for the path - stat(dir_path, &stat_path); - - // if path does not exists or is not dir - exit with status -1 - if (S_ISDIR(stat_path.st_mode) == 0) { - NoticeMessage(MSG_NOT_DIR_FAIL, - _("Continue"), NULL, dir_path); - return FALSE; - } - - // if not possible to read the directory for this user - if ((dir = opendir(dir_path)) == NULL) { - NoticeMessage(MSG_OPEN_DIR_FAIL, - _("Continue"), NULL, dir_path); - return FALSE; - } - - // iteration through entries in the directory - while ((entry = readdir(dir)) != NULL) { - // skip entries "." and ".." - if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, "..")) { - continue; - } - - // determinate a full path of an entry - MakeFullpath(&full_path, dir_path, entry->d_name, NULL); - - // stat for the entry - stat(full_path, &stat_entry); - - if (prefix && prefix[0]) { - MakeFullpath(&arch_path, prefix, entry->d_name, NULL); - } else { - MakeFullpath(&arch_path, entry->d_name, NULL); - } - - // recursively add a nested directory - if (S_ISDIR(stat_entry.st_mode) != 0) { - if (zip_dir_add(za, arch_path, 0) < 0) { - zip_error_t *ziperr = zip_get_error(za); - buf = zip_error_strerror(ziperr); - NoticeMessage(MSG_ZIP_DIR_ADD_FAIL, - _("Continue"), NULL, arch_path, buf); + char *full_path; + char *arch_path; + DIR *dir; + const char * buf; + struct stat stat_path, stat_entry; + struct dirent *entry; + + zip_source_t * zt; + + // stat for the path + stat(dir_path, &stat_path); + + // if path does not exists or is not dir - exit with status -1 + if (S_ISDIR(stat_path.st_mode) == 0) { + NoticeMessage(MSG_NOT_DIR_FAIL, + _("Continue"), NULL, dir_path); + return FALSE; + } + + // if not possible to read the directory for this user + if ((dir = opendir(dir_path)) == NULL) { + NoticeMessage(MSG_OPEN_DIR_FAIL, + _("Continue"), NULL, dir_path); + return FALSE; + } + + // iteration through entries in the directory + while ((entry = readdir(dir)) != NULL) { + // skip entries "." and ".." + if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, "..")) { + continue; + } + + // determinate a full path of an entry + MakeFullpath(&full_path, dir_path, entry->d_name, NULL); + + // stat for the entry + stat(full_path, &stat_entry); + + if (prefix && prefix[0]) { + MakeFullpath(&arch_path, prefix, entry->d_name, NULL); + } else { + MakeFullpath(&arch_path, entry->d_name, NULL); + } + + // recursively add a nested directory + if (S_ISDIR(stat_entry.st_mode) != 0) { + if (zip_dir_add(za, arch_path, 0) < 0) { + zip_error_t *ziperr = zip_get_error(za); + buf = zip_error_strerror(ziperr); + NoticeMessage(MSG_ZIP_DIR_ADD_FAIL, + _("Continue"), NULL, arch_path, buf); #if DEBUG - printf("Added Directory %s \n", arch_path); + printf("Added Directory %s \n", arch_path); #endif - } - - if (AddDirectoryToArchive(za, full_path, arch_path) != TRUE) { - free(full_path); - free(arch_path); - return FALSE; - } - free(arch_path); - continue; - } else { + } + + if (AddDirectoryToArchive(za, full_path, arch_path) != TRUE) { + free(full_path); + free(arch_path); + return FALSE; + } + free(arch_path); + continue; + } else { char *archPathUtf8 = MyStrdup(arch_path); char *fullPathUtf8 = MyStrdup(full_path); #ifdef UTFCONVERT @@ -208,30 +208,30 @@ BOOL_T AddDirectoryToArchive( fullPathUtf8 = Convert2UTF8(fullPathUtf8); ConvertPathForward(archPathUtf8); #endif // UTFCONVERT - zt = zip_source_file(za, fullPathUtf8, 0, -1); - if (zip_file_add(za, archPathUtf8, zt, ZIP_FL_ENC_UTF_8) == -1) { - zip_error_t *ziperr = zip_get_error(za); - buf = zip_error_strerror(ziperr); - NoticeMessage(MSG_ZIP_FILE_ADD_FAIL, _("Continue"), NULL, full_path, arch_path, - buf); - free(full_path); - free(arch_path); + zt = zip_source_file(za, fullPathUtf8, 0, -1); + if (zip_file_add(za, archPathUtf8, zt, ZIP_FL_ENC_UTF_8) == -1) { + zip_error_t *ziperr = zip_get_error(za); + buf = zip_error_strerror(ziperr); + NoticeMessage(MSG_ZIP_FILE_ADD_FAIL, _("Continue"), NULL, full_path, arch_path, + buf); + free(full_path); + free(arch_path); MyFree(fullPathUtf8); MyFree(archPathUtf8); - return FALSE; - } + return FALSE; + } MyFree(fullPathUtf8); MyFree(archPathUtf8); #if DEBUG - printf("Added File %s", full_path); + printf("Added File %s", full_path); #endif - } - free(arch_path); - free(full_path); - } + } + free(arch_path); + free(full_path); + } - closedir(dir); - return TRUE; + closedir(dir); + return TRUE; } /*********************************************************************** @@ -244,20 +244,20 @@ BOOL_T AddDirectoryToArchive( */ BOOL_T CreateArchive( - const char * dir_path, - const char * fileName) + const char * dir_path, + const char * fileName) { - struct zip *za; - int err; - char buf[100]; + struct zip *za; + int err; + zip_error_t error; - char * archive = MyStrdup(fileName); // Because of const char - char * archive_name = FindFilename(archive); - char * archive_path; + char * archive = MyStrdup(fileName); // Because of const char + char * archive_name = FindFilename(archive); + char * archive_path; char * archiveUtf8; - MakeFullpath(&archive_path, workingDir, archive_name, NULL); - + MakeFullpath(&archive_path, workingDir, archive_name, NULL); + archiveUtf8 = MyStrdup(archive_path); #ifdef UTFCONVERT archiveUtf8 = Convert2UTF8(archiveUtf8); @@ -265,43 +265,51 @@ BOOL_T CreateArchive( MyFree(archive); - if ((za = zip_open(archiveUtf8, ZIP_CREATE, &err)) == NULL) { - zip_error_to_str(buf, sizeof(buf), err, errno); - NoticeMessage(MSG_ZIP_CREATE_FAIL, _("Continue"), NULL, archiveUtf8, buf); - MyFree(archiveUtf8); - return FALSE; - } + if ((za = zip_open(archiveUtf8, ZIP_CREATE, &err)) == NULL) { + zip_error_init_with_code(&error, err); + NoticeMessage(MSG_ZIP_CREATE_FAIL, _("Continue"), NULL, archiveUtf8, + zip_error_strerror(&error)); + zip_error_fini(&error); + MyFree(archiveUtf8); + return FALSE; + } #if DEBUG - printf("====================== \n"); - printf("Started Archive %s", archive_path); + printf("====================== \n"); + printf("Started Archive %s", archive_path); #endif - AddDirectoryToArchive(za, dir_path, ""); - - if (zip_close(za) == -1) { - zip_error_to_str(buf, sizeof(buf), err, errno); - NoticeMessage(MSG_ZIP_CLOSE_FAIL, _("Continue"), NULL, archiveUtf8, buf); - free(archive_path); - MyFree(archiveUtf8); - return FALSE; - } + AddDirectoryToArchive(za, dir_path, ""); - unlink(fileName); //Delete Old - if (rename(archive_path, fileName) == -1) { //Move zip into place - NoticeMessage(MSG_ZIP_RENAME_FAIL, _("Continue"), NULL, archiveUtf8, fileName, - strerror(errno)); + if (zip_close(za) == -1) { + zip_error_init_with_code(&error, err); + NoticeMessage(MSG_ZIP_CLOSE_FAIL, _("Continue"), NULL, archiveUtf8, + zip_error_strerror(&error)); + zip_error_fini(&error); free(archive_path); MyFree(archiveUtf8); - return FALSE; - } + return FALSE; + } + + unlink(fileName); //Delete Old + if (rename(archive_path, fileName) == -1) { //Move zip into place + if ( Copyfile( archive_path, fileName ) == -1 ) { + NoticeMessage(MSG_ZIP_RENAME_FAIL, _("Continue"), NULL, archiveUtf8, + fileName, strerror(errno)); + free(archive_path); + MyFree(archiveUtf8); + return FALSE; + } else { + unlink( archive_path ); + } + } free(archive_path); MyFree(archiveUtf8); #if DEBUG - printf("Moved Archive to %s", fileName); - printf("====================== \n"); + printf("Moved Archive to %s", fileName); + printf("====================== \n"); #endif - return TRUE; + return TRUE; } /************************************************************************** @@ -314,21 +322,22 @@ BOOL_T CreateArchive( * \returns TRUE if all worked */ BOOL_T UnpackArchiveFor( - const char * pathName, /*Full name of archive*/ - const char * fileName, /*Layout name and extension */ - const char * tempDir, /*Directory to unpack into */ - BOOL_T file_only) + const char * pathName, /*Full name of archive*/ + const char * fileName, /*Layout name and extension */ + const char * tempDir, /*Directory to unpack into */ + BOOL_T file_only) { - char *dirName; - struct zip *za; - struct zip_file *zf; - struct zip_stat sb; - char buf[100]; - int err; - int i; - int64_t len; - FILE *fd; - long long sum; + char *dirName; + struct zip *za; + struct zip_file *zf; + struct zip_stat sb; + char buf[100]; + zip_error_t error; + int err; + int i; + int64_t len; + FILE *fd; + long long sum; char *destBuffer = MyStrdup(pathName); #ifdef UTFCONVERT @@ -336,95 +345,97 @@ BOOL_T UnpackArchiveFor( #endif // UTFCONVERT - if ((za = zip_open(destBuffer, 0, &err)) == NULL) { - zip_error_to_str(buf, sizeof(buf), err, errno); - NoticeMessage(MSG_ZIP_OPEN_FAIL, _("Continue"), NULL, pathName, buf); - fprintf(stderr, "xtrkcad: can't open xtrkcad zip archive `%s': %s \n", - pathName, buf); + if ((za = zip_open(destBuffer, 0, &err)) == NULL) { + zip_error_init_with_code(&error, err); + NoticeMessage(MSG_ZIP_OPEN_FAIL, _("Continue"), NULL, pathName, + zip_error_strerror(&error)); + fprintf(stderr, "xtrkcad: can't open xtrkcad zip archive `%s': %s \n", + pathName, zip_error_strerror(&error)); + zip_error_fini(&error); MyFree(destBuffer); - return FALSE; - } + return FALSE; + } - for (i = 0; i < zip_get_num_entries(za, 0); i++) { - if (zip_stat_index(za, i, 0, &sb) == 0) { - len = strlen(sb.name); + for (i = 0; i < zip_get_num_entries(za, 0); i++) { + if (zip_stat_index(za, i, 0, &sb) == 0) { + len = strlen(sb.name); #if DEBUG - printf("==================\n"); - printf("Name: [%s], ", sb.name); - printf("Size: [%llu], ", sb.size); - printf("mtime: [%u]\n", (unsigned int)sb.mtime); - printf("mtime: [%u]\n", (unsigned int)sb.mtime); + printf("==================\n"); + printf("Name: [%s], ", sb.name); + printf("Size: [%llu], ", sb.size); + printf("mtime: [%u]\n", (unsigned int)sb.mtime); + printf("mtime: [%u]\n", (unsigned int)sb.mtime); #endif - LOG(log_zip, 1, ("================= \n")) - LOG(log_zip, 1, ("Zip-Name [%s] \n", sb.name)) - LOG(log_zip, 1, ("Zip-Size [%llu] \n", sb.size)) - LOG(log_zip, 1, ("Zip-mtime [%u] \n", (unsigned int)sb.mtime)) - - if (sb.name[len - 1] == '/' && !file_only) { - MakeFullpath(&dirName, tempDir, &sb.name[0], NULL); - if (SafeCreateDir(dirName) != TRUE) { - free(dirName); - return FALSE; - } - free(dirName); - } else { - zf = zip_fopen_index(za, i, 0); - if (!zf) { - NoticeMessage(MSG_ZIP_INDEX_FAIL, _("Continue"), NULL); - fprintf(stderr, "xtrkcad zip archive open index error \n"); - return FALSE; - } - - if (file_only) { - if (strncmp(sb.name, fileName, strlen(fileName)) != 0) { - continue; /* Ignore any other files than the one we asked for */ - } - } - MakeFullpath(&dirName, tempDir, &sb.name[0], NULL); + LOG(log_zip, 1, ("================= \n")) + LOG(log_zip, 1, ("Zip-Name [%s] \n", sb.name)) + LOG(log_zip, 1, ("Zip-Size [%llu] \n", sb.size)) + LOG(log_zip, 1, ("Zip-mtime [%u] \n", (unsigned int)sb.mtime)) + + if (sb.name[len - 1] == '/' && !file_only) { + MakeFullpath(&dirName, tempDir, &sb.name[0], NULL); + if (SafeCreateDir(dirName) != TRUE) { + free(dirName); + return FALSE; + } + free(dirName); + } else { + zf = zip_fopen_index(za, i, 0); + if (!zf) { + NoticeMessage(MSG_ZIP_INDEX_FAIL, _("Continue"), NULL); + fprintf(stderr, "xtrkcad zip archive open index error \n"); + return FALSE; + } + + if (file_only) { + if (strncmp(sb.name, fileName, strlen(fileName)) != 0) { + continue; /* Ignore any other files than the one we asked for */ + } + } + MakeFullpath(&dirName, tempDir, &sb.name[0], NULL); #ifdef UTFCONVERT ConvertUTF8ToSystem(dirName); #endif // UTFCONVERT fd = fopen(dirName, "wb"); - if (!fd) { - NoticeMessage(MSG_ZIP_FILE_OPEN_FAIL, _("Continue"), NULL, dirName, - strerror(errno)); - free(dirName); - return FALSE; - } - - sum = 0; - while (sum != sb.size) { - len = zip_fread(zf, buf, 100); - if (len < 0) { - NoticeMessage(MSG_ZIP_READ_FAIL, _("Continue"), NULL, dirName, &sb.name[0]); - free(dirName); + if (!fd) { + NoticeMessage(MSG_ZIP_FILE_OPEN_FAIL, _("Continue"), NULL, dirName, + strerror(errno)); + free(dirName); + return FALSE; + } + + sum = 0; + while (sum != sb.size) { + len = zip_fread(zf, buf, 100); + if (len < 0) { + NoticeMessage(MSG_ZIP_READ_FAIL, _("Continue"), NULL, dirName, &sb.name[0]); + free(dirName); fclose(fd); - return FALSE; - } - fwrite(buf, 1, (unsigned int)len, fd); - sum += len; - } - fclose(fd); - free(dirName); - zip_fclose(zf); - } - } else { - LOG(log_zip, 1, ("Zip-Unknown File[%s] Line[%d] \n", __FILE__, __LINE__)) + return FALSE; + } + fwrite(buf, 1, (unsigned int)len, fd); + sum += len; + } + fclose(fd); + free(dirName); + zip_fclose(zf); + } + } else { + LOG(log_zip, 1, ("Zip-Unknown File[%s] Line[%d] \n", __FILE__, __LINE__)) #if DEBUG - printf("File[%s] Line[%d]\n", __FILE__, __LINE__); + printf("File[%s] Line[%d]\n", __FILE__, __LINE__); #endif - } - } + } + } MyFree(destBuffer); - if (zip_close(za) == -1) { - NoticeMessage(MSG_ZIP_CLOSE_FAIL, _("Continue"), NULL, dirName, &sb.name[0]); - return FALSE; - } - return TRUE; + if (zip_close(za) == -1) { + NoticeMessage(MSG_ZIP_CLOSE_FAIL, _("Continue"), NULL, dirName, &sb.name[0]); + return FALSE; + } + return TRUE; } diff --git a/app/bin/archive.h b/app/bin/archive.h index 7977bc6..8c938b2 100644 --- a/app/bin/archive.h +++ b/app/bin/archive.h @@ -9,7 +9,9 @@ extern const char *workingDir; struct zip; char *GetZipDirectoryName(enum ArchiveOps op); -BOOL_T AddDirectoryToArchive(struct zip * za, const char * dir_path, const char * prefix); +BOOL_T AddDirectoryToArchive(struct zip * za, const char * dir_path, + const char * prefix); BOOL_T CreateArchive(const char * dir_path, const char * fileName); -BOOL_T UnpackArchiveFor(const char * pathName, const char * fileName, const char * tempDir, BOOL_T file_only); +BOOL_T UnpackArchiveFor(const char * pathName, const char * fileName, + const char * tempDir, BOOL_T file_only); #endif diff --git a/app/bin/bdf2xtp.c b/app/bin/bdf2xtp.c index f19ceb8..20cea11 100644 --- a/app/bin/bdf2xtp.c +++ b/app/bin/bdf2xtp.c @@ -17,30 +17,30 @@ #include <stdlib.h> char helpStr[] = -"Bdf2xtp translates .bdf files (which are source files for Winrail track\n" -"libraries) to .xtp files (which are XTrkCad parameter files).\n" -"Bdf2xtp is a MS-DOS command and must be in run in a DOS box under MS-Windows.\n" -"\n" -"Usage: bdf2xtp OPTIONS SOURCE.BDF TARGET.XTP\n" -"\n" -"OPTIONS:\n" -" -c CONTENTS description of contents\n" -" -k COLOR color of non-track segments\n" -" -s SCALE scale of turnouts (ie. HO HOn3 N O S ... )\n" -" -v verbose - include .bdf source as comments in .xtp file\n" -"\n" -"For example:\n" -" bdf2xtp -c \"Faller HO Structures\" -k ff0000 -s HO fallerh0.bdf fallerh0.xtp\n" -"\n" -"Turnouts are composed of rails (which are Black) and lines. Structures are\n" -"composed of only lines. By default lines are Purple but you change this with\n" -"the -k optioon. The color is specified as a 6 digit hexidecimal value, where\n" -"the first 2 digits are the Red value, the middle 2 digits are the Green value\n" -"and the last 2 digits are the Blue value\n" -" ff0000 Red\n" -" 00ff00 Green\n" -" 00ffff Yellow\n" -; + "Bdf2xtp translates .bdf files (which are source files for Winrail track\n" + "libraries) to .xtp files (which are XTrkCad parameter files).\n" + "Bdf2xtp is a MS-DOS command and must be in run in a DOS box under MS-Windows.\n" + "\n" + "Usage: bdf2xtp OPTIONS SOURCE.BDF TARGET.XTP\n" + "\n" + "OPTIONS:\n" + " -c CONTENTS description of contents\n" + " -k COLOR color of non-track segments\n" + " -s SCALE scale of turnouts (ie. HO HOn3 N O S ... )\n" + " -v verbose - include .bdf source as comments in .xtp file\n" + "\n" + "For example:\n" + " bdf2xtp -c \"Faller HO Structures\" -k ff0000 -s HO fallerh0.bdf fallerh0.xtp\n" + "\n" + "Turnouts are composed of rails (which are Black) and lines. Structures are\n" + "composed of only lines. By default lines are Purple but you change this with\n" + "the -k optioon. The color is specified as a 6 digit hexidecimal value, where\n" + "the first 2 digits are the Red value, the middle 2 digits are the Green value\n" + "and the last 2 digits are the Blue value\n" + " ff0000 Red\n" + " 00ff00 Green\n" + " 00ffff Yellow\n" + ; /* NOTES: BDF files have a number of constructors for different types of turnouts @@ -89,9 +89,9 @@ Then the list of segments is written out to the output file. #define MAXSEG (40) /* Maximum number of segments in an object */ typedef struct { /* a co-ordinate */ - double x; - double y; - } coOrd; + double x; + double y; +} coOrd; FILE * fin; /* input file */ FILE * fout; /* output file */ @@ -107,8 +107,8 @@ long color = 0x00FF00FF;/* default color */ double normalizeAngle( double angle ) /* make sure <angle> is >= 0.0 and < 360.0 */ { - while (angle<0) angle += 360.0; - while (angle>=360) angle -= 360.0; + while (angle<0) { angle += 360.0; } + while (angle>=360) { angle -= 360.0; } return angle; } @@ -143,8 +143,8 @@ double findAngle( coOrd p0, coOrd p1 ) { double dx = p1.x-p0.x, dy = p1.y-p0.y; if (small(dx) && small(dy)) { - if (dy >=0.0) return 0.0; - else return 180.0; + if (dy >=0.0) { return 0.0; } + else { return 180.0; } } return R2D(atan2( dx,dy )); } @@ -152,156 +152,157 @@ double findAngle( coOrd p0, coOrd p1 ) /* Where do we expect each input line? */ typedef enum { - CLS_NULL, - CLS_START, - CLS_END, - CLS_BODY - } class_e; + CLS_NULL, + CLS_START, + CLS_END, + CLS_BODY +} class_e; /* Type of input line */ typedef enum { - ACT_UNKNOWN, - ACT_DONE, - ACT_STRAIGHT, - ACT_CURVE, - ACT_TURNOUT_LEFT, - ACT_TURNOUT_RIGHT, - ACT_CURVEDTURNOUT_LEFT, - ACT_CURVEDTURNOUT_RIGHT, - ACT_THREEWAYTURNOUT, - ACT_CROSSING_LEFT, - ACT_CROSSING_RIGHT, - ACT_DOUBLESLIP_LEFT, - ACT_DOUBLESLIP_RIGHT, - ACT_CROSSING_SYMMETRIC, - ACT_DOUBLESLIP_SYMMETRIC, - ACT_TURNTABLE, - ACT_ENDTURNTABLE, - ACT_TRANSFERTABLE, - ACT_ENDTRANSFERTABLE, - ACT_TRACK, - ACT_STRUCTURE, - ACT_ENDSTRUCTURE, - - ACT_FILL_POINT, - ACT_LINE, - ACT_CURVEDLINE, - ACT_CIRCLE, - ACT_DESCRIPTIONPOS, - ACT_ARTICLENOPOS, - ACT_CONNECTINGPOINT, - ACT_STRAIGHTTRACK, - ACT_CURVEDTRACK, - ACT_STRAIGHT_BODY, - ACT_CURVE_BODY, - ACT_PRICE - } action_e; + ACT_UNKNOWN, + ACT_DONE, + ACT_STRAIGHT, + ACT_CURVE, + ACT_TURNOUT_LEFT, + ACT_TURNOUT_RIGHT, + ACT_CURVEDTURNOUT_LEFT, + ACT_CURVEDTURNOUT_RIGHT, + ACT_THREEWAYTURNOUT, + ACT_CROSSING_LEFT, + ACT_CROSSING_RIGHT, + ACT_DOUBLESLIP_LEFT, + ACT_DOUBLESLIP_RIGHT, + ACT_CROSSING_SYMMETRIC, + ACT_DOUBLESLIP_SYMMETRIC, + ACT_TURNTABLE, + ACT_ENDTURNTABLE, + ACT_TRANSFERTABLE, + ACT_ENDTRANSFERTABLE, + ACT_TRACK, + ACT_STRUCTURE, + ACT_ENDSTRUCTURE, + + ACT_FILL_POINT, + ACT_LINE, + ACT_CURVEDLINE, + ACT_CIRCLE, + ACT_DESCRIPTIONPOS, + ACT_ARTICLENOPOS, + ACT_CONNECTINGPOINT, + ACT_STRAIGHTTRACK, + ACT_CURVEDTRACK, + ACT_STRAIGHT_BODY, + ACT_CURVE_BODY, + ACT_PRICE +} action_e; /* input line description */ typedef struct { - char * name; /* first token on line */ - class_e class; /* where do we expect this? */ - action_e action;/* what type of line is it */ - char *args; /* what else is on the line */ - } tokenDesc_t; + char * name; /* first token on line */ + class_e class; /* where do we expect this? */ + action_e action;/* what type of line is it */ + char *args; /* what else is on the line */ +} tokenDesc_t; /* first token on each line tells what kind of line it is */ tokenDesc_t tokens[] = { - { "Straight", CLS_START, ACT_STRAIGHT, "SSNN" }, - { "EndStraight", CLS_END, ACT_DONE, NULL }, - { "Curve", CLS_START, ACT_CURVE, "SSNNN" }, - { "EndCurve", CLS_END, ACT_DONE, NULL }, - { "Turnout_Left", CLS_START, ACT_TURNOUT_LEFT, "SSN" }, - { "Turnout_Right", CLS_START, ACT_TURNOUT_RIGHT, "SSN" }, - { "EndTurnout", CLS_END, ACT_DONE, NULL }, - { "CurvedTurnout_Left", CLS_START, ACT_CURVEDTURNOUT_LEFT, "SSN" }, - { "CurvedTurnout_Right", CLS_START, ACT_CURVEDTURNOUT_RIGHT, "SSN" }, - { "ThreeWayTurnout", CLS_START, ACT_THREEWAYTURNOUT, "SSN" }, - { "Crossing_Left", CLS_START, ACT_CROSSING_LEFT, "SSNNNN" }, - { "Crossing_Right", CLS_START, ACT_CROSSING_RIGHT, "SSNNNN" }, - { "DoubleSlip_Left", CLS_START, ACT_DOUBLESLIP_LEFT, "SSNNNNN" }, - { "DoubleSlip_Right", CLS_START, ACT_DOUBLESLIP_RIGHT, "SSNNNNN" }, - { "Crossing_Symetric", CLS_START, ACT_CROSSING_SYMMETRIC, "SSNNN" }, - { "DoubleSlip_Symetric", CLS_START, ACT_DOUBLESLIP_SYMMETRIC, "SSNNNN" }, - { "EndCrossing", CLS_END, ACT_DONE, NULL }, - { "Turntable", CLS_START, ACT_TURNTABLE, "SSNNNN" }, - { "EndTurntable", CLS_END, ACT_ENDTURNTABLE, NULL }, - { "TravellingPlatform", CLS_START, ACT_TRANSFERTABLE, "SSNNNNN" }, - { "EndTravellingPlatform", CLS_END, ACT_ENDTRANSFERTABLE, NULL }, - { "Track", CLS_START, ACT_TRACK, "SSN" }, - { "EndTrack", CLS_END, ACT_DONE, NULL }, - { "Structure", CLS_START, ACT_STRUCTURE, "SS" }, - { "EndStructure", CLS_END, ACT_ENDSTRUCTURE, NULL }, - - { "FillPoint", CLS_BODY, ACT_FILL_POINT, "NNI" }, - { "Line", CLS_BODY, ACT_LINE, "NNNN" }, - { "CurvedLine", CLS_BODY, ACT_CURVEDLINE, "NNNNN" }, - { "CurveLine", CLS_BODY, ACT_CURVEDLINE, "NNNNN" }, - { "Circle", CLS_BODY, ACT_CIRCLE, "NNN" }, - { "DescriptionPos", CLS_BODY, ACT_DESCRIPTIONPOS, "NN" }, - { "ArticleNoPos", CLS_BODY, ACT_DESCRIPTIONPOS, "NN" }, - { "ConnectingPoint", CLS_BODY, ACT_CONNECTINGPOINT, "NNN" }, - { "StraightTrack", CLS_BODY, ACT_STRAIGHTTRACK, "NNNN" }, - { "CurvedTrack", CLS_BODY, ACT_CURVEDTRACK, "NNNNN" }, - { "Straight", CLS_BODY, ACT_STRAIGHT_BODY, "N" }, - { "Curve", CLS_BODY, ACT_CURVE_BODY, "NNN" }, - { "Price", CLS_BODY, ACT_PRICE, "N" }, - - { "Gerade", CLS_START, ACT_STRAIGHT, "SSNN" }, - { "EndGerade", CLS_END, ACT_DONE, NULL }, - { "Bogen", CLS_START, ACT_CURVE, "SSNNN" }, - { "EndBogen", CLS_END, ACT_DONE, NULL }, - { "Weiche_links", CLS_START, ACT_TURNOUT_LEFT, "SSN" }, - { "Weiche_Rechts", CLS_START, ACT_TURNOUT_RIGHT, "SSN" }, - { "EndWeiche", CLS_END, ACT_DONE, NULL }, - { "Bogenweiche_Links", CLS_START, ACT_CURVEDTURNOUT_LEFT, "SSN" }, - { "Bogenweiche_Rechts", CLS_START, ACT_CURVEDTURNOUT_RIGHT, "SSN" }, - { "Dreiwegweiche", CLS_START, ACT_THREEWAYTURNOUT, "SSN" }, - { "Kreuzung_Links", CLS_START, ACT_CROSSING_LEFT, "SSNNNN" }, - { "Kreuzung_Rechts", CLS_START, ACT_CROSSING_RIGHT, "SSNNNN" }, - { "DKW_Links", CLS_START, ACT_DOUBLESLIP_LEFT, "SSNNNNN" }, - { "DKW_Rechts", CLS_START, ACT_DOUBLESLIP_RIGHT, "SSNNNNN" }, - { "Kreuzung_Symmetrisch", CLS_START, ACT_CROSSING_SYMMETRIC, "SSNNN" }, - { "DKW_Symmetrisch", CLS_START, ACT_DOUBLESLIP_SYMMETRIC, "SSNNNN" }, - { "EndKreuzung", CLS_END, ACT_DONE, NULL }, - { "Drehscheibe", CLS_START, ACT_TURNTABLE, "SSNNNN" }, - { "EndDrehscheibe", CLS_END, ACT_ENDTURNTABLE, NULL }, - { "Schiebebuehne", CLS_START, ACT_TRANSFERTABLE, "SSNNNNN" }, - { "EndSchiebebuehne", CLS_END, ACT_ENDTRANSFERTABLE, NULL }, - { "Schiene", CLS_START, ACT_TRACK, "SSN" }, - { "EndSchiene", CLS_END, ACT_DONE, NULL }, - { "Haus", CLS_START, ACT_STRUCTURE, "SS" }, - { "EndHaus", CLS_END, ACT_ENDSTRUCTURE, NULL }, - - { "FuellPunkt", CLS_BODY, ACT_FILL_POINT, "NNI" }, - { "Linie", CLS_BODY, ACT_LINE, "NNNN" }, - { "Bogenlinie", CLS_BODY, ACT_CURVEDLINE, "NNNNN" }, - { "Kreislinie", CLS_BODY, ACT_CIRCLE, "NNN" }, - { "BezeichnungsPos", CLS_BODY, ACT_DESCRIPTIONPOS, "NN" }, - { "ArtikelNrPos", CLS_BODY, ACT_DESCRIPTIONPOS, "NN" }, - { "Anschlusspunkt", CLS_BODY, ACT_CONNECTINGPOINT, "NNN" }, - { "GeradesGleis", CLS_BODY, ACT_STRAIGHTTRACK, "NNNN" }, - { "BogenGleis", CLS_BODY, ACT_CURVEDTRACK, "NNNNN" }, - { "Gerade", CLS_BODY, ACT_STRAIGHT_BODY, "N" }, - { "Bogen", CLS_BODY, ACT_CURVE_BODY, "NNN" }, - { "Preis", CLS_BODY, ACT_PRICE, "N" } }; + { "Straight", CLS_START, ACT_STRAIGHT, "SSNN" }, + { "EndStraight", CLS_END, ACT_DONE, NULL }, + { "Curve", CLS_START, ACT_CURVE, "SSNNN" }, + { "EndCurve", CLS_END, ACT_DONE, NULL }, + { "Turnout_Left", CLS_START, ACT_TURNOUT_LEFT, "SSN" }, + { "Turnout_Right", CLS_START, ACT_TURNOUT_RIGHT, "SSN" }, + { "EndTurnout", CLS_END, ACT_DONE, NULL }, + { "CurvedTurnout_Left", CLS_START, ACT_CURVEDTURNOUT_LEFT, "SSN" }, + { "CurvedTurnout_Right", CLS_START, ACT_CURVEDTURNOUT_RIGHT, "SSN" }, + { "ThreeWayTurnout", CLS_START, ACT_THREEWAYTURNOUT, "SSN" }, + { "Crossing_Left", CLS_START, ACT_CROSSING_LEFT, "SSNNNN" }, + { "Crossing_Right", CLS_START, ACT_CROSSING_RIGHT, "SSNNNN" }, + { "DoubleSlip_Left", CLS_START, ACT_DOUBLESLIP_LEFT, "SSNNNNN" }, + { "DoubleSlip_Right", CLS_START, ACT_DOUBLESLIP_RIGHT, "SSNNNNN" }, + { "Crossing_Symetric", CLS_START, ACT_CROSSING_SYMMETRIC, "SSNNN" }, + { "DoubleSlip_Symetric", CLS_START, ACT_DOUBLESLIP_SYMMETRIC, "SSNNNN" }, + { "EndCrossing", CLS_END, ACT_DONE, NULL }, + { "Turntable", CLS_START, ACT_TURNTABLE, "SSNNNN" }, + { "EndTurntable", CLS_END, ACT_ENDTURNTABLE, NULL }, + { "TravellingPlatform", CLS_START, ACT_TRANSFERTABLE, "SSNNNNN" }, + { "EndTravellingPlatform", CLS_END, ACT_ENDTRANSFERTABLE, NULL }, + { "Track", CLS_START, ACT_TRACK, "SSN" }, + { "EndTrack", CLS_END, ACT_DONE, NULL }, + { "Structure", CLS_START, ACT_STRUCTURE, "SS" }, + { "EndStructure", CLS_END, ACT_ENDSTRUCTURE, NULL }, + + { "FillPoint", CLS_BODY, ACT_FILL_POINT, "NNI" }, + { "Line", CLS_BODY, ACT_LINE, "NNNN" }, + { "CurvedLine", CLS_BODY, ACT_CURVEDLINE, "NNNNN" }, + { "CurveLine", CLS_BODY, ACT_CURVEDLINE, "NNNNN" }, + { "Circle", CLS_BODY, ACT_CIRCLE, "NNN" }, + { "DescriptionPos", CLS_BODY, ACT_DESCRIPTIONPOS, "NN" }, + { "ArticleNoPos", CLS_BODY, ACT_DESCRIPTIONPOS, "NN" }, + { "ConnectingPoint", CLS_BODY, ACT_CONNECTINGPOINT, "NNN" }, + { "StraightTrack", CLS_BODY, ACT_STRAIGHTTRACK, "NNNN" }, + { "CurvedTrack", CLS_BODY, ACT_CURVEDTRACK, "NNNNN" }, + { "Straight", CLS_BODY, ACT_STRAIGHT_BODY, "N" }, + { "Curve", CLS_BODY, ACT_CURVE_BODY, "NNN" }, + { "Price", CLS_BODY, ACT_PRICE, "N" }, + + { "Gerade", CLS_START, ACT_STRAIGHT, "SSNN" }, + { "EndGerade", CLS_END, ACT_DONE, NULL }, + { "Bogen", CLS_START, ACT_CURVE, "SSNNN" }, + { "EndBogen", CLS_END, ACT_DONE, NULL }, + { "Weiche_links", CLS_START, ACT_TURNOUT_LEFT, "SSN" }, + { "Weiche_Rechts", CLS_START, ACT_TURNOUT_RIGHT, "SSN" }, + { "EndWeiche", CLS_END, ACT_DONE, NULL }, + { "Bogenweiche_Links", CLS_START, ACT_CURVEDTURNOUT_LEFT, "SSN" }, + { "Bogenweiche_Rechts", CLS_START, ACT_CURVEDTURNOUT_RIGHT, "SSN" }, + { "Dreiwegweiche", CLS_START, ACT_THREEWAYTURNOUT, "SSN" }, + { "Kreuzung_Links", CLS_START, ACT_CROSSING_LEFT, "SSNNNN" }, + { "Kreuzung_Rechts", CLS_START, ACT_CROSSING_RIGHT, "SSNNNN" }, + { "DKW_Links", CLS_START, ACT_DOUBLESLIP_LEFT, "SSNNNNN" }, + { "DKW_Rechts", CLS_START, ACT_DOUBLESLIP_RIGHT, "SSNNNNN" }, + { "Kreuzung_Symmetrisch", CLS_START, ACT_CROSSING_SYMMETRIC, "SSNNN" }, + { "DKW_Symmetrisch", CLS_START, ACT_DOUBLESLIP_SYMMETRIC, "SSNNNN" }, + { "EndKreuzung", CLS_END, ACT_DONE, NULL }, + { "Drehscheibe", CLS_START, ACT_TURNTABLE, "SSNNNN" }, + { "EndDrehscheibe", CLS_END, ACT_ENDTURNTABLE, NULL }, + { "Schiebebuehne", CLS_START, ACT_TRANSFERTABLE, "SSNNNNN" }, + { "EndSchiebebuehne", CLS_END, ACT_ENDTRANSFERTABLE, NULL }, + { "Schiene", CLS_START, ACT_TRACK, "SSN" }, + { "EndSchiene", CLS_END, ACT_DONE, NULL }, + { "Haus", CLS_START, ACT_STRUCTURE, "SS" }, + { "EndHaus", CLS_END, ACT_ENDSTRUCTURE, NULL }, + + { "FuellPunkt", CLS_BODY, ACT_FILL_POINT, "NNI" }, + { "Linie", CLS_BODY, ACT_LINE, "NNNN" }, + { "Bogenlinie", CLS_BODY, ACT_CURVEDLINE, "NNNNN" }, + { "Kreislinie", CLS_BODY, ACT_CIRCLE, "NNN" }, + { "BezeichnungsPos", CLS_BODY, ACT_DESCRIPTIONPOS, "NN" }, + { "ArtikelNrPos", CLS_BODY, ACT_DESCRIPTIONPOS, "NN" }, + { "Anschlusspunkt", CLS_BODY, ACT_CONNECTINGPOINT, "NNN" }, + { "GeradesGleis", CLS_BODY, ACT_STRAIGHTTRACK, "NNNN" }, + { "BogenGleis", CLS_BODY, ACT_CURVEDTRACK, "NNNNN" }, + { "Gerade", CLS_BODY, ACT_STRAIGHT_BODY, "N" }, + { "Bogen", CLS_BODY, ACT_CURVE_BODY, "NNN" }, + { "Preis", CLS_BODY, ACT_PRICE, "N" } +}; /* argument description */ typedef union { - char * string; - double number; - long integer; - } arg_t; + char * string; + double number; + long integer; +} arg_t; /* description of a curve */ typedef struct { - char type; - coOrd pos[2]; - double radius, a0, a1; - coOrd center; - } line_t; + char type; + coOrd pos[2]; + double radius, a0, a1; + coOrd center; +} line_t; /* state info for the current object */ int curAction; @@ -314,30 +315,30 @@ int right = 0; /* A XTrkCad End-Point */ typedef struct { - int busy; - coOrd pos; - double a; - } endPoint_t; + int busy; + coOrd pos; + double a; +} endPoint_t; endPoint_t endPoints[MAXSEG]; endPoint_t *endPoint_p; /* the segments */ typedef struct { - double radius; - coOrd pos[2]; - int mark; - endPoint_t * ep[2]; - } segs_t; + double radius; + coOrd pos[2]; + int mark; + endPoint_t * ep[2]; +} segs_t; segs_t segs[MAXSEG]; segs_t *seg_p; /* the segment paths */ typedef struct { - int index; - int count; - int segs[MAXSEG]; - } paths_t; + int index; + int count; + int segs[MAXSEG]; +} paths_t; paths_t paths[MAXSEG]; paths_t *paths_p; @@ -345,16 +346,18 @@ int curPath[MAXSEG]; int curPathInx; char * pathNames[] = { - "Normal", - "Reverse" }; + "Normal", + "Reverse" +}; int isclose( coOrd a, coOrd b ) { if ( fabs(a.x-b.x) < 0.1 && - fabs(a.y-b.y) < 0.1 ) + fabs(a.y-b.y) < 0.1 ) { return 1; - else + } else { return 0; + } } @@ -373,22 +376,25 @@ void searchSegs( segs_t * sp, int ep ) curPath[curPathInx] = (ep==0?-((sp-segs)+1):((sp-segs)+1)); if (sp->ep[ep] != NULL) { inx = abs(curPath[0]); - if ( (sp-segs)+1 < inx ) + if ( (sp-segs)+1 < inx ) { return; + } paths_p->index = 0; paths_p->count = curPathInx+1; - for (inx=0;inx<=curPathInx;inx++) + for (inx=0; inx<=curPathInx; inx++) { paths_p->segs[inx] = curPath[inx]; + } paths_p++; return; } curPathInx++; for ( sp1 = segs; sp1<seg_p; sp1++ ) { if (!sp1->mark) { - if ( isclose( sp->pos[ep], sp1->pos[0] ) ) + if ( isclose( sp->pos[ep], sp1->pos[0] ) ) { searchSegs( sp1, 1 ); - else if ( isclose( sp->pos[ep], sp1->pos[1] ) ) + } else if ( isclose( sp->pos[ep], sp1->pos[1] ) ) { searchSegs( sp1, 0 ); + } } } curPathInx--; @@ -424,8 +430,9 @@ void computePaths( void ) } } for ( sp = segs; sp<seg_p; sp++ ) { - for ( sp1 = segs; sp1<seg_p; sp1++ ) + for ( sp1 = segs; sp1<seg_p; sp1++ ) { sp1->mark = 0; + } curPathInx = 0; if ( sp->ep[0] ) { searchSegs( sp, 1 ); @@ -436,10 +443,11 @@ void computePaths( void ) pathIndex = 0; pathCount = paths_p-paths; while (pathCount>0) { - if (pathIndex < 2) + if (pathIndex < 2) { fprintf( fout, "\tP \"%s\"", pathNames[pathIndex] ); - else + } else { fprintf( fout, "\tP \"%d\"", pathIndex+1 ); + } pathIndex++; firstPath = 1; memset( bitmap, 0, sizeof bitmap ); @@ -447,8 +455,9 @@ void computePaths( void ) ep->busy = 0; } for (pp = paths; pp < paths_p; pp++) { - if (pp->count == 0) + if (pp->count == 0) { continue; + } segNo = pp->segs[0]; epNo = (segNo>0?0:1); ep = segs[abs(segNo)-1].ep[epNo]; @@ -458,12 +467,13 @@ void computePaths( void ) if ( (ep && ep->busy) || (ep2 && ep2->busy) ) { goto nextPath; } - if (ep) ep->busy = 1; - if (ep2) ep2->busy = 1; + if (ep) { ep->busy = 1; } + if (ep2) { ep2->busy = 1; } for (inx=0; inx<pp->count; inx++) { segNo = abs(pp->segs[inx]); - if (bitmap[segNo]) + if (bitmap[segNo]) { goto nextPath; + } } if (!firstPath) { fprintf( fout, " 0"); @@ -478,7 +488,7 @@ void computePaths( void ) pp->count = 0; pathCount--; nextPath: - ; + ; } fprintf( fout, "\n" ); } @@ -492,7 +502,8 @@ void translate( coOrd *res, coOrd orig, double a, double d ) } -static void computeCurve( coOrd pos0, coOrd pos1, double radius, coOrd * center, double * a0, double * a1 ) +static void computeCurve( coOrd pos0, coOrd pos1, double radius, coOrd * center, + double * a0, double * a1 ) /* translate between curves described by 2 end-points and a radius to a curve described by a center, radius and angles. */ @@ -502,8 +513,9 @@ static void computeCurve( coOrd pos0, coOrd pos1, double radius, coOrd * center, d = findDistance( pos0, pos1 )/2.0; a = findAngle( pos0, pos1 ); s = fabs(d/radius); - if (s > 1.0) + if (s > 1.0) { s = 1.0; + } aa = R2D(asin( s )); if (radius > 0) { aaa = a + (90.0 - aa); @@ -520,10 +532,11 @@ static void computeCurve( coOrd pos0, coOrd pos1, double radius, coOrd * center, double X( double v ) { - if ( -0.000001 < v && v < 0.000001 ) + if ( -0.000001 < v && v < 0.000001 ) { return 0.0; - else + } else { return v; + } } @@ -542,27 +555,27 @@ void generateTurnout( void ) computePaths(); for (ep=endPoints; ep<endPoint_p; ep++) fprintf( fout, "\tE %0.6f %0.6f %0.6f\n", - X(ep->pos.x), X(ep->pos.y), X(ep->a) ); + X(ep->pos.x), X(ep->pos.y), X(ep->a) ); for (lp=lines; lp<line_p; lp++) { switch (lp->type) { case 'L': fprintf( fout, "\tL %ld 0 %0.6f %0.6f %0.6f %0.6f\n", color, - X(lp->pos[0].x), X(lp->pos[0].y), X(lp->pos[1].x), X(lp->pos[1].y) ); + X(lp->pos[0].x), X(lp->pos[0].y), X(lp->pos[1].x), X(lp->pos[1].y) ); break; case 'A': fprintf( fout, "\tA %ld 0 %0.6f %0.6f %0.6f %0.6f %0.6f\n", color, - X(lp->radius), X(lp->center.x), X(lp->center.y), X(lp->a0), X(lp->a1) ); + X(lp->radius), X(lp->center.x), X(lp->center.y), X(lp->a0), X(lp->a1) ); break; } } for (sp=segs; sp<seg_p; sp++) if (sp->radius == 0.0) { fprintf( fout, "\tS 0 0 %0.6f %0.6f %0.6f %0.6f\n", - X(sp->pos[0].x), X(sp->pos[0].y), X(sp->pos[1].x), X(sp->pos[1].y) ); + X(sp->pos[0].x), X(sp->pos[0].y), X(sp->pos[1].x), X(sp->pos[1].y) ); } else { computeCurve( sp->pos[0], sp->pos[1], sp->radius, ¢er, &a0, &a1 ); fprintf( fout, "\tC 0 0 %0.6f %0.6f %0.6f %0.6f %0.6f\n", - X(sp->radius), X(center.x), X(center.y), X(a0), X(a1) ); + X(sp->radius), X(center.x), X(center.y), X(a0), X(a1) ); } fprintf( fout, "\t%s\n", END_SEGS ); } @@ -572,23 +585,25 @@ void reset( tokenDesc_t * tp, arg_t *args ) /* Start of a new turnout or structure */ { int inx; - curAction = tp->action; - line_p = lines; - seg_p = segs; - endPoint_p = endPoints; - partNo = strdup( args[0].string ); - name = strdup( args[1].string ); - for (inx=2; tp->args[inx]; inx++) - params[inx-2] = args[inx].number; + curAction = tp->action; + line_p = lines; + seg_p = segs; + endPoint_p = endPoints; + partNo = strdup( args[0].string ); + name = strdup( args[1].string ); + for (inx=2; tp->args[inx]; inx++) { + params[inx-2] = args[inx].number; + } } double getDim( double value ) /* convert to inches from tenths of a an inch or millimeters. */ { - if (inch) + if (inch) { return value/10.0; - else + } else { return value/25.4; + } } @@ -597,8 +612,9 @@ char * getLine( void ) { char * cp; while (1) { - if (fgets(line, sizeof line, fin) == NULL) + if (fgets(line, sizeof line, fin) == NULL) { return NULL; + } lineCount++; lineLen = strlen(line); if (lineLen > 0 && line[lineLen-1] == '\n') { @@ -619,10 +635,12 @@ char * getLine( void ) cp++; lineLen--; } - if (lineLen <= 0) + if (lineLen <= 0) { continue; - if (verbose) + } + if (verbose) { fprintf( fout, "# %s\n", line ); + } return cp; } } @@ -633,8 +651,9 @@ void flushInput( void ) { char *cp; while (cp=getLine()) { - if (strncasecmp( cp, "End", 3 ) == 0 ) + if (strncasecmp( cp, "End", 3 ) == 0 ) { break; + } } inBody = 0; } @@ -711,8 +730,9 @@ void process( tokenDesc_t * tp, arg_t *args ) endPoint_p->pos.x = 0.0; endPoint_p->a = 270.0; endPoint_p++; - if ((cp=getLine())==NULL) + if ((cp=getLine())==NULL) { return; + } if ((rc=sscanf( line, "%lf %lf", &radius, &angle ) ) != 2) { fprintf( stderr, "syntax error: %d: %s\n", lineCount, line ); flushInput(); @@ -728,8 +748,9 @@ void process( tokenDesc_t * tp, arg_t *args ) seg_p->radius = -radius; endPoint_p++; seg_p++; - if ((cp=getLine())==NULL) + if ((cp=getLine())==NULL) { return; + } if ((rc=sscanf( line, "%lf %lf", &radius2, &angle ) ) != 2) { fprintf( stderr, "syntax error: %d: %s\n", lineCount, line ); flushInput(); @@ -789,7 +810,7 @@ void process( tokenDesc_t * tp, arg_t *args ) seg_p++; length /= 2.0; if (tp->action == ACT_CROSSING_SYMMETRIC || - tp->action == ACT_DOUBLESLIP_SYMMETRIC) { + tp->action == ACT_DOUBLESLIP_SYMMETRIC) { length2 = length; } else { length2 = getDim( args[5].number )/2.0; @@ -805,7 +826,7 @@ void process( tokenDesc_t * tp, arg_t *args ) endPoint_p++; seg_p++; if (tp->action == ACT_CROSSING_RIGHT || - tp->action == ACT_DOUBLESLIP_RIGHT ) { + tp->action == ACT_DOUBLESLIP_RIGHT ) { endPoint_p[-1].pos.y = -endPoint_p[-1].pos.y; endPoint_p[-2].pos.y = -endPoint_p[-2].pos.y; seg_p[-1].pos[0].y = -seg_p[-1].pos[0].y; @@ -817,8 +838,9 @@ void process( tokenDesc_t * tp, arg_t *args ) case ACT_TURNTABLE: reset( tp, args ); - if ((cp=getLine())==NULL) + if ((cp=getLine())==NULL) { return; + } if ((rc=sscanf( line, "%lf %s", &angle, bits ) ) != 2) { fprintf( stderr, "syntax error: %d: %s\n", lineCount, line ); flushInput(); @@ -828,8 +850,9 @@ void process( tokenDesc_t * tp, arg_t *args ) count = 360.0/angle; angle = 0; length = strlen( bits ); - if (length < count) + if (length < count) { count = length; + } length = getDim( args[3].number ); length2 = getDim( args[5].number ); endNo = 1; @@ -843,24 +866,24 @@ void process( tokenDesc_t * tp, arg_t *args ) angle = normalizeAngle( 90.0 - inx * ( 360.0 / count ) ); if (bits[inx]!='0') fprintf( fout, "\tE %0.6f %0.6f %0.6f\n", - X(length * sin(D2R(angle))), - X(length * cos(D2R(angle))), - X(angle) ); + X(length * sin(D2R(angle))), + X(length * cos(D2R(angle))), + X(angle) ); } for ( inx=0; inx<count; inx++ ) { angle = normalizeAngle( 90.0 - inx * ( 360.0 / count ) ); if (bits[inx]!='0') fprintf( fout, "\tS 0 0 %0.6f %0.6f %0.6f %0.6f\n", - X(length * sin(D2R(angle))), - X(length * cos(D2R(angle))), - X(length2 * sin(D2R(angle))), - X(length2 * cos(D2R(angle))) ); + X(length * sin(D2R(angle))), + X(length * cos(D2R(angle))), + X(length2 * sin(D2R(angle))), + X(length2 * cos(D2R(angle))) ); } fprintf( fout, "\tA %ld 0 %0.6f 0.000000 0.000000 0.000000 360.000000\n", - color, length2 ); + color, length2 ); if (length != length2) fprintf( fout, "\tA %ld 0 %0.6f 0.000000 0.000000 0.000000 360.000000\n", - color, length ); + color, length ); break; case ACT_ENDTURNTABLE: @@ -868,11 +891,11 @@ void process( tokenDesc_t * tp, arg_t *args ) switch (lp->type) { case 'L': fprintf( fout, "\tL %ld 0 %0.6f %0.6f %0.6f %0.6f\n", color, - X(lp->pos[0].x), X(lp->pos[0].y), X(lp->pos[1].x), X(lp->pos[1].y) ); + X(lp->pos[0].x), X(lp->pos[0].y), X(lp->pos[1].x), X(lp->pos[1].y) ); break; case 'A': fprintf( fout, "\tA %ld 0 %0.6f %0.6f %0.6f %0.6f %0.6f\n", color, - X(lp->radius), X(lp->center.x), X(lp->center.y), X(lp->a0), X(lp->a1) ); + X(lp->radius), X(lp->center.x), X(lp->center.y), X(lp->a0), X(lp->a1) ); break; } } @@ -886,15 +909,18 @@ void process( tokenDesc_t * tp, arg_t *args ) width2 = getDim(args[5].number); length = getDim( args[6].number); fprintf( fout, "\tL %ld 0 0.0000000 0.000000 0.000000 %0.6f\n", color, length ); - fprintf( fout, "\tL %ld 0 0.0000000 %0.6f %0.6f %0.6f\n", color, length, width, length ); - fprintf( fout, "\tL %ld 0 %0.6f %0.6f %0.6f 0.000000\n", color, width, length, width ); + fprintf( fout, "\tL %ld 0 0.0000000 %0.6f %0.6f %0.6f\n", color, length, width, + length ); + fprintf( fout, "\tL %ld 0 %0.6f %0.6f %0.6f 0.000000\n", color, width, length, + width ); fprintf( fout, "\tL %ld 0 %0.6f 0.0000000 0.000000 0.000000\n", color, width ); fprintf( fout, "\tL %ld 0 %0.6f %0.6f %0.6f %0.6f\n", color, - (width-width2)/2.0, 0.0, (width-width2)/2.0, length ); + (width-width2)/2.0, 0.0, (width-width2)/2.0, length ); fprintf( fout, "\tL %ld 0 %0.6f %0.6f %0.6f %0.6f\n", color, - width-(width-width2)/2.0, 0.0, width-(width-width2)/2.0, length ); - if ((cp=getLine())==NULL) + width-(width-width2)/2.0, 0.0, width-(width-width2)/2.0, length ); + if ((cp=getLine())==NULL) { return; + } if ((rc=sscanf( line, "%lf %lf %s", &length2, &offset, bits ) ) != 3) { fprintf( stderr, "syntax error: %d: %s\n", lineCount, line ); flushInput(); @@ -905,14 +931,15 @@ void process( tokenDesc_t * tp, arg_t *args ) for (inx=0; bits[inx]; inx++) { if (bits[inx]=='1') { fprintf( fout, "\tE 0.000000 %0.6f 270.0\n", - offset ); + offset ); fprintf( fout, "\tS 0 0 0.000000 %0.6f %0.6f %0.6f\n", - offset, (width-width2)/2.0, offset ); + offset, (width-width2)/2.0, offset ); } offset += length2; } - if ((cp=getLine())==NULL) + if ((cp=getLine())==NULL) { return; + } if ((rc=sscanf( line, "%lf %lf %s", &length2, &offset, bits ) ) != 3) { fprintf( stderr, "syntax error: %d: %s\n", lineCount, line ); flushInput(); @@ -923,9 +950,9 @@ void process( tokenDesc_t * tp, arg_t *args ) for (inx=0; bits[inx]; inx++) { if (bits[inx]=='1') { fprintf( fout, "\tE %0.6f %0.6f 90.0\n", - width, offset ); + width, offset ); fprintf( fout, "\tS 0 0 %0.6f %0.6f %0.6f %0.6f\n", - width-(width-width2)/2.0, offset, width, offset ); + width-(width-width2)/2.0, offset, width, offset ); } offset += length2; } @@ -949,11 +976,11 @@ void process( tokenDesc_t * tp, arg_t *args ) switch (lp->type) { case 'L': fprintf( fout, "\tL %ld 0 %0.6f %0.6f %0.6f %0.6f\n", color, - X(lp->pos[0].x), X(lp->pos[0].y), X(lp->pos[1].x), X(lp->pos[1].y) ); + X(lp->pos[0].x), X(lp->pos[0].y), X(lp->pos[1].x), X(lp->pos[1].y) ); break; case 'A': fprintf( fout, "\tA %ld 0 %0.6f %0.6f %0.6f %0.6f %0.6f\n", color, - X(lp->radius), X(lp->center.x), X(lp->center.y), X(lp->a0), X(lp->a1) ); + X(lp->radius), X(lp->center.x), X(lp->center.y), X(lp->a0), X(lp->a1) ); break; } } @@ -981,7 +1008,8 @@ void process( tokenDesc_t * tp, arg_t *args ) angle = args[3].number/2.0 + args[4].number; pos1.x = pos0.x + length2*cos(D2R(angle)); pos1.y = pos0.y + length2*sin(D2R(angle)); - computeCurve( pos0, pos1, line_p->radius, &line_p->center, &line_p->a0, &line_p->a1 ); + computeCurve( pos0, pos1, line_p->radius, &line_p->center, &line_p->a0, + &line_p->a1 ); line_p++; break; @@ -1096,71 +1124,74 @@ void parse( void ) inch++; continue; } - for ( tp=tokens; tp<&tokens[COUNT( tokens )]; tp++ ){ + for ( tp=tokens; tp<&tokens[COUNT( tokens )]; tp++ ) { tlen = strlen(tp->name); - if ( strncasecmp( cp, tp->name, tlen) != 0 ) + if ( strncasecmp( cp, tp->name, tlen) != 0 ) { continue; - if ( cp[tlen] != '\0' && cp[tlen] != ' ' && cp[tlen] != ',' ) + } + if ( cp[tlen] != '\0' && cp[tlen] != ' ' && cp[tlen] != ',' ) { continue; + } if ( (inBody) == (tp->class==CLS_START) ) { continue; } cp += tlen+1; if (tp->args) - for ( inx=0, sp=strings; tp->args[inx]; inx++ ) { - if (*cp == '\0') { - fprintf( stderr, "%d: unexpected end of line\n", lineCount ); - goto nextLine; - } - switch( tp->args[inx] ) { - case 'S': - args[inx].string = sp; - while (isspace((unsigned char)*cp)) cp++; - if (*cp != '"') { - fprintf( stderr, "%d: expected a \": %s\n", lineCount, cp ); + for ( inx=0, sp=strings; tp->args[inx]; inx++ ) { + if (*cp == '\0') { + fprintf( stderr, "%d: unexpected end of line\n", lineCount ); goto nextLine; } - cp++; - while ( *cp ) { - if ( *cp != '"' ) { - *sp++ = *cp++; - } else if ( cp[1] == '"' ) { - *sp++ = '"'; - *sp++ = '"'; - cp += 2; - } else { - cp++; - *sp++ = '\0'; - break; + switch( tp->args[inx] ) { + case 'S': + args[inx].string = sp; + while (isspace((unsigned char)*cp)) { cp++; } + if (*cp != '"') { + fprintf( stderr, "%d: expected a \": %s\n", lineCount, cp ); + goto nextLine; } - } - break; + cp++; + while ( *cp ) { + if ( *cp != '"' ) { + *sp++ = *cp++; + } else if ( cp[1] == '"' ) { + *sp++ = '"'; + *sp++ = '"'; + cp += 2; + } else { + cp++; + *sp++ = '\0'; + break; + } + } + break; - case 'N': - args[inx].number = strtod( cp, &cpp ); - if (cpp == cp) { - fprintf( stderr, "%d: expected a number: %s\n", lineCount, cp ); - goto nextLine; - } - cp = cpp; - break; + case 'N': + args[inx].number = strtod( cp, &cpp ); + if (cpp == cp) { + fprintf( stderr, "%d: expected a number: %s\n", lineCount, cp ); + goto nextLine; + } + cp = cpp; + break; + + case 'I': + args[inx].integer = strtol( cp, &cpp, 10 ); + if (cpp == cp) { + fprintf( stderr, "%d: expected an integer: %s\n", lineCount, cp ); + goto nextLine; + } + cp = cpp; + break; - case 'I': - args[inx].integer = strtol( cp, &cpp, 10 ); - if (cpp == cp) { - fprintf( stderr, "%d: expected an integer: %s\n", lineCount, cp ); - goto nextLine; } - cp = cpp; - break; - } - } process( tp, args ); - if (tp->class == CLS_START) + if (tp->class == CLS_START) { inBody = 1; - else if (tp->class == CLS_END) + } else if (tp->class == CLS_END) { inBody = 0; + } tp = NULL; break; } @@ -1222,7 +1253,8 @@ int main ( int argc, char * argv[] ) perror(*argv); exit(1); } - if (contents) + if (contents) { fprintf( fout, "CONTENTS %s\n", contents ); + } parse(); } diff --git a/app/bin/bitmaps/16pix/bridge.png b/app/bin/bitmaps/16pix/bridge.png Binary files differdeleted file mode 100644 index ebcde0a..0000000 --- a/app/bin/bitmaps/16pix/bridge.png +++ /dev/null diff --git a/app/bin/bitmaps/CMakeLists.txt b/app/bin/bitmaps/CMakeLists.txt new file mode 100644 index 0000000..0a68722 --- /dev/null +++ b/app/bin/bitmaps/CMakeLists.txt @@ -0,0 +1,100 @@ +# Generate XPM bitmaps from SVG files
+
+PROJECT(genbitmaps)
+
+# Find the conversion tool
+
+find_package(Inkscape)
+
+if( NOT Inkscape_FOUND )
+ message( STATUS "Inkscape not found." )
+else()
+ message(STATUS "Inkscape is: ${Inkscape_EXECUTABLE}")
+ message(STATUS "Export option is: ${Inkscape_EXPORT}")
+
+ set (XPMS
+ background benchwork bezier-line bezier-track block bottom box
+ bridge building car-inventory change-grid circle-center
+ circle-filled-center circle-filled-tangent circle-line-center
+ circle-line-tangent circle-line circle-tangent circle clone
+ connect control convert-from convert-to copy cornu curved-chord
+ curved-end curved-line-chord curved-line-end curved-line-middle
+ curved-line-tangent curved-middle curved-tangent cut delete
+ describe description dimension doc-export-bmap doc-export-dxf
+ doc-export-svg doc-export doc-import-mod doc-import doc-new doc-open
+ doc-print doc-recent doc-revert doc-save-as doc-save doc-setup down
+ ease-broad ease-cornu ease-gt-broad ease-gt-sharp ease-lt-broad
+ ease-lt-sharp ease-none ease-normal ease-sharp
+ elevation exit extend filled-box filled-polygon go helix
+ info join-line join layers magnet manage map move
+ new-car ok pan-zoom parallel-line parallel parameter paste
+ polygon polyline profile protractor redo reflect roadbed
+ rotate ruler select sensor signal snap-curs snap-grid
+ split-draw split sticky-doc sticky-link sticky-note stop
+ straight-line straight switch-motor table-edge text ties top
+ train trim tunnel turnout-design turnout turntable undo
+ zoom-choose zoom-extent zoom-in zoom-out
+ )
+ set( PIXS 16 24 32 )
+
+ foreach(xpm ${XPMS})
+ foreach(pix ${PIXS})
+ if ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/png/${xpm}${pix}.png" )
+ # MESSAGE( STATUS "Custom ${CMAKE_CURRENT_SOURCE_DIR}/png/${xpm}${pix}.png" )
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/png/${xpm}${pix}.png
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/png/${xpm}${pix}.png
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/png/
+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/png/${xpm}${pix}.png ${CMAKE_CURRENT_BINARY_DIR}/png/${xpm}${pix}.png
+ )
+ else()
+ # MESSAGE( STATUS "SVG ${CMAKE_CURRENT_SOURCE_DIR}/svg/${xpm}.svg" )
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/png/${xpm}${pix}.png
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/svg/${xpm}.svg
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/png/
+ COMMAND ${Inkscape_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/svg/${xpm}.svg -h ${pix} ${Inkscape_EXPORT}${CMAKE_CURRENT_BINARY_DIR}/png/${xpm}${pix}.png
+ )
+ endif()
+ # build a list of all the depends
+ list(APPEND PNG_RESULTS ${CMAKE_CURRENT_BINARY_DIR}/png/${xpm}${pix}.png)
+ endforeach()
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${xpm}.xpm3
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/png/${xpm}16.png
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/png/${xpm}24.png
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/png/${xpm}32.png
+ COMMAND pngtoxpm ${CMAKE_CURRENT_BINARY_DIR}/${xpm}.xpm3
+# COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/${xpm}.xpm3 ${CMAKE_CURRENT_SOURCE_DIR}/${xpm}.xpm3
+ )
+ # build a list of all the depends
+ list(APPEND XPM_RESULTS ${xpm}.xpm3)
+ endforeach()
+
+ add_custom_target (
+ genbitmaps
+ DEPENDS ${XPM_RESULTS}
+ DEPENDS ${PNG_RESULTS}
+ )
+
+ if(WIN32)
+ # Temporarily the FreeImage dll is copied to the build directory
+ add_custom_command(
+ TARGET genbitmaps PRE_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy ${FREEIMAGE_SHAREDLIB} ${CMAKE_CURRENT_BINARY_DIR}
+ )
+ cmake_path(GET FREEIMAGE_SHAREDLIB FILENAME filename)
+ add_custom_command(
+ TARGET genbitmaps POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E rm ${CMAKE_CURRENT_BINARY_DIR}/${filename}
+ )
+#
+
+ endif()
+endif()
+
+#MESSAGE (STATUS "SVG Converter: ${SVG_CONVERTER}")
+#MESSAGE (STATUS "Source Dir: ${CMAKE_CURRENT_SOURCE_DIR}")
+#MESSAGE (STATUS "XPMs: ${XPMS}")
+#MESSAGE (STATUS "XPM_RESULTS: ${XPM_RESULTS}")
+#MESSAGE (STATUS "PNG_RESULTS: ${PNG_RESULTS}")
diff --git a/app/bin/bitmaps/Info.xpm b/app/bin/bitmaps/Info.xpm deleted file mode 100644 index c4fa897..0000000 --- a/app/bin/bitmaps/Info.xpm +++ /dev/null @@ -1,116 +0,0 @@ -static char *Info_x16[] = {
- "16 16 11 1",
- " c None",
- "0 c #000000",
- "1 c #0066FF",
- "2 c #3366FF",
- "3 c #6666FF",
- "4 c #6699FF",
- "5 c #9999FF",
- "6 c #99CCFF",
- "7 c #CCCCFF",
- "8 c #CCFFFF",
- "9 c #FFFFFF",
- " ",
- " 122221 ",
- " 25799763 ",
- " 3899999994 ",
- " 289994299993 ",
- " 15999922999973 ",
- " 27999912999992 ",
- " 29999942999992 ",
- " 29999954999992 ",
- " 27999976999992 ",
- " 26999999999972 ",
- " 299994299994 ",
- " 149997699952 ",
- " 2379999833 ",
- " 223312 ",
- " "};
-
-static char *Info_x24[] = {
- "24 24 11 1",
- " c None",
- "0 c #000000",
- "1 c #0066FF",
- "2 c #3366FF",
- "3 c #6666FF",
- "4 c #6699FF",
- "5 c #9999FF",
- "6 c #99CCFF",
- "7 c #CCCCFF",
- "8 c #CCFFFF",
- "9 c #FFFFFF",
- " ",
- " 111111 ",
- " 1111111111 ",
- " 11115777762111 ",
- " 1114999999995111 ",
- " 11799994499997211 ",
- " 116999971179999811 ",
- " 11499999611599999511 ",
- " 119999995114999999211 ",
- " 1159999996114999999611 ",
- " 1179999996114999999711 ",
- " 1179999997115999999911 ",
- " 1179999999117999999911 ",
- " 1179999999117999999811 ",
- " 1159999999529999999711 ",
- " 129999999779999999511 ",
- " 11599999711599999711 ",
- " 1179999211199999211 ",
- " 114999971149999511 ",
- " 1127999779997311 ",
- " 11157999975111 ",
- " 111111111111 ",
- " 11111111 ",
- " "};
-
-static char *Info_x32[] = {
- "32 32 11 1",
- " c None",
- "0 c #000000",
- "1 c #0066FF",
- "2 c #3366FF",
- "3 c #6666FF",
- "4 c #6699FF",
- "5 c #9999FF",
- "6 c #99CCFF",
- "7 c #CCCCFF",
- "8 c #CCFFFF",
- "9 c #FFFFFF",
- " ",
- " 11 ",
- " 111111111111 ",
- " 1111111111111111 ",
- " 111111577775211111 ",
- " 11114799999999751111 ",
- " 1111799999779999972111 ",
- " 111279999971179999994111 ",
- " 1117999999411299999992111 ",
- " 11179999999111199999997111 ",
- " 113999999971111799999994111 ",
- " 1117999999971111799999997111 ",
- " 1119999999991111799999999411 ",
- " 11499999999911117999999996111 ",
- " 11599999999911117999999997111 ",
- " 111799999999931119999999997111 ",
- " 11799999999951119999999999111 ",
- " 11699999999971149999999997111 ",
- " 11599999999971159999999997111 ",
- " 1129999999999317999999999511 ",
- " 1117999999999979999999999111 ",
- " 1114999999995114999999997111 ",
- " 11179999997111179999999211 ",
- " 11139999997111159999995111 ",
- " 111499999911117999996111 ",
- " 1114999997557999995111 ",
- " 111279999999999731111 ",
- " 111126799998731111 ",
- " 1111111111111111 ",
- " 111111111111 ",
- " 11111111 ",
- " "};
-
-static char **Info_xpm[3] = { Info_x16, Info_x24, Info_x32 };
-
diff --git a/app/bin/bitmaps/SVG/NotUsed/ease-broad.svg b/app/bin/bitmaps/SVG/NotUsed/ease-broad.svg deleted file mode 100644 index fadc6df..0000000 --- a/app/bin/bitmaps/SVG/NotUsed/ease-broad.svg +++ /dev/null @@ -1,66 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - version="1.1" - id="Layer_1" - x="0px" - y="0px" - viewBox="0 0 96 48" - style="enable-background:new 0 0 96 48;" - xml:space="preserve" - sodipodi:docname="ease-broad.svg" - inkscape:version="1.0.2-2 (e86c870879, 2021-01-15)"><metadata - id="metadata15"><rdf:RDF><cc:Work - rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs - id="defs13" /><sodipodi:namedview - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1" - objecttolerance="10" - gridtolerance="10" - guidetolerance="10" - inkscape:pageopacity="0" - inkscape:pageshadow="2" - inkscape:window-width="1555" - inkscape:window-height="828" - id="namedview11" - showgrid="false" - inkscape:zoom="7.6695312" - inkscape:cx="41.461112" - inkscape:cy="27.685221" - inkscape:window-x="166" - inkscape:window-y="170" - inkscape:window-maximized="0" - inkscape:current-layer="Layer_1" - inkscape:document-rotation="0" /> -<style - type="text/css" - id="style2"> - .st0{fill:#0090FC;stroke:#000000;stroke-width:0.5;stroke-miterlimit:10;} - .st1{font-family:'MyriadPro-Regular';} - .st2{font-size:14px;} -</style> -<text - transform="scale(1.0348781,0.96629742)" - id="text8" - x="-0.08601547" - y="19.259062" - style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:22.9881px;font-family:Calibri;-inkscape-font-specification:'Calibri, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke-width:1.03629"><tspan - x="-0.08601547" - y="19.259062" - class="st0 st1 st2" - id="tspan4" - style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:22.9881px;font-family:Calibri;-inkscape-font-specification:'Calibri, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal">Easement </tspan><tspan - x="16.575085" - y="43.812256" - class="st0 st1 st2" - id="tspan6" - style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:22.9881px;font-family:Calibri;-inkscape-font-specification:'Calibri, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal">Broad</tspan></text> -</svg> diff --git a/app/bin/bitmaps/SVG/NotUsed/ease-cornu.svg b/app/bin/bitmaps/SVG/NotUsed/ease-cornu.svg deleted file mode 100644 index df906a9..0000000 --- a/app/bin/bitmaps/SVG/NotUsed/ease-cornu.svg +++ /dev/null @@ -1,61 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - version="1.1" - id="Layer_1" - x="0px" - y="0px" - viewBox="0 0 96 48" - style="enable-background:new 0 0 96 48;" - xml:space="preserve" - sodipodi:docname="ease-cornu.svg" - inkscape:version="1.0.2-2 (e86c870879, 2021-01-15)"><metadata - id="metadata876"><rdf:RDF><cc:Work - rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs - id="defs874" /><sodipodi:namedview - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1" - objecttolerance="10" - gridtolerance="10" - guidetolerance="10" - inkscape:pageopacity="0" - inkscape:pageshadow="2" - inkscape:window-width="1398" - inkscape:window-height="732" - id="namedview872" - showgrid="false" - inkscape:zoom="3.8254353" - inkscape:cx="40.172441" - inkscape:cy="24" - inkscape:window-x="0" - inkscape:window-y="0" - inkscape:window-maximized="0" - inkscape:current-layer="Layer_1" - inkscape:document-rotation="0" /> -<style - type="text/css" - id="style859"> - .st0{fill:none;stroke:#F7931E;stroke-miterlimit:10;} - .st1{fill:#0090FC;stroke:#000000;stroke-width:0.5;stroke-miterlimit:10;} - .st2{font-family:'MyriadPro-Regular';} - .st3{font-size:14px;} - .st4{fill:none;stroke:#000000;stroke-width:0.5;stroke-miterlimit:10;} -</style> -<path - class="st0" - d="M13.2,28.5c-0.8,0.4-1.1,1.3-0.7,2.1c0.5,1,1.7,1.4,2.7,0.9c1.2-0.6,1.7-2.1,1.1-3.3c-0.8-1.5-2.6-2.1-4.2-1.4 c-1.9,1-2.7,3.3-1.7,5.2c1.2,2.4,4.1,3.3,6.5,2.1c3-1.5,4.2-5.1,2.7-8.1c-1.9-3.7-6.4-5.2-10.1-3.3c-4.7,2.3-6.5,9-4.2,13.7 c2.9,5.8,10.6,5.4,15.9,4.2c4.1-1.1,22.6-6.1,22.6-6.1l8.1-2.4c0,0,18-5.1,22.1-6.4c5.2-1.5,12.9-1.3,16.1,4.4 c2.6,4.5,1,10.3-3.5,12.9c-3.6,2.1-8.2,0.8-10.3-2.8c-1.7-2.9-0.6-6.6,2.3-8.2c2.3-1.3,5.3-0.5,6.6,1.8c1.1,1.9,0.4,4.2-1.4,5.3 c-1.5,0.8-3.4,0.3-4.2-1.2c-0.7-1.2-0.3-2.7,0.9-3.4c0.9-0.5,2.2-0.2,2.7,0.7c0.4,0.8,0.2,1.7-0.6,2.2" - id="path861" /> - -<path - class="st4" - d="M73.8,28.6" - id="path869" /> -</svg> diff --git a/app/bin/bitmaps/SVG/NotUsed/ease-gt-broad.svg b/app/bin/bitmaps/SVG/NotUsed/ease-gt-broad.svg deleted file mode 100644 index 9b2f26d..0000000 --- a/app/bin/bitmaps/SVG/NotUsed/ease-gt-broad.svg +++ /dev/null @@ -1,69 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - version="1.1" - id="Layer_1" - x="0px" - y="0px" - viewBox="0 0 96 48" - style="enable-background:new 0 0 96 48;" - xml:space="preserve" - sodipodi:docname="ease-gt-broad.svg" - inkscape:version="1.0.2-2 (e86c870879, 2021-01-15)"><metadata - id="metadata15"><rdf:RDF><cc:Work - rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs - id="defs13" /><sodipodi:namedview - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1" - objecttolerance="10" - gridtolerance="10" - guidetolerance="10" - inkscape:pageopacity="0" - inkscape:pageshadow="2" - inkscape:window-width="1561" - inkscape:window-height="828" - id="namedview11" - showgrid="false" - inkscape:zoom="7.6695312" - inkscape:cx="46.310737" - inkscape:cy="32.900664" - inkscape:window-x="219" - inkscape:window-y="132" - inkscape:window-maximized="0" - inkscape:current-layer="Layer_1" - inkscape:document-rotation="0" /> -<style - type="text/css" - id="style2"> - .st0{fill:#0090FC;stroke:#000000;stroke-width:0.5;stroke-miterlimit:10;} - .st1{font-family:'MyriadPro-Regular';} - .st2{font-size:14px;} -</style> - -<text - xml:space="preserve" - style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:21.3333px;line-height:1.25;font-family:Tahoma;-inkscape-font-specification:'Tahoma, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal" - x="8.6054811" - y="42.636246" - id="text1429"><tspan - sodipodi:role="line" - id="tspan1427" - x="8.6054811" - y="42.636246">> Broad</tspan></text><text - xml:space="preserve" - style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:21.3333px;line-height:1.25;font-family:Tahoma;-inkscape-font-specification:'Tahoma, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal" - x="1.434247" - y="20.079454" - id="text1433"><tspan - sodipodi:role="line" - id="tspan1431" - x="1.434247" - y="20.079454">Easement</tspan></text></svg> diff --git a/app/bin/bitmaps/SVG/NotUsed/ease-gt-sharp.svg b/app/bin/bitmaps/SVG/NotUsed/ease-gt-sharp.svg deleted file mode 100644 index 77031f6..0000000 --- a/app/bin/bitmaps/SVG/NotUsed/ease-gt-sharp.svg +++ /dev/null @@ -1,66 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - version="1.1" - id="Layer_1" - x="0px" - y="0px" - viewBox="0 0 96 48" - style="enable-background:new 0 0 96 48;" - xml:space="preserve" - sodipodi:docname="Easement-Sharp.svg" - inkscape:version="1.0.2-2 (e86c870879, 2021-01-15)"><metadata - id="metadata2655"><rdf:RDF><cc:Work - rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs - id="defs2653" /><sodipodi:namedview - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1" - objecttolerance="10" - gridtolerance="10" - guidetolerance="10" - inkscape:pageopacity="0" - inkscape:pageshadow="2" - inkscape:window-width="1540" - inkscape:window-height="857" - id="namedview2651" - showgrid="false" - inkscape:zoom="8.2200207" - inkscape:cx="42.464734" - inkscape:cy="24" - inkscape:window-x="0" - inkscape:window-y="0" - inkscape:window-maximized="0" - inkscape:current-layer="Layer_1" - inkscape:document-rotation="0" /> -<style - type="text/css" - id="style2642"> - .st0{fill:#0090FC;stroke:#000000;stroke-width:0.5;stroke-miterlimit:10;} - .st1{font-family:'MyriadPro-Regular';} - .st2{font-size:14px;} -</style> -<text - transform="scale(1.1867603,0.84263014)" - id="text2648" - style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:Calibri;-inkscape-font-specification:'Calibri, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke-width:1.18676" - x="3.2132704" - y="23.310022"><tspan - x="3.2132704" - y="23.310022" - class="st0 st1 st2" - id="tspan2644" - style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:Calibri;-inkscape-font-specification:'Calibri, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal">Easement </tspan><tspan - x="17.098368" - y="43.247597" - class="st0 st1 st2" - id="tspan2646" - style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:Calibri;-inkscape-font-specification:'Calibri, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal">Sharp</tspan></text> -</svg> diff --git a/app/bin/bitmaps/SVG/NotUsed/ease-lt-broad.svg b/app/bin/bitmaps/SVG/NotUsed/ease-lt-broad.svg deleted file mode 100644 index 3022616..0000000 --- a/app/bin/bitmaps/SVG/NotUsed/ease-lt-broad.svg +++ /dev/null @@ -1,67 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - version="1.1" - id="Layer_1" - x="0px" - y="0px" - viewBox="0 0 96 48" - style="enable-background:new 0 0 96 48;" - xml:space="preserve" - sodipodi:docname="ease-lt-broad.svg" - inkscape:version="1.0.2-2 (e86c870879, 2021-01-15)"><metadata - id="metadata15"><rdf:RDF><cc:Work - rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><defs - id="defs13" /><sodipodi:namedview - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1" - objecttolerance="10" - gridtolerance="10" - guidetolerance="10" - inkscape:pageopacity="0" - inkscape:pageshadow="2" - inkscape:window-width="1557" - inkscape:window-height="828" - id="namedview11" - showgrid="false" - inkscape:zoom="8.5185912" - inkscape:cx="47.999985" - inkscape:cy="23.061186" - inkscape:window-x="219" - inkscape:window-y="132" - inkscape:window-maximized="0" - inkscape:current-layer="Layer_1" - inkscape:document-rotation="0" /> -<style - type="text/css" - id="style2"> - .st0{fill:#0090FC;stroke:#000000;stroke-width:0.5;stroke-miterlimit:10;} - .st1{font-family:'MyriadPro-Regular';} - .st2{font-size:14px;} -</style> - -<text - xml:space="preserve" - style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:17.4906px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:sans-serif;stroke:none;stroke-width:1.09316;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - x="8.7710075" - y="16.856054" - id="text848" - transform="scale(0.91477909,1.0931601)"><tspan - sodipodi:role="line" - id="tspan846" - x="8.7710075" - y="16.856054" - style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:sans-serif;-inkscape-font-specification:sans-serif;stroke-width:1.09316">Easement</tspan><tspan - sodipodi:role="line" - x="8.7710075" - y="38.719307" - id="tspan850" - style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:sans-serif;-inkscape-font-specification:sans-serif;stroke-width:1.09316"> < Broad</tspan></text></svg> diff --git a/app/bin/bitmaps/SVG/NotUsed/ease-lt-sharp.svg b/app/bin/bitmaps/SVG/NotUsed/ease-lt-sharp.svg deleted file mode 100644 index 77031f6..0000000 --- a/app/bin/bitmaps/SVG/NotUsed/ease-lt-sharp.svg +++ /dev/null @@ -1,66 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - version="1.1" - id="Layer_1" - x="0px" - y="0px" - viewBox="0 0 96 48" - style="enable-background:new 0 0 96 48;" - xml:space="preserve" - sodipodi:docname="Easement-Sharp.svg" - inkscape:version="1.0.2-2 (e86c870879, 2021-01-15)"><metadata - id="metadata2655"><rdf:RDF><cc:Work - rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs - id="defs2653" /><sodipodi:namedview - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1" - objecttolerance="10" - gridtolerance="10" - guidetolerance="10" - inkscape:pageopacity="0" - inkscape:pageshadow="2" - inkscape:window-width="1540" - inkscape:window-height="857" - id="namedview2651" - showgrid="false" - inkscape:zoom="8.2200207" - inkscape:cx="42.464734" - inkscape:cy="24" - inkscape:window-x="0" - inkscape:window-y="0" - inkscape:window-maximized="0" - inkscape:current-layer="Layer_1" - inkscape:document-rotation="0" /> -<style - type="text/css" - id="style2642"> - .st0{fill:#0090FC;stroke:#000000;stroke-width:0.5;stroke-miterlimit:10;} - .st1{font-family:'MyriadPro-Regular';} - .st2{font-size:14px;} -</style> -<text - transform="scale(1.1867603,0.84263014)" - id="text2648" - style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:Calibri;-inkscape-font-specification:'Calibri, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke-width:1.18676" - x="3.2132704" - y="23.310022"><tspan - x="3.2132704" - y="23.310022" - class="st0 st1 st2" - id="tspan2644" - style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:Calibri;-inkscape-font-specification:'Calibri, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal">Easement </tspan><tspan - x="17.098368" - y="43.247597" - class="st0 st1 st2" - id="tspan2646" - style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:Calibri;-inkscape-font-specification:'Calibri, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal">Sharp</tspan></text> -</svg> diff --git a/app/bin/bitmaps/SVG/NotUsed/ease-none.svg b/app/bin/bitmaps/SVG/NotUsed/ease-none.svg deleted file mode 100644 index 75fa776..0000000 --- a/app/bin/bitmaps/SVG/NotUsed/ease-none.svg +++ /dev/null @@ -1,66 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - version="1.1" - id="Layer_1" - x="0px" - y="0px" - viewBox="0 0 96 48" - style="enable-background:new 0 0 96 48;" - xml:space="preserve" - sodipodi:docname="Easement-None.svg" - inkscape:version="1.0.2-2 (e86c870879, 2021-01-15)"><metadata - id="metadata1473"><rdf:RDF><cc:Work - rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs - id="defs1471" /><sodipodi:namedview - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1" - objecttolerance="10" - gridtolerance="10" - guidetolerance="10" - inkscape:pageopacity="0" - inkscape:pageshadow="2" - inkscape:window-width="1600" - inkscape:window-height="784" - id="namedview1469" - showgrid="false" - inkscape:zoom="8.2200207" - inkscape:cx="48" - inkscape:cy="27.685221" - inkscape:window-x="0" - inkscape:window-y="0" - inkscape:window-maximized="0" - inkscape:current-layer="Layer_1" - inkscape:document-rotation="0" /> -<style - type="text/css" - id="style1460"> - .st0{fill:#0090FC;stroke:#000000;stroke-width:0.5;stroke-miterlimit:10;} - .st1{font-family:'MyriadPro-Regular';} - .st2{font-size:14px;} -</style> -<text - transform="scale(1.1867603,0.84263015)" - id="text1466" - x="4.3408761" - y="24.176271" - style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;font-family:Arial;-inkscape-font-specification:Arial;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke-width:1.18676"><tspan - x="4.3408761" - y="24.176271" - class="st0 st1 st2" - id="tspan1462" - style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;font-family:Arial;-inkscape-font-specification:Arial;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal">Easement </tspan><tspan - x="19.531406" - y="44.113842" - class="st0 st1 st2" - id="tspan1464" - style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;font-family:Arial;-inkscape-font-specification:Arial;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal">None</tspan></text> -</svg> diff --git a/app/bin/bitmaps/SVG/NotUsed/ease-normal.svg b/app/bin/bitmaps/SVG/NotUsed/ease-normal.svg deleted file mode 100644 index 3e94707..0000000 --- a/app/bin/bitmaps/SVG/NotUsed/ease-normal.svg +++ /dev/null @@ -1,66 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - version="1.1" - id="Layer_1" - x="0px" - y="0px" - viewBox="0 0 96 48" - style="enable-background:new 0 0 96 48;" - xml:space="preserve" - sodipodi:docname="Easement-Normal.svg" - inkscape:version="1.0.2-2 (e86c870879, 2021-01-15)"><metadata - id="metadata2064"><rdf:RDF><cc:Work - rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs - id="defs2062" /><sodipodi:namedview - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1" - objecttolerance="10" - gridtolerance="10" - guidetolerance="10" - inkscape:pageopacity="0" - inkscape:pageshadow="2" - inkscape:window-width="1538" - inkscape:window-height="857" - id="namedview2060" - showgrid="false" - inkscape:zoom="7.6695312" - inkscape:cx="42.464734" - inkscape:cy="24" - inkscape:window-x="0" - inkscape:window-y="0" - inkscape:window-maximized="0" - inkscape:current-layer="Layer_1" - inkscape:document-rotation="0" /> -<style - type="text/css" - id="style2051"> - .st0{fill:#0090FC;stroke:#000000;stroke-width:0.5;stroke-miterlimit:10;} - .st1{font-family:'MyriadPro-Regular';} - .st2{font-size:14px;} -</style> -<text - transform="scale(1.1867603,0.84263014)" - id="text2057" - style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:Calibri;-inkscape-font-specification:'Calibri, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke-width:1.18676" - x="2.7634513" - y="24.342073"><tspan - x="2.7634513" - y="24.342073" - class="st0 st1 st2" - id="tspan2053" - style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:Calibri;-inkscape-font-specification:'Calibri, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal">Easement </tspan><tspan - x="11.070774" - y="44.27964" - class="st0 st1 st2" - id="tspan2055" - style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:Calibri;-inkscape-font-specification:'Calibri, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal">Normal</tspan></text> -</svg> diff --git a/app/bin/bitmaps/SVG/NotUsed/ease-sharp.svg b/app/bin/bitmaps/SVG/NotUsed/ease-sharp.svg deleted file mode 100644 index 77031f6..0000000 --- a/app/bin/bitmaps/SVG/NotUsed/ease-sharp.svg +++ /dev/null @@ -1,66 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - version="1.1" - id="Layer_1" - x="0px" - y="0px" - viewBox="0 0 96 48" - style="enable-background:new 0 0 96 48;" - xml:space="preserve" - sodipodi:docname="Easement-Sharp.svg" - inkscape:version="1.0.2-2 (e86c870879, 2021-01-15)"><metadata - id="metadata2655"><rdf:RDF><cc:Work - rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs - id="defs2653" /><sodipodi:namedview - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1" - objecttolerance="10" - gridtolerance="10" - guidetolerance="10" - inkscape:pageopacity="0" - inkscape:pageshadow="2" - inkscape:window-width="1540" - inkscape:window-height="857" - id="namedview2651" - showgrid="false" - inkscape:zoom="8.2200207" - inkscape:cx="42.464734" - inkscape:cy="24" - inkscape:window-x="0" - inkscape:window-y="0" - inkscape:window-maximized="0" - inkscape:current-layer="Layer_1" - inkscape:document-rotation="0" /> -<style - type="text/css" - id="style2642"> - .st0{fill:#0090FC;stroke:#000000;stroke-width:0.5;stroke-miterlimit:10;} - .st1{font-family:'MyriadPro-Regular';} - .st2{font-size:14px;} -</style> -<text - transform="scale(1.1867603,0.84263014)" - id="text2648" - style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:Calibri;-inkscape-font-specification:'Calibri, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke-width:1.18676" - x="3.2132704" - y="23.310022"><tspan - x="3.2132704" - y="23.310022" - class="st0 st1 st2" - id="tspan2644" - style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:Calibri;-inkscape-font-specification:'Calibri, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal">Easement </tspan><tspan - x="17.098368" - y="43.247597" - class="st0 st1 st2" - id="tspan2646" - style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:Calibri;-inkscape-font-specification:'Calibri, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal">Sharp</tspan></text> -</svg> diff --git a/app/bin/bitmaps/background.xpm b/app/bin/bitmaps/background.xpm deleted file mode 100644 index 2e8a141..0000000 --- a/app/bin/bitmaps/background.xpm +++ /dev/null @@ -1,157 +0,0 @@ -static char *background_x16[] = {
- "16 16 23 1",
- " c None",
- "0 c #000000",
- "1 c #003300",
- "2 c #333300",
- "3 c #333333",
- "4 c #336666",
- "5 c #336699",
- "6 c #339933",
- "7 c #339966",
- "8 c #33CC33",
- "9 c #669966",
- "A c #66CC66",
- "B c #66CCFF",
- "C c #999966",
- "D c #999999",
- "E c #99CC66",
- "F c #99CC99",
- "G c #99CCCC",
- "H c #CC9999",
- "I c #CCCC99",
- "J c #FFCC99",
- "K c #FFCCCC",
- "L c #C0C0C0",
- "3333333333333333",
- "5BBBBBBBBDCCCCC0",
- "5BBBBBBBBHC69HH0",
- "5BBBBBBBBH966CH0",
- "5BBBBBBBFED99HH0",
- "5BBBBBGD88AHHHH0",
- "5BBGLHHD88AIHHH0",
- "5BGDCHHHIEIIIIH0",
- "4GH77CHIIIIIIII0",
- "2HH77CIIIJKKIII0",
- "2HHDCFIIKKKKIIH0",
- "2HHHE88EKKKJIIH0",
- "2C9CE88EIKJIIIH0",
- "2666CAAIIIIIIHH0",
- "2969HHHHIIIHHHH0",
- "2011000000000000"};
-
-static char *background_x24[] = {
- "24 24 23 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333333",
- "3 c #339933",
- "4 c #339966",
- "5 c #33CC33",
- "6 c #666666",
- "7 c #669966",
- "8 c #6699CC",
- "9 c #66CC66",
- "A c #66CCFF",
- "B c #996666",
- "C c #999966",
- "D c #999999",
- "E c #99CC66",
- "F c #99CC99",
- "G c #99CCCC",
- "H c #CC9999",
- "I c #CCCC99",
- "J c #FFCC99",
- "K c #FFCCCC",
- "L c #C0C0C0",
- " 0000000000000000000000 ",
- "28888888888888BBBBBBBB62",
- "2AAAAAAAAAAAAAHHHHCHHHC2",
- "2AAAAAAAAAAAAGHH733CHHC2",
- "2AAAAAAAAAAAALH73337HHC2",
- "2AAAAAAAAAAAAHHC3333HHC2",
- "2AAAAAAAAAAAFDEH733CHHC2",
- "2AAAAAAAAAGH9559HDHHHHC2",
- "2AAAAAAAAGHE5555HHHHHHC2",
- "2AAAAAGHHHHE5555IIHHHHC2",
- "2AAAGHHHHHHHE55IIIIIHHC2",
- "2AAGH77HHHHIIIIIIIIIIHC2",
- "2AGH7444HHIIIIIIIIIIIIC2",
- "2CHH7444HHIIIIIKKKIIIIC2",
- "2CHHC447HIIIIJKKKKIIIIC2",
- "2CHHHCCCHIIIJKKKKKIIIIC2",
- "2CHHHHHE55EIKKKKKJIIIHC2",
- "2CHHHHE5555IKKKKKIIIIHC2",
- "2CC73HH5555IIKKKIIIIHHC2",
- "2C3333C9559IIIIIIIIIHHC2",
- "2C3333CH9EIIIIIIIIIHHHC2",
- "2C3337DHHHHIIIIIIHHHHHC2",
- "2BC77CCCCCCCCCCCCCCCCCC2",
- "122222222222222222222222"};
-
-static char *background_x32[] = {
- "32 32 28 1",
- " c None",
- "0 c #000000",
- "1 c #333333",
- "2 c #336666",
- "3 c #339933",
- "4 c #339966",
- "5 c #33CC33",
- "6 c #33CC66",
- "7 c #663333",
- "8 c #666633",
- "9 c #666666",
- "A c #666699",
- "B c #669966",
- "C c #6699CC",
- "D c #66CC66",
- "E c #66CCFF",
- "F c #996666",
- "G c #999966",
- "H c #999999",
- "I c #99CC66",
- "J c #99CC99",
- "K c #99CCCC",
- "L c #CC9999",
- "M c #CCCC99",
- "N c #FFCC99",
- "O c #FFCCCC",
- "P c #C0C0C0",
- "Q c #808080",
- " ",
- "02AAAAAAAAAAAAAAAA97777777777710",
- "0CEEEEEEEEEEEEEEEEKLLLLLLLLLLLF0",
- "0CEEEEEEEEEEEEEEEELLLLGGGLLLLLF0",
- "0CEEEEEEEEEEEEEEEELLLG333GLLLLF0",
- "0CEEEEEEEEEEEEEEEELLG33333GLLLF0",
- "0CEEEEEEEEEEEEEEEKLLG33333GLLLF0",
- "0CEEEEEEEEEEEEEEELLLG33333BLLLF0",
- "0CEEEEEEEEEEEEEEJLLILB333BLLLLF0",
- "0CEEEEEEEEEEEEELI555ILBGGGLLLLF0",
- "0CEEEEEEEEEEEKLI55555ILLLLLLLLF0",
- "0CEEEEEEEEEEPLLD55555ILLLLLLLLF0",
- "0CEEEEEEKPLLLLLI55555DMMLLLLLLF0",
- "0CEEEELLLLLLLLLID555DMMMMMLLLLF0",
- "0CEEEKLLLLLLLLLLM6IIMMMMMMMLLLF0",
- "0CEEKLG44BLLLLLMMMMMMMMMMMMMMLF0",
- "0CEKLHB4444LLLMMMMMMMMMMMMMMMLF0",
- "0QLLLG4444BLLMMMMMMMNOOMMMMMMLF0",
- "09LLLH44444LMMMMMMMOOOOOMMMMMLF0",
- "09LLLLB444GLMMMMMMOOOOOOMMMMMLF0",
- "09LLLLL4BBLMMMMMMOOOOOOOMMMMMLF0",
- "09LLLLLLLLDD5IMMOOOOOOONMMMMLLF0",
- "09LLLLLLLI5555IMOOOOOOOMMMMMLLF0",
- "09LLLLLLL55555DMOOOOOONMMMMMLLF0",
- "09LGBBBLLD5555DMMOOOOMMMMMMLLLF0",
- "09H3333BH55555DMMMMMMMMMMMMLLLF0",
- "09333333GHD555MMMMMMMMMMMMLLLLF0",
- "09B33333GLHIMMMMMMMMMMMMMLLLLLF0",
- "09B33333GLLLLLMMMMMMMMMLLLLLLLF0",
- "09LG333GLLLLLLLLLLLLLLLLLLLLLLF0",
- "07FFBFFFFFFFFFFFFFFFFFFFFFFFFF80",
- " 000000000000000000000000000000 "};
-
-static char **background_xpm[3] = { background_x16, background_x24, background_x32 };
-
diff --git a/app/bin/bitmaps/benchwork.xpm b/app/bin/bitmaps/benchwork.xpm deleted file mode 100644 index a94b1fa..0000000 --- a/app/bin/bitmaps/benchwork.xpm +++ /dev/null @@ -1,112 +0,0 @@ -static char *benchwork_x16[] = {
- "16 16 9 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #663300",
- "3 c #993300",
- "4 c #996600",
- "5 c #CC6600",
- "6 c #FF6600",
- "7 c #FF9900",
- " 2 3 ",
- " 126743 ",
- " 1476257 ",
- " 026752677 ",
- " 1366247777 ",
- " 00001677777 ",
- " 07772777777 ",
- " 07772777777 ",
- " 07772777777 ",
- " 07772777777 ",
- " 07772777775 ",
- " 07772777742 ",
- " 0777277622 ",
- " 07772762 ",
- " 0777252 ",
- " 000012 "};
-
-static char *benchwork_x24[] = {
- "24 24 10 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #663300",
- "4 c #993300",
- "5 c #996600",
- "6 c #CC6600",
- "7 c #FF6600",
- "8 c #FF9900",
- " ",
- " 03788843 ",
- " 147887368 ",
- " 02688863788 ",
- " 147887358888 ",
- " 01688863788888 ",
- " 137887447888888 ",
- " 0000003688888888 ",
- " 0888807888888888 ",
- " 0888808888888888 ",
- " 0888808888888888 ",
- " 0888808888888888 ",
- " 0888808888888888 ",
- " 0888808888888888 ",
- " 0888808888888888 ",
- " 0888808888888886 ",
- " 0888808888888743 ",
- " 088880888888733 ",
- " 0888808888863 ",
- " 088880888853 ",
- " 08888088733 ",
- " 088880873 ",
- " 08888053 ",
- " 0000001 "};
-
-static char *benchwork_x32[] = {
- "32 32 10 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #663300",
- "4 c #993300",
- "5 c #996600",
- "6 c #CC6600",
- "7 c #FF6600",
- "8 c #FF9900",
- " ",
- " 027888874 ",
- " 3478888736 ",
- " 026888885378 ",
- " 1478888736888 ",
- " 16888886378888 ",
- " 1378888734888888 ",
- " 16888886268888888 ",
- " 0378888743788888888 ",
- " 16888887368888888888 ",
- " 000000001788888888888 ",
- " 088888884888888888888 ",
- " 088888884888888888888 ",
- " 088888884888888888888 ",
- " 088888884888888888888 ",
- " 088888884888888888888 ",
- " 088888884888888888888 ",
- " 088888884888888888888 ",
- " 088888884888888888888 ",
- " 088888884888888888888 ",
- " 088888884888888888888 ",
- " 088888884888888888873 ",
- " 08888888488888888863 ",
- " 0888888848888888863 ",
- " 088888884888888743 ",
- " 08888888488888733 ",
- " 088888884888863 ",
- " 08888888488853 ",
- " 0888888848733 ",
- " 08888888463 ",
- " 0000000033 ",
- " 0 "};
-
-static char **benchwork_xpm[3] = { benchwork_x16, benchwork_x24, benchwork_x32 };
-
diff --git a/app/bin/bitmaps/bezier-line.xpm b/app/bin/bitmaps/bezier-line.xpm deleted file mode 100644 index 2aea754..0000000 --- a/app/bin/bitmaps/bezier-line.xpm +++ /dev/null @@ -1,98 +0,0 @@ -static char *bezier_line_x16[] = {
- "16 16 5 1",
- " c None",
- "0 c #000000",
- "1 c #990000",
- "2 c #CC0000",
- "3 c #800000",
- " 2 ",
- " 2222222222221",
- " 22222222221111",
- " 22 00 ",
- " 00 ",
- " 0 ",
- " 0 ",
- " 00 ",
- " 0 ",
- " 00 ",
- " 0 ",
- " 0 ",
- " 00 2 ",
- " 13331 2222 ",
- "12222222222 2 ",
- " 222 "};
-
-static char *bezier_line_x24[] = {
- "24 24 4 1",
- " c None",
- "0 c #000000",
- "1 c #990000",
- "2 c #CC0000",
- " ",
- " 222 ",
- " 22 2222222222222221 ",
- " 2 2222222222221111 ",
- " 2222 00 ",
- " 0 ",
- " 0 ",
- " 00 ",
- " 00 ",
- " 0 ",
- " 00 ",
- " 0 ",
- " 00 ",
- " 0 ",
- " 0 ",
- " 00 ",
- " 0 ",
- " 0 ",
- " 0 ",
- " 00 2222 ",
- " 000 22 2 ",
- " 222222222222222 2 ",
- " 2222 ",
- " 22 "};
-
-static char *bezier_line_x32[] = {
- "32 32 6 1",
- " c None",
- "0 c #000000",
- "1 c #660000",
- "2 c #990000",
- "3 c #CC0000",
- "4 c #800000",
- " ",
- " 33333 ",
- " 3333333 ",
- " 33 333333333333333333332 ",
- " 33 333333333333333333334 ",
- " 3333333 0000 ",
- " 33333 0000 ",
- " 00 ",
- " 00 ",
- " 000 ",
- " 000 ",
- " 00 ",
- " 000 ",
- " 00 ",
- " 000 ",
- " 00 ",
- " 00 ",
- " 000 ",
- " 00 ",
- " 000 ",
- " 00 ",
- " 00 ",
- " 000 ",
- " 000 ",
- " 000 ",
- " 000 3333 ",
- " 0000 333333 ",
- " 24441142 33333333 33 ",
- " 23333333333333333333 33 ",
- " 233333 333 333 ",
- " 33333 ",
- " 333 "};
-
-static char **bezier_line_xpm[3] = { bezier_line_x16, bezier_line_x24, bezier_line_x32 };
-
diff --git a/app/bin/bitmaps/bezier-track.xpm b/app/bin/bitmaps/bezier-track.xpm deleted file mode 100644 index a8b7d92..0000000 --- a/app/bin/bitmaps/bezier-track.xpm +++ /dev/null @@ -1,130 +0,0 @@ -static char *bezier_track_x16[] = {
- "16 16 9 1",
- " c None",
- "0 c #000000",
- "1 c #996666",
- "2 c #999999",
- "3 c #CC0000",
- "4 c #CC6666",
- "5 c #CC9966",
- "6 c #FFCCCC",
- "7 c #808080",
- " ",
- " 434 200",
- " 3 33333333333",
- " 434 07 5 5",
- " 0 5 700",
- " 05 602 ",
- " 06 50 ",
- " 06160 ",
- " 05 60 ",
- " 06 50 ",
- " 206160 ",
- "0075 60 ",
- " 5 570 434 ",
- "3333333333 3 ",
- "002 434 ",
- " "};
-
-static char *bezier_track_x24[] = {
- "24 24 18 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #333333",
- "4 c #663333",
- "5 c #666633",
- "6 c #990000",
- "7 c #993300",
- "8 c #996633",
- "9 c #999933",
- "A c #999966",
- "B c #CC0000",
- "C c #CC3300",
- "D c #CC3333",
- "E c #CC6633",
- "F c #CC9966",
- "G c #CCCC66",
- " ",
- " FF ",
- " BBBB G 00000",
- " BB BBBBBBBBBBD76BEEB",
- " BB BBBBBBBBB66ECBEEB",
- " BBBB GF0 FF0100",
- " 4F 244 G ",
- " 0 GF20FF ",
- " G4 2F ",
- " 18G 00 ",
- " 0 A5 ",
- " F48 0F ",
- " 05GG10 ",
- " F50 A5 ",
- " A5F 0 F ",
- " F 0 GG20 ",
- " 854 58G ",
- " G G808G 00 ",
- " 9218 F0 BB ",
- "084 GF 02F BBBB ",
- "BBBBBBBBBBBBBBBBB B ",
- "083008 BBBB ",
- "088 FF BBB ",
- " G "};
-
-static char *bezier_track_x32[] = {
- "32 32 20 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #333333",
- "4 c #663333",
- "5 c #666633",
- "6 c #990000",
- "7 c #993300",
- "8 c #996633",
- "9 c #999933",
- "A c #999966",
- "B c #CC0000",
- "C c #CC3300",
- "D c #CC3333",
- "E c #CC6633",
- "F c #CC9933",
- "G c #CC9966",
- "H c #CCCC66",
- "I c #800000",
- " ",
- " HH ",
- " BBB AG80",
- " BBBBBB H 0002540",
- " BBB BBBBBBBBBBBBBCE76BBEFE ",
- " BB BBBBBBBBBBBBBBBBBBBBBBB",
- " BBB BBB EDBI6CGGC EGE ",
- " BBBBB HG2 GH800340",
- " BBB G5GH 484 HH ",
- " 0GHHG00AH ",
- " H 0 H95 ",
- " H88 35H ",
- " 85HH 0 ",
- " 0 HHG3 ",
- " HH2 H5GH ",
- " HA8H 02H ",
- " 2GHHG0 ",
- " 0 HH8A ",
- " H84 45HH ",
- " 88HH 0 ",
- " 0 HHH10 ",
- " HG2 HG8H ",
- " H 85GH 2GH ",
- " HG20GHHH 0 ",
- " HG0448 HG2 BBB ",
- "00400GH 85GH BBBBB ",
- " EFBBEFEB66DEEBBBBBBBBB BBB ",
- " BBBBBBBBBBBBBBBBBBBBB BB ",
- " EG7III8E BBB BBB ",
- "04520 HH BBBBB ",
- " HH BB ",
- " "};
-
-static char **bezier_track_xpm[3] = { bezier_track_x16, bezier_track_x24, bezier_track_x32 };
-
diff --git a/app/bin/bitmaps/block.xpm b/app/bin/bitmaps/block.xpm deleted file mode 100644 index e3a6937..0000000 --- a/app/bin/bitmaps/block.xpm +++ /dev/null @@ -1,138 +0,0 @@ -static char *block_x16[] = {
- "16 16 18 1",
- " c None",
- "0 c #000000",
- "1 c #003300",
- "2 c #003333",
- "3 c #006600",
- "4 c #006666",
- "5 c #009900",
- "6 c #009999",
- "7 c #00CC00",
- "8 c #00FF00",
- "9 c #330000",
- "A c #660000",
- "B c #990000",
- "C c #990033",
- "D c #CC0033",
- "E c #FF0033",
- "F c #008000",
- "G c #008080",
- " ",
- " 0 ",
- " 0 1111 ",
- " 0 6 1577F1 ",
- " G6 088880 ",
- " 66 188881 ",
- " 6 66 178871 ",
- " 66 1FF3 ",
- " 099966 00 ",
- " 0ADDB966 66 ",
- " 9DEEE9 6666 ",
- " 9EEEE9 66 ",
- " 9CEED9 6640 ",
- " 99A9 6 0 ",
- " 0 ",
- " 0"};
-
-static char *block_x24[] = {
- "24 24 18 1",
- " c None",
- "0 c #000000",
- "1 c #003300",
- "2 c #006600",
- "3 c #006666",
- "4 c #009900",
- "5 c #009999",
- "6 c #00CC00",
- "7 c #00FF00",
- "8 c #330000",
- "9 c #660000",
- "A c #990000",
- "B c #990033",
- "C c #CC0033",
- "D c #FF0033",
- "E c #800000",
- "F c #008000",
- "G c #008080",
- " ",
- " 00 ",
- " 000 ",
- " 000 110 ",
- " 000 5 1266421 ",
- " 000 555 2777772 ",
- " 03555 167777761 ",
- " 555 177777761 ",
- " 55555 177777761 ",
- " 555 555 167777741 ",
- " 5 555 2677761 ",
- " 555 12F21 ",
- " 080 555 ",
- " 8BCC98 555 ",
- " 8DDDDD9 555 55 ",
- " 0BDDDDDC8 555555 ",
- " 8CDDDDDC8 5555 ",
- " 8CDDDDDC8 55G0 ",
- " 9DDDDDA8 555000 ",
- " 9ECDDB9 55 000 ",
- " 08088 000 ",
- " 000 ",
- " 000",
- " 0 "};
-
-static char *block_x32[] = {
- "32 32 19 1",
- " c None",
- "0 c #000000",
- "1 c #003300",
- "2 c #003333",
- "3 c #006600",
- "4 c #006666",
- "5 c #009900",
- "6 c #009999",
- "7 c #00CC00",
- "8 c #00FF00",
- "9 c #330000",
- "A c #660000",
- "B c #990000",
- "C c #990033",
- "D c #CC0033",
- "E c #FF0033",
- "F c #800000",
- "G c #008000",
- "H c #008080",
- " ",
- " 00 ",
- " 000 ",
- " 0000 ",
- " 0000 00 ",
- " 0000 6 135531 ",
- " 0000 666 137888871 ",
- " 0000 6666 1888888871 ",
- " 000H666 1588888888G ",
- " 26666 178888888850 ",
- " 66666 178888888871 ",
- " 6666666 178888888850 ",
- " 6666 6666 05888888883 ",
- " 66 6666 1788888851 ",
- " 6666 17888851 ",
- " 6666 103111 ",
- " 00 6666 ",
- " 99FBA9 6666 ",
- " 9DEEEEDA 6666 6 ",
- " 9DEEEEEED9 6666 666 ",
- " 9EEEEEEEEB0 6666 666 ",
- " 0FEEEEEEEED9 666666 ",
- " 0FEEEEEEEED9 6666 ",
- " AEEEEEEEEC0 66640 ",
- " 9DEEEEEEEA 6664000 ",
- " AEEEEEEB9 666 0000 ",
- " 9DDDDA9 6 0000 ",
- " 0999 0000 ",
- " 0000 ",
- " 000 ",
- " 00 ",
- " "};
-
-static char **block_xpm[3] = { block_x16, block_x24, block_x32 };
-
diff --git a/app/bin/bitmaps/bottom.xpm b/app/bin/bitmaps/bottom.xpm deleted file mode 100644 index dd50a6c..0000000 --- a/app/bin/bitmaps/bottom.xpm +++ /dev/null @@ -1,101 +0,0 @@ -static char *bottom_x16[] = {
- "16 16 6 1",
- " c None",
- "0 c #000000",
- "1 c #990000",
- "2 c #CC0000",
- "3 c #FF0000",
- "4 c #808080",
- " ",
- " ",
- " 000000000 ",
- " 104444444440",
- " 11204444444440",
- " 123304444444440",
- " 233304444444440",
- "1233304444444440",
- "1233304444444440",
- "1233304444444440",
- " 133304444444440",
- " 13304444444440",
- " 1104444444440",
- " 0000000000",
- " ",
- " "};
-
-static char *bottom_x24[] = {
- "24 24 6 1",
- " c None",
- "0 c #000000",
- "1 c #990000",
- "2 c #CC0000",
- "3 c #FF0000",
- "4 c #808080",
- " ",
- " ",
- " ",
- " ",
- " 000000000000000 ",
- " 111044444444444440 ",
- " 1223044444444444440 ",
- " 13333044444444444440 ",
- " 133333044444444444440 ",
- " 1333333044444444444440 ",
- " 1333333044444444444440 ",
- " 1333333044444444444440 ",
- " 2333333044444444444440 ",
- " 1333333044444444444440 ",
- " 1333333044444444444440 ",
- " 1233333044444444444440 ",
- " 123333044444444444440 ",
- " 12333044444444444440 ",
- " 1112044444444444440 ",
- " 000000000000000 ",
- " ",
- " ",
- " ",
- " "};
-
-static char *bottom_x32[] = {
- "32 32 6 1",
- " c None",
- "0 c #000000",
- "1 c #990000",
- "2 c #CC0000",
- "3 c #FF0000",
- "4 c #808080",
- " ",
- " ",
- " ",
- " ",
- " ",
- " 00000000000000000000 ",
- " 04444444444444444440 ",
- " 11104444444444444444440 ",
- " 1223304444444444444444440 ",
- " 113333304444444444444444440 ",
- " 1233333304444444444444444440 ",
- " 2333333304444444444444444440 ",
- " 13333333304444444444444444440 ",
- " 123333333304444444444444444440 ",
- " 123333333304444444444444444440 ",
- " 133333333304444444444444444440 ",
- " 133333333304444444444444444440 ",
- " 133333333304444444444444444440 ",
- " 123333333304444444444444444440 ",
- " 123333333304444444444444444440 ",
- " 13333333304444444444444444440 ",
- " 1333333304444444444444444440 ",
- " 133333304444444444444444440 ",
- " 12333304444444444444444440 ",
- " 1112204444444444444444440 ",
- " 1104444444444444444440 ",
- " 00000000000000000000 ",
- " ",
- " ",
- " ",
- " ",
- " "};
-
-static char **bottom_xpm[3] = { bottom_x16, bottom_x24, bottom_x32 };
-
diff --git a/app/bin/bitmaps/box.xpm b/app/bin/bitmaps/box.xpm deleted file mode 100644 index 610fb5a..0000000 --- a/app/bin/bitmaps/box.xpm +++ /dev/null @@ -1,93 +0,0 @@ -static char *box_x16[] = {
- "16 16 4 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #CC0000",
- " ",
- " 00000000000000 ",
- " 0 0 ",
- " 0 22220 ",
- " 0 2220 ",
- " 0 22 20 ",
- " 0 22 20 ",
- " 0 22 0 ",
- " 0 22 0 ",
- " 0 2 0 ",
- " 0 2 0 ",
- " 0 2 0 ",
- " 0 2 0 ",
- " 12 0 ",
- " 00000000000000 ",
- " "};
-
-static char *box_x24[] = {
- "24 24 3 1",
- " c None",
- "0 c #000000",
- "1 c #CC0000",
- " ",
- " ",
- " 000000000000000000000 ",
- " 0 0 ",
- " 0 1111111 0 ",
- " 0 111111 0 ",
- " 0 1111 0 ",
- " 0 11 11 0 ",
- " 0 11 11 0 ",
- " 0 11 11 0 ",
- " 0 11 0 ",
- " 0 11 0 ",
- " 0 11 0 ",
- " 0 1 0 ",
- " 0 1 0 ",
- " 0 1 0 ",
- " 0 1 0 ",
- " 0 11 0 ",
- " 0 11 0 ",
- " 0 11 0 ",
- " 0 0 ",
- " 0000000000000000000000 ",
- " ",
- " "};
-
-static char *box_x32[] = {
- "32 32 3 1",
- " c None",
- "0 c #000000",
- "1 c #CC0000",
- " ",
- " ",
- " ",
- " 0000000000000000000000000000 ",
- " 0 0 ",
- " 0 11111111 0 ",
- " 0 111111111 0 ",
- " 0 11111 0 ",
- " 0 111111 0 ",
- " 0 1111111 0 ",
- " 0 1111 11 0 ",
- " 0 1111 11 0 ",
- " 0 1111 11 0 ",
- " 0 1111 11 0 ",
- " 0 1111 0 ",
- " 0 111 0 ",
- " 0 111 0 ",
- " 0 111 0 ",
- " 0 111 0 ",
- " 0 111 0 ",
- " 0 111 0 ",
- " 0 1111 0 ",
- " 0 1111 0 ",
- " 0 1111 0 ",
- " 0 1111 0 ",
- " 0 1111 0 ",
- " 0 111 0 ",
- " 0 0 ",
- " 0000000000000000000000000000 ",
- " ",
- " ",
- " "};
-
-static char **box_xpm[3] = { box_x16, box_x24, box_x32 };
-
diff --git a/app/bin/bitmaps/bridge.xpm b/app/bin/bitmaps/bridge.xpm deleted file mode 100644 index 089542d..0000000 --- a/app/bin/bitmaps/bridge.xpm +++ /dev/null @@ -1,105 +0,0 @@ -static char *bridge_x16[] = {
- "16 16 5 1",
- " c None",
- "0 c #000000",
- "1 c #333300",
- "2 c #333333",
- "3 c #CC6600",
- " ",
- " ",
- "2 2 ",
- "22 22 ",
- " 2222222222222 ",
- " 3 3 3 3 3 3 3 ",
- "000000000000000 ",
- " 3 3 3 3 3 3 3 ",
- "010000000000000 ",
- " 3 3 3 3 3 3 3 ",
- " 2222222222222 ",
- "22 22 ",
- "2 2 ",
- " ",
- " ",
- " "};
-
-static char *bridge_x24[] = {
- "24 24 8 1",
- " c None",
- "0 c #000000",
- "1 c #333300",
- "2 c #663300",
- "3 c #996600",
- "4 c #996666",
- "5 c #CC6600",
- "6 c #CC9900",
- " ",
- " ",
- "444 44",
- " 44 44 ",
- " 44 44 ",
- " 444444444444444444 ",
- " 444444444444444444 ",
- " ",
- " 6 6 6 66 6 66 6 ",
- "032023003103300300320130",
- "032023003103300300320130",
- " 6 6 6 66 6 66 6 ",
- " 6 6 6 66 6 66 6 ",
- " 6 6 6 66 6 66 6 ",
- "000000000000000000000000",
- " 6 6 6 66 6 66 6 ",
- " ",
- " ",
- " 444444444444444444 ",
- " 44444444444444444444 ",
- " 44 44 ",
- "444 444",
- " 4 44",
- " "};
-
-static char *bridge_x32[] = {
- "32 32 9 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #663300",
- "4 c #996600",
- "5 c #996666",
- "6 c #CC6600",
- "7 c #CC9900",
- " ",
- " ",
- " 55 55",
- " 55 555",
- " 555 555 ",
- " 555 555 ",
- " 55555555555555555555555555 ",
- " 555555555555555555555555 ",
- " 55555555555555555555555 ",
- " ",
- " ",
- " 77 77 777 77 77 77 77 ",
- "03320033002320033002330033101330",
- "00000000000000000000000000000000",
- " 77 77 777 77 77 77 77 ",
- " 77 77 777 77 77 77 77 ",
- " 77 77 777 77 77 77 77 ",
- " 77 77 777 77 77 77 77 ",
- " 4430044003430044003440044202440",
- "00000000000000000000000000000000",
- " 77 77 777 77 77 77 77 ",
- " ",
- " ",
- " 5555555555555555555555 ",
- " 555555555555555555555555 ",
- " 55555555555555555555555555 ",
- " 555 555 ",
- " 555 555 ",
- " 55 5555",
- "555 555",
- " ",
- " "};
-
-static char **bridge_xpm[3] = { bridge_x16, bridge_x24, bridge_x32 };
-
diff --git a/app/bin/bitmaps/building.xpm b/app/bin/bitmaps/building.xpm deleted file mode 100644 index 044e3f8..0000000 --- a/app/bin/bitmaps/building.xpm +++ /dev/null @@ -1,125 +0,0 @@ -static char *building_x16[] = {
- "16 16 13 1",
- " c None",
- "0 c #000000",
- "1 c #333300",
- "2 c #333333",
- "3 c #666600",
- "4 c #666633",
- "5 c #666666",
- "6 c #996666",
- "7 c #999966",
- "8 c #999999",
- "9 c #CCCCCC",
- "A c #C0C0C0",
- "B c #808080",
- " ",
- " 011111111110 ",
- " 137888888841 ",
- " 448AAAAAA844 ",
- " 4448AAAAA634 ",
- " 4846AAAA84B4 ",
- " 4884333334A4 ",
- " 48B5AAAA8484 ",
- " 4B4999999B44 ",
- " 448999999944 ",
- " 159999999981 ",
- "0550000000000050",
- "0999999999999992",
- "0999999999999992",
- "0555555555555550",
- " "};
-
-static char *building_x24[] = {
- "24 24 15 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #333333",
- "4 c #663333",
- "5 c #666600",
- "6 c #666633",
- "7 c #666666",
- "8 c #996666",
- "9 c #999966",
- "A c #999999",
- "B c #CCCCCC",
- "C c #C0C0C0",
- "D c #808080",
- " ",
- " ",
- " 12222222222222220 ",
- " 066777DAAAAAAAAD50 ",
- " 156CCCCCCCCCCCCD62 ",
- " 156DCCCCCCCCCCA652 ",
- " 1686ACCCCCCCCCD662 ",
- " 16A66CCCCCCCCA6982 ",
- " 16CA6ACCCCCCCD6C82 ",
- " 16CC66777777769B82 ",
- " 16CC7377777774AB82 ",
- " 16CA6BBBBBBBBA6B82 ",
- " 16A6ABBBBBBBBB6D82 ",
- " 1677BBBBBBBBBBC662 ",
- " 156BBBBBBBBBBBB752 ",
- " 06ABBBBBBBBBBBBB41 ",
- "333000000000000000000333",
- "3ACCBBBBBBBBBBBBBBBBCCC0",
- "3BBBBBBBBBBBBBBBBBBBBBB0",
- "3BBBBBBBBBBBBBBBBBBBBBB0",
- "3BBBBBBBBBBBBBBBBBBBBBB0",
- "3ACCCCCCCCCCCCCCCCCCCCC0",
- "333333333333333333333333",
- " "};
-
-static char *building_x32[] = {
- "32 32 14 1",
- " c None",
- "0 c #000000",
- "1 c #333300",
- "2 c #333333",
- "3 c #663333",
- "4 c #666600",
- "5 c #666633",
- "6 c #666666",
- "7 c #996666",
- "8 c #999966",
- "9 c #999999",
- "A c #CCCCCC",
- "B c #C0C0C0",
- "C c #808080",
- " ",
- " ",
- " ",
- " 0111111111111111111110 ",
- " 0456666C99999999999951 ",
- " 358BBBBBBBBBBBBBBBB951 ",
- " 5559BBBBBBBBBBBBBBB655 ",
- " 5756BBBBBBBBBBBBBB9555 ",
- " 59559BBBBBBBBBBBBB7595 ",
- " 59955BBBBBBBBBBBB955A5 ",
- " 59B649BBBBBBBBBBBC59A5 ",
- " 59B9559BBBBBBBBB955AA5 ",
- " 59BB956999999999659AA5 ",
- " 59BB94111111111115AAA5 ",
- " 59BBC5AAAAAAAAAAA59AA5 ",
- " 59B959AAAAAAAAAAA95AA5 ",
- " 59B56AAAAAAAAAAAAA2CA5 ",
- " 59C5AAAAAAAAAAAAAA95B5 ",
- " 5959AAAAAAAAAAAAAAA555 ",
- " 556AAAAAAAAAAAAAAAAB55 ",
- " 33AAAAAAAAAAAAAAAAAA65 ",
- " 09AAAAAAAAAAAAAAAAAAB0 ",
- "20006000000000000000000000062002",
- "29AAAAAAAAAAAAAAAAAAAAAAAAAAAAB2",
- "29AAAAAAAAAAAAAAAAAAAAAAAAAAAAB2",
- "29AAAAAAAAAAAAAAAAAAAAAAAAAAAAB2",
- "29AAAAAAAAAAAAAAAAAAAAAAAAAAAAB2",
- "29AAAAAAAAAAAAAAAAAAAAAAAAAAAAB2",
- "29AAAAAAAAAAAAAAAAAAAAAAAAAAAAB2",
- "20000000000000000000000000000002",
- " ",
- " "};
-
-static char **building_xpm[3] = { building_x16, building_x24, building_x32 };
-
diff --git a/app/bin/bitmaps/car-inventory.xpm b/app/bin/bitmaps/car-inventory.xpm deleted file mode 100644 index 45ceb2c..0000000 --- a/app/bin/bitmaps/car-inventory.xpm +++ /dev/null @@ -1,103 +0,0 @@ -static char *car_inventory_x16[] = {
- "16 16 6 1",
- " c None",
- "0 c #000000",
- "1 c #003366",
- "2 c #006600",
- "3 c #663300",
- "4 c #999999",
- " ",
- " 33333333 ",
- " 33333333 ",
- " 33333333 ",
- " 4 ",
- " 0411111111 ",
- " 11111111 ",
- " 11111111 ",
- " 4 ",
- " 0422222222 ",
- " 22222222 ",
- " 22222222 ",
- " 4 4 4 4 ",
- " 040 040 ",
- " ",
- " "};
-
-static char *car_inventory_x24[] = {
- "24 24 6 1",
- " c None",
- "0 c #000000",
- "1 c #003366",
- "2 c #006600",
- "3 c #663300",
- "4 c #CCCCCC",
- "44444444444444444 ",
- "43333333333333334 ",
- "43333333333333334 ",
- "43333333333333334 ",
- "43333333333333334 ",
- "43333333333333334 ",
- "44444444444444444 ",
- " 00 4444444444444444 ",
- " 00041111111111111114 ",
- " 0 41111111111111114 ",
- " 41111111111111114 ",
- " 41111111111111114 ",
- " 41111111111111114 ",
- " 44444444444444444 ",
- " 0044444444444444444",
- " 0042222222222222224",
- " 0042222222222222224",
- " 42222222222222224",
- " 42222222222222224",
- " 42222222222222224",
- " 44444444444444444",
- " 00 00 00 00 ",
- " 00000 00000 ",
- " 00 00 00 00 "};
-
-static char *car_inventory_x32[] = {
- "32 32 8 1",
- " c None",
- "0 c #000000",
- "1 c #003366",
- "2 c #006600",
- "3 c #663300",
- "4 c #999999",
- "5 c #CCCCCC",
- "6 c #C0C0C0",
- " 555555555555555555555 ",
- "53333333333333333333335 ",
- "53333333333333333333335 ",
- "53333333333333333333335 ",
- "53333333333333333333335 ",
- "53333333333333333333335 ",
- "53333333333333333333335 ",
- "53333333333333333333335 ",
- "53333333333333333333335 ",
- " 564555555555555555555 ",
- " 0005555555555555555555555 ",
- " 0005111111111111111111115 ",
- " 00 5111111111111111111115 ",
- " 5111111111111111111115 ",
- " 5111111111111111111115 ",
- " 5111111111111111111115 ",
- " 5111111111111111111115 ",
- " 5111111111111111111115 ",
- " 5555555555555555555555 ",
- " 000 5555555555555555555555",
- " 00052222222222222222222225",
- " 00052222222222222222222225",
- " 52222222222222222222225",
- " 52222222222222222222225",
- " 52222222222222222222225",
- " 52222222222222222222225",
- " 52222222222222222222225",
- " 55555555555555555555555",
- " 00 00 000 00 ",
- " 00000000 0000000 ",
- " 0000000 0000000 ",
- " 0 00 0 00 "};
-
-static char **car_inventory_xpm[3] = { car_inventory_x16, car_inventory_x24, car_inventory_x32 };
-
diff --git a/app/bin/bitmaps/change-grid.xpm b/app/bin/bitmaps/change-grid.xpm deleted file mode 100644 index 0287f34..0000000 --- a/app/bin/bitmaps/change-grid.xpm +++ /dev/null @@ -1,118 +0,0 @@ -static char *change_grid_x16[] = {
- "16 16 12 1",
- " c None",
- "0 c #000000",
- "1 c #00CC00",
- "2 c #00CC33",
- "3 c #339933",
- "4 c #666666",
- "5 c #669933",
- "6 c #669966",
- "7 c #996666",
- "8 c #999966",
- "9 c #CC9966",
- "A c #FFCC66",
- "1111111111111111",
- "1111111111111111",
- "1 1 11 3 1",
- "1 1 11 484 1",
- "11111111159A8311",
- "1 1 169A94 1",
- "1 1 69A962 1",
- "11111148A9411111",
- "1111168794211111",
- "1 14994 1 1",
- "1 14462 1 1",
- "1111111111111111",
- "11 11 11 11 11",
- "1 1 11 1 1",
- "11 11 11 11 11",
- "1111111111111111"};
-
-static char *change_grid_x24[] = {
- "24 24 12 1",
- " c None",
- "0 c #000000",
- "1 c #00CC00",
- "2 c #33CC33",
- "3 c #666666",
- "4 c #669933",
- "5 c #669966",
- "6 c #996666",
- "7 c #999966",
- "8 c #CC9966",
- "9 c #FF9966",
- "A c #FFCC66",
- " 1 1 11 1 1 ",
- "111111111111111111111111",
- "11 1 11 1 11",
- "11 1 11 1 11",
- "11 1 11 33 11",
- "11 1 11 3796 11",
- "1111111111111147AA932111",
- "11 11 1157AAA83 11",
- "11 1 147AAA83 11",
- "11 1 47AAA85 11",
- "11 1 37AAA831 11",
- "11111111156AAA8511111111",
- "111111114787A85111111111",
- "11 1 39A863 1 11",
- "11 1 39A83 1 11",
- "11 1 33351 1 11",
- "11 1 11 1 11",
- "111111111111111111111111",
- "11 1 11 1 11",
- "11 1 11 1 11",
- "11 1 11 1 11",
- "11 1 11 1 11",
- "111111111111111111111111",
- "111111111111111111111111"};
-
-static char *change_grid_x32[] = {
- "32 32 11 1",
- " c None",
- "0 c #000000",
- "1 c #00CC00",
- "2 c #33CC33",
- "3 c #666666",
- "4 c #669933",
- "5 c #669966",
- "6 c #996666",
- "7 c #999966",
- "8 c #CC9966",
- "9 c #FFCC66",
- " ",
- "11111111111111111111111111111111",
- "11111111111111111111111111111111",
- " 1 11 11 11 11",
- " 1 11 11 11 11",
- " 1 11 11 44 11",
- " 1 11 11 3775 11",
- " 1 11 11 379973 11",
- " 1111111111111111112799997411111",
- " 1111111111111111127999997411111",
- " 1 11 11379999973 11",
- " 1 11 1279999975 11",
- " 1 11 279999974 11",
- " 1 11 3799999751 11",
- " 1 11 37999997311 11",
- " 1111111111123899998511111111111",
- " 1111111111279789984111111111111",
- " 1 11 39997883 11 11",
- " 1 11 3999963 11 11",
- " 1 11 399985 11 11",
- " 1 11 333351 11 11",
- " 1 11 11 11 11",
- " 1111111111111111111111111111111",
- " 1111111111111111111111111111111",
- " 1 11 11 11 11",
- " 1 11 11 11 11",
- " 1 11 11 11 11",
- " 1 11 11 11 11",
- " 1 11 11 11 11",
- "111 11 11 111 111",
- "11111111111111111111111111111111",
- " "};
-
-static char **change_grid_xpm[3] = { change_grid_x16, change_grid_x24, change_grid_x32 };
-
diff --git a/app/bin/bitmaps/circle-center.xpm b/app/bin/bitmaps/circle-center.xpm deleted file mode 100644 index e58036a..0000000 --- a/app/bin/bitmaps/circle-center.xpm +++ /dev/null @@ -1,114 +0,0 @@ -static char *circle_center_x16[] = {
- "16 16 6 1",
- " c None",
- "0 c #000000",
- "1 c #CC0000",
- "2 c #CC9966",
- "3 c #FF0000",
- "4 c #808080",
- " 000000 ",
- " 40 2 2 04 ",
- " 0 2 0000 2 0 ",
- " 4 00 00 4 ",
- " 020 020 ",
- "0 0 0 0",
- "020 020",
- "0 0 0 0",
- "0 0 3 0 0",
- "020 3 020",
- "0 3 1 0",
- " 020 31 0 ",
- " 4 00 111 4 ",
- " 0 2 0000 0 ",
- " 40 2 2 04 ",
- " 000000 "};
-
-static char *circle_center_x24[] = {
- "24 24 13 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #663300",
- "4 c #666600",
- "5 c #990000",
- "6 c #993300",
- "7 c #996600",
- "8 c #CC0000",
- "9 c #CC3300",
- "A c #CC6600",
- "B c #CC9900",
- " B ",
- " 07700 B ",
- " B7000770017 ",
- " 07A A7 B30 BB ",
- " B30 B70033017 17 ",
- " 33 077 BB A303B10 ",
- " 0 A2 B 36 0 ",
- " 00 0A BA0 33B ",
- " A2B00 23B30 ",
- " 13B1B B2 00 ",
- " 0 0 00 0 ",
- " 0 00 33A0 ",
- "B3A77B 8 B77B1B",
- " 2772 8 00 0 ",
- " 00 0B 8 90 00 ",
- " 1B37 8 A93B10 ",
- " B37 0 8857A3B ",
- " 0 33 8985 0 ",
- " 02B307B A856B00 ",
- " 31 31077022 33 ",
- " B 007B 0770 B 00BB ",
- " 320 77 032 ",
- " B 0033007B ",
- " BB "};
-
-static char *circle_center_x32[] = {
- "32 32 12 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #663300",
- "4 c #990000",
- "5 c #993300",
- "6 c #996600",
- "7 c #CC0000",
- "8 c #CC3300",
- "9 c #CC6600",
- "A c #CC9900",
- " A ",
- " AA ",
- " A 00000000 A ",
- " 6100 AA 0220 ",
- " 039 AA A900 A ",
- " A 0 A 00000001A 06A ",
- " A60 6200 AA 0320 31 ",
- " 2A 00A A A 00 A 00 ",
- " 0 A10 336 0 ",
- " 00 19 A60 00AA ",
- " 0 00 00 A39 ",
- " A66A 0 29A20 ",
- " 06A66 A91 0 ",
- " 0 09A 0 0 ",
- " 0 0 0 00 ",
- " 00 0 7 33 33 ",
- "A63A93AA 777 A36A66A",
- " 62 61 777 00 00 ",
- " 0 0 777 0 0 ",
- " 0 03A 777 7740 0 ",
- " 00A93A 777 8756 00 ",
- " 63A 00 777773AA36 ",
- " AA20 06A 7777 2AA ",
- " 0 636 777777 00 ",
- " 00 A300 A 777789 00 ",
- " 36 036 AA 620 A60 ",
- " AA10 9000320039 03A ",
- " 000AA 96 A 000 AA ",
- " 022 AA 520 ",
- " A900003200029 ",
- " A 96 A ",
- " A "};
-
-static char **circle_center_xpm[3] = { circle_center_x16, circle_center_x24, circle_center_x32 };
-
diff --git a/app/bin/bitmaps/circle-filled-center.xpm b/app/bin/bitmaps/circle-filled-center.xpm deleted file mode 100644 index 91f7764..0000000 --- a/app/bin/bitmaps/circle-filled-center.xpm +++ /dev/null @@ -1,145 +0,0 @@ -static char *circle_filled_center_x16[] = {
- "16 16 19 1",
- " c None",
- "0 c #000000",
- "1 c #003333",
- "2 c #333333",
- "3 c #333366",
- "4 c #336666",
- "5 c #336699",
- "6 c #339999",
- "7 c #669999",
- "8 c #6699CC",
- "9 c #66CCCC",
- "A c #66CCFF",
- "B c #9999CC",
- "C c #99CCCC",
- "D c #99CCFF",
- "E c #99FFFF",
- "F c #CC0000",
- "G c #CC6666",
- "H c #CC6699",
- " 00 ",
- " 11488413 ",
- " 28AEEEEE93 ",
- " 3AEEEEEEEEA3 ",
- " 38EEEEEEEEEE93 ",
- " 2AEEEEEEEEEEE4 ",
- "05EEEEEEEEEEEE80",
- "18EEEEEBDEEEEE92",
- "18EEEEEDHDEEEE92",
- "06EEEEEEDHDECE81",
- " 4EEEEEEEDHDFE60",
- " 29EEEEEEEDHGA2 ",
- " 3AEEEEEBGFH4 ",
- " 14AEEEEDDA43 ",
- " 268AA973 ",
- " 012210 "};
-
-static char *circle_filled_center_x24[] = {
- "24 24 20 1",
- " c None",
- "0 c #000000",
- "1 c #003333",
- "2 c #333333",
- "3 c #333366",
- "4 c #336666",
- "5 c #336699",
- "6 c #339999",
- "7 c #669999",
- "8 c #6699CC",
- "9 c #66CCCC",
- "A c #66CCFF",
- "B c #9999CC",
- "C c #99CCCC",
- "D c #99CCFF",
- "E c #99FFFF",
- "F c #CC0000",
- "G c #CC6666",
- "H c #CC6699",
- "I c #CC9999",
- " ",
- " 11044011 ",
- " 238AEEEEA942 ",
- " 26AEEEEEEEEE83 ",
- " 29EEEEEEEEEEEEA4 ",
- " 2AEEEEEEEEEEEEEEA3 ",
- " 27EEEEEEEEEEEEEEEE93 ",
- " 4AEEEEEEEEEEEEEEEEE50 ",
- " 19EEEEEEEEEEEEEEEEEEA2 ",
- " 1AEEEEEEEEEEEEEEEEEEE1 ",
- " 3EEEEEEEEEEEEEEEEEEEE50",
- " 4EEEEEEEEDIDEEEEEEEEE60",
- " 4EEEEEEEEECIDEEEEEEEE60",
- " 3EEEEEEEEEECIDEEEEEEE50",
- " 1AEEEEEEEEEECIDEEHCEE4 ",
- " 29EEEEEEEEEEECIDDFBEA1 ",
- " 05EEEEEEEEEEEECIDFCE71 ",
- " 39EEEEEEEEEEEECHFDA2 ",
- " 2AEEEEEEEEDIGFFFD4 ",
- " 04AEEEEEEEDHIBCC62 ",
- " 139EEEEEEEEEEA42 ",
- " 26AEEEEEEA82 ",
- " 2146886411 ",
- " 0000 "};
-
-static char *circle_filled_center_x32[] = {
- "32 32 23 1",
- " c None",
- "0 c #000000",
- "1 c #000033",
- "2 c #003333",
- "3 c #333333",
- "4 c #333366",
- "5 c #336666",
- "6 c #336699",
- "7 c #339999",
- "8 c #669999",
- "9 c #6699CC",
- "A c #66CCCC",
- "B c #66CCFF",
- "C c #9999CC",
- "D c #99CCCC",
- "E c #99CCFF",
- "F c #99FFFF",
- "G c #CC0000",
- "H c #CC3333",
- "I c #CC3366",
- "J c #CC6666",
- "K c #CC6699",
- "L c #CC9999",
- " ",
- " 00333300 ",
- " 3169ABBA97230 ",
- " 35AFFFFFFFFFFB63 ",
- " 4AFFFFFFFFFFFFFFB52 ",
- " 5BFFFFFFFFFFFFFFFFB64 ",
- " 5BFFFFFFFFFFFFFFFFFFF62 ",
- " 5BFFFFFFFFFFFFFFFFFFFFB5 ",
- " 3AFFFFFFFFFFFFFFFFFFFFFFB3 ",
- " 5FFFFFFFFFFFFFFFFFFFFFFFF82 ",
- " 3AFFFFFFFFFFFFFFFFFFFFFFFFB2 ",
- " 2FFFFFFFFFFFFFFFFFFFFFFFFFF5 ",
- " 07FFFFFFFFFFFFFFFFFFFFFFFFFF92 ",
- " 2AFFFFFFFFFFFFFFFFFFFFFFFFFFB3 ",
- " 3AFFFFFFFFFFFFEFFFFFFFFFFFFFB2 ",
- " 3BFFFFFFFFFFFDHLFFFFFFFFFFFFF0 ",
- " 2BFFFFFFFFFFFDHGLFFFFFFFFFFFF0 ",
- " 3BFFFFFFFFFFFFDHGLFFFFFFFFFFB2 ",
- " 3AFFFFFFFFFFFFFDHGLFFFFEEFFFB3 ",
- " 08FFFFFFFFFFFFFFDHGLFFFIHFFFA3 ",
- " 4FFFFFFFFFFFFFFFDHGLFEGHFFF60 ",
- " 2BFFFFFFFFFFFFFFFDHGLEGJFFB2 ",
- " 28FFFFFFFFFFFFFFFFDHGKGLFF92 ",
- " 3BFFFFFFFFFFFFFFFFDHGGCFB3 ",
- " 6BFFFFFFFFFFFFEKJGGGGDF73 ",
- " 47FFFFFFFFFFFFLGGGHKLE94 ",
- " 57FFFFFFFFFFFEEEFFFF94 ",
- " 36BFFFFFFFFFFFFFFB74 ",
- " 239BFFFFFFFFFFFA33 ",
- " 227ABFFFFBA723 ",
- " 0330000230 ",
- " "};
-
-static char **circle_filled_center_xpm[3] = { circle_filled_center_x16, circle_filled_center_x24, circle_filled_center_x32 };
-
diff --git a/app/bin/bitmaps/circle-filled-tangent.xpm b/app/bin/bitmaps/circle-filled-tangent.xpm deleted file mode 100644 index f20856e..0000000 --- a/app/bin/bitmaps/circle-filled-tangent.xpm +++ /dev/null @@ -1,148 +0,0 @@ -static char *circle_filled_tangent_x16[] = {
- "16 16 20 1",
- " c None",
- "0 c #000000",
- "1 c #003333",
- "2 c #333333",
- "3 c #333366",
- "4 c #336666",
- "5 c #336699",
- "6 c #339999",
- "7 c #666699",
- "8 c #669999",
- "9 c #6699CC",
- "A c #66CCCC",
- "B c #66CCFF",
- "C c #9999CC",
- "D c #99CCFF",
- "E c #99FFFF",
- "F c #CC3333",
- "G c #CC6699",
- "H c #CC9999",
- "I c #CC99CC",
- " 0110 ",
- " 3469A842 ",
- " 3AEEEEEEA31 ",
- " 2BEEEEEEEEB4 ",
- " 3AEEEEEEEEEEB3 ",
- " 4EEEEEEEEEEEE60",
- "08EEEEEEEEEEEEA1",
- "2AEEEEEDCIHEEEB2",
- "2AEEEEECFCDEEEB1",
- "09EEEEEHCGDEEEA2",
- "05EEEEEHDDGDEE90",
- " 3BEEEEEEEDGDB3 ",
- " 4BEEEEEEEDG71 ",
- " 34BEEEEEEB74 ",
- " 39ABBB931 ",
- " 021120 "};
-
-static char *circle_filled_tangent_x24[] = {
- "24 24 22 1",
- " c None",
- "0 c #000000",
- "1 c #000033",
- "2 c #003333",
- "3 c #333333",
- "4 c #333366",
- "5 c #336666",
- "6 c #336699",
- "7 c #339999",
- "8 c #669999",
- "9 c #6699CC",
- "A c #66CCCC",
- "B c #66CCFF",
- "C c #9999CC",
- "D c #99CCCC",
- "E c #99CCFF",
- "F c #99FFFF",
- "G c #CC0000",
- "H c #CC6666",
- "I c #CC6699",
- "J c #CC9999",
- "K c #CC99CC",
- " ",
- " 0315555230 ",
- " 46AFFFFFFB73 ",
- " 03AFFFFFFFFFFA42 ",
- " 05BFFFFFFFFFFFFB73 ",
- " 3BFFFFFFFFFFFFFFB5 ",
- " 4AFFFFFFFFFFFFFFFFB4 ",
- " 26FFFFFFFFFFFFFFFFFF94 ",
- " 3BFFFFFFFFFFFFFFFFFFB2 ",
- " 2FFFFFFFFFFFFFFFFFFFF5 ",
- " 5FFFFFFFFFFFFFEFFFFFF80",
- "07FFFFFFFFFDIHGGCFFFFF92",
- "08FFFFFFFFFIGJCDEFFFFFA2",
- "06FFFFFFFFFHIIEFFFFFFF90",
- " 5FFFFFFFFEGKEIEFFFFFF60",
- " 2BFFFFFFFEGDFEIEFFFFB2 ",
- " 29FFFFFFFFEEFFEIEFFFA3 ",
- " 4BFFFFFFFFFFFFEIEFB4 ",
- " 5BFFFFFFFFFFFFEIE72 ",
- " 48FFFFFFFFFFFFFEC4 ",
- " 35BFFFFFFFFFFB74 ",
- " 3AFFFFFFFFA42 ",
- " 3179AA9723 ",
- " 003300 "};
-
-static char *circle_filled_tangent_x32[] = {
- "32 32 23 1",
- " c None",
- "0 c #000000",
- "1 c #000033",
- "2 c #003333",
- "3 c #333333",
- "4 c #333366",
- "5 c #336666",
- "6 c #336699",
- "7 c #339999",
- "8 c #669999",
- "9 c #6699CC",
- "A c #66CCCC",
- "B c #66CCFF",
- "C c #9999CC",
- "D c #99CCCC",
- "E c #99CCFF",
- "F c #99FFFF",
- "G c #CC0000",
- "H c #CC3333",
- "I c #CC6666",
- "J c #CC6699",
- "K c #CC9999",
- "L c #CC99CC",
- " ",
- " 233003320 ",
- " 2259BBFFBB9622 ",
- " 28BFFFFFFFFFFB920 ",
- " 25BFFFFFFFFFFFFFFB63 ",
- " 37BFFFFFFFFFFFFFFFFF84 ",
- " 27FFFFFFFFFFFFFFFFFFFF94 ",
- " 5BFFFFFFFFFFFFFFFFFFFFF74 ",
- " 4BFFFFFFFFFFFFFFFFFFFFFFB3 ",
- " 28FFFFFFFFFFFFFFFFFFFFFFFFA3 ",
- " 2BFFFFFFFFFFFFFFFFFFFFFFFFF4 ",
- " 5FFFFFFFFFFFFFFFFFFFFFFFFFF80 ",
- " 29FFFFFFFFFFFFFFFFFFFFFFFFFFB3 ",
- " 3BFFFFFFFFFFFFFFFFFFFFFFFFFFB1 ",
- " 2BFFFFFFFFFFFFFFEEDCDFFFFFFFF2 ",
- " 0FFFFFFFFFFFFFLHGGGGGEFFFFFFF5 ",
- " 1FFFFFFFFFFFFFHGGJLCEFFFFFFFF5 ",
- " 2BFFFFFFFFFFFEGGGIEFFFFFFFFFF4 ",
- " 3BFFFFFFFFFFFEGIJGIEFFFFFFFFF0 ",
- " 3AFFFFFFFFFFFDGKEJGHEFFFFFFFB3 ",
- " 07FFFFFFFFFFFCGCFEJGHEFFFFFF92 ",
- " 2FFFFFFFFFFFEJEFFEJGHEFFFFF5 ",
- " 29FFFFFFFFFFFFFFFFEJGHEFFFB3 ",
- " 4BFFFFFFFFFFFFFFFFEJGHEFF5 ",
- " 27FFFFFFFFFFFFFFFFFEJGHEA4 ",
- " 49FFFFFFFFFFFFFFFFFEJDB4 ",
- " 4AFFFFFFFFFFFFFFFFFFB5 ",
- " 49FFFFFFFFFFFFFFFFA4 ",
- " 45AFFFFFFFFFFFFB54 ",
- " 359BFFFFFFB953 ",
- " 2305555022 ",
- " "};
-
-static char **circle_filled_tangent_xpm[3] = { circle_filled_tangent_x16, circle_filled_tangent_x24, circle_filled_tangent_x32 };
-
diff --git a/app/bin/bitmaps/circle-line-center.xpm b/app/bin/bitmaps/circle-line-center.xpm deleted file mode 100644 index 24a41f6..0000000 --- a/app/bin/bitmaps/circle-line-center.xpm +++ /dev/null @@ -1,93 +0,0 @@ -static char *circle_line_center_x16[] = {
- "16 16 3 1",
- " c None",
- "0 c #000000",
- "1 c #CC0000",
- " 00 ",
- " 00000000 ",
- " 00 00 ",
- " 0 0 ",
- " 00 00 ",
- " 0 0 ",
- "00 00",
- "00 00",
- "00 1 00",
- "00 1 00",
- " 0 1 1 00",
- " 00 11 0 ",
- " 0 1110 ",
- " 00 00 ",
- " 000 000 ",
- " 000000 "};
-
-static char *circle_line_center_x24[] = {
- "24 24 3 1",
- " c None",
- "0 c #000000",
- "1 c #CC0000",
- " ",
- " 00000000 ",
- " 000 000 ",
- " 00 00 ",
- " 00 0 ",
- " 0 0 ",
- " 00 00 ",
- " 0 0 ",
- " 00 0 ",
- " 0 0 ",
- " 0 0 ",
- " 0 1 00",
- " 0 11 00",
- " 0 11 00",
- " 0 11 0 ",
- " 00 11 1 0 ",
- " 00 11 1 00 ",
- " 00 111 0 ",
- " 0 1111 0 ",
- " 00 1 00 ",
- " 000 00 ",
- " 00 00 ",
- " 0000000000 ",
- " 000 "};
-
-static char *circle_line_center_x32[] = {
- "32 32 4 1",
- " c None",
- "0 c #000000",
- "1 c #990000",
- "2 c #CC0000",
- " ",
- " 0000000000 ",
- " 00000000000000 ",
- " 00000 00000 ",
- " 0000 0000 ",
- " 000 000 ",
- " 000 000 ",
- " 000 000 ",
- " 00 000 ",
- " 000 00 ",
- " 00 000 ",
- " 000 00 ",
- " 00 00 ",
- " 00 00 ",
- " 00 000",
- " 00 2 000",
- " 00 222 000",
- " 00 2222 000",
- " 00 2222 00 ",
- " 00 2222 00 ",
- " 000 2222 22 00 ",
- " 00 2222 22 000 ",
- " 00 222222 00 ",
- " 000 22222 000 ",
- " 000 2222222000 ",
- " 000 2222221000 ",
- " 000 0000 ",
- " 0000 0000 ",
- " 0000 00000 ",
- " 0000000 0000000 ",
- " 000000000000 ",
- " 0000 "};
-
-static char **circle_line_center_xpm[3] = { circle_line_center_x16, circle_line_center_x24, circle_line_center_x32 };
-
diff --git a/app/bin/bitmaps/circle-line-tangent.xpm b/app/bin/bitmaps/circle-line-tangent.xpm deleted file mode 100644 index 0a5a52d..0000000 --- a/app/bin/bitmaps/circle-line-tangent.xpm +++ /dev/null @@ -1,93 +0,0 @@ -static char *circle_line_tangent_x16[] = {
- "16 16 3 1",
- " c None",
- "0 c #000000",
- "1 c #CC0000",
- " 00 ",
- " 00000000 ",
- " 00 00 ",
- " 00 0 ",
- " 00 00 ",
- " 0 0 ",
- " 0 00",
- "00 1111 00",
- "00 11 00",
- "00 1 1 00",
- " 0 1 1 00",
- " 00 1 0 ",
- " 0 10 ",
- " 00 00 ",
- " 0000 000 ",
- " 00000 "};
-
-static char *circle_line_tangent_x24[] = {
- "24 24 4 1",
- " c None",
- "0 c #000000",
- "1 c #990000",
- "2 c #CC0000",
- " ",
- " 00000000 ",
- " 000 000 ",
- " 00 00 ",
- " 00 0 ",
- " 00 0 ",
- " 0 00 ",
- " 0 0 ",
- " 00 00 ",
- " 0 0 ",
- " 0 2222 0 ",
- " 0 22222 00",
- " 0 222 00",
- " 0 22 22 0 ",
- " 0 22 22 0 ",
- " 00 22 22 0 ",
- " 0 22 00 ",
- " 00 22 0 ",
- " 0 2 0 ",
- " 0 00 ",
- " 000 00 ",
- " 00 00 ",
- " 0000000000 ",
- " 00 "};
-
-static char *circle_line_tangent_x32[] = {
- "32 32 3 1",
- " c None",
- "0 c #000000",
- "1 c #CC0000",
- " ",
- " 000000000 ",
- " 00000000000000 ",
- " 000000 000000 ",
- " 0000 0000 ",
- " 0000 000 ",
- " 000 000 ",
- " 000 000 ",
- " 000 00 ",
- " 000 000 ",
- " 00 00 ",
- " 00 000 ",
- " 000 00 ",
- " 00 00 ",
- " 00 1111111 00 ",
- " 00 1111111 000",
- " 00 11111 000",
- " 00 111111 00 ",
- " 00 11 1111 00 ",
- " 00 11 1111 00 ",
- " 000 11 1111 00 ",
- " 00 1111 000 ",
- " 000 1111 00 ",
- " 00 1111 000 ",
- " 000 111000 ",
- " 000 1000 ",
- " 000 0000 ",
- " 000 0000 ",
- " 0000 0000 ",
- " 0000000000000000 ",
- " 000000000000 ",
- " 00 "};
-
-static char **circle_line_tangent_xpm[3] = { circle_line_tangent_x16, circle_line_tangent_x24, circle_line_tangent_x32 };
-
diff --git a/app/bin/bitmaps/circle-line.xpm b/app/bin/bitmaps/circle-line.xpm deleted file mode 100644 index 1f6de11..0000000 --- a/app/bin/bitmaps/circle-line.xpm +++ /dev/null @@ -1,95 +0,0 @@ -static char *circle_line_x16[] = {
- "16 16 5 1",
- " c None",
- "0 c #000000",
- "1 c #990000",
- "2 c #CC0000",
- "3 c #800000",
- " 00 ",
- " 00000000 ",
- " 00 00 ",
- " 0 22 22 0 ",
- " 00 2 222 00 ",
- " 0 22222 0 ",
- "00 2 222222 2 00",
- "0022 2200",
- "0322222222222210",
- "0022 2 00",
- " 0 00",
- " 00 0 ",
- " 0 0 ",
- " 00 00 ",
- " 000 000 ",
- " 000000 "};
-
-static char *circle_line_x24[] = {
- "24 24 3 1",
- " c None",
- "0 c #000000",
- "1 c #CC0000",
- " ",
- " 00000000 ",
- " 000 000 ",
- " 00 00 ",
- " 00 0 ",
- " 00 1111 111 0 ",
- " 00 11 11 00 ",
- " 0 11 1111 0 ",
- " 00 1111 11 00 ",
- " 0 1111 1111 0 ",
- " 0 1 11 1 11 0 ",
- " 0 11 11 00",
- " 0 111111111111111111 00",
- " 0 11 11 0 ",
- " 0 1 1 0 ",
- " 00 0 ",
- " 0 00 ",
- " 00 0 ",
- " 0 0 ",
- " 0 00 ",
- " 000 00 ",
- " 00 00 ",
- " 0000000000 ",
- " 00 "};
-
-static char *circle_line_x32[] = {
- "32 32 4 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #CC0000",
- " ",
- " 0000000000 ",
- " 00000000000000 ",
- " 00000 00000 ",
- " 0000 0000 ",
- " 000 000 ",
- " 000 222 222 000 ",
- " 000 22222 22222 000 ",
- " 00 2 22 22 000 ",
- " 000 22 22222 00 ",
- " 00 222 222 22 000 ",
- " 000 22 22 22 000 ",
- " 00 2 22222 222222 00 ",
- " 00 222 2222 2222 222 00 ",
- " 00 222 2222 00 ",
- " 0022222222222222222222222222000",
- " 0022222222222222222222222222100",
- " 00 222 222 000",
- " 00 222 222 00 ",
- " 00 222 22 00 ",
- " 000 00 ",
- " 00 000 ",
- " 00 00 ",
- " 000 000 ",
- " 000 000 ",
- " 000 000 ",
- " 000 0000 ",
- " 0000 0000 ",
- " 0000 00000 ",
- " 0000000000000000 ",
- " 000000000000 ",
- " 0000 "};
-
-static char **circle_line_xpm[3] = { circle_line_x16, circle_line_x24, circle_line_x32 };
-
diff --git a/app/bin/bitmaps/circle-tangent.xpm b/app/bin/bitmaps/circle-tangent.xpm deleted file mode 100644 index 4ae8c69..0000000 --- a/app/bin/bitmaps/circle-tangent.xpm +++ /dev/null @@ -1,110 +0,0 @@ -static char *circle_tangent_x16[] = {
- "16 16 5 1",
- " c None",
- "0 c #000000",
- "1 c #CC0000",
- "2 c #CC9966",
- "3 c #808080",
- " 000000 ",
- " 30 2 2 03 ",
- " 0 2 0000 2 0 ",
- " 3 00 00 3 ",
- " 020 020 ",
- "0 0 0 0",
- "020 020",
- "0 0 0 0",
- "0 0 111 0 0",
- "020 11 020",
- "0 0 1 1 0",
- " 020 1 20 ",
- " 3 00 1 3 ",
- " 0 2 0000 2 0 ",
- " 30 2 2 03 ",
- " 000000 "};
-
-static char *circle_tangent_x24[] = {
- "24 24 11 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #663300",
- "4 c #990000",
- "5 c #996600",
- "6 c #CC0000",
- "7 c #CC3300",
- "8 c #CC6600",
- "9 c #CC9900",
- " 99 ",
- " 9 00330059 ",
- " 5000550023 ",
- " 0059 85 93009 ",
- " 930 80023025 25 ",
- " 139 035 99 8305900 ",
- " 0 920 335 0 ",
- " 00 059 950 539 ",
- " 83930 3591 ",
- " 03938 90 00 ",
- " 0 0 0 0 ",
- " 0 0 6666 2551 ",
- "928839 66666 955829",
- " 15 0 6666 0 0 ",
- " 00 05 66666 0 00 ",
- " 01953 66 666983900 ",
- " 839 0 66608939 ",
- " 920 38 764 029 ",
- " 0395029 9316800 ",
- " 35 31053022 82 ",
- " 9500 9 055059 0089 ",
- " 025 99 520 ",
- " 8100330038 ",
- " 55 9 "};
-
-static char *circle_tangent_x32[] = {
- "32 32 11 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #663300",
- "4 c #993300",
- "5 c #996600",
- "6 c #CC0000",
- "7 c #CC6600",
- "8 c #CC9900",
- "9 c #800000",
- " 8 ",
- " 75 8 ",
- " 8 00003200018 ",
- " 3200 88 0320 ",
- " 0028 88 8 00 8 ",
- " 8 00 88000100038 058 ",
- " 52 300 78 032 830 ",
- " 018 0058 8 8 0088 0 ",
- " 0 830 23 0 ",
- " 00 138 830 038 ",
- " 850 0 0 8835 ",
- " 8558 00 538 00 ",
- " 058828 830 0 ",
- " 0 028 0 0 ",
- " 0 00 0 0 ",
- " 00 0 6666666 07 25 ",
- "85488378 666666 8278458",
- " 52 25 6666 0 0 ",
- " 0 00 66666 0 0 ",
- " 0 18 6666666 00 0 ",
- " 00 837 666 6666 8835 00 ",
- " 3388 0 6 6666 138833 ",
- " 881 018 66660 288 ",
- " 00 35 6666 00 ",
- " 0 8700 8 8 0967 00 ",
- " 17 015 8 510 870 ",
- " 71 8200320037 37 ",
- " 00 88 75 8 00 8 ",
- " 005 88 8500 ",
- " 53000 55 0003 ",
- " 88 00033000 8 ",
- " 88 "};
-
-static char **circle_tangent_xpm[3] = { circle_tangent_x16, circle_tangent_x24, circle_tangent_x32 };
-
diff --git a/app/bin/bitmaps/circle.xpm b/app/bin/bitmaps/circle.xpm deleted file mode 100644 index 0be3fe9..0000000 --- a/app/bin/bitmaps/circle.xpm +++ /dev/null @@ -1,115 +0,0 @@ -static char *circle_x16[] = {
- "16 16 5 1",
- " c None",
- "0 c #000000",
- "1 c #CC0000",
- "2 c #CC9966",
- "3 c #808080",
- " 000000 ",
- " 30 2 2 03 ",
- " 0 2 0000 2 0 ",
- " 3 00 00 3 ",
- " 020 020 ",
- "0 0 0 0",
- "0 00 303 0",
- "0 1 0 0 0 1 0",
- "311110 0 011113",
- "0 1 00 303 1 0",
- "0 0",
- " 020 020 ",
- " 3 00 00 3 ",
- " 0 2 0000 2 0 ",
- " 30 2 2 03 ",
- " 000000 "};
-
-static char *circle_x24[] = {
- "24 24 13 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #660000",
- "4 c #663300",
- "5 c #990000",
- "6 c #996600",
- "7 c #CC0000",
- "8 c #CC3300",
- "9 c #CC6600",
- "A c #CC9900",
- "B c #800000",
- " AA ",
- " 004400 A ",
- " 6000660014 ",
- " 06A 69 A600 A ",
- " A40 60024006 24 ",
- " 44A 066 A A601A40 ",
- " 0 92 44 0 ",
- " 00 09 AA0 64A ",
- " A2A00 64A40 ",
- " 14AB8 000 000 971 0 ",
- " 00577 0 0000 00 777 0 ",
- " 03777 000 00 007777816",
- "A497787 000000 017887829",
- " 26878 0000 00 77 0 ",
- " 00 57 0000 000 773 0 ",
- " 0A46 A4920 ",
- " A49 0 04A49 ",
- " A 0 24A A60 00A ",
- " 01A40 A A 04A 0 ",
- " 44 240660420 64 ",
- " A 00 A404404A 006A ",
- " 240 AA 620 ",
- " A40000004A ",
- " A AA A "};
-
-static char *circle_x32[] = {
- "32 32 14 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #660000",
- "4 c #663300",
- "5 c #990000",
- "6 c #993300",
- "7 c #996600",
- "8 c #CC0000",
- "9 c #CC3300",
- "A c #CC6600",
- "B c #CC9900",
- "C c #800000",
- " BB ",
- " BB ",
- " B 0000000000AB ",
- " 7100 BB 0240 ",
- " 02B BB BB000 B ",
- " B 0 BA00000000A 04B ",
- " A1 4400 BB 420 72 ",
- " 1B 00BB B BB00 B 00 ",
- " 0 B10 47 00 ",
- " 00 17B BB0 0BB ",
- " B 0 00 0 B77 ",
- " B77B 0 47B 0 ",
- " 07B799 0000 000 A93 0 ",
- " 0 588 00000 00000 888C 00 ",
- " 0 8888 00 00 00 888 00 ",
- " 0 88888 0000 00 00 88888862 ",
- "B74A88888 0000 00 00 888889A4B",
- "BA2B9889 00000 00 888 00 ",
- " 0 888 0 000 00 00 8885 00 ",
- " 0 189 00000 0000 88C 00 ",
- " 00 A4B BB74 0 ",
- " 74BB00 2BB74 ",
- " BB40 0 B 00 2AB ",
- " 0 44A B40 00 ",
- " 00 B700 B B 07B 0 ",
- " 27 02A BB A40 BA0 ",
- " B20 A100440017 2A ",
- " B 00 BB 77 B 00 BB ",
- " 044 BB 7700 ",
- " A00004700007 ",
- " BB 0470 BB ",
- " BB "};
-
-static char **circle_xpm[3] = { circle_x16, circle_x24, circle_x32 };
-
diff --git a/app/bin/bitmaps/connect.xpm b/app/bin/bitmaps/connect.xpm deleted file mode 100644 index 3853635..0000000 --- a/app/bin/bitmaps/connect.xpm +++ /dev/null @@ -1,116 +0,0 @@ -static char *connect_x16[] = {
- "16 16 12 1",
- " c None",
- "0 c #000000",
- "1 c #003399",
- "2 c #336699",
- "3 c #3366CC",
- "4 c #3366FF",
- "5 c #3399FF",
- "6 c #6699FF",
- "7 c #9966CC",
- "8 c #CC0000",
- "9 c #CC3366",
- "A c #CC3399",
- " ",
- " ",
- " ",
- " 5 4333 3435 5 ",
- "1313121 1313131",
- " 6 6 66 6 6 6 ",
- " 313233 3313133",
- "1313233 2313132",
- " 6 6 9 A 6 6 ",
- " 88 88 ",
- "8888888888888888",
- " 8 8 ",
- " 8 8 ",
- " ",
- " ",
- " "};
-
-static char *connect_x24[] = {
- "24 24 11 1",
- " c None",
- "0 c #000000",
- "1 c #003399",
- "2 c #336699",
- "3 c #3366CC",
- "4 c #3366FF",
- "5 c #3399FF",
- "6 c #6699FF",
- "7 c #CC0000",
- "8 c #CC3366",
- "9 c #CC6699",
- " ",
- " ",
- " ",
- " ",
- " 6 6 6 6 6 6 ",
- " 35 5 53 35 53 43 ",
- "11311311311 11311311211",
- " 6 6 6 6 6 66 ",
- " 6 6 6 6 6 66 ",
- " 6 6 6 6 6 66 ",
- "11111111111 11111111111",
- " 6 6 6 6 6 66 ",
- " 8 8 ",
- " 77 777 ",
- " 777 777 ",
- " 7777777777777777777777 ",
- " 7777777777 77777777777 ",
- " 777 777 ",
- " 777 777 ",
- " 7 7 ",
- " ",
- " ",
- " ",
- " "};
-
-static char *connect_x32[] = {
- "32 32 10 1",
- " c None",
- "0 c #000000",
- "1 c #003399",
- "2 c #336699",
- "3 c #3366CC",
- "4 c #3366FF",
- "5 c #3399FF",
- "6 c #6699FF",
- "7 c #CC0000",
- "8 c #CC3366",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " 66 6 6 6 6 66 ",
- " 33 35 53 35 53 34 ",
- " 1111113111311 1131113111121 ",
- " 66 6 6 6 6 66 ",
- " 66 6 6 6 6 66 ",
- " 66 6 6 6 6 66 ",
- " 66 6 6 6 6 66 ",
- " 1331113111321 1131113211331 ",
- " 1331113111321 1131113211331 ",
- " 66 6 6 6 6 66 ",
- " 78 87 ",
- " 777 777 ",
- " 7777 7777 ",
- " 7777 7777 ",
- " 77777777777777 777777777777777 ",
- " 777777777777777777777777777777 ",
- " 7777 7777 ",
- " 777 777 ",
- " 777 777 ",
- " 77 77 ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " "};
-
-static char **connect_xpm[3] = { connect_x16, connect_x24, connect_x32 };
-
diff --git a/app/bin/bitmaps/control.xpm b/app/bin/bitmaps/control.xpm deleted file mode 100644 index 45d1f9b..0000000 --- a/app/bin/bitmaps/control.xpm +++ /dev/null @@ -1,129 +0,0 @@ -static char *control_x16[] = {
- "16 16 16 1",
- " c None",
- "0 c #000000",
- "1 c #003300",
- "2 c #006600",
- "3 c #009900",
- "4 c #00CC00",
- "5 c #00FF00",
- "6 c #330000",
- "7 c #333300",
- "8 c #660000",
- "9 c #663300",
- "A c #990000",
- "B c #CC0000",
- "C c #FF0000",
- "D c #800000",
- "E c #008000",
- " ",
- " 0 00",
- " 0 00 ",
- " 0 00 ",
- " 0 8ABD 00 ",
- " 07CCCCA0 ",
- " E49CCCCD ",
- " 4549CCCB ",
- " 45549CCB0 ",
- " 355549CA ",
- " 04555496 ",
- " 01455420 ",
- " 0 00 0 ",
- " 0 0 ",
- " 0 0 ",
- "0 0"};
-
-static char *control_x24[] = {
- "24 24 15 1",
- " c None",
- "0 c #000000",
- "1 c #006600",
- "2 c #009900",
- "3 c #00CC00",
- "4 c #00FF00",
- "5 c #330000",
- "6 c #339900",
- "7 c #660000",
- "8 c #663300",
- "9 c #990000",
- "A c #CC0000",
- "B c #FF0000",
- "C c #800000",
- "D c #008000",
- " ",
- " 00 00 ",
- " 000 000 ",
- " 000 000 ",
- " 000 000 ",
- " 000 000 ",
- " 000005CC700000 ",
- " 007ABBBBA500 ",
- " 018BBBBBBA50 ",
- " 0338BBBBBBA0 ",
- " 014438BBBBBB70 ",
- " 0244438BBBBB90 ",
- " 03444438BBBB90 ",
- " 0D4444438BBB90 ",
- " 0044444438BB5 ",
- " 0D4444443890 ",
- " 002444444600 ",
- " 00001333310000 ",
- " 000 000000 000 ",
- " 000 000 ",
- " 000 000 ",
- " 000 000 ",
- " 00 000",
- " "};
-
-static char *control_x32[] = {
- "32 32 15 1",
- " c None",
- "0 c #000000",
- "1 c #003300",
- "2 c #006600",
- "3 c #009900",
- "4 c #00CC00",
- "5 c #00FF00",
- "6 c #330000",
- "7 c #660000",
- "8 c #663300",
- "9 c #990000",
- "A c #CC0000",
- "B c #FF0000",
- "C c #800000",
- "D c #008000",
- " ",
- " 0 0 ",
- " 000 000 ",
- " 000 0000 ",
- " 000 0000 ",
- " 000 0000 ",
- " 000 0000 ",
- " 000 00 0000 ",
- " 000 00077000 0000 ",
- " 0000CABBBBAC00000 ",
- " 06ABBBBBBBB9000 ",
- " 0038BBBBBBBBB90 ",
- " 0D548BBBBBBBBB70 ",
- " 0045548BBBBBBBBA0 ",
- " 02555548BBBBBBBB60 ",
- " 035555548BBBBBBBC0 ",
- " 0355555548BBBBBBC0 ",
- " 0D555555548BBBBB70 ",
- " 005555555548BBBB00 ",
- " 035555555548BB90 ",
- " 0045555555548B60 ",
- " 02455555555480 ",
- " 000145555554D000 ",
- " 00000024444200 000 ",
- " 000 00000000 000 ",
- " 000 000 ",
- " 000 000 ",
- " 000 000 ",
- " 000 000 ",
- " 000 000 ",
- " 00 00 ",
- " "};
-
-static char **control_xpm[3] = { control_x16, control_x24, control_x32 };
-
diff --git a/app/bin/bitmaps/convert-from.xpm b/app/bin/bitmaps/convert-from.xpm deleted file mode 100644 index ed72d8a..0000000 --- a/app/bin/bitmaps/convert-from.xpm +++ /dev/null @@ -1,99 +0,0 @@ -static char *convert_from_x16[] = {
- "16 16 8 1",
- " c None",
- "0 c #000000",
- "1 c #999999",
- "2 c #CC0000",
- "3 c #CCCCCC",
- "4 c #FF0000",
- "5 c #FFFFFF",
- "6 c #808080",
- " 363 363 ",
- "5060 10601 ",
- "36 1 6006 03",
- "30 101 1 63",
- " 10601 060 ",
- " 363 2 363 ",
- " 2 ",
- " 2 ",
- " 42224 ",
- " 424 ",
- " 4 ",
- " 00000 ",
- " 00 ",
- " 0000 ",
- " 00 ",
- " 00 "};
-
-static char *convert_from_x24[] = {
- "24 24 4 1",
- " c None",
- "0 c #000000",
- "1 c #CC0000",
- "2 c #CC0033",
- " ",
- " 00 0000 ",
- " 0000 00000 00 ",
- " 00 00 0000 0 00 ",
- " 0 00 000 00 0 ",
- " 00 00 00 0 0 ",
- " 0 000 0 00 ",
- " 000000 22 0000 ",
- " 22 ",
- " 22 ",
- " 2 22 ",
- " 2 22 22 ",
- " 2222 ",
- " 22 ",
- " 2 ",
- " 000000 ",
- " 00 ",
- " 0 ",
- " 00000 ",
- " 00 ",
- " 0 ",
- " 0 ",
- " 0 ",
- " "};
-
-static char *convert_from_x32[] = {
- "32 32 4 1",
- " c None",
- "0 c #000000",
- "1 c #CC0000",
- "2 c #CC0033",
- " ",
- " ",
- " 00000 0000000 ",
- " 00 0 0000 00 ",
- " 0 00 0000 0 ",
- " 0 00 000 000 00 ",
- " 0 0 000 0 00 ",
- " 0 000 00 00 00 ",
- " 00 00 0 0 ",
- " 00 0000 22 00 00 ",
- " 00000 22 0000 ",
- " 22 ",
- " 22 ",
- " 2 22 ",
- " 22 22 22 ",
- " 222 22 222 ",
- " 22222222 ",
- " 222222 ",
- " 222 ",
- " 2 ",
- " 00000000 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 000000 ",
- " 000000 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " ",
- " "};
-
-static char **convert_from_xpm[3] = { convert_from_x16, convert_from_x24, convert_from_x32 };
-
diff --git a/app/bin/bitmaps/convert-to.xpm b/app/bin/bitmaps/convert-to.xpm deleted file mode 100644 index 5f5c94e..0000000 --- a/app/bin/bitmaps/convert-to.xpm +++ /dev/null @@ -1,99 +0,0 @@ -static char *convert_to_x16[] = {
- "16 16 8 1",
- " c None",
- "0 c #000000",
- "1 c #999999",
- "2 c #CC0000",
- "3 c #CCCCCC",
- "4 c #FF0000",
- "5 c #FFFFFF",
- "6 c #808080",
- " 00000 ",
- " 00 ",
- " 0000 ",
- " 00 ",
- " 00 ",
- " 2 ",
- " 2 ",
- " 2 ",
- " 42224 ",
- " 424 ",
- " 363 4 363 ",
- "5060 10601 ",
- "36 1 6006 03",
- "30 101 1 63",
- " 10601 060 ",
- " 363 363 "};
-
-static char *convert_to_x24[] = {
- "24 24 4 1",
- " c None",
- "0 c #000000",
- "1 c #CC0000",
- "2 c #CC0033",
- " ",
- " 000000 ",
- " 000000 ",
- " 00 ",
- " 00000 ",
- " 00000 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 2 ",
- " 2 ",
- " 2 ",
- " 22 2 2 ",
- " 22 2 2 ",
- " 2222 ",
- " 22 ",
- " 0000 00000 ",
- " 00 0 0000 0 ",
- " 0 00 0000 00 00 ",
- " 0 0 00 0 0 ",
- " 00 00 00 00 0 ",
- " 00 000 0 0 ",
- " 0000 000 ",
- " "};
-
-static char *convert_to_x32[] = {
- "32 32 4 1",
- " c None",
- "0 c #000000",
- "1 c #CC0000",
- "2 c #CC0033",
- " ",
- " ",
- " 00000000 ",
- " 0 ",
- " 0 ",
- " 0 ",
- " 000000 ",
- " 0 ",
- " 0 ",
- " 0 ",
- " 0 ",
- " 0 ",
- " 22 ",
- " 22 ",
- " 22 ",
- " 22 ",
- " 22 22 22 ",
- " 222 22 222 ",
- " 22222222 ",
- " 222222 ",
- " 2222 ",
- " 000 22 00000 ",
- " 000 00 00000 000 ",
- " 0 0 0000 00 ",
- " 00 00 000 00 0 ",
- " 00 0 000 00 00 ",
- " 00 000 000 00 00 ",
- " 0 00 00 0 ",
- " 00 00 0 00 ",
- " 0000000 00000 ",
- " 00 ",
- " "};
-
-static char **convert_to_xpm[3] = { convert_to_x16, convert_to_x24, convert_to_x32 };
-
diff --git a/app/bin/bitmaps/copy.xpm b/app/bin/bitmaps/copy.xpm deleted file mode 100644 index 1812343..0000000 --- a/app/bin/bitmaps/copy.xpm +++ /dev/null @@ -1,95 +0,0 @@ -static char *copy_x16[] = {
- "16 16 4 1",
- " c None",
- "0 c #000000",
- "1 c #666666",
- "2 c #FFFFFF",
- "111111111111 ",
- "1222222222221 ",
- "1222222222221 ",
- "1221111111111111",
- "1221222222222221",
- "1221222222222221",
- "1221222222222221",
- "1221222222222221",
- "1221222222222221",
- "1221222222222221",
- "1221222222222221",
- "1221222222222221",
- "1111222222222221",
- " 1222222222221",
- " 1222222222221",
- " 1111111111111"};
-
-static char *copy_x24[] = {
- "24 24 4 1",
- " c None",
- "0 c #000000",
- "1 c #666666",
- "2 c #FFFFFF",
- " 11111111111111111 ",
- "1222222222222222221 ",
- "1222222222222222221 ",
- "1222222222222222221 ",
- "12222211111111111111111 ",
- "122221222222222222222221",
- "122221222222222222222221",
- "122221222222222222222221",
- "122221222222222222222221",
- "122221222222222222222221",
- "122221222222222222222221",
- "122221222222222222222221",
- "122221222222222222222221",
- "122221222222222222222221",
- "122221222222222222222221",
- "122221222222222222222221",
- "122221222222222222222221",
- "122221222222222222222221",
- "122221222222222222222221",
- " 11111222222222222222221",
- " 1222222222222222221",
- " 1222222222222222221",
- " 1222222222222222221",
- " 11111111111111111 "};
-
-static char *copy_x32[] = {
- "32 32 4 1",
- " c None",
- "0 c #000000",
- "1 c #666666",
- "2 c #FFFFFF",
- " ",
- " 111111111111111111111111 ",
- " 122222222222222222222221 ",
- " 122222222222222222222221 ",
- " 122222222222222222222221 ",
- " 122222222222222222222221 ",
- " 122222111111111111111111111111 ",
- " 122222122222222222222222222221 ",
- " 122222122222222222222222222221 ",
- " 122222122222222222222222222221 ",
- " 122222122222222222222222222221 ",
- " 122222122222222222222222222221 ",
- " 122222122222222222222222222221 ",
- " 122222122222222222222222222221 ",
- " 122222122222222222222222222221 ",
- " 122222122222222222222222222221 ",
- " 122222122222222222222222222221 ",
- " 122222122222222222222222222221 ",
- " 122222122222222222222222222221 ",
- " 122222122222222222222222222221 ",
- " 122222122222222222222222222221 ",
- " 122222122222222222222222222221 ",
- " 122222122222222222222222222221 ",
- " 122222122222222222222222222221 ",
- " 122222122222222222222222222221 ",
- " 111111122222222222222222222221 ",
- " 122222222222222222222221 ",
- " 122222222222222222222221 ",
- " 122222222222222222222221 ",
- " 122222222222222222222221 ",
- " 111111111111111111111111 ",
- " "};
-
-static char **copy_xpm[3] = { copy_x16, copy_x24, copy_x32 };
-
diff --git a/app/bin/bitmaps/cornu.xpm b/app/bin/bitmaps/cornu.xpm deleted file mode 100644 index d1bffcb..0000000 --- a/app/bin/bitmaps/cornu.xpm +++ /dev/null @@ -1,117 +0,0 @@ -static char *cornu_x16[] = {
- "16 16 10 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #663300",
- "4 c #993300",
- "5 c #996600",
- "6 c #CC0000",
- "7 c #CC6600",
- "8 c #CC9900",
- " 5 ",
- " 5303022 ",
- " 8307353733 ",
- " 03523552566 ",
- " 8233 84666 ",
- " 0327 66 ",
- "8353 ",
- " 153 ",
- " 253 ",
- " 3518 ",
- " 34528 ",
- " 832538 6 ",
- " 3552555753666",
- " 232523335666",
- " 85301331246 ",
- " 7557 "};
-
-static char *cornu_x24[] = {
- "24 24 12 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #663300",
- "4 c #666600",
- "5 c #990000",
- "6 c #996600",
- "7 c #CC0000",
- "8 c #CC6600",
- "9 c #CC9900",
- "A c #800000",
- " ",
- " 9 66009 ",
- " 300360320 ",
- " 91069 99 99018 ",
- " 36 6100023 915 ",
- " 099038 9 8138777 ",
- " 92 28 9657 7 ",
- " 3392 5777 ",
- " 00339 77 ",
- " 91826 ",
- " 91928 ",
- " 0 0 ",
- " 61938 ",
- " 91963 ",
- " 00 19 ",
- " 03962 ",
- " 93 069 ",
- " 0 9309 7 ",
- " 33 3209 9 98A777 ",
- " 93049 32032330377 7 ",
- " 32099 8368 98777 ",
- " 9002308166022A7 ",
- " 90130160 9 ",
- " 9 9 "};
-
-static char *cornu_x32[] = {
- "32 32 12 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #663300",
- "4 c #990000",
- "5 c #993300",
- "6 c #996600",
- "7 c #CC0000",
- "8 c #CC6600",
- "9 c #CC9900",
- "A c #800000",
- " ",
- " 9 9 ",
- " 98000000038 ",
- " 1300 9 6300 ",
- " 9 00099 99 9 039 ",
- " 61 9 033039 60 ",
- " 029 021086062039 47 ",
- " 0 80089 9 9 13577477 ",
- " 9920 28 9917 7 ",
- " 639 0 7 77 ",
- " 00966 777 ",
- " 0 08 ",
- " 0 0 ",
- " 9869839 ",
- " 00 62 ",
- " 00 0 ",
- " 00 629 ",
- " 9669928 ",
- " 60 00 ",
- " 0 19 ",
- " 019932 ",
- " 839 0 9 ",
- " 930 38 ",
- " 00 98009 7 ",
- " 26 33 9 9 99 4777 ",
- " 9920 93016 69 903317 77 ",
- " 008 85010002008 7 77 ",
- " 8300 9 99 9 997777 ",
- " 9 00060 99 960220A7 ",
- " 96000000020089 ",
- " 9 99 99 ",
- " "};
-
-static char **cornu_xpm[3] = { cornu_x16, cornu_x24, cornu_x32 };
-
diff --git a/app/bin/bitmaps/curved-chord.xpm b/app/bin/bitmaps/curved-chord.xpm deleted file mode 100644 index b8c1d9d..0000000 --- a/app/bin/bitmaps/curved-chord.xpm +++ /dev/null @@ -1,109 +0,0 @@ -static char *curved_chord_x16[] = {
- "16 16 5 1",
- " c None",
- "0 c #000000",
- "1 c #CC0000",
- "2 c #CC9966",
- "3 c #FF6666",
- " 2 2 ",
- " 2 0000 ",
- " 2 00 2 2 ",
- " 2 00 2 000 ",
- " 0 2 002 2 ",
- " 2 0 2002 ",
- " 0 ",
- " 20 2 1111 ",
- " 020 113 ",
- " 20 0 1313 ",
- " 0202 1 313 1 ",
- " 0 0 31311 ",
- "20202 311 ",
- " 0 0 11 ",
- "20202 11 ",
- " "};
-
-static char *curved_chord_x24[] = {
- "24 24 11 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #663300",
- "4 c #993300",
- "5 c #996600",
- "6 c #CC0000",
- "7 c #CC3300",
- "8 c #CC6600",
- "9 c #CC9900",
- " 9 ",
- " 9100300",
- " 0130 89 ",
- " 820089 99 ",
- " 018 930200",
- " 9500 99 013059 ",
- " 135 500 9 ",
- " 9900 9 039 ",
- " 53 81 9 ",
- " 099 019 ",
- " 9 0 950 ",
- " 938 39 ",
- " 029990 766666 ",
- " 0 38 666666 ",
- " 953 00 6666 ",
- " 19990 66 66 ",
- " 00 559 66 66 ",
- " 00 0 66 66 66",
- " 929930 66 66 ",
- " 3299559 6666 ",
- " 00 0 66 ",
- " 00 0 66 ",
- "9459829 66 ",
- " 25 539 6 "};
-
-static char *curved_chord_x32[] = {
- "32 32 10 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #663300",
- "4 c #993300",
- "5 c #996600",
- "6 c #CC0000",
- "7 c #CC6600",
- "8 c #CC9900",
- " 8 ",
- " 88 000330 ",
- " 250000000 ",
- " 8 000020 88 ",
- " 85000058 8 ",
- " 00010 8 00130 ",
- " 00038 3200000 ",
- " 87000 88 00022 8 ",
- " 0000 5000088 ",
- " 00078 003 ",
- " 8500 88000088 ",
- " 503 500 ",
- " 0288 0037 ",
- " 00 888100 8 ",
- " 88000 8501 ",
- " 405 0038 ",
- " 00888 0076666666 ",
- " 00 820 66666666 ",
- " 00 0058 66666 ",
- " 830 00 66666 ",
- " 0388800 66 666 ",
- " 00 8703 66 6666 ",
- " 00 007 66 6666 66 ",
- " 00 00 66 6666 6666",
- " 8505 000 6 6666 6666 ",
- " 1188831 6666666 ",
- " 00 5038 66666 ",
- " 00 000 666 ",
- " 00 00 666 ",
- " 503 00 666 ",
- "850788318 666 ",
- " 0 00 6 "};
-
-static char **curved_chord_xpm[3] = { curved_chord_x16, curved_chord_x24, curved_chord_x32 };
-
diff --git a/app/bin/bitmaps/curved-end.xpm b/app/bin/bitmaps/curved-end.xpm deleted file mode 100644 index 6c91543..0000000 --- a/app/bin/bitmaps/curved-end.xpm +++ /dev/null @@ -1,107 +0,0 @@ -static char *curved_end_x16[] = {
- "16 16 5 1",
- " c None",
- "0 c #000000",
- "1 c #CC0000",
- "2 c #CC9966",
- "3 c #FF6666",
- " 111 ",
- " 11 ",
- " 2 133 ",
- " 2 0 1 ",
- " 2 00 2 331",
- " 0 2 00 11",
- " 2 0 2002 111",
- " 0 02 ",
- " 20 20 ",
- " 0202 ",
- " 20 0 ",
- " 0202 ",
- " 0 0 ",
- "20202 ",
- " 0 0 ",
- "20202 "};
-
-static char *curved_end_x24[] = {
- "24 24 10 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #663300",
- "4 c #666600",
- "5 c #996600",
- "6 c #CC0000",
- "7 c #CC6600",
- "8 c #CC9900",
- " ",
- " 66 ",
- " 66666 ",
- " 6 6 ",
- " 8 6 ",
- " 750 66 ",
- " 85005 66 ",
- " 8 0130 8 6 ",
- " 730 88 530 6 6 ",
- " 058 7015 66666 ",
- " 70 87035 8 666 ",
- " 18 532 ",
- " 870 83078 ",
- " 35 33 ",
- " 008850 ",
- " 881 38 ",
- " 35880 ",
- " 0 53 ",
- " 71 05 ",
- " 55871 ",
- " 00 338 ",
- " 0 00 ",
- "837835 ",
- " 17 35 "};
-
-static char *curved_end_x32[] = {
- "32 32 9 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #663300",
- "4 c #996600",
- "5 c #CC0000",
- "6 c #CC6600",
- "7 c #CC9900",
- " ",
- " 555 ",
- " 555555 ",
- " 55555555 ",
- " 55555 5 ",
- " 55 55 ",
- " 77 55 ",
- " 6400 555 ",
- " 7700367 55 ",
- " 420 77 55 ",
- " 7700377 77 55 55",
- " 743 77 64215 55555 ",
- " 047 760046 5555555 ",
- " 740 77 333 77 55555 ",
- " 636 774037 5555 ",
- " 1777 347 ",
- " 7 0 777017 ",
- " 734 734 ",
- " 3477 077 ",
- " 0 7772 ",
- " 7730 447 ",
- " 6377 007 ",
- " 047772 ",
- " 0 447 ",
- " 740 067 ",
- " 7447740 ",
- " 1677447 ",
- " 0 16 ",
- " 0 0 ",
- " 437 41 ",
- "76477637 ",
- " 00 42 "};
-
-static char **curved_end_xpm[3] = { curved_end_x16, curved_end_x24, curved_end_x32 };
-
diff --git a/app/bin/bitmaps/curved-line-chord.xpm b/app/bin/bitmaps/curved-line-chord.xpm deleted file mode 100644 index 779cc67..0000000 --- a/app/bin/bitmaps/curved-line-chord.xpm +++ /dev/null @@ -1,92 +0,0 @@ -static char *curved_line_chord_x16[] = {
- "16 16 3 1",
- " c None",
- "0 c #000000",
- "1 c #CC0000",
- " ",
- " 0000 ",
- " 0000 ",
- " 00 ",
- " 0 ",
- " 00 ",
- " 01111 ",
- " 0 111 ",
- " 00 1111 ",
- " 0 1 11 ",
- " 00 11 11",
- " 0 11 11 ",
- " 0 111 ",
- " 0 11 ",
- " 0 11 ",
- " "};
-
-static char *curved_line_chord_x24[] = {
- "24 24 3 1",
- " c None",
- "0 c #000000",
- "1 c #CC0000",
- " ",
- " ",
- " 00000 ",
- " 0000 ",
- " 000 ",
- " 00 ",
- " 00 ",
- " 0 ",
- " 0 ",
- " 0 11111 ",
- " 00 111 ",
- " 00 111 ",
- " 0 1 11 ",
- " 00 1 11 ",
- " 0 1 11 ",
- " 00 11 1 ",
- " 0 11 1 ",
- " 0 11 1 ",
- " 00 111 ",
- " 00 11 ",
- " 00 11 ",
- " 00 11 ",
- " 11 ",
- " "};
-
-static char *curved_line_chord_x32[] = {
- "32 32 3 1",
- " c None",
- "0 c #000000",
- "1 c #CC0000",
- " ",
- " ",
- " 00000 ",
- " 00000000 ",
- " 000000 ",
- " 00000 ",
- " 0000 ",
- " 000 ",
- " 000 ",
- " 0000 ",
- " 000 ",
- " 000 ",
- " 0011111111 ",
- " 00011111111 ",
- " 000 1111 ",
- " 000 11111 ",
- " 00 11 111 ",
- " 000 11 111 ",
- " 00 11 111 ",
- " 000 11 111 ",
- " 00 111 1 ",
- " 00 111 111 ",
- " 000 11 111 ",
- " 00 111 111 ",
- " 00 11111 ",
- " 00 111 ",
- " 00 111 ",
- " 00 111 ",
- " 00 111 ",
- " 11 ",
- " ",
- " "};
-
-static char **curved_line_chord_xpm[3] = { curved_line_chord_x16, curved_line_chord_x24, curved_line_chord_x32 };
-
diff --git a/app/bin/bitmaps/curved-line-end.xpm b/app/bin/bitmaps/curved-line-end.xpm deleted file mode 100644 index 0e967ab..0000000 --- a/app/bin/bitmaps/curved-line-end.xpm +++ /dev/null @@ -1,94 +0,0 @@ -static char *curved_line_end_x16[] = {
- "16 16 3 1",
- " c None",
- "0 c #000000",
- "1 c #CC0000",
- " ",
- " 11 ",
- " 1111 ",
- " 11 ",
- " 00011 ",
- " 0000 11 ",
- " 000 1111 ",
- " 00 11 ",
- " 00 ",
- " 00 ",
- " 0 ",
- " 0 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 0 "};
-
-static char *curved_line_end_x24[] = {
- "24 24 4 1",
- " c None",
- "0 c #000000",
- "1 c #660000",
- "2 c #CC0000",
- " ",
- " 2 ",
- " 2222 ",
- " 222222 ",
- " 22 ",
- " 22 ",
- " 00012 ",
- " 00000 2 ",
- " 000 2 ",
- " 000 22222 ",
- " 00 222 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 0 ",
- " 00 ",
- " 0 ",
- " 0 ",
- " 00 ",
- " 00 ",
- " 0 ",
- " 0 ",
- " 0 ",
- " 0 "};
-
-static char *curved_line_end_x32[] = {
- "32 32 4 1",
- " c None",
- "0 c #000000",
- "1 c #660000",
- "2 c #CC0000",
- " ",
- " ",
- " 222 ",
- " 22222 ",
- " 2222222 ",
- " 22222 22 ",
- " 222 ",
- " 222 ",
- " 0000122 ",
- " 0000000 22 ",
- " 000000 22 ",
- " 00000 22 22 ",
- " 0000 22222222 ",
- " 000 2222222 ",
- " 0000 2222 ",
- " 000 2 ",
- " 000 ",
- " 000 ",
- " 000 ",
- " 00 ",
- " 000 ",
- " 00 ",
- " 00 ",
- " 000 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 000 ",
- " 000 ",
- " 00 ",
- " "};
-
-static char **curved_line_end_xpm[3] = { curved_line_end_x16, curved_line_end_x24, curved_line_end_x32 };
-
diff --git a/app/bin/bitmaps/curved-line-middle.xpm b/app/bin/bitmaps/curved-line-middle.xpm deleted file mode 100644 index fceb7d6..0000000 --- a/app/bin/bitmaps/curved-line-middle.xpm +++ /dev/null @@ -1,95 +0,0 @@ -static char *curved_line_middle_x16[] = {
- "16 16 4 1",
- " c None",
- "0 c #000000",
- "1 c #CC0000",
- "2 c #800000",
- " ",
- " 00000",
- " 0000 ",
- " 000 ",
- " 00 ",
- " 00 ",
- " 02111 ",
- " 00111 ",
- " 0 1111 ",
- " 00 11 ",
- " 0 11 ",
- " 00 11 ",
- " 00 11 ",
- " 0 1 ",
- " 0 ",
- " 0 "};
-
-static char *curved_line_middle_x24[] = {
- "24 24 4 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #CC0000",
- " ",
- " 0 ",
- " 000000 ",
- " 0000 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 0 ",
- " 0 ",
- " 0022222 ",
- " 00 222 ",
- " 0 22 2 ",
- " 00 22 2 ",
- " 00 22 ",
- " 00 22 ",
- " 0 22 ",
- " 00 22 ",
- " 00 22 ",
- " 0 22 ",
- " 0 2 ",
- " 0 ",
- " 0 ",
- " "};
-
-static char *curved_line_middle_x32[] = {
- "32 32 4 1",
- " c None",
- "0 c #000000",
- "1 c #CC0000",
- "2 c #800000",
- " ",
- " ",
- " 000000 ",
- " 000000000 ",
- " 000000 ",
- " 00000 ",
- " 00000 ",
- " 0000 ",
- " 000 ",
- " 000 ",
- " 000 ",
- " 000 ",
- " 002 ",
- " 000111111 ",
- " 000 111111 ",
- " 00 11111 ",
- " 00 11 111 ",
- " 000 11 111 ",
- " 00 11 111 ",
- " 000 111 ",
- " 00 111 ",
- " 00 111 ",
- " 000 111 ",
- " 00 111 ",
- " 00 1111 ",
- " 000 111 ",
- " 00 111 ",
- " 00 111 ",
- " 00 1 ",
- " 00 ",
- " 00 ",
- " "};
-
-static char **curved_line_middle_xpm[3] = { curved_line_middle_x16, curved_line_middle_x24, curved_line_middle_x32 };
-
diff --git a/app/bin/bitmaps/curved-line-tangent.xpm b/app/bin/bitmaps/curved-line-tangent.xpm deleted file mode 100644 index e184d3a..0000000 --- a/app/bin/bitmaps/curved-line-tangent.xpm +++ /dev/null @@ -1,98 +0,0 @@ -static char *curved_line_tangent_x16[] = {
- "16 16 4 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #CC0000",
- " ",
- " 00000",
- " 0000 ",
- " 000 ",
- " 00 ",
- " 10 ",
- " 022 ",
- " 00 22 ",
- " 00 22 ",
- " 0 22 ",
- " 00 22 ",
- " 00 22 2 ",
- " 0 22 2 ",
- " 0 222 ",
- "00 2222 ",
- " 0 "};
-
-static char *curved_line_tangent_x24[] = {
- "24 24 5 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #660000",
- "3 c #CC0000",
- " ",
- " ",
- " 000000 ",
- " 0000 ",
- " 000 ",
- " 000 ",
- " 00 ",
- " 00 ",
- " 01 ",
- " 23 ",
- " 0 3 ",
- " 0 3 ",
- " 00 3 ",
- " 0 3 ",
- " 0 33 ",
- " 0 33 ",
- " 00 33 ",
- " 0 33 3 ",
- " 00 33 3 ",
- " 00 33 3 ",
- " 00 333 ",
- " 00 33333 ",
- " 0 3 ",
- " "};
-
-static char *curved_line_tangent_x32[] = {
- "32 32 6 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #990000",
- "3 c #CC0000",
- "4 c #800000",
- " ",
- " ",
- " 00000 ",
- " 00000000 ",
- " 0000000 ",
- " 00000 ",
- " 00000 ",
- " 0000 ",
- " 000 ",
- " 000 ",
- " 0000 ",
- " 001 ",
- " 0043 ",
- " 002333 ",
- " 00 333 ",
- " 000 333 ",
- " 000 333 ",
- " 00 333 ",
- " 000 333 ",
- " 00 333 ",
- " 000 333 ",
- " 00 333 ",
- " 00 333 3 ",
- " 00 333 33 ",
- " 00 333 33 ",
- " 00 333 33 ",
- " 00 333333 ",
- " 000 3333 ",
- " 000 33333333 ",
- " 00 33333333 ",
- " ",
- " "};
-
-static char **curved_line_tangent_xpm[3] = { curved_line_tangent_x16, curved_line_tangent_x24, curved_line_tangent_x32 };
-
diff --git a/app/bin/bitmaps/curved-middle.xpm b/app/bin/bitmaps/curved-middle.xpm deleted file mode 100644 index 70fc4de..0000000 --- a/app/bin/bitmaps/curved-middle.xpm +++ /dev/null @@ -1,108 +0,0 @@ -static char *curved_middle_x16[] = {
- "16 16 5 1",
- " c None",
- "0 c #000000",
- "1 c #CC0000",
- "2 c #CC9966",
- "3 c #FF6666",
- " 2 2 ",
- " 2 0000 ",
- " 2 00 2 2 ",
- " 2 00 2 000 ",
- " 0 2 002 2 ",
- " 2 0 2 ",
- " 0 1111 ",
- " 20 113 ",
- " 02 1313 ",
- " 20 1 313 ",
- " 0202 313 ",
- " 0 0 313 ",
- "20202 313 ",
- " 0 0 313 ",
- "20202 31 ",
- " "};
-
-static char *curved_middle_x24[] = {
- "24 24 9 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #663300",
- "4 c #996600",
- "5 c #CC0000",
- "6 c #CC6600",
- "7 c #CC9900",
- " 7 ",
- " 7 430",
- " 4300340",
- " 7 0026 77 ",
- " 320 730210",
- " 7 00077 013037 ",
- " 41 400 7 7 ",
- " 037 037 ",
- " 720 60 7 ",
- " 167 027 ",
- " 00 740 7 ",
- " 743 37 ",
- " 17740 655555 ",
- " 00 736 55555 ",
- " 742 00 555 ",
- " 26760 5 55 ",
- " 0 367 5 55 ",
- " 00 0 5 55 ",
- "7726720 5 ",
- " 277277 5 ",
- " 00 0 5 ",
- " 00 00 5 ",
- "7447447 5 ",
- " 01 34 "};
-
-static char *curved_middle_x32[] = {
- "32 32 11 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #663300",
- "4 c #666600",
- "5 c #996600",
- "6 c #CC0000",
- "7 c #CC3300",
- "8 c #CC6600",
- "9 c #CC9900",
- " ",
- " 99 ",
- " 9 002300",
- " 5200038 ",
- " 99 00038 9 ",
- " 810 9 820",
- " 028 8500033 ",
- " 99 000 99 005 99 ",
- " 930 9200 99 ",
- " 059 015 ",
- " 99 0 9 00 99 ",
- " 983 920 ",
- " 399 08 ",
- " 0 99950 9 ",
- " 99 0 9938 ",
- " 935 299 ",
- " 02999 0 97666666 ",
- " 0 953 66666666 ",
- " 00 0299 6666666 ",
- " 9991 0 666666 ",
- " 3599 00 6666666 ",
- " 0 9839 666 6666 ",
- " 00 0399 666 6666 ",
- " 00 0 6666 ",
- " 9919 00 666 ",
- " 5399928 666 ",
- " 00 3299 666 ",
- " 00 00 666 ",
- " 0 00 666 ",
- "99289 15 666 ",
- "990999199 66 ",
- " 0 0 "};
-
-static char **curved_middle_xpm[3] = { curved_middle_x16, curved_middle_x24, curved_middle_x32 };
-
diff --git a/app/bin/bitmaps/curved-tangent.xpm b/app/bin/bitmaps/curved-tangent.xpm deleted file mode 100644 index 6332785..0000000 --- a/app/bin/bitmaps/curved-tangent.xpm +++ /dev/null @@ -1,116 +0,0 @@ -static char *curved_tangent_x16[] = {
- "16 16 5 1",
- " c None",
- "0 c #000000",
- "1 c #CC0000",
- "2 c #CC9966",
- "3 c #FF6666",
- " 2 2 ",
- " 2 0000 ",
- " 2 00 2 2 ",
- " 2 00 2 000 ",
- " 0 2 002 2 ",
- " 2 0 002 ",
- " 0 13 ",
- " 20 313 ",
- " 020 313 ",
- " 20 0 313 ",
- " 0202 313 ",
- " 0 0 313 1 ",
- "20202 3131 ",
- " 0 0 311 ",
- "20202 1111 ",
- " "};
-
-static char *curved_tangent_x24[] = {
- "24 24 13 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #663300",
- "4 c #996600",
- "5 c #CC0000",
- "6 c #CC6600",
- "7 c #CC6666",
- "8 c #CC9900",
- "9 c #CCCCCC",
- "A c #FFCCCC",
- "B c #FFFFFF",
- " ",
- " 8 440 ",
- " 2400340 ",
- " 830048 8 ",
- " 014 88 8 ",
- " 8600 88 80030 ",
- " 34 80022 4 ",
- " 00 8 33 ",
- " 63 81048 ",
- " 08BA 34 ",
- " 60 95A0 ",
- " 26 B755 ",
- " 00 880B555 ",
- " 60 43 555 ",
- " 448 0 555 ",
- " 0 8830 555 ",
- " 00 438 555 ",
- " 10 00 555 5 ",
- " 828881 555 55 ",
- " 0 8438 55555 ",
- " 00 00 5555 ",
- " 33 23 55555 ",
- " 448836 55555 ",
- " 0 0 "};
-
-static char *curved_tangent_x32[] = {
- "32 32 15 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #663300",
- "4 c #993300",
- "5 c #996600",
- "6 c #CC0000",
- "7 c #CC3333",
- "8 c #CC6600",
- "9 c #CC6666",
- "A c #CC9900",
- "B c #CC9999",
- "C c #FFCCCC",
- "D c #FFFFFF",
- " ",
- " AA ",
- " AA 003200 ",
- " 320005A ",
- " A0000A A ",
- " 32 AA A ",
- " 005A AA A3 ",
- " A 00 AA A000010 ",
- " 33 A 0023 A ",
- " 00AA 8200A ",
- " A 00 A 018 ",
- " 33 A500 A ",
- " 02AADD 53 ",
- " 00 D9BD08 ",
- " A82 DC76BD ",
- " 1AA DC766 ",
- " 00 AA 0C666 ",
- " 0 A3 666 ",
- " A1 05A 666 ",
- " 54A 00 666 ",
- " 0 AAA0 666 ",
- " 0 55 666 ",
- " 00 0 666 ",
- " 0 00 666 6 ",
- " A3AAA 00 666 666 ",
- " 00 AAA2A 6666666 ",
- " 00 00 666666 ",
- " 00 00 66666 ",
- " 0 00 6666666 ",
- " A3AAAA38 6666666 ",
- " 0 08 ",
- " "};
-
-static char **curved_tangent_xpm[3] = { curved_tangent_x16, curved_tangent_x24, curved_tangent_x32 };
-
diff --git a/app/bin/bitmaps/cut.xpm b/app/bin/bitmaps/cut.xpm deleted file mode 100644 index 6dcae39..0000000 --- a/app/bin/bitmaps/cut.xpm +++ /dev/null @@ -1,92 +0,0 @@ -static char *cut_x16[] = {
- "16 16 3 1",
- " c None",
- "0 c #000000",
- "1 c #333333",
- " ",
- " ",
- " 1 ",
- " 1111 ",
- " 11 11 ",
- " 1111 ",
- " 11 ",
- " 11 11111 ",
- " 11111111111111 ",
- " 11111 1111 ",
- " 1 11 111 ",
- " 111 111 ",
- " 111 ",
- " 111 ",
- " ",
- " "};
-
-static char *cut_x24[] = {
- "24 24 3 1",
- " c None",
- "0 c #000000",
- "1 c #333333",
- " ",
- " ",
- " ",
- " ",
- " 1111 ",
- " 11 11 ",
- " 111 11 ",
- " 111 1 ",
- " 1111 ",
- " 1111 ",
- " 1111 ",
- " 1111 1111111 ",
- " 11111111111111111111 ",
- " 111111111111111111111 ",
- " 1111111 111 ",
- " 11 11 1111 ",
- " 11 111 1111 ",
- " 111 1111 ",
- " 1111 ",
- " 1111 ",
- " 111 ",
- " ",
- " ",
- " "};
-
-static char *cut_x32[] = {
- "32 32 3 1",
- " c None",
- "0 c #000000",
- "1 c #333333",
- " ",
- " ",
- " ",
- " ",
- " ",
- " 11111 ",
- " 1111111 ",
- " 111 111 ",
- " 111 11 ",
- " 1111 111 ",
- " 111111111 ",
- " 1111111 ",
- " 1111 ",
- " 11111 ",
- " 11111 ",
- " 11111 1111111111 ",
- " 111111111111111111111111 ",
- " 1111111111111111111111111111 ",
- " 111111111111111111 ",
- " 111 111 1111 ",
- " 11 111 1111 ",
- " 111 111 11111 ",
- " 1111111 11111 ",
- " 11111 1111 ",
- " 1111 ",
- " 11111 ",
- " 11111 ",
- " 111 ",
- " ",
- " ",
- " ",
- " "};
-
-static char **cut_xpm[3] = { cut_x16, cut_x24, cut_x32 };
-
diff --git a/app/bin/bitmaps/delete.xpm b/app/bin/bitmaps/delete.xpm deleted file mode 100644 index 9002046..0000000 --- a/app/bin/bitmaps/delete.xpm +++ /dev/null @@ -1,114 +0,0 @@ -static char *delete_x16[] = {
- "16 16 9 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #990000",
- "3 c #CC0000",
- "4 c #CC3300",
- "5 c #CC6600",
- "6 c #CC9900",
- "7 c #800000",
- " ",
- " ",
- " 33 33 ",
- " 33 333 ",
- " 33 333 ",
- " 6 6 533534 6 6 ",
- "0000007333100000",
- " 6 6 663346 6 6 ",
- " 6 6 663356 6 6 ",
- "0000007332000000",
- " 6 6 633435 6 6 ",
- " 333 33 ",
- " 333 33 ",
- " 33 333 ",
- " 3 ",
- " "};
-
-static char *delete_x24[] = {
- "24 24 11 1",
- " c None",
- "0 c #000000",
- "1 c #333300",
- "2 c #663300",
- "3 c #993300",
- "4 c #996600",
- "5 c #CC0000",
- "6 c #CC3300",
- "7 c #CC6600",
- "8 c #CC9900",
- "9 c #800000",
- " ",
- " ",
- " ",
- " 555 555 ",
- " 5555 555 ",
- " 5555 555 ",
- " 5555 5555 ",
- " 555 5555 ",
- " 8 8 75557556 8 8 ",
- "01200200295555520020021 ",
- " 47 7 74555567 7 74 ",
- " 8 8 8 555578 8 8 ",
- " 8 8 8 5555 8 8 8 ",
- " 47 7 74555537 7 74 ",
- "012002002255555200200210",
- " 8 8 85556557 8 8 ",
- " 5555 555 ",
- " 555 555 ",
- " 555 5555 ",
- " 555 5555 ",
- " 555 555 ",
- " 5 5 ",
- " ",
- " "};
-
-static char *delete_x32[] = {
- "32 32 11 1",
- " c None",
- "0 c #000000",
- "1 c #333300",
- "2 c #663300",
- "3 c #990000",
- "4 c #993300",
- "5 c #996600",
- "6 c #CC0000",
- "7 c #CC3300",
- "8 c #CC6600",
- "9 c #CC9900",
- " ",
- " ",
- " ",
- " 6 6 ",
- " 666 666 ",
- " 66666 66666 ",
- " 66666 66666 ",
- " 66666 6666 ",
- " 66666 6666 ",
- " 66666 66666 ",
- " 66666 66666 ",
- " 99 99 9766686667 99 99 ",
- " 055005510254666666651025500550 ",
- " 055005510255366666751025500550 ",
- " 99 99 99 6666699 99 99 ",
- " 99 99 99 6666699 99 99 ",
- " 99 99 99 6666699 99 99 ",
- " 99 99 99 6666699 99 99 ",
- " 055005510255666666551025500550 ",
- " 055005510254666666751025500550 ",
- " 99 99 9766686668 99 99 ",
- " 66666 6666 ",
- " 6666 6666 ",
- " 6666 66666 ",
- " 66666 66666 ",
- " 66666 66666 ",
- " 6666 66666 ",
- " 6666 666 ",
- " 66 6 ",
- " ",
- " ",
- " "};
-
-static char **delete_xpm[3] = { delete_x16, delete_x24, delete_x32 };
-
diff --git a/app/bin/bitmaps/describe.xpm b/app/bin/bitmaps/describe.xpm deleted file mode 100644 index 1cbeb20..0000000 --- a/app/bin/bitmaps/describe.xpm +++ /dev/null @@ -1,111 +0,0 @@ -static char *describe_x16[] = {
- "16 16 5 1",
- " c None",
- "0 c #000000",
- "1 c #CC0000",
- "2 c #CC9966",
- "3 c #FF6666",
- " ",
- " 331133 ",
- " 31111113 ",
- " 113 311 ",
- " 11 ",
- " 2 2 2 3113 2 ",
- "000000 3113 0000",
- " 2 2 2 113 2 2 ",
- " 2 2 2 11 2 2 2 ",
- "000000 11 000000",
- " 2 2 2 11 2 2 2 ",
- " ",
- " 11 ",
- " 11 ",
- " ",
- " "};
-
-static char *describe_x24[] = {
- "24 24 10 1",
- " c None",
- "0 c #000000",
- "1 c #333300",
- "2 c #660000",
- "3 c #663300",
- "4 c #990000",
- "5 c #996600",
- "6 c #CC0000",
- "7 c #CC6600",
- "8 c #CC9900",
- " ",
- " ",
- " ",
- " 66666666 ",
- " 6666666666 ",
- " 66666666666 ",
- " 6666 6666 ",
- " 66 6666 ",
- " 6666 ",
- " 8 8 88 66666 8 88 ",
- " 00000000046666620000000",
- " 8 8 88666667 8 88 ",
- " 8 8 886666 8 8 88 ",
- " 8 8 886666 8 8 88 ",
- " 1500510536664150051053 ",
- " 1500510536664150051053 ",
- " 8 8 8 6666 8 8 8 ",
- " 666 ",
- " 6 ",
- " 66 ",
- " 666 ",
- " ",
- " ",
- " "};
-
-static char *describe_x32[] = {
- "32 32 13 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #663300",
- "4 c #990000",
- "5 c #993300",
- "6 c #996600",
- "7 c #CC0000",
- "8 c #CC3300",
- "9 c #CC6600",
- "A c #CC9900",
- "B c #800000",
- " ",
- " ",
- " ",
- " 7777 ",
- " 7777777777 ",
- " 777777777777 ",
- " 77777777777777 ",
- " 77777 77777 ",
- " 7777 77777 ",
- " 7777 77777 ",
- " 77 7777 ",
- " 77777 ",
- " AA AA AA 777777 AA AA ",
- " 066006630266B77777777106600660 ",
- " 066006630266B77777785006600660 ",
- " AA AA AA 777778AA AA AA ",
- " AA AA AA 7777 AAA AA AA ",
- " AA AA AA 7777 AAA AA AA ",
- " AA AA AA 7777 AAA AA AA ",
- " 033003320133B77770232003300330 ",
- " 99 696 39947777 696 99 99 ",
- " AA AA AA 7777 AAA AA AA ",
- " 7777 ",
- " 7777 ",
- " 7 ",
- " 77 ",
- " 7777 ",
- " 7777 ",
- " 77 ",
- " ",
- " ",
- " "};
-
-static char **describe_xpm[3] = { describe_x16, describe_x24, describe_x32 };
-
diff --git a/app/bin/bitmaps/description.xpm b/app/bin/bitmaps/description.xpm deleted file mode 100644 index 47941b0..0000000 --- a/app/bin/bitmaps/description.xpm +++ /dev/null @@ -1,101 +0,0 @@ -static char *description_x16[] = {
- "16 16 5 1",
- " c None",
- "0 c #000000",
- "1 c #0066CC",
- "2 c #0099FF",
- "3 c #FF0000",
- " ",
- "00 000 00 00 ",
- "0 0 0 0 0 ",
- "0 0 00 0 0 ",
- "0 0 0 0 0 ",
- "00 000 00 00 ",
- " 3 ",
- " 333 ",
- " 33333 ",
- " 3 ",
- " 2 2 2 3 2 2 2 ",
- " 11111 3 11111 ",
- " 2 2 2 2 2 2 ",
- " 1111111111111 ",
- " 2 2 2 2 2 2 2 ",
- " "};
-
-static char *description_x24[] = {
- "24 24 5 1",
- " c None",
- "0 c #000000",
- "1 c #0066CC",
- "2 c #0099FF",
- "3 c #FF0000",
- " ",
- " ",
- " ",
- " 000 0000 000 00 ",
- " 0 0 0 0 0 0 ",
- " 0 0 000 00 0 ",
- " 0 0 0 0 0 0 ",
- " 000 0000 000 00 ",
- " ",
- " 33 ",
- " 3333 ",
- " 333333 ",
- " 33 ",
- " 33 ",
- " 2 2 2 33 2 2 2 ",
- " 111111111 33 11111111 ",
- " 2 2 2 33 2 2 2 ",
- " 2 2 2 33 2 2 2 ",
- " 2 2 2 2 2 2 ",
- " 111111111111111111111 ",
- " 2 2 2 2 2 2 2 ",
- " ",
- " ",
- " "};
-
-static char *description_x32[] = {
- "32 32 8 1",
- " c None",
- "0 c #000000",
- "1 c #0000CC",
- "2 c #0033CC",
- "3 c #0066CC",
- "4 c #0066FF",
- "5 c #0099FF",
- "6 c #CC0000",
- " ",
- " 0000 00000 000 000 ",
- " 000000 00000 00000 00000 ",
- " 00 000 00 00 00 ",
- " 00 00 00000 0000 00 ",
- " 00 000 00 0000 00 ",
- " 00 000 00 0 00 000 0 ",
- " 000000 00000 00000 00000 ",
- " ",
- " 66 ",
- " 6666 ",
- " 666666 ",
- " 66666666 ",
- " 6 66 66 ",
- " 66 ",
- " 66 ",
- " 66 ",
- " 66 ",
- " 66 ",
- " 66 ",
- " ",
- " 55 5 5 55 5 5 55 ",
- " 55 35 53 55 35 53 45 ",
- " 111111111111111111111111111111 ",
- " 55 35 53 55 35 53 45 ",
- " 55 5 5 55 5 5 55 ",
- " 55 5 5 55 5 5 55 ",
- " 55 35 53 55 35 53 45 ",
- " 111111111111111111111111111111 ",
- " 133112311133113311231113311331 ",
- " 55 5 5 55 5 5 55 ",
- " "};
-
-static char **description_xpm[3] = { description_x16, description_x24, description_x32 };
-
diff --git a/app/bin/bitmaps/dimension.xpm b/app/bin/bitmaps/dimension.xpm deleted file mode 100644 index faceac6..0000000 --- a/app/bin/bitmaps/dimension.xpm +++ /dev/null @@ -1,94 +0,0 @@ -static char *dimension_x16[] = {
- "16 16 4 1",
- " c None",
- "0 c #000000",
- "1 c #990000",
- "2 c #999999",
- " 1111",
- " 111",
- " 1111",
- " 111 1",
- " 11 ",
- " 002 200 ",
- " 0 0 ",
- " 02 002 ",
- " 0 0 0 ",
- " 002 202 ",
- " ",
- " 11 ",
- "1 111 ",
- "1111 ",
- "111 ",
- "1111 "};
-
-static char *dimension_x24[] = {
- "24 24 4 1",
- " c None",
- "0 c #000000",
- "1 c #990000",
- "2 c #CC0000",
- " ",
- " 222222 ",
- " 22222 ",
- " 22222",
- " 222222",
- " 222 22",
- " 222 2 ",
- " 22 ",
- " 2 ",
- " 000 0000 ",
- " 0 00 0 0 ",
- " 00 0000 ",
- " 0000 00 ",
- " 0 0 0 0 ",
- " 0000 0000 ",
- " 0 0 ",
- " 22 ",
- " 22 222 ",
- " 22 222 ",
- " 22222 ",
- " 2222 ",
- " 222222 ",
- " 222222 ",
- " "};
-
-static char *dimension_x32[] = {
- "32 32 3 1",
- " c None",
- "0 c #000000",
- "1 c #CC0000",
- " ",
- " 1111111 ",
- " 11111111 ",
- " 1111111 ",
- " 11111 ",
- " 111111 ",
- " 1111 11 ",
- " 1111 11 ",
- " 1111 11 ",
- " 1111 ",
- " 111 ",
- " ",
- " 00000 00000 ",
- " 00 00 00 00 ",
- " 00 00 ",
- " 000 000000 ",
- " 000 00 00 ",
- " 0000 00 ",
- " 00 00 0 00 ",
- " 00000 00000 ",
- " 0 00 ",
- " 11 ",
- " 1 111 ",
- " 111 1111 ",
- " 111 1111 ",
- " 111 1111 ",
- " 1111111 ",
- " 111111 ",
- " 11111111 ",
- " 11111111 ",
- " 11111111 ",
- " "};
-
-static char **dimension_xpm[3] = { dimension_x16, dimension_x24, dimension_x32 };
-
diff --git a/app/bin/bitmaps/doc-export-bmap.xpm b/app/bin/bitmaps/doc-export-bmap.xpm deleted file mode 100644 index 543cc1a..0000000 --- a/app/bin/bitmaps/doc-export-bmap.xpm +++ /dev/null @@ -1,162 +0,0 @@ -static char *doc_export_bmap_x16[] = {
- "16 16 23 1",
- " c None",
- "0 c #000000",
- "1 c #333300",
- "2 c #333333",
- "3 c #336666",
- "4 c #336699",
- "5 c #3399CC",
- "6 c #663333",
- "7 c #666633",
- "8 c #666666",
- "9 c #669933",
- "A c #6699CC",
- "B c #996633",
- "C c #996666",
- "D c #999966",
- "E c #999999",
- "F c #CC0000",
- "G c #CC9966",
- "H c #CC9999",
- "I c #CCCC99",
- "J c #CCCCCC",
- "K c #FFCCCC",
- "L c #808080",
- "2888888888872 ",
- "8KH2788881JI2 ",
- "8DIJKEJKKKHI2 ",
- "8E99I8KKKKK82 ",
- "8I99DHKKKKK22 ",
- "8CII7JKKKKKHF ",
- "8J2K7JKKKKKKFF ",
- "8KKD2KKKIHHGFFFF",
- "4LKK0KKKHHHGFFFF",
- "4AAK2KKKKKKKFF ",
- "4AAH2KIHHHK8F ",
- "4AA32KCBBBI02 ",
- "4AA4LKCBBBI62 ",
- "4AAAKDIHHHKH2 ",
- "4AAAKK88C2EI2 ",
- "45558EEEEEED2 "};
-
-static char *doc_export_bmap_x24[] = {
- "24 24 30 1",
- " c None",
- "0 c #000000",
- "1 c #000033",
- "2 c #003333",
- "3 c #330000",
- "4 c #333300",
- "5 c #333333",
- "6 c #336699",
- "7 c #339933",
- "8 c #3399CC",
- "9 c #663333",
- "A c #666633",
- "B c #666666",
- "C c #666699",
- "D c #669933",
- "E c #6699CC",
- "F c #996633",
- "G c #996666",
- "H c #999966",
- "I c #999999",
- "J c #CC0000",
- "K c #CC3333",
- "L c #CC6666",
- "M c #CC9966",
- "N c #CC9999",
- "O c #CCCC99",
- "P c #CCCCCC",
- "Q c #FFCC99",
- "R c #FFCCCC",
- "S c #808080",
- "3000000000000000005 ",
- "5RRRROOOOOOOOPRRRP5 ",
- "5RRN5SSNNNNNNB5IRP5 ",
- "5RGNRRRRORRRRRROBP5 ",
- "5OSOHOROBRRRRRRRGO5 ",
- "5BR77DOBORRRRRRROI5 ",
- "5AOD7DOBRRRRRRRROS5 ",
- "5BRODHINRRRRRRRRP5 ",
- "5OHRRRHNRRRRRRRRRP J ",
- "5RI9PRHNRRRRRRRRRRJJJ ",
- "5RRRAIGORRRRRRRRRR JJJJ ",
- "5RRRRHBORRRRQLLLLKJJJJJJ",
- "5SORRR0ORRRRQLLLLKJJJJJJ",
- "5EEBRR4ORRRRRRRRRR JJJJ ",
- "5EEECRBPRRRRRRRRRRJJJ ",
- "5EEE8RBPRRRRRRRRPG J ",
- "5EEEENGPRO9999FRR5 ",
- "5EEEEHGPRNFMMMFPRB5 ",
- "5EEEESONRNFMMMFPOH5 ",
- "5EEEECR9RO9999FRIN5 ",
- "5EEEE6RIBRRRRRRR4P5 ",
- "5EEEE8RRO3BNNNB0PP5 ",
- "5EEEEEIRRRROOOPRRP5 ",
- "2111110BBBBBBBBBBB5 "};
-
-static char *doc_export_bmap_x32[] = {
- "32 32 26 1",
- " c None",
- "0 c #000000",
- "1 c #003333",
- "2 c #333333",
- "3 c #336666",
- "4 c #336699",
- "5 c #339933",
- "6 c #339999",
- "7 c #3399CC",
- "8 c #663333",
- "9 c #666633",
- "A c #666666",
- "B c #669933",
- "C c #669966",
- "D c #6699CC",
- "E c #996633",
- "F c #996666",
- "G c #999966",
- "H c #999999",
- "I c #CC0000",
- "J c #CC9966",
- "K c #CC9999",
- "L c #CCCC99",
- "M c #CCCCCC",
- "N c #FFCCCC",
- "O c #808080",
- "2000000000000000000000002 ",
- "0NNNNNNNNNNNNNNNNNNNNNNN0 ",
- "0NNNNMHFFFFFFFFFFOHLNNNN0 ",
- "0NNNH2GKKKLLLLLLLKH9ALNN0 ",
- "0NNFAMNNNNNMNNNNNNNNK2LN0 ",
- "0NHANNLNNNLANNNNNNNNNHAN0 ",
- "0N2LG5BLNNALNNNNNNNNNN2M0 ",
- "0KANB55BMKHNNNNNNNNNNNAL0 ",
- "0KOLB55BN9MNNNNNNNNNNNFK0 ",
- "0LANLBBCL9NNNNNNNNNNNNFA2 ",
- "0M2MNLMNKGNNNNNNNNNNNNKA ",
- "0NAHNNNNKGNNNNNNNNNNNNNN II ",
- "0NLAALNNKGNNNNNNNNNNNNN IIII ",
- "0NNNK2HNHHNNNNNNNNNNNNN IIII ",
- "0NNNNMFAHHNNNNNNNNNNNNN IIIII ",
- "0NNNNNNGAHNNNNNNNIIIIIIIIIIIIIII",
- "13LNNNNN2GNNNNNNNIIIIIIIIIIIIIII",
- "1DD3KNNNAFNNNNNNNNNNNNN IIIII ",
- "1DDDDHNNGHNNNNNNNNNNNNN IIII ",
- "1DDDDDKNHHNNNNNNNNNNNNN IIII ",
- "1DDDDDANHHNNNNNNNNNNNNM II ",
- "1DDDDD4MHHNNNKKKKKKKNNH2 ",
- "1DDDDD7LHHNNMEEEEEE8NNGF2 ",
- "1DDDDDDLHGNNMEJJJJJ8NNGK0 ",
- "1DDDDDDKL8NNMEJJJJJ8NNFK0 ",
- "1DDDDDDHN2LNMEEEEEE8NNAL0 ",
- "1DDDDDDANHANNKKKKKKLNL2M0 ",
- "1DDDDDD3NNAFMNNNNNNNMAHN0 ",
- "1DDDDDD6LNNH2FKLLLLH2ONN0 ",
- "1DDDDDDDKNNNMKFAAAAGLNNN0 ",
- "1DDDDDDD3NNNNNNNNNNNNNNN0 ",
- "122222222AAAAAAAAAAAAAAA0 "};
-
-static char **doc_export_bmap_xpm[3] = { doc_export_bmap_x16, doc_export_bmap_x24, doc_export_bmap_x32 };
-
diff --git a/app/bin/bitmaps/doc-export-dxf.xpm b/app/bin/bitmaps/doc-export-dxf.xpm deleted file mode 100644 index 7ac2c54..0000000 --- a/app/bin/bitmaps/doc-export-dxf.xpm +++ /dev/null @@ -1,100 +0,0 @@ -static char *doc_export_dxf_x16[] = {
- "16 16 7 1",
- " c None",
- "0 c #000000",
- "1 c #666666",
- "2 c #993333",
- "3 c #996666",
- "4 c #CC0000",
- "5 c #CC3333",
- "1111111111111 ",
- "11 11 11 11 1 ",
- "1 1 1 1 1 ",
- "1111111111111 ",
- "11 11 11 11 1 ",
- "1 1 1 1 2 ",
- "11111111111144 ",
- "11 11 112325 44 ",
- "1 1 1 44444444",
- "11111111111144 ",
- "1 1 1 1 4 ",
- "1 1 1 1 1 ",
- "1111111111111 ",
- "1 1 1 1 1 ",
- "1 1 1 1 1 ",
- "1111111111111 "};
-
-static char *doc_export_dxf_x24[] = {
- "24 24 5 1",
- " c None",
- "0 c #000000",
- "1 c #666666",
- "2 c #996666",
- "3 c #CC0000",
- "11111111111111111111 ",
- "11111111111111111111 ",
- "11 1 11 1 11 ",
- "11 1 11 1 11 ",
- "11 1 11 1 11 ",
- "11111111111111111111 ",
- "11 1 11 1 11 ",
- "11 1 11 1 1 ",
- "11 1 11 1 33 ",
- "111111111111111112333 ",
- "11111111111111111 333 ",
- "11 1 11 33333333333 ",
- "11 1 11 33333333333 ",
- "11 1 11 1 333 ",
- "111111111111111112333 ",
- "11 1 11 1 33 ",
- "11 1 11 1 1 ",
- "11 1 11 1 11 ",
- "11111111111111111111 ",
- "11 1 11 1 11 ",
- "11 1 11 1 11 ",
- "11 1 11 1 11 ",
- "11 1 11 1 11 ",
- "11111111111111111111 "};
-
-static char *doc_export_dxf_x32[] = {
- "32 32 5 1",
- " c None",
- "0 c #000000",
- "1 c #666666",
- "2 c #993333",
- "3 c #CC0000",
- " 1 11 11 11 11 ",
- "11111111111111111111111111 ",
- " 1 1 1 11 11 ",
- " 1 1 1 11 11 ",
- " 1 1 1 11 11 ",
- " 1 1 1 11 11 ",
- " 1 11 11 11 11 ",
- "11111111111111111111111111 ",
- " 1 1 1 11 11 ",
- " 1 1 1 11 11 ",
- " 1 1 1 11 ",
- " 1 1 1 11 33 ",
- " 1 11 11 11 333 ",
- "11111111111111111111111 33333 ",
- " 1 1 1 1 3333 ",
- " 1 1 1 333333333333333 ",
- " 1 1 1 333333333333333 ",
- " 1 1 1 32 33333 ",
- " 1 11 11 11 3333 ",
- "1111111111111111111111123333 ",
- " 1 1 1 1 33 ",
- " 1 1 1 1 ",
- " 1 1 1 1 11 ",
- " 1 1 1 1 11 ",
- "11111111111111111111111111 ",
- "11111111111111111111111111 ",
- " 1 1 1 1 11 ",
- " 1 1 1 1 11 ",
- " 1 1 1 1 11 ",
- " 1 1 1 1 11 ",
- " 1111111111111111111111111 ",
- " 1111111111111111111111111 "};
-
-static char **doc_export_dxf_xpm[3] = { doc_export_dxf_x16, doc_export_dxf_x24, doc_export_dxf_x32 };
-
diff --git a/app/bin/bitmaps/doc-export-svg.xpm b/app/bin/bitmaps/doc-export-svg.xpm deleted file mode 100644 index 72c85d3..0000000 --- a/app/bin/bitmaps/doc-export-svg.xpm +++ /dev/null @@ -1,114 +0,0 @@ -static char *doc_export_svg_x16[] = {
- "16 16 10 1",
- " c None",
- "0 c #000000",
- "1 c #003300",
- "2 c #003366",
- "3 c #003399",
- "4 c #006600",
- "5 c #0066CC",
- "6 c #0066FF",
- "7 c #CC0000",
- "8 c #008000",
- " 888 ",
- " 888888400000 ",
- " 8 011 ",
- "88 00 88 ",
- "88 00 88 ",
- "8800 88 7 ",
- " 41 8 77 ",
- " 048888 77777777",
- " 0 77777777",
- " 00 6 77 ",
- " 00 666 7 ",
- " 036 6 ",
- " 300 6 ",
- " 6 00230000 ",
- " 66 32000 ",
- " 666666666 "};
-
-static char *doc_export_svg_x24[] = {
- "24 24 10 1",
- " c None",
- "0 c #000000",
- "1 c #003300",
- "2 c #003366",
- "3 c #003399",
- "4 c #006600",
- "5 c #0066CC",
- "6 c #0066FF",
- "7 c #CC0000",
- "8 c #008000",
- " 888 ",
- " 88888888 ",
- " 888 88840000000 ",
- " 888 0111 ",
- " 88 000 88 ",
- "88 00 88 ",
- "88 00 88 ",
- "88 0 88 ",
- " 8800 88 7 ",
- " 880 88 777 ",
- " 448 888 7777 ",
- " 048888888 77777777777",
- " 0 8888 77777777777",
- " 0 7777 ",
- " 0 66 7777 ",
- " 00 66 7 ",
- " 0 6 6 ",
- " 056 66 ",
- " 520 6 ",
- " 6 000026 ",
- " 6 00002000000 ",
- " 66 5300000 ",
- " 6666666666666 ",
- " 6666666666666 "};
-
-static char *doc_export_svg_x32[] = {
- "32 32 11 1",
- " c None",
- "0 c #000000",
- "1 c #000033",
- "2 c #003300",
- "3 c #003366",
- "4 c #003399",
- "5 c #006600",
- "6 c #0066CC",
- "7 c #0066FF",
- "8 c #CC0000",
- "9 c #008000",
- " 99 ",
- " 99999999 ",
- " 999999999999 00000000 ",
- " 9999 9950000000000 ",
- " 999 0000000 ",
- " 999 0000299 ",
- " 99 00000 99 ",
- "999 0000 99 ",
- "999 0000 99 ",
- "999 000 99 ",
- " 99 000 99 ",
- " 995000 999 88 ",
- " 99200 999 8888 ",
- " 9005 9999 88888 ",
- " 029999999999 88888 ",
- " 002999999999 888888888888888",
- " 000 99999 888888888888888",
- " 000 88888 ",
- " 000 7 88888 ",
- " 000 777 88888 ",
- " 00 77777 88 ",
- " 000 777777 ",
- " 000677 777 ",
- " 0036 777 ",
- " 63000 777 ",
- " 76300000677 ",
- " 777 00000146 ",
- " 777 00000000000000 ",
- " 777 3431000000 ",
- " 777 777 ",
- " 7777777777777777777 ",
- "777777777777777777777 "};
-
-static char **doc_export_svg_xpm[3] = { doc_export_svg_x16, doc_export_svg_x24, doc_export_svg_x32 };
-
diff --git a/app/bin/bitmaps/doc-export-xtc.xpm b/app/bin/bitmaps/doc-export-xtc.xpm deleted file mode 100644 index 6afb7c7..0000000 --- a/app/bin/bitmaps/doc-export-xtc.xpm +++ /dev/null @@ -1,108 +0,0 @@ -static char *doc_export_xtc_x16[] = {
- "16 16 9 1",
- " c None",
- "0 c #000000",
- "1 c #666666",
- "2 c #996666",
- "3 c #CC0000",
- "4 c #CC3333",
- "5 c #CC9999",
- "6 c #FFCCCC",
- "7 c #FFFFFF",
- "111111111111 ",
- "177777777771 ",
- "177777777771 ",
- "177777777771 ",
- "177777777771 ",
- "1777777777713 ",
- "17777777777133 ",
- "1777777755543333",
- "177777776662 33 ",
- "17777777777133 ",
- "1777777777713 ",
- "177777777771 ",
- "177777777771 ",
- "177777777771 ",
- "177777777771 ",
- "111111111111 "};
-
-static char *doc_export_xtc_x24[] = {
- "24 24 7 1",
- " c None",
- "0 c #000000",
- "1 c #666666",
- "2 c #993333",
- "3 c #CC0000",
- "4 c #FFCCCC",
- "5 c #FFFFFF",
- " 1111111111111111 ",
- "15555555555555551 ",
- "15555555555555551 ",
- "15555555555555551 ",
- "15555555555555551 ",
- "15555555555555551 ",
- "15555555555555551 ",
- "15555555555555551 ",
- "15555555555555551 33 ",
- "15555555555555551 3333 ",
- "15555555555555551 3333 ",
- "155555555555433333333333",
- "15555555555544442333333 ",
- "15555555555555551 333 ",
- "15555555555555551 333 ",
- "15555555555555551 3 ",
- "15555555555555551 ",
- "15555555555555551 ",
- "15555555555555551 ",
- "15555555555555551 ",
- "15555555555555551 ",
- "15555555555555551 ",
- "15555555555555551 ",
- " 1111111111111111 "};
-
-static char *doc_export_xtc_x32[] = {
- "32 32 9 1",
- " c None",
- "0 c #000000",
- "1 c #666666",
- "2 c #993333",
- "3 c #CC0000",
- "4 c #CC3333",
- "5 c #CC9999",
- "6 c #FFCCCC",
- "7 c #FFFFFF",
- " ",
- " 1111111111111111111111 ",
- " 1777777777777777777771 ",
- " 1777777777777777777771 ",
- " 1777777777777777777771 ",
- " 1777777777777777777771 ",
- " 1777777777777777777771 ",
- " 1777777777777777777771 ",
- " 1777777777777777777771 ",
- " 1777777777777777777771 ",
- " 1777777777777777777771 ",
- " 1777777777777777777771 333 ",
- " 1777777777777777777771 3333 ",
- " 1777777777777777777771 33333 ",
- " 177777777777777766666233333333 ",
- " 1777777777777776333333333333333",
- " 177777777777777655555433333333 ",
- " 1777777777777777777771 3333 ",
- " 1777777777777777777771 33333 ",
- " 1777777777777777777771 333 ",
- " 1777777777777777777771 3 ",
- " 1777777777777777777771 ",
- " 1777777777777777777771 ",
- " 1777777777777777777771 ",
- " 1777777777777777777771 ",
- " 1777777777777777777771 ",
- " 1777777777777777777771 ",
- " 1777777777777777777771 ",
- " 1777777777777777777771 ",
- " 1777777777777777777771 ",
- " 1111111111111111111111 ",
- " "};
-
-static char **doc_export_xtc_xpm[3] = { doc_export_xtc_x16, doc_export_xtc_x24, doc_export_xtc_x32 };
-
diff --git a/app/bin/bitmaps/doc-export.xpm b/app/bin/bitmaps/doc-export.xpm deleted file mode 100644 index e594e38..0000000 --- a/app/bin/bitmaps/doc-export.xpm +++ /dev/null @@ -1,119 +0,0 @@ -static char *doc_export_x16[] = {
- "16 16 12 1",
- " c None",
- "0 c #000000",
- "1 c #666666",
- "2 c #993333",
- "3 c #999999",
- "4 c #CC0000",
- "5 c #CC6666",
- "6 c #CC9999",
- "7 c #CCCCCC",
- "8 c #FFCCCC",
- "9 c #FFFFFF",
- "A c #C0C0C0",
- "111111111111 ",
- "199999999991 ",
- "199999999991 ",
- "193333333391 ",
- "193777777391 ",
- "1937777773914 ",
- "19377777739144 ",
- "1937777765824444",
- "19377777A582444 ",
- "19377777739144 ",
- "1937777773914 ",
- "193333333391 ",
- "199999999991 ",
- "199999999991 ",
- "199999999991 ",
- "111111111111 "};
-
-static char *doc_export_x24[] = {
- "24 24 12 1",
- " c None",
- "0 c #000000",
- "1 c #666666",
- "2 c #993333",
- "3 c #999999",
- "4 c #CC0000",
- "5 c #CC6666",
- "6 c #CC9999",
- "7 c #CCCCCC",
- "8 c #FFCCCC",
- "9 c #FFFFFF",
- "A c #C0C0C0",
- " 1111111111111111 ",
- "199999999999999991 ",
- "199999999999999991 ",
- "199999999999999991 ",
- "199999999999999991 ",
- "199333333333333991 ",
- "199377777777773991 ",
- "199377777777773991 ",
- "19937777777777399144 ",
- "199377777777773991444 ",
- "199377777777773991 4444 ",
- "199377777777A44444444444",
- "19937777777776588244444 ",
- "199377777777773991 444 ",
- "199377777777773991444 ",
- "199377777777773991 4 ",
- "199377777777773991 ",
- "199333333333333991 ",
- "199999999999999991 ",
- "199999999999999991 ",
- "199999999999999991 ",
- "199999999999999991 ",
- "199999999999999991 ",
- " 1111111111111111 "};
-
-static char *doc_export_x32[] = {
- "32 32 12 1",
- " c None",
- "0 c #000000",
- "1 c #666666",
- "2 c #993333",
- "3 c #999999",
- "4 c #CC0000",
- "5 c #CC3333",
- "6 c #CC6666",
- "7 c #CC9999",
- "8 c #CCCCCC",
- "9 c #FFCCCC",
- "A c #FFFFFF",
- " ",
- " 1111111111111111111111 ",
- " 1AAAAAAAAAAAAAAAAAAAA1 ",
- " 1AAAAAAAAAAAAAAAAAAAA1 ",
- " 1AAAAAAAAAAAAAAAAAAAA1 ",
- " 1AAAAAAAAAAAAAAAAAAAA1 ",
- " 1AAAAAAAAAAAAAAAAAAAA1 ",
- " 1AAA33333333333333AAA1 ",
- " 1AA3888888888888883AA1 ",
- " 1AA3888888888888883AA1 ",
- " 1AA3888888888888883AA1 ",
- " 1AA3888888888888883AA1 444 ",
- " 1AA3888888888888883AA1 4444 ",
- " 1AA3888888888888883AA1 44444 ",
- " 1AA388888888888877699244444444 ",
- " 1AA3888888888888444444444444444",
- " 1AA388888888888866677544444444 ",
- " 1AA3888888888888883AA1 4444 ",
- " 1AA3888888888888883AA1 44444 ",
- " 1AA3888888888888883AA1 444 ",
- " 1AA3888888888888883AA1 4 ",
- " 1AA3888888888888883AA1 ",
- " 1AA3888888888888883AA1 ",
- " 1AA3333333333333333AA1 ",
- " 1AAAAAAAAAAAAAAAAAAAA1 ",
- " 1AAAAAAAAAAAAAAAAAAAA1 ",
- " 1AAAAAAAAAAAAAAAAAAAA1 ",
- " 1AAAAAAAAAAAAAAAAAAAA1 ",
- " 1AAAAAAAAAAAAAAAAAAAA1 ",
- " 1AAAAAAAAAAAAAAAAAAAA1 ",
- " 1111111111111111111111 ",
- " "};
-
-static char **doc_export_xpm[3] = { doc_export_x16, doc_export_x24, doc_export_x32 };
-
diff --git a/app/bin/bitmaps/doc-import-xtc.xpm b/app/bin/bitmaps/doc-import-xtc.xpm deleted file mode 100644 index 4b00631..0000000 --- a/app/bin/bitmaps/doc-import-xtc.xpm +++ /dev/null @@ -1,123 +0,0 @@ -static char *doc_import_xtc_x16[] = {
- "16 16 13 1",
- " c None",
- "0 c #000000",
- "1 c #009933",
- "2 c #336666",
- "3 c #339966",
- "4 c #666666",
- "5 c #669966",
- "6 c #999999",
- "7 c #99CC99",
- "8 c #99CCCC",
- "9 c #CCCCCC",
- "A c #FFFFFF",
- "B c #C0C0C0",
- " 4444444444444",
- " 4AAAAAAAAAAA4",
- " 4AAAAAAAAAAA4",
- " 4AAAAAAAAAAA4",
- " 4AAAAAAAAAAA4",
- " 49AAAAAAAAAA4",
- " 486AAAAAAAAA4",
- "1112B739AAAAAAA4",
- "1112B759AAAAAAA4",
- " 496AAAAAAAAA4",
- " 4BAAAAAAAAAA4",
- " 4AAAAAAAAAAA4",
- " 4AAAAAAAAAAA4",
- " 4AAAAAAAAAAA4",
- " 4AAAAAAAAAAA4",
- " 4444444444444"};
-
-static char *doc_import_xtc_x24[] = {
- "24 24 13 1",
- " c None",
- "0 c #000000",
- "1 c #009933",
- "2 c #336633",
- "3 c #339966",
- "4 c #666666",
- "5 c #669966",
- "6 c #669999",
- "7 c #999999",
- "8 c #99CC99",
- "9 c #CCCCCC",
- "A c #FFFFFF",
- "B c #C0C0C0",
- " 444444444444444444",
- " 4AAAAAAAAAAAAAAAAA4",
- " 4AAAAAAAAAAAAAAAAA4",
- " 4AAAAAAAAAAAAAAAAA4",
- " 4AAAAAAAAAAAAAAAAA4",
- " 4AAAAAAAAAAAAAAAAA4",
- " 4AAAAAAAAAAAAAAAAA4",
- " 4AAAAAAAAAAAAAAAAA4",
- " 498AAAAAAAAAAAAAAA4",
- " 4516AAAAAAAAAAAAAA4",
- " 4A8139AAAAAAAAAAAA4",
- "111111111119AAAAAAAAAAA4",
- "111112775119AAAAAAAAAAA4",
- " 4A7159AAAAAAAAAAAA4",
- " 4517AAAAAAAAAAAAAA4",
- " 49BAAAAAAAAAAAAAAA4",
- " 4AAAAAAAAAAAAAAAAA4",
- " 4AAAAAAAAAAAAAAAAA4",
- " 4AAAAAAAAAAAAAAAAA4",
- " 4AAAAAAAAAAAAAAAAA4",
- " 4AAAAAAAAAAAAAAAAA4",
- " 4AAAAAAAAAAAAAAAAA4",
- " 4AAAAAAAAAAAAAAAAA4",
- " 4444444444444444444"};
-
-static char *doc_import_xtc_x32[] = {
- "32 32 14 1",
- " c None",
- "0 c #000000",
- "1 c #006633",
- "2 c #009933",
- "3 c #339933",
- "4 c #339966",
- "5 c #666666",
- "6 c #669966",
- "7 c #669999",
- "8 c #99CC99",
- "9 c #CCCCCC",
- "A c #CCFFCC",
- "B c #CCFFFF",
- "C c #FFFFFF",
- " 55555555555555555555555 ",
- " 5CCCCCCCCCCCCCCCCCCCCCCC5",
- " 5CCCCCCCCCCCCCCCCCCCCCCC5",
- " 5CCCCCCCCCCCCCCCCCCCCCCC5",
- " 5CCCCCCCCCCCCCCCCCCCCCCC5",
- " 5CCCCCCCCCCCCCCCCCCCCCCC5",
- " 5CCCCCCCCCCCCCCCCCCCCCCC5",
- " 5CCCCCCCCCCCCCCCCCCCCCCC5",
- " 5CCCCCCCCCCCCCCCCCCCCCCC5",
- " 5CCCCCCCCCCCCCCCCCCCCCCC5",
- " 5CCCCCCCCCCCCCCCCCCCCCCC5",
- " 5939CCCCCCCCCCCCCCCCCCCC5",
- " 56228CCCCCCCCCCCCCCCCCCC5",
- " 5C6226CCCCCCCCCCCCCCCCCC5",
- " 59982239CCCCCCCCCCCCCCCC5",
- " 22222222222222BCCCCCCCCCCCCCCC5",
- " 22222222222223CCCCCCCCCCCCCCCC5",
- " 5CC7226ACCCCCCCCCCCCCCCC5",
- " 594228CCCCCCCCCCCCCCCCCC5",
- " 56239CCCCCCCCCCCCCCCCCCC5",
- " 596ACCCCCCCCCCCCCCCCCCCC5",
- " 5CCCCCCCCCCCCCCCCCCCCCCC5",
- " 5CCCCCCCCCCCCCCCCCCCCCCC5",
- " 5CCCCCCCCCCCCCCCCCCCCCCC5",
- " 5CCCCCCCCCCCCCCCCCCCCCCC5",
- " 5CCCCCCCCCCCCCCCCCCCCCCC5",
- " 5CCCCCCCCCCCCCCCCCCCCCCC5",
- " 5CCCCCCCCCCCCCCCCCCCCCCC5",
- " 5CCCCCCCCCCCCCCCCCCCCCCC5",
- " 5CCCCCCCCCCCCCCCCCCCCCCC5",
- " 5CCCCCCCCCCCCCCCCCCCCCCC5",
- " 55555555555555555555555 "};
-
-static char **doc_import_xtc_xpm[3] = { doc_import_xtc_x16, doc_import_xtc_x24, doc_import_xtc_x32 };
-
diff --git a/app/bin/bitmaps/doc-import.xpm b/app/bin/bitmaps/doc-import.xpm deleted file mode 100644 index 0b10537..0000000 --- a/app/bin/bitmaps/doc-import.xpm +++ /dev/null @@ -1,123 +0,0 @@ -static char *doc_import_x16[] = {
- "16 16 13 1",
- " c None",
- "0 c #000000",
- "1 c #009933",
- "2 c #336666",
- "3 c #339966",
- "4 c #666666",
- "5 c #669966",
- "6 c #999999",
- "7 c #99CC99",
- "8 c #99CCCC",
- "9 c #CCCCCC",
- "A c #FFFFFF",
- "B c #C0C0C0",
- " 4444444444444",
- " 4AAAAAAAAAAA4",
- " 4AAAAAAAAAAA4",
- " 4AAAAAAAAAAA4",
- " 4A666666666A4",
- " 49699999996A4",
- " 48599999996A4",
- "1112B537999996A4",
- "1112B537999996A4",
- " 49399999996A4",
- " 4B699999996A4",
- " 4A699999996A4",
- " 4AA66666666A4",
- " 4AAAAAAAAAAA4",
- " 4AAAAAAAAAAA4",
- " 4444444444444"};
-
-static char *doc_import_x24[] = {
- "24 24 12 1",
- " c None",
- "0 c #000000",
- "1 c #009933",
- "2 c #336633",
- "3 c #339966",
- "4 c #666666",
- "5 c #669966",
- "6 c #999999",
- "7 c #99CC99",
- "8 c #CCCCCC",
- "9 c #FFFFFF",
- "A c #C0C0C0",
- " 444444444444444444",
- " 4999999999999999994",
- " 4999999999999999994",
- " 4999999999999999994",
- " 4999999999999999994",
- " 4999999999999999994",
- " 4996666666666666994",
- " 4996888888888886994",
- " 4876888888888886994",
- " 4613888888888886994",
- " 49713A8888888886994",
- "11111111111A888888886994",
- "11111266311A888888886994",
- " 49613A8888888886994",
- " 4515888888888886994",
- " 48A6888888888886994",
- " 4996888888888886994",
- " 4996888888888886994",
- " 4999666666666666994",
- " 4999999999999999994",
- " 4999999999999999994",
- " 4999999999999999994",
- " 4999999999999999994",
- " 4444444444444444444"};
-
-static char *doc_import_x32[] = {
- "32 32 15 1",
- " c None",
- "0 c #000000",
- "1 c #006633",
- "2 c #009933",
- "3 c #339933",
- "4 c #339966",
- "5 c #666666",
- "6 c #669966",
- "7 c #669999",
- "8 c #999999",
- "9 c #99CC99",
- "A c #CCCCCC",
- "B c #CCFFCC",
- "C c #FFFFFF",
- "D c #C0C0C0",
- " 55555555555555555555555 ",
- " 5CCCCCCCCCCCCCCCCCCCCCCC5",
- " 5CCCCCCCCCCCCCCCCCCCCCCC5",
- " 5CCCCCCCCCCCCCCCCCCCCCCC5",
- " 5CCCCCCCCCCCCCCCCCCCCCCC5",
- " 5CCCCCCCCCCCCCCCCCCCCCCC5",
- " 5CCCCCCCCCCCCCCCCCCCCCCC5",
- " 5CCCCCCCCCCCCCCCCCCCCCCC5",
- " 5CCC88888888888888888CCC5",
- " 5CCC8AAAAAAAAAAAAAAA8CCC5",
- " 5CCC8AAAAAAAAAAAAAAA8CCC5",
- " 5B4A8AAAAAAAAAAAAAAA8CCC5",
- " 56226AAAAAAAAAAAAAAA8CCC5",
- " 5C7226DAAAAAAAAAAAAA8CCC5",
- " 5AA92239AAAAAAAAAAAA8CCC5",
- " 22222222222222DAAAAAAAAAAA8CCC5",
- " 22222222222222DAAAAAAAAAAA8CCC5",
- " 5CC7224DAAAAAAAAAAAA8CCC5",
- " 5A4226AAAAAAAAAAAAAA8CCC5",
- " 56226AAAAAAAAAAAAAAA8CCC5",
- " 5A6B8AAAAAAAAAAAAAAA8CCC5",
- " 5CCC8AAAAAAAAAAAAAAA8CCC5",
- " 5CCC8AAAAAAAAAAAAAAA8CCC5",
- " 5CCC8AAAAAAAAAAAAAAA8CCC5",
- " 5CCC88888888888888888CCC5",
- " 5CCCCCCCCCCCCCCCCCCCCCCC5",
- " 5CCCCCCCCCCCCCCCCCCCCCCC5",
- " 5CCCCCCCCCCCCCCCCCCCCCCC5",
- " 5CCCCCCCCCCCCCCCCCCCCCCC5",
- " 5CCCCCCCCCCCCCCCCCCCCCCC5",
- " 5CCCCCCCCCCCCCCCCCCCCCCC5",
- " 55555555555555555555555 "};
-
-static char **doc_import_xpm[3] = { doc_import_x16, doc_import_x24, doc_import_x32 };
-
diff --git a/app/bin/bitmaps/doc-new.xpm b/app/bin/bitmaps/doc-new.xpm deleted file mode 100644 index cd4dbc1..0000000 --- a/app/bin/bitmaps/doc-new.xpm +++ /dev/null @@ -1,127 +0,0 @@ -static char *doc_new_x16[] = {
- "16 16 15 1",
- " c None",
- "0 c #000000",
- "1 c #009933",
- "2 c #00CC33",
- "3 c #00CC66",
- "4 c #00FF66",
- "5 c #33CC66",
- "6 c #666666",
- "7 c #669966",
- "8 c #66CC99",
- "9 c #99CC99",
- "A c #CCCCCC",
- "B c #CCFFCC",
- "C c #FFFFFF",
- "D c #C0C0C0",
- " 666666666666 ",
- " 6CCA9CCCCCC6 ",
- " 6CC52ACCCCC6 ",
- " 6D71278CCCC6 ",
- " 6544444BCCC6 ",
- " 6AD139DCCCC6 ",
- " 6CC12ACCCCC6 ",
- " 6CCA9CCCCCC6 ",
- " 6CCCCCCCCCC6 ",
- " 6CCCCCCCCCC6 ",
- " 6CCCCCCCCCC6 ",
- " 6CCCCCCCCCC6 ",
- " 6CCCCCCCCCC6 ",
- " 6CCCCCCCCCC6 ",
- " 6CCCCCCCCCC6 ",
- " 666666666666 "};
-
-static char *doc_new_x24[] = {
- "24 24 14 1",
- " c None",
- "0 c #000000",
- "1 c #009933",
- "2 c #00CC33",
- "3 c #00CC66",
- "4 c #00FF66",
- "5 c #33CC66",
- "6 c #666666",
- "7 c #66CC66",
- "8 c #66CC99",
- "9 c #99CC99",
- "A c #CCCCCC",
- "B c #CCFFCC",
- "C c #FFFFFF",
- " 666666666666666666 ",
- " 6CCCCCCCCCCCCCCCC6 ",
- " 6CCCC87ACCCCCCCCC6 ",
- " 6CCCC347CCCCCCCCC6 ",
- " 6CCCC547CCCCCCCCC6 ",
- " 6C87734211ACCCCCC6 ",
- " 6C344444449CCCCCC6 ",
- " 6C522342229CCCCCC6 ",
- " 6CCCB547CCCCCCCCC6 ",
- " 6CCCB547CCCCCCCCC6 ",
- " 6CCCC779CCCCCCCCC6 ",
- " 6CCCCCCCCCCCCCCCC6 ",
- " 6CCCCCCCCCCCCCCCC6 ",
- " 6CCCCCCCCCCCCCCCC6 ",
- " 6CCCCCCCCCCCCCCCC6 ",
- " 6CCCCCCCCCCCCCCCC6 ",
- " 6CCCCCCCCCCCCCCCC6 ",
- " 6CCCCCCCCCCCCCCCC6 ",
- " 6CCCCCCCCCCCCCCCC6 ",
- " 6CCCCCCCCCCCCCCCC6 ",
- " 6CCCCCCCCCCCCCCCC6 ",
- " 6CCCCCCCCCCCCCCCC6 ",
- " 6CCCCCCCCCCCCCCCC6 ",
- " 666666666666666666 "};
-
-static char *doc_new_x32[] = {
- "32 32 15 1",
- " c None",
- "0 c #000000",
- "1 c #009933",
- "2 c #00CC33",
- "3 c #00FF66",
- "4 c #339933",
- "5 c #666666",
- "6 c #669966",
- "7 c #66CC99",
- "8 c #99CC99",
- "9 c #CCCCCC",
- "A c #CCFFCC",
- "B c #CCFFFF",
- "C c #FFFFFF",
- "D c #C0C0C0",
- " 555555555555555555555555 ",
- " 5CCCCCCCCCCCCCCCCCCCCCC5 ",
- " 5CCCCCCCCCCCCCCCCCCCCCC5 ",
- " 5CCCCC8111DCCCCCCCCCCCC5 ",
- " 5CCCCC8232DCCCCCCCCCCCC5 ",
- " 5CCCCC8232DCCCCCCCCCCCC5 ",
- " 5CCAAA82328AAACCCCCCCCC5 ",
- " 5C822223322221ACCCCCCCC5 ",
- " 5C823333333332ACCCCCCCC5 ",
- " 5C823333333332ACCCCCCCC5 ",
- " 5C988842326888BCCCCCCCC5 ",
- " 5CCCCC62329CCCCCCCCCCCC5 ",
- " 5CCCCC72329CCCCCCCCCCCC5 ",
- " 5CCCCC82229CCCCCCCCCCCC5 ",
- " 5CCCCC9DDDBCCCCCCCCCCCC5 ",
- " 5CCCCCCCCCCCCCCCCCCCCCC5 ",
- " 5CCCCCCCCCCCCCCCCCCCCCC5 ",
- " 5CCCCCCCCCCCCCCCCCCCCCC5 ",
- " 5CCCCCCCCCCCCCCCCCCCCCC5 ",
- " 5CCCCCCCCCCCCCCCCCCCCCC5 ",
- " 5CCCCCCCCCCCCCCCCCCCCCC5 ",
- " 5CCCCCCCCCCCCCCCCCCCCCC5 ",
- " 5CCCCCCCCCCCCCCCCCCCCCC5 ",
- " 5CCCCCCCCCCCCCCCCCCCCCC5 ",
- " 5CCCCCCCCCCCCCCCCCCCCCC5 ",
- " 5CCCCCCCCCCCCCCCCCCCCCC5 ",
- " 5CCCCCCCCCCCCCCCCCCCCCC5 ",
- " 5CCCCCCCCCCCCCCCCCCCCCC5 ",
- " 5CCCCCCCCCCCCCCCCCCCCCC5 ",
- " 5CCCCCCCCCCCCCCCCCCCCCC5 ",
- " 5CCCCCCCCCCCCCCCCCCCCCC5 ",
- " 555555555555555555555555 "};
-
-static char **doc_new_xpm[3] = { doc_new_x16, doc_new_x24, doc_new_x32 };
-
diff --git a/app/bin/bitmaps/doc-open.xpm b/app/bin/bitmaps/doc-open.xpm deleted file mode 100644 index 992c9bf..0000000 --- a/app/bin/bitmaps/doc-open.xpm +++ /dev/null @@ -1,136 +0,0 @@ -static char *doc_open_x16[] = {
- "16 16 17 1",
- " c None",
- "0 c #000000",
- "1 c #663300",
- "2 c #666600",
- "3 c #666633",
- "4 c #996633",
- "5 c #996666",
- "6 c #999966",
- "7 c #999999",
- "8 c #CC9966",
- "9 c #CCCC66",
- "A c #CCCC99",
- "B c #CCCCCC",
- "C c #FFCC99",
- "D c #FFFFFF",
- "E c #C0C0C0",
- "F c #808080",
- " ",
- " ",
- "2466666677F ",
- "3C7BBBBBBBE7431 ",
- "3C7DDDDDDDDBA61 ",
- "3C7DDDDDDDDD761 ",
- "3C51111111111113",
- "3A3CCCCCCCCCCCC3",
- "386CCCCCCCCCCC93",
- "369CCCCCCCCCCC81",
- "33CCCCCCCCCCCC4 ",
- "24CCCCCCCCCCCC2 ",
- "28CCCCCCCCCCCC3 ",
- "368888888888862 ",
- "222222222222221 ",
- " "};
-
-static char *doc_open_x24[] = {
- "24 24 18 1",
- " c None",
- "0 c #000000",
- "1 c #663300",
- "2 c #666600",
- "3 c #666633",
- "4 c #666666",
- "5 c #996633",
- "6 c #996666",
- "7 c #999933",
- "8 c #999966",
- "9 c #999999",
- "A c #CC9966",
- "B c #CC9999",
- "C c #CCCC66",
- "D c #CCCC99",
- "E c #FFCC99",
- "F c #FFFFFF",
- "G c #C0C0C0",
- " ",
- " ",
- " ",
- "355888888869 ",
- "3CE9GGGGGGGGGGG941111 ",
- "3CE9FFFFFFFFFFFFBBAA51 ",
- "3CE9FFFFFFFFFFFFFGDE81 ",
- "3CE9FFFFFFFFFFFFFFGE81 ",
- "3CE9FFFFFFFFFFFFFFGE81 ",
- "3CE988888888888888675333",
- "3CE5CDDDDDDDDDDDDDDDDDA3",
- "3CE3EEEEEEEEEEEEEEEEEEA1",
- "3CC8EEEEEEEEEEEEEEEEEE5 ",
- "3CACEEEEEEEEEEEEEEEEEE2 ",
- "3C5EEEEEEEEEEEEEEEEEEE3 ",
- "3A5EEEEEEEEEEEEEEEEEEA3 ",
- "3A8EEEEEEEEEEEEEEEEEE71 ",
- "37CEEEEEEEEEEEEEEEEEE3 ",
- "33EEEEEEEEEEEEEEEEEEE3 ",
- "35EEEEEEEEEEEEEEEEEEC3 ",
- "25AAAAAAAAAAAAAAAAAA71 ",
- "222222222222222222222 ",
- " ",
- " "};
-
-static char *doc_open_x32[] = {
- "32 32 18 1",
- " c None",
- "0 c #000000",
- "1 c #663300",
- "2 c #666600",
- "3 c #666633",
- "4 c #996633",
- "5 c #996666",
- "6 c #999933",
- "7 c #999966",
- "8 c #999999",
- "9 c #CC9966",
- "A c #CC9999",
- "B c #CCCC66",
- "C c #CCCC99",
- "D c #CCCCCC",
- "E c #FFCC99",
- "F c #FFFFFF",
- "G c #C0C0C0",
- " ",
- " ",
- " ",
- " ",
- "134444444444433 ",
- "17EECGGGGGGGGG8888888 ",
- "17EEGDFFFFFFFFFFFFFFD8311112 ",
- "17EEGFFFFFFFFFFFFFFFFFAEEEE4 ",
- "17EEGFFFFFFFFFFFFFFFFFFAEEE4 ",
- "17EEGFFFFFFFFFFFFFFFFFFFGEE4 ",
- "17EEGFFFFFFFFFFFFFFFFFFFDCE4 ",
- "17EEGFFFFFFFFFFFFFFFFFFFDCE4 ",
- "17EEGGGGGGGGGGGGGGGGGGGG8793111 ",
- "17EE7799999999999999999999999941",
- "17EE5CEEEEEEEEEEEEEEEEEEEEEEEE4 ",
- "17EE3EEEEEEEEEEEEEEEEEEEEEEEEE2 ",
- "17EC6EEEEEEEEEEEEEEEEEEEEEEEEE3 ",
- "17E99EEEEEEEEEEEEEEEEEEEEEEEEB3 ",
- "17E4EEEEEEEEEEEEEEEEEEEEEEEEE71 ",
- "17E3EEEEEEEEEEEEEEEEEEEEEEEEE4 ",
- "17B7EEEEEEEEEEEEEEEEEEEEEEEEE2 ",
- "1799EEEEEEEEEEEEEEEEEEEEEEEEB3 ",
- "174EEEEEEEEEEEEEEEEEEEEEEEEE92 ",
- "174EEEEEEEEEEEEEEEEEEEEEEEEE61 ",
- "147EEEEEEEEEEEEEEEEEEEEEEEEE2 ",
- "14BEEEEEEEEEEEEEEEEEEEEEEEEE3 ",
- "13EEEEEEEEEEEEEEEEEEEEEEEEEB3 ",
- "12999999999999999999999999941 ",
- " 222222222222222222222222222 ",
- " ",
- " ",
- " "};
-
-static char **doc_open_xpm[3] = { doc_open_x16, doc_open_x24, doc_open_x32 };
-
diff --git a/app/bin/bitmaps/doc-print.xpm b/app/bin/bitmaps/doc-print.xpm deleted file mode 100644 index 853014f..0000000 --- a/app/bin/bitmaps/doc-print.xpm +++ /dev/null @@ -1,108 +0,0 @@ -static char *doc_print_x16[] = {
- "16 16 8 1",
- " c None",
- "0 c #000000",
- "1 c #666666",
- "2 c #999999",
- "3 c #CCCCCC",
- "4 c #FFFFFF",
- "5 c #C0C0C0",
- "6 c #808080",
- " 111111111111 ",
- " 144444444441 ",
- " 144444444441 ",
- " 144444444441 ",
- " 144444444441 ",
- " 666666666666666",
- "6255555555555556",
- "6333333333333336",
- "6333333333333336",
- "6333333333333336",
- "6311111111111136",
- "6316111111654136",
- "6512666666624136",
- "6616111111165166",
- " 166666666341 ",
- " 111111111111 "};
-
-static char *doc_print_x24[] = {
- "24 24 8 1",
- " c None",
- "0 c #000000",
- "1 c #666666",
- "2 c #999999",
- "3 c #CCCCCC",
- "4 c #FFFFFF",
- "5 c #C0C0C0",
- "6 c #808080",
- " 1111111111111111 ",
- " 144444444444444441 ",
- " 144444444444444441 ",
- " 144444444444444441 ",
- " 144444444444444441 ",
- " 144444444444444441 ",
- " 144444444444444441 ",
- " 144444444444444441 ",
- " 6666666666666666666666 ",
- "625555555555555555555526",
- "653333333333333333333356",
- "653333333333333333333356",
- "653333333333333333333356",
- "653333333333333333333356",
- "653333333333333333333356",
- "653111111111111111111356",
- "653136666666666634441356",
- "653142222222222255441356",
- "653142222222222225441356",
- "662136666666666664441266",
- " 136666666666666241 ",
- " 142222222222233441 ",
- " 145555555555544441 ",
- " 1111111111111111 "};
-
-static char *doc_print_x32[] = {
- "32 32 9 1",
- " c None",
- "0 c #000000",
- "1 c #333333",
- "2 c #666666",
- "3 c #999999",
- "4 c #CCCCCC",
- "5 c #FFFFFF",
- "6 c #C0C0C0",
- "7 c #808080",
- " ",
- " 2222222222222222222222 ",
- " 2555555555555555555552 ",
- " 2555555555555555555552 ",
- " 2555555555555555555552 ",
- " 2555555555555555555552 ",
- " 2555555555555555555552 ",
- " 2555555555555555555552 ",
- " 2555555555555555555552 ",
- " 2555555555555555555552 ",
- " 2555555555555555555552 ",
- " 777777777777777777777777777777 ",
- " 7666666666666666666666666666677",
- " 3444444444444444444444444444437",
- " 3444444444444444444444444444437",
- " 3444444444444444444444444444437",
- " 3444444444444444444444444444437",
- " 3444444444444444444444444444437",
- " 3444444444444444444444444444437",
- " 3444444444444444444444444444437",
- " 3444222222222222222222222244437",
- " 3444254444444444444455555244437",
- " 3444267777777777777765555244437",
- " 3444246666666666666666655244437",
- " 3444246666666666666666655244437",
- " 7444267777777777777773555244437",
- " 777725444444444444444555527777 ",
- " 2311111111111111111152 ",
- " 2544444444444444555552 ",
- " 2377777777777777455552 ",
- " 2222222222222222222222 ",
- " "};
-
-static char **doc_print_xpm[3] = { doc_print_x16, doc_print_x24, doc_print_x32 };
-
diff --git a/app/bin/bitmaps/doc-revert.xpm b/app/bin/bitmaps/doc-revert.xpm deleted file mode 100644 index 4af778a..0000000 --- a/app/bin/bitmaps/doc-revert.xpm +++ /dev/null @@ -1,134 +0,0 @@ -static char *doc_revert_x16[] = {
- "16 16 17 1",
- " c None",
- "0 c #000000",
- "1 c #666666",
- "2 c #996633",
- "3 c #CC6633",
- "4 c #CC9900",
- "5 c #CC9933",
- "6 c #CC9966",
- "7 c #CC9999",
- "8 c #CCCC33",
- "9 c #CCCC99",
- "A c #CCCCCC",
- "B c #FFCC00",
- "C c #FFCC33",
- "D c #FFCCCC",
- "E c #FFFFCC",
- "F c #FFFFFF",
- " 111111111111 ",
- " 1FFFFFFFFFF1 ",
- " 1FFFFFFFFFF1 ",
- " 1FFFADFFFFF1 ",
- " 1FF639FFFFF1 ",
- " 1D5BB529FFF1 ",
- " 1F65B5B86FF1 ",
- " 1FF93665C7F1 ",
- " 1FFFDAFA55E1 ",
- " 1FFFFFFF7491 ",
- " 1FFFFFFFD561 ",
- " 1FFFFFFFF251 ",
- " 1FFFFFFFF621 ",
- " 1FFFFFFFFFF1 ",
- " 1FFFFFFFFFF1 ",
- " 111111111111 "};
-
-static char *doc_revert_x24[] = {
- "24 24 17 1",
- " c None",
- "0 c #000000",
- "1 c #666666",
- "2 c #996600",
- "3 c #996633",
- "4 c #CC6633",
- "5 c #CC9900",
- "6 c #CC9933",
- "7 c #CC9966",
- "8 c #CC9999",
- "9 c #CCCC99",
- "A c #CCCCCC",
- "B c #FFCC00",
- "C c #FFCC33",
- "D c #FFCCCC",
- "E c #FFFFCC",
- "F c #FFFFFF",
- " 111111111111111111 ",
- " 1FFFFFFFFFFFFFFFF1 ",
- " 1FFFFFFFFFFFFFFFF1 ",
- " 1FFFFFFFFFFFFFFFF1 ",
- " 1FFFFFFFFFFFFFFFF1 ",
- " 1FFFFFD8FFFFFFFFF1 ",
- " 1FFFF863FFFFFFFFF1 ",
- " 1FFD6CB37AFFFFFFF1 ",
- " 1FA6BBBBB568FFFFF1 ",
- " 1FF76BBBBBBB7FFFF1 ",
- " 1FFFA6B2736BB7FFF1 ",
- " 1FFFFE72FF96B69FF1 ",
- " 1FFFFFF9FFF96B3FF1 ",
- " 1FFFFFFFFFFF7B6DF1 ",
- " 1FFFFFFFFFFFD6B8F1 ",
- " 1FFFFFFFFFFFF7B3F1 ",
- " 1FFFFFFFFFFFFA62F1 ",
- " 1FFFFFFFFFFFFE66F1 ",
- " 1FFFFFFFFFFFFF34E1 ",
- " 1FFFFFFFFFFFFFAAF1 ",
- " 1FFFFFFFFFFFFFFFF1 ",
- " 1FFFFFFFFFFFFFFFF1 ",
- " 1FFFFFFFFFFFFFFFF1 ",
- " 111111111111111111 "};
-
-static char *doc_revert_x32[] = {
- "32 32 17 1",
- " c None",
- "0 c #000000",
- "1 c #666666",
- "2 c #996600",
- "3 c #996633",
- "4 c #CC6633",
- "5 c #CC9900",
- "6 c #CC9933",
- "7 c #CC9966",
- "8 c #CC9999",
- "9 c #CCCC99",
- "A c #CCCCCC",
- "B c #FFCC00",
- "C c #FFCC33",
- "D c #FFCCCC",
- "E c #FFFFCC",
- "F c #FFFFFF",
- " 111111111111111111111111 ",
- " 1FFFFFFFFFFFFFFFFFFFFFF1 ",
- " 1FFFFFFFFFFFFFFFFFFFFFF1 ",
- " 1FFFFFFFFFFFFFFFFFFFFFF1 ",
- " 1FFFFFFFFFFFFFFFFFFFFFF1 ",
- " 1FFFFFFFFFFFFFFFFFFFFFF1 ",
- " 1FFFFFFFFFFFFFFFFFFFFFF1 ",
- " 1FFFFFFFE7DFFFFFFFFFFFF1 ",
- " 1FFFFFF965AFFFFFFFFFFFF1 ",
- " 1FFFFE76B59FFFFFFFFFFFF1 ",
- " 1FFF96BBBB6328FFFFFFFFF1 ",
- " 1FF86BBBBBBBBB68FFFFFFF1 ",
- " 1FFF76BBBBBBBBBC7FFFFFF1 ",
- " 1FFFFA6BB5266BBBB7FFFFF1 ",
- " 1FFFFFF7C5AFA66BBC8FFFF1 ",
- " 1FFFFFFF849FFF96BB6DFFF1 ",
- " 1FFFFFFFFAAFFFF96BB7FFF1 ",
- " 1FFFFFFFFFFFFFFF7BB6FFF1 ",
- " 1FFFFFFFFFFFFFFFF6B6AFF1 ",
- " 1FFFFFFFFFFFFFFFF7BB7FF1 ",
- " 1FFFFFFFFFFFFFFFFD6B3FF1 ",
- " 1FFFFFFFFFFFFFFFFF3B3FF1 ",
- " 1FFFFFFFFFFFFFFFFF8B6FF1 ",
- " 1FFFFFFFFFFFFFFFFFA66DF1 ",
- " 1FFFFFFFFFFFFFFFFFD66AF1 ",
- " 1FFFFFFFFFFFFFFFFFF87EF1 ",
- " 1FFFFFFFFFFFFFFFFFFFFFF1 ",
- " 1FFFFFFFFFFFFFFFFFFFFFF1 ",
- " 1FFFFFFFFFFFFFFFFFFFFFF1 ",
- " 1FFFFFFFFFFFFFFFFFFFFFF1 ",
- " 1FFFFFFFFFFFFFFFFFFFFFF1 ",
- " 111111111111111111111111 "};
-
-static char **doc_revert_xpm[3] = { doc_revert_x16, doc_revert_x24, doc_revert_x32 };
-
diff --git a/app/bin/bitmaps/doc-save-as.xpm b/app/bin/bitmaps/doc-save-as.xpm deleted file mode 100644 index 2ded960..0000000 --- a/app/bin/bitmaps/doc-save-as.xpm +++ /dev/null @@ -1,135 +0,0 @@ -static char *doc_save_as_x16[] = {
- "16 16 15 1",
- " c None",
- "0 c #000000",
- "1 c #0066FF",
- "2 c #333333",
- "3 c #333366",
- "4 c #336666",
- "5 c #666666",
- "6 c #666699",
- "7 c #669999",
- "8 c #6699CC",
- "9 c #996666",
- "A c #999966",
- "B c #9999CC",
- "C c #CC9966",
- "D c #FFCC66",
- " ",
- "111111 ",
- "11111111 ",
- "111111111 ",
- " 1111 1 ",
- " 111111 95 ",
- " 111111 9DC5",
- " 1111 9DD9 ",
- " 1169DD9 ",
- "2222222235DD9222",
- "267B67B65CA98772",
- "236736735C557442",
- "2367367356547442",
- "2367367367447442",
- "2222222222222222",
- " "};
-
-static char *doc_save_as_x24[] = {
- "24 24 18 1",
- " c None",
- "0 c #000000",
- "1 c #0066FF",
- "2 c #333333",
- "3 c #333366",
- "4 c #336666",
- "5 c #666666",
- "6 c #666699",
- "7 c #669999",
- "8 c #6699CC",
- "9 c #996666",
- "A c #999966",
- "B c #9999CC",
- "C c #99CCCC",
- "D c #CC9966",
- "E c #FF9966",
- "F c #FFCC66",
- "G c #808080",
- " ",
- " ",
- "11111111111 ",
- "111111111111 ",
- "1111111111111 ",
- " 11111 ",
- " 1111 ",
- " 1111111111 55 ",
- " 1111111111 5DA5 ",
- " 11111111 5DFFA5",
- " 111111 5DFFE9 ",
- " 11111 5DFFE9 ",
- " 1111 5DFFF9 ",
- " 11 5DFFF9 ",
- "22222222222225AFFF922222",
- "2C7C7C6C7C88GDDAF9C7CC72",
- "286B4C0C4B775FFDG4C68862",
- "286B4C0C4B775DD9C3C68862",
- "286B4C0C4B777574C3C68862",
- "286B4C0C4B77B4C3C3C68862",
- "287C5C2C5C77C5C4C4C78872",
- "222222222222222222222222",
- " ",
- " "};
-
-static char *doc_save_as_x32[] = {
- "32 32 19 1",
- " c None",
- "0 c #000000",
- "1 c #0066FF",
- "2 c #333333",
- "3 c #333366",
- "4 c #336666",
- "5 c #666666",
- "6 c #666699",
- "7 c #669999",
- "8 c #6699CC",
- "9 c #996666",
- "A c #999966",
- "B c #999999",
- "C c #9999CC",
- "D c #99CCCC",
- "E c #CC9966",
- "F c #FF9966",
- "G c #FFCC66",
- "H c #808080",
- " ",
- " ",
- " 111111 ",
- " 1111111111111 ",
- " 111111111111111 ",
- " 1111111111111111 ",
- " 1111111111111111 ",
- " 111111 ",
- " 11111 ",
- " 111 1111 111 5 ",
- " 111111111111 5A5 ",
- " 111111111111 5EGE5 ",
- " 1111111111 5EGGGE5 ",
- " 1111111111 5EGGGGF9 ",
- " 11111111 5EGGGGF9 ",
- " 111111 5EGGGGF9 ",
- " 11111 5EGGGGF9 ",
- " 1111 5EGGGGF9 ",
- " 222222222222222325EGGGGF922222 ",
- "2DDDDDDDDDDDDDDDDB9EGGGFHDDDDDD2",
- "2D8DD8DD8DD7DD7DBEGEEGFHDD7DD7D2",
- "2D4CD4CD4CD3DD3DHFGGEEH2DD0DD0D2",
- "2D4CD4CD4CD3DD3DHFGGFHD0DD0DD0D2",
- "2D4CD4CD4CD3DD3DHEEE5DD0DD0DD0D2",
- "2D4CD4CD4CD3DD3DC57B2DD0DD0DD0D2",
- "2D4CD4CD4CD3DD3DD3DD0DD0DD0DD0D2",
- "2D4CD4CD4CD3DD3DD3DD0DD0DD0DD0D2",
- "2D6DD6DD6DD4DD4DD4DD3DD3DD3DD3D2",
- "2DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD2",
- "22222222222222222222222222222222",
- " ",
- " "};
-
-static char **doc_save_as_xpm[3] = { doc_save_as_x16, doc_save_as_x24, doc_save_as_x32 };
-
diff --git a/app/bin/bitmaps/doc-save.xpm b/app/bin/bitmaps/doc-save.xpm deleted file mode 100644 index f775f95..0000000 --- a/app/bin/bitmaps/doc-save.xpm +++ /dev/null @@ -1,116 +0,0 @@ -static char *doc_save_x16[] = {
- "16 16 10 1",
- " c None",
- "0 c #000000",
- "1 c #0066FF",
- "2 c #333333",
- "3 c #333366",
- "4 c #336666",
- "5 c #666699",
- "6 c #669999",
- "7 c #6699CC",
- "8 c #9999CC",
- " ",
- "111111 ",
- "11111111 ",
- "111111111 ",
- " 1111 1 ",
- " 111111 ",
- " 111111 ",
- " 1111 ",
- " 11 ",
- "2222222232222222",
- "2568568567668662",
- "2356356356446442",
- "2356356356446442",
- "2356356356446442",
- "2222222222222222",
- " "};
-
-static char *doc_save_x24[] = {
- "24 24 12 1",
- " c None",
- "0 c #000000",
- "1 c #0066FF",
- "2 c #333333",
- "3 c #333366",
- "4 c #336666",
- "5 c #666666",
- "6 c #666699",
- "7 c #669999",
- "8 c #6699CC",
- "9 c #9999CC",
- "A c #99CCCC",
- " ",
- " ",
- "11111111111 ",
- "111111111111 ",
- "1111111111111 ",
- " 11111 ",
- " 1111 ",
- " 1111111111 ",
- " 1111111111 ",
- " 11111111 ",
- " 111111 ",
- " 11111 ",
- " 1111 ",
- " 11 ",
- "222222222222222222222222",
- "2A7A7A6A7A88A7A7A7A7AA72",
- "28694A0A497794A3A3A68862",
- "28694A0A497794A3A3A68862",
- "28694A0A497794A3A3A68862",
- "28694A0A497794A3A3A68862",
- "287A5A2A5A77A5A4A4A78872",
- "222222222222222222222222",
- " ",
- " "};
-
-static char *doc_save_x32[] = {
- "32 32 11 1",
- " c None",
- "0 c #000000",
- "1 c #0066FF",
- "2 c #333333",
- "3 c #333366",
- "4 c #336666",
- "5 c #666699",
- "6 c #669999",
- "7 c #6699CC",
- "8 c #9999CC",
- "9 c #99CCCC",
- " ",
- " ",
- " 111111 ",
- " 1111111111111 ",
- " 111111111111111 ",
- " 1111111111111111 ",
- " 1111111111111111 ",
- " 111111 ",
- " 11111 ",
- " 111 1111 111 ",
- " 111111111111 ",
- " 111111111111 ",
- " 1111111111 ",
- " 1111111111 ",
- " 11111111 ",
- " 111111 ",
- " 11111 ",
- " 1111 ",
- " 222222222222222322222222222222 ",
- "29999999999999999999999999999992",
- "29799799799699699699699699699692",
- "29489489489399399399099099099092",
- "29489489489399399399099099099092",
- "29489489489399399399099099099092",
- "29489489489399399399099099099092",
- "29489489489399399399099099099092",
- "29489489489399399399099099099092",
- "29599599599499499499399399399392",
- "29999999999999999999999999999992",
- "22222222222222222222222222222222",
- " ",
- " "};
-
-static char **doc_save_xpm[3] = { doc_save_x16, doc_save_x24, doc_save_x32 };
-
diff --git a/app/bin/bitmaps/doc-setup.xpm b/app/bin/bitmaps/doc-setup.xpm deleted file mode 100644 index c6c8e48..0000000 --- a/app/bin/bitmaps/doc-setup.xpm +++ /dev/null @@ -1,110 +0,0 @@ -static char *doc_setup_x16[] = {
- "16 16 9 1",
- " c None",
- "0 c #000000",
- "1 c #333333",
- "2 c #666666",
- "3 c #999999",
- "4 c #CCCCCC",
- "5 c #FFFFFF",
- "6 c #C0C0C0",
- "7 c #808080",
- "22222222222 ",
- "25555555552 ",
- "25555555552 ",
- "25555555552 ",
- "25555555552 ",
- "25555555552 ",
- "255555552222222 ",
- "255555552555552 ",
- "255555552555552 ",
- "2555555477777777",
- "2555554366666667",
- "2555554644444443",
- "2555554622222223",
- "2222227311111723",
- " 711111227",
- " 1111122 "};
-
-static char *doc_setup_x24[] = {
- "24 24 9 1",
- " c None",
- "0 c #000000",
- "1 c #333333",
- "2 c #666666",
- "3 c #999999",
- "4 c #CCCCCC",
- "5 c #FFFFFF",
- "6 c #C0C0C0",
- "7 c #808080",
- "2222222222222222 ",
- "2555555555555552 ",
- "2555555555555552 ",
- "2555555555555552 ",
- "2555555555555552 ",
- "2555555555555552 ",
- "2555555555555552 ",
- "2555555555555552 ",
- "2555555555555552 ",
- "2555555555552222222222 ",
- "2555555555552555555552 ",
- "2555555555552555555552 ",
- "2555555555552555555552 ",
- "2555555555552555555552 ",
- "255555555544777777777777",
- "255555555576666666666667",
- "255555555574444444444443",
- "255555555574444444444443",
- "255555555574222222222243",
- "255555555574277777735243",
- "222222222274111111112247",
- " 77222222223277",
- " 1222222762 ",
- " 2222222222 "};
-
-static char *doc_setup_x32[] = {
- "32 32 9 1",
- " c None",
- "0 c #000000",
- "1 c #333333",
- "2 c #666666",
- "3 c #999999",
- "4 c #CCCCCC",
- "5 c #FFFFFF",
- "6 c #C0C0C0",
- "7 c #808080",
- " 22222222222222222222 ",
- "2555555555555555555552 ",
- "2555555555555555555552 ",
- "2555555555555555555552 ",
- "2555555555555555555552 ",
- "2555555555555555555552 ",
- "2555555555555555555552 ",
- "2555555555555555555552 ",
- "2555555555555555555552 ",
- "2555555555555555555552 ",
- "2555555555555555555552 ",
- "2555555555555555555552 ",
- "2555555555555555555552 ",
- "255555555555555522222222222222 ",
- "255555555555555525555555555552 ",
- "255555555555555525555555555552 ",
- "255555555555555525555555555552 ",
- "255555555555555525555555555552 ",
- "255555555555555525555555555552 ",
- "25555555555554447777777777777777",
- "25555555555556366666666666666667",
- "25555555555556644444444444444447",
- "25555555555556644444444444444447",
- "25555555555556644444444444444447",
- "25555555555556642222222222222447",
- "25555555555556642444444444555247",
- "25555555555556642777777777455247",
- " 2222222222227342777777777735247",
- " 7772777777777745277",
- " 27777777777742 ",
- " 21111111125552 ",
- " 22222222222222 "};
-
-static char **doc_setup_xpm[3] = { doc_setup_x16, doc_setup_x24, doc_setup_x32 };
-
diff --git a/app/bin/bitmaps/down.xpm b/app/bin/bitmaps/down.xpm deleted file mode 100644 index 8edaca4..0000000 --- a/app/bin/bitmaps/down.xpm +++ /dev/null @@ -1,89 +0,0 @@ -static char *down_x16[] = {
- "8 16 2 1",
- " c None",
- "0 c #000000",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " 000000 ",
- " 000000 ",
- " 0000 ",
- " 00 ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " "};
-
-static char *down_x24[] = {
- "12 24 2 1",
- " c None",
- "0 c #000000",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " 0000000000 ",
- " 0000000000 ",
- " 0000000000 ",
- " 00000000 ",
- " 000000 ",
- " 0000 ",
- " 00 ",
- " 0 ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " "};
-
-static char *down_x32[] = {
- "16 32 2 1",
- " c None",
- "0 c #000000",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " 0000000000000 ",
- " 0000000000000 ",
- " 0000000000000 ",
- " 000000000000 ",
- " 0000000000 ",
- " 00000000 ",
- " 000000 ",
- " 0000 ",
- " 000 ",
- " 00 ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " "};
-
-static char **down_xpm[3] = { down_x16, down_x24, down_x32 };
-
diff --git a/app/bin/bitmaps/ease-broad.xpm b/app/bin/bitmaps/ease-broad.xpm deleted file mode 100644 index 646791e..0000000 --- a/app/bin/bitmaps/ease-broad.xpm +++ /dev/null @@ -1,89 +0,0 @@ -/* XPM */ -static char * ease_broad_x16[] = { -"41 16 2 1", -" c None", -"x c #000000000000", -"xxxxx x ", -"x xxx", -"x xx xxx xx xxx xx xx xxx x ", -"xxxx x x x x x x x x x x x x x ", -"x x x xx xxxx x x x xxxx x x x ", -"x x xx x x x x x x x x x ", -"xxxxx x x xxx xxx x x x xxx x x x", -" ", -" xxxx x ", -" x x x ", -" x x xxx xx xx xxx ", -" xxxx x x x x x x x x ", -" x x x x x x x x x ", -" x x x x x x xx x x ", -" xxxx x xx x x xxx ", -" "}; - -static char* ease_broad_x24[] = { -"56 24 2 1", -" c None", -"x c #000000", -" ", -"xxxxxx ", -"xx ", -"xx x ", -"xx xx ", -"xxxx xxxxx xxxxx xxxx xxx xx xxxx xx xx xxxxxx", -"xx xx xx xx xx xx xxxxxxxx xx xx xxx xx xx ", -"xx xx xx xxx xx xx xx xx xx xx xx xx xx xx ", -"xx xx xx xxxx xxxxxx xx xx xx xxxxxx xx xx xx ", -"xx xx xx xx xx xx xx xx xx xx xx xx ", -"xxxxxx xxx x xxxxx xxxxx xx xx xx xxxxx xx xx xxx", -" ", -" xxxxxx xx ", -" xx xx xx ", -" xx xx xx ", -" xx xx xx ", -" xxxxxx xx xxx xxxxx xxxxxx xxxxxx ", -" xx xx xxx xx xx xx xx xx xx xx ", -" xx xx xx xx xx xx xx xx xx xx ", -" xx xx xx xx xx xx xx xx xx ", -" xx xx xx xx xx xx xx xx xx ", -" xxxxxx xx xxxxx xxxx x xxxxxx ", -" ", -" "}; - -static char* ease_broad_x32[] = { -"66 32 2 1", -" c None", -"x c #000000", -" ", -"xxxxxxx ", -"xxxxxxx ", -"xx x ", -"xx xx ", -"xx xx ", -"xxxxx xxxxx xxxxxx xxxx xxxx xxx xxxx xx xx xxxxxx", -"xxxxx xxxxxx xxxxxxx xxxxxx xxxxxxxxxx xxxxxx xxxxxx xxxxxx", -"xx xx xx xxx xx xx xx xx xx xx xx xxx xx xx ", -"xx xx xx xxx xxxxxxx xx xx xx xxxxxxx xx xx xx ", -"xx xx xx xxx xxxxxxx xx xx xx xxxxxxx xx xx xx ", -"xx xx xx xxx xx xx xx xx xx xx xx xx ", -"xxxxxxx xxxxxxx xxxxxxx xxxxxxx xx xx xx xxxxxx xx xx xxxx", -"xxxxxxx xxx xx xxxxxx xxxxxx xx xx xx xxxxxx xx xx xxx", -" ", -" xxxxxxx xx ", -" xxxxxxxx xx ", -" xx xx xx ", -" xx xx xx ", -" xx xx xx ", -" xxxxxxxx xx xxx xxxxxx xxxxxxx xxxxxx ", -" xxxxxxxx xx xxxx xxxxxxxx xxxxxxxx xxxxxxx ", -" xx xx xxx xx xx xx xx xx xx xx ", -" xx xx xx xx xx xx xx xx xx xx ", -" xx xx xx xx xx xx xx xx xx ", -" xx xx xx xx xx xx xx xx xx ", -" xxxxxxxx xx xxxxxxxx xxxxxxxx xxxxxxx ", -" xxxxxxx xx xxxxxx xxxx xx xxxxxx ", -" ", -" ", -" ", -" "}; - -static char **ease_broad_xpm[3] = { ease_broad_x16, ease_broad_x24, ease_broad_x32 }; diff --git a/app/bin/bitmaps/ease-cornu.xpm b/app/bin/bitmaps/ease-cornu.xpm deleted file mode 100644 index 745f436..0000000 --- a/app/bin/bitmaps/ease-cornu.xpm +++ /dev/null @@ -1,96 +0,0 @@ -/* XPM */ -static char * ease_cornu_x16[] = { -"41 16 4 1", -" c None", -"x c #000000", -"# c #009999", -"$ c #FF9900", -"xxxxx x ", -"x xxx", -"x xx xxx xx xxx xx xx xxx x ", -"xxxx x x x x x x x x x x x x x ", -"x x x xx xxxx x x x xxxx x x x ", -"x x x x x x x x x x x x ", -"xxxxx xxx xxx xxx x x x xxx x x x", -" ", -" $$$ ### $$$$$ ", -" $ $ # # $$$$ $ ", -" $ $ $# ## ### ###$$# # $$$ $ ", -"$ $ $ # # # #$$#$# # # #$ $ $", -"$ $ $# #$$#$# # # # # $ $ $", -" $ $$$ # $#$# # # # # # #$ $ $ ", -" $ $### ## # # # ## $ $ ", -" $$$$$ $$$ "}; - -static char* ease_cornu_x24[] = { -"56 24 4 1", -" c None", -"x c #000000", -"# c #009999", -"- c #FF9900", -" ", -"xxxxxx ", -"xx ", -"xx x ", -"xx xx ", -"xxxx xxxxx xxxxx xxxx xxx xx xxxx xx xx xxxxxx", -"xx xx xx xx xx xx xxxxxxxx xx xx xxx xx xx ", -"xx xx xx xxx xx xx xx xx xx xx xx xx xx xx ", -"xx xx xx xxxx xxxxxx xx xx xx xxxxxx xx xx xx ", -"xx xx xx xx xx xx xx xx xx xx xx xx ", -"xxxxxx xxx x xxxxx xxxxx xx xx xx xxxxx xx xx xxx", -" --- ", -" ------ ##### ", -" --- -## ## ----- ", -" -- --- ## ----------- ", -" -- ---- ## ------ --- ", -" -- ---- ## ##### ## ### -##-### ## ## - -- ", -" -- ---- ## ## ## ###--##-### ## ## ## -- -- ", -" --- --- ## ## -##-##-- ## ## ## ## --- -- ", -" --- ## ## ##---## ## ## ## ## ## -- -- ", -" ----- #####---##### ## ## ## #### # --- ", -" ----- ------- ", -" ----- ", -" "}; - -static char* ease_cornu_x32[] = { -"66 32 4 1", -" c None", -"x c #000000", -"# c #009999", -"- c #FF9900", -" ", -"xxxxxxx ", -"xxxxxxx ", -"xx x ", -"xx xx ", -"xx xx ", -"xxxxx xxxxx xxxxxx xxxx xxxx xxx xxxx xx xx xxxxxx", -"xxxxx xxxxxx xxxxxxx xxxxxx xxxxxxxxxx xxxxxx xxxxxx xxxxxx", -"xx xx xx xxx xx xx xx xxx xxx xx xx xxx xx xx ", -"xx xx xx xxx xxxxxxx xx xx xx xxxxxxx xx xx xx ", -"xx xx xx xxx xxxxxxx xx xx xx xxxxxxx xx xx xx ", -"xx xx xx xxx xx xx xx xx xx xx xx xx ", -"xxxxxxx xxxxxxx xxxxxxx xxxxxxx xx xx xx xxxxxx xx xx xxxx", -"xxxxxxx xxx xx xxxxxx xxxxxx xx xx xx xxxxxx xx xx xxx", -" ", -" ----- ###### ", -" ------ ######## ", -" -- ## ## -------- ", -" -- ----## ------------- ", -" -- ----##-- ###### ## ### ## #### ## ## ---- ", -" -- -----## -- ######## ######## ######## ## ## --- ", -" -- -----## -- ## ## ### ## ### - ## ## ##-- -- ", -" -- -----## - ## ## ## -- ## -- ## ## ##--- -- ", -" -- ----## ## ## ## ----- ## ## ## ##---- -- ", -" -- ---## ## ## ## ## --- ## ## ## -##---- -- ", -" -- ######## ######## ## ## ## ########---- -- ", -" --- ###### - ###### ## ## ## ##### #---- --- ", -" ---- -------- -- ---- -- ", -" ------------ --- --- ", -" --- ---- ---- ", -" ------ ", -" "}; - -static char **ease_cornu_xpm[3] = { ease_cornu_x16, ease_cornu_x24, ease_cornu_x32 }; - diff --git a/app/bin/bitmaps/ease-gt-broad.xpm b/app/bin/bitmaps/ease-gt-broad.xpm deleted file mode 100644 index b2dc1cc..0000000 --- a/app/bin/bitmaps/ease-gt-broad.xpm +++ /dev/null @@ -1,89 +0,0 @@ -/* XPM */ -static char * ease_gtbroad_x16[] = { -"41 16 2 1", -" c None", -"x c #000000000000", -"xxxxx x ", -"x xxx", -"x xx xxx xx xxx xx xx xxx x ", -"xxxx x x x x x x x x x x x x x ", -"x x x xx xxxx x x x xxxx x x x ", -"x x xx x x x x x x x x x ", -"xxxxx x x xxx xxx x x x xxx x x x", -" ", -" ", -" x xxxx x ", -" x x x x ", -" x x x xxx xx xx xxx ", -" x xxxx x x x x x x x x ", -" x x x x x x x x x x ", -" x x x x x x x xx x x ", -" x xxxx x xx xx x xx "}; - -static char* ease_gtbroad_x24[] = { -"56 24 2 1", -" c None", -"x c #000000", -" ", -"xxxxxx ", -"xx ", -"xx x ", -"xx xx ", -"xxxx xxxxx xxxxx xxxx xxx xx xxxx xx xx xxxxxx", -"xx xx xx xx xx xx xxxxxxxx xx xx xxx xx xx ", -"xx xx xx xxx xx xx xx xx xx xx xx xx xx xx ", -"xx xx xx xxxx xxxxxx xx xx xx xxxxxx xx xx xx ", -"xx xx xx xx xx xx xx xx xx xx xx xx ", -"xxxxxx xxx x xxxxx xxxxx xx xx xx xxxxx xx xx xxx", -" ", -" xx xxxxxx xx ", -" xx xx xx xx ", -" xx xx xx xx ", -" xx xx xx xx ", -" xx xxxxxx xx xxx xxxxx xxxxxx xxxxxx ", -" xx xx xx xxx xx xx xx xx xx xx xx ", -" xx xx xx xx xx xx xx xx xx xx xx ", -" xx xx xx xx xx xx xx xx xx xx ", -" xx xx xx xx xx xx xx xx xx xx ", -" xx xxxxxx xx xxxxx xxxx x xxxxxx ", -" ", -" "}; - -static char* ease_gtbroad_x32[] = { -"66 32 2 1", -" c None", -"x c #000000", -" ", -"xxxxxxx ", -"xxxxxxx ", -"xx x ", -"xx xx ", -"xx xx ", -"xxxxx xxxxx xxxxxx xxxx xxxx xxx xxxx xx xx xxxxxx", -"xxxxx xxxxxx xxxxxxx xxxxxx xxxxxxxxxx xxxxxx xxxxxx xxxxxx", -"xx xx xx xxx xx xx xx xxx xxx xx xx xxx xx xx ", -"xx xx xx xxx xxxxxxx xx xx xx xxxxxxx xx xx xx ", -"xx xx xx xxx xxxxxxx xx xx xx xxxxxxx xx xx xx ", -"xx xx xx xxx xx xx xx xx xx xx xx xx ", -"xxxxxxx xxxxxxx xxxxxxx xxxxxxx xx xx xx xxxxxx xx xx xxxx", -"xxxxxxx xxx xx xxxxxx xxxxxx xx xx xx xxxxxx xx xx xxx", -" ", -" xx xxxxxxx xx ", -" xx xxxxxxxx xx ", -" xx xx xx xx ", -" xx xx xx xx ", -" xx xx xx xx ", -" xx xxxxxxxx xx xxx xxxxxx xxxxxxx xxxxxx ", -" xx xxxxxxxx xx xxxx xxxxxxxx xxxxxxxx xxxxxxx ", -" xx xx xx xxx xx xx xx xx xx xx xx ", -" xx xx xx xx xx xx xx xx xx xx xx ", -" xx xx xx xx xx xx xx xx xx xx ", -" xx xx xx xx xx xx xx xx xx xx ", -" xx xxxxxxxx xx xxxxxxxx xxxxxxxx xxxxxxx ", -" xx xxxxxxx xx xxxxxx xxxx xx xxxxxx ", -" ", -" ", -" ", -" "}; - -static char **ease_gtbroad_xpm[3] = { ease_gtbroad_x16, ease_gtbroad_x24, ease_gtbroad_x32 }; diff --git a/app/bin/bitmaps/ease-gt-sharp.xpm b/app/bin/bitmaps/ease-gt-sharp.xpm deleted file mode 100644 index bd12492..0000000 --- a/app/bin/bitmaps/ease-gt-sharp.xpm +++ /dev/null @@ -1,89 +0,0 @@ -/* XPM */ -static char * ease_gtsharp_x16[] = { -"41 16 2 1", -" c None", -"x c #000000000000", -"xxxxx x ", -"x xxx", -"x xx xxx xx xxx xx xx xxx x ", -"xxxx x x x x x x x x x x x x x ", -"x x x xx xxxx x x x xxxx x x x ", -"x x xx x x x x x x x x x ", -"xxxxx x x xxx xxx x x x xxx x x x", -" ", -" x xxxxx x ", -" x x x ", -" x x xxx xx xxx xxx ", -" x xxxxx x x x x x x x x ", -" x x x x x x x x x ", -" x x x x x xx x xxx ", -" x xxxxx x x x x x x ", -" x "}; - -static char* ease_gtsharp_x24[] = { -"56 24 2 1", -" c None", -"x c #000000", -" ", -"xxxxxx ", -"xx ", -"xx x ", -"xx xx ", -"xxxx xxxxx xxxxx xxxx xxx xx xxxx xx xx xxxxxx", -"xx xx xx xx xx xx xxxxxxxx xx xx xxx xx xx ", -"xx xx xx xxx xx xx xx xx xx xx xx xx xx xx ", -"xx xx xx xxxx xxxxxx xx xx xx xxxxxx xx xx xx ", -"xx xx xx xx xx xx xx xx xx xx xx xx ", -"xxxxxx xxx x xxxxx xxxxx xx xx xx xxxxx xx xx xxx", -" ", -" xx xxxxxx xx ", -" xx xx xx ", -" xx xx xx ", -" xx xx xx ", -" xx xxxxx xx xxx xxxxxx xx xxx xxxxxx ", -" xx xx xxx xx xx xx xxx xx xx xx ", -" xx xx xx xx xx xx xx xx xx ", -" xx xx xx xx xx xx xx xx xx ", -" xx xx xx xx xx xx xx xxx xx ", -" xx xxxxxx xx xx xxxx x xx xx xxx ", -" xx ", -" xx "}; - -static char* ease_gtsharp_x32[] = { -"66 32 2 1", -" c None", -"x c #000000", -" ", -"xxxxxxx ", -"xxxxxxx ", -"xx x ", -"xx xx ", -"xx xx ", -"xxxxx xxxxx xxxxxx xxxx xxxx xxx xxxx xx xx xxxxxx", -"xxxxx xxxxxx xxxxxxx xxxxxx xxxxxxxxxx xxxxxx xxxxxx xxxxxx", -"xx xx xx xxx xx xx xx xxx xxx xx xx xxx xx xx ", -"xx xx xx xxx xxxxxxx xx xx xx xxxxxxx xx xx xx ", -"xx xx xx xxx xxxxxxx xx xx xx xxxxxxx xx xx xx ", -"xx xx xx xxx xx xx xx xx xx xx xx xx ", -"xxxxxxx xxxxxxx xxxxxxx xxxxxxx xx xx xx xxxxxx xx xx xxxx", -"xxxxxxx xxx xx xxxxxx xxxxxx xx xx xx xxxxxx xx xx xxx", -" ", -" xx xxxxxxx xx ", -" xx xxxxxxxx xx ", -" xx xx xx ", -" xx xx xx ", -" xx xx xx ", -" xx xxxxxx xx xxx xxxxxxx xx xxx xxxxxx ", -" xx xxxxxx xxxxxxx xxxxxxxx xx xxxx xxxxxxx ", -" xx xx xxx xx xx xx xxx xx xx xx ", -" xx xx xx xx xx xx xx xx xx xx ", -" xx xx xx xx xx xx xx xx xx ", -" xx xx xx xx xx xx xx xx xx ", -" xx xxxxxxxx xx xx xxxxxxxx xx xxxxxxxx ", -" xx xxxxxxx xx xx xxxx xx xx xxxxxxx ", -" xx ", -" xx ", -" xx ", -" "}; - -static char **ease_gtsharp_xpm[3] = { ease_gtsharp_x16, ease_gtsharp_x24, ease_gtsharp_x32 }; diff --git a/app/bin/bitmaps/ease-lt-broad.xpm b/app/bin/bitmaps/ease-lt-broad.xpm deleted file mode 100644 index ab043ee..0000000 --- a/app/bin/bitmaps/ease-lt-broad.xpm +++ /dev/null @@ -1,89 +0,0 @@ -/* XPM */ -static char * ease_ltbroad_x16[] = { -"41 16 2 1", -" c None", -"x c #000000000000", -"xxxxx x ", -"x xxx", -"x xx xxx xx xxx xx xx xxx x ", -"xxxx x x x x x x x x x x x x x ", -"x x x xx xxxx x x x xxxx x x x ", -"x x xx x x x x x x x x x ", -"xxxxx x x xxx xxx x x x xxx x x x", -" ", -" ", -" x xxxx x ", -" x x x x ", -" x x x xxx xx xx xxx ", -" x xxxx x x x x x x x x ", -" x x x x x x x x x x ", -" x x x x x x x xx x x ", -" x xxxx x xx xx x xx "}; - -static char* ease_ltbroad_x24[] = { -"56 24 2 1", -" c None", -"x c #000000", -" ", -"xxxxxx ", -"xx ", -"xx x ", -"xx xx ", -"xxxx xxxxx xxxxx xxxx xxx xx xxxx xx xx xxxxxx", -"xx xx xx xx xx xx xxxxxxxx xx xx xxx xx xx ", -"xx xx xx xxx xx xx xx xx xx xx xx xx xx xx ", -"xx xx xx xxxx xxxxxx xx xx xx xxxxxx xx xx xx ", -"xx xx xx xx xx xx xx xx xx xx xx xx ", -"xxxxxx xxx x xxxxx xxxxx xx xx xx xxxxx xx xx xxx", -" ", -" xx xxxxxx xx ", -" xx xx xx xx ", -" xx xx xx xx ", -" xx xx xx xx ", -" xx xxxxxx xx xxx xxxxx xxxxxx xxxxxx ", -" xx xx xx xxx xx xx xx xx xx xx xx ", -" xx xx xx xx xx xx xx xx xx xx xx ", -" xx xx xx xx xx xx xx xx xx xx ", -" xx xx xx xx xx xx xx xx xx xx ", -" xx xxxxxx xx xxxxx xxxx x xxxxxx ", -" ", -" "}; - -static char* ease_ltbroad_x32[] = { -"66 32 2 1", -" c None", -"x c #000000", -" ", -"xxxxxxx ", -"xxxxxxx ", -"xx x ", -"xx xx ", -"xx xx ", -"xxxxx xxxxx xxxxxx xxxx xxxx xxx xxxx xx xx xxxxxx", -"xxxxx xxxxxx xxxxxxx xxxxxx xxxxxxxxxx xxxxxx xxxxxx xxxxxx", -"xx xx xx xxx xx xx xx xxx xxx xx xx xxx xx xx ", -"xx xx xx xxx xxxxxxx xx xx xx xxxxxxx xx xx xx ", -"xx xx xx xxx xxxxxxx xx xx xx xxxxxxx xx xx xx ", -"xx xx xx xxx xx xx xx xx xx xx xx xx ", -"xxxxxxx xxxxxxx xxxxxxx xxxxxxx xx xx xx xxxxxx xx xx xxxx", -"xxxxxxx xxx xx xxxxxx xxxxxx xx xx xx xxxxxx xx xx xxx", -" ", -" xx xxxxxxx xx ", -" xx xxxxxxxx xx ", -" xx xx xx xx ", -" xx xx xx xx ", -" xx xx xx xx ", -" xx xxxxxxxx xx xxx xxxxxx xxxxxxx xxxxxx ", -" xx xxxxxxxx xx xxxx xxxxxxxx xxxxxxxx xxxxxxx ", -" xx xx xx xxx xx xx xx xx xx xx xx ", -" xx xx xx xx xx xx xx xx xx xx xx ", -" xx xx xx xx xx xx xx xx xx xx ", -" xx xx xx xx xx xx xx xx xx xx ", -" xx xxxxxxxx xx xxxxxxxx xxxxxxxx xxxxxxx ", -" xx xxxxxxx xx xxxxxx xxxx xx xxxxxx ", -" ", -" ", -" ", -" "}; - -static char **ease_ltbroad_xpm[3] = { ease_ltbroad_x16, ease_ltbroad_x24, ease_ltbroad_x32 }; diff --git a/app/bin/bitmaps/ease-lt-sharp.xpm b/app/bin/bitmaps/ease-lt-sharp.xpm deleted file mode 100644 index 93faf60..0000000 --- a/app/bin/bitmaps/ease-lt-sharp.xpm +++ /dev/null @@ -1,89 +0,0 @@ -/* XPM */ -static char * ease_ltsharp_x16[] = { -"41 16 2 1", -" c None", -"x c #000000000000", -"xxxxx x ", -"x xxx", -"x xx xxx xx xxx xx xx xxx x ", -"xxxx x x x x x x x x x x x x x ", -"x x x xx xxxx x x x xxxx x x x ", -"x x xx x x x x x x x x x ", -"xxxxx x x xxx xxx x x x xxx x x x", -" ", -" x xxxxx x ", -" x x x ", -" x x xxx xx xxx xxx ", -" x xxxxx x x x x x x x x ", -" x x x x x x x x x ", -" x x x x x xx x xxx ", -" x xxxxx x x x x x x ", -" x "}; - -static char* ease_ltsharp_x24[] = { -"56 24 2 1", -" c None", -"x c #000000", -" ", -"xxxxxx ", -"xx ", -"xx x ", -"xx xx ", -"xxxx xxxxx xxxxx xxxx xxx xx xxxx xx xx xxxxxx", -"xx xx xx xx xx xx xxxxxxxx xx xx xxx xx xx ", -"xx xx xx xxx xx xx xx xx xx xx xx xx xx xx ", -"xx xx xx xxxx xxxxxx xx xx xx xxxxxx xx xx xx ", -"xx xx xx xx xx xx xx xx xx xx xx xx ", -"xxxxxx xxx x xxxxx xxxxx xx xx xx xxxxx xx xx xxx", -" ", -" xx xxxxxx xx ", -" xx xx xx ", -" xx xx xx ", -" xx xx xx ", -" xx xxxxx xx xxx xxxxxx xx xxx xxxxxx ", -" xx xx xxx xx xx xx xxx xx xx xx ", -" xx xx xx xx xx xx xx xx xx ", -" xx xx xx xx xx xx xx xx xx ", -" xx xx xx xx xx xx xx xxx xx ", -" xx xxxxxx xx xx xxxx x xx xx xxx ", -" xx ", -" xx "}; - -static char* ease_ltsharp_x32[] = { -"66 32 2 1", -" c None", -"x c #000000", -" ", -"xxxxxxx ", -"xxxxxxx ", -"xx x ", -"xx xx ", -"xx xx ", -"xxxxx xxxxx xxxxxx xxxx xxxx xxx xxxx xx xx xxxxxx", -"xxxxx xxxxxx xxxxxxx xxxxxx xxxxxxxxxx xxxxxx xxxxxx xxxxxx", -"xx xx xx xxx xx xx xx xxx xxx xx xx xxx xx xx ", -"xx xx xx xxx xxxxxxx xx xx xx xxxxxxx xx xx xx ", -"xx xx xx xxx xxxxxxx xx xx xx xxxxxxx xx xx xx ", -"xx xx xx xxx xx xx xx xx xx xx xx xx ", -"xxxxxxx xxxxxxx xxxxxxx xxxxxxx xx xx xx xxxxxx xx xx xxxx", -"xxxxxxx xxx xx xxxxxx xxxxxx xx xx xx xxxxxx xx xx xxx", -" ", -" xx xxxxxxx xx ", -" xx xxxxxxxx xx ", -" xx xx xx ", -" xx xx xx ", -" xx xx xx ", -" xx xxxxxx xx xxx xxxxxxx xx xxx xxxxxx ", -" xx xxxxxx xxxxxxx xxxxxxxx xx xxxx xxxxxxx ", -" xx xx xxx xx xx xx xxx xx xx xx ", -" xx xx xx xx xx xx xx xx xx xx ", -" xx xx xx xx xx xx xx xx xx ", -" xx xx xx xx xx xx xx xx xx ", -" xx xxxxxxxx xx xx xxxxxxxx xx xxxxxxxx ", -" xx xxxxxxx xx xx xxxx xx xx xxxxxxx ", -" xx ", -" xx ", -" xx ", -" "}; - -static char **ease_ltsharp_xpm[3] = { ease_ltsharp_x16, ease_ltsharp_x24, ease_ltsharp_x32 }; diff --git a/app/bin/bitmaps/ease-none.xpm b/app/bin/bitmaps/ease-none.xpm deleted file mode 100644 index b2fe985..0000000 --- a/app/bin/bitmaps/ease-none.xpm +++ /dev/null @@ -1,89 +0,0 @@ -/* XPM */ -static char * ease_none_x16[] = { -"41 16 2 1", -" c None", -"x c #000000000000", -"xxxxx x ", -"x xxx", -"x xx xxx xx xxx xx xx xxx x ", -"xxxx x x x x x x x x x x x x x ", -"x x x xx xxxx x x x xxxx x x x ", -"x x x x x x x x x x x x ", -"xxxxx xxx xxx xxx x x x xxx x x x", -" ", -" x x ", -" xx x ", -" xxx x xx xxx xx ", -" x x x x x x x x x ", -" x xxx x x x x xxx ", -" x xx x x x x x ", -" x x xx x x xxx ", -" "}; - -static char* ease_none_x24[] = { -"56 24 2 1", -" c None", -"x c #000000", -" ", -"xxxxxx ", -"xx ", -"xx x ", -"xx xx ", -"xxxx xxxxx xxxxx xxxx xxx xx xxxx xx xx xxxxxx", -"xx xx xx xx xx xx xxxxxxxx xx xx xxx xx xx ", -"xx xx xx xxx xx xx xx xx xx xx xx xx xx xx ", -"xx xx xx xxxx xxxxxx xx xx xx xxxxxx xx xx xx ", -"xx xx xx xx xx xx xx xx xx xx xx xx ", -"xxxxxx xxx x xxxxx xxxxx xx xx xx xxxxx xx xx xxx", -" ", -" xx xx ", -" xx xx ", -" xxx xx ", -" xxxx xx ", -" xxxxxxx xxxxx xx xxx xxxxx ", -" xx xxxx xx xx xxx xx xx xx ", -" xx xxx xx xx xx xx xx xx ", -" xx xx xx xx xx xx xxxxxxx ", -" xx xx xx xx xx xx xx ", -" xx xx xxxxx xx xx xxxxxx ", -" ", -" "}; - -static char* ease_none_x32[] = { -"66 32 2 1", -" c None", -"x c #000000", -" ", -"xxxxxxx ", -"xxxxxxx ", -"xx x ", -"xx xx ", -"xx xx ", -"xxxxx xxxxx xxxxxx xxxx xxxx xxx xxxx xx xx xxxxxx", -"xxxxx xxxxxx xxxxxxx xxxxxx xxxxxxxxxx xxxxxx xxxxxx xxxxxx", -"xx xx xx xxx xx xx xx xxx xxx xx xx xxx xx xx ", -"xx xx xx xxx xxxxxxx xx xx xx xxxxxxx xx xx xx ", -"xx xx xx xxx xxxxxxx xx xx xx xxxxxxx xx xx xx ", -"xx xx xx xxx xx xx xx xx xx xx xx xx ", -"xxxxxxx xxxxxxx xxxxxxx xxxxxxx xx xx xx xxxxxx xx xx xxxx", -"xxxxxxx xxx xx xxxxxx xxxxxx xx xx xx xxxxxx xx xx xxx", -" ", -" xx xx ", -" xx xx ", -" xx xx ", -" xxx xx ", -" xxxx xx ", -" xxxxx xx xxxxxx xx xxxx xxxxxx ", -" xx xxx xx xxxxxxxx xxxxxxxx xxxxxxxx ", -" xx xxxxx xx xx xxx xx xx xx ", -" xx xxxx xx xx xx xx xxxxxxxx ", -" xx xxx xx xx xx xx xxxxxxxx ", -" xx xx xx xx xx xx xx ", -" xx xx xxxxxxxx xx xx xxxxxxxx ", -" xx xx xxxxxx xx xx xxxxxxx ", -" ", -" ", -" ", -" "}; - -static char **ease_none_xpm[3] = { ease_none_x16, ease_none_x24, ease_none_x32 }; diff --git a/app/bin/bitmaps/ease-normal.xpm b/app/bin/bitmaps/ease-normal.xpm deleted file mode 100644 index 411a036..0000000 --- a/app/bin/bitmaps/ease-normal.xpm +++ /dev/null @@ -1,89 +0,0 @@ -/* XPM */ -static char * ease_normal_x16[] = { -"41 16 2 1", -" c None", -"x c #000000000000", -"xxxxx x ", -"x xxx", -"x xx xxx xx xxx xx xx xxx x ", -"xxxx x x x x x x x x x x x x x ", -"x x x xx xxxx x x x xxxx x x x ", -"x x x x x x x x x x x x ", -"xxxxx xxx xxx xxx x x x xxx x x x", -" ", -" x x x ", -" xx x x ", -" xxx x xx xxx xxx xx xx x ", -" x x x x x x x x x x x x x ", -" x xxx x x x x x x x x x ", -" x xx x x x x x x x x x ", -" x x xx x x x x xxx x ", -" "}; - -static char* ease_normal_x24[] = { -"56 24 2 1", -" c None", -"x c #000000", -" ", -"xxxxxx ", -"xx ", -"xx x ", -"xx xx ", -"xxxx xxxxx xxxxx xxxx xxx xx xxxx xx xx xxxxxx", -"xx xx xx xx xx xx xxxxxxxx xx xx xxx xx xx ", -"xx xx xx xxx xx xx xx xx xx xx xx xx xx xx ", -"xx xx xx xxxx xxxxxx xx xx xx xxxxxx xx xx xx ", -"xx xx xx xx xx xx xx xx xx xx xx xx ", -"xxxxxx xxx x xxxxx xxxxx xx xx xx xxxxx xx xx xxx", -" ", -" xx xx xx ", -" xx xx xx ", -" xxx xx xx ", -" xxxx xx xx ", -" xxxxxxx xxxxx xx xxx xx xx xx xxxxxx xx ", -" xx xxxx xx xx xxx xx xxxxxxxx xx xx xx ", -" xx xxx xx xx xx xx xx xx xx xx xx ", -" xx xx xx xx xx xx xx xx xx xx xx ", -" xx xx xx xx xx xx xx xx xx xx xx ", -" xx xx xxxxx xx xx xx xx xxxx x xx ", -" ", -" "}; - -static char* ease_normal_x32[] = { -"66 32 2 1", -" c None", -"x c #000000", -" ", -"xxxxxxx ", -"xxxxxxx ", -"xx x ", -"xx xx ", -"xx xx ", -"xxxxx xxxxx xxxxxx xxxx xxxx xxx xxxx xx xx xxxxxx", -"xxxxx xxxxxx xxxxxxx xxxxxx xxxxxxxxxx xxxxxx xxxxxx xxxxxx", -"xx xx xx xxx xx xx xx xxx xxx xx xx xxx xx xx ", -"xx xx xx xxx xxxxxxx xx xx xx xxxxxxx xx xx xx ", -"xx xx xx xxx xxxxxxx xx xx xx xxxxxxx xx xx xx ", -"xx xx xx xxx xx xx xx xx xx xx xx xx ", -"xxxxxxx xxxxxxx xxxxxxx xxxxxxx xx xx xx xxxxxx xx xx xxxx", -"xxxxxxx xxx xx xxxxxx xxxxxx xx xx xx xxxxxx xx xx xxx", -" ", -" xx xx xx ", -" xx xx xx ", -" xx xx xx ", -" xxx xx xx ", -" xxxx xx xx ", -" xxxxx xx xxxxxx xx xxx xx xx xx xxxxxxx xx ", -" xx xxx xx xxxxxxxx xxxxxxx xxxxxxxxxx xxxxxxxx xx ", -" xx xxxxx xx xx xxx xx xx xxx xxx xx xx xx ", -" xx xxxx xx xx xx xx xx xx xx xx xx ", -" xx xxx xx xx xx xx xx xx xx xx xx ", -" xx xx xx xx xx xx xx xx xx xx xx ", -" xx xx xxxxxxxx xx xx xx xx xxxxxxxx xxx ", -" xx xx xxxxxx xx xx xx xx xxxx xx xxx ", -" ", -" ", -" ", -" "}; - -static char **ease_normal_xpm[3] = { ease_normal_x16, ease_normal_x24, ease_normal_x32 }; diff --git a/app/bin/bitmaps/ease-sharp.xpm b/app/bin/bitmaps/ease-sharp.xpm deleted file mode 100644 index 05c5c3b..0000000 --- a/app/bin/bitmaps/ease-sharp.xpm +++ /dev/null @@ -1,89 +0,0 @@ -/* XPM */ -static char * ease_sharp_x16[] = { -"41 16 2 1", -" c None", -"x c #000000000000", -"xxxxx x ", -"x xxx", -"x xx xxx xx xxx xx xx xxx x ", -"xxxx x x x x x x x x x x x x x ", -"x x x xx xxxx x x x xxxx x x x ", -"x x xx x x x x x x x x x ", -"xxxxx x x xxx xxx x x x xxx x x x", -" ", -" xxxxx x ", -" x x ", -" x xxx xx xxx xxx ", -" xxxx x x x x x x x x ", -" x x x x x x x x ", -" x x x x xx x xxx ", -" xxxxx x x x x x x ", -" x "}; - -static char* ease_sharp_x24[] = { -"56 24 2 1", -" c None", -"x c #000000", -" ", -"xxxxxx ", -"xx ", -"xx x ", -"xx xx ", -"xxxx xxxxx xxxxx xxxx xxx xx xxxx xx xx xxxxxx", -"xx xx xx xx xx xx xxxxxxxx xx xx xxx xx xx ", -"xx xx xx xxx xx xx xx xx xx xx xx xx xx xx ", -"xx xx xx xxxx xxxxxx xx xx xx xxxxxx xx xx xx ", -"xx xx xx xx xx xx xx xx xx xx xx xx ", -"xxxxxx xxx x xxxxx xxxxx xx xx xx xxxxx xx xx xxx", -" ", -" xxxxxx xx ", -" xx xx ", -" xx xx ", -" xx xx ", -" xxxxx xx xxx xxxxxx xx xxx xxxxxx ", -" xx xxx xx xx xx xxx xx xx xx ", -" xx xx xx xx xx xx xx xx ", -" xx xx xx xx xx xx xx xx ", -" xx xx xx xx xx xx xxx xx ", -" xxxxxx xx xx xxxx x xx xx xxx ", -" xx ", -" xx "}; - -static char* ease_sharp_x32[] = { -"66 32 2 1", -" c None", -"x c #000000", -" ", -"xxxxxxx ", -"xxxxxxx ", -"xx x ", -"xx xx ", -"xx xx ", -"xxxxx xxxxx xxxxxx xxxx xxxx xxx xxxx xx xx xxxxxx", -"xxxxx xxxxxx xxxxxxx xxxxxx xxxxxxxxxx xxxxxx xxxxxx xxxxxx", -"xx xx xx xxx xx xx xx xxx xxx xx xx xxx xx xx ", -"xx xx xx xxx xxxxxxx xx xx xx xxxxxxx xx xx xx ", -"xx xx xx xxx xxxxxxx xx xx xx xxxxxxx xx xx xx ", -"xx xx xx xxx xx xx xx xx xx xx xx xx ", -"xxxxxxx xxxxxxx xxxxxxx xxxxxxx xx xx xx xxxxxx xx xx xxxx", -"xxxxxxx xxx xx xxxxxx xxxxxx xx xx xx xxxxxx xx xx xxx", -" ", -" xxxxxxx xx ", -" xxxxxxxx xx ", -" xx xx ", -" xx xx ", -" xx xx ", -" xxxxxx xx xxx xxxxxxx xx xxx xxxxxx ", -" xxxxxx xxxxxxx xxxxxxxx xx xxxx xxxxxxx ", -" xx xxx xx xx xx xxx xx xx xx ", -" xx xx xx xx xx xx xx xx xx ", -" xx xx xx xx xx xx xx xx ", -" xx xx xx xx xx xx xx xx ", -" xxxxxxxx xx xx xxxxxxxx xx xxxxxxxx ", -" xxxxxxx xx xx xxxx xx xx xxxxxxx ", -" xx ", -" xx ", -" xx ", -" "}; - -static char **ease_sharp_xpm[3] = { ease_sharp_x16, ease_sharp_x24, ease_sharp_x32 }; diff --git a/app/bin/bitmaps/elevation.xpm b/app/bin/bitmaps/elevation.xpm deleted file mode 100644 index ab65147..0000000 --- a/app/bin/bitmaps/elevation.xpm +++ /dev/null @@ -1,117 +0,0 @@ -static char *elevation_x16[] = {
- "16 16 5 1",
- " c None",
- "0 c #000000",
- "1 c #CC0000",
- "2 c #CC6600",
- "3 c #FF0000",
- " ",
- " 1 11111 ",
- " 131 33 ",
- " 13331 33 ",
- " 1 33 ",
- " 1 33 ",
- " 1 11111 ",
- " 1 ",
- " ",
- " 2 2 2 2 2 2 2 ",
- " 00000000000000 ",
- " 2 2 2 2 2 2 2 ",
- " 00000000000000 ",
- " 2 2 2 2 2 2 2 ",
- " ",
- " "};
-
-static char *elevation_x24[] = {
- "24 24 14 1",
- " c None",
- "0 c #000000",
- "1 c #663300",
- "2 c #666600",
- "3 c #996600",
- "4 c #996633",
- "5 c #CC0000",
- "6 c #CC3300",
- "7 c #CC6600",
- "8 c #CC6633",
- "9 c #CC9933",
- "A c #FF6633",
- "B c #FF9933",
- "C c #FFCC33",
- " ",
- " ",
- " 5555555 ",
- " 55555555 ",
- " 555 ",
- " 55 555 ",
- " 5555 555 ",
- " 555555 55 ",
- " 5555555 555 ",
- " 5 55 5 55555555 ",
- " 55 55555555 ",
- " 55 ",
- " 55 ",
- " 55 ",
- " 55 ",
- " 440440345640180090081 ",
- " 0440440345640180090081 ",
- " BB BB BC57C C C C ",
- " BB BB BC5AC C C C ",
- " BB BB BC C C C C ",
- " 440440340240180090081 ",
- " 0440440340240180090081 ",
- " ",
- " "};
-
-static char *elevation_x32[] = {
- "32 32 15 1",
- " c None",
- "0 c #000000",
- "1 c #333300",
- "2 c #663300",
- "3 c #666600",
- "4 c #990000",
- "5 c #996600",
- "6 c #996633",
- "7 c #CC0000",
- "8 c #CC3300",
- "9 c #CC6600",
- "A c #CC6633",
- "B c #CC9933",
- "C c #FF9933",
- "D c #FFCC33",
- " ",
- " ",
- " ",
- " 777777777 ",
- " 777777777 ",
- " 777 ",
- " 777 ",
- " 77 7777 ",
- " 7777 777 ",
- " 777777 777 ",
- " 77777777 777 ",
- " 777777777 777 ",
- " 77 777 77 7777777777 ",
- " 777 7777777777 ",
- " 777 7777777777 ",
- " 777 ",
- " 777 ",
- " 777 ",
- " 777 ",
- " 777 ",
- " BB BB 6B778B B B5 B6 ",
- " 02200220013474500050005100310 ",
- " DC CC D778D D D D ",
- " DC CC D778D D D D ",
- " DC CC D779D D D D ",
- " DC CC D D D D D ",
- " DC CC D D D D D ",
- " 06500660036002A000B000A200630 ",
- " 06500660036002A000B000A200630 ",
- " D D D C D D ",
- " ",
- " "};
-
-static char **elevation_xpm[3] = { elevation_x16, elevation_x24, elevation_x32 };
-
diff --git a/app/bin/bitmaps/exit.xpm b/app/bin/bitmaps/exit.xpm deleted file mode 100644 index 7daf3ab..0000000 --- a/app/bin/bitmaps/exit.xpm +++ /dev/null @@ -1,94 +0,0 @@ -static char *exit_x16[] = {
- "16 16 3 1",
- " c None",
- "0 c #000000",
- "1 c #FF0000",
- " ",
- " 1 ",
- " 111 ",
- " 11111 ",
- " 1 ",
- " 1 ",
- " 1 ",
- " 1 ",
- " ",
- " ",
- " 000 0 0 0 000 ",
- " 0 0 0 0 0 ",
- " 00 0 0 0 ",
- " 0 0 0 0 0 ",
- " 000 0 0 0 0 ",
- " "};
-
-static char *exit_x24[] = {
- "24 24 5 1",
- " c None",
- "0 c #000000",
- "1 c #333333",
- "2 c #CC0000",
- "3 c #808080",
- " ",
- " ",
- " 22 ",
- " 2222 ",
- " 222222 ",
- " 22222222 ",
- " 22 ",
- " 22 ",
- " 22 ",
- " 22 ",
- " 22 ",
- " 22 ",
- " ",
- " ",
- " 00000 0 0 00 000000 ",
- " 00 01 10 00 00 ",
- " 00 030 00 00 ",
- " 0000 303 00 00 ",
- " 00 030 00 00 ",
- " 00 01 10 00 00 ",
- " 00000 0 0 00 00 ",
- " ",
- " ",
- " "};
-
-static char *exit_x32[] = {
- "32 32 3 1",
- " c None",
- "0 c #000000",
- "1 c #CC0000",
- " ",
- " 11 ",
- " 1111 ",
- " 111111 ",
- " 111111111 ",
- " 11111111111 ",
- " 11111111111111 ",
- " 1111 1111 1111 ",
- " 111 1111 111 ",
- " 1111 1 ",
- " 1111 ",
- " 1111 ",
- " 1111 ",
- " 1111 ",
- " 1111 ",
- " 1111 ",
- " 1111 ",
- " 111 ",
- " ",
- " ",
- " ",
- " 00000000 000 00 00 000000000",
- " 00000000 000 000 00 00000000 ",
- " 00 000000 00 000 ",
- " 000 00000 00 000 ",
- " 0000000 000 00 000 ",
- " 0000000 0000 00 000 ",
- " 00 00000 00 000 ",
- " 00 000 000 00 000 ",
- " 00000000 000 000 00 000 ",
- " 00000000 00 000 00 000 ",
- " "};
-
-static char **exit_xpm[3] = { exit_x16, exit_x24, exit_x32 };
-
diff --git a/app/bin/bitmaps/extend.xpm b/app/bin/bitmaps/extend.xpm deleted file mode 100644 index 43490a0..0000000 --- a/app/bin/bitmaps/extend.xpm +++ /dev/null @@ -1,143 +0,0 @@ -static char *extend_x16[] = {
- "16 16 21 1",
- " c None",
- "0 c #000000",
- "1 c #0066FF",
- "2 c #3366CC",
- "3 c #3366FF",
- "4 c #3399FF",
- "5 c #666666",
- "6 c #6666CC",
- "7 c #6699FF",
- "8 c #66CCFF",
- "9 c #993333",
- "A c #996666",
- "B c #999999",
- "C c #9999CC",
- "D c #CC0000",
- "E c #CC3333",
- "F c #CC6633",
- "G c #CC6666",
- "H c #CCCCCC",
- "I c #C0C0C0",
- "J c #808080",
- " D ",
- " DDD ",
- " GAE9 ",
- " BJEJI ",
- " BJD5 ",
- " BBGJH ",
- " HJFE5 ",
- " BJEJB ",
- " CJGEJH ",
- " 46FJI ",
- " 734832 ",
- " 884438814 ",
- " 343448 34 ",
- " 8 8441 ",
- " 411338 ",
- " 44 8 "};
-
-static char *extend_x24[] = {
- "24 24 21 1",
- " c None",
- "0 c #000000",
- "1 c #0066FF",
- "2 c #3366FF",
- "3 c #3399FF",
- "4 c #666666",
- "5 c #6666CC",
- "6 c #6699FF",
- "7 c #66CCFF",
- "8 c #993333",
- "9 c #999999",
- "A c #CC0000",
- "B c #CC3300",
- "C c #CC3333",
- "D c #CC6633",
- "E c #CC6666",
- "F c #CC6699",
- "G c #CC9999",
- "H c #CCCCCC",
- "I c #C0C0C0",
- "J c #808080",
- " ",
- " AA ",
- " AAAAA ",
- " B AA ",
- " 99EGJI ",
- " J9DG4H ",
- " 44A 4 ",
- " HJIC94 ",
- " 4GE99H ",
- " H94AA44 ",
- " JICG4 ",
- " H44CE99 ",
- " 9JGA 4I ",
- " 75 EGJ4 ",
- " 37 A9JH ",
- " 62 7732 ",
- " 77227 32 ",
- " 7776223 7 1 7 ",
- " 23323277 32 ",
- " 236 7 76117 ",
- " 77 77112 ",
- " 76111117 ",
- " 112117 ",
- " 77 "};
-
-static char *extend_x32[] = {
- "32 32 18 1",
- " c None",
- "0 c #000000",
- "1 c #0066FF",
- "2 c #3366CC",
- "3 c #3366FF",
- "4 c #3399FF",
- "5 c #666666",
- "6 c #6699FF",
- "7 c #66CCFF",
- "8 c #999999",
- "9 c #CC0000",
- "A c #CC3300",
- "B c #CC3333",
- "C c #CC6666",
- "D c #CC9999",
- "E c #CCCCCC",
- "F c #C0C0C0",
- "G c #808080",
- " ",
- " 99 ",
- " 999999 ",
- " 99999999 ",
- " 99 99 99 ",
- " 5 99 5 ",
- " EGECBEGE ",
- " 5 998G ",
- " 5 9955 ",
- " E8G 9955 ",
- " E88D9FG8 ",
- " 559AEGFE ",
- " EF5 99 5 ",
- " E88D9 55 ",
- " 5 CBE5 ",
- " EE55 9B8GE ",
- " 8G 99 5 ",
- " 5ED9B55 ",
- " 73 9CF5 ",
- " 377 5FE ",
- " 763 77 12 ",
- " 7 347 741 ",
- " 7633 7 147 ",
- " 7 77334 7 11 ",
- " 463333 7 431 ",
- " 334337 77 1147 ",
- " 7 77 711 ",
- " 7 7 1136 ",
- " 7 411 7 ",
- " 11311147 ",
- " 37 7 ",
- " 7 "};
-
-static char **extend_xpm[3] = { extend_x16, extend_x24, extend_x32 };
-
diff --git a/app/bin/bitmaps/filled-box.xpm b/app/bin/bitmaps/filled-box.xpm deleted file mode 100644 index cd85179..0000000 --- a/app/bin/bitmaps/filled-box.xpm +++ /dev/null @@ -1,120 +0,0 @@ -static char *filled_box_x16[] = {
- "16 16 12 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #9999CC",
- "3 c #99CCCC",
- "4 c #99CCFF",
- "5 c #99FFFF",
- "6 c #CC0000",
- "7 c #CC6666",
- "8 c #CC6699",
- "9 c #CC9999",
- "A c #CC99CC",
- " ",
- " 00000000000000 ",
- " 05555555542220 ",
- " 05555555542860 ",
- " 0555555555A271 ",
- " 05555555592581 ",
- " 05555554935540 ",
- " 05555549355550 ",
- " 05555483555550 ",
- " 05554845555550 ",
- " 05548455555550 ",
- " 05484555555550 ",
- " 04845555555550 ",
- " 18455555555550 ",
- " 00000000000000 ",
- " "};
-
-static char *filled_box_x24[] = {
- "24 24 12 1",
- " c None",
- "0 c #000000",
- "1 c #9999CC",
- "2 c #99CCCC",
- "3 c #99CCFF",
- "4 c #99FFFF",
- "5 c #CC0000",
- "6 c #CC3333",
- "7 c #CC6666",
- "8 c #CC6699",
- "9 c #CC9999",
- "A c #CC99CC",
- " ",
- " ",
- " 0000000000000000000000 ",
- " 0444444444444433333340 ",
- " 0444444444444415555640 ",
- " 0444444444444433317540 ",
- " 0444444444444444292530 ",
- " 0444444444444441942530 ",
- " 04444444444444A1443530 ",
- " 0444444444444914443230 ",
- " 0444444444439244444440 ",
- " 0444444444392444444440 ",
- " 0444444443824444444440 ",
- " 0444444438344444444440 ",
- " 0444444383444444444440 ",
- " 0444443834444444444440 ",
- " 0444438344444444444440 ",
- " 0444283444444444444440 ",
- " 0442934444444444444440 ",
- " 0429344444444444444440 ",
- " 0314444444444444444440 ",
- " 0000000000000000000000 ",
- " ",
- " "};
-
-static char *filled_box_x32[] = {
- "32 32 13 1",
- " c None",
- "0 c #000000",
- "1 c #9999CC",
- "2 c #99CCCC",
- "3 c #99CCFF",
- "4 c #99FFFF",
- "5 c #CC0000",
- "6 c #CC3333",
- "7 c #CC3366",
- "8 c #CC6666",
- "9 c #CC6699",
- "A c #CC9999",
- "B c #CC99CC",
- " ",
- " ",
- " 000000000000000000000000000000 ",
- " 000000000000000000000000000000 ",
- " 004444444444444444444444444400 ",
- " 004444444444444444436555558400 ",
- " 004444444444444444436555556400 ",
- " 004444444444444444444436555400 ",
- " 004444444444444444444265A85300 ",
- " 00444444444444444444265A485300 ",
- " 0044444444444444444255B4495300 ",
- " 0044444444444444441551444A5300 ",
- " 004444444444444441552444431300 ",
- " 0044444444444444A5524444444400 ",
- " 004444444444444A56244444444400 ",
- " 00444444444443A562444444444400 ",
- " 0044444444443A5634444444444400 ",
- " 004444444443857344444444444400 ",
- " 004444444438583444444444444400 ",
- " 004444444385834444444444444400 ",
- " 004444443758344444444444444400 ",
- " 004444436593444444444444444400 ",
- " 004444265A34444444444444444400 ",
- " 00444265A344444444444444444400 ",
- " 0044255A4444444444444444444400 ",
- " 004155144444444444444444444400 ",
- " 003651444444444444444444444400 ",
- " 004224444444444444444444444400 ",
- " 000000000000000000000000000000 ",
- " 000000000000000000000000000000 ",
- " ",
- " "};
-
-static char **filled_box_xpm[3] = { filled_box_x16, filled_box_x24, filled_box_x32 };
-
diff --git a/app/bin/bitmaps/filled-polygon.xpm b/app/bin/bitmaps/filled-polygon.xpm deleted file mode 100644 index 2620b74..0000000 --- a/app/bin/bitmaps/filled-polygon.xpm +++ /dev/null @@ -1,121 +0,0 @@ -static char *filled_polygon_x16[] = {
- "16 16 12 1",
- " c None",
- "0 c #000000",
- "1 c #003333",
- "2 c #333333",
- "3 c #333366",
- "4 c #336666",
- "5 c #336699",
- "6 c #669999",
- "7 c #6699CC",
- "8 c #66CCCC",
- "9 c #66CCFF",
- "A c #99FFFF",
- " ",
- " 01220144 ",
- " 17799AAA93 ",
- " 17AAAAAAAA84 ",
- " 29AAAAAAAAA83 ",
- " 4AAAAAAAAAAA83 ",
- "06AAAAAAAAAAAA71",
- " 4AAAAAAAAAAAA82",
- " 19AAAAAAAAAAA82",
- " 17AAAAAAAAAAA82",
- " 4AAAAAAAAAAA82",
- " 19AAAAAAAAAA92",
- " 1179AAAAAAAA92",
- " 1279AAAA9752",
- " 227640210 ",
- " 00 "};
-
-static char *filled_polygon_x24[] = {
- "24 24 14 1",
- " c None",
- "0 c #000000",
- "1 c #000033",
- "2 c #003333",
- "3 c #333333",
- "4 c #333366",
- "5 c #336666",
- "6 c #336699",
- "7 c #339999",
- "8 c #669999",
- "9 c #6699CC",
- "A c #66CCCC",
- "B c #66CCFF",
- "C c #99FFFF",
- " ",
- " 0032 ",
- " 0033105599A62 ",
- " 299ABBCCCCCCB62 ",
- " 06CCCCCCCCCCCCB5 ",
- " 3ACCCCCCCCCCCCCB5 ",
- " 2BCCCCCCCCCCCCCCB5 ",
- " 07CCCCCCCCCCCCCCCCB5 ",
- " 3ACCCCCCCCCCCCCCCCCB4 ",
- " 1BCCCCCCCCCCCCCCCCCCB4 ",
- " 3BCCCCCCCCCCCCCCCCCCC4 ",
- " 08CCCCCCCCCCCCCCCCCCC4 ",
- " 2CCCCCCCCCCCCCCCCCCC4 ",
- " 3BCCCCCCCCCCCCCCCCCC5 ",
- " 07CCCCCCCCCCCCCCCCCC5 ",
- " 2BCCCCCCCCCCCCCCCCC5 ",
- " 3ACCCCCCCCCCCCCCCCC5 ",
- " 07CCCCCCCCCCCCCCCCC5 ",
- " 45BCCCCCCCCCCCCCCC5 ",
- " 35BCCCCCCCCCCCCC5 ",
- " 36BCCCCCCCBA850 ",
- " 028BBA952230 ",
- " 22230 ",
- " "};
-
-static char *filled_polygon_x32[] = {
- "32 32 12 1",
- " c None",
- "0 c #000000",
- "1 c #003333",
- "2 c #333366",
- "3 c #336666",
- "4 c #336699",
- "5 c #339999",
- "6 c #669999",
- "7 c #6699CC",
- "8 c #66CCCC",
- "9 c #66CCFF",
- "A c #99FFFF",
- " ",
- " 0000 ",
- " 000000000000 ",
- " 0000000000447789300 ",
- " 004477999AAAAAAA9300 ",
- " 008AAAAAAAAAAAAAAA9100 ",
- " 019AAAAAAAAAAAAAAAA9100 ",
- " 05AAAAAAAAAAAAAAAAAA9100 ",
- " 008AAAAAAAAAAAAAAAAAAA810 ",
- " 029AAAAAAAAAAAAAAAAAAAA800 ",
- " 006AAAAAAAAAAAAAAAAAAAAAA800 ",
- " 009AAAAAAAAAAAAAAAAAAAAAAA700 ",
- " 02AAAAAAAAAAAAAAAAAAAAAAAAA700 ",
- " 009AAAAAAAAAAAAAAAAAAAAAAAAA30 ",
- " 008AAAAAAAAAAAAAAAAAAAAAAAAA40 ",
- " 04AAAAAAAAAAAAAAAAAAAAAAAAA40 ",
- " 009AAAAAAAAAAAAAAAAAAAAAAAA50 ",
- " 008AAAAAAAAAAAAAAAAAAAAAAAA60 ",
- " 04AAAAAAAAAAAAAAAAAAAAAAAA60 ",
- " 009AAAAAAAAAAAAAAAAAAAAAAA60 ",
- " 007AAAAAAAAAAAAAAAAAAAAAAA60 ",
- " 04AAAAAAAAAAAAAAAAAAAAAAA60 ",
- " 009AAAAAAAAAAAAAAAAAAAAAA60 ",
- " 0069AAAAAAAAAAAAAAAAAAAAA60 ",
- " 0027AAAAAAAAAAAAAAAAAAAA70 ",
- " 00038AAAAAAAAAAAAAAAAAA70 ",
- " 00038AAAAAAAAAAAAAA9840 ",
- " 00049AAAAAAA997520000 ",
- " 00059A98630000000 ",
- " 00010000000 ",
- " 0000 ",
- " "};
-
-static char **filled_polygon_xpm[3] = { filled_polygon_x16, filled_polygon_x24, filled_polygon_x32 };
-
diff --git a/app/bin/bitmaps/go.xpm b/app/bin/bitmaps/go.xpm deleted file mode 100644 index deb8a81..0000000 --- a/app/bin/bitmaps/go.xpm +++ /dev/null @@ -1,135 +0,0 @@ -static char *go_x16[] = {
- "16 16 16 1",
- " c None",
- "0 c #000000",
- "1 c #003300",
- "2 c #006600",
- "3 c #006633",
- "4 c #009933",
- "5 c #339933",
- "6 c #33CC33",
- "7 c #33CC66",
- "8 c #66CC66",
- "9 c #66CC99",
- "A c #99CC99",
- "B c #99FF99",
- "C c #99FFCC",
- "D c #CCFFCC",
- "E c #008000",
- " 00 ",
- " 1221 ",
- " 11577511 ",
- " 015788887510 ",
- " 12678898887620 ",
- " 14788AAAA877E0 ",
- " 1478AACCA98740 ",
- " 1478ACDDB98740 ",
- " 1478ABCCA98740 ",
- " 14789ABBA887E0 ",
- " 147789AA9876E0 ",
- " 11578888877410 ",
- " 1377777631 ",
- " 01476410 ",
- " 1111 ",
- " "};
-
-static char *go_x24[] = {
- "24 24 18 1",
- " c None",
- "0 c #000000",
- "1 c #003300",
- "2 c #006600",
- "3 c #006633",
- "4 c #009900",
- "5 c #009933",
- "6 c #00CC33",
- "7 c #339933",
- "8 c #33CC33",
- "9 c #33CC66",
- "A c #66CC66",
- "B c #66CC99",
- "C c #99CC99",
- "D c #99FF99",
- "E c #99FFCC",
- "F c #CCFFCC",
- "G c #008000",
- " ",
- " 0110 ",
- " 138721 ",
- " 1279999711 ",
- " 11799999999510 ",
- " 015899AAAAAA99821 ",
- " 125899AAABBAAA998510 ",
- " 15899AABCCCBBAA986G0 ",
- " 1589AABCCCCCCAA998G0 ",
- " 1589AACCEEECCBAA98G0 ",
- " 1599ABCCEFEECCAA9850 ",
- " 1599ABCEEFFECCAA9850 ",
- " 1599ABCDEFFECCAA9850 ",
- " 1599AACCEEEECBAA9850 ",
- " 1589AABCCCCCCBAA98G0 ",
- " 15899AABCCCCBAA996G0 ",
- " 14689AAABBBBAA9986G0 ",
- " 1G899AAAAAAA9986G1 ",
- " 117999AAAA998511 ",
- " 128999999711 ",
- " 015888821 ",
- " 115G10 ",
- " 10 ",
- " "};
-
-static char *go_x32[] = {
- "32 32 18 1",
- " c None",
- "0 c #000000",
- "1 c #003300",
- "2 c #006600",
- "3 c #006633",
- "4 c #009900",
- "5 c #009933",
- "6 c #00CC33",
- "7 c #339933",
- "8 c #33CC33",
- "9 c #33CC66",
- "A c #66CC66",
- "B c #66CC99",
- "C c #99CC99",
- "D c #99FF99",
- "E c #99FFCC",
- "F c #CCFFCC",
- "G c #008000",
- " ",
- " 11 ",
- " 115310 ",
- " 015888721 ",
- " 138999998711 ",
- " 1179999999998511 ",
- " 1158999AAAAA9999831 ",
- " 01G8899AAAAAAAAA9998511 ",
- " 1258899AAAAAAAAAAA99986G1 ",
- " 146899AAAABCCCBBAAA99886G0 ",
- " 156899AAABCCCCCCBAAA9986G0 ",
- " 15899AAABCCCCCCCCBAA9986G0 ",
- " 15899AABCCCEEEDCCBAAA988G0 ",
- " 15899AABCCEEEEEDCCBAA998G0 ",
- " 1589AAACCCEEFFEECCBAA998G0 ",
- " 1589AAACCDEFFFEECCBAA99850 ",
- " 1589AAACCCEFFFEECCBAA998G0 ",
- " 15899AABCCEEEEEDCCBAA998G0 ",
- " 15899AABCCCEEEECCCAAA988G0 ",
- " 15899AAABCCCCCCCCBAA9986G0 ",
- " 156899AABCCCCCCCBAAA9986G0 ",
- " 156899AAAABCCCBBAAA99886G0 ",
- " 1G68899AAAAABAAAAAA9986520 ",
- " 1158899AAAAAAAAA99986511 ",
- " 1G88999AAAAAA9998711 ",
- " 11589999999999821 ",
- " 11789999998510 ",
- " 1278888511 ",
- " 0136511 ",
- " 111 ",
- " ",
- " "};
-
-static char **go_xpm[3] = { go_x16, go_x24, go_x32 };
-
diff --git a/app/bin/bitmaps/helix.xpm b/app/bin/bitmaps/helix.xpm deleted file mode 100644 index d02bb29..0000000 --- a/app/bin/bitmaps/helix.xpm +++ /dev/null @@ -1,95 +0,0 @@ -static char *helix_x16[] = {
- "16 16 4 1",
- " c None",
- "0 c #000000",
- "1 c #333333",
- "2 c #666666",
- " 1111 ",
- " 1111111111 ",
- " 11 11 11 ",
- " 11 111111111 1 ",
- "11111 1111",
- "111 2222222 11",
- "11 2222 22111",
- "112 11111",
- "111 1111 12",
- "22111 1112",
- "221 111111111 22",
- "2211 1 22 ",
- " 2 11111222222 ",
- " 22 1122 ",
- " 2222 ",
- " 2222 "};
-
-static char *helix_x24[] = {
- "24 24 4 1",
- " c None",
- "0 c #000000",
- "1 c #333333",
- "2 c #666666",
- " 11 ",
- " 11111111111 ",
- " 111 1111 ",
- " 11 11 ",
- " 11 11111111 1 ",
- " 1 1111 11 11111 1 ",
- " 11 111 111 1 ",
- " 1 11 22 111 ",
- " 111 22222222222 11 ",
- " 11 222 222111 ",
- " 11 22 1111 ",
- " 112 1111 21 ",
- " 111 1111111 11 ",
- " 1211 1122",
- " 22 111 111 2 ",
- " 21 1111111111111 2 ",
- " 221 1111111 2 ",
- " 22 11 22 ",
- " 2 1111 2222 ",
- " 22 11111222222 ",
- " 22 ",
- " 22 ",
- " 222222 ",
- " 22 "};
-
-static char *helix_x32[] = {
- "32 32 4 1",
- " c None",
- "0 c #000000",
- "1 c #333333",
- "2 c #666666",
- " 1 ",
- " 1111111111111 ",
- " 111111111111111111 ",
- " 11111 11111 ",
- " 111 1111 ",
- " 111 1111111 111 ",
- " 111 111111111111111 11 ",
- " 11 1111111 11 11111111 11 ",
- " 111 11111 11111 11 ",
- " 11 111 11111 ",
- " 11111 22222222222 1111 ",
- " 1111 22222222222222222 111 ",
- " 111 222222 2222221111 ",
- " 111 2222 211111 ",
- " 111222 1111211 ",
- " 11122 1111111 211 ",
- " 1111 1111111111 111 ",
- " 12111 111111 1112 ",
- " 2121111 111122 ",
- " 211 11111 11111 22 ",
- " 2211 1111111111111111111 22 ",
- " 22111 111111111111111 222 ",
- " 22 111 11 222 ",
- " 222 1111 22222 ",
- " 22 111111 222222 ",
- " 22 11111111222222222 ",
- " 222 11111222222 ",
- " 2222 ",
- " 22222 ",
- " 2222222 ",
- " 22222222 ",
- " 2222 "};
-
-static char **helix_xpm[3] = { helix_x16, helix_x24, helix_x32 };
-
diff --git a/app/bin/bitmaps/join-line.xpm b/app/bin/bitmaps/join-line.xpm deleted file mode 100644 index 1912e9a..0000000 --- a/app/bin/bitmaps/join-line.xpm +++ /dev/null @@ -1,99 +0,0 @@ -static char *join_line_x16[] = {
- "16 16 5 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #CC0000",
- "3 c #800000",
- " ",
- " 00",
- " 0 ",
- " 0 ",
- " 0 ",
- " 223 ",
- " 222 ",
- " 222 ",
- " 2 ",
- " 2 ",
- " 2 ",
- " 2 2 ",
- " 222 ",
- " 022 ",
- " 00000 22 ",
- " 000 "};
-
-static char *join_line_x24[] = {
- "24 24 5 1",
- " c None",
- "0 c #000000",
- "1 c #990000",
- "2 c #CC0000",
- "3 c #800000",
- " ",
- " 0 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 0 ",
- " 00 ",
- " 2223 ",
- " 2222 ",
- " 2222 ",
- " 22 ",
- " 2 ",
- " 22 ",
- " 22 ",
- " 22 ",
- " 22 ",
- " 2 22 ",
- " 22222 ",
- " 222 ",
- " 0122 ",
- " 0000 22 ",
- " 000000 ",
- " "};
-
-static char *join_line_x32[] = {
- "32 32 6 1",
- " c None",
- "0 c #000000",
- "1 c #660000",
- "2 c #990000",
- "3 c #CC0000",
- "4 c #800000",
- " ",
- " 0 ",
- " 0 ",
- " 0 ",
- " 0 ",
- " 0 ",
- " 00 ",
- " 00 ",
- " 0 ",
- " 0 ",
- " 21 ",
- " 333333 ",
- " 3333333 ",
- " 33333 ",
- " 33 33 ",
- " 333 ",
- " 33 ",
- " 33 ",
- " 333 ",
- " 333 ",
- " 333 ",
- " 333 ",
- " 333 ",
- " 33 333 ",
- " 33 3333 ",
- " 33333 ",
- " 3333 ",
- " 04333 ",
- " 0000 333 ",
- " 0000000 3 ",
- " 00000 ",
- " "};
-
-static char **join_line_xpm[3] = { join_line_x16, join_line_x24, join_line_x32 };
-
diff --git a/app/bin/bitmaps/join.xpm b/app/bin/bitmaps/join.xpm deleted file mode 100644 index 944e443..0000000 --- a/app/bin/bitmaps/join.xpm +++ /dev/null @@ -1,117 +0,0 @@ -static char *join_x16[] = {
- "16 16 13 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #660000",
- "4 c #663300",
- "5 c #990000",
- "6 c #996600",
- "7 c #CC0000",
- "8 c #CC3300",
- "9 c #CC6600",
- "A c #CC9900",
- "B c #800000",
- " 66 0 ",
- " 66A2A",
- " 20 0 ",
- " A4964 ",
- " 3 46 ",
- " 7777B ",
- " 777 ",
- " 77 ",
- " 7 ",
- " 7 ",
- " 7 77 ",
- " 9161777 ",
- "0406977 ",
- " A A6157 ",
- "04006 ",
- " 9 A "};
-
-static char *join_x24[] = {
- "24 24 10 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #663300",
- "4 c #990000",
- "5 c #996600",
- "6 c #CC0000",
- "7 c #CC6600",
- "8 c #CC9900",
- " 0 ",
- " 8558827 ",
- " 338818 ",
- " 00 0 ",
- " 825 0 ",
- " 7288538 ",
- " 00 158 ",
- " 6666660 ",
- " 6666664 ",
- " 66666 ",
- " 66 666 ",
- " 666 6 ",
- " 666 ",
- " 666 ",
- " 6 666 ",
- " 66 666 ",
- " 666666 ",
- " 7 33066666 ",
- " 02007 666 ",
- " 8 8866666 ",
- " 8 8500466 ",
- " 350005 ",
- " 15 8 ",
- " 8 "};
-
-static char *join_x32[] = {
- "32 32 11 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #663300",
- "4 c #990000",
- "5 c #996600",
- "6 c #CC0000",
- "7 c #CC6600",
- "8 c #CC9900",
- "9 c #800000",
- " ",
- " 20 00 ",
- " 855888558 ",
- " 00 05 ",
- " 0 0 ",
- " 0 0 ",
- " 88388 0 ",
- " 03888758 ",
- " 0 038 ",
- " 64666 0 ",
- " 666666660 ",
- " 666666664 ",
- " 666666 ",
- " 666 666 ",
- " 666 666 ",
- " 6666 ",
- " 6666 ",
- " 6666 ",
- " 6666 ",
- " 66 6666 ",
- " 66 6666 ",
- " 666 66666 ",
- " 87096666666 ",
- " 88 0320666666 ",
- " 0100038 66666 ",
- " 78 8 666666 ",
- " 88 88 46666 ",
- " 88 7000 666 ",
- " 57000033 ",
- " 02300 88 ",
- " 8 8 ",
- " 8 "};
-
-static char **join_xpm[3] = { join_x16, join_x24, join_x32 };
-
diff --git a/app/bin/bitmaps/l1.xbm b/app/bin/bitmaps/l1.xbm deleted file mode 100644 index 031edd1..0000000 --- a/app/bin/bitmaps/l1.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l1_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x80, 0x03,
- 0xC0, 0x03,
- 0xE0, 0x03,
- 0x80, 0x03,
- 0x80, 0x03,
- 0x80, 0x03,
- 0x80, 0x03,
- 0x80, 0x03,
- 0x80, 0x03,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l1_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x1C, 0x00,
- 0x00, 0x1E, 0x00,
- 0x00, 0x1E, 0x00,
- 0x00, 0x1F, 0x00,
- 0x80, 0x1D, 0x00,
- 0x00, 0x1C, 0x00,
- 0x00, 0x1C, 0x00,
- 0x00, 0x1C, 0x00,
- 0x00, 0x1C, 0x00,
- 0x00, 0x1C, 0x00,
- 0x00, 0x1C, 0x00,
- 0x00, 0x1C, 0x00,
- 0x00, 0x1C, 0x00,
- 0x00, 0x1C, 0x00,
- 0x00, 0x1C, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l1_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xE0, 0x00, 0x00,
- 0x00, 0xE0, 0x00, 0x00,
- 0x00, 0xF0, 0x00, 0x00,
- 0x00, 0xF8, 0x00, 0x00,
- 0x00, 0xFC, 0x00, 0x00,
- 0x00, 0xFE, 0x00, 0x00,
- 0x00, 0xE6, 0x00, 0x00,
- 0x00, 0xE0, 0x00, 0x00,
- 0x00, 0xE0, 0x00, 0x00,
- 0x00, 0xE0, 0x00, 0x00,
- 0x00, 0xE0, 0x00, 0x00,
- 0x00, 0xE0, 0x00, 0x00,
- 0x00, 0xE0, 0x00, 0x00,
- 0x00, 0xE0, 0x00, 0x00,
- 0x00, 0xE0, 0x00, 0x00,
- 0x00, 0xE0, 0x00, 0x00,
- 0x00, 0xE0, 0x00, 0x00,
- 0x00, 0xE0, 0x00, 0x00,
- 0x00, 0xE0, 0x00, 0x00,
- 0x00, 0xE0, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l10.xbm b/app/bin/bitmaps/l10.xbm deleted file mode 100644 index 10920b9..0000000 --- a/app/bin/bitmaps/l10.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l10_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x70, 0x1E,
- 0x78, 0x3F,
- 0x7C, 0x33,
- 0x70, 0x33,
- 0x70, 0x33,
- 0x70, 0x33,
- 0x70, 0x33,
- 0x70, 0x3F,
- 0x70, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l10_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xC0, 0xE1, 0x03,
- 0xE0, 0x71, 0x07,
- 0xE0, 0x31, 0x07,
- 0xF0, 0x39, 0x06,
- 0xD8, 0x39, 0x06,
- 0xC0, 0x39, 0x0E,
- 0xC0, 0x39, 0x0E,
- 0xC0, 0x39, 0x0E,
- 0xC0, 0x39, 0x0E,
- 0xC0, 0x39, 0x0E,
- 0xC0, 0x39, 0x06,
- 0xC0, 0x39, 0x06,
- 0xC0, 0x31, 0x07,
- 0xC0, 0x71, 0x07,
- 0xC0, 0xE1, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l10_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x03, 0x7E, 0x00,
- 0x80, 0x03, 0xFF, 0x00,
- 0xC0, 0x03, 0xEF, 0x01,
- 0xE0, 0x83, 0xC7, 0x01,
- 0xF0, 0x83, 0xC3, 0x03,
- 0xF8, 0x83, 0xC3, 0x03,
- 0x98, 0xC3, 0x83, 0x03,
- 0x80, 0xC3, 0x83, 0x03,
- 0x80, 0xC3, 0x83, 0x03,
- 0x80, 0xC3, 0x83, 0x03,
- 0x80, 0xC3, 0x83, 0x03,
- 0x80, 0xC3, 0x83, 0x03,
- 0x80, 0xC3, 0x83, 0x03,
- 0x80, 0xC3, 0x83, 0x03,
- 0x80, 0x83, 0xC3, 0x03,
- 0x80, 0x83, 0xC3, 0x03,
- 0x80, 0x83, 0xC7, 0x01,
- 0x80, 0x03, 0xEF, 0x01,
- 0x80, 0x03, 0xFF, 0x00,
- 0x80, 0x03, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l11.xbm b/app/bin/bitmaps/l11.xbm deleted file mode 100644 index ce82cfe..0000000 --- a/app/bin/bitmaps/l11.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l11_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x70, 0x1C,
- 0x78, 0x1E,
- 0x7C, 0x1F,
- 0x70, 0x1C,
- 0x70, 0x1C,
- 0x70, 0x1C,
- 0x70, 0x1C,
- 0x70, 0x1C,
- 0x70, 0x1C,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l11_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xC0, 0x81, 0x03,
- 0xE0, 0xC1, 0x03,
- 0xE0, 0xC1, 0x03,
- 0xF0, 0xE1, 0x03,
- 0xD8, 0xB1, 0x03,
- 0xC0, 0x81, 0x03,
- 0xC0, 0x81, 0x03,
- 0xC0, 0x81, 0x03,
- 0xC0, 0x81, 0x03,
- 0xC0, 0x81, 0x03,
- 0xC0, 0x81, 0x03,
- 0xC0, 0x81, 0x03,
- 0xC0, 0x81, 0x03,
- 0xC0, 0x81, 0x03,
- 0xC0, 0x81, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l11_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x03, 0x70, 0x00,
- 0x80, 0x03, 0x70, 0x00,
- 0xC0, 0x03, 0x78, 0x00,
- 0xE0, 0x03, 0x7C, 0x00,
- 0xF0, 0x03, 0x7E, 0x00,
- 0xF8, 0x03, 0x7F, 0x00,
- 0x98, 0x03, 0x73, 0x00,
- 0x80, 0x03, 0x70, 0x00,
- 0x80, 0x03, 0x70, 0x00,
- 0x80, 0x03, 0x70, 0x00,
- 0x80, 0x03, 0x70, 0x00,
- 0x80, 0x03, 0x70, 0x00,
- 0x80, 0x03, 0x70, 0x00,
- 0x80, 0x03, 0x70, 0x00,
- 0x80, 0x03, 0x70, 0x00,
- 0x80, 0x03, 0x70, 0x00,
- 0x80, 0x03, 0x70, 0x00,
- 0x80, 0x03, 0x70, 0x00,
- 0x80, 0x03, 0x70, 0x00,
- 0x80, 0x03, 0x70, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l12.xbm b/app/bin/bitmaps/l12.xbm deleted file mode 100644 index e660ef3..0000000 --- a/app/bin/bitmaps/l12.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l12_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x70, 0x1E,
- 0x78, 0x3F,
- 0x7C, 0x33,
- 0x70, 0x30,
- 0x70, 0x38,
- 0x70, 0x1C,
- 0x70, 0x0E,
- 0x70, 0x07,
- 0x70, 0x3F,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l12_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xC0, 0xE1, 0x03,
- 0xE0, 0x71, 0x07,
- 0xE0, 0x39, 0x06,
- 0xF0, 0x39, 0x0E,
- 0xD8, 0x01, 0x0E,
- 0xC0, 0x01, 0x0E,
- 0xC0, 0x01, 0x07,
- 0xC0, 0x81, 0x07,
- 0xC0, 0x81, 0x03,
- 0xC0, 0xC1, 0x01,
- 0xC0, 0xE1, 0x01,
- 0xC0, 0xF1, 0x00,
- 0xC0, 0x71, 0x00,
- 0xC0, 0x79, 0x00,
- 0xC0, 0xF9, 0x0F,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l12_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x03, 0xFE, 0x00,
- 0x80, 0x03, 0xFF, 0x01,
- 0xC0, 0x83, 0xE7, 0x03,
- 0xE0, 0x83, 0xC3, 0x03,
- 0xF0, 0xC3, 0x83, 0x03,
- 0xF8, 0xC3, 0x83, 0x03,
- 0x98, 0x03, 0x80, 0x03,
- 0x80, 0x03, 0xC0, 0x03,
- 0x80, 0x03, 0xC0, 0x03,
- 0x80, 0x03, 0xE0, 0x01,
- 0x80, 0x03, 0xF0, 0x01,
- 0x80, 0x03, 0xF8, 0x00,
- 0x80, 0x03, 0x78, 0x00,
- 0x80, 0x03, 0x3C, 0x00,
- 0x80, 0x03, 0x1E, 0x00,
- 0x80, 0x03, 0x0F, 0x00,
- 0x80, 0x83, 0x07, 0x00,
- 0x80, 0x83, 0x07, 0x00,
- 0x80, 0xC3, 0xFF, 0x03,
- 0x80, 0xC3, 0xFF, 0x03,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l13.xbm b/app/bin/bitmaps/l13.xbm deleted file mode 100644 index a11c7f7..0000000 --- a/app/bin/bitmaps/l13.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l13_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x70, 0x1E,
- 0x78, 0x3B,
- 0x7C, 0x38,
- 0x70, 0x18,
- 0x70, 0x3C,
- 0x70, 0x38,
- 0x70, 0x33,
- 0x70, 0x3F,
- 0x70, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l13_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xC0, 0xE1, 0x03,
- 0xE0, 0x71, 0x07,
- 0xE0, 0x39, 0x07,
- 0xF0, 0x01, 0x07,
- 0xD8, 0x01, 0x07,
- 0xC0, 0x01, 0x07,
- 0xC0, 0x81, 0x03,
- 0xC0, 0xC1, 0x07,
- 0xC0, 0x01, 0x07,
- 0xC0, 0x01, 0x0E,
- 0xC0, 0x01, 0x0E,
- 0xC0, 0x39, 0x0E,
- 0xC0, 0x39, 0x07,
- 0xC0, 0x71, 0x07,
- 0xC0, 0xE1, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l13_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x03, 0x7E, 0x00,
- 0x80, 0x03, 0xFF, 0x00,
- 0xC0, 0x83, 0xE7, 0x01,
- 0xE0, 0x83, 0xC7, 0x01,
- 0xF0, 0x83, 0xC3, 0x03,
- 0xF8, 0x03, 0xC0, 0x03,
- 0x98, 0x03, 0xC0, 0x01,
- 0x80, 0x03, 0xE0, 0x01,
- 0x80, 0x03, 0xFC, 0x00,
- 0x80, 0x03, 0xFC, 0x00,
- 0x80, 0x03, 0xE0, 0x01,
- 0x80, 0x03, 0xC0, 0x03,
- 0x80, 0x03, 0x80, 0x03,
- 0x80, 0x03, 0x80, 0x03,
- 0x80, 0xC3, 0x83, 0x03,
- 0x80, 0xC3, 0x83, 0x03,
- 0x80, 0x83, 0xC7, 0x03,
- 0x80, 0x83, 0xE7, 0x01,
- 0x80, 0x03, 0xFF, 0x01,
- 0x80, 0x03, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l14.xbm b/app/bin/bitmaps/l14.xbm deleted file mode 100644 index 765ca93..0000000 --- a/app/bin/bitmaps/l14.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l14_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x70, 0x1C,
- 0x78, 0x1C,
- 0x7C, 0x1E,
- 0x70, 0x1E,
- 0x70, 0x1F,
- 0x70, 0x1B,
- 0xF0, 0x3F,
- 0x70, 0x18,
- 0x70, 0x18,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l14_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xC0, 0x81, 0x03,
- 0xE0, 0x81, 0x03,
- 0xE0, 0xC1, 0x03,
- 0xF0, 0xC1, 0x03,
- 0xD8, 0xE1, 0x03,
- 0xC0, 0xE1, 0x03,
- 0xC0, 0xF1, 0x03,
- 0xC0, 0xB1, 0x03,
- 0xC0, 0xB9, 0x03,
- 0xC0, 0x99, 0x03,
- 0xC0, 0xFD, 0x0F,
- 0xC0, 0x81, 0x03,
- 0xC0, 0x81, 0x03,
- 0xC0, 0x81, 0x03,
- 0xC0, 0x81, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l14_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x03, 0xF0, 0x00,
- 0x80, 0x03, 0xF0, 0x00,
- 0xC0, 0x03, 0xF8, 0x00,
- 0xE0, 0x03, 0xF8, 0x00,
- 0xF0, 0x03, 0xFC, 0x00,
- 0xF8, 0x03, 0xFC, 0x00,
- 0x98, 0x03, 0xFE, 0x00,
- 0x80, 0x03, 0xEE, 0x00,
- 0x80, 0x03, 0xEF, 0x00,
- 0x80, 0x83, 0xE7, 0x00,
- 0x80, 0x83, 0xE7, 0x00,
- 0x80, 0xC3, 0xE3, 0x00,
- 0x80, 0xC3, 0xE1, 0x00,
- 0x80, 0xE3, 0xFF, 0x03,
- 0x80, 0xE3, 0xFF, 0x03,
- 0x80, 0x03, 0xE0, 0x00,
- 0x80, 0x03, 0xE0, 0x00,
- 0x80, 0x03, 0xE0, 0x00,
- 0x80, 0x03, 0xE0, 0x00,
- 0x80, 0x03, 0xE0, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l15.xbm b/app/bin/bitmaps/l15.xbm deleted file mode 100644 index 7850754..0000000 --- a/app/bin/bitmaps/l15.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l15_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x70, 0x3F,
- 0x78, 0x07,
- 0x7C, 0x07,
- 0x70, 0x1F,
- 0x70, 0x3B,
- 0x70, 0x30,
- 0x70, 0x33,
- 0x70, 0x3F,
- 0x70, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l15_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xC0, 0xF1, 0x07,
- 0xE0, 0x71, 0x00,
- 0xE0, 0x71, 0x00,
- 0xF0, 0x31, 0x00,
- 0xD8, 0x31, 0x00,
- 0xC0, 0xF9, 0x03,
- 0xC0, 0x79, 0x07,
- 0xC0, 0x39, 0x07,
- 0xC0, 0x01, 0x0E,
- 0xC0, 0x01, 0x0E,
- 0xC0, 0x01, 0x0E,
- 0xC0, 0x39, 0x06,
- 0xC0, 0x39, 0x07,
- 0xC0, 0x71, 0x07,
- 0xC0, 0xE1, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l15_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x03, 0xFF, 0x03,
- 0x80, 0x03, 0xFF, 0x03,
- 0xC0, 0x03, 0x07, 0x00,
- 0xE0, 0x03, 0x07, 0x00,
- 0xF0, 0x83, 0x07, 0x00,
- 0xF8, 0x83, 0x07, 0x00,
- 0x98, 0x83, 0x7F, 0x00,
- 0x80, 0x83, 0xFF, 0x01,
- 0x80, 0x83, 0xE7, 0x01,
- 0x80, 0x83, 0xC3, 0x03,
- 0x80, 0x03, 0xC0, 0x03,
- 0x80, 0x03, 0x80, 0x03,
- 0x80, 0x03, 0x80, 0x03,
- 0x80, 0x03, 0x80, 0x03,
- 0x80, 0xC3, 0x83, 0x03,
- 0x80, 0xC3, 0xC3, 0x03,
- 0x80, 0x83, 0xC3, 0x03,
- 0x80, 0x83, 0xE7, 0x01,
- 0x80, 0x03, 0xFF, 0x00,
- 0x80, 0x03, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l16.xbm b/app/bin/bitmaps/l16.xbm deleted file mode 100644 index 88e94f6..0000000 --- a/app/bin/bitmaps/l16.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l16_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x70, 0x1E,
- 0x78, 0x3F,
- 0x7C, 0x03,
- 0x70, 0x1F,
- 0x70, 0x3F,
- 0x70, 0x33,
- 0x70, 0x33,
- 0x70, 0x3F,
- 0x70, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l16_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xC0, 0xE1, 0x03,
- 0xE0, 0x71, 0x07,
- 0xE0, 0x31, 0x07,
- 0xF0, 0x39, 0x00,
- 0xD8, 0x39, 0x00,
- 0xC0, 0x39, 0x00,
- 0xC0, 0xF9, 0x03,
- 0xC0, 0x79, 0x07,
- 0xC0, 0x39, 0x07,
- 0xC0, 0x39, 0x0E,
- 0xC0, 0x39, 0x0E,
- 0xC0, 0x39, 0x0E,
- 0xC0, 0x31, 0x07,
- 0xC0, 0x71, 0x07,
- 0xC0, 0xE1, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l16_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x03, 0xFC, 0x00,
- 0x80, 0x03, 0xFF, 0x01,
- 0xC0, 0x03, 0xEF, 0x01,
- 0xE0, 0x83, 0xC7, 0x03,
- 0xF0, 0x83, 0xC3, 0x03,
- 0xF8, 0x83, 0x03, 0x00,
- 0x98, 0xC3, 0x03, 0x00,
- 0x80, 0xC3, 0x7F, 0x00,
- 0x80, 0xC3, 0xFF, 0x01,
- 0x80, 0xC3, 0xEF, 0x01,
- 0x80, 0xC3, 0xC7, 0x03,
- 0x80, 0xC3, 0x83, 0x03,
- 0x80, 0xC3, 0x83, 0x03,
- 0x80, 0xC3, 0x83, 0x03,
- 0x80, 0xC3, 0x83, 0x03,
- 0x80, 0x83, 0x83, 0x03,
- 0x80, 0x83, 0xC7, 0x03,
- 0x80, 0x83, 0xEF, 0x01,
- 0x80, 0x03, 0xFF, 0x01,
- 0x80, 0x03, 0x7C, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l17.xbm b/app/bin/bitmaps/l17.xbm deleted file mode 100644 index df3fb94..0000000 --- a/app/bin/bitmaps/l17.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l17_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x70, 0x3F,
- 0x78, 0x38,
- 0x7C, 0x18,
- 0x70, 0x1C,
- 0x70, 0x0C,
- 0x70, 0x0E,
- 0x70, 0x0E,
- 0x70, 0x06,
- 0x70, 0x06,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l17_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xC0, 0xF9, 0x0F,
- 0xE0, 0x01, 0x0F,
- 0xE0, 0x01, 0x07,
- 0xF0, 0x81, 0x03,
- 0xD8, 0x81, 0x03,
- 0xC0, 0xC1, 0x01,
- 0xC0, 0xC1, 0x01,
- 0xC0, 0xC1, 0x01,
- 0xC0, 0xE1, 0x00,
- 0xC0, 0xE1, 0x00,
- 0xC0, 0xE1, 0x00,
- 0xC0, 0xE1, 0x00,
- 0xC0, 0xE1, 0x00,
- 0xC0, 0x71, 0x00,
- 0xC0, 0x71, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l17_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x80, 0xC3, 0xFF, 0x03,
- 0x80, 0xC3, 0xFF, 0x03,
- 0xC0, 0x03, 0xC0, 0x03,
- 0xE0, 0x03, 0xE0, 0x01,
- 0xF0, 0x03, 0xE0, 0x01,
- 0xF8, 0x03, 0xF0, 0x00,
- 0x98, 0x03, 0xF0, 0x00,
- 0x80, 0x03, 0x78, 0x00,
- 0x80, 0x03, 0x78, 0x00,
- 0x80, 0x03, 0x38, 0x00,
- 0x80, 0x03, 0x3C, 0x00,
- 0x80, 0x03, 0x3C, 0x00,
- 0x80, 0x03, 0x1C, 0x00,
- 0x80, 0x03, 0x1E, 0x00,
- 0x80, 0x03, 0x1E, 0x00,
- 0x80, 0x03, 0x1E, 0x00,
- 0x80, 0x03, 0x1E, 0x00,
- 0x80, 0x03, 0x0E, 0x00,
- 0x80, 0x03, 0x0E, 0x00,
- 0x80, 0x03, 0x0E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l18.xbm b/app/bin/bitmaps/l18.xbm deleted file mode 100644 index 7ab0b30..0000000 --- a/app/bin/bitmaps/l18.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l18_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x70, 0x1E,
- 0x78, 0x3F,
- 0x7C, 0x3B,
- 0x70, 0x3F,
- 0x70, 0x1E,
- 0x70, 0x3F,
- 0x70, 0x33,
- 0x70, 0x3F,
- 0x70, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l18_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xC0, 0xE1, 0x03,
- 0xE0, 0x71, 0x07,
- 0xE0, 0x31, 0x07,
- 0xF0, 0x39, 0x07,
- 0xD8, 0x39, 0x07,
- 0xC0, 0x39, 0x07,
- 0xC0, 0x71, 0x07,
- 0xC0, 0xE1, 0x03,
- 0xC0, 0x71, 0x07,
- 0xC0, 0x39, 0x06,
- 0xC0, 0x39, 0x0E,
- 0xC0, 0x39, 0x0E,
- 0xC0, 0x39, 0x06,
- 0xC0, 0x71, 0x07,
- 0xC0, 0xE1, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l18_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x03, 0x7E, 0x00,
- 0x80, 0x03, 0xFF, 0x00,
- 0xC0, 0x83, 0xEF, 0x01,
- 0xE0, 0x83, 0xC7, 0x01,
- 0xF0, 0x83, 0xC3, 0x03,
- 0xF8, 0x83, 0xC3, 0x03,
- 0x98, 0x83, 0xC7, 0x01,
- 0x80, 0x03, 0xEF, 0x01,
- 0x80, 0x03, 0xFE, 0x00,
- 0x80, 0x03, 0xFF, 0x00,
- 0x80, 0x83, 0xE7, 0x01,
- 0x80, 0x83, 0xC3, 0x03,
- 0x80, 0xC3, 0x83, 0x03,
- 0x80, 0xC3, 0x83, 0x03,
- 0x80, 0xC3, 0x83, 0x03,
- 0x80, 0xC3, 0x83, 0x03,
- 0x80, 0x83, 0xC3, 0x03,
- 0x80, 0x83, 0xE7, 0x01,
- 0x80, 0x03, 0xFF, 0x01,
- 0x80, 0x03, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l19.xbm b/app/bin/bitmaps/l19.xbm deleted file mode 100644 index 08aee34..0000000 --- a/app/bin/bitmaps/l19.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l19_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x70, 0x1E,
- 0x78, 0x3F,
- 0x7C, 0x33,
- 0x70, 0x33,
- 0x70, 0x3F,
- 0x70, 0x3E,
- 0x70, 0x30,
- 0x70, 0x3B,
- 0x70, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l19_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xC0, 0xE1, 0x01,
- 0xE0, 0x71, 0x07,
- 0xE0, 0x39, 0x07,
- 0xF0, 0x39, 0x06,
- 0xD8, 0x39, 0x0E,
- 0xC0, 0x39, 0x0E,
- 0xC0, 0x39, 0x0F,
- 0xC0, 0x71, 0x0F,
- 0xC0, 0xE1, 0x0F,
- 0xC0, 0x01, 0x0E,
- 0xC0, 0x01, 0x06,
- 0xC0, 0x01, 0x06,
- 0xC0, 0x39, 0x07,
- 0xC0, 0x71, 0x03,
- 0xC0, 0xF1, 0x01,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l19_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x03, 0x7E, 0x00,
- 0x80, 0x03, 0xFF, 0x00,
- 0xC0, 0x83, 0xEF, 0x01,
- 0xE0, 0x83, 0xC7, 0x01,
- 0xF0, 0xC3, 0x83, 0x03,
- 0xF8, 0xC3, 0x83, 0x03,
- 0x98, 0xC3, 0x83, 0x03,
- 0x80, 0xC3, 0x83, 0x03,
- 0x80, 0xC3, 0x83, 0x03,
- 0x80, 0x83, 0xC3, 0x03,
- 0x80, 0x83, 0xE7, 0x03,
- 0x80, 0x03, 0xFF, 0x03,
- 0x80, 0x03, 0xFE, 0x03,
- 0x80, 0x03, 0x80, 0x03,
- 0x80, 0x03, 0x80, 0x03,
- 0x80, 0x83, 0xC3, 0x03,
- 0x80, 0x83, 0xC3, 0x01,
- 0x80, 0x83, 0xE7, 0x01,
- 0x80, 0x03, 0xFF, 0x00,
- 0x80, 0x03, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l2.xbm b/app/bin/bitmaps/l2.xbm deleted file mode 100644 index 4ab709c..0000000 --- a/app/bin/bitmaps/l2.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l2_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0xC0, 0x03,
- 0xE0, 0x07,
- 0x60, 0x06,
- 0x00, 0x06,
- 0x00, 0x07,
- 0x80, 0x03,
- 0xC0, 0x01,
- 0xE0, 0x00,
- 0xE0, 0x07,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l2_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x1F, 0x00,
- 0x80, 0x3B, 0x00,
- 0xC0, 0x31, 0x00,
- 0xC0, 0x71, 0x00,
- 0x00, 0x70, 0x00,
- 0x00, 0x70, 0x00,
- 0x00, 0x38, 0x00,
- 0x00, 0x3C, 0x00,
- 0x00, 0x1C, 0x00,
- 0x00, 0x0E, 0x00,
- 0x00, 0x0F, 0x00,
- 0x80, 0x07, 0x00,
- 0x80, 0x03, 0x00,
- 0xC0, 0x03, 0x00,
- 0xC0, 0x7F, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l2_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xFC, 0x01, 0x00,
- 0x00, 0xFE, 0x03, 0x00,
- 0x00, 0xCF, 0x07, 0x00,
- 0x00, 0x87, 0x07, 0x00,
- 0x80, 0x07, 0x07, 0x00,
- 0x80, 0x07, 0x07, 0x00,
- 0x00, 0x00, 0x07, 0x00,
- 0x00, 0x80, 0x07, 0x00,
- 0x00, 0x80, 0x07, 0x00,
- 0x00, 0xC0, 0x03, 0x00,
- 0x00, 0xE0, 0x03, 0x00,
- 0x00, 0xF0, 0x01, 0x00,
- 0x00, 0xF0, 0x00, 0x00,
- 0x00, 0x78, 0x00, 0x00,
- 0x00, 0x3C, 0x00, 0x00,
- 0x00, 0x1E, 0x00, 0x00,
- 0x00, 0x0F, 0x00, 0x00,
- 0x00, 0x0F, 0x00, 0x00,
- 0x80, 0xFF, 0x07, 0x00,
- 0x80, 0xFF, 0x07, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l20.xbm b/app/bin/bitmaps/l20.xbm deleted file mode 100644 index 9da3bef..0000000 --- a/app/bin/bitmaps/l20.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l20_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1E,
- 0xFC, 0x3F,
- 0xCC, 0x33,
- 0xC0, 0x33,
- 0xE0, 0x33,
- 0x70, 0x33,
- 0x38, 0x33,
- 0x1C, 0x3F,
- 0xFC, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l20_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xE1, 0x03,
- 0xB8, 0x73, 0x07,
- 0x1C, 0x33, 0x07,
- 0x1C, 0x3F, 0x06,
- 0x00, 0x3F, 0x06,
- 0x00, 0x3F, 0x0E,
- 0x80, 0x3B, 0x0E,
- 0xC0, 0x3B, 0x0E,
- 0xC0, 0x39, 0x0E,
- 0xE0, 0x38, 0x0E,
- 0xF0, 0x38, 0x06,
- 0x78, 0x38, 0x06,
- 0x38, 0x30, 0x07,
- 0x3C, 0x70, 0x07,
- 0xFC, 0xE7, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l20_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x07, 0x7E, 0x00,
- 0xF8, 0x0F, 0xFF, 0x00,
- 0x3C, 0x1F, 0xEF, 0x01,
- 0x1C, 0x9E, 0xC7, 0x01,
- 0x1E, 0x9C, 0xC3, 0x03,
- 0x1E, 0x9C, 0xC3, 0x03,
- 0x00, 0xDC, 0x83, 0x03,
- 0x00, 0xDE, 0x83, 0x03,
- 0x00, 0xDE, 0x83, 0x03,
- 0x00, 0xCF, 0x83, 0x03,
- 0x80, 0xCF, 0x83, 0x03,
- 0xC0, 0xC7, 0x83, 0x03,
- 0xC0, 0xC3, 0x83, 0x03,
- 0xE0, 0xC1, 0x83, 0x03,
- 0xF0, 0x80, 0xC3, 0x03,
- 0x78, 0x80, 0xC3, 0x03,
- 0x3C, 0x80, 0xC7, 0x01,
- 0x3C, 0x00, 0xEF, 0x01,
- 0xFE, 0x1F, 0xFF, 0x00,
- 0xFE, 0x1F, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l21.xbm b/app/bin/bitmaps/l21.xbm deleted file mode 100644 index 32d81cc..0000000 --- a/app/bin/bitmaps/l21.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l21_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1C,
- 0xFC, 0x1E,
- 0xCC, 0x1F,
- 0xC0, 0x1C,
- 0xE0, 0x1C,
- 0x70, 0x1C,
- 0x38, 0x1C,
- 0x1C, 0x1C,
- 0xFC, 0x1C,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l21_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0x81, 0x03,
- 0xB8, 0xC3, 0x03,
- 0x1C, 0xC3, 0x03,
- 0x1C, 0xE7, 0x03,
- 0x00, 0xB7, 0x03,
- 0x00, 0x87, 0x03,
- 0x80, 0x83, 0x03,
- 0xC0, 0x83, 0x03,
- 0xC0, 0x81, 0x03,
- 0xE0, 0x80, 0x03,
- 0xF0, 0x80, 0x03,
- 0x78, 0x80, 0x03,
- 0x38, 0x80, 0x03,
- 0x3C, 0x80, 0x03,
- 0xFC, 0x87, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l21_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x07, 0x70, 0x00,
- 0xF8, 0x0F, 0x70, 0x00,
- 0x3C, 0x1F, 0x78, 0x00,
- 0x1C, 0x1E, 0x7C, 0x00,
- 0x1E, 0x1C, 0x7E, 0x00,
- 0x1E, 0x1C, 0x7F, 0x00,
- 0x00, 0x1C, 0x73, 0x00,
- 0x00, 0x1E, 0x70, 0x00,
- 0x00, 0x1E, 0x70, 0x00,
- 0x00, 0x0F, 0x70, 0x00,
- 0x80, 0x0F, 0x70, 0x00,
- 0xC0, 0x07, 0x70, 0x00,
- 0xC0, 0x03, 0x70, 0x00,
- 0xE0, 0x01, 0x70, 0x00,
- 0xF0, 0x00, 0x70, 0x00,
- 0x78, 0x00, 0x70, 0x00,
- 0x3C, 0x00, 0x70, 0x00,
- 0x3C, 0x00, 0x70, 0x00,
- 0xFE, 0x1F, 0x70, 0x00,
- 0xFE, 0x1F, 0x70, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l22.xbm b/app/bin/bitmaps/l22.xbm deleted file mode 100644 index 9cfc394..0000000 --- a/app/bin/bitmaps/l22.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l22_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1E,
- 0xFC, 0x3F,
- 0xCC, 0x33,
- 0xC0, 0x30,
- 0xE0, 0x38,
- 0x70, 0x1C,
- 0x38, 0x0E,
- 0x1C, 0x07,
- 0xFC, 0x3F,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l22_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xE1, 0x03,
- 0xB8, 0x73, 0x07,
- 0x1C, 0x3B, 0x06,
- 0x1C, 0x3F, 0x0E,
- 0x00, 0x07, 0x0E,
- 0x00, 0x07, 0x0E,
- 0x80, 0x03, 0x07,
- 0xC0, 0x83, 0x07,
- 0xC0, 0x81, 0x03,
- 0xE0, 0xC0, 0x01,
- 0xF0, 0xE0, 0x01,
- 0x78, 0xF0, 0x00,
- 0x38, 0x70, 0x00,
- 0x3C, 0x78, 0x00,
- 0xFC, 0xFF, 0x0F,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l22_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x07, 0xFE, 0x00,
- 0xF8, 0x0F, 0xFF, 0x01,
- 0x3C, 0x9F, 0xE7, 0x03,
- 0x1C, 0x9E, 0xC3, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x00, 0x1C, 0x80, 0x03,
- 0x00, 0x1E, 0xC0, 0x03,
- 0x00, 0x1E, 0xC0, 0x03,
- 0x00, 0x0F, 0xE0, 0x01,
- 0x80, 0x0F, 0xF0, 0x01,
- 0xC0, 0x07, 0xF8, 0x00,
- 0xC0, 0x03, 0x78, 0x00,
- 0xE0, 0x01, 0x3C, 0x00,
- 0xF0, 0x00, 0x1E, 0x00,
- 0x78, 0x00, 0x0F, 0x00,
- 0x3C, 0x80, 0x07, 0x00,
- 0x3C, 0x80, 0x07, 0x00,
- 0xFE, 0xDF, 0xFF, 0x03,
- 0xFE, 0xDF, 0xFF, 0x03,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l23.xbm b/app/bin/bitmaps/l23.xbm deleted file mode 100644 index efb4ac4..0000000 --- a/app/bin/bitmaps/l23.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l23_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1E,
- 0xFC, 0x3B,
- 0xCC, 0x38,
- 0xC0, 0x18,
- 0xE0, 0x3C,
- 0x70, 0x38,
- 0x38, 0x33,
- 0x1C, 0x3F,
- 0xFC, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l23_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xE1, 0x03,
- 0xB8, 0x73, 0x07,
- 0x1C, 0x3B, 0x07,
- 0x1C, 0x07, 0x07,
- 0x00, 0x07, 0x07,
- 0x00, 0x07, 0x07,
- 0x80, 0x83, 0x03,
- 0xC0, 0xC3, 0x07,
- 0xC0, 0x01, 0x07,
- 0xE0, 0x00, 0x0E,
- 0xF0, 0x00, 0x0E,
- 0x78, 0x38, 0x0E,
- 0x38, 0x38, 0x07,
- 0x3C, 0x70, 0x07,
- 0xFC, 0xE7, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l23_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x07, 0x7E, 0x00,
- 0xF8, 0x0F, 0xFF, 0x00,
- 0x3C, 0x9F, 0xE7, 0x01,
- 0x1C, 0x9E, 0xC7, 0x01,
- 0x1E, 0x9C, 0xC3, 0x03,
- 0x1E, 0x1C, 0xC0, 0x03,
- 0x00, 0x1C, 0xC0, 0x01,
- 0x00, 0x1E, 0xE0, 0x01,
- 0x00, 0x1E, 0xFC, 0x00,
- 0x00, 0x0F, 0xFC, 0x00,
- 0x80, 0x0F, 0xE0, 0x01,
- 0xC0, 0x07, 0xC0, 0x03,
- 0xC0, 0x03, 0x80, 0x03,
- 0xE0, 0x01, 0x80, 0x03,
- 0xF0, 0xC0, 0x83, 0x03,
- 0x78, 0xC0, 0x83, 0x03,
- 0x3C, 0x80, 0xC7, 0x03,
- 0x3C, 0x80, 0xE7, 0x01,
- 0xFE, 0x1F, 0xFF, 0x01,
- 0xFE, 0x1F, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l24.xbm b/app/bin/bitmaps/l24.xbm deleted file mode 100644 index 8fd49ae..0000000 --- a/app/bin/bitmaps/l24.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l24_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1C,
- 0xFC, 0x1C,
- 0xCC, 0x1E,
- 0xC0, 0x1E,
- 0xE0, 0x1F,
- 0x70, 0x1B,
- 0xB8, 0x3F,
- 0x1C, 0x18,
- 0xFC, 0x18,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l24_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0x81, 0x03,
- 0xB8, 0x83, 0x03,
- 0x1C, 0xC3, 0x03,
- 0x1C, 0xC7, 0x03,
- 0x00, 0xE7, 0x03,
- 0x00, 0xE7, 0x03,
- 0x80, 0xF3, 0x03,
- 0xC0, 0xB3, 0x03,
- 0xC0, 0xB9, 0x03,
- 0xE0, 0x98, 0x03,
- 0xF0, 0xFC, 0x0F,
- 0x78, 0x80, 0x03,
- 0x38, 0x80, 0x03,
- 0x3C, 0x80, 0x03,
- 0xFC, 0x87, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l24_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x07, 0xF0, 0x00,
- 0xF8, 0x0F, 0xF0, 0x00,
- 0x3C, 0x1F, 0xF8, 0x00,
- 0x1C, 0x1E, 0xF8, 0x00,
- 0x1E, 0x1C, 0xFC, 0x00,
- 0x1E, 0x1C, 0xFC, 0x00,
- 0x00, 0x1C, 0xFE, 0x00,
- 0x00, 0x1E, 0xEE, 0x00,
- 0x00, 0x1E, 0xEF, 0x00,
- 0x00, 0x8F, 0xE7, 0x00,
- 0x80, 0x8F, 0xE7, 0x00,
- 0xC0, 0xC7, 0xE3, 0x00,
- 0xC0, 0xC3, 0xE1, 0x00,
- 0xE0, 0xE1, 0xFF, 0x03,
- 0xF0, 0xE0, 0xFF, 0x03,
- 0x78, 0x00, 0xE0, 0x00,
- 0x3C, 0x00, 0xE0, 0x00,
- 0x3C, 0x00, 0xE0, 0x00,
- 0xFE, 0x1F, 0xE0, 0x00,
- 0xFE, 0x1F, 0xE0, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l25.xbm b/app/bin/bitmaps/l25.xbm deleted file mode 100644 index 6bf1e2b..0000000 --- a/app/bin/bitmaps/l25.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l25_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x3F,
- 0xFC, 0x07,
- 0xCC, 0x07,
- 0xC0, 0x1F,
- 0xE0, 0x3B,
- 0x70, 0x30,
- 0x38, 0x33,
- 0x1C, 0x3F,
- 0xFC, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l25_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xF1, 0x07,
- 0xB8, 0x73, 0x00,
- 0x1C, 0x73, 0x00,
- 0x1C, 0x37, 0x00,
- 0x00, 0x37, 0x00,
- 0x00, 0xFF, 0x03,
- 0x80, 0x7B, 0x07,
- 0xC0, 0x3B, 0x07,
- 0xC0, 0x01, 0x0E,
- 0xE0, 0x00, 0x0E,
- 0xF0, 0x00, 0x0E,
- 0x78, 0x38, 0x06,
- 0x38, 0x38, 0x07,
- 0x3C, 0x70, 0x07,
- 0xFC, 0xE7, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l25_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x07, 0xFF, 0x03,
- 0xF8, 0x0F, 0xFF, 0x03,
- 0x3C, 0x1F, 0x07, 0x00,
- 0x1C, 0x1E, 0x07, 0x00,
- 0x1E, 0x9C, 0x07, 0x00,
- 0x1E, 0x9C, 0x07, 0x00,
- 0x00, 0x9C, 0x7F, 0x00,
- 0x00, 0x9E, 0xFF, 0x01,
- 0x00, 0x9E, 0xE7, 0x01,
- 0x00, 0x8F, 0xC3, 0x03,
- 0x80, 0x0F, 0xC0, 0x03,
- 0xC0, 0x07, 0x80, 0x03,
- 0xC0, 0x03, 0x80, 0x03,
- 0xE0, 0x01, 0x80, 0x03,
- 0xF0, 0xC0, 0x83, 0x03,
- 0x78, 0xC0, 0xC3, 0x03,
- 0x3C, 0x80, 0xC3, 0x03,
- 0x3C, 0x80, 0xE7, 0x01,
- 0xFE, 0x1F, 0xFF, 0x00,
- 0xFE, 0x1F, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l26.xbm b/app/bin/bitmaps/l26.xbm deleted file mode 100644 index ebed83b..0000000 --- a/app/bin/bitmaps/l26.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l26_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1E,
- 0xFC, 0x3F,
- 0xCC, 0x03,
- 0xC0, 0x1F,
- 0xE0, 0x3F,
- 0x70, 0x33,
- 0x38, 0x33,
- 0x1C, 0x3F,
- 0xFC, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l26_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xE1, 0x03,
- 0xB8, 0x73, 0x07,
- 0x1C, 0x33, 0x07,
- 0x1C, 0x3F, 0x00,
- 0x00, 0x3F, 0x00,
- 0x00, 0x3F, 0x00,
- 0x80, 0xFB, 0x03,
- 0xC0, 0x7B, 0x07,
- 0xC0, 0x39, 0x07,
- 0xE0, 0x38, 0x0E,
- 0xF0, 0x38, 0x0E,
- 0x78, 0x38, 0x0E,
- 0x38, 0x30, 0x07,
- 0x3C, 0x70, 0x07,
- 0xFC, 0xE7, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l26_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x07, 0xFC, 0x00,
- 0xF8, 0x0F, 0xFF, 0x01,
- 0x3C, 0x1F, 0xEF, 0x01,
- 0x1C, 0x9E, 0xC7, 0x03,
- 0x1E, 0x9C, 0xC3, 0x03,
- 0x1E, 0x9C, 0x03, 0x00,
- 0x00, 0xDC, 0x03, 0x00,
- 0x00, 0xDE, 0x7F, 0x00,
- 0x00, 0xDE, 0xFF, 0x01,
- 0x00, 0xCF, 0xEF, 0x01,
- 0x80, 0xCF, 0xC7, 0x03,
- 0xC0, 0xC7, 0x83, 0x03,
- 0xC0, 0xC3, 0x83, 0x03,
- 0xE0, 0xC1, 0x83, 0x03,
- 0xF0, 0xC0, 0x83, 0x03,
- 0x78, 0x80, 0x83, 0x03,
- 0x3C, 0x80, 0xC7, 0x03,
- 0x3C, 0x80, 0xEF, 0x01,
- 0xFE, 0x1F, 0xFF, 0x01,
- 0xFE, 0x1F, 0x7C, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l27.xbm b/app/bin/bitmaps/l27.xbm deleted file mode 100644 index d611f65..0000000 --- a/app/bin/bitmaps/l27.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l27_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x3F,
- 0xFC, 0x38,
- 0xCC, 0x18,
- 0xC0, 0x1C,
- 0xE0, 0x0C,
- 0x70, 0x0E,
- 0x38, 0x0E,
- 0x1C, 0x06,
- 0xFC, 0x06,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l27_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xF9, 0x0F,
- 0xB8, 0x03, 0x0F,
- 0x1C, 0x03, 0x07,
- 0x1C, 0x87, 0x03,
- 0x00, 0x87, 0x03,
- 0x00, 0xC7, 0x01,
- 0x80, 0xC3, 0x01,
- 0xC0, 0xC3, 0x01,
- 0xC0, 0xE1, 0x00,
- 0xE0, 0xE0, 0x00,
- 0xF0, 0xE0, 0x00,
- 0x78, 0xE0, 0x00,
- 0x38, 0xE0, 0x00,
- 0x3C, 0x70, 0x00,
- 0xFC, 0x77, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l27_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0xC7, 0xFF, 0x03,
- 0xF8, 0xCF, 0xFF, 0x03,
- 0x3C, 0x1F, 0xC0, 0x03,
- 0x1C, 0x1E, 0xE0, 0x01,
- 0x1E, 0x1C, 0xE0, 0x01,
- 0x1E, 0x1C, 0xF0, 0x00,
- 0x00, 0x1C, 0xF0, 0x00,
- 0x00, 0x1E, 0x78, 0x00,
- 0x00, 0x1E, 0x78, 0x00,
- 0x00, 0x0F, 0x38, 0x00,
- 0x80, 0x0F, 0x3C, 0x00,
- 0xC0, 0x07, 0x3C, 0x00,
- 0xC0, 0x03, 0x1C, 0x00,
- 0xE0, 0x01, 0x1E, 0x00,
- 0xF0, 0x00, 0x1E, 0x00,
- 0x78, 0x00, 0x1E, 0x00,
- 0x3C, 0x00, 0x1E, 0x00,
- 0x3C, 0x00, 0x0E, 0x00,
- 0xFE, 0x1F, 0x0E, 0x00,
- 0xFE, 0x1F, 0x0E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l28.xbm b/app/bin/bitmaps/l28.xbm deleted file mode 100644 index d5ae122..0000000 --- a/app/bin/bitmaps/l28.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l28_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1E,
- 0xFC, 0x3F,
- 0xCC, 0x3B,
- 0xC0, 0x3F,
- 0xE0, 0x1E,
- 0x70, 0x3F,
- 0x38, 0x33,
- 0x1C, 0x3F,
- 0xFC, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l28_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xE1, 0x03,
- 0xB8, 0x73, 0x07,
- 0x1C, 0x33, 0x07,
- 0x1C, 0x3F, 0x07,
- 0x00, 0x3F, 0x07,
- 0x00, 0x3F, 0x07,
- 0x80, 0x73, 0x07,
- 0xC0, 0xE3, 0x03,
- 0xC0, 0x71, 0x07,
- 0xE0, 0x38, 0x06,
- 0xF0, 0x38, 0x0E,
- 0x78, 0x38, 0x0E,
- 0x38, 0x38, 0x06,
- 0x3C, 0x70, 0x07,
- 0xFC, 0xE7, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l28_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x07, 0x7E, 0x00,
- 0xF8, 0x0F, 0xFF, 0x00,
- 0x3C, 0x9F, 0xEF, 0x01,
- 0x1C, 0x9E, 0xC7, 0x01,
- 0x1E, 0x9C, 0xC3, 0x03,
- 0x1E, 0x9C, 0xC3, 0x03,
- 0x00, 0x9C, 0xC7, 0x01,
- 0x00, 0x1E, 0xEF, 0x01,
- 0x00, 0x1E, 0xFE, 0x00,
- 0x00, 0x0F, 0xFF, 0x00,
- 0x80, 0x8F, 0xE7, 0x01,
- 0xC0, 0x87, 0xC3, 0x03,
- 0xC0, 0xC3, 0x83, 0x03,
- 0xE0, 0xC1, 0x83, 0x03,
- 0xF0, 0xC0, 0x83, 0x03,
- 0x78, 0xC0, 0x83, 0x03,
- 0x3C, 0x80, 0xC3, 0x03,
- 0x3C, 0x80, 0xE7, 0x01,
- 0xFE, 0x1F, 0xFF, 0x01,
- 0xFE, 0x1F, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l29.xbm b/app/bin/bitmaps/l29.xbm deleted file mode 100644 index 7b23c07..0000000 --- a/app/bin/bitmaps/l29.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l29_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1E,
- 0xFC, 0x3F,
- 0xCC, 0x33,
- 0xC0, 0x33,
- 0xE0, 0x3F,
- 0x70, 0x3E,
- 0x38, 0x30,
- 0x1C, 0x3B,
- 0xFC, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l29_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xE1, 0x01,
- 0xB8, 0x73, 0x07,
- 0x1C, 0x3B, 0x07,
- 0x1C, 0x3F, 0x06,
- 0x00, 0x3F, 0x0E,
- 0x00, 0x3F, 0x0E,
- 0x80, 0x3B, 0x0F,
- 0xC0, 0x73, 0x0F,
- 0xC0, 0xE1, 0x0F,
- 0xE0, 0x00, 0x0E,
- 0xF0, 0x00, 0x06,
- 0x78, 0x00, 0x06,
- 0x38, 0x38, 0x07,
- 0x3C, 0x70, 0x03,
- 0xFC, 0xF7, 0x01,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l29_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x07, 0x7E, 0x00,
- 0xF8, 0x0F, 0xFF, 0x00,
- 0x3C, 0x9F, 0xEF, 0x01,
- 0x1C, 0x9E, 0xC7, 0x01,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x00, 0xDC, 0x83, 0x03,
- 0x00, 0xDE, 0x83, 0x03,
- 0x00, 0xDE, 0x83, 0x03,
- 0x00, 0x8F, 0xC3, 0x03,
- 0x80, 0x8F, 0xE7, 0x03,
- 0xC0, 0x07, 0xFF, 0x03,
- 0xC0, 0x03, 0xFE, 0x03,
- 0xE0, 0x01, 0x80, 0x03,
- 0xF0, 0x00, 0x80, 0x03,
- 0x78, 0x80, 0xC3, 0x03,
- 0x3C, 0x80, 0xC3, 0x01,
- 0x3C, 0x80, 0xE7, 0x01,
- 0xFE, 0x1F, 0xFF, 0x00,
- 0xFE, 0x1F, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l3.xbm b/app/bin/bitmaps/l3.xbm deleted file mode 100644 index 070b9bb..0000000 --- a/app/bin/bitmaps/l3.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l3_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0xC0, 0x03,
- 0x60, 0x07,
- 0x00, 0x07,
- 0x00, 0x03,
- 0x80, 0x07,
- 0x00, 0x07,
- 0x60, 0x06,
- 0xE0, 0x07,
- 0xC0, 0x03,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l3_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x1F, 0x00,
- 0x80, 0x3B, 0x00,
- 0xC0, 0x39, 0x00,
- 0x00, 0x38, 0x00,
- 0x00, 0x38, 0x00,
- 0x00, 0x38, 0x00,
- 0x00, 0x1C, 0x00,
- 0x00, 0x3E, 0x00,
- 0x00, 0x38, 0x00,
- 0x00, 0x70, 0x00,
- 0x00, 0x70, 0x00,
- 0xC0, 0x71, 0x00,
- 0xC0, 0x39, 0x00,
- 0x80, 0x3B, 0x00,
- 0x00, 0x1F, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l3_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xFC, 0x00, 0x00,
- 0x00, 0xFE, 0x01, 0x00,
- 0x00, 0xCF, 0x03, 0x00,
- 0x00, 0x8F, 0x03, 0x00,
- 0x00, 0x87, 0x07, 0x00,
- 0x00, 0x80, 0x07, 0x00,
- 0x00, 0x80, 0x03, 0x00,
- 0x00, 0xC0, 0x03, 0x00,
- 0x00, 0xF8, 0x01, 0x00,
- 0x00, 0xF8, 0x01, 0x00,
- 0x00, 0xC0, 0x03, 0x00,
- 0x00, 0x80, 0x07, 0x00,
- 0x00, 0x00, 0x07, 0x00,
- 0x00, 0x00, 0x07, 0x00,
- 0x80, 0x07, 0x07, 0x00,
- 0x80, 0x07, 0x07, 0x00,
- 0x00, 0x8F, 0x07, 0x00,
- 0x00, 0xCF, 0x03, 0x00,
- 0x00, 0xFE, 0x03, 0x00,
- 0x00, 0xFC, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l30.xbm b/app/bin/bitmaps/l30.xbm deleted file mode 100644 index 324f979..0000000 --- a/app/bin/bitmaps/l30.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l30_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1E,
- 0xEC, 0x3F,
- 0xE0, 0x33,
- 0x60, 0x33,
- 0xF0, 0x33,
- 0xE0, 0x33,
- 0xCC, 0x33,
- 0xFC, 0x3F,
- 0x78, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l30_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xE1, 0x03,
- 0xB8, 0x73, 0x07,
- 0x9C, 0x33, 0x07,
- 0x80, 0x3B, 0x06,
- 0x80, 0x3B, 0x06,
- 0x80, 0x3B, 0x0E,
- 0xC0, 0x39, 0x0E,
- 0xE0, 0x3B, 0x0E,
- 0x80, 0x3B, 0x0E,
- 0x00, 0x3F, 0x0E,
- 0x00, 0x3F, 0x06,
- 0x1C, 0x3F, 0x06,
- 0x9C, 0x33, 0x07,
- 0xB8, 0x73, 0x07,
- 0xF0, 0xE1, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l30_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x03, 0x7E, 0x00,
- 0xF8, 0x07, 0xFF, 0x00,
- 0x3C, 0x0F, 0xEF, 0x01,
- 0x3C, 0x8E, 0xC7, 0x01,
- 0x1C, 0x9E, 0xC3, 0x03,
- 0x00, 0x9E, 0xC3, 0x03,
- 0x00, 0xCE, 0x83, 0x03,
- 0x00, 0xCF, 0x83, 0x03,
- 0xE0, 0xC7, 0x83, 0x03,
- 0xE0, 0xC7, 0x83, 0x03,
- 0x00, 0xCF, 0x83, 0x03,
- 0x00, 0xDE, 0x83, 0x03,
- 0x00, 0xDC, 0x83, 0x03,
- 0x00, 0xDC, 0x83, 0x03,
- 0x1E, 0x9C, 0xC3, 0x03,
- 0x1E, 0x9C, 0xC3, 0x03,
- 0x3C, 0x9E, 0xC7, 0x01,
- 0x3C, 0x0F, 0xEF, 0x01,
- 0xF8, 0x0F, 0xFF, 0x00,
- 0xF0, 0x03, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l31.xbm b/app/bin/bitmaps/l31.xbm deleted file mode 100644 index e379ca6..0000000 --- a/app/bin/bitmaps/l31.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l31_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1C,
- 0xEC, 0x1E,
- 0xE0, 0x1F,
- 0x60, 0x1C,
- 0xF0, 0x1C,
- 0xE0, 0x1C,
- 0xCC, 0x1C,
- 0xFC, 0x1C,
- 0x78, 0x1C,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l31_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0x81, 0x03,
- 0xB8, 0xC3, 0x03,
- 0x9C, 0xC3, 0x03,
- 0x80, 0xE3, 0x03,
- 0x80, 0xB3, 0x03,
- 0x80, 0x83, 0x03,
- 0xC0, 0x81, 0x03,
- 0xE0, 0x83, 0x03,
- 0x80, 0x83, 0x03,
- 0x00, 0x87, 0x03,
- 0x00, 0x87, 0x03,
- 0x1C, 0x87, 0x03,
- 0x9C, 0x83, 0x03,
- 0xB8, 0x83, 0x03,
- 0xF0, 0x81, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l31_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x03, 0x70, 0x00,
- 0xF8, 0x07, 0x70, 0x00,
- 0x3C, 0x0F, 0x78, 0x00,
- 0x3C, 0x0E, 0x7C, 0x00,
- 0x1C, 0x1E, 0x7E, 0x00,
- 0x00, 0x1E, 0x7F, 0x00,
- 0x00, 0x0E, 0x73, 0x00,
- 0x00, 0x0F, 0x70, 0x00,
- 0xE0, 0x07, 0x70, 0x00,
- 0xE0, 0x07, 0x70, 0x00,
- 0x00, 0x0F, 0x70, 0x00,
- 0x00, 0x1E, 0x70, 0x00,
- 0x00, 0x1C, 0x70, 0x00,
- 0x00, 0x1C, 0x70, 0x00,
- 0x1E, 0x1C, 0x70, 0x00,
- 0x1E, 0x1C, 0x70, 0x00,
- 0x3C, 0x1E, 0x70, 0x00,
- 0x3C, 0x0F, 0x70, 0x00,
- 0xF8, 0x0F, 0x70, 0x00,
- 0xF0, 0x03, 0x70, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l32.xbm b/app/bin/bitmaps/l32.xbm deleted file mode 100644 index 3cbaaac..0000000 --- a/app/bin/bitmaps/l32.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l32_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1E,
- 0xEC, 0x3F,
- 0xE0, 0x33,
- 0x60, 0x30,
- 0xF0, 0x38,
- 0xE0, 0x1C,
- 0xCC, 0x0E,
- 0xFC, 0x07,
- 0x78, 0x3F,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l32_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xE1, 0x03,
- 0xB8, 0x73, 0x07,
- 0x9C, 0x3B, 0x06,
- 0x80, 0x3B, 0x0E,
- 0x80, 0x03, 0x0E,
- 0x80, 0x03, 0x0E,
- 0xC0, 0x01, 0x07,
- 0xE0, 0x83, 0x07,
- 0x80, 0x83, 0x03,
- 0x00, 0xC7, 0x01,
- 0x00, 0xE7, 0x01,
- 0x1C, 0xF7, 0x00,
- 0x9C, 0x73, 0x00,
- 0xB8, 0x7B, 0x00,
- 0xF0, 0xF9, 0x0F,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l32_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x03, 0xFE, 0x00,
- 0xF8, 0x07, 0xFF, 0x01,
- 0x3C, 0x8F, 0xE7, 0x03,
- 0x3C, 0x8E, 0xC3, 0x03,
- 0x1C, 0xDE, 0x83, 0x03,
- 0x00, 0xDE, 0x83, 0x03,
- 0x00, 0x0E, 0x80, 0x03,
- 0x00, 0x0F, 0xC0, 0x03,
- 0xE0, 0x07, 0xC0, 0x03,
- 0xE0, 0x07, 0xE0, 0x01,
- 0x00, 0x0F, 0xF0, 0x01,
- 0x00, 0x1E, 0xF8, 0x00,
- 0x00, 0x1C, 0x78, 0x00,
- 0x00, 0x1C, 0x3C, 0x00,
- 0x1E, 0x1C, 0x1E, 0x00,
- 0x1E, 0x1C, 0x0F, 0x00,
- 0x3C, 0x9E, 0x07, 0x00,
- 0x3C, 0x8F, 0x07, 0x00,
- 0xF8, 0xCF, 0xFF, 0x03,
- 0xF0, 0xC3, 0xFF, 0x03,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l33.xbm b/app/bin/bitmaps/l33.xbm deleted file mode 100644 index 8d318c6..0000000 --- a/app/bin/bitmaps/l33.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l33_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1E,
- 0xEC, 0x3B,
- 0xE0, 0x38,
- 0x60, 0x18,
- 0xF0, 0x3C,
- 0xE0, 0x38,
- 0xCC, 0x33,
- 0xFC, 0x3F,
- 0x78, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l33_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xE1, 0x03,
- 0xB8, 0x73, 0x07,
- 0x9C, 0x3B, 0x07,
- 0x80, 0x03, 0x07,
- 0x80, 0x03, 0x07,
- 0x80, 0x03, 0x07,
- 0xC0, 0x81, 0x03,
- 0xE0, 0xC3, 0x07,
- 0x80, 0x03, 0x07,
- 0x00, 0x07, 0x0E,
- 0x00, 0x07, 0x0E,
- 0x1C, 0x3F, 0x0E,
- 0x9C, 0x3B, 0x07,
- 0xB8, 0x73, 0x07,
- 0xF0, 0xE1, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l33_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x03, 0x7E, 0x00,
- 0xF8, 0x07, 0xFF, 0x00,
- 0x3C, 0x8F, 0xE7, 0x01,
- 0x3C, 0x8E, 0xC7, 0x01,
- 0x1C, 0x9E, 0xC3, 0x03,
- 0x00, 0x1E, 0xC0, 0x03,
- 0x00, 0x0E, 0xC0, 0x01,
- 0x00, 0x0F, 0xE0, 0x01,
- 0xE0, 0x07, 0xFC, 0x00,
- 0xE0, 0x07, 0xFC, 0x00,
- 0x00, 0x0F, 0xE0, 0x01,
- 0x00, 0x1E, 0xC0, 0x03,
- 0x00, 0x1C, 0x80, 0x03,
- 0x00, 0x1C, 0x80, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x3C, 0x9E, 0xC7, 0x03,
- 0x3C, 0x8F, 0xE7, 0x01,
- 0xF8, 0x0F, 0xFF, 0x01,
- 0xF0, 0x03, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l34.xbm b/app/bin/bitmaps/l34.xbm deleted file mode 100644 index 4e90020..0000000 --- a/app/bin/bitmaps/l34.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l34_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1C,
- 0xEC, 0x1C,
- 0xE0, 0x1E,
- 0x60, 0x1E,
- 0xF0, 0x1F,
- 0xE0, 0x1B,
- 0xCC, 0x3F,
- 0xFC, 0x18,
- 0x78, 0x18,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l34_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0x81, 0x03,
- 0xB8, 0x83, 0x03,
- 0x9C, 0xC3, 0x03,
- 0x80, 0xC3, 0x03,
- 0x80, 0xE3, 0x03,
- 0x80, 0xE3, 0x03,
- 0xC0, 0xF1, 0x03,
- 0xE0, 0xB3, 0x03,
- 0x80, 0xBB, 0x03,
- 0x00, 0x9F, 0x03,
- 0x00, 0xFF, 0x0F,
- 0x1C, 0x87, 0x03,
- 0x9C, 0x83, 0x03,
- 0xB8, 0x83, 0x03,
- 0xF0, 0x81, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l34_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x03, 0xF0, 0x00,
- 0xF8, 0x07, 0xF0, 0x00,
- 0x3C, 0x0F, 0xF8, 0x00,
- 0x3C, 0x0E, 0xF8, 0x00,
- 0x1C, 0x1E, 0xFC, 0x00,
- 0x00, 0x1E, 0xFC, 0x00,
- 0x00, 0x0E, 0xFE, 0x00,
- 0x00, 0x0F, 0xEE, 0x00,
- 0xE0, 0x07, 0xEF, 0x00,
- 0xE0, 0x87, 0xE7, 0x00,
- 0x00, 0x8F, 0xE7, 0x00,
- 0x00, 0xDE, 0xE3, 0x00,
- 0x00, 0xDC, 0xE1, 0x00,
- 0x00, 0xFC, 0xFF, 0x03,
- 0x1E, 0xFC, 0xFF, 0x03,
- 0x1E, 0x1C, 0xE0, 0x00,
- 0x3C, 0x1E, 0xE0, 0x00,
- 0x3C, 0x0F, 0xE0, 0x00,
- 0xF8, 0x0F, 0xE0, 0x00,
- 0xF0, 0x03, 0xE0, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l35.xbm b/app/bin/bitmaps/l35.xbm deleted file mode 100644 index f8de169..0000000 --- a/app/bin/bitmaps/l35.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l35_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x3F,
- 0xEC, 0x07,
- 0xE0, 0x07,
- 0x60, 0x1F,
- 0xF0, 0x3B,
- 0xE0, 0x30,
- 0xCC, 0x33,
- 0xFC, 0x3F,
- 0x78, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l35_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xF1, 0x07,
- 0xB8, 0x73, 0x00,
- 0x9C, 0x73, 0x00,
- 0x80, 0x33, 0x00,
- 0x80, 0x33, 0x00,
- 0x80, 0xFB, 0x03,
- 0xC0, 0x79, 0x07,
- 0xE0, 0x3B, 0x07,
- 0x80, 0x03, 0x0E,
- 0x00, 0x07, 0x0E,
- 0x00, 0x07, 0x0E,
- 0x1C, 0x3F, 0x06,
- 0x9C, 0x3B, 0x07,
- 0xB8, 0x73, 0x07,
- 0xF0, 0xE1, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l35_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x03, 0xFF, 0x03,
- 0xF8, 0x07, 0xFF, 0x03,
- 0x3C, 0x0F, 0x07, 0x00,
- 0x3C, 0x0E, 0x07, 0x00,
- 0x1C, 0x9E, 0x07, 0x00,
- 0x00, 0x9E, 0x07, 0x00,
- 0x00, 0x8E, 0x7F, 0x00,
- 0x00, 0x8F, 0xFF, 0x01,
- 0xE0, 0x87, 0xE7, 0x01,
- 0xE0, 0x87, 0xC3, 0x03,
- 0x00, 0x0F, 0xC0, 0x03,
- 0x00, 0x1E, 0x80, 0x03,
- 0x00, 0x1C, 0x80, 0x03,
- 0x00, 0x1C, 0x80, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0xDC, 0xC3, 0x03,
- 0x3C, 0x9E, 0xC3, 0x03,
- 0x3C, 0x8F, 0xE7, 0x01,
- 0xF8, 0x0F, 0xFF, 0x00,
- 0xF0, 0x03, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l36.xbm b/app/bin/bitmaps/l36.xbm deleted file mode 100644 index c3c19eb..0000000 --- a/app/bin/bitmaps/l36.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l36_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1E,
- 0xEC, 0x3F,
- 0xE0, 0x03,
- 0x60, 0x1F,
- 0xF0, 0x3F,
- 0xE0, 0x33,
- 0xCC, 0x33,
- 0xFC, 0x3F,
- 0x78, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l36_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xE1, 0x03,
- 0xB8, 0x73, 0x07,
- 0x9C, 0x33, 0x07,
- 0x80, 0x3B, 0x00,
- 0x80, 0x3B, 0x00,
- 0x80, 0x3B, 0x00,
- 0xC0, 0xF9, 0x03,
- 0xE0, 0x7B, 0x07,
- 0x80, 0x3B, 0x07,
- 0x00, 0x3F, 0x0E,
- 0x00, 0x3F, 0x0E,
- 0x1C, 0x3F, 0x0E,
- 0x9C, 0x33, 0x07,
- 0xB8, 0x73, 0x07,
- 0xF0, 0xE1, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l36_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x03, 0xFC, 0x00,
- 0xF8, 0x07, 0xFF, 0x01,
- 0x3C, 0x0F, 0xEF, 0x01,
- 0x3C, 0x8E, 0xC7, 0x03,
- 0x1C, 0x9E, 0xC3, 0x03,
- 0x00, 0x9E, 0x03, 0x00,
- 0x00, 0xCE, 0x03, 0x00,
- 0x00, 0xCF, 0x7F, 0x00,
- 0xE0, 0xC7, 0xFF, 0x01,
- 0xE0, 0xC7, 0xEF, 0x01,
- 0x00, 0xCF, 0xC7, 0x03,
- 0x00, 0xDE, 0x83, 0x03,
- 0x00, 0xDC, 0x83, 0x03,
- 0x00, 0xDC, 0x83, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0x9C, 0x83, 0x03,
- 0x3C, 0x9E, 0xC7, 0x03,
- 0x3C, 0x8F, 0xEF, 0x01,
- 0xF8, 0x0F, 0xFF, 0x01,
- 0xF0, 0x03, 0x7C, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l37.xbm b/app/bin/bitmaps/l37.xbm deleted file mode 100644 index df579f5..0000000 --- a/app/bin/bitmaps/l37.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l37_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x3F,
- 0xEC, 0x38,
- 0xE0, 0x18,
- 0x60, 0x1C,
- 0xF0, 0x0C,
- 0xE0, 0x0E,
- 0xCC, 0x0E,
- 0xFC, 0x06,
- 0x78, 0x06,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l37_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xF9, 0x0F,
- 0xB8, 0x03, 0x0F,
- 0x9C, 0x03, 0x07,
- 0x80, 0x83, 0x03,
- 0x80, 0x83, 0x03,
- 0x80, 0xC3, 0x01,
- 0xC0, 0xC1, 0x01,
- 0xE0, 0xC3, 0x01,
- 0x80, 0xE3, 0x00,
- 0x00, 0xE7, 0x00,
- 0x00, 0xE7, 0x00,
- 0x1C, 0xE7, 0x00,
- 0x9C, 0xE3, 0x00,
- 0xB8, 0x73, 0x00,
- 0xF0, 0x71, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l37_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0xC3, 0xFF, 0x03,
- 0xF8, 0xC7, 0xFF, 0x03,
- 0x3C, 0x0F, 0xC0, 0x03,
- 0x3C, 0x0E, 0xE0, 0x01,
- 0x1C, 0x1E, 0xE0, 0x01,
- 0x00, 0x1E, 0xF0, 0x00,
- 0x00, 0x0E, 0xF0, 0x00,
- 0x00, 0x0F, 0x78, 0x00,
- 0xE0, 0x07, 0x78, 0x00,
- 0xE0, 0x07, 0x38, 0x00,
- 0x00, 0x0F, 0x3C, 0x00,
- 0x00, 0x1E, 0x3C, 0x00,
- 0x00, 0x1C, 0x1C, 0x00,
- 0x00, 0x1C, 0x1E, 0x00,
- 0x1E, 0x1C, 0x1E, 0x00,
- 0x1E, 0x1C, 0x1E, 0x00,
- 0x3C, 0x1E, 0x1E, 0x00,
- 0x3C, 0x0F, 0x0E, 0x00,
- 0xF8, 0x0F, 0x0E, 0x00,
- 0xF0, 0x03, 0x0E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l38.xbm b/app/bin/bitmaps/l38.xbm deleted file mode 100644 index 424b263..0000000 --- a/app/bin/bitmaps/l38.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l38_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1E,
- 0xEC, 0x3F,
- 0xE0, 0x3B,
- 0x60, 0x3F,
- 0xF0, 0x1E,
- 0xE0, 0x3F,
- 0xCC, 0x33,
- 0xFC, 0x3F,
- 0x78, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l38_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xE1, 0x03,
- 0xB8, 0x73, 0x07,
- 0x9C, 0x33, 0x07,
- 0x80, 0x3B, 0x07,
- 0x80, 0x3B, 0x07,
- 0x80, 0x3B, 0x07,
- 0xC0, 0x71, 0x07,
- 0xE0, 0xE3, 0x03,
- 0x80, 0x73, 0x07,
- 0x00, 0x3F, 0x06,
- 0x00, 0x3F, 0x0E,
- 0x1C, 0x3F, 0x0E,
- 0x9C, 0x3B, 0x06,
- 0xB8, 0x73, 0x07,
- 0xF0, 0xE1, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l38_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x03, 0x7E, 0x00,
- 0xF8, 0x07, 0xFF, 0x00,
- 0x3C, 0x8F, 0xEF, 0x01,
- 0x3C, 0x8E, 0xC7, 0x01,
- 0x1C, 0x9E, 0xC3, 0x03,
- 0x00, 0x9E, 0xC3, 0x03,
- 0x00, 0x8E, 0xC7, 0x01,
- 0x00, 0x0F, 0xEF, 0x01,
- 0xE0, 0x07, 0xFE, 0x00,
- 0xE0, 0x07, 0xFF, 0x00,
- 0x00, 0x8F, 0xE7, 0x01,
- 0x00, 0x9E, 0xC3, 0x03,
- 0x00, 0xDC, 0x83, 0x03,
- 0x00, 0xDC, 0x83, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x3C, 0x9E, 0xC3, 0x03,
- 0x3C, 0x8F, 0xE7, 0x01,
- 0xF8, 0x0F, 0xFF, 0x01,
- 0xF0, 0x03, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l39.xbm b/app/bin/bitmaps/l39.xbm deleted file mode 100644 index 51d14ab..0000000 --- a/app/bin/bitmaps/l39.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l39_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1E,
- 0xEC, 0x3F,
- 0xE0, 0x33,
- 0x60, 0x33,
- 0xF0, 0x3F,
- 0xE0, 0x3E,
- 0xCC, 0x30,
- 0xFC, 0x3B,
- 0x78, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l39_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xE1, 0x01,
- 0xB8, 0x73, 0x07,
- 0x9C, 0x3B, 0x07,
- 0x80, 0x3B, 0x06,
- 0x80, 0x3B, 0x0E,
- 0x80, 0x3B, 0x0E,
- 0xC0, 0x39, 0x0F,
- 0xE0, 0x73, 0x0F,
- 0x80, 0xE3, 0x0F,
- 0x00, 0x07, 0x0E,
- 0x00, 0x07, 0x06,
- 0x1C, 0x07, 0x06,
- 0x9C, 0x3B, 0x07,
- 0xB8, 0x73, 0x03,
- 0xF0, 0xF1, 0x01,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l39_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x03, 0x7E, 0x00,
- 0xF8, 0x07, 0xFF, 0x00,
- 0x3C, 0x8F, 0xEF, 0x01,
- 0x3C, 0x8E, 0xC7, 0x01,
- 0x1C, 0xDE, 0x83, 0x03,
- 0x00, 0xDE, 0x83, 0x03,
- 0x00, 0xCE, 0x83, 0x03,
- 0x00, 0xCF, 0x83, 0x03,
- 0xE0, 0xC7, 0x83, 0x03,
- 0xE0, 0x87, 0xC3, 0x03,
- 0x00, 0x8F, 0xE7, 0x03,
- 0x00, 0x1E, 0xFF, 0x03,
- 0x00, 0x1C, 0xFE, 0x03,
- 0x00, 0x1C, 0x80, 0x03,
- 0x1E, 0x1C, 0x80, 0x03,
- 0x1E, 0x9C, 0xC3, 0x03,
- 0x3C, 0x9E, 0xC3, 0x01,
- 0x3C, 0x8F, 0xE7, 0x01,
- 0xF8, 0x0F, 0xFF, 0x00,
- 0xF0, 0x03, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l4.xbm b/app/bin/bitmaps/l4.xbm deleted file mode 100644 index 411ad63..0000000 --- a/app/bin/bitmaps/l4.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l4_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x80, 0x03,
- 0x80, 0x03,
- 0xC0, 0x03,
- 0xC0, 0x03,
- 0xE0, 0x03,
- 0x60, 0x03,
- 0xF0, 0x07,
- 0x00, 0x03,
- 0x00, 0x03,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l4_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x1C, 0x00,
- 0x00, 0x1C, 0x00,
- 0x00, 0x1E, 0x00,
- 0x00, 0x1E, 0x00,
- 0x00, 0x1F, 0x00,
- 0x00, 0x1F, 0x00,
- 0x80, 0x1F, 0x00,
- 0x80, 0x1D, 0x00,
- 0xC0, 0x1D, 0x00,
- 0xC0, 0x1C, 0x00,
- 0xE0, 0x7F, 0x00,
- 0x00, 0x1C, 0x00,
- 0x00, 0x1C, 0x00,
- 0x00, 0x1C, 0x00,
- 0x00, 0x1C, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l4_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xE0, 0x01, 0x00,
- 0x00, 0xE0, 0x01, 0x00,
- 0x00, 0xF0, 0x01, 0x00,
- 0x00, 0xF0, 0x01, 0x00,
- 0x00, 0xF8, 0x01, 0x00,
- 0x00, 0xF8, 0x01, 0x00,
- 0x00, 0xFC, 0x01, 0x00,
- 0x00, 0xDC, 0x01, 0x00,
- 0x00, 0xDE, 0x01, 0x00,
- 0x00, 0xCF, 0x01, 0x00,
- 0x00, 0xCF, 0x01, 0x00,
- 0x80, 0xC7, 0x01, 0x00,
- 0x80, 0xC3, 0x01, 0x00,
- 0xC0, 0xFF, 0x07, 0x00,
- 0xC0, 0xFF, 0x07, 0x00,
- 0x00, 0xC0, 0x01, 0x00,
- 0x00, 0xC0, 0x01, 0x00,
- 0x00, 0xC0, 0x01, 0x00,
- 0x00, 0xC0, 0x01, 0x00,
- 0x00, 0xC0, 0x01, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l40.xbm b/app/bin/bitmaps/l40.xbm deleted file mode 100644 index 8ee8e0f..0000000 --- a/app/bin/bitmaps/l40.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l40_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x70, 0x1E,
- 0x70, 0x3F,
- 0x78, 0x33,
- 0x78, 0x33,
- 0x7C, 0x33,
- 0x6C, 0x33,
- 0xFE, 0x33,
- 0x60, 0x3F,
- 0x60, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l40_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xC0, 0xE1, 0x03,
- 0xC0, 0x71, 0x07,
- 0xE0, 0x31, 0x07,
- 0xE0, 0x39, 0x06,
- 0xF0, 0x39, 0x06,
- 0xF0, 0x39, 0x0E,
- 0xF8, 0x39, 0x0E,
- 0xD8, 0x39, 0x0E,
- 0xDC, 0x39, 0x0E,
- 0xCC, 0x39, 0x0E,
- 0xFE, 0x3F, 0x06,
- 0xC0, 0x39, 0x06,
- 0xC0, 0x31, 0x07,
- 0xC0, 0x71, 0x07,
- 0xC0, 0xE1, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l40_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x07, 0x7E, 0x00,
- 0x80, 0x07, 0xFF, 0x00,
- 0xC0, 0x07, 0xEF, 0x01,
- 0xC0, 0x87, 0xC7, 0x01,
- 0xE0, 0x87, 0xC3, 0x03,
- 0xE0, 0x87, 0xC3, 0x03,
- 0xF0, 0xC7, 0x83, 0x03,
- 0x70, 0xC7, 0x83, 0x03,
- 0x78, 0xC7, 0x83, 0x03,
- 0x3C, 0xC7, 0x83, 0x03,
- 0x3C, 0xC7, 0x83, 0x03,
- 0x1E, 0xC7, 0x83, 0x03,
- 0x0E, 0xC7, 0x83, 0x03,
- 0xFF, 0xDF, 0x83, 0x03,
- 0xFF, 0x9F, 0xC3, 0x03,
- 0x00, 0x87, 0xC3, 0x03,
- 0x00, 0x87, 0xC7, 0x01,
- 0x00, 0x07, 0xEF, 0x01,
- 0x00, 0x07, 0xFF, 0x00,
- 0x00, 0x07, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l41.xbm b/app/bin/bitmaps/l41.xbm deleted file mode 100644 index 8535fda..0000000 --- a/app/bin/bitmaps/l41.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l41_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x70, 0x1C,
- 0x70, 0x1E,
- 0x78, 0x1F,
- 0x78, 0x1C,
- 0x7C, 0x1C,
- 0x6C, 0x1C,
- 0xFE, 0x1C,
- 0x60, 0x1C,
- 0x60, 0x1C,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l41_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xC0, 0x81, 0x03,
- 0xC0, 0xC1, 0x03,
- 0xE0, 0xC1, 0x03,
- 0xE0, 0xE1, 0x03,
- 0xF0, 0xB1, 0x03,
- 0xF0, 0x81, 0x03,
- 0xF8, 0x81, 0x03,
- 0xD8, 0x81, 0x03,
- 0xDC, 0x81, 0x03,
- 0xCC, 0x81, 0x03,
- 0xFE, 0x87, 0x03,
- 0xC0, 0x81, 0x03,
- 0xC0, 0x81, 0x03,
- 0xC0, 0x81, 0x03,
- 0xC0, 0x81, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l41_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x07, 0x70, 0x00,
- 0x80, 0x07, 0x70, 0x00,
- 0xC0, 0x07, 0x78, 0x00,
- 0xC0, 0x07, 0x7C, 0x00,
- 0xE0, 0x07, 0x7E, 0x00,
- 0xE0, 0x07, 0x7F, 0x00,
- 0xF0, 0x07, 0x73, 0x00,
- 0x70, 0x07, 0x70, 0x00,
- 0x78, 0x07, 0x70, 0x00,
- 0x3C, 0x07, 0x70, 0x00,
- 0x3C, 0x07, 0x70, 0x00,
- 0x1E, 0x07, 0x70, 0x00,
- 0x0E, 0x07, 0x70, 0x00,
- 0xFF, 0x1F, 0x70, 0x00,
- 0xFF, 0x1F, 0x70, 0x00,
- 0x00, 0x07, 0x70, 0x00,
- 0x00, 0x07, 0x70, 0x00,
- 0x00, 0x07, 0x70, 0x00,
- 0x00, 0x07, 0x70, 0x00,
- 0x00, 0x07, 0x70, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l42.xbm b/app/bin/bitmaps/l42.xbm deleted file mode 100644 index 1b1b742..0000000 --- a/app/bin/bitmaps/l42.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l42_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x70, 0x1E,
- 0x70, 0x3F,
- 0x78, 0x33,
- 0x78, 0x30,
- 0x7C, 0x38,
- 0x6C, 0x1C,
- 0xFE, 0x0E,
- 0x60, 0x07,
- 0x60, 0x3F,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l42_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xC0, 0xE1, 0x03,
- 0xC0, 0x71, 0x07,
- 0xE0, 0x39, 0x06,
- 0xE0, 0x39, 0x0E,
- 0xF0, 0x01, 0x0E,
- 0xF0, 0x01, 0x0E,
- 0xF8, 0x01, 0x07,
- 0xD8, 0x81, 0x07,
- 0xDC, 0x81, 0x03,
- 0xCC, 0xC1, 0x01,
- 0xFE, 0xE7, 0x01,
- 0xC0, 0xF1, 0x00,
- 0xC0, 0x71, 0x00,
- 0xC0, 0x79, 0x00,
- 0xC0, 0xF9, 0x0F,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l42_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x07, 0xFE, 0x00,
- 0x80, 0x07, 0xFF, 0x01,
- 0xC0, 0x87, 0xE7, 0x03,
- 0xC0, 0x87, 0xC3, 0x03,
- 0xE0, 0xC7, 0x83, 0x03,
- 0xE0, 0xC7, 0x83, 0x03,
- 0xF0, 0x07, 0x80, 0x03,
- 0x70, 0x07, 0xC0, 0x03,
- 0x78, 0x07, 0xC0, 0x03,
- 0x3C, 0x07, 0xE0, 0x01,
- 0x3C, 0x07, 0xF0, 0x01,
- 0x1E, 0x07, 0xF8, 0x00,
- 0x0E, 0x07, 0x78, 0x00,
- 0xFF, 0x1F, 0x3C, 0x00,
- 0xFF, 0x1F, 0x1E, 0x00,
- 0x00, 0x07, 0x0F, 0x00,
- 0x00, 0x87, 0x07, 0x00,
- 0x00, 0x87, 0x07, 0x00,
- 0x00, 0xC7, 0xFF, 0x03,
- 0x00, 0xC7, 0xFF, 0x03,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l43.xbm b/app/bin/bitmaps/l43.xbm deleted file mode 100644 index 1512650..0000000 --- a/app/bin/bitmaps/l43.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l43_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x70, 0x1E,
- 0x70, 0x3B,
- 0x78, 0x38,
- 0x78, 0x18,
- 0x7C, 0x3C,
- 0x6C, 0x38,
- 0xFE, 0x33,
- 0x60, 0x3F,
- 0x60, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l43_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xC0, 0xE1, 0x03,
- 0xC0, 0x71, 0x07,
- 0xE0, 0x39, 0x07,
- 0xE0, 0x01, 0x07,
- 0xF0, 0x01, 0x07,
- 0xF0, 0x01, 0x07,
- 0xF8, 0x81, 0x03,
- 0xD8, 0xC1, 0x07,
- 0xDC, 0x01, 0x07,
- 0xCC, 0x01, 0x0E,
- 0xFE, 0x07, 0x0E,
- 0xC0, 0x39, 0x0E,
- 0xC0, 0x39, 0x07,
- 0xC0, 0x71, 0x07,
- 0xC0, 0xE1, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l43_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x07, 0x7E, 0x00,
- 0x80, 0x07, 0xFF, 0x00,
- 0xC0, 0x87, 0xE7, 0x01,
- 0xC0, 0x87, 0xC7, 0x01,
- 0xE0, 0x87, 0xC3, 0x03,
- 0xE0, 0x07, 0xC0, 0x03,
- 0xF0, 0x07, 0xC0, 0x01,
- 0x70, 0x07, 0xE0, 0x01,
- 0x78, 0x07, 0xFC, 0x00,
- 0x3C, 0x07, 0xFC, 0x00,
- 0x3C, 0x07, 0xE0, 0x01,
- 0x1E, 0x07, 0xC0, 0x03,
- 0x0E, 0x07, 0x80, 0x03,
- 0xFF, 0x1F, 0x80, 0x03,
- 0xFF, 0xDF, 0x83, 0x03,
- 0x00, 0xC7, 0x83, 0x03,
- 0x00, 0x87, 0xC7, 0x03,
- 0x00, 0x87, 0xE7, 0x01,
- 0x00, 0x07, 0xFF, 0x01,
- 0x00, 0x07, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l44.xbm b/app/bin/bitmaps/l44.xbm deleted file mode 100644 index 7a96e04..0000000 --- a/app/bin/bitmaps/l44.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l44_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x70, 0x1C,
- 0x70, 0x1C,
- 0x78, 0x1E,
- 0x78, 0x1E,
- 0x7C, 0x1F,
- 0x6C, 0x1B,
- 0xFE, 0x3F,
- 0x60, 0x18,
- 0x60, 0x18,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l44_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xC0, 0x81, 0x03,
- 0xC0, 0x81, 0x03,
- 0xE0, 0xC1, 0x03,
- 0xE0, 0xC1, 0x03,
- 0xF0, 0xE1, 0x03,
- 0xF0, 0xE1, 0x03,
- 0xF8, 0xF1, 0x03,
- 0xD8, 0xB1, 0x03,
- 0xDC, 0xB9, 0x03,
- 0xCC, 0x99, 0x03,
- 0xFE, 0xFF, 0x0F,
- 0xC0, 0x81, 0x03,
- 0xC0, 0x81, 0x03,
- 0xC0, 0x81, 0x03,
- 0xC0, 0x81, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l44_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x07, 0xF0, 0x00,
- 0x80, 0x07, 0xF0, 0x00,
- 0xC0, 0x07, 0xF8, 0x00,
- 0xC0, 0x07, 0xF8, 0x00,
- 0xE0, 0x07, 0xFC, 0x00,
- 0xE0, 0x07, 0xFC, 0x00,
- 0xF0, 0x07, 0xFE, 0x00,
- 0x70, 0x07, 0xEE, 0x00,
- 0x78, 0x07, 0xEF, 0x00,
- 0x3C, 0x87, 0xE7, 0x00,
- 0x3C, 0x87, 0xE7, 0x00,
- 0x1E, 0xC7, 0xE3, 0x00,
- 0x0E, 0xC7, 0xE1, 0x00,
- 0xFF, 0xFF, 0xFF, 0x03,
- 0xFF, 0xFF, 0xFF, 0x03,
- 0x00, 0x07, 0xE0, 0x00,
- 0x00, 0x07, 0xE0, 0x00,
- 0x00, 0x07, 0xE0, 0x00,
- 0x00, 0x07, 0xE0, 0x00,
- 0x00, 0x07, 0xE0, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l45.xbm b/app/bin/bitmaps/l45.xbm deleted file mode 100644 index d326cc1..0000000 --- a/app/bin/bitmaps/l45.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l45_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x70, 0x3F,
- 0x70, 0x07,
- 0x78, 0x07,
- 0x78, 0x1F,
- 0x7C, 0x3B,
- 0x6C, 0x30,
- 0xFE, 0x33,
- 0x60, 0x3F,
- 0x60, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l45_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xC0, 0xF1, 0x07,
- 0xC0, 0x71, 0x00,
- 0xE0, 0x71, 0x00,
- 0xE0, 0x31, 0x00,
- 0xF0, 0x31, 0x00,
- 0xF0, 0xF9, 0x03,
- 0xF8, 0x79, 0x07,
- 0xD8, 0x39, 0x07,
- 0xDC, 0x01, 0x0E,
- 0xCC, 0x01, 0x0E,
- 0xFE, 0x07, 0x0E,
- 0xC0, 0x39, 0x06,
- 0xC0, 0x39, 0x07,
- 0xC0, 0x71, 0x07,
- 0xC0, 0xE1, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l45_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x07, 0xFF, 0x03,
- 0x80, 0x07, 0xFF, 0x03,
- 0xC0, 0x07, 0x07, 0x00,
- 0xC0, 0x07, 0x07, 0x00,
- 0xE0, 0x87, 0x07, 0x00,
- 0xE0, 0x87, 0x07, 0x00,
- 0xF0, 0x87, 0x7F, 0x00,
- 0x70, 0x87, 0xFF, 0x01,
- 0x78, 0x87, 0xE7, 0x01,
- 0x3C, 0x87, 0xC3, 0x03,
- 0x3C, 0x07, 0xC0, 0x03,
- 0x1E, 0x07, 0x80, 0x03,
- 0x0E, 0x07, 0x80, 0x03,
- 0xFF, 0x1F, 0x80, 0x03,
- 0xFF, 0xDF, 0x83, 0x03,
- 0x00, 0xC7, 0xC3, 0x03,
- 0x00, 0x87, 0xC3, 0x03,
- 0x00, 0x87, 0xE7, 0x01,
- 0x00, 0x07, 0xFF, 0x00,
- 0x00, 0x07, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l46.xbm b/app/bin/bitmaps/l46.xbm deleted file mode 100644 index 5313ab6..0000000 --- a/app/bin/bitmaps/l46.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l46_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x70, 0x1E,
- 0x70, 0x3F,
- 0x78, 0x03,
- 0x78, 0x1F,
- 0x7C, 0x3F,
- 0x6C, 0x33,
- 0xFE, 0x33,
- 0x60, 0x3F,
- 0x60, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l46_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xC0, 0xE1, 0x03,
- 0xC0, 0x71, 0x07,
- 0xE0, 0x31, 0x07,
- 0xE0, 0x39, 0x00,
- 0xF0, 0x39, 0x00,
- 0xF0, 0x39, 0x00,
- 0xF8, 0xF9, 0x03,
- 0xD8, 0x79, 0x07,
- 0xDC, 0x39, 0x07,
- 0xCC, 0x39, 0x0E,
- 0xFE, 0x3F, 0x0E,
- 0xC0, 0x39, 0x0E,
- 0xC0, 0x31, 0x07,
- 0xC0, 0x71, 0x07,
- 0xC0, 0xE1, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l46_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x07, 0xFC, 0x00,
- 0x80, 0x07, 0xFF, 0x01,
- 0xC0, 0x07, 0xEF, 0x01,
- 0xC0, 0x87, 0xC7, 0x03,
- 0xE0, 0x87, 0xC3, 0x03,
- 0xE0, 0x87, 0x03, 0x00,
- 0xF0, 0xC7, 0x03, 0x00,
- 0x70, 0xC7, 0x7F, 0x00,
- 0x78, 0xC7, 0xFF, 0x01,
- 0x3C, 0xC7, 0xEF, 0x01,
- 0x3C, 0xC7, 0xC7, 0x03,
- 0x1E, 0xC7, 0x83, 0x03,
- 0x0E, 0xC7, 0x83, 0x03,
- 0xFF, 0xDF, 0x83, 0x03,
- 0xFF, 0xDF, 0x83, 0x03,
- 0x00, 0x87, 0x83, 0x03,
- 0x00, 0x87, 0xC7, 0x03,
- 0x00, 0x87, 0xEF, 0x01,
- 0x00, 0x07, 0xFF, 0x01,
- 0x00, 0x07, 0x7C, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l47.xbm b/app/bin/bitmaps/l47.xbm deleted file mode 100644 index e635d03..0000000 --- a/app/bin/bitmaps/l47.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l47_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x70, 0x3F,
- 0x70, 0x38,
- 0x78, 0x18,
- 0x78, 0x1C,
- 0x7C, 0x0C,
- 0x6C, 0x0E,
- 0xFE, 0x0E,
- 0x60, 0x06,
- 0x60, 0x06,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l47_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xC0, 0xF9, 0x0F,
- 0xC0, 0x01, 0x0F,
- 0xE0, 0x01, 0x07,
- 0xE0, 0x81, 0x03,
- 0xF0, 0x81, 0x03,
- 0xF0, 0xC1, 0x01,
- 0xF8, 0xC1, 0x01,
- 0xD8, 0xC1, 0x01,
- 0xDC, 0xE1, 0x00,
- 0xCC, 0xE1, 0x00,
- 0xFE, 0xE7, 0x00,
- 0xC0, 0xE1, 0x00,
- 0xC0, 0xE1, 0x00,
- 0xC0, 0x71, 0x00,
- 0xC0, 0x71, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l47_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x80, 0xC7, 0xFF, 0x03,
- 0x80, 0xC7, 0xFF, 0x03,
- 0xC0, 0x07, 0xC0, 0x03,
- 0xC0, 0x07, 0xE0, 0x01,
- 0xE0, 0x07, 0xE0, 0x01,
- 0xE0, 0x07, 0xF0, 0x00,
- 0xF0, 0x07, 0xF0, 0x00,
- 0x70, 0x07, 0x78, 0x00,
- 0x78, 0x07, 0x78, 0x00,
- 0x3C, 0x07, 0x38, 0x00,
- 0x3C, 0x07, 0x3C, 0x00,
- 0x1E, 0x07, 0x3C, 0x00,
- 0x0E, 0x07, 0x1C, 0x00,
- 0xFF, 0x1F, 0x1E, 0x00,
- 0xFF, 0x1F, 0x1E, 0x00,
- 0x00, 0x07, 0x1E, 0x00,
- 0x00, 0x07, 0x1E, 0x00,
- 0x00, 0x07, 0x0E, 0x00,
- 0x00, 0x07, 0x0E, 0x00,
- 0x00, 0x07, 0x0E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l48.xbm b/app/bin/bitmaps/l48.xbm deleted file mode 100644 index 977b660..0000000 --- a/app/bin/bitmaps/l48.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l48_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x70, 0x1E,
- 0x70, 0x3F,
- 0x78, 0x3B,
- 0x78, 0x3F,
- 0x7C, 0x1E,
- 0x6C, 0x3F,
- 0xFE, 0x33,
- 0x60, 0x3F,
- 0x60, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l48_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xC0, 0xE1, 0x03,
- 0xC0, 0x71, 0x07,
- 0xE0, 0x31, 0x07,
- 0xE0, 0x39, 0x07,
- 0xF0, 0x39, 0x07,
- 0xF0, 0x39, 0x07,
- 0xF8, 0x71, 0x07,
- 0xD8, 0xE1, 0x03,
- 0xDC, 0x71, 0x07,
- 0xCC, 0x39, 0x06,
- 0xFE, 0x3F, 0x0E,
- 0xC0, 0x39, 0x0E,
- 0xC0, 0x39, 0x06,
- 0xC0, 0x71, 0x07,
- 0xC0, 0xE1, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l48_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x07, 0x7E, 0x00,
- 0x80, 0x07, 0xFF, 0x00,
- 0xC0, 0x87, 0xEF, 0x01,
- 0xC0, 0x87, 0xC7, 0x01,
- 0xE0, 0x87, 0xC3, 0x03,
- 0xE0, 0x87, 0xC3, 0x03,
- 0xF0, 0x87, 0xC7, 0x01,
- 0x70, 0x07, 0xEF, 0x01,
- 0x78, 0x07, 0xFE, 0x00,
- 0x3C, 0x07, 0xFF, 0x00,
- 0x3C, 0x87, 0xE7, 0x01,
- 0x1E, 0x87, 0xC3, 0x03,
- 0x0E, 0xC7, 0x83, 0x03,
- 0xFF, 0xDF, 0x83, 0x03,
- 0xFF, 0xDF, 0x83, 0x03,
- 0x00, 0xC7, 0x83, 0x03,
- 0x00, 0x87, 0xC3, 0x03,
- 0x00, 0x87, 0xE7, 0x01,
- 0x00, 0x07, 0xFF, 0x01,
- 0x00, 0x07, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l49.xbm b/app/bin/bitmaps/l49.xbm deleted file mode 100644 index e930612..0000000 --- a/app/bin/bitmaps/l49.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l49_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x70, 0x1E,
- 0x70, 0x3F,
- 0x78, 0x33,
- 0x78, 0x33,
- 0x7C, 0x3F,
- 0x6C, 0x3E,
- 0xFE, 0x30,
- 0x60, 0x3B,
- 0x60, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l49_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xC0, 0xE1, 0x01,
- 0xC0, 0x71, 0x07,
- 0xE0, 0x39, 0x07,
- 0xE0, 0x39, 0x06,
- 0xF0, 0x39, 0x0E,
- 0xF0, 0x39, 0x0E,
- 0xF8, 0x39, 0x0F,
- 0xD8, 0x71, 0x0F,
- 0xDC, 0xE1, 0x0F,
- 0xCC, 0x01, 0x0E,
- 0xFE, 0x07, 0x06,
- 0xC0, 0x01, 0x06,
- 0xC0, 0x39, 0x07,
- 0xC0, 0x71, 0x03,
- 0xC0, 0xF1, 0x01,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l49_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x07, 0x7E, 0x00,
- 0x80, 0x07, 0xFF, 0x00,
- 0xC0, 0x87, 0xEF, 0x01,
- 0xC0, 0x87, 0xC7, 0x01,
- 0xE0, 0xC7, 0x83, 0x03,
- 0xE0, 0xC7, 0x83, 0x03,
- 0xF0, 0xC7, 0x83, 0x03,
- 0x70, 0xC7, 0x83, 0x03,
- 0x78, 0xC7, 0x83, 0x03,
- 0x3C, 0x87, 0xC3, 0x03,
- 0x3C, 0x87, 0xE7, 0x03,
- 0x1E, 0x07, 0xFF, 0x03,
- 0x0E, 0x07, 0xFE, 0x03,
- 0xFF, 0x1F, 0x80, 0x03,
- 0xFF, 0x1F, 0x80, 0x03,
- 0x00, 0x87, 0xC3, 0x03,
- 0x00, 0x87, 0xC3, 0x01,
- 0x00, 0x87, 0xE7, 0x01,
- 0x00, 0x07, 0xFF, 0x00,
- 0x00, 0x07, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l5.xbm b/app/bin/bitmaps/l5.xbm deleted file mode 100644 index 4d43af0..0000000 --- a/app/bin/bitmaps/l5.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l5_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0xE0, 0x07,
- 0xE0, 0x00,
- 0xE0, 0x00,
- 0xE0, 0x03,
- 0x60, 0x07,
- 0x00, 0x06,
- 0x60, 0x06,
- 0xE0, 0x07,
- 0xC0, 0x03,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l5_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x80, 0x3F, 0x00,
- 0x80, 0x03, 0x00,
- 0x80, 0x03, 0x00,
- 0x80, 0x01, 0x00,
- 0x80, 0x01, 0x00,
- 0xC0, 0x1F, 0x00,
- 0xC0, 0x3B, 0x00,
- 0xC0, 0x39, 0x00,
- 0x00, 0x70, 0x00,
- 0x00, 0x70, 0x00,
- 0x00, 0x70, 0x00,
- 0xC0, 0x31, 0x00,
- 0xC0, 0x39, 0x00,
- 0x80, 0x3B, 0x00,
- 0x00, 0x1F, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l5_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xFE, 0x07, 0x00,
- 0x00, 0xFE, 0x07, 0x00,
- 0x00, 0x0E, 0x00, 0x00,
- 0x00, 0x0E, 0x00, 0x00,
- 0x00, 0x0F, 0x00, 0x00,
- 0x00, 0x0F, 0x00, 0x00,
- 0x00, 0xFF, 0x00, 0x00,
- 0x00, 0xFF, 0x03, 0x00,
- 0x00, 0xCF, 0x03, 0x00,
- 0x00, 0x87, 0x07, 0x00,
- 0x00, 0x80, 0x07, 0x00,
- 0x00, 0x00, 0x07, 0x00,
- 0x00, 0x00, 0x07, 0x00,
- 0x00, 0x00, 0x07, 0x00,
- 0x80, 0x07, 0x07, 0x00,
- 0x80, 0x87, 0x07, 0x00,
- 0x00, 0x87, 0x07, 0x00,
- 0x00, 0xCF, 0x03, 0x00,
- 0x00, 0xFE, 0x01, 0x00,
- 0x00, 0xFC, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l50.xbm b/app/bin/bitmaps/l50.xbm deleted file mode 100644 index 834ab8f..0000000 --- a/app/bin/bitmaps/l50.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l50_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0xFC, 0x1E,
- 0x1C, 0x3F,
- 0x1C, 0x33,
- 0x7C, 0x33,
- 0xEC, 0x33,
- 0xC0, 0x33,
- 0xCC, 0x33,
- 0xFC, 0x3F,
- 0x78, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l50_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF8, 0xE3, 0x03,
- 0x38, 0x70, 0x07,
- 0x38, 0x30, 0x07,
- 0x18, 0x38, 0x06,
- 0x18, 0x38, 0x06,
- 0xFC, 0x39, 0x0E,
- 0xBC, 0x3B, 0x0E,
- 0x9C, 0x3B, 0x0E,
- 0x00, 0x3F, 0x0E,
- 0x00, 0x3F, 0x0E,
- 0x00, 0x3F, 0x06,
- 0x1C, 0x3B, 0x06,
- 0x9C, 0x33, 0x07,
- 0xB8, 0x73, 0x07,
- 0xF0, 0xE1, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l50_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF8, 0x1F, 0x7E, 0x00,
- 0xF8, 0x1F, 0xFF, 0x00,
- 0x38, 0x00, 0xEF, 0x01,
- 0x38, 0x80, 0xC7, 0x01,
- 0x3C, 0x80, 0xC3, 0x03,
- 0x3C, 0x80, 0xC3, 0x03,
- 0xFC, 0xC3, 0x83, 0x03,
- 0xFC, 0xCF, 0x83, 0x03,
- 0x3C, 0xCF, 0x83, 0x03,
- 0x1C, 0xDE, 0x83, 0x03,
- 0x00, 0xDE, 0x83, 0x03,
- 0x00, 0xDC, 0x83, 0x03,
- 0x00, 0xDC, 0x83, 0x03,
- 0x00, 0xDC, 0x83, 0x03,
- 0x1E, 0x9C, 0xC3, 0x03,
- 0x1E, 0x9E, 0xC3, 0x03,
- 0x1C, 0x9E, 0xC7, 0x01,
- 0x3C, 0x0F, 0xEF, 0x01,
- 0xF8, 0x07, 0xFF, 0x00,
- 0xF0, 0x03, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l51.xbm b/app/bin/bitmaps/l51.xbm deleted file mode 100644 index 8081e2f..0000000 --- a/app/bin/bitmaps/l51.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l51_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0xFC, 0x1C,
- 0x1C, 0x1E,
- 0x1C, 0x1F,
- 0x7C, 0x1C,
- 0xEC, 0x1C,
- 0xC0, 0x1C,
- 0xCC, 0x1C,
- 0xFC, 0x1C,
- 0x78, 0x1C,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l51_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF8, 0x83, 0x03,
- 0x38, 0xC0, 0x03,
- 0x38, 0xC0, 0x03,
- 0x18, 0xE0, 0x03,
- 0x18, 0xB0, 0x03,
- 0xFC, 0x81, 0x03,
- 0xBC, 0x83, 0x03,
- 0x9C, 0x83, 0x03,
- 0x00, 0x87, 0x03,
- 0x00, 0x87, 0x03,
- 0x00, 0x87, 0x03,
- 0x1C, 0x83, 0x03,
- 0x9C, 0x83, 0x03,
- 0xB8, 0x83, 0x03,
- 0xF0, 0x81, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l51_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF8, 0x1F, 0x70, 0x00,
- 0xF8, 0x1F, 0x70, 0x00,
- 0x38, 0x00, 0x78, 0x00,
- 0x38, 0x00, 0x7C, 0x00,
- 0x3C, 0x00, 0x7E, 0x00,
- 0x3C, 0x00, 0x7F, 0x00,
- 0xFC, 0x03, 0x73, 0x00,
- 0xFC, 0x0F, 0x70, 0x00,
- 0x3C, 0x0F, 0x70, 0x00,
- 0x1C, 0x1E, 0x70, 0x00,
- 0x00, 0x1E, 0x70, 0x00,
- 0x00, 0x1C, 0x70, 0x00,
- 0x00, 0x1C, 0x70, 0x00,
- 0x00, 0x1C, 0x70, 0x00,
- 0x1E, 0x1C, 0x70, 0x00,
- 0x1E, 0x1E, 0x70, 0x00,
- 0x1C, 0x1E, 0x70, 0x00,
- 0x3C, 0x0F, 0x70, 0x00,
- 0xF8, 0x07, 0x70, 0x00,
- 0xF0, 0x03, 0x70, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l52.xbm b/app/bin/bitmaps/l52.xbm deleted file mode 100644 index 1547b10..0000000 --- a/app/bin/bitmaps/l52.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l52_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0xFC, 0x1E,
- 0x1C, 0x3F,
- 0x1C, 0x33,
- 0x7C, 0x30,
- 0xEC, 0x38,
- 0xC0, 0x1C,
- 0xCC, 0x0E,
- 0xFC, 0x07,
- 0x78, 0x3F,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l52_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF8, 0xE3, 0x03,
- 0x38, 0x70, 0x07,
- 0x38, 0x38, 0x06,
- 0x18, 0x38, 0x0E,
- 0x18, 0x00, 0x0E,
- 0xFC, 0x01, 0x0E,
- 0xBC, 0x03, 0x07,
- 0x9C, 0x83, 0x07,
- 0x00, 0x87, 0x03,
- 0x00, 0xC7, 0x01,
- 0x00, 0xE7, 0x01,
- 0x1C, 0xF3, 0x00,
- 0x9C, 0x73, 0x00,
- 0xB8, 0x7B, 0x00,
- 0xF0, 0xF9, 0x0F,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l52_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF8, 0x1F, 0xFE, 0x00,
- 0xF8, 0x1F, 0xFF, 0x01,
- 0x38, 0x80, 0xE7, 0x03,
- 0x38, 0x80, 0xC3, 0x03,
- 0x3C, 0xC0, 0x83, 0x03,
- 0x3C, 0xC0, 0x83, 0x03,
- 0xFC, 0x03, 0x80, 0x03,
- 0xFC, 0x0F, 0xC0, 0x03,
- 0x3C, 0x0F, 0xC0, 0x03,
- 0x1C, 0x1E, 0xE0, 0x01,
- 0x00, 0x1E, 0xF0, 0x01,
- 0x00, 0x1C, 0xF8, 0x00,
- 0x00, 0x1C, 0x78, 0x00,
- 0x00, 0x1C, 0x3C, 0x00,
- 0x1E, 0x1C, 0x1E, 0x00,
- 0x1E, 0x1E, 0x0F, 0x00,
- 0x1C, 0x9E, 0x07, 0x00,
- 0x3C, 0x8F, 0x07, 0x00,
- 0xF8, 0xC7, 0xFF, 0x03,
- 0xF0, 0xC3, 0xFF, 0x03,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l53.xbm b/app/bin/bitmaps/l53.xbm deleted file mode 100644 index a9620b9..0000000 --- a/app/bin/bitmaps/l53.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l53_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0xFC, 0x1E,
- 0x1C, 0x3B,
- 0x1C, 0x38,
- 0x7C, 0x18,
- 0xEC, 0x3C,
- 0xC0, 0x38,
- 0xCC, 0x33,
- 0xFC, 0x3F,
- 0x78, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l53_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF8, 0xE3, 0x03,
- 0x38, 0x70, 0x07,
- 0x38, 0x38, 0x07,
- 0x18, 0x00, 0x07,
- 0x18, 0x00, 0x07,
- 0xFC, 0x01, 0x07,
- 0xBC, 0x83, 0x03,
- 0x9C, 0xC3, 0x07,
- 0x00, 0x07, 0x07,
- 0x00, 0x07, 0x0E,
- 0x00, 0x07, 0x0E,
- 0x1C, 0x3B, 0x0E,
- 0x9C, 0x3B, 0x07,
- 0xB8, 0x73, 0x07,
- 0xF0, 0xE1, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l53_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF8, 0x1F, 0x7E, 0x00,
- 0xF8, 0x1F, 0xFF, 0x00,
- 0x38, 0x80, 0xE7, 0x01,
- 0x38, 0x80, 0xC7, 0x01,
- 0x3C, 0x80, 0xC3, 0x03,
- 0x3C, 0x00, 0xC0, 0x03,
- 0xFC, 0x03, 0xC0, 0x01,
- 0xFC, 0x0F, 0xE0, 0x01,
- 0x3C, 0x0F, 0xFC, 0x00,
- 0x1C, 0x1E, 0xFC, 0x00,
- 0x00, 0x1E, 0xE0, 0x01,
- 0x00, 0x1C, 0xC0, 0x03,
- 0x00, 0x1C, 0x80, 0x03,
- 0x00, 0x1C, 0x80, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0xDE, 0x83, 0x03,
- 0x1C, 0x9E, 0xC7, 0x03,
- 0x3C, 0x8F, 0xE7, 0x01,
- 0xF8, 0x07, 0xFF, 0x01,
- 0xF0, 0x03, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l54.xbm b/app/bin/bitmaps/l54.xbm deleted file mode 100644 index 68a392e..0000000 --- a/app/bin/bitmaps/l54.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l54_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0xFC, 0x1C,
- 0x1C, 0x1C,
- 0x1C, 0x1E,
- 0x7C, 0x1E,
- 0xEC, 0x1F,
- 0xC0, 0x1B,
- 0xCC, 0x3F,
- 0xFC, 0x18,
- 0x78, 0x18,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l54_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF8, 0x83, 0x03,
- 0x38, 0x80, 0x03,
- 0x38, 0xC0, 0x03,
- 0x18, 0xC0, 0x03,
- 0x18, 0xE0, 0x03,
- 0xFC, 0xE1, 0x03,
- 0xBC, 0xF3, 0x03,
- 0x9C, 0xB3, 0x03,
- 0x00, 0xBF, 0x03,
- 0x00, 0x9F, 0x03,
- 0x00, 0xFF, 0x0F,
- 0x1C, 0x83, 0x03,
- 0x9C, 0x83, 0x03,
- 0xB8, 0x83, 0x03,
- 0xF0, 0x81, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l54_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF8, 0x1F, 0xF0, 0x00,
- 0xF8, 0x1F, 0xF0, 0x00,
- 0x38, 0x00, 0xF8, 0x00,
- 0x38, 0x00, 0xF8, 0x00,
- 0x3C, 0x00, 0xFC, 0x00,
- 0x3C, 0x00, 0xFC, 0x00,
- 0xFC, 0x03, 0xFE, 0x00,
- 0xFC, 0x0F, 0xEE, 0x00,
- 0x3C, 0x0F, 0xEF, 0x00,
- 0x1C, 0x9E, 0xE7, 0x00,
- 0x00, 0x9E, 0xE7, 0x00,
- 0x00, 0xDC, 0xE3, 0x00,
- 0x00, 0xDC, 0xE1, 0x00,
- 0x00, 0xFC, 0xFF, 0x03,
- 0x1E, 0xFC, 0xFF, 0x03,
- 0x1E, 0x1E, 0xE0, 0x00,
- 0x1C, 0x1E, 0xE0, 0x00,
- 0x3C, 0x0F, 0xE0, 0x00,
- 0xF8, 0x07, 0xE0, 0x00,
- 0xF0, 0x03, 0xE0, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l55.xbm b/app/bin/bitmaps/l55.xbm deleted file mode 100644 index 8c35927..0000000 --- a/app/bin/bitmaps/l55.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l55_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0xFC, 0x3F,
- 0x1C, 0x07,
- 0x1C, 0x07,
- 0x7C, 0x1F,
- 0xEC, 0x3B,
- 0xC0, 0x30,
- 0xCC, 0x33,
- 0xFC, 0x3F,
- 0x78, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l55_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF8, 0xF3, 0x07,
- 0x38, 0x70, 0x00,
- 0x38, 0x70, 0x00,
- 0x18, 0x30, 0x00,
- 0x18, 0x30, 0x00,
- 0xFC, 0xF9, 0x03,
- 0xBC, 0x7B, 0x07,
- 0x9C, 0x3B, 0x07,
- 0x00, 0x07, 0x0E,
- 0x00, 0x07, 0x0E,
- 0x00, 0x07, 0x0E,
- 0x1C, 0x3B, 0x06,
- 0x9C, 0x3B, 0x07,
- 0xB8, 0x73, 0x07,
- 0xF0, 0xE1, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l55_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF8, 0x1F, 0xFF, 0x03,
- 0xF8, 0x1F, 0xFF, 0x03,
- 0x38, 0x00, 0x07, 0x00,
- 0x38, 0x00, 0x07, 0x00,
- 0x3C, 0x80, 0x07, 0x00,
- 0x3C, 0x80, 0x07, 0x00,
- 0xFC, 0x83, 0x7F, 0x00,
- 0xFC, 0x8F, 0xFF, 0x01,
- 0x3C, 0x8F, 0xE7, 0x01,
- 0x1C, 0x9E, 0xC3, 0x03,
- 0x00, 0x1E, 0xC0, 0x03,
- 0x00, 0x1C, 0x80, 0x03,
- 0x00, 0x1C, 0x80, 0x03,
- 0x00, 0x1C, 0x80, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0xDE, 0xC3, 0x03,
- 0x1C, 0x9E, 0xC3, 0x03,
- 0x3C, 0x8F, 0xE7, 0x01,
- 0xF8, 0x07, 0xFF, 0x00,
- 0xF0, 0x03, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l56.xbm b/app/bin/bitmaps/l56.xbm deleted file mode 100644 index e8f4d59..0000000 --- a/app/bin/bitmaps/l56.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l56_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0xFC, 0x1E,
- 0x1C, 0x3F,
- 0x1C, 0x03,
- 0x7C, 0x1F,
- 0xEC, 0x3F,
- 0xC0, 0x33,
- 0xCC, 0x33,
- 0xFC, 0x3F,
- 0x78, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l56_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF8, 0xE3, 0x03,
- 0x38, 0x70, 0x07,
- 0x38, 0x30, 0x07,
- 0x18, 0x38, 0x00,
- 0x18, 0x38, 0x00,
- 0xFC, 0x39, 0x00,
- 0xBC, 0xFB, 0x03,
- 0x9C, 0x7B, 0x07,
- 0x00, 0x3F, 0x07,
- 0x00, 0x3F, 0x0E,
- 0x00, 0x3F, 0x0E,
- 0x1C, 0x3B, 0x0E,
- 0x9C, 0x33, 0x07,
- 0xB8, 0x73, 0x07,
- 0xF0, 0xE1, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l56_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF8, 0x1F, 0xFC, 0x00,
- 0xF8, 0x1F, 0xFF, 0x01,
- 0x38, 0x00, 0xEF, 0x01,
- 0x38, 0x80, 0xC7, 0x03,
- 0x3C, 0x80, 0xC3, 0x03,
- 0x3C, 0x80, 0x03, 0x00,
- 0xFC, 0xC3, 0x03, 0x00,
- 0xFC, 0xCF, 0x7F, 0x00,
- 0x3C, 0xCF, 0xFF, 0x01,
- 0x1C, 0xDE, 0xEF, 0x01,
- 0x00, 0xDE, 0xC7, 0x03,
- 0x00, 0xDC, 0x83, 0x03,
- 0x00, 0xDC, 0x83, 0x03,
- 0x00, 0xDC, 0x83, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0x9E, 0x83, 0x03,
- 0x1C, 0x9E, 0xC7, 0x03,
- 0x3C, 0x8F, 0xEF, 0x01,
- 0xF8, 0x07, 0xFF, 0x01,
- 0xF0, 0x03, 0x7C, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l57.xbm b/app/bin/bitmaps/l57.xbm deleted file mode 100644 index 5149c54..0000000 --- a/app/bin/bitmaps/l57.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l57_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0xFC, 0x3F,
- 0x1C, 0x38,
- 0x1C, 0x18,
- 0x7C, 0x1C,
- 0xEC, 0x0C,
- 0xC0, 0x0E,
- 0xCC, 0x0E,
- 0xFC, 0x06,
- 0x78, 0x06,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l57_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF8, 0xFB, 0x0F,
- 0x38, 0x00, 0x0F,
- 0x38, 0x00, 0x07,
- 0x18, 0x80, 0x03,
- 0x18, 0x80, 0x03,
- 0xFC, 0xC1, 0x01,
- 0xBC, 0xC3, 0x01,
- 0x9C, 0xC3, 0x01,
- 0x00, 0xE7, 0x00,
- 0x00, 0xE7, 0x00,
- 0x00, 0xE7, 0x00,
- 0x1C, 0xE3, 0x00,
- 0x9C, 0xE3, 0x00,
- 0xB8, 0x73, 0x00,
- 0xF0, 0x71, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l57_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF8, 0xDF, 0xFF, 0x03,
- 0xF8, 0xDF, 0xFF, 0x03,
- 0x38, 0x00, 0xC0, 0x03,
- 0x38, 0x00, 0xE0, 0x01,
- 0x3C, 0x00, 0xE0, 0x01,
- 0x3C, 0x00, 0xF0, 0x00,
- 0xFC, 0x03, 0xF0, 0x00,
- 0xFC, 0x0F, 0x78, 0x00,
- 0x3C, 0x0F, 0x78, 0x00,
- 0x1C, 0x1E, 0x38, 0x00,
- 0x00, 0x1E, 0x3C, 0x00,
- 0x00, 0x1C, 0x3C, 0x00,
- 0x00, 0x1C, 0x1C, 0x00,
- 0x00, 0x1C, 0x1E, 0x00,
- 0x1E, 0x1C, 0x1E, 0x00,
- 0x1E, 0x1E, 0x1E, 0x00,
- 0x1C, 0x1E, 0x1E, 0x00,
- 0x3C, 0x0F, 0x0E, 0x00,
- 0xF8, 0x07, 0x0E, 0x00,
- 0xF0, 0x03, 0x0E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l58.xbm b/app/bin/bitmaps/l58.xbm deleted file mode 100644 index 3fe4ad7..0000000 --- a/app/bin/bitmaps/l58.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l58_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0xFC, 0x1E,
- 0x1C, 0x3F,
- 0x1C, 0x3B,
- 0x7C, 0x3F,
- 0xEC, 0x1E,
- 0xC0, 0x3F,
- 0xCC, 0x33,
- 0xFC, 0x3F,
- 0x78, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l58_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF8, 0xE3, 0x03,
- 0x38, 0x70, 0x07,
- 0x38, 0x30, 0x07,
- 0x18, 0x38, 0x07,
- 0x18, 0x38, 0x07,
- 0xFC, 0x39, 0x07,
- 0xBC, 0x73, 0x07,
- 0x9C, 0xE3, 0x03,
- 0x00, 0x77, 0x07,
- 0x00, 0x3F, 0x06,
- 0x00, 0x3F, 0x0E,
- 0x1C, 0x3B, 0x0E,
- 0x9C, 0x3B, 0x06,
- 0xB8, 0x73, 0x07,
- 0xF0, 0xE1, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l58_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF8, 0x1F, 0x7E, 0x00,
- 0xF8, 0x1F, 0xFF, 0x00,
- 0x38, 0x80, 0xEF, 0x01,
- 0x38, 0x80, 0xC7, 0x01,
- 0x3C, 0x80, 0xC3, 0x03,
- 0x3C, 0x80, 0xC3, 0x03,
- 0xFC, 0x83, 0xC7, 0x01,
- 0xFC, 0x0F, 0xEF, 0x01,
- 0x3C, 0x0F, 0xFE, 0x00,
- 0x1C, 0x1E, 0xFF, 0x00,
- 0x00, 0x9E, 0xE7, 0x01,
- 0x00, 0x9C, 0xC3, 0x03,
- 0x00, 0xDC, 0x83, 0x03,
- 0x00, 0xDC, 0x83, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0xDE, 0x83, 0x03,
- 0x1C, 0x9E, 0xC3, 0x03,
- 0x3C, 0x8F, 0xE7, 0x01,
- 0xF8, 0x07, 0xFF, 0x01,
- 0xF0, 0x03, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l59.xbm b/app/bin/bitmaps/l59.xbm deleted file mode 100644 index 9459753..0000000 --- a/app/bin/bitmaps/l59.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l59_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0xFC, 0x1E,
- 0x1C, 0x3F,
- 0x1C, 0x33,
- 0x7C, 0x33,
- 0xEC, 0x3F,
- 0xC0, 0x3E,
- 0xCC, 0x30,
- 0xFC, 0x3B,
- 0x78, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l59_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF8, 0xE3, 0x01,
- 0x38, 0x70, 0x07,
- 0x38, 0x38, 0x07,
- 0x18, 0x38, 0x06,
- 0x18, 0x38, 0x0E,
- 0xFC, 0x39, 0x0E,
- 0xBC, 0x3B, 0x0F,
- 0x9C, 0x73, 0x0F,
- 0x00, 0xE7, 0x0F,
- 0x00, 0x07, 0x0E,
- 0x00, 0x07, 0x06,
- 0x1C, 0x03, 0x06,
- 0x9C, 0x3B, 0x07,
- 0xB8, 0x73, 0x03,
- 0xF0, 0xF1, 0x01,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l59_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF8, 0x1F, 0x7E, 0x00,
- 0xF8, 0x1F, 0xFF, 0x00,
- 0x38, 0x80, 0xEF, 0x01,
- 0x38, 0x80, 0xC7, 0x01,
- 0x3C, 0xC0, 0x83, 0x03,
- 0x3C, 0xC0, 0x83, 0x03,
- 0xFC, 0xC3, 0x83, 0x03,
- 0xFC, 0xCF, 0x83, 0x03,
- 0x3C, 0xCF, 0x83, 0x03,
- 0x1C, 0x9E, 0xC3, 0x03,
- 0x00, 0x9E, 0xE7, 0x03,
- 0x00, 0x1C, 0xFF, 0x03,
- 0x00, 0x1C, 0xFE, 0x03,
- 0x00, 0x1C, 0x80, 0x03,
- 0x1E, 0x1C, 0x80, 0x03,
- 0x1E, 0x9E, 0xC3, 0x03,
- 0x1C, 0x9E, 0xC3, 0x01,
- 0x3C, 0x8F, 0xE7, 0x01,
- 0xF8, 0x07, 0xFF, 0x00,
- 0xF0, 0x03, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l6.xbm b/app/bin/bitmaps/l6.xbm deleted file mode 100644 index 325c80c..0000000 --- a/app/bin/bitmaps/l6.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l6_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0xC0, 0x03,
- 0xE0, 0x07,
- 0x60, 0x00,
- 0xE0, 0x03,
- 0xE0, 0x07,
- 0x60, 0x06,
- 0x60, 0x06,
- 0xE0, 0x07,
- 0xC0, 0x03,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l6_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x1F, 0x00,
- 0x80, 0x3B, 0x00,
- 0x80, 0x39, 0x00,
- 0xC0, 0x01, 0x00,
- 0xC0, 0x01, 0x00,
- 0xC0, 0x01, 0x00,
- 0xC0, 0x1F, 0x00,
- 0xC0, 0x3B, 0x00,
- 0xC0, 0x39, 0x00,
- 0xC0, 0x71, 0x00,
- 0xC0, 0x71, 0x00,
- 0xC0, 0x71, 0x00,
- 0x80, 0x39, 0x00,
- 0x80, 0x3B, 0x00,
- 0x00, 0x1F, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l6_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xF8, 0x01, 0x00,
- 0x00, 0xFE, 0x03, 0x00,
- 0x00, 0xDE, 0x03, 0x00,
- 0x00, 0x8F, 0x07, 0x00,
- 0x00, 0x87, 0x07, 0x00,
- 0x00, 0x07, 0x00, 0x00,
- 0x80, 0x07, 0x00, 0x00,
- 0x80, 0xFF, 0x00, 0x00,
- 0x80, 0xFF, 0x03, 0x00,
- 0x80, 0xDF, 0x03, 0x00,
- 0x80, 0x8F, 0x07, 0x00,
- 0x80, 0x07, 0x07, 0x00,
- 0x80, 0x07, 0x07, 0x00,
- 0x80, 0x07, 0x07, 0x00,
- 0x80, 0x07, 0x07, 0x00,
- 0x00, 0x07, 0x07, 0x00,
- 0x00, 0x8F, 0x07, 0x00,
- 0x00, 0xDF, 0x03, 0x00,
- 0x00, 0xFE, 0x03, 0x00,
- 0x00, 0xF8, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l60.xbm b/app/bin/bitmaps/l60.xbm deleted file mode 100644 index 11b9cc7..0000000 --- a/app/bin/bitmaps/l60.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l60_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1E,
- 0xFC, 0x3F,
- 0x0C, 0x33,
- 0x7C, 0x33,
- 0xFC, 0x33,
- 0xCC, 0x33,
- 0xCC, 0x33,
- 0xFC, 0x3F,
- 0x78, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l60_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xE1, 0x03,
- 0xB8, 0x73, 0x07,
- 0x98, 0x33, 0x07,
- 0x1C, 0x38, 0x06,
- 0x1C, 0x38, 0x06,
- 0x1C, 0x38, 0x0E,
- 0xFC, 0x39, 0x0E,
- 0xBC, 0x3B, 0x0E,
- 0x9C, 0x3B, 0x0E,
- 0x1C, 0x3F, 0x0E,
- 0x1C, 0x3F, 0x06,
- 0x1C, 0x3F, 0x06,
- 0x98, 0x33, 0x07,
- 0xB8, 0x73, 0x07,
- 0xF0, 0xE1, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l60_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xE0, 0x07, 0x7E, 0x00,
- 0xF8, 0x0F, 0xFF, 0x00,
- 0x78, 0x0F, 0xEF, 0x01,
- 0x3C, 0x9E, 0xC7, 0x01,
- 0x1C, 0x9E, 0xC3, 0x03,
- 0x1C, 0x80, 0xC3, 0x03,
- 0x1E, 0xC0, 0x83, 0x03,
- 0xFE, 0xC3, 0x83, 0x03,
- 0xFE, 0xCF, 0x83, 0x03,
- 0x7E, 0xCF, 0x83, 0x03,
- 0x3E, 0xDE, 0x83, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0x9C, 0xC3, 0x03,
- 0x1C, 0x9C, 0xC3, 0x03,
- 0x3C, 0x9E, 0xC7, 0x01,
- 0x7C, 0x0F, 0xEF, 0x01,
- 0xF8, 0x0F, 0xFF, 0x00,
- 0xE0, 0x03, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l61.xbm b/app/bin/bitmaps/l61.xbm deleted file mode 100644 index 1983790..0000000 --- a/app/bin/bitmaps/l61.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l61_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1C,
- 0xFC, 0x1E,
- 0x0C, 0x1F,
- 0x7C, 0x1C,
- 0xFC, 0x1C,
- 0xCC, 0x1C,
- 0xCC, 0x1C,
- 0xFC, 0x1C,
- 0x78, 0x1C,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l61_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0x81, 0x03,
- 0xB8, 0xC3, 0x03,
- 0x98, 0xC3, 0x03,
- 0x1C, 0xE0, 0x03,
- 0x1C, 0xB0, 0x03,
- 0x1C, 0x80, 0x03,
- 0xFC, 0x81, 0x03,
- 0xBC, 0x83, 0x03,
- 0x9C, 0x83, 0x03,
- 0x1C, 0x87, 0x03,
- 0x1C, 0x87, 0x03,
- 0x1C, 0x87, 0x03,
- 0x98, 0x83, 0x03,
- 0xB8, 0x83, 0x03,
- 0xF0, 0x81, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l61_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xE0, 0x07, 0x70, 0x00,
- 0xF8, 0x0F, 0x70, 0x00,
- 0x78, 0x0F, 0x78, 0x00,
- 0x3C, 0x1E, 0x7C, 0x00,
- 0x1C, 0x1E, 0x7E, 0x00,
- 0x1C, 0x00, 0x7F, 0x00,
- 0x1E, 0x00, 0x73, 0x00,
- 0xFE, 0x03, 0x70, 0x00,
- 0xFE, 0x0F, 0x70, 0x00,
- 0x7E, 0x0F, 0x70, 0x00,
- 0x3E, 0x1E, 0x70, 0x00,
- 0x1E, 0x1C, 0x70, 0x00,
- 0x1E, 0x1C, 0x70, 0x00,
- 0x1E, 0x1C, 0x70, 0x00,
- 0x1E, 0x1C, 0x70, 0x00,
- 0x1C, 0x1C, 0x70, 0x00,
- 0x3C, 0x1E, 0x70, 0x00,
- 0x7C, 0x0F, 0x70, 0x00,
- 0xF8, 0x0F, 0x70, 0x00,
- 0xE0, 0x03, 0x70, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l62.xbm b/app/bin/bitmaps/l62.xbm deleted file mode 100644 index 93573ec..0000000 --- a/app/bin/bitmaps/l62.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l62_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1E,
- 0xFC, 0x3F,
- 0x0C, 0x33,
- 0x7C, 0x30,
- 0xFC, 0x38,
- 0xCC, 0x1C,
- 0xCC, 0x0E,
- 0xFC, 0x07,
- 0x78, 0x3F,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l62_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xE1, 0x03,
- 0xB8, 0x73, 0x07,
- 0x98, 0x3B, 0x06,
- 0x1C, 0x38, 0x0E,
- 0x1C, 0x00, 0x0E,
- 0x1C, 0x00, 0x0E,
- 0xFC, 0x01, 0x07,
- 0xBC, 0x83, 0x07,
- 0x9C, 0x83, 0x03,
- 0x1C, 0xC7, 0x01,
- 0x1C, 0xE7, 0x01,
- 0x1C, 0xF7, 0x00,
- 0x98, 0x73, 0x00,
- 0xB8, 0x7B, 0x00,
- 0xF0, 0xF9, 0x0F,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l62_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xE0, 0x07, 0xFE, 0x00,
- 0xF8, 0x0F, 0xFF, 0x01,
- 0x78, 0x8F, 0xE7, 0x03,
- 0x3C, 0x9E, 0xC3, 0x03,
- 0x1C, 0xDE, 0x83, 0x03,
- 0x1C, 0xC0, 0x83, 0x03,
- 0x1E, 0x00, 0x80, 0x03,
- 0xFE, 0x03, 0xC0, 0x03,
- 0xFE, 0x0F, 0xC0, 0x03,
- 0x7E, 0x0F, 0xE0, 0x01,
- 0x3E, 0x1E, 0xF0, 0x01,
- 0x1E, 0x1C, 0xF8, 0x00,
- 0x1E, 0x1C, 0x78, 0x00,
- 0x1E, 0x1C, 0x3C, 0x00,
- 0x1E, 0x1C, 0x1E, 0x00,
- 0x1C, 0x1C, 0x0F, 0x00,
- 0x3C, 0x9E, 0x07, 0x00,
- 0x7C, 0x8F, 0x07, 0x00,
- 0xF8, 0xCF, 0xFF, 0x03,
- 0xE0, 0xC3, 0xFF, 0x03,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l63.xbm b/app/bin/bitmaps/l63.xbm deleted file mode 100644 index 6b95b4d..0000000 --- a/app/bin/bitmaps/l63.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l63_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1E,
- 0xFC, 0x3B,
- 0x0C, 0x38,
- 0x7C, 0x18,
- 0xFC, 0x3C,
- 0xCC, 0x38,
- 0xCC, 0x33,
- 0xFC, 0x3F,
- 0x78, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l63_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xE1, 0x03,
- 0xB8, 0x73, 0x07,
- 0x98, 0x3B, 0x07,
- 0x1C, 0x00, 0x07,
- 0x1C, 0x00, 0x07,
- 0x1C, 0x00, 0x07,
- 0xFC, 0x81, 0x03,
- 0xBC, 0xC3, 0x07,
- 0x9C, 0x03, 0x07,
- 0x1C, 0x07, 0x0E,
- 0x1C, 0x07, 0x0E,
- 0x1C, 0x3F, 0x0E,
- 0x98, 0x3B, 0x07,
- 0xB8, 0x73, 0x07,
- 0xF0, 0xE1, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l63_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xE0, 0x07, 0x7E, 0x00,
- 0xF8, 0x0F, 0xFF, 0x00,
- 0x78, 0x8F, 0xE7, 0x01,
- 0x3C, 0x9E, 0xC7, 0x01,
- 0x1C, 0x9E, 0xC3, 0x03,
- 0x1C, 0x00, 0xC0, 0x03,
- 0x1E, 0x00, 0xC0, 0x01,
- 0xFE, 0x03, 0xE0, 0x01,
- 0xFE, 0x0F, 0xFC, 0x00,
- 0x7E, 0x0F, 0xFC, 0x00,
- 0x3E, 0x1E, 0xE0, 0x01,
- 0x1E, 0x1C, 0xC0, 0x03,
- 0x1E, 0x1C, 0x80, 0x03,
- 0x1E, 0x1C, 0x80, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1C, 0xDC, 0x83, 0x03,
- 0x3C, 0x9E, 0xC7, 0x03,
- 0x7C, 0x8F, 0xE7, 0x01,
- 0xF8, 0x0F, 0xFF, 0x01,
- 0xE0, 0x03, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l64.xbm b/app/bin/bitmaps/l64.xbm deleted file mode 100644 index e2a6cc5..0000000 --- a/app/bin/bitmaps/l64.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l64_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1C,
- 0xFC, 0x1C,
- 0x0C, 0x1E,
- 0x7C, 0x1E,
- 0xFC, 0x1F,
- 0xCC, 0x1B,
- 0xCC, 0x3F,
- 0xFC, 0x18,
- 0x78, 0x18,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l64_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0x81, 0x03,
- 0xB8, 0x83, 0x03,
- 0x98, 0xC3, 0x03,
- 0x1C, 0xC0, 0x03,
- 0x1C, 0xE0, 0x03,
- 0x1C, 0xE0, 0x03,
- 0xFC, 0xF1, 0x03,
- 0xBC, 0xB3, 0x03,
- 0x9C, 0xBB, 0x03,
- 0x1C, 0x9F, 0x03,
- 0x1C, 0xFF, 0x0F,
- 0x1C, 0x87, 0x03,
- 0x98, 0x83, 0x03,
- 0xB8, 0x83, 0x03,
- 0xF0, 0x81, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l64_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xE0, 0x07, 0xF0, 0x00,
- 0xF8, 0x0F, 0xF0, 0x00,
- 0x78, 0x0F, 0xF8, 0x00,
- 0x3C, 0x1E, 0xF8, 0x00,
- 0x1C, 0x1E, 0xFC, 0x00,
- 0x1C, 0x00, 0xFC, 0x00,
- 0x1E, 0x00, 0xFE, 0x00,
- 0xFE, 0x03, 0xEE, 0x00,
- 0xFE, 0x0F, 0xEF, 0x00,
- 0x7E, 0x8F, 0xE7, 0x00,
- 0x3E, 0x9E, 0xE7, 0x00,
- 0x1E, 0xDC, 0xE3, 0x00,
- 0x1E, 0xDC, 0xE1, 0x00,
- 0x1E, 0xFC, 0xFF, 0x03,
- 0x1E, 0xFC, 0xFF, 0x03,
- 0x1C, 0x1C, 0xE0, 0x00,
- 0x3C, 0x1E, 0xE0, 0x00,
- 0x7C, 0x0F, 0xE0, 0x00,
- 0xF8, 0x0F, 0xE0, 0x00,
- 0xE0, 0x03, 0xE0, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l65.xbm b/app/bin/bitmaps/l65.xbm deleted file mode 100644 index 3ab1ce6..0000000 --- a/app/bin/bitmaps/l65.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l65_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x3F,
- 0xFC, 0x07,
- 0x0C, 0x07,
- 0x7C, 0x1F,
- 0xFC, 0x3B,
- 0xCC, 0x30,
- 0xCC, 0x33,
- 0xFC, 0x3F,
- 0x78, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l65_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xF1, 0x07,
- 0xB8, 0x73, 0x00,
- 0x98, 0x73, 0x00,
- 0x1C, 0x30, 0x00,
- 0x1C, 0x30, 0x00,
- 0x1C, 0xF8, 0x03,
- 0xFC, 0x79, 0x07,
- 0xBC, 0x3B, 0x07,
- 0x9C, 0x03, 0x0E,
- 0x1C, 0x07, 0x0E,
- 0x1C, 0x07, 0x0E,
- 0x1C, 0x3F, 0x06,
- 0x98, 0x3B, 0x07,
- 0xB8, 0x73, 0x07,
- 0xF0, 0xE1, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l65_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xE0, 0x07, 0xFF, 0x03,
- 0xF8, 0x0F, 0xFF, 0x03,
- 0x78, 0x0F, 0x07, 0x00,
- 0x3C, 0x1E, 0x07, 0x00,
- 0x1C, 0x9E, 0x07, 0x00,
- 0x1C, 0x80, 0x07, 0x00,
- 0x1E, 0x80, 0x7F, 0x00,
- 0xFE, 0x83, 0xFF, 0x01,
- 0xFE, 0x8F, 0xE7, 0x01,
- 0x7E, 0x8F, 0xC3, 0x03,
- 0x3E, 0x1E, 0xC0, 0x03,
- 0x1E, 0x1C, 0x80, 0x03,
- 0x1E, 0x1C, 0x80, 0x03,
- 0x1E, 0x1C, 0x80, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1C, 0xDC, 0xC3, 0x03,
- 0x3C, 0x9E, 0xC3, 0x03,
- 0x7C, 0x8F, 0xE7, 0x01,
- 0xF8, 0x0F, 0xFF, 0x00,
- 0xE0, 0x03, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l66.xbm b/app/bin/bitmaps/l66.xbm deleted file mode 100644 index 1abbf7c..0000000 --- a/app/bin/bitmaps/l66.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l66_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1E,
- 0xFC, 0x3F,
- 0x0C, 0x03,
- 0x7C, 0x1F,
- 0xFC, 0x3F,
- 0xCC, 0x33,
- 0xCC, 0x33,
- 0xFC, 0x3F,
- 0x78, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l66_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xE1, 0x03,
- 0xB8, 0x73, 0x07,
- 0x98, 0x33, 0x07,
- 0x1C, 0x38, 0x00,
- 0x1C, 0x38, 0x00,
- 0x1C, 0x38, 0x00,
- 0xFC, 0xF9, 0x03,
- 0xBC, 0x7B, 0x07,
- 0x9C, 0x3B, 0x07,
- 0x1C, 0x3F, 0x0E,
- 0x1C, 0x3F, 0x0E,
- 0x1C, 0x3F, 0x0E,
- 0x98, 0x33, 0x07,
- 0xB8, 0x73, 0x07,
- 0xF0, 0xE1, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l66_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xE0, 0x07, 0xFC, 0x00,
- 0xF8, 0x0F, 0xFF, 0x01,
- 0x78, 0x0F, 0xEF, 0x01,
- 0x3C, 0x9E, 0xC7, 0x03,
- 0x1C, 0x9E, 0xC3, 0x03,
- 0x1C, 0x80, 0x03, 0x00,
- 0x1E, 0xC0, 0x03, 0x00,
- 0xFE, 0xC3, 0x7F, 0x00,
- 0xFE, 0xCF, 0xFF, 0x01,
- 0x7E, 0xCF, 0xEF, 0x01,
- 0x3E, 0xDE, 0xC7, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1C, 0x9C, 0x83, 0x03,
- 0x3C, 0x9E, 0xC7, 0x03,
- 0x7C, 0x8F, 0xEF, 0x01,
- 0xF8, 0x0F, 0xFF, 0x01,
- 0xE0, 0x03, 0x7C, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l67.xbm b/app/bin/bitmaps/l67.xbm deleted file mode 100644 index 8cce97c..0000000 --- a/app/bin/bitmaps/l67.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l67_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x3F,
- 0xFC, 0x38,
- 0x0C, 0x18,
- 0x7C, 0x1C,
- 0xFC, 0x0C,
- 0xCC, 0x0E,
- 0xCC, 0x0E,
- 0xFC, 0x06,
- 0x78, 0x06,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l67_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xF9, 0x0F,
- 0xB8, 0x03, 0x0F,
- 0x98, 0x03, 0x07,
- 0x1C, 0x80, 0x03,
- 0x1C, 0x80, 0x03,
- 0x1C, 0xC0, 0x01,
- 0xFC, 0xC1, 0x01,
- 0xBC, 0xC3, 0x01,
- 0x9C, 0xE3, 0x00,
- 0x1C, 0xE7, 0x00,
- 0x1C, 0xE7, 0x00,
- 0x1C, 0xE7, 0x00,
- 0x98, 0xE3, 0x00,
- 0xB8, 0x73, 0x00,
- 0xF0, 0x71, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l67_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xE0, 0xC7, 0xFF, 0x03,
- 0xF8, 0xCF, 0xFF, 0x03,
- 0x78, 0x0F, 0xC0, 0x03,
- 0x3C, 0x1E, 0xE0, 0x01,
- 0x1C, 0x1E, 0xE0, 0x01,
- 0x1C, 0x00, 0xF0, 0x00,
- 0x1E, 0x00, 0xF0, 0x00,
- 0xFE, 0x03, 0x78, 0x00,
- 0xFE, 0x0F, 0x78, 0x00,
- 0x7E, 0x0F, 0x38, 0x00,
- 0x3E, 0x1E, 0x3C, 0x00,
- 0x1E, 0x1C, 0x3C, 0x00,
- 0x1E, 0x1C, 0x1C, 0x00,
- 0x1E, 0x1C, 0x1E, 0x00,
- 0x1E, 0x1C, 0x1E, 0x00,
- 0x1C, 0x1C, 0x1E, 0x00,
- 0x3C, 0x1E, 0x1E, 0x00,
- 0x7C, 0x0F, 0x0E, 0x00,
- 0xF8, 0x0F, 0x0E, 0x00,
- 0xE0, 0x03, 0x0E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l68.xbm b/app/bin/bitmaps/l68.xbm deleted file mode 100644 index e32b8c2..0000000 --- a/app/bin/bitmaps/l68.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l68_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1E,
- 0xFC, 0x3F,
- 0x0C, 0x3B,
- 0x7C, 0x3F,
- 0xFC, 0x1E,
- 0xCC, 0x3F,
- 0xCC, 0x33,
- 0xFC, 0x3F,
- 0x78, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l68_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xE1, 0x03,
- 0xB8, 0x73, 0x07,
- 0x98, 0x33, 0x07,
- 0x1C, 0x38, 0x07,
- 0x1C, 0x38, 0x07,
- 0x1C, 0x38, 0x07,
- 0xFC, 0x71, 0x07,
- 0xBC, 0xE3, 0x03,
- 0x9C, 0x73, 0x07,
- 0x1C, 0x3F, 0x06,
- 0x1C, 0x3F, 0x0E,
- 0x1C, 0x3F, 0x0E,
- 0x98, 0x3B, 0x06,
- 0xB8, 0x73, 0x07,
- 0xF0, 0xE1, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l68_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xE0, 0x07, 0x7E, 0x00,
- 0xF8, 0x0F, 0xFF, 0x00,
- 0x78, 0x8F, 0xEF, 0x01,
- 0x3C, 0x9E, 0xC7, 0x01,
- 0x1C, 0x9E, 0xC3, 0x03,
- 0x1C, 0x80, 0xC3, 0x03,
- 0x1E, 0x80, 0xC7, 0x01,
- 0xFE, 0x03, 0xEF, 0x01,
- 0xFE, 0x0F, 0xFE, 0x00,
- 0x7E, 0x0F, 0xFF, 0x00,
- 0x3E, 0x9E, 0xE7, 0x01,
- 0x1E, 0x9C, 0xC3, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1C, 0xDC, 0x83, 0x03,
- 0x3C, 0x9E, 0xC3, 0x03,
- 0x7C, 0x8F, 0xE7, 0x01,
- 0xF8, 0x0F, 0xFF, 0x01,
- 0xE0, 0x03, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l69.xbm b/app/bin/bitmaps/l69.xbm deleted file mode 100644 index 8df10ca..0000000 --- a/app/bin/bitmaps/l69.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l69_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1E,
- 0xFC, 0x3F,
- 0x0C, 0x33,
- 0x7C, 0x33,
- 0xFC, 0x3F,
- 0xCC, 0x3E,
- 0xCC, 0x30,
- 0xFC, 0x3B,
- 0x78, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l69_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xE1, 0x01,
- 0xB8, 0x73, 0x07,
- 0x98, 0x3B, 0x07,
- 0x1C, 0x38, 0x06,
- 0x1C, 0x38, 0x0E,
- 0x1C, 0x38, 0x0E,
- 0xFC, 0x39, 0x0F,
- 0xBC, 0x73, 0x0F,
- 0x9C, 0xE3, 0x0F,
- 0x1C, 0x07, 0x0E,
- 0x1C, 0x07, 0x06,
- 0x1C, 0x07, 0x06,
- 0x98, 0x3B, 0x07,
- 0xB8, 0x73, 0x03,
- 0xF0, 0xF1, 0x01,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l69_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xE0, 0x07, 0x7E, 0x00,
- 0xF8, 0x0F, 0xFF, 0x00,
- 0x78, 0x8F, 0xEF, 0x01,
- 0x3C, 0x9E, 0xC7, 0x01,
- 0x1C, 0xDE, 0x83, 0x03,
- 0x1C, 0xC0, 0x83, 0x03,
- 0x1E, 0xC0, 0x83, 0x03,
- 0xFE, 0xC3, 0x83, 0x03,
- 0xFE, 0xCF, 0x83, 0x03,
- 0x7E, 0x8F, 0xC3, 0x03,
- 0x3E, 0x9E, 0xE7, 0x03,
- 0x1E, 0x1C, 0xFF, 0x03,
- 0x1E, 0x1C, 0xFE, 0x03,
- 0x1E, 0x1C, 0x80, 0x03,
- 0x1E, 0x1C, 0x80, 0x03,
- 0x1C, 0x9C, 0xC3, 0x03,
- 0x3C, 0x9E, 0xC3, 0x01,
- 0x7C, 0x8F, 0xE7, 0x01,
- 0xF8, 0x0F, 0xFF, 0x00,
- 0xE0, 0x03, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l7.xbm b/app/bin/bitmaps/l7.xbm deleted file mode 100644 index a86a7cc..0000000 --- a/app/bin/bitmaps/l7.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l7_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0xE0, 0x07,
- 0x00, 0x07,
- 0x00, 0x03,
- 0x80, 0x03,
- 0x80, 0x01,
- 0xC0, 0x01,
- 0xC0, 0x01,
- 0xC0, 0x00,
- 0xC0, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l7_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xC0, 0x7F, 0x00,
- 0x00, 0x78, 0x00,
- 0x00, 0x38, 0x00,
- 0x00, 0x1C, 0x00,
- 0x00, 0x1C, 0x00,
- 0x00, 0x0E, 0x00,
- 0x00, 0x0E, 0x00,
- 0x00, 0x0E, 0x00,
- 0x00, 0x07, 0x00,
- 0x00, 0x07, 0x00,
- 0x00, 0x07, 0x00,
- 0x00, 0x07, 0x00,
- 0x00, 0x07, 0x00,
- 0x80, 0x03, 0x00,
- 0x80, 0x03, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l7_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x80, 0xFF, 0x07, 0x00,
- 0x80, 0xFF, 0x07, 0x00,
- 0x00, 0x80, 0x07, 0x00,
- 0x00, 0xC0, 0x03, 0x00,
- 0x00, 0xC0, 0x03, 0x00,
- 0x00, 0xE0, 0x01, 0x00,
- 0x00, 0xE0, 0x01, 0x00,
- 0x00, 0xF0, 0x00, 0x00,
- 0x00, 0xF0, 0x00, 0x00,
- 0x00, 0x70, 0x00, 0x00,
- 0x00, 0x78, 0x00, 0x00,
- 0x00, 0x78, 0x00, 0x00,
- 0x00, 0x38, 0x00, 0x00,
- 0x00, 0x3C, 0x00, 0x00,
- 0x00, 0x3C, 0x00, 0x00,
- 0x00, 0x3C, 0x00, 0x00,
- 0x00, 0x3C, 0x00, 0x00,
- 0x00, 0x1C, 0x00, 0x00,
- 0x00, 0x1C, 0x00, 0x00,
- 0x00, 0x1C, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l70.xbm b/app/bin/bitmaps/l70.xbm deleted file mode 100644 index cfa65e6..0000000 --- a/app/bin/bitmaps/l70.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l70_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0xFC, 0x1E,
- 0xE0, 0x3F,
- 0x60, 0x33,
- 0x70, 0x33,
- 0x30, 0x33,
- 0x38, 0x33,
- 0x38, 0x33,
- 0x18, 0x3F,
- 0x18, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l70_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xFC, 0xE7, 0x03,
- 0x80, 0x77, 0x07,
- 0x80, 0x33, 0x07,
- 0xC0, 0x39, 0x06,
- 0xC0, 0x39, 0x06,
- 0xE0, 0x38, 0x0E,
- 0xE0, 0x38, 0x0E,
- 0xE0, 0x38, 0x0E,
- 0x70, 0x38, 0x0E,
- 0x70, 0x38, 0x0E,
- 0x70, 0x38, 0x06,
- 0x70, 0x38, 0x06,
- 0x70, 0x30, 0x07,
- 0x38, 0x70, 0x07,
- 0x38, 0xE0, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l70_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xFE, 0x1F, 0x7E, 0x00,
- 0xFE, 0x1F, 0xFF, 0x00,
- 0x00, 0x1E, 0xEF, 0x01,
- 0x00, 0x8F, 0xC7, 0x01,
- 0x00, 0x8F, 0xC3, 0x03,
- 0x80, 0x87, 0xC3, 0x03,
- 0x80, 0xC7, 0x83, 0x03,
- 0xC0, 0xC3, 0x83, 0x03,
- 0xC0, 0xC3, 0x83, 0x03,
- 0xC0, 0xC1, 0x83, 0x03,
- 0xE0, 0xC1, 0x83, 0x03,
- 0xE0, 0xC1, 0x83, 0x03,
- 0xE0, 0xC0, 0x83, 0x03,
- 0xF0, 0xC0, 0x83, 0x03,
- 0xF0, 0x80, 0xC3, 0x03,
- 0xF0, 0x80, 0xC3, 0x03,
- 0xF0, 0x80, 0xC7, 0x01,
- 0x70, 0x00, 0xEF, 0x01,
- 0x70, 0x00, 0xFF, 0x00,
- 0x70, 0x00, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l71.xbm b/app/bin/bitmaps/l71.xbm deleted file mode 100644 index eeb2d63..0000000 --- a/app/bin/bitmaps/l71.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l71_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0xFC, 0x1C,
- 0xE0, 0x1E,
- 0x60, 0x1F,
- 0x70, 0x1C,
- 0x30, 0x1C,
- 0x38, 0x1C,
- 0x38, 0x1C,
- 0x18, 0x1C,
- 0x18, 0x1C,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l71_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xFC, 0x87, 0x03,
- 0x80, 0xC7, 0x03,
- 0x80, 0xC3, 0x03,
- 0xC0, 0xE1, 0x03,
- 0xC0, 0xB1, 0x03,
- 0xE0, 0x80, 0x03,
- 0xE0, 0x80, 0x03,
- 0xE0, 0x80, 0x03,
- 0x70, 0x80, 0x03,
- 0x70, 0x80, 0x03,
- 0x70, 0x80, 0x03,
- 0x70, 0x80, 0x03,
- 0x70, 0x80, 0x03,
- 0x38, 0x80, 0x03,
- 0x38, 0x80, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l71_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xFE, 0x1F, 0x70, 0x00,
- 0xFE, 0x1F, 0x70, 0x00,
- 0x00, 0x1E, 0x78, 0x00,
- 0x00, 0x0F, 0x7C, 0x00,
- 0x00, 0x0F, 0x7E, 0x00,
- 0x80, 0x07, 0x7F, 0x00,
- 0x80, 0x07, 0x73, 0x00,
- 0xC0, 0x03, 0x70, 0x00,
- 0xC0, 0x03, 0x70, 0x00,
- 0xC0, 0x01, 0x70, 0x00,
- 0xE0, 0x01, 0x70, 0x00,
- 0xE0, 0x01, 0x70, 0x00,
- 0xE0, 0x00, 0x70, 0x00,
- 0xF0, 0x00, 0x70, 0x00,
- 0xF0, 0x00, 0x70, 0x00,
- 0xF0, 0x00, 0x70, 0x00,
- 0xF0, 0x00, 0x70, 0x00,
- 0x70, 0x00, 0x70, 0x00,
- 0x70, 0x00, 0x70, 0x00,
- 0x70, 0x00, 0x70, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l72.xbm b/app/bin/bitmaps/l72.xbm deleted file mode 100644 index 9ff206f..0000000 --- a/app/bin/bitmaps/l72.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l72_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0xFC, 0x1E,
- 0xE0, 0x3F,
- 0x60, 0x33,
- 0x70, 0x30,
- 0x30, 0x38,
- 0x38, 0x1C,
- 0x38, 0x0E,
- 0x18, 0x07,
- 0x18, 0x3F,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l72_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xFC, 0xE7, 0x03,
- 0x80, 0x77, 0x07,
- 0x80, 0x3B, 0x06,
- 0xC0, 0x39, 0x0E,
- 0xC0, 0x01, 0x0E,
- 0xE0, 0x00, 0x0E,
- 0xE0, 0x00, 0x07,
- 0xE0, 0x80, 0x07,
- 0x70, 0x80, 0x03,
- 0x70, 0xC0, 0x01,
- 0x70, 0xE0, 0x01,
- 0x70, 0xF0, 0x00,
- 0x70, 0x70, 0x00,
- 0x38, 0x78, 0x00,
- 0x38, 0xF8, 0x0F,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l72_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xFE, 0x1F, 0xFE, 0x00,
- 0xFE, 0x1F, 0xFF, 0x01,
- 0x00, 0x9E, 0xE7, 0x03,
- 0x00, 0x8F, 0xC3, 0x03,
- 0x00, 0xCF, 0x83, 0x03,
- 0x80, 0xC7, 0x83, 0x03,
- 0x80, 0x07, 0x80, 0x03,
- 0xC0, 0x03, 0xC0, 0x03,
- 0xC0, 0x03, 0xC0, 0x03,
- 0xC0, 0x01, 0xE0, 0x01,
- 0xE0, 0x01, 0xF0, 0x01,
- 0xE0, 0x01, 0xF8, 0x00,
- 0xE0, 0x00, 0x78, 0x00,
- 0xF0, 0x00, 0x3C, 0x00,
- 0xF0, 0x00, 0x1E, 0x00,
- 0xF0, 0x00, 0x0F, 0x00,
- 0xF0, 0x80, 0x07, 0x00,
- 0x70, 0x80, 0x07, 0x00,
- 0x70, 0xC0, 0xFF, 0x03,
- 0x70, 0xC0, 0xFF, 0x03,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l73.xbm b/app/bin/bitmaps/l73.xbm deleted file mode 100644 index 64dfbb4..0000000 --- a/app/bin/bitmaps/l73.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l73_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0xFC, 0x1E,
- 0xE0, 0x3B,
- 0x60, 0x38,
- 0x70, 0x18,
- 0x30, 0x3C,
- 0x38, 0x38,
- 0x38, 0x33,
- 0x18, 0x3F,
- 0x18, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l73_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xFC, 0xE7, 0x03,
- 0x80, 0x77, 0x07,
- 0x80, 0x3B, 0x07,
- 0xC0, 0x01, 0x07,
- 0xC0, 0x01, 0x07,
- 0xE0, 0x00, 0x07,
- 0xE0, 0x80, 0x03,
- 0xE0, 0xC0, 0x07,
- 0x70, 0x00, 0x07,
- 0x70, 0x00, 0x0E,
- 0x70, 0x00, 0x0E,
- 0x70, 0x38, 0x0E,
- 0x70, 0x38, 0x07,
- 0x38, 0x70, 0x07,
- 0x38, 0xE0, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l73_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xFE, 0x1F, 0x7E, 0x00,
- 0xFE, 0x1F, 0xFF, 0x00,
- 0x00, 0x9E, 0xE7, 0x01,
- 0x00, 0x8F, 0xC7, 0x01,
- 0x00, 0x8F, 0xC3, 0x03,
- 0x80, 0x07, 0xC0, 0x03,
- 0x80, 0x07, 0xC0, 0x01,
- 0xC0, 0x03, 0xE0, 0x01,
- 0xC0, 0x03, 0xFC, 0x00,
- 0xC0, 0x01, 0xFC, 0x00,
- 0xE0, 0x01, 0xE0, 0x01,
- 0xE0, 0x01, 0xC0, 0x03,
- 0xE0, 0x00, 0x80, 0x03,
- 0xF0, 0x00, 0x80, 0x03,
- 0xF0, 0xC0, 0x83, 0x03,
- 0xF0, 0xC0, 0x83, 0x03,
- 0xF0, 0x80, 0xC7, 0x03,
- 0x70, 0x80, 0xE7, 0x01,
- 0x70, 0x00, 0xFF, 0x01,
- 0x70, 0x00, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l74.xbm b/app/bin/bitmaps/l74.xbm deleted file mode 100644 index c41ea54..0000000 --- a/app/bin/bitmaps/l74.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l74_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0xFC, 0x1C,
- 0xE0, 0x1C,
- 0x60, 0x1E,
- 0x70, 0x1E,
- 0x30, 0x1F,
- 0x38, 0x1B,
- 0xB8, 0x3F,
- 0x18, 0x18,
- 0x18, 0x18,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l74_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xFC, 0x87, 0x03,
- 0x80, 0x87, 0x03,
- 0x80, 0xC3, 0x03,
- 0xC0, 0xC1, 0x03,
- 0xC0, 0xE1, 0x03,
- 0xE0, 0xE0, 0x03,
- 0xE0, 0xF0, 0x03,
- 0xE0, 0xB0, 0x03,
- 0x70, 0xB8, 0x03,
- 0x70, 0x98, 0x03,
- 0x70, 0xFC, 0x0F,
- 0x70, 0x80, 0x03,
- 0x70, 0x80, 0x03,
- 0x38, 0x80, 0x03,
- 0x38, 0x80, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l74_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xFE, 0x1F, 0xF0, 0x00,
- 0xFE, 0x1F, 0xF0, 0x00,
- 0x00, 0x1E, 0xF8, 0x00,
- 0x00, 0x0F, 0xF8, 0x00,
- 0x00, 0x0F, 0xFC, 0x00,
- 0x80, 0x07, 0xFC, 0x00,
- 0x80, 0x07, 0xFE, 0x00,
- 0xC0, 0x03, 0xEE, 0x00,
- 0xC0, 0x03, 0xEF, 0x00,
- 0xC0, 0x81, 0xE7, 0x00,
- 0xE0, 0x81, 0xE7, 0x00,
- 0xE0, 0xC1, 0xE3, 0x00,
- 0xE0, 0xC0, 0xE1, 0x00,
- 0xF0, 0xE0, 0xFF, 0x03,
- 0xF0, 0xE0, 0xFF, 0x03,
- 0xF0, 0x00, 0xE0, 0x00,
- 0xF0, 0x00, 0xE0, 0x00,
- 0x70, 0x00, 0xE0, 0x00,
- 0x70, 0x00, 0xE0, 0x00,
- 0x70, 0x00, 0xE0, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l75.xbm b/app/bin/bitmaps/l75.xbm deleted file mode 100644 index 58a6c52..0000000 --- a/app/bin/bitmaps/l75.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l75_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0xFC, 0x3F,
- 0xE0, 0x07,
- 0x60, 0x07,
- 0x70, 0x1F,
- 0x30, 0x3B,
- 0x38, 0x30,
- 0x38, 0x33,
- 0x18, 0x3F,
- 0x18, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l75_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xFC, 0xF7, 0x07,
- 0x80, 0x77, 0x00,
- 0x80, 0x73, 0x00,
- 0xC0, 0x31, 0x00,
- 0xC0, 0x31, 0x00,
- 0xE0, 0xF8, 0x03,
- 0xE0, 0x78, 0x07,
- 0xE0, 0x38, 0x07,
- 0x70, 0x00, 0x0E,
- 0x70, 0x00, 0x0E,
- 0x70, 0x00, 0x0E,
- 0x70, 0x38, 0x06,
- 0x70, 0x38, 0x07,
- 0x38, 0x70, 0x07,
- 0x38, 0xE0, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l75_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xFE, 0x1F, 0xFF, 0x03,
- 0xFE, 0x1F, 0xFF, 0x03,
- 0x00, 0x1E, 0x07, 0x00,
- 0x00, 0x0F, 0x07, 0x00,
- 0x00, 0x8F, 0x07, 0x00,
- 0x80, 0x87, 0x07, 0x00,
- 0x80, 0x87, 0x7F, 0x00,
- 0xC0, 0x83, 0xFF, 0x01,
- 0xC0, 0x83, 0xE7, 0x01,
- 0xC0, 0x81, 0xC3, 0x03,
- 0xE0, 0x01, 0xC0, 0x03,
- 0xE0, 0x01, 0x80, 0x03,
- 0xE0, 0x00, 0x80, 0x03,
- 0xF0, 0x00, 0x80, 0x03,
- 0xF0, 0xC0, 0x83, 0x03,
- 0xF0, 0xC0, 0xC3, 0x03,
- 0xF0, 0x80, 0xC3, 0x03,
- 0x70, 0x80, 0xE7, 0x01,
- 0x70, 0x00, 0xFF, 0x00,
- 0x70, 0x00, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l76.xbm b/app/bin/bitmaps/l76.xbm deleted file mode 100644 index 9b385dc..0000000 --- a/app/bin/bitmaps/l76.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l76_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0xFC, 0x1E,
- 0xE0, 0x3F,
- 0x60, 0x03,
- 0x70, 0x1F,
- 0x30, 0x3F,
- 0x38, 0x33,
- 0x38, 0x33,
- 0x18, 0x3F,
- 0x18, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l76_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xFC, 0xE7, 0x03,
- 0x80, 0x77, 0x07,
- 0x80, 0x33, 0x07,
- 0xC0, 0x39, 0x00,
- 0xC0, 0x39, 0x00,
- 0xE0, 0x38, 0x00,
- 0xE0, 0xF8, 0x03,
- 0xE0, 0x78, 0x07,
- 0x70, 0x38, 0x07,
- 0x70, 0x38, 0x0E,
- 0x70, 0x38, 0x0E,
- 0x70, 0x38, 0x0E,
- 0x70, 0x30, 0x07,
- 0x38, 0x70, 0x07,
- 0x38, 0xE0, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l76_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xFE, 0x1F, 0xFC, 0x00,
- 0xFE, 0x1F, 0xFF, 0x01,
- 0x00, 0x1E, 0xEF, 0x01,
- 0x00, 0x8F, 0xC7, 0x03,
- 0x00, 0x8F, 0xC3, 0x03,
- 0x80, 0x87, 0x03, 0x00,
- 0x80, 0xC7, 0x03, 0x00,
- 0xC0, 0xC3, 0x7F, 0x00,
- 0xC0, 0xC3, 0xFF, 0x01,
- 0xC0, 0xC1, 0xEF, 0x01,
- 0xE0, 0xC1, 0xC7, 0x03,
- 0xE0, 0xC1, 0x83, 0x03,
- 0xE0, 0xC0, 0x83, 0x03,
- 0xF0, 0xC0, 0x83, 0x03,
- 0xF0, 0xC0, 0x83, 0x03,
- 0xF0, 0x80, 0x83, 0x03,
- 0xF0, 0x80, 0xC7, 0x03,
- 0x70, 0x80, 0xEF, 0x01,
- 0x70, 0x00, 0xFF, 0x01,
- 0x70, 0x00, 0x7C, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l77.xbm b/app/bin/bitmaps/l77.xbm deleted file mode 100644 index c406f2d..0000000 --- a/app/bin/bitmaps/l77.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l77_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0xFC, 0x3F,
- 0xE0, 0x38,
- 0x60, 0x18,
- 0x70, 0x1C,
- 0x30, 0x0C,
- 0x38, 0x0E,
- 0x38, 0x0E,
- 0x18, 0x06,
- 0x18, 0x06,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l77_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xFC, 0xFF, 0x0F,
- 0x80, 0x07, 0x0F,
- 0x80, 0x03, 0x07,
- 0xC0, 0x81, 0x03,
- 0xC0, 0x81, 0x03,
- 0xE0, 0xC0, 0x01,
- 0xE0, 0xC0, 0x01,
- 0xE0, 0xC0, 0x01,
- 0x70, 0xE0, 0x00,
- 0x70, 0xE0, 0x00,
- 0x70, 0xE0, 0x00,
- 0x70, 0xE0, 0x00,
- 0x70, 0xE0, 0x00,
- 0x38, 0x70, 0x00,
- 0x38, 0x70, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l77_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xFE, 0xDF, 0xFF, 0x03,
- 0xFE, 0xDF, 0xFF, 0x03,
- 0x00, 0x1E, 0xC0, 0x03,
- 0x00, 0x0F, 0xE0, 0x01,
- 0x00, 0x0F, 0xE0, 0x01,
- 0x80, 0x07, 0xF0, 0x00,
- 0x80, 0x07, 0xF0, 0x00,
- 0xC0, 0x03, 0x78, 0x00,
- 0xC0, 0x03, 0x78, 0x00,
- 0xC0, 0x01, 0x38, 0x00,
- 0xE0, 0x01, 0x3C, 0x00,
- 0xE0, 0x01, 0x3C, 0x00,
- 0xE0, 0x00, 0x1C, 0x00,
- 0xF0, 0x00, 0x1E, 0x00,
- 0xF0, 0x00, 0x1E, 0x00,
- 0xF0, 0x00, 0x1E, 0x00,
- 0xF0, 0x00, 0x1E, 0x00,
- 0x70, 0x00, 0x0E, 0x00,
- 0x70, 0x00, 0x0E, 0x00,
- 0x70, 0x00, 0x0E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l78.xbm b/app/bin/bitmaps/l78.xbm deleted file mode 100644 index 0674918..0000000 --- a/app/bin/bitmaps/l78.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l78_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0xFC, 0x1E,
- 0xE0, 0x3F,
- 0x60, 0x3B,
- 0x70, 0x3F,
- 0x30, 0x1E,
- 0x38, 0x3F,
- 0x38, 0x33,
- 0x18, 0x3F,
- 0x18, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l78_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xFC, 0xE7, 0x03,
- 0x80, 0x77, 0x07,
- 0x80, 0x33, 0x07,
- 0xC0, 0x39, 0x07,
- 0xC0, 0x39, 0x07,
- 0xE0, 0x38, 0x07,
- 0xE0, 0x70, 0x07,
- 0xE0, 0xE0, 0x03,
- 0x70, 0x70, 0x07,
- 0x70, 0x38, 0x06,
- 0x70, 0x38, 0x0E,
- 0x70, 0x38, 0x0E,
- 0x70, 0x38, 0x06,
- 0x38, 0x70, 0x07,
- 0x38, 0xE0, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l78_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xFE, 0x1F, 0x7E, 0x00,
- 0xFE, 0x1F, 0xFF, 0x00,
- 0x00, 0x9E, 0xEF, 0x01,
- 0x00, 0x8F, 0xC7, 0x01,
- 0x00, 0x8F, 0xC3, 0x03,
- 0x80, 0x87, 0xC3, 0x03,
- 0x80, 0x87, 0xC7, 0x01,
- 0xC0, 0x03, 0xEF, 0x01,
- 0xC0, 0x03, 0xFE, 0x00,
- 0xC0, 0x01, 0xFF, 0x00,
- 0xE0, 0x81, 0xE7, 0x01,
- 0xE0, 0x81, 0xC3, 0x03,
- 0xE0, 0xC0, 0x83, 0x03,
- 0xF0, 0xC0, 0x83, 0x03,
- 0xF0, 0xC0, 0x83, 0x03,
- 0xF0, 0xC0, 0x83, 0x03,
- 0xF0, 0x80, 0xC3, 0x03,
- 0x70, 0x80, 0xE7, 0x01,
- 0x70, 0x00, 0xFF, 0x01,
- 0x70, 0x00, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l79.xbm b/app/bin/bitmaps/l79.xbm deleted file mode 100644 index c1d909b..0000000 --- a/app/bin/bitmaps/l79.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l79_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0xFC, 0x1E,
- 0xE0, 0x3F,
- 0x60, 0x33,
- 0x70, 0x33,
- 0x30, 0x3F,
- 0x38, 0x3E,
- 0x38, 0x30,
- 0x18, 0x3B,
- 0x18, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l79_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xFC, 0xE7, 0x01,
- 0x80, 0x77, 0x07,
- 0x80, 0x3B, 0x07,
- 0xC0, 0x39, 0x06,
- 0xC0, 0x39, 0x0E,
- 0xE0, 0x38, 0x0E,
- 0xE0, 0x38, 0x0F,
- 0xE0, 0x70, 0x0F,
- 0x70, 0xE0, 0x0F,
- 0x70, 0x00, 0x0E,
- 0x70, 0x00, 0x06,
- 0x70, 0x00, 0x06,
- 0x70, 0x38, 0x07,
- 0x38, 0x70, 0x03,
- 0x38, 0xF0, 0x01,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l79_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xFE, 0x1F, 0x7E, 0x00,
- 0xFE, 0x1F, 0xFF, 0x00,
- 0x00, 0x9E, 0xEF, 0x01,
- 0x00, 0x8F, 0xC7, 0x01,
- 0x00, 0xCF, 0x83, 0x03,
- 0x80, 0xC7, 0x83, 0x03,
- 0x80, 0xC7, 0x83, 0x03,
- 0xC0, 0xC3, 0x83, 0x03,
- 0xC0, 0xC3, 0x83, 0x03,
- 0xC0, 0x81, 0xC3, 0x03,
- 0xE0, 0x81, 0xE7, 0x03,
- 0xE0, 0x01, 0xFF, 0x03,
- 0xE0, 0x00, 0xFE, 0x03,
- 0xF0, 0x00, 0x80, 0x03,
- 0xF0, 0x00, 0x80, 0x03,
- 0xF0, 0x80, 0xC3, 0x03,
- 0xF0, 0x80, 0xC3, 0x01,
- 0x70, 0x80, 0xE7, 0x01,
- 0x70, 0x00, 0xFF, 0x00,
- 0x70, 0x00, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l8.xbm b/app/bin/bitmaps/l8.xbm deleted file mode 100644 index 1054bfd..0000000 --- a/app/bin/bitmaps/l8.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l8_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0xC0, 0x03,
- 0xE0, 0x07,
- 0x60, 0x07,
- 0xE0, 0x07,
- 0xC0, 0x03,
- 0xE0, 0x07,
- 0x60, 0x06,
- 0xE0, 0x07,
- 0xC0, 0x03,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l8_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x1F, 0x00,
- 0x80, 0x3B, 0x00,
- 0x80, 0x39, 0x00,
- 0xC0, 0x39, 0x00,
- 0xC0, 0x39, 0x00,
- 0xC0, 0x39, 0x00,
- 0x80, 0x3B, 0x00,
- 0x00, 0x1F, 0x00,
- 0x80, 0x3B, 0x00,
- 0xC0, 0x31, 0x00,
- 0xC0, 0x71, 0x00,
- 0xC0, 0x71, 0x00,
- 0xC0, 0x31, 0x00,
- 0x80, 0x3B, 0x00,
- 0x00, 0x1F, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l8_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xFC, 0x00, 0x00,
- 0x00, 0xFE, 0x01, 0x00,
- 0x00, 0xDF, 0x03, 0x00,
- 0x00, 0x8F, 0x03, 0x00,
- 0x00, 0x87, 0x07, 0x00,
- 0x00, 0x87, 0x07, 0x00,
- 0x00, 0x8F, 0x03, 0x00,
- 0x00, 0xDE, 0x03, 0x00,
- 0x00, 0xFC, 0x01, 0x00,
- 0x00, 0xFE, 0x01, 0x00,
- 0x00, 0xCF, 0x03, 0x00,
- 0x00, 0x87, 0x07, 0x00,
- 0x80, 0x07, 0x07, 0x00,
- 0x80, 0x07, 0x07, 0x00,
- 0x80, 0x07, 0x07, 0x00,
- 0x80, 0x07, 0x07, 0x00,
- 0x00, 0x87, 0x07, 0x00,
- 0x00, 0xCF, 0x03, 0x00,
- 0x00, 0xFE, 0x03, 0x00,
- 0x00, 0xFC, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l80.xbm b/app/bin/bitmaps/l80.xbm deleted file mode 100644 index 8dc12d0..0000000 --- a/app/bin/bitmaps/l80.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l80_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1E,
- 0xFC, 0x3F,
- 0xEC, 0x33,
- 0xFC, 0x33,
- 0x78, 0x33,
- 0xFC, 0x33,
- 0xCC, 0x33,
- 0xFC, 0x3F,
- 0x78, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l80_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xE1, 0x03,
- 0xB8, 0x73, 0x07,
- 0x98, 0x33, 0x07,
- 0x9C, 0x3B, 0x06,
- 0x9C, 0x3B, 0x06,
- 0x9C, 0x3B, 0x0E,
- 0xB8, 0x3B, 0x0E,
- 0xF0, 0x39, 0x0E,
- 0xB8, 0x3B, 0x0E,
- 0x1C, 0x3B, 0x0E,
- 0x1C, 0x3F, 0x06,
- 0x1C, 0x3F, 0x06,
- 0x1C, 0x33, 0x07,
- 0xB8, 0x73, 0x07,
- 0xF0, 0xE1, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l80_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x03, 0x7E, 0x00,
- 0xF8, 0x07, 0xFF, 0x00,
- 0x7C, 0x0F, 0xEF, 0x01,
- 0x3C, 0x8E, 0xC7, 0x01,
- 0x1C, 0x9E, 0xC3, 0x03,
- 0x1C, 0x9E, 0xC3, 0x03,
- 0x3C, 0xCE, 0x83, 0x03,
- 0x78, 0xCF, 0x83, 0x03,
- 0xF0, 0xC7, 0x83, 0x03,
- 0xF8, 0xC7, 0x83, 0x03,
- 0x3C, 0xCF, 0x83, 0x03,
- 0x1C, 0xDE, 0x83, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0x9C, 0xC3, 0x03,
- 0x1E, 0x9C, 0xC3, 0x03,
- 0x1C, 0x9E, 0xC7, 0x01,
- 0x3C, 0x0F, 0xEF, 0x01,
- 0xF8, 0x0F, 0xFF, 0x00,
- 0xF0, 0x03, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l81.xbm b/app/bin/bitmaps/l81.xbm deleted file mode 100644 index 118901b..0000000 --- a/app/bin/bitmaps/l81.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l81_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1C,
- 0xFC, 0x1E,
- 0xEC, 0x1F,
- 0xFC, 0x1C,
- 0x78, 0x1C,
- 0xFC, 0x1C,
- 0xCC, 0x1C,
- 0xFC, 0x1C,
- 0x78, 0x1C,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l81_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0x81, 0x03,
- 0xB8, 0xC3, 0x03,
- 0x98, 0xC3, 0x03,
- 0x9C, 0xE3, 0x03,
- 0x9C, 0xB3, 0x03,
- 0x9C, 0x83, 0x03,
- 0xB8, 0x83, 0x03,
- 0xF0, 0x81, 0x03,
- 0xB8, 0x83, 0x03,
- 0x1C, 0x83, 0x03,
- 0x1C, 0x87, 0x03,
- 0x1C, 0x87, 0x03,
- 0x1C, 0x83, 0x03,
- 0xB8, 0x83, 0x03,
- 0xF0, 0x81, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l81_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x03, 0x70, 0x00,
- 0xF8, 0x07, 0x70, 0x00,
- 0x7C, 0x0F, 0x78, 0x00,
- 0x3C, 0x0E, 0x7C, 0x00,
- 0x1C, 0x1E, 0x7E, 0x00,
- 0x1C, 0x1E, 0x7F, 0x00,
- 0x3C, 0x0E, 0x73, 0x00,
- 0x78, 0x0F, 0x70, 0x00,
- 0xF0, 0x07, 0x70, 0x00,
- 0xF8, 0x07, 0x70, 0x00,
- 0x3C, 0x0F, 0x70, 0x00,
- 0x1C, 0x1E, 0x70, 0x00,
- 0x1E, 0x1C, 0x70, 0x00,
- 0x1E, 0x1C, 0x70, 0x00,
- 0x1E, 0x1C, 0x70, 0x00,
- 0x1E, 0x1C, 0x70, 0x00,
- 0x1C, 0x1E, 0x70, 0x00,
- 0x3C, 0x0F, 0x70, 0x00,
- 0xF8, 0x0F, 0x70, 0x00,
- 0xF0, 0x03, 0x70, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l82.xbm b/app/bin/bitmaps/l82.xbm deleted file mode 100644 index 74edb5d..0000000 --- a/app/bin/bitmaps/l82.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l82_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1E,
- 0xFC, 0x3F,
- 0xEC, 0x33,
- 0xFC, 0x30,
- 0x78, 0x38,
- 0xFC, 0x1C,
- 0xCC, 0x0E,
- 0xFC, 0x07,
- 0x78, 0x3F,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l82_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xE1, 0x03,
- 0xB8, 0x73, 0x07,
- 0x98, 0x3B, 0x06,
- 0x9C, 0x3B, 0x0E,
- 0x9C, 0x03, 0x0E,
- 0x9C, 0x03, 0x0E,
- 0xB8, 0x03, 0x07,
- 0xF0, 0x81, 0x07,
- 0xB8, 0x83, 0x03,
- 0x1C, 0xC3, 0x01,
- 0x1C, 0xE7, 0x01,
- 0x1C, 0xF7, 0x00,
- 0x1C, 0x73, 0x00,
- 0xB8, 0x7B, 0x00,
- 0xF0, 0xF9, 0x0F,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l82_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x03, 0xFE, 0x00,
- 0xF8, 0x07, 0xFF, 0x01,
- 0x7C, 0x8F, 0xE7, 0x03,
- 0x3C, 0x8E, 0xC3, 0x03,
- 0x1C, 0xDE, 0x83, 0x03,
- 0x1C, 0xDE, 0x83, 0x03,
- 0x3C, 0x0E, 0x80, 0x03,
- 0x78, 0x0F, 0xC0, 0x03,
- 0xF0, 0x07, 0xC0, 0x03,
- 0xF8, 0x07, 0xE0, 0x01,
- 0x3C, 0x0F, 0xF0, 0x01,
- 0x1C, 0x1E, 0xF8, 0x00,
- 0x1E, 0x1C, 0x78, 0x00,
- 0x1E, 0x1C, 0x3C, 0x00,
- 0x1E, 0x1C, 0x1E, 0x00,
- 0x1E, 0x1C, 0x0F, 0x00,
- 0x1C, 0x9E, 0x07, 0x00,
- 0x3C, 0x8F, 0x07, 0x00,
- 0xF8, 0xCF, 0xFF, 0x03,
- 0xF0, 0xC3, 0xFF, 0x03,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l83.xbm b/app/bin/bitmaps/l83.xbm deleted file mode 100644 index 3f7a1a0..0000000 --- a/app/bin/bitmaps/l83.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l83_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1E,
- 0xFC, 0x3B,
- 0xEC, 0x38,
- 0xFC, 0x18,
- 0x78, 0x3C,
- 0xFC, 0x38,
- 0xCC, 0x33,
- 0xFC, 0x3F,
- 0x78, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l83_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xE1, 0x03,
- 0xB8, 0x73, 0x07,
- 0x98, 0x3B, 0x07,
- 0x9C, 0x03, 0x07,
- 0x9C, 0x03, 0x07,
- 0x9C, 0x03, 0x07,
- 0xB8, 0x83, 0x03,
- 0xF0, 0xC1, 0x07,
- 0xB8, 0x03, 0x07,
- 0x1C, 0x03, 0x0E,
- 0x1C, 0x07, 0x0E,
- 0x1C, 0x3F, 0x0E,
- 0x1C, 0x3B, 0x07,
- 0xB8, 0x73, 0x07,
- 0xF0, 0xE1, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l83_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x03, 0x7E, 0x00,
- 0xF8, 0x07, 0xFF, 0x00,
- 0x7C, 0x8F, 0xE7, 0x01,
- 0x3C, 0x8E, 0xC7, 0x01,
- 0x1C, 0x9E, 0xC3, 0x03,
- 0x1C, 0x1E, 0xC0, 0x03,
- 0x3C, 0x0E, 0xC0, 0x01,
- 0x78, 0x0F, 0xE0, 0x01,
- 0xF0, 0x07, 0xFC, 0x00,
- 0xF8, 0x07, 0xFC, 0x00,
- 0x3C, 0x0F, 0xE0, 0x01,
- 0x1C, 0x1E, 0xC0, 0x03,
- 0x1E, 0x1C, 0x80, 0x03,
- 0x1E, 0x1C, 0x80, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1C, 0x9E, 0xC7, 0x03,
- 0x3C, 0x8F, 0xE7, 0x01,
- 0xF8, 0x0F, 0xFF, 0x01,
- 0xF0, 0x03, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l84.xbm b/app/bin/bitmaps/l84.xbm deleted file mode 100644 index 0cce4be..0000000 --- a/app/bin/bitmaps/l84.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l84_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1C,
- 0xFC, 0x1C,
- 0xEC, 0x1E,
- 0xFC, 0x1E,
- 0x78, 0x1F,
- 0xFC, 0x1B,
- 0xCC, 0x3F,
- 0xFC, 0x18,
- 0x78, 0x18,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l84_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0x81, 0x03,
- 0xB8, 0x83, 0x03,
- 0x98, 0xC3, 0x03,
- 0x9C, 0xC3, 0x03,
- 0x9C, 0xE3, 0x03,
- 0x9C, 0xE3, 0x03,
- 0xB8, 0xF3, 0x03,
- 0xF0, 0xB1, 0x03,
- 0xB8, 0xBB, 0x03,
- 0x1C, 0x9B, 0x03,
- 0x1C, 0xFF, 0x0F,
- 0x1C, 0x87, 0x03,
- 0x1C, 0x83, 0x03,
- 0xB8, 0x83, 0x03,
- 0xF0, 0x81, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l84_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x03, 0xF0, 0x00,
- 0xF8, 0x07, 0xF0, 0x00,
- 0x7C, 0x0F, 0xF8, 0x00,
- 0x3C, 0x0E, 0xF8, 0x00,
- 0x1C, 0x1E, 0xFC, 0x00,
- 0x1C, 0x1E, 0xFC, 0x00,
- 0x3C, 0x0E, 0xFE, 0x00,
- 0x78, 0x0F, 0xEE, 0x00,
- 0xF0, 0x07, 0xEF, 0x00,
- 0xF8, 0x87, 0xE7, 0x00,
- 0x3C, 0x8F, 0xE7, 0x00,
- 0x1C, 0xDE, 0xE3, 0x00,
- 0x1E, 0xDC, 0xE1, 0x00,
- 0x1E, 0xFC, 0xFF, 0x03,
- 0x1E, 0xFC, 0xFF, 0x03,
- 0x1E, 0x1C, 0xE0, 0x00,
- 0x1C, 0x1E, 0xE0, 0x00,
- 0x3C, 0x0F, 0xE0, 0x00,
- 0xF8, 0x0F, 0xE0, 0x00,
- 0xF0, 0x03, 0xE0, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l85.xbm b/app/bin/bitmaps/l85.xbm deleted file mode 100644 index 420ea67..0000000 --- a/app/bin/bitmaps/l85.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l85_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x3F,
- 0xFC, 0x07,
- 0xEC, 0x07,
- 0xFC, 0x1F,
- 0x78, 0x3B,
- 0xFC, 0x30,
- 0xCC, 0x33,
- 0xFC, 0x3F,
- 0x78, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l85_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xF1, 0x07,
- 0xB8, 0x73, 0x00,
- 0x98, 0x73, 0x00,
- 0x9C, 0x33, 0x00,
- 0x9C, 0x33, 0x00,
- 0x9C, 0xFB, 0x03,
- 0xB8, 0x7B, 0x07,
- 0xF0, 0x39, 0x07,
- 0xB8, 0x03, 0x0E,
- 0x1C, 0x03, 0x0E,
- 0x1C, 0x07, 0x0E,
- 0x1C, 0x3F, 0x06,
- 0x1C, 0x3B, 0x07,
- 0xB8, 0x73, 0x07,
- 0xF0, 0xE1, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l85_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x03, 0xFF, 0x03,
- 0xF8, 0x07, 0xFF, 0x03,
- 0x7C, 0x0F, 0x07, 0x00,
- 0x3C, 0x0E, 0x07, 0x00,
- 0x1C, 0x9E, 0x07, 0x00,
- 0x1C, 0x9E, 0x07, 0x00,
- 0x3C, 0x8E, 0x7F, 0x00,
- 0x78, 0x8F, 0xFF, 0x01,
- 0xF0, 0x87, 0xE7, 0x01,
- 0xF8, 0x87, 0xC3, 0x03,
- 0x3C, 0x0F, 0xC0, 0x03,
- 0x1C, 0x1E, 0x80, 0x03,
- 0x1E, 0x1C, 0x80, 0x03,
- 0x1E, 0x1C, 0x80, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0xDC, 0xC3, 0x03,
- 0x1C, 0x9E, 0xC3, 0x03,
- 0x3C, 0x8F, 0xE7, 0x01,
- 0xF8, 0x0F, 0xFF, 0x00,
- 0xF0, 0x03, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l86.xbm b/app/bin/bitmaps/l86.xbm deleted file mode 100644 index 31ee6f1..0000000 --- a/app/bin/bitmaps/l86.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l86_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1E,
- 0xFC, 0x3F,
- 0xEC, 0x03,
- 0xFC, 0x1F,
- 0x78, 0x3F,
- 0xFC, 0x33,
- 0xCC, 0x33,
- 0xFC, 0x3F,
- 0x78, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l86_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xE1, 0x03,
- 0xB8, 0x73, 0x07,
- 0x98, 0x33, 0x07,
- 0x9C, 0x3B, 0x00,
- 0x9C, 0x3B, 0x00,
- 0x9C, 0x3B, 0x00,
- 0xB8, 0xFB, 0x03,
- 0xF0, 0x79, 0x07,
- 0xB8, 0x3B, 0x07,
- 0x1C, 0x3B, 0x0E,
- 0x1C, 0x3F, 0x0E,
- 0x1C, 0x3F, 0x0E,
- 0x1C, 0x33, 0x07,
- 0xB8, 0x73, 0x07,
- 0xF0, 0xE1, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l86_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x03, 0xFC, 0x00,
- 0xF8, 0x07, 0xFF, 0x01,
- 0x7C, 0x0F, 0xEF, 0x01,
- 0x3C, 0x8E, 0xC7, 0x03,
- 0x1C, 0x9E, 0xC3, 0x03,
- 0x1C, 0x9E, 0x03, 0x00,
- 0x3C, 0xCE, 0x03, 0x00,
- 0x78, 0xCF, 0x7F, 0x00,
- 0xF0, 0xC7, 0xFF, 0x01,
- 0xF8, 0xC7, 0xEF, 0x01,
- 0x3C, 0xCF, 0xC7, 0x03,
- 0x1C, 0xDE, 0x83, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0x9C, 0x83, 0x03,
- 0x1C, 0x9E, 0xC7, 0x03,
- 0x3C, 0x8F, 0xEF, 0x01,
- 0xF8, 0x0F, 0xFF, 0x01,
- 0xF0, 0x03, 0x7C, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l87.xbm b/app/bin/bitmaps/l87.xbm deleted file mode 100644 index dcd52b5..0000000 --- a/app/bin/bitmaps/l87.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l87_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x3F,
- 0xFC, 0x38,
- 0xEC, 0x18,
- 0xFC, 0x1C,
- 0x78, 0x0C,
- 0xFC, 0x0E,
- 0xCC, 0x0E,
- 0xFC, 0x06,
- 0x78, 0x06,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l87_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xF9, 0x0F,
- 0xB8, 0x03, 0x0F,
- 0x98, 0x03, 0x07,
- 0x9C, 0x83, 0x03,
- 0x9C, 0x83, 0x03,
- 0x9C, 0xC3, 0x01,
- 0xB8, 0xC3, 0x01,
- 0xF0, 0xC1, 0x01,
- 0xB8, 0xE3, 0x00,
- 0x1C, 0xE3, 0x00,
- 0x1C, 0xE7, 0x00,
- 0x1C, 0xE7, 0x00,
- 0x1C, 0xE3, 0x00,
- 0xB8, 0x73, 0x00,
- 0xF0, 0x71, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l87_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0xC3, 0xFF, 0x03,
- 0xF8, 0xC7, 0xFF, 0x03,
- 0x7C, 0x0F, 0xC0, 0x03,
- 0x3C, 0x0E, 0xE0, 0x01,
- 0x1C, 0x1E, 0xE0, 0x01,
- 0x1C, 0x1E, 0xF0, 0x00,
- 0x3C, 0x0E, 0xF0, 0x00,
- 0x78, 0x0F, 0x78, 0x00,
- 0xF0, 0x07, 0x78, 0x00,
- 0xF8, 0x07, 0x38, 0x00,
- 0x3C, 0x0F, 0x3C, 0x00,
- 0x1C, 0x1E, 0x3C, 0x00,
- 0x1E, 0x1C, 0x1C, 0x00,
- 0x1E, 0x1C, 0x1E, 0x00,
- 0x1E, 0x1C, 0x1E, 0x00,
- 0x1E, 0x1C, 0x1E, 0x00,
- 0x1C, 0x1E, 0x1E, 0x00,
- 0x3C, 0x0F, 0x0E, 0x00,
- 0xF8, 0x0F, 0x0E, 0x00,
- 0xF0, 0x03, 0x0E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l88.xbm b/app/bin/bitmaps/l88.xbm deleted file mode 100644 index 4d06b28..0000000 --- a/app/bin/bitmaps/l88.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l88_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1E,
- 0xFC, 0x3F,
- 0xEC, 0x3B,
- 0xFC, 0x3F,
- 0x78, 0x1E,
- 0xFC, 0x3F,
- 0xCC, 0x33,
- 0xFC, 0x3F,
- 0x78, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l88_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xE1, 0x03,
- 0xB8, 0x73, 0x07,
- 0x98, 0x33, 0x07,
- 0x9C, 0x3B, 0x07,
- 0x9C, 0x3B, 0x07,
- 0x9C, 0x3B, 0x07,
- 0xB8, 0x73, 0x07,
- 0xF0, 0xE1, 0x03,
- 0xB8, 0x73, 0x07,
- 0x1C, 0x3B, 0x06,
- 0x1C, 0x3F, 0x0E,
- 0x1C, 0x3F, 0x0E,
- 0x1C, 0x3B, 0x06,
- 0xB8, 0x73, 0x07,
- 0xF0, 0xE1, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l88_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x03, 0x7E, 0x00,
- 0xF8, 0x07, 0xFF, 0x00,
- 0x7C, 0x8F, 0xEF, 0x01,
- 0x3C, 0x8E, 0xC7, 0x01,
- 0x1C, 0x9E, 0xC3, 0x03,
- 0x1C, 0x9E, 0xC3, 0x03,
- 0x3C, 0x8E, 0xC7, 0x01,
- 0x78, 0x0F, 0xEF, 0x01,
- 0xF0, 0x07, 0xFE, 0x00,
- 0xF8, 0x07, 0xFF, 0x00,
- 0x3C, 0x8F, 0xE7, 0x01,
- 0x1C, 0x9E, 0xC3, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1C, 0x9E, 0xC3, 0x03,
- 0x3C, 0x8F, 0xE7, 0x01,
- 0xF8, 0x0F, 0xFF, 0x01,
- 0xF0, 0x03, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l89.xbm b/app/bin/bitmaps/l89.xbm deleted file mode 100644 index 74b1448..0000000 --- a/app/bin/bitmaps/l89.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l89_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1E,
- 0xFC, 0x3F,
- 0xEC, 0x33,
- 0xFC, 0x33,
- 0x78, 0x3F,
- 0xFC, 0x3E,
- 0xCC, 0x30,
- 0xFC, 0x3B,
- 0x78, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l89_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xE1, 0x01,
- 0xB8, 0x73, 0x07,
- 0x98, 0x3B, 0x07,
- 0x9C, 0x3B, 0x06,
- 0x9C, 0x3B, 0x0E,
- 0x9C, 0x3B, 0x0E,
- 0xB8, 0x3B, 0x0F,
- 0xF0, 0x71, 0x0F,
- 0xB8, 0xE3, 0x0F,
- 0x1C, 0x03, 0x0E,
- 0x1C, 0x07, 0x06,
- 0x1C, 0x07, 0x06,
- 0x1C, 0x3B, 0x07,
- 0xB8, 0x73, 0x03,
- 0xF0, 0xF1, 0x01,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l89_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x03, 0x7E, 0x00,
- 0xF8, 0x07, 0xFF, 0x00,
- 0x7C, 0x8F, 0xEF, 0x01,
- 0x3C, 0x8E, 0xC7, 0x01,
- 0x1C, 0xDE, 0x83, 0x03,
- 0x1C, 0xDE, 0x83, 0x03,
- 0x3C, 0xCE, 0x83, 0x03,
- 0x78, 0xCF, 0x83, 0x03,
- 0xF0, 0xC7, 0x83, 0x03,
- 0xF8, 0x87, 0xC3, 0x03,
- 0x3C, 0x8F, 0xE7, 0x03,
- 0x1C, 0x1E, 0xFF, 0x03,
- 0x1E, 0x1C, 0xFE, 0x03,
- 0x1E, 0x1C, 0x80, 0x03,
- 0x1E, 0x1C, 0x80, 0x03,
- 0x1E, 0x9C, 0xC3, 0x03,
- 0x1C, 0x9E, 0xC3, 0x01,
- 0x3C, 0x8F, 0xE7, 0x01,
- 0xF8, 0x0F, 0xFF, 0x00,
- 0xF0, 0x03, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l9.xbm b/app/bin/bitmaps/l9.xbm deleted file mode 100644 index 281474c..0000000 --- a/app/bin/bitmaps/l9.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l9_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0xC0, 0x03,
- 0xE0, 0x07,
- 0x60, 0x06,
- 0x60, 0x06,
- 0xE0, 0x07,
- 0xC0, 0x07,
- 0x00, 0x06,
- 0x60, 0x07,
- 0xC0, 0x03,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l9_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x0F, 0x00,
- 0x80, 0x3B, 0x00,
- 0xC0, 0x39, 0x00,
- 0xC0, 0x31, 0x00,
- 0xC0, 0x71, 0x00,
- 0xC0, 0x71, 0x00,
- 0xC0, 0x79, 0x00,
- 0x80, 0x7B, 0x00,
- 0x00, 0x7F, 0x00,
- 0x00, 0x70, 0x00,
- 0x00, 0x30, 0x00,
- 0x00, 0x30, 0x00,
- 0xC0, 0x39, 0x00,
- 0x80, 0x1B, 0x00,
- 0x80, 0x0F, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l9_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xFC, 0x00, 0x00,
- 0x00, 0xFE, 0x01, 0x00,
- 0x00, 0xDF, 0x03, 0x00,
- 0x00, 0x8F, 0x03, 0x00,
- 0x80, 0x07, 0x07, 0x00,
- 0x80, 0x07, 0x07, 0x00,
- 0x80, 0x07, 0x07, 0x00,
- 0x80, 0x07, 0x07, 0x00,
- 0x80, 0x07, 0x07, 0x00,
- 0x00, 0x87, 0x07, 0x00,
- 0x00, 0xCF, 0x07, 0x00,
- 0x00, 0xFE, 0x07, 0x00,
- 0x00, 0xFC, 0x07, 0x00,
- 0x00, 0x00, 0x07, 0x00,
- 0x00, 0x00, 0x07, 0x00,
- 0x00, 0x87, 0x07, 0x00,
- 0x00, 0x87, 0x03, 0x00,
- 0x00, 0xCF, 0x03, 0x00,
- 0x00, 0xFE, 0x01, 0x00,
- 0x00, 0xFC, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l90.xbm b/app/bin/bitmaps/l90.xbm deleted file mode 100644 index d56c618..0000000 --- a/app/bin/bitmaps/l90.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l90_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1E,
- 0xFC, 0x3F,
- 0xCC, 0x33,
- 0xCC, 0x33,
- 0xFC, 0x33,
- 0xF8, 0x33,
- 0xC0, 0x33,
- 0xEC, 0x3F,
- 0x78, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l90_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xE0, 0x03,
- 0xB8, 0x73, 0x07,
- 0x9C, 0x33, 0x07,
- 0x1C, 0x3B, 0x06,
- 0x1C, 0x3F, 0x06,
- 0x1C, 0x3F, 0x0E,
- 0x9C, 0x3F, 0x0E,
- 0xB8, 0x3F, 0x0E,
- 0xF0, 0x3F, 0x0E,
- 0x00, 0x3F, 0x0E,
- 0x00, 0x3B, 0x06,
- 0x00, 0x3B, 0x06,
- 0x9C, 0x33, 0x07,
- 0xB8, 0x71, 0x07,
- 0xF8, 0xE0, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l90_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x03, 0x7E, 0x00,
- 0xF8, 0x07, 0xFF, 0x00,
- 0x7C, 0x0F, 0xEF, 0x01,
- 0x3C, 0x8E, 0xC7, 0x01,
- 0x1E, 0x9C, 0xC3, 0x03,
- 0x1E, 0x9C, 0xC3, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1C, 0xDE, 0x83, 0x03,
- 0x3C, 0xDF, 0x83, 0x03,
- 0xF8, 0xDF, 0x83, 0x03,
- 0xF0, 0xDF, 0x83, 0x03,
- 0x00, 0xDC, 0x83, 0x03,
- 0x00, 0x9C, 0xC3, 0x03,
- 0x1C, 0x9E, 0xC3, 0x03,
- 0x1C, 0x8E, 0xC7, 0x01,
- 0x3C, 0x0F, 0xEF, 0x01,
- 0xF8, 0x07, 0xFF, 0x00,
- 0xF0, 0x03, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l91.xbm b/app/bin/bitmaps/l91.xbm deleted file mode 100644 index cb63233..0000000 --- a/app/bin/bitmaps/l91.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l91_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1C,
- 0xFC, 0x1E,
- 0xCC, 0x1F,
- 0xCC, 0x1C,
- 0xFC, 0x1C,
- 0xF8, 0x1C,
- 0xC0, 0x1C,
- 0xEC, 0x1C,
- 0x78, 0x1C,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l91_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0x80, 0x03,
- 0xB8, 0xC3, 0x03,
- 0x9C, 0xC3, 0x03,
- 0x1C, 0xE3, 0x03,
- 0x1C, 0xB7, 0x03,
- 0x1C, 0x87, 0x03,
- 0x9C, 0x87, 0x03,
- 0xB8, 0x87, 0x03,
- 0xF0, 0x87, 0x03,
- 0x00, 0x87, 0x03,
- 0x00, 0x83, 0x03,
- 0x00, 0x83, 0x03,
- 0x9C, 0x83, 0x03,
- 0xB8, 0x81, 0x03,
- 0xF8, 0x80, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l91_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x03, 0x70, 0x00,
- 0xF8, 0x07, 0x70, 0x00,
- 0x7C, 0x0F, 0x78, 0x00,
- 0x3C, 0x0E, 0x7C, 0x00,
- 0x1E, 0x1C, 0x7E, 0x00,
- 0x1E, 0x1C, 0x7F, 0x00,
- 0x1E, 0x1C, 0x73, 0x00,
- 0x1E, 0x1C, 0x70, 0x00,
- 0x1E, 0x1C, 0x70, 0x00,
- 0x1C, 0x1E, 0x70, 0x00,
- 0x3C, 0x1F, 0x70, 0x00,
- 0xF8, 0x1F, 0x70, 0x00,
- 0xF0, 0x1F, 0x70, 0x00,
- 0x00, 0x1C, 0x70, 0x00,
- 0x00, 0x1C, 0x70, 0x00,
- 0x1C, 0x1E, 0x70, 0x00,
- 0x1C, 0x0E, 0x70, 0x00,
- 0x3C, 0x0F, 0x70, 0x00,
- 0xF8, 0x07, 0x70, 0x00,
- 0xF0, 0x03, 0x70, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l92.xbm b/app/bin/bitmaps/l92.xbm deleted file mode 100644 index 8323e42..0000000 --- a/app/bin/bitmaps/l92.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l92_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1E,
- 0xFC, 0x3F,
- 0xCC, 0x33,
- 0xCC, 0x30,
- 0xFC, 0x38,
- 0xF8, 0x1C,
- 0xC0, 0x0E,
- 0xEC, 0x07,
- 0x78, 0x3F,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l92_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xE0, 0x03,
- 0xB8, 0x73, 0x07,
- 0x9C, 0x3B, 0x06,
- 0x1C, 0x3B, 0x0E,
- 0x1C, 0x07, 0x0E,
- 0x1C, 0x07, 0x0E,
- 0x9C, 0x07, 0x07,
- 0xB8, 0x87, 0x07,
- 0xF0, 0x87, 0x03,
- 0x00, 0xC7, 0x01,
- 0x00, 0xE3, 0x01,
- 0x00, 0xF3, 0x00,
- 0x9C, 0x73, 0x00,
- 0xB8, 0x79, 0x00,
- 0xF8, 0xF8, 0x0F,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l92_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x03, 0xFE, 0x00,
- 0xF8, 0x07, 0xFF, 0x01,
- 0x7C, 0x8F, 0xE7, 0x03,
- 0x3C, 0x8E, 0xC3, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0x1C, 0x80, 0x03,
- 0x1E, 0x1C, 0xC0, 0x03,
- 0x1E, 0x1C, 0xC0, 0x03,
- 0x1C, 0x1E, 0xE0, 0x01,
- 0x3C, 0x1F, 0xF0, 0x01,
- 0xF8, 0x1F, 0xF8, 0x00,
- 0xF0, 0x1F, 0x78, 0x00,
- 0x00, 0x1C, 0x3C, 0x00,
- 0x00, 0x1C, 0x1E, 0x00,
- 0x1C, 0x1E, 0x0F, 0x00,
- 0x1C, 0x8E, 0x07, 0x00,
- 0x3C, 0x8F, 0x07, 0x00,
- 0xF8, 0xC7, 0xFF, 0x03,
- 0xF0, 0xC3, 0xFF, 0x03,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l93.xbm b/app/bin/bitmaps/l93.xbm deleted file mode 100644 index 4be9859..0000000 --- a/app/bin/bitmaps/l93.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l93_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1E,
- 0xFC, 0x3B,
- 0xCC, 0x38,
- 0xCC, 0x18,
- 0xFC, 0x3C,
- 0xF8, 0x38,
- 0xC0, 0x33,
- 0xEC, 0x3F,
- 0x78, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l93_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xE0, 0x03,
- 0xB8, 0x73, 0x07,
- 0x9C, 0x3B, 0x07,
- 0x1C, 0x03, 0x07,
- 0x1C, 0x07, 0x07,
- 0x1C, 0x07, 0x07,
- 0x9C, 0x87, 0x03,
- 0xB8, 0xC7, 0x07,
- 0xF0, 0x07, 0x07,
- 0x00, 0x07, 0x0E,
- 0x00, 0x03, 0x0E,
- 0x00, 0x3B, 0x0E,
- 0x9C, 0x3B, 0x07,
- 0xB8, 0x71, 0x07,
- 0xF8, 0xE0, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l93_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x03, 0x7E, 0x00,
- 0xF8, 0x07, 0xFF, 0x00,
- 0x7C, 0x8F, 0xE7, 0x01,
- 0x3C, 0x8E, 0xC7, 0x01,
- 0x1E, 0x9C, 0xC3, 0x03,
- 0x1E, 0x1C, 0xC0, 0x03,
- 0x1E, 0x1C, 0xC0, 0x01,
- 0x1E, 0x1C, 0xE0, 0x01,
- 0x1E, 0x1C, 0xFC, 0x00,
- 0x1C, 0x1E, 0xFC, 0x00,
- 0x3C, 0x1F, 0xE0, 0x01,
- 0xF8, 0x1F, 0xC0, 0x03,
- 0xF0, 0x1F, 0x80, 0x03,
- 0x00, 0x1C, 0x80, 0x03,
- 0x00, 0xDC, 0x83, 0x03,
- 0x1C, 0xDE, 0x83, 0x03,
- 0x1C, 0x8E, 0xC7, 0x03,
- 0x3C, 0x8F, 0xE7, 0x01,
- 0xF8, 0x07, 0xFF, 0x01,
- 0xF0, 0x03, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l94.xbm b/app/bin/bitmaps/l94.xbm deleted file mode 100644 index 65f4306..0000000 --- a/app/bin/bitmaps/l94.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l94_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1C,
- 0xFC, 0x1C,
- 0xCC, 0x1E,
- 0xCC, 0x1E,
- 0xFC, 0x1F,
- 0xF8, 0x1B,
- 0xC0, 0x3F,
- 0xEC, 0x18,
- 0x78, 0x18,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l94_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0x80, 0x03,
- 0xB8, 0x83, 0x03,
- 0x9C, 0xC3, 0x03,
- 0x1C, 0xC3, 0x03,
- 0x1C, 0xE7, 0x03,
- 0x1C, 0xE7, 0x03,
- 0x9C, 0xF7, 0x03,
- 0xB8, 0xB7, 0x03,
- 0xF0, 0xBF, 0x03,
- 0x00, 0x9F, 0x03,
- 0x00, 0xFF, 0x0F,
- 0x00, 0x83, 0x03,
- 0x9C, 0x83, 0x03,
- 0xB8, 0x81, 0x03,
- 0xF8, 0x80, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l94_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x03, 0xF0, 0x00,
- 0xF8, 0x07, 0xF0, 0x00,
- 0x7C, 0x0F, 0xF8, 0x00,
- 0x3C, 0x0E, 0xF8, 0x00,
- 0x1E, 0x1C, 0xFC, 0x00,
- 0x1E, 0x1C, 0xFC, 0x00,
- 0x1E, 0x1C, 0xFE, 0x00,
- 0x1E, 0x1C, 0xEE, 0x00,
- 0x1E, 0x1C, 0xEF, 0x00,
- 0x1C, 0x9E, 0xE7, 0x00,
- 0x3C, 0x9F, 0xE7, 0x00,
- 0xF8, 0xDF, 0xE3, 0x00,
- 0xF0, 0xDF, 0xE1, 0x00,
- 0x00, 0xFC, 0xFF, 0x03,
- 0x00, 0xFC, 0xFF, 0x03,
- 0x1C, 0x1E, 0xE0, 0x00,
- 0x1C, 0x0E, 0xE0, 0x00,
- 0x3C, 0x0F, 0xE0, 0x00,
- 0xF8, 0x07, 0xE0, 0x00,
- 0xF0, 0x03, 0xE0, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l95.xbm b/app/bin/bitmaps/l95.xbm deleted file mode 100644 index e8ab2c2..0000000 --- a/app/bin/bitmaps/l95.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l95_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x3F,
- 0xFC, 0x07,
- 0xCC, 0x07,
- 0xCC, 0x1F,
- 0xFC, 0x3B,
- 0xF8, 0x30,
- 0xC0, 0x33,
- 0xEC, 0x3F,
- 0x78, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l95_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xF0, 0x07,
- 0xB8, 0x73, 0x00,
- 0x9C, 0x73, 0x00,
- 0x1C, 0x33, 0x00,
- 0x1C, 0x37, 0x00,
- 0x1C, 0xFF, 0x03,
- 0x9C, 0x7F, 0x07,
- 0xB8, 0x3F, 0x07,
- 0xF0, 0x07, 0x0E,
- 0x00, 0x07, 0x0E,
- 0x00, 0x03, 0x0E,
- 0x00, 0x3B, 0x06,
- 0x9C, 0x3B, 0x07,
- 0xB8, 0x71, 0x07,
- 0xF8, 0xE0, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l95_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x03, 0xFF, 0x03,
- 0xF8, 0x07, 0xFF, 0x03,
- 0x7C, 0x0F, 0x07, 0x00,
- 0x3C, 0x0E, 0x07, 0x00,
- 0x1E, 0x9C, 0x07, 0x00,
- 0x1E, 0x9C, 0x07, 0x00,
- 0x1E, 0x9C, 0x7F, 0x00,
- 0x1E, 0x9C, 0xFF, 0x01,
- 0x1E, 0x9C, 0xE7, 0x01,
- 0x1C, 0x9E, 0xC3, 0x03,
- 0x3C, 0x1F, 0xC0, 0x03,
- 0xF8, 0x1F, 0x80, 0x03,
- 0xF0, 0x1F, 0x80, 0x03,
- 0x00, 0x1C, 0x80, 0x03,
- 0x00, 0xDC, 0x83, 0x03,
- 0x1C, 0xDE, 0xC3, 0x03,
- 0x1C, 0x8E, 0xC3, 0x03,
- 0x3C, 0x8F, 0xE7, 0x01,
- 0xF8, 0x07, 0xFF, 0x00,
- 0xF0, 0x03, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l96.xbm b/app/bin/bitmaps/l96.xbm deleted file mode 100644 index b114e81..0000000 --- a/app/bin/bitmaps/l96.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l96_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1E,
- 0xFC, 0x3F,
- 0xCC, 0x03,
- 0xCC, 0x1F,
- 0xFC, 0x3F,
- 0xF8, 0x33,
- 0xC0, 0x33,
- 0xEC, 0x3F,
- 0x78, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l96_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xE0, 0x03,
- 0xB8, 0x73, 0x07,
- 0x9C, 0x33, 0x07,
- 0x1C, 0x3B, 0x00,
- 0x1C, 0x3F, 0x00,
- 0x1C, 0x3F, 0x00,
- 0x9C, 0xFF, 0x03,
- 0xB8, 0x7F, 0x07,
- 0xF0, 0x3F, 0x07,
- 0x00, 0x3F, 0x0E,
- 0x00, 0x3B, 0x0E,
- 0x00, 0x3B, 0x0E,
- 0x9C, 0x33, 0x07,
- 0xB8, 0x71, 0x07,
- 0xF8, 0xE0, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l96_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x03, 0xFC, 0x00,
- 0xF8, 0x07, 0xFF, 0x01,
- 0x7C, 0x0F, 0xEF, 0x01,
- 0x3C, 0x8E, 0xC7, 0x03,
- 0x1E, 0x9C, 0xC3, 0x03,
- 0x1E, 0x9C, 0x03, 0x00,
- 0x1E, 0xDC, 0x03, 0x00,
- 0x1E, 0xDC, 0x7F, 0x00,
- 0x1E, 0xDC, 0xFF, 0x01,
- 0x1C, 0xDE, 0xEF, 0x01,
- 0x3C, 0xDF, 0xC7, 0x03,
- 0xF8, 0xDF, 0x83, 0x03,
- 0xF0, 0xDF, 0x83, 0x03,
- 0x00, 0xDC, 0x83, 0x03,
- 0x00, 0xDC, 0x83, 0x03,
- 0x1C, 0x9E, 0x83, 0x03,
- 0x1C, 0x8E, 0xC7, 0x03,
- 0x3C, 0x8F, 0xEF, 0x01,
- 0xF8, 0x07, 0xFF, 0x01,
- 0xF0, 0x03, 0x7C, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l97.xbm b/app/bin/bitmaps/l97.xbm deleted file mode 100644 index 75ab190..0000000 --- a/app/bin/bitmaps/l97.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l97_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x3F,
- 0xFC, 0x38,
- 0xCC, 0x18,
- 0xCC, 0x1C,
- 0xFC, 0x0C,
- 0xF8, 0x0E,
- 0xC0, 0x0E,
- 0xEC, 0x06,
- 0x78, 0x06,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l97_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xF8, 0x0F,
- 0xB8, 0x03, 0x0F,
- 0x9C, 0x03, 0x07,
- 0x1C, 0x83, 0x03,
- 0x1C, 0x87, 0x03,
- 0x1C, 0xC7, 0x01,
- 0x9C, 0xC7, 0x01,
- 0xB8, 0xC7, 0x01,
- 0xF0, 0xE7, 0x00,
- 0x00, 0xE7, 0x00,
- 0x00, 0xE3, 0x00,
- 0x00, 0xE3, 0x00,
- 0x9C, 0xE3, 0x00,
- 0xB8, 0x71, 0x00,
- 0xF8, 0x70, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l97_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0xC3, 0xFF, 0x03,
- 0xF8, 0xC7, 0xFF, 0x03,
- 0x7C, 0x0F, 0xC0, 0x03,
- 0x3C, 0x0E, 0xE0, 0x01,
- 0x1E, 0x1C, 0xE0, 0x01,
- 0x1E, 0x1C, 0xF0, 0x00,
- 0x1E, 0x1C, 0xF0, 0x00,
- 0x1E, 0x1C, 0x78, 0x00,
- 0x1E, 0x1C, 0x78, 0x00,
- 0x1C, 0x1E, 0x38, 0x00,
- 0x3C, 0x1F, 0x3C, 0x00,
- 0xF8, 0x1F, 0x3C, 0x00,
- 0xF0, 0x1F, 0x1C, 0x00,
- 0x00, 0x1C, 0x1E, 0x00,
- 0x00, 0x1C, 0x1E, 0x00,
- 0x1C, 0x1E, 0x1E, 0x00,
- 0x1C, 0x0E, 0x1E, 0x00,
- 0x3C, 0x0F, 0x0E, 0x00,
- 0xF8, 0x07, 0x0E, 0x00,
- 0xF0, 0x03, 0x0E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l98.xbm b/app/bin/bitmaps/l98.xbm deleted file mode 100644 index 744aad6..0000000 --- a/app/bin/bitmaps/l98.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l98_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1E,
- 0xFC, 0x3F,
- 0xCC, 0x3B,
- 0xCC, 0x3F,
- 0xFC, 0x1E,
- 0xF8, 0x3F,
- 0xC0, 0x33,
- 0xEC, 0x3F,
- 0x78, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l98_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xE0, 0x03,
- 0xB8, 0x73, 0x07,
- 0x9C, 0x33, 0x07,
- 0x1C, 0x3B, 0x07,
- 0x1C, 0x3F, 0x07,
- 0x1C, 0x3F, 0x07,
- 0x9C, 0x77, 0x07,
- 0xB8, 0xE7, 0x03,
- 0xF0, 0x77, 0x07,
- 0x00, 0x3F, 0x06,
- 0x00, 0x3B, 0x0E,
- 0x00, 0x3B, 0x0E,
- 0x9C, 0x3B, 0x06,
- 0xB8, 0x71, 0x07,
- 0xF8, 0xE0, 0x03,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l98_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x03, 0x7E, 0x00,
- 0xF8, 0x07, 0xFF, 0x00,
- 0x7C, 0x8F, 0xEF, 0x01,
- 0x3C, 0x8E, 0xC7, 0x01,
- 0x1E, 0x9C, 0xC3, 0x03,
- 0x1E, 0x9C, 0xC3, 0x03,
- 0x1E, 0x9C, 0xC7, 0x01,
- 0x1E, 0x1C, 0xEF, 0x01,
- 0x1E, 0x1C, 0xFE, 0x00,
- 0x1C, 0x1E, 0xFF, 0x00,
- 0x3C, 0x9F, 0xE7, 0x01,
- 0xF8, 0x9F, 0xC3, 0x03,
- 0xF0, 0xDF, 0x83, 0x03,
- 0x00, 0xDC, 0x83, 0x03,
- 0x00, 0xDC, 0x83, 0x03,
- 0x1C, 0xDE, 0x83, 0x03,
- 0x1C, 0x8E, 0xC3, 0x03,
- 0x3C, 0x8F, 0xE7, 0x01,
- 0xF8, 0x07, 0xFF, 0x01,
- 0xF0, 0x03, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/l99.xbm b/app/bin/bitmaps/l99.xbm deleted file mode 100644 index b7d956a..0000000 --- a/app/bin/bitmaps/l99.xbm +++ /dev/null @@ -1,78 +0,0 @@ -static char l99_x16[] = {
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x78, 0x1E,
- 0xFC, 0x3F,
- 0xCC, 0x33,
- 0xCC, 0x33,
- 0xFC, 0x3F,
- 0xF8, 0x3E,
- 0xC0, 0x30,
- 0xEC, 0x3B,
- 0x78, 0x1E,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00, };
-
-static char l99_x24[] = {
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0xF0, 0xE0, 0x01,
- 0xB8, 0x73, 0x07,
- 0x9C, 0x3B, 0x07,
- 0x1C, 0x3B, 0x06,
- 0x1C, 0x3F, 0x0E,
- 0x1C, 0x3F, 0x0E,
- 0x9C, 0x3F, 0x0F,
- 0xB8, 0x77, 0x0F,
- 0xF0, 0xE7, 0x0F,
- 0x00, 0x07, 0x0E,
- 0x00, 0x03, 0x06,
- 0x00, 0x03, 0x06,
- 0x9C, 0x3B, 0x07,
- 0xB8, 0x71, 0x03,
- 0xF8, 0xF0, 0x01,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, };
-
-static char l99_x32[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x03, 0x7E, 0x00,
- 0xF8, 0x07, 0xFF, 0x00,
- 0x7C, 0x8F, 0xEF, 0x01,
- 0x3C, 0x8E, 0xC7, 0x01,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1E, 0xDC, 0x83, 0x03,
- 0x1C, 0x9E, 0xC3, 0x03,
- 0x3C, 0x9F, 0xE7, 0x03,
- 0xF8, 0x1F, 0xFF, 0x03,
- 0xF0, 0x1F, 0xFE, 0x03,
- 0x00, 0x1C, 0x80, 0x03,
- 0x00, 0x1C, 0x80, 0x03,
- 0x1C, 0x9E, 0xC3, 0x03,
- 0x1C, 0x8E, 0xC3, 0x01,
- 0x3C, 0x8F, 0xE7, 0x01,
- 0xF8, 0x07, 0xFF, 0x00,
- 0xF0, 0x03, 0x7E, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, };
-
diff --git a/app/bin/bitmaps/layer_num.inc b/app/bin/bitmaps/layer_num.inc new file mode 100644 index 0000000..e8104f9 --- /dev/null +++ b/app/bin/bitmaps/layer_num.inc @@ -0,0 +1,515 @@ +// Define digits for layer buttons
+
+static char* n0_x16[] = {
+ " #### "
+ "######"
+ "## ##"
+ "## ##"
+ "## ##"
+ "## ##"
+ "## ##"
+ "## ##"
+ "######"
+ " #### "};
+
+static char* n1_x16[] = {
+ " ##"
+ " ###"
+ "####"
+ " ##"
+ " ##"
+ " ##"
+ " ##"
+ " ##"
+ " ##"
+ " ##"};
+
+static char* n2_x16[] = {
+ " #### "
+ "######"
+ "## ##"
+ " ##"
+ " ###"
+ " ### "
+ " ### "
+ "### "
+ "######"
+ "######"};
+
+static char* n3_x16[] = {
+ " #### "
+ "######"
+ "## ##"
+ " ##"
+ " #### "
+ " #### "
+ " ##"
+ "## ##"
+ "######"
+ " #### "};
+
+static char* n4_x16[] = {
+ " ##"
+ " ###"
+ " ####"
+ " ## ##"
+ "## ##"
+ "######"
+ "######"
+ " ##"
+ " ##"
+ " ##"};
+
+static char* n5_x16[] = {
+ "######"
+ "######"
+ "## "
+ "## "
+ "#### "
+ " ####"
+ " ##"
+ "## ##"
+ "######"
+ " #### "};
+
+static char* n6_x16[] = {
+ " #### "
+ "######"
+ "## "
+ "## "
+ "##### "
+ "######"
+ "## ##"
+ "## ##"
+ "######"
+ " #### "};
+
+static char* n7_x16[] = {
+ "######"
+ "######"
+ " ##"
+ " ##"
+ " ## "
+ " ## "
+ " ## "
+ " ## "
+ " ## "
+ " ## "};
+
+static char* n8_x16[] = {
+ " #### "
+ "######"
+ "## ##"
+ "## ##"
+ " #### "
+ " #### "
+ "## ##"
+ "## ##"
+ "######"
+ " #### "};
+
+static char* n9_x16[] = {
+ " #### "
+ "######"
+ "## ##"
+ "## ##"
+ "######"
+ " #####"
+ " ##"
+ " ##"
+ "######"
+ " #### "};
+
+/* ***************** */
+
+static char* n0_x24[] = {
+ " ###### "
+ " ######## "
+ "### ###"
+ "### ###"
+ "### ###"
+ "### ###"
+ "### ###"
+ "### ###"
+ "### ###"
+ "### ###"
+ "### ###"
+ "### ###"
+ "### ###"
+ " ######## "
+ " ###### "};
+
+static char* n1_x24[] = {
+ " ###"
+ " ####"
+ "#####"
+ " ###"
+ " ###"
+ " ###"
+ " ###"
+ " ###"
+ " ###"
+ " ###"
+ " ###"
+ " ###"
+ " ###"
+ " ###"
+ " ###"};
+
+static char* n2_x24[] = {
+ " #### "
+ " ######## "
+ "#### ####"
+ "### ###"
+ " ###"
+ " ####"
+ " #### "
+ " #### "
+ " #### "
+ " #### "
+ " #### "
+ "#### "
+ "### ###"
+ "##########"
+ "##########"};
+
+static char* n3_x24[] = {
+ " #### "
+ " ######## "
+ "#### ####"
+ "### ###"
+ " ###"
+ " ####"
+ " ###### "
+ " ##### "
+ " #### "
+ " ####"
+ " ###"
+ "### ###"
+ "#### ####"
+ " ######## "
+ " #### "};
+
+static char* n4_x24[] = {
+ " ##### "
+ " ##### "
+ " ###### "
+ " ###### "
+ " ### ### "
+ " ### ### "
+ " ### ### "
+ "### ### "
+ "### ### "
+ "##########"
+ "##########"
+ " ### "
+ " ### "
+ " ### "
+ " ### "};
+
+static char* n5_x24[] = {
+ "##########"
+ "##########"
+ "### "
+ "### "
+ "### "
+ "### "
+ "######## "
+ " ######## "
+ " ###"
+ " ###"
+ " ###"
+ " ###"
+ "### ###"
+ "######### "
+ " ####### "};
+
+static char* n6_x24[] = {
+ " #### "
+ " ######## "
+ "#### ####"
+ "### ###"
+ "### "
+ "### "
+ "####### "
+ "######### "
+ "### ####"
+ "### ###"
+ "### ###"
+ "### ###"
+ "#### ####"
+ " ######## "
+ " #### "};
+
+static char* n7_x24[] = {
+ "##########"
+ "##########"
+ "### ###"
+ " ###"
+ " ### "
+ " ### "
+ " ### "
+ " ### "
+ " ### "
+ " ### "
+ " ### "
+ " ### "
+ " ### "
+ " ### "
+ " ### "};
+
+static char* n8_x24[] = {
+ " #### "
+ " ######## "
+ "#### ####"
+ "### ###"
+ "### ###"
+ "#### ####"
+ " ######## "
+ " ######## "
+ "#### ####"
+ "### ###"
+ "### ###"
+ "### ###"
+ "#### ####"
+ " ######## "
+ " #### "};
+
+static char* n9_x24[] = {
+ " #### "
+ " ######## "
+ "#### ####"
+ "### ###"
+ "### ###"
+ "#### ###"
+ " #########"
+ " #######"
+ " ###"
+ " ###"
+ " ###"
+ "### ###"
+ "#### ####"
+ " ######## "
+ " #### "};
+
+/* ***************** */
+
+static char* n0_x32[] = {
+ " ###### "
+ " ########## "
+ " ############ "
+ "##### #####"
+ "#### ####"
+ "#### ####"
+ "#### ####"
+ "#### ####"
+ "#### ####"
+ "#### ####"
+ "#### ####"
+ "#### ####"
+ "#### ####"
+ "#### ####"
+ "#### ####"
+ "#### ####"
+ "##### #####"
+ " ############ "
+ " ########## "
+ " ###### "};
+
+static char* n1_x32[] = {
+ " ####"
+ " #####"
+ "######"
+ "######"
+ " ####"
+ " ####"
+ " ####"
+ " ####"
+ " ####"
+ " ####"
+ " ####"
+ " ####"
+ " ####"
+ " ####"
+ " ####"
+ " ####"
+ " ####"
+ " ####"
+ " ####"
+ " ####"};
+
+static char* n2_x32[] = {
+ " ###### "
+ " ########## "
+ " ############ "
+ "##### #####"
+ "#### ####"
+ " ####"
+ " ####"
+ " ####"
+ " ##### "
+ " ##### "
+ " ##### "
+ " ##### "
+ " ##### "
+ " ##### "
+ " ##### "
+ " ##### "
+ "##### ####"
+ "##############"
+ "##############"
+ "##############"};
+
+static char* n3_x32[] = {
+ " ###### "
+ " ########## "
+ " ############ "
+ "##### #####"
+ "#### ####"
+ " ####"
+ " ####"
+ " #### "
+ " ####### "
+ " ###### "
+ " ####### "
+ " #### "
+ " ####"
+ " ####"
+ " ####"
+ "#### ####"
+ "##### #####"
+ " ############ "
+ " ########## "
+ " ###### "};
+
+static char* n4_x32[] = {
+ " ####### "
+ " ####### "
+ " ######## "
+ " ######## "
+ " #### #### "
+ " #### #### "
+ " #### #### "
+ " #### #### "
+ " #### #### "
+ " #### #### "
+ "#### #### "
+ "#### #### "
+ "##############"
+ "##############"
+ "##############"
+ " #### "
+ " #### "
+ " #### "
+ " #### "
+ " #### "};
+
+static char* n5_x32[] = {
+ "##############"
+ "##############"
+ "##############"
+ "#### "
+ "#### "
+ "#### "
+ "#### "
+ "#### "
+ "########## "
+ "############ "
+ "############# "
+ " #####"
+ " ####"
+ " ####"
+ " ####"
+ "#### ####"
+ "##### #####"
+ " ############ "
+ " ########## "
+ " ###### "};
+
+static char* n6_x32[] = {
+ " ###### "
+ " ########## "
+ " ############ "
+ "##### #####"
+ "#### ####"
+ "#### "
+ "#### "
+ "#### "
+ "########## "
+ "############ "
+ "############# "
+ "#### #####"
+ "#### ####"
+ "#### ####"
+ "#### ####"
+ "#### ####"
+ "##### #####"
+ " ############ "
+ " ########## "
+ " ###### "};
+
+static char* n7_x32[] = {
+ "##############"
+ "##############"
+ "##############"
+ "#### ####"
+ "#### #### "
+ " #### "
+ " #### "
+ " #### "
+ " #### "
+ " #### "
+ " #### "
+ " #### "
+ " #### "
+ " #### "
+ " #### "
+ " #### "
+ " #### "
+ " #### "
+ " #### "
+ " #### "};
+
+static char* n8_x32[] = {
+ " ###### "
+ " ########## "
+ " ############ "
+ "##### #####"
+ "#### ####"
+ "#### ####"
+ "#### ####"
+ " #### #### "
+ " ########## "
+ " ######## "
+ " ########## "
+ " #### #### "
+ "#### ####"
+ "#### ####"
+ "#### ####"
+ "#### ####"
+ "##### #####"
+ " ############ "
+ " ########## "
+ " ###### "};
+
+static char* n9_x32[] = {
+ " ###### "
+ " ########## "
+ " ############ "
+ "##### #####"
+ "#### ####"
+ "#### ####"
+ "#### ####"
+ "#### ####"
+ "##### ####"
+ " #############"
+ " ############"
+ " ##########"
+ " ####"
+ " ####"
+ " ####"
+ "#### ####"
+ "##### #####"
+ " ############ "
+ " ########## "
+ " ###### "};
diff --git a/app/bin/bitmaps/layers.xpm b/app/bin/bitmaps/layers.xpm deleted file mode 100644 index 60e1761..0000000 --- a/app/bin/bitmaps/layers.xpm +++ /dev/null @@ -1,110 +0,0 @@ -static char *layers_x16[] = {
- "16 16 9 1",
- " c None",
- "0 c #000000",
- "1 c #333333",
- "2 c #666666",
- "3 c #999999",
- "4 c #CCCCCC",
- "5 c #FFFFFF",
- "6 c #C0C0C0",
- "7 c #808080",
- " ",
- " ",
- " 177777777771 ",
- " 0755555555541 ",
- " 1455555555570 ",
- " 13555555555411 ",
- " 13333333333231 ",
- " 01777777777371 ",
- " 1666666666610 ",
- " 17333333333720 ",
- " 11122222222271 ",
- " 133333333331 ",
- " 0233333333371 ",
- " 011111111111 ",
- " ",
- " "};
-
-static char *layers_x24[] = {
- "24 24 9 1",
- " c None",
- "0 c #000000",
- "1 c #333333",
- "2 c #666666",
- "3 c #999999",
- "4 c #CCCCCC",
- "5 c #FFFFFF",
- "6 c #C0C0C0",
- "7 c #808080",
- " ",
- " ",
- " ",
- " 100000000000000001 ",
- " 165555555555555552 ",
- " 155555555555555541 ",
- " 165555555555555552 ",
- " 155555555555555561 ",
- " 165555555555555551001 ",
- " 14444444444444443761 ",
- " 11122222222222227631 ",
- " 136666666666666661 ",
- " 166666666666666631 ",
- " 136666666666666661001 ",
- " 133333333333333372320 ",
- " 11122222222222222371 ",
- " 0233333333333333320 ",
- " 173333333333333371 ",
- " 0233333333333333320 ",
- " 173333333333333371 ",
- " 00000000000000000 ",
- " ",
- " ",
- " "};
-
-static char *layers_x32[] = {
- "32 32 9 1",
- " c None",
- "0 c #000000",
- "1 c #333333",
- "2 c #666666",
- "3 c #999999",
- "4 c #CCCCCC",
- "5 c #FFFFFF",
- "6 c #C0C0C0",
- "7 c #808080",
- " ",
- " ",
- " ",
- " ",
- " 10000000000000000000001 ",
- " 135555555555555555555561 ",
- " 14555555555555555555551 ",
- " 135555555555555555555561 ",
- " 15555555555555555555551 ",
- " 165555555555555555555561 ",
- " 155555555555555555555410 ",
- " 165555555555555555555531221 ",
- " 155555555555555555555416671 ",
- " 117277777777777777777727631 ",
- " 173333333333333333336620 ",
- " 026666666666666666666631 ",
- " 136666666666666666666620 ",
- " 026666666666666666666631000 ",
- " 136666666666666666666622720 ",
- " 1266666666666666666666313370 ",
- " 100000000000000000000017330 ",
- " 173333333333333333333320 ",
- " 013333333333333333333330 ",
- " 173333333333333333333320 ",
- " 013333333333333333333330 ",
- " 173333333333333333333320 ",
- " 017777777777777777777770 ",
- " 111111111111111111111110 ",
- " ",
- " ",
- " ",
- " "};
-
-static char **layers_xpm[3] = { layers_x16, layers_x24, layers_x32 };
-
diff --git a/app/bin/bitmaps/loosen.xpm b/app/bin/bitmaps/loosen.xpm new file mode 100644 index 0000000..9a92872 --- /dev/null +++ b/app/bin/bitmaps/loosen.xpm @@ -0,0 +1,183 @@ +static char *loosen_x16[] = {
+ "16 16 24 1",
+ " c None",
+ "0 c #4878c8",
+ "1 c #c80000",
+ "2 c #c86868",
+ "3 c #6890c8",
+ "4 c #78a8e8",
+ "5 c #c82020",
+ "6 c #5880c8",
+ "7 c #7890b0",
+ "8 c #c83838",
+ "9 c #c81010",
+ "A c #8090b8",
+ "B c #88b0e8",
+ "C c #c87070",
+ "D c #5888d0",
+ "E c #c82828",
+ "F c #7090b8",
+ "G c #5078c0",
+ "H c #6088d0",
+ "I c #c87878",
+ "J c #c83030",
+ "K c #c84040",
+ "L c #6890d0",
+ "M c #7890b8",
+ " ",
+ " ",
+ " ",
+ " D D 3 3 D D ",
+ " 0A0A6M M6A0A0 ",
+ " 4 4 B B 4 4 ",
+ " 0707GF FG7070 ",
+ " H H L L H H ",
+ " EC2E ",
+ " 89 9J ",
+ " 1I 1C ",
+ " K9 98 ",
+ " 5C2E ",
+ " ",
+ " ",
+ " "};
+static char *loosen_x24[] = {
+ "24 24 38 1",
+ " c None",
+ "0 c #084098",
+ "1 c #c80000",
+ "2 c #3870c8",
+ "3 c #c84848",
+ "4 c #4888e8",
+ "5 c #2058c0",
+ "6 c #c81818",
+ "7 c #78a8e8",
+ "8 c #6080b8",
+ "9 c #4870b0",
+ "A c #c86868",
+ "B c #6090e8",
+ "C c #4068b0",
+ "D c #90a8d0",
+ "E c #5878a8",
+ "F c #c82828",
+ "G c #c80808",
+ "H c #3068b8",
+ "I c #5890f8",
+ "J c #7088b0",
+ "K c #6898f0",
+ "L c #5880b8",
+ "M c #c85858",
+ "N c #c87070",
+ "O c #88a8e8",
+ "P c #104098",
+ "Q c #3068c8",
+ "R c #2860b8",
+ "S c #6898e0",
+ "T c #c81010",
+ "U c #4070c0",
+ "V c #5070a8",
+ "W c #104898",
+ "X c #c83030",
+ "Y c #c82020",
+ "Z c #c85050",
+ "a c #c87878",
+ " ",
+ " ",
+ " ",
+ " ",
+ " ",
+ " LUJJQJJ28 82JJQJJUL ",
+ " CHEV5EER9 9REE5VEHC ",
+ " 7 I K K I 7 ",
+ " 7 I K K I 7 ",
+ " DS 4 B B 4 SD ",
+ " P0PW0PP0P P0PP0WP0P ",
+ " O K 7 7 K O ",
+ " ZG 1M ",
+ " N1G 11A ",
+ " 11 11a ",
+ " G1M A11 ",
+ " 316 Y1X ",
+ " F1X X1Y ",
+ " T1 1T ",
+ " A M ",
+ " ",
+ " ",
+ " ",
+ " "};
+static char *loosen_x32[] = {
+ "32 32 41 1",
+ " c None",
+ "0 c #0840a0",
+ "1 c #c80000",
+ "2 c #7088b0",
+ "3 c #c82828",
+ "4 c #3068c0",
+ "5 c #5090f8",
+ "6 c #2058bc",
+ "7 c #80a8e8",
+ "8 c #c85050",
+ "9 c #6078b0",
+ "A c #c81010",
+ "B c #3058a0",
+ "C c #689df0",
+ "D c #486ca8",
+ "E c #205098",
+ "F c #c83838",
+ "G c #95b0e0",
+ "H c #4068a0",
+ "I c #c86060",
+ "J c #1648a0",
+ "K c #4870b8",
+ "L c #3d68b0",
+ "M c #2860b8",
+ "N c #2050a4",
+ "O c #1048a8",
+ "P c #c84343",
+ "Q c #c80808",
+ "R c #c81919",
+ "S c #5070a9",
+ "T c #70a0f0",
+ "U c #c86c6c",
+ "V c #6480b0",
+ "W c #4070b8",
+ "X c #5890f8",
+ "Y c #2860c4",
+ "Z c #3860a0",
+ "a c #c83030",
+ "b c #2850a0",
+ "c c #1850a8",
+ "d c #88a8e8",
+ " ",
+ " ",
+ " ",
+ " ",
+ " ",
+ " ",
+ " 7G T C C T G7 ",
+ " VMLSSL6SSS6LV VL6SSS6LSSLMV ",
+ " DcNBBNOBBBObD DbOBBBONBBNcD ",
+ " Cd GX 5 5 XG dC ",
+ " Cd GX 5 5 XG dC ",
+ " Cd GX 5 5 XG dC ",
+ " Cd GX 5 5 XG dC ",
+ " ZJJEEJ0EEE0JH HJ0EEE0JEEJJZ ",
+ " 24W99KY999YS2 2SY999YK99W42 ",
+ " 7G T C C T G7 ",
+ " QF R1 ",
+ " 111 11Q ",
+ " A11U I11Q ",
+ " 311P 811R ",
+ " P113 P11R ",
+ " 8113 F113 ",
+ " a11P P11R ",
+ " A11U I11A ",
+ " 111 11Q ",
+ " 1a R1 ",
+ " ",
+ " ",
+ " ",
+ " ",
+ " ",
+ " "};
+
+static char **loosen_xpm[3] = { loosen_x16, loosen_x24, loosen_x32 };
diff --git a/app/bin/bitmaps/magnet.xpm b/app/bin/bitmaps/magnet.xpm deleted file mode 100644 index 3d9a5ac..0000000 --- a/app/bin/bitmaps/magnet.xpm +++ /dev/null @@ -1,139 +0,0 @@ -static char *magnet_x16[] = {
- "16 16 18 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #660000",
- "4 c #663300",
- "5 c #666600",
- "6 c #990000",
- "7 c #999900",
- "8 c #CC0000",
- "9 c #CC3300",
- "A c #CC9900",
- "B c #CCCC00",
- "C c #FF0000",
- "D c #FF6600",
- "E c #FFCC00",
- "F c #FFFF00",
- "G c #800000",
- " 1110 ",
- " 11888610 ",
- " 16CCCCCCG0 ",
- " 08CC836CCC30",
- " 06CC83 13CC81",
- " 3CC83 GCC1",
- " 1CCC3 3CC1",
- " 5DCC3 38C81",
- "5BEDG1 38CC3 ",
- " 5EA4 38CCG0 ",
- " 55 18CC61 ",
- " 18CC81 ",
- " 5ACC83 ",
- " 27FE93 ",
- " 5AB5 ",
- " 55 "};
-
-static char *magnet_x24[] = {
- "24 24 19 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #660000",
- "4 c #663300",
- "5 c #666600",
- "6 c #990000",
- "7 c #996600",
- "8 c #999900",
- "9 c #CC0000",
- "A c #CC9900",
- "B c #FF0000",
- "C c #FF6600",
- "D c #FF9900",
- "E c #FFCC00",
- "F c #FFFF00",
- "G c #800000",
- "H c #808000",
- " 000 ",
- " 3399G310 ",
- " 019BBBBBBG1 ",
- " 0GBBBBBBBBB91 ",
- " 0GBBBBBBBBBBBB1 ",
- " 06BBBBBG319BBBBB1 ",
- " 03BBBBB31 GGBBBBG0",
- " 3BBBBB3 6GBBB91",
- " 1BBBBB3 G9BBB1",
- " 19BBBBG 39BBB1",
- " 29BBBB6G G9BBB60",
- " 48DBBB93 GGBBBB1 ",
- "58FFDB91 GBBBBG0 ",
- " 5EFFE3 GBBBB91 ",
- " 5EE72 3BBBBB1 ",
- " 5H4 3BBBBB3 ",
- " 2 3BBBBB3 ",
- " 13BBBBBG1 ",
- " HCBBBBG1 ",
- " 5EECBB63 ",
- " 48FFFD61 ",
- " 5HEFA2 ",
- " 45A5 ",
- " 5 "};
-
-static char *magnet_x32[] = {
- "32 32 19 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #660000",
- "4 c #663300",
- "5 c #666600",
- "6 c #990000",
- "7 c #996600",
- "8 c #CC0000",
- "9 c #CC9900",
- "A c #CCCC00",
- "B c #FF0000",
- "C c #FF3300",
- "D c #FF6600",
- "E c #FFCC00",
- "F c #FFFF00",
- "G c #800000",
- "H c #808000",
- " ",
- " 013GGG010 ",
- " 16BBBBBB8G00 ",
- " 38BBBBBBBBBB30 ",
- " 03BBBBBBBBBBBBB80 ",
- " 03BBBBBBBBBBBBBBB80 ",
- " 0GBBBBBBB88BBBBBBBB80 ",
- " 03BBBBBBB83G3GBBBBBBBG0 ",
- " 1BBBBBBB61 G38BBBBBB0 ",
- " 1BBBBBBB61 G8BBBBBG0",
- " 1BBBBBBB63 3BBBBB80",
- " 08BBBBBB63 6GBBBB80",
- " 06BBBBBB63 68BBBB81",
- " 03BBBBBB83 8GBBBBBG0",
- " 5CBBBBB83 3BBBBBB1 ",
- " 5EECBBBB3 G8BBBBBG0 ",
- " 5EFFECBBG1 G8BBBBB81 ",
- " 5EFFFED81 G8BBBBBB1 ",
- " 5EFFFE4 38BBBBBBG0 ",
- " 5EFE5 38BBBBBB81 ",
- " 5A5 18BBBBBB81 ",
- " 5 18BBBBBB81 ",
- " 08BBBBBBB3 ",
- " 08BBBBBBB3 ",
- " 59CBBBBBB3 ",
- " 5AFECBBBB3 ",
- " 59FFFECBBG ",
- " 45EFFFEDG0 ",
- " 5EFFE70 ",
- " 5EE74 ",
- " 5H2 ",
- " 2 "};
-
-static char **magnet_xpm[3] = { magnet_x16, magnet_x24, magnet_x32 };
-
diff --git a/app/bin/bitmaps/manage.xpm b/app/bin/bitmaps/manage.xpm deleted file mode 100644 index 12264cf..0000000 --- a/app/bin/bitmaps/manage.xpm +++ /dev/null @@ -1,110 +0,0 @@ -static char *manage_x16[] = {
- "16 16 9 1",
- " c None",
- "0 c #000000",
- "1 c #333333",
- "2 c #666666",
- "3 c #999999",
- "4 c #CCCCCC",
- "5 c #FFFFFF",
- "6 c #C0C0C0",
- "7 c #808080",
- " 11 ",
- " 1370 ",
- " 101 1361 111 ",
- " 247074432742 ",
- " 134444444431 ",
- " 24432734470 ",
- " 1743744734310 ",
- "1274424555144330",
- "1344414555144630",
- "111347355674611 ",
- " 14471274470 ",
- " 24444644431 ",
- " 1463644677470 ",
- " 171013410121 ",
- " 0 0761 ",
- " 101 "};
-
-static char *manage_x24[] = {
- "24 24 9 1",
- " c None",
- "0 c #000000",
- "1 c #333333",
- "2 c #666666",
- "3 c #999999",
- "4 c #CCCCCC",
- "5 c #FFFFFF",
- "6 c #C0C0C0",
- "7 c #808080",
- " 00 ",
- " 1331 ",
- " 2440 ",
- " 11 02441 111 ",
- " 173100164431102431 ",
- " 144473444444334441 ",
- " 134444444444444421 ",
- " 1644444444444431 ",
- " 1344462102644431 ",
- " 14446745547644410 ",
- " 11134442455554244447201",
- "076644442555555764444461",
- "134444462555555734444461",
- "013344441455555244447101",
- " 0024443755553344420 ",
- " 1344431732344461 ",
- " 0744444336444461 ",
- " 16444444444444471 ",
- " 134466444444634442 ",
- " 164311164447112441 ",
- " 171 14431 11 ",
- " 0 14470 ",
- " 13620 ",
- " 111 "};
-
-static char *manage_x32[] = {
- "32 32 9 1",
- " c None",
- "0 c #000000",
- "1 c #333333",
- "2 c #666666",
- "3 c #999999",
- "4 c #CCCCCC",
- "5 c #FFFFFF",
- "6 c #C0C0C0",
- "7 c #808080",
- " ",
- " 11221 ",
- " 164430 ",
- " 164430 ",
- " 11 164431 11 ",
- " 1331 02444410 2461 ",
- " 164431112444444701244461 ",
- " 144446364444444446444461 ",
- " 13444444444444444444441 ",
- " 134444444444444444441 ",
- " 14444444373344444461 ",
- " 14444431011003444441 ",
- " 0744443074554707444431 ",
- " 016444417555555306444421111 ",
- " 1227644443045555555174444466620",
- "02444444447255555555324444444430",
- "07444444447255555555324444444430",
- " 244444444305555555527444443332 ",
- " 100074444603555555403444471000 ",
- " 1344447065555412444431 ",
- " 14444470233702444442 ",
- " 13444443710234444440 ",
- " 164444444444444444421 ",
- " 13444444444444444444421 ",
- " 174444444444444444444441 ",
- " 164443123444444620164441 ",
- " 14431 12444431 13471 ",
- " 1121 174441 111 ",
- " 074441 ",
- " 074440 ",
- " 13371 ",
- " 000 "};
-
-static char **manage_xpm[3] = { manage_x16, manage_x24, manage_x32 };
-
diff --git a/app/bin/bitmaps/map.xpm b/app/bin/bitmaps/map.xpm deleted file mode 100644 index e123f7f..0000000 --- a/app/bin/bitmaps/map.xpm +++ /dev/null @@ -1,169 +0,0 @@ -static char *map_x16[] = {
- "16 16 28 1",
- " c None",
- "0 c #000000",
- "1 c #003333",
- "2 c #003366",
- "3 c #0099CC",
- "4 c #00CCFF",
- "5 c #330000",
- "6 c #330033",
- "7 c #333300",
- "8 c #333366",
- "9 c #660033",
- "A c #663300",
- "B c #666699",
- "C c #990066",
- "D c #993300",
- "E c #993399",
- "F c #996600",
- "G c #CC0099",
- "H c #CC3399",
- "I c #CC6600",
- "J c #CC9900",
- "K c #CC9933",
- "L c #CC99CC",
- "M c #FF0099",
- "N c #FF00CC",
- "O c #FF33CC",
- "P c #FF6699",
- "Q c #FF9900",
- "0 0 ",
- "000 00000 ",
- "00000 000 0 000 ",
- "00 000 0QQ 00",
- "0AQQ 0 Q0 QQ 0",
- "DIQQQ7JQQ 0 Q70",
- "50 7KP 0 QF0",
- "00 5MNN 0 QJA",
- "5CNNN9G NN044 0",
- "6EN 0 N04 4B6",
- "2344 1 40L OH8",
- "00 4424 440NNN81",
- "00 034 00 0",
- "000 0 000000 0",
- " 000000 000",
- " 00 00"};
-
-static char *map_x24[] = {
- "24 24 29 1",
- " c None",
- "0 c #000000",
- "1 c #003333",
- "2 c #003366",
- "3 c #006666",
- "4 c #006699",
- "5 c #0099CC",
- "6 c #00CCFF",
- "7 c #330000",
- "8 c #330033",
- "9 c #333300",
- "A c #336699",
- "B c #660033",
- "C c #660066",
- "D c #663300",
- "E c #6699CC",
- "F c #66CCFF",
- "G c #990066",
- "H c #996600",
- "I c #CC0099",
- "J c #CC3399",
- "K c #CC6600",
- "L c #FF0099",
- "M c #FF00CC",
- "N c #FF3399",
- "O c #FF33CC",
- "P c #FF66CC",
- "Q c #FF9900",
- "R c #FF9933",
- " ",
- " 00 000 ",
- " 0000 0000000 ",
- " 0 000 000 0 00 ",
- " 0 00000 DK 000 ",
- " 0 00 QDKQQ 00",
- " 0 QQ 0 Q7 QQ 00",
- " 9QQQQQ 0 Q 0 QQ 00",
- "HDQ QQ9QQQQ 0 Q 00",
- " 0 9QRN 0 Q 00",
- " 0 0MMMM 0 QQD0",
- " 0 8MMMMM 0 QQHD",
- " 0 MMMMLBM MMM0 666 00",
- " BMMMM I0 MMC46 66 00",
- " 1 0 MGE 6FB0",
- " 3666 0 FGJ MOG8",
- " 0 666662 66CIMMMMMA2",
- " 0 6516 66 0GMMM 00",
- " 0 0 66 00 00",
- " 00 0 00000 00",
- " 000 0 00 000 00",
- " 000 0 00 00000",
- " 00000 000",
- " 0 "};
-
-static char *map_x32[] = {
- "32 32 29 1",
- " c None",
- "0 c #000000",
- "1 c #006666",
- "2 c #006699",
- "3 c #0099CC",
- "4 c #00CCCC",
- "5 c #00CCFF",
- "6 c #330000",
- "7 c #333300",
- "8 c #333366",
- "9 c #663300",
- "A c #666699",
- "B c #66CCFF",
- "C c #990066",
- "D c #993399",
- "E c #996600",
- "F c #996699",
- "G c #9999CC",
- "H c #9999FF",
- "I c #CC0099",
- "J c #CC6600",
- "K c #CC66CC",
- "L c #CC9900",
- "M c #FF0099",
- "N c #FF00CC",
- "O c #FF33CC",
- "P c #FF6699",
- "Q c #FF9900",
- "R c #FF9933",
- " ",
- " 0 00 ",
- " 000 000000 ",
- " 0 000 00 00 000 ",
- " 0 000 00 00 000 ",
- " 0 000 00 EE 00 ",
- " 0 00000 JJQQ 00 ",
- " 0 00 QJEQQQQ 0 ",
- " 0 QQQ 0 QQE0 QQQQ 0 ",
- " 0 QQQQQQ 0 QQQ00 QQQ 0 ",
- " 9QQQQQQQQJ0 QQQQQ 00 QQ 0 ",
- " 7QQ QQLEQQQQQQ 00 QQ 0 ",
- " 0 LEQQRP 00 QQQ 0 ",
- " 0 6 NNNN 00 QQQ 0 ",
- " 0 6NNNNNN 00 QQQ0 ",
- " 0 ICNN NNNN 00 55 QQQ0 ",
- " 0 NNNNNNICN NNNN00 555 0 ",
- " 0MNNNNNNNI6 NNNC0555555 0 ",
- " 0MNN 0 NNIA55 5555 0 ",
- " 045 0 NIF5 55BK0 ",
- " 055555 0 HIIB KON0 ",
- " 03555555531 55DIN NNNOG0 ",
- " 0 55555325 55558CNNNNNN 0 ",
- " 0 55315555555 00NNNN 0 ",
- " 0 055555 00 0 ",
- " 00 0 55 0000 0 ",
- " 000 0 000 000 0 ",
- " 000 0 00 000 0 ",
- " 000 0 00 000 0 ",
- " 0000000 000 ",
- " 000 0 ",
- " "};
-
-static char **map_xpm[3] = { map_x16, map_x24, map_x32 };
-
diff --git a/app/bin/bitmaps/move.xpm b/app/bin/bitmaps/move.xpm deleted file mode 100644 index 5482a6b..0000000 --- a/app/bin/bitmaps/move.xpm +++ /dev/null @@ -1,119 +0,0 @@ -static char *move_x16[] = {
- "16 16 7 1",
- " c None",
- "0 c #000000",
- "1 c #0066CC",
- "2 c #0099FF",
- "3 c #CC0000",
- "4 c #CCCCCC",
- "5 c #808080",
- " 1 1 5 5 ",
- "21212 45454",
- " 1 1 5 5 ",
- "21212 45454",
- " 1 1 5 5 ",
- "21212 3 45454",
- " 1 1 33 5 5 ",
- "21212 333333 454",
- " 1 1 33 5 5 ",
- "21212 3 45454",
- " 1 1 5 5 ",
- "21212 45454",
- " 1 1 5 5 ",
- "21212 45454",
- " 1 1 5 5 ",
- " "};
-
-static char *move_x24[] = {
- "24 24 15 1",
- " c None",
- "0 c #000000",
- "1 c #006699",
- "2 c #009999",
- "3 c #0099CC",
- "4 c #00CCCC",
- "5 c #666666",
- "6 c #996666",
- "7 c #999999",
- "8 c #CC0000",
- "9 c #CC3333",
- "A c #CC6666",
- "B c #CC9999",
- "C c #C0C0C0",
- "D c #808080",
- " ",
- " 1 1 55 5 ",
- " 44144424 CD7CCD7C ",
- " 1 1 55 5 ",
- " 1 1 55 5 ",
- " 44144424 CD7CCD7C ",
- " 31 31 DD 5D ",
- " 1 1 55 5 ",
- " 44144314 B6DCCD7C ",
- " 4144314 A86CCD7 ",
- " 1 1 98 5 ",
- " 4147666888888AA89BD7 ",
- " 44147666988889A698BD7C ",
- " 1 1 988 5 ",
- " 31 31 A89 5D ",
- " 44144424 B67CCD7C ",
- " 1 1 55 5 ",
- " 1 1 55 5 ",
- " 44144424 CD7CCD7C ",
- " 1 1 55 5 ",
- " 1 1 55 5 ",
- " 44144424 CD7CCD7C ",
- " 31 31 DD 5D ",
- " 1 1 5 "};
-
-static char *move_x32[] = {
- "32 32 14 1",
- " c None",
- "0 c #000000",
- "1 c #006699",
- "2 c #0099CC",
- "3 c #00CCCC",
- "4 c #666666",
- "5 c #996666",
- "6 c #999999",
- "7 c #CC0000",
- "8 c #CC3333",
- "9 c #CC6666",
- "A c #CC9999",
- "B c #C0C0C0",
- "C c #808080",
- " ",
- " 1 1 4 4 ",
- " 1 12 4 46 ",
- " 3313333133 BB4BBBBC6B ",
- " 1 1 4 4 ",
- " 1 1 4 4 ",
- " 1 1 4 4 ",
- " 3313333133 BB4BBBBC6B ",
- " 1 1 4 4 ",
- " 1 1 4 4 ",
- " 1 1 4 4 ",
- " 3313333133 BA4BBBBC6B ",
- " 1 12 977A 46 ",
- " 1 1 777 4 ",
- " 1 1 877 4 ",
- " 331368777777777777777779B46B ",
- " 331367777777777777777778B46B ",
- " 1 1 877 4 ",
- " 1 1 777 4 ",
- " 1 1 77 4 ",
- " 3313333133 A95BBBBC6B ",
- " 1 1 4 4 ",
- " 1 1 4 4 ",
- " 1 1 4 4 ",
- " 3313333133 BB4BBBBC6B ",
- " 1 12 4 46 ",
- " 1 1 4 4 ",
- " 1 1 4 4 ",
- " 3313333133 BB4BBBB46B ",
- " 3313333133 BB4BBBB46B ",
- " 1 1 4 4 ",
- " "};
-
-static char **move_xpm[3] = { move_x16, move_x24, move_x32 };
-
diff --git a/app/bin/bitmaps/new-car.xpm b/app/bin/bitmaps/new-car.xpm deleted file mode 100644 index c2fd649..0000000 --- a/app/bin/bitmaps/new-car.xpm +++ /dev/null @@ -1,100 +0,0 @@ -static char *new_car_x16[] = {
- "16 16 5 1",
- " c None",
- "0 c #000000",
- "1 c #339900",
- "2 c #663300",
- "3 c #808080",
- " 11 ",
- " 11 ",
- " 111111 ",
- " 111111 ",
- " 11 ",
- " 11 ",
- " ",
- " 22222222222222 ",
- " 22222222222222 ",
- " 22222222222222 ",
- " 22222222222222 ",
- " 22222222222222 ",
- " 3 3 3 3 ",
- " 30303 30303 ",
- " 3 3 3 3 ",
- " "};
-
-static char *new_car_x24[] = {
- "24 24 6 1",
- " c None",
- "0 c #000000",
- "1 c #009933",
- "2 c #00CC33",
- "3 c #00FF66",
- "4 c #663300",
- " ",
- " 221 ",
- " 231 ",
- " 1231 ",
- " 222332221 ",
- " 233333331 ",
- " 11123111 ",
- " 1231 ",
- " 1231 ",
- " 11 ",
- " ",
- "444444444444444444444444",
- "444444444444444444444444",
- "444444444444444444444444",
- "444444444444444444444444",
- "444444444444444444444444",
- "444444444444444444444444",
- "444444444444444444444444",
- "444444444444444444444444",
- "444444444444444444444444",
- " 00 0 00 0 ",
- " 0000000 000 000 ",
- " 000 000 000 000 ",
- " 0 "};
-
-static char *new_car_x32[] = {
- "32 32 6 1",
- " c None",
- "0 c #000000",
- "1 c #009933",
- "2 c #00CC33",
- "3 c #00FF66",
- "4 c #663300",
- " ",
- " 11111 ",
- " 2331 ",
- " 2331 ",
- " 12331 ",
- " 111123321111 ",
- " 233333333331 ",
- " 233333333331 ",
- " 111123311111 ",
- " 12331 ",
- " 12331 ",
- " 2221 ",
- " 1111 ",
- " ",
- " ",
- "4444444444444444444444444444444 ",
- "4444444444444444444444444444444 ",
- "4444444444444444444444444444444 ",
- "4444444444444444444444444444444 ",
- "4444444444444444444444444444444 ",
- "4444444444444444444444444444444 ",
- "4444444444444444444444444444444 ",
- "4444444444444444444444444444444 ",
- "4444444444444444444444444444444 ",
- "4444444444444444444444444444444 ",
- "4444444444444444444444444444444 ",
- "4444444444444444444444444444444 ",
- " 00 000 00 00 ",
- " 00000000 00000000 ",
- " 00000000 00000000 ",
- " 000 000 000 000 ",
- " "};
-
-static char **new_car_xpm[3] = { new_car_x16, new_car_x24, new_car_x32 };
-
diff --git a/app/bin/bitmaps/ok.xpm b/app/bin/bitmaps/ok.xpm deleted file mode 100644 index 1671eae..0000000 --- a/app/bin/bitmaps/ok.xpm +++ /dev/null @@ -1,92 +0,0 @@ -static char *ok_x16[] = {
- "16 16 3 1",
- " c None",
- "0 c #000000",
- "1 c #008000",
- " ",
- " 1 ",
- " 11 ",
- " 111 ",
- " 1111 ",
- " 1111 ",
- " 1111 ",
- " 1111 ",
- " 1 1111 ",
- " 11 1111 ",
- " 1111111 ",
- " 111111 ",
- " 1111 ",
- " 111 ",
- " 1 ",
- " "};
-
-static char *ok_x24[] = {
- "24 24 3 1",
- " c None",
- "0 c #000000",
- "1 c #008000",
- " ",
- " ",
- " 1 ",
- " 1111 ",
- " 1111 ",
- " 1111 ",
- " 1111 ",
- " 11111 ",
- " 11111 ",
- " 11111 ",
- " 11111 ",
- " 11111 ",
- " 11111 ",
- " 11 11111 ",
- " 1111 11111 ",
- " 11111 11111 ",
- " 111111111 ",
- " 11111111 ",
- " 111111 ",
- " 1111 ",
- " 111 ",
- " 1 ",
- " ",
- " "};
-
-static char *ok_x32[] = {
- "32 32 3 1",
- " c None",
- "0 c #000000",
- "1 c #008000",
- " ",
- " ",
- " ",
- " 111 ",
- " 1111 ",
- " 11111 ",
- " 11111 ",
- " 11111 ",
- " 11111 ",
- " 11111 ",
- " 11111 ",
- " 11111 ",
- " 11111 ",
- " 11111 ",
- " 111111 ",
- " 111111 ",
- " 1111111 ",
- " 1 1111111 ",
- " 111 1111111 ",
- " 1111 1111111 ",
- " 11111 1111111 ",
- " 111111111111 ",
- " 11111111111 ",
- " 111111111 ",
- " 11111111 ",
- " 111111 ",
- " 11111 ",
- " 111 ",
- " 11 ",
- " ",
- " ",
- " "};
-
-static char **ok_xpm[3] = { ok_x16, ok_x24, ok_x32 };
-
diff --git a/app/bin/bitmaps/pan-zoom.xpm b/app/bin/bitmaps/pan-zoom.xpm deleted file mode 100644 index a42beee..0000000 --- a/app/bin/bitmaps/pan-zoom.xpm +++ /dev/null @@ -1,94 +0,0 @@ -static char *pan_zoom_x16[] = {
- "16 16 4 1",
- " c None",
- "0 c #000000",
- "1 c #FF0000",
- "2 c #FF3333",
- " ",
- " 11 ",
- " 1211 ",
- " 111111 ",
- " 11 ",
- " 1 11 1 ",
- " 11 11 11 ",
- " 11111111111111 ",
- " 11111111111111 ",
- " 11 11 11 ",
- " 1 11 1 ",
- " 11 ",
- " 122111 ",
- " 1111 ",
- " 11 ",
- " "};
-
-static char *pan_zoom_x24[] = {
- "24 24 4 1",
- " c None",
- "0 c #000000",
- "1 c #FF0000",
- "2 c #FF3333",
- " ",
- " ",
- " 11 ",
- " 1111 ",
- " 111111 ",
- " 11111211 ",
- " 11 ",
- " 11 ",
- " 1 11 1 ",
- " 11 11 11 ",
- " 111 11 111 ",
- " 11111111111111111111 ",
- " 11111111111111111111 ",
- " 111 11 111 ",
- " 11 11 11 ",
- " 1 11 1 ",
- " 11 ",
- " 11 ",
- " 11111111 ",
- " 111111 ",
- " 1111 ",
- " 11 ",
- " ",
- " "};
-
-static char *pan_zoom_x32[] = {
- "32 32 3 1",
- " c None",
- "0 c #000000",
- "1 c #CC0000",
- " ",
- " ",
- " 11 ",
- " 111111 ",
- " 1111111111 ",
- " 111111111111 ",
- " 1111 111 111 ",
- " 111 ",
- " 111 ",
- " 111 ",
- " 11 111 11 ",
- " 111 111 111 ",
- " 1111 111 1111 ",
- " 111 111 111 ",
- " 1111111111111111111111111111 ",
- " 11111111111111111111111111111 ",
- " 1111111111111111111111111111 ",
- " 111 111 111 ",
- " 1111 111 1111 ",
- " 111 111 111 ",
- " 11 111 111 ",
- " 111 ",
- " 111 ",
- " 111 ",
- " 111 111 1 ",
- " 1111 111 111 ",
- " 11111111111 ",
- " 111111111 ",
- " 11111 ",
- " 111 ",
- " ",
- " "};
-
-static char **pan_zoom_xpm[3] = { pan_zoom_x16, pan_zoom_x24, pan_zoom_x32 };
-
diff --git a/app/bin/bitmaps/parallel-line.xpm b/app/bin/bitmaps/parallel-line.xpm deleted file mode 100644 index b490c84..0000000 --- a/app/bin/bitmaps/parallel-line.xpm +++ /dev/null @@ -1,108 +0,0 @@ -static char *parallel_line_x16[] = {
- "16 16 4 1",
- " c None",
- "0 c #000000",
- "1 c #CC0000",
- "2 c #CC9966",
- " ",
- "000000000000000 ",
- " ",
- " 1 ",
- " 111 ",
- " 11111 ",
- " 1 ",
- " 1 ",
- " 1 ",
- " 2 2 2 2 2 2 ",
- "000000000000000 ",
- " 2 2 2 2 2 2 2 ",
- " 2 2 2 2 2 2 2 ",
- "000000000000000 ",
- " 2 2 2 2 2 2 2 ",
- " "};
-
-static char *parallel_line_x24[] = {
- "24 24 11 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #663300",
- "4 c #666666",
- "5 c #996600",
- "6 c #CC0000",
- "7 c #CC3300",
- "8 c #CC6600",
- "9 c #CC9900",
- " ",
- " ",
- " ",
- " 4444444444444444444444 ",
- " ",
- " 66 ",
- " 6666 ",
- " 6666 6 ",
- " 66 ",
- " 66 ",
- " 66 ",
- " 66 ",
- " 66 ",
- " 7 ",
- " 9 9 99 99 9 9 9 ",
- " 0000000000000000000000 ",
- " 9 9 99 99 9 9 9 ",
- " 9 9 99 99 9 9 9 ",
- " 9 9 99 99 9 9 9 ",
- " 0300320320230230130031 ",
- " 8 85 85 58 58 38 83 ",
- " 9 9 9 9 9 9 9 ",
- " ",
- " "};
-
-static char *parallel_line_x32[] = {
- "32 32 10 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #663300",
- "4 c #666666",
- "5 c #996600",
- "6 c #CC0000",
- "7 c #CC6600",
- "8 c #CC9900",
- " ",
- " ",
- " ",
- " ",
- " 444444444444444444444444444444 ",
- " ",
- " ",
- " 66 ",
- " 6666 ",
- " 66 6 66 ",
- " 6 6 6 ",
- " 6 ",
- " 6 ",
- " 6 ",
- " 6 ",
- " 6 ",
- " 6 ",
- " 6 ",
- " ",
- " 88 88 88 88 88 88 88 ",
- " 000000000000000000000000000000 ",
- " 88 88 88 88 88 88 88 ",
- " 88 88 88 88 88 88 88 ",
- " 88 88 88 88 88 88 88 ",
- " 88 88 88 88 88 88 88 ",
- " 575 575 77 77 573 575 377 ",
- " 033202330033003300331023201330 ",
- " 88 88 88 88 88 88 88 ",
- " ",
- " ",
- " ",
- " "};
-
-static char **parallel_line_xpm[3] = { parallel_line_x16, parallel_line_x24, parallel_line_x32 };
-
diff --git a/app/bin/bitmaps/parallel.xpm b/app/bin/bitmaps/parallel.xpm deleted file mode 100644 index a19f797..0000000 --- a/app/bin/bitmaps/parallel.xpm +++ /dev/null @@ -1,116 +0,0 @@ -static char *parallel_x16[] = {
- "16 16 6 1",
- " c None",
- "0 c #000000",
- "1 c #CC0000",
- "2 c #CC9966",
- "3 c #CCCCCC",
- "4 c #808080",
- " 3 3 3 3 3 3 3 ",
- "444444444444444 ",
- " 3 3 3 3 3 3 3 ",
- " 3 3 3 3 3 3 3 ",
- "4444444 4444444 ",
- " 3 3 3 1 3 3 3 ",
- " 111 ",
- " 11111 ",
- " 1 ",
- " 1 ",
- " 2 2 2 1 2 2 2 ",
- "0000000 0000000 ",
- " 2 2 2 2 2 2 2 ",
- " 2 2 2 2 2 2 2 ",
- "000000000000000 ",
- " 2 2 2 2 2 2 2 "};
-
-static char *parallel_x24[] = {
- "24 24 14 1",
- " c None",
- "0 c #000000",
- "1 c #333300",
- "2 c #663300",
- "3 c #666666",
- "4 c #996600",
- "5 c #999999",
- "6 c #CC0000",
- "7 c #CC3300",
- "8 c #CC6600",
- "9 c #CC9900",
- "A c #CC9999",
- "B c #C0C0C0",
- "C c #808080",
- " B B B ",
- " 55 5 5C 55 C5 5C 55 ",
- "3CC33C33C33CC33C33C33CC3",
- " BB B B BB B B BB ",
- " BB B B BB B B BB ",
- " BB B B BB B B BB ",
- "3CC33C33C33CC33C33C33CC3",
- " 55 5 5C 55 C5 5C 55 ",
- " B B B AA B B ",
- " 666 ",
- " 666666 ",
- " 666666 ",
- " 66 ",
- " 66 ",
- " 66 ",
- " 77 ",
- " 99 9 9 99 9 9 99 ",
- "000000000000000000000000",
- " 99 9 9 99 9 9 99 ",
- " 99 9 9 99 9 9 99 ",
- " 99 9 9 99 9 9 99 ",
- " 2400400420440140041044 ",
- " 2400400420440140041044 ",
- " 9 9 9 99 9 9 99 "};
-
-static char *parallel_x32[] = {
- "32 32 13 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #663300",
- "4 c #666666",
- "5 c #996600",
- "6 c #999999",
- "7 c #CC0000",
- "8 c #CC6600",
- "9 c #CC9900",
- "A c #C0C0C0",
- "B c #808080",
- " ",
- " AA AA AA AA AAA AA AA ",
- " 46B44B6B4B6B446644B6B446B44B6B ",
- " 46B44B6B4B6B446644B6B446B44B6B ",
- " AA AA AA AA AAA AA AA ",
- " AA AA AA AA AAA AA AA ",
- " AA AA AA AA AAA AA AA ",
- " AA AA AA AA AAA AA AA ",
- " 46B44B6B4B6B446644B6B446B44B6B ",
- " 46B44B6B4B6B446644B6B446B44B6B ",
- " AA AA AA AA AAA AA AA ",
- " ",
- " 7777 ",
- " 777777 ",
- " 77777777 ",
- " 77 77 777 ",
- " 77 ",
- " 77 ",
- " 77 ",
- " 77 ",
- " 77 ",
- " 99 99 9 99 9 99 99 ",
- " 88 883 585 88 585 88 883 ",
- " 0330033102330033002320033003310",
- " 99 99 99 99 999 99 99 ",
- " 99 99 99 99 999 99 99 ",
- " 99 99 99 99 999 99 99 ",
- " 99 99 99 99 999 99 99 ",
- " 88 883 585 88 585 88 883 ",
- " 0330033102330033002320033003310",
- " 99 99 99 99 999 99 99 ",
- " "};
-
-static char **parallel_xpm[3] = { parallel_x16, parallel_x24, parallel_x32 };
-
diff --git a/app/bin/bitmaps/parameter.xpm b/app/bin/bitmaps/parameter.xpm deleted file mode 100644 index 7a58a6f..0000000 --- a/app/bin/bitmaps/parameter.xpm +++ /dev/null @@ -1,104 +0,0 @@ -static char *parameter_x16[] = {
- "16 16 3 1",
- " c None",
- "0 c #000000",
- "1 c #999999",
- " 11111111111 ",
- " 1 11 ",
- " 1 11 ",
- " 1 00000000 11 ",
- " 1 1 ",
- " 1 0 1 ",
- " 1 00 1 ",
- " 1 00 1 ",
- " 1 000 1 ",
- " 1 1 ",
- " 1 00000000 1 ",
- " 1 00 1 ",
- " 1 00 1 ",
- " 1 00 1 ",
- " 1 1 ",
- " 11111111111111 "};
-
-static char *parameter_x24[] = {
- "24 24 9 1",
- " c None",
- "0 c #000000",
- "1 c #333333",
- "2 c #666666",
- "3 c #999999",
- "4 c #CCCCCC",
- "5 c #FFFFFF",
- "6 c #C0C0C0",
- "7 c #808080",
- " 7777777777777777 ",
- " 234444444444444447 ",
- " 2355555555555555537 ",
- " 2355100000000000757 ",
- " 23555555555555555557 ",
- " 235555555555555445547 ",
- " 2355555555555437455537 ",
- " 2355555555432745555547 ",
- " 2355377202765555555547 ",
- " 2355544555555555555547 ",
- " 2355455555555555555547 ",
- " 2355323455555472455547 ",
- " 2355554724532345555547 ",
- " 355555562074555555547 ",
- " 355556234547745555547 ",
- " 355323555555432455547 ",
- " 355455555555555555547 ",
- " 355466336666666455547 ",
- " 355666321366666655547 ",
- " 355555555326555555547 ",
- " 355555555553265555547 ",
- " 355555555555562455547 ",
- " 355555555555555555547 ",
- " 222222222222222222227 "};
-
-static char *parameter_x32[] = {
- "32 32 9 1",
- " c None",
- "0 c #000000",
- "1 c #333333",
- "2 c #666666",
- "3 c #999999",
- "4 c #CCCCCC",
- "5 c #FFFFFF",
- "6 c #C0C0C0",
- "7 c #808080",
- " 222222222222222222222 ",
- " 73666666666666666666637 ",
- " 74555555555555555555557 ",
- " 745555555555555555555547 ",
- " 7455500000000000000004547 ",
- " 74555777777777777777745537 ",
- " 74555555555555555555555557 ",
- " 745555555555555555547555557 ",
- " 7455555555555555547004555547 ",
- " 7455555555555543100355555557 ",
- " 7455554666637000265555555557 ",
- " 7455530000001765555555555557 ",
- " 7455546444455555555555555557 ",
- " 7455555555555555555555555557 ",
- " 7455537455555555554375555557 ",
- " 7455531023555555420075555557 ",
- " 7455555420074431013555555557 ",
- " 7455555554300007455555555557 ",
- " 7455555553101100345555555557 ",
- " 7455554700245547002655555557 ",
- " 7455570134555555532015555557 ",
- " 7455544555555555555465555557 ",
- " 7455555555555555555555555557 ",
- " 7455537777227777777774555557 ",
- " 7455570000000000000006555557 ",
- " 7455555555531016555555555557 ",
- " 7455555555555610135555555557 ",
- " 7455555555555556200345555557 ",
- " 7455555555555555542005555557 ",
- " 7455555555555555555435555557 ",
- " 7644444444444444444444444447 ",
- " 7777777777777777777777777777 "};
-
-static char **parameter_xpm[3] = { parameter_x16, parameter_x24, parameter_x32 };
-
diff --git a/app/bin/bitmaps/paste.xpm b/app/bin/bitmaps/paste.xpm deleted file mode 100644 index c820a4e..0000000 --- a/app/bin/bitmaps/paste.xpm +++ /dev/null @@ -1,107 +0,0 @@ -static char *paste_x16[] = {
- "16 16 8 1",
- " c None",
- "0 c #000000",
- "1 c #666666",
- "2 c #999999",
- "3 c #CCCCCC",
- "4 c #FFFFFF",
- "5 c #C0C0C0",
- "6 c #808080",
- " 6116 ",
- " 666623326666 ",
- "63333222233356 ",
- "6444411111111111",
- "6444144444444441",
- "6444144444444441",
- "6444144444444441",
- "6444144444444441",
- "6444144444444441",
- "6444144444444441",
- "6444144444444441",
- "6444144444444441",
- "6444144444444441",
- "6444144444444441",
- "6255144444444441",
- " 111111111111111"};
-
-static char *paste_x24[] = {
- "24 24 8 1",
- " c None",
- "0 c #000000",
- "1 c #666666",
- "2 c #999999",
- "3 c #CCCCCC",
- "4 c #FFFFFF",
- "5 c #C0C0C0",
- "6 c #808080",
- " 66666 ",
- " 6533336 ",
- " 6111111333336111166 ",
- "12444444522224444441 ",
- "15444444444444444446 ",
- "15444441111111111111111 ",
- "154444144444444444444441",
- "154444144444444444444441",
- "154444144444444444444441",
- "154444144444444444444441",
- "154444144444444444444441",
- "154444144444444444444441",
- "154444144444444444444441",
- "154444144444444444444441",
- "154444144444444444444441",
- "154444144444444444444441",
- "154444144444444444444441",
- "154444144444444444444441",
- "154444144444444444444441",
- "154444144444444444444441",
- "154444144444444444444441",
- "124444144444444444444441",
- " 61111144444444444444441",
- " 1111111111111111 "};
-
-static char *paste_x32[] = {
- "32 32 8 1",
- " c None",
- "0 c #000000",
- "1 c #666666",
- "2 c #999999",
- "3 c #CCCCCC",
- "4 c #FFFFFF",
- "5 c #C0C0C0",
- "6 c #808080",
- " 111111 ",
- " 62555556 ",
- " 6244444436 ",
- " 6622222266333333662222266 ",
- " 64444444442222223444444451 ",
- " 64444444444444444444444436 ",
- " 24444444444444444444444436 ",
- " 244444441111111111111111111111 ",
- " 244444441444444444444444444441 ",
- " 244444441444444444444444444441 ",
- " 244444441444444444444444444441 ",
- " 244444441444444444444444444441 ",
- " 244444441444444444444444444441 ",
- " 244444441444444444444444444441 ",
- " 244444441444444444444444444441 ",
- " 244444441444444444444444444441 ",
- " 244444441444444444444444444441 ",
- " 244444441444444444444444444441 ",
- " 244444441444444444444444444441 ",
- " 244444441444444444444444444441 ",
- " 244444441444444444444444444441 ",
- " 244444441444444444444444444441 ",
- " 244444441444444444444444444441 ",
- " 244444441444444444444444444441 ",
- " 244444441444444444444444444441 ",
- " 244444441444444444444444444441 ",
- " 244444441444444444444444444441 ",
- " 244444441444444444444444444441 ",
- " 644444441444444444444444444441 ",
- " 665555551444444444444444444441 ",
- " 1111111444444444444444444441 ",
- " 1111111111111111111111 "};
-
-static char **paste_xpm[3] = { paste_x16, paste_x24, paste_x32 };
-
diff --git a/app/bin/bitmaps/16pix/circle-center.png b/app/bin/bitmaps/png/circle-center16.png Binary files differindex 062560d..062560d 100644 --- a/app/bin/bitmaps/16pix/circle-center.png +++ b/app/bin/bitmaps/png/circle-center16.png diff --git a/app/bin/bitmaps/16pix/circle-tangent.png b/app/bin/bitmaps/png/circle-tangent16.png Binary files differindex 0dc831b..0dc831b 100644 --- a/app/bin/bitmaps/16pix/circle-tangent.png +++ b/app/bin/bitmaps/png/circle-tangent16.png diff --git a/app/bin/bitmaps/16pix/circle.png b/app/bin/bitmaps/png/circle16.png Binary files differindex eaecd31..eaecd31 100644 --- a/app/bin/bitmaps/16pix/circle.png +++ b/app/bin/bitmaps/png/circle16.png diff --git a/app/bin/bitmaps/16pix/curved-chord.png b/app/bin/bitmaps/png/curved-chord16.png Binary files differindex 0068d1a..0068d1a 100644 --- a/app/bin/bitmaps/16pix/curved-chord.png +++ b/app/bin/bitmaps/png/curved-chord16.png diff --git a/app/bin/bitmaps/16pix/curved-end.png b/app/bin/bitmaps/png/curved-end16.png Binary files differindex 49dcee3..49dcee3 100644 --- a/app/bin/bitmaps/16pix/curved-end.png +++ b/app/bin/bitmaps/png/curved-end16.png diff --git a/app/bin/bitmaps/16pix/curved-middle.png b/app/bin/bitmaps/png/curved-middle16.png Binary files differindex d23a6a2..d23a6a2 100644 --- a/app/bin/bitmaps/16pix/curved-middle.png +++ b/app/bin/bitmaps/png/curved-middle16.png diff --git a/app/bin/bitmaps/16pix/curved-tangent.png b/app/bin/bitmaps/png/curved-tangent16.png Binary files differindex 6d8fcfe..6d8fcfe 100644 --- a/app/bin/bitmaps/16pix/curved-tangent.png +++ b/app/bin/bitmaps/png/curved-tangent16.png diff --git a/app/bin/bitmaps/16pix/description.png b/app/bin/bitmaps/png/description16.png Binary files differindex 9bd679c..9bd679c 100644 --- a/app/bin/bitmaps/16pix/description.png +++ b/app/bin/bitmaps/png/description16.png diff --git a/app/bin/bitmaps/24pix/description.png b/app/bin/bitmaps/png/description24.png Binary files differindex e273ed5..e273ed5 100644 --- a/app/bin/bitmaps/24pix/description.png +++ b/app/bin/bitmaps/png/description24.png diff --git a/app/bin/bitmaps/png/down16.png b/app/bin/bitmaps/png/down16.png Binary files differnew file mode 100644 index 0000000..e272de2 --- /dev/null +++ b/app/bin/bitmaps/png/down16.png diff --git a/app/bin/bitmaps/png/down24.png b/app/bin/bitmaps/png/down24.png Binary files differnew file mode 100644 index 0000000..0b72634 --- /dev/null +++ b/app/bin/bitmaps/png/down24.png diff --git a/app/bin/bitmaps/png/ease-broad16.png b/app/bin/bitmaps/png/ease-broad16.png Binary files differnew file mode 100644 index 0000000..f2bd685 --- /dev/null +++ b/app/bin/bitmaps/png/ease-broad16.png diff --git a/app/bin/bitmaps/png/ease-broad24.png b/app/bin/bitmaps/png/ease-broad24.png Binary files differnew file mode 100644 index 0000000..bf29e0f --- /dev/null +++ b/app/bin/bitmaps/png/ease-broad24.png diff --git a/app/bin/bitmaps/png/ease-broad32.png b/app/bin/bitmaps/png/ease-broad32.png Binary files differnew file mode 100644 index 0000000..43e45ea --- /dev/null +++ b/app/bin/bitmaps/png/ease-broad32.png diff --git a/app/bin/bitmaps/png/ease-cornu16.png b/app/bin/bitmaps/png/ease-cornu16.png Binary files differnew file mode 100644 index 0000000..acdd269 --- /dev/null +++ b/app/bin/bitmaps/png/ease-cornu16.png diff --git a/app/bin/bitmaps/png/ease-cornu24.png b/app/bin/bitmaps/png/ease-cornu24.png Binary files differnew file mode 100644 index 0000000..e64ea53 --- /dev/null +++ b/app/bin/bitmaps/png/ease-cornu24.png diff --git a/app/bin/bitmaps/png/ease-cornu32.png b/app/bin/bitmaps/png/ease-cornu32.png Binary files differnew file mode 100644 index 0000000..a5e0d29 --- /dev/null +++ b/app/bin/bitmaps/png/ease-cornu32.png diff --git a/app/bin/bitmaps/png/ease-gt-broad16.png b/app/bin/bitmaps/png/ease-gt-broad16.png Binary files differnew file mode 100644 index 0000000..715e2dd --- /dev/null +++ b/app/bin/bitmaps/png/ease-gt-broad16.png diff --git a/app/bin/bitmaps/png/ease-gt-broad24.png b/app/bin/bitmaps/png/ease-gt-broad24.png Binary files differnew file mode 100644 index 0000000..1db1640 --- /dev/null +++ b/app/bin/bitmaps/png/ease-gt-broad24.png diff --git a/app/bin/bitmaps/png/ease-gt-broad32.png b/app/bin/bitmaps/png/ease-gt-broad32.png Binary files differnew file mode 100644 index 0000000..f7ae18e --- /dev/null +++ b/app/bin/bitmaps/png/ease-gt-broad32.png diff --git a/app/bin/bitmaps/png/ease-gt-sharp16.png b/app/bin/bitmaps/png/ease-gt-sharp16.png Binary files differnew file mode 100644 index 0000000..b642ad5 --- /dev/null +++ b/app/bin/bitmaps/png/ease-gt-sharp16.png diff --git a/app/bin/bitmaps/png/ease-gt-sharp24.png b/app/bin/bitmaps/png/ease-gt-sharp24.png Binary files differnew file mode 100644 index 0000000..1d45db8 --- /dev/null +++ b/app/bin/bitmaps/png/ease-gt-sharp24.png diff --git a/app/bin/bitmaps/png/ease-gt-sharp32.png b/app/bin/bitmaps/png/ease-gt-sharp32.png Binary files differnew file mode 100644 index 0000000..a33306c --- /dev/null +++ b/app/bin/bitmaps/png/ease-gt-sharp32.png diff --git a/app/bin/bitmaps/png/ease-lt-broad16.png b/app/bin/bitmaps/png/ease-lt-broad16.png Binary files differnew file mode 100644 index 0000000..7343b9e --- /dev/null +++ b/app/bin/bitmaps/png/ease-lt-broad16.png diff --git a/app/bin/bitmaps/png/ease-lt-broad24.png b/app/bin/bitmaps/png/ease-lt-broad24.png Binary files differnew file mode 100644 index 0000000..3154ae1 --- /dev/null +++ b/app/bin/bitmaps/png/ease-lt-broad24.png diff --git a/app/bin/bitmaps/png/ease-lt-broad32.png b/app/bin/bitmaps/png/ease-lt-broad32.png Binary files differnew file mode 100644 index 0000000..862fedc --- /dev/null +++ b/app/bin/bitmaps/png/ease-lt-broad32.png diff --git a/app/bin/bitmaps/png/ease-lt-sharp16.png b/app/bin/bitmaps/png/ease-lt-sharp16.png Binary files differnew file mode 100644 index 0000000..a4e7a12 --- /dev/null +++ b/app/bin/bitmaps/png/ease-lt-sharp16.png diff --git a/app/bin/bitmaps/png/ease-lt-sharp24.png b/app/bin/bitmaps/png/ease-lt-sharp24.png Binary files differnew file mode 100644 index 0000000..100756d --- /dev/null +++ b/app/bin/bitmaps/png/ease-lt-sharp24.png diff --git a/app/bin/bitmaps/png/ease-lt-sharp32.png b/app/bin/bitmaps/png/ease-lt-sharp32.png Binary files differnew file mode 100644 index 0000000..557e3a1 --- /dev/null +++ b/app/bin/bitmaps/png/ease-lt-sharp32.png diff --git a/app/bin/bitmaps/png/ease-none16.png b/app/bin/bitmaps/png/ease-none16.png Binary files differnew file mode 100644 index 0000000..70bbadf --- /dev/null +++ b/app/bin/bitmaps/png/ease-none16.png diff --git a/app/bin/bitmaps/png/ease-none24.png b/app/bin/bitmaps/png/ease-none24.png Binary files differnew file mode 100644 index 0000000..35cc7d9 --- /dev/null +++ b/app/bin/bitmaps/png/ease-none24.png diff --git a/app/bin/bitmaps/png/ease-none32.png b/app/bin/bitmaps/png/ease-none32.png Binary files differnew file mode 100644 index 0000000..93db06f --- /dev/null +++ b/app/bin/bitmaps/png/ease-none32.png diff --git a/app/bin/bitmaps/png/ease-normal16.png b/app/bin/bitmaps/png/ease-normal16.png Binary files differnew file mode 100644 index 0000000..1051cc6 --- /dev/null +++ b/app/bin/bitmaps/png/ease-normal16.png diff --git a/app/bin/bitmaps/png/ease-normal24.png b/app/bin/bitmaps/png/ease-normal24.png Binary files differnew file mode 100644 index 0000000..e8c7136 --- /dev/null +++ b/app/bin/bitmaps/png/ease-normal24.png diff --git a/app/bin/bitmaps/png/ease-normal32.png b/app/bin/bitmaps/png/ease-normal32.png Binary files differnew file mode 100644 index 0000000..6dde86d --- /dev/null +++ b/app/bin/bitmaps/png/ease-normal32.png diff --git a/app/bin/bitmaps/png/ease-sharp16.png b/app/bin/bitmaps/png/ease-sharp16.png Binary files differnew file mode 100644 index 0000000..5c79b51 --- /dev/null +++ b/app/bin/bitmaps/png/ease-sharp16.png diff --git a/app/bin/bitmaps/png/ease-sharp24.png b/app/bin/bitmaps/png/ease-sharp24.png Binary files differnew file mode 100644 index 0000000..537050e --- /dev/null +++ b/app/bin/bitmaps/png/ease-sharp24.png diff --git a/app/bin/bitmaps/png/ease-sharp32.png b/app/bin/bitmaps/png/ease-sharp32.png Binary files differnew file mode 100644 index 0000000..48c7d39 --- /dev/null +++ b/app/bin/bitmaps/png/ease-sharp32.png diff --git a/app/bin/bitmaps/16pix/elevation.png b/app/bin/bitmaps/png/elevation16.png Binary files differindex 9121d56..9121d56 100644 --- a/app/bin/bitmaps/16pix/elevation.png +++ b/app/bin/bitmaps/png/elevation16.png diff --git a/app/bin/bitmaps/16pix/exit.png b/app/bin/bitmaps/png/exit16.png Binary files differindex ba227c3..ba227c3 100644 --- a/app/bin/bitmaps/16pix/exit.png +++ b/app/bin/bitmaps/png/exit16.png diff --git a/app/bin/bitmaps/24pix/exit.png b/app/bin/bitmaps/png/exit24.png Binary files differindex d3ebf2f..d3ebf2f 100644 --- a/app/bin/bitmaps/24pix/exit.png +++ b/app/bin/bitmaps/png/exit24.png diff --git a/app/bin/bitmaps/png/extend16.png b/app/bin/bitmaps/png/extend16.png Binary files differnew file mode 100644 index 0000000..957c8f4 --- /dev/null +++ b/app/bin/bitmaps/png/extend16.png diff --git a/app/bin/bitmaps/16pix/palette.png b/app/bin/bitmaps/png/palette.png Binary files differindex efcf3d3..efcf3d3 100644 --- a/app/bin/bitmaps/16pix/palette.png +++ b/app/bin/bitmaps/png/palette.png diff --git a/app/bin/bitmaps/16pix/pan-zoom.png b/app/bin/bitmaps/png/pan-zoom16.png Binary files differindex 04d18f7..04d18f7 100644 --- a/app/bin/bitmaps/16pix/pan-zoom.png +++ b/app/bin/bitmaps/png/pan-zoom16.png diff --git a/app/bin/bitmaps/24pix/pan-zoom.png b/app/bin/bitmaps/png/pan-zoom24.png Binary files differindex 67ab631..67ab631 100644 --- a/app/bin/bitmaps/24pix/pan-zoom.png +++ b/app/bin/bitmaps/png/pan-zoom24.png diff --git a/app/bin/bitmaps/png/ruler16.png b/app/bin/bitmaps/png/ruler16.png Binary files differnew file mode 100644 index 0000000..ec94bf3 --- /dev/null +++ b/app/bin/bitmaps/png/ruler16.png diff --git a/app/bin/bitmaps/16pix/select.png b/app/bin/bitmaps/png/select16.png Binary files differindex 39605d1..39605d1 100644 --- a/app/bin/bitmaps/16pix/select.png +++ b/app/bin/bitmaps/png/select16.png diff --git a/app/bin/bitmaps/16pix/snap-curs.png b/app/bin/bitmaps/png/snap-curs16.png Binary files differindex acf8f66..acf8f66 100644 --- a/app/bin/bitmaps/16pix/snap-curs.png +++ b/app/bin/bitmaps/png/snap-curs16.png diff --git a/app/bin/bitmaps/24pix/snap-curs.png b/app/bin/bitmaps/png/snap-curs24.png Binary files differindex 15154a2..15154a2 100644 --- a/app/bin/bitmaps/24pix/snap-curs.png +++ b/app/bin/bitmaps/png/snap-curs24.png diff --git a/app/bin/bitmaps/16pix/snap-grid.png b/app/bin/bitmaps/png/snap-grid16.png Binary files differindex 381b451..381b451 100644 --- a/app/bin/bitmaps/16pix/snap-grid.png +++ b/app/bin/bitmaps/png/snap-grid16.png diff --git a/app/bin/bitmaps/24pix/snap-grid.png b/app/bin/bitmaps/png/snap-grid24.png Binary files differindex 3073985..3073985 100644 --- a/app/bin/bitmaps/24pix/snap-grid.png +++ b/app/bin/bitmaps/png/snap-grid24.png diff --git a/app/bin/bitmaps/png/straight16.png b/app/bin/bitmaps/png/straight16.png Binary files differnew file mode 100644 index 0000000..d96aff7 --- /dev/null +++ b/app/bin/bitmaps/png/straight16.png diff --git a/app/bin/bitmaps/png/turntable16.png b/app/bin/bitmaps/png/turntable16.png Binary files differnew file mode 100644 index 0000000..181abf3 --- /dev/null +++ b/app/bin/bitmaps/png/turntable16.png diff --git a/app/bin/bitmaps/polygon.xpm b/app/bin/bitmaps/polygon.xpm deleted file mode 100644 index cce796a..0000000 --- a/app/bin/bitmaps/polygon.xpm +++ /dev/null @@ -1,89 +0,0 @@ -static char *polygon_x16[] = {
- "16 16 2 1",
- " c None",
- "0 c #000000",
- " ",
- " 000000000 ",
- " 000 00 ",
- " 00 00 ",
- " 0 00 ",
- " 0 00 ",
- "00 00",
- " 0 00",
- " 0 00",
- " 00 00",
- " 0 00",
- " 0 00",
- " 000 00",
- " 000 000",
- " 000000000 ",
- " 00 "};
-
-static char *polygon_x24[] = {
- "24 24 2 1",
- " c None",
- "0 c #000000",
- " ",
- " 00000 ",
- " 0000000000 00 ",
- " 000 00 ",
- " 0 0 ",
- " 00 0 ",
- " 0 0 ",
- " 00 0 ",
- " 00 0 ",
- " 0 0 ",
- " 0 0 ",
- " 00 0 ",
- " 0 0 ",
- " 0 0 ",
- " 00 0 ",
- " 0 0 ",
- " 0 0 ",
- " 00 0 ",
- " 00 0 ",
- " 00 0 ",
- " 000 0000 ",
- " 000 000000 ",
- " 000000 ",
- " "};
-
-static char *polygon_x32[] = {
- "32 32 2 1",
- " c None",
- "0 c #000000",
- " ",
- " 000 ",
- " 000000000000 ",
- " 00000000000000 000 ",
- " 000000 000 ",
- " 000 000 ",
- " 00 000 ",
- " 00 00 ",
- " 000 000 ",
- " 00 000 ",
- " 00 000 ",
- " 00 000 ",
- " 00 000 ",
- " 00 00 ",
- " 000 00 ",
- " 00 00 ",
- " 00 00 ",
- " 000 00 ",
- " 00 00 ",
- " 00 00 ",
- " 000 00 ",
- " 00 00 ",
- " 00 00 ",
- " 000 00 ",
- " 0000 00 ",
- " 00000 00 ",
- " 0000 00 ",
- " 0000 0000000 ",
- " 0000 0000000000 ",
- " 00000000000 ",
- " 0000 ",
- " "};
-
-static char **polygon_xpm[3] = { polygon_x16, polygon_x24, polygon_x32 };
-
diff --git a/app/bin/bitmaps/polyline.xpm b/app/bin/bitmaps/polyline.xpm deleted file mode 100644 index 6611f44..0000000 --- a/app/bin/bitmaps/polyline.xpm +++ /dev/null @@ -1,92 +0,0 @@ -static char *polyline_x16[] = {
- "16 16 3 1",
- " c None",
- "0 c #000000",
- "1 c #0000FF",
- " ",
- " 1 ",
- " 1 1 ",
- "11111 11 ",
- " 1 1111 11 ",
- " 1 11 1 ",
- " 1 11",
- " 11 11",
- " 11 11",
- " 1 1 ",
- " 11 11 ",
- " 11 1 ",
- " 11 11 ",
- " 1 11111 ",
- " 11111 ",
- " "};
-
-static char *polyline_x24[] = {
- "24 24 3 1",
- " c None",
- "0 c #000000",
- "1 c #0000FF",
- " ",
- " ",
- " 1 ",
- " 11 ",
- " 111 1 ",
- " 111111 11 ",
- " 11 1111 11 ",
- " 11 1111 1 ",
- " 1 1 11 ",
- " 1 11 ",
- " 1 1 ",
- " 11 1 ",
- " 11 1 ",
- " 1 11 ",
- " 1 1 ",
- " 1 11 ",
- " 1 1 ",
- " 11 11 ",
- " 11 1 ",
- " 11 1 ",
- " 1 111111 ",
- " 111111 ",
- " ",
- " "};
-
-static char *polyline_x32[] = {
- "32 32 3 1",
- " c None",
- "0 c #000000",
- "1 c #0000FF",
- " ",
- " ",
- " ",
- " 11 ",
- " 111 ",
- " 111 11 ",
- " 111111 11 ",
- " 111111111 11 ",
- " 11 11111 11 ",
- " 11 111111 11 ",
- " 11 1111 11 ",
- " 11 1 11 ",
- " 11 11 ",
- " 11 11 ",
- " 11 11 ",
- " 11 11 ",
- " 11 11 ",
- " 11 11 ",
- " 11 11 ",
- " 11 111 ",
- " 11 11 ",
- " 111 111 ",
- " 111 11 ",
- " 111 11 ",
- " 11 11 ",
- " 11 11 ",
- " 11 1111 ",
- " 111 1111111111 ",
- " 1111111111 ",
- " 11 ",
- " ",
- " "};
-
-static char **polyline_xpm[3] = { polyline_x16, polyline_x24, polyline_x32 };
-
diff --git a/app/bin/bitmaps/profile.xpm b/app/bin/bitmaps/profile.xpm deleted file mode 100644 index d446bb4..0000000 --- a/app/bin/bitmaps/profile.xpm +++ /dev/null @@ -1,121 +0,0 @@ -static char *profile_x16[] = {
- "16 16 12 1",
- " c None",
- "0 c #000000",
- "1 c #003333",
- "2 c #333333",
- "3 c #336666",
- "4 c #336699",
- "5 c #339999",
- "6 c #669999",
- "7 c #6699CC",
- "8 c #66CCCC",
- "9 c #66CCFF",
- "A c #99CCFF",
- " ",
- " 0 ",
- " 262 ",
- " 05A71 ",
- " 05A92 20120 ",
- "004AA82238A98300",
- " 05AAA58AAAAA50 ",
- "005AAAAAAAAAA500",
- "004AAAAAAAAAA400",
- " 05AAAAAAAAAA50 ",
- "004AAAAAAAAAA400",
- " 05AAAAAAAAAA50 ",
- " 00000000000000 ",
- " 0 00 0 0 0 ",
- " 0 0 0 ",
- " "};
-
-static char *profile_x24[] = {
- "24 24 13 1",
- " c None",
- "0 c #000000",
- "1 c #003333",
- "2 c #333333",
- "3 c #333366",
- "4 c #336666",
- "5 c #336699",
- "6 c #339999",
- "7 c #669999",
- "8 c #6699CC",
- "9 c #66CCCC",
- "A c #66CCFF",
- "B c #99CCFF",
- " ",
- " ",
- " 0 ",
- " 1481 ",
- " 04AB81 ",
- " 06BBA4 ",
- " 06BBB92 11210 ",
- " 006BBBB50 128AA8630000",
- "0006BBBBA3128ABBBBBB5000",
- " 06BBBBB87ABBBBBBBB60 ",
- " 06BBBBBBBBBBBBBBBB60 ",
- " 006BBBBBBBBBBBBBBBB5000",
- " 006BBBBBBBBBBBBBBBB5000",
- " 06BBBBBBBBBBBBBBBB60 ",
- " 06BBBBBBBBBBBBBBBB60 ",
- "0006BBBBBBBBBBBBBBBB5000",
- " 06BBBBBBBBBBBBBBBB60 ",
- " 06BBBBBBBBBBBBBBBB60 ",
- " 01444444444444444410 ",
- " 000000000000000000 ",
- " 0 00 0 0 00 ",
- " 0 0 00 ",
- " ",
- " "};
-
-static char *profile_x32[] = {
- "32 32 13 1",
- " c None",
- "0 c #000000",
- "1 c #003333",
- "2 c #333333",
- "3 c #333366",
- "4 c #336666",
- "5 c #336699",
- "6 c #339999",
- "7 c #669999",
- "8 c #6699CC",
- "9 c #66CCCC",
- "A c #66CCFF",
- "B c #99CCFF",
- " ",
- " ",
- " ",
- " 00 ",
- " 2683 ",
- " 029BB82 ",
- " 06BBBB4 ",
- " 06BBBBA2 ",
- " 06BBBBB50 11200 ",
- " 06BBBBBA1 017AA8511200 ",
- " 0006BBBBBB83 016ABBBBBBA93000 ",
- " 0006BBBBBBA2025ABBBBBBBBBB4000 ",
- " 06BBBBBBB94ABBBBBBBBBBBB40 ",
- " 06BBBBBBBBBBBBBBBBBBBBBB40 ",
- " 06BBBBBBBBBBBBBBBBBBBBBB40 ",
- " 0006BBBBBBBBBBBBBBBBBBBBBB4000 ",
- " 0006BBBBBBBBBBBBBBBBBBBBBB4000 ",
- " 06BBBBBBBBBBBBBBBBBBBBBB40 ",
- " 06BBBBBBBBBBBBBBBBBBBBBB40 ",
- " 06BBBBBBBBBBBBBBBBBBBBBB40 ",
- " 0006BBBBBBBBBBBBBBBBBBBBBB4000 ",
- " 0006BBBBBBBBBBBBBBBBBBBBBB4000 ",
- " 06BBBBBBBBBBBBBBBBBBBBBB40 ",
- " 06BBBBBBBBBBBBBBBBBBBBBB40 ",
- " 04888888888888888888888830 ",
- " 00000000000000000000000000 ",
- " 00 00 00 00 00 ",
- " 00 0 00 0 00 ",
- " 00 00 00 ",
- " ",
- " ",
- " "};
-
-static char **profile_xpm[3] = { profile_x16, profile_x24, profile_x32 };
-
diff --git a/app/bin/bitmaps/protractor.xpm b/app/bin/bitmaps/protractor.xpm deleted file mode 100644 index 43fa250..0000000 --- a/app/bin/bitmaps/protractor.xpm +++ /dev/null @@ -1,99 +0,0 @@ -static char *protractor_x16[] = {
- "16 16 5 1",
- " c None",
- "0 c #000000",
- "1 c #660000",
- "2 c #990000",
- "3 c #CC0000",
- " ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 0 ",
- " 0 ",
- " 01 ",
- " 0033 ",
- " 00 3 ",
- " 00 33 ",
- " 0 3 ",
- " 000 3 ",
- " 00000023 ",
- " 000000 ",
- " 00000 ",
- " 0 "};
-
-static char *protractor_x24[] = {
- "24 24 6 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #660000",
- "3 c #CC0000",
- "4 c #800000",
- " ",
- " 00 ",
- " 000 ",
- " 000 ",
- " 00 ",
- " 000 ",
- " 000 ",
- " 000 ",
- " 000 ",
- " 010 ",
- " 00033 ",
- " 000 3 ",
- " 000 33 ",
- " 000 3 ",
- " 000 3 ",
- " 000 33 ",
- " 000 33 ",
- " 000000 33 ",
- " 00000000 33 ",
- " 00000042 ",
- " 00000000 ",
- " 0000000 ",
- " 0000 ",
- " "};
-
-static char *protractor_x32[] = {
- "32 32 5 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #990000",
- "3 c #CC0000",
- " ",
- " 0 ",
- " 000 ",
- " 000 ",
- " 000 ",
- " 0000 ",
- " 0000 ",
- " 0000 ",
- " 000 ",
- " 000 ",
- " 0000 ",
- " 0000 ",
- " 0001 ",
- " 00033 ",
- " 000 33 ",
- " 0000 33 ",
- " 0000 33 ",
- " 0000 333 ",
- " 0000 33 ",
- " 000 33 ",
- " 000 333 ",
- " 0000 333 ",
- " 00000 33 ",
- " 000000000 33 ",
- " 0000000000 333 ",
- " 00000000023 ",
- " 0000000000 ",
- " 000000000 ",
- " 000000000 ",
- " 0000000 ",
- " 00 ",
- " "};
-
-static char **protractor_xpm[3] = { protractor_x16, protractor_x24, protractor_x32 };
-
diff --git a/app/bin/bitmaps/redo.xpm b/app/bin/bitmaps/redo.xpm deleted file mode 100644 index 045a8f2..0000000 --- a/app/bin/bitmaps/redo.xpm +++ /dev/null @@ -1,104 +0,0 @@ -static char *redo_x16[] = {
- "16 16 7 1",
- " c None",
- "0 c #000000",
- "1 c #006600",
- "2 c #009900",
- "3 c #00CC00",
- "4 c #00FF00",
- "5 c #008000",
- " ",
- " 1 ",
- " 151 ",
- " 11425 ",
- " 1553344355 ",
- " 5244444435 ",
- " 5344511425 ",
- " 5435 151 ",
- " 5345 1 ",
- " 145 ",
- " 1235 ",
- " 135 ",
- " 525 ",
- " 521 ",
- " 51 ",
- " "};
-
-static char *redo_x24[] = {
- "24 24 7 1",
- " c None",
- "0 c #000000",
- "1 c #006600",
- "2 c #009900",
- "3 c #00CC00",
- "4 c #00FF00",
- "5 c #008000",
- " ",
- " ",
- " 1 ",
- " 151 ",
- " 5425 ",
- " 11544351 ",
- " 552234444425 ",
- " 553444444444425 ",
- " 524444444444455 ",
- " 52444421124435 ",
- " 5444351 2455 ",
- " 544425 55 ",
- " 54421 5 ",
- " 53435 ",
- " 1445 ",
- " 12435 ",
- " 5345 ",
- " 5335 ",
- " 5421 ",
- " 545 ",
- " 141 ",
- " 155 ",
- " ",
- " "};
-
-static char *redo_x32[] = {
- "32 32 7 1",
- " c None",
- "0 c #000000",
- "1 c #006600",
- "2 c #009900",
- "3 c #00CC00",
- "4 c #00FF00",
- "5 c #008000",
- " ",
- " ",
- " ",
- " 1 ",
- " 151 ",
- " 2425 ",
- " 244351 ",
- " 1152444425 ",
- " 552233444444355 ",
- " 553444444444444425 ",
- " 534444444444444435 ",
- " 1244444444444444425 ",
- " 5244444435113444351 ",
- " 544444211 134425 ",
- " 53444451 13351 ",
- " 1244445 155 ",
- " 544445 15 ",
- " 54442 ",
- " 534435 ",
- " 14445 ",
- " 54431 ",
- " 13441 ",
- " 53435 ",
- " 5445 ",
- " 1445 ",
- " 5435 ",
- " 5431 ",
- " 542 ",
- " 531 ",
- " 111 ",
- " ",
- " "};
-
-static char **redo_xpm[3] = { redo_x16, redo_x24, redo_x32 };
-
diff --git a/app/bin/bitmaps/reflect.xpm b/app/bin/bitmaps/reflect.xpm deleted file mode 100644 index 47adaad..0000000 --- a/app/bin/bitmaps/reflect.xpm +++ /dev/null @@ -1,115 +0,0 @@ -static char *reflect_x16[] = {
- "16 16 12 1",
- " c None",
- "0 c #000000",
- "1 c #003333",
- "2 c #006699",
- "3 c #0099CC",
- "4 c #333333",
- "5 c #3399CC",
- "6 c #33CCCC",
- "7 c #33CCFF",
- "8 c #666666",
- "9 c #66CCFF",
- "A c #99CCFF",
- " ",
- " 00 ",
- " 00 ",
- "33 00 00",
- "3553 00 0040",
- "36965 00 04840",
- "36AA95 00 048840",
- "36AAA95200888840",
- "36AAA95100488840",
- "36AA75 00 048840",
- "36955 00 04840",
- "3553 00 040",
- "33 00 00",
- " 00 ",
- " 00 ",
- " "};
-
-static char *reflect_x24[] = {
- "24 24 10 1",
- " c None",
- "0 c #000000",
- "1 c #0099CC",
- "2 c #333333",
- "3 c #3399CC",
- "4 c #33CCCC",
- "5 c #33CCFF",
- "6 c #666666",
- "7 c #66CCFF",
- "8 c #99CCFF",
- " ",
- " ",
- " 00 ",
- " 00 ",
- " 1 00 0 ",
- " 13 00 00 ",
- " 1733 00 0060 ",
- " 17753 00 02660 ",
- " 178873 00 066660 ",
- " 17888733 00 02666660 ",
- " 178888773 00 026666660 ",
- " 1788888873000266666660 ",
- " 178888873 00 066666660 ",
- " 17888873 00 02666660 ",
- " 1788873 00 0266660 ",
- " 178743 00 026660 ",
- " 17731 00 0660 ",
- " 173 00 060 ",
- " 13 00 00 ",
- " 1 00 0 ",
- " 00 ",
- " 00 ",
- " ",
- " "};
-
-static char *reflect_x32[] = {
- "32 32 10 1",
- " c None",
- "0 c #000000",
- "1 c #0099CC",
- "2 c #333333",
- "3 c #3399CC",
- "4 c #33CCCC",
- "5 c #33CCFF",
- "6 c #666666",
- "7 c #66CCFF",
- "8 c #99CCFF",
- " ",
- " ",
- " ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 1 00 00 ",
- " 133 00 020 ",
- " 14733 00 02620 ",
- " 148753 00 026620 ",
- " 1488873 00 0666620 ",
- " 148888733 00 026666620 ",
- " 1488888773 00 0266666620 ",
- " 14888888873 00 006666666620 ",
- " 1488888888733 00 0266666666620 ",
- " 1488888888871 0002666666666620 ",
- " 148888888873 00 0266666666620 ",
- " 14888888873 00 06666666620 ",
- " 1488888873 00 0266666620 ",
- " 148888873 00 026666620 ",
- " 14888743 00 02666620 ",
- " 1488731 00 266620 ",
- " 14873 00 06620 ",
- " 1473 00 0220 ",
- " 133 00 000 ",
- " 3 00 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " ",
- " ",
- " "};
-
-static char **reflect_xpm[3] = { reflect_x16, reflect_x24, reflect_x32 };
-
diff --git a/app/bin/bitmaps/rotate.xpm b/app/bin/bitmaps/rotate.xpm deleted file mode 100644 index d41ca61..0000000 --- a/app/bin/bitmaps/rotate.xpm +++ /dev/null @@ -1,148 +0,0 @@ -static char *rotate_x16[] = {
- "16 16 24 1",
- " c None",
- "0 c #000000",
- "1 c #0066CC",
- "2 c #0099CC",
- "3 c #00CCCC",
- "4 c #00CCFF",
- "5 c #00FFFF",
- "6 c #336699",
- "7 c #3399CC",
- "8 c #33CCCC",
- "9 c #33CCFF",
- "A c #6699CC",
- "B c #66CCCC",
- "C c #66CCFF",
- "D c #996666",
- "E c #999999",
- "F c #99CCCC",
- "G c #CC0000",
- "H c #CC3333",
- "I c #CC3366",
- "J c #CC6666",
- "K c #CC9999",
- "L c #C0C0C0",
- "M c #808080",
- " 1 ",
- "525435 ",
- " 2437HG ",
- "52543KGGG ",
- " 1 11 GG ",
- "52543 GG ",
- " 2432 GGG ",
- "52543 GG G ",
- " 2432 G G ",
- "52543BGG GGGG ",
- " 298AH GGJ ",
- "52BAJEEMEMEMEDE ",
- " 2BIAEEMEMEMEME ",
- " 2CB7FLLL L L L ",
- " MMMMMMMMMMMMMM",
- " LLLL L L L L "};
-
-static char *rotate_x24[] = {
- "24 24 19 1",
- " c None",
- "0 c #000000",
- "1 c #0066CC",
- "2 c #0099CC",
- "3 c #00CCCC",
- "4 c #00CCFF",
- "5 c #00FFFF",
- "6 c #33CCFF",
- "7 c #33FFFF",
- "8 c #669999",
- "9 c #6699CC",
- "A c #66FFFF",
- "B c #996699",
- "C c #999999",
- "D c #CC0000",
- "E c #CC3333",
- "F c #CC9999",
- "G c #C0C0C0",
- "H c #808080",
- " ",
- " 1 1 ",
- " 5155525 ",
- " 1 1 ",
- " 1 32FDDDDD ",
- " 5155525 DDD ",
- " 1 1 DD ",
- " 1 32 DD ",
- " 5155525 DDDD ",
- " 1 1 DD D ",
- " 5155425 D ",
- " 5155425 DD DD ",
- " 1 1 DD ",
- " 5155525 DD D DD ",
- " 1 32 DD DD DDD ",
- " 1 1 D DDD ",
- " 515752FD G G G FEDG ",
- " 18CCBCHHCHHCHCCHCHHCH ",
- " 1HCEBCHHCHHCHCCHCHHCH ",
- " 515562A G GG GG GG G ",
- " 1 G91G G GG GG GG G ",
- " HHHHHHHHHHHHHHHHHHHH ",
- " CH C HC CC CC CC CC ",
- " "};
-
-static char *rotate_x32[] = {
- "32 32 22 1",
- " c None",
- "0 c #000000",
- "1 c #0066CC",
- "2 c #0099CC",
- "3 c #00CCCC",
- "4 c #00CCFF",
- "5 c #00FFFF",
- "6 c #3399CC",
- "7 c #33FFFF",
- "8 c #66CCCC",
- "9 c #66FFFF",
- "A c #996666",
- "B c #996699",
- "C c #999999",
- "D c #99CCCC",
- "E c #CC0000",
- "F c #CC3333",
- "G c #CC3366",
- "H c #CC6666",
- "I c #CC9999",
- "J c #C0C0C0",
- "K c #808080",
- " ",
- " 1 1 ",
- " 32 32 ",
- " 552555525 ",
- " 1 1 ",
- " 1 1 EEEEEE ",
- " 542555425FEEEEEEE ",
- " 542555425 EEEEE ",
- " 1 1 EEEE ",
- " 1 1 EEE ",
- " 552555525 EEE ",
- " 32 32 EEEEE ",
- " 1 1 EEE EEE ",
- " 1 1 E EE ",
- " 552555525 EE EEE ",
- " 1 1 EEE EE ",
- " 1 1 E EEE ",
- " 1 1 EE EE E ",
- " 552555525 EEE EE EE EEE ",
- " 1 1 E EEEEEEEE ",
- " 1 1 EE EEEEEE ",
- " 32 732CEE EEEE ",
- " 552577567C J J J JIE JJ ",
- " 1KKCAGCCKKCKKKCKKKCKKKCKKCKK ",
- " 1KKHEBCCKKCKKKCKKKCKKKCKKCK ",
- " 542598C29D J J J JJ JJ ",
- " 542599429D J J J JJ JJ ",
- " 1 JJ 1JJ J J J JJ JJ ",
- " KKKKKKKKKKKKKKKKKKKKKKKKKKK ",
- " CC CC CC C KC CC CC ",
- " J JJ J J J JJ JJ ",
- " "};
-
-static char **rotate_xpm[3] = { rotate_x16, rotate_x24, rotate_x32 };
-
diff --git a/app/bin/bitmaps/ruler.xpm b/app/bin/bitmaps/ruler.xpm deleted file mode 100644 index 11dbde8..0000000 --- a/app/bin/bitmaps/ruler.xpm +++ /dev/null @@ -1,89 +0,0 @@ -static char *ruler_x16[] = {
- "16 16 2 1",
- " c None",
- "0 c #000000",
- " ",
- " ",
- " 0 ",
- " 00 ",
- " 0 ",
- " 0 0 ",
- " 0 0 ",
- " 00 ",
- " 0 00 0 00",
- " 0 00 00 0 0 ",
- " 0000 00 0 0 ",
- " 000000 00 00 ",
- " 000000 00 ",
- " 0000 ",
- " ",
- " "};
-
-static char *ruler_x24[] = {
- "24 24 2 1",
- " c None",
- "0 c #000000",
- " ",
- " ",
- " ",
- " 0 ",
- " 000 ",
- " 000 ",
- " 0 ",
- " 0 ",
- " 0 0 ",
- " 0 0 ",
- " 00 ",
- " 00 ",
- " 0 0 0 ",
- " 0 0 0 0 ",
- " 00 00 00 00 00 ",
- " 000 00 00 00 0 ",
- " 00000 0 0 0 ",
- " 00000 0 00 ",
- " 0000000 00 ",
- " 0000000 ",
- " 000 ",
- " ",
- " ",
- " "};
-
-static char *ruler_x32[] = {
- "32 32 2 1",
- " c None",
- "0 c #000000",
- " ",
- " ",
- " ",
- " ",
- " 00 ",
- " 000 ",
- " 00000 ",
- " 00000 ",
- " 000 ",
- " 000 ",
- " 00 000 ",
- " 00 000 ",
- " 000 000 ",
- " 00 ",
- " 00 ",
- " 00 0 ",
- " 000 0 ",
- " 00 00 0 00 ",
- " 00 0 0 000 ",
- " 000 0 00 0 00 ",
- " 0000 00 00 0 00 ",
- " 00000000 0 00 00 ",
- " 00000000 0 00 000 ",
- " 00000000 0 00 ",
- " 000000000 00 ",
- " 00000000 000 ",
- " 00000000 ",
- " 000 ",
- " ",
- " ",
- " ",
- " "};
-
-static char **ruler_xpm[3] = { ruler_x16, ruler_x24, ruler_x32 };
-
diff --git a/app/bin/bitmaps/select.xpm b/app/bin/bitmaps/select.xpm deleted file mode 100644 index bd118c6..0000000 --- a/app/bin/bitmaps/select.xpm +++ /dev/null @@ -1,106 +0,0 @@ -static char *select_x16[] = {
- "16 16 6 1",
- " c None",
- "0 c #000000",
- "1 c #333300",
- "2 c #CC0000",
- "3 c #CC6600",
- "4 c #FF9999",
- " ",
- " ",
- " ",
- " 3 3 3 3 3 3 3 ",
- "000000000000000 ",
- " 3 3 3 3 3 ",
- " 3 3 3 3 3 ",
- "010000 222 0000 ",
- " 3 3 3 224 3 3 ",
- " 2424 ",
- " 424 ",
- " 424 ",
- " 424 ",
- " 4 ",
- " ",
- " "};
-
-static char *select_x24[] = {
- "24 24 9 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #663300",
- "3 c #996600",
- "4 c #CC0000",
- "5 c #CC3300",
- "6 c #CC6600",
- "7 c #CC9900",
- " ",
- " ",
- " ",
- " ",
- " 7 7 7 7 ",
- " 33 26 62 33 26 62 33 ",
- "022012002102201200210220",
- " 77 7 7 77 7 7 77 ",
- " 77 7 7 56 56 7 77 ",
- " 77 7 7 4444444 7 77 ",
- "022012002144444440210220",
- " 33 26 6344444 62 33 ",
- " 7 7 44 444 7 ",
- " 44 444 ",
- " 44 444 ",
- " 4 444 ",
- " 444 ",
- " 444 ",
- " 44 ",
- " ",
- " ",
- " ",
- " ",
- " "};
-
-static char *select_x32[] = {
- "32 32 8 1",
- " c None",
- "0 c #000000",
- "1 c #333300",
- "2 c #663300",
- "3 c #996600",
- "4 c #CC0000",
- "5 c #CC6600",
- "6 c #CC9900",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " 6 66 6 66 6 66 6 ",
- " 031002300030003300332003200130 ",
- " 000000000000000000000000000000 ",
- " 52 35 5 55 353 53 25 ",
- " 6 66 6 66 666 66 6 ",
- " 6 66 6 44444444 66 6 ",
- " 6 66 6 4444444444 66 6 ",
- " 031002300030444444444403200130 ",
- " 000000000000444444 00000000 ",
- " 6 66 6 4444444 53 25 ",
- " 6 6 6 444 4444 6 6 ",
- " 444 4444 ",
- " 444 4444 ",
- " 44 4444 ",
- " 4 4444 ",
- " 4444 ",
- " 4444 ",
- " 4444 ",
- " 444 ",
- " 4 ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " "};
-
-static char **select_xpm[3] = { select_x16, select_x24, select_x32 };
-
diff --git a/app/bin/bitmaps/sensor.xpm b/app/bin/bitmaps/sensor.xpm deleted file mode 100644 index 207f4c4..0000000 --- a/app/bin/bitmaps/sensor.xpm +++ /dev/null @@ -1,138 +0,0 @@ -static char *sensor_x16[] = {
- "16 16 18 1",
- " c None",
- "0 c #000000",
- "1 c #00CCCC",
- "2 c #336666",
- "3 c #339966",
- "4 c #339999",
- "5 c #33CC99",
- "6 c #33CCCC",
- "7 c #666666",
- "8 c #669966",
- "9 c #669999",
- "A c #66CCCC",
- "B c #999999",
- "C c #99CCCC",
- "D c #CCCCCC",
- "E c #CCFFCC",
- "F c #CCFFFF",
- "G c #FFFFFF",
- " 77 ",
- " 27444478 ",
- " 941111114B ",
- " 9GA111111AG9 ",
- " 34AGA1111AGA43 ",
- " 311AGA116GA114 ",
- "74111AGA6GC11147",
- "741111AGFC111143",
- "7411111FGA111153",
- "741111FCAGA11147",
- " 3111EE11AGA1147",
- " 341DF1111AGA53 ",
- " 3CF111111AG9 ",
- " 2D51111115BB ",
- " 34455443 ",
- " 773377 "};
-
-static char *sensor_x24[] = {
- "24 24 17 1",
- " c None",
- "0 c #000000",
- "1 c #00CCCC",
- "2 c #336666",
- "3 c #339966",
- "4 c #339999",
- "5 c #33CC99",
- "6 c #33CCCC",
- "7 c #666666",
- "8 c #669999",
- "9 c #66CCCC",
- "A c #999999",
- "B c #99CCCC",
- "C c #CCCCCC",
- "D c #CCFFCC",
- "E c #CCFFFF",
- "F c #FFFFFF",
- " ",
- " 72777727 ",
- " 734511115432 ",
- " 34111111111143 ",
- " 8D111111111111BC ",
- " 3BFE11111111119F63 ",
- " 241BFE111111119F6143 ",
- " 3111BFE1111119F91114 ",
- " 741111BFE11116F9111153 ",
- " 7111111BFE116F91111112 ",
- " 71111111DFE6EB11111114 ",
- " 311111111DFFB1111111147",
- " 3111111111FFD1111111147",
- " 311111111EBDFD111111147",
- " 71111111DD11DFD1111113 ",
- " 2411111DD1111DFD111152 ",
- " 741111BE111111DFD11147 ",
- " 3411BE11111111DFD153 ",
- " 31BE6111111111DFD3 ",
- " 7AE611111111111DC2 ",
- " 8841111111111532 ",
- " 345111111543 ",
- " 7234444327 ",
- " 77 "};
-
-static char *sensor_x32[] = {
- "32 32 20 1",
- " c None",
- "0 c #000000",
- "1 c #00CCCC",
- "2 c #336666",
- "3 c #339966",
- "4 c #339999",
- "5 c #33CC99",
- "6 c #33CCCC",
- "7 c #666666",
- "8 c #669999",
- "9 c #66CC99",
- "A c #66CCCC",
- "B c #999999",
- "C c #99CC99",
- "D c #99CCCC",
- "E c #CCCCCC",
- "F c #CCFFCC",
- "G c #CCFFFF",
- "H c #FFFFFF",
- "I c #C0C0C0",
- " ",
- " 7777777777 ",
- " 77777344477777 ",
- " 777744111111543777 ",
- " 77741111111111114377 ",
- " 7B81111111111111111CB7 ",
- " 77GHA11111111111111AHHB7 ",
- " 774GHHA111111111111AHHG477 ",
- " 7711GHHA1111111111AHHG11477 ",
- " 774111GHHA111111116HHG111577 ",
- " 7311111GHHA1111116HHG61111477 ",
- " 774111111GHHA11116GHH611111577 ",
- " 7751111116GHHA111GHH6111111177 ",
- " 77111111116GHH61GHHA1111111147 ",
- " 741111111116GHHGHHA11111111147 ",
- " 7411111111116GHHHA1111111111477",
- " 7411111111111DHHH61111111111477",
- " 741111111111DHHHHH6111111111477",
- " 73111111111DHHD6GHH61111111147 ",
- " 7711111111DHHD116GHH6111111137 ",
- " 774111111AHHE11116GHH611111577 ",
- " 7411111AHHF1111116HHH61111477 ",
- " 774111AHHG111111116HHG611177 ",
- " 774116HHG11111111116HHG61477 ",
- " 7746HHG6111111111116HHG577 ",
- " 77GHG611111111111116HHB77 ",
- " 7BG61111111111111119I77 ",
- " 7774511111111111114777 ",
- " 7774511111111547777 ",
- " 7777344444437777 ",
- " 777777777777 ",
- " 7777 "};
-
-static char **sensor_xpm[3] = { sensor_x16, sensor_x24, sensor_x32 };
-
diff --git a/app/bin/bitmaps/signal.xpm b/app/bin/bitmaps/signal.xpm deleted file mode 100644 index 66f55c7..0000000 --- a/app/bin/bitmaps/signal.xpm +++ /dev/null @@ -1,106 +0,0 @@ -static char *signal_x16[] = {
- "16 16 7 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #660000",
- "3 c #CC0033",
- "4 c #FF0033",
- "5 c #800000",
- " 00 ",
- " 23321 ",
- " 144441 ",
- " 144445 ",
- " 144441 ",
- " 23321 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 0000000000 "};
-
-static char *signal_x24[] = {
- "24 24 8 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #660000",
- "3 c #990033",
- "4 c #CC0033",
- "5 c #FF0033",
- "6 c #800000",
- " ",
- " 11110 ",
- " 12555562 ",
- " 15555552 ",
- " 0655555541 ",
- " 0355555541 ",
- " 155555560 ",
- " 13555541 ",
- " 123321 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00000000000000 ",
- " 00000000000000 "};
-
-static char *signal_x32[] = {
- "32 32 8 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #660000",
- "3 c #990033",
- "4 c #CC0033",
- "5 c #FF0033",
- "6 c #800000",
- " ",
- " 000000 ",
- " 0001662000 ",
- " 00355554100 ",
- " 003555555400 ",
- " 015555555560 ",
- " 0655555555400 ",
- " 0655555555300 ",
- " 005555555520 ",
- " 006555555300 ",
- " 0064554600 ",
- " 00000000 ",
- " 000000 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 000000000000000000 ",
- " 000000000000000000 ",
- " 000000000000000000 "};
-
-static char **signal_xpm[3] = { signal_x16, signal_x24, signal_x32 };
-
diff --git a/app/bin/bitmaps/snap-curs.xpm b/app/bin/bitmaps/snap-curs.xpm deleted file mode 100644 index 08b93d0..0000000 --- a/app/bin/bitmaps/snap-curs.xpm +++ /dev/null @@ -1,102 +0,0 @@ -static char *snap_curs_x16[] = {
- "16 16 4 1",
- " c None",
- "0 c #000000",
- "1 c #00CC00",
- "2 c #808080",
- " 1 1 1 1 ",
- "1 1 1 1 1 1 1 1 ",
- " 10000 1 1 ",
- " 002 ",
- " 0202 1 1 ",
- "1 0 202 1 1 1 1 ",
- " 1 202 1 1 ",
- " 202 ",
- " 1 1 201 1 ",
- "1 1 1 1 1 1 1 1 ",
- " 1 1 1 1 ",
- " ",
- " 1 1 1 1 ",
- "1 1 1 1 1 1 1 1 ",
- " 1 1 1 1 ",
- " "};
-
-static char *snap_curs_x24[] = {
- "24 24 5 1",
- " c None",
- "0 c #000000",
- "1 c #00CC00",
- "2 c #330033",
- "3 c #808080",
- " ",
- " ",
- " ",
- " 11 11 11 11 ",
- " 1 1 1 1 1 1 1 1 ",
- " 1 1 1 1 1 1 1 1 ",
- " 11222222 11 11 ",
- " 022223 ",
- " 22223 ",
- " 02223 ",
- " 11023303 11 11 ",
- " 1 031 3031 1 1 1 ",
- " 1 1 303 1 1 1 ",
- " 11 11 3031 11 ",
- " 303 ",
- " 30 ",
- " ",
- " 11 11 11 11 ",
- " 1 1 1 1 1 1 1 1 ",
- " 1 1 1 1 1 1 1 1 ",
- " 11 11 11 11 ",
- " ",
- " ",
- " "};
-
-static char *snap_curs_x32[] = {
- "32 32 10 1",
- " c None",
- "0 c #000000",
- "1 c #006600",
- "2 c #009900",
- "3 c #00CC00",
- "4 c #330000",
- "5 c #330033",
- "6 c #333300",
- "7 c #333333",
- "8 c #008000",
- " ",
- " 333 33 333 ",
- " 33333 333333 33333 ",
- " 33 33 3 3 33 3 ",
- " 3 4413 33 33 33 3 ",
- " 3 5555555555554 33 33 3 ",
- " 33 455555555555 3 3 3 ",
- " 33355555555583333 33333 ",
- " 3555555555 ",
- " 55555555 ",
- " 555555554 ",
- " 5555555554 ",
- " 45555455551 ",
- " 33335554 555583 33333 ",
- " 33 554 155563 3 33 ",
- " 3 68 33555513 33 3 ",
- " 3 83 33 55556 33 3 ",
- " 3 33 3 45555 33 3 ",
- " 33 33 333327555 33 33 ",
- " 333 3333455554 333 ",
- " 55554 ",
- " 55554 ",
- " 555 ",
- " 54 ",
- " 3333 3333 3333 ",
- " 33 3 33 33 33 33 ",
- " 3 3 3 33 33 3 ",
- " 3 3 33 33 33 3 ",
- " 3 3 3 33 33 3 ",
- " 3 3 33 33 33 33 ",
- " 333 3333 3333 ",
- " "};
-
-static char **snap_curs_xpm[3] = { snap_curs_x16, snap_curs_x24, snap_curs_x32 };
-
diff --git a/app/bin/bitmaps/snap-grid.xpm b/app/bin/bitmaps/snap-grid.xpm deleted file mode 100644 index 1139051..0000000 --- a/app/bin/bitmaps/snap-grid.xpm +++ /dev/null @@ -1,92 +0,0 @@ -static char *snap_grid_x16[] = {
- "16 16 3 1",
- " c None",
- "0 c #000000",
- "1 c #00CC00",
- " ",
- " 1111111111111 ",
- " 1 1 1 1 1 ",
- " 1 1 1 1 1 ",
- " 1111111111111 ",
- " 1 1 1 1 1 ",
- " 1 1 1 1 1 ",
- " 1111111111111 ",
- " 1 1 1 1 1 ",
- " 1 1 1 1 1 ",
- " 1111111111111 ",
- " 1 1 1 1 1 ",
- " 1 1 1 1 1 ",
- " 1111111111111 ",
- " ",
- " "};
-
-static char *snap_grid_x24[] = {
- "24 24 3 1",
- " c None",
- "0 c #000000",
- "1 c #00CC00",
- " ",
- " 111111111111111111111 ",
- " 1 1 1 1 1 ",
- " 1 1 1 1 1 ",
- " 1 1 1 1 1 ",
- " 1 1 1 1 1 ",
- " 111111111111111111111 ",
- " 1 1 1 1 1 ",
- " 1 1 1 1 1 ",
- " 1 1 1 1 1 ",
- " 1 1 1 1 1 ",
- " 111111111111111111111 ",
- " 1 1 1 1 1 ",
- " 1 1 1 1 1 ",
- " 1 1 1 1 1 ",
- " 1 1 1 1 1 ",
- " 111111111111111111111 ",
- " 1 1 1 1 1 ",
- " 1 1 1 1 1 ",
- " 1 1 1 1 1 ",
- " 1 1 1 1 1 ",
- " 111111111111111111111 ",
- " ",
- " "};
-
-static char *snap_grid_x32[] = {
- "32 32 3 1",
- " c None",
- "0 c #000000",
- "1 c #00CC00",
- " ",
- " 1111111111111111111111111111111",
- " 11 11 11 11 1 ",
- " 1 11 11 1 1 ",
- " 1 11 11 1 1 ",
- " 1 11 11 1 1 ",
- " 1 11 11 1 1 ",
- " 1 11 11 1 1 ",
- " 111111111111111111111111111111 ",
- " 111111111111111111111111111111 ",
- " 1 11 11 1 1 ",
- " 1 11 11 1 1 ",
- " 1 11 11 1 1 ",
- " 1 11 11 1 1 ",
- " 1 11 11 1 1 ",
- " 11 11 11 11 1 ",
- " 111111111111111111111111111111 ",
- " 1 11 11 1 1 ",
- " 1 11 11 1 1 ",
- " 1 11 11 1 1 ",
- " 1 11 11 1 1 ",
- " 1 11 11 1 1 ",
- " 11 11 11 11 1 ",
- " 111111111111111111111111111111 ",
- " 1 11 11 1 1 ",
- " 1 11 11 1 1 ",
- " 1 11 11 1 1 ",
- " 1 11 11 1 1 ",
- " 1 11 11 1 1 ",
- " 1 11 11 1 1 ",
- " 1111111111111111111111111111111",
- " "};
-
-static char **snap_grid_xpm[3] = { snap_grid_x16, snap_grid_x24, snap_grid_x32 };
-
diff --git a/app/bin/bitmaps/split-draw.xpm b/app/bin/bitmaps/split-draw.xpm deleted file mode 100644 index 3e94832..0000000 --- a/app/bin/bitmaps/split-draw.xpm +++ /dev/null @@ -1,95 +0,0 @@ -static char *split_draw_x16[] = {
- "16 16 4 1",
- " c None",
- "0 c #000000",
- "1 c #CC0000",
- "2 c #808080",
- " ",
- " 2 ",
- " 2 ",
- " 2 ",
- " 1 2 ",
- " 11 2 ",
- " 11 2 ",
- " 111122 ",
- " 2 111 ",
- " 221111 ",
- " 22 11 ",
- " 22 11 ",
- " 22 ",
- " 22 ",
- " 22 ",
- " "};
-
-static char *split_draw_x24[] = {
- "24 24 4 1",
- " c None",
- "0 c #000000",
- "1 c #CC0000",
- "2 c #808080",
- " ",
- " 2 ",
- " 22 ",
- " 22 ",
- " 2 ",
- " 2 ",
- " 11 2 ",
- " 11 2 ",
- " 11 2 ",
- " 11 2 ",
- " 111111 2 ",
- " 11111 ",
- " 11 ",
- " 2 111111 ",
- " 22 11 ",
- " 22 1 ",
- " 22 1 ",
- " 22 1 ",
- " 22 1 ",
- " 22 ",
- " 22 ",
- " 22 ",
- " 2 ",
- " "};
-
-static char *split_draw_x32[] = {
- "32 32 4 1",
- " c None",
- "0 c #000000",
- "1 c #CC0000",
- "2 c #808080",
- " ",
- " ",
- " 2 ",
- " 222 ",
- " 222 ",
- " 222 ",
- " 222 ",
- " 222 ",
- " 11 222 ",
- " 11 222 ",
- " 11 222 ",
- " 11 222 ",
- " 11 222 ",
- " 11111 222 ",
- " 11111111 22 ",
- " 1111111 ",
- " ",
- " 22 11111111 ",
- " 222 11111111 ",
- " 222 11 ",
- " 222 11 ",
- " 22 11 ",
- " 222 11 ",
- " 222 11 ",
- " 222 11 ",
- " 222 ",
- " 222 ",
- " 222 ",
- " 222 ",
- " 22 ",
- " ",
- " "};
-
-static char **split_draw_xpm[3] = { split_draw_x16, split_draw_x24, split_draw_x32 };
-
diff --git a/app/bin/bitmaps/split.xpm b/app/bin/bitmaps/split.xpm deleted file mode 100644 index 1e0386a..0000000 --- a/app/bin/bitmaps/split.xpm +++ /dev/null @@ -1,107 +0,0 @@ -static char *split_x16[] = {
- "16 16 10 1",
- " c None",
- "0 c #000000",
- "1 c #666666",
- "2 c #996666",
- "3 c #999999",
- "4 c #CC0000",
- "5 c #CC3333",
- "6 c #CC6666",
- "7 c #C0C0C0",
- "8 c #808080",
- " ",
- " 781 ",
- " 71371 ",
- " 4 83 88 ",
- " 4 887317 ",
- " 47887887 ",
- " 444418718 ",
- " 562 38 ",
- " 38 17 ",
- " 7317314444 ",
- " 7887 834 ",
- " 88 38 74 ",
- " 38 313 4 ",
- " 13313 ",
- " 83 ",
- " 7 "};
-
-static char *split_x24[] = {
- "24 24 7 1",
- " c None",
- "0 c #000000",
- "1 c #666666",
- "2 c #999999",
- "3 c #CC0000",
- "4 c #C0C0C0",
- "5 c #808080",
- " ",
- " 4 1 ",
- " 251 ",
- " 4 124 ",
- " 3 451 4211 ",
- " 33 4 124 52 ",
- " 33 451 44114 ",
- " 334 154 55 ",
- " 33451 44114 ",
- " 333333154 52 ",
- " 3333333 441144 ",
- " 4 55 ",
- " 421 144 ",
- " 12 333 ",
- " 21 44513333333 ",
- " 12 55 33 ",
- " 21 451 433 ",
- " 12 55 33 ",
- " 21 421 4 33 ",
- " 12 52 3 ",
- " 1 421 4 ",
- " 52 ",
- " 1 4 ",
- " "};
-
-static char *split_x32[] = {
- "32 32 7 1",
- " c None",
- "0 c #000000",
- "1 c #666666",
- "2 c #999999",
- "3 c #CC0000",
- "4 c #C0C0C0",
- "5 c #808080",
- " ",
- " ",
- " 44 1 ",
- " 25 ",
- " 124 ",
- " 4411 44 1 ",
- " 33 55 421 ",
- " 33 4 1144 52 ",
- " 33 451 44 1 44 ",
- " 33 15 25 ",
- " 33 4 11 44 124 ",
- " 33 421 421 4 ",
- " 33333333 114 52 ",
- " 33333333 1 4 1 44 ",
- " 33333 411 ",
- " 4 12 ",
- " 421 11 4 ",
- " 52 ",
- " 4 1 44 333333333 ",
- " 21 4411 33333333 ",
- " 124 25 333 ",
- " 4 11 44 1124 33 ",
- " 55 421 33 ",
- " 4 154 152 33 ",
- " 4411 4 1 4 33 ",
- " 55 21 33 ",
- " 11 4 12 ",
- " 4 1 4 ",
- " 25 ",
- " 1 4 ",
- " 1 ",
- " "};
-
-static char **split_xpm[3] = { split_x16, split_x24, split_x32 };
-
diff --git a/app/bin/bitmaps/sticky-doc.xpm b/app/bin/bitmaps/sticky-doc.xpm deleted file mode 100644 index 7b0e4cb..0000000 --- a/app/bin/bitmaps/sticky-doc.xpm +++ /dev/null @@ -1,130 +0,0 @@ -static char *sticky_doc_x16[] = {
- "16 16 15 1",
- " c None",
- "0 c #000000",
- "1 c #0066CC",
- "2 c #666699",
- "3 c #669999",
- "4 c #996633",
- "5 c #999999",
- "6 c #CC6633",
- "7 c #CC9900",
- "8 c #CC9933",
- "9 c #CC9999",
- "A c #CCCC66",
- "B c #FFCC00",
- "C c #FFCC33",
- "D c #FFCC66",
- " ",
- " ",
- "4888888888884 ",
- "4BBBBBBCBBBB764 ",
- "4BBD59B99BBB7774",
- "4BC2D95C95CBBBB4",
- "4BC2CBA5CA5CBBB4",
- "4BBC5ABD5CD5CBB4",
- "4BBBC59BCABC3CB4",
- "4BBBBB95CBBB5DB4",
- "4BBBBBBA2ABD2CB4",
- "4BBBBBBBC513DBB4",
- "4BBBBBBBBBBBBBB4",
- "4777777777777774",
- " 444444444444444",
- " "};
-
-static char *sticky_doc_x24[] = {
- "24 24 17 1",
- " c None",
- "0 c #000000",
- "1 c #0066CC",
- "2 c #3366CC",
- "3 c #666699",
- "4 c #669999",
- "5 c #996633",
- "6 c #999999",
- "7 c #CC6633",
- "8 c #CC9900",
- "9 c #CC9933",
- "A c #CC9966",
- "B c #CC9999",
- "C c #CCCC66",
- "D c #FFCC00",
- "E c #FFCC33",
- "F c #FFCC66",
- " ",
- " ",
- " ",
- "5555555555555555555 ",
- "58DDDDDDDDDDDDDDDD85 ",
- "58DDDDDDDDDDEDDDDD8875 ",
- "58DDDC26ADD64EDDDD88885 ",
- "58DDA13216EB13FDDDDDDD85",
- "58DD32EE616EC22CDDDDDD95",
- "58DD42CDDB13EF21ADDDDD95",
- "58DDF21BDDA12FE316EDDD95",
- "58DDDE316EDC22EE616EDD95",
- "58DDDDE614EDFBDDE616DD95",
- "58DDDDDDB12FDDDDDD61ED95",
- "58DDDDDDDC21BDDDDD61ED95",
- "58DDDDDDDDE316EDDF16DD95",
- "58DDDDDDDDDE612BB21FDD95",
- "58DDDDDDDDDDDC3112CDDD95",
- "58DDDDDDDDDDDDDFFDDDDD95",
- "58DDDDDDDDDDDDDDDDDDDD95",
- "579999999999999999999955",
- " 5555555555555555555555 ",
- " ",
- " "};
-
-static char *sticky_doc_x32[] = {
- "32 32 15 1",
- " c None",
- "0 c #000000",
- "1 c #0066CC",
- "2 c #3366CC",
- "3 c #666699",
- "4 c #996633",
- "5 c #999999",
- "6 c #CC6633",
- "7 c #CC9900",
- "8 c #CC9966",
- "9 c #CC9999",
- "A c #CCCC66",
- "B c #FFCC00",
- "C c #FFCC33",
- "D c #FFCC66",
- " ",
- " ",
- " ",
- " ",
- " 444444444444444444444444 ",
- " 4BBBBBBBBBBBBBBBBBBBBB764 ",
- " 4BBBBBBBBBBBBBBBBBBBBBB7744 ",
- " 4BBBBBBBBBBBBBCCBBBBBBB77744 ",
- " 4BBBBBA315DBBB53DBBBBBB777774 ",
- " 4BBBB511112ABC212ABBBBB7777774 ",
- " 4BBBA115A3119BC3118BBBBBBBBBB4 ",
- " 4BBB915BBC5115CC5119BBBBBBBBB4 ",
- " 4BBB812DBBB5115CC5115CBBBBBBB4 ",
- " 4BBBC3118BBB8113CB9115CBBBBBB4 ",
- " 4BBBBC3119CBBA212DBA213DBBBBB4 ",
- " 4BBBBBC5115CBBD313CBD212ABBBB4 ",
- " 4BBBBBBB9113DBBC5DBBBC311CBBB4 ",
- " 4BBBBBBBBA2128BBBBBBBBC319BBB4 ",
- " 4BBBBBBBBBC3115CBBBBBBB915BBB4 ",
- " 4BBBBBBBBBBC5115CBBBBBB915BBB4 ",
- " 4BBBBBBBBBBBB9113DBBBBC219BBB4 ",
- " 4BBBBBBBBBBBBBA2115CBA313CBBB4 ",
- " 4BBBBBBBBBBBBBBC51111112DBBBB4 ",
- " 4BBBBBBBBBBBBBBBBA31115CBBBBB4 ",
- " 4BBBBBBBBBBBBBBBBBCDDCBBBBBBB4 ",
- " 4BBBBBBBBBBBBBBBBBBBBBBBBBBBB4 ",
- " 4BBBBBBBBBBBBBBBBBBBBBBBBBBBB4 ",
- " 444444444444444444444444444444 ",
- " ",
- " ",
- " ",
- " "};
-
-static char **sticky_doc_xpm[3] = { sticky_doc_x16, sticky_doc_x24, sticky_doc_x32 };
-
diff --git a/app/bin/bitmaps/sticky-link.xpm b/app/bin/bitmaps/sticky-link.xpm deleted file mode 100644 index b2a027b..0000000 --- a/app/bin/bitmaps/sticky-link.xpm +++ /dev/null @@ -1,138 +0,0 @@ -static char *sticky_link_x16[] = {
- "16 16 18 1",
- " c None",
- "0 c #000000",
- "1 c #3366CC",
- "2 c #666699",
- "3 c #6666CC",
- "4 c #669999",
- "5 c #996600",
- "6 c #996633",
- "7 c #999999",
- "8 c #CC6633",
- "9 c #CC9900",
- "A c #CC9933",
- "B c #CC9966",
- "C c #CC9999",
- "D c #CCCC66",
- "E c #FFCC00",
- "F c #FFCC33",
- "G c #FFCC66",
- " ",
- " ",
- "68AAAAAAAAAA6 ",
- "6EEEEEEEEEEE986 ",
- "6EEEEEEEEEEE9996",
- "6EEGCGEEEEFCGEE6",
- "6ED7C4CEED2C7BE6",
- "6E4GEEB777FEF1F6",
- "6E1FEEF22GEEE3F6",
- "6E77GC4FF77GB7E6",
- "6EEC7BFEEEB77FE6",
- "6EEEEEEEEEEEEEE6",
- "6EEEEEEEEEEEEEE6",
- "6A99999999999996",
- " 666666666666666",
- " "};
-
-static char *sticky_link_x24[] = {
- "24 24 19 1",
- " c None",
- "0 c #000000",
- "1 c #0066CC",
- "2 c #3366CC",
- "3 c #666699",
- "4 c #6666CC",
- "5 c #669999",
- "6 c #996600",
- "7 c #996633",
- "8 c #999999",
- "9 c #CC6633",
- "A c #CC9900",
- "B c #CC9933",
- "C c #CC9966",
- "D c #CC9999",
- "E c #CCCC66",
- "F c #FFCC00",
- "G c #FFCC33",
- "H c #FFCC66",
- " ",
- " ",
- " ",
- "7777777777777777777 ",
- "7BFFFFFFFFFFFFFFFFA7 ",
- "7BFFFFFFFFFFFFFFFFAA97 ",
- "7BFFFFFFFFFFFFFFFFAAAA7 ",
- "7BFFFFFFFFFFFFFFFFFFFFA7",
- "7BFFH888EFFFFFFG888HFFA7",
- "7BFG228418GFFGD12822HFA7",
- "7BFD2GFFC22HG818GFG38FA7",
- "7BF88FFFFG3142EFFFFD2GA7",
- "7BF3DFFFFFD118GFFFFE1GA7",
- "7BF83FFFG818D13HFFF85FA7",
- "7BFE18D822CFFE218D81DFA7",
- "7BFFD1118HFFFFGD2118GFA7",
- "7BFFFGHFFFFFFFFFFGGFFFA7",
- "7BFFFFFFFFFFFFFFFFFFFFA7",
- "7BFFFFFFFFFFFFFFFFFFFFA7",
- "7BFFFFFFFFFFFFFFFFFFFFA7",
- "77BBBBBBBBBBBBBBBBBBBB97",
- " 7777777777777777777777 ",
- " ",
- " "};
-
-static char *sticky_link_x32[] = {
- "32 32 18 1",
- " c None",
- "0 c #000000",
- "1 c #0066CC",
- "2 c #3366CC",
- "3 c #666699",
- "4 c #6666CC",
- "5 c #669999",
- "6 c #996600",
- "7 c #996633",
- "8 c #999999",
- "9 c #CC9900",
- "A c #CC9933",
- "B c #CC9966",
- "C c #CC9999",
- "D c #CCCC66",
- "E c #FFCC00",
- "F c #FFCC33",
- "G c #FFCC66",
- " ",
- " ",
- " ",
- " ",
- " 777777777777777777777777 ",
- " 7EEEEEEEEEEEEEEEEEEEEEEA7 ",
- " 7EEEEEEEEEEEEEEEEEEEEEE9977 ",
- " 7EEEEEEEEEEEEEEEEEEEEEE99977 ",
- " 7EEEEEEEEEEEEEEEEEEEEEE999997 ",
- " 7EEEEEEEEEEEEEEEEEEEEEE9999997 ",
- " 7EEEEEFFEEEEEEEEEEEEEEFFEEEEE7 ",
- " 7EEEF82115DFEEEEEEEG81118FEEE7 ",
- " 7EEF81111113FEEEEF81111115FEE7 ",
- " 7EED12DEFB412BEEG3118GEG51CEE7 ",
- " 7EE81DEEEEF811CD213GEEEEG12EE7 ",
- " 7EE42EEEEEEEC11118FEEEEEE81FE7 ",
- " 7EE22EEEEEEEF8112FEEEEEEE81GE7 ",
- " 7EE51FEEEEEG312312DEEEEEE31FE7 ",
- " 7EEC18EEEF8113GF8118FEEEB18EE7 ",
- " 7EEF21488111CFEEEC21188811DEE7 ",
- " 7EEEG411118GEEEEEEF811111BEEE7 ",
- " 7EEEEFDCDFEEEEEEEEEEFCCCFEEEE7 ",
- " 7EEEEEEEEEEEEEEEEEEEEEEEEEEEE7 ",
- " 7EEEEEEEEEEEEEEEEEEEEEEEEEEEE7 ",
- " 7EEEEEEEEEEEEEEEEEEEEEEEEEEEE7 ",
- " 7EEEEEEEEEEEEEEEEEEEEEEEEEEEE7 ",
- " 7EEEEEEEEEEEEEEEEEEEEEEEEEEEE7 ",
- " 777777777777777777777777777777 ",
- " ",
- " ",
- " ",
- " "};
-
-static char **sticky_link_xpm[3] = { sticky_link_x16, sticky_link_x24, sticky_link_x32 };
-
diff --git a/app/bin/bitmaps/sticky-note.xpm b/app/bin/bitmaps/sticky-note.xpm deleted file mode 100644 index fbd12e1..0000000 --- a/app/bin/bitmaps/sticky-note.xpm +++ /dev/null @@ -1,124 +0,0 @@ -static char *sticky_note_x16[] = {
- "16 16 14 1",
- " c None",
- "0 c #000000",
- "1 c #996600",
- "2 c #996633",
- "3 c #999999",
- "4 c #CC6633",
- "5 c #CC9900",
- "6 c #CC9933",
- "7 c #CC9966",
- "8 c #CC9999",
- "9 c #CCCC66",
- "A c #FFCC00",
- "B c #FFCC33",
- "C c #FFCC66",
- " ",
- " ",
- "2466666666662 ",
- "2AAAAAAAAAAA542 ",
- "2733333333375552",
- "2BCCCCCCCCCBAAA2",
- "2B88888888888CA2",
- "2B88888888888CA2",
- "2BCCCCCCCCCCBAA2",
- "2733333333338AA2",
- "2AAAAAAAAAAAAAA2",
- "2733333333333392",
- "2BCCCCCCCCCCCCB2",
- "2655555555555552",
- " 222222222222222",
- " "};
-
-static char *sticky_note_x24[] = {
- "24 24 14 1",
- " c None",
- "0 c #000000",
- "1 c #0066CC",
- "2 c #996600",
- "3 c #996633",
- "4 c #999999",
- "5 c #CC6633",
- "6 c #CC9900",
- "7 c #CC9933",
- "8 c #CC9999",
- "9 c #CCCC66",
- "A c #FFCC00",
- "B c #FFCC33",
- "C c #FFCC66",
- " ",
- " ",
- " ",
- "3333333333333333333 ",
- "37AAAAAAAAAAAAAAAA63 ",
- "37AAAAAAAAAAAAAAAA6653 ",
- "37B11111111111114A66663 ",
- "37B44444444444448AAAAA63",
- "37AAAAAAAAAAAAAAAAAAAA63",
- "37B88888888888888889AA63",
- "37B11111111111111114AA63",
- "37BCCCCCCCCCCCCCCCCCAA63",
- "37AAAAAAAAAAAAAAAAAAAA63",
- "37B1111111111111118AAA63",
- "37B4444444444444449AAA63",
- "37AAAAAAAAAAAAAAAAAAAA63",
- "37B888888888888888888A63",
- "37B111111111111111111A63",
- "37BCCCCCCCCCCCCCCCCCCA63",
- "37AAAAAAAAAAAAAAAAAAAA63",
- "337777777777777777777753",
- " 3333333333333333333333 ",
- " ",
- " "};
-
-static char *sticky_note_x32[] = {
- "32 32 13 1",
- " c None",
- "0 c #000000",
- "1 c #0066CC",
- "2 c #996600",
- "3 c #996633",
- "4 c #999999",
- "5 c #CC9900",
- "6 c #CC9933",
- "7 c #CC9999",
- "8 c #CCCC66",
- "9 c #FFCC00",
- "A c #FFCC33",
- "B c #FFCC66",
- " ",
- " ",
- " ",
- " ",
- " 333333333333333333333333 ",
- " 3999999999999999999999963 ",
- " 399999999999999999999995533 ",
- " 3999999999999999999999955533 ",
- " 39A111111111111111111B9555553 ",
- " 39A111111111111111111B95555553 ",
- " 39ABBBBBBBBBBBBBBBBBBA99999993 ",
- " 399999999999999999999999999993 ",
- " 39ABBBBBBBBBBBBBBBBBBBBBBA9993 ",
- " 39A1111111111111111111111B9993 ",
- " 39A1111111111111111111111B9993 ",
- " 399999999999999999999999999993 ",
- " 399999999999999999999999999993 ",
- " 39A777777777777777777778999993 ",
- " 39B111111111111111111114999993 ",
- " 39B444444444444444444447999993 ",
- " 399999999999999999999999999993 ",
- " 399999999999999999999999999993 ",
- " 39A111111111111111111111111993 ",
- " 39A111111111111111111111111993 ",
- " 39ABBBBBBBBBBBBBBBBBBBBBBBB993 ",
- " 399999999999999999999999999993 ",
- " 399999999999999999999999999993 ",
- " 333333333333333333333333333333 ",
- " ",
- " ",
- " ",
- " "};
-
-static char **sticky_note_xpm[3] = { sticky_note_x16, sticky_note_x24, sticky_note_x32 };
-
diff --git a/app/bin/bitmaps/stop.xpm b/app/bin/bitmaps/stop.xpm deleted file mode 100644 index 78fb1fc..0000000 --- a/app/bin/bitmaps/stop.xpm +++ /dev/null @@ -1,128 +0,0 @@ -static char *stop_x16[] = {
- "16 16 14 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #660000",
- "3 c #990000",
- "4 c #993300",
- "5 c #993333",
- "6 c #CC3333",
- "7 c #CC6633",
- "8 c #CC6666",
- "9 c #CC9966",
- "A c #CC9999",
- "B c #FF9999",
- "C c #800000",
- " 00 ",
- " 1221 ",
- " 11566511 ",
- " 015788886510 ",
- " 12678888886620 ",
- " 13688AAA9876C0 ",
- " 14689ABAA886C0 ",
- " 1478AABBA886C0 ",
- " 14789ABBA886C0 ",
- " 14688AAAA886C0 ",
- " 136788A98876C0 ",
- " 11568888876410 ",
- " 1C677776C1 ",
- " 11566411 ",
- " 1111 ",
- " "};
-
-static char *stop_x24[] = {
- "24 24 15 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #660000",
- "3 c #990000",
- "4 c #993300",
- "5 c #993333",
- "6 c #CC3300",
- "7 c #CC3333",
- "8 c #CC6633",
- "9 c #CC6666",
- "A c #CC9966",
- "B c #CC9999",
- "C c #FF9999",
- "D c #800000",
- " ",
- " 0110 ",
- " 1D7721 ",
- " 1277777511 ",
- " 11578888877410 ",
- " 01D77899999987721 ",
- " 12677899999999877310 ",
- " 13778999ABA9999776D0 ",
- " 1377899BBBBBA99877D0 ",
- " 147899ABBBBBB99977D0 ",
- " 147899BBCCCBBA9977D0 ",
- " 147899BBCCCCBA9987D0 ",
- " 147899BBCCCCBA9977D0 ",
- " 147899ABBCCBB99977D0 ",
- " 1377999BBBBBA99877D0 ",
- " 13778999BBBA999876D0 ",
- " 136779999999998776D0 ",
- " 1D77789999998776D1 ",
- " 1157788998877411 ",
- " 127777777511 ",
- " 014777721 ",
- " 113D10 ",
- " 10 ",
- " "};
-
-static char *stop_x32[] = {
- "32 32 16 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #660000",
- "3 c #990000",
- "4 c #993300",
- "5 c #993333",
- "6 c #CC0000",
- "7 c #CC3300",
- "8 c #CC3333",
- "9 c #CC6633",
- "A c #CC6666",
- "B c #CC9966",
- "C c #CC9999",
- "D c #FF9999",
- "E c #800000",
- " ",
- " 11 ",
- " 113E10 ",
- " 014888821 ",
- " 128888888511 ",
- " 1158889999888411 ",
- " 11488999AAA999888E1 ",
- " 01E88899AAAAAAAA9888411 ",
- " 12388899AAAAAAAAAA98887E1 ",
- " 1378899AAAABBBAAAAA98886E0 ",
- " 137889AAAABCCCCBAAAA9887E0 ",
- " 138899AAACCCCCCCBAAA9887E0 ",
- " 14889AAABCCCCCCCCAAA9888E0 ",
- " 14889AAACCCDDDDCCBAAA988E0 ",
- " 14889AABCCDDDDDCCCAAA988E0 ",
- " 14889AABCCDDDDDCCCAAA988E0 ",
- " 17889AABCCDDDDDCCCAAA988E0 ",
- " 17889AAACCCDDDDCCBAAA988E0 ",
- " 17889AAABCCCCCCCCBAA9888E0 ",
- " 138899AAACCCCCCCBAAA9887E0 ",
- " 137889AAABCCCCCBAAAA9887E0 ",
- " 1378899AAAABBBAAAAA98887E0 ",
- " 1E78889AAAAAAAAAAA98887620 ",
- " 11488899AAAAAAAA99887311 ",
- " 1E888999AAAA99888521 ",
- " 11488899999888821 ",
- " 11588888888410 ",
- " 1288888411 ",
- " 01E7411 ",
- " 111 ",
- " ",
- " "};
-
-static char **stop_xpm[3] = { stop_x16, stop_x24, stop_x32 };
-
diff --git a/app/bin/bitmaps/straight-line.xpm b/app/bin/bitmaps/straight-line.xpm deleted file mode 100644 index 9808d8d..0000000 --- a/app/bin/bitmaps/straight-line.xpm +++ /dev/null @@ -1,96 +0,0 @@ -static char *straight_line_x16[] = {
- "16 16 4 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #CC0000",
- " ",
- " 222 ",
- " 222 ",
- " 2 2 ",
- " 22 ",
- " 22 ",
- " 22 ",
- " 01 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " "};
-
-static char *straight_line_x24[] = {
- "24 24 5 1",
- " c None",
- "0 c #000000",
- "1 c #990000",
- "2 c #CC0000",
- "3 c #800000",
- " ",
- " ",
- " 2222 ",
- " 22 ",
- " 2 2 ",
- " 2 2 ",
- " 2 ",
- " 22 ",
- " 22 ",
- " 22 ",
- " 03 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " 00 ",
- " ",
- " "};
-
-static char *straight_line_x32[] = {
- "32 32 4 1",
- " c None",
- "0 c #000000",
- "1 c #990000",
- "2 c #CC0000",
- " ",
- " ",
- " 22222 ",
- " 2222222 ",
- " 2222 ",
- " 22222 ",
- " 222 22 ",
- " 222 22 ",
- " 222 22 ",
- " 222 ",
- " 222 ",
- " 222 ",
- " 122 ",
- " 002 ",
- " 000 ",
- " 000 ",
- " 000 ",
- " 000 ",
- " 000 ",
- " 000 ",
- " 000 ",
- " 000 ",
- " 000 ",
- " 000 ",
- " 000 ",
- " 000 ",
- " 000 ",
- " 000 ",
- " 000 ",
- " 0 ",
- " ",
- " "};
-
-static char **straight_line_xpm[3] = { straight_line_x16, straight_line_x24, straight_line_x32 };
-
diff --git a/app/bin/bitmaps/straight.xpm b/app/bin/bitmaps/straight.xpm deleted file mode 100644 index 83e2f67..0000000 --- a/app/bin/bitmaps/straight.xpm +++ /dev/null @@ -1,133 +0,0 @@ -static char *straight_x16[] = {
- "16 16 18 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #663300",
- "4 c #666666",
- "5 c #993333",
- "6 c #996600",
- "7 c #996633",
- "8 c #996666",
- "9 c #999999",
- "A c #CC0000",
- "B c #CC3333",
- "C c #CC6600",
- "D c #CC6666",
- "E c #CC9900",
- "F c #C0C0C0",
- "G c #808080",
- " AAA ",
- " AAAA",
- " 945AAA",
- " G9A8AA",
- " G8B94 ",
- " FG8D8GF ",
- " E49B8G ",
- " 37A9G ",
- " 62EC49 ",
- " E32E 2E ",
- " E13E 3 ",
- " 63 E2 E ",
- " C1EE0C ",
- " 2E 2C ",
- " 33 ",
- " 03E "};
-
-static char *straight_x24[] = {
- "24 24 15 1",
- " c None",
- "0 c #000000",
- "1 c #333300",
- "2 c #333333",
- "3 c #663300",
- "4 c #666666",
- "5 c #996600",
- "6 c #999999",
- "7 c #CC0000",
- "8 c #CC3333",
- "9 c #CC6600",
- "A c #CC9900",
- "B c #CC9999",
- "C c #C0C0C0",
- "D c #808080",
- " ",
- " 77777 ",
- " 777 ",
- " C 4 7777 ",
- " 6D 77 7 ",
- " C 4DB7 4 7 ",
- " 6D4 8B44 ",
- " C 4DB7 DD ",
- " CD4 8B44CC ",
- " A 4DB7 DD ",
- " A52 8B44CC ",
- " A 03A7 DD ",
- " A50 AA246C ",
- " 03A 53 ",
- " A50 AA 0AA ",
- " 3A 93 ",
- " A90 AA 09A ",
- " 1A 93 ",
- " A90 AA 05A ",
- " 39 A3 ",
- " 0 AA 05A ",
- " A30 ",
- " 05A ",
- " 0 "};
-
-static char *straight_x32[] = {
- "32 32 17 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #333333",
- "4 c #663300",
- "5 c #666666",
- "6 c #996600",
- "7 c #999999",
- "8 c #CC0000",
- "9 c #CC3333",
- "A c #CC6600",
- "B c #CC6666",
- "C c #CC9900",
- "D c #CC9999",
- "E c #C0C0C0",
- "F c #808080",
- " ",
- " 888888 ",
- " 8888888 ",
- " 8888 ",
- " E 5 88888 ",
- " E75 888 88 ",
- " F7 888 88 ",
- " EE 5 D988 5 88 ",
- " 7F5 88D 5 ",
- " 57D8887F ",
- " E 55 988 57E ",
- " EF5 88D755 E ",
- " 5FD888 FF ",
- " CC35 989 55EE ",
- " 64 889E55 ",
- " 00CC 8 FF ",
- " C40 CC 55 E ",
- " 44 C60 ",
- " C 0 C 04C ",
- " CA0 C 00 CC ",
- " 2A A2 ",
- " CC 0 CC 0C ",
- " C2 CC 0 C ",
- " 0AC 64 ",
- " C 00 CC 06C ",
- " 44 CC0 ",
- " 04C 46 ",
- " 0 C 0 CC ",
- " C20 ",
- " 1A ",
- " 00 C ",
- " "};
-
-static char **straight_xpm[3] = { straight_x16, straight_x24, straight_x32 };
-
diff --git a/app/bin/bitmaps/SVG/background.svg b/app/bin/bitmaps/svg/background.svg index 4856eac..b168f0b 100644 --- a/app/bin/bitmaps/SVG/background.svg +++ b/app/bin/bitmaps/svg/background.svg @@ -34,7 +34,7 @@ showgrid="false" inkscape:snap-nodes="false" inkscape:zoom="10.897825" - inkscape:cx="23.903852" + inkscape:cx="23.857972" inkscape:cy="23.995614" inkscape:window-x="0" inkscape:window-y="0" diff --git a/app/bin/bitmaps/SVG/benchwork.svg b/app/bin/bitmaps/svg/benchwork.svg index 1562ae3..1562ae3 100644 --- a/app/bin/bitmaps/SVG/benchwork.svg +++ b/app/bin/bitmaps/svg/benchwork.svg diff --git a/app/bin/bitmaps/SVG/bezier-line.svg b/app/bin/bitmaps/svg/bezier-line.svg index df4232b..df4232b 100644 --- a/app/bin/bitmaps/SVG/bezier-line.svg +++ b/app/bin/bitmaps/svg/bezier-line.svg diff --git a/app/bin/bitmaps/SVG/bezier-track.svg b/app/bin/bitmaps/svg/bezier-track.svg index 4f3cf33..4f3cf33 100644 --- a/app/bin/bitmaps/SVG/bezier-track.svg +++ b/app/bin/bitmaps/svg/bezier-track.svg diff --git a/app/bin/bitmaps/SVG/block.svg b/app/bin/bitmaps/svg/block.svg index 9d306d7..9d306d7 100755 --- a/app/bin/bitmaps/SVG/block.svg +++ b/app/bin/bitmaps/svg/block.svg diff --git a/app/bin/bitmaps/SVG/blockdel.svg b/app/bin/bitmaps/svg/blockdel.svg index 014101e..014101e 100755 --- a/app/bin/bitmaps/SVG/blockdel.svg +++ b/app/bin/bitmaps/svg/blockdel.svg diff --git a/app/bin/bitmaps/SVG/blockedit.svg b/app/bin/bitmaps/svg/blockedit.svg index 3ed69c3..3ed69c3 100755 --- a/app/bin/bitmaps/SVG/blockedit.svg +++ b/app/bin/bitmaps/svg/blockedit.svg diff --git a/app/bin/bitmaps/SVG/blocknew.svg b/app/bin/bitmaps/svg/blocknew.svg index e8c51e3..e8c51e3 100755 --- a/app/bin/bitmaps/SVG/blocknew.svg +++ b/app/bin/bitmaps/svg/blocknew.svg diff --git a/app/bin/bitmaps/SVG/bottom.svg b/app/bin/bitmaps/svg/bottom.svg index e529c66..e529c66 100644 --- a/app/bin/bitmaps/SVG/bottom.svg +++ b/app/bin/bitmaps/svg/bottom.svg diff --git a/app/bin/bitmaps/SVG/box.svg b/app/bin/bitmaps/svg/box.svg index e936fa4..49054b5 100644 --- a/app/bin/bitmaps/SVG/box.svg +++ b/app/bin/bitmaps/svg/box.svg @@ -1,12 +1,5 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> <svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" version="1.1" id="Layer_1" x="0px" @@ -15,7 +8,14 @@ style="enable-background:new 0 0 48 48;" xml:space="preserve" sodipodi:docname="box.svg" - inkscape:version="1.0.2-2 (e86c870879, 2021-01-15)"><metadata + inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/"><metadata id="metadata910"><rdf:RDF><cc:Work rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs @@ -33,13 +33,15 @@ id="namedview906" showgrid="false" inkscape:zoom="12.521303" - inkscape:cx="24" - inkscape:cy="24" + inkscape:cx="23.9991" + inkscape:cy="24.039032" inkscape:window-x="0" inkscape:window-y="0" inkscape:window-maximized="0" inkscape:current-layer="Layer_1" - inkscape:document-rotation="0" /> + inkscape:document-rotation="0" + inkscape:pagecheckerboard="0" + inkscape:snap-smooth-nodes="true" /> <style type="text/css" id="style897"> @@ -63,10 +65,8 @@ y2="9.0605688" id="line901" style="stroke-width:3;stroke-miterlimit:10;stroke-dasharray:none;stroke:#cc0000;stroke-opacity:1" /> -<polyline - class="st2" - points="39.9,18.3 39.4,11.4 32.7,11.4 " - id="polyline903" - transform="matrix(1.4025875,0,0,1.3570092,-15.557291,-6.2439345)" - style="stroke-width:2.17452736;stroke-miterlimit:10;stroke-dasharray:none;stroke:#cc0000;stroke-opacity:1" /> -</svg> + +<path + style="fill:none;stroke:#cc0000;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none" + d="M 29.070457,9.1843477 40.014923,9.0605688 39.852082,20.285429" + id="path1619" /></svg> diff --git a/app/bin/bitmaps/SVG/bridge.svg b/app/bin/bitmaps/svg/bridge.svg index af55093..c05e827 100644 --- a/app/bin/bitmaps/SVG/bridge.svg +++ b/app/bin/bitmaps/svg/bridge.svg @@ -16,21 +16,14 @@ id="parapet" style="display:inline;stroke:#917c6f;stroke-width:2.56211;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" transform="matrix(1.4366046,0,0,1.7036947,-13.366682,-16.698783)"><path - d="M 15.9996,38.6673 H 46.6655" + d="m 15.9996,38.6673 11.239513,0" fill="none" stroke="#ff6700" stroke-miterlimit="10" stroke-width="2.6666" id="path1633" - style="fill:#000000;fill-opacity:1;stroke:#917c6f;stroke-width:2.56211;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /><path - d="m 46.53217,38.709966 5.334533,5.145205" - fill="none" - stroke="#ff6700" - stroke-linecap="round" - stroke-miterlimit="10" - stroke-width="2.6666" - id="path1637" - style="fill:#000000;fill-opacity:1;stroke:#917c6f;stroke-width:2.56211;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /><path + style="fill:#000000;fill-opacity:1;stroke:#917c6f;stroke-width:2.56211;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + sodipodi:nodetypes="cc" /><path d="M 15.928935,38.645967 11.357049,43.85517" fill="none" stroke="#ff6700" @@ -39,13 +32,14 @@ stroke-width="2.6666" id="path1641" style="fill:#000000;fill-opacity:1;stroke:#917c6f;stroke-width:2.56211;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /><path - d="M 46.6655,18.6678 H 15.9996" + d="m 36.085871,18.6678 -20.086271,0" fill="none" stroke="#ff6700" stroke-miterlimit="10" stroke-width="2.6666" id="path1645" - style="fill:none;fill-opacity:1;stroke:#917c6f;stroke-width:2.56211;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /><path + style="fill:none;fill-opacity:1;stroke:#917c6f;stroke-width:2.56211;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + sodipodi:nodetypes="cc" /><path d="M 16.886244,18.657134 11.358382,13.313268" fill="none" stroke="#ff6700" @@ -53,14 +47,6 @@ stroke-miterlimit="10" stroke-width="2.6666" id="path1649" - style="fill:none;fill-opacity:1;stroke:#917c6f;stroke-width:2.56211;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /><path - d="m 45.913519,18.657134 5.954518,-5.343866" - fill="none" - stroke="#ff6700" - stroke-linecap="round" - stroke-miterlimit="10" - stroke-width="2.6666" - id="path1653" style="fill:none;fill-opacity:1;stroke:#917c6f;stroke-width:2.56211;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /></g><metadata id="metadata1665"><rdf:RDF><cc:Work rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type @@ -78,9 +64,9 @@ inkscape:window-height="866" id="namedview1661" showgrid="false" - inkscape:zoom="9.3956422" - inkscape:cx="36.186989" - inkscape:cy="32.036128" + inkscape:zoom="7.6322099" + inkscape:cx="36.162527" + inkscape:cy="32.100794" inkscape:window-x="0" inkscape:window-y="0" inkscape:window-maximized="0" @@ -159,4 +145,8 @@ stroke="#000000" stroke-miterlimit="10" id="path1629" - style="stroke-width:2.30261;stroke-miterlimit:10;stroke-dasharray:none" /></g></g></svg> + style="stroke-width:2.30261;stroke-miterlimit:10;stroke-dasharray:none" /></g></g><path + style="fill:none;stroke:#cc0000;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="M 41.180129,2.6688602 22.819872,61.33114" + id="path947" + sodipodi:nodetypes="cc" /></svg> diff --git a/app/bin/bitmaps/SVG/building.svg b/app/bin/bitmaps/svg/building.svg index 4b63286..4b63286 100644 --- a/app/bin/bitmaps/SVG/building.svg +++ b/app/bin/bitmaps/svg/building.svg diff --git a/app/bin/bitmaps/SVG/car-inventory.svg b/app/bin/bitmaps/svg/car-inventory.svg index 27d805d..27d805d 100644 --- a/app/bin/bitmaps/SVG/car-inventory.svg +++ b/app/bin/bitmaps/svg/car-inventory.svg diff --git a/app/bin/bitmaps/SVG/change-grid.svg b/app/bin/bitmaps/svg/change-grid.svg index 0962f5f..0962f5f 100644 --- a/app/bin/bitmaps/SVG/change-grid.svg +++ b/app/bin/bitmaps/svg/change-grid.svg diff --git a/app/bin/bitmaps/SVG/circle-center.svg b/app/bin/bitmaps/svg/circle-center.svg index dc1b0fc..dc1b0fc 100644 --- a/app/bin/bitmaps/SVG/circle-center.svg +++ b/app/bin/bitmaps/svg/circle-center.svg diff --git a/app/bin/bitmaps/SVG/circle-filled-center.svg b/app/bin/bitmaps/svg/circle-filled-center.svg index 252ce43..252ce43 100644 --- a/app/bin/bitmaps/SVG/circle-filled-center.svg +++ b/app/bin/bitmaps/svg/circle-filled-center.svg diff --git a/app/bin/bitmaps/SVG/circle-filled-tangent.svg b/app/bin/bitmaps/svg/circle-filled-tangent.svg index afbf7ea..afbf7ea 100644 --- a/app/bin/bitmaps/SVG/circle-filled-tangent.svg +++ b/app/bin/bitmaps/svg/circle-filled-tangent.svg diff --git a/app/bin/bitmaps/SVG/circle-line-center.svg b/app/bin/bitmaps/svg/circle-line-center.svg index 18e05df..18e05df 100644 --- a/app/bin/bitmaps/SVG/circle-line-center.svg +++ b/app/bin/bitmaps/svg/circle-line-center.svg diff --git a/app/bin/bitmaps/SVG/circle-line-tangent.svg b/app/bin/bitmaps/svg/circle-line-tangent.svg index 02f8c39..02f8c39 100644 --- a/app/bin/bitmaps/SVG/circle-line-tangent.svg +++ b/app/bin/bitmaps/svg/circle-line-tangent.svg diff --git a/app/bin/bitmaps/SVG/circle-line.svg b/app/bin/bitmaps/svg/circle-line.svg index 2aa4811..2aa4811 100644 --- a/app/bin/bitmaps/SVG/circle-line.svg +++ b/app/bin/bitmaps/svg/circle-line.svg diff --git a/app/bin/bitmaps/SVG/circle-tangent.svg b/app/bin/bitmaps/svg/circle-tangent.svg index 3e970c6..3e970c6 100644 --- a/app/bin/bitmaps/SVG/circle-tangent.svg +++ b/app/bin/bitmaps/svg/circle-tangent.svg diff --git a/app/bin/bitmaps/SVG/circle.svg b/app/bin/bitmaps/svg/circle.svg index 660e7fd..660e7fd 100644 --- a/app/bin/bitmaps/SVG/circle.svg +++ b/app/bin/bitmaps/svg/circle.svg diff --git a/app/bin/bitmaps/SVG/doc-export-xtc.svg b/app/bin/bitmaps/svg/clone.svg index dab12aa..31c63bb 100644 --- a/app/bin/bitmaps/SVG/doc-export-xtc.svg +++ b/app/bin/bitmaps/svg/clone.svg @@ -4,7 +4,7 @@ viewBox="0 0 64 64" xml:space="preserve" id="svg1659" - sodipodi:docname="doc-export-xtc.svg" + sodipodi:docname="clone.svg" inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" @@ -13,12 +13,19 @@ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/"><rect - style="fill:#f5f5f5;fill-opacity:1;stroke:#666666;stroke-width:1.9309;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + style="fill:#f5f5f5;fill-opacity:1;stroke:#666666;stroke-width:2.00172;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" id="rect900" - width="59.649868" - height="42.871033" - x="2.1262496" - y="-45.047009" + width="49.334457" + height="45.780003" + x="2.1271074" + y="-48.169491" + transform="rotate(90)" /><rect + style="fill:#f5f5f5;fill-opacity:1;stroke:#05a3ff;stroke-width:2.00172;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + id="rect900-2" + width="49.334457" + height="45.780003" + x="12.440801" + y="-61.699257" transform="rotate(90)" /><metadata id="metadata1665"><rdf:RDF><cc:Work rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type @@ -47,14 +54,16 @@ inkscape:pagecheckerboard="0" /><g inkscape:groupmode="layer" id="layer1" - inkscape:label="Export"><g - id="arrow" - transform="translate(2.5460266,-0.85071321)" - inkscape:label="arrow" - style="stroke:#cc0000;stroke-width:4.7811;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"><path - style="fill:none;fill-opacity:1;stroke:#cc0000;stroke-width:4.7811;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - d="m 46.398031,40.401712 11.404136,-8.5769 -11.209194,-8.430286" - id="path1484" /><path - style="fill:none;stroke:#cc0000;stroke-width:4.44353;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - d="M 57.802167,31.824812 H 30.834752" - id="path1706" /></g></g></svg> + inkscape:label="Export" /><g + id="plus" + transform="matrix(1.3262569,0,0,1.2941157,-31.896132,-8.0085511)" + inkscape:label="plus"><path + style="display:inline;fill:#005a20;fill-opacity:1;stroke:#0082cc;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 46.809533,31.077554 v -4.700241 h 4.630089 v -3.086726 l -4.559936,0.07015 -0.07015,-4.559936 h -3.016572 l 0.140305,4.559936 -4.840547,0.07015 0.07015,3.086726 4.489783,-0.07015 0.140306,4.630088 z" + id="path1718" /><path + style="fill:none;fill-opacity:1;stroke:#05a3ff;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="M 45.350068,18.723791 V 31.070694" + id="path1702" /><path + style="fill:none;fill-opacity:1;stroke:#05a3ff;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="M 51.516636,24.897242 H 39.169733" + id="path1708" /></g></svg> diff --git a/app/bin/bitmaps/SVG/connect.svg b/app/bin/bitmaps/svg/connect.svg index 91578a6..0fd3065 100644 --- a/app/bin/bitmaps/SVG/connect.svg +++ b/app/bin/bitmaps/svg/connect.svg @@ -1,12 +1,5 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> <svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" version="1.1" id="Layer_1" x="0px" @@ -15,7 +8,14 @@ style="enable-background:new 0 0 48 48;" xml:space="preserve" sodipodi:docname="connect.svg" - inkscape:version="1.0.2-2 (e86c870879, 2021-01-15)"><metadata + inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/"><metadata id="metadata39"><rdf:RDF><cc:Work rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs @@ -33,13 +33,14 @@ id="namedview35" showgrid="false" inkscape:zoom="13.417014" - inkscape:cx="24" - inkscape:cy="24" + inkscape:cx="24.036645" + inkscape:cy="23.999379" inkscape:window-x="0" inkscape:window-y="0" inkscape:window-maximized="0" inkscape:current-layer="Layer_1" - inkscape:document-rotation="0" /> + inkscape:document-rotation="0" + inkscape:pagecheckerboard="0" /> <style type="text/css" id="style2"> @@ -125,12 +126,12 @@ style="stroke-width:2;stroke-miterlimit:10;stroke-dasharray:none" /> <line class="st2" - x1="25.311279" + x1="26.801924" y1="31.447706" x2="46.29179" y2="31.447706" id="line24" - style="stroke:#cc0000;stroke-width:3.27821;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1" /> + style="stroke:#cc0000;stroke-width:4;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1" /> <path class="st3" d="M 26.229179,29.861805" @@ -140,8 +141,8 @@ class="st4" points="28.5,33.3 24.2,29 28.5,24.8 " id="polyline28" - style="stroke:#cc0000;stroke-width:2.5;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1" - transform="matrix(1.3112816,0,0,1.3112816,-6.1594786,-6.5794627)" /> + style="stroke:#cc0000;stroke-width:3.17082;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1" + transform="matrix(1.2136125,0,0,1.3112816,-2.0816474,-6.5794627)" /> <line class="st2" x1="21.503935" @@ -149,11 +150,11 @@ x2="1.8347114" y2="31.447706" id="line30" - style="stroke:#cc0000;stroke-width:3.27821;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1" /> + style="stroke:#cc0000;stroke-width:4;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1" /> <polyline class="st4" points="18.3,33.3 21.8,29 18.3,24.8 " id="polyline32" - style="stroke:#cc0000;stroke-width:2.5;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1" - transform="matrix(1.3112816,0,0,1.3112816,-7.3442601,-6.5794627)" /> + style="stroke:#cc0000;stroke-width:3.05045;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1" + transform="matrix(1.3112816,0,0,1.3112816,-7.7914533,-6.5794627)" /> </svg> diff --git a/app/bin/bitmaps/SVG/control.svg b/app/bin/bitmaps/svg/control.svg index 051e57f..051e57f 100644 --- a/app/bin/bitmaps/SVG/control.svg +++ b/app/bin/bitmaps/svg/control.svg diff --git a/app/bin/bitmaps/SVG/convert-from.svg b/app/bin/bitmaps/svg/convert-from.svg index 259abd8..ed1ac55 100644 --- a/app/bin/bitmaps/SVG/convert-from.svg +++ b/app/bin/bitmaps/svg/convert-from.svg @@ -1,21 +1,21 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> <svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" version="1.1" viewBox="0 0 64 64" xml:space="preserve" id="svg5557" sodipodi:docname="convert-from.svg" - inkscape:version="1.0.2-2 (e86c870879, 2021-01-15)"><metadata + inkscape:version="1.2.1 (9c6d41e410, 2022-07-14)" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/"><metadata id="metadata5561"><rdf:RDF><cc:Work rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><sodipodi:namedview + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><sodipodi:namedview pagecolor="#ffffff" bordercolor="#666666" borderopacity="1" @@ -29,17 +29,17 @@ id="namedview5559" showgrid="false" inkscape:zoom="9.3956422" - inkscape:cx="32" - inkscape:cy="35.011765" + inkscape:cx="32.036128" + inkscape:cy="35.016233" inkscape:window-x="210" inkscape:window-y="45" inkscape:window-maximized="0" inkscape:current-layer="arrow" - inkscape:document-rotation="0" /><defs - id="defs5523"><clipPath - id="clipPath3916"><path - d="m0 48h48v-48h-48z" - id="path5520" /></clipPath></defs><g + inkscape:document-rotation="0" + inkscape:showpageshadow="2" + inkscape:pagecheckerboard="0" + inkscape:deskcolor="#d1d1d1" /><defs + id="defs5523" /><g id="arrow" transform="matrix(2.0520076,0,0,-2.195505,-30.0162,95.07383)"><g transform="matrix(1.3333,0,0,-1.3333,30.307242,34.6674)" diff --git a/app/bin/bitmaps/SVG/convert-to.svg b/app/bin/bitmaps/svg/convert-to.svg index 5876444..5876444 100644 --- a/app/bin/bitmaps/SVG/convert-to.svg +++ b/app/bin/bitmaps/svg/convert-to.svg diff --git a/app/bin/bitmaps/SVG/copy.svg b/app/bin/bitmaps/svg/copy.svg index a865437..a865437 100644 --- a/app/bin/bitmaps/SVG/copy.svg +++ b/app/bin/bitmaps/svg/copy.svg diff --git a/app/bin/bitmaps/SVG/cornu.svg b/app/bin/bitmaps/svg/cornu.svg index be91077..be91077 100644 --- a/app/bin/bitmaps/SVG/cornu.svg +++ b/app/bin/bitmaps/svg/cornu.svg diff --git a/app/bin/bitmaps/SVG/curved-chord.svg b/app/bin/bitmaps/svg/curved-chord.svg index 5db0f01..5db0f01 100644 --- a/app/bin/bitmaps/SVG/curved-chord.svg +++ b/app/bin/bitmaps/svg/curved-chord.svg diff --git a/app/bin/bitmaps/SVG/curved-end.svg b/app/bin/bitmaps/svg/curved-end.svg index 4c76cb4..4c76cb4 100644 --- a/app/bin/bitmaps/SVG/curved-end.svg +++ b/app/bin/bitmaps/svg/curved-end.svg diff --git a/app/bin/bitmaps/SVG/curved-line-chord.svg b/app/bin/bitmaps/svg/curved-line-chord.svg index b1cc041..b1cc041 100644 --- a/app/bin/bitmaps/SVG/curved-line-chord.svg +++ b/app/bin/bitmaps/svg/curved-line-chord.svg diff --git a/app/bin/bitmaps/SVG/curved-line-end.svg b/app/bin/bitmaps/svg/curved-line-end.svg index 365e1bd..365e1bd 100644 --- a/app/bin/bitmaps/SVG/curved-line-end.svg +++ b/app/bin/bitmaps/svg/curved-line-end.svg diff --git a/app/bin/bitmaps/SVG/curved-line-middle.svg b/app/bin/bitmaps/svg/curved-line-middle.svg index 237b453..237b453 100644 --- a/app/bin/bitmaps/SVG/curved-line-middle.svg +++ b/app/bin/bitmaps/svg/curved-line-middle.svg diff --git a/app/bin/bitmaps/SVG/curved-line-tangent.svg b/app/bin/bitmaps/svg/curved-line-tangent.svg index dbac2e2..dbac2e2 100644 --- a/app/bin/bitmaps/SVG/curved-line-tangent.svg +++ b/app/bin/bitmaps/svg/curved-line-tangent.svg diff --git a/app/bin/bitmaps/SVG/curved-middle.svg b/app/bin/bitmaps/svg/curved-middle.svg index 011b402..011b402 100644 --- a/app/bin/bitmaps/SVG/curved-middle.svg +++ b/app/bin/bitmaps/svg/curved-middle.svg diff --git a/app/bin/bitmaps/SVG/curved-tangent.svg b/app/bin/bitmaps/svg/curved-tangent.svg index e9aee6b..e9aee6b 100644 --- a/app/bin/bitmaps/SVG/curved-tangent.svg +++ b/app/bin/bitmaps/svg/curved-tangent.svg diff --git a/app/bin/bitmaps/SVG/cut.svg b/app/bin/bitmaps/svg/cut.svg index 8b8d9f0..8b8d9f0 100644 --- a/app/bin/bitmaps/SVG/cut.svg +++ b/app/bin/bitmaps/svg/cut.svg diff --git a/app/bin/bitmaps/SVG/delete.svg b/app/bin/bitmaps/svg/delete.svg index 55d6471..55d6471 100644 --- a/app/bin/bitmaps/SVG/delete.svg +++ b/app/bin/bitmaps/svg/delete.svg diff --git a/app/bin/bitmaps/SVG/describe.svg b/app/bin/bitmaps/svg/describe.svg index 495a3b8..495a3b8 100644 --- a/app/bin/bitmaps/SVG/describe.svg +++ b/app/bin/bitmaps/svg/describe.svg diff --git a/app/bin/bitmaps/SVG/description.svg b/app/bin/bitmaps/svg/description.svg index 15f43e2..15f43e2 100644 --- a/app/bin/bitmaps/SVG/description.svg +++ b/app/bin/bitmaps/svg/description.svg diff --git a/app/bin/bitmaps/SVG/dimension.svg b/app/bin/bitmaps/svg/dimension.svg index 7443b8a..7443b8a 100644 --- a/app/bin/bitmaps/SVG/dimension.svg +++ b/app/bin/bitmaps/svg/dimension.svg diff --git a/app/bin/bitmaps/SVG/doc-export-bmap.svg b/app/bin/bitmaps/svg/doc-export-bmap.svg index 90a88b0..f6dd9c6 100644 --- a/app/bin/bitmaps/SVG/doc-export-bmap.svg +++ b/app/bin/bitmaps/svg/doc-export-bmap.svg @@ -18,7 +18,7 @@ xmlns:dc="http://purl.org/dc/elements/1.1/"><metadata id="metadata1665"><rdf:RDF><cc:Work rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><defs + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs id="defs1663" /><sodipodi:namedview pagecolor="#ffffff" bordercolor="#666666" @@ -46,23 +46,13 @@ id="layer2" inkscape:label="Export DXF"><path style="fill:#e5d0bc;fill-opacity:1;stroke:#000000;stroke-width:1.08845;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - d="m 45.81776,41.744039 3.150401,4.442557 -0.337543,17.068768 H 0.92453011 V 0.82575003 L 48.74313,0.94265931 48.968158,17.076152 46.549182,20.088854" + d="M 48.968161,46.186596 48.630618,63.255364 H 0.92453011 V 0.82575003 L 48.74313,0.94265931 48.968158,18.648436" id="path849" - sodipodi:nodetypes="cccccccc" /><path + sodipodi:nodetypes="cccccc" /><path style="opacity:0.999;fill:#54a7d6;fill-opacity:1;stroke:#000000;stroke-width:0.348134;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="m 1.488555,32.04338 7.6505091,3.398841 3.3862919,3.398843 1.505019,6.069362 0.627092,6.312136 1.25418,6.554908 2.006693,4.855492 -16.429785,0.121386 z" id="lake" - sodipodi:nodetypes="ccccccccc" /><g - id="arrow" - transform="matrix(0.99468395,0,0,0.97646706,3.2675238,0.70437977)" - inkscape:label="arrow" - style="fill:none;fill-opacity:1;stroke:#cc0000;stroke-width:4.7811;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"><path - style="fill:none;fill-opacity:1;stroke:#cc0000;stroke-width:4.7811;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - d="m 46.398031,40.401712 11.404136,-8.5769 -11.209194,-8.430286" - id="path1484" /><path - style="fill:none;fill-opacity:1;stroke:#cc0000;stroke-width:4.46101;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - d="M 57.802167,31.824812 H 30.622099" - id="path1706" /></g><path + sodipodi:nodetypes="ccccccccc" /><path style="fill:none;stroke:#000000;stroke-width:2.17239;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="m 17.73639,35.772982 0.356685,-15.69413 c 1.305829,-5.853103 2.125288,-5.497379 4.874693,-9.987174" id="path922" @@ -94,4 +84,8 @@ style="opacity:0.998;fill:none;stroke:#000000;stroke-width:2.11841;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="m 45.772104,42.452438 0.01591,4.896454 C 45.426458,53.678042 43.785788,57.38601 36.32066,58.414645 L 29.558257,58.291694 C 22.244079,57.158368 18.761734,53.151166 18.000693,47.102987 L 17.877741,36.406092 C 17.586359,28.846724 11.453325,27.410748 6.0742709,23.741953 5.1148889,21.906907 4.1108952,20.205698 4.1070261,15.504114 5.7689541,8.76985 9.6724691,7.159212 13.574394,5.5449374 L 33.12389,5.2990318 c 7.305654,0.2514013 12.330785,3.466217 12.418233,11.0657502 l 0.114988,4.535242" id="track" - sodipodi:nodetypes="cccccccccccc" /></g></svg> + sodipodi:nodetypes="cccccccccccc" /><path + style="fill:#cc0000;fill-opacity:1;stroke:#f5f5f5;stroke-width:1.67;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 49.781581,18.67186 12.004892,9.672973 c 1.569669,1.986112 1.63065,5.354975 -0.267389,7.361364 l -12.401729,9.618708 -4.115416,-5.022173 6.13417,-4.930619 -18.200761,0.102318 -0.0031,-7.266705 17.677577,0.120129 -5.373841,-4.429189 z" + id="path940" + sodipodi:nodetypes="ccccccccccc" /></g></svg> diff --git a/app/bin/bitmaps/SVG/doc-export-dxf.svg b/app/bin/bitmaps/svg/doc-export-dxf.svg index 30e6e79..d22f028 100644 --- a/app/bin/bitmaps/SVG/doc-export-dxf.svg +++ b/app/bin/bitmaps/svg/doc-export-dxf.svg @@ -100,15 +100,8 @@ style="fill:none;stroke:#666666;stroke-width:1.89027;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="m 44.437406,3.280868 0.0019,16.965896" id="path949-2-3-4" - sodipodi:nodetypes="cc" /></g></g><g - id="arrow" - transform="translate(1.8075544,0.21265346)" - inkscape:label="arrow" - style="stroke:#cc0000;stroke-width:4.7811;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"><path - style="fill:none;fill-opacity:1;stroke:#cc0000;stroke-width:4.7811;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - d="m 46.398031,40.401712 11.404136,-8.5769 -11.209194,-8.749266" - id="path1484" - sodipodi:nodetypes="ccc" /><path - style="fill:none;stroke:#cc0000;stroke-width:4.46101;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - d="M 57.802167,31.824812 H 30.622099" - id="path1706" /></g></g></svg> + sodipodi:nodetypes="cc" /></g></g><path + style="fill:#cc0000;fill-opacity:1;stroke:#f5f5f5;stroke-width:1.67;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 49.567628,18.67186 12.004892,9.672973 c 1.569669,1.986112 1.63065,5.354975 -0.267389,7.361364 l -12.401729,9.618708 -4.115416,-5.022173 6.13417,-4.930619 -18.200761,0.102318 -0.0031,-7.266705 17.677577,0.120129 -5.373841,-4.429189 z" + id="path940" + sodipodi:nodetypes="ccccccccccc" /></g></svg> diff --git a/app/bin/bitmaps/SVG/doc-export-svg.svg b/app/bin/bitmaps/svg/doc-export-svg.svg index fcde438..6872f3c 100644 --- a/app/bin/bitmaps/SVG/doc-export-svg.svg +++ b/app/bin/bitmaps/svg/doc-export-svg.svg @@ -55,17 +55,7 @@ inkscape:rounded="0.2" inkscape:randomized="0" d="m 46.677435,42.424367 c -1.194815,1.501816 -5.645649,5.26905 -7.324235,6.199311 -1.678585,0.930262 -7.232276,2.707471 -9.139082,2.924554 -1.906807,0.217082 -7.717858,-0.266296 -9.562592,-0.795441 -1.844733,-0.529145 -7.028463,-3.19952 -8.530278,-4.394335 C 10.619431,45.16364 6.8521971,40.712806 5.9219358,39.034221 4.9916746,37.355636 3.2144648,31.801944 2.9973824,29.895139 2.7802999,27.988332 3.263678,22.17728 3.792823,20.332547 4.3219679,18.487814 6.9923437,13.304084 8.1871586,11.802268 9.3819738,10.300452 13.832808,6.5332178 15.511393,5.6029565 17.189978,4.6726954 22.74367,2.8954856 24.650476,2.6784031 c 1.906806,-0.2170824 7.717858,0.2662956 9.562591,0.7954407 1.844733,0.5291449 7.028463,3.1995206 8.530279,4.3943355 1.501816,1.1948153 5.26905,5.6456497 6.199312,7.3242347 0.930261,1.678585 2.707471,7.232277 2.924553,9.139082 0.217083,1.906807 -0.266295,7.717859 -0.795441,9.562592 -0.529144,1.844733 -3.19952,7.028463 -4.394335,8.530279 z" - transform="matrix(0.59879059,0,0,0.57681546,1.2240368,1.2665708)" /><g - id="arrow" - inkscape:label="arrow" - style="stroke:#cc0000;stroke-width:5;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - transform="translate(3.296128,0.10188103)"><path - style="fill:none;fill-opacity:1;stroke:#cc0000;stroke-width:5;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - d="m 46.398031,40.401712 11.404136,-8.5769 -11.209194,-8.430286" - id="path1484" /><path - style="fill:none;stroke:#cc0000;stroke-width:5;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - d="M 57.802167,31.824812 H 30.622099" - id="path1706" /></g><path + transform="matrix(0.59879059,0,0,0.57681546,1.2240368,1.2665708)" /><path style="fill:none;stroke:#1a66e5;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="M 4.3166078,61.082184 20.880646,38.63199 37.365489,61.229149 Z" id="path851" @@ -73,4 +63,8 @@ style="fill:none;stroke:#000000;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="M 50.110141,5.2235118 C 40.279181,5.3434014 34.524473,6.4224094 28.769764,8.5804247 20.377481,11.937336 12.824425,17.092597 8.7481732,24.285983 c 0,0 -5.155259,11.149748 0.2397801,18.582913 4.7955897,7.792835 16.1251727,10.190629 16.1251727,10.190629 10.43041,3.956362 24.757235,2.517685 24.757235,2.517685" id="path853" - sodipodi:nodetypes="cccccc" /></g></svg> + sodipodi:nodetypes="cccccc" /><path + style="fill:#cc0000;fill-opacity:1;stroke:#f5f5f5;stroke-width:1.67;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 49.780281,18.67186 12.004892,9.672973 c 1.569669,1.986112 1.63065,5.354975 -0.267389,7.361364 l -12.401729,9.618708 -4.115416,-5.022173 6.13417,-4.930619 -18.200761,0.102318 -0.0031,-7.266705 17.677577,0.120129 -5.373841,-4.429189 z" + id="path940" + sodipodi:nodetypes="ccccccccccc" /></g></svg> diff --git a/app/bin/bitmaps/SVG/doc-export.svg b/app/bin/bitmaps/svg/doc-export.svg index 6954caf..6954caf 100644 --- a/app/bin/bitmaps/SVG/doc-export.svg +++ b/app/bin/bitmaps/svg/doc-export.svg diff --git a/app/bin/bitmaps/SVG/doc-import.svg b/app/bin/bitmaps/svg/doc-import-mod.svg index e2bfc72..28bd818 100644 --- a/app/bin/bitmaps/SVG/doc-import.svg +++ b/app/bin/bitmaps/svg/doc-import-mod.svg @@ -4,7 +4,7 @@ viewBox="0 0 64 64" xml:space="preserve" id="svg1659" - sodipodi:docname="doc-import.svg" + sodipodi:docname="doc-import-xtc.svg" inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" @@ -22,7 +22,7 @@ transform="rotate(90)" /><metadata id="metadata1665"><rdf:RDF><cc:Work rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><defs + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs id="defs1663" /><sodipodi:namedview pagecolor="#ffffff" bordercolor="#666666" @@ -36,9 +36,9 @@ inkscape:window-height="866" id="namedview1661" showgrid="false" - inkscape:zoom="9.4049726" - inkscape:cx="12.227574" - inkscape:cy="32.961287" + inkscape:zoom="8.7705101" + inkscape:cx="35.117684" + inkscape:cy="32.951333" inkscape:window-x="18" inkscape:window-y="57" inkscape:window-maximized="0" diff --git a/app/bin/bitmaps/SVG/doc-import-xtc.svg b/app/bin/bitmaps/svg/doc-import.svg index 01f2275..9a7eaa2 100644 --- a/app/bin/bitmaps/SVG/doc-import-xtc.svg +++ b/app/bin/bitmaps/svg/doc-import.svg @@ -4,7 +4,7 @@ viewBox="0 0 64 64" xml:space="preserve" id="svg1659" - sodipodi:docname="doc-import-xtc.svg" + sodipodi:docname="doc-import.svg" inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" @@ -22,7 +22,7 @@ transform="rotate(90)" /><metadata id="metadata1665"><rdf:RDF><cc:Work rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><defs + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs id="defs1663" /><sodipodi:namedview pagecolor="#ffffff" bordercolor="#666666" @@ -37,7 +37,7 @@ id="namedview1661" showgrid="false" inkscape:zoom="9.4049726" - inkscape:cx="12.227574" + inkscape:cx="30.941079" inkscape:cy="32.961287" inkscape:window-x="18" inkscape:window-y="57" diff --git a/app/bin/bitmaps/SVG/doc-new.svg b/app/bin/bitmaps/svg/doc-new.svg index 6aac25e..e324191 100644 --- a/app/bin/bitmaps/SVG/doc-new.svg +++ b/app/bin/bitmaps/svg/doc-new.svg @@ -15,7 +15,7 @@ xmlns:dc="http://purl.org/dc/elements/1.1/"><metadata id="metadata1665"><rdf:RDF><cc:Work rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><defs + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs id="defs1663" /><sodipodi:namedview pagecolor="#ffffff" bordercolor="#666666" @@ -50,14 +50,14 @@ y="-55.713051" transform="rotate(90)" /><g id="plus" - transform="matrix(1.6740309,0,0,1.6334616,-51.092795,-24.413751)" + transform="matrix(1.5984081,0,0,1.5596714,-48.1547,-23.370556)" inkscape:label="plus"><path - style="display:inline;fill:#005a20;fill-opacity:1;stroke:#00993d;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + style="display:inline;fill:#005a20;fill-opacity:1;stroke:#0082cc;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="m 46.809533,31.077554 v -4.700241 h 4.630089 v -3.086726 l -4.559936,0.07015 -0.07015,-4.559936 h -3.016572 l 0.140305,4.559936 -4.840547,0.07015 0.07015,3.086726 4.489783,-0.07015 0.140306,4.630088 z" id="path1718" /><path - style="fill:none;fill-opacity:1;stroke:#00e552;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + style="fill:none;fill-opacity:1;stroke:#05a3ff;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="M 45.350068,18.723791 V 31.070694" id="path1702" /><path - style="fill:none;fill-opacity:1;stroke:#00e552;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + style="fill:none;fill-opacity:1;stroke:#05a3ff;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="M 51.516636,24.897242 H 39.169733" id="path1708" /></g></g></svg> diff --git a/app/bin/bitmaps/SVG/doc-open.svg b/app/bin/bitmaps/svg/doc-open.svg index ede9909..ede9909 100644 --- a/app/bin/bitmaps/SVG/doc-open.svg +++ b/app/bin/bitmaps/svg/doc-open.svg diff --git a/app/bin/bitmaps/SVG/doc-print.svg b/app/bin/bitmaps/svg/doc-print.svg index 1926edf..1926edf 100644 --- a/app/bin/bitmaps/SVG/doc-print.svg +++ b/app/bin/bitmaps/svg/doc-print.svg diff --git a/app/bin/bitmaps/svg/doc-recent.svg b/app/bin/bitmaps/svg/doc-recent.svg new file mode 100644 index 0000000..5718a2f --- /dev/null +++ b/app/bin/bitmaps/svg/doc-recent.svg @@ -0,0 +1,63 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + version="1.1" + viewBox="0 0 64 64" + xml:space="preserve" + id="svg1659" + sodipodi:docname="doc-recent.svg" + inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/"><metadata + id="metadata1665"><rdf:RDF><cc:Work + rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs + id="defs1663" /><sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1688" + inkscape:window-height="943" + id="namedview1661" + showgrid="false" + inkscape:zoom="8.1826993" + inkscape:cx="32.079879" + inkscape:cy="27.558143" + inkscape:window-x="0" + inkscape:window-y="0" + inkscape:window-maximized="0" + inkscape:current-layer="Layout" + inkscape:document-rotation="0" + inkscape:pagecheckerboard="0" /><g + id="Layout" + inkscape:label="#layout" + transform="translate(-0.22803691,0.91214765)" + style="opacity:1"><rect + style="fill:#f5f5f5;fill-opacity:1;stroke:#666666;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + id="rect900" + width="60.915188" + height="46.970028" + x="0.63025844" + y="-55.713051" + transform="rotate(90)" /><g + id="g827" + transform="matrix(1.0619869,0,0,1.0619869,-1.2047468,-0.93973971)"><ellipse + style="opacity:1;fill:none;fill-rule:evenodd;stroke:#005fff;stroke-width:2.60267;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" + id="path929" + cx="24.364325" + cy="16.018827" + rx="9.542079" + ry="9.4148512" /><path + style="fill:none;stroke:#005fff;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 24.526241,10.323952 0.115076,5.901701 h 4.399527" + id="path964" + sodipodi:nodetypes="ccc" /></g></g></svg> diff --git a/app/bin/bitmaps/SVG/doc-revert.svg b/app/bin/bitmaps/svg/doc-revert.svg index f5b6290..f5b6290 100644 --- a/app/bin/bitmaps/SVG/doc-revert.svg +++ b/app/bin/bitmaps/svg/doc-revert.svg diff --git a/app/bin/bitmaps/SVG/doc-save-as.svg b/app/bin/bitmaps/svg/doc-save-as.svg index cf9244d..cf9244d 100644 --- a/app/bin/bitmaps/SVG/doc-save-as.svg +++ b/app/bin/bitmaps/svg/doc-save-as.svg diff --git a/app/bin/bitmaps/SVG/doc-save.svg b/app/bin/bitmaps/svg/doc-save.svg index 3a553dd..3a553dd 100644 --- a/app/bin/bitmaps/SVG/doc-save.svg +++ b/app/bin/bitmaps/svg/doc-save.svg diff --git a/app/bin/bitmaps/SVG/doc-setup.svg b/app/bin/bitmaps/svg/doc-setup.svg index 1219b1e..1219b1e 100644 --- a/app/bin/bitmaps/SVG/doc-setup.svg +++ b/app/bin/bitmaps/svg/doc-setup.svg diff --git a/app/bin/bitmaps/SVG/down.svg b/app/bin/bitmaps/svg/down.svg index 41f83fb..41f83fb 100644 --- a/app/bin/bitmaps/SVG/down.svg +++ b/app/bin/bitmaps/svg/down.svg diff --git a/app/bin/bitmaps/SVG/elevation.svg b/app/bin/bitmaps/svg/elevation.svg index b6f9813..b6f9813 100644 --- a/app/bin/bitmaps/SVG/elevation.svg +++ b/app/bin/bitmaps/svg/elevation.svg diff --git a/app/bin/bitmaps/SVG/exit.svg b/app/bin/bitmaps/svg/exit.svg index 210bdb9..210bdb9 100644 --- a/app/bin/bitmaps/SVG/exit.svg +++ b/app/bin/bitmaps/svg/exit.svg diff --git a/app/bin/bitmaps/SVG/extend.svg b/app/bin/bitmaps/svg/extend.svg index eac7840..eac7840 100644 --- a/app/bin/bitmaps/SVG/extend.svg +++ b/app/bin/bitmaps/svg/extend.svg diff --git a/app/bin/bitmaps/SVG/filled-box.svg b/app/bin/bitmaps/svg/filled-box.svg index 2d8e2dd..2d8e2dd 100644 --- a/app/bin/bitmaps/SVG/filled-box.svg +++ b/app/bin/bitmaps/svg/filled-box.svg diff --git a/app/bin/bitmaps/SVG/filled-polygon.svg b/app/bin/bitmaps/svg/filled-polygon.svg index 6fe8cce..6fe8cce 100644 --- a/app/bin/bitmaps/SVG/filled-polygon.svg +++ b/app/bin/bitmaps/svg/filled-polygon.svg diff --git a/app/bin/bitmaps/SVG/go.svg b/app/bin/bitmaps/svg/go.svg index 943e561..943e561 100644 --- a/app/bin/bitmaps/SVG/go.svg +++ b/app/bin/bitmaps/svg/go.svg diff --git a/app/bin/bitmaps/SVG/grid.svg b/app/bin/bitmaps/svg/grid.svg index 23b9b93..23b9b93 100644 --- a/app/bin/bitmaps/SVG/grid.svg +++ b/app/bin/bitmaps/svg/grid.svg diff --git a/app/bin/bitmaps/SVG/helix.svg b/app/bin/bitmaps/svg/helix.svg index c88f470..c88f470 100644 --- a/app/bin/bitmaps/SVG/helix.svg +++ b/app/bin/bitmaps/svg/helix.svg diff --git a/app/bin/bitmaps/SVG/Info.svg b/app/bin/bitmaps/svg/info.svg index 979601d..979601d 100644 --- a/app/bin/bitmaps/SVG/Info.svg +++ b/app/bin/bitmaps/svg/info.svg diff --git a/app/bin/bitmaps/SVG/join-line.svg b/app/bin/bitmaps/svg/join-line.svg index feb8a93..feb8a93 100644 --- a/app/bin/bitmaps/SVG/join-line.svg +++ b/app/bin/bitmaps/svg/join-line.svg diff --git a/app/bin/bitmaps/SVG/join.svg b/app/bin/bitmaps/svg/join.svg index c441656..c441656 100644 --- a/app/bin/bitmaps/SVG/join.svg +++ b/app/bin/bitmaps/svg/join.svg diff --git a/app/bin/bitmaps/SVG/layers.svg b/app/bin/bitmaps/svg/layers.svg index b261d30..b261d30 100644 --- a/app/bin/bitmaps/SVG/layers.svg +++ b/app/bin/bitmaps/svg/layers.svg diff --git a/app/bin/bitmaps/svg/loosen.svg b/app/bin/bitmaps/svg/loosen.svg new file mode 100644 index 0000000..eb3d0a6 --- /dev/null +++ b/app/bin/bitmaps/svg/loosen.svg @@ -0,0 +1,146 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + version="1.1" + id="Layer_1" + x="0px" + y="0px" + viewBox="0 0 48 48" + style="enable-background:new 0 0 48 48;" + xml:space="preserve" + sodipodi:docname="loosen.svg" + inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/"><metadata + id="metadata39"><rdf:RDF><cc:Work + rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs + id="defs37" /><sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1436" + inkscape:window-height="950" + id="namedview35" + showgrid="false" + inkscape:zoom="13.417014" + inkscape:cx="24.036645" + inkscape:cy="23.999379" + inkscape:window-x="0" + inkscape:window-y="0" + inkscape:window-maximized="0" + inkscape:current-layer="Layer_1" + inkscape:document-rotation="0" + inkscape:pagecheckerboard="0" /> +<style + type="text/css" + id="style2"> + .st0{fill:none;stroke:#5494FF;stroke-width:2;stroke-miterlimit:10;} + .st1{fill:none;stroke:#003794;stroke-miterlimit:10;} + .st2{fill:none;stroke:#FB0000;stroke-width:2;stroke-miterlimit:10;} + .st3{fill:none;stroke:#FB0000;stroke-miterlimit:10;} + .st4{fill:none;stroke:#FB0000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;} +</style> +<line + class="st0" + x1="4.3307743" + y1="9.274683" + x2="4.3307743" + y2="23.698782" + id="line4" /> +<line + class="st0" + x1="10.887182" + y1="9.274683" + x2="10.887182" + y2="23.698782" + id="line6" /> +<line + class="st0" + x1="17.44359" + y1="9.274683" + x2="17.44359" + y2="23.698782" + id="line8" /> +<line + class="st0" + x1="30.556406" + y1="9.274683" + x2="30.556406" + y2="23.698782" + id="line10" /> +<line + class="st0" + x1="37.112816" + y1="9.274683" + x2="37.112816" + y2="23.698782" + id="line12" /> +<line + class="st0" + x1="43.669224" + y1="9.274683" + x2="43.669224" + y2="23.698782" + id="line14" /> +<line + class="st1" + x1="27.249117" + y1="12.130193" + x2="46.29179" + y2="12.130193" + id="line16" + style="stroke-width:2;stroke-miterlimit:10;stroke-dasharray:none" /> +<line + class="st1" + x1="1.7082114" + y1="12.130193" + x2="20.750879" + y2="12.130193" + id="line18" + style="stroke-width:2;stroke-miterlimit:10;stroke-dasharray:none" /> +<line + class="st1" + x1="27.249117" + y1="20.76922" + x2="46.29179" + y2="20.76922" + id="line20" + style="stroke-width:2;stroke-miterlimit:10;stroke-dasharray:none" /> +<line + class="st1" + x1="1.7082114" + y1="20.76922" + x2="20.750879" + y2="20.76922" + id="line22" + style="stroke-width:2;stroke-miterlimit:10;stroke-dasharray:none" /> + +<path + class="st3" + d="M 26.229179,29.861805" + id="path26" + style="stroke-width:1.31128" /> +<polyline + class="st4" + points="28.5,33.3 24.2,29 28.5,24.8 " + id="polyline28" + style="stroke:#cc0000;stroke-width:3.18899611;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1" + transform="matrix(-1.1826806,0,0,1.3302845,60.9101,-7.1314984)" /> + +<polyline + class="st4" + points="18.3,33.3 21.8,29 18.3,24.8 " + id="polyline32" + style="stroke:#cc0000;stroke-width:3.0504508;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1" + transform="matrix(-1.3112816,0,0,1.3112816,44.604466,-6.5794627)" /> +</svg> diff --git a/app/bin/bitmaps/SVG/magnet.svg b/app/bin/bitmaps/svg/magnet.svg index 9d0b3a6..9d0b3a6 100644 --- a/app/bin/bitmaps/SVG/magnet.svg +++ b/app/bin/bitmaps/svg/magnet.svg diff --git a/app/bin/bitmaps/SVG/manage.svg b/app/bin/bitmaps/svg/manage.svg index 2791e15..2791e15 100644 --- a/app/bin/bitmaps/SVG/manage.svg +++ b/app/bin/bitmaps/svg/manage.svg diff --git a/app/bin/bitmaps/SVG/map.svg b/app/bin/bitmaps/svg/map.svg index 69686be..69686be 100644 --- a/app/bin/bitmaps/SVG/map.svg +++ b/app/bin/bitmaps/svg/map.svg diff --git a/app/bin/bitmaps/SVG/move.svg b/app/bin/bitmaps/svg/move.svg index 9c1e906..9c1e906 100644 --- a/app/bin/bitmaps/SVG/move.svg +++ b/app/bin/bitmaps/svg/move.svg diff --git a/app/bin/bitmaps/SVG/new-car.svg b/app/bin/bitmaps/svg/new-car.svg index 6b0d579..6b0d579 100644 --- a/app/bin/bitmaps/SVG/new-car.svg +++ b/app/bin/bitmaps/svg/new-car.svg diff --git a/app/bin/bitmaps/SVG/ok.svg b/app/bin/bitmaps/svg/ok.svg index 21e0640..21e0640 100644 --- a/app/bin/bitmaps/SVG/ok.svg +++ b/app/bin/bitmaps/svg/ok.svg diff --git a/app/bin/bitmaps/SVG/pan-zoom.svg b/app/bin/bitmaps/svg/pan-zoom.svg index 7597072..7597072 100644 --- a/app/bin/bitmaps/SVG/pan-zoom.svg +++ b/app/bin/bitmaps/svg/pan-zoom.svg diff --git a/app/bin/bitmaps/SVG/parallel-line.svg b/app/bin/bitmaps/svg/parallel-line.svg index ad96c16..ad96c16 100644 --- a/app/bin/bitmaps/SVG/parallel-line.svg +++ b/app/bin/bitmaps/svg/parallel-line.svg diff --git a/app/bin/bitmaps/SVG/parallel.svg b/app/bin/bitmaps/svg/parallel.svg index 9ff2898..9ff2898 100644 --- a/app/bin/bitmaps/SVG/parallel.svg +++ b/app/bin/bitmaps/svg/parallel.svg diff --git a/app/bin/bitmaps/SVG/parameter.svg b/app/bin/bitmaps/svg/parameter.svg index b686804..b686804 100644 --- a/app/bin/bitmaps/SVG/parameter.svg +++ b/app/bin/bitmaps/svg/parameter.svg diff --git a/app/bin/bitmaps/SVG/paste.svg b/app/bin/bitmaps/svg/paste.svg index 7d089d6..7d089d6 100644 --- a/app/bin/bitmaps/SVG/paste.svg +++ b/app/bin/bitmaps/svg/paste.svg diff --git a/app/bin/bitmaps/SVG/polygon.svg b/app/bin/bitmaps/svg/polygon.svg index f8aa925..f8aa925 100644 --- a/app/bin/bitmaps/SVG/polygon.svg +++ b/app/bin/bitmaps/svg/polygon.svg diff --git a/app/bin/bitmaps/SVG/polyline.svg b/app/bin/bitmaps/svg/polyline.svg index 695bad9..695bad9 100644 --- a/app/bin/bitmaps/SVG/polyline.svg +++ b/app/bin/bitmaps/svg/polyline.svg diff --git a/app/bin/bitmaps/SVG/profile.svg b/app/bin/bitmaps/svg/profile.svg index 9f76546..9f76546 100644 --- a/app/bin/bitmaps/SVG/profile.svg +++ b/app/bin/bitmaps/svg/profile.svg diff --git a/app/bin/bitmaps/SVG/protractor.svg b/app/bin/bitmaps/svg/protractor.svg index 6e7d141..6e7d141 100644 --- a/app/bin/bitmaps/SVG/protractor.svg +++ b/app/bin/bitmaps/svg/protractor.svg diff --git a/app/bin/bitmaps/SVG/redo.svg b/app/bin/bitmaps/svg/redo.svg index 77c8cb8..77c8cb8 100644 --- a/app/bin/bitmaps/SVG/redo.svg +++ b/app/bin/bitmaps/svg/redo.svg diff --git a/app/bin/bitmaps/SVG/reflect.svg b/app/bin/bitmaps/svg/reflect.svg index 837743c..837743c 100644 --- a/app/bin/bitmaps/SVG/reflect.svg +++ b/app/bin/bitmaps/svg/reflect.svg diff --git a/app/bin/bitmaps/svg/roadbed.svg b/app/bin/bitmaps/svg/roadbed.svg new file mode 100644 index 0000000..0a2f264 --- /dev/null +++ b/app/bin/bitmaps/svg/roadbed.svg @@ -0,0 +1,121 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + version="1.1" + viewBox="0 0 64 64" + xml:space="preserve" + id="svg1659" + sodipodi:docname="roadbed.svg" + inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/"><metadata + id="metadata1665"><rdf:RDF><cc:Work + rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs + id="defs1663" /><sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1393" + inkscape:window-height="866" + id="namedview1661" + showgrid="false" + inkscape:zoom="8.1776315" + inkscape:cx="36.1963" + inkscape:cy="32.038617" + inkscape:window-x="0" + inkscape:window-y="0" + inkscape:window-maximized="0" + inkscape:current-layer="svg1659" + inkscape:document-rotation="0" + inkscape:pagecheckerboard="0" /><path + style="fill:#cccccc;fill-opacity:1;stroke:#cccccc;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="m 1.3451327,10.638778 0,43.044247 H 25.068383 L 38.764281,10.761062 Z" + id="path1255" + sodipodi:nodetypes="ccccc" /><g + id="track" + style="display:inline" + transform="matrix(1.0504573,0,0,1.0504573,-1.6146336,-1.5690294)"><g + id="ties" + inkscape:label="#ties" + style="stroke:#d88b0d;stroke-width:2.667;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + transform="matrix(1.3028702,0,0,1.3028702,-9.6908041,-5.2415278)"><path + d="M 11.9997,21.3344 V 36.0007" + fill="none" + stroke="#fbb03b" + stroke-miterlimit="10" + stroke-width="2.6666" + id="path1597" + style="stroke:#d88b0d;stroke-width:2.667;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /><path + d="M 0,0 V -11" + fill="none" + stroke="#fbb03b" + stroke-miterlimit="10" + stroke-width="2" + id="path1601" + transform="matrix(1.3333,0,0,-1.3333,18.6662,21.3344)" + style="stroke:#d88b0d;stroke-width:2.0003;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /><path + d="M 25.3327,21.3344 V 36.0007" + fill="none" + stroke="#fbb03b" + stroke-miterlimit="10" + stroke-width="2.6666" + id="path1605" + style="stroke:#d88b0d;stroke-width:2.667;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /><path + d="M 31.9992,21.3344 V 36.0007" + fill="none" + stroke="#fbb03b" + stroke-miterlimit="10" + stroke-width="2.6666" + id="path1609" + style="stroke:#d88b0d;stroke-width:2.667;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /><path + d="M 38.6657,21.3344 V 36.0007" + fill="none" + stroke="#fbb03b" + stroke-miterlimit="10" + stroke-width="2.6666" + id="path1613" + style="stroke:#d88b0d;stroke-width:2.667;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /><path + d="M 45.3322,21.3344 V 36.0007" + fill="none" + stroke="#fbb03b" + stroke-miterlimit="10" + stroke-width="2.6666" + id="path1617" + style="stroke:#d88b0d;stroke-width:2.667;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /><path + d="M 51.9987,21.3344 V 36.0007" + fill="none" + stroke="#fbb03b" + stroke-miterlimit="10" + stroke-width="2.6666" + id="path1621" + style="stroke:#d88b0d;stroke-width:2.667;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /></g><g + id="rails" + inkscape:label="#rails" + style="stroke-width:2;stroke-miterlimit:10;stroke-dasharray:none" + transform="matrix(1.3028702,0,0,1.3028702,-9.6908041,-5.2415278)"><path + d="M 9.3331,24.185806 H 54.6653" + fill="none" + stroke="#000000" + stroke-miterlimit="10" + id="path1625" + style="stroke-width:2.30261;stroke-miterlimit:10;stroke-dasharray:none" /><path + d="M 9.3331,33.149294 H 54.6653" + fill="none" + stroke="#000000" + stroke-miterlimit="10" + id="path1629" + style="stroke-width:2.30261;stroke-miterlimit:10;stroke-dasharray:none" /></g></g><path + style="fill:none;stroke:#cc0000;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="M 40.131939,10.661303 23.868061,53.338697" + id="path947" + sodipodi:nodetypes="cc" /></svg> diff --git a/app/bin/bitmaps/SVG/rotate.svg b/app/bin/bitmaps/svg/rotate.svg index 2c788f2..2c788f2 100644 --- a/app/bin/bitmaps/SVG/rotate.svg +++ b/app/bin/bitmaps/svg/rotate.svg diff --git a/app/bin/bitmaps/SVG/ruler.svg b/app/bin/bitmaps/svg/ruler.svg index 8cb140b..8cb140b 100644 --- a/app/bin/bitmaps/SVG/ruler.svg +++ b/app/bin/bitmaps/svg/ruler.svg diff --git a/app/bin/bitmaps/SVG/select.svg b/app/bin/bitmaps/svg/select.svg index bb81e69..bb81e69 100644 --- a/app/bin/bitmaps/SVG/select.svg +++ b/app/bin/bitmaps/svg/select.svg diff --git a/app/bin/bitmaps/SVG/sensor.svg b/app/bin/bitmaps/svg/sensor.svg index 4188f0e..4188f0e 100644 --- a/app/bin/bitmaps/SVG/sensor.svg +++ b/app/bin/bitmaps/svg/sensor.svg diff --git a/app/bin/bitmaps/SVG/signal.svg b/app/bin/bitmaps/svg/signal.svg index ad01427..c0e11be 100644 --- a/app/bin/bitmaps/SVG/signal.svg +++ b/app/bin/bitmaps/svg/signal.svg @@ -4,7 +4,7 @@ viewBox="0 0 64 64" xml:space="preserve" id="svg27" - sodipodi:docname="signal.svg" + sodipodi:docname="signal1.svg" inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" @@ -30,7 +30,7 @@ showgrid="false" inkscape:zoom="9.3956422" inkscape:cx="31.982912" - inkscape:cy="35.016233" + inkscape:cy="7.8759917" inkscape:window-x="0" inkscape:window-y="0" inkscape:window-maximized="0" @@ -62,17 +62,21 @@ id="path11" style="stroke-width:1.47008;stroke-miterlimit:4;stroke-dasharray:none" /></g><g clip-path="url(#clipPath3381)" - id="g23" - transform="matrix(2.1918574,0,0,-2.4227971,-21.664458,94.940764)"><g - transform="translate(27.604,31.282)" - id="g17"><path - d="m 0,0 c 0,-1.489 -1.294,-2.697 -2.89,-2.697 -1.595,0 -2.889,1.208 -2.889,2.697 0,1.489 1.294,2.696 2.889,2.696 C -1.294,2.696 0,1.489 0,0" - fill="#f40f3b" - id="path15" /></g><g - transform="translate(27.604,31.282)" - id="g21"><path - d="m 0,0 c 0,-1.489 -1.294,-2.697 -2.89,-2.697 -1.595,0 -2.889,1.208 -2.889,2.697 0,1.489 1.294,2.696 2.889,2.696 C -1.294,2.696 0,1.489 0,0 Z" - fill="none" - stroke="#020000" - stroke-miterlimit="10" - id="path19" /></g></g></g></svg> + id="signal" + transform="matrix(1.1339699,0,0,-1.2534478,4.6618651,54.929612)" + style="display:inline"><path + d="m 27.383451,24.789336 c 0,-1.615182 -1.294,-2.925552 -2.89,-2.925552 -1.595,0 -2.889,1.31037 -2.889,2.925552 0,0.807592 -0.04119,4.493604 0.116996,6.842029 0.151733,2.252629 2.092782,2.686262 2.890282,2.686262 0.798,0 2.830828,-0.40148 2.85173,-2.644199 0.02032,-2.180176 -0.08001,-6.0765 -0.08001,-6.884092 z" + fill="none" + stroke="#020000" + stroke-miterlimit="10" + id="target" + sodipodi:nodetypes="sssssss" + style="fill:#000000;fill-opacity:1;stroke-width:1.04151" /><path + d="m 27.19258,31.345607 c 0,-1.340191 -1.164679,-2.427465 -2.601177,-2.427465 -1.435597,0 -2.600277,1.087274 -2.600277,2.427465 0,1.340192 1.16468,2.426566 2.600277,2.426566 1.436498,0 2.601177,-1.086374 2.601177,-2.426566" + fill="#f40f3b" + id="red" + style="display:inline;stroke-width:0.900061" /><path + d="m 27.076572,24.835939 c 0,-1.326466 -1.152752,-2.402605 -2.574538,-2.402605 -1.420896,0 -2.573648,1.076139 -2.573648,2.402605 0,1.326467 1.152752,2.401715 2.573648,2.401715 1.421786,0 2.574538,-1.075248 2.574538,-2.401715" + fill="#f40f3b" + id="green" + style="display:inline;fill:#10db0b;fill-opacity:1;stroke:none;stroke-width:0.890844;stroke-opacity:1" /></g></g></svg> diff --git a/app/bin/bitmaps/SVG/snap-curs.svg b/app/bin/bitmaps/svg/snap-curs.svg index fa700ce..fa700ce 100644 --- a/app/bin/bitmaps/SVG/snap-curs.svg +++ b/app/bin/bitmaps/svg/snap-curs.svg diff --git a/app/bin/bitmaps/SVG/snap-grid.svg b/app/bin/bitmaps/svg/snap-grid.svg index f6650a7..f6650a7 100644 --- a/app/bin/bitmaps/SVG/snap-grid.svg +++ b/app/bin/bitmaps/svg/snap-grid.svg diff --git a/app/bin/bitmaps/SVG/split-draw.svg b/app/bin/bitmaps/svg/split-draw.svg index d74ee25..d74ee25 100644 --- a/app/bin/bitmaps/SVG/split-draw.svg +++ b/app/bin/bitmaps/svg/split-draw.svg diff --git a/app/bin/bitmaps/SVG/split.svg b/app/bin/bitmaps/svg/split.svg index 2bc28cb..2bc28cb 100644 --- a/app/bin/bitmaps/SVG/split.svg +++ b/app/bin/bitmaps/svg/split.svg diff --git a/app/bin/bitmaps/SVG/star.svg b/app/bin/bitmaps/svg/star.svg index 13f0914..13f0914 100644 --- a/app/bin/bitmaps/SVG/star.svg +++ b/app/bin/bitmaps/svg/star.svg diff --git a/app/bin/bitmaps/SVG/sticky-doc.svg b/app/bin/bitmaps/svg/sticky-doc.svg index 20ea76f..20ea76f 100644 --- a/app/bin/bitmaps/SVG/sticky-doc.svg +++ b/app/bin/bitmaps/svg/sticky-doc.svg diff --git a/app/bin/bitmaps/SVG/sticky-link.svg b/app/bin/bitmaps/svg/sticky-link.svg index f403661..f403661 100644 --- a/app/bin/bitmaps/SVG/sticky-link.svg +++ b/app/bin/bitmaps/svg/sticky-link.svg diff --git a/app/bin/bitmaps/SVG/sticky-note.svg b/app/bin/bitmaps/svg/sticky-note.svg index 1fe3d30..1fe3d30 100644 --- a/app/bin/bitmaps/SVG/sticky-note.svg +++ b/app/bin/bitmaps/svg/sticky-note.svg diff --git a/app/bin/bitmaps/SVG/stop.svg b/app/bin/bitmaps/svg/stop.svg index 4bd5fa0..4bd5fa0 100644 --- a/app/bin/bitmaps/SVG/stop.svg +++ b/app/bin/bitmaps/svg/stop.svg diff --git a/app/bin/bitmaps/SVG/straight-line.svg b/app/bin/bitmaps/svg/straight-line.svg index 32a01a3..32a01a3 100644 --- a/app/bin/bitmaps/SVG/straight-line.svg +++ b/app/bin/bitmaps/svg/straight-line.svg diff --git a/app/bin/bitmaps/SVG/straight.svg b/app/bin/bitmaps/svg/straight.svg index 6c5f37b..6c5f37b 100644 --- a/app/bin/bitmaps/SVG/straight.svg +++ b/app/bin/bitmaps/svg/straight.svg diff --git a/app/bin/bitmaps/SVG/switch-ai.svg b/app/bin/bitmaps/svg/switch-motor.svg index 9c842e3..9c842e3 100644 --- a/app/bin/bitmaps/SVG/switch-ai.svg +++ b/app/bin/bitmaps/svg/switch-motor.svg diff --git a/app/bin/bitmaps/SVG/switchm.svg b/app/bin/bitmaps/svg/switchm.svg index 5064f4e..5064f4e 100644 --- a/app/bin/bitmaps/SVG/switchm.svg +++ b/app/bin/bitmaps/svg/switchm.svg diff --git a/app/bin/bitmaps/SVG/switchmdel.svg b/app/bin/bitmaps/svg/switchmdel.svg index cdf6d81..cdf6d81 100644 --- a/app/bin/bitmaps/SVG/switchmdel.svg +++ b/app/bin/bitmaps/svg/switchmdel.svg diff --git a/app/bin/bitmaps/SVG/switchmedit.svg b/app/bin/bitmaps/svg/switchmedit.svg index 9a2008a..9a2008a 100644 --- a/app/bin/bitmaps/SVG/switchmedit.svg +++ b/app/bin/bitmaps/svg/switchmedit.svg diff --git a/app/bin/bitmaps/SVG/switchmnew.svg b/app/bin/bitmaps/svg/switchmnew.svg index 4f8a2e6..4f8a2e6 100644 --- a/app/bin/bitmaps/SVG/switchmnew.svg +++ b/app/bin/bitmaps/svg/switchmnew.svg diff --git a/app/bin/bitmaps/SVG/table-edge.svg b/app/bin/bitmaps/svg/table-edge.svg index e2663ac..e2663ac 100644 --- a/app/bin/bitmaps/SVG/table-edge.svg +++ b/app/bin/bitmaps/svg/table-edge.svg diff --git a/app/bin/bitmaps/SVG/text.svg b/app/bin/bitmaps/svg/text.svg index c5e5c32..c5e5c32 100644 --- a/app/bin/bitmaps/SVG/text.svg +++ b/app/bin/bitmaps/svg/text.svg diff --git a/app/bin/bitmaps/svg/ties.svg b/app/bin/bitmaps/svg/ties.svg new file mode 100644 index 0000000..b8e8c35 --- /dev/null +++ b/app/bin/bitmaps/svg/ties.svg @@ -0,0 +1,97 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + version="1.1" + viewBox="0 0 64 64" + xml:space="preserve" + id="svg1659" + sodipodi:docname="ties.svg" + inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/"><metadata + id="metadata1665"><rdf:RDF><cc:Work + rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs + id="defs1663" /><sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1393" + inkscape:window-height="866" + id="namedview1661" + showgrid="false" + inkscape:zoom="8.1776315" + inkscape:cx="36.1963" + inkscape:cy="32.038617" + inkscape:window-x="0" + inkscape:window-y="0" + inkscape:window-maximized="0" + inkscape:current-layer="svg1659" + inkscape:document-rotation="0" + inkscape:pagecheckerboard="0" /><g + id="track" + style="display:inline" + transform="matrix(1.0504573,0,0,1.0504573,-1.6146336,-1.5690294)"><g + id="ties" + inkscape:label="#ties" + style="stroke:#d88b0d;stroke-width:2.667;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + transform="matrix(1.3028702,0,0,1.3028702,-9.6908041,-5.2415278)"><path + d="M 11.9997,21.3344 V 36.0007" + fill="none" + stroke="#fbb03b" + stroke-miterlimit="10" + stroke-width="2.6666" + id="path1597" + style="stroke:#d88b0d;stroke-width:2.667;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /><path + d="M 0,0 V -11" + fill="none" + stroke="#fbb03b" + stroke-miterlimit="10" + stroke-width="2" + id="path1601" + transform="matrix(1.3333,0,0,-1.3333,18.6662,21.3344)" + style="stroke:#d88b0d;stroke-width:2.0003;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /><path + d="M 25.3327,21.3344 V 36.0007" + fill="none" + stroke="#fbb03b" + stroke-miterlimit="10" + stroke-width="2.6666" + id="path1605" + style="stroke:#d88b0d;stroke-width:2.667;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /><path + d="m 31.9992,21.3344 v 7.250278" + fill="none" + stroke="#fbb03b" + stroke-miterlimit="10" + stroke-width="2.6666" + id="path1609" + style="stroke:#d88b0d;stroke-width:2.667;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + sodipodi:nodetypes="cc" /></g><g + id="rails" + inkscape:label="#rails" + style="stroke-width:2;stroke-miterlimit:10;stroke-dasharray:none" + transform="matrix(1.3028702,0,0,1.3028702,-9.6908041,-5.2415278)"><path + d="M 9.3331,24.185806 H 54.6653" + fill="none" + stroke="#000000" + stroke-miterlimit="10" + id="path1625" + style="stroke-width:2.30261;stroke-miterlimit:10;stroke-dasharray:none" /><path + d="M 9.3331,33.149294 H 54.6653" + fill="none" + stroke="#000000" + stroke-miterlimit="10" + id="path1629" + style="stroke-width:2.30261;stroke-miterlimit:10;stroke-dasharray:none" /></g></g><path + style="fill:none;stroke:#cc0000;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="M 41.180129,2.6688598 22.819872,61.33114" + id="path947" + sodipodi:nodetypes="cc" /></svg> diff --git a/app/bin/bitmaps/SVG/tipofday.svg b/app/bin/bitmaps/svg/tipofday.svg index c83540d..c83540d 100644 --- a/app/bin/bitmaps/SVG/tipofday.svg +++ b/app/bin/bitmaps/svg/tipofday.svg diff --git a/app/bin/bitmaps/SVG/top.svg b/app/bin/bitmaps/svg/top.svg index ccf60ad..ccf60ad 100644 --- a/app/bin/bitmaps/SVG/top.svg +++ b/app/bin/bitmaps/svg/top.svg diff --git a/app/bin/bitmaps/SVG/train.svg b/app/bin/bitmaps/svg/train.svg index e2d2a71..e2d2a71 100644 --- a/app/bin/bitmaps/SVG/train.svg +++ b/app/bin/bitmaps/svg/train.svg diff --git a/app/bin/bitmaps/SVG/trim.svg b/app/bin/bitmaps/svg/trim.svg index 553d08f..553d08f 100644 --- a/app/bin/bitmaps/SVG/trim.svg +++ b/app/bin/bitmaps/svg/trim.svg diff --git a/app/bin/bitmaps/SVG/tunnel.svg b/app/bin/bitmaps/svg/tunnel.svg index c31fabe..c31fabe 100644 --- a/app/bin/bitmaps/SVG/tunnel.svg +++ b/app/bin/bitmaps/svg/tunnel.svg diff --git a/app/bin/bitmaps/SVG/turnout-designer.svg b/app/bin/bitmaps/svg/turnout-design.svg index f11cbf6..0c394e1 100644 --- a/app/bin/bitmaps/SVG/turnout-designer.svg +++ b/app/bin/bitmaps/svg/turnout-design.svg @@ -7,7 +7,7 @@ viewBox="0 0 48 48" style="enable-background:new 0 0 48 48;" xml:space="preserve" - sodipodi:docname="turnout-designer.svg" + sodipodi:docname="turnout-designer1.svg" inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" @@ -60,7 +60,7 @@ <g id="ties" inkscape:label="ties" - transform="matrix(1.1169958,0,0,1.1169958,-1.7103261,3.8486509)"><line + transform="matrix(1.1169958,0,0,1.1169958,-1.7103261,6.554599)"><line class="st0" x1="5" y1="22" @@ -137,7 +137,7 @@ <g id="rail" inkscape:label="rail" - transform="matrix(1.1169958,0,0,1.1169958,-1.7103261,3.8486509)" + transform="matrix(1.1169958,0,0,1.1169958,-1.7103261,6.554599)" style="stroke-width:1.79052;stroke-miterlimit:4;stroke-dasharray:none"><line class="st1" x1="3" @@ -170,10 +170,14 @@ -<polygon - class="st2" - points="24.8,29.5 24.9,39.5 21.5,39.5 21.5,29.5 17,29.5 18.5,25.5 28.5,25.5 28.5,29.5 " - id="polygon985" - transform="matrix(2.1634384,0,0,1.7702694,-25.884336,-36.87808)" - style="stroke:#cccccc;stroke-width:1.12617;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1" /> -</svg> + +<g + id="g6458" + transform="translate(-8.8106866,0.27373616)"><path + style="fill:#f1b76f;fill-opacity:1;stroke:#666666;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="M 21.519231,26.538462 V 21.461538 L 38.798077,4.2403846 43.701923,9.2596154 26.798077,26.451923 Z" + id="path1780" + sodipodi:nodetypes="cccccc" /><path + style="fill:none;stroke:#666666;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 24.346154,18.461538 c 5.134615,5.134616 5.134615,5.134616 5.134615,5.134616" + id="path4988" /></g></svg> diff --git a/app/bin/bitmaps/SVG/turnout.svg b/app/bin/bitmaps/svg/turnout.svg index 35b8260..35b8260 100644 --- a/app/bin/bitmaps/SVG/turnout.svg +++ b/app/bin/bitmaps/svg/turnout.svg diff --git a/app/bin/bitmaps/SVG/turntable.svg b/app/bin/bitmaps/svg/turntable.svg index 8dbb510..8dbb510 100644 --- a/app/bin/bitmaps/SVG/turntable.svg +++ b/app/bin/bitmaps/svg/turntable.svg diff --git a/app/bin/bitmaps/SVG/undo.svg b/app/bin/bitmaps/svg/undo.svg index 290e251..290e251 100644 --- a/app/bin/bitmaps/SVG/undo.svg +++ b/app/bin/bitmaps/svg/undo.svg diff --git a/app/bin/bitmaps/SVG/zoom-choose.svg b/app/bin/bitmaps/svg/zoom-choose.svg index 1f41ba8..a78a425 100644 --- a/app/bin/bitmaps/SVG/zoom-choose.svg +++ b/app/bin/bitmaps/svg/zoom-choose.svg @@ -1,13 +1,5 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> <svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:xlink="http://www.w3.org/1999/xlink" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" version="1.1" id="Layer_1" x="0px" @@ -16,55 +8,19 @@ style="enable-background:new 0 0 48 48;" xml:space="preserve" sodipodi:docname="zoom-choose.svg" - inkscape:version="1.0.2-2 (e86c870879, 2021-01-15)"><metadata + inkscape:version="1.2.1 (9c6d41e410, 2022-07-14)" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/"><metadata id="metadata1134"><rdf:RDF><cc:Work rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs - id="defs1132"> - - <defs - id="defs999"> - <filter - id="Adobe_OpacityMaskFilter" - filterUnits="userSpaceOnUse" - x="24.3" - y="25" - width="17.5" - height="19.2"> - <feFlood - style="flood-color:white;flood-opacity:1" - result="back" - id="feFlood994" /> - <feBlend - in="SourceGraphic" - in2="back" - mode="normal" - id="feBlend996" /> - </filter> - </defs> - <mask - maskUnits="userSpaceOnUse" - x="24.3" - y="25" - width="17.5" - height="19.2" - id="SVGID_1_"> - <g - class="st2" - id="g1003"> - - <image - style="overflow:visible;" - width="22" - height="25" - xlink:href="data:image/jpeg;base64,/9j/4AAQSkZJRgABAgEASABIAAD/7AARRHVja3kAAQAEAAAAHgAA/+4AIUFkb2JlAGTAAAAAAQMA EAMCAwYAAAGKAAABqwAAAe7/2wCEABALCwsMCxAMDBAXDw0PFxsUEBAUGx8XFxcXFx8eFxoaGhoX Hh4jJSclIx4vLzMzLy9AQEBAQEBAQEBAQEBAQEABEQ8PERMRFRISFRQRFBEUGhQWFhQaJhoaHBoa JjAjHh4eHiMwKy4nJycuKzU1MDA1NUBAP0BAQEBAQEBAQEBAQP/CABEIABkAFgMBIgACEQEDEQH/ xAB3AAEAAwEBAAAAAAAAAAAAAAAAAwQFAgYBAQAAAAAAAAAAAAAAAAAAAAAQAAICAwEBAAAAAAAA AAAAAAMEAQIAIBEQFBEBAAEDAwQDAAAAAAAAAAAAAQIAITEQEVEgQTIDEiIEEgEAAAAAAAAAAAAA AAAAAAAg/9oADAMBAAIRAxEAAADw8HegZYE8Asqw/9oACAECAAEFANP/2gAIAQMAAQUA0//aAAgB AQABBQBZSWK2rNbYA1wEbCJsPJ7ijNlySwL6/f/aAAgBAgIGPwAf/9oACAEDAgY/AB//2gAIAQEB Bj8AkxlsmCmMjZLOhOLjJyUfo9F5nkFbd+NPlmL5FHuI/QunNuj/2Q==" - transform="matrix(1 0 0 1 22 22)" - id="image1001"> - </image> - </g> - </mask> - -</defs><sodipodi:namedview + id="defs1132" /><sodipodi:namedview pagecolor="#ffffff" bordercolor="#666666" borderopacity="1" @@ -78,13 +34,16 @@ id="namedview1130" showgrid="false" inkscape:zoom="10.897825" - inkscape:cx="24" - inkscape:cy="24" - inkscape:window-x="0" - inkscape:window-y="0" + inkscape:cx="24.041495" + inkscape:cy="24.087375" + inkscape:window-x="95" + inkscape:window-y="27" inkscape:window-maximized="0" inkscape:current-layer="Layer_1" - inkscape:document-rotation="0" /> + inkscape:document-rotation="0" + inkscape:showpageshadow="2" + inkscape:pagecheckerboard="0" + inkscape:deskcolor="#d1d1d1" /> <style type="text/css" id="style986"> diff --git a/app/bin/bitmaps/SVG/zoom-extent.svg b/app/bin/bitmaps/svg/zoom-extent.svg index 9ee2521..9ee2521 100644 --- a/app/bin/bitmaps/SVG/zoom-extent.svg +++ b/app/bin/bitmaps/svg/zoom-extent.svg diff --git a/app/bin/bitmaps/SVG/zoom-in.svg b/app/bin/bitmaps/svg/zoom-in.svg index 8c9a883..8c9a883 100644 --- a/app/bin/bitmaps/SVG/zoom-in.svg +++ b/app/bin/bitmaps/svg/zoom-in.svg diff --git a/app/bin/bitmaps/SVG/zoom-out.svg b/app/bin/bitmaps/svg/zoom-out.svg index a476985..a476985 100644 --- a/app/bin/bitmaps/SVG/zoom-out.svg +++ b/app/bin/bitmaps/svg/zoom-out.svg diff --git a/app/bin/bitmaps/switch-ai.xpm b/app/bin/bitmaps/switch-ai.xpm deleted file mode 100644 index 34213ba..0000000 --- a/app/bin/bitmaps/switch-ai.xpm +++ /dev/null @@ -1,96 +0,0 @@ -static char *switch_ai_x16[] = {
- "16 16 4 1",
- " c None",
- "0 c #000000",
- "1 c #990000",
- "2 c #CC0000",
- " ",
- " 2 ",
- " 2 ",
- " 2222 ",
- " 2222 ",
- " 2222 ",
- " 2221 ",
- " 2 00 ",
- " 00 ",
- " 0 ",
- " 0 000 ",
- " 00000 ",
- " 00 00 ",
- " 00 000 ",
- " 00 000 ",
- " 00000000"};
-
-static char *switch_ai_x24[] = {
- "24 24 4 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #CC0000",
- " ",
- "222 ",
- " 222 ",
- " 222 ",
- " 222 ",
- " 22222 ",
- " 222222 ",
- " 222222 ",
- " 222222 ",
- " 222222 ",
- " 222210 ",
- " 000 ",
- " 000 ",
- " 000 ",
- " 000 ",
- " 000 000 ",
- " 00000000 ",
- " 000 00 ",
- " 000 00 ",
- " 00000 00 ",
- " 0 00000 ",
- " 0 0000 ",
- " 00000000000 ",
- " 00 00 "};
-
-static char *switch_ai_x32[] = {
- "32 32 5 1",
- " c None",
- "0 c #000000",
- "1 c #990000",
- "2 c #CC0000",
- "3 c #800000",
- " ",
- " 22 ",
- " 222 ",
- " 222 ",
- " 2222 ",
- " 2222 ",
- " 2222 ",
- " 2222222 ",
- " 2222222 ",
- " 22222222 ",
- " 22222222 ",
- " 22222222 ",
- " 22222221 ",
- " 2222230 ",
- " 2221000 ",
- " 0000 ",
- " 0000 ",
- " 0000 ",
- " 0000 ",
- " 0000 ",
- " 0000 0000 ",
- " 000 000000 ",
- " 0000000000 ",
- " 0000 00 ",
- " 0000 00 ",
- " 000000 00 ",
- " 000 0000 00 ",
- " 000 000000 ",
- " 00 00000 ",
- " 000000000000000 ",
- " 00000000000000000",
- " 000000000000000 "};
-
-static char **switch_ai_xpm[3] = { switch_ai_x16, switch_ai_x24, switch_ai_x32 };
-
diff --git a/app/bin/bitmaps/switchm.xpm b/app/bin/bitmaps/switchm.xpm deleted file mode 100644 index 0230351..0000000 --- a/app/bin/bitmaps/switchm.xpm +++ /dev/null @@ -1,30 +0,0 @@ -/* XPM */
-static char * switchm_xpm[] = {
-"16 16 11 1",
-" c None",
-". c #EE2828",
-"+ c #EF2828",
-"@ c #EF2929",
-"# c #ED2828",
-"$ c #EE2929",
-"% c #EC2828",
-"& c #E92C2C",
-"* c #D5403F",
-"= c #2E3436",
-"- c #898A83",
-" ",
-" .+@ ",
-" ..@# ",
-" $@$ ",
-" .@@. ",
-" @@. ",
-" .@%. ",
-" &*. ",
-" = ",
-" === ",
-" == == ",
-" == == ",
-" == = ",
-" == == ",
-" === - === ",
-" == == "};
diff --git a/app/bin/bitmaps/table-edge.xpm b/app/bin/bitmaps/table-edge.xpm deleted file mode 100644 index 1983460..0000000 --- a/app/bin/bitmaps/table-edge.xpm +++ /dev/null @@ -1,114 +0,0 @@ -static char *table_edge_x16[] = {
- "16 16 11 1",
- " c None",
- "0 c #000000",
- "1 c #003300",
- "2 c #006600",
- "3 c #333333",
- "4 c #336633",
- "5 c #339933",
- "6 c #33CC33",
- "7 c #666666",
- "8 c #999999",
- "9 c #808080",
- " ",
- " 5 ",
- " 666666666666630",
- " 666666666666430",
- " 666666666664770",
- " 666666666647970",
- " 666666666479970",
- " 666666664799970",
- "122222222399993 ",
- " 8888888979993 ",
- " 888888897993 ",
- " 88888889793 ",
- " 8888888973 ",
- " 888888870 ",
- " 000000000 ",
- " "};
-
-static char *table_edge_x24[] = {
- "24 24 10 1",
- " c None",
- "0 c #000000",
- "1 c #333333",
- "2 c #336633",
- "3 c #339933",
- "4 c #33CC33",
- "5 c #666633",
- "6 c #666666",
- "7 c #999999",
- "8 c #808080",
- " ",
- " ",
- " 2 ",
- " 4444444444444444444430 ",
- " 4444444444444444444310 ",
- " 4444444444444444443180 ",
- " 4444444444444444431880 ",
- " 4444444444444444318880 ",
- " 4444444444444443188880 ",
- " 4444444444444431888880 ",
- " 4444444444444418888880 ",
- " 4444444444444188888881 ",
- " 333333333333188888881 ",
- " 77777777777718888881 ",
- " 7777777777771888881 ",
- " 777777777777188881 ",
- " 777777777777188810 ",
- " 77777777777718851 ",
- " 7777777777771861 ",
- " 777777777777161 ",
- " 77777777777701 ",
- " 0000000000000 ",
- " ",
- " "};
-
-static char *table_edge_x32[] = {
- "32 32 10 1",
- " c None",
- "0 c #000000",
- "1 c #333333",
- "2 c #336633",
- "3 c #339933",
- "4 c #33CC33",
- "5 c #666633",
- "6 c #666666",
- "7 c #999999",
- "8 c #808080",
- " ",
- " ",
- " ",
- " 4444444444444444444444444443 ",
- " 444444444444444444444444444310 ",
- " 444444444444444444444444444110 ",
- " 444444444444444444444444441860 ",
- " 444444444444444444444444428860 ",
- " 444444444444444444444444268860 ",
- " 444444444444444444444442688860 ",
- " 444444444444444444444426888860 ",
- " 444444444444444444444268888860 ",
- " 444444444444444444443588888860 ",
- " 444444444444444444431888888860 ",
- " 444444444444444444318888888860 ",
- " 44444444444444444318888888881 ",
- " 2333333333333333318888888881 ",
- " 888888888888888668888888810 ",
- " 77777777777777766888888851 ",
- " 7777777777777776688888861 ",
- " 777777777777777668888861 ",
- " 77777777777777766888861 ",
- " 7777777777777776688861 ",
- " 777777777777777688881 ",
- " 77777777777777768881 ",
- " 7777777777777776881 ",
- " 777777777777777661 ",
- " 77777777777777711 ",
- " 000000000000000000 ",
- " ",
- " ",
- " "};
-
-static char **table_edge_xpm[3] = { table_edge_x16, table_edge_x24, table_edge_x32 };
-
diff --git a/app/bin/bitmaps/text.xpm b/app/bin/bitmaps/text.xpm deleted file mode 100644 index 12bc092..0000000 --- a/app/bin/bitmaps/text.xpm +++ /dev/null @@ -1,89 +0,0 @@ -static char *text_x16[] = {
- "16 16 2 1",
- " c None",
- "0 c #000000",
- " ",
- " 0000 ",
- " 000000 ",
- " 000000 ",
- " 0000000 ",
- " 00000000 ",
- " 000 000 ",
- " 0000 0000 ",
- " 0000 0000 ",
- " 0000 00000 ",
- " 000000000000 ",
- " 000000000000 ",
- " 0000 0000 ",
- " 0000 0000 ",
- "0000 0000",
- "0000 0000"};
-
-static char *text_x24[] = {
- "24 24 2 1",
- " c None",
- "0 c #000000",
- " ",
- " 000000 ",
- " 000000 ",
- " 00000000 ",
- " 00000000 ",
- " 0000000000 ",
- " 0000000000 ",
- " 0000000000 ",
- " 00000 00000 ",
- " 00000 00000 ",
- " 000000 000000 ",
- " 00000 00000 ",
- " 00000 000000 ",
- " 00000 00000 ",
- " 0000000000000000 ",
- " 000000000000000000 ",
- " 000000000000000000 ",
- " 0000000000000000000 ",
- " 000000 000000 ",
- " 00000 00000 ",
- " 000000 000000 ",
- " 00000 00000 ",
- "000000 000000",
- " "};
-
-static char *text_x32[] = {
- "32 32 2 1",
- " c None",
- "0 c #000000",
- " ",
- " 00000000 ",
- " 00000000 ",
- " 000000000 ",
- " 0000000000 ",
- " 0000000000 ",
- " 000000000000 ",
- " 000000000000 ",
- " 00000000000000 ",
- " 00000000000000 ",
- " 000000 000000 ",
- " 0000000 0000000 ",
- " 000000 0000000 ",
- " 0000000 0000000 ",
- " 0000000 0000000 ",
- " 000000 0000000 ",
- " 0000000 0000000 ",
- " 0000000 0000000 ",
- " 0000000 0000000 ",
- " 0000000000000000000000 ",
- " 00000000000000000000000 ",
- " 000000000000000000000000 ",
- " 000000000000000000000000 ",
- " 00000000000000000000000000 ",
- " 0000000 0000000 ",
- " 0000000 00000000 ",
- " 0000000 0000000 ",
- " 0000000 0000000 ",
- " 0000000 0000000 ",
- " 0000000 0000000 ",
- "00000000 00000000",
- " "};
-
-static char **text_xpm[3] = { text_x16, text_x24, text_x32 };
-
diff --git a/app/bin/bitmaps/top.xpm b/app/bin/bitmaps/top.xpm deleted file mode 100644 index 84d2152..0000000 --- a/app/bin/bitmaps/top.xpm +++ /dev/null @@ -1,111 +0,0 @@ -static char *top_x16[] = {
- "16 16 9 1",
- " c None",
- "0 c #000000",
- "1 c #660000",
- "2 c #990000",
- "3 c #993333",
- "4 c #996666",
- "5 c #CC0000",
- "6 c #FF0000",
- "7 c #808080",
- " ",
- " ",
- " 000000000 ",
- " 214777777770",
- " 22555377777770",
- " 256666637777770",
- " 566666663777770",
- "2566666662777770",
- "2566666662777770",
- "2566666662777770",
- " 266666654777770",
- " 26666537777770",
- " 2222477777770",
- " 0000000000",
- " ",
- " "};
-
-static char *top_x24[] = {
- "24 24 10 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #990000",
- "3 c #993333",
- "4 c #996666",
- "5 c #CC0000",
- "6 c #FF0000",
- "7 c #808080",
- "8 c #800000",
- " ",
- " ",
- " ",
- " ",
- " 000000000000000 ",
- " 222847777777777770 ",
- " 2556552377777777770 ",
- " 26666666537777777770 ",
- " 266666666663777777770 ",
- " 2666666666665477777770 ",
- " 2666666666666377777770 ",
- " 2666666666666277777770 ",
- "25666666666666277777770 ",
- " 2666666666666377777770 ",
- " 2666666666665377777770 ",
- " 2566666666662777777770 ",
- " 256666666654777777770 ",
- " 25666666247777777770 ",
- " 2225223777777777770 ",
- " 100000000000000 ",
- " ",
- " ",
- " ",
- " "};
-
-static char *top_x32[] = {
- "32 32 9 1",
- " c None",
- "0 c #000000",
- "1 c #660000",
- "2 c #990000",
- "3 c #993333",
- "4 c #996666",
- "5 c #CC0000",
- "6 c #FF0000",
- "7 c #808080",
- " ",
- " ",
- " ",
- " ",
- " ",
- " 00000000000000000000 ",
- " 07777777777777777770 ",
- " 222223477777777777777770 ",
- " 2556666537777777777777770 ",
- " 226666666662477777777777770 ",
- " 2566666666666547777777777770 ",
- " 25666666666666654777777777770 ",
- " 26666666666666663777777777770 ",
- " 256666666666666665477777777770 ",
- " 266666666666666666377777777770 ",
- " 266666666666666666377777777770 ",
- " 266666666666666666377777777770 ",
- " 266666666666666666377777777770 ",
- " 256666666666666665377777777770 ",
- " 256666666666666665477777777770 ",
- " 26666666666666663777777777770 ",
- " 2666666666666637777777777770 ",
- " 2566666666666347777777777770 ",
- " 225666666653777777777777770 ",
- " 2225552247777777777777770 ",
- " 2217777777777777777770 ",
- " 00000000000000000000 ",
- " ",
- " ",
- " ",
- " ",
- " "};
-
-static char **top_xpm[3] = { top_x16, top_x24, top_x32 };
-
diff --git a/app/bin/bitmaps/train.xpm b/app/bin/bitmaps/train.xpm deleted file mode 100644 index bc9a846..0000000 --- a/app/bin/bitmaps/train.xpm +++ /dev/null @@ -1,118 +0,0 @@ -static char *train_x16[] = {
- "16 16 12 1",
- " c None",
- "0 c #000000",
- "1 c #003300",
- "2 c #003333",
- "3 c #006633",
- "4 c #006666",
- "5 c #009966",
- "6 c #669933",
- "7 c #999933",
- "8 c #99CC33",
- "9 c #CCCC33",
- "A c #808080",
- " ",
- " AAAAAAAAA ",
- " AAAAAAAAAAA ",
- " AAAAAAAAAAAA ",
- " AAAAAAAAAAAA ",
- " AAAAA A ",
- " 0 A ",
- " 0000 0 ",
- " 0 0 0 ",
- " 3761111111111 ",
- " 3985555555555 ",
- " 3984444444444 ",
- " 3971221221221 ",
- " 000000000 00 ",
- " 0000000000000 0",
- " 0 0 0 "};
-
-static char *train_x24[] = {
- "24 24 11 1",
- " c None",
- "0 c #000000",
- "1 c #003300",
- "2 c #003333",
- "3 c #006633",
- "4 c #009966",
- "5 c #669933",
- "6 c #999933",
- "7 c #99CC33",
- "8 c #FFFF33",
- "9 c #808080",
- " ",
- " 9999999999 ",
- " 999999999999999 ",
- " 99999999999999999 ",
- " 999999999999999999 ",
- " 999999999999999999 ",
- " 99999999999999999 ",
- " 99999999999 99 ",
- " 99 99 ",
- " 99 ",
- " 0000000 00 ",
- " 0 00 ",
- " 0 00 00 ",
- " 0 00 00 ",
- " 33573322222222222222 ",
- " 33683344444444444444 ",
- " 33683344444444444444 ",
- " 33683333333333333333 ",
- " 33683322222222222222 ",
- " 333521000000000000000 ",
- " 00000000 0000 00 ",
- " 00 00000000 0000 00 00",
- " 00 000 000 000 00 ",
- " "};
-
-static char *train_x32[] = {
- "32 32 12 1",
- " c None",
- "0 c #000000",
- "1 c #003300",
- "2 c #003333",
- "3 c #006633",
- "4 c #009966",
- "5 c #336633",
- "6 c #669933",
- "7 c #999933",
- "8 c #CCCC33",
- "9 c #FFFF33",
- "A c #808080",
- " ",
- " ",
- " AAAAAAAAAAAAAAAA ",
- " AAAAAAAAAAAAAAAAAAAA ",
- " AAAAAAAAAAAAAAAAAAAAAAA ",
- " AAAAAAAAAAAAAAAAAAAAAAAA ",
- " AAAAAAAAAAAAAAAAAAAAAAAA ",
- " AAAAAAAAAAAAAAAAAAAAAAAAA ",
- " AAAAAAAAAAAAAAAAAAAAAAAA ",
- " AAAAAAAAAAAAAAAAA AAA ",
- " AAAAAAAAAAA AA ",
- " AA ",
- " AA ",
- " 0000 ",
- " 00000000 0000 ",
- " 00 0000 ",
- " 00 000 0000 ",
- " 00 000 0000 ",
- " 33333330000000000000000000 ",
- " 33587332222222222222222222 ",
- " 33698333333333333333333333 ",
- " 33698334444444444444444444 ",
- " 33698334444444444444444444 ",
- " 33698333333333333333333333 ",
- " 33698332222222222222222222 ",
- " 33333320011000011000011100 ",
- " 0000 0000 0000 00 ",
- " 0 000000000000000000 0 00 ",
- " 000 000000000000000000 000 00 ",
- " 000 00000 0000 0000 000 ",
- " 000 00 00 0 ",
- " "};
-
-static char **train_xpm[3] = { train_x16, train_x24, train_x32 };
-
diff --git a/app/bin/bitmaps/trim.xpm b/app/bin/bitmaps/trim.xpm deleted file mode 100644 index ac679d6..0000000 --- a/app/bin/bitmaps/trim.xpm +++ /dev/null @@ -1,99 +0,0 @@ -static char *trim_x16[] = {
- "16 16 6 1",
- " c None",
- "0 c #000000",
- "1 c #666666",
- "2 c #CC0000",
- "3 c #808080",
- "4 c #800000",
- " ",
- " 3 ",
- " 22 3 ",
- " 22 3 ",
- " 22 2 3 ",
- " 222 3 ",
- " 22 3 ",
- " 222221 ",
- " 42222 ",
- " 0 2222 ",
- " 0 222 ",
- " 00 2 2 ",
- " 00 2 ",
- " 00 2 ",
- " 00 2 ",
- " "};
-
-static char *trim_x24[] = {
- "24 24 5 1",
- " c None",
- "0 c #000000",
- "1 c #990000",
- "2 c #CC0000",
- "3 c #808080",
- " ",
- " ",
- " 3 ",
- " 2 3 ",
- " 2 3 ",
- " 2 2 3 ",
- " 22 22 3 ",
- " 22 22 3 ",
- " 2222 3 ",
- " 222 3 ",
- " 222222 3 ",
- " 2222222 ",
- " 122 222 ",
- " 0 2222222 ",
- " 0 2222 ",
- " 0 22 2 ",
- " 0 22 2 ",
- " 00 22 2 ",
- " 00 22 2 ",
- " 00 22 ",
- " 00 22 ",
- " 00 2 ",
- " 0 ",
- " "};
-
-static char *trim_x32[] = {
- "32 32 5 1",
- " c None",
- "0 c #000000",
- "1 c #CC0000",
- "2 c #808080",
- "3 c #800000",
- " ",
- " ",
- " 2 ",
- " 222 ",
- " 11 222 ",
- " 111 222 ",
- " 111 222 ",
- " 111 1 222 ",
- " 111 111 222 ",
- " 111 111 222 ",
- " 111 111 222 ",
- " 111111 222 ",
- " 11111 222 ",
- " 11111111 222 ",
- " 1111111111 2 ",
- " 111 1111 ",
- " 3111 ",
- " 003111111111 ",
- " 000 11111111 ",
- " 000 11111 ",
- " 000 111111 ",
- " 000 111 111 ",
- " 000 111 111 ",
- " 000 111 111 ",
- " 000 11 111 ",
- " 0000 111 ",
- " 0000 111 ",
- " 0000 1111 ",
- " 000 11 ",
- " 00 ",
- " ",
- " "};
-
-static char **trim_xpm[3] = { trim_x16, trim_x24, trim_x32 };
-
diff --git a/app/bin/bitmaps/tunnel.xpm b/app/bin/bitmaps/tunnel.xpm deleted file mode 100644 index 9b70b28..0000000 --- a/app/bin/bitmaps/tunnel.xpm +++ /dev/null @@ -1,118 +0,0 @@ -static char *tunnel_x16[] = {
- "16 16 11 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333333",
- "3 c #663300",
- "4 c #666666",
- "5 c #993300",
- "6 c #996600",
- "7 c #999999",
- "8 c #CC6600",
- "9 c #808080",
- " ",
- " ",
- " ",
- " ",
- " 00 ",
- " 8 8 007 7 7 7 ",
- "0303102999949499",
- " 6 63027797 7 79",
- " 8 8 0077 7 7 7 ",
- "0000002444444444",
- " 8 8 0077 7 7 7 ",
- " 00 ",
- " 0 ",
- " ",
- " ",
- " "};
-
-static char *tunnel_x24[] = {
- "24 24 11 1",
- " c None",
- "0 c #000000",
- "1 c #333300",
- "2 c #333333",
- "3 c #663300",
- "4 c #666666",
- "5 c #993300",
- "6 c #996600",
- "7 c #999999",
- "8 c #CC6600",
- "9 c #808080",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " 00 ",
- " 00 ",
- " 8 8 00 7 7 7 77 ",
- " 35006000449949944994994",
- " 35006000449949944994994",
- " 88 8 0 77 7 7 77 ",
- " 88 8 0 77 7 7 77 ",
- " 66 6 02 79 97 79 77 ",
- "013003000449949944994994",
- " 88 8 0 77 7 7 77 ",
- " 00 ",
- " 00 ",
- " 0 ",
- " ",
- " ",
- " ",
- " ",
- " "};
-
-static char *tunnel_x32[] = {
- "32 32 13 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #333333",
- "4 c #663300",
- "5 c #663333",
- "6 c #666666",
- "7 c #993300",
- "8 c #996600",
- "9 c #999999",
- "A c #CC6600",
- "B c #808080",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " 00 ",
- " 000 ",
- " 00 ",
- " AA AA 00 99 99 99 99 ",
- " 488 884 003 99 99B 99 99B ",
- " 14400441000566BB66BBB66BB66BBB6",
- " AA AA 00 99 99 99 99 ",
- " AA AA 00 99 99 99 99 ",
- " AA AA 00 99 99 99 99 ",
- " AA AA 00 99 99 99 99 ",
- " 28700782000366BB66BBB66BB66BBB ",
- " 28700782000366BB66BBB66BB66BBB ",
- " AA AA 00 99 99 99 99 ",
- " 000 ",
- " 000 ",
- " 0000 ",
- " 0 ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " "};
-
-static char **tunnel_xpm[3] = { tunnel_x16, tunnel_x24, tunnel_x32 };
-
diff --git a/app/bin/bitmaps/turnout-designer.xpm b/app/bin/bitmaps/turnout-designer.xpm deleted file mode 100644 index 00db9be..0000000 --- a/app/bin/bitmaps/turnout-designer.xpm +++ /dev/null @@ -1,129 +0,0 @@ -static char *turnout_designer_x16[] = {
- "16 16 15 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #333333",
- "4 c #663300",
- "5 c #666666",
- "6 c #996600",
- "7 c #999999",
- "8 c #CC6600",
- "9 c #CC9900",
- "A c #CC9966",
- "B c #CCCCCC",
- "C c #C0C0C0",
- "D c #808080",
- " ",
- " ",
- " BBBBBBB ",
- " B777777CB ",
- " BC5500557B ",
- " BBBBD3BBBB ",
- " BD3B99640 ",
- " BD3B64169 ",
- " CD3B669 60",
- " 9 9667D3B9 6168",
- "10000077DB000000",
- " 9 999ACC76 9 9 ",
- "4424101244414240",
- " 86646866684868 ",
- " ",
- " "};
-
-static char *turnout_designer_x24[] = {
- "24 24 17 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #333333",
- "4 c #663300",
- "5 c #666666",
- "6 c #996600",
- "7 c #999966",
- "8 c #999999",
- "9 c #CC6600",
- "A c #CC9900",
- "B c #CC9999",
- "C c #CCCC99",
- "D c #CCCCCC",
- "E c #C0C0C0",
- "F c #808080",
- " ",
- " ",
- " ",
- " ",
- " DDEEEEEEEEEDD ",
- " D50000000008D ",
- " DE00000000008D ",
- " DDEEE8005EEEDD ",
- " DD008D ",
- " D008D A40 ",
- " D008DAAA016 ",
- " D008D9424 AA ",
- " D008846AA A0 ",
- " A D008EAA AA024 ",
- " AA A 925D008DAA 4409A ",
- "0000000003D0088000000000",
- " AA A A DEED826 AA A ",
- " AA A A 7FF7 AA AA A ",
- " 66 96040040 9 66 66 96 ",
- "044041041140040440440420",
- " AA A A A A AA AA A ",
- " ",
- " ",
- " "};
-
-static char *turnout_designer_x32[] = {
- "32 32 14 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #333333",
- "4 c #663300",
- "5 c #666666",
- "6 c #993300",
- "7 c #996600",
- "8 c #999999",
- "9 c #CC6600",
- "A c #CC9900",
- "B c #CCCCCC",
- "C c #C0C0C0",
- " ",
- " ",
- " ",
- " ",
- " ",
- " BBBBBBBBBBBBBBBBB ",
- " BB5555555555555BB ",
- " B80000000000000BB ",
- " BB30000000000000BB ",
- " BC55555500355555BB ",
- " BBBBBBBB8003BBBBBBB ",
- " B8003BB ",
- " B8003BB A00 ",
- " B8003BB AA 044 ",
- " B8003BB A97007A ",
- " B8003BB76077 AA ",
- " B8003B827 AA A ",
- " B8003BC A A 920 ",
- " AA B8003BB A AA 019 ",
- " A A 9700B8003BB A 0410AA ",
- " 041014000200B8003B824000440440 ",
- " 94 490079 BC888B8210079 77 ",
- " A A AA BBBBCC87A A AA ",
- " A A AA 74007A A A AA ",
- " A A 770047 AA A A AA ",
- " 000000000000000000000000000000 ",
- " A A AA AA AA A A AA ",
- " A A A A A A A A ",
- " ",
- " ",
- " ",
- " "};
-
-static char **turnout_designer_xpm[3] = { turnout_designer_x16, turnout_designer_x24, turnout_designer_x32 };
-
diff --git a/app/bin/bitmaps/turnout.xpm b/app/bin/bitmaps/turnout.xpm deleted file mode 100644 index dc60fdb..0000000 --- a/app/bin/bitmaps/turnout.xpm +++ /dev/null @@ -1,107 +0,0 @@ -static char *turnout_x16[] = {
- "16 16 8 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #663300",
- "4 c #996600",
- "5 c #CC6600",
- "6 c #CC9900",
- " ",
- " ",
- " ",
- " ",
- " 64 ",
- " 6414 ",
- " 53236650",
- " 541346 5234",
- "2323002232301231",
- " 54545543133535 ",
- " 54533124453535 ",
- "2323123232313130",
- " ",
- " ",
- " ",
- " "};
-
-static char *turnout_x24[] = {
- "24 24 8 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #663300",
- "4 c #996600",
- "5 c #CC6600",
- "6 c #CC9900",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " 6 ",
- " 6 32 ",
- " 643036 ",
- " 6602346 66 ",
- " 6 32056 6 40 ",
- " 6 33046 66 64035 ",
- " 3404302014034043003243 ",
- " 3404304224034030043043 ",
- " 66 66 6 6 32046 66 6 ",
- " 66 66 6322035 66 66 6 ",
- "02303200003023032032032 ",
- " 45 5405335 45 54 54 54 ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " "};
-
-static char *turnout_x32[] = {
- "32 32 8 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #663300",
- "4 c #996600",
- "5 c #CC6600",
- "6 c #CC9900",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " 6 ",
- " 50 ",
- " 6660035 ",
- " 66121 6 ",
- " 6 32056 66 ",
- " 6 50046 6 6 0 ",
- " 64004 66 66 32 ",
- " 6 6 66 0310 6 66 62046 ",
- " 54 500320044 5 45 0113054 ",
- " 032003001300320030022002320320 ",
- " 6 6 66 6 63014 66 66 ",
- " 6 6 66 6 021066 66 66 ",
- " 6 6 66 41006 66 66 66 ",
- " 54 500330044 53 45 45 54 ",
- " 032003001300320031023002300320 ",
- " 6 6 66 6 6 66 66 66 ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " "};
-
-static char **turnout_xpm[3] = { turnout_x16, turnout_x24, turnout_x32 };
-
diff --git a/app/bin/bitmaps/turntable.xpm b/app/bin/bitmaps/turntable.xpm deleted file mode 100644 index c6e6375..0000000 --- a/app/bin/bitmaps/turntable.xpm +++ /dev/null @@ -1,133 +0,0 @@ -static char *turntable_x16[] = {
- "16 16 17 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #333333",
- "4 c #663300",
- "5 c #663333",
- "6 c #666633",
- "7 c #666666",
- "8 c #996600",
- "9 c #999999",
- "A c #CC6600",
- "B c #CC9900",
- "C c #CCCCCC",
- "D c #FFFFFF",
- "E c #C0C0C0",
- "F c #808080",
- " 1B ",
- " 0 82B 000 ",
- " 84 85033303 ",
- " B446FF397793 ",
- " B39DF3977DC3 ",
- " 7DDF3977DDF3",
- "88A5EDDF3977DDC3",
- "4443CDDF3977DDD0",
- "BBB3CDDF3977DDD3",
- "1000EDDF3977DDC3",
- "BBB49DDF3977DDE3",
- " B3CDF3977DD3 ",
- " B483CF3977CF3 ",
- " 84 837373330 ",
- " 0B82B03330 ",
- " 04B "};
-
-static char *turntable_x24[] = {
- "24 24 17 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #333333",
- "4 c #663300",
- "5 c #666600",
- "6 c #666633",
- "7 c #666666",
- "8 c #996600",
- "9 c #999999",
- "A c #CC6600",
- "B c #CC9900",
- "C c #CCCCCC",
- "D c #FFFFFF",
- "E c #C0C0C0",
- "F c #808080",
- " 0 B ",
- " 48 ",
- " 0 B20B 000 ",
- " 2A 48300000030 ",
- " B1 B8397799939F3 ",
- " 467CD779993EDE3 ",
- " B83CDD779993EDDC3 ",
- " 3CDDD779993EDDD93 ",
- " 0FDDDD779993EDDDD3 ",
- " B B3EDDDD779993EDDDD90",
- "040243CDDDD779993EDDDDC3",
- " A 8A0DDDDD779993EDDDDC3",
- " B BB3DDDDD779993EDDDDC3",
- " A 8A3CDDDD779993EDDDDE3",
- "040243CDDDD779993EDDDD90",
- " B B39DDDD779993EDDDD7 ",
- " 3CDDD779993EDDDC3 ",
- " B2FDDD779993EDDD3 ",
- " 443EDD779993EDDF3 ",
- " B40 B37C779993EC73 ",
- " 24 B41333777073 ",
- " 0 B 08B 0300330 ",
- " 48 ",
- " 04B "};
-
-static char *turntable_x32[] = {
- "32 32 16 1",
- " c None",
- "0 c #000000",
- "1 c #330000",
- "2 c #333300",
- "3 c #333333",
- "4 c #663300",
- "5 c #663333",
- "6 c #666666",
- "7 c #996600",
- "8 c #999999",
- "9 c #CC6600",
- "A c #CC9900",
- "B c #CCCCCC",
- "C c #FFFFFF",
- "D c #C0C0C0",
- "E c #808080",
- " 0 ",
- " 04A ",
- " 72 ",
- " 0 AA 00AA 0000 ",
- " 04A 47 3000000033 ",
- " A71 A903D668888E3D33 ",
- " A 02AA38BC668888E3CC83 ",
- " 443BCCC668888E3CCCB6 ",
- " A 08CCCC668888E3CCCCB3 ",
- " 3ECCCCC668888E3CCCCCD3 ",
- " 3BCCCCC668888E3CCCCCC6 ",
- " 08CCCCCC668888E3CCCCCCD3 ",
- " AA A 3BCCCCCC668888E3CCCCCCB3 ",
- " 77 903CCCCCCC668888E3CCCCCCC6 ",
- "04400403CCCCCCC668888E3CCCCCCC80",
- " AA A0ECCCCCCC668888E3CCCCCCC83",
- " AA A0ECCCCCCC668888E3CCCCCCCD3",
- " AA A 6CCCCCCC668888E3CCCCCCC80",
- "04400403CCCCCCC668888E3CCCCCCC80",
- " 77 9 3BCCCCCC668888E3CCCCCCC6 ",
- " AA A 3DCCCCCC668888E3CCCCCCB3 ",
- " 6CCCCCC668888E3CCCCCC83 ",
- " 3BCCCCC668888E3CCCCCB3 ",
- " A13BCCCC668888E3CCCCC6 ",
- " 743ECCCC668888E3CCCC83 ",
- " A 09A5EBCC668888E3CCC86 ",
- " 91 AA33DC668888E3CB63 ",
- " 2A 74 363366666363 ",
- " 0 A 09A 03000033 ",
- " 90 ",
- " 29 ",
- " 0 AA "};
-
-static char **turntable_xpm[3] = { turntable_x16, turntable_x24, turntable_x32 };
-
diff --git a/app/bin/bitmaps/undo.xpm b/app/bin/bitmaps/undo.xpm deleted file mode 100644 index 2450967..0000000 --- a/app/bin/bitmaps/undo.xpm +++ /dev/null @@ -1,103 +0,0 @@ -static char *undo_x16[] = {
- "16 16 6 1",
- " c None",
- "0 c #000000",
- "1 c #996600",
- "2 c #CC6600",
- "3 c #CC9900",
- "4 c #FFCC00",
- " ",
- " 1 ",
- " 11 ",
- " 13411 ",
- " 134443311 ",
- " 1344444432 ",
- " 1342114431 ",
- " 11 1443 ",
- " 1 1441 ",
- " 141 ",
- " 1331 ",
- " 131 ",
- " 131 ",
- " 131 ",
- " 11 ",
- " "};
-
-static char *undo_x24[] = {
- "24 24 7 1",
- " c None",
- "0 c #000000",
- "1 c #996600",
- "2 c #CC6600",
- "3 c #CC9900",
- "4 c #FF9900",
- "5 c #FFCC00",
- " ",
- " ",
- " 1 ",
- " 11 ",
- " 12531 ",
- " 1355311 ",
- " 135555533311 ",
- " 15555555555411 ",
- " 13555555555531 ",
- " 13553113555531 ",
- " 2531 135552 ",
- " 111 135551 ",
- " 1 3553 ",
- " 13551 ",
- " 1551 ",
- " 1353 ",
- " 1531 ",
- " 1551 ",
- " 1351 ",
- " 151 ",
- " 151 ",
- " 131 ",
- " 11 ",
- " "};
-
-static char *undo_x32[] = {
- "32 32 7 1",
- " c None",
- "0 c #000000",
- "1 c #996600",
- "2 c #CC6600",
- "3 c #CC9900",
- "4 c #FF9900",
- "5 c #FFCC00",
- " ",
- " ",
- " ",
- " 1 ",
- " 121 ",
- " 12531 ",
- " 135531 ",
- " 13555551111 ",
- " 135555555433211 ",
- " 15555555555555531 ",
- " 1355555555555555531 ",
- " 255555555555555531 ",
- " 135555112355555531 ",
- " 125551 113555552 ",
- " 1351 12555551 ",
- " 121 2555531 ",
- " 11 255551 ",
- " 35552 ",
- " 135531 ",
- " 15551 ",
- " 13551 ",
- " 15531 ",
- " 14531 ",
- " 3551 ",
- " 1551 ",
- " 1551 ",
- " 1351 ",
- " 1351 ",
- " 151 ",
- " 111 ",
- " ",
- " "};
-
-static char **undo_xpm[3] = { undo_x16, undo_x24, undo_x32 };
-
diff --git a/app/bin/bitmaps/zoom-choose.xpm b/app/bin/bitmaps/zoom-choose.xpm deleted file mode 100644 index 4066455..0000000 --- a/app/bin/bitmaps/zoom-choose.xpm +++ /dev/null @@ -1,127 +0,0 @@ -static char *zoom_choose_x16[] = {
- "16 16 13 1",
- " c None",
- "0 c #000000",
- "1 c #333333",
- "2 c #333366",
- "3 c #336666",
- "4 c #666666",
- "5 c #669999",
- "6 c #6699CC",
- "7 c #9999CC",
- "8 c #99CCCC",
- "9 c #99CCFF",
- "A c #99FFFF",
- "B c #CCFFFF",
- " ",
- " 13421 ",
- " 249BBB93 ",
- " 3BBBBBB92 ",
- " 18500000650 ",
- " 19934443981 ",
- " 19B73438B81 ",
- " 18BB415BB50 ",
- " 3BBA5BBA3 ",
- " 15ABBB931 ",
- " 014431141 ",
- " 0140 ",
- " 0140 ",
- " 0110 ",
- " 010 ",
- " "};
-
-static char *zoom_choose_x24[] = {
- "24 24 15 1",
- " c None",
- "0 c #000000",
- "1 c #003333",
- "2 c #333333",
- "3 c #333366",
- "4 c #336666",
- "5 c #666666",
- "6 c #666699",
- "7 c #669999",
- "8 c #6699CC",
- "9 c #9999CC",
- "A c #99CCCC",
- "B c #99CCFF",
- "C c #99FFFF",
- "D c #CCFFFF",
- " ",
- " 02220 ",
- " 227ABA832 ",
- " 37DDDDDDC93 ",
- " 29DDDDDDDDDA3 ",
- " 4DDDDDDDDDDD72 ",
- " 2AD755555556CB2 ",
- " 2CD725555525DD2 ",
- " 0DDD4555554BDD4 ",
- " 2DDDB45554ADDD4 ",
- " 2BDDDA4557DDDD1 ",
- " 2ADDDD754CDDDB2 ",
- " 4DDDDC4BDDDD72 ",
- " 27DDDDDDDDDA2 ",
- " 37CDDDDDD7350 ",
- " 0279AA6222520 ",
- " 00220 05520 ",
- " 05520 ",
- " 2552 ",
- " 2552 ",
- " 02550 ",
- " 0220 ",
- " 0 ",
- " "};
-
-static char *zoom_choose_x32[] = {
- "32 32 16 1",
- " c None",
- "0 c #000000",
- "1 c #000033",
- "2 c #003333",
- "3 c #333333",
- "4 c #333366",
- "5 c #336666",
- "6 c #666666",
- "7 c #666699",
- "8 c #669999",
- "9 c #6699CC",
- "A c #9999CC",
- "B c #99CCCC",
- "C c #99CCFF",
- "D c #99FFFF",
- "E c #CCFFFF",
- " ",
- " ",
- " 31560130 ",
- " 36BEEEEEC83 ",
- " 3AEEEEEEEEEC64 ",
- " 4CEEEEEEEEEEEE83 ",
- " 4BEEEEEEEEEEEEED5 ",
- " 5EEEEEEEEEEEEEEEC3 ",
- " 3CEDAAAAAAAAAAABEE5 ",
- " 2EED333333333339EEB3 ",
- " 4EEEC4666666666EEEB3 ",
- " 6EEEE956666665CEEEC3 ",
- " 08EEEEE6666665BEEEEC3 ",
- " 5EEEEEC566668EEEEEB3 ",
- " 3EEEEEEB5665EEEEEE80 ",
- " 3BEEEEEE865CEEEEEE5 ",
- " 5EEEEEEE5AEEEEEEB3 ",
- " 38EEEEEEDEEEEEED3 ",
- " 4BEEEEEEEEEEED530 ",
- " 38DEEEEEEEEB36630 ",
- " 33BCCEECB7336663 ",
- " 33300330 036660 ",
- " 036660 ",
- " 036663 ",
- " 066630 ",
- " 066630 ",
- " 366630 ",
- " 36660 ",
- " 03630 ",
- " 000 ",
- " ",
- " "};
-
-static char **zoom_choose_xpm[3] = { zoom_choose_x16, zoom_choose_x24, zoom_choose_x32 };
-
diff --git a/app/bin/bitmaps/zoom-extent.xpm b/app/bin/bitmaps/zoom-extent.xpm deleted file mode 100644 index 17688da..0000000 --- a/app/bin/bitmaps/zoom-extent.xpm +++ /dev/null @@ -1,125 +0,0 @@ -static char *zoom_extent_x16[] = {
- "16 16 15 1",
- " c None",
- "0 c #000000",
- "1 c #003333",
- "2 c #333333",
- "3 c #333366",
- "4 c #336666",
- "5 c #666666",
- "6 c #669999",
- "7 c #990000",
- "8 c #9999CC",
- "9 c #99CCCC",
- "A c #99CCFF",
- "B c #CC0000",
- "C c #CCFFFF",
- "D c #800000",
- " B BBB ",
- "BBBBB BBBBB",
- "BBB BBB",
- "BB B B BB",
- " B B B BB",
- " D2523 ",
- " 2ACC60 ",
- " 06CCC92 ",
- " 4CCC81 ",
- " 36A93 ",
- " 2220 ",
- " B 00 B ",
- "BB BB 000 B BB",
- "BBBB 00 BBB",
- "BBB BBB",
- "BBBBB BBBBB"};
-
-static char *zoom_extent_x24[] = {
- "24 24 12 1",
- " c None",
- "0 c #000000",
- "1 c #333333",
- "2 c #336666",
- "3 c #666666",
- "4 c #666699",
- "5 c #669999",
- "6 c #99CCCC",
- "7 c #99CCFF",
- "8 c #99FFFF",
- "9 c #CC0000",
- "A c #CCFFFF",
- " ",
- " 999999 999999 ",
- " 999 99 ",
- " 999 9 9 ",
- " 9 9 9 9 ",
- " 9 9 9 9 ",
- " 9 9 9 9 ",
- " 9 111 9 ",
- " 1267621 ",
- " 28AAA82 ",
- " 16AAAAA61 ",
- " 17AAAAA71 ",
- " 16AAAAA61 ",
- " 3AAAAA50 ",
- " 147A752 ",
- " 01010 ",
- " 010 ",
- " 9 99 010 9 9 ",
- " 9 99 01 9 9 ",
- " 9 99 010 9 9 ",
- " 9 99 000 9 9 ",
- " 999 99 ",
- " 999999 999999 ",
- " "};
-
-static char *zoom_extent_x32[] = {
- "32 32 15 1",
- " c None",
- "0 c #000000",
- "1 c #000033",
- "2 c #333333",
- "3 c #333366",
- "4 c #336666",
- "5 c #666666",
- "6 c #666699",
- "7 c #669999",
- "8 c #6699CC",
- "9 c #99CCCC",
- "A c #99CCFF",
- "B c #99FFFF",
- "C c #CC0000",
- "D c #CCFFFF",
- " ",
- " CCCCCCCC CCCCCCCC ",
- " CCCCCCCC CCCCCCCC ",
- " CCCCC CCCC ",
- " CCCCC CCCCC ",
- " CCCCCC CCC CC ",
- " CC CCC CCC CC ",
- " CC CCC CCC CC ",
- " CC CCC CCC CC ",
- " CC CC ",
- " 20012 ",
- " 369DDD94 ",
- " 06DDDDDDA4 ",
- " 2ADDDDDDD82 ",
- " 4DDDDDDDDA2 ",
- " 5DDDDDDDDA2 ",
- " 3DDDDDDDDA2 ",
- " 2ADDDDDDD72 ",
- " 4BDDDDDA3 ",
- " 49DDA84 ",
- " 210210 ",
- " 050 ",
- " CC 0220 CC ",
- " CC CCC 050 CCC CC ",
- " CC CCC 050 CCC CC ",
- " CC CCC 0220 CCC CC ",
- " CC CCC 020 CCC CC ",
- " CCCCC 00 CCCCC ",
- " CCCC CCCC ",
- " CCCCCCCC CCCCCCCC ",
- " CCCCCCCC CCCCCCCC ",
- " "};
-
-static char **zoom_extent_xpm[3] = { zoom_extent_x16, zoom_extent_x24, zoom_extent_x32 };
-
diff --git a/app/bin/bitmaps/zoom-in.xpm b/app/bin/bitmaps/zoom-in.xpm deleted file mode 100644 index 8f66a29..0000000 --- a/app/bin/bitmaps/zoom-in.xpm +++ /dev/null @@ -1,128 +0,0 @@ -static char *zoom_in_x16[] = {
- "16 16 15 1",
- " c None",
- "0 c #000000",
- "1 c #003333",
- "2 c #333333",
- "3 c #333366",
- "4 c #336666",
- "5 c #666666",
- "6 c #666699",
- "7 c #669999",
- "8 c #6699CC",
- "9 c #9999CC",
- "A c #99CCCC",
- "B c #99CCFF",
- "C c #99FFFF",
- "D c #CCFFFF",
- " 00 ",
- " 227752 ",
- " 37DB9CB5 ",
- " 5DDA0BDC3 ",
- " 2ADDA0BDD70 ",
- " 2B6000007A2 ",
- " 2BA97089AA1 ",
- " 2ADDA0BDD70 ",
- " 4CDA0BDB2 ",
- " 4ADDCA22 ",
- " 20022252 ",
- " 0250 ",
- " 0250 ",
- " 0520 ",
- " 022 ",
- " 0 "};
-
-static char *zoom_in_x24[] = {
- "24 24 14 1",
- " c None",
- "0 c #000000",
- "1 c #003333",
- "2 c #333333",
- "3 c #333366",
- "4 c #336666",
- "5 c #666666",
- "6 c #666699",
- "7 c #669999",
- "8 c #9999CC",
- "9 c #99CCCC",
- "A c #99CCFF",
- "B c #99FFFF",
- "C c #CCFFFF",
- " ",
- " 0220220 ",
- " 379BCA962 ",
- " 39CCAAACC93 ",
- " 2ACCC706CCC93 ",
- " 27CCCC706CCCC70 ",
- " 2ACCCC706CCCC92 ",
- " 0CA888504888AB1 ",
- " 3CA0000000009C3 ",
- " 2CA6664026669C1 ",
- " 2ACCCC706CCCCA2 ",
- " 29CCCC706CCCC93 ",
- " 3ACCC706CCCB4 ",
- " 5CCCAAACCB52 ",
- " 329CCCCB93250 ",
- " 225541205520 ",
- " 05520 ",
- " 2552 ",
- " 2552 ",
- " 02550 ",
- " 02550 ",
- " 0520 ",
- " 00 ",
- " "};
-
-static char *zoom_in_x32[] = {
- "32 32 16 1",
- " c None",
- "0 c #000000",
- "1 c #000033",
- "2 c #003333",
- "3 c #333333",
- "4 c #333366",
- "5 c #336666",
- "6 c #666666",
- "7 c #666699",
- "8 c #669999",
- "9 c #6699CC",
- "A c #9999CC",
- "B c #99CCCC",
- "C c #99CCFF",
- "D c #99FFFF",
- "E c #CCFFFF",
- " ",
- " 0000 ",
- " 338AA9653 ",
- " 4BEEEEEEEB53 ",
- " 35CEEEEEEEEEEB4 ",
- " 07EEEEE700CEEEE83 ",
- " 3CEEEEE700CEEEEE7 ",
- " 38EEEEEE700CEEEEEC3 ",
- " 1EEEEEEE700CEEEEEE5 ",
- " 4EEEEEEE700CEEEEEE90 ",
- " 6EE8000000000000CEB3 ",
- " 08EE8000000000000CEB3 ",
- " 08EE8000000000000CEB3 ",
- " 5EEEEEEE700CEEEEEEA2 ",
- " 3DEEEEEE700CEEEEEE6 ",
- " 3BEEEEEE700CEEEEEC4 ",
- " 4CEEEEE700CEEEEE5 ",
- " 6EEEEE977CEEEEB3 ",
- " 38DEEEEEEEEEE8330 ",
- " 33BEEEEEEEC63663 ",
- " 3469AA853036663 ",
- " 0000 036660 ",
- " 036660 ",
- " 066630 ",
- " 066630 ",
- " 36663 ",
- " 36660 ",
- " 036660 ",
- " 03660 ",
- " 030 ",
- " 0 ",
- " "};
-
-static char **zoom_in_xpm[3] = { zoom_in_x16, zoom_in_x24, zoom_in_x32 };
-
diff --git a/app/bin/bitmaps/zoom-out.xpm b/app/bin/bitmaps/zoom-out.xpm deleted file mode 100644 index c37242d..0000000 --- a/app/bin/bitmaps/zoom-out.xpm +++ /dev/null @@ -1,127 +0,0 @@ -static char *zoom_out_x16[] = {
- "16 16 14 1",
- " c None",
- "0 c #000000",
- "1 c #003333",
- "2 c #333333",
- "3 c #333366",
- "4 c #336666",
- "5 c #666666",
- "6 c #666699",
- "7 c #669999",
- "8 c #9999CC",
- "9 c #99CCCC",
- "A c #99CCFF",
- "B c #99FFFF",
- "C c #CCFFFF",
- " 00 ",
- " 227752 ",
- " 37CCCCA5 ",
- " 5CCCCCCB3 ",
- " 29CCCCCCC70 ",
- " 2A600000792 ",
- " 2A988888991 ",
- " 29CCCCCCC70 ",
- " 4BCCCCCA2 ",
- " 49CCB922 ",
- " 20022252 ",
- " 0250 ",
- " 0250 ",
- " 0520 ",
- " 022 ",
- " 0 "};
-
-static char *zoom_out_x24[] = {
- "24 24 14 1",
- " c None",
- "0 c #000000",
- "1 c #003333",
- "2 c #333333",
- "3 c #333366",
- "4 c #336666",
- "5 c #666666",
- "6 c #666699",
- "7 c #669999",
- "8 c #9999CC",
- "9 c #99CCCC",
- "A c #99CCFF",
- "B c #99FFFF",
- "C c #CCFFFF",
- " ",
- " 0220220 ",
- " 379BCA962 ",
- " 39CCCCCCC93 ",
- " 2ACCCCCCCCC93 ",
- " 27CCCCCCCCCCC70 ",
- " 2ACCCCCCCCCCC92 ",
- " 0CA888888888AB1 ",
- " 3CA0000000009C3 ",
- " 2CA6666666669C1 ",
- " 2ACCCCCCCCCCCA2 ",
- " 29CCCCCCCCCCC93 ",
- " 3ACCCCCCCCCB4 ",
- " 5CCCCCCCCB52 ",
- " 329CCCCB93250 ",
- " 225541205520 ",
- " 05520 ",
- " 2552 ",
- " 2552 ",
- " 02550 ",
- " 02550 ",
- " 0520 ",
- " 00 ",
- " "};
-
-static char *zoom_out_x32[] = {
- "32 32 16 1",
- " c None",
- "0 c #000000",
- "1 c #000033",
- "2 c #003333",
- "3 c #333333",
- "4 c #333366",
- "5 c #336666",
- "6 c #666666",
- "7 c #666699",
- "8 c #669999",
- "9 c #6699CC",
- "A c #9999CC",
- "B c #99CCCC",
- "C c #99CCFF",
- "D c #99FFFF",
- "E c #CCFFFF",
- " ",
- " 0000 ",
- " 338AA9653 ",
- " 4BEEEEEEEB53 ",
- " 35CEEEEEEEEEEB4 ",
- " 07EEEEEEEEEEEEE83 ",
- " 3CEEEEEEEEEEEEEE7 ",
- " 38EEEEEEEEEEEEEEEC3 ",
- " 1EEEEEEEEEEEEEEEEE5 ",
- " 4EEEEEEEEEEEEEEEEE90 ",
- " 6EE8000000000000CEB3 ",
- " 08EE8000000000000CEB3 ",
- " 08EE8000000000000CEB3 ",
- " 5EEEEEEEEEEEEEEEEEA2 ",
- " 3DEEEEEEEEEEEEEEEE6 ",
- " 3BEEEEEEEEEEEEEEEC4 ",
- " 4CEEEEEEEEEEEEEE5 ",
- " 6EEEEEEEEEEEEEB3 ",
- " 38DEEEEEEEEEE8330 ",
- " 33BEEEEEEEC63663 ",
- " 3469AA853036663 ",
- " 0000 036660 ",
- " 036660 ",
- " 066630 ",
- " 066630 ",
- " 36663 ",
- " 36660 ",
- " 036660 ",
- " 03660 ",
- " 030 ",
- " 0 ",
- " "};
-
-static char **zoom_out_xpm[3] = { zoom_out_x16, zoom_out_x24, zoom_out_x32 };
-
diff --git a/app/bin/cJSON.c b/app/bin/cJSON.c deleted file mode 100755 index ee641fc..0000000 --- a/app/bin/cJSON.c +++ /dev/null @@ -1,2932 +0,0 @@ -/** - Copyright (c) 2009-2017 Dave Gamble and cJSON contributors - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. -*/ - -/* cJSON */ -/* JSON parser in C. */ - -/* disable warnings about old C89 functions in MSVC */ -#if !defined(_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) -#define _CRT_SECURE_NO_DEPRECATE -#endif - -#ifdef __GNUC__ -#pragma GCC visibility push(default) -#endif -#if defined(_MSC_VER) -#pragma warning (push) -/* disable warning about single line comments in system headers */ -#pragma warning (disable : 4001) -#endif - -#include <string.h> -#include <stdio.h> -#include <math.h> -#include <stdlib.h> -#include <limits.h> -#include <ctype.h> - -#ifdef ENABLE_LOCALES -#include <locale.h> -#endif - -#if defined(_MSC_VER) -#pragma warning (pop) -#endif -#ifdef __GNUC__ -#pragma GCC visibility pop -#endif - -#include "cJSON.h" - -/* define our own boolean type */ -#define true ((cJSON_bool)1) -#define false ((cJSON_bool)0) - -typedef struct { - const unsigned char *json; - size_t position; -} error; -static error global_error = { NULL, 0 }; - -CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void) -{ - return (const char*) (global_error.json + global_error.position); -} - -CJSON_PUBLIC(char *) cJSON_GetStringValue(cJSON *item) { - if (!cJSON_IsString(item)) { - return NULL; - } - - return item->valuestring; -} - -/* This is a safeguard to prevent copy-pasters from using incompatible C and header files */ -#if (CJSON_VERSION_MAJOR != 1) || (CJSON_VERSION_MINOR != 7) || (CJSON_VERSION_PATCH != 8) - #error cJSON.h and cJSON.c have different versions. Make sure that both have the same. -#endif - -CJSON_PUBLIC(const char*) cJSON_Version(void) -{ - static char version[15]; - sprintf(version, "%i.%i.%i", CJSON_VERSION_MAJOR, CJSON_VERSION_MINOR, CJSON_VERSION_PATCH); - - return version; -} - -/* Case insensitive string comparison, doesn't consider two NULL pointers equal though */ -static int case_insensitive_strcmp(const unsigned char *string1, const unsigned char *string2) -{ - if ((string1 == NULL) || (string2 == NULL)) - { - return 1; - } - - if (string1 == string2) - { - return 0; - } - - for(; tolower(*string1) == tolower(*string2); (void)string1++, string2++) - { - if (*string1 == '\0') - { - return 0; - } - } - - return tolower(*string1) - tolower(*string2); -} - -typedef struct internal_hooks -{ - void *(CJSON_CDECL *allocate)(size_t size); - void (CJSON_CDECL *deallocate)(void *pointer); - void *(CJSON_CDECL *reallocate)(void *pointer, size_t size); -} internal_hooks; - -#if defined(_MSC_VER) -/* work around MSVC error C2322: '...' address of dillimport '...' is not static */ -static void * CJSON_CDECL internal_malloc(size_t size) -{ - return malloc(size); -} -static void CJSON_CDECL internal_free(void *pointer) -{ - free(pointer); -} -static void * CJSON_CDECL internal_realloc(void *pointer, size_t size) -{ - return realloc(pointer, size); -} -#else -#define internal_malloc malloc -#define internal_free free -#define internal_realloc realloc -#endif - -static internal_hooks global_hooks = { internal_malloc, internal_free, internal_realloc }; - -static unsigned char* cJSON_strdup(const unsigned char* string, const internal_hooks * const hooks) -{ - size_t length = 0; - unsigned char *copy = NULL; - - if (string == NULL) - { - return NULL; - } - - length = strlen((const char*)string) + sizeof(""); - copy = (unsigned char*)hooks->allocate(length); - if (copy == NULL) - { - return NULL; - } - memcpy(copy, string, length); - - return copy; -} - -CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks) -{ - if (hooks == NULL) - { - /* Reset hooks */ - global_hooks.allocate = malloc; - global_hooks.deallocate = free; - global_hooks.reallocate = realloc; - return; - } - - global_hooks.allocate = malloc; - if (hooks->malloc_fn != NULL) - { - global_hooks.allocate = hooks->malloc_fn; - } - - global_hooks.deallocate = free; - if (hooks->free_fn != NULL) - { - global_hooks.deallocate = hooks->free_fn; - } - - /* use realloc only if both free and malloc are used */ - global_hooks.reallocate = NULL; - if ((global_hooks.allocate == malloc) && (global_hooks.deallocate == free)) - { - global_hooks.reallocate = realloc; - } -} - -/* Internal constructor. */ -static cJSON *cJSON_New_Item(const internal_hooks * const hooks) -{ - cJSON* node = (cJSON*)hooks->allocate(sizeof(cJSON)); - if (node) - { - memset(node, '\0', sizeof(cJSON)); - } - - return node; -} - -/* Delete a cJSON structure. */ -CJSON_PUBLIC(void) cJSON_Delete(cJSON *item) -{ - cJSON *next = NULL; - while (item != NULL) - { - next = item->next; - if (!(item->type & cJSON_IsReference) && (item->child != NULL)) - { - cJSON_Delete(item->child); - } - if (!(item->type & cJSON_IsReference) && (item->valuestring != NULL)) - { - global_hooks.deallocate(item->valuestring); - } - if (!(item->type & cJSON_StringIsConst) && (item->string != NULL)) - { - global_hooks.deallocate(item->string); - } - global_hooks.deallocate(item); - item = next; - } -} - -/* get the decimal point character of the current locale */ -static unsigned char get_decimal_point(void) -{ -#ifdef ENABLE_LOCALES - struct lconv *lconv = localeconv(); - return (unsigned char) lconv->decimal_point[0]; -#else - return '.'; -#endif -} - -typedef struct -{ - const unsigned char *content; - size_t length; - size_t offset; - size_t depth; /* How deeply nested (in arrays/objects) is the input at the current offset. */ - internal_hooks hooks; -} parse_buffer; - -/* check if the given size is left to read in a given parse buffer (starting with 1) */ -#define can_read(buffer, size) ((buffer != NULL) && (((buffer)->offset + size) <= (buffer)->length)) -/* check if the buffer can be accessed at the given index (starting with 0) */ -#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length)) -#define cannot_access_at_index(buffer, index) (!can_access_at_index(buffer, index)) -/* get a pointer to the buffer at the position */ -#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset) - -/* Parse the input text to generate a number, and populate the result into item. */ -static cJSON_bool parse_number(cJSON * const item, parse_buffer * const input_buffer) -{ - double number = 0; - unsigned char *after_end = NULL; - unsigned char number_c_string[64]; - unsigned char decimal_point = get_decimal_point(); - size_t i = 0; - - if ((input_buffer == NULL) || (input_buffer->content == NULL)) - { - return false; - } - - /* copy the number into a temporary buffer and replace '.' with the decimal point - * of the current locale (for strtod) - * This also takes care of '\0' not necessarily being available for marking the end of the input */ - for (i = 0; (i < (sizeof(number_c_string) - 1)) && can_access_at_index(input_buffer, i); i++) - { - switch (buffer_at_offset(input_buffer)[i]) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case '+': - case '-': - case 'e': - case 'E': - number_c_string[i] = buffer_at_offset(input_buffer)[i]; - break; - - case '.': - number_c_string[i] = decimal_point; - break; - - default: - goto loop_end; - } - } -loop_end: - number_c_string[i] = '\0'; - - number = strtod((const char*)number_c_string, (char**)&after_end); - if (number_c_string == after_end) - { - return false; /* parse_error */ - } - - item->valuedouble = number; - - /* use saturation in case of overflow */ - if (number >= INT_MAX) - { - item->valueint = INT_MAX; - } - else if (number <= (double)INT_MIN) - { - item->valueint = INT_MIN; - } - else - { - item->valueint = (int)number; - } - - item->type = cJSON_Number; - - input_buffer->offset += (size_t)(after_end - number_c_string); - return true; -} - -/* don't ask me, but the original cJSON_SetNumberValue returns an integer or double */ -CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number) -{ - if (number >= INT_MAX) - { - object->valueint = INT_MAX; - } - else if (number <= (double)INT_MIN) - { - object->valueint = INT_MIN; - } - else - { - object->valueint = (int)number; - } - - return object->valuedouble = number; -} - -typedef struct -{ - unsigned char *buffer; - size_t length; - size_t offset; - size_t depth; /* current nesting depth (for formatted printing) */ - cJSON_bool noalloc; - cJSON_bool format; /* is this print a formatted print */ - internal_hooks hooks; -} printbuffer; - -/* realloc printbuffer if necessary to have at least "needed" bytes more */ -static unsigned char* ensure(printbuffer * const p, size_t needed) -{ - unsigned char *newbuffer = NULL; - size_t newsize = 0; - - if ((p == NULL) || (p->buffer == NULL)) - { - return NULL; - } - - if ((p->length > 0) && (p->offset >= p->length)) - { - /* make sure that offset is valid */ - return NULL; - } - - if (needed > INT_MAX) - { - /* sizes bigger than INT_MAX are currently not supported */ - return NULL; - } - - needed += p->offset + 1; - if (needed <= p->length) - { - return p->buffer + p->offset; - } - - if (p->noalloc) { - return NULL; - } - - /* calculate new buffer size */ - if (needed > (INT_MAX / 2)) - { - /* overflow of int, use INT_MAX if possible */ - if (needed <= INT_MAX) - { - newsize = INT_MAX; - } - else - { - return NULL; - } - } - else - { - newsize = needed * 2; - } - - if (p->hooks.reallocate != NULL) - { - /* reallocate with realloc if available */ - newbuffer = (unsigned char*)p->hooks.reallocate(p->buffer, newsize); - if (newbuffer == NULL) - { - p->hooks.deallocate(p->buffer); - p->length = 0; - p->buffer = NULL; - - return NULL; - } - } - else - { - /* otherwise reallocate manually */ - newbuffer = (unsigned char*)p->hooks.allocate(newsize); - if (!newbuffer) - { - p->hooks.deallocate(p->buffer); - p->length = 0; - p->buffer = NULL; - - return NULL; - } - if (newbuffer) - { - memcpy(newbuffer, p->buffer, p->offset + 1); - } - p->hooks.deallocate(p->buffer); - } - p->length = newsize; - p->buffer = newbuffer; - - return newbuffer + p->offset; -} - -/* calculate the new length of the string in a printbuffer and update the offset */ -static void update_offset(printbuffer * const buffer) -{ - const unsigned char *buffer_pointer = NULL; - if ((buffer == NULL) || (buffer->buffer == NULL)) - { - return; - } - buffer_pointer = buffer->buffer + buffer->offset; - - buffer->offset += strlen((const char*)buffer_pointer); -} - -/* Render the number nicely from the given item into a string. */ -static cJSON_bool print_number(const cJSON * const item, printbuffer * const output_buffer) -{ - unsigned char *output_pointer = NULL; - double d = item->valuedouble; - int length = 0; - size_t i = 0; - unsigned char number_buffer[26]; /* temporary buffer to print the number into */ - unsigned char decimal_point = get_decimal_point(); - double test; - - if (output_buffer == NULL) - { - return false; - } - - /* This checks for NaN and Infinity */ - if ((d * 0) != 0) - { - length = sprintf((char*)number_buffer, "null"); - } - else - { - /* Try 15 decimal places of precision to avoid nonsignificant nonzero digits */ - length = sprintf((char*)number_buffer, "%1.15g", d); - - /* Check whether the original double can be recovered */ - if ((sscanf((char*)number_buffer, "%lg", &test) != 1) || ((double)test != d)) - { - /* If not, print with 17 decimal places of precision */ - length = sprintf((char*)number_buffer, "%1.17g", d); - } - } - - /* sprintf failed or buffer overrun occured */ - if ((length < 0) || (length > (int)(sizeof(number_buffer) - 1))) - { - return false; - } - - /* reserve appropriate space in the output */ - output_pointer = ensure(output_buffer, (size_t)length + sizeof("")); - if (output_pointer == NULL) - { - return false; - } - - /* copy the printed number to the output and replace locale - * dependent decimal point with '.' */ - for (i = 0; i < ((size_t)length); i++) - { - if (number_buffer[i] == decimal_point) - { - output_pointer[i] = '.'; - continue; - } - - output_pointer[i] = number_buffer[i]; - } - output_pointer[i] = '\0'; - - output_buffer->offset += (size_t)length; - - return true; -} - -/* parse 4 digit hexadecimal number */ -static unsigned parse_hex4(const unsigned char * const input) -{ - unsigned int h = 0; - size_t i = 0; - - for (i = 0; i < 4; i++) - { - /* parse digit */ - if ((input[i] >= '0') && (input[i] <= '9')) - { - h += (unsigned int) input[i] - '0'; - } - else if ((input[i] >= 'A') && (input[i] <= 'F')) - { - h += (unsigned int) 10 + input[i] - 'A'; - } - else if ((input[i] >= 'a') && (input[i] <= 'f')) - { - h += (unsigned int) 10 + input[i] - 'a'; - } - else /* invalid */ - { - return 0; - } - - if (i < 3) - { - /* shift left to make place for the next nibble */ - h = h << 4; - } - } - - return h; -} - -/* converts a UTF-16 literal to UTF-8 - * A literal can be one or two sequences of the form \uXXXX */ -static unsigned char utf16_literal_to_utf8(const unsigned char * const input_pointer, const unsigned char * const input_end, unsigned char **output_pointer) -{ - long unsigned int codepoint = 0; - unsigned int first_code = 0; - const unsigned char *first_sequence = input_pointer; - unsigned char utf8_length = 0; - unsigned char utf8_position = 0; - unsigned char sequence_length = 0; - unsigned char first_byte_mark = 0; - - if ((input_end - first_sequence) < 6) - { - /* input ends unexpectedly */ - goto fail; - } - - /* get the first utf16 sequence */ - first_code = parse_hex4(first_sequence + 2); - - /* check that the code is valid */ - if (((first_code >= 0xDC00) && (first_code <= 0xDFFF))) - { - goto fail; - } - - /* UTF16 surrogate pair */ - if ((first_code >= 0xD800) && (first_code <= 0xDBFF)) - { - const unsigned char *second_sequence = first_sequence + 6; - unsigned int second_code = 0; - sequence_length = 12; /* \uXXXX\uXXXX */ - - if ((input_end - second_sequence) < 6) - { - /* input ends unexpectedly */ - goto fail; - } - - if ((second_sequence[0] != '\\') || (second_sequence[1] != 'u')) - { - /* missing second half of the surrogate pair */ - goto fail; - } - - /* get the second utf16 sequence */ - second_code = parse_hex4(second_sequence + 2); - /* check that the code is valid */ - if ((second_code < 0xDC00) || (second_code > 0xDFFF)) - { - /* invalid second half of the surrogate pair */ - goto fail; - } - - - /* calculate the unicode codepoint from the surrogate pair */ - codepoint = 0x10000 + (((first_code & 0x3FF) << 10) | (second_code & 0x3FF)); - } - else - { - sequence_length = 6; /* \uXXXX */ - codepoint = first_code; - } - - /* encode as UTF-8 - * takes at maximum 4 bytes to encode: - * 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx */ - if (codepoint < 0x80) - { - /* normal ascii, encoding 0xxxxxxx */ - utf8_length = 1; - } - else if (codepoint < 0x800) - { - /* two bytes, encoding 110xxxxx 10xxxxxx */ - utf8_length = 2; - first_byte_mark = 0xC0; /* 11000000 */ - } - else if (codepoint < 0x10000) - { - /* three bytes, encoding 1110xxxx 10xxxxxx 10xxxxxx */ - utf8_length = 3; - first_byte_mark = 0xE0; /* 11100000 */ - } - else if (codepoint <= 0x10FFFF) - { - /* four bytes, encoding 1110xxxx 10xxxxxx 10xxxxxx 10xxxxxx */ - utf8_length = 4; - first_byte_mark = 0xF0; /* 11110000 */ - } - else - { - /* invalid unicode codepoint */ - goto fail; - } - - /* encode as utf8 */ - for (utf8_position = (unsigned char)(utf8_length - 1); utf8_position > 0; utf8_position--) - { - /* 10xxxxxx */ - (*output_pointer)[utf8_position] = (unsigned char)((codepoint | 0x80) & 0xBF); - codepoint >>= 6; - } - /* encode first byte */ - if (utf8_length > 1) - { - (*output_pointer)[0] = (unsigned char)((codepoint | first_byte_mark) & 0xFF); - } - else - { - (*output_pointer)[0] = (unsigned char)(codepoint & 0x7F); - } - - *output_pointer += utf8_length; - - return sequence_length; - -fail: - return 0; -} - -/* Parse the input text into an unescaped cinput, and populate item. */ -static cJSON_bool parse_string(cJSON * const item, parse_buffer * const input_buffer) -{ - const unsigned char *input_pointer = buffer_at_offset(input_buffer) + 1; - const unsigned char *input_end = buffer_at_offset(input_buffer) + 1; - unsigned char *output_pointer = NULL; - unsigned char *output = NULL; - - /* not a string */ - if (buffer_at_offset(input_buffer)[0] != '\"') - { - goto fail; - } - - { - /* calculate approximate size of the output (overestimate) */ - size_t allocation_length = 0; - size_t skipped_bytes = 0; - while (((size_t)(input_end - input_buffer->content) < input_buffer->length) && (*input_end != '\"')) - { - /* is escape sequence */ - if (input_end[0] == '\\') - { - if ((size_t)(input_end + 1 - input_buffer->content) >= input_buffer->length) - { - /* prevent buffer overflow when last input character is a backslash */ - goto fail; - } - skipped_bytes++; - input_end++; - } - input_end++; - } - if (((size_t)(input_end - input_buffer->content) >= input_buffer->length) || (*input_end != '\"')) - { - goto fail; /* string ended unexpectedly */ - } - - /* This is at most how much we need for the output */ - allocation_length = (size_t) (input_end - buffer_at_offset(input_buffer)) - skipped_bytes; - output = (unsigned char*)input_buffer->hooks.allocate(allocation_length + sizeof("")); - if (output == NULL) - { - goto fail; /* allocation failure */ - } - } - - output_pointer = output; - /* loop through the string literal */ - while (input_pointer < input_end) - { - if (*input_pointer != '\\') - { - *output_pointer++ = *input_pointer++; - } - /* escape sequence */ - else - { - unsigned char sequence_length = 2; - if ((input_end - input_pointer) < 1) - { - goto fail; - } - - switch (input_pointer[1]) - { - case 'b': - *output_pointer++ = '\b'; - break; - case 'f': - *output_pointer++ = '\f'; - break; - case 'n': - *output_pointer++ = '\n'; - break; - case 'r': - *output_pointer++ = '\r'; - break; - case 't': - *output_pointer++ = '\t'; - break; - case '\"': - case '\\': - case '/': - *output_pointer++ = input_pointer[1]; - break; - - /* UTF-16 literal */ - case 'u': - sequence_length = utf16_literal_to_utf8(input_pointer, input_end, &output_pointer); - if (sequence_length == 0) - { - /* failed to convert UTF16-literal to UTF-8 */ - goto fail; - } - break; - - default: - goto fail; - } - input_pointer += sequence_length; - } - } - - /* zero terminate the output */ - *output_pointer = '\0'; - - item->type = cJSON_String; - item->valuestring = (char*)output; - - input_buffer->offset = (size_t) (input_end - input_buffer->content); - input_buffer->offset++; - - return true; - -fail: - if (output != NULL) - { - input_buffer->hooks.deallocate(output); - } - - if (input_pointer != NULL) - { - input_buffer->offset = (size_t)(input_pointer - input_buffer->content); - } - - return false; -} - -/* Render the cstring provided to an escaped version that can be printed. */ -static cJSON_bool print_string_ptr(const unsigned char * const input, printbuffer * const output_buffer) -{ - const unsigned char *input_pointer = NULL; - unsigned char *output = NULL; - unsigned char *output_pointer = NULL; - size_t output_length = 0; - /* numbers of additional characters needed for escaping */ - size_t escape_characters = 0; - - if (output_buffer == NULL) - { - return false; - } - - /* empty string */ - if (input == NULL) - { - output = ensure(output_buffer, sizeof("\"\"")); - if (output == NULL) - { - return false; - } - strcpy((char*)output, "\"\""); - - return true; - } - - /* set "flag" to 1 if something needs to be escaped */ - for (input_pointer = input; *input_pointer; input_pointer++) - { - switch (*input_pointer) - { - case '\"': - case '\\': - case '\b': - case '\f': - case '\n': - case '\r': - case '\t': - /* one character escape sequence */ - escape_characters++; - break; - default: - if (*input_pointer < 32) - { - /* UTF-16 escape sequence uXXXX */ - escape_characters += 5; - } - break; - } - } - output_length = (size_t)(input_pointer - input) + escape_characters; - - output = ensure(output_buffer, output_length + sizeof("\"\"")); - if (output == NULL) - { - return false; - } - - /* no characters have to be escaped */ - if (escape_characters == 0) - { - output[0] = '\"'; - memcpy(output + 1, input, output_length); - output[output_length + 1] = '\"'; - output[output_length + 2] = '\0'; - - return true; - } - - output[0] = '\"'; - output_pointer = output + 1; - /* copy the string */ - for (input_pointer = input; *input_pointer != '\0'; (void)input_pointer++, output_pointer++) - { - if ((*input_pointer > 31) && (*input_pointer != '\"') && (*input_pointer != '\\')) - { - /* normal character, copy */ - *output_pointer = *input_pointer; - } - else - { - /* character needs to be escaped */ - *output_pointer++ = '\\'; - switch (*input_pointer) - { - case '\\': - *output_pointer = '\\'; - break; - case '\"': - *output_pointer = '\"'; - break; - case '\b': - *output_pointer = 'b'; - break; - case '\f': - *output_pointer = 'f'; - break; - case '\n': - *output_pointer = 'n'; - break; - case '\r': - *output_pointer = 'r'; - break; - case '\t': - *output_pointer = 't'; - break; - default: - /* escape and print as unicode codepoint */ - sprintf((char*)output_pointer, "u%04x", *input_pointer); - output_pointer += 4; - break; - } - } - } - output[output_length + 1] = '\"'; - output[output_length + 2] = '\0'; - - return true; -} - -/* Invoke print_string_ptr (which is useful) on an item. */ -static cJSON_bool print_string(const cJSON * const item, printbuffer * const p) -{ - return print_string_ptr((unsigned char*)item->valuestring, p); -} - -/* Predeclare these prototypes. */ -static cJSON_bool parse_value(cJSON * const item, parse_buffer * const input_buffer); -static cJSON_bool print_value(const cJSON * const item, printbuffer * const output_buffer); -static cJSON_bool parse_array(cJSON * const item, parse_buffer * const input_buffer); -static cJSON_bool print_array(const cJSON * const item, printbuffer * const output_buffer); -static cJSON_bool parse_object(cJSON * const item, parse_buffer * const input_buffer); -static cJSON_bool print_object(const cJSON * const item, printbuffer * const output_buffer); - -/* Utility to jump whitespace and cr/lf */ -static parse_buffer *buffer_skip_whitespace(parse_buffer * const buffer) -{ - if ((buffer == NULL) || (buffer->content == NULL)) - { - return NULL; - } - - while (can_access_at_index(buffer, 0) && (buffer_at_offset(buffer)[0] <= 32)) - { - buffer->offset++; - } - - if (buffer->offset == buffer->length) - { - buffer->offset--; - } - - return buffer; -} - -/* skip the UTF-8 BOM (byte order mark) if it is at the beginning of a buffer */ -static parse_buffer *skip_utf8_bom(parse_buffer * const buffer) -{ - if ((buffer == NULL) || (buffer->content == NULL) || (buffer->offset != 0)) - { - return NULL; - } - - if (can_access_at_index(buffer, 4) && (strncmp((const char*)buffer_at_offset(buffer), "\xEF\xBB\xBF", 3) == 0)) - { - buffer->offset += 3; - } - - return buffer; -} - -/* Parse an object - create a new root, and populate. */ -CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated) -{ - parse_buffer buffer = { 0, 0, 0, 0, { 0, 0, 0 } }; - cJSON *item = NULL; - - /* reset error position */ - global_error.json = NULL; - global_error.position = 0; - - if (value == NULL) - { - goto fail; - } - - buffer.content = (const unsigned char*)value; - buffer.length = strlen((const char*)value) + sizeof(""); - buffer.offset = 0; - buffer.hooks = global_hooks; - - item = cJSON_New_Item(&global_hooks); - if (item == NULL) /* memory fail */ - { - goto fail; - } - - if (!parse_value(item, buffer_skip_whitespace(skip_utf8_bom(&buffer)))) - { - /* parse failure. ep is set. */ - goto fail; - } - - /* if we require null-terminated JSON without appended garbage, skip and then check for a null terminator */ - if (require_null_terminated) - { - buffer_skip_whitespace(&buffer); - if ((buffer.offset >= buffer.length) || buffer_at_offset(&buffer)[0] != '\0') - { - goto fail; - } - } - if (return_parse_end) - { - *return_parse_end = (const char*)buffer_at_offset(&buffer); - } - - return item; - -fail: - if (item != NULL) - { - cJSON_Delete(item); - } - - if (value != NULL) - { - error local_error; - local_error.json = (const unsigned char*)value; - local_error.position = 0; - - if (buffer.offset < buffer.length) - { - local_error.position = buffer.offset; - } - else if (buffer.length > 0) - { - local_error.position = buffer.length - 1; - } - - if (return_parse_end != NULL) - { - *return_parse_end = (const char*)local_error.json + local_error.position; - } - - global_error = local_error; - } - - return NULL; -} - -/* Default options for cJSON_Parse */ -CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value) -{ - return cJSON_ParseWithOpts(value, 0, 0); -} - -#define cjson_min(a, b) ((a < b) ? a : b) - -static unsigned char *print(const cJSON * const item, cJSON_bool format, const internal_hooks * const hooks) -{ - static const size_t default_buffer_size = 256; - printbuffer buffer[1]; - unsigned char *printed = NULL; - - memset(buffer, 0, sizeof(buffer)); - - /* create buffer */ - buffer->buffer = (unsigned char*) hooks->allocate(default_buffer_size); - buffer->length = default_buffer_size; - buffer->format = format; - buffer->hooks = *hooks; - if (buffer->buffer == NULL) - { - goto fail; - } - - /* print the value */ - if (!print_value(item, buffer)) - { - goto fail; - } - update_offset(buffer); - - /* check if reallocate is available */ - if (hooks->reallocate != NULL) - { - printed = (unsigned char*) hooks->reallocate(buffer->buffer, buffer->offset + 1); - if (printed == NULL) { - goto fail; - } - buffer->buffer = NULL; - } - else /* otherwise copy the JSON over to a new buffer */ - { - printed = (unsigned char*) hooks->allocate(buffer->offset + 1); - if (printed == NULL) - { - goto fail; - } - memcpy(printed, buffer->buffer, cjson_min(buffer->length, buffer->offset + 1)); - printed[buffer->offset] = '\0'; /* just to be sure */ - - /* free the buffer */ - hooks->deallocate(buffer->buffer); - } - - return printed; - -fail: - if (buffer->buffer != NULL) - { - hooks->deallocate(buffer->buffer); - } - - if (printed != NULL) - { - hooks->deallocate(printed); - } - - return NULL; -} - -/* Render a cJSON item/entity/structure to text. */ -CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item) -{ - return (char*)print(item, true, &global_hooks); -} - -CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item) -{ - return (char*)print(item, false, &global_hooks); -} - -CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt) -{ - printbuffer p = { 0, 0, 0, 0, 0, 0, { 0, 0, 0 } }; - - if (prebuffer < 0) - { - return NULL; - } - - p.buffer = (unsigned char*)global_hooks.allocate((size_t)prebuffer); - if (!p.buffer) - { - return NULL; - } - - p.length = (size_t)prebuffer; - p.offset = 0; - p.noalloc = false; - p.format = fmt; - p.hooks = global_hooks; - - if (!print_value(item, &p)) - { - global_hooks.deallocate(p.buffer); - return NULL; - } - - return (char*)p.buffer; -} - -CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buf, const int len, const cJSON_bool fmt) -{ - printbuffer p = { 0, 0, 0, 0, 0, 0, { 0, 0, 0 } }; - - if ((len < 0) || (buf == NULL)) - { - return false; - } - - p.buffer = (unsigned char*)buf; - p.length = (size_t)len; - p.offset = 0; - p.noalloc = true; - p.format = fmt; - p.hooks = global_hooks; - - return print_value(item, &p); -} - -/* Parser core - when encountering text, process appropriately. */ -static cJSON_bool parse_value(cJSON * const item, parse_buffer * const input_buffer) -{ - if ((input_buffer == NULL) || (input_buffer->content == NULL)) - { - return false; /* no input */ - } - - /* parse the different types of values */ - /* null */ - if (can_read(input_buffer, 4) && (strncmp((const char*)buffer_at_offset(input_buffer), "null", 4) == 0)) - { - item->type = cJSON_NULL; - input_buffer->offset += 4; - return true; - } - /* false */ - if (can_read(input_buffer, 5) && (strncmp((const char*)buffer_at_offset(input_buffer), "false", 5) == 0)) - { - item->type = cJSON_False; - input_buffer->offset += 5; - return true; - } - /* true */ - if (can_read(input_buffer, 4) && (strncmp((const char*)buffer_at_offset(input_buffer), "true", 4) == 0)) - { - item->type = cJSON_True; - item->valueint = 1; - input_buffer->offset += 4; - return true; - } - /* string */ - if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '\"')) - { - return parse_string(item, input_buffer); - } - /* number */ - if (can_access_at_index(input_buffer, 0) && ((buffer_at_offset(input_buffer)[0] == '-') || ((buffer_at_offset(input_buffer)[0] >= '0') && (buffer_at_offset(input_buffer)[0] <= '9')))) - { - return parse_number(item, input_buffer); - } - /* array */ - if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '[')) - { - return parse_array(item, input_buffer); - } - /* object */ - if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '{')) - { - return parse_object(item, input_buffer); - } - - return false; -} - -/* Render a value to text. */ -static cJSON_bool print_value(const cJSON * const item, printbuffer * const output_buffer) -{ - unsigned char *output = NULL; - - if ((item == NULL) || (output_buffer == NULL)) - { - return false; - } - - switch ((item->type) & 0xFF) - { - case cJSON_NULL: - output = ensure(output_buffer, 5); - if (output == NULL) - { - return false; - } - strcpy((char*)output, "null"); - return true; - - case cJSON_False: - output = ensure(output_buffer, 6); - if (output == NULL) - { - return false; - } - strcpy((char*)output, "false"); - return true; - - case cJSON_True: - output = ensure(output_buffer, 5); - if (output == NULL) - { - return false; - } - strcpy((char*)output, "true"); - return true; - - case cJSON_Number: - return print_number(item, output_buffer); - - case cJSON_Raw: - { - size_t raw_length = 0; - if (item->valuestring == NULL) - { - return false; - } - - raw_length = strlen(item->valuestring) + sizeof(""); - output = ensure(output_buffer, raw_length); - if (output == NULL) - { - return false; - } - memcpy(output, item->valuestring, raw_length); - return true; - } - - case cJSON_String: - return print_string(item, output_buffer); - - case cJSON_Array: - return print_array(item, output_buffer); - - case cJSON_Object: - return print_object(item, output_buffer); - - default: - return false; - } -} - -/* Build an array from input text. */ -static cJSON_bool parse_array(cJSON * const item, parse_buffer * const input_buffer) -{ - cJSON *head = NULL; /* head of the linked list */ - cJSON *current_item = NULL; - - if (input_buffer->depth >= CJSON_NESTING_LIMIT) - { - return false; /* to deeply nested */ - } - input_buffer->depth++; - - if (buffer_at_offset(input_buffer)[0] != '[') - { - /* not an array */ - goto fail; - } - - input_buffer->offset++; - buffer_skip_whitespace(input_buffer); - if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ']')) - { - /* empty array */ - goto success; - } - - /* check if we skipped to the end of the buffer */ - if (cannot_access_at_index(input_buffer, 0)) - { - input_buffer->offset--; - goto fail; - } - - /* step back to character in front of the first element */ - input_buffer->offset--; - /* loop through the comma separated array elements */ - do - { - /* allocate next item */ - cJSON *new_item = cJSON_New_Item(&(input_buffer->hooks)); - if (new_item == NULL) - { - goto fail; /* allocation failure */ - } - - /* attach next item to list */ - if (head == NULL) - { - /* start the linked list */ - current_item = head = new_item; - } - else - { - /* add to the end and advance */ - current_item->next = new_item; - new_item->prev = current_item; - current_item = new_item; - } - - /* parse next value */ - input_buffer->offset++; - buffer_skip_whitespace(input_buffer); - if (!parse_value(current_item, input_buffer)) - { - goto fail; /* failed to parse value */ - } - buffer_skip_whitespace(input_buffer); - } - while (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ',')); - - if (cannot_access_at_index(input_buffer, 0) || buffer_at_offset(input_buffer)[0] != ']') - { - goto fail; /* expected end of array */ - } - -success: - input_buffer->depth--; - - item->type = cJSON_Array; - item->child = head; - - input_buffer->offset++; - - return true; - -fail: - if (head != NULL) - { - cJSON_Delete(head); - } - - return false; -} - -/* Render an array to text */ -static cJSON_bool print_array(const cJSON * const item, printbuffer * const output_buffer) -{ - unsigned char *output_pointer = NULL; - size_t length = 0; - cJSON *current_element = item->child; - - if (output_buffer == NULL) - { - return false; - } - - /* Compose the output array. */ - /* opening square bracket */ - output_pointer = ensure(output_buffer, 1); - if (output_pointer == NULL) - { - return false; - } - - *output_pointer = '['; - output_buffer->offset++; - output_buffer->depth++; - - while (current_element != NULL) - { - if (!print_value(current_element, output_buffer)) - { - return false; - } - update_offset(output_buffer); - if (current_element->next) - { - length = (size_t) (output_buffer->format ? 2 : 1); - output_pointer = ensure(output_buffer, length + 1); - if (output_pointer == NULL) - { - return false; - } - *output_pointer++ = ','; - if(output_buffer->format) - { - *output_pointer++ = ' '; - } - *output_pointer = '\0'; - output_buffer->offset += length; - } - current_element = current_element->next; - } - - output_pointer = ensure(output_buffer, 2); - if (output_pointer == NULL) - { - return false; - } - *output_pointer++ = ']'; - *output_pointer = '\0'; - output_buffer->depth--; - - return true; -} - -/* Build an object from the text. */ -static cJSON_bool parse_object(cJSON * const item, parse_buffer * const input_buffer) -{ - cJSON *head = NULL; /* linked list head */ - cJSON *current_item = NULL; - - if (input_buffer->depth >= CJSON_NESTING_LIMIT) - { - return false; /* to deeply nested */ - } - input_buffer->depth++; - - if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != '{')) - { - goto fail; /* not an object */ - } - - input_buffer->offset++; - buffer_skip_whitespace(input_buffer); - if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '}')) - { - goto success; /* empty object */ - } - - /* check if we skipped to the end of the buffer */ - if (cannot_access_at_index(input_buffer, 0)) - { - input_buffer->offset--; - goto fail; - } - - /* step back to character in front of the first element */ - input_buffer->offset--; - /* loop through the comma separated array elements */ - do - { - /* allocate next item */ - cJSON *new_item = cJSON_New_Item(&(input_buffer->hooks)); - if (new_item == NULL) - { - goto fail; /* allocation failure */ - } - - /* attach next item to list */ - if (head == NULL) - { - /* start the linked list */ - current_item = head = new_item; - } - else - { - /* add to the end and advance */ - current_item->next = new_item; - new_item->prev = current_item; - current_item = new_item; - } - - /* parse the name of the child */ - input_buffer->offset++; - buffer_skip_whitespace(input_buffer); - if (!parse_string(current_item, input_buffer)) - { - goto fail; /* faile to parse name */ - } - buffer_skip_whitespace(input_buffer); - - /* swap valuestring and string, because we parsed the name */ - current_item->string = current_item->valuestring; - current_item->valuestring = NULL; - - if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != ':')) - { - goto fail; /* invalid object */ - } - - /* parse the value */ - input_buffer->offset++; - buffer_skip_whitespace(input_buffer); - if (!parse_value(current_item, input_buffer)) - { - goto fail; /* failed to parse value */ - } - buffer_skip_whitespace(input_buffer); - } - while (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ',')); - - if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != '}')) - { - goto fail; /* expected end of object */ - } - -success: - input_buffer->depth--; - - item->type = cJSON_Object; - item->child = head; - - input_buffer->offset++; - return true; - -fail: - if (head != NULL) - { - cJSON_Delete(head); - } - - return false; -} - -/* Render an object to text. */ -static cJSON_bool print_object(const cJSON * const item, printbuffer * const output_buffer) -{ - unsigned char *output_pointer = NULL; - size_t length = 0; - cJSON *current_item = item->child; - - if (output_buffer == NULL) - { - return false; - } - - /* Compose the output: */ - length = (size_t) (output_buffer->format ? 2 : 1); /* fmt: {\n */ - output_pointer = ensure(output_buffer, length + 1); - if (output_pointer == NULL) - { - return false; - } - - *output_pointer++ = '{'; - output_buffer->depth++; - if (output_buffer->format) - { - *output_pointer++ = '\n'; - } - output_buffer->offset += length; - - while (current_item) - { - if (output_buffer->format) - { - size_t i; - output_pointer = ensure(output_buffer, output_buffer->depth); - if (output_pointer == NULL) - { - return false; - } - for (i = 0; i < output_buffer->depth; i++) - { - *output_pointer++ = '\t'; - } - output_buffer->offset += output_buffer->depth; - } - - /* print key */ - if (!print_string_ptr((unsigned char*)current_item->string, output_buffer)) - { - return false; - } - update_offset(output_buffer); - - length = (size_t) (output_buffer->format ? 2 : 1); - output_pointer = ensure(output_buffer, length); - if (output_pointer == NULL) - { - return false; - } - *output_pointer++ = ':'; - if (output_buffer->format) - { - *output_pointer++ = '\t'; - } - output_buffer->offset += length; - - /* print value */ - if (!print_value(current_item, output_buffer)) - { - return false; - } - update_offset(output_buffer); - - /* print comma if not last */ - length = ((size_t)(output_buffer->format ? 1 : 0) + (size_t)(current_item->next ? 1 : 0)); - output_pointer = ensure(output_buffer, length + 1); - if (output_pointer == NULL) - { - return false; - } - if (current_item->next) - { - *output_pointer++ = ','; - } - - if (output_buffer->format) - { - *output_pointer++ = '\n'; - } - *output_pointer = '\0'; - output_buffer->offset += length; - - current_item = current_item->next; - } - - output_pointer = ensure(output_buffer, output_buffer->format ? (output_buffer->depth + 1) : 2); - if (output_pointer == NULL) - { - return false; - } - if (output_buffer->format) - { - size_t i; - for (i = 0; i < (output_buffer->depth - 1); i++) - { - *output_pointer++ = '\t'; - } - } - *output_pointer++ = '}'; - *output_pointer = '\0'; - output_buffer->depth--; - - return true; -} - -/* Get Array size/item / object item. */ -CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array) -{ - cJSON *child = NULL; - size_t size = 0; - - if (array == NULL) - { - return 0; - } - - child = array->child; - - while(child != NULL) - { - size++; - child = child->next; - } - - /* FIXME: Can overflow here. Cannot be fixed without breaking the API */ - - return (int)size; -} - -static cJSON* get_array_item(const cJSON *array, size_t index) -{ - cJSON *current_child = NULL; - - if (array == NULL) - { - return NULL; - } - - current_child = array->child; - while ((current_child != NULL) && (index > 0)) - { - index--; - current_child = current_child->next; - } - - return current_child; -} - -CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index) -{ - if (index < 0) - { - return NULL; - } - - return get_array_item(array, (size_t)index); -} - -static cJSON *get_object_item(const cJSON * const object, const char * const name, const cJSON_bool case_sensitive) -{ - cJSON *current_element = NULL; - - if ((object == NULL) || (name == NULL)) - { - return NULL; - } - - current_element = object->child; - if (case_sensitive) - { - while ((current_element != NULL) && (strcmp(name, current_element->string) != 0)) - { - current_element = current_element->next; - } - } - else - { - while ((current_element != NULL) && (case_insensitive_strcmp((const unsigned char*)name, (const unsigned char*)(current_element->string)) != 0)) - { - current_element = current_element->next; - } - } - - return current_element; -} - -CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string) -{ - return get_object_item(object, string, false); -} - -CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string) -{ - return get_object_item(object, string, true); -} - -CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string) -{ - return cJSON_GetObjectItem(object, string) ? 1 : 0; -} - -/* Utility for array list handling. */ -static void suffix_object(cJSON *prev, cJSON *item) -{ - prev->next = item; - item->prev = prev; -} - -/* Utility for handling references. */ -static cJSON *create_reference(const cJSON *item, const internal_hooks * const hooks) -{ - cJSON *reference = NULL; - if (item == NULL) - { - return NULL; - } - - reference = cJSON_New_Item(hooks); - if (reference == NULL) - { - return NULL; - } - - memcpy(reference, item, sizeof(cJSON)); - reference->string = NULL; - reference->type |= cJSON_IsReference; - reference->next = reference->prev = NULL; - return reference; -} - -static cJSON_bool add_item_to_array(cJSON *array, cJSON *item) -{ - cJSON *child = NULL; - - if ((item == NULL) || (array == NULL)) - { - return false; - } - - child = array->child; - - if (child == NULL) - { - /* list is empty, start new one */ - array->child = item; - } - else - { - /* append to the end */ - while (child->next) - { - child = child->next; - } - suffix_object(child, item); - } - - return true; -} - -/* Add item to array/object. */ -CJSON_PUBLIC(void) cJSON_AddItemToArray(cJSON *array, cJSON *item) -{ - add_item_to_array(array, item); -} - -#if defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5)))) - #pragma GCC diagnostic push -#endif -#ifdef __GNUC__ -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -/* helper function to cast away const */ -static void* cast_away_const(const void* string) -{ - return (void*)string; -} -#if defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5)))) - #pragma GCC diagnostic pop -#endif - - -static cJSON_bool add_item_to_object(cJSON * const object, const char * const string, cJSON * const item, const internal_hooks * const hooks, const cJSON_bool constant_key) -{ - char *new_key = NULL; - int new_type = cJSON_Invalid; - - if ((object == NULL) || (string == NULL) || (item == NULL)) - { - return false; - } - - if (constant_key) - { - new_key = (char*)cast_away_const(string); - new_type = item->type | cJSON_StringIsConst; - } - else - { - new_key = (char*)cJSON_strdup((const unsigned char*)string, hooks); - if (new_key == NULL) - { - return false; - } - - new_type = item->type & ~cJSON_StringIsConst; - } - - if (!(item->type & cJSON_StringIsConst) && (item->string != NULL)) - { - hooks->deallocate(item->string); - } - - item->string = new_key; - item->type = new_type; - - return add_item_to_array(object, item); -} - -CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item) -{ - add_item_to_object(object, string, item, &global_hooks, false); -} - -/* Add an item to an object with constant string as key */ -CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item) -{ - add_item_to_object(object, string, item, &global_hooks, true); -} - -CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item) -{ - if (array == NULL) - { - return; - } - - add_item_to_array(array, create_reference(item, &global_hooks)); -} - -CJSON_PUBLIC(void) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item) -{ - if ((object == NULL) || (string == NULL)) - { - return; - } - - add_item_to_object(object, string, create_reference(item, &global_hooks), &global_hooks, false); -} - -CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name) -{ - cJSON *null = cJSON_CreateNull(); - if (add_item_to_object(object, name, null, &global_hooks, false)) - { - return null; - } - - cJSON_Delete(null); - return NULL; -} - -CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const char * const name) -{ - cJSON *true_item = cJSON_CreateTrue(); - if (add_item_to_object(object, name, true_item, &global_hooks, false)) - { - return true_item; - } - - cJSON_Delete(true_item); - return NULL; -} - -CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const char * const name) -{ - cJSON *false_item = cJSON_CreateFalse(); - if (add_item_to_object(object, name, false_item, &global_hooks, false)) - { - return false_item; - } - - cJSON_Delete(false_item); - return NULL; -} - -CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_bool boolean) -{ - cJSON *bool_item = cJSON_CreateBool(boolean); - if (add_item_to_object(object, name, bool_item, &global_hooks, false)) - { - return bool_item; - } - - cJSON_Delete(bool_item); - return NULL; -} - -CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char * const name, const double number) -{ - cJSON *number_item = cJSON_CreateNumber(number); - if (add_item_to_object(object, name, number_item, &global_hooks, false)) - { - return number_item; - } - - cJSON_Delete(number_item); - return NULL; -} - -CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string) -{ - cJSON *string_item = cJSON_CreateString(string); - if (add_item_to_object(object, name, string_item, &global_hooks, false)) - { - return string_item; - } - - cJSON_Delete(string_item); - return NULL; -} - -CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * const name, const char * const raw) -{ - cJSON *raw_item = cJSON_CreateRaw(raw); - if (add_item_to_object(object, name, raw_item, &global_hooks, false)) - { - return raw_item; - } - - cJSON_Delete(raw_item); - return NULL; -} - -CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char * const name) -{ - cJSON *object_item = cJSON_CreateObject(); - if (add_item_to_object(object, name, object_item, &global_hooks, false)) - { - return object_item; - } - - cJSON_Delete(object_item); - return NULL; -} - -CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name) -{ - cJSON *array = cJSON_CreateArray(); - if (add_item_to_object(object, name, array, &global_hooks, false)) - { - return array; - } - - cJSON_Delete(array); - return NULL; -} - -CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item) -{ - if ((parent == NULL) || (item == NULL)) - { - return NULL; - } - - if (item->prev != NULL) - { - /* not the first element */ - item->prev->next = item->next; - } - if (item->next != NULL) - { - /* not the last element */ - item->next->prev = item->prev; - } - - if (item == parent->child) - { - /* first element */ - parent->child = item->next; - } - /* make sure the detached item doesn't point anywhere anymore */ - item->prev = NULL; - item->next = NULL; - - return item; -} - -CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which) -{ - if (which < 0) - { - return NULL; - } - - return cJSON_DetachItemViaPointer(array, get_array_item(array, (size_t)which)); -} - -CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which) -{ - cJSON_Delete(cJSON_DetachItemFromArray(array, which)); -} - -CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string) -{ - cJSON *to_detach = cJSON_GetObjectItem(object, string); - - return cJSON_DetachItemViaPointer(object, to_detach); -} - -CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string) -{ - cJSON *to_detach = cJSON_GetObjectItemCaseSensitive(object, string); - - return cJSON_DetachItemViaPointer(object, to_detach); -} - -CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string) -{ - cJSON_Delete(cJSON_DetachItemFromObject(object, string)); -} - -CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string) -{ - cJSON_Delete(cJSON_DetachItemFromObjectCaseSensitive(object, string)); -} - -/* Replace array/object items with new ones. */ -CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem) -{ - cJSON *after_inserted = NULL; - - if (which < 0) - { - return; - } - - after_inserted = get_array_item(array, (size_t)which); - if (after_inserted == NULL) - { - add_item_to_array(array, newitem); - return; - } - - newitem->next = after_inserted; - newitem->prev = after_inserted->prev; - after_inserted->prev = newitem; - if (after_inserted == array->child) - { - array->child = newitem; - } - else - { - newitem->prev->next = newitem; - } -} - -CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement) -{ - if ((parent == NULL) || (replacement == NULL) || (item == NULL)) - { - return false; - } - - if (replacement == item) - { - return true; - } - - replacement->next = item->next; - replacement->prev = item->prev; - - if (replacement->next != NULL) - { - replacement->next->prev = replacement; - } - if (replacement->prev != NULL) - { - replacement->prev->next = replacement; - } - if (parent->child == item) - { - parent->child = replacement; - } - - item->next = NULL; - item->prev = NULL; - cJSON_Delete(item); - - return true; -} - -CJSON_PUBLIC(void) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem) -{ - if (which < 0) - { - return; - } - - cJSON_ReplaceItemViaPointer(array, get_array_item(array, (size_t)which), newitem); -} - -static cJSON_bool replace_item_in_object(cJSON *object, const char *string, cJSON *replacement, cJSON_bool case_sensitive) -{ - if ((replacement == NULL) || (string == NULL)) - { - return false; - } - - /* replace the name in the replacement */ - if (!(replacement->type & cJSON_StringIsConst) && (replacement->string != NULL)) - { - cJSON_free(replacement->string); - } - replacement->string = (char*)cJSON_strdup((const unsigned char*)string, &global_hooks); - replacement->type &= ~cJSON_StringIsConst; - - cJSON_ReplaceItemViaPointer(object, get_object_item(object, string, case_sensitive), replacement); - - return true; -} - -CJSON_PUBLIC(void) cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem) -{ - replace_item_in_object(object, string, newitem, false); -} - -CJSON_PUBLIC(void) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object, const char *string, cJSON *newitem) -{ - replace_item_in_object(object, string, newitem, true); -} - -/* Create basic types: */ -CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void) -{ - cJSON *item = cJSON_New_Item(&global_hooks); - if(item) - { - item->type = cJSON_NULL; - } - - return item; -} - -CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void) -{ - cJSON *item = cJSON_New_Item(&global_hooks); - if(item) - { - item->type = cJSON_True; - } - - return item; -} - -CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void) -{ - cJSON *item = cJSON_New_Item(&global_hooks); - if(item) - { - item->type = cJSON_False; - } - - return item; -} - -CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool b) -{ - cJSON *item = cJSON_New_Item(&global_hooks); - if(item) - { - item->type = b ? cJSON_True : cJSON_False; - } - - return item; -} - -CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num) -{ - cJSON *item = cJSON_New_Item(&global_hooks); - if(item) - { - item->type = cJSON_Number; - item->valuedouble = num; - - /* use saturation in case of overflow */ - if (num >= INT_MAX) - { - item->valueint = INT_MAX; - } - else if (num <= (double)INT_MIN) - { - item->valueint = INT_MIN; - } - else - { - item->valueint = (int)num; - } - } - - return item; -} - -CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string) -{ - cJSON *item = cJSON_New_Item(&global_hooks); - if(item) - { - item->type = cJSON_String; - item->valuestring = (char*)cJSON_strdup((const unsigned char*)string, &global_hooks); - if(!item->valuestring) - { - cJSON_Delete(item); - return NULL; - } - } - - return item; -} - -CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string) -{ - cJSON *item = cJSON_New_Item(&global_hooks); - if (item != NULL) - { - item->type = cJSON_String | cJSON_IsReference; - item->valuestring = (char*)cast_away_const(string); - } - - return item; -} - -CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child) -{ - cJSON *item = cJSON_New_Item(&global_hooks); - if (item != NULL) { - item->type = cJSON_Object | cJSON_IsReference; - item->child = (cJSON*)cast_away_const(child); - } - - return item; -} - -CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child) { - cJSON *item = cJSON_New_Item(&global_hooks); - if (item != NULL) { - item->type = cJSON_Array | cJSON_IsReference; - item->child = (cJSON*)cast_away_const(child); - } - - return item; -} - -CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw) -{ - cJSON *item = cJSON_New_Item(&global_hooks); - if(item) - { - item->type = cJSON_Raw; - item->valuestring = (char*)cJSON_strdup((const unsigned char*)raw, &global_hooks); - if(!item->valuestring) - { - cJSON_Delete(item); - return NULL; - } - } - - return item; -} - -CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void) -{ - cJSON *item = cJSON_New_Item(&global_hooks); - if(item) - { - item->type=cJSON_Array; - } - - return item; -} - -CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void) -{ - cJSON *item = cJSON_New_Item(&global_hooks); - if (item) - { - item->type = cJSON_Object; - } - - return item; -} - -/* Create Arrays: */ -CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count) -{ - size_t i = 0; - cJSON *n = NULL; - cJSON *p = NULL; - cJSON *a = NULL; - - if ((count < 0) || (numbers == NULL)) - { - return NULL; - } - - a = cJSON_CreateArray(); - for(i = 0; a && (i < (size_t)count); i++) - { - n = cJSON_CreateNumber(numbers[i]); - if (!n) - { - cJSON_Delete(a); - return NULL; - } - if(!i) - { - a->child = n; - } - else - { - suffix_object(p, n); - } - p = n; - } - - return a; -} - -CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count) -{ - size_t i = 0; - cJSON *n = NULL; - cJSON *p = NULL; - cJSON *a = NULL; - - if ((count < 0) || (numbers == NULL)) - { - return NULL; - } - - a = cJSON_CreateArray(); - - for(i = 0; a && (i < (size_t)count); i++) - { - n = cJSON_CreateNumber((double)numbers[i]); - if(!n) - { - cJSON_Delete(a); - return NULL; - } - if(!i) - { - a->child = n; - } - else - { - suffix_object(p, n); - } - p = n; - } - - return a; -} - -CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count) -{ - size_t i = 0; - cJSON *n = NULL; - cJSON *p = NULL; - cJSON *a = NULL; - - if ((count < 0) || (numbers == NULL)) - { - return NULL; - } - - a = cJSON_CreateArray(); - - for(i = 0;a && (i < (size_t)count); i++) - { - n = cJSON_CreateNumber(numbers[i]); - if(!n) - { - cJSON_Delete(a); - return NULL; - } - if(!i) - { - a->child = n; - } - else - { - suffix_object(p, n); - } - p = n; - } - - return a; -} - -CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char **strings, int count) -{ - size_t i = 0; - cJSON *n = NULL; - cJSON *p = NULL; - cJSON *a = NULL; - - if ((count < 0) || (strings == NULL)) - { - return NULL; - } - - a = cJSON_CreateArray(); - - for (i = 0; a && (i < (size_t)count); i++) - { - n = cJSON_CreateString(strings[i]); - if(!n) - { - cJSON_Delete(a); - return NULL; - } - if(!i) - { - a->child = n; - } - else - { - suffix_object(p,n); - } - p = n; - } - - return a; -} - -/* Duplication */ -CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse) -{ - cJSON *newitem = NULL; - cJSON *child = NULL; - cJSON *next = NULL; - cJSON *newchild = NULL; - - /* Bail on bad ptr */ - if (!item) - { - goto fail; - } - /* Create new item */ - newitem = cJSON_New_Item(&global_hooks); - if (!newitem) - { - goto fail; - } - /* Copy over all vars */ - newitem->type = item->type & (~cJSON_IsReference); - newitem->valueint = item->valueint; - newitem->valuedouble = item->valuedouble; - if (item->valuestring) - { - newitem->valuestring = (char*)cJSON_strdup((unsigned char*)item->valuestring, &global_hooks); - if (!newitem->valuestring) - { - goto fail; - } - } - if (item->string) - { - newitem->string = (item->type&cJSON_StringIsConst) ? item->string : (char*)cJSON_strdup((unsigned char*)item->string, &global_hooks); - if (!newitem->string) - { - goto fail; - } - } - /* If non-recursive, then we're done! */ - if (!recurse) - { - return newitem; - } - /* Walk the ->next chain for the child. */ - child = item->child; - while (child != NULL) - { - newchild = cJSON_Duplicate(child, true); /* Duplicate (with recurse) each item in the ->next chain */ - if (!newchild) - { - goto fail; - } - if (next != NULL) - { - /* If newitem->child already set, then crosswire ->prev and ->next and move on */ - next->next = newchild; - newchild->prev = next; - next = newchild; - } - else - { - /* Set newitem->child and move to it */ - newitem->child = newchild; - next = newchild; - } - child = child->next; - } - - return newitem; - -fail: - if (newitem != NULL) - { - cJSON_Delete(newitem); - } - - return NULL; -} - -CJSON_PUBLIC(void) cJSON_Minify(char *json) -{ - unsigned char *into = (unsigned char*)json; - - if (json == NULL) - { - return; - } - - while (*json) - { - if (*json == ' ') - { - json++; - } - else if (*json == '\t') - { - /* Whitespace characters. */ - json++; - } - else if (*json == '\r') - { - json++; - } - else if (*json=='\n') - { - json++; - } - else if ((*json == '/') && (json[1] == '/')) - { - /* double-slash comments, to end of line. */ - while (*json && (*json != '\n')) - { - json++; - } - } - else if ((*json == '/') && (json[1] == '*')) - { - /* multiline comments. */ - while (*json && !((*json == '*') && (json[1] == '/'))) - { - json++; - } - json += 2; - } - else if (*json == '\"') - { - /* string literals, which are \" sensitive. */ - *into++ = (unsigned char)*json++; - while (*json && (*json != '\"')) - { - if (*json == '\\') - { - *into++ = (unsigned char)*json++; - } - *into++ = (unsigned char)*json++; - } - *into++ = (unsigned char)*json++; - } - else - { - /* All other characters. */ - *into++ = (unsigned char)*json++; - } - } - - /* and null-terminate. */ - *into = '\0'; -} - -CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item) -{ - if (item == NULL) - { - return false; - } - - return (item->type & 0xFF) == cJSON_Invalid; -} - -CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item) -{ - if (item == NULL) - { - return false; - } - - return (item->type & 0xFF) == cJSON_False; -} - -CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item) -{ - if (item == NULL) - { - return false; - } - - return (item->type & 0xff) == cJSON_True; -} - - -CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item) -{ - if (item == NULL) - { - return false; - } - - return (item->type & (cJSON_True | cJSON_False)) != 0; -} -CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item) -{ - if (item == NULL) - { - return false; - } - - return (item->type & 0xFF) == cJSON_NULL; -} - -CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item) -{ - if (item == NULL) - { - return false; - } - - return (item->type & 0xFF) == cJSON_Number; -} - -CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item) -{ - if (item == NULL) - { - return false; - } - - return (item->type & 0xFF) == cJSON_String; -} - -CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item) -{ - if (item == NULL) - { - return false; - } - - return (item->type & 0xFF) == cJSON_Array; -} - -CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item) -{ - if (item == NULL) - { - return false; - } - - return (item->type & 0xFF) == cJSON_Object; -} - -CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item) -{ - if (item == NULL) - { - return false; - } - - return (item->type & 0xFF) == cJSON_Raw; -} - -CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive) -{ - if ((a == NULL) || (b == NULL) || ((a->type & 0xFF) != (b->type & 0xFF)) || cJSON_IsInvalid(a)) - { - return false; - } - - /* check if type is valid */ - switch (a->type & 0xFF) - { - case cJSON_False: - case cJSON_True: - case cJSON_NULL: - case cJSON_Number: - case cJSON_String: - case cJSON_Raw: - case cJSON_Array: - case cJSON_Object: - break; - - default: - return false; - } - - /* identical objects are equal */ - if (a == b) - { - return true; - } - - switch (a->type & 0xFF) - { - /* in these cases and equal type is enough */ - case cJSON_False: - case cJSON_True: - case cJSON_NULL: - return true; - - case cJSON_Number: - if (a->valuedouble == b->valuedouble) - { - return true; - } - return false; - - case cJSON_String: - case cJSON_Raw: - if ((a->valuestring == NULL) || (b->valuestring == NULL)) - { - return false; - } - if (strcmp(a->valuestring, b->valuestring) == 0) - { - return true; - } - - return false; - - case cJSON_Array: - { - cJSON *a_element = a->child; - cJSON *b_element = b->child; - - for (; (a_element != NULL) && (b_element != NULL);) - { - if (!cJSON_Compare(a_element, b_element, case_sensitive)) - { - return false; - } - - a_element = a_element->next; - b_element = b_element->next; - } - - /* one of the arrays is longer than the other */ - if (a_element != b_element) { - return false; - } - - return true; - } - - case cJSON_Object: - { - cJSON *a_element = NULL; - cJSON *b_element = NULL; - cJSON_ArrayForEach(a_element, a) - { - /* TODO This has O(n^2) runtime, which is horrible! */ - b_element = get_object_item(b, a_element->string, case_sensitive); - if (b_element == NULL) - { - return false; - } - - if (!cJSON_Compare(a_element, b_element, case_sensitive)) - { - return false; - } - } - - /* doing this twice, once on a and b to prevent true comparison if a subset of b - * TODO: Do this the proper way, this is just a fix for now */ - cJSON_ArrayForEach(b_element, b) - { - a_element = get_object_item(a, b_element->string, case_sensitive); - if (a_element == NULL) - { - return false; - } - - if (!cJSON_Compare(b_element, a_element, case_sensitive)) - { - return false; - } - } - - return true; - } - - default: - return false; - } -} - -CJSON_PUBLIC(void *) cJSON_malloc(size_t size) -{ - return global_hooks.allocate(size); -} - -CJSON_PUBLIC(void) cJSON_free(void *object) -{ - global_hooks.deallocate(object); -} diff --git a/app/bin/cJSON.h b/app/bin/cJSON.h deleted file mode 100755 index 291d694..0000000 --- a/app/bin/cJSON.h +++ /dev/null @@ -1,285 +0,0 @@ -/** - Copyright (c) 2009-2017 Dave Gamble and cJSON contributors - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. -*/ - -#ifndef cJSON__h -#define cJSON__h - -#ifdef __cplusplus -extern "C" -{ -#endif - -#if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32)) -#define __WINDOWS__ -#endif - -#ifdef __WINDOWS__ - -/* When compiling for windows, we specify a specific calling convention to avoid issues where we are being called from a project with a different default calling convention. For windows you have 3 define options: - -CJSON_HIDE_SYMBOLS - Define this in the case where you don't want to ever dllexport symbols -CJSON_EXPORT_SYMBOLS - Define this on library build when you want to dllexport symbols (default) -CJSON_IMPORT_SYMBOLS - Define this if you want to dllimport symbol - -For *nix builds that support visibility attribute, you can define similar behavior by - -setting default visibility to hidden by adding --fvisibility=hidden (for gcc) -or --xldscope=hidden (for sun cc) -to CFLAGS - -then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJSON_EXPORT_SYMBOLS does - -*/ - -#define CJSON_CDECL __cdecl -#define CJSON_STDCALL __stdcall - -/* export symbols by default, this is necessary for copy pasting the C and header file */ -#if !defined(CJSON_HIDE_SYMBOLS) && !defined(CJSON_IMPORT_SYMBOLS) && !defined(CJSON_EXPORT_SYMBOLS) -#define CJSON_EXPORT_SYMBOLS -#endif - -#if defined(CJSON_HIDE_SYMBOLS) -#define CJSON_PUBLIC(type) type CJSON_STDCALL -#elif defined(CJSON_EXPORT_SYMBOLS) -#define CJSON_PUBLIC(type) __declspec(dllexport) type CJSON_STDCALL -#elif defined(CJSON_IMPORT_SYMBOLS) -#define CJSON_PUBLIC(type) __declspec(dllimport) type CJSON_STDCALL -#endif -#else /* !__WINDOWS__ */ -#define CJSON_CDECL -#define CJSON_STDCALL - -#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(CJSON_API_VISIBILITY) -#define CJSON_PUBLIC(type) __attribute__((visibility("default"))) type -#else -#define CJSON_PUBLIC(type) type -#endif -#endif - -/* project version */ -#define CJSON_VERSION_MAJOR 1 -#define CJSON_VERSION_MINOR 7 -#define CJSON_VERSION_PATCH 8 - -#include <stddef.h> - -/* cJSON Types: */ -#define cJSON_Invalid (0) -#define cJSON_False (1 << 0) -#define cJSON_True (1 << 1) -#define cJSON_NULL (1 << 2) -#define cJSON_Number (1 << 3) -#define cJSON_String (1 << 4) -#define cJSON_Array (1 << 5) -#define cJSON_Object (1 << 6) -#define cJSON_Raw (1 << 7) /* raw json */ - -#define cJSON_IsReference 256 -#define cJSON_StringIsConst 512 - -/* The cJSON structure: */ -typedef struct cJSON -{ - /* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */ - struct cJSON *next; - struct cJSON *prev; - /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */ - struct cJSON *child; - - /* The type of the item, as above. */ - int type; - - /* The item's string, if type==cJSON_String and type == cJSON_Raw */ - char *valuestring; - /* writing to valueint is DEPRECATED, use cJSON_SetNumberValue instead */ - int valueint; - /* The item's number, if type==cJSON_Number */ - double valuedouble; - - /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */ - char *string; -} cJSON; - -typedef struct cJSON_Hooks -{ - /* malloc/free are CDECL on Windows regardless of the default calling convention of the compiler, so ensure the hooks allow passing those functions directly. */ - void *(CJSON_CDECL *malloc_fn)(size_t sz); - void (CJSON_CDECL *free_fn)(void *ptr); -} cJSON_Hooks; - -typedef int cJSON_bool; - -/* Limits how deeply nested arrays/objects can be before cJSON rejects to parse them. - * This is to prevent stack overflows. */ -#ifndef CJSON_NESTING_LIMIT -#define CJSON_NESTING_LIMIT 1000 -#endif - -/* returns the version of cJSON as a string */ -CJSON_PUBLIC(const char*) cJSON_Version(void); - -/* Supply malloc, realloc and free functions to cJSON */ -CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks); - -/* Memory Management: the caller is always responsible to free the results from all variants of cJSON_Parse (with cJSON_Delete) and cJSON_Print (with stdlib free, cJSON_Hooks.free_fn, or cJSON_free as appropriate). The exception is cJSON_PrintPreallocated, where the caller has full responsibility of the buffer. */ -/* Supply a block of JSON, and this returns a cJSON object you can interrogate. */ -CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value); -/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */ -/* If you supply a ptr in return_parse_end and parsing fails, then return_parse_end will contain a pointer to the error so will match cJSON_GetErrorPtr(). */ -CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated); - -/* Render a cJSON entity to text for transfer/storage. */ -CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item); -/* Render a cJSON entity to text for transfer/storage without any formatting. */ -CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item); -/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess at the final size. guessing well reduces reallocation. fmt=0 gives unformatted, =1 gives formatted */ -CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt); -/* Render a cJSON entity to text using a buffer already allocated in memory with given length. Returns 1 on success and 0 on failure. */ -/* NOTE: cJSON is not always 100% accurate in estimating how much memory it will use, so to be safe allocate 5 bytes more than you actually need */ -CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format); -/* Delete a cJSON entity and all subentities. */ -CJSON_PUBLIC(void) cJSON_Delete(cJSON *c); - -/* Returns the number of items in an array (or object). */ -CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array); -/* Retrieve item number "index" from array "array". Returns NULL if unsuccessful. */ -CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index); -/* Get item "string" from object. Case insensitive. */ -CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string); -CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string); -CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string); -/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */ -CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void); - -/* Check if the item is a string and return its valuestring */ -CJSON_PUBLIC(char *) cJSON_GetStringValue(cJSON *item); - -/* These functions check the type of an item */ -CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item); -CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item); -CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item); -CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item); -CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item); -CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item); -CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item); -CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item); -CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item); -CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item); - -/* These calls create a cJSON item of the appropriate type. */ -CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void); -CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void); -CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void); -CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean); -CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num); -CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string); -/* raw json */ -CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw); -CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void); -CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void); - -/* Create a string where valuestring references a string so - * it will not be freed by cJSON_Delete */ -CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string); -/* Create an object/arrray that only references it's elements so - * they will not be freed by cJSON_Delete */ -CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child); -CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child); - -/* These utilities create an Array of count items. */ -CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count); -CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count); -CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count); -CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char **strings, int count); - -/* Append item to the specified array/object. */ -CJSON_PUBLIC(void) cJSON_AddItemToArray(cJSON *array, cJSON *item); -CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item); -/* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object. - * WARNING: When this function was used, make sure to always check that (item->type & cJSON_StringIsConst) is zero before - * writing to `item->string` */ -CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item); -/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */ -CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item); -CJSON_PUBLIC(void) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item); - -/* Remove/Detatch items from Arrays/Objects. */ -CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item); -CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which); -CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which); -CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string); -CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string); -CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string); -CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string); - -/* Update array items. */ -CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem); /* Shifts pre-existing items to the right. */ -CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement); -CJSON_PUBLIC(void) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem); -CJSON_PUBLIC(void) cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem); -CJSON_PUBLIC(void) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object,const char *string,cJSON *newitem); - -/* Duplicate a cJSON item */ -CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse); -/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will -need to be released. With recurse!=0, it will duplicate any children connected to the item. -The item->next and ->prev pointers are always zero on return from Duplicate. */ -/* Recursively compare two cJSON items for equality. If either a or b is NULL or invalid, they will be considered unequal. - * case_sensitive determines if object keys are treated case sensitive (1) or case insensitive (0) */ -CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive); - - -CJSON_PUBLIC(void) cJSON_Minify(char *json); - -/* Helper functions for creating and adding items to an object at the same time. - * They return the added item or NULL on failure. */ -CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name); -CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const char * const name); -CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const char * const name); -CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_bool boolean); -CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char * const name, const double number); -CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string); -CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * const name, const char * const raw); -CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char * const name); -CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name); - -/* When assigning an integer value, it needs to be propagated to valuedouble too. */ -#define cJSON_SetIntValue(object, number) ((object) ? (object)->valueint = (object)->valuedouble = (number) : (number)) -/* helper for the cJSON_SetNumberValue macro */ -CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number); -#define cJSON_SetNumberValue(object, number) ((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number)) - -/* Macro for iterating over an array or object */ -#define cJSON_ArrayForEach(element, array) for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next) - -/* malloc/free objects using the malloc/free functions that have been set with cJSON_InitHooks */ -CJSON_PUBLIC(void *) cJSON_malloc(size_t size); -CJSON_PUBLIC(void) cJSON_free(void *object); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/app/bin/cbezier.c b/app/bin/cbezier.c index 22c95ba..1e09e5d 100644 --- a/app/bin/cbezier.c +++ b/app/bin/cbezier.c @@ -1,45 +1,45 @@ /** \file cbezier.c * Bezier Command. Draw or modify a Bezier (Track or Line). */ - /* XTrkCad - Model Railroad CAD - * - * Cubic Bezier curves have a definitional representation as an a set of four points. - * The first and fourth are the end points, while the middle two are control points. - * The control points positions define the angle at the ends and by their relative positions the overall - * curvature. This representation is a familiar approach for those who know drawing programs such as Adobe - * Illustrator or CorelDraw. - * - * In XTrackCAD, the Bezier form is also represented and drawn as a set of - * joined circular arcs that approximate the Bezier form within a small tolerance. This is because - * many of the operations we need to do are either computationally difficult or - * impossible using the Bezier equations. For example, creating a parallel Bezier - * which is necessary to draw a track with two lines or sleepers has no easy, stable solution. - * But the program is already able to do these tasks for straight lines and curves. - * - * Note that every time we change the Bezier points we have to recalculate the arc approximation, - * but that means that the majority of the time we are using the simpler approximation. - * - * We do not allow Bezier curves that have loops or cusps as they make no sense for tracks and - * can easily be approximated for lines with multiple unaligned Bezier curves. - * - * This program borrows from particular ideas about converting Bezier curves that Pomax placed into - * open source. The originals in Javascript can be found at github.com/Pomax. - * The web pages that explain many other techniques are located at https://pomax.github.io/bezierinfo - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ +/* XTrkCad - Model Railroad CAD +* +* Cubic Bezier curves have a definitional representation as an a set of four points. +* The first and fourth are the end points, while the middle two are control points. +* The control points positions define the angle at the ends and by their relative positions the overall +* curvature. This representation is a familiar approach for those who know drawing programs such as Adobe +* Illustrator or CorelDraw. +* +* In XTrackCAD, the Bezier form is also represented and drawn as a set of +* joined circular arcs that approximate the Bezier form within a small tolerance. This is because +* many of the operations we need to do are either computationally difficult or +* impossible using the Bezier equations. For example, creating a parallel Bezier +* which is necessary to draw a track with two lines or sleepers has no easy, stable solution. +* But the program is already able to do these tasks for straight lines and curves. +* +* Note that every time we change the Bezier points we have to recalculate the arc approximation, +* but that means that the majority of the time we are using the simpler approximation. +* +* We do not allow Bezier curves that have loops or cusps as they make no sense for tracks and +* can easily be approximated for lines with multiple unaligned Bezier curves. +* +* This program borrows from particular ideas about converting Bezier curves that Pomax placed into +* open source. The originals in Javascript can be found at github.com/Pomax. +* The web pages that explain many other techniques are located at https://pomax.github.io/bezierinfo +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ #include "common.h" @@ -59,49 +59,47 @@ #include "cundo.h" #include "compound.h" -extern drawCmd_t tempD; /* * STATE INFO */ enum Bezier_States { NONE, - POS_1, - CONTROL_ARM_1, - POS_2, - CONTROL_ARM_2, - PICK_POINT, - POINT_PICKED, - TRACK_SELECTED }; + POS_1, + CONTROL_ARM_1, + POS_2, + CONTROL_ARM_2, + PICK_POINT, + POINT_PICKED, + TRACK_SELECTED + }; typedef struct { - curveData_t curveData; - double start; - double end; - coOrd pos0; - coOrd pos1; - } bCurveData_t; + curveData_t curveData; + double start; + double end; + coOrd pos0; + coOrd pos1; +} bCurveData_t; static struct { - enum Bezier_States state; - coOrd pos[4]; - int selectPoint; - wDrawColor color; - DIST_T width; - track_p trk[2]; - EPINX_T ep[2]; - dynArr_t crvSegs_da; - int crvSegs_da_cnt; - trkSeg_t cp1Segs_da[4]; - int cp1Segs_da_cnt; - trkSeg_t cp2Segs_da[4]; - int cp2Segs_da_cnt; - BOOL_T unlocked; - track_p selectTrack; - BOOL_T track; - DIST_T minRadius; - DIST_T trackGauge; - } Da; + enum Bezier_States state; + coOrd pos[4]; + int selectPoint; + track_p trk[2]; + EPINX_T ep[2]; + dynArr_t crvSegs_da; + int crvSegs_da_cnt; + trkSeg_t cp1Segs_da[4]; + int cp1Segs_da_cnt; + trkSeg_t cp2Segs_da[4]; + int cp2Segs_da_cnt; + BOOL_T unlocked; + track_p selectTrack; + BOOL_T track; + DIST_T minRadius; + DIST_T trackGauge; +} Da; static dynArr_t anchors_da; #define anchors(N) DYNARR_N(trkSeg_t,anchors_da,N) @@ -114,46 +112,47 @@ static dynArr_t anchors_da; * A red color indicates that this arm, end or control point is "active" as it was selected. */ int createControlArm( - trkSeg_t sp[], //seg pointer for up to 3 trkSegs (ends and line) - coOrd pos0, //end on curve - coOrd pos1, // control point at other end of line - BOOL_T track, // isTrack()? (otherwise Line) - BOOL_T selectable, // can this arm be selected? - BOOL_T cp_direction_locked, //isFixed to track - int point_selected, //number of point 0, 1 or -1 - wDrawColor color //drawColorBlack or drawColorWhite - ) + trkSeg_t sp[], //seg pointer for up to 3 trkSegs (ends and line) + coOrd pos0, //end on curve + coOrd pos1, // control point at other end of line + BOOL_T track, // isTrack()? (otherwise Line) + BOOL_T selectable, // can this arm be selected? + BOOL_T cp_direction_locked, //isFixed to track + int point_selected, //number of point 0, 1 or -1 + wDrawColor color //drawColorBlack or drawColorWhite +) { - DIST_T d, w; - d = tempD.scale*0.25; - w = tempD.scale/tempD.dpi; /*double width*/ - sp[0].u.l.pos[0] = pos0; - sp[0].u.l.pos[1] = pos1; - sp[0].type = SEG_STRLIN; - sp[0].width = w; - sp[0].color = (point_selected>=0)?drawColorRed:drawColorBlack; - int n = 0; - if (selectable) { - for (int j=0;j<2;j++) { - if (j==0 && cp_direction_locked) continue; //Don't show select circle if end locked - n++; - sp[n].u.c.center = j==0?pos0:pos1; - sp[n].u.c.radius = d/4; - sp[n].width = w; - sp[n].color = (j==point_selected)?drawColorRed:drawColorBlack; - if (j==point_selected && cp_direction_locked) { - sp[n].type = SEG_FILCRCL; - } else { - sp[n].type = SEG_CRVLIN; - sp[n].u.c.a0 = 0.0; - sp[n].u.c.a1 = 360.0; - } - } - } - return n+1; + DIST_T d, w; + d = tempD.scale*0.25; + w = tempD.scale/tempD.dpi; /*double width*/ + sp[0].u.l.pos[0] = pos0; + sp[0].u.l.pos[1] = pos1; + sp[0].type = SEG_STRLIN; + sp[0].lineWidth = w; + sp[0].color = (point_selected>=0)?drawColorRed:drawColorBlack; + int n = 0; + if (selectable) { + for (int j=0; j<2; j++) { + if (j==0 && cp_direction_locked) { continue; } //Don't show select circle if end locked + n++; + sp[n].u.c.center = j==0?pos0:pos1; + sp[n].u.c.radius = d/4; + sp[n].lineWidth = w; + sp[n].color = (j==point_selected)?drawColorRed:drawColorBlack; + if (j==point_selected && cp_direction_locked) { + sp[n].type = SEG_FILCRCL; + } else { + sp[n].type = SEG_CRVLIN; + sp[n].u.c.a0 = 0.0; + sp[n].u.c.a1 = 360.0; + } + } + } + return n+1; } -coOrd getPoint(coOrd pos[4], double s) { +coOrd getPoint(coOrd pos[4], double s) +{ double mt = 1-s; double a = mt*mt*mt; double b = mt*mt*s*3; @@ -172,48 +171,53 @@ coOrd getPoint(coOrd pos[4], double s) { * than 0.5 pixels - that will mean it is not a good fit. * */ -double BezError(coOrd pos[4], coOrd center, coOrd start_point, double start, double end) { +double BezError(coOrd pos[4], coOrd center, coOrd start_point, double start, + double end) +{ double quarter = (end - start) / 4; // take point at 1/4 and 3/4 and check coOrd c1 = getPoint(pos, start + quarter); coOrd c2 = getPoint(pos, end - quarter); double ref = FindDistance(center, start_point); //radius double d1 = FindDistance(center, c1); // distance to quarter double d2 = FindDistance(center, c2); // distance to three quarters - return fabs(d1-ref) + fabs(d2-ref); //total error at quarter points + return fabs(d1-ref) + fabs(d2 + -ref); //total error at quarter points }; /* * Get distance between a point and a line segment */ -double DistanceToLineSegment(coOrd p, coOrd l1, coOrd l2) { +double DistanceToLineSegment(coOrd p, coOrd l1, coOrd l2) +{ double A = p.x - l1.x; - double B = p.y - l1.y; - double C = l2.x - l1.x; - double D = l2.y - l1.y; - - double dot = A * C + B * D; - double len_sq = C * C + D * D; - double param = -1; - if (len_sq != 0) //non 0 length line - param = dot / len_sq; - - double xx, yy; - - if (param < 0) { // zero length line or beyond end use point 1 - xx = l1.x; - yy = l1.y; - } else if (param > 1) { // beyond point 2 end of line segment - xx = l2.x; - yy = l2.y; - } else { // In the middle - xx = l1.x + param * C; - yy = l1.y + param * D; - } - - double dx = p.x - xx; //distance to perpendicular (or end point) - double dy = p.y - yy; - return sqrt(dx * dx + dy * dy); + double B = p.y - l1.y; + double C = l2.x - l1.x; + double D = l2.y - l1.y; + + double dot = A * C + B * D; + double len_sq = C * C + D * D; + double param = -1; + if (len_sq != 0) { //non 0 length line + param = dot / len_sq; + } + + double xx, yy; + + if (param < 0) { // zero length line or beyond end use point 1 + xx = l1.x; + yy = l1.y; + } else if (param > 1) { // beyond point 2 end of line segment + xx = l2.x; + yy = l2.y; + } else { // In the middle + xx = l1.x + param * C; + yy = l1.y + param * D; + } + + double dx = p.x - xx; //distance to perpendicular (or end point) + double dy = p.y - yy; + return sqrt(dx * dx + dy * dy); } /* @@ -221,7 +225,9 @@ double DistanceToLineSegment(coOrd p, coOrd l1, coOrd l2) { * Sum distance to straight line of quarter points. */ -double BezErrorLine(coOrd pos[4], coOrd start_point, coOrd end_point, double start, double end) { +double BezErrorLine(coOrd pos[4], coOrd start_point, coOrd end_point, + double start, double end) +{ double quarter = (end - start) / 4; // take point at 1/4 and 3/4 and check coOrd c1 = getPoint(pos, start + quarter); coOrd c2 = getPoint(pos, end - quarter); @@ -233,7 +239,8 @@ double BezErrorLine(coOrd pos[4], coOrd start_point, coOrd end_point, double sta /* * Add element to DYNARR pointed to by caller from segment handed in */ -void addSegBezier(dynArr_t * array_p, trkSeg_p seg) { +void addSegBezier(dynArr_t * array_p, trkSeg_p seg) +{ trkSeg_p s; @@ -241,23 +248,21 @@ void addSegBezier(dynArr_t * array_p, trkSeg_p seg) { s = &DYNARR_N(trkSeg_t,*array_p,(array_p->cnt)-1); s->type = seg->type; s->color = seg->color; - s->width = seg->width; - s->bezSegs.cnt = 0; - s->bezSegs.ptr=NULL; - s->bezSegs.max = 0; + s->lineWidth = seg->lineWidth; + DYNARR_INIT( trkSeg_t, s->bezSegs ); if ((s->type == SEG_BEZLIN || s->type == SEG_BEZTRK) && seg->bezSegs.cnt) { s->u.b.angle0 = seg->u.b.angle0; //Copy all the rest s->u.b.angle3 = seg->u.b.angle3; s->u.b.length = seg->u.b.length; s->u.b.minRadius = seg->u.b.minRadius; - for (int i=0;i<4;i++) s->u.b.pos[i] = seg->u.b.pos[i]; + for (int i=0; i<4; i++) { s->u.b.pos[i] = seg->u.b.pos[i]; } s->u.b.radius0 = seg->u.b.radius3; - s->bezSegs.cnt = 0; - if (s->bezSegs.ptr) MyFree(s->bezSegs.ptr); - s->bezSegs.max = 0; - s->bezSegs.ptr = NULL; //Make sure new space as addr copied in earlier from seg + // TODO we init'd the DA above, why free it now? + DYNARR_FREE( trkSeg_t, s->bezSegs ); + //Make sure new space as addr copied in earlier from seg for (int i = 0; i<seg->bezSegs.cnt; i++) { - addSegBezier(&s->bezSegs,(((trkSeg_p)seg->bezSegs.ptr)+i)); //recurse for copying embedded Beziers as in Cornu joint + //recurse for copying embedded Beziers as in Cornu joint + addSegBezier(&s->bezSegs, &DYNARR_N( trkSeg_t, seg->bezSegs, i ) ); } } else { s->u = seg->u; @@ -274,7 +279,9 @@ enum BezierType {PLAIN, LOOP, CUSP, INFLECTION, DOUBLEINFLECTION, LINE, ENDS, CO * We will eliminate cusps and loops as not useful forms. Line, Plain, Inflection and DoubleInflection are ok. * */ -EXPORT enum BezierType AnalyseCurve(coOrd inpos[4], double *Rfx, double *Rfy, double *cusp) { +EXPORT enum BezierType AnalyseCurve(coOrd inpos[4], double *Rfx, double *Rfy, + double *cusp) +{ *Rfx = *Rfy = 0; if (Da.track && inpos[0].x == inpos[3].x && inpos[0].y == inpos[3].y ) { @@ -287,14 +294,14 @@ EXPORT enum BezierType AnalyseCurve(coOrd inpos[4], double *Rfx, double *Rfy, do if (d01+d12 == d02) { //straight DIST_T d23 = FindDistance(inpos[2],inpos[3]); DIST_T d03 = FindDistance(inpos[0],inpos[3]); - if (d02+d23 == d03) return LINE; + if (d02+d23 == d03) { return LINE; } } int common_points = 0; - for (int i=0;i<3;i++) { - if (inpos[i].x == inpos[i+1].x && inpos[i].y == inpos[i+1].y) common_points++; + for (int i=0; i<3; i++) { + if (inpos[i].x == inpos[i+1].x && inpos[i].y == inpos[i+1].y) { common_points++; } } - for (int i=0;i<2;i++) { - if (inpos[i].x == inpos[i+2].x && inpos[i].y == inpos[i+2].y) common_points++; + for (int i=0; i<2; i++) { + if (inpos[i].x == inpos[i+2].x && inpos[i].y == inpos[i+2].y) { common_points++; } } if (common_points>2) { @@ -304,7 +311,7 @@ EXPORT enum BezierType AnalyseCurve(coOrd inpos[4], double *Rfx, double *Rfy, do coOrd pos[4]; coOrd offset2, offset = inpos[0]; - for (int i=0;i<4;i++) { //move to zero origin + for (int i=0; i<4; i++) { //move to zero origin pos[i].x = inpos[i].x-offset.x; pos[i].y = inpos[i].y-offset.y; } @@ -312,31 +319,32 @@ EXPORT enum BezierType AnalyseCurve(coOrd inpos[4], double *Rfx, double *Rfy, do offset2.x = -offset.x + pos[3].x; offset2.y = -offset.y + pos[3].y; if (pos[1].y == 0.0) { //flip order of points - for (int i=0;i<4;i++) { + for (int i=0; i<4; i++) { coOrd temp_pos = pos[i]; pos[i].x = pos[3-i].x - offset2.x; pos[i].y = pos[3-i].y - offset2.y; pos[3-i] = temp_pos; } - if (pos[1].y == 0.0) { //Both ways round the second point has no y left after translation + if (pos[1].y == + 0.0) { //Both ways round the second point has no y left after translation return PLAIN; } } double f21 = (pos[2].y)/(pos[1].y); double f31 = (pos[3].y)/(pos[1].y); - if (fabs(pos[2].x-(pos[1].x*f21)) <0.0001) return PLAIN; //defend against divide by zero + if (fabs(pos[2].x-(pos[1].x*f21)) <0.0001) { return PLAIN; } //defend against divide by zero double fx = (pos[3].x-(pos[1].x*f31))/(pos[2].x-(pos[1].x*f21)); double fy = f31+(1-f21)*fx; *Rfx = fx; *Rfy = fy; *cusp = fabs(fy - (-(fx*fx)+2*fx+3)/4); - if (fy > 1.0) return INFLECTION; - if (fx >= 1.0) return PLAIN; - if (fabs(fy - (-(fx*fx)+2*fx+3)/4) <0.100) return CUSP; + if (fy > 1.0) { return INFLECTION; } + if (fx >= 1.0) { return PLAIN; } + if (fabs(fy - (-(fx*fx)+2*fx+3)/4) <0.100) { return CUSP; } if (fy < (-(fx*fx)+2*fx+3)/4) { - if (fx <= 0.0 && fy >= (3*fx-(fx*fx))/3) return LOOP; - if (fx > 0.0 && fy >= (sqrt(3*(4*fx-fx*fx))-fx)/2) return LOOP; + if (fx <= 0.0 && fy >= (3*fx-(fx*fx))/3) { return LOOP; } + if (fx > 0.0 && fy >= (sqrt(3*(4*fx-fx*fx))-fx)/2) { return LOOP; } return PLAIN; } @@ -352,130 +360,138 @@ EXPORT enum BezierType AnalyseCurve(coOrd inpos[4], double *Rfx, double *Rfy, do * to perform actions on the Bezier and also to export it to DXF. * */ -EXPORT BOOL_T ConvertToArcs (coOrd pos[4], dynArr_t * segs, BOOL_T track, wDrawColor color, DIST_T width) { - double t_s = 0.0, t_e = 1.0; - double errorThreshold = 0.05; - bCurveData_t prev_arc; - prev_arc.end = 0.0; - bCurveData_t arc; - segs->cnt = 0; //wipe out - BOOL_T safety; - int col = 0; - - double prev_e = 0.0; - // we do a binary search to find the "good `t` closest to no-longer-good" - do { - safety=FALSE; - // step 1: start with the maximum possible arc length - t_e = 1.0; - // points: - coOrd start_point, mid_point, end_point; - // booleans: - BOOL_T curr_good = FALSE, prev_good = FALSE, done = FALSE; - // numbers: - double t_m, step = 0; - // step 2: find the best possible arc - do { // !done - prev_good = curr_good; //remember last time - t_m = (t_s + t_e)/2; - step++; - start_point = getPoint(pos, t_s); //Start of arc - mid_point = getPoint(pos, t_m); //Middle of trial arc - end_point = getPoint(pos, t_e); //End of trial Arc - - PlotCurve( crvCmdFromChord, start_point, end_point, mid_point, - &(arc.curveData), FALSE, 0.0 ); //Find Arc through three points - - arc.start = t_s; //remember start - arc.end = t_e; //remember end - arc.pos0 = start_point; //remember start point (used for Straight) - arc.pos1 = end_point; // Remember end point (used for Straight) - - if (arc.curveData.type == curveTypeStraight) { - double error = BezErrorLine(pos,start_point,end_point, t_s, t_e); - curr_good = (error <= errorThreshold/4); - //arc.curveData.a0 = FindAngle(start_point,end_point); - //arc.curveData.a1 = FindAngle(end_point,start_point); - - } else if (arc.curveData.type == curveTypeNone) { - return FALSE; //Something wrong - } else { - double error = BezError(pos, arc.curveData.curvePos, start_point, t_s, t_e); - curr_good = (error <= errorThreshold/4); - }; - - done = prev_good && !curr_good; //Was better than this last time? - if(!done) { - // this arc is fine: we can move 'e' up to see if we can find a wider arc - if(curr_good) { - prev_e = t_e; //remember good end only - prev_arc = arc; - // if e is already at max, then we're done for this arc. - if (t_e >= 1.0) { - // make sure we cap at t=1 - arc.end = prev_e = 1.0; - // if we capped the arc segment to t=1 we also need to make sure that - // the arc's end angle is correct with respect to the bezier end point. - if (t_e > 1.0) { - if (arc.curveData.type != curveTypeStraight) { - coOrd d; - d.x = arc.curveData.curvePos.x + fabs(arc.curveData.curveRadius) * cos(D2R(arc.curveData.a1)); - d.y = arc.curveData.curvePos.y + fabs(arc.curveData.curveRadius) * sin(D2R(arc.curveData.a1)); - - arc.curveData.a1 += FindAngle(d, getPoint(pos,1.0)); - t_e = 1.0; - } - } - prev_arc = arc; - done = TRUE; - break; - } - // if not, move it up by half the iteration distance or to end - t_e = t_e + (t_e-t_s)/2; - if (t_e > 1.0) t_e = 1.0; - } - // this is a bad arc: we need to move 'e' down to find a good arc - else { - t_e = t_m; - } - } // If !Done end - } while(!done && safety++<100); - if(safety>=100) { - return FALSE; //Failed to make into arcs - } - prev_arc = prev_arc.end==0.0?arc:prev_arc; - trkSeg_t curveSeg; //Now set up tempSeg to copy into array - curveSeg.width = track?0:width; - if ( prev_arc.curveData.type == curveTypeCurve ) { - if (track) - curveSeg.color = (fabs(prev_arc.curveData.curveRadius)<(GetLayoutMinTrackRadius()-EPSILON))?exceptionColor:normalColor; - else - curveSeg.color = color; - curveSeg.type = track?SEG_CRVTRK:SEG_CRVLIN; - curveSeg.u.c.a0 = prev_arc.curveData.a0; - curveSeg.u.c.a1 = prev_arc.curveData.a1; - curveSeg.u.c.center = prev_arc.curveData.curvePos; - if (prev_arc.curveData.negative) - curveSeg.u.c.radius = -prev_arc.curveData.curveRadius; - else - curveSeg.u.c.radius = prev_arc.curveData.curveRadius; - } else { //Straight Line because all points co-linear - curveSeg.type = track?SEG_STRTRK:SEG_STRLIN; - if (track) - curveSeg.color = wDrawColorBlack; - else - curveSeg.color = color; - curveSeg.u.l.angle = FindAngle(prev_arc.pos0,prev_arc.pos1); - curveSeg.u.l.pos[0] = prev_arc.pos0; - curveSeg.u.l.pos[1] = prev_arc.pos1; - curveSeg.u.l.option = 0; - } - addSegBezier(segs, &curveSeg); //Add to array of segs used - t_s = prev_e; - col++; - } while(prev_e < 1.0); - - return TRUE; +EXPORT BOOL_T ConvertToArcs (coOrd pos[4], dynArr_t * segs, BOOL_T track, + wDrawColor color, LWIDTH_T lineWidth) +{ + double t_s = 0.0, t_e = 1.0; + double errorThreshold = 0.05; + bCurveData_t prev_arc; + prev_arc.end = 0.0; + bCurveData_t arc; + DYNARR_RESET( trkSeg_t, *segs ); // wipe out + BOOL_T safety; + int col = 0; + + double prev_e = 0.0; + // we do a binary search to find the "good `t` closest to no-longer-good" + do { + safety=FALSE; + // step 1: start with the maximum possible arc length + t_e = 1.0; + // points: + coOrd start_point, mid_point, end_point; + // booleans: + BOOL_T curr_good = FALSE, prev_good = FALSE, done = FALSE; + // numbers: + double t_m, step = 0; + // step 2: find the best possible arc + do { // !done + prev_good = curr_good; //remember last time + t_m = (t_s + t_e)/2; + step++; + start_point = getPoint(pos, t_s); //Start of arc + mid_point = getPoint(pos, t_m); //Middle of trial arc + end_point = getPoint(pos, t_e); //End of trial Arc + + PlotCurve( crvCmdFromChord, start_point, end_point, mid_point, + &(arc.curveData), FALSE, 0.0 ); //Find Arc through three points + + arc.start = t_s; //remember start + arc.end = t_e; //remember end + arc.pos0 = start_point; //remember start point (used for Straight) + arc.pos1 = end_point; // Remember end point (used for Straight) + + if (arc.curveData.type == curveTypeStraight) { + double error = BezErrorLine(pos,start_point,end_point, t_s, t_e); + curr_good = (error <= errorThreshold/4); + //arc.curveData.a0 = FindAngle(start_point,end_point); + //arc.curveData.a1 = FindAngle(end_point,start_point); + + } else if (arc.curveData.type == curveTypeNone) { + return FALSE; //Something wrong + } else { + double error = BezError(pos, arc.curveData.curvePos, start_point, t_s, t_e); + curr_good = (error <= errorThreshold/4); + }; + + done = prev_good && !curr_good; //Was better than this last time? + if(!done) { + // this arc is fine: we can move 'e' up to see if we can find a wider arc + if(curr_good) { + prev_e = t_e; //remember good end only + prev_arc = arc; + // if e is already at max, then we're done for this arc. + if (t_e >= 1.0) { + // make sure we cap at t=1 + arc.end = prev_e = 1.0; + // if we capped the arc segment to t=1 we also need to make sure that + // the arc's end angle is correct with respect to the bezier end point. + if (t_e > 1.0) { + if (arc.curveData.type != curveTypeStraight) { + coOrd d; + d.x = arc.curveData.curvePos.x + fabs(arc.curveData.curveRadius) * cos(D2R( + arc.curveData.a1)); + d.y = arc.curveData.curvePos.y + fabs(arc.curveData.curveRadius) * sin(D2R( + arc.curveData.a1)); + + arc.curveData.a1 += FindAngle(d, getPoint(pos,1.0)); + t_e = 1.0; + } + } + prev_arc = arc; + done = TRUE; + break; + } + // if not, move it up by half the iteration distance or to end + t_e = t_e + (t_e-t_s)/2; + if (t_e > 1.0) { t_e = 1.0; } + } + // this is a bad arc: we need to move 'e' down to find a good arc + else { + t_e = t_m; + } + } // If !Done end + } while(!done && safety++<100); + if(safety>=100) { + return FALSE; //Failed to make into arcs + } + prev_arc = prev_arc.end==0.0?arc:prev_arc; + trkSeg_t curveSeg; //Now set up tempSeg to copy into array + curveSeg.lineWidth = track?0:lineWidth; + if ( prev_arc.curveData.type == curveTypeCurve ) { + if (track) { + curveSeg.color = (fabs(prev_arc.curveData.curveRadius)< + (GetLayoutMinTrackRadius()-EPSILON))?exceptionColor:normalColor; + } else { + curveSeg.color = color; + } + curveSeg.type = track?SEG_CRVTRK:SEG_CRVLIN; + curveSeg.u.c.a0 = prev_arc.curveData.a0; + curveSeg.u.c.a1 = prev_arc.curveData.a1; + curveSeg.u.c.center = prev_arc.curveData.curvePos; + if (prev_arc.curveData.negative) { + curveSeg.u.c.radius = -prev_arc.curveData.curveRadius; + } else { + curveSeg.u.c.radius = prev_arc.curveData.curveRadius; + } + } else { //Straight Line because all points co-linear + curveSeg.type = track?SEG_STRTRK:SEG_STRLIN; + if (track) { + curveSeg.color = wDrawColorBlack; + } else { + curveSeg.color = color; + } + curveSeg.u.l.angle = FindAngle(prev_arc.pos0,prev_arc.pos1); + curveSeg.u.l.pos[0] = prev_arc.pos0; + curveSeg.u.l.pos[1] = prev_arc.pos1; + curveSeg.u.l.option = 0; + } + addSegBezier(segs, &curveSeg); //Add to array of segs used + t_s = prev_e; + col++; + } while(prev_e < 1.0); + + return TRUE; }; /* * Draw Bezier while editing it. It consists of three elements - the curve and one or two control arms. @@ -483,19 +499,25 @@ EXPORT BOOL_T ConvertToArcs (coOrd pos[4], dynArr_t * segs, BOOL_T track, wDrawC */ static void DrawBezCurve(trkSeg_p control_arm1, - int cp1Segs_cnt, - trkSeg_p control_arm2, - int cp2Segs_cnt, - trkSeg_p curveSegs, - int crvSegs_cnt, - wDrawColor color - ) { - if (crvSegs_cnt && curveSegs) + int cp1Segs_cnt, + trkSeg_p control_arm2, + int cp2Segs_cnt, + trkSeg_p curveSegs, + int crvSegs_cnt, + wDrawColor color + ) +{ + if (crvSegs_cnt && curveSegs) { DrawSegs( &tempD, zero, 0.0, curveSegs, crvSegs_cnt, Da.trackGauge, color ); - if (cp1Segs_cnt && control_arm1) - DrawSegs( &tempD, zero, 0.0, control_arm1, cp1Segs_cnt, Da.trackGauge, drawColorBlack ); - if (cp2Segs_cnt && control_arm2) - DrawSegs( &tempD, zero, 0.0, control_arm2, cp2Segs_cnt, Da.trackGauge, drawColorBlack ); + } + if (cp1Segs_cnt && control_arm1) { + DrawSegs( &tempD, zero, 0.0, control_arm1, cp1Segs_cnt, Da.trackGauge, + drawColorBlack ); + } + if (cp2Segs_cnt && control_arm2) { + DrawSegs( &tempD, zero, 0.0, control_arm2, cp2Segs_cnt, Da.trackGauge, + drawColorBlack ); + } } @@ -506,45 +528,55 @@ static void DrawBezCurve(trkSeg_p control_arm1, /* * If Track, make it red if the radius is below minimum */ -void DrawTempBezier(BOOL_T track) { - if (track) DrawBezCurve(Da.cp1Segs_da,Da.cp1Segs_da_cnt,Da.cp2Segs_da,Da.cp2Segs_da_cnt, (trkSeg_t *)Da.crvSegs_da.ptr,Da.crvSegs_da_cnt,fabs(Da.minRadius)<(GetLayoutMinTrackRadius()-EPSILON)?exceptionColor:normalColor); - else - DrawBezCurve(Da.cp1Segs_da,Da.cp1Segs_da_cnt,Da.cp2Segs_da,Da.cp2Segs_da_cnt, (trkSeg_t *)Da.crvSegs_da.ptr,Da.crvSegs_da_cnt,drawColorBlack); //Add Second Arm +void DrawTempBezier(BOOL_T track) +{ + if (track) { + DrawBezCurve(Da.cp1Segs_da,Da.cp1Segs_da_cnt,Da.cp2Segs_da,Da.cp2Segs_da_cnt, + &DYNARR_N(trkSeg_t,Da.crvSegs_da,0),Da.crvSegs_da_cnt, + fabs(Da.minRadius)<(GetLayoutMinTrackRadius()-EPSILON)?exceptionColor: + normalColor); + } else { + DrawBezCurve(Da.cp1Segs_da,Da.cp1Segs_da_cnt,Da.cp2Segs_da,Da.cp2Segs_da_cnt, + &DYNARR_N(trkSeg_t,Da.crvSegs_da,0),Da.crvSegs_da_cnt, + drawColorBlack); //Add Second Arm + } } -void CreateBothControlArms(int selectPoint, BOOL_T track) { +void CreateBothControlArms(int selectPoint, BOOL_T track) +{ if (selectPoint == -1) { Da.cp1Segs_da_cnt = createControlArm(Da.cp1Segs_da, Da.pos[0], - Da.pos[1], track, TRUE, Da.trk[0]!=NULL, -1, - drawColorBlack); + Da.pos[1], track, TRUE, Da.trk[0]!=NULL, -1, + drawColorBlack); Da.cp2Segs_da_cnt = createControlArm(Da.cp2Segs_da, Da.pos[3], - Da.pos[2], track, TRUE, Da.trk[1]!=NULL, -1, - drawColorBlack); + Da.pos[2], track, TRUE, Da.trk[1]!=NULL, -1, + drawColorBlack); } else if (selectPoint == 0 || selectPoint == 1) { Da.cp1Segs_da_cnt = createControlArm(Da.cp1Segs_da, Da.pos[0], - Da.pos[1], track, TRUE, Da.trk[0]!=NULL, selectPoint, - drawColorBlack); + Da.pos[1], track, TRUE, Da.trk[0]!=NULL, selectPoint, + drawColorBlack); Da.cp2Segs_da_cnt = createControlArm(Da.cp2Segs_da, Da.pos[3], - Da.pos[2], track, FALSE, Da.trk[1]!=NULL, -1, - drawColorBlack); + Da.pos[2], track, FALSE, Da.trk[1]!=NULL, -1, + drawColorBlack); } else { Da.cp1Segs_da_cnt = createControlArm(Da.cp1Segs_da, Da.pos[0], - Da.pos[1], track, FALSE, Da.trk[0]!=NULL, -1, - drawColorBlack); + Da.pos[1], track, FALSE, Da.trk[0]!=NULL, -1, + drawColorBlack); Da.cp2Segs_da_cnt = createControlArm(Da.cp2Segs_da, Da.pos[3], - Da.pos[2], track, TRUE, Da.trk[1]!=NULL, - 3-selectPoint, drawColorBlack); + Da.pos[2], track, TRUE, Da.trk[1]!=NULL, + 3-selectPoint, drawColorBlack); } } -void CreateMoveAnchor(coOrd pos,BOOL_T fill) { +void CreateMoveAnchor(coOrd pos,BOOL_T fill) +{ double d = tempD.scale*0.15; DYNARR_APPEND(trkSeg_t,anchors_da,1); int inx = anchors_da.cnt-1; anchors(inx).type = fill?SEG_FILCRCL:SEG_CRVLIN; anchors(inx).u.c.a0 = 0.0; anchors(inx).u.c.a1 = 360.0; - anchors(inx).width = 0; + anchors(inx).lineWidth = 0; anchors(inx).color = wDrawColorBlue; anchors(inx).u.c.radius = d/4; anchors(inx).u.c.center = pos; @@ -566,67 +598,69 @@ void CreateMoveAnchor(coOrd pos,BOOL_T fill) { * */ EXPORT STATUS_T AdjustBezCurve( - wAction_t action, - coOrd pos, - BOOL_T track, - wDrawColor color, - DIST_T width, - bezMessageProc message ) + wAction_t action, + coOrd pos, + BOOL_T track, + wDrawColor color, + LWIDTH_T lineWidth, + bezMessageProc message ) { track_p t; DIST_T d; ANGLE_T angle1, angle2; - static coOrd pos0, pos3, p; + static coOrd pos0, /* pos3,*/ p; enum BezierType b; DIST_T dd; EPINX_T ep; double fx, fy, cusp; - int controlArm = -1; +// int controlArm = -1; - if (Da.state != PICK_POINT && Da.state != POINT_PICKED && Da.state != TRACK_SELECTED) return C_CONTINUE; + if (Da.state != PICK_POINT && Da.state != POINT_PICKED + && Da.state != TRACK_SELECTED) { return C_CONTINUE; } switch ( action & 0xFF) { case C_START: - Da.selectPoint = -1; - CreateBothControlArms(Da.selectPoint, track); - if (ConvertToArcs(Da.pos,&Da.crvSegs_da,track,color,Da.width)) Da.crvSegs_da_cnt = Da.crvSegs_da.cnt; - Da.minRadius = BezierMinRadius(Da.pos,Da.crvSegs_da); - Da.unlocked = FALSE; - if (track) - InfoMessage( _("Select End-Point - Ctrl unlocks end-point") ); - else - InfoMessage( _("Select End-Point") ); - return C_CONTINUE; + Da.selectPoint = -1; + CreateBothControlArms(Da.selectPoint, track); + if (ConvertToArcs(Da.pos,&Da.crvSegs_da,track,color,lineWidth)) { Da.crvSegs_da_cnt = Da.crvSegs_da.cnt; } + Da.minRadius = BezierMinRadius(Da.pos,Da.crvSegs_da); + Da.unlocked = FALSE; + if (track) { + InfoMessage( _("Select End-Point - Ctrl unlocks end-point") ); + } else { + InfoMessage( _("Select End-Point") ); + } + return C_CONTINUE; case wActionMove: DYNARR_RESET(trkSeg_t,anchors_da); - if (Da.state != PICK_POINT) return C_CONTINUE; - if (Da.state != PICK_POINT) return C_CONTINUE; - for (int i=0;i<4;i++) { - if (i==0 && Da.trk[0]) continue; - if (i==3 && Da.trk[1]) continue; //ignore locked points + if (Da.state != PICK_POINT) { return C_CONTINUE; } + if (Da.state != PICK_POINT) { return C_CONTINUE; } + for (int i=0; i<4; i++) { + if (i==0 && Da.trk[0]) { continue; } + if (i==3 && Da.trk[1]) { continue; } //ignore locked points d = FindDistance(Da.pos[i],pos); - if (IsClose(d)) CreateMoveAnchor(Da.pos[i],TRUE); + if (IsClose(d)) { CreateMoveAnchor(Da.pos[i],TRUE); } } break; case C_DOWN: - if (Da.state != PICK_POINT) return C_CONTINUE; + if (Da.state != PICK_POINT) { return C_CONTINUE; } dd = DIST_INF; Da.selectPoint = -1; - for (int i=0;i<4;i++) { + for (int i=0; i<4; i++) { d = FindDistance(Da.pos[i],pos); if (d < dd) { - if (i==0 && Da.trk[0]) continue; - if (i==3 && Da.trk[1]) continue; //ignore locked points + if (i==0 && Da.trk[0]) { continue; } + if (i==3 && Da.trk[1]) { continue; } //ignore locked points dd = d; Da.selectPoint = i; } } - if (!IsClose(dd) ) Da.selectPoint = -1; + if (!IsClose(dd) ) { Da.selectPoint = -1; } DYNARR_RESET(trkSeg_t,anchors_da); if (Da.selectPoint == -1) { InfoMessage( _("Not close enough to any valid, selectable point, reselect") ); @@ -635,10 +669,11 @@ EXPORT STATUS_T AdjustBezCurve( pos = Da.pos[Da.selectPoint]; CreateMoveAnchor(pos,TRUE); Da.state = POINT_PICKED; - InfoMessage( _("Drag point %d to new location and release it"),Da.selectPoint+1 ); + InfoMessage( _("Drag point %d to new location and release it"), + Da.selectPoint+1 ); } CreateBothControlArms(Da.selectPoint, track); - if (ConvertToArcs(Da.pos, &Da.crvSegs_da, track, color,Da.width)) Da.crvSegs_da_cnt = Da.crvSegs_da.cnt; + if (ConvertToArcs(Da.pos, &Da.crvSegs_da, track, color,lineWidth)) { Da.crvSegs_da_cnt = Da.crvSegs_da.cnt; } Da.minRadius = BezierMinRadius(Da.pos, Da.crvSegs_da); return C_CONTINUE; @@ -654,41 +689,47 @@ EXPORT STATUS_T AdjustBezCurve( if (Da.trk[controlArm]) { angle1 = NormalizeAngle(GetTrkEndAngle(Da.trk[controlArm], Da.ep[controlArm])); angle2 = NormalizeAngle(FindAngle(pos, Da.pos[Da.selectPoint==1?0:3])-angle1); - if (angle2 > 90.0 && angle2 < 270.0) - Translate( &pos, Da.pos[Da.selectPoint==1?0:3], angle1, -FindDistance( Da.pos[Da.selectPoint==1?0:3], pos )*cos(D2R(angle2)) ); - else pos = Da.pos[Da.selectPoint==1?0:3]; + if (angle2 > 90.0 && angle2 < 270.0) { + Translate( &pos, Da.pos[Da.selectPoint==1?0:3], angle1, + -FindDistance( Da.pos[Da.selectPoint==1?0:3], pos )*cos(D2R(angle2)) ); + } else { pos = Da.pos[Da.selectPoint==1?0:3]; } } // Dont Snap control points - } else SnapPos(&pos); + } else { SnapPos(&pos); } Da.pos[Da.selectPoint] = pos; CreateMoveAnchor(pos,TRUE); CreateBothControlArms(Da.selectPoint, track); - if (ConvertToArcs(Da.pos,&Da.crvSegs_da,track, color, Da.width)) Da.crvSegs_da_cnt = Da.crvSegs_da.cnt; + if (ConvertToArcs(Da.pos,&Da.crvSegs_da,track, color, lineWidth)) { Da.crvSegs_da_cnt = Da.crvSegs_da.cnt; } Da.minRadius = BezierMinRadius(Da.pos,Da.crvSegs_da); if (Da.track) { b = AnalyseCurve(Da.pos,&fx,&fy,&cusp); if (b==ENDS) { wBeep(); - InfoMessage(_("Bezier Curve Invalid has identical end points Change End Point"),b==CUSP?"Cusp":"Loop"); + InfoMessage(_("Bezier Curve Invalid has identical end points Change End Point"), + b==CUSP?"Cusp":"Loop"); } else if ( b == CUSP || b == LOOP) { wBeep(); - InfoMessage(_("Bezier Curve Invalid has %s Change End Point"),b==CUSP?"Cusp":"Loop"); + InfoMessage(_("Bezier Curve Invalid has %s Change End Point"), + b==CUSP?"Cusp":"Loop"); } else if ( b == COINCIDENT ) { wBeep(); - InfoMessage(_("Bezier Curve Invalid has three co-incident points"),b==CUSP?"Cusp":"Loop"); + InfoMessage(_("Bezier Curve Invalid has three co-incident points"), + b==CUSP?"Cusp":"Loop"); } else if ( b == LINE ) { InfoMessage(_("Bezier is Straight Line")); } else - InfoMessage( _("Bezier %s : Min Radius=%s Length=%s fx=%0.3f fy=%0.3f cusp=%0.3f"),track?"Track":"Line", - FormatDistance(Da.minRadius>=100000?0:Da.minRadius), - FormatDistance(BezierLength(Da.pos,Da.crvSegs_da)),fx,fy,cusp); + InfoMessage( + _("Bezier %s : Min Radius=%s Length=%s fx=%0.3f fy=%0.3f cusp=%0.3f"), + track?"Track":"Line", + FormatDistance(Da.minRadius>=100000?0:Da.minRadius), + FormatDistance(BezierLength(Da.pos,Da.crvSegs_da)),fx,fy,cusp); } else - InfoMessage( _("Bezier %s : Min Radius=%s Length=%s"),track?"Track":"Line", - FormatDistance(Da.minRadius>=100000?0:Da.minRadius), - FormatDistance(BezierLength(Da.pos,Da.crvSegs_da))); + InfoMessage( _("Bezier %s : Min Radius=%s Length=%s"),track?"Track":"Line", + FormatDistance(Da.minRadius>=100000?0:Da.minRadius), + FormatDistance(BezierLength(Da.pos,Da.crvSegs_da))); return C_CONTINUE; case C_UP: - if (Da.state != POINT_PICKED) return C_CONTINUE; + if (Da.state != POINT_PICKED) { return C_CONTINUE; } //Take last pos and decide if it should be snapped to a track because SHIFT is held (pos0 and pos3) ep = 0; BOOL_T found = FALSE; @@ -696,7 +737,8 @@ EXPORT STATUS_T AdjustBezCurve( p = pos; if (track && (Da.selectPoint == 0 || Da.selectPoint == 3)) { //EPs if ((MyGetKeyState() & WKEY_SHIFT) != 0) { //Snap Track - if ((t = OnTrackIgnore(&p, FALSE, TRUE, Da.selectTrack)) != NULL) { //Snap to endPoint + if ((t = OnTrackIgnore(&p, FALSE, TRUE, + Da.selectTrack)) != NULL) { //Snap to endPoint ep = PickUnconnectedEndPointSilent(p, t); if (ep != -1) { Da.trk[Da.selectPoint/3] = t; @@ -712,39 +754,46 @@ EXPORT STATUS_T AdjustBezCurve( } } if (found) { - angle1 = NormalizeAngle(GetTrkEndAngle(Da.trk[Da.selectPoint/3], Da.ep[Da.selectPoint/3])); + angle1 = NormalizeAngle(GetTrkEndAngle(Da.trk[Da.selectPoint/3], + Da.ep[Da.selectPoint/3])); angle2 = NormalizeAngle(FindAngle(pos, pos0)-angle1); - Translate(&Da.pos[Da.selectPoint==0?1:2], Da.pos[Da.selectPoint==0?0:3], angle1, FindDistance(Da.pos[Da.selectPoint==0?1:2],pos)*cos(D2R(angle2))); + Translate(&Da.pos[Da.selectPoint==0?1:2], Da.pos[Da.selectPoint==0?0:3], angle1, + FindDistance(Da.pos[Da.selectPoint==0?1:2],pos)*cos(D2R(angle2))); } Da.selectPoint = -1; CreateBothControlArms(Da.selectPoint,track); - if (ConvertToArcs(Da.pos,&Da.crvSegs_da,track,color,Da.width)) Da.crvSegs_da_cnt = Da.crvSegs_da.cnt; + if (ConvertToArcs(Da.pos,&Da.crvSegs_da,track,color,lineWidth)) { Da.crvSegs_da_cnt = Da.crvSegs_da.cnt; } Da.minRadius = BezierMinRadius(Da.pos,Da.crvSegs_da); if (Da.track) { b = AnalyseCurve(Da.pos,&fx,&fy,&cusp); if (b==ENDS) { wBeep(); - InfoMessage(_("Bezier curve invalid has identical end points Change End Point"),b==CUSP?"Cusp":"Loop"); + InfoMessage(_("Bezier curve invalid has identical end points Change End Point"), + b==CUSP?"Cusp":"Loop"); } else if ( b == CUSP || b == LOOP) { wBeep(); - InfoMessage(_("Bezier curve invalid has %s Change End Point"),b==CUSP?"Cusp":"Loop"); + InfoMessage(_("Bezier curve invalid has %s Change End Point"), + b==CUSP?"Cusp":"Loop"); } else if ( b == COINCIDENT ) { wBeep(); - InfoMessage(_("Bezier curve invalid has three co-incident points"),b==CUSP?"Cusp":"Loop"); + InfoMessage(_("Bezier curve invalid has three co-incident points"), + b==CUSP?"Cusp":"Loop"); } else if ( b == LINE) { InfoMessage(_("Bezier curve is straight line")); } - InfoMessage(_("Pick any circle to adjust it - Enter to confirm, ESC to abort")); - } else InfoMessage(_("Pick any circle to adjust it - Enter to confirm, ESC to abort")); + } else { + InfoMessage( + _("Pick any circle to adjust it - Enter to confirm, ESC to abort")); + } Da.state = PICK_POINT; return C_CONTINUE; case C_OK: //C_OK is not called by Modify. if ( Da.state == PICK_POINT ) { - char c = (unsigned char)(action >> 8); +// char c = (unsigned char)(action >> 8); if (Da.track && Da.pos[0].x == Da.pos[3].x && Da.pos[0].y == Da.pos[3].y ) { wBeep(); ErrorMessage(_("Invalid Bezier Track - end points are identical")); @@ -768,17 +817,14 @@ EXPORT STATUS_T AdjustBezCurve( Da.minRadius = BezierMinRadius(Da.pos,Da.crvSegs_da); UndoStart( _("Create Bezier"), "newBezier - CR" ); if (Da.track) { - t = NewBezierTrack( Da.pos, (trkSeg_p)Da.crvSegs_da.ptr, Da.crvSegs_da.cnt); - for (int i=0;i<2;i++) - if (Da.trk[i] != NULL) ConnectAbuttingTracks(t,i,Da.trk[i],Da.ep[i]); - } - else t = NewBezierLine(Da.pos, (trkSeg_p)Da.crvSegs_da.ptr, Da.crvSegs_da.cnt,color,width); + t = NewBezierTrack( Da.pos, &DYNARR_N(trkSeg_t,Da.crvSegs_da,0), + Da.crvSegs_da.cnt); + for (int i=0; i<2; i++) + if (Da.trk[i] != NULL) { ConnectAbuttingTracks(t,i,Da.trk[i],Da.ep[i]); } + } else { t = NewBezierLine(Da.pos, &DYNARR_N(trkSeg_t,Da.crvSegs_da,0), Da.crvSegs_da.cnt,color,lineWidth); } UndoEnd(); - if (Da.crvSegs_da.ptr) MyFree(Da.crvSegs_da.ptr); DYNARR_RESET(trkSeg_t,anchors_da); - Da.crvSegs_da.ptr = NULL; - Da.crvSegs_da.cnt = 0; - Da.crvSegs_da.max = 0; + DYNARR_FREE( trkSeg_t, Da.crvSegs_da ); DrawNewTrack(t); Da.state = NONE; return C_TERMINATE; @@ -787,10 +833,11 @@ EXPORT STATUS_T AdjustBezCurve( return C_CONTINUE; case C_REDRAW: - if (Da.state != NONE) + if (Da.state != NONE) { DrawTempBezier(Da.track); - if (anchors_da.cnt>0) - DrawSegs( &tempD, zero, 0.0, &anchors(0), anchors_da.cnt, trackGauge, wDrawColorBlack ); + } + DrawSegsDA( &tempD, NULL, zero, 0.0, &anchors_da, trackGauge, wDrawColorBlack, + 0 ); return C_CONTINUE; default: @@ -818,14 +865,16 @@ EXPORT STATUS_T AdjustBezCurve( * Note: Available points are shown - if a Bezier track is attached to its neighbor, only the control point on that side is selectable. * Any free end-point can be locked to a unconnected end point using SHIFT during drag. */ -STATUS_T CmdBezModify (track_p trk, wAction_t action, coOrd pos, DIST_T trackG) { +STATUS_T CmdBezModify (track_p trk, wAction_t action, coOrd pos, DIST_T trackG) +{ BOOL_T track = TRUE; - double width = 1.0; - long mode = 0; - long cmd; +// double width = 1.0; +// long mode = 0; +// long cmd; - struct extraDataBezier_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, extraDataBezier_t); - cmd = VP2L(commandContext); + struct extraDataBezier_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, + extraDataBezier_t); +// cmd = VP2L(commandContext); Da.trackGauge = trackG; switch (action&0xFF) { @@ -840,43 +889,51 @@ STATUS_T CmdBezModify (track_p trk, wAction_t action, coOrd pos, DIST_T trackG) if (IsTrack(trk)) { Da.track = TRUE; Da.trk[0] = GetTrkEndTrk( trk, 0 ); - if (Da.trk[0]) Da.ep[0] = GetEndPtConnectedToMe(Da.trk[0],trk); + if (Da.trk[0]) { Da.ep[0] = GetEndPtConnectedToMe(Da.trk[0],trk); } Da.trk[1] = GetTrkEndTrk( trk, 1 ); - if (Da.trk[1]) Da.ep[1] = GetEndPtConnectedToMe(Da.trk[1],trk); - } - else Da.track = FALSE; + if (Da.trk[1]) { Da.ep[1] = GetEndPtConnectedToMe(Da.trk[1],trk); } + } else { Da.track = FALSE; } Da.selectTrack = trk; - for (int i=0;i<4;i++) Da.pos[i] = xx->pos[i]; //Copy parms from old trk + for (int i=0; i<4; i++) { Da.pos[i] = xx->pos[i]; } //Copy parms from old trk InfoMessage(_("%s picked - now select a Point"),track?"Track":"Line"); Da.state = TRACK_SELECTED; - DrawTrack(Da.selectTrack,&mainD,wDrawColorWhite); //Wipe out real track, draw replacement - return AdjustBezCurve(C_START, pos, Da.track, xx->segsColor, xx->segsWidth, InfoMessage); + DrawTrack(Da.selectTrack,&mainD, + wDrawColorWhite); //Wipe out real track, draw replacement + return AdjustBezCurve(C_START, pos, Da.track, xx->segsColor, xx->segsLineWidth, + InfoMessage); case wActionMove: - if (Da.state == NONE) return C_CONTINUE; - return AdjustBezCurve(wActionMove, pos, Da.track, xx->segsColor, xx->segsWidth, InfoMessage); + if (Da.state == NONE) { return C_CONTINUE; } + return AdjustBezCurve(wActionMove, pos, Da.track, xx->segsColor, + xx->segsLineWidth, + InfoMessage); case C_DOWN: - if (Da.state == TRACK_SELECTED) return C_CONTINUE; //Ignore until first up + if (Da.state == TRACK_SELECTED) { return C_CONTINUE; } //Ignore until first up UndrawNewTrack( Da.selectTrack ); - return AdjustBezCurve(C_DOWN, pos, Da.track, xx->segsColor, xx->segsWidth, InfoMessage); + return AdjustBezCurve(C_DOWN, pos, Da.track, xx->segsColor, xx->segsLineWidth, + InfoMessage); case C_MOVE: - if (Da.state == TRACK_SELECTED) return C_CONTINUE; //Ignore until first up and down - return AdjustBezCurve(C_MOVE, pos, Da.track, xx->segsColor, xx->segsWidth, InfoMessage); + if (Da.state == TRACK_SELECTED) { return C_CONTINUE; } //Ignore until first up and down + return AdjustBezCurve(C_MOVE, pos, Da.track, xx->segsColor, xx->segsLineWidth, + InfoMessage); case C_UP: if (Da.state == TRACK_SELECTED) { - Da.state = PICK_POINT; //First time up, next time pick a point + Da.state = + PICK_POINT; //First time up, next time pick a point } - return AdjustBezCurve(C_UP, pos, Da.track, xx->segsColor, xx->segsWidth, InfoMessage); //Run Adjust + return AdjustBezCurve(C_UP, pos, Da.track, xx->segsColor, xx->segsLineWidth, + InfoMessage); //Run Adjust case C_TEXT: - if ((action>>8) != 32) + if ((action>>8) != 32) { return C_CONTINUE; - /* no break */ + } + /* no break */ case C_OK: if (Da.state != PICK_POINT) { //Too early - abandon InfoMessage(_("No changes made")); @@ -887,13 +944,13 @@ STATUS_T CmdBezModify (track_p trk, wAction_t action, coOrd pos, DIST_T trackG) UndoModify( trk ); Da.state = NONE; - wDrawColor color = wDrawColorBlack; - DIST_T width = 0; - if ( !Da.track ) { - color = xx->segsColor; - width = xx->segsWidth; - } - SetBezierData( trk, Da.pos, xx->segsColor, xx->segsWidth ); +// wDrawColor color = wDrawColorBlack; +// LWIDTH_T lineWidth = 0; +// if ( !Da.track ) { +// color = xx->segsColor; +// lineWidth = xx->segsLineWidth; +// } + SetBezierData( trk, Da.pos, xx->segsColor, xx->segsLineWidth ); DrawNewTrack( trk ); UndoEnd(); @@ -906,7 +963,8 @@ STATUS_T CmdBezModify (track_p trk, wAction_t action, coOrd pos, DIST_T trackG) return C_TERMINATE; case C_REDRAW: - return AdjustBezCurve(C_REDRAW, pos, Da.track, xx->segsColor, xx->segsWidth, InfoMessage); + return AdjustBezCurve(C_REDRAW, pos, Da.track, xx->segsColor, xx->segsLineWidth, + InfoMessage); } return C_CONTINUE; @@ -916,11 +974,12 @@ STATUS_T CmdBezModify (track_p trk, wAction_t action, coOrd pos, DIST_T trackG) /* * Find length by adding up the underlying segments. The segments can be straights, curves or bezier. */ -DIST_T BezierLength(coOrd pos[4],dynArr_t segs) { +DIST_T BezierLength(coOrd pos[4],dynArr_t segs) +{ DIST_T dd = 0.0; - if (segs.cnt == 0 ) return dd; - for (int i = 0;i<segs.cnt;i++) { + if (segs.cnt == 0 ) { return dd; } + for (int i = 0; i<segs.cnt; i++) { trkSeg_t t = DYNARR_N(trkSeg_t, segs, i); if (t.type == SEG_CRVTRK || t.type == SEG_CRVLIN) { dd += fabs(t.u.c.radius*D2R(t.u.c.a1)); @@ -933,10 +992,11 @@ DIST_T BezierLength(coOrd pos[4],dynArr_t segs) { return dd; } -DIST_T BezierOffsetLength(dynArr_t segs, double offset) { +DIST_T BezierOffsetLength(dynArr_t segs, double offset) +{ DIST_T dd = 0.0; - if (segs.cnt == 0 ) return dd; - for (int i = 0;i<segs.cnt;i++) { + if (segs.cnt == 0 ) { return dd; } + for (int i = 0; i<segs.cnt; i++) { trkSeg_t t = DYNARR_N(trkSeg_t, segs, i); if (t.type == SEG_CRVTRK || t.type == SEG_CRVLIN) { dd += fabs((t.u.c.radius+(t.u.c.radius>0?offset:-offset))*D2R(t.u.c.a1)); @@ -950,22 +1010,24 @@ DIST_T BezierOffsetLength(dynArr_t segs, double offset) { } -DIST_T BezierMinRadius(coOrd pos[4],dynArr_t segs) { +DIST_T BezierMinRadius(coOrd pos[4],dynArr_t segs) +{ DIST_T r = DIST_INF, rr; - if (segs.cnt == 0 ) return r; - for (int i = 0;i<segs.cnt;i++) { + if (segs.cnt == 0 ) { return r; } + for (int i = 0; i<segs.cnt; i++) { trkSeg_t t = DYNARR_N(trkSeg_t, segs, i); if (t.type == SEG_CRVTRK || t.type == SEG_CRVLIN) { rr = fabs(t.u.c.radius); } else if (t.type == SEG_BEZLIN || t.type == SEG_BEZTRK) { rr = BezierMinRadius(t.u.b.pos, t.bezSegs); - } else rr = DIST_INF; - if (rr<r) r = rr; + } else { rr = DIST_INF; } + if (rr<r) { r = rr; } } return r; } -static void CreateEndAnchor(coOrd p, wBool_t lock) { +static void CreateEndAnchor(coOrd p, wBool_t lock) +{ DIST_T d = tempD.scale*0.15; DYNARR_APPEND(trkSeg_t,anchors_da,1); @@ -976,7 +1038,7 @@ static void CreateEndAnchor(coOrd p, wBool_t lock) { anchors(i).u.c.radius = d/2; anchors(i).u.c.a0 = 0.0; anchors(i).u.c.a1 = 360.0; - anchors(i).width = 0; + anchors(i).lineWidth = 0; } /* @@ -992,17 +1054,15 @@ static void CreateEndAnchor(coOrd p, wBool_t lock) { STATUS_T CmdBezCurve( wAction_t action, coOrd pos ) { track_p t; - static int segCnt; +// static int segCnt; static BOOL_T lock; static coOrd movePos; - STATUS_T rc = C_CONTINUE; - long curveMode = 0; +// STATUS_T rc = C_CONTINUE; +// long curveMode = 0; long cmd; if (action>>8) { cmd = action>>8; - } else cmd = VP2L(commandContext); - - Da.width = (double)lineWidth/mainD.dpi; + } else { cmd = VP2L(commandContext); } Da.trackGauge = trackGauge; @@ -1011,14 +1071,13 @@ STATUS_T CmdBezCurve( wAction_t action, coOrd pos ) case C_START: Da.track = (cmd == bezCmdModifyTrack || cmd == bezCmdCreateTrack)?TRUE:FALSE; - if (Da.track ) - Da.color = wDrawColorBlack; - else - Da.color = lineColor; + if (Da.track ) { + lineColor = wDrawColorBlack; + } Da.state = POS_1; Da. selectPoint = -1; - for (int i=0;i<4;i++) { + for (int i=0; i<4; i++) { Da.pos[i] = zero; } Da.trk[0] = Da.trk[1] = NULL; @@ -1027,7 +1086,8 @@ STATUS_T CmdBezCurve( wAction_t action, coOrd pos ) DYNARR_RESET(trkSeg_t,Da.crvSegs_da); Da.cp1Segs_da_cnt = 0; Da.cp2Segs_da_cnt = 0; - InfoMessage( _("Place 1st endpoint of Bezier - snap to %s"), Da.track?"unconnected Track":"line" ); + InfoMessage( _("Place 1st endpoint of Bezier - snap to %s"), + Da.track?"unconnected Track":"line" ); return C_CONTINUE; @@ -1035,7 +1095,7 @@ STATUS_T CmdBezCurve( wAction_t action, coOrd pos ) DYNARR_RESET(trkSeg_t,anchors_da); if ( Da.state == POS_1 || Da.state == POS_2) { //Set the first or third point coOrd p = pos; - BOOL_T found = FALSE; +// BOOL_T found = FALSE; int end = Da.state==POS_1?0:1; EPINX_T ep; if (Da.track) { @@ -1053,14 +1113,15 @@ STATUS_T CmdBezCurve( wAction_t action, coOrd pos ) Da.trk[end] = t; Da.ep[end] = ep; pos = GetTrkEndPos(t, ep); - found = TRUE; +// found = TRUE; } } } } } else { //Snap Bez Line to Lines - if (lock) + if (lock) { pos = movePos; + } } if (Da.state == POS_1) { Da.pos[0] = pos; @@ -1068,27 +1129,31 @@ STATUS_T CmdBezCurve( wAction_t action, coOrd pos ) Da.state = CONTROL_ARM_1; //Draw the first control arm Da.selectPoint = 1; InfoMessage( _("Drag end of first control arm") ); - Da.cp1Segs_da_cnt = createControlArm(Da.cp1Segs_da, Da.pos[0], Da.pos[1], Da.track,TRUE,Da.trk[1]!=NULL,1,wDrawColorBlack); - } else { + Da.cp1Segs_da_cnt = createControlArm(Da.cp1Segs_da, Da.pos[0], Da.pos[1], + Da.track,TRUE,Da.trk[1]!=NULL,1,wDrawColorBlack); + } else { Da.pos[3] = pos; //2nd End Point Da.pos[2] = pos; //2nd Ctl Point Da.state = POINT_PICKED; // Drag out the second control arm Da.selectPoint = 2; InfoMessage( _("Drag end of second control arm") ); - Da.cp1Segs_da_cnt = createControlArm(Da.cp1Segs_da, Da.pos[0], Da.pos[1], Da.track,FALSE,Da.trk[0]!=NULL,-1,wDrawColorBlack); - Da.cp2Segs_da_cnt = createControlArm(Da.cp2Segs_da, Da.pos[3], Da.pos[2], Da.track,TRUE,Da.trk[1]!=NULL,1,wDrawColorBlack); - if (ConvertToArcs(Da.pos,&Da.crvSegs_da,Da.track,Da.color,Da.width)) Da.crvSegs_da_cnt = Da.crvSegs_da.cnt; + Da.cp1Segs_da_cnt = createControlArm(Da.cp1Segs_da, Da.pos[0], Da.pos[1], + Da.track,FALSE,Da.trk[0]!=NULL,-1,wDrawColorBlack); + Da.cp2Segs_da_cnt = createControlArm(Da.cp2Segs_da, Da.pos[3], Da.pos[2], + Da.track,TRUE,Da.trk[1]!=NULL,1,wDrawColorBlack); + if (ConvertToArcs(Da.pos,&Da.crvSegs_da,Da.track,lineColor,lineWidth)) { Da.crvSegs_da_cnt = Da.crvSegs_da.cnt; } } return C_CONTINUE; } else { - return AdjustBezCurve( action&0xFF, pos, Da.track, Da.color, Da.width, InfoMessage ); + return AdjustBezCurve( action&0xFF, pos, Da.track, lineColor, lineWidth, + InfoMessage ); } return C_CONTINUE; case wActionMove: DYNARR_RESET(trkSeg_t,anchors_da); lock = FALSE; - if ( Da.state != POS_1 && Da.state != POS_2) return C_CONTINUE; //Don't snap CPs + if ( Da.state != POS_1 && Da.state != POS_2) { return C_CONTINUE; } //Don't snap CPs if (Da.track) { if (((MyGetKeyState() & WKEY_ALT) == 0) == magneticSnap) { if ((t = OnTrack(&pos, FALSE, TRUE)) != NULL) { @@ -1117,43 +1182,49 @@ STATUS_T CmdBezCurve( wAction_t action, coOrd pos ) lock = TRUE; movePos = pos; } - if (anchors_da.cnt) return C_CONTINUE; - /* no break */ + if (anchors_da.cnt) { return C_CONTINUE; } + /* no break */ case C_MOVE: if (Da.state == POS_1) { - InfoMessage( _("Place 1st endpoint of Bezier - snap to %s"), Da.track?"unconnected track":"line" ); + InfoMessage( _("Place 1st endpoint of Bezier - snap to %s"), + Da.track?"unconnected track":"line" ); return C_CONTINUE; } if (Da.state == POS_2) { - InfoMessage( _("Select other end of Bezier - snap to %s end"), Da.track?"unconnected track":"line" ); + InfoMessage( _("Select other end of Bezier - snap to %s end"), + Da.track?"unconnected track":"line" ); } if (Da.state == CONTROL_ARM_1 ) { if (Da.trk[0]) { - EPINX_T ep = 0; +// EPINX_T ep = 0; ANGLE_T angle1,angle2; angle1 = NormalizeAngle(GetTrkEndAngle(Da.trk[0],Da.ep[0])); angle2 = NormalizeAngle(FindAngle(pos, Da.pos[0])-angle1); - if (angle2 > 90.0 && angle2 < 270.0) - Translate( &pos, Da.pos[0], angle1, -FindDistance( Da.pos[0], pos )*cos(D2R(angle2))); - else pos = Da.pos[0]; + if (angle2 > 90.0 && angle2 < 270.0) { + Translate( &pos, Da.pos[0], angle1, -FindDistance( Da.pos[0], + pos )*cos(D2R(angle2))); + } else { pos = Da.pos[0]; } } // Don't Snap control points Da.pos[1] = pos; - Da.cp1Segs_da_cnt = createControlArm(Da.cp1Segs_da, Da.pos[0], Da.pos[1], Da.track, TRUE, Da.trk[0]!=NULL, 1, wDrawColorBlack); + Da.cp1Segs_da_cnt = createControlArm(Da.cp1Segs_da, Da.pos[0], Da.pos[1], + Da.track, TRUE, Da.trk[0]!=NULL, 1, wDrawColorBlack); } else { - return AdjustBezCurve( action&0xFF, pos, Da.track, Da.color, Da.width, InfoMessage ); + return AdjustBezCurve( action&0xFF, pos, Da.track, lineColor, lineWidth, + InfoMessage ); } return C_CONTINUE; case C_UP: if (Da.state == CONTROL_ARM_1) { if (Da.trk[0]) { - EPINX_T ep = Da.ep[0]; +// EPINX_T ep = Da.ep[0]; ANGLE_T angle1,angle2; angle1 = NormalizeAngle(GetTrkEndAngle(Da.trk[0],Da.ep[0])); angle2 = NormalizeAngle(FindAngle(pos, Da.pos[0])-angle1); - if (angle2 > 90.0 && angle2 < 270.0) - Translate( &pos, Da.pos[0], angle1, -FindDistance( Da.pos[0], pos )*cos(D2R(angle2))); - else pos = Da.pos[0]; + if (angle2 > 90.0 && angle2 < 270.0) { + Translate( &pos, Da.pos[0], angle1, -FindDistance( Da.pos[0], + pos )*cos(D2R(angle2))); + } else { pos = Da.pos[0]; } } // Don't Snap control points Da.pos[1] = pos; if (FindDistance(Da.pos[0],Da.pos[1]) <=minLength) { @@ -1162,26 +1233,32 @@ STATUS_T CmdBezCurve( wAction_t action, coOrd pos ) return C_CONTINUE; } Da.state = POS_2; - InfoMessage( _("Select other end of Bezier - snap to %s end"), Da.track?"Unconnected Track":"Line" ); - Da.cp1Segs_da_cnt = createControlArm(Da.cp1Segs_da, Da.pos[0], Da.pos[1], Da.track, FALSE, Da.trk[0]!=NULL, -1, wDrawColorBlack); + InfoMessage( _("Select other end of Bezier - snap to %s end"), + Da.track?"Unconnected Track":"Line" ); + Da.cp1Segs_da_cnt = createControlArm(Da.cp1Segs_da, Da.pos[0], Da.pos[1], + Da.track, FALSE, Da.trk[0]!=NULL, -1, wDrawColorBlack); return C_CONTINUE; } else { - return AdjustBezCurve( action&0xFF, pos, Da.track, Da.color, Da.width, InfoMessage ); + return AdjustBezCurve( action&0xFF, pos, Da.track, lineColor, lineWidth, + InfoMessage ); } case C_TEXT: - if (Da.state != PICK_POINT || (action>>8) != ' ') //Space is same as Enter. - return C_CONTINUE; - /* no break */ - case C_OK: - if (Da.state != PICK_POINT) return C_CONTINUE; - return AdjustBezCurve( C_OK, pos, Da.track, Da.color, Da.width, InfoMessage); + if (Da.state != PICK_POINT || (action>>8) != ' ') { //Space is same as Enter. + return C_CONTINUE; + } + /* no break */ + case C_OK: + if (Da.state != PICK_POINT) { return C_CONTINUE; } + return AdjustBezCurve( C_OK, pos, Da.track, lineColor, lineWidth, InfoMessage); case C_REDRAW: if ( Da.state != NONE ) { - DrawBezCurve(Da.cp1Segs_da,Da.cp1Segs_da_cnt,Da.cp2Segs_da,Da.cp2Segs_da_cnt,(trkSeg_t *)Da.crvSegs_da.ptr,Da.crvSegs_da.cnt, Da.color); + DrawBezCurve(Da.cp1Segs_da,Da.cp1Segs_da_cnt,Da.cp2Segs_da,Da.cp2Segs_da_cnt, + &DYNARR_N( trkSeg_t, Da.crvSegs_da, 0 ), + Da.crvSegs_da.cnt, lineColor); } - if (anchors_da.cnt) - DrawSegs( &tempD, zero, 0.0, &anchors(0), anchors_da.cnt, trackGauge, wDrawColorBlack ); + DrawSegsDA( &tempD, NULL, zero, 0.0, &anchors_da, trackGauge, wDrawColorBlack, + 0 ); return C_CONTINUE; case C_CANCEL: @@ -1189,40 +1266,27 @@ STATUS_T CmdBezCurve( wAction_t action, coOrd pos ) Da.cp1Segs_da_cnt = 0; Da.cp2Segs_da_cnt = 0; Da.crvSegs_da_cnt = 0; - for (int i=0;i<2;i++) { + for (int i=0; i<2; i++) { Da.trk[i] = NULL; Da.ep[i] = -1; } - if (Da.crvSegs_da.ptr) MyFree(Da.crvSegs_da.ptr); - Da.crvSegs_da.ptr = NULL; - Da.crvSegs_da.cnt = 0; - Da.crvSegs_da.max = 0; + DYNARR_FREE( trkSeg_t, Da.crvSegs_da ); } Da.state = NONE; return C_CONTINUE; - - default: - - return C_CONTINUE; - } -} + default: -void UpdateParms(wDrawColor color,long width) { - Da.color = lineColor; - Da.width = (double)lineWidth/mainD.dpi; - if (Da.crvSegs_da.cnt) { - ConvertToArcs(Da.pos,&Da.crvSegs_da,Da.track,Da.color,Da.width); + return C_CONTINUE; } - DrawTempBezier(Da.track); } -#include "bitmaps/bezier-track.xpm" -#include "bitmaps/bezier-line.xpm" +//#include "bitmaps/bezier-track.xpm" +//#include "bitmaps/bezier-line.xpm" EXPORT void InitCmdBezier( wMenu_p menu ) -{ +{ } diff --git a/app/bin/cbezier.h b/app/bin/cbezier.h index 74ef51f..2cd72d9 100644 --- a/app/bin/cbezier.h +++ b/app/bin/cbezier.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "common.h" @@ -32,23 +32,21 @@ extern dynArr_t tempEndPts_da; #define bezCmdCreateTrack (3) #define bezCmdCreateLine (4) -extern wDrawColor lineColor; -extern long lineWidth; - typedef void (*bezMessageProc)( const char *, ... ); STATUS_T CmdBezCurve( wAction_t, coOrd); STATUS_T CmdBezModify(track_p, wAction_t, coOrd, DIST_T); -STATUS_T CreateBezier( wAction_t, coOrd, BOOL_T, wDrawColor, DIST_T, long, bezMessageProc ); +STATUS_T CreateBezier( wAction_t, coOrd, BOOL_T, wDrawColor, DIST_T, long, + bezMessageProc ); DIST_T BezierDescriptionDistance( coOrd, track_p, coOrd *, BOOL_T, BOOL_T * ); STATUS_T BezierDescriptionMove( track_p, wAction_t, coOrd ); -BOOL_T ConvertToArcs (coOrd[4], dynArr_t *, BOOL_T, wDrawColor, DIST_T); +BOOL_T ConvertToArcs (coOrd[4], dynArr_t *, BOOL_T, wDrawColor, LWIDTH_T); track_p NewBezierTrack(coOrd[4], trkSeg_p, int); double BezierLength(coOrd[4], dynArr_t); double BezierOffsetLength(dynArr_t,double offset); double BezierMinRadius(coOrd[4],dynArr_t); -void UpdateParms(wDrawColor color,long width); +void UpdateParms(wDrawColor color,LWIDTH_T lineWidth); void addSegBezier(dynArr_t * array_p, trkSeg_p seg); diff --git a/app/bin/cblock.c b/app/bin/cblock.c index 0291b4a..bc23e14 100644 --- a/app/bin/cblock.c +++ b/app/bin/cblock.c @@ -40,7 +40,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * T_BLOCK * $Header: /home/dmarkle/xtrkcad-fork-cvs/xtrkcad/app/bin/cblock.c,v 1.5 2009-11-23 19:46:16 rheller Exp $ @@ -53,7 +53,7 @@ #include "fileio.h" #include "param.h" #include "track.h" -#include "trackx.h" +#include "trkendpt.h" #include "common-ui.h" #ifdef UTFCONVERT @@ -65,19 +65,20 @@ EXPORT TRKTYP_T T_BLOCK = -1; static int log_block = 0; static void NoDrawLine(drawCmd_p d, coOrd p0, coOrd p1, wDrawWidth width, - wDrawColor color ) {} + wDrawColor color ) {} static void NoDrawArc(drawCmd_p d, coOrd p, DIST_T r, ANGLE_T angle0, - ANGLE_T angle1, BOOL_T drawCenter, wDrawWidth width, - wDrawColor color ) {} + ANGLE_T angle1, BOOL_T drawCenter, wDrawWidth width, + wDrawColor color ) {} static void NoDrawString( drawCmd_p d, coOrd p, ANGLE_T a, char * s, - wFont_p fp, FONTSIZE_T fontSize, wDrawColor color ) {} + wFont_p fp, FONTSIZE_T fontSize, wDrawColor color ) {} static void NoDrawBitMap( drawCmd_p d, coOrd p, wDrawBitMap_p bm, - wDrawColor color) {} + wDrawColor color) {} static void NoDrawPoly( drawCmd_p d, int cnt, coOrd * pts, int * types, - wDrawColor color, wDrawWidth width, drawFill_e eFillOpt ) {} + wDrawColor color, wDrawWidth width, drawFill_e eFillOpt ) {} static void NoDrawFillCircle( drawCmd_p d, coOrd p, DIST_T r, - wDrawColor color ) {} -static void NoDrawRectangle( drawCmd_p d, coOrd orig, coOrd size, wDrawColor color, drawFill_e eFill ) {} + wDrawColor color ) {} +static void NoDrawRectangle( drawCmd_p d, coOrd orig, coOrd size, + wDrawColor color, drawFill_e eFill ) {} static drawFuncs_t noDrawFuncs = { NoDrawLine, @@ -86,7 +87,8 @@ static drawFuncs_t noDrawFuncs = { NoDrawBitMap, NoDrawPoly, NoDrawFillCircle, - NoDrawRectangle}; + NoDrawRectangle +}; static drawCmd_t blockD = { NULL, @@ -95,7 +97,8 @@ static drawCmd_t blockD = { 1.0, 0.0, {0.0,0.0}, {0.0,0.0}, - Pix2CoOrd, CoOrd2Pix }; + Pix2CoOrd, CoOrd2Pix +}; static char blockName[STR_SHORT_SIZE]; static char blockScript[STR_LONG_SIZE]; @@ -104,8 +107,8 @@ static track_p first_block; static track_p last_block; static paramData_t blockPLs[] = { -/*0*/ { PD_STRING, blockName, "name", PDO_NOPREF | PDO_NOTBLANK, I2VP(200), N_("Name"), 0, 0, sizeof( blockName )}, -/*1*/ { PD_STRING, blockScript, "script", PDO_NOPREF, I2VP(350), N_("Script"), 0, 0, sizeof( blockScript)} + /*0*/ { PD_STRING, blockName, "name", PDO_NOPREF | PDO_NOTBLANK, I2VP(200), N_("Name"), 0, 0, sizeof( blockName )}, + /*1*/ { PD_STRING, blockScript, "script", PDO_NOPREF, I2VP(350), N_("Script"), 0, 0, sizeof( blockScript)} }; static paramGroup_t blockPG = { "block", 0, blockPLs, COUNT( blockPLs ) }; static wWin_p blockW; @@ -116,16 +119,16 @@ static char blockEditSegs[STR_LONG_SIZE]; static track_p blockEditTrack; static paramData_t blockEditPLs[] = { -/*0*/ { PD_STRING, blockEditName, "name", PDO_NOPREF | PDO_NOTBLANK, I2VP(200), N_("Name"), 0, 0, sizeof(blockEditName)}, -/*1*/ { PD_STRING, blockEditScript, "script", PDO_NOPREF, I2VP(350), N_("Script"), 0, 0, sizeof(blockEditScript)}, -/*2*/ { PD_STRING, blockEditSegs, "segments", PDO_NOPREF, I2VP(350), N_("Segments"), BO_READONLY, 0, sizeof(blockEditSegs) }, + /*0*/ { PD_STRING, blockEditName, "name", PDO_NOPREF | PDO_NOTBLANK, I2VP(200), N_("Name"), 0, 0, sizeof(blockEditName)}, + /*1*/ { PD_STRING, blockEditScript, "script", PDO_NOPREF, I2VP(350), N_("Script"), 0, 0, sizeof(blockEditScript)}, + /*2*/ { PD_STRING, blockEditSegs, "segments", PDO_NOPREF, I2VP(350), N_("Segments"), BO_READONLY, 0, sizeof(blockEditSegs) }, }; static paramGroup_t blockEditPG = { "block", 0, blockEditPLs, COUNT( blockEditPLs ) }; static wWin_p blockEditW; typedef struct btrackinfo_t { - track_p t; - TRKINX_T i; + track_p t; + TRKINX_T i; } btrackinfo_t, *btrackinfo_p; static dynArr_t blockTrk_da; @@ -136,13 +139,13 @@ static dynArr_t blockTrk_da; typedef struct blockData_t { - extraDataBase_t base; - char * name; - char * script; - BOOL_T IsHilite; - track_p next_block; - wIndex_t numTracks; - btrackinfo_t trackList; + extraDataBase_t base; + char * name; + char * script; + BOOL_T IsHilite; + track_p next_block; + wIndex_t numTracks; + btrackinfo_t trackList; } blockData_t, *blockData_p; static blockData_p GetblockData ( track_p trk ) @@ -163,14 +166,16 @@ static struct { typedef enum { NM, SC, LN, E0, E1 } blockDesc_e; static descData_t blockDesc[] = { -/*NM*/ { DESC_STRING, N_("Name"), &blockData.name, sizeof(blockData.name) }, -/*SC*/ { DESC_STRING, N_("Script"), &blockData.script, sizeof(blockData.script) }, -/*LN*/ { DESC_DIM, N_("Length"), &blockData.length }, -/*E0*/ { DESC_POS, N_("End Pt 1: X,Y"), &blockData.endPt[0] }, -/*E1*/ { DESC_POS, N_("End Pt 2: X,Y"), &blockData.endPt[1] }, - { DESC_NULL } }; - -static void UpdateBlock (track_p trk, int inx, descData_p descUpd, BOOL_T needUndoStart ) + /*NM*/ { DESC_STRING, N_("Name"), &blockData.name, sizeof(blockData.name) }, + /*SC*/ { DESC_STRING, N_("Script"), &blockData.script, sizeof(blockData.script) }, + /*LN*/ { DESC_DIM, N_("Length"), &blockData.length }, + /*E0*/ { DESC_POS, N_("End Pt 1: X,Y"), &blockData.endPt[0] }, + /*E1*/ { DESC_POS, N_("End Pt 2: X,Y"), &blockData.endPt[1] }, + { DESC_NULL } +}; + +static void UpdateBlock (track_p trk, int inx, descData_p descUpd, + BOOL_T needUndoStart ) { blockData_p xx = GetblockData(trk); const char * thename, *thescript; @@ -191,7 +196,7 @@ static void UpdateBlock (track_p trk, int inx, descData_p descUpd, BOOL_T needUn strncpy(newName, thename, max_str - 1); newName[max_str-1] = '\0'; NoticeMessage2(0, MSG_ENTERED_STRING_TRUNCATED, _("Ok"), NULL, max_str-1); - } else newName = MyStrdup(thename); + } else { newName = MyStrdup(thename); } } thescript = wStringGetValue( (wString_p)blockDesc[SC].control0 ); @@ -203,18 +208,19 @@ static void UpdateBlock (track_p trk, int inx, descData_p descUpd, BOOL_T needUn strncpy(newScript, thescript, max_str - 1); newScript[max_str-1] = '\0'; NoticeMessage2(0, MSG_ENTERED_STRING_TRUNCATED, _("Ok"), NULL, max_str-1); - } else newScript = MyStrdup(thescript); + } else { newScript = MyStrdup(thescript); } } - if ( ! changed ) return; - if ( needUndoStart ) + if ( ! changed ) { return; } + if ( needUndoStart ) { UndoStart( _("Change block"), "Change block" ); + } UndoModify( trk ); if (nChanged) { - if (xx->name) MyFree(xx->name); + if (xx->name) { MyFree(xx->name); } xx->name = newName; } if (sChanged) { - if (xx->script) MyFree(xx->script); + if (xx->script) { MyFree(xx->script); } xx->script = newScript; } return; @@ -231,7 +237,7 @@ static DIST_T DistanceBlock (track_p t, coOrd * p ) coOrd best_pos = pos; for (iTrk = 0; iTrk < xx->numTracks; iTrk++) { pos = *p; - if ((&(xx->trackList))[iTrk].t == NULL) continue; + if ((&(xx->trackList))[iTrk].t == NULL) { continue; } current = GetTrkDistance ((&(xx->trackList))[iTrk].t, &pos); if (current < closest) { closest = current; @@ -246,13 +252,14 @@ static void DescribeBlock (track_p trk, char * str, CSIZE_T len ) { blockData_p xx = GetblockData(trk); wIndex_t tcount = 0; - track_p lastTrk = NULL; +// track_p lastTrk = NULL; long listLabelsOption = listLabels; LOG( log_block, 1, ("*** DescribeBlock(): trk is T%d\n",GetTrkIndex(trk))) FormatCompoundTitle( listLabelsOption, xx->name ); - if (message[0] == '\0') + if (message[0] == '\0') { FormatCompoundTitle( listLabelsOption|LABEL_DESCR, xx->name ); + } strcpy( str, _(GetTrkTypeName( trk )) ); str++; while (*str) { @@ -260,7 +267,7 @@ static void DescribeBlock (track_p trk, char * str, CSIZE_T len ) str++; } sprintf( str, _("(%d): Layer=%u %s"), - GetTrkIndex(trk), GetTrkLayer(trk)+1, message ); + GetTrkIndex(trk), GetTrkLayer(trk)+1, message ); blockData.name[0] = '\0'; strncat(blockData.name,xx->name,STR_SHORT_SIZE-1); blockData.script[0] = '\0'; @@ -268,21 +275,21 @@ static void DescribeBlock (track_p trk, char * str, CSIZE_T len ) blockData.length = 0; BOOL_T first = TRUE; for (tcount = 0; tcount < xx->numTracks; tcount++) { - if ((&(xx->trackList))[tcount].t == NULL) continue; - if (first) { - blockData.endPt[0] = GetTrkEndPos((&(xx->trackList))[tcount].t,0); - first = FALSE; - } - blockData.endPt[1] = GetTrkEndPos((&(xx->trackList))[tcount].t,1); - blockData.length += GetTrkLength((&(xx->trackList))[tcount].t,0,1); - tcount++; - break; + if ((&(xx->trackList))[tcount].t == NULL) { continue; } + if (first) { + blockData.endPt[0] = GetTrkEndPos((&(xx->trackList))[tcount].t,0); + first = FALSE; + } + blockData.endPt[1] = GetTrkEndPos((&(xx->trackList))[tcount].t,1); + blockData.length += GetTrkLength((&(xx->trackList))[tcount].t,0,1); + tcount++; + break; } blockDesc[E0].mode = - blockDesc[E1].mode = - blockDesc[LN].mode = DESC_RO; + blockDesc[E1].mode = + blockDesc[LN].mode = DESC_RO; blockDesc[NM].mode = - blockDesc[SC].mode = DESC_NOREDRAW; + blockDesc[SC].mode = DESC_NOREDRAW; DoDescribe(_("Block"), trk, blockDesc, UpdateBlock ); } @@ -297,25 +304,26 @@ static int blockDebug (track_p trk) LOG( log_block, 1, ("*** blockDebug(): script = \"%s\"\n",xx->script)) LOG( log_block, 1, ("*** blockDebug(): numTracks = %d\n",xx->numTracks)) for (iTrack = 0; iTrack < xx->numTracks; iTrack++) { - if ((&(xx->trackList))[iTrack].t == NULL) continue; - LOG( log_block, 1, ("*** blockDebug(): trackList[%d] = T%d, ",iTrack,GetTrkIndex((&(xx->trackList))[iTrack].t))) + if ((&(xx->trackList))[iTrack].t == NULL) { continue; } + LOG( log_block, 1, ("*** blockDebug(): trackList[%d] = T%d, ",iTrack, + GetTrkIndex((&(xx->trackList))[iTrack].t))) LOG( log_block, 1, ("%s\n",GetTrkTypeName((&(xx->trackList))[iTrack].t))) } return(0); } -static BOOL_T blockCheckContigiousPath() +static BOOL_T blockCheckContiguousPath() { EPINX_T ep, epCnt, epN; int inx; track_p trk, trk1; DIST_T dist; ANGLE_T angle; - /*int pathElemStart = 0;*/ + /*int pathElemStart = 0;*/ coOrd endPtOrig = zero; BOOL_T IsConnectedP; trkEndPt_p endPtP; - DYNARR_RESET( trkEndPt_t, tempEndPts_da ); + TempEndPtsReset(); for ( inx=0; inx<blockTrk_da.cnt; inx++ ) { trk = blockTrk(inx).t; @@ -325,51 +333,54 @@ static BOOL_T blockCheckContigiousPath() trk1 = GetTrkEndTrk(trk,ep); if ( trk1 == NULL || !GetTrkSelected(trk1) ) { /* boundary EP */ - for ( epN=0; epN<tempEndPts_da.cnt; epN++ ) { - dist = FindDistance( GetTrkEndPos(trk,ep), tempEndPts(epN).pos ); - angle = NormalizeAngle( GetTrkEndAngle(trk,ep) - tempEndPts(epN).angle + connectAngle/2.0 ); - if ( dist < connectDistance && angle < connectAngle ) + for ( epN=0; epN<TempEndPtsCount(); epN++ ) { + endPtP = TempEndPt(epN); + dist = FindDistance( GetTrkEndPos(trk,ep), GetEndPtPos(endPtP) ); + angle = NormalizeAngle( GetTrkEndAngle(trk, + ep) - GetEndPtAngle(endPtP) + connectAngle/2.0 ); + if ( dist < connectDistance && angle < connectAngle ) { break; + } } - if ( epN>=tempEndPts_da.cnt ) { - DYNARR_APPEND( trkEndPt_t, tempEndPts_da, 10 ); - endPtP = &tempEndPts(tempEndPts_da.cnt-1); - memset( endPtP, 0, sizeof *endPtP ); - endPtP->pos = GetTrkEndPos(trk,ep); - endPtP->angle = GetTrkEndAngle(trk,ep); + if ( epN>=TempEndPtsCount() ) { + endPtP = TempEndPtsAppend(); + SetEndPt( endPtP, GetTrkEndPos(trk,ep), GetTrkEndAngle(trk,ep) ); /*endPtP->track = trk1;*/ /* These End Points are dummies -- we don't want DeleteTrack to look at them. */ - endPtP->track = NULL; - endPtP->index = (trk1?GetEndPtConnectedToMe(trk1,trk):-1); - endPtOrig.x += endPtP->pos.x; - endPtOrig.y += endPtP->pos.y; + SetEndPtTrack( endPtP, NULL ); + // TODO-EPP What is this for? + SetEndPtEndPt( endPtP, (trk1?GetEndPtConnectedToMe(trk1,trk):-1) ); + endPtOrig.x += GetEndPtPos(endPtP).x; + endPtOrig.y += GetEndPtPos(endPtP).y; } } else { IsConnectedP = TRUE; } } - if (!IsConnectedP && blockTrk_da.cnt > 1) return FALSE; + if (!IsConnectedP && blockTrk_da.cnt > 1) { return FALSE; } } return TRUE; } static void DeleteBlock ( track_p t ) { - track_p trk1; - blockData_p xx1; + track_p trk1; + blockData_p xx1; LOG( log_block, 1, ("*** DeleteBlock(%p)\n",t)) blockData_p xx = GetblockData(t); LOG( log_block, 1, ("*** DeleteBlock(): index is %d\n",GetTrkIndex(t))) - LOG( log_block, 1, ("*** DeleteBlock(): xx = %p, xx->name = %p, xx->script = %p\n", - xx,xx->name,xx->script)) + LOG( log_block, 1, + ("*** DeleteBlock(): xx = %p, xx->name = %p, xx->script = %p\n", + xx,xx->name,xx->script)) MyFree(xx->name); xx->name = NULL; MyFree(xx->script); xx->script = NULL; - if (first_block == t) - first_block = xx->next_block; + if (first_block == t) { + first_block = xx->next_block; + } trk1 = first_block; while(trk1) { xx1 = GetblockData (trk1); @@ -379,8 +390,9 @@ static void DeleteBlock ( track_p t ) } trk1 = xx1->next_block; } - if (t == last_block) + if (t == last_block) { last_block = trk1; + } } @@ -396,11 +408,11 @@ static BOOL_T WriteBlock ( track_p t, FILE * f ) #endif // UTFCONVERT rc &= fprintf(f, "BLOCK %d \"%s\" \"%s\"\n", - GetTrkIndex(t), blockName, xx->script)>0; + GetTrkIndex(t), blockName, xx->script)>0; for (iTrack = 0; iTrack < xx->numTracks && rc; iTrack++) { - if ((&(xx->trackList))[iTrack].t == NULL) continue; + if ((&(xx->trackList))[iTrack].t == NULL) { continue; } rc &= fprintf(f, "\tTRK %d\n", - GetTrkIndex((&(xx->trackList))[iTrack].t))>0; + GetTrkIndex((&(xx->trackList))[iTrack].t))>0; } rc &= fprintf( f, "\t%s\n", END_BLOCK )>0; MyFree(blockName); @@ -429,37 +441,39 @@ static BOOL_T ReadBlock ( char * line ) #endif // UTFCONVERT - DYNARR_RESET( btrackinfo_t , blockTrk_da ); + DYNARR_RESET( btrackinfo_t, blockTrk_da ); while ( (cp = GetNextLine()) != NULL ) { if ( IsEND( END_BLOCK ) ) { break; } - while (isspace((unsigned char)*cp)) cp++; + while (isspace((unsigned char)*cp)) { cp++; } if ( *cp == '\n' || *cp == '#' ) { continue; } if ( strncmp( cp, "TRK", 3 ) == 0 ) { - if (!GetArgs(cp+4,"d",&trkindex)) return FALSE; + if (!GetArgs(cp+4,"d",&trkindex)) { return FALSE; } /*trk = FindTrack(trkindex);*/ DYNARR_APPEND( btrackinfo_t, blockTrk_da, 10 ); DYNARR_LAST( btrackinfo_t, blockTrk_da ).i = trkindex; } } /*blockCheckContigiousPath(); save for ResolveBlockTracks */ - trk = NewTrack(index, T_BLOCK, tempEndPts_da.cnt, sizeof(blockData_t)+(sizeof(btrackinfo_t)*(blockTrk_da.cnt))+1); - for ( ep=0; ep<tempEndPts_da.cnt; ep++) { - endPtP = &tempEndPts(ep); - SetTrkEndPoint( trk, ep, endPtP->pos, endPtP->angle ); + trk = NewTrack(index, T_BLOCK, TempEndPtsCount(), + sizeof(blockData_t)+(sizeof(btrackinfo_t)*(blockTrk_da.cnt))+1); + for ( ep=0; ep<TempEndPtsCount(); ep++) { + endPtP = TempEndPt(ep); + SetTrkEndPoint( trk, ep, GetEndPtPos(endPtP), GetEndPtAngle(endPtP) ); } xx = GetblockData( trk ); - LOG( log_block, 1, ("*** ReadBlock(): trk = %p (%d), xx = %p\n",trk,GetTrkIndex(trk),xx)) + LOG( log_block, 1, ("*** ReadBlock(): trk = %p (%d), xx = %p\n",trk, + GetTrkIndex(trk),xx)) LOG( log_block, 1, ("*** ReadBlock(): name = %p, script = %p\n",name,script)) xx->name = name; xx->script = script; xx->IsHilite = FALSE; xx->numTracks = blockTrk_da.cnt; trk1 = last_block; - if (!trk1) first_block = trk; + if (!trk1) { first_block = trk; } else { xx1 = GetblockData(trk1); xx1->next_block = trk; @@ -477,21 +491,23 @@ static BOOL_T ReadBlock ( char * line ) EXPORT void ResolveBlockTrack ( track_p trk ) { - LOG( log_block, 1, ("*** ResolveBlockTrack(%p)\n",trk)) - blockData_p xx; - track_p t_trk; - wIndex_t iTrack; - if (GetTrkType(trk) != T_BLOCK) return; - LOG( log_block, 1, ("*** ResolveBlockTrack(%d)\n",GetTrkIndex(trk))) - xx = GetblockData(trk); - for (iTrack = 0; iTrack < xx->numTracks; iTrack++) { - t_trk = FindTrack(tracklist(iTrack).i); - if (t_trk == NULL) { - NoticeMessage( _("resolveBlockTrack: T%d[%d]: T%d doesn't exist"), _("Continue"), NULL, GetTrkIndex(trk), iTrack, tracklist(iTrack).i,t_trk ); - } - tracklist(iTrack).t = t_trk; - LOG( log_block, 1, ("*** ResolveBlockTrack(): %d (%d): %p\n",iTrack,tracklist(iTrack).i,t_trk)) - } + LOG( log_block, 1, ("*** ResolveBlockTrack(%p)\n",trk)) + blockData_p xx; + track_p t_trk; + wIndex_t iTrack; + if (GetTrkType(trk) != T_BLOCK) { return; } + LOG( log_block, 1, ("*** ResolveBlockTrack(%d)\n",GetTrkIndex(trk))) + xx = GetblockData(trk); + for (iTrack = 0; iTrack < xx->numTracks; iTrack++) { + t_trk = FindTrack(tracklist(iTrack).i); + if (t_trk == NULL) { + NoticeMessage( _("resolveBlockTrack: T%d[%d]: T%d doesn't exist"), + _("Continue"), NULL, GetTrkIndex(trk), iTrack, tracklist(iTrack).i,t_trk ); + } + tracklist(iTrack).t = t_trk; + LOG( log_block, 1, ("*** ResolveBlockTrack(): %d (%d): %p\n",iTrack, + tracklist(iTrack).i,t_trk)) + } } static void MoveBlock (track_p trk, coOrd orig ) {} @@ -533,24 +549,26 @@ static trackCmd_t blockCmds = { -static BOOL_T TrackInBlock (track_p trk, track_p blk) { +static BOOL_T TrackInBlock (track_p trk, track_p blk) +{ wIndex_t iTrack; blockData_p xx = GetblockData(blk); for (iTrack = 0; iTrack < xx->numTracks; iTrack++) { - if (trk == (&(xx->trackList))[iTrack].t) return TRUE; + if (trk == (&(xx->trackList))[iTrack].t) { return TRUE; } } return FALSE; } -static track_p FindBlock (track_p trk) { +static track_p FindBlock (track_p trk) +{ track_p a_trk; blockData_p xx; - if (!first_block) return NULL; + if (!first_block) { return NULL; } a_trk = first_block; while (a_trk) { if (!IsTrackDeleted(a_trk)) { if (GetTrkType(a_trk) == T_BLOCK && - TrackInBlock(trk,a_trk)) return a_trk; + TrackInBlock(trk,a_trk)) { return a_trk; } } xx = GetblockData(a_trk); a_trk = xx->next_block; @@ -599,8 +617,8 @@ static void BlockOk ( void * junk ) } /* Need to check that all block elements are connected to each other... */ - if (!blockCheckContigiousPath()) { - NoticeMessage( _("Block is discontigious!"), _("Ok"), NULL ); + if (!blockCheckContiguousPath()) { + NoticeMessage( _("Block is discontiguous!"), _("Ok"), NULL ); wDrawDelayUpdate( mainD.d, FALSE ); wHide( blockW ); return; @@ -608,23 +626,24 @@ static void BlockOk ( void * junk ) UndoStart( _("Create block"), "Create block" ); /* Create a block object */ LOG( log_block, 1, ("*** BlockOk(): %d tracks in block\n",blockTrk_da.cnt)) - trk = NewTrack(0, T_BLOCK, tempEndPts_da.cnt, sizeof(blockData_t)+(sizeof(btrackinfo_t)*(blockTrk_da.cnt-1))+1); - for ( ep=0; ep<tempEndPts_da.cnt; ep++) { - endPtP = &tempEndPts(ep); - SetTrkEndPoint( trk, ep, endPtP->pos, endPtP->angle ); + trk = NewTrack(0, T_BLOCK, TempEndPtsCount(), + sizeof(blockData_t)+(sizeof(btrackinfo_t)*(blockTrk_da.cnt-1))+1); + for ( ep=0; ep<TempEndPtsCount(); ep++) { + endPtP = TempEndPt(ep); + SetTrkEndPoint( trk, ep, GetEndPtPos(endPtP), GetEndPtAngle(endPtP) ); } xx = GetblockData( trk ); - LOG(log_block, 1, ("*** BlockOk(): trk = %p (%d), xx = %p\n", trk, GetTrkIndex(trk), xx)) + LOG(log_block, 1, ("*** BlockOk(): trk = %p (%d), xx = %p\n", trk, + GetTrkIndex(trk), xx)) xx->name = MyStrdup(blockName); xx->script = MyStrdup(blockScript); - xx->IsHilite = FALSE; + xx->IsHilite = FALSE; xx->numTracks = blockTrk_da.cnt; trk1 = last_block; if (!trk1) { first_block = trk; - } - else { + } else { xx1 = GetblockData(trk1); xx1->next_block = trk; } @@ -667,10 +686,11 @@ static void NewBlockDialog() ErrorMessage( MSG_NO_SELECTED_TRK ); return; } - if ( log_block < 0 ) log_block = LogFindIndex( "block" ); + if ( log_block < 0 ) { log_block = LogFindIndex( "block" ); } if ( !blockW ) { ParamRegister( &blockPG ); - blockW = ParamCreateDialog (&blockPG, MakeWindowTitle(_("Create Block")), _("Ok"), BlockOk, wHide, TRUE, NULL, F_BLOCK, NULL ); + blockW = ParamCreateDialog (&blockPG, MakeWindowTitle(_("Create Block")), + _("Ok"), BlockOk, wHide, TRUE, NULL, F_BLOCK, NULL ); blockD.dpi = mainD.dpi; } ParamLoadControls( &blockPG ); @@ -682,7 +702,7 @@ static STATUS_T CmdBlockCreate( wAction_t action, coOrd pos ) LOG( log_block, 1, ("*** CmdBlockAction(%08x,{%f,%f})\n",action,pos.x,pos.y)) switch (action & 0xFF) { case C_START: - LOG( log_block, 1,("*** CmdBlockCreate(): C_START\n")) + LOG( log_block, 1,("*** CmdBlockCreate(): C_START\n")) NewBlockDialog(); return C_TERMINATE; default: @@ -691,7 +711,6 @@ static STATUS_T CmdBlockCreate( wAction_t action, coOrd pos ) } #if 0 -extern BOOL_T inDescribeCmd; static STATUS_T CmdBlockEdit( wAction_t action, coOrd pos ) { @@ -745,7 +764,8 @@ static STATUS_T CmdBlockDelete( wAction_t action, coOrd pos ) } /* Confirm Delete Block */ xx = GetblockData(btrk); - if ( NoticeMessage( _("Really delete block %s?"), _("Yes"), _("No"), xx->name) ) { + if ( NoticeMessage( _("Really delete block %s?"), _("Yes"), _("No"), + xx->name) ) { UndoStart( _("Delete Block"), "delete" ); DeleteTrack (btrk, FALSE); UndoEnd(); @@ -781,74 +801,74 @@ static STATUS_T CmdBlock (wAction_t action, coOrd pos ) void CheckDeleteBlock(track_p t) { - track_p blk; - blockData_p xx; - if (!IsTrack(t)) { - return; - } - blk = FindBlock(t); - if (blk == NULL) { - return; - } - xx = GetblockData(blk); - NoticeMessage(_("Deleting block %s"),_("Ok"),NULL,xx->name); - DeleteTrack(blk,FALSE); + track_p blk; + blockData_p xx; + if (!IsTrack(t)) { + return; + } + blk = FindBlock(t); + if (blk == NULL) { + return; + } + xx = GetblockData(blk); + NoticeMessage(_("Deleting block %s"),_("Ok"),NULL,xx->name); + DeleteTrack(blk,FALSE); } static void BlockEditOk ( void * junk ) { - blockData_p xx; - track_p trk; - - LOG( log_block, 1, ("*** BlockEditOk()\n")) - ParamUpdate (&blockEditPG ); - if ( blockEditName[0]==0 ) { - NoticeMessage( _("Block must have a name!"), _("Ok"), NULL); - return; - } - wDrawDelayUpdate( mainD.d, TRUE ); - UndoStart( _("Modify Block"), "Modify Block" ); - trk = blockEditTrack; - xx = GetblockData( trk ); - xx->name = MyStrdup(blockEditName); - xx->script = MyStrdup(blockEditScript); - blockDebug(trk); - UndoEnd(); - wHide( blockEditW ); + blockData_p xx; + track_p trk; + + LOG( log_block, 1, ("*** BlockEditOk()\n")) + ParamUpdate (&blockEditPG ); + if ( blockEditName[0]==0 ) { + NoticeMessage( _("Block must have a name!"), _("Ok"), NULL); + return; + } + wDrawDelayUpdate( mainD.d, TRUE ); + UndoStart( _("Modify Block"), "Modify Block" ); + trk = blockEditTrack; + xx = GetblockData( trk ); + xx->name = MyStrdup(blockEditName); + xx->script = MyStrdup(blockEditScript); + blockDebug(trk); + UndoEnd(); + wHide( blockEditW ); } static void EditBlock (track_p trk) { - blockData_p xx = GetblockData(trk); - wIndex_t iTrack; - BOOL_T needComma = FALSE; - char temp[32]; + blockData_p xx = GetblockData(trk); + wIndex_t iTrack; + BOOL_T needComma = FALSE; + char temp[32]; strncpy(blockEditName, xx->name, STR_SHORT_SIZE - 1); blockEditName[STR_SHORT_SIZE-1] = '\0'; strncpy(blockEditScript, xx->script, STR_LONG_SIZE - 1); blockEditScript[STR_LONG_SIZE-1] = '\0'; - blockEditSegs[0] = '\0'; - for (iTrack = 0; iTrack < xx->numTracks ; iTrack++) { - if ((&(xx->trackList))[iTrack].t == NULL) continue; - sprintf(temp,"%d",GetTrkIndex((&(xx->trackList))[iTrack].t)); - if (needComma) strcat(blockEditSegs,", "); - strcat(blockEditSegs,temp); - needComma = TRUE; - } - blockEditTrack = trk; - if ( !blockEditW ) { - ParamRegister( &blockEditPG ); - blockEditW = ParamCreateDialog (&blockEditPG, - MakeWindowTitle(_("Edit block")), - _("Ok"), BlockEditOk, - wHide, TRUE, NULL, F_BLOCK, - NULL ); - } - ParamLoadControls( &blockEditPG ); - sprintf( message, _("Edit block %d"), GetTrkIndex(trk) ); - wWinSetTitle( blockEditW, message ); - wShow (blockEditW); + blockEditSegs[0] = '\0'; + for (iTrack = 0; iTrack < xx->numTracks ; iTrack++) { + if ((&(xx->trackList))[iTrack].t == NULL) { continue; } + sprintf(temp,"%d",GetTrkIndex((&(xx->trackList))[iTrack].t)); + if (needComma) { strcat(blockEditSegs,", "); } + strcat(blockEditSegs,temp); + needComma = TRUE; + } + blockEditTrack = trk; + if ( !blockEditW ) { + ParamRegister( &blockEditPG ); + blockEditW = ParamCreateDialog (&blockEditPG, + MakeWindowTitle(_("Edit block")), + _("Ok"), BlockEditOk, + wHide, TRUE, NULL, F_BLOCK, + NULL ); + } + ParamLoadControls( &blockEditPG ); + sprintf( message, _("Edit block %d"), GetTrkIndex(trk) ); + wWinSetTitle( blockEditW, message ); + wShow (blockEditW); } static coOrd blkhiliteOrig, blkhiliteSize; @@ -856,146 +876,157 @@ static POS_T blkhiliteBorder; static wDrawColor blkhiliteColor = 0; static void DrawBlockTrackHilite( void ) { - if (blkhiliteColor==0) + if (blkhiliteColor==0) { blkhiliteColor = wDrawColorGray(87); + } // This is incomplete. We should be in temp drawing mode and clearing temp draw on UN_HILIGHT - DrawRectangle( &tempD, blkhiliteOrig, blkhiliteSize, blkhiliteColor, DRAW_TRANSPARENT ); + DrawRectangle( &tempD, blkhiliteOrig, blkhiliteSize, blkhiliteColor, + DRAW_TRANSPARENT ); } static int BlockMgmProc ( int cmd, void * data ) { - track_p trk = (track_p) data; - blockData_p xx = GetblockData(trk); - wIndex_t iTrack; - BOOL_T needComma = FALSE; - char temp[32]; - /*char msg[STR_SIZE];*/ - coOrd tempOrig, tempSize; - BOOL_T first = TRUE; - - switch ( cmd ) { - case CONTMGM_CAN_EDIT: - return TRUE; - break; - case CONTMGM_DO_EDIT: - EditBlock (trk); - /*inDescribeCmd = TRUE;*/ - /*DescribeTrack (trk, msg, sizeof msg );*/ - /*InfoMessage( msg );*/ - return TRUE; - break; - case CONTMGM_CAN_DELETE: - return TRUE; - break; - case CONTMGM_DO_DELETE: - DeleteTrack (trk, FALSE); - return TRUE; - break; - case CONTMGM_DO_HILIGHT: - if (!xx->IsHilite) { - blkhiliteBorder = mainD.scale*0.1; - if ( blkhiliteBorder < trackGauge ) blkhiliteBorder = trackGauge; - first = TRUE; - for (iTrack = 0; iTrack < xx->numTracks ; iTrack++) { - if ((&(xx->trackList))[iTrack].t == NULL) continue; - GetBoundingBox( (&(xx->trackList))[iTrack].t, &tempSize, &tempOrig ); - if (first) { - blkhiliteOrig = tempOrig; - blkhiliteSize = tempSize; - first = FALSE; - } else { - if (tempSize.x > blkhiliteSize.x) - blkhiliteSize.x = tempSize.x; - if (tempSize.y > blkhiliteSize.y) - blkhiliteSize.y = tempSize.y; - if (tempOrig.x < blkhiliteOrig.x) - blkhiliteOrig.x = tempOrig.x; - if (tempOrig.y < blkhiliteOrig.y) - blkhiliteOrig.y = tempOrig.y; - } - } - blkhiliteOrig.x -= blkhiliteBorder; - blkhiliteOrig.y -= blkhiliteBorder; - blkhiliteSize.x -= blkhiliteOrig.x-blkhiliteBorder; - blkhiliteSize.y -= blkhiliteOrig.y-blkhiliteBorder; - DrawBlockTrackHilite(); - xx->IsHilite = TRUE; - } - break; - case CONTMGM_UN_HILIGHT: - if (xx->IsHilite) { - blkhiliteBorder = mainD.scale*0.1; - if ( blkhiliteBorder < trackGauge ) blkhiliteBorder = trackGauge; - first = TRUE; - for (iTrack = 0; iTrack < xx->numTracks ; iTrack++) { - if ((&(xx->trackList))[iTrack].t == NULL) continue; - GetBoundingBox( (&(xx->trackList))[iTrack].t, &tempSize, &tempOrig ); - if (first) { - blkhiliteOrig = tempOrig; - blkhiliteSize = tempSize; - first = FALSE; - } else { - if (tempSize.x > blkhiliteSize.x) - blkhiliteSize.x = tempSize.x; - if (tempSize.y > blkhiliteSize.y) - blkhiliteSize.y = tempSize.y; - if (tempOrig.x < blkhiliteOrig.x) - blkhiliteOrig.x = tempOrig.x; - if (tempOrig.y < blkhiliteOrig.y) - blkhiliteOrig.y = tempOrig.y; - } - } - blkhiliteOrig.x -= blkhiliteBorder; - blkhiliteOrig.y -= blkhiliteBorder; - blkhiliteSize.x -= blkhiliteOrig.x-blkhiliteBorder; - blkhiliteSize.y -= blkhiliteOrig.y-blkhiliteBorder; - DrawBlockTrackHilite(); - xx->IsHilite = FALSE; - } - break; - case CONTMGM_GET_TITLE: - sprintf( message, "\t%s\t", xx->name); - for (iTrack = 0; iTrack < xx->numTracks ; iTrack++) { - if ((&(xx->trackList))[iTrack].t == NULL) continue; - sprintf(temp,"%d",GetTrkIndex((&(xx->trackList))[iTrack].t)); - if (needComma) strcat(message,", "); - strcat(message,temp); - needComma = TRUE; - } - break; - } - return FALSE; + track_p trk = (track_p) data; + blockData_p xx = GetblockData(trk); + wIndex_t iTrack; + BOOL_T needComma = FALSE; + char temp[32]; + /*char msg[STR_SIZE];*/ + coOrd tempOrig, tempSize; + BOOL_T first = TRUE; + + switch ( cmd ) { + case CONTMGM_CAN_EDIT: + return TRUE; + break; + case CONTMGM_DO_EDIT: + EditBlock (trk); + /*inDescribeCmd = TRUE;*/ + /*DescribeTrack (trk, msg, sizeof msg );*/ + /*InfoMessage( msg );*/ + return TRUE; + break; + case CONTMGM_CAN_DELETE: + return TRUE; + break; + case CONTMGM_DO_DELETE: + DeleteTrack (trk, FALSE); + return TRUE; + break; + case CONTMGM_DO_HILIGHT: + if (!xx->IsHilite) { + blkhiliteBorder = mainD.scale*0.1; + if ( blkhiliteBorder < trackGauge ) { blkhiliteBorder = trackGauge; } + first = TRUE; + for (iTrack = 0; iTrack < xx->numTracks ; iTrack++) { + if ((&(xx->trackList))[iTrack].t == NULL) { continue; } + GetBoundingBox( (&(xx->trackList))[iTrack].t, &tempSize, &tempOrig ); + if (first) { + blkhiliteOrig = tempOrig; + blkhiliteSize = tempSize; + first = FALSE; + } else { + if (tempSize.x > blkhiliteSize.x) { + blkhiliteSize.x = tempSize.x; + } + if (tempSize.y > blkhiliteSize.y) { + blkhiliteSize.y = tempSize.y; + } + if (tempOrig.x < blkhiliteOrig.x) { + blkhiliteOrig.x = tempOrig.x; + } + if (tempOrig.y < blkhiliteOrig.y) { + blkhiliteOrig.y = tempOrig.y; + } + } + } + blkhiliteOrig.x -= blkhiliteBorder; + blkhiliteOrig.y -= blkhiliteBorder; + blkhiliteSize.x -= blkhiliteOrig.x-blkhiliteBorder; + blkhiliteSize.y -= blkhiliteOrig.y-blkhiliteBorder; + DrawBlockTrackHilite(); + xx->IsHilite = TRUE; + } + break; + case CONTMGM_UN_HILIGHT: + if (xx->IsHilite) { + blkhiliteBorder = mainD.scale*0.1; + if ( blkhiliteBorder < trackGauge ) { blkhiliteBorder = trackGauge; } + first = TRUE; + for (iTrack = 0; iTrack < xx->numTracks ; iTrack++) { + if ((&(xx->trackList))[iTrack].t == NULL) { continue; } + GetBoundingBox( (&(xx->trackList))[iTrack].t, &tempSize, &tempOrig ); + if (first) { + blkhiliteOrig = tempOrig; + blkhiliteSize = tempSize; + first = FALSE; + } else { + if (tempSize.x > blkhiliteSize.x) { + blkhiliteSize.x = tempSize.x; + } + if (tempSize.y > blkhiliteSize.y) { + blkhiliteSize.y = tempSize.y; + } + if (tempOrig.x < blkhiliteOrig.x) { + blkhiliteOrig.x = tempOrig.x; + } + if (tempOrig.y < blkhiliteOrig.y) { + blkhiliteOrig.y = tempOrig.y; + } + } + } + blkhiliteOrig.x -= blkhiliteBorder; + blkhiliteOrig.y -= blkhiliteBorder; + blkhiliteSize.x -= blkhiliteOrig.x-blkhiliteBorder; + blkhiliteSize.y -= blkhiliteOrig.y-blkhiliteBorder; + DrawBlockTrackHilite(); + xx->IsHilite = FALSE; + } + break; + case CONTMGM_GET_TITLE: + sprintf( message, "\t%s\t", xx->name); + for (iTrack = 0; iTrack < xx->numTracks ; iTrack++) { + if ((&(xx->trackList))[iTrack].t == NULL) { continue; } + sprintf(temp,"%d",GetTrkIndex((&(xx->trackList))[iTrack].t)); + if (needComma) { strcat(message,", "); } + strcat(message,temp); + needComma = TRUE; + } + break; + } + return FALSE; } //#include "bitmaps/blocknew.xpm" //#include "bitmaps/blockedit.xpm" //#include "bitmaps/blockdel.xpm" -#include "bitmaps/block.xpm" +#include "bitmaps/block.xpm3" EXPORT void BlockMgmLoad( void ) { - track_p trk; - static wIcon_p blockI = NULL; - - if ( blockI == NULL) - blockI = wIconCreatePixMap( block_xpm[iconSize] ); - - TRK_ITERATE(trk) { - if (GetTrkType(trk) != T_BLOCK) continue; - ContMgmLoad( blockI, BlockMgmProc, trk ); - } - + track_p trk; + static wIcon_p blockI = NULL; + + if ( blockI == NULL) { + blockI = wIconCreatePixMap( block_xpm3[iconSize] ); + } + + TRK_ITERATE(trk) { + if (GetTrkType(trk) != T_BLOCK) { continue; } + ContMgmLoad( blockI, BlockMgmProc, trk ); + } + } EXPORT void InitCmdBlock( wMenu_p menu ) { blockName[0] = '\0'; blockScript[0] = '\0'; - AddMenuButton( menu, CmdBlockCreate, "cmdBlockCreate", _("Block"), - wIconCreatePixMap( block_xpm[iconSize] ), LEVEL0_50, - IC_STICKY|IC_POPUP2, ACCL_BLOCK1, NULL ); + AddMenuButton( menu, CmdBlockCreate, "cmdBlockCreate", _("Block"), + wIconCreatePixMap( block_xpm3[iconSize] ), LEVEL0_50, + IC_STICKY|IC_POPUP2, ACCL_BLOCK1, NULL ); ParamRegister( &blockPG ); } @@ -1004,9 +1035,7 @@ EXPORT void InitTrkBlock( void ) { T_BLOCK = InitObject ( &blockCmds ); log_block = LogFindIndex ( "block" ); - blockTrk_da.max = 0; - blockTrk_da.cnt = 0; - blockTrk_da.ptr = NULL; + DYNARR_INIT( btrackinfo_t, blockTrk_da ); last_block = NULL; } diff --git a/app/bin/ccontrol.c b/app/bin/ccontrol.c index a4f9b27..90c4fb2 100644 --- a/app/bin/ccontrol.c +++ b/app/bin/ccontrol.c @@ -4,8 +4,8 @@ /* -*- C -*- **************************************************************** * - * System : - * Module : + * System : + * Module : * Object Name : $RCSfile$ * Revision : $Revision$ * Date : $Date$ @@ -14,12 +14,12 @@ * Created : Sun Mar 5 16:01:37 2017 * Last Modified : <170314.1418> * - * Description + * Description * * Notes * * History - * + * **************************************************************************** * * Copyright (C) 2017 Robert Heller D/B/A Deepwoods Software @@ -38,13 +38,13 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * * - * * ****************************************************************************/ -static const char rcsid[] = "@(#) : $Id$"; +//static const char rcsid[] = "@(#) : $Id$"; #include "compound.h" #include "cselect.h" @@ -54,7 +54,6 @@ static const char rcsid[] = "@(#) : $Id$"; #include "layout.h" #include "param.h" #include "track.h" -#include "trackx.h" #include "common-ui.h" #ifdef UTFCONVERT #include "include/utf8convert.h" @@ -73,7 +72,8 @@ static drawCmd_t controlD = { 1.0, 0.0, {0.0,0.0}, {0.0,0.0}, - Pix2CoOrd, CoOrd2Pix }; + Pix2CoOrd, CoOrd2Pix +}; static char controlName[STR_SHORT_SIZE]; static char controlOnScript[STR_LONG_SIZE]; @@ -81,17 +81,17 @@ static char controlOffScript[STR_LONG_SIZE]; #endif typedef struct controlData_t { - extraDataBase_t base; - coOrd orig; - BOOL_T IsHilite; - char * name; - char * onscript; - char * offscript; + extraDataBase_t base; + coOrd orig; + BOOL_T IsHilite; + char * name; + char * onscript; + char * offscript; } controlData_t, *controlData_p; static controlData_p GetcontrolData ( track_p trk ) { - return GET_EXTRA_DATA( trk, T_CONTROL, controlData_t ); + return GET_EXTRA_DATA( trk, T_CONTROL, controlData_t ); } #define RADIUS 6 @@ -99,267 +99,270 @@ static controlData_p GetcontrolData ( track_p trk ) #define control_SF (3.0) -static void DDrawControl(drawCmd_p d, coOrd orig, DIST_T scaleRatio, +static void DDrawControl(drawCmd_p d, coOrd orig, DIST_T scaleRatio, wDrawColor color ) { - coOrd p1, p2; - - p1 = orig; - DrawFillCircle(d,p1, RADIUS * control_SF / scaleRatio,color); - Translate (&p1, orig, 45, RADIUS * control_SF / scaleRatio); - Translate (&p2, p1, 45, LINE * control_SF / scaleRatio); - DrawLine(d, p1, p2, 2, color); - Translate (&p1, orig, 45+90, RADIUS * control_SF / scaleRatio); - Translate (&p2, p1, 45+90, LINE * control_SF / scaleRatio); - DrawLine(d, p1, p2, 2, color); - Translate (&p1, orig, 45+180, RADIUS * control_SF / scaleRatio); - Translate (&p2, p1, 45+180, LINE * control_SF / scaleRatio); - DrawLine(d, p1, p2, 2, color); - Translate (&p1, orig, 45+270, RADIUS * control_SF / scaleRatio); - Translate (&p2, p1, 45+270, LINE * control_SF / scaleRatio); - DrawLine(d, p1, p2, 2, color); + coOrd p1, p2; + + p1 = orig; + DrawFillCircle(d,p1, RADIUS * control_SF / scaleRatio,color); + Translate (&p1, orig, 45, RADIUS * control_SF / scaleRatio); + Translate (&p2, p1, 45, LINE * control_SF / scaleRatio); + DrawLine(d, p1, p2, 2, color); + Translate (&p1, orig, 45+90, RADIUS * control_SF / scaleRatio); + Translate (&p2, p1, 45+90, LINE * control_SF / scaleRatio); + DrawLine(d, p1, p2, 2, color); + Translate (&p1, orig, 45+180, RADIUS * control_SF / scaleRatio); + Translate (&p2, p1, 45+180, LINE * control_SF / scaleRatio); + DrawLine(d, p1, p2, 2, color); + Translate (&p1, orig, 45+270, RADIUS * control_SF / scaleRatio); + Translate (&p2, p1, 45+270, LINE * control_SF / scaleRatio); + DrawLine(d, p1, p2, 2, color); } static void DrawControl (track_p t, drawCmd_p d, wDrawColor color ) { - controlData_p xx = GetcontrolData(t); - DDrawControl(d,xx->orig,GetScaleRatio(GetTrkScale(t)),color); + controlData_p xx = GetcontrolData(t); + DDrawControl(d,xx->orig,GetScaleRatio(GetTrkScale(t)),color); } -static void ControlBoundingBox (coOrd orig, DIST_T scaleRatio, coOrd *hi, +static void ControlBoundingBox (coOrd orig, DIST_T scaleRatio, coOrd *hi, coOrd *lo) { - coOrd p1, p2; - - p1 = orig; - Translate (&p1, orig, 0, -(RADIUS+LINE) * control_SF / scaleRatio); - Translate (&p2, orig, 0, (RADIUS+LINE) * control_SF / scaleRatio); - *hi = p1; *lo = p1; - if (p2.x > hi->x) hi->x = p2.x; - if (p2.x < lo->x) lo->x = p2.x; - if (p2.y > hi->y) hi->y = p2.y; - if (p2.y < lo->y) lo->y = p2.y; -} + coOrd p1, p2; + + p1 = orig; + Translate (&p1, orig, 0, -(RADIUS+LINE) * control_SF / scaleRatio); + Translate (&p2, orig, 0, (RADIUS+LINE) * control_SF / scaleRatio); + *hi = p1; *lo = p1; + if (p2.x > hi->x) { hi->x = p2.x; } + if (p2.x < lo->x) { lo->x = p2.x; } + if (p2.y > hi->y) { hi->y = p2.y; } + if (p2.y < lo->y) { lo->y = p2.y; } +} static void ComputeControlBoundingBox (track_p t ) { - coOrd lo, hi; - controlData_p xx = GetcontrolData(t); - ControlBoundingBox(xx->orig, GetScaleRatio(GetTrkScale(t)), &hi, &lo); - SetBoundingBox(t, hi, lo); + coOrd lo, hi; + controlData_p xx = GetcontrolData(t); + ControlBoundingBox(xx->orig, GetScaleRatio(GetTrkScale(t)), &hi, &lo); + SetBoundingBox(t, hi, lo); } static DIST_T DistanceControl (track_p t, coOrd * p ) { - controlData_p xx = GetcontrolData(t); - return FindDistance(xx->orig, *p); + controlData_p xx = GetcontrolData(t); + return FindDistance(xx->orig, *p); } static struct { - char name[STR_SHORT_SIZE]; - coOrd pos; - char onscript[STR_LONG_SIZE]; - char offscript[STR_LONG_SIZE]; + char name[STR_SHORT_SIZE]; + coOrd pos; + char onscript[STR_LONG_SIZE]; + char offscript[STR_LONG_SIZE]; } controlProperties; typedef enum { NM, PS, ON, OF } controlDesc_e; static descData_t controlDesc[] = { - /* NM */ { DESC_STRING, N_("Name"), &controlProperties.name, sizeof(controlProperties.name) }, - /* PS */ { DESC_POS, N_("Position"), &controlProperties.pos }, - /* ON */ { DESC_STRING, N_("On Script"), &controlProperties.onscript, sizeof(controlProperties.onscript) }, - /* OF */ { DESC_STRING, N_("Off Script"),&controlProperties.offscript, sizeof(controlProperties.offscript) }, - { DESC_NULL } }; + /* NM */ { DESC_STRING, N_("Name"), &controlProperties.name, sizeof(controlProperties.name) }, + /* PS */ { DESC_POS, N_("Position"), &controlProperties.pos }, + /* ON */ { DESC_STRING, N_("On Script"), &controlProperties.onscript, sizeof(controlProperties.onscript) }, + /* OF */ { DESC_STRING, N_("Off Script"),&controlProperties.offscript, sizeof(controlProperties.offscript) }, + { DESC_NULL } +}; static void UpdateControlProperties ( track_p trk, int inx, descData_p - descUpd, BOOL_T needUndoStart ) + descUpd, BOOL_T needUndoStart ) { - controlData_p xx = GetcontrolData(trk); - const char *thename, *theonscript, *theoffscript; - unsigned int max_str; - char *newName, *newOnScript, *newOffScript; - BOOL_T changed, nChanged, pChanged, onChanged, offChanged; - - switch (inx) { - case NM: - break; - case PS: - break; - case ON: - break; - case OF: - break; - case -1: - changed = nChanged = pChanged = onChanged = offChanged = FALSE; - thename = wStringGetValue( (wString_p) controlDesc[NM].control0 ); - if (strcmp(thename,xx->name) != 0) { - nChanged = changed = TRUE; - max_str = controlDesc[NM].max_string; + controlData_p xx = GetcontrolData(trk); + const char *thename, *theonscript, *theoffscript; + unsigned int max_str; + char *newName, *newOnScript, *newOffScript=NULL; + BOOL_T changed, nChanged, pChanged, onChanged, offChanged; + + switch (inx) { + case NM: + break; + case PS: + break; + case ON: + break; + case OF: + break; + case -1: + changed = nChanged = pChanged = onChanged = offChanged = FALSE; + thename = wStringGetValue( (wString_p) controlDesc[NM].control0 ); + if (strcmp(thename,xx->name) != 0) { + nChanged = changed = TRUE; + max_str = controlDesc[NM].max_string; if (max_str && strlen(thename)>max_str-1) { newName = MyMalloc(max_str); newName[0] = '\0'; strncat(newName,thename,max_str-1); NoticeMessage2(0, MSG_ENTERED_STRING_TRUNCATED, _("Ok"), NULL, max_str-1); - } else newName = MyStrdup(thename); - } + } else { newName = MyStrdup(thename); } + } - theonscript = wStringGetValue( (wString_p) controlDesc[ON].control0 ); - if (strcmp(theonscript,xx->onscript) != 0) { - onChanged = changed = TRUE; - max_str = controlDesc[ON].max_string; + theonscript = wStringGetValue( (wString_p) controlDesc[ON].control0 ); + if (strcmp(theonscript,xx->onscript) != 0) { + onChanged = changed = TRUE; + max_str = controlDesc[ON].max_string; if (max_str && strlen(theonscript)>max_str-1) { newOnScript = MyMalloc(max_str); newOnScript[0] = '\0'; strncat(newOnScript,theonscript,max_str-1); NoticeMessage2(0, MSG_ENTERED_STRING_TRUNCATED, _("Ok"), NULL, max_str-1); - } else newOnScript = MyStrdup(theonscript); - } + } else { newOnScript = MyStrdup(theonscript); } + } - theoffscript = wStringGetValue( (wString_p) controlDesc[OF].control0 ); - if (strcmp(theoffscript,xx->offscript) != 0) { - offChanged = changed = TRUE; - max_str = controlDesc[OF].max_string; + theoffscript = wStringGetValue( (wString_p) controlDesc[OF].control0 ); + if (strcmp(theoffscript,xx->offscript) != 0) { + offChanged = changed = TRUE; + max_str = controlDesc[OF].max_string; if (max_str && strlen(theoffscript)>max_str-1) { newOffScript = MyMalloc(max_str); newOffScript[max_str-1] = '\0'; strncat(newOffScript,theoffscript,max_str-1); NoticeMessage2(0, MSG_ENTERED_STRING_TRUNCATED, _("Ok"), NULL, max_str); - } else newOffScript = MyStrdup(theoffscript); - } - - if (controlProperties.pos.x != xx->orig.x || - controlProperties.pos.y != xx->orig.y) { - pChanged = changed = TRUE; - } - if (!changed) break; - if (needUndoStart) - UndoStart( _("Change Control"), "Change Control" ); - UndoModify( trk ); - if (nChanged) { - MyFree(xx->name); - xx->name = newName; - } - if (pChanged) { - UndrawNewTrack( trk ); - } - if (pChanged) { - xx->orig = controlProperties.pos; - } - if (onChanged) { - MyFree(xx->onscript); - xx->onscript = newOnScript; - } - if (offChanged) { - MyFree(xx->offscript); - xx->offscript = newOffScript; - } - if (pChanged) { - ComputeControlBoundingBox( trk ); - DrawNewTrack( trk ); - } - break; - } + } else { newOffScript = MyStrdup(theoffscript); } + } + + if (controlProperties.pos.x != xx->orig.x || + controlProperties.pos.y != xx->orig.y) { + pChanged = changed = TRUE; + } + if (!changed) { break; } + if (needUndoStart) { + UndoStart( _("Change Control"), "Change Control" ); + } + UndoModify( trk ); + if (nChanged) { + MyFree(xx->name); + xx->name = newName; + } + if (pChanged) { + UndrawNewTrack( trk ); + } + if (pChanged) { + xx->orig = controlProperties.pos; + } + if (onChanged) { + MyFree(xx->onscript); + xx->onscript = newOnScript; + } + if (offChanged) { + MyFree(xx->offscript); + xx->offscript = newOffScript; + } + if (pChanged) { + ComputeControlBoundingBox( trk ); + DrawNewTrack( trk ); + } + break; + } } - + static void DescribeControl (track_p trk, char * str, CSIZE_T len ) { - controlData_p xx = GetcontrolData(trk); - - strcpy( str, _(GetTrkTypeName( trk )) ); - str++; - while (*str) { - *str = tolower((unsigned char)*str); - str++; - } - sprintf( str, _("(%d [%s]): Layer=%u, at %0.3f,%0.3f"), - GetTrkIndex(trk), - xx->name,GetTrkLayer(trk)+1, xx->orig.x, xx->orig.y); - strncpy(controlProperties.name,xx->name,STR_SHORT_SIZE-1); - controlProperties.name[STR_SHORT_SIZE-1] = '\0'; - strncpy(controlProperties.onscript,xx->onscript,STR_LONG_SIZE-1); - controlProperties.onscript[STR_LONG_SIZE-1] = '\0'; - strncpy(controlProperties.offscript,xx->offscript,STR_LONG_SIZE-1); - controlProperties.offscript[STR_LONG_SIZE-1] = '\0'; - controlProperties.pos = xx->orig; - controlDesc[NM].mode = - controlDesc[ON].mode = - controlDesc[OF].mode = DESC_NOREDRAW; - DoDescribe( _("Control"), trk, controlDesc, UpdateControlProperties ); - + controlData_p xx = GetcontrolData(trk); + + strcpy( str, _(GetTrkTypeName( trk )) ); + str++; + while (*str) { + *str = tolower((unsigned char)*str); + str++; + } + sprintf( str, _("(%d [%s]): Layer=%u, at %0.3f,%0.3f"), + GetTrkIndex(trk), + xx->name,GetTrkLayer(trk)+1, xx->orig.x, xx->orig.y); + strncpy(controlProperties.name,xx->name,STR_SHORT_SIZE-1); + controlProperties.name[STR_SHORT_SIZE-1] = '\0'; + strncpy(controlProperties.onscript,xx->onscript,STR_LONG_SIZE-1); + controlProperties.onscript[STR_LONG_SIZE-1] = '\0'; + strncpy(controlProperties.offscript,xx->offscript,STR_LONG_SIZE-1); + controlProperties.offscript[STR_LONG_SIZE-1] = '\0'; + controlProperties.pos = xx->orig; + controlDesc[NM].mode = + controlDesc[ON].mode = + controlDesc[OF].mode = DESC_NOREDRAW; + DoDescribe( _("Control"), trk, controlDesc, UpdateControlProperties ); + } -static void DeleteControl ( track_p trk ) +static void DeleteControl ( track_p trk ) { - controlData_p xx = GetcontrolData(trk); - MyFree(xx->name); xx->name = NULL; - MyFree(xx->onscript); xx->onscript = NULL; - MyFree(xx->offscript); xx->offscript = NULL; + controlData_p xx = GetcontrolData(trk); + MyFree(xx->name); xx->name = NULL; + MyFree(xx->onscript); xx->onscript = NULL; + MyFree(xx->offscript); xx->offscript = NULL; } static BOOL_T WriteControl ( track_p t, FILE * f ) { - BOOL_T rc = TRUE; - controlData_p xx = GetcontrolData(t); + BOOL_T rc = TRUE; + controlData_p xx = GetcontrolData(t); char *controlName = MyStrdup(xx->name); #ifdef UTFCONVERT controlName = Convert2UTF8(controlName); #endif // UTFCONVERT - rc &= fprintf(f, "CONTROL %d %u %s %d %0.6f %0.6f \"%s\" \"%s\" \"%s\"\n", - GetTrkIndex(t), GetTrkLayer(t), GetTrkScaleName(t), - GetTrkVisible(t), xx->orig.x, xx->orig.y, controlName, - xx->onscript, xx->offscript)>0; + rc &= fprintf(f, "CONTROL %d %u %s %d %0.6f %0.6f \"%s\" \"%s\" \"%s\"\n", + GetTrkIndex(t), GetTrkLayer(t), GetTrkScaleName(t), + GetTrkVisible(t), xx->orig.x, xx->orig.y, controlName, + xx->onscript, xx->offscript)>0; MyFree(controlName); - return rc; + return rc; } static BOOL_T ReadControl ( char * line ) { - wIndex_t index; - /*TRKINX_T trkindex;*/ - track_p trk; - /*char * cp = NULL;*/ - char *name; - char *onscript, *offscript; - coOrd orig; - BOOL_T visible; - char scale[10]; - wIndex_t layer; - controlData_p xx; - if (!GetArgs(line+7,"dLsdpqqq",&index,&layer,scale, &visible, &orig,&name,&onscript,&offscript)) { - return FALSE; - } + wIndex_t index; + /*TRKINX_T trkindex;*/ + track_p trk; + /*char * cp = NULL;*/ + char *name; + char *onscript, *offscript; + coOrd orig; + BOOL_T visible; + char scale[10]; + wIndex_t layer; + controlData_p xx; + if (!GetArgs(line+7,"dLsdpqqq",&index,&layer,scale, &visible, &orig,&name, + &onscript,&offscript)) { + return FALSE; + } #ifdef UTFCONVERT ConvertUTF8ToSystem(name); #endif // UTFCONVERT - trk = NewTrack(index, T_CONTROL, 0, sizeof(controlData_t)); - SetTrkVisible(trk, visible); - SetTrkScale(trk, LookupScale( scale )); - SetTrkLayer(trk, layer); - xx = GetcontrolData ( trk ); - xx->name = name; - xx->orig = orig; - xx->onscript = onscript; - xx->offscript = offscript; - ComputeControlBoundingBox(trk); - return TRUE; + trk = NewTrack(index, T_CONTROL, 0, sizeof(controlData_t)); + SetTrkVisible(trk, visible); + SetTrkScale(trk, LookupScale( scale )); + SetTrkLayer(trk, layer); + xx = GetcontrolData ( trk ); + xx->name = name; + xx->orig = orig; + xx->onscript = onscript; + xx->offscript = offscript; + ComputeControlBoundingBox(trk); + return TRUE; } static void MoveControl (track_p trk, coOrd orig ) { - controlData_p xx = GetcontrolData ( trk ); - xx->orig.x += orig.x; - xx->orig.y += orig.y; - ComputeControlBoundingBox(trk); + controlData_p xx = GetcontrolData ( trk ); + xx->orig.x += orig.x; + xx->orig.y += orig.y; + ComputeControlBoundingBox(trk); } static void RotateControl (track_p trk, coOrd orig, ANGLE_T angle ) @@ -370,44 +373,44 @@ static void RescaleControl (track_p trk, FLOAT_T ratio ) { } -static void FlipControl (track_p trk, coOrd orig, ANGLE_T angle ) +static void FlipControl (track_p trk, coOrd orig, ANGLE_T angle ) { - controlData_p xx = GetcontrolData ( trk ); - FlipPoint(&(xx->orig), orig, angle); - ComputeControlBoundingBox(trk); + controlData_p xx = GetcontrolData ( trk ); + FlipPoint(&(xx->orig), orig, angle); + ComputeControlBoundingBox(trk); } static trackCmd_t controlCmds = { - "CONTROL", - DrawControl, - DistanceControl, - DescribeControl, - DeleteControl, - WriteControl, - ReadControl, - MoveControl, - RotateControl, - RescaleControl, - NULL, /* audit */ - NULL, /* getAngle */ - NULL, /* split */ - NULL, /* traverse */ - NULL, /* enumerate */ - NULL, /* redraw */ - NULL, /* trim */ - NULL, /* merge */ - NULL, /* modify */ - NULL, /* getLength */ - NULL, /* getTrkParams */ - NULL, /* moveEndPt */ - NULL, /* query */ - NULL, /* ungroup */ - FlipControl, /* flip */ - NULL, /* drawPositionIndicator */ - NULL, /* advancePositionIndicator */ - NULL, /* checkTraverse */ - NULL, /* makeParallel */ - NULL /* drawDesc */ + "CONTROL", + DrawControl, + DistanceControl, + DescribeControl, + DeleteControl, + WriteControl, + ReadControl, + MoveControl, + RotateControl, + RescaleControl, + NULL, /* audit */ + NULL, /* getAngle */ + NULL, /* split */ + NULL, /* traverse */ + NULL, /* enumerate */ + NULL, /* redraw */ + NULL, /* trim */ + NULL, /* merge */ + NULL, /* modify */ + NULL, /* getLength */ + NULL, /* getTrkParams */ + NULL, /* moveEndPt */ + NULL, /* query */ + NULL, /* ungroup */ + FlipControl, /* flip */ + NULL, /* drawPositionIndicator */ + NULL, /* advancePositionIndicator */ + NULL, /* checkTraverse */ + NULL, /* makeParallel */ + NULL /* drawDesc */ }; static coOrd controlEditOrig; @@ -419,15 +422,15 @@ static char controlEditOffScript[STR_LONG_SIZE]; static paramFloatRange_t r_1000_1000 = { -1000.0, 1000.0, 80 }; static paramData_t controlEditPLs[] = { #define I_CONTROLNAME (0) - /*0*/ { PD_STRING, controlEditName, "name", PDO_NOPREF | PDO_NOTBLANK, I2VP(200), N_("Name"), 0, 0, sizeof(controlEditName) }, + /*0*/ { PD_STRING, controlEditName, "name", PDO_NOPREF | PDO_NOTBLANK, I2VP(200), N_("Name"), 0, 0, sizeof(controlEditName) }, #define I_ORIGX (1) - /*1*/ { PD_FLOAT, &controlEditOrig.x, "origx", PDO_DIM, &r_1000_1000, N_("Origin X") }, + /*1*/ { PD_FLOAT, &controlEditOrig.x, "origx", PDO_DIM, &r_1000_1000, N_("Origin X") }, #define I_ORIGY (2) - /*2*/ { PD_FLOAT, &controlEditOrig.y, "origy", PDO_DIM, &r_1000_1000, N_("Origin Y") }, + /*2*/ { PD_FLOAT, &controlEditOrig.y, "origy", PDO_DIM, &r_1000_1000, N_("Origin Y") }, #define I_CONTROLONSCRIPT (3) - /*3*/ { PD_STRING, controlEditOnScript, "script", PDO_NOPREF, I2VP(350), N_("On Script"), 0, 0, sizeof(controlEditOnScript)}, + /*3*/ { PD_STRING, controlEditOnScript, "script", PDO_NOPREF, I2VP(350), N_("On Script"), 0, 0, sizeof(controlEditOnScript)}, #define I_CONTROLOFFSCRIPT (4) - /*4*/ { PD_STRING, controlEditOffScript, "script", PDO_NOPREF, I2VP(350), N_("Off Script"), 0, 0, sizeof(controlEditOffScript)}, + /*4*/ { PD_STRING, controlEditOffScript, "script", PDO_NOPREF, I2VP(350), N_("Off Script"), 0, 0, sizeof(controlEditOffScript)}, }; static paramGroup_t controlEditPG = { "controlEdit", 0, controlEditPLs, COUNT( controlEditPLs ) }; @@ -435,115 +438,120 @@ static wWin_p controlEditW; static void ControlEditOk ( void * junk ) { - track_p trk; - controlData_p xx; - - if (controlEditTrack == NULL) { - UndoStart( _("Create Control"), "Create Control"); - trk = NewTrack(0, T_CONTROL, 0, sizeof(controlData_t)); - } else { - UndoStart( _("Modify Control"), "Modify Control"); - trk = controlEditTrack; - } - xx = GetcontrolData(trk); - xx->orig = controlEditOrig; - if ( xx->name == NULL || strncmp (xx->name, controlEditName, STR_SHORT_SIZE) != 0) { - MyFree(xx->name); - xx->name = MyStrdup(controlEditName); - } - if ( xx->onscript == NULL || strncmp (xx->onscript, controlEditOnScript, STR_LONG_SIZE) != 0) { - MyFree(xx->onscript); - xx->onscript = MyStrdup(controlEditOnScript); - } - if ( xx->offscript == NULL || strncmp (xx->offscript, controlEditOffScript, STR_LONG_SIZE) != 0) { - MyFree(xx->offscript); - xx->offscript = MyStrdup(controlEditOffScript); - } - UndoEnd(); - ComputeControlBoundingBox(trk); - DoRedraw(); - wHide( controlEditW ); + track_p trk; + controlData_p xx; + + if (controlEditTrack == NULL) { + UndoStart( _("Create Control"), "Create Control"); + trk = NewTrack(0, T_CONTROL, 0, sizeof(controlData_t)); + } else { + UndoStart( _("Modify Control"), "Modify Control"); + trk = controlEditTrack; + } + xx = GetcontrolData(trk); + xx->orig = controlEditOrig; + if ( xx->name == NULL + || strncmp (xx->name, controlEditName, STR_SHORT_SIZE) != 0) { + MyFree(xx->name); + xx->name = MyStrdup(controlEditName); + } + if ( xx->onscript == NULL + || strncmp (xx->onscript, controlEditOnScript, STR_LONG_SIZE) != 0) { + MyFree(xx->onscript); + xx->onscript = MyStrdup(controlEditOnScript); + } + if ( xx->offscript == NULL + || strncmp (xx->offscript, controlEditOffScript, STR_LONG_SIZE) != 0) { + MyFree(xx->offscript); + xx->offscript = MyStrdup(controlEditOffScript); + } + UndoEnd(); + ComputeControlBoundingBox(trk); + DoRedraw(); + wHide( controlEditW ); } #if 0 static void ControlEditCancel ( wWin_p junk ) { - wHide( controlEditW ); + wHide( controlEditW ); } #endif static void EditControlDialog() { - controlData_p xx; - - if ( !controlEditW ) { - ParamRegister( &controlEditPG ); - controlEditW = ParamCreateDialog (&controlEditPG, - MakeWindowTitle(_("Edit control")), - _("Ok"), ControlEditOk, - wHide, TRUE, NULL, - F_BLOCK, - NULL ); - } - if (controlEditTrack == NULL) { - controlEditName[0] = '\0'; - controlEditOnScript[0] = '\0'; - controlEditOffScript[0] = '\0'; - } else { - xx = GetcontrolData ( controlEditTrack ); - strncpy(controlEditName,xx->name,STR_SHORT_SIZE); - strncpy(controlEditOnScript,xx->onscript,STR_LONG_SIZE); - strncpy(controlEditOffScript,xx->offscript,STR_LONG_SIZE); - controlEditOrig = xx->orig; - } - ParamLoadControls( &controlEditPG ); - wShow( controlEditW ); + controlData_p xx; + + if ( !controlEditW ) { + ParamRegister( &controlEditPG ); + controlEditW = ParamCreateDialog (&controlEditPG, + MakeWindowTitle(_("Edit control")), + _("Ok"), ControlEditOk, + wHide, TRUE, NULL, + F_BLOCK, + NULL ); + } + if (controlEditTrack == NULL) { + controlEditName[0] = '\0'; + controlEditOnScript[0] = '\0'; + controlEditOffScript[0] = '\0'; + } else { + xx = GetcontrolData ( controlEditTrack ); + strncpy(controlEditName,xx->name,STR_SHORT_SIZE-1); + strncpy(controlEditOnScript,xx->onscript,STR_LONG_SIZE-1); + strncpy(controlEditOffScript,xx->offscript,STR_LONG_SIZE-1); + controlEditOrig = xx->orig; + } + ParamLoadControls( &controlEditPG ); + wShow( controlEditW ); } static void EditControl (track_p trk) { - controlEditTrack = trk; - EditControlDialog(); + controlEditTrack = trk; + EditControlDialog(); } static void CreateNewControl (coOrd orig) { - controlEditOrig = orig; - controlEditTrack = NULL; - EditControlDialog(); + controlEditOrig = orig; + controlEditTrack = NULL; + EditControlDialog(); } static STATUS_T CmdControl ( wAction_t action, coOrd pos ) { - - static coOrd control_pos; - static BOOL_T create; - switch (action) { - case C_START: - InfoMessage(_("Place control")); - SetAllTrackSelect( FALSE ); - create = FALSE; - return C_CONTINUE; - case C_DOWN: - create = TRUE; - /* no break */ + + static coOrd control_pos; + static BOOL_T create; + switch (action) { + case C_START: + InfoMessage(_("Place control")); + SetAllTrackSelect( FALSE ); + create = FALSE; + return C_CONTINUE; + case C_DOWN: + create = TRUE; + /* no break */ case C_MOVE: SnapPos(&pos); control_pos = pos; - return C_CONTINUE; - case C_UP: - SnapPos(&pos); - CreateNewControl(pos); - return C_TERMINATE; - case C_REDRAW: - if (create) - DDrawControl( &tempD, control_pos, GetScaleRatio(GetLayoutCurScale()), wDrawColorBlack ); - return C_CONTINUE; - case C_CANCEL: - return C_CONTINUE; - default: - return C_CONTINUE; - } + return C_CONTINUE; + case C_UP: + SnapPos(&pos); + CreateNewControl(pos); + return C_TERMINATE; + case C_REDRAW: + if (create) { + DDrawControl( &tempD, control_pos, GetScaleRatio(GetLayoutCurScale()), + wDrawColorBlack ); + } + return C_CONTINUE; + case C_CANCEL: + return C_CONTINUE; + default: + return C_CONTINUE; + } } static coOrd ctlhiliteOrig, ctlhiliteSize; @@ -551,92 +559,95 @@ static POS_T ctlhiliteBorder; static wDrawColor ctlhiliteColor = 0; static void DrawControlTrackHilite( void ) { - if (ctlhiliteColor==0) + if (ctlhiliteColor==0) { ctlhiliteColor = wDrawColorGray(87); - DrawRectangle( &tempD, ctlhiliteOrig, ctlhiliteSize, ctlhiliteColor, DRAW_TRANSPARENT ); + } + DrawRectangle( &tempD, ctlhiliteOrig, ctlhiliteSize, ctlhiliteColor, + DRAW_TRANSPARENT ); } static int ControlMgmProc ( int cmd, void * data ) { - track_p trk = (track_p) data; - controlData_p xx = GetcontrolData(trk); - /*char msg[STR_SIZE];*/ - - switch ( cmd ) { - case CONTMGM_CAN_EDIT: - return TRUE; - break; - case CONTMGM_DO_EDIT: - EditControl(trk); - return TRUE; - break; - case CONTMGM_CAN_DELETE: - return TRUE; - break; - case CONTMGM_DO_DELETE: - DeleteTrack(trk, FALSE); - return TRUE; - break; - case CONTMGM_DO_HILIGHT: - if (!xx->IsHilite) { - ctlhiliteBorder = mainD.scale*0.1; - if ( ctlhiliteBorder < trackGauge ) ctlhiliteBorder = trackGauge; - GetBoundingBox( trk, &ctlhiliteSize, &ctlhiliteOrig ); - ctlhiliteOrig.x -= ctlhiliteBorder; - ctlhiliteOrig.y -= ctlhiliteBorder; - ctlhiliteSize.x -= ctlhiliteOrig.x-ctlhiliteBorder; - ctlhiliteSize.y -= ctlhiliteOrig.y-ctlhiliteBorder; - DrawControlTrackHilite(); - xx->IsHilite = TRUE; - } - break; - case CONTMGM_UN_HILIGHT: - if (xx->IsHilite) { - ctlhiliteBorder = mainD.scale*0.1; - if ( ctlhiliteBorder < trackGauge ) ctlhiliteBorder = trackGauge; - GetBoundingBox( trk, &ctlhiliteSize, &ctlhiliteOrig ); - ctlhiliteOrig.x -= ctlhiliteBorder; - ctlhiliteOrig.y -= ctlhiliteBorder; - ctlhiliteSize.x -= ctlhiliteOrig.x-ctlhiliteBorder; - ctlhiliteSize.y -= ctlhiliteOrig.y-ctlhiliteBorder; - DrawControlTrackHilite(); - xx->IsHilite = FALSE; - } - break; - case CONTMGM_GET_TITLE: - sprintf(message,"\t%s\t",xx->name); - break; - } - return FALSE; + track_p trk = (track_p) data; + controlData_p xx = GetcontrolData(trk); + /*char msg[STR_SIZE];*/ + + switch ( cmd ) { + case CONTMGM_CAN_EDIT: + return TRUE; + break; + case CONTMGM_DO_EDIT: + EditControl(trk); + return TRUE; + break; + case CONTMGM_CAN_DELETE: + return TRUE; + break; + case CONTMGM_DO_DELETE: + DeleteTrack(trk, FALSE); + return TRUE; + break; + case CONTMGM_DO_HILIGHT: + if (!xx->IsHilite) { + ctlhiliteBorder = mainD.scale*0.1; + if ( ctlhiliteBorder < trackGauge ) { ctlhiliteBorder = trackGauge; } + GetBoundingBox( trk, &ctlhiliteSize, &ctlhiliteOrig ); + ctlhiliteOrig.x -= ctlhiliteBorder; + ctlhiliteOrig.y -= ctlhiliteBorder; + ctlhiliteSize.x -= ctlhiliteOrig.x-ctlhiliteBorder; + ctlhiliteSize.y -= ctlhiliteOrig.y-ctlhiliteBorder; + DrawControlTrackHilite(); + xx->IsHilite = TRUE; + } + break; + case CONTMGM_UN_HILIGHT: + if (xx->IsHilite) { + ctlhiliteBorder = mainD.scale*0.1; + if ( ctlhiliteBorder < trackGauge ) { ctlhiliteBorder = trackGauge; } + GetBoundingBox( trk, &ctlhiliteSize, &ctlhiliteOrig ); + ctlhiliteOrig.x -= ctlhiliteBorder; + ctlhiliteOrig.y -= ctlhiliteBorder; + ctlhiliteSize.x -= ctlhiliteOrig.x-ctlhiliteBorder; + ctlhiliteSize.y -= ctlhiliteOrig.y-ctlhiliteBorder; + DrawControlTrackHilite(); + xx->IsHilite = FALSE; + } + break; + case CONTMGM_GET_TITLE: + sprintf(message,"\t%s\t",xx->name); + break; + } + return FALSE; } -#include "bitmaps/control.xpm" +#include "bitmaps/control.xpm3" EXPORT void ControlMgmLoad ( void ) { - track_p trk; - static wIcon_p controlI = NULL; - - if (controlI == NULL) { - controlI = wIconCreatePixMap( control_xpm[iconSize] ); - } - - TRK_ITERATE(trk) { - if (GetTrkType(trk) != T_CONTROL) continue; - ContMgmLoad (controlI, ControlMgmProc, trk ); - } + track_p trk; + static wIcon_p controlI = NULL; + + if (controlI == NULL) { + controlI = wIconCreatePixMap( control_xpm3[iconSize] ); + } + + TRK_ITERATE(trk) { + if (GetTrkType(trk) != T_CONTROL) { continue; } + ContMgmLoad (controlI, ControlMgmProc, trk ); + } } #define ACCL_CONTROL 0 EXPORT void InitCmdControl ( wMenu_p menu ) { - AddMenuButton( menu, CmdControl, "cmdControl", _("Control"), - wIconCreatePixMap( control_xpm[iconSize] ), LEVEL0_50, IC_STICKY|IC_POPUP2, ACCL_CONTROL, NULL ); + AddMenuButton( menu, CmdControl, "cmdControl", _("Control"), + wIconCreatePixMap( control_xpm3[iconSize] ), LEVEL0_50, IC_STICKY|IC_POPUP2, + ACCL_CONTROL, NULL ); } EXPORT void InitTrkControl ( void ) { - T_CONTROL = InitObject ( &controlCmds ); - log_control = LogFindIndex ( "control" ); + T_CONTROL = InitObject ( &controlCmds ); + log_control = LogFindIndex ( "control" ); } diff --git a/app/bin/ccornu.c b/app/bin/ccornu.c index f447d64..9e721d8 100644 --- a/app/bin/ccornu.c +++ b/app/bin/ccornu.c @@ -63,7 +63,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -87,9 +87,6 @@ #include "fileio.h" #include "common-ui.h" -extern drawCmd_t tempD; -extern TRKTYP_T T_BEZIER; -extern TRKTYP_T T_CORNU; typedef struct { coOrd end_center; @@ -106,66 +103,67 @@ typedef struct { * STATE INFO */ enum Cornu_States { NONE, - POS_1, - LOC_2, - POS_2, - PICK_POINT, - POINT_PICKED, - TRACK_SELECTED }; + POS_1, + LOC_2, + POS_2, + PICK_POINT, + POINT_PICKED, + TRACK_SELECTED + }; typedef enum {CORNU_MODIFY, CORNU_CREATE} cornuCmdType_e; static struct { - enum Cornu_States state; - coOrd pos[2]; - int number_of_points; - int selectEndPoint; - int selectMidPoint; - int selectEndHandle; - int prevSelected; - int prevEndPoint; - DIST_T width; - track_p trk[2]; - EPINX_T ep[2]; - DIST_T radius[2]; - ANGLE_T angle[2]; - ANGLE_T arcA0[2]; - ANGLE_T arcA1[2]; - coOrd center[2]; - curveType_e trackType[2]; - - BOOL_T extend[2]; - trkSeg_t extendSeg[2]; - - trkSeg_t ep1Segs[11]; - int ep1Segs_da_cnt; - trkSeg_t ep2Segs[11]; - int ep2Segs_da_cnt; - dynArr_t crvSegs_da; - int crvSegs_da_cnt; - trkSeg_t trk1Seg; - trkSeg_t trk2Seg; - track_p selectTrack; - DIST_T minRadius; - BOOL_T circleorHelix[2]; - DIST_T trackGauge; - - int cmdType; - - dynArr_t midSegs; - - dynArr_t mid_points; - dynArr_t tracks; - BOOL_T ends[2]; - - endHandle endHandle[2]; - - bezctx * bezc; - - cornuCmdType_e commandType; - - } Da; + enum Cornu_States state; + coOrd pos[4]; + int number_of_points; + int selectEndPoint; + int selectMidPoint; + int selectEndHandle; + int prevSelected; + int prevEndPoint; + LWIDTH_T lineWidth; + track_p trk[2]; + EPINX_T ep[2]; + DIST_T radius[2]; + ANGLE_T angle[2]; + ANGLE_T arcA0[2]; + ANGLE_T arcA1[2]; + coOrd center[2]; + curveType_e trackType[2]; + + BOOL_T extend[2]; + trkSeg_t extendSeg[2]; + + trkSeg_t ep1Segs[11]; + int ep1Segs_da_cnt; + trkSeg_t ep2Segs[11]; + int ep2Segs_da_cnt; + dynArr_t crvSegs_da; + int crvSegs_da_cnt; + trkSeg_t trk1Seg; + trkSeg_t trk2Seg; + track_p selectTrack; + DIST_T minRadius; + BOOL_T circleorHelix[2]; + DIST_T trackGauge; + + int cmdType; + + dynArr_t midSegs; + + dynArr_t mid_points; + dynArr_t tracks; + BOOL_T ends[2]; + + endHandle endHandle[2]; + + bezctx * bezc; + + cornuCmdType_e commandType; + +} Da; static trkSeg_p curCornu; static wIndex_t cornuHotBarCmdInx; @@ -179,10 +177,10 @@ static struct { static char * CmdCornuHotBarProc( - hotBarProc_e op, - void * data, - drawCmd_p d, - coOrd * origP ) + hotBarProc_e op, + void * data, + drawCmd_p d, + coOrd * origP ) { trkSeg_p trkseg = &hotB.st; switch ( op ) { @@ -259,15 +257,16 @@ EXPORT void AddHotBarCornu( void ) //end.y = 21.25; hotB.count = 3; //hotB.st.u.l.pos[1] = end; - AddHotBarElement( label, end, zero, TRUE, TRUE, curBarScale>0?curBarScale:-1, &hotB, CmdCornuHotBarProc ); + AddHotBarElement( label, end, zero, TRUE, TRUE, curBarScale>0?curBarScale:-1, + &hotB, CmdCornuHotBarProc ); } int createMidPoint(dynArr_t * ap, - coOrd pos0, //end on curve - BOOL_T point_selected, - BOOL_T point_selectable, - BOOL_T track_modifyable - ) + coOrd pos0, //end on curve + BOOL_T point_selected, + BOOL_T point_selectable, + BOOL_T track_modifyable + ) { DIST_T d, w; d = tempD.scale*0.25; @@ -282,7 +281,7 @@ int createMidPoint(dynArr_t * ap, sp->u.c.a1 = 360.0; sp->u.c.radius = d/2; sp->type = point_selected?SEG_FILCRCL:SEG_CRVLIN; - sp->width = w; + sp->lineWidth = w; sp->color = drawColorBlack; return 1; @@ -295,87 +294,97 @@ int createMidPoint(dynArr_t * ap, * A Cornu end Point has a filled circle surrounded by another circle for endpoint */ int createEndPoint( - trkSeg_t sp[], //seg pointer for up to 2 trkSegs (ends and line) - coOrd pos0, //end on curve - BOOL_T point_selected, - BOOL_T point_selectable, - BOOL_T track_modifyable, - BOOL_T track_present, - ANGLE_T angle, - DIST_T radius, - coOrd centert, - endHandle * endHandle - ) + trkSeg_t sp[], //seg pointer for up to 2 trkSegs (ends and line) + coOrd pos0, //end on curve + BOOL_T point_selected, + BOOL_T point_selectable, + BOOL_T track_modifyable, + BOOL_T track_present, + ANGLE_T angle, + DIST_T radius, + coOrd centert, + endHandle * endHandle +) { - DIST_T d, w; - int num =0; - d = tempD.scale*0.25; - w = tempD.scale/tempD.dpi; /*double width*/ - num = 1; - if (point_selectable) { + DIST_T d, w; + int num =0; + d = tempD.scale*0.25; + w = tempD.scale/tempD.dpi; /*double width*/ + num = 1; + if (point_selectable) { sp[1].u.c.center = pos0; sp[1].u.c.a0 = 0.0; sp[1].u.c.a1 = 360.0; sp[1].u.c.radius = d/2; sp[1].type = SEG_CRVLIN; - sp[1].width = w; + sp[1].lineWidth = w; sp[1].color = point_selected?drawColorBlue:drawColorRed; num = 2; - } - sp[0].u.c.center = pos0; - sp[0].u.c.a0 = 0.0; - sp[0].u.c.a1 = 360.0; - sp[0].width = w; - sp[0].u.c.radius = d/4; - sp[0].color = point_selected?drawColorBlue:drawColorRed; - if (track_modifyable) - sp[0].type = SEG_CRVLIN; - else - sp[0].type = SEG_FILCRCL; - if (!track_present && endHandle ) { - endHandle->end_center = zero; - endHandle->end_curve = zero; - endHandle->end_valid = TRUE; - endHandle->mid_disp = 0.0; - DIST_T end_length = tempD.scale*2.0; - Translate(&endHandle->end_curve,pos0,angle,end_length); - Translate(&endHandle->end_center,pos0,angle,end_length/2); - if (radius>0.0) { - ANGLE_T a1 = R2D(end_length/radius); - if (DifferenceBetweenAngles(angle,FindAngle(centert,pos0))>0.0) { - a1 = -a1; - } - PointOnCircle( &endHandle->end_curve, centert,radius,NormalizeAngle(FindAngle(centert,pos0)+a1)); - PointOnCircle( &endHandle->end_center,centert,radius,NormalizeAngle(FindAngle(centert,pos0)+(a1/2.0))); + } + sp[0].u.c.center = pos0; + sp[0].u.c.a0 = 0.0; + sp[0].u.c.a1 = 360.0; + sp[0].lineWidth = w; + sp[0].u.c.radius = d/4; + sp[0].color = point_selected?drawColorBlue:drawColorRed; + if (track_modifyable) { + sp[0].type = SEG_CRVLIN; + } else { + sp[0].type = SEG_FILCRCL; + } + if (!track_present && endHandle ) { + endHandle->end_center = zero; + endHandle->end_curve = zero; + endHandle->end_valid = TRUE; + endHandle->mid_disp = 0.0; + DIST_T end_length = tempD.scale*2.0; + Translate(&endHandle->end_curve,pos0,angle,end_length); + Translate(&endHandle->end_center,pos0,angle,end_length/2); + if (radius>0.0) { + ANGLE_T a1 = R2D(end_length/radius); + if (DifferenceBetweenAngles(angle,FindAngle(centert,pos0))>0.0) { + a1 = -a1; + } + PointOnCircle( &endHandle->end_curve, centert,radius, + NormalizeAngle(FindAngle(centert,pos0)+a1)); + PointOnCircle( &endHandle->end_center,centert,radius, + NormalizeAngle(FindAngle(centert,pos0)+(a1/2.0))); coOrd cm; cm = endHandle->end_center; ANGLE_T a = FindAngle(endHandle->end_curve,pos0); Rotate(&cm,endHandle->end_curve,-a ); endHandle->mid_disp = cm.x-endHandle->end_curve.x; curveData_t curveData; - PlotCurve(crvCmdFromCenter,pos0,endHandle->end_center, endHandle->end_curve, &curveData, FALSE, 0.0); + PlotCurve(crvCmdFromCenter,pos0,endHandle->end_center, endHandle->end_curve, + &curveData, FALSE, 0.0); if (curveData.type == curveTypeStraight) { coOrd pos_line[2]; - Translate(&pos_line[0],pos0,FindAngle(pos0,endHandle->end_curve)+90,trackGauge/2); - Translate(&pos_line[1],endHandle->end_curve,FindAngle(pos0,endHandle->end_curve)+90,trackGauge/2); + Translate(&pos_line[0],pos0,FindAngle(pos0,endHandle->end_curve)+90, + trackGauge/2); + Translate(&pos_line[1],endHandle->end_curve,FindAngle(pos0, + endHandle->end_curve)+90,trackGauge/2); sp[num].type = SEG_STRLIN; - sp[num].width = w; + sp[num].lineWidth = w; sp[num].u.l.pos[0] = pos_line[0]; sp[num].u.l.pos[1] = pos_line[1]; - sp[num].color = (endHandle->last_selected||endHandle->radius_selected)?drawColorBlue:drawColorRed; + sp[num].color = (endHandle->last_selected + ||endHandle->radius_selected)?drawColorBlue:drawColorRed; num++; - Translate(&pos_line[0],pos0,FindAngle(pos0,endHandle->end_curve)-90,trackGauge/2); - Translate(&pos_line[1],endHandle->end_curve,FindAngle(pos0,endHandle->end_curve)-90,trackGauge/2); + Translate(&pos_line[0],pos0,FindAngle(pos0,endHandle->end_curve)-90, + trackGauge/2); + Translate(&pos_line[1],endHandle->end_curve,FindAngle(pos0, + endHandle->end_curve)-90,trackGauge/2); sp[num].type = SEG_STRLIN; - sp[num].width = w; + sp[num].lineWidth = w; sp[num].u.l.pos[0] = pos_line[0]; sp[num].u.l.pos[1] = pos_line[1]; - sp[num].color = (endHandle->last_selected||endHandle->radius_selected)?drawColorBlue:drawColorRed; + sp[num].color = (endHandle->last_selected + ||endHandle->radius_selected)?drawColorBlue:drawColorRed; num++; pos_line[0]= pos0; Translate(&pos_line[1],pos0,-FindAngle(pos0,endHandle->end_curve),end_length); sp[num].type = SEG_STRLIN; - sp[num].width = w; + sp[num].lineWidth = w; sp[num].u.l.pos[0] = pos_line[0]; sp[num].u.l.pos[1] = pos_line[1]; sp[num].color = drawColorRed; @@ -384,7 +393,7 @@ int createEndPoint( DIST_T pos_rad; pos_rad = radius+trackGauge/2; sp[num].type = SEG_CRVLIN; - sp[num].width = w; + sp[num].lineWidth = w; sp[num].u.c.center = centert; sp[num].u.c.radius = pos_rad; ANGLE_T an0 = FindAngle(centert,pos0); @@ -397,43 +406,51 @@ int createEndPoint( sp[num].u.c.a0 = an1; } endHandle->arc_angle = sp[num].u.c.a1; - sp[num].color = (endHandle->last_selected||endHandle->radius_selected)?drawColorBlue:drawColorRed; + sp[num].color = (endHandle->last_selected + ||endHandle->radius_selected)?drawColorBlue:drawColorRed; num++; pos_rad = radius-trackGauge/2; sp[num].type = SEG_CRVLIN; - sp[num].width = w; + sp[num].lineWidth = w; sp[num].u.c.center = centert; sp[num].u.c.radius = pos_rad; sp[num].u.c.a1 = sp[num-1].u.c.a1; sp[num].u.c.a0 = sp[num-1].u.c.a0; - sp[num].color = (endHandle->last_selected||endHandle->radius_selected)?drawColorBlue:drawColorRed; + sp[num].color = (endHandle->last_selected + ||endHandle->radius_selected)?drawColorBlue:drawColorRed; num++; } - } else { - coOrd pos_line[2]; - Translate(&pos_line[0],pos0,FindAngle(pos0,endHandle->end_curve)+90,trackGauge/2); - Translate(&pos_line[1],endHandle->end_curve,FindAngle(pos0,endHandle->end_curve)+90,trackGauge/2); - sp[num].type = SEG_STRLIN; - sp[num].width = w; + } else { + coOrd pos_line[2]; + Translate(&pos_line[0],pos0,FindAngle(pos0,endHandle->end_curve)+90, + trackGauge/2); + Translate(&pos_line[1],endHandle->end_curve,FindAngle(pos0, + endHandle->end_curve)+90,trackGauge/2); + sp[num].type = SEG_STRLIN; + sp[num].lineWidth = w; sp[num].u.l.pos[0] = pos_line[0]; sp[num].u.l.pos[1] = pos_line[1]; - sp[num].color = (endHandle->last_selected||endHandle->radius_selected)?drawColorBlue:drawColorRed; + sp[num].color = (endHandle->last_selected + ||endHandle->radius_selected)?drawColorBlue:drawColorRed; num++; - Translate(&pos_line[0],pos0,FindAngle(pos0,endHandle->end_curve)-90,trackGauge/2); - Translate(&pos_line[1],endHandle->end_curve,FindAngle(pos0,endHandle->end_curve)-90,trackGauge/2); + Translate(&pos_line[0],pos0,FindAngle(pos0,endHandle->end_curve)-90, + trackGauge/2); + Translate(&pos_line[1],endHandle->end_curve,FindAngle(pos0, + endHandle->end_curve)-90,trackGauge/2); sp[num].type = SEG_STRLIN; - sp[num].width = w; + sp[num].lineWidth = w; sp[num].u.l.pos[0] = pos_line[0]; sp[num].u.l.pos[1] = pos_line[1]; - sp[num].color = (endHandle->last_selected||endHandle->radius_selected)?drawColorBlue:drawColorRed; + sp[num].color = (endHandle->last_selected + ||endHandle->radius_selected)?drawColorBlue:drawColorRed; num++; - } - coOrd pos_line[2]; - pos_line[0]= pos0; + } + coOrd pos_line[2]; + pos_line[0]= pos0; Translate(&pos_line[1],pos0,angle+180,end_length); sp[num].type = SEG_STRLIN; - sp[num].width = w; + sp[num].lineWidth = w; sp[num].u.l.pos[0] = pos_line[0]; sp[num].u.l.pos[1] = pos_line[1]; sp[num].color = drawColorRed; @@ -442,25 +459,30 @@ int createEndPoint( sp[num].u.c.center = endHandle->end_curve; sp[num].u.c.a0 = 0.0; sp[num].u.c.a1 = 360.0; - sp[num].width = w; + sp[num].lineWidth = w; sp[num].u.c.radius = d/4; sp[num].color = endHandle->angle_selected?drawColorBlue:drawColorRed; num++; - if (radius<=0.0) - DrawArrowHeads(&sp[num],endHandle->end_center,angle+90.0,TRUE,endHandle->radius_selected?drawColorBlue:drawColorRed); - else - DrawArrowHeads(&sp[num],endHandle->end_center,FindAngle(centert,endHandle->end_center),TRUE,endHandle->radius_selected?drawColorBlue:drawColorRed); + if (radius<=0.0) { + DrawArrowHeads(&sp[num],endHandle->end_center,angle+90.0,TRUE, + endHandle->radius_selected?drawColorBlue:drawColorRed); + } else { + DrawArrowHeads(&sp[num],endHandle->end_center,FindAngle(centert, + endHandle->end_center),TRUE, + endHandle->radius_selected?drawColorBlue:drawColorRed); + } num=num+5; - } else if (endHandle) { - endHandle->end_valid=FALSE; - } - return num; + } else if (endHandle) { + endHandle->end_valid=FALSE; + } + return num; } static dynArr_t anchors_da; #define anchors(N) DYNARR_N(trkSeg_t,anchors_da,N) -static void CreateCornuEndAnchor(coOrd p, wBool_t lock) { +static void CreateCornuEndAnchor(coOrd p, wBool_t lock) +{ DIST_T d = tempD.scale*0.15; DYNARR_APPEND(trkSeg_t,anchors_da,1); @@ -471,7 +493,7 @@ static void CreateCornuEndAnchor(coOrd p, wBool_t lock) { anchors(i).u.c.radius = d/2; anchors(i).u.c.a0 = 0.0; anchors(i).u.c.a1 = 360.0; - anchors(i).width = 0; + anchors(i).lineWidth = 0; DYNARR_APPEND(trkSeg_t,anchors_da,1); i = anchors_da.cnt-1; anchors(i).type = SEG_CRVLIN; @@ -480,15 +502,18 @@ static void CreateCornuEndAnchor(coOrd p, wBool_t lock) { anchors(i).u.c.radius = d; anchors(i).u.c.a0 = 0.0; anchors(i).u.c.a1 = 360.0; - anchors(i).width = 0; + anchors(i).lineWidth = 0; } -static void CreateCornuExtendAnchor(coOrd p, ANGLE_T a, wBool_t selected) { +static void CreateCornuExtendAnchor(coOrd p, ANGLE_T a, wBool_t selected) +{ DYNARR_SET(trkSeg_t,anchors_da,anchors_da.cnt+5); - DrawArrowHeads(&DYNARR_N(trkSeg_t,anchors_da,anchors_da.cnt-5),p,a,FALSE,wDrawColorBlue); + DrawArrowHeads(&DYNARR_N(trkSeg_t,anchors_da,anchors_da.cnt-5),p,a,FALSE, + wDrawColorBlue); } -static void CreateCornuAnchor(coOrd p, wBool_t open) { +static void CreateCornuAnchor(coOrd p, wBool_t open) +{ DIST_T d = tempD.scale*0.15; DYNARR_APPEND(trkSeg_t,anchors_da,1); int i = anchors_da.cnt-1; @@ -498,39 +523,40 @@ static void CreateCornuAnchor(coOrd p, wBool_t open) { anchors(i).u.c.radius = d/2; anchors(i).u.c.a0 = 0.0; anchors(i).u.c.a1 = 360.0; - anchors(i).width = 0; + anchors(i).lineWidth = 0; } /* * Add element to DYNARR pointed to by caller from segment handed in */ -void addSegCornu(dynArr_t * const array_p, trkSeg_p seg) { +void addSegCornu(dynArr_t * const array_p, trkSeg_p seg) +{ trkSeg_p s; DYNARR_APPEND(trkSeg_t, * array_p, 10); //Adds 1 to cnt s = &DYNARR_N(trkSeg_t,* array_p,array_p->cnt-1); s->type = seg->type; - s->bezSegs.max = 0; - s->bezSegs.cnt = 0; - if (s->bezSegs.ptr) MyFree(s->bezSegs.ptr); - s->bezSegs.ptr = NULL; + DYNARR_FREE( trkSeg, s->bezSegs ); s->color = seg->color; - s->width = seg->width; + s->lineWidth = seg->lineWidth; if ((s->type == SEG_BEZLIN || s->type == SEG_BEZTRK) && seg->bezSegs.cnt) { s->u.b.angle0 = seg->u.b.angle0; //Copy all the rest s->u.b.angle3 = seg->u.b.angle3; s->u.b.length = seg->u.b.length; s->u.b.minRadius = seg->u.b.minRadius; - for (int i=0;i<4;i++) s->u.b.pos[i] = seg->u.b.pos[i]; + for (int i=0; i<4; i++) { s->u.b.pos[i] = seg->u.b.pos[i]; } s->u.b.radius0 = seg->u.b.radius3; for (int i = 0; i<seg->bezSegs.cnt; i++) { - addSegCornu(&s->bezSegs, (((trkSeg_p)seg->bezSegs.ptr) + i)); //recurse for copying embedded Beziers as in Cornu joint + //recurse for copying embedded Beziers as in Cornu joint + addSegCornu(&s->bezSegs, + &DYNARR_N(trkSeg_t,seg->bezSegs,i)); } } else { s->u = seg->u; } } -EXPORT void SetKnots(spiro_cp knots[], coOrd posk[], char type[], int count) { +EXPORT void SetKnots(spiro_cp knots[], coOrd posk[], char type[], int count) +{ for (int i = 0; i < count; i++) { knots[i].x = posk[i].x; knots[i].y = posk[i].y; @@ -547,8 +573,10 @@ typedef struct { // G2 (position only k1'' = k2'' = 0); Also Cornu <-> Cornu // G4 (position only - splitable for Cornu - a G4 point) k1''= k2'' -BOOL_T CallCornuM(dynArr_t extra_points, BOOL_T end[2], coOrd pos[2], cornuParm_t * cp, dynArr_t * array_p, BOOL_T spots) { - array_p->cnt = 0; +BOOL_T CallCornuM(dynArr_t extra_points, BOOL_T end[2], coOrd pos[2], + cornuParm_t * cp, dynArr_t * array_p, BOOL_T spots) +{ + DYNARR_RESET( trkSeg_t, *array_p ); //Create LH knots //Find remote end point of track, create start knot int ends[2]; @@ -562,7 +590,7 @@ BOOL_T CallCornuM(dynArr_t extra_points, BOOL_T end[2], coOrd pos[2], cornuParm_ BOOL_T back; ANGLE_T angle1; - if (Da.bezc) free(Da.bezc); + if (Da.bezc) { free(Da.bezc); } Da.bezc = new_bezctx_xtrkcad(array_p,ends,spots,tempD.scale*0.15/4); @@ -577,8 +605,8 @@ BOOL_T CallCornuM(dynArr_t extra_points, BOOL_T end[2], coOrd pos[2], cornuParm_ Translate(&posk[1],pos0,cp->angle[0],5); } else { angle1 = FindAngle(cp->center[0],pos[0]); - if (NormalizeAngle(angle1 - cp->angle[0])<180) back = TRUE; - else back = FALSE; + if (NormalizeAngle(angle1 - cp->angle[0])<180) { back = TRUE; } + else { back = FALSE; } posk[0] = pos[0]; Rotate(&posk[0],cp->center[0],(back)?-10:10); posk[1] = pos[0]; @@ -590,12 +618,12 @@ BOOL_T CallCornuM(dynArr_t extra_points, BOOL_T end[2], coOrd pos[2], cornuParm_ posk[0] = pos[0]; } - for (int i=0;i<extra_points.cnt;i++) { - posk[(end[0]?3:1)+i] = DYNARR_N(coOrd,extra_points,i); - type[(end[0]?3:1)+i] = SPIRO_G4; - } + for (int i=0; i<extra_points.cnt; i++) { + posk[(end[0]?3:1)+i] = DYNARR_N(coOrd,extra_points,i); + type[(end[0]?3:1)+i] = SPIRO_G4; + } - posk[(end[0]?3:1)+extra_points.cnt] = pos[1]; + posk[(end[0]?3:1)+extra_points.cnt] = pos[1]; coOrd pos1 = pos[1]; if (end[1]) { @@ -607,8 +635,8 @@ BOOL_T CallCornuM(dynArr_t extra_points, BOOL_T end[2], coOrd pos[2], cornuParm_ Translate(&posk[(end[0]?3:1)+extra_points.cnt+2],pos1,cp->angle[1],10); } else { angle1 = FindAngle(cp->center[1],pos[1]); - if (NormalizeAngle(angle1 - cp->angle[1])>180) back = TRUE; - else back = FALSE; + if (NormalizeAngle(angle1 - cp->angle[1])>180) { back = TRUE; } + else { back = FALSE; } posk[(end[0]?3:1)+extra_points.cnt+1] = pos[1]; Rotate(&posk[(end[0]?3:1)+extra_points.cnt+1],cp->center[1],(back)?5:-5); posk[(end[0]?3:1)+extra_points.cnt+2] = pos[1]; @@ -628,8 +656,10 @@ BOOL_T CallCornuM(dynArr_t extra_points, BOOL_T end[2], coOrd pos[2], cornuParm_ return TRUE; } -EXPORT BOOL_T CallCornu0(coOrd pos[2], coOrd center[2], ANGLE_T angle[2], DIST_T radius[2], dynArr_t * array_p, BOOL_T spots) { - array_p->cnt = 0; +EXPORT BOOL_T CallCornu0(coOrd pos[2], coOrd center[2], ANGLE_T angle[2], + DIST_T radius[2], dynArr_t * array_p, BOOL_T spots) +{ + DYNARR_RESET( trkSeg_t, *array_p ); //Create LH knots //Find remote end point of track, create start knot int ends[2]; @@ -640,7 +670,7 @@ EXPORT BOOL_T CallCornu0(coOrd pos[2], coOrd center[2], ANGLE_T angle[2], DIST_T BOOL_T back; ANGLE_T angle1; - if (Da.bezc) free(Da.bezc); + if (Da.bezc) { free(Da.bezc); } Da.bezc = new_bezctx_xtrkcad(array_p,ends,spots,tempD.scale*0.15/4); @@ -653,8 +683,8 @@ EXPORT BOOL_T CallCornu0(coOrd pos[2], coOrd center[2], ANGLE_T angle[2], DIST_T Translate(&posk[1],pos0,angle[0],5); } else { angle1 = FindAngle(center[0],pos[0]); - if (NormalizeAngle(angle1 - angle[0])<180) back = TRUE; - else back = FALSE; + if (NormalizeAngle(angle1 - angle[0])<180) { back = TRUE; } + else { back = FALSE; } posk[0] = pos[0]; Rotate(&posk[0],center[0],(back)?-10:10); posk[1] = pos[0]; @@ -674,8 +704,8 @@ EXPORT BOOL_T CallCornu0(coOrd pos[2], coOrd center[2], ANGLE_T angle[2], DIST_T Translate(&posk[5],pos1,angle[1],10); } else { angle1 = FindAngle(center[1],pos[1]); - if (NormalizeAngle(angle1 - angle[1])>180) back = TRUE; - else back = FALSE; + if (NormalizeAngle(angle1 - angle[1])>180) { back = TRUE; } + else { back = FALSE; } posk[4] = pos[1]; Rotate(&posk[4],center[1],(back)?5:-5); posk[5] = pos[1]; @@ -695,36 +725,41 @@ EXPORT BOOL_T CallCornu0(coOrd pos[2], coOrd center[2], ANGLE_T angle[2], DIST_T /* * Set up the call to Cornu0. Take the conditions of the two ends from the connected tracks. */ -BOOL_T CallCornu(coOrd pos[2], track_p trk[2], EPINX_T ep[2], dynArr_t * array_p, cornuParm_t * cp) { +BOOL_T CallCornu(coOrd pos[2], track_p trk[2], EPINX_T ep[2], + dynArr_t * array_p, cornuParm_t * cp) +{ trackParams_t params; ANGLE_T angle; - for (int i=0;i<2;i++) { + for (int i=0; i<2; i++) { if (trk[i]) { - if (!GetTrackParams(PARAMS_CORNU,trk[i],pos[i],¶ms)) return FALSE; + if (!GetTrackParams(PARAMS_CORNU,trk[i],pos[i],¶ms)) { return FALSE; } cp->pos[i] = pos[i]; - if (ep && ep[i]>=0) angle = GetTrkEndAngle(trk[i],ep[i]); - else angle = params.angle; //Turntable only + if (ep && ep[i]>=0) { angle = GetTrkEndAngle(trk[i],ep[i]); } + else { angle = params.angle; } //Turntable only if (Da.circleorHelix[i]) { //Helix/Circle only cp->radius[i] = params.arcR; cp->center[i] = params.arcP; - if (ep && ep[i]>=0) cp->angle[i] = NormalizeAngle(params.track_angle+(ep[i]?180:0)); + if (ep && ep[i]>=0) { cp->angle[i] = NormalizeAngle(params.track_angle+(ep[i]?180:0)); } } else if (params.type == curveTypeStraight) { cp->angle[i] = NormalizeAngle(angle+180); //Because end always backwards cp->radius[i] = 0.0; - } else if ((params.type == curveTypeCornu || params.type == curveTypeBezier) && params.arcR == 0.0 ) { + } else if ((params.type == curveTypeCornu || params.type == curveTypeBezier) + && params.arcR == 0.0 ) { cp->radius[i] = 0.0; - if (ep && ep[i]>=0) cp->angle[i] = NormalizeAngle(params.track_angle+(ep[i]?180:0)); //Use point not end + if (ep && ep[i]>=0) { cp->angle[i] = NormalizeAngle(params.track_angle+(ep[i]?180:0)); } //Use point not end } else if (params.type == curveTypeCurve) { - if (ep && ep[i]>=0) cp->angle[i] = NormalizeAngle(params.track_angle+(ep[i]?180:0)); + if (ep && ep[i]>=0) { cp->angle[i] = NormalizeAngle(params.track_angle+(ep[i]?180:0)); } cp->radius[i] = params.arcR; cp->center[i] = params.arcP; - } else if ((params.type == curveTypeCornu || params.type == curveTypeBezier) && params.arcR != 0.0 ){ - if (ep && ep[i]>=0) cp->angle[i] = NormalizeAngle(params.track_angle+(ep[i]?180:0)); + } else if ((params.type == curveTypeCornu || params.type == curveTypeBezier) + && params.arcR != 0.0 ) { + if (ep && ep[i]>=0) { cp->angle[i] = NormalizeAngle(params.track_angle+(ep[i]?180:0)); } cp->radius[i] = params.arcR; cp->center[i] = params.arcP; } else { - cp->angle[i] = NormalizeAngle(angle+180); //Unknown - treat like straight + cp->angle[i] = NormalizeAngle(angle + +180); //Unknown - treat like straight cp->radius[i] = params.arcR; cp->center[i] = params.arcP; } @@ -742,67 +777,85 @@ BOOL_T CallCornu(coOrd pos[2], track_p trk[2], EPINX_T ep[2], dynArr_t * array_p */ EXPORT void DrawCornuCurve( - trkSeg_p first_trk, - trkSeg_p point1, - int ep1Segs_cnt, - trkSeg_p curveSegs, - int crvSegs_cnt, - trkSeg_p point2, - int ep2Segs_cnt, - trkSeg_p second_trk, - trkSeg_p extend1_trk, - trkSeg_p extend2_trk, - trkSeg_p mids, - int midSegs_cnt, - wDrawColor color - ) { - if (first_trk) + trkSeg_p first_trk, + trkSeg_p point1, + int ep1Segs_cnt, + trkSeg_p curveSegs, + int crvSegs_cnt, + trkSeg_p point2, + int ep2Segs_cnt, + trkSeg_p second_trk, + trkSeg_p extend1_trk, + trkSeg_p extend2_trk, + trkSeg_p mids, + int midSegs_cnt, + wDrawColor color +) +{ + if (first_trk) { DrawSegs( &tempD, zero, 0.0, first_trk, 1, Da.trackGauge, drawColorBlack ); - if (crvSegs_cnt>0 && curveSegs) + } + if (crvSegs_cnt>0 && curveSegs) { DrawSegs( &tempD, zero, 0.0, curveSegs, crvSegs_cnt, Da.trackGauge, color ); - if (second_trk) + } + if (second_trk) { DrawSegs( &tempD, zero, 0.0, second_trk, 1, Da.trackGauge, drawColorBlack ); - if (ep1Segs_cnt>0 && point1) - DrawSegs( &tempD, zero, 0.0, point1, ep1Segs_cnt, Da.trackGauge, drawColorBlack ); - if (ep2Segs_cnt>0 && point2) - DrawSegs( &tempD, zero, 0.0, point2, ep2Segs_cnt, Da.trackGauge, drawColorBlack ); - if (midSegs_cnt>0 && mids) - DrawSegs( &tempD, zero, 0.0, mids, midSegs_cnt, Da.trackGauge, drawColorBlack ); - if (extend1_trk) + } + if (ep1Segs_cnt>0 && point1) { + DrawSegs( &tempD, zero, 0.0, point1, ep1Segs_cnt, Da.trackGauge, + drawColorBlack ); + } + if (ep2Segs_cnt>0 && point2) { + DrawSegs( &tempD, zero, 0.0, point2, ep2Segs_cnt, Da.trackGauge, + drawColorBlack ); + } + if (midSegs_cnt>0 && mids) { + DrawSegs( &tempD, zero, 0.0, mids, midSegs_cnt, Da.trackGauge, + drawColorBlack ); + } + if (extend1_trk) { DrawSegs( &tempD, zero, 0.0, extend1_trk, 1, Da.trackGauge, drawColorBlack); - if (extend2_trk) + } + if (extend2_trk) { DrawSegs( &tempD, zero, 0.0, extend2_trk, 1, Da.trackGauge, drawColorBlack); + } } /* * If Track, make it red if the radius is below minimum */ -void DrawTempCornu() { +void DrawTempCornu() +{ - DrawCornuCurve(&Da.trk1Seg, - &Da.ep1Segs[0],Da.ep1Segs_da_cnt, - (trkSeg_t *)Da.crvSegs_da.ptr,Da.crvSegs_da_cnt, - &Da.ep2Segs[0],Da.ep2Segs_da_cnt, - &Da.trk2Seg, - Da.extend[0]?&Da.extendSeg[0]:NULL, - Da.extend[1]?&Da.extendSeg[1]:NULL, - (trkSeg_t *)Da.midSegs.ptr,Da.midSegs.cnt, - fabs(Da.minRadius)<(GetLayoutMinTrackRadius()-EPSILON)?exceptionColor:normalColor); + DrawCornuCurve(&Da.trk1Seg, + &Da.ep1Segs[0],Da.ep1Segs_da_cnt, + &DYNARR_N(trkSeg_t,Da.crvSegs_da,0),Da.crvSegs_da_cnt, + &Da.ep2Segs[0],Da.ep2Segs_da_cnt, + &Da.trk2Seg, + Da.extend[0]?&Da.extendSeg[0]:NULL, + Da.extend[1]?&Da.extendSeg[1]:NULL, + &DYNARR_N(trkSeg_t,Da.midSegs,0),Da.midSegs.cnt, + fabs(Da.minRadius)<(GetLayoutMinTrackRadius()-EPSILON)?exceptionColor: + normalColor); } -void CreateBothEnds(int selectEndPoint, int selectMidPoint, int selectEndHandle, int lastSelected ) { +void CreateBothEnds(int selectEndPoint, int selectMidPoint, int selectEndHandle, + int lastSelected ) +{ BOOL_T selectable[2],modifyable[2]; selectable[0] = !Da.trk[0] || ( - Da.trk[0] && !QueryTrack(Da.trk[0],Q_IS_CORNU) && !QueryTrack(Da.trk[0],Q_CAN_MODIFY_CONTROL_POINTS)); + Da.trk[0] && !QueryTrack(Da.trk[0],Q_IS_CORNU) + && !QueryTrack(Da.trk[0],Q_CAN_MODIFY_CONTROL_POINTS)); modifyable[0] = !Da.trk[0] || ( - Da.trk[0] && QueryTrack(Da.trk[0],Q_CORNU_CAN_MODIFY)); + Da.trk[0] && QueryTrack(Da.trk[0],Q_CORNU_CAN_MODIFY)); selectable[1] = !Da.trk[1] || ( - Da.trk[1] && !QueryTrack(Da.trk[1],Q_IS_CORNU) && !QueryTrack(Da.trk[1],Q_CAN_MODIFY_CONTROL_POINTS)); + Da.trk[1] && !QueryTrack(Da.trk[1],Q_IS_CORNU) + && !QueryTrack(Da.trk[1],Q_CAN_MODIFY_CONTROL_POINTS)); modifyable[1] = !Da.trk[1] || ( - Da.trk[1] && QueryTrack(Da.trk[1],Q_CORNU_CAN_MODIFY)); + Da.trk[1] && QueryTrack(Da.trk[1],Q_CORNU_CAN_MODIFY)); Da.endHandle[0].angle_selected = (selectEndHandle==1)?TRUE:FALSE; Da.endHandle[0].radius_selected = (selectEndHandle==0)?TRUE:FALSE; @@ -811,30 +864,41 @@ void CreateBothEnds(int selectEndPoint, int selectMidPoint, int selectEndHandle, Da.endHandle[0].last_selected = lastSelected==0?TRUE:FALSE; Da.endHandle[1].last_selected = lastSelected==1?TRUE:FALSE; if (selectEndPoint == -1) { - Da.ep1Segs_da_cnt = createEndPoint(Da.ep1Segs, Da.pos[0],FALSE,selectable[0],modifyable[0],Da.trk[0]!=NULL,Da.angle[0],Da.radius[0],Da.center[0],Da.extend[0]?NULL:&Da.endHandle[0]); - Da.ep2Segs_da_cnt = createEndPoint(Da.ep2Segs, Da.pos[1],FALSE,selectable[1],modifyable[1],Da.trk[1]!=NULL,Da.angle[1],Da.radius[1],Da.center[1],Da.extend[1]?NULL:&Da.endHandle[1]); + Da.ep1Segs_da_cnt = createEndPoint(Da.ep1Segs, Da.pos[0],FALSE,selectable[0], + modifyable[0],Da.trk[0]!=NULL,Da.angle[0],Da.radius[0],Da.center[0], + Da.extend[0]?NULL:&Da.endHandle[0]); + Da.ep2Segs_da_cnt = createEndPoint(Da.ep2Segs, Da.pos[1],FALSE,selectable[1], + modifyable[1],Da.trk[1]!=NULL,Da.angle[1],Da.radius[1],Da.center[1], + Da.extend[1]?NULL:&Da.endHandle[1]); } else { - Da.ep1Segs_da_cnt = createEndPoint(Da.ep1Segs, Da.pos[0],selectEndPoint == 0,selectable[0],modifyable[0],Da.trk[0]!=NULL,Da.angle[0],Da.radius[0],Da.center[0],Da.extend[0]?NULL:&Da.endHandle[0]); - Da.ep2Segs_da_cnt = createEndPoint(Da.ep2Segs, Da.pos[1],selectEndPoint == 1,selectable[1],modifyable[1],Da.trk[1]!=NULL,Da.angle[1],Da.radius[1],Da.center[1],Da.extend[1]?NULL:&Da.endHandle[1]); + Da.ep1Segs_da_cnt = createEndPoint(Da.ep1Segs, Da.pos[0],selectEndPoint == 0, + selectable[0],modifyable[0],Da.trk[0]!=NULL,Da.angle[0],Da.radius[0], + Da.center[0],Da.extend[0]?NULL:&Da.endHandle[0]); + Da.ep2Segs_da_cnt = createEndPoint(Da.ep2Segs, Da.pos[1],selectEndPoint == 1, + selectable[1],modifyable[1],Da.trk[1]!=NULL,Da.angle[1],Da.radius[1], + Da.center[1],Da.extend[1]?NULL:&Da.endHandle[1]); } Da.endHandle[0].end_valid = !Da.extend[0]; Da.endHandle[1].end_valid = !Da.extend[1]; DYNARR_RESET(trkSeg_t,Da.midSegs); - for (int i=0;i<Da.mid_points.cnt;i++) { - createMidPoint(&Da.midSegs, DYNARR_N(coOrd,Da.mid_points,i),selectMidPoint == i,TRUE, TRUE ); + for (int i=0; i<Da.mid_points.cnt; i++) { + createMidPoint(&Da.midSegs, DYNARR_N(coOrd,Da.mid_points,i),selectMidPoint == i, + TRUE, TRUE ); } - if (Da.radius[0] >=0.0) Da.ends[0] = TRUE; - else Da.ends[0] = FALSE; - if (Da.radius[1] >=0.0) Da.ends[1] = TRUE; - else Da.ends[1] = FALSE; + if (Da.radius[0] >=0.0) { Da.ends[0] = TRUE; } + else { Da.ends[0] = FALSE; } + if (Da.radius[1] >=0.0) { Da.ends[1] = TRUE; } + else { Da.ends[1] = FALSE; } } -BOOL_T GetConnectedTrackParms(track_p t, const coOrd pos, int end, EPINX_T track_end, wBool_t extend) { +BOOL_T GetConnectedTrackParms(track_p t, const coOrd pos, int end, + EPINX_T track_end, wBool_t extend) +{ trackParams_t trackParams; coOrd pos1; - if ((track_end>=0) && extend) pos1 = GetTrkEndPos(t,track_end); - else pos1 = pos; - if (!GetTrackParams(PARAMS_CORNU, t, pos1, &trackParams)) return FALSE; + if ((track_end>=0) && extend) { pos1 = GetTrkEndPos(t,track_end); } + else { pos1 = pos; } + if (!GetTrackParams(PARAMS_CORNU, t, pos1, &trackParams)) { return FALSE; } Da.radius[end] = 0.0; Da.center[end] = zero; Da.circleorHelix[end] = FALSE; @@ -869,9 +933,10 @@ BOOL_T GetConnectedTrackParms(track_p t, const coOrd pos, int end, EPINX_T track Da.pos[end] = trackParams.cornuEnd[ep]; Da.center[end] = trackParams.cornuCenter[ep]; } else if (trackParams.type == curveTypeStraight) { - if (trackParams.ep>=0) - Da.angle[end] = NormalizeAngle(GetTrkEndAngle(t,track_end)+180); //Ignore params.angle because it gives from nearest end - else { + if (trackParams.ep>=0) { + Da.angle[end] = NormalizeAngle(GetTrkEndAngle(t, + track_end)+180); //Ignore params.angle because it gives from nearest end + } else { Da.angle[end] = NormalizeAngle(trackParams.angle+180); //Turntable Da.pos[end] = trackParams.lineEnd; //End moved to constrain angle } @@ -879,18 +944,20 @@ BOOL_T GetConnectedTrackParms(track_p t, const coOrd pos, int end, EPINX_T track return TRUE; } -void CorrectHelixAngles() { +void CorrectHelixAngles() +{ if ( Da.circleorHelix[0] ) { Da.ep[0] = PickArcEndPt( Da.center[0], Da.pos[0], Da.pos[1] ); - if (Da.ep[0] == 1) Da.angle[0] = NormalizeAngle(Da.angle[0]+180); + if (Da.ep[0] == 1) { Da.angle[0] = NormalizeAngle(Da.angle[0]+180); } } if ( Da.circleorHelix[1] ) { Da.ep[1] = PickArcEndPt( Da.center[1], Da.pos[1], Da.pos[0] ); - if (Da.ep[1] == 1) Da.angle[1] = NormalizeAngle(Da.angle[1]+180); + if (Da.ep[1] == 1) { Da.angle[1] = NormalizeAngle(Da.angle[1]+180); } } } -BOOL_T CheckHelix(track_p trk) { +BOOL_T CheckHelix(track_p trk) +{ if ( Da.trk[0] && QueryTrack(Da.trk[0],Q_HAS_VARIABLE_ENDPOINTS)) { track_p t = GetTrkEndTrk(Da.trk[0],Da.ep[0]); if ( t != NULL && t != trk) { @@ -908,86 +975,92 @@ BOOL_T CheckHelix(track_p trk) { return TRUE; } -void SetUpCornuParms(cornuParm_t * cp) { - cp->center[0] = Da.center[0]; - cp->angle[0] = Da.angle[0]; - cp->radius[0] = Da.radius[0]; - cp->center[1] = Da.center[1]; - cp->angle[1] = Da.angle[1]; - cp->radius[1] = Da.radius[1]; +void SetUpCornuParms(cornuParm_t * cp) +{ + cp->center[0] = Da.center[0]; + cp->angle[0] = Da.angle[0]; + cp->radius[0] = Da.radius[0]; + cp->center[1] = Da.center[1]; + cp->angle[1] = Da.angle[1]; + cp->radius[1] = Da.radius[1]; } -track_p CreateCornuFromPoints(coOrd pos[2],BOOL_T track_end[2]) { - coOrd center[2]; - DIST_T radius[2]; - ANGLE_T angle[2]; - BOOL_T back, neg; - cornuParm_t new; - int inx,subinx; - coOrd pos_temp[2]; - - for (int i=0;i<2;i++) { - pos_temp[i] = pos[i]; +track_p CreateCornuFromPoints(coOrd pos[2],BOOL_T track_end[2]) +{ + coOrd center[2]; + DIST_T radius[2]; + ANGLE_T angle[2]; + BOOL_T back, neg; + cornuParm_t new; + int inx,subinx; + coOrd pos_temp[2]; - if (!track_end[i] || (Da.radius[i]==-1.0)) { + for (int i=0; i<2; i++) { + pos_temp[i] = pos[i]; - angle[i] = GetAngleSegs(Da.crvSegs_da.cnt,(trkSeg_t *)(Da.crvSegs_da.ptr),&pos_temp[i],&inx,NULL,&back,&subinx,&neg); + if (!track_end[i] || (Da.radius[i]==-1.0)) { - trkSeg_p segPtr = &DYNARR_N(trkSeg_t, Da.crvSegs_da, inx); + angle[i] = GetAngleSegs(Da.crvSegs_da.cnt,&DYNARR_N(trkSeg_t,Da.crvSegs_da,0), + &pos_temp[i],&inx,NULL,&back,&subinx,&neg); - if (segPtr->type == SEG_BEZTRK) - segPtr = &DYNARR_N(trkSeg_t, segPtr->bezSegs, subinx); + trkSeg_p segPtr = &DYNARR_N(trkSeg_t, Da.crvSegs_da, inx); - if (i==0) { - if (neg==back) angle[i] = NormalizeAngle(angle[i]+180); - } else { - if (!(neg==back)) angle[i] = NormalizeAngle(angle[i]+180); - } + if (segPtr->type == SEG_BEZTRK) { + segPtr = &DYNARR_N(trkSeg_t, segPtr->bezSegs, subinx); + } - if (segPtr->type == SEG_STRTRK) { - radius[i] = 0.0; - center[i] = zero; - } else if (segPtr->type == SEG_CRVTRK) { - center[i] = segPtr->u.c.center; - radius[i] = fabs(segPtr->u.c.radius); - } + if (i==0) { + if (neg==back) { angle[i] = NormalizeAngle(angle[i]+180); } } else { - pos[i] = Da.pos[i]; - radius[i] = Da.radius[i]; - center[i] = Da.center[i]; - angle[i] = Da.angle[i]; - neg = FALSE; - back = FALSE; - } - } - new.pos[0] = pos[0]; - new.pos[1] = pos[1]; - new.angle[0] = angle[0]; - new.angle[1] = angle[1]; - new.center[0] = center[0]; - new.center[1] = center[1]; - new.radius[0] = radius[0]; - new.radius[1] = radius[1]; - - track_p trk1 = NewCornuTrack(new.pos,new.center,new.angle,new.radius,NULL,0); - if (trk1==NULL) { - wBeep(); - InfoMessage(_("Cornu Create Failed for p1[%0.3f,%0.3f] p2[%0.3f,%0.3f], c1[%0.3f,%0.3f] c2[%0.3f,%0.3f], a1=%0.3f a2=%0.3f, r1=%s r2=%s"), - new.pos[0].x,new.pos[0].y, - new.pos[1].x,new.pos[1].y, - new.center[0].x,new.center[0].y, - new.center[1].x,new.center[1].y, - new.angle[0],new.angle[1], - FormatDistance(new.radius[0]),FormatDistance(new.radius[1])); - UndoEnd(); - return NULL; + if (!(neg==back)) { angle[i] = NormalizeAngle(angle[i]+180); } + } + + if (segPtr->type == SEG_STRTRK) { + radius[i] = 0.0; + center[i] = zero; + } else if (segPtr->type == SEG_CRVTRK) { + center[i] = segPtr->u.c.center; + radius[i] = fabs(segPtr->u.c.radius); + } + } else { + pos[i] = Da.pos[i]; + radius[i] = Da.radius[i]; + center[i] = Da.center[i]; + angle[i] = Da.angle[i]; + neg = FALSE; + back = FALSE; } - return trk1; + } + new.pos[0] = pos[0]; + new.pos[1] = pos[1]; + new.angle[0] = angle[0]; + new.angle[1] = angle[1]; + new.center[0] = center[0]; + new.center[1] = center[1]; + new.radius[0] = radius[0]; + new.radius[1] = radius[1]; + + track_p trk1 = NewCornuTrack(new.pos,new.center,new.angle,new.radius,NULL,0); + if (trk1==NULL) { + wBeep(); + InfoMessage( + _("Cornu Create Failed for p1[%0.3f,%0.3f] p2[%0.3f,%0.3f], c1[%0.3f,%0.3f] c2[%0.3f,%0.3f], a1=%0.3f a2=%0.3f, r1=%s r2=%s"), + new.pos[0].x,new.pos[0].y, + new.pos[1].x,new.pos[1].y, + new.center[0].x,new.center[0].y, + new.center[1].x,new.center[1].y, + new.angle[0],new.angle[1], + FormatDistance(new.radius[0]),FormatDistance(new.radius[1])); + UndoEnd(); + return NULL; + } + return trk1; } -ANGLE_T GetOpenAngle(coOrd pos[2],ANGLE_T angle[2],int moved) { +ANGLE_T GetOpenAngle(coOrd pos[2],ANGLE_T angle[2],int moved) +{ ANGLE_T a = FindAngle(pos[1-moved],pos[moved]); ANGLE_T diff = (180+a)-angle[1-moved]; //Difference between input and line return a+diff; //Change to line plus this at the other end @@ -1028,9 +1101,9 @@ static paramGroup_t cornuModPG = { "cornuMod", 0, cornuModPLs, COUNT( cornuModPL * */ EXPORT STATUS_T AdjustCornuCurve( - wAction_t action, - coOrd pos, - cornuMessageProc message ) + wAction_t action, + coOrd pos, + cornuMessageProc message ) { track_p t; DIST_T d; @@ -1044,7 +1117,8 @@ EXPORT STATUS_T AdjustCornuCurve( Da.cmdType = VP2L(commandContext); - if (Da.state != PICK_POINT && Da.state != POINT_PICKED && Da.state != TRACK_SELECTED) return C_CONTINUE; + if (Da.state != PICK_POINT && Da.state != POINT_PICKED + && Da.state != TRACK_SELECTED) { return C_CONTINUE; } switch ( action & 0xFF) { @@ -1058,28 +1132,31 @@ EXPORT STATUS_T AdjustCornuCurve( Da.prevEndPoint = -1; Da.extend[0] = FALSE; Da.extend[1] = FALSE; - CreateBothEnds(Da.selectEndPoint, Da.selectMidPoint,Da.selectEndHandle,Da.prevSelected); - Da.crvSegs_da.cnt = 0; + CreateBothEnds(Da.selectEndPoint, Da.selectMidPoint,Da.selectEndHandle, + Da.prevSelected); + DYNARR_RESET( trkSeg_t, Da.crvSegs_da ); SetUpCornuParms(&cp); - if (CallCornuM(Da.mid_points,Da.ends,Da.pos,&cp,&Da.crvSegs_da,TRUE)) Da.crvSegs_da_cnt = Da.crvSegs_da.cnt; - else Da.crvSegs_da_cnt = 0; + if (CallCornuM(Da.mid_points,Da.ends,Da.pos,&cp,&Da.crvSegs_da,TRUE)) { Da.crvSegs_da_cnt = Da.crvSegs_da.cnt; } + else { Da.crvSegs_da_cnt = 0; } Da.minRadius = CornuMinRadius(Da.pos,Da.crvSegs_da); InfoMessage( _("Select Point, or Add Point") ); TempRedraw(); // AdjustCornuCurve C_START return C_CONTINUE; case C_UPDATE: - if (Da.state != PICK_POINT && Da.prevSelected>-1) return C_CONTINUE; + if (Da.state != PICK_POINT && Da.prevSelected>-1) { return C_CONTINUE; } int sel = Da.prevSelected; - if (Da.trk[sel]) return C_CONTINUE; //Track Here - should never happen + if (Da.trk[sel]) { return C_CONTINUE; } //Track Here - should never happen Da.radius[sel] = fabs(cornuModCmdContext.radius); Da.angle[sel] = cornuModCmdContext.angle; - if (cornuModCmdContext.radius!=0) - Translate(&Da.center[sel],Da.pos[sel],Da.angle[sel]+90,cornuModCmdContext.radius); + if (cornuModCmdContext.radius!=0) { + Translate(&Da.center[sel],Da.pos[sel],Da.angle[sel]+90, + cornuModCmdContext.radius); + } CreateBothEnds(Da.prevSelected,-1,-1,Da.prevSelected); SetUpCornuParms(&cp); - if (CallCornuM(Da.mid_points,Da.ends,Da.pos,&cp,&Da.crvSegs_da,TRUE)) Da.crvSegs_da_cnt = Da.crvSegs_da.cnt; - else Da.crvSegs_da_cnt = 0; + if (CallCornuM(Da.mid_points,Da.ends,Da.pos,&cp,&Da.crvSegs_da,TRUE)) { Da.crvSegs_da_cnt = Da.crvSegs_da.cnt; } + else { Da.crvSegs_da_cnt = 0; } Da.minRadius = CornuMinRadius(Da.pos,Da.crvSegs_da); return C_CONTINUE; break; @@ -1088,7 +1165,7 @@ EXPORT STATUS_T AdjustCornuCurve( if (Da.state == NONE || Da.state == PICK_POINT) { wSetCursor(mainD.d,defaultCursor); DYNARR_RESET(trkSeg_t,anchors_da); - for(int i=0;i<2;i++) { + for(int i=0; i<2; i++) { if (IsClose(FindDistance(pos,Da.pos[i]))) { if (((MyGetKeyState() & WKEY_SHIFT) != 0) && Da.selectTrack) { CreateCornuExtendAnchor(Da.pos[i], Da.angle[i], FALSE); @@ -1099,9 +1176,10 @@ EXPORT STATUS_T AdjustCornuCurve( } } } - CreateBothEnds(Da.selectEndPoint,Da.selectMidPoint,Da.selectEndHandle,Da.prevSelected); + CreateBothEnds(Da.selectEndPoint,Da.selectMidPoint,Da.selectEndHandle, + Da.prevSelected); Da.selectEndPoint = -1; - for (int i=0;i<Da.mid_points.cnt;i++) { + for (int i=0; i<Da.mid_points.cnt; i++) { d = FindDistance(DYNARR_N(coOrd,Da.mid_points,i),pos); if (IsClose(d)) { CreateCornuAnchor(DYNARR_N(coOrd,Da.mid_points,i),FALSE); @@ -1109,8 +1187,8 @@ EXPORT STATUS_T AdjustCornuCurve( return C_CONTINUE; } } - for (int i=0;i<2;i++) { - if (Da.endHandle[i].end_valid == FALSE) continue; + for (int i=0; i<2; i++) { + if (Da.endHandle[i].end_valid == FALSE) { continue; } d = FindDistance(Da.endHandle[i].end_center,pos); if (IsClose(d)) { CreateCornuAnchor(Da.endHandle[i].end_center, FALSE); @@ -1118,8 +1196,8 @@ EXPORT STATUS_T AdjustCornuCurve( return C_CONTINUE; } } - for (int i=0;i<2;i++) { - if (Da.endHandle[i].end_valid == FALSE) continue; + for (int i=0; i<2; i++) { + if (Da.endHandle[i].end_valid == FALSE) { continue; } d = FindDistance(Da.endHandle[i].end_curve,pos); if (IsClose(d)) { CreateCornuAnchor(Da.endHandle[i].end_curve, FALSE); @@ -1128,15 +1206,16 @@ EXPORT STATUS_T AdjustCornuCurve( } } coOrd temp_pos = pos; - if (IsClose(DistanceSegs(zero,0.0,Da.crvSegs_da.cnt,(trkSeg_p)Da.crvSegs_da.ptr,&temp_pos,NULL))) { + if (IsClose(DistanceSegs(zero,0.0,Da.crvSegs_da.cnt,&DYNARR_N(trkSeg_t, + Da.crvSegs_da,0),&temp_pos,NULL))) { CreateCornuAnchor(temp_pos, TRUE); - } else wSetCursor(mainD.d,defaultCursor); + } else { wSetCursor(mainD.d,defaultCursor); } } return C_CONTINUE; case C_DOWN: DYNARR_RESET(trkSeg_t,anchors_da); - if (Da.state != PICK_POINT) return C_CONTINUE; + if (Da.state != PICK_POINT) { return C_CONTINUE; } Da.selectEndPoint = -1; Da.selectMidPoint = -1; Da.selectEndHandle = -1; @@ -1145,7 +1224,7 @@ EXPORT STATUS_T AdjustCornuCurve( InfoSubstituteControls( NULL, NULL ); infoSubst = FALSE; } - for (int i=0;i<2;i++) { + for (int i=0; i<2; i++) { d = FindDistance(Da.pos[i],pos); if (IsClose(d)) { Da.selectEndPoint = i; @@ -1154,7 +1233,7 @@ EXPORT STATUS_T AdjustCornuCurve( } } if (Da.selectEndPoint == -1) { - for (int i=0;i<Da.mid_points.cnt;i++) { + for (int i=0; i<Da.mid_points.cnt; i++) { d = FindDistance(DYNARR_N(coOrd,Da.mid_points,i),pos); if (IsClose(d)) { Da.selectMidPoint = i; @@ -1164,8 +1243,8 @@ EXPORT STATUS_T AdjustCornuCurve( } } if (Da.selectMidPoint == -1 ) { - for (int i=0;i<2;i++) { - if (Da.endHandle[i].end_valid == FALSE) continue; + for (int i=0; i<2; i++) { + if (Da.endHandle[i].end_valid == FALSE) { continue; } d = FindDistance(Da.endHandle[i].end_center,pos); if (IsClose(d)) { Da.selectEndHandle = i*2; @@ -1176,8 +1255,8 @@ EXPORT STATUS_T AdjustCornuCurve( } } if (Da.selectEndHandle == -1) { - for (int i=0;i<2;i++) { - if (Da.endHandle[i].end_valid == FALSE) continue; + for (int i=0; i<2; i++) { + if (Da.endHandle[i].end_valid == FALSE) { continue; } d = FindDistance(Da.endHandle[i].end_curve,pos); if (IsClose(d)) { Da.selectEndHandle = 1+i*2; @@ -1190,26 +1269,32 @@ EXPORT STATUS_T AdjustCornuCurve( } } } else { //We picked an end point - if (!Da.trk[Da.selectEndPoint] && ((MyGetKeyState() & WKEY_SHIFT) != 0) && Da.selectTrack) { //With Shift no track -> Extend + if (!Da.trk[Da.selectEndPoint] && ((MyGetKeyState() & WKEY_SHIFT) != 0) + && Da.selectTrack) { //With Shift no track -> Extend Da.extend[Da.selectEndPoint] = TRUE; //Adding to end Point DYNARR_RESET(trkSeg_t,anchors_da); - CreateCornuExtendAnchor(Da.pos[Da.selectEndPoint], Da.angle[Da.selectEndPoint], FALSE); + CreateCornuExtendAnchor(Da.pos[Da.selectEndPoint], Da.angle[Da.selectEndPoint], + FALSE); } } - if (Da.selectMidPoint ==-1 && Da.selectEndPoint ==-1 && Da.selectEndHandle ==-1) { + if (Da.selectMidPoint ==-1 && Da.selectEndPoint ==-1 + && Da.selectEndHandle ==-1) { coOrd temp_pos = pos; wIndex_t index; - if (IsClose(DistanceSegs(zero,0.0,Da.crvSegs_da.cnt,(trkSeg_p)Da.crvSegs_da.ptr,&temp_pos,&index))) { + if (IsClose(DistanceSegs(zero,0.0,Da.crvSegs_da.cnt,&DYNARR_N(trkSeg_t, + Da.crvSegs_da,0),&temp_pos,&index))) { //Add Point between two other points //Find closest two points along Track int closest = -1; wIndex_t pIndex, nIndex; temp_pos = Da.pos[0]; - DistanceSegs(zero,0.0,Da.crvSegs_da.cnt,(trkSeg_p)Da.crvSegs_da.ptr,&temp_pos,&pIndex); + DistanceSegs(zero,0.0,Da.crvSegs_da.cnt,&DYNARR_N(trkSeg_t,Da.crvSegs_da,0), + &temp_pos,&pIndex); if (Da.mid_points.cnt>0) { - for (int i=0;i<Da.mid_points.cnt;i++) { - temp_pos = DYNARR_N(coOrd ,Da.mid_points,i); - DistanceSegs(zero,0.0,Da.crvSegs_da.cnt,(trkSeg_p)Da.crvSegs_da.ptr,&temp_pos,&nIndex); + for (int i=0; i<Da.mid_points.cnt; i++) { + temp_pos = DYNARR_N(coOrd,Da.mid_points,i); + DistanceSegs(zero,0.0,Da.crvSegs_da.cnt,&DYNARR_N(trkSeg_t,Da.crvSegs_da,0), + &temp_pos,&nIndex); if (((pIndex<=index) && (nIndex>=index))) { closest = i; break; @@ -1217,14 +1302,16 @@ EXPORT STATUS_T AdjustCornuCurve( pIndex = nIndex; } temp_pos = Da.pos[1]; - DistanceSegs(zero,0.0,Da.crvSegs_da.cnt,(trkSeg_p)Da.crvSegs_da.ptr,&temp_pos,&nIndex); - if (index == nIndex) closest = Da.mid_points.cnt; - if (closest == -1) + DistanceSegs(zero,0.0,Da.crvSegs_da.cnt,&DYNARR_N(trkSeg_t,Da.crvSegs_da,0), + &temp_pos,&nIndex); + if (index == nIndex) { closest = Da.mid_points.cnt; } + if (closest == -1) { closest = Da.mid_points.cnt; - } else closest = 0; + } + } else { closest = 0; } DYNARR_APPEND(coOrd,Da.mid_points,1); - for (int i=Da.mid_points.cnt-1;i>closest;i--) { - DYNARR_N(coOrd,Da.mid_points,i) = DYNARR_N(coOrd ,Da.mid_points,i-1); + for (int i=Da.mid_points.cnt-1; i>closest; i--) { + DYNARR_N(coOrd,Da.mid_points,i) = DYNARR_N(coOrd,Da.mid_points,i-1); } DYNARR_N(coOrd,Da.mid_points,closest) = pos; Da.selectMidPoint = closest; @@ -1237,19 +1324,21 @@ EXPORT STATUS_T AdjustCornuCurve( return C_CONTINUE; } } - if (Da.selectEndPoint == -1 && Da.selectMidPoint == -1 && Da.selectEndHandle ==-1) { + if (Da.selectEndPoint == -1 && Da.selectMidPoint == -1 + && Da.selectEndHandle ==-1) { wBeep(); InfoMessage( _("Not close enough to track or point, reselect") ); return C_CONTINUE; } else { if (Da.selectEndPoint >=0 ) { pos = Da.pos[Da.selectEndPoint]; - if (Da.extend[Da.selectEndPoint]) + if (Da.extend[Da.selectEndPoint]) { InfoMessage( _("Drag out end of Cornu")); - else if (Da.trk[Da.selectEndPoint]) { + } else if (Da.trk[Da.selectEndPoint]) { InfoMessage( _("Drag along end of track")); - } else + } else { InfoMessage( _("Drag to move")); + } } else if (Da.selectMidPoint >=0 ) { pos = DYNARR_N(coOrd,Da.mid_points,Da.selectMidPoint); InfoMessage( _("Drag point to new location, Delete to remove")); @@ -1264,17 +1353,19 @@ EXPORT STATUS_T AdjustCornuCurve( } Da.state = POINT_PICKED; } - CreateBothEnds(Da.selectEndPoint,Da.selectMidPoint,Da.selectEndHandle,Da.prevSelected); + CreateBothEnds(Da.selectEndPoint,Da.selectMidPoint,Da.selectEndHandle, + Da.prevSelected); SetUpCornuParms(&cp); - if (CallCornuM(Da.mid_points,Da.ends,Da.pos,&cp,&Da.crvSegs_da,TRUE)) Da.crvSegs_da_cnt = Da.crvSegs_da.cnt; - else Da.crvSegs_da_cnt = 0; + if (CallCornuM(Da.mid_points,Da.ends,Da.pos,&cp,&Da.crvSegs_da,TRUE)) { Da.crvSegs_da_cnt = Da.crvSegs_da.cnt; } + else { Da.crvSegs_da_cnt = 0; } Da.minRadius = CornuMinRadius(Da.pos, Da.crvSegs_da); return C_CONTINUE; case C_MOVE: DYNARR_RESET(trkSeg_t,anchors_da); if (Da.state != POINT_PICKED) { - InfoMessage(_("Pick any circle to adjust or add - Enter to accept, Esc to cancel")); + InfoMessage( + _("Pick any circle to adjust or add - Enter to accept, Esc to cancel")); return C_CONTINUE; } if (Da.selectEndPoint >= 0) { @@ -1291,16 +1382,16 @@ EXPORT STATUS_T AdjustCornuCurve( if (Da.ep[sel]>=0) { //If not turntable Da.pos[sel] = pos = GetTrkEndPos(Da.trk[sel],Da.ep[sel]); } else { - if (QueryTrack(Da.trk[sel],Q_CAN_ADD_ENDPOINTS)){ //Turntable + if (QueryTrack(Da.trk[sel],Q_CAN_ADD_ENDPOINTS)) { //Turntable trackParams_t tp; - if (!GetTrackParams(PARAMS_CORNU, Da.trk[sel], pos, &tp)) return C_CONTINUE; + if (!GetTrackParams(PARAMS_CORNU, Da.trk[sel], pos, &tp)) { return C_CONTINUE; } ANGLE_T a = tp.angle; Translate(&pos,tp.ttcenter,a,tp.ttradius); Da.angle[sel] = NormalizeAngle(a+180); SetUpCornuParms(&cp); - if (CallCornuM(Da.mid_points,Da.ends,Da.pos,&cp,&Da.crvSegs_da,TRUE)) Da.crvSegs_da_cnt = Da.crvSegs_da.cnt; - else Da.crvSegs_da_cnt = 0; - } else return C_CONTINUE; + if (CallCornuM(Da.mid_points,Da.ends,Da.pos,&cp,&Da.crvSegs_da,TRUE)) { Da.crvSegs_da_cnt = Da.crvSegs_da.cnt; } + else { Da.crvSegs_da_cnt = 0; } + } else { return C_CONTINUE; } } } } else { @@ -1308,16 +1399,19 @@ EXPORT STATUS_T AdjustCornuCurve( } if (!inside) { if (Da.ep[sel]>=0) { //Track defined end point - ANGLE_T diff = NormalizeAngle(GetTrkEndAngle(Da.trk[sel],Da.ep[sel])-FindAngle(GetTrkEndPos(Da.trk[sel],Da.ep[sel]),pos)); - if (diff>90.0 && diff<270.0) { //The point is not on track but outside cone of end angle+/-90 + ANGLE_T diff = NormalizeAngle(GetTrkEndAngle(Da.trk[sel], + Da.ep[sel])-FindAngle(GetTrkEndPos(Da.trk[sel],Da.ep[sel]),pos)); + if (diff>90.0 + && diff<270.0) { //The point is not on track but outside cone of end angle+/-90 Da.pos[sel] = pos = GetTrkEndPos(Da.trk[sel],Da.ep[sel]); - CreateBothEnds(Da.selectEndPoint,Da.selectMidPoint,Da.selectEndHandle,Da.prevSelected); + CreateBothEnds(Da.selectEndPoint,Da.selectMidPoint,Da.selectEndHandle, + Da.prevSelected); return C_CONTINUE; } } else { //Not an end point - if (QueryTrack(Da.trk[sel],Q_CAN_ADD_ENDPOINTS)){ //Turntable + if (QueryTrack(Da.trk[sel],Q_CAN_ADD_ENDPOINTS)) { //Turntable trackParams_t tp; - if (!GetTrackParams(PARAMS_CORNU, Da.trk[sel], pos, &tp)) return C_CONTINUE; + if (!GetTrackParams(PARAMS_CORNU, Da.trk[sel], pos, &tp)) { return C_CONTINUE; } ANGLE_T a = tp.angle; coOrd edge; Translate(&edge,tp.ttcenter,a,tp.ttradius); @@ -1326,25 +1420,30 @@ EXPORT STATUS_T AdjustCornuCurve( Translate(&pos,edge,a,d); Da.angle[sel] = NormalizeAngle(a+180); Da.pos[sel] = pos; - CreateBothEnds(Da.selectEndPoint,Da.selectMidPoint,Da.selectEndHandle,Da.prevSelected); + CreateBothEnds(Da.selectEndPoint,Da.selectMidPoint,Da.selectEndHandle, + Da.prevSelected); Da.extendSeg[sel].type = SEG_STRTRK; - Da.extendSeg[sel].width = 0; + Da.extendSeg[sel].lineWidth = 0; Da.extendSeg[sel].color = wDrawColorBlack; Da.extendSeg[sel].u.l.pos[1-sel] = pos; Da.extendSeg[sel].u.l.pos[sel] = edge; Da.extend[sel] = TRUE; SetUpCornuParms(&cp); - if (CallCornuM(Da.mid_points,Da.ends,Da.pos,&cp,&Da.crvSegs_da,TRUE)) Da.crvSegs_da_cnt = Da.crvSegs_da.cnt; - else Da.crvSegs_da_cnt = 0; + if (CallCornuM(Da.mid_points,Da.ends,Da.pos,&cp,&Da.crvSegs_da,TRUE)) { Da.crvSegs_da_cnt = Da.crvSegs_da.cnt; } + else { Da.crvSegs_da_cnt = 0; } return C_CONTINUE; //Stop moving end point - } else return C_CONTINUE; + } else { return C_CONTINUE; } } } // Stop the user extending right through the other track - if (Da.ep[sel]>=0 && QueryTrack(Da.trk[sel],Q_CORNU_CAN_MODIFY)) { //For non-turnouts - if ((!QueryTrack(Da.trk[sel],Q_CAN_ADD_ENDPOINTS)) // Not Turntable - may not be needed - && (!QueryTrack(Da.trk[sel],Q_HAS_VARIABLE_ENDPOINTS))) { // Not Helix or a Circle - DIST_T ab = FindDistance(GetTrkEndPos(Da.trk[sel],Da.ep[sel]),GetTrkEndPos(Da.trk[sel],1-Da.ep[sel])); + if (Da.ep[sel]>=0 + && QueryTrack(Da.trk[sel],Q_CORNU_CAN_MODIFY)) { //For non-turnouts + if ((!QueryTrack(Da.trk[sel], + Q_CAN_ADD_ENDPOINTS)) // Not Turntable - may not be needed + && (!QueryTrack(Da.trk[sel], + Q_HAS_VARIABLE_ENDPOINTS))) { // Not Helix or a Circle + DIST_T ab = FindDistance(GetTrkEndPos(Da.trk[sel],Da.ep[sel]), + GetTrkEndPos(Da.trk[sel],1-Da.ep[sel])); DIST_T ac = FindDistance(GetTrkEndPos(Da.trk[sel],Da.ep[sel]),pos); DIST_T cb = FindDistance(GetTrkEndPos(Da.trk[sel],1-Da.ep[sel]),pos); if (cb<minLength) { @@ -1355,34 +1454,38 @@ EXPORT STATUS_T AdjustCornuCurve( pos = GetTrkEndPos(Da.trk[sel],1-Da.ep[sel]); //Make other end of track } } - } else if (Da.ep[sel]>=0 && inside) { //Has a point and inside track - InfoMessage(_("Can't move end inside a turnout")); //Turnouts are stuck to end-point + } else if (Da.ep[sel]>=0 + && inside) { //Has a point and inside track + InfoMessage( + _("Can't move end inside a turnout")); //Turnouts are stuck to end-point Da.pos[sel] = pos = GetTrkEndPos(Da.trk[sel],Da.ep[sel]); - CreateBothEnds(Da.selectEndPoint,Da.selectMidPoint,Da.selectEndHandle,Da.prevSelected); + CreateBothEnds(Da.selectEndPoint,Da.selectMidPoint,Da.selectEndHandle, + Da.prevSelected); return C_CONTINUE; } } if(!Da.trk[sel]) { //Cornu with no end - if (((MyGetKeyState() & WKEY_SHIFT) != 0) && Da.selectTrack) { //Extend end locked + if (((MyGetKeyState() & WKEY_SHIFT) != 0) + && Da.selectTrack) { //Extend end locked SetUpCornuParms(&cp); CallCornuM(Da.mid_points,Da.ends,Da.pos,&cp,&Da.crvSegs_da,FALSE); if (Da.radius[sel] == 0) { //Straight - Da.extendSeg[sel].type = SEG_STRTRK; - Da.extendSeg[sel].width = 0; - Da.extendSeg[sel].color = wDrawColorBlack; - Da.extendSeg[sel].u.l.pos[1-sel] = Da.pos[sel]; - d = FindDistance( Da.extendSeg[sel].u.l.pos[1-sel], pos ); - a = NormalizeAngle(Da.angle[sel]-FindAngle(pos,Da.pos[sel])); - if (cos(D2R(a))<=0) { - Translate( &Da.extendSeg[sel].u.l.pos[sel], - Da.extendSeg[sel].u.l.pos[1-sel], - Da.angle[sel], - d * cos(D2R(a))); - pos = Da.extendSeg[sel].u.l.pos[sel]; - Da.extend[sel] = TRUE; - } else Da.extend[sel] = FALSE; + Da.extendSeg[sel].type = SEG_STRTRK; + Da.extendSeg[sel].lineWidth = 0; + Da.extendSeg[sel].color = wDrawColorBlack; + Da.extendSeg[sel].u.l.pos[1-sel] = Da.pos[sel]; + d = FindDistance( Da.extendSeg[sel].u.l.pos[1-sel], pos ); + a = NormalizeAngle(Da.angle[sel]-FindAngle(pos,Da.pos[sel])); + if (cos(D2R(a))<=0) { + Translate( &Da.extendSeg[sel].u.l.pos[sel], + Da.extendSeg[sel].u.l.pos[1-sel], + Da.angle[sel], - d * cos(D2R(a))); + pos = Da.extendSeg[sel].u.l.pos[sel]; + Da.extend[sel] = TRUE; + } else { Da.extend[sel] = FALSE; } } else { //Curve Da.extendSeg[sel].type = SEG_CRVTRK; - Da.extendSeg[sel].width = 0; + Da.extendSeg[sel].lineWidth = 0; Da.extendSeg[sel].color = wDrawColorBlack; Da.extendSeg[sel].u.c.center = Da.center[sel]; Da.extendSeg[sel].u.c.radius = Da.radius[sel]; @@ -1390,17 +1493,18 @@ EXPORT STATUS_T AdjustCornuCurve( PointOnCircle( &pos, Da.extendSeg[sel].u.c.center, Da.radius[sel], a ); a2 = FindAngle(Da.extendSeg[sel].u.c.center,Da.pos[sel]); if (((Da.angle[sel] < 180) && (a2>90 && a2<270)) || - ((Da.angle[sel] > 180) && (a2<90 || a2>270))) { + ((Da.angle[sel] > 180) && (a2<90 || a2>270))) { Da.extendSeg[sel].u.c.a0 = a; Da.extendSeg[sel].u.c.a1 = NormalizeAngle(a2-a); } else { Da.extendSeg[sel].u.c.a0 = a2; Da.extendSeg[sel].u.c.a1 = NormalizeAngle(a-a2); } - if (Da.extendSeg[sel].u.c.a1 == 0 || Da.extendSeg[sel].u.c.a1 >180 ) + if (Da.extendSeg[sel].u.c.a1 == 0 || Da.extendSeg[sel].u.c.a1 >180 ) { Da.extend[sel] = FALSE; - else + } else { Da.extend[sel] = TRUE; + } } } else { Da.extend[sel] = FALSE; @@ -1413,7 +1517,8 @@ EXPORT STATUS_T AdjustCornuCurve( Da.center[sel].y += offset.y; } if (Da.selectTrack) { //We have track - if (!Da.trk[sel] && ((t = OnTrackIgnore(&pos,FALSE,TRUE,Da.selectTrack))!= NULL) ) { + if (!Da.trk[sel] + && ((t = OnTrackIgnore(&pos,FALSE,TRUE,Da.selectTrack))!= NULL) ) { if ((ep = PickUnconnectedEndPointSilent(pos,t))>=0) { pos = GetTrkEndPos(t,ep); if (IsClose(FindDistance(pos,pos)/2)) { @@ -1435,7 +1540,7 @@ EXPORT STATUS_T AdjustCornuCurve( } } } else { //Cornu with ends - if (inside) Da.pos[sel] = pos; + if (inside) { Da.pos[sel] = pos; } if (!GetConnectedTrackParms(Da.trk[sel],pos,sel,Da.ep[sel],inside?FALSE:TRUE)) { wBeep(); return C_CONTINUE; //Stop drawing @@ -1444,32 +1549,34 @@ EXPORT STATUS_T AdjustCornuCurve( if (!inside) { //Extend the track if (Da.trackType[sel] == curveTypeStraight) { //Extend with a straight Da.extendSeg[sel].type = SEG_STRTRK; - Da.extendSeg[sel].width = 0; + Da.extendSeg[sel].lineWidth = 0; Da.extendSeg[sel].color = wDrawColorBlack; if (Da.ep[sel]>=0) { Da.extendSeg[sel].u.l.pos[0] = GetTrkEndPos( Da.trk[sel], Da.ep[sel] ); - a = NormalizeAngle(Da.angle[sel]-FindAngle(pos,GetTrkEndPos(Da.trk[sel],Da.ep[sel]))); + a = NormalizeAngle(Da.angle[sel]-FindAngle(pos,GetTrkEndPos(Da.trk[sel], + Da.ep[sel]))); } else { //Turntable when unconnected Da.extendSeg[sel].u.l.pos[0] = Da.pos[sel]; a = NormalizeAngle(Da.angle[sel]-FindAngle(pos,Da.pos[sel])); } // Remove any extend in opposite direction for Turntable/Turnouts if ((QueryTrack(Da.trk[sel],Q_CAN_ADD_ENDPOINTS) && Da.ep[sel]>=0) - && (!QueryTrack(Da.trk[sel],Q_CORNU_CAN_MODIFY)) - && (a>90 && a<270)) { - Da.extend[sel] = FALSE; //Turntable with point and extension is other side of well + && (!QueryTrack(Da.trk[sel],Q_CORNU_CAN_MODIFY)) + && (a>90 && a<270)) { + Da.extend[sel] = + FALSE; //Turntable with point and extension is other side of well Da.pos[sel] = GetTrkEndPos(Da.trk[sel],Da.ep[sel]); } else { Da.extend[sel] = TRUE; d = FindDistance( Da.extendSeg[sel].u.l.pos[0], pos ); Translate( &Da.extendSeg[sel].u.l.pos[1], - Da.extendSeg[sel].u.l.pos[0], - Da.angle[sel], -d * cos(D2R(a))); + Da.extendSeg[sel].u.l.pos[0], + Da.angle[sel], -d * cos(D2R(a))); Da.pos[sel] = pos = Da.extendSeg[sel].u.l.pos[1]; } } else if (Da.trackType[sel] == curveTypeCurve) { //Extend with temp curve Da.extendSeg[sel].type = SEG_CRVTRK; - Da.extendSeg[sel].width = 0; + Da.extendSeg[sel].lineWidth = 0; Da.extendSeg[sel].color = wDrawColorBlack; Da.extendSeg[sel].u.c.center = Da.center[sel]; Da.extendSeg[sel].u.c.radius = Da.radius[sel]; @@ -1477,7 +1584,7 @@ EXPORT STATUS_T AdjustCornuCurve( PointOnCircle( &pos, Da.center[sel], Da.radius[sel], a ); a2 = FindAngle(Da.center[sel],GetTrkEndPos(Da.trk[sel],Da.ep[sel])); if ((Da.angle[sel] < 180 && (a2>90 && a2 <270)) || - (Da.angle[sel] > 180 && (a2<90 || a2 >270))) { + (Da.angle[sel] > 180 && (a2<90 || a2 >270))) { Da.extendSeg[sel].u.c.a0 = a2; Da.extendSeg[sel].u.c.a1 = NormalizeAngle(a-a2); } else { @@ -1485,9 +1592,11 @@ EXPORT STATUS_T AdjustCornuCurve( Da.extendSeg[sel].u.c.a1 = NormalizeAngle(a2-a); } if (Da.extendSeg[sel].u.c.a1 == 0.0 || Da.extendSeg[sel].u.c.a1 >180 - || (Da.extendSeg[sel].u.c.a0 >= Da.arcA0[sel] && Da.extendSeg[sel].u.c.a0 < Da.arcA0[sel]+Da.arcA1[sel] - && Da.extendSeg[sel].u.c.a0 + Da.extendSeg[sel].u.c.a1 <= Da.arcA0[sel] + Da.arcA1[sel]) - ) { + || (Da.extendSeg[sel].u.c.a0 >= Da.arcA0[sel] + && Da.extendSeg[sel].u.c.a0 < Da.arcA0[sel]+Da.arcA1[sel] + && Da.extendSeg[sel].u.c.a0 + Da.extendSeg[sel].u.c.a1 <= Da.arcA0[sel] + + Da.arcA1[sel]) + ) { Da.extend[sel] = FALSE; Da.pos[sel] = pos; } else { @@ -1501,9 +1610,9 @@ EXPORT STATUS_T AdjustCornuCurve( pos = GetTrkEndPos(Da.trk[sel],Da.ep[sel]); return C_CONTINUE; } - } else Da.pos[sel] = pos; + } else { Da.pos[sel] = pos; } } - } else if (Da.selectMidPoint >=0){ + } else if (Da.selectMidPoint >=0) { DYNARR_N(coOrd,Da.mid_points,Da.selectMidPoint) = pos; } else if (Da.selectEndHandle >=0) { //Cornu has no end, so has handles int end = Da.selectEndHandle/2; @@ -1511,7 +1620,8 @@ EXPORT STATUS_T AdjustCornuCurve( coOrd p0 = Da.pos[end]; //Start coOrd p1 = Da.endHandle[end].end_curve; //End ANGLE_T a0 = FindAngle( p1, p0 ); - DIST_T d0 = FindDistance( p0, p1 )/2.0; //Distance to Middle of Chord + DIST_T d0 = FindDistance( p0, + p1 )/2.0; //Distance to Middle of Chord coOrd pos2 = pos; //New pos Rotate( &pos2, p1, -a0 ); pos2.x -= p1.x; //Deflection at right angles to Chord @@ -1543,37 +1653,46 @@ EXPORT STATUS_T AdjustCornuCurve( Da.radius[end] = 0.0; Da.angle[end] = FindAngle(Da.pos[end],Da.endHandle[end].end_curve); } else { - Translate( &pc, posx, a0, fabs(r) - fabs(pos2.x) ); //Move Radius less Deflection to get to center + Translate( &pc, posx, a0, + fabs(r) - fabs(pos2.x) ); //Move Radius less Deflection to get to center Da.center[end] = pc; - if (DifferenceBetweenAngles(FindAngle(Da.center[end],Da.pos[end]),FindAngle(Da.center[end],Da.endHandle[end].end_curve))>0.0) + if (DifferenceBetweenAngles(FindAngle(Da.center[end],Da.pos[end]), + FindAngle(Da.center[end],Da.endHandle[end].end_curve))>0.0) { Da.angle[end] = NormalizeAngle(FindAngle(Da.center[end],Da.pos[end])+90.0); - else + } else { Da.angle[end] = NormalizeAngle(FindAngle(Da.center[end],Da.pos[end])-90.0); + } Da.radius[end] = fabs(r); } } else { Da.angle[end] = FindAngle(Da.pos[end],pos); Da.radius[end] = 0.0; - Translate(&Da.center[end],Da.pos[end],NormalizeAngle(Da.angle[end]+90.0),Da.radius[end]); + Translate(&Da.center[end],Da.pos[end],NormalizeAngle(Da.angle[end]+90.0), + Da.radius[end]); } } - CreateBothEnds(Da.selectEndPoint,Da.selectMidPoint,Da.selectEndHandle,Da.prevSelected); - SetUpCornuParms(&cp); //In case we want to use these because the ends are not on the track - if (CallCornuM(Da.mid_points,Da.ends,Da.pos,&cp,&Da.crvSegs_da,TRUE)) Da.crvSegs_da_cnt = Da.crvSegs_da.cnt; - else Da.crvSegs_da_cnt = 0; - for (int i=0;i<2;i++) { - if (Da.trk[i] || Da.ends[i]) continue; + CreateBothEnds(Da.selectEndPoint,Da.selectMidPoint,Da.selectEndHandle, + Da.prevSelected); + SetUpCornuParms( + &cp); //In case we want to use these because the ends are not on the track + if (CallCornuM(Da.mid_points,Da.ends,Da.pos,&cp,&Da.crvSegs_da,TRUE)) { Da.crvSegs_da_cnt = Da.crvSegs_da.cnt; } + else { Da.crvSegs_da_cnt = 0; } + for (int i=0; i<2; i++) { + if (Da.trk[i] || Da.ends[i]) { continue; } coOrd p = Da.pos[i]; - Da.angle[i] = NormalizeAngle((i?0:180)+GetAngleSegs( Da.crvSegs_da_cnt, Da.crvSegs_da.ptr, &p, NULL, NULL, NULL, NULL, NULL)); + Da.angle[i] = NormalizeAngle((i?0:180)+GetAngleSegs( Da.crvSegs_da_cnt, + &DYNARR_N(trkSeg_t,Da.crvSegs_da,0), &p, NULL, NULL, NULL, NULL, NULL)); Da.radius[i] = 0.0; } Da.minRadius = CornuMinRadius(Da.pos,Da.crvSegs_da); DIST_T rin = Da.radius[0]; - InfoMessage( _("Cornu : Min Radius=%s MaxRateofCurveChange/Scale=%s Length=%s Winding Arc=%s"), - FormatDistance(Da.minRadius), - FormatFloat(CornuMaxRateofChangeofCurvature(Da.pos,Da.crvSegs_da,&rin)*GetScaleRatio(GetLayoutCurScale())), - FormatDistance(CornuLength(Da.pos,Da.crvSegs_da)), - FormatDistance(CornuTotalWindingArc(Da.pos,Da.crvSegs_da))); + InfoMessage( + _("Cornu : Min Radius=%s MaxRateofCurveChange/Scale=%s Length=%s Winding Arc=%s"), + FormatDistance(Da.minRadius), + FormatFloat(CornuMaxRateofChangeofCurvature(Da.pos,Da.crvSegs_da, + &rin)*GetScaleRatio(GetLayoutCurScale())), + FormatDistance(CornuLength(Da.pos,Da.crvSegs_da)), + FormatDistance(CornuTotalWindingArc(Da.pos,Da.crvSegs_da))); return C_CONTINUE; case C_UP: @@ -1583,27 +1702,30 @@ EXPORT STATUS_T AdjustCornuCurve( return C_CONTINUE; } ep = 0; - if (Da.selectMidPoint!=-1) Da.prevSelected = Da.selectMidPoint; + if (Da.selectMidPoint!=-1) { Da.prevSelected = Da.selectMidPoint; } else if (Da.selectEndPoint!=-1) { if (!Da.trk[Da.selectEndPoint] && - (t=OnTrack(&pos,FALSE,TRUE)) != NULL && t != Da.selectTrack ) { + (t=OnTrack(&pos,FALSE,TRUE)) != NULL && t != Da.selectTrack ) { EPINX_T ep = PickUnconnectedEndPoint(pos,t); if (ep>=0) { - if (QueryTrack(t,Q_HAS_VARIABLE_ENDPOINTS)) { //Circle/Helix find if there is an open slot and where - if ((GetTrkEndTrk(t,0) != NULL) && (GetTrkEndTrk(t,1) != NULL)) { - InfoMessage(_("Helix Already Connected")); - return C_CONTINUE; - } - ep = -1; //Not a real ep yet - } else ep = PickUnconnectedEndPointSilent(pos, t); //EP + if (QueryTrack(t, + Q_HAS_VARIABLE_ENDPOINTS)) { //Circle/Helix find if there is an open slot and where + if ((GetTrkEndTrk(t,0) != NULL) && (GetTrkEndTrk(t,1) != NULL)) { + InfoMessage(_("Helix Already Connected")); + return C_CONTINUE; + } + ep = -1; //Not a real ep yet + } else { ep = PickUnconnectedEndPointSilent(pos, t); } //EP if (ep>=0 && QueryTrack(t,Q_CAN_ADD_ENDPOINTS)) { ep=-1; //Don't attach to Turntable trackParams_t tp; - if (!GetTrackParams(PARAMS_CORNU, t, pos, &tp)) return C_CONTINUE; + if (!GetTrackParams(PARAMS_CORNU, t, pos, &tp)) { return C_CONTINUE; } ANGLE_T a = tp.angle; Translate(&pos,tp.ttcenter,a,tp.ttradius); } - if ( ep==-1 && (!QueryTrack(t,Q_CAN_ADD_ENDPOINTS) && !QueryTrack(t,Q_HAS_VARIABLE_ENDPOINTS))) { //No endpoints and not Turntable or Helix/Circle + if ( ep==-1 && (!QueryTrack(t,Q_CAN_ADD_ENDPOINTS) + && !QueryTrack(t, + Q_HAS_VARIABLE_ENDPOINTS))) { //No endpoints and not Turntable or Helix/Circle wBeep(); InfoMessage(_("No Valid end point on that track")); return C_CONTINUE; @@ -1619,13 +1741,15 @@ EXPORT STATUS_T AdjustCornuCurve( Da.ep[Da.selectEndPoint] = ep; // Note: -1 for Turntable or Circle pos = GetTrkEndPos(t,ep); Da.pos[Da.selectEndPoint] = pos; - if (!GetConnectedTrackParms(t,pos,Da.selectEndPoint,ep,FALSE)) return C_CONTINUE; + if (!GetConnectedTrackParms(t,pos,Da.selectEndPoint,ep,FALSE)) { return C_CONTINUE; } } } else { cornuModCmdContext.angle = NormalizeAngle(Da.angle[Da.selectEndPoint]); cornuModCmdContext.radius = Da.radius[Da.selectEndPoint]; - if (DifferenceBetweenAngles(FindAngle(Da.center[Da.selectEndPoint],Da.pos[Da.selectEndPoint]),Da.angle[Da.selectEndPoint])<0.0) + if (DifferenceBetweenAngles(FindAngle(Da.center[Da.selectEndPoint], + Da.pos[Da.selectEndPoint]),Da.angle[Da.selectEndPoint])<0.0) { cornuModCmdContext.radius = -cornuModCmdContext.radius; + } controls[0] = cornuModEndRadiusPD.control; controls[1] = cornuModEndAnglePD.control; controls[2] = NULL; @@ -1643,8 +1767,10 @@ EXPORT STATUS_T AdjustCornuCurve( Da.prevSelected = Da.selectEndHandle>2?1:0; cornuModCmdContext.angle = NormalizeAngle(Da.angle[Da.prevSelected]); cornuModCmdContext.radius = Da.radius[Da.prevSelected]; - if (DifferenceBetweenAngles(FindAngle(Da.center[Da.prevSelected],Da.pos[Da.prevSelected]),Da.angle[Da.prevSelected])<0.0) + if (DifferenceBetweenAngles(FindAngle(Da.center[Da.prevSelected], + Da.pos[Da.prevSelected]),Da.angle[Da.prevSelected])<0.0) { cornuModCmdContext.radius = -cornuModCmdContext.radius; + } controls[0] = cornuModEndRadiusPD.control; controls[1] = cornuModEndAnglePD.control; controls[2] = NULL; @@ -1658,12 +1784,14 @@ EXPORT STATUS_T AdjustCornuCurve( Da.selectEndHandle = -1; } Da.selectEndPoint = -1; Da.selectMidPoint = -1; - CreateBothEnds(Da.selectEndPoint,Da.selectMidPoint,Da.selectEndHandle,Da.prevSelected); + CreateBothEnds(Da.selectEndPoint,Da.selectMidPoint,Da.selectEndHandle, + Da.prevSelected); SetUpCornuParms(&cp); - if (CallCornuM(Da.mid_points,Da.ends,Da.pos,&cp,&Da.crvSegs_da,TRUE)) Da.crvSegs_da_cnt = Da.crvSegs_da.cnt; - else Da.crvSegs_da_cnt = 0; + if (CallCornuM(Da.mid_points,Da.ends,Da.pos,&cp,&Da.crvSegs_da,TRUE)) { Da.crvSegs_da_cnt = Da.crvSegs_da.cnt; } + else { Da.crvSegs_da_cnt = 0; } Da.minRadius = CornuMinRadius(Da.pos,Da.crvSegs_da); - InfoMessage(_("Pick on point to adjust it along track - Delete to remove, Enter to confirm, ESC to abort")); + InfoMessage( + _("Pick on point to adjust it along track - Delete to remove, Enter to confirm, ESC to abort")); Da.state = PICK_POINT; return C_CONTINUE; @@ -1672,17 +1800,18 @@ EXPORT STATUS_T AdjustCornuCurve( //Delete or backspace deletes last selected index if (action>>8 == 127 || action>>8 == 8) { if ((Da.state == PICK_POINT) && Da.prevSelected !=-1) { - for (int i=Da.prevSelected;i<Da.mid_points.cnt;i++) { + for (int i=Da.prevSelected; i<Da.mid_points.cnt; i++) { DYNARR_N(coOrd,Da.mid_points,i) = DYNARR_N(coOrd,Da.mid_points,i+1); } Da.mid_points.cnt--; } Da.prevSelected = -1; - CreateBothEnds(Da.selectEndPoint,Da.selectMidPoint,Da.selectEndHandle,Da.prevSelected); + CreateBothEnds(Da.selectEndPoint,Da.selectMidPoint,Da.selectEndHandle, + Da.prevSelected); cornuParm_t cp; SetUpCornuParms(&cp); - if (CallCornuM(Da.mid_points,Da.ends,Da.pos,&cp,&Da.crvSegs_da,TRUE)) Da.crvSegs_da_cnt = Da.crvSegs_da.cnt; - else Da.crvSegs_da_cnt = 0; + if (CallCornuM(Da.mid_points,Da.ends,Da.pos,&cp,&Da.crvSegs_da,TRUE)) { Da.crvSegs_da_cnt = Da.crvSegs_da.cnt; } + else { Da.crvSegs_da_cnt = 0; } return C_CONTINUE; } return C_CONTINUE; @@ -1700,12 +1829,15 @@ EXPORT STATUS_T AdjustCornuCurve( wBeep(); return C_CONTINUE; } - for (int i=0;i<2;i++) { - if (Da.trk[i] && !(QueryTrack(Da.trk[i],Q_CAN_ADD_ENDPOINTS))) { // Not Turntable + for (int i=0; i<2; i++) { + if (Da.trk[i] + && !(QueryTrack(Da.trk[i],Q_CAN_ADD_ENDPOINTS))) { // Not Turntable if (FindDistance(Da.pos[i],GetTrkEndPos(Da.trk[i],1-Da.ep[i])) < minLength) { - wBeep(); - InfoMessage(_("Cornu point %d too close to other end of connect track - reposition it"),i+1); - return C_CONTINUE; + wBeep(); + InfoMessage( + _("Cornu point %d too close to other end of connect track - reposition it"), + i+1); + return C_CONTINUE; } } } @@ -1715,12 +1847,12 @@ EXPORT STATUS_T AdjustCornuCurve( end_point[1] = FALSE; coOrd sub_pos[2]; sub_pos[0] = Da.pos[0]; - if (Da.radius[0] == -1) end_point[0] = FALSE; + if (Da.radius[0] == -1) { end_point[0] = FALSE; } track_p first_trk= NULL,trk1=NULL,trk2 = NULL; - for (int i=0;i<Da.mid_points.cnt;i++) { + for (int i=0; i<Da.mid_points.cnt; i++) { sub_pos[1] = DYNARR_N(coOrd,Da.mid_points,i); - if ((trk1 = CreateCornuFromPoints(sub_pos,end_point))== NULL) return C_TERMINATE; + if ((trk1 = CreateCornuFromPoints(sub_pos,end_point))== NULL) { return C_TERMINATE; } if (Da.trk[0]) { CopyAttributes( Da.trk[0], trk1 ); } else if (Da.trk[1]) { @@ -1730,38 +1862,41 @@ EXPORT STATUS_T AdjustCornuCurve( SetTrkBits( trk1, TB_HIDEDESC ); } DrawNewTrack(trk1); - if (first_trk == NULL) first_trk = trk1; - if (trk2) ConnectTracks(trk1,0,trk2,1); + if (first_trk == NULL) { first_trk = trk1; } + if (trk2) { ConnectTracks(trk1,0,trk2,1); } trk2 = trk1; end_point[0] = FALSE; sub_pos[0] = DYNARR_N(coOrd,Da.mid_points,i); } sub_pos[1] = Da.pos[1]; end_point[1] = TRUE; - if (Da.radius[1] == -1) end_point[1] = FALSE; - if ((trk1 = CreateCornuFromPoints(sub_pos,end_point)) == NULL) return C_TERMINATE; + if (Da.radius[1] == -1) { end_point[1] = FALSE; } + if ((trk1 = CreateCornuFromPoints(sub_pos,end_point)) == NULL) { return C_TERMINATE; } if (Da.trk[0]) { CopyAttributes( Da.trk[0], trk1 ); - } else if (Da.trk[1]){ + } else if (Da.trk[1]) { CopyAttributes( Da.trk[1], trk1 ); } else { SetTrkScale( trk1, GetLayoutCurScale() ); SetTrkBits( trk1, TB_HIDEDESC ); } - if (trk2) ConnectTracks(trk1,0,trk2,1); - if (first_trk == NULL) first_trk = trk1; - //t = NewCornuTrack( Da.pos, Da.center, Da.angle, Da.radius,(trkSeg_p)Da.crvSegs_da.ptr, Da.crvSegs_da.cnt); + if (trk2) { ConnectTracks(trk1,0,trk2,1); } + if (first_trk == NULL) { first_trk = trk1; } + //t = NewCornuTrack( Da.pos, Da.center, Da.angle, Da.radius,&DYNARR(trkSeg_t,Da.crvSegs_da,0), Da.crvSegs_da.cnt); - for (int i=0;i<2;i++) { + for (int i=0; i<2; i++) { if (Da.trk[i]) { UndoModify(Da.trk[i]); MoveEndPt(&Da.trk[i],&Da.ep[i],Da.pos[i],0); - //End position not precise, so readjust Cornu - GetConnectedTrackParms(Da.trk[i],GetTrkEndPos(Da.trk[i],Da.ep[i]),i,Da.ep[i],FALSE); + //End position not precise, so readjust Cornu + GetConnectedTrackParms(Da.trk[i],GetTrkEndPos(Da.trk[i],Da.ep[i]),i,Da.ep[i], + FALSE); ANGLE_T endAngle = NormalizeAngle(GetTrkEndAngle(Da.trk[i],Da.ep[i])+180); - SetCornuEndPt(i==0?first_trk:trk1,i,GetTrkEndPos(Da.trk[i],Da.ep[i]),Da.center[i],endAngle,Da.radius[i]); - if (Da.ep[i]>=0) + SetCornuEndPt(i==0?first_trk:trk1,i,GetTrkEndPos(Da.trk[i],Da.ep[i]), + Da.center[i],endAngle,Da.radius[i]); + if (Da.ep[i]>=0) { ConnectTracks(Da.trk[i],Da.ep[i],i==0?first_trk:trk1,i); + } } } UndoEnd(); @@ -1775,12 +1910,11 @@ EXPORT STATUS_T AdjustCornuCurve( return C_CONTINUE; case C_REDRAW: - if (Da.state == NONE) return C_CONTINUE; + if (Da.state == NONE) { return C_CONTINUE; } DrawTempCornu(); - if (anchors_da.cnt) { - DrawSegs( &tempD, zero, 0.0, &anchors(0), anchors_da.cnt, trackGauge, wDrawColorBlack ); - } - if (Da.state == POINT_PICKED) wSetCursor(mainD.d,wCursorNone); + DrawSegsDA( &tempD, NULL, zero, 0.0, &anchors_da, trackGauge, wDrawColorBlack, + 0 ); + if (Da.state == POINT_PICKED) { wSetCursor(mainD.d,wCursorNone); } return C_CONTINUE; case C_CANCEL: case C_FINISH: @@ -1795,14 +1929,14 @@ EXPORT STATUS_T AdjustCornuCurve( } static void cornuModDlgUpdate( - paramGroup_p pg, - int inx, - void * valueP ) + paramGroup_p pg, + int inx, + void * valueP ) { - AdjustCornuCurve(C_UPDATE, zero, InfoMessage); - ParamLoadControl(&cornuModPG,cornuModEndRadius); // Make sure Radius updated - ParamLoadControl(&cornuModPG,cornuModEndAngle); //Relative Angle as well - TempRedraw(); + AdjustCornuCurve(C_UPDATE, zero, InfoMessage); + ParamLoadControl(&cornuModPG,cornuModEndRadius); // Make sure Radius updated + ParamLoadControl(&cornuModPG,cornuModEndAngle); //Relative Angle as well + TempRedraw(); } @@ -1820,7 +1954,9 @@ static void cornuModDlgUpdate( * - C_CANCEL (Esc) sets the state to NONE and reshows the original track unchanged. * */ -STATUS_T CmdCornuModify (track_p trk, wAction_t action, coOrd pos, DIST_T trackG ) { +STATUS_T CmdCornuModify (track_p trk, wAction_t action, coOrd pos, + DIST_T trackG ) +{ Da.trackGauge = trackG; @@ -1833,9 +1969,9 @@ STATUS_T CmdCornuModify (track_p trk, wAction_t action, coOrd pos, DIST_T trackG Da.ep1Segs_da_cnt = 0; Da.ep2Segs_da_cnt = 0; Da.crvSegs_da_cnt = 0; - Da.midSegs.cnt = 0; + DYNARR_RESET( trkSeg_t*, Da.midSegs ); Da.extend[0] = FALSE; - Da.extend[1] = FALSE; + Da.extend[1] = FALSE; Da.selectEndPoint = -1; Da.selectTrack = NULL; DYNARR_RESET(coOrd,Da.mid_points); @@ -1845,9 +1981,9 @@ STATUS_T CmdCornuModify (track_p trk, wAction_t action, coOrd pos, DIST_T trackG Da.selectTrack = trk; DYNARR_APPEND(track_p,Da.tracks,1); DYNARR_LAST(track_p,Da.tracks) = trk; - Da.trk[0] = GetTrkEndTrk( trk, 0 ); - track_p prior = trk; - if (Da.trk[0]) Da.ep[0] = GetEndPtConnectedToMe(Da.trk[0],trk); + Da.trk[0] = GetTrkEndTrk( trk, 0 ); + track_p prior = trk; + if (Da.trk[0]) { Da.ep[0] = GetEndPtConnectedToMe(Da.trk[0],trk); } EPINX_T ep0 = 0; //Move down the LHS adding tracks until no more Cornu while (Da.trk[0] && QueryTrack(Da.trk[0],Q_IS_CORNU)) { @@ -1856,13 +1992,13 @@ STATUS_T CmdCornuModify (track_p trk, wAction_t action, coOrd pos, DIST_T trackG DYNARR_APPEND(track_p,Da.tracks,1); DYNARR_LAST(track_p,Da.tracks) = prior; DYNARR_APPEND(coOrd,Da.mid_points,1); - for (int i=Da.mid_points.cnt-1;i>0;i--) { + for (int i=Da.mid_points.cnt-1; i>0; i--) { DYNARR_N(coOrd,Da.mid_points,i) = DYNARR_N(coOrd,Da.mid_points,i-1); } DYNARR_N(coOrd,Da.mid_points,0) = GetTrkEndPos(prior,1-ep0); Da.trk[0] = GetTrkEndTrk( prior, ep0 ); - if (Da.trk[0]) Da.ep[0] = GetEndPtConnectedToMe(Da.trk[0],prior); - else Da.ep[0] = -1; + if (Da.trk[0]) { Da.ep[0] = GetEndPtConnectedToMe(Da.trk[0],prior); } + else { Da.ep[0] = -1; } } if (prior) { struct extraDataCornu_t *xx0 = GET_EXTRA_DATA(prior, T_CORNU, extraDataCornu_t); @@ -1877,7 +2013,7 @@ STATUS_T CmdCornuModify (track_p trk, wAction_t action, coOrd pos, DIST_T trackG Da.trk[1] = GetTrkEndTrk( trk, 1 ); track_p next = trk; EPINX_T ep1 = 1; - if (Da.trk[1]) Da.ep[1] = GetEndPtConnectedToMe(Da.trk[1],trk); + if (Da.trk[1]) { Da.ep[1] = GetEndPtConnectedToMe(Da.trk[1],trk); } //Move down RHS adding tracks until no more Cornu while (Da.trk[1] && QueryTrack(Da.trk[1],Q_IS_CORNU)) { next = Da.trk[1]; @@ -1887,7 +2023,7 @@ STATUS_T CmdCornuModify (track_p trk, wAction_t action, coOrd pos, DIST_T trackG DYNARR_APPEND(coOrd,Da.mid_points,1); DYNARR_LAST(coOrd,Da.mid_points) = GetTrkEndPos(next,1-ep1); Da.trk[1] = GetTrkEndTrk( next, ep1 ); - if (Da.trk[1]) Da.ep[1] = GetEndPtConnectedToMe(Da.trk[1],next); + if (Da.trk[1]) { Da.ep[1] = GetEndPtConnectedToMe(Da.trk[1],next); } } if (next) { @@ -1900,8 +2036,9 @@ STATUS_T CmdCornuModify (track_p trk, wAction_t action, coOrd pos, DIST_T trackG InfoMessage(_("Now Select or Add (+Shift) a Point")); Da.state = TRACK_SELECTED; - for (int i=0;i<Da.tracks.cnt;i++) { - DrawTrack(DYNARR_N(track_p,Da.tracks,i),&mainD,wDrawColorWhite); //Wipe out real tracks, draw replacement + for (int i=0; i<Da.tracks.cnt; i++) { + DrawTrack(DYNARR_N(track_p,Da.tracks,i),&mainD, + wDrawColorWhite); //Wipe out real tracks, draw replacement } return AdjustCornuCurve(C_START, pos, InfoMessage); @@ -1910,21 +2047,22 @@ STATUS_T CmdCornuModify (track_p trk, wAction_t action, coOrd pos, DIST_T trackG break; case C_DOWN: - if (Da.state == TRACK_SELECTED) return C_CONTINUE; //Ignore until first up + if (Da.state == TRACK_SELECTED) { return C_CONTINUE; } //Ignore until first up return AdjustCornuCurve(C_DOWN, pos, InfoMessage); case C_LCLICK: - if (Da.state == TRACK_SELECTED) return C_CONTINUE; //Ignore until first up + if (Da.state == TRACK_SELECTED) { return C_CONTINUE; } //Ignore until first up AdjustCornuCurve(C_DOWN, pos, InfoMessage); return AdjustCornuCurve(C_UP, pos, InfoMessage); case C_MOVE: - if (Da.state == TRACK_SELECTED) return C_CONTINUE; //Ignore until first up and down + if (Da.state == TRACK_SELECTED) { return C_CONTINUE; } //Ignore until first up and down return AdjustCornuCurve(C_MOVE, pos, InfoMessage); case C_UP: if (Da.state == TRACK_SELECTED) { - Da.state = PICK_POINT; //First time up, next time pick a point + Da.state = + PICK_POINT; //First time up, next time pick a point } return AdjustCornuCurve(C_UP, pos, InfoMessage); //Run Adjust @@ -1934,9 +2072,10 @@ STATUS_T CmdCornuModify (track_p trk, wAction_t action, coOrd pos, DIST_T trackG return AdjustCornuCurve(action, pos, InfoMessage); } //Space bar or enter means done - if ( (action>>8 != ' ') && (action>>8 != 13) ) + if ( (action>>8 != ' ') && (action>>8 != 13) ) { return C_CONTINUE; - /* no break */ + } + /* no break */ case C_OK: if (infoSubst) { InfoSubstituteControls( NULL, NULL ); @@ -1952,28 +2091,31 @@ STATUS_T CmdCornuModify (track_p trk, wAction_t action, coOrd pos, DIST_T trackG wBeep(); return C_CONTINUE; } - for (int i=0;i<2;i++) { + for (int i=0; i<2; i++) { if (Da.trk[i] && - !(QueryTrack(Da.trk[i],Q_CAN_ADD_ENDPOINTS))) { // Not Turntable + !(QueryTrack(Da.trk[i],Q_CAN_ADD_ENDPOINTS))) { // Not Turntable if (FindDistance(Da.pos[i],GetTrkEndPos(Da.trk[i],1-Da.ep[i])) < minLength) { wBeep(); - InfoMessage(_("Cornu end %d too close to other end of connect track - reposition it"),i+1); + InfoMessage( + _("Cornu end %d too close to other end of connect track - reposition it"),i+1); return C_CONTINUE; } } } UndoStart( _("Modify Cornu"), "newCornu - CR" ); - for (int i=0;i<2;i++) { + for (int i=0; i<2; i++) { if (!Da.trk[i] && Da.extend[i]) { if (Da.extendSeg[i].type == SEG_STRTRK) { - Da.trk[i] = NewStraightTrack(Da.extendSeg[i].u.l.pos[0],Da.extendSeg[i].u.l.pos[1]); - if (Da.trk[i]) Da.ep[i] = 1-i; + Da.trk[i] = NewStraightTrack(Da.extendSeg[i].u.l.pos[0], + Da.extendSeg[i].u.l.pos[1]); + if (Da.trk[i]) { Da.ep[i] = 1-i; } } else { - Da.trk[i] = NewCurvedTrack(Da.extendSeg[i].u.c.center,fabs(Da.extendSeg[i].u.c.radius), - Da.extendSeg[i].u.c.a0,Da.extendSeg[i].u.c.a1,FALSE); + Da.trk[i] = NewCurvedTrack(Da.extendSeg[i].u.c.center, + fabs(Da.extendSeg[i].u.c.radius), + Da.extendSeg[i].u.c.a0,Da.extendSeg[i].u.c.a1,FALSE); if (FindDistance(GetTrkEndPos(Da.trk[i],0),Da.pos[i])<=connectDistance) { Da.ep[i] = 0; - } else Da.ep[i] = 1; + } else { Da.ep[i] = 1; } } if (!Da.trk[i]) { wBeep(); @@ -1991,17 +2133,18 @@ STATUS_T CmdCornuModify (track_p trk, wAction_t action, coOrd pos, DIST_T trackG sub_pos[0] = Da.pos[0]; track_p first_trk= NULL,trk1=NULL,trk2 = NULL; - for (int i=0;i<Da.mid_points.cnt;i++) { + for (int i=0; i<Da.mid_points.cnt; i++) { sub_pos[1] = DYNARR_N(coOrd,Da.mid_points,i); if ((trk1 = CreateCornuFromPoints(sub_pos, end_point))== NULL) { wBeep(); - InfoMessage(_("Cornu Create Failed for p1[%0.3f,%0.3f] p2[%0.3f,%0.3f], c1[%0.3f,%0.3f] c2[%0.3f,%0.3f], a1=%0.3f a2=%0.3f, r1=%s r2=%s"), - Da.pos[0].x,Da.pos[0].y, - Da.pos[1].x,Da.pos[1].y, - Da.center[0].x,Da.center[0].y, - Da.center[1].x,Da.center[1].y, - Da.angle[0],Da.angle[1], - FormatDistance(Da.radius[0]),FormatDistance(Da.radius[1])); + InfoMessage( + _("Cornu Create Failed for p1[%0.3f,%0.3f] p2[%0.3f,%0.3f], c1[%0.3f,%0.3f] c2[%0.3f,%0.3f], a1=%0.3f a2=%0.3f, r1=%s r2=%s"), + Da.pos[0].x,Da.pos[0].y, + Da.pos[1].x,Da.pos[1].y, + Da.center[0].x,Da.center[0].y, + Da.center[1].x,Da.center[1].y, + Da.angle[0],Da.angle[1], + FormatDistance(Da.radius[0]),FormatDistance(Da.radius[1])); UndoUndo(NULL); Da.state = NONE; return C_TERMINATE; @@ -2015,8 +2158,8 @@ STATUS_T CmdCornuModify (track_p trk, wAction_t action, coOrd pos, DIST_T trackG SetTrkBits( trk1, TB_HIDEDESC ); } DrawNewTrack(trk1); - if (first_trk == NULL) first_trk = trk1; - if (trk2) ConnectTracks(trk1,0,trk2,1); + if (first_trk == NULL) { first_trk = trk1; } + if (trk2) { ConnectTracks(trk1,0,trk2,1); } trk2 = trk1; end_point[0] = FALSE; sub_pos[0] = DYNARR_N(coOrd,Da.mid_points,i); @@ -2025,13 +2168,14 @@ STATUS_T CmdCornuModify (track_p trk, wAction_t action, coOrd pos, DIST_T trackG end_point[1] = TRUE; if ((trk1 = CreateCornuFromPoints(sub_pos,end_point)) == NULL) { wBeep(); - InfoMessage(_("Cornu Create Failed for p1[%0.3f,%0.3f] p2[%0.3f,%0.3f], c1[%0.3f,%0.3f] c2[%0.3f,%0.3f], a1=%0.3f a2=%0.3f, r1=%s r2=%s"), - Da.pos[0].x,Da.pos[0].y, - Da.pos[1].x,Da.pos[1].y, - Da.center[0].x,Da.center[0].y, - Da.center[1].x,Da.center[1].y, - Da.angle[0],Da.angle[1], - FormatDistance(Da.radius[0]),FormatDistance(Da.radius[1])); + InfoMessage( + _("Cornu Create Failed for p1[%0.3f,%0.3f] p2[%0.3f,%0.3f], c1[%0.3f,%0.3f] c2[%0.3f,%0.3f], a1=%0.3f a2=%0.3f, r1=%s r2=%s"), + Da.pos[0].x,Da.pos[0].y, + Da.pos[1].x,Da.pos[1].y, + Da.center[0].x,Da.center[0].y, + Da.center[1].x,Da.center[1].y, + Da.angle[0],Da.angle[1], + FormatDistance(Da.radius[0]),FormatDistance(Da.radius[1])); UndoUndo(NULL); Da.state = NONE; return C_TERMINATE; @@ -2045,27 +2189,30 @@ STATUS_T CmdCornuModify (track_p trk, wAction_t action, coOrd pos, DIST_T trackG SetTrkScale( trk1, GetLayoutCurScale() ); SetTrkBits( trk1, TB_HIDEDESC ); } - if (trk2) ConnectTracks(trk1,0,trk2,1); - if (first_trk == NULL) first_trk = trk1; + if (trk2) { ConnectTracks(trk1,0,trk2,1); } + if (first_trk == NULL) { first_trk = trk1; } Da.state = NONE; //Must do before Delete - for (int i=0;i<Da.tracks.cnt;i++) { + for (int i=0; i<Da.tracks.cnt; i++) { DeleteTrack(DYNARR_N(track_p,Da.tracks,i), TRUE); } - if (Da.trk[0]) UndoModify(Da.trk[0]); - if (Da.trk[1]) UndoModify(Da.trk[1]); + if (Da.trk[0]) { UndoModify(Da.trk[0]); } + if (Da.trk[1]) { UndoModify(Da.trk[1]); } - for (int i=0;i<2;i++) { //Attach new track + for (int i=0; i<2; i++) { //Attach new track if (Da.trk[i] && Da.ep[i] != -1) { //Like the old track if (MoveEndPt(&Da.trk[i],&Da.ep[i],Da.pos[i],0)) { //Bezier split position not precise, so readjust Cornu - GetConnectedTrackParms(Da.trk[i],GetTrkEndPos(Da.trk[i],Da.ep[i]),i,Da.ep[i],FALSE); + GetConnectedTrackParms(Da.trk[i],GetTrkEndPos(Da.trk[i],Da.ep[i]),i,Da.ep[i], + FALSE); ANGLE_T endAngle = NormalizeAngle(GetTrkEndAngle(Da.trk[i],Da.ep[i])+180); - SetCornuEndPt(i==0?first_trk:trk1,i,GetTrkEndPos(Da.trk[i],Da.ep[i]),Da.center[i],endAngle,Da.radius[i]); - if (Da.ep[i]>= 0) + SetCornuEndPt(i==0?first_trk:trk1,i,GetTrkEndPos(Da.trk[i],Da.ep[i]), + Da.center[i],endAngle,Da.radius[i]); + if (Da.ep[i]>= 0) { ConnectTracks(i==0?first_trk:trk1,i,Da.trk[i],Da.ep[i]); + } } else { UndoUndo(NULL); wBeep(); @@ -2100,11 +2247,12 @@ STATUS_T CmdCornuModify (track_p trk, wAction_t action, coOrd pos, DIST_T trackG /* * Find length by adding up the underlying segments. The segments can be straights, curves or bezier. */ -DIST_T CornuLength(coOrd pos[4],dynArr_t segs) { +DIST_T CornuLength(coOrd pos[4],dynArr_t segs) +{ DIST_T dd = 0.0; - if (segs.cnt == 0 ) return dd; - for (int i = 0;i<segs.cnt;i++) { + if (segs.cnt == 0 ) { return dd; } + for (int i = 0; i<segs.cnt; i++) { trkSeg_t t = DYNARR_N(trkSeg_t, segs, i); if (t.type == SEG_CRVTRK || t.type == SEG_CRVLIN) { dd += fabs(t.u.c.radius*D2R(t.u.c.a1)); @@ -2117,10 +2265,11 @@ DIST_T CornuLength(coOrd pos[4],dynArr_t segs) { return dd; } -DIST_T CornuOffsetLength(dynArr_t segs, double offset) { +DIST_T CornuOffsetLength(dynArr_t segs, double offset) +{ DIST_T dd = 0.0; - if (segs.cnt == 0 ) return dd; - for (int i = 0;i<segs.cnt;i++) { + if (segs.cnt == 0 ) { return dd; } + for (int i = 0; i<segs.cnt; i++) { trkSeg_t t = DYNARR_N(trkSeg_t, segs, i); if (t.type == SEG_CRVTRK || t.type == SEG_CRVLIN) { dd += fabs((t.u.c.radius+(t.u.c.radius>0?offset:-offset))*D2R(t.u.c.a1)); @@ -2133,25 +2282,27 @@ DIST_T CornuOffsetLength(dynArr_t segs, double offset) { return dd; } -DIST_T CornuMinRadius(coOrd pos[4],dynArr_t segs) { +DIST_T CornuMinRadius(coOrd pos[4],dynArr_t segs) +{ DIST_T r = DIST_INF, rr; - if (segs.cnt == 0 ) return r; - for (int i = 0;i<segs.cnt;i++) { + if (segs.cnt == 0 ) { return r; } + for (int i = 0; i<segs.cnt; i++) { trkSeg_t t = DYNARR_N(trkSeg_t, segs, i); if (t.type == SEG_CRVTRK || t.type == SEG_CRVLIN) { rr = fabs(t.u.c.radius); } else if (t.type == SEG_BEZLIN || t.type == SEG_BEZTRK) { rr = CornuMinRadius(t.u.b.pos, t.bezSegs); - } else rr = DIST_INF; - if (rr<r) r = rr; + } else { rr = DIST_INF; } + if (rr<r) { r = rr; } } return r; } -DIST_T CornuTotalWindingArc(coOrd pos[4],dynArr_t segs) { +DIST_T CornuTotalWindingArc(coOrd pos[4],dynArr_t segs) +{ DIST_T rr = 0; - if (segs.cnt == 0 ) return 0; - for (int i = 0;i<segs.cnt;i++) { + if (segs.cnt == 0 ) { return 0; } + for (int i = 0; i<segs.cnt; i++) { trkSeg_t t = DYNARR_N(trkSeg_t, segs, i); if (t.type == SEG_CRVTRK || t.type == SEG_CRVLIN) { rr += t.u.c.a1; @@ -2162,14 +2313,16 @@ DIST_T CornuTotalWindingArc(coOrd pos[4],dynArr_t segs) { return rr; } -DIST_T CornuMaxRateofChangeofCurvature(coOrd pos[4], dynArr_t segs, DIST_T * last_c) { +DIST_T CornuMaxRateofChangeofCurvature(coOrd pos[4], dynArr_t segs, + DIST_T * last_c) +{ DIST_T r_max = 0.0, rc, lc = 0.0; lc = * last_c; segProcData_t segProcData; - if (segs.cnt == 0 ) return r_max; - for (int i = 0;i<segs.cnt;i++) { + if (segs.cnt == 0 ) { return r_max; } + for (int i = 0; i<segs.cnt; i++) { trkSeg_t t = DYNARR_N(trkSeg_t, segs, i); - if (t.type == SEG_FILCRCL) continue; + if (t.type == SEG_FILCRCL) { continue; } SegProc(SEGPROC_LENGTH,&t,&segProcData); if (t.type == SEG_CRVTRK || t.type == SEG_CRVLIN) { rc = fabs(1/fabs(t.u.c.radius) - lc)/segProcData.length.length/2; @@ -2180,7 +2333,7 @@ DIST_T CornuMaxRateofChangeofCurvature(coOrd pos[4], dynArr_t segs, DIST_T * las rc = fabs(0.0-lc)/segProcData.length.length/2; lc = 0.0; } - if (rc > r_max) r_max = rc; + if (rc > r_max) { r_max = rc; } } * last_c = lc; return r_max; @@ -2206,7 +2359,7 @@ STATUS_T CmdCornu( wAction_t action, coOrd pos ) Da.commandType = CORNU_CREATE; - Da.width = (double)lineWidth/mainD.dpi; + Da.lineWidth = (double)lineWidth; Da.trackGauge = trackGauge; Da.selectTrack = NULL; @@ -2221,7 +2374,7 @@ STATUS_T CmdCornu( wAction_t action, coOrd pos ) Da.selectMidPoint = -1; Da.endHandle[0].end_valid = FALSE; Da.endHandle[1].end_valid = FALSE; - for (int i=0;i<2;i++) { + for (int i=0; i<2; i++) { Da.ends[i] = FALSE; Da.pos[i] = zero; Da.angle[i] = 0.0; @@ -2233,21 +2386,23 @@ STATUS_T CmdCornu( wAction_t action, coOrd pos ) Da.ep1Segs_da_cnt = 0; Da.ep2Segs_da_cnt = 0; Da.crvSegs_da_cnt = 0; - Da.midSegs.cnt = 0; + DYNARR_RESET( trkSeg_t*, Da.midSegs ); DYNARR_RESET(coOrd,Da.mid_points); DYNARR_RESET(track_p,Da.tracks); DYNARR_RESET(trkSeg_t,anchors_da); Da.extend[0] = FALSE; Da.extend[1] = FALSE; - if (Da.cmdType == cornuCmdCreateTrack) + if (Da.cmdType == cornuCmdCreateTrack) { InfoMessage( _("Left click - Start Cornu track") ); - else if (Da.cmdType == cornuCmdHotBar) { + } else if (Da.cmdType == cornuCmdHotBar) { InfoMessage( _("Left click - Place Flextrack") ); } else { - if (selectedTrackCount==0) + if (selectedTrackCount==0) { InfoMessage( _("Left click - join with Cornu track") ); - else - InfoMessage( _("Left click - join with Cornu track, Shift Left click - move to join") ); + } else { + InfoMessage( + _("Left click - join with Cornu track, Shift Left click - move to join") ); + } } return C_CONTINUE; @@ -2257,11 +2412,12 @@ STATUS_T CmdCornu( wAction_t action, coOrd pos ) coOrd p = pos; t = NULL; int end = 0; - if (Da.state != NONE) end=1; + if (Da.state != NONE) { end=1; } EPINX_T ep = -1; //Lock to endpoint if one is available and under pointer if ((t = OnTrack(&p, FALSE, TRUE)) != NULL && t != Da.selectTrack) { - if (QueryTrack(t,Q_HAS_VARIABLE_ENDPOINTS)) { //Circle/Helix find if there is an open slot and where + if (QueryTrack(t, + Q_HAS_VARIABLE_ENDPOINTS)) { //Circle/Helix find if there is an open slot and where if ((GetTrkEndTrk(t,0) != NULL) && (GetTrkEndTrk(t,1) != NULL)) { wBeep(); InfoMessage(_("Helix Already Connected")); @@ -2271,12 +2427,14 @@ STATUS_T CmdCornu( wAction_t action, coOrd pos ) } else if (QueryTrack(t,Q_CAN_ADD_ENDPOINTS)) { ep=-1; //Don't attach to existing Turntable ep trackParams_t tp; - if (!GetTrackParams(PARAMS_CORNU, t, pos, &tp)) return C_CONTINUE; + if (!GetTrackParams(PARAMS_CORNU, t, pos, &tp)) { return C_CONTINUE; } ANGLE_T a = tp.angle; Translate(&pos,tp.ttcenter,a,tp.ttradius); p = pos; //Fix to wall of turntable initially - } else ep = PickUnconnectedEndPointSilent(p, t); //EP - if ( t && ep==-1 && (!QueryTrack(t,Q_CAN_ADD_ENDPOINTS) && !QueryTrack(t,Q_HAS_VARIABLE_ENDPOINTS))) { //No endpoints and not Turntable or Helix/Circle + } else { ep = PickUnconnectedEndPointSilent(p, t); } //EP + if ( t && ep==-1 && (!QueryTrack(t,Q_CAN_ADD_ENDPOINTS) + && !QueryTrack(t, + Q_HAS_VARIABLE_ENDPOINTS))) { //No endpoints and not Turntable or Helix/Circle wBeep(); InfoMessage(_("No valid open endpoint on that track")); t = NULL; @@ -2293,9 +2451,10 @@ STATUS_T CmdCornu( wAction_t action, coOrd pos ) pos = GetTrkEndPos(t,ep); Da.pos[end] = pos; Da.angle[end] = GetTrkEndAngle(t,ep); - } else if (t == NULL) { //end not on Track, OK for CreateCornu -> empty end point + } else if (t == + NULL) { //end not on Track, OK for CreateCornu -> empty end point pos = p; //Reset to initial - if (lock) SnapPos( &pos ); //Only snap if snapped in move + if (lock) { SnapPos( &pos ); } //Only snap if snapped in move if (Da.cmdType == cornuCmdCreateTrack || Da.cmdType == cornuCmdHotBar) { Da.trk[end] = NULL; Da.pos[end] = pos; @@ -2304,25 +2463,28 @@ STATUS_T CmdCornu( wAction_t action, coOrd pos ) Da.state = POS_1; Da.angle[0] = 270.0; Da.radius[0] = 0.0; - Da.ep1Segs_da_cnt = createEndPoint(Da.ep1Segs, Da.pos[0], FALSE,TRUE,TRUE,FALSE,Da.angle[0],Da.radius[0],zero,&Da.endHandle[0]); + Da.ep1Segs_da_cnt = createEndPoint(Da.ep1Segs, Da.pos[0], FALSE,TRUE,TRUE,FALSE, + Da.angle[0],Da.radius[0],zero,&Da.endHandle[0]); Da.ep2Segs_da_cnt = 0; InfoMessage( _("Drag arm in the direction of track") ); return C_CONTINUE; } Da.state = POS_2; //Now this is second end and it is open Da.selectEndPoint = 1; - Da.mid_points.cnt=0; + DYNARR_RESET( trkSeg_t*, Da.midSegs ); Da.angle[1] = GetOpenAngle(Da.pos,Da.angle,1); Da.radius[1] = 0.0; CreateBothEnds(1,-1,-1,-1); SetUpCornuParms(&cp); - if (CallCornuM(Da.mid_points,Da.ends,Da.pos,&cp,&Da.crvSegs_da,TRUE)) - Da.crvSegs_da_cnt = Da.crvSegs_da.cnt; + if (CallCornuM(Da.mid_points,Da.ends,Da.pos,&cp,&Da.crvSegs_da,TRUE)) { + Da.crvSegs_da_cnt = Da.crvSegs_da.cnt; + } InfoMessage( _("Drag arm in the direction of track") ); return C_CONTINUE; } wBeep(); - InfoMessage(_("No Unconnected Track End there")); //Not creating a Cornu - Join can't be open + InfoMessage( + _("No Unconnected Track End there")); //Not creating a Cornu - Join can't be open return C_CONTINUE; } else { Da.pos[end] = p; @@ -2343,16 +2505,17 @@ STATUS_T CmdCornu( wAction_t action, coOrd pos ) } Da.state = POS_1; Da.selectEndPoint = 0; //Select first end point - Da.ep1Segs_da_cnt = createEndPoint(Da.ep1Segs, Da.pos[0], FALSE, !QueryTrack(Da.trk[0],Q_IS_CORNU),QueryTrack(Da.trk[0],Q_CORNU_CAN_MODIFY), - Da.trk[0]!=NULL,Da.angle[0],Da.radius[0],Da.center[0],NULL); + Da.ep1Segs_da_cnt = createEndPoint(Da.ep1Segs, Da.pos[0], FALSE, + !QueryTrack(Da.trk[0],Q_IS_CORNU),QueryTrack(Da.trk[0],Q_CORNU_CAN_MODIFY), + Da.trk[0]!=NULL,Da.angle[0],Da.radius[0],Da.center[0],NULL); InfoMessage( _("Locked - Move 1st end point of Cornu track along track 1") ); return C_CONTINUE; } else { //Second Point if (Da.trk[0] == t) { - ErrorMessage( MSG_JOIN_CORNU_SAME ); - Da.trk[1] = NULL; - Da.ep[1] = -1; - return C_CONTINUE; + ErrorMessage( MSG_JOIN_CORNU_SAME ); + Da.trk[1] = NULL; + Da.ep[1] = -1; + return C_CONTINUE; } if (!GetConnectedTrackParms(t, pos, 1, Da.ep[1],FALSE)) { Da.trk[1] = NULL; //Turntable Fail @@ -2373,8 +2536,9 @@ STATUS_T CmdCornu( wAction_t action, coOrd pos ) } CreateBothEnds(1,-1,-1,-1); SetUpCornuParms(&cp); - if (CallCornuM(Da.mid_points,Da.ends,Da.pos,&cp,&Da.crvSegs_da,TRUE)) + if (CallCornuM(Da.mid_points,Da.ends,Da.pos,&cp,&Da.crvSegs_da,TRUE)) { Da.crvSegs_da_cnt = Da.crvSegs_da.cnt; + } return C_CONTINUE; } else { //This is after both ends exist return AdjustCornuCurve( action&0xFF, pos, InfoMessage ); @@ -2384,27 +2548,30 @@ STATUS_T CmdCornu( wAction_t action, coOrd pos ) case wActionMove: lock = FALSE; DYNARR_RESET(trkSeg_t,anchors_da); - if (Da.state != NONE && Da.state != LOC_2) return C_CONTINUE; - if (Da.trk[0] && Da.trk[1]) return C_CONTINUE; + if (Da.state != NONE && Da.state != LOC_2) { return C_CONTINUE; } + if (Da.trk[0] && Da.trk[1]) { return C_CONTINUE; } EPINX_T ep = -1; t = NULL; if (((MyGetKeyState() & WKEY_ALT) == 0) == magneticSnap) { //Lock to endpoint if one is available and under pointer if ((t = OnTrack(&pos, FALSE, TRUE)) != NULL && t != Da.selectTrack) { - if (QueryTrack(t,Q_HAS_VARIABLE_ENDPOINTS)) { //Circle/Helix find if there is an open slot and where + if (QueryTrack(t, + Q_HAS_VARIABLE_ENDPOINTS)) { //Circle/Helix find if there is an open slot and where if ((GetTrkEndTrk(t,0) != NULL) && (GetTrkEndTrk(t,1) != NULL)) { return C_CONTINUE; } ep = -1; //Not a real ep yet - } else ep = PickUnconnectedEndPointSilent(pos, t); //EP - if (ep>=0 && QueryTrack(t,Q_CAN_ADD_ENDPOINTS)) ep=-1; //Don't attach to Turntable - if ( ep==-1 && (!QueryTrack(t,Q_CAN_ADD_ENDPOINTS) && !QueryTrack(t,Q_HAS_VARIABLE_ENDPOINTS))) { //No endpoints and not Turntable or Helix/Circle + } else { ep = PickUnconnectedEndPointSilent(pos, t); } //EP + if (ep>=0 && QueryTrack(t,Q_CAN_ADD_ENDPOINTS)) { ep=-1; } //Don't attach to Turntable + if ( ep==-1 && (!QueryTrack(t,Q_CAN_ADD_ENDPOINTS) + && !QueryTrack(t, + Q_HAS_VARIABLE_ENDPOINTS))) { //No endpoints and not Turntable or Helix/Circle return C_CONTINUE; } if (GetTrkGauge(t) != GetScaleTrackGauge(GetLayoutCurScale())) { return C_CONTINUE; } - if (Da.state != NONE && t==Da.trk[0]) return C_CONTINUE; + if (Da.state != NONE && t==Da.trk[0]) { return C_CONTINUE; } } } if (ep>=0 && t) { @@ -2412,41 +2579,47 @@ STATUS_T CmdCornu( wAction_t action, coOrd pos ) CreateCornuEndAnchor(pos,TRUE); } else if (t) { trackParams_t tp; //Turntable or extendable track - if (!GetTrackParams(PARAMS_CORNU, t, pos, &tp)) return C_CONTINUE; + if (!GetTrackParams(PARAMS_CORNU, t, pos, &tp)) { return C_CONTINUE; } if (QueryTrack(t,Q_CAN_ADD_ENDPOINTS)) { - if (!GetTrackParams(PARAMS_CORNU, t, pos, &tp)) return C_CONTINUE; + if (!GetTrackParams(PARAMS_CORNU, t, pos, &tp)) { return C_CONTINUE; } ANGLE_T a = tp.angle; Translate(&pos,tp.ttcenter,a,tp.ttradius); CreateCornuEndAnchor(pos,TRUE); - } else CreateCornuEndAnchor(pos,TRUE); + } else { CreateCornuEndAnchor(pos,TRUE); } } else if (SnapPos(&pos)) { CreateCornuEndAnchor(pos,FALSE); lock = TRUE; } return C_CONTINUE; - + case C_MOVE: if (Da.state == NONE) { //First point not created if (Da.cmdType == cornuCmdCreateTrack || Da.cmdType == cornuCmdHotBar) { InfoMessage("Place 1st end point of Cornu track"); - } else + } else if (Da.cmdType == cornuJoinTrack) { + return C_CONTINUE; + } else { InfoMessage("Place 1st end point of Cornu track on unconnected end-point"); + } return C_CONTINUE; } if (Da.state == POS_1) { //First point has been created - if ((Da.cmdType == cornuCmdCreateTrack || Da.cmdType == cornuCmdHotBar) && !Da.trk[0]) { //OK for CreateCornu -> No track selected - if (IsClose(FindDistance(pos,Da.pos[0]))) return C_CONTINUE; + if ((Da.cmdType == cornuCmdCreateTrack || Da.cmdType == cornuCmdHotBar) + && !Da.trk[0]) { //OK for CreateCornu -> No track selected + if (IsClose(FindDistance(pos,Da.pos[0]))) { return C_CONTINUE; } Da.selectEndPoint = 0; Da.angle[0] = NormalizeAngle(FindAngle(Da.pos[0],pos)+180); - Da.ep1Segs_da_cnt = createEndPoint(Da.ep1Segs, Da.pos[0],TRUE,TRUE,TRUE,FALSE,Da.angle[0],0.0,zero,&Da.endHandle[0]); + Da.ep1Segs_da_cnt = createEndPoint(Da.ep1Segs, Da.pos[0],TRUE,TRUE,TRUE,FALSE, + Da.angle[0],0.0,zero,&Da.endHandle[0]); Da.radius[1] = -1.0; /*No end*/ return C_CONTINUE; } EPINX_T ep = 0; - BOOL_T found = FALSE; - int end = Da.state==POS_1?0:1; - if(!QueryTrack(Da.trk[0],Q_CORNU_CAN_MODIFY) && !QueryTrack(Da.trk[0],Q_CAN_ADD_ENDPOINTS)) { +// BOOL_T found = FALSE; +// int end = Da.state==POS_1?0:1; + if(!QueryTrack(Da.trk[0],Q_CORNU_CAN_MODIFY) + && !QueryTrack(Da.trk[0],Q_CAN_ADD_ENDPOINTS)) { InfoMessage(_("Track can't be split - so locked to endpoint")); return C_CONTINUE; } @@ -2464,18 +2637,21 @@ STATUS_T CmdCornu( wAction_t action, coOrd pos ) return C_CONTINUE; } Da.pos[ep] = pos; - Da.ep1Segs_da_cnt = createEndPoint(Da.ep1Segs,Da.pos[0],TRUE,!QueryTrack(Da.trk[0],Q_IS_CORNU),QueryTrack(Da.trk[0],Q_CORNU_CAN_MODIFY), - Da.trk[0]!=NULL,Da.angle[0],Da.radius[0],Da.center[0],NULL); + Da.ep1Segs_da_cnt = createEndPoint(Da.ep1Segs,Da.pos[0],TRUE, + !QueryTrack(Da.trk[0],Q_IS_CORNU),QueryTrack(Da.trk[0],Q_CORNU_CAN_MODIFY), + Da.trk[0]!=NULL,Da.angle[0],Da.radius[0],Da.center[0],NULL); } else if (Da.state == POS_2 && - (Da.cmdType == cornuCmdCreateTrack || Da.cmdType == cornuCmdHotBar) && !Da.trk[1]) { //OK for CreateCornu -> No track selected - if (IsClose(FindDistance(pos,Da.pos[1]))) return C_CONTINUE; + (Da.cmdType == cornuCmdCreateTrack || Da.cmdType == cornuCmdHotBar) + && !Da.trk[1]) { //OK for CreateCornu -> No track selected + if (IsClose(FindDistance(pos,Da.pos[1]))) { return C_CONTINUE; } Da.selectEndPoint = 1; Da.angle[1] = NormalizeAngle(FindAngle(Da.pos[1],pos)+180); Da.radius[1] = 0.0; /*No end*/ - Da.ep1Segs_da_cnt = createEndPoint(Da.ep2Segs,Da.pos[1],TRUE,TRUE,TRUE,FALSE,Da.angle[1],0.0,zero,&Da.endHandle[1]); + Da.ep1Segs_da_cnt = createEndPoint(Da.ep2Segs,Da.pos[1],TRUE,TRUE,TRUE,FALSE, + Da.angle[1],0.0,zero,&Da.endHandle[1]); SetUpCornuParms(&cp); - if (CallCornuM(Da.mid_points,Da.ends,Da.pos,&cp,&Da.crvSegs_da,TRUE)) Da.crvSegs_da_cnt = Da.crvSegs_da.cnt; - else Da.crvSegs_da_cnt = 0; + if (CallCornuM(Da.mid_points,Da.ends,Da.pos,&cp,&Da.crvSegs_da,TRUE)) { Da.crvSegs_da_cnt = Da.crvSegs_da.cnt; } + else { Da.crvSegs_da_cnt = 0; } CreateBothEnds(-1,-1,-1,-1); Da.minRadius = CornuMinRadius(Da.pos,Da.crvSegs_da); return C_CONTINUE; @@ -2485,32 +2661,41 @@ STATUS_T CmdCornu( wAction_t action, coOrd pos ) return C_CONTINUE; case C_UP: - if (Da.state == POS_1 && (Da.cmdType == cornuCmdCreateTrack || Da.cmdType == cornuCmdHotBar || Da.trk[0])) { + if (Da.state == POS_1 && (Da.cmdType == cornuCmdCreateTrack + || Da.cmdType == cornuCmdHotBar || Da.trk[0])) { Da.state = LOC_2; Da.selectEndPoint = -1; if (Da.cmdType == cornuCmdCreateTrack || Da.cmdType == cornuCmdHotBar) { - if (Da.cmdType == cornuCmdCreateTrack) + if (Da.cmdType == cornuCmdCreateTrack) { InfoMessage( _("Pick other end of Cornu") ); - else - InfoMessage( _("Select flextrack ends or anchors and drag, Enter to approve, Esc to Cancel") ); - Da.ep1Segs_da_cnt = createEndPoint(Da.ep1Segs, Da.pos[0],FALSE,TRUE,TRUE,FALSE,0.0,0.0,zero,NULL); + } else { + InfoMessage( + _("Select flextrack ends or anchors and drag, Enter to approve, Esc to Cancel") ); + } + Da.ep1Segs_da_cnt = createEndPoint(Da.ep1Segs, Da.pos[0],FALSE,TRUE,TRUE,FALSE, + 0.0,0.0,zero,NULL); return C_CONTINUE; } - InfoMessage( _("Put other end of Cornu on a track with an unconnected end point") ); + InfoMessage( + _("Put other end of Cornu on a track with an unconnected end point") ); if (Da.trk[0]) - Da.ep1Segs_da_cnt = createEndPoint(Da.ep1Segs, Da.pos[0], FALSE,!QueryTrack(Da.trk[0],Q_IS_CORNU),QueryTrack(Da.trk[0],Q_CORNU_CAN_MODIFY), - Da.trk[0]!=NULL,Da.angle[0],Da.radius[0],Da.center[0],NULL); - else - Da.ep1Segs_da_cnt = createEndPoint(Da.ep1Segs, Da.pos[0], FALSE,TRUE,TRUE,FALSE, Da.angle[0],Da.radius[0],Da.center[0],&Da.endHandle[0]); + Da.ep1Segs_da_cnt = createEndPoint(Da.ep1Segs, Da.pos[0], FALSE, + !QueryTrack(Da.trk[0],Q_IS_CORNU),QueryTrack(Da.trk[0],Q_CORNU_CAN_MODIFY), + Da.trk[0]!=NULL,Da.angle[0],Da.radius[0],Da.center[0],NULL); + else { + Da.ep1Segs_da_cnt = createEndPoint(Da.ep1Segs, Da.pos[0], FALSE,TRUE,TRUE,FALSE, + Da.angle[0],Da.radius[0],Da.center[0],&Da.endHandle[0]); + } return C_CONTINUE; - } else if (Da.state == POS_2 && (Da.cmdType == cornuCmdCreateTrack || Da.cmdType == cornuCmdHotBar || Da.trk[1] )){ + } else if (Da.state == POS_2 && (Da.cmdType == cornuCmdCreateTrack + || Da.cmdType == cornuCmdHotBar || Da.trk[1] )) { Da.state = PICK_POINT; Da.selectEndPoint = -1; Da.prevEndPoint = 1; Da.prevSelected = -1; SetUpCornuParms(&cp); - if (CallCornuM(Da.mid_points,Da.ends,Da.pos,&cp,&Da.crvSegs_da,TRUE)) Da.crvSegs_da_cnt = Da.crvSegs_da.cnt; - else Da.crvSegs_da_cnt = 0; + if (CallCornuM(Da.mid_points,Da.ends,Da.pos,&cp,&Da.crvSegs_da,TRUE)) { Da.crvSegs_da_cnt = Da.crvSegs_da.cnt; } + else { Da.crvSegs_da_cnt = 0; } CreateBothEnds(-1,-1,-1,-1); Da.minRadius = CornuMinRadius(Da.pos,Da.crvSegs_da); return C_CONTINUE; @@ -2520,21 +2705,23 @@ STATUS_T CmdCornu( wAction_t action, coOrd pos ) return C_CONTINUE; break; case C_TEXT: - if (Da.state != PICK_POINT) return C_CONTINUE; - if ((action>>8 == 127) || (action>>8 == 8)) // - return AdjustCornuCurve(action, pos, InfoMessage); - if (!(action>>8 == 32 )) //Space is same as Enter. - return C_CONTINUE; - /* no break */ - case C_OK: - if (Da.state != PICK_POINT) return C_CONTINUE; - STATUS_T rc = AdjustCornuCurve( C_OK, pos, InfoMessage); - if (rc == C_TERMINATE) { - Da.state = NONE; - Da.ep1Segs_da_cnt = 0; + if (Da.state != PICK_POINT) { return C_CONTINUE; } + if ((action>>8 == 127) || (action>>8 == 8)) { // + return AdjustCornuCurve(action, pos, InfoMessage); + } + if (!(action>>8 == 32 )) { //Space is same as Enter. + return C_CONTINUE; + } + /* no break */ + case C_OK: + if (Da.state != PICK_POINT) { return C_CONTINUE; } + STATUS_T rc = AdjustCornuCurve( C_OK, pos, InfoMessage); + if (rc == C_TERMINATE) { + Da.state = NONE; + Da.ep1Segs_da_cnt = 0; Da.ep2Segs_da_cnt = 0; Da.crvSegs_da_cnt = 0; - for (int i=0;i<2;i++) { + for (int i=0; i<2; i++) { Da.radius[i] = 0.0; Da.angle[i] = 0.0; Da.center[i] = zero; @@ -2544,22 +2731,24 @@ STATUS_T CmdCornu( wAction_t action, coOrd pos ) Da.endHandle[i].end_valid = FALSE; } SetAllTrackSelect( FALSE ); - } - return rc; + } + return rc; case C_REDRAW: wSetCursor(mainD.d,defaultCursor); DrawHighlightBoxes(FALSE,FALSE,NULL); HighlightSelectedTracks(NULL, TRUE, TRUE); if ( Da.state != NONE ) { - DrawCornuCurve(NULL,Da.ep1Segs,Da.ep1Segs_da_cnt,Da.ep2Segs,Da.ep2Segs_da_cnt,(trkSeg_t *)Da.crvSegs_da.ptr,Da.crvSegs_da_cnt, NULL, - Da.extend[0]?&Da.extendSeg[0]:NULL,Da.extend[1]?&Da.extendSeg[1]:NULL,(trkSeg_t *)Da.midSegs.ptr,Da.midSegs.cnt,wDrawColorBlack); + DrawCornuCurve(NULL,Da.ep1Segs,Da.ep1Segs_da_cnt,Da.ep2Segs,Da.ep2Segs_da_cnt, + &DYNARR_N(trkSeg_t,Da.crvSegs_da,0),Da.crvSegs_da_cnt, NULL, + Da.extend[0]?&Da.extendSeg[0]:NULL,Da.extend[1]?&Da.extendSeg[1]:NULL, + &DYNARR_N(trkSeg_t,Da.midSegs,0),Da.midSegs.cnt,wDrawColorBlack); } - if (anchors_da.cnt) - DrawSegs( &tempD, zero, 0.0, &anchors(0), anchors_da.cnt, trackGauge, wDrawColorBlack ); - if (MyGetKeyState()&WKEY_SHIFT) DrawHighlightBoxes(FALSE,FALSE,NULL); + DrawSegsDA( &tempD, NULL, zero, 0.0, &anchors_da, trackGauge, wDrawColorBlack, + 0 ); + if (MyGetKeyState()&WKEY_SHIFT) { DrawHighlightBoxes(FALSE,FALSE,NULL); } - if (Da.state == POINT_PICKED) wSetCursor(mainD.d,wCursorNone); + if (Da.state == POINT_PICKED) { wSetCursor(mainD.d,wCursorNone); } return C_CONTINUE; @@ -2568,7 +2757,7 @@ STATUS_T CmdCornu( wAction_t action, coOrd pos ) Da.ep1Segs_da_cnt = 0; Da.ep2Segs_da_cnt = 0; Da.crvSegs_da_cnt = 0; - for (int i=0;i<2;i++) { + for (int i=0; i<2; i++) { Da.radius[i] = 0.0; Da.angle[i] = 0.0; Da.center[i] = zero; @@ -2586,20 +2775,21 @@ STATUS_T CmdCornu( wAction_t action, coOrd pos ) infoSubst = FALSE; } return C_CONTINUE; - + default: - return C_CONTINUE; + return C_CONTINUE; } return C_CONTINUE; } -BOOL_T GetTracksFromCornuTrack(track_p trk, track_p newTracks[2]) { +BOOL_T GetTracksFromCornuTrack(track_p trk, track_p newTracks[2]) +{ track_p trk_old = NULL; newTracks[0] = NULL, newTracks[1] = NULL; struct extraDataCornu_t * xx = GET_EXTRA_DATA(trk, T_CORNU, extraDataCornu_t); - if (!IsTrack(trk)) return FALSE; - for (int i=0; i<xx->arcSegs.cnt;i++) { + if (!IsTrack(trk)) { return FALSE; } + for (int i=0; i<xx->arcSegs.cnt; i++) { track_p bezTrack[2]; bezTrack[0] = NULL, bezTrack[1] = NULL; trkSeg_p seg = &DYNARR_N(trkSeg_t,xx->arcSegs,i); @@ -2607,15 +2797,17 @@ BOOL_T GetTracksFromCornuTrack(track_p trk, track_p newTracks[2]) { DYNARR_RESET(trkSeg_t,seg->bezSegs); FixUpBezierSeg(seg->u.b.pos,seg,TRUE); GetTracksFromBezierSegment(seg, bezTrack, trk); - if (newTracks[0] == NULL) newTracks[0] = bezTrack[0]; + if (newTracks[0] == NULL) { newTracks[0] = bezTrack[0]; } newTracks[1] = bezTrack[1]; if (trk_old) { - for (int i=0;i<2;i++) { + for (int i=0; i<2; i++) { if (GetTrkEndTrk(trk_old,i)==NULL) { coOrd pos = GetTrkEndPos(trk_old,i); EPINX_T ep_n = PickUnconnectedEndPoint(pos,bezTrack[0]); - if ((connectDistance >= FindDistance(GetTrkEndPos(trk_old,i),GetTrkEndPos(bezTrack[0],ep_n))) && - (connectAngle >= fabs(DifferenceBetweenAngles(GetTrkEndAngle(trk_old,i),GetTrkEndAngle(bezTrack[0],ep_n)+180))) ) { + if ((connectDistance >= FindDistance(GetTrkEndPos(trk_old,i), + GetTrkEndPos(bezTrack[0],ep_n))) && + (connectAngle >= fabs(DifferenceBetweenAngles(GetTrkEndAngle(trk_old,i), + GetTrkEndAngle(bezTrack[0],ep_n)+180))) ) { ConnectTracks(trk_old,i,bezTrack[0],ep_n); break; } @@ -2624,21 +2816,25 @@ BOOL_T GetTracksFromCornuTrack(track_p trk, track_p newTracks[2]) { } trk_old = newTracks[1]; } else { - track_p new_trk; - if (seg->type == SEG_CRVTRK) - new_trk = NewCurvedTrack(seg->u.c.center,seg->u.c.radius,seg->u.c.a0,seg->u.c.a1,0); - else if (seg->type == SEG_STRTRK) + track_p new_trk = NULL; + if (seg->type == SEG_CRVTRK) { + new_trk = NewCurvedTrack(seg->u.c.center,seg->u.c.radius,seg->u.c.a0, + seg->u.c.a1,0); + } else if (seg->type == SEG_STRTRK) { new_trk = NewStraightTrack(seg->u.l.pos[0],seg->u.l.pos[1]); - if (newTracks[0] == NULL) newTracks[0] = new_trk; + } + if (newTracks[0] == NULL) { newTracks[0] = new_trk; } CopyAttributes( trk, new_trk ); newTracks[1] = new_trk; if (trk_old) { - for (int i=0;i<2;i++) { + for (int i=0; i<2; i++) { if (GetTrkEndTrk(trk_old,i)==NULL) { coOrd pos = GetTrkEndPos(trk_old,i); EPINX_T ep_n = PickUnconnectedEndPoint(pos,new_trk); - if ((connectDistance >= FindDistance(GetTrkEndPos(trk_old,i),GetTrkEndPos(new_trk,ep_n))) && - (connectAngle >= fabs(DifferenceBetweenAngles(GetTrkEndAngle(trk_old,i),GetTrkEndAngle(new_trk,ep_n)+180)))) { + if ((connectDistance >= FindDistance(GetTrkEndPos(trk_old,i), + GetTrkEndPos(new_trk,ep_n))) && + (connectAngle >= fabs(DifferenceBetweenAngles(GetTrkEndAngle(trk_old,i), + GetTrkEndAngle(new_trk,ep_n)+180)))) { ConnectTracks(trk_old,i,new_trk,ep_n); break; } @@ -2653,8 +2849,9 @@ BOOL_T GetTracksFromCornuTrack(track_p trk, track_p newTracks[2]) { } static STATUS_T cmdCornuCreate( - wAction_t action, - coOrd pos ) { + wAction_t action, + coOrd pos ) +{ static int createState = 0; int rc = 0; @@ -2669,8 +2866,9 @@ static STATUS_T cmdCornuCreate( if (createState != 0 ) { createState = 0; CmdCornu( C_OK, pos ); - } else + } else { CmdCornu( C_CANCEL, pos ); + } Da.prevSelected = -1; Da.selectEndHandle = -1; Da.selectEndPoint = -1; @@ -2683,9 +2881,10 @@ static STATUS_T cmdCornuCreate( Da.endHandle[0].end_valid = Da.endHandle[1].end_valid = FALSE; return C_TERMINATE; case C_TEXT: - if ((action>>8) != ' ' && (action>>8) != 32) + if ((action>>8) != ' ' && (action>>8) != 32) { return CmdCornu(action,pos); - /*no break*/ + } + /*no break*/ case C_OK: CmdCornu(C_OK,pos); MainRedraw(); @@ -2695,7 +2894,7 @@ static STATUS_T cmdCornuCreate( CmdCornu(C_CANCEL, pos); createState = 0; rc = C_TERMINATE; - /* no break */ + /* no break */ case C_START: createState = 0; commandContext = I2VP(cornuCmdHotBar); @@ -2718,344 +2917,364 @@ static STATUS_T cmdCornuCreate( } static STATUS_T CmdConvertTo( - wAction_t action, - coOrd pos ) + wAction_t action, + coOrd pos ) { static track_p trk; cornuParm_t cp; switch (action) { case wActionMove: - if ((trk = OnTrack(&pos,FALSE,TRUE)) == NULL) return C_CONTINUE; + if ((trk = OnTrack(&pos,FALSE,TRUE)) == NULL) { return C_CONTINUE; } if (!QueryTrack(trk, Q_CORNU_CAN_MODIFY) && //Not Fixed Track/Turnout/Turntable - !QueryTrack(trk, Q_IGNORE_EASEMENT_ON_EXTEND )) + !QueryTrack(trk, Q_IGNORE_EASEMENT_ON_EXTEND )) { trk = NULL; + } return C_CONTINUE; case C_LCLICK: - if ((trk = OnTrack(&pos,FALSE,TRUE))!=NULL) { - SetTrkBits(trk,TB_SELECTED); - selectedTrackCount = 1; - } else { - wBeep(); - InfoMessage( _("Not on a Track") ); - return C_CONTINUE; - } - trk = NULL; + if ((trk = OnTrack(&pos,FALSE,TRUE))!=NULL) { + SetTrkBits(trk,TB_SELECTED); + selectedTrackCount = 1; + } else { + wBeep(); + InfoMessage( _("Not on a Track") ); + return C_CONTINUE; + } + trk = NULL; - /* no break */ + /* no break */ case C_START: - if (selectedTrackCount==0) { - InfoMessage( _("Select a Track To Convert") ); - return C_CONTINUE; + if (selectedTrackCount==0) { + InfoMessage( _("Select a Track To Convert") ); + return C_CONTINUE; + } else if (selectedTrackCount>1) { + if (NoticeMessage(_("Convert all Selected Tracks to Cornu Tracks?"), _("Yes"), + _("No"))<=0) { + SetAllTrackSelect(FALSE); + return C_TERMINATE; } - else if (selectedTrackCount>1) { - if (NoticeMessage(_("Convert all Selected Tracks to Cornu Tracks?"), _("Yes"), _("No"))<=0) { - SetAllTrackSelect(FALSE); - return C_TERMINATE; - } + } + UndoStart( _("Convert Cornu"),"newCornu curves"); + trk = NULL; + int converted=0, not_convertable = 0, created=0, deleted=0; + DYNARR_RESET(track_p,Da.tracks); + while ( TrackIterate( &trk ) ) { + if (!GetTrkSelected( trk )) { continue; } //Only selected + if (!QueryTrack(trk, Q_CORNU_CAN_MODIFY) && //Not Fixed Track/Turnout/Turntable + !QueryTrack( trk, Q_IGNORE_EASEMENT_ON_EXTEND )) { //But Yes to Easement + not_convertable++; + continue; } - UndoStart( _("Convert Cornu"),"newCornu curves"); - trk = NULL; - int converted=0, not_convertable = 0, created=0, deleted=0; - DYNARR_RESET(track_p,Da.tracks); - while ( TrackIterate( &trk ) ) { - if (!GetTrkSelected( trk )) continue; //Only selected - if (!QueryTrack(trk, Q_CORNU_CAN_MODIFY) && //Not Fixed Track/Turnout/Turntable - !QueryTrack( trk, Q_IGNORE_EASEMENT_ON_EXTEND )) { //But Yes to Easement - not_convertable++; - continue; + converted++; + DYNARR_RESET(trkSeg_t,Da.crvSegs_da); + Da.ep1Segs_da_cnt = 0; + Da.ep2Segs_da_cnt = 0; + DYNARR_RESET( trkSeg_t*, Da.midSegs ); + Da.extend[0] = FALSE; + Da.extend[1] = FALSE; + Da.selectEndPoint = -1; + Da.selectTrack = NULL; + DYNARR_RESET(coOrd,Da.mid_points); + ClrTrkBits( trk, TB_SELECTED ); //Done with this one + Da.selectTrack = trk; + DYNARR_APPEND(track_p,Da.tracks,1); + DYNARR_LAST(track_p,Da.tracks) = trk; + Da.trk[0] = GetTrkEndTrk( trk, 0 ); + track_p prior = trk; + if (Da.trk[0]) { Da.ep[0] = GetEndPtConnectedToMe(Da.trk[0],trk); } + else { Da.ep[0] = -1; } + EPINX_T ep0 = 0; + //Move down the LHS adding tracks until no more Selected or not modifyable + while (Da.trk[0] && GetTrkSelected( Da.trk[0]) && IsTrack(Da.trk[0]) + && (QueryTrack(Da.trk[0], Q_CORNU_CAN_MODIFY) + || QueryTrack(Da.trk[0], Q_IS_CORNU)) ) { + prior = Da.trk[0]; + ep0 = 1-Da.ep[0]; + ClrTrkBits( Da.trk[0], TB_SELECTED ); //Done with this one + if (selectedTrackCount>0) { selectedTrackCount--; } + DYNARR_APPEND(track_p,Da.tracks,1); + DYNARR_LAST(track_p,Da.tracks) = prior; + DYNARR_APPEND(coOrd,Da.mid_points,1); + for (int i=Da.mid_points.cnt-1; i>1; i--) { + DYNARR_N(coOrd,Da.mid_points,i) = DYNARR_N(coOrd,Da.mid_points,i-1); } + DYNARR_N(coOrd,Da.mid_points,0) = GetTrkEndPos(prior,1-ep0); + Da.trk[0] = GetTrkEndTrk( prior, ep0 ); + if (Da.trk[0]) { Da.ep[0] = GetEndPtConnectedToMe(Da.trk[0],prior); } + else { Da.ep[0] = -1; } converted++; - DYNARR_RESET(trkSeg_t,Da.crvSegs_da); - Da.ep1Segs_da_cnt = 0; - Da.ep2Segs_da_cnt = 0; - Da.midSegs.cnt = 0; - Da.extend[0] = FALSE; - Da.extend[1] = FALSE; - Da.selectEndPoint = -1; - Da.selectTrack = NULL; - DYNARR_RESET(coOrd,Da.mid_points); - ClrTrkBits( trk, TB_SELECTED ); //Done with this one - Da.selectTrack = trk; + } + Da.radius[0] = -1.0; //Initialize with no end + Da.ends[0] = FALSE; + Da.center[0] = zero; + Da.pos[0] = GetTrkEndPos(prior,ep0); + if (Da.trk[0] && Da.ep[0]>=0) { + GetConnectedTrackParms(Da.trk[0],GetTrkEndPos(Da.trk[0],Da.ep[0]),0,Da.ep[0], + FALSE); + } + + //Move to RHS + + Da.trk[1] = GetTrkEndTrk( trk, 1 ); + track_p next = trk; + EPINX_T ep1 = 1; + if (Da.trk[1]) { Da.ep[1] = GetEndPtConnectedToMe(Da.trk[1],trk); } + else { Da.ep[1] = -1; } + //Move down RHS adding tracks until no more Selected or not modifyable + while (Da.trk[1] && GetTrkSelected( Da.trk[1]) + && (QueryTrack(Da.trk[1], Q_CORNU_CAN_MODIFY) + || QueryTrack(Da.trk[1], Q_IS_CORNU))) { + next = Da.trk[1]; + ep1 = 1-Da.ep[1]; + if (selectedTrackCount>0) { selectedTrackCount--; } + ClrTrkBits( Da.trk[1], TB_SELECTED ); //Done with this one DYNARR_APPEND(track_p,Da.tracks,1); - DYNARR_LAST(track_p,Da.tracks) = trk; - Da.trk[0] = GetTrkEndTrk( trk, 0 ); - track_p prior = trk; - if (Da.trk[0]) Da.ep[0] = GetEndPtConnectedToMe(Da.trk[0],trk); - else Da.ep[0] = -1; - EPINX_T ep0 = 0; - //Move down the LHS adding tracks until no more Selected or not modifyable - while (Da.trk[0] && GetTrkSelected( Da.trk[0]) && IsTrack(Da.trk[0]) && (QueryTrack(Da.trk[0], Q_CORNU_CAN_MODIFY) || QueryTrack(Da.trk[0], Q_IS_CORNU)) ) { - prior = Da.trk[0]; - ep0 = 1-Da.ep[0]; - ClrTrkBits( Da.trk[0], TB_SELECTED ); //Done with this one - if (selectedTrackCount>0) selectedTrackCount--; - DYNARR_APPEND(track_p,Da.tracks,1); - DYNARR_LAST(track_p,Da.tracks) = prior; - DYNARR_APPEND(coOrd,Da.mid_points,1); - for (int i=Da.mid_points.cnt-1;i>1;i--) { - DYNARR_N(coOrd,Da.mid_points,i) = DYNARR_N(coOrd,Da.mid_points,i-1); - } - DYNARR_N(coOrd,Da.mid_points,0) = GetTrkEndPos(prior,1-ep0); - Da.trk[0] = GetTrkEndTrk( prior, ep0 ); - if (Da.trk[0]) Da.ep[0] = GetEndPtConnectedToMe(Da.trk[0],prior); - else Da.ep[0] = -1; - converted++; - } - Da.radius[0] = -1.0; //Initialize with no end - Da.ends[0] = FALSE; - Da.center[0] = zero; - Da.pos[0] = GetTrkEndPos(prior,ep0); - if (Da.trk[0] && Da.ep[0]>=0) { - GetConnectedTrackParms(Da.trk[0],GetTrkEndPos(Da.trk[0],Da.ep[0]),0,Da.ep[0],FALSE); - } + DYNARR_LAST(track_p,Da.tracks) = next; + DYNARR_APPEND(coOrd,Da.mid_points,1); + DYNARR_LAST(coOrd,Da.mid_points) = GetTrkEndPos(next,1-ep1); + Da.trk[1] = GetTrkEndTrk( next, ep1 ); + if (Da.trk[1]) { Da.ep[1] = GetEndPtConnectedToMe(Da.trk[1],next); } + converted++; + } + Da.radius[1] = -1.0; //Initialize with no end + Da.ends[1] = FALSE; + Da.center[1] = zero; + Da.pos[1] = GetTrkEndPos(next,ep1); + if (Da.trk[1] && Da.ep[1]>=0) { + GetConnectedTrackParms(Da.trk[1],GetTrkEndPos(Da.trk[1],Da.ep[1]),1,Da.ep[1], + FALSE); + } + SetUpCornuParms(&cp); + if (CallCornuM(Da.mid_points,Da.ends,Da.pos,&cp,&Da.crvSegs_da,TRUE)) { Da.crvSegs_da_cnt = Da.crvSegs_da.cnt; } + else { continue; } //Checks that a solution can be found - //Move to RHS - - Da.trk[1] = GetTrkEndTrk( trk, 1 ); - track_p next = trk; - EPINX_T ep1 = 1; - if (Da.trk[1]) Da.ep[1] = GetEndPtConnectedToMe(Da.trk[1],trk); - else Da.ep[1] = -1; - //Move down RHS adding tracks until no more Selected or not modifyable - while (Da.trk[1] && GetTrkSelected( Da.trk[1]) && (QueryTrack(Da.trk[1], Q_CORNU_CAN_MODIFY) || QueryTrack(Da.trk[1], Q_IS_CORNU))) { - next = Da.trk[1]; - ep1 = 1-Da.ep[1]; - if (selectedTrackCount>0) selectedTrackCount--; - ClrTrkBits( Da.trk[1], TB_SELECTED ); //Done with this one - DYNARR_APPEND(track_p,Da.tracks,1); - DYNARR_LAST(track_p,Da.tracks) = next; - DYNARR_APPEND(coOrd,Da.mid_points,1); - DYNARR_LAST(coOrd,Da.mid_points) = GetTrkEndPos(next,1-ep1); - Da.trk[1] = GetTrkEndTrk( next, ep1 ); - if (Da.trk[1]) Da.ep[1] = GetEndPtConnectedToMe(Da.trk[1],next); - converted++; - } - Da.radius[1] = -1.0; //Initialize with no end - Da.ends[1] = FALSE; - Da.center[1] = zero; - Da.pos[1] = GetTrkEndPos(next,ep1); - if (Da.trk[1] && Da.ep[1]>=0) { - GetConnectedTrackParms(Da.trk[1],GetTrkEndPos(Da.trk[1],Da.ep[1]),1,Da.ep[1],FALSE); - } - SetUpCornuParms(&cp); - if (CallCornuM(Da.mid_points,Da.ends,Da.pos,&cp,&Da.crvSegs_da,TRUE)) Da.crvSegs_da_cnt = Da.crvSegs_da.cnt; - else continue; //Checks that a solution can be found - - // Do the deed - Create a replacement Cornu - - BOOL_T end_point[2]; - end_point[0] = TRUE; - end_point[1] = FALSE; - coOrd sub_pos[2]; - sub_pos[0] = Da.pos[0]; - if (Da.radius[0] == -1) end_point[0] = FALSE; - track_p first_trk= NULL,trk1=NULL,trk2 = NULL; - - for (int i=0;i<Da.mid_points.cnt;i++) { - sub_pos[1] = DYNARR_N(coOrd,Da.mid_points,i); - if ((trk1 = CreateCornuFromPoints(sub_pos,end_point))== NULL) continue; - if (Da.trk[0]) { - CopyAttributes( Da.trk[0], trk1 ); - } else if (Da.trk[1]) { - CopyAttributes( Da.trk[1], trk1 ); - } else { - SetTrkScale( trk1, GetLayoutCurScale() ); - SetTrkBits( trk1, TB_HIDEDESC ); - } - DrawNewTrack(trk1); - if (first_trk == NULL) first_trk = trk1; - if (trk2) ConnectTracks(trk1,0,trk2,1); - trk2 = trk1; - end_point[0] = FALSE; - sub_pos[0] = DYNARR_N(coOrd,Da.mid_points,i); - } - sub_pos[1] = Da.pos[1]; - end_point[1] = TRUE; - if (Da.radius[1] == -1) end_point[1] = FALSE; - if ((trk1 = CreateCornuFromPoints(sub_pos,end_point)) == NULL) continue; - created++; - DrawNewTrack(trk1); + // Do the deed - Create a replacement Cornu + + BOOL_T end_point[2]; + end_point[0] = TRUE; + end_point[1] = FALSE; + coOrd sub_pos[2]; + sub_pos[0] = Da.pos[0]; + if (Da.radius[0] == -1) { end_point[0] = FALSE; } + track_p first_trk= NULL,trk1=NULL,trk2 = NULL; + + for (int i=0; i<Da.mid_points.cnt; i++) { + sub_pos[1] = DYNARR_N(coOrd,Da.mid_points,i); + if ((trk1 = CreateCornuFromPoints(sub_pos,end_point))== NULL) { continue; } if (Da.trk[0]) { CopyAttributes( Da.trk[0], trk1 ); - } else if (Da.trk[1]){ + } else if (Da.trk[1]) { CopyAttributes( Da.trk[1], trk1 ); } else { SetTrkScale( trk1, GetLayoutCurScale() ); SetTrkBits( trk1, TB_HIDEDESC ); } - if (trk2) ConnectTracks(trk1,0,trk2,1); - if (first_trk == NULL) first_trk = trk1; - - for (int i=0;i<2;i++) { + DrawNewTrack(trk1); + if (first_trk == NULL) { first_trk = trk1; } + if (trk2) { ConnectTracks(trk1,0,trk2,1); } + trk2 = trk1; + end_point[0] = FALSE; + sub_pos[0] = DYNARR_N(coOrd,Da.mid_points,i); + } + sub_pos[1] = Da.pos[1]; + end_point[1] = TRUE; + if (Da.radius[1] == -1) { end_point[1] = FALSE; } + if ((trk1 = CreateCornuFromPoints(sub_pos,end_point)) == NULL) { continue; } + created++; + DrawNewTrack(trk1); + if (Da.trk[0]) { + CopyAttributes( Da.trk[0], trk1 ); + } else if (Da.trk[1]) { + CopyAttributes( Da.trk[1], trk1 ); + } else { + SetTrkScale( trk1, GetLayoutCurScale() ); + SetTrkBits( trk1, TB_HIDEDESC ); + } + if (trk2) { ConnectTracks(trk1,0,trk2,1); } + if (first_trk == NULL) { first_trk = trk1; } + + for (int i=0; i<2; i++) { + if (Da.ep[i]>=0 && Da.trk[i]) { + track_p trk_old = GetTrkEndTrk(Da.trk[i],Da.ep[i]); + EPINX_T old_ep = GetEndPtConnectedToMe(trk_old,Da.trk[i]); + DisconnectTracks(Da.trk[i],Da.ep[i],trk_old,old_ep); if (Da.ep[i]>=0 && Da.trk[i]) { - track_p trk_old = GetTrkEndTrk(Da.trk[i],Da.ep[i]); - EPINX_T old_ep = GetEndPtConnectedToMe(trk_old,Da.trk[i]); - DisconnectTracks(Da.trk[i],Da.ep[i],trk_old,old_ep); - if (Da.ep[i]>=0 && Da.trk[i]) - ConnectTracks(Da.trk[i],Da.ep[i],i==0?first_trk:trk1,i); + ConnectTracks(Da.trk[i],Da.ep[i],i==0?first_trk:trk1,i); } } - - } //Find next track - SetAllTrackSelect(FALSE); - //Get rid of old tracks - for (int i = 0; i<Da.tracks.cnt;i++) { - DeleteTrack(DYNARR_N(track_p,Da.tracks,i),FALSE); - deleted++; } - UndoEnd(); //Stop accumulating - NoticeMessage(_("Tracks Counts: %d converted %d unconvertible %d created %d deleted"),_("OK"),NULL,converted,not_convertable,created,deleted); + } //Find next track + SetAllTrackSelect(FALSE); + //Get rid of old tracks + for (int i = 0; i<Da.tracks.cnt; i++) { + DeleteTrack(DYNARR_N(track_p,Da.tracks,i),FALSE); + deleted++; + } - return C_TERMINATE; + UndoEnd(); //Stop accumulating + NoticeMessage( + _("Tracks Counts: %d converted %d unconvertible %d created %d deleted"),_("OK"), + NULL,converted,not_convertable,created,deleted); - case C_REDRAW: - if (trk) { - DrawTrack(trk,&tempD,wDrawColorPreviewSelected); - } - return C_CONTINUE; + return C_TERMINATE; - case C_CANCEL: - return C_TERMINATE; + case C_REDRAW: + if (trk) { + DrawTrack(trk,&tempD,wDrawColorPreviewSelected); + } + return C_CONTINUE; - case C_OK: - return C_TERMINATE; + case C_CANCEL: + return C_TERMINATE; - case C_CONFIRM: - return C_CONTINUE; + case C_OK: + return C_TERMINATE; - default: - return C_CONTINUE; - } + case C_CONFIRM: + return C_CONTINUE; + + default: + return C_CONTINUE; + } } static STATUS_T CmdConvertFrom( - wAction_t action, - coOrd pos ) + wAction_t action, + coOrd pos ) { static track_p trk; - track_p trk1,trk2; + track_p trk1; +// track_p trk2; switch (action) { - case wActionMove: - if ((trk = OnTrack(&pos,FALSE,TRUE)) == NULL) return C_CONTINUE; - if ((!(GetTrkType(trk) == T_CORNU)) || - (!(GetTrkType(trk) == T_BEZIER))) - trk = NULL; - return C_CONTINUE; + case wActionMove: + if ((trk = OnTrack(&pos,FALSE,TRUE)) == NULL) { return C_CONTINUE; } + if ((!(GetTrkType(trk) == T_CORNU)) || + (!(GetTrkType(trk) == T_BEZIER))) { + trk = NULL; + } + return C_CONTINUE; - case C_LCLICK: - if ((trk = OnTrack(&pos,FALSE,TRUE))!=NULL) { - SetTrkBits(trk,TB_SELECTED); - selectedTrackCount = 1; - trk = NULL; - } else { - wBeep(); - InfoMessage( _("Not on a Track") ); - trk = NULL; - return C_CONTINUE; - } - /* no break */ - case C_START: - if (selectedTrackCount==0) { - InfoMessage( _("Select a Cornu or Bezier Track To Convert to Fixed") ); - return C_CONTINUE; + case C_LCLICK: + if ((trk = OnTrack(&pos,FALSE,TRUE))!=NULL) { + SetTrkBits(trk,TB_SELECTED); + selectedTrackCount = 1; + trk = NULL; + } else { + wBeep(); + InfoMessage( _("Not on a Track") ); + trk = NULL; + return C_CONTINUE; + } + /* no break */ + case C_START: + if (selectedTrackCount==0) { + InfoMessage( _("Select a Cornu or Bezier Track To Convert to Fixed") ); + return C_CONTINUE; + } else if (selectedTrackCount>1) { + if (NoticeMessage(_("Convert all Selected Tracks to Fixed Tracks?"), _("Yes"), + _("No"))<=0) { + SetAllTrackSelect(FALSE); + return C_TERMINATE; } - else if (selectedTrackCount>1) { - if (NoticeMessage(_("Convert all Selected Tracks to Fixed Tracks?"), _("Yes"), _("No"))<=0) { - SetAllTrackSelect(FALSE); - return C_TERMINATE; + } +// dynArr_t trackSegs_da; +// DYNARR_RESET(trkSeg_t,trackSegs_da); + trk1 = NULL; +// trk2 = NULL; + trk = NULL; + UndoStart( _("Convert Bezier and Cornu"),"Try to convert all selected tracks"); + track_p tracks[2]; + DYNARR_RESET(track_p,Da.tracks); + int converted=0, not_convertable = 0, deleted=0; +// int created=0; + while ( TrackIterate( &trk1 ) ) { + if ( GetTrkSelected( trk1 ) && IsTrack( trk1 ) ) { + //Only Cornu or Bezier + tracks[0] = NULL, tracks[1] = NULL; + if (selectedTrackCount>0) { selectedTrackCount--; } + ClrTrkBits( trk1, TB_SELECTED ); //Done with this one + if (GetTrkType(trk1) == T_CORNU) { + GetTracksFromCornuTrack(trk1,tracks); + DYNARR_APPEND(track_p,Da.tracks,1); + DYNARR_LAST(track_p,Da.tracks) = trk1; + converted++; + } else if (GetTrkType(trk1) == T_BEZIER) { + GetTracksFromBezierTrack(trk1,tracks); + DYNARR_APPEND(track_p,Da.tracks,1); + DYNARR_LAST(track_p,Da.tracks) = trk1; + converted++; + } else { + not_convertable++; + continue; } - } - dynArr_t trackSegs_da; - DYNARR_RESET(trkSeg_t,trackSegs_da); - trk1 = NULL; - trk2 = NULL; - trk = NULL; - UndoStart( _("Convert Bezier and Cornu"),"Try to convert all selected tracks"); - track_p tracks[2]; - DYNARR_RESET(track_p,Da.tracks); - int converted=0, not_convertable = 0, created=0, deleted=0; - while ( TrackIterate( &trk1 ) ) { - if ( GetTrkSelected( trk1 ) && IsTrack( trk1 ) ) { - //Only Cornu or Bezier - tracks[0] = NULL, tracks[1] = NULL; - if (selectedTrackCount>0) selectedTrackCount--; - ClrTrkBits( trk1, TB_SELECTED ); //Done with this one - if (GetTrkType(trk1) == T_CORNU) { - GetTracksFromCornuTrack(trk1,tracks); - DYNARR_APPEND(track_p,Da.tracks,1); - DYNARR_LAST(track_p,Da.tracks) = trk1; - converted++; - } else if (GetTrkType(trk1) == T_BEZIER) { - GetTracksFromBezierTrack(trk1,tracks); - DYNARR_APPEND(track_p,Da.tracks,1); - DYNARR_LAST(track_p,Da.tracks) = trk1; - converted++; - } else { - not_convertable++; - continue; - } - for (int i=0;i<2;i++) { - track_p trk2 = GetTrkEndTrk(trk1,i); - if (trk2) { - EPINX_T ep1 = GetEndPtConnectedToMe( trk2, trk1 ); - DisconnectTracks(trk2,ep1,trk1,i); - pos = GetTrkEndPos(trk2,ep1); - for (int j=0;j<2;j++) { - EPINX_T ep2 = PickUnconnectedEndPointSilent( pos, tracks[j] ); - coOrd ep_pos; - if (ep2<0) continue; - ep_pos = GetTrkEndPos(tracks[j],ep2); - if (connectDistance>=FindDistance(pos,ep_pos) && - connectAngle >= fabs(DifferenceBetweenAngles(GetTrkEndAngle(tracks[j],ep2),GetTrkEndAngle(trk2,ep1)+180))) { - ConnectTracks(trk2,ep1,tracks[j],ep2); - break; - } + for (int i=0; i<2; i++) { + track_p trk2 = GetTrkEndTrk(trk1,i); + if (trk2) { + EPINX_T ep1 = GetEndPtConnectedToMe( trk2, trk1 ); + DisconnectTracks(trk2,ep1,trk1,i); + pos = GetTrkEndPos(trk2,ep1); + for (int j=0; j<2; j++) { + EPINX_T ep2 = PickUnconnectedEndPointSilent( pos, tracks[j] ); + coOrd ep_pos; + if (ep2<0) { continue; } + ep_pos = GetTrkEndPos(tracks[j],ep2); + if (connectDistance>=FindDistance(pos,ep_pos) && + connectAngle >= fabs(DifferenceBetweenAngles(GetTrkEndAngle(tracks[j],ep2), + GetTrkEndAngle(trk2,ep1)+180))) { + ConnectTracks(trk2,ep1,tracks[j],ep2); + break; } } } } } - SetAllTrackSelect(FALSE); - for (int i = 0; i<Da.tracks.cnt;i++) { - DeleteTrack(DYNARR_N(track_p,Da.tracks,i),FALSE); - deleted++; - } - UndoEnd(); - NoticeMessage(_("Tracks Counts: %d converted %d unconvertible %d deleted"),_("OK"),NULL,converted,not_convertable,deleted); - return C_TERMINATE; + } + SetAllTrackSelect(FALSE); + for (int i = 0; i<Da.tracks.cnt; i++) { + DeleteTrack(DYNARR_N(track_p,Da.tracks,i),FALSE); + deleted++; + } + UndoEnd(); + NoticeMessage(_("Tracks Counts: %d converted %d unconvertible %d deleted"), + _("OK"),NULL,converted,not_convertable,deleted); + return C_TERMINATE; - case C_REDRAW: - if (trk) { - DrawTrack(trk,&tempD,wDrawColorPreviewSelected); - } - return C_CONTINUE; + case C_REDRAW: + if (trk) { + DrawTrack(trk,&tempD,wDrawColorPreviewSelected); + } + return C_CONTINUE; - case C_CANCEL: - return C_TERMINATE; + case C_CANCEL: + return C_TERMINATE; - case C_OK: - return C_TERMINATE; + case C_OK: + return C_TERMINATE; - case C_CONFIRM: - return C_CONTINUE; + case C_CONFIRM: + return C_CONTINUE; - default: - return C_CONTINUE; - } + default: + return C_CONTINUE; + } } -#include "bitmaps/convert-to.xpm" -#include "bitmaps/convert-from.xpm" +#include "bitmaps/convert-to.xpm3" +#include "bitmaps/convert-from.xpm3" EXPORT void InitCmdCornu( wMenu_p menu ) -{ +{ ButtonGroupBegin( _("Convert"), "cmdConvertSetCmd", _("Convert") ); - AddMenuButton( menu, CmdConvertTo, "cmdConvertTo", _("Convert To Cornu"), wIconCreatePixMap(convert_to_xpm[iconSize]), LEVEL0_50, IC_STICKY|IC_LCLICK|IC_POPUP3|IC_WANT_MOVE,ACCL_CONVERTTO, NULL ); - AddMenuButton( menu, CmdConvertFrom, "cmdConvertFrom", _("Convert From Cornu"), wIconCreatePixMap(convert_from_xpm[iconSize]), LEVEL0_50, IC_STICKY|IC_LCLICK|IC_POPUP3|IC_WANT_MOVE,ACCL_CONVERTFR, NULL ); - cornuHotBarCmdInx = AddMenuButton(menu, cmdCornuCreate, "cmdCornuCreate", "", NULL, LEVEL0_50, IC_STICKY|IC_POPUP3|IC_WANT_MOVE, 0, NULL); + AddMenuButton( menu, CmdConvertTo, "cmdConvertTo", _("Convert To Cornu"), + wIconCreatePixMap(convert_to_xpm3[iconSize]), LEVEL0_50, + IC_STICKY|IC_LCLICK|IC_POPUP3|IC_WANT_MOVE,ACCL_CONVERTTO, NULL ); + AddMenuButton( menu, CmdConvertFrom, "cmdConvertFrom", _("Convert From Cornu"), + wIconCreatePixMap(convert_from_xpm3[iconSize]), LEVEL0_50, + IC_STICKY|IC_LCLICK|IC_POPUP3|IC_WANT_MOVE,ACCL_CONVERTFR, NULL ); + cornuHotBarCmdInx = AddMenuButton(menu, cmdCornuCreate, "cmdCornuCreate", "", + NULL, LEVEL0_50, IC_STICKY|IC_POPUP3|IC_WANT_MOVE, 0, NULL); ButtonGroupEnd(); ParamCreateControls( &cornuModPG, cornuModDlgUpdate) ; } diff --git a/app/bin/ccornu.h b/app/bin/ccornu.h index 29b6171..ff3810f 100644 --- a/app/bin/ccornu.h +++ b/app/bin/ccornu.h @@ -20,14 +20,17 @@ typedef void (*cornuMessageProc)( const char *, ... ); #endif /* APP_BIN_CCORNU_H_ */ STATUS_T CmdCornu( wAction_t action, coOrd pos ); -BOOL_T CallCornu0(coOrd pos[2], coOrd center[2], ANGLE_T angle[2], DIST_T radius[2], dynArr_t * array_p, BOOL_T spots); +BOOL_T CallCornu0(coOrd pos[2], coOrd center[2], ANGLE_T angle[2], + DIST_T radius[2], dynArr_t * array_p, BOOL_T spots); DIST_T CornuMinRadius(coOrd pos[4],dynArr_t segs); -DIST_T CornuMaxRateofChangeofCurvature(coOrd pos[4],dynArr_t segs,DIST_T * last_c); +DIST_T CornuMaxRateofChangeofCurvature(coOrd pos[4],dynArr_t segs, + DIST_T * last_c); DIST_T CornuLength(coOrd pos[4],dynArr_t segs); DIST_T CornuOffsetLength(dynArr_t segs, double offset); DIST_T CornuTotalWindingArc(coOrd pos[4],dynArr_t segs); -STATUS_T CmdCornuModify (track_p trk, wAction_t action, coOrd pos, DIST_T trackG); +STATUS_T CmdCornuModify (track_p trk, wAction_t action, coOrd pos, + DIST_T trackG); void InitCmdCornu( wMenu_p menu ); diff --git a/app/bin/ccurve.c b/app/bin/ccurve.c index 2308bd1..373a975 100644 --- a/app/bin/ccurve.c +++ b/app/bin/ccurve.c @@ -17,11 +17,11 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "ccurve.h" - + #include "cjoin.h" #include "cstraigh.h" #include "cundo.h" @@ -43,19 +43,19 @@ typedef enum createState_e {NOCURVE,FIRSTEND_DEF,SECONDEND_DEF,CENTER_DEF} createState_e; static struct { - STATE_T state; - createState_e create_state; - coOrd pos0; - coOrd pos1; - curveData_t curveData; - track_p trk; - EPINX_T ep; - BOOL_T down; - BOOL_T lock0; - coOrd middle; - coOrd end0; - coOrd end1; - } Da; + STATE_T state; + createState_e create_state; + coOrd pos0; + coOrd pos1; + curveData_t curveData; + track_p trk; + EPINX_T ep; + BOOL_T down; + BOOL_T lock0; + coOrd middle; + coOrd end0; + coOrd end1; +} Da; static long curveMode; @@ -65,58 +65,60 @@ static dynArr_t anchors_da; EXPORT int DrawArrowHeads( - trkSeg_p sp, - coOrd pos, - ANGLE_T angle, - BOOL_T bidirectional, - wDrawColor color ) + trkSeg_p sp, + coOrd pos, + ANGLE_T angle, + BOOL_T bidirectional, + wDrawColor color ) { - coOrd p0, p1; - DIST_T d, w; - int inx; - d = mainD.scale*0.25; - w = mainD.scale/mainD.dpi*2; - for ( inx=0; inx<5; inx++ ) { - sp[inx].type = SEG_STRLIN; - sp[inx].width = w; - sp[inx].color = color; - } - Translate( &p0, pos, angle, d ); - Translate( &p1, pos, angle+180, bidirectional?d:(d/2.0) ); - sp[0].u.l.pos[0] = p0; - sp[0].u.l.pos[1] = p1; - sp[1].u.l.pos[0] = p0; - Translate( &sp[1].u.l.pos[1], p0, angle+135, d/2.0 ); - sp[2].u.l.pos[0] = p0; - Translate( &sp[2].u.l.pos[1], p0, angle-135, d/2.0 ); - if (bidirectional) { - sp[3].u.l.pos[0] = p1; - Translate( &sp[3].u.l.pos[1], p1, angle-45, d/2.0 ); - sp[4].u.l.pos[0] = p1; - Translate( &sp[4].u.l.pos[1], p1, angle+45, d/2.0 ); - } else { - sp[3].u.l.pos[0] = p1; - sp[3].u.l.pos[1] = p1; - sp[4].u.l.pos[0] = p1; - sp[4].u.l.pos[1] = p1; - } - return 5; + coOrd p0, p1; + DIST_T d, w; + int inx; + d = mainD.scale*0.25; + w = mainD.scale/mainD.dpi*2; + for ( inx=0; inx<5; inx++ ) { + sp[inx].type = SEG_STRLIN; + sp[inx].lineWidth = w; + sp[inx].color = color; + } + Translate( &p0, pos, angle, d ); + Translate( &p1, pos, angle+180, bidirectional?d:(d/2.0) ); + sp[0].u.l.pos[0] = p0; + sp[0].u.l.pos[1] = p1; + sp[1].u.l.pos[0] = p0; + Translate( &sp[1].u.l.pos[1], p0, angle+135, d/2.0 ); + sp[2].u.l.pos[0] = p0; + Translate( &sp[2].u.l.pos[1], p0, angle-135, d/2.0 ); + if (bidirectional) { + sp[3].u.l.pos[0] = p1; + Translate( &sp[3].u.l.pos[1], p1, angle-45, d/2.0 ); + sp[4].u.l.pos[0] = p1; + Translate( &sp[4].u.l.pos[1], p1, angle+45, d/2.0 ); + } else { + sp[3].u.l.pos[0] = p1; + sp[3].u.l.pos[1] = p1; + sp[4].u.l.pos[0] = p1; + sp[4].u.l.pos[1] = p1; + } + return 5; } EXPORT int DrawArrowHeadsArray( - dynArr_t *anchor_array, - coOrd pos, - ANGLE_T angle, - BOOL_T bidirectional, - wDrawColor color ) + dynArr_t *anchor_array, + coOrd pos, + ANGLE_T angle, + BOOL_T bidirectional, + wDrawColor color ) { int i = (*anchor_array).cnt; DYNARR_SET(trkSeg_t,*anchor_array,i+5) - return DrawArrowHeads(&DYNARR_N(trkSeg_t,*anchor_array,i),pos,angle,bidirectional,color); + return DrawArrowHeads(&DYNARR_N(trkSeg_t,*anchor_array,i),pos,angle, + bidirectional,color); } -static void CreateEndAnchor(coOrd p, dynArr_t * anchor_array, wBool_t lock) { +static void CreateEndAnchor(coOrd p, dynArr_t * anchor_array, wBool_t lock) +{ DIST_T d = tempD.scale*0.15; DYNARR_APPEND(trkSeg_t,*anchor_array,1); @@ -127,48 +129,50 @@ static void CreateEndAnchor(coOrd p, dynArr_t * anchor_array, wBool_t lock) { array_anchor(i).u.c.radius = d/2; array_anchor(i).u.c.a0 = 0.0; array_anchor(i).u.c.a1 = 360.0; - array_anchor(i).width = 0; + array_anchor(i).lineWidth = 0; } EXPORT STATUS_T CreateCurve( - wAction_t action, - coOrd pos, - BOOL_T track, - wDrawColor color, - DIST_T width, - long mode, - dynArr_t * anchor_array, - curveMessageProc message ) + wAction_t action, + coOrd pos, + BOOL_T track, + wDrawColor color, + LWIDTH_T width, + long mode, + dynArr_t * anchor_array, + curveMessageProc message ) { track_p t; DIST_T d; ANGLE_T a, angle1, angle2; - static coOrd pos0, p; + static coOrd p; +// static coOrd pos0; int inx; switch ( action ) { case C_START: DYNARR_RESET(trkSeg_t,*anchor_array); - DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); + DYNARR_RESET( trkSeg_t, tempSegs_da ); Da.create_state = NOCURVE; - tempSegs_da.cnt = 0; Da.down = FALSE; //Not got a valid start yet Da.pos0 = zero; Da.pos1 = zero; switch ( curveMode ) { case crvCmdFromEP1: - if (track) + if (track) { message(_("Drag from endpoint in direction of curve - lock to track open endpoint") ); - else + } else { message (_("Drag from endpoint in direction of curve") ); + } break; case crvCmdFromTangent: - if (track) + if (track) { message(_("Drag from endpoint to center - lock to track open endpoint") ); - else + } else { message(_("Drag from endpoint to center") ); + } break; case crvCmdFromCenter: message(_("Drag from center to endpoint") ); @@ -179,168 +183,178 @@ EXPORT STATUS_T CreateCurve( } return C_CONTINUE; case C_DOWN: - DYNARR_RESET(trkSeg_t, *anchor_array); - for ( inx=0; inx<8; inx++ ) { - tempSegs(inx).color = wDrawColorBlack; - tempSegs(inx).width = 0; - } - tempSegs_da.cnt = 0; - p = pos; - BOOL_T found = FALSE; - Da.trk = NULL; - if (track) { - if ((mode == crvCmdFromEP1 || mode == crvCmdFromTangent || (mode == crvCmdFromChord)) && - ((MyGetKeyState() & WKEY_ALT) == 0 ) == magneticSnap) { - if ((t = OnTrack(&p, FALSE, TRUE)) != NULL) { - EPINX_T ep = PickUnconnectedEndPointSilent(p, t); - if (ep != -1) { - if (GetTrkScale(t) != (char)GetLayoutCurScale()) { - wBeep(); - InfoMessage(_("Track is different gauge")); - return C_CONTINUE; - } - Da.trk = t; - Da.ep = ep; - pos = GetTrkEndPos(t, ep); - found = TRUE; + DYNARR_RESET(trkSeg_t, *anchor_array); + DYNARR_SET( trkSeg_t, tempSegs_da, 8 ); + for ( inx=0; inx<8; inx++ ) { + tempSegs(inx).color = wDrawColorBlack; + tempSegs(inx).lineWidth = width; + } + DYNARR_RESET( trkSeg_t, tempSegs_da ); + p = pos; + BOOL_T found = FALSE; + Da.trk = NULL; + if (track) { + if ((mode == crvCmdFromEP1 || mode == crvCmdFromTangent + || (mode == crvCmdFromChord)) && + ((MyGetKeyState() & WKEY_ALT) == 0 ) == magneticSnap) { + if ((t = OnTrack(&p, FALSE, TRUE)) != NULL) { + EPINX_T ep = PickUnconnectedEndPointSilent(p, t); + if (ep != -1) { + if (GetTrkScale(t) != (char)GetLayoutCurScale()) { + wBeep(); + InfoMessage(_("Track is different gauge")); + return C_CONTINUE; } + Da.trk = t; + Da.ep = ep; + pos = GetTrkEndPos(t, ep); + found = TRUE; } } - } else { - if (((t = OnTrack(&p, FALSE, FALSE)) != NULL) && IsClose(FindDistance(p,pos))) { - if (!IsTrack(t)) { - pos = p; - found = TRUE; - } - } - } - Da.down = TRUE; - if (!found && !track) SnapPos( &pos ); - if (mode == crvCmdFromCenter) SnapPos( &pos ); - Da.lock0 = found; - - if (Da.create_state == NOCURVE) - Da.pos0 = pos; - else - Da.pos1 = pos; + } + } else { + if (((t = OnTrack(&p, FALSE, FALSE)) != NULL) && IsClose(FindDistance(p,pos))) { + if (!IsTrack(t)) { + pos = p; + found = TRUE; + } + } + } + Da.down = TRUE; + if (!found && !track) { SnapPos( &pos ); } + if (mode == crvCmdFromCenter) { SnapPos( &pos ); } + Da.lock0 = found; - tempSegs_da.cnt = 1; - switch (mode) { - case crvCmdFromEP1: - tempSegs(0).type = (track?SEG_STRTRK:SEG_STRLIN); - tempSegs(0).color = color; - tempSegs(0).width = width; - Da.create_state = FIRSTEND_DEF; - Da.end0 = pos; - CreateEndAnchor(pos,anchor_array,found); - if (Da.trk && !(MyGetKeyState() & WKEY_SHIFT)) message(_("End locked: Drag out curve start")); - else if (Da.trk) message(_("End Position locked: Drag out curve start with Shift")); - else message(_("Drag along curve start") ); - break; - case crvCmdFromTangent: - Da.create_state = FIRSTEND_DEF; - tempSegs(0).type = SEG_STRLIN; - tempSegs(0).color = color; - Da.create_state = CENTER_DEF; - CreateEndAnchor(pos,anchor_array,found); - if (Da.trk && !(MyGetKeyState() & WKEY_SHIFT)) message(_("End locked: Drag out curve center")); - else if (Da.trk) message(_("End Position locked: Drag out curve start with Shift")); - else message(_("Drag out curve center") ); - break; - case crvCmdFromCenter: - tempSegs(0).type = SEG_STRLIN; - tempSegs(0).color = color; - Da.create_state = CENTER_DEF; - CreateEndAnchor(pos,anchor_array,FALSE); - message(_("Drag out from center to endpoint")); - break; - case crvCmdFromChord: - tempSegs(0).type = (track?SEG_STRTRK:SEG_STRLIN); - tempSegs(0).color = color; - tempSegs(0).width = width; - CreateEndAnchor(pos,anchor_array,FALSE); - Da.create_state = FIRSTEND_DEF; - if (Da.trk && !(MyGetKeyState() & WKEY_SHIFT)) - message( _("End locked: Drag to other end of chord") ); - else if (Da.trk) message(_("End Position locked: Drag out curve start with Shift")); - else - message( _("Drag to other end of chord") ); - break; + if (Da.create_state == NOCURVE) { + Da.pos0 = pos; + } else { + Da.pos1 = pos; + } + + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); + switch (mode) { + case crvCmdFromEP1: + tempSegs(0).type = (track?SEG_STRTRK:SEG_STRLIN); + tempSegs(0).color = color; + tempSegs(0).lineWidth = width; + Da.create_state = FIRSTEND_DEF; + Da.end0 = pos; + CreateEndAnchor(pos,anchor_array,found); + if (Da.trk && !(MyGetKeyState() & WKEY_SHIFT)) { message(_("End locked: Drag out curve start")); } + else if (Da.trk) { message(_("End Position locked: Drag out curve start with Shift")); } + else { message(_("Drag along curve start") ); } + break; + case crvCmdFromTangent: + Da.create_state = FIRSTEND_DEF; + tempSegs(0).type = SEG_STRLIN; + tempSegs(0).color = color; + Da.create_state = CENTER_DEF; + CreateEndAnchor(pos,anchor_array,found); + if (Da.trk && !(MyGetKeyState() & WKEY_SHIFT)) { message(_("End locked: Drag out curve center")); } + else if (Da.trk) { message(_("End Position locked: Drag out curve start with Shift")); } + else { message(_("Drag out curve center") ); } + break; + case crvCmdFromCenter: + tempSegs(0).type = SEG_STRLIN; + tempSegs(0).color = color; + Da.create_state = CENTER_DEF; + CreateEndAnchor(pos,anchor_array,FALSE); + message(_("Drag out from center to endpoint")); + break; + case crvCmdFromChord: + tempSegs(0).type = (track?SEG_STRTRK:SEG_STRLIN); + tempSegs(0).color = color; + tempSegs(0).lineWidth = width; + CreateEndAnchor(pos,anchor_array,FALSE); + Da.create_state = FIRSTEND_DEF; + if (Da.trk && !(MyGetKeyState() & WKEY_SHIFT)) { + message( _("End locked: Drag to other end of chord") ); + } else if (Da.trk) { message(_("End Position locked: Drag out curve start with Shift")); } + else { + message( _("Drag to other end of chord") ); } - tempSegs(0).u.l.pos[0] = tempSegs(0).u.l.pos[1] = pos; + break; + } + tempSegs(0).u.l.pos[0] = tempSegs(0).u.l.pos[1] = pos; return C_CONTINUE; case C_MOVE: DYNARR_RESET(trkSeg_t,*anchor_array); DYNARR_APPEND(trkSeg_t,*anchor_array,1); - if (!Da.down) return C_CONTINUE; - if (Da.trk && track && !(MyGetKeyState() & WKEY_SHIFT)) { //Shift inhibits direction lock + if (!Da.down) { return C_CONTINUE; } + if (Da.trk && track + && !(MyGetKeyState() & WKEY_SHIFT)) { //Shift inhibits direction lock angle1 = NormalizeAngle(GetTrkEndAngle(Da.trk, Da.ep)); angle2 = NormalizeAngle(FindAngle(pos, Da.pos0)-angle1); if (mode ==crvCmdFromEP1 ) { - if (angle2 > 90.0 && angle2 < 270.0) - Translate( &pos, Da.pos0, angle1, -FindDistance( Da.pos0, pos )*cos(D2R(angle2)) ); - else pos = Da.pos0; + if (angle2 > 90.0 && angle2 < 270.0) { + Translate( &pos, Da.pos0, angle1, -FindDistance( Da.pos0, + pos )*cos(D2R(angle2)) ); + } else { pos = Da.pos0; } } else if ( mode == crvCmdFromChord ) { DIST_T dp = -FindDistance(Da.pos0, pos)*sin(D2R(angle2)); - if (DifferenceBetweenAngles(FindAngle(Da.pos0,pos),angle1)>0) + if (DifferenceBetweenAngles(FindAngle(Da.pos0,pos),angle1)>0) { Translate( &pos, Da.pos0, angle1+90, dp ); - else + } else { Translate( &pos, Da.pos0, angle1-90, -dp ); + } } else if (mode == crvCmdFromCenter) { DIST_T dp = -FindDistance(Da.pos0, pos)*sin(D2R(angle2)); - if (angle2 > 90 && angle2 < 270.0) + if (angle2 > 90 && angle2 < 270.0) { Translate( &pos, Da.pos0, angle1+90.0, dp ); - else + } else { Translate( &pos, Da.pos0, angle1-90.0, dp ); + } } else if (mode == crvCmdFromTangent) { DIST_T dp = FindDistance(Da.pos0, pos)*sin(D2R(angle2)); Translate( &pos, Da.pos0, angle1-90.0, dp ); } - } else if (track) SnapPos(&pos); - tempSegs_da.cnt =1; + } else if (track) { SnapPos(&pos); } + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); if (Da.trk && mode == crvCmdFromChord) { tempSegs(0).type = SEG_CRVTRK; tempSegs(0).u.c.center.x = (pos.x+Da.pos0.x)/2.0; tempSegs(0).u.c.center.y = (pos.y+Da.pos0.y)/2.0; tempSegs(0).u.c.radius = FindDistance(pos,Da.pos0)/2; ANGLE_T a0 = FindAngle(tempSegs(0).u.c.center,Da.pos0); - ANGLE_T a1 = FindAngle(tempSegs(0).u.c.center,pos); - if (NormalizeAngle(a0+90-GetTrkEndAngle(Da.trk,Da.ep))<90) { - tempSegs(0).u.c.a0 = a0; - } else { - tempSegs(0).u.c.a0 = a1; + if ( NormalizeAngle( GetTrkEndAngle(Da.trk,Da.ep) - a0 ) > 180.0 ) { + a0 = NormalizeAngle( a0 + 180.0 ); } + tempSegs(0).u.c.a0 = a0; tempSegs(0).u.c.a1 = 180.0; - } else tempSegs(0).u.l.pos[1] = pos; + } else { tempSegs(0).u.l.pos[1] = pos; } Da.pos1 = pos; d = FindDistance( Da.pos0, Da.pos1 ); a = FindAngle( Da.pos0, Da.pos1 ); switch ( mode ) { case crvCmdFromEP1: - if (Da.trk) message( _("Start Locked: Drag out curve start - Angle=%0.3f"), PutAngle(a)); - else message( _("Drag out curve start - Angle=%0.3f"), PutAngle(a) ); + if (Da.trk) { message( _("Start Locked: Drag out curve start - Angle=%0.3f"), PutAngle(a)); } + else { message( _("Drag out curve start - Angle=%0.3f"), PutAngle(a) ); } CreateEndAnchor(Da.pos0,anchor_array,Da.lock0); - DrawArrowHeadsArray( anchor_array, pos, FindAngle(Da.pos0,Da.pos1)+90, TRUE, wDrawColorBlue ); - tempSegs_da.cnt = 1; + DrawArrowHeadsArray( anchor_array, pos, FindAngle(Da.pos0,Da.pos1)+90, TRUE, + wDrawColorBlue ); + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); break; case crvCmdFromTangent: - if (Da.trk) message( _("Tangent locked: Drag out center - Radius=%s Angle=%0.3f"), FormatDistance(d), PutAngle(a) ); - else message( _("Drag out center - Radius=%s Angle=%0.3f"), FormatDistance(d), PutAngle(a) ); + if (Da.trk) { message( _("Tangent locked: Drag out center - Radius=%s Angle=%0.3f"), FormatDistance(d), PutAngle(a) ); } + else { message( _("Drag out center - Radius=%s Angle=%0.3f"), FormatDistance(d), PutAngle(a) ); } CreateEndAnchor(Da.pos1,anchor_array,TRUE); - DrawArrowHeadsArray( anchor_array, Da.pos0, FindAngle(Da.pos0,Da.pos1)+90, TRUE, wDrawColorBlue ); - tempSegs_da.cnt = 1; + DrawArrowHeadsArray( anchor_array, Da.pos0, FindAngle(Da.pos0,Da.pos1)+90, TRUE, + wDrawColorBlue ); + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); break; case crvCmdFromCenter: - message( _("Drag to Edge: Radius=%s Angle=%0.3f"), FormatDistance(d), PutAngle(a) ); + message( _("Drag to Edge: Radius=%s Angle=%0.3f"), FormatDistance(d), + PutAngle(a) ); CreateEndAnchor(Da.pos0,anchor_array,Da.lock0); - DrawArrowHeadsArray( anchor_array, Da.pos1, FindAngle(Da.pos1,Da.pos0)+90, TRUE, wDrawColorBlue ); - tempSegs_da.cnt = 1; + DrawArrowHeadsArray( anchor_array, Da.pos1, FindAngle(Da.pos1,Da.pos0)+90, TRUE, + wDrawColorBlue ); + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); break; case crvCmdFromChord: - if (Da.trk) message( _("Start locked: Drag out chord length=%s angle=%0.3f"), FormatDistance(d), PutAngle(a) ); - else message( _("Drag out chord length=%s angle=%0.3f"), FormatDistance(d), PutAngle(a) ); + if (Da.trk) { message( _("Start locked: Drag out chord length=%s angle=%0.3f"), FormatDistance(d), PutAngle(a) ); } + else { message( _("Drag out chord length=%s angle=%0.3f"), FormatDistance(d), PutAngle(a) ); } Da.middle.x = (Da.pos1.x+Da.pos0.x)/2.0; Da.middle.y = (Da.pos1.y+Da.pos0.y)/2.0; if (track && Da.trk) { @@ -349,20 +363,23 @@ EXPORT STATUS_T CreateCurve( } CreateEndAnchor(Da.pos0,anchor_array,TRUE); CreateEndAnchor(Da.pos1,anchor_array,FALSE); - if (!track || !Da.trk) - DrawArrowHeadsArray( anchor_array, Da.middle, FindAngle(Da.pos0,Da.pos1)+90, TRUE, wDrawColorBlue ); + if (!track || !Da.trk) { + DrawArrowHeadsArray( anchor_array, Da.middle, FindAngle(Da.pos0,Da.pos1)+90, + TRUE, wDrawColorBlue ); + } break; } return C_CONTINUE; case C_UP: /* Note - no anchor reset - assumes run after Down/Move */ - if (!Da.down) return C_CONTINUE; + if (!Da.down) { return C_CONTINUE; } if (Da.trk) { angle1 = NormalizeAngle(GetTrkEndAngle(Da.trk, Da.ep)); angle2 = NormalizeAngle(FindAngle(pos, Da.pos0)-angle1); if (mode == crvCmdFromEP1) { - if (angle2 > 90.0 && angle2 < 270.0) { - Translate( &pos, Da.pos0, angle1, -FindDistance( Da.pos0, pos )*cos(D2R(angle2)) ); + if (angle2 > 90.0 && angle2 < 270.0) { + Translate( &pos, Da.pos0, angle1, -FindDistance( Da.pos0, + pos )*cos(D2R(angle2)) ); Da.pos1 = pos; } else { ErrorMessage( MSG_TRK_TOO_SHORT, "Curved ", PutDim(0.0) ); @@ -374,23 +391,25 @@ EXPORT STATUS_T CreateCurve( Da.pos1 = pos; } else { DIST_T dp = -FindDistance(Da.pos0, pos)*sin(D2R(angle2)); - if (angle2 > 180.0) + if (angle2 > 180.0) { Translate( &pos, Da.pos0, angle1+90.0, dp ); - else + } else { Translate( &pos, Da.pos0, angle1-90.0, dp ); + } Da.pos1 = pos; } if (FindDistance(Da.pos0,Da.pos1)<minLength) { - ErrorMessage( MSG_TRK_TOO_SHORT, "Curved ", PutDim(FindDistance(Da.pos0,Da.pos1)) ); + ErrorMessage( MSG_TRK_TOO_SHORT, "Curved ", PutDim(FindDistance(Da.pos0, + Da.pos1)) ); return C_TERMINATE; } } switch (mode) { - case crvCmdFromEP1: + case crvCmdFromEP1: case crvCmdFromTangent: case crvCmdFromCenter: case crvCmdFromChord: - for (int i=0;i<(*anchor_array).cnt;i++) { + for (int i=0; i<(*anchor_array).cnt; i++) { DYNARR_N(trkSeg_t,*anchor_array,i).color = drawColorRed; } break; @@ -434,7 +453,7 @@ static STATUS_T CmdCurve( wAction_t action, coOrd pos ) curveMode = VP2L(commandContext); Da.state = -1; Da.pos0 = pos; - tempSegs_da.cnt = 0; + DYNARR_RESET( trkSeg_t, tempSegs_da ); segCnt = 0; STATUS_T rcode; DYNARR_RESET(trkSeg_t,anchors_da); @@ -442,16 +461,18 @@ static STATUS_T CmdCurve( wAction_t action, coOrd pos ) ParamCreateControls(&curvePG, NULL); } SetAllTrackSelect(FALSE); - return CreateCurve( action, pos, TRUE, wDrawColorBlack, 0, curveMode, &anchors_da, InfoMessage ); + return CreateCurve( action, pos, TRUE, wDrawColorBlack, 0, curveMode, + &anchors_da, InfoMessage ); case C_DOWN: if (Da.state == -1) { - if (lock) pos = movePos; + if (lock) { pos = movePos; } Da.pos0 = Da.pos1 = pos; Da.state = 0; - rcode = CreateCurve( action, pos, TRUE, wDrawColorBlack, 0, curveMode, &anchors_da, InfoMessage ); + rcode = CreateCurve( action, pos, TRUE, wDrawColorBlack, 0, curveMode, + &anchors_da, InfoMessage ); segCnt = tempSegs_da.cnt ; - if (!Da.down) Da.state = -1; + if (!Da.down) { Da.state = -1; } return rcode; //Da.pos0 = pos; } @@ -462,7 +483,7 @@ static STATUS_T CmdCurve( wAction_t action, coOrd pos ) } infoSubst = FALSE; //This is where the user could adjust - if we allow that? - tempSegs_da.cnt = segCnt; + DYNARR_SET( trkSeg_t, tempSegs_da, segCnt ); return C_CONTINUE; @@ -492,78 +513,89 @@ static STATUS_T CmdCurve( wAction_t action, coOrd pos ) return C_CONTINUE; case C_MOVE: - if (Da.state<0) return C_CONTINUE; + if (Da.state<0) { return C_CONTINUE; } if ( Da.state == 0 ) { - Da.pos1 = pos; - rc = CreateCurve( action, pos, TRUE, wDrawColorBlack, 0, curveMode, &anchors_da, InfoMessage ); + Da.pos1 = pos; + rc = CreateCurve( action, pos, TRUE, wDrawColorBlack, 0, curveMode, &anchors_da, + InfoMessage ); segCnt = tempSegs_da.cnt ; } else { DYNARR_RESET(trkSeg_t,anchors_da); // SnapPos( &pos ); - tempSegs_da.cnt = segCnt; - if (Da.trk) PlotCurve( curveMode, Da.pos0, Da.pos1, pos, &Da.curveData, FALSE, desired_radius ); - else PlotCurve( curveMode, Da.pos0, Da.pos1, pos, &Da.curveData, TRUE, desired_radius ); + DYNARR_SET( trkSeg_t, tempSegs_da, segCnt ); + if (Da.trk) { PlotCurve( curveMode, Da.pos0, Da.pos1, pos, &Da.curveData, FALSE, desired_radius ); } + else { PlotCurve( curveMode, Da.pos0, Da.pos1, pos, &Da.curveData, TRUE, desired_radius ); } if (Da.curveData.type == curveTypeStraight) { + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); tempSegs(0).type = SEG_STRTRK; tempSegs(0).u.l.pos[0] = Da.pos0; tempSegs(0).u.l.pos[1] = Da.curveData.pos1; - tempSegs_da.cnt = 1; segCnt = 1; InfoMessage( _("Straight Track: Length=%s Angle=%0.3f"), - FormatDistance(FindDistance( Da.pos0, Da.curveData.pos1 )), - PutAngle(FindAngle( Da.pos0, Da.curveData.pos1 )) ); - DrawArrowHeadsArray(&anchors_da,Da.curveData.pos1,FindAngle(Da.pos0, Da.curveData.pos1)+90,TRUE,wDrawColorRed); + FormatDistance(FindDistance( Da.pos0, Da.curveData.pos1 )), + PutAngle(FindAngle( Da.pos0, Da.curveData.pos1 )) ); + DrawArrowHeadsArray(&anchors_da,Da.curveData.pos1,FindAngle(Da.pos0, + Da.curveData.pos1)+90,TRUE,wDrawColorRed); } else if (Da.curveData.type == curveTypeNone) { - tempSegs_da.cnt = 0; + DYNARR_RESET( trkSeg_t, tempSegs_da ); segCnt = 0; InfoMessage( _("Back") ); } else if (Da.curveData.type == curveTypeCurve) { + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); tempSegs(0).type = SEG_CRVTRK; tempSegs(0).u.c.center = Da.curveData.curvePos; tempSegs(0).u.c.radius = Da.curveData.curveRadius; tempSegs(0).u.c.a0 = Da.curveData.a0; tempSegs(0).u.c.a1 = Da.curveData.a1; - tempSegs_da.cnt = 1; segCnt = 1; d = D2R(Da.curveData.a1); - if (d < 0.0) + if (d < 0.0) { d = 2*M_PI+d; + } if ( d*Da.curveData.curveRadius > mapD.size.x+mapD.size.y ) { ErrorMessage( MSG_CURVE_TOO_LARGE ); - tempSegs_da.cnt = 0; + DYNARR_RESET( trkSeg_t, tempSegs_da ); Da.curveData.type = curveTypeNone; return C_CONTINUE; } InfoMessage( _("Curved Track: Radius=%s Angle=%0.3f Length=%s"), - FormatDistance(Da.curveData.curveRadius), Da.curveData.a1, - FormatDistance(Da.curveData.curveRadius*d) ); + FormatDistance(Da.curveData.curveRadius), Da.curveData.a1, + FormatDistance(Da.curveData.curveRadius*d) ); coOrd pos1; - Translate(&pos1,Da.curveData.curvePos,Da.curveData.a0+Da.curveData.a1,Da.curveData.curveRadius); - if (curveMode == crvCmdFromEP1 || curveMode == crvCmdFromChord) - DrawArrowHeadsArray(&anchors_da,pos,FindAngle(Da.curveData.curvePos,pos),TRUE,wDrawColorRed); - else if (curveMode == crvCmdFromTangent || curveMode == crvCmdFromCenter) { - if (Da.curveData.curveRadius == desired_radius) + Translate(&pos1,Da.curveData.curvePos,Da.curveData.a0+Da.curveData.a1, + Da.curveData.curveRadius); + if (curveMode == crvCmdFromEP1 || curveMode == crvCmdFromChord) { + DrawArrowHeadsArray(&anchors_da,pos,FindAngle(Da.curveData.curvePos,pos),TRUE, + wDrawColorRed); + } else if (curveMode == crvCmdFromTangent || curveMode == crvCmdFromCenter) { + if (Da.curveData.curveRadius == desired_radius) { CreateEndAnchor(Da.curveData.pos2,&anchors_da,TRUE); - else + } else { CreateEndAnchor(Da.curveData.pos2,&anchors_da,FALSE); - DrawArrowHeadsArray(&anchors_da,Da.curveData.pos2,FindAngle(Da.curveData.curvePos,Da.curveData.pos2)+90,TRUE,wDrawColorRed); + } + DrawArrowHeadsArray(&anchors_da,Da.curveData.pos2, + FindAngle(Da.curveData.curvePos,Da.curveData.pos2)+90,TRUE,wDrawColorRed); } - if (Da.curveData.curveRadius == desired_radius) + if (Da.curveData.curveRadius == desired_radius) { CreateEndAnchor(Da.curveData.curvePos,&anchors_da,TRUE); - else + } else { CreateEndAnchor(Da.curveData.curvePos,&anchors_da,FALSE); + } } } return rc; case C_TEXT: - if ( Da.state == 0 ) - return CreateCurve( action, pos, TRUE, wDrawColorBlack, 0, curveMode, &anchors_da, InfoMessage ); - /*no break*/ + if ( Da.state == 0 ) { + return CreateCurve( action, pos, TRUE, wDrawColorBlack, 0, curveMode, + &anchors_da, InfoMessage ); + } + /*no break*/ case C_UP: - if (Da.state<0) return C_CONTINUE; - if (Da.state == 0 && ((curveMode != crvCmdFromChord) || (curveMode == crvCmdFromChord && !Da.trk))) { + if (Da.state<0) { return C_CONTINUE; } + if (Da.state == 0 && ((curveMode != crvCmdFromChord) + || (curveMode == crvCmdFromChord && !Da.trk))) { //SnapPos( &pos ); //Da.pos1 = pos; if ((d = FindDistance(Da.pos0,Da.pos1))<minLength) { @@ -571,8 +603,9 @@ static STATUS_T CmdCurve( wAction_t action, coOrd pos ) return C_TERMINATE; } Da.state = 1; - CreateCurve( action, pos, TRUE, wDrawColorBlack, 0, curveMode, &anchors_da, InfoMessage ); - tempSegs_da.cnt = 1; + CreateCurve( action, pos, TRUE, wDrawColorBlack, 0, curveMode, &anchors_da, + InfoMessage ); + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); segCnt = tempSegs_da.cnt; sprintf(message, "desired_radius-%s", curScaleName); @@ -594,9 +627,10 @@ static STATUS_T CmdCurve( wAction_t action, coOrd pos ) ErrorMessage( MSG_TRK_TOO_SHORT, "Curved ", PutDim(fabs(minLength-d)) ); return C_TERMINATE; } - PlotCurve( curveMode, Da.pos0, Da.pos1, Da.middle, &Da.curveData, TRUE, desired_radius ); + PlotCurve( curveMode, Da.pos0, Da.pos1, Da.middle, &Da.curveData, TRUE, + desired_radius ); } - tempSegs_da.cnt = 0; + DYNARR_RESET( trkSeg_t, tempSegs_da ); segCnt = 0; Da.state = -1; DYNARR_RESET(trkSeg_t,anchors_da); // No More anchors for this one @@ -609,21 +643,22 @@ static STATUS_T CmdCurve( wAction_t action, coOrd pos ) t = NewStraightTrack( Da.pos0, Da.curveData.pos1 ); if (Da.trk && !(MyGetKeyState() & WKEY_SHIFT)) { EPINX_T ep = PickUnconnectedEndPoint(Da.pos0, t); - if (ep != -1) ConnectTracks(Da.trk, Da.ep, t, ep); + if (ep != -1) { ConnectTracks(Da.trk, Da.ep, t, ep); } } UndoEnd(); } else if (Da.curveData.type == curveTypeCurve) { - if ((d = Da.curveData.curveRadius * Da.curveData.a1 *2.0*M_PI/360.0) < minLength) { + if ((d = Da.curveData.curveRadius * Da.curveData.a1 *2.0*M_PI/360.0) < + minLength) { ErrorMessage( MSG_TRK_TOO_SHORT, "Curved ", PutDim(fabs(minLength-d)) ); return C_TERMINATE; } UndoStart( _("Create Curved Track"), "newCurve - curve" ); t = NewCurvedTrack( Da.curveData.curvePos, Da.curveData.curveRadius, - Da.curveData.a0, Da.curveData.a1, 0 ); + Da.curveData.a0, Da.curveData.a1, 0 ); if (Da.trk && !(MyGetKeyState() & WKEY_SHIFT)) { EPINX_T ep = PickUnconnectedEndPoint(Da.pos0, t); - if (ep != -1) ConnectTracks(Da.trk, Da.ep, t, ep); + if (ep != -1) { ConnectTracks(Da.trk, Da.ep, t, ep); } } UndoEnd(); } else { @@ -634,15 +669,15 @@ static STATUS_T CmdCurve( wAction_t action, coOrd pos ) case C_REDRAW: if ( Da.state >= 0 ) { - DrawSegs( &tempD, zero, 0.0, &tempSegs(0), tempSegs_da.cnt, trackGauge, wDrawColorBlack ); + DrawSegsDA( &tempD, NULL, zero, 0.0, &tempSegs_da, trackGauge, wDrawColorBlack, + 0 ); } - if (anchors_da.cnt) - DrawSegs( &tempD, zero, 0.0, &anchors(0), anchors_da.cnt, trackGauge, wDrawColorBlack ); + DrawSegsDA( &tempD, NULL, zero, 0.0, &anchors_da, trackGauge, wDrawColorBlack, + 0 ); return C_CONTINUE; case C_CANCEL: if (Da.state == 1) { - tempSegs_da.cnt = 0; Da.trk = NULL; } DYNARR_RESET(trkSeg_t,anchors_da); @@ -695,24 +730,27 @@ static paramData_t helixPLs[] = { { PD_FLOAT, &helixGrade, "grade", 0, &r0_100, N_("Grade") }, { PD_FLOAT, &helixVertSep, "vertSep", PDO_DIM, &r0_1000000, N_("Vertical Separation") }, #define I_HELIXMSG (6) - { PD_MESSAGE, N_("Total Length"), NULL, PDO_DLGRESETMARGIN, I2VP(200) } }; + { PD_MESSAGE, N_("Total Length"), NULL, PDO_DLGRESETMARGIN, I2VP(200) } +}; static paramGroup_t helixPG = { "helix", PGO_PREFMISCGROUP, helixPLs, COUNT( helixPLs ) }; static paramData_t circleRadiusPLs[] = { - { PD_FLOAT, &circleRadius, "radius", PDO_DIM, &r1_10000 } }; + { PD_FLOAT, &circleRadius, "radius", PDO_DIM, &r1_10000 } +}; static paramGroup_t circleRadiusPG = { "circle", 0, circleRadiusPLs, COUNT( circleRadiusPLs ) }; static void ComputeHelix( - paramGroup_p pg, - int h_inx, - void * data ) + paramGroup_p pg, + int h_inx, + void * data ) { DIST_T totTurns; DIST_T length; long updates = 0; - if ( h_inx < 0 || h_inx >= COUNT( h_orders ) ) + if ( h_inx < 0 || h_inx >= COUNT( h_orders ) ) { return; + } ParamLoadData( &helixPG ); totTurns = helixTurns + helixAngSep/360.0; length = totTurns * helixRadius * (2 * M_PI); @@ -720,7 +758,7 @@ static void ComputeHelix( switch ( h_inx ) { case H_ELEV: if (h_orders[H_TURNS]<h_orders[H_VERTSEP] && - origVertSep > 0.0) { + origVertSep > 0.0) { helixTurns = (int)floor(helixElev/origVertSep - helixAngSep/360.0); totTurns = helixTurns + helixAngSep/360.0; updates |= (1<<H_TURNS); @@ -753,7 +791,7 @@ static void ComputeHelix( } if ( totTurns > 0.0 ) { if ( h_orders[H_RADIUS]>=h_orders[H_GRADE] || - (helixGrade==0.0 && totTurns>0 && helixRadius>0) ) { + (helixGrade==0.0 && totTurns>0 && helixRadius>0) ) { if ( helixRadius > 0.0 ) { helixGrade = helixElev/(totTurns*helixRadius*(2*M_PI))*100.0; updates |= (1<<H_GRADE); @@ -767,13 +805,15 @@ static void ComputeHelix( } length = totTurns * helixRadius * (2 * M_PI); for ( h_inx=0; updates; h_inx++,updates>>=1 ) { - if ( (updates&1) ) + if ( (updates&1) ) { ParamLoadControl( &helixPG, h_inx ); + } } - if (length > 0.0) + if (length > 0.0) { sprintf( message, _("Total Length %s"), FormatDistance(length) ); - else + } else { strcpy( message, " " ); + } ParamLoadMessage( &helixPG, I_HELIXMSG, message ); } @@ -787,8 +827,8 @@ static void HelixCancel( wWin_p win ) static void ChangeHelixW( long changes ) { if ( (changes & CHANGE_UNITS) && - helixW != NULL && - wWinIsVisible(helixW) ) { + helixW != NULL && + wWinIsVisible(helixW) ) { ParamLoadControls( &helixPG ); ComputeHelix( NULL, 6, NULL ); } @@ -808,8 +848,10 @@ static STATUS_T CmdCircleCommon( wAction_t action, coOrd pos, BOOL_T helix ) case C_START: if (helix) { - if (helixW == NULL) - helixW = ParamCreateDialog(&helixPG, MakeWindowTitle(_("Helix")), NULL, NULL, HelixCancel, TRUE, NULL, 0, ComputeHelix); + if (helixW == NULL) { + helixW = ParamCreateDialog(&helixPG, MakeWindowTitle(_("Helix")), NULL, NULL, + HelixCancel, TRUE, NULL, 0, ComputeHelix); + } ParamLoadControls(&helixPG); ParamGroupRecord(&helixPG); ComputeHelix(NULL, 6, NULL); @@ -837,12 +879,10 @@ static STATUS_T CmdCircleCommon( wAction_t action, coOrd pos, BOOL_T helix ) } } SetAllTrackSelect( FALSE ); - tempSegs_da.cnt = 0; + DYNARR_RESET( trkSeg_t, tempSegs_da ); return C_CONTINUE; case C_DOWN: - DYNARR_SET(trkSeg_t, tempSegs_da, 1); - tempSegs_da.cnt = 0; if (helix) { if (helixRadius <= 0.0) { ErrorMessage(MSG_RADIUS_GTR_0); @@ -873,13 +913,14 @@ static STATUS_T CmdCircleCommon( wAction_t action, coOrd pos, BOOL_T helix ) } } SnapPos(&pos); - tempSegs(0).u.c.center = pos0 = pos; - tempSegs(0).color = wDrawColorBlack; - tempSegs(0).width = 0; + DYNARR_RESET(trkSeg_t, tempSegs_da); + pos0 = pos; return C_CONTINUE; case C_MOVE: SnapPos(&pos); + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); + tempSegs(0).type = SEG_CRVTRK; tempSegs(0).u.c.center = pos; if (!helix) { switch (circleMode) { @@ -896,11 +937,11 @@ static STATUS_T CmdCircleCommon( wAction_t action, coOrd pos, BOOL_T helix ) break; } } - tempSegs(0).type = SEG_CRVTRK; + tempSegs(0).color = wDrawColorBlack; + tempSegs(0).lineWidth = 0; tempSegs(0).u.c.radius = helix ? helixRadius : circleRadius; tempSegs(0).u.c.a0 = 0.0; tempSegs(0).u.c.a1 = 360.0; - tempSegs_da.cnt = 1; return C_CONTINUE; case C_UP: @@ -933,22 +974,25 @@ static STATUS_T CmdCircleCommon( wAction_t action, coOrd pos, BOOL_T helix ) } UndoEnd(); DrawNewTrack(t); - if (helix) + if (helix) { wHide( helixW ); - else + } else { InfoSubstituteControls( NULL, NULL ); - tempSegs_da.cnt = 0; + } + DYNARR_RESET( trkSeg_t, tempSegs_da ); return C_TERMINATE; case C_REDRAW: - DrawSegs( &tempD, zero, 0.0, &tempSegs(0), tempSegs_da.cnt, trackGauge, wDrawColorBlack ); + DrawSegsDA( &tempD, NULL, zero, 0.0, &tempSegs_da, trackGauge, wDrawColorBlack, + 0 ); return C_CONTINUE; case C_CANCEL: - if (helix) + if (helix) { wHide( helixW ); - else + } else { InfoSubstituteControls( NULL, NULL ); + } return C_CONTINUE; default: @@ -971,31 +1015,50 @@ static STATUS_T CmdHelix( wAction_t action, coOrd pos ) return CmdCircleCommon( action, pos, TRUE ); } -#include "bitmaps/curved-end.xpm" -#include "bitmaps/curved-tangent.xpm" -#include "bitmaps/curved-middle.xpm" -#include "bitmaps/curved-chord.xpm" -#include "bitmaps/bezier-track.xpm" -#include "bitmaps/cornu.xpm" -#include "bitmaps/circle.xpm" -#include "bitmaps/circle-tangent.xpm" -#include "bitmaps/circle-center.xpm" +#include "bitmaps/curved-end.xpm3" +#include "bitmaps/curved-tangent.xpm3" +#include "bitmaps/curved-middle.xpm3" +#include "bitmaps/curved-chord.xpm3" +#include "bitmaps/bezier-track.xpm3" +#include "bitmaps/cornu.xpm3" +#include "bitmaps/circle.xpm3" +#include "bitmaps/circle-tangent.xpm3" +#include "bitmaps/circle-center.xpm3" +// #include "bitmaps/helix.xpm" EXPORT void InitCmdCurve( wMenu_p menu ) { ButtonGroupBegin( _("Curve Track"), "cmdCurveSetCmd", _("Curve Tracks") ); - AddMenuButton( menu, CmdCurve, "cmdCurveEndPt", _("Curve from End-Pt"), wIconCreatePixMap( curved_end_xpm[iconSize] ), LEVEL0_50, IC_STICKY|IC_POPUP2|IC_WANT_MOVE, ACCL_CURVE1, I2VP(0) ); - AddMenuButton( menu, CmdCurve, "cmdCurveTangent", _("Curve from Tangent"), wIconCreatePixMap( curved_tangent_xpm[iconSize] ), LEVEL0_50, IC_STICKY|IC_POPUP2|IC_WANT_MOVE, ACCL_CURVE2, I2VP(1) ); - AddMenuButton( menu, CmdCurve, "cmdCurveCenter", _("Curve from Center"), wIconCreatePixMap( curved_middle_xpm[iconSize] ), LEVEL0_50, IC_STICKY|IC_POPUP2|IC_WANT_MOVE, ACCL_CURVE3, I2VP(2) ); - AddMenuButton( menu, CmdCurve, "cmdCurveChord", _("Curve from Chord"), wIconCreatePixMap( curved_chord_xpm[iconSize] ), LEVEL0_50, IC_STICKY|IC_POPUP2|IC_WANT_MOVE, ACCL_CURVE4, I2VP(3) ); - AddMenuButton( menu, CmdBezCurve, "cmdBezier", _("Bezier Curve"), wIconCreatePixMap( bezier_track_xpm[iconSize] ), LEVEL0_50, IC_STICKY|IC_POPUP2|IC_WANT_MOVE, ACCL_BEZIER, I2VP(bezCmdCreateTrack) ); - AddMenuButton( menu, CmdCornu, "cmdCornu", _("Cornu Curve"), wIconCreatePixMap( cornu_xpm[iconSize] ), LEVEL0_50, IC_STICKY|IC_POPUP2|IC_WANT_MOVE, ACCL_CORNU, I2VP(cornuCmdCreateTrack)); + AddMenuButton( menu, CmdCurve, "cmdCurveEndPt", _("Curve from End-Pt"), + wIconCreatePixMap( curved_end_xpm3[iconSize] ), LEVEL0_50, + IC_STICKY|IC_POPUP2|IC_WANT_MOVE, ACCL_CURVE1, I2VP(0) ); + AddMenuButton( menu, CmdCurve, "cmdCurveTangent", _("Curve from Tangent"), + wIconCreatePixMap( curved_tangent_xpm3[iconSize] ), LEVEL0_50, + IC_STICKY|IC_POPUP2|IC_WANT_MOVE, ACCL_CURVE2, I2VP(1) ); + AddMenuButton( menu, CmdCurve, "cmdCurveCenter", _("Curve from Center"), + wIconCreatePixMap( curved_middle_xpm3[iconSize] ), LEVEL0_50, + IC_STICKY|IC_POPUP2|IC_WANT_MOVE, ACCL_CURVE3, I2VP(2) ); + AddMenuButton( menu, CmdCurve, "cmdCurveChord", _("Curve from Chord"), + wIconCreatePixMap( curved_chord_xpm3[iconSize] ), LEVEL0_50, + IC_STICKY|IC_POPUP2|IC_WANT_MOVE, ACCL_CURVE4, I2VP(3) ); + AddMenuButton( menu, CmdBezCurve, "cmdBezier", _("Bezier Curve"), + wIconCreatePixMap( bezier_track_xpm3[iconSize] ), LEVEL0_50, + IC_STICKY|IC_POPUP2|IC_WANT_MOVE, ACCL_BEZIER, I2VP(bezCmdCreateTrack) ); + AddMenuButton( menu, CmdCornu, "cmdCornu", _("Cornu Curve"), + wIconCreatePixMap( cornu_xpm3[iconSize] ), LEVEL0_50, + IC_STICKY|IC_POPUP2|IC_WANT_MOVE, ACCL_CORNU, I2VP(cornuCmdCreateTrack)); ButtonGroupEnd(); ButtonGroupBegin( _("Circle Track"), "cmdCircleSetCmd", _("Circle Tracks") ); - AddMenuButton( menu, CmdCircle, "cmdCircleFixedRadius", _("Fixed Radius Circle"), wIconCreatePixMap( circle_xpm[iconSize] ), LEVEL0_50, IC_STICKY|IC_POPUP2, ACCL_CIRCLE1, I2VP(0) ); - AddMenuButton( menu, CmdCircle, "cmdCircleTangent", _("Circle from Tangent"), wIconCreatePixMap( circle_tangent_xpm[iconSize] ), LEVEL0_50, IC_STICKY|IC_POPUP2, ACCL_CIRCLE2, I2VP(1) ); - AddMenuButton( menu, CmdCircle, "cmdCircleCenter", _("Circle from Center"), wIconCreatePixMap( circle_center_xpm[iconSize] ), LEVEL0_50, IC_STICKY|IC_POPUP2, ACCL_CIRCLE3, I2VP(2) ); + AddMenuButton( menu, CmdCircle, "cmdCircleFixedRadius", + _("Fixed Radius Circle"), wIconCreatePixMap( circle_xpm3[iconSize] ), LEVEL0_50, + IC_STICKY|IC_POPUP2, ACCL_CIRCLE1, I2VP(0) ); + AddMenuButton( menu, CmdCircle, "cmdCircleTangent", _("Circle from Tangent"), + wIconCreatePixMap( circle_tangent_xpm3[iconSize] ), LEVEL0_50, + IC_STICKY|IC_POPUP2, ACCL_CIRCLE2, I2VP(1) ); + AddMenuButton( menu, CmdCircle, "cmdCircleCenter", _("Circle from Center"), + wIconCreatePixMap( circle_center_xpm3[iconSize] ), LEVEL0_50, + IC_STICKY|IC_POPUP2, ACCL_CIRCLE3, I2VP(2) ); ButtonGroupEnd(); ParamRegister( &circleRadiusPG ); @@ -1013,8 +1076,8 @@ EXPORT void InitCmdCurve( wMenu_p menu ) void InitCmdHelix(wMenu_p menu) { - AddMenuButton(menu, CmdHelix, "cmdHelix", _("Helix"), NULL, LEVEL0_50, - IC_STICKY|IC_INITNOTSTICKY|IC_POPUP2, ACCL_HELIX, NULL); - ParamRegister(&helixPG); - RegisterChangeNotification(ChangeHelixW); + AddMenuButton(menu, CmdHelix, "cmdHelix", _("Helix"), NULL, LEVEL0_50, + IC_STICKY|IC_INITNOTSTICKY|IC_POPUP2, ACCL_HELIX, NULL); + ParamRegister(&helixPG); + RegisterChangeNotification(ChangeHelixW); } diff --git a/app/bin/ccurve.h b/app/bin/ccurve.h index 7ae4227..07122f9 100644 --- a/app/bin/ccurve.h +++ b/app/bin/ccurve.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef HAVE_CCURVE_H @@ -27,14 +27,14 @@ #include "track.h" //- curveType_e typedef struct { - curveType_e type; - coOrd curvePos; - coOrd pos1; - coOrd pos2; - DIST_T curveRadius; - ANGLE_T a0, a1; - BOOL_T negative; - } curveData_t; + curveType_e type; + coOrd curvePos; + coOrd pos1; + coOrd pos2; + DIST_T curveRadius; + ANGLE_T a0, a1; + BOOL_T negative; +} curveData_t; #define crvCmdFromEP1 (0) #define crvCmdFromTangent (1) @@ -47,14 +47,17 @@ typedef struct { #define circleCmdFromCenter (2) typedef void (*curveMessageProc)( const char *, ... ); -STATUS_T CreateCurve( wAction_t, coOrd, BOOL_T, wDrawColor, DIST_T, long, dynArr_t *,curveMessageProc ); +STATUS_T CreateCurve( wAction_t, coOrd, BOOL_T, wDrawColor, DIST_T, long, + dynArr_t *,curveMessageProc ); int IsCurveCircle( track_p ); void PlotCurve( long, coOrd, coOrd, coOrd, curveData_t *, BOOL_T, DIST_T ); track_p NewCurvedTrack( coOrd, DIST_T, ANGLE_T, ANGLE_T, long ); DIST_T CurveDescriptionDistance( coOrd, track_p, coOrd *, BOOL_T, BOOL_T * ); STATUS_T CurveDescriptionMove( track_p, wAction_t, coOrd ); -BOOL_T GetCurveMiddle( track_p , coOrd * ); -int DrawArrowHeads(trkSeg_p sp, coOrd pos, ANGLE_T angle, BOOL_T bidirectional, wDrawColor color ); -int DrawArrowHeadsArray(dynArr_t *anchor_array,coOrd pos,ANGLE_T angle,BOOL_T bidirectional,wDrawColor color ); +BOOL_T GetCurveMiddle( track_p, coOrd * ); +int DrawArrowHeads(trkSeg_p sp, coOrd pos, ANGLE_T angle, BOOL_T bidirectional, + wDrawColor color ); +int DrawArrowHeadsArray(dynArr_t *anchor_array,coOrd pos,ANGLE_T angle, + BOOL_T bidirectional,wDrawColor color ); #endif // !HAVE_CCURVE_H diff --git a/app/bin/cdraw.c b/app/bin/cdraw.c index b6cc035..4d52408 100644 --- a/app/bin/cdraw.c +++ b/app/bin/cdraw.c @@ -2,23 +2,23 @@ * Drawing of geometric elements */ - /* XTrkCad - Model Railroad CAD - * Copyright (C) 2005 Dave Bullis - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ +/* XTrkCad - Model Railroad CAD + * Copyright (C) 2005 Dave Bullis + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ #include "common.h" #include "ccurve.h" @@ -27,10 +27,11 @@ #include "fileio.h" #include "param.h" #include "track.h" +#include "tbezier.h" #include "misc.h" #include "cselect.h" +#include "cundo.h" #include "common-ui.h" -extern TRKTYP_T T_BZRLIN; static wMenu_p drawModDelMI; static wMenu_p drawModLinMI; @@ -56,35 +57,32 @@ static wMenuPush_p drawModCenterDot; static wMenuPush_p drawModPhantom; -extern void wSetSelectedFontSize(wFontSize_t size); - static long fontSizeList[] = { - 4, 5, 6, 7, 8, 10, 12, 14, 16, 18, 20, 24, 28, 32, 36, - 40, 48, 56, 64, 72, 80, 90, 100, 120, 140, 160, 180, - 200, 250, 300, 350, 400, 450, 500 }; + 4, 5, 6, 7, 8, 10, 12, 14, 16, 18, 20, 24, 28, 32, 36, + 40, 48, 56, 64, 72, 80, 90, 100, 120, 140, 160, 180, + 200, 250, 300, 350, 400, 450, 500 +}; EXPORT void LoadFontSizeList( - wList_p list, - long curFontSize) + wList_p list, + long curFontSize) { wIndex_t curInx = 0, inx1; int inx; wListClear(list); - for (inx = 0; inx < COUNT( fontSizeList ); inx++) - { + for (inx = 0; inx < COUNT( fontSizeList ); inx++) { if ((inx == 0 || curFontSize > fontSizeList[inx - 1]) && - (curFontSize < fontSizeList[inx])) - { + (curFontSize < fontSizeList[inx])) { sprintf(message, "%ld", curFontSize); curInx = wListAddValue(list, message, NULL, I2VP(curFontSize)); } sprintf(message, "%ld", fontSizeList[inx]); inx1 = wListAddValue(list, message, NULL, I2VP(fontSizeList[inx])); - if (curFontSize == fontSizeList[inx]) + if (curFontSize == fontSizeList[inx]) { curInx = inx1; + } } - if (curFontSize > fontSizeList[ COUNT( fontSizeList ) - 1]) - { + if (curFontSize > fontSizeList[ COUNT( fontSizeList ) - 1]) { sprintf(message, "%ld", curFontSize); curInx = wListAddValue(list, message, NULL, I2VP(curFontSize)); } @@ -100,20 +98,22 @@ long GetFontSize(wIndex_t inx) long GetFontSizeIndex(long size) { int i; - for (i = 0; i < COUNT( fontSizeList ); i++) - { - if (fontSizeList[i] == size) + for (i = 0; i < COUNT( fontSizeList ); i++) { + if (fontSizeList[i] == size) { return(i); + } } return(-1); } EXPORT void UpdateFontSizeList( - long * fontSizeR, - wList_p list, - wIndex_t listInx ) + long * fontSizeR, + wList_p list, + wIndex_t listInx ) { long fontSize; + long largeFontSize; + wPrefGetInteger( "misc", "large-font-size", &largeFontSize, 500 ); if ( listInx >= 0 ) { *fontSizeR = VP2L( wListGetItemContext( list, listInx )); @@ -126,8 +126,13 @@ EXPORT void UpdateFontSizeList( sprintf( message, "%ld", *fontSizeR ); wListSetValue( list, message ); } else { - if ( fontSize <= 500 || NoticeMessage( MSG_LARGE_FONT, _("Yes"), _("No") ) > 0 ) { - + if ( fontSize <= largeFontSize + || NoticeMessage( MSG_LARGE_FONT, _("Yes"), _("No") ) > 0 ) { + + if ( fontSize > largeFontSize ) { + largeFontSize = fontSize; + wPrefSetInteger( "misc", "large-font-size", largeFontSize ); + } *fontSizeR = fontSize; /* inform gtkfont dialog from change */ wSetSelectedFontSize((wFontSize_t)fontSize); @@ -149,13 +154,13 @@ EXPORT void UpdateFontSizeList( typedef struct extraDataDraw_t { - extraDataBase_t base; - coOrd orig; - ANGLE_T angle; - drawLineType_e lineType; - wIndex_t segCnt; - trkSeg_t segs[1]; - } extraDataDraw_t; + extraDataBase_t base; + coOrd orig; + ANGLE_T angle; + drawLineType_e lineType; + wIndex_t segCnt; + trkSeg_t segs[1]; +} extraDataDraw_t; static TRKTYP_T T_DRAW = -1; static track_p ignoredTableEdge; @@ -175,17 +180,26 @@ static void ComputeDrawBoundingBox( track_p t ) static track_p MakeDrawFromSeg1( - wIndex_t index, - coOrd pos, - ANGLE_T angle, - trkSeg_p sp ) + wIndex_t index, + coOrd pos, + ANGLE_T angle, + trkSeg_p sp ) { struct extraDataDraw_t * xx; track_p trk; - if ( sp->type == ' ' ) + if ( sp->type == ' ' ) { return NULL; + } + if (sp->type == SEG_BEZLIN) { + trk = NewBezierLine(sp->u.l.pos, NULL, 0, sp->color, sp->lineWidth); + trkSeg_p spb = &DYNARR_N(trkSeg_t, sp->bezSegs, 0); + FixUpBezierSegs(spb, sp->bezSegs.cnt); + MoveBezier(trk, pos); + RotateBezier(trk, pos, angle); + return trk; + } trk = NewTrack( index, T_DRAW, 0, sizeof *xx ); - xx = GET_EXTRA_DATA( trk, T_DRAW, extraDataDraw_t ); + xx = GET_EXTRA_DATA(trk, T_DRAW, extraDataDraw_t); xx->orig = pos; xx->angle = angle; xx->segCnt = 1; @@ -193,7 +207,7 @@ static track_p MakeDrawFromSeg1( memcpy( xx->segs, sp, sizeof *(trkSeg_p)0 ); if (xx->segs[0].type == SEG_POLY || - xx->segs[0].type == SEG_FILPOLY ) { + xx->segs[0].type == SEG_FILPOLY ) { xx->segs[0].u.p.pts = (pts_t*)MyMalloc( (sp->u.p.cnt) * sizeof (pts_t) ); memcpy(xx->segs[0].u.p.pts, sp->u.p.pts, sp->u.p.cnt * sizeof (pts_t) ); } @@ -205,25 +219,26 @@ static track_p MakeDrawFromSeg1( } EXPORT track_p MakeDrawFromSeg( - coOrd pos, - ANGLE_T angle, - trkSeg_p sp ) + coOrd pos, + ANGLE_T angle, + trkSeg_p sp ) { return MakeDrawFromSeg1( 0, pos, angle, sp ); } -int SliceCuts(ANGLE_T a, DIST_T radius) { +int SliceCuts(ANGLE_T a, DIST_T radius) +{ double Error = 0.05; double Error_angle = acos(1-(Error/fabs(radius))); - if (Error_angle <0.0001) return 0; + if (Error_angle <0.0001) { return 0; } return (int)(floor(D2R(a)/(2*Error_angle))); } /* Only straight, curved and PolyLine */ EXPORT track_p MakePolyLineFromSegs( - coOrd pos, - ANGLE_T angle, - dynArr_t * segsArr) + coOrd pos, + ANGLE_T angle, + dynArr_t * segsArr) { struct extraDataDraw_t * xx; track_p trk; @@ -234,72 +249,77 @@ EXPORT track_p MakePolyLineFromSegs( xx->lineType = DRAWLINESOLID; xx->segCnt = 1; xx->segs[0].type = SEG_POLY; - xx->segs[0].width = 0; + xx->segs[0].lineWidth = 0; xx->segs[0].u.p.polyType = POLYLINE; xx->segs[0].color = wDrawColorBlack; coOrd last; BOOL_T first = TRUE; int cnt = 0; - for (int i=0;i<segsArr->cnt;i++) { + for (int i=0; i<segsArr->cnt; i++) { trkSeg_p sp = &DYNARR_N(trkSeg_t,*segsArr,i); if (sp->type == SEG_BEZLIN || sp->type == SEG_BEZTRK ) { - for (int j=0;j<sp->bezSegs.cnt;j++) { + for (int j=0; j<sp->bezSegs.cnt; j++) { trkSeg_p spb = &DYNARR_N(trkSeg_t,sp->bezSegs,j); if (spb->type == SEG_STRLIN || spb->type == SEG_STRTRK) { - if (!first && IsClose(FindDistance(spb->u.l.pos[0], last))) + if (!first && IsClose(FindDistance(spb->u.l.pos[0], last))) { cnt++; - else + } else { cnt=cnt+2; + } last = spb->u.l.pos[1]; first = FALSE; - } - else if (spb->type == SEG_CRVLIN || spb->type == SEG_CRVTRK) { + } else if (spb->type == SEG_CRVLIN || spb->type == SEG_CRVTRK) { coOrd this; - if (spb->u.c.radius >= 0.0) + if (spb->u.c.radius >= 0.0) { Translate(&this, spb->u.c.center, spb->u.c.a0, fabs(spb->u.c.radius)); - else - Translate(&this, spb->u.c.center, spb->u.c.a0+spb->u.c.a1, fabs(spb->u.c.radius)); + } else { + Translate(&this, spb->u.c.center, spb->u.c.a0+spb->u.c.a1, + fabs(spb->u.c.radius)); + } if (first || !IsClose(FindDistance(this, last))) { cnt++; //Add first point } cnt += 1 + SliceCuts(spb->u.c.a1,spb->u.c.radius); - if (spb->u.c.radius >= 0.0) - Translate(&last, spb->u.c.center, spb->u.c.a0+spb->u.c.a1, fabs(spb->u.c.radius)); - else + if (spb->u.c.radius >= 0.0) { + Translate(&last, spb->u.c.center, spb->u.c.a0+spb->u.c.a1, + fabs(spb->u.c.radius)); + } else { Translate(&last, spb->u.c.center, spb->u.c.a0, fabs(spb->u.c.radius)); + } first = FALSE; } } - } - else if (sp->type == SEG_STRLIN || sp->type == SEG_STRTRK) { - if (!first && IsClose(FindDistance(sp->u.l.pos[0], last))) + } else if (sp->type == SEG_STRLIN || sp->type == SEG_STRTRK) { + if (!first && IsClose(FindDistance(sp->u.l.pos[0], last))) { cnt++; - else + } else { cnt=cnt+2; + } last = sp->u.l.pos[1]; first = FALSE; - } - else if (sp->type == SEG_CRVLIN || sp->type == SEG_CRVTRK) { + } else if (sp->type == SEG_CRVLIN || sp->type == SEG_CRVTRK) { coOrd this; - if (sp->u.c.radius >= 0.0) + if (sp->u.c.radius >= 0.0) { Translate(&this, sp->u.c.center, sp->u.c.a0, fabs(sp->u.c.radius)); - else + } else { Translate(&this, sp->u.c.center, sp->u.c.a0+sp->u.c.a1, fabs(sp->u.c.radius)); + } if (first || !IsClose(FindDistance(this, last))) { cnt++; //Add first point } cnt += 1+ SliceCuts(sp->u.c.a1,sp->u.c.radius); - if (sp->u.c.radius >= 0.0) + if (sp->u.c.radius >= 0.0) { Translate(&last, sp->u.c.center, sp->u.c.a0+sp->u.c.a1, fabs(sp->u.c.radius)); - else + } else { Translate(&last, sp->u.c.center, sp->u.c.a0, fabs(sp->u.c.radius)); + } first = FALSE; - } - else if (sp->type == SEG_POLY) { - if (!first && IsClose(FindDistance(sp->u.p.pts[0].pt, last))) + } else if (sp->type == SEG_POLY) { + if (!first && IsClose(FindDistance(sp->u.p.pts[0].pt, last))) { cnt = cnt + sp->u.p.cnt-1; - else + } else { cnt = cnt + sp->u.p.cnt; + } last = sp->u.p.pts[sp->u.p.cnt-1].pt; first = FALSE; } @@ -308,10 +328,10 @@ EXPORT track_p MakePolyLineFromSegs( xx->segs[0].u.p.pts = (pts_t*)MyMalloc( (cnt) * sizeof (pts_t) ); first = TRUE; int j =0; - for (int i=0;i<segsArr->cnt;i++) { + for (int i=0; i<segsArr->cnt; i++) { trkSeg_p sp = &DYNARR_N(trkSeg_t,*segsArr,i); if (sp->type == SEG_BEZLIN || sp->type == SEG_BEZTRK ) { - for (int l=0;l<sp->bezSegs.cnt;l++) { + for (int l=0; l<sp->bezSegs.cnt; l++) { trkSeg_p spb = &DYNARR_N(trkSeg_t,sp->bezSegs,l); if (spb->type == SEG_STRLIN || spb->type == SEG_STRTRK) { if (first || !IsClose(FindDistance(spb->u.l.pos[0], last))) { @@ -327,28 +347,36 @@ EXPORT track_p MakePolyLineFromSegs( } if (spb->type == SEG_CRVLIN || spb->type == SEG_CRVTRK) { coOrd this; - if (spb->u.c.radius>=0.0) + if (spb->u.c.radius>=0.0) { Translate(&this, spb->u.c.center, spb->u.c.a0, fabs(spb->u.c.radius)); - else - Translate(&this, spb->u.c.center, spb->u.c.a0+spb->u.c.a1, fabs(spb->u.c.radius)); + } else { + Translate(&this, spb->u.c.center, spb->u.c.a0+spb->u.c.a1, + fabs(spb->u.c.radius)); + } if (first || !IsClose(FindDistance(this, last))) { xx->segs[0].u.p.pts[j].pt= this; xx->segs[0].u.p.pts[j].pt_type = wPolyLineStraight; j++; } int slices = SliceCuts(spb->u.c.a1,spb->u.c.radius); - for (int k=1; k<slices;k++) { - if (spb->u.c.radius>=0.0) - Translate(&xx->segs[0].u.p.pts[j].pt, spb->u.c.center, spb->u.c.a0+(k*(spb->u.c.a1/(slices))), fabs(spb->u.c.radius)); - else - Translate(&xx->segs[0].u.p.pts[j].pt, spb->u.c.center, spb->u.c.a0+((slices-k)*(spb->u.c.a1/(slices))), fabs(spb->u.c.radius)); + for (int k=1; k<slices; k++) { + if (spb->u.c.radius>=0.0) { + Translate(&xx->segs[0].u.p.pts[j].pt, spb->u.c.center, + spb->u.c.a0+(k*(spb->u.c.a1/(slices))), fabs(spb->u.c.radius)); + } else { + Translate(&xx->segs[0].u.p.pts[j].pt, spb->u.c.center, + spb->u.c.a0+((slices-k)*(spb->u.c.a1/(slices))), fabs(spb->u.c.radius)); + } xx->segs[0].u.p.pts[j].pt_type = wPolyLineSmooth; j++; } - if (spb->u.c.radius>=0.0) - Translate(&xx->segs[0].u.p.pts[j].pt, spb->u.c.center, spb->u.c.a0+spb->u.c.a1, fabs(spb->u.c.radius)); - else - Translate(&xx->segs[0].u.p.pts[j].pt, spb->u.c.center, spb->u.c.a0, fabs(spb->u.c.radius)); + if (spb->u.c.radius>=0.0) { + Translate(&xx->segs[0].u.p.pts[j].pt, spb->u.c.center, spb->u.c.a0+spb->u.c.a1, + fabs(spb->u.c.radius)); + } else { + Translate(&xx->segs[0].u.p.pts[j].pt, spb->u.c.center, spb->u.c.a0, + fabs(spb->u.c.radius)); + } xx->segs[0].u.p.pts[j].pt_type = wPolyLineStraight; last = xx->segs[0].u.p.pts[j].pt; @@ -371,10 +399,11 @@ EXPORT track_p MakePolyLineFromSegs( } if (sp->type == SEG_CRVLIN || sp->type == SEG_CRVTRK) { coOrd this; - if (sp->u.c.radius>0) + if (sp->u.c.radius>0) { Translate(&this, sp->u.c.center, sp->u.c.a0, fabs(sp->u.c.radius)); - else + } else { Translate(&this, sp->u.c.center, sp->u.c.a0+sp->u.c.a1, fabs(sp->u.c.radius)); + } if (first || !IsClose(FindDistance(this, last))) { xx->segs[0].u.p.pts[j].pt= this; xx->segs[0].u.p.pts[j].pt_type = wPolyLineStraight; @@ -382,18 +411,24 @@ EXPORT track_p MakePolyLineFromSegs( } int slices = SliceCuts(sp->u.c.a1,sp->u.c.radius); - for (int k=1; k<slices;k++) { - if (sp->u.c.radius>0) - Translate(&xx->segs[0].u.p.pts[j].pt, sp->u.c.center, sp->u.c.a0+(k*(sp->u.c.a1/(slices))), fabs(sp->u.c.radius)); - else - Translate(&xx->segs[0].u.p.pts[j].pt, sp->u.c.center, sp->u.c.a0+((slices-k)*(sp->u.c.a1/(slices))), fabs(sp->u.c.radius)); + for (int k=1; k<slices; k++) { + if (sp->u.c.radius>0) { + Translate(&xx->segs[0].u.p.pts[j].pt, sp->u.c.center, + sp->u.c.a0+(k*(sp->u.c.a1/(slices))), fabs(sp->u.c.radius)); + } else { + Translate(&xx->segs[0].u.p.pts[j].pt, sp->u.c.center, + sp->u.c.a0+((slices-k)*(sp->u.c.a1/(slices))), fabs(sp->u.c.radius)); + } xx->segs[0].u.p.pts[j].pt_type = wPolyLineSmooth; j++; } - if (sp->u.c.radius>0) - Translate(&xx->segs[0].u.p.pts[j].pt, sp->u.c.center, sp->u.c.a0+sp->u.c.a1, fabs(sp->u.c.radius)); - else - Translate(&xx->segs[0].u.p.pts[j].pt, sp->u.c.center, sp->u.c.a0, fabs(sp->u.c.radius)); + if (sp->u.c.radius>0) { + Translate(&xx->segs[0].u.p.pts[j].pt, sp->u.c.center, sp->u.c.a0+sp->u.c.a1, + fabs(sp->u.c.radius)); + } else { + Translate(&xx->segs[0].u.p.pts[j].pt, sp->u.c.center, sp->u.c.a0, + fabs(sp->u.c.radius)); + } xx->segs[0].u.p.pts[j].pt_type = wPolyLineStraight; last = xx->segs[0].u.p.pts[j].pt; @@ -405,17 +440,18 @@ EXPORT track_p MakePolyLineFromSegs( xx->segs[0].u.p.pts[j] = sp->u.p.pts[0]; j++; } - memcpy(&xx->segs[0].u.p.pts[j],&sp->u.p.pts[1], (sp->u.p.cnt-1) * sizeof (pts_t)); + memcpy(&xx->segs[0].u.p.pts[j],&sp->u.p.pts[1], + (sp->u.p.cnt-1) * sizeof (pts_t)); last = xx->segs[0].u.p.pts[sp->u.p.cnt-1].pt; j +=sp->u.p.cnt-1; first = FALSE; } - ASSERT(j<=cnt); - + CHECK(j<=cnt); } xx->segs[0].u.p.cnt = j; - if (IsClose(FindDistance(xx->segs[0].u.p.pts[0].pt,xx->segs[0].u.p.pts[xx->segs[0].u.p.cnt-1].pt))) { + if (IsClose(FindDistance(xx->segs[0].u.p.pts[0].pt, + xx->segs[0].u.p.pts[xx->segs[0].u.p.cnt-1].pt))) { xx->segs[0].u.p.polyType = FREEFORM; xx->segs[0].u.p.cnt = xx->segs[0].u.p.cnt-1; } @@ -428,36 +464,38 @@ EXPORT track_p MakePolyLineFromSegs( static dynArr_t anchors_da; #define anchors(N) DYNARR_N(trkSeg_t,anchors_da,N) -void static CreateOriginAnchor(coOrd origin, wBool_t trans_selected) { - double d = tempD.scale*0.15; - DYNARR_APPEND(trkSeg_t,anchors_da,2); - int i = anchors_da.cnt-1; - coOrd p0,p1; - Translate(&p0,origin,0,d*4); - Translate(&p1,origin,0,-d*4); - anchors(i).type = SEG_STRLIN; - anchors(i).u.l.pos[0] = p0; - anchors(i).u.l.pos[1] = p1; - anchors(i).color = wDrawColorBlue; - anchors(i).width = 0; - DYNARR_APPEND(trkSeg_t,anchors_da,1); - Translate(&p0,origin,90,d*4); - Translate(&p1,origin,90,-d*4); - i = anchors_da.cnt-1; - anchors(i).type = SEG_STRLIN; - anchors(i).u.l.pos[0] = p0; - anchors(i).u.l.pos[1] = p1; - anchors(i).color = wDrawColorBlue; - anchors(i).width = 0; +void static CreateOriginAnchor(coOrd origin, wBool_t trans_selected) +{ + double d = tempD.scale*0.15; + DYNARR_APPEND(trkSeg_t,anchors_da,2); + int i = anchors_da.cnt-1; + coOrd p0,p1; + Translate(&p0,origin,0,d*4); + Translate(&p1,origin,0,-d*4); + anchors(i).type = SEG_STRLIN; + anchors(i).u.l.pos[0] = p0; + anchors(i).u.l.pos[1] = p1; + anchors(i).color = wDrawColorBlue; + anchors(i).lineWidth = 0; + DYNARR_APPEND(trkSeg_t,anchors_da,1); + Translate(&p0,origin,90,d*4); + Translate(&p1,origin,90,-d*4); + i = anchors_da.cnt-1; + anchors(i).type = SEG_STRLIN; + anchors(i).u.l.pos[0] = p0; + anchors(i).u.l.pos[1] = p1; + anchors(i).color = wDrawColorBlue; + anchors(i).lineWidth = 0; } -EXPORT void DrawOriginAnchor(track_p trk) { - if (!trk || GetTrkType(trk) != T_DRAW) return; +EXPORT void DrawOriginAnchor(track_p trk) +{ + if (!trk || GetTrkType(trk) != T_DRAW) { return; } struct extraDataDraw_t * xx = GET_EXTRA_DATA(trk, T_DRAW, extraDataDraw_t); if ((xx->orig.x != 0.0) || (xx->orig.y !=0.0) ) { DYNARR_RESET(trkSeg_t,anchors_da); CreateOriginAnchor(xx->orig,FALSE); - DrawSegs(&tempD, zero, 0.0, anchors_da.ptr, anchors_da.cnt, trackGauge, wDrawColorBlue); + DrawSegsDA(&tempD, NULL, zero, 0.0, &anchors_da, trackGauge, wDrawColorBlue, 0); } } @@ -466,80 +504,83 @@ EXPORT void DrawOriginAnchor(track_p trk) { static DIST_T DistanceDraw( track_p t, coOrd * p ) { struct extraDataDraw_t * xx = GET_EXTRA_DATA(t, T_DRAW, extraDataDraw_t); - if ( ignoredTableEdge == t && xx->segs[0].type == SEG_TBLEDGE ) + if ( ignoredTableEdge == t && xx->segs[0].type == SEG_TBLEDGE ) { return DIST_INF; - if ( ignoredDraw == t ) + } + if ( ignoredDraw == t ) { return DIST_INF; + } return DistanceSegs( xx->orig, xx->angle, xx->segCnt, xx->segs, p, NULL ); } static struct { - coOrd endPt[4]; - coOrd origin; - coOrd oldOrigin; - coOrd oldE0; - coOrd oldE1; - FLOAT_T length; - FLOAT_T height; - FLOAT_T width; - coOrd center; - DIST_T radius; - ANGLE_T angle0; - ANGLE_T angle1; - ANGLE_T angle; - ANGLE_T rotate_angle; - ANGLE_T oldAngle; - long pointCount; - long lineWidth; - BOOL_T boxed; - BOOL_T filled; - BOOL_T open; - BOOL_T lock_origin; - wDrawColor color; - wIndex_t benchChoice; - wIndex_t benchOrient; - wIndex_t dimenSize; - descPivot_t pivot; - wIndex_t fontSizeInx; - char text[STR_HUGE_SIZE]; - unsigned int layer; - wIndex_t lineType; - } drawData; + coOrd endPt[4]; + coOrd origin; + coOrd oldOrigin; + coOrd oldE0; + coOrd oldE1; + FLOAT_T length; + FLOAT_T height; + FLOAT_T width; + coOrd center; + DIST_T radius; + ANGLE_T angle0; + ANGLE_T angle1; + ANGLE_T angle; + ANGLE_T rotate_angle; + ANGLE_T oldAngle; + long pointCount; + LWIDTH_T lineWidth; + BOOL_T boxed; + BOOL_T filled; + BOOL_T open; + BOOL_T lock_origin; + wDrawColor color; + wIndex_t benchChoice; + wIndex_t benchOrient; + wIndex_t dimenSize; + descPivot_t pivot; + wIndex_t fontSizeInx; + char text[STR_HUGE_SIZE]; + unsigned int layer; + wIndex_t lineType; +} drawData; typedef enum { E0, E1, PP, CE, AL, LA, A1, A2, RD, LN, HT, WT, PV, VC, LW, LT, CO, FL, OP, BX, BE, OR, DS, TP, TA, TS, TX, LK, OI, RA, LY } drawDesc_e; static descData_t drawDesc[] = { -/*E0*/ { DESC_POS, N_("End Pt 1: X,Y"), &drawData.endPt[0] }, -/*E1*/ { DESC_POS, N_("End Pt 2: X,Y"), &drawData.endPt[1] }, -/*PP*/ { DESC_POS, N_("First Point: X,Y"), &drawData.endPt[0] }, -/*CE*/ { DESC_POS, N_("Center: X,Y"), &drawData.center }, -/*AL*/ { DESC_FLOAT, N_("Angular Length"), &drawData.angle }, -/*LA*/ { DESC_FLOAT, N_("Line Angle"), &drawData.angle }, -/*A1*/ { DESC_ANGLE, N_("CCW Angle"), &drawData.angle0 }, -/*A2*/ { DESC_ANGLE, N_("CW Angle"), &drawData.angle1 }, -/*RD*/ { DESC_DIM, N_("Radius"), &drawData.radius }, -/*LN*/ { DESC_DIM, N_("Length"), &drawData.length }, -/*HT*/ { DESC_DIM, N_("Height"), &drawData.height }, -/*WT*/ { DESC_DIM, N_("Width"), &drawData.width }, -/*PV*/ { DESC_PIVOT, N_("Pivot"), &drawData.pivot }, -/*VC*/ { DESC_LONG, N_("Point Count"), &drawData.pointCount }, -/*LW*/ { DESC_LONG, N_("Line Width"), &drawData.lineWidth }, -/*LT*/ { DESC_LIST, N_("Line Type"), &drawData.lineType }, -/*CO*/ { DESC_COLOR, N_("Color"), &drawData.color }, -/*FL*/ { DESC_BOXED, N_("Filled"), &drawData.filled }, -/*OP*/ { DESC_BOXED, N_("Open End"), &drawData.open }, -/*BX*/ { DESC_BOXED, N_("Boxed"), &drawData.boxed }, -/*BE*/ { DESC_LIST, N_("Lumber"), &drawData.benchChoice }, -/*OR*/ { DESC_LIST, N_("Orientation"), &drawData.benchOrient }, -/*DS*/ { DESC_LIST, N_("Size"), &drawData.dimenSize }, -/*TP*/ { DESC_POS, N_("Text Origin: X,Y"), &drawData.endPt[0] }, -/*TA*/ { DESC_FLOAT, N_("Text Angle"), &drawData.angle }, -/*TS*/ { DESC_EDITABLELIST, N_("Font Size"), &drawData.fontSizeInx }, -/*TX*/ { DESC_TEXT, N_("Text"), &drawData.text }, -/*LK*/ { DESC_BOXED, N_("Lock To Origin"), &drawData.lock_origin}, -/*OI*/ { DESC_POS, N_("Rot Origin: X,Y"), &drawData.origin }, -/*RA*/ { DESC_FLOAT, N_("Rotate By"), &drawData.rotate_angle }, -/*LY*/ { DESC_LAYER, N_("Layer"), &drawData.layer }, - { DESC_NULL } }; + /*E0*/ { DESC_POS, N_("End Pt 1: X,Y"), &drawData.endPt[0] }, + /*E1*/ { DESC_POS, N_("End Pt 2: X,Y"), &drawData.endPt[1] }, + /*PP*/ { DESC_POS, N_("First Point: X,Y"), &drawData.endPt[0] }, + /*CE*/ { DESC_POS, N_("Center: X,Y"), &drawData.center }, + /*AL*/ { DESC_FLOAT, N_("Angular Length"), &drawData.angle }, + /*LA*/ { DESC_FLOAT, N_("Line Angle"), &drawData.angle }, + /*A1*/ { DESC_ANGLE, N_("CCW Angle"), &drawData.angle0 }, + /*A2*/ { DESC_ANGLE, N_("CW Angle"), &drawData.angle1 }, + /*RD*/ { DESC_DIM, N_("Radius"), &drawData.radius }, + /*LN*/ { DESC_DIM, N_("Length"), &drawData.length }, + /*HT*/ { DESC_DIM, N_("Height"), &drawData.height }, + /*WT*/ { DESC_DIM, N_("Width"), &drawData.width }, + /*PV*/ { DESC_PIVOT, N_("Pivot"), &drawData.pivot }, + /*VC*/ { DESC_LONG, N_("Point Count"), &drawData.pointCount }, + /*LW*/ { DESC_FLOAT, N_("Line Width"), &drawData.lineWidth }, + /*LT*/ { DESC_LIST, N_("Line Type"), &drawData.lineType }, + /*CO*/ { DESC_COLOR, N_("Color"), &drawData.color }, + /*FL*/ { DESC_BOXED, N_("Filled"), &drawData.filled }, + /*OP*/ { DESC_BOXED, N_("Open End"), &drawData.open }, + /*BX*/ { DESC_BOXED, N_("Boxed"), &drawData.boxed }, + /*BE*/ { DESC_LIST, N_("Lumber"), &drawData.benchChoice }, + /*OR*/ { DESC_LIST, N_("Orientation"), &drawData.benchOrient }, + /*DS*/ { DESC_LIST, N_("Size"), &drawData.dimenSize }, + /*TP*/ { DESC_POS, N_("Text Origin: X,Y"), &drawData.endPt[0] }, + /*TA*/ { DESC_FLOAT, N_("Text Angle"), &drawData.angle }, + /*TS*/ { DESC_EDITABLELIST, N_("Font Size"), &drawData.fontSizeInx }, + /*TX*/ { DESC_TEXT, N_("Text"), &drawData.text }, + /*LK*/ { DESC_BOXED, N_("Lock To Origin"), &drawData.lock_origin}, + /*OI*/ { DESC_POS, N_("Rot Origin: X,Y"), &drawData.origin }, + /*RA*/ { DESC_FLOAT, N_("Rotate By"), &drawData.rotate_angle }, + /*LY*/ { DESC_LAYER, N_("Layer"), &drawData.layer }, + { DESC_NULL } +}; static int drawSegInx; #define UNREORIGIN( Q, P, A, O ) { \ @@ -577,22 +618,20 @@ static void UpdateDraw( track_p trk, int inx, descData_p descUpd, BOOL_T final ) coOrd mid; long fontSize; - if ( drawSegInx==-1 ) + if ( drawSegInx==-1 ) { return; + } segPtr = &xx->segs[drawSegInx]; if ( inx == -1 ) { - if (segPtr->type != SEG_TEXT) return; - else inx = TX; //Always look at TextField for SEG_TEXT on "Done" + if (segPtr->type != SEG_TEXT) { return; } + else { inx = TX; } //Always look at TextField for SEG_TEXT on "Done" } UndrawNewTrack( trk ); coOrd pt; coOrd off; switch ( inx ) { case LW: - if (drawData.lineWidth<0) - segPtr->width = drawData.lineWidth; - else - segPtr->width = drawData.lineWidth/75.0; //Replace with absolute pixel + segPtr->lineWidth = drawData.lineWidth; break; case CO: segPtr->color = drawData.color; @@ -604,24 +643,24 @@ static void UpdateDraw( track_p trk, int inx, descData_p descUpd, BOOL_T final ) off.x = drawData.endPt[0].x - drawData.oldE0.x; off.y = drawData.endPt[0].y - drawData.oldE0.y; switch(segPtr->type) { //E0 does not alter length - translates - case SEG_STRLIN: - case SEG_DIMLIN: - case SEG_BENCH: - case SEG_TBLEDGE: - UNREORIGIN( segPtr->u.l.pos[0], drawData.endPt[0], 0.0, xx->orig ); - drawData.endPt[1].x = off.x+drawData.endPt[1].x; - drawData.endPt[1].y = off.y+drawData.endPt[1].y; - UNREORIGIN( segPtr->u.l.pos[1], drawData.endPt[1], 0.0, xx->orig ); - drawDesc[E1].mode |= DESC_CHANGE; - break; - case SEG_CRVLIN: - case SEG_FILCRCL: - UNREORIGIN( segPtr->u.c.center, drawData.endPt[0], 0.0, xx->orig ); - break; - case SEG_POLY: - case SEG_FILPOLY: - break; //Note not used by POLYGONS - default:; + case SEG_STRLIN: + case SEG_DIMLIN: + case SEG_BENCH: + case SEG_TBLEDGE: + UNREORIGIN( segPtr->u.l.pos[0], drawData.endPt[0], 0.0, xx->orig ); + drawData.endPt[1].x = off.x+drawData.endPt[1].x; + drawData.endPt[1].y = off.y+drawData.endPt[1].y; + UNREORIGIN( segPtr->u.l.pos[1], drawData.endPt[1], 0.0, xx->orig ); + drawDesc[E1].mode |= DESC_CHANGE; + break; + case SEG_CRVLIN: + case SEG_FILCRCL: + UNREORIGIN( segPtr->u.c.center, drawData.endPt[0], 0.0, xx->orig ); + break; + case SEG_POLY: + case SEG_FILPOLY: + break; //Note not used by POLYGONS + default:; } } else { UNREORIGIN( segPtr->u.l.pos[1], drawData.endPt[1], 0.0, xx->orig ); @@ -635,54 +674,54 @@ static void UpdateDraw( track_p trk, int inx, descData_p descUpd, BOOL_T final ) xx->orig = drawData.origin; if (!drawData.lock_origin) { //Move the points so that the object is not moved switch(segPtr->type) { - case SEG_POLY: - case SEG_FILPOLY: - for (int i=0;i<segPtr->u.p.cnt;i++) { - UNREORIGIN( segPtr->u.p.pts[i].pt, segPtr->u.p.pts[i].pt, 0.0, off ); - } + case SEG_POLY: + case SEG_FILPOLY: + for (int i=0; i<segPtr->u.p.cnt; i++) { + UNREORIGIN( segPtr->u.p.pts[i].pt, segPtr->u.p.pts[i].pt, 0.0, off ); + } break; - case SEG_STRLIN: - case SEG_DIMLIN: - case SEG_BENCH: - case SEG_TBLEDGE: - for (int i=0;i<2;i++) { - UNREORIGIN( segPtr->u.l.pos[i], segPtr->u.l.pos[i], 0.0, off ); - } - break; - case SEG_CRVLIN: - case SEG_FILCRCL: - UNREORIGIN( segPtr->u.c.center, segPtr->u.c.center, 0.0, off ); - break; - case SEG_TEXT: - UNREORIGIN( segPtr->u.t.pos, segPtr->u.t.pos, 0.0, off ); - default:; + case SEG_STRLIN: + case SEG_DIMLIN: + case SEG_BENCH: + case SEG_TBLEDGE: + for (int i=0; i<2; i++) { + UNREORIGIN( segPtr->u.l.pos[i], segPtr->u.l.pos[i], 0.0, off ); + } + break; + case SEG_CRVLIN: + case SEG_FILCRCL: + UNREORIGIN( segPtr->u.c.center, segPtr->u.c.center, 0.0, off ); + break; + case SEG_TEXT: + UNREORIGIN( segPtr->u.t.pos, segPtr->u.t.pos, 0.0, off ); + default:; } } else { switch(segPtr->type) { - case SEG_STRLIN: - case SEG_DIMLIN: - case SEG_BENCH: - case SEG_TBLEDGE: - REORIGIN( drawData.endPt[0], segPtr->u.l.pos[0], 0.0, xx->orig ); - REORIGIN( drawData.endPt[1], segPtr->u.l.pos[1], 0.0, xx->orig ); - drawDesc[E0].mode |= DESC_CHANGE; - drawDesc[E1].mode |= DESC_CHANGE; - break; - case SEG_CRVLIN: - case SEG_FILCRCL: - REORIGIN( drawData.center, segPtr->u.c.center, 0.0, xx->orig ); - drawDesc[CE].mode |= DESC_CHANGE; - break; - case SEG_TEXT: - REORIGIN( drawData.endPt[0], segPtr->u.t.pos, 0.0, xx->orig ); - drawDesc[TP].mode |= DESC_CHANGE; - break; - case SEG_POLY: - case SEG_FILPOLY: - REORIGIN(drawData.endPt[0], segPtr->u.p.pts[0].pt, 0.0, xx->orig); - drawDesc[PP].mode |= DESC_CHANGE; - break; - default:; + case SEG_STRLIN: + case SEG_DIMLIN: + case SEG_BENCH: + case SEG_TBLEDGE: + REORIGIN( drawData.endPt[0], segPtr->u.l.pos[0], 0.0, xx->orig ); + REORIGIN( drawData.endPt[1], segPtr->u.l.pos[1], 0.0, xx->orig ); + drawDesc[E0].mode |= DESC_CHANGE; + drawDesc[E1].mode |= DESC_CHANGE; + break; + case SEG_CRVLIN: + case SEG_FILCRCL: + REORIGIN( drawData.center, segPtr->u.c.center, 0.0, xx->orig ); + drawDesc[CE].mode |= DESC_CHANGE; + break; + case SEG_TEXT: + REORIGIN( drawData.endPt[0], segPtr->u.t.pos, 0.0, xx->orig ); + drawDesc[TP].mode |= DESC_CHANGE; + break; + case SEG_POLY: + case SEG_FILPOLY: + REORIGIN(drawData.endPt[0], segPtr->u.p.pts[0].pt, 0.0, xx->orig); + drawDesc[PP].mode |= DESC_CHANGE; + break; + default:; } } break; @@ -713,17 +752,18 @@ static void UpdateDraw( track_p trk, int inx, descData_p descUpd, BOOL_T final ) switch(segPtr->type) { case SEG_POLY: case SEG_FILPOLY: - for (int i=0;i<segPtr->u.p.cnt;i++) { + for (int i=0; i<segPtr->u.p.cnt; i++) { UNREORIGIN(pt, segPtr->u.p.pts[i].pt, angle, drawData.origin); REORIGIN(segPtr->u.p.pts[i].pt, pt, 0.0, drawData.origin); - if (i == 0) drawData.endPt[0] = pt; + if (i == 0) { drawData.endPt[0] = pt; } } drawDesc[PP].mode |= DESC_CHANGE; break; case SEG_CRVLIN:; coOrd end0, end1; Translate(&end0,segPtr->u.c.center,segPtr->u.c.a0,segPtr->u.c.radius); - Translate(&end1,segPtr->u.c.center,segPtr->u.c.a0+segPtr->u.c.a1,segPtr->u.c.radius); + Translate(&end1,segPtr->u.c.center,segPtr->u.c.a0+segPtr->u.c.a1, + segPtr->u.c.radius); REORIGIN(drawData.center, segPtr->u.c.center, angle, drawData.origin); REORIGIN(end0, end0, angle, drawData.origin); REORIGIN(end1, end1, angle, drawData.origin); @@ -732,9 +772,10 @@ static void UpdateDraw( track_p trk, int inx, descData_p descUpd, BOOL_T final ) UNREORIGIN(segPtr->u.c.center,drawData.center,0.0,drawData.origin); drawDesc[CE].mode |= DESC_CHANGE; drawDesc[A1].mode |= DESC_CHANGE; - /*no break*/ + /*no break*/ case SEG_FILCRCL: - REORIGIN(drawData.center, segPtr->u.c.center, angle, drawData.origin); //Remove angle + REORIGIN(drawData.center, segPtr->u.c.center, angle, + drawData.origin); //Remove angle UNREORIGIN(segPtr->u.c.center, drawData.center, 0.0, drawData.origin); drawDesc[CE].mode |= DESC_CHANGE; break; @@ -742,7 +783,7 @@ static void UpdateDraw( track_p trk, int inx, descData_p descUpd, BOOL_T final ) case SEG_DIMLIN: case SEG_BENCH: case SEG_TBLEDGE: - for (int i=0;i<2;i++) { + for (int i=0; i<2; i++) { REORIGIN( drawData.endPt[i], segPtr->u.l.pos[i], angle, drawData.origin ); UNREORIGIN( segPtr->u.l.pos[i], drawData.endPt[i], 0.0, drawData.origin ); } @@ -762,80 +803,83 @@ static void UpdateDraw( track_p trk, int inx, descData_p descUpd, BOOL_T final ) } } xx->angle = drawData.rotate_angle = 0.0; - if (!drawData.lock_origin) drawDesc[RA].mode = DESC_RO; + if (!drawData.lock_origin) { drawDesc[RA].mode = DESC_RO; } drawDesc[RA].mode |= DESC_CHANGE; break; case AL: //Uses Pivot Point case LA:; ANGLE_T angle = NormalizeAngle(drawData.angle); switch(segPtr->type) { - case SEG_POLY: - case SEG_FILPOLY: - break; //Doesn't Use - case SEG_CRVLIN: //Uses as swept angle - switch ( drawData.pivot ) { - case DESC_PIVOT_FIRST: - segPtr->u.c.a1 = drawData.angle; - drawData.angle1 = NormalizeAngle( drawData.angle0+segPtr->u.c.a1 ); - drawDesc[A2].mode |= DESC_CHANGE; - break; - case DESC_PIVOT_SECOND: - segPtr->u.c.a0 = NormalizeAngle( segPtr->u.c.a1+segPtr->u.c.a0-drawData.angle); - segPtr->u.c.a1 = drawData.angle; - drawData.angle0 = NormalizeAngle( segPtr->u.c.a0 ); - drawData.angle1 = NormalizeAngle( drawData.angle0+segPtr->u.c.a1 ); - drawDesc[A1].mode |= DESC_CHANGE; - drawDesc[A2].mode |= DESC_CHANGE; - break; - case DESC_PIVOT_MID: - segPtr->u.c.a0 = NormalizeAngle( segPtr->u.c.a0+segPtr->u.c.a1/2.0-drawData.angle/2.0); - segPtr->u.c.a1 = drawData.angle; - drawData.angle0 = NormalizeAngle( segPtr->u.c.a0 ); - drawData.angle1 = NormalizeAngle( drawData.angle0+segPtr->u.c.a1 ); - drawDesc[A1].mode |= DESC_CHANGE; - drawDesc[A2].mode |= DESC_CHANGE; - break; - default: - break; - } - drawData.length = 2*M_PI*segPtr->u.c.radius*segPtr->u.c.a1/360; - drawDesc[LN].mode = DESC_RO|DESC_CHANGE; + case SEG_POLY: + case SEG_FILPOLY: + break; //Doesn't Use + case SEG_CRVLIN: //Uses as swept angle + switch ( drawData.pivot ) { + case DESC_PIVOT_FIRST: + segPtr->u.c.a1 = drawData.angle; + drawData.angle1 = NormalizeAngle( drawData.angle0+segPtr->u.c.a1 ); + drawDesc[A2].mode |= DESC_CHANGE; break; - case SEG_FILCRCL: - break; //Doesn't Use - case SEG_STRLIN: - case SEG_DIMLIN: - case SEG_BENCH: - case SEG_TBLEDGE: - switch ( drawData.pivot ) { - case DESC_PIVOT_FIRST: - Translate(&drawData.endPt[1],drawData.endPt[0],angle,drawData.length); - UNREORIGIN(segPtr->u.l.pos[1], drawData.endPt[1], 0.0, xx->orig ); - drawDesc[E1].mode |= DESC_CHANGE; - break; - case DESC_PIVOT_MID:; - coOrd middle; - middle.x = (drawData.endPt[1].x+drawData.endPt[0].x)/2; - middle.y = (drawData.endPt[1].y+drawData.endPt[0].y)/2; - Translate(&drawData.endPt[0],middle,NormalizeAngle(angle+180),drawData.length/2); - Translate(&drawData.endPt[1],middle,angle,drawData.length/2); - UNREORIGIN(segPtr->u.l.pos[0], drawData.endPt[0], 0.0, xx->orig ); - UNREORIGIN(segPtr->u.l.pos[1], drawData.endPt[1], 0.0, xx->orig ); - drawDesc[E0].mode |= DESC_CHANGE; - drawDesc[E1].mode |= DESC_CHANGE; - break; - case DESC_PIVOT_SECOND: - Translate(&drawData.endPt[0],drawData.endPt[1],NormalizeAngle(angle+180),drawData.length); - UNREORIGIN(segPtr->u.l.pos[0], drawData.endPt[0], 0.0, xx->orig ); - drawDesc[E0].mode |= DESC_CHANGE; - break; - default: - break; - } + case DESC_PIVOT_SECOND: + segPtr->u.c.a0 = NormalizeAngle( segPtr->u.c.a1+segPtr->u.c.a0-drawData.angle); + segPtr->u.c.a1 = drawData.angle; + drawData.angle0 = NormalizeAngle( segPtr->u.c.a0 ); + drawData.angle1 = NormalizeAngle( drawData.angle0+segPtr->u.c.a1 ); + drawDesc[A1].mode |= DESC_CHANGE; + drawDesc[A2].mode |= DESC_CHANGE; break; - case SEG_TEXT: - break; //Doesnt Use - default:; + case DESC_PIVOT_MID: + segPtr->u.c.a0 = NormalizeAngle( segPtr->u.c.a0+segPtr->u.c.a1/2.0 + -drawData.angle/2.0); + segPtr->u.c.a1 = drawData.angle; + drawData.angle0 = NormalizeAngle( segPtr->u.c.a0 ); + drawData.angle1 = NormalizeAngle( drawData.angle0+segPtr->u.c.a1 ); + drawDesc[A1].mode |= DESC_CHANGE; + drawDesc[A2].mode |= DESC_CHANGE; + break; + default: + break; + } + drawData.length = 2*M_PI*segPtr->u.c.radius*segPtr->u.c.a1/360; + drawDesc[LN].mode = DESC_RO|DESC_CHANGE; + break; + case SEG_FILCRCL: + break; //Doesn't Use + case SEG_STRLIN: + case SEG_DIMLIN: + case SEG_BENCH: + case SEG_TBLEDGE: + switch ( drawData.pivot ) { + case DESC_PIVOT_FIRST: + Translate(&drawData.endPt[1],drawData.endPt[0],angle,drawData.length); + UNREORIGIN(segPtr->u.l.pos[1], drawData.endPt[1], 0.0, xx->orig ); + drawDesc[E1].mode |= DESC_CHANGE; + break; + case DESC_PIVOT_MID:; + coOrd middle; + middle.x = (drawData.endPt[1].x+drawData.endPt[0].x)/2; + middle.y = (drawData.endPt[1].y+drawData.endPt[0].y)/2; + Translate(&drawData.endPt[0],middle,NormalizeAngle(angle+180), + drawData.length/2); + Translate(&drawData.endPt[1],middle,angle,drawData.length/2); + UNREORIGIN(segPtr->u.l.pos[0], drawData.endPt[0], 0.0, xx->orig ); + UNREORIGIN(segPtr->u.l.pos[1], drawData.endPt[1], 0.0, xx->orig ); + drawDesc[E0].mode |= DESC_CHANGE; + drawDesc[E1].mode |= DESC_CHANGE; + break; + case DESC_PIVOT_SECOND: + Translate(&drawData.endPt[0],drawData.endPt[1],NormalizeAngle(angle+180), + drawData.length); + UNREORIGIN(segPtr->u.l.pos[0], drawData.endPt[0], 0.0, xx->orig ); + drawDesc[E0].mode |= DESC_CHANGE; + break; + default: + break; + } + break; + case SEG_TEXT: + break; //Doesnt Use + default:; } break; case LN: @@ -848,12 +892,14 @@ static void UpdateDraw( track_p trk, int inx, descData_p descUpd, BOOL_T final ) if ( segPtr->type != SEG_CRVLIN ) { switch ( drawData.pivot ) { case DESC_PIVOT_FIRST: - Translate( &drawData.endPt[1], drawData.endPt[0], drawData.angle, drawData.length ); + Translate( &drawData.endPt[1], drawData.endPt[0], drawData.angle, + drawData.length ); UNREORIGIN( segPtr->u.l.pos[1], drawData.endPt[1], 0.0, xx->orig ); drawDesc[E1].mode |= DESC_CHANGE; break; case DESC_PIVOT_SECOND: - Translate( &drawData.endPt[0], drawData.endPt[1], drawData.angle+180.0, drawData.length ); + Translate( &drawData.endPt[0], drawData.endPt[1], drawData.angle+180.0, + drawData.length ); UNREORIGIN( segPtr->u.l.pos[0], drawData.endPt[0], 0.0, xx->orig ); drawDesc[E0].mode |= DESC_CHANGE; break; @@ -877,15 +923,19 @@ static void UpdateDraw( track_p trk, int inx, descData_p descUpd, BOOL_T final ) break; case RD: if ( drawData.pivot == DESC_PIVOT_FIRST ) { - Translate( &segPtr->u.c.center, segPtr->u.c.center, segPtr->u.c.a0, segPtr->u.c.radius-drawData.radius ); + Translate( &segPtr->u.c.center, segPtr->u.c.center, segPtr->u.c.a0, + segPtr->u.c.radius-drawData.radius ); } else if ( drawData.pivot == DESC_PIVOT_SECOND ) { - Translate( &segPtr->u.c.center, segPtr->u.c.center, segPtr->u.c.a0+segPtr->u.c.a1, segPtr->u.c.radius-drawData.radius ); + Translate( &segPtr->u.c.center, segPtr->u.c.center, + segPtr->u.c.a0+segPtr->u.c.a1, segPtr->u.c.radius-drawData.radius ); } else { - Translate( &segPtr->u.c.center, segPtr->u.c.center, (segPtr->u.c.a0+segPtr->u.c.a1)/2.0, segPtr->u.c.radius-drawData.radius ); + Translate( &segPtr->u.c.center, segPtr->u.c.center, + (segPtr->u.c.a0+segPtr->u.c.a1)/2.0, segPtr->u.c.radius-drawData.radius ); } drawDesc[CE].mode |= DESC_CHANGE; segPtr->u.c.radius = drawData.radius; - drawData.length = 2*M_PI*segPtr->u.c.radius*(segPtr->type==SEG_CRVLIN?segPtr->u.c.a1/360:1.0); + drawData.length = 2*M_PI*segPtr->u.c.radius*(segPtr->type==SEG_CRVLIN + ?segPtr->u.c.a1/360:1.0); drawDesc[LN].mode = DESC_RO|DESC_CHANGE; break; case A1: //Angle of first point of curve @@ -899,15 +949,19 @@ static void UpdateDraw( track_p trk, int inx, descData_p descUpd, BOOL_T final ) drawDesc[A1].mode |= DESC_CHANGE; break; case BE: - BenchUpdateOrientationList( VP2L( wListGetItemContext((wList_p)drawDesc[BE].control0, drawData.benchChoice)), (wList_p)drawDesc[OR].control0 ); - if ( drawData.benchOrient < wListGetCount( (wList_p)drawDesc[OR].control0 ) ) + BenchUpdateOrientationList( VP2L( wListGetItemContext((wList_p) + drawDesc[BE].control0, drawData.benchChoice)), (wList_p)drawDesc[OR].control0 ); + if ( drawData.benchOrient < wListGetCount( (wList_p)drawDesc[OR].control0 ) ) { wListSetIndex( (wList_p)drawDesc[OR].control0, drawData.benchOrient ); - else + } else { drawData.benchOrient = 0; - segPtr->u.l.option = GetBenchData( VP2L(wListGetItemContext((wList_p)drawDesc[BE].control0, drawData.benchChoice)), drawData.benchOrient ); + } + segPtr->u.l.option = GetBenchData( VP2L(wListGetItemContext(( + wList_p)drawDesc[BE].control0, drawData.benchChoice)), drawData.benchOrient ); break; case OR: - segPtr->u.l.option = GetBenchData( VP2L(wListGetItemContext((wList_p)drawDesc[BE].control0, drawData.benchChoice)), drawData.benchOrient ); + segPtr->u.l.option = GetBenchData( VP2L(wListGetItemContext(( + wList_p)drawDesc[BE].control0, drawData.benchChoice)), drawData.benchOrient ); break; case DS: segPtr->u.l.option = drawData.dimenSize; @@ -918,7 +972,7 @@ static void UpdateDraw( track_p trk, int inx, descData_p descUpd, BOOL_T final ) case PP: off.x = drawData.endPt[0].x - drawData.oldE0.x; off.y = drawData.endPt[0].y - drawData.oldE0.y; - for (int i=0;i<segPtr->u.p.cnt;i++) { + for (int i=0; i<segPtr->u.p.cnt; i++) { REORIGIN( pt, segPtr->u.p.pts[i].pt, 0.0, xx->orig ); pt.x += off.x; pt.y += off.y; @@ -933,7 +987,8 @@ static void UpdateDraw( track_p trk, int inx, descData_p descUpd, BOOL_T final ) break; case TS: fontSize = (long)segPtr->u.t.fontSize; - UpdateFontSizeList( &fontSize, (wList_p)drawDesc[TS].control0, drawData.fontSizeInx ); + UpdateFontSizeList( &fontSize, (wList_p)drawDesc[TS].control0, + drawData.fontSizeInx ); segPtr->u.t.fontSize = fontSize; break; case FL: @@ -946,7 +1001,6 @@ static void UpdateDraw( track_p trk, int inx, descData_p descUpd, BOOL_T final ) if(drawData.filled) { if (segPtr->type == SEG_POLY) { segPtr->type = SEG_FILPOLY; - segPtr->u.p.polyType = FREEFORM; drawData.open = FALSE; drawDesc[OP].mode = DESC_RO|DESC_CHANGE; } @@ -958,7 +1012,6 @@ static void UpdateDraw( track_p trk, int inx, descData_p descUpd, BOOL_T final ) } else { if (segPtr->type == SEG_FILPOLY) { segPtr->type = SEG_POLY; - segPtr->u.p.polyType = FREEFORM; drawData.open = FALSE; drawDesc[OP].mode = DESC_CHANGE; } @@ -995,9 +1048,16 @@ static void UpdateDraw( track_p trk, int inx, descData_p descUpd, BOOL_T final ) segPtr->u.t.boxed = drawData.boxed; break; case TX: - if ( wTextGetModified((wText_p)drawDesc[TX].control0 )) { + if ( wTextGetModified((wText_p)drawDesc[TX].control0 ) || + inPlayback ) { int len = wTextGetSize((wText_p)drawDesc[TX].control0); - MyFree( segPtr->u.t.string ); + // TODO - minor memory leak, but this allows Undo on text object. See BUG-527 + // MyFree( segPtr->u.t.string ); + if ( !descUndoStarted ) { + UndoStart( _("Change Track"), "Change Track"); + descUndoStarted = TRUE; + } + UndoModify( trk ); if (len>STR_HUGE_SIZE-8) { //Truncate string to max len = STR_HUGE_SIZE-8; ErrorMessage( MSG_TEXT_TOO_LONG ); @@ -1024,7 +1084,7 @@ static void UpdateDraw( track_p trk, int inx, descData_p descUpd, BOOL_T final ) xx->lineType = drawData.lineType; break; default: - AbortProg( "bad op" ); + CHECKMSG( FALSE, ( "bad op: %d", inx ) ); } drawData.oldE0 = drawData.endPt[0]; drawData.oldE1 = drawData.endPt[1]; @@ -1035,7 +1095,6 @@ static void UpdateDraw( track_p trk, int inx, descData_p descUpd, BOOL_T final ) TempRedraw(); // UpdateDraw } -extern BOOL_T inDescribeCmd; static void DescribeDraw( track_p trk, char * str, CSIZE_T len ) { @@ -1044,12 +1103,13 @@ static void DescribeDraw( track_p trk, char * str, CSIZE_T len ) trkSeg_p segPtr; int inx; char * title = NULL; - char * polyType = NULL; +// char * polyType = NULL; DistanceSegs( xx->orig, xx->angle, xx->segCnt, xx->segs, &pos, &drawSegInx ); - if ( drawSegInx==-1 ) + if ( drawSegInx==-1 ) { return; + } segPtr = &xx->segs[drawSegInx]; for ( inx=0; inx<COUNT( drawDesc ); inx++ ) { drawDesc[inx].mode = DESC_IGNORE; @@ -1058,20 +1118,17 @@ static void DescribeDraw( track_p trk, char * str, CSIZE_T len ) drawData.color = segPtr->color; drawData.layer = GetTrkLayer(trk); drawDesc[CO].mode = 0; - if (drawData.lineWidth<0) - drawData.lineWidth = (long)segPtr->width; - else - drawData.lineWidth = (long)floor(segPtr->width*75.0+0.5); + drawData.lineWidth = segPtr->lineWidth; drawDesc[LW].mode = 0; drawDesc[LY].mode = DESC_NOREDRAW; drawDesc[BE].mode = - drawDesc[OR].mode = - drawDesc[LT].mode = - drawDesc[DS].mode = DESC_IGNORE; + drawDesc[OR].mode = + drawDesc[LT].mode = + drawDesc[DS].mode = DESC_IGNORE; drawData.pivot = DESC_PIVOT_MID; - if ((xx->orig.x == 0.0) && (xx->orig.y == 0.0)) drawData.lock_origin = FALSE; - else drawData.lock_origin = TRUE; + if ((xx->orig.x == 0.0) && (xx->orig.y == 0.0)) { drawData.lock_origin = FALSE; } + else { drawData.lock_origin = TRUE; } drawData.rotate_angle = 0.0; @@ -1092,14 +1149,14 @@ static void DescribeDraw( track_p trk, char * str, CSIZE_T len ) UNREORIGIN(segPtr->u.l.pos[1], drawData.endPt[1], 0.0, xx->orig); xx->angle = 0.0; drawDesc[LN].mode = - drawDesc[LA].mode = - drawDesc[PV].mode = 0; + drawDesc[LA].mode = + drawDesc[PV].mode = 0; drawDesc[E0].mode = - drawDesc[OI].mode = 0; + drawDesc[OI].mode = 0; drawDesc[E1].mode = 0; drawDesc[RA].mode = 0; - if (!drawData.lock_origin) drawDesc[RA].mode = DESC_RO; - else drawDesc[RA].mode = 0; + if (!drawData.lock_origin) { drawDesc[RA].mode = DESC_RO; } + else { drawDesc[RA].mode = 0; } switch (segPtr->type) { case SEG_STRLIN: title = _("Straight Line"); @@ -1109,29 +1166,29 @@ static void DescribeDraw( track_p trk, char * str, CSIZE_T len ) case SEG_DIMLIN: title = _("Dimension Line"); drawDesc[CO].mode = - drawDesc[LW].mode = - drawDesc[LK].mode = - drawDesc[OI].mode = - drawDesc[RA].mode = DESC_IGNORE; + drawDesc[LW].mode = + drawDesc[LK].mode = + drawDesc[OI].mode = + drawDesc[RA].mode = DESC_IGNORE; drawData.dimenSize = (wIndex_t)segPtr->u.l.option; drawDesc[DS].mode = 0; break; case SEG_BENCH: title = _("Lumber"); drawDesc[LK].mode = - drawDesc[OI].mode = - drawDesc[RA].mode = - drawDesc[LW].mode = DESC_IGNORE; + drawDesc[OI].mode = + drawDesc[RA].mode = + drawDesc[LW].mode = DESC_IGNORE; drawDesc[BE].mode = - drawDesc[OR].mode = 0; + drawDesc[OR].mode = 0; drawData.benchChoice = GetBenchListIndex( segPtr->u.l.option ); drawData.benchOrient = (wIndex_t)(segPtr->u.l.option&0xFF); break; case SEG_TBLEDGE: title = _("Table Edge"); drawDesc[LK].mode = - drawDesc[OI].mode = - drawDesc[RA].mode = DESC_IGNORE; + drawDesc[OI].mode = + drawDesc[RA].mode = DESC_IGNORE; drawDesc[CO].mode = DESC_IGNORE; drawDesc[LW].mode = DESC_IGNORE; break; @@ -1141,14 +1198,14 @@ static void DescribeDraw( track_p trk, char * str, CSIZE_T len ) REORIGIN( drawData.center, segPtr->u.c.center, xx->angle, xx->orig ); //Remove input Angle (if any) UNREORIGIN(segPtr->u.c.center, drawData.center, 0.0, xx->orig); - xx->angle = 0.0; + xx->angle = 0.0; drawData.radius = fabs(segPtr->u.c.radius); drawData.origin = xx->orig; drawDesc[OI].mode = 0; drawDesc[CE].mode = - drawDesc[RD].mode = 0; - if (!drawData.lock_origin) drawDesc[RA].mode = DESC_RO; - else drawDesc[RA].mode = 0; + drawDesc[RD].mode = 0; + if (!drawData.lock_origin) { drawDesc[RA].mode = DESC_RO; } + else { drawDesc[RA].mode = 0; } drawDesc[LT].mode = 0; drawData.lineType = (wIndex_t)xx->lineType; if ( segPtr->u.c.a1 >= 360.0 ) { @@ -1164,8 +1221,8 @@ static void DescribeDraw( track_p trk, char * str, CSIZE_T len ) drawDesc[LN].mode = DESC_RO; drawData.length = 2*M_PI*segPtr->u.c.radius*segPtr->u.c.a1/360; drawDesc[AL].mode = - drawDesc[A1].mode = - drawDesc[A2].mode = 0; + drawDesc[A1].mode = + drawDesc[A2].mode = 0; drawDesc[PV].mode = 0; title = _("Curved Line"); } @@ -1174,18 +1231,18 @@ static void DescribeDraw( track_p trk, char * str, CSIZE_T len ) REORIGIN( drawData.center, segPtr->u.c.center, xx->angle, xx->orig ); //Remove input Angle (if any) UNREORIGIN(segPtr->u.c.center, drawData.center, 0.0, xx->orig); - xx->angle = 0.0; + xx->angle = 0.0; drawData.radius = fabs(segPtr->u.c.radius); drawData.origin = xx->orig; drawDesc[OI].mode = - drawDesc[FL].mode = 0; - if (!drawData.lock_origin) drawDesc[RA].mode = DESC_RO; - else drawDesc[RA].mode = 0; + drawDesc[FL].mode = 0; + if (!drawData.lock_origin) { drawDesc[RA].mode = DESC_RO; } + else { drawDesc[RA].mode = 0; } drawData.filled = TRUE; drawData.length = 0.0; drawDesc[LN].mode = DESC_RO; drawDesc[CE].mode = - drawDesc[RD].mode = 0; + drawDesc[RD].mode = 0; drawDesc[PV].mode = 0; drawDesc[OI].mode = 0; drawDesc[LW].mode = DESC_IGNORE; @@ -1194,10 +1251,10 @@ static void DescribeDraw( track_p trk, char * str, CSIZE_T len ) case SEG_POLY: case SEG_FILPOLY:; BOOL_T filled = FALSE; - if (segPtr->type == SEG_FILPOLY) filled = TRUE; + if (segPtr->type == SEG_FILPOLY) { filled = TRUE; } REORIGIN(drawData.endPt[0],segPtr->u.p.pts[0].pt, xx->angle, xx->orig); //Remove input Angle (if any) - for (int i=0;i<segPtr->u.p.cnt;i++) { + for (int i=0; i<segPtr->u.p.cnt; i++) { coOrd pt; REORIGIN(pt,segPtr->u.p.pts[i].pt, xx->angle, xx->orig); UNREORIGIN(segPtr->u.p.pts[i].pt, pt, 0.0, xx->orig); @@ -1209,8 +1266,8 @@ static void DescribeDraw( track_p trk, char * str, CSIZE_T len ) drawData.filled = filled; drawDesc[FL].mode = 0; drawData.angle = 0.0; - if (!drawData.lock_origin) drawDesc[RA].mode = DESC_RO; - else drawDesc[RA].mode = 0; + if (!drawData.lock_origin) { drawDesc[RA].mode = DESC_RO; } + else { drawDesc[RA].mode = 0; } drawData.origin = xx->orig; drawDesc[OI].mode = 0; drawData.open= FALSE; @@ -1218,29 +1275,29 @@ static void DescribeDraw( track_p trk, char * str, CSIZE_T len ) drawDesc[LT].mode = 0; drawData.lineType = (wIndex_t)xx->lineType; switch (segPtr->u.p.polyType) { - case RECTANGLE: - title = filled?_("Filled Rectangle"):_("Rectangle"); - drawDesc[OP].mode = DESC_IGNORE; - drawDesc[VC].mode = DESC_IGNORE; - drawData.width = FindDistance(segPtr->u.p.pts[0].pt, segPtr->u.p.pts[1].pt); - drawDesc[WT].mode = 0; - drawData.height = FindDistance(segPtr->u.p.pts[0].pt, segPtr->u.p.pts[3].pt); - drawDesc[HT].mode = 0; - for(int i=0;i<4;i++) { - REORIGIN( drawData.endPt[i], segPtr->u.p.pts[i].pt, xx->angle, xx->orig ); - } - drawDesc[E0].mode = DESC_IGNORE; - drawData.origin = xx->orig; - break; - case POLYLINE: - title = _("Polyline"); - drawData.open=TRUE; - drawData.filled= FALSE; - drawDesc[FL].mode = DESC_RO; - drawDesc[OP].mode = 0; - break; - default: - title = filled?_("Filled Polygon"):_("Polygon"); + case RECTANGLE: + title = filled?_("Filled Rectangle"):_("Rectangle"); + drawDesc[OP].mode = DESC_IGNORE; + drawDesc[VC].mode = DESC_IGNORE; + drawData.width = FindDistance(segPtr->u.p.pts[0].pt, segPtr->u.p.pts[1].pt); + drawDesc[WT].mode = 0; + drawData.height = FindDistance(segPtr->u.p.pts[0].pt, segPtr->u.p.pts[3].pt); + drawDesc[HT].mode = 0; + for(int i=0; i<4; i++) { + REORIGIN( drawData.endPt[i], segPtr->u.p.pts[i].pt, xx->angle, xx->orig ); + } + drawDesc[E0].mode = DESC_IGNORE; + drawData.origin = xx->orig; + break; + case POLYLINE: + title = _("Polyline"); + drawData.open=TRUE; + drawData.filled= FALSE; + drawDesc[FL].mode = DESC_RO; + drawDesc[OP].mode = 0; + break; + default: + title = filled?_("Filled Polygon"):_("Polygon"); } break; case SEG_TEXT: @@ -1253,16 +1310,16 @@ static void DescribeDraw( track_p trk, char * str, CSIZE_T len ) drawData.text[sizeof drawData.text-1] ='\0'; drawData.boxed = segPtr->u.t.boxed; drawDesc[TP].mode = - drawDesc[TS].mode = - drawDesc[TX].mode = - drawDesc[TA].mode = - drawDesc[LK].mode = - drawDesc[OI].mode = - drawDesc[BX].mode = 0; - if (!drawData.lock_origin) drawDesc[RA].mode = DESC_RO; - else drawDesc[RA].mode = 0; + drawDesc[TS].mode = + drawDesc[TX].mode = + drawDesc[TA].mode = + drawDesc[LK].mode = + drawDesc[OI].mode = + drawDesc[BX].mode = 0; + if (!drawData.lock_origin) { drawDesc[RA].mode = DESC_RO; } + else { drawDesc[RA].mode = 0; } drawDesc[E0].mode = DESC_IGNORE; - drawDesc[CO].mode = 0; /*Allow Text color setting*/ + drawDesc[CO].mode = 0; /*Allow Text color setting*/ drawDesc[LW].mode = DESC_IGNORE; title = _("Text"); break; @@ -1270,9 +1327,10 @@ static void DescribeDraw( track_p trk, char * str, CSIZE_T len ) ; } - snprintf( str, len, _("%s(%d) Layer=%d"), title, GetTrkIndex(trk), GetTrkLayer(trk)+1 ); + snprintf( str, len, _("%s(%d) Layer=%d"), title, GetTrkIndex(trk), + GetTrkLayer(trk)+1 ); - if (!inDescribeCmd) return; + if (!inDescribeCmd) { return; } drawData.oldE0 = drawData.endPt[0]; drawData.oldE1 = drawData.endPt[1]; @@ -1282,13 +1340,17 @@ static void DescribeDraw( track_p trk, char * str, CSIZE_T len ) DoDescribe( title, trk, drawDesc, UpdateDraw ); - if ( segPtr->type==SEG_BENCH && drawDesc[BE].control0!=NULL && drawDesc[OR].control0!=NULL) { - BenchLoadLists( (wList_p)drawDesc[BE].control0, (wList_p)drawDesc[OR].control0 ); + if ( segPtr->type==SEG_BENCH && drawDesc[BE].control0!=NULL + && drawDesc[OR].control0!=NULL) { + BenchLoadLists( (wList_p)drawDesc[BE].control0, + (wList_p)drawDesc[OR].control0 ); wListSetIndex( (wList_p)drawDesc[BE].control0, drawData.benchChoice ); - BenchUpdateOrientationList( VP2L(wListGetItemContext((wList_p)drawDesc[BE].control0, drawData.benchChoice)), (wList_p)drawDesc[OR].control0 ); + BenchUpdateOrientationList( VP2L(wListGetItemContext((wList_p) + drawDesc[BE].control0, drawData.benchChoice)), (wList_p)drawDesc[OR].control0 ); wListSetIndex( (wList_p)drawDesc[OR].control0, drawData.benchOrient ); } - if ( (segPtr->type==SEG_STRLIN || segPtr->type==SEG_CRVLIN || segPtr->type==SEG_POLY) && drawDesc[LT].control0!=NULL) { + if ( (segPtr->type==SEG_STRLIN || segPtr->type==SEG_CRVLIN + || segPtr->type==SEG_POLY) && drawDesc[LT].control0!=NULL) { wListClear( (wList_p)drawDesc[LT].control0 ); wListAddValue( (wList_p)drawDesc[LT].control0, _("Solid"), NULL, I2VP(0 )); wListAddValue( (wList_p)drawDesc[LT].control0, _("Dash"), NULL, I2VP(1 )); @@ -1319,12 +1381,12 @@ static void DrawDraw( track_p t, drawCmd_p d, wDrawColor color ) unsigned long NotSolid = ~(DC_NOTSOLIDLINE); d->options &= NotSolid; if (xx->lineType == DRAWLINESOLID) {} - else if (xx->lineType == DRAWLINEDASH) d->options |= DC_DASH; - else if (xx->lineType == DRAWLINEDOT) d->options |= DC_DOT; - else if (xx->lineType == DRAWLINEDASHDOT) d->options |= DC_DASHDOT; - else if (xx->lineType == DRAWLINEDASHDOTDOT) d->options |= DC_DASHDOTDOT; - else if (xx->lineType == DRAWLINECENTER) d->options |= DC_CENTER; - else if (xx->lineType == DRAWLINEPHANTOM) d->options |= DC_PHANTOM; + else if (xx->lineType == DRAWLINEDASH) { d->options |= DC_DASH; } + else if (xx->lineType == DRAWLINEDOT) { d->options |= DC_DOT; } + else if (xx->lineType == DRAWLINEDASHDOT) { d->options |= DC_DASHDOT; } + else if (xx->lineType == DRAWLINEDASHDOTDOT) { d->options |= DC_DASHDOTDOT; } + else if (xx->lineType == DRAWLINECENTER) { d->options |= DC_CENTER; } + else if (xx->lineType == DRAWLINEPHANTOM) { d->options |= DC_PHANTOM; } DrawSegs( d, xx->orig, xx->angle, xx->segs, xx->segCnt, 0.0, color ); d->options = d->options&~(DC_NOTSOLIDLINE); } @@ -1335,7 +1397,7 @@ static void DeleteDraw( track_p t ) /* Get rid of points if specified */ struct extraDataDraw_t * xx = GET_EXTRA_DATA(t, T_DRAW, extraDataDraw_t); if (xx->segs[0].type == SEG_POLY || - xx->segs[0].type == SEG_FILPOLY) { + xx->segs[0].type == SEG_FILPOLY) { MyFree(xx->segs[0].u.p.pts); xx->segs[0].u.p.pts = NULL; } @@ -1346,9 +1408,10 @@ static BOOL_T WriteDraw( track_p t, FILE * f ) { struct extraDataDraw_t * xx = GET_EXTRA_DATA(t, T_DRAW, extraDataDraw_t); BOOL_T rc = TRUE; - rc &= fprintf(f, "DRAW %d %d %d 0 0 %0.6f %0.6f 0 %0.6f\n", GetTrkIndex(t), GetTrkLayer(t), - xx->lineType, - xx->orig.x, xx->orig.y, xx->angle )>0; + rc &= fprintf(f, "DRAW %d %d %d 0 0 %0.6f %0.6f 0 %0.6f\n", GetTrkIndex(t), + GetTrkLayer(t), + xx->lineType, + xx->orig.x, xx->orig.y, xx->angle )>0; rc &= WriteSegs( f, xx->segCnt, xx->segs ); return rc; } @@ -1365,25 +1428,29 @@ static BOOL_T ReadDraw( char * header ) int lineType; struct extraDataDraw_t * xx; - if ( !GetArgs( header+5, paramVersion<3?"dXXpYf":paramVersion<9?"dLX00pYf":"dLd00pff", - &index, &layer, &lineType, &orig, &elev, &angle ) ) + if ( !GetArgs( header+5, + paramVersion<3?"dXXpYf":paramVersion<9?"dLX00pYf":"dLd00pff", + &index, &layer, &lineType, &orig, &elev, &angle ) ) { return FALSE; - if ( !ReadSegs() ) + } + if ( !ReadSegs() ) { return FALSE; + } if (tempSegs_da.cnt == 1) { trk = MakeDrawFromSeg1( index, orig, angle, &tempSegs(0) ); xx = GET_EXTRA_DATA(trk, T_DRAW, extraDataDraw_t); xx->lineType = lineType; SetTrkLayer( trk, layer ); } else { - trk = NewTrack( index, T_DRAW, 0, sizeof *xx + (tempSegs_da.cnt-1) * sizeof *(trkSeg_p)0 ); + trk = NewTrack( index, T_DRAW, 0, + sizeof *xx + (tempSegs_da.cnt-1) * sizeof *(trkSeg_p)0 ); SetTrkLayer( trk, layer ); xx = GET_EXTRA_DATA(trk, T_DRAW, extraDataDraw_t); xx->orig = orig; xx->angle = angle; xx->segCnt = tempSegs_da.cnt; xx->lineType = lineType; - memcpy( xx->segs, tempSegs_da.ptr, tempSegs_da.cnt * sizeof *(trkSeg_p)0 ); + memcpy( xx->segs, &tempSegs(0), tempSegs_da.cnt * sizeof *(trkSeg_p)0 ); ComputeDrawBoundingBox( trk ); } return TRUE; @@ -1398,28 +1465,28 @@ static void MoveDraw( track_p trk, coOrd off ) if (xx->orig.x == 0.0 && xx->orig.y == 0.0) { //No origin set switch(segPtr->type) { - case SEG_POLY: - case SEG_FILPOLY: - for (int i=0;i<segPtr->u.p.cnt;i++) { - REORIGIN( segPtr->u.p.pts[i].pt, segPtr->u.p.pts[i].pt, 0.0, off ); - } + case SEG_POLY: + case SEG_FILPOLY: + for (int i=0; i<segPtr->u.p.cnt; i++) { + REORIGIN( segPtr->u.p.pts[i].pt, segPtr->u.p.pts[i].pt, 0.0, off ); + } break; - case SEG_STRLIN: - case SEG_DIMLIN: - case SEG_BENCH: - case SEG_TBLEDGE: - for (int i=0;i<2;i++) { - REORIGIN( segPtr->u.l.pos[i], segPtr->u.l.pos[i], 0.0, off ); - } - break; - case SEG_CRVLIN: - case SEG_FILCRCL: - REORIGIN( segPtr->u.c.center, segPtr->u.c.center, 0.0, off ); - break; - case SEG_TEXT: - REORIGIN( segPtr->u.t.pos, segPtr->u.t.pos, 0.0, off ); - break; - default:; + case SEG_STRLIN: + case SEG_DIMLIN: + case SEG_BENCH: + case SEG_TBLEDGE: + for (int i=0; i<2; i++) { + REORIGIN( segPtr->u.l.pos[i], segPtr->u.l.pos[i], 0.0, off ); + } + break; + case SEG_CRVLIN: + case SEG_FILCRCL: + REORIGIN( segPtr->u.c.center, segPtr->u.c.center, 0.0, off ); + break; + case SEG_TEXT: + REORIGIN( segPtr->u.t.pos, segPtr->u.t.pos, 0.0, off ); + break; + default:; } } else { @@ -1436,30 +1503,30 @@ static void RotateDraw( track_p trk, coOrd orig, ANGLE_T angle ) trkSeg_p segPtr = &xx->segs[0]; if (xx->orig.x == 0.0 && xx->orig.y == 0.0) { //No origin set switch(segPtr->type) { - case SEG_POLY: - case SEG_FILPOLY: - for (int i=0;i<segPtr->u.p.cnt;i++) { - Rotate(&segPtr->u.p.pts[i].pt, orig, angle ); - } + case SEG_POLY: + case SEG_FILPOLY: + for (int i=0; i<segPtr->u.p.cnt; i++) { + Rotate(&segPtr->u.p.pts[i].pt, orig, angle ); + } break; - case SEG_STRLIN: - case SEG_DIMLIN: - case SEG_BENCH: - case SEG_TBLEDGE: - for (int i=0;i<2;i++) { - Rotate( &segPtr->u.l.pos[i], orig, angle ); - } - break; - case SEG_CRVLIN: - case SEG_FILCRCL: - Rotate( &segPtr->u.c.center, orig, angle ); - segPtr->u.c.a0 = NormalizeAngle(segPtr->u.c.a0 + angle); - break; - case SEG_TEXT: - Rotate( &segPtr->u.t.pos, orig, angle ); - segPtr->u.t.angle = NormalizeAngle(segPtr->u.t.angle+angle+xx->angle); - break; - default:; + case SEG_STRLIN: + case SEG_DIMLIN: + case SEG_BENCH: + case SEG_TBLEDGE: + for (int i=0; i<2; i++) { + Rotate( &segPtr->u.l.pos[i], orig, angle ); + } + break; + case SEG_CRVLIN: + case SEG_FILCRCL: + Rotate( &segPtr->u.c.center, orig, angle ); + segPtr->u.c.a0 = NormalizeAngle(segPtr->u.c.a0 + angle); + break; + case SEG_TEXT: + Rotate( &segPtr->u.t.pos, orig, angle ); + segPtr->u.t.angle = NormalizeAngle(segPtr->u.t.angle+angle+xx->angle); + break; + default:; } } else { Rotate( &xx->orig, orig, angle ); @@ -1477,23 +1544,27 @@ static void RescaleDraw( track_p trk, FLOAT_T ratio ) RescaleSegs( xx->segCnt, xx->segs, ratio, ratio, ratio ); } -static void DoConvertFill(void) { +#if 0 +static void DoConvertFill(void) +{ } +#endif static drawModContext_t drawModCmdContext = { - InfoMessage, - DoRedraw, - &mainD}; + InfoMessage, + DoRedraw, + &mainD +}; static BOOL_T infoSubst = FALSE; -static paramIntegerRange_t i100_100 = { -100, 100, 25 }; //Allow negative numbers +static paramFloatRange_t r100_100 = { -100.0, 100.0, 50 }; //Allow negative numbers static paramFloatRange_t r0d001_10000 = { 0.001, 10000 }; -static paramFloatRange_t r1_10000 = { 1, 10000 }; +//static paramFloatRange_t r1_10000 = { 1, 10000 }; static paramFloatRange_t r0_10000 = { 0, 10000 }; -static paramFloatRange_t r10000_10000 = {-10000, 10000}; +//static paramFloatRange_t r10000_10000 = {-10000, 10000}; static paramFloatRange_t r360_360 = { -360, 360, 80 }; static paramFloatRange_t r0_360 = { 0, 360, 80 }; static paramData_t drawModPLs[] = { @@ -1526,15 +1597,16 @@ static paramData_t drawModPLs[] = { static paramGroup_t drawModPG = { "drawMod", 0, drawModPLs, COUNT( drawModPLs ) }; static void DrawModDlgUpdate( - paramGroup_p pg, - int inx, - void * valueP ) + paramGroup_p pg, + int inx, + void * valueP ) { - DrawGeomModify(C_UPDATE,zero,&drawModCmdContext); - ParamLoadControl(&drawModPG,drawModRotCenterInx-1); //Make sure the angle is updated in case center moved - ParamLoadControl(&drawModPG,drawModRadius); // Make sure Radius updated - ParamLoadControl(&drawModPG,drawModRelAngle); //Relative Angle as well - MainRedraw(); + DrawGeomModify(C_UPDATE,zero,&drawModCmdContext); + ParamLoadControl(&drawModPG, + drawModRotCenterInx-1); //Make sure the angle is updated in case center moved + ParamLoadControl(&drawModPG,drawModRadius); // Make sure Radius updated + ParamLoadControl(&drawModPG,drawModRelAngle); //Relative Angle as well + MainRedraw(); } @@ -1556,20 +1628,23 @@ static STATUS_T ModifyDraw( track_p trk, wAction_t action, coOrd pos ) switch(action&0xFF) { //Remove Text value case C_START: + for (int inx = 0; inx < COUNT(drawModPLs); ++inx ) { + drawModPLs[inx].option |= PDO_DLGIGNORE; + } drawModCmdContext.type = xx->segs[0].type; switch(drawModCmdContext.type) { - case SEG_POLY: - case SEG_FILPOLY: - drawModCmdContext.filled = (drawModCmdContext.type==SEG_FILPOLY)?TRUE:FALSE; - drawModCmdContext.subtype = xx->segs[0].u.p.polyType; - drawModCmdContext.open = (drawModCmdContext.subtype==POLYLINE)?TRUE:FALSE; - break; - case SEG_TEXT: - InfoMessage("Text can only be modified in Describe Mode"); - wBeep(); - return C_ERROR; - default: - break; + case SEG_POLY: + case SEG_FILPOLY: + drawModCmdContext.filled = (drawModCmdContext.type==SEG_FILPOLY)?TRUE:FALSE; + drawModCmdContext.subtype = xx->segs[0].u.p.polyType; + drawModCmdContext.open = (drawModCmdContext.subtype==POLYLINE)?TRUE:FALSE; + break; + case SEG_TEXT: + InfoMessage("Text can only be modified in Describe Mode"); + wBeep(); + return C_ERROR; + default: + break; } drawModCmdContext.rot_moved = FALSE; @@ -1616,6 +1691,8 @@ static STATUS_T ModifyDraw( track_p trk, wAction_t action, coOrd pos ) if (drawModCmdContext.prev_inx >= 0) { controls[0] = drawModLengthPD.control; controls[1] = drawModRelAnglePD.control; + drawModLengthPD.option &= ~PDO_DLGIGNORE; + drawModRelAnglePD.option &= ~PDO_DLGIGNORE; controls[2] = NULL; labels[0] = N_("Seg Lth"); labels[1] = N_("Rel Ang"); @@ -1628,6 +1705,8 @@ static STATUS_T ModifyDraw( track_p trk, wAction_t action, coOrd pos ) } else { controls[0] = drawModWidthPD.control; controls[1] = drawModHeightPD.control; + drawModWidthPD.option &= ~PDO_DLGIGNORE; + drawModHeightPD.option &= ~PDO_DLGIGNORE; controls[2] = NULL; labels[0] = N_("Width"); labels[1] = N_("Height"); @@ -1637,13 +1716,15 @@ static STATUS_T ModifyDraw( track_p trk, wAction_t action, coOrd pos ) drawModHeightPD.option &= ~PDO_NORECORD; infoSubst = TRUE; } - break; + break; case SEG_STRLIN: case SEG_BENCH: case SEG_DIMLIN: case SEG_TBLEDGE: controls[0] = drawModLengthPD.control; controls[1] = drawModAnglePD.control; + drawModLengthPD.option &= ~PDO_DLGIGNORE; + drawModAnglePD.option &= ~PDO_DLGIGNORE; controls[2] = NULL; labels[0] = N_("Length"); labels[1] = N_("Angle"); @@ -1652,13 +1733,15 @@ static STATUS_T ModifyDraw( track_p trk, wAction_t action, coOrd pos ) drawModLengthPD.option &= ~PDO_NORECORD; drawModAnglePD.option &= ~PDO_NORECORD; infoSubst = TRUE; - break; + break; case SEG_CRVLIN: case SEG_FILCRCL: controls[0] = drawModRadiusPD.control; + drawModRadiusPD.option &= ~PDO_DLGIGNORE; controls[1] = NULL; labels[0] = N_("Radius"); - if ((drawModCmdContext.type == SEG_CRVLIN) && xx->segs[0].u.c.a1>0.0 && xx->segs[0].u.c.a1 <360.0) { + if ((drawModCmdContext.type == SEG_CRVLIN) && xx->segs[0].u.c.a1>0.0 + && xx->segs[0].u.c.a1 <360.0) { controls[1] = drawModArcAnglePD.control; controls[2] = NULL; labels[1] = N_("Arc Angle"); @@ -1666,14 +1749,15 @@ static STATUS_T ModifyDraw( track_p trk, wAction_t action, coOrd pos ) ParamLoadControls( &drawModPG ); InfoSubstituteControls( controls, labels ); drawModArcAnglePD.option &= ~PDO_NORECORD; - if (drawModCmdContext.type == SEG_CRVLIN) + if (drawModCmdContext.type == SEG_CRVLIN) { drawModArcAnglePD.option &= ~PDO_NORECORD; + } infoSubst = TRUE; break; default: InfoSubstituteControls( NULL, NULL ); infoSubst = FALSE; - break; + break; } } else { InfoSubstituteControls( NULL, NULL ); @@ -1700,21 +1784,28 @@ static STATUS_T ModifyDraw( track_p trk, wAction_t action, coOrd pos ) wMenuPushEnable( drawModDashDotDot, TRUE); wMenuPushEnable( drawModCenterDot, TRUE); wMenuPushEnable( drawModPhantom, TRUE); - if (!drawModCmdContext.rotate_state && (drawModCmdContext.type == SEG_POLY || drawModCmdContext.type == SEG_FILPOLY)) { - wMenuPushEnable( drawModDel,drawModCmdContext.prev_inx>=0); - if ((!drawModCmdContext.open && drawModCmdContext.prev_inx>=0) || - ((drawModCmdContext.prev_inx>0) && (drawModCmdContext.prev_inx<drawModCmdContext.max_inx))) { - wMenuPushEnable( drawModRound,TRUE); - wMenuPushEnable( drawModVertex, TRUE); - wMenuPushEnable( drawModSmooth, TRUE); - } - wMenuPushEnable( drawModFill, (!drawModCmdContext.open) && (!drawModCmdContext.filled)); - wMenuPushEnable( drawModEmpty, (!drawModCmdContext.open) && (drawModCmdContext.filled)); - wMenuPushEnable( drawModClose, drawModCmdContext.open); - wMenuPushEnable( drawModOpen, !drawModCmdContext.open); + if (!drawModCmdContext.rotate_state && (drawModCmdContext.type == SEG_POLY + || drawModCmdContext.type == SEG_FILPOLY)) { + wMenuPushEnable( drawModFill, (!drawModCmdContext.open) + && (!drawModCmdContext.filled)); + wMenuPushEnable( drawModEmpty, (!drawModCmdContext.open) + && (drawModCmdContext.filled)); + if (drawModCmdContext.subtype != RECTANGLE) { + wMenuPushEnable( drawModDel,drawModCmdContext.prev_inx>=0); + if ((!drawModCmdContext.open && drawModCmdContext.prev_inx>=0) || + ((drawModCmdContext.prev_inx>0) + && (drawModCmdContext.prev_inx<drawModCmdContext.max_inx))) { + wMenuPushEnable( drawModRound,TRUE); + wMenuPushEnable( drawModVertex, TRUE); + wMenuPushEnable( drawModSmooth, TRUE); + wMenuPushEnable( drawModClose, drawModCmdContext.open); + wMenuPushEnable( drawModOpen, !drawModCmdContext.open); + } + } } wMenuPushEnable( drawModOrigin,drawModCmdContext.rotate_state); - wMenuPushEnable( drawModLast,drawModCmdContext.rotate_state && (drawModCmdContext.prev_inx>=0)); + wMenuPushEnable( drawModLast,drawModCmdContext.rotate_state + && (drawModCmdContext.prev_inx>=0)); wMenuPushEnable( drawModCenter,drawModCmdContext.rotate_state); break; case wActionExtKey: @@ -1722,12 +1813,12 @@ static STATUS_T ModifyDraw( track_p trk, wAction_t action, coOrd pos ) ignoredDraw = trk ; rc = DrawGeomModify( action, pos, &drawModCmdContext ); if ( infoSubst ) { - InfoSubstituteControls( NULL, NULL ); - infoSubst = FALSE; + InfoSubstituteControls( NULL, NULL ); + infoSubst = FALSE; } ignoredDraw = NULL; - if (rc == C_CONTINUE) break; - /* no break*/ + if (rc == C_CONTINUE) { break; } + /* no break*/ case C_FINISH: ignoredDraw = trk; rc = DrawGeomModify( C_FINISH, pos, &drawModCmdContext ); @@ -1771,8 +1862,9 @@ static void UngroupDraw( track_p trk ) { struct extraDataDraw_t * xx = GET_EXTRA_DATA(trk, T_DRAW, extraDataDraw_t); int inx; - if ( xx->segCnt <= 1 ) + if ( xx->segCnt <= 1 ) { return; + } DeleteTrack( trk, FALSE ); for ( inx=0; inx<xx->segCnt; inx++ ) { trk = MakeDrawFromSeg( xx->orig, xx->angle, &xx->segs[inx] ); @@ -1785,10 +1877,10 @@ static void UngroupDraw( track_p trk ) static ANGLE_T GetAngleDraw( - track_p trk, - coOrd pos, - EPINX_T * ep0, - EPINX_T * ep1 ) + track_p trk, + coOrd pos, + EPINX_T * ep0, + EPINX_T * ep1 ) { struct extraDataDraw_t * xx = GET_EXTRA_DATA(trk, T_DRAW, extraDataDraw_t); ANGLE_T angle; @@ -1797,15 +1889,15 @@ static ANGLE_T GetAngleDraw( pos.y -= xx->orig.y; Rotate( &pos, zero, -xx->angle ); angle = GetAngleSegs( xx->segCnt, xx->segs, &pos, NULL, NULL, NULL, NULL, NULL); - if ( ep0 ) *ep0 = -1; - if ( ep1 ) *ep1 = -1; + if ( ep0 ) { *ep0 = -1; } + if ( ep1 ) { *ep1 = -1; } return NormalizeAngle( angle + xx->angle ); } static BOOL_T EnumerateDraw( - track_p trk ) + track_p trk ) { struct extraDataDraw_t * xx; int inx; @@ -1813,13 +1905,15 @@ static BOOL_T EnumerateDraw( if ( trk ) { xx = GET_EXTRA_DATA(trk, T_DRAW, extraDataDraw_t); - if ( xx->segCnt < 1 ) + if ( xx->segCnt < 1 ) { return FALSE; + } BOOL_T content = FALSE; for ( inx=0; inx<xx->segCnt; inx++ ) { segPtr = &xx->segs[inx]; if ( segPtr->type == SEG_BENCH ) { - CountBench( segPtr->u.l.option, FindDistance( segPtr->u.l.pos[0], segPtr->u.l.pos[1] ) ); + CountBench( segPtr->u.l.option, FindDistance( segPtr->u.l.pos[0], + segPtr->u.l.pos[1] ) ); content = TRUE; } } @@ -1832,9 +1926,9 @@ static BOOL_T EnumerateDraw( static void FlipDraw( - track_p trk, - coOrd orig, - ANGLE_T angle ) + track_p trk, + coOrd orig, + ANGLE_T angle ) { struct extraDataDraw_t * xx = GET_EXTRA_DATA(trk, T_DRAW, extraDataDraw_t); @@ -1850,29 +1944,29 @@ static void FlipDraw( if (reorigin) { switch(segPtr->type) { - case SEG_POLY: - case SEG_FILPOLY: - for (int i=0;i<segPtr->u.p.cnt;i++) { - REORIGIN( segPtr->u.p.pts[i].pt, segPtr->u.p.pts[i].pt, xx->angle, xx->orig); - } + case SEG_POLY: + case SEG_FILPOLY: + for (int i=0; i<segPtr->u.p.cnt; i++) { + REORIGIN( segPtr->u.p.pts[i].pt, segPtr->u.p.pts[i].pt, xx->angle, xx->orig); + } break; - case SEG_STRLIN: - case SEG_DIMLIN: - case SEG_BENCH: - case SEG_TBLEDGE: - for (int i=0;i<2;i++) { - REORIGIN( segPtr->u.l.pos[i], segPtr->u.l.pos[i], xx->angle, xx->orig); - } - break; - case SEG_CRVLIN: - case SEG_FILCRCL: - REORIGIN( segPtr->u.c.center, segPtr->u.c.center, xx->angle, xx->orig); - segPtr->u.c.a0 = NormalizeAngle(segPtr->u.c.a0 + xx->angle); - break; - case SEG_TEXT: - REORIGIN( segPtr->u.t.pos, segPtr->u.t.pos, xx->angle, xx->orig ); - break; - default:; + case SEG_STRLIN: + case SEG_DIMLIN: + case SEG_BENCH: + case SEG_TBLEDGE: + for (int i=0; i<2; i++) { + REORIGIN( segPtr->u.l.pos[i], segPtr->u.l.pos[i], xx->angle, xx->orig); + } + break; + case SEG_CRVLIN: + case SEG_FILCRCL: + REORIGIN( segPtr->u.c.center, segPtr->u.c.center, xx->angle, xx->orig); + segPtr->u.c.a0 = NormalizeAngle(segPtr->u.c.a0 + xx->angle); + break; + case SEG_TEXT: + REORIGIN( segPtr->u.t.pos, segPtr->u.t.pos, xx->angle, xx->orig ); + break; + default:; } xx->orig.x = 0.0, xx->orig.y = 0.0, xx->angle = 0.0; } @@ -1881,13 +1975,13 @@ static void FlipDraw( } static BOOL_T StoreDraw( - track_p trk, - void **data, - long * len) + track_p trk, + void **data, + long * len) { struct extraDataDraw_t * xx = GET_EXTRA_DATA(trk, T_DRAW, extraDataDraw_t); if (xx->segs[0].type == SEG_POLY || - xx->segs[0].type == SEG_FILPOLY) { + xx->segs[0].type == SEG_FILPOLY) { *data = xx->segs[0].u.p.pts; *len = xx->segs[0].u.p.cnt* sizeof (pts_t); return TRUE; @@ -1896,13 +1990,13 @@ static BOOL_T StoreDraw( } static BOOL_T ReplayDraw( - track_p trk, - void * data, - long len) + track_p trk, + void * data, + long len) { struct extraDataDraw_t * xx = GET_EXTRA_DATA(trk, T_DRAW, extraDataDraw_t); if (xx->segs[0].type == SEG_POLY || - xx->segs[0].type == SEG_FILPOLY) { + xx->segs[0].type == SEG_FILPOLY) { xx->segs[0].u.p.pts = MyMalloc(len); memcpy(xx->segs[0].u.p.pts,data,len); return TRUE; @@ -1919,26 +2013,26 @@ static BOOL_T QueryDraw( track_p trk, int query ) case Q_IS_POLY: if ((xx->segs[0].type == SEG_POLY) || (xx->segs[0].type == SEG_FILPOLY) ) { return TRUE; - } - else + } else { return FALSE; + } case Q_IS_TEXT: - if (xx->segs[0].type== SEG_TEXT) return TRUE; - else return FALSE; + if (xx->segs[0].type== SEG_TEXT) { return TRUE; } + else { return FALSE; } case Q_GET_NODES: return TRUE; case Q_CAN_PARALLEL: case Q_MODIFY_CAN_SPLIT: if ((xx->segs[0].type == SEG_STRLIN) || - (xx->segs[0].type == SEG_CRVLIN) || - (xx->segs[0].type == SEG_BEZLIN) || - (xx->segs[0].type == SEG_FILCRCL) || - (xx->segs[0].type == SEG_FILPOLY) || - (xx->segs[0].type == SEG_POLY) || - (xx->segs[0].type == SEG_BENCH) || - (xx->segs[0].type == SEG_TBLEDGE) - ) return TRUE; - else return FALSE; + (xx->segs[0].type == SEG_CRVLIN) || + (xx->segs[0].type == SEG_BEZLIN) || + (xx->segs[0].type == SEG_FILCRCL) || + (xx->segs[0].type == SEG_FILPOLY) || + (xx->segs[0].type == SEG_POLY) || + (xx->segs[0].type == SEG_BENCH) || + (xx->segs[0].type == SEG_TBLEDGE) + ) { return TRUE; } + else { return FALSE; } default: return FALSE; } @@ -1955,454 +2049,489 @@ static wBool_t CompareDraw( track_cp trk1, track_cp trk2 ) return CompareSegs( xx1->segs, xx1->segCnt, xx2->segs, xx2->segCnt ); } -static BOOL_T GetParamsDraw( int inx, track_p trk, coOrd pos, trackParams_t * params ) { +static BOOL_T GetParamsDraw( int inx, track_p trk, coOrd pos, + trackParams_t * params ) +{ struct extraDataDraw_t * xx = GET_EXTRA_DATA(trk, T_DRAW, extraDataDraw_t); - if (inx != PARAMS_NODES ) return FALSE; + if (inx != PARAMS_NODES ) { return FALSE; } DYNARR_RESET(coOrd,params->nodes); BOOL_T back = FALSE; coOrd start,end; switch (xx->segs[0].type) { - case SEG_POLY: - if (xx->segs[0].u.p.polyType != POLYLINE) return FALSE; - REORIGIN(start,xx->segs[0].u.p.pts[0].pt,xx->angle,xx->orig); - REORIGIN(end,xx->segs[0].u.p.pts[xx->segs[0].u.p.cnt-1].pt,xx->angle,xx->orig); - params->ep = 1; - if (FindDistance(pos,start)>FindDistance(pos,end)) back = TRUE; - for (int i=0;i<xx->segs[0].u.p.cnt;i++) { - DYNARR_APPEND(coOrd,params->nodes,xx->segs[0].u.p.cnt); - if (back) - DYNARR_LAST(coOrd,params->nodes) = xx->segs[0].u.p.pts[xx->segs[0].u.p.cnt-1-i].pt; - else - DYNARR_LAST(coOrd,params->nodes) = xx->segs[0].u.p.pts[i].pt; - REORIGIN(DYNARR_LAST(coOrd,params->nodes),DYNARR_LAST(coOrd,params->nodes),xx->angle,xx->orig); - } - params->lineOrig = DYNARR_N(coOrd,params->nodes,0); - params->lineEnd = DYNARR_LAST(coOrd,params->nodes); - return TRUE; - - case SEG_STRLIN:; - REORIGIN(start,xx->segs[0].u.l.pos[0],xx->angle,xx->orig); - REORIGIN(end,xx->segs[0].u.l.pos[1],xx->angle,xx->orig); - params->ep = 1; - if (FindDistance(pos,start)>FindDistance(pos,end)) { - back = TRUE; - } - for (int i=0;i<2;i++) { - DYNARR_APPEND(coOrd,params->nodes,2); - REORIGIN(DYNARR_LAST(coOrd,params->nodes),xx->segs[0].u.l.pos[back?1-i:i],xx->angle,xx->orig); + case SEG_POLY: + if (xx->segs[0].u.p.polyType != POLYLINE) { return FALSE; } + REORIGIN(start,xx->segs[0].u.p.pts[0].pt,xx->angle,xx->orig); + REORIGIN(end,xx->segs[0].u.p.pts[xx->segs[0].u.p.cnt-1].pt,xx->angle,xx->orig); + params->ep = 1; + if (FindDistance(pos,start)>FindDistance(pos,end)) { back = TRUE; } + for (int i=0; i<xx->segs[0].u.p.cnt; i++) { + DYNARR_APPEND(coOrd,params->nodes,xx->segs[0].u.p.cnt); + if (back) { + DYNARR_LAST(coOrd,params->nodes) = xx->segs[0].u.p.pts[xx->segs[0].u.p.cnt-1 + -i].pt; + } else { + DYNARR_LAST(coOrd,params->nodes) = xx->segs[0].u.p.pts[i].pt; } - params->lineOrig = DYNARR_N(coOrd,params->nodes,0); - params->lineEnd = DYNARR_LAST(coOrd,params->nodes); - return TRUE; + REORIGIN(DYNARR_LAST(coOrd,params->nodes),DYNARR_LAST(coOrd,params->nodes), + xx->angle,xx->orig); + } + params->lineOrig = DYNARR_N(coOrd,params->nodes,0); + params->lineEnd = DYNARR_LAST(coOrd,params->nodes); + return TRUE; - case SEG_CRVLIN:; - Translate(&start,xx->segs[0].u.c.center,xx->segs[0].u.c.a0,fabs(xx->segs[0].u.c.radius)); - REORIGIN(start,start,xx->angle,xx->orig); - Translate(&end,xx->segs[0].u.c.center,xx->segs[0].u.c.a0+xx->segs[0].u.c.a1,fabs(xx->segs[0].u.c.radius)); - REORIGIN(end,end,xx->angle,xx->orig); - if (FindDistance(start,pos) > FindDistance(end,pos)) back = TRUE; - if (fabs(xx->segs[0].u.c.radius) > 0.5) { - double min_angle = R2D(2*acos(1.0-(0.1/fabs(xx->segs[0].u.c.radius)))); //Error max is 0.1" - int number = (int) ceil(xx->segs[0].u.c.a1/min_angle); - double arc_size = xx->segs[0].u.c.a1/number; - for (int i=0;i<=number;i++) { - DYNARR_APPEND(coOrd,params->nodes,number); - if (back) - Translate(&DYNARR_LAST(coOrd,params->nodes),xx->segs[0].u.c.center,xx->segs[0].u.c.a0+xx->segs[0].u.c.a1-(i*arc_size),fabs(xx->segs[0].u.c.radius)); - else - Translate(&DYNARR_LAST(coOrd,params->nodes),xx->segs[0].u.c.center,xx->segs[0].u.c.a0+(i*arc_size),fabs(xx->segs[0].u.c.radius)); - REORIGIN(DYNARR_LAST(coOrd,params->nodes),DYNARR_LAST(coOrd,params->nodes),xx->angle,xx->orig); + case SEG_STRLIN:; + REORIGIN(start,xx->segs[0].u.l.pos[0],xx->angle,xx->orig); + REORIGIN(end,xx->segs[0].u.l.pos[1],xx->angle,xx->orig); + params->ep = 1; + if (FindDistance(pos,start)>FindDistance(pos,end)) { + back = TRUE; + } + for (int i=0; i<2; i++) { + DYNARR_APPEND(coOrd,params->nodes,2); + REORIGIN(DYNARR_LAST(coOrd,params->nodes),xx->segs[0].u.l.pos[back?1-i:i], + xx->angle,xx->orig); + } + params->lineOrig = DYNARR_N(coOrd,params->nodes,0); + params->lineEnd = DYNARR_LAST(coOrd,params->nodes); + return TRUE; + + case SEG_CRVLIN:; + Translate(&start,xx->segs[0].u.c.center,xx->segs[0].u.c.a0, + fabs(xx->segs[0].u.c.radius)); + REORIGIN(start,start,xx->angle,xx->orig); + Translate(&end,xx->segs[0].u.c.center,xx->segs[0].u.c.a0+xx->segs[0].u.c.a1, + fabs(xx->segs[0].u.c.radius)); + REORIGIN(end,end,xx->angle,xx->orig); + if (FindDistance(start,pos) > FindDistance(end,pos)) { back = TRUE; } + if (fabs(xx->segs[0].u.c.radius) > 0.5) { + double min_angle = R2D(2*acos(1.0-(0.1/fabs( + xx->segs[0].u.c.radius)))); //Error max is 0.1" + int number = (int) ceil(xx->segs[0].u.c.a1/min_angle); + double arc_size = xx->segs[0].u.c.a1/number; + for (int i=0; i<=number; i++) { + DYNARR_APPEND(coOrd,params->nodes,number); + if (back) { + Translate(&DYNARR_LAST(coOrd,params->nodes),xx->segs[0].u.c.center, + xx->segs[0].u.c.a0+xx->segs[0].u.c.a1-(i*arc_size), + fabs(xx->segs[0].u.c.radius)); + } else { + Translate(&DYNARR_LAST(coOrd,params->nodes),xx->segs[0].u.c.center, + xx->segs[0].u.c.a0+(i*arc_size),fabs(xx->segs[0].u.c.radius)); } - } else { - DYNARR_APPEND(coOrd,params->nodes,2); - REORIGIN(DYNARR_LAST(coOrd,params->nodes),back?end:start,xx->angle,xx->orig); - DYNARR_APPEND(coOrd,params->nodes,2); - REORIGIN(DYNARR_LAST(coOrd,params->nodes),back?start:end,xx->angle,xx->orig); + REORIGIN(DYNARR_LAST(coOrd,params->nodes),DYNARR_LAST(coOrd,params->nodes), + xx->angle,xx->orig); } - params->lineOrig = DYNARR_N(coOrd,params->nodes,0); - params->lineEnd = DYNARR_LAST(coOrd,params->nodes); - params->ep = 1; - return TRUE; + } else { + DYNARR_APPEND(coOrd,params->nodes,2); + REORIGIN(DYNARR_LAST(coOrd,params->nodes),back?end:start,xx->angle,xx->orig); + DYNARR_APPEND(coOrd,params->nodes,2); + REORIGIN(DYNARR_LAST(coOrd,params->nodes),back?start:end,xx->angle,xx->orig); + } + params->lineOrig = DYNARR_N(coOrd,params->nodes,0); + params->lineEnd = DYNARR_LAST(coOrd,params->nodes); + params->ep = 1; + return TRUE; - case SEG_BEZLIN: - REORIGIN(start,xx->segs[0].u.b.pos[0],xx->angle,xx->orig); - REORIGIN(end,xx->segs[0].u.b.pos[3],xx->angle,xx->orig); - if (FindDistance(pos,start) < FindDistance(pos,end)) - params->ep = 0; - else params->ep = 1; - BOOL_T back = FALSE; - coOrd curr_pos = params->bezierPoints[params->ep*3]; - BOOL_T first = TRUE; - for (int i = 0; i<xx->segs[0].bezSegs.cnt;i++) { - trkSeg_p segPtr = &DYNARR_N(trkSeg_t,xx->segs[0].bezSegs,params->ep?xx->segs[0].bezSegs.cnt-1-i:i); - if (segPtr->type == SEG_STRLIN) { - back = FindDistance(segPtr->u.l.pos[0],curr_pos)>FindDistance(segPtr->u.l.pos[1],curr_pos); - if (first) { - first = FALSE; - DYNARR_APPEND(coOrd,params->nodes,2); - REORIGIN(DYNARR_LAST(coOrd,params->nodes),segPtr->u.l.pos[back],xx->angle,xx->orig); - } + case SEG_BEZLIN: + REORIGIN(start,xx->segs[0].u.b.pos[0],xx->angle,xx->orig); + REORIGIN(end,xx->segs[0].u.b.pos[3],xx->angle,xx->orig); + if (FindDistance(pos,start) < FindDistance(pos,end)) { + params->ep = 0; + } else { params->ep = 1; } + BOOL_T back = FALSE; + coOrd curr_pos = params->bezierPoints[params->ep*3]; + BOOL_T first = TRUE; + for (int i = 0; i<xx->segs[0].bezSegs.cnt; i++) { + trkSeg_p segPtr = &DYNARR_N(trkSeg_t,xx->segs[0].bezSegs, + params->ep?xx->segs[0].bezSegs.cnt-1-i:i); + if (segPtr->type == SEG_STRLIN) { + back = FindDistance(segPtr->u.l.pos[0], + curr_pos)>FindDistance(segPtr->u.l.pos[1],curr_pos); + if (first) { + first = FALSE; DYNARR_APPEND(coOrd,params->nodes,2); - REORIGIN(DYNARR_LAST(coOrd,params->nodes),segPtr->u.l.pos[1-back],xx->angle,xx->orig); - curr_pos = DYNARR_LAST(coOrd,params->nodes); - } else { - coOrd start,end; - Translate(&start,segPtr->u.c.center,segPtr->u.c.a0,segPtr->u.c.radius); - Translate(&end,segPtr->u.c.center,segPtr->u.c.a0+segPtr->u.c.a1,segPtr->u.c.radius); - back = FindDistance(start,curr_pos)>FindDistance(end,curr_pos); - if (fabs(segPtr->u.c.radius) > 0.2) { - double min_angle = 360*acos(1.0-(0.1/fabs(segPtr->u.c.radius)))/M_PI; //Error max is 0.1" - int number = (int)ceil(segPtr->u.c.a1/min_angle); - double arc_size = segPtr->u.c.a1/number; - for (int j=1-first;j<number;j++) { - DYNARR_APPEND(coOrd,params->nodes,number-first); - if (back == params->ep) - Translate(&DYNARR_LAST(coOrd,params->nodes),segPtr->u.c.center,segPtr->u.c.a0+(j*arc_size),fabs(segPtr->u.c.radius) ); - else - Translate(&DYNARR_LAST(coOrd,params->nodes),segPtr->u.c.center,segPtr->u.c.a0+segPtr->u.c.a1-(j*arc_size),fabs(segPtr->u.c.radius) ); - REORIGIN(DYNARR_LAST(coOrd,params->nodes),DYNARR_LAST(coOrd,params->nodes),xx->angle,xx->orig); - } - first = FALSE; - } else { - if (first) { - first = FALSE; - DYNARR_APPEND(coOrd,params->nodes,2); - REORIGIN(DYNARR_LAST(coOrd,params->nodes),start,xx->angle,xx->orig); + REORIGIN(DYNARR_LAST(coOrd,params->nodes),segPtr->u.l.pos[back],xx->angle, + xx->orig); + } + DYNARR_APPEND(coOrd,params->nodes,2); + REORIGIN(DYNARR_LAST(coOrd,params->nodes),segPtr->u.l.pos[1-back],xx->angle, + xx->orig); + curr_pos = DYNARR_LAST(coOrd,params->nodes); + } else { + coOrd start,end; + Translate(&start,segPtr->u.c.center,segPtr->u.c.a0,segPtr->u.c.radius); + Translate(&end,segPtr->u.c.center,segPtr->u.c.a0+segPtr->u.c.a1, + segPtr->u.c.radius); + back = FindDistance(start,curr_pos)>FindDistance(end,curr_pos); + if (fabs(segPtr->u.c.radius) > 0.2) { + double min_angle = 360*acos(1.0-(0.1/fabs( + segPtr->u.c.radius)))/M_PI; //Error max is 0.1" + int number = (int)ceil(segPtr->u.c.a1/min_angle); + double arc_size = segPtr->u.c.a1/number; + for (int j=1-first; j<number; j++) { + DYNARR_APPEND(coOrd,params->nodes,number-first); + if (back == params->ep) { + Translate(&DYNARR_LAST(coOrd,params->nodes),segPtr->u.c.center, + segPtr->u.c.a0+(j*arc_size),fabs(segPtr->u.c.radius) ); + } else { + Translate(&DYNARR_LAST(coOrd,params->nodes),segPtr->u.c.center, + segPtr->u.c.a0+segPtr->u.c.a1-(j*arc_size),fabs(segPtr->u.c.radius) ); } - DYNARR_APPEND(coOrd,params->nodes,1); - REORIGIN(DYNARR_LAST(coOrd,params->nodes),end,xx->angle,xx->orig); + REORIGIN(DYNARR_LAST(coOrd,params->nodes),DYNARR_LAST(coOrd,params->nodes), + xx->angle,xx->orig); + } + first = FALSE; + } else { + if (first) { first = FALSE; + DYNARR_APPEND(coOrd,params->nodes,2); + REORIGIN(DYNARR_LAST(coOrd,params->nodes),start,xx->angle,xx->orig); } - curr_pos = DYNARR_LAST(coOrd,params->nodes); + DYNARR_APPEND(coOrd,params->nodes,1); + REORIGIN(DYNARR_LAST(coOrd,params->nodes),end,xx->angle,xx->orig); + first = FALSE; } + curr_pos = DYNARR_LAST(coOrd,params->nodes); } - params->lineOrig = DYNARR_N(coOrd,params->nodes,0); - params->lineEnd = DYNARR_LAST(coOrd,params->nodes); - return TRUE; + } + params->lineOrig = DYNARR_N(coOrd,params->nodes,0); + params->lineEnd = DYNARR_LAST(coOrd,params->nodes); + return TRUE; - default: - return FALSE; + default: + return FALSE; } return FALSE; } -static BOOL_T SplitDraw( track_p trk, coOrd pos, EPINX_T ep, track_p *leftover, EPINX_T * ep0, EPINX_T * ep1 ) +static BOOL_T SplitDraw( track_p trk, coOrd pos, EPINX_T ep, track_p *leftover, + EPINX_T * ep0, EPINX_T * ep1 ) { - struct extraDataDraw_t * xx = GET_EXTRA_DATA(trk, T_DRAW, extraDataDraw_t); + struct extraDataDraw_t * xx = GET_EXTRA_DATA(trk, T_DRAW, extraDataDraw_t); - coOrd p0,p1; - DIST_T d; - BOOL_T polyline_trim = FALSE, new_last = ep; + coOrd p0,p1; + DIST_T d; + BOOL_T polyline_trim = FALSE, new_last = ep; - DYNARR_SET(trkSeg_t, tempSegs_da, 1); + DYNARR_SET(trkSeg_t, tempSegs_da, 1); - tempSegs(0).type = -1; + tempSegs(0).type = -1; - switch (xx->segs[0].type) { - case SEG_STRLIN: - case SEG_BENCH: - case SEG_TBLEDGE: - REORIGIN(p0,xx->segs[0].u.l.pos[0],xx->angle,xx->orig); - REORIGIN(p1,xx->segs[0].u.l.pos[1],xx->angle,xx->orig); - tempSegs(0).color = xx->segs[0].color; - tempSegs(0).width = xx->segs[0].width; - tempSegs_da.cnt = 1; - tempSegs(0).type = xx->segs[0].type; - tempSegs(0).u.l.pos[0] = 1-ep?p0:pos; - tempSegs(0).u.l.pos[1] = 1-ep?pos:p1; - xx->segs[0].u.l.pos[0] = 1-ep?pos:p0; - xx->segs[0].u.l.pos[1] = 1-ep?p1:pos; - break; - case SEG_CRVLIN: - case SEG_FILCRCL: ; - coOrd c; - REORIGIN(c, xx->segs[0].u.c.center, xx->angle, xx->orig); - coOrd c0,c1; - if (xx->segs[0].type == SEG_FILCRCL || - (xx->segs[0].type == SEG_CRVLIN && xx->segs[0].u.c.a1 >= 360.0)) { - Translate(&c0,c,FindAngle(c,pos),xx->segs[0].u.c.radius); - c1 = c0; - xx->segs[0].type = SEG_CRVLIN; - xx->segs[0].u.c.a0 = FindAngle(c,c0); - xx->segs[0].u.c.a1 = 355.0; + switch (xx->segs[0].type) { + case SEG_STRLIN: + case SEG_BENCH: + case SEG_TBLEDGE: + REORIGIN(p0,xx->segs[0].u.l.pos[0],xx->angle,xx->orig); + REORIGIN(p1,xx->segs[0].u.l.pos[1],xx->angle,xx->orig); + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); + tempSegs(0).color = xx->segs[0].color; + tempSegs(0).lineWidth = xx->segs[0].lineWidth; + tempSegs(0).type = xx->segs[0].type; + tempSegs(0).u.l.pos[0] = 1-ep?p0:pos; + tempSegs(0).u.l.pos[1] = 1-ep?pos:p1; + xx->segs[0].u.l.pos[0] = 1-ep?pos:p0; + xx->segs[0].u.l.pos[1] = 1-ep?p1:pos; + break; + case SEG_CRVLIN: + case SEG_FILCRCL: ; + coOrd c; + REORIGIN(c, xx->segs[0].u.c.center, xx->angle, xx->orig); + coOrd c0,c1; + if (xx->segs[0].type == SEG_FILCRCL || + (xx->segs[0].type == SEG_CRVLIN && xx->segs[0].u.c.a1 >= 360.0)) { + Translate(&c0,c,FindAngle(c,pos),xx->segs[0].u.c.radius); + c1 = c0; + xx->segs[0].type = SEG_CRVLIN; + xx->segs[0].u.c.a0 = FindAngle(c,c0); + xx->segs[0].u.c.a1 = 355.0; + } else { + Translate(&c0,c,xx->segs[0].u.c.a0+xx->angle,xx->segs[0].u.c.radius); + Translate(&c1,c,xx->segs[0].u.c.a1+xx->segs[0].u.c.a0+xx->angle, + xx->segs[0].u.c.radius); + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); + tempSegs(0).color = xx->segs[0].color; + tempSegs(0).lineWidth = xx->segs[0].lineWidth; + tempSegs(0).type = SEG_CRVLIN; + tempSegs(0).u.c.center = c; + tempSegs(0).u.c.radius = xx->segs[0].u.c.radius; + if (ep) { + tempSegs(0).u.c.a0 = FindAngle(c,c0); + tempSegs(0).u.c.a1 = NormalizeAngle(FindAngle(c,pos)-tempSegs(0).u.c.a0); + } else { + tempSegs(0).u.c.a0 = FindAngle(c,pos); + tempSegs(0).u.c.a1 = NormalizeAngle(FindAngle(c,c1)-tempSegs(0).u.c.a0); + } + xx->segs[0].u.c.center = c; + if (ep) { + xx->segs[0].u.c.a0 = FindAngle(c,pos); + xx->segs[0].u.c.a1 = NormalizeAngle(FindAngle(c,c1)-xx->segs[0].u.c.a0); + } else { + xx->segs[0].u.c.a0 = FindAngle(c,c0); + xx->segs[0].u.c.a1 = NormalizeAngle(FindAngle(c,pos)-xx->segs[0].u.c.a0); + } + } + break; + case SEG_POLY: + case SEG_FILPOLY: + d = DIST_INF; + DIST_T dd; + BOOL_T onPoint = FALSE; +// BOOL_T closeSeg = FALSE; + coOrd end; + int polyInx = -1; + for ( int inx=0; inx<xx->segs[0].u.p.cnt-1; inx++ ) { + p0 = pos; + coOrd pl0,pl1; + REORIGIN(pl0,xx->segs[0].u.p.pts[inx].pt,xx->angle,xx->orig); + REORIGIN(pl1,xx->segs[0].u.p.pts[inx+1].pt,xx->angle,xx->orig); + dd = LineDistance( &p0, pl0, pl1 ); + if ( d > dd ) { + d = dd; + if (IsClose(FindDistance(pos,pl1))) { + polyInx = inx; + REORIGIN(pos,xx->segs[0].u.p.pts[inx].pt,xx->angle,xx->orig); + onPoint = TRUE; + break; + } else if (IsClose(FindDistance(pos,pl1))) { + polyInx = inx+1; + REORIGIN(pos,xx->segs[0].u.p.pts[inx+1].pt,xx->angle,xx->orig); + onPoint=TRUE; + break; } else { - Translate(&c0,c,xx->segs[0].u.c.a0+xx->angle,xx->segs[0].u.c.radius); - Translate(&c1,c,xx->segs[0].u.c.a1+xx->segs[0].u.c.a0+xx->angle,xx->segs[0].u.c.radius); - tempSegs(0).color = xx->segs[0].color; - tempSegs(0).width = xx->segs[0].width; - tempSegs_da.cnt = 1; - tempSegs(0).type = SEG_CRVLIN; - tempSegs(0).u.c.center = c; - tempSegs(0).u.c.radius = xx->segs[0].u.c.radius; - if (ep) { - tempSegs(0).u.c.a0 = FindAngle(c,c0); - tempSegs(0).u.c.a1 = NormalizeAngle(FindAngle(c,pos)-tempSegs(0).u.c.a0); - } else { - tempSegs(0).u.c.a0 = FindAngle(c,pos); - tempSegs(0).u.c.a1 = NormalizeAngle(FindAngle(c,c1)-tempSegs(0).u.c.a0); - } - xx->segs[0].u.c.center = c; - if (ep) { - xx->segs[0].u.c.a0 = FindAngle(c,pos); - xx->segs[0].u.c.a1 = NormalizeAngle(FindAngle(c,c1)-xx->segs[0].u.c.a0); - } else { - xx->segs[0].u.c.a0 = FindAngle(c,c0); - xx->segs[0].u.c.a1 = NormalizeAngle(FindAngle(c,pos)-xx->segs[0].u.c.a0); - } - } - break; - case SEG_POLY: - case SEG_FILPOLY: - d = DIST_INF; - DIST_T dd; - BOOL_T onPoint = FALSE; - BOOL_T closeSeg = FALSE; - coOrd end; - int polyInx = -1; - for ( int inx=0; inx<xx->segs[0].u.p.cnt-1; inx++ ) { - p0 = pos; - coOrd pl0,pl1; - REORIGIN(pl0,xx->segs[0].u.p.pts[inx].pt,xx->angle,xx->orig); - REORIGIN(pl1,xx->segs[0].u.p.pts[inx+1].pt,xx->angle,xx->orig); - dd = LineDistance( &p0, pl0, pl1 ); - if ( d > dd ) { - d = dd; - if (IsClose(FindDistance(pos,pl1))) { - polyInx = inx; - REORIGIN(pos,xx->segs[0].u.p.pts[inx].pt,xx->angle,xx->orig); - onPoint = TRUE; - break; - } else if (IsClose(FindDistance(pos,pl1))) { - polyInx = inx+1; - REORIGIN(pos,xx->segs[0].u.p.pts[inx+1].pt,xx->angle,xx->orig); - onPoint=TRUE; - break; - } else { - if (!IsClose(d)) continue; - polyInx = inx; - pos = p0; - break; - } - } + if (!IsClose(d)) { continue; } + polyInx = inx; + pos = p0; + break; } - //If Closed, look at closing line - if ( !onPoint && (xx->segs[0].u.p.polyType != POLYLINE)) { - coOrd pl0,pl1; - p0 = pos; - REORIGIN(pl0,xx->segs[0].u.p.pts[xx->segs[0].u.p.cnt-1].pt,xx->angle,xx->orig); - REORIGIN(pl1,xx->segs[0].u.p.pts[0].pt,xx->angle,xx->orig); - dd = LineDistance( &p0, pl0, pl1 ); - if (d > dd) { - d = dd; - if (IsClose(d)) { - polyInx = xx->segs[0].u.p.cnt-1; - closeSeg=TRUE; - pos = p0; - } - } + } + } + //If Closed, look at closing line + if ( !onPoint && (xx->segs[0].u.p.polyType != POLYLINE)) { + coOrd pl0,pl1; + p0 = pos; + REORIGIN(pl0,xx->segs[0].u.p.pts[xx->segs[0].u.p.cnt-1].pt,xx->angle,xx->orig); + REORIGIN(pl1,xx->segs[0].u.p.pts[0].pt,xx->angle,xx->orig); + dd = LineDistance( &p0, pl0, pl1 ); + if (d > dd) { + d = dd; + if (IsClose(d)) { + polyInx = xx->segs[0].u.p.cnt-1; +// closeSeg=TRUE; + pos = p0; } - //If Closed, split into a PolyLine - if (xx->segs[0].u.p.polyType != POLYLINE) { - if (!IsClose(d)) { - *leftover = NULL; - return FALSE; - } - end = pos; - REORIGIN(end,end,xx->angle,xx->orig); - - trkSeg_t temp; //Buffer for expanded array - temp.u.p.cnt = xx->segs[0].u.p.cnt + 2 - onPoint; - temp.u.p.pts = MyMalloc(temp.u.p.cnt*sizeof(pts_t)); - int j = 0; - temp.u.p.pts[j].pt = end; - temp.u.p.pts[j].pt_type = wPolyLineStraight; - j++; - /* After split */ - for (int i=polyInx+1;i<=xx->segs[0].u.p.cnt-1;i++,j++) { - temp.u.p.pts[j] = xx->segs[0].u.p.pts[i]; - REORIGIN(temp.u.p.pts[j].pt,temp.u.p.pts[j].pt,xx->angle,xx->orig); - } - /* Before split */ - for (int i=0;i<=polyInx;i++,j++) { - temp.u.p.pts[j] = xx->segs[0].u.p.pts[i]; - REORIGIN(temp.u.p.pts[j].pt,temp.u.p.pts[j].pt,xx->angle,xx->orig); - } - if (!onPoint) { - temp.u.p.pts[temp.u.p.cnt-1].pt = end; - } - temp.u.p.pts[temp.u.p.cnt-1].pt_type = wPolyLineStraight; + } + } + //If Closed, split into a PolyLine + if (xx->segs[0].u.p.polyType != POLYLINE) { + if (!IsClose(d)) { + *leftover = NULL; + return FALSE; + } + end = pos; + REORIGIN(end,end,xx->angle,xx->orig); - //Swap Pts Array into existing track - MyFree(xx->segs[0].u.p.pts); - xx->segs[0].u.p.pts = temp.u.p.pts; - xx->segs[0].u.p.cnt = temp.u.p.cnt; - xx->segs[0].u.p.polyType = POLYLINE; - break; + trkSeg_t temp; //Buffer for expanded array + temp.u.p.cnt = xx->segs[0].u.p.cnt + 2 - onPoint; + temp.u.p.pts = MyMalloc(temp.u.p.cnt*sizeof(pts_t)); + int j = 0; + temp.u.p.pts[j].pt = end; + temp.u.p.pts[j].pt_type = wPolyLineStraight; + j++; + /* After split */ + for (int i=polyInx+1; i<=xx->segs[0].u.p.cnt-1; i++,j++) { + temp.u.p.pts[j] = xx->segs[0].u.p.pts[i]; + REORIGIN(temp.u.p.pts[j].pt,temp.u.p.pts[j].pt,xx->angle,xx->orig); + } + /* Before split */ + for (int i=0; i<=polyInx; i++,j++) { + temp.u.p.pts[j] = xx->segs[0].u.p.pts[i]; + REORIGIN(temp.u.p.pts[j].pt,temp.u.p.pts[j].pt,xx->angle,xx->orig); + } + if (!onPoint) { + temp.u.p.pts[temp.u.p.cnt-1].pt = end; + } + temp.u.p.pts[temp.u.p.cnt-1].pt_type = wPolyLineStraight; + + //Swap Pts Array into existing track + MyFree(xx->segs[0].u.p.pts); + xx->segs[0].u.p.pts = temp.u.p.pts; + xx->segs[0].u.p.cnt = temp.u.p.cnt; + xx->segs[0].u.p.polyType = POLYLINE; + break; + } + //Check if on an end-point -> reject + if ((polyInx <= 0 || polyInx >= xx->segs[0].u.p.cnt-1) && onPoint ) { + *leftover = NULL; + return FALSE; + } + if (polyInx == 0 || (polyInx == 1 && onPoint )) { + //Between First End and Next -> Trim end + end = xx->segs[0].u.p.pts[0].pt; + REORIGIN(end,end,xx->angle,xx->orig); + if (onPoint) { + for (int i=0; i< xx->segs[0].u.p.cnt-1; i++) { + xx->segs[0].u.p.pts[i] = xx->segs[0].u.p.pts[i+1]; + REORIGIN(xx->segs[0].u.p.pts[i].pt,xx->segs[0].u.p.pts[i].pt,xx->angle, + xx->orig); + } + --xx->segs[0].u.p.cnt; + } else { + xx->segs[0].u.p.pts[0].pt = pos; + for (int i=1; i< xx->segs[0].u.p.cnt; i++) { + REORIGIN(xx->segs[0].u.p.pts[i].pt,xx->segs[0].u.p.pts[i].pt,xx->angle, + xx->orig); } - //Check if on an end-point -> reject - if ((polyInx <= 0 || polyInx >= xx->segs[0].u.p.cnt-1) && onPoint ) { - *leftover = NULL; - return FALSE; + } + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); + tempSegs(0).color = xx->segs[0].color; + tempSegs(0).lineWidth = xx->segs[0].lineWidth; + tempSegs(0).type = SEG_STRLIN; + tempSegs(0).u.l.pos[0] = pos; + tempSegs(0).u.l.pos[1] = end; + polyline_trim = TRUE; + new_last = FALSE; + } else if (polyInx == xx->segs[0].u.p.cnt-2) { + //Between second last and last -> Trim the other end + end = xx->segs[0].u.p.pts[xx->segs[0].u.p.cnt-1].pt; + REORIGIN(end,end,xx->angle,xx->orig); + if (onPoint) { + --xx->segs[0].u.p.cnt; + for (int i=0; i<xx->segs[0].u.p.cnt; i++) { + REORIGIN(xx->segs[0].u.p.pts[i].pt,xx->segs[0].u.p.pts[i].pt,xx->angle, + xx->orig); } - if (polyInx == 0 || (polyInx == 1 && onPoint )) { - //Between First End and Next -> Trim end - end = xx->segs[0].u.p.pts[0].pt; - REORIGIN(end,end,xx->angle,xx->orig); - if (onPoint) { - for (int i=0;i< xx->segs[0].u.p.cnt-1;i++) { - xx->segs[0].u.p.pts[i] = xx->segs[0].u.p.pts[i+1]; - REORIGIN(xx->segs[0].u.p.pts[i].pt,xx->segs[0].u.p.pts[i].pt,xx->angle,xx->orig); - } - --xx->segs[0].u.p.cnt; - } else { - xx->segs[0].u.p.pts[0].pt = pos; - for (int i=1;i< xx->segs[0].u.p.cnt;i++) { - REORIGIN(xx->segs[0].u.p.pts[i].pt,xx->segs[0].u.p.pts[i].pt,xx->angle,xx->orig); - } - } - tempSegs(0).color = xx->segs[0].color; - tempSegs(0).width = xx->segs[0].width; - tempSegs_da.cnt = 1; - tempSegs(0).type = SEG_STRLIN; - tempSegs(0).u.l.pos[0] = pos; - tempSegs(0).u.l.pos[1] = end; - polyline_trim = TRUE; - new_last = FALSE; - } else if (polyInx == xx->segs[0].u.p.cnt-2) { - //Between second last and last -> Trim the other end - end = xx->segs[0].u.p.pts[xx->segs[0].u.p.cnt-1].pt; - REORIGIN(end,end,xx->angle,xx->orig); - if (onPoint) { - --xx->segs[0].u.p.cnt; - for (int i=0;i<xx->segs[0].u.p.cnt;i++) { - REORIGIN(xx->segs[0].u.p.pts[i].pt,xx->segs[0].u.p.pts[i].pt,xx->angle,xx->orig); - } - } else { - xx->segs[0].u.p.pts[xx->segs[0].u.p.cnt-1].pt = pos; - for (int i=0;i<xx->segs[0].u.p.cnt;i++) { - REORIGIN(xx->segs[0].u.p.pts[i].pt,xx->segs[0].u.p.pts[i].pt,xx->angle,xx->orig); - } + } else { + xx->segs[0].u.p.pts[xx->segs[0].u.p.cnt-1].pt = pos; + for (int i=0; i<xx->segs[0].u.p.cnt; i++) { + REORIGIN(xx->segs[0].u.p.pts[i].pt,xx->segs[0].u.p.pts[i].pt,xx->angle, + xx->orig); + } + } + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); + tempSegs(0).color = xx->segs[0].color; + tempSegs(0).lineWidth = xx->segs[0].lineWidth; + tempSegs(0).type = SEG_STRLIN; + tempSegs(0).u.l.pos[0] = end; + tempSegs(0).u.l.pos[1] = pos; + polyline_trim = TRUE; + new_last = TRUE; + } else { + //Check that new line will have >=3 spots if not -> reject + if (xx->segs[0].u.p.cnt >3) { + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); + tempSegs(0).color = xx->segs[0].color; + tempSegs(0).lineWidth = xx->segs[0].lineWidth; + tempSegs(0).type = SEG_POLY; + tempSegs(0).u.p.polyType = POLYLINE; + if (1-ep) { + tempSegs(0).u.p.cnt = xx->segs[0].u.p.cnt - polyInx; + } else { + tempSegs(0).u.p.cnt = polyInx + 2 - onPoint; + } + tempSegs(0).u.p.pts = MyMalloc(tempSegs(0).u.p.cnt*sizeof(pts_t)); + int j = 0; + if (1-ep) { + tempSegs(0).u.p.pts[0].pt=pos; + tempSegs(0).u.p.pts[0].pt_type = wPolyLineStraight; + j = 1; + for (int i=polyInx+1; i<xx->segs[0].u.p.cnt; i++,j++) { + tempSegs(0).u.p.pts[j] = xx->segs[0].u.p.pts[i]; + REORIGIN(tempSegs(0).u.p.pts[j].pt,tempSegs(0).u.p.pts[j].pt,xx->angle, + xx->orig); } - tempSegs(0).color = xx->segs[0].color; - tempSegs(0).width = xx->segs[0].width; - tempSegs_da.cnt = 1; - tempSegs(0).type = SEG_STRLIN; - tempSegs(0).u.l.pos[0] = end; - tempSegs(0).u.l.pos[1] = pos; - polyline_trim = TRUE; - new_last = TRUE; } else { - //Check that new line will have >=3 spots if not -> reject - if (xx->segs[0].u.p.cnt >3) { - tempSegs(0).color = xx->segs[0].color; - tempSegs(0).width = xx->segs[0].width; - tempSegs_da.cnt = 1; - tempSegs(0).type = SEG_POLY; - tempSegs(0).u.p.polyType = POLYLINE; - if (1-ep) - tempSegs(0).u.p.cnt = xx->segs[0].u.p.cnt - polyInx; - else - tempSegs(0).u.p.cnt = polyInx + 2 - onPoint; - tempSegs(0).u.p.pts = MyMalloc(tempSegs(0).u.p.cnt*sizeof(pts_t)); - int j = 0; - if (1-ep) { - tempSegs(0).u.p.pts[0].pt=pos; - tempSegs(0).u.p.pts[0].pt_type = wPolyLineStraight; - j = 1; - for (int i=polyInx+1;i<xx->segs[0].u.p.cnt;i++,j++) { - tempSegs(0).u.p.pts[j] = xx->segs[0].u.p.pts[i]; - REORIGIN(tempSegs(0).u.p.pts[j].pt,tempSegs(0).u.p.pts[j].pt,xx->angle,xx->orig); - } - } else { - for (int i=0;i<=polyInx+1;i++,j++) { - tempSegs(0).u.p.pts[j] = xx->segs[0].u.p.pts[i]; - REORIGIN(tempSegs(0).u.p.pts[j].pt,tempSegs(0).u.p.pts[j].pt,xx->angle,xx->orig); - } - if (!onPoint) { - tempSegs(0).u.p.pts[tempSegs(0).u.p.cnt-1].pt = pos; - tempSegs(0).u.p.pts[tempSegs(0).u.p.cnt-1].pt_type = wPolyLineStraight; - } - } - } else { - *leftover = NULL; - return FALSE; + for (int i=0; i<=polyInx+1; i++,j++) { + tempSegs(0).u.p.pts[j] = xx->segs[0].u.p.pts[i]; + REORIGIN(tempSegs(0).u.p.pts[j].pt,tempSegs(0).u.p.pts[j].pt,xx->angle, + xx->orig); } - polyline_trim = TRUE; - new_last = 1-ep; - int new_cnt, old_cnt = xx->segs[0].u.p.cnt; - if (1-ep) - new_cnt = polyInx + 2 - onPoint; - else - new_cnt = xx->segs[0].u.p.cnt-polyInx; - pts_t * newpts = MyMalloc(new_cnt*sizeof(pts_t)); - int j = 0; - if (1-ep) { - for (int i = 0; i<polyInx+1; i++,j++) { - newpts[j] = xx->segs[0].u.p.pts[i]; - REORIGIN(newpts[j].pt,newpts[i].pt,xx->angle,xx->orig); - } - if (!onPoint) { - newpts[new_cnt-1].pt = pos; - newpts[new_cnt-1].pt_type = wPolyLineStraight; - } - } else { - newpts[0].pt = pos; - newpts[0].pt_type = wPolyLineStraight; - j = 1; - for (int i=polyInx+1;i<old_cnt;i++,j++) { - newpts[j] = xx->segs[0].u.p.pts[i]; - REORIGIN(newpts[j].pt,newpts[j].pt,xx->angle,xx->orig); - } + if (!onPoint) { + tempSegs(0).u.p.pts[tempSegs(0).u.p.cnt-1].pt = pos; + tempSegs(0).u.p.pts[tempSegs(0).u.p.cnt-1].pt_type = wPolyLineStraight; } - MyFree(xx->segs[0].u.p.pts); - xx->segs[0].u.p.cnt = new_cnt; - xx->segs[0].u.p.pts = newpts; } - break; - default: + } else { + *leftover = NULL; return FALSE; - } - *leftover = NULL; - if (tempSegs(0).type != -1) { - *leftover = MakeDrawFromSeg( zero, 0.0, &tempSegs(0) ); - struct extraDataDraw_t * yy = GET_EXTRA_DATA(*leftover, T_DRAW, extraDataDraw_t); - yy->lineType = xx->lineType; - if (tempSegs(0).type == SEG_POLY && tempSegs(0).u.p.pts) { - MyFree(tempSegs(0).u.p.pts); - tempSegs(0).u.p.cnt = 0; - tempSegs(0).u.p.pts = NULL; } + polyline_trim = TRUE; + new_last = 1-ep; + int new_cnt, old_cnt = xx->segs[0].u.p.cnt; + if (1-ep) { + new_cnt = polyInx + 2 - onPoint; + } else { + new_cnt = xx->segs[0].u.p.cnt-polyInx; + } + pts_t * newpts = MyMalloc(new_cnt*sizeof(pts_t)); + int j = 0; + if (1-ep) { + for (int i = 0; i<polyInx+1; i++,j++) { + newpts[j] = xx->segs[0].u.p.pts[i]; + REORIGIN(newpts[j].pt,newpts[i].pt,xx->angle,xx->orig); + } + if (!onPoint) { + newpts[new_cnt-1].pt = pos; + newpts[new_cnt-1].pt_type = wPolyLineStraight; + } + } else { + newpts[0].pt = pos; + newpts[0].pt_type = wPolyLineStraight; + j = 1; + for (int i=polyInx+1; i<old_cnt; i++,j++) { + newpts[j] = xx->segs[0].u.p.pts[i]; + REORIGIN(newpts[j].pt,newpts[j].pt,xx->angle,xx->orig); + } + } + MyFree(xx->segs[0].u.p.pts); + xx->segs[0].u.p.cnt = new_cnt; + xx->segs[0].u.p.pts = newpts; } + break; + default: + return FALSE; + } + *leftover = NULL; + if (tempSegs(0).type != -1) { + *leftover = MakeDrawFromSeg( zero, 0.0, &tempSegs(0) ); + struct extraDataDraw_t * yy = GET_EXTRA_DATA(*leftover, T_DRAW, + extraDataDraw_t); + yy->lineType = xx->lineType; + if (tempSegs(0).type == SEG_POLY && tempSegs(0).u.p.pts) { + MyFree(tempSegs(0).u.p.pts); + tempSegs(0).u.p.cnt = 0; + tempSegs(0).u.p.pts = NULL; + } + } - if (*leftover) { - //Polyline sets new_last to the end of the extra - if (polyline_trim && (ep != new_last)) { - *leftover = trk; - } + if (*leftover) { + //Polyline sets new_last to the end of the extra + if (polyline_trim && (ep != new_last)) { + *leftover = trk; } - xx->orig = zero; - xx->angle = 0.0; - ComputeDrawBoundingBox(trk); - *ep0 = 1-ep; - *ep1 = ep; - return TRUE; + } + xx->orig = zero; + xx->angle = 0.0; + ComputeDrawBoundingBox(trk); + *ep0 = 1-ep; + *ep1 = ep; + return TRUE; } static BOOL_T MakeParallelDraw( - track_p trk, - coOrd pos, - DIST_T sep, - DIST_T factor, - track_p * newTrkR, - coOrd * p0R, - coOrd * p1R, - BOOL_T track) + track_p trk, + coOrd pos, + DIST_T sep, + DIST_T factor, + track_p * newTrkR, + coOrd * p0R, + coOrd * p1R, + BOOL_T track) { - if (track) return FALSE; + if (track) { return FALSE; } struct extraDataDraw_t * xx = GET_EXTRA_DATA(trk, T_DRAW, extraDataDraw_t); ANGLE_T angle; @@ -2411,167 +2540,181 @@ static BOOL_T MakeParallelDraw( DYNARR_SET(trkSeg_t, tempSegs_da, 1); switch (xx->segs[0].type) { - case SEG_STRLIN: - angle = NormalizeAngle(FindAngle(xx->segs[0].u.l.pos[0],xx->segs[0].u.l.pos[1])+xx->angle); - if ( NormalizeAngle( FindAngle( xx->segs[0].u.l.pos[0], pos ) - angle ) < 180.0 ) - angle += 90; - else - angle -= 90; - coOrd p0,p1; - REORIGIN(p0,xx->segs[0].u.l.pos[0],xx->angle,xx->orig); - REORIGIN(p1,xx->segs[0].u.l.pos[1],xx->angle,xx->orig); - Translate(&p0,p0, angle, sep); - Translate(&p1,p1, angle, sep); - tempSegs(0).color = xx->segs[0].color; - tempSegs(0).width = xx->segs[0].width; - tempSegs_da.cnt = 1; - tempSegs(0).type = SEG_STRLIN; - tempSegs(0).u.l.pos[0] = p0; - tempSegs(0).u.l.pos[1] = p1; - if (newTrkR) { - *newTrkR = MakeDrawFromSeg( zero, 0.0, &tempSegs(0) ); - struct extraDataDraw_t * yy = GET_EXTRA_DATA(*newTrkR, T_DRAW, extraDataDraw_t); - yy->lineType = xx->lineType; - } + case SEG_STRLIN: + angle = NormalizeAngle(FindAngle(xx->segs[0].u.l.pos[0], + xx->segs[0].u.l.pos[1])+xx->angle); + if ( NormalizeAngle( FindAngle( xx->segs[0].u.l.pos[0], + pos ) - angle ) < 180.0 ) { + angle += 90; + } else { + angle -= 90; + } + coOrd p0,p1; + REORIGIN(p0,xx->segs[0].u.l.pos[0],xx->angle,xx->orig); + REORIGIN(p1,xx->segs[0].u.l.pos[1],xx->angle,xx->orig); + Translate(&p0,p0, angle, sep); + Translate(&p1,p1, angle, sep); + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); + tempSegs(0).color = xx->segs[0].color; + tempSegs(0).lineWidth = xx->segs[0].lineWidth; + tempSegs(0).type = SEG_STRLIN; + tempSegs(0).u.l.pos[0] = p0; + tempSegs(0).u.l.pos[1] = p1; + if (newTrkR) { + *newTrkR = MakeDrawFromSeg( zero, 0.0, &tempSegs(0) ); + struct extraDataDraw_t * yy = GET_EXTRA_DATA(*newTrkR, T_DRAW, extraDataDraw_t); + yy->lineType = xx->lineType; + } - if ( p0R ) *p0R = p0; - if ( p1R ) *p1R = p1; - return TRUE; - break; - case SEG_CRVLIN: - case SEG_FILCRCL:; - coOrd c; - REORIGIN(c, xx->segs[0].u.c.center, xx->angle, xx->orig); - rad = FindDistance( pos, c ); - if ( rad > xx->segs[0].u.c.radius ) - rad = xx->segs[0].u.c.radius + sep; - else - rad = xx->segs[0].u.c.radius - sep; - tempSegs(0).color = xx->segs[0].color; - tempSegs(0).width = xx->segs[0].width; - tempSegs_da.cnt = 1; - tempSegs(0).type = SEG_CRVLIN; - tempSegs(0).u.c.center = c; - tempSegs(0).u.c.radius = rad; - tempSegs(0).u.c.a0 = xx->segs[0].u.c.a0 + xx->angle; - tempSegs(0).u.c.a1 = xx->segs[0].u.c.a1; - if (newTrkR) { - *newTrkR = MakeDrawFromSeg( zero, 0.0, &tempSegs(0) ); - struct extraDataDraw_t * yy = GET_EXTRA_DATA(*newTrkR, T_DRAW, extraDataDraw_t); - yy->lineType = xx->lineType; - } - if ( p0R ) PointOnCircle( p0R, xx->segs[0].u.c.center, rad, xx->segs[0].u.c.a0 ); - if ( p1R ) PointOnCircle( p1R, xx->segs[0].u.c.center, rad, xx->segs[0].u.c.a0+xx->segs[0].u.c.a1 ); - return TRUE; - break; - case SEG_POLY: - case SEG_FILPOLY: - pos.x -= xx->orig.x; - pos.y -= xx->orig.y; - Rotate( &pos, zero, -xx->angle ); - coOrd p = pos; - int inx2; - angle = NormalizeAngle(GetAngleSegs(1,&xx->segs[0],&p,NULL,NULL,NULL,&inx2,NULL)+xx->angle); - if ( NormalizeAngle( FindAngle( p, pos ) - angle ) < 180.0 ) { - angle = +90.0; + if ( p0R ) { *p0R = p0; } + if ( p1R ) { *p1R = p1; } + return TRUE; + break; + case SEG_CRVLIN: + case SEG_FILCRCL:; + coOrd c; + REORIGIN(c, xx->segs[0].u.c.center, xx->angle, xx->orig); + rad = FindDistance( pos, c ); + if ( rad > xx->segs[0].u.c.radius ) { + rad = xx->segs[0].u.c.radius + sep; + } else { + rad = xx->segs[0].u.c.radius - sep; + } + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); + tempSegs(0).color = xx->segs[0].color; + tempSegs(0).lineWidth = xx->segs[0].lineWidth; + tempSegs(0).type = SEG_CRVLIN; + tempSegs(0).u.c.center = c; + tempSegs(0).u.c.radius = rad; + tempSegs(0).u.c.a0 = xx->segs[0].u.c.a0 + xx->angle; + tempSegs(0).u.c.a1 = xx->segs[0].u.c.a1; + if (newTrkR) { + *newTrkR = MakeDrawFromSeg( zero, 0.0, &tempSegs(0) ); + struct extraDataDraw_t * yy = GET_EXTRA_DATA(*newTrkR, T_DRAW, extraDataDraw_t); + yy->lineType = xx->lineType; + } + if ( p0R ) { PointOnCircle( p0R, xx->segs[0].u.c.center, rad, xx->segs[0].u.c.a0 ); } + if ( p1R ) { PointOnCircle( p1R, xx->segs[0].u.c.center, rad, xx->segs[0].u.c.a0+xx->segs[0].u.c.a1 ); } + return TRUE; + break; + case SEG_POLY: + case SEG_FILPOLY: + pos.x -= xx->orig.x; + pos.y -= xx->orig.y; + Rotate( &pos, zero, -xx->angle ); + coOrd p = pos; + int inx2; + angle = NormalizeAngle(GetAngleSegs(1,&xx->segs[0],&p,NULL,NULL,NULL,&inx2, + NULL)+xx->angle); + if ( NormalizeAngle( FindAngle( p, pos ) - angle ) < 180.0 ) { + angle = +90.0; + } else { + angle = -90.0; + } + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); + tempSegs(0).color = xx->segs[0].color; + tempSegs(0).lineWidth = xx->segs[0].lineWidth; + tempSegs(0).type = SEG_POLY; + tempSegs(0).u.p.polyType = xx->segs[0].type==SEG_POLY?xx->segs[0].u.p.polyType: + POLYLINE; + tempSegs(0).u.p.pts = memdup( xx->segs[0].u.p.pts, + xx->segs[0].u.p.cnt*sizeof (pts_t) ); + tempSegs(0).u.p.cnt = xx->segs[0].u.p.cnt; + ANGLE_T a,b; + for (int i=0; i<xx->segs[0].u.p.cnt; i++) { + REORIGIN(tempSegs(0).u.p.pts[i].pt,tempSegs(0).u.p.pts[i].pt,xx->angle, + xx->orig); + } + for (int i=0; i<xx->segs[0].u.p.cnt; i++) { + if (xx->segs[0].u.p.polyType == POLYLINE) { + if (i==0) { + a = FindAngle(tempSegs(0).u.p.pts[0].pt,tempSegs(0).u.p.pts[1].pt); + b = 0; + } else if (i==xx->segs[0].u.p.cnt-1) { + a = NormalizeAngle(FindAngle(tempSegs(0).u.p.pts[i].pt, + tempSegs(0).u.p.pts[i-1].pt)+180.0); + b = 0; + } else { + a = FindAngle(tempSegs(0).u.p.pts[i].pt,tempSegs(0).u.p.pts[i+1].pt); + b = DifferenceBetweenAngles(a,FindAngle(tempSegs(0).u.p.pts[i].pt, + tempSegs(0).u.p.pts[i-1].pt)+180.0)/2; + a = a + b; + } } else { - angle = -90.0; - } - tempSegs(0).color = xx->segs[0].color; - tempSegs(0).width = xx->segs[0].width; - tempSegs_da.cnt = 1; - tempSegs(0).type = SEG_POLY; - tempSegs(0).u.p.polyType = xx->segs[0].type==SEG_POLY?xx->segs[0].u.p.polyType:POLYLINE; - tempSegs(0).u.p.pts = memdup( xx->segs[0].u.p.pts, xx->segs[0].u.p.cnt*sizeof (pts_t) ); - tempSegs(0).u.p.cnt = xx->segs[0].u.p.cnt; - ANGLE_T a,b; - for (int i=0;i<xx->segs[0].u.p.cnt;i++) { - REORIGIN(tempSegs(0).u.p.pts[i].pt,tempSegs(0).u.p.pts[i].pt,xx->angle, xx->orig); - } - for (int i=0;i<xx->segs[0].u.p.cnt;i++) { - if (xx->segs[0].u.p.polyType == POLYLINE) { - if (i==0) { - a = FindAngle(tempSegs(0).u.p.pts[0].pt,tempSegs(0).u.p.pts[1].pt); - b = 0; - } else if (i==xx->segs[0].u.p.cnt-1) { - a = NormalizeAngle(FindAngle(tempSegs(0).u.p.pts[i].pt,tempSegs(0).u.p.pts[i-1].pt)+180.0); - b = 0; - } else { - a = FindAngle(tempSegs(0).u.p.pts[i].pt,tempSegs(0).u.p.pts[i+1].pt); - b = DifferenceBetweenAngles(a,FindAngle(tempSegs(0).u.p.pts[i].pt,tempSegs(0).u.p.pts[i-1].pt)+180.0)/2; - a = a + b; - } + if (i==0) { + a = FindAngle(tempSegs(0).u.p.pts[i].pt,tempSegs(0).u.p.pts[i+1].pt); + b = DifferenceBetweenAngles(a,FindAngle(tempSegs(0).u.p.pts[i].pt, + tempSegs(0).u.p.pts[xx->segs[0].u.p.cnt-1].pt)+180.0)/2; + a = a+b; + } else if (i==xx->segs[0].u.p.cnt-1) { + a = FindAngle(tempSegs(0).u.p.pts[i].pt,tempSegs(0).u.p.pts[0].pt); + b = DifferenceBetweenAngles(a,FindAngle(tempSegs(0).u.p.pts[i].pt, + tempSegs(0).u.p.pts[i-1].pt)+180.0)/2; + a = a+b; } else { - if (i==0) { - a = FindAngle(tempSegs(0).u.p.pts[i].pt,tempSegs(0).u.p.pts[i+1].pt); - b = DifferenceBetweenAngles(a,FindAngle(tempSegs(0).u.p.pts[i].pt,tempSegs(0).u.p.pts[xx->segs[0].u.p.cnt-1].pt)+180.0)/2; - a = a+b; - } else if (i==xx->segs[0].u.p.cnt-1) { - a = FindAngle(tempSegs(0).u.p.pts[i].pt,tempSegs(0).u.p.pts[0].pt); - b = DifferenceBetweenAngles(a,FindAngle(tempSegs(0).u.p.pts[i].pt,tempSegs(0).u.p.pts[i-1].pt)+180.0)/2; - a = a+b; - } else { - a = FindAngle(tempSegs(0).u.p.pts[i].pt,tempSegs(0).u.p.pts[i+1].pt); - b = DifferenceBetweenAngles(a,FindAngle(tempSegs(0).u.p.pts[i].pt,tempSegs(0).u.p.pts[i-1].pt)+180.0)/2; - a = a+b; - } + a = FindAngle(tempSegs(0).u.p.pts[i].pt,tempSegs(0).u.p.pts[i+1].pt); + b = DifferenceBetweenAngles(a,FindAngle(tempSegs(0).u.p.pts[i].pt, + tempSegs(0).u.p.pts[i-1].pt)+180.0)/2; + a = a+b; } - - Translate(&tempSegs(0).u.p.pts[i].pt,tempSegs(0).u.p.pts[i].pt,a+angle,fabs(sep/cos(D2R(b)))); } - if (newTrkR) { - *newTrkR = MakeDrawFromSeg( zero, 0.0, &tempSegs(0) ); - struct extraDataDraw_t * yy = GET_EXTRA_DATA(*newTrkR, T_DRAW, extraDataDraw_t); - yy->lineType = xx->lineType; - if (tempSegs(0).u.p.pts) MyFree(tempSegs(0).u.p.pts); - } - if (p0R) *p0R = tempSegs(0).u.p.pts[0].pt; - if (p1R) *p1R = tempSegs(0).u.p.pts[tempSegs(0).u.p.cnt-1].pt; - return TRUE; - break; - default: + + Translate(&tempSegs(0).u.p.pts[i].pt,tempSegs(0).u.p.pts[i].pt,a+angle, + fabs(sep/cos(D2R(b)))); + } + if (newTrkR) { + *newTrkR = MakeDrawFromSeg( zero, 0.0, &tempSegs(0) ); + struct extraDataDraw_t * yy = GET_EXTRA_DATA(*newTrkR, T_DRAW, extraDataDraw_t); + yy->lineType = xx->lineType; + if (tempSegs(0).u.p.pts) { MyFree(tempSegs(0).u.p.pts); } + } + if (p0R) { *p0R = tempSegs(0).u.p.pts[0].pt; } + if (p1R) { *p1R = tempSegs(0).u.p.pts[tempSegs(0).u.p.cnt-1].pt; } + return TRUE; + break; + default: return FALSE; } return FALSE; } static trackCmd_t drawCmds = { - "DRAW", - DrawDraw, - DistanceDraw, - DescribeDraw, - DeleteDraw, - WriteDraw, - ReadDraw, - MoveDraw, - RotateDraw, - RescaleDraw, - NULL, - GetAngleDraw, /* getAngle */ - SplitDraw, /* split */ - NULL, /* traverse */ - EnumerateDraw, - NULL, /* redraw */ - NULL, /* trim */ - NULL, /* merge */ - ModifyDraw, - NULL, /* getLength */ - GetParamsDraw, /* getTrackParams */ - NULL, /* moveEndPt */ - QueryDraw, /* query */ - UngroupDraw, - FlipDraw, - NULL, - NULL, - NULL, - MakeParallelDraw, /*Parallel*/ - NULL, - NULL, /*MakeSegs*/ - ReplayDraw, - StoreDraw, - NULL, - CompareDraw - }; + "DRAW", + DrawDraw, + DistanceDraw, + DescribeDraw, + DeleteDraw, + WriteDraw, + ReadDraw, + MoveDraw, + RotateDraw, + RescaleDraw, + NULL, + GetAngleDraw, /* getAngle */ + SplitDraw, /* split */ + NULL, /* traverse */ + EnumerateDraw, + NULL, /* redraw */ + NULL, /* trim */ + NULL, /* merge */ + ModifyDraw, + NULL, /* getLength */ + GetParamsDraw, /* getTrackParams */ + NULL, /* moveEndPt */ + QueryDraw, /* query */ + UngroupDraw, + FlipDraw, + NULL, + NULL, + NULL, + MakeParallelDraw, /*Parallel*/ + NULL, + NULL, /*MakeSegs*/ + ReplayDraw, + StoreDraw, + NULL, + CompareDraw +}; EXPORT BOOL_T OnTableEdgeEndPt( track_p trk, coOrd * pos ) { @@ -2581,11 +2724,12 @@ EXPORT BOOL_T OnTableEdgeEndPt( track_p trk, coOrd * pos ) ignoredTableEdge = trk; if ((trk1 = OnTrack( &pos1, FALSE, FALSE )) != NULL && - GetTrkType(trk1) == T_DRAW) { + GetTrkType(trk1) == T_DRAW) { ignoredTableEdge = NULL; xx = GET_EXTRA_DATA(trk1, T_DRAW, extraDataDraw_t); - if (xx->segCnt < 1) + if (xx->segCnt < 1) { return FALSE; + } if (xx->segs[0].type == SEG_TBLEDGE) { if ( IsClose( FindDistance( *pos, xx->segs[0].u.l.pos[0] ) ) ) { *pos = xx->segs[0].u.l.pos[0]; @@ -2607,8 +2751,9 @@ EXPORT BOOL_T GetClosestEndPt( track_p trk, coOrd * pos) if (GetTrkType(trk) == T_DRAW) { ignoredTableEdge = NULL; xx = GET_EXTRA_DATA(trk, T_DRAW, extraDataDraw_t); - if (xx->segCnt < 1) + if (xx->segCnt < 1) { return FALSE; + } DIST_T dd0,dd1; coOrd p00,p0,p1; p00 = *pos; @@ -2617,26 +2762,28 @@ EXPORT BOOL_T GetClosestEndPt( track_p trk, coOrd * pos) p00.x -= xx->orig.x; p00.y -= xx->orig.y; switch (xx->segs[0].type) { - case SEG_CRVLIN: - PointOnCircle( &p0, xx->segs[0].u.c.center, fabs(xx->segs[0].u.c.radius), xx->segs[0].u.c.a0 ); - dd0 = FindDistance( p00, p0); - PointOnCircle( &p1, xx->segs[0].u.c.center, fabs(xx->segs[0].u.c.radius), xx->segs[0].u.c.a0 + xx->segs[0].u.c.a1); - dd1 = FindDistance( p00, p1); + case SEG_CRVLIN: + PointOnCircle( &p0, xx->segs[0].u.c.center, fabs(xx->segs[0].u.c.radius), + xx->segs[0].u.c.a0 ); + dd0 = FindDistance( p00, p0); + PointOnCircle( &p1, xx->segs[0].u.c.center, fabs(xx->segs[0].u.c.radius), + xx->segs[0].u.c.a0 + xx->segs[0].u.c.a1); + dd1 = FindDistance( p00, p1); break; - case SEG_STRLIN: - dd0 = FindDistance( p00, xx->segs[0].u.l.pos[0]); - p0 = xx->segs[0].u.l.pos[0]; - dd1 = FindDistance( p00, xx->segs[0].u.l.pos[1]); - p1 = xx->segs[0].u.l.pos[1]; + case SEG_STRLIN: + dd0 = FindDistance( p00, xx->segs[0].u.l.pos[0]); + p0 = xx->segs[0].u.l.pos[0]; + dd1 = FindDistance( p00, xx->segs[0].u.l.pos[1]); + p1 = xx->segs[0].u.l.pos[1]; break; - case SEG_BEZLIN: - dd0 = FindDistance( p00, xx->segs[0].u.b.pos[0]); - p0 = xx->segs[0].u.b.pos[0]; - dd1 = FindDistance( p00, xx->segs[0].u.b.pos[3]); - p1 = xx->segs[0].u.b.pos[3]; + case SEG_BEZLIN: + dd0 = FindDistance( p00, xx->segs[0].u.b.pos[0]); + p0 = xx->segs[0].u.b.pos[0]; + dd1 = FindDistance( p00, xx->segs[0].u.b.pos[3]); + p1 = xx->segs[0].u.b.pos[3]; break; - default: - return FALSE; + default: + return FALSE; } p0.x += xx->orig.x; p0.y += xx->orig.y; @@ -2651,7 +2798,7 @@ EXPORT BOOL_T GetClosestEndPt( track_p trk, coOrd * pos) p1 = xx->segs[0].u.b.pos[3]; dd0 = FindDistance(p00,p0); dd1 = FindDistance(p00,p1); - } else return FALSE; + } else { return FALSE; } if (dd0>dd1) { * pos = p1; return TRUE; @@ -2666,23 +2813,24 @@ EXPORT BOOL_T GetClosestEndPt( track_p trk, coOrd * pos) static drawContext_t drawCmdContext = { - InfoMessage, - DoRedraw, - &mainD, - OP_LINE }; + InfoMessage, + DoRedraw, + &mainD, + OP_LINE +}; static wIndex_t benchChoice; static wIndex_t benchOrient; static wIndex_t dimArrowSize; wDrawColor lineColor = 1; -long lineWidth = 0; -static wDrawColor benchColor; +LWIDTH_T lineWidth = 0; +wDrawColor benchColor; static paramData_t drawPLs[] = { #define drawLineWidthPD (drawPLs[0]) - { PD_LONG, &drawCmdContext.line_Width, "linewidth", PDO_NORECORD, &i100_100, N_("Line Width") }, + { PD_FLOAT, &lineWidth, "linewidth", PDO_NORECORD, &r100_100, N_("Line Width") }, #define drawColorPD (drawPLs[1]) { PD_COLORLIST, &lineColor, "linecolor", PDO_NORECORD, NULL, N_("Color") }, #define drawBenchColorPD (drawPLs[2]) @@ -2690,9 +2838,9 @@ static paramData_t drawPLs[] = { #define drawBenchChoicePD (drawPLs[3]) #ifdef WINDOWS { PD_DROPLIST, &benchChoice, "benchlist", PDO_NOPREF|PDO_NORECORD|PDO_LISTINDEX, I2VP(120), N_("Lumber Type") }, -#else - { PD_DROPLIST, &benchChoice, "benchlist", PDO_NOPREF|PDO_NORECORD|PDO_LISTINDEX, I2VP(145), N_("Lumber Type") }, -#endif +#else + { PD_DROPLIST, &benchChoice, "benchlist", PDO_NOPREF|PDO_NORECORD|PDO_LISTINDEX, I2VP(145), N_("Lumber Type") }, +#endif #define drawBenchOrientPD (drawPLs[4]) #ifdef WINDOWS { PD_DROPLIST, &benchOrient, "benchorient", PDO_NOPREF|PDO_NORECORD|PDO_LISTINDEX, I2VP(45), "", 0 }, @@ -2716,27 +2864,28 @@ static paramData_t drawPLs[] = { static paramGroup_t drawPG = { "draw", 0, drawPLs, COUNT( drawPLs ) }; static char * objectName[] = { - N_("Straight"), - N_("Dimension"), - N_("Lumber"), - N_("Table Edge"), - N_("Curved"), - N_("Curved"), - N_("Curved"), - N_("Curved"), - N_("Circle"), - N_("Circle"), - N_("Circle"), - N_("Box"), - N_("Polygon"), - N_("Filled Circle"), - N_("Filled Circle"), - N_("Filled Circle"), - N_("Filled Box"), - N_("Filled Polygon"), - N_("Bezier Line"), - N_("Polyline"), - NULL}; + N_("Straight"), + N_("Dimension"), + N_("Lumber"), + N_("Table Edge"), + N_("Curved"), + N_("Curved"), + N_("Curved"), + N_("Curved"), + N_("Circle"), + N_("Circle"), + N_("Circle"), + N_("Box"), + N_("Polygon"), + N_("Filled Circle"), + N_("Filled Circle"), + N_("Filled Circle"), + N_("Filled Box"), + N_("Filled Polygon"), + N_("Bezier Line"), + N_("Polyline"), + NULL +}; static STATUS_T CmdDraw( wAction_t action, coOrd pos ) @@ -2819,11 +2968,14 @@ static STATUS_T CmdDraw( wAction_t action, coOrd pos ) labels[0] = N_("Lumber Type"); labels[1] = ""; labels[2] = N_("Color"); - if ( wListGetCount( (wList_p)drawBenchChoicePD.control ) == 0 ) - BenchLoadLists( (wList_p)drawBenchChoicePD.control, (wList_p)drawBenchOrientPD.control ); + if ( wListGetCount( (wList_p)drawBenchChoicePD.control ) == 0 ) { + BenchLoadLists( (wList_p)drawBenchChoicePD.control, + (wList_p)drawBenchOrientPD.control ); + } ParamLoadControls( &drawPG ); - BenchUpdateOrientationList( VP2L(wListGetItemContext( (wList_p)drawBenchChoicePD.control, benchChoice )), (wList_p)drawBenchOrientPD.control ); + BenchUpdateOrientationList( VP2L(wListGetItemContext( (wList_p) + drawBenchChoicePD.control, benchChoice )), (wList_p)drawBenchOrientPD.control ); wListSetIndex( (wList_p)drawBenchOrientPD.control, benchOrient ); InfoSubstituteControls( controls, labels ); drawBenchColorPD.option &= ~PDO_NORECORD; @@ -2853,7 +3005,7 @@ static STATUS_T CmdDraw( wAction_t action, coOrd pos ) infoSubst = FALSE; } ParamGroupRecord( &drawPG ); - if (drawCmdContext.Op == OP_BEZLIN) return CmdBezCurve(act2, pos); + if (drawCmdContext.Op == OP_BEZLIN) { return CmdBezCurve(act2, pos); } DrawGeomMouse( C_START, pos, &drawCmdContext); return C_CONTINUE; @@ -2864,33 +3016,34 @@ static STATUS_T CmdDraw( wAction_t action, coOrd pos ) return CmdBezCurve(act2, pos); } if ( drawCmdContext.Op == OP_BENCH ) { - drawCmdContext.benchOption = GetBenchData( VP2L(wListGetItemContext((wList_p)drawBenchChoicePD.control, benchChoice )), benchOrient ); - drawCmdContext.Color = benchColor; + drawCmdContext.benchOption = GetBenchData( VP2L(wListGetItemContext(( + wList_p)drawBenchChoicePD.control, benchChoice )), benchOrient ); + lineColor = benchColor; } else if ( drawCmdContext.Op == OP_DIMLINE ) { - drawCmdContext.Color = wDrawColorBlack; + lineColor = wDrawColorBlack; drawCmdContext.benchOption = dimArrowSize; } else if ( drawCmdContext.Op == OP_TBLEDGE ) { - drawCmdContext.Color = wDrawColorBlack; + lineColor = wDrawColorBlack; } else { - drawCmdContext.Color = lineColor; + lineColor = lineColor; } if ( infoSubst ) { InfoSubstituteControls( NULL, NULL ); infoSubst = FALSE; } - /* no break */ + /* no break */ case wActionLDrag: ParamLoadData( &drawPG ); - /* no break */ + /* no break */ case wActionMove: case wActionRDown: case wActionRDrag: - if (drawCmdContext.Op == OP_BEZLIN) return CmdBezCurve(act2, pos); + if (drawCmdContext.Op == OP_BEZLIN) { return CmdBezCurve(act2, pos); } return DrawGeomMouse( action, pos, &drawCmdContext); case wActionLUp: case wActionRUp: - if (drawCmdContext.Op == OP_BEZLIN) return CmdBezCurve(act2, pos); + if (drawCmdContext.Op == OP_BEZLIN) { return CmdBezCurve(act2, pos); } drawCmdContext.show = TRUE; int rc = DrawGeomMouse( action, pos, &drawCmdContext); // Put up text entry boxes ready for updates if the result was continue @@ -2944,12 +3097,14 @@ static STATUS_T CmdDraw( wAction_t action, coOrd pos ) controls[1] = drawAnglePD.control; controls[2] = NULL; labels[0] = N_("Seg Length"); - if (drawCmdContext.Op == OP_LINE || drawCmdContext.Op == OP_BENCH || drawCmdContext.Op == OP_TBLEDGE) + if (drawCmdContext.Op == OP_LINE || drawCmdContext.Op == OP_BENCH + || drawCmdContext.Op == OP_TBLEDGE) { labels[1] = N_("Angle"); - else if (drawCmdContext.index > 0 ) + } else if (drawCmdContext.index > 0 ) { labels[1] = N_("Rel Angle"); - else + } else { labels[1] = N_("Angle"); + } ParamLoadControls( &drawPG ); InfoSubstituteControls( controls, labels ); drawLengthPD.option &= ~PDO_NORECORD; @@ -2977,29 +3132,29 @@ static STATUS_T CmdDraw( wAction_t action, coOrd pos ) case C_CANCEL: InfoSubstituteControls( NULL, NULL ); - if (drawCmdContext.Op == OP_BEZLIN) return CmdBezCurve(act2, pos); + if (drawCmdContext.Op == OP_BEZLIN) { return CmdBezCurve(act2, pos); } return DrawGeomMouse( action, pos, &drawCmdContext); case C_TEXT: - if (drawCmdContext.Op == OP_BEZLIN) return CmdBezCurve(action, pos); + if (drawCmdContext.Op == OP_BEZLIN) { return CmdBezCurve(action, pos); } return DrawGeomMouse( action, pos, &drawCmdContext); case C_OK: - if (drawCmdContext.Op == OP_BEZLIN) return CmdBezCurve(act2, pos); + if (drawCmdContext.Op == OP_BEZLIN) { return CmdBezCurve(act2, pos); } return DrawGeomMouse( (0x0D<<8|wActionText), pos, &drawCmdContext); case C_CONFIRM: - if (drawCmdContext.Op == OP_BEZLIN) return CmdBezCurve(act2, pos); + if (drawCmdContext.Op == OP_BEZLIN) { return CmdBezCurve(act2, pos); } return DrawGeomMouse( (0x0D<<8|wActionText), pos, &drawCmdContext); case C_FINISH: - if (drawCmdContext.Op == OP_BEZLIN) return CmdBezCurve(act2, pos); + if (drawCmdContext.Op == OP_BEZLIN) { return CmdBezCurve(act2, pos); } return DrawGeomMouse( (0x0D<<8|wActionText), pos, &drawCmdContext); - /*DrawOk( NULL );*/ + /*DrawOk( NULL );*/ case C_REDRAW: - if (drawCmdContext.Op == OP_BEZLIN) return CmdBezCurve(act2, pos); + if (drawCmdContext.Op == OP_BEZLIN) { return CmdBezCurve(act2, pos); } return DrawGeomMouse( action, pos, &drawCmdContext); case C_CMDMENU: - if (drawCmdContext.Op == OP_BEZLIN) return C_CONTINUE; + if (drawCmdContext.Op == OP_BEZLIN) { return C_CONTINUE; } return DrawGeomMouse( action, pos, &drawCmdContext); default: @@ -3007,84 +3162,88 @@ static STATUS_T CmdDraw( wAction_t action, coOrd pos ) } } -#include "bitmaps/straight-line.xpm" -#include "bitmaps/dimension.xpm" -#include "bitmaps/benchwork.xpm" -#include "bitmaps/table-edge.xpm" +#include "bitmaps/straight-line.xpm3" +#include "bitmaps/dimension.xpm3" +#include "bitmaps/benchwork.xpm3" +#include "bitmaps/table-edge.xpm3" -#include "bitmaps/curved-line-end.xpm" -#include "bitmaps/curved-line-tangent.xpm" -#include "bitmaps/curved-line-middle.xpm" -#include "bitmaps/curved-line-chord.xpm" +#include "bitmaps/curved-line-end.xpm3" +#include "bitmaps/curved-line-tangent.xpm3" +#include "bitmaps/curved-line-middle.xpm3" +#include "bitmaps/curved-line-chord.xpm3" /*#include "bitmaps/dcircle1.xpm"*/ -#include "bitmaps/circle-line-center.xpm" -#include "bitmaps/circle-line-tangent.xpm" +#include "bitmaps/circle-line-center.xpm3" +#include "bitmaps/circle-line-tangent.xpm3" /*#include "bitmaps/dflcrcl1.xpm"*/ -#include "bitmaps/circle-filled-center.xpm" -#include "bitmaps/circle-filled-tangent.xpm" +#include "bitmaps/circle-filled-center.xpm3" +#include "bitmaps/circle-filled-tangent.xpm3" -#include "bitmaps/box.xpm" -#include "bitmaps/filled-box.xpm" -#include "bitmaps/polygon.xpm" -#include "bitmaps/filled-polygon.xpm" -#include "bitmaps/bezier-line.xpm" -#include "bitmaps/polyline.xpm" +#include "bitmaps/box.xpm3" +#include "bitmaps/filled-box.xpm3" +#include "bitmaps/polygon.xpm3" +#include "bitmaps/filled-polygon.xpm3" +#include "bitmaps/bezier-line.xpm3" +#include "bitmaps/polyline.xpm3" typedef struct { - char ***xpm; - int OP; - char * shortName; - char * cmdName; - char * helpKey; - long acclKey; - } drawData_t; + char ***xpm; + int OP; + char * shortName; + char * cmdName; + char * helpKey; + long acclKey; +} drawData_t; static drawData_t dlineCmds[] = { - { straight_line_xpm, OP_LINE, N_("Line"), N_("Draw Line"), "cmdDrawLine", ACCL_DRAWLINE }, - { dimension_xpm, OP_DIMLINE, N_("Dimension Line"), N_("Draw Dimension Line"), "cmdDrawDimLine", ACCL_DRAWDIMLINE }, - { benchwork_xpm, OP_BENCH, N_("Benchwork"), N_("Draw Benchwork"), "cmdDrawBench", ACCL_DRAWBENCH }, - { table_edge_xpm, OP_TBLEDGE, N_("Table Edge"), N_("Draw Table Edge"), "cmdDrawTableEdge", ACCL_DRAWTBLEDGE } }; + { straight_line_xpm3, OP_LINE, N_("Line"), N_("Draw Line"), "cmdDrawLine", ACCL_DRAWLINE }, + { dimension_xpm3, OP_DIMLINE, N_("Dimension Line"), N_("Draw Dimension Line"), "cmdDrawDimLine", ACCL_DRAWDIMLINE }, + { benchwork_xpm3, OP_BENCH, N_("Benchwork"), N_("Draw Benchwork"), "cmdDrawBench", ACCL_DRAWBENCH }, + { table_edge_xpm3, OP_TBLEDGE, N_("Table Edge"), N_("Draw Table Edge"), "cmdDrawTableEdge", ACCL_DRAWTBLEDGE } +}; static drawData_t dcurveCmds[] = { - { curved_line_end_xpm, OP_CURVE1, N_("Curve End"), N_("Draw Curve from End"), "cmdDrawCurveEndPt", ACCL_DRAWCURVE1 }, - { curved_line_tangent_xpm, OP_CURVE2, N_("Curve Tangent"), N_("Draw Curve from Tangent"), "cmdDrawCurveTangent", ACCL_DRAWCURVE2 }, - { curved_line_middle_xpm, OP_CURVE3, N_("Curve Center"), N_("Draw Curve from Center"), "cmdDrawCurveCenter", ACCL_DRAWCURVE3 }, - { curved_line_chord_xpm, OP_CURVE4, N_("Curve Chord"), N_("Draw Curve from Chord"), "cmdDrawCurveChord", ACCL_DRAWCURVE4 }, - { bezier_line_xpm, OP_BEZLIN, N_("Bezier Curve"), N_("Draw Bezier"), "cmdDrawBezierCurve", ACCL_DRAWBEZLINE } }; + { curved_line_end_xpm3, OP_CURVE1, N_("Curve End"), N_("Draw Curve from End"), "cmdDrawCurveEndPt", ACCL_DRAWCURVE1 }, + { curved_line_tangent_xpm3, OP_CURVE2, N_("Curve Tangent"), N_("Draw Curve from Tangent"), "cmdDrawCurveTangent", ACCL_DRAWCURVE2 }, + { curved_line_middle_xpm3, OP_CURVE3, N_("Curve Center"), N_("Draw Curve from Center"), "cmdDrawCurveCenter", ACCL_DRAWCURVE3 }, + { curved_line_chord_xpm3, OP_CURVE4, N_("Curve Chord"), N_("Draw Curve from Chord"), "cmdDrawCurveChord", ACCL_DRAWCURVE4 }, + { bezier_line_xpm3, OP_BEZLIN, N_("Bezier Curve"), N_("Draw Bezier"), "cmdDrawBezierCurve", ACCL_DRAWBEZLINE } +}; static drawData_t dcircleCmds[] = { - /*{ dcircle1_xpm, OP_CIRCLE1, "Circle Fixed Radius", "Draw Fixed Radius Circle", "cmdDrawCircleFixedRadius", ACCL_DRAWCIRCLE1 },*/ - { circle_line_center_xpm, OP_CIRCLE3, N_("Circle Center"), N_("Draw Circle from Center"), "cmdDrawCircleCenter", ACCL_DRAWCIRCLE2 }, - { circle_line_tangent_xpm, OP_CIRCLE2, N_("Circle Tangent"), N_("Draw Circle from Tangent"), "cmdDrawCircleTangent", ACCL_DRAWCIRCLE3 }, - /*{ dflcrcl1_xpm, OP_FILLCIRCLE1, "Circle Filled Fixed Radius", "Draw Fixed Radius Filled Circle", "cmdDrawFilledCircleFixedRadius", ACCL_DRAWFILLCIRCLE1 },*/ - { circle_filled_center_xpm, OP_FILLCIRCLE3, N_("Circle Filled Center"), N_("Draw Filled Circle from Center"), "cmdDrawFilledCircleCenter", ACCL_DRAWFILLCIRCLE2 }, - { circle_filled_tangent_xpm, OP_FILLCIRCLE2, N_("Circle Filled Tangent"), N_("Draw Filled Circle from Tangent"), "cmdDrawFilledCircleTangent", ACCL_DRAWFILLCIRCLE3 } }; + /*{ dcircle1_xpm, OP_CIRCLE1, "Circle Fixed Radius", "Draw Fixed Radius Circle", "cmdDrawCircleFixedRadius", ACCL_DRAWCIRCLE1 },*/ + { circle_line_center_xpm3, OP_CIRCLE3, N_("Circle Center"), N_("Draw Circle from Center"), "cmdDrawCircleCenter", ACCL_DRAWCIRCLE2 }, + { circle_line_tangent_xpm3, OP_CIRCLE2, N_("Circle Tangent"), N_("Draw Circle from Tangent"), "cmdDrawCircleTangent", ACCL_DRAWCIRCLE3 }, + /*{ dflcrcl1_xpm, OP_FILLCIRCLE1, "Circle Filled Fixed Radius", "Draw Fixed Radius Filled Circle", "cmdDrawFilledCircleFixedRadius", ACCL_DRAWFILLCIRCLE1 },*/ + { circle_filled_center_xpm3, OP_FILLCIRCLE3, N_("Circle Filled Center"), N_("Draw Filled Circle from Center"), "cmdDrawFilledCircleCenter", ACCL_DRAWFILLCIRCLE2 }, + { circle_filled_tangent_xpm3, OP_FILLCIRCLE2, N_("Circle Filled Tangent"), N_("Draw Filled Circle from Tangent"), "cmdDrawFilledCircleTangent", ACCL_DRAWFILLCIRCLE3 } +}; static drawData_t dshapeCmds[] = { - { box_xpm, OP_BOX, N_("Box"), N_("Draw Box"), "cmdDrawBox", ACCL_DRAWBOX }, - { filled_box_xpm, OP_FILLBOX, N_("Filled Box"), N_("Draw Filled Box"), "cmdDrawFilledBox", ACCL_DRAWFILLBOX }, - { polygon_xpm, OP_POLY, N_("Polygon"), N_("Draw Polygon"), "cmdDrawPolygon", ACCL_DRAWPOLY }, - { filled_polygon_xpm, OP_FILLPOLY, N_("Filled Polygon"), N_("Draw Filled Polygon"), "cmdDrawFilledPolygon", ACCL_DRAWFILLPOLYGON }, - { polyline_xpm, OP_POLYLINE, N_("PolyLine"), N_("Draw PolyLine"), "cmdDrawPolyline", ACCL_DRAWPOLYLINE }, + { box_xpm3, OP_BOX, N_("Box"), N_("Draw Box"), "cmdDrawBox", ACCL_DRAWBOX }, + { filled_box_xpm3, OP_FILLBOX, N_("Filled Box"), N_("Draw Filled Box"), "cmdDrawFilledBox", ACCL_DRAWFILLBOX }, + { polygon_xpm3, OP_POLY, N_("Polygon"), N_("Draw Polygon"), "cmdDrawPolygon", ACCL_DRAWPOLY }, + { filled_polygon_xpm3, OP_FILLPOLY, N_("Filled Polygon"), N_("Draw Filled Polygon"), "cmdDrawFilledPolygon", ACCL_DRAWFILLPOLYGON }, + { polyline_xpm3, OP_POLYLINE, N_("PolyLine"), N_("Draw PolyLine"), "cmdDrawPolyline", ACCL_DRAWPOLYLINE }, }; typedef struct { - char * helpKey; - char * menuTitle; - char * stickyLabel; - int cnt; - drawData_t * data; - long acclKey; - wIndex_t cmdInx; - int curr; - } drawStuff_t; + char * helpKey; + char * menuTitle; + char * stickyLabel; + int cnt; + drawData_t * data; + long acclKey; + wIndex_t cmdInx; + int curr; +} drawStuff_t; static drawStuff_t drawStuff[4]; static drawStuff_t drawStuff[4] = { - { "cmdDrawLineSetCmd", N_("Straight Objects"), N_("Draw Straight Objects"), 4, dlineCmds }, - { "cmdDrawCurveSetCmd", N_("Curved Lines"), N_("Draw Curved Lines"), 5, dcurveCmds }, - { "cmdDrawCircleSetCmd", N_("Circle Lines"), N_("Draw Circles"), 4, dcircleCmds }, - { "cmdDrawShapeSetCmd", N_("Shapes"), N_("Draw Shapes"), 5, dshapeCmds} }; - + { "cmdDrawLineSetCmd", N_("Straight Objects"), N_("Draw Straight Objects"), 4, dlineCmds }, + { "cmdDrawCurveSetCmd", N_("Curved Lines"), N_("Draw Curved Lines"), 5, dcurveCmds }, + { "cmdDrawCircleSetCmd", N_("Circle Lines"), N_("Draw Circles"), 4, dcircleCmds }, + { "cmdDrawShapeSetCmd", N_("Shapes"), N_("Draw Shapes"), 5, dshapeCmds} +}; + static void ChangeDraw( long changes ) { @@ -3093,7 +3252,8 @@ static void ChangeDraw( long changes ) if ( drawBenchChoicePD.control && drawBenchOrientPD.control ) { choice = wListGetIndex( (wList_p)drawBenchChoicePD.control ); orient = wListGetIndex( (wList_p)drawBenchOrientPD.control ); - BenchLoadLists( (wList_p)drawBenchChoicePD.control, (wList_p)drawBenchOrientPD.control ); + BenchLoadLists( (wList_p)drawBenchChoicePD.control, + (wList_p)drawBenchOrientPD.control ); wListSetIndex( (wList_p)drawBenchChoicePD.control, choice ); wListSetIndex( (wList_p)drawBenchOrientPD.control, orient ); } @@ -3103,53 +3263,43 @@ static void ChangeDraw( long changes ) static void DrawDlgUpdate( - paramGroup_p pg, - int inx, - void * valueP ) + paramGroup_p pg, + int inx, + void * valueP ) { - if (inx==3) { - if (drawCmdContext.Op == OP_BEZLIN) { - if ( (inx == 0 && pg->paramPtr[inx].valueP == &drawCmdContext.line_Width) || - (inx == 1 && pg->paramPtr[inx].valueP == &lineColor)) - { - lineWidth = drawCmdContext.line_Width; - UpdateParms(lineColor, lineWidth); - } - } - } if (inx >=6 ) { if (drawCmdContext.Op == OP_CIRCLE1 || - drawCmdContext.Op == OP_FILLCIRCLE1 || - drawCmdContext.Op == OP_CIRCLE2 || - drawCmdContext.Op == OP_FILLCIRCLE2 || - drawCmdContext.Op == OP_CIRCLE3 || - drawCmdContext.Op == OP_FILLCIRCLE3) { + drawCmdContext.Op == OP_FILLCIRCLE1 || + drawCmdContext.Op == OP_CIRCLE2 || + drawCmdContext.Op == OP_FILLCIRCLE2 || + drawCmdContext.Op == OP_CIRCLE3 || + drawCmdContext.Op == OP_FILLCIRCLE3) { coOrd pos = zero; DrawGeomMouse(C_UPDATE,pos,&drawCmdContext); } if (drawCmdContext.Op == OP_CURVE1 || - drawCmdContext.Op == OP_CURVE2 || - drawCmdContext.Op == OP_CURVE3 || - drawCmdContext.Op == OP_CURVE4 ) { + drawCmdContext.Op == OP_CURVE2 || + drawCmdContext.Op == OP_CURVE3 || + drawCmdContext.Op == OP_CURVE4 ) { coOrd pos = zero; DrawGeomMouse(C_UPDATE,pos,&drawCmdContext); } if (drawCmdContext.Op == OP_LINE || - drawCmdContext.Op == OP_BENCH|| - drawCmdContext.Op == OP_TBLEDGE) { + drawCmdContext.Op == OP_BENCH|| + drawCmdContext.Op == OP_TBLEDGE) { coOrd pos = zero; DrawGeomMouse(C_UPDATE,pos,&drawCmdContext); } if (drawCmdContext.Op == OP_BOX || - drawCmdContext.Op == OP_FILLBOX ){ + drawCmdContext.Op == OP_FILLBOX ) { coOrd pos = zero; DrawGeomMouse(C_UPDATE,pos,&drawCmdContext); } if (drawCmdContext.Op == OP_POLY || - drawCmdContext.Op == OP_FILLPOLY || - drawCmdContext.Op == OP_POLYLINE) { + drawCmdContext.Op == OP_FILLPOLY || + drawCmdContext.Op == OP_POLYLINE) { coOrd pos = zero; DrawGeomMouse(C_UPDATE,pos,&drawCmdContext); } @@ -3161,8 +3311,11 @@ static void DrawDlgUpdate( //} } - if ( inx >= 0 && pg->paramPtr[inx].valueP == &benchChoice ) - BenchUpdateOrientationList( VP2L(wListGetItemContext( (wList_p)drawBenchChoicePD.control, (wIndex_t)*(long*)valueP )), (wList_p)drawBenchOrientPD.control ); + if ( inx >= 0 && pg->paramPtr[inx].valueP == &benchChoice ) { + BenchUpdateOrientationList( VP2L(wListGetItemContext( (wList_p) + drawBenchChoicePD.control, (wIndex_t)*(long*)valueP )), + (wList_p)drawBenchOrientPD.control ); + } } EXPORT void InitCmdDraw( wMenu_p menu ) @@ -3172,7 +3325,6 @@ EXPORT void InitCmdDraw( wMenu_p menu ) drawData_t * ddp; wIcon_p icon; - drawCmdContext.Color = wDrawColorBlack; lineColor = wDrawColorBlack; benchColor = wDrawFindColor( wRGB(255,192,0) ); ParamCreateControls( &drawPG, DrawDlgUpdate ); @@ -3185,7 +3337,8 @@ EXPORT void InitCmdDraw( wMenu_p menu ) for ( inx2=0; inx2<dsp->cnt; inx2++ ) { ddp = &dsp->data[inx2]; icon = wIconCreatePixMap( ddp->xpm[iconSize] ); - AddMenuButton( menu, CmdDraw, ddp->helpKey, _(ddp->cmdName), icon, LEVEL0_50, IC_STICKY|IC_POPUP2|IC_WANT_MOVE, ddp->acclKey, I2VP(ddp->OP) ); + AddMenuButton( menu, CmdDraw, ddp->helpKey, _(ddp->cmdName), icon, LEVEL0_50, + IC_STICKY|IC_POPUP2|IC_WANT_MOVE, ddp->acclKey, I2VP(ddp->OP) ); } ButtonGroupEnd(); } @@ -3204,12 +3357,14 @@ BOOL_T ReadTableEdge( char * line ) trkSeg_t seg; wIndex_t layer; - if ( !GetArgs( line, paramVersion<3?"dXpYpY":paramVersion<9?"dL000pYpY":"dL000pfpf", - &index, &layer, &seg.u.l.pos[0], &elev0, &seg.u.l.pos[1], &elev1 ) ) + if ( !GetArgs( line, paramVersion<3?"dXpYpY":paramVersion<9 + ?"dL000pYpY":"dL000pfpf", + &index, &layer, &seg.u.l.pos[0], &elev0, &seg.u.l.pos[1], &elev1 ) ) { return FALSE; + } seg.type = SEG_TBLEDGE; seg.color = wDrawColorBlack; - seg.width = 0; + seg.lineWidth = 0; trk = MakeDrawFromSeg1( index, zero, 0.0, &seg ); SetTrkLayer(trk, layer); return TRUE; @@ -3217,11 +3372,11 @@ BOOL_T ReadTableEdge( char * line ) /** * Create a new segment for text. The data are stored in a trk structure. - * Storage for the string is dynamically allocated. + * Storage for the string is dynamically allocated. * * \param index IN of new element * \param pos IN coordinates of element - * \param angle IN orientation + * \param angle IN orientation * \param text IN text itself * \param textSize IN font size in pts * \param color IN text color @@ -3229,19 +3384,19 @@ BOOL_T ReadTableEdge( char * line ) */ EXPORT track_p NewText( - wIndex_t index, - coOrd pos, - ANGLE_T angle, - char * text, - CSIZE_T textSize, + wIndex_t index, + coOrd pos, + ANGLE_T angle, + char * text, + CSIZE_T textSize, wDrawColor color, - BOOL_T boxed) + BOOL_T boxed) { trkSeg_t tempSeg; track_p trk; tempSeg.type = SEG_TEXT; tempSeg.color = color; - tempSeg.width = 0; + tempSeg.lineWidth = 0; tempSeg.u.t.pos = pos; tempSeg.u.t.angle = angle; tempSeg.u.t.fontP = NULL; @@ -3261,17 +3416,23 @@ EXPORT BOOL_T ReadText( char * line ) wIndex_t layer; track_p trk; ANGLE_T angle; - wDrawColor color = wDrawColorBlack; - if ( paramVersion<3 ) { - if (!GetArgs( line, "XXpYql", &index, &layer, &pos, &angle, &text, &textSize )) - return FALSE; - } else if (paramVersion<9 ) { - if (!GetArgs(line, "dL000pYql", &index, &layer, &pos, &angle, &text, &textSize)) - return FALSE; - } else { - if (!GetArgs(line, "dLl00pfql", &index, &layer, &color, &pos, &angle, &text, &textSize )) - return FALSE; - } + wDrawColor color = wDrawColorBlack; + if ( paramVersion<3 ) { + if (!GetArgs( line, "XXpYql", &index, &layer, &pos, &angle, &text, + &textSize )) { + return FALSE; + } + } else if (paramVersion<9 ) { + if (!GetArgs(line, "dL000pYql", &index, &layer, &pos, &angle, &text, + &textSize)) { + return FALSE; + } + } else { + if (!GetArgs(line, "dLl00pfql", &index, &layer, &color, &pos, &angle, &text, + &textSize )) { + return FALSE; + } + } trk = NewText( index, pos, angle, text, textSize, color, FALSE ); SetTrkLayer( trk, layer ); @@ -3301,17 +3462,20 @@ void MenuEnter( void * keyVP ) int action; action = C_TEXT; action |= key<<8; - if (drawModCmdContext.rotate_state) + if (drawModCmdContext.rotate_state) { DrawGeomOriginMove(action,zero,&drawModCmdContext); - else + } else { DrawGeomModify(action,zero,&drawModCmdContext); + } } void MenuLine( void * keyVP ) { int key = (int)VP2L(keyVP); - struct extraDataDraw_t * xx = GET_EXTRA_DATA(drawModCmdContext.trk, T_DRAW, extraDataDraw_t); - if ( drawModCmdContext.type==SEG_STRLIN || drawModCmdContext.type==SEG_CRVLIN || drawModCmdContext.type==SEG_POLY ) { + struct extraDataDraw_t * xx = GET_EXTRA_DATA(drawModCmdContext.trk, T_DRAW, + extraDataDraw_t); + if ( drawModCmdContext.type==SEG_STRLIN || drawModCmdContext.type==SEG_CRVLIN + || drawModCmdContext.type==SEG_POLY ) { switch(key) { case '0': xx->lineType = DRAWLINESOLID; @@ -3339,10 +3503,12 @@ void MenuLine( void * keyVP ) } } -EXPORT void SetLineType( track_p trk, int width ) { +EXPORT void SetLineType( track_p trk, int width ) +{ if (QueryTrack(trk, Q_IS_DRAW)) { struct extraDataDraw_t * xx = GET_EXTRA_DATA(trk, T_DRAW, extraDataDraw_t); - if ( xx->segs[0].type==SEG_STRLIN || xx->segs[0].type==SEG_CRVLIN || xx->segs[0].type==SEG_POLY) { + if ( xx->segs[0].type==SEG_STRLIN || xx->segs[0].type==SEG_CRVLIN + || xx->segs[0].type==SEG_POLY) { switch(width) { case 0: xx->lineType = DRAWLINESOLID; @@ -3377,29 +3543,49 @@ EXPORT void InitTrkDraw( void ) AddParam( "TEXT", ReadText ); drawModDelMI = MenuRegister( "Modify Draw Edit Menu" ); - drawModClose = wMenuPushCreate( drawModDelMI, "", _("Close Polygon - 'g'"), 0, MenuEnter, I2VP( 'g')); - drawModOpen = wMenuPushCreate( drawModDelMI, "", _("Make PolyLine - 'l'"), 0, MenuEnter, I2VP( 'l')); - drawModFill = wMenuPushCreate( drawModDelMI, "", _("Fill Polygon - 'f'"), 0, MenuEnter, I2VP( 'f')); - drawModEmpty = wMenuPushCreate( drawModDelMI, "", _("Empty Polygon - 'u'"), 0, MenuEnter, I2VP( 'u')); + drawModClose = wMenuPushCreate( drawModDelMI, "", _("Close Polygon - 'g'"), 0, + MenuEnter, I2VP( 'g')); + drawModOpen = wMenuPushCreate( drawModDelMI, "", _("Make PolyLine - 'l'"), 0, + MenuEnter, I2VP( 'l')); + drawModFill = wMenuPushCreate( drawModDelMI, "", _("Fill Polygon - 'f'"), 0, + MenuEnter, I2VP( 'f')); + drawModEmpty = wMenuPushCreate( drawModDelMI, "", _("Empty Polygon - 'u'"), 0, + MenuEnter, I2VP( 'u')); wMenuSeparatorCreate( drawModDelMI ); - drawModPointsMode = wMenuPushCreate( drawModDelMI, "", _("Points Mode - 'p'"), 0, MenuMode, I2VP( 0 )); - drawModDel = wMenuPushCreate( drawModDelMI, "", _("Delete Selected Point - 'Del'"), 0, MenuEnter, I2VP( 127 )); - drawModVertex = wMenuPushCreate( drawModDelMI, "", _("Vertex Point - 'v'"), 0, MenuEnter, I2VP( 'v' )); - drawModRound = wMenuPushCreate( drawModDelMI, "", _("Round Corner - 'r'"), 0, MenuEnter, I2VP( 'r' )); - drawModSmooth = wMenuPushCreate( drawModDelMI, "", _("Smooth Corner - 's'"), 0, MenuEnter, I2VP( 's' )); + drawModPointsMode = wMenuPushCreate( drawModDelMI, "", _("Points Mode - 'p'"), + 0, MenuMode, I2VP( 0 )); + drawModDel = wMenuPushCreate( drawModDelMI, "", + _("Delete Selected Point - 'Del'"), 0, MenuEnter, I2VP( 127 )); + drawModVertex = wMenuPushCreate( drawModDelMI, "", _("Vertex Point - 'v'"), 0, + MenuEnter, I2VP( 'v' )); + drawModRound = wMenuPushCreate( drawModDelMI, "", _("Round Corner - 'r'"), 0, + MenuEnter, I2VP( 'r' )); + drawModSmooth = wMenuPushCreate( drawModDelMI, "", _("Smooth Corner - 's'"), 0, + MenuEnter, I2VP( 's' )); wMenuSeparatorCreate( drawModDelMI ); drawModLinMI = wMenuMenuCreate( drawModDelMI, "", _("LineType...") ); - drawModSolid = wMenuPushCreate( drawModLinMI, "", _("Solid Line"), 0, MenuLine, I2VP( '0' )); - drawModDot = wMenuPushCreate( drawModLinMI, "", _("Dashed Line"), 0, MenuLine, I2VP( '1' )); - drawModDash = wMenuPushCreate( drawModLinMI, "", _("Dotted Line"), 0, MenuLine, I2VP( '2' )); - drawModDashDot = wMenuPushCreate( drawModLinMI, "", _("Dash-Dot Line"), 0, MenuLine, I2VP( '3' )); - drawModDashDotDot = wMenuPushCreate( drawModLinMI, "", _("Dash-Dot-Dot Line"), 0, MenuLine, I2VP( '4' )); - drawModCenterDot = wMenuPushCreate( drawModLinMI, "", _("Center-Dot Line"), 0, MenuLine, I2VP( '5' )); - drawModPhantom = wMenuPushCreate( drawModLinMI, "", _("Phantom-Dot Line"), 0, MenuLine, I2VP( '6' )); + drawModSolid = wMenuPushCreate( drawModLinMI, "", _("Solid Line"), 0, MenuLine, + I2VP( '0' )); + drawModDot = wMenuPushCreate( drawModLinMI, "", _("Dashed Line"), 0, MenuLine, + I2VP( '1' )); + drawModDash = wMenuPushCreate( drawModLinMI, "", _("Dotted Line"), 0, MenuLine, + I2VP( '2' )); + drawModDashDot = wMenuPushCreate( drawModLinMI, "", _("Dash-Dot Line"), 0, + MenuLine, I2VP( '3' )); + drawModDashDotDot = wMenuPushCreate( drawModLinMI, "", _("Dash-Dot-Dot Line"), + 0, MenuLine, I2VP( '4' )); + drawModCenterDot = wMenuPushCreate( drawModLinMI, "", _("Center-Dot Line"), 0, + MenuLine, I2VP( '5' )); + drawModPhantom = wMenuPushCreate( drawModLinMI, "", _("Phantom-Dot Line"), 0, + MenuLine, I2VP( '6' )); wMenuSeparatorCreate( drawModDelMI ); - drawModriginMode = wMenuPushCreate( drawModDelMI, "", _("Origin Mode - 'o'"), 0, MenuMode, I2VP( 1 )); - drawModOrigin = wMenuPushCreate( drawModDelMI, "", _("Reset Origin - '0'"), 0, MenuEnter, I2VP( '0' )); - drawModLast = wMenuPushCreate( drawModDelMI, "", _("Origin to Selected - 'l'"), 0, MenuEnter, I2VP( 'l' )); - drawModCenter = wMenuPushCreate( drawModDelMI, "", _("Origin to Middle - 'm'"), 0, MenuEnter, I2VP( 'm')); + drawModriginMode = wMenuPushCreate( drawModDelMI, "", _("Origin Mode - 'o'"), 0, + MenuMode, I2VP( 1 )); + drawModOrigin = wMenuPushCreate( drawModDelMI, "", _("Reset Origin - '0'"), 0, + MenuEnter, I2VP( '0' )); + drawModLast = wMenuPushCreate( drawModDelMI, "", _("Origin to Selected - 'l'"), + 0, MenuEnter, I2VP( 'l' )); + drawModCenter = wMenuPushCreate( drawModDelMI, "", _("Origin to Middle - 'm'"), + 0, MenuEnter, I2VP( 'm')); } diff --git a/app/bin/celev.c b/app/bin/celev.c index b80874f..e55a1fe 100644 --- a/app/bin/celev.c +++ b/app/bin/celev.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "cselect.h" @@ -40,7 +40,8 @@ static EPINX_T elevEp; static BOOL_T elevUndo = FALSE; static char * elevModeLabels[] = { N_("None"), N_("Defined"), N_("Hidden"), - N_("Computed"), N_("Grade"), N_("Station"), N_("Ignore"), NULL }; + N_("Computed"), N_("Grade"), N_("Station"), N_("Ignore"), NULL + }; static paramFloatRange_t r_1000_1000 = { -1000, 1000 }; static paramData_t elevationPLs[] = { @@ -53,37 +54,40 @@ static paramData_t elevationPLs[] = { #define I_GRADE (3) { PD_MESSAGE, NULL, "grade", 0, I2VP(80) }, #define I_STATION (4) - { PD_STRING, elevStationV, "station", PDO_DLGUNDERCMDBUTT|PDO_STRINGLIMITLENGTH, I2VP(200), NULL, 0, 0, sizeof(elevStationV)} }; + { PD_STRING, elevStationV, "station", PDO_DLGUNDERCMDBUTT|PDO_STRINGLIMITLENGTH, I2VP(200), NULL, 0, 0, sizeof(elevStationV)} +}; static paramGroup_t elevationPG = { "elev", 0, elevationPLs, COUNT( elevationPLs ) }; static dynArr_t anchors_da; #define anchors(N) DYNARR_N(trkSeg_t,anchors_da,N) -static void CreateSquareAnchor(coOrd p) { +static void CreateSquareAnchor(coOrd p) +{ DIST_T d = tempD.scale*0.25; int i = anchors_da.cnt; DYNARR_SET(trkSeg_t,anchors_da,i+4); - for (int j =0; j<4;j++) { + for (int j =0; j<4; j++) { anchors(i+j).type = SEG_STRLIN; anchors(i+j).color = wDrawColorBlue; - anchors(i+j).width = 0; + anchors(i+j).lineWidth = 0; } anchors(i).u.l.pos[0].x = anchors(i+2).u.l.pos[1].x = - anchors(i+3).u.l.pos[0].x = anchors(i+3).u.l.pos[1].x = p.x-d/2; + anchors(i+3).u.l.pos[0].x = anchors(i+3).u.l.pos[1].x = p.x-d/2; anchors(i).u.l.pos[0].y = anchors(i).u.l.pos[1].y = - anchors(i+1).u.l.pos[0].y = anchors(i+3).u.l.pos[1].y = p.y-d/2; + anchors(i+1).u.l.pos[0].y = anchors(i+3).u.l.pos[1].y = p.y-d/2; anchors(i).u.l.pos[1].x = - anchors(i+1).u.l.pos[0].x = anchors(i+1).u.l.pos[1].x = - anchors(i+2).u.l.pos[0].x = p.x+d/2; + anchors(i+1).u.l.pos[0].x = anchors(i+1).u.l.pos[1].x = + anchors(i+2).u.l.pos[0].x = p.x+d/2; anchors(i+1).u.l.pos[1].y = - anchors(i+2).u.l.pos[0].y = anchors(i+2).u.l.pos[1].y = - anchors(i+3).u.l.pos[0].y = p.y+d/2; + anchors(i+2).u.l.pos[0].y = anchors(i+2).u.l.pos[1].y = + anchors(i+3).u.l.pos[0].y = p.y+d/2; } -static void CreateEndAnchor(coOrd p, wBool_t lock) { +static void CreateEndAnchor(coOrd p, wBool_t lock) +{ DIST_T d = tempD.scale*0.15; DYNARR_APPEND(trkSeg_t,anchors_da,1); @@ -94,11 +98,12 @@ static void CreateEndAnchor(coOrd p, wBool_t lock) { anchors(i).u.c.radius = d/2; anchors(i).u.c.a0 = 0.0; anchors(i).u.c.a1 = 360.0; - anchors(i).width = 0; + anchors(i).lineWidth = 0; } -static void CreateSplitAnchor(coOrd pos, track_p t) { - DIST_T d = tempD.scale*0.1; +static void CreateSplitAnchor(coOrd pos, track_p t) +{ +// DIST_T d = tempD.scale*0.1; DIST_T w = tempD.scale/tempD.dpi*4; int i; ANGLE_T a = NormalizeAngle(GetAngleAtPoint(t,pos,NULL,NULL)+90.0); @@ -108,31 +113,37 @@ static void CreateSplitAnchor(coOrd pos, track_p t) { anchors(i).color = wDrawColorBlue; Translate(&anchors(i).u.l.pos[0],pos,a,GetTrkGauge(t)); Translate(&anchors(i).u.l.pos[1],pos,a,-GetTrkGauge(t)); - anchors(i).width = w; + anchors(i).lineWidth = w; } -void static CreateMoveAnchor(coOrd pos) { +#if 0 +void static CreateMoveAnchor(coOrd pos) +{ DYNARR_SET(trkSeg_t,anchors_da,anchors_da.cnt+5); - DrawArrowHeads(&DYNARR_N(trkSeg_t,anchors_da,anchors_da.cnt-5),pos,0,TRUE,wDrawColorBlue); + DrawArrowHeads(&DYNARR_N(trkSeg_t,anchors_da,anchors_da.cnt-5),pos,0,TRUE, + wDrawColorBlue); DYNARR_SET(trkSeg_t,anchors_da,anchors_da.cnt+5); - DrawArrowHeads(&DYNARR_N(trkSeg_t,anchors_da,anchors_da.cnt-5),pos,90,TRUE,wDrawColorBlue); + DrawArrowHeads(&DYNARR_N(trkSeg_t,anchors_da,anchors_da.cnt-5),pos,90,TRUE, + wDrawColorBlue); DYNARR_APPEND(trkSeg_t,anchors_da,1); CreateSquareAnchor(pos); } +#endif static void LayoutElevW( - paramData_t * pd, - int inx, - wWinPix_t colX, - wWinPix_t * x, - wWinPix_t * y ) + paramData_t * pd, + int inx, + wWinPix_t colX, + wWinPix_t * x, + wWinPix_t * y ) { static wWinPix_t h = 0; switch ( inx ) { case I_HEIGHT: - h = wControlGetHeight( elevationPLs[I_MODE].control )/(COUNT( elevModeLabels )-1); + h = wControlGetHeight( elevationPLs[I_MODE].control )/(COUNT( + elevModeLabels )-1); #ifndef WINDOWS h += 3; #endif @@ -153,8 +164,9 @@ static int GetElevMode( void ) int newMode; static int modeMap[7] = { ELEV_NONE, ELEV_DEF|ELEV_VISIBLE, ELEV_DEF, ELEV_COMP|ELEV_VISIBLE, ELEV_GRADE|ELEV_VISIBLE, ELEV_STATION|ELEV_VISIBLE, ELEV_IGNORE }; mode = (int)elevModeV; - if (mode<0||mode>=7) + if (mode<0||mode>=7) { return -1; + } newMode = modeMap[mode]; return newMode; } @@ -168,8 +180,9 @@ static void DoElevUpdate( paramGroup_p pg, int inx, void * valueP ) if ( inx == 0 ) { long mode = *(long*)valueP; - if ( mode < 0 || mode >= 7 ) + if ( mode < 0 || mode >= 7 ) { return; + } ParamControlActive( &elevationPG, I_HEIGHT, FALSE ); ParamControlActive( &elevationPG, I_STATION, FALSE ); switch ( mode ) { @@ -190,23 +203,28 @@ static void DoElevUpdate( paramGroup_p pg, int inx, void * valueP ) } ParamLoadData( &elevationPG ); newMode = GetElevMode(); - if (newMode == -1) + if (newMode == -1) { return; - if (elevTrk == NULL) + } + if (elevTrk == NULL) { return; + } oldMode = GetTrkEndElevUnmaskedMode( elevTrk, elevEp ); elevNewValue = 0.0; - if ((newMode&ELEV_MASK) == ELEV_DEF) + if ((newMode&ELEV_MASK) == ELEV_DEF) { elevNewValue = elevHeightV; + } if (oldMode == newMode) { if ((newMode&ELEV_MASK) == ELEV_DEF) { elevOldValue = GetTrkEndElevHeight( elevTrk, elevEp ); diff = fabs( elevOldValue-elevNewValue ); - if ( diff < 0.02 ) + if ( diff < 0.02 ) { return; + } } else if ((newMode&ELEV_MASK) == ELEV_STATION) { - if ( strcmp(elevStationV, GetTrkEndElevStation( elevTrk, elevEp ) ) == 0) + if ( strcmp(elevStationV, GetTrkEndElevStation( elevTrk, elevEp ) ) == 0) { return; + } } else { return; } @@ -261,10 +279,11 @@ static void ElevSelect( track_p trk, EPINX_T ep ) radio = 0; break; case ELEV_DEF: - if ( mode & ELEV_VISIBLE ) + if ( mode & ELEV_VISIBLE ) { radio = 1; - else + } else { radio = 2; + } elevHeightV = GetTrkEndElevHeight(trk,ep); elevOldValue = elevHeightV; ParamLoadControl( &elevationPG, I_HEIGHT ); @@ -291,7 +310,8 @@ static void ElevSelect( track_p trk, EPINX_T ep ) elevModeV = radio; ParamLoadControl( &elevationPG, I_MODE ); gradeOk = ComputeElev( trk, ep, FALSE, &elevX, &grade, TRUE ); - sprintf( message, "%0.2f%s", round(PutDim( elevX )*100.0)/100.0, (units==UNITS_METRIC?"cm":"\"") ); + sprintf( message, "%0.2f%s", round(PutDim( elevX )*100.0)/100.0, + (units==UNITS_METRIC?"cm":"\"") ); ParamLoadMessage( &elevationPG, I_COMPUTED, message ); if (gradeOk) { sprintf( message, "%0.1f%%", fabs(round(grade*1000.0)/10.0) ); @@ -299,17 +319,20 @@ static void ElevSelect( track_p trk, EPINX_T ep ) if ( EndPtIsDefinedElev(trk,ep) ) { elev = GetElevation(trk); dist = GetTrkLength(trk,ep,-1); - if (dist>0.1) + if (dist>0.1) { sprintf( message, "%0.1f%%", fabs(round(((elev-elevX)/dist)*1000.0))/10.0 ); - else + } else { sprintf( message, _("Undefined") ); + } if ( (trk1=GetTrkEndTrk(trk,ep)) && (ep1=GetEndPtConnectedToMe(trk1,trk))>=0 ) { elev = GetElevation(trk1); dist = GetTrkLength(trk1,ep1,-1); - if (dist>0.1) - sprintf( message+strlen(message), " - %0.1f%%", fabs(round(((elev-elevX)/dist)*1000.0))/10.0 ); - else + if (dist>0.1) { + sprintf( message+strlen(message), " - %0.1f%%", + fabs(round(((elev-elevX)/dist)*1000.0))/10.0 ); + } else { sprintf( message+strlen(message), " - %s", _("Undefined") ); + } } } else { strcpy( message, _("Undefined") ); @@ -323,11 +346,13 @@ static void ElevSelect( track_p trk, EPINX_T ep ) wShow(elevW); } -static BOOL_T GetPointElev(track_p trk, coOrd pos, DIST_T * height) { +static BOOL_T GetPointElev(track_p trk, coOrd pos, DIST_T * height) +{ DIST_T elev0, elev1, dist0, dist1; if ( IsTrack( trk ) && GetTrkEndPtCnt(trk) == 2 ) { - if ( GetTrkLength( trk, 0, 1 ) < 0.1 ) + if ( GetTrkLength( trk, 0, 1 ) < 0.1 ) { return FALSE; + } dist0 = FindDistance(pos,GetTrkEndPos(trk,0)); dist1 = FindDistance(pos,GetTrkEndPos(trk,1)); ComputeElev( trk, 0, FALSE, &elev0, NULL, FALSE ); @@ -338,8 +363,8 @@ static BOOL_T GetPointElev(track_p trk, coOrd pos, DIST_T * height) { } *height = ((elev1-elev0)*(dist0/(dist0+dist1)))+elev0; return TRUE; - } else if (GetTrkEndPtCnt(trk) == 1 && - ComputeElev( trk, 0, FALSE, &elev0, NULL, FALSE ) ) { + } else if (GetTrkEndPtCnt(trk) == 1 && + ComputeElev( trk, 0, FALSE, &elev0, NULL, FALSE ) ) { *height = elev0; return TRUE; } @@ -351,12 +376,14 @@ static STATUS_T CmdElevation( wAction_t action, coOrd pos ) { track_p trk0, trk1; EPINX_T ep0; - int oldTrackCount; +// int oldTrackCount; switch (action) { case C_START: - if ( elevW == NULL ) - elevW = ParamCreateDialog( &elevationPG, MakeWindowTitle(_("Elevation")), _("Done"), DoElevDone, wHide, TRUE, LayoutElevW, 0, DoElevUpdate ); + if ( elevW == NULL ) { + elevW = ParamCreateDialog( &elevationPG, MakeWindowTitle(_("Elevation")), + _("Done"), DoElevDone, wHide, TRUE, LayoutElevW, 0, DoElevUpdate ); + } elevModeV = 0; elevHeightV = 0.0; elevStationV[0] = 0; @@ -368,7 +395,8 @@ static STATUS_T CmdElevation( wAction_t action, coOrd pos ) ParamControlActive( &elevationPG, I_STATION, FALSE ); ParamLoadMessage( &elevationPG, I_COMPUTED, "" ); ParamLoadMessage( &elevationPG, I_GRADE, "" ); - InfoMessage( _("Click on end, +Shift to split, +Ctrl to move description, +Alt to show elevation") ); + InfoMessage( + _("Click on end, +Shift to split, +Ctrl to move description, +Alt to show elevation") ); elevTrk = NULL; elevUndo = FALSE; CmdMoveDescription( action, pos ); @@ -381,10 +409,11 @@ static STATUS_T CmdElevation( wAction_t action, coOrd pos ) CmdMoveDescription( action, pos ); return C_CONTINUE; } - BOOL_T xing = FALSE; +// BOOL_T xing = FALSE; coOrd p0 = pos, p2=pos; if ((trk0 = OnTrack2(&p0,FALSE, TRUE, FALSE, NULL)) != NULL) { - EPINX_T ep0 = 0, ep1 = 1; + EPINX_T ep0 = 0; +// EPINX_T ep1 = 1; DIST_T elev0, elev1; if (GetTrkEndPtCnt(trk0) == 2) { if (!GetPointElev(trk0,p0,&elev0)) { @@ -398,13 +427,18 @@ static STATUS_T CmdElevation( wAction_t action, coOrd pos ) if (((MyGetKeyState()&WKEY_ALT))) { //Add square with Alt if ((trk1 = OnTrack2(&p2,FALSE, TRUE, FALSE, trk0)) != NULL) { if (IsClose(FindDistance(p0,p2))) { - if (GetEndPtConnectedToMe(trk0,trk1) == -1) { //Not simply connected to each other!!! + if (GetEndPtConnectedToMe(trk0, + trk1) == -1) { //Not simply connected to each other!!! if (GetTrkEndPtCnt(trk1) == 2) { if (GetPointElev(trk1,p2,&elev1)) { if (MyGetKeyState()&WKEY_SHIFT) { - InfoMessage (_("Crossing - First %0.3f, Second %0.3f, Clearance %0.3f - Click to Split"), PutDim(elev0), PutDim(elev1), PutDim(fabs(elev0-elev1))); - } else - InfoMessage (_("Crossing - First %0.3f, Second %0.3f, Clearance %0.3f"), PutDim(elev0), PutDim(elev1), PutDim(fabs(elev0-elev1))); + InfoMessage ( + _("Crossing - First %0.3f, Second %0.3f, Clearance %0.3f - Click to Split"), + PutDim(elev0), PutDim(elev1), PutDim(fabs(elev0-elev1))); + } else { + InfoMessage (_("Crossing - First %0.3f, Second %0.3f, Clearance %0.3f"), + PutDim(elev0), PutDim(elev1), PutDim(fabs(elev0-elev1))); + } } CreateSquareAnchor(p2); return C_CONTINUE; @@ -414,21 +448,23 @@ static STATUS_T CmdElevation( wAction_t action, coOrd pos ) } } if ((ep0 = PickEndPoint( p0, trk0 )) != -1) { - if ((MyGetKeyState()&WKEY_SHIFT) && QueryTrack(trk0,Q_MODIFY_CAN_SPLIT) - && !(QueryTrack(trk0,Q_IS_TURNOUT))) { + if ((MyGetKeyState()&WKEY_SHIFT) && QueryTrack(trk0,Q_MODIFY_CAN_SPLIT) + && !(QueryTrack(trk0,Q_IS_TURNOUT))) { InfoMessage( _("Click to split here - elevation %0.3f"), PutDim(elev0)); CreateSplitAnchor(p0,trk0); - } else if ((IsClose(FindDistance(GetTrkEndPos(trk0,ep0),p0)) - || (FindDistance(GetTrkEndPos(trk0,ep0),p0)<minLength))) { + } else if ((IsClose(FindDistance(GetTrkEndPos(trk0,ep0),p0)) + || (FindDistance(GetTrkEndPos(trk0,ep0),p0)<minLength))) { CreateEndAnchor(GetTrkEndPos(trk0,ep0),FALSE); InfoMessage (_("Track End elevation %0.3f - snap End Pt"), PutDim(elev0)); } else if (MyGetKeyState()&WKEY_ALT) { CreateEndAnchor(p0,TRUE); InfoMessage (_("Track End elevation %0.3f"), PutDim(elev0)); } - } else InfoMessage( _("Click on End Pt, +Shift to split, +Ctrl to move description, +Alt show Elevation") ); - } else - InfoMessage( _("Click on End Pt, +Shift to split, +Ctrl to move description, +Alt show Elevation") ); + } else { InfoMessage( _("Click on End Pt, +Shift to split, +Ctrl to move description, +Alt show Elevation") ); } + } else { + InfoMessage( + _("Click on End Pt, +Shift to split, +Ctrl to move description, +Alt show Elevation") ); + } return C_CONTINUE; case C_DOWN: case C_MOVE: @@ -440,7 +476,7 @@ static STATUS_T CmdElevation( wAction_t action, coOrd pos ) elevTrk = NULL; return C_CONTINUE; } - /*no break*/ + /*no break*/ case C_LCLICK: ; p0= pos; @@ -452,16 +488,18 @@ static STATUS_T CmdElevation( wAction_t action, coOrd pos ) ep0 = PickEndPoint( p0, trk0 ); if ( (MyGetKeyState()&WKEY_SHIFT) ) { UndoStart( _("Split track"), "SplitTrack( T%d[%d] )", GetTrkIndex(trk0), ep0 ); - oldTrackCount = trackCount; +// oldTrackCount = trackCount; if (!QueryTrack(trk0,Q_IS_TURNOUT) && - !SplitTrack( trk0, p0, ep0, &trk1, FALSE )) + !SplitTrack( trk0, p0, ep0, &trk1, FALSE )) { return C_CONTINUE; + } InfoMessage( _("Track split!") ); ElevSelect( trk0, ep0 ); UndoEnd(); elevUndo = FALSE; } else if (IsClose(FindDistance(GetTrkEndPos(trk0,ep0),p0)) || - (FindDistance(GetTrkEndPos(trk0,ep0),p0)<minLength)) { //Snap if close visually or track + (FindDistance(GetTrkEndPos(trk0,ep0), + p0)<minLength)) { //Snap if close visually or track InfoMessage( _("Point selected!") ); ElevSelect( trk0, ep0 ); } @@ -481,9 +519,10 @@ static STATUS_T CmdElevation( wAction_t action, coOrd pos ) wSetCursor(mainD.d,defaultCursor); DoElevHilight( NULL ); HilightSelectedEndPt( TRUE, elevTrk, elevEp ); + DrawSegsDA( &tempD, NULL, zero, 0.0, &anchors_da, trackGauge, wDrawColorBlack, + 0 ); if (anchors_da.cnt) { - DrawSegs( &tempD, zero, 0.0, &anchors(0), anchors_da.cnt, trackGauge, wDrawColorBlack ); - wSetCursor(mainD.d,wCursorNone); + wSetCursor(mainD.d,wCursorNone); } CmdMoveDescription( action, pos ); return C_CONTINUE; @@ -494,11 +533,13 @@ static STATUS_T CmdElevation( wAction_t action, coOrd pos ) -#include "bitmaps/elevation.xpm" +#include "bitmaps/elevation.xpm3" EXPORT void InitCmdElevation( wMenu_p menu ) { ParamRegister( &elevationPG ); - AddMenuButton( menu, CmdElevation, "cmdElevation", _("Elevation"), wIconCreatePixMap(elevation_xpm[iconSize]), LEVEL0_50, IC_POPUP|IC_LCLICK|IC_RCLICK|IC_WANT_MOVE, ACCL_ELEVATION, NULL ); + AddMenuButton( menu, CmdElevation, "cmdElevation", _("Elevation"), + wIconCreatePixMap(elevation_xpm3[iconSize]), LEVEL0_50, + IC_POPUP|IC_LCLICK|IC_RCLICK|IC_WANT_MOVE, ACCL_ELEVATION, NULL ); } diff --git a/app/bin/cgroup.c b/app/bin/cgroup.c index d30481f..6940ea0 100644 --- a/app/bin/cgroup.c +++ b/app/bin/cgroup.c @@ -18,7 +18,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "cselect.h" @@ -32,8 +32,18 @@ #include "param.h" #include "shrtpath.h" #include "track.h" +#include "trkendpt.h" #include "common-ui.h" +/* + * Note: Bumper support + * Currently Ungroup will convert 1 ended Turnouts (Bumpers) to simple 2-ended Straight + * Group will remove any Bumpers from the Selected track list + * See TODO-BUMPER + * + * The remaining issue is that the ShortestPath logic aborts if it gets to the end of a + * path elem list and can't find the corresponing EP. + */ /***************************************************************************** * @@ -52,9 +62,6 @@ static char groupPartno[STR_SIZE]; static char groupTitle[STR_LONG_SIZE]; static int groupCompoundCount = 0; -extern TRKTYP_T T_BZRTRK; -extern TRKTYP_T T_BZRLIN; -extern TRKTYP_T T_CORNU; /***************************************************************************** * @@ -63,79 +70,85 @@ extern TRKTYP_T T_CORNU; */ typedef struct { - int segInx; - EPINX_T segEP; - int inx; - track_p trk; - } mergePt_t; + int segInx; + EPINX_T segEP; + int inx; + track_p trk; +} mergePt_t; static dynArr_t mergePt_da; #define mergePt(N) DYNARR_N( mergePt_t, mergePt_da, N ) static void AddMergePt( - int segInx, - EPINX_T segEP ) + int segInx, + EPINX_T segEP ) { int inx; mergePt_t * mp; for ( inx=0; inx<mergePt_da.cnt; inx++ ) { mp = &mergePt(inx); if ( mp->segInx == segInx && - mp->segEP == segEP ) + mp->segEP == segEP ) { return; + } } DYNARR_APPEND( mergePt_t, mergePt_da, 10 ); mp = &mergePt(mergePt_da.cnt-1); mp->segInx = segInx; mp->segEP = segEP; mp->inx = mergePt_da.cnt-1; -LOG( log_group, 2, ( " MergePt: %d.%d\n", segInx, segEP ) ); + LOG( log_group, 2, ( " MergePt: %d.%d\n", segInx, segEP ) ); } static EPINX_T FindEP( - EPINX_T epCnt, - trkEndPt_p endPts, - coOrd pos ) + EPINX_T epCnt, + trkEndPt_p endPts, + coOrd pos ) { DIST_T dist; EPINX_T ep; for ( ep=0; ep<epCnt; ep++ ) { - dist = FindDistance( pos, endPts[ep].pos ); - if ( dist < connectDistance ) + dist = FindDistance( pos, GetEndPtPos( EndPtIndex( endPts, ep ) ) ); + if ( dist < connectDistance ) { return ep; + } } return -1; } static void SegOnMP( - int segInx, - int mpInx, - int segCnt, - int * map ) + int segInx, + int mpInx, + int segCnt, + int * map ) { int inx; mergePt_t * mp; if ( map[segInx] < 0 ) { -LOG( log_group, 2, ( " S%d: on MP%d\n", segInx, mpInx ) ); + LOG( log_group, 2, ( " S%d: on MP%d\n", segInx, mpInx ) ); map[segInx] = mpInx; return; } -LOG( log_group, 2, ( " S%d: remapping MP%d to MP%d\n", segInx, mpInx, map[segInx] ) ); + LOG( log_group, 2, ( " S%d: remapping MP%d to MP%d\n", segInx, mpInx, + map[segInx] ) ); for ( inx=0; inx<segCnt; inx++ ) - if ( map[inx] == mpInx ) + if ( map[inx] == mpInx ) { map[inx] = map[segInx]; + } for ( inx=0; inx<mergePt_da.cnt; inx++ ) { - if ( inx == map[segInx] ) + if ( inx == map[segInx] ) { continue; + } mp = &mergePt(inx); - if ( mp->inx == mpInx ) + if ( mp->inx == mpInx ) { mp->inx = map[segInx]; + } } } static void GroupCopyTitle( - char * title ) + char * title ) { char *mP, *nP, *pP; int mL, nL, pL; @@ -154,22 +167,31 @@ static void GroupCopyTitle( groupPartno[pL] = '\0'; } else { if ( mL != (int)strlen( groupManuf ) || - strncmp( groupManuf, mP, mL ) != 0 ) + strncmp( groupManuf, mP, mL ) != 0 ) { groupManuf[0] = '\0'; + } if ( nL != (int)strlen( groupDesc ) || - strncmp( groupDesc, nP, nL ) != 0 ) + strncmp( groupDesc, nP, nL ) != 0 ) { groupDesc[0] = '\0'; + } if ( pL != (int)strlen( groupPartno ) || - strncmp( groupPartno, pP, pL ) != 0 ) + strncmp( groupPartno, pP, pL ) != 0 ) { groupPartno[0] = '\0'; + } } } +// TODO-BUMPER - handle paths which don't end on an EP +// Set GROUP_BUMPER_REFCOUT +// to 1 to convert Bumper tracks to Straight tracks with 2 EP +// to 2 to create 1 EP Turnout tracks +#define GROUP_BUMPER_REFCOUNT (1) EXPORT void UngroupCompound( - track_p trk ) + track_p trk ) { - struct extraDataCompound_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, extraDataCompound_t); + struct extraDataCompound_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, + extraDataCompound_t); struct extraDataCompound_t *xx1; trkSeg_p sp; track_p trk0, trk1; @@ -188,7 +210,7 @@ EXPORT void UngroupCompound( typedef struct { track_p trk; EPINX_T ep[2]; - } segTrack_t; + } segTrack_t; #define segTrack(N) DYNARR_N( segTrack_t, segTrack_da, N ) static dynArr_t segTrack_da; segTrack_t * stp, * stp1; @@ -218,55 +240,61 @@ EXPORT void UngroupCompound( } #endif -LOG( log_group, 1, ( "Ungroup( T%d )\n", GetTrkIndex(trk) ) ); + LOG( log_group, 1, ( "Ungroup( T%d )\n", GetTrkIndex(trk) ) ); epCnt = GetTrkEndPtCnt(trk); segCnt = xx->segCnt; int trackCount = 0; for ( sp=xx->segs; sp<&xx->segs[xx->segCnt]; sp++ ) { - if (IsSegTrack(sp)) trackCount++; + if (IsSegTrack(sp)) { trackCount++; } } - //ASSERT( (epCnt==0) == (segCnt==0) ); - ASSERT( (epCnt==0) == (trackCount==0) ); + //CHECK( (epCnt==0) == (segCnt==0) ); + CHECK( (epCnt==0) == (trackCount==0) ); turnoutChanged = FALSE; if ( epCnt > 0 ) { turnoutChanged = TRUE; /* 1: collect EPs */ - DYNARR_SET( trkEndPt_t, tempEndPts_da, epCnt ); + TempEndPtsSet( epCnt ); DYNARR_SET( segTrack_t, segTrack_da, segCnt ); - memset( segTrack_da.ptr, 0, segCnt * sizeof segTrack(0) ); + memset( &segTrack(0), 0, segCnt * sizeof segTrack(0) ); for ( ep=0; ep<epCnt; ep++ ) { - epp = &tempEndPts(ep); - epp->pos = GetTrkEndPos( trk, ep ); - epp->angle = GetTrkEndAngle( trk, ep ); - Rotate( &epp->pos, xx->orig, -xx->angle ); - epp->pos.x -= xx->orig.x; - epp->pos.y -= xx->orig.y; - epp->track = GetTrkEndTrk( trk, ep ); - if ( epp->track ) - epp->index = GetEndPtConnectedToMe( epp->track, trk ); - else - epp->index = -1; -LOG( log_group, 1, ( " EP%d = [%0.3f %0.3f] A%0.3f T%d.%d\n", ep, epp->pos.x, epp->pos.y, epp->angle, epp->track?GetTrkIndex(epp->track):-1, epp->track?epp->index:-1 ) ); + epp = TempEndPt(ep); + coOrd pos = GetTrkEndPos( trk, ep ); + Rotate( &pos, xx->orig, -xx->angle ); + pos.x -= xx->orig.x; + pos.y -= xx->orig.y; + ANGLE_T angle = GetTrkEndAngle( trk, ep ); + track_p trk1 = GetTrkEndTrk( trk, ep ); + EPINX_T ep1; + ep1 = trk1 ? GetEndPtConnectedToMe( trk1, trk ) : -1 ; + SetEndPt( epp, pos, angle ); + SetEndPtTrack( epp, trk1 ); + // Remember what EP on trk1 was connecting to me + SetEndPtEndPt( epp, ep1 ); + LOG( log_group, 1, ( " EP%d = [%0.3f %0.3f] A%0.3f T%d.%d\n", ep, pos.x, pos.y, + angle, trk1?GetTrkIndex(trk1):-1, ep1 ) ); } /* 3: Count number of times each segment is referenced * If the refcount differs between adjacent segments * add segment with smaller count to mergePts * Treat EndPts as a phantom segment with inx above segCnt - * Path ends that don't map onto a real EndPt (bumpers) get a fake EP + * Path ends that don't map onto a real EndPt (bumpers) get a virtual EP */ DYNARR_SET( int, refCount_da, segCnt+epCnt ); - memset( refCount_da.ptr, 0, refCount_da.cnt * sizeof *(int*)0 ); + memset( &refCount(0), 0, refCount_da.cnt * sizeof *(int*)0 ); cp = (char *)GetPaths( trk ); while ( cp[0] ) { cp += strlen(cp)+1; while ( cp[0] ) { + // Process 1st seg in sub-path GetSegInxEP( cp[0], &segInx, &segEP ); + // Find EP its connected to pos = GetSegEndPt( xx->segs+segInx, segEP, FALSE, NULL ); - segInx1 = FindEP( tempEndPts_da.cnt, &tempEndPts(0), pos ); + segInx1 = FindEP( TempEndPtsCount(), TempEndPt(0), pos ); if ( segInx1 >= 0 ) { + // Found existing EP, incr it's refCount segInx1 += segCnt; if ( segInx1 >= refCount_da.cnt ) { InputError( "Invalid segInx1 %d", TRUE, segInx1 ); @@ -274,44 +302,52 @@ LOG( log_group, 1, ( " EP%d = [%0.3f %0.3f] A%0.3f T%d.%d\n", ep, epp->pos.x, ep } refCount(segInx1)++; } else { - DYNARR_APPEND( trkEndPt_t, tempEndPts_da, 10 ); + // No existing EP: must be a bumper, add virtual EP + epp = TempEndPtsAppend(); DYNARR_APPEND( int, refCount_da, 10 ); - epp = &tempEndPts(tempEndPts_da.cnt-1); - epp->pos = pos; - epp->angle = 0; + SetEndPt( epp, pos, 0 ); segInx1 = refCount_da.cnt-1; - refCount(segInx1) = 2; + refCount(segInx1) = GROUP_BUMPER_REFCOUNT; } segEP1 = 0; while ( cp[0] ) { + // Process remaining segs GetSegInxEP( cp[0], &segInx, &segEP ); if ( segInx1 >= refCount_da.cnt ) { InputError( "Invalid segInx1 %d", TRUE, segInx1 ); return; } + // Incr it's refCoount refCount(segInx)++; - if ( refCount(segInx) > refCount(segInx1) ) + // Is my refCount > then previous seg/EP? + if ( refCount(segInx) > refCount(segInx1) ) { AddMergePt( segInx, segEP ); - if ( refCount(segInx1) > refCount(segInx) ) + } + // Is previous seg/EP refCount > my refCount + if ( refCount(segInx1) > refCount(segInx) ) { AddMergePt( segInx1, segEP1 ); + } + // Advance to next seg segInx1 = segInx; segEP1 = 1-segEP; cp++; } + // Process last seg in sub-path GetSegInxEP( cp[-1], &segInx, &segEP ); + // Find EP its connected to pos = GetSegEndPt( xx->segs+segInx, 1-segEP, FALSE, NULL ); - segInx = FindEP( tempEndPts_da.cnt, &tempEndPts(0), pos ); + segInx = FindEP( TempEndPtsCount(), TempEndPt(0), pos ); if ( segInx >= 0 ) { + // Found EP, incr refCount segInx += segCnt; refCount(segInx)++; } else { - DYNARR_APPEND( trkEndPt_t, tempEndPts_da, 10 ); + // No existing EP: must be a bumper, add virtual EP + epp = TempEndPtsAppend(); DYNARR_APPEND( int, refCount_da, 10 ); - epp = &tempEndPts(tempEndPts_da.cnt-1); - epp->pos = pos; - epp->angle = 0; + SetEndPt( epp, pos, 0 ); segInx = refCount_da.cnt-1; - refCount(segInx) = 2; + refCount(segInx) = GROUP_BUMPER_REFCOUNT; } if ( refCount(segInx) > refCount(segInx1) ) { AddMergePt( segInx, 0 ); @@ -320,14 +356,13 @@ LOG( log_group, 1, ( " EP%d = [%0.3f %0.3f] A%0.3f T%d.%d\n", ep, epp->pos.x, ep } cp++; } - epCnt1 = tempEndPts_da.cnt; - + /* 4: For each path element, map segment to a mergePt if the adjacent segment * and EP is a mergePt * If segment is already mapped then merge mergePts */ DYNARR_SET( int, refCount_da, segCnt ); - memset( refCount_da.ptr, -1, segCnt * sizeof *(int*)0 ); + memset( &refCount(0), -1, segCnt * sizeof *(int*)0 ); cp = (char *)GetPaths( trk ); while ( cp[0] ) { cp += strlen(cp)+1; @@ -335,7 +370,7 @@ LOG( log_group, 1, ( " EP%d = [%0.3f %0.3f] A%0.3f T%d.%d\n", ep, epp->pos.x, ep GetSegInxEP( cp[0], &segInx, &segEP ); pos = GetSegEndPt( xx->segs+segInx, segEP, FALSE, NULL ); /*REORIGIN1( pos, xx->angle, xx->orig );*/ - segInx1 = FindEP( tempEndPts_da.cnt, &tempEndPts(0), pos ); + segInx1 = FindEP( TempEndPtsCount(), TempEndPt(0), pos ); if ( segInx1 >= 0 ) { segInx1 += segCnt; } @@ -360,7 +395,7 @@ LOG( log_group, 1, ( " EP%d = [%0.3f %0.3f] A%0.3f T%d.%d\n", ep, epp->pos.x, ep GetSegInxEP( cp[-1], &segInx, &segEP ); pos = GetSegEndPt( xx->segs+segInx, 1-segEP, FALSE, NULL ); /*REORIGIN1( pos, xx->angle, xx->orig );*/ - segInx = FindEP( tempEndPts_da.cnt, &tempEndPts(0), pos ); + segInx = FindEP( TempEndPtsCount(), TempEndPt(0), pos ); if ( segInx >= 0 ) { segInx += segCnt; for ( inx=0; inx<mergePt_da.cnt; inx++ ) { @@ -379,8 +414,9 @@ LOG( log_group, 1, ( " EP%d = [%0.3f %0.3f] A%0.3f T%d.%d\n", ep, epp->pos.x, ep */ if ( mergePt_da.cnt > 0 ) { for ( segInx=0; segInx<segCnt; segInx++ ) - if ( refCount(segInx) != mergePt(0).inx ) + if ( refCount(segInx) != mergePt(0).inx ) { break; + } if ( segInx == segCnt ) { /* all segments on same turnout, nothing we can do here */ turnoutChanged = FALSE; @@ -397,11 +433,13 @@ LOG( log_group, 1, ( " EP%d = [%0.3f %0.3f] A%0.3f T%d.%d\n", ep, epp->pos.x, ep wDrawDelayUpdate( mainD.d, TRUE ); if ( turnoutChanged ) { for ( ep=0; ep<epCnt; ep++ ) { - epp = &tempEndPts(ep); - if ( epp->track ) { - DrawEndPt( &mainD, epp->track, epp->index, wDrawColorWhite ); + epp = TempEndPt(ep); + track_p trk1 = GetEndPtTrack(epp); + if ( trk1 ) { + EPINX_T ep1 = GetEndPtEndPt(epp); + DrawEndPt( &mainD, trk1, ep1, wDrawColorWhite ); DrawEndPt( &mainD, trk, ep, wDrawColorWhite ); - DisconnectTracks( trk, ep, epp->track, epp->index ); + DisconnectTracks( trk, ep, trk1, ep1 ); } } } @@ -432,11 +470,13 @@ LOG( log_group, 1, ( " EP%d = [%0.3f %0.3f] A%0.3f T%d.%d\n", ep, epp->pos.x, ep */ for ( inx=0; inx<mergePt_da.cnt; inx++ ) { mp = &mergePt(inx); - if ( mp->inx != inx ) + if ( mp->inx != inx ) { continue; + } DYNARR_RESET( trkSeg_t, tempSegs_da ); - DYNARR_SET( trkEndPt_t, tempEndPts_da, epCnt1 ); DYNARR_RESET( char, pathPtr_da ); + // Mark start of virtual EPs for this MergePt + epCnt1 = TempEndPtsCount(); for ( segInx=0; segInx<segCnt; segInx++ ) { if ( refCount(segInx) == inx ) { DYNARR_APPEND( trkSeg_t, tempSegs_da, 10 ); @@ -451,22 +491,23 @@ LOG( log_group, 1, ( " EP%d = [%0.3f %0.3f] A%0.3f T%d.%d\n", ep, epp->pos.x, ep pathPtr(off+2) = '\0'; for ( ep=0; ep<2; ep++ ) { pos = GetSegEndPt( xx->segs+segInx, ep, FALSE, &angle ); - segEP = FindEP( epCnt1, &tempEndPts(0), pos ); + segEP = FindEP( epCnt1, TempEndPt(0), pos ); if ( segEP >= 0 && segEP >= epCnt && segEP < epCnt1 ) { /* was a bumper: no EP */ eps[ep] = -1; + // TODO-BUMPER To support Bumpers remove this continue continue; } REORIGIN1( pos, xx->angle, xx->orig ); angle = NormalizeAngle( xx->angle+angle ); - eps[ep] = FindEP( tempEndPts_da.cnt-epCnt1, &tempEndPts(epCnt1), pos ); + eps[ep] = -1; + if ( TempEndPtsCount()-epCnt1 > 0 ) { + eps[ep] = FindEP( TempEndPtsCount()-epCnt1, TempEndPt(epCnt1), pos ); + } if ( eps[ep] < 0 ) { - DYNARR_APPEND( trkEndPt_t, tempEndPts_da, 10 ); - eps[ep] = tempEndPts_da.cnt-1-epCnt1; - epp = &tempEndPts(tempEndPts_da.cnt-1); - memset( epp, 0, sizeof *epp ); - epp->pos = pos; - epp->angle = angle; + epp = TempEndPtsAppend(); + eps[ep] = TempEndPtsCount()-1-epCnt1; + SetEndPt( epp, pos, angle ); } } segTrack(segInx).ep[0] = eps[0]; @@ -475,10 +516,7 @@ LOG( log_group, 1, ( " EP%d = [%0.3f %0.3f] A%0.3f T%d.%d\n", ep, epp->pos.x, ep } DYNARR_SET( char, pathPtr_da, pathPtr_da.cnt+1 ); pathPtr(pathPtr_da.cnt-1) = '\0'; - if ( tempSegs_da.cnt == 0 ) { - AbortProg( "tempSegs_da.cnt == 0" ); - continue; - } + CHECK ( tempSegs_da.cnt != 0 ); GetSegBounds( zero, 0, tempSegs_da.cnt, &tempSegs(0), &orig, &size ); orig.x = -orig.x; orig.y = -orig.y; @@ -486,7 +524,9 @@ LOG( log_group, 1, ( " EP%d = [%0.3f %0.3f] A%0.3f T%d.%d\n", ep, epp->pos.x, ep Rotate( &orig, zero, xx->angle ); orig.x = xx->orig.x - orig.x; orig.y = xx->orig.y - orig.y; - trk1 = NewCompound( T_TURNOUT, 0, orig, xx->angle, xx->title, tempEndPts_da.cnt-epCnt1, &tempEndPts(epCnt1), (PATHPTR_T)&pathPtr(0), tempSegs_da.cnt, &tempSegs(0) ); + trk1 = NewCompound( T_TURNOUT, 0, orig, xx->angle, xx->title, + TempEndPtsCount()-epCnt1, TempEndPt(epCnt1), (PATHPTR_T)&pathPtr(0), + tempSegs_da.cnt, &tempSegs(0) ); xx1 = GET_EXTRA_DATA(trk1, T_TURNOUT, extraDataCompound_t); xx1->ungrouped = TRUE; xx1->pathOverRide = xx->pathOverRide; @@ -506,9 +546,10 @@ LOG( log_group, 1, ( " EP%d = [%0.3f %0.3f] A%0.3f T%d.%d\n", ep, epp->pos.x, ep /* 8: for remaining segments, create simple tracks */ for ( segInx=0; segInx<segCnt; segInx++ ) { - if ( refCount(segInx) >= 0 ) continue; - if ( ! IsSegTrack( xx->segs+segInx ) ) + if ( refCount(segInx) >= 0 ) { continue; } + if ( ! IsSegTrack( xx->segs+segInx ) ) { continue; + } SegProc( SEGPROC_NEWTRACK, xx->segs+segInx, &segProcData ); SetTrkScale( segProcData.newTrack.trk, GetTrkScale(trk) ); SetTrkBits( segProcData.newTrack.trk, TB_SELECTED ); @@ -528,13 +569,16 @@ LOG( log_group, 1, ( " EP%d = [%0.3f %0.3f] A%0.3f T%d.%d\n", ep, epp->pos.x, ep /* joint EP to this segment */ GetSegInxEP( cp[0], &segInx, &segEP ); stp = &segTrack(segInx); - ep = FindEP( epCnt, &tempEndPts(0), GetSegEndPt( xx->segs+segInx, segEP, FALSE, NULL ) ); + ep = FindEP( epCnt, TempEndPt(0), GetSegEndPt( xx->segs+segInx, segEP, FALSE, + NULL ) ); if ( ep >= 0 ) { - epp = &tempEndPts(ep); - if ( epp->track ) { - ConnectTracks( stp->trk, stp->ep[segEP], epp->track, epp->index ); - DrawEndPt( &mainD, epp->track, epp->index, GetTrkColor(epp->track,&mainD) ); - epp->track = NULL; + epp = TempEndPt(ep); + track_p trk1 = GetEndPtTrack(epp); + if ( trk1 ) { + EPINX_T ep1 = GetEndPtEndPt(epp); + ConnectTracks( stp->trk, stp->ep[segEP], trk1, ep1 ); + DrawEndPt( &mainD, trk1, ep1, GetTrkColor(trk1, &mainD) ); + SetEndPtTrack( epp, NULL ); // Finished with this EP } } stp1 = stp; @@ -543,28 +587,35 @@ LOG( log_group, 1, ( " EP%d = [%0.3f %0.3f] A%0.3f T%d.%d\n", ep, epp->pos.x, ep while ( cp[0] ) { GetSegInxEP( cp[0], &segInx, &segEP ); stp = &segTrack(segInx); + // Check EPs are not virtual (Bumpers) + // TODO-BUMPER May not be necessary + CHECK( stp->ep[segEP] >= 0 ); + CHECK( stp1->ep[segEP1] >= 0 ); trk0 = GetTrkEndTrk( stp->trk, stp->ep[segEP] ); trk1 = GetTrkEndTrk( stp1->trk, stp1->ep[segEP1] ); if ( trk0 == NULL ) { - if ( trk1 != NULL ) - AbortProg( "ungroup: seg half connected" ); + CHECK ( trk1 == NULL ); ConnectTracks( stp->trk, stp->ep[segEP], stp1->trk, stp1->ep[segEP1] ); } else { - if ( trk1 != stp->trk || stp1->trk != trk0 ) - AbortProg( "ungroup: last seg not connected to curr" ); + CHECK( trk1 == stp->trk ); + CHECK( stp1->trk == trk0 ); + // ungroup: last seg not connected to curr } stp1 = stp; segEP1 = 1-segEP; cp++; } /* joint EP to last segment */ - ep = FindEP( epCnt, &tempEndPts(0), GetSegEndPt( xx->segs+segInx, segEP1, FALSE, NULL ) ); + ep = FindEP( epCnt, TempEndPt(0), GetSegEndPt( xx->segs+segInx, segEP1, FALSE, + NULL ) ); if ( ep > 0 ) { - epp = &tempEndPts(ep); - if ( epp->track ) { - ConnectTracks( stp1->trk, stp1->ep[segEP1], epp->track, epp->index ); - DrawEndPt( &mainD, epp->track, epp->index, wDrawColorWhite ); - epp->track = NULL; + epp = TempEndPt(ep); + track_p trk1 = GetEndPtTrack( epp ); + if ( trk1 ) { + EPINX_T ep1 = GetEndPtEndPt( epp ); + ConnectTracks( stp1->trk, stp1->ep[segEP1], trk1, ep1 ); + DrawEndPt( &mainD, trk1, ep1, wDrawColorWhite ); + SetEndPtTrack( epp, NULL ); // Finished with this EP } } cp++; @@ -584,8 +635,9 @@ LOG( log_group, 1, ( " EP%d = [%0.3f %0.3f] A%0.3f T%d.%d\n", ep, epp->pos.x, ep mp->trk = NULL; } } else { - if ( segTrack(segInx).trk ) + if ( segTrack(segInx).trk ) { DrawNewTrack( segTrack(segInx).trk ); + } } } wDrawDelayUpdate( mainD.d, FALSE ); @@ -601,8 +653,9 @@ EXPORT void DoUngroup( void * unused ) int oldTrackCount; TRKINX_T lastTrackIndex; - if ( log_group < 0 ) + if ( log_group < 0 ) { log_group = LogFindIndex( "group" ); + } groupManuf[0] = 0; groupDesc[0] = 0; groupPartno[0] = 0; @@ -615,65 +668,71 @@ EXPORT void DoUngroup( void * unused ) if ( GetTrkSelected( trk ) && GetTrkIndex(trk) <= lastTrackIndex ) { oldTrackCount = trackCount; UngroupTrack( trk ); - if ( oldTrackCount != trackCount ) + if ( oldTrackCount != trackCount ) { ungroupCnt++; + } } } - if ( ungroupCnt ) + if ( ungroupCnt ) { InfoMessage( _("%d objects ungrouped"), ungroupCnt ); - else + } else { InfoMessage( _("No objects ungrouped") ); + } } static drawCmd_t groupD = { - NULL, &tempSegDrawFuncs, DC_SEGTRACK, 1, 0.0, {0.0, 0.0}, {0.0, 0.0}, Pix2CoOrd, CoOrd2Pix }; + NULL, &tempSegDrawFuncs, DC_SEGTRACK, 1, 0.0, {0.0, 0.0}, {0.0, 0.0}, Pix2CoOrd, CoOrd2Pix +}; static long groupSegCnt; static long groupReplace; static long groupNoCombine; static double groupOriginX; static double groupOriginY; char * groupReplaceLabels[] = { N_("Replace with new group?"), NULL }; +char * groupNoCombineLabels[] = { N_("Turntable/TransferTable/DblSlipSwith?"), NULL }; static wWin_p groupW; static paramIntegerRange_t r0_999999 = { 0, 999999 }; static paramFloatRange_t r_1000_1000 = { -1000.0, 1000.0, 80 }; static paramData_t groupPLs[] = { -/*0*/ { PD_STRING, groupManuf, "manuf", PDO_NOPREF | PDO_NOTBLANK, I2VP(350), N_("Manufacturer"), 0, 0, sizeof(groupManuf)}, -/*1*/ { PD_STRING, groupDesc, "desc", PDO_NOPREF | PDO_NOTBLANK, I2VP(230), N_("Description"), 0, 0, sizeof(groupDesc)}, -/*2*/ { PD_STRING, groupPartno, "partno", PDO_NOPREF|PDO_DLGHORZ|PDO_DLGIGNORELABELWIDTH|PDO_NOTBLANK, I2VP(100), N_("#"), 0, 0, sizeof(groupPartno)}, -/*3*/ { PD_LONG, &groupSegCnt, "segcnt", PDO_NOPREF, &r0_999999, N_("# Segments"), BO_READONLY }, + /*0*/ { PD_STRING, groupManuf, "manuf", PDO_NOPREF | PDO_NOTBLANK, I2VP(350), N_("Manufacturer"), 0, 0, sizeof(groupManuf)}, + /*1*/ { PD_STRING, groupDesc, "desc", PDO_NOPREF | PDO_NOTBLANK, I2VP(230), N_("Description"), 0, 0, sizeof(groupDesc)}, + /*2*/ { PD_STRING, groupPartno, "partno", PDO_NOPREF|PDO_DLGHORZ|PDO_DLGIGNORELABELWIDTH|PDO_NOTBLANK, I2VP(100), N_("#"), 0, 0, sizeof(groupPartno)}, + /*3*/ { PD_LONG, &groupSegCnt, "segcnt", PDO_NOPREF, &r0_999999, N_("# Segments"), BO_READONLY }, #define I_GROUP_ORIGIN_OFFSET 4 /* Need to change if add above */ -/*4*/ { PD_FLOAT, &groupOriginX, "orig", PDO_DIM, &r_1000_1000, N_("Offset X,Y:")}, -/*5*/ { PD_FLOAT, &groupOriginY, "origy",PDO_DIM | PDO_DLGHORZ, &r_1000_1000, ""}, -/*6*/ { PD_TOGGLE, &groupReplace, "replace", 0, groupReplaceLabels, "", BC_HORZ|BC_NOBORDER } }; + /*4*/ { PD_FLOAT, &groupOriginX, "orig", PDO_DIM, &r_1000_1000, N_("Offset X,Y:")}, + /*5*/ { PD_FLOAT, &groupOriginY, "origy",PDO_DIM | PDO_DLGHORZ, &r_1000_1000, ""}, + /*6*/ { PD_TOGGLE, &groupNoCombine, "noCombine", 0, groupNoCombineLabels, "", BC_HORZ|BC_NOBORDER }, + /*7*/ { PD_TOGGLE, &groupReplace, "replace", 0, groupReplaceLabels, "", BC_HORZ|BC_NOBORDER } +}; static paramGroup_t groupPG = { "group", 0, groupPLs, COUNT( groupPLs ) }; typedef struct { - track_p trk; - int segStart; - int segEnd; - int totalSegStart; //Where we are overall - int totalSegEnd; - } groupTrk_t, * groupTrk_p; + track_p trk; + int segStart; + int segEnd; + int totalSegStart; //Where we are overall + int totalSegEnd; +} groupTrk_t, * groupTrk_p; static dynArr_t groupTrk_da; #define groupTrk(N) DYNARR_N( groupTrk_t, groupTrk_da, N ) typedef struct { - int groupInx; - EPINX_T ep1, ep2; - PATHPTR_T path; - BOOL_T flip; - } pathElem_t, *pathElem_p; + int groupInx; + EPINX_T ep1, ep2; + PATHPTR_T path; + BOOL_T flip; +} pathElem_t, *pathElem_p; typedef struct { - int pathElemStart; - int pathElemEnd; - EPINX_T ep1, ep2; - int conflicts; - BOOL_T inGroup; - BOOL_T done; - } path_t, *path_p; + int pathElemStart; + int pathElemEnd; + EPINX_T ep1, ep2; + int conflicts; + BOOL_T inGroup; + BOOL_T done; +} path_t, *path_p; static dynArr_t path_da; #define path(N) DYNARR_N( path_t, path_da, N ) static dynArr_t pathElem_da; @@ -684,34 +743,36 @@ static int pathElemStart; /* * Find sub-path that connects the 2 EPs for the given track * - * \param trk IN Track + * \param trk IN Track * \param ep1, ep2 IN EndPt index * \param BOOL_T *flip OUT whether path is flipped * \return sub-path that connects the 2 EPs */ static char * FindPathBtwEP( - track_p trk, - EPINX_T ep1, - EPINX_T ep2, - BOOL_T * flip ) + track_p trk, + EPINX_T ep1, + EPINX_T ep2, + BOOL_T * flip ) { char * cp; coOrd trkPos[2]; - - LOG( log_group, 3, (" FindPathBtwEP: T%d .%d .%d = ", trk?GetTrkIndex(trk):-1, ep1, ep2 )); + + LOG( log_group, 3, (" FindPathBtwEP: T%d .%d .%d = ", trk?GetTrkIndex(trk):-1, + ep1, ep2 )); if ( GetTrkType(trk) != T_TURNOUT ) { - if ( ep1+ep2 != 1 ) - AbortProg( "findPathBtwEP" ); + CHECK( ep1+ep2 == 1 ); *flip = ( ep1 == 1 ); - if (GetTrkType(trk) == T_CORNU ) { // Cornu doesn't have a path but lots of segs! + if (GetTrkType(trk) == + T_CORNU ) { // Cornu doesn't have a path but lots of segs! cp = CreateSegPathList(trk); // Make path -LOG( log_group, 2, ( " Group: Cornu path:%s \n", cp ) ) - } else cp = "\1\0\0"; //One segment (but could be a Bezier) + LOG( log_group, 2, ( " Group: Cornu path:%s \n", cp ) ) + } else { cp = "\1\0\0"; } //One segment (but could be a Bezier) LOG( log_group, 3, (" Flip:%s Path= Seg=%d-\n", *flip?"T":"F", *cp ) ); return cp; } - struct extraDataCompound_t * xx = GET_EXTRA_DATA( trk, T_TURNOUT, extraDataCompound_t ); + struct extraDataCompound_t * xx = GET_EXTRA_DATA( trk, T_TURNOUT, + extraDataCompound_t ); cp = (char *)GetPaths( trk ); trkPos[0] = GetTrkEndPos(trk,ep1); Rotate( &trkPos[0], xx->orig, -xx->angle ); @@ -740,7 +801,7 @@ LOG( log_group, 2, ( " Group: Cornu path:%s \n", cp ) ) cp += strlen(cp); GetSegInxEP( cp[-1], &segInx, &segEP ); segPos[1] = GetSegEndPt( &xx->segs[segInx], 1-segEP, FALSE, NULL ); - + // Find the closest seg end for ( int inx = 0; inx<2; inx++ ) { // Check 1st end @@ -750,7 +811,9 @@ LOG( log_group, 2, ( " Group: Cornu path:%s \n", cp ) ) DIST_T dist2 = FindDistance( trkPos[1], segPos[1-inx] ); if ( dist2 > dist1 ) // 2nd end is further away + { dist1 = dist2; + } if ( dist1 < connectDistance && dist1 < dist ) { // both ends are closest dist = dist1; @@ -764,18 +827,19 @@ LOG( log_group, 2, ( " Group: Cornu path:%s \n", cp ) ) } cp++; } -LOG( log_group, 3, (" %s: %d..%d Flip:%s\n", pName, path?path[0]:-1, path?path[strlen(path)-1]:-1, *flip?"T":"F" ) ); + LOG( log_group, 3, (" %s: %d..%d Flip:%s\n", pName, path?path[0]:-1, + path?path[strlen(path)-1]:-1, *flip?"T":"F" ) ); return path; } static int GroupShortestPathFunc( - SPTF_CMD cmd, - track_p trk, - EPINX_T ep1, - EPINX_T ep2, - DIST_T dist, - void * data ) + SPTF_CMD cmd, + track_p trk, + EPINX_T ep1, + EPINX_T ep2, + DIST_T dist, + void * data ) { track_p trk1; path_t *pp; @@ -788,13 +852,20 @@ static int GroupShortestPathFunc( switch ( cmd ) { case SPTC_MATCH: - if ( !GetTrkSelected(trk) ) + if ( !GetTrkSelected(trk) ) { return 0; + } + // TODO-BUMPER may not be necessary + if ( GetTrkEndPtCnt(trk) < 2 && ep1 >= 1 ) { + return 1; + } trk1 = GetTrkEndTrk(trk,ep1); - if ( trk1 == NULL ) + if ( trk1 == NULL ) { return 1; - if ( !GetTrkSelected(trk1) ) + } + if ( !GetTrkSelected(trk1) ) { return 1; + } return 0; case SPTC_MATCHANY: @@ -803,7 +874,7 @@ static int GroupShortestPathFunc( case SPTC_ADD_TRK: LOG( log_group, 4, ( " Add T%d[%d]\n", GetTrkIndex(trk), ep2 ) ) DYNARR_APPEND( pathElem_t, pathElem_da, 10 ); - ppp = &pathElem(pathElem_da.cnt-1); + ppp = &pathElem(pathElem_da.cnt-1); for ( inx=0; inx<groupTrk_da.cnt; inx++ ) { if ( groupTrk(inx).trk == trk ) { ppp->groupInx = inx; @@ -813,7 +884,9 @@ static int GroupShortestPathFunc( return 0; } } - AbortProg( "GroupShortestPathFunc(SPTC_ADD_TRK, T%d) - track not in group", GetTrkIndex(trk) ); + CHECKMSG( FALSE, + ( "GroupShortestPathFunc(SPTC_ADD_TRK, T%d) - track not in group", + GetTrkIndex(trk) ) ); case SPTC_TERMINATE: ppp = &pathElem(pathElemStart); @@ -825,31 +898,35 @@ static int GroupShortestPathFunc( pos2 = GetTrkEndPos( trk, ppp->ep1 ); ang2 = GetTrkEndAngle( trk, ppp->ep1 ); ep1 = ep2 = -1; - for ( ep=0; ep<tempEndPts_da.cnt; ep++ ) { + for ( ep=0; ep<TempEndPtsCount(); ep++ ) { if ( ep1 < 0 ) { - dist = FindDistance( pos1, tempEndPts(ep).pos ); - angle = NormalizeAngle( ang1 - tempEndPts(ep).angle + connectAngle/2.0 ); - if ( dist < connectDistance && angle < connectAngle ) + dist = FindDistance( pos1, GetEndPtPos(TempEndPt(ep))); + angle = NormalizeAngle( ang1 - GetEndPtAngle(TempEndPt(ep)) + + connectAngle/2.0 ); + if ( dist < connectDistance && angle < connectAngle ) { ep1 = ep; + } } if ( ep2 < 0 ) { - dist = FindDistance( pos2, tempEndPts(ep).pos ); - angle = NormalizeAngle( ang2 - tempEndPts(ep).angle + connectAngle/2.0 ); - if ( dist < connectDistance && angle < connectAngle ) + dist = FindDistance( pos2, GetEndPtPos(TempEndPt(ep)) ); + angle = NormalizeAngle( ang2 - GetEndPtAngle(TempEndPt(ep)) + + connectAngle/2.0 ); + if ( dist < connectDistance && angle < connectAngle ) { ep2 = ep; + } } } if ( ep1<0 || ep2<0 ) { -LOG( log_group, 4, ( " Remove: ep not found\n" ) ) - pathElem_da.cnt = pathElemStart; + LOG( log_group, 4, ( " Remove: ep not found\n" ) ) + DYNARR_SET( pathElem_t, pathElem_da, pathElemStart ); return 0; } for ( inx=0; inx<path_da.cnt; inx++ ) { pp = &path(inx); if ( ( ep1 < 0 || ( pp->ep1 == ep1 || pp->ep2 == ep1 ) ) && - ( ep2 < 0 || ( pp->ep1 == ep2 || pp->ep2 == ep2 ) ) ) { -LOG( log_group, 4, ( " Remove: duplicate path P%d\n", inx ) ) - pathElem_da.cnt = pathElemStart; + ( ep2 < 0 || ( pp->ep1 == ep2 || pp->ep2 == ep2 ) ) ) { + LOG( log_group, 4, ( " Remove: duplicate path P%d\n", inx ) ) + DYNARR_SET( pathElem_t, pathElem_da, pathElemStart ); return 0; } } @@ -861,18 +938,21 @@ LOG( log_group, 4, ( " Remove: duplicate path P%d\n", inx ) ) pp->ep1 = ep1; pp->ep2 = ep2; pathElemStart = pathElem_da.cnt; -LOG( log_group, 4, ( " Keep\n" ) ) + LOG( log_group, 4, ( " Keep\n" ) ) return 0; case SPTC_IGNNXTTRK: - if ( !GetTrkSelected(trk) ) + if ( !GetTrkSelected(trk) ) { return 1; - if ( ep1 == ep2 ) + } + if ( ep1 == ep2 ) { return 1; - if ( GetTrkEndPtCnt(trk) == 2 ) + } + if ( GetTrkEndPtCnt(trk) == 2 ) { return 0; - if ( GetTrkType(trk) != T_TURNOUT ) - AbortProg( "GroupShortestPathFunc(IGNNXTTRK,T%d:%d,%d)", GetTrkIndex(trk), ep1, ep2 ); + } + CHECKMSG( GetTrkType(trk) == T_TURNOUT, + ( "GroupShortestPathFunc(IGNNXTTRK,T%d:%d,%d)", GetTrkIndex(trk), ep1, ep2 ) ); return FindPathBtwEP( trk, ep2, ep1, &flip ) == NULL; case SPTC_VALID: @@ -884,8 +964,8 @@ LOG( log_group, 4, ( " Keep\n" ) ) static int CmpGroupOrder( - const void * ptr1, - const void * ptr2 ) + const void * ptr1, + const void * ptr2 ) { int inx1 = *(int*)ptr1; int inx2 = *(int*)ptr2; @@ -895,71 +975,76 @@ static int CmpGroupOrder( static coOrd endPtOrig; static ANGLE_T endPtAngle; static int CmpEndPtAngle( - const void * ptr1, - const void * ptr2 ) + const void * ptr1, + const void * ptr2 ) { ANGLE_T angle; trkEndPt_p epp1 = (trkEndPt_p)ptr1; trkEndPt_p epp2 = (trkEndPt_p)ptr2; - - angle = NormalizeAngle(FindAngle(endPtOrig,epp1->pos)-endPtAngle) - NormalizeAngle(FindAngle(endPtOrig,epp2->pos)-endPtAngle); + + angle = NormalizeAngle(FindAngle(endPtOrig, + GetEndPtPos(epp1))-endPtAngle) - NormalizeAngle(FindAngle(endPtOrig, + GetEndPtPos(epp2))-endPtAngle); return (int)angle; } static int ConflictPaths( - path_p path0, - path_p path1 ) + path_p path0, + path_p path1 ) { if ( groupNoCombine != 0 ) { // No grouping return TRUE; } /* do these paths share an EP? */ - if ( path0->ep1 == path1->ep1 ) return TRUE; - if ( path0->ep1 == path1->ep2 ) return TRUE; - if ( path0->ep2 == path1->ep1 ) return TRUE; - if ( path0->ep2 == path1->ep2 ) return TRUE; + if ( path0->ep1 == path1->ep1 ) { return TRUE; } + if ( path0->ep1 == path1->ep2 ) { return TRUE; } + if ( path0->ep2 == path1->ep1 ) { return TRUE; } + if ( path0->ep2 == path1->ep2 ) { return TRUE; } return FALSE; } static BOOL_T CheckPathEndPt( - track_p trk, - char cc, - EPINX_T ep ) + track_p trk, + char cc, + EPINX_T ep ) { - struct extraDataCompound_t *xx = GET_EXTRA_DATA(trk, T_TURNOUT, extraDataCompound_t); + struct extraDataCompound_t *xx = GET_EXTRA_DATA(trk, T_TURNOUT, + extraDataCompound_t); wIndex_t segInx; EPINX_T segEP, epCnt; DIST_T d; coOrd pos; GetSegInxEP( cc, &segInx, &segEP ); - if ( ep ) segEP = 1-segEP; + if ( ep ) { segEP = 1-segEP; } pos = GetSegEndPt( &xx->segs[segInx], segEP, FALSE, NULL ); REORIGIN1( pos, xx->angle, xx->orig ); epCnt = GetTrkEndPtCnt(trk); for ( ep=0; ep<epCnt; ep++ ) { d = FindDistance( pos, GetTrkEndPos( trk, ep ) ); - if ( d < connectDistance ) + if ( d < connectDistance ) { return TRUE; + } } return FALSE; } static BOOL_T CheckForBumper( - track_p trk ) + track_p trk ) { char * cp; cp = (char *)GetPaths( trk ); while ( cp[0] ) { cp += strlen(cp)+1; while ( cp[0] ) { - if ( !CheckPathEndPt( trk, cp[0], 0 ) ) return FALSE; - while ( cp[0] ) + if ( !CheckPathEndPt( trk, cp[0], 0 ) ) { return FALSE; } + while ( cp[0] ) { cp++; - if ( !CheckPathEndPt( trk, cp[-1], 1 ) ) return FALSE; + } + if ( !CheckPathEndPt( trk, cp[-1], 1 ) ) { return FALSE; } cp++; } cp++; @@ -975,7 +1060,7 @@ static dynArr_t outputSegs_da; #define outputSegs(N) DYNARR_N( trkSeg_t, outputSegs_da, N) static void LogSeg( - trkSeg_p segP ) + trkSeg_p segP ) { if ( segP == NULL ) { LogPrintf( "<NULL>\n" ); @@ -989,15 +1074,15 @@ static void LogSeg( case SEG_BENCH: case SEG_TBLEDGE: LogPrintf( "[ %0.3f %0.3f ] [ %0.3f %0.3f ]\n", - segP->u.l.pos[0].x, segP->u.l.pos[0].y, - segP->u.l.pos[1].x, segP->u.l.pos[1].y ); + segP->u.l.pos[0].x, segP->u.l.pos[0].y, + segP->u.l.pos[1].x, segP->u.l.pos[1].y ); break; case SEG_CRVLIN: case SEG_CRVTRK: LogPrintf( "R:%0.3f [ %0.3f %0.3f } A0:%0.3f A1:%0.3f\n", - segP->u.c.radius, - segP->u.c.center.x, segP->u.c.center.y, - segP->u.c.a0, segP->u.c.a1 ); + segP->u.c.radius, + segP->u.c.center.x, segP->u.c.center.y, + segP->u.c.a0, segP->u.c.a1 ); break; default: LogPrintf( "%c:\n", segP->type ); @@ -1063,7 +1148,7 @@ static void GroupOk( void * unused ) DYNARR_RESET( groupTrk_t, groupTrk_da ); DYNARR_RESET( path_t, path_da ); DYNARR_RESET( pathElem_t, pathElem_da ); - DYNARR_RESET( trkEndPt_t, tempEndPts_da ); + TempEndPtsReset(); DYNARR_RESET( char, pathPtr_da ); ParamUpdate( &groupPG ); @@ -1074,8 +1159,9 @@ static void GroupOk( void * unused ) sprintf( message, "%s\t%s\t%s", groupManuf, groupDesc, groupPartno ); if ( strcmp( message, groupTitle ) != 0 ) { if ( FindCompound( FIND_TURNOUT|FIND_STRUCT, curScaleName, message ) ) - if ( !NoticeMessage2( 1, MSG_TODSGN_REPLACE, _("Yes"), _("No") ) ) + if ( !NoticeMessage2( 1, MSG_TODSGN_REPLACE, _("Yes"), _("No") ) ) { return; + } strcpy( groupTitle, message ); } @@ -1084,8 +1170,11 @@ static void GroupOk( void * unused ) * 1: Collect tracks */ trk = NULL; - int InInx = -1; +// int InInx = -1; BOOL_T hasTracks = FALSE; + wIndex_t nTrkSeg = 0; + wIndex_t nSeg = 0; + wIndex_t iLastTrkSeg = 0; while ( TrackIterate( &trk ) ) { if ( GetTrkSelected( trk ) ) { DYNARR_APPEND( groupTrk_t, groupTrk_da, 10 ); @@ -1093,7 +1182,7 @@ static void GroupOk( void * unused ) groupP->trk = trk; groupP->segStart = trackSegs_da.cnt; groupP->totalSegStart = tempSegs_da.cnt+trackSegs_da.cnt; - if (IsTrack(trk)) hasTracks = TRUE; + if (IsTrack(trk)) { hasTracks = TRUE; } if ( GetTrkType(trk) == T_TURNOUT || GetTrkType(trk) == T_STRUCTURE) { xx = GET_EXTRA_DATA(trk, T_NOTRACK, extraDataCompound_t); for ( pinx=0; pinx<xx->segCnt; pinx++ ) { @@ -1122,53 +1211,66 @@ static void GroupOk( void * unused ) } else if (GetTrkType(trk) == T_CORNU) { - int start = trackSegs_da.cnt; +// int start = trackSegs_da.cnt; - GetBezierSegmentsFromCornu(trk,&trackSegs_da,TRUE); //Only give back Bezier - cant be undone + GetBezierSegmentsFromCornu(trk,&trackSegs_da, + TRUE); //Only give back Bezier - cant be undone } else { - if (IsTrack(trk)) hasTracks=TRUE; + if (IsTrack(trk)) { hasTracks=TRUE; } segCnt = tempSegs_da.cnt; DrawTrack( trk, &groupD, wDrawColorBlack ); - DYNARR_APPEND( trkSeg_t, trackSegs_da, 10 ); - segPtr = &trackSegs(trackSegs_da.cnt-1); - *segPtr = tempSegs( segCnt ); - - if ( tempSegs_da.cnt != segCnt+1 ) { - NoticeMessage2( 0, MSG_CANNOT_GROUP_TRACK, _("Ok"), NULL, GetTrkTypeName(trk)); - wHide( groupW ); - return; + for ( ; segCnt < tempSegs_da.cnt; segCnt++ ) { + // Copy drawn segments + DYNARR_APPEND( trkSeg_t, trackSegs_da, 10 ); + segPtr = &trackSegs(trackSegs_da.cnt-1); + *segPtr = tempSegs( segCnt ); } + } + // Count number of track segs and if any appear after seg 127 + for ( ; nSeg < trackSegs_da.cnt; nSeg++ ) { + if ( IsSegTrack( &trackSegs( nSeg ) ) ) { + nTrkSeg++; + iLastTrkSeg = nSeg; + } } groupP->segEnd = trackSegs_da.cnt-1; } } -if ( log_group >= 1 && logTable(log_group).level >= 4 ) { - LogPrintf( "Track Segs:\n"); - for ( int inx = 0; inx < trackSegs_da.cnt; inx++ ) { - if (IsSegTrack(&trackSegs(inx))) { - LogPrintf( " %d: ", inx+1 ); - LogSeg( &trackSegs(inx) ); + if ( log_group >= 1 && logTable(log_group).level >= 4 ) { + LogPrintf( "Track Segs:\n"); + for ( int inx = 0; inx < trackSegs_da.cnt; inx++ ) { + if (IsSegTrack(&trackSegs(inx))) { + LogPrintf( " %d: ", inx+1 ); + LogSeg( &trackSegs(inx) ); + } } - } - LogPrintf( "Other Segs:\n"); - for ( int inx = 0; inx < trackSegs_da.cnt; inx++ ) { - if (!IsSegTrack(&trackSegs(inx))) { - LogPrintf( " %d: ", inx+1 ); - LogSeg( &tempSegs(inx) ); + LogPrintf( "Other Segs:\n"); + for ( int inx = 0; inx < trackSegs_da.cnt; inx++ ) { + if (!IsSegTrack(&trackSegs(inx))) { + LogPrintf( " %d: ", inx+1 ); + LogSeg( &tempSegs(inx) ); + } } } -} - if ( groupTrk_da.cnt>0 && hasTracks) { - if ( groupTrk_da.cnt > 128 ) { - NoticeMessage( MSG_TOOMANYSEGSINGROUP, _("Ok"), NULL ); - wDrawDelayUpdate( mainD.d, FALSE ); - wHide( groupW ); - return; - } + if ( nTrkSeg > MAX_PATH_SEGS ) { + // Too many track segs + NoticeMessage( MSG_TOOMANYSEGSINGROUP, _("Ok"), NULL ); + wDrawDelayUpdate( mainD.d, FALSE ); + wHide( groupW ); + return; + } + if ( iLastTrkSeg > MAX_PATH_SEGS ) { + // track segs beyond threshold + NoticeMessage( MSG_TOOMANYSEGSINGROUP2, _("Ok"), NULL ); + wDrawDelayUpdate( mainD.d, FALSE ); + wHide( groupW ); + return; + } + if ( groupTrk_da.cnt>0 && hasTracks) { /* * Collect EndPts and find paths */ @@ -1181,38 +1283,40 @@ if ( log_group >= 1 && logTable(log_group).level >= 4 ) { trk1 = GetTrkEndTrk(trk,ep); if ( trk1 == NULL || !GetTrkSelected(trk1) ) { /* boundary EP */ - for ( epN=0; epN<tempEndPts_da.cnt; epN++ ) { - dist = FindDistance( GetTrkEndPos(trk,ep), tempEndPts(epN).pos ); - angle = NormalizeAngle( GetTrkEndAngle(trk,ep) - tempEndPts(epN).angle + connectAngle/2.0 ); - if ( dist < connectDistance && angle < connectAngle ) + for ( epN=0; epN<TempEndPtsCount(); epN++ ) { + dist = FindDistance( GetTrkEndPos(trk,ep), GetEndPtPos(TempEndPt(epN)) ); + angle = NormalizeAngle( GetTrkEndAngle(trk, + ep) - GetEndPtAngle(TempEndPt(epN)) + connectAngle/2.0 ); + if ( dist < connectDistance && angle < connectAngle ) { break; + } } - if ( epN>=tempEndPts_da.cnt ) { - DYNARR_APPEND( trkEndPt_t, tempEndPts_da, 10 ); - endPtP = &tempEndPts(tempEndPts_da.cnt-1); - memset( endPtP, 0, sizeof *endPtP ); - endPtP->pos = GetTrkEndPos(trk,ep); - endPtP->angle = GetTrkEndAngle(trk,ep); - endPtP->track = trk1; - endPtP->index = (trk1?GetEndPtConnectedToMe(trk1,trk):-1); - endPtOrig.x += endPtP->pos.x; - endPtOrig.y += endPtP->pos.y; + if ( epN>=TempEndPtsCount() ) { + endPtP = TempEndPtsAppend(); + SetEndPt( endPtP, GetTrkEndPos(trk,ep), GetTrkEndAngle(trk,ep)); + SetEndPtTrack( endPtP, trk1 ); + // Remember what EP on trk1 was connecting to me + SetEndPtEndPt( endPtP, trk1?GetEndPtConnectedToMe(trk1,trk):-1 ); + endPtOrig.x += GetEndPtPos(endPtP).x; + endPtOrig.y += GetEndPtPos(endPtP).y; } } } } -if ( log_group >= 1 && logTable(log_group).level >= 4 ) { - LogPrintf( "EndPts:\n" ); - for ( int inx=0; inx<tempEndPts_da.cnt; inx++ ) { - endPtP = &tempEndPts(inx); - LogPrintf( " [ %0.3f %0.3f ] A:%0.3f, T:%d.%d\n", - endPtP->pos.x, endPtP->pos.y, endPtP->angle, endPtP->track?GetTrkIndex(endPtP->track):-1, endPtP->index ); - } -} + if ( log_group >= 1 && logTable(log_group).level >= 4 ) { + LogPrintf( "EndPts:\n" ); + for ( int inx=0; inx<TempEndPtsCount(); inx++ ) { + endPtP = TempEndPt(inx); + LogPrintf( " [ %0.3f %0.3f ] A:%0.3f, T:%d.%d\n", + GetEndPtPos(endPtP).x, GetEndPtPos(endPtP).y, GetEndPtAngle(endPtP), + GetEndPtTrack(endPtP)?GetTrkIndex(GetEndPtTrack(endPtP)):-1, + GetEndPtEndPt(endPtP) ); + } + } /* * 2: Collect EndPts */ - if ( tempEndPts_da.cnt <= 0 ) { + if ( TempEndPtsCount() <= 0 ) { NoticeMessage( _("No endpts"), _("Ok"), NULL ); wDrawDelayUpdate( mainD.d, FALSE ); wHide( groupW ); @@ -1220,7 +1324,8 @@ if ( log_group >= 1 && logTable(log_group).level >= 4 ) { } /* Make sure no turnouts in groupTrk list have a path end which is not an EndPt */ - //TODO Add Trap Points (which are Turnouts with a bumper track) + // TODO-BUMPER Add Trap Points (which are Turnouts with a bumper track) + // for Bumper support remove this loop for ( inx=0; inx<groupTrk_da.cnt; inx++ ) { trk = groupTrk(0).trk; if ( GetTrkType( trk ) == T_TURNOUT ) { @@ -1248,37 +1353,38 @@ if ( log_group >= 1 && logTable(log_group).level >= 4 ) { /* * Sort EndPts by angle */ - endPtOrig.x /= tempEndPts_da.cnt; - endPtOrig.y /= tempEndPts_da.cnt; + endPtOrig.x /= TempEndPtsCount(); + endPtOrig.y /= TempEndPtsCount(); angleN = 270.0; epN = -1; - for ( ep=0; ep<tempEndPts_da.cnt; ep++ ) { - angle = FindAngle(endPtOrig,tempEndPts(ep).pos); + for ( ep=0; ep<TempEndPtsCount(); ep++ ) { + angle = FindAngle(endPtOrig,GetEndPtPos(TempEndPt(ep))); if ( fabs(angle-270.0) < angleN ) { epN = ep; angleN = fabs(angle-270.0); endPtAngle = angle; } } - qsort( tempEndPts_da.ptr, tempEndPts_da.cnt, sizeof *endPtP, CmpEndPtAngle ); - if ( NormalizeAngle( tempEndPts(0).angle - tempEndPts(tempEndPts_da.cnt-1).angle ) > - NormalizeAngle( tempEndPts(1).angle - tempEndPts(0).angle ) ) { - - for ( ep=1; ep<(tempEndPts_da.cnt+1)/2; ep++ ) { - trkEndPt_t tempEndPt; - tempEndPt = tempEndPts(ep); - tempEndPts(ep) = tempEndPts(tempEndPts_da.cnt-ep); - tempEndPts(tempEndPts_da.cnt-ep) = tempEndPt; + qsort( TempEndPt(0), TempEndPtsCount(), EndPtSize(1), CmpEndPtAngle ); + // TODO-BUMPER - handle TempEndPt(1) + if ( NormalizeAngle( GetEndPtAngle(TempEndPt(0)) - GetEndPtAngle(TempEndPt( + TempEndPtsCount()-1)) ) > + NormalizeAngle( GetEndPtAngle(TempEndPt(1)) - GetEndPtAngle(TempEndPt(0)) ) ) { + + for ( ep=1; ep<(TempEndPtsCount()+1)/2; ep++ ) { + SwapEndPts( TempEndPt(0), ep, TempEndPtsCount()-ep ); + } + } + if ( log_group >= 1 && logTable(log_group).level >= 3 ) { + LogPrintf( "Sorted EndPts:\n" ); + for ( int inx=0; inx<TempEndPtsCount(); inx++ ) { + endPtP = TempEndPt(inx); + track_p trk1 = GetEndPtTrack(endPtP); + LogPrintf( " [ %0.3f %0.3f ] A:%0.3f, T:%d.%d\n", + GetEndPtPos(endPtP).x, GetEndPtPos(endPtP).y, GetEndPtAngle(endPtP), + trk1?GetTrkIndex(trk1):-1, GetEndPtEndPt(endPtP) ); } } -if ( log_group >= 1 && logTable(log_group).level >= 3 ) { - LogPrintf( "Sorted EndPts:\n" ); - for ( int inx=0; inx<tempEndPts_da.cnt; inx++ ) { - endPtP = &tempEndPts(inx); - LogPrintf( " [ %0.3f %0.3f ] A:%0.3f, T:%d.%d\n", - endPtP->pos.x, endPtP->pos.y, endPtP->angle, endPtP->track?GetTrkIndex(endPtP->track):-1, endPtP->index ); - } -} /* * 3: Find shortest Paths @@ -1295,35 +1401,40 @@ if ( log_group >= 1 && logTable(log_group).level >= 3 ) { } } } -if ( log_group >= 1 && logTable(log_group).level >= 3 ) { - LogPrintf( "Shortest path:\n Group Tracks\n" ); - for ( int inx=0; inx<groupTrk_da.cnt; inx++ ) { - groupTrk_p gtp = &groupTrk(inx); - LogPrintf( " %d: T%d S%d-%d\n", inx, GetTrkIndex( gtp->trk ), gtp->segStart+1, gtp->segEnd+1 ); - } - LogPrintf( " Path Elem\n" ); - for ( int inx=0; inx<pathElem_da.cnt; inx++ ) { - ppp = &pathElem(inx); - LogPrintf( " %d: GTx: %d, EP: %d %d, F:%s, P:", - inx, ppp->groupInx, ppp->ep1, ppp->ep2, ppp->flip?"T":"F" ); - for ( PATHPTR_T cp = ppp->path; cp[0] || cp[1]; cp++ ) { - LogPrintf( " %d", *cp ); - } - LogPrintf( " 0\n" ); - } - LogPrintf( " Path\n" ); - for ( int inx=0; inx<path_da.cnt; inx++ ) { - path_p pp = &path(inx); - LogPrintf( " %d: PE: %d-%d, EP: %d-%d, Conf: %d, InGrp: %s, Done: %s\n", - inx, pp->pathElemStart, pp->pathElemEnd, pp->ep1, pp->ep2, - pp->conflicts, pp->inGroup?"T":"F", pp->done?"T":"F" ); - } -} + if ( log_group >= 1 && logTable(log_group).level >= 3 ) { + LogPrintf( "Shortest path:\n Group Tracks\n" ); + for ( int inx=0; inx<groupTrk_da.cnt; inx++ ) { + groupTrk_p gtp = &groupTrk(inx); + LogPrintf( " %d: T%d S%d-%d\n", inx, GetTrkIndex( gtp->trk ), + gtp->segStart+1, gtp->segEnd+1 ); + } + LogPrintf( " Path Elem\n" ); + for ( int inx=0; inx<pathElem_da.cnt; inx++ ) { + ppp = &pathElem(inx); + LogPrintf( " %d: GTx: %d, EP: %d %d, F:%s, P:", + inx, ppp->groupInx, ppp->ep1, ppp->ep2, ppp->flip?"T":"F" ); + if ( ppp->path == NULL ) { + LogPrintf( "No Paths!\n" ); + } else { + for ( PATHPTR_T cp = ppp->path; cp[0] || cp[1]; cp++ ) { + LogPrintf( " %d", *cp ); + } + } + LogPrintf( " 0\n" ); + } + LogPrintf( " Path\n" ); + for ( int inx=0; inx<path_da.cnt; inx++ ) { + path_p pp = &path(inx); + LogPrintf( " %d: PE: %d-%d, EP: %d-%d, Conf: %d, InGrp: %s, Done: %s\n", + inx, pp->pathElemStart, pp->pathElemEnd, pp->ep1, pp->ep2, + pp->conflicts, pp->inGroup?"T":"F", pp->done?"T":"F" ); + } + } /* * 4: Flip paths so they align */ if ( path_da.cnt == 0 ) { - NoticeMessage( _("No paths"), _("Ok"), NULL ); + NoticeMessage( MSG_GROUP_NO_PATHS, _("Ok"), NULL ); wDrawDelayUpdate( mainD.d, FALSE ); wHide( groupW ); return; @@ -1335,24 +1446,25 @@ if ( log_group >= 1 && logTable(log_group).level >= 3 ) { inx = -1; for ( pinx=0; pinx<path_da.cnt; pinx++ ) { pp = &path(pinx); - if ( pp->done ) continue; + if ( pp->done ) { continue; } for ( pinx2=0; pinx2<path_da.cnt; pinx2++ ) { - if ( pinx2==pinx ) continue; + if ( pinx2==pinx ) { continue; } ppN = &path(pinx2); if ( pp->ep1 == ppN->ep1 || - pp->ep2 == ppN->ep2 ) { + pp->ep2 == ppN->ep2 ) { pp->done = TRUE; allDone = FALSE; -LOG( log_group, 1, ( "P%d aligns with P%d\n", pinx, pinx2 ) ); + LOG( log_group, 1, ( "P%d aligns with P%d\n", pinx, pinx2 ) ); break; } if ( pp->ep1 == ppN->ep2 || - pp->ep2 == ppN->ep1 ) { + pp->ep2 == ppN->ep1 ) { pp->done = TRUE; allDone = FALSE; -LOG( log_group, 1, ( "P%d aligns flipped with P%d\n", pinx, pinx2 ) ); + LOG( log_group, 1, ( "P%d aligns flipped with P%d\n", pinx, pinx2 ) ); inx = (pp->pathElemStart+pp->pathElemEnd-1)/2; - for ( ginx=pp->pathElemStart,ginx2=pp->pathElemEnd; ginx<=inx; ginx++,ginx2-- ) { + for ( ginx=pp->pathElemStart,ginx2=pp->pathElemEnd; ginx<=inx; + ginx++,ginx2-- ) { pathElemTemp = pathElem(ginx); pathElem(ginx) = pathElem(ginx2); pathElem(ginx2) = pathElemTemp; @@ -1370,33 +1482,35 @@ LOG( log_group, 1, ( "P%d aligns flipped with P%d\n", pinx, pinx2 ) ); break; } } - if ( inx<0 && !pp->done ) + if ( inx<0 && !pp->done ) { inx = pinx; + } } if ( allDone && inx>=0 ) { allDone = FALSE; path(inx).done = TRUE; - } - } -if ( log_group >= 1 && logTable(log_group).level >= 1 ) { - LogPrintf( "Group Paths\n" ); - for ( pinx=0; pinx<path_da.cnt; pinx++ ) { - pp = &path(pinx); - LogPrintf( " P%2d:%d.%d ", pinx, pp->ep1, pp->ep2 ); - for ( pinx2=pp->pathElemEnd; pinx2>=pp->pathElemStart; pinx2-- ) { - ppp = &pathElem(pinx2); - LogPrintf( " %sT%d:%d.%d", ppp->flip?"-":"", GetTrkIndex(groupTrk(ppp->groupInx).trk), ppp->ep1, ppp->ep2 ); - } - LogPrintf( "\n" ); - } -} + } + } + if ( log_group >= 1 && logTable(log_group).level >= 1 ) { + LogPrintf( "Group Paths\n" ); + for ( pinx=0; pinx<path_da.cnt; pinx++ ) { + pp = &path(pinx); + LogPrintf( " P%2d:%d.%d ", pinx, pp->ep1, pp->ep2 ); + for ( pinx2=pp->pathElemEnd; pinx2>=pp->pathElemStart; pinx2-- ) { + ppp = &pathElem(pinx2); + LogPrintf( " %sT%d:%d.%d", ppp->flip?"-":"", + GetTrkIndex(groupTrk(ppp->groupInx).trk), ppp->ep1, ppp->ep2 ); + } + LogPrintf( "\n" ); + } + } /* * 5: Create Conflict Map */ DYNARR_SET( int, conflictMap_da, path_da.cnt*path_da.cnt ); - memset( conflictMap_da.ptr, 0, conflictMap_da.max * sizeof conflictMap(0,0) ); + memset( &conflictMap(0,0), 0, conflictMap_da.cnt * sizeof conflictMap(0,0) ); for ( pinx=0; pinx<path_da.cnt; pinx++ ) { for ( pinx2=pinx+1; pinx2<path_da.cnt; pinx2++ ) { if ( ConflictPaths( &path(pinx), &path(pinx2) ) ) { @@ -1411,27 +1525,28 @@ if ( log_group >= 1 && logTable(log_group).level >= 1 ) { * Sort Paths by number of conflicts */ DYNARR_SET( int, groupOrder_da, path_da.cnt ); - for ( pinx=0; pinx<path_da.cnt; pinx++ ) groupOrder(pinx) = pinx; - qsort( groupOrder_da.ptr, path_da.cnt, sizeof groupOrder(0), CmpGroupOrder ); + for ( pinx=0; pinx<path_da.cnt; pinx++ ) { groupOrder(pinx) = pinx; } + qsort( &groupOrder(0), path_da.cnt, sizeof groupOrder(0), CmpGroupOrder ); /* - * Group Paths, 1st pass: + * Group Paths, 1st pass: */ DYNARR_SET( int, groupMap_da, path_da.cnt*(path_da.cnt+1) ); - memset( groupMap_da.ptr, -1, groupMap_da.max * sizeof groupMap(0,0) ); + memset( &groupMap(0,0), -1, groupMap_da.cnt * sizeof groupMap(0,0) ); groupCnt = 0; for ( pinx=0; pinx<path_da.cnt; pinx++ ) { pp = &path(groupOrder(pinx)); - if ( pp->inGroup ) continue; + if ( pp->inGroup ) { continue; } pp->inGroup = TRUE; groupCnt++; groupMap( groupCnt-1, 0 ) = groupOrder(pinx); ginx = 1; for ( pinx2=pinx+1; pinx2<path_da.cnt; pinx2++ ) { gpinx2 = groupOrder(pinx2); - if ( path(gpinx2).inGroup ) continue; - for ( ginx2=0; ginx2<ginx && !conflictMap(groupMap(groupCnt-1,ginx2),gpinx2); ginx2++ ); - if ( ginx2<ginx ) continue; + if ( path(gpinx2).inGroup ) { continue; } + for ( ginx2=0; ginx2<ginx + && !conflictMap(groupMap(groupCnt-1,ginx2),gpinx2); ginx2++ ); + if ( ginx2<ginx ) { continue; } path(gpinx2).inGroup = TRUE; groupMap( groupCnt-1, ginx++ ) = gpinx2; } @@ -1445,22 +1560,24 @@ if ( log_group >= 1 && logTable(log_group).level >= 1 ) { for ( pinx2=0; pinx2<path_da.cnt; pinx2++ ) { gpinx2 = groupOrder(pinx2); for ( ginx2=0; ginx2<ginx && groupMap(pinx,ginx2)!=gpinx2; ginx2++ ); - if ( ginx2<ginx ) continue; /* already on list */ - for ( ginx2=0; ginx2<ginx && !conflictMap(groupMap(pinx,ginx2),gpinx2); ginx2++ ); - if ( ginx2<ginx ) continue; /* conflicts with someone on list */ + if ( ginx2<ginx ) { continue; } /* already on list */ + for ( ginx2=0; ginx2<ginx + && !conflictMap(groupMap(pinx,ginx2),gpinx2); ginx2++ ); + if ( ginx2<ginx ) { continue; } /* conflicts with someone on list */ groupMap(pinx,ginx++) = gpinx2; } } -if ( log_group >= 1 && logTable(log_group).level >= 3 ) { - LogPrintf( "Group Map\n"); - for ( pinx=0; pinx<groupCnt; pinx++ ) { - LogPrintf( "G%d:", pinx ); - for ( ginx=0; groupMap(pinx,ginx) >= 0; ginx++ ) - LogPrintf( " %d: %d", ginx, groupMap(pinx,ginx) ); - LogPrintf( "\n" ); - } -} + if ( log_group >= 1 && logTable(log_group).level >= 3 ) { + LogPrintf( "Group Map\n"); + for ( pinx=0; pinx<groupCnt; pinx++ ) { + LogPrintf( "G%d:", pinx ); + for ( ginx=0; groupMap(pinx,ginx) >= 0; ginx++ ) { + LogPrintf( " %d: %d", ginx, groupMap(pinx,ginx) ); + } + LogPrintf( "\n" ); + } + } /* * 6: Count number of times each segment is used as flipped @@ -1469,34 +1586,36 @@ if ( log_group >= 1 && logTable(log_group).level >= 3 ) { memset( &segFlip(0), 0, trackSegs_da.cnt * sizeof segFlip(0) ); for ( pinx=0; pinx<pathElem_da.cnt; pinx++ ) { ppp = &pathElem(pinx); - for ( PATHPTR_T pPaths=ppp->path; *pPaths; pPaths++ ) { + for ( PATHPTR_T pPaths=ppp->path; pPaths && *pPaths; pPaths++ ) { inx = *pPaths; - if ( inx<0 ) + if ( inx<0 ) { inx = - inx; - if ( inx > trackSegs_da.cnt ) - AbortProg( "inx > trackSegs_da.cnt" ); + } + CHECK( inx <= trackSegs_da.cnt ); flip = *pPaths<0; - if ( ppp->flip ) + if ( ppp->flip ) { flip = !flip; + } inx += groupTrk(ppp->groupInx).segStart - 1; - if ( !flip ) + if ( !flip ) { segFlip(inx)++; - else + } else { segFlip(inx)--; + } } } /* * Flip each segment that is used as flipped more than not */ -LOG( log_group, 3, ( "Flipping Segments:" ) ); + LOG( log_group, 3, ( "Flipping Segments:" ) ); for ( pinx=0; pinx<trackSegs_da.cnt; pinx++ ) { if ( segFlip(pinx) < 0 ) { - SegProc( SEGPROC_FLIP, &trackSegs(pinx), NULL ); -LOG( log_group, 3, ( " %d", pinx ) ); + SegProc( SEGPROC_FLIP, &trackSegs(pinx), NULL ); + LOG( log_group, 3, ( " %d", pinx ) ); } } -LOG( log_group, 3, ( "\n" ) ); + LOG( log_group, 3, ( "\n" ) ); /* * 7: Output Path lists @@ -1508,16 +1627,24 @@ LOG( log_group, 3, ( "\n" ) ); memcpy( &pathPtr(inx), message, pathPtr_da.cnt-inx ); for ( ginx=0; groupMap(pinx,ginx) >= 0; ginx++ ) { pp = &path(groupMap(pinx,ginx)); - LOG( log_group, 3, (" Group Map(%d, %d): elem %d-%d, EP %d %d, Conflicts %d, inGrp %d, Done: %s\n", pinx, ginx, pp->pathElemStart, pp->pathElemEnd, pp->ep1, pp->ep2, pp->conflicts, pp->inGroup, pp->done?"T":"F" ) ); + LOG( log_group, 3, + (" Group Map(%d, %d): elem %d-%d, EP %d %d, Conflicts %d, inGrp %d, Done: %s\n", + pinx, ginx, pp->pathElemStart, pp->pathElemEnd, pp->ep1, pp->ep2, pp->conflicts, + pp->inGroup, pp->done?"T":"F" ) ); for ( pinx2=pp->pathElemEnd; pinx2>=pp->pathElemStart; pinx2-- ) { ppp = &pathElem( pinx2 ); - LOG( log_group, 3, (" PE %d: GI %d, EP %d %d, Flip %d =", pinx2, ppp->groupInx, ppp->ep1, ppp->ep2, ppp->flip )); + LOG( log_group, 3, (" PE %d: GI %d, EP %d %d, Flip %d =", pinx2, + ppp->groupInx, ppp->ep1, ppp->ep2, ppp->flip )); groupP = &groupTrk( ppp->groupInx ); PATHPTR_T pPaths = ppp->path; flip = ppp->flip; - if ( pPaths == NULL ) - AbortProg( "Missing Path T%d:%d.%d", GetTrkIndex(groupP->trk), ppp->ep2, ppp->ep1 ); - if ( flip ) pPaths += strlen((char *)pPaths)-1; + if ( pPaths == NULL ) { + ErrorMessage( MSG_GROUP_NO_PATHS, _("Ok"), NULL ); + wDrawDelayUpdate( mainD.d, FALSE ); + wHide( groupW ); + return; + } + if ( flip ) { pPaths += strlen((char *)pPaths)-1; } while ( *pPaths && (pPaths >= ppp->path) ) { //Add Guard for flip backwards DYNARR_APPEND( char, pathPtr_da, 10 ); pathChar = *pPaths; @@ -1527,9 +1654,10 @@ LOG( log_group, 3, ( "\n" ) ); pathChar = - pathChar; } pathChar = groupP->segStart+pathChar; - if ( segFlip(pathChar-1)<0 ) + if ( segFlip(pathChar-1)<0 ) { flip1 = ! flip1; - if ( flip1 ) pathChar = - pathChar; + } + if ( flip1 ) { pathChar = - pathChar; } pathPtr(pathPtr_da.cnt-1) = pathChar; pPaths += (flip?-1:1); LOG( log_group, 3, (" %d", pathChar ) ); @@ -1551,21 +1679,24 @@ LOG( log_group, 3, ( "\n" ) ); DYNARR_RESET(trkSeg_t, outputSegs_da); - for (int i=0; i<trackSegs_da.cnt;i++) { + for (int i=0; i<trackSegs_da.cnt; i++) { DYNARR_APPEND(trkSeg_t,outputSegs_da,10); trkSeg_p from_p = &trackSegs(i); trkSeg_p to_p = &DYNARR_LAST(trkSeg_t, outputSegs_da); memcpy(to_p,from_p,sizeof( trkSeg_t)); } - CloneFilledDraw( outputSegs_da.cnt, outputSegs_da.ptr, FALSE ); + CloneFilledDraw( outputSegs_da.cnt, &outputSegs(0), FALSE ); GetSegBounds( zero, 0, outputSegs_da.cnt, &outputSegs(0), &orig, &size ); - orig.x = - tempEndPts(0).pos.x; - orig.y = - tempEndPts(0).pos.y; + orig.x = - GetEndPtPos(TempEndPt(0)).x; + orig.y = - GetEndPtPos(TempEndPt(0)).y; MoveSegs( outputSegs_da.cnt, &outputSegs(0), orig ); - for ( ep=0; ep<tempEndPts_da.cnt; ep++ ) { - tempEndPts(ep).pos.x += orig.x; - tempEndPts(ep).pos.y += orig.y; + for ( ep=0; ep<TempEndPtsCount(); ep++ ) { + trkEndPt_p epp = TempEndPt(ep); + coOrd pos = GetEndPtPos(epp); + pos.x += orig.x; + pos.y += orig.y; + SetEndPt( epp, pos, GetEndPtAngle(epp) ); } /* @@ -1573,12 +1704,14 @@ LOG( log_group, 3, ( "\n" ) ); */ PATHPTR_T pPaths = (PATHPTR_T)&pathPtr(0); - CheckPaths( outputSegs_da.cnt, &outputSegs(0), pPaths ); + CheckPaths( outputSegs_da.cnt, &outputSegs(0), pPaths, groupTitle ); long options = 0; - if ( groupNoCombine != 0 ) + if ( groupNoCombine != 0 ) { options |= COMPOUND_OPTION_PATH_NOCOMBINE; - to = CreateNewTurnout( curScaleName, groupTitle, outputSegs_da.cnt, &outputSegs(0), pPaths, tempEndPts_da.cnt, &tempEndPts(0), TRUE, options ); + } + to = CreateNewTurnout( curScaleName, groupTitle, outputSegs_da.cnt, + &outputSegs(0), pPaths, TempEndPtsCount(), TempEndPt(0), TRUE, options ); /* * 10: Write defn to xtrkcad.cus @@ -1586,8 +1719,10 @@ LOG( log_group, 3, ( "\n" ) ); f = OpenCustom("a"); if (f && to) { SetCLocale(); - rc &= fprintf( f, "TURNOUT %s \"%s\" %ld\n", curScaleName, PutTitle(to->title), options )>0; - rc &= WriteCompoundPathsEndPtsSegs( f, pPaths, outputSegs_da.cnt, &outputSegs(0), tempEndPts_da.cnt, &tempEndPts(0) ); + rc &= fprintf( f, "TURNOUT %s \"%s\" %ld\n", curScaleName, PutTitle(to->title), + options )>0; + rc &= WriteCompoundPathsEndPtsSegs( f, pPaths, outputSegs_da.cnt, + &outputSegs(0), TempEndPtsCount(), TempEndPt(0) ); SetUserLocale(); } if ( groupReplace ) { @@ -1597,17 +1732,21 @@ LOG( log_group, 3, ( "\n" ) ); UndoStart( _("Group Tracks"), "group" ); orig.x = - orig.x; orig.y = - orig.y; - for ( ep=0; ep<tempEndPts_da.cnt; ep++ ) { - endPtP = &tempEndPts(ep); - if ( endPtP->track ) { - trk = GetTrkEndTrk( endPtP->track, endPtP->index ); - epN = GetEndPtConnectedToMe( trk, endPtP->track ); - DrawEndPt( &mainD, endPtP->track, endPtP->index, wDrawColorWhite ); + for ( ep=0; ep<TempEndPtsCount(); ep++ ) { + endPtP = TempEndPt(ep); + track_p trk1 = GetEndPtTrack(endPtP); + if ( trk1 ) { + EPINX_T ep1 = GetEndPtEndPt(endPtP); + trk = GetTrkEndTrk( trk1, ep1 ); + epN = GetEndPtConnectedToMe( trk, trk1 ); + DrawEndPt( &mainD, trk1, ep1, wDrawColorWhite ); DrawEndPt( &mainD, trk, epN, wDrawColorWhite ); - DisconnectTracks( trk, epN, endPtP->track, endPtP->index ); + DisconnectTracks( trk, epN, trk1, ep1 ); } - endPtP->pos.x += orig.x; - endPtP->pos.y += orig.y; + coOrd pos = GetEndPtPos(endPtP); + pos.x += orig.x; + pos.y += orig.y; + SetEndPt( endPtP, pos, GetEndPtAngle(endPtP) ); } trk = NULL; while ( TrackIterate( &trk ) ) { @@ -1618,16 +1757,21 @@ LOG( log_group, 3, ( "\n" ) ); } } SelectRecount(); - trk = NewCompound( T_TURNOUT, 0, orig, 0.0, to->title, tempEndPts_da.cnt, &tempEndPts(0), pPaths, outputSegs_da.cnt, &outputSegs(0) ); - struct extraDataCompound_t *xx = GET_EXTRA_DATA(trk, T_TURNOUT, extraDataCompound_t); + trk = NewCompound( T_TURNOUT, 0, orig, 0.0, to->title, TempEndPtsCount(), + TempEndPt(0), pPaths, outputSegs_da.cnt, &outputSegs(0) ); + struct extraDataCompound_t *xx = GET_EXTRA_DATA(trk, T_TURNOUT, + extraDataCompound_t); xx->pathOverRide = FALSE; xx->pathNoCombine = groupNoCombine; SetTrkVisible( trk, TRUE ); - for ( ep=0; ep<tempEndPts_da.cnt; ep++ ) { - if ( tempEndPts(ep).track ) { - ConnectTracks( trk, ep, tempEndPts(ep).track, (EPINX_T)tempEndPts(ep).index ); - DrawEndPt( &mainD, tempEndPts(ep).track, (EPINX_T)tempEndPts(ep).index, GetTrkColor( tempEndPts(ep).track, &mainD ) ); + for ( ep=0; ep<TempEndPtsCount(); ep++ ) { + trkEndPt_p epp = TempEndPt(ep); + track_p trk1 = GetEndPtTrack(epp); + if ( trk1 ) { + EPINX_T ep1 = GetEndPtEndPt(epp); + ConnectTracks( trk, ep, trk1, ep1 ); + DrawEndPt( &mainD, trk1, ep1, GetTrkColor(trk1, &mainD ) ); } } DrawNewTrack( trk ); @@ -1640,11 +1784,13 @@ LOG( log_group, 3, ( "\n" ) ); orig.x = - orig.x-groupOriginX; //Include orig offset orig.y = - orig.y-groupOriginY; MoveSegs( trackSegs_da.cnt, &trackSegs(0), orig ); - to = CreateNewStructure( curScaleName, groupTitle, trackSegs_da.cnt, &trackSegs(0), TRUE ); + to = CreateNewStructure( curScaleName, groupTitle, trackSegs_da.cnt, + &trackSegs(0), TRUE ); f = OpenCustom("a"); if (f && to) { SetCLocale(); - rc &= fprintf( f, "STRUCTURE %s \"%s\"\n", curScaleName, PutTitle(groupTitle) )>0; + rc &= fprintf( f, "STRUCTURE %s \"%s\"\n", curScaleName, + PutTitle(groupTitle) )>0; rc &= WriteSegs( f, trackSegs_da.cnt, &trackSegs(0) ); SetUserLocale(); } @@ -1661,13 +1807,14 @@ LOG( log_group, 3, ( "\n" ) ); SelectRecount(); orig.x = - orig.x; orig.y = - orig.y; - trk = NewCompound( T_STRUCTURE, 0, orig, 0.0, groupTitle, 0, NULL, NULL, trackSegs_da.cnt, &trackSegs(0) ); + trk = NewCompound( T_STRUCTURE, 0, orig, 0.0, groupTitle, 0, NULL, NULL, + trackSegs_da.cnt, &trackSegs(0) ); SetTrkVisible( trk, TRUE ); DrawNewTrack( trk ); EnableCommands(); } } - if (f) fclose(f); + if (f) { fclose(f); } DoChangeNotification( CHANGE_PARAMS ); wHide( groupW ); wDrawDelayUpdate( mainD.d, FALSE ); @@ -1692,15 +1839,18 @@ EXPORT void DoGroup( void * unused ) while ( TrackIterate( &trk ) ) { if ( GetTrkSelected( trk ) ) { trkType = GetTrkType(trk); - if ( IsTrack(trk) ) isTurnout = TRUE; + if ( IsTrack(trk) ) { isTurnout = TRUE; } if ( trkType == T_TURNOUT || trkType == T_STRUCTURE ) { xx = GET_EXTRA_DATA(trk, trkType, extraDataCompound_t); groupSegCnt += xx->segCnt; GroupCopyTitle( xtitle(xx) ); - if ( trkType == T_TURNOUT && GetTrkEndPtCnt(trk) > 2 && xx->pathNoCombine != 0 ) + if ( trkType == T_TURNOUT && GetTrkEndPtCnt(trk) > 2 + && xx->pathNoCombine != 0 ) { groupNoCombine = TRUE; - } else + } + } else { groupSegCnt += 1; + } } } if ( groupSegCnt <= 0 ) { @@ -1708,11 +1858,13 @@ EXPORT void DoGroup( void * unused ) return; } sprintf( groupTitle, "%s\t%s\t%s", groupManuf, groupDesc, groupPartno ); - if ( log_group < 0 ) + if ( log_group < 0 ) { log_group = LogFindIndex( "group" ); + } if ( !groupW ) { ParamRegister( &groupPG ); - groupW = ParamCreateDialog( &groupPG, MakeWindowTitle(_("Group Objects")), _("Ok"), GroupOk, wHide, TRUE, NULL, F_BLOCK, NULL ); + groupW = ParamCreateDialog( &groupPG, MakeWindowTitle(_("Group Objects")), + _("Ok"), GroupOk, wHide, TRUE, NULL, F_BLOCK, NULL ); groupD.dpi = mainD.dpi; } if (isTurnout) { diff --git a/app/bin/chndldto.c b/app/bin/chndldto.c index abb6e32..fb7c05f 100644 --- a/app/bin/chndldto.c +++ b/app/bin/chndldto.c @@ -18,7 +18,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "ccurve.h" @@ -36,17 +36,17 @@ * STATE INFO */ static struct { - STATE_T state; - coOrd normalP; - ANGLE_T normalA; - track_p normalT; - coOrd reverseP; - coOrd reverseP1; - ANGLE_T reverseA; - DIST_T frogNo; - ANGLE_T frogA; - curveData_t curveData; - } Dhlt; + STATE_T state; + coOrd normalP; + ANGLE_T normalA; + track_p normalT; + coOrd reverseP; + coOrd reverseP1; + ANGLE_T reverseA; + DIST_T frogNo; + ANGLE_T frogA; + curveData_t curveData; +} Dhlt; static STATUS_T CmdHandLaidTurnout( wAction_t action, coOrd pos ) @@ -55,7 +55,8 @@ static STATUS_T CmdHandLaidTurnout( wAction_t action, coOrd pos ) EPINX_T ep, ep1, ep2, ep2a=-1, ep2b=-1, pointEp0, pointEp1; DIST_T dist, reverseD, pointD; coOrd off, intersectP; - coOrd pointP, pointC, pointP1, reverseC, point0; + coOrd pointP, pointP1, reverseC, point0; +// coOrd pointC; track_p trk, trk1, trk2, trk2a=NULL, trk2b=NULL, pointT; trkSeg_p segP; BOOL_T right; @@ -68,18 +69,18 @@ static STATUS_T CmdHandLaidTurnout( wAction_t action, coOrd pos ) DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); Dhlt.state = 0; Dhlt.normalT = NULL; - tempSegs_da.cnt = 0; DYNARR_SET( trkSeg_t, tempSegs_da, 2 ); tempSegs(0).color = drawColorBlack; - tempSegs(0).width = 0; + tempSegs(0).lineWidth = 0; tempSegs(1).color = drawColorBlack; - tempSegs(1).width = 0; + tempSegs(1).lineWidth = 0; return C_CONTINUE; case C_DOWN: if (Dhlt.state == 0) { - if ((Dhlt.normalT = OnTrack( &pos, TRUE, TRUE )) == NULL) + if ((Dhlt.normalT = OnTrack( &pos, TRUE, TRUE )) == NULL) { break; + } if ( QueryTrack( Dhlt.normalT, Q_NOT_PLACE_FROGPOINTS ) ) { ErrorMessage( MSG_CANT_PLACE_FROGPOINTS, _("frog") ); Dhlt.normalT = NULL; @@ -89,19 +90,20 @@ static STATUS_T CmdHandLaidTurnout( wAction_t action, coOrd pos ) Dhlt.normalA = GetAngleAtPoint( Dhlt.normalT, Dhlt.normalP, NULL, NULL ); InfoMessage( _("Drag to set angle") ); Dhlt.state = 1; - pointC = pointP = pointP1 = reverseC = zero; +// pointC = pointP = pointP1 = reverseC = zero; return C_CONTINUE; } case C_MOVE: case C_UP: - if (Dhlt.normalT == NULL) + if (Dhlt.normalT == NULL) { break; + } if (Dhlt.state == 1) { Dhlt.reverseP1 = pos; Dhlt.reverseA = FindAngle( Dhlt.reverseP, Dhlt.reverseP1 ); Dhlt.frogA = NormalizeAngle( Dhlt.reverseA - Dhlt.normalA ); -/*printf( "RA=%0.3f FA=%0.3f ", Dhlt.reverseA, Dhlt.frogA );*/ + /*printf( "RA=%0.3f FA=%0.3f ", Dhlt.reverseA, Dhlt.frogA );*/ if (Dhlt.frogA > 270.0) { Dhlt.frogA = 360.0-Dhlt.frogA; right = FALSE; @@ -118,12 +120,13 @@ static STATUS_T CmdHandLaidTurnout( wAction_t action, coOrd pos ) } else { right = TRUE; } -/*printf( "NA=%0.3f FA=%0.3f R=%d\n", Dhlt.normalA, Dhlt.frogA, right );*/ + /*printf( "NA=%0.3f FA=%0.3f R=%d\n", Dhlt.normalA, Dhlt.frogA, right );*/ Dhlt.frogNo = tan(D2R(Dhlt.frogA)); - if (Dhlt.frogNo > 0.01) + if (Dhlt.frogNo > 0.01) { Dhlt.frogNo = 1.0/Dhlt.frogNo; - else + } else { Dhlt.frogNo = 0.0; + } if (action == C_MOVE) { if (Dhlt.frogNo != 0) { InfoMessage( _("Angle = %0.2f Frog# = %0.2f"), Dhlt.frogA, Dhlt.frogNo ); @@ -133,15 +136,18 @@ static STATUS_T CmdHandLaidTurnout( wAction_t action, coOrd pos ) } else { InfoMessage( _("Select point position") ); Dhlt.state = 2; - Translate( &Dhlt.reverseP, Dhlt.reverseP, Dhlt.normalA+(right?+90:-90), trackGauge ); - Translate( &Dhlt.reverseP1, Dhlt.reverseP1, Dhlt.normalA+(right?+90:-90), trackGauge ); + Translate( &Dhlt.reverseP, Dhlt.reverseP, Dhlt.normalA+(right?+90:-90), + trackGauge ); + Translate( &Dhlt.reverseP1, Dhlt.reverseP1, Dhlt.normalA+(right?+90:-90), + trackGauge ); } return C_CONTINUE; } else if ( Dhlt.state == 2 ) { - tempSegs_da.cnt = 0; + DYNARR_RESET( trkSeg_t, tempSegs_da ); pointP = pos; - if ((pointT = OnTrack( &pointP, TRUE, TRUE )) == NULL) + if ((pointT = OnTrack( &pointP, TRUE, TRUE )) == NULL) { break; + } if ( QueryTrack( pointT, Q_NOT_PLACE_FROGPOINTS ) ) { ErrorMessage( MSG_CANT_PLACE_FROGPOINTS, _("points") ); break; @@ -149,11 +155,11 @@ static STATUS_T CmdHandLaidTurnout( wAction_t action, coOrd pos ) dist = FindDistance( Dhlt.normalP, pointP ); pointA = GetAngleAtPoint( pointT, pointP, &pointEp0, &pointEp1 ); angle = NormalizeAngle( pointA + 180.0 - Dhlt.reverseA ); -PTRACE(( "rA=%0.1f pA=%0.1f a=%0.1f ", Dhlt.reverseA, pointA, angle )) + PTRACE(( "rA=%0.1f pA=%0.1f a=%0.1f ", Dhlt.reverseA, pointA, angle )) if ( angle > 90.0 && angle < 270.0 ) { pointA = NormalizeAngle( pointA + 180.0 ); angle = NormalizeAngle( angle + 180.0 ); -PTRACE(( " {pA=%0.1f a=%0.1f} ", pointA, angle )) + PTRACE(( " {pA=%0.1f a=%0.1f} ", pointA, angle )) } else { ep = pointEp0; pointEp0 = pointEp1; pointEp1 = ep; } @@ -163,10 +169,11 @@ PTRACE(( " {pA=%0.1f a=%0.1f} ", pointA, angle )) } else { right = FALSE; } -PTRACE(( "r=%c a=%0.1f ", right?'T':'F', angle )) + PTRACE(( "r=%c a=%0.1f ", right?'T':'F', angle )) Translate( &off, pointP, pointA+180.0, trackGauge*2.0 ); - if ((trk = OnTrack( &off, TRUE, TRUE )) == NULL) + if ((trk = OnTrack( &off, TRUE, TRUE )) == NULL) { break; + } if ( QueryTrack( trk, Q_NOT_PLACE_FROGPOINTS ) ) { ErrorMessage( MSG_CANT_PLACE_FROGPOINTS, _("points") ); break; @@ -175,23 +182,25 @@ PTRACE(( "r=%c a=%0.1f ", right?'T':'F', angle )) Rotate( &off, Dhlt.reverseP, 180-Dhlt.reverseA ); off.x -= Dhlt.reverseP.x; off.y -= Dhlt.reverseP.y; - if (right) + if (right) { off.x = -off.x; -PTRACE(( "off=[%0.3f %0.3f] ", off.x, off.y )) + } + PTRACE(( "off=[%0.3f %0.3f] ", off.x, off.y )) if (off.y < 0) { ErrorMessage( MSG_MOVE_POINTS_OTHER_SIDE ); -PTRACE(("\n")) + PTRACE(("\n")) break; } if (off.x < 0) { ErrorMessage( MSG_MOVE_POINTS_AWAY_CLOSE ); -PTRACE(("\n")) + PTRACE(("\n")) break; } angle2 = FindAngle( zero, off ); -PTRACE(( "a2=%0.1f\n", angle2 )) + PTRACE(( "a2=%0.1f\n", angle2 )) if (angle < 0.5) { if ( off.x < connectDistance ) { + DYNARR_SET( trkSeg_t, tempSegs_da, 2 ); tempSegs(0).type = SEG_STRTRK; tempSegs(0).color = wDrawColorBlack; tempSegs(0).u.l.pos[0] = pointP; @@ -200,23 +209,25 @@ PTRACE(( "a2=%0.1f\n", angle2 )) tempSegs(1).color = wDrawColorBlack; tempSegs(1).u.l.pos[0] = Dhlt.reverseP; Translate( &tempSegs(1).u.l.pos[1], Dhlt.reverseP, Dhlt.reverseA, trackGauge ); - tempSegs_da.cnt = 2; } else { - ErrorMessage( MSG_MOVE_POINTS_AWAY_NO_INTERSECTION ); - break; + ErrorMessage( MSG_MOVE_POINTS_AWAY_NO_INTERSECTION ); + break; } } else if (angle < angle2) { ErrorMessage( MSG_MOVE_POINTS_AWAY_NO_INTERSECTION ); break; } else { - if (!FindIntersection( &intersectP, Dhlt.reverseP, Dhlt.reverseA+180.0, pointP, pointA+180.0 )) + if (!FindIntersection( &intersectP, Dhlt.reverseP, Dhlt.reverseA+180.0, pointP, + pointA+180.0 )) { break; + } reverseD = FindDistance( Dhlt.reverseP, intersectP ); pointD = FindDistance( pointP, intersectP ); if (reverseD > pointD) { reverseR = pointD/tan(D2R(angle/2.0)); Translate( &reverseC, pointP, pointA+(right?-90:+90), reverseR ); -PTRACE(( "rR=%0.3f rC=[%0.3f %0.3f]\n", reverseR, reverseC.x, reverseC.y )) + PTRACE(( "rR=%0.3f rC=[%0.3f %0.3f]\n", reverseR, reverseC.x, reverseC.y )) + DYNARR_SET( trkSeg_t, tempSegs_da, 3 ); tempSegs(0).type = SEG_CRVTRK; tempSegs(0).color = wDrawColorBlack; tempSegs(0).u.c.center = reverseC; @@ -225,13 +236,13 @@ PTRACE(( "rR=%0.3f rC=[%0.3f %0.3f]\n", reverseR, reverseC.x, reverseC.y )) tempSegs(0).u.c.a1 = angle; tempSegs(1).type = SEG_STRTRK; tempSegs(1).color = wDrawColorBlack; - PointOnCircle( &tempSegs(1).u.l.pos[0], reverseC, reverseR, tempSegs(0).u.c.a0 + (right?angle:0.0) ); + PointOnCircle( &tempSegs(1).u.l.pos[0], reverseC, reverseR, + tempSegs(0).u.c.a0 + (right?angle:0.0) ); tempSegs(1).u.l.pos[1] = Dhlt.reverseP; tempSegs(2).type = SEG_STRTRK; tempSegs(2).color = wDrawColorBlack; tempSegs(2).u.l.pos[0] = Dhlt.reverseP; Translate( &tempSegs(2).u.l.pos[1], Dhlt.reverseP, Dhlt.reverseA, trackGauge ); - tempSegs_da.cnt = 3; } else { reverseR = reverseD/tan(D2R(angle/2.0)); reverseR *= sqrt(reverseD/pointD); @@ -240,17 +251,21 @@ PTRACE(( "rR=%0.3f rC=[%0.3f %0.3f]\n", reverseR, reverseC.x, reverseC.y )) dist = FindDistance( reverseC, pointP ); angle2 = R2D( asin( reverseR/dist ) ); angle3 = FindAngle( pointP, reverseC ); - if (right) + if (right) { angle2 = NormalizeAngle(angle3 - pointA+180) - angle2; - else + } else { angle2 = NormalizeAngle(pointA+180 - angle3) - angle2; + } reverseA1 = angle-angle2; -PTRACE(( " a2=%0.1f rA1=%0.1f\n", angle2, reverseA1 )) + PTRACE(( " a2=%0.1f rA1=%0.1f\n", angle2, reverseA1 )) + DYNARR_SET( trkSeg_t, tempSegs_da, 3 ); tempSegs(0).type = SEG_STRTRK; tempSegs(0).color = wDrawColorBlack; tempSegs(0).u.l.pos[0] = pointP; - tempSegs(1).u.c.a0 = NormalizeAngle(Dhlt.reverseA + (right?(-90.0-reverseA1):+90.0)); - PointOnCircle( &tempSegs(0).u.l.pos[1], reverseC, reverseR, tempSegs(1).u.c.a0 + (right?0.0:reverseA1) ); + tempSegs(1).u.c.a0 = NormalizeAngle(Dhlt.reverseA + (right? + (-90.0-reverseA1):+90.0)); + PointOnCircle( &tempSegs(0).u.l.pos[1], reverseC, reverseR, + tempSegs(1).u.c.a0 + (right?0.0:reverseA1) ); tempSegs(1).type = SEG_CRVTRK; tempSegs(1).color = wDrawColorBlack; tempSegs(1).u.c.center = reverseC; @@ -260,26 +275,29 @@ PTRACE(( " a2=%0.1f rA1=%0.1f\n", angle2, reverseA1 )) tempSegs(2).color = wDrawColorBlack; tempSegs(2).u.l.pos[0] = Dhlt.reverseP; Translate( &tempSegs(2).u.l.pos[1], Dhlt.reverseP, Dhlt.reverseA, trackGauge ); - tempSegs_da.cnt = 3; } } if (action != C_UP) { dist = FindDistance( pointP, Dhlt.normalP ); - InfoMessage( _("Length = %0.2f Angle = %0.2f Frog# = %0.2f"), dist, Dhlt.frogA, Dhlt.frogNo ); + InfoMessage( _("Length = %0.2f Angle = %0.2f Frog# = %0.2f"), dist, Dhlt.frogA, + Dhlt.frogNo ); return C_CONTINUE; } - UndoStart( _("Create Hand Laid Turnout"), "Hndldto( T%d[%d] )", GetTrkIndex(pointT), pointEp0 ); + UndoStart( _("Create Hand Laid Turnout"), "Hndldto( T%d[%d] )", + GetTrkIndex(pointT), pointEp0 ); UndoModify( pointT ); - if (!SplitTrack( pointT, pointP, pointEp0, &trk1, TRUE )) + if (!SplitTrack( pointT, pointP, pointEp0, &trk1, TRUE )) { break; + } dist = trackGauge*2.0; if ( !trk1 ) { trk1 = pointT; pointT = NULL; } ep1 = PickEndPoint( pointP, trk1 ); - if (!RemoveTrack( &trk1, &ep1, &dist )) + if (!RemoveTrack( &trk1, &ep1, &dist )) { break; + } point0 = GetTrkEndPos( trk1, ep1 ); angle0 = NormalizeAngle(GetTrkEndAngle(trk1,ep1)+180.0); trk2 = NULL; @@ -291,7 +309,8 @@ PTRACE(( " a2=%0.1f rA1=%0.1f\n", angle2, reverseA1 )) ep2b = 0; break; case SEG_CRVTRK: - trk2b = NewCurvedTrack( segP->u.c.center, fabs(segP->u.c.radius), segP->u.c.a0, segP->u.c.a1, 0 ); + trk2b = NewCurvedTrack( segP->u.c.center, fabs(segP->u.c.radius), segP->u.c.a0, + segP->u.c.a1, 0 ); ep2b = (right?0:1); } if (trk2 == NULL) { @@ -305,11 +324,13 @@ PTRACE(( " a2=%0.1f rA1=%0.1f\n", angle2, reverseA1 )) } *trkpp = NULL; dist = trackGauge*2.0; - if (!RemoveTrack( &trk2, &ep2, &dist )) + if (!RemoveTrack( &trk2, &ep2, &dist )) { break; + } trk = NewHandLaidTurnout( pointP, pointA, - point0, angle0, - GetTrkEndPos(trk2,ep2), NormalizeAngle(GetTrkEndAngle(trk2,ep2)+180.0), Dhlt.frogA ); + point0, angle0, + GetTrkEndPos(trk2,ep2), NormalizeAngle(GetTrkEndAngle(trk2,ep2)+180.0), + Dhlt.frogA ); DrawEndPt( &mainD, trk1, ep1, wDrawColorWhite ); if ( pointT ) { DrawEndPt( &mainD, pointT, pointEp0, wDrawColorWhite ); @@ -324,18 +345,22 @@ PTRACE(( " a2=%0.1f rA1=%0.1f\n", angle2, reverseA1 )) DrawTrack( pointT, &mainD, wDrawColorBlack ); } DrawTrack( trk, &mainD, wDrawColorBlack ); - for (trkpp=trks; *trkpp; trkpp++) + for (trkpp=trks; *trkpp; trkpp++) { DrawTrack( *trkpp, &mainD, wDrawColorBlack ); - + } + Dhlt.state = 0; return C_TERMINATE; } case C_REDRAW: - if (Dhlt.state >= 1) + if (Dhlt.state >= 1) { DrawLine( &tempD, Dhlt.reverseP, Dhlt.reverseP1, 0, wDrawColorBlack ); - if (Dhlt.state >= 2) - DrawSegs( &tempD, zero, 0.0, &tempSegs(0), tempSegs_da.cnt, trackGauge, wDrawColorBlack ); + } + if (Dhlt.state >= 2) { + DrawSegsDA( &tempD, NULL, zero, 0.0, &tempSegs_da, trackGauge, wDrawColorBlack, + 0 ); + } return C_CONTINUE; case C_CANCEL: @@ -348,9 +373,11 @@ PTRACE(( " a2=%0.1f rA1=%0.1f\n", angle2, reverseA1 )) } -#include "bitmaps/turnout-designer.xpm" +#include "bitmaps/turnout-design.xpm3" EXPORT void InitCmdHandLaidTurnout( wMenu_p menu ) { - AddMenuButton( menu, CmdHandLaidTurnout, "cmdHandLaidTurnout", _("HandLaidTurnout"), wIconCreatePixMap(turnout_designer_xpm[iconSize]), LEVEL0_50, IC_STICKY|IC_INITNOTSTICKY|IC_POPUP2, ACCL_HNDLDTO, NULL ); + AddMenuButton( menu, CmdHandLaidTurnout, "cmdHandLaidTurnout", + _("HandLaidTurnout"), wIconCreatePixMap(turnout_design_xpm3[iconSize]), + LEVEL0_50, IC_STICKY|IC_INITNOTSTICKY|IC_POPUP2, ACCL_HNDLDTO, NULL ); } diff --git a/app/bin/chotbar.c b/app/bin/chotbar.c index 379f31a..a0e6332 100644 --- a/app/bin/chotbar.c +++ b/app/bin/chotbar.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "compound.h" @@ -41,27 +41,28 @@ static wMenu_p hotbarPopupM; static wMenuList_p hotBarML = NULL; static wIndex_t hotBarMLcnt = 0; static drawCmd_t hotBarD = { - NULL, - &screenDrawFuncs, - 0, - 1.0, - 0.0, - {0.0, 0.0}, {0.0, 0.0}, - Pix2CoOrd, CoOrd2Pix }; + NULL, + &screenDrawFuncs, + 0, + 1.0, + 0.0, + {0.0, 0.0}, {0.0, 0.0}, + Pix2CoOrd, CoOrd2Pix +}; static wWinPix_t hotBarDrawHeight[] = {26, 32, 40}; -static wFontSize_t hotBarFontSize[] = {7, 8, 9}; +static wFontSize_t hotBarFontSize[] = {7, 11, 14}; typedef struct { - DIST_T x; - DIST_T w; - DIST_T objectW; - DIST_T labelW; - coOrd size; - coOrd orig; - BOOL_T isFixed; - void * context; - hotBarProc_t proc; - DIST_T barScale; - } hotBarMap_t; + DIST_T x; + DIST_T w; + DIST_T objectW; + DIST_T labelW; + coOrd size; + coOrd orig; + BOOL_T isFixed; + void * context; + hotBarProc_t proc; + DIST_T barScale; +} hotBarMap_t; static dynArr_t hotBarMap_da; #define hotBarMap(N) DYNARR_N( hotBarMap_t, hotBarMap_da, N ) static int hotBarCurrSelects[2] = { -1, -1 }; @@ -74,23 +75,25 @@ static DIST_T hotBarWidth = 0.0; static void HotBarHighlight( int inx, DIST_T fixed_x ) { - if ( inx > 0 && ( inx < hotBarCurrStart || inx >= hotBarCurrEnd ) ) + if ( inx > 0 && ( inx < hotBarCurrStart || inx >= hotBarCurrEnd ) ) { return; + } coOrd orig, size; hotBarD.scale = 1; - if ( inx == 0 && hotBarMap_da.cnt>0 && hotBarMap(0).isFixed) + if ( inx == 0 && hotBarMap_da.cnt>0 && hotBarMap(0).isFixed) { orig.x = 0; - else + } else { orig.x = hotBarMap(inx).x-hotBarMap(hotBarCurrStart).x + (inx>0?fixed_x:0); + } orig.y = 0; size.x = hotBarMap(inx).w - 2.0/hotBarD.dpi; size.y = toolbarHeight; #ifdef LATER printf( "HotBarHilite fixed_x:%0.3f X0:%d/%0.3f X:%d/%0.3f+%0.3f X=%0.3f\n", - fixed_x, - hotBarCurrStart, hotBarMap(hotBarCurrStart).x, - inx, hotBarMap(inx).x, hotBarMap(inx).w, - orig.x ); + fixed_x, + hotBarCurrStart, hotBarMap(hotBarCurrStart).x, + inx, hotBarMap(inx).x, hotBarMap(inx).w, + orig.x ); #endif DrawRectangle( &hotBarD, orig, size, wDrawColorBlack, DRAW_TRANSPARENT ); } @@ -106,15 +109,18 @@ static void RedrawHotBar( wDraw_p dd, void * data, wWinPix_t w, wWinPix_t h ) coOrd orig; int inx; hotBarMap_t * tbm; - DIST_T barHeight = (DIST_T)(wControlGetHeight( (wControl_p)hotBarD.d ) - 2)/hotBarD.dpi; - DIST_T barWidth = (DIST_T)(wControlGetWidth( (wControl_p)hotBarD.d ) - 2)/hotBarD.dpi; + DIST_T barHeight = (DIST_T)(wControlGetHeight( (wControl_p)hotBarD.d ) - + 2)/hotBarD.dpi; + DIST_T barWidth = (DIST_T)(wControlGetWidth( (wControl_p)hotBarD.d ) - + 2)/hotBarD.dpi; + DIST_T barScale; DIST_T x; wDrawClear( hotBarD.d ); - if (hotBarCurrStart >0) + if (hotBarCurrStart >0) { wControlActive( (wControl_p)hotBarLeftB, TRUE ); - else { + } else { wButtonSetBusy(hotBarLeftB, FALSE); wControlActive( (wControl_p)hotBarLeftB, FALSE ); } @@ -124,11 +130,13 @@ static void RedrawHotBar( wDraw_p dd, void * data, wWinPix_t w, wWinPix_t h ) wControlActive( (wControl_p)hotBarRightB, FALSE ); return; } - if ( hotBarLabels && !hotBarFp ) + if ( hotBarLabels && !hotBarFp ) { hotBarFp = wStandardFont( F_HELV, FALSE, FALSE ); + } DIST_T fixed_x = 0.0; - if (hotBarCurrStart>0 && hotBarMap_da.cnt>0 && hotBarMap(0).isFixed) { //Do fixed element first - Cornu + if (hotBarCurrStart>0 && hotBarMap_da.cnt>0 + && hotBarMap(0).isFixed) { //Do fixed element first - Cornu tbm = &hotBarMap(0); barScale = tbm->barScale; x = 0.0; @@ -138,8 +146,8 @@ static void RedrawHotBar( wDraw_p dd, void * data, wWinPix_t w, wWinPix_t h ) if ( tbm->labelW > tbm->objectW ) { fixed_x = tbm->labelW; x += (tbm->labelW-tbm->objectW)/2; - } else fixed_x = tbm->objectW; - } else fixed_x = tbm->objectW; + } else { fixed_x = tbm->objectW; } + } else { fixed_x = tbm->objectW; } x *= barScale; orig.x = x; hotBarD.scale = barScale; @@ -150,7 +158,8 @@ static void RedrawHotBar( wDraw_p dd, void * data, wWinPix_t w, wWinPix_t h ) hotBarD.scale = 1.0; orig.x = 0.0; orig.y = 2.0/hotBarD.dpi; //Draw Label under icon - DrawString( &hotBarD, orig, 0.0, tbm->proc( HB_BARTITLE, tbm->context, NULL, NULL ), hotBarFp, hotBarFs, drawColorBlack ); + DrawString( &hotBarD, orig, 0.0, tbm->proc( HB_BARTITLE, tbm->context, NULL, + NULL ), hotBarFp, hotBarFs, drawColorBlack ); } } @@ -179,18 +188,21 @@ static void RedrawHotBar( wDraw_p dd, void * data, wWinPix_t w, wWinPix_t h ) hotBarD.scale = 1.0; orig.x = tbm->x - hotBarMap(hotBarCurrStart).x + fixed_x; orig.y = 2.0/hotBarD.dpi; //Draw Label under icon - DrawString( &hotBarD, orig, 0.0, tbm->proc( HB_BARTITLE, tbm->context, NULL, NULL ), hotBarFp, hotBarFs, drawColorBlack ); + DrawString( &hotBarD, orig, 0.0, tbm->proc( HB_BARTITLE, tbm->context, NULL, + NULL ), hotBarFp, hotBarFs, drawColorBlack ); } } hotBarCurrEnd = inx; if ((hotBarCurrSelect==0 && hotBarMap_da.cnt>0 && hotBarMap(0).isFixed) || - ((hotBarCurrSelect >= hotBarCurrStart) && (hotBarCurrSelect < hotBarCurrEnd)) ) + ((hotBarCurrSelect >= hotBarCurrStart) + && (hotBarCurrSelect < hotBarCurrEnd)) ) { HotBarHighlight( hotBarCurrSelect, fixed_x ); -/* else - hotBarCurrSelect = -1;*/ - if (hotBarCurrEnd < hotBarMap_da.cnt) + } + /* else + hotBarCurrSelect = -1;*/ + if (hotBarCurrEnd < hotBarMap_da.cnt) { wControlActive( (wControl_p)hotBarRightB, TRUE ); - else { + } else { wButtonSetBusy(hotBarRightB, FALSE); wControlActive( (wControl_p)hotBarRightB, FALSE ); } @@ -200,22 +212,26 @@ static void RedrawHotBar( wDraw_p dd, void * data, wWinPix_t w, wWinPix_t h ) static void DoHotBarRight( void * data ) { - DIST_T barWidth = ((DIST_T)wControlGetWidth( (wControl_p)hotBarD.d ) - 2.0)/hotBarD.dpi; + DIST_T barWidth = ((DIST_T)wControlGetWidth( (wControl_p)hotBarD.d ) - + 2.0)/hotBarD.dpi; int inx = hotBarCurrStart; - DIST_T lastX = hotBarMap(hotBarMap_da.cnt-1).x + hotBarMap(hotBarMap_da.cnt-1).w + 2.0/hotBarD.dpi; + DIST_T lastX = hotBarMap(hotBarMap_da.cnt-1).x + hotBarMap( + hotBarMap_da.cnt-1).w + 2.0/hotBarD.dpi; if (MyGetKeyState()&WKEY_SHIFT) { inx += hotBarMap_da.cnt/8; } else { inx++; } - if ( inx >= hotBarMap_da.cnt ) + if ( inx >= hotBarMap_da.cnt ) { inx = hotBarMap_da.cnt-1; + } DIST_T fixed_x = 0.0; if (hotBarCurrStart>0 && hotBarMap(0).isFixed) { fixed_x = hotBarMap(0).w; } - while ( (inx > 1) && ((lastX - hotBarMap(inx-1).x) < (barWidth - fixed_x)) ) - inx--; + while ( (inx > 1) && ((lastX - hotBarMap(inx-1).x) < (barWidth - fixed_x)) ) { + inx--; + } if ( inx != hotBarCurrStart ) { hotBarCurrStart = inx; RedrawHotBar( hotBarD.d, NULL, 0, 0 ); @@ -231,8 +247,9 @@ static void DoHotBarLeft( void * data ) } else { inx --; } - if ( inx < 0 ) + if ( inx < 0 ) { inx = 0; + } if ( inx != hotBarCurrStart ) { hotBarCurrStart = inx; RedrawHotBar( hotBarD.d, NULL, 0, 0 ); @@ -245,17 +262,20 @@ static void DoHotBarJump( int inx ) DIST_T x, barWidth; inx -= '0'; - if (inx < 0 || inx > 9) + if (inx < 0 || inx > 9) { return; - if (inx == 0) + } + if (inx == 0) { inx = 9; - else + } else { inx--; + } barWidth = (DIST_T)wControlGetWidth( (wControl_p)hotBarD.d )/hotBarD.dpi; x = (inx*(hotBarWidth-barWidth))/9.0; for ( inx=0; inx<hotBarMap_da.cnt; inx++ ) { - if (x <= hotBarMap(inx).x) + if (x <= hotBarMap(inx).x) { break; + } } if ( hotBarCurrStart != inx ) { hotBarCurrStart = inx; @@ -264,21 +284,35 @@ static void DoHotBarJump( int inx ) } -static void SelectHotBar( wDraw_p d, void * context, wAction_t action, wDrawPix_t w, wDrawPix_t h ) +static void SelectHotBar( wDraw_p d, void * context, wAction_t action, + wDrawPix_t w, wDrawPix_t h ) { int inx; - coOrd pos; +// coOrd pos; DIST_T x; wWinPix_t px; hotBarMap_t * tbm; char * titleP; - if ( hotBarMap_da.cnt <= 0 ) + if ( hotBarMap_da.cnt <= 0 ) { return; + } #if 0 - if ( !CommandEnabled( hotBarCmdInx ) ) + if ( !CommandEnabled( hotBarCmdInx ) ) { return; + } #endif + + if ( ( action & 0xff ) == wActionText ) { + int key = (int)(action >> 8); + if ( key >= '0' && key <= '9') { + DoHotBarJump( key ); + } else if ( key == 0x1B ) { + ConfirmReset( FALSE ); + } + return; + } + if ( (action&0xFF) == wActionRUp ) { wMenuPopupShow( hotbarPopupM ); return; @@ -290,20 +324,21 @@ static void SelectHotBar( wDraw_p d, void * context, wAction_t action, wDrawPix_ fixed_x = hotBarMap(0).w; x = w/hotBarD.dpi + hotBarMap(0).x; if ( (x>= hotBarMap(0).x) && - (x <=hotBarMap(0).w )) inx = 0; //Match on fixed + (x <=hotBarMap(0).w )) { inx = 0; } //Match on fixed } - if (inx<0){ //NoMatch + if (inx<0) { //NoMatch x = w/hotBarD.dpi + hotBarMap(hotBarCurrStart).x; for ( inx=hotBarCurrStart; inx<hotBarCurrEnd; inx++ ) { if ((x >= hotBarMap(inx).x + fixed_x) && //leave spaces between buttons - (x <= hotBarMap(inx).x + hotBarMap(inx).w + fixed_x )) { - break; + (x <= hotBarMap(inx).x + hotBarMap(inx).w + fixed_x )) { + break; } } } - if (inx >= hotBarCurrEnd) + if (inx >= hotBarCurrEnd) { return; + } tbm = &hotBarMap(inx); if (inx==0) { px = (wWinPix_t)((tbm->x-hotBarMap(0).x)*hotBarD.dpi); @@ -316,8 +351,8 @@ static void SelectHotBar( wDraw_p d, void * context, wAction_t action, wDrawPix_ wControlSetBalloon( (wControl_p)hotBarD.d, px, -20, titleP ); switch (action & 0xff) { case wActionLDown: - pos.x = mainD.size.x+mainD.orig.x; - pos.y = mainD.size.y+mainD.orig.y; +// pos.x = mainD.size.x+mainD.orig.x; +// pos.y = mainD.size.y+mainD.orig.y; if ( hotBarCurrSelect >= 0 ) { //HotBarHighlight( hotBarCurrSelect ); hotBarCurrSelect = -1; @@ -328,7 +363,8 @@ static void SelectHotBar( wDraw_p d, void * context, wAction_t action, wDrawPix_ hotBarCurrSelect = inx; HotBarHighlight( hotBarCurrSelect, fixed_x ); if (recordF) { - fprintf( recordF, "HOTBARSELECT %s\n", tbm->proc( HB_FULLTITLE, tbm->context, NULL, NULL ) ); + fprintf( recordF, "HOTBARSELECT %s\n", tbm->proc( HB_FULLTITLE, tbm->context, + NULL, NULL ) ); } FakeDownMouseState(); break; @@ -348,25 +384,6 @@ static void SelectHotBar( wDraw_p d, void * context, wAction_t action, wDrawPix_ break; } break; - case wActionText: - switch (action >> 8) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - DoHotBarJump( action >> 8 ); - break; - case 0x1B: - ConfirmReset(FALSE); - break; - } - break; } } @@ -375,34 +392,32 @@ EXPORT void HotBarCancel( void ) { if ( hotBarCurrSelect >= 0 ) //HotBarHighlight( hotBarCurrSelect ); - hotBarCurrSelect = -1; + { + hotBarCurrSelect = -1; + } RedrawHotBar(hotBarD.d, NULL, 0, 0 ); } static BOOL_T HotBarSelectPlayback( char * line ) { - int inx; - hotBarMap_t * tbm; - while (*line && isspace((unsigned char)*line) ) line++; - DIST_T fixed_x = 0; - for ( inx=0; inx<hotBarMap_da.cnt; inx++ ) { - tbm = &hotBarMap(inx); - if (inx == 0 && hotBarMap_da.cnt>0 && hotBarMap(0).isFixed) { - fixed_x = hotBarMap(0).w; - } + while (*line && isspace((unsigned char)*line) ) { line++; } + for ( int inx=0; inx<hotBarMap_da.cnt; inx++ ) { + hotBarMap_t * tbm = &hotBarMap(inx); if ( strcmp( tbm->proc( HB_FULLTITLE, tbm->context, NULL, NULL ), line) == 0) { - if ( hotBarCurrSelect >= 0 ) { - //HotBarHighlight( hotBarCurrSelect ); - RedrawHotBar(hotBarD.d, NULL, 0, 0 ); - } + tbm->proc( HB_SELECT, hotBarMap(inx).context, NULL, NULL ); hotBarCurrSelect = inx; if ( hotBarCurrSelect < hotBarCurrStart || hotBarCurrSelect > hotBarCurrEnd ) { + // Shift the hotbar so the selected object is visible hotBarCurrStart = hotBarCurrSelect; RedrawHotBar( hotBarD.d, NULL, 0, 0 ); } + DIST_T fixed_x = 0.0; + if ( inx > 0 && hotBarCurrStart > 0 && hotBarMap(0).isFixed ) { + // Leave room for Flex object + fixed_x = hotBarMap(0).w; + } HotBarHighlight( hotBarCurrSelect, fixed_x ); - hotBarMap(inx).proc( HB_SELECT, hotBarMap(inx).context, NULL, NULL ); FakeDownMouseState(); return TRUE; } @@ -427,58 +442,64 @@ static BOOL_T SetHotBarScale( char * line ) static char curContentsLabel[STR_SHORT_SIZE]; EXPORT void AddHotBarElement( - char * contentsLabel, - coOrd size, - coOrd orig, - BOOL_T isTrack, - BOOL_T isFixed, - DIST_T barScale, - void * context, - hotBarProc_t proc_p ) + char * contentsLabel, + coOrd size, + coOrd orig, + BOOL_T isTrack, + BOOL_T isFixed, + DIST_T barScale, + void * context, + hotBarProc_t proc_p ) { hotBarMap_t * tbm; coOrd textsize; - if ( contentsLabel && strncmp(contentsLabel, curContentsLabel, sizeof curContentsLabel) != 0 && !isFixed ) { - wMenuListAdd( hotBarML, hotBarMLcnt++, contentsLabel, I2VP(hotBarMap_da.cnt) ); - strncpy( curContentsLabel, contentsLabel, sizeof curContentsLabel ); - } - if (barScale <= 0) { - if (!isTrack) - barScale = size.y/(((double)hotBarHeight-2.0)/hotBarD.dpi); - else if (isTrack) { - // size.y += 2.0 * trackGauge; - barScale = (trackGauge>0.1)?trackGauge*(36-hotBarHeight/2):10.0; - // barScale = 2.0 / ((hotBarHeight-2.0) / hotBarD.dpi); - //if (size.y >= size.x) - if (size.y/barScale > ((double)hotBarHeight-2.0)/hotBarD.dpi) - barScale = (size.y+2.0*trackGauge)/(((double)hotBarHeight-2.0)/hotBarD.dpi); + if ( contentsLabel + && strncmp(contentsLabel, curContentsLabel, sizeof curContentsLabel) != 0 + && !isFixed ) { + wMenuListAdd( hotBarML, hotBarMLcnt++, contentsLabel, I2VP(hotBarMap_da.cnt) ); + strncpy( curContentsLabel, contentsLabel, sizeof(curContentsLabel)-1 ); + } + if (barScale <= 0) { + if (!isTrack) { + barScale = size.y/(((double)hotBarHeight-2.0)/hotBarD.dpi); + } else if (isTrack) { + // size.y += 2.0 * trackGauge; + barScale = (trackGauge>0.1)?trackGauge*(36-hotBarHeight/2):10.0; + // barScale = 2.0 / ((hotBarHeight-2.0) / hotBarD.dpi); + //if (size.y >= size.x) + if (size.y/barScale > ((double)hotBarHeight-2.0)/hotBarD.dpi) { + barScale = (size.y+2.0*trackGauge)/(((double)hotBarHeight-2.0)/hotBarD.dpi); } - // orig.y += 1.0/hotBarD.dpi; } - DYNARR_APPEND( hotBarMap_t, hotBarMap_da, 10 ); - tbm = &hotBarMap(hotBarMap_da.cnt-1); - if (barScale < 1) - barScale = 1; - if (size.x > barScale) - barScale = size.x; - tbm->context = context; - tbm->size = size; - tbm->orig = orig; - tbm->proc = proc_p; - tbm->barScale = barScale; - tbm->isFixed = isFixed; - tbm->w = tbm->objectW = size.x/barScale + 5.0/hotBarD.dpi; - tbm->labelW = 0; - tbm->x = hotBarWidth; - if ( hotBarLabels ) { - DrawTextSize( &hotBarD, proc_p( HB_BARTITLE, context, NULL, NULL), hotBarFp, hotBarFs, FALSE, &textsize ); - tbm->labelW = textsize.x+5/hotBarD.dpi; - if ( tbm->labelW > tbm->w ) { - tbm->w = tbm->labelW; - } + // orig.y += 1.0/hotBarD.dpi; + } + DYNARR_APPEND( hotBarMap_t, hotBarMap_da, 10 ); + tbm = &hotBarMap(hotBarMap_da.cnt-1); + if (barScale < 1) { + barScale = 1; + } + if (size.x > barScale) { + barScale = size.x; + } + tbm->context = context; + tbm->size = size; + tbm->orig = orig; + tbm->proc = proc_p; + tbm->barScale = barScale; + tbm->isFixed = isFixed; + tbm->w = tbm->objectW = size.x/barScale + 5.0/hotBarD.dpi; + tbm->labelW = 0; + tbm->x = hotBarWidth; + if ( hotBarLabels ) { + DrawTextSize( &hotBarD, proc_p( HB_BARTITLE, context, NULL, NULL), hotBarFp, + hotBarFs, FALSE, &textsize ); + tbm->labelW = textsize.x+5/hotBarD.dpi; + if ( tbm->labelW > tbm->w ) { + tbm->w = tbm->labelW; } - hotBarWidth += tbm->w + 2/hotBarD.dpi; + } + hotBarWidth += tbm->w + 2/hotBarD.dpi; } @@ -490,10 +511,12 @@ static void ChangeHotBar( long changes ) #endif static long programModeOld = 0; - if ( (changes&(CHANGE_SCALE|CHANGE_PARAMS|CHANGE_TOOLBAR)) == 0 ) + if ( (changes&(CHANGE_SCALE|CHANGE_PARAMS|CHANGE_TOOLBAR)) == 0 ) { return; - if ( hotBarLabels && !hotBarFp ) + } + if ( hotBarLabels && !hotBarFp ) { hotBarFp = wStandardFont( F_HELV, FALSE, FALSE ); + } if (hotBarLeftB != NULL && curScaleName) { hotBarWidth = 0.0; hotBarMLcnt = 0; @@ -501,8 +524,9 @@ static void ChangeHotBar( long changes ) DYNARR_RESET( hotBarMap_t, hotBarMap_da ); curContentsLabel[0] = '\0'; if ( programMode == MODE_DESIGN ) { - if (showFlexTrack) + if (showFlexTrack) { AddHotBarCornu(); + } AddHotBarTurnouts(); AddHotBarStructures(); } else { @@ -513,8 +537,10 @@ static void ChangeHotBar( long changes ) hotBarCurrSelects[0] = hotBarCurrSelects[1] = -1; programModeOld = programMode; } - if (hotBarMap_da.cnt > 0 && (hotBarCurrStart >= hotBarMap_da.cnt||hotBarCurrStart < 0)) + if (hotBarMap_da.cnt > 0 && (hotBarCurrStart >= hotBarMap_da.cnt + ||hotBarCurrStart < 0)) { hotBarCurrStart = 0; + } RedrawHotBar( NULL, NULL, 0, 0 ); } } @@ -542,28 +568,25 @@ EXPORT void LayoutHotBar( void * redraw ) BOOL_T initialize = FALSE; wWinGetSize( mainW, &winWidth, &winHeight ); - /** @prefs [Preference] LargeIcons=1.5 Sets Icon scaling limits 1.0 to 2.0 */ - double scaleicon; - wPrefGetFloat(PREFSECTION, LARGEICON, &scaleicon, 1.0); - if (scaleicon<1.0) scaleicon=1.0; - if (scaleicon>2.0) scaleicon=2.0; - //if (scaleicon>1.0) { - // hotBarHeight = (wWinPix_t)(hotBarHeight); - //} - hotBarTextHeight = (wWinPix_t)round(wMessageGetHeight(0L) * (0.5 + (double)iconSize / 10.0)); + hotBarTextHeight = (wWinPix_t)round(wMessageGetHeight(0L) * (0.6 + 0.4 * + (double)iconSize)); if ( hotBarLabels) { - hbHeight += hotBarTextHeight; + hbHeight += hotBarTextHeight; } if (hotBarLeftB == NULL) { wIcon_p bm_p; - if (winWidth < 50) + if (winWidth < 50) { return; + } bm_p = wIconCreateBitMap( 16, 16, turnbarl_bits, wDrawColorBlack ); - hotBarLeftB = wButtonCreate( mainW, 0, 0, "hotBarLeft", (char*)bm_p, BO_ICON|BO_REPEAT, 0, DoHotBarLeft, NULL ); + hotBarLeftB = wButtonCreate( mainW, 0, 0, "hotBarLeft", (char*)bm_p, + BO_ICON|BO_REPEAT, 0, DoHotBarLeft, NULL ); bm_p = wIconCreateBitMap( 16, 16, turnbarr_bits, wDrawColorBlack ); - hotBarRightB = wButtonCreate( mainW, 0, 0, "hotBarRight", (char*)bm_p, BO_ICON|BO_REPEAT, 0, DoHotBarRight, NULL ); - hotBarD.d = wDrawCreate( mainW, 0, 0, NULL, BD_NOCAPTURE|BD_NOFOCUS, 100, hbHeight, NULL, RedrawHotBar, SelectHotBar ); + hotBarRightB = wButtonCreate( mainW, 0, 0, "hotBarRight", (char*)bm_p, + BO_ICON|BO_REPEAT, 0, DoHotBarRight, NULL ); + hotBarD.d = wDrawCreate( mainW, 0, 0, NULL, 0, 100, + hbHeight, NULL, RedrawHotBar, SelectHotBar ); hotBarD.dpi = wDrawGetDPI( hotBarD.d ); hotBarD.scale = 1.0; wSetCursor(hotBarD.d,wCursorNormal); @@ -571,19 +594,25 @@ EXPORT void LayoutHotBar( void * redraw ) } buttonWidth = wControlGetWidth((wControl_p)hotBarLeftB); buttonHeight = wControlGetHeight((wControl_p)hotBarLeftB); - wControlSetPos( (wControl_p)hotBarLeftB, HOTBAR_LEFT, toolbarHeight+(hbHeight-buttonHeight)/2 ); - wControlSetPos( (wControl_p)hotBarRightB, winWidth-20-buttonWidth+HOTBAR_LEFT+1, toolbarHeight+(hbHeight-buttonHeight)/2 ); - wControlSetPos( (wControl_p)hotBarD.d, buttonWidth+HOTBAR_LEFT+1, toolbarHeight ); + wControlSetPos( (wControl_p)hotBarLeftB, HOTBAR_LEFT, + toolbarHeight+(hbHeight-buttonHeight)/2 ); + wControlSetPos( (wControl_p)hotBarRightB, winWidth-20-buttonWidth+HOTBAR_LEFT+1, + toolbarHeight+(hbHeight-buttonHeight)/2 ); + wControlSetPos( (wControl_p)hotBarD.d, buttonWidth+HOTBAR_LEFT+1, + toolbarHeight ); wDrawSetSize( hotBarD.d, winWidth-20-buttonWidth*2, hbHeight+2, redraw ); - hotBarD.size.x = ((double)(winWidth-20-buttonWidth*2))/hotBarD.dpi*hotBarD.scale; - hotBarD.size.y = (double)hotBarHeight/hotBarD.dpi*hotBarD.scale; //Exclude Label from calc + hotBarD.size.x = ((double)(winWidth-20 + -buttonWidth*2))/hotBarD.dpi*hotBarD.scale; + hotBarD.size.y = (double) + hotBarHeight/hotBarD.dpi*hotBarD.scale; //Exclude Label from calc wControlShow( (wControl_p)hotBarLeftB, TRUE ); wControlShow( (wControl_p)hotBarRightB, TRUE ); wControlShow( (wControl_p)hotBarD.d, TRUE ); - if (initialize) + if (initialize) { ChangeHotBar( CHANGE_PARAMS ); - else if (!redraw) + } else if (!redraw) { RedrawHotBar( NULL, NULL, 0, 0 ); + } toolbarHeight += hbHeight+3; } diff --git a/app/bin/cjoin.c b/app/bin/cjoin.c index a027327..cb794bd 100644 --- a/app/bin/cjoin.c +++ b/app/bin/cjoin.c @@ -20,7 +20,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -40,30 +40,30 @@ static BOOL_T debug = 0; /** @logcmd @showrefby join=n cjoin.c */ static int log_join = 0; typedef struct { - curveType_e type; - BOOL_T flip; - coOrd arcP; - DIST_T arcR; - ANGLE_T arcA0, arcA1; - coOrd pos[2]; - } joinRes_t; + curveType_e type; + BOOL_T flip; + coOrd arcP; + DIST_T arcR; + ANGLE_T arcA0, arcA1; + coOrd pos[2]; +} joinRes_t; static struct { - STATE_T state; - int joinMoveState; - BOOL_T cornuMode; - struct { - TRKTYP_T realType; - track_p trk; - coOrd pos; - EPINX_T ep; - trackParams_t params; - } inp[2]; - joinRes_t jRes; - coOrd inp_pos[2]; - easementData_t jointD[2]; - dynArr_t anchors; - } Dj; + STATE_T state; + int joinMoveState; + BOOL_T cornuMode; + struct { + TRKTYP_T realType; + track_p trk; + coOrd pos; + EPINX_T ep; + trackParams_t params; + } inp[2]; + joinRes_t jRes; + coOrd inp_pos[2]; + easementData_t jointD[2]; + dynArr_t anchors; +} Dj; /***************************************************************************** @@ -74,11 +74,11 @@ static struct { static BOOL_T JoinWithStraight( - coOrd pos0, - ANGLE_T a0, - coOrd pos1, - ANGLE_T a1, - joinRes_t * res ) + coOrd pos0, + ANGLE_T a0, + coOrd pos1, + ANGLE_T a1, + joinRes_t * res ) /* * Determine a track from a point and angle (pos1,a1) to * a straight (given by an origin and angle: pos0, a0) @@ -92,17 +92,17 @@ static BOOL_T JoinWithStraight( DOUBLE_T beyond; b = NormalizeAngle( a0 - a1 ); -LOG( log_join, 2, ( - "JwL: pos0=[%0.3f %0.3f] a0=%0.3f pos1=[%0.3f %0.3f] a1=%0.3f b=%0.3f\n", - pos0.x, pos0.y, a0, pos1.x, pos1.y, a1, b ) ) + LOG( log_join, 2, ( + "JwL: pos0=[%0.3f %0.3f] a0=%0.3f pos1=[%0.3f %0.3f] a1=%0.3f b=%0.3f\n", + pos0.x, pos0.y, a0, pos1.x, pos1.y, a1, b ) ) -/* 3 - cases: */ + /* 3 - cases: */ if (b >= 360.0-connectAngle/2.0 || b <= connectAngle/2.0) { -/* CASE 1: antiparallel */ + /* CASE 1: antiparallel */ FindPos( &off, NULL, pos1, pos0, a0, DIST_INF ); res->arcR = off.y/2.0; res->arcA1 = 180.0; -LOG( log_join, 3, ("JwL: parallel: off.y=%0.3f\n", off.y ) ) + LOG( log_join, 3, ("JwL: parallel: off.y=%0.3f\n", off.y ) ) res->arcA0 = NormalizeAngle( a1 - 90.0 ); Translate( &res->arcP, pos1, res->arcA0, res->arcR ); if (res->arcR > 0.0) { @@ -112,14 +112,15 @@ LOG( log_join, 3, ("JwL: parallel: off.y=%0.3f\n", off.y ) ) res->flip = 1; } } else if (b >= 180.0-connectAngle/2.0 && b <= 180.0+connectAngle/2.0) { -/* CASE 2: parallel, possibly colinear? */ + /* CASE 2: parallel, possibly colinear? */ FindPos( &off, &beyond, pos0, pos1, a0, DIST_INF ); -LOG( log_join, 3, ("JwL: colinear? off.y=%0.3f\n", off.y ) ) + LOG( log_join, 3, ("JwL: colinear? off.y=%0.3f\n", off.y ) ) if (off.y > -connectDistance && off.y < connectDistance) { res->type = curveTypeStraight; res->pos[0]=pos0; res->pos[1]=pos1; -LOG( log_join, 2, (" = STRAIGHT [%0.3f %0.3f] [%0.3f %0.3f]\n", pos0.x, pos0.y, pos1.x, pos1.y ) ) + LOG( log_join, 2, (" = STRAIGHT [%0.3f %0.3f] [%0.3f %0.3f]\n", pos0.x, + pos0.y, pos1.x, pos1.y ) ) return TRUE; } else { res->type = curveTypeNone; @@ -127,7 +128,7 @@ LOG( log_join, 2, (" = STRAIGHT [%0.3f %0.3f] [%0.3f %0.3f]\n", pos0.x, pos0. return TRUE; } } else { -/* CASE 3: intersecting */ + /* CASE 3: intersecting */ if (!FindIntersection( &Px, pos0, a0, pos1, a1 )) { res->type = curveTypeNone; ErrorMessage( MSG_SELECTED_TRACKS_PARALLEL ); @@ -136,13 +137,16 @@ LOG( log_join, 2, (" = STRAIGHT [%0.3f %0.3f] [%0.3f %0.3f]\n", pos0.x, pos0. d = FindDistance( pos1, Px ); k = NormalizeAngle( FindAngle(pos1, Px) - a1 ); c = (b > 180.0) ? (360.0-b) : b; - if (k < 90.0 && k > 270.0) + if (k < 90.0 && k > 270.0) { c += 180.0; -LOG( log_join, 3, (" Px=[%0.3f %0.3f] b=%0.3f c=%0.3f d=%0.3f k=%0.3f\n", Px.x, Px.y, b, c, d, k ) ) + } + LOG( log_join, 3, (" Px=[%0.3f %0.3f] b=%0.3f c=%0.3f d=%0.3f k=%0.3f\n", + Px.x, Px.y, b, c, d, k ) ) res->arcR = d * sin(D2R(c/2.0))/cos(D2R(c/2.0)); res->arcA1 = 180.0-c; - if (90.0<k && k<270.0) - res->arcA1 = 360.0 - res->arcA1; + if (90.0<k && k<270.0) { + res->arcA1 = 360.0 - res->arcA1; + } if ( (res->arcA1>180.0) == (b>180.0) ) { Translate( &res->arcP, pos1, a1-90.0, res->arcR ); res->arcA0 = NormalizeAngle( a0 - 90.0 ); @@ -153,73 +157,78 @@ LOG( log_join, 3, (" Px=[%0.3f %0.3f] b=%0.3f c=%0.3f d=%0.3f k=%0.3f\n", Px res->flip = TRUE; } } -LOG( log_join, 2, (" = CURVE @ Pc=[%0.3f %0.3f] R=%0.3f A0=%0.3f A1=%0.3f Flip=%d\n", - res->arcP.x, res->arcP.y, res->arcR, res->arcA0, res->arcA1, res->flip ) ) - if (res->arcR<0.0) res->arcR = - res->arcR; + LOG( log_join, 2, + (" = CURVE @ Pc=[%0.3f %0.3f] R=%0.3f A0=%0.3f A1=%0.3f Flip=%d\n", + res->arcP.x, res->arcP.y, res->arcR, res->arcA0, res->arcA1, res->flip ) ) + if (res->arcR<0.0) { res->arcR = - res->arcR; } res->type = curveTypeCurve; d = D2R(res->arcA1); - if (d < 0.0) + if (d < 0.0) { d = 2*M_PI + d; + } if (!debug) InfoMessage( _("Curved Track: Radius=%s Length=%s"), - FormatDistance(res->arcR), FormatDistance(res->arcR*d) ); + FormatDistance(res->arcR), FormatDistance(res->arcR*d) ); return TRUE; } static BOOL_T JoinWithCurve( - coOrd pos0, - DIST_T r0, - EPINX_T ep0, - coOrd pos1, - ANGLE_T a1, /* Angle perpendicular to track at (pos1) */ - joinRes_t * res ) + coOrd pos0, + DIST_T r0, + EPINX_T ep0, + coOrd pos1, + ANGLE_T a1, /* Angle perpendicular to track at (pos1) */ + joinRes_t * res ) /* * Determine a track point and angle (pos1,a1) to * a curve (given by center and radius (pos0, r0). * Curve endPt (ep0) determines whether the connection is * clockwise or counterclockwise. - */ + */ { coOrd p1, pt; DIST_T d, r; ANGLE_T a, aa, A0, A1; -/* Compute angle of line connecting endPoints: */ + /* Compute angle of line connecting endPoints: */ Translate( &p1, pos1, a1, -r0 ); aa = FindAngle( p1, pos0 ); a = NormalizeAngle( aa - a1 ); -LOG( log_join, 2, ("JwA: pos0=[%0.3f %0.3f] r0=%0.3f ep0=%d pos1=[%0.3f %0.3f] a1=%0.3f\n", - pos0.x, pos0.y, r0, ep0, pos1.x, pos1.y, a1 ) ) -LOG( log_join, 3, (" p1=[%0.3f %0.3f] aa=%0.3f a=%0.3f\n", - p1.x, p1.y, aa, a ) ) + LOG( log_join, 2, + ("JwA: pos0=[%0.3f %0.3f] r0=%0.3f ep0=%d pos1=[%0.3f %0.3f] a1=%0.3f\n", + pos0.x, pos0.y, r0, ep0, pos1.x, pos1.y, a1 ) ) + LOG( log_join, 3, (" p1=[%0.3f %0.3f] aa=%0.3f a=%0.3f\n", + p1.x, p1.y, aa, a ) ) if ( (ep0==1 && a > 89.5 && a < 90.5) || - (ep0==0 && a > 269.5 && a < 270.5) ) { -/* The long way around! */ + (ep0==0 && a > 269.5 && a < 270.5) ) { + /* The long way around! */ ErrorMessage( MSG_CURVE_TOO_LARGE ); res->type = curveTypeNone; } else if ( (ep0==0 && a > 89.5 && a < 90.5) || - (ep0==1 && a > 269.5 && a < 270.5) ) { -/* Straight: */ + (ep0==1 && a > 269.5 && a < 270.5) ) { + /* Straight: */ PointOnCircle( &pt, pos0, r0, a1); -LOG( log_join, 2, (" = STRAIGHT [%0.3f %0.3f] [%0.3f %0.3f]\n", pt.x, pt.y, pos1.x, pos1.y ) ) + LOG( log_join, 2, (" = STRAIGHT [%0.3f %0.3f] [%0.3f %0.3f]\n", pt.x, pt.y, + pos1.x, pos1.y ) ) if (!debug) InfoMessage( _("Straight Track: Length=%s Angle=%0.3f"), - FormatDistance(FindDistance( pt, pos1 )), PutAngle(FindAngle( pt, pos1 )) ); + FormatDistance(FindDistance( pt, pos1 )), PutAngle(FindAngle( pt, pos1 )) ); res->type = curveTypeStraight; res->pos[0]=pt; res->pos[1]=pos1; res->flip = FALSE; } else { -/* Curve: */ + /* Curve: */ d = FindDistance( p1, pos0 ) / 2.0; r = d/cos(D2R(a)); Translate( &res->arcP, p1, a1, r ); res->arcR = r-r0; -LOG( log_join, 3, (" Curved d=%0.3f C=[%0.3f %0.3f], r=%0.3f a=%0.3f arcR=%0.3f\n", - d, res->arcP.x, res->arcP.y, r, a, res->arcR ) ) + LOG( log_join, 3, + (" Curved d=%0.3f C=[%0.3f %0.3f], r=%0.3f a=%0.3f arcR=%0.3f\n", + d, res->arcP.x, res->arcP.y, r, a, res->arcR ) ) if ( (ep0==0) == (res->arcR<0) ) { A1 = 180 + 2*a; A0 = a1; @@ -243,12 +252,14 @@ LOG( log_join, 3, (" Curved d=%0.3f C=[%0.3f %0.3f], r=%0.3f a=%0.3f arcR=%0 return TRUE; } -LOG( log_join, 3, (" A0=%0.3f A1=%0.3f R=%0.3f\n", res->arcA0, res->arcA1, res->arcR ) ) + LOG( log_join, 3, (" A0=%0.3f A1=%0.3f R=%0.3f\n", res->arcA0, res->arcA1, + res->arcR ) ) d = D2R(res->arcA1); - if (d < 0.0) + if (d < 0.0) { d = 2*M_PI + d; + } if (!debug) InfoMessage( _("Curved Track: Radius=%s Length=%s Angle=%0.3f"), - FormatDistance(res->arcR), FormatDistance(res->arcR*d), PutAngle(res->arcA1) ); + FormatDistance(res->arcR), FormatDistance(res->arcR*d), PutAngle(res->arcA1) ); res->type = curveTypeCurve; } return TRUE; @@ -262,10 +273,10 @@ LOG( log_join, 3, (" A0=%0.3f A1=%0.3f R=%0.3f\n", res->arcA0, res->arcA1, static STATUS_T AdjustJoint( - BOOL_T adjust, - ANGLE_T a1, - DIST_T eR[2], - ANGLE_T normalAngle ) + BOOL_T adjust, + ANGLE_T a1, + DIST_T eR[2], + ANGLE_T normalAngle ) /* * Compute how to join 2 tracks and then compute the transition-curve * from the 2 tracks to the joint. @@ -285,38 +296,42 @@ static STATUS_T AdjustJoint( coOrd pc; DIST_T eRc; DIST_T l, d=0; - - if (adjust) + + if (adjust) { Translate( &p1, Dj.inp[1].pos, a1, Dj.jointD[1].x ); - else + } else { p1 = Dj.inp[1].pos; + } switch ( Dj.inp[0].params.type ) { case curveTypeCurve: if (adjust) { a0 = FindAngle( Dj.inp[0].params.arcP, Dj.jRes.pos[0] ); Translate( &pc, Dj.inp[0].params.arcP, a0, Dj.jointD[0].x ); -LOG( log_join, 2, (" Move P0 X%0.3f A%0.3f P1 X%0.3f A%0.3f SC%d FL%d\n", - Dj.jointD[0].x, a0, Dj.jointD[1].x, a1, - Dj.jointD[0].Scurve, Dj.jointD[0].flip ) ) + LOG( log_join, 2, (" Move P0 X%0.3f A%0.3f P1 X%0.3f A%0.3f SC%d FL%d\n", + Dj.jointD[0].x, a0, Dj.jointD[1].x, a1, + Dj.jointD[0].Scurve, Dj.jointD[0].flip ) ) } else { pc = Dj.inp[0].params.arcP; } if (!JoinWithCurve( pc, Dj.inp[0].params.arcR, - Dj.inp[0].params.ep, p1, normalAngle, &Dj.jRes )) + Dj.inp[0].params.ep, p1, normalAngle, &Dj.jRes )) { return FALSE; + } break; case curveTypeStraight: if (adjust) { a0 = Dj.inp[0].params.angle + (Dj.jointD[0].negate?-90.0:+90.0); Translate( &p0, Dj.inp[0].params.lineOrig, a0, Dj.jointD[0].x ); -LOG( log_join, 2, (" Move P0 X%0.3f A%0.3f P1 X%0.3f A%0.3f\n", - Dj.jointD[0].x, a0, Dj.jointD[1].x, a1 ) ) + LOG( log_join, 2, (" Move P0 X%0.3f A%0.3f P1 X%0.3f A%0.3f\n", + Dj.jointD[0].x, a0, Dj.jointD[1].x, a1 ) ) } else { p0 = Dj.inp[0].params.lineOrig; } - if (!JoinWithStraight( p0, Dj.inp[0].params.angle, p1, Dj.inp[1].params.angle, &Dj.jRes )) + if (!JoinWithStraight( p0, Dj.inp[0].params.angle, p1, Dj.inp[1].params.angle, + &Dj.jRes )) { return FALSE; + } break; default: break; @@ -328,13 +343,15 @@ LOG( log_join, 2, (" Move P0 X%0.3f A%0.3f P1 X%0.3f A%0.3f\n", if (Dj.jRes.type == curveTypeCurve) { eRc = Dj.jRes.arcR; - if (Dj.jRes.flip==1) + if (Dj.jRes.flip==1) { eRc = -eRc; - } else + } + } else { eRc = 0.0; + } if ( ComputeJoint( eR[0], eRc, &Dj.jointD[0] ) == E_ERROR || - ComputeJoint( -eR[1], -eRc, &Dj.jointD[1] ) == E_ERROR ) { + ComputeJoint( -eR[1], -eRc, &Dj.jointD[1] ) == E_ERROR ) { return FALSE; } @@ -343,9 +360,9 @@ LOG( log_join, 2, (" Move P0 X%0.3f A%0.3f P1 X%0.3f A%0.3f\n", if (Dj.inp[inx].params.type == curveTypeStraight ) { d = FindDistance( Dj.inp[inx].params.lineOrig, Dj.inp_pos[inx] ); if (d < Dj.jointD[inx].d0) { - InfoMessage( _("Track (%d) is too short for transition-curve by %0.3f"), - GetTrkIndex(Dj.inp[inx].trk), - PutDim(fabs(Dj.jointD[inx].d0-d)) ); + InfoMessage( _("Track (%d) is too short for transition-curve by %0.3f"), + GetTrkIndex(Dj.inp[inx].trk), + PutDim(fabs(Dj.jointD[inx].d0-d)) ); return FALSE; } } @@ -360,20 +377,23 @@ LOG( log_join, 2, (" Move P0 X%0.3f A%0.3f P1 X%0.3f A%0.3f\n", } d -= l; if ( d <= minLength ) { - if (!debug) - InfoMessage( _("Connecting track is too short by %0.3f"), PutDim(fabs(minLength-d)) ); + if (!debug) { + InfoMessage( _("Connecting track is too short by %0.3f"), + PutDim(fabs(minLength-d)) ); + } return FALSE; } if (Dj.jRes.type == curveTypeCurve) { PointOnCircle( &Dj.jRes.pos[Dj.jRes.flip], Dj.jRes.arcP, - Dj.jRes.arcR, Dj.jRes.arcA0 ); + Dj.jRes.arcR, Dj.jRes.arcA0 ); PointOnCircle( &Dj.jRes.pos[1-Dj.jRes.flip], Dj.jRes.arcP, - Dj.jRes.arcR, Dj.jRes.arcA0+Dj.jRes.arcA1 ); + Dj.jRes.arcR, Dj.jRes.arcA0+Dj.jRes.arcA1 ); } - if (adjust) + if (adjust) { Translate( &Dj.inp_pos[0], Dj.jRes.pos[0], a0+180.0, Dj.jointD[0].x ); + } return TRUE; } @@ -381,76 +401,83 @@ LOG( log_join, 2, (" Move P0 X%0.3f A%0.3f P1 X%0.3f A%0.3f\n", static STATUS_T DoMoveToJoin( coOrd pos ) { - if ( selectedTrackCount <= 0 ) { - ErrorMessage( MSG_NO_SELECTED_TRK ); - return C_CONTINUE; - } - if ( (Dj.inp[Dj.joinMoveState].trk = OnTrack( &pos, TRUE, TRUE )) == NULL ) - return C_CONTINUE; - // if (Dj.joinMoveState == 0 && !CheckTrackLayerSilent( Dj.inp[Dj.joinMoveState].trk ) ) - // return C_CONTINUE; - Dj.inp[Dj.joinMoveState].params.ep = PickUnconnectedEndPoint( pos, Dj.inp[Dj.joinMoveState].trk ); /* CHECKME */ - if ( Dj.inp[Dj.joinMoveState].params.ep == -1 ) { + if ( selectedTrackCount <= 0 ) { + ErrorMessage( MSG_NO_SELECTED_TRK ); + return C_CONTINUE; + } + if ( (Dj.inp[Dj.joinMoveState].trk = OnTrack( &pos, TRUE, TRUE )) == NULL ) { + return C_CONTINUE; + } + // if (Dj.joinMoveState == 0 && !CheckTrackLayerSilent( Dj.inp[Dj.joinMoveState].trk ) ) + // return C_CONTINUE; + Dj.inp[Dj.joinMoveState].params.ep = PickUnconnectedEndPoint( pos, + Dj.inp[Dj.joinMoveState].trk ); /* CHECKME */ + if ( Dj.inp[Dj.joinMoveState].params.ep == -1 ) { #ifdef LATER - ErrorMessage( MSG_NO_ENDPTS ); + ErrorMessage( MSG_NO_ENDPTS ); #endif - return C_CONTINUE; - } + return C_CONTINUE; + } #ifdef LATER - if ( GetTrkEndTrk( Dj.inp[Dj.joinMoveState].trk, Dj.inp[Dj.joinMoveState].params.ep ) ) { - ErrorMessage( MSG_SEL_EP_CONN ); - return C_CONTINUE; - } + if ( GetTrkEndTrk( Dj.inp[Dj.joinMoveState].trk, + Dj.inp[Dj.joinMoveState].params.ep ) ) { + ErrorMessage( MSG_SEL_EP_CONN ); + return C_CONTINUE; + } #endif - if (Dj.joinMoveState == 0) { - Dj.joinMoveState++; - InfoMessage( GetTrkSelected(Dj.inp[0].trk)? - _("Click on an unselected End-Point"): - _("Click on a selected End-Point") ); - Dj.inp[0].pos = pos; - return C_CONTINUE; - } - if ( GetTrkSelected(Dj.inp[0].trk) == GetTrkSelected(Dj.inp[1].trk) ) { - ErrorMessage( MSG_2ND_TRK_NOT_SEL_UNSEL, GetTrkSelected(Dj.inp[0].trk) - ? _("unselected") : _("selected") ); - return C_CONTINUE; - } - if (GetTrkSelected(Dj.inp[0].trk)) - MoveToJoin( Dj.inp[0].trk, Dj.inp[0].params.ep, Dj.inp[1].trk, Dj.inp[1].params.ep ); - else - MoveToJoin( Dj.inp[1].trk, Dj.inp[1].params.ep, Dj.inp[0].trk, Dj.inp[0].params.ep ); - Dj.joinMoveState = 0; - return C_TERMINATE; + if (Dj.joinMoveState == 0) { + Dj.joinMoveState++; + InfoMessage( GetTrkSelected(Dj.inp[0].trk)? + _("Click on an unselected End-Point"): + _("Click on a selected End-Point") ); + Dj.inp[0].pos = pos; + return C_CONTINUE; + } + if ( GetTrkSelected(Dj.inp[0].trk) == GetTrkSelected(Dj.inp[1].trk) ) { + ErrorMessage( MSG_2ND_TRK_NOT_SEL_UNSEL, GetTrkSelected(Dj.inp[0].trk) + ? _("unselected") : _("selected") ); + return C_CONTINUE; + } + if (GetTrkSelected(Dj.inp[0].trk)) { + MoveToJoin( Dj.inp[0].trk, Dj.inp[0].params.ep, Dj.inp[1].trk, + Dj.inp[1].params.ep ); + } else { + MoveToJoin( Dj.inp[1].trk, Dj.inp[1].params.ep, Dj.inp[0].trk, + Dj.inp[0].params.ep ); + } + Dj.joinMoveState = 0; + return C_TERMINATE; } typedef enum {NO_LINE,FIRST_END,HAVE_LINE,HAVE_SECOND_LINE} LineState_t; static struct { - LineState_t line_state; - int joinMoveState; - track_p curr_line; - struct { - TRKTYP_T realType; - track_p line; - coOrd pos; - coOrd end; - int cnt; - } inp[2]; - joinRes_t jRes; - coOrd inp_pos[2]; - dynArr_t anchors_da; - trackParams_t params; - dynArr_t newLine; - } Dl; + LineState_t line_state; + int joinMoveState; + track_p curr_line; + struct { + TRKTYP_T realType; + track_p line; + coOrd pos; + coOrd end; + int cnt; + } inp[2]; + joinRes_t jRes; + coOrd inp_pos[2]; + dynArr_t anchors_da; + trackParams_t params; + dynArr_t newLine; +} Dl; #define anchors(N) DYNARR_N(trkSeg_t,Dl.anchors_da,N) -void AddAnchorEnd(coOrd p) { +void AddAnchorEnd(coOrd p) +{ DIST_T d = tempD.scale*0.15; DYNARR_APPEND(trkSeg_t,Dl.anchors_da,1); trkSeg_p a = &DYNARR_LAST(trkSeg_t,Dl.anchors_da); a->type = SEG_CRVLIN; - a->width = 0; + a->lineWidth = 0; a->u.c.a0 = 0.0; a->u.c.a1 = 360.0; a->u.c.center = p; @@ -460,8 +487,8 @@ void AddAnchorEnd(coOrd p) { static STATUS_T CmdJoinLine( - wAction_t action, - coOrd pos ) + wAction_t action, + coOrd pos ) /* * Join 2 lines. */ @@ -472,7 +499,7 @@ static STATUS_T CmdJoinLine( InfoMessage( _("Left click - Select first draw object end") ); Dl.line_state = NO_LINE; Dl.joinMoveState = 0; - tempSegs_da.cnt = 0; + DYNARR_RESET( trkSeg_t, tempSegs_da ); DYNARR_RESET(trkSeg_t,Dl.newLine); Dl.curr_line = NULL; SetAllTrackSelect( FALSE ); @@ -482,7 +509,7 @@ static STATUS_T CmdJoinLine( Dl.curr_line = NULL; coOrd pos1= pos; Dl.curr_line = OnTrack( &pos1, FALSE, FALSE ); - if (!Dl.curr_line) return C_CONTINUE; + if (!Dl.curr_line) { return C_CONTINUE; } if (IsTrack(Dl.curr_line)) { Dl.curr_line = NULL; return C_CONTINUE; @@ -496,8 +523,8 @@ static STATUS_T CmdJoinLine( return C_CONTINUE; } if ( (Dl.line_state != NO_LINE) && - (Dl.inp[0].line == Dl.curr_line) && - (IsClose(FindDistance(Dl.inp[0].pos,Dl.params.lineOrig)) ) ) { + (Dl.inp[0].line == Dl.curr_line) && + (IsClose(FindDistance(Dl.inp[0].pos,Dl.params.lineOrig)) ) ) { Dl.curr_line = NULL; } else { AddAnchorEnd(Dl.params.lineOrig); @@ -512,8 +539,8 @@ static STATUS_T CmdJoinLine( InfoMessage( _("Not a line - Try again") ); return C_CONTINUE; } - if (!QueryTrack(Dl.curr_line,Q_GET_NODES)) return C_CONTINUE; - if (!GetTrackParams(PARAMS_NODES,Dl.curr_line,pos,&Dl.params)) return C_CONTINUE; + if (!QueryTrack(Dl.curr_line,Q_GET_NODES)) { return C_CONTINUE; } + if (!GetTrackParams(PARAMS_NODES,Dl.curr_line,pos,&Dl.params)) { return C_CONTINUE; } Dl.line_state = HAVE_LINE; Dl.inp[0].line = Dl.curr_line; Dl.inp[0].pos = Dl.params.lineOrig; @@ -522,20 +549,23 @@ static STATUS_T CmdJoinLine( DYNARR_LAST(trkSeg_t,Dl.newLine).type = SEG_POLY; DYNARR_LAST(trkSeg_t,Dl.newLine).color = wDrawColorBlack; - DYNARR_LAST(trkSeg_t,Dl.newLine).width = 0; + DYNARR_LAST(trkSeg_t,Dl.newLine).lineWidth = 0; DYNARR_LAST(trkSeg_t,Dl.newLine).u.p.polyType = POLYLINE; - DYNARR_LAST(trkSeg_t,Dl.newLine).u.p.pts = MyMalloc(sizeof(pts_t)*Dl.params.nodes.cnt); + DYNARR_LAST(trkSeg_t,Dl.newLine).u.p.pts = MyMalloc(sizeof( + pts_t)*Dl.params.nodes.cnt); DYNARR_LAST(trkSeg_t,Dl.newLine).u.p.cnt = Dl.params.nodes.cnt; if (Dl.params.ep) { //Copy in reverse as we want this point to be last - for (int i=Dl.params.nodes.cnt-1,j=0;i>=0;i--,j++) { - DYNARR_LAST(trkSeg_t,Dl.newLine).u.p.pts[j].pt = DYNARR_N(coOrd,Dl.params.nodes,i); + for (int i=Dl.params.nodes.cnt-1,j=0; i>=0; i--,j++) { + DYNARR_LAST(trkSeg_t,Dl.newLine).u.p.pts[j].pt = DYNARR_N(coOrd,Dl.params.nodes, + i); DYNARR_LAST(trkSeg_t,Dl.newLine).u.p.pts[j].pt_type = wPolyLineStraight; } } else { //Copy forwards to end up with this point last - for (int i=0; i<Dl.params.nodes.cnt;i++) { - DYNARR_LAST(trkSeg_t,Dl.newLine).u.p.pts[i].pt = DYNARR_N(coOrd,Dl.params.nodes,i); + for (int i=0; i<Dl.params.nodes.cnt; i++) { + DYNARR_LAST(trkSeg_t,Dl.newLine).u.p.pts[i].pt = DYNARR_N(coOrd,Dl.params.nodes, + i); DYNARR_LAST(trkSeg_t,Dl.newLine).u.p.pts[i].pt_type = wPolyLineStraight; } } @@ -546,11 +576,11 @@ static STATUS_T CmdJoinLine( InfoMessage( _("Not a line - Try again") ); return C_CONTINUE; } - if (!QueryTrack(Dl.curr_line,Q_GET_NODES)) return C_CONTINUE; - if (!GetTrackParams(PARAMS_NODES,Dl.curr_line,pos,&Dl.params)) return C_CONTINUE; + if (!QueryTrack(Dl.curr_line,Q_GET_NODES)) { return C_CONTINUE; } + if (!GetTrackParams(PARAMS_NODES,Dl.curr_line,pos,&Dl.params)) { return C_CONTINUE; } if (Dl.curr_line == Dl.inp[0].line) { if ((Dl.params.lineOrig.x == Dl.inp[0].pos.x) && - (Dl.params.lineOrig.y == Dl.inp[0].pos.y)) { + (Dl.params.lineOrig.y == Dl.inp[0].pos.y)) { InfoMessage( _("Same draw object and same endpoint - Try again") ); return C_CONTINUE; } @@ -562,23 +592,29 @@ static STATUS_T CmdJoinLine( int old_cnt = DYNARR_LAST(trkSeg_t,Dl.newLine).u.p.cnt; BOOL_T join_near = FALSE; if (Dl.inp[1].line == Dl.inp[0].line) { - DYNARR_LAST(trkSeg_t,Dl.newLine).u.p.pts = MyRealloc(DYNARR_LAST(trkSeg_t,Dl.newLine).u.p.pts,sizeof(pts_t)*(old_cnt+1)); - DYNARR_LAST(trkSeg_t,Dl.newLine).u.p.pts[old_cnt] = DYNARR_LAST(trkSeg_t,Dl.newLine).u.p.pts[0]; // Joined up Polygon + DYNARR_LAST(trkSeg_t,Dl.newLine).u.p.pts = MyRealloc(DYNARR_LAST(trkSeg_t, + Dl.newLine).u.p.pts,sizeof(pts_t)*(old_cnt+1)); + DYNARR_LAST(trkSeg_t,Dl.newLine).u.p.pts[old_cnt] = DYNARR_LAST(trkSeg_t, + Dl.newLine).u.p.pts[0]; // Joined up Polygon DYNARR_LAST(trkSeg_t,Dl.newLine).u.p.cnt += 1; } else { - if (IsClose(FindDistance(Dl.inp[0].pos,Dl.inp[1].pos))) + if (IsClose(FindDistance(Dl.inp[0].pos,Dl.inp[1].pos))) { join_near = TRUE; - DYNARR_LAST(trkSeg_t,Dl.newLine).u.p.pts = MyRealloc(DYNARR_LAST(trkSeg_t,Dl.newLine).u.p.pts,sizeof(pts_t)*(old_cnt+Dl.params.nodes.cnt-join_near)); + } + DYNARR_LAST(trkSeg_t,Dl.newLine).u.p.pts = MyRealloc(DYNARR_LAST(trkSeg_t, + Dl.newLine).u.p.pts,sizeof(pts_t)*(old_cnt+Dl.params.nodes.cnt-join_near)); if (Dl.params.ep) { //Copy forwards as this point is first - for (int i=join_near,j=old_cnt;i<Dl.params.nodes.cnt;i++,j++) { - DYNARR_LAST(trkSeg_t,Dl.newLine).u.p.pts[j].pt = DYNARR_N(coOrd,Dl.params.nodes,i); + for (int i=join_near,j=old_cnt; i<Dl.params.nodes.cnt; i++,j++) { + DYNARR_LAST(trkSeg_t,Dl.newLine).u.p.pts[j].pt = DYNARR_N(coOrd,Dl.params.nodes, + i); DYNARR_LAST(trkSeg_t,Dl.newLine).u.p.pts[j].pt_type = wPolyLineStraight; } } else { //Copy backwards as this point is last - for (int i=Dl.params.nodes.cnt-join_near-1,j=old_cnt;i>=0;i--,j++) { - DYNARR_LAST(trkSeg_t,Dl.newLine).u.p.pts[j].pt = DYNARR_N(coOrd,Dl.params.nodes,i); + for (int i=Dl.params.nodes.cnt-join_near-1,j=old_cnt; i>=0; i--,j++) { + DYNARR_LAST(trkSeg_t,Dl.newLine).u.p.pts[j].pt = DYNARR_N(coOrd,Dl.params.nodes, + i); DYNARR_LAST(trkSeg_t,Dl.newLine).u.p.pts[j].pt_type = wPolyLineStraight; } } @@ -591,13 +627,14 @@ static STATUS_T CmdJoinLine( case C_MOVE: break; case C_UP: - if (Dl.line_state != HAVE_SECOND_LINE) return C_CONTINUE; + if (Dl.line_state != HAVE_SECOND_LINE) { return C_CONTINUE; } Dl.line_state = NO_LINE; UndoStart(_("Create PolyLine"), "newPolyLine"); track_p newTrack = MakePolyLineFromSegs( zero, 0.0, &Dl.newLine ); DeleteTrack(Dl.inp[0].line,FALSE); - if (Dl.inp[0].line != Dl.inp[1].line) + if (Dl.inp[0].line != Dl.inp[1].line) { DeleteTrack(Dl.inp[1].line,FALSE); + } UndoEnd(); DrawNewTrack(newTrack); CleanSegs(&Dl.newLine); @@ -610,10 +647,15 @@ static STATUS_T CmdJoinLine( Dl.curr_line = NULL; break; case C_REDRAW: - if (Dl.line_state != NO_LINE) DrawSegs(&tempD,zero,0.0,((trkSeg_t*)Dl.newLine.ptr), Dl.newLine.cnt, trackGauge, wDrawColorPreviewSelected); - if (Dl.curr_line) DrawTrack(Dl.curr_line,&tempD,wDrawColorPreviewSelected); - if (Dl.anchors_da.cnt>0) - DrawSegs( &tempD, zero, 0.0, &anchors(0), Dl.anchors_da.cnt, trackGauge, wDrawColorPreviewSelected ); + if (Dl.line_state != NO_LINE) { + DrawSegsDA(&tempD,NULL,zero,0.0,&Dl.newLine, trackGauge, + wDrawColorPreviewSelected,0); + } + if (Dl.curr_line) { + DrawTrack(Dl.curr_line,&tempD,wDrawColorPreviewSelected); + } + DrawSegsDA( &tempD, NULL, zero, 0.0, &Dl.anchors_da, trackGauge, + wDrawColorPreviewSelected, 0 ); break; case C_TEXT: case C_OK: @@ -626,34 +668,37 @@ static STATUS_T CmdJoinLine( } -void AnchorTempLine(coOrd p0, coOrd p1) { +void AnchorTempLine(coOrd p0, coOrd p1) +{ DYNARR_APPEND(trkSeg_t,Dj.anchors,1); trkSeg_p p = &DYNARR_LAST(trkSeg_t,Dj.anchors); p->type = SEG_STRLIN; p->color = wDrawColorBlue; - p->width = 0.0; + p->lineWidth = 0.0; p->u.l.pos[0] = p0; p->u.l.pos[1] = p1; } -void AnchorTempCircle(coOrd center,DIST_T radius, ANGLE_T a0, ANGLE_T a1) { +void AnchorTempCircle(coOrd center,DIST_T radius, ANGLE_T a0, ANGLE_T a1) +{ DYNARR_APPEND(trkSeg_t,Dj.anchors,1); trkSeg_p p = &DYNARR_LAST(trkSeg_t,Dj.anchors); p->type = SEG_CRVLIN; p->color = wDrawColorBlue; - p->width = 0.0; + p->lineWidth = 0.0; p->u.c.a0 =a0; p->u.c.a1 = a1; p->u.c.radius = radius; p->u.c.center = center; } -void AnchorPoint(coOrd center) { +void AnchorPoint(coOrd center) +{ DYNARR_APPEND(trkSeg_t,Dj.anchors,1); trkSeg_p p = &DYNARR_LAST(trkSeg_t,Dj.anchors); p->type = SEG_CRVLIN; p->color = wDrawColorAqua; - p->width = 0.0; + p->lineWidth = 0.0; p->u.c.a0 =0.0; p->u.c.a1 = 360.0; p->u.c.radius = mainD.scale/4; @@ -672,100 +717,126 @@ static paramGroup_t joinPG = { "joinfixed", 0, joinPLs, COUNT( joinPLs ) }; -BOOL_T AdjustPosToRadius(coOrd *pos, DIST_T desired_radius, ANGLE_T an0, ANGLE_T an1) { +BOOL_T AdjustPosToRadius(coOrd *pos, DIST_T desired_radius, ANGLE_T an0, + ANGLE_T an1) +{ coOrd point1,point2; switch ( Dj.inp[1].params.type ) { - case curveTypeCurve: - if (Dj.inp[0].params.type == curveTypeStraight) { - coOrd newP, newP1; - //Offset curve by desired_radius - DIST_T newR1; - newR1 = Dj.inp[1].params.arcR + desired_radius*((fabs(an1-Dj.inp[1].params.arcA0)<1.0)?1:-1); - if (newR1<=0.0) { - if (debug) InfoMessage("Zero Radius C1"); - return FALSE; - } - //Offset line by desired_radius - Translate(&newP,Dj.inp[0].params.lineEnd,an0,desired_radius); - Translate(&newP1,Dj.inp[0].params.lineOrig,an0,desired_radius); - if (debug) - AnchorTempLine(newP,newP1); - //Intersect - this is the joining curve center - if (debug) - AnchorTempCircle(Dj.inp[1].params.arcP,newR1,Dj.inp[1].params.arcA0,Dj.inp[1].params.arcA1); - if (!FindArcAndLineIntersections(&point1,&point2,Dj.inp[1].params.arcP,newR1,newP,newP1)) - return FALSE; - } else if (Dj.inp[0].params.type == curveTypeCurve) { - //Offset curve by desired_radius - DIST_T newR0; - newR0 = Dj.inp[0].params.arcR + desired_radius*((fabs(an0-Dj.inp[0].params.arcA0)<1.0)?1:-1); - if (newR0<=0.0) { - if (debug) InfoMessage("Zero Radius C0"); - return FALSE; - } - //Offset curve by desired_radius - if (debug) - AnchorTempCircle(Dj.inp[0].params.arcP,newR0,Dj.inp[0].params.arcA0,Dj.inp[0].params.arcA1); - DIST_T newR1; - newR1 = Dj.inp[1].params.arcR + desired_radius*((fabs(an1-Dj.inp[1].params.arcA0)<1.0)?1:-1); - if (newR1<=0.0) { - if (debug) InfoMessage("Zero Radius C1"); - return FALSE; - } - //Intersect - this is the joining curve center - if (debug) - AnchorTempCircle(Dj.inp[1].params.arcP,newR1,Dj.inp[1].params.arcA0,Dj.inp[1].params.arcA1); - if (!FindArcIntersections(&point1,&point2,Dj.inp[0].params.arcP,newR0,Dj.inp[1].params.arcP,newR1)) - return FALSE; + case curveTypeCurve: + if (Dj.inp[0].params.type == curveTypeStraight) { + coOrd newP, newP1; + //Offset curve by desired_radius + DIST_T newR1; + newR1 = Dj.inp[1].params.arcR + desired_radius*((fabs(an1 + -Dj.inp[1].params.arcA0)<1.0)?1:-1); + if (newR1<=0.0) { + if (debug) { InfoMessage("Zero Radius C1"); } + return FALSE; } + //Offset line by desired_radius + Translate(&newP,Dj.inp[0].params.lineEnd,an0,desired_radius); + Translate(&newP1,Dj.inp[0].params.lineOrig,an0,desired_radius); if (debug) { - AnchorPoint(point1); - AnchorPoint(point2); + AnchorTempLine(newP,newP1); } - break; - case curveTypeStraight: - if (Dj.inp[0].params.type == curveTypeStraight) { - coOrd newI,newP0,newP01, newP1, newP11; - //Offset line1 by desired_radius - Translate(&newP0,Dj.inp[0].params.lineEnd,an0,desired_radius); - Translate(&newP01,Dj.inp[0].params.lineOrig,an0,desired_radius); - if (debug) - AnchorTempLine(newP0,newP01); - //Offset line2 by desired_radius - Translate(&newP1,Dj.inp[1].params.lineEnd,an1,desired_radius); - Translate(&newP11,Dj.inp[1].params.lineOrig,an1,desired_radius); - if (debug) - AnchorTempLine(newP1,newP11); - if (!FindIntersection(&newI,newP0,Dj.inp[0].params.angle,newP1,Dj.inp[1].params.angle)) - return FALSE; - point1 = point2 = newI; - } else if (Dj.inp[0].params.type == curveTypeCurve) { - coOrd newP, newP1; - //Offset curve by desired_radius - DIST_T newR0; - newR0 = Dj.inp[0].params.arcR + desired_radius*((fabs(an0-Dj.inp[0].params.arcA0)<1.0)?1:-1); - if (newR0<=0.0) { - if (debug) InfoMessage("Zero Radius C0"); - return FALSE; - } - if (debug) - AnchorTempCircle(Dj.inp[0].params.arcP,newR0,Dj.inp[0].params.arcA0,Dj.inp[0].params.arcA1); - //Offset line by desired_radius - Translate(&newP,Dj.inp[1].params.lineEnd,an1,desired_radius); - Translate(&newP1,Dj.inp[1].params.lineOrig,an1,desired_radius); - if (debug) - AnchorTempLine(newP,newP1); - //Intersect - this is the joining curve center - if (!FindArcAndLineIntersections(&point1,&point2,Dj.inp[0].params.arcP,newR0,newP,newP1)) - return FALSE; + //Intersect - this is the joining curve center + if (debug) { + AnchorTempCircle(Dj.inp[1].params.arcP,newR1,Dj.inp[1].params.arcA0, + Dj.inp[1].params.arcA1); } + if (!FindArcAndLineIntersections(&point1,&point2,Dj.inp[1].params.arcP,newR1, + newP,newP1)) { + return FALSE; + } + } else if (Dj.inp[0].params.type == curveTypeCurve) { + //Offset curve by desired_radius + DIST_T newR0; + newR0 = Dj.inp[0].params.arcR + desired_radius*((fabs(an0 + -Dj.inp[0].params.arcA0)<1.0)?1:-1); + if (newR0<=0.0) { + if (debug) { InfoMessage("Zero Radius C0"); } + return FALSE; + } + //Offset curve by desired_radius if (debug) { - AnchorPoint(point1); - AnchorPoint(point2); + AnchorTempCircle(Dj.inp[0].params.arcP,newR0,Dj.inp[0].params.arcA0, + Dj.inp[0].params.arcA1); } - break; - default: - return FALSE; + DIST_T newR1; + newR1 = Dj.inp[1].params.arcR + desired_radius*((fabs(an1 + -Dj.inp[1].params.arcA0)<1.0)?1:-1); + if (newR1<=0.0) { + if (debug) { InfoMessage("Zero Radius C1"); } + return FALSE; + } + //Intersect - this is the joining curve center + if (debug) { + AnchorTempCircle(Dj.inp[1].params.arcP,newR1,Dj.inp[1].params.arcA0, + Dj.inp[1].params.arcA1); + } + if (!FindArcIntersections(&point1,&point2,Dj.inp[0].params.arcP,newR0, + Dj.inp[1].params.arcP,newR1)) { + return FALSE; + } + } + if (debug) { + AnchorPoint(point1); + AnchorPoint(point2); + } + break; + case curveTypeStraight: + if (Dj.inp[0].params.type == curveTypeStraight) { + coOrd newI,newP0,newP01, newP1, newP11; + //Offset line1 by desired_radius + Translate(&newP0,Dj.inp[0].params.lineEnd,an0,desired_radius); + Translate(&newP01,Dj.inp[0].params.lineOrig,an0,desired_radius); + if (debug) { + AnchorTempLine(newP0,newP01); + } + //Offset line2 by desired_radius + Translate(&newP1,Dj.inp[1].params.lineEnd,an1,desired_radius); + Translate(&newP11,Dj.inp[1].params.lineOrig,an1,desired_radius); + if (debug) { + AnchorTempLine(newP1,newP11); + } + if (!FindIntersection(&newI,newP0,Dj.inp[0].params.angle,newP1, + Dj.inp[1].params.angle)) { + return FALSE; + } + point1 = point2 = newI; + } else if (Dj.inp[0].params.type == curveTypeCurve) { + coOrd newP, newP1; + //Offset curve by desired_radius + DIST_T newR0; + newR0 = Dj.inp[0].params.arcR + desired_radius*((fabs(an0 + -Dj.inp[0].params.arcA0)<1.0)?1:-1); + if (newR0<=0.0) { + if (debug) { InfoMessage("Zero Radius C0"); } + return FALSE; + } + if (debug) { + AnchorTempCircle(Dj.inp[0].params.arcP,newR0,Dj.inp[0].params.arcA0, + Dj.inp[0].params.arcA1); + } + //Offset line by desired_radius + Translate(&newP,Dj.inp[1].params.lineEnd,an1,desired_radius); + Translate(&newP1,Dj.inp[1].params.lineOrig,an1,desired_radius); + if (debug) { + AnchorTempLine(newP,newP1); + } + //Intersect - this is the joining curve center + if (!FindArcAndLineIntersections(&point1,&point2,Dj.inp[0].params.arcP,newR0, + newP,newP1)) { + return FALSE; + } + } + if (debug) { + AnchorPoint(point1); + AnchorPoint(point2); + } + break; + default: + return FALSE; } if (FindDistance(*pos,point1)<=FindDistance(*pos,point2)) { if (Dj.inp[1].params.type == curveTypeCurve) { @@ -778,27 +849,30 @@ BOOL_T AdjustPosToRadius(coOrd *pos, DIST_T desired_radius, ANGLE_T an0, ANGLE_T if (Dj.inp[1].params.type == curveTypeCurve) { ANGLE_T a = FindAngle(Dj.inp[1].params.arcP,point2); Translate(pos,Dj.inp[1].params.arcP,a,Dj.inp[1].params.arcR); - } else + } else { Translate(pos,point2,NormalizeAngle(an1+180),desired_radius); + } } return TRUE; } -void AddAnchorJoin(coOrd pos, ANGLE_T angle) { +void AddAnchorJoin(coOrd pos, ANGLE_T angle) +{ DIST_T d = tempD.scale*0.15; DYNARR_APPEND(trkSeg_t,Dj.anchors,1); trkSeg_p a = &DYNARR_LAST(trkSeg_t,Dj.anchors); a->type = SEG_CRVLIN; - a->width = 0; + a->lineWidth = 0; a->u.c.a0 = 0.0; a->u.c.a1 = 360.0; a->u.c.center = pos; a->u.c.radius = d/2; a->color = wDrawColorBlue; DYNARR_SET(trkSeg_t,Dj.anchors,Dj.anchors.cnt+5); - DrawArrowHeads(&DYNARR_N(trkSeg_t,Dj.anchors,Dj.anchors.cnt-5),pos,angle,FALSE,wDrawColorBlue); + DrawArrowHeads(&DYNARR_N(trkSeg_t,Dj.anchors,Dj.anchors.cnt-5),pos,angle,FALSE, + wDrawColorBlue); } @@ -808,8 +882,8 @@ static coOrd anchor_pos; static ANGLE_T anchor_angle = 0.0; static STATUS_T CmdJoin( - wAction_t action, - coOrd pos ) + wAction_t action, + coOrd pos ) /* * Join 2 tracks. */ @@ -827,17 +901,20 @@ static STATUS_T CmdJoin( BOOL_T ok; wControl_p controls[2]; char * labels[1]; + trkSeg_p p; switch (action&0xFF) { case C_START: if (joinPLs[0].control==NULL) { - ParamCreateControls(&joinPG, NULL); + ParamCreateControls(&joinPG, NULL); } - if (selectedTrackCount==0) + if (selectedTrackCount==0) { InfoMessage( _("Left click - join with track") ); - else - InfoMessage( _("Left click - join with track, Shift Left click - move to join") ); + } else { + InfoMessage( + _("Left click - join with track, Shift Left click - move to join") ); + } DYNARR_RESET(trkSeg_t,Dj.anchors); Dj.state = 0; Dj.joinMoveState = 0; @@ -845,70 +922,86 @@ static STATUS_T CmdJoin( /*ParamGroupRecord( &easementPG );*/ infoSubst = FALSE; anchor_trk = NULL; - if (easementVal < 0.0) + if (easementVal < 0.0) { + commandContext = I2VP(cornuJoinTrack); return CmdCornu(action, pos); + } return C_CONTINUE; case wActionMove: anchor_trk = NULL; DYNARR_RESET(rkSeg_t,Dj.anchors); - if ((easementVal < 0) && Dj.joinMoveState == 0 ) + if ((easementVal < 0) && Dj.joinMoveState == 0 ) { + commandContext = I2VP(cornuJoinTrack); return CmdCornu(action, pos); - if ( Dj.state >= 2) return C_CONTINUE; - if ( (trk = OnTrack( &pos, FALSE, TRUE )) == NULL) + } + if ( Dj.state >= 2) { return C_CONTINUE; } + if ( (trk = OnTrack( &pos, FALSE, TRUE )) == NULL) { return C_CONTINUE; - if (!CheckTrackLayer( trk ) ) + } + if (!CheckTrackLayer( trk ) ) { return C_CONTINUE; - if ((Dj.state > 0) && (trk == Dj.inp[0].trk)) + } + if ((Dj.state > 0) && (trk == Dj.inp[0].trk)) { return C_CONTINUE; + } trackParams_t moveParams; - if (!GetTrackParams( PARAMS_1ST_JOIN, trk, pos, &moveParams )) + if (!GetTrackParams( PARAMS_1ST_JOIN, trk, pos, &moveParams )) { return C_CONTINUE; + } if (moveParams.type == curveTypeBezier || moveParams.type == curveTypeCornu) { if (!(easementVal<0)) { return C_CONTINUE; } } ep = PickUnconnectedEndPointSilent(pos,trk); - if (ep <0) return C_CONTINUE; - if (IsClose(FindDistance(GetTrkEndPos(trk,ep),pos))) + if (ep <0) { return C_CONTINUE; } + if (IsClose(FindDistance(GetTrkEndPos(trk,ep),pos))) { anchor_angle = GetTrkEndAngle(trk,ep); - else + } else { anchor_angle = FindAngle(pos,GetTrkEndPos(trk,ep)); + } anchor_trk = trk; anchor_pos = pos; AddAnchorJoin(pos,anchor_angle); break; - + case C_DOWN: - if ( !Dj.cornuMode && ((Dj.state == 0 && (MyGetKeyState() & WKEY_SHIFT) != 0) || Dj.joinMoveState != 0) ) + if ( !Dj.cornuMode && ((Dj.state == 0 && (MyGetKeyState() & WKEY_SHIFT) != 0) + || Dj.joinMoveState != 0) ) { return DoMoveToJoin( pos ); + } if (easementVal < 0.0 && Dj.joinMoveState == 0) { Dj.cornuMode = TRUE; + commandContext = I2VP(cornuJoinTrack); return CmdCornu(action, pos); } DYNARR_SET( trkSeg_t, tempSegs_da, 3 ); tempSegs(0).color = drawColorBlack; - tempSegs(0).width = 0; + tempSegs(0).lineWidth = 0; tempSegs(1).color = drawColorBlack; - tempSegs(1).width = 0; + tempSegs(1).lineWidth = 0; tempSegs(2).color = drawColorBlack; - tempSegs(2).width = 0; - tempSegs_da.cnt = 0; + tempSegs(2).lineWidth = 0; + DYNARR_RESET( trkSeg_t, tempSegs_da ); Dj.joinMoveState = 0; -/* Populate (Dj.inp[0]) and check for connecting abutting tracks */ + /* Populate (Dj.inp[0]) and check for connecting abutting tracks */ if (Dj.state == 0) { - if ( (Dj.inp[0].trk = OnTrack( &pos, TRUE, TRUE )) == NULL) + if ( (Dj.inp[0].trk = OnTrack( &pos, TRUE, TRUE )) == NULL) { return C_CONTINUE; - if (!CheckTrackLayer( Dj.inp[0].trk ) ) + } + if (!CheckTrackLayer( Dj.inp[0].trk ) ) { return C_CONTINUE; + } Dj.inp[0].pos = pos; -LOG( log_join, 1, ("JOIN: 1st track %d @[%0.3f %0.3f]\n", - GetTrkIndex(Dj.inp[0].trk), Dj.inp[0].pos.x, Dj.inp[1].pos.y ) ) - if (!GetTrackParams( PARAMS_1ST_JOIN, Dj.inp[0].trk, pos, &Dj.inp[0].params )) + LOG( log_join, 1, ("JOIN: 1st track %d @[%0.3f %0.3f]\n", + GetTrkIndex(Dj.inp[0].trk), Dj.inp[0].pos.x, Dj.inp[1].pos.y ) ) + if (!GetTrackParams( PARAMS_1ST_JOIN, Dj.inp[0].trk, pos, &Dj.inp[0].params )) { return C_CONTINUE; - if (Dj.inp[0].params.type == curveTypeBezier || Dj.inp[0].params.type == curveTypeCornu) { + } + if (Dj.inp[0].params.type == curveTypeBezier + || Dj.inp[0].params.type == curveTypeCornu) { if (!(easementVal<0 && Dj.cornuMode)) { ErrorMessage( MSG_JOIN_NOTBEZIERORCORNU); return C_CONTINUE; @@ -929,34 +1022,42 @@ LOG( log_join, 1, ("JOIN: 1st track %d @[%0.3f %0.3f]\n", ParamGroupRecord(&joinPG); return C_CONTINUE; } else { - if ( (Dj.inp[1].trk = OnTrack( &pos, FALSE, TRUE )) == NULL) + if ( (Dj.inp[1].trk = OnTrack( &pos, FALSE, TRUE )) == NULL) { return C_CONTINUE; - if (!CheckTrackLayer( Dj.inp[1].trk ) ) + } + if (!CheckTrackLayer( Dj.inp[1].trk ) ) { return C_CONTINUE; + } Dj.inp[1].pos = pos; - if (!GetTrackParams( PARAMS_2ND_JOIN, Dj.inp[1].trk, pos, &Dj.inp[1].params )) + if (!GetTrackParams( PARAMS_2ND_JOIN, Dj.inp[1].trk, pos, &Dj.inp[1].params )) { return C_CONTINUE; + } if ( Dj.inp[0].trk == Dj.inp[1].trk ) { ErrorMessage( MSG_JOIN_SAME ); return C_CONTINUE; } - if (infoSubst) + if (infoSubst) { InfoSubstituteControls(NULL, NULL); + } infoSubst = FALSE; Dj.inp[1].realType = GetTrkType(Dj.inp[1].trk); - if ( IsCurveCircle( Dj.inp[0].trk ) ) - Dj.inp[0].params.ep = PickArcEndPt( Dj.inp[0].params.arcP, Dj.inp[0].pos, pos ); - if ( IsCurveCircle( Dj.inp[1].trk ) ) - Dj.inp[1].params.ep = PickArcEndPt( Dj.inp[1].params.arcP, pos, Dj.inp[0].pos ); - -LOG( log_join, 1, (" 2nd track %d, @[%0.3f %0.3f] EP0=%d EP1=%d\n", - GetTrkIndex(Dj.inp[1].trk), Dj.inp[1].pos.x, Dj.inp[1].pos.y, - Dj.inp[0].params.ep, Dj.inp[1].params.ep ) ) -LOG( log_join, 1, ("P1=[%0.3f %0.3f]\n", pos.x, pos.y ) ) + if ( IsCurveCircle( Dj.inp[0].trk ) ) { + Dj.inp[0].params.ep = PickArcEndPt( Dj.inp[0].params.arcP, Dj.inp[0].pos, + pos ); + } + if ( IsCurveCircle( Dj.inp[1].trk ) ) { + Dj.inp[1].params.ep = PickArcEndPt( Dj.inp[1].params.arcP, pos, + Dj.inp[0].pos ); + } + + LOG( log_join, 1, (" 2nd track %d, @[%0.3f %0.3f] EP0=%d EP1=%d\n", + GetTrkIndex(Dj.inp[1].trk), Dj.inp[1].pos.x, Dj.inp[1].pos.y, + Dj.inp[0].params.ep, Dj.inp[1].params.ep ) ) + LOG( log_join, 1, ("P1=[%0.3f %0.3f]\n", pos.x, pos.y ) ) BOOL_T only_merge = FALSE; if ( (Dj.inp[0].params.ep >=0) && - (GetTrkEndTrk(Dj.inp[0].trk,Dj.inp[0].params.ep) != NULL)) { + (GetTrkEndTrk(Dj.inp[0].trk,Dj.inp[0].params.ep) != NULL)) { if (GetTrkEndTrk(Dj.inp[0].trk,Dj.inp[0].params.ep) != Dj.inp[1].trk) { only_merge = TRUE; ErrorMessage( MSG_TRK_ALREADY_CONN, _("First") ); @@ -964,14 +1065,15 @@ LOG( log_join, 1, ("P1=[%0.3f %0.3f]\n", pos.x, pos.y ) ) } } if ( (Dj.inp[1].params.ep >= 0) && - (GetTrkEndTrk(Dj.inp[1].trk,Dj.inp[1].params.ep) != NULL)) { + (GetTrkEndTrk(Dj.inp[1].trk,Dj.inp[1].params.ep) != NULL)) { if (GetTrkEndTrk(Dj.inp[1].trk,Dj.inp[1].params.ep) != Dj.inp[0].trk) { only_merge = TRUE; ErrorMessage( MSG_TRK_ALREADY_CONN, _("Second") ); return C_CONTINUE; } } - if (Dj.inp[1].params.type == curveTypeBezier || Dj.inp[1].params.type == curveTypeCornu) { + if (Dj.inp[1].params.type == curveTypeBezier + || Dj.inp[1].params.type == curveTypeCornu) { if (!(easementVal<0 && Dj.cornuMode)) { ErrorMessage( MSG_JOIN_NOTBEZIERORCORNU); return C_CONTINUE; @@ -979,25 +1081,27 @@ LOG( log_join, 1, ("P1=[%0.3f %0.3f]\n", pos.x, pos.y ) ) } rc = C_CONTINUE; if ( MergeTracks( Dj.inp[0].trk, Dj.inp[0].params.ep, - Dj.inp[1].trk, Dj.inp[1].params.ep ) ) { + Dj.inp[1].trk, Dj.inp[1].params.ep ) ) { rc = C_TERMINATE; } else if (only_merge) { rc = C_TERMINATE; } else if ( Dj.inp[0].params.ep >= 0 && Dj.inp[1].params.ep >= 0 ) { if ( Dj.inp[0].params.type == curveTypeStraight && - Dj.inp[1].params.type == curveTypeStraight && - ExtendStraightToJoin( Dj.inp[0].trk, Dj.inp[0].params.ep, - Dj.inp[1].trk, Dj.inp[1].params.ep ) ) + Dj.inp[1].params.type == curveTypeStraight && + ExtendStraightToJoin( Dj.inp[0].trk, Dj.inp[0].params.ep, + Dj.inp[1].trk, Dj.inp[1].params.ep ) ) { rc = C_TERMINATE; + } if ( ConnectAbuttingTracks( Dj.inp[0].trk, Dj.inp[0].params.ep, - Dj.inp[1].trk, Dj.inp[1].params.ep ) ) + Dj.inp[1].trk, Dj.inp[1].params.ep ) ) { rc = C_TERMINATE; + } } if ( rc == C_TERMINATE ) { return rc; } if ( QueryTrack( Dj.inp[0].trk, Q_CANNOT_BE_ON_END ) || - QueryTrack( Dj.inp[1].trk, Q_CANNOT_BE_ON_END ) ) { + QueryTrack( Dj.inp[1].trk, Q_CANNOT_BE_ON_END ) ) { ErrorMessage( MSG_JOIN_EASEMENTS ); return C_CONTINUE; } @@ -1005,23 +1109,27 @@ LOG( log_join, 1, ("P1=[%0.3f %0.3f]\n", pos.x, pos.y ) ) Dj.state = 2; Dj.jRes.flip = FALSE; } - tempSegs_da.cnt = 0; /* no break */ - + case C_MOVE: - if (easementVal < 0 && Dj.cornuMode) + DYNARR_RESET( trkSeg_t, tempSegs_da ); + if (easementVal < 0 && Dj.cornuMode) { + commandContext = I2VP(cornuJoinTrack); return CmdCornu(action, pos); + } -LOG( log_join, 3, ("P1=[%0.3f %0.3f]\n", pos.x, pos.y ) ) - if (Dj.state != 2) + LOG( log_join, 3, ("P1=[%0.3f %0.3f]\n", pos.x, pos.y ) ) + if (Dj.state != 2) { return C_CONTINUE; + } DYNARR_RESET(trkSeg_t,Dj.anchors); //Fix Pos onto the line of the second track if (Dj.inp[1].params.type == curveTypeStraight) { - ANGLE_T a = NormalizeAngle(FindAngle(Dj.inp[1].params.lineOrig,pos)-Dj.inp[1].params.angle); + ANGLE_T a = NormalizeAngle(FindAngle(Dj.inp[1].params.lineOrig, + pos)-Dj.inp[1].params.angle); DIST_T d = FindDistance(Dj.inp[1].params.lineOrig,pos); Translate(&pos,Dj.inp[1].params.lineOrig,Dj.inp[1].params.angle,d*cos(D2R(a))); } else { @@ -1030,33 +1138,39 @@ LOG( log_join, 3, ("P1=[%0.3f %0.3f]\n", pos.x, pos.y ) ) } if ((desired_radius != 0.0) && - ((Dj.inp[0].params.type == curveTypeStraight) || (Dj.inp[0].params.type == curveTypeCurve)) && - ((Dj.inp[1].params.type == curveTypeStraight) || (Dj.inp[1].params.type == curveTypeCurve)) && - Dj.jRes.type==curveTypeCurve - ) { + ((Dj.inp[0].params.type == curveTypeStraight) + || (Dj.inp[0].params.type == curveTypeCurve)) && + ((Dj.inp[1].params.type == curveTypeStraight) + || (Dj.inp[1].params.type == curveTypeCurve)) && + Dj.jRes.type==curveTypeCurve + ) { ANGLE_T na0=0.0,na1=0.0; - coOrd end0, end1; +// coOrd end0, end1; ANGLE_T a0,a1; - end0 = GetTrkEndPos(Dj.inp[0].trk,Dj.inp[0].params.ep); - end1 = GetTrkEndPos(Dj.inp[1].trk,Dj.inp[1].params.ep); +// end0 = GetTrkEndPos(Dj.inp[0].trk,Dj.inp[0].params.ep); +// end1 = GetTrkEndPos(Dj.inp[1].trk,Dj.inp[1].params.ep); if (Dj.inp[0].params.type == curveTypeStraight) { - a0 = DifferenceBetweenAngles(Dj.inp[0].params.angle,FindAngle(Dj.jRes.pos[0], pos)); + a0 = DifferenceBetweenAngles(Dj.inp[0].params.angle,FindAngle(Dj.jRes.pos[0], + pos)); na0 = NormalizeAngle( Dj.inp[0].params.angle + - ((a0>0.0)?90.0:-90.0)); + ((a0>0.0)?90.0:-90.0)); } else { na0 = Dj.inp[0].params.arcA0; - if (FindDistance(Dj.inp[0].params.arcP,pos)<Dj.inp[0].params.arcR) + if (FindDistance(Dj.inp[0].params.arcP,pos)<Dj.inp[0].params.arcR) { na0 = NormalizeAngle(na0+180.0); + } } //Now Second Line offset if (Dj.inp[1].params.type == curveTypeStraight) { - a1 = DifferenceBetweenAngles(Dj.inp[1].params.angle,FindAngle(pos, Dj.jRes.pos[0])); + a1 = DifferenceBetweenAngles(Dj.inp[1].params.angle,FindAngle(pos, + Dj.jRes.pos[0])); na1 = NormalizeAngle( Dj.inp[1].params.angle + - ((a1>0.0)?90.0:-90.0)); + ((a1>0.0)?90.0:-90.0)); } else { na1 = Dj.inp[1].params.arcA0; - if (FindDistance(Dj.inp[1].params.arcP,Dj.jRes.pos[0])<Dj.inp[1].params.arcR) + if (FindDistance(Dj.inp[1].params.arcP,Dj.jRes.pos[0])<Dj.inp[1].params.arcR) { na1 = NormalizeAngle(na1+180.0); + } } coOrd pos1 = pos; if (AdjustPosToRadius(&pos1,desired_radius+(Dj.jointD[0].x), na0, na1)) { @@ -1064,10 +1178,11 @@ LOG( log_join, 3, ("P1=[%0.3f %0.3f]\n", pos.x, pos.y ) ) beyond = 1.0; if (Dj.inp[1].params.type == curveTypeStraight) { FindPos( &off, &beyond, pos1, Dj.inp[1].params.lineOrig, Dj.inp[1].params.angle, - FindDistance(Dj.inp[1].params.lineOrig,Dj.inp[1].params.lineEnd) ); + FindDistance(Dj.inp[1].params.lineOrig,Dj.inp[1].params.lineEnd) ); } else if (Dj.inp[1].params.type == curveTypeCurve) { ANGLE_T a = FindAngle(Dj.inp[1].params.arcP,pos1); - if ((a>Dj.inp[1].params.arcA0+Dj.inp[1].params.arcA1) || (a< Dj.inp[1].params.arcA0)) { + if ((a>Dj.inp[1].params.arcA0+Dj.inp[1].params.arcA1) + || (a< Dj.inp[1].params.arcA0)) { beyond = 1.0; } } @@ -1075,9 +1190,9 @@ LOG( log_join, 3, ("P1=[%0.3f %0.3f]\n", pos.x, pos.y ) ) if (beyond>-0.01 && IsClose(FindDistance(pos,pos1))) { pos = pos1; DYNARR_APPEND(trkSeg_t,Dj.anchors,1); - trkSeg_p p = &DYNARR_LAST(trkSeg_t,Dj.anchors); + p = &DYNARR_LAST(trkSeg_t,Dj.anchors); p->type= SEG_CRVLIN; - p->width = 0; + p->lineWidth = 0; p->color = wDrawColorBlue; p->u.c.center = pos; p->u.c.a1= 360.0; @@ -1088,16 +1203,15 @@ LOG( log_join, 3, ("P1=[%0.3f %0.3f]\n", pos.x, pos.y ) ) } - - tempSegs_da.cnt = 0; - tempSegs(0).color = drawColorBlack; ok = FALSE; -/* Populate (Dj.inp[1]) */ + /* Populate (Dj.inp[1]) */ if ( QueryTrack(Dj.inp[1].trk,Q_REFRESH_JOIN_PARAMS_ON_MOVE) ) { - if ( !GetTrackParams( PARAMS_2ND_JOIN, Dj.inp[1].trk, pos, &Dj.inp[1].params ) ) + if ( !GetTrackParams( PARAMS_2ND_JOIN, Dj.inp[1].trk, pos, + &Dj.inp[1].params ) ) { return C_CONTINUE; + } } @@ -1106,19 +1220,20 @@ LOG( log_join, 3, ("P1=[%0.3f %0.3f]\n", pos.x, pos.y ) ) case curveTypeCurve: normalAngle = FindAngle( Dj.inp[1].params.arcP, pos ); Dj.inp[1].params.angle = NormalizeAngle( normalAngle + - ((Dj.inp[1].params.ep==0)?-90.0:90.0)); + ((Dj.inp[1].params.ep==0)?-90.0:90.0)); PointOnCircle( &Dj.inp[1].pos, Dj.inp[1].params.arcP, - Dj.inp[1].params.arcR, normalAngle ); - if (Dj.inp[0].params.ep == Dj.inp[1].params.ep) + Dj.inp[1].params.arcR, normalAngle ); + if (Dj.inp[0].params.ep == Dj.inp[1].params.ep) { normalAngle = NormalizeAngle( normalAngle + 180.0 ); + } break; case curveTypeStraight: FindPos( &off, &beyond, pos, Dj.inp[1].params.lineOrig, Dj.inp[1].params.angle, - DIST_INF ); + DIST_INF ); Translate( &Dj.inp[1].pos, Dj.inp[1].params.lineOrig, Dj.inp[1].params.angle, - off.x ); + off.x ); normalAngle = NormalizeAngle( Dj.inp[1].params.angle + - ((Dj.inp[0].params.ep==0)?-90.0:90.0) ); + ((Dj.inp[0].params.ep==0)?-90.0:90.0) ); break; case curveTypeNone: case curveTypeBezier: @@ -1126,23 +1241,27 @@ LOG( log_join, 3, ("P1=[%0.3f %0.3f]\n", pos.x, pos.y ) ) break; } -/* Compute the radius of the 2 tracks, for ComputeE() */ - for (inx=0;inx<2;inx++) + /* Compute the radius of the 2 tracks, for ComputeE() */ + for (inx=0; inx<2; inx++) if (Dj.inp[inx].params.type == curveTypeCurve) { eR[inx] = Dj.inp[inx].params.arcR; - if (Dj.inp[inx].params.ep == inx) + if (Dj.inp[inx].params.ep == inx) { eR[inx] = - eR[inx]; - } else + } + } else { eR[inx] = 0.0; + } - if (!AdjustJoint( FALSE, 0.0, eR, normalAngle )) + if (!AdjustJoint( FALSE, 0.0, eR, normalAngle )) { goto errorReturn; - /*return C_CONTINUE;*/ + } + /*return C_CONTINUE;*/ if (beyond < -0.000001) { #ifdef VERBOSE -printf("pos=[%0.3f,%0.3f] lineOrig=[%0.3f,%0.3f], angle=%0.3f = off=[%0.3f,%0.3f], beyond=%0.3f\n", -pos.x, pos.y, Dj.inp[1].params.lineOrig.x, Dj.inp[1].params.lineOrig.y, Dj.inp[1].params.angle, off.x, off.y, beyond ); + printf("pos=[%0.3f,%0.3f] lineOrig=[%0.3f,%0.3f], angle=%0.3f = off=[%0.3f,%0.3f], beyond=%0.3f\n", + pos.x, pos.y, Dj.inp[1].params.lineOrig.x, Dj.inp[1].params.lineOrig.y, + Dj.inp[1].params.angle, off.x, off.y, beyond ); #endif InfoMessage( _("Beyond end of 2nd track") ); goto errorReturn; @@ -1150,34 +1269,35 @@ pos.x, pos.y, Dj.inp[1].params.lineOrig.x, Dj.inp[1].params.lineOrig.y, Dj.inp[1 Dj.inp_pos[0] = Dj.jRes.pos[0]; Dj.inp_pos[1] = Dj.jRes.pos[1]; -LOG( log_join, 3, (" -E POS0=[%0.3f %0.3f] POS1=[%0.3f %0.3f]\n", - Dj.jRes.pos[0].x, Dj.jRes.pos[0].y, - Dj.jRes.pos[1].x, Dj.jRes.pos[1].y ) ) + LOG( log_join, 3, (" -E POS0=[%0.3f %0.3f] POS1=[%0.3f %0.3f]\n", + Dj.jRes.pos[0].x, Dj.jRes.pos[0].y, + Dj.jRes.pos[1].x, Dj.jRes.pos[1].y ) ) if ( Dj.jointD[0].x!=0.0 || Dj.jointD[1].x!=0.0 ) { -/* Compute the transition-curve, hopefully twice is enough */ + /* Compute the transition-curve, hopefully twice is enough */ a1 = Dj.inp[1].params.angle + (Dj.jointD[1].negate?-90.0:+90.0); if ((!AdjustJoint( TRUE, a1, eR, normalAngle )) || - (!AdjustJoint( TRUE, a1, eR, normalAngle )) ) + (!AdjustJoint( TRUE, a1, eR, normalAngle )) ) { goto errorReturn; - /*return C_CONTINUE;*/ + } + /*return C_CONTINUE;*/ if (logTable(log_join).level >= 3) { Translate( &p1, Dj.jRes.pos[1], a1+180.0, Dj.jointD[1].x ); LogPrintf(" X0=%0.3f, P1=[%0.3f %0.3f]\n", - FindDistance( Dj.inp_pos[0], Dj.jRes.pos[0] ), p1.x, p1.y ); + FindDistance( Dj.inp_pos[0], Dj.jRes.pos[0] ), p1.x, p1.y ); LogPrintf(" E+ POS0=[%0.3f %0.3f]..[%0.3f %0.3f] POS1=[%0.3f %0.3f]..[%0.3f %0.3f]\n", - Dj.inp_pos[0].x, Dj.inp_pos[0].y, - Dj.jRes.pos[0].x, Dj.jRes.pos[0].y, - p1.x, p1.y, Dj.jRes.pos[1].x, Dj.jRes.pos[1].y ); + Dj.inp_pos[0].x, Dj.inp_pos[0].y, + Dj.jRes.pos[0].x, Dj.jRes.pos[0].y, + p1.x, p1.y, Dj.jRes.pos[1].x, Dj.jRes.pos[1].y ); } } switch ( Dj.inp[0].params.type ) { case curveTypeStraight: FindPos( &off, &beyond, Dj.inp_pos[0], Dj.inp[0].params.lineOrig, - Dj.inp[0].params.angle, DIST_INF ); + Dj.inp[0].params.angle, DIST_INF ); if (beyond < 0.0) { InfoMessage(_("Beyond end of 1st track")); goto errorReturn; @@ -1191,10 +1311,11 @@ LOG( log_join, 3, (" -E POS0=[%0.3f %0.3f] POS1=[%0.3f %0.3f]\n", d = DIST_INF; } else { a = FindAngle( Dj.inp[0].params.arcP, Dj.inp_pos[0] ); - if (Dj.inp[0].params.ep == 0) + if (Dj.inp[0].params.ep == 0) { a1 = NormalizeAngle( Dj.inp[0].params.arcA0+Dj.inp[0].params.arcA1-a ); - else + } else { a1 = NormalizeAngle( a-Dj.inp[0].params.arcA0 ); + } d = Dj.inp[0].params.arcR * a1 * 2.0*M_PI/360.0; } break; @@ -1204,7 +1325,8 @@ LOG( log_join, 3, (" -E POS0=[%0.3f %0.3f] POS1=[%0.3f %0.3f]\n", InfoMessage( _("First Track Type not supported for non-Cornu Join") ); goto errorReturn; default: - AbortProg( "cmdJoin - unknown type[0]" ); + CHECKMSG( FALSE, ( "cmdJoin - unknown type[0] %d", + (int)(Dj.inp[0].params.type) ) ); } d -= Dj.jointD[0].d0; if ( d <= minLength ) { @@ -1223,10 +1345,11 @@ LOG( log_join, 3, (" -E POS0=[%0.3f %0.3f] POS1=[%0.3f %0.3f]\n", d = DIST_INF; } else { a = FindAngle( Dj.inp[1].params.arcP, Dj.inp_pos[1] ); - if (Dj.inp[1].params.ep == 0) + if (Dj.inp[1].params.ep == 0) { a1 = NormalizeAngle( Dj.inp[1].params.arcA0+Dj.inp[1].params.arcA1-a ); - else + } else { a1 = NormalizeAngle( a-Dj.inp[1].params.arcA0 ); + } d = Dj.inp[1].params.arcR * a1 * 2.0*M_PI/360.0; } break; @@ -1236,7 +1359,7 @@ LOG( log_join, 3, (" -E POS0=[%0.3f %0.3f] POS1=[%0.3f %0.3f]\n", InfoMessage( _("Second Track Type not supported for non-Cornu Join") ); goto errorReturn; default: - AbortProg( "cmdJoin - unknown type[1]" ); + CHECKMSG( FALSE, ( "cmdJoin - unknown type[1]", Dj.inp[1].params.type ) ); } d -= Dj.jointD[1].d0; if ( d <= minLength ) { @@ -1261,35 +1384,42 @@ LOG( log_join, 3, (" -E POS0=[%0.3f %0.3f] POS1=[%0.3f %0.3f]\n", } } -/* Setup temp track */ + /* Setup temp track */ for ( ep=0; ep<2; ep++ ) { switch( Dj.inp[ep].params.type ) { case curveTypeCurve: - tempSegs(tempSegs_da.cnt).type = SEG_CRVTRK; - tempSegs(tempSegs_da.cnt).u.c.center = Dj.inp[ep].params.arcP; - tempSegs(tempSegs_da.cnt).u.c.radius = Dj.inp[ep].params.arcR; - if (IsCurveCircle( Dj.inp[ep].trk )) + DYNARR_APPEND( trkSeg_t, tempSegs_da, 1 ); + p = &DYNARR_LAST( trkSeg_t, tempSegs_da ); + p->type = SEG_CRVTRK; + p->color = drawColorBlack; + p->u.c.center = Dj.inp[ep].params.arcP; + p->u.c.radius = Dj.inp[ep].params.arcR; + if (IsCurveCircle( Dj.inp[ep].trk )) { break; + } a = FindAngle( Dj.inp[ep].params.arcP, Dj.inp_pos[ep] ); a1 = NormalizeAngle( a-Dj.inp[ep].params.arcA0 ); - if (a1 <= Dj.inp[ep].params.arcA1) + if (a1 <= Dj.inp[ep].params.arcA1) { break; + } if (Dj.inp[ep].params.ep == 0) { - tempSegs(tempSegs_da.cnt).u.c.a0 = a; - tempSegs(tempSegs_da.cnt).u.c.a1 = NormalizeAngle(Dj.inp[ep].params.arcA0-a); + p->u.c.a0 = a; + p->u.c.a1 = NormalizeAngle(Dj.inp[ep].params.arcA0-a); } else { - tempSegs(tempSegs_da.cnt).u.c.a0 = Dj.inp[ep].params.arcA0+Dj.inp[ep].params.arcA1; - tempSegs(tempSegs_da.cnt).u.c.a1 = a1-Dj.inp[ep].params.arcA1; + p->u.c.a0 = Dj.inp[ep].params.arcA0 + +Dj.inp[ep].params.arcA1; + p->u.c.a1 = a1-Dj.inp[ep].params.arcA1; } - tempSegs_da.cnt++; break; case curveTypeStraight: if ( FindDistance( Dj.inp[ep].params.lineOrig, Dj.inp[ep].params.lineEnd ) < - FindDistance( Dj.inp[ep].params.lineOrig, Dj.inp_pos[ep] ) ) { - tempSegs(tempSegs_da.cnt).type = SEG_STRTRK; - tempSegs(tempSegs_da.cnt).u.l.pos[0] = Dj.inp[ep].params.lineEnd; - tempSegs(tempSegs_da.cnt).u.l.pos[1] = Dj.inp_pos[ep]; - tempSegs_da.cnt++; + FindDistance( Dj.inp[ep].params.lineOrig, Dj.inp_pos[ep] ) ) { + DYNARR_APPEND( trkSeg_t, tempSegs_da, 1 ); + p = &DYNARR_LAST( trkSeg_t, tempSegs_da ); + p->type = SEG_STRTRK; + p->color = drawColorBlack; + p->u.l.pos[0] = Dj.inp[ep].params.lineEnd; + p->u.l.pos[1] = Dj.inp_pos[ep]; } break; default: @@ -1299,46 +1429,48 @@ LOG( log_join, 3, (" -E POS0=[%0.3f %0.3f] POS1=[%0.3f %0.3f]\n", ok = TRUE; errorReturn: - if (!ok) - tempSegs(tempSegs_da.cnt).color = drawColorRed; + DYNARR_APPEND( trkSeg_t, tempSegs_da, 1 ); + p = &DYNARR_LAST( trkSeg_t, tempSegs_da ); + p->color = ok ? drawColorBlack : drawColorRed; switch( Dj.jRes.type ) { case curveTypeCurve: - tempSegs(tempSegs_da.cnt).type = SEG_CRVTRK; - tempSegs(tempSegs_da.cnt).u.c.center = Dj.jRes.arcP; - tempSegs(tempSegs_da.cnt).u.c.radius = Dj.jRes.arcR; - tempSegs(tempSegs_da.cnt).u.c.a0 = Dj.jRes.arcA0; - tempSegs(tempSegs_da.cnt).u.c.a1 = Dj.jRes.arcA1; - tempSegs_da.cnt++; + p->type = SEG_CRVTRK; + p->u.c.center = Dj.jRes.arcP; + p->u.c.radius = Dj.jRes.arcR; + p->u.c.a0 = Dj.jRes.arcA0; + p->u.c.a1 = Dj.jRes.arcA1; break; case curveTypeStraight: - tempSegs(tempSegs_da.cnt).type = SEG_STRTRK; - tempSegs(tempSegs_da.cnt).u.l.pos[0] = Dj.jRes.pos[0]; - tempSegs(tempSegs_da.cnt).u.l.pos[1] = Dj.jRes.pos[1]; - tempSegs_da.cnt++; + p->type = SEG_STRTRK; + p->u.l.pos[0] = Dj.jRes.pos[0]; + p->u.l.pos[1] = Dj.jRes.pos[1]; break; case curveTypeNone: - tempSegs_da.cnt = 0; + DYNARR_RESET( trkSeg_t, tempSegs_da ); break; default: - AbortProg( "Bad track type %d", Dj.jRes.type ); + CHECKMSG( FALSE, ( "Bad track type %d", Dj.jRes.type ) ); } - if (!ok) + if (!ok) { Dj.jRes.type = curveTypeNone; + } return C_CONTINUE; - + case C_UP: if (Dj.state == 0) { - if (easementVal<0 && Dj.cornuMode) + if (easementVal<0 && Dj.cornuMode) { + commandContext = I2VP(cornuJoinTrack); return CmdCornu(action, pos); - else + } else { return C_CONTINUE; + } } if (Dj.state == 1) { InfoMessage( _("Select 2nd track") ); return C_CONTINUE; } tempSegs(0).color = drawColorBlack; - tempSegs_da.cnt = 0; + DYNARR_RESET( trkSeg_t, tempSegs_da ); if (Dj.jRes.type == curveTypeNone) { Dj.state = 1; InfoMessage( _("Select 2nd track") ); @@ -1352,7 +1484,7 @@ errorReturn: break; case curveTypeCurve: trk = NewCurvedTrack( Dj.jRes.arcP, Dj.jRes.arcR, - Dj.jRes.arcA0, Dj.jRes.arcA1, 0 ); + Dj.jRes.arcA0, Dj.jRes.arcA1, 0 ); break; case curveTypeNone: case curveTypeBezier: @@ -1372,24 +1504,27 @@ errorReturn: wPrefSetFloat("misc", message, desired_radius); } if ( (!JoinTracks( Dj.inp[0].trk, Dj.inp[0].params.ep, Dj.inp_pos[0], - trk, ep, Dj.jRes.pos[0], &Dj.jointD[0] ) ) || - (!JoinTracks( Dj.inp[1].trk, Dj.inp[1].params.ep, Dj.inp_pos[1], - trk, 1-ep, Dj.jRes.pos[1], &Dj.jointD[1] ) ) ) + trk, ep, Dj.jRes.pos[0], &Dj.jointD[0] ) ) || + (!JoinTracks( Dj.inp[1].trk, Dj.inp[1].params.ep, Dj.inp_pos[1], + trk, 1-ep, Dj.jRes.pos[1], &Dj.jointD[1] ) ) ) { rc = C_ERROR; + } UndoEnd(); DrawNewTrack( Dj.inp[0].trk ); DrawNewTrack( Dj.inp[1].trk ); DrawNewTrack( trk ); - if (infoSubst) + if (infoSubst) { InfoSubstituteControls(NULL, NULL); + } infoSubst = FALSE; return rc; case C_CANCEL: SetAllTrackSelect( FALSE ); - if (infoSubst) + if (infoSubst) { InfoSubstituteControls(NULL, NULL); + } infoSubst = FALSE; break; @@ -1398,20 +1533,25 @@ errorReturn: HighlightSelectedTracks(NULL, TRUE, TRUE); if ( Dj.joinMoveState == 1 || Dj.state == 1 ) { DrawFillCircle( &tempD, Dj.inp[0].pos, 0.10*mainD.scale, selectedColor ); - } else if (easementVal<0 && Dj.joinMoveState == 0) + } else if (easementVal<0 && Dj.joinMoveState == 0) { + commandContext = I2VP(cornuJoinTrack); return CmdCornu(action,pos); - if (Dj.anchors.cnt) - DrawSegs(&tempD, zero, 0.0, &(((trkSeg_t *)Dj.anchors.ptr)[0]), Dj.anchors.cnt,trackGauge,wDrawColorBlack); - DrawSegs( &tempD, zero, 0.0, &tempSegs(0), tempSegs_da.cnt, trackGauge, wDrawColorBlack ); + } + DrawSegsDA(&tempD, NULL, zero, 0.0, &Dj.anchors, trackGauge, wDrawColorBlack, + 0); + DrawSegsDA( &tempD, NULL, zero, 0.0, &tempSegs_da, trackGauge, wDrawColorBlack, + 0 ); break; case C_TEXT: case C_OK: SetAllTrackSelect( FALSE ); - if (easementVal<0 && Dj.cornuMode) + if (easementVal<0 && Dj.cornuMode) { return CmdCornu(action,pos); - if (infoSubst) + } + if (infoSubst) { InfoSubstituteControls(NULL, NULL); + } infoSubst = FALSE; } @@ -1427,14 +1567,18 @@ errorReturn: * */ -#include "bitmaps/join.xpm" -#include "bitmaps/join-line.xpm" +#include "bitmaps/join.xpm3" +#include "bitmaps/join-line.xpm3" void InitCmdJoin( wMenu_p menu ) { ButtonGroupBegin( _("Join"), "cmdJoinSetCmd", _("Join") ); - joinCmdInx = AddMenuButton( menu, CmdJoin, "cmdJoinTrack", _("Join Track"), wIconCreatePixMap(join_xpm[iconSize]), LEVEL0_50, IC_STICKY|IC_POPUP|IC_WANT_MOVE, ACCL_JOIN, NULL ); - AddMenuButton( menu, CmdJoinLine, "cmdJoinLine", _("Join Lines"), wIconCreatePixMap(join_line_xpm[iconSize]), LEVEL0_50, IC_STICKY|IC_POPUP|IC_WANT_MOVE, ACCL_JOIN, NULL ); + AddMenuButton( menu, CmdJoin, "cmdJoinTrack", _("Join Track"), + wIconCreatePixMap(join_xpm3[iconSize]), LEVEL0_50, + IC_STICKY|IC_POPUP|IC_WANT_MOVE, ACCL_JOIN, NULL ); + AddMenuButton( menu, CmdJoinLine, "cmdJoinLine", _("Join Lines"), + wIconCreatePixMap(join_line_xpm3[iconSize]), LEVEL0_50, + IC_STICKY|IC_POPUP|IC_WANT_MOVE, ACCL_JOIN, NULL ); ButtonGroupEnd(); /** @logcmd @showrefby join=n cjoin.c Log Join Lines and Tracks command */ log_join = LogFindIndex( "join" ); diff --git a/app/bin/cjoin.h b/app/bin/cjoin.h index eabdce0..710cb72 100644 --- a/app/bin/cjoin.h +++ b/app/bin/cjoin.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef HAVE_CJOIN_H @@ -29,24 +29,29 @@ #define E_ERROR (2) typedef struct { - DIST_T x; - DIST_T r0, r1; - DIST_T l0, l1; - DIST_T d0, d1; - BOOL_T flip, negate, Scurve; - } easementData_t; + DIST_T x; + DIST_T r0, r1; + DIST_T l0, l1; + DIST_T d0, d1; + BOOL_T flip, negate, Scurve; +} easementData_t; extern DIST_T easementVal; extern DIST_T easeR; extern DIST_T easeL; STATUS_T ComputeJoint( DIST_T, DIST_T, easementData_t * ); -BOOL_T JoinTracks( track_p, EPINX_T, coOrd, track_p, EPINX_T, coOrd, easementData_t * ); +BOOL_T JoinTracks( track_p, EPINX_T, coOrd, track_p, EPINX_T, coOrd, + easementData_t * ); void UndoJoint( track_p, EPINX_T, track_p, EPINX_T ); -void DrawJointTrack( drawCmd_p, coOrd, ANGLE_T, DIST_T, DIST_T, DIST_T, DIST_T, BOOL_T, BOOL_T, BOOL_T, track_p, EPINX_T, EPINX_T, DIST_T, wDrawColor, long ); -DIST_T JointDistance( coOrd *, coOrd, ANGLE_T, DIST_T, DIST_T, DIST_T, DIST_T, BOOL_T, BOOL_T ); -coOrd GetJointSegEndPos( coOrd, ANGLE_T, DIST_T, DIST_T, DIST_T, DIST_T, BOOL_T, BOOL_T, BOOL_T, EPINX_T, ANGLE_T * ); -DIST_T JointDescriptionDistance(coOrd pos, track_p trk, coOrd * dpos, BOOL_T show_hidden, BOOL_T * hidden); +void DrawJointTrack( drawCmd_p, coOrd, ANGLE_T, DIST_T, DIST_T, DIST_T, DIST_T, + BOOL_T, BOOL_T, BOOL_T, track_p, EPINX_T, EPINX_T, DIST_T, wDrawColor, long ); +DIST_T JointDistance( coOrd *, coOrd, ANGLE_T, DIST_T, DIST_T, DIST_T, DIST_T, + BOOL_T, BOOL_T ); +coOrd GetJointSegEndPos( coOrd, ANGLE_T, DIST_T, DIST_T, DIST_T, DIST_T, BOOL_T, + BOOL_T, BOOL_T, EPINX_T, ANGLE_T * ); +DIST_T JointDescriptionDistance(coOrd pos, track_p trk, coOrd * dpos, + BOOL_T show_hidden, BOOL_T * hidden); #endif // !HAVE_CJOIN_H diff --git a/app/bin/cmisc.c b/app/bin/cmisc.c index 9685503..580c681 100644 --- a/app/bin/cmisc.c +++ b/app/bin/cmisc.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "common.h" @@ -27,28 +27,26 @@ #include "cselect.h" #include "track.h" #include "common-ui.h" +#include "draw.h" EXPORT wIndex_t describeCmdInx; EXPORT BOOL_T inDescribeCmd; -extern wIndex_t selectCmdInx; -extern wIndex_t joinCmdInx; -extern wIndex_t modifyCmdInx; - static track_p descTrk; static descData_p descData; static descUpdate_t descUpdateFunc; static coOrd descOrig, descSize; static POS_T descBorder; static wDrawColor descColor = 0; -static BOOL_T descUndoStarted; +EXPORT BOOL_T descUndoStarted; static BOOL_T descNeedDrawHilite; static wWinPix_t describeW_posy; static wWinPix_t describeCmdButtonEnd; static wMenu_p descPopupM; -static unsigned int editableLayerList[NUM_LAYERS]; /**< list of non-frozen layers */ +static unsigned int +editableLayerList[NUM_LAYERS]; /**< list of non-frozen layers */ static int * layerValue; /**pointer to current Layer (int *) */ static paramFloatRange_t rdata = { 0, 0, 100, PDO_NORANGECHECK_HIGH|PDO_NORANGECHECK_LOW }; @@ -58,28 +56,28 @@ static char * pivotLabels[] = { N_("First"), N_("Middle"), N_("End"), NULL }; static char * boxLabels[] = { "", NULL }; static paramData_t describePLs[] = { #define I_FLOAT_0 (0) - { PD_FLOAT, NULL, "F1", PDO_NOPREF, &rdata }, - { PD_FLOAT, NULL, "F2", PDO_NOPREF, &rdata }, - { PD_FLOAT, NULL, "F3", PDO_NOPREF, &rdata }, - { PD_FLOAT, NULL, "F4", PDO_NOPREF, &rdata }, - { PD_FLOAT, NULL, "F5", PDO_NOPREF, &rdata }, - { PD_FLOAT, NULL, "F6", PDO_NOPREF, &rdata }, - { PD_FLOAT, NULL, "F7", PDO_NOPREF, &rdata }, - { PD_FLOAT, NULL, "F8", PDO_NOPREF, &rdata }, - { PD_FLOAT, NULL, "F9", PDO_NOPREF, &rdata }, - { PD_FLOAT, NULL, "F10", PDO_NOPREF, &rdata }, - { PD_FLOAT, NULL, "F11", PDO_NOPREF, &rdata }, - { PD_FLOAT, NULL, "F12", PDO_NOPREF, &rdata }, - { PD_FLOAT, NULL, "F13", PDO_NOPREF, &rdata }, - { PD_FLOAT, NULL, "F14", PDO_NOPREF, &rdata }, - { PD_FLOAT, NULL, "F15", PDO_NOPREF, &rdata }, - { PD_FLOAT, NULL, "F16", PDO_NOPREF, &rdata }, - { PD_FLOAT, NULL, "F17", PDO_NOPREF, &rdata }, - { PD_FLOAT, NULL, "F18", PDO_NOPREF, &rdata }, - { PD_FLOAT, NULL, "F19", PDO_NOPREF, &rdata }, - { PD_FLOAT, NULL, "F20", PDO_NOPREF, &rdata }, + { PD_FLOAT, NULL, "F1", PDO_NOPREF, &rdata }, + { PD_FLOAT, NULL, "F2", PDO_NOPREF, &rdata }, + { PD_FLOAT, NULL, "F3", PDO_NOPREF, &rdata }, + { PD_FLOAT, NULL, "F4", PDO_NOPREF, &rdata }, + { PD_FLOAT, NULL, "F5", PDO_NOPREF, &rdata }, + { PD_FLOAT, NULL, "F6", PDO_NOPREF, &rdata }, + { PD_FLOAT, NULL, "F7", PDO_NOPREF, &rdata }, + { PD_FLOAT, NULL, "F8", PDO_NOPREF, &rdata }, + { PD_FLOAT, NULL, "F9", PDO_NOPREF, &rdata }, + { PD_FLOAT, NULL, "F10", PDO_NOPREF, &rdata }, + { PD_FLOAT, NULL, "F11", PDO_NOPREF, &rdata }, + { PD_FLOAT, NULL, "F12", PDO_NOPREF, &rdata }, + { PD_FLOAT, NULL, "F13", PDO_NOPREF, &rdata }, + { PD_FLOAT, NULL, "F14", PDO_NOPREF, &rdata }, + { PD_FLOAT, NULL, "F15", PDO_NOPREF, &rdata }, + { PD_FLOAT, NULL, "F16", PDO_NOPREF, &rdata }, + { PD_FLOAT, NULL, "F17", PDO_NOPREF, &rdata }, + { PD_FLOAT, NULL, "F18", PDO_NOPREF, &rdata }, + { PD_FLOAT, NULL, "F19", PDO_NOPREF, &rdata }, + { PD_FLOAT, NULL, "F20", PDO_NOPREF, &rdata }, { PD_FLOAT, NULL, "F21", PDO_NOPREF, &rdata }, - { PD_FLOAT, NULL, "F22", PDO_NOPREF, &rdata }, + { PD_FLOAT, NULL, "F22", PDO_NOPREF, &rdata }, { PD_FLOAT, NULL, "F23", PDO_NOPREF, &rdata }, { PD_FLOAT, NULL, "F24", PDO_NOPREF, &rdata }, { PD_FLOAT, NULL, "F25", PDO_NOPREF, &rdata }, @@ -90,7 +88,7 @@ static paramData_t describePLs[] = { { PD_FLOAT, NULL, "F30", PDO_NOPREF, &rdata }, { PD_FLOAT, NULL, "F31", PDO_NOPREF, &rdata }, { PD_FLOAT, NULL, "F32", PDO_NOPREF, &rdata }, - { PD_FLOAT, NULL, "F33", PDO_NOPREF, &rdata }, + { PD_FLOAT, NULL, "F33", PDO_NOPREF, &rdata }, { PD_FLOAT, NULL, "F34", PDO_NOPREF, &rdata }, { PD_FLOAT, NULL, "F35", PDO_NOPREF, &rdata }, { PD_FLOAT, NULL, "F36", PDO_NOPREF, &rdata }, @@ -101,49 +99,49 @@ static paramData_t describePLs[] = { #define I_FLOAT_N I_FLOAT_0+40 #define I_LONG_0 I_FLOAT_N - { PD_LONG, NULL, "I1", PDO_NOPREF, &idata }, - { PD_LONG, NULL, "I2", PDO_NOPREF, &idata }, - { PD_LONG, NULL, "I3", PDO_NOPREF, &idata }, - { PD_LONG, NULL, "I4", PDO_NOPREF, &idata }, - { PD_LONG, NULL, "I5", PDO_NOPREF, &idata }, + { PD_LONG, NULL, "I1", PDO_NOPREF, &idata }, + { PD_LONG, NULL, "I2", PDO_NOPREF, &idata }, + { PD_LONG, NULL, "I3", PDO_NOPREF, &idata }, + { PD_LONG, NULL, "I4", PDO_NOPREF, &idata }, + { PD_LONG, NULL, "I5", PDO_NOPREF, &idata }, #define I_LONG_N I_LONG_0+5 #define I_STRING_0 I_LONG_N - { PD_STRING, NULL, "S1", PDO_NOPREF, I2VP(300) }, - { PD_STRING, NULL, "S2", PDO_NOPREF, I2VP(300) }, - { PD_STRING, NULL, "S3", PDO_NOPREF, I2VP(300) }, - { PD_STRING, NULL, "S4", PDO_NOPREF, I2VP(300) }, + { PD_STRING, NULL, "S1", PDO_NOPREF, I2VP(300) }, + { PD_STRING, NULL, "S2", PDO_NOPREF, I2VP(300) }, + { PD_STRING, NULL, "S3", PDO_NOPREF, I2VP(300) }, + { PD_STRING, NULL, "S4", PDO_NOPREF, I2VP(300) }, #define I_STRING_N I_STRING_0+4 #define I_LAYER_0 I_STRING_N - { PD_DROPLIST, NULL, "Y1", PDO_NOPREF, I2VP(150), NULL, 0 }, + { PD_DROPLIST, NULL, "Y1", PDO_NOPREF, I2VP(150), NULL, 0 }, #define I_LAYER_N I_LAYER_0+1 #define I_COLOR_0 I_LAYER_N - { PD_COLORLIST, NULL, "C1", PDO_NOPREF, NULL, N_("Color"), BC_HORZ|BC_NOBORDER }, + { PD_COLORLIST, NULL, "C1", PDO_NOPREF, NULL, N_("Color"), BC_HORZ|BC_NOBORDER }, #define I_COLOR_N I_COLOR_0+1 #define I_LIST_0 I_COLOR_N - { PD_DROPLIST, NULL, "L1", PDO_NOPREF, I2VP(150), NULL, 0 }, - { PD_DROPLIST, NULL, "L2", PDO_NOPREF, I2VP(150), NULL, 0 }, + { PD_DROPLIST, NULL, "L1", PDO_NOPREF, I2VP(150), NULL, 0 }, + { PD_DROPLIST, NULL, "L2", PDO_NOPREF, I2VP(150), NULL, 0 }, { PD_DROPLIST, NULL, "L3", PDO_NOPREF, I2VP(150), NULL, 0 }, { PD_DROPLIST, NULL, "L4", PDO_NOPREF, I2VP(150), NULL, 0 }, #define I_LIST_N I_LIST_0+4 #define I_EDITLIST_0 I_LIST_N - { PD_DROPLIST, NULL, "LE1", PDO_NOPREF, I2VP(150), NULL, BL_EDITABLE }, + { PD_DROPLIST, NULL, "LE1", PDO_NOPREF, I2VP(150), NULL, BL_EDITABLE }, #define I_EDITLIST_N I_EDITLIST_0+1 #define I_TEXT_0 I_EDITLIST_N - { PD_TEXT, NULL, "T1", PDO_NOPREF, &tdata, NULL, BT_HSCROLL }, + { PD_TEXT, NULL, "T1", PDO_NOPREF, &tdata, NULL, BT_HSCROLL }, #define I_TEXT_N I_TEXT_0+1 #define I_PIVOT_0 I_TEXT_N - { PD_RADIO, NULL, "P1", PDO_NOPREF, pivotLabels, N_("Lock"), BC_HORZ|BC_NOBORDER, 0 }, + { PD_RADIO, NULL, "P1", PDO_NOPREF, pivotLabels, N_("Lock"), BC_HORZ|BC_NOBORDER, 0 }, #define I_PIVOT_N I_PIVOT_0+1 #define I_TOGGLE_0 I_PIVOT_N - { PD_TOGGLE, NULL, "boxed1", PDO_NOPREF|PDO_DLGHORZ, boxLabels, N_("Boxed"), BC_HORZ|BC_NOBORDER }, + { PD_TOGGLE, NULL, "boxed1", PDO_NOPREF|PDO_DLGHORZ, boxLabels, N_("Boxed"), BC_HORZ|BC_NOBORDER }, { PD_TOGGLE, NULL, "boxed2", PDO_NOPREF|PDO_DLGHORZ, boxLabels, N_("Boxed"), BC_HORZ|BC_NOBORDER }, { PD_TOGGLE, NULL, "boxed3", PDO_NOPREF|PDO_DLGHORZ, boxLabels, N_("Boxed"), BC_HORZ|BC_NOBORDER }, { PD_TOGGLE, NULL, "boxed4", PDO_NOPREF|PDO_DLGHORZ, boxLabels, N_("Boxed"), BC_HORZ|BC_NOBORDER }, @@ -161,16 +159,16 @@ static paramGroup_t describePG = { "describe", 0, describePLs, COUNT( describePL void CreateEditableLayersList() { - int i = 0; - int j = 0; + int i = 0; + int j = 0; - while (i < NUM_LAYERS) { - if (!GetLayerFrozen(i)) { - editableLayerList[j++] = i; - } + while (i < NUM_LAYERS) { + if (!GetLayerFrozen(i)) { + editableLayerList[j++] = i; + } - i++; - } + i++; + } } /** @@ -183,244 +181,254 @@ CreateEditableLayersList() static int SearchEditableLayerList(unsigned int layer) { - int i; + int i; - for (i = 0; i < NUM_LAYERS; i++) { - if (editableLayerList[i] == layer) { - return (i); - } - } + for (i = 0; i < NUM_LAYERS; i++) { + if (editableLayerList[i] == layer) { + return (i); + } + } - return (-1); + return (-1); } static void DrawDescHilite(BOOL_T selected) { - if (descNeedDrawHilite == FALSE) { - return; - } - - if (descColor==0) { - descColor = wDrawColorGray(87); - } - DrawRectangle(&tempD, descOrig, descSize, selected?descColor:wDrawColorBlue, DRAW_TRANSPARENT); + if (descNeedDrawHilite == FALSE) { + return; + } + + if (descColor==0) { + descColor = wDrawColorGray(87); + } + DrawRectangle(&tempD, descOrig, descSize, selected?descColor:wDrawColorBlue, + DRAW_TRANSPARENT); } static void DescribeUpdate( - paramGroup_p pg, - int inx, - void * data) + paramGroup_p pg, + int inx, + void * data) { - coOrd hi, lo; - descData_p ddp; - - if (inx < 0) { - return; - } - - ddp = (descData_p)pg->paramPtr[inx].context; - - if ((ddp->mode&(DESC_RO|DESC_IGNORE)) != 0) { - return; - } - - if (ddp->type == DESC_PIVOT) { - return; - } - - if (!descUndoStarted) { - UndoStart(_("Change Track"), "Change Track"); - descUndoStarted = TRUE; - } - - if (!descTrk) { - return; // In case timer pops after OK - } - - UndoModify(descTrk); - descUpdateFunc(descTrk, (int)(ddp-descData), descData, FALSE); - - if (descTrk) { - GetBoundingBox(descTrk, &hi, &lo); - if ((ddp->mode&DESC_NOREDRAW) == 0) { - descOrig = lo; - descSize = hi; - descOrig.x -= descBorder; - descOrig.y -= descBorder; - descSize.x -= descOrig.x-descBorder; - descSize.y -= descOrig.y-descBorder; - } - - - if (OFF_D(mapD.orig, mapD.size, descOrig, descSize)) { - ErrorMessage(MSG_MOVE_OUT_OF_BOUNDS); - } - } - - - for (inx = 0; inx < COUNT( describePLs ); inx++) { - if ((describePLs[inx].option & PDO_DLGIGNORE) != 0) { - continue; - } - - ddp = (descData_p)describePLs[inx].context; - - if ((ddp->mode&DESC_IGNORE) != 0) { - continue; - } - - if ((ddp->mode&DESC_CHANGE) == 0) { - if ((ddp->mode&DESC_CHANGE2) == 0) - continue; - } - - if (ddp->mode&DESC_RO) { - wControlActive(ddp->control0, FALSE); - } else { - wControlActive(ddp->control0, TRUE); - } - - ddp->mode &= ~DESC_CHANGE; - if (ddp->type == DESC_POS) { //POS Has two fields - if (ddp->mode&DESC_CHANGE2) { - ddp->mode &= ~DESC_CHANGE2; //Second time - } else { - ddp->mode |= DESC_CHANGE2; //First time - } - } - - ParamLoadControl(&describePG, inx); - } + coOrd hi, lo; + descData_p ddp; + + if (inx < 0) { + return; + } + + ddp = (descData_p)pg->paramPtr[inx].context; + + if ((ddp->mode&(DESC_RO|DESC_IGNORE)) != 0) { + return; + } + + if (ddp->type == DESC_PIVOT) { + return; + } + + if (!descUndoStarted) { + UndoStart(_("Change Track"), "Change Track"); + descUndoStarted = TRUE; + } + + if (!descTrk) { + return; // In case timer pops after OK + } + + UndoModify(descTrk); + descUpdateFunc(descTrk, (int)(ddp-descData), descData, FALSE); + + if (descTrk) { + GetBoundingBox(descTrk, &hi, &lo); + if ((ddp->mode&DESC_NOREDRAW) == 0) { + descOrig = lo; + descSize = hi; + descOrig.x -= descBorder; + descOrig.y -= descBorder; + descSize.x -= descOrig.x-descBorder; + descSize.y -= descOrig.y-descBorder; + } + + + if (OFF_D(mapD.orig, mapD.size, descOrig, descSize)) { + ErrorMessage(MSG_MOVE_OUT_OF_BOUNDS); + } + } + + + for (inx = 0; inx < COUNT( describePLs ); inx++) { + if ((describePLs[inx].option & PDO_DLGIGNORE) != 0) { + continue; + } + + ddp = (descData_p)describePLs[inx].context; + + if ((ddp->mode&DESC_IGNORE) != 0) { + continue; + } + + if ((ddp->mode&DESC_CHANGE) == 0) { + if ((ddp->mode&DESC_CHANGE2) == 0) { + continue; + } + } + + if (ddp->mode&DESC_RO) { + wControlActive(ddp->control0, FALSE); + } else { + wControlActive(ddp->control0, TRUE); + } + + ddp->mode &= ~DESC_CHANGE; + if (ddp->type == DESC_POS) { //POS Has two fields + if (ddp->mode&DESC_CHANGE2) { + ddp->mode &= ~DESC_CHANGE2; //Second time + } else { + ddp->mode |= DESC_CHANGE2; //First time + } + } + + ParamLoadControl(&describePG, inx); + } } static void DescOk(void * junk) { - wHide(describePG.win); - - if (layerValue && *layerValue>=0) { - SetTrkLayer(descTrk, editableLayerList[*layerValue]); //int found that is really in the parm controls. - } - layerValue = NULL; // wipe out reference - descUpdateFunc(descTrk, -1, descData, !descUndoStarted); - descTrk = NULL; - - if (descUndoStarted) { - UndoEnd(); - descUndoStarted = FALSE; - } - - descNeedDrawHilite = FALSE; - Reset(); // DescOk + wHide(describePG.win); + + if (layerValue && *layerValue>=0) { + SetTrkLayer(descTrk, + editableLayerList[*layerValue]); //int found that is really in the parm controls. + } + layerValue = NULL; // wipe out reference + descUpdateFunc(descTrk, -1, descData, !descUndoStarted); + descTrk = NULL; + + if (descUndoStarted) { + UndoEnd(); + descUndoStarted = FALSE; + } + + descNeedDrawHilite = FALSE; + if (programMode == MODE_DESIGN) { + Reset(); // DescOk + } else { + descNeedDrawHilite = FALSE; + wSetCursor(mainD.d,defaultCursor); + } } static struct { - parameterType pd_type; - long option; - int first; - int last; + parameterType pd_type; + long option; + int first; + int last; } descTypeMap[] = { - /*NULL*/ { 0, 0 }, - /*POS*/ { PD_FLOAT, PDO_DIM, I_FLOAT_0, I_FLOAT_N }, - /*FLOAT*/ { PD_FLOAT, 0, I_FLOAT_0, I_FLOAT_N }, - /*ANGLE*/ { PD_FLOAT, PDO_ANGLE, I_FLOAT_0, I_FLOAT_N }, - /*LONG*/ { PD_LONG, 0, I_LONG_0, I_LONG_N }, - /*COLOR*/ { PD_LONG, 0, I_COLOR_0, I_COLOR_N }, - /*DIM*/ { PD_FLOAT, PDO_DIM, I_FLOAT_0, I_FLOAT_N }, - /*PIVOT*/ { PD_RADIO, 0, I_PIVOT_0, I_PIVOT_N }, - /*LAYER*/ { PD_DROPLIST,PDO_LISTINDEX, I_LAYER_0, I_LAYER_N }, - /*STRING*/ { PD_STRING,0, I_STRING_0, I_STRING_N }, - /*TEXT*/ { PD_TEXT, PDO_DLGNOLABELALIGN, I_TEXT_0, I_TEXT_N }, - /*LIST*/ { PD_DROPLIST, PDO_LISTINDEX, I_LIST_0, I_LIST_N }, - /*EDITABLELIST*/{ PD_DROPLIST, 0, I_EDITLIST_0, I_EDITLIST_N }, + /*NULL*/ { 0, 0 }, + /*POS*/ { PD_FLOAT, PDO_DIM, I_FLOAT_0, I_FLOAT_N }, + /*FLOAT*/ { PD_FLOAT, 0, I_FLOAT_0, I_FLOAT_N }, + /*ANGLE*/ { PD_FLOAT, PDO_ANGLE, I_FLOAT_0, I_FLOAT_N }, + /*LONG*/ { PD_LONG, 0, I_LONG_0, I_LONG_N }, + /*COLOR*/ { PD_LONG, 0, I_COLOR_0, I_COLOR_N }, + /*DIM*/ { PD_FLOAT, PDO_DIM, I_FLOAT_0, I_FLOAT_N }, + /*PIVOT*/ { PD_RADIO, 0, I_PIVOT_0, I_PIVOT_N }, + /*LAYER*/ { PD_DROPLIST,PDO_LISTINDEX, I_LAYER_0, I_LAYER_N }, + /*STRING*/ { PD_STRING,0, I_STRING_0, I_STRING_N }, + /*TEXT*/ { PD_TEXT, PDO_DLGNOLABELALIGN, I_TEXT_0, I_TEXT_N }, + /*LIST*/ { PD_DROPLIST, PDO_LISTINDEX, I_LIST_0, I_LIST_N }, + /*EDITABLELIST*/{ PD_DROPLIST, 0, I_EDITLIST_0, I_EDITLIST_N }, /*BOXED*/ { PD_TOGGLE, 0, I_TOGGLE_0, I_TOGGLE_N }, }; /** * An unused param element is selected from the list of pre-defined param elements and initialized - * for an element specific param. - * + * for an element specific param. + * * \param ddp Element specific param * \param valueP the value pointer used by the element * \param label the label assigned by the element * \param sep ? * \return the selected widget */ - -static wControl_p AssignParamToDescribeDialog(descData_p ddp, void * valueP, char * label, - wWinPix_t sep) + +static wControl_p AssignParamToDescribeDialog(descData_p ddp, void * valueP, + char * label, + wWinPix_t sep) { - int inx; - - for (inx = descTypeMap[ddp->type].first; inx<descTypeMap[ddp->type].last; - inx++) { - if ((describePLs[inx].option & PDO_DLGIGNORE) != 0) { - describePLs[inx].option = descTypeMap[ddp->type].option; - - if (describeW_posy > describeCmdButtonEnd) { - describePLs[inx].option |= PDO_DLGUNDERCMDBUTT; - } - - if (sep) - describeW_posy += wControlGetHeight(describePLs[inx].control) + sep; - describePLs[inx].context = ddp; - describePLs[inx].valueP = valueP; - if ((ddp->type == DESC_STRING) && ddp->max_string) { - describePLs[inx].max_string = ddp->max_string; - describePLs[inx].option |= PDO_STRINGLIMITLENGTH; - } - - if (label && ddp->type != DESC_TEXT) { - wControlSetLabel(describePLs[inx].control, label); - describePLs[inx].winLabel = label; - } else { - wControlSetLabel(describePLs[inx].control, ""); - describePLs[inx].winLabel = ""; - } - - return describePLs[inx].control; - } - } - - AbortProg("AssignParamToDescribeDialog: can't find %d", ddp->type); - return NULL; + int inx; + + for (inx = descTypeMap[ddp->type].first; inx<descTypeMap[ddp->type].last; + inx++) { + if ((describePLs[inx].option & PDO_DLGIGNORE) != 0) { + describePLs[inx].option = descTypeMap[ddp->type].option; + + if (describeW_posy > describeCmdButtonEnd) { + describePLs[inx].option |= PDO_DLGUNDERCMDBUTT; + } + + if (sep) { + describeW_posy += wControlGetHeight(describePLs[inx].control) + sep; + } + describePLs[inx].context = ddp; + describePLs[inx].valueP = valueP; + if ((ddp->type == DESC_STRING) && ddp->max_string) { + describePLs[inx].max_string = ddp->max_string; + describePLs[inx].option |= PDO_STRINGLIMITLENGTH; + } + + if (label && ddp->type != DESC_TEXT) { + wControlSetLabel(describePLs[inx].control, label); + describePLs[inx].winLabel = label; + } else { + wControlSetLabel(describePLs[inx].control, ""); + describePLs[inx].winLabel = ""; + } + + return describePLs[inx].control; + } + } + + CHECKMSG( FALSE, ("AssignParamToDescribeDialog: can't find %d", ddp->type) ); + return NULL; } static void DescribeLayout( - paramData_t * pd, - int inx, - wWinPix_t colX, - wWinPix_t * x, - wWinPix_t * y) + paramData_t * pd, + int inx, + wWinPix_t colX, + wWinPix_t * x, + wWinPix_t * y) { - descData_p ddp; - wWinPix_t w, h; - - if (inx < 0) { - return; - } - - if (pd->context == NULL) { - return; - } - - ddp = (descData_p)pd->context; - *y = ddp->posy; - - if (ddp->type == DESC_POS && - ddp->control0 != pd->control) { - *x += wControlGetWidth(pd->control) + 3; - } else if (ddp->type == DESC_TEXT) { - w = tdata.width; - h = tdata.height; - wTextSetSize((wText_p)pd->control, w, h); - } - - wControlShow(pd->control, TRUE); + descData_p ddp; + wWinPix_t w, h; + + if (inx < 0) { + return; + } + + if (pd->context == NULL) { + return; + } + + ddp = (descData_p)pd->context; + *y = ddp->posy; + + if (ddp->type == DESC_POS && + ddp->control0 != pd->control) { + *x += wControlGetWidth(pd->control) + 3; + } else if (ddp->type == DESC_TEXT) { + w = tdata.width; + h = tdata.height; + wTextSetSize((wText_p)pd->control, w, h); + } + + wControlShow(pd->control, TRUE); } @@ -436,82 +444,82 @@ static void DescribeLayout( * */ -static wList_p setLayerL; +//static wList_p setLayerL; void DoDescribe(char * title, track_p trk, descData_p data, descUpdate_t update) { - int inx; - descData_p ddp; - char * label; - int ro_mode; - - if (!inDescribeCmd) { - return; - } - - CreateEditableLayersList(); - descTrk = trk; - descData = data; - descUpdateFunc = update; - describeW_posy = 0; - - if (describePG.win == NULL) { - /* SDB 5.13.2005 */ - ParamCreateDialog(&describePG, _("Description"), _("Done"), DescOk, - (paramActionCancelProc) DescribeCancel, - TRUE, DescribeLayout, F_RECALLPOS, - DescribeUpdate); - describeCmdButtonEnd = wControlBelow((wControl_p)describePG.helpB); - } - - for (inx=0; inx<COUNT( describePLs ); inx++) { - describePLs[inx].option = PDO_DLGIGNORE; - wControlShow(describePLs[inx].control, FALSE); - } - - ro_mode = (GetLayerFrozen(GetTrkLayer(trk))?DESC_RO:0); - - if (ro_mode) - for (ddp=data; ddp->type != DESC_NULL; ddp++) { - if (ddp->mode&DESC_IGNORE) { - continue; - } - - ddp->mode |= DESC_RO; - } - - for (ddp=data; ddp->type != DESC_NULL; ddp++) { - if (ddp->mode&DESC_IGNORE) { - continue; - } - - label = _(ddp->label); - ddp->posy = describeW_posy; - ddp->control0 = AssignParamToDescribeDialog(ddp, ddp->valueP, label, - (ddp->type == DESC_POS?3:3)); - if (ddp->type != DESC_LAYER) - wControlActive(ddp->control0, (!(ddp->mode&DESC_RO))); - - switch (ddp->type) { - case DESC_POS: - ddp->control1 = AssignParamToDescribeDialog(ddp, - &((coOrd*)(ddp->valueP))->y, - NULL, - 0); - wControlActive(ddp->control1, (!(ddp->mode&DESC_RO))); - break; - - case DESC_LAYER: - wListClear((wList_p)ddp->control0); // Rebuild list on each invocation - - if (ro_mode) { - char *layerFormattedName; - layerFormattedName = FormatLayerName(*(int *)(ddp->valueP)); - wListAddValue((wList_p)ddp->control0, layerFormattedName, NULL, I2VP(inx)); - free(layerFormattedName); - *(int *)(ddp->valueP) = 0; - layerValue = (int *)(ddp->valueP); - wControlActive(ddp->control0, FALSE); - } else { + int inx; + descData_p ddp; + char * label; + int ro_mode; + + if (!inDescribeCmd) { + return; + } + + CreateEditableLayersList(); + descTrk = trk; + descData = data; + descUpdateFunc = update; + describeW_posy = 0; + + if (describePG.win == NULL) { + /* SDB 5.13.2005 */ + ParamCreateDialog(&describePG, _("Description"), _("Done"), DescOk, + (paramActionCancelProc) DescribeCancel, + TRUE, DescribeLayout, F_RECALLPOS, + DescribeUpdate); + describeCmdButtonEnd = wControlBelow((wControl_p)describePG.helpB); + } + + for (inx=0; inx<COUNT( describePLs ); inx++) { + describePLs[inx].option = PDO_DLGIGNORE; + wControlShow(describePLs[inx].control, FALSE); + } + + ro_mode = (GetLayerFrozen(GetTrkLayer(trk))?DESC_RO:0); + + if (ro_mode) + for (ddp=data; ddp->type != DESC_NULL; ddp++) { + if (ddp->mode&DESC_IGNORE) { + continue; + } + + ddp->mode |= DESC_RO; + } + + for (ddp=data; ddp->type != DESC_NULL; ddp++) { + if (ddp->mode&DESC_IGNORE) { + continue; + } + + label = _(ddp->label); + ddp->posy = describeW_posy; + ddp->control0 = AssignParamToDescribeDialog(ddp, ddp->valueP, label, 3); + if (ddp->type != DESC_LAYER) { + wControlActive(ddp->control0, (!(ddp->mode&DESC_RO))); + } + + switch (ddp->type) { + case DESC_POS: + ddp->control1 = AssignParamToDescribeDialog(ddp, + &((coOrd*)(ddp->valueP))->y, + NULL, + 0); + wControlActive(ddp->control1, (!(ddp->mode&DESC_RO))); + break; + + case DESC_LAYER: + wListClear((wList_p)ddp->control0); // Rebuild list on each invocation + + if (ro_mode) { + char *layerFormattedName; + layerFormattedName = FormatLayerName(*(int *)(ddp->valueP)); + wListAddValue((wList_p)ddp->control0, layerFormattedName, NULL, I2VP(inx)); + free(layerFormattedName); + *(int *)(ddp->valueP) = 0; + layerValue = (int *)(ddp->valueP); + wControlActive(ddp->control0, FALSE); + } else { for (inx = 0; inx<NUM_LAYERS; inx++) { char *layerFormattedName; layerFormattedName = FormatLayerName(editableLayerList[inx]); @@ -522,28 +530,28 @@ void DoDescribe(char * title, track_p trk, descData_p data, descUpdate_t update) *(int *)(ddp->valueP) = SearchEditableLayerList(*(int *)(ddp->valueP)); layerValue = (int *)(ddp->valueP); wControlActive(ddp->control0, TRUE); - } + } - break; + break; - default: - break; - } - } + default: + break; + } + } - ParamLayoutDialog(&describePG); - ParamLoadControls(&describePG); - sprintf(message, "%s (T%d)", title, GetTrkIndex(trk)); - wWinSetTitle(describePG.win, message); - wShow(describePG.win); + ParamLayoutDialog(&describePG); + ParamLoadControls(&describePG); + sprintf(message, "%s (T%d)", title, GetTrkIndex(trk)); + wWinSetTitle(describePG.win, message); + wShow(describePG.win); } static void DescChange(long changes) { if ((changes&CHANGE_UNITS) && describePG.win && wWinIsVisible(describePG.win)) { - ParamLoadControls(&describePG); - } + ParamLoadControls(&describePG); + } } /***************************************************************************** @@ -555,89 +563,90 @@ static void DescChange(long changes) EXPORT void DescribeCancel(void) { - if (describePG.win && wWinIsVisible(describePG.win)) { - if (descTrk) { - ASSERT(!IsTrackDeleted(descTrk)); - descUpdateFunc(descTrk, -1, descData, TRUE); - descTrk = NULL; + if (describePG.win && wWinIsVisible(describePG.win)) { + if (descTrk) { + CHECK(!IsTrackDeleted(descTrk)); + descUpdateFunc(descTrk, -1, descData, TRUE); + descTrk = NULL; - } + } - wHide(describePG.win); + wHide(describePG.win); - if (descUndoStarted) { - UndoEnd(); - descUndoStarted = FALSE; - } - } + if (descUndoStarted) { + UndoEnd(); + descUndoStarted = FALSE; + } + } - descNeedDrawHilite = FALSE; + descNeedDrawHilite = FALSE; } EXPORT STATUS_T CmdDescribe(wAction_t action, coOrd pos) { - static track_p trk; - char msg[STR_SIZE]; - - switch (action) { - case C_START: - InfoMessage(_("Select track to describe +Shift for Frozen")); - wSetCursor(mainD.d,wCursorQuestion); - descUndoStarted = FALSE; - trk = NULL; - return C_CONTINUE; - - case wActionMove: - trk = OnTrack(&pos, FALSE, FALSE); - if (trk && GetLayerFrozen(GetTrkLayer(trk)) && !(MyGetKeyState() & WKEY_SHIFT)) { + static track_p trk; + char msg[STR_SIZE]; + + switch (action) { + case C_START: + InfoMessage(_("Select track to describe +Shift for Frozen")); + wSetCursor(mainD.d,wCursorQuestion); + descUndoStarted = FALSE; + trk = NULL; + return C_CONTINUE; + + case wActionMove: + trk = OnTrack(&pos, FALSE, FALSE); + if (trk && GetLayerFrozen(GetTrkLayer(trk)) + && !(MyGetKeyState() & WKEY_SHIFT)) { trk = NULL; return C_CONTINUE; } - return C_CONTINUE; - - - case C_DOWN: - if ((trk = OnTrack(&pos, FALSE, FALSE)) != NULL) { - if (GetLayerFrozen(GetTrkLayer(trk)) && !(MyGetKeyState()& WKEY_SHIFT)) { - InfoMessage("Track is Frozen, Add Shift to Describe"); - trk = NULL; - return C_CONTINUE; - } - if (describePG.win && wWinIsVisible(describePG.win) && descTrk) { - descUpdateFunc(descTrk, -1, descData, TRUE); - descTrk = NULL; - } - - descBorder = mainD.scale*0.1; - - if (descBorder < trackGauge) { - descBorder = trackGauge; - } - - inDescribeCmd = TRUE; - GetBoundingBox(trk, &descSize, &descOrig); - descOrig.x -= descBorder; - descOrig.y -= descBorder; - descSize.x -= descOrig.x-descBorder; - descSize.y -= descOrig.y-descBorder; - descNeedDrawHilite = TRUE; - DescribeTrack(trk, msg, 255); - inDescribeCmd = FALSE; - InfoMessage(msg); - trk = NULL; - } else { - InfoMessage(""); - } - - return C_CONTINUE; - - case C_REDRAW: - - if (describePG.win && wWinIsVisible(describePG.win) && descTrk) { - descNeedDrawHilite = TRUE; - coOrd lo,hi; - GetBoundingBox(descTrk,&hi,&lo); + return C_CONTINUE; + + + case C_DOWN: + if ((trk = OnTrack(&pos, FALSE, FALSE)) != NULL) { + if (GetLayerFrozen(GetTrkLayer(trk)) && !(MyGetKeyState()& WKEY_SHIFT)) { + InfoMessage("Track is Frozen, Add Shift to Describe"); + trk = NULL; + return C_CONTINUE; + } + if (describePG.win && wWinIsVisible(describePG.win) && descTrk) { + descUpdateFunc(descTrk, -1, descData, TRUE); + descTrk = NULL; + } + + descBorder = mainD.scale*0.1; + + if (descBorder < trackGauge) { + descBorder = trackGauge; + } + + inDescribeCmd = TRUE; + GetBoundingBox(trk, &descSize, &descOrig); + descOrig.x -= descBorder; + descOrig.y -= descBorder; + descSize.x -= descOrig.x-descBorder; + descSize.y -= descOrig.y-descBorder; + descNeedDrawHilite = TRUE; + DescribeTrack(trk, msg, 255); + inDescribeCmd = FALSE; + InfoMessage(msg); + trk = NULL; + } else { + InfoMessage(""); + } + + return C_CONTINUE; + + case C_REDRAW: + + if (describePG.win && wWinIsVisible(describePG.win) && descTrk) { + descNeedDrawHilite = TRUE; + coOrd lo,hi; + GetBoundingBox(descTrk,&hi,&lo); descOrig = lo; descSize = hi; descOrig.x -= descBorder; @@ -645,54 +654,53 @@ EXPORT STATUS_T CmdDescribe(wAction_t action, coOrd pos) descSize.x -= descOrig.x-descBorder; descSize.y -= descOrig.y-descBorder; - DrawDescHilite(TRUE); + DrawDescHilite(TRUE); - if (descTrk && QueryTrack(descTrk, Q_IS_DRAW)) { + if (descTrk && QueryTrack(descTrk, Q_IS_DRAW)) { DrawOriginAnchor(descTrk); } - } else if (trk){ - DrawTrack(trk,&tempD,wDrawColorPreviewSelected); - } + } else if (trk) { + DrawTrack(trk,&tempD,wDrawColorPreviewSelected); + } - break; + break; - case C_CANCEL: - DescribeCancel(); - wSetCursor(mainD.d,defaultCursor); - return C_CONTINUE; + case C_CANCEL: + DescribeCancel(); + wSetCursor(mainD.d,defaultCursor); + return C_CONTINUE; - case C_CMDMENU: - menuPos = pos; - if (!trk) wMenuPopupShow(descPopupM); - return C_CONTINUE; - } + case C_CMDMENU: + menuPos = pos; + if (!trk) { wMenuPopupShow(descPopupM); } + return C_CONTINUE; + } - return C_CONTINUE; + return C_CONTINUE; } -#include "bitmaps/describe.xpm" - -extern wIndex_t selectCmdInx; -extern wIndex_t modifyCmdInx; -extern wIndex_t panCmdInx; +#include "bitmaps/describe.xpm3" void InitCmdDescribe(wMenu_p menu) { - describeCmdInx = AddMenuButton(menu, CmdDescribe, "cmdDescribe", - _("Properties"), wIconCreatePixMap(describe_xpm[iconSize]), - LEVEL0, IC_CANCEL|IC_POPUP|IC_WANT_MOVE|IC_CMDMENU, ACCL_DESCRIBE, NULL); - RegisterChangeNotification(DescChange); - ParamRegister(&describePG); + describeCmdInx = AddMenuButton(menu, CmdDescribe, "cmdDescribe", + _("Properties"), wIconCreatePixMap(describe_xpm3[iconSize]), + LEVEL0, IC_CANCEL|IC_POPUP|IC_WANT_MOVE|IC_CMDMENU, ACCL_DESCRIBE, NULL); + RegisterChangeNotification(DescChange); + ParamRegister(&describePG); } void InitCmdDescribe2(wMenu_p menu) { - descPopupM = MenuRegister( "Describe Context Menu" ); - wMenuPushCreate(descPopupM, "cmdSelectMode", GetBalloonHelpStr("cmdSelectMode"), 0, DoCommandB, I2VP(selectCmdInx)); - wMenuPushCreate(descPopupM, "cmdModifyMode", GetBalloonHelpStr("cmdModifyMode"), 0, DoCommandB, I2VP(modifyCmdInx)); - wMenuPushCreate(descPopupM, "cmdPanMode", GetBalloonHelpStr("cmdPanMode"), 0, DoCommandB, I2VP(panCmdInx)); + descPopupM = MenuRegister( "Describe Context Menu" ); + wMenuPushCreate(descPopupM, "cmdSelectMode", GetBalloonHelpStr("cmdSelectMode"), + 0, DoCommandB, I2VP(selectCmdInx)); + wMenuPushCreate(descPopupM, "cmdModifyMode", GetBalloonHelpStr("cmdModifyMode"), + 0, DoCommandB, I2VP(modifyCmdInx)); + wMenuPushCreate(descPopupM, "cmdPanMode", GetBalloonHelpStr("cmdPanMode"), 0, + DoCommandB, I2VP(panCmdInx)); } diff --git a/app/bin/cmodify.c b/app/bin/cmodify.c index 1e66e74..491aae3 100644 --- a/app/bin/cmodify.c +++ b/app/bin/cmodify.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "cjoin.h" @@ -34,25 +34,24 @@ #include "layout.h" #include "cselect.h" #include "common-ui.h" +#include "draw.h" + +EXPORT wIndex_t modifyCmdInx; static struct { - track_p Trk; - trackParams_t params; - coOrd pos00, pos00x, pos01; - ANGLE_T angle; - curveData_t curveData; - easementData_t jointD; - DIST_T r1; - BOOL_T valid; - BOOL_T first; - } Dex; + track_p Trk; + trackParams_t params; + coOrd pos00, pos00x, pos01; + ANGLE_T angle; + curveData_t curveData; + easementData_t jointD; + DIST_T r1; + BOOL_T valid; + BOOL_T first; +} Dex; static wMenu_p modPopupM; -extern wIndex_t selectCmdInx; -extern wIndex_t joinCmdInx; -extern wIndex_t describeCmdInx; - static dynArr_t anchors_da; #define anchors(N) DYNARR_N(trkSeg_t,anchors_da,N) @@ -65,7 +64,8 @@ static BOOL_T modifyProtractorMode; static BOOL_T modifyExtendMode; -static void CreateEndAnchor(coOrd p, wBool_t lock) { +static void CreateEndAnchor(coOrd p, wBool_t lock) +{ DIST_T d = tempD.scale*0.15; DYNARR_APPEND(trkSeg_t,anchors_da,1); @@ -76,11 +76,12 @@ static void CreateEndAnchor(coOrd p, wBool_t lock) { anchors(i).u.c.radius = d/2; anchors(i).u.c.a0 = 0.0; anchors(i).u.c.a1 = 360.0; - anchors(i).width = 0; + anchors(i).lineWidth = 0; wSetCursor(mainD.d,wCursorNone); } -static void CreateCornuAnchor(coOrd p, wBool_t lock) { +static void CreateCornuAnchor(coOrd p, wBool_t lock) +{ DIST_T d = tempD.scale*0.15; DYNARR_APPEND(trkSeg_t,anchors_da,1); @@ -91,7 +92,7 @@ static void CreateCornuAnchor(coOrd p, wBool_t lock) { anchors(i).u.c.radius = d/2; anchors(i).u.c.a0 = 0.0; anchors(i).u.c.a1 = 360.0; - anchors(i).width = 0; + anchors(i).lineWidth = 0; DYNARR_APPEND(trkSeg_t,anchors_da,1); i = anchors_da.cnt-1; anchors(i).type = SEG_CRVLIN; @@ -100,42 +101,45 @@ static void CreateCornuAnchor(coOrd p, wBool_t lock) { anchors(i).u.c.radius = d; anchors(i).u.c.a0 = 0.0; anchors(i).u.c.a1 = 360.0; - anchors(i).width = 0; + anchors(i).lineWidth = 0; wSetCursor(mainD.d,wCursorNone); } -static void CreateRadiusAnchor(coOrd p, ANGLE_T a, BOOL_T bi) { +static void CreateRadiusAnchor(coOrd p, ANGLE_T a, BOOL_T bi) +{ DYNARR_SET(trkSeg_t,anchors_da,anchors_da.cnt+5); - DrawArrowHeads(&DYNARR_N(trkSeg_t,anchors_da,anchors_da.cnt-5),p,a,bi,wDrawColorBlue); + DrawArrowHeads(&DYNARR_N(trkSeg_t,anchors_da,anchors_da.cnt-5),p,a,bi, + wDrawColorBlue); } /* * Call cbezier.c CmdBezModify to alter Bezier Track and Lines. * Picking a Bezier will allow control point(s) modifications until terminated with "Enter" */ -static STATUS_T ModifyBezier(wAction_t action, coOrd pos) { +static STATUS_T ModifyBezier(wAction_t action, coOrd pos) +{ STATUS_T rc = C_CONTINUE; - if (Dex.Trk == NULL) return C_ERROR; //No track picked yet! + if (Dex.Trk == NULL) { return C_ERROR; } //No track picked yet! switch (action&0xFF) { - case C_START: - case C_DOWN: - case C_MOVE: - case C_UP: - case C_OK: - case C_TEXT: - case wActionMove: - trackGauge = (IsTrack(Dex.Trk)?GetTrkGauge(Dex.Trk):0.0); - rc = CmdBezModify(Dex.Trk, action, pos, trackGauge); - break; - case C_TERMINATE: - rc = CmdBezModify(Dex.Trk, action, pos, trackGauge); - Dex.Trk = NULL; - modifyBezierMode = FALSE; - break; - case C_REDRAW: - rc = CmdBezModify(Dex.Trk, action, pos, trackGauge); - break; + case C_START: + case C_DOWN: + case C_MOVE: + case C_UP: + case C_OK: + case C_TEXT: + case wActionMove: + trackGauge = (IsTrack(Dex.Trk)?GetTrkGauge(Dex.Trk):0.0); + rc = CmdBezModify(Dex.Trk, action, pos, trackGauge); + break; + case C_TERMINATE: + rc = CmdBezModify(Dex.Trk, action, pos, trackGauge); + Dex.Trk = NULL; + modifyBezierMode = FALSE; + break; + case C_REDRAW: + rc = CmdBezModify(Dex.Trk, action, pos, trackGauge); + break; } return rc; } @@ -144,29 +148,30 @@ static STATUS_T ModifyBezier(wAction_t action, coOrd pos) { * Call ccornu.c CmdCornuModify to alter Cornu Track and Lines. * Picking a Cornu will allow end point(s) modifications until terminated with "Enter" */ -static STATUS_T ModifyCornu(wAction_t action, coOrd pos) { +static STATUS_T ModifyCornu(wAction_t action, coOrd pos) +{ STATUS_T rc = C_CONTINUE; - if (Dex.Trk == NULL) return C_ERROR; //No track picked yet! + if (Dex.Trk == NULL) { return C_ERROR; } //No track picked yet! switch (action&0xFF) { - case C_LCLICK: - case C_START: - case C_DOWN: - case C_MOVE: - case C_UP: - case C_OK: - case C_TEXT: - case wActionMove: - trackGauge = (IsTrack(Dex.Trk)?GetTrkGauge(Dex.Trk):0.0); - rc = CmdCornuModify(Dex.Trk, action, pos, trackGauge); - break; - case C_TERMINATE: - rc = CmdCornuModify(Dex.Trk, action, pos, trackGauge); - Dex.Trk = NULL; - modifyCornuMode = FALSE; - break; - case C_REDRAW: - rc = CmdCornuModify(Dex.Trk, action, pos, trackGauge); - break; + case C_LCLICK: + case C_START: + case C_DOWN: + case C_MOVE: + case C_UP: + case C_OK: + case C_TEXT: + case wActionMove: + trackGauge = (IsTrack(Dex.Trk)?GetTrkGauge(Dex.Trk):0.0); + rc = CmdCornuModify(Dex.Trk, action, pos, trackGauge); + break; + case C_TERMINATE: + rc = CmdCornuModify(Dex.Trk, action, pos, trackGauge); + Dex.Trk = NULL; + modifyCornuMode = FALSE; + break; + case C_REDRAW: + rc = CmdCornuModify(Dex.Trk, action, pos, trackGauge); + break; } return rc; } @@ -174,64 +179,66 @@ static STATUS_T ModifyCornu(wAction_t action, coOrd pos) { /* * Picking a DRAW will allow point modifications until terminated with "Enter"/"Space" */ -static STATUS_T ModifyDraw(wAction_t action, coOrd pos) { +static STATUS_T ModifyDraw(wAction_t action, coOrd pos) +{ STATUS_T rc = C_CONTINUE; - if (Dex.Trk == NULL) return C_ERROR; //No item picked yet! + if (Dex.Trk == NULL) { return C_ERROR; } //No item picked yet! switch (action&0xFF) { - case C_START: - case C_DOWN: - case C_MOVE: - case C_UP: - rc = ModifyTrack( Dex.Trk, action, pos ); - break; - case wActionMove: - rc = ModifyTrack( Dex.Trk, action, pos ); - break; - case C_TEXT: - //Delete or '0' - continues - if ((action>>8 !=32) && (action >>8 !=13) && (action >>8 !=9)) - return ModifyTrack( Dex.Trk, action, pos ); - //Enter/Space/Tab does not - if ((action>>8 !=32) && (action>>8 != 13) && (action>>8 != 9)) return C_CONTINUE; - if (((action>>8) == 9 && (MyGetKeyState()&WKEY_SHIFT))) return C_TERMINATE; - /*no break*/ - case C_OK: - rc = ModifyTrack( Dex.Trk, C_OK, pos ); - if (rc != C_CONTINUE) modifyDrawMode = FALSE; - UndoEnd(); - break; - case C_CONFIRM: - rc = ModifyTrack( Dex.Trk, action, pos ); - break; - case C_CANCEL: - case C_FINISH: - case C_TERMINATE: - rc = ModifyTrack( Dex.Trk, action, pos ); - Dex.Trk = NULL; - modifyDrawMode = FALSE; - tempSegs_da.cnt = 0; - rc = C_CONTINUE; - break; - case C_REDRAW: - rc = ModifyTrack( Dex.Trk, action, pos ); - break; - case C_CMDMENU: - menuPos = pos; - rc = ModifyTrack( Dex.Trk, action, pos ); - break; - case wActionExtKey: - rc = ModifyTrack( Dex.Trk, action, pos ); - break; - default: - break; + case C_START: + case C_DOWN: + case C_MOVE: + case C_UP: + rc = ModifyTrack( Dex.Trk, action, pos ); + break; + case wActionMove: + rc = ModifyTrack( Dex.Trk, action, pos ); + break; + case C_TEXT: + //Delete or '0' - continues + if ((action>>8 !=32) && (action >>8 !=13) && (action >>8 !=9)) { + return ModifyTrack( Dex.Trk, action, pos ); + } + //Enter/Space/Tab does not + if ((action>>8 !=32) && (action>>8 != 13) && (action>>8 != 9)) { return C_CONTINUE; } + if (((action>>8) == 9 && (MyGetKeyState()&WKEY_SHIFT))) { return C_TERMINATE; } + /*no break*/ + case C_OK: + rc = ModifyTrack( Dex.Trk, C_OK, pos ); + if (rc != C_CONTINUE) { modifyDrawMode = FALSE; } + UndoEnd(); + break; + case C_CONFIRM: + rc = ModifyTrack( Dex.Trk, action, pos ); + break; + case C_CANCEL: + case C_FINISH: + case C_TERMINATE: + rc = ModifyTrack( Dex.Trk, action, pos ); + Dex.Trk = NULL; + modifyDrawMode = FALSE; + DYNARR_RESET( trkSeg_t, tempSegs_da ); + rc = C_CONTINUE; + break; + case C_REDRAW: + rc = ModifyTrack( Dex.Trk, action, pos ); + break; + case C_CMDMENU: + menuPos = pos; + rc = ModifyTrack( Dex.Trk, action, pos ); + break; + case wActionExtKey: + rc = ModifyTrack( Dex.Trk, action, pos ); + break; + default: + break; } return rc; } STATUS_T CmdModify( - wAction_t action, - coOrd pos ) + wAction_t action, + coOrd pos ) /* * Extend and alter a track. * Extend a track with a curve or straight and optionally an easement. @@ -253,19 +260,22 @@ STATUS_T CmdModify( static DIST_T trackGauge; if ( changeTrackMode ) { - if ( action == C_MOVE ) + if ( action == C_MOVE ) { action = C_RMOVE; - if ( action == C_UP ) + } + if ( action == C_UP ) { action = C_RUP; + } } switch (action&0xFF) { case C_START: DYNARR_RESET(trkSeg_t,anchors_da); - InfoMessage( _("Select a track to modify, Left-Click change length, Right-Click to add flextrack") ); + InfoMessage( + _("Select a track to modify, Left-Click change length, Right-Click to add flextrack") ); Dex.Trk = NULL; - tempSegs_da.cnt = 0; + DYNARR_RESET( trkSeg_t, tempSegs_da ); /*ChangeParameter( &easementPD );*/ trackGauge = 0.0; changeTrackMode = modifyRulerMode = FALSE; @@ -281,21 +291,25 @@ STATUS_T CmdModify( case C_DOWN: case C_LDOUBLE: DYNARR_RESET(trkSeg_t,anchors_da); - if (modifyProtractorMode) + if (modifyProtractorMode) { return ModifyProtractor(C_DOWN, pos); - if (modifyBezierMode) + } + if (modifyBezierMode) { return ModifyBezier(C_DOWN, pos); - if (modifyCornuMode) + } + if (modifyCornuMode) { return ModifyCornu(C_DOWN, pos); - if (modifyDrawMode) + } + if (modifyDrawMode) { return ModifyDraw(C_DOWN, pos); + } DYNARR_SET( trkSeg_t, tempSegs_da, 2 ); tempSegs(0).color = wDrawColorBlack; - tempSegs(0).width = 0; + tempSegs(0).lineWidth = 0; tempSegs(1).color = wDrawColorBlack; - tempSegs(1).width = 0; - tempSegs_da.cnt = 0; + tempSegs(1).lineWidth = 0; + DYNARR_RESET( trkSeg_t, tempSegs_da ); Dex.Trk = OnTrack( &pos, FALSE, FALSE ); //Dex.Trk = trk; if (Dex.Trk == NULL) { @@ -320,7 +334,7 @@ STATUS_T CmdModify( if (ModifyBezier(C_START, pos) != C_CONTINUE) { //Call Start with track modifyBezierMode = FALSE; //Function rejected Bezier Dex.Trk =NULL; - tempSegs_da.cnt = 0; + DYNARR_RESET( trkSeg_t, tempSegs_da ); } return C_CONTINUE; //That's it } @@ -329,7 +343,7 @@ STATUS_T CmdModify( if (ModifyCornu(C_START, pos) != C_CONTINUE) { //Call Start with track modifyCornuMode = FALSE; //Function rejected Cornu Dex.Trk =NULL; - tempSegs_da.cnt = 0; + DYNARR_RESET( trkSeg_t, tempSegs_da ); } return C_CONTINUE; //That's it @@ -340,32 +354,34 @@ STATUS_T CmdModify( if (ModifyDraw(C_START, pos) != C_CONTINUE) { modifyDrawMode = FALSE; Dex.Trk = NULL; - tempSegs_da.cnt = 0; + DYNARR_RESET( trkSeg_t, tempSegs_da ); } return C_CONTINUE; } - if ((action&0xFF) == C_LDOUBLE) return C_ERROR; + if ((action&0xFF) == C_LDOUBLE) { return C_ERROR; } - if ((MyGetKeyState()&WKEY_CTRL)) goto extendTrack; + if ((MyGetKeyState()&WKEY_CTRL)) { goto extendTrack; } if ( (MyGetKeyState()&WKEY_SHIFT) && //Free to change radius - QueryTrack( Dex.Trk, Q_CAN_MODIFYRADIUS )&& - ((inx=PickUnconnectedEndPoint(pos,Dex.Trk)) >= 0 )) { + QueryTrack( Dex.Trk, Q_CAN_MODIFYRADIUS )&& + ((inx=PickUnconnectedEndPoint(pos,Dex.Trk)) >= 0 )) { trk = Dex.Trk; - while ( (trk1=GetTrkEndTrk(trk,1-inx)) && //Means next track to mine even if can be end... - QueryTrack(trk1, Q_CANNOT_BE_ON_END) ) { + while ( (trk1=GetTrkEndTrk(trk,1-inx)) + && //Means next track to mine even if can be end... + QueryTrack(trk1, Q_CANNOT_BE_ON_END) ) { inx = GetEndPtConnectedToMe( trk1, trk ); trk = trk1; } if (trk1) { - UndoStart( _("Change Track"), "Change( T%d[%d] )", GetTrkIndex(Dex.Trk), Dex.params.ep ); + UndoStart( _("Change Track"), "Change( T%d[%d] )", GetTrkIndex(Dex.Trk), + Dex.params.ep ); inx = GetEndPtConnectedToMe( trk1, trk ); - Dex.Trk = NULL; - UndrawNewTrack( trk ); - DeleteTrack(trk, TRUE); //Get rid of original track + Dex.Trk = NULL; + UndrawNewTrack( trk ); + DeleteTrack(trk, TRUE); //Get rid of original track if ( !GetTrkEndTrk( trk1, inx ) ) { Dex.Trk = trk1; Dex.pos00 = GetTrkEndPos( Dex.Trk, inx ); @@ -385,9 +401,9 @@ STATUS_T CmdModify( case wActionMove: DYNARR_RESET(trkSeg_t,anchors_da); - if (modifyCornuMode) return ModifyCornu(wActionMove,pos); - if (modifyDrawMode) return ModifyDraw(wActionMove,pos); - if (modifyBezierMode) return ModifyBezier(wActionMove, pos); + if (modifyCornuMode) { return ModifyCornu(wActionMove,pos); } + if (modifyDrawMode) { return ModifyDraw(wActionMove,pos); } + if (modifyBezierMode) { return ModifyBezier(wActionMove, pos); } track_p t; wSetCursor(mainD.d,defaultCursor); if (((t=OnTrack(&pos,FALSE,TRUE))!= NULL) && CheckTrackLayerSilent( t )) { @@ -395,11 +411,12 @@ STATUS_T CmdModify( if (QueryTrack( t, Q_IS_CORNU )) { CreateCornuAnchor(pos,FALSE); } else if ( QueryTrack( t, Q_CAN_MODIFY_CONTROL_POINTS )) { - CreateRadiusAnchor(pos,NormalizeAngle(GetAngleAtPoint(t,pos,NULL,NULL)+90.0),TRUE); + CreateRadiusAnchor(pos,NormalizeAngle(GetAngleAtPoint(t,pos,NULL,NULL)+90.0), + TRUE); CreateEndAnchor(pos,FALSE); - } else if (QueryTrack(t,Q_CAN_ADD_ENDPOINTS)){ //Turntable + } else if (QueryTrack(t,Q_CAN_ADD_ENDPOINTS)) { //Turntable trackParams_t tp; - if (!GetTrackParams(PARAMS_CORNU, t, pos, &tp)) return C_CONTINUE; + if (!GetTrackParams(PARAMS_CORNU, t, pos, &tp)) { return C_CONTINUE; } ANGLE_T a = tp.angle; Translate(&pos,tp.ttcenter,a,tp.ttradius); CreateRadiusAnchor(pos,a,FALSE); @@ -414,15 +431,17 @@ STATUS_T CmdModify( } else { CreateEndAnchor(pos,FALSE); if ((MyGetKeyState()&WKEY_SHIFT) && //Shift Down - QueryTrack( t, Q_CAN_MODIFYRADIUS ) && // Straight or Curve - ((inx=PickUnconnectedEndPointSilent(pos,t)) >= 0 )) { //Which has an open end - if (GetTrkEndTrk(t,1-inx)) // Has to have a track on other end - CreateRadiusAnchor(pos,NormalizeAngle(GetAngleAtPoint(t,pos,NULL,NULL)+90.0),TRUE); + QueryTrack( t, Q_CAN_MODIFYRADIUS ) && // Straight or Curve + ((inx=PickUnconnectedEndPointSilent(pos,t)) >= 0 )) { //Which has an open end + if (GetTrkEndTrk(t,1-inx)) { // Has to have a track on other end + CreateRadiusAnchor(pos,NormalizeAngle(GetAngleAtPoint(t,pos,NULL,NULL)+90.0), + TRUE); + } } CreateRadiusAnchor(pos,GetAngleAtPoint(t,pos,NULL,NULL),TRUE); } } - } else if (ep>=0){ //Turnout + } else if (ep>=0) { //Turnout pos = GetTrkEndPos(t, ep); CreateEndAnchor(pos,TRUE); if ( (MyGetKeyState()&WKEY_CTRL)) { @@ -435,8 +454,8 @@ STATUS_T CmdModify( } } } else if (((t=OnTrack(&pos,FALSE,FALSE))!= NULL) - && (!(GetLayerFrozen(GetTrkLayer(t)) || GetLayerModule(GetTrkLayer(t)))) - && (QueryTrack(t, Q_IS_DRAW ) && !QueryTrack(t, Q_IS_TEXT)) ) { + && (!(GetLayerFrozen(GetTrkLayer(t)) || GetLayerModule(GetTrkLayer(t)))) + && (QueryTrack(t, Q_IS_DRAW ) && !QueryTrack(t, Q_IS_TEXT)) ) { CreateEndAnchor(pos,FALSE); } else { ModifyRuler (wActionMove, pos); @@ -444,23 +463,29 @@ STATUS_T CmdModify( return C_CONTINUE; case C_MOVE: - if ( modifyRulerMode ) + if ( modifyRulerMode ) { return ModifyRuler( C_MOVE, pos ); - if ( modifyProtractorMode ) + } + if ( modifyProtractorMode ) { return ModifyProtractor( C_MOVE, pos ); - if (Dex.Trk == NULL) + } + if (Dex.Trk == NULL) { return C_CONTINUE; - if ( modifyBezierMode ) + } + if ( modifyBezierMode ) { return ModifyBezier(C_MOVE, pos); - if ( modifyCornuMode ) + } + if ( modifyCornuMode ) { return ModifyCornu(C_MOVE, pos); - if ( modifyDrawMode) + } + if ( modifyDrawMode) { return ModifyDraw(C_MOVE, pos); - if (modifyExtendMode && (MyGetKeyState()&WKEY_CTRL)) + } + if (modifyExtendMode && (MyGetKeyState()&WKEY_CTRL)) { goto extendTrackMove; - tempSegs_da.cnt = 0; + } - if ((MyGetKeyState() & WKEY_ALT) == 0) SnapPos( &pos ); + if ((MyGetKeyState() & WKEY_ALT) == 0) { SnapPos( &pos ); } rc = ModifyTrack( Dex.Trk, C_MOVE, pos ); if ( rc != C_CONTINUE ) { rc = C_CONTINUE; @@ -470,28 +495,35 @@ STATUS_T CmdModify( case C_UP: DYNARR_RESET(trkSeg_t,anchors_da); - if (Dex.Trk == NULL) + if (Dex.Trk == NULL) { return C_CONTINUE; - if ( modifyRulerMode ) + } + if ( modifyRulerMode ) { return ModifyRuler( C_MOVE, pos ); - if ( modifyProtractorMode) + } + if ( modifyProtractorMode) { return ModifyProtractor( C_UP, pos); - if ( modifyBezierMode ) + } + if ( modifyBezierMode ) { return ModifyBezier( C_UP, pos); - if (modifyCornuMode) + } + if (modifyCornuMode) { return ModifyCornu(C_UP, pos); - if (modifyDrawMode) + } + if (modifyDrawMode) { return ModifyDraw(C_UP, pos); - if ((MyGetKeyState()&WKEY_CTRL)) goto extendTrackUp; + } + if ((MyGetKeyState()&WKEY_CTRL)) { goto extendTrackUp; } - tempSegs_da.cnt = 0; - if ((MyGetKeyState() & WKEY_ALT) == 0) SnapPos( &pos ); - UndoStart( _("Modify Track"), "Modify( T%d[%d] )", GetTrkIndex(Dex.Trk), Dex.params.ep ); + if ((MyGetKeyState() & WKEY_ALT) == 0) { SnapPos( &pos ); } + UndoStart( _("Modify Track"), "Modify( T%d[%d] )", GetTrkIndex(Dex.Trk), + Dex.params.ep ); UndoModify( Dex.Trk ); rc = ModifyTrack( Dex.Trk, C_UP, pos ); + DYNARR_RESET( trkSeg_t, tempSegs_da ); UndoEnd(); - Dex.Trk = NULL; + Dex.Trk = NULL; return rc; case C_RDOWN: //This is same as context menu.... @@ -514,7 +546,7 @@ extendTrack: } trackGauge = GetTrkGauge( Dex.Trk ); Dex.pos00 = pos; - CHANGE_TRACK: +CHANGE_TRACK: if (GetTrackParams( PARAMS_EXTEND, Dex.Trk, Dex.pos00, &Dex.params)) { if (Dex.params.ep == -1) { Dex.Trk = NULL; @@ -527,8 +559,8 @@ extendTrack: Dex.pos00 = GetTrkEndPos(Dex.Trk,Dex.params.ep); Dex.angle = GetTrkEndAngle( Dex.Trk,Dex.params.ep); Translate( &Dex.pos00x, Dex.pos00, Dex.angle, 10.0 ); - LOG( log_modify, 1, ("extend endPt[%d] = [%0.3f %0.3f] A%0.3f\n", - Dex.params.ep, Dex.pos00.x, Dex.pos00.y, Dex.angle ) ) + LOG( log_modify, 1, ("extend endPt[%d] = [%0.3f %0.3f] A%0.3f\n", + Dex.params.ep, Dex.pos00.x, Dex.pos00.y, Dex.angle ) ) InfoMessage( _("Drag to add flex track") ); } else { return C_ERROR; @@ -542,40 +574,47 @@ extendTrack: InfoMessage ( _("No track selected")); return C_ERROR; } - /* no break */ + /* no break */ case C_RMOVE: extendTrackMove: DYNARR_RESET(trkSeg_t,anchors_da); - tempSegs_da.cnt = 0; + DYNARR_RESET( trkSeg_t, tempSegs_da ); Dex.valid = FALSE; - if (Dex.Trk == NULL) return C_CONTINUE; - if ((MyGetKeyState() & WKEY_ALT) == 0) SnapPos( &pos ); - if ( Dex.first && FindDistance( pos, Dex.pos00 ) <= minLength ) + if (Dex.Trk == NULL) { return C_CONTINUE; } + if ((MyGetKeyState() & WKEY_ALT) == 0) { SnapPos( &pos ); } + if ( Dex.first && FindDistance( pos, Dex.pos00 ) <= minLength ) { return C_CONTINUE; + } Dex.first = FALSE; Dex.pos01 = Dex.pos00; - if (Dex.params.type == curveTypeCornu) { //Always Restrict Cornu drag out to match end + if (Dex.params.type == + curveTypeCornu) { //Always Restrict Cornu drag out to match end ANGLE_T angle2 = NormalizeAngle(FindAngle(pos, Dex.pos00)-Dex.angle); if (angle2 > 90.0 && angle2 < 270.0) { if (Dex.params.cornuRadius[Dex.params.ep] == 0) { Translate( &pos, Dex.pos00, Dex.angle, FindDistance( Dex.pos00, pos ) ); } else { ANGLE_T angle = FindAngle(Dex.params.cornuCenter[Dex.params.ep],pos)- - FindAngle(Dex.params.cornuCenter[Dex.params.ep],Dex.pos00); + FindAngle(Dex.params.cornuCenter[Dex.params.ep],Dex.pos00); pos=Dex.pos00; Rotate(&pos,Dex.params.cornuCenter[Dex.params.ep],angle); } - } else pos = Dex.pos00; //Only out from end - PlotCurve( crvCmdFromCornu, Dex.pos00, Dex.pos00x, pos, &Dex.curveData, FALSE, 0.0 ); - } else - PlotCurve( crvCmdFromEP1, Dex.pos00, Dex.pos00x, pos, &Dex.curveData, TRUE, 0.0 ); + } else { pos = Dex.pos00; } //Only out from end + PlotCurve( crvCmdFromCornu, Dex.pos00, Dex.pos00x, pos, &Dex.curveData, FALSE, + 0.0 ); + } else { + PlotCurve( crvCmdFromEP1, Dex.pos00, Dex.pos00x, pos, &Dex.curveData, TRUE, + 0.0 ); + } curveType = Dex.curveData.type; if ( curveType == curveTypeStraight ) { Dex.r1 = 0.0; - if (Dex.params.type == curveTypeCurve) { - if (ComputeJoint( Dex.params.arcR, Dex.r1, &Dex.jointD ) == E_ERROR) + if (Dex.params.type == curveTypeCurve && + !QueryTrack( Dex.Trk, Q_IGNORE_EASEMENT_ON_EXTEND ) ) { + if (ComputeJoint( Dex.params.arcR, Dex.r1, &Dex.jointD ) == E_ERROR) { return C_CONTINUE; + } d = Dex.params.len - Dex.jointD.d0; if (d <= minLength) { ErrorMessage( MSG_TRK_TOO_SHORT, "First ", PutDim(fabs(minLength-d)) ); @@ -584,8 +623,9 @@ extendTrackMove: } else { Dex.jointD.d1 = 0.0; } + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); tempSegs(0).type = SEG_STRTRK; - tempSegs(0).width = 0; + tempSegs(0).lineWidth = 0; tempSegs(0).u.l.pos[0] = Dex.pos01; tempSegs(0).u.l.pos[1] = Dex.curveData.pos1; d = FindDistance( Dex.pos01, Dex.curveData.pos1 ); @@ -594,50 +634,56 @@ extendTrackMove: ErrorMessage( MSG_TRK_TOO_SHORT, "Extending ", PutDim(fabs(minLength-d)) ); return C_CONTINUE; } - tempSegs_da.cnt = 1; Dex.valid = TRUE; if (action != C_RDOWN) InfoMessage( _("Straight Track: Length=%s Angle=%0.3f"), - FormatDistance( FindDistance( Dex.curveData.pos1, Dex.pos01 ) ), - PutAngle( FindAngle( Dex.pos01, Dex.curveData.pos1 ) ) ); + FormatDistance( FindDistance( Dex.curveData.pos1, Dex.pos01 ) ), + PutAngle( FindAngle( Dex.pos01, Dex.curveData.pos1 ) ) ); } else if ( curveType == curveTypeNone ) { - if (action != C_RDOWN) + if (action != C_RDOWN) { InfoMessage( _("Back") ); + } return C_CONTINUE; } else if ( curveType == curveTypeCurve ) { Dex.r1 = Dex.curveData.curveRadius; if ( QueryTrack( Dex.Trk, Q_IGNORE_EASEMENT_ON_EXTEND ) ) { - /* Ignore easements when extending turnouts or turntables */ + /* Ignore easements when extending turnouts or turntables */ Dex.jointD.x = - Dex.jointD.r0 = Dex.jointD.r1 = - Dex.jointD.l0 = Dex.jointD.l1 = - Dex.jointD.d0 = Dex.jointD.d1 = 0.0; + Dex.jointD.r0 = Dex.jointD.r1 = + Dex.jointD.l0 = Dex.jointD.l1 = + Dex.jointD.d0 = Dex.jointD.d1 = 0.0; Dex.jointD.flip = Dex.jointD.negate = Dex.jointD.Scurve = FALSE; d = Dex.curveData.curveRadius * Dex.curveData.a1 * 2.0*M_PI/360.0; } else { /* Easement code */ if (easementVal<0.0) { //Cornu Join - need to estimate a "good" easement length d = Dex.curveData.curveRadius * Dex.curveData.a1 * 2.0*M_PI/360.0; - Dex.jointD.d0 = Dex.jointD.d1 =0.75*72*12/GetTrkScale(Dex.Trk); //Easement 1.5 cars long to start - if (Dex.jointD.d0>(GetTrkLength(Dex.Trk,0,1)/2)) + Dex.jointD.d0 = Dex.jointD.d1 =0.75*72*12/GetTrkScale( + Dex.Trk); //Easement 1.5 cars long to start + if (Dex.jointD.d0>(GetTrkLength(Dex.Trk,0,1)/2)) { Dex.jointD.d0 = GetTrkLength(Dex.Trk,0,1)/2; - if (Dex.jointD.d1>d/2) + } + if (Dex.jointD.d1>d/2) { Dex.jointD.d1 = d/2; - Dex.jointD.negate = DifferenceBetweenAngles(Dex.angle,FindAngle(Dex.pos00,pos))<0.0; + } + Dex.jointD.negate = DifferenceBetweenAngles(Dex.angle,FindAngle(Dex.pos00, + pos))<0.0; Dex.jointD.x = 2*trackGauge; //Signal an easement present to JoinTracks } else { if ( easeR > 0.0 && Dex.r1 < easeR ) { ErrorMessage( MSG_RADIUS_LSS_EASE_MIN, - FormatDistance( Dex.r1 ), FormatDistance( easeR ) ); + FormatDistance( Dex.r1 ), FormatDistance( easeR ) ); return C_CONTINUE; } if ( Dex.r1*2.0*M_PI*Dex.curveData.a1/360.0 > mapD.size.x+mapD.size.y ) { ErrorMessage( MSG_CURVE_TOO_LARGE ); return C_CONTINUE; } - if ( NormalizeAngle( FindAngle( Dex.pos00, pos ) - Dex.angle ) > 180.0 ) + if ( NormalizeAngle( FindAngle( Dex.pos00, pos ) - Dex.angle ) > 180.0 ) { Dex.r1 = - Dex.r1; - if (ComputeJoint( Dex.params.arcR, Dex.r1, &Dex.jointD ) == E_ERROR) + } + if (ComputeJoint( Dex.params.arcR, Dex.r1, &Dex.jointD ) == E_ERROR) { return C_CONTINUE; + } d = Dex.params.len - Dex.jointD.d0; if (d <= minLength) { ErrorMessage( MSG_TRK_TOO_SHORT, "First ", PutDim(fabs(minLength-d)) ); @@ -648,34 +694,37 @@ extendTrackMove: a0 = Dex.angle + (Dex.jointD.negate?-90.0:+90.0); Translate( &Dex.pos01, Dex.pos00, a0, Dex.jointD.x ); Translate( &Dex.curveData.curvePos, Dex.curveData.curvePos, - a0, Dex.jointD.x ); -LOG( log_modify, 2, ("A=%0.3f X=%0.3f\n", a0, Dex.jointD.x ) ) + a0, Dex.jointD.x ); + LOG( log_modify, 2, ("A=%0.3f X=%0.3f\n", a0, Dex.jointD.x ) ) } if (d <= minLength) { ErrorMessage( MSG_TRK_TOO_SHORT, "Extending ", PutDim(fabs(minLength-d)) ); return C_CONTINUE; } + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); tempSegs(0).type = SEG_CRVTRK; - tempSegs(0).width = 0; + tempSegs(0).lineWidth = 0; tempSegs(0).u.c.center = Dex.curveData.curvePos; tempSegs(0).u.c.radius = Dex.curveData.curveRadius, - tempSegs(0).u.c.a0 = Dex.curveData.a0; + tempSegs(0).u.c.a0 = Dex.curveData.a0; tempSegs(0).u.c.a1 = Dex.curveData.a1; - tempSegs_da.cnt = 1; double da = D2R(Dex.curveData.a1); - if (da < 0.0) + if (da < 0.0) { da = 2*M_PI + da; - a = NormalizeAngle( Dex.angle - FindAngle( Dex.pos00, Dex.curveData.curvePos ) ); - if ( a < 180.0 ) + } + a = NormalizeAngle( Dex.angle - FindAngle( Dex.pos00, + Dex.curveData.curvePos ) ); + if ( a < 180.0 ) { a = NormalizeAngle( Dex.curveData.a0-90 ); - else + } else { a = NormalizeAngle( Dex.curveData.a0+Dex.curveData.a1+90.0 ); + } Dex.valid = TRUE; if (action != C_RDOWN) InfoMessage( _("Curve Track: Radius=%s Length=%s Angle=%0.3f"), - FormatDistance( Dex.curveData.curveRadius ), - FormatDistance( Dex.curveData.curveRadius * da), - Dex.curveData.a1 ); + FormatDistance( Dex.curveData.curveRadius ), + FormatDistance( Dex.curveData.curveRadius * da), + Dex.curveData.a1 ); } return C_CONTINUE; @@ -683,38 +732,41 @@ LOG( log_modify, 2, ("A=%0.3f X=%0.3f\n", a0, Dex.jointD.x ) ) extendTrackUp: changeTrackMode = FALSE; modifyExtendMode = FALSE; - tempSegs_da.cnt = 0; - if (Dex.Trk == NULL) return C_CONTINUE; - if (!Dex.valid) + DYNARR_RESET( trkSeg_t, tempSegs_da ); + if (Dex.Trk == NULL) { return C_CONTINUE; } + if (!Dex.valid) { return C_CONTINUE; - UndoStart( _("Extend Track"), "Extend( T%d[%d] )", GetTrkIndex(Dex.Trk), Dex.params.ep ); + } + UndoStart( _("Extend Track"), "Extend( T%d[%d] )", GetTrkIndex(Dex.Trk), + Dex.params.ep ); trk = NULL; curveType = Dex.curveData.type; - + if ( curveType == curveTypeStraight ) { if (QueryTrack(Dex.Trk,Q_CAN_EXTEND)) //Check it isn't a turnout end.... if ( Dex.params.type == curveTypeStraight && - FindDistance(Dex.pos01, Dex.curveData.pos1) > 0 ) { + FindDistance(Dex.pos01, Dex.curveData.pos1) > 0 ) { UndoModify( Dex.Trk ); AdjustStraightEndPt( Dex.Trk, Dex.params.ep, Dex.curveData.pos1 ); UndoEnd(); DrawNewTrack(Dex.Trk ); return C_TERMINATE; - } - if (FindDistance(Dex.pos01, Dex.curveData.pos1) == 0) return C_ERROR; -LOG( log_modify, 1, ("L = %0.3f, P0 = %0.3f, P1 = %0.3f\n", - Dex.params.len, Dex.pos01, Dex.curveData.pos1 ) ) + } + if (FindDistance(Dex.pos01, Dex.curveData.pos1) == 0) { return C_ERROR; } + LOG( log_modify, 1, ("L = %0.3f, P0 = %0.3f, P1 = %0.3f\n", + Dex.params.len, Dex.pos01, Dex.curveData.pos1 ) ) trk = NewStraightTrack( Dex.pos01, Dex.curveData.pos1 ); inx = 0; } else if ( curveType == curveTypeCurve ) { -LOG( log_modify, 1, ("R = %0.3f, A0 = %0.3f, A1 = %0.3f\n", - Dex.curveData.curveRadius, Dex.curveData.a0, Dex.curveData.a1 ) ) + LOG( log_modify, 1, ("R = %0.3f, A0 = %0.3f, A1 = %0.3f\n", + Dex.curveData.curveRadius, Dex.curveData.a0, Dex.curveData.a1 ) ) trk = NewCurvedTrack( Dex.curveData.curvePos, Dex.curveData.curveRadius, - Dex.curveData.a0, Dex.curveData.a1, 0 ); + Dex.curveData.a0, Dex.curveData.a1, 0 ); inx = PickUnconnectedEndPoint( Dex.pos01, trk ); - if (inx == -1) + if (inx == -1) { return C_ERROR; + } } else { return C_ERROR; @@ -726,28 +778,30 @@ LOG( log_modify, 1, ("R = %0.3f, A0 = %0.3f, A1 = %0.3f\n", DrawEndPt( &mainD, Dex.Trk, Dex.params.ep, wDrawColorBlack ); } else { UndrawNewTrack( Dex.Trk ); - JoinTracks( Dex.Trk, Dex.params.ep, Dex.pos00, trk, inx, Dex.pos01, &Dex.jointD ); + JoinTracks( Dex.Trk, Dex.params.ep, Dex.pos00, trk, inx, Dex.pos01, + &Dex.jointD ); DrawNewTrack( Dex.Trk ); } UndoEnd(); - tempSegs_da.cnt = 0; DrawNewTrack( trk ); return C_TERMINATE; case C_REDRAW: - if (modifyBezierMode) return ModifyBezier(C_REDRAW, pos); - if (modifyCornuMode) return ModifyCornu(C_REDRAW, pos); - if (modifyDrawMode) return ModifyDraw(C_REDRAW, pos); - DrawSegs( &tempD, zero, 0.0, &tempSegs(0), tempSegs_da.cnt, trackGauge, wDrawColorBlack ); - if (anchors_da.cnt) - DrawSegs( &tempD, zero, 0.0, &anchors(0), anchors_da.cnt, trackGauge, wDrawColorBlack ); + if (modifyBezierMode) { return ModifyBezier(C_REDRAW, pos); } + if (modifyCornuMode) { return ModifyCornu(C_REDRAW, pos); } + if (modifyDrawMode) { return ModifyDraw(C_REDRAW, pos); } + DrawSegsDA( &tempD, NULL, zero, 0.0, &tempSegs_da, trackGauge, wDrawColorBlack, + 0 ); + DrawSegsDA( &tempD, NULL, zero, 0.0, &anchors_da, trackGauge, wDrawColorBlack, + 0 ); return C_CONTINUE; case C_TEXT: if ((action>>8) == 'c') { panCenter = pos; - LOG( log_pan, 2, ( "PanCenter:Mod-%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); + LOG( log_pan, 2, ( "PanCenter:Mod-%d %0.3f %0.3f\n", __LINE__, panCenter.x, + panCenter.y ) ); PanHere(I2VP(0)); return C_CONTINUE; } @@ -760,14 +814,18 @@ LOG( log_modify, 1, ("R = %0.3f, A0 = %0.3f, A1 = %0.3f\n", if ((action>>8) == '0' || (action>>8 == 'o')) { PanMenuEnter(I2VP('o')); } - if ( !Dex.Trk ) + if ( !Dex.Trk ) { return C_CONTINUE; - if (modifyBezierMode) + } + if (modifyBezierMode) { return ModifyBezier(action, pos); - if (modifyCornuMode) + } + if (modifyCornuMode) { return ModifyCornu(action, pos); - if (modifyDrawMode) + } + if (modifyDrawMode) { return ModifyDraw(action, pos); + } return ModifyTrack( Dex.Trk, action, pos ); case C_CMDMENU: @@ -776,29 +834,35 @@ LOG( log_modify, 1, ("R = %0.3f, A0 = %0.3f, A1 = %0.3f\n", wMenuPopupShow(modPopupM); return C_CONTINUE; } - if (modifyBezierMode) + if (modifyBezierMode) { return ModifyBezier(action, pos); - if (modifyCornuMode) + } + if (modifyCornuMode) { return ModifyCornu(action, pos); - if (modifyDrawMode) + } + if (modifyDrawMode) { return ModifyDraw(action, pos); + } return ModifyTrack( Dex.Trk, action, pos ); case C_LCLICK: if ( modifyDrawMode) { rc = ModifyDraw(C_DOWN, pos); - if (rc == C_CONTINUE) + if (rc == C_CONTINUE) { return ModifyDraw(C_UP, pos); + } } - if (modifyCornuMode) + if (modifyCornuMode) { return ModifyCornu(action, pos); - /*no break*/ + } + /*no break*/ default: - if (modifyBezierMode) return ModifyBezier(action, pos); - if (modifyCornuMode) return ModifyCornu(action, pos); - if (modifyDrawMode) return ModifyDraw(action, pos); - if (Dex.Trk) + if (modifyBezierMode) { return ModifyBezier(action, pos); } + if (modifyCornuMode) { return ModifyCornu(action, pos); } + if (modifyDrawMode) { return ModifyDraw(action, pos); } + if (Dex.Trk) { return ModifyTrack( Dex.Trk, action, pos ); + } return C_CONTINUE; } return C_CONTINUE; @@ -811,21 +875,22 @@ LOG( log_modify, 1, ("R = %0.3f, A0 = %0.3f, A1 = %0.3f\n", * */ -#include "bitmaps/extend.xpm" -extern wIndex_t panCmdInx; -extern wIndex_t selectCmdInx; -extern wIndex_t describeCmdInx; - +#include "bitmaps/extend.xpm3" void InitCmdModify( wMenu_p menu ) { - modifyCmdInx = AddMenuButton( menu, CmdModify, "cmdModify", _("Modify"), wIconCreatePixMap(extend_xpm[iconSize]), LEVEL0_50, IC_STICKY|IC_POPUP|IC_WANT_MOVE|IC_CMDMENU, ACCL_MODIFY, NULL ); + modifyCmdInx = AddMenuButton( menu, CmdModify, "cmdModify", _("Modify"), + wIconCreatePixMap(extend_xpm3[iconSize]), LEVEL0_50, + IC_STICKY|IC_POPUP|IC_WANT_MOVE|IC_CMDMENU, ACCL_MODIFY, NULL ); /** @logcmd @showrefby modify=n cmodify.c Log Modify command */ log_modify = LogFindIndex( "modify" ); modPopupM = MenuRegister( "Modify Context Menu" ); - wMenuPushCreate(modPopupM, "cmdSelectMode", GetBalloonHelpStr("cmdSelectMode"), 0, DoCommandB, I2VP(selectCmdInx)); - wMenuPushCreate(modPopupM, "cmdDescribeMode", GetBalloonHelpStr("cmdDescribeMode"), 0, DoCommandB, I2VP(describeCmdInx)); - wMenuPushCreate(modPopupM, "cmdPanMode", GetBalloonHelpStr("cmdPanMode"), 0, DoCommandB, I2VP(panCmdInx)); + wMenuPushCreate(modPopupM, "cmdSelectMode", GetBalloonHelpStr("cmdSelectMode"), + 0, DoCommandB, I2VP(selectCmdInx)); + wMenuPushCreate(modPopupM, "cmdDescribeMode", + GetBalloonHelpStr("cmdDescribeMode"), 0, DoCommandB, I2VP(describeCmdInx)); + wMenuPushCreate(modPopupM, "cmdPanMode", GetBalloonHelpStr("cmdPanMode"), 0, + DoCommandB, I2VP(panCmdInx)); wMenuSeparatorCreate(modPopupM); wMenuPushCreate(modPopupM, "", _("Zoom In"), 0, DoZoomUp, I2VP(1)); wMenuPushCreate(modPopupM, "", _("Zoom Out"), 0, DoZoomDown, I2VP(1)); diff --git a/app/bin/cnote.c b/app/bin/cnote.c index 7e4c0f9..04d63f1 100644 --- a/app/bin/cnote.c +++ b/app/bin/cnote.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "custom.h" @@ -34,51 +34,59 @@ static paramTextData_t noteTextData = { 300, 150 }; static paramData_t notePLs[] = { #define I_NOTETEXT (0) #define noteT ((wText_p)notePLs[I_NOTETEXT].control) - { PD_TEXT, NULL, "text", PDO_DLGRESIZE, ¬eTextData } + { PD_TEXT, NULL, "text", PDO_DLGRESIZE, ¬eTextData } }; static paramGroup_t notePG = { "note", 0, notePLs, COUNT( notePLs ) }; void ClearNote(void) { - if (mainText) { - MyFree(mainText); - mainText = NULL; - } + if (mainText) { + MyFree(mainText); + mainText = NULL; + } } static void NoteOk(void * unused) { - if (wTextGetModified(noteT)) { - int len; - ClearNote(); - len = wTextGetSize(noteT); - mainText = (char*)MyMalloc(len+2); - wTextGetText(noteT, mainText, len); - } - - wHide(noteW); + if (wTextGetModified(noteT)) { + int len; + ClearNote(); + len = wTextGetSize(noteT); + mainText = (char*)MyMalloc(len+2); + wTextGetText(noteT, mainText, len); + } + + wHide(noteW); } void DoNote(void * unused) { - if (noteW == NULL) { - noteW = ParamCreateDialog(¬ePG, MakeWindowTitle(_("Note")), _("Ok"), NoteOk, - wHide, FALSE, NULL, F_NOTTRANSIENT|F_RESIZE, NULL); - } - - wTextClear(noteT); - wTextAppend(noteT, mainText?mainText: - _("Replace this text with your layout notes")); - wTextSetReadonly(noteT, FALSE); - wShow(noteW); + if (noteW == NULL) { + noteW = ParamCreateDialog(¬ePG, MakeWindowTitle(_("Note")), _("Ok"), NoteOk, + wHide, FALSE, NULL, F_NOTTRANSIENT|F_RESIZE, NULL); + } + + wTextClear(noteT); + wTextAppend(noteT, mainText?mainText: + _("Replace this text with your layout notes")); + wTextSetReadonly(noteT, FALSE); + wShow(noteW); } +/** + * Save the main layout note to file. The note text is converted to + * UTF-8 if this is configured at compile time. Before saving characters that + * have special meanings in the XTC file (eg. ") are escaped. + * + * \param f open layout file + * \return + */ BOOL_T WriteMainNote(FILE* f) { - BOOL_T rc = TRUE; + BOOL_T rc = TRUE; char *noteText = mainText; if (noteText && *noteText) { @@ -92,18 +100,17 @@ BOOL_T WriteMainNote(FILE* f) } #endif // UTFCONVERT - - char * sText = ConvertToEscapedText( noteText ); - rc &= fprintf(f, "NOTE MAIN 0 0 0 0 0 \"%s\"\n", sText )>0; - MyFree( sText ); + char * sText = ConvertToEscapedText( noteText ); + rc &= fprintf(f, "NOTE MAIN 0 0 0 0 0 \"%s\"\n", sText )>0; + MyFree( sText ); #ifdef UTFCONVERT if (out) { MyFree(out); } #endif // UTFCONVERT - } - return rc; + } + return rc; } /** @@ -114,28 +121,30 @@ BOOL_T WriteMainNote(FILE* f) BOOL_T ReadMainNote(char *line) { - long size; - char * sNote = NULL; - - if (!GetArgs(line + 9, - paramVersion < 3 ? "l" : - paramVersion < VERSION_INLINENOTE ? "0000l": - "0000lq", &size, &sNote)) { - return FALSE; - } - - if (mainText) { - MyFree(mainText); - } - - if ( paramVersion < VERSION_INLINENOTE ) - mainText = ReadMultilineText(); - else - mainText = sNote; - return TRUE; + long size; + char * sNote = NULL; + + if (!GetArgs(line + 9, + paramVersion < 3 ? "l" : + paramVersion < VERSION_INLINENOTE ? "0000l": + "0000lq", &size, &sNote)) { + return FALSE; + } + + if (mainText) { + MyFree(mainText); + } + + if ( paramVersion < VERSION_INLINENOTE ) { + mainText = ReadMultilineText(); + } else { + mainText = sNote; + } + + return TRUE; } void InitCmdNote() { - ParamRegister(¬ePG); + ParamRegister(¬ePG); } diff --git a/app/bin/cnvdsgn.c b/app/bin/cnvdsgn.c index fc4a827..91a31e5 100644 --- a/app/bin/cnvdsgn.c +++ b/app/bin/cnvdsgn.c @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "utility.h" @@ -25,23 +25,24 @@ static int trackSeparation = 20; static int arrowHeadLength = 10; -static double FindCenter( - coOrd * pos, - coOrd p0, - coOrd p1, - double radius ) +static double FindCenter( + coOrd * pos, + coOrd p0, + coOrd p1, + double radius ) { double d; double a0, a1; d = FindDistance( p0, p1 )/2.0; a0 = FindAngle( p0, p1 ); a1 = NormalizeAngle(R2D(asin( d/radius ))); - if (a1 > 180) + if (a1 > 180) { a1 -= 360; + } /*a0 = NormalizeAngle( a0 + (radius>0 ? +(90.0-a1) : -(90.0-a1) ) );*/ a0 = NormalizeAngle( a0 + (90.0-a1) ); Translate( pos, p0, a0, radius ); -/*fprintf(stderr,"Center = %0.3f %0.3f\n", pos->x, pos->y );*/ + /*fprintf(stderr,"Center = %0.3f %0.3f\n", pos->x, pos->y );*/ return a1*2.0; } @@ -56,35 +57,35 @@ static void buildDesignerLines( FILE * inf, FILE * outf ) double len; while ( fgets( line, sizeof line, inf ) != NULL ) { - + if ( strncmp( line, "ARROW", 5 ) == 0 ) { if ( sscanf( line, "ARROW, %lf, %lf, %lf, %lf", - &p0.x, &p0.y, &p1.x, &p1.y ) != 4) { + &p0.x, &p0.y, &p1.x, &p1.y ) != 4) { fprintf( stderr, "SYNTAX: %s", line ); exit (1); } a0 = FindAngle( p1, p0 ); fprintf( outf, " { 1, %ld, %ld, %ld, %ld },\n", - (long)(p0.x+0.5), (long)(p0.y+0.5), (long)(p1.x+0.5), (long)(p1.y+0.5) ); + (long)(p0.x+0.5), (long)(p0.y+0.5), (long)(p1.x+0.5), (long)(p1.y+0.5) ); Translate( &p1, p0, a0+135, arrowHeadLength ); fprintf( outf, " { 1, %ld, %ld, %ld, %ld },\n", - (long)(p0.x+0.5), (long)(p0.y+0.5), (long)(p1.x+0.5), (long)(p1.y+0.5) ); + (long)(p0.x+0.5), (long)(p0.y+0.5), (long)(p1.x+0.5), (long)(p1.y+0.5) ); Translate( &p1, p0, a0-135, arrowHeadLength ); fprintf( outf, " { 1, %ld, %ld, %ld, %ld },\n", - (long)(p0.x+0.5), (long)(p0.y+0.5), (long)(p1.x+0.5), (long)(p1.y+0.5) ); + (long)(p0.x+0.5), (long)(p0.y+0.5), (long)(p1.x+0.5), (long)(p1.y+0.5) ); } else if ( strncmp( line, "LINE", 4 ) == 0 ) { if ( sscanf( line, "LINE, %lf, %lf, %lf, %lf", - &p0.x, &p0.y, &p1.x, &p1.y ) != 4) { + &p0.x, &p0.y, &p1.x, &p1.y ) != 4) { fprintf( stderr, "SYNTAX: %s", line ); exit (1); } fprintf( outf, " { 1, %ld, %ld, %ld, %ld },\n", - (long)(p0.x+0.5), (long)(p0.y+0.5), (long)(p1.x+0.5), (long)(p1.y+0.5) ); + (long)(p0.x+0.5), (long)(p0.y+0.5), (long)(p1.x+0.5), (long)(p1.y+0.5) ); } else if ( strncmp( line, "STRAIGHT", 8 ) == 0 ) { if ( sscanf( line, "STRAIGHT, %lf, %lf, %lf, %lf", - &p0.x, &p0.y, &p1.x, &p1.y ) != 4) { + &p0.x, &p0.y, &p1.x, &p1.y ) != 4) { fprintf( stderr, "SYNTAX: %s", line ); exit (1); } @@ -92,38 +93,39 @@ static void buildDesignerLines( FILE * inf, FILE * outf ) Translate( &q0, p0, a0+90, trackSeparation/2.0 ); Translate( &q1, p1, a0+90, trackSeparation/2.0 ); fprintf( outf, " { 3, %ld, %ld, %ld, %ld },\n", - (long)(q0.x+0.5), (long)(q0.y+0.5), (long)(q1.x+0.5), (long)(q1.y+0.5) ); + (long)(q0.x+0.5), (long)(q0.y+0.5), (long)(q1.x+0.5), (long)(q1.y+0.5) ); Translate( &q0, p0, a0-90, trackSeparation/2.0 ); Translate( &q1, p1, a0-90, trackSeparation/2.0 ); fprintf( outf, " { 3, %ld, %ld, %ld, %ld },\n", - (long)(q0.x+0.5), (long)(q0.y+0.5), (long)(q1.x+0.5), (long)(q1.y+0.5) ); - + (long)(q0.x+0.5), (long)(q0.y+0.5), (long)(q1.x+0.5), (long)(q1.y+0.5) ); + } else if ( strncmp( line, "CURVE", 5 ) == 0 ) { if ( sscanf( line, "CURVE, %lf, %lf, %lf, %lf, %lf", - &p0.x, &p0.y, &p1.x, &p1.y, &radius ) != 5) { + &p0.x, &p0.y, &p1.x, &p1.y, &radius ) != 5) { fprintf( stderr, "SYNTAX: %s", line ); exit (1); } a1 = FindCenter( &pc, p0, p1, radius ); a0 = FindAngle( pc, p0 ); -/*fprintf(stderr, "A0 = %0.3f, A1 = %0.3f\n", a0, a1 );*/ + /*fprintf(stderr, "A0 = %0.3f, A1 = %0.3f\n", a0, a1 );*/ len = radius * M_PI * 2 * ( a1 / 360.0 ); num = len/20; - if (num < 0) num = - num; + if (num < 0) { num = - num; } num++; a1 /= num; - if (radius < 0) + if (radius < 0) { radius = -radius; + } for ( j=0; j<num; j++ ) { -/*fprintf( stderr, "A0 = %0.3f\n", a0 );*/ + /*fprintf( stderr, "A0 = %0.3f\n", a0 );*/ Translate( &p0, pc, a0, radius+trackSeparation/2.0 ); Translate( &p1, pc, a0+a1, radius+trackSeparation/2.0 ); fprintf( outf, " { 3, %ld, %ld, %ld, %ld },\n", - (long)(p0.x+0.5), (long)(p0.y+0.5), (long)(p1.x+0.5), (long)(p1.y+0.5) ); + (long)(p0.x+0.5), (long)(p0.y+0.5), (long)(p1.x+0.5), (long)(p1.y+0.5) ); Translate( &p0, pc, a0, radius-trackSeparation/2.0 ); Translate( &p1, pc, a0+a1, radius-trackSeparation/2.0 ); fprintf( outf, " { 3, %ld, %ld, %ld, %ld },\n", - (long)(p0.x+0.5), (long)(p0.y+0.5), (long)(p1.x+0.5), (long)(p1.y+0.5) ); + (long)(p0.x+0.5), (long)(p0.y+0.5), (long)(p1.x+0.5), (long)(p1.y+0.5) ); a0 += a1; p0 = p1; } diff --git a/app/bin/command.c b/app/bin/command.c new file mode 100644 index 0000000..bf628f8 --- /dev/null +++ b/app/bin/command.c @@ -0,0 +1,800 @@ +/* file command.c + * Main routine and initialization for the application + */ + +/* XTrkCad - Model Railroad CAD + * Copyright (C) 2005 Dave Bullis + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + + + +#include "command.h" +#include "common.h" +#include "cselect.h" +#include "cundo.h" +#include "draw.h" +#include "fileio.h" +#include "track.h" +#include "common-ui.h" +#include "menu.h" + +/***************************************************************************** + * + * COMMAND + * + */ + +#define COMMAND_MAX (250) +#define BUTTON_MAX (250) + +static struct { + wControl_p control; + wBool_t enabled; + wWinPix_t x, y; + long options; + int group; + wIndex_t cmdInx; +} buttonList[BUTTON_MAX]; +EXPORT int buttonCnt = 0; // TODO-misc-refactor + +static struct { + procCommand_t cmdProc; + char * helpKey; + wIndex_t buttInx; + char * labelStr; + wIcon_p icon; + int reqLevel; + wBool_t enabled; + long options; + long stickyMask; + long acclKey; + wMenuPush_p menu[NUM_CMDMENUS]; + void * context; +} commandList[COMMAND_MAX]; + + +EXPORT int commandCnt = 0; + +static wIndex_t curCommand = 0; + +EXPORT int cmdGroup; + +static int log_command; + +#define TOOLBARSET_INIT (0xFFFF) +EXPORT long toolbarSet = TOOLBARSET_INIT; +EXPORT wWinPix_t toolbarHeight = 0; +static wWinPix_t toolbarWidth = 0; +EXPORT long preSelect = 0; /**< default command 0 = Describe 1 = Select */ +EXPORT long rightClickMode = 0; +EXPORT void * commandContext; +EXPORT coOrd cmdMenuPos; + +/*--------------------------------------------------------------------*/ +EXPORT const char* GetCurCommandName() +{ + return commandList[curCommand].helpKey; +} + +EXPORT void EnableCommands(void) +{ + int inx, minx; + wBool_t enable; + + LOG(log_command, 5, + ( "COMMAND enable S%d M%d\n", selectedTrackCount, programMode )) + for (inx = 0; inx < commandCnt; inx++) { + if (commandList[inx].buttInx) { + if ((commandList[inx].options & IC_SELECTED) + && selectedTrackCount <= 0) { + enable = FALSE; + } else if ((programMode == MODE_TRAIN + && (commandList[inx].options + & (IC_MODETRAIN_TOO | IC_MODETRAIN_ONLY)) == 0) + || (programMode != MODE_TRAIN + && (commandList[inx].options & IC_MODETRAIN_ONLY) + != 0)) { + enable = FALSE; + } else { + enable = TRUE; + } + if (commandList[inx].enabled != enable) { + if (commandList[inx].buttInx >= 0) + wControlActive(buttonList[commandList[inx].buttInx].control, + enable); + for (minx = 0; minx < NUM_CMDMENUS; minx++) + if (commandList[inx].menu[minx]) { + wMenuPushEnable(commandList[inx].menu[minx], enable); + } + commandList[inx].enabled = enable; + } + } + } + + EnableMenus(); + + for (inx = 0; inx < buttonCnt; inx++) { + if (buttonList[inx].cmdInx < 0 + && (buttonList[inx].options & IC_SELECTED)) { + wControlActive(buttonList[inx].control, selectedTrackCount > 0); + } + } +} + +EXPORT wIndex_t GetCurrentCommand() +{ + return curCommand; +} + +EXPORT void Reset(void) +{ + if (recordF) { + fprintf(recordF, "RESET\n"); + fflush(recordF); + } + LOG(log_command, 2, + ( "COMMAND CANCEL %s\n", commandList[curCommand].helpKey )) + commandList[curCommand].cmdProc( C_CANCEL, zero); + if (commandList[curCommand].buttInx >= 0) + wButtonSetBusy( + (wButton_p) buttonList[commandList[curCommand].buttInx].control, + FALSE); + curCommand = (preSelect ? selectCmdInx : describeCmdInx); + wSetCursor(mainD.d, preSelect ? defaultCursor : wCursorQuestion); + commandContext = commandList[curCommand].context; + if (commandList[curCommand].buttInx >= 0) + wButtonSetBusy( + (wButton_p) buttonList[commandList[curCommand].buttInx].control, + TRUE); + DYNARR_RESET( trkSeg_t, tempSegs_da ); + + TryCheckPoint(); + + ClrAllTrkBits( TB_UNDRAWN ); + DoRedraw(); // Reset + EnableCommands(); + ResetMouseState(); + LOG(log_command, 1, + ( "COMMAND RESET %s\n", commandList[curCommand].helpKey )) + (void) commandList[curCommand].cmdProc( C_START, zero); +} + +static BOOL_T CheckClick(wAction_t *action, coOrd *pos, BOOL_T checkLeft, + BOOL_T checkRight) +{ + static long time0; + static coOrd pos0; + long time1; + long timeDelta; + DIST_T distDelta; + + switch (*action) { + case C_LDOUBLE: + if (!checkLeft) { + return TRUE; + } + time0 = 0; + break; + case C_DOWN: + if (!checkLeft) { + return TRUE; + } + time0 = wGetTimer() - adjTimer; + pos0 = *pos; + return FALSE; + case C_MOVE: + if (!checkLeft) { + return TRUE; + } + if (time0 != 0) { + time1 = wGetTimer() - adjTimer; + timeDelta = time1 - time0; + distDelta = FindDistance(*pos, pos0); + if (timeDelta > dragTimeout || distDelta > dragDistance) { + time0 = 0; + *pos = pos0; + *action = C_DOWN; + } else { + return FALSE; + } + } + break; + case C_UP: + if (!checkLeft) { + return TRUE; + } + if (time0 != 0) { + time1 = wGetTimer() - adjTimer; + timeDelta = time1 - time0; + distDelta = FindDistance(*pos, pos0); + time0 = 0; + *action = C_LCLICK; + } + break; + case C_RDOWN: + if (!checkRight) { + return TRUE; + } + time0 = wGetTimer() - adjTimer; + pos0 = *pos; + return FALSE; + case C_RMOVE: + if (!checkRight) { + return TRUE; + } + if (time0 != 0) { + time1 = wGetTimer() - adjTimer; + timeDelta = time1 - time0; + distDelta = FindDistance(*pos, pos0); + if (timeDelta > dragTimeout || distDelta > dragDistance) { + time0 = 0; + *pos = pos0; + *action = C_RDOWN; + } else { + return FALSE; + } + } + break; + case C_RUP: + if (!checkRight) { + return TRUE; + } + if (time0 != 0) { + time0 = 0; + *action = C_RCLICK; + } + break; + } + return TRUE; +} + +EXPORT wBool_t DoCurCommand(wAction_t action, coOrd pos) +{ + wAction_t rc; + int mode; + wBool_t bExit = FALSE; + + if (action == wActionMove) { + if ((commandList[curCommand].options & IC_WANT_MOVE) == 0) { + bExit = TRUE; + } + } else if ((action&0xFF) == wActionModKey) { + if ((commandList[curCommand].options & IC_WANT_MODKEYS) == 0) { + bExit = TRUE; + } + } else if (!CheckClick(&action, &pos, + (int) (commandList[curCommand].options & IC_LCLICK), TRUE)) { + bExit = TRUE; + } else if (action == C_RCLICK + && (commandList[curCommand].options & IC_RCLICK) == 0) { + if (!inPlayback) { + mode = MyGetKeyState(); + if ((mode & (~WKEY_SHIFT)) != 0) { + wBeep(); + bExit = TRUE; + } else if (((mode & WKEY_SHIFT) == 0) == (rightClickMode == 0)) { + if (selectedTrackCount > 0) { + if (commandList[curCommand].options & IC_CMDMENU) { + } + wMenuPopupShow(popup2M); + } else { + wMenuPopupShow(popup1M); + } + bExit = TRUE; + } else if ((commandList[curCommand].options & IC_CMDMENU)) { + cmdMenuPos = pos; + action = C_CMDMENU; + } else { + wBeep(); + bExit = TRUE; + } + } else { + bExit = TRUE; + } + } + if ( bExit ) { + TempRedraw(); // DoCurCommand: precommand + return C_CONTINUE; + } + + LOG(log_command, 2, + ( "COMMAND MOUSE %s %d @ %0.3f %0.3f\n", commandList[curCommand].helpKey, + (int)action, pos.x, pos.y )) + rc = commandList[curCommand].cmdProc(action, pos); + LOG(log_command, 4, ( " COMMAND returns %d\n", rc )) + switch ( action & 0xFF ) { + case wActionMove: + case wActionModKey: + case C_DOWN: + case C_MOVE: + case C_UP: + case C_RDOWN: + case C_RMOVE: + case C_RUP: + case C_LCLICK: + case C_RCLICK: + case C_TEXT: + case C_OK: + if (rc== C_TERMINATE) { MainRedraw(); } + else { TempRedraw(); } // DoCurCommand: postcommand + break; + default: + break; + } + if ((rc == C_TERMINATE || rc == C_INFO) + && (commandList[curCommand].options & IC_STICKY) + && (commandList[curCommand].stickyMask & stickySet)) { + DYNARR_RESET( trkSeg_t, tempSegs_da ); + UpdateAllElevations(); + if (commandList[curCommand].options & IC_NORESTART) { + return C_CONTINUE; + } + //Make sure we checkpoint even sticky commands + TryCheckPoint(); + LOG(log_command, 1, + ( "COMMAND START %s\n", commandList[curCommand].helpKey )) + wSetCursor(mainD.d,defaultCursor); + rc = commandList[curCommand].cmdProc( C_START, pos); + LOG(log_command, 4, ( " COMMAND returns %d\n", rc )) + switch (rc) { + case C_CONTINUE: + break; + case C_ERROR: + Reset(); +#ifdef VERBOSE + lprintf( "Start returns Error"); +#endif + break; + case C_TERMINATE: + InfoMessage(""); + case C_INFO: + Reset(); + break; + } + } + return rc; +} + +/* + * \parm reset says if the user used Esc rather than undo/redo + */ +EXPORT int ConfirmReset(BOOL_T retry) +{ + wAction_t rc; + if (curCommand != describeCmdInx) { + LOG(log_command, 3, + ( "COMMAND CONFIRM %s\n", commandList[curCommand].helpKey )) + rc = commandList[curCommand].cmdProc( C_CONFIRM, zero); + LOG(log_command, 4, ( " COMMAND returns %d\n", rc )) + if (rc == C_ERROR) { + if (retry) + rc = + wNotice3( + _( + "Cancelling the current command will undo the changes\n" + "you are currently making. Do you want to do the update instead?"), + _("Yes"), _("No"), _("Cancel")); + else + rc = + wNoticeEx( NT_WARNING, + _( + "Cancelling the current command will undo the changes\n" + "you are currently making. Do you want to do the update instead?"), + _("Yes"), _("No")); + if (rc == 1) { + LOG(log_command, 3, + ( "COMMAND OK %s\n", commandList[curCommand].helpKey )) + commandList[curCommand].cmdProc( C_OK, zero); + return C_OK; + } else if (rc == -1) { + return C_CANCEL; + } + } else if (rc == C_TERMINATE) { + return C_TERMINATE; + } + } + if (retry) { + /* because user pressed esc */ + SetAllTrackSelect( FALSE); + } + Reset(); + LOG(log_command, 1, + ( "COMMAND RESET %s\n", commandList[curCommand].helpKey )) + commandList[curCommand].cmdProc( C_START, zero); + return C_CONTINUE; +} + +EXPORT void DoCommandB(void * data) +{ + wIndex_t inx = (wIndex_t)VP2L(data); + STATUS_T rc; + static coOrd pos = { 0, 0 }; + static int inDoCommandB = FALSE; + wIndex_t buttInx; + + if (inDoCommandB) { + return; + } + inDoCommandB = TRUE; + + if (inx < 0 || inx >= commandCnt) { + CHECK(FALSE); + inDoCommandB = FALSE; + return; + } + + if ((!inPlayback) && (!commandList[inx].enabled)) { + ErrorMessage(MSG_COMMAND_DISABLED); + inx = describeCmdInx; + } + + InfoMessage(""); + if (curCommand != selectCmdInx) { + LOG(log_command, 3, + ( "COMMAND FINISH %s\n", commandList[curCommand].helpKey )) + rc = commandList[curCommand].cmdProc( C_FINISH, zero); + LOG(log_command, 3, + ( "COMMAND CONFIRM %s\n", commandList[curCommand].helpKey )) + rc = commandList[curCommand].cmdProc( C_CONFIRM, zero); + LOG(log_command, 4, ( " COMMAND returns %d\n", rc )) + if (rc == C_ERROR) { + rc = wNotice3( + _("Cancelling the current command will undo the changes\n" + "you are currently making. Do you want to update?"), + _("Yes"), _("No"), _("Cancel")); + if (rc == 1) { + commandList[curCommand].cmdProc( C_OK, zero); + } else if (rc == -1) { + inDoCommandB = FALSE; + return; + } + } + LOG(log_command, 3, + ( "COMMAND CANCEL %s\n", commandList[curCommand].helpKey )) + commandList[curCommand].cmdProc( C_CANCEL, pos); + DYNARR_RESET( trkSeg_t, tempSegs_da ); + } else { + LOG(log_command, 3, + ( "COMMAND FINISH %s\n", commandList[curCommand].helpKey )) + rc = commandList[curCommand].cmdProc( C_FINISH, zero); + } + if (commandList[curCommand].buttInx >= 0) + wButtonSetBusy( + (wButton_p) buttonList[commandList[curCommand].buttInx].control, + FALSE); + + if (recordF) { + fprintf(recordF, "COMMAND %s\n", commandList[inx].helpKey + 3); + fflush(recordF); + } + + curCommand = inx; + commandContext = commandList[curCommand].context; + if ((buttInx = commandList[curCommand].buttInx) >= 0) { + if (buttonList[buttInx].cmdInx != curCommand) { + wButtonSetLabel((wButton_p) buttonList[buttInx].control, + (char*) commandList[curCommand].icon); + wControlSetHelp(buttonList[buttInx].control, + GetBalloonHelpStr(commandList[curCommand].helpKey)); + wControlSetContext(buttonList[buttInx].control, + I2VP(curCommand)); + buttonList[buttInx].cmdInx = curCommand; + } + wButtonSetBusy( + (wButton_p) buttonList[commandList[curCommand].buttInx].control, + TRUE); + } + LOG(log_command, 1, + ( "COMMAND START %s\n", commandList[curCommand].helpKey )) + wSetCursor(mainD.d,defaultCursor); + rc = commandList[curCommand].cmdProc( C_START, pos); + LOG(log_command, 4, ( " COMMAND returns %d\n", rc )) + TempRedraw(); // DoCommandB + switch (rc) { + case C_CONTINUE: + break; + case C_ERROR: + Reset(); +#ifdef VERBOSE + lprintf( "Start returns Error"); +#endif + break; + case C_TERMINATE: + case C_INFO: + if (rc == C_TERMINATE) { + InfoMessage(""); + } + Reset(); + break; + } + inDoCommandB = FALSE; +} + +static void LayoutSetPos(wIndex_t inx) +{ + wWinPix_t w, h, offset; + static wWinPix_t toolbarRowHeight = 0; + static wWinPix_t width; + static int lastGroup; + static wWinPix_t gap; + static int layerButtCnt; + static int layerButtNumber; + int currGroup; + + if (inx == 0) { + lastGroup = 0; + wWinGetSize(mainW, &width, &h); + gap = 5; + toolbarWidth = width - 20 + 5; + layerButtCnt = 0; + layerButtNumber = 0; + toolbarHeight = 0; + } + + if (buttonList[inx].control) { + if (toolbarRowHeight <= 0) { + toolbarRowHeight = wControlGetHeight(buttonList[inx].control); + } + + currGroup = buttonList[inx].group & ~BG_BIGGAP; + if (currGroup != lastGroup && (buttonList[inx].group & BG_BIGGAP)) { + gap = 15; + } + if ((toolbarSet & (1 << currGroup)) + && (programMode != MODE_TRAIN + || (buttonList[inx].options + & (IC_MODETRAIN_TOO | IC_MODETRAIN_ONLY))) + && (programMode == MODE_TRAIN + || (buttonList[inx].options & IC_MODETRAIN_ONLY) == 0) + && ((buttonList[inx].group & ~BG_BIGGAP) != BG_LAYER + || layerButtCnt < layerCount)) { + if (currGroup != lastGroup) { + toolbarWidth += gap; + lastGroup = currGroup; + gap = 5; + } + w = wControlGetWidth(buttonList[inx].control); + h = wControlGetHeight(buttonList[inx].control); + if (h<toolbarRowHeight) { + offset = (h-toolbarRowHeight)/2; + h = toolbarRowHeight; //Uniform + } else { offset = 0; } + if (inx < buttonCnt - 1 && (buttonList[inx + 1].options & IC_ABUT)) { + w += wControlGetWidth(buttonList[inx + 1].control); + } + if (toolbarWidth + w > width - 20) { + toolbarWidth = 0; + toolbarHeight += h + 5; + } + if ((currGroup == BG_LAYER) && layerButtNumber>1 + && GetLayerHidden(layerButtNumber-2) ) { + wControlShow(buttonList[inx].control, FALSE); + layerButtNumber++; + } else { + if (currGroup == BG_LAYER ) { + if (layerButtNumber>1) { layerButtCnt++; } // Ignore List and Background + layerButtNumber++; + } + wControlSetPos(buttonList[inx].control, toolbarWidth, + toolbarHeight - (h + 5 +offset)); + buttonList[inx].x = toolbarWidth; + buttonList[inx].y = toolbarHeight - (h + 5 + offset); + toolbarWidth += wControlGetWidth(buttonList[inx].control); + wControlShow(buttonList[inx].control, TRUE); + } + } else { + wControlShow(buttonList[inx].control, FALSE); + } + } +} + +EXPORT void LayoutToolBar( void * data ) +{ + int inx; + + for (inx = 0; inx < buttonCnt; inx++) { + LayoutSetPos(inx); + } + if (toolbarSet&(1<<BG_HOTBAR)) { + LayoutHotBar(data); + } else { + HideHotBar(); + } +} + +static void ToolbarChange(long changes) +{ + if ((changes & CHANGE_TOOLBAR)) { + /*if ( !(changes&CHANGE_MAIN) )*/ + MainProc( mainW, wResize_e, NULL, NULL ); + /*else + LayoutToolBar();*/ + } +} + +/*************************************************************************** + * + * + * + */ + +EXPORT BOOL_T CommandEnabled(wIndex_t cmdInx) +{ + return commandList[cmdInx].enabled; +} + + +EXPORT wIndex_t AddCommand(procCommand_t cmdProc, const char * helpKey, + const char * nameStr, wIcon_p icon, int reqLevel, long options, long acclKey, + wIndex_t buttInx, long stickyMask, wMenuPush_p cmdMenus[NUM_CMDMENUS], + void * context) +{ + CHECK( commandCnt < COMMAND_MAX - 1 ); + commandList[commandCnt].labelStr = MyStrdup(nameStr); + commandList[commandCnt].helpKey = MyStrdup(helpKey); + commandList[commandCnt].cmdProc = cmdProc; + commandList[commandCnt].icon = icon; + commandList[commandCnt].reqLevel = reqLevel; + commandList[commandCnt].enabled = TRUE; + commandList[commandCnt].options = options; + commandList[commandCnt].acclKey = acclKey; + commandList[commandCnt].context = context; + commandList[commandCnt].buttInx = buttInx; + commandList[commandCnt].stickyMask = stickyMask; + commandList[commandCnt].menu[0] = cmdMenus[0]; + commandList[commandCnt].menu[1] = cmdMenus[1]; + commandList[commandCnt].menu[2] = cmdMenus[2]; + commandList[commandCnt].menu[3] = cmdMenus[3]; + if ( buttInx >= 0 && buttonList[buttInx].cmdInx == -1 ) { + // set button back-link + buttonList[buttInx].cmdInx = commandCnt; + } + commandCnt++; + return commandCnt - 1; +} + +EXPORT void AddToolbarControl(wControl_p control, long options) +{ + CHECK( buttonCnt < COMMAND_MAX - 1 ); + buttonList[buttonCnt].enabled = TRUE; + buttonList[buttonCnt].options = options; + buttonList[buttonCnt].group = cmdGroup; + buttonList[buttonCnt].x = 0; + buttonList[buttonCnt].y = 0; + buttonList[buttonCnt].control = control; + buttonList[buttonCnt].cmdInx = -1; + LayoutSetPos(buttonCnt); + buttonCnt++; +} + + +/*--------------------------------------------------------------------*/ + +EXPORT void PlaybackButtonMouse(wIndex_t buttInx) +{ + wWinPix_t cmdX, cmdY; + coOrd pos; + + if (buttInx < 0 || buttInx >= buttonCnt) { + return; + } + if (buttonList[buttInx].control == NULL) { + return; + } + cmdX = buttonList[buttInx].x + 17; + cmdY = toolbarHeight - (buttonList[buttInx].y + 17) + + (wWinPix_t) (mainD.size.y / mainD.scale * mainD.dpi) + 30; + + mainD.Pix2CoOrd( &mainD, cmdX, cmdY, &pos ); + MovePlaybackCursor(&mainD, pos, TRUE, buttonList[buttInx].control); + if (playbackTimer == 0) { + wButtonSetBusy((wButton_p) buttonList[buttInx].control, TRUE); + wFlush(); + wPause(500); + wButtonSetBusy((wButton_p) buttonList[buttInx].control, FALSE); + wFlush(); + } +} + + +EXPORT void PlaybackCommand(const char * line, wIndex_t lineNum) +{ + size_t inx; + wIndex_t buttInx; + size_t len1, len2; + len1 = strlen(line + 8); + for (inx = 0; inx < commandCnt; inx++) { + len2 = strlen(commandList[inx].helpKey + 3); + if (len1 == len2 + && strncmp(line + 8, commandList[inx].helpKey + 3, len2) == 0) { + break; + } + } + if (inx >= commandCnt) { + fprintf(stderr, "Unknown playback COMMAND command %d : %s\n", lineNum, + line); + } else { + wWinPix_t cmdX, cmdY; + coOrd pos; + if ((buttInx = commandList[inx].buttInx) >= 0) { + cmdX = buttonList[buttInx].x + 17; + cmdY = toolbarHeight - (buttonList[buttInx].y + 17) + + (wWinPix_t) (mainD.size.y / mainD.scale * mainD.dpi) + 30; + mainD.Pix2CoOrd( &mainD, cmdX, cmdY, &pos ); + MovePlaybackCursor(&mainD, pos,TRUE,buttonList[buttInx].control); + } + if (strcmp(line + 8, "Undo") == 0) { + if (buttInx > 0 && playbackTimer == 0) { + wButtonSetBusy((wButton_p) buttonList[buttInx].control, TRUE); + wFlush(); + wPause(500); + wButtonSetBusy((wButton_p) buttonList[buttInx].control, FALSE); + wFlush(); + } + UndoUndo(NULL); + } else if (strcmp(line + 8, "Redo") == 0) { + if (buttInx >= 0 && playbackTimer == 0) { + wButtonSetBusy((wButton_p) buttonList[buttInx].control, TRUE); + wFlush(); + wPause(500); + wButtonSetBusy((wButton_p) buttonList[buttInx].control, FALSE); + wFlush(); + } + UndoRedo(NULL); + } else { + if (buttInx >= 0 && playbackTimer == 0) { + wButtonSetBusy((wButton_p) buttonList[buttInx].control, TRUE); + wFlush(); + wPause(500); + wButtonSetBusy((wButton_p) buttonList[buttInx].control, FALSE); + wFlush(); + } + DoCommandB(I2VP(inx)); + } + } +} + +/*--------------------------------------------------------------------*/ + + +EXPORT BOOL_T IsCurCommandSticky(void) +{ + if ((commandList[curCommand].options & IC_STICKY) != 0 + && (commandList[curCommand].stickyMask & stickySet) != 0) { + return TRUE; + } + return FALSE; +} + +EXPORT void ResetIfNotSticky(void) +{ + if ((commandList[curCommand].options & IC_STICKY) == 0 + || (commandList[curCommand].stickyMask & stickySet) == 0) { + Reset(); + } +} + + +/*--------------------------------------------------------------------*/ +EXPORT void CommandInit( void ) +{ + curCommand = describeCmdInx; + commandContext = commandList[curCommand].context; + log_command = LogFindIndex( "command" ); + RegisterChangeNotification(ToolbarChange); +} + diff --git a/app/bin/command.h b/app/bin/command.h new file mode 100644 index 0000000..073e412 --- /dev/null +++ b/app/bin/command.h @@ -0,0 +1,150 @@ +/** \file command.h + * Application wide declarations and defines + */ + +/* XTrkCad - Model Railroad CAD + * Copyright (C) 2005 Dave Bullis + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef COMMAND_H +#define COMMAND_H + +#include "common.h" + +#define IC_STICKY (1<<0) +#define IC_INITNOTSTICKY (1<<1) +#define IC_CANCEL (1<<2) +#define IC_MENU (1<<3) +#define IC_NORESTART (1<<4) +#define IC_SELECTED (1<<5) +#define IC_POPUP (1<<6) +#define IC_LCLICK (1<<7) +#define IC_RCLICK (1<<8) +#define IC_CMDMENU (1<<9) +#define IC_POPUP2 (1<<10) +#define IC_ABUT (1<<11) +#define IC_ACCLKEY (1<<12) +#define IC_MODETRAIN_TOO (1<<13) +#define IC_MODETRAIN_ONLY (1<<14) +#define IC_WANT_MOVE (1<<15) +#define IC_PLAYBACK_PUSH (1<<16) +#define IC_WANT_MODKEYS (1<<17) +#define IC_POPUP3 (1<<18) + + +/* + * Command Action + */ +#define C_DOWN wActionLDown +#define C_MOVE wActionLDrag +#define C_UP wActionLUp +#define C_RDOWN wActionRDown +#define C_RMOVE wActionRDrag +#define C_RUP wActionRUp +#define C_TEXT wActionText +#define C_WUP wActionWheelUp +#define C_WDOWN wActionWheelDown +#define C_LDOUBLE wActionLDownDouble +#define C_MODKEY wActionModKey +#define C_SCROLLUP wActionScrollUp +#define C_SCROLLDOWN wActionScrollDown +#define C_SCROLLLEFT wActionScrollLeft +#define C_SCROLLRIGHT wActionScrollRight +#define C_MDOWN wActionMDown +#define C_MMOVE wActionMDrag +#define C_MUP wActionMUp +#define C_INIT (wActionLast+1) +#define C_START (wActionLast+2) +#define C_REDRAW (wActionLast+3) +#define C_CANCEL (wActionLast+4) +#define C_OK (wActionLast+5) +#define C_CONFIRM (wActionLast+6) +#define C_LCLICK (wActionLast+7) +#define C_RCLICK (wActionLast+8) +#define C_CMDMENU (wActionLast+9) +#define C_FINISH (wActionLast+10) +#define C_UPDATE (wActionLast+11) + +#define C_CONTINUE (100) +#define C_TERMINATE (101) +#define C_INFO (102) +#define C_ERROR (103) + +/* + * Command Levels - obsolete + */ +#define LEVEL0 (0) +#define LEVEL0_50 (1) +#define LEVEL1 (2) +#define LEVEL2 (3) + +/* + * Command groups + */ +#define BG_SELECT (0) +#define BG_ZOOM (1) +#define BG_UNDO (2) +#define BG_EASE (3) +#define BG_TRKCRT (4) +#define BG_TRKMOD (5) +#define BG_TRKGRP (6) +#define BG_MISCCRT (7) +#define BG_RULER (8) +#define BG_LAYER (9) +#define BG_HOTBAR (10) +#define BG_SNAP (11) +#define BG_TRAIN (12) +#define BG_COUNT (13) +#define BG_FILE (14) +#define BG_CONTROL (15) +#define BG_EXPORTIMPORT (16) +#define BG_PRINT (17) +#define BG_BIGGAP (1<<8) +extern int cmdGroup; + + +extern int buttonCnt; +extern int commandCnt; +extern int cmdGroup; +extern long toolbarSet; +extern wWinPix_t toolbarHeight; +extern long preSelect; +extern long rightClickMode; +extern void * commandContext; +extern coOrd cmdMenuPos; + +const char * GetCurCommandName( void ); +void EnableCommands( void ); +wIndex_t GetCurrentCommand(void); +void Reset( void ); +wBool_t DoCurCommand( wAction_t, coOrd ); +int ConfirmReset( BOOL_T ); +void DoCommandB( void * ); +void LayoutToolBar( void * ); +BOOL_T CommandEnabled( wIndex_t ); +#define NUM_CMDMENUS (4) +wIndex_t AddCommand(procCommand_t cmdProc, const char * helpKey, + const char * nameStr, wIcon_p icon, int reqLevel, long options, long acclKey, + wIndex_t buttInx, long stickyMask, wMenuPush_p cmdMenus[NUM_CMDMENUS], + void * context); +void AddToolbarControl( wControl_p, long ); +void PlaybackButtonMouse( wIndex_t ); +void PlaybackCommand( const char *, wIndex_t ); +BOOL_T IsCurCommandSticky(void); +void ResetIfNotSticky( void ); +void CommandInit( void ); +#endif diff --git a/app/bin/common-ui.h b/app/bin/common-ui.h index 893dbc7..e34c4a9 100644 --- a/app/bin/common-ui.h +++ b/app/bin/common-ui.h @@ -1,5 +1,5 @@ /** \file common-ui.h - * Defnitions of message and other UI types + * Defnitions of message and other UI types */ /* XTrkCad - Model Railroad CAD @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* Do not include this file in header (.h) files */ diff --git a/app/bin/common.h b/app/bin/common.h index 92620f2..f03a04c 100644 --- a/app/bin/common.h +++ b/app/bin/common.h @@ -17,14 +17,13 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef COMMON_H #define COMMON_H // INCLUDES -#include <assert.h> #include <ctype.h> #include <errno.h> #include <locale.h> @@ -38,10 +37,6 @@ #include <sys/types.h> #include <time.h> -#ifdef HAVE_MALLOC_H -#include <malloc.h> -#endif - #include "wlib.h" #ifndef WINDOWS @@ -119,6 +114,8 @@ typedef double FLOAT_T; typedef double POS_T; typedef double DIST_T; typedef double ANGLE_T; +typedef double LWIDTH_T; + #define SCANF_FLOAT_FORMAT "%lf" typedef double DOUBLE_T; @@ -126,8 +123,8 @@ typedef double WDOUBLE_T; typedef double FONTSIZE_T; typedef struct { - POS_T x,y; - } coOrd; + POS_T x,y; +} coOrd; typedef struct { coOrd pt; @@ -148,48 +145,80 @@ typedef signed char TRKTYP_T; typedef int TRKINX_T; typedef long DEBUGF_T; typedef int REGION_T; +typedef long SCALEINX_T; +typedef long GAUGEINX_T; +typedef long SCALEDESCINX_T; -enum paramFileState { PARAMFILE_UNLOADED = 0, PARAMFILE_NOTUSABLE, PARAMFILE_COMPATIBLE, PARAMFILE_FIT, PARAMFILE_MAXSTATE }; -#define SCALE_ANY (-2) -#define SCALE_DEMO (-1) +enum paramFileState { PARAMFILE_UNLOADED = 0, PARAMFILE_NOTUSABLE, PARAMFILE_COMPATIBLE, PARAMFILE_FIT, PARAMFILE_MAXSTATE }; // DYNARRAY typedef struct { - int cnt; - int max; - void * ptr; - } dynArr_t; + int cnt; + int max; + void * ptr; +} dynArr_t; #define CHECK_SIZE(T,DA) +/** + * Append INCR mambers to DA + * INCR is > 1 if we plan to add more members soon + * Increments .cnt for the next member + * Note: new members may not be empty + */ #define DYNARR_APPEND(T,DA,INCR) \ { if ((DA).cnt >= (DA).max) { \ - (DA).max += INCR; \ - CHECK_SIZE(T,DA) \ + (DA).max += (INCR); \ + CHECK_SIZE((T),(DA)) \ (DA).ptr = MyRealloc( (DA).ptr, (DA).max * sizeof *(T*)NULL ); \ if ( (DA).ptr == NULL ) \ abort(); \ } \ (DA).cnt++; } -#define DYNARR_ADD(T,DA,INCR) DYNARR_APPEND(T,DA,INCR) +/** + * Return Last member of DA + */ #define DYNARR_LAST(T,DA) \ (((T*)(DA).ptr)[(DA).cnt-1]) +/** + * Return N't member of DA + */ #define DYNARR_N(T,DA,N) \ (((T*)(DA).ptr)[N]) +/** + * Logically empty the DA + * .max and .ptr are untouched + */ #define DYNARR_RESET(T,DA) \ (DA).cnt=0 +/** + * Set number of members to N + * If extending (.cnt > .max ), new values will be 0'd, otherwise not + */ #define DYNARR_SET(T,DA,N) \ - { if ((DA).max < N) { \ - (DA).max = N; \ - CHECK_SIZE(T,DA) \ + { if ((DA).max < (N)) { \ + (DA).max = (N); \ + CHECK_SIZE((T),(DA)) \ (DA).ptr = MyRealloc( (DA).ptr, (DA).max * sizeof *(T*)NULL ); \ if ( (DA).ptr == NULL ) \ abort(); \ } \ - (DA).cnt = N; } + (DA).cnt = (N); } +/** + * Initializes DA to empty when .ptr might be garbage (ie local vars) + * All fields are cleared + */ +#define DYNARR_INIT(T,DA) \ + { (DA).ptr = NULL; \ + (DA).max = 0; \ + (DA).cnt = 0; \ + } +/** + * Initializes DA to empty and frees .ptr + */ #define DYNARR_FREE(T,DA) \ { if ((DA).ptr) { \ MyFree( (DA).ptr); \ @@ -197,15 +226,19 @@ typedef struct { } \ (DA).max = 0; \ (DA).cnt = 0; } -#define DYNARR_REMOVE(T,DA,I) \ +/** + * Removes N'th member from DA + * (Not used) + */ +#define DYNARR_REMOVE(T,DA,N) \ { \ - { if ((DA).cnt-1 > I) { \ - for (int i=I;i<(DA).cnt-1;i++) { \ + { if ((DA).cnt-1 > (N)) { \ + for (int i=(N);i<(DA).cnt-1;i++) { \ (((T*)(DA).ptr)[i])= (((T*)(DA).ptr)[i+1]); \ } \ } \ } \ - if ((DA.cnt)>=I) (DA).cnt--; \ + if ((DA).cnt>=(N)) (DA).cnt--; \ } // Base DotsPerInch @@ -223,14 +256,19 @@ typedef struct { // FORWARD TYPE DECLS typedef struct drawCmd_t * drawCmd_p; typedef struct track_t * track_p; +typedef struct track_t * track_cp; typedef struct trkSeg_t * trkSeg_p; typedef struct traverseTrack_t * traverseTrack_p; typedef struct trkEndPt_t * trkEndPt_p; +typedef void (*doSaveCallBack_p)( void ); +typedef void (*addButtonCallBack_t)(void*); +typedef STATUS_T (*procCommand_t) (wAction_t, coOrd); + // base class for extraData*_t: each of which must include this struct as the first element typedef struct extraDataBase_t { - TRKTYP_T trkType; - } extraDataBase_t; + TRKTYP_T trkType; +} extraDataBase_t; // We check if TRKTYP_T in trk, trk->extraDataBase and the code context (TRKTYP) match. // If TRKTYP is T_NOTRACK then we are dealing with T_TURNOUT/T_STRUCTURE or T_BEZIER/T_BEZLIN which // share a log of code and have the same extraData*_t structure. @@ -238,12 +276,43 @@ typedef struct extraDataBase_t { ((TYPE*)GetTrkExtraData( (TRK), (TRKTYP) )) extraDataBase_t * GetTrkExtraData( track_p, TRKTYP_T ); + +typedef struct { + BOOL_T valid; + DIST_T length; + DIST_T width; + DIST_T spacing; +} tieData_t, *tieData_p; + +// Syntactic suger for exported (non-static) objects +#define EXPORT + +#define COUNT(A) (sizeof(A)/sizeof(A[0])) + +#define STR_SIZE (256) +#define STR_SHORT_SIZE (80) +#define STR_LONG_SIZE (1024) +#define STR_HUGE_SIZE (10240) + +#define CAST_AWAY_CONST (char*) + +#define TITLEMAXLEN (40) + + + // COMMON INCLUDES // If you add includes here, please remove them elsewhere #include "i18n.h" #include "utility.h" +#include "acclkeys.h" #include "misc.h" +// TODO - move these includes to the files that need them +#include "dlayer.h" +#include "scale.h" +#include "command.h" +#include "menu.h" + #endif diff --git a/app/bin/compound.c b/app/bin/compound.c index b6d5847..dea754d 100644 --- a/app/bin/compound.c +++ b/app/bin/compound.c @@ -18,7 +18,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "tbezier.h" @@ -30,6 +30,7 @@ #include "fileio.h" #include "shrtpath.h" #include "track.h" +#include "trkendpt.h" #include "draw.h" #include "include/paramfile.h" #include "common-ui.h" @@ -50,7 +51,8 @@ */ EXPORT PATHPTR_T GetPaths( track_p trk ) { - struct extraDataCompound_t * xx = GET_EXTRA_DATA( trk, T_NOTRACK, extraDataCompound_t ); + struct extraDataCompound_t * xx = GET_EXTRA_DATA( trk, T_NOTRACK, + extraDataCompound_t ); if ( GetTrkType(trk) == T_STRUCTURE && xx->paths != NULL ) { LogPrintf( "GetPaths( STRUCTURE, paths!=NULL )\n" ); } @@ -70,7 +72,7 @@ EXPORT PATHPTR_T GetPaths( track_p trk ) EXPORT wIndex_t GetPathsLength( PATHPTR_T paths ) { PATHPTR_T pp; - ASSERT( paths != NULL ); + CHECK( paths != NULL ); for ( pp = paths; pp[0]; pp+=2 ) for ( pp += strlen( (char*)pp ); pp[0] || pp[1]; pp++ ); return (wIndex_t)(pp - paths + 1); @@ -96,9 +98,11 @@ EXPORT void SetPaths( track_p trk, PATHPTR_T paths ) LogPrintf( "SetPaths( TURNOUT, paths==NULL )\n" ); } - struct extraDataCompound_t * xx = GET_EXTRA_DATA( trk, T_NOTRACK, extraDataCompound_t ); - if ( xx->paths ) + struct extraDataCompound_t * xx = GET_EXTRA_DATA( trk, T_NOTRACK, + extraDataCompound_t ); + if ( xx->paths ) { MyFree( xx->paths ); + } if ( paths == NULL ) { xx->paths = NULL; } else { @@ -121,13 +125,15 @@ EXPORT void SetPaths( track_p trk, PATHPTR_T paths ) */ EXPORT PATHPTR_T GetCurrPath( track_p trk ) { - struct extraDataCompound_t * xx = GET_EXTRA_DATA( trk, T_TURNOUT, extraDataCompound_t ); - if ( xx->currPath ) + struct extraDataCompound_t * xx = GET_EXTRA_DATA( trk, T_TURNOUT, + extraDataCompound_t ); + if ( xx->currPath ) { return xx->currPath; + } PATHPTR_T path = GetPaths( trk ); for ( wIndex_t position = xx->currPathIndex; - position > 0 && path[0]; - path+=2, position-- ) { + position > 0 && path[0]; + path+=2, position-- ) { for ( path += strlen( (char*)path ); path[0] || path[1]; path++ ); } if ( !path[0] ) { @@ -141,18 +147,22 @@ EXPORT PATHPTR_T GetCurrPath( track_p trk ) EXPORT long GetCurrPathIndex( track_p trk ) { - if ( GetTrkType( trk ) != T_TURNOUT ) + if ( GetTrkType( trk ) != T_TURNOUT ) { return 0; - struct extraDataCompound_t * xx = GET_EXTRA_DATA( trk, T_TURNOUT, extraDataCompound_t ); + } + struct extraDataCompound_t * xx = GET_EXTRA_DATA( trk, T_TURNOUT, + extraDataCompound_t ); return xx->currPathIndex; } EXPORT void SetCurrPathIndex( track_p trk, long position ) { - if ( GetTrkType( trk ) != T_TURNOUT ) + if ( GetTrkType( trk ) != T_TURNOUT ) { return; - struct extraDataCompound_t * xx = GET_EXTRA_DATA( trk, T_TURNOUT, extraDataCompound_t ); + } + struct extraDataCompound_t * xx = GET_EXTRA_DATA( trk, T_TURNOUT, + extraDataCompound_t ); xx->currPathIndex = position; xx->currPath = NULL; } @@ -173,7 +183,7 @@ PATHPTR_T GetParamPaths( turnoutInfo_t * to ) * * Set paths for a Turnout Parameter 'to' * Used when creating a new turnout def'n - * + * * \param to IN * \param paths IN */ @@ -195,12 +205,12 @@ void SetParamPaths( turnoutInfo_t * to, PATHPTR_T paths ) */ EXPORT BOOL_T WriteCompoundPathsEndPtsSegs( - FILE * f, - PATHPTR_T paths, - wIndex_t segCnt, - trkSeg_p segs, - EPINX_T endPtCnt, - trkEndPt_t * endPts ) + FILE * f, + PATHPTR_T paths, + wIndex_t segCnt, + trkSeg_p segs, + EPINX_T endPtCnt, + trkEndPt_p endPts ) { int i; PATHPTR_T pp; @@ -209,27 +219,30 @@ EXPORT BOOL_T WriteCompoundPathsEndPtsSegs( if ( paths ) { for ( pp=paths; *pp; pp+=2 ) { rc &= fprintf( f, "\tP \"%s\"", pp )>0; - for ( pp+=strlen((char *)pp)+1; pp[0]!=0 || pp[1]!=0; pp++ ) + for ( pp+=strlen((char *)pp)+1; pp[0]!=0 || pp[1]!=0; pp++ ) { rc &= fprintf( f, " %d", pp[0] )>0; + } rc &= fprintf( f, "\n" )>0; } } - for ( i=0; i<endPtCnt; i++ ) + for ( i=0; i<endPtCnt; i++ ) { + trkEndPt_p epp = EndPtIndex( endPts, i ); rc &= fprintf( f, "\tE %0.6f %0.6f %0.6f\n", - endPts[i].pos.x, endPts[i].pos.y, endPts[i].angle )>0; + GetEndPtPos(epp).x, GetEndPtPos(epp).y, GetEndPtAngle(epp) ) > 0; + } rc &= WriteSegs( f, segCnt, segs )>0; return rc; } EXPORT void ParseCompoundTitle( - char * title, - char * * manufP, - int * manufL, - char * * nameP, - int * nameL, - char * * partnoP, - int * partnoL ) + char * title, + char * * manufP, + int * manufL, + char * * nameP, + int * nameL, + char * * partnoP, + int * partnoL ) { char * cp1, *cp2; size_t len; @@ -256,10 +269,12 @@ EXPORT void ParseCompoundTitle( } } +EXPORT long listLabels = 7; +EXPORT long layoutLabels = 1; -void FormatCompoundTitle( - long format, - char * title ) +EXPORT void FormatCompoundTitle( + long format, + char * title ) { char *cp1, *cp2=NULL, *cq; size_t len; @@ -277,8 +292,9 @@ void FormatCompoundTitle( cq += strlen(cq); } cp1 = strchr( title, '\t' ); - if ( cp1 != NULL ) + if ( cp1 != NULL ) { cp2 = strchr( cp1+1, '\t' ); + } if (cp2 == NULL) { if ( (format&LABEL_TABBED) ) { *cq++ = '\t'; @@ -339,7 +355,7 @@ void FormatCompoundTitle( void ComputeCompoundBoundingBox( - track_p trk ) + track_p trk ) { struct extraDataCompound_t *xx; coOrd hi, lo; @@ -359,32 +375,33 @@ turnoutInfo_t * FindCompound( long type, char * scale, char * title ) wIndex_t inx; SCALEINX_T scaleInx; - if ( scale ) + if ( scale ) { scaleInx = LookupScale( scale ); - else + } else { scaleInx = -1; + } if ( type&FIND_TURNOUT ) - for (inx=0; inx<turnoutInfo_da.cnt; inx++) { - to = turnoutInfo(inx); - if ( IsParamValid(to->paramFileIndex) && - to->segCnt > 0 && - (scaleInx == -1 || to->scaleInx == scaleInx ) && - to->segCnt != 0 && - strcmp( to->title, title ) == 0 ) { - return to; + for (inx=0; inx<turnoutInfo_da.cnt; inx++) { + to = turnoutInfo(inx); + if ( IsParamValid(to->paramFileIndex) && + to->segCnt > 0 && + (scaleInx == -1 || to->scaleInx == scaleInx ) && + to->segCnt != 0 && + strcmp( to->title, title ) == 0 ) { + return to; + } } - } if ( type&FIND_STRUCT ) - for (inx=0; inx<structureInfo_da.cnt; inx++) { - to = structureInfo(inx); - if ( IsParamValid(to->paramFileIndex) && - to->segCnt > 0 && - (scaleInx == -1 || to->scaleInx == scaleInx ) && - to->segCnt != 0 && - strcmp( to->title, title ) == 0 ) { - return to; + for (inx=0; inx<structureInfo_da.cnt; inx++) { + to = structureInfo(inx); + if ( IsParamValid(to->paramFileIndex) && + to->segCnt > 0 && + (scaleInx == -1 || to->scaleInx == scaleInx ) && + to->segCnt != 0 && + strcmp( to->title, title ) == 0 ) { + return to; + } } - } return NULL; } @@ -402,13 +419,17 @@ EXPORT void CompoundClearDemoDefns( void ) for (inx=0; inx<turnoutInfo_da.cnt; inx++) { to = turnoutInfo(inx); - if ( to->paramFileIndex == PARAM_CUSTOM && strcasecmp( GetScaleName(to->scaleInx), "DEMO" ) == 0 ) + if ( to->paramFileIndex == PARAM_CUSTOM + && strcasecmp( GetScaleName(to->scaleInx), "DEMO" ) == 0 ) { to->segCnt = 0; + } } for (inx=0; inx<structureInfo_da.cnt; inx++) { to = structureInfo(inx); - if ( to->paramFileIndex == PARAM_CUSTOM && strcasecmp( GetScaleName(to->scaleInx), "DEMO" ) == 0 ) + if ( to->paramFileIndex == PARAM_CUSTOM + && strcasecmp( GetScaleName(to->scaleInx), "DEMO" ) == 0 ) { to->segCnt = 0; + } } } @@ -419,13 +440,14 @@ EXPORT void CompoundClearDemoDefns( void ) */ void SetDescriptionOrig( - track_p trk ) + track_p trk ) { - struct extraDataCompound_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, extraDataCompound_t); + struct extraDataCompound_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, + extraDataCompound_t); int i, j; coOrd p0, p1; - for (i=0,j=-1;i<xx->segCnt;i++) { + for (i=0,j=-1; i<xx->segCnt; i++) { if ( IsSegTrack( &xx->segs[i] ) ) { if (j == -1) { j = i; @@ -438,8 +460,8 @@ void SetDescriptionOrig( if (j != -1 && xx->segs[j].type == SEG_CRVTRK) { REORIGIN( p0, xx->segs[j].u.c.center, xx->angle, xx->orig ) Translate( &p0, p0, - xx->segs[j].u.c.a0 + xx->segs[j].u.c.a1/2.0 + xx->angle, - fabs(xx->segs[j].u.c.radius) ); + xx->segs[j].u.c.a0 + xx->segs[j].u.c.a1/2.0 + xx->angle, + fabs(xx->segs[j].u.c.radius) ); } else { GetBoundingBox( trk, (&p0), (&p1) ); @@ -453,31 +475,38 @@ void SetDescriptionOrig( void DrawCompoundDescription( - track_p trk, - drawCmd_p d, - wDrawColor color ) + track_p trk, + drawCmd_p d, + wDrawColor color ) { wFont_p fp; coOrd p1; - struct extraDataCompound_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, extraDataCompound_t); + struct extraDataCompound_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, + extraDataCompound_t); char * desc; long layoutLabelsOption = layoutLabels; - if (layoutLabels == 0) + if (layoutLabels == 0) { return; - if ((labelEnable&LABELENABLE_TRKDESC)==0) + } + if ((labelEnable&LABELENABLE_TRKDESC)==0) { return; - if ( (d->options&(DC_SIMPLE|DC_SEGTRACK)) ) + } + if ( (d->options&(DC_SIMPLE|DC_SEGTRACK)) ) { return; + } if ( xx->special == TOpier ) { desc = xx->u.pier.name; } else { - if ( xx->flipped ) + if ( xx->flipped ) { layoutLabelsOption |= LABEL_FLIPPED; - if ( xx->ungrouped ) + } + if ( xx->ungrouped ) { layoutLabelsOption |= LABEL_UNGROUPED; - if ( xx->split ) + } + if ( xx->split ) { layoutLabelsOption |= LABEL_SPLIT; + } FormatCompoundTitle( layoutLabelsOption, xtitle(xx) ); desc = message; } @@ -492,45 +521,51 @@ void DrawCompoundDescription( DrawLine( d, p0, p1, 0, color ); } fp = wStandardFont( F_TIMES, FALSE, FALSE ); - DrawBoxedString( (xx->special==TOpier)?BOX_INVERT:BOX_NONE, d, p1, desc, fp, (wFontSize_t)descriptionFontSize, color, 0.0 ); + DrawBoxedString( (xx->special==TOpier)?BOX_INVERT:BOX_NONE, d, p1, desc, fp, + (wFontSize_t)descriptionFontSize, color, 0.0 ); } DIST_T CompoundDescriptionDistance( - coOrd pos, - track_p trk, - coOrd * dpos, - BOOL_T show_hidden, - BOOL_T * hidden) + coOrd pos, + track_p trk, + coOrd * dpos, + BOOL_T show_hidden, + BOOL_T * hidden) { coOrd p1; - if (GetTrkType(trk) != T_TURNOUT && GetTrkType(trk) != T_STRUCTURE) + if (GetTrkType(trk) != T_TURNOUT && GetTrkType(trk) != T_STRUCTURE) { return DIST_INF; - struct extraDataCompound_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, extraDataCompound_t); - if ( ((GetTrkBits( trk ) & TB_HIDEDESC) != 0 ) && !show_hidden) + } + struct extraDataCompound_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, + extraDataCompound_t); + if ( ((GetTrkBits( trk ) & TB_HIDEDESC) != 0 ) && !show_hidden) { return DIST_INF; + } p1 = xx->descriptionOrig; coOrd offset = xx->descriptionOff; - if ( (GetTrkBits( trk ) & TB_HIDEDESC) != 0 ) offset = zero; + if ( (GetTrkBits( trk ) & TB_HIDEDESC) != 0 ) { offset = zero; } Rotate( &p1, zero, xx->angle ); p1.x += xx->orig.x + offset.x; p1.y += xx->orig.y + offset.y; - if (hidden) *hidden = (GetTrkBits( trk ) & TB_HIDEDESC); + if (hidden) { *hidden = (GetTrkBits( trk ) & TB_HIDEDESC); } *dpos = p1; coOrd tpos = pos; - if (DistanceCompound(trk,&tpos)<FindDistance( p1, pos )) + if (DistanceCompound(trk,&tpos)<FindDistance( p1, pos )) { return DistanceCompound(trk,&pos); + } return FindDistance( p1, pos ); } STATUS_T CompoundDescriptionMove( - track_p trk, - wAction_t action, - coOrd pos ) + track_p trk, + wAction_t action, + coOrd pos ) { - struct extraDataCompound_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, extraDataCompound_t); + struct extraDataCompound_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, + extraDataCompound_t); static coOrd p0, p1; static BOOL_T editMode; wDrawColor color; @@ -578,9 +613,9 @@ STATUS_T CompoundDescriptionMove( */ EXPORT void SetSegInxEP( - signed char * segChar, - int segInx, - EPINX_T segEP ) + signed char * segChar, + int segInx, + EPINX_T segEP ) { if (segEP == 1) { * segChar = -(segInx+1); @@ -591,9 +626,9 @@ EXPORT void SetSegInxEP( } EXPORT void GetSegInxEP( - signed char segChar, - int * segInx, - EPINX_T * segEP ) + signed char segChar, + int * segInx, + EPINX_T * segEP ) { int inx; inx = segChar; @@ -608,12 +643,14 @@ EXPORT void GetSegInxEP( DIST_T DistanceCompound( - track_p t, - coOrd * p ) + track_p t, + coOrd * p ) { - struct extraDataCompound_t *xx = GET_EXTRA_DATA(t, T_NOTRACK, extraDataCompound_t); + struct extraDataCompound_t *xx = GET_EXTRA_DATA(t, T_NOTRACK, + extraDataCompound_t); EPINX_T ep; - DIST_T d0, d1; + DIST_T d0; +// DIST_T d1; coOrd p0, p2; PATHPTR_T path; int segInx; @@ -637,7 +674,7 @@ DIST_T DistanceCompound( path = GetCurrPath( t ); for ( path += strlen((char *)path)+1; path[0] || path[1]; path++ ) { if ( path[0] != 0 ) { - d1 = DIST_INF; +// d1 = DIST_INF; GetSegInxEP( *path, &segInx, &segEP ); segProcData.distance.pos1 = p0; SegProc( SEGPROC_DISTANCE, &xx->segs[segInx], &segProcData ); @@ -659,64 +696,67 @@ DIST_T DistanceCompound( static struct { - coOrd endPt[4]; - ANGLE_T endAngle[4]; - DIST_T endRadius[4]; - coOrd endCenter[4]; - FLOAT_T elev[4]; - coOrd orig; - ANGLE_T angle; - descPivot_t pivot; - char manuf[STR_SIZE]; - char name[STR_SIZE]; - char partno[STR_SIZE]; - long epCnt; - long segCnt; - long pathCnt; - FLOAT_T grade; - DIST_T length; - drawLineType_e linetype; - unsigned int layerNumber; - } compoundData; + coOrd endPt[4]; + ANGLE_T endAngle[4]; + DIST_T endRadius[4]; + coOrd endCenter[4]; + FLOAT_T elev[4]; + coOrd orig; + ANGLE_T angle; + descPivot_t pivot; + char manuf[STR_SIZE]; + char name[STR_SIZE]; + char partno[STR_SIZE]; + long epCnt; + long segCnt; + long pathCnt; + FLOAT_T grade; + DIST_T length; + drawLineType_e linetype; + unsigned int layerNumber; +} compoundData; typedef enum { E0, A0, C0, R0, Z0, E1, A1, C1, R1, Z1, E2, A2, C2, R2, Z2, E3, A3, C3, R3, Z3, GR, OR, AN, PV, MN, NM, PN, LT, SC, LY } compoundDesc_e; static descData_t compoundDesc[] = { -/*E0*/ { DESC_POS, N_("End Pt 1: X,Y"), &compoundData.endPt[0] }, -/*A0*/ { DESC_ANGLE, N_("Angle"), &compoundData.endAngle[0] }, -/*C0*/ { DESC_POS, N_("Center X,Y"), &compoundData.endCenter[0] }, -/*R0*/ { DESC_DIM, N_("Radius"), &compoundData.endRadius[0] }, -/*Z0*/ { DESC_DIM, N_("Z1"), &compoundData.elev[0] }, -/*E1*/ { DESC_POS, N_("End Pt 2: X,Y"), &compoundData.endPt[1] }, -/*A1*/ { DESC_ANGLE, N_("Angle"), &compoundData.endAngle[1] }, -/*C1*/ { DESC_POS, N_("Center X,Y"), &compoundData.endCenter[1] }, -/*R1*/ { DESC_DIM, N_("Radius"), &compoundData.endRadius[1] }, -/*Z1*/ { DESC_DIM, N_("Z2"), &compoundData.elev[1] }, -/*E2*/ { DESC_POS, N_("End Pt 3: X,Y"), &compoundData.endPt[2] }, -/*A2*/ { DESC_ANGLE, N_("Angle"), &compoundData.endAngle[2] }, -/*C2*/ { DESC_POS, N_("Center X,Y"), &compoundData.endCenter[2] }, -/*R2*/ { DESC_DIM, N_("Radius"), &compoundData.endRadius[2] }, -/*Z2*/ { DESC_DIM, N_("Z3"), &compoundData.elev[2] }, -/*E3*/ { DESC_POS, N_("End Pt 4: X,Y"), &compoundData.endPt[3] }, -/*A3*/ { DESC_ANGLE, N_("Angle"), &compoundData.endAngle[3] }, -/*C3*/ { DESC_POS, N_("Center X,Y"), &compoundData.endCenter[3] }, -/*R3*/ { DESC_DIM, N_("Radius"), &compoundData.endRadius[3] }, -/*Z3*/ { DESC_DIM, N_("Z4"), &compoundData.elev[3] }, -/*GR*/ { DESC_FLOAT, N_("Grade"), &compoundData.grade }, -/*OR*/ { DESC_POS, N_("Origin: X,Y"), &compoundData.orig }, -/*AN*/ { DESC_ANGLE, N_("Angle"), &compoundData.angle }, -/*PV*/ { DESC_PIVOT, N_("Pivot"), &compoundData.pivot }, -/*MN*/ { DESC_STRING, N_("Manufacturer"), &compoundData.manuf, sizeof(compoundData.manuf)}, -/*NM*/ { DESC_STRING, N_("Name"), &compoundData.name, sizeof(compoundData.name) }, -/*PN*/ { DESC_STRING, N_("Part No"), &compoundData.partno, sizeof(compoundData.partno)}, -/*LT*/ { DESC_LIST, N_("LineType"), &compoundData.linetype }, -/*SC*/ { DESC_LONG, N_("# Segments"), &compoundData.segCnt }, -/*LY*/ { DESC_LAYER, N_("Layer"), &compoundData.layerNumber }, - { DESC_NULL } }; + /*E0*/ { DESC_POS, N_("End Pt 1: X,Y"), &compoundData.endPt[0] }, + /*A0*/ { DESC_ANGLE, N_("Angle"), &compoundData.endAngle[0] }, + /*C0*/ { DESC_POS, N_("Center X,Y"), &compoundData.endCenter[0] }, + /*R0*/ { DESC_DIM, N_("Radius"), &compoundData.endRadius[0] }, + /*Z0*/ { DESC_DIM, N_("Z1"), &compoundData.elev[0] }, + /*E1*/ { DESC_POS, N_("End Pt 2: X,Y"), &compoundData.endPt[1] }, + /*A1*/ { DESC_ANGLE, N_("Angle"), &compoundData.endAngle[1] }, + /*C1*/ { DESC_POS, N_("Center X,Y"), &compoundData.endCenter[1] }, + /*R1*/ { DESC_DIM, N_("Radius"), &compoundData.endRadius[1] }, + /*Z1*/ { DESC_DIM, N_("Z2"), &compoundData.elev[1] }, + /*E2*/ { DESC_POS, N_("End Pt 3: X,Y"), &compoundData.endPt[2] }, + /*A2*/ { DESC_ANGLE, N_("Angle"), &compoundData.endAngle[2] }, + /*C2*/ { DESC_POS, N_("Center X,Y"), &compoundData.endCenter[2] }, + /*R2*/ { DESC_DIM, N_("Radius"), &compoundData.endRadius[2] }, + /*Z2*/ { DESC_DIM, N_("Z3"), &compoundData.elev[2] }, + /*E3*/ { DESC_POS, N_("End Pt 4: X,Y"), &compoundData.endPt[3] }, + /*A3*/ { DESC_ANGLE, N_("Angle"), &compoundData.endAngle[3] }, + /*C3*/ { DESC_POS, N_("Center X,Y"), &compoundData.endCenter[3] }, + /*R3*/ { DESC_DIM, N_("Radius"), &compoundData.endRadius[3] }, + /*Z3*/ { DESC_DIM, N_("Z4"), &compoundData.elev[3] }, + /*GR*/ { DESC_FLOAT, N_("Grade"), &compoundData.grade }, + /*OR*/ { DESC_POS, N_("Origin: X,Y"), &compoundData.orig }, + /*AN*/ { DESC_ANGLE, N_("Angle"), &compoundData.angle }, + /*PV*/ { DESC_PIVOT, N_("Pivot"), &compoundData.pivot }, + /*MN*/ { DESC_STRING, N_("Manufacturer"), &compoundData.manuf, sizeof(compoundData.manuf)}, + /*NM*/ { DESC_STRING, N_("Name"), &compoundData.name, sizeof(compoundData.name) }, + /*PN*/ { DESC_STRING, N_("Part No"), &compoundData.partno, sizeof(compoundData.partno)}, + /*LT*/ { DESC_LIST, N_("LineType"), &compoundData.linetype }, + /*SC*/ { DESC_LONG, N_("# Segments"), &compoundData.segCnt }, + /*LY*/ { DESC_LAYER, N_("Layer"), &compoundData.layerNumber }, + { DESC_NULL } +}; #define MAX_DESCRIBE_ENDS 4 -static void UpdateCompound( track_p trk, int inx, descData_p descUpd, BOOL_T needUndoStart ) +static void UpdateCompound( track_p trk, int inx, descData_p descUpd, + BOOL_T needUndoStart ) { - struct extraDataCompound_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, extraDataCompound_t); + struct extraDataCompound_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, + extraDataCompound_t); const char * manufS, * nameS, * partnoS; char * mP, *nP, *pP; int mL, nL, pL; @@ -733,18 +773,19 @@ static void UpdateCompound( track_p trk, int inx, descData_p descUpd, BOOL_T nee case PN: titleChanged = FALSE; ParseCompoundTitle( xtitle(xx), &mP, &mL, &nP, &nL, &pP, &pL ); - if (mP == NULL) mP = ""; - if (nP == NULL) nP = ""; - if (pP == NULL) pP = ""; + if (mP == NULL) { mP = ""; } + if (nP == NULL) { nP = ""; } + if (pP == NULL) { pP = ""; } manufS = wStringGetValue( (wString_p)compoundDesc[MN].control0 ); size_t max_manustr = 256, max_partstr = 256, max_namestr = 256; - if (compoundDesc[MN].max_string) + if (compoundDesc[MN].max_string) { max_manustr = compoundDesc[MN].max_string-1; + } if (strlen(manufS)>max_manustr) { NoticeMessage2(0, MSG_ENTERED_STRING_TRUNCATED, _("Ok"), NULL, max_manustr-1); } message[0] = '\0'; - strncat( message, manufS, max_manustr-1 ); + strncat( message, manufS, max_manustr-1 ); if ( strncmp( manufS, mP, mL ) != 0 || mL != strlen(manufS) ) { titleChanged = TRUE; } @@ -753,8 +794,9 @@ static void UpdateCompound( track_p trk, int inx, descData_p descUpd, BOOL_T nee split = xx->split; nameS = wStringGetValue( (wString_p)compoundDesc[NM].control0 ); max_namestr = 256; - if (compoundDesc[NM].max_string) + if (compoundDesc[NM].max_string) { max_namestr = compoundDesc[NM].max_string; + } if (strlen(nameS)>max_namestr) { NoticeMessage2(0, MSG_ENTERED_STRING_TRUNCATED, _("Ok"), NULL, max_namestr-1); } @@ -777,17 +819,18 @@ static void UpdateCompound( track_p trk, int inx, descData_p descUpd, BOOL_T nee split = FALSE; } if ( strncmp( nameS, nP, nL ) != 0 || nL != strlen(nameS) || - xx->flipped != flipped || - xx->ungrouped != ungrouped || - xx->split != split ) { + xx->flipped != flipped || + xx->ungrouped != ungrouped || + xx->split != split ) { titleChanged = TRUE; } strcat( message, "\t" ); strncat( message, nameS, max_namestr-1 ); partnoS = wStringGetValue( (wString_p)compoundDesc[PN].control0 ); max_partstr = 256; - if (compoundDesc[PN].max_string) + if (compoundDesc[PN].max_string) { max_partstr = compoundDesc[PN].max_string; + } if (strlen(partnoS)>max_partstr) { NoticeMessage2(0, MSG_ENTERED_STRING_TRUNCATED, _("Ok"), NULL, max_partstr-1); } @@ -801,22 +844,23 @@ static void UpdateCompound( track_p trk, int inx, descData_p descUpd, BOOL_T nee MyFree(newTitle); return; } - if ( needUndoStart ) - UndoStart( _("Change Track"), "Change Track" ); + if ( needUndoStart ) { + UndoStart( _("Change Track"), "Change Track" ); + } UndoModify( trk ); GetBoundingBox( trk, &hi, &lo ); if ( labelScale >= mainD.scale && - !OFF_MAIND( lo, hi ) ) { + !OFF_MAIND( lo, hi ) ) { DrawCompoundDescription( trk, &mainD, wDrawColorWhite ); } /*sprintf( message, "%s\t%s\t%s", manufS, nameS, partnoS );*/ - if (xx->title) MyFree(xx->title); + if (xx->title) { MyFree(xx->title); } xx->title = newTitle; xx->flipped = flipped; xx->ungrouped = ungrouped; xx->split = split; if ( labelScale >= mainD.scale && - !OFF_MAIND( lo, hi ) ) { + !OFF_MAIND( lo, hi ) ) { DrawCompoundDescription( trk, &mainD, GetTrkColor(trk,&tempD) ); } return; @@ -835,29 +879,30 @@ static void UpdateCompound( track_p trk, int inx, descData_p descUpd, BOOL_T nee case A1: case A2: case A3: - if (inx==A3) ep=3; - else if (inx==A2) ep=2; - else if (inx==A1) ep=1; - else ep=0; - RotateTrack( trk, GetTrkEndPos(trk,ep), NormalizeAngle( compoundData.endAngle[ep]-GetTrkEndAngle(trk,ep) ) ); + if (inx==A3) { ep=3; } + else if (inx==A2) { ep=2; } + else if (inx==A1) { ep=1; } + else { ep=0; } + RotateTrack( trk, GetTrkEndPos(trk,ep), + NormalizeAngle( compoundData.endAngle[ep]-GetTrkEndAngle(trk,ep) ) ); ComputeCompoundBoundingBox( trk ); break; case AN: orig = xx->orig; GetBoundingBox(trk,&hi,&lo); switch (compoundData.pivot) { - case DESC_PIVOT_MID: - orig.x = (hi.x-lo.x)/2+lo.x; - orig.y = (hi.y-lo.y)/2+lo.y; - break; - case DESC_PIVOT_SECOND: - orig.x = (hi.x-lo.x)/2+lo.x; - orig.y = (hi.y-lo.y)/2+lo.y; - orig.x = (orig.x - xx->orig.x)*2+xx->orig.x; - orig.y = (orig.y - xx->orig.y)*2+xx->orig.y; - break; - default: - break; + case DESC_PIVOT_MID: + orig.x = (hi.x-lo.x)/2+lo.x; + orig.y = (hi.y-lo.y)/2+lo.y; + break; + case DESC_PIVOT_SECOND: + orig.x = (hi.x-lo.x)/2+lo.x; + orig.y = (hi.y-lo.y)/2+lo.y; + orig.x = (orig.x - xx->orig.x)*2+xx->orig.x; + orig.y = (orig.y - xx->orig.y)*2+xx->orig.y; + break; + default: + break; } RotateTrack( trk, orig, NormalizeAngle( compoundData.angle-xx->angle ) ); ComputeCompoundBoundingBox( trk ); @@ -866,10 +911,10 @@ static void UpdateCompound( track_p trk, int inx, descData_p descUpd, BOOL_T nee case E1: case E2: case E3: - if (inx==E3) ep=3; - else if (inx==E2) ep=2; - else if (inx==E1) ep=1; - else ep=0; + if (inx==E3) { ep=3; } + else if (inx==E2) { ep=2; } + else if (inx==E1) { ep=1; } + else { ep=0; } pos = GetTrkEndPos(trk,ep); pos.x = compoundData.endPt[ep].x - pos.x; pos.y = compoundData.endPt[ep].y - pos.y; @@ -881,17 +926,21 @@ static void UpdateCompound( track_p trk, int inx, descData_p descUpd, BOOL_T nee case Z2: case Z3: ep = (inx==Z0?0:(inx==Z1?1:(inx==Z2?2:3))); - UpdateTrkEndElev( trk, ep, GetTrkEndElevUnmaskedMode(trk,ep), compoundData.elev[ep], NULL ); - if ( GetTrkEndPtCnt(trk) == 1 ) - break; - for (int i=0;i<compoundData.epCnt;i++) { - if (i==ep) continue; + UpdateTrkEndElev( trk, ep, GetTrkEndElevUnmaskedMode(trk,ep), + compoundData.elev[ep], NULL ); + if ( GetTrkEndPtCnt(trk) == 1 ) { + break; + } + for (int i=0; i<compoundData.epCnt; i++) { + if (i==ep) { continue; } ComputeElev( trk, i, FALSE, &compoundData.elev[i], NULL, TRUE ); } - if ( compoundData.length > minLength ) - compoundData.grade = fabs( (compoundData.elev[0]-compoundData.elev[1])/compoundData.length )*100.0; - else + if ( compoundData.length > minLength ) { + compoundData.grade = fabs( (compoundData.elev[0] + -compoundData.elev[1])/compoundData.length )*100.0; + } else { compoundData.grade = 0.0; + } compoundDesc[GR].mode |= DESC_CHANGE; compoundDesc[Z0+(E1-E0)*inx].mode |= DESC_CHANGE; break; @@ -901,18 +950,18 @@ static void UpdateCompound( track_p trk, int inx, descData_p descUpd, BOOL_T nee default: break; } - switch ( inx ) { - case A0: - case A1: - case A2: - case A3: - case E0: - case E1: - case E2: - case E3: - case AN: - case OR: - for (int i=0;(i<compoundData.epCnt)&&(i<MAX_DESCRIBE_ENDS);i++) { + switch ( inx ) { + case A0: + case A1: + case A2: + case A3: + case E0: + case E1: + case E2: + case E3: + case AN: + case OR: + for (int i=0; (i<compoundData.epCnt)&&(i<MAX_DESCRIBE_ENDS); i++) { compoundData.endPt[i] = GetTrkEndPos(trk,i); compoundDesc[i*(E1-E0)+E0].mode |= DESC_CHANGE; trackParams_t params; @@ -921,20 +970,20 @@ static void UpdateCompound( track_p trk, int inx, descData_p descUpd, BOOL_T nee GetTrackParams(PARAMS_CORNU,trk,compoundData.endPt[i],¶ms); compoundData.endRadius[i] = params.arcR; if (params.arcR != 0.0) { - compoundData.endCenter[i] = params.arcP; - compoundDesc[i*(E1-E0)+C0].mode |= DESC_CHANGE; + compoundData.endCenter[i] = params.arcP; + compoundDesc[i*(E1-E0)+C0].mode |= DESC_CHANGE; } } compoundData.orig = xx->orig; compoundDesc[OR].mode |= DESC_CHANGE; compoundData.angle = xx->angle; compoundDesc[AN].mode |= DESC_CHANGE; - break; - case LT: - xx->lineType = compoundData.linetype; - break; - default: - break; + break; + case LT: + xx->lineType = compoundData.linetype; + break; + default: + break; }; DrawNewTrack( trk ); @@ -943,11 +992,12 @@ static void UpdateCompound( track_p trk, int inx, descData_p descUpd, BOOL_T nee void DescribeCompound( - track_p trk, - char * str, - CSIZE_T len ) + track_p trk, + char * str, + CSIZE_T len ) { - struct extraDataCompound_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, extraDataCompound_t); + struct extraDataCompound_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, + extraDataCompound_t); int fix; EPINX_T ep, epCnt; char * mP, *nP, *pP, *cnP; @@ -955,31 +1005,35 @@ void DescribeCompound( long mode; long listLabelsOption = listLabels; DynString description; - char *trackType; + char *trackType; - if ( xx->flipped ) + if ( xx->flipped ) { listLabelsOption |= LABEL_FLIPPED; - if ( xx->ungrouped ) + } + if ( xx->ungrouped ) { listLabelsOption |= LABEL_UNGROUPED; - if ( xx->split ) + } + if ( xx->split ) { listLabelsOption |= LABEL_SPLIT; + } FormatCompoundTitle( listLabelsOption, xtitle(xx) ); - if (message[0] == '\0') + if (message[0] == '\0') { FormatCompoundTitle( listLabelsOption|LABEL_DESCR, xtitle(xx) ); + } - if (GetTrkEndPtCnt(trk) <= 1) { + if (GetTrkEndPtCnt(trk) < 1) { trackType = _("Structure"); } else { trackType = GetTrkEndPtCnt(trk) > 2 ? _("Turnout") : _("Sectional Track"); } DynStringMalloc(&description, len); DynStringPrintf(&description, - _("%s (%d) Layer= %d %s"), - trackType, - GetTrkIndex(trk), - GetTrkLayer(trk) + 1, - message); - + _("%s (%d) Layer= %d %s"), + trackType, + GetTrkIndex(trk), + GetTrkLayer(trk) + 1, + message); + if (DynStringSize(&description) > (unsigned)len) { strncpy(str, DynStringToCStr(&description), len - 1); strcpy(str + len - 4, "..."); @@ -1040,7 +1094,7 @@ void DescribeCompound( for ( int i=0 ; i<4 ; i++) { compoundDesc[E0+(E1-E0)*i].mode = DESC_IGNORE; - compoundDesc[A0+(E1-E0)*i].mode = DESC_IGNORE; + compoundDesc[A0+(E1-E0)*i].mode = DESC_IGNORE; compoundDesc[R0+(E1-E0)*i].mode = DESC_IGNORE; compoundDesc[C0+(E1-E0)*i].mode = DESC_IGNORE; compoundDesc[Z0+(E1-E0)*i].mode = DESC_IGNORE; @@ -1048,16 +1102,16 @@ void DescribeCompound( compoundDesc[GR].mode = DESC_IGNORE; compoundDesc[OR].mode = - compoundDesc[AN].mode = fix?DESC_RO:0; + compoundDesc[AN].mode = fix?DESC_RO:0; compoundDesc[MN].mode = - compoundDesc[NM].mode = - compoundDesc[PN].mode = 0 /*DESC_NOREDRAW*/; + compoundDesc[NM].mode = + compoundDesc[PN].mode = 0 /*DESC_NOREDRAW*/; compoundDesc[SC].mode = DESC_RO; compoundDesc[LY].mode = DESC_NOREDRAW; compoundDesc[PV].mode = 0; compoundData.pivot = DESC_PIVOT_FIRST; if (compoundData.epCnt >0) { - for (int i=0;(i<compoundData.epCnt)&&(i<MAX_DESCRIBE_ENDS);i++) { + for (int i=0; (i<compoundData.epCnt)&&(i<MAX_DESCRIBE_ENDS); i++) { compoundDesc[A0+(E1-E0)*i].mode = (int)mode; compoundDesc[R0+(E1-E0)*i].mode = DESC_RO; compoundDesc[C0+(E1-E0)*i].mode = DESC_RO; @@ -1074,21 +1128,26 @@ void DescribeCompound( compoundDesc[R0+(E1-E0)*i].mode = DESC_IGNORE; } ComputeElev( trk, i, FALSE, &compoundData.elev[i], NULL, FALSE ); - compoundDesc[Z0+(E1-E0)*i].mode = (EndPtIsDefinedElev(trk,i)?0:DESC_RO)|DESC_NOREDRAW; + compoundDesc[Z0+(E1-E0)*i].mode = (EndPtIsDefinedElev(trk, + i)?0:DESC_RO)|DESC_NOREDRAW; } compoundDesc[GR].mode = DESC_RO; } - if ( compoundData.epCnt == 2 ) + if ( compoundData.epCnt == 2 ) { compoundData.length = GetTrkLength( trk, 0, 1 ); - if ( compoundData.length > minLength && compoundData.epCnt > 1) - compoundData.grade = fabs( (compoundData.elev[0]-compoundData.elev[1])/compoundData.length )*100.0; - else + } + if ( compoundData.length > minLength && compoundData.epCnt > 1) { + compoundData.grade = fabs( (compoundData.elev[0] + -compoundData.elev[1])/compoundData.length )*100.0; + } else { compoundData.grade = 0.0; + } if (GetTrkEndPtCnt(trk) == 0) { compoundDesc[LT].mode = 0; - } else + } else { compoundDesc[LT].mode = DESC_IGNORE; + } DoDescribe(trackType, trk, compoundDesc, UpdateCompound); @@ -1097,10 +1156,14 @@ void DescribeCompound( wListAddValue( (wList_p)compoundDesc[LT].control0, _("Solid"), NULL, I2VP(0) ); wListAddValue( (wList_p)compoundDesc[LT].control0, _("Dash"), NULL, I2VP(1) ); wListAddValue( (wList_p)compoundDesc[LT].control0, _("Dot"), NULL, I2VP(2) ); - wListAddValue( (wList_p)compoundDesc[LT].control0, _("DashDot"), NULL, I2VP(3) ); - wListAddValue( (wList_p)compoundDesc[LT].control0, _("DashDotDot"), NULL, I2VP(4) ); - wListAddValue( (wList_p)compoundDesc[LT].control0, _("CenterDot"), NULL, I2VP(5) ); - wListAddValue( (wList_p)compoundDesc[LT].control0, _("PhantomDot"), NULL, I2VP(6) ); + wListAddValue( (wList_p)compoundDesc[LT].control0, _("DashDot"), NULL, + I2VP(3) ); + wListAddValue( (wList_p)compoundDesc[LT].control0, _("DashDotDot"), NULL, + I2VP(4) ); + wListAddValue( (wList_p)compoundDesc[LT].control0, _("CenterDot"), NULL, + I2VP(5) ); + wListAddValue( (wList_p)compoundDesc[LT].control0, _("PhantomDot"), NULL, + I2VP(6) ); wListSetIndex( (wList_p)compoundDesc[LT].control0, compoundData.linetype ); } @@ -1108,66 +1171,82 @@ void DescribeCompound( void DeleteCompound( - track_p t ) + track_p t ) { - struct extraDataCompound_t *xx = GET_EXTRA_DATA(t, T_NOTRACK, extraDataCompound_t); + struct extraDataCompound_t *xx = GET_EXTRA_DATA(t, T_NOTRACK, + extraDataCompound_t); FreeFilledDraw( xx->segCnt, xx->segs ); - if (xx->segCnt>0) MyFree( xx->segs ); + if (xx->segCnt>0) { MyFree( xx->segs ); } xx->segs = NULL; } BOOL_T WriteCompound( - track_p t, - FILE * f ) + track_p t, + FILE * f ) { - struct extraDataCompound_t *xx = GET_EXTRA_DATA(t, T_NOTRACK, extraDataCompound_t); + struct extraDataCompound_t *xx = GET_EXTRA_DATA(t, T_NOTRACK, + extraDataCompound_t); EPINX_T ep, epCnt; + int bits; long options; - long position = 0; +// long position = 0; drawLineType_e lineType = 0; BOOL_T rc = TRUE; options = (long)GetTrkWidth(t); - if (xx->handlaid) + if (xx->handlaid) { options |= COMPOUND_OPTION_HANDLAID; - if (xx->flipped) + } + if (xx->flipped) { options |= COMPOUND_OPTION_FLIPPED; - if (xx->ungrouped) + } + if (xx->ungrouped) { options |= COMPOUND_OPTION_UNGROUPED; - if (xx->split) + } + if (xx->split) { options |= COMPOUND_OPTION_SPLIT; - if (xx->pathOverRide) + } + if (xx->pathOverRide) { options |= COMPOUND_OPTION_PATH_OVERRIDE; - if (xx->pathNoCombine) + } + if (xx->pathNoCombine) { options |= COMPOUND_OPTION_PATH_NOCOMBINE; - if ( ( GetTrkBits( t ) & TB_HIDEDESC ) != 0 ) + } + if ( ( GetTrkBits( t ) & TB_HIDEDESC ) != 0 ) { options |= COMPOUND_OPTION_HIDEDESC; + } epCnt = GetTrkEndPtCnt(t); lineType = xx->lineType; + bits = GetTrkVisible(t)|(GetTrkNoTies(t)?1<<2:0)|(GetTrkBridge(t)?1<<3:0)| + (GetTrkRoadbed(t)?1<<4:0); rc &= fprintf(f, "%s %d %d %ld %ld %d %s %d %0.6f %0.6f 0 %0.6f \"%s\"\n", - GetTrkTypeName(t), - GetTrkIndex(t), GetTrkLayer(t), options, - GetCurrPathIndex(t), lineType, - GetTrkScaleName(t), GetTrkVisible(t)|(GetTrkNoTies(t)?1<<2:0)|(GetTrkBridge(t)?1<<3:0), - xx->orig.x, xx->orig.y, xx->angle, - PutTitle(xtitle(xx)) )>0; - for (ep=0; ep<epCnt; ep++ ) + GetTrkTypeName(t), + GetTrkIndex(t), GetTrkLayer(t), options, + GetCurrPathIndex(t), lineType, + GetTrkScaleName(t), bits, + xx->orig.x, xx->orig.y, xx->angle, + PutTitle(xtitle(xx)) )>0; + for (ep=0; ep<epCnt; ep++ ) { WriteEndPt( f, t, ep ); + } switch ( xx->special ) { case TOadjustable: rc &= fprintf( f, "\tX %s %0.3f %0.3f\n", ADJUSTABLE, - xx->u.adjustable.minD, xx->u.adjustable.maxD )>0; + xx->u.adjustable.minD, xx->u.adjustable.maxD )>0; break; case TOpier: - rc &= fprintf( f, "\tX %s %0.6f \"%s\"\n", PIER, xx->u.pier.height, xx->u.pier.name )>0; + rc &= fprintf( f, "\tX %s %0.6f \"%s\"\n", PIER, xx->u.pier.height, + xx->u.pier.name )>0; break; default: ; } - rc &= fprintf( f, "\tD %0.6f %0.6f\n", xx->descriptionOff.x, xx->descriptionOff.y )>0; - rc &= WriteCompoundPathsEndPtsSegs( f, GetPaths( t ), xx->segCnt, xx->segs, 0, NULL ); + rc &= fprintf( f, "\tD %0.6f %0.6f\n", xx->descriptionOff.x, + xx->descriptionOff.y )>0; + rc &= WriteCompoundPathsEndPtsSegs( f, GetPaths( t ), xx->segCnt, xx->segs, 0, + NULL ); return rc; } @@ -1180,8 +1259,10 @@ BOOL_T WriteCompound( * */ -EXPORT void SetCompoundLineType( track_p trk, int width ) { - struct extraDataCompound_t * xx = GET_EXTRA_DATA(trk, T_NOTRACK, extraDataCompound_t); +EXPORT void SetCompoundLineType( track_p trk, int width ) +{ + struct extraDataCompound_t * xx = GET_EXTRA_DATA(trk, T_NOTRACK, + extraDataCompound_t); switch(width) { case 0: xx->lineType = DRAWLINESOLID; @@ -1210,16 +1291,16 @@ EXPORT void SetCompoundLineType( track_p trk, int width ) { EXPORT track_p NewCompound( - TRKTYP_T trkType, - TRKINX_T index, - coOrd pos, - ANGLE_T angle, - char * title, - EPINX_T epCnt, - trkEndPt_t * epp, - PATHPTR_T paths, - wIndex_t segCnt, - trkSeg_p segs ) + TRKTYP_T trkType, + TRKINX_T index, + coOrd pos, + ANGLE_T angle, + char * title, + EPINX_T epCnt, + trkEndPt_p epp0, + PATHPTR_T paths, + wIndex_t segCnt, + trkSeg_p segs ) { track_p trk; struct extraDataCompound_t * xx; @@ -1241,21 +1322,22 @@ EXPORT track_p NewCompound( SetPaths( trk, paths ); xx->segCnt = segCnt; xx->segs = memdup( segs, segCnt * sizeof *segs ); - trkSeg_p p = xx->segs; +// trkSeg_p p = xx->segs; CopyPoly(xx->segs, xx->segCnt); FixUpBezierSegs(xx->segs,xx->segCnt); ComputeCompoundBoundingBox( trk ); SetDescriptionOrig( trk ); for ( ep=0; ep<epCnt; ep++ ) { - SetTrkEndPoint( trk, ep, epp[ep].pos, epp[ep].angle ); + trkEndPt_p epp = EndPtIndex( epp0, ep ); + SetTrkEndPoint( trk, ep, GetEndPtPos(epp), GetEndPtAngle(epp) ); } return trk; } BOOL_T ReadCompound( - char * line, - TRKTYP_T trkType ) + char * line, + TRKTYP_T trkType ) { track_p trk; struct extraDataCompound_t *xx; @@ -1274,25 +1356,31 @@ BOOL_T ReadCompound( if (paramVersion<3) { if ( !GetArgs( line, "dXsdpfq", - &index, &layer, scale, &visible, &orig, &angle, &title ) ) + &index, &layer, scale, &visible, &orig, &angle, &title ) ) { return FALSE; + } } else if (paramVersion <= 5 && trkType == T_STRUCTURE) { if ( !GetArgs( line, "dL00sdpfq", - &index, &layer, scale, &visible, &orig, &angle, &title ) ) + &index, &layer, scale, &visible, &orig, &angle, &title ) ) { return FALSE; + } } else { if ( !GetArgs( line, paramVersion<9?"dLlldsdpYfq":"dLlldsdpffq", - &index, &layer, &options, &position, &lineType, scale, &visible, &orig, &elev, &angle, &title ) ) + &index, &layer, &options, &position, &lineType, scale, &visible, &orig, &elev, + &angle, &title ) ) { return FALSE; + } } - if (paramVersion >=3 && paramVersion <= 5 && trkType == T_STRUCTURE) + if (paramVersion >=3 && paramVersion <= 5 && trkType == T_STRUCTURE) { strcpy( scale, curScaleName ); - DYNARR_RESET( trkEndPt_t, tempEndPts_da ); + } + TempEndPtsReset(); pathCnt = 0; - if ( !ReadSegs() ) + if ( !ReadSegs() ) { return FALSE; + } if ( trkType == T_TURNOUT ) { - if ( tempEndPts_da.cnt <= 0 ) { + if ( TempEndPtsCount() <= 0 ) { InputError( "Turnout defn without EndPoints", TRUE ); return FALSE; } @@ -1311,17 +1399,19 @@ BOOL_T ReadCompound( } } trk = NewCompound( trkType, index, orig, angle, title, 0, NULL, - pathCnt > 1 ? pathPtr : NULL, - tempSegs_da.cnt, &tempSegs(0) ); + pathCnt > 1 ? pathPtr : NULL, + tempSegs_da.cnt, &tempSegs(0) ); SetEndPts( trk, 0 ); if ( paramVersion < 3 ) { SetTrkVisible(trk, visible!=0); SetTrkNoTies(trk, FALSE); SetTrkBridge(trk, FALSE); + SetTrkRoadbed(trk, FALSE); } else { SetTrkVisible(trk, visible&2); SetTrkNoTies(trk, visible&4); SetTrkBridge(trk, visible&8); + SetTrkRoadbed(trk, visible&16); } SetTrkScale(trk, LookupScale( scale )); SetTrkLayer(trk, layer); @@ -1335,21 +1425,24 @@ BOOL_T ReadCompound( xx->pathNoCombine = (int)((options&COMPOUND_OPTION_PATH_NOCOMBINE)!=0); xx->lineType = lineType; xx->descriptionOff = descriptionOff; - if ( ( options & COMPOUND_OPTION_HIDEDESC ) != 0 ) + if ( ( options & COMPOUND_OPTION_HIDEDESC ) != 0 ) { SetTrkBits( trk, TB_HIDEDESC ); + } if (tempSpecial[0] != '\0') { if (strncmp( tempSpecial, ADJUSTABLE, strlen(ADJUSTABLE) ) == 0) { xx->special = TOadjustable; if ( !GetArgs( tempSpecial+strlen(ADJUSTABLE), "ff", - &xx->u.adjustable.minD, &xx->u.adjustable.maxD ) ) + &xx->u.adjustable.minD, &xx->u.adjustable.maxD ) ) { return FALSE; + } } else if (strncmp( tempSpecial, PIER, strlen(PIER) ) == 0) { xx->special = TOpier; if ( !GetArgs( tempSpecial+strlen(PIER), "fq", - &xx->u.pier.height, &xx->u.pier.name ) ) + &xx->u.pier.height, &xx->u.pier.name ) ) { return FALSE; + } } else { InputError("Unknown special case", TRUE); @@ -1361,10 +1454,11 @@ BOOL_T ReadCompound( } void MoveCompound( - track_p trk, - coOrd orig ) + track_p trk, + coOrd orig ) { - struct extraDataCompound_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, extraDataCompound_t); + struct extraDataCompound_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, + extraDataCompound_t); xx->orig.x += orig.x; xx->orig.y += orig.y; ComputeCompoundBoundingBox( trk ); @@ -1372,11 +1466,12 @@ void MoveCompound( void RotateCompound( - track_p trk, - coOrd orig, - ANGLE_T angle ) + track_p trk, + coOrd orig, + ANGLE_T angle ) { - struct extraDataCompound_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, extraDataCompound_t); + struct extraDataCompound_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, + extraDataCompound_t); Rotate( &xx->orig, orig, angle ); xx->angle = NormalizeAngle( xx->angle + angle ); Rotate( &xx->descriptionOff, zero, angle ); @@ -1385,10 +1480,11 @@ void RotateCompound( void RescaleCompound( - track_p trk, - FLOAT_T ratio ) + track_p trk, + FLOAT_T ratio ) { - struct extraDataCompound_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, extraDataCompound_t); + struct extraDataCompound_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, + extraDataCompound_t); xx->orig.x *= ratio; xx->orig.y *= ratio; xx->descriptionOff.x *= ratio; @@ -1400,11 +1496,12 @@ void RescaleCompound( void FlipCompound( - track_p trk, - coOrd orig, - ANGLE_T angle ) + track_p trk, + coOrd orig, + ANGLE_T angle ) { - struct extraDataCompound_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, extraDataCompound_t); + struct extraDataCompound_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, + extraDataCompound_t); EPINX_T ep, epCnt; char * mP, *nP, *pP; int mL, nL, pL; @@ -1424,16 +1521,18 @@ void FlipCompound( xx->descriptionOrig.y = - xx->descriptionOrig.y; ComputeCompoundBoundingBox( trk ); epCnt = GetTrkEndPtCnt( trk ); - if ( epCnt >= 1 && epCnt <= 2 ) + if ( epCnt >= 1 && epCnt <= 2 ) { return; + } ParseCompoundTitle( xtitle(xx), &mP, &mL, &nP, &nL, &pP, &pL ); - to = FindCompound( epCnt==0?FIND_STRUCT:FIND_TURNOUT, GetScaleName(GetTrkScale(trk)), xx->title ); + to = FindCompound( epCnt==0?FIND_STRUCT:FIND_TURNOUT, + GetScaleName(GetTrkScale(trk)), xx->title ); if ( epCnt!=0 && to && to->customInfo ) { if ( GetArgs( to->customInfo, "qc", &type, &cp ) ) { if ( strcmp( type, "Regular Turnout" ) == 0 || - strcmp( type, "Curved Turnout" ) == 0 ) { + strcmp( type, "Curved Turnout" ) == 0 ) { if ( GetArgs( cp, "qqqqq", &mfg, &descL, &partL, &descR, &partR ) && - mP && strcmp( mP, mfg ) == 0 && nP && pP ) { + mP && strcmp( mP, mfg ) == 0 && nP && pP ) { if ( strcmp( nP, descL ) == 0 && strcmp( pP, partL ) == 0 ) { sprintf( message, "%s\t%s\t%s", mfg, descR, partR ); xx->title = MyStrdup( message ); @@ -1445,7 +1544,7 @@ void FlipCompound( return; } } - } + } } } if ( epCnt == 3 || epCnt == 4 ) { @@ -1459,54 +1558,66 @@ void FlipCompound( if ( epCnt == 3 ) { /* Wye? */ if ( fabs(endPos[1].x-endPos[2].x) < SMALLVALUE && - fabs(endPos[1].y+endPos[2].y) < SMALLVALUE ) + fabs(endPos[1].y+endPos[2].y) < SMALLVALUE ) { return; + } } else { /* Crossing */ - if ( fabs( (endPos[1].x-endPos[3].x) - (endPos[2].x-endPos[0].x ) ) < SMALLVALUE && - fabs( (endPos[2].y+endPos[3].y) ) < SMALLVALUE && - fabs( (endPos[0].y-endPos[1].y) ) < SMALLVALUE && - NormalizeAngle( (endAngle[2]-endAngle[3]-180+0.05) ) < 0.10 ) + if ( fabs( (endPos[1].x-endPos[3].x) - (endPos[2].x-endPos[0].x ) ) < SMALLVALUE + && + fabs( (endPos[2].y+endPos[3].y) ) < SMALLVALUE && + fabs( (endPos[0].y-endPos[1].y) ) < SMALLVALUE && + NormalizeAngle( (endAngle[2]-endAngle[3]-180+0.05) ) < 0.10 ) { return; + } /* 3 way */ if ( fabs( (endPos[1].x-endPos[2].x) ) < SMALLVALUE && - fabs( (endPos[1].y+endPos[2].y) ) < SMALLVALUE && - fabs( (endPos[0].y-endPos[3].y) ) < SMALLVALUE && - NormalizeAngle( (endAngle[1]+endAngle[2]-180+0.05) ) < 0.10 ) + fabs( (endPos[1].y+endPos[2].y) ) < SMALLVALUE && + fabs( (endPos[0].y-endPos[3].y) ) < SMALLVALUE && + NormalizeAngle( (endAngle[1]+endAngle[2]-180+0.05) ) < 0.10 ) { return; + } } toBest = NULL; d0 = 0.0; for (inx=0; inx<turnoutInfo_da.cnt; inx++) { to = turnoutInfo(inx); if ( IsParamValid(to->paramFileIndex) && - to->segCnt > 0 && - to->scaleInx == GetTrkScale(trk) && - to->segCnt != 0 && - to->endCnt == epCnt ) { + to->segCnt > 0 && + to->scaleInx == GetTrkScale(trk) && + to->segCnt != 0 && + to->endCnt == epCnt ) { d1 = 0; a1 = 0; for ( ep=0; ep<epCnt; ep++ ) { - d2 = FindDistance( endPos[ep], to->endPt[ep].pos ); - if ( d2 > SMALLVALUE ) + trkEndPt_p epp = EndPtIndex( to->endPt, ep ); + d2 = FindDistance( endPos[ep], GetEndPtPos(epp) ); + if ( d2 > SMALLVALUE ) { break; - if ( d2 > d1 ) + } + if ( d2 > d1 ) { d1 = d2; - a2 = NormalizeAngle( endAngle[ep] - to->endPt[ep].angle + 0.05 ); - if ( a2 > 0.1 ) + } + a2 = NormalizeAngle( endAngle[ep] - GetEndPtAngle(epp) + 0.05 ); + if ( a2 > 0.1 ) { break; - if ( a2 > a1 ) + } + if ( a2 > a1 ) { a1 = a2; + } } - if ( ep<epCnt ) + if ( ep<epCnt ) { continue; - if ( toBest == NULL || d1 < d0 ) + } + if ( toBest == NULL || d1 < d0 ) { toBest = to; + } } } if ( toBest ) { - if ( strcmp( xx->title, toBest->title ) != 0 ) + if ( strcmp( xx->title, toBest->title ) != 0 ) { xx->title = MyStrdup( toBest->title ); + } return; } } @@ -1515,12 +1626,12 @@ void FlipCompound( typedef struct { - long count; - char * type; - char * name; - FLOAT_T price; - DynString indexes; - } enumCompound_t; + long count; + char * type; + char * name; + FLOAT_T price; + DynString indexes; +} enumCompound_t; static dynArr_t enumCompound_da; #define EnumCompound(N) DYNARR_N( enumCompound_t,enumCompound_da,N) @@ -1534,17 +1645,21 @@ BOOL_T EnumerateCompound( track_p trk ) if ( trk != NULL ) { xx = GET_EXTRA_DATA(trk, T_NOTRACK, extraDataCompound_t); - if ( xx->flipped ) + if ( xx->flipped ) { listLabelsOption |= LABEL_FLIPPED; + } #ifdef LATER - if ( xx->ungrouped ) + if ( xx->ungrouped ) { listLabelsOption |= LABEL_UNGROUPED; - if ( xx->split ) + } + if ( xx->split ) { listLabelsOption |= LABEL_SPLIT; + } #endif FormatCompoundTitle( listLabelsOption, xtitle(xx) ); - if (message[0] == '\0') - return FALSE; //No content + if (message[0] == '\0') { + return FALSE; //No content + } for (inx = 0; inx < enumCompound_da.cnt; inx++ ) { cmp = strcmp( EnumCompound(inx).name, message ); if ( cmp == 0 ) { @@ -1558,11 +1673,13 @@ BOOL_T EnumerateCompound( track_p trk ) } } DYNARR_APPEND( enumCompound_t, enumCompound_da, 10 ); - for ( inx2 = enumCompound_da.cnt-1; inx2 > inx; inx2-- ) + for ( inx2 = enumCompound_da.cnt-1; inx2 > inx; inx2-- ) { EnumCompound(inx2) = EnumCompound(inx2-1); + } EnumCompound(inx).name = MyStrdup( message ); - if (strlen(message) > (size_t)enumerateMaxDescLen) + if (strlen(message) > (size_t)enumerateMaxDescLen) { enumerateMaxDescLen = (int)strlen(message); + } EnumCompound(inx).type = GetTrkTypeName( trk ); EnumCompound(inx).count = 1; DynStringMalloc(&(EnumCompound(inx).indexes),100); @@ -1575,9 +1692,10 @@ BOOL_T EnumerateCompound( track_p trk ) for (inx = 0; inx < enumCompound_da.cnt; inx++ ) { if (EnumCompound(inx).type[0] == *type) { EnumerateList( EnumCompound(inx).count, - EnumCompound(inx).price, - EnumCompound(inx).name, - DynStringSize(&(EnumCompound(inx).indexes))?DynStringToCStr(&(EnumCompound(inx).indexes)):NULL); + EnumCompound(inx).price, + EnumCompound(inx).name, + DynStringSize(&(EnumCompound(inx).indexes))?DynStringToCStr(&(EnumCompound( + inx).indexes)):NULL); } DynStringFree(&(EnumCompound(inx).indexes)); } diff --git a/app/bin/compound.h b/app/bin/compound.h index edcbb66..0a4a0ae 100644 --- a/app/bin/compound.h +++ b/app/bin/compound.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef COMPOUND_H @@ -29,77 +29,72 @@ typedef enum { TOnormal, TOadjustable, TOpierInfo, TOpier, TOcarDesc, TOlast } TOspecial_e; typedef struct { - char * name; - FLOAT_T height; - } pierInfo_t; + char * name; + FLOAT_T height; +} pierInfo_t; typedef union { - struct { - FLOAT_T minD, maxD; - } adjustable; - struct { - int cnt; - pierInfo_t * info; - } pierInfo; - struct { - FLOAT_T height; - char * name; - } pier; - } turnoutInfo_u; - -typedef struct turnoutInfo_t{ - SCALEINX_T scaleInx; - char * title; - coOrd orig; - coOrd size; - wIndex_t segCnt; - trkSeg_p segs; - wIndex_t endCnt; - trkEndPt_p endPt; - PATHPTR_T paths; - int paramFileIndex; - char * customInfo; - DIST_T barScale; - TOspecial_e special; - turnoutInfo_u u; - wBool_t pathOverRide; - wBool_t pathNoCombine; - char * contentsLabel; - } turnoutInfo_t; + struct { + FLOAT_T minD, maxD; + } adjustable; + struct { + int cnt; + pierInfo_t * info; + } pierInfo; + struct { + FLOAT_T height; + char * name; + } pier; +} turnoutInfo_u; + +typedef struct turnoutInfo_t { + SCALEINX_T scaleInx; + char * title; + coOrd orig; + coOrd size; + wIndex_t segCnt; + trkSeg_p segs; + wIndex_t endCnt; + trkEndPt_p endPt; + PATHPTR_T paths; + int paramFileIndex; + char * customInfo; + DIST_T barScale; + TOspecial_e special; + turnoutInfo_u u; + wBool_t pathOverRide; + wBool_t pathNoCombine; + char * contentsLabel; +} turnoutInfo_t; #define xtitle(X) \ (X->title) typedef struct extraDataCompound_t { - extraDataBase_t base; - coOrd orig; - ANGLE_T angle; - BOOL_T handlaid; - BOOL_T flipped; - BOOL_T ungrouped; - BOOL_T split; - BOOL_T pathOverRide; - BOOL_T pathNoCombine; - coOrd descriptionOrig; - coOrd descriptionOff; - coOrd descriptionSize; - char * title; - char * customInfo; - TOspecial_e special; - turnoutInfo_u u; - PATHPTR_T paths; - PATHPTR_T currPath; - long currPathIndex; - wIndex_t segCnt; - trkSeg_p segs; - drawLineType_e lineType; - } extraDataCompound_t; - -extern TRKTYP_T T_TURNOUT; -extern TRKTYP_T T_STRUCTURE; -extern TRKTYP_T T_BEZIER; -extern TRKTYP_T T_BZRLIN; -extern TRKTYP_T T_CORNU; + extraDataBase_t base; + coOrd orig; + ANGLE_T angle; + BOOL_T handlaid; + BOOL_T flipped; + BOOL_T ungrouped; + BOOL_T split; + BOOL_T pathOverRide; + BOOL_T pathNoCombine; + coOrd descriptionOrig; + coOrd descriptionOff; + coOrd descriptionSize; + char * title; + char * customInfo; + TOspecial_e special; + turnoutInfo_u u; + PATHPTR_T paths; + PATHPTR_T currPath; + long currPathIndex; + wIndex_t segCnt; + trkSeg_p segs; + drawLineType_e lineType; +} extraDataCompound_t; + extern DIST_T curBarScale; extern dynArr_t turnoutInfo_da; extern dynArr_t structureInfo_da; @@ -135,9 +130,11 @@ void SetParamPaths( turnoutInfo_t * to, PATHPTR_T paths ); #define FIND_TURNOUT (1<<11) #define FIND_STRUCT (1<<12) -void FormatCompoundTitle( long, char *); -BOOL_T WriteCompoundPathsEndPtsSegs( FILE *, PATHPTR_T, wIndex_t, trkSeg_p, EPINX_T, trkEndPt_p); -void ParseCompoundTitle( char *, char **, int *, char **, int *, char **, int * ); +void FormatCompoundTitle( long, char *); +BOOL_T WriteCompoundPathsEndPtsSegs( FILE *, PATHPTR_T, wIndex_t, trkSeg_p, + EPINX_T, trkEndPt_p); +void ParseCompoundTitle( char *, char **, int *, char **, int *, char **, + int * ); void FormatCompoundTitle( long, char *); void ComputeCompoundBoundingBox( track_p); turnoutInfo_t * FindCompound( long, char *, char * ); @@ -149,7 +146,8 @@ void DrawCompoundDescription( track_p, drawCmd_p, wDrawColor ); DIST_T DistanceCompound( track_p, coOrd * ); void DescribeCompound( track_p, char *, CSIZE_T ); void DeleteCompound( track_p ); -track_p NewCompound( TRKTYP_T, TRKINX_T, coOrd, ANGLE_T, char *, EPINX_T, trkEndPt_p, PATHPTR_T, wIndex_t, trkSeg_p ); +track_p NewCompound( TRKTYP_T, TRKINX_T, coOrd, ANGLE_T, char *, EPINX_T, + trkEndPt_p, PATHPTR_T, wIndex_t, trkSeg_p ); BOOL_T WriteCompound( track_p, FILE * ); BOOL_T ReadCompound( char *, TRKTYP_T ); void MoveCompound( track_p, coOrd ); @@ -172,35 +170,38 @@ wIndex_t FindListItemByContext( wList_p, void *); /* cturnout.c */ +extern long curTurnoutEp; EPINX_T TurnoutPickEndPt( coOrd p, track_p ); -BOOL_T SplitTurnoutCheck(track_p,coOrd,EPINX_T ep,track_p *,EPINX_T *,EPINX_T *,BOOL_T check, coOrd *, ANGLE_T *); +BOOL_T SplitTurnoutCheck(track_p,coOrd,EPINX_T ep,track_p *,EPINX_T *,EPINX_T *, + BOOL_T check, coOrd *, ANGLE_T *); void GetSegInxEP( signed char, int *, EPINX_T * ); void SetSegInxEP( signed char *, int, EPINX_T) ; -wIndex_t CheckPaths( wIndex_t, trkSeg_p, PATHPTR_T ); -turnoutInfo_t * CreateNewTurnout( char *, char *, wIndex_t, trkSeg_p, PATHPTR_T, EPINX_T, trkEndPt_p, wBool_t, long ); +wIndex_t CheckPaths( wIndex_t, trkSeg_p, PATHPTR_T, char* ); +turnoutInfo_t * CreateNewTurnout( char *, char *, wIndex_t, trkSeg_p, PATHPTR_T, + EPINX_T, trkEndPt_p, wBool_t, long ); void DeleteTurnoutParams(int fileInx); turnoutInfo_t * TurnoutAdd( long, SCALEINX_T, wList_p, coOrd *, EPINX_T ); STATUS_T CmdTurnoutAction( wAction_t, coOrd ); -BOOL_T ConnectAdjustableTracks( track_p trk1, EPINX_T ep1, track_p trk2, EPINX_T ep2 ); -track_p NewHandLaidTurnout( coOrd, ANGLE_T, coOrd, ANGLE_T, coOrd, ANGLE_T, ANGLE_T ); +BOOL_T ConnectAdjustableTracks( track_p trk1, EPINX_T ep1, track_p trk2, + EPINX_T ep2 ); +track_p NewHandLaidTurnout( coOrd, ANGLE_T, coOrd, ANGLE_T, coOrd, ANGLE_T, + ANGLE_T ); void NextTurnoutPosition( track_p trk ); -enum paramFileState GetTrackCompatibility(int paramFileIndex, SCALEINX_T scaleIndex); +enum paramFileState GetTrackCompatibility(int paramFileIndex, + SCALEINX_T scaleIndex); /* ctodesgn.c */ void EditCustomTurnout( turnoutInfo_t *, turnoutInfo_t * ); long ComputeTurnoutRoadbedSide( trkSeg_p, int, int, ANGLE_T, DIST_T ); /* cstruct.c */ -turnoutInfo_t * CreateNewStructure( char *, char *, wIndex_t, trkSeg_p, BOOL_T ); -enum paramFileState GetStructureCompatibility(int paramFileIndex, SCALEINX_T scaleIndex); -turnoutInfo_t * StructAdd( long, SCALEINX_T, wList_p, coOrd * ); +turnoutInfo_t * CreateNewStructure( char *, char *, wIndex_t, trkSeg_p, + BOOL_T ); +enum paramFileState GetStructureCompatibility(int paramFileIndex, + SCALEINX_T scaleIndex); +turnoutInfo_t * StructAdd( long, SCALEINX_T, wList_p, coOrd * ); STATUS_T CmdStructureAction( wAction_t, coOrd ); BOOL_T StructLoadCarDescList( wList_p ); void DeleteStructures(int fileIndex); -/* cstrdsgn.c */ -void EditCustomStructure( turnoutInfo_t * ); - -STATUS_T CmdCarDescAction( wAction_t, coOrd ); -BOOL_T CarCustomSave( FILE * ); #endif diff --git a/app/bin/cparalle.c b/app/bin/cparalle.c index 6825aea..533b9d5 100644 --- a/app/bin/cparalle.c +++ b/app/bin/cparalle.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "ccurve.h" @@ -30,10 +30,10 @@ #include "common-ui.h" static struct { - track_p Trk; - coOrd orig; - track_p anchor_Trk; - } Dpa; + track_p Trk; + coOrd orig; + track_p anchor_Trk; +} Dpa; static DIST_T parSeparation = 1.0; static double parSepFactor = 0.0; @@ -57,146 +57,150 @@ static paramGroup_t parSepPG = { "parallel", 0, parSepPLs, COUNT( parSepPLs ) }; static STATUS_T CmdParallel(wAction_t action, coOrd pos) { - DIST_T d; - track_p t=NULL; - coOrd p; - static coOrd p0, p1; - ANGLE_T a; - track_p t0, t1; - EPINX_T ep0=-1, ep1=-1; - wControl_p controls[4]; - char * labels[3]; - static DIST_T parRFactor; + DIST_T d; + track_p t=NULL; + coOrd p; + static coOrd p0, p1; + ANGLE_T a; + track_p t0, t1; + EPINX_T ep0=-1, ep1=-1; + wControl_p controls[4]; + char * labels[3]; + static DIST_T parRFactor; - parType = VP2L(commandContext); + parType = VP2L(commandContext); - switch (action&0xFF) { + switch (action&0xFF) { - case C_START: - if (parSepPLs[0].control==NULL) { - ParamCreateControls(&parSepPG, NULL); - } - if (parType == PAR_TRACK) { - sprintf(message, "parallel-separation-%s", curScaleName); - parSeparation = ceil(13.0*12.0/curScaleRatio); - } else { - sprintf(message, "parallel-line-separation-%s", curScaleName); - parSeparation = 5.0*12.0/curScaleRatio; - } - wPrefGetFloat("misc", message, &parSeparation, parSeparation); - ParamLoadControls(&parSepPG); - ParamGroupRecord(&parSepPG); - parSepPD.option |= PDO_NORECORD; + case C_START: + if (parSepPLs[0].control==NULL) { + ParamCreateControls(&parSepPG, NULL); + } + if (parType == PAR_TRACK) { + sprintf(message, "parallel-separation-%s", curScaleName); + parSeparation = ceil(13.0*12.0/curScaleRatio); + } else { + sprintf(message, "parallel-line-separation-%s", curScaleName); + parSeparation = 5.0*12.0/curScaleRatio; + } + wPrefGetFloat("misc", message, &parSeparation, parSeparation); + ParamLoadControls(&parSepPG); + ParamGroupRecord(&parSepPG); + parSepPD.option |= PDO_NORECORD; parFactorPD.option |= PDO_NORECORD; - controls[0] = parSepPD.control; - if (parType == PAR_TRACK) - controls[1] = parFactorPD.control; - else - controls[1] = NULL; - controls[2] = NULL; - labels[0] = N_("Separation"); - labels[1] = N_("Radius Factor"); - InfoSubstituteControls(controls, labels); - parSepPD.option &= ~PDO_NORECORD; - parFactorPD.option &= ~PDO_NORECORD; - Dpa.anchor_Trk = NULL; - tempSegs_da.cnt = 0; - SetAllTrackSelect( FALSE ); - return C_CONTINUE; + controls[0] = parSepPD.control; + if (parType == PAR_TRACK) { + controls[1] = parFactorPD.control; + } else { + controls[1] = NULL; + } + controls[2] = NULL; + labels[0] = N_("Separation"); + labels[1] = N_("Radius Factor"); + InfoSubstituteControls(controls, labels); + parSepPD.option &= ~PDO_NORECORD; + parFactorPD.option &= ~PDO_NORECORD; + Dpa.anchor_Trk = NULL; + DYNARR_RESET( trkSeg_t, tempSegs_da ); + SetAllTrackSelect( FALSE ); + return C_CONTINUE; - case wActionMove: - tempSegs_da.cnt = 0; - Dpa.anchor_Trk = NULL; - if (parType == PAR_TRACK) - Dpa.anchor_Trk = OnTrack(&pos, FALSE, TRUE); - else - Dpa.anchor_Trk = OnTrack(&pos, FALSE, FALSE); + case wActionMove: + DYNARR_RESET( trkSeg_t, tempSegs_da ); + Dpa.anchor_Trk = NULL; + if (parType == PAR_TRACK) { + Dpa.anchor_Trk = OnTrack(&pos, FALSE, TRUE); + } else { + Dpa.anchor_Trk = OnTrack(&pos, FALSE, FALSE); + } - if (!Dpa.anchor_Trk) { - return C_CONTINUE; - } - if (Dpa.anchor_Trk && !CheckTrackLayerSilent(Dpa.anchor_Trk)) { - Dpa.anchor_Trk = NULL; - return C_CONTINUE; - } - if (!QueryTrack(Dpa.anchor_Trk, Q_CAN_PARALLEL)) { - Dpa.anchor_Trk = NULL; - return C_CONTINUE; - } - break; - case C_DOWN: - Dpa.anchor_Trk = NULL; - tempSegs_da.cnt = 0; - if (parSeparation < 0.0) { - ErrorMessage(MSG_PARALLEL_SEP_GTR_0); - return C_ERROR; - } + if (!Dpa.anchor_Trk) { + return C_CONTINUE; + } + if (Dpa.anchor_Trk && !CheckTrackLayerSilent(Dpa.anchor_Trk)) { + Dpa.anchor_Trk = NULL; + return C_CONTINUE; + } + if (!QueryTrack(Dpa.anchor_Trk, Q_CAN_PARALLEL)) { + Dpa.anchor_Trk = NULL; + return C_CONTINUE; + } + break; + case C_DOWN: + Dpa.anchor_Trk = NULL; + DYNARR_RESET( trkSeg_t, tempSegs_da ); + if (parSeparation < 0.0) { + ErrorMessage(MSG_PARALLEL_SEP_GTR_0); + return C_ERROR; + } - controls[0] = parSepPD.control; - controls[1] = parFactorPD.control; - controls[2] = NULL; - labels[0] = N_("Separation"); - labels[1] = N_("Radius factor"); - InfoSubstituteControls(controls, labels); - ParamLoadData(&parSepPG); - Dpa.orig = pos; - if (parType == PAR_TRACK) + controls[0] = parSepPD.control; + controls[1] = parFactorPD.control; + controls[2] = NULL; + labels[0] = N_("Separation"); + labels[1] = N_("Radius factor"); + InfoSubstituteControls(controls, labels); + ParamLoadData(&parSepPG); + Dpa.orig = pos; + if (parType == PAR_TRACK) { Dpa.Trk = OnTrack(&pos, FALSE, TRUE); - else - Dpa.Trk = OnTrack(&pos, FALSE, FALSE); //Also lines for line - if (!Dpa.Trk) { - return C_CONTINUE; - } - if (!QueryTrack(Dpa.Trk, Q_CAN_PARALLEL)) { - Dpa.Trk = NULL; - InfoMessage(_(" Track/Line doesn't support parallel")); - wBeep(); - return C_CONTINUE; - } + } else { + Dpa.Trk = OnTrack(&pos, FALSE, FALSE); //Also lines for line + } + if (!Dpa.Trk) { + return C_CONTINUE; + } + if (!QueryTrack(Dpa.Trk, Q_CAN_PARALLEL)) { + Dpa.Trk = NULL; + InfoMessage(_(" Track/Line doesn't support parallel")); + wBeep(); + return C_CONTINUE; + } - parRFactor = (2864.0*(double)parSepFactor)/curScaleRatio; + parRFactor = (2864.0*(double)parSepFactor)/curScaleRatio; - if ((parType == PAR_TRACK) && (parSeparation == 0.0)) { - DIST_T orig_gauge = GetTrkGauge(Dpa.Trk); - DIST_T new_gauge = GetScaleTrackGauge(GetLayoutCurScale()); - if (orig_gauge == new_gauge) { - ErrorMessage(MSG_PARALLEL_SEP_GTR_0); - return C_ERROR; - } - parSeparation = fabs(orig_gauge/2-new_gauge/2); - parRFactor = 0.0; - } else if (parType != PAR_TRACK) - parRFactor = 0.0; - /* in case query has changed things (eg joint) */ - /* - * this seems to cause problems so I commented it out - * until further investigation shows the necessity - */ - //Dpa.Trk = OnTrack( &Dpa.orig, TRUE, TRUE ); - tempSegs_da.cnt = 0; - /* no break */ + if ((parType == PAR_TRACK) && (parSeparation == 0.0)) { + DIST_T orig_gauge = GetTrkGauge(Dpa.Trk); + DIST_T new_gauge = GetScaleTrackGauge(GetLayoutCurScale()); + if (orig_gauge == new_gauge) { + ErrorMessage(MSG_PARALLEL_SEP_GTR_0); + return C_ERROR; + } + parSeparation = fabs(orig_gauge/2-new_gauge/2); + parRFactor = 0.0; + } else if (parType != PAR_TRACK) { + parRFactor = 0.0; + } + /* in case query has changed things (eg joint) */ + /* + * this seems to cause problems so I commented it out + * until further investigation shows the necessity + */ + //Dpa.Trk = OnTrack( &Dpa.orig, TRUE, TRUE ); + DYNARR_RESET( trkSeg_t, tempSegs_da ); + /* no break */ - case C_MOVE: - if (Dpa.Trk == NULL) { - return C_CONTINUE; - } - tempSegs_da.cnt = 0; - if (!MakeParallelTrack(Dpa.Trk, pos, parSeparation, parRFactor, NULL, &p0, &p1, - parType == PAR_TRACK)) { - Dpa.Trk = NULL; - return C_CONTINUE; - } - return C_CONTINUE; + case C_MOVE: + if (Dpa.Trk == NULL) { + return C_CONTINUE; + } + DYNARR_RESET( trkSeg_t, tempSegs_da ); + if (!MakeParallelTrack(Dpa.Trk, pos, parSeparation, parRFactor, NULL, &p0, &p1, + parType == PAR_TRACK)) { + Dpa.Trk = NULL; + return C_CONTINUE; + } + return C_CONTINUE; - case C_UP: - Dpa.anchor_Trk = NULL; - if (Dpa.Trk == NULL) { - return C_CONTINUE; - } - t0=t1=NULL; - if (parType == PAR_TRACK) { + case C_UP: + Dpa.anchor_Trk = NULL; + if (Dpa.Trk == NULL) { + return C_CONTINUE; + } + t0=t1=NULL; + if (parType == PAR_TRACK) { p = p0; - tempSegs_da.cnt = 0; + DYNARR_RESET( trkSeg_t, tempSegs_da ); if ((t0=OnTrack(&p, FALSE, TRUE)) != NULL) { ep0 = PickEndPoint(p, t0); if (ep0 < 0 || GetTrkEndTrk(t0,ep0) != NULL) { @@ -222,23 +226,23 @@ static STATUS_T CmdParallel(wAction_t action, coOrd pos) } } } - } - UndoStart(_("Create Parallel Track"), "newParallel"); - if (!MakeParallelTrack(Dpa.Trk, pos, parSeparation, parRFactor, &t, NULL, NULL, - parType == PAR_TRACK)) { - tempSegs_da.cnt = 0; - return C_TERMINATE; - } - if (parType == PAR_TRACK) { - if (GetTrkGauge(Dpa.Trk)> parSeparation) { - SetTrkNoTies(t, TRUE); - } - //CopyAttributes( Dpa.Trk, t ); Don't force scale or track width or Layer - SetTrkBits(t,(GetTrkBits(t)&TB_HIDEDESC) | (GetTrkBits(Dpa.Trk)&~TB_HIDEDESC)); + } + UndoStart(_("Create Parallel Track"), "newParallel"); + if (!MakeParallelTrack(Dpa.Trk, pos, parSeparation, parRFactor, &t, NULL, NULL, + parType == PAR_TRACK)) { + DYNARR_RESET( trkSeg_t, tempSegs_da ); + return C_TERMINATE; + } + if (parType == PAR_TRACK) { + if (GetTrkGauge(Dpa.Trk)> parSeparation) { + SetTrkNoTies(t, TRUE); + } + //CopyAttributes( Dpa.Trk, t ); Don't force scale or track width or Layer + SetTrkBits(t,(GetTrkBits(t)&TB_HIDEDESC) | (GetTrkBits(Dpa.Trk)&~TB_HIDEDESC)); if (t0) { a = NormalizeAngle(GetTrkEndAngle(t0, ep0) - GetTrkEndAngle(t, - 0) + (180.0+connectAngle/2.0)); + 0) + (180.0+connectAngle/2.0)); if (a < connectAngle) { DrawEndPt(&mainD, t0, ep0, wDrawColorWhite); ConnectTracks(t0, ep0, t, 0); @@ -247,55 +251,58 @@ static STATUS_T CmdParallel(wAction_t action, coOrd pos) } if (t1) { a = NormalizeAngle(GetTrkEndAngle(t1, ep1) - GetTrkEndAngle(t, - 1) + (180.0+connectAngle/2.0)); + 1) + (180.0+connectAngle/2.0)); if (a < connectAngle) { DrawEndPt(&mainD, t1, ep1, wDrawColorWhite); ConnectTracks(t1, ep1, t, 1); DrawEndPt(&mainD, t1, ep1, wDrawColorBlack); } } - } - DrawNewTrack(t); - UndoEnd(); - InfoSubstituteControls(NULL, NULL); - if (parType == PAR_TRACK) - sprintf(message, "parallel-separation-%s", curScaleName); - else - sprintf(message, "parallel-line-separation-%s", curScaleName); - wPrefSetFloat("misc", message, parSeparation); - tempSegs_da.cnt = 0; - return C_TERMINATE; + } + DrawNewTrack(t); + UndoEnd(); + InfoSubstituteControls(NULL, NULL); + if (parType == PAR_TRACK) { + sprintf(message, "parallel-separation-%s", curScaleName); + } else { + sprintf(message, "parallel-line-separation-%s", curScaleName); + } + wPrefSetFloat("misc", message, parSeparation); + DYNARR_RESET( trkSeg_t, tempSegs_da ); + return C_TERMINATE; - case C_REDRAW: - if (Dpa.anchor_Trk) { + case C_REDRAW: + if (Dpa.anchor_Trk) { DrawTrack(Dpa.anchor_Trk,&tempD, - wDrawColorPreviewSelected); //Special color means THICK3 as well - } - if (tempSegs_da.cnt>0) { - DrawSegs( &tempD, zero, 0.0, &tempSegs(0), tempSegs_da.cnt, trackGauge, - wDrawColorBlack ); - } - return C_CONTINUE; + wDrawColorPreviewSelected); //Special color means THICK3 as well + } + DrawSegsDA( &tempD, NULL, zero, 0.0, &tempSegs_da, trackGauge, wDrawColorBlack, + 0 ); + return C_CONTINUE; - case C_CANCEL: - Dpa.anchor_Trk = NULL; - tempSegs_da.cnt = 0; - InfoSubstituteControls(NULL, NULL); - return C_TERMINATE; + case C_CANCEL: + Dpa.anchor_Trk = NULL; + DYNARR_RESET( trkSeg_t, tempSegs_da ); + InfoSubstituteControls(NULL, NULL); + return C_TERMINATE; - } - return C_CONTINUE; + } + return C_CONTINUE; } -#include "bitmaps/parallel.xpm" -#include "bitmaps/parallel-line.xpm" +#include "bitmaps/parallel.xpm3" +#include "bitmaps/parallel-line.xpm3" EXPORT void InitCmdParallel( wMenu_p menu ) { ButtonGroupBegin( _("Parallel"), "cmdParallelSetCmd", _("Parallel") ); - AddMenuButton( menu, CmdParallel, "cmdParallelTrack", _("Parallel Track"), wIconCreatePixMap(parallel_xpm[iconSize]), LEVEL0_50, IC_STICKY|IC_POPUP|IC_WANT_MOVE, ACCL_PARALLEL, I2VP(0) ); - AddMenuButton( menu, CmdParallel, "cmdParallelLine", _("Parallel Line"), wIconCreatePixMap(parallel_line_xpm[iconSize]), LEVEL0_50, IC_STICKY|IC_POPUP|IC_WANT_MOVE, ACCL_PARALLEL, I2VP(1) ); + AddMenuButton( menu, CmdParallel, "cmdParallelTrack", _("Parallel Track"), + wIconCreatePixMap(parallel_xpm3[iconSize]), LEVEL0_50, + IC_STICKY|IC_POPUP|IC_WANT_MOVE, ACCL_PARALLEL, I2VP(0) ); + AddMenuButton( menu, CmdParallel, "cmdParallelLine", _("Parallel Line"), + wIconCreatePixMap(parallel_line_xpm3[iconSize]), LEVEL0_50, + IC_STICKY|IC_POPUP|IC_WANT_MOVE, ACCL_PARALLEL, I2VP(1) ); ButtonGroupEnd(); ParamRegister( &parSepPG ); } diff --git a/app/bin/cprint.c b/app/bin/cprint.c index a8ae0c1..123ad99 100644 --- a/app/bin/cprint.c +++ b/app/bin/cprint.c @@ -1,5 +1,5 @@ /** \file cprint.c - * Printing functions. + * Printing functions. */ /* XTrkCad - Model Railroad CAD @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "custom.h" @@ -37,29 +37,31 @@ #define PRINTOPTION_SNAP (1<<0) typedef struct { - int x0, x1, y0, y1; - char * bm; - int memsize; - coOrd orig; - coOrd size; - ANGLE_T angle; - } bitmap_t; + int x0, x1, y0, y1; + char * bm; + int memsize; + coOrd orig; + coOrd size; + ANGLE_T angle; +} bitmap_t; static bitmap_t bm, bm0; #define BITMAP( BM, X, Y ) \ (BM).bm[ (X)-(BM).x0 + ((Y)-(BM).y0) * ((BM).x1-(BM).x0) ] static struct { - coOrd size; - coOrd orig; - ANGLE_T angle; - } currPrintGrid, newPrintGrid; + coOrd size; + coOrd orig; + ANGLE_T angle; +} currPrintGrid, newPrintGrid; -EXPORT coOrd GetPrintOrig() { +EXPORT coOrd GetPrintOrig() +{ return currPrintGrid.orig; } -EXPORT ANGLE_T GetPrintAngle() { +EXPORT ANGLE_T GetPrintAngle() +{ return currPrintGrid.angle; } /* @@ -70,7 +72,7 @@ EXPORT ANGLE_T GetPrintAngle() { static long printGaudy = 1; static long printRegistrationMarks = 1; static long printPageNumbers = 1; -static long printPhysSize = FALSE; +static long bIgnoreMargins = FALSE; static long printFormat = PORTRAIT; static long printOrder = 0; static long printGrid = 0; @@ -87,7 +89,7 @@ static coOrd maxPageSize; static coOrd realPageSize; static wWin_p printWin = NULL; -static wWin_p printMarginWin = NULL; +static wWin_p customMarginWin = NULL; static wMenu_p printGridPopupM; @@ -110,7 +112,7 @@ static char * printOrderLabels[] = { N_("Normal"), N_("Reverse"), NULL }; static char * printGaudyLabels[] = { N_("Engineering Data"), NULL }; static char * printRegistrationMarksLabels[] = { N_("Registration Marks (in 1:1 scale only)"), NULL }; static char * printPageNumberLabels[] = { N_("Page Numbers"), NULL }; -static char * printPhysSizeLabels[] = { N_("Ignore Page Margins"), NULL }; +static char * sIgnoreMarginsLabels[] = { N_("Ignore Page Margins"), NULL }; static char * printGridLabels[] = { N_("Snap Grid"), NULL }; static char * printRulerLabels[] = { N_("Layout Edge"), N_("Every Page"), N_("None"), NULL }; static char * printRoadbedLabels[] = { N_("Roadbed Outline"), NULL }; @@ -123,48 +125,50 @@ static paramFloatRange_t r_100_99999 = { -100, 99999, 0, PDO_NORANGECHECK_HIGH } static paramFloatRange_t r0_360 = { 0, 360 }; static paramData_t printPLs[] = { -/*0*/ { PD_LONG, &iPrintScale, "scale", 0, &rminScale_999, N_("Print Scale"), 0, I2VP(1) }, -/*1*/ { PD_FLOAT, &newPrintGrid.size.x, "pagew", PDO_DIM|PDO_SMALLDIM|PDO_NORECORD|PDO_NOPREF, &r1_pgsz_x, N_("Page Width"), 0, I2VP(2) }, -/*2*/ { PD_BUTTON, PrintMaxPageSize, "max", PDO_DLGHORZ, NULL, N_("Max") }, -/*3*/ { PD_FLOAT, &newPrintGrid.size.y, "pageh", PDO_DIM|PDO_SMALLDIM|PDO_NORECORD|PDO_NOPREF, &r1_pgsz_y, N_("Height"), 0, I2VP(2) }, -/*4*/ { PD_BUTTON, PrintSnapShot, "snapshot", PDO_DLGHORZ, NULL, N_("Snap Shot") }, -/*5*/ { PD_RADIO, &printFormat, "format", 0, printFormatLabels, N_("Page Format"), BC_HORZ|BC_NOBORDER, I2VP(1) }, -/*6*/ { PD_RADIO, &printOrder, "order", PDO_DLGBOXEND, printOrderLabels, N_("Print Order"), BC_HORZ|BC_NOBORDER }, -/*7*/ { PD_MESSAGE, N_("Print "), NULL, PDO_DLGRESETMARGIN| PDO_DLGNOLABELALIGN, I2VP(0) }, -/*8*/ { PD_TOGGLE, &printGaudy, "style", PDO_DLGNOLABELALIGN, printGaudyLabels, NULL, BC_HORZ|BC_NOBORDER, I2VP(1) }, + /*0*/ { PD_LONG, &iPrintScale, "scale", 0, &rminScale_999, N_("Print Scale"), 0, I2VP(1) }, + /*1*/ { PD_FLOAT, &newPrintGrid.size.x, "pagew", PDO_DIM|PDO_SMALLDIM|PDO_NORECORD|PDO_NOPREF, &r1_pgsz_x, N_("Page Width"), 0, I2VP(2) }, + /*2*/ { PD_BUTTON, PrintMaxPageSize, "max", PDO_DLGHORZ, NULL, N_("Max") }, + /*3*/ { PD_FLOAT, &newPrintGrid.size.y, "pageh", PDO_DIM|PDO_SMALLDIM|PDO_NORECORD|PDO_NOPREF, &r1_pgsz_y, N_("Height"), 0, I2VP(2) }, + /*4*/ { PD_BUTTON, PrintSnapShot, "snapshot", PDO_DLGHORZ, NULL, N_("Snap Shot") }, + /*5*/ { PD_RADIO, &printFormat, "format", 0, printFormatLabels, N_("Page Format"), BC_HORZ|BC_NOBORDER, I2VP(1) }, + /*6*/ { PD_RADIO, &printOrder, "order", PDO_DLGBOXEND, printOrderLabels, N_("Print Order"), BC_HORZ|BC_NOBORDER }, + /*7*/ { PD_MESSAGE, N_("Print "), NULL, PDO_DLGRESETMARGIN| PDO_DLGNOLABELALIGN, I2VP(0) }, + /*8*/ { PD_TOGGLE, &printGaudy, "style", PDO_DLGNOLABELALIGN, printGaudyLabels, NULL, BC_HORZ|BC_NOBORDER, I2VP(1) }, #define I_REGMARKS (9) -/*9*/ { PD_TOGGLE, &printRegistrationMarks, "registrationMarks", PDO_DLGNOLABELALIGN, printRegistrationMarksLabels, NULL, BC_HORZ|BC_NOBORDER }, + /*9*/ { PD_TOGGLE, &printRegistrationMarks, "registrationMarks", PDO_DLGNOLABELALIGN, printRegistrationMarksLabels, NULL, BC_HORZ|BC_NOBORDER }, #define I_PAGENUMBERS (10) -/*10*/ { PD_TOGGLE, &printPageNumbers, "pageNumbers", PDO_DLGNOLABELALIGN, printPageNumberLabels, NULL, BC_HORZ | BC_NOBORDER }, + /*10*/ { PD_TOGGLE, &printPageNumbers, "pageNumbers", PDO_DLGNOLABELALIGN, printPageNumberLabels, NULL, BC_HORZ | BC_NOBORDER }, #define I_GRID (11) -/*11*/ { PD_TOGGLE, &printGrid, "grid", PDO_DLGNOLABELALIGN, printGridLabels, NULL, BC_HORZ|BC_NOBORDER }, + /*11*/ { PD_TOGGLE, &printGrid, "grid", PDO_DLGNOLABELALIGN, printGridLabels, NULL, BC_HORZ|BC_NOBORDER }, #define I_RULER (12) -/*12*/ { PD_RADIO, &printRuler, "ruler", 0, printRulerLabels, N_("Rulers:"), BC_HORZ|BC_NOBORDER }, + /*12*/ { PD_RADIO, &printRuler, "ruler", 0, printRulerLabels, N_("Rulers:"), BC_HORZ|BC_NOBORDER }, #define I_CENTERLINE (13) -/*13*/ { PD_TOGGLE, &printCenterLine, "centerLine", PDO_DLGNOLABELALIGN, printCenterLineLabels, NULL, BC_HORZ|BC_NOBORDER }, + /*13*/ { PD_TOGGLE, &printCenterLine, "centerLine", PDO_DLGNOLABELALIGN, printCenterLineLabels, NULL, BC_HORZ|BC_NOBORDER }, #define I_ROADBED (14) -/*14*/{ PD_TOGGLE, &printRoadbed, "roadbed", PDO_DLGNOLABELALIGN, printRoadbedLabels, NULL, BC_HORZ|BC_NOBORDER }, + /*14*/{ PD_TOGGLE, &printRoadbed, "roadbed", PDO_DLGNOLABELALIGN, printRoadbedLabels, NULL, BC_HORZ|BC_NOBORDER }, #define I_ROADBEDWIDTH (15) -/*15*/{ PD_FLOAT, &printRoadbedWidth, "roadbedWidth", PDO_DIM , &r0_, N_(" Width") }, -/*16*/ { PD_TOGGLE, &printPhysSize, "physsize", PDO_DLGNOLABELALIGN, printPhysSizeLabels, NULL, BC_HORZ | BC_NOBORDER, I2VP(1) }, -/*17*/ { PD_BUTTON, DoPrintMargin, "margin", PDO_DLGHORZ|PDO_DLGBOXEND, NULL, N_("Margins") }, -/*18*/{ PD_FLOAT, &newPrintGrid.orig.x, "origx", PDO_DIM|PDO_DLGRESETMARGIN, &r_100_99999, N_("Origin: X"), 0, I2VP(2) }, -/*19*/ { PD_FLOAT, &newPrintGrid.orig.y, "origy", PDO_DIM, &r_100_99999, N_("Y"), 0, I2VP(2) }, -/*20*/ { PD_BUTTON, DoResetGrid, "reset", PDO_DLGHORZ, NULL, N_("Reset") }, -/*21*/ { PD_FLOAT, &newPrintGrid.angle, "origa", PDO_ANGLE|PDO_DLGBOXEND, &r0_360, N_("Angle"), 0, I2VP(2) }, -/*22*/ { PD_BUTTON, DoPrintSetup, "setup", PDO_DLGCMDBUTTON, NULL, N_("Setup") }, -/*23*/ { PD_BUTTON, SelectAllPages, "selall", 0, NULL, N_("Select All") }, -/*24*/ { PD_BUTTON, PrintClear, "clear", 0, NULL, N_("Clear") }, + /*15*/{ PD_FLOAT, &printRoadbedWidth, "roadbedWidth", PDO_DIM, &r0_, N_(" Width") }, + /*16*/ { PD_TOGGLE, &bIgnoreMargins, "physsize", PDO_DLGNOLABELALIGN, sIgnoreMarginsLabels, NULL, BC_HORZ | BC_NOBORDER, I2VP(1) }, + /*17*/ { PD_BUTTON, DoPrintMargin, "margin", PDO_DLGHORZ|PDO_DLGBOXEND, NULL, N_("Margins") }, + /*18*/{ PD_FLOAT, &newPrintGrid.orig.x, "origx", PDO_DIM|PDO_DLGRESETMARGIN, &r_100_99999, N_("Origin: X"), 0, I2VP(2) }, + /*19*/ { PD_FLOAT, &newPrintGrid.orig.y, "origy", PDO_DIM, &r_100_99999, N_("Y"), 0, I2VP(2) }, + /*20*/ { PD_BUTTON, DoResetGrid, "reset", PDO_DLGHORZ, NULL, N_("Reset") }, + /*21*/ { PD_FLOAT, &newPrintGrid.angle, "origa", PDO_ANGLE|PDO_DLGBOXEND, &r0_360, N_("Angle"), 0, I2VP(2) }, + /*22*/ { PD_BUTTON, DoPrintSetup, "setup", PDO_DLGCMDBUTTON, NULL, N_("Setup") }, + /*23*/ { PD_BUTTON, SelectAllPages, "selall", 0, NULL, N_("Select All") }, + /*24*/ { PD_BUTTON, PrintClear, "clear", 0, NULL, N_("Clear") }, #define I_PAGECNT (25) -/*25*/ { PD_MESSAGE, N_("0 pages"), NULL, 0, I2VP(80) }, -/*26*/ { PD_MESSAGE, N_("selected"), NULL, 0, I2VP(80) } + /*25*/ { PD_MESSAGE, N_("0 pages"), NULL, 0, I2VP(80) }, + /*26*/ { PD_MESSAGE, N_("selected"), NULL, 0, I2VP(80) } }; static paramGroup_t printPG = { "print", PGO_PREFMISCGROUP, printPLs, COUNT( printPLs ) }; -static struct { +struct margins_s { double top, right, bottom, left; -} printMargin = { 0.0, 0.0, 0.0, 0.0 }; +}; +static struct margins_s printerMargin = { 0.0, 0.0, 0.0, 0.0 }; +static struct margins_s customMargin = { 0.0, 0.0, 0.0, 0.0 }; /***************************************************************************** * @@ -174,10 +178,10 @@ static struct { /** * Update the dialog with the current number of selected pages. - * + * */ -static void +static void UpdatePageCount() { DynString msg; @@ -186,7 +190,7 @@ UpdatePageCount() DynStringPrintf(&msg, (pageCount == 1?_("%d page"):_("%d pages")), pageCount); ParamLoadMessage(&printPG, I_PAGECNT, DynStringToCStr(&msg)); ParamDialogOkActive(&printPG, pageCount != 0); - + DynStringFree(&msg); } @@ -198,11 +202,13 @@ static void ChangeDim( void ) bitmap_t tmpBm; BOOL_T selected; - MapGrid( zero, mapD.size, 0.0, currPrintGrid.orig, currPrintGrid.angle, currPrintGrid.size.x, currPrintGrid.size.y, - &x0, &x1, &y0, &y1 ); + MapGrid( zero, mapD.size, 0.0, currPrintGrid.orig, currPrintGrid.angle, + currPrintGrid.size.x, currPrintGrid.size.y, + &x0, &x1, &y0, &y1 ); - if ( x0==bm.x0 && x1==bm.x1 && y0==bm.y0 && y1==bm.y1 ) + if ( x0==bm.x0 && x1==bm.x1 && y0==bm.y0 && y1==bm.y1 ) { return; + } size = (x1-x0) * (y1-y0); if (size > bm0.memsize) { bm0.bm = MyRealloc( bm0.bm, size ); @@ -245,15 +251,15 @@ static void ChangeDim( void ) static void MarkPage( - wIndex_t x, - wIndex_t y ) + wIndex_t x, + wIndex_t y ) /* * Hilite a area */ { coOrd p[4]; - -LOG1( log_print, ( "MarkPage( %d, %d )\n", x, y) ) + + LOG1( log_print, ( "MarkPage( %d, %d )\n", x, y) ) if ( x<bm.x0 || x>=bm.x1 || y<bm.y0 || y>=bm.y1) { ErrorMessage( MSG_OUT_OF_BOUNDS ); return; @@ -266,7 +272,8 @@ LOG1( log_print, ( "MarkPage( %d, %d )\n", x, y) ) Rotate( &p[1], currPrintGrid.orig, currPrintGrid.angle ); Rotate( &p[2], currPrintGrid.orig, currPrintGrid.angle ); Rotate( &p[3], currPrintGrid.orig, currPrintGrid.angle ); -LOG( log_print, 2, ( "MP(%d,%d) [%0.3f %0.3f] x [%0.3f %0.3f]\n", x, y, p[0].x, p[0].y, p[2].x, p[2].y ) ) + LOG( log_print, 2, ( "MP(%d,%d) [%0.3f %0.3f] x [%0.3f %0.3f]\n", x, y, p[0].x, + p[0].y, p[2].x, p[2].y ) ) DrawHilightPolygon( &tempD, p, 4 ); } @@ -281,8 +288,9 @@ static void SelectPage( coOrd pos ) Rotate( &pos, zero, -currPrintGrid.angle ); x = (int)floor(pos.x/currPrintGrid.size.x); y = (int)floor(pos.y/currPrintGrid.size.y); - if ( x<bm.x0 || x>=bm.x1 || y<bm.y0 || y>=bm.y1) + if ( x<bm.x0 || x>=bm.x1 || y<bm.y0 || y>=bm.y1) { return; + } selected = BITMAP( bm, x, y ); pageCount += (selected?-1:1); BITMAP( bm, x, y ) = !selected; @@ -299,7 +307,8 @@ static void DrawPrintGrid( void ) { wIndex_t x, y; - DrawGrid( &tempD, &mapD.size, currPrintGrid.size.x, currPrintGrid.size.y, 0, 0, currPrintGrid.orig, currPrintGrid.angle, wDrawColorBlack, TRUE ); + DrawGrid( &tempD, &mapD.size, currPrintGrid.size.x, currPrintGrid.size.y, 0, 0, + currPrintGrid.orig, currPrintGrid.angle, wDrawColorBlack, TRUE ); for (y=bm.y0; y<bm.y1; y++) for (x=bm.x0; x<bm.x1; x++) @@ -316,33 +325,35 @@ static void DrawPrintGrid( void ) static drawCmd_t print_d = { - NULL, - &printDrawFuncs, - DC_PRINT, - 16.0, - 0.0, - {0.0, 0.0}, {1.0, 1.0}, - Pix2CoOrd, CoOrd2Pix }; + NULL, + &printDrawFuncs, + DC_PRINT, + 16.0, + 0.0, + {0.0, 0.0}, {1.0, 1.0}, + Pix2CoOrd, CoOrd2Pix +}; static drawCmd_t page_d = { - NULL, - &printDrawFuncs, - DC_PRINT, - 1.0, - 0.0, - {0.0, 0.0}, {1.0, 1.0}, - Pix2CoOrd, CoOrd2Pix }; + NULL, + &printDrawFuncs, + DC_PRINT, + 1.0, + 0.0, + {0.0, 0.0}, {1.0, 1.0}, + Pix2CoOrd, CoOrd2Pix +}; /** * Print the basic layout for a trackplan. This includes the frame and some * information like room size, print scale etc.. * - * \param roomSize IN size of the layout + * \param roomSize IN size of the layout */ static void PrintGaudyBox( - coOrd roomSize ) + coOrd roomSize ) { coOrd p00, p01, p10, p11; struct tm *tm; @@ -359,8 +370,9 @@ static void PrintGaudyBox( strftime( dat, STR_SIZE, "%x", tm ); smiggin = wDrawGetDPI( print_d.d ); - if (smiggin>4.0) + if (smiggin>4.0) { smiggin = 4.0/smiggin; + } pageW = currPrintGrid.size.x/print_d.scale; pageH = currPrintGrid.size.y/print_d.scale; /* Draw some lines */ @@ -405,19 +417,19 @@ static void PrintGaudyBox( DrawString( &page_d, p00, 0.0, GetLayoutSubtitle(), fp, 12.0, wDrawColorBlack ); sprintf( dat, _("PrintScale 1:%ld Room %s x %s Model Scale %s File %s"), - (long)printScale, - FormatDistance( roomSize.x ), - FormatDistance( roomSize.y ), - curScaleName, GetLayoutFilename() ); + (long)printScale, + FormatDistance( roomSize.x ), + FormatDistance( roomSize.y ), + curScaleName, GetLayoutFilename() ); p00.x = 0.05; p00.y = 0.25+0.05; DrawString( &page_d, p00, 0.0, dat, fp, 14.0, wDrawColorBlack ); } static void PrintPlainBox( - int x, - int y, - coOrd *corners ) + int x, + int y, + coOrd *corners ) { coOrd p00, p01, p10, p11; char tmp[30]; @@ -426,8 +438,9 @@ static void PrintPlainBox( DIST_T smiggin; smiggin = wDrawGetDPI( print_d.d ); - if (smiggin>4.0) + if (smiggin>4.0) { smiggin = 4.0/smiggin; + } pageW = currPrintGrid.size.x/print_d.scale; pageH = currPrintGrid.size.y/print_d.scale; @@ -481,7 +494,7 @@ static void PrintEnableControls( void ) printRegistrationMarks = 0; ParamControlActive( &printPG, I_REGMARKS, FALSE ); } - if (printScale <= (twoRailScale*2+1)/2.0) { + if ( DrawTwoRails( &print_d, 1 ) ) { ParamLoadControl( &printPG, I_ROADBED ); ParamControlActive( &printPG, I_ROADBED, TRUE ); ParamControlActive( &printPG, I_ROADBEDWIDTH, TRUE ); @@ -516,20 +529,21 @@ static void PrintUpdate( int inx0 ) } currPrintGrid = newPrintGrid; for ( inx = 0; inx < COUNT( printPLs ); inx++ ) { - if ( inx != inx0 && printPLs[inx].context == I2VP(2) ) + if ( inx != inx0 && printPLs[inx].context == I2VP(2) ) { ParamLoadControl( &printPG, inx ); + } } ChangeDim(); } -static void SetPageSize( BOOL_T doScale ) +static void SetMaxPageSize( BOOL_T doScale ) { WDOUBLE_T temp, x, y; wPrintGetPageSize( &x, &y ); - if (!printPhysSize) { - x -= (printMargin.left+printMargin.right); - y -= (printMargin.top+printMargin.bottom); + if (!bIgnoreMargins) { + x -= (customMargin.left+customMargin.right); + y -= (customMargin.top+customMargin.bottom); } maxPageSize.x = x; maxPageSize.y = y; @@ -543,8 +557,9 @@ static void SetPageSize( BOOL_T doScale ) printRotate = FALSE; } if (doScale) { - if (printGaudy) + if (printGaudy) { maxPageSize.y -= 1.0; + } maxPageSize.x *= printScale; maxPageSize.y *= printScale; } @@ -554,7 +569,7 @@ static void SetPageSize( BOOL_T doScale ) /** * Select all pages for printing. - * + * */ static void SelectAllPages(void) @@ -576,7 +591,7 @@ static void PrintMaxPageSize( void ) * (depending on paper size, scale and orientation) */ { - SetPageSize( TRUE ); + SetMaxPageSize( TRUE ); currPrintGrid.size = maxPageSize; newPrintGrid = currPrintGrid; ParamLoadControls( &printPG ); @@ -591,7 +606,7 @@ static void DoPrintScale( void ) * Called whenever print scale or orientation changes. */ { - printScale = iPrintScale; + print_d.scale = printScale = iPrintScale; PrintMaxPageSize(); PrintEnableControls(); } @@ -603,38 +618,42 @@ static void DoPrintScale( void ) static void PrintMarginReset(); static paramFloatRange_t r0_1 = { 0.0, 1.0, 50 }; -static paramData_t printMarginPLs[] = { +static paramData_t customMarginPLs[] = { #define I_PM_FIRST (0) - { PD_FLOAT, &printMargin.top, "marginT", PDO_DIM|PDO_NOPREF, &r0_1, NULL, 0, NULL }, - { PD_FLOAT, &printMargin.right, "marginR", PDO_DIM|PDO_NOPREF, &r0_1, NULL, 0, NULL }, - { PD_FLOAT, &printMargin.bottom, "marginB", PDO_DIM|PDO_NOPREF, &r0_1, NULL, 0, NULL }, - { PD_FLOAT, &printMargin.left, "marginL", PDO_DIM|PDO_NOPREF, &r0_1, NULL, 0, NULL }, + { PD_FLOAT, &customMargin.top, "marginT", PDO_DIM|PDO_NOPREF, &r0_1, NULL, BO_IGNFOCUS, NULL }, + { PD_FLOAT, &customMargin.right, "marginR", PDO_DIM|PDO_NOPREF, &r0_1, NULL, BO_IGNFOCUS, NULL }, + { PD_FLOAT, &customMargin.bottom, "marginB", PDO_DIM|PDO_NOPREF, &r0_1, NULL, BO_IGNFOCUS, NULL }, + { PD_FLOAT, &customMargin.left, "marginL", PDO_DIM|PDO_NOPREF, &r0_1, NULL, BO_IGNFOCUS, NULL }, #define I_PM_COUNT (4) #define I_PM_MESSAGE (4) { PD_MESSAGE, NULL, NULL, 0, NULL }, #define I_PM_RESET (5) - { PD_BUTTON, PrintMarginReset, "marginReset", PDO_DLGCMDBUTTON, NULL, N_("Reset") } }; -static paramGroup_t printMarginPG = { "printMargin", PGO_PREFMISCGROUP|PGO_NODEFAULTPROC, printMarginPLs, COUNT( printMarginPLs ) }; + { PD_BUTTON, PrintMarginReset, "marginReset", PDO_DLGCMDBUTTON, NULL, N_("Reset") } +}; +static paramGroup_t customMarginPG = { "printMargin", PGO_PREFMISCGROUP|PGO_NODEFAULTPROC, customMarginPLs, COUNT( customMarginPLs ) }; static wLines_t aPmLines[] = { - { 1, 25, 11, 94, 11 }, - { 1, 94, 11, 94, 111 }, - { 1, 94, 111, 25, 111 }, - { 1, 25, 111, 25, 11 }}; + { 1, 25, 11, 94, 11 }, + { 1, 94, 11, 94, 111 }, + { 1, 94, 111, 25, 111 }, + { 1, 25, 111, 25, 11 } +}; static int pmxoff=14; static int pmyoff=5; static void PrintMarginLayout( - paramData_t * pd, - int index, - wWinPix_t colX, - wWinPix_t * w, - wWinPix_t * h ) + paramData_t * pd, + int index, + wWinPix_t colX, + wWinPix_t * w, + wWinPix_t * h ) { - if ( index < I_PM_FIRST || index > (I_PM_MESSAGE) ) + if ( index < I_PM_FIRST || index > (I_PM_MESSAGE) ) { return; + } if ( index == I_PM_MESSAGE ) { - *h = wControlGetPosY( printMarginPLs[I_PM_FIRST+2].control ) + wControlGetHeight( printMarginPLs[I_PM_FIRST+2].control ); + *h = wControlGetPosY( customMarginPLs[I_PM_FIRST+2].control ) + + wControlGetHeight( customMarginPLs[I_PM_FIRST+2].control ); return; } wWinPix_t x0, y0; @@ -642,9 +661,6 @@ static void PrintMarginLayout( y0 = (aPmLines[index-I_PM_FIRST].y0+aPmLines[index-I_PM_FIRST].y1)/2; x0 -= pmxoff; y0 -= pmyoff; -// y0 += wControlGetPosY( printMarginPLs[0].control ) + wControlGetHeight( printMarginPLs[0].control ); -// x0 -= wControlGetWidth( printMarginPLs[index-I_PM_FIRST].control )/2; -// y0 -= wControlGetHeight( printMarginPLs[index-I_PM_FIRST].control )/2; *w = x0; *h = y0; } @@ -652,85 +668,98 @@ static void PrintMarginLayout( static const char * sPrinterName = NULL; -static BOOL_T SetMargins() +/** + * Get saved customMargins (default values = printerMargins) + * Return true is any values differ from default + */ +static void GetMargins() { - double top, right, bottom, left; - wPrintGetMargins( &top, &right, &bottom, &left ); + wPrintGetMargins( &printerMargin.top, &printerMargin.right, + &printerMargin.bottom, &printerMargin.left ); sprintf( message, "%s-marginT", sPrinterName ); - wPrefGetFloat( "printer", message, &printMargin.top, top ); + wPrefGetFloat( "printer", message, &customMargin.top, printerMargin.top ); sprintf( message, "%s-marginR", sPrinterName ); - wPrefGetFloat( "printer", message, &printMargin.right, right ); + wPrefGetFloat( "printer", message, &customMargin.right, printerMargin.right ); sprintf( message, "%s-marginB", sPrinterName ); - wPrefGetFloat( "printer", message, &printMargin.bottom, bottom ); + wPrefGetFloat( "printer", message, &customMargin.bottom, printerMargin.bottom ); sprintf( message, "%s-marginL", sPrinterName ); - wPrefGetFloat( "printer", message, &printMargin.left, left ); - ParamLoadControls( &printMarginPG ); - return - fabs( top - printMargin.top ) >= 0.001 || - fabs( right - printMargin.right ) >= 0.001 || - fabs( bottom - printMargin.bottom ) >= 0.001 || - fabs( left - printMargin.left ) >= 0.001; + wPrefGetFloat( "printer", message, &customMargin.left, printerMargin.left ); + ParamLoadControls( &customMarginPG ); } +/** + * Process PrintMargin Ok button + * Save updates margins + * Recalc page size and update dialog items + */ static void DoPrintMarginOk( void * context ) { - wHide( printMarginWin ); + wHide( customMarginWin ); sprintf( message, "%s-marginT", sPrinterName ); - wPrefSetFloat( "printer", message, printMargin.top ); + wPrefSetFloat( "printer", message, customMargin.top ); sprintf( message, "%s-marginR", sPrinterName ); - wPrefSetFloat( "printer", message, printMargin.right ); + wPrefSetFloat( "printer", message, customMargin.right ); sprintf( message, "%s-marginB", sPrinterName ); - wPrefSetFloat( "printer", message, printMargin.bottom ); + wPrefSetFloat( "printer", message, customMargin.bottom ); sprintf( message, "%s-marginL", sPrinterName ); - wPrefSetFloat( "printer", message, printMargin.left ); - SetPageSize( TRUE ); + wPrefSetFloat( "printer", message, customMargin.left ); + SetMaxPageSize( TRUE ); for ( int inx = 0; inx < COUNT( printPLs ); inx++ ) { - if ( printPLs[inx].context == I2VP(2) ) + if ( printPLs[inx].context == I2VP(2) ) { ParamLoadControl( &printPG, inx ); + } } + ParamLoadControls( &customMarginPG ); DoPrintScale(); } static void PrintMarginDlgUpdate( paramGroup_p pg, int index, void * context ) { - wControlActive( printMarginPLs[I_PM_RESET].control, TRUE ); + wBool_t bEnable = + fabs( printerMargin.top - customMargin.top ) >= 0.001 || + fabs( printerMargin.right - customMargin.right ) >= 0.001 || + fabs( printerMargin.bottom - customMargin.bottom ) >= 0.001 || + fabs( printerMargin.left - customMargin.left ) >= 0.001; + wControlActive( customMarginPLs[I_PM_RESET].control, bEnable ); } +/** + * Reset custom margins to printer margins + */ static void PrintMarginReset() { - wPrintGetMargins( &printMargin.top, &printMargin.right, &printMargin.bottom, &printMargin.left ); - ParamLoadControls( &printMarginPG ); - wControlActive( printMarginPLs[I_PM_RESET].control, FALSE ); + customMargin = printerMargin; + ParamLoadControls( &customMarginPG ); + wControlActive( customMarginPLs[I_PM_RESET].control, FALSE ); } +/** + * Open PrintMargin dialog + */ static void DoPrintMargin( void ) { - sPrinterName = wPrintGetName(); - while ( *sPrinterName == '\0' ) { - int rc = NoticeMessage( MSG_NO_PRINTER_SELECTED, _("Ok"), _("Cancel") ); - if ( rc <= 0 ) - return; - DoPrintSetup(); - } - if ( printMarginWin == NULL ) { + if ( customMarginWin == NULL ) { int x=10, y=10; - printMarginWin = ParamCreateDialog( &printMarginPG, MakeWindowTitle(_("Print Margins")), _("Ok"), DoPrintMarginOk, NULL, TRUE, PrintMarginLayout, F_BLOCK, PrintMarginDlgUpdate ); - if ( printMarginWin == NULL ) + customMarginWin = ParamCreateDialog( &customMarginPG, + MakeWindowTitle(_("Print Margins")), _("Ok"), DoPrintMarginOk, NULL, TRUE, + PrintMarginLayout, F_BLOCK, PrintMarginDlgUpdate ); + if ( customMarginWin == NULL ) { return; + } for ( int i=0; i<COUNT( aPmLines ); i++ ) { aPmLines[i].x0 += x; aPmLines[i].x1 += x; aPmLines[i].y0 += y; aPmLines[i].y1 += y; } - wLineCreate( printMarginWin, NULL, COUNT( aPmLines ), aPmLines ); + wLineCreate( customMarginWin, NULL, COUNT( aPmLines ), aPmLines ); } - wMessageSetValue( (wMessage_p)printMarginPLs[I_PM_MESSAGE].control, sPrinterName ); - // Enable Reset button if we've changed anything - wControlActive( printMarginPLs[I_PM_RESET].control, SetMargins() ); - wShow( printMarginWin ); + wMessageSetValue( (wMessage_p)customMarginPLs[I_PM_MESSAGE].control, + sPrinterName ); + ParamLoadControls( &customMarginPG ); + wShow( customMarginWin ); } @@ -741,7 +770,8 @@ static void DoPrintSetup( void ) { wPrintSetup( (wPrintSetupCallBack_p)DoPrintScale ); sPrinterName = wPrintGetName(); - SetPageSize( TRUE ); + GetMargins(); + SetMaxPageSize( TRUE ); } @@ -778,7 +808,7 @@ static void PrintSnapShot( void ) POS_T t; PrintClear(); - SetPageSize( FALSE ); + SetMaxPageSize( FALSE ); pageSize = realPageSize; if (pageSize.x > pageSize.y) { t = pageSize.x; @@ -788,24 +818,26 @@ static void PrintSnapShot( void ) size = mapD.size; scaleH = 1; - for (i=0;i<3;i++) { + for (i=0; i<3; i++) { size = mapD.size; size.x += 2*0.5*scaleH; size.y += 2*0.5*scaleH; - if (printGaudy) + if (printGaudy) { size.y += 1.0*scaleH; + } scaleX = size.x/pageSize.x; scaleY = size.y/pageSize.y; scaleH = (long)ceil(max( scaleX, scaleY )); } scaleV = 1; - for (i=0;i<3;i++) { + for (i=0; i<3; i++) { size = mapD.size; size.x += 2*0.5*scaleV; size.y += 2*0.5*scaleV; - if (printGaudy) + if (printGaudy) { size.y += 1.0*scaleV; + } scaleX = size.x/pageSize.y; scaleY = size.y/pageSize.x; scaleV = (long)ceil(max( scaleX, scaleY )); @@ -819,17 +851,17 @@ static void PrintSnapShot( void ) printFormat = LANDSCAPE; } - SetPageSize( TRUE ); -/* - if (printFormat == LANDSCAPE) { - currPrintGrid.orig.x = -0.5*printScale; - currPrintGrid.orig.y = maxPageSize.x-0.5*printScale; - currPrintGrid.angle = 90.0; - } else {*/ - currPrintGrid.orig.x = -0.5*printScale; //Bigger rulers - currPrintGrid.orig.y = -0.5*printScale; //Bigger rules - currPrintGrid.angle = 0.0; -/* }*/ + SetMaxPageSize( TRUE ); + /* + if (printFormat == LANDSCAPE) { + currPrintGrid.orig.x = -0.5*printScale; + currPrintGrid.orig.y = maxPageSize.x-0.5*printScale; + currPrintGrid.angle = 90.0; + } else {*/ + currPrintGrid.orig.x = -0.5*printScale; //Bigger rulers + currPrintGrid.orig.y = -0.5*printScale; //Bigger rules + currPrintGrid.angle = 0.0; + /* }*/ currPrintGrid.size = maxPageSize; newPrintGrid = currPrintGrid; iPrintScale = (long)printScale; @@ -865,9 +897,11 @@ static void DrawRegistrationMarks( drawCmd_p d ) qq.x = p0.x = p1.x = (POS_T)GetDim(x); p0.y = 0.0; p1.y = mapD.size.y; - if (!ClipLine( &p0, &p1, d->orig, d->angle, d->size )) + if (!ClipLine( &p0, &p1, d->orig, d->angle, d->size )) { continue; - for ( y=(long)(ceil(PutDim(p0.y)/delta)*delta); (POS_T)y<PutDim(p1.y); y+=delta ) { + } + for ( y=(long)(ceil(PutDim(p0.y)/delta)*delta); (POS_T)y<PutDim(p1.y); + y+=delta ) { qq.y = (POS_T)GetDim(y); q0.x = q1.x = qq.x; if ( x%divisor == 0 && y%divisor == 0 ) { @@ -886,16 +920,18 @@ static void DrawRegistrationMarks( drawCmd_p d ) DrawLine( d, q0, q1, 0, wDrawColorBlack ); q0.x = qq.x + len/4;; q0.y = qq.y + len/4;; - if (units == UNITS_METRIC) + if (units == UNITS_METRIC) { sprintf( msg, "%0.1fm", (DOUBLE_T)x/100.0 ); - else + } else { sprintf( msg, "%ld\' %ld\"", x/12, x%12 ); + } DrawString( d, q0, 0.0, msg, fp, fs, wDrawColorBlack ); q0.y = qq.y - len*3/4; - if (units == UNITS_METRIC) + if (units == UNITS_METRIC) { sprintf( msg, "%0.1fm", (DOUBLE_T)y/100.0 ); - else + } else { sprintf( msg, "%ld\' %ld\"", y/12, y%12 ); + } DrawString( d, q0, 0.0, msg, fp, fs, wDrawColorBlack ); } } @@ -913,22 +949,22 @@ static void DrawRegistrationMarks( drawCmd_p d ) static char * FormatPageNumber(int x, int y) { - DynString formatted; - char *result; - - DynStringMalloc(&formatted, 16); - x -= bm.x0-1; - y -= bm.y0-1; - if (x > 0 && x <= bm.x1-bm.x0 && y > 0 && y <= bm.y1-bm.y0) { - DynStringPrintf(&formatted, "(%d/%d)", x, y); - } else { - DynStringCatCStr(&formatted, "(-/-)"); - } - - result = strdup(DynStringToCStr(&formatted)); - DynStringFree(&formatted); - - return (result); + DynString formatted; + char *result; + + DynStringMalloc(&formatted, 16); + x -= bm.x0-1; + y -= bm.y0-1; + if (x > 0 && x <= bm.x1-bm.x0 && y > 0 && y <= bm.y1-bm.y0) { + DynStringPrintf(&formatted, "(%d/%d)", x, y); + } else { + DynStringCatCStr(&formatted, "(-/-)"); + } + + result = strdup(DynStringToCStr(&formatted)); + DynStringFree(&formatted); + + return (result); } /** @@ -944,16 +980,16 @@ FormatPageNumber(int x, int y) static bool PrintPageNumber(int x, int y, DIST_T width, DIST_T height) { - coOrd printPosition; - coOrd textSize; + coOrd printPosition; + coOrd textSize; - char *positionText; - wFont_p fp = wStandardFont(F_HELV, TRUE, FALSE); - wFontSize_t fs = 64.0; + char *positionText; + wFont_p fp = wStandardFont(F_HELV, TRUE, FALSE); + wFontSize_t fs = 64.0; - positionText = FormatPageNumber(x, y); + positionText = FormatPageNumber(x, y); - if (strcmp(positionText,"(-/-)") != 0) { + if (strcmp(positionText,"(-/-)") != 0) { // even though we're printing into page_d, mainD must be used here DrawTextSize(&mainD, positionText, fp, fs, TRUE, &textSize); @@ -968,13 +1004,13 @@ PrintPageNumber(int x, int y, DIST_T width, DIST_T height) unsigned long options = page_d.options; page_d.options |= DC_OUTLINE; DrawString(&page_d, printPosition, 0.0, positionText, fp, fs, - wDrawColorGray(70)); + wDrawColorGray(70)); page_d.options = options; - } + } - free(positionText); + free(positionText); - return (TRUE); + return (TRUE); } /** @@ -988,34 +1024,35 @@ PrintPageNumber(int x, int y, DIST_T width, DIST_T height) void PrintNextPageNumberAt(int x, int y, coOrd position) { - char *pageNumber; - wFont_p fp = wStandardFont(F_HELV, FALSE, FALSE); - wFontSize_t fs = 8.0; - - pageNumber = FormatPageNumber(x, y); - //Suppress garbage page numbers - if (strcmp(pageNumber,"(-/-)") != 0) - DrawString(&page_d, position, 0.0, pageNumber, fp, fs, wDrawColorBlack); - free(pageNumber); + char *pageNumber; + wFont_p fp = wStandardFont(F_HELV, FALSE, FALSE); + wFontSize_t fs = 8.0; + + pageNumber = FormatPageNumber(x, y); + //Suppress garbage page numbers + if (strcmp(pageNumber,"(-/-)") != 0) { + DrawString(&page_d, position, 0.0, pageNumber, fp, fs, wDrawColorBlack); + } + free(pageNumber); } /** * Print the page numbers of all four adjoining pages (left, right, above, below) - * + * * \param x page index of current page x * \param y page index of current page y * \param pageW width of page * \param pageH height of page - * + * * \return TRUE */ static bool PrintNextPageNumbers(int x, int y, DIST_T pageW, DIST_T pageH) { - coOrd p00; + coOrd p00; - // above + // above if (printFormat == PORTRAIT) { p00.x = pageW / 2.0 - 20.0 / 72.0; p00.y = pageH - 10.0 / 72.0; @@ -1023,17 +1060,17 @@ PrintNextPageNumbers(int x, int y, DIST_T pageW, DIST_T pageH) p00.x = pageH / 2.0 - 20.0 / 72.0; p00.y = pageW - 10.0 / 72.0; } - PrintNextPageNumberAt(x, y + 1, p00); + PrintNextPageNumberAt(x, y + 1, p00); - // below + // below if (printFormat == PORTRAIT) { p00.y = 10.0 / 72.0; } else { p00.y = 10.0 / 72.0; } - PrintNextPageNumberAt(x, y-1, p00); + PrintNextPageNumberAt(x, y-1, p00); - // right + // right if (printFormat == PORTRAIT) { p00.y = pageH / 2 + 10.0 / 72.0; p00.x = pageW - 20.0 / 72.0; @@ -1041,7 +1078,7 @@ PrintNextPageNumbers(int x, int y, DIST_T pageW, DIST_T pageH) p00.y = pageW / 2 + 10.0 / 72.0; p00.x = pageH - 20.0 / 72.0; } - PrintNextPageNumberAt(x+1, y, p00); + PrintNextPageNumberAt(x+1, y, p00); // left if (printFormat == PORTRAIT) { @@ -1050,199 +1087,211 @@ PrintNextPageNumbers(int x, int y, DIST_T pageW, DIST_T pageH) p00.x = 10.0 / 72.0; } PrintNextPageNumberAt(x-1, y, p00); - return (TRUE); + return (TRUE); } static BOOL_T PrintPage( - int x, - int y ) + int x, + int y ) { coOrd orig, p[4], psave[4], minP, maxP; int i; coOrd clipOrig, clipSize; coOrd roomSize; - if (BITMAP(bm,x,y)) { - orig.x = currPrintGrid.orig.x + x*currPrintGrid.size.x; - orig.y = currPrintGrid.orig.y + y*currPrintGrid.size.y; - if (printPhysSize) { - orig.x += printMargin.left; - orig.y += printMargin.bottom; - } - Rotate( &orig, currPrintGrid.orig, currPrintGrid.angle ); - p[0] = p[1] = p[2] = p[3] = orig; - p[1].x = p[2].x = orig.x + currPrintGrid.size.x; - p[2].y = p[3].y = orig.y + currPrintGrid.size.y + - ( printGaudy ? printScale : 0.0 ); - Rotate( &p[0], orig, currPrintGrid.angle ); - Rotate( &p[1], orig, currPrintGrid.angle ); - Rotate( &p[2], orig, currPrintGrid.angle ); - Rotate( &p[3], orig, currPrintGrid.angle ); - minP = maxP = p[0]; - for (i=1; i<4; i++) { - if (maxP.x < p[i].x) maxP.x = p[i].x; - if (maxP.y < p[i].y) maxP.y = p[i].y; - if (minP.x > p[i].x) minP.x = p[i].x; - if (minP.y > p[i].y) minP.y = p[i].y; - } - maxP.x -= minP.x; - maxP.y -= minP.y; - print_d.d = page_d.d = wPrintPageStart(); - if (page_d.d == NULL) - return FALSE; - print_d.dpi = page_d.dpi = wDrawGetDPI( print_d.d ); - print_d.angle = currPrintGrid.angle; - print_d.orig = orig; - print_d.size = /*maxP*/ currPrintGrid.size; - page_d.orig = zero; - page_d.angle = 0.0; - if ( printGaudy ) { - Translate( &print_d.orig, orig, currPrintGrid.angle+180.0, printScale ); - print_d.size.y += printScale; - } - for (int i=0;i<4;i++) { - psave[i] = p[i]; - } - if (printRotate) { - rotateCW = (printFormat != PORTRAIT); - if (rotateCW) { - page_d.orig.x = realPageSize.y; - page_d.orig.y = 0.0; - page_d.angle = -90.0; - print_d.angle += -90.0; - Translate( &print_d.orig, print_d.orig, currPrintGrid.angle+90, maxPageSize.x ); - } else { - page_d.orig.x = 0.0; - page_d.orig.y = realPageSize.x; - page_d.angle = 90.0; - print_d.angle += 90.0; - Translate( &print_d.orig, print_d.orig, currPrintGrid.angle, - maxPageSize.y+(printGaudy?printScale:0) ); - } - page_d.size.x = print_d.size.y/printScale; - page_d.size.y = print_d.size.x/printScale; - print_d.size.x = currPrintGrid.size.y; - print_d.size.y = currPrintGrid.size.x; - } else { - page_d.size.x = print_d.size.x/printScale; - page_d.size.y = print_d.size.y/printScale; - } - wSetCursor( mainD.d, wCursorWait ); - print_d.scale = printScale; - if (print_d.d == NULL) - AbortProg( "wPrintPageStart" ); - clipOrig.x = clipOrig.y = 0; - clipSize.x = maxPageSize.x/printScale; - clipSize.y = maxPageSize.y/printScale; - GetRoomSize( &roomSize ); - if (printGaudy) { - PrintGaudyBox( roomSize ); - if ((!printRotate) || rotateCW) { - clipOrig.y = 1.0; - } - if (printRotate && rotateCW) { - print_d.size.x += printScale; - } - } - if (printRotate) { - wPrintClip( (clipOrig.y*print_d.dpi), (clipOrig.x*print_d.dpi), - (clipSize.y*print_d.dpi), (clipSize.x*print_d.dpi) ); - } else { - wPrintClip( (clipOrig.x*print_d.dpi), (clipOrig.y*print_d.dpi), - (clipSize.x*print_d.dpi), (clipSize.y*print_d.dpi) ); - } - p[0].x = p[3].x = 0.0; - p[1].x = p[2].x = roomSize.x; - p[0].y = p[1].y = 0.0; - p[2].y = p[3].y = roomSize.y; - - BOOL_T left_clear = FALSE, right_clear = FALSE, base_clear = FALSE, top_clear = FALSE; - - if (currPrintGrid.orig.x <= -0.5*printScale) left_clear = TRUE; - if (currPrintGrid.orig.y <= -0.5*printScale) base_clear = TRUE; - if (clipOrig.x + clipSize.x > roomSize.x + 0.5*printScale) right_clear = TRUE; - if (clipOrig.y + clipSize.y > roomSize.y + 0.5*printScale) top_clear = TRUE; - - if (printRuler != 2) { /* Not None so Edge or Every */ - DrawRuler( &print_d, p[0], p[1], 0.0, TRUE, !base_clear, wDrawColorBlack ); - DrawRuler( &print_d, p[0], p[3], 0.0, TRUE, left_clear, wDrawColorBlack ); - DrawRuler( &print_d, p[1], p[2], 0.0, TRUE, right_clear, wDrawColorBlack ); - DrawRuler( &print_d, p[3], p[2], 0.0, TRUE, !top_clear, wDrawColorBlack ); - } - if ( printRuler==1 && currPrintGrid.angle == 0 ) { /* Every Page and not rotated origin */ - if ( !printRotate ) { - p[2] = p[3] = print_d.orig; - p[3].x += print_d.size.x; - p[3].y += print_d.size.y; - } else if ( rotateCW ) { - p[2].x = print_d.orig.x - print_d.size.y; - p[2].y = print_d.orig.y; - p[3].x = print_d.orig.x; - p[3].y = print_d.orig.y + print_d.size.x; - } else { - p[2].x = print_d.orig.x; - p[2].y = print_d.orig.y - print_d.size.x; - p[3].x = print_d.orig.x + print_d.size.y; - p[3].y = print_d.orig.y; - } - if ( p[2].x > 0 ) - minP.x = p[2].x + 0.5 * print_d.scale; - else - minP.x = 0.0; - if ( p[3].x < roomSize.x ) - maxP.x = p[3].x - 0.5 * print_d.scale; - else - maxP.x = roomSize.x; - if ( p[2].y > 0 ) - minP.y = p[2].y + 0.5 * print_d.scale; - else - minP.y = 0.0; - if ( p[3].y < roomSize.y ) - maxP.y = p[3].y - 0.5 * print_d.scale; - else - maxP.y = roomSize.y; - p[0].y = 0.0; - p[1].y = maxP.y - minP.y; - if ( p[2].x > 0.5* print_d.scale ) { - p[0].x = p[1].x = p[2].x + 0.5* print_d.scale; - DrawRuler( &print_d, p[0], p[1], minP.y, TRUE, TRUE, wDrawColorBlack ); - } - if ( p[3].x < roomSize.x - 0.5 * print_d.scale ) { - p[0].x = p[1].x = p[3].x - 0.5 * print_d.scale; - DrawRuler( &print_d, p[0], p[1], minP.y, TRUE, FALSE, wDrawColorBlack ); - } - p[0].x = 0; - p[1].x = maxP.x - minP.x; - if ( p[2].y > 0.5 * print_d.scale ) { - p[0].y = p[1].y = p[2].y + 0.5 * print_d.scale; - DrawRuler( &print_d, p[0], p[1], minP.x, TRUE, FALSE, wDrawColorBlack ); - } - if ( p[3].y < roomSize.y - 0.5 * print_d.scale) { - p[0].y = p[1].y = p[3].y - 0.5 * print_d.scale; - DrawRuler( &print_d, p[0], p[1], minP.x, TRUE, TRUE, wDrawColorBlack ); - } - } + if (BITMAP(bm,x,y)) { + orig.x = currPrintGrid.orig.x + x*currPrintGrid.size.x; + orig.y = currPrintGrid.orig.y + y*currPrintGrid.size.y; + orig.x += printerMargin.left; + orig.y += printerMargin.bottom; + if (!bIgnoreMargins) { + orig.x -= customMargin.left; + orig.y -= customMargin.bottom; + } + Rotate( &orig, currPrintGrid.orig, currPrintGrid.angle ); + p[0] = p[1] = p[2] = p[3] = orig; + p[1].x = p[2].x = orig.x + currPrintGrid.size.x; + p[2].y = p[3].y = orig.y + currPrintGrid.size.y + + ( printGaudy ? printScale : 0.0 ); + Rotate( &p[0], orig, currPrintGrid.angle ); + Rotate( &p[1], orig, currPrintGrid.angle ); + Rotate( &p[2], orig, currPrintGrid.angle ); + Rotate( &p[3], orig, currPrintGrid.angle ); + minP = maxP = p[0]; + for (i=1; i<4; i++) { + if (maxP.x < p[i].x) { maxP.x = p[i].x; } + if (maxP.y < p[i].y) { maxP.y = p[i].y; } + if (minP.x > p[i].x) { minP.x = p[i].x; } + if (minP.y > p[i].y) { minP.y = p[i].y; } + } + maxP.x -= minP.x; + maxP.y -= minP.y; + print_d.d = page_d.d = wPrintPageStart(); + if (page_d.d == NULL) { + return FALSE; + } + print_d.dpi = page_d.dpi = wDrawGetDPI( print_d.d ); + print_d.angle = currPrintGrid.angle; + print_d.orig = orig; + print_d.size = /*maxP*/ currPrintGrid.size; + page_d.orig = zero; + page_d.angle = 0.0; + if ( printGaudy ) { + Translate( &print_d.orig, orig, currPrintGrid.angle+180.0, printScale ); + print_d.size.y += printScale; + } + for (int i=0; i<4; i++) { + psave[i] = p[i]; + } + if (printRotate) { + rotateCW = (printFormat != PORTRAIT); + if (rotateCW) { + page_d.orig.x = realPageSize.y; + page_d.orig.y = 0.0; + page_d.angle = -90.0; + print_d.angle += -90.0; + Translate( &print_d.orig, print_d.orig, currPrintGrid.angle+90, maxPageSize.x ); + } else { + page_d.orig.x = 0.0; + page_d.orig.y = realPageSize.x; + page_d.angle = 90.0; + print_d.angle += 90.0; + Translate( &print_d.orig, print_d.orig, currPrintGrid.angle, + maxPageSize.y+(printGaudy?printScale:0) ); + } + page_d.size.x = print_d.size.y/printScale; + page_d.size.y = print_d.size.x/printScale; + print_d.size.x = currPrintGrid.size.y; + print_d.size.y = currPrintGrid.size.x; + } else { + page_d.size.x = print_d.size.x/printScale; + page_d.size.y = print_d.size.y/printScale; + } + wSetCursor( mainD.d, wCursorWait ); + print_d.scale = printScale; + CHECK(print_d.d); + clipOrig.x = clipOrig.y = 0; + clipSize.x = maxPageSize.x/printScale; + clipSize.y = maxPageSize.y/printScale; + roomSize = mapD.size; + if (printGaudy) { + PrintGaudyBox( roomSize ); + if ((!printRotate) || rotateCW) { + clipOrig.y = 1.0; + } + if (printRotate && rotateCW) { + print_d.size.x += printScale; + } + } + if (printRotate) { + wPrintClip( (clipOrig.y*print_d.dpi), (clipOrig.x*print_d.dpi), + (clipSize.y*print_d.dpi), (clipSize.x*print_d.dpi) ); + } else { + wPrintClip( (clipOrig.x*print_d.dpi), (clipOrig.y*print_d.dpi), + (clipSize.x*print_d.dpi), (clipSize.y*print_d.dpi) ); + } + p[0].x = p[3].x = 0.0; + p[1].x = p[2].x = roomSize.x; + p[0].y = p[1].y = 0.0; + p[2].y = p[3].y = roomSize.y; + + BOOL_T left_clear = FALSE, right_clear = FALSE, base_clear = FALSE, + top_clear = FALSE; + + if (currPrintGrid.orig.x <= -0.5*printScale) { left_clear = TRUE; } + if (currPrintGrid.orig.y <= -0.5*printScale) { base_clear = TRUE; } + if (clipOrig.x + clipSize.x > roomSize.x + 0.5*printScale) { right_clear = TRUE; } + if (clipOrig.y + clipSize.y > roomSize.y + 0.5*printScale) { top_clear = TRUE; } + + if (printRuler != 2) { /* Not None so Edge or Every */ + DrawRuler( &print_d, p[0], p[1], 0.0, TRUE, !base_clear, wDrawColorBlack ); + DrawRuler( &print_d, p[0], p[3], 0.0, TRUE, left_clear, wDrawColorBlack ); + DrawRuler( &print_d, p[1], p[2], 0.0, TRUE, right_clear, wDrawColorBlack ); + DrawRuler( &print_d, p[3], p[2], 0.0, TRUE, !top_clear, wDrawColorBlack ); + } + if ( printRuler==1 + && currPrintGrid.angle == 0 ) { /* Every Page and not rotated origin */ + if ( !printRotate ) { + p[2] = p[3] = print_d.orig; + p[3].x += print_d.size.x; + p[3].y += print_d.size.y; + } else if ( rotateCW ) { + p[2].x = print_d.orig.x - print_d.size.y; + p[2].y = print_d.orig.y; + p[3].x = print_d.orig.x; + p[3].y = print_d.orig.y + print_d.size.x; + } else { + p[2].x = print_d.orig.x; + p[2].y = print_d.orig.y - print_d.size.x; + p[3].x = print_d.orig.x + print_d.size.y; + p[3].y = print_d.orig.y; + } + if ( p[2].x > 0 ) { + minP.x = p[2].x + 0.5 * print_d.scale; + } else { + minP.x = 0.0; + } + if ( p[3].x < roomSize.x ) { + maxP.x = p[3].x - 0.5 * print_d.scale; + } else { + maxP.x = roomSize.x; + } + if ( p[2].y > 0 ) { + minP.y = p[2].y + 0.5 * print_d.scale; + } else { + minP.y = 0.0; + } + if ( p[3].y < roomSize.y ) { + maxP.y = p[3].y - 0.5 * print_d.scale; + } else { + maxP.y = roomSize.y; + } + p[0].y = 0.0; + p[1].y = maxP.y - minP.y; + if ( p[2].x > 0.5* print_d.scale ) { + p[0].x = p[1].x = p[2].x + 0.5* print_d.scale; + DrawRuler( &print_d, p[0], p[1], minP.y, TRUE, TRUE, wDrawColorBlack ); + } + if ( p[3].x < roomSize.x - 0.5 * print_d.scale ) { + p[0].x = p[1].x = p[3].x - 0.5 * print_d.scale; + DrawRuler( &print_d, p[0], p[1], minP.y, TRUE, FALSE, wDrawColorBlack ); + } + p[0].x = 0; + p[1].x = maxP.x - minP.x; + if ( p[2].y > 0.5 * print_d.scale ) { + p[0].y = p[1].y = p[2].y + 0.5 * print_d.scale; + DrawRuler( &print_d, p[0], p[1], minP.x, TRUE, FALSE, wDrawColorBlack ); + } + if ( p[3].y < roomSize.y - 0.5 * print_d.scale) { + p[0].y = p[1].y = p[3].y - 0.5 * print_d.scale; + DrawRuler( &print_d, p[0], p[1], minP.x, TRUE, TRUE, wDrawColorBlack ); + } + } - if (printGrid) - DrawSnapGrid( &print_d, mapD.size, FALSE ); - roadbedWidth = printRoadbed?printRoadbedWidth:0.0; - if (printCenterLine) { - print_d.options |= DC_CENTERLINE; - } else { - print_d.options &= ~DC_CENTERLINE; - } - DrawTracks( &print_d, print_d.scale, minP, maxP ); - if (printRegistrationMarks && printScale == 1) - DrawRegistrationMarks( &print_d ); - if (printRegistrationMarks) - PrintPlainBox( x, y, psave ); - - if (printPageNumbers) { - PrintPageNumber(x, y, page_d.size.x, page_d.size.y); - PrintNextPageNumbers(x, y, page_d.size.x, page_d.size.y); - } - if ( !wPrintPageEnd( print_d.d ) ) - return FALSE; + if (printGrid) { + DrawSnapGrid( &print_d, mapD.size, FALSE ); + } + roadbedWidth = printRoadbed?printRoadbedWidth:0.0; + if (printCenterLine) { + print_d.options |= DC_CENTERLINE; + } else { + print_d.options &= ~DC_CENTERLINE; + } + DrawTracks( &print_d, print_d.scale, minP, maxP ); + if (printRegistrationMarks && printScale == 1) { + DrawRegistrationMarks( &print_d ); + } + if (printRegistrationMarks) { + PrintPlainBox( x, y, psave ); + } + + if (printPageNumbers) { + PrintPageNumber(x, y, page_d.size.x, page_d.size.y); + PrintNextPageNumbers(x, y, page_d.size.x, page_d.size.y); + } + if ( !wPrintPageEnd( print_d.d ) ) { + return FALSE; + } } return TRUE; } @@ -1272,23 +1321,25 @@ static void DoPrintPrint( void * junk ) wSetCursor( mainD.d, defaultCursor ); return; } - if (copies <= 0) + if (copies <= 0) { copies = 1; + } for ( copy=1; copy<=copies; copy++) { if ( printOrder == 0 ) { for (x=bm.x0; x<bm.x1; x++) for (y=bm.y1-1; y>=bm.y0; y--) - if (!PrintPage( x, y )) goto quitPrinting; + if (!PrintPage( x, y )) { goto quitPrinting; } } else { for (y=bm.y0; y<bm.y1; y++) for (x=bm.x0; x<bm.x1; x++) - if (!PrintPage( x, y )) goto quitPrinting; + if (!PrintPage( x, y )) { goto quitPrinting; } } for (y=bm.y0; y<bm.y1; y++) for (x=bm.x0; x<bm.x1; x++) if (BITMAP(bm,x,y)) { - if (copy >= copies) + if (copy >= copies) { BITMAP(bm,x,y) = 0; + } } } @@ -1329,11 +1380,14 @@ static void PrintGridRotate( void * pangle ) static void PrintChange( long changes ) { - if ( (changes&(CHANGE_MAP|CHANGE_UNITS|CHANGE_GRID))==0 || printWin==NULL || !wWinIsVisible(printWin) ) + if ( (changes&(CHANGE_MAP|CHANGE_UNITS|CHANGE_GRID))==0 || printWin==NULL + || !wWinIsVisible(printWin) ) { return; + } newPrintGrid = currPrintGrid; - if (!GridIsVisible()) + if (!GridIsVisible()) { printGrid = 0; + } ParamLoadControls( &printPG ); ParamControlActive( &printPG, I_GRID, GridIsVisible() ); PrintEnableControls(); @@ -1341,22 +1395,23 @@ static void PrintChange( long changes ) static void PrintDlgUpdate( - paramGroup_p pg, - int inx, - void * valueP ) + paramGroup_p pg, + int inx, + void * valueP ) { - if ( inx < 0 ) return; - if ( pg->paramPtr[inx].context == I2VP(1) ) + if ( inx < 0 ) { return; } + if ( pg->paramPtr[inx].context == I2VP(1) ) { DoPrintScale(); - else if ( pg->paramPtr[inx].context == I2VP(2) ) + } else if ( pg->paramPtr[inx].context == I2VP(2) ) { PrintUpdate( inx ); + } ParamControlActive( &printPG, I_RULER, currPrintGrid.angle == 0 ); TempRedraw(); // PrintDlgUpdate } static STATUS_T CmdPrint( - wAction_t action, - coOrd pos ) + wAction_t action, + coOrd pos ) /* * Print command: * @@ -1372,33 +1427,46 @@ static STATUS_T CmdPrint( switch (action) { case C_START: - if (!wPrintInit()) + if (!wPrintInit()) { return C_TERMINATE; + } printScale = iPrintScale; if (printWin == NULL) { rminScale_999.low = 1; - if (printScale < rminScale_999.low) + if (printScale < rminScale_999.low) { printScale = rminScale_999.low; + } print_d.scale = printScale; - printWin = ParamCreateDialog( &printPG, MakeWindowTitle(_("Print")), _("Print"), DoPrintPrint, (paramActionCancelProc)Reset, TRUE, NULL, 0, PrintDlgUpdate ); + printWin = ParamCreateDialog( &printPG, MakeWindowTitle(_("Print")), _("Print"), + DoPrintPrint, (paramActionCancelProc)Reset, TRUE, NULL, 0, PrintDlgUpdate ); } sPrinterName = wPrintGetName(); - SetMargins(); + while ( *sPrinterName == '\0' ) { + int rc = NoticeMessage( MSG_NO_PRINTER_SELECTED, _("Ok"), _("Cancel") ); + if ( rc <= 0 ) { + return C_TERMINATE; + } + DoPrintSetup(); + } + GetMargins(); wShow( printWin ); - SetPageSize( TRUE ); + SetMaxPageSize( TRUE ); if (currPrintGrid.size.x == 0.0) { currPrintGrid.size.x = maxPageSize.x; currPrintGrid.size.y = maxPageSize.y; } - if (currPrintGrid.size.x >= maxPageSize.x) + if (currPrintGrid.size.x >= maxPageSize.x) { currPrintGrid.size.x = maxPageSize.x; - if (currPrintGrid.size.y >= maxPageSize.y) + } + if (currPrintGrid.size.y >= maxPageSize.y) { currPrintGrid.size.y = maxPageSize.y; + } newPrintGrid = currPrintGrid; ParamLoadControls( &printPG ); pageCount = 0; UpdatePageCount(); -LOG( log_print, 2, ( "Page size = %0.3f %0.3f\n", currPrintGrid.size.x, currPrintGrid.size.y ) ) + LOG( log_print, 2, ( "Page size = %0.3f %0.3f\n", currPrintGrid.size.x, + currPrintGrid.size.y ) ) PrintChange( CHANGE_MAP|CHANGE_UNITS ); ChangeDim(); InfoMessage( _("Select pages to print, or drag to move print grid") ); @@ -1470,8 +1538,9 @@ LOG( log_print, 2, ( "Page size = %0.3f %0.3f\n", currPrintGrid.size.x, currPrin return C_TERMINATE; case C_CANCEL: - if (printWin == NULL) + if (printWin == NULL) { return C_TERMINATE; + } PrintClear(); wHide( printWin ); return C_TERMINATE; @@ -1491,7 +1560,7 @@ LOG( log_print, 2, ( "Page size = %0.3f %0.3f\n", currPrintGrid.size.x, currPrin } -#include "bitmaps/doc-print.xpm" +#include "bitmaps/doc-print.xpm3" EXPORT wIndex_t InitCmdPrint( wMenu_p menu ) { @@ -1501,8 +1570,10 @@ EXPORT wIndex_t InitCmdPrint( wMenu_p menu ) RegisterChangeNotification( PrintChange ); printGridPopupM = MenuRegister( "Print Grid Rotate" ); AddRotateMenu( printGridPopupM, PrintGridRotate ); - ParamRegister( &printMarginPG ); - return AddMenuButton( menu, CmdPrint, "cmdPrint", N_("Print..."), wIconCreatePixMap(doc_print_xpm[iconSize]), LEVEL0, IC_LCLICK|IC_POPUP3|IC_CMDMENU, ACCL_PRINT, NULL ); + ParamRegister( &customMarginPG ); + return AddMenuButton( menu, CmdPrint, "cmdPrint", N_("Print..."), + wIconCreatePixMap(doc_print_xpm3[iconSize]), LEVEL0, + IC_LCLICK|IC_POPUP3|IC_CMDMENU, ACCL_PRINT, NULL ); } /***************************************************************************** @@ -1514,7 +1585,7 @@ EXPORT wIndex_t InitCmdPrint( wMenu_p menu ) wDrawable_t printD, mainD; -void PrintPage( void * d, wIndex_t mode , wIndex_t x, wIndex_t y ) +void PrintPage( void * d, wIndex_t mode, wIndex_t x, wIndex_t y ) { lprintf( "printPage %dx%d at (%0.3f %0.3f)\n", x, y, orig.x, orig.y ); } @@ -1541,7 +1612,7 @@ void DumpMap( char * f, ANGLE_T a, ANGLE_T b ) } else { lprintf( " "); } - lprintf( "\n"); + lprintf( "\n"); } } @@ -1553,24 +1624,24 @@ struct { wAction_t cmd; coOrd pos; } cmds[] = { - { C_START, 0, 0 }, - { C_DOWN, 20.5, 12.4 }, - { C_MOVE, 20.5, 12.5 }, - { C_MOVE, 20.5, 12.3 }, - { C_MOVE, 39.3, 69.4 }, - { C_MOVE, 39.4, 4.5 }, - { C_MOVE, 2.4, 4.5 }, - { C_MOVE, 2.4, 50.3 }, - { C_UP, 0, 0 }, - { C_DOWN, 20.5, 12.4 }, - { C_UP, 0, 0 }, - { C_DOWN, 32.5, 4.4 }, - { C_UP, 0, 0 }, - { C_PRINT, 0, 0, }, - { C_START, 0, 0, }, - { C_DOWN, 45.3, 43.5 }, - { C_CANCEL, 0, 0 } - }; + { C_START, 0, 0 }, + { C_DOWN, 20.5, 12.4 }, + { C_MOVE, 20.5, 12.5 }, + { C_MOVE, 20.5, 12.3 }, + { C_MOVE, 39.3, 69.4 }, + { C_MOVE, 39.4, 4.5 }, + { C_MOVE, 2.4, 4.5 }, + { C_MOVE, 2.4, 50.3 }, + { C_UP, 0, 0 }, + { C_DOWN, 20.5, 12.4 }, + { C_UP, 0, 0 }, + { C_DOWN, 32.5, 4.4 }, + { C_UP, 0, 0 }, + { C_PRINT, 0, 0, }, + { C_START, 0, 0, }, + { C_DOWN, 45.3, 43.5 }, + { C_CANCEL, 0, 0 } +}; main( INT_T argc, char * argv[] ) { diff --git a/app/bin/cprofile.c b/app/bin/cprofile.c index 433e1d5..ba51383 100644 --- a/app/bin/cprofile.c +++ b/app/bin/cprofile.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "custom.h" @@ -102,9 +102,9 @@ static BOOL_T printVert = TRUE; static wMenu_p profilePopupM; static track_p profilePopupTrk; static EPINX_T profilePopupEp; -static wMenuToggle_p profilePopupToggles[3]; +static wMenuToggle_p profilePopupToggles[3]; -static int log_profile = 0; +static int log_profile = 0; #define LABELH (labelH*fontSize/screenProfileFontSize) #define LABELW (labelW*fontSize/screenProfileFontSize) @@ -113,10 +113,10 @@ static int log_profile = 0; #define PBR(FS) (1.0*(labelW*(FS)/screenProfileFontSize+3.0/mainD.dpi)) #define PBL(FS) (1.0*(labelW*(FS)/screenProfileFontSize+3.0/mainD.dpi)) static FLOAT_T labelH; -static FLOAT_T labelW; +static FLOAT_T labelW; -track_p pathStartTrk; +track_p pathStartTrk; EPINX_T pathStartEp; track_p pathEndTrk; EPINX_T pathEndEp; @@ -125,33 +125,33 @@ EPINX_T pathEndEp; #define NOP typedef struct { - track_p trk; - EPINX_T ep; - DIST_T elev; - DIST_T dist; - BOOL_T defined; /* from prev PE to current */ + track_p trk; + EPINX_T ep; + DIST_T elev; + DIST_T dist; + BOOL_T defined; /* from prev PE to current */ } profElem_t, *profElem_p; -static dynArr_t profElem_da; +static dynArr_t profElem_da; static profElem_p copyOfprofElem; -#define profElem(N) DYNARR_N( profElem_t, profElem_da, N ) +#define profElem(N) DYNARR_N( profElem_t, profElem_da, N ) typedef struct { - DIST_T dist; - char * name; + DIST_T dist; + char * name; } station_t, *station_p; -static dynArr_t station_da; +static dynArr_t station_da; #define station(N) DYNARR_N( station_t, station_da, N ) struct { - DIST_T totalD, minE; - int minC, maxC, incrC; - DIST_T scaleX, scaleY; -} prof; + DIST_T totalD, minE; + int minC, maxC, incrC; + DIST_T scaleX, scaleY; +} prof; /** @@ -161,17 +161,14 @@ struct { static void CreateCopyProfileElements() { - if (copyOfprofElem) { - MyFree(copyOfprofElem); - } - - copyOfprofElem = MyMalloc(profElem_da.cnt * sizeof(profElem_t)); - if (!copyOfprofElem) { - AbortProg("Couldn't allocate memory for profile copy\n"); - } - for (int i = 0; i < profElem_da.cnt; i++) { - copyOfprofElem[i] = profElem(i); - } + if (copyOfprofElem) { + MyFree(copyOfprofElem); + } + + copyOfprofElem = MyMalloc(profElem_da.cnt * sizeof(profElem_t)); + for (int i = 0; i < profElem_da.cnt; i++) { + copyOfprofElem[i] = profElem(i); + } } /** @@ -181,10 +178,10 @@ CreateCopyProfileElements() static void DestroyCopyOfProfileElements() { - if (copyOfprofElem) { - MyFree(copyOfprofElem); - copyOfprofElem = NULL; - } + if (copyOfprofElem) { + MyFree(copyOfprofElem); + copyOfprofElem = NULL; + } } @@ -198,118 +195,118 @@ DestroyCopyOfProfileElements() static void DrawProfile(drawCmd_p D, wFontSize_t fontSize, BOOL_T printVert) { - coOrd pl, pt, pb; - int inx; - DIST_T grade; - wFont_p fp; - static dynArr_t points_da; + coOrd pl, pt, pb; + int inx; + DIST_T grade; + wFont_p fp; + static dynArr_t points_da; #define points(N) DYNARR_N( coOrd, points_da, N ) - wDrawWidth lw; - station_p ps; - coOrd textsize; - - lw = (wDrawWidth)(D->dpi*1.0/mainD.dpi); - fp = wStandardFont(F_HELV, FALSE, FALSE); - DYNARR_RESET(pts_t, points_da); - - pb.x = pt.x = 0; - pb.y = prof.minE; - pt.y = GetDim(prof.maxC); - DrawLine(D, pb, pt, 0, snapGridColor); - pb.x = pt.x = prof.totalD; - DrawLine(D, pb, pt, 0, snapGridColor); - pb.x = 0; - pt.x = prof.totalD; - - // Draw horizontal grid and y scale - for (inx=prof.minC; inx<=prof.maxC; inx+=prof.incrC) { - coOrd textsize; - // grid line - pt.y = pb.y = GetDim(inx); - DrawLine(D, pb, pt, 0, snapGridColor); - // scale - sprintf(message, "%d", inx); - DrawTextSize(&mainD, message, wStandardFont(F_HELV, FALSE, FALSE), - screenProfileFontSize, FALSE, &textsize); - pl.x = ((-3.0/mainD.dpi) - textsize.y*0.5 - textsize.x) / prof.scaleX*D->scale; - pl.y = pb.y-LABELH/2/prof.scaleY*D->scale; - - DrawString(D, pl, 0.0, message, fp, fontSize*D->scale, borderColor); - } - - // show the measurement units - sprintf(message, "%s", units == UNITS_ENGLISH ? "in." : "cm"); - DrawTextSize(&mainD, message, wStandardFont(F_HELV, FALSE, FALSE), - screenProfileFontSize, FALSE, &textsize); - pl.x = ((-3.0 / mainD.dpi) - textsize.y*0.5 - textsize.x) / - prof.scaleX*D->scale; - pl.y += LABELH * 1.5 / prof.scaleY*D->scale; - DrawString(D, pl, 0.0, message, fp, fontSize*D->scale, borderColor); - - if (profElem_da.cnt <= 0) { - return; - } - - for (inx=0; inx<profElem_da.cnt; inx++) { - pt.y = profElem(inx).elev; - pt.x = profElem(inx).dist; - DYNARR_APPEND(pts_t, points_da, 10); - points(points_da.cnt-1) = pt; - } - pb.y = pt.y = prof.minE; - if (points_da.cnt > 1) { - DYNARR_APPEND(coOrd, points_da, 10); - pt.x = prof.totalD; - points(points_da.cnt-1) = pt; - DYNARR_APPEND(pts_t, points_da, 10); - pb.x = 0; - points(points_da.cnt-1) = pb; - DrawPoly(D, points_da.cnt, points_da.ptr, NULL, profileColorFill, 1, DRAW_FILL); - } - - pt.y = prof.minE-(2*LABELH+3.0/mainD.dpi)/prof.scaleY*D->scale; - for (inx=0; inx<station_da.cnt; inx++) { - ps = &station(inx); - DrawTextSize(&mainD, ps->name, fp, fontSize, FALSE, &textsize); - pt.x = ps->dist - textsize.x/2.0/prof.scaleX*D->scale; - if (pt.x < -PBR(screenProfileFontSize)) { - pt.x = -(PBR(screenProfileFontSize)-3/mainD.dpi)/prof.scaleX*D->scale; - } else if (pt.x+textsize.x > prof.totalD) { - pt.x = prof.totalD-(textsize.x-3/mainD.dpi)/prof.scaleX*D->scale; - } - DrawString(D, pt, 0.0, ps->name, fp, fontSize*D->scale, borderColor); - } - - pb.x = 0.0; - pb.y = prof.minE; + wDrawWidth lw; + station_p ps; + coOrd textsize; + + lw = (wDrawWidth)(D->dpi*1.0/mainD.dpi); + fp = wStandardFont(F_HELV, FALSE, FALSE); + DYNARR_RESET(pts_t, points_da); + + pb.x = pt.x = 0; + pb.y = prof.minE; + pt.y = GetDim(prof.maxC); + DrawLine(D, pb, pt, 0, snapGridColor); + pb.x = pt.x = prof.totalD; + DrawLine(D, pb, pt, 0, snapGridColor); + pb.x = 0; + pt.x = prof.totalD; + + // Draw horizontal grid and y scale + for (inx=prof.minC; inx<=prof.maxC; inx+=prof.incrC) { + coOrd textsize; + // grid line + pt.y = pb.y = GetDim(inx); + DrawLine(D, pb, pt, 0, snapGridColor); + // scale + sprintf(message, "%d", inx); + DrawTextSize(&mainD, message, wStandardFont(F_HELV, FALSE, FALSE), + screenProfileFontSize, FALSE, &textsize); + pl.x = ((-3.0/mainD.dpi) - textsize.y*0.5 - textsize.x) / prof.scaleX*D->scale; + pl.y = pb.y-LABELH/2/prof.scaleY*D->scale; + + DrawString(D, pl, 0.0, message, fp, fontSize*D->scale, borderColor); + } + + // show the measurement units + sprintf(message, "%s", units == UNITS_ENGLISH ? "in." : "cm"); + DrawTextSize(&mainD, message, wStandardFont(F_HELV, FALSE, FALSE), + screenProfileFontSize, FALSE, &textsize); + pl.x = ((-3.0 / mainD.dpi) - textsize.y*0.5 - textsize.x) / + prof.scaleX*D->scale; + pl.y += LABELH * 1.5 / prof.scaleY*D->scale; + DrawString(D, pl, 0.0, message, fp, fontSize*D->scale, borderColor); + + if (profElem_da.cnt <= 0) { + return; + } + + for (inx=0; inx<profElem_da.cnt; inx++) { + pt.y = profElem(inx).elev; + pt.x = profElem(inx).dist; + DYNARR_APPEND(pts_t, points_da, 10); + points(points_da.cnt-1) = pt; + } + pb.y = pt.y = prof.minE; + if (points_da.cnt > 1) { + DYNARR_APPEND(coOrd, points_da, 10); + pt.x = prof.totalD; + points(points_da.cnt-1) = pt; + DYNARR_APPEND(pts_t, points_da, 10); + pb.x = 0; + points(points_da.cnt-1) = pb; + DrawPoly(D, points_da.cnt, &points(0), NULL, profileColorFill, 1, DRAW_FILL); + } + + pt.y = prof.minE-(2*LABELH+3.0/mainD.dpi)/prof.scaleY*D->scale; + for (inx=0; inx<station_da.cnt; inx++) { + ps = &station(inx); + DrawTextSize(&mainD, ps->name, fp, fontSize, FALSE, &textsize); + pt.x = ps->dist - textsize.x/2.0/prof.scaleX*D->scale; + if (pt.x < -PBR(screenProfileFontSize)) { + pt.x = -(PBR(screenProfileFontSize)-3/mainD.dpi)/prof.scaleX*D->scale; + } else if (pt.x+textsize.x > prof.totalD) { + pt.x = prof.totalD-(textsize.x-3/mainD.dpi)/prof.scaleX*D->scale; + } + DrawString(D, pt, 0.0, ps->name, fp, fontSize*D->scale, borderColor); + } + + pb.x = 0.0; + pb.y = prof.minE; // mark the starting point for the profile - pt = points(0); - DrawLine(D, pb, pt, lw, snapGridColor); + pt = points(0); + DrawLine(D, pb, pt, lw, snapGridColor); DrawArc(D, pt, 0.05, 0, 360, TRUE, 2, wDrawColorGrey40); - if (units==UNITS_ENGLISH) { - sprintf(message, "%0.1f", PutDim(profElem(0).elev)+0.05); - } else { - sprintf(message, "%0.1f", PutDim(profElem(0).elev)+0.05); - } - if (printVert) { - pl.x = pt.x + LABELH/2.0/prof.scaleX*D->scale; - pl.y = pt.y + 2.0/mainD.dpi/prof.scaleY*D->scale + GetDim(prof.incrC) / 16;; - DrawString(D, pl, 270.0, message, fp, fontSize*D->scale, borderColor); - } else { - pl.x = pt.x+2.0/mainD.dpi/prof.scaleX*D->scale + GetDim(prof.incrC) / 16;; - pl.y = pt.y; - if (profElem_da.cnt>1 && profElem(0).elev < profElem(1).elev) { - pl.y -= LABELH/prof.scaleY*D->scale; - } - DrawString(D, pl, 0.0, message, fp, fontSize*D->scale, borderColor); - } - pl = pt; - - for (inx=1; inx<profElem_da.cnt; inx++) { - pt.y = profElem(inx).elev; - pb.x = pt.x = profElem(inx).dist; - pt = points(inx); + if (units==UNITS_ENGLISH) { + sprintf(message, "%0.1f", PutDim(profElem(0).elev)+0.05); + } else { + sprintf(message, "%0.1f", PutDim(profElem(0).elev)+0.05); + } + if (printVert) { + pl.x = pt.x + LABELH/2.0/prof.scaleX*D->scale; + pl.y = pt.y + 2.0/mainD.dpi/prof.scaleY*D->scale + GetDim(prof.incrC) / 16;; + DrawString(D, pl, 270.0, message, fp, fontSize*D->scale, borderColor); + } else { + pl.x = pt.x+2.0/mainD.dpi/prof.scaleX*D->scale + GetDim(prof.incrC) / 16;; + pl.y = pt.y; + if (profElem_da.cnt>1 && profElem(0).elev < profElem(1).elev) { + pl.y -= LABELH/prof.scaleY*D->scale; + } + DrawString(D, pl, 0.0, message, fp, fontSize*D->scale, borderColor); + } + pl = pt; + + for (inx=1; inx<profElem_da.cnt; inx++) { + pt.y = profElem(inx).elev; + pb.x = pt.x = profElem(inx).dist; + pt = points(inx); // draw line to x-axis for intermediate elevation points if (inx != profElem_da.cnt - 1) { @@ -322,62 +319,62 @@ static void DrawProfile(drawCmd_p D, wFontSize_t fontSize, BOOL_T printVert) // draw grade line DrawLine(D, pl, pt, lw*2, (profElem(inx).defined ? profileColorDefinedProfile : - profileColorUndefinedProfile)); - // draw the markers - DrawArc(D, pt, 0.05, 0, 360, TRUE, 2, wDrawColorGrey40); - - if (profElem(inx).dist > 0.1) { - grade = fabs(profElem(inx).elev-profElem(inx-1).elev)/ - (profElem(inx).dist-profElem(inx-1).dist); - sprintf(message, "%0.1f%%", round(grade*1000.0)/10.0); - DrawTextSize(&mainD, message, fp, fontSize, FALSE, &textsize); - pl.x = (points(inx).x+points(inx-1).x)/2.0; - pl.y = (points(inx).y+points(inx-1).y)/2.0; - if (printVert) { - pl.x += (LABELH/2)/prof.scaleX*D->scale; - pl.y += ((LABELH/2)*grade/prof.scaleX + 2.0/mainD.dpi/prof.scaleY)*D->scale; - DrawString(D, pl, 270.0, message, fp, fontSize*D->scale, borderColor); - } else { - pl.x -= (textsize.x/2)/prof.scaleX*D->scale; - pl.y += (textsize.x/2)*grade/prof.scaleX*D->scale; - DrawString(D, pl, 0.0, message, fp, fontSize*D->scale, borderColor); - } - } - if (units==UNITS_ENGLISH) { - if (prof.totalD > 240) { - sprintf(message, "%0.1f'", (round((profElem(inx).dist/12.0)*10.0)/10.0)); - } else { - sprintf(message, "%d'%0.1f\"", (int)floor((profElem(inx).dist)/12.0), - round(fmod(profElem(inx).dist,12.0)*10.0)/10.0); - } - } else { - if (PutDim(prof.totalD) > 10000) { - sprintf(message, "%0.1fm", (round(PutDim(profElem(inx).dist)/10.0)/10.0)); - } else if (PutDim(prof.totalD) > 100) { - sprintf(message, "%0.2fm", (round(PutDim(profElem(inx).dist))/100.0)); - } else { - sprintf(message, "%0.1fcm", round(PutDim(profElem(inx).dist)+0.5)); - } - } - DrawTextSize(&mainD, message, fp, fontSize, FALSE, &textsize); - pl.x = pb.x-(textsize.x/2)/prof.scaleX*D->scale; - pl.y = prof.minE-(LABELH+3.0/mainD.dpi)/prof.scaleY*D->scale; - DrawString(D, pl, 0.0, message, fp, fontSize*D->scale, borderColor); - sprintf(message, "%0.1f", round(PutDim(profElem(inx).elev)*100.0)/100.0); - if (printVert) { - pl.x = pt.x + LABELH/2.0/prof.scaleX*D->scale; - pl.y = pt.y + 2.0/mainD.dpi/prof.scaleY*D->scale+GetDim(prof.incrC) / 16; - DrawString(D, pl, 270.0, message, fp, fontSize*D->scale, borderColor); - } else { - pl.x = pt.x + 2.0/mainD.dpi/prof.scaleX*D->scale + GetDim(prof.incrC) / 16; - pl.y = pt.y; - if (inx != profElem_da.cnt-1 && profElem(inx).elev < profElem(inx+1).elev) { - pl.y -= LABELH/prof.scaleY*D->scale; - } - DrawString(D, pl, 0.0, message, fp, fontSize*D->scale, borderColor); - } - pl = pt; - } + profileColorUndefinedProfile)); + // draw the markers + DrawArc(D, pt, 0.05, 0, 360, TRUE, 2, wDrawColorGrey40); + + if (profElem(inx).dist > 0.1) { + grade = fabs(profElem(inx).elev-profElem(inx-1).elev)/ + (profElem(inx).dist-profElem(inx-1).dist); + sprintf(message, "%0.1f%%", round(grade*1000.0)/10.0); + DrawTextSize(&mainD, message, fp, fontSize, FALSE, &textsize); + pl.x = (points(inx).x+points(inx-1).x)/2.0; + pl.y = (points(inx).y+points(inx-1).y)/2.0; + if (printVert) { + pl.x += (LABELH/2)/prof.scaleX*D->scale; + pl.y += ((LABELH/2)*grade/prof.scaleX + 2.0/mainD.dpi/prof.scaleY)*D->scale; + DrawString(D, pl, 270.0, message, fp, fontSize*D->scale, borderColor); + } else { + pl.x -= (textsize.x/2)/prof.scaleX*D->scale; + pl.y += (textsize.x/2)*grade/prof.scaleX*D->scale; + DrawString(D, pl, 0.0, message, fp, fontSize*D->scale, borderColor); + } + } + if (units==UNITS_ENGLISH) { + if (prof.totalD > 240) { + sprintf(message, "%0.1f'", (round((profElem(inx).dist/12.0)*10.0)/10.0)); + } else { + sprintf(message, "%d'%0.1f\"", (int)floor((profElem(inx).dist)/12.0), + round(fmod(profElem(inx).dist,12.0)*10.0)/10.0); + } + } else { + if (PutDim(prof.totalD) > 10000) { + sprintf(message, "%0.1fm", (round(PutDim(profElem(inx).dist)/10.0)/10.0)); + } else if (PutDim(prof.totalD) > 100) { + sprintf(message, "%0.2fm", (round(PutDim(profElem(inx).dist))/100.0)); + } else { + sprintf(message, "%0.1fcm", round(PutDim(profElem(inx).dist)+0.5)); + } + } + DrawTextSize(&mainD, message, fp, fontSize, FALSE, &textsize); + pl.x = pb.x-(textsize.x/2)/prof.scaleX*D->scale; + pl.y = prof.minE-(LABELH+3.0/mainD.dpi)/prof.scaleY*D->scale; + DrawString(D, pl, 0.0, message, fp, fontSize*D->scale, borderColor); + sprintf(message, "%0.1f", round(PutDim(profElem(inx).elev)*100.0)/100.0); + if (printVert) { + pl.x = pt.x + LABELH/2.0/prof.scaleX*D->scale; + pl.y = pt.y + 2.0/mainD.dpi/prof.scaleY*D->scale+GetDim(prof.incrC) / 16; + DrawString(D, pl, 270.0, message, fp, fontSize*D->scale, borderColor); + } else { + pl.x = pt.x + 2.0/mainD.dpi/prof.scaleX*D->scale + GetDim(prof.incrC) / 16; + pl.y = pt.y; + if (inx != profElem_da.cnt-1 && profElem(inx).elev < profElem(inx+1).elev) { + pl.y -= LABELH/prof.scaleY*D->scale; + } + DrawString(D, pl, 0.0, message, fp, fontSize*D->scale, borderColor); + } + pl = pt; + } } @@ -385,206 +382,207 @@ static void DrawProfile(drawCmd_p D, wFontSize_t fontSize, BOOL_T printVert) static void ProfilePix2CoOrd(drawCmd_p, wDrawPix_t, wDrawPix_t, coOrd *); static void ProfileCoOrd2Pix(drawCmd_p, coOrd, wDrawPix_t*, wDrawPix_t*); static drawCmd_t screenProfileD = { - NULL, - &screenDrawFuncs, + NULL, + &screenDrawFuncs, DC_NOCLIP, - 1.0, - 0.0, - {0.0,0.0}, {0.0,0.0}, - ProfilePix2CoOrd, ProfileCoOrd2Pix + 1.0, + 0.0, + {0.0,0.0}, {0.0,0.0}, + ProfilePix2CoOrd, ProfileCoOrd2Pix }; static void ProfilePix2CoOrd( - drawCmd_p d, - wDrawPix_t xx, - wDrawPix_t yy, - coOrd * pos) + drawCmd_p d, + wDrawPix_t xx, + wDrawPix_t yy, + coOrd * pos) { - pos->x = (xx/d->dpi+d->orig.x)/prof.scaleX; - pos->y = (yy/d->dpi+d->orig.y)/prof.scaleY+prof.minE; + pos->x = (xx/d->dpi+d->orig.x)/prof.scaleX; + pos->y = (yy/d->dpi+d->orig.y)/prof.scaleY+prof.minE; } static void ProfileCoOrd2Pix( - drawCmd_p d, - coOrd pos, - wDrawPix_t *xx, - wDrawPix_t *yy) + drawCmd_p d, + coOrd pos, + wDrawPix_t *xx, + wDrawPix_t *yy) { - wDrawPix_t x, y; - x = ((((pos.x*prof.scaleX)/d->scale-d->orig.x)*d->dpi+0.5)); - y = (((((pos.y-prof.minE)*prof.scaleY)/d->scale-d->orig.y)*d->dpi+0.5)); - if (d->angle == 0) { - *xx = x; - *yy = y; - } else if (d->angle == -90.0) { - /* L->P */ - *xx = y; - *yy = -x; - } else { - /* P->L */ - *xx = -y; - *yy = x; - } + wDrawPix_t x, y; + x = ((((pos.x*prof.scaleX)/d->scale-d->orig.x)*d->dpi+0.5)); + y = (((((pos.y-prof.minE)*prof.scaleY)/d->scale-d->orig.y)*d->dpi+0.5)); + if (d->angle == 0) { + *xx = x; + *yy = y; + } else if (d->angle == -90.0) { + /* L->P */ + *xx = y; + *yy = -x; + } else { + /* P->L */ + *xx = -y; + *yy = x; + } } -/** - * Redraw profile window +/** + * Redraw profile window */ -static void RedrawProfileW( wDraw_p d, void * context, wWinPix_t x, wWinPix_t y ) +static void RedrawProfileW( wDraw_p d, void * context, wWinPix_t x, + wWinPix_t y ) { - wWinPix_t ww, hh; - coOrd size; - int divC; - DIST_T maxE, rngE; - profElem_t *p; - wFont_p fp; - POS_T w; - coOrd textsize; - char *pTestString; - - wDrawDelayUpdate(screenProfileD.d, TRUE); + wWinPix_t ww, hh; + coOrd size; + int divC; + DIST_T maxE, rngE; + profElem_t *p; + wFont_p fp; + POS_T w; + coOrd textsize; + char *pTestString; + + wDrawDelayUpdate(screenProfileD.d, TRUE); wDrawClear(screenProfileD.d); // get the size of the window area in pixels and convert to inches - wDrawGetSize(screenProfileD.d, &ww, &hh); - screenProfileD.size.x = (ww)/screenProfileD.dpi; - screenProfileD.size.y = (hh)/screenProfileD.dpi; + wDrawGetSize(screenProfileD.d, &ww, &hh); + screenProfileD.size.x = (ww)/screenProfileD.dpi; + screenProfileD.size.y = (hh)/screenProfileD.dpi; // calculate positions for labels??? fp = wStandardFont(F_HELV, FALSE, FALSE); screenProfileD.orig.x = -PBL(screenProfileFontSize); - screenProfileD.orig.y = -PBB(screenProfileFontSize); - - /* Calculate usable dimension of canvas in inches */ - size = screenProfileD.size; - size.x -= (PBL(screenProfileFontSize)); - size.y -= (PBB(screenProfileFontSize)); - - /* make sure there is enough space to show the rightmost coordinate value*/ - if (units == UNITS_ENGLISH) { - if (prof.totalD > 240.0) { - pTestString = "9999'"; - } else { - pTestString = "999'11\""; - } - } else { - if (PutDim(prof.totalD) > 10000.0) { - pTestString = "999m"; - } else { - if (PutDim(prof.totalD) > 100.0) { - pTestString = "99.9m"; - } else { - pTestString = "9.99m"; - } - } - } - DrawTextSize(&mainD, pTestString, fp, screenProfileFontSize, FALSE, &textsize); - size.x -= textsize.x / 2; - size.y -= textsize.y * 1.5 ; + screenProfileD.orig.y = -PBB(screenProfileFontSize); + + /* Calculate usable dimension of canvas in inches */ + size = screenProfileD.size; + size.x -= (PBL(screenProfileFontSize)); + size.y -= (PBB(screenProfileFontSize)); + + /* make sure there is enough space to show the rightmost coordinate value*/ + if (units == UNITS_ENGLISH) { + if (prof.totalD > 240.0) { + pTestString = "9999'"; + } else { + pTestString = "999'11\""; + } + } else { + if (PutDim(prof.totalD) > 10000.0) { + pTestString = "999m"; + } else { + if (PutDim(prof.totalD) > 100.0) { + pTestString = "99.9m"; + } else { + pTestString = "9.99m"; + } + } + } + DrawTextSize(&mainD, pTestString, fp, screenProfileFontSize, FALSE, &textsize); + size.x -= textsize.x / 2; + size.y -= textsize.y * 1.5 ; // now we have the size of the profile area #ifdef WINDOWS - if (printVert) { - size.x -= PBR(screenProfileFontSize)/4.0; - size.y -= PBT; - } else + if (printVert) { + size.x -= PBR(screenProfileFontSize)/4.0; + size.y -= PBT; + } else #endif - { - size.x -= PBR(screenProfileFontSize); - size.y -= PBT; - } - - if (size.x < 0.1 || size.y < 0.1) { - wDrawDelayUpdate(screenProfileD.d, FALSE); - return; - } - - /* Calculate range of data values */ - if (profElem_da.cnt<=0) { - prof.totalD = 0.0; - prof.minE = 0.0; - maxE = 1.0; - } else { - maxE = prof.minE = profElem(0).elev; - prof.totalD = profElem(profElem_da.cnt-1).dist; - for (int inx=1; inx<profElem_da.cnt; inx++) { - p = &profElem(inx); - if (p->elev<prof.minE) { - prof.minE = p->elev; - } - if (p->elev>maxE) { - maxE = p->elev; - } - } - } - - /* Calculate number of grid lines */ - prof.minC = (int)floor(PutDim(prof.minE)); - prof.maxC = (int)ceil(PutDim(maxE)); - if (prof.maxC-prof.minC <= 0) { - prof.maxC = prof.minC+1; - } - divC = (int)floor(size.y/labelH); - if (divC < 1) { - divC = 1; - } - prof.incrC = (prof.maxC-prof.minC+divC-1)/divC; - if (prof.incrC < 1) { - prof.incrC = 1; - } - prof.maxC = prof.minC + (prof.maxC-prof.minC+prof.incrC-1)/prof.incrC * - prof.incrC; - - /* Reset bounds based on intergal values */ - prof.minE = GetDim(prof.minC); - rngE = GetDim(prof.maxC) - prof.minE; - if (rngE < 1.0) { - rngE = 1.0; - } - - /* Compute vert scale */ - prof.scaleY = size.y/rngE; - sprintf(message, "%0.2f", maxE); - - DrawTextSize(&mainD, message, fp, screenProfileFontSize, FALSE, &textsize); - w = textsize.x; - w -= PBT; - w += 4.0/screenProfileD.dpi; - w -= (GetDim(prof.maxC)-maxE)*prof.scaleY; - if (w > 0) { - size.y -= w; - prof.scaleY = size.y/rngE; - } - - /* Compute horz scale */ - if (prof.totalD <= 0.1) { - prof.totalD = size.x; - } - prof.scaleX = size.x/prof.totalD; - - DrawProfile(&screenProfileD, screenProfileFontSize, + { + size.x -= PBR(screenProfileFontSize); + size.y -= PBT; + } + + if (size.x < 0.1 || size.y < 0.1) { + wDrawDelayUpdate(screenProfileD.d, FALSE); + return; + } + + /* Calculate range of data values */ + if (profElem_da.cnt<=0) { + prof.totalD = 0.0; + prof.minE = 0.0; + maxE = 1.0; + } else { + maxE = prof.minE = profElem(0).elev; + prof.totalD = profElem(profElem_da.cnt-1).dist; + for (int inx=1; inx<profElem_da.cnt; inx++) { + p = &profElem(inx); + if (p->elev<prof.minE) { + prof.minE = p->elev; + } + if (p->elev>maxE) { + maxE = p->elev; + } + } + } + + /* Calculate number of grid lines */ + prof.minC = (int)floor(PutDim(prof.minE)); + prof.maxC = (int)ceil(PutDim(maxE)); + if (prof.maxC-prof.minC <= 0) { + prof.maxC = prof.minC+1; + } + divC = (int)floor(size.y/labelH); + if (divC < 1) { + divC = 1; + } + prof.incrC = (prof.maxC-prof.minC+divC-1)/divC; + if (prof.incrC < 1) { + prof.incrC = 1; + } + prof.maxC = prof.minC + (prof.maxC-prof.minC+prof.incrC-1)/prof.incrC * + prof.incrC; + + /* Reset bounds based on intergal values */ + prof.minE = GetDim(prof.minC); + rngE = GetDim(prof.maxC) - prof.minE; + if (rngE < 1.0) { + rngE = 1.0; + } + + /* Compute vert scale */ + prof.scaleY = size.y/rngE; + sprintf(message, "%0.2f", maxE); + + DrawTextSize(&mainD, message, fp, screenProfileFontSize, FALSE, &textsize); + w = textsize.x; + w -= PBT; + w += 4.0/screenProfileD.dpi; + w -= (GetDim(prof.maxC)-maxE)*prof.scaleY; + if (w > 0) { + size.y -= w; + prof.scaleY = size.y/rngE; + } + + /* Compute horz scale */ + if (prof.totalD <= 0.1) { + prof.totalD = size.x; + } + prof.scaleX = size.x/prof.totalD; + + DrawProfile(&screenProfileD, screenProfileFontSize, #ifdef WINDOWS - printVert + printVert #else - FALSE + FALSE #endif - ); - wDrawDelayUpdate(screenProfileD.d, FALSE); + ); + wDrawDelayUpdate(screenProfileD.d, FALSE); } static drawCmd_t printProfileD = { - NULL, - &printDrawFuncs, + NULL, + &printDrawFuncs, DC_PRINT | DC_NOCLIP, - 1.0, - 0.0, - {0.0,0.0}, {1.0,1.0}, - ProfilePix2CoOrd, ProfileCoOrd2Pix + 1.0, + 0.0, + {0.0,0.0}, {1.0,1.0}, + ProfilePix2CoOrd, ProfileCoOrd2Pix }; /** @@ -600,83 +598,83 @@ static drawCmd_t printProfileD = { static void DoProfilePrint(void * junk) { - coOrd size, p[4]; - int copies; - WDOUBLE_T w, h, screenRatio, printRatio, titleH; - wFont_p fp; - coOrd screenSize; - coOrd textsize; - - if (!wPrintDocStart(_("Profile"), 1, &copies)) { - return; - } - printProfileD.d = wPrintPageStart(); - if (printProfileD.d == NULL) { - return; - } - printProfileD.dpi = wDrawGetDPI(printProfileD.d); - wPrintGetPageSize(&w, &h); - printProfileD.orig.x = -PBL(printProfileFontSize); - printProfileD.orig.y = -PBB(printProfileFontSize); - printProfileD.angle = 0.0; - screenRatio = screenProfileD.size.y/screenProfileD.size.x; - screenSize.x = prof.totalD*prof.scaleX; - screenSize.y = GetDim(prof.maxC-prof.minC)*prof.scaleY; - screenRatio = screenSize.y/screenSize.x; - printProfileD.size.x = w; - printProfileD.size.y = h; - sprintf(message, _("%s Profile: %s"), sProdName, GetLayoutTitle()); - fp = wStandardFont(F_TIMES, FALSE, FALSE); - DrawTextSize(&mainD, message, fp, 24, FALSE, &textsize); - titleH = textsize.y + 6.0/mainD.dpi; - if (screenRatio < 1.0 && w < h) { - /* Landscape -> Portrait */ - printProfileD.angle = -90.0; - printProfileD.orig.x += h; - size.x = h; - size.y = w; - } else if (screenRatio > 1.0 && w > h) { - /* Portrait -> Landscape */ - printProfileD.angle = 90.0; - printProfileD.orig.y += w; - size.x = h; - size.y = w; - } else { - size.x = w; - size.y = h; - } - size.y -= titleH+(printVert?PBT*2:PBT)+PBB(printProfileFontSize); - size.x -= 4.0/mainD.dpi+PBL(printProfileFontSize)+(printVert?PBR( - printProfileFontSize)/4.0:PBR(printProfileFontSize)); - printRatio = size.y/size.x; - if (printRatio < screenRatio) { - printProfileD.scale = screenSize.y/size.y; - size.x = screenSize.x/printProfileD.scale; - } else { - printProfileD.scale = screenSize.x/size.x; - printProfileD.orig.y -= size.y; - size.y = screenSize.y/printProfileD.scale; - printProfileD.orig.y += size.y; - } + coOrd size, p[4]; + int copies; + WDOUBLE_T w, h, screenRatio, printRatio, titleH; + wFont_p fp; + coOrd screenSize; + coOrd textsize; + + if (!wPrintDocStart(_("Profile"), 1, &copies)) { + return; + } + printProfileD.d = wPrintPageStart(); + if (printProfileD.d == NULL) { + return; + } + printProfileD.dpi = wDrawGetDPI(printProfileD.d); + wPrintGetPageSize(&w, &h); + printProfileD.orig.x = -PBL(printProfileFontSize); + printProfileD.orig.y = -PBB(printProfileFontSize); + printProfileD.angle = 0.0; + screenRatio = screenProfileD.size.y/screenProfileD.size.x; + screenSize.x = prof.totalD*prof.scaleX; + screenSize.y = GetDim(prof.maxC-prof.minC)*prof.scaleY; + screenRatio = screenSize.y/screenSize.x; + printProfileD.size.x = w; + printProfileD.size.y = h; + sprintf(message, _("%s Profile: %s"), sProdName, GetLayoutTitle()); + fp = wStandardFont(F_TIMES, FALSE, FALSE); + DrawTextSize(&mainD, message, fp, 24, FALSE, &textsize); + titleH = textsize.y + 6.0/mainD.dpi; + if (screenRatio < 1.0 && w < h) { + /* Landscape -> Portrait */ + printProfileD.angle = -90.0; + printProfileD.orig.x += h; + size.x = h; + size.y = w; + } else if (screenRatio > 1.0 && w > h) { + /* Portrait -> Landscape */ + printProfileD.angle = 90.0; + printProfileD.orig.y += w; + size.x = h; + size.y = w; + } else { + size.x = w; + size.y = h; + } + size.y -= titleH+(printVert?PBT*2:PBT)+PBB(printProfileFontSize); + size.x -= 4.0/mainD.dpi+PBL(printProfileFontSize)+(printVert?PBR( + printProfileFontSize)/4.0:PBR(printProfileFontSize)); + printRatio = size.y/size.x; + if (printRatio < screenRatio) { + printProfileD.scale = screenSize.y/size.y; + size.x = screenSize.x/printProfileD.scale; + } else { + printProfileD.scale = screenSize.x/size.x; + printProfileD.orig.y -= size.y; + size.y = screenSize.y/printProfileD.scale; + printProfileD.orig.y += size.y; + } #define PRINT_ABS2PAGEX(X) (((X)*printProfileD.scale)/prof.scaleX) #define PRINT_ABS2PAGEY(Y) (((Y)*printProfileD.scale)/prof.scaleY+prof.minE) - p[0].y = PRINT_ABS2PAGEY(size.y+(printVert?PBT*2:PBT)+0.05); - p[0].x = PRINT_ABS2PAGEX((size.x-textsize.x)/2.0); - if (p[0].x < 0) { - p[0].x = 0; - } - DrawString(&printProfileD, p[0], 0, message, fp, 24*printProfileD.scale, - borderColor); - p[0].x = p[3].x = PRINT_ABS2PAGEX((-PBL(printProfileFontSize))+2.0/mainD.dpi); - p[0].y = p[1].y = PRINT_ABS2PAGEY(-PBB(printProfileFontSize)); - p[1].x = p[2].x = PRINT_ABS2PAGEX(size.x+(printVert?PBR( - printProfileFontSize)/4.0:PBR(printProfileFontSize))); - p[2].y = p[3].y = PRINT_ABS2PAGEY(size.y+(printVert?PBT*2:PBT)); - DrawPoly( &printProfileD, 4, p, NULL, drawColorBlack, 0, DRAW_CLOSED ); - - DrawProfile(&printProfileD, printProfileFontSize, printVert); - wPrintPageEnd(printProfileD.d); - wPrintDocEnd(); + p[0].y = PRINT_ABS2PAGEY(size.y+(printVert?PBT*2:PBT)+0.05); + p[0].x = PRINT_ABS2PAGEX((size.x-textsize.x)/2.0); + if (p[0].x < 0) { + p[0].x = 0; + } + DrawString(&printProfileD, p[0], 0, message, fp, 24*printProfileD.scale, + borderColor); + p[0].x = p[3].x = PRINT_ABS2PAGEX((-PBL(printProfileFontSize))+2.0/mainD.dpi); + p[0].y = p[1].y = PRINT_ABS2PAGEY(-PBB(printProfileFontSize)); + p[1].x = p[2].x = PRINT_ABS2PAGEX(size.x+(printVert?PBR( + printProfileFontSize)/4.0:PBR(printProfileFontSize))); + p[2].y = p[3].y = PRINT_ABS2PAGEY(size.y+(printVert?PBT*2:PBT)); + DrawPoly( &printProfileD, 4, p, NULL, drawColorBlack, 0, DRAW_CLOSED ); + + DrawProfile(&printProfileD, printProfileFontSize, printVert); + wPrintPageEnd(printProfileD.d); + wPrintDocEnd(); } /************************************************************************** @@ -699,17 +697,17 @@ static void CloseProfileWindow(paramGroup_p pg, int event, void *data); static paramDrawData_t profileDrawData = { 300, 150, RedrawProfileW, SelProfileW, &screenProfileD }; static paramData_t profilePLs[] = { - { PD_DRAW, NULL, "canvas", PDO_DLGRESIZE, &profileDrawData }, + { PD_DRAW, NULL, "canvas", PDO_DLGRESIZE, &profileDrawData }, #define I_PROFILEMSG (1) - { PD_MESSAGE, NULL, NULL, PDO_DLGIGNOREX, I2VP(300) }, + { PD_MESSAGE, NULL, NULL, PDO_DLGIGNOREX, I2VP(300) }, #define I_CHANGEBUTTON 2 - { PD_BUTTON, DoProfileChange, "change", PDO_DLGCMDBUTTON, NULL, N_("Change") }, + { PD_BUTTON, DoProfileChange, "change", PDO_DLGCMDBUTTON, NULL, N_("Change") }, #define I_RESETBUTTON 3 - { PD_BUTTON, DoProfileReset, "reset", PDO_DLGCMDBUTTON, NULL, N_("Reset") }, + { PD_BUTTON, DoProfileReset, "reset", PDO_DLGCMDBUTTON, NULL, N_("Reset") }, #define I_CLEARBUTTON 4 - { PD_BUTTON, DoProfileClear, "clear", PDO_DLGCMDBUTTON, NULL, N_("Clear") }, + { PD_BUTTON, DoProfileClear, "clear", PDO_DLGCMDBUTTON, NULL, N_("Clear") }, #define I_PRINTBUTTON 5 - { PD_BUTTON, DoProfilePrint, "print", 0, NULL, N_("Print") } + { PD_BUTTON, DoProfilePrint, "print", 0, NULL, N_("Print") } }; static paramGroup_t profilePG = { "profile", 0, profilePLs, COUNT( profilePLs ) }; @@ -719,97 +717,97 @@ static paramGroup_t profilePG = { "profile", 0, profilePLs, COUNT( profilePLs ) #define PRINTBUTTON ((wButton_p)profilePLs[I_PRINTBUTTON].control) static void SelProfileW( - wIndex_t action, - coOrd pos) + wIndex_t action, + coOrd pos) { - DIST_T dist; - static DIST_T oldElev; - static int inx; - DIST_T elev; - - if (profElem_da.cnt <= 0) { - return; - } - - dist = pos.x; - elev = pos.y; - - switch (action&0xFF) { - case C_START: - profileUndo = FALSE; - break; - case C_DOWN: - for (inx=0; inx<profElem_da.cnt; inx++) { - if (dist <= profElem(inx).dist) { - if (inx!=0 && profElem(inx).dist-dist > dist-profElem(inx-1).dist) { - inx--; - } - break; - } - } - if (inx >= profElem_da.cnt) { - inx = profElem_da.cnt-1; - } - sprintf(message, _("Elev = %0.1f"), round(PutDim(elev)*10.0)/10.0); - ParamLoadMessage(&profilePG, I_PROFILEMSG, message); - oldElev = elev; - RedrawProfileW( screenProfileD.d, NULL, 0, 0 ); - break; - case C_MOVE: - if (inx < 0) { - break; - } - if (profElem_da.cnt == 1) { - sprintf(message, _("Elev = %0.1f"), round(PutDim(elev)*10.0)/10.0); - } else if (inx == 0) { - sprintf(message, _("Elev=%0.2f %0.1f%%"), - round(PutDim(elev)*100.0)/100.0, - round(fabs(((profElem(inx+1).elev-elev) / (profElem(inx+1).dist-profElem( - inx).dist)) * 1000.0))/10.0); - } else if (inx == profElem_da.cnt-1) { - sprintf(message, _("%0.1f%% Elev = %0.2f"), - round(fabs(((profElem(inx-1).elev-elev) / (profElem(inx).dist-profElem( - inx-1).dist)) * 1000.0))/10.0, - round(PutDim(elev)*100.0)/100.0); - } else { - sprintf(message, _("%0.1f%% Elev = %0.2f %0.1f%%"), - round(fabs(((profElem(inx-1).elev-elev) / (profElem(inx).dist-profElem( - inx-1).dist)) * 1000.0))/10.0, - round(PutDim(elev)*100.0)/100.0, - round(fabs((profElem(inx+1).elev-elev) / (profElem(inx+1).dist-profElem( - inx).dist)) * 1000.0)/10.0); - } - ParamLoadMessage(&profilePG, I_PROFILEMSG, message); - oldElev = elev; - profElem(inx).elev = oldElev; - RedrawProfileW( screenProfileD.d, NULL, 0, 0 ); + DIST_T dist; + static DIST_T oldElev; + static int inx; + DIST_T elev; + + if (profElem_da.cnt <= 0) { + return; + } + + dist = pos.x; + elev = pos.y; + + switch (action&0xFF) { + case C_START: + profileUndo = FALSE; + break; + case C_DOWN: + for (inx=0; inx<profElem_da.cnt; inx++) { + if (dist <= profElem(inx).dist) { + if (inx!=0 && profElem(inx).dist-dist > dist-profElem(inx-1).dist) { + inx--; + } + break; + } + } + if (inx >= profElem_da.cnt) { + inx = profElem_da.cnt-1; + } + sprintf(message, _("Elev = %0.1f"), round(PutDim(elev)*10.0)/10.0); + ParamLoadMessage(&profilePG, I_PROFILEMSG, message); + oldElev = elev; + RedrawProfileW( screenProfileD.d, NULL, 0, 0 ); + break; + case C_MOVE: + if (inx < 0) { + break; + } + if (profElem_da.cnt == 1) { + sprintf(message, _("Elev = %0.1f"), round(PutDim(elev)*10.0)/10.0); + } else if (inx == 0) { + sprintf(message, _("Elev=%0.2f %0.1f%%"), + round(PutDim(elev)*100.0)/100.0, + round(fabs(((profElem(inx+1).elev-elev) / (profElem(inx+1).dist-profElem( + inx).dist)) * 1000.0))/10.0); + } else if (inx == profElem_da.cnt-1) { + sprintf(message, _("%0.1f%% Elev = %0.2f"), + round(fabs(((profElem(inx-1).elev-elev) / (profElem(inx).dist-profElem( + inx-1).dist)) * 1000.0))/10.0, + round(PutDim(elev)*100.0)/100.0); + } else { + sprintf(message, _("%0.1f%% Elev = %0.2f %0.1f%%"), + round(fabs(((profElem(inx-1).elev-elev) / (profElem(inx).dist-profElem( + inx-1).dist)) * 1000.0))/10.0, + round(PutDim(elev)*100.0)/100.0, + round(fabs((profElem(inx+1).elev-elev) / (profElem(inx+1).dist-profElem( + inx).dist)) * 1000.0)/10.0); + } + ParamLoadMessage(&profilePG, I_PROFILEMSG, message); + oldElev = elev; + profElem(inx).elev = oldElev; + RedrawProfileW( screenProfileD.d, NULL, 0, 0 ); wPause(500l); break; - case C_UP: - if (profileUndo == FALSE) { - UndoStart(_("Profile Command"), "Profile - set elevation"); - profileUndo = TRUE; - } - if (profElem(inx).trk) { - UpdateTrkEndElev(profElem(inx).trk, profElem(inx).ep, ELEV_DEF|ELEV_VISIBLE, - oldElev, NULL); - } - profElem(inx).elev = oldElev; - RedrawProfileW( screenProfileD.d, NULL, 0, 0 ); - ParamLoadMessage(&profilePG, I_PROFILEMSG, _("Drag to change Elevation")); - inx = -1; - break; - default: - break; - } + case C_UP: + if (profileUndo == FALSE) { + UndoStart(_("Profile Command"), "Profile - set elevation"); + profileUndo = TRUE; + } + if (profElem(inx).trk) { + UpdateTrkEndElev(profElem(inx).trk, profElem(inx).ep, ELEV_DEF|ELEV_VISIBLE, + oldElev, NULL); + } + profElem(inx).elev = oldElev; + RedrawProfileW( screenProfileD.d, NULL, 0, 0 ); + ParamLoadMessage(&profilePG, I_PROFILEMSG, _("Drag to change Elevation")); + inx = -1; + break; + default: + break; + } } static void HilightProfileElevations(BOOL_T show) { - /*if ( profElem_da.cnt <= 0 ) {*/ - HilightElevations(show); - /*} else { - }*/ + /*if ( profElem_da.cnt <= 0 ) {*/ + HilightElevations(show); + /*} else { + }*/ } /** @@ -822,15 +820,15 @@ static void HilightProfileElevations(BOOL_T show) void CloseProfileWindow(paramGroup_p pg, int event, void *data) { - Reset(); - return; + Reset(); + return; } -/** +/** * Undo the changes made in the profile window to the layout. */ - + static void ResetChanges() { @@ -839,7 +837,7 @@ ResetChanges() profElem(i) = copyOfprofElem[i]; if (profElem(i).trk) { UpdateTrkEndElev(profElem(i).trk, profElem(i).ep, ELEV_DEF | ELEV_VISIBLE, - copyOfprofElem[i].elev, NULL); + copyOfprofElem[i].elev, NULL); } } } @@ -861,7 +859,7 @@ DoProfileReset(void *junk) } ResetChanges(); RedrawProfileW( screenProfileD.d, NULL, 0, 0 ); - TempRedraw(); + TempRedraw(); } /** @@ -874,34 +872,34 @@ static void DoProfileChange(void *junk) { DestroyCopyOfProfileElements(); - TempRedraw(); + TempRedraw(); } static void DoProfileDone(void * junk) { - Reset(); + Reset(); } static void DoProfileClear(void * junk) { ResetChanges(); - profElem_da.cnt = 0; - station_da.cnt = 0; - ClrAllTrkBitsRedraw(TB_PROFILEPATH, TRUE); - pathStartTrk = pathEndTrk = NULL; - RedrawProfileW( screenProfileD.d, NULL, 0, 0 ); + DYNARR_RESET( profElem_t, profElem_da ); + DYNARR_RESET( station_t, station_da ); + ClrAllTrkBitsRedraw(TB_PROFILEPATH, TRUE); + pathStartTrk = pathEndTrk = NULL; + RedrawProfileW( screenProfileD.d, NULL, 0, 0 ); } static void DoProfileChangeMode(void * junk) { - if (profElem_da.cnt<=0) { - InfoMessage(_("Select a Defined Elevation to start Profile")); - } else { - InfoMessage(_("Select a Defined Elevation to extend Profile")); - } + if (profElem_da.cnt<=0) { + InfoMessage(_("Select a Defined Elevation to start Profile")); + } else { + InfoMessage(_("Select a Defined Elevation to extend Profile")); + } } /************************************************************************** @@ -912,15 +910,15 @@ static void DoProfileChangeMode(void * junk) static BOOL_T PathListEmpty(void) { - return pathStartTrk == NULL; + return pathStartTrk == NULL; } static BOOL_T PathListSingle(void) { - return pathStartTrk != NULL && - (pathEndTrk == NULL || - (GetTrkEndTrk(pathEndTrk,pathEndEp) == pathStartTrk && - GetTrkEndTrk(pathStartTrk,pathStartEp) == pathEndTrk)); + return pathStartTrk != NULL && + (pathEndTrk == NULL || + (GetTrkEndTrk(pathEndTrk,pathEndEp) == pathStartTrk && + GetTrkEndTrk(pathStartTrk,pathStartEp) == pathEndTrk)); } @@ -928,106 +926,106 @@ static int profileShortestPathMatch; static DIST_T profileShortestPathDist; static int ProfileShortestPathFunc( - SPTF_CMD cmd, - track_p trk, - EPINX_T ep, - EPINX_T ep0, - DIST_T dist, - void * data) + SPTF_CMD cmd, + track_p trk, + EPINX_T ep, + EPINX_T ep0, + DIST_T dist, + void * data) { - int rc0=0; - int pathMatch; - - switch (cmd) { - track_p trkN; - case SPTC_TERMINATE: - rc0 = 1; - break; - - case SPTC_MATCH: - if (EndPtIsIgnoredElev(trk,ep)) { - break; - } - if (PathListSingle()) { - if (trk == pathStartTrk && ep == pathStartEp) { - pathMatch = 2; - } else if (trk == pathEndTrk && ep == pathEndEp) { - pathMatch = 3; - } else { - break; - } - } else if ((trkN = GetTrkEndTrk(trk,ep)) == NULL) { - break; - } else { - EPINX_T epN; - epN = GetEndPtConnectedToMe(trkN, trk); - if (trkN == pathStartTrk && epN == pathStartEp) { - pathMatch = 1; - } else if (trkN == pathEndTrk && epN == pathEndEp) { - pathMatch = 2; - } else if (trkN == pathStartTrk && trkN == pathEndTrk) { - pathMatch = 2; - } else if (trkN == pathStartTrk) { - pathMatch = 1; - } else if (trkN == pathEndTrk) { - pathMatch = 2; - } else { - break; - } - } - if (profileShortestPathMatch < 0 || profileShortestPathDist > dist) { - LOG(log_shortPath, 4, (" Match=%d", pathMatch)) - profileShortestPathMatch = pathMatch; - profileShortestPathDist = dist; - } - rc0 = 1; - break; - - case SPTC_MATCHANY: - rc0 = -1; - break; - - case SPTC_IGNNXTTRK: - if (EndPtIsIgnoredElev(trk,ep)) { - rc0 = 1; - } else if ((GetTrkBits(trk)&TB_PROFILEPATH)!=0) { - rc0 = 1; - } else if ((!EndPtIsDefinedElev(trk,ep)) && GetTrkEndTrk(trk,ep)==NULL) { - rc0 = 1; - } else { - rc0 = 0; - } - break; - - case SPTC_ADD_TRK: - if (log_shortPath<=0|| - logTable(log_shortPath).level<4) LOG(log_profile, 4, (" ADD_TRK T%d:%d", - GetTrkIndex(trk), ep)) - SetTrkBits(trk, TB_PROFILEPATH); - DrawTrack(trk, &mainD, profilePathColor); - rc0 = 0; - break; - - case SPTC_VALID: - rc0 = 1; - break; - - default: - break; - } - return rc0; + int rc0=0; + int pathMatch; + + switch (cmd) { + track_p trkN; + case SPTC_TERMINATE: + rc0 = 1; + break; + + case SPTC_MATCH: + if (EndPtIsIgnoredElev(trk,ep)) { + break; + } + if (PathListSingle()) { + if (trk == pathStartTrk && ep == pathStartEp) { + pathMatch = 2; + } else if (trk == pathEndTrk && ep == pathEndEp) { + pathMatch = 3; + } else { + break; + } + } else if ((trkN = GetTrkEndTrk(trk,ep)) == NULL) { + break; + } else { + EPINX_T epN; + epN = GetEndPtConnectedToMe(trkN, trk); + if (trkN == pathStartTrk && epN == pathStartEp) { + pathMatch = 1; + } else if (trkN == pathEndTrk && epN == pathEndEp) { + pathMatch = 2; + } else if (trkN == pathStartTrk && trkN == pathEndTrk) { + pathMatch = 2; + } else if (trkN == pathStartTrk) { + pathMatch = 1; + } else if (trkN == pathEndTrk) { + pathMatch = 2; + } else { + break; + } + } + if (profileShortestPathMatch < 0 || profileShortestPathDist > dist) { + LOG(log_shortPath, 4, (" Match=%d", pathMatch)) + profileShortestPathMatch = pathMatch; + profileShortestPathDist = dist; + } + rc0 = 1; + break; + + case SPTC_MATCHANY: + rc0 = -1; + break; + + case SPTC_IGNNXTTRK: + if (EndPtIsIgnoredElev(trk,ep)) { + rc0 = 1; + } else if ((GetTrkBits(trk)&TB_PROFILEPATH)!=0) { + rc0 = 1; + } else if ((!EndPtIsDefinedElev(trk,ep)) && GetTrkEndTrk(trk,ep)==NULL) { + rc0 = 1; + } else { + rc0 = 0; + } + break; + + case SPTC_ADD_TRK: + if (log_shortPath<=0|| + logTable(log_shortPath).level<4) LOG(log_profile, 4, (" ADD_TRK T%d:%d", + GetTrkIndex(trk), ep)) + SetTrkBits(trk, TB_PROFILEPATH); + DrawTrack(trk, &mainD, profilePathColor); + rc0 = 0; + break; + + case SPTC_VALID: + rc0 = 1; + break; + + default: + break; + } + return rc0; } static int FindProfileShortestPath( - track_p trkN, - EPINX_T epN) + track_p trkN, + EPINX_T epN) { - LOG(log_profile, 4, ("Searching from T%d:%d to T%d:%d or T%d:%d\n", - GetTrkIndex(trkN), epN, - pathStartTrk?GetTrkIndex(pathStartTrk):-1, pathStartTrk?pathStartEp:-1, - pathEndTrk?GetTrkIndex(pathEndTrk):-1, pathEndTrk?pathEndEp:-1)) - profileShortestPathMatch = -1; - return FindShortestPath(trkN, epN, TRUE, ProfileShortestPathFunc, NULL); + LOG(log_profile, 4, ("Searching from T%d:%d to T%d:%d or T%d:%d\n", + GetTrkIndex(trkN), epN, + pathStartTrk?GetTrkIndex(pathStartTrk):-1, pathStartTrk?pathStartEp:-1, + pathEndTrk?GetTrkIndex(pathEndTrk):-1, pathEndTrk?pathEndEp:-1)) + profileShortestPathMatch = -1; + return FindShortestPath(trkN, epN, TRUE, ProfileShortestPathFunc, NULL); } @@ -1044,492 +1042,493 @@ static int FindProfileShortestPath( #define ONPATH_BRANCH (1<<3) static int OnPath(track_p trk, EPINX_T ep) { - if (GetTrkBits(trk)&TB_PROFILEPATH) { - track_p trk0; - trk0 = GetTrkEndTrk(profilePopupTrk, profilePopupEp); - if (trk0 && (GetTrkBits(trk0)&TB_PROFILEPATH)) { - return ONPATH_MID; - } - if (trk == pathStartTrk && ep == pathStartEp) { - return ONPATH_END; - } - return ONPATH_BRANCH; - } - return ONPATH_NOT; + if (GetTrkBits(trk)&TB_PROFILEPATH) { + track_p trk0; + trk0 = GetTrkEndTrk(profilePopupTrk, profilePopupEp); + if (trk0 && (GetTrkBits(trk0)&TB_PROFILEPATH)) { + return ONPATH_MID; + } + if (trk == pathStartTrk && ep == pathStartEp) { + return ONPATH_END; + } + return ONPATH_BRANCH; + } + return ONPATH_NOT; } static BOOL_T PathListCheck(void) { - track_p trk; - if (PathListEmpty() || PathListSingle()) { - return TRUE; - } - if (!(GetTrkBits(pathStartTrk)&TB_PROFILEPATH)) { - ErrorMessage(MSG_PST_NOT_ON_PATH); - return FALSE; - } - if (!(GetTrkBits(pathEndTrk)&TB_PROFILEPATH)) { - ErrorMessage(MSG_PET_NOT_ON_PATH); - return FALSE; - } - trk = GetTrkEndTrk(pathStartTrk,pathStartEp); - if (trk && (GetTrkBits(trk)&TB_PROFILEPATH)) { - ErrorMessage(MSG_INV_PST_ON_PATH); - return FALSE; - } - trk = GetTrkEndTrk(pathEndTrk,pathEndEp); - if (trk && (GetTrkBits(trk)&TB_PROFILEPATH)) { - ErrorMessage(MSG_INV_PET_ON_PATH); - return FALSE; - } - return TRUE; + track_p trk; + if (PathListEmpty() || PathListSingle()) { + return TRUE; + } + if (!(GetTrkBits(pathStartTrk)&TB_PROFILEPATH)) { + ErrorMessage(MSG_PST_NOT_ON_PATH); + return FALSE; + } + if (!(GetTrkBits(pathEndTrk)&TB_PROFILEPATH)) { + ErrorMessage(MSG_PET_NOT_ON_PATH); + return FALSE; + } + trk = GetTrkEndTrk(pathStartTrk,pathStartEp); + if (trk && (GetTrkBits(trk)&TB_PROFILEPATH)) { + ErrorMessage(MSG_INV_PST_ON_PATH); + return FALSE; + } + trk = GetTrkEndTrk(pathEndTrk,pathEndEp); + if (trk && (GetTrkBits(trk)&TB_PROFILEPATH)) { + ErrorMessage(MSG_INV_PET_ON_PATH); + return FALSE; + } + return TRUE; } static void RemoveTracksFromPath( - track_p *Rtrk, - EPINX_T *Rep, - track_p trkEnd, - EPINX_T epEnd) + track_p *Rtrk, + EPINX_T *Rep, + track_p trkEnd, + EPINX_T epEnd) { - track_p trk = *Rtrk, trkN; - EPINX_T ep = *Rep; - - PASSERT("removeTracksFromPath", trk, NOP); - PASSERT("removeTracksFromPath", !PathListSingle(), NOP); - while (1) { - EPINX_T ep2; - DrawTrack(trk, &mainD, drawColorWhite); - ClrTrkBits(trk, TB_PROFILEPATH); - DrawTrack(trk, &mainD, drawColorBlack); - - if (trk == trkEnd) { - pathStartTrk = trkEnd; - pathStartEp = epEnd; - pathEndTrk = GetTrkEndTrk(pathStartTrk,pathStartEp); - if (pathEndTrk) { - pathEndEp = GetEndPtConnectedToMe(pathEndTrk,pathStartTrk); - } - return; - } - - ep2 = GetNextTrkOnPath(trk, ep); - PASSERT("removeTracksFromPath", ep2 >= 0,NOP); - trkN = GetTrkEndTrk(trk,ep2); - PASSERT("removeTracksFromPath", trkN != NULL, NOP); - ep = GetEndPtConnectedToMe(trkN,trk); - trk = trkN; - if (EndPtIsDefinedElev(trk,ep)) { - *Rtrk = trk; - *Rep = ep; - return; - } - } + track_p trk = *Rtrk, trkN; + EPINX_T ep = *Rep; + + PASSERT("removeTracksFromPath", trk, NOP); + PASSERT("removeTracksFromPath", !PathListSingle(), NOP); + while (1) { + EPINX_T ep2; + DrawTrack(trk, &mainD, drawColorWhite); + ClrTrkBits(trk, TB_PROFILEPATH); + DrawTrack(trk, &mainD, drawColorBlack); + + if (trk == trkEnd) { + pathStartTrk = trkEnd; + pathStartEp = epEnd; + pathEndTrk = GetTrkEndTrk(pathStartTrk,pathStartEp); + if (pathEndTrk) { + pathEndEp = GetEndPtConnectedToMe(pathEndTrk,pathStartTrk); + } + return; + } + + ep2 = GetNextTrkOnPath(trk, ep); + PASSERT("removeTracksFromPath", ep2 >= 0,NOP); + trkN = GetTrkEndTrk(trk,ep2); + PASSERT("removeTracksFromPath", trkN != NULL, NOP); + ep = GetEndPtConnectedToMe(trkN,trk); + trk = trkN; + if (EndPtIsDefinedElev(trk,ep)) { + *Rtrk = trk; + *Rep = ep; + return; + } + } } static void ChkElev(track_p trk, EPINX_T ep, EPINX_T ep2, DIST_T dist, BOOL_T * defined) { - profElem_p p; - station_p s; - EPINX_T epDefElev = -1; - int mode; - BOOL_T undefined; - - mode = GetTrkEndElevMode(trk, ep); - if (mode == ELEV_DEF) { - epDefElev = ep; - } else if (mode == ELEV_STATION) { - DYNARR_APPEND(station_t, station_da, 10); - s = &station(station_da.cnt-1); - s->dist = dist; - s->name = GetTrkEndElevStation(trk,ep); - } - undefined = FALSE; - if (epDefElev<0) { - if ((trk == pathStartTrk && ep == pathStartEp) || - (trk == pathEndTrk && ep == pathEndEp)) { - epDefElev = ep; - } - } - if (epDefElev<0) { - if (ep == ep2 || - GetTrkEndElevMode(trk,ep2) != ELEV_DEF) - for (EPINX_T ep1=0; ep1<GetTrkEndPtCnt(trk); ep1++) { - if (ep1==ep || ep1==ep2) { - continue; - } - if (EndPtIsDefinedElev(trk,ep1)) { - epDefElev = ep1; - dist -= GetTrkLength(trk, ep, ep1); - break; - } - if (GetTrkEndTrk(trk,ep1)) { - if (!EndPtIsIgnoredElev(trk,ep1)) { - undefined = TRUE; - } - } - } - } - - if (epDefElev>=0) { - DYNARR_APPEND(profElem_t, profElem_da, 10); - p = &profElem(profElem_da.cnt-1); - p->trk = trk; - p->ep = epDefElev; - p->dist = dist; - if (GetTrkEndElevMode(trk,epDefElev) == ELEV_DEF) { - p->elev = GetTrkEndElevHeight(trk,epDefElev); - } else { - ComputeElev(trk, epDefElev, TRUE, &p->elev, NULL, TRUE); - } - p->defined = *defined; - *defined = TRUE; - } else if (undefined) { - *defined = FALSE; - } + profElem_p p; + station_p s; + EPINX_T epDefElev = -1; + int mode; + BOOL_T undefined; + + mode = GetTrkEndElevMode(trk, ep); + if (mode == ELEV_DEF) { + epDefElev = ep; + } else if (mode == ELEV_STATION) { + DYNARR_APPEND(station_t, station_da, 10); + s = &station(station_da.cnt-1); + s->dist = dist; + s->name = GetTrkEndElevStation(trk,ep); + } + undefined = FALSE; + if (epDefElev<0) { + if ((trk == pathStartTrk && ep == pathStartEp) || + (trk == pathEndTrk && ep == pathEndEp)) { + epDefElev = ep; + } + } + if (epDefElev<0) { + if (ep == ep2 || + GetTrkEndElevMode(trk,ep2) != ELEV_DEF) + for (EPINX_T ep1=0; ep1<GetTrkEndPtCnt(trk); ep1++) { + if (ep1==ep || ep1==ep2) { + continue; + } + if (EndPtIsDefinedElev(trk,ep1)) { + epDefElev = ep1; + dist -= GetTrkLength(trk, ep, ep1); + break; + } + if (GetTrkEndTrk(trk,ep1)) { + if (!EndPtIsIgnoredElev(trk,ep1)) { + undefined = TRUE; + } + } + } + } + + if (epDefElev>=0) { + DYNARR_APPEND(profElem_t, profElem_da, 10); + p = &profElem(profElem_da.cnt-1); + p->trk = trk; + p->ep = epDefElev; + p->dist = dist; + if (GetTrkEndElevMode(trk,epDefElev) == ELEV_DEF) { + p->elev = GetTrkEndElevHeight(trk,epDefElev); + } else { + ComputeElev(trk, epDefElev, TRUE, &p->elev, NULL, TRUE); + } + p->defined = *defined; + *defined = TRUE; + } else if (undefined) { + *defined = FALSE; + } } static void ComputeProfElem(void) { - track_p trk = pathStartTrk, trkN; - EPINX_T ep = pathStartEp, ep2; - BOOL_T go; - DIST_T dist; - BOOL_T defined; - - profElem_da.cnt = 0; - station_da.cnt = 0; - dist = 0; - defined = TRUE; - if (PathListEmpty()) { - return; - } - ChkElev(trk, ep, ep, dist, &defined); - if (PathListSingle()) { - return; - } - go = TRUE; - while (go) { - if (trk == pathEndTrk) { - go = FALSE; - ep2 = pathEndEp; - } else { - ep2 = GetNextTrkOnPath(trk, ep); - //PASSERT( "computeProfElem", ep2 >= 0, NOP ); - } - dist += GetTrkLength(trk, ep, ep2); - ChkElev(trk, ep2, ep, dist, &defined); - if (!go) { - break; - } - trkN = GetTrkEndTrk(trk,ep2); - ep = GetEndPtConnectedToMe(trkN,trk); - trk = trkN; - } + track_p trk = pathStartTrk, trkN; + EPINX_T ep = pathStartEp, ep2; + BOOL_T go; + DIST_T dist; + BOOL_T defined; + + DYNARR_RESET( profElem_t, profElem_da ); + DYNARR_RESET( station_t, station_da ); + dist = 0; + defined = TRUE; + if (PathListEmpty()) { + return; + } + ChkElev(trk, ep, ep, dist, &defined); + if (PathListSingle()) { + return; + } + go = TRUE; + while (go) { + if (trk == pathEndTrk) { + go = FALSE; + ep2 = pathEndEp; + } else { + ep2 = GetNextTrkOnPath(trk, ep); + //PASSERT( "computeProfElem", ep2 >= 0, NOP ); + } + dist += GetTrkLength(trk, ep, ep2); + ChkElev(trk, ep2, ep, dist, &defined); + if (!go) { + break; + } + trkN = GetTrkEndTrk(trk,ep2); + ep = GetEndPtConnectedToMe(trkN,trk); + trk = trkN; + } } static void DumpProfElems(void) { - track_p trk, trkN; - EPINX_T ep; - BOOL_T go; - - trk = pathStartTrk; - ep = pathStartEp; - - if (pathStartTrk==NULL) { - lprintf("s--:- e--:-"); - } else if (pathEndTrk == NULL) { - lprintf("sT%d:%d e--:-", GetTrkIndex(pathStartTrk), pathStartEp); - } else { - lprintf("sT%d:%d eT%d:%d", GetTrkIndex(pathStartTrk), pathStartEp, - GetTrkIndex(pathEndTrk), pathEndEp); - } - lprintf(" { "); - go = TRUE; - if (!PathListSingle()) - while (trk) { - EPINX_T ep2; - if (trk==pathEndTrk) { - ep2 = pathEndEp; - go = FALSE; - } else { - ep2 = GetNextTrkOnPath(trk, ep); - PASSERT("computeProfElem", ep2 >= 0, NOP); - } - lprintf("T%d:%d:%d ", GetTrkIndex(trk), ep, ep2); - if (!go) { - break; - } - trkN = GetTrkEndTrk(trk,ep2); - ep = GetEndPtConnectedToMe(trkN,trk); - trk = trkN; - } - lprintf("}"); + track_p trk, trkN; + EPINX_T ep; + BOOL_T go; + + trk = pathStartTrk; + ep = pathStartEp; + + if (pathStartTrk==NULL) { + lprintf("s--:- e--:-"); + } else if (pathEndTrk == NULL) { + lprintf("sT%d:%d e--:-", GetTrkIndex(pathStartTrk), pathStartEp); + } else { + lprintf("sT%d:%d eT%d:%d", GetTrkIndex(pathStartTrk), pathStartEp, + GetTrkIndex(pathEndTrk), pathEndEp); + } + lprintf(" { "); + go = TRUE; + if (!PathListSingle()) + while (trk) { + EPINX_T ep2; + if (trk==pathEndTrk) { + ep2 = pathEndEp; + go = FALSE; + } else { + ep2 = GetNextTrkOnPath(trk, ep); + PASSERT("computeProfElem", ep2 >= 0, NOP); + } + lprintf("T%d:%d:%d ", GetTrkIndex(trk), ep, ep2); + if (!go) { + break; + } + trkN = GetTrkEndTrk(trk,ep2); + ep = GetEndPtConnectedToMe(trkN,trk); + trk = trkN; + } + lprintf("}"); } static void ProfileSelect(track_p trkN, EPINX_T epN) { - track_p trkP; - EPINX_T epP=-1; - int rc; - - if (log_profile>=1) { - DumpProfElems(); - lprintf(" @ T%d:%d ", GetTrkIndex(trkN), epN); - if (log_profile>=2) { - lprintf("\n"); - } - } - - trkP = GetTrkEndTrk(trkN, epN); - if (trkP) { - epP = GetEndPtConnectedToMe(trkP, trkN); - } - - if (!PathListCheck()) { - return; - } - - if (PathListEmpty()) { - pathStartTrk = trkN; - pathStartEp = epN; - pathEndTrk = trkP; - pathEndEp = epP; - LOG(log_profile, 2, ("Adding first element\n")) - - } else if (PathListSingle() && - ((trkN == pathStartTrk && epN == pathStartEp) || - (trkP && trkP == pathStartTrk && epP == pathStartEp))) { - pathStartTrk = pathEndTrk = NULL; - LOG(log_profile, 2, ("Clearing list\n")) - - } else if ((trkN == pathStartTrk && epN == pathStartEp) || - (trkP && trkP == pathStartTrk && epP == pathStartEp)) { - RemoveTracksFromPath(&pathStartTrk, &pathStartEp, pathEndTrk, pathEndEp); - LOG(log_profile, 2, ("Removing first element\n")) - - } else if ((trkN == pathEndTrk && epN == pathEndEp) || - (trkP && trkP == pathEndTrk && epP == pathEndEp)) { - RemoveTracksFromPath(&pathEndTrk, &pathEndEp, pathStartTrk, pathStartEp); - LOG(log_profile, 2, ("Removing last element\n")) - - } else if ((GetTrkBits(trkN)&TB_PROFILEPATH) || (trkP && - (GetTrkBits(trkP)&TB_PROFILEPATH))) { - ErrorMessage(MSG_EP_ON_PATH); - return; - - } else if ((rc = FindProfileShortestPath(trkN, epN)) > 0) { - if (!(GetTrkBits(trkN)&TB_PROFILEPATH)) { - PASSERT("profileSelect", trkP != NULL, NOP); - trkN = trkP; - epN = epP; - LOG(log_profile, 2, ("Invert selected EP\n")) - } - - switch (profileShortestPathMatch) { - case 1: - /* extend Start */ - pathStartTrk = trkN; - pathStartEp = epN; - LOG(log_profile, 2, ("Prepending Path\n")) - break; - case 2: - /* extend End */ - pathEndTrk = trkN; - pathEndEp = epN; - LOG(log_profile, 2, ("Appending Path\n")) - break; - case 3: - /* need to flip */ - pathStartTrk = pathEndTrk; - pathStartEp = pathEndEp; - pathEndTrk = trkN; - pathEndEp = epN; - LOG(log_profile, 2, ("Flip/Appending Path\n")) - break; - default: - AbortProg("findPaths:1"); - } - - } else { - ErrorMessage(MSG_NO_PATH_TO_EP); - return; - } - - DestroyCopyOfProfileElements(); - ComputeProfElem(); - CreateCopyProfileElements(); - - RedrawProfileW( screenProfileD.d, NULL, 0, 0 ); - DoProfileChangeMode(NULL); - if (log_profile>=1) { - lprintf(" = "); - DumpProfElems(); - lprintf("\n"); - } - PathListCheck(); + track_p trkP; + EPINX_T epP=-1; + int rc; + + if (log_profile>=1) { + DumpProfElems(); + lprintf(" @ T%d:%d ", GetTrkIndex(trkN), epN); + if (log_profile>=2) { + lprintf("\n"); + } + } + + trkP = GetTrkEndTrk(trkN, epN); + if (trkP) { + epP = GetEndPtConnectedToMe(trkP, trkN); + } + + if (!PathListCheck()) { + return; + } + + if (PathListEmpty()) { + pathStartTrk = trkN; + pathStartEp = epN; + pathEndTrk = trkP; + pathEndEp = epP; + LOG(log_profile, 2, ("Adding first element\n")) + + } else if (PathListSingle() && + ((trkN == pathStartTrk && epN == pathStartEp) || + (trkP && trkP == pathStartTrk && epP == pathStartEp))) { + pathStartTrk = pathEndTrk = NULL; + LOG(log_profile, 2, ("Clearing list\n")) + + } else if ((trkN == pathStartTrk && epN == pathStartEp) || + (trkP && trkP == pathStartTrk && epP == pathStartEp)) { + RemoveTracksFromPath(&pathStartTrk, &pathStartEp, pathEndTrk, pathEndEp); + LOG(log_profile, 2, ("Removing first element\n")) + + } else if ((trkN == pathEndTrk && epN == pathEndEp) || + (trkP && trkP == pathEndTrk && epP == pathEndEp)) { + RemoveTracksFromPath(&pathEndTrk, &pathEndEp, pathStartTrk, pathStartEp); + LOG(log_profile, 2, ("Removing last element\n")) + + } else if ((GetTrkBits(trkN)&TB_PROFILEPATH) || (trkP && + (GetTrkBits(trkP)&TB_PROFILEPATH))) { + ErrorMessage(MSG_EP_ON_PATH); + return; + + } else if ((rc = FindProfileShortestPath(trkN, epN)) > 0) { + if (!(GetTrkBits(trkN)&TB_PROFILEPATH)) { + PASSERT("profileSelect", trkP != NULL, NOP); + trkN = trkP; + epN = epP; + LOG(log_profile, 2, ("Invert selected EP\n")) + } + + switch (profileShortestPathMatch) { + case 1: + /* extend Start */ + pathStartTrk = trkN; + pathStartEp = epN; + LOG(log_profile, 2, ("Prepending Path\n")) + break; + case 2: + /* extend End */ + pathEndTrk = trkN; + pathEndEp = epN; + LOG(log_profile, 2, ("Appending Path\n")) + break; + case 3: + /* need to flip */ + pathStartTrk = pathEndTrk; + pathStartEp = pathEndEp; + pathEndTrk = trkN; + pathEndEp = epN; + LOG(log_profile, 2, ("Flip/Appending Path\n")) + break; + default: + CHECK(FALSE); + } + + } else { + ErrorMessage(MSG_NO_PATH_TO_EP); + return; + } + + DestroyCopyOfProfileElements(); + ComputeProfElem(); + CreateCopyProfileElements(); + + RedrawProfileW( screenProfileD.d, NULL, 0, 0 ); + DoProfileChangeMode(NULL); + if (log_profile>=1) { + lprintf(" = "); + DumpProfElems(); + lprintf("\n"); + } + PathListCheck(); } static void ProfileSubCommand(void* pcmd) { - long cmd = VP2L(pcmd); - int mode; - coOrd pos = oldMarker; - DIST_T elev; - DIST_T radius; - - if ((profilePopupTrk = OnTrack(&pos, TRUE, TRUE)) == NULL || - (profilePopupEp = PickEndPoint(pos, profilePopupTrk)) < 0) { - return; - } - if (profileUndo==0) { - profileUndo = TRUE; - UndoStart(_("Profile Command"), "Profile"); - } - radius = 0.05*mainD.scale; - if (radius < trackGauge/2.0) { - radius = trackGauge/2.0; - } - pos = GetTrkEndPos(profilePopupTrk, profilePopupEp); - mode = GetTrkEndElevMode(profilePopupTrk, profilePopupEp); - - elev = 0.0; - switch (cmd) { - case 0: - /* define */ - ComputeElev(profilePopupTrk, profilePopupEp, TRUE, &elev, NULL, TRUE); - mode = ELEV_DEF|ELEV_VISIBLE; - break; - case 1: - /* ignore */ - mode = ELEV_IGNORE|ELEV_VISIBLE; - break; - case 2: - default: - /* none */ - mode = ELEV_NONE; - break; - } - UpdateTrkEndElev(profilePopupTrk, profilePopupEp, mode, elev, NULL); - ComputeProfElem(); - RedrawProfileW( screenProfileD.d, NULL, 0, 0 ); - TempRedraw(); // ProfileSubCommand + long cmd = VP2L(pcmd); + int mode; + coOrd pos = oldMarker; + DIST_T elev; + DIST_T radius; + + if ((profilePopupTrk = OnTrack(&pos, TRUE, TRUE)) == NULL || + (profilePopupEp = PickEndPoint(pos, profilePopupTrk)) < 0) { + return; + } + if (profileUndo==0) { + profileUndo = TRUE; + UndoStart(_("Profile Command"), "Profile"); + } + radius = 0.05*mainD.scale; + if (radius < trackGauge/2.0) { + radius = trackGauge/2.0; + } + pos = GetTrkEndPos(profilePopupTrk, profilePopupEp); + mode = GetTrkEndElevMode(profilePopupTrk, profilePopupEp); + + elev = 0.0; + switch (cmd) { + case 0: + /* define */ + ComputeElev(profilePopupTrk, profilePopupEp, TRUE, &elev, NULL, TRUE); + mode = ELEV_DEF|ELEV_VISIBLE; + break; + case 1: + /* ignore */ + mode = ELEV_IGNORE|ELEV_VISIBLE; + break; + case 2: + default: + /* none */ + mode = ELEV_NONE; + break; + } + UpdateTrkEndElev(profilePopupTrk, profilePopupEp, mode, elev, NULL); + ComputeProfElem(); + RedrawProfileW( screenProfileD.d, NULL, 0, 0 ); + TempRedraw(); // ProfileSubCommand } static STATUS_T CmdProfile(wAction_t action, coOrd pos) { - track_p trk0; - coOrd textsize; - - switch (action) { - case C_START: - if (profileW == NULL) { - profileColorDefinedProfile = drawColorBlue; - profileColorUndefinedProfile = drawColorRed; - profileColorFill = drawColorGrey80; - DrawTextSize(&mainD, "999.9", wStandardFont(F_HELV, FALSE, FALSE), - screenProfileFontSize, FALSE, &textsize); - labelH = textsize.y; - labelW = textsize.x; - profileW = ParamCreateDialog(&profilePG, MakeWindowTitle(_("Profile")), NULL, - NULL, wHide, TRUE, NULL, F_RESIZE, CloseProfileWindow); - } - ParamLoadControls(&profilePG); - ParamGroupRecord(&profilePG); - wShow(profileW); - ParamLoadMessage(&profilePG, I_PROFILEMSG, _("Drag to change Elevation")); - profElem_da.cnt = 0; - station_da.cnt = 0; - RedrawProfileW( screenProfileD.d, NULL, 0, 0 ); - ClrAllTrkBitsRedraw(TB_PROFILEPATH, TRUE); - pathStartTrk = NULL; - SetAllTrackSelect(FALSE); - profileUndo = FALSE; - InfoMessage(_("Select a Defined Elevation to start profile")); - TempRedraw(); // CmdProfile C_START - return C_CONTINUE; - case C_LCLICK: - InfoMessage(""); - if ((trk0 = OnTrack(&pos, TRUE, TRUE)) != NULL) { - EPINX_T ep0; - ep0 = PickEndPoint(pos, trk0); - if (ep0 >= 0) { - ProfileSelect(trk0, ep0); - } - } - return C_CONTINUE; - case C_CMDMENU: - if ((profilePopupTrk = OnTrack(&pos, TRUE, TRUE)) != NULL) { - profilePopupEp = PickEndPoint(pos, profilePopupTrk); - if (profilePopupEp >= 0) { - int mode; - mode = GetTrkEndElevMode(profilePopupTrk, profilePopupEp); - if (mode != ELEV_DEF && mode != ELEV_IGNORE && mode != ELEV_NONE) { - ErrorMessage(MSG_CHANGE_ELEV_MODE); - } else { - wMenuToggleEnable(profilePopupToggles[1], TRUE); - if (OnPath(profilePopupTrk, profilePopupEp) & (ONPATH_END|ONPATH_MID)) { - wMenuToggleEnable(profilePopupToggles[1], FALSE); - } - wMenuToggleSet(profilePopupToggles[0], mode == ELEV_DEF); - wMenuToggleSet(profilePopupToggles[1], mode == ELEV_IGNORE); - wMenuToggleSet(profilePopupToggles[2], mode == ELEV_NONE); - menuPos = pos; - wMenuPopupShow(profilePopupM); - } - } - } - return C_CONTINUE; - case C_OK: - DoProfileDone(NULL); - return C_TERMINATE; - case C_CANCEL: - wHide(profileW); - ClrAllTrkBitsRedraw(TB_PROFILEPATH, TRUE); - return C_TERMINATE; - case C_REDRAW: - if (wWinIsVisible(profileW)) { - HilightProfileElevations(wWinIsVisible(profileW)); - } - return C_CONTINUE; - } - return C_CONTINUE; + track_p trk0; + coOrd textsize; + + switch (action) { + case C_START: + if (profileW == NULL) { + profileColorDefinedProfile = drawColorBlue; + profileColorUndefinedProfile = drawColorRed; + profileColorFill = drawColorGrey80; + DrawTextSize(&mainD, "999.9", wStandardFont(F_HELV, FALSE, FALSE), + screenProfileFontSize, FALSE, &textsize); + labelH = textsize.y; + labelW = textsize.x; + profileW = ParamCreateDialog(&profilePG, MakeWindowTitle(_("Profile")), NULL, + NULL, wHide, TRUE, NULL, F_RESIZE, CloseProfileWindow); + } + ParamLoadControls(&profilePG); + ParamGroupRecord(&profilePG); + wShow(profileW); + ParamLoadMessage(&profilePG, I_PROFILEMSG, _("Drag to change Elevation")); + DYNARR_RESET( profElem_t, profElem_da ); + DYNARR_RESET( station_t, station_da ); + RedrawProfileW( screenProfileD.d, NULL, 0, 0 ); + ClrAllTrkBitsRedraw(TB_PROFILEPATH, TRUE); + pathStartTrk = NULL; + SetAllTrackSelect(FALSE); + profileUndo = FALSE; + InfoMessage(_("Select a Defined Elevation to start profile")); + TempRedraw(); // CmdProfile C_START + return C_CONTINUE; + case C_LCLICK: + InfoMessage(""); + if ((trk0 = OnTrack(&pos, TRUE, TRUE)) != NULL) { + EPINX_T ep0; + ep0 = PickEndPoint(pos, trk0); + if (ep0 >= 0) { + ProfileSelect(trk0, ep0); + } + } + return C_CONTINUE; + case C_CMDMENU: + if ((profilePopupTrk = OnTrack(&pos, TRUE, TRUE)) != NULL) { + profilePopupEp = PickEndPoint(pos, profilePopupTrk); + if (profilePopupEp >= 0) { + int mode; + mode = GetTrkEndElevMode(profilePopupTrk, profilePopupEp); + if (mode != ELEV_DEF && mode != ELEV_IGNORE && mode != ELEV_NONE) { + ErrorMessage(MSG_CHANGE_ELEV_MODE); + } else { + wMenuToggleEnable(profilePopupToggles[1], TRUE); + if (OnPath(profilePopupTrk, profilePopupEp) & (ONPATH_END|ONPATH_MID)) { + wMenuToggleEnable(profilePopupToggles[1], FALSE); + } + wMenuToggleSet(profilePopupToggles[0], mode == ELEV_DEF); + wMenuToggleSet(profilePopupToggles[1], mode == ELEV_IGNORE); + wMenuToggleSet(profilePopupToggles[2], mode == ELEV_NONE); + menuPos = pos; + wMenuPopupShow(profilePopupM); + } + } + } + return C_CONTINUE; + case C_OK: + DoProfileDone(NULL); + return C_TERMINATE; + case C_CANCEL: + wHide(profileW); + ClrAllTrkBitsRedraw(TB_PROFILEPATH, TRUE); + return C_TERMINATE; + case C_REDRAW: + if (wWinIsVisible(profileW)) { + HilightProfileElevations(wWinIsVisible(profileW)); + } + return C_CONTINUE; + } + return C_CONTINUE; } static void ProfileChange(long changes) { - if ((changes & CHANGE_UNITS) && screenProfileD.d) { - RedrawProfileW( screenProfileD.d, NULL, 0, 0 ); - } + if ((changes & CHANGE_UNITS) && screenProfileD.d) { + RedrawProfileW( screenProfileD.d, NULL, 0, 0 ); + } } -#include "bitmaps/profile.xpm" +#include "bitmaps/profile.xpm3" EXPORT void InitCmdProfile(wMenu_p menu) { - log_profile = LogFindIndex("profile"); - ParamRegister(&profilePG); - - AddMenuButton(menu, CmdProfile, "cmdProfile", _("Profile"), - wIconCreatePixMap(profile_xpm[iconSize]), LEVEL0_50, IC_LCLICK|IC_CMDMENU|IC_POPUP3, - ACCL_PROFILE, NULL); - profilePopupM = MenuRegister("Profile Mode"); - profilePopupToggles[0] = wMenuToggleCreate(profilePopupM, "", _("Define"), 0, - FALSE, ProfileSubCommand, I2VP(0)); - profilePopupToggles[1] = wMenuToggleCreate(profilePopupM, "", _("Ignore"), 0, - FALSE, ProfileSubCommand, I2VP(1)); - profilePopupToggles[2] = wMenuToggleCreate(profilePopupM, "", _("None"), 0, - FALSE, ProfileSubCommand, I2VP(2)); - RegisterChangeNotification(ProfileChange); + log_profile = LogFindIndex("profile"); + ParamRegister(&profilePG); + + AddMenuButton(menu, CmdProfile, "cmdProfile", _("Profile"), + wIconCreatePixMap(profile_xpm3[iconSize]), LEVEL0_50, + IC_LCLICK|IC_CMDMENU|IC_POPUP3, + ACCL_PROFILE, NULL); + profilePopupM = MenuRegister("Profile Mode"); + profilePopupToggles[0] = wMenuToggleCreate(profilePopupM, "", _("Define"), 0, + FALSE, ProfileSubCommand, I2VP(0)); + profilePopupToggles[1] = wMenuToggleCreate(profilePopupM, "", _("Ignore"), 0, + FALSE, ProfileSubCommand, I2VP(1)); + profilePopupToggles[2] = wMenuToggleCreate(profilePopupM, "", _("None"), 0, + FALSE, ProfileSubCommand, I2VP(2)); + RegisterChangeNotification(ProfileChange); } diff --git a/app/bin/cpull.c b/app/bin/cpull.c index afdf834..af6642e 100644 --- a/app/bin/cpull.c +++ b/app/bin/cpull.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "cselect.h" @@ -37,22 +37,22 @@ DIST_T littleD = 0.1; static double factorX=10, factorY=100, factorA=0.2; typedef struct { - double X, Y, A, T; - } cost_t; + double X, Y, A, T; +} cost_t; static cost_t sumCosts; static cost_t maxCosts; static int maxCostsInx; typedef struct { - coOrd p[2]; - ANGLE_T a[2]; - ANGLE_T angle; - DIST_T dist; - track_p trk; - EPINX_T ep[2]; - cost_t costs[2]; - double contrib; - coOrd pp; - } section_t, *section_p; + coOrd p[2]; + ANGLE_T a[2]; + ANGLE_T angle; + DIST_T dist; + track_p trk; + EPINX_T ep[2]; + cost_t costs[2]; + double contrib; + coOrd pp; +} section_t, *section_p; static dynArr_t section_da; #define section(N) DYNARR_N( section_t, section_da, N ) static double contribL, contribR; @@ -67,10 +67,10 @@ typedef enum { freeEnd, connectedEnd, loopEnd } ending_e; * Utilities */ static ending_e GetConnectedTracks( - track_p trk, - EPINX_T ep, - track_p endTrk, - EPINX_T endEp ) + track_p trk, + EPINX_T ep, + track_p endTrk, + EPINX_T endEp ) { track_p trk1; EPINX_T ep1, ep2; @@ -81,15 +81,15 @@ static ending_e GetConnectedTracks( trk1 = NULL; } else { ep2 = GetNextTrk( trk, ep, &trk1, &ep1, 0 ); - if (trk1 == NULL) + if (trk1 == NULL) { return freeEnd; + } } if ( ep2 >= 0 ) { int inx; - for (inx=0;inx<section_da.cnt;inx++) { - if ( section(inx).trk == trk ) { - AbortProg("GetConnectedTracks(T%d already selected)", GetTrkIndex(trk)); - } + for (inx=0; inx<section_da.cnt; inx++) { + CHECKMSG( section(inx).trk != trk, ("GetConnectedTracks(T%d already selected)", + GetTrkIndex(trk)) ); } } DYNARR_APPEND( section_t, section_da, 10 ); @@ -99,17 +99,19 @@ static ending_e GetConnectedTracks( sp->ep[1] = ep2; sp->p[0] = GetTrkEndPos(trk,ep); sp->costs[0].X = sp->costs[0].Y = sp->costs[0].A = sp->costs[0].T = - sp->costs[1].X = sp->costs[1].Y = sp->costs[1].A = sp->costs[1].T =0.0; + sp->costs[1].X = sp->costs[1].Y = sp->costs[1].A = sp->costs[1].T =0.0; sp->a[0] = GetTrkEndAngle(trk,ep); sp->a[1] = 0; - if (ep2 < 0) + if (ep2 < 0) { return connectedEnd; + } sp->p[1] = GetTrkEndPos(trk,ep2); sp->dist = FindDistance( GetTrkEndPos(trk,ep), GetTrkEndPos(trk,ep2) ); sp->angle = NormalizeAngle( GetTrkEndAngle(trk,ep2)-GetTrkEndAngle(trk,ep) ); sp->a[1] = GetTrkEndAngle(trk,ep2); - if (trk == endTrk) + if (trk == endTrk) { return loopEnd; + } trk = trk1; ep = ep1; } @@ -119,10 +121,10 @@ static ending_e GetConnectedTracks( * Simple move to connect */ static void MoveConnectedTracks( - track_p trk1, - EPINX_T ep1, - coOrd pos, - ANGLE_T angle ) + track_p trk1, + EPINX_T ep1, + coOrd pos, + ANGLE_T angle ) { EPINX_T ep, ep2; track_p trk; @@ -140,10 +142,10 @@ static void MoveConnectedTracks( RotateTrack( trk1, pos, a ); DrawNewTrack( trk1 ); ep2 = GetNextTrk( trk1, ep1, &trk, &ep, 0 ); - if (trk==NULL) + if (trk==NULL) { return; - if (ep2 < 0) - AbortProg("MoveConnectedTracks(T%d rooted)", GetTrkIndex(trk1)); + } + CHECKMSG( ep2 >= 0, ("MoveConnectedTracks(T%d rooted)", GetTrkIndex(trk1)) );; angle = NormalizeAngle(GetTrkEndAngle( trk1, ep2 )+180.0); pos = GetTrkEndPos( trk1, ep2 ); trk1 = trk; @@ -156,7 +158,7 @@ static void MoveConnectedTracks( * Helpers for complex case */ static void ReverseSectionList( - int start, int end ) + int start, int end ) { int up, down; section_t tmpUp, tmpDown; @@ -200,25 +202,28 @@ static int CheckConnections( void ) sp = §ion(inx); dist = FindDistance( sp[0].p[0], sp[-1].p[1] ); angle = NormalizeAngle( sp[0].a[0] - sp[-1].a[1] + 180.0 + connectAngle/2 ); - if (dist > connectDistance) + if (dist > connectDistance) { rc |= DIST_FAULT; - if (angle > connectAngle) + } + if (angle > connectAngle) { rc |= ANGLE_FAULT; + } } return rc; } static void ComputeCost( - coOrd p, - ANGLE_T a, - section_p sp ) + coOrd p, + ANGLE_T a, + section_p sp ) { ANGLE_T da; coOrd pp; da = NormalizeAngle( sp->a[0]+180.0-a ); - if (da>180) + if (da>180) { da = 360.0-a; + } sp->costs[0].A = da*factorA; pp = sp->p[0]; Rotate( &pp, p, -a ); @@ -226,8 +231,9 @@ static void ComputeCost( pp.y -= p.y; sp->costs[0].X = fabs(pp.y*factorX); sp->costs[0].Y = fabs(pp.x*factorY); - if ( pp.x < -0.010 ) + if ( pp.x < -0.010 ) { sp->costs[0].X *= 100; + } sp->costs[0].T = sp->costs[0].X+sp->costs[0].Y; } @@ -242,9 +248,9 @@ static void ComputeCosts( void ) for (inx=1; inx<section_da.cnt; inx++) { sp = §ion(inx); ComputeCost( sp[-1].p[1], sp[-1].a[1], sp ); -if (debugPull) { -/*printf("%2d: X=%0.3f Y=%0.3f A=%0.3f T=%0.3f\n", inx, sp->costs[0].X, sp->costs[0].Y, sp->costs[0].A, sp->costs[0].T );*/ -} + if (debugPull) { + /*printf("%2d: X=%0.3f Y=%0.3f A=%0.3f T=%0.3f\n", inx, sp->costs[0].X, sp->costs[0].Y, sp->costs[0].A, sp->costs[0].T );*/ + } sumCosts.A += sp->costs[0].A; sumCosts.X += sp->costs[0].X; sumCosts.Y += sp->costs[0].Y; @@ -261,11 +267,11 @@ if (debugPull) { static double ComputeContrib( - DIST_T dist, - ANGLE_T angle, - int start, - int end, - EPINX_T ep ) + DIST_T dist, + ANGLE_T angle, + int start, + int end, + EPINX_T ep ) { int inx; section_p sp; @@ -292,27 +298,30 @@ static void ComputeContribs( coOrd *rp1 ) Rotate( &p1, p0, -sp[0].a[0] ); p1.x -= p0.x; p1.y -= p0.y; - if (sp->costs[0].X > 0.000001 && sp->costs[0].X > aveX) + if (sp->costs[0].X > 0.000001 && sp->costs[0].X > aveX) { p1.y *= 1-aveX/sp->costs[0].X; - else + } else { p1.y = 0.0; - if (sp->costs[0].Y > 0.000001 && sp->costs[0].Y > aveY) + } + if (sp->costs[0].Y > 0.000001 && sp->costs[0].Y > aveY) { p1.x *= 1-aveY/sp->costs[0].Y; - else + } else { p1.x = 0.0; + } Rotate( &p1, zero, sp[0].a[0] ); dist = FindDistance( zero, p1 ); angle = FindAngle( zero, p1 ); - contribL = ComputeContrib( dist, NormalizeAngle(angle+180.0), 1, maxCostsInx-1, 0 ); + contribL = ComputeContrib( dist, NormalizeAngle(angle+180.0), 1, maxCostsInx-1, + 0 ); contribR = ComputeContrib( dist, angle, maxCostsInx, section_da.cnt-2, 1 ); if (debugPull) { printf( "Minx=%d D=%0.3f A=%0.3f X=%0.3f Y=%0.3f L=%0.3f R=%0.3f\n", - maxCostsInx, dist, angle, p1.x, p1.y, contribL, contribR ); + maxCostsInx, dist, angle, p1.x, p1.y, contribL, contribR ); sp = §ion(0); printf( " 0[%d] [%0.3f %0.3f] [%0.3f %0.3f]\n", - GetTrkIndex(sp->trk), - sp[0].p[0].x, sp[0].p[0].y, sp[0].p[1].x, sp[0].p[1].y ); + GetTrkIndex(sp->trk), + sp[0].p[0].x, sp[0].p[0].y, sp[0].p[1].x, sp[0].p[1].y ); } *rp1 = p1; } @@ -322,8 +331,8 @@ static void ComputeContribs( coOrd *rp1 ) * Shufflers */ static void AdjustSection( - section_p sp, - coOrd amount ) + section_p sp, + coOrd amount ) { sp->p[0].x += amount.x; sp->p[0].y += amount.y; @@ -368,13 +377,16 @@ static void DumpSections( void ) sp = §ion(inx); dist = FindDistance( sp[0].p[0], sp[-1].p[1] ); printf( "%2d[%d] X%0.3f Y%0.3f A%0.3f T%0.3f C%0.3f x%0.3f y%0.3f [%0.3f %0.3f] [%0.3f %0.3f] dd%0.3f da%0.3f\n", - inx, GetTrkIndex(sp->trk), sp->costs[0].X, sp->costs[0].Y, sp->costs[0].A, sp->costs[0].T, - sp->contrib, sp->pp.x, sp->pp.y, - sp[0].p[0].x, sp[0].p[0].y, sp[0].p[1].x, sp[0].p[1].y, - dist, - (dist>0.001)?NormalizeAngle( FindAngle( sp[0].p[0], sp[-1].p[1] ) - sp[0].a[0] ):0.0 ); + inx, GetTrkIndex(sp->trk), sp->costs[0].X, sp->costs[0].Y, sp->costs[0].A, + sp->costs[0].T, + sp->contrib, sp->pp.x, sp->pp.y, + sp[0].p[0].x, sp[0].p[0].y, sp[0].p[1].x, sp[0].p[1].y, + dist, + (dist>0.001)?NormalizeAngle( FindAngle( sp[0].p[0], + sp[-1].p[1] ) - sp[0].a[0] ):0.0 ); } - printf("== X%0.3f Y%0.3f A%0.3f T%0.3f\n", sumCosts.X, sumCosts.Y, sumCosts.A, sumCosts.T ); + printf("== X%0.3f Y%0.3f A%0.3f T%0.3f\n", sumCosts.X, sumCosts.Y, sumCosts.A, + sumCosts.T ); } @@ -387,22 +399,28 @@ static int MinimizeCosts( void ) int inx; int rc = 0; coOrd p1; - if (section_da.cnt <= 0) + if (section_da.cnt <= 0) { return FALSE; + } for (inx=0; inx<iterCnt; inx++) { rc = CheckConnections(); ComputeCosts(); - if (maxCostsInx<0) + if (maxCostsInx<0) { return TRUE; + } ComputeContribs( &p1 ); - if (contribR+contribL <= 0.001) + if (contribR+contribL <= 0.001) { return rc; + } if (maxCosts.T*1.1 < sumCosts.T/(contribR+contribL) && rc) /* our work is done */ + { return rc; + } AdjustSections( p1 ); - if (debugPull) + if (debugPull) { DumpSections(); + } } return rc; } @@ -422,9 +440,9 @@ static void MoveSectionTracks( void ) oldPos = GetTrkEndPos( sp->trk, sp->ep[0] ); amount.x = sp->p[0].x-oldPos.x; amount.y = sp->p[0].y-oldPos.y; -if (debugPull) { -printf("%2d: X%0.3f Y%0.3f\n", inx, amount.x, amount.y ); -} + if (debugPull) { + printf("%2d: X%0.3f Y%0.3f\n", inx, amount.x, amount.y ); + } if (fabs(amount.x)>0.001 || fabs(amount.y)>0.001) { UndrawNewTrack( sp->trk ); UndoModify( sp->trk ); @@ -438,10 +456,10 @@ printf("%2d: X%0.3f Y%0.3f\n", inx, amount.x, amount.y ); static void PullTracks( - track_p trk1, - EPINX_T ep1, - track_p trk2, - EPINX_T ep2 ) + track_p trk1, + EPINX_T ep1, + track_p trk2, + EPINX_T ep2 ) { ending_e e1, e2; DIST_T d; @@ -449,7 +467,8 @@ static void PullTracks( coOrd p1, p2; ANGLE_T a1, a2; coOrd p; - int cnt1, cnt2; + int cnt1; +// int cnt2; int rc; if (QueryTrack(trk1,Q_CAN_ADD_ENDPOINTS)) { @@ -460,13 +479,15 @@ static void PullTracks( return; } - if (ep1<0 || ep2<0 ) return; + if (ep1<0 || ep2<0 ) { return; } - if (ConnectAbuttingTracks( trk1, ep1, trk2, ep2 )) + if (ConnectAbuttingTracks( trk1, ep1, trk2, ep2 )) { return; + } - if (ConnectAdjustableTracks( trk1, ep1, trk2, ep2 )) + if (ConnectAdjustableTracks( trk1, ep1, trk2, ep2 )) { return; + } p1 = GetTrkEndPos( trk1, ep1 ); @@ -479,23 +500,25 @@ static void PullTracks( ErrorMessage( MSG_TOO_FAR_APART_DIVERGE ); return; } - UndoStart( _("Pull Tracks"), "PullTracks(T%d[%d] T%d[%d] D%0.3f A%0.3F )", GetTrkIndex(trk1), ep1, GetTrkIndex(trk2), ep2, d, a ); - + UndoStart( _("Pull Tracks"), "PullTracks(T%d[%d] T%d[%d] D%0.3f A%0.3F )", + GetTrkIndex(trk1), ep1, GetTrkIndex(trk2), ep2, d, a ); + DYNARR_RESET( section_t, section_da ); e1 = e2 = GetConnectedTracks( trk1, ep1, trk2, ep2 ); cnt1 = section_da.cnt; if ( e1 != loopEnd ) { e2 = GetConnectedTracks( trk2, ep2, trk1, ep1 ); - } - cnt2 = section_da.cnt - cnt1; + } +// cnt2 = section_da.cnt - cnt1; if ( e1 == freeEnd && e2 == freeEnd ) { p.x = (p1.x+p2.x)/2.0; p.y = (p1.y+p2.y)/2.0; a = NormalizeAngle( (a1-(a2+180.0)) ); - if ( a < 180.0 ) + if ( a < 180.0 ) { a = NormalizeAngle(a1 + a/2.0); - else + } else { a = NormalizeAngle(a1 - (360-a)/2.0); + } MoveConnectedTracks( trk1, ep1, p, a ); MoveConnectedTracks( trk2, ep2, p, a+180.0 ); } else if ( e1 == freeEnd ) { @@ -545,8 +568,8 @@ static void PullTracks( */ static void TightenTracks( - track_p trk, - EPINX_T ep ) + track_p trk, + EPINX_T ep ) { track_p trk1; EPINX_T ep1, ep2; @@ -559,8 +582,9 @@ static void TightenTracks( ep = ep1; } trk1 = GetTrkEndTrk( trk, ep ); - if (trk1 == NULL) + if (trk1 == NULL) { return; + } ep1 = GetEndPtConnectedToMe( trk1, trk ); cnt = 0; while(1) { @@ -571,9 +595,9 @@ static void TightenTracks( p1.x = p0.x - p1.x; p1.y = p0.y - p1.y; a1 = NormalizeAngle( a0-a1 ); -if (debugPull) { -printf("T%d [%0.3f %0.3f %0.3f]\n", GetTrkIndex(trk1), p1.x, p1.y, a1 ); -} + if (debugPull) { + printf("T%d [%0.3f %0.3f %0.3f]\n", GetTrkIndex(trk1), p1.x, p1.y, a1 ); + } if ( FindDistance( zero, p1 ) > 0.001 || ( a1 > 0.05 && a1 < 365.95 ) ) { UndrawNewTrack( trk1 ); UndoModify( trk1 ); @@ -584,15 +608,16 @@ printf("T%d [%0.3f %0.3f %0.3f]\n", GetTrkIndex(trk1), p1.x, p1.y, a1 ); } trk = trk1; ep = GetNextTrk( trk, ep1, &trk1, &ep1, 0 ); - if (trk1 == NULL) + if (trk1 == NULL) { break; - if (ep<0) - AbortProg( "tightenTracks: can't happen" ); + } + CHECK(ep>=0); } InfoMessage( _("%d tracks moved"), cnt ); } -static void CreateConnectAnchor(EPINX_T ep, track_p t, BOOL_T shift) { +static void CreateConnectAnchor(EPINX_T ep, track_p t, BOOL_T shift) +{ coOrd pos = GetTrkEndPos(t,ep); DIST_T d = tempD.scale*0.15; DIST_T w = tempD.scale/tempD.dpi*4; @@ -606,7 +631,7 @@ static void CreateConnectAnchor(EPINX_T ep, track_p t, BOOL_T shift) { anchors(i).u.l.pos[0] = pos; Translate(&anchors(i).u.l.pos[1],pos,a+90,-GetTrkGauge(t)); Translate(&anchors(i).u.l.pos[1],anchors(i).u.l.pos[1],a,-d); - anchors(i).width = w; + anchors(i).lineWidth = w; DYNARR_APPEND(trkSeg_t,anchors_da,1); i = anchors_da.cnt-1; anchors(i).type = SEG_STRLIN; @@ -614,7 +639,7 @@ static void CreateConnectAnchor(EPINX_T ep, track_p t, BOOL_T shift) { anchors(i).u.l.pos[0] = pos; Translate(&anchors(i).u.l.pos[1],pos,a+90,GetTrkGauge(t)); Translate(&anchors(i).u.l.pos[1],anchors(i).u.l.pos[1],a,-d); - anchors(i).width = w; + anchors(i).lineWidth = w; } else { DYNARR_APPEND(trkSeg_t,anchors_da,1); i = anchors_da.cnt-1; @@ -624,7 +649,7 @@ static void CreateConnectAnchor(EPINX_T ep, track_p t, BOOL_T shift) { Translate(&anchors(i).u.l.pos[0],anchors(i).u.l.pos[0],a,d); Translate(&anchors(i).u.l.pos[1],pos,a+90,-GetTrkGauge(t)); Translate(&anchors(i).u.l.pos[1],anchors(i).u.l.pos[1],a,-d); - anchors(i).width = w; + anchors(i).lineWidth = w; DYNARR_APPEND(trkSeg_t,anchors_da,1); i = anchors_da.cnt-1; anchors(i).type = SEG_STRLIN; @@ -633,24 +658,28 @@ static void CreateConnectAnchor(EPINX_T ep, track_p t, BOOL_T shift) { Translate(&anchors(i).u.l.pos[0],anchors(i).u.l.pos[0],a,-d); Translate(&anchors(i).u.l.pos[1],pos,a+90,-GetTrkGauge(t)); Translate(&anchors(i).u.l.pos[1],anchors(i).u.l.pos[1],a,d); - anchors(i).width = w; + anchors(i).lineWidth = w; } } -STATUS_T ConnectMultiple() { +STATUS_T ConnectMultiple() +{ int countTracksR0 =0,countTracksR1 =0, possibleEndPoints =0; if (selectedTrackCount==0) { - ErrorMessage(_("Connect Multiple Tracks - Select multiple tracks to join first")); + ErrorMessage( + _("Connect Multiple Tracks - Select multiple tracks to join first")); return C_CONTINUE; } - if (NoticeMessage(_("Try to Connect all Selected Tracks?"), _("Yes"), _("No"))<=0) return C_CONTINUE; + if (NoticeMessage(_("Try to Connect all Selected Tracks?"), _("Yes"), + _("No"))<=0) { return C_CONTINUE; } track_p trk1 = NULL; track_p trk2 = NULL; EPINX_T ep1,ep2; ANGLE_T a; DIST_T d; UndoStart( _("ReConnect"),"Try to reconnect all selected tracks"); - for (int i=0;i<2;i++) { // Try twice - in case later joins help earlier ones and to try close ones first + for (int i=0; i<2; + i++) { // Try twice - in case later joins help earlier ones and to try close ones first while ( TrackIterate( &trk1 ) ) { BOOL_T found = FALSE; if ( GetTrkSelected( trk1 ) ) { @@ -658,42 +687,46 @@ STATUS_T ConnectMultiple() { if (!GetTrkEndTrk( trk1, ep1 )) { trk2 = NULL; while (!found && TrackIterate(&trk2) ) { - if (trk1 == trk2) continue; + if (trk1 == trk2) { continue; } for (ep2=0; ep2<GetTrkEndPtCnt(trk2); ep2++) { - if (GetTrkEndTrk( trk2, ep2 )) continue; + if (GetTrkEndTrk( trk2, ep2 )) { continue; } d = FindDistance(GetTrkEndPos(trk1,ep1),GetTrkEndPos(trk2,ep2)); - a = NormalizeAngle( 180+GetTrkEndAngle( trk1, ep1 ) - GetTrkEndAngle( trk2, ep2 )+(connectAngle/2.0)); + a = NormalizeAngle( 180+GetTrkEndAngle( trk1, ep1 ) - GetTrkEndAngle( trk2, + ep2 )+(connectAngle/2.0)); // Take two passes. In round one favor closer connections. In round two try anything. if ( (i==0 && (d < connectDistance) && (a < connectAngle)) || - (i>0 && (d<3.0 && a<7.5))) { // Match PullTracks criteria in round 2 + (i>0 && (d<3.0 && a<7.5))) { // Match PullTracks criteria in round 2 PullTracks(trk1,ep1,trk2,ep2); if (GetTrkEndTrk( trk2, ep2 )) { found = TRUE; - if (i==0) + if (i==0) { countTracksR0++; - else + } else { countTracksR1++; + } break; //Stop looking - } else if (i==1) possibleEndPoints++; + } else if (i==1) { possibleEndPoints++; } } } } - if (found) break; //Next EndPoint + if (found) { break; } //Next EndPoint } } } } } UndoEnd(); - NoticeMessage(_("Round 1 %d and Round 2 %d tracks connected, %d close pairs of end Points were not connected"), _("Ok"), NULL, countTracksR0, countTracksR1, possibleEndPoints); + NoticeMessage( + _("Round 1 %d and Round 2 %d tracks connected, %d close pairs of end Points were not connected"), + _("Ok"), NULL, countTracksR0, countTracksR1, possibleEndPoints); return C_TERMINATE; } static wMenu_p pullPopupM; static STATUS_T CmdPull( - wAction_t action, - coOrd pos ) + wAction_t action, + coOrd pos ) { static track_p trk1, t1, t2; @@ -703,16 +736,19 @@ static STATUS_T CmdPull( EPINX_T ep2; static BOOL_T turntable; - int countTracksR0 = 0, countTracksR1 = 0, possibleEndPoints = 0; - BOOL_T found = FALSE; +// int countTracksR0 = 0, countTracksR1 = 0, possibleEndPoints = 0; +// BOOL_T found = FALSE; switch (action&0xFF) { case C_START: - if (selectedTrackCount==0) - InfoMessage( _("Select first endpoint or turntable to connect, +Shift to tighten") ); - else - InfoMessage( _("Select first endpoint to connect, or Right-Click for connecting selected tracks (not turntable)") ); + if (selectedTrackCount==0) { + InfoMessage( + _("Select first endpoint or turntable to connect, +Shift to tighten") ); + } else { + InfoMessage( + _("Select first endpoint to connect, or Right-Click for connecting selected tracks (not turntable)") ); + } trk1 = NULL; turntable = FALSE; t1 = t2 = NULL; @@ -728,35 +764,39 @@ static STATUS_T CmdPull( if (QueryTrack(t1, Q_CAN_ADD_ENDPOINTS)) { DrawTrack(t1,&mainD,wDrawColorBlue); t_turn1 = TRUE; - } else t1 = NULL; + } else { t1 = NULL; } } - if (t1 && t_ep1 >=0) + if (t1 && t_ep1 >=0) { CreateConnectAnchor(t_ep1,t1,FALSE); + } } } else { if (t1 != NULL) { - if (t_turn1) DrawTrack(t1,&mainD,wDrawColorBlue); - else CreateConnectAnchor(t_ep1,t1,FALSE); + if (t_turn1) { DrawTrack(t1,&mainD,wDrawColorBlue); } + else { CreateConnectAnchor(t_ep1,t1,FALSE); } } if ((t2= OnTrackIgnore( &pos, FALSE, TRUE, t1 )) != NULL) { if ((t_ep2 = PickUnconnectedEndPointSilent( pos, t2 )) < 0) { if (QueryTrack(t2, Q_CAN_ADD_ENDPOINTS)) { DrawTrack(t2,&mainD,wDrawColorBlue); t_turn2 = TRUE; - } else t2 = NULL; + } else { t2 = NULL; } } - if (t2 && t_ep2 >=0) + if (t2 && t_ep2 >=0) { CreateConnectAnchor(t_ep2,t2,FALSE); + } } } } else { //Shift, tighten t1 = OnTrack( &pos, FALSE, TRUE ); - if (t1 == NULL) + if (t1 == NULL) { return C_CONTINUE; + } t_ep1 = PickUnconnectedEndPointSilent( pos, t1 ); - if ( t_ep1 < 0 ) + if ( t_ep1 < 0 ) { return C_CONTINUE; + } CreateConnectAnchor(t_ep1,t1,TRUE); } break; @@ -769,7 +809,7 @@ static STATUS_T CmdPull( if (QueryTrack(trk1, Q_CAN_ADD_ENDPOINTS)) { turntable = TRUE; ep1 = -1; - } else trk1 = NULL; + } else { trk1 = NULL; } } else { InfoMessage( _("Select second endpoint or turntable to connect") ); } @@ -787,7 +827,8 @@ static STATUS_T CmdPull( inError = TRUE; return C_TERMINATE; } - if (!turntable && QueryTrack(trk2, Q_CAN_ADD_ENDPOINTS)) { /*Second end a turntable */ + if (!turntable + && QueryTrack(trk2, Q_CAN_ADD_ENDPOINTS)) { /*Second end a turntable */ ep2 = -1; turntable = TRUE; PullTracks( trk2, ep2, trk1, ep1); @@ -800,11 +841,13 @@ static STATUS_T CmdPull( } } else { trk1 = OnTrack( &pos, TRUE, TRUE ); - if (trk1 == NULL) + if (trk1 == NULL) { return C_CONTINUE; + } ep1 = PickUnconnectedEndPoint( pos, trk1 ); - if ( ep1 < 0 ) + if ( ep1 < 0 ) { return C_CONTINUE; + } TightenTracks( trk1, ep1 ); trk1 = NULL; inError = TRUE; @@ -815,12 +858,14 @@ static STATUS_T CmdPull( case C_REDRAW: DrawHighlightBoxes(FALSE,FALSE,NULL); HighlightSelectedTracks(NULL, TRUE, TRUE); - if (anchors_da.cnt) - DrawSegs( &tempD, zero, 0.0, &anchors(0), anchors_da.cnt, trackGauge, wDrawColorBlack ); - if (t1 && t_turn1) - DrawTrack(t1,&tempD,wDrawColorBlue); - if (t2 && t_turn2) - DrawTrack(t2,&tempD,wDrawColorBlue); + DrawSegsDA( &tempD, NULL, zero, 0.0, &anchors_da, trackGauge, wDrawColorBlack, + 0 ); + if (t1 && t_turn1) { + DrawTrack(t1,&tempD,wDrawColorBlue); + } + if (t2 && t_turn2) { + DrawTrack(t2,&tempD,wDrawColorBlue); + } return C_CONTINUE; case C_TEXT: @@ -855,7 +900,7 @@ static STATUS_T CmdPull( -#include "bitmaps/connect.xpm" +#include "bitmaps/connect.xpm3" wMenuPush_p pullConnectMultiple; @@ -870,7 +915,11 @@ void pullMenuEnter( void * keyVP ) void InitCmdPull( wMenu_p menu ) { - AddMenuButton( menu, CmdPull, "cmdConnect", _("Connect Two Tracks"), wIconCreatePixMap(connect_xpm[iconSize]), LEVEL0_50, IC_STICKY|IC_INITNOTSTICKY|IC_LCLICK|IC_POPUP3|IC_CMDMENU|IC_WANT_MOVE, ACCL_CONNECT, NULL ); + AddMenuButton( menu, CmdPull, "cmdConnect", _("Connect Two Tracks"), + wIconCreatePixMap(connect_xpm3[iconSize]), LEVEL0_50, + IC_STICKY|IC_INITNOTSTICKY|IC_LCLICK|IC_POPUP3|IC_CMDMENU|IC_WANT_MOVE, + ACCL_CONNECT, NULL ); pullPopupM = MenuRegister( "Connect Options" ); - pullConnectMultiple = wMenuPushCreate( pullPopupM, "", _("Connect All Selected - 'S'"), 0, pullMenuEnter, I2VP('S') ); + pullConnectMultiple = wMenuPushCreate( pullPopupM, "", + _("Connect All Selected - 'S'"), 0, pullMenuEnter, I2VP('S') ); } diff --git a/app/bin/cruler.c b/app/bin/cruler.c index eb6a77d..1ab65b2 100644 --- a/app/bin/cruler.c +++ b/app/bin/cruler.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "cundo.h" @@ -34,21 +34,22 @@ static struct { - STATE_T state; - coOrd pos0; - coOrd pos1; - coOrd pos2; - BOOL_T isClose; - int modifyingEnd; - } An = { AN_OFF, { 0,0 }, { 0,0 } }; + STATE_T state; + coOrd pos0; + coOrd pos1; + coOrd pos2; + BOOL_T isClose; + int modifyingEnd; +} An = { AN_OFF, { 0,0 }, { 0,0 } }; -void DrawAngle(drawCmd_p d, coOrd p0, coOrd p1, coOrd p2, wDrawColor color) { +void DrawAngle(drawCmd_p d, coOrd p0, coOrd p1, coOrd p2, wDrawColor color) +{ char msg[512]; trkSeg_t seg; if ((An.state != AN_OFF) && !IsClose(FindDistance(p0,p1))) { seg.type = SEG_STRLIN; - seg.width = 0; + seg.lineWidth = 0; seg.color = wDrawColorBlack; seg.u.l.pos[0] = p0; seg.u.l.pos[1] = p1; @@ -56,7 +57,7 @@ void DrawAngle(drawCmd_p d, coOrd p0, coOrd p1, coOrd p2, wDrawColor color) { if (!(IsClose(FindDistance(p0,p2)))) { seg.type = SEG_STRLIN; - seg.width = 0; + seg.lineWidth = 0; seg.color = wDrawColorBlack; seg.u.l.pos[0] = p0; seg.u.l.pos[1] = p2; @@ -66,10 +67,11 @@ void DrawAngle(drawCmd_p d, coOrd p0, coOrd p1, coOrd p2, wDrawColor color) { ANGLE_T a = DifferenceBetweenAngles(FindAngle(p0,p1),FindAngle(p0,p2)); ANGLE_T a0; - if (a>=0) + if (a>=0) { a0 = FindAngle(p0,p1); - else + } else { a0 = FindAngle(p0,p2); + } ANGLE_T a1 = fabs(DifferenceBetweenAngles(FindAngle(p0,p1),FindAngle(p0,p2))); seg.type = SEG_CRVLIN; seg.u.c.center = p0; @@ -124,8 +126,8 @@ static STATUS_T CmdAngle( wAction_t action, coOrd pos ) case AN_FIRST: An.pos2 = pos; An.state = AN_SECOND; - InfoMessage( "Drag Angle" ); - break; + InfoMessage( "Drag Angle" ); + break; } return C_CONTINUE; @@ -133,8 +135,8 @@ static STATUS_T CmdAngle( wAction_t action, coOrd pos ) //Lock to 90 degrees with CTRL if (MyGetKeyState()&WKEY_CTRL) { ANGLE_T line_angle; - if (An.state == AN_FIRST) line_angle = 0.0; - else line_angle = FindAngle(An.pos0,An.pos1); + if (An.state == AN_FIRST) { line_angle = 0.0; } + else { line_angle = FindAngle(An.pos0,An.pos1); } DIST_T l = FindDistance(An.pos0, pos); if (!IsClose(l)) { ANGLE_T angle2 = NormalizeAngle(FindAngle(An.pos0, pos)-line_angle); @@ -144,23 +146,26 @@ static STATUS_T CmdAngle( wAction_t action, coOrd pos ) } } switch (An.state) { - case AN_FIRST: - An.pos1 = An.pos2 = pos; - break; - case AN_SECOND: - An.pos2 = pos; - break; - default:; + case AN_FIRST: + An.pos1 = An.pos2 = pos; + break; + case AN_SECOND: + An.pos2 = pos; + break; + default:; } - if (An.state == AN_FIRST) + if (An.state == AN_FIRST) { InfoMessage( "Base Angle %0.3f",FindAngle(An.pos0,An.pos1)); + } if (An.state == AN_SECOND) - InfoMessage( "Base Angle %0.3f, Relative Angle %0.3f",FindAngle(An.pos0,An.pos1), - fabs(DifferenceBetweenAngles(FindAngle(An.pos0,An.pos1),FindAngle(An.pos0,An.pos2)))); + InfoMessage( "Base Angle %0.3f, Relative Angle %0.3f",FindAngle(An.pos0, + An.pos1), + fabs(DifferenceBetweenAngles(FindAngle(An.pos0,An.pos1),FindAngle(An.pos0, + An.pos2)))); return C_CONTINUE; case C_UP: - if (An.state == AN_SECOND) return C_TERMINATE; + if (An.state == AN_SECOND) { return C_TERMINATE; } return C_CONTINUE; case C_REDRAW: @@ -182,23 +187,25 @@ static STATUS_T CmdAngle( wAction_t action, coOrd pos ) } STATUS_T ModifyProtractor( - wAction_t action, - coOrd pos ) + wAction_t action, + coOrd pos ) { switch (action&0xFF) { case C_DOWN: An.modifyingEnd = -1; An.isClose = FALSE; - if ( An.state == AN_OFF ) + if ( An.state == AN_OFF ) { return C_ERROR; + } if ( IsClose(FindDistance( pos, An.pos0 ))) { An.modifyingEnd = 0; } else if ( IsClose(FindDistance( pos, An.pos1 ))) { An.modifyingEnd = 1; } else if ( IsClose(FindDistance( pos, An.pos2 ))) { An.modifyingEnd = 2; - } else + } else { return C_ERROR; + } break; case C_MOVE: if ( An.modifyingEnd == 0 ) { @@ -208,21 +215,25 @@ STATUS_T ModifyProtractor( } else if (An.modifyingEnd == 2) { An.pos2 = pos; } - InfoMessage( "Base Angle %0.3f, Relative Angle %0.3f",FindAngle(An.pos0,An.pos1), - fabs(DifferenceBetweenAngles(FindAngle(An.pos0,An.pos1),FindAngle(An.pos0,An.pos2)))); + InfoMessage( "Base Angle %0.3f, Relative Angle %0.3f",FindAngle(An.pos0, + An.pos1), + fabs(DifferenceBetweenAngles(FindAngle(An.pos0,An.pos1),FindAngle(An.pos0, + An.pos2)))); return C_CONTINUE; case C_UP: return C_CONTINUE; case C_REDRAW: - DrawAngle( &tempD, An.pos0, An.pos1, An.pos2, An.isClose?wDrawColorBlue:wDrawColorBlack ); + DrawAngle( &tempD, An.pos0, An.pos1, An.pos2, + An.isClose?wDrawColorBlue:wDrawColorBlack ); break; case wActionMove: if ( IsClose(FindDistance( pos, An.pos0 )) || - IsClose(FindDistance( pos, An.pos1 )) || - IsClose(FindDistance( pos, An.pos2 )) ) { + IsClose(FindDistance( pos, An.pos1 )) || + IsClose(FindDistance( pos, An.pos2 )) ) { An.isClose = TRUE; - } else + } else { An.isClose = FALSE; + } break; default: return C_ERROR; @@ -246,25 +257,29 @@ STATUS_T ModifyProtractor( #define DR_ON (1) static struct { - STATE_T state; - coOrd pos0; - coOrd pos1; - BOOL_T isClose; - int modifyingEnd; - } Dr = { DR_OFF, { 0,0 }, { 0,0 } }; + STATE_T state; + coOrd pos0; + coOrd pos1; + BOOL_T isClose; + int modifyingEnd; +} Dr = { DR_OFF, { 0,0 }, { 0,0 } }; void RulerRedraw( BOOL_T demo ) { - if (programMode == MODE_TRAIN) return; - if (Dr.state == DR_ON) - DrawRuler( &tempD, Dr.pos0, Dr.pos1, 0.0, TRUE, TRUE, Dr.isClose?wDrawColorBlue:wDrawColorBlack ); + if (programMode == MODE_TRAIN) { return; } + if (Dr.state == DR_ON) { + DrawRuler( &tempD, Dr.pos0, Dr.pos1, 0.0, TRUE, TRUE, + Dr.isClose?wDrawColorBlue:wDrawColorBlack ); + } if (demo) { Dr.state = DR_OFF; An.state = AN_OFF; } - if (An.state != AN_OFF) - DrawAngle( &tempD, An.pos0, An.pos1, An.pos2, An.isClose?wDrawColorBlue:wDrawColorBlack); + if (An.state != AN_OFF) { + DrawAngle( &tempD, An.pos0, An.pos1, An.pos2, + An.isClose?wDrawColorBlue:wDrawColorBlack); + } } @@ -304,7 +319,8 @@ static STATUS_T CmdRuler( wAction_t action, coOrd pos ) DrawHighlightBoxes(FALSE,FALSE,NULL); HighlightSelectedTracks(NULL, TRUE, TRUE); if (Dr.state == DR_ON) { - DrawRuler( &tempD, Dr.pos0, Dr.pos1, 0.0, TRUE, TRUE, Dr.isClose?wDrawColorBlue:wDrawColorBlack ); + DrawRuler( &tempD, Dr.pos0, Dr.pos1, 0.0, TRUE, TRUE, + Dr.isClose?wDrawColorBlue:wDrawColorBlack ); } return C_CONTINUE; @@ -318,14 +334,15 @@ static STATUS_T CmdRuler( wAction_t action, coOrd pos ) STATUS_T ModifyRuler( - wAction_t action, - coOrd pos ) + wAction_t action, + coOrd pos ) { switch (action&0xFF) { case C_DOWN: Dr.modifyingEnd = -1; - if ( Dr.state != DR_ON ) + if ( Dr.state != DR_ON ) { return C_ERROR; + } if ( IsClose(FindDistance( pos, Dr.pos0 ))) { Dr.modifyingEnd = 0; } else if ( IsClose(FindDistance( pos, Dr.pos1 ))) { @@ -339,17 +356,18 @@ STATUS_T ModifyRuler( Dr.pos0 = pos; } else if ( Dr.modifyingEnd == 1) { Dr.pos1 = pos; - } else return C_ERROR; + } else { return C_ERROR; } InfoMessage( "%s", FormatDistance( FindDistance( Dr.pos0, Dr.pos1 ) ) ); return C_CONTINUE; case C_UP: return C_CONTINUE; case C_REDRAW: - DrawRuler( &tempD, Dr.pos0, Dr.pos1, 0.0, TRUE, TRUE, Dr.isClose?wDrawColorBlue:wDrawColorBlack ); + DrawRuler( &tempD, Dr.pos0, Dr.pos1, 0.0, TRUE, TRUE, + Dr.isClose?wDrawColorBlue:wDrawColorBlack ); break; case wActionMove: if ( IsClose(FindDistance( pos, Dr.pos0 )) || - IsClose(FindDistance( pos, Dr.pos1 ))) { + IsClose(FindDistance( pos, Dr.pos1 ))) { Dr.isClose = TRUE; An.isClose = FALSE; } else { @@ -364,13 +382,17 @@ STATUS_T ModifyRuler( } -#include "bitmaps/ruler.xpm" -#include "bitmaps/protractor.xpm" +#include "bitmaps/ruler.xpm3" +#include "bitmaps/protractor.xpm3" void InitCmdRuler( wMenu_p menu ) { ButtonGroupBegin( _("Measurement"), "cmdMeasureSetCmd", _("Measurement") ); - AddMenuButton( menu, CmdRuler, "cmdRuler", _("Ruler"), wIconCreatePixMap(ruler_xpm[iconSize]), LEVEL0, IC_STICKY|IC_POPUP|IC_NORESTART, ACCL_RULER, NULL ); - AddMenuButton( menu, CmdAngle, "cmdAngle", _("Protractor"), wIconCreatePixMap(protractor_xpm[iconSize]), LEVEL0, IC_STICKY|IC_POPUP|IC_NORESTART, ACCL_ANGLE, NULL ); + AddMenuButton( menu, CmdRuler, "cmdRuler", _("Ruler"), + wIconCreatePixMap(ruler_xpm3[iconSize]), LEVEL0, + IC_STICKY|IC_POPUP|IC_NORESTART, ACCL_RULER, NULL ); + AddMenuButton( menu, CmdAngle, "cmdAngle", _("Protractor"), + wIconCreatePixMap(protractor_xpm3[iconSize]), LEVEL0, + IC_STICKY|IC_POPUP|IC_NORESTART, ACCL_ANGLE, NULL ); ButtonGroupEnd(); } diff --git a/app/bin/cselect.c b/app/bin/cselect.c index 1b153b9..a1158bc 100644 --- a/app/bin/cselect.c +++ b/app/bin/cselect.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "common.h" @@ -37,8 +37,8 @@ #include "cjoin.h" #include "draw.h" #include "misc.h" -#include "trackx.h" #include "common-ui.h" +#include "ctrain.h" #include "bitmaps/bmendpt.xbm" @@ -54,6 +54,9 @@ EXPORT wIndex_t moveCmdInx; EXPORT wIndex_t rotateCmdInx; EXPORT wIndex_t flipCmdInx; +EXPORT long selectMode = 0; +EXPORT long selectZero = 1; + #define MAXMOVEMODE (3) static long moveMode = MAXMOVEMODE; static BOOL_T enableMoveDraw = TRUE; @@ -76,25 +79,27 @@ static dynArr_t tlist_da; { DYNARR_APPEND( track_p, tlist_da, 10 );\ Tlist(tlist_da.cnt-1) = T; } -BOOL_T TListSearch(track_p T) { - for (int i=0;i<tlist_da.cnt-1;i++) { \ - if (Tlist(i) == T) return TRUE; +BOOL_T TListSearch(track_p T) +{ + for (int i=0; i<tlist_da.cnt-1; i++) { + \ + if (Tlist(i) == T) { return TRUE; } } return FALSE; } static wMenu_p selectPopup1M; -static wMenu_p selectPopup1CM; static wMenu_p selectPopup2M; -static wMenu_p selectPopup2CM; static wMenu_p selectPopup2RM; static wMenu_p selectPopup2TM; static wMenu_p selectPopup2TYM; static wMenuPush_p menuPushModify; static wMenuPush_p rotateAlignMI; static wMenuPush_p descriptionMI; +static wMenuPush_p tiesMI; static wMenuPush_p hideMI; static wMenuPush_p bridgeMI; +static wMenuPush_p roadbedMI; static wMenuPush_p tiesMI; @@ -102,51 +107,53 @@ static BOOL_T doingAlign = FALSE; static enum { AREA, MOVE } mode; static void SelectOneTrack( - track_p trk, - wBool_t selected ); + track_p trk, + wBool_t selected ); static void DrawSelectedTracksD( drawCmd_p d, wDrawColor color ); static dynArr_t anchors_da; #define anchors(N) DYNARR_N(trkSeg_t,anchors_da,N) -void CreateArrowAnchor(coOrd pos,ANGLE_T a,DIST_T len) { - DYNARR_APPEND(trkSeg_t,anchors_da,1); - int i = anchors_da.cnt-1; - anchors(i).type = SEG_STRLIN; - anchors(i).width = 0; - anchors(i).u.l.pos[0] = pos; - Translate(&anchors(i).u.l.pos[1],pos,NormalizeAngle(a+135),len); - anchors(i).color = wDrawColorBlue; - DYNARR_APPEND(trkSeg_t,anchors_da,1); - i = anchors_da.cnt-1; - anchors(i).type = SEG_STRLIN; - anchors(i).width = 0; - anchors(i).u.l.pos[0] = pos; - Translate(&anchors(i).u.l.pos[1],pos,NormalizeAngle(a-135),len); - anchors(i).color = wDrawColorBlue; - wSetCursor(mainD.d,wCursorNone); +void CreateArrowAnchor(coOrd pos,ANGLE_T a,DIST_T len) +{ + DYNARR_APPEND(trkSeg_t,anchors_da,1); + int i = anchors_da.cnt-1; + anchors(i).type = SEG_STRLIN; + anchors(i).lineWidth = 0; + anchors(i).u.l.pos[0] = pos; + Translate(&anchors(i).u.l.pos[1],pos,NormalizeAngle(a+135),len); + anchors(i).color = wDrawColorBlue; + DYNARR_APPEND(trkSeg_t,anchors_da,1); + i = anchors_da.cnt-1; + anchors(i).type = SEG_STRLIN; + anchors(i).lineWidth = 0; + anchors(i).u.l.pos[0] = pos; + Translate(&anchors(i).u.l.pos[1],pos,NormalizeAngle(a-135),len); + anchors(i).color = wDrawColorBlue; + wSetCursor(mainD.d,wCursorNone); } -void static CreateRotateAnchor(coOrd pos) { +void static CreateRotateAnchor(coOrd pos) +{ DIST_T d = tempD.scale*0.15; DYNARR_APPEND(trkSeg_t,anchors_da,1); int i = anchors_da.cnt-1; anchors(i).type = SEG_CRVLIN; - anchors(i).width = d/8; + anchors(i).lineWidth = d/8; anchors(i).u.c.center = pos; anchors(i).u.c.a0 = 180.0; anchors(i).u.c.a1 = 360.0; anchors(i).u.c.radius = d*2; anchors(i).color = wDrawColorAqua; coOrd head; //Arrows - for (int j=0;j<3;j++) { + for (int j=0; j<3; j++) { Translate(&head,pos,j*120,d*2); CreateArrowAnchor(head,NormalizeAngle((j*120)+90),d); } DYNARR_APPEND(trkSeg_t,anchors_da,1); i = anchors_da.cnt-1; anchors(i).type = SEG_CRVLIN; - anchors(i).width = d/8; + anchors(i).lineWidth = d/8; anchors(i).u.c.center = pos; anchors(i).u.c.a0 = 180.0; anchors(i).u.c.a1 = 360.0; @@ -155,12 +162,13 @@ void static CreateRotateAnchor(coOrd pos) { wSetCursor(mainD.d,wCursorNone); } -void static CreateModifyAnchor(coOrd pos) { +void static CreateModifyAnchor(coOrd pos) +{ DIST_T d = tempD.scale*0.15; DYNARR_APPEND(trkSeg_t,anchors_da,1); int i = anchors_da.cnt-1; anchors(i).type = SEG_FILCRCL; - anchors(i).width = 0; + anchors(i).lineWidth = 0; anchors(i).u.c.center = pos; anchors(i).u.c.a0 = 180.0; anchors(i).u.c.a1 = 360.0; @@ -169,7 +177,7 @@ void static CreateModifyAnchor(coOrd pos) { DYNARR_APPEND(trkSeg_t,anchors_da,1); i = anchors_da.cnt-1; anchors(i).type = SEG_CRVLIN; - anchors(i).width = 0; + anchors(i).lineWidth = 0; anchors(i).u.c.center = pos; anchors(i).u.c.a0 = 180.0; anchors(i).u.c.a1 = 360.0; @@ -179,15 +187,16 @@ void static CreateModifyAnchor(coOrd pos) { } -void CreateDescribeAnchor(coOrd pos) { +void CreateDescribeAnchor(coOrd pos) +{ DIST_T d = tempD.scale*0.15; - for (int j=0;j<2;j++) { + for (int j=0; j<2; j++) { pos.x += j*d*3/4; pos.y += j*d/2; DYNARR_APPEND(trkSeg_t,anchors_da,1); int i = anchors_da.cnt-1; anchors(i).type = SEG_CRVLIN; - anchors(i).width = d/4; + anchors(i).lineWidth = d/4; anchors(i).u.c.center = pos; anchors(i).u.c.a0 = 270.0; anchors(i).u.c.a1 = 270.0; @@ -196,7 +205,7 @@ void CreateDescribeAnchor(coOrd pos) { DYNARR_APPEND(trkSeg_t,anchors_da,1); i = anchors_da.cnt-1; anchors(i).type = SEG_STRLIN; - anchors(i).width = d/4; + anchors(i).lineWidth = d/4; Translate(&anchors(i).u.l.pos[0],pos,180.0,d*3/4); Translate(&anchors(i).u.l.pos[1],pos,180.0,d*1.5); anchors(i).color = wDrawColorPowderedBlue; @@ -204,13 +213,14 @@ void CreateDescribeAnchor(coOrd pos) { wSetCursor(mainD.d,wCursorNone); } -void CreateActivateAnchor(coOrd pos) { +void CreateActivateAnchor(coOrd pos) +{ DIST_T d = tempD.scale*0.15; coOrd c = pos; DYNARR_APPEND(trkSeg_t,anchors_da,1); int i = anchors_da.cnt-1; anchors(i).type = SEG_CRVLIN; - anchors(i).width = 0; + anchors(i).lineWidth = 0; c.x -= d*3/4; anchors(i).u.c.center = c; anchors(i).u.c.a0 = 0.0; @@ -221,7 +231,7 @@ void CreateActivateAnchor(coOrd pos) { i = anchors_da.cnt-1; c.x += d*1.5; anchors(i).type = SEG_CRVLIN; - anchors(i).width = 0; + anchors(i).lineWidth = 0; anchors(i).u.c.center = pos; anchors(i).u.c.a0 = 0.0; anchors(i).u.c.a1 = 360.0; @@ -230,15 +240,19 @@ void CreateActivateAnchor(coOrd pos) { wSetCursor(mainD.d,wCursorNone); } -void static CreateMoveAnchor(coOrd pos) { +void static CreateMoveAnchor(coOrd pos) +{ DYNARR_SET(trkSeg_t,anchors_da,anchors_da.cnt+5); - DrawArrowHeads(&DYNARR_N(trkSeg_t,anchors_da,anchors_da.cnt-5),pos,0,TRUE,wDrawColorBlue); + DrawArrowHeads(&DYNARR_N(trkSeg_t,anchors_da,anchors_da.cnt-5),pos,0,TRUE, + wDrawColorBlue); DYNARR_SET(trkSeg_t,anchors_da,anchors_da.cnt+5); - DrawArrowHeads(&DYNARR_N(trkSeg_t,anchors_da,anchors_da.cnt-5),pos,90,TRUE,wDrawColorBlue); + DrawArrowHeads(&DYNARR_N(trkSeg_t,anchors_da,anchors_da.cnt-5),pos,90,TRUE, + wDrawColorBlue); wSetCursor(mainD.d,wCursorNone); } -void CreateEndAnchor(coOrd p, wBool_t lock) { +void CreateEndAnchor(coOrd p, wBool_t lock) +{ DIST_T d = tempD.scale*0.15; DYNARR_APPEND(trkSeg_t,anchors_da,1); @@ -249,7 +263,7 @@ void CreateEndAnchor(coOrd p, wBool_t lock) { anchors(i).u.c.radius = d/2; anchors(i).u.c.a0 = 0.0; anchors(i).u.c.a1 = 360.0; - anchors(i).width = 0; + anchors(i).lineWidth = 0; } @@ -260,7 +274,8 @@ void CreateEndAnchor(coOrd p, wBool_t lock) { * */ -EXPORT long selectedTrackCount = 0; /**< number of currently selected track components */ +EXPORT long selectedTrackCount = + 0; /**< number of currently selected track components */ static void SelectedTrackCountChange( void ) { @@ -279,20 +294,20 @@ static void SelectedTrackCountChange( void ) static void DrawTrackAndEndPts( - track_p trk, - wDrawColor color ) + track_p trk, + wDrawColor color ) { EPINX_T ep, ep2; track_p trk2; DrawTrack( trk, &mainD, color ); - for (ep=0;ep<GetTrkEndPtCnt(trk);ep++) { + for (ep=0; ep<GetTrkEndPtCnt(trk); ep++) { if ((trk2=GetTrkEndTrk(trk,ep)) != NULL) { - ASSERT( !IsTrackDeleted(trk) ); + CHECK( !IsTrackDeleted(trk) ); ep2 = GetEndPtConnectedToMe( trk2, trk ); DrawEndPt( &mainD, trk2, ep2, - (color==wDrawColorBlack && GetTrkSelected(trk2))? - selectedColor:color ); + (color==wDrawColorBlack && GetTrkSelected(trk2))? + selectedColor:color ); } } } @@ -301,14 +316,14 @@ static void DrawTrackAndEndPts( static void RedrawSelectedTracksBoundary() { -/* Truth table: 4 cases for a track trk, connected to trk1 - * SELREDRAW - * trk, trk1: F, F - No changes, nothing to draw - * T, F - trk changes but trk1 didn't, flip drawing of select boundary marker - * F, T - trk didn't change but trk1 did, handle redrawing when we get to 2nd track - * T, T - both changed, but we don't need to redraw anything - * unfortunately we will do a redundant redraw when we get to the 2nd track - */ + /* Truth table: 4 cases for a track trk, connected to trk1 + * SELREDRAW + * trk, trk1: F, F - No changes, nothing to draw + * T, F - trk changes but trk1 didn't, flip drawing of select boundary marker + * F, T - trk didn't change but trk1 did, handle redrawing when we get to 2nd track + * T, T - both changed, but we don't need to redraw anything + * unfortunately we will do a redundant redraw when we get to the 2nd track + */ // if (importTrack != NULL) // return; track_p trk; @@ -317,8 +332,9 @@ static void RedrawSelectedTracksBoundary() // This track has changed for ( EPINX_T ep = 0; ep < GetTrkEndPtCnt(trk); ep++ ) { track_p trk1 = GetTrkEndTrk( trk, ep ); - if ( trk1 == NULL ) + if ( trk1 == NULL ) { continue; + } // if ( GetTrkIndex( trk ) < GetTrkIndex( trk1 ) // continue; @@ -335,20 +351,23 @@ static void RedrawSelectedTracksBoundary() ANGLE_T a = GetTrkEndAngle( trk, ep ); coOrd p0, p1, p2; len = GetTrkGauge(trk)*2.0; - if (len < 0.10*mainD.scale) + if (len < 0.10*mainD.scale) { len = 0.10*mainD.scale; - Translate( &p1, p, a+45, len ); - Translate( &p2, p, a+225, len ); - DrawLine( &mainD, p1, p2, 2, color ); - Translate( &p1, p, a-45, len ); - Translate( &p2, p, a-225, len ); - DrawLine( &mainD, p1, p2, 2, color ); + } + if (DrawTwoRails( &mainD, 1 ) ) { + Translate( &p1, p, a+45, len ); + Translate( &p2, p, a+225, len ); + DrawLine( &mainD, p1, p2, 2, color ); + Translate( &p1, p, a-45, len ); + Translate( &p2, p, a-225, len ); + DrawLine( &mainD, p1, p2, 2, color ); + } if ( color == wDrawColorWhite ) { // Fill in holes by undraw cross DIST_T len2 = sqrt( GetTrkGauge(trk)*GetTrkGauge(trk)/2.0 ); DIST_T len3 = 0.1*mainD.scale; color = GetTrkColor( trk, &mainD ); - if ( mainD.scale < twoRailScale ) { + if ( DrawTwoRails( &mainD, 1 ) ) { Translate( &p0, p, a-225, len2 ); Translate( &p1, p0, a, len3 ); Translate( &p2, p0, a+180, len3 ); @@ -393,16 +412,20 @@ EXPORT void SetAllTrackSelect( BOOL_T select ) selectedTrackCount = 0; trk = NULL; while ( TrackIterate( &trk ) ) { - if ((!select) || (GetLayerVisible( GetTrkLayer( trk )) && !GetLayerFrozen(GetTrkLayer( trk )) )) { - if (select) + if ((!select) || (GetLayerVisible( GetTrkLayer( trk )) + && !GetLayerFrozen(GetTrkLayer( trk )) )) { + if (select) { selectedTrackCount++; + } if ((GetTrkSelected(trk)!=0) != select) { - if (select) + if (select) { SetTrkBits( trk, TB_SELECTED ); - else + } else { ClrTrkBits( trk, TB_SELECTED ); - if (!doRedraw) + } + if (!doRedraw) { SetTrkBits( trk, TB_SELREDRAW ); + } DrawTrackAndEndPts( trk, wDrawColorBlack ); } } @@ -421,7 +444,7 @@ EXPORT void SetAllTrackSelect( BOOL_T select ) * \param none * \return none */ - + EXPORT void InvertTrackSelect( void * unused ) { track_p trk; @@ -429,11 +452,11 @@ EXPORT void InvertTrackSelect( void * unused ) trk = NULL; while ( TrackIterate( &trk ) ) { if (GetLayerVisible( GetTrkLayer( trk )) && - !GetLayerModule(GetTrkLayer( trk )) && !GetLayerFrozen(GetTrkLayer( trk )) ) { + !GetLayerModule(GetTrkLayer( trk )) && !GetLayerFrozen(GetTrkLayer( trk )) ) { SelectOneTrack( trk, GetTrkSelected(trk)==0 ); } } - + RedrawSelectedTracksBoundary(); SelectedTrackCountChange(); MainRedraw(); // InvertTrackSelect @@ -444,28 +467,30 @@ EXPORT void InvertTrackSelect( void * unused ) * \param none * \return none */ - + EXPORT void OrphanedTrackSelect( void *ptr ) { track_p trk; EPINX_T ep; int cnt ; - + trk = NULL; - + while( TrackIterate( &trk ) ) { cnt = 0; - if( GetLayerVisible( GetTrkLayer( trk ) && !GetLayerModule(GetTrkLayer(trk)) && !GetLayerFrozen(GetTrkLayer(trk)))) { + if( GetLayerVisible( GetTrkLayer( trk ) && !GetLayerModule(GetTrkLayer(trk)) + && !GetLayerFrozen(GetTrkLayer(trk)))) { for( ep = 0; ep < GetTrkEndPtCnt( trk ); ep++ ) { - if( GetTrkEndTrk( trk, ep ) ) - cnt++; + if( GetTrkEndTrk( trk, ep ) ) { + cnt++; + } } - + if( !cnt && GetTrkEndPtCnt( trk )) { SetTrkBits( trk, TB_SELECTED ); DrawTrackAndEndPts( trk, wDrawColorBlack ); - selectedTrackCount++; - } + selectedTrackCount++; + } } } RedrawSelectedTracksBoundary(); @@ -474,43 +499,45 @@ EXPORT void OrphanedTrackSelect( void *ptr ) } static void SelectOneTrack( - track_p trk, - wBool_t selected ) + track_p trk, + wBool_t selected ) { - BOOL_T bRedraw = (GetTrkSelected(trk) != 0) != selected; - if ( !bRedraw ) { - ClrTrkBits( trk, TB_SELREDRAW ); - return; - } - SetTrkBits( trk, TB_SELREDRAW ); - if (selected) { - SetTrkBits( trk, TB_SELECTED ); - selectedTrackCount++; - } else { - ClrTrkBits( trk, TB_SELECTED ); - selectedTrackCount--; - } - SelectedTrackCountChange(); + BOOL_T bRedraw = (GetTrkSelected(trk) != 0) != selected; + if ( !bRedraw ) { + ClrTrkBits( trk, TB_SELREDRAW ); + return; + } + SetTrkBits( trk, TB_SELREDRAW ); + if (selected) { + SetTrkBits( trk, TB_SELECTED ); + selectedTrackCount++; + } else { + ClrTrkBits( trk, TB_SELECTED ); + selectedTrackCount--; + } + SelectedTrackCountChange(); } EXPORT void HighlightSelectedTracks( - track_p trk_ignore, BOOL_T keep, BOOL_T invert ) + track_p trk_ignore, BOOL_T keep, BOOL_T invert ) { track_p trk = NULL; - if ( selectedTrackCount == 0 ) + if ( selectedTrackCount == 0 ) { return; + } while ( TrackIterate( &trk ) ) { - if (trk == trk_ignore) continue; - if(GetTrkSelected(trk)) { - if (!GetLayerVisible( GetTrkLayer( trk ))) continue; - if (keep) - DrawTrack(trk,&tempD,selectedColor); - else if (invert) - DrawTrack(trk,&tempD,wDrawColorPreviewUnselected); - else - DrawTrack(trk,&tempD,wDrawColorPreviewSelected ); - } + if (trk == trk_ignore) { continue; } + if(GetTrkSelected(trk)) { + if (!GetLayerVisible( GetTrkLayer( trk ))) { continue; } + if (keep) { + DrawTrack(trk,&tempD,selectedColor); + } else if (invert) { + DrawTrack(trk,&tempD,wDrawColorPreviewUnselected); + } else { + DrawTrack(trk,&tempD,wDrawColorPreviewSelected ); + } + } } } @@ -521,28 +548,31 @@ EXPORT void HighlightSelectedTracks( * Ignore Frozen Tracks */ static void SelectConnectedTracks( - track_p trk, BOOL_T display_only ) + track_p trk, BOOL_T display_only ) { track_p trk1; int inx; EPINX_T ep; - tlist_da.cnt = 0; + DYNARR_RESET( track_p, tlist_da ); TlistAppend( trk ); InfoCount( 0 ); - if (!display_only) wDrawDelayUpdate( mainD.d, FALSE ); + if (!display_only) { wDrawDelayUpdate( mainD.d, FALSE ); } for (inx=0; inx<tlist_da.cnt; inx++) { - if ( inx > 0 && (selectedTrackCount == 0) && !display_only ) + if ( inx > 0 && (selectedTrackCount == 0) && !display_only ) { return; + } trk = Tlist(inx); if (!GetLayerFrozen(GetTrkLayer(trk))) { if (inx!=0 && - GetTrkSelected(trk)) { - if (display_only) + GetTrkSelected(trk)) { + if (display_only) { DrawTrack(trk,&tempD,wDrawColorPreviewSelected ); + } continue; } else if (GetTrkSelected(trk)) { - if (display_only) + if (display_only) { DrawTrack(trk,&tempD,wDrawColorPreviewUnselected); + } continue; } } @@ -550,11 +580,11 @@ static void SelectConnectedTracks( trk1 = GetTrkEndTrk( trk, ep ); if (trk1 && !TListSearch(trk1) && GetLayerVisible( GetTrkLayer( trk1 ))) { if (GetTrkSelected(trk1)) { - if (display_only) DrawTrack(trk1,&tempD,wDrawColorPreviewSelected ); - } else TlistAppend( trk1 ); + if (display_only) { DrawTrack(trk1,&tempD,wDrawColorPreviewSelected ); } + } else { TlistAppend( trk1 ); } } } - if (display_only && !GetLayerFrozen(GetTrkLayer(trk))) DrawTrack(trk,&tempD,wDrawColorPreviewSelected ); + if (display_only && !GetLayerFrozen(GetTrkLayer(trk))) { DrawTrack(trk,&tempD,wDrawColorPreviewSelected ); } else if (!GetTrkSelected(trk)) { if (GetLayerModule(GetTrkLayer(trk))) { continue; @@ -575,44 +605,47 @@ static void SelectConnectedTracks( } typedef void (*doModuleTrackCallBack_t)(track_p, BOOL_T); -static int DoModuleTracks( int moduleLayer, doModuleTrackCallBack_t doit, BOOL_T val) +static int DoModuleTracks( int moduleLayer, doModuleTrackCallBack_t doit, + BOOL_T val) { track_p trk; trk = NULL; int cnt = 0; while ( TrackIterate( &trk ) ) { if (GetTrkLayer(trk) == moduleLayer) { - doit( trk, val ); - cnt++; + doit( trk, val ); + cnt++; } } return cnt; } -static void DrawSingleTrack(track_p trk, BOOL_T bit) { +static void DrawSingleTrack(track_p trk, BOOL_T bit) +{ DrawTrack(trk,&tempD,bit?wDrawColorPreviewSelected:wDrawColorPreviewUnselected); } typedef BOOL_T (*testSelectedTrackCallBack_t)(track_p, int); -static BOOL_T TestAllSelectedTracks( testSelectedTrackCallBack_t testit, int value) +static BOOL_T TestAllSelectedTracks( testSelectedTrackCallBack_t testit, + int value) { track_p trk; - trk = NULL; - while ( TrackIterate( &trk ) ) { - if (GetTrkSelected(trk)) { - if ( !testit( trk, value ) ) { - return FALSE; - } + trk = NULL; + while ( TrackIterate( &trk ) ) { + if (GetTrkSelected(trk)) { + if ( !testit( trk, value ) ) { + return FALSE; } } + } return TRUE; } typedef BOOL_T (*doSelectedTrackCallBack_t)(track_p, BOOL_T); -static void DoSelectedTracks( doSelectedTrackCallBack_t doit ) +EXPORT void DoSelectedTracks( doSelectedTrackCallBack_t doit ) { track_p trk; trk = NULL; @@ -645,8 +678,9 @@ static BOOL_T SelectedTracksAreFrozen( void ) EXPORT void SelectTrackWidth( void* width ) { track_p trk; - if (SelectedTracksAreFrozen()) + if (SelectedTracksAreFrozen()) { return; + } if (selectedTrackCount<=0) { ErrorMessage( MSG_NO_SELECTED_TRK ); return; @@ -670,8 +704,9 @@ static void SelectLineType( void* widthVP ) { int width = (int)VP2L(widthVP); track_p trk; - if (SelectedTracksAreFrozen()) + if (SelectedTracksAreFrozen()) { return; + } if (selectedTrackCount<=0) { ErrorMessage( MSG_NO_SELECTED_TRK ); return; @@ -682,11 +717,11 @@ static void SelectLineType( void* widthVP ) while ( TrackIterate( &trk ) ) { if (GetTrkSelected(trk)) { UndoModify( trk ); - if (QueryTrack(trk, Q_CAN_MODIFY_CONTROL_POINTS)) + if (QueryTrack(trk, Q_CAN_MODIFY_CONTROL_POINTS)) { SetBezierLineType(trk, width); - else if (QueryTrack(trk, Q_IS_DRAW)) + } else if (QueryTrack(trk, Q_IS_DRAW)) { SetLineType( trk, width ); - else if (QueryTrack(trk, Q_IS_STRUCTURE)) { + } else if (QueryTrack(trk, Q_IS_STRUCTURE)) { SetCompoundLineType(trk, width); } } @@ -707,13 +742,15 @@ EXPORT int SelectDelete( void ) } } - if (doingDouble || (GetCurrentCommand() == modifyCmdInx)) return 1; + if (doingDouble || (GetCurrentCommand() == modifyCmdInx)) { return 1; } - if (SelectedTracksAreFrozen()) + if (SelectedTracksAreFrozen()) { return 0; + } if (selectedTrackCount>0) { BOOL_T UndoStarted = FALSE; - if (!TestAllSelectedTracks(QueryTrack,(int)Q_ISTRAIN)) { // If all Cars, don't bother with UndoStart as there will be nothing to delete + if (!TestAllSelectedTracks(QueryTrack, + (int)Q_ISTRAIN)) { // If all Cars, don't bother with UndoStart as there will be nothing to delete UndoStarted = TRUE; UndoStart( _("Delete Tracks"), "delete" ); } @@ -725,8 +762,9 @@ EXPORT int SelectDelete( void ) wDrawDelayUpdate( mapD.d, FALSE ); selectedTrackCount = 0; SelectedTrackCountChange(); - if (UndoStarted) + if (UndoStarted) { UndoEnd(); + } } else { ErrorMessage( MSG_NO_SELECTED_TRK ); } @@ -736,7 +774,8 @@ EXPORT int SelectDelete( void ) /* * Called By Windows directly with Delete Key. We first try a simple Delete, and if that doesn't work saying "In Modify" we call Modify with a Text key for Delete */ -EXPORT void TrySelectDelete( void ) { +EXPORT void TrySelectDelete( void ) +{ if(SelectDelete() == 1) { CmdModify((C_TEXT+(int)(127<<8)),zero); } @@ -756,13 +795,15 @@ static BOOL_T FlipHidden( track_p trk, BOOL_T unused ) UndrawNewTrack( trk2 ); }*/ UndoModify( trk ); - if ( drawTunnel == 0 ) + if ( drawTunnel == 0 ) { flipHiddenDoSelectRecount = TRUE; + } if (GetTrkVisible(trk)) { ClrTrkBits( trk, TB_VISIBLE|(drawTunnel==0?(TB_SELECTED|TB_SELREDRAW):0) ); ClrTrkBits (trk, TB_BRIDGE); ClrTrkBits (trk, TB_NOTIES); -; } else { + ; + } else { SetTrkBits( trk, TB_VISIBLE ); } /*DrawNewTrack( trk );*/ @@ -787,6 +828,18 @@ static BOOL_T FlipBridge( track_p trk, BOOL_T unused ) return TRUE; } +static BOOL_T FlipRoadbed( track_p trk, BOOL_T unused ) +{ + UndoModify( trk ); + if (GetTrkRoadbed(trk)) { + ClrTrkBits( trk, TB_ROADBED ); + } else { + SetTrkBits( trk, TB_ROADBED ); + SetTrkBits( trk, TB_VISIBLE); + } + return TRUE; +} + static BOOL_T FlipTies( track_p trk, BOOL_T unused ) { UndoModify( trk ); @@ -801,8 +854,9 @@ static BOOL_T FlipTies( track_p trk, BOOL_T unused ) EXPORT void SelectTunnel( void * unused ) { - if (SelectedTracksAreFrozen()) + if (SelectedTracksAreFrozen()) { return; + } if (selectedTrackCount>0) { flipHiddenDoSelectRecount = FALSE; UndoStart( _("Hide Tracks (Tunnel)"), "tunnel" ); @@ -813,14 +867,16 @@ EXPORT void SelectTunnel( void * unused ) } else { ErrorMessage( MSG_NO_SELECTED_TRK ); } - if ( flipHiddenDoSelectRecount ) + if ( flipHiddenDoSelectRecount ) { SelectRecount(); + } } EXPORT void SelectBridge( void * unused ) { - if (SelectedTracksAreFrozen()) + if (SelectedTracksAreFrozen()) { return; + } if (selectedTrackCount>0) { flipHiddenDoSelectRecount = FALSE; UndoStart( _("Bridge Tracks "), "bridge" ); @@ -834,10 +890,29 @@ EXPORT void SelectBridge( void * unused ) MainRedraw(); // SelectBridge } +EXPORT void SelectRoadbed( void * unused ) +{ + if (SelectedTracksAreFrozen()) { + return; + } + if (selectedTrackCount>0) { + flipHiddenDoSelectRecount = FALSE; + UndoStart( _("Roadbed Tracks "), "roadbed" ); + wDrawDelayUpdate( mainD.d, TRUE ); + DoSelectedTracks( FlipRoadbed ); + wDrawDelayUpdate( mainD.d, FALSE ); + UndoEnd(); + } else { + ErrorMessage( MSG_NO_SELECTED_TRK ); + } + MainRedraw(); // SelectBridge +} + EXPORT void SelectTies( void * unused ) { - if (SelectedTracksAreFrozen()) + if (SelectedTracksAreFrozen()) { return; + } if (selectedTrackCount>0) { flipHiddenDoSelectRecount = FALSE; UndoStart( _("Ties Tracks "), "noties" ); @@ -874,22 +949,23 @@ static BOOL_T SetLayer( track_p trk, BOOL_T unused ) EXPORT void MoveSelectedTracksToCurrentLayer( void * unused ) { - if (SelectedTracksAreFrozen()) + if (SelectedTracksAreFrozen()) { return; - if (selectedTrackCount>0) { - UndoStart( _("Move To Current Layer"), "changeLayer" ); - DoSelectedTracks( SetLayer ); - UndoEnd(); - } else { - ErrorMessage( MSG_NO_SELECTED_TRK ); - } + } + if (selectedTrackCount>0) { + UndoStart( _("Move To Current Layer"), "changeLayer" ); + DoSelectedTracks( SetLayer ); + UndoEnd(); + } else { + ErrorMessage( MSG_NO_SELECTED_TRK ); + } } EXPORT void SelectCurrentLayer( void * unused ) { track_p trk; trk = NULL; - if (GetLayerFrozen(curLayer)) return; + if (GetLayerFrozen(curLayer)) { return; } while ( TrackIterate( &trk ) ) { if ((!GetTrkSelected(trk)) && GetTrkLayer(trk) == curLayer) { SelectOneTrack( trk, TRUE ); @@ -898,7 +974,8 @@ EXPORT void SelectCurrentLayer( void * unused ) RedrawSelectedTracksBoundary(); } -EXPORT void DeselectLayer( unsigned int layer ) { +EXPORT void DeselectLayer( unsigned int layer ) +{ track_p trk; trk = NULL; while ( TrackIterate( &trk ) ) { @@ -926,8 +1003,9 @@ static BOOL_T ClearElevation( track_p trk, BOOL_T unused ) EXPORT void ClearElevations( void * unused ) { - if (SelectedTracksAreFrozen()) + if (SelectedTracksAreFrozen()) { return; + } if (selectedTrackCount>0) { UndoStart( _("Clear Elevations"), "clear elevations" ); DoSelectedTracks( ClearElevation ); @@ -951,8 +1029,9 @@ static BOOL_T AddElevation( track_p trk, BOOL_T unused ) if ((trk1=GetTrkEndTrk(trk,ep))) { ep1 = GetEndPtConnectedToMe( trk1, trk ); if (ep1 >= 0) { - if (GetTrkSelected(trk1) && GetTrkIndex(trk1)<GetTrkIndex(trk)) + if (GetTrkSelected(trk1) && GetTrkIndex(trk1)<GetTrkIndex(trk)) { continue; + } } } if (EndPtIsDefinedElev(trk,ep)) { @@ -969,8 +1048,9 @@ static BOOL_T AddElevation( track_p trk, BOOL_T unused ) EXPORT void AddElevations( DIST_T delta ) { - if (SelectedTracksAreFrozen()) + if (SelectedTracksAreFrozen()) { return; + } if (selectedTrackCount>0) { elevDelta = delta; UndoStart( _("Add Elevations"), "add elevations" ); @@ -985,8 +1065,9 @@ EXPORT void AddElevations( DIST_T delta ) EXPORT void DoRefreshCompound( void * unused ) { - if (SelectedTracksAreFrozen()) + if (SelectedTracksAreFrozen()) { return; + } if (selectedTrackCount>0) { UndoStart( _("Refresh Compound"), "refresh compound" ); DoSelectedTracks( RefreshCompound ); @@ -1000,7 +1081,8 @@ EXPORT void DoRefreshCompound( void * unused ) static drawCmd_t tempSegsD = { - NULL, &tempSegDrawFuncs, 0, 1, 0.0, {0.0, 0.0}, {0.0, 0.0}, Pix2CoOrd, CoOrd2Pix }; + NULL, &tempSegDrawFuncs, 0, 1, 0.0, {0.0, 0.0}, {0.0, 0.0}, Pix2CoOrd, CoOrd2Pix +}; EXPORT void WriteSelectedTracksToTempSegs( void ) { track_p trk; @@ -1008,8 +1090,9 @@ EXPORT void WriteSelectedTracksToTempSegs( void ) tempSegsD.dpi = mainD.dpi; for ( trk=NULL; TrackIterate(&trk); ) { if ( GetTrkSelected( trk ) ) { - if ( IsTrack( trk ) ) + if ( IsTrack( trk ) ) { continue; + } ClrTrkBits( trk, TB_SELECTED ); DrawTrack( trk, &tempSegsD, wDrawColorBlack ); SetTrkBits( trk, TB_SELECTED ); @@ -1017,260 +1100,6 @@ EXPORT void WriteSelectedTracksToTempSegs( void ) } } -static char rescaleFromScale[20]; -static char rescaleFromGauge[20]; - -static char * rescaleToggleLabels[] = { N_("Scale"), N_("Ratio"), NULL }; -static long rescaleMode; -static wIndex_t rescaleFromScaleInx; -static wIndex_t rescaleFromGaugeInx; -static wIndex_t rescaleToScaleInx; -static wIndex_t rescaleToGaugeInx; -static wIndex_t rescaleToInx; -static long rescaleNoChangeDim = FALSE; -static FLOAT_T rescalePercent; -static char * rescaleChangeDimLabels[] = { N_("Do not resize track"), NULL }; -static paramFloatRange_t r0o001_10000 = { 0.001, 10000.0 }; -static paramData_t rescalePLs[] = { -#define I_RESCALE_MODE (0) - { PD_RADIO, &rescaleMode, "toggle", PDO_NOPREF, &rescaleToggleLabels, N_("Rescale by:"), BC_HORZ|BC_NOBORDER }, -#define I_RESCALE_FROM_SCALE (1) - { PD_STRING, rescaleFromScale, "fromS", PDO_NOPREF|PDO_STRINGLIMITLENGTH, I2VP(100), N_("From:"),0, 0, sizeof(rescaleFromScale)}, -#define I_RESCALE_FROM_GAUGE (2) - { PD_STRING, rescaleFromGauge, "fromG", PDO_NOPREF|PDO_DLGHORZ | PDO_STRINGLIMITLENGTH, I2VP(100), " / ", 0, 0, sizeof(rescaleFromGauge)}, -#define I_RESCALE_TO_SCALE (3) - { PD_DROPLIST, &rescaleToScaleInx, "toS", PDO_NOPREF|PDO_LISTINDEX, I2VP(100), N_("To: ") }, -#define I_RESCALE_TO_GAUGE (4) - { PD_DROPLIST, &rescaleToGaugeInx, "toG", PDO_NOPREF|PDO_LISTINDEX|PDO_DLGHORZ, NULL, " / " }, -#define I_RESCALE_CHANGE (5) - { PD_TOGGLE, &rescaleNoChangeDim, "change-dim", 0, &rescaleChangeDimLabels, "", BC_HORZ|BC_NOBORDER }, -#define I_RESCALE_PERCENT (6) - { PD_FLOAT, &rescalePercent, "ratio", 0, &r0o001_10000, N_("Ratio") }, - { PD_MESSAGE, "%", NULL, PDO_DLGHORZ } }; -static paramGroup_t rescalePG = { "rescale", 0, rescalePLs, COUNT( rescalePLs ) }; - - -static long getboundsCount; -static coOrd getboundsLo, getboundsHi; - -static BOOL_T GetboundsDoIt( track_p trk, BOOL_T unused ) -{ - coOrd hi, lo; - - GetBoundingBox( trk, &hi, &lo ); - if ( getboundsCount == 0 ) { - getboundsLo = lo; - getboundsHi = hi; - } else { - if ( lo.x < getboundsLo.x ) getboundsLo.x = lo.x; - if ( lo.y < getboundsLo.y ) getboundsLo.y = lo.y; - if ( hi.x > getboundsHi.x ) getboundsHi.x = hi.x; - if ( hi.y > getboundsHi.y ) getboundsHi.y = hi.y; - } - getboundsCount++; - return TRUE; -} - -static coOrd rescaleShift; -static BOOL_T RescaleDoIt( track_p trk, BOOL_T unused ) -{ - EPINX_T ep, ep1; - track_p trk1; - UndrawNewTrack( trk ); - UndoModify(trk); - if ( rescalePercent != 100.0 ) { - for (ep=0; ep<GetTrkEndPtCnt(trk); ep++) { - if ((trk1 = GetTrkEndTrk(trk,ep)) != NULL && - !GetTrkSelected(trk1)) { - ep1 = GetEndPtConnectedToMe( trk1, trk ); - DisconnectTracks( trk, ep, trk1, ep1 ); - } - } - /* should the track dimensions ie. length or radius be changed as well? */ - if( rescaleNoChangeDim == 0 ) - RescaleTrack( trk, rescalePercent/100.0, rescaleShift ); - } - - if ( rescaleMode==0 ) - SetTrkScale( trk, rescaleToInx ); - getboundsCount++; - DrawNewTrack( trk ); - return TRUE; -} - - -static void RescaleDlgOk( - void * unused ) -{ - coOrd center, size; - DIST_T d; - FLOAT_T ratio = rescalePercent/100.0; - - UndoStart( _("Rescale Tracks"), "Rescale" ); - getboundsCount = 0; - DoSelectedTracks( GetboundsDoIt ); - center.x = (getboundsLo.x+getboundsHi.x)/2.0; - center.y = (getboundsLo.y+getboundsHi.y)/2.0; - size.x = (getboundsHi.x-getboundsLo.x)/2.0*ratio; - size.y = (getboundsHi.y-getboundsLo.y)/2.0*ratio; - getboundsLo.x = center.x - size.x; - getboundsLo.y = center.y - size.y; - getboundsHi.x = center.x + size.x; - getboundsHi.y = center.y + size.y; - if ( getboundsLo.x < 0 ) { - getboundsHi.x -= getboundsLo.x; - getboundsLo.x = 0; - } else if ( getboundsHi.x > mapD.size.x ) { - d = getboundsHi.x - mapD.size.x; - if ( getboundsLo.x < d ) - d = getboundsLo.x; - getboundsHi.x -= d; - getboundsLo.x -= d; - } - if ( getboundsLo.y < 0 ) { - getboundsHi.y -= getboundsLo.y; - getboundsLo.y = 0; - } else if ( getboundsHi.y > mapD.size.y ) { - d = getboundsHi.y - mapD.size.y; - if ( getboundsLo.y < d ) - d = getboundsLo.y; - getboundsHi.y -= d; - getboundsLo.y -= d; - } - if ( rescaleNoChangeDim == 0 && - (getboundsHi.x > mapD.size.x || - getboundsHi.y > mapD.size.y )) { - NoticeMessage( MSG_RESCALE_TOO_BIG, _("Ok"), NULL, FormatDistance(getboundsHi.x), FormatDistance(getboundsHi.y) ); - } - rescaleShift.x = (getboundsLo.x+getboundsHi.x)/2.0 - center.x*ratio; - rescaleShift.y = (getboundsLo.y+getboundsHi.y)/2.0 - center.y*ratio; - - rescaleToInx = GetScaleInx( rescaleToScaleInx, rescaleToGaugeInx ); - DoSelectedTracks( RescaleDoIt ); - - // rescale the background if it exists and the layout is resized - if (HasBackGround() && ratio != 1.0) { - coOrd pos = GetLayoutBackGroundPos(); - double size = GetLayoutBackGroundSize(); - pos.x = ratio * pos.x + rescaleShift.x; - pos.y = ratio * pos.y + rescaleShift.y; - SetLayoutBackGroundPos(pos); - - size *= ratio; - SetLayoutBackGroundSize(size); - } - DoRedraw(); - wHide( rescalePG.win ); -} - - -static void RescaleDlgUpdate( - paramGroup_p pg, - int inx, - void * valueP ) -{ - switch (inx) { - case I_RESCALE_MODE: - wControlShow( pg->paramPtr[I_RESCALE_FROM_SCALE].control, rescaleMode==0 ); - wControlActive( pg->paramPtr[I_RESCALE_FROM_SCALE].control, FALSE ); - wControlShow( pg->paramPtr[I_RESCALE_TO_SCALE].control, rescaleMode==0 ); - wControlShow( pg->paramPtr[I_RESCALE_FROM_GAUGE].control, rescaleMode==0 ); - wControlActive( pg->paramPtr[I_RESCALE_FROM_GAUGE].control, FALSE ); - wControlShow( pg->paramPtr[I_RESCALE_TO_GAUGE].control, rescaleMode==0 ); - wControlShow( pg->paramPtr[I_RESCALE_CHANGE].control, rescaleMode==0 ); - wControlActive( pg->paramPtr[I_RESCALE_PERCENT].control, rescaleMode==1 ); - if ( rescaleMode!=0 ) - break; - case I_RESCALE_TO_SCALE: - LoadGaugeList( (wList_p)rescalePLs[I_RESCALE_TO_GAUGE].control, *((int *)valueP) ); - rescaleToGaugeInx = 0; - ParamLoadControl( pg, I_RESCALE_TO_GAUGE ); - ParamLoadControl( pg, I_RESCALE_TO_SCALE ); - rescalePercent = GetScaleDescRatio(rescaleFromScaleInx)/GetScaleDescRatio(rescaleToScaleInx)*100.0; - wControlActive( pg->paramPtr[I_RESCALE_CHANGE].control, (rescaleFromScaleInx != rescaleToScaleInx) ); - ParamLoadControl( pg, I_RESCALE_PERCENT ); - break; - case I_RESCALE_TO_GAUGE: - ParamLoadControl( pg, I_RESCALE_TO_GAUGE ); - break; - case I_RESCALE_FROM_SCALE: - ParamLoadControl( pg, I_RESCALE_FROM_SCALE ); - break; - case I_RESCALE_FROM_GAUGE: - ParamLoadControl( pg, I_RESCALE_FROM_GAUGE ); - break; - case I_RESCALE_CHANGE: - ParamLoadControl( pg, I_RESCALE_CHANGE ); - break; - case -1: - break; - } - ParamDialogOkActive( pg, rescalePercent!=100.0 || rescaleFromGaugeInx != rescaleToGaugeInx ); -} - -/** - * Get the scale gauge information for the selected track pieces. - * FIXME: special cases like tracks pieces with different gauges or scale need to be handled - * - * \param IN trk track element - * \param IN unused - * \return TRUE; - */ - -static BOOL_T SelectedScaleGauge( track_p trk, BOOL_T unused ) -{ - char *scaleName; - SCALEINX_T scale; - SCALEDESCINX_T scaleInx; - GAUGEINX_T gaugeInx; - - scale = GetTrkScale( trk ); - scaleName = GetScaleName( scale ); - if( strcmp( scaleName, "*" )) { - GetScaleGauge( scale, &scaleInx, &gaugeInx ); - strcpy( rescaleFromScale,GetScaleDesc( scaleInx )); - strcpy( rescaleFromGauge, GetGaugeDesc( scaleInx, gaugeInx )); - - rescaleFromScaleInx = scaleInx; - rescaleFromGaugeInx = gaugeInx; - rescaleToScaleInx = scaleInx; - rescaleToGaugeInx = gaugeInx; - } - - return TRUE; -} - -/** - * Bring up the rescale dialog. The dialog for rescaling the selected pieces - * of track is created if necessary and shown. Handling of user input is done via - * RescaleDlgUpdate() - */ - -EXPORT void DoRescale( void * unused ) -{ - if ( rescalePG.win == NULL ) { - ParamCreateDialog( &rescalePG, MakeWindowTitle(_("Rescale")), _("Ok"), RescaleDlgOk, wHide, TRUE, NULL, F_BLOCK, RescaleDlgUpdate ); - LoadScaleList( (wList_p)rescalePLs[I_RESCALE_TO_SCALE].control ); - LoadGaugeList( (wList_p)rescalePLs[I_RESCALE_TO_GAUGE].control, GetLayoutCurScaleDesc() ); /* set correct gauge list here */ - rescaleFromScaleInx = GetLayoutCurScale(); - rescaleToScaleInx = rescaleFromScaleInx; - rescalePercent = 100.0; - } - - DoSelectedTracks( SelectedScaleGauge ); - - RescaleDlgUpdate( &rescalePG, I_RESCALE_MODE, &rescaleMode ); - RescaleDlgUpdate( &rescalePG, I_RESCALE_CHANGE, &rescaleMode ); - - RescaleDlgUpdate( &rescalePG, I_RESCALE_FROM_GAUGE, rescaleFromGauge ); - RescaleDlgUpdate( &rescalePG, I_RESCALE_FROM_SCALE, rescaleFromScale ); - - RescaleDlgUpdate( &rescalePG, I_RESCALE_TO_SCALE, &rescaleToScaleInx ); - RescaleDlgUpdate( &rescalePG, I_RESCALE_TO_GAUGE, &rescaleToGaugeInx ); - - wShow( rescalePG.win ); -} - static void DrawSelectedTracksD( drawCmd_p d, wDrawColor color ) { @@ -1282,31 +1111,35 @@ static void DrawSelectedTracksD( drawCmd_p d, wDrawColor color ) trk = Tlist(inx); if (d != &mapD) { GetBoundingBox( trk, &hi, &lo ); - if ( OFF_D( d->orig, d->size, lo, hi ) ) + if ( OFF_D( d->orig, d->size, lo, hi ) ) { continue; + } } - if (color != wDrawColorWhite) + if (color != wDrawColorWhite) { ClrTrkBits(trk, TB_UNDRAWN); - if (color == wDrawColorWhite) + } + if (color == wDrawColorWhite) { SetTrkBits( trk, TB_UNDRAWN ); + } } MainRedraw(); //Omitting all the tracks with TB_UNDRAWN set /*wDrawDelayUpdate( d->d, FALSE );*/ } static BOOL_T AddSelectedTrack( - track_p trk, BOOL_T unused ) + track_p trk, BOOL_T unused ) { DYNARR_APPEND( track_p, tlist_da, 10 ); DYNARR_LAST( track_p, tlist_da ) = trk; return TRUE; } -static BOOL_T RemoveSelectedTrack(track_p trk) { +static BOOL_T RemoveSelectedTrack(track_p trk) +{ - for(int i=0;i<tlist_da.cnt; i++) { + for(int i=0; i<tlist_da.cnt; i++) { if (DYNARR_N(track_p,tlist_da,i) == trk) { - for (int j=i;j<tlist_da.cnt-1;j++) { + for (int j=i; j<tlist_da.cnt-1; j++) { DYNARR_N(track_p,tlist_da,j) = DYNARR_N(track_p,tlist_da,j+1); } tlist_da.cnt--; @@ -1316,13 +1149,43 @@ static BOOL_T RemoveSelectedTrack(track_p trk) { return FALSE; } +static long getSelectedBoundsCount; +static coOrd getSelectedBoundsLo, getSelectedBoundsHi; + +static BOOL_T GetBoundsDoIt( track_p trk, BOOL_T unused ) +{ + coOrd hi, lo; + + GetBoundingBox( trk, &hi, &lo ); + if ( getSelectedBoundsCount == 0 ) { + getSelectedBoundsLo = lo; + getSelectedBoundsHi = hi; + } else { + if ( lo.x < getSelectedBoundsLo.x ) { getSelectedBoundsLo.x = lo.x; } + if ( lo.y < getSelectedBoundsLo.y ) { getSelectedBoundsLo.y = lo.y; } + if ( hi.x > getSelectedBoundsHi.x ) { getSelectedBoundsHi.x = hi.x; } + if ( hi.y > getSelectedBoundsHi.y ) { getSelectedBoundsHi.y = hi.y; } + } + getSelectedBoundsCount++; + return TRUE; +} + +EXPORT void GetSelectedBounds( coOrd * low, coOrd * high ) +{ + getSelectedBoundsCount = 0; + DoSelectedTracks( GetBoundsDoIt ); + *low = getSelectedBoundsLo; + *high = getSelectedBoundsHi; +} + static coOrd moveOrig; static ANGLE_T moveAngle; static coOrd moveD_hi, moveD_lo; static drawCmd_t moveD = { - NULL, &tempSegDrawFuncs, DC_SIMPLE, 1, 0.0, {0.0, 0.0}, {0.0, 0.0}, Pix2CoOrd, CoOrd2Pix }; + NULL, &tempSegDrawFuncs, DC_SIMPLE, 1, 0.0, {0.0, 0.0}, {0.0, 0.0}, Pix2CoOrd, CoOrd2Pix +}; @@ -1347,12 +1210,13 @@ static void AccumulateTracks( void ) if (trk) { GetBoundingBox( trk, &hi, &lo ); if (lo.x <= moveD_hi.x && hi.x >= moveD_lo.x && - lo.y <= moveD_hi.y && hi.y >= moveD_lo.y ) { - if (!QueryTrack(trk,Q_IS_CORNU)) - DrawTrack( trk, &moveD, wDrawColorBlack ); + lo.y <= moveD_hi.y && hi.y >= moveD_lo.y ) { + if (!QueryTrack(trk,Q_IS_CORNU)) { + DrawTrack( trk, &moveD, wDrawColorBlack ); } - movedCnt++; } + movedCnt++; + } } InfoCount( movedCnt ); /*wDrawDelayUpdate( moveD.d, FALSE );*/ @@ -1360,13 +1224,15 @@ static void AccumulateTracks( void ) static dynArr_t auto_select_da; -static void AddEndCornus() { - for (int i=0;i<tlist_da.cnt;i++) { +static void AddEndCornus() +{ + for (int i=0; i<tlist_da.cnt; i++) { track_p trk = DYNARR_N(track_p,tlist_da,i); track_p tc; - for (int j=GetTrkEndPtCnt(trk)-1;j>=0;j--) { + for (int j=GetTrkEndPtCnt(trk)-1; j>=0; j--) { tc = GetTrkEndTrk(trk,j); - if (tc && !GetTrkSelected(tc) && QueryTrack(tc,Q_IS_CORNU) && !QueryTrack(trk,Q_IS_CORNU)) { //On end and cornu + if (tc && !GetTrkSelected(tc) && QueryTrack(tc,Q_IS_CORNU) + && !QueryTrack(trk,Q_IS_CORNU)) { //On end and cornu SelectOneTrack( tc, TRUE ); DYNARR_APPEND(track_p,tlist_da,1); //Add to selected list DYNARR_LAST(track_p,tlist_da) = tc; @@ -1377,9 +1243,10 @@ static void AddEndCornus() { } } -static void RemoveEndCornus() { +static void RemoveEndCornus() +{ track_p tc; - for (int i=0;i<auto_select_da.cnt;i++) { + for (int i=0; i<auto_select_da.cnt; i++) { tc = DYNARR_N(track_p,auto_select_da,i); SelectOneTrack( tc, FALSE ); RemoveSelectedTrack(tc); @@ -1435,16 +1302,20 @@ static void SetMoveD( BOOL_T moveB, coOrd orig, ANGLE_T angle ) moveD_hi = mainD.orig; Rotate( &moveD_hi, orig, -angle ); moveD_lo = moveD_hi; - for (inx=0;inx<3;inx++) { + for (inx=0; inx<3; inx++) { Rotate( &corner[inx], orig, -angle ); - if (corner[inx].x < moveD_lo.x) + if (corner[inx].x < moveD_lo.x) { moveD_lo.x = corner[inx].x; - if (corner[inx].y < moveD_lo.y) + } + if (corner[inx].y < moveD_lo.y) { moveD_lo.y = corner[inx].y; - if (corner[inx].x > moveD_hi.x) + } + if (corner[inx].x > moveD_hi.x) { moveD_hi.x = corner[inx].x; - if (corner[inx].y > moveD_hi.y) + } + if (corner[inx].y > moveD_hi.y) { moveD_hi.y = corner[inx].y; + } } } AccumulateTracks(); @@ -1456,9 +1327,10 @@ static void DrawMovedTracks( void ) int inx; track_p trk; dynArr_t cornu_segs; + DYNARR_INIT( trkSeg_t, cornu_segs ); - DrawSegs( &tempD, moveOrig, moveAngle, &tempSegs(0), tempSegs_da.cnt, - 0.0, selectedColor ); + DrawSegsDA( &tempD, NULL, moveOrig, moveAngle, &tempSegs_da, 0.0, selectedColor, + 0 ); for ( inx=0; inx<tlist_da.cnt; inx++ ) { trk = Tlist(inx); @@ -1470,13 +1342,13 @@ static void DrawMovedTracks( void ) coOrd center[2]; trackParams_t trackParams; if (GetTrackParams(PARAMS_CORNU, trk, zero, &trackParams)) { - for (int i=0;i<2;i++) { + for (int i=0; i<2; i++) { pos[i] = trackParams.cornuEnd[i]; center[i] = trackParams.cornuCenter[i]; angle[i] = trackParams.cornuAngle[i]; radius[i] = trackParams.cornuRadius[i]; if (!GetTrkEndTrk(trk,i) || - (GetTrkEndTrk(trk,i) && GetTrkSelected(GetTrkEndTrk(trk,i)))) { + (GetTrkEndTrk(trk,i) && GetTrkSelected(GetTrkEndTrk(trk,i)))) { if (!move0B) { Rotate( &pos[i], zero, moveAngle ); Rotate( ¢er[i],zero, moveAngle ); @@ -1489,10 +1361,8 @@ static void DrawMovedTracks( void ) } } CallCornu0(&pos[0],¢er[0],&angle[0],&radius[0],&cornu_segs, FALSE); - trkSeg_p cornu_p = &DYNARR_N(trkSeg_t,cornu_segs,0); - - DrawSegsO(&tempD, trk, zero, 0.0, cornu_p,cornu_segs.cnt, - GetTrkGauge(trk), selectedColor, DTS_LEFT|DTS_RIGHT ); + DrawSegsDA(&tempD, trk, zero, 0.0, &cornu_segs, + GetTrkGauge(trk), selectedColor, DTS_LEFT|DTS_RIGHT ); } } @@ -1504,13 +1374,13 @@ static void DrawMovedTracks( void ) static void MoveTracks( - BOOL_T eraseFirst, - BOOL_T move, - BOOL_T rotate, - coOrd base, - coOrd orig, - ANGLE_T angle, - BOOL_T undo) + BOOL_T eraseFirst, + BOOL_T move, + BOOL_T rotate, + coOrd base, + coOrd orig, + ANGLE_T angle, + BOOL_T undo) { track_p trk, trk1; EPINX_T ep, ep1; @@ -1530,21 +1400,23 @@ static void MoveTracks( } //Do non-Cornu first to establish new end-points for ( inx=0; inx<tlist_da.cnt; inx++ ) { - trk = Tlist(inx); - UndoModify( trk ); - if (QueryTrack(trk, Q_IS_CORNU)) continue; - if (move) - MoveTrack( trk, base ); - if (rotate) - RotateTrack( trk, orig, angle ); - for (ep=0; ep<GetTrkEndPtCnt(trk); ep++) { - if ((trk1 = GetTrkEndTrk(trk,ep)) != NULL && - !GetTrkSelected(trk1)) { - ep1 = GetEndPtConnectedToMe( trk1, trk ); - DisconnectTracks( trk, ep, trk1, ep1 ); - DrawEndPt( &mainD, trk1, ep1, wDrawColorBlack ); - } + trk = Tlist(inx); + UndoModify( trk ); + if (QueryTrack(trk, Q_IS_CORNU)) { continue; } + if (move) { + MoveTrack( trk, base ); + } + if (rotate) { + RotateTrack( trk, orig, angle ); + } + for (ep=0; ep<GetTrkEndPtCnt(trk); ep++) { + if ((trk1 = GetTrkEndTrk(trk,ep)) != NULL && + !GetTrkSelected(trk1)) { + ep1 = GetEndPtConnectedToMe( trk1, trk ); + DisconnectTracks( trk, ep, trk1, ep1 ); + DrawEndPt( &mainD, trk1, ep1, wDrawColorBlack ); } + } } //Now do the just Cornus - to reset to where the fixed parts ended up for ( inx=0; inx<tlist_da.cnt; inx++ ) { @@ -1552,28 +1424,30 @@ static void MoveTracks( UndoModify( trk ); BOOL_T fixed_end; fixed_end = FALSE; - if (!QueryTrack(trk, Q_IS_CORNU)) continue; - for (int i=0;i<2;i++) { + if (!QueryTrack(trk, Q_IS_CORNU)) { continue; } + for (int i=0; i<2; i++) { track_p te; if ((te = GetTrkEndTrk(trk,i)) && !GetTrkSelected(te)) { fixed_end = TRUE; } } - if (!fixed_end) { - if (move) + if (!fixed_end) { + if (move) { MoveTrack( trk, base ); - if (rotate) + } + if (rotate) { RotateTrack( trk, orig, angle ); + } for (ep=0; ep<GetTrkEndPtCnt(trk); ep++) { if ((trk1 = GetTrkEndTrk(trk,ep)) != NULL && - !GetTrkSelected(trk1)) { + !GetTrkSelected(trk1)) { ep1 = GetEndPtConnectedToMe( trk1, trk ); DisconnectTracks( trk, ep, trk1, ep1 ); DrawEndPt( &mainD, trk1, ep1, wDrawColorBlack ); } } - } else { - for (int i=0;i<2;i++) { + } else { + for (int i=0; i<2; i++) { if ((trk1 = GetTrkEndTrk(trk,i)) && GetTrkSelected(trk1)) { ep1 = GetEndPtConnectedToMe( trk1, trk ); DisconnectTracks(trk,i,trk1,ep1); @@ -1610,7 +1484,8 @@ static void MoveTracks( end_center = trackParms.cornuCenter[i]; end_center.x += base.x; end_center.y += base.y; - SetCornuEndPt(trk,i,end_pos,end_center,trackParms.cornuAngle[i],trackParms.cornuRadius[i]); + SetCornuEndPt(trk,i,end_pos,end_center,trackParms.cornuAngle[i], + trackParms.cornuRadius[i]); } if (rotate) { coOrd end_pos, end_center; @@ -1626,7 +1501,7 @@ static void MoveTracks( DrawTrack(trk,&mapD,wDrawColorBlack); } } - } + } InfoCount( inx ); } @@ -1634,52 +1509,62 @@ static void MoveTracks( ClrAllTrkBits(TB_UNDRAWN); DoRedraw(); wSetCursor( mainD.d, defaultCursor ); - if (undo) UndoEnd(); + if (undo) { UndoEnd(); } InfoCount( trackCount ); } - void MoveToJoin( - track_p trk0, - EPINX_T ep0, - track_p trk1, - EPINX_T ep1 ) + track_p trk0, + EPINX_T ep0, + track_p trk1, + EPINX_T ep1 ) { coOrd orig; coOrd base; ANGLE_T angle; - UndoStart( _("Move To Join"), "Move To Join" ); - base = GetTrkEndPos(trk0,ep0); - orig = GetTrkEndPos(trk1, ep1 ); - base.x = orig.x - base.x; - base.y = orig.y - base.y; - angle = GetTrkEndAngle(trk1,ep1); - angle -= GetTrkEndAngle(trk0,ep0); - angle += 180.0; - angle = NormalizeAngle( angle ); - GetMovedTracks( FALSE ); - MoveTracks( TRUE, TRUE, TRUE, base, orig, angle, TRUE ); - UndrawNewTrack( trk0 ); - UndrawNewTrack( trk1 ); - ConnectTracks( trk0, ep0, trk1, ep1 ); - DrawNewTrack( trk0 ); - DrawNewTrack( trk1 ); - RemoveEndCornus(); + UndoStart(_("Move To Join"), "Move To Join"); + base = GetTrkEndPos(trk0, ep0); + orig = GetTrkEndPos(trk1, ep1); + base.x = orig.x - base.x; + base.y = orig.y - base.y; + angle = GetTrkEndAngle(trk1, ep1); + angle -= GetTrkEndAngle(trk0, ep0); + angle += 180.0; + angle = NormalizeAngle(angle); + GetMovedTracks(FALSE); + MoveTracks(TRUE, TRUE, TRUE, base, orig, angle, TRUE); + UndrawNewTrack( trk0 ); + UndrawNewTrack( trk1 ); + ConnectTracks( trk0, ep0, trk1, ep1 ); + DrawNewTrack( trk0 ); + DrawNewTrack( trk1 ); + RemoveEndCornus(); + + track_p trk = NULL; + while (TrackIterate(&trk)) { + if (GetTrkSelected(trk)) { + ConnectAllEndPts(trk); + } + } } -void FreeTempStrings() { +void FreeTempStrings() +{ for (int i = 0; i<tempSegs_da.cnt; i++) { if (tempSegs(i).type == SEG_TEXT) { - if (tempSegs(i).u.t.string) + if (tempSegs(i).u.t.string) { MyFree(tempSegs(i).u.t.string); + } tempSegs(i).u.t.string = NULL; } } } -wBool_t FindEndIntersection(coOrd base, coOrd orig, ANGLE_T angle, track_p * t1, EPINX_T * ep1, track_p * t2, EPINX_T * ep2) { +wBool_t FindEndIntersection(coOrd base, coOrd orig, ANGLE_T angle, track_p * t1, + EPINX_T * ep1, track_p * t2, EPINX_T * ep2) +{ *ep1 = -1; *ep2 = -1; *t1 = NULL; @@ -1689,13 +1574,13 @@ wBool_t FindEndIntersection(coOrd base, coOrd orig, ANGLE_T angle, track_p * t1, for (int i=0; i<GetTrkEndPtCnt(ts); i++) { //All EndPoints track_p ct; if ((ct = GetTrkEndTrk(ts,i))!=NULL) { - if (GetTrkSelected(ct) || QueryTrack(ts,Q_IS_CORNU)) continue; // Another selected track or Cornu - ignore + if (GetTrkSelected(ct) || QueryTrack(ts,Q_IS_CORNU)) { continue; } // Another selected track or Cornu - ignore } coOrd pos1 = GetTrkEndPos(ts,i); - if (angle != 0.0) + if (angle != 0.0) { Rotate(&pos1,orig,angle); - else { + } else { pos1.x +=base.x; pos1.y +=base.y; } @@ -1703,7 +1588,7 @@ wBool_t FindEndIntersection(coOrd base, coOrd orig, ANGLE_T angle, track_p * t1, pos2 = pos1; track_p tt; if ((tt=OnTrackIgnore(&pos2,FALSE,TRUE,ts))!=NULL) { - if (GetTrkGauge(ts) != GetTrkGauge(tt)) continue; //Ignore if different gauges + if (GetTrkGauge(ts) != GetTrkGauge(tt)) { continue; } //Ignore if different gauges if (!GetTrkSelected(tt)) { //Ignore if new track is selected EPINX_T epp = PickUnconnectedEndPointSilent(pos2, tt); if (epp>=0) { @@ -1719,7 +1604,8 @@ wBool_t FindEndIntersection(coOrd base, coOrd orig, ANGLE_T angle, track_p * t1, epp = PickEndPoint(pos2,tt); //Any close end point (even joined) if (epp>=0) { ct = GetTrkEndTrk(tt,epp); - if (ct && GetTrkSelected(ct)) { //Point is junction to selected track - so will be broken + if (ct && GetTrkSelected( + ct)) { //Point is junction to selected track - so will be broken DIST_T d = FindDistance(pos1,GetTrkEndPos(tt,epp)); if (IsClose(d)) { *ep1 = epp; @@ -1738,14 +1624,15 @@ wBool_t FindEndIntersection(coOrd base, coOrd orig, ANGLE_T angle, track_p * t1, return FALSE; } -void DrawHighlightLayer(int layer) { +void DrawHighlightLayer(int layer) +{ track_p ts = NULL; BOOL_T initial = TRUE; coOrd layer_hi = zero,layer_lo = zero; while ( TrackIterate( &ts ) ) { - if ( !GetLayerVisible( GetTrkLayer( ts))) continue; - if (!GetTrkSelected(ts)) continue; - if (GetTrkLayer(ts) != layer) continue; + if ( !GetLayerVisible( GetTrkLayer( ts))) { continue; } + if (!GetTrkSelected(ts)) { continue; } + if (GetTrkLayer(ts) != layer) { continue; } coOrd hi,lo; GetBoundingBox(ts, &hi, &lo); if (initial) { @@ -1753,10 +1640,10 @@ void DrawHighlightLayer(int layer) { layer_lo = lo; initial = FALSE; } else { - if (layer_hi.x < hi.x ) layer_hi.x = hi.x; - if (layer_hi.y < hi.y ) layer_hi.y = hi.y; - if (layer_lo.x > lo.x ) layer_lo.x = lo.x; - if (layer_lo.y > lo.y ) layer_lo.y = lo.y; + if (layer_hi.x < hi.x ) { layer_hi.x = hi.x; } + if (layer_hi.y < hi.y ) { layer_hi.y = hi.y; } + if (layer_lo.x > lo.x ) { layer_lo.x = lo.x; } + if (layer_lo.y > lo.y ) { layer_lo.y = lo.y; } } } wDrawPix_t margin = (10.5*mainD.scale/mainD.dpi); @@ -1777,7 +1664,8 @@ void DrawHighlightLayer(int layer) { DrawPoly(&tempD,4,rect,type,wDrawColorPowderedBlue,wDrawLineDash,DRAW_CLOSED); } -void SetUpMenu2(coOrd pos, track_p trk) { +void SetUpMenu2(coOrd pos, track_p trk) +{ wMenuPushEnable( menuPushModify,FALSE); wMenuPushEnable(descriptionMI,FALSE); wMenuPushEnable( rotateAlignMI, FALSE ); @@ -1785,12 +1673,13 @@ void SetUpMenu2(coOrd pos, track_p trk) { wMenuPushEnable( bridgeMI, FALSE ); wMenuPushEnable( tiesMI, FALSE ); if ((trk) && - QueryTrack(trk,Q_CAN_ADD_ENDPOINTS)) { //Turntable snap to center if within 1/4 radius + QueryTrack(trk, + Q_CAN_ADD_ENDPOINTS)) { //Turntable snap to center if within 1/4 radius trackParams_t trackParams; if (GetTrackParams(PARAMS_CORNU, trk, pos, &trackParams)) { DIST_T dist = FindDistance(pos, trackParams.ttcenter); if (dist < trackParams.ttradius/4) { - cmdMenuPos = trackParams.ttcenter; + cmdMenuPos = trackParams.ttcenter; } } } @@ -1801,24 +1690,25 @@ void SetUpMenu2(coOrd pos, track_p trk) { } if (trk) { wMenuPushEnable( menuPushModify, - (QueryTrack( trk, Q_CAN_MODIFY_CONTROL_POINTS ) || - QueryTrack( trk, Q_IS_CORNU ) || - (QueryTrack( trk, Q_IS_DRAW ) && !QueryTrack( trk, Q_IS_TEXT )) || - QueryTrack( trk, Q_IS_ACTIVATEABLE))); + (QueryTrack( trk, Q_CAN_MODIFY_CONTROL_POINTS ) || + QueryTrack( trk, Q_IS_CORNU ) || + (QueryTrack( trk, Q_IS_DRAW ) && !QueryTrack( trk, Q_IS_TEXT )) || + QueryTrack( trk, Q_IS_ACTIVATEABLE))); } if ((trk)) { wMenuPushEnable(descriptionMI, QueryTrack( trk, Q_HAS_DESC )); moveDescTrk = trk; moveDescPos = pos; } - if (selectedTrackCount>0) + if (selectedTrackCount>0) { wMenuPushEnable( rotateAlignMI, TRUE ); + } } static STATUS_T CmdMove( - wAction_t action, - coOrd pos ) + wAction_t action, + coOrd pos ) { static coOrd base; static coOrd orig; @@ -1832,166 +1722,172 @@ static STATUS_T CmdMove( switch( action & 0xFF) { - case C_START: - DYNARR_RESET(trkSeg_t,anchors_da); - if (selectedTrackCount == 0) { - ErrorMessage( MSG_NO_SELECTED_TRK ); - return C_TERMINATE; - } - if (SelectedTracksAreFrozen()) { - return C_TERMINATE; - } - InfoMessage( _("Drag to move selected tracks - Shift+Ctrl+Arrow micro-steps the move") ); - state = 0; - ep1 = -1; - ep2 = -1; - doingMove = FALSE; - break; + case C_START: + DYNARR_RESET(trkSeg_t,anchors_da); + if (selectedTrackCount == 0) { + ErrorMessage( MSG_NO_SELECTED_TRK ); + return C_TERMINATE; + } + if (SelectedTracksAreFrozen()) { + return C_TERMINATE; + } + InfoMessage( + _("Drag to move selected tracks - Shift+Ctrl+Arrow micro-steps the move") ); + state = 0; + ep1 = -1; + ep2 = -1; + doingMove = FALSE; + break; - case wActionMove: - DYNARR_RESET(trkSeg_t,anchors_da); - CreateMoveAnchor(pos); - break; - case C_DOWN: - DYNARR_RESET(trkSeg_t,anchors_da); - if (doingMove) { - doingMove = FALSE; - UndoEnd(); - } + case wActionMove: + DYNARR_RESET(trkSeg_t,anchors_da); + CreateMoveAnchor(pos); + break; + case C_DOWN: + DYNARR_RESET(trkSeg_t,anchors_da); + if (doingMove) { + doingMove = FALSE; + UndoEnd(); + } - if (SelectedTracksAreFrozen()) { - return C_TERMINATE; - } - UndoStart( _("Move Tracks"), "move" ); - base = zero; - orig = pos; - DYNARR_RESET(track_p,auto_select_da); - GetMovedTracks(TRUE); - SetMoveD( TRUE, base, 0.0 ); - drawCount = 0; - state = 1; - return C_CONTINUE; - case C_MOVE: - DYNARR_RESET(trkSeg_t,anchors_da); - ep1=-1; - ep2=-1; - drawEnable = enableMoveDraw; - base.x = pos.x - orig.x; - base.y = pos.y - orig.y; - if ((MyGetKeyState() & WKEY_ALT) == 0) SnapPos( &base ); - SetMoveD( TRUE, base, 0.0 ); - if (((MyGetKeyState()&(WKEY_ALT)) == 0) == magneticSnap) { // ALT - if (FindEndIntersection(base,zero,0.0,&t1,&ep1,&t2,&ep2)) { - coOrd pos2 = GetTrkEndPos(t2,ep2); - pos2.x +=base.x; - pos2.y +=base.y; - CreateEndAnchor(pos2,FALSE); - CreateEndAnchor(GetTrkEndPos(t1,ep1),TRUE); - } + if (SelectedTracksAreFrozen()) { + return C_TERMINATE; + } + UndoStart( _("Move Tracks"), "move" ); + base = zero; + orig = pos; + DYNARR_RESET(track_p,auto_select_da); + GetMovedTracks(TRUE); + SetMoveD( TRUE, base, 0.0 ); + drawCount = 0; + state = 1; + return C_CONTINUE; + case C_MOVE: + DYNARR_RESET(trkSeg_t,anchors_da); + ep1=-1; + ep2=-1; + drawEnable = enableMoveDraw; + base.x = pos.x - orig.x; + base.y = pos.y - orig.y; + if ((MyGetKeyState() & WKEY_ALT) == 0) { SnapPos( &base ); } + SetMoveD( TRUE, base, 0.0 ); + if (((MyGetKeyState()&(WKEY_ALT)) == 0) == magneticSnap) { // ALT + if (FindEndIntersection(base,zero,0.0,&t1,&ep1,&t2,&ep2)) { + coOrd pos2 = GetTrkEndPos(t2,ep2); + pos2.x +=base.x; + pos2.y +=base.y; + CreateEndAnchor(pos2,FALSE); + CreateEndAnchor(GetTrkEndPos(t1,ep1),TRUE); } + } #ifdef DRAWCOUNT - InfoMessage( " [%s %s] #%ld", FormatDistance(base.x), FormatDistance(base.y), drawCount ); + InfoMessage( " [%s %s] #%ld", FormatDistance(base.x), FormatDistance(base.y), + drawCount ); #else - InfoMessage( " [%s %s]", FormatDistance(base.x), FormatDistance(base.y) ); + InfoMessage( " [%s %s]", FormatDistance(base.x), FormatDistance(base.y) ); #endif - drawEnable = TRUE; - return C_CONTINUE; - case C_UP: - DYNARR_RESET(trkSeg_t,anchors_da); - state = 0; - FreeTempStrings(); - if (t1 && ep1>=0 && t2 && ep2>=0) { - MoveToJoin(t2,ep2,t1,ep1); - } else { - MoveTracks( FALSE, TRUE, FALSE, base, zero, 0.0, TRUE ); - } - ep1 = -1; - ep2 = -1; - RemoveEndCornus(); - tlist_da.cnt = 0; - return C_TERMINATE; + drawEnable = TRUE; + return C_CONTINUE; + case C_UP: + DYNARR_RESET(trkSeg_t,anchors_da); + state = 0; + FreeTempStrings(); + if (t1 && ep1>=0 && t2 && ep2>=0) { + MoveToJoin(t2,ep2,t1,ep1); + } else { + MoveTracks( FALSE, TRUE, FALSE, base, zero, 0.0, TRUE ); + } + ep1 = -1; + ep2 = -1; + RemoveEndCornus(); + DYNARR_RESET( track_p, tlist_da ); + return C_TERMINATE; - case C_CMDMENU: - if (doingMove) UndoEnd(); - doingMove = FALSE; - base = pos; - track_p trk = OnTrack(&pos, FALSE, FALSE); //Note pollutes pos if turntable - if ((trk) && - QueryTrack(trk,Q_CAN_ADD_ENDPOINTS)) { //Turntable snap to center if within 1/4 radius - trackParams_t trackParams; - if (GetTrackParams(PARAMS_CORNU, trk, pos, &trackParams)) { - DIST_T dist = FindDistance(base, trackParams.ttcenter); - if (dist < trackParams.ttradius/4) { - cmdMenuPos = trackParams.ttcenter; - } + case C_CMDMENU: + if (doingMove) { UndoEnd(); } + doingMove = FALSE; + base = pos; + track_p trk = OnTrack(&pos, FALSE, FALSE); //Note pollutes pos if turntable + if ((trk) && + QueryTrack(trk, + Q_CAN_ADD_ENDPOINTS)) { //Turntable snap to center if within 1/4 radius + trackParams_t trackParams; + if (GetTrackParams(PARAMS_CORNU, trk, pos, &trackParams)) { + DIST_T dist = FindDistance(base, trackParams.ttcenter); + if (dist < trackParams.ttradius/4) { + cmdMenuPos = trackParams.ttcenter; } } - moveDescPos = pos; - moveDescTrk = trk; - SetUpMenu2(pos,trk); - menuPos = pos; - wMenuPopupShow( selectPopup2M ); - return C_CONTINUE; + } + moveDescPos = pos; + moveDescTrk = trk; + SetUpMenu2(pos,trk); + menuPos = pos; + wMenuPopupShow( selectPopup2M ); + return C_CONTINUE; - case C_TEXT: - if ((action>>8) == 'c') { - panCenter = pos; - LOG( log_pan, 2, ( "PanCenter:Sel-%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); - PanHere(I2VP(0)); - } - if ((action>>8) == 'e') { - DoZoomExtents(I2VP(0)); - } - if ((action>>8 == 's')) { - DoZoomExtents(I2VP(1)); - } - if ((action>>8) == '0' || (action>>8 == 'o')) { - PanMenuEnter(I2VP('o')); - } - if ((action>>8) == 127 || (action>>8) == 8) - SelectDelete(); + case C_TEXT: + if ((action>>8) == 'c') { + panCenter = pos; + LOG( log_pan, 2, ( "PanCenter:Sel-%d %0.3f %0.3f\n", __LINE__, panCenter.x, + panCenter.y ) ); + PanHere(I2VP(0)); + } + if ((action>>8) == 'e') { + DoZoomExtents(I2VP(0)); + } + if ((action>>8 == 's')) { + DoZoomExtents(I2VP(1)); + } + if ((action>>8) == '0' || (action>>8 == 'o')) { + PanMenuEnter(I2VP('o')); + } + if ((action>>8) == 127 || (action>>8) == 8) { + SelectDelete(); + } + break; + case C_REDRAW: + /* DO_REDRAW */ + //Draw all existing highlight boxes only + DrawHighlightBoxes(FALSE, FALSE, NULL); + HighlightSelectedTracks(NULL, TRUE, TRUE); + DrawSegsDA( &tempD, NULL, zero, 0.0, &anchors_da, trackGauge, wDrawColorBlack, + 0 ); + if ( state == 0 ) { break; - case C_REDRAW: - /* DO_REDRAW */ - //Draw all existing highlight boxes only - DrawHighlightBoxes(FALSE, FALSE, NULL); - HighlightSelectedTracks(NULL, TRUE, TRUE); - if (anchors_da.cnt) - DrawSegs( &tempD, zero, 0.0, &anchors(0), anchors_da.cnt, trackGauge, wDrawColorBlack ); - if ( state == 0 ) - break; - DrawMovedTracks(); + } + DrawMovedTracks(); - break; + break; - case wActionExtKey: - if (state) return C_CONTINUE; - if (SelectedTracksAreFrozen()) return C_TERMINATE; - if ((MyGetKeyState() & - (WKEY_SHIFT | WKEY_CTRL)) == (WKEY_SHIFT | WKEY_CTRL)) { //Both - base = zero; - DIST_T w = tempD.scale/tempD.dpi; - switch((wAccelKey_e) action>>8) { - case wAccelKey_Up: - base.y = w; - break; - case wAccelKey_Down: - base.y = -w; - break; - case wAccelKey_Left: - base.x = -w; - break; - case wAccelKey_Right: - base.x = w; - break; - default: - return C_CONTINUE; - break; - } + case wActionExtKey: + if (state) { return C_CONTINUE; } + if (SelectedTracksAreFrozen()) { return C_TERMINATE; } + if ((MyGetKeyState() & + (WKEY_SHIFT | WKEY_CTRL)) == (WKEY_SHIFT | WKEY_CTRL)) { //Both + base = zero; + DIST_T w = tempD.scale/tempD.dpi; + switch((wAccelKey_e) action>>8) { + case wAccelKey_Up: + base.y = w; + break; + case wAccelKey_Down: + base.y = -w; + break; + case wAccelKey_Left: + base.x = -w; + break; + case wAccelKey_Right: + base.x = w; + break; + default: + return C_CONTINUE; + break; + } drawEnable = enableMoveDraw; GetMovedTracks(TRUE); - if (!doingMove) UndoStart( _("Move Tracks"), "move" ); + if (!doingMove) { UndoStart( _("Move Tracks"), "move" ); } doingMove = TRUE; SetMoveD( TRUE, base, 0.0 ); MoveTracks( FALSE, TRUE, FALSE, base, zero, 0.0, FALSE ); @@ -2002,28 +1898,28 @@ static STATUS_T CmdMove( } RemoveEndCornus(); return C_CONTINUE; - } - break; + } + break; - case C_FINISH: - if (doingMove) { - doingMove = FALSE; - UndoEnd(); - } - RemoveEndCornus(); - tlist_da.cnt = 0; - break; - case C_CONFIRM: - case C_CANCEL: - if (doingMove) { - doingMove = FALSE; - UndoUndo(NULL); - } - RemoveEndCornus(); - tlist_da.cnt = 0; - break; - default: - break; + case C_FINISH: + if (doingMove) { + doingMove = FALSE; + UndoEnd(); + } + RemoveEndCornus(); + DYNARR_RESET( track_p, tlist_da ); + break; + case C_CONFIRM: + case C_CANCEL: + if (doingMove) { + doingMove = FALSE; + UndoUndo(NULL); + } + RemoveEndCornus(); + DYNARR_RESET( track_p, tlist_da ); + break; + default: + break; } return C_CONTINUE; } @@ -2045,8 +1941,8 @@ static void RotateAlign( void * alignVP ) } static STATUS_T CmdRotate( - wAction_t action, - coOrd pos ) + wAction_t action, + coOrd pos ) { static coOrd base; static coOrd orig_base; @@ -2068,303 +1964,332 @@ static STATUS_T CmdRotate( switch( action ) { - case C_START: - DYNARR_RESET(trkSeg_t,anchors_da); - state = 0; - if (selectedTrackCount == 0) { - ErrorMessage( MSG_NO_SELECTED_TRK ); - return C_TERMINATE; - } - if (SelectedTracksAreFrozen()) { - return C_TERMINATE; - } - InfoMessage( _("Drag to rotate selected tracks, Shift+RightClick for QuickRotate Menu") ); - wMenuPushEnable( rotateAlignMI, TRUE ); - rotateAlignState = 0; - ep1 = -1; - ep2 = -1; - break; - case wActionMove: - DYNARR_RESET(trkSeg_t,anchors_da); - CreateRotateAnchor(pos); - break; - case C_DOWN: - DYNARR_RESET(trkSeg_t,anchors_da); - state = 1; - if (SelectedTracksAreFrozen()) { - return C_TERMINATE; - } - UndoStart( _("Rotate Tracks"), "rotate" ); - DYNARR_RESET(track_p,auto_select_da); - if ( rotateAlignState == 0 ) { - drawnAngle = FALSE; - angle = 0.0; - base = orig = pos; - trk = OnTrack(&pos, FALSE, FALSE); //Note pollutes pos if turntable - if ((trk) && - QueryTrack(trk,Q_CAN_ADD_ENDPOINTS)) { //Turntable snap to center if within 1/4 radius - trackParams_t trackParams; - if (GetTrackParams(PARAMS_CORNU, trk, pos, &trackParams)) { - DIST_T dist = FindDistance(base, trackParams.ttcenter); - if (dist < trackParams.ttradius/4) { - base = orig = trackParams.ttcenter; - InfoMessage( _("Center of Rotation snapped to Turntable center") ); - } + case C_START: + DYNARR_RESET(trkSeg_t,anchors_da); + state = 0; + if (selectedTrackCount == 0) { + ErrorMessage( MSG_NO_SELECTED_TRK ); + return C_TERMINATE; + } + if (SelectedTracksAreFrozen()) { + return C_TERMINATE; + } + InfoMessage( + _("Drag to rotate selected tracks, Shift+RightClick for QuickRotate Menu") ); + wMenuPushEnable( rotateAlignMI, TRUE ); + rotateAlignState = 0; + ep1 = -1; + ep2 = -1; + break; + case wActionMove: + DYNARR_RESET(trkSeg_t,anchors_da); + CreateRotateAnchor(pos); + break; + case C_DOWN: + DYNARR_RESET(trkSeg_t,anchors_da); + state = 1; + if (SelectedTracksAreFrozen()) { + return C_TERMINATE; + } + UndoStart( _("Rotate Tracks"), "rotate" ); + DYNARR_RESET(track_p,auto_select_da); + if ( rotateAlignState == 0 ) { + drawnAngle = FALSE; + angle = 0.0; + base = orig = pos; + trk = OnTrack(&pos, FALSE, FALSE); //Note pollutes pos if turntable + if ((trk) && + QueryTrack(trk, + Q_CAN_ADD_ENDPOINTS)) { //Turntable snap to center if within 1/4 radius + trackParams_t trackParams; + if (GetTrackParams(PARAMS_CORNU, trk, pos, &trackParams)) { + DIST_T dist = FindDistance(base, trackParams.ttcenter); + if (dist < trackParams.ttradius/4) { + base = orig = trackParams.ttcenter; + InfoMessage( _("Center of Rotation snapped to Turntable center") ); } } - CreateRotateAnchor(orig); - GetMovedTracks(TRUE); - SetMoveD( FALSE, base, angle ); + } + CreateRotateAnchor(orig); + GetMovedTracks(TRUE); + SetMoveD( FALSE, base, angle ); - /*DrawLine( &mainD, base, orig, 0, wDrawColorBlack ); - DrawMovedTracks(FALSE, orig, angle);*/ - } else { - pos1 = pos; - drawnAngle = FALSE; - onTrackInSplit = TRUE; - trk = OnTrack( &pos, TRUE, FALSE ); - onTrackInSplit = FALSE; - if ( trk == NULL ) return C_CONTINUE; - angle1 = NormalizeAngle( GetAngleAtPoint( trk, pos, NULL, NULL ) ); - if ( rotateAlignState == 1 ) { - if ( !GetTrkSelected(trk) ) { - NoticeMessage( MSG_1ST_TRACK_MUST_BE_SELECTED, _("Ok"), NULL ); - } else { - base = pos; - baseAngle = angle1; - getboundsCount = 0; - DoSelectedTracks( GetboundsDoIt ); - orig.x = (getboundsLo.x+getboundsHi.x)/2.0; - orig.y = (getboundsLo.y+getboundsHi.y)/2.0; -/*printf( "orig = [%0.3f %0.3f], baseAngle = %0.3f\n", orig.x, orig.y, baseAngle );*/ - } + /*DrawLine( &mainD, base, orig, 0, wDrawColorBlack ); + DrawMovedTracks(FALSE, orig, angle);*/ + } else { + pos1 = pos; + drawnAngle = FALSE; + onTrackInSplit = TRUE; + trk = OnTrack( &pos, TRUE, FALSE ); + onTrackInSplit = FALSE; + if ( trk == NULL ) { return C_CONTINUE; } + angle1 = NormalizeAngle( GetAngleAtPoint( trk, pos, NULL, NULL ) ); + if ( rotateAlignState == 1 ) { + if ( !GetTrkSelected(trk) ) { + NoticeMessage( MSG_1ST_TRACK_MUST_BE_SELECTED, _("Ok"), NULL ); } else { - if ( GetTrkSelected(trk) ) { - ErrorMessage( MSG_2ND_TRACK_MUST_BE_UNSELECTED ); - angle = 0; - } else { - angle = NormalizeAngle(angle1-baseAngle); - //if ( angle > 90 && angle < 270 ) - // angle = NormalizeAngle( angle + 180.0 ); - //if ( NormalizeAngle( FindAngle( base, pos1 ) - angle1 ) < 180.0 ) - // angle = NormalizeAngle( angle + 180.0 ); -/*printf( "angle 1 = %0.3f\n", angle );*/ - if ( angle1 > 180.0 ) angle1 -= 180.0; - InfoMessage( _("Angle %0.3f"), angle1 ); - } - GetMovedTracks(TRUE); - SetMoveD( FALSE, orig, angle ); + coOrd low, high; + base = pos; + baseAngle = angle1; + GetSelectedBounds( &low, &high ); +// getboundsCount = 0; +// DoSelectedTracks( GetboundsDoIt ); +// orig.x = (getboundsLo.x+getboundsHi.x)/2.0; +// orig.y = (getboundsLo.y+getboundsHi.y)/2.0; + orig.x = (low.x+high.x)/2.0; + orig.y = (low.y+high.y)/2.0; + /*printf( "orig = [%0.3f %0.3f], baseAngle = %0.3f\n", orig.x, orig.y, baseAngle );*/ } - } - return C_CONTINUE; - case C_MOVE: - DYNARR_RESET(trkSeg_t,anchors_da); - ep1=-1; - ep2=-1; - if ( rotateAlignState == 1 ) - return C_CONTINUE; - if ( rotateAlignState == 2 ) { - pos1 = pos; - onTrackInSplit = TRUE; - trk = OnTrack( &pos, TRUE, FALSE ); - onTrackInSplit = FALSE; - if ( trk == NULL ) - return C_CONTINUE; + } else { if ( GetTrkSelected(trk) ) { ErrorMessage( MSG_2ND_TRACK_MUST_BE_UNSELECTED ); - return C_CONTINUE; + angle = 0; + } else { + angle = NormalizeAngle(angle1-baseAngle); + //if ( angle > 90 && angle < 270 ) + // angle = NormalizeAngle( angle + 180.0 ); + //if ( NormalizeAngle( FindAngle( base, pos1 ) - angle1 ) < 180.0 ) + // angle = NormalizeAngle( angle + 180.0 ); + /*printf( "angle 1 = %0.3f\n", angle );*/ + if ( angle1 > 180.0 ) { angle1 -= 180.0; } + InfoMessage( _("Angle %0.3f"), angle1 ); } - angle1 = NormalizeAngle( GetAngleAtPoint( trk, pos, NULL, NULL ) ); - angle = NormalizeAngle(angle1-baseAngle); - if ( angle > 90 && angle < 270 ) - angle = NormalizeAngle( angle + 180.0 ); - if ( NormalizeAngle( FindAngle( pos, pos1 ) - angle1 ) < 180.0 ) - angle = NormalizeAngle( angle + 180.0 ); - if ( angle1 > 180.0 ) angle1 -= 180.0; - InfoMessage( _("Angle %0.3f"), angle1 ); + GetMovedTracks(TRUE); SetMoveD( FALSE, orig, angle ); -/*printf( "angle 2 = %0.3f\n", angle );*/ + } + } + return C_CONTINUE; + case C_MOVE: + DYNARR_RESET(trkSeg_t,anchors_da); + ep1=-1; + ep2=-1; + if ( rotateAlignState == 1 ) { + return C_CONTINUE; + } + if ( rotateAlignState == 2 ) { + pos1 = pos; + onTrackInSplit = TRUE; + trk = OnTrack( &pos, TRUE, FALSE ); + onTrackInSplit = FALSE; + if ( trk == NULL ) { return C_CONTINUE; } - ANGLE_T diff_angle = 0.0; - base = pos; - drawEnable = enableMoveDraw; - if ( FindDistance( orig, pos ) > (20.0/BASE_DPI)*mainD.scale ) { - ANGLE_T old_angle = angle; - angle = FindAngle( orig, pos ); - if (!drawnAngle) { - baseAngle = angle; - drawnAngle = TRUE; - direction_set = FALSE; + if ( GetTrkSelected(trk) ) { + ErrorMessage( MSG_2ND_TRACK_MUST_BE_UNSELECTED ); + return C_CONTINUE; + } + angle1 = NormalizeAngle( GetAngleAtPoint( trk, pos, NULL, NULL ) ); + angle = NormalizeAngle(angle1-baseAngle); + if ( angle > 90 && angle < 270 ) { + angle = NormalizeAngle( angle + 180.0 ); + } + if ( NormalizeAngle( FindAngle( pos, pos1 ) - angle1 ) < 180.0 ) { + angle = NormalizeAngle( angle + 180.0 ); + } + if ( angle1 > 180.0 ) { angle1 -= 180.0; } + InfoMessage( _("Angle %0.3f"), angle1 ); + SetMoveD( FALSE, orig, angle ); + /*printf( "angle 2 = %0.3f\n", angle );*/ + return C_CONTINUE; + } + ANGLE_T diff_angle = 0.0; + base = pos; + drawEnable = enableMoveDraw; + if ( FindDistance( orig, pos ) > (20.0/BASE_DPI)*mainD.scale ) { + ANGLE_T old_angle = angle; + angle = FindAngle( orig, pos ); + if (!drawnAngle) { + baseAngle = angle; + drawnAngle = TRUE; + direction_set = FALSE; + } else { + if (!direction_set) { + if (DifferenceBetweenAngles(baseAngle,angle)>=0) { clockwise = TRUE; } + else { clockwise = FALSE; } + direction_set = TRUE; } else { - if (!direction_set) { - if (DifferenceBetweenAngles(baseAngle,angle)>=0) clockwise = TRUE; - else clockwise = FALSE; - direction_set = TRUE; + if (clockwise) { + if (DifferenceBetweenAngles(baseAngle,angle)<0 + && fabs(DifferenceBetweenAngles(baseAngle, old_angle))<5) { + clockwise = FALSE; + } } else { - if (clockwise) { - if (DifferenceBetweenAngles(baseAngle,angle)<0 && fabs(DifferenceBetweenAngles(baseAngle, old_angle))<5) - clockwise = FALSE; - } else { - if (DifferenceBetweenAngles(baseAngle,angle)>=0 && fabs(DifferenceBetweenAngles(baseAngle,old_angle))<5) - clockwise = TRUE; + if (DifferenceBetweenAngles(baseAngle,angle)>=0 + && fabs(DifferenceBetweenAngles(baseAngle,old_angle))<5) { + clockwise = TRUE; } } } - orig_base = base = pos; - //angle = NormalizeAngle( angle-baseAngle ); - diff_angle = DifferenceBetweenAngles(baseAngle,angle); - if ( (MyGetKeyState() & (WKEY_CTRL|WKEY_SHIFT)) == (WKEY_CTRL|WKEY_SHIFT) ) { //Both Shift+Ctrl - if (clockwise) { - if (diff_angle<0) diff_angle+=360; - } else { - if (diff_angle>0) diff_angle-=360; - } - diff_angle = floor((diff_angle+7.5)/15.0)*15.0; - angle = baseAngle+diff_angle; + } + orig_base = base = pos; + //angle = NormalizeAngle( angle-baseAngle ); + diff_angle = DifferenceBetweenAngles(baseAngle,angle); + if ( (MyGetKeyState() & (WKEY_CTRL|WKEY_SHIFT)) == + (WKEY_CTRL|WKEY_SHIFT) ) { //Both Shift+Ctrl + if (clockwise) { + if (diff_angle<0) { diff_angle+=360; } + } else { + if (diff_angle>0) { diff_angle-=360; } } - Translate( &base, orig, angle, FindDistance(orig,pos) ); //Line one - Translate( &orig_base,orig, baseAngle, FindDistance(orig,pos)<=(60.0/BASE_DPI*mainD.scale)?FindDistance(orig,pos):60.0/BASE_DPI*mainD.scale ); //Line two - SetMoveD( FALSE, orig, NormalizeAngle( angle-baseAngle ) ); - if (((MyGetKeyState()&(WKEY_ALT)) == WKEY_ALT) != magneticSnap) { //Just Shift - if (FindEndIntersection(zero,orig,NormalizeAngle( angle-baseAngle ),&t1,&ep1,&t2,&ep2)) { - coOrd pos2 = GetTrkEndPos(t2,ep2); - coOrd pos1 = GetTrkEndPos(t1,ep1); - Rotate(&pos2,orig,NormalizeAngle( angle-baseAngle )); - CreateEndAnchor(pos2,FALSE); - CreateEndAnchor(pos1,TRUE); - } + diff_angle = floor((diff_angle+7.5)/15.0)*15.0; + angle = baseAngle+diff_angle; + } + Translate( &base, orig, angle, FindDistance(orig,pos) ); //Line one + Translate( &orig_base,orig, baseAngle, FindDistance(orig, + pos)<=(60.0/BASE_DPI*mainD.scale)?FindDistance(orig, + pos):60.0/BASE_DPI*mainD.scale ); //Line two + SetMoveD( FALSE, orig, NormalizeAngle( angle-baseAngle ) ); + if (((MyGetKeyState()&(WKEY_ALT)) == WKEY_ALT) != magneticSnap) { //Just Shift + if (FindEndIntersection(zero,orig,NormalizeAngle( angle-baseAngle ),&t1,&ep1, + &t2,&ep2)) { + coOrd pos2 = GetTrkEndPos(t2,ep2); + coOrd pos1 = GetTrkEndPos(t1,ep1); + Rotate(&pos2,orig,NormalizeAngle( angle-baseAngle )); + CreateEndAnchor(pos2,FALSE); + CreateEndAnchor(pos1,TRUE); } + } #ifdef DRAWCOUNT - InfoMessage( _("Angle %0.3f #%ld"), fabs(diff_angle), drawCount ); + InfoMessage( _("Angle %0.3f #%ld"), fabs(diff_angle), drawCount ); #else - InfoMessage( _("Angle %0.3f %s"), fabs(diff_angle), clockwise?"Clockwise":"Counter-Clockwise" ); + InfoMessage( _("Angle %0.3f %s"), fabs(diff_angle), + clockwise?"Clockwise":"Counter-Clockwise" ); #endif - wFlush(); - drawEnable = TRUE; - } else - InfoMessage( _("Origin Set. Drag away to set start angle")); + wFlush(); + drawEnable = TRUE; + } else { + InfoMessage( _("Origin Set. Drag away to set start angle")); + } - return C_CONTINUE; + return C_CONTINUE; - case C_UP: - DYNARR_RESET(trkSeg_t,anchors_da); - state = 0; - if (t1 && ep1>=0 && t2 && ep2>=0) { - MoveToJoin(t2,ep2,t1,ep1); - CleanSegs(&tempSegs_da); - rotateAlignState = 0; - } else { - if ( rotateAlignState == 1 ) { - if ( trk && GetTrkSelected(trk) ) { - InfoMessage( _("Align: Click on the 2nd unselected object") ); - rotateAlignState = 2; - } - return C_CONTINUE; - } - CleanSegs(&tempSegs_da); - if ( rotateAlignState == 2 ) { - MoveTracks( FALSE, FALSE, TRUE, zero, orig, angle, TRUE ); - rotateAlignState = 0; - } else if (drawnAngle) { - MoveTracks( FALSE, FALSE, TRUE, zero, orig, NormalizeAngle( angle-baseAngle ), TRUE ); + case C_UP: + DYNARR_RESET(trkSeg_t,anchors_da); + state = 0; + if (t1 && ep1>=0 && t2 && ep2>=0) { + MoveToJoin(t2,ep2,t1,ep1); + CleanSegs(&tempSegs_da); + rotateAlignState = 0; + } else { + if ( rotateAlignState == 1 ) { + if ( trk && GetTrkSelected(trk) ) { + InfoMessage( _("Align: Click on the 2nd unselected object") ); + rotateAlignState = 2; } + return C_CONTINUE; } - UndoEnd(); - RemoveEndCornus(); - tlist_da.cnt = 0; - return C_TERMINATE; + CleanSegs(&tempSegs_da); + if ( rotateAlignState == 2 ) { + MoveTracks( FALSE, FALSE, TRUE, zero, orig, angle, TRUE ); + rotateAlignState = 0; + } else if (drawnAngle) { + MoveTracks( FALSE, FALSE, TRUE, zero, orig, NormalizeAngle( angle-baseAngle ), + TRUE ); + } + } + UndoEnd(); + RemoveEndCornus(); + DYNARR_RESET( track_p, tlist_da ); + return C_TERMINATE; - case C_CMDMENU: - base = pos; - trk = OnTrack(&pos, FALSE, FALSE); //Note pollutes pos if turntable - if ((trk) && - QueryTrack(trk,Q_CAN_ADD_ENDPOINTS)) { //Turntable snap to center if within 1/4 radius - trackParams_t trackParams; - if (GetTrackParams(PARAMS_CORNU, trk, pos, &trackParams)) { - DIST_T dist = FindDistance(base, trackParams.ttcenter); - if (dist < trackParams.ttradius/4) { - cmdMenuPos = trackParams.ttcenter; - } + case C_CMDMENU: + base = pos; + trk = OnTrack(&pos, FALSE, FALSE); //Note pollutes pos if turntable + if ((trk) && + QueryTrack(trk, + Q_CAN_ADD_ENDPOINTS)) { //Turntable snap to center if within 1/4 radius + trackParams_t trackParams; + if (GetTrackParams(PARAMS_CORNU, trk, pos, &trackParams)) { + DIST_T dist = FindDistance(base, trackParams.ttcenter); + if (dist < trackParams.ttradius/4) { + cmdMenuPos = trackParams.ttcenter; } } - moveDescPos = pos; - moveDescTrk = trk; - SetUpMenu2(pos,trk); - menuPos = pos; - wMenuPopupShow( selectPopup2M ); - return C_CONTINUE; + } + moveDescPos = pos; + moveDescTrk = trk; + SetUpMenu2(pos,trk); + menuPos = pos; + wMenuPopupShow( selectPopup2M ); + return C_CONTINUE; - case C_TEXT: - if ((action>>8) == 'd') { - panCenter = pos; - LOG( log_pan, 2, ( "PanCenter:Sel-%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); - PanHere(I2VP(0)); - } - if ((action>>8) == 'e') { - DoZoomExtents(I2VP(0)); - } - if ((action>>8) == 's') { - DoZoomExtents(I2VP(1)); - } - if ((action>>8) == '0' || (action>>8 == 'o')) { - PanMenuEnter(I2VP('o')); - } + case C_TEXT: + if ((action>>8) == 'd') { + panCenter = pos; + LOG( log_pan, 2, ( "PanCenter:Sel-%d %0.3f %0.3f\n", __LINE__, panCenter.x, + panCenter.y ) ); + PanHere(I2VP(0)); + } + if ((action>>8) == 'e') { + DoZoomExtents(I2VP(0)); + } + if ((action>>8) == 's') { + DoZoomExtents(I2VP(1)); + } + if ((action>>8) == '0' || (action>>8 == 'o')) { + PanMenuEnter(I2VP('o')); + } + break; + case C_REDRAW: + DrawHighlightBoxes(FALSE,FALSE,NULL); + HighlightSelectedTracks(NULL, TRUE, TRUE); + DrawSegsDA( &tempD, NULL, zero, 0.0, &anchors_da, trackGauge, wDrawColorBlack, + 0 ); + /* DO_REDRAW */ + if ( state == 0 ) { break; - case C_REDRAW: - DrawHighlightBoxes(FALSE,FALSE,NULL); - HighlightSelectedTracks(NULL, TRUE, TRUE); - if (anchors_da.cnt) - DrawSegs( &tempD, zero, 0.0, &anchors(0), anchors_da.cnt, trackGauge, wDrawColorBlack ); - /* DO_REDRAW */ - if ( state == 0 ) - break; - if ( rotateAlignState != 2 ) { - DIST_T width = tempD.scale*0.15; - DrawLine( &tempD, base, orig, 0, wDrawColorBlue ); - if (drawnAngle) { - DrawLine( &tempD, orig_base, orig, (wDrawWidth)width/2, wDrawColorBlue ); - ANGLE_T a = DifferenceBetweenAngles(FindAngle(orig, orig_base),FindAngle(orig, base)); - - DIST_T dist = FindDistance(orig,base); - if (dist>(60.0/BASE_DPI)*mainD.scale) dist = (60.0/BASE_DPI)*mainD.scale; - - if (direction_set) { - if (clockwise) { - if (a<0) a = a + 360; - DrawArc( &tempD, orig, dist/2, FindAngle(orig,orig_base), a, FALSE, 0, wDrawColorBlue); - } else { - if (a>0) a = a - 360; - DrawArc( &tempD, orig, dist/2, FindAngle(orig,base), fabs(a), FALSE, 0, wDrawColorBlue); - } - DIST_T d; - d = mainD.scale*0.25; - ANGLE_T arrow_a = NormalizeAngle(FindAngle(orig,orig_base)+a/2); - coOrd arr1,arr2,arr3; - Translate(&arr2,orig,arrow_a,dist/2); - if (clockwise) arrow_a +=90; - else arrow_a -=90; - Translate(&arr1,arr2,arrow_a+135,d/2); - Translate(&arr3,arr2,arrow_a-135,d/2); - DrawLine( &tempD, arr1, arr2, 0, wDrawColorBlue ); - DrawLine( &tempD, arr2, arr3, 0, wDrawColorBlue ); + } + if ( rotateAlignState != 2 ) { + DIST_T width = tempD.scale*0.15; + DrawLine( &tempD, base, orig, 0, wDrawColorBlue ); + if (drawnAngle) { + DrawLine( &tempD, orig_base, orig, (wDrawWidth)width/2, wDrawColorBlue ); + ANGLE_T a = DifferenceBetweenAngles(FindAngle(orig, orig_base),FindAngle(orig, + base)); + + DIST_T dist = FindDistance(orig,base); + if (dist>(60.0/BASE_DPI)*mainD.scale) { dist = (60.0/BASE_DPI)*mainD.scale; } + + if (direction_set) { + if (clockwise) { + if (a<0) { a = a + 360; } + DrawArc( &tempD, orig, dist/2, FindAngle(orig,orig_base), a, FALSE, 0, + wDrawColorBlue); + } else { + if (a>0) { a = a - 360; } + DrawArc( &tempD, orig, dist/2, FindAngle(orig,base), fabs(a), FALSE, 0, + wDrawColorBlue); } + DIST_T d; + d = mainD.scale*0.25; + ANGLE_T arrow_a = NormalizeAngle(FindAngle(orig,orig_base)+a/2); + coOrd arr1,arr2,arr3; + Translate(&arr2,orig,arrow_a,dist/2); + if (clockwise) { arrow_a +=90; } + else { arrow_a -=90; } + Translate(&arr1,arr2,arrow_a+135,d/2); + Translate(&arr3,arr2,arrow_a-135,d/2); + DrawLine( &tempD, arr1, arr2, 0, wDrawColorBlue ); + DrawLine( &tempD, arr2, arr3, 0, wDrawColorBlue ); } - } - DrawMovedTracks(); - break; } + DrawMovedTracks(); + break; + + } return C_CONTINUE; } -static void QuickMove( void* pos) { +static void QuickMove( void* pos) +{ coOrd move_pos = *(coOrd*)pos; DYNARR_RESET(track_p,auto_select_da); - if ( SelectedTracksAreFrozen() ) + if ( SelectedTracksAreFrozen() ) { return; + } wDrawDelayUpdate( mainD.d, TRUE ); GetMovedTracks(FALSE); UndoStart( _("Move Tracks"), "Move Tracks" ); @@ -2372,16 +2297,18 @@ static void QuickMove( void* pos) { wDrawDelayUpdate( mainD.d, FALSE ); } -static track_p SelectTrackByIndex(TRKINX_T ti, char * message ) { +static track_p SelectTrackByIndex(TRKINX_T ti, char * message ) +{ track_p trk = FindTrack(ti); if (trk) { if (!GetLayerFrozen( GetTrkLayer( trk ) ) ) { if (GetLayerModule(GetTrkLayer(trk))) { DoModuleTracks(GetTrkLayer(trk),DrawSingleTrack,TRUE); - snprintf(message, STR_LONG_SIZE, "%s %d",_("In module layer:"),GetTrkLayer(trk)+1); + snprintf(message, STR_LONG_SIZE, "%s %d",_("In module layer:"), + GetTrkLayer(trk)+1); } else { - if (!GetLayerVisible(GetTrkLayer(trk))) FlipLayer(I2VP(GetTrkLayer(trk))); - if (!GetTrkVisible(trk) && drawTunnel==0 ) drawTunnel = 1; //Force DRAW_TUNNEL_DASH + if (!GetLayerVisible(GetTrkLayer(trk))) { FlipLayer(I2VP(GetTrkLayer(trk))); } + if (!GetTrkVisible(trk) && drawTunnel==0 ) { drawTunnel = 1; } //Force DRAW_TUNNEL_DASH SelectOneTrack(trk,TRUE); } } else { @@ -2394,7 +2321,8 @@ static track_p SelectTrackByIndex(TRKINX_T ti, char * message ) { return trk; } -EXPORT void SelectByIndex( void* string) { +EXPORT void SelectByIndex( void* string) +{ char result[STR_LONG_SIZE] = ""; char * message; SetAllTrackSelect(FALSE); @@ -2414,13 +2342,13 @@ EXPORT void SelectByIndex( void* string) { } } cp = strtok(NULL,","); - if (cp) single = FALSE; + if (cp) { single = FALSE; } } DoZoomExtents(I2VP(1)); - if (strlen(result)) + if (strlen(result)) { InfoMessage(result); - else if (single && trk) { + } else if (single && trk) { char msg[STR_SIZE]; DescribeTrack( trk, msg, sizeof msg ); InfoMessage( msg ); @@ -2433,8 +2361,9 @@ static void QuickRotate( void* pangle ) { ANGLE_T angle = (ANGLE_T)VP2L(pangle); DYNARR_RESET(track_p,auto_select_da); - if ( SelectedTracksAreFrozen() ) + if ( SelectedTracksAreFrozen() ) { return; + } wDrawDelayUpdate( mainD.d, TRUE ); GetMovedTracks(FALSE); //DrawSelectedTracksD( &mainD, wDrawColorWhite ); @@ -2457,8 +2386,9 @@ static void ChangeDetailedFlag( void * mode ) if ( ( GetTrkBits( moveDescTrk ) & TB_DETAILDESC ) == 0 ) { ClrTrkBits( moveDescTrk, TB_HIDEDESC ); SetTrkBits( moveDescTrk, TB_DETAILDESC ); - } else + } else { ClrTrkBits( moveDescTrk, TB_DETAILDESC ); + } DrawNewTrack( moveDescTrk ); wDrawDelayUpdate( mainD.d, FALSE ); } @@ -2469,10 +2399,11 @@ static void ChangeDescFlag( void * mode ) UndoStart( _("Toggle Label"), "Modedesc( T%d )", GetTrkIndex(moveDescTrk) ); UndoModify( moveDescTrk ); UndrawNewTrack( moveDescTrk ); - if ( ( GetTrkBits( moveDescTrk ) & TB_HIDEDESC ) == 0 ) + if ( ( GetTrkBits( moveDescTrk ) & TB_HIDEDESC ) == 0 ) { SetTrkBits( moveDescTrk, TB_HIDEDESC ); - else + } else { ClrTrkBits( moveDescTrk, TB_HIDEDESC ); + } DrawNewTrack( moveDescTrk ); wDrawDelayUpdate( mainD.d, FALSE ); } @@ -2481,134 +2412,142 @@ static void ChangeDescFlag( void * mode ) * Mode_o -1 = everything, 0 = elevations only, 1 = descriptions only */ -track_p FindTrackDescription(coOrd pos, EPINX_T * ep_o, int * mode_o, BOOL_T show_hidden, BOOL_T * hidden_o) { - track_p trk = NULL; - DIST_T d, dd = DIST_INF; - track_p trk1 = NULL; - EPINX_T ep1=-1, ep=-1; - BOOL_T hidden_t, hidden; - coOrd dpos = pos; - coOrd cpos; - int mode = -1; - while ( TrackIterate( &trk1 ) ) { - if ( !GetLayerVisible(GetTrkLayer(trk1)) ) - continue; - if ( (!GetTrkVisible(trk1)) && drawTunnel==0 ) - continue; - if ( GetLayerFrozen( GetTrkLayer( trk1 ) )) - continue; - if ( (labelEnable&LABELENABLE_ENDPT_ELEV)!=0 && *mode_o <= 0) { - for ( ep1=0; ep1<GetTrkEndPtCnt(trk1); ep1++ ) { - d = EndPtDescriptionDistance( pos, trk1, ep1, &dpos, FALSE, NULL ); //No hidden - if ( d < dd ) { - dd = d; - trk = trk1; - ep = ep1; - mode = 0; - hidden = FALSE; - cpos= dpos; - } +track_p FindTrackDescription(coOrd pos, EPINX_T * ep_o, int * mode_o, + BOOL_T show_hidden, BOOL_T * hidden_o) +{ + track_p trk = NULL; + DIST_T d, dd = DIST_INF; + track_p trk1 = NULL; + EPINX_T ep1=-1, ep=-1; + BOOL_T hidden_t, hidden; + coOrd dpos = pos; +// coOrd cpos; + int mode = -1; + while ( TrackIterate( &trk1 ) ) { + if ( !GetLayerVisible(GetTrkLayer(trk1)) ) { + continue; + } + if ( (!GetTrkVisible(trk1)) && drawTunnel==0 ) { + continue; + } + if ( GetLayerFrozen( GetTrkLayer( trk1 ) )) { + continue; + } + if ( (labelEnable&LABELENABLE_ENDPT_ELEV)!=0 && *mode_o <= 0) { + for ( ep1=0; ep1<GetTrkEndPtCnt(trk1); ep1++ ) { + d = EndPtDescriptionDistance( pos, trk1, ep1, &dpos, FALSE, NULL ); //No hidden + if ( d < dd ) { + dd = d; + trk = trk1; + ep = ep1; + mode = 0; + hidden = FALSE; +// cpos= dpos; } } - if (IsClose(dd)) break; - if ( *mode_o == 0 || !QueryTrack( trk1, Q_HAS_DESC ) ) - continue; - if ((labelEnable&LABELENABLE_TRKDESC)==0) - continue; - if ( ( GetTrkBits( trk1 ) & TB_HIDEDESC ) != 0 ) { - if ( !show_hidden ) continue; - } - d = CompoundDescriptionDistance( pos, trk1, &dpos, show_hidden, &hidden_t ); - if ( d < dd ) { - dd = d; - trk = trk1; - ep = -1; - mode = 1; - hidden = hidden_t; - cpos = dpos; - } - d = CurveDescriptionDistance( pos, trk1, &dpos, show_hidden, &hidden_t ); - if ( d < dd ) { - dd = d; - trk = trk1; - ep = -1; - mode = 2; - hidden = hidden_t; - cpos = dpos; - } - d = CornuDescriptionDistance( pos, trk1, &dpos, show_hidden, &hidden_t ); - if ( d < dd ) { - dd = d; - trk = trk1; - ep = -1; - mode = 3; - hidden = hidden_t; - cpos = dpos; - } - d = BezierDescriptionDistance( pos, trk1, &dpos, show_hidden, &hidden_t ); - if ( d < dd ) { - dd = d; - trk = trk1; - ep = -1; - mode = 4; - hidden = hidden_t; - cpos = dpos; - } - d = StraightDescriptionDistance( pos, trk1, &dpos, show_hidden, &hidden_t ); - if (d < dd ) { - dd = d; - trk = trk1; - ep = -1; - mode = 5; - hidden = hidden_t; - cpos = dpos; - } - d = JointDescriptionDistance( pos, trk1, &dpos, show_hidden, &hidden_t ); - if (d < dd ) { - dd = d; - trk = trk1; - ep = -1; - mode = 6; - hidden = hidden_t; - cpos = dpos; - } - - } - - coOrd pos1 = pos; - - if ((trk != NULL) && IsClose(dd) ) { - if (ep_o) *ep_o = ep; - if (mode_o) *mode_o = mode; - if (hidden_o) *hidden_o = hidden; - return trk; - } else { // Return other track for description (not near to description but nearest to track) - if ((trk1 = OnTrack(&pos1, FALSE, FALSE))==NULL) return NULL; - if (!QueryTrack( trk1, Q_HAS_DESC )) return NULL; - if (GetLayerFrozen(GetTrkLayer(trk1))) return NULL; - if (IsClose(FindDistance(pos,pos1))) { - if (mode_o) *mode_o = -1; - if (ep_o) *ep_o = -1; - if (hidden_o) *hidden_o = GetTrkBits( trk1 ) & TB_HIDEDESC; - return trk1; - } - } - - return NULL; + } + if (IsClose(dd)) { break; } + if ( *mode_o == 0 || !QueryTrack( trk1, Q_HAS_DESC ) ) { + continue; + } + if ((labelEnable&LABELENABLE_TRKDESC)==0) { + continue; + } + if ( ( GetTrkBits( trk1 ) & TB_HIDEDESC ) != 0 ) { + if ( !show_hidden ) { continue; } + } + d = CompoundDescriptionDistance( pos, trk1, &dpos, show_hidden, &hidden_t ); + if ( d < dd ) { + dd = d; + trk = trk1; + ep = -1; + mode = 1; + hidden = hidden_t; +// cpos = dpos; + } + d = CurveDescriptionDistance( pos, trk1, &dpos, show_hidden, &hidden_t ); + if ( d < dd ) { + dd = d; + trk = trk1; + ep = -1; + mode = 2; + hidden = hidden_t; +// cpos = dpos; + } + d = CornuDescriptionDistance( pos, trk1, &dpos, show_hidden, &hidden_t ); + if ( d < dd ) { + dd = d; + trk = trk1; + ep = -1; + mode = 3; + hidden = hidden_t; +// cpos = dpos; + } + d = BezierDescriptionDistance( pos, trk1, &dpos, show_hidden, &hidden_t ); + if ( d < dd ) { + dd = d; + trk = trk1; + ep = -1; + mode = 4; + hidden = hidden_t; +// cpos = dpos; + } + d = StraightDescriptionDistance( pos, trk1, &dpos, show_hidden, &hidden_t ); + if (d < dd ) { + dd = d; + trk = trk1; + ep = -1; + mode = 5; + hidden = hidden_t; +// cpos = dpos; + } + d = JointDescriptionDistance( pos, trk1, &dpos, show_hidden, &hidden_t ); + if (d < dd ) { + dd = d; + trk = trk1; + ep = -1; + mode = 6; + hidden = hidden_t; +// cpos = dpos; + } + + } + + coOrd pos1 = pos; + + if ((trk != NULL) && IsClose(dd) ) { + if (ep_o) { *ep_o = ep; } + if (mode_o) { *mode_o = mode; } + if (hidden_o) { *hidden_o = hidden; } + return trk; + } else { // Return other track for description (not near to description but nearest to track) + if ((trk1 = OnTrack(&pos1, FALSE, FALSE))==NULL) { return NULL; } + if (!QueryTrack( trk1, Q_HAS_DESC )) { return NULL; } + if (GetLayerFrozen(GetTrkLayer(trk1))) { return NULL; } + if (IsClose(FindDistance(pos,pos1))) { + if (mode_o) { *mode_o = -1; } + if (ep_o) { *ep_o = -1; } + if (hidden_o) { *hidden_o = GetTrkBits( trk1 ) & TB_HIDEDESC; } + return trk1; + } + } + + return NULL; } static long moveDescMode; STATUS_T CmdMoveDescription( - wAction_t action, - coOrd pos ) + wAction_t action, + coOrd pos ) { static EPINX_T ep; static BOOL_T hidden; static int mode; BOOL_T bChanged; - moveDescMode = VP2L(commandContext); //Context 0 = everything, 1 means elevations, 2 means descriptions + moveDescMode = VP2L( + commandContext); //Context 0 = everything, 1 means elevations, 2 means descriptions bChanged = FALSE; switch (action&0xFF) { @@ -2618,55 +2557,58 @@ STATUS_T CmdMoveDescription( hidden = FALSE; mode = -1; if ( labelWhen < 2 || mainD.scale > labelScale || - (labelEnable&(LABELENABLE_TRKDESC|LABELENABLE_ENDPT_ELEV))==0 ) { + (labelEnable&(LABELENABLE_TRKDESC|LABELENABLE_ENDPT_ELEV))==0 ) { ErrorMessage( MSG_DESC_NOT_VISIBLE ); return C_ERROR; } SetAllTrackSelect( FALSE ); - /* no break */ + /* no break */ case wActionMove: - if ( labelWhen < 2 || mainD.scale > labelScale ) return C_CONTINUE; - mode = moveDescMode-1; // -1 means everything, 0 means elevations only, 1 means descriptions only - if ((moveDescTrk=FindTrackDescription(pos,&ep,&mode,TRUE,&hidden))!=NULL) { - if (mode==0) { - InfoMessage(_("Elevation description")); + if ( labelWhen < 2 || mainD.scale > labelScale ) { return C_CONTINUE; } + mode = moveDescMode + -1; // -1 means everything, 0 means elevations only, 1 means descriptions only + if ((moveDescTrk=FindTrackDescription(pos,&ep,&mode,TRUE,&hidden))!=NULL) { + if (mode==0) { + InfoMessage(_("Elevation description")); + } else { + if (moveDescMode == 1) { + moveDescTrk = NULL; + return C_CONTINUE; //Ignore other tracks if only looking for elevations + } + if (hidden) { + InfoMessage(_("Hidden description - 's' to Show, 'd' Details")); + moveDescPos = pos; } else { - if (moveDescMode == 1) { - moveDescTrk = NULL; - return C_CONTINUE; //Ignore other tracks if only looking for elevations - } - if (hidden) { - InfoMessage(_("Hidden description - 's' to Show, 'd' Details")); - moveDescPos = pos; - } else { - InfoMessage(_("Shown description - 'h' to Hide")); - moveDescPos = pos; - } + InfoMessage(_("Shown description - 'h' to Hide")); + moveDescPos = pos; } - return C_CONTINUE; - } else { - moveDescTrk = NULL; } - InfoMessage( _("Select and drag a description") ); - break; + return C_CONTINUE; + } else { + moveDescTrk = NULL; + } + InfoMessage( _("Select and drag a description") ); + break; case C_TEXT: - if (!moveDescTrk) return C_CONTINUE; - if (mode == 0) return C_CONTINUE; + if (!moveDescTrk) { return C_CONTINUE; } + if (mode == 0) { return C_CONTINUE; } bChanged = FALSE; if (action>>8 == 's') { - if ( ( GetTrkBits( moveDescTrk ) & TB_HIDEDESC) != 0 ) + if ( ( GetTrkBits( moveDescTrk ) & TB_HIDEDESC) != 0 ) { bChanged = TRUE; + } ClrTrkBits( moveDescTrk, TB_HIDEDESC ); } else if (action>>8 == 'h') { - if ( ( GetTrkBits( moveDescTrk ) & TB_HIDEDESC) == 0 ) + if ( ( GetTrkBits( moveDescTrk ) & TB_HIDEDESC) == 0 ) { bChanged = TRUE; + } SetTrkBits( moveDescTrk, TB_HIDEDESC ); ClrTrkBits( moveDescTrk, TB_DETAILDESC ); } else if (action>>8 == 'd') { //Toggle Detailed bChanged = TRUE; - if ((GetTrkBits( moveDescTrk ) & TB_DETAILDESC) != 0) + if ((GetTrkBits( moveDescTrk ) & TB_DETAILDESC) != 0) { ClrTrkBits( moveDescTrk, TB_DETAILDESC); - else { + } else { ClrTrkBits( moveDescTrk, TB_HIDEDESC ); SetTrkBits( moveDescTrk, TB_DETAILDESC ); } @@ -2677,57 +2619,62 @@ STATUS_T CmdMoveDescription( break; case C_DOWN: if (( labelWhen < 2 || mainD.scale > labelScale ) || - (labelEnable&(LABELENABLE_TRKDESC|LABELENABLE_ENDPT_ELEV))==0 ) { - ErrorMessage( MSG_DESC_NOT_VISIBLE ); + (labelEnable&(LABELENABLE_TRKDESC|LABELENABLE_ENDPT_ELEV))==0 ) { + ErrorMessage( MSG_DESC_NOT_VISIBLE ); return C_ERROR; - } + } mode = moveDescMode-1; moveDescTrk = FindTrackDescription(pos,&ep,&mode,TRUE,&hidden); - if (moveDescTrk == NULL ) + if (moveDescTrk == NULL ) { return C_CONTINUE; + } if (hidden) { InfoMessage(_("Hidden Label - Drag to reveal")); } else { InfoMessage(_("Drag label")); } - if (ep == -1 ) + if (ep == -1 ) { DrawTrack( moveDescTrk, &mainD, wDrawColorWhite ); - /* no break */ + } + /* no break */ case C_MOVE: - if (moveDescTrk == NULL ) - return C_CONTINUE; + if (moveDescTrk == NULL ) { + return C_CONTINUE; + } UndoStart( _("Move Label"), "Modedesc( T%d )", GetTrkIndex(moveDescTrk) ); UndoModify( moveDescTrk ); ClrTrkBits( moveDescTrk, TB_HIDEDESC ); hidden = FALSE; - /* no break */ + /* no break */ case C_UP: - if ( labelWhen < 2 || mainD.scale > labelScale ) + if ( labelWhen < 2 || mainD.scale > labelScale ) { return C_CONTINUE; - if ( moveDescTrk == NULL ) + } + if ( moveDescTrk == NULL ) { return C_CONTINUE; - int rc = C_CONTINUE; + } +// int rc = C_CONTINUE; switch (mode) { case 0: - rc = EndPtDescriptionMove( moveDescTrk, ep, action, pos ); + EndPtDescriptionMove( moveDescTrk, ep, action, pos ); break; case 1: - rc = CompoundDescriptionMove( moveDescTrk, action, pos ); + CompoundDescriptionMove( moveDescTrk, action, pos ); break; case 2: - rc = CurveDescriptionMove( moveDescTrk, action, pos ); + CurveDescriptionMove( moveDescTrk, action, pos ); break; case 3: - rc = CornuDescriptionMove( moveDescTrk, action, pos ); + CornuDescriptionMove( moveDescTrk, action, pos ); break; case 4: - rc = BezierDescriptionMove( moveDescTrk, action, pos ); + BezierDescriptionMove( moveDescTrk, action, pos ); break; case 5: - rc = StraightDescriptionMove( moveDescTrk, action, pos); + StraightDescriptionMove( moveDescTrk, action, pos); break; case 6: - rc = JointDescriptionMove( moveDescTrk, action, pos); + JointDescriptionMove( moveDescTrk, action, pos); break; } hidden = FALSE; @@ -2738,8 +2685,9 @@ STATUS_T CmdMoveDescription( } break; case C_REDRAW: - if ( labelWhen < 2 || mainD.scale > labelScale ) + if ( labelWhen < 2 || mainD.scale > labelScale ) { return C_CONTINUE; + } if ( moveDescTrk ) { if (mode==0) { DrawEndPt2( &tempD, moveDescTrk, ep, drawColorPreviewSelected ); @@ -2762,15 +2710,18 @@ STATUS_T CmdMoveDescription( } else { moveDescPos = pos; } - if ( moveDescTrk == NULL ) break; - if ( ! QueryTrack( moveDescTrk, Q_HAS_DESC ) ) break; + if ( moveDescTrk == NULL ) { break; } + if ( ! QueryTrack( moveDescTrk, Q_HAS_DESC ) ) { break; } if ( moveDescM == NULL ) { moveDescM = MenuRegister( "Move Desc Toggle" ); - moveDescMI = wMenuToggleCreate( moveDescM, "", _("Show/Hide Description"), 0, TRUE, ChangeDescFlag, NULL ); - moveDetailDescMI = wMenuToggleCreate( moveDescM, "", _("Toggle Detailed Description"), 0, TRUE, ChangeDetailedFlag, NULL ); + moveDescMI = wMenuToggleCreate( moveDescM, "", _("Show/Hide Description"), 0, + TRUE, ChangeDescFlag, NULL ); + moveDetailDescMI = wMenuToggleCreate( moveDescM, "", + _("Toggle Detailed Description"), 0, TRUE, ChangeDetailedFlag, NULL ); } wMenuToggleSet( moveDescMI, !( GetTrkBits( moveDescTrk ) & TB_HIDEDESC ) ); - wMenuToggleSet( moveDetailDescMI, ( GetTrkBits( moveDescTrk ) & TB_DETAILDESC ) ); + wMenuToggleSet( moveDetailDescMI, + ( GetTrkBits( moveDescTrk ) & TB_DETAILDESC ) ); menuPos = pos; wMenuPopupShow( moveDescM ); break; @@ -2778,14 +2729,14 @@ STATUS_T CmdMoveDescription( default: ; } - + return C_CONTINUE; } static void FlipTracks( - coOrd orig, - ANGLE_T angle ) + coOrd orig, + ANGLE_T angle ) { track_p trk, trk1; EPINX_T ep, ep1; @@ -2797,16 +2748,17 @@ static void FlipTracks( wDrawDelayUpdate( mapD.d, TRUE ); } for ( trk=NULL; TrackIterate(&trk); ) { - if ( !GetTrkSelected(trk) ) + if ( !GetTrkSelected(trk) ) { continue; + } UndoModify( trk ); if (selectedTrackCount <= incrementalDrawLimit) { - DrawTrack( trk, &mainD, wDrawColorWhite ); - DrawTrack( trk, &mapD, wDrawColorWhite ); + DrawTrack( trk, &mainD, wDrawColorWhite ); + DrawTrack( trk, &mapD, wDrawColorWhite ); } for (ep=0; ep<GetTrkEndPtCnt(trk); ep++) { if ((trk1 = GetTrkEndTrk(trk,ep)) != NULL && - !GetTrkSelected(trk1)) { + !GetTrkSelected(trk1)) { ep1 = GetEndPtConnectedToMe( trk1, trk ); DisconnectTracks( trk, ep, trk1, ep1 ); DrawEndPt( &mainD, trk1, ep1, wDrawColorBlack ); @@ -2814,8 +2766,8 @@ static void FlipTracks( } FlipTrack( trk, orig, angle ); if (selectedTrackCount <= incrementalDrawLimit) { - DrawTrack( trk, &mainD, wDrawColorBlack ); - DrawTrack( trk, &mapD, wDrawColorBlack ); + DrawTrack( trk, &mainD, wDrawColorBlack ); + DrawTrack( trk, &mapD, wDrawColorBlack ); } } if (selectedTrackCount > incrementalDrawLimit) { @@ -2831,8 +2783,8 @@ static void FlipTracks( static STATUS_T CmdFlip( - wAction_t action, - coOrd pos ) + wAction_t action, + coOrd pos ) { static coOrd pos0; static coOrd pos1; @@ -2840,53 +2792,55 @@ static STATUS_T CmdFlip( switch( action ) { - case C_START: - state = 0; - if (selectedTrackCount == 0) { - ErrorMessage( MSG_NO_SELECTED_TRK ); - return C_TERMINATE; - } - if (SelectedTracksAreFrozen()) - return C_TERMINATE; - InfoMessage( _("Drag to mark mirror line") ); - break; - case C_DOWN: - state = 1; - if (SelectedTracksAreFrozen()) { - return C_TERMINATE; - } - pos0 = pos1 = pos; - return C_CONTINUE; - case C_MOVE: - pos1 = pos; - InfoMessage( _("Angle %0.2f"), FindAngle( pos0, pos1 ) ); - return C_CONTINUE; - case C_UP: - UndoStart( _("Flip Tracks"), "flip" ); - FlipTracks( pos0, FindAngle( pos0, pos1 ) ); - state = 0; + case C_START: + state = 0; + if (selectedTrackCount == 0) { + ErrorMessage( MSG_NO_SELECTED_TRK ); return C_TERMINATE; + } + if (SelectedTracksAreFrozen()) { + return C_TERMINATE; + } + InfoMessage( _("Drag to mark mirror line") ); + break; + case C_DOWN: + state = 1; + if (SelectedTracksAreFrozen()) { + return C_TERMINATE; + } + pos0 = pos1 = pos; + return C_CONTINUE; + case C_MOVE: + pos1 = pos; + InfoMessage( _("Angle %0.2f"), FindAngle( pos0, pos1 ) ); + return C_CONTINUE; + case C_UP: + UndoStart( _("Flip Tracks"), "flip" ); + FlipTracks( pos0, FindAngle( pos0, pos1 ) ); + state = 0; + return C_TERMINATE; #ifdef LATER - case C_CANCEL: + case C_CANCEL: #endif - case C_REDRAW: - DrawHighlightBoxes(FALSE,FALSE,NULL); - HighlightSelectedTracks(NULL, TRUE, TRUE); - if ( state == 0 ) - return C_CONTINUE; - DrawLine( &tempD, pos0, pos1, 0, wDrawColorBlack ); + case C_REDRAW: + DrawHighlightBoxes(FALSE,FALSE,NULL); + HighlightSelectedTracks(NULL, TRUE, TRUE); + if ( state == 0 ) { return C_CONTINUE; + } + DrawLine( &tempD, pos0, pos1, 0, wDrawColorBlack ); + return C_CONTINUE; - default: - break; + default: + break; } return C_CONTINUE; } static BOOL_T SelectArea( - wAction_t action, - coOrd pos ) + wAction_t action, + coOrd pos ) { static coOrd pos0; static int state; @@ -2938,36 +2892,39 @@ static BOOL_T SelectArea( subtract = (action == C_RUP); cnt = 0; trk = NULL; - if (add && (selectMode == 0)) SetAllTrackSelect( FALSE ); //Remove all tracks first + if (add && (selectMode == 0)) { SetAllTrackSelect( FALSE ); } //Remove all tracks first while ( TrackIterate( &trk ) ) { GetBoundingBox( trk, &hi, &lo ); if (GetLayerVisible( GetTrkLayer( trk ) ) && - lo.x >= base.x && hi.x <= base.x+size.x && - lo.y >= base.y && hi.y <= base.y+size.y) { - if ( (GetTrkSelected( trk )==0) == (action==C_UP) ) - cnt++; + lo.x >= base.x && hi.x <= base.x+size.x && + lo.y >= base.y && hi.y <= base.y+size.y) { + if ( (GetTrkSelected( trk )==0) == (action==C_UP) ) { + cnt++; + } } } trk = NULL; while ( TrackIterate( &trk ) ) { GetBoundingBox( trk, &hi, &lo ); if (GetLayerVisible( GetTrkLayer( trk ) ) && - lo.x >= base.x && hi.x <= base.x+size.x && - lo.y >= base.y && hi.y <= base.y+size.y) { + lo.x >= base.x && hi.x <= base.x+size.x && + lo.y >= base.y && hi.y <= base.y+size.y) { if ( (GetTrkSelected( trk )==0) == (action==C_UP) ) { if (GetLayerFrozen(GetTrkLayer(trk))) { continue; } else if (GetLayerModule(GetTrkLayer(trk))) { - if (add) + if (add) { DoModuleTracks(GetTrkLayer(trk),SelectOneTrack,TRUE); - else + } else { DoModuleTracks(GetTrkLayer(trk),SelectOneTrack,FALSE); + } } else if (cnt > incrementalDrawLimit) { selectedTrackCount += (action==C_UP?1:-1); - if (add) + if (add) { SetTrkBits( trk, TB_SELECTED ); - else + } else { ClrTrkBits( trk, TB_SELECTED ); + } } else { SelectOneTrack( trk, add ); } @@ -2992,33 +2949,38 @@ static BOOL_T SelectArea( break; case C_REDRAW: - if (state == 0) + if (state == 0) { break; + } //Draw to-be selected tracks versus not. trk = NULL; - if (selectMode == 1 && add) HighlightSelectedTracks(NULL, TRUE, TRUE); + if (selectMode == 1 && add) { HighlightSelectedTracks(NULL, TRUE, TRUE); } while ( TrackIterate( &trk ) ) { GetBoundingBox( trk, &hi, &lo ); if (GetLayerVisible( GetTrkLayer( trk ) ) && - lo.x >= base.x && hi.x <= base.x+size.x && - lo.y >= base.y && hi.y <= base.y+size.y) { - if (GetLayerFrozen(GetTrkLayer(trk))) + lo.x >= base.x && hi.x <= base.x+size.x && + lo.y >= base.y && hi.y <= base.y+size.y) { + if (GetLayerFrozen(GetTrkLayer(trk))) { continue; + } if (GetLayerModule(GetTrkLayer(trk))) { - if (add) + if (add) { DoModuleTracks(GetTrkLayer(trk),DrawSingleTrack,TRUE); - else if (subtract) + } else if (subtract) { DoModuleTracks(GetTrkLayer(trk),DrawSingleTrack,FALSE); + } } else { if (add) { - if (selectMode == 0 && add) + if (selectMode == 0 && add) { DrawTrack(trk,&tempD,wDrawColorPreviewSelected); - if (!GetTrkSelected(trk)) + } + if (!GetTrkSelected(trk)) { DrawTrack(trk,&tempD,wDrawColorPreviewSelected); - } - else if (subtract) { - if (GetTrkSelected(trk)) + } + } else if (subtract) { + if (GetTrkSelected(trk)) { DrawTrack(trk,&tempD,wDrawColorPreviewUnselected); + } } } } @@ -3033,23 +2995,19 @@ static BOOL_T SelectArea( return FALSE; } -extern BOOL_T inDescribeCmd; -extern wIndex_t modifyCmdInx; -extern wIndex_t describeCmdInx; -extern wIndex_t panCmdInx; -extern wIndex_t trainCmdInx; -static STATUS_T SelectTrack( - coOrd pos ) +static STATUS_T SelectTrack( + coOrd pos ) { track_p trk; char msg[STR_SIZE]; - if (((trk = OnTrack( &pos, FALSE, FALSE )) == NULL) && selectZero) { //If option set and !ctrl or unset and ctrl + if (((trk = OnTrack( &pos, FALSE, FALSE )) == NULL) + && selectZero) { //If option set and !ctrl or unset and ctrl SetAllTrackSelect( FALSE ); //Unselect all return C_CONTINUE; } - if (trk == NULL) return C_CONTINUE; + if (trk == NULL) { return C_CONTINUE; } if (!CheckTrackLayerSilent( trk ) ) { if (GetLayerFrozen(GetTrkLayer(trk)) ) { trk = NULL; @@ -3061,10 +3019,12 @@ static STATUS_T SelectTrack( DescribeTrack( trk, msg, sizeof msg ); InfoMessage( msg ); if (GetLayerModule(GetTrkLayer(trk))) { - if (((MyGetKeyState() & WKEY_CTRL) && (selectMode==0)) || (!(MyGetKeyState() & WKEY_CTRL) && (selectMode==1)) ) { + if (((MyGetKeyState() & WKEY_CTRL) && (selectMode==0)) + || (!(MyGetKeyState() & WKEY_CTRL) && (selectMode==1)) ) { DoModuleTracks(GetTrkLayer(trk),SelectOneTrack,!GetTrkSelected(trk)); } else { - SetAllTrackSelect( FALSE ); //Just this Track if selectMode = 0 and !CTRL or selectMode = 1 and CTRL + SetAllTrackSelect( + FALSE ); //Just this Track if selectMode = 0 and !CTRL or selectMode = 1 and CTRL DoModuleTracks(GetTrkLayer(trk),SelectOneTrack,TRUE); } RedrawSelectedTracksBoundary(); @@ -3085,57 +3045,62 @@ static STATUS_T SelectTrack( return C_CONTINUE; } -static STATUS_T Activate( coOrd pos) { +static STATUS_T Activate( coOrd pos) +{ track_p trk; if ((trk = OnTrack( &pos, TRUE, FALSE )) == NULL) { - return C_CONTINUE; + return C_CONTINUE; } if (GetLayerModule(GetTrkLayer(trk))) { return C_CONTINUE; } - if (QueryTrack(trk,Q_IS_ACTIVATEABLE)) ActivateTrack(trk); + if (QueryTrack(trk,Q_IS_ACTIVATEABLE)) { ActivateTrack(trk); } return C_CONTINUE; } -track_p IsInsideABox(coOrd pos) { +track_p IsInsideABox(coOrd pos) +{ track_p ts = NULL; while ( TrackIterate( &ts ) ) { - if (!GetLayerVisible( GetTrkLayer( ts))) continue; - if (!GetTrkSelected(ts)) continue; + if (!GetLayerVisible( GetTrkLayer( ts))) { continue; } + if (!GetTrkSelected(ts)) { continue; } coOrd hi,lo; GetBoundingBox(ts, &hi, &lo); double boundary = mainD.scale*5/mainD.dpi; - if ((pos.x>=lo.x-boundary && pos.x<=hi.x+boundary) && (pos.y>=lo.y-boundary && pos.y<=hi.y+boundary)) { + if ((pos.x>=lo.x-boundary && pos.x<=hi.x+boundary) && (pos.y>=lo.y-boundary + && pos.y<=hi.y+boundary)) { return ts; } } return NULL; } -void DrawHighlightBoxes(BOOL_T highlight_selected, BOOL_T select, track_p not_this) { +void DrawHighlightBoxes(BOOL_T highlight_selected, BOOL_T select, + track_p not_this) +{ track_p ts = NULL; coOrd origin,max; BOOL_T first = TRUE; while ( TrackIterate( &ts ) ) { - if ( !GetLayerVisible( GetTrkLayer( ts))) continue; - if (!GetTrkSelected(ts)) continue; + if ( !GetLayerVisible( GetTrkLayer( ts))) { continue; } + if (!GetTrkSelected(ts)) { continue; } if (GetLayerModule(GetTrkLayer(ts))) { DrawHighlightLayer(GetTrkLayer(ts)); } coOrd hi,lo; - if (highlight_selected && (ts != not_this)) DrawTrack(ts,&tempD,select?wDrawColorPreviewSelected:wDrawColorPreviewUnselected ); + if (highlight_selected && (ts != not_this)) { DrawTrack(ts,&tempD,select?wDrawColorPreviewSelected:wDrawColorPreviewUnselected ); } GetBoundingBox(ts, &hi, &lo); if (first) { origin = lo; max = hi; first = FALSE; } else { - if (lo.x <origin.x) origin.x = lo.x; - if (lo.y <origin.y) origin.y = lo.y; - if (hi.x >max.x) max.x = hi.x; - if (hi.y >max.y) max.y = hi.y; + if (lo.x <origin.x) { origin.x = lo.x; } + if (lo.y <origin.y) { origin.y = lo.y; } + if (hi.x >max.x) { max.x = hi.x; } + if (hi.y >max.y) { max.y = hi.y; } } } if (!first) { @@ -3152,19 +3117,23 @@ void DrawHighlightBoxes(BOOL_T highlight_selected, BOOL_T select, track_p not_th } static STATUS_T CallModify(wAction_t action, - coOrd pos ) { + coOrd pos ) +{ int rc = CmdModify(action,pos); - if (rc != C_CONTINUE) + if (rc != C_CONTINUE) { doingDouble = FALSE; + } return rc; } -static STATUS_T CallDescribe(wAction_t action, coOrd pos) { +static STATUS_T CallDescribe(wAction_t action, coOrd pos) +{ int rc = CmdDescribe(action, pos); return rc; } -static void CallPushDescribe(void * unused) { +static void CallPushDescribe(void * unused) +{ if (moveDescTrk) { CallDescribe(C_START, moveDescPos); CallDescribe(C_DOWN, moveDescPos); @@ -3175,7 +3144,8 @@ static void CallPushDescribe(void * unused) { static STATUS_T CmdSelect(wAction_t,coOrd); -static void CallPushModify(void * unused) { +static void CallPushModify(void * unused) +{ if (moveDescTrk) { CmdSelect(C_LDOUBLE, moveDescPos); } @@ -3183,8 +3153,8 @@ static void CallPushModify(void * unused) { } static STATUS_T CmdSelect( - wAction_t action, - coOrd pos ) + wAction_t action, + coOrd pos ) { static BOOL_T doingMove; @@ -3195,17 +3165,19 @@ static STATUS_T CmdSelect( STATUS_T rc=C_CONTINUE; static track_p trk = NULL; typedef enum {NOSHOW,SHOWMOVE,SHOWROTATE,SHOWMODIFY,SHOWACTIVATE} showType; - static showType showMode; +// static showType showMode; mode = AREA; - if (doingAlign || doingRotate || doingMove ) + if (doingAlign || doingRotate || doingMove ) { mode = MOVE; - else { - if ( (action == C_DOWN) || (action == C_RDOWN) || ((action&0xFF) == wActionExtKey) ) { + } else { + if ( (action == C_DOWN) || (action == C_RDOWN) + || ((action&0xFF) == wActionExtKey) ) { mode = AREA; - if ( ((action&0xFF) == wActionExtKey) || ( //Moves don't need to be in a box - ( MyGetKeyState() & (WKEY_SHIFT|WKEY_CTRL|WKEY_ALT)) && IsInsideABox(pos)) ) //But cursors do - { + if ( ((action&0xFF) == wActionExtKey) + || ( //Moves don't need to be in a box + ( MyGetKeyState() & (WKEY_SHIFT|WKEY_CTRL|WKEY_ALT)) + && IsInsideABox(pos)) ) { //But cursors do mode = MOVE; } } @@ -3218,7 +3190,7 @@ static STATUS_T CmdSelect( doingRotate = FALSE; doingAlign = FALSE; doingDouble = FALSE; - showMode = NOSHOW; +// showMode = NOSHOW; SelectArea( action, pos ); wMenuPushEnable( rotateAlignMI, FALSE ); wSetCursor(mainD.d,defaultCursor); @@ -3231,12 +3203,12 @@ static STATUS_T CmdSelect( if (doingDouble) { return CallModify(action,pos); } - showMode = NOSHOW; +// showMode = NOSHOW; DYNARR_RESET(trkSeg_t,anchors_da); coOrd p = pos; trk = OnTrack( &p, FALSE, FALSE ); track_p ht; - if ((selectedTrackCount==0) && (trk == NULL)) return C_CONTINUE; + if ((selectedTrackCount==0) && (trk == NULL)) { return C_CONTINUE; } if (trk && !CheckTrackLayerSilent( trk ) ) { if (GetLayerFrozen(GetTrkLayer(trk)) ) { trk = NULL; @@ -3248,25 +3220,25 @@ static STATUS_T CmdSelect( if ((ht = IsInsideABox(pos)) != NULL) { if ((MyGetKeyState()&WKEY_SHIFT)) { CreateMoveAnchor(pos); - showMode = SHOWMOVE; +// showMode = SHOWMOVE; } else if ((MyGetKeyState()&WKEY_CTRL)) { CreateRotateAnchor(pos); - showMode = SHOWROTATE; +// showMode = SHOWROTATE; } else if (!GetLayerModule(GetTrkLayer(ht))) { if (QueryTrack( ht, Q_CAN_MODIFY_CONTROL_POINTS ) || - QueryTrack( ht, Q_IS_CORNU ) || - (QueryTrack( ht, Q_IS_DRAW ) && !QueryTrack( ht, Q_IS_TEXT))) { + QueryTrack( ht, Q_IS_CORNU ) || + (QueryTrack( ht, Q_IS_DRAW ) && !QueryTrack( ht, Q_IS_TEXT))) { CreateModifyAnchor(pos); - showMode = SHOWMODIFY; +// showMode = SHOWMODIFY; } else { if (QueryTrack(ht,Q_IS_ACTIVATEABLE)) { CreateActivateAnchor(pos); - showMode = SHOWACTIVATE; - } else wSetCursor(mainD.d,defaultCursor); +// showMode = SHOWACTIVATE; + } else { wSetCursor(mainD.d,defaultCursor); } } - } else wSetCursor(mainD.d,defaultCursor); - } else wSetCursor(mainD.d,defaultCursor); - } else wSetCursor(mainD.d,defaultCursor); + } else { wSetCursor(mainD.d,defaultCursor); } + } else { wSetCursor(mainD.d,defaultCursor); } + } else { wSetCursor(mainD.d,defaultCursor); } break; case C_DOWN: @@ -3306,13 +3278,15 @@ static STATUS_T CmdSelect( SelectDelete(); break; } - /* No Break */ + /* No Break */ case C_RMOVE: case C_MOVE: if (doingDouble) { return CallModify(action,pos); } - if ((action&0xFF) == wActionExtKey && ((MyGetKeyState() & (WKEY_SHIFT|WKEY_CTRL)) == (WKEY_SHIFT|WKEY_CTRL))) { //Both + arrow + if ((action&0xFF) == wActionExtKey + && ((MyGetKeyState() & (WKEY_SHIFT|WKEY_CTRL)) == + (WKEY_SHIFT|WKEY_CTRL))) { //Both + arrow doingMove = TRUE; mode = MOVE; } @@ -3321,7 +3295,7 @@ static STATUS_T CmdSelect( case MOVE: if (SelectedTracksAreFrozen() || (selectedTrackCount==0)) { rc = C_TERMINATE; - tlist_da.cnt = 0; + DYNARR_RESET( track_p, tlist_da ); doingMove = FALSE; doingRotate = FALSE; } else if (doingRotate == TRUE) { @@ -3338,8 +3312,11 @@ static STATUS_T CmdSelect( break; default: ; } - if ((action&0xFF) == wActionExtKey && ((MyGetKeyState() & (WKEY_SHIFT|WKEY_CTRL)) == (WKEY_SHIFT|WKEY_CTRL))) //Both + if ((action&0xFF) == wActionExtKey + && ((MyGetKeyState() & (WKEY_SHIFT|WKEY_CTRL)) == + (WKEY_SHIFT|WKEY_CTRL))) { //Both doingMove = FALSE; + } return rc; break; case C_RUP: @@ -3392,24 +3369,26 @@ static STATUS_T CmdSelect( //Once doing a move or a rotate, make an early exit if (doingMove || doingRotate) { - if (anchors_da.cnt) { - DrawSegs( &tempD, zero, 0.0, &anchors(0), anchors_da.cnt, trackGauge, wDrawColorBlack ); - } + DrawSegsDA( &tempD, NULL, zero, 0.0, &anchors_da, trackGauge, wDrawColorBlack, + 0 ); return C_CONTINUE; } BOOL_T AreaSelect = FALSE; // Draw the selected area, no-op if none selected if (mode==AREA) { - AreaSelect = SelectArea( action, pos ); - if (AreaSelect) return C_CONTINUE; + AreaSelect = SelectArea( action, pos ); + if (AreaSelect) { return C_CONTINUE; } } // Highlight a whole Module's worth of tracks if we are hovering over one if (trk && GetLayerModule(GetTrkLayer(trk))) { - if ( (selectMode == 1) && ((MyGetKeyState() & (WKEY_CTRL|WKEY_SHIFT)) != WKEY_CTRL) ) - DoModuleTracks(GetTrkLayer(trk),DrawSingleTrack,!GetTrkSelected(trk)); //Toggle - else + if ( (selectMode == 1) + && ((MyGetKeyState() & (WKEY_CTRL|WKEY_SHIFT)) != WKEY_CTRL) ) { + DoModuleTracks(GetTrkLayer(trk),DrawSingleTrack, + !GetTrkSelected(trk)); //Toggle + } else { DoModuleTracks(GetTrkLayer(trk),DrawSingleTrack,TRUE); + } DrawHighlightLayer(GetTrkLayer(trk)); } @@ -3425,66 +3404,77 @@ static STATUS_T CmdSelect( } } else { //Handle the SHIFT+ which means SelectAllConnected case - if ((MyGetKeyState() & WKEY_SHIFT) ) - SelectConnectedTracks(trk, TRUE); //Highlight all connected + if ((MyGetKeyState() & WKEY_SHIFT) ) { + SelectConnectedTracks(trk, TRUE); //Highlight all connected + } //Normal case - handle track we are hovering over else { //Select=Add if (selectMode == 1) { if ((MyGetKeyState() & (WKEY_CTRL|WKEY_SHIFT)) == WKEY_CTRL) { //Only Highlight if adding otherwise show already selected - if (!GetTrkSelected(trk)) + if (!GetTrkSelected(trk)) { DrawTrack(trk,&tempD,wDrawColorPreviewSelected); - else + } else { DrawTrack(trk,&tempD,selectedColor); + } } else { - if (GetTrkSelected(trk)) - DrawTrack(trk,&tempD,wDrawColorPreviewUnselected); //Toggle - else + if (GetTrkSelected(trk)) { + DrawTrack(trk,&tempD,wDrawColorPreviewUnselected); //Toggle + } else { DrawTrack(trk,&tempD,wDrawColorPreviewSelected); + } } - //Select=Only + //Select=Only } else { if ((MyGetKeyState() & (WKEY_CTRL|WKEY_SHIFT)) == WKEY_CTRL) { - if (GetTrkSelected(trk)) - DrawTrack(trk,&tempD,wDrawColorPreviewUnselected); //Toggle - else + if (GetTrkSelected(trk)) { + DrawTrack(trk,&tempD,wDrawColorPreviewUnselected); //Toggle + } else { DrawTrack(trk,&tempD,wDrawColorPreviewSelected); + } } else { //Only Highlight if adding - if (!GetTrkSelected(trk)) + if (!GetTrkSelected(trk)) { DrawTrack(trk,&tempD,wDrawColorPreviewSelected ); - else + } else { DrawTrack(trk,&tempD,selectedColor); + } } } } // Now Highlight the rest of the tracks or Module if (GetLayerModule(GetTrkLayer(trk))) { - if (selectMode == 1 && ((MyGetKeyState() & (WKEY_CTRL|WKEY_SHIFT)) != WKEY_CTRL) ) - DoModuleTracks(GetTrkLayer(trk),DrawSingleTrack,!GetTrkSelected(trk)); //Toggle - else + if (selectMode == 1 + && ((MyGetKeyState() & (WKEY_CTRL|WKEY_SHIFT)) != WKEY_CTRL) ) { + DoModuleTracks(GetTrkLayer(trk),DrawSingleTrack, + !GetTrkSelected(trk)); //Toggle + } else { DoModuleTracks(GetTrkLayer(trk),DrawSingleTrack,TRUE); + } DrawHighlightLayer(GetTrkLayer(trk)); } //Select=Add if (selectMode == 1) { - if (((MyGetKeyState() & (WKEY_CTRL|WKEY_SHIFT)) == WKEY_CTRL)) + if (((MyGetKeyState() & (WKEY_CTRL|WKEY_SHIFT)) == WKEY_CTRL)) { HighlightSelectedTracks(trk, FALSE, TRUE); - else - HighlightSelectedTracks(trk, TRUE, FALSE); // Highlight all others selected - //Select=Only + } else { + HighlightSelectedTracks(trk, TRUE, + FALSE); // Highlight all others selected + } + //Select=Only } else { - if (((MyGetKeyState() & (WKEY_CTRL|WKEY_SHIFT)) != WKEY_CTRL)) + if (((MyGetKeyState() & (WKEY_CTRL|WKEY_SHIFT)) != WKEY_CTRL)) { HighlightSelectedTracks(trk, FALSE, TRUE); - else - HighlightSelectedTracks(trk, TRUE, FALSE); // Highlight all others selected + } else { + HighlightSelectedTracks(trk, TRUE, + FALSE); // Highlight all others selected + } } } //Finally add the anchors for any actions or snaps - if (anchors_da.cnt) { - DrawSegs( &tempD, zero, 0.0, &anchors(0), anchors_da.cnt, trackGauge, wDrawColorBlack ); - } + DrawSegsDA( &tempD, NULL, zero, 0.0, &anchors_da, trackGauge, wDrawColorBlack, + 0 ); return rc; @@ -3498,8 +3488,9 @@ static STATUS_T CmdSelect( if (doingAlign) { rc = CmdRotate (C_DOWN, pos); rc = CmdRotate (C_UP, pos); - } else + } else { rc = SelectTrack( pos ); + } doingRotate = FALSE; doingMove = FALSE; return rc; @@ -3512,23 +3503,23 @@ static STATUS_T CmdSelect( return C_CONTINUE; } switch (mode) { - case AREA: - if ((ht = OnTrack(&pos,FALSE,FALSE))!=NULL) { - if (QueryTrack( ht, Q_CAN_MODIFY_CONTROL_POINTS ) || - QueryTrack( ht, Q_IS_CORNU ) || - (QueryTrack( ht, Q_IS_DRAW ) && !QueryTrack( ht, Q_IS_TEXT ))) { - doingDouble = TRUE; - CallModify(C_START,pos); - if (doingDouble == FALSE) return C_CONTINUE; - CallModify(C_LDOUBLE,pos); - } else if (QueryTrack( ht, Q_IS_ACTIVATEABLE)){ - return Activate(pos); - } + case AREA: + if ((ht = OnTrack(&pos,FALSE,FALSE))!=NULL) { + if (QueryTrack( ht, Q_CAN_MODIFY_CONTROL_POINTS ) || + QueryTrack( ht, Q_IS_CORNU ) || + (QueryTrack( ht, Q_IS_DRAW ) && !QueryTrack( ht, Q_IS_TEXT ))) { + doingDouble = TRUE; + CallModify(C_START,pos); + if (doingDouble == FALSE) { return C_CONTINUE; } + CallModify(C_LDOUBLE,pos); + } else if (QueryTrack( ht, Q_IS_ACTIVATEABLE)) { + return Activate(pos); } - break; - case MOVE: - default: - break; + } + break; + case MOVE: + default: + break; } break; @@ -3540,7 +3531,7 @@ static STATUS_T CmdSelect( if (selectedTrackCount <= 0) { wMenuPopupShow( selectPopup1M ); } else { - track_p trk = OnTrack(&pos, FALSE, FALSE); //Note pollutes pos if turntable + track_p trk = OnTrack(&pos, FALSE, FALSE); //Note pollutes pos if turntable SetUpMenu2(pos,trk); wMenuPopupShow( selectPopup2M ); } @@ -3555,7 +3546,8 @@ static STATUS_T CmdSelect( } if ((action>>8) == 'c') { panCenter = pos; - LOG( log_pan, 2, ( "PanCenter:Sel-%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); + LOG( log_pan, 2, ( "PanCenter:Sel-%d %0.3f %0.3f\n", __LINE__, panCenter.x, + panCenter.y ) ); PanHere(I2VP(0)); } if ((action>>8) == 'e') { @@ -3565,120 +3557,149 @@ static STATUS_T CmdSelect( PanMenuEnter(I2VP('o')); } if ((action>>8) == '?') { - if((moveDescTrk = OnTrack(&pos,FALSE,FALSE)) != NULL) + if((moveDescTrk = OnTrack(&pos,FALSE,FALSE)) != NULL) { moveDescPos = pos; - CallPushDescribe(I2VP(0)); + } + CallPushDescribe(I2VP(0)); wSetCursor(mainD.d,defaultCursor); moveDescTrk = NULL; } break; case C_CONFIRM: - if (doingDouble) + if (doingDouble) { return CallModify(action,pos); + } return C_CONTINUE; case C_FINISH: if (doingDouble) { CallModify(C_OK,pos); CallModify(C_FINISH,pos); } - if (doingMove) UndoEnd(); + if (doingMove) { UndoEnd(); } doingDouble = FALSE; wSetCursor(mainD.d,defaultCursor); break; default: - if (doingDouble) return CallModify(action, pos); + if (doingDouble) { return CallModify(action, pos); } } return C_CONTINUE; } -#include "bitmaps/select.xpm" -#include "bitmaps/delete.xpm" -#include "bitmaps/tunnel.xpm" -#include "bitmaps/bridge.xpm" -#include "bitmaps/move.xpm" -#include "bitmaps/rotate.xpm" -#include "bitmaps/reflect.xpm" -#include "bitmaps/description.xpm" +#include "bitmaps/select.xpm3" +#include "bitmaps/delete.xpm3" +#include "bitmaps/tunnel.xpm3" +#include "bitmaps/ties.xpm3" +#include "bitmaps/bridge.xpm3" +#include "bitmaps/roadbed.xpm3" +#include "bitmaps/move.xpm3" +#include "bitmaps/rotate.xpm3" +#include "bitmaps/reflect.xpm3" +#include "bitmaps/description.xpm3" static void SetMoveMode( char * line ) { long tmp = atol( line ); moveMode = tmp & 0x0F; - if (moveMode < 0 || moveMode > MAXMOVEMODE) + if (moveMode < 0 || moveMode > MAXMOVEMODE) { moveMode = MAXMOVEMODE; + } enableMoveDraw = ((tmp&0x10) == 0); } -static void moveDescription( void * unused ) { - if (!moveDescTrk) return; +static void moveDescription( void * unused ) +{ + if (!moveDescTrk) { return; } int hidden = GetTrkBits( moveDescTrk) &TB_HIDEDESC ; - if (hidden) + if (hidden) { ClrTrkBits( moveDescTrk, TB_HIDEDESC ); - else + } else { SetTrkBits( moveDescTrk, TB_HIDEDESC ); + } MainRedraw(); } EXPORT void InitCmdSelect( wMenu_p menu ) { - selectCmdInx = AddMenuButton( menu, CmdSelect, "cmdSelect", _("Select"), wIconCreatePixMap(select_xpm[iconSize]), - LEVEL0, IC_CANCEL|IC_POPUP|IC_LCLICK|IC_CMDMENU|IC_WANT_MOVE|IC_WANT_MODKEYS, ACCL_SELECT, NULL ); + selectCmdInx = AddMenuButton( menu, CmdSelect, "cmdSelect", _("Select"), + wIconCreatePixMap(select_xpm3[iconSize]), + LEVEL0, IC_CANCEL|IC_POPUP|IC_LCLICK|IC_CMDMENU|IC_WANT_MOVE|IC_WANT_MODKEYS, + ACCL_SELECT, NULL ); } -extern wIndex_t trainCmdInx; -EXPORT void InitCmdSelect2( wMenu_p menu ) { +EXPORT void InitCmdSelect2( wMenu_p menu ) +{ - endpt_bm = wDrawBitMapCreate( mainD.d, bmendpt_width, bmendpt_width, 7, 7, bmendpt_bits ); - angle_bm[0] = wDrawBitMapCreate( mainD.d, bma90_width, bma90_width, 7, 7, bma90_bits ); - angle_bm[1] = wDrawBitMapCreate( mainD.d, bma135_width, bma135_width, 7, 7, bma135_bits ); - angle_bm[2] = wDrawBitMapCreate( mainD.d, bma0_width, bma0_width, 7, 7, bma0_bits ); - angle_bm[3] = wDrawBitMapCreate( mainD.d, bma45_width, bma45_width, 7, 7, bma45_bits ); + endpt_bm = wDrawBitMapCreate( mainD.d, bmendpt_width, bmendpt_width, 7, 7, + bmendpt_bits ); + angle_bm[0] = wDrawBitMapCreate( mainD.d, bma90_width, bma90_width, 7, 7, + bma90_bits ); + angle_bm[1] = wDrawBitMapCreate( mainD.d, bma135_width, bma135_width, 7, 7, + bma135_bits ); + angle_bm[2] = wDrawBitMapCreate( mainD.d, bma0_width, bma0_width, 7, 7, + bma0_bits ); + angle_bm[3] = wDrawBitMapCreate( mainD.d, bma45_width, bma45_width, 7, 7, + bma45_bits ); AddPlaybackProc( SETMOVEMODE, (playbackProc_p)SetMoveMode, NULL ); wPrefGetInteger( "draw", "movemode", &moveMode, MAXMOVEMODE ); - if (moveMode > MAXMOVEMODE || moveMode < 0) + if (moveMode > MAXMOVEMODE || moveMode < 0) { moveMode = MAXMOVEMODE; + } selectPopup1M = MenuRegister( "Select Mode Menu" ); wMenuPushCreate(selectPopup1M, "", _("Undo"), 0, UndoUndo, NULL); wMenuPushCreate(selectPopup1M, "", _("Redo"), 0, UndoRedo, NULL); wMenuSeparatorCreate( selectPopup1M ); - wMenuPushCreate(selectPopup1M, "cmdDescribeMode", GetBalloonHelpStr("cmdModifyMode"), 0, DoCommandB, I2VP(modifyCmdInx)); - wMenuPushCreate(selectPopup1M, "cmdPanMode", GetBalloonHelpStr("cmdPanMode"), 0, DoCommandB, I2VP(panCmdInx)); - wMenuPushCreate(selectPopup1M, "cmdTrainMode", GetBalloonHelpStr("cmdTrainMode"), 0, DoCommandB, I2VP(trainCmdInx)); + wMenuPushCreate(selectPopup1M, "cmdDescribeMode", + GetBalloonHelpStr("cmdModifyMode"), 0, DoCommandB, I2VP(modifyCmdInx)); + wMenuPushCreate(selectPopup1M, "cmdPanMode", GetBalloonHelpStr("cmdPanMode"), 0, + DoCommandB, I2VP(panCmdInx)); + wMenuPushCreate(selectPopup1M, "cmdTrainMode", + GetBalloonHelpStr("cmdTrainMode"), 0, DoCommandB, I2VP(trainCmdInx)); wMenuSeparatorCreate( selectPopup1M ); wMenuPushCreate(selectPopup1M, "", _("Zoom In"), 0, DoZoomUp, I2VP(1)); - wMenuPushCreate( selectPopup1M, "", _("Zoom to extents - 'e'"), 0, DoZoomExtents, I2VP(0) ); + wMenuPushCreate( selectPopup1M, "", _("Zoom to extents - 'e'"), 0, + DoZoomExtents, I2VP(0) ); wMenu_p zoomPop1 = wMenuMenuCreate(selectPopup1M, "", _("&Zoom")); InitCmdZoom(NULL, NULL, zoomPop1, NULL); wMenuPushCreate(selectPopup1M, "", _("Zoom Out"), 0, DoZoomDown, I2VP(1)); - wMenuPushCreate(selectPopup1M, "", _("Pan to Origin - 'o'/'0'"), 0, PanMenuEnter, I2VP( 'o')); - wMenuPushCreate(selectPopup1M, "", _("Pan Center Here - 'c'"), 0, PanHere, I2VP( 3)); + wMenuPushCreate(selectPopup1M, "", _("Pan to Origin - 'o'/'0'"), 0, + PanMenuEnter, I2VP( 'o')); + wMenuPushCreate(selectPopup1M, "", _("Pan Center Here - 'c'"), 0, PanHere, + I2VP( 3)); wMenuSeparatorCreate( selectPopup1M ); - wMenuPushCreate(selectPopup1M, "", _("Select All"), 0,(wMenuCallBack_p) SetAllTrackSelect, I2VP( 1)); - wMenuPushCreate(selectPopup1M, "",_("Select Current Layer"), 0, SelectCurrentLayer, I2VP( 0)); + wMenuPushCreate(selectPopup1M, "", _("Select All"), 0, + (wMenuCallBack_p) SetAllTrackSelect, I2VP( 1)); + wMenuPushCreate(selectPopup1M, "",_("Select Current Layer"), 0, + SelectCurrentLayer, I2VP( 0)); AddIndexMenu( selectPopup1M, SelectByIndex); wMenuSeparatorCreate( selectPopup1M ); selectPopup2M = MenuRegister( "Track Selected Menu " ); - wMenuPushCreate(selectPopup2M, "", _("Undo"), 0, UndoUndo , NULL); - wMenuPushCreate(selectPopup2M, "", _("Redo"), 0, UndoRedo , NULL); + wMenuPushCreate(selectPopup2M, "", _("Undo"), 0, UndoUndo, NULL); + wMenuPushCreate(selectPopup2M, "", _("Redo"), 0, UndoRedo, NULL); wMenuSeparatorCreate( selectPopup2M ); wMenuPushCreate(selectPopup2M, "", _("Zoom In"), 0, DoZoomUp, I2VP( 1)); wMenuPushCreate(selectPopup2M, "", _("Zoom Out"), 0, DoZoomDown, I2VP( 1)); - wMenuPushCreate( selectPopup2M, "", _("Zoom to extents - 'e'"), 0, DoZoomExtents, I2VP( 0)); - wMenuPushCreate( selectPopup2M, "", _("Zoom to selected - 's'"), 0, DoZoomExtents, I2VP( 1)); - wMenuPushCreate(selectPopup2M, "", _("Pan Center Here - 'c'"), 0, PanHere, I2VP( 3)); + wMenuPushCreate( selectPopup2M, "", _("Zoom to extents - 'e'"), 0, + DoZoomExtents, I2VP( 0)); + wMenuPushCreate( selectPopup2M, "", _("Zoom to selected - 's'"), 0, + DoZoomExtents, I2VP( 1)); + wMenuPushCreate(selectPopup2M, "", _("Pan Center Here - 'c'"), 0, PanHere, + I2VP( 3)); wMenuSeparatorCreate( selectPopup2M ); AddIndexMenu( selectPopup2M, SelectByIndex); - wMenuPushCreate(selectPopup2M, "", _("Deselect All"), 0, (wMenuCallBack_p) SetAllTrackSelect, I2VP( 0)); + wMenuPushCreate(selectPopup2M, "", _("Deselect All"), 0, + (wMenuCallBack_p) SetAllTrackSelect, I2VP( 0)); wMenuSeparatorCreate( selectPopup2M ); - wMenuPushCreate(selectPopup2M, "", _("Properties -'?'"), 0, CallPushDescribe, I2VP(0)); - menuPushModify = wMenuPushCreate(selectPopup2M, "", _("Modify/Activate Track"), 0, CallPushModify, I2VP(0)); + wMenuPushCreate(selectPopup2M, "", _("Properties -'?'"), 0, CallPushDescribe, + I2VP(0)); + menuPushModify = wMenuPushCreate(selectPopup2M, "", _("Modify/Activate Track"), + 0, CallPushModify, I2VP(0)); wMenuSeparatorCreate( selectPopup2M ); wMenuPushCreate(selectPopup2M, "", _("Cut"), 0, EditCut, I2VP( 0)); wMenuPushCreate(selectPopup2M, "", _("Copy"), 0, EditCopy, I2VP( 0)); @@ -3687,23 +3708,40 @@ EXPORT void InitCmdSelect2( wMenu_p menu ) { AddMoveMenu( selectPopup2M, QuickMove); selectPopup2RM = wMenuMenuCreate(selectPopup2M, "", _("Rotate...")); AddRotateMenu( selectPopup2RM, QuickRotate ); - rotateAlignMI = wMenuPushCreate( selectPopup2RM, "", _("Align"), 0, RotateAlign, I2VP(1) ); + rotateAlignMI = wMenuPushCreate( selectPopup2RM, "", _("Align"), 0, RotateAlign, + I2VP(1) ); wMenuSeparatorCreate( selectPopup2M ); - descriptionMI = wMenuPushCreate(selectPopup2M, "cmdMoveLabel", _("Show/Hide Description"), 0, moveDescription, I2VP(0)); + descriptionMI = wMenuPushCreate(selectPopup2M, "cmdMoveLabel", + _("Show/Hide Description"), 0, moveDescription, I2VP(0)); wMenuSeparatorCreate( selectPopup2M ); - hideMI = wMenuPushCreate(selectPopup2M, "", _("Hide/NoHide"), 0, SelectTunnel, I2VP( 0)); - bridgeMI = wMenuPushCreate(selectPopup2M, "", _("Bridge/NoBridge"), 0, SelectBridge, I2VP( 0)); - tiesMI = wMenuPushCreate(selectPopup2M, "", _("NoTies/Ties"), 0, SelectTies, I2VP( 0)); + tiesMI = wMenuPushCreate(selectPopup2M, "", _("Ties/NoTies"), 0, SelectTies, + I2VP( 0)); + hideMI = wMenuPushCreate(selectPopup2M, "", _("Hide/NoHide"), 0, SelectTunnel, + I2VP( 0)); + bridgeMI = wMenuPushCreate(selectPopup2M, "", _("Bridge/NoBridge"), 0, + SelectBridge, I2VP( 0)); + roadbedMI = wMenuPushCreate(selectPopup2M, "", _("Roadbed/NoRoadbed"), 0, + SelectRoadbed, I2VP( 0)); + tiesMI = wMenuPushCreate(selectPopup2M, "", _("NoTies/Ties"), 0, SelectTies, + I2VP( 0)); selectPopup2TM = wMenuMenuCreate(selectPopup2M, "", _("Thickness...")); - wMenuPushCreate( selectPopup2TM, "", _("Thin Tracks"), 0, SelectTrackWidth, I2VP(0 )); - wMenuPushCreate( selectPopup2TM, "", _("Medium Tracks"), 0, SelectTrackWidth, I2VP(2 )); - wMenuPushCreate( selectPopup2TM, "", _("Thick Tracks"), 0, SelectTrackWidth, I2VP(3 )); + wMenuPushCreate( selectPopup2TM, "", _("Thin Tracks"), 0, SelectTrackWidth, + I2VP(0 )); + wMenuPushCreate( selectPopup2TM, "", _("Medium Tracks"), 0, SelectTrackWidth, + I2VP(2 )); + wMenuPushCreate( selectPopup2TM, "", _("Thick Tracks"), 0, SelectTrackWidth, + I2VP(3 )); selectPopup2TYM = wMenuMenuCreate( selectPopup2M, "", _("LineType...") ); - wMenuPushCreate( selectPopup2TYM, "", _("Solid Line"), 0, SelectLineType, I2VP(0 )); - wMenuPushCreate( selectPopup2TYM, "", _("Dashed Line"), 0, SelectLineType, I2VP(1 )); - wMenuPushCreate( selectPopup2TYM, "", _("Dotted Line"), 0, SelectLineType, I2VP(2 )); - wMenuPushCreate( selectPopup2TYM, "", _("Dash-Dotted Line"), 0, SelectLineType, I2VP(3 )); - wMenuPushCreate( selectPopup2TYM, "", _("Dash-Dot-Dotted Line"), 0, SelectLineType, I2VP(4 )); + wMenuPushCreate( selectPopup2TYM, "", _("Solid Line"), 0, SelectLineType, + I2VP(0 )); + wMenuPushCreate( selectPopup2TYM, "", _("Dashed Line"), 0, SelectLineType, + I2VP(1 )); + wMenuPushCreate( selectPopup2TYM, "", _("Dotted Line"), 0, SelectLineType, + I2VP(2 )); + wMenuPushCreate( selectPopup2TYM, "", _("Dash-Dotted Line"), 0, SelectLineType, + I2VP(3 )); + wMenuPushCreate( selectPopup2TYM, "", _("Dash-Dot-Dotted Line"), 0, + SelectLineType, I2VP(4 )); wMenuSeparatorCreate( selectPopup2M ); wMenuPushCreate(selectPopup2M, "", _("Move To Front"), 0, SelectAbove,I2VP( 0)); wMenuPushCreate(selectPopup2M, "", _("Move To Back"), 0, SelectBelow, I2VP( 0)); @@ -3711,8 +3749,6 @@ EXPORT void InitCmdSelect2( wMenu_p menu ) { wMenuPushCreate(selectPopup2M, "", _("Group"), 0, DoGroup, I2VP( 0)); wMenuPushCreate(selectPopup2M, "", _("UnGroup"), 0, DoUngroup, I2VP( 0)); wMenuSeparatorCreate( selectPopup2M ); - - ParamRegister( &rescalePG ); } @@ -3720,38 +3756,58 @@ EXPORT void InitCmdSelect2( wMenu_p menu ) { EXPORT void InitCmdDelete( void ) { wIcon_p icon; - icon = wIconCreatePixMap( delete_xpm[iconSize] ); - AddToolbarButton( "cmdDelete", icon, IC_SELECTED, (wButtonCallBack_p)SelectDelete, 0 ); + icon = wIconCreatePixMap( delete_xpm3[iconSize] ); + AddToolbarButton( "cmdDelete", icon, IC_SELECTED, + (wButtonCallBack_p)SelectDelete, 0 ); +} + +EXPORT void InitCmdTies( void ) +{ + wIcon_p icon; + icon = wIconCreatePixMap( ties_xpm3[iconSize] ); + AddToolbarButton( "cmdTies", icon, IC_SELECTED|IC_POPUP, SelectTies, NULL ); } EXPORT void InitCmdTunnel( void ) { wIcon_p icon; - icon = wIconCreatePixMap( tunnel_xpm[iconSize] ); + icon = wIconCreatePixMap( tunnel_xpm3[iconSize] ); AddToolbarButton( "cmdTunnel", icon, IC_SELECTED|IC_POPUP, SelectTunnel, NULL ); } EXPORT void InitCmdBridge( void) { wIcon_p icon; - icon = wIconCreatePixMap( bridge_xpm[iconSize] ); + icon = wIconCreatePixMap( bridge_xpm3[iconSize] ); AddToolbarButton( "cmdBridge", icon, IC_SELECTED|IC_POPUP, SelectBridge, NULL ); } +EXPORT void InitCmdRoadbed( void) +{ + wIcon_p icon; + icon = wIconCreatePixMap( roadbed_xpm3[iconSize] ); + AddToolbarButton( "cmdRoadbed", icon, IC_SELECTED|IC_POPUP, SelectRoadbed, + NULL ); +} + EXPORT void InitCmdMoveDescription( wMenu_p menu ) { - AddMenuButton( menu, CmdMoveDescription, "cmdMoveLabel", _("Move Description"), wIconCreatePixMap(description_xpm[iconSize]), - LEVEL0, IC_STICKY|IC_POPUP3|IC_CMDMENU|IC_WANT_MOVE, ACCL_MOVEDESC, I2VP( 0 )); + AddMenuButton( menu, CmdMoveDescription, "cmdMoveLabel", _("Move Description"), + wIconCreatePixMap(description_xpm3[iconSize]), + LEVEL0, IC_STICKY|IC_POPUP3|IC_CMDMENU|IC_WANT_MOVE, ACCL_MOVEDESC, I2VP( 0 )); } EXPORT void InitCmdMove( wMenu_p menu ) { - moveCmdInx = AddMenuButton( menu, CmdMove, "cmdMove", _("Move"), wIconCreatePixMap(move_xpm[iconSize]), - LEVEL0, IC_STICKY|IC_SELECTED|IC_CMDMENU|IC_WANT_MOVE, ACCL_MOVE, NULL ); - rotateCmdInx = AddMenuButton( menu, CmdRotate, "cmdRotate", _("Rotate"), wIconCreatePixMap(rotate_xpm[iconSize]), - LEVEL0, IC_STICKY|IC_SELECTED|IC_CMDMENU|IC_WANT_MOVE, ACCL_ROTATE, NULL ); - flipCmdInx = AddMenuButton( menu, CmdFlip, "cmdFlip", _("Flip"), wIconCreatePixMap(reflect_xpm[iconSize]), - LEVEL0, IC_STICKY|IC_SELECTED|IC_CMDMENU, ACCL_FLIP, NULL ); + moveCmdInx = AddMenuButton( menu, CmdMove, "cmdMove", _("Move"), + wIconCreatePixMap(move_xpm3[iconSize]), + LEVEL0, IC_STICKY|IC_SELECTED|IC_CMDMENU|IC_WANT_MOVE, ACCL_MOVE, NULL ); + rotateCmdInx = AddMenuButton( menu, CmdRotate, "cmdRotate", _("Rotate"), + wIconCreatePixMap(rotate_xpm3[iconSize]), + LEVEL0, IC_STICKY|IC_SELECTED|IC_CMDMENU|IC_WANT_MOVE, ACCL_ROTATE, NULL ); + flipCmdInx = AddMenuButton( menu, CmdFlip, "cmdFlip", _("Flip"), + wIconCreatePixMap(reflect_xpm3[iconSize]), + LEVEL0, IC_STICKY|IC_SELECTED|IC_CMDMENU, ACCL_FLIP, NULL ); } diff --git a/app/bin/cselect.h b/app/bin/cselect.h index 0f36cfd..9227032 100644 --- a/app/bin/cselect.h +++ b/app/bin/cselect.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef CSELECT_H @@ -29,6 +29,10 @@ extern wIndex_t selectCmdInx; extern wIndex_t moveCmdInx; extern wIndex_t rotateCmdInx; +extern wIndex_t flipCmdInx; + +extern long selectMode; +extern long selectZero; extern int incrementalDrawLimit; extern long selectedTrackCount; @@ -37,6 +41,7 @@ void OrphanedTrackSelect( void * unused ); void SetAllTrackSelect( BOOL_T ); void SelectTunnel( void * unused ); void SelectBridge( void * unused ); +void SelectRoadbed( void * unused ); void SelectTies( void * unused ); void SelectRecount( void ); void SelectTrackWidth( void* ); @@ -51,9 +56,11 @@ void ClearElevations( void * unused ); void AddElevations( DIST_T ); void DoRefreshCompound( void * unused ); void WriteSelectedTracksToTempSegs( void ); -void DoRescale( void *unused ); +void GetSelectedBounds( coOrd *, coOrd * ); STATUS_T CmdMoveDescription( wAction_t, coOrd ); void DrawHighlightBoxes(BOOL_T, BOOL_T,track_p); void HighlightSelectedTracks(track_p trk_ignore, BOOL_T keep, BOOL_T invert ); +typedef BOOL_T (*doSelectedTrackCallBack_t)(track_p, BOOL_T); +void DoSelectedTracks( doSelectedTrackCallBack_t doit ); #endif diff --git a/app/bin/csensor.c b/app/bin/csensor.c index b6f2224..761b511 100644 --- a/app/bin/csensor.c +++ b/app/bin/csensor.c @@ -4,8 +4,8 @@ /* -*- C -*- **************************************************************** * - * System : - * Module : + * System : + * Module : * Object Name : $RCSfile$ * Revision : $Revision$ * Date : $Date$ @@ -14,12 +14,12 @@ * Created : Sun Mar 5 16:01:37 2017 * Last Modified : <170314.1407> * - * Description + * Description * * Notes * * History - * + * **************************************************************************** * * Copyright (C) 2017 Robert Heller D/B/A Deepwoods Software @@ -38,13 +38,13 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * * - * * ****************************************************************************/ -static const char rcsid[] = "@(#) : $Id$"; +//static const char rcsid[] = "@(#) : $Id$"; #include "compound.h" #include "cselect.h" @@ -54,7 +54,6 @@ static const char rcsid[] = "@(#) : $Id$"; #include "layout.h" #include "param.h" #include "track.h" -#include "trackx.h" #include "common-ui.h" #ifdef UTFCONVERT #include "include/utf8convert.h" @@ -73,257 +72,261 @@ static drawCmd_t sensorD = { 1.0, 0.0, {0.0,0.0}, {0.0,0.0}, - Pix2CoOrd, CoOrd2Pix }; + Pix2CoOrd, CoOrd2Pix +}; static char sensorName[STR_SHORT_SIZE]; static char sensorScript[STR_LONG_SIZE]; #endif typedef struct sensorData_t { - extraDataBase_t base; - coOrd orig; - BOOL_T IsHilite; - char * name; - char * script; + extraDataBase_t base; + coOrd orig; + BOOL_T IsHilite; + char * name; + char * script; } sensorData_t, *sensorData_p; static sensorData_p GetsensorData ( track_p trk ) { - return GET_EXTRA_DATA( trk, T_SENSOR, sensorData_t ); + return GET_EXTRA_DATA( trk, T_SENSOR, sensorData_t ); } #define RADIUS 6 #define sensor_SF (3.0) -static void DDrawSensor(drawCmd_p d, coOrd orig, DIST_T scaleRatio, - wDrawColor color ) +static void DDrawSensor(drawCmd_p d, coOrd orig, DIST_T scaleRatio, + wDrawColor color ) { - coOrd p1, p2; - - p1 = orig; - DrawFillCircle(d,p1, RADIUS * sensor_SF / scaleRatio,color); - Translate (&p2, orig, 45, RADIUS * sensor_SF / scaleRatio); - DrawLine(d, p1, p2, 2, wDrawColorWhite); - Translate (&p2, orig, 45+90, RADIUS * sensor_SF / scaleRatio); - DrawLine(d, p1, p2, 2, wDrawColorWhite); - Translate (&p2, orig, 45+180, RADIUS * sensor_SF / scaleRatio); - DrawLine(d, p1, p2, 2, wDrawColorWhite); - Translate (&p2, orig, 45+270, RADIUS * sensor_SF / scaleRatio); - DrawLine(d, p1, p2, 2, wDrawColorWhite); + coOrd p1, p2; + + p1 = orig; + DrawFillCircle(d,p1, RADIUS * sensor_SF / scaleRatio,color); + Translate (&p2, orig, 45, RADIUS * sensor_SF / scaleRatio); + DrawLine(d, p1, p2, 2, wDrawColorWhite); + Translate (&p2, orig, 45+90, RADIUS * sensor_SF / scaleRatio); + DrawLine(d, p1, p2, 2, wDrawColorWhite); + Translate (&p2, orig, 45+180, RADIUS * sensor_SF / scaleRatio); + DrawLine(d, p1, p2, 2, wDrawColorWhite); + Translate (&p2, orig, 45+270, RADIUS * sensor_SF / scaleRatio); + DrawLine(d, p1, p2, 2, wDrawColorWhite); } static void DrawSensor (track_p t, drawCmd_p d, wDrawColor color ) { - sensorData_p xx = GetsensorData(t); - DDrawSensor(d,xx->orig,GetScaleRatio(GetTrkScale(t)),color); + sensorData_p xx = GetsensorData(t); + DDrawSensor(d,xx->orig,GetScaleRatio(GetTrkScale(t)),color); } -static void SensorBoundingBox (coOrd orig, DIST_T scaleRatio, coOrd *hi, - coOrd *lo) +static void SensorBoundingBox (coOrd orig, DIST_T scaleRatio, coOrd *hi, + coOrd *lo) { - coOrd p1, p2; - - p1 = orig; - Translate (&p1, orig, 0, -RADIUS * sensor_SF / scaleRatio); - Translate (&p2, orig, 0, RADIUS * sensor_SF / scaleRatio); - *hi = p1; *lo = p1; - if (p2.x > hi->x) hi->x = p2.x; - if (p2.x < lo->x) lo->x = p2.x; - if (p2.y > hi->y) hi->y = p2.y; - if (p2.y < lo->y) lo->y = p2.y; -} + coOrd p1, p2; + + p1 = orig; + Translate (&p1, orig, 0, -RADIUS * sensor_SF / scaleRatio); + Translate (&p2, orig, 0, RADIUS * sensor_SF / scaleRatio); + *hi = p1; *lo = p1; + if (p2.x > hi->x) { hi->x = p2.x; } + if (p2.x < lo->x) { lo->x = p2.x; } + if (p2.y > hi->y) { hi->y = p2.y; } + if (p2.y < lo->y) { lo->y = p2.y; } +} static void ComputeSensorBoundingBox (track_p t ) { - coOrd lo, hi; - sensorData_p xx = GetsensorData(t); - SensorBoundingBox(xx->orig, GetScaleRatio(GetTrkScale(t)), &hi, &lo); - SetBoundingBox(t, hi, lo); + coOrd lo, hi; + sensorData_p xx = GetsensorData(t); + SensorBoundingBox(xx->orig, GetScaleRatio(GetTrkScale(t)), &hi, &lo); + SetBoundingBox(t, hi, lo); } static DIST_T DistanceSensor (track_p t, coOrd * p ) { - sensorData_p xx = GetsensorData(t); - return FindDistance(xx->orig, *p); + sensorData_p xx = GetsensorData(t); + return FindDistance(xx->orig, *p); } static struct { - char name[STR_SHORT_SIZE]; - coOrd pos; - char script[STR_LONG_SIZE]; + char name[STR_SHORT_SIZE]; + coOrd pos; + char script[STR_LONG_SIZE]; } sensorProperties; typedef enum { NM, PS, SC } sensorDesc_e; static descData_t sensorDesc[] = { - /* NM */ { DESC_STRING, N_("Name"), &sensorProperties.name, sizeof(sensorProperties.name) }, - /* PS */ { DESC_POS, N_("Position"), &sensorProperties.pos }, - /* SC */ { DESC_STRING, N_("Script"), &sensorProperties.script, sizeof(sensorProperties.script) }, - { DESC_NULL } }; + /* NM */ { DESC_STRING, N_("Name"), &sensorProperties.name, sizeof(sensorProperties.name) }, + /* PS */ { DESC_POS, N_("Position"), &sensorProperties.pos }, + /* SC */ { DESC_STRING, N_("Script"), &sensorProperties.script, sizeof(sensorProperties.script) }, + { DESC_NULL } +}; static void UpdateSensorProperties ( track_p trk, int inx, descData_p - descUpd, BOOL_T needUndoStart ) + descUpd, BOOL_T needUndoStart ) { - sensorData_p xx = GetsensorData(trk); - const char *thename, *thescript; - char *newName, *newScript; - unsigned int max_str; - BOOL_T changed, nChanged, pChanged, sChanged; - - switch (inx) { - case NM: - break; - case PS: - break; - case SC: - break; - case -1: - changed = nChanged = pChanged = sChanged = FALSE; - thename = wStringGetValue( (wString_p) sensorDesc[NM].control0 ); - if (strcmp(thename,xx->name) != 0) { - nChanged = changed = TRUE; - max_str = sensorDesc[NM].max_string; + sensorData_p xx = GetsensorData(trk); + const char *thename, *thescript; + char *newName, *newScript = NULL; + unsigned int max_str; + BOOL_T changed, nChanged, pChanged, sChanged; + + switch (inx) { + case NM: + break; + case PS: + break; + case SC: + break; + case -1: + changed = nChanged = pChanged = sChanged = FALSE; + thename = wStringGetValue( (wString_p) sensorDesc[NM].control0 ); + if (strcmp(thename,xx->name) != 0) { + nChanged = changed = TRUE; + max_str = sensorDesc[NM].max_string; if (max_str && strlen(thename)>max_str-1) { newName = MyMalloc(max_str); newName[max_str-1] = '\0'; strncat(newName,thename,max_str-1); NoticeMessage2(0, MSG_ENTERED_STRING_TRUNCATED, _("Ok"), NULL, max_str-1); - } else newName = MyStrdup(thename); - } + } else { newName = MyStrdup(thename); } + } - thescript = wStringGetValue( (wString_p) sensorDesc[SC].control0 ); - if (strcmp(thescript,xx->script) != 0) { - sChanged = changed = TRUE; - max_str = sensorDesc[SC].max_string; + thescript = wStringGetValue( (wString_p) sensorDesc[SC].control0 ); + if (strcmp(thescript,xx->script) != 0) { + sChanged = changed = TRUE; + max_str = sensorDesc[SC].max_string; if (max_str && strlen(thename)>max_str-1) { newScript = MyMalloc(max_str); newScript[max_str-1] = '\0'; strncat(newScript,thescript,max_str-1); NoticeMessage2(0, MSG_ENTERED_STRING_TRUNCATED, _("Ok"), NULL, max_str-1); - } else newScript = MyStrdup(thescript); - } - - if (sensorProperties.pos.x != xx->orig.x || - sensorProperties.pos.y != xx->orig.y) { - pChanged = changed = TRUE; - } - if (!changed) break; - if (needUndoStart) - UndoStart( _("Change Sensor"), "Change Sensor" ); - UndoModify( trk ); - if (nChanged) { - MyFree(xx->name); - xx->name = newName; - } - if (pChanged) { - UndrawNewTrack( trk ); - } - if (pChanged) { - xx->orig = sensorProperties.pos; - } - if (sChanged) { - MyFree(xx->script); - xx->script = newScript; - } - if (pChanged) { - ComputeSensorBoundingBox( trk ); - DrawNewTrack( trk ); - } - break; - } + } else { newScript = MyStrdup(thescript); } + } + + if (sensorProperties.pos.x != xx->orig.x || + sensorProperties.pos.y != xx->orig.y) { + pChanged = changed = TRUE; + } + if (!changed) { break; } + if (needUndoStart) { + UndoStart( _("Change Sensor"), "Change Sensor" ); + } + UndoModify( trk ); + if (nChanged) { + MyFree(xx->name); + xx->name = newName; + } + if (pChanged) { + UndrawNewTrack( trk ); + } + if (pChanged) { + xx->orig = sensorProperties.pos; + } + if (sChanged) { + MyFree(xx->script); + xx->script = newScript; + } + if (pChanged) { + ComputeSensorBoundingBox( trk ); + DrawNewTrack( trk ); + } + break; + } } - + static void DescribeSensor (track_p trk, char * str, CSIZE_T len ) { - sensorData_p xx = GetsensorData(trk); - - strcpy( str, _(GetTrkTypeName( trk )) ); - str++; - while (*str) { - *str = tolower((unsigned char)*str); - str++; - } - sprintf( str, _("(%d [%s]): Layer=%u, at %0.3f,%0.3f"), - GetTrkIndex(trk), - xx->name,GetTrkLayer(trk)+1, xx->orig.x, xx->orig.y); - strncpy(sensorProperties.name,xx->name,STR_SHORT_SIZE-1); - sensorProperties.name[STR_SHORT_SIZE-1] = '\0'; - strncpy(sensorProperties.script,xx->script,STR_LONG_SIZE-1); - sensorProperties.script[STR_LONG_SIZE-1] = '\0'; - sensorProperties.pos = xx->orig; - sensorDesc[NM].mode = - sensorDesc[SC].mode = DESC_NOREDRAW; - DoDescribe( _("Sensor"), trk, sensorDesc, UpdateSensorProperties ); + sensorData_p xx = GetsensorData(trk); + + strcpy( str, _(GetTrkTypeName( trk )) ); + str++; + while (*str) { + *str = tolower((unsigned char)*str); + str++; + } + sprintf( str, _("(%d [%s]): Layer=%u, at %0.3f,%0.3f"), + GetTrkIndex(trk), + xx->name,GetTrkLayer(trk)+1, xx->orig.x, xx->orig.y); + strncpy(sensorProperties.name,xx->name,STR_SHORT_SIZE-1); + sensorProperties.name[STR_SHORT_SIZE-1] = '\0'; + strncpy(sensorProperties.script,xx->script,STR_LONG_SIZE-1); + sensorProperties.script[STR_LONG_SIZE-1] = '\0'; + sensorProperties.pos = xx->orig; + sensorDesc[NM].mode = + sensorDesc[SC].mode = DESC_NOREDRAW; + DoDescribe( _("Sensor"), trk, sensorDesc, UpdateSensorProperties ); } -static void DeleteSensor ( track_p trk ) +static void DeleteSensor ( track_p trk ) { - sensorData_p xx = GetsensorData(trk); - MyFree(xx->name); xx->name = NULL; - MyFree(xx->script); xx->script = NULL; + sensorData_p xx = GetsensorData(trk); + MyFree(xx->name); xx->name = NULL; + MyFree(xx->script); xx->script = NULL; } static BOOL_T WriteSensor ( track_p t, FILE * f ) { - BOOL_T rc = TRUE; - sensorData_p xx = GetsensorData(t); + BOOL_T rc = TRUE; + sensorData_p xx = GetsensorData(t); char *sensorName = MyStrdup(xx->name); #ifdef UTFCONVERT sensorName = Convert2UTF8(sensorName); #endif // UTFCONVERT - rc &= fprintf(f, "SENSOR %d %u %s %d %0.6f %0.6f \"%s\" \"%s\"\n", - GetTrkIndex(t), GetTrkLayer(t), GetTrkScaleName(t), - GetTrkVisible(t), xx->orig.x, xx->orig.y, sensorName, - xx->script)>0; + rc &= fprintf(f, "SENSOR %d %u %s %d %0.6f %0.6f \"%s\" \"%s\"\n", + GetTrkIndex(t), GetTrkLayer(t), GetTrkScaleName(t), + GetTrkVisible(t), xx->orig.x, xx->orig.y, sensorName, + xx->script)>0; MyFree(sensorName); - return rc; + return rc; } static BOOL_T ReadSensor ( char * line ) { - wIndex_t index; - /*TRKINX_T trkindex;*/ - track_p trk; - /*char * cp = NULL;*/ - char *name; - char *script; - coOrd orig; - BOOL_T visible; - char scale[10]; - wIndex_t layer; - sensorData_p xx; - if (!GetArgs(line+7,"dLsdpqq",&index,&layer,scale, &visible, &orig,&name,&script)) { - return FALSE; - } + wIndex_t index; + /*TRKINX_T trkindex;*/ + track_p trk; + /*char * cp = NULL;*/ + char *name; + char *script; + coOrd orig; + BOOL_T visible; + char scale[10]; + wIndex_t layer; + sensorData_p xx; + if (!GetArgs(line+7,"dLsdpqq",&index,&layer,scale, &visible, &orig,&name, + &script)) { + return FALSE; + } #ifdef UTFCONVERT ConvertUTF8ToSystem(name); #endif // UTFCONVERT - trk = NewTrack(index, T_SENSOR, 0, sizeof(sensorData_t)); - SetTrkVisible(trk, visible); - SetTrkScale(trk, LookupScale( scale )); - SetTrkLayer(trk, layer); - xx = GetsensorData ( trk ); - xx->name = name; - xx->orig = orig; - xx->script = script; - ComputeSensorBoundingBox(trk); - return TRUE; + trk = NewTrack(index, T_SENSOR, 0, sizeof(sensorData_t)); + SetTrkVisible(trk, visible); + SetTrkScale(trk, LookupScale( scale )); + SetTrkLayer(trk, layer); + xx = GetsensorData ( trk ); + xx->name = name; + xx->orig = orig; + xx->script = script; + ComputeSensorBoundingBox(trk); + return TRUE; } static void MoveSensor (track_p trk, coOrd orig ) { - sensorData_p xx = GetsensorData ( trk ); - xx->orig.x += orig.x; - xx->orig.y += orig.y; - ComputeSensorBoundingBox(trk); + sensorData_p xx = GetsensorData ( trk ); + xx->orig.x += orig.x; + xx->orig.y += orig.y; + ComputeSensorBoundingBox(trk); } static void RotateSensor (track_p trk, coOrd orig, ANGLE_T angle ) @@ -334,45 +337,45 @@ static void RescaleSensor (track_p trk, FLOAT_T ratio ) { } -static void FlipSensor (track_p trk, coOrd orig, ANGLE_T angle ) +static void FlipSensor (track_p trk, coOrd orig, ANGLE_T angle ) { - sensorData_p xx = GetsensorData ( trk ); - FlipPoint(&(xx->orig), orig, angle); - ComputeSensorBoundingBox(trk); + sensorData_p xx = GetsensorData ( trk ); + FlipPoint(&(xx->orig), orig, angle); + ComputeSensorBoundingBox(trk); } static trackCmd_t sensorCmds = { - "SENSOR", - DrawSensor, - DistanceSensor, - DescribeSensor, - DeleteSensor, - WriteSensor, - ReadSensor, - MoveSensor, - RotateSensor, - RescaleSensor, - NULL, /* audit */ - NULL, /* getAngle */ - NULL, /* split */ - NULL, /* traverse */ - NULL, /* enumerate */ - NULL, /* redraw */ - NULL, /* trim */ - NULL, /* merge */ - NULL, /* modify */ - NULL, /* getLength */ - NULL, /* getTrkParams */ - NULL, /* moveEndPt */ - NULL, /* query */ - NULL, /* ungroup */ - FlipSensor, /* flip */ - NULL, /* drawPositionIndicator */ - NULL, /* advancePositionIndicator */ - NULL, /* checkTraverse */ - NULL, /* makeParallel */ - NULL /* drawDesc */ + "SENSOR", + DrawSensor, + DistanceSensor, + DescribeSensor, + DeleteSensor, + WriteSensor, + ReadSensor, + MoveSensor, + RotateSensor, + RescaleSensor, + NULL, /* audit */ + NULL, /* getAngle */ + NULL, /* split */ + NULL, /* traverse */ + NULL, /* enumerate */ + NULL, /* redraw */ + NULL, /* trim */ + NULL, /* merge */ + NULL, /* modify */ + NULL, /* getLength */ + NULL, /* getTrkParams */ + NULL, /* moveEndPt */ + NULL, /* query */ + NULL, /* ungroup */ + FlipSensor, /* flip */ + NULL, /* drawPositionIndicator */ + NULL, /* advancePositionIndicator */ + NULL, /* checkTraverse */ + NULL, /* makeParallel */ + NULL /* drawDesc */ }; static coOrd sensorEditOrig; @@ -383,13 +386,13 @@ static char sensorEditScript[STR_LONG_SIZE]; static paramFloatRange_t r_1000_1000 = { -1000.0, 1000.0, 80 }; static paramData_t sensorEditPLs[] = { #define I_SENSORNAME (0) - /*0*/ { PD_STRING, sensorEditName, "name", PDO_NOPREF|PDO_NOTBLANK, I2VP(200), N_("Name"), 0, 0, sizeof(sensorEditName)}, + /*0*/ { PD_STRING, sensorEditName, "name", PDO_NOPREF|PDO_NOTBLANK, I2VP(200), N_("Name"), 0, 0, sizeof(sensorEditName)}, #define I_ORIGX (1) - /*1*/ { PD_FLOAT, &sensorEditOrig.x, "origx", PDO_DIM, &r_1000_1000, N_("Origin X") }, + /*1*/ { PD_FLOAT, &sensorEditOrig.x, "origx", PDO_DIM, &r_1000_1000, N_("Origin X") }, #define I_ORIGY (2) - /*2*/ { PD_FLOAT, &sensorEditOrig.y, "origy", PDO_DIM, &r_1000_1000, N_("Origin Y") }, + /*2*/ { PD_FLOAT, &sensorEditOrig.y, "origy", PDO_DIM, &r_1000_1000, N_("Origin Y") }, #define I_SENSORSCRIPT (3) - /*3*/ { PD_STRING, sensorEditScript, "script", PDO_NOPREF, I2VP(350), N_("Script"), 0, 0, sizeof(sensorEditScript)}, + /*3*/ { PD_STRING, sensorEditScript, "script", PDO_NOPREF, I2VP(350), N_("Script"), 0, 0, sizeof(sensorEditScript)}, }; static paramGroup_t sensorEditPG = { "sensorEdit", 0, sensorEditPLs, COUNT( sensorEditPLs ) }; @@ -397,109 +400,113 @@ static wWin_p sensorEditW; static void SensorEditOk ( void * junk ) { - track_p trk; - sensorData_p xx; - - if (sensorEditTrack == NULL) { - UndoStart( _("Create Sensor"), "Create Sensor"); - trk = NewTrack(0, T_SENSOR, 0, sizeof(sensorData_t)); - } else { - UndoStart( _("Modify Sensor"), "Modify Sensor"); - trk = sensorEditTrack; - } - xx = GetsensorData(trk); - xx->orig = sensorEditOrig; - if ( xx->name == NULL || strncmp (xx->name, sensorEditName, STR_SHORT_SIZE) != 0) { - MyFree(xx->name); - xx->name = MyStrdup(sensorEditName); - } - if ( xx->script == NULL || strncmp (xx->script, sensorEditScript, STR_LONG_SIZE) != 0) { - MyFree(xx->script); - xx->script = MyStrdup(sensorEditScript); - } - UndoEnd(); - DoRedraw(); - ComputeSensorBoundingBox(trk); - wHide( sensorEditW ); + track_p trk; + sensorData_p xx; + + if (sensorEditTrack == NULL) { + UndoStart( _("Create Sensor"), "Create Sensor"); + trk = NewTrack(0, T_SENSOR, 0, sizeof(sensorData_t)); + } else { + UndoStart( _("Modify Sensor"), "Modify Sensor"); + trk = sensorEditTrack; + } + xx = GetsensorData(trk); + xx->orig = sensorEditOrig; + if ( xx->name == NULL + || strncmp (xx->name, sensorEditName, STR_SHORT_SIZE) != 0) { + MyFree(xx->name); + xx->name = MyStrdup(sensorEditName); + } + if ( xx->script == NULL + || strncmp (xx->script, sensorEditScript, STR_LONG_SIZE) != 0) { + MyFree(xx->script); + xx->script = MyStrdup(sensorEditScript); + } + UndoEnd(); + DoRedraw(); + ComputeSensorBoundingBox(trk); + wHide( sensorEditW ); } #if 0 static void SensorEditCancel ( wWin_p junk ) { - wHide( sensorEditW ); + wHide( sensorEditW ); } #endif static void EditSensorDialog() { - sensorData_p xx; - - if ( !sensorEditW ) { - ParamRegister( &sensorEditPG ); - sensorEditW = ParamCreateDialog (&sensorEditPG, - MakeWindowTitle(_("Edit sensor")), - _("Ok"), SensorEditOk, - wHide, TRUE, NULL, - F_BLOCK, - NULL ); - } - if (sensorEditTrack == NULL) { - sensorEditName[0] = '\0'; - sensorEditScript[0] = '\0'; - } else { - xx = GetsensorData ( sensorEditTrack ); - strncpy(sensorEditName,xx->name,STR_SHORT_SIZE); - strncpy(sensorEditScript,xx->script,STR_LONG_SIZE); - sensorEditOrig = xx->orig; - } - ParamLoadControls( &sensorEditPG ); - wShow( sensorEditW ); + sensorData_p xx; + + if ( !sensorEditW ) { + ParamRegister( &sensorEditPG ); + sensorEditW = ParamCreateDialog (&sensorEditPG, + MakeWindowTitle(_("Edit sensor")), + _("Ok"), SensorEditOk, + wHide, TRUE, NULL, + F_BLOCK, + NULL ); + } + if (sensorEditTrack == NULL) { + sensorEditName[0] = '\0'; + sensorEditScript[0] = '\0'; + } else { + xx = GetsensorData ( sensorEditTrack ); + strncpy(sensorEditName,xx->name,STR_SHORT_SIZE); + strncpy(sensorEditScript,xx->script,STR_LONG_SIZE); + sensorEditOrig = xx->orig; + } + ParamLoadControls( &sensorEditPG ); + wShow( sensorEditW ); } static void EditSensor (track_p trk) { - sensorEditTrack = trk; - EditSensorDialog(); + sensorEditTrack = trk; + EditSensorDialog(); } static void CreateNewSensor (coOrd orig) { - sensorEditOrig = orig; - sensorEditTrack = NULL; - EditSensorDialog(); + sensorEditOrig = orig; + sensorEditTrack = NULL; + EditSensorDialog(); } static STATUS_T CmdSensor ( wAction_t action, coOrd pos ) { static coOrd sensor_pos; static BOOL_T create; - switch (action) { - case C_START: - InfoMessage(_("Place sensor")); - SetAllTrackSelect( FALSE ); - create = FALSE; - return C_CONTINUE; - case C_DOWN: - create = TRUE; - /* no break */ + switch (action) { + case C_START: + InfoMessage(_("Place sensor")); + SetAllTrackSelect( FALSE ); + create = FALSE; + return C_CONTINUE; + case C_DOWN: + create = TRUE; + /* no break */ case C_MOVE: SnapPos(&pos); sensor_pos = pos; - return C_CONTINUE; - case C_UP: - SnapPos(&pos); - CreateNewSensor(pos); - return C_TERMINATE; - case C_REDRAW: - if (create) - DDrawSensor( &tempD, sensor_pos, GetScaleRatio(GetLayoutCurScale()), wDrawColorBlack ); - return C_CONTINUE; - case C_CANCEL: - create = FALSE; - return C_CONTINUE; - default: - return C_CONTINUE; - } + return C_CONTINUE; + case C_UP: + SnapPos(&pos); + CreateNewSensor(pos); + return C_TERMINATE; + case C_REDRAW: + if (create) { + DDrawSensor( &tempD, sensor_pos, GetScaleRatio(GetLayoutCurScale()), + wDrawColorBlack ); + } + return C_CONTINUE; + case C_CANCEL: + create = FALSE; + return C_CONTINUE; + default: + return C_CONTINUE; + } } static coOrd ctlhiliteOrig, ctlhiliteSize; @@ -507,92 +514,95 @@ static POS_T ctlhiliteBorder; static wDrawColor ctlhiliteColor = 0; static void DrawSensorTrackHilite( void ) { - if (ctlhiliteColor==0) + if (ctlhiliteColor==0) { ctlhiliteColor = wDrawColorGray(87); - DrawRectangle( &tempD, ctlhiliteOrig, ctlhiliteSize, ctlhiliteColor, DRAW_TRANSPARENT ); + } + DrawRectangle( &tempD, ctlhiliteOrig, ctlhiliteSize, ctlhiliteColor, + DRAW_TRANSPARENT ); } static int SensorMgmProc ( int cmd, void * data ) { - track_p trk = (track_p) data; - sensorData_p xx = GetsensorData(trk); - /*char msg[STR_SIZE];*/ - - switch ( cmd ) { - case CONTMGM_CAN_EDIT: - return TRUE; - break; - case CONTMGM_DO_EDIT: - EditSensor(trk); - return TRUE; - break; - case CONTMGM_CAN_DELETE: - return TRUE; - break; - case CONTMGM_DO_DELETE: - DeleteTrack(trk, FALSE); - return TRUE; - break; - case CONTMGM_DO_HILIGHT: - if (!xx->IsHilite) { - ctlhiliteBorder = mainD.scale*0.1; - if ( ctlhiliteBorder < trackGauge ) ctlhiliteBorder = trackGauge; - GetBoundingBox( trk, &ctlhiliteSize, &ctlhiliteOrig ); - ctlhiliteOrig.x -= ctlhiliteBorder; - ctlhiliteOrig.y -= ctlhiliteBorder; - ctlhiliteSize.x -= ctlhiliteOrig.x-ctlhiliteBorder; - ctlhiliteSize.y -= ctlhiliteOrig.y-ctlhiliteBorder; - DrawSensorTrackHilite(); - xx->IsHilite = TRUE; - } - break; - case CONTMGM_UN_HILIGHT: - if (xx->IsHilite) { - ctlhiliteBorder = mainD.scale*0.1; - if ( ctlhiliteBorder < trackGauge ) ctlhiliteBorder = trackGauge; - GetBoundingBox( trk, &ctlhiliteSize, &ctlhiliteOrig ); - ctlhiliteOrig.x -= ctlhiliteBorder; - ctlhiliteOrig.y -= ctlhiliteBorder; - ctlhiliteSize.x -= ctlhiliteOrig.x-ctlhiliteBorder; - ctlhiliteSize.y -= ctlhiliteOrig.y-ctlhiliteBorder; - DrawSensorTrackHilite(); - xx->IsHilite = FALSE; - } - break; - case CONTMGM_GET_TITLE: - sprintf(message,"\t%s\t",xx->name); - break; - } - return FALSE; + track_p trk = (track_p) data; + sensorData_p xx = GetsensorData(trk); + /*char msg[STR_SIZE];*/ + + switch ( cmd ) { + case CONTMGM_CAN_EDIT: + return TRUE; + break; + case CONTMGM_DO_EDIT: + EditSensor(trk); + return TRUE; + break; + case CONTMGM_CAN_DELETE: + return TRUE; + break; + case CONTMGM_DO_DELETE: + DeleteTrack(trk, FALSE); + return TRUE; + break; + case CONTMGM_DO_HILIGHT: + if (!xx->IsHilite) { + ctlhiliteBorder = mainD.scale*0.1; + if ( ctlhiliteBorder < trackGauge ) { ctlhiliteBorder = trackGauge; } + GetBoundingBox( trk, &ctlhiliteSize, &ctlhiliteOrig ); + ctlhiliteOrig.x -= ctlhiliteBorder; + ctlhiliteOrig.y -= ctlhiliteBorder; + ctlhiliteSize.x -= ctlhiliteOrig.x-ctlhiliteBorder; + ctlhiliteSize.y -= ctlhiliteOrig.y-ctlhiliteBorder; + DrawSensorTrackHilite(); + xx->IsHilite = TRUE; + } + break; + case CONTMGM_UN_HILIGHT: + if (xx->IsHilite) { + ctlhiliteBorder = mainD.scale*0.1; + if ( ctlhiliteBorder < trackGauge ) { ctlhiliteBorder = trackGauge; } + GetBoundingBox( trk, &ctlhiliteSize, &ctlhiliteOrig ); + ctlhiliteOrig.x -= ctlhiliteBorder; + ctlhiliteOrig.y -= ctlhiliteBorder; + ctlhiliteSize.x -= ctlhiliteOrig.x-ctlhiliteBorder; + ctlhiliteSize.y -= ctlhiliteOrig.y-ctlhiliteBorder; + DrawSensorTrackHilite(); + xx->IsHilite = FALSE; + } + break; + case CONTMGM_GET_TITLE: + sprintf(message,"\t%s\t",xx->name); + break; + } + return FALSE; } -#include "bitmaps/sensor.xpm" +#include "bitmaps/sensor.xpm3" EXPORT void SensorMgmLoad ( void ) { - track_p trk; - static wIcon_p sensorI = NULL; - - if (sensorI == NULL) { - sensorI = wIconCreatePixMap( sensor_xpm[iconSize] ); - } - - TRK_ITERATE(trk) { - if (GetTrkType(trk) != T_SENSOR) continue; - ContMgmLoad (sensorI, SensorMgmProc, trk ); - } + track_p trk; + static wIcon_p sensorI = NULL; + + if (sensorI == NULL) { + sensorI = wIconCreatePixMap( sensor_xpm3[iconSize] ); + } + + TRK_ITERATE(trk) { + if (GetTrkType(trk) != T_SENSOR) { continue; } + ContMgmLoad (sensorI, SensorMgmProc, trk ); + } } #define ACCL_SENSOR 0 EXPORT void InitCmdSensor ( wMenu_p menu ) { - AddMenuButton( menu, CmdSensor, "cmdSensor", _("Sensor"), - wIconCreatePixMap( sensor_xpm[iconSize] ), LEVEL0_50, IC_STICKY|IC_POPUP2, ACCL_SENSOR, NULL ); + AddMenuButton( menu, CmdSensor, "cmdSensor", _("Sensor"), + wIconCreatePixMap( sensor_xpm3[iconSize] ), LEVEL0_50, IC_STICKY|IC_POPUP2, + ACCL_SENSOR, NULL ); } EXPORT void InitTrkSensor ( void ) { - T_SENSOR = InitObject ( &sensorCmds ); - log_sensor = LogFindIndex ( "sensor" ); + T_SENSOR = InitObject ( &sensorCmds ); + log_sensor = LogFindIndex ( "sensor" ); } diff --git a/app/bin/csignal.c b/app/bin/csignal.c index 83609e1..36392cc 100644 --- a/app/bin/csignal.c +++ b/app/bin/csignal.c @@ -4,8 +4,8 @@ /* -*- C -*- **************************************************************** * - * System : - * Module : + * System : + * Module : * Object Name : $RCSfile$ * Revision : $Revision$ * Date : $Date$ @@ -14,12 +14,12 @@ * Created : Sun Feb 19 13:11:45 2017 * Last Modified : <170417.1113> * - * Description + * Description * * Notes * * History - * + * **************************************************************************** * * Copyright (C) 2017 Robert Heller D/B/A Deepwoods Software @@ -38,13 +38,13 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * * - * * ****************************************************************************/ -static const char rcsid[] = "@(#) : $Id$"; +//static const char rcsid[] = "@(#) : $Id$"; #include "compound.h" @@ -55,7 +55,6 @@ static const char rcsid[] = "@(#) : $Id$"; #include "layout.h" #include "param.h" #include "track.h" -#include "trackx.h" #include "common-ui.h" #ifdef UTFCONVERT #include "include/utf8convert.h" @@ -74,34 +73,35 @@ static drawCmd_t signalD = { 1.0, 0.0, {0.0,0.0}, {0.0,0.0}, - Pix2CoOrd, CoOrd2Pix }; + Pix2CoOrd, CoOrd2Pix +}; static char signalName[STR_SHORT_SIZE]; static int signalHeadCount; #endif typedef struct signalAspect_t { - char * aspectName; - char * aspectScript; + char * aspectName; + char * aspectScript; } signalAspect_t, *signalAspect_p; static dynArr_t signalAspect_da; #define signalAspect(N) DYNARR_N( signalAspect_t, signalAspect_da, N ) typedef struct signalData_t { - extraDataBase_t base; - coOrd orig; - ANGLE_T angle; - char * name; - wIndex_t numHeads; - BOOL_T IsHilite; - wIndex_t numAspects; - signalAspect_t aspectList; + extraDataBase_t base; + coOrd orig; + ANGLE_T angle; + char * name; + wIndex_t numHeads; + BOOL_T IsHilite; + wIndex_t numAspects; + signalAspect_t aspectList; } signalData_t, *signalData_p; static signalData_p GetsignalData ( track_p trk ) { - return GET_EXTRA_DATA( trk, T_SIGNAL, signalData_t ); + return GET_EXTRA_DATA( trk, T_SIGNAL, signalData_t ); } #define BASEX 6 @@ -115,368 +115,372 @@ static signalData_p GetsignalData ( track_p trk ) #define signal_SF (3.0) -static void DDrawSignal(drawCmd_p d, coOrd orig, ANGLE_T angle, - wIndex_t numHeads, DIST_T scaleRatio, +static void DDrawSignal(drawCmd_p d, coOrd orig, ANGLE_T angle, + wIndex_t numHeads, DIST_T scaleRatio, wDrawColor color ) { - coOrd p1, p2; - ANGLE_T x_angle, y_angle; - DIST_T hoffset; - wIndex_t ihead; - - x_angle = 90-(360-angle); - if (x_angle < 0) x_angle += 360; - y_angle = -(360-angle); - if (y_angle < 0) y_angle += 360; - - Translate (&p1, orig, x_angle, (-BASEX) * signal_SF / scaleRatio); - Translate (&p1, p1, y_angle, BASEY * signal_SF / scaleRatio); - Translate (&p2, orig, x_angle, BASEX * signal_SF / scaleRatio); - Translate (&p2, p2, y_angle, BASEY * signal_SF / scaleRatio); - DrawLine(d, p1, p2, 2, color); - p1 = orig; - Translate (&p2, orig, x_angle, MASTX * signal_SF / scaleRatio); - Translate (&p2, p2, y_angle, MASTY * signal_SF / scaleRatio); - DrawLine(d, p1, p2, 2, color); - hoffset = MASTY; - for (ihead = 0; ihead < numHeads; ihead++) { - Translate (&p1, orig, x_angle, MASTX * signal_SF / scaleRatio); - Translate (&p1, p1, y_angle, (hoffset+HEADR) * signal_SF / scaleRatio); - DrawFillCircle(d,p1,HEADR * signal_SF / scaleRatio,color); - hoffset += HEADR*2; - } + coOrd p1, p2; + ANGLE_T x_angle, y_angle; + DIST_T hoffset; + wIndex_t ihead; + + x_angle = 90-(360-angle); + if (x_angle < 0) { x_angle += 360; } + y_angle = -(360-angle); + if (y_angle < 0) { y_angle += 360; } + + Translate (&p1, orig, x_angle, (-BASEX) * signal_SF / scaleRatio); + Translate (&p1, p1, y_angle, BASEY * signal_SF / scaleRatio); + Translate (&p2, orig, x_angle, BASEX * signal_SF / scaleRatio); + Translate (&p2, p2, y_angle, BASEY * signal_SF / scaleRatio); + DrawLine(d, p1, p2, 2, color); + p1 = orig; + Translate (&p2, orig, x_angle, MASTX * signal_SF / scaleRatio); + Translate (&p2, p2, y_angle, MASTY * signal_SF / scaleRatio); + DrawLine(d, p1, p2, 2, color); + hoffset = MASTY; + for (ihead = 0; ihead < numHeads; ihead++) { + Translate (&p1, orig, x_angle, MASTX * signal_SF / scaleRatio); + Translate (&p1, p1, y_angle, (hoffset+HEADR) * signal_SF / scaleRatio); + DrawFillCircle(d,p1,HEADR * signal_SF / scaleRatio,color); + hoffset += HEADR*2; + } } static void DrawSignal (track_p t, drawCmd_p d, wDrawColor color ) { - signalData_p xx = GetsignalData(t); - DDrawSignal(d,xx->orig, xx->angle, xx->numHeads, GetScaleRatio(GetTrkScale(t)),color); + signalData_p xx = GetsignalData(t); + DDrawSignal(d,xx->orig, xx->angle, xx->numHeads, GetScaleRatio(GetTrkScale(t)), + color); } -static void SignalBoundingBox (coOrd orig, ANGLE_T angle,wIndex_t numHeads, +static void SignalBoundingBox (coOrd orig, ANGLE_T angle,wIndex_t numHeads, DIST_T scaleRatio, coOrd *hi, coOrd *lo) { - coOrd p1, p2, headp1, headp2; - ANGLE_T x_angle, y_angle; - DIST_T hoffset,delta; - wIndex_t ihead; - - x_angle = 90-(360-angle); - if (x_angle < 0) x_angle += 360; - y_angle = -(360-angle); - if (y_angle < 0) y_angle += 360; - - Translate (&p1, orig, x_angle, (-BASEX) * signal_SF / scaleRatio); - Translate (&p1, p1, y_angle, BASEY * signal_SF / scaleRatio); - Translate (&p2, orig, x_angle, BASEX * signal_SF / scaleRatio); - Translate (&p2, p2, y_angle, BASEY * signal_SF / scaleRatio); - *hi = p1; *lo = p1; - if (p2.x > hi->x) hi->x = p2.x; - if (p2.x < lo->x) lo->x = p2.x; - if (p2.y > hi->y) hi->y = p2.y; - if (p2.y < lo->y) lo->y = p2.y; - p1 = orig; - Translate (&p2, orig, x_angle, MASTX * signal_SF / scaleRatio); - Translate (&p2, p2, y_angle, MASTY * signal_SF / scaleRatio); - if (p1.x > hi->x) hi->x = p1.x; - if (p1.x < lo->x) lo->x = p1.x; - if (p1.y > hi->y) hi->y = p1.y; - if (p1.y < lo->y) lo->y = p1.y; - if (p2.x > hi->x) hi->x = p2.x; - if (p2.x < lo->x) lo->x = p2.x; - if (p2.y > hi->y) hi->y = p2.y; - if (p2.y < lo->y) lo->y = p2.y; - hoffset = MASTY; - for (ihead = 0; ihead < numHeads; ihead++) { - Translate (&p1, orig, x_angle, MASTX * signal_SF / scaleRatio); - Translate (&p1, p1, y_angle, (hoffset+HEADR) * signal_SF / scaleRatio); - delta = HEADR * signal_SF / scaleRatio; - headp1.x = p1.x - delta; - headp1.y = p1.y - delta; - headp2.x = p1.x + delta; - headp2.y = p1.y + delta; - if (headp1.x > hi->x) hi->x = headp1.x; - if (headp1.x < lo->x) lo->x = headp1.x; - if (headp1.y > hi->y) hi->y = headp1.y; - if (headp1.y < lo->y) lo->y = headp1.y; - if (headp2.x > hi->x) hi->x = headp2.x; - if (headp2.x < lo->x) lo->x = headp2.x; - if (headp2.y > hi->y) hi->y = headp2.y; - if (headp2.y < lo->y) lo->y = headp2.y; - hoffset += HEADR*2; - } - + coOrd p1, p2, headp1, headp2; + ANGLE_T x_angle, y_angle; + DIST_T hoffset,delta; + wIndex_t ihead; + + x_angle = 90-(360-angle); + if (x_angle < 0) { x_angle += 360; } + y_angle = -(360-angle); + if (y_angle < 0) { y_angle += 360; } + + Translate (&p1, orig, x_angle, (-BASEX) * signal_SF / scaleRatio); + Translate (&p1, p1, y_angle, BASEY * signal_SF / scaleRatio); + Translate (&p2, orig, x_angle, BASEX * signal_SF / scaleRatio); + Translate (&p2, p2, y_angle, BASEY * signal_SF / scaleRatio); + *hi = p1; *lo = p1; + if (p2.x > hi->x) { hi->x = p2.x; } + if (p2.x < lo->x) { lo->x = p2.x; } + if (p2.y > hi->y) { hi->y = p2.y; } + if (p2.y < lo->y) { lo->y = p2.y; } + p1 = orig; + Translate (&p2, orig, x_angle, MASTX * signal_SF / scaleRatio); + Translate (&p2, p2, y_angle, MASTY * signal_SF / scaleRatio); + if (p1.x > hi->x) { hi->x = p1.x; } + if (p1.x < lo->x) { lo->x = p1.x; } + if (p1.y > hi->y) { hi->y = p1.y; } + if (p1.y < lo->y) { lo->y = p1.y; } + if (p2.x > hi->x) { hi->x = p2.x; } + if (p2.x < lo->x) { lo->x = p2.x; } + if (p2.y > hi->y) { hi->y = p2.y; } + if (p2.y < lo->y) { lo->y = p2.y; } + hoffset = MASTY; + for (ihead = 0; ihead < numHeads; ihead++) { + Translate (&p1, orig, x_angle, MASTX * signal_SF / scaleRatio); + Translate (&p1, p1, y_angle, (hoffset+HEADR) * signal_SF / scaleRatio); + delta = HEADR * signal_SF / scaleRatio; + headp1.x = p1.x - delta; + headp1.y = p1.y - delta; + headp2.x = p1.x + delta; + headp2.y = p1.y + delta; + if (headp1.x > hi->x) { hi->x = headp1.x; } + if (headp1.x < lo->x) { lo->x = headp1.x; } + if (headp1.y > hi->y) { hi->y = headp1.y; } + if (headp1.y < lo->y) { lo->y = headp1.y; } + if (headp2.x > hi->x) { hi->x = headp2.x; } + if (headp2.x < lo->x) { lo->x = headp2.x; } + if (headp2.y > hi->y) { hi->y = headp2.y; } + if (headp2.y < lo->y) { lo->y = headp2.y; } + hoffset += HEADR*2; + } + } static void ComputeSignalBoundingBox (track_p t ) { - coOrd lo, hi; - signalData_p xx = GetsignalData(t); - SignalBoundingBox(xx->orig, xx->angle, xx->numHeads, - GetScaleRatio(GetTrkScale(t)), &hi, &lo); - SetBoundingBox(t, hi, lo); + coOrd lo, hi; + signalData_p xx = GetsignalData(t); + SignalBoundingBox(xx->orig, xx->angle, xx->numHeads, + GetScaleRatio(GetTrkScale(t)), &hi, &lo); + SetBoundingBox(t, hi, lo); } static DIST_T DistanceSignal (track_p t, coOrd * p ) { - signalData_p xx = GetsignalData(t); - return FindDistance(xx->orig, *p); + signalData_p xx = GetsignalData(t); + return FindDistance(xx->orig, *p); } static struct { - char name[STR_SHORT_SIZE]; - coOrd pos; - ANGLE_T orient; - long heads; + char name[STR_SHORT_SIZE]; + coOrd pos; + ANGLE_T orient; + long heads; } signalProperties; typedef enum { NM, PS, OR, HD } signalDesc_e; static descData_t signalDesc[] = { - /* NM */ { DESC_STRING, N_("Name"), &signalProperties.name, sizeof(signalProperties.name) }, - /* PS */ { DESC_POS, N_("Position"), &signalProperties.pos }, - /* OR */ { DESC_ANGLE, N_("Angle"), &signalProperties.orient }, - /* HD */ { DESC_LONG, N_("Number Of Heads"), &signalProperties.heads }, - { DESC_NULL } }; + /* NM */ { DESC_STRING, N_("Name"), &signalProperties.name, sizeof(signalProperties.name) }, + /* PS */ { DESC_POS, N_("Position"), &signalProperties.pos }, + /* OR */ { DESC_ANGLE, N_("Angle"), &signalProperties.orient }, + /* HD */ { DESC_LONG, N_("Number Of Heads"), &signalProperties.heads }, + { DESC_NULL } +}; static void UpdateSignalProperties ( track_p trk, int inx, descData_p descUpd, BOOL_T needUndoStart ) { - signalData_p xx = GetsignalData( trk ); - const char *thename; - char *newName; - BOOL_T changed, nChanged, pChanged, oChanged; - - switch (inx) { - case NM: break; - case PS: break; - case OR: break; - case HD: break; - case -1: - changed = nChanged = pChanged = oChanged = FALSE; - thename = wStringGetValue( (wString_p) signalDesc[NM].control0 ); - if (strcmp(thename,xx->name) != 0) { - nChanged = changed = TRUE; - unsigned int max_str = signalDesc[NM].max_string; + signalData_p xx = GetsignalData( trk ); + const char *thename; + char *newName; + BOOL_T changed, nChanged, pChanged, oChanged; + + switch (inx) { + case NM: break; + case PS: break; + case OR: break; + case HD: break; + case -1: + changed = nChanged = pChanged = oChanged = FALSE; + thename = wStringGetValue( (wString_p) signalDesc[NM].control0 ); + if (strcmp(thename,xx->name) != 0) { + nChanged = changed = TRUE; + unsigned int max_str = signalDesc[NM].max_string; if (max_str && strlen(thename)>max_str) { newName = MyMalloc(max_str); newName[max_str-1] = '\0'; strncat(newName,thename, max_str-1); NoticeMessage2(0, MSG_ENTERED_STRING_TRUNCATED, _("Ok"), NULL, max_str-1); - } else newName = MyStrdup(thename); - } - - if (signalProperties.pos.x != xx->orig.x || - signalProperties.pos.y != xx->orig.y) { - pChanged = changed = TRUE; - } - if (signalProperties.orient != xx->angle) { - oChanged = changed = TRUE; - } - if (!changed) break; - if (needUndoStart) - UndoStart( _("Change Signal"), "Change Signal" ); - UndoModify( trk ); - if (nChanged) { - MyFree(xx->name); - xx->name = newName; - } - if (pChanged || oChanged) { - UndrawNewTrack( trk ); - } - if (pChanged) { - xx->orig = signalProperties.pos; - } - if (oChanged) { - xx->angle = signalProperties.orient; - } - if (pChanged || oChanged) { - ComputeSignalBoundingBox( trk ); - DrawNewTrack( trk ); - } - break; - } -} - - -static void DescribeSignal (track_p trk, char * str, CSIZE_T len ) -{ - signalData_p xx = GetsignalData(trk); - - strcpy( str, _(GetTrkTypeName( trk )) ); - str++; - while (*str) { - *str = tolower((unsigned char)*str); - str++; - } - sprintf( str, _("(%d [%s]): Layer=%u, %d heads at %0.3f,%0.3f A%0.3f"), - GetTrkIndex(trk), - xx->name,GetTrkLayer(trk)+1, xx->numHeads, - xx->orig.x, xx->orig.y,xx->angle ); - strncpy(signalProperties.name,xx->name,STR_SHORT_SIZE-1); - signalProperties.name[STR_SHORT_SIZE-1] = '\0'; - signalProperties.pos = xx->orig; - signalProperties.orient = xx->angle; - signalProperties.heads = xx->numHeads; - signalDesc[HD].mode = DESC_RO; - signalDesc[NM].mode = DESC_NOREDRAW; - DoDescribe( _("Signal"), trk, signalDesc, UpdateSignalProperties ); + } else { newName = MyStrdup(thename); } + } + + if (signalProperties.pos.x != xx->orig.x || + signalProperties.pos.y != xx->orig.y) { + pChanged = changed = TRUE; + } + if (signalProperties.orient != xx->angle) { + oChanged = changed = TRUE; + } + if (!changed) { break; } + if (needUndoStart) { + UndoStart( _("Change Signal"), "Change Signal" ); + } + UndoModify( trk ); + if (nChanged) { + MyFree(xx->name); + xx->name = newName; + } + if (pChanged || oChanged) { + UndrawNewTrack( trk ); + } + if (pChanged) { + xx->orig = signalProperties.pos; + } + if (oChanged) { + xx->angle = signalProperties.orient; + } + if (pChanged || oChanged) { + ComputeSignalBoundingBox( trk ); + DrawNewTrack( trk ); + } + break; + } +} + + +static void DescribeSignal (track_p trk, char * str, CSIZE_T len ) +{ + signalData_p xx = GetsignalData(trk); + + strcpy( str, _(GetTrkTypeName( trk )) ); + str++; + while (*str) { + *str = tolower((unsigned char)*str); + str++; + } + sprintf( str, _("(%d [%s]): Layer=%u, %d heads at %0.3f,%0.3f A%0.3f"), + GetTrkIndex(trk), + xx->name,GetTrkLayer(trk)+1, xx->numHeads, + xx->orig.x, xx->orig.y,xx->angle ); + strncpy(signalProperties.name,xx->name,STR_SHORT_SIZE-1); + signalProperties.name[STR_SHORT_SIZE-1] = '\0'; + signalProperties.pos = xx->orig; + signalProperties.orient = xx->angle; + signalProperties.heads = xx->numHeads; + signalDesc[HD].mode = DESC_RO; + signalDesc[NM].mode = DESC_NOREDRAW; + DoDescribe( _("Signal"), trk, signalDesc, UpdateSignalProperties ); } static void DeleteSignal ( track_p trk ) { - wIndex_t ia; - signalData_p xx = GetsignalData(trk); - MyFree(xx->name); xx->name = NULL; - for (ia = 0; ia < xx->numAspects; ia++) { - MyFree((&(xx->aspectList))[ia].aspectName); - MyFree((&(xx->aspectList))[ia].aspectScript); - } + wIndex_t ia; + signalData_p xx = GetsignalData(trk); + MyFree(xx->name); xx->name = NULL; + for (ia = 0; ia < xx->numAspects; ia++) { + MyFree((&(xx->aspectList))[ia].aspectName); + MyFree((&(xx->aspectList))[ia].aspectScript); + } } static BOOL_T WriteSignal ( track_p t, FILE * f ) { - BOOL_T rc = TRUE; - wIndex_t ia; - signalData_p xx = GetsignalData(t); + BOOL_T rc = TRUE; + wIndex_t ia; + signalData_p xx = GetsignalData(t); char *signalName = MyStrdup(xx->name); #ifdef UTFCONVERT signalName = Convert2UTF8(signalName); #endif // UTFCONVERT - rc &= fprintf(f, "SIGNAL %d %u %s %d %0.6f %0.6f %0.6f %d \"%s\"\n", - GetTrkIndex(t), GetTrkLayer(t), GetTrkScaleName(t), - GetTrkVisible(t), xx->orig.x, xx->orig.y, xx->angle, - xx->numHeads, signalName)>0; - for (ia = 0; ia < xx->numAspects; ia++) { - rc &= fprintf(f, "\tASPECT \"%s\" \"%s\"\n", - (&(xx->aspectList))[ia].aspectName, - (&(xx->aspectList))[ia].aspectScript)>0; - } - rc &= fprintf( f, "\t%s\n",END_SIGNAL )>0; + rc &= fprintf(f, "SIGNAL %d %u %s %d %0.6f %0.6f %0.6f %d \"%s\"\n", + GetTrkIndex(t), GetTrkLayer(t), GetTrkScaleName(t), + GetTrkVisible(t), xx->orig.x, xx->orig.y, xx->angle, + xx->numHeads, signalName)>0; + for (ia = 0; ia < xx->numAspects; ia++) { + rc &= fprintf(f, "\tASPECT \"%s\" \"%s\"\n", + (&(xx->aspectList))[ia].aspectName, + (&(xx->aspectList))[ia].aspectScript)>0; + } + rc &= fprintf( f, "\t%s\n",END_SIGNAL )>0; MyFree(signalName); - return rc; + return rc; } static BOOL_T ReadSignal ( char * line ) { - /*TRKINX_T trkindex;*/ - wIndex_t index; - track_p trk; - char * cp = NULL; - wIndex_t ia; - char *name; - char *aspname, *aspscript; - wIndex_t numHeads; - coOrd orig; - ANGLE_T angle; - BOOL_T visible; - char scale[10]; - wIndex_t layer; - signalData_p xx; - if (!GetArgs(line+6,"dLsdpfdq",&index,&layer,scale, &visible, &orig, - &angle, &numHeads,&name)) { - return FALSE; - } + /*TRKINX_T trkindex;*/ + wIndex_t index; + track_p trk; + char * cp = NULL; + wIndex_t ia; + char *name; + char *aspname, *aspscript; + wIndex_t numHeads; + coOrd orig; + ANGLE_T angle; + BOOL_T visible; + char scale[10]; + wIndex_t layer; + signalData_p xx; + if (!GetArgs(line+6,"dLsdpfdq",&index,&layer,scale, &visible, &orig, + &angle, &numHeads,&name)) { + return FALSE; + } #ifdef UTFCONVERT ConvertUTF8ToSystem(name); #endif // UTFCONVERT - DYNARR_RESET( signalAspect_p, signalAspect_da ); - while ( (cp = GetNextLine()) != NULL ) { - if ( IsEND( END_SIGNAL) ) { - break; - } - while (isspace((unsigned char)*cp)) cp++; - if ( *cp == '\n' || *cp == '#' ) { - continue; - } - if ( strncmp( cp, "ASPECT", 6 ) == 0 ) { - if (!GetArgs(cp+4,"qq",&aspname,&aspscript)) return FALSE; - DYNARR_APPEND( signalAspect_p *, signalAspect_da, 10 ); - signalAspect(signalAspect_da.cnt-1).aspectName = aspname; - signalAspect(signalAspect_da.cnt-1).aspectScript = aspscript; - } - } - trk = NewTrack(index, T_SIGNAL, 0, sizeof(signalData_t)+(sizeof(signalAspect_t)*(signalAspect_da.cnt-1))+1); - SetTrkVisible(trk, visible); - SetTrkScale(trk, LookupScale( scale )); - SetTrkLayer(trk, layer); - xx = GetsignalData ( trk ); - xx->name = name; - xx->numHeads = numHeads; - xx->orig = orig; - xx->angle = angle; - xx->numAspects = signalAspect_da.cnt; - for (ia = 0; ia < xx->numAspects; ia++) { - (&(xx->aspectList))[ia].aspectName = signalAspect(ia).aspectName; - (&(xx->aspectList))[ia].aspectScript = signalAspect(ia).aspectScript; - } - ComputeSignalBoundingBox(trk); - return TRUE; + DYNARR_RESET( signalAspect_p, signalAspect_da ); + while ( (cp = GetNextLine()) != NULL ) { + if ( IsEND( END_SIGNAL) ) { + break; + } + while (isspace((unsigned char)*cp)) { cp++; } + if ( *cp == '\n' || *cp == '#' ) { + continue; + } + if ( strncmp( cp, "ASPECT", 6 ) == 0 ) { + if (!GetArgs(cp+4,"qq",&aspname,&aspscript)) { return FALSE; } + DYNARR_APPEND( signalAspect_p *, signalAspect_da, 10 ); + signalAspect(signalAspect_da.cnt-1).aspectName = aspname; + signalAspect(signalAspect_da.cnt-1).aspectScript = aspscript; + } + } + trk = NewTrack(index, T_SIGNAL, 0, + sizeof(signalData_t)+(sizeof(signalAspect_t)*(signalAspect_da.cnt-1))+1); + SetTrkVisible(trk, visible); + SetTrkScale(trk, LookupScale( scale )); + SetTrkLayer(trk, layer); + xx = GetsignalData ( trk ); + xx->name = name; + xx->numHeads = numHeads; + xx->orig = orig; + xx->angle = angle; + xx->numAspects = signalAspect_da.cnt; + for (ia = 0; ia < xx->numAspects; ia++) { + (&(xx->aspectList))[ia].aspectName = signalAspect(ia).aspectName; + (&(xx->aspectList))[ia].aspectScript = signalAspect(ia).aspectScript; + } + ComputeSignalBoundingBox(trk); + return TRUE; } static void MoveSignal (track_p trk, coOrd orig ) { - signalData_p xx = GetsignalData ( trk ); - xx->orig.x += orig.x; - xx->orig.y += orig.y; - ComputeSignalBoundingBox(trk); + signalData_p xx = GetsignalData ( trk ); + xx->orig.x += orig.x; + xx->orig.y += orig.y; + ComputeSignalBoundingBox(trk); } -static void RotateSignal (track_p trk, coOrd orig, ANGLE_T angle ) +static void RotateSignal (track_p trk, coOrd orig, ANGLE_T angle ) { - signalData_p xx = GetsignalData ( trk ); - Rotate(&(xx->orig), orig, angle); - xx->angle = NormalizeAngle(xx->angle + angle); - ComputeSignalBoundingBox(trk); + signalData_p xx = GetsignalData ( trk ); + Rotate(&(xx->orig), orig, angle); + xx->angle = NormalizeAngle(xx->angle + angle); + ComputeSignalBoundingBox(trk); } -static void RescaleSignal (track_p trk, FLOAT_T ratio ) +static void RescaleSignal (track_p trk, FLOAT_T ratio ) { } static void FlipSignal (track_p trk, coOrd orig, ANGLE_T angle ) { - signalData_p xx = GetsignalData ( trk ); - FlipPoint(&(xx->orig), orig, angle); - xx->angle = NormalizeAngle(2*angle - xx->angle); - ComputeSignalBoundingBox(trk); + signalData_p xx = GetsignalData ( trk ); + FlipPoint(&(xx->orig), orig, angle); + xx->angle = NormalizeAngle(2*angle - xx->angle); + ComputeSignalBoundingBox(trk); } static trackCmd_t signalCmds = { - "SIGNAL", - DrawSignal, - DistanceSignal, - DescribeSignal, - DeleteSignal, - WriteSignal, - ReadSignal, - MoveSignal, - RotateSignal, - RescaleSignal, - NULL, /* audit */ - NULL, /* getAngle */ - NULL, /* split */ - NULL, /* traverse */ - NULL, /* enumerate */ - NULL, /* redraw */ - NULL, /* trim */ - NULL, /* merge */ - NULL, /* modify */ - NULL, /* getLength */ - NULL, /* getTrkParams */ - NULL, /* moveEndPt */ - NULL, /* query */ - NULL, /* ungroup */ - FlipSignal, /* flip */ - NULL, /* drawPositionIndicator */ - NULL, /* advancePositionIndicator */ - NULL, /* checkTraverse */ - NULL, /* makeParallel */ - NULL /* drawDesc */ + "SIGNAL", + DrawSignal, + DistanceSignal, + DescribeSignal, + DeleteSignal, + WriteSignal, + ReadSignal, + MoveSignal, + RotateSignal, + RescaleSignal, + NULL, /* audit */ + NULL, /* getAngle */ + NULL, /* split */ + NULL, /* traverse */ + NULL, /* enumerate */ + NULL, /* redraw */ + NULL, /* trim */ + NULL, /* merge */ + NULL, /* modify */ + NULL, /* getLength */ + NULL, /* getTrkParams */ + NULL, /* moveEndPt */ + NULL, /* query */ + NULL, /* ungroup */ + FlipSignal, /* flip */ + NULL, /* drawPositionIndicator */ + NULL, /* advancePositionIndicator */ + NULL, /* checkTraverse */ + NULL, /* makeParallel */ + NULL /* drawDesc */ }; static BOOL_T signalCreate_P; @@ -503,24 +507,24 @@ static paramFloatRange_t r_1000_1000 = { -1000.0, 1000.0, 80 }; static paramFloatRange_t r0_360 = { 0.0, 360.0, 80 }; static paramData_t signalEditPLs[] = { #define I_SIGNALNAME (0) - /*0*/ { PD_STRING, signalEditName, "name", PDO_NOPREF|PDO_NOTBLANK, I2VP(200), N_("Name"), 0, 0, sizeof(signalEditName)}, + /*0*/ { PD_STRING, signalEditName, "name", PDO_NOPREF|PDO_NOTBLANK, I2VP(200), N_("Name"), 0, 0, sizeof(signalEditName)}, #define I_ORIGX (1) - /*1*/ { PD_FLOAT, &signalEditOrig.x, "origx", PDO_DIM, &r_1000_1000, N_("Origin X") }, + /*1*/ { PD_FLOAT, &signalEditOrig.x, "origx", PDO_DIM, &r_1000_1000, N_("Origin X") }, #define I_ORIGY (2) - /*2*/ { PD_FLOAT, &signalEditOrig.y, "origy", PDO_DIM, &r_1000_1000, N_("Origin Y") }, + /*2*/ { PD_FLOAT, &signalEditOrig.y, "origy", PDO_DIM, &r_1000_1000, N_("Origin Y") }, #define I_ANGLE (3) - /*3*/ { PD_FLOAT, &signalEditAngle, "origa", PDO_ANGLE, &r0_360, N_("Angle") }, + /*3*/ { PD_FLOAT, &signalEditAngle, "origa", PDO_ANGLE, &r0_360, N_("Angle") }, #define I_SIGNALHEADCOUNT (4) - /*4*/ { PD_LONG, &signalEditHeadCount, "headCount", PDO_NOPREF, &r1_3, N_("Number of Heads") }, + /*4*/ { PD_LONG, &signalEditHeadCount, "headCount", PDO_NOPREF, &r1_3, N_("Number of Heads") }, #define I_SIGNALASPECTLIST (5) #define aspectSelL ((wList_p)signalEditPLs[I_SIGNALASPECTLIST].control) - /*5*/ { PD_LIST, NULL, "inx", PDO_DLGRESETMARGIN|PDO_DLGRESIZE, &aspectListData, NULL, BL_MANY }, + /*5*/ { PD_LIST, NULL, "inx", PDO_DLGRESETMARGIN|PDO_DLGRESIZE, &aspectListData, NULL, BL_MANY }, #define I_SIGNALASPECTEDIT (6) - /*6*/ { PD_BUTTON, AspectEdit, "edit", PDO_DLGCMDBUTTON, NULL, N_("Edit Aspect") }, + /*6*/ { PD_BUTTON, AspectEdit, "edit", PDO_DLGCMDBUTTON, NULL, N_("Edit Aspect") }, #define I_SIGNALASPECTADD (7) - /*7*/ { PD_BUTTON, AspectAdd, "add", PDO_DLGCMDBUTTON, NULL, N_("Add Aspect") }, + /*7*/ { PD_BUTTON, AspectAdd, "add", PDO_DLGCMDBUTTON, NULL, N_("Add Aspect") }, #define I_SIGNALASPECTDELETE (8) - /*8*/ { PD_BUTTON, AspectDelete, "delete", 0, NULL, N_("Delete Aspect") }, + /*8*/ { PD_BUTTON, AspectDelete, "delete", 0, NULL, N_("Delete Aspect") }, }; static paramGroup_t signalEditPG = { "signalEdit", 0, signalEditPLs, COUNT( signalEditPLs ) }; static wWin_p signalEditW; @@ -529,11 +533,11 @@ static paramIntegerRange_t rm1_999999 = { -1, 999999 }; static paramData_t aspectEditPLs[] = { #define I_ASPECTNAME (0) - /*0*/ { PD_STRING, signalAspectEditName, "name", PDO_NOPREF|PDO_NOTBLANK, I2VP(200), N_("Name"), 0, 0, sizeof(signalAspectEditName)}, + /*0*/ { PD_STRING, signalAspectEditName, "name", PDO_NOPREF|PDO_NOTBLANK, I2VP(200), N_("Name"), 0, 0, sizeof(signalAspectEditName)}, #define I_ASPECTSCRIPT (1) - /*1*/ { PD_STRING, signalAspectEditScript, "script", PDO_NOPREF, I2VP(350), N_("Script"), 0, 0, sizeof(signalAspectEditScript)}, + /*1*/ { PD_STRING, signalAspectEditScript, "script", PDO_NOPREF, I2VP(350), N_("Script"), 0, 0, sizeof(signalAspectEditScript)}, #define I_ASPECTINDEX (2) - /*2*/ { PD_LONG, &signalAspectEditIndex, "index", PDO_NOPREF, &rm1_999999, N_("Aspect Index"), BO_READONLY }, + /*2*/ { PD_LONG, &signalAspectEditIndex, "index", PDO_NOPREF, &rm1_999999, N_("Aspect Index"), BO_READONLY }, }; static paramGroup_t aspectEditPG = { "aspectEdit", 0, aspectEditPLs, COUNT( aspectEditPLs ) }; @@ -542,224 +546,239 @@ static wWin_p aspectEditW; static void SignalEditOk ( void * junk ) { - track_p trk; - signalData_p xx; - wIndex_t ia; - CSIZE_T newsize; - - if (signalCreate_P) { - UndoStart( _("Create Signal"), "Create Signal"); - trk = NewTrack(0, T_SIGNAL, 0, sizeof(signalData_t)+(sizeof(signalAspect_t)*(signalAspect_da.cnt-1))+1); - xx = GetsignalData(trk); - } else { - UndoStart( _("Modify Signal"), "Modify Signal"); - trk = signalEditTrack; - xx = GetsignalData(trk); - if (xx->numAspects != signalAspect_da.cnt) { - /* We need to reallocate the extra data. */ - for (ia = 0; ia < xx->numAspects; ia++) { - MyFree((&(xx->aspectList))[ia].aspectName); - MyFree((&(xx->aspectList))[ia].aspectScript); - (&(xx->aspectList))[ia].aspectName = NULL; - (&(xx->aspectList))[ia].aspectScript = NULL; - } - newsize = sizeof(signalData_t)+(sizeof(signalAspect_t)*(signalAspect_da.cnt-1))+1; - trk->extraData = MyRealloc(trk->extraData,newsize); - trk->extraSize = newsize; - xx = GetsignalData(trk); - } - } - xx->orig = signalEditOrig; - xx->angle = signalEditAngle; - xx->numHeads = signalEditHeadCount; - if ( xx->name == NULL || strncmp (xx->name, signalEditName, STR_SHORT_SIZE) != 0) { - MyFree(xx->name); - xx->name = MyStrdup(signalEditName); - } - xx->numAspects = signalAspect_da.cnt; - for (ia = 0; ia < xx->numAspects; ia++) { - if ((&(xx->aspectList))[ia].aspectName == NULL) { - (&(xx->aspectList))[ia].aspectName = signalAspect(ia).aspectName; - } else if (strcmp((&(xx->aspectList))[ia].aspectName,signalAspect(ia).aspectName) != 0) { - MyFree((&(xx->aspectList))[ia].aspectName); - (&(xx->aspectList))[ia].aspectName = signalAspect(ia).aspectName; - } else { - MyFree(signalAspect(ia).aspectName); - } - if ((&(xx->aspectList))[ia].aspectScript == NULL) { - (&(xx->aspectList))[ia].aspectScript = signalAspect(ia).aspectScript; - } else if (strcmp((&(xx->aspectList))[ia].aspectScript,signalAspect(ia).aspectScript) != 0) { - MyFree((&(xx->aspectList))[ia].aspectScript); - (&(xx->aspectList))[ia].aspectScript = signalAspect(ia).aspectScript; - } else { - MyFree(signalAspect(ia).aspectScript); - } - } - UndoEnd(); - DoRedraw(); - ComputeSignalBoundingBox(trk); - wHide( signalEditW ); + track_p trk; + signalData_p xx; + wIndex_t ia; + CSIZE_T newsize; + + if (signalCreate_P) { + UndoStart( _("Create Signal"), "Create Signal"); + trk = NewTrack(0, T_SIGNAL, 0, + sizeof(signalData_t)+(sizeof(signalAspect_t)*(signalAspect_da.cnt-1))+1); + xx = GetsignalData(trk); + } else { + UndoStart( _("Modify Signal"), "Modify Signal"); + trk = signalEditTrack; + xx = GetsignalData(trk); + if (xx->numAspects != signalAspect_da.cnt) { + /* We need to reallocate the extra data. */ + for (ia = 0; ia < xx->numAspects; ia++) { + MyFree((&(xx->aspectList))[ia].aspectName); + MyFree((&(xx->aspectList))[ia].aspectScript); + (&(xx->aspectList))[ia].aspectName = NULL; + (&(xx->aspectList))[ia].aspectScript = NULL; + } + newsize = sizeof(signalData_t)+(sizeof(signalAspect_t)*(signalAspect_da.cnt-1)) + +1; + ResizeExtraData( trk, newsize ); + xx = GetsignalData(trk); + } + } + xx->orig = signalEditOrig; + xx->angle = signalEditAngle; + xx->numHeads = signalEditHeadCount; + if ( xx->name == NULL + || strncmp (xx->name, signalEditName, STR_SHORT_SIZE) != 0) { + MyFree(xx->name); + xx->name = MyStrdup(signalEditName); + } + xx->numAspects = signalAspect_da.cnt; + for (ia = 0; ia < xx->numAspects; ia++) { + if ((&(xx->aspectList))[ia].aspectName == NULL) { + (&(xx->aspectList))[ia].aspectName = signalAspect(ia).aspectName; + } else if (strcmp((&(xx->aspectList))[ia].aspectName, + signalAspect(ia).aspectName) != 0) { + MyFree((&(xx->aspectList))[ia].aspectName); + (&(xx->aspectList))[ia].aspectName = signalAspect(ia).aspectName; + } else { + MyFree(signalAspect(ia).aspectName); + } + if ((&(xx->aspectList))[ia].aspectScript == NULL) { + (&(xx->aspectList))[ia].aspectScript = signalAspect(ia).aspectScript; + } else if (strcmp((&(xx->aspectList))[ia].aspectScript, + signalAspect(ia).aspectScript) != 0) { + MyFree((&(xx->aspectList))[ia].aspectScript); + (&(xx->aspectList))[ia].aspectScript = signalAspect(ia).aspectScript; + } else { + MyFree(signalAspect(ia).aspectScript); + } + } + UndoEnd(); + DoRedraw(); + ComputeSignalBoundingBox(trk); + wHide( signalEditW ); } static void SignalEditCancel ( wWin_p junk ) { - wIndex_t ia; + wIndex_t ia; - for (ia = 0; ia < signalAspect_da.cnt; ia++) { - MyFree(signalAspect(ia).aspectName); - MyFree(signalAspect(ia).aspectScript); - } - DYNARR_RESET( signalAspect_p, signalAspect_da ); - wHide( signalEditW ); + for (ia = 0; ia < signalAspect_da.cnt; ia++) { + MyFree(signalAspect(ia).aspectName); + MyFree(signalAspect(ia).aspectScript); + } + DYNARR_RESET( signalAspect_p, signalAspect_da ); + wHide( signalEditW ); } static void SignalEditDlgUpdate (paramGroup_p pg, int inx, void *valueP ) { - wIndex_t selcnt = wListGetSelectedCount( aspectSelL ); - - if ( inx != I_SIGNALASPECTLIST ) return; - ParamControlActive( &signalEditPG, I_SIGNALASPECTEDIT, selcnt>0 ); - ParamControlActive( &signalEditPG, I_SIGNALASPECTADD, TRUE ); - ParamControlActive( &signalEditPG, I_SIGNALASPECTDELETE, selcnt>0 ); + wIndex_t selcnt = wListGetSelectedCount( aspectSelL ); + + if ( inx != I_SIGNALASPECTLIST ) { return; } + ParamControlActive( &signalEditPG, I_SIGNALASPECTEDIT, selcnt>0 ); + ParamControlActive( &signalEditPG, I_SIGNALASPECTADD, TRUE ); + ParamControlActive( &signalEditPG, I_SIGNALASPECTDELETE, selcnt>0 ); } static void aspectEditOK ( void * junk ) { - if (signalAspectEditIndex < 0) { - DYNARR_APPEND( signalAspect_p *, signalAspect_da, 10 ); - signalAspect(signalAspect_da.cnt-1).aspectName = MyStrdup(signalAspectEditName); - signalAspect(signalAspect_da.cnt-1).aspectScript = MyStrdup(signalAspectEditScript); - snprintf(message,sizeof(message),"%s\t%s",signalAspectEditName,signalAspectEditScript); - wListAddValue( aspectSelL, message, NULL, NULL ); - } else { - if ( strncmp( signalAspectEditName, signalAspect(signalAspectEditIndex).aspectName,STR_SHORT_SIZE ) != 0 ) { - MyFree(signalAspect(signalAspectEditIndex).aspectName); - signalAspect(signalAspectEditIndex).aspectName = MyStrdup(signalAspectEditName); - } - if ( strncmp( signalAspectEditScript, signalAspect(signalAspectEditIndex).aspectScript, STR_LONG_SIZE ) != 0 ) { - MyFree(signalAspect(signalAspectEditIndex).aspectScript); - signalAspect(signalAspectEditIndex).aspectScript = MyStrdup(signalAspectEditScript); - } - snprintf(message,sizeof(message),"%s\t%s",signalAspect(signalAspectEditIndex).aspectName,signalAspect(signalAspectEditIndex).aspectScript); - wListSetValues( aspectSelL, signalAspectEditIndex, message, NULL, NULL ); - } - wHide( aspectEditW ); + if (signalAspectEditIndex < 0) { + DYNARR_APPEND( signalAspect_p *, signalAspect_da, 10 ); + signalAspect(signalAspect_da.cnt-1).aspectName = MyStrdup(signalAspectEditName); + signalAspect(signalAspect_da.cnt-1).aspectScript = MyStrdup( + signalAspectEditScript); + snprintf(message,sizeof(message),"%s\t%s",signalAspectEditName, + signalAspectEditScript); + wListAddValue( aspectSelL, message, NULL, NULL ); + } else { + if ( strncmp( signalAspectEditName, + signalAspect(signalAspectEditIndex).aspectName,STR_SHORT_SIZE ) != 0 ) { + MyFree(signalAspect(signalAspectEditIndex).aspectName); + signalAspect(signalAspectEditIndex).aspectName = MyStrdup(signalAspectEditName); + } + if ( strncmp( signalAspectEditScript, + signalAspect(signalAspectEditIndex).aspectScript, STR_LONG_SIZE ) != 0 ) { + MyFree(signalAspect(signalAspectEditIndex).aspectScript); + signalAspect(signalAspectEditIndex).aspectScript = MyStrdup( + signalAspectEditScript); + } + snprintf(message,sizeof(message),"%s\t%s", + signalAspect(signalAspectEditIndex).aspectName, + signalAspect(signalAspectEditIndex).aspectScript); + wListSetValues( aspectSelL, signalAspectEditIndex, message, NULL, NULL ); + } + wHide( aspectEditW ); } static void EditAspectDialog ( wIndex_t inx ) { - if (inx < 0) { - signalAspectEditName[0] = '\0'; - signalAspectEditScript[0] = '\0'; - } else { - strncpy(signalAspectEditName,signalAspect(inx).aspectName,STR_SHORT_SIZE); - strncpy(signalAspectEditScript,signalAspect(inx).aspectScript,STR_LONG_SIZE); - } - signalAspectEditIndex = inx; - if ( !aspectEditW ) { - ParamRegister( &aspectEditPG ); - aspectEditW = ParamCreateDialog (&aspectEditPG, - MakeWindowTitle(_("Edit aspect")), - _("Ok"), aspectEditOK, - wHide, TRUE, NULL,F_BLOCK,NULL); - } - ParamLoadControls( &aspectEditPG ); - wShow( aspectEditW ); + if (inx < 0) { + signalAspectEditName[0] = '\0'; + signalAspectEditScript[0] = '\0'; + } else { + strncpy(signalAspectEditName,signalAspect(inx).aspectName,STR_SHORT_SIZE); + strncpy(signalAspectEditScript,signalAspect(inx).aspectScript,STR_LONG_SIZE); + } + signalAspectEditIndex = inx; + if ( !aspectEditW ) { + ParamRegister( &aspectEditPG ); + aspectEditW = ParamCreateDialog (&aspectEditPG, + MakeWindowTitle(_("Edit aspect")), + _("Ok"), aspectEditOK, + wHide, TRUE, NULL,F_BLOCK,NULL); + } + ParamLoadControls( &aspectEditPG ); + wShow( aspectEditW ); } static void AspectEdit( void * action ) { - wIndex_t selcnt = wListGetSelectedCount( aspectSelL ); - wIndex_t inx, cnt; - - if ( selcnt != 1) return; - cnt = wListGetCount( aspectSelL ); - for ( inx=0; - inx<cnt && wListGetItemSelected( aspectSelL, inx ) != TRUE; - inx++ ); - if ( inx >= cnt ) return; - EditAspectDialog(inx); + wIndex_t selcnt = wListGetSelectedCount( aspectSelL ); + wIndex_t inx, cnt; + + if ( selcnt != 1) { return; } + cnt = wListGetCount( aspectSelL ); + for ( inx=0; + inx<cnt && wListGetItemSelected( aspectSelL, inx ) != TRUE; + inx++ ); + if ( inx >= cnt ) { return; } + EditAspectDialog(inx); } static void AspectAdd( void * action ) { - EditAspectDialog(-1); + EditAspectDialog(-1); } static void MoveAspectUp (wIndex_t inx) { - wIndex_t cnt = signalAspect_da.cnt; - wIndex_t ia; - - MyFree(signalAspect(inx).aspectName); - MyFree(signalAspect(inx).aspectScript); - for (ia = inx+1; ia < cnt; ia++) { - signalAspect(ia-1).aspectName = signalAspect(ia).aspectName; - signalAspect(ia-1).aspectScript = signalAspect(ia).aspectScript; - } - DYNARR_SET(signalAspect_t,signalAspect_da,cnt-1); + wIndex_t cnt = signalAspect_da.cnt; + wIndex_t ia; + + MyFree(signalAspect(inx).aspectName); + MyFree(signalAspect(inx).aspectScript); + for (ia = inx+1; ia < cnt; ia++) { + signalAspect(ia-1).aspectName = signalAspect(ia).aspectName; + signalAspect(ia-1).aspectScript = signalAspect(ia).aspectScript; + } + DYNARR_SET(signalAspect_t,signalAspect_da,cnt-1); } static void AspectDelete( void * action ) { - wIndex_t selcnt = wListGetSelectedCount( aspectSelL ); - wIndex_t inx, cnt; - - if ( selcnt <= 0) return; - if ( (!NoticeMessage2( 1, _("Are you sure you want to delete the %d aspect(s)"), _("Yes"), _("No"), selcnt ) ) ) - return; - cnt = wListGetCount( aspectSelL ); - for ( inx=0; inx<cnt; inx++ ) { - if ( !wListGetItemSelected( aspectSelL, inx ) ) continue; - wListDelete( aspectSelL, inx ); - MoveAspectUp(inx); - inx--; - cnt--; - } - DoChangeNotification( CHANGE_PARAMS ); + wIndex_t selcnt = wListGetSelectedCount( aspectSelL ); + wIndex_t inx, cnt; + + if ( selcnt <= 0) { return; } + if ( (!NoticeMessage2( 1, _("Are you sure you want to delete the %d aspect(s)"), + _("Yes"), _("No"), selcnt ) ) ) { + return; + } + cnt = wListGetCount( aspectSelL ); + for ( inx=0; inx<cnt; inx++ ) { + if ( !wListGetItemSelected( aspectSelL, inx ) ) { continue; } + wListDelete( aspectSelL, inx ); + MoveAspectUp(inx); + inx--; + cnt--; + } + DoChangeNotification( CHANGE_PARAMS ); } static void EditSignalDialog() { - signalData_p xx; - wIndex_t ia; - - if ( !signalEditW ) { - ParamRegister( &signalEditPG ); - signalEditW = ParamCreateDialog (&signalEditPG, - MakeWindowTitle(_("Edit signal")), - _("Ok"), SignalEditOk, - SignalEditCancel, TRUE, NULL, - F_RESIZE|F_RECALLSIZE|F_BLOCK, - SignalEditDlgUpdate ); - } - if (signalCreate_P) { - signalEditName[0] = '\0'; - signalEditHeadCount = 1; - wListClear( aspectSelL ); - DYNARR_RESET( signalAspect_p, signalAspect_da ); - } else { - xx = GetsignalData ( signalEditTrack ); - strncpy(signalEditName,xx->name,STR_SHORT_SIZE); - signalEditHeadCount = xx->numHeads; - signalEditOrig = xx->orig; - signalEditAngle = xx->angle; - wListClear( aspectSelL ); - DYNARR_RESET( signalAspect_p, signalAspect_da ); - for (ia = 0; ia < xx->numAspects; ia++) { - snprintf(message,sizeof(message),"%s\t%s",(&(xx->aspectList))[ia].aspectName, - (&(xx->aspectList))[ia].aspectScript); - wListAddValue( aspectSelL, message, NULL, NULL ); - DYNARR_APPEND( signalAspect_p *, signalAspect_da, 10 ); - signalAspect(signalAspect_da.cnt-1).aspectName = MyStrdup((&(xx->aspectList))[ia].aspectName); - signalAspect(signalAspect_da.cnt-1).aspectScript = MyStrdup((&(xx->aspectList))[ia].aspectScript); - } - } - ParamLoadControls( &signalEditPG ); - ParamControlActive( &signalEditPG, I_SIGNALASPECTEDIT, FALSE ); - ParamControlActive( &signalEditPG, I_SIGNALASPECTADD, TRUE ); - ParamControlActive( &signalEditPG, I_SIGNALASPECTDELETE, FALSE ); - wShow( signalEditW ); + signalData_p xx; + wIndex_t ia; + + if ( !signalEditW ) { + ParamRegister( &signalEditPG ); + signalEditW = ParamCreateDialog (&signalEditPG, + MakeWindowTitle(_("Edit signal")), + _("Ok"), SignalEditOk, + SignalEditCancel, TRUE, NULL, + F_RESIZE|F_RECALLSIZE|F_BLOCK, + SignalEditDlgUpdate ); + } + if (signalCreate_P) { + signalEditName[0] = '\0'; + signalEditHeadCount = 1; + wListClear( aspectSelL ); + DYNARR_RESET( signalAspect_p, signalAspect_da ); + } else { + xx = GetsignalData ( signalEditTrack ); + strncpy(signalEditName,xx->name,STR_SHORT_SIZE); + signalEditHeadCount = xx->numHeads; + signalEditOrig = xx->orig; + signalEditAngle = xx->angle; + wListClear( aspectSelL ); + DYNARR_RESET( signalAspect_p, signalAspect_da ); + for (ia = 0; ia < xx->numAspects; ia++) { + snprintf(message,sizeof(message),"%s\t%s",(&(xx->aspectList))[ia].aspectName, + (&(xx->aspectList))[ia].aspectScript); + wListAddValue( aspectSelL, message, NULL, NULL ); + DYNARR_APPEND( signalAspect_p *, signalAspect_da, 10 ); + signalAspect(signalAspect_da.cnt-1).aspectName = MyStrdup((& + (xx->aspectList))[ia].aspectName); + signalAspect(signalAspect_da.cnt-1).aspectScript = MyStrdup((& + (xx->aspectList))[ia].aspectScript); + } + } + ParamLoadControls( &signalEditPG ); + ParamControlActive( &signalEditPG, I_SIGNALASPECTEDIT, FALSE ); + ParamControlActive( &signalEditPG, I_SIGNALASPECTADD, TRUE ); + ParamControlActive( &signalEditPG, I_SIGNALASPECTDELETE, FALSE ); + wShow( signalEditW ); } @@ -767,17 +786,17 @@ static void EditSignalDialog() static void EditSignal (track_p trk) { - signalCreate_P = FALSE; - signalEditTrack = trk; - EditSignalDialog(); + signalCreate_P = FALSE; + signalEditTrack = trk; + EditSignalDialog(); } static void CreateNewSignal (coOrd orig, ANGLE_T angle) { - signalCreate_P = TRUE; - signalEditOrig = orig; - signalEditAngle = angle; - EditSignalDialog(); + signalCreate_P = TRUE; + signalEditOrig = orig; + signalEditAngle = angle; + EditSignalDialog(); } static coOrd pos0; @@ -785,39 +804,41 @@ static ANGLE_T orient; static STATUS_T CmdSignal ( wAction_t action, coOrd pos ) { - - static BOOL_T create; - switch (action) { - case C_START: - InfoMessage(_("Place base of signal")); - create = FALSE; - SetAllTrackSelect( FALSE ); - return C_CONTINUE; - case C_DOWN: - SnapPos(&pos); - pos0 = pos; - create = TRUE; - InfoMessage(_("Drag to orient signal")); - return C_CONTINUE; - case C_MOVE: - SnapPos(&pos); - orient = FindAngle(pos0,pos); - return C_CONTINUE; - case C_UP: - SnapPos(&pos); - orient = FindAngle(pos0,pos); - CreateNewSignal(pos0,orient); - return C_TERMINATE; - case C_REDRAW: - if (create) - DDrawSignal( &tempD, pos0, orient, 1, GetScaleRatio(GetLayoutCurScale()), wDrawColorBlack ); - return C_CONTINUE; - case C_CANCEL: - create = FALSE; - return C_CONTINUE; - default: - return C_CONTINUE; - } + + static BOOL_T create; + switch (action) { + case C_START: + InfoMessage(_("Place base of signal")); + create = FALSE; + SetAllTrackSelect( FALSE ); + return C_CONTINUE; + case C_DOWN: + SnapPos(&pos); + pos0 = pos; + create = TRUE; + InfoMessage(_("Drag to orient signal")); + return C_CONTINUE; + case C_MOVE: + SnapPos(&pos); + orient = FindAngle(pos0,pos); + return C_CONTINUE; + case C_UP: + SnapPos(&pos); + orient = FindAngle(pos0,pos); + CreateNewSignal(pos0,orient); + return C_TERMINATE; + case C_REDRAW: + if (create) { + DDrawSignal( &tempD, pos0, orient, 1, GetScaleRatio(GetLayoutCurScale()), + wDrawColorBlack ); + } + return C_CONTINUE; + case C_CANCEL: + create = FALSE; + return C_CONTINUE; + default: + return C_CONTINUE; + } } static coOrd sighiliteOrig, sighiliteSize; @@ -825,92 +846,95 @@ static POS_T sighiliteBorder; static wDrawColor sighiliteColor = 0; static void DrawSignalTrackHilite( void ) { - if (sighiliteColor==0) + if (sighiliteColor==0) { sighiliteColor = wDrawColorGray(87); - DrawRectangle( &tempD, sighiliteOrig, sighiliteSize, sighiliteColor, DRAW_TRANSPARENT ); + } + DrawRectangle( &tempD, sighiliteOrig, sighiliteSize, sighiliteColor, + DRAW_TRANSPARENT ); } static int SignalMgmProc ( int cmd, void * data ) { - track_p trk = (track_p) data; - signalData_p xx = GetsignalData(trk); - /*char msg[STR_SIZE];*/ - - switch ( cmd ) { - case CONTMGM_CAN_EDIT: - return TRUE; - break; - case CONTMGM_DO_EDIT: - EditSignal(trk); - return TRUE; - break; - case CONTMGM_CAN_DELETE: - return TRUE; - break; - case CONTMGM_DO_DELETE: - DeleteTrack(trk, FALSE); - return TRUE; - break; - case CONTMGM_DO_HILIGHT: - if (!xx->IsHilite) { - sighiliteBorder = mainD.scale*0.1; - if ( sighiliteBorder < trackGauge ) sighiliteBorder = trackGauge; - GetBoundingBox( trk, &sighiliteSize, &sighiliteOrig ); - sighiliteOrig.x -= sighiliteBorder; - sighiliteOrig.y -= sighiliteBorder; - sighiliteSize.x -= sighiliteOrig.x-sighiliteBorder; - sighiliteSize.y -= sighiliteOrig.y-sighiliteBorder; - DrawSignalTrackHilite(); - xx->IsHilite = TRUE; - } - break; - case CONTMGM_UN_HILIGHT: - if (xx->IsHilite) { - sighiliteBorder = mainD.scale*0.1; - if ( sighiliteBorder < trackGauge ) sighiliteBorder = trackGauge; - GetBoundingBox( trk, &sighiliteSize, &sighiliteOrig ); - sighiliteOrig.x -= sighiliteBorder; - sighiliteOrig.y -= sighiliteBorder; - sighiliteSize.x -= sighiliteOrig.x-sighiliteBorder; - sighiliteSize.y -= sighiliteOrig.y-sighiliteBorder; - DrawSignalTrackHilite(); - xx->IsHilite = FALSE; - } - break; - case CONTMGM_GET_TITLE: - sprintf(message,"\t%s\t",xx->name); - break; - } - return FALSE; -} - -#include "bitmaps/signal.xpm" + track_p trk = (track_p) data; + signalData_p xx = GetsignalData(trk); + /*char msg[STR_SIZE];*/ + + switch ( cmd ) { + case CONTMGM_CAN_EDIT: + return TRUE; + break; + case CONTMGM_DO_EDIT: + EditSignal(trk); + return TRUE; + break; + case CONTMGM_CAN_DELETE: + return TRUE; + break; + case CONTMGM_DO_DELETE: + DeleteTrack(trk, FALSE); + return TRUE; + break; + case CONTMGM_DO_HILIGHT: + if (!xx->IsHilite) { + sighiliteBorder = mainD.scale*0.1; + if ( sighiliteBorder < trackGauge ) { sighiliteBorder = trackGauge; } + GetBoundingBox( trk, &sighiliteSize, &sighiliteOrig ); + sighiliteOrig.x -= sighiliteBorder; + sighiliteOrig.y -= sighiliteBorder; + sighiliteSize.x -= sighiliteOrig.x-sighiliteBorder; + sighiliteSize.y -= sighiliteOrig.y-sighiliteBorder; + DrawSignalTrackHilite(); + xx->IsHilite = TRUE; + } + break; + case CONTMGM_UN_HILIGHT: + if (xx->IsHilite) { + sighiliteBorder = mainD.scale*0.1; + if ( sighiliteBorder < trackGauge ) { sighiliteBorder = trackGauge; } + GetBoundingBox( trk, &sighiliteSize, &sighiliteOrig ); + sighiliteOrig.x -= sighiliteBorder; + sighiliteOrig.y -= sighiliteBorder; + sighiliteSize.x -= sighiliteOrig.x-sighiliteBorder; + sighiliteSize.y -= sighiliteOrig.y-sighiliteBorder; + DrawSignalTrackHilite(); + xx->IsHilite = FALSE; + } + break; + case CONTMGM_GET_TITLE: + sprintf(message,"\t%s\t",xx->name); + break; + } + return FALSE; +} + +#include "bitmaps/signal.xpm3" EXPORT void SignalMgmLoad ( void ) { - track_p trk; - static wIcon_p signalI = NULL; - - if (signalI == NULL) { - signalI = wIconCreatePixMap( signal_xpm[iconSize] ); - } - - TRK_ITERATE(trk) { - if (GetTrkType(trk) != T_SIGNAL) continue; - ContMgmLoad (signalI, SignalMgmProc, trk ); - } + track_p trk; + static wIcon_p signalI = NULL; + + if (signalI == NULL) { + signalI = wIconCreatePixMap( signal_xpm3[iconSize] ); + } + + TRK_ITERATE(trk) { + if (GetTrkType(trk) != T_SIGNAL) { continue; } + ContMgmLoad (signalI, SignalMgmProc, trk ); + } } #define ACCL_SIGNAL 0 EXPORT void InitCmdSignal ( wMenu_p menu ) { - AddMenuButton( menu, CmdSignal, "cmdSignal", _("Signal"), - wIconCreatePixMap( signal_xpm[iconSize] ), LEVEL0_50, IC_STICKY|IC_POPUP2, ACCL_SIGNAL, NULL ); + AddMenuButton( menu, CmdSignal, "cmdSignal", _("Signal"), + wIconCreatePixMap( signal_xpm3[iconSize] ), LEVEL0_50, IC_STICKY|IC_POPUP2, + ACCL_SIGNAL, NULL ); } EXPORT void InitTrkSignal ( void ) { - T_SIGNAL = InitObject ( &signalCmds ); - log_signal = LogFindIndex ( "signal" ); + T_SIGNAL = InitObject ( &signalCmds ); + log_signal = LogFindIndex ( "signal" ); } diff --git a/app/bin/csnap.c b/app/bin/csnap.c index 5c437fa..baf6998 100644 --- a/app/bin/csnap.c +++ b/app/bin/csnap.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "custom.h" @@ -31,11 +31,11 @@ int log_timedrawgrid = 0; /***************************************************************************** * - + * */ -EXPORT long minGridSpacing = 3; +EXPORT long minGridSpacing = 5; #define CROSSTICK #ifdef CROSSTICK @@ -46,17 +46,17 @@ static wDrawBitMap_p cross0_bm; #define DEFAULTGRIDSPACING (1.0) EXPORT void MapGrid( - coOrd orig, - coOrd size, - ANGLE_T angle, - coOrd gridOrig, - ANGLE_T gridAngle, - POS_T Xspacing, - POS_T Yspacing, - int * x0, - int * x1, - int * y0, - int * y1 ) + coOrd orig, + coOrd size, + ANGLE_T angle, + coOrd gridOrig, + ANGLE_T gridAngle, + POS_T Xspacing, + POS_T Yspacing, + int * x0, + int * x1, + int * y0, + int * y1 ) { coOrd p[4], hi, lo; int i; @@ -76,14 +76,18 @@ EXPORT void MapGrid( } hi = lo = p[0]; for (i=1; i<4; i++) { - if (hi.x < p[i].x) + if (hi.x < p[i].x) { hi.x = p[i].x; - if (hi.y < p[i].y) + } + if (hi.y < p[i].y) { hi.y = p[i].y; - if (lo.x > p[i].x) + } + if (lo.x > p[i].x) { lo.x = p[i].x; - if (lo.y > p[i].y) + } + if (lo.y > p[i].y) { lo.y = p[i].y; + } } *x0 = (int)floor( lo.x / Xspacing ); *y0 = (int)floor( lo.y / Yspacing ); @@ -95,15 +99,16 @@ EXPORT void MapGrid( static DIST_T Gdx, Gdy, Ddx, Ddy; static coOrd GDorig; static wDrawPix_t lborder, bborder; +int nDrawGridPoints = 0; void static DrawGridPoint( - drawCmd_p D, - wDrawColor Color, - coOrd orig, - coOrd * size, - DIST_T dpi, - coOrd p0, - BOOL_T bigdot ) + drawCmd_p D, + wDrawColor Color, + coOrd orig, + coOrd * size, + DIST_T dpi, + coOrd p0, + BOOL_T bigdot ) { // Map Grid index to Layout pos POS_T x; @@ -111,29 +116,34 @@ void static DrawGridPoint( p0.y = (p0.y*Gdx - p0.x*Gdy) + orig.y; p0.x = x; if (size && - ( p0.x < 0.0 || p0.x > size->x || - p0.y < 0.0 || p0.y > size->y ) ) + ( p0.x < 0.0 || p0.x > size->x || + p0.y < 0.0 || p0.y > size->y ) ) { return; + } DIST_T r; + nDrawGridPoints++; if ( bigdot ) { r = (bigdot_width+0.5)/2 - 0.5; } else { r = 0.75; } - r /= dpi; - DrawFillCircle( D, p0, r, Color ); + coOrd sz; + sz.x = sz.y = (bigdot?2.5:1.5)/dpi; + p0.x -= 1.0/dpi; + p0.y -= 1.0/dpi; + DrawRectangle( D, p0, sz, Color, DRAW_FILL ); } static void DrawGridLine( - drawCmd_p D, - wDrawColor Color, - coOrd orig, - coOrd * size, - DIST_T dpi, - BOOL_T clip, - coOrd p0, - coOrd p1 ) + drawCmd_p D, + wDrawColor Color, + coOrd orig, + coOrd * size, + DIST_T dpi, + BOOL_T clip, + coOrd p0, + coOrd p1 ) { POS_T x; x = (p0.x*Gdx + p0.y*Gdy) + orig.x; @@ -142,23 +152,24 @@ static void DrawGridLine( x = (p1.x*Gdx + p1.y*Gdy) + orig.x; p1.y = (p1.y*Gdx - p1.x*Gdy) + orig.y; p1.x = x; - if (size && clip && !ClipLine( &p0, &p1, zero, 0.0, *size )) + if (size && clip && !ClipLine( &p0, &p1, zero, 0.0, *size )) { return; + } DrawLine( D, p0, p1, 0, Color ); } EXPORT void DrawGrid( - drawCmd_p D, - coOrd * size, - POS_T hMajSpacing, - POS_T vMajSpacing, - long Hdivision, - long Vdivision, - coOrd Gorig, - ANGLE_T Gangle, - wDrawColor Color, - BOOL_T clip ) + drawCmd_p D, + coOrd * size, + POS_T hMajSpacing, + POS_T vMajSpacing, + long Hdivision, + long Vdivision, + coOrd Gorig, + ANGLE_T Gangle, + wDrawColor Color, + BOOL_T clip ) { int hMaj, hMajCnt0, hMajCnt1, vMaj, vMajCnt0, vMajCnt1; coOrd p0, p1; @@ -169,15 +180,21 @@ EXPORT void DrawGrid( POS_T hMajSpacing_dpi, vMajSpacing_dpi; BOOL_T bigdot; - if (hMajSpacing <= 0 && vMajSpacing <= 0) + if (hMajSpacing <= 0 && vMajSpacing <= 0) { return; + } #ifdef CROSSTICK - if (!cross0_bm) - cross0_bm = wDrawBitMapCreate( mainD.d, cross0_width, cross0_height, 2, 2, cross0_bits ); + if (!cross0_bm) { + cross0_bm = wDrawBitMapCreate( mainD.d, cross0_width, cross0_height, 2, 2, + cross0_bits ); + } #endif + unsigned long drawOptions = D->options; + D->options |= DC_ROUND; unsigned long time0 = wGetTimer(); + nDrawGridPoints = 0; wSetCursor( mainD.d, wCursorWait ); dpi = D->dpi/D->scale; Gdx = cos(D2R(Gangle)); @@ -196,9 +213,9 @@ EXPORT void DrawGrid( vMajSpacing_dpi = vMajSpacing*dpi; MapGrid( D->orig, D->size, D->angle, Gorig, Gangle, - (hMajSpacing>0?hMajSpacing:vMajSpacing), - (vMajSpacing>0?vMajSpacing:hMajSpacing), - &hMajCnt0, &hMajCnt1, &vMajCnt0, &vMajCnt1 ); + (hMajSpacing>0?hMajSpacing:vMajSpacing), + (vMajSpacing>0?vMajSpacing:hMajSpacing), + &hMajCnt0, &hMajCnt1, &vMajCnt0, &vMajCnt1 ); hMinCnt1 = vMinCnt1 = 0; @@ -213,8 +230,9 @@ EXPORT void DrawGrid( } if ( Hdivision > 0 ) { hMinSpacing = hMajSpacing/Hdivision; - if (hMinSpacing*dpi > minGridSpacing) + if (hMinSpacing*dpi > minGridSpacing) { hMinCnt1 = (int)Hdivision; + } } } @@ -229,13 +247,15 @@ EXPORT void DrawGrid( } if ( Vdivision > 0 ) { vMinSpacing = vMajSpacing/Vdivision; - if (vMinSpacing*dpi > minGridSpacing) + if (vMinSpacing*dpi > minGridSpacing) { vMinCnt1 = (int)Vdivision; + } } } - if (hMinCnt1 <= 0 && vMinCnt1 <= 0) + if (hMinCnt1 <= 0 && vMinCnt1 <= 0) { goto done; + } if (hMajSpacing <= 0) { hMinCnt1 = vMinCnt1+1; @@ -282,7 +302,7 @@ EXPORT void DrawGrid( vMinCnt1 = (int)(Vdivision/f); vMinSpacing *= f; } - + bigdot = ( hMinSpacing*dpi > 10 && vMinSpacing*dpi > 10 ); for ( hMaj=hMajCnt0; hMaj<hMajCnt1; hMaj++ ) { for ( vMaj=vMajCnt0; vMaj<vMajCnt1; vMaj++ ) { @@ -295,11 +315,13 @@ EXPORT void DrawGrid( } } } - + done: + D->options = drawOptions; wSetCursor( mainD.d, defaultCursor ); - LOG( log_timedrawgrid, 1, ( "DrawGrid time = %lu mS\n", wGetTimer()-time0 ) ); + LOG( log_timedrawgrid, 1, ( "DrawGrid BD = %d, n = %d, time = %lu mS\n", bigdot, + nDrawGridPoints, wGetTimer()-time0 ) ); } @@ -308,8 +330,9 @@ static void DrawBigCross( coOrd pos, ANGLE_T angle ) { coOrd p0, p1; DIST_T d; - if (angleSystem!=ANGLE_POLAR) + if (angleSystem!=ANGLE_POLAR) { angle += 90.0; + } d = max( mainD.size.x, mainD.size.y ); Translate( &p0, pos, angle, d ); Translate( &p1, pos, angle+180, d ); @@ -326,10 +349,10 @@ static void DrawBigCross( coOrd pos, ANGLE_T angle ) EXPORT STATUS_T GridAction( - wAction_t action, - coOrd pos, - coOrd *orig, - DIST_T *angle ) + wAction_t action, + coOrd pos, + coOrd *orig, + DIST_T *angle ) { static coOrd pos0, pos1; @@ -357,8 +380,9 @@ EXPORT STATUS_T GridAction( if ( FindDistance(pos0, pos) > 0.1*mainD.scale ) { pos1 = pos; newAngle = FindAngle( pos0, pos1 ); - if (angleSystem!=ANGLE_POLAR) + if (angleSystem!=ANGLE_POLAR) { newAngle = newAngle-90.0; + } newAngle = NormalizeAngle( floor( newAngle*10.0 ) / 10.0 ); *angle = newAngle; } @@ -386,48 +410,55 @@ EXPORT STATUS_T GridAction( EXPORT wDrawColor snapGridColor; typedef struct { - DIST_T Spacing; - long Division; - long Enable; - } gridData; + DIST_T Spacing; + long Division; + long Enable; +} gridData; typedef struct { - gridData Horz; - gridData Vert; - coOrd Orig; - ANGLE_T Angle; - long Show; - } gridHVData; + gridData Horz; + gridData Vert; + coOrd Orig; + ANGLE_T Angle; + long Show; +} gridHVData; static gridHVData grid = { { 1.0, 0, 1 }, - { 1.0, 0, 1 } }; + { 1.0, 0, 1 } +}; EXPORT BOOL_T SnapPos( coOrd * pos ) { coOrd p; DIST_T spacing; - if ((MyGetKeyState() & WKEY_ALT) != 0) + if ((MyGetKeyState() & WKEY_ALT) != 0) { return FALSE; - if ( grid.Vert.Enable == FALSE && grid.Horz.Enable == FALSE ) + } + if ( grid.Vert.Enable == FALSE && grid.Horz.Enable == FALSE ) { return FALSE; + } p = *pos; p.x -= grid.Orig.x; p.y -= grid.Orig.y; Rotate( &p, zero, -grid.Angle ); if ( grid.Horz.Enable ) { - if ( grid.Horz.Division > 0 ) + if ( grid.Horz.Division > 0 ) { spacing = grid.Horz.Spacing / grid.Horz.Division; - else + } else { spacing = grid.Horz.Spacing; - if (spacing > 0.001) + } + if (spacing > 0.001) { p.x = floor(p.x/spacing+0.5) * spacing; + } } if ( grid.Vert.Enable ) { - if ( grid.Vert.Division > 0 ) + if ( grid.Vert.Division > 0 ) { spacing = grid.Vert.Spacing / grid.Vert.Division; - else + } else { spacing = grid.Vert.Spacing; - if (spacing > 0.001) + } + if (spacing > 0.001) { p.y = floor(p.y/spacing+0.5) * spacing; + } } REORIGIN1( p, grid.Angle, grid.Orig ); *pos = p; @@ -435,18 +466,30 @@ EXPORT BOOL_T SnapPos( coOrd * pos ) return TRUE; } +EXPORT BOOL_T SnapPosAngle( coOrd * pos, ANGLE_T * angle ) +{ + if ( SnapPos( pos ) ) { + *angle = grid.Angle; + return TRUE; + } + return FALSE; +} + -static void DrawASnapGrid( gridHVData * gridP, drawCmd_p d, coOrd size, BOOL_T drawDivisions ) +static void DrawASnapGrid( gridHVData * gridP, drawCmd_p d, coOrd size, + BOOL_T drawDivisions ) { - if (gridP->Horz.Spacing <= 0.0 && gridP->Vert.Spacing <= 0.0) + if (gridP->Horz.Spacing <= 0.0 && gridP->Vert.Spacing <= 0.0) { return; - if (gridP->Show == FALSE) + } + if (gridP->Show == FALSE) { return; + } DrawGrid( d, &size, - gridP->Horz.Spacing, gridP->Vert.Spacing, - drawDivisions?gridP->Horz.Division:0, - drawDivisions?gridP->Vert.Division:0, - gridP->Orig, gridP->Angle, snapGridColor, TRUE ); + gridP->Horz.Spacing, gridP->Vert.Spacing, + drawDivisions?gridP->Horz.Division:0, + drawDivisions?gridP->Vert.Division:0, + gridP->Orig, gridP->Angle, snapGridColor, TRUE ); } @@ -471,8 +514,6 @@ static wWin_p gridW; static wMenu_p snapGridPopupM; static wButton_p snapGridEnable_b; static wButton_p snapGridShow_b; -EXPORT wMenuToggle_p snapGridEnableMI; -EXPORT wMenuToggle_p snapGridShowMI; static gridHVData oldGrid; @@ -510,7 +551,8 @@ static paramData_t gridPLs[] = { { PD_FLOAT, &grid.Angle, "origa", PDO_ANGLE, &r0_360, N_("A") }, #define I_SHOW (11) #define gridShowT ((wChoice_p)gridPLs[I_SHOW].control) - { PD_TOGGLE, &grid.Show, "show", PDO_DLGIGNORELABELWIDTH, gridLabels, N_("Show"), BC_HORZ|BC_NOBORDER } }; + { PD_TOGGLE, &grid.Show, "show", PDO_DLGIGNORELABELWIDTH, gridLabels, N_("Show"), BC_HORZ|BC_NOBORDER } +}; static paramGroup_t gridPG = { "grid", PGO_RECORD, gridPLs, COUNT( gridPLs ) }; @@ -518,20 +560,20 @@ static paramGroup_t gridPG = { "grid", PGO_RECORD, gridPLs, COUNT( gridPLs ) }; static BOOL_T GridChanged( void ) { return - grid.Horz.Spacing != oldGrid.Horz.Spacing || - grid.Horz.Division != oldGrid.Horz.Division || - grid.Vert.Spacing != oldGrid.Vert.Spacing || - grid.Vert.Division != oldGrid.Vert.Division || - grid.Orig.x != oldGrid.Orig.x || - grid.Orig.y != oldGrid.Orig.y || - grid.Angle != oldGrid.Angle || - grid.Horz.Division != oldGrid.Horz.Division; + grid.Horz.Spacing != oldGrid.Horz.Spacing || + grid.Horz.Division != oldGrid.Horz.Division || + grid.Vert.Spacing != oldGrid.Vert.Spacing || + grid.Vert.Division != oldGrid.Vert.Division || + grid.Orig.x != oldGrid.Orig.x || + grid.Orig.y != oldGrid.Orig.y || + grid.Angle != oldGrid.Angle || + grid.Horz.Division != oldGrid.Horz.Division; } static void RedrawGrid( void ) { if (grid.Show != oldGrid.Show || - GridChanged() ) { + GridChanged() ) { wDrawDelayUpdate( tempD.d, TRUE ); MainRedraw(); // RedrawGrid wDrawDelayUpdate( tempD.d, FALSE ); @@ -545,19 +587,22 @@ static void GridOk( void * unused ) ParamLoadData( &gridPG ); if ( ( grid.Horz.Enable && grid.Horz.Spacing <= 0.0) || - ( grid.Vert.Enable && grid.Vert.Spacing <= 0.0) ) { + ( grid.Vert.Enable && grid.Vert.Spacing <= 0.0) ) { NoticeMessage( MSG_GRID_ENABLE_SPACE_GTR_0, _("Ok"), NULL ); return; } if ( grid.Horz.Spacing <= 0.0 && - grid.Vert.Spacing <= 0.0 ) + grid.Vert.Spacing <= 0.0 ) { grid.Show = FALSE; + } changes = 0; - if ( GridChanged() ) + if ( GridChanged() ) { changes |= CHANGE_GRID; - if (grid.Show != oldGrid.Show || changes != 0) + } + if (grid.Show != oldGrid.Show || changes != 0) { changes |= CHANGE_MAIN; + } DoChangeNotification( changes ); oldGrid = grid; Reset(); @@ -569,44 +614,55 @@ static void GridButtonUpdate( long mode0 ) long mode1; mode1 = 0; if ( grid.Show && - grid.Horz.Spacing <= 0.0 && - grid.Vert.Spacing <= 0.0 ) { + grid.Horz.Spacing <= 0.0 && + grid.Vert.Spacing <= 0.0 ) { grid.Show = FALSE; - if ( mode0&CHK_SHOW ) + if ( mode0&CHK_SHOW ) { ErrorMessage( MSG_GRID_SHOW_SPACE_GTR_0 ); + } } if ( grid.Horz.Enable && - grid.Horz.Spacing <= 0.0 ) { + grid.Horz.Spacing <= 0.0 ) { grid.Horz.Enable = FALSE; - if ( mode0&CHK_HENABLE ) + if ( mode0&CHK_HENABLE ) { mode1 |= CHK_HENABLE; + } } if ( grid.Vert.Enable && - grid.Vert.Spacing <= 0.0 ) { + grid.Vert.Spacing <= 0.0 ) { grid.Vert.Enable = FALSE; - if ( mode0&CHK_VENABLE ) + if ( mode0&CHK_VENABLE ) { mode1 |= CHK_VENABLE; + } } if ( mode1 && - (mode0&(CHK_HENABLE|CHK_VENABLE)) == mode1 ) + (mode0&(CHK_HENABLE|CHK_VENABLE)) == mode1 ) { ErrorMessage( MSG_GRID_ENABLE_SPACE_GTR_0 ); + } if ( gridShowT && - grid.Show != (wToggleGetValue( gridShowT ) != 0) ) + grid.Show != (wToggleGetValue( gridShowT ) != 0) ) { ParamLoadControl( &gridPG, I_SHOW ); + } if ( gridHorzEnableT && - grid.Horz.Enable != (wToggleGetValue( gridHorzEnableT ) != 0) ) + grid.Horz.Enable != (wToggleGetValue( gridHorzEnableT ) != 0) ) { ParamLoadControl( &gridPG, I_HORZENABLE ); + } if ( gridVertEnableT && - grid.Vert.Enable != (wToggleGetValue( gridVertEnableT ) != 0) ) + grid.Vert.Enable != (wToggleGetValue( gridVertEnableT ) != 0) ) { ParamLoadControl( &gridPG, I_VERTENABLE ); - if (snapGridEnable_b) + } + if (snapGridEnable_b) { wButtonSetBusy( snapGridEnable_b, grid.Horz.Enable||grid.Vert.Enable ); - if (snapGridShow_b) + } + if (snapGridShow_b) { wButtonSetBusy( snapGridShow_b, (wBool_t)grid.Show ); - if (snapGridEnableMI) + } + if (snapGridEnableMI) { wMenuToggleSet( snapGridEnableMI, grid.Horz.Enable||grid.Vert.Enable ); - if (snapGridShowMI) + } + if (snapGridShowMI) { wMenuToggleSet( snapGridShowMI, (wBool_t)grid.Show ); + } if ( mode0&CHK_SHOW ) { RedrawGrid(); @@ -617,19 +673,21 @@ static void GridButtonUpdate( long mode0 ) static void GridChange( long changes ) { - if ( (changes&(CHANGE_GRID|CHANGE_UNITS))==0 ) + if ( (changes&(CHANGE_GRID|CHANGE_UNITS))==0 ) { return; + } GridButtonUpdate( 0 ); - if (gridW==NULL || !wWinIsVisible(gridW)) + if (gridW==NULL || !wWinIsVisible(gridW)) { return; + } ParamLoadControls( &gridPG ); } static void GridDlgUpdate( - paramGroup_p pg, - int inx, - void * valueP ) + paramGroup_p pg, + int inx, + void * valueP ) { switch ( inx ) { case I_HORZENABLE: @@ -663,8 +721,8 @@ static void SnapGridRotate( void * pangle ) EXPORT STATUS_T CmdGrid( - wAction_t action, - coOrd pos ) + wAction_t action, + coOrd pos ) { STATUS_T rc; @@ -672,7 +730,8 @@ EXPORT STATUS_T CmdGrid( case C_START: if (gridW == NULL) { - gridW = ParamCreateDialog( &gridPG, MakeWindowTitle(_("Snap Grid")), _("Ok"), GridOk, (paramActionCancelProc)Reset, TRUE, NULL, 0, GridDlgUpdate ); + gridW = ParamCreateDialog( &gridPG, MakeWindowTitle(_("Snap Grid")), _("Ok"), + GridOk, (paramActionCancelProc)Reset, TRUE, NULL, 0, GridDlgUpdate ); } oldGrid = grid; ParamLoadControls( &gridPG ); @@ -694,10 +753,11 @@ EXPORT STATUS_T CmdGrid( case C_CONFIRM: if (GridChanged() || - grid.Show != oldGrid.Show ) + grid.Show != oldGrid.Show ) { return C_ERROR; - else + } else { return C_CONTINUE; + } case C_DOWN: case C_RDOWN: @@ -728,7 +788,7 @@ EXPORT STATUS_T CmdGrid( /** - * Initialize the user interface for the grid functions. + * Initialize the user interface for the grid functions. * * \param menu IN pulldown to which the grid function will be added * \return created command button @@ -738,18 +798,22 @@ EXPORT wIndex_t InitGrid( wMenu_p menu ) { ParamRegister( &gridPG ); RegisterChangeNotification( GridChange ); - if ( grid.Horz.Enable && grid.Horz.Spacing <= 0.0 ) + if ( grid.Horz.Enable && grid.Horz.Spacing <= 0.0 ) { grid.Horz.Enable = FALSE; - if ( grid.Vert.Enable && grid.Vert.Spacing <= 0.0 ) + } + if ( grid.Vert.Enable && grid.Vert.Spacing <= 0.0 ) { grid.Vert.Enable = FALSE; + } if ( grid.Horz.Spacing <= 0.0 && - grid.Vert.Spacing <= 0.0 ) + grid.Vert.Spacing <= 0.0 ) { grid.Show = FALSE; + } snapGridPopupM = MenuRegister( "Snap Grid Rotate" ); AddRotateMenu( snapGridPopupM, SnapGridRotate ); GridButtonUpdate( 0 ); log_timedrawgrid = LogFindIndex( "timedrawgrid" ); - return InitCommand( menu, CmdGrid, N_("Change Grid..."), NULL, LEVEL0, IC_CMDMENU, ACCL_GRIDW ); + return AddMenuButton( menu, CmdGrid, "cmdChange Grid...", N_("Change Grid..."), + NULL, LEVEL0, IC_CMDMENU, ACCL_GRIDW, NULL ); } @@ -766,11 +830,14 @@ EXPORT void SnapGridShow( void * unused ) GridButtonUpdate( CHK_SHOW ); } -#include "bitmaps/snap-curs.xpm" -#include "bitmaps/snap-grid.xpm" +#include "bitmaps/snap-curs.xpm3" +#include "bitmaps/snap-grid.xpm3" EXPORT void InitSnapGridButtons( void ) { - snapGridEnable_b = AddToolbarButton( "cmdGridEnable", wIconCreatePixMap(snap_curs_xpm[iconSize] ), 0, SnapGridEnable, NULL ); - snapGridShow_b = AddToolbarButton( "cmdGridShow", wIconCreatePixMap(snap_grid_xpm[iconSize] ), IC_MODETRAIN_TOO, SnapGridShow, NULL ); + snapGridEnable_b = AddToolbarButton( "cmdGridEnable", + wIconCreatePixMap(snap_curs_xpm3[iconSize] ), 0, SnapGridEnable, NULL ); + snapGridShow_b = AddToolbarButton( "cmdGridShow", + wIconCreatePixMap(snap_grid_xpm3[iconSize] ), IC_MODETRAIN_TOO, SnapGridShow, + NULL ); } diff --git a/app/bin/csplit.c b/app/bin/csplit.c index 49b87ce..154b837 100644 --- a/app/bin/csplit.c +++ b/app/bin/csplit.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "cundo.h" @@ -50,8 +50,9 @@ static void ChangeSplitEPMode( void * mode ) UndoModify( splitTrkTrk[inx] ); option = GetTrkEndOption( splitTrkTrk[inx], splitTrkEP[inx] ); option &= ~EPOPT_GAPPED; - if ( (imode&1) != 0 ) + if ( (imode&1) != 0 ) { option |= EPOPT_GAPPED; + } SetTrkEndOption( splitTrkTrk[inx], splitTrkEP[inx], option ); imode >>= 1; } @@ -59,7 +60,9 @@ static void ChangeSplitEPMode( void * mode ) DrawEndPt( &mainD, splitTrkTrk[1], splitTrkEP[1], wDrawColorBlack ); } -static void CreateSplitAnchorAngle(coOrd pos, track_p t, BOOL_T end, ANGLE_T a, BOOL_T trim) { +static void CreateSplitAnchorAngle(coOrd pos, track_p t, BOOL_T end, ANGLE_T a, + BOOL_T trim) +{ DIST_T d = tempD.scale*0.1; DIST_T w = tempD.scale/tempD.dpi*4; int i; @@ -70,7 +73,7 @@ static void CreateSplitAnchorAngle(coOrd pos, track_p t, BOOL_T end, ANGLE_T a, anchors(i).color = wDrawColorBlue; Translate(&anchors(i).u.l.pos[0],pos,a,trim?2*GetTrkGauge(t):GetTrkGauge(t)); Translate(&anchors(i).u.l.pos[1],pos,a,trim?2*-GetTrkGauge(t):-GetTrkGauge(t)); - anchors(i).width = w; + anchors(i).lineWidth = w; } else { DYNARR_APPEND(trkSeg_t,anchors_da,1); i = anchors_da.cnt-1; @@ -80,7 +83,7 @@ static void CreateSplitAnchorAngle(coOrd pos, track_p t, BOOL_T end, ANGLE_T a, Translate(&anchors(i).u.l.pos[0],anchors(i).u.l.pos[0],a+90,d); Translate(&anchors(i).u.l.pos[1],pos,a,-GetTrkGauge(t)); Translate(&anchors(i).u.l.pos[1],anchors(i).u.l.pos[1],a+90,-d); - anchors(i).width = w; + anchors(i).lineWidth = w; DYNARR_APPEND(trkSeg_t,anchors_da,1); i = anchors_da.cnt-1; anchors(i).type = SEG_STRLIN; @@ -89,17 +92,18 @@ static void CreateSplitAnchorAngle(coOrd pos, track_p t, BOOL_T end, ANGLE_T a, Translate(&anchors(i).u.l.pos[0],anchors(i).u.l.pos[0],a+90,-d); Translate(&anchors(i).u.l.pos[1],pos,a,-GetTrkGauge(t)); Translate(&anchors(i).u.l.pos[1],anchors(i).u.l.pos[1],a+90,d); - anchors(i).width = w; + anchors(i).lineWidth = w; } } -static void CreateSplitAnchor(coOrd pos, track_p t, BOOL_T end) { +static void CreateSplitAnchor(coOrd pos, track_p t, BOOL_T end) +{ ANGLE_T a = NormalizeAngle(GetAngleAtPoint(t,pos,NULL,NULL)+90.0); CreateSplitAnchorAngle(pos,t,end,a,FALSE); } -static void CreateTrimAnchorLeg(coOrd pos, ANGLE_T a, track_p t) { - DIST_T d = tempD.scale*0.1; +static void CreateTrimAnchorLeg(coOrd pos, ANGLE_T a, track_p t) +{ DIST_T w = tempD.scale/tempD.dpi*4; DYNARR_APPEND(trkSeg_t,anchors_da,1); int i = anchors_da.cnt-1; @@ -107,11 +111,12 @@ static void CreateTrimAnchorLeg(coOrd pos, ANGLE_T a, track_p t) { anchors(i).color = wDrawColorBlue; anchors(i).u.l.pos[0] = pos; Translate(&anchors(i).u.l.pos[1],pos,a,GetTrkGauge(t)*2); - anchors(i).width = w; + anchors(i).lineWidth = w; } -static void CreateTrimAnchor(coOrd pos, track_p t, track_p s, coOrd cursor) { +static void CreateTrimAnchor(coOrd pos, track_p t, track_p s, coOrd cursor) +{ ANGLE_T a = NormalizeAngle(GetAngleAtPoint(s,pos,NULL,NULL)); CreateSplitAnchorAngle(pos,t,FALSE,a,TRUE); ANGLE_T aa = FindAngle(pos,cursor); @@ -123,16 +128,16 @@ static STATUS_T CmdSplitTrack( wAction_t action, coOrd pos ) { track_p trk0, trk1; EPINX_T ep0 = 0; - int oldTrackCount; +// int oldTrackCount; int inx, mode, quad; ANGLE_T angle; switch (action) { case C_START: - InfoMessage( _("Select track to split") ); + InfoMessage( _("Select track and position for split") ); DYNARR_RESET(trkSeg_t,anchors_da); SetAllTrackSelect( FALSE ); - /* no break */ + /* no break */ case C_DOWN: case C_MOVE: return C_CONTINUE; @@ -146,7 +151,8 @@ static STATUS_T CmdSplitTrack( wAction_t action, coOrd pos ) return C_TERMINATE; } ep0 = PickEndPoint( pos, trk0 ); - if (IsClose(FindDistance(GetTrkEndPos(trk0,ep0),pos)) && (GetTrkEndTrk(trk0,ep0)!=NULL)) { + if (IsClose(FindDistance(GetTrkEndPos(trk0,ep0),pos)) + && (GetTrkEndTrk(trk0,ep0)!=NULL)) { pos = GetTrkEndPos(trk0,ep0); } else { if (!IsTrack(trk0) || @@ -161,11 +167,12 @@ static STATUS_T CmdSplitTrack( wAction_t action, coOrd pos ) return C_CONTINUE; } UndoStart( _("Split Track"), "SplitTrack( T%d[%d] )", GetTrkIndex(trk0), ep0 ); - oldTrackCount = trackCount; +// oldTrackCount = trackCount; SplitTrack( trk0, pos, ep0, &trk1, FALSE ); UndoEnd(); return C_TERMINATE; - } else if ((trk0 = OnTrack( &pos, FALSE, FALSE))!=NULL && CheckTrackLayerSilent( trk0 )) { + } else if ((trk0 = OnTrack( &pos, FALSE, FALSE))!=NULL + && CheckTrackLayerSilent( trk0 )) { if (!QueryTrack(trk0,Q_MODIFY_CAN_SPLIT)) { onTrackInSplit = FALSE; InfoMessage(_("Can't Split that Draw Object")); @@ -173,7 +180,7 @@ static STATUS_T CmdSplitTrack( wAction_t action, coOrd pos ) } onTrackInSplit = FALSE; UndoStart( _("Split Track"), "SplitTrack( T%d[%d] )", GetTrkIndex(trk0), ep0 ); - oldTrackCount = trackCount; +// oldTrackCount = trackCount; SplitTrack( trk0, pos, ep0, &trk1, FALSE ); UndoEnd(); return C_TERMINATE; @@ -186,56 +193,75 @@ static STATUS_T CmdSplitTrack( wAction_t action, coOrd pos ) break; case C_CMDMENU: splitTrkTrk[0] = OnTrack( &pos, TRUE, TRUE ); - if ( splitTrkTrk[0] == NULL ) + if ( splitTrkTrk[0] == NULL ) { return C_CONTINUE; + } if ( splitPopupM[0] == NULL ) { splitPopupM[0] = MenuRegister( "End Point Mode R-L" ); - splitPopupMI[0][0] = wMenuToggleCreate( splitPopupM[0], "", _("None"), 0, TRUE, ChangeSplitEPMode, I2VP(0) ); - splitPopupMI[0][1] = wMenuToggleCreate( splitPopupM[0], "", _("Left"), 0, FALSE, ChangeSplitEPMode, I2VP(1) ); - splitPopupMI[0][2] = wMenuToggleCreate( splitPopupM[0], "", _("Right"), 0, FALSE, ChangeSplitEPMode, I2VP(2) ); - splitPopupMI[0][3] = wMenuToggleCreate( splitPopupM[0], "", _("Both"), 0, FALSE, ChangeSplitEPMode, I2VP(3) ); + splitPopupMI[0][0] = wMenuToggleCreate( splitPopupM[0], "", _("None"), 0, TRUE, + ChangeSplitEPMode, I2VP(0) ); + splitPopupMI[0][1] = wMenuToggleCreate( splitPopupM[0], "", _("Left"), 0, FALSE, + ChangeSplitEPMode, I2VP(1) ); + splitPopupMI[0][2] = wMenuToggleCreate( splitPopupM[0], "", _("Right"), 0, + FALSE, ChangeSplitEPMode, I2VP(2) ); + splitPopupMI[0][3] = wMenuToggleCreate( splitPopupM[0], "", _("Both"), 0, FALSE, + ChangeSplitEPMode, I2VP(3) ); splitPopupM[1] = MenuRegister( "End Point Mode T-B" ); - splitPopupMI[1][0] = wMenuToggleCreate( splitPopupM[1], "", _("None"), 0, TRUE, ChangeSplitEPMode, I2VP(0) ); - splitPopupMI[1][1] = wMenuToggleCreate( splitPopupM[1], "", _("Top"), 0, FALSE, ChangeSplitEPMode, I2VP(1) ); - splitPopupMI[1][2] = wMenuToggleCreate( splitPopupM[1], "", _("Bottom"), 0, FALSE, ChangeSplitEPMode, I2VP(2) ); - splitPopupMI[1][3] = wMenuToggleCreate( splitPopupM[1], "", _("Both"), 0, FALSE, ChangeSplitEPMode, I2VP(3) ); + splitPopupMI[1][0] = wMenuToggleCreate( splitPopupM[1], "", _("None"), 0, TRUE, + ChangeSplitEPMode, I2VP(0) ); + splitPopupMI[1][1] = wMenuToggleCreate( splitPopupM[1], "", _("Top"), 0, FALSE, + ChangeSplitEPMode, I2VP(1) ); + splitPopupMI[1][2] = wMenuToggleCreate( splitPopupM[1], "", _("Bottom"), 0, + FALSE, ChangeSplitEPMode, I2VP(2) ); + splitPopupMI[1][3] = wMenuToggleCreate( splitPopupM[1], "", _("Both"), 0, FALSE, + ChangeSplitEPMode, I2VP(3) ); } splitTrkEP[0] = PickEndPoint( pos, splitTrkTrk[0] ); angle = NormalizeAngle(GetTrkEndAngle( splitTrkTrk[0], splitTrkEP[0] )); - if ( angle <= 45.0 ) + if ( angle <= 45.0 ) { quad = 0; - else if ( angle <= 135.0 ) + } else if ( angle <= 135.0 ) { quad = 1; - else if ( angle <= 225.0 ) + } else if ( angle <= 225.0 ) { quad = 2; - else if ( angle <= 315.0 ) + } else if ( angle <= 315.0 ) { quad = 3; - else + } else { quad = 0; + } splitTrkFlip = (quad<2); - if ( (splitTrkTrk[1] = GetTrkEndTrk( splitTrkTrk[0], splitTrkEP[0] ) ) == NULL ) { + if ( (splitTrkTrk[1] = GetTrkEndTrk( splitTrkTrk[0], + splitTrkEP[0] ) ) == NULL ) { ErrorMessage( MSG_BAD_BLOCKGAP ); return C_CONTINUE; } splitTrkEP[1] = GetEndPtConnectedToMe( splitTrkTrk[1], splitTrkTrk[0] ); mode = 0; - if ( GetTrkEndOption( splitTrkTrk[1-splitTrkFlip], splitTrkEP[1-splitTrkFlip] ) & EPOPT_GAPPED ) + if ( GetTrkEndOption( splitTrkTrk[1-splitTrkFlip], + splitTrkEP[1-splitTrkFlip] ) & EPOPT_GAPPED ) { mode |= 2; - if ( GetTrkEndOption( splitTrkTrk[splitTrkFlip], splitTrkEP[splitTrkFlip] ) & EPOPT_GAPPED ) + } + if ( GetTrkEndOption( splitTrkTrk[splitTrkFlip], + splitTrkEP[splitTrkFlip] ) & EPOPT_GAPPED ) { mode |= 1; - for ( inx=0; inx<4; inx++ ) + } + for ( inx=0; inx<4; inx++ ) { wMenuToggleSet( splitPopupMI[quad&1][inx], mode == inx ); + } menuPos = pos; wMenuPopupShow( splitPopupM[quad&1] ); break; case wActionMove: DYNARR_RESET(trkSeg_t,anchors_da); onTrackInSplit = TRUE; - if ((trk0 = OnTrack( &pos, FALSE, TRUE ))!=NULL && CheckTrackLayerSilent( trk0 )) { + if ((trk0 = OnTrack( &pos, FALSE, TRUE ))!=NULL + && CheckTrackLayerSilent( trk0 )) { ep0 = PickEndPoint( pos, trk0 ); - if ( ep0 < 0 ) + if ( ep0 < 0 ) { break; - if (IsClose(FindDistance(GetTrkEndPos(trk0,ep0),pos)) && (GetTrkEndTrk(trk0,ep0)!=NULL)) { + } + if (IsClose(FindDistance(GetTrkEndPos(trk0,ep0),pos)) + && (GetTrkEndTrk(trk0,ep0)!=NULL)) { CreateSplitAnchor(GetTrkEndPos(trk0,ep0),trk0,TRUE); } else if (QueryTrack(trk0,Q_IS_TURNOUT)) { if ((MyGetKeyState()&WKEY_SHIFT) != 0 ) { @@ -251,7 +277,8 @@ static STATUS_T CmdSplitTrack( wAction_t action, coOrd pos ) CreateSplitAnchor(pos,trk0,FALSE); } } else { - if ((trk0 = OnTrack( &pos, FALSE, FALSE))!=NULL && CheckTrackLayerSilent( trk0 )) { + if ((trk0 = OnTrack( &pos, FALSE, FALSE))!=NULL + && CheckTrackLayerSilent( trk0 )) { if (QueryTrack(trk0,Q_MODIFY_CAN_SPLIT)) { CreateSplitAnchor(pos,trk0, FALSE); } @@ -261,8 +288,8 @@ static STATUS_T CmdSplitTrack( wAction_t action, coOrd pos ) break; case C_REDRAW: - if (anchors_da.cnt) - DrawSegs( &tempD, zero, 0.0, &anchors(0), anchors_da.cnt, trackGauge, wDrawColorBlack ); + DrawSegsDA( &tempD, NULL, zero, 0.0, &anchors_da, trackGauge, wDrawColorBlack, + 0 ); break; } @@ -273,22 +300,23 @@ static STATUS_T CmdSplitDraw( wAction_t action, coOrd pos ) { track_p trk0, trk1; EPINX_T ep0 = 0; - int oldTrackCount; +// int oldTrackCount; switch (action) { case C_START: InfoMessage( _("Select draw to split") ); DYNARR_RESET(trkSeg_t,anchors_da); SetAllTrackSelect( FALSE ); - /* no break */ + /* no break */ case C_DOWN: case C_MOVE: return C_CONTINUE; break; case C_UP: onTrackInSplit = TRUE; - if ((trk0 = OnTrack( &pos, FALSE, FALSE))!=NULL && CheckTrackLayerSilent( trk0 )) { - if (IsTrack(trk0)) return C_CONTINUE; + if ((trk0 = OnTrack( &pos, FALSE, FALSE))!=NULL + && CheckTrackLayerSilent( trk0 )) { + if (IsTrack(trk0)) { return C_CONTINUE; } if (!QueryTrack(trk0,Q_MODIFY_CAN_SPLIT)) { onTrackInSplit = FALSE; InfoMessage(_("Can't Split that Draw Object")); @@ -296,7 +324,7 @@ static STATUS_T CmdSplitDraw( wAction_t action, coOrd pos ) } onTrackInSplit = FALSE; UndoStart( _("Split Draw"), "SplitDraw( T%d[%d] )", GetTrkIndex(trk0), ep0 ); - oldTrackCount = trackCount; +// oldTrackCount = trackCount; SplitTrack( trk0, pos, ep0, &trk1, FALSE ); UndoEnd(); return C_TERMINATE; @@ -310,8 +338,9 @@ static STATUS_T CmdSplitDraw( wAction_t action, coOrd pos ) case wActionMove: DYNARR_RESET(trkSeg_t,anchors_da); onTrackInSplit = TRUE; - if ((trk0 = OnTrack( &pos, FALSE, FALSE))!=NULL && CheckTrackLayerSilent( trk0 )) { - if (IsTrack(trk0)) break; + if ((trk0 = OnTrack( &pos, FALSE, FALSE))!=NULL + && CheckTrackLayerSilent( trk0 )) { + if (IsTrack(trk0)) { break; } if (QueryTrack(trk0,Q_MODIFY_CAN_SPLIT)) { CreateSplitAnchor(pos,trk0, FALSE); } @@ -319,8 +348,8 @@ static STATUS_T CmdSplitDraw( wAction_t action, coOrd pos ) onTrackInSplit = FALSE; break; case C_REDRAW: - if (anchors_da.cnt) - DrawSegs( &tempD, zero, 0.0, &anchors(0), anchors_da.cnt, trackGauge, wDrawColorBlack ); + DrawSegsDA( &tempD, NULL, zero, 0.0, &anchors_da, trackGauge, wDrawColorBlack, + 0 ); break; } @@ -345,14 +374,15 @@ static STATUS_T CmdTrimDraw( wAction_t action, coOrd pos ) trimLine = NULL; trk = NULL; SetAllTrackSelect( FALSE ); - /* no break */ + /* no break */ case C_DOWN: case C_MOVE: return C_CONTINUE; break; case C_UP: if (trimState == TRIM_NONE) { - if ((trk0 = OnTrack( &pos, FALSE, FALSE))!=NULL && CheckTrackLayerSilent( trk0 )) { + if ((trk0 = OnTrack( &pos, FALSE, FALSE))!=NULL + && CheckTrackLayerSilent( trk0 )) { if (IsTrack(trk0)) { InfoMessage(_("Can't Trim with a Track")); return C_CONTINUE; @@ -361,8 +391,7 @@ static STATUS_T CmdTrimDraw( wAction_t action, coOrd pos ) trimLine = trk0; InfoMessage( _("Select an intersecting draw object to Trim") ); return C_CONTINUE; - } - else return C_CONTINUE; + } else { return C_CONTINUE; } } if (!trimLine) { InfoMessage(_("No Draw to Trim with")); @@ -382,27 +411,27 @@ static STATUS_T CmdTrimDraw( wAction_t action, coOrd pos ) return C_CONTINUE; } pos1 = pos; - if (IsClose(GetTrkDistance(trimLine,&pos1)*4)) { + if (IsClose(GetTrkDistance(trimLine,&pos1)*4)) { if ( IsClose(GetTrkDistance(trk1,&pos1)*4)) { //Iterate twice - for (int i=0; i<2;i++) { + for (int i=0; i<2; i++) { GetTrkDistance(trimLine,&pos1); GetTrkDistance(trk1,&pos1); } - } else return C_CONTINUE; + } else { return C_CONTINUE; } } else { return C_CONTINUE; } - } else return C_CONTINUE; + } else { return C_CONTINUE; } ANGLE_T a = GetAngleAtPoint(trk1,pos1,NULL,NULL); ANGLE_T aa = DifferenceBetweenAngles(a,FindAngle(pos1,pos)); - if (fabs(aa)<90 ) ep0 = 1; - else ep0 = 0; + if (fabs(aa)<90 ) { ep0 = 1; } + else { ep0 = 0; } UndoStart( _("Trim Draw"), "TrimDraw( T%d[%d] )", GetTrkIndex(trimLine), ep0 ); SplitTrack( trk1, pos1, ep0, &trk2, FALSE ); - if (trk2 ) DeleteTrack(trk2, FALSE); + if (trk2 ) { DeleteTrack(trk2, FALSE); } UndoEnd(); MainRedraw(); InfoMessage( _("Select another draw object to Trim, or Space to Deselect") ); @@ -412,8 +441,9 @@ static STATUS_T CmdTrimDraw( wAction_t action, coOrd pos ) DYNARR_RESET(trkSeg_t,anchors_da); trk = NULL; if (trimState == TRIM_NONE) { - if ((trk0 = OnTrack( &pos, FALSE, FALSE))!=NULL && CheckTrackLayerSilent( trk0 )) { - if (IsTrack(trk0)) break; + if ((trk0 = OnTrack( &pos, FALSE, FALSE))!=NULL + && CheckTrackLayerSilent( trk0 )) { + if (IsTrack(trk0)) { break; } if (QueryTrack(trk0,Q_MODIFY_CAN_SPLIT)) { trk = trk0; } @@ -429,7 +459,7 @@ static STATUS_T CmdTrimDraw( wAction_t action, coOrd pos ) if (IsClose(GetTrkDistance(trimLine,&pos1)*4)) { if (IsClose(GetTrkDistance(trk1,&pos1)*4)) { //Iterate Twice - for (int i=0; i<2;i++) { + for (int i=0; i<2; i++) { GetTrkDistance(trimLine,&pos1); GetTrkDistance(trk1,&pos1); } @@ -446,12 +476,13 @@ static STATUS_T CmdTrimDraw( wAction_t action, coOrd pos ) if (trimLine) { DrawTrack(trimLine,&tempD,selectedColor); } - if (anchors_da.cnt) - DrawSegs( &tempD, zero, 0.0, &anchors(0), anchors_da.cnt, trackGauge, wDrawColorBlack ); + DrawSegsDA( &tempD, NULL, zero, 0.0, &anchors_da, trackGauge, wDrawColorBlack, + 0 ); break; case C_TEXT: - if (action>>8 != ' ' && action>>8 != 13 ) + if (action>>8 != ' ' && action>>8 != 13 ) { return C_CONTINUE; + } trimLine = NULL; trk = NULL; trimState = TRIM_NONE; @@ -464,16 +495,22 @@ static STATUS_T CmdTrimDraw( wAction_t action, coOrd pos ) } -#include "bitmaps/split.xpm" -#include "bitmaps/split-draw.xpm" -#include "bitmaps/trim.xpm" +#include "bitmaps/split.xpm3" +#include "bitmaps/split-draw.xpm3" +#include "bitmaps/trim.xpm3" void InitCmdSplit( wMenu_p menu ) { ButtonGroupBegin( _("Split"), "cmdSplitSetCmd", _("Split") ); - AddMenuButton( menu, CmdSplitTrack, "cmdSplitTrack", _("Split Track"), wIconCreatePixMap(split_xpm[iconSize]), LEVEL0_50, IC_STICKY|IC_POPUP|IC_CMDMENU|IC_WANT_MOVE, ACCL_SPLIT, NULL); - AddMenuButton( menu, CmdSplitDraw, "cmdSplitDraw", _("Split Draw"), wIconCreatePixMap(split_draw_xpm[iconSize]), LEVEL0_50, IC_STICKY|IC_POPUP|IC_WANT_MOVE, ACCL_SPLITDRAW, NULL); - AddMenuButton( menu, CmdTrimDraw, "cmdTrimDraw", _("Trim Draw"), wIconCreatePixMap(trim_xpm[iconSize]), LEVEL0_50, IC_STICKY|IC_POPUP|IC_WANT_MOVE, ACCL_TRIMDRAW, NULL); + AddMenuButton( menu, CmdSplitTrack, "cmdSplitTrack", _("Split Track"), + wIconCreatePixMap(split_xpm3[iconSize]), LEVEL0_50, + IC_STICKY|IC_POPUP|IC_CMDMENU|IC_WANT_MOVE, ACCL_SPLIT, NULL); + AddMenuButton( menu, CmdSplitDraw, "cmdSplitDraw", _("Split Draw"), + wIconCreatePixMap(split_draw_xpm3[iconSize]), LEVEL0_50, + IC_STICKY|IC_POPUP|IC_WANT_MOVE, ACCL_SPLITDRAW, NULL); + AddMenuButton( menu, CmdTrimDraw, "cmdTrimDraw", _("Trim Draw"), + wIconCreatePixMap(trim_xpm3[iconSize]), LEVEL0_50, + IC_STICKY|IC_POPUP|IC_WANT_MOVE, ACCL_TRIMDRAW, NULL); ButtonGroupEnd(); } diff --git a/app/bin/cstraigh.c b/app/bin/cstraigh.c index 277db96..b61d9b8 100644 --- a/app/bin/cstraigh.c +++ b/app/bin/cstraigh.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "cstraigh.h" @@ -33,16 +33,17 @@ * STATE INFO */ static struct { - coOrd pos0, pos1; - track_p trk; - EPINX_T ep; - BOOL_T down; - } Dl; + coOrd pos0, pos1; + track_p trk; + EPINX_T ep; + BOOL_T down; +} Dl; static dynArr_t anchors_da; #define anchors(N) DYNARR_N(trkSeg_t,anchors_da,N) -static void CreateEndAnchor(coOrd p, wBool_t lock) { +static void CreateEndAnchor(coOrd p, wBool_t lock) +{ DIST_T d = tempD.scale*0.15; DYNARR_APPEND(trkSeg_t,anchors_da,1); @@ -53,7 +54,7 @@ static void CreateEndAnchor(coOrd p, wBool_t lock) { anchors(i).u.c.radius = d/2; anchors(i).u.c.a0 = 0.0; anchors(i).u.c.a1 = 360.0; - anchors(i).width = 0; + anchors(i).lineWidth = 0; } @@ -72,7 +73,8 @@ static STATUS_T CmdStraight( wAction_t action, coOrd pos ) Dl.trk = NULL; Dl.ep=-1; Dl.down = FALSE; - InfoMessage( _("Place 1st endpoint of straight track, snap to unconnected endpoint") ); + InfoMessage( + _("Place 1st endpoint of straight track, snap to unconnected endpoint") ); SetAllTrackSelect( FALSE ); return C_CONTINUE; @@ -83,30 +85,30 @@ static STATUS_T CmdStraight( wAction_t action, coOrd pos ) Dl.trk = NULL; if (((MyGetKeyState() & WKEY_ALT) == 0) == magneticSnap) { if ((t = OnTrack(&p, FALSE, TRUE)) != NULL) { - EPINX_T ep = PickUnconnectedEndPointSilent(p, t); - if (ep != -1) { - if (GetTrkGauge(t) != GetScaleTrackGauge(GetLayoutCurScale())) { - wBeep(); - InfoMessage(_("Track is different gauge")); - return C_CONTINUE; - } - Dl.trk = t; - Dl.ep = ep; - pos = GetTrkEndPos(t, ep); - found = TRUE; - } + EPINX_T ep = PickUnconnectedEndPointSilent(p, t); + if (ep != -1) { + if (GetTrkGauge(t) != GetScaleTrackGauge(GetLayoutCurScale())) { + wBeep(); + InfoMessage(_("Track is different gauge")); + return C_CONTINUE; + } + Dl.trk = t; + Dl.ep = ep; + pos = GetTrkEndPos(t, ep); + found = TRUE; + } } } - Dl.down = TRUE; - if (!found) SnapPos( &pos ); + Dl.down = TRUE; + if (!found) { SnapPos( &pos ); } Dl.pos0 = pos; InfoMessage( _("Drag to place 2nd end point") ); DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); tempSegs(0).color = wDrawColorBlack; - tempSegs(0).width = 0; - tempSegs_da.cnt = 0; + tempSegs(0).lineWidth = 0; tempSegs(0).type = SEG_STRTRK; tempSegs(0).u.l.pos[0] = pos; + DYNARR_RESET( trkSeg_t, tempSegs_da ); return C_CONTINUE; case C_MOVE: @@ -118,13 +120,13 @@ static STATUS_T CmdStraight( wAction_t action, coOrd pos ) p = pos; if ((t = OnTrack(&p, FALSE, TRUE)) != NULL) { if (GetTrkGauge(t) == GetScaleTrackGauge(GetLayoutCurScale())) { - EPINX_T ep = PickUnconnectedEndPointSilent(pos, t); - if (ep != -1) { - if (GetTrkGauge(t) == GetScaleTrackGauge(GetLayoutCurScale())) { - CreateEndAnchor(GetTrkEndPos(t,ep),FALSE); - found = TRUE; - } - } + EPINX_T ep = PickUnconnectedEndPointSilent(pos, t); + if (ep != -1) { + if (GetTrkGauge(t) == GetScaleTrackGauge(GetLayoutCurScale())) { + CreateEndAnchor(GetTrkEndPos(t,ep),FALSE); + found = TRUE; + } + } } } } @@ -138,35 +140,35 @@ static STATUS_T CmdStraight( wAction_t action, coOrd pos ) if (Dl.trk && !(MyGetKeyState() & WKEY_SHIFT)) { angle = NormalizeAngle(GetTrkEndAngle( Dl.trk, Dl.ep)); angle2 = NormalizeAngle(FindAngle(pos, Dl.pos0)-angle); - if (angle2 > 90.0 && angle2 < 270.0) + if (angle2 > 90.0 && angle2 < 270.0) { Translate( &pos, Dl.pos0, angle, FindDistance( Dl.pos0, pos ) ); - else pos = Dl.pos0; + } else { pos = Dl.pos0; } } else if (SnapPos( &pos )) { - CreateEndAnchor(pos,FALSE); - found = TRUE; + CreateEndAnchor(pos,FALSE); + found = TRUE; } - + InfoMessage( _("Straight Track Length=%s Angle=%0.3f"), - FormatDistance(FindDistance( Dl.pos0, pos )), - PutAngle(FindAngle( Dl.pos0, pos )) ); + FormatDistance(FindDistance( Dl.pos0, pos )), + PutAngle(FindAngle( Dl.pos0, pos )) ); + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); tempSegs(0).u.l.pos[1] = pos; - tempSegs_da.cnt = 1; return C_CONTINUE; case C_UP: DYNARR_RESET(trkSeg_t,anchors_da); - if (!Dl.down) return C_CONTINUE; - tempSegs_da.cnt = 0; + if (!Dl.down) { return C_CONTINUE; } + DYNARR_RESET( trkSeg_t, tempSegs_da ); if (Dl.trk && !(MyGetKeyState() & WKEY_SHIFT)) { angle = NormalizeAngle(GetTrkEndAngle( Dl.trk, Dl.ep)); angle2 = NormalizeAngle(FindAngle(pos, Dl.pos0)-angle); - if (angle2 > 90.0 && angle2 < 270.0) + if (angle2 > 90.0 && angle2 < 270.0) { Translate( &pos, Dl.pos0, angle, FindDistance( Dl.pos0, pos )); - else pos = Dl.pos0; - } else SnapPos( &pos ); + } else { pos = Dl.pos0; } + } else { SnapPos( &pos ); } if ((dist=FindDistance( Dl.pos0, pos )) <= minLength) { - ErrorMessage( MSG_TRK_TOO_SHORT, "Straight ", PutDim(fabs(minLength-dist)) ); - return C_TERMINATE; + ErrorMessage( MSG_TRK_TOO_SHORT, "Straight ", PutDim(fabs(minLength-dist)) ); + return C_TERMINATE; } UndoStart( _("Create Straight Track"), "newStraight" ); t = NewStraightTrack( Dl.pos0, pos ); @@ -178,10 +180,12 @@ static STATUS_T CmdStraight( wAction_t action, coOrd pos ) return C_TERMINATE; case C_REDRAW: - if (anchors_da.cnt) - DrawSegs( &tempD, zero, 0.0, &anchors(0), anchors_da.cnt, trackGauge, wDrawColorBlack ); - if (Dl.down) - DrawSegs( &tempD, zero, 0.0, &tempSegs(0), tempSegs_da.cnt, trackGauge, wDrawColorBlack ); + DrawSegsDA( &tempD, NULL, zero, 0.0, &anchors_da, trackGauge, wDrawColorBlack, + 0 ); + if (Dl.down) { + DrawSegsDA( &tempD, NULL, zero, 0.0, &tempSegs_da, trackGauge, wDrawColorBlack, + 0 ); + } return C_CONTINUE; case C_CANCEL: Dl.down = FALSE; @@ -193,9 +197,11 @@ static STATUS_T CmdStraight( wAction_t action, coOrd pos ) } -#include "bitmaps/straight.xpm" +#include "bitmaps/straight.xpm3" void InitCmdStraight( wMenu_p menu ) { - AddMenuButton( menu, CmdStraight, "cmdStraight", _("Straight Track"), wIconCreatePixMap(straight_xpm[iconSize]), LEVEL0_50, IC_STICKY|IC_POPUP2|IC_WANT_MOVE, ACCL_STRAIGHT, NULL ); + AddMenuButton( menu, CmdStraight, "cmdStraight", _("Straight Track"), + wIconCreatePixMap(straight_xpm3[iconSize]), LEVEL0_50, + IC_STICKY|IC_POPUP2|IC_WANT_MOVE, ACCL_STRAIGHT, NULL ); } diff --git a/app/bin/cstraigh.h b/app/bin/cstraigh.h index 1231546..bff288a 100644 --- a/app/bin/cstraigh.h +++ b/app/bin/cstraigh.h @@ -17,16 +17,16 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef HAVE_CSTRAIGH_H
-#define HAVE_CSTRAIGH_H
-
-#include "common.h"
+#ifndef HAVE_CSTRAIGH_H +#define HAVE_CSTRAIGH_H + +#include "common.h" void AdjustStraightEndPt( track_p t, EPINX_T ep, coOrd pos ); track_p NewStraightTrack( coOrd p0, coOrd p1 ); BOOL_T ExtendStraightToJoin( track_p, EPINX_T, track_p, EPINX_T ); -#endif // !HAVE_CSTRAIGH_H
\ No newline at end of file +#endif // !HAVE_CSTRAIGH_H diff --git a/app/bin/cstruct.c b/app/bin/cstruct.c index fc13924..9006ebd 100644 --- a/app/bin/cstruct.c +++ b/app/bin/cstruct.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "compound.h" @@ -30,6 +30,7 @@ #include "cselect.h" #include "include/paramfile.h" #include "track.h" +#include "tbezier.h" #include "ccurve.h" #include "common-ui.h" @@ -45,18 +46,20 @@ static int log_structure = 0; static wMenu_p structPopupM; static drawCmd_t structureD = { - NULL, - &screenDrawFuncs, - 0, - 1.0, - 0.0, - {0.0,0.0}, {0.0,0.0}, - Pix2CoOrd, CoOrd2Pix }; + NULL, + &screenDrawFuncs, + 0, + 1.0, + 0.0, + {0.0,0.0}, {0.0,0.0}, + Pix2CoOrd, CoOrd2Pix +}; static wIndex_t structureHotBarCmdInx; static wIndex_t structureInx; static long hideStructureWindow; -static void RedrawStructure( wDraw_p d, void * context, wWinPix_t x, wWinPix_t y ); +static void RedrawStructure( wDraw_p d, void * context, wWinPix_t x, + wWinPix_t y ); static wWinPix_t structureListWidths[] = { 80, 80, 220 }; static const char * structureListTitles[] = { N_("Manufacturer"), N_("Part No"), N_("Description") }; @@ -76,7 +79,8 @@ static paramData_t structurePLs[] = { #define I_MSGWIDTH (4) { PD_MESSAGE, NULL, NULL, 0, I2VP(80) }, #define I_MSGHEIGHT (5) - { PD_MESSAGE, NULL, NULL, 0, I2VP(80) } }; + { PD_MESSAGE, NULL, NULL, 0, I2VP(80) } +}; static paramGroup_t structurePG = { "structure", 0, structurePLs, COUNT( structurePLs ) }; @@ -91,19 +95,20 @@ static paramGroup_t structurePG = { "structure", 0, structurePLs, COUNT( structu EXPORT turnoutInfo_t * CreateNewStructure( - char * scale, - char * title, - wIndex_t segCnt, - trkSeg_p segData, - BOOL_T updateList ) + char * scale, + char * title, + wIndex_t segCnt, + trkSeg_p segData, + BOOL_T updateList ) { turnoutInfo_t * to; #ifdef REORIGSTRUCT coOrd orig; #endif - if (segCnt == 0) - return NULL; + if (segCnt == 0) { + return NULL; + } to = FindCompound( FIND_STRUCT, scale, title ); if (to == NULL) { DYNARR_APPEND( turnoutInfo_t *, structureInfo_da, 10 ); @@ -115,6 +120,7 @@ EXPORT turnoutInfo_t * CreateNewStructure( to->segCnt = segCnt; to->segs = (trkSeg_p)memdup( segData, (sizeof *segData) * segCnt ); CopyPoly(to->segs,segCnt); + FixUpBezierSegs(to->segs, segCnt); GetSegBounds( zero, 0.0, to->segCnt, to->segs, &to->orig, &to->size ); #ifdef REORIGSTRUCT GetSegBounds( zero, 0.0, to->segCnt, to->segs, &orig, &to->size ); @@ -124,16 +130,19 @@ EXPORT turnoutInfo_t * CreateNewStructure( to->orig = zero; #endif to->paramFileIndex = curParamFileIndex; - if (curParamFileIndex == PARAM_CUSTOM) + if (curParamFileIndex == PARAM_CUSTOM) { to->contentsLabel = MyStrdup("Custom Structures"); - else + } else { to->contentsLabel = curSubContents; + } to->endCnt = 0; SetParamPaths( to, NULL ); if (updateList && structureListL != NULL) { - FormatCompoundTitle( LABEL_TABBED|LABEL_MANUF|LABEL_PARTNO|LABEL_DESCR, to->title ); - if (message[0] != '\0') + FormatCompoundTitle( LABEL_TABBED|LABEL_MANUF|LABEL_PARTNO|LABEL_DESCR, + to->title ); + if (message[0] != '\0') { wListAddValue( structureListL, message, NULL, to ); + } } to->barScale = curBarScale>0?curBarScale:-1; @@ -141,7 +150,7 @@ EXPORT turnoutInfo_t * CreateNewStructure( } /** - * Delete a structure definition from memory. + * Delete a structure definition from memory. * \TODO Find a better way to handle Custom Structures (see CreateNewStructure) * * \param [IN] structure the structure to be deleted @@ -161,9 +170,10 @@ StructureDelete(void *structure) to->u.pier.name = NULL; break; case TOpierInfo: - for(int pierInx=0;pierInx<to->u.pierInfo.cnt;pierInx++) { - if (to->u.pierInfo.info[pierInx].name) + for(int pierInx=0; pierInx<to->u.pierInfo.cnt; pierInx++) { + if (to->u.pierInfo.info[pierInx].name) { MyFree(to->u.pierInfo.info[pierInx].name); + } to->u.pierInfo.info[pierInx].name = NULL; } MyFree(to->u.pierInfo.info); @@ -188,34 +198,34 @@ StructureDelete(void *structure) void DeleteStructures(int fileIndex) { - int inx = 0; - int startInx = -1; - int cnt = 0; - - // go to the start of the block - while (inx < structureInfo_da.cnt && - structureInfo(inx)->paramFileIndex != fileIndex) { - startInx = inx++; - } - - // delete them - for (; inx < structureInfo_da.cnt && - structureInfo(inx)->paramFileIndex == fileIndex; inx++) { - turnoutInfo_t * to = structureInfo(inx); - if (to->paramFileIndex == fileIndex) { - StructureDelete(to); - cnt++; - } - } - - // copy down the rest of the list to fill the gap - startInx++; - while (inx < structureInfo_da.cnt) { - structureInfo(startInx++) = structureInfo(inx++); - } - - // and reduce the actual number - structureInfo_da.cnt -= cnt; + int inx = 0; + int startInx = -1; + int cnt = 0; + + // go to the start of the block + while (inx < structureInfo_da.cnt && + structureInfo(inx)->paramFileIndex != fileIndex) { + startInx = inx++; + } + + // delete them + for (; inx < structureInfo_da.cnt && + structureInfo(inx)->paramFileIndex == fileIndex; inx++) { + turnoutInfo_t * to = structureInfo(inx); + if (to->paramFileIndex == fileIndex) { + StructureDelete(to); + cnt++; + } + } + + // copy down the rest of the list to fill the gap + startInx++; + while (inx < structureInfo_da.cnt) { + structureInfo(startInx++) = structureInfo(inx++); + } + + // and reduce the actual number + structureInfo_da.cnt -= cnt; } /** @@ -230,19 +240,19 @@ DeleteStructures(int fileIndex) * \return */ enum paramFileState -GetStructureCompatibility(int paramFileIndex, SCALEINX_T scaleIndex) -{ +GetStructureCompatibility(int paramFileIndex, SCALEINX_T scaleIndex) { int i; enum paramFileState ret = PARAMFILE_NOTUSABLE; - DIST_T ratio = GetScaleRatio(scaleIndex); - if (!IsParamValid(paramFileIndex)) { + if (!IsParamValid(paramFileIndex)) + { return(PARAMFILE_UNLOADED); } //Loop over all entries until an exact fit is found if none return if compatibles were found - for (i = 0; i < structureInfo_da.cnt; i++) { + for (i = 0; i < structureInfo_da.cnt; i++) + { turnoutInfo_t *to = structureInfo(i); if (to->paramFileIndex == paramFileIndex) { SCALE_FIT_T fit = CompatibleScale(FIT_STRUCTURE,to->scaleInx,scaleIndex); @@ -261,22 +271,25 @@ GetStructureCompatibility(int paramFileIndex, SCALEINX_T scaleIndex) } static BOOL_T ReadStructureParam( - char * firstLine ) + char * firstLine ) { char scale[10]; char *title; turnoutInfo_t * to; char * cp; -static dynArr_t pierInfo_da; + static dynArr_t pierInfo_da; #define pierInfo(N) DYNARR_N( pierInfo_t, pierInfo_da, N ) - if ( !GetArgs( firstLine+10, "sq", scale, &title ) ) + if ( !GetArgs( firstLine+10, "sq", scale, &title ) ) { return FALSE; - if ( !ReadSegs() ) - return FALSE; + } + if ( !ReadSegs() ) { + return FALSE; + } to = CreateNewStructure( scale, title, tempSegs_da.cnt, &tempSegs(0), FALSE ); - if (to == NULL) + if (to == NULL) { return FALSE; + } if (tempSpecial[0] != '\0') { if (strncmp( tempSpecial, PIER, strlen(PIER) ) == 0) { DYNARR_RESET( pierInfo_t, pierInfo_da ); @@ -284,14 +297,18 @@ static dynArr_t pierInfo_da; cp = tempSpecial+strlen(PIER); while (cp) { DYNARR_APPEND( pierInfo_t, pierInfo_da, 10 ); - if ( !GetArgs( cp, "fqc", &pierInfo(pierInfo_da.cnt-1).height, &pierInfo(pierInfo_da.cnt-1).name, &cp ) ) + if ( !GetArgs( cp, "fqc", &pierInfo(pierInfo_da.cnt-1).height, + &pierInfo(pierInfo_da.cnt-1).name, &cp ) ) { return FALSE; + } } to->u.pierInfo.cnt = pierInfo_da.cnt; - to->u.pierInfo.info = (pierInfo_t*)MyMalloc( pierInfo_da.cnt * sizeof *(pierInfo_t*)NULL ); - memcpy( to->u.pierInfo.info, &pierInfo(0), pierInfo_da.cnt * sizeof *(pierInfo_t*)NULL ); + to->u.pierInfo.info = (pierInfo_t*)MyMalloc( pierInfo_da.cnt * sizeof * + (pierInfo_t*)NULL ); + memcpy( to->u.pierInfo.info, &pierInfo(0), + pierInfo_da.cnt * sizeof *(pierInfo_t*)NULL ); } else { - InputError("Unknown special case", TRUE); + InputError("Unknown special case", TRUE); } } if (tempCustom[0] != '\0') { @@ -302,7 +319,8 @@ static dynArr_t pierInfo_da; } -EXPORT turnoutInfo_t * StructAdd( long mode, SCALEINX_T scale, wList_p list, coOrd * maxDim ) +EXPORT turnoutInfo_t * StructAdd( long mode, SCALEINX_T scale, wList_p list, + coOrd * maxDim ) { wIndex_t inx; turnoutInfo_t * to, *to1=NULL; @@ -310,11 +328,12 @@ EXPORT turnoutInfo_t * StructAdd( long mode, SCALEINX_T scale, wList_p list, coO for ( inx = 0; inx < structureInfo_da.cnt; inx++ ) { to = structureInfo(inx); if ( IsParamValid(to->paramFileIndex) && - to->segCnt > 0 && - (FIT_NONE != CompatibleScale( FIT_STRUCTURE, to->scaleInx, scale )) && - to->segCnt != 0 ) { - if (to1 == NULL) + to->segCnt > 0 && + (FIT_NONE != CompatibleScale( FIT_STRUCTURE, to->scaleInx, scale )) && + to->segCnt != 0 ) { + if (to1 == NULL) { to1 = to; + } if ( to == curStructure ) { to1 = to; structureInx = wListGetCount( list ); @@ -323,10 +342,12 @@ EXPORT turnoutInfo_t * StructAdd( long mode, SCALEINX_T scale, wList_p list, coO if (message[0] != '\0') { wListAddValue( list, message, NULL, to ); if (maxDim) { - if (to->size.x > maxDim->x) + if (to->size.x > maxDim->x) { maxDim->x = to->size.x; - if (to->size.y > maxDim->y) - maxDim->y = to->size.y; + } + if (to->size.y > maxDim->y) { + maxDim->y = to->size.y; + } } } } @@ -342,11 +363,12 @@ EXPORT turnoutInfo_t * StructAdd( long mode, SCALEINX_T scale, wList_p list, coO */ static void DrawStructure( - track_p t, - drawCmd_p d, - wDrawColor color ) + track_p t, + drawCmd_p d, + wDrawColor color ) { - struct extraDataCompound_t *xx = GET_EXTRA_DATA(t, T_STRUCTURE, extraDataCompound_t); + struct extraDataCompound_t *xx = GET_EXTRA_DATA(t, T_STRUCTURE, + extraDataCompound_t); d->options &= ~DC_NOTSOLIDLINE; switch(xx->lineType) { @@ -374,36 +396,37 @@ static void DrawStructure( DrawSegs( d, xx->orig, xx->angle, xx->segs, xx->segCnt, 0.0, color ); d->options &= ~DC_NOTSOLIDLINE; if ( ((d->options & DC_SIMPLE)==0) && - (labelWhen == 2 || (labelWhen == 1 && (d->options&DC_PRINT))) && - labelScale >= d->scale && - ( GetTrkBits( t ) & TB_HIDEDESC ) == 0 ) { + (labelWhen == 2 || (labelWhen == 1 && (d->options&DC_PRINT))) && + labelScale >= d->scale && + ( GetTrkBits( t ) & TB_HIDEDESC ) == 0 ) { DrawCompoundDescription( t, d, color ); } } static BOOL_T ReadStructure( - char * line ) + char * line ) { return ReadCompound( line+10, T_STRUCTURE ); } static ANGLE_T GetAngleStruct( - track_p trk, - coOrd pos, - EPINX_T * ep0, - EPINX_T * ep1 ) + track_p trk, + coOrd pos, + EPINX_T * ep0, + EPINX_T * ep1 ) { - struct extraDataCompound_t * xx = GET_EXTRA_DATA(trk, T_STRUCTURE, extraDataCompound_t); + struct extraDataCompound_t * xx = GET_EXTRA_DATA(trk, T_STRUCTURE, + extraDataCompound_t); ANGLE_T angle; pos.x -= xx->orig.x; pos.y -= xx->orig.y; Rotate( &pos, zero, -xx->angle ); angle = GetAngleSegs( xx->segCnt, xx->segs, &pos, NULL, NULL, NULL, NULL, NULL); - if ( ep0 ) *ep0 = -1; - if ( ep1 ) *ep1 = -1; + if ( ep0 ) { *ep0 = -1; } + if ( ep1 ) { *ep1 = -1; } return NormalizeAngle( angle+xx->angle ); } @@ -423,8 +446,10 @@ static BOOL_T QueryStructure( track_p trk, int query ) static wBool_t CompareStruct( track_cp trk1, track_cp trk2 ) { - struct extraDataCompound_t *xx1 = GET_EXTRA_DATA( trk1, T_STRUCTURE, extraDataCompound_t ); - struct extraDataCompound_t *xx2 = GET_EXTRA_DATA( trk2, T_STRUCTURE, extraDataCompound_t ); + struct extraDataCompound_t *xx1 = GET_EXTRA_DATA( trk1, T_STRUCTURE, + extraDataCompound_t ); + struct extraDataCompound_t *xx2 = GET_EXTRA_DATA( trk2, T_STRUCTURE, + extraDataCompound_t ); char * cp = message + strlen(message); REGRESS_CHECK_POS( "Orig", xx1, xx2, orig ) REGRESS_CHECK_ANGLE( "Angle", xx1, xx2, angle ) @@ -439,44 +464,46 @@ static wBool_t CompareStruct( track_cp trk1, track_cp trk2 ) } static trackCmd_t structureCmds = { - "STRUCTURE", - DrawStructure, - DistanceCompound, - DescribeCompound, - DeleteCompound, - WriteCompound, - ReadStructure, - MoveCompound, - RotateCompound, - RescaleCompound, - NULL, - GetAngleStruct, - NULL, /* split */ - NULL, /* traverse */ - EnumerateCompound, - NULL, /* redraw */ - NULL, /* trim */ - NULL, /* merge */ - NULL, /* modify */ - NULL, /* getLength */ - NULL, /* getTrkParams */ - NULL, /* moveEndPt */ - QueryStructure, - UngroupCompound, - FlipCompound, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - CompareStruct }; + "STRUCTURE", + DrawStructure, + DistanceCompound, + DescribeCompound, + DeleteCompound, + WriteCompound, + ReadStructure, + MoveCompound, + RotateCompound, + RescaleCompound, + NULL, + GetAngleStruct, + NULL, /* split */ + NULL, /* traverse */ + EnumerateCompound, + NULL, /* redraw */ + NULL, /* trim */ + NULL, /* merge */ + NULL, /* modify */ + NULL, /* getLength */ + NULL, /* getTrkParams */ + NULL, /* moveEndPt */ + QueryStructure, + UngroupCompound, + FlipCompound, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + CompareStruct +}; static paramData_t pierPLs[] = { - { PD_DROPLIST, &pierListInx, "inx", 0, I2VP(50), N_("Pier Number") } }; + { PD_DROPLIST, &pierListInx, "inx", 0, I2VP(50), N_("Pier Number") } +}; static paramGroup_t pierPG = { "structure-pier", 0, pierPLs, COUNT( pierPLs ) }; #define pierL ((wList_p)pierPLs[0].control) @@ -493,13 +520,15 @@ static void ShowPierL( void ) } currInx = wListGetIndex( pierL ); wListClear( pierL ); - for (inx=0;inx<curStructure->u.pierInfo.cnt; inx++) { + for (inx=0; inx<curStructure->u.pierInfo.cnt; inx++) { wListAddValue( pierL, curStructure->u.pierInfo.info[inx].name, NULL, NULL ); } - if ( currInx < 0 ) - currInx = 0; - if ( currInx >= curStructure->u.pierInfo.cnt ) - currInx = curStructure->u.pierInfo.cnt-1; + if ( currInx < 0 ) { + currInx = 0; + } + if ( currInx >= curStructure->u.pierInfo.cnt ) { + currInx = curStructure->u.pierInfo.cnt-1; + } wListSetIndex( pierL, currInx ); controls[0] = (wControl_p)pierL; controls[1] = NULL; @@ -546,21 +575,25 @@ static void RescaleStructure( void ) static void structureChange( long changes ) { static char * lastScaleName = NULL; - if (structureW == NULL) + if (structureW == NULL) { return; + } wListSetIndex( structureListL, 0 ); if ( (!wWinIsVisible(structureW)) || - ( ((changes&CHANGE_SCALE) == 0 || lastScaleName == curScaleName) && - (changes&CHANGE_PARAMS) == 0 ) ) + ( ((changes&CHANGE_SCALE) == 0 || lastScaleName == curScaleName) && + (changes&CHANGE_PARAMS) == 0 ) ) { return; + } lastScaleName = curScaleName; //curStructure = NULL; wControlShow( (wControl_p)structureListL, FALSE ); wListClear( structureListL ); maxStructureDim.x = maxStructureDim.y = 0.0; - if (structureInfo_da.cnt <= 0) + if (structureInfo_da.cnt <= 0) { return; - curStructure = StructAdd( LABEL_TABBED|LABEL_MANUF|LABEL_PARTNO|LABEL_DESCR, GetLayoutCurScale(), structureListL, &maxStructureDim ); + } + curStructure = StructAdd( LABEL_TABBED|LABEL_MANUF|LABEL_PARTNO|LABEL_DESCR, + GetLayoutCurScale(), structureListL, &maxStructureDim ); wListSetIndex( structureListL, structureInx ); wControlShow( (wControl_p)structureListL, TRUE ); if (curStructure == NULL) { @@ -576,18 +609,21 @@ static void structureChange( long changes ) -static void RedrawStructure( wDraw_p d, void * context, wWinPix_t x, wWinPix_t y ) +static void RedrawStructure( wDraw_p d, void * context, wWinPix_t x, + wWinPix_t y ) { RescaleStructure(); -LOG( log_structure, 2, ( "SelStructure(%s)\n", (curStructure?curStructure->title:"<NULL>") ) ) + LOG( log_structure, 2, ( "SelStructure(%s)\n", + (curStructure?curStructure->title:"<NULL>") ) ) wDrawClear( structureD.d ); if (curStructure == NULL) { return; } structureD.orig.x = -0.10*structureD.scale + curStructure->orig.x; - structureD.orig.y = (curStructure->size.y + curStructure->orig.y) - structureD.size.y + trackGauge; + structureD.orig.y = (curStructure->size.y + curStructure->orig.y) - + structureD.size.y + trackGauge; DrawSegs( &structureD, zero, 0.0, curStructure->segs, curStructure->segCnt, - 0.0, wDrawColorBlack ); + 0.0, wDrawColorBlack ); sprintf( message, _("Scale %d:1"), (int)structureD.scale ); ParamLoadMessage( &structurePG, I_MSGSCALE, message ); sprintf( message, _("Width %s"), FormatDistance(curStructure->size.x) ); @@ -598,13 +634,14 @@ LOG( log_structure, 2, ( "SelStructure(%s)\n", (curStructure?curStructure->title static void StructureDlgUpdate( - paramGroup_p pg, - int inx, - void * valueP ) + paramGroup_p pg, + int inx, + void * valueP ) { turnoutInfo_t * to; - if ( inx != I_LIST ) return; - to = (turnoutInfo_t*)wListGetItemContext( (wList_p)pg->paramPtr[inx].control, (wIndex_t)*(long*)valueP ); + if ( inx != I_LIST ) { return; } + to = (turnoutInfo_t*)wListGetItemContext( (wList_p)pg->paramPtr[inx].control, + (wIndex_t)*(long*)valueP ); NewStructure(); curStructure = to; ShowPierL(); @@ -631,10 +668,10 @@ static void DoStructOk( void ) * STATE INFO */ static struct { - int state; - coOrd pos; - ANGLE_T angle; - } Dst; + int state; + coOrd pos; + ANGLE_T angle; +} Dst; static track_p pierTrk; static EPINX_T pierEp; @@ -642,70 +679,78 @@ static EPINX_T pierEp; static dynArr_t anchors_da; #define anchors(N) DYNARR_N(trkSeg_t,anchors_da,N) -void static CreateArrowAnchor(coOrd pos,ANGLE_T a,DIST_T len) { +void static CreateArrowAnchor(coOrd pos,ANGLE_T a,DIST_T len) +{ DYNARR_APPEND(trkSeg_t,anchors_da,1); int i = anchors_da.cnt-1; anchors(i).type = SEG_STRLIN; - anchors(i).width = 0; + anchors(i).lineWidth = 0; anchors(i).u.l.pos[0] = pos; Translate(&anchors(i).u.l.pos[1],pos,NormalizeAngle(a+135),len); anchors(i).color = wDrawColorBlue; DYNARR_APPEND(trkSeg_t,anchors_da,1); i = anchors_da.cnt-1; anchors(i).type = SEG_STRLIN; - anchors(i).width = 0; + anchors(i).lineWidth = 0; anchors(i).u.l.pos[0] = pos; Translate(&anchors(i).u.l.pos[1],pos,NormalizeAngle(a-135),len); anchors(i).color = wDrawColorBlue; } -void static CreateRotateAnchor(coOrd pos) { +void static CreateRotateAnchor(coOrd pos) +{ DIST_T d = tempD.scale*0.15; DYNARR_APPEND(trkSeg_t,anchors_da,1); int i = anchors_da.cnt-1; anchors(i).type = SEG_CRVLIN; - anchors(i).width = 0.5; + anchors(i).lineWidth = 0.5; anchors(i).u.c.center = pos; anchors(i).u.c.a0 = 180.0; anchors(i).u.c.a1 = 360.0; anchors(i).u.c.radius = d*2; anchors(i).color = wDrawColorAqua; coOrd head; //Arrows - for (int j=0;j<3;j++) { + for (int j=0; j<3; j++) { Translate(&head,pos,j*120,d*2); CreateArrowAnchor(head,NormalizeAngle((j*120)+90),d); } } -void static CreateMoveAnchor(coOrd pos) { +void static CreateMoveAnchor(coOrd pos) +{ DYNARR_SET(trkSeg_t,anchors_da,anchors_da.cnt+5); - DrawArrowHeads(&DYNARR_N(trkSeg_t,anchors_da,anchors_da.cnt-5),pos,0,TRUE,wDrawColorBlue); + DrawArrowHeads(&DYNARR_N(trkSeg_t,anchors_da,anchors_da.cnt-5),pos,0,TRUE, + wDrawColorBlue); DYNARR_SET(trkSeg_t,anchors_da,anchors_da.cnt+5); - DrawArrowHeads(&DYNARR_N(trkSeg_t,anchors_da,anchors_da.cnt-5),pos,90,TRUE,wDrawColorBlue); + DrawArrowHeads(&DYNARR_N(trkSeg_t,anchors_da,anchors_da.cnt-5),pos,90,TRUE, + wDrawColorBlue); } static ANGLE_T PlaceStructure( - coOrd p0, - coOrd p1, - coOrd origPos, - coOrd * resPos, - ANGLE_T * resAngle ) + coOrd p0, + coOrd p1, + coOrd origPos, + coOrd * resPos, + ANGLE_T * resAngle ) { coOrd p2 = p1; if (curStructure->special == TOpierInfo) { pierTrk = OnTrack( &p1, FALSE, TRUE ); if (pierTrk != NULL) { - if (GetTrkType(pierTrk) == T_TURNOUT) { - pierEp = PickEndPoint( p1, pierTrk ); - if (pierEp >= 0) { - *resPos = GetTrkEndPos(pierTrk, pierEp); - *resAngle = NormalizeAngle(GetTrkEndAngle(pierTrk, pierEp)-90.0); - return TRUE; + if (((MyGetKeyState() & WKEY_ALT)==0) == magneticSnap ) { + if (GetTrkType(pierTrk) == T_TURNOUT) { + pierEp = PickEndPoint( p1, pierTrk ); + if (pierEp >= 0) { + *resPos = GetTrkEndPos(pierTrk, pierEp); + *resAngle = NormalizeAngle(GetTrkEndAngle(pierTrk, pierEp)-90.0); + return TRUE; + } } } *resAngle = NormalizeAngle(GetAngleAtPoint( pierTrk, p1, NULL, NULL )+90.0); - if ( NormalizeAngle( FindAngle( p1, p2 ) - *resAngle + 90.0 ) > 180.0 ) + if ( NormalizeAngle( FindAngle( p1, p2 ) - *resAngle + 90.0 ) > 180.0 ) { *resAngle = NormalizeAngle( *resAngle + 180.0 ); + } *resPos = p1; return TRUE; } @@ -722,45 +767,47 @@ static void NewStructure( void ) struct extraDataCompound_t *xx; wIndex_t pierInx; - if (curStructure->segCnt < 1) { - AbortProg( "newStructure: bad cnt" ); - } - if (Dst.state == 0) + CHECK( curStructure->segCnt >= 1 ); + if (Dst.state == 0) { return; + } if (curStructure->special == TOpierInfo && - curStructure->u.pierInfo.cnt>1 && - wListGetIndex(pierL) == -1) { + curStructure->u.pierInfo.cnt>1 && + wListGetIndex(pierL) == -1) { return; } UndoStart( _("Place Structure"), "newStruct" ); - trk = NewCompound( T_STRUCTURE, 0, Dst.pos, Dst.angle, curStructure->title, 0, NULL, NULL, curStructure->segCnt, curStructure->segs ); + trk = NewCompound( T_STRUCTURE, 0, Dst.pos, Dst.angle, curStructure->title, 0, + NULL, NULL, curStructure->segCnt, curStructure->segs ); xx = GET_EXTRA_DATA(trk, T_STRUCTURE, extraDataCompound_t); switch(curStructure->special) { - case TOnormal: - xx->special = TOnormal; - break; - case TOpierInfo: - xx->special = TOpier; - if (curStructure->u.pierInfo.cnt>1) { - pierInx = wListGetIndex(pierL); - if (pierInx < 0 || pierInx >= curStructure->u.pierInfo.cnt) - pierInx = 0; - } else { + case TOnormal: + xx->special = TOnormal; + break; + case TOpierInfo: + xx->special = TOpier; + if (curStructure->u.pierInfo.cnt>1) { + pierInx = wListGetIndex(pierL); + if (pierInx < 0 || pierInx >= curStructure->u.pierInfo.cnt) { pierInx = 0; } - xx->u.pier.height = curStructure->u.pierInfo.info[pierInx].height; - xx->u.pier.name = curStructure->u.pierInfo.info[pierInx].name; - if (pierTrk != NULL && xx->u.pier.height >= 0 ) { - UpdateTrkEndElev( pierTrk, pierEp, ELEV_DEF, xx->u.pier.height, NULL ); - } - break; - default: - AbortProg("bad special"); + } else { + pierInx = 0; + } + xx->u.pier.height = curStructure->u.pierInfo.info[pierInx].height; + xx->u.pier.name = curStructure->u.pierInfo.info[pierInx].name; + if (pierTrk != NULL && xx->u.pier.height >= 0 ) { + UpdateTrkEndElev( pierTrk, pierEp, ELEV_DEF, xx->u.pier.height, NULL ); + } + break; + default: + CHECKMSG( FALSE, ("bad special %d", (int) (curStructure->special) ) ); } - + SetTrkVisible( trk, TRUE ); SetTrkNoTies( trk, FALSE); SetTrkBridge( trk, FALSE); + SetTrkRoadbed( trk, FALSE); DrawNewTrack( trk ); /*DrawStructure( trk, &mainD, wDrawColorBlack, 0 );*/ @@ -773,8 +820,9 @@ static void NewStructure( void ) static void StructRotate( void * pangle ) { - if (Dst.state == 0) + if (Dst.state == 0) { return; + } ANGLE_T angle = (ANGLE_T)VP2L(pangle); angle /= 1000.0; Dst.pos = cmdMenuPos; @@ -785,8 +833,8 @@ static void StructRotate( void * pangle ) EXPORT STATUS_T CmdStructureAction( - wAction_t action, - coOrd pos ) + wAction_t action, + coOrd pos ) { ANGLE_T angle; @@ -799,9 +847,15 @@ EXPORT STATUS_T CmdStructureAction( switch (action & 0xFF) { case C_START: + if (!magneticSnap) { + InfoMessage(_("+Alt for Magnetic Snap")); + } else { + InfoMessage(_("+Alt to inhibit Magnetic Snap")); + } + DYNARR_RESET(trkSeg_t,anchors_da); Dst.state = 0; - Dst.angle = 00.0; + Dst.angle = 0.0; ShowPierL(); SetAllTrackSelect( FALSE ); return C_CONTINUE; @@ -818,8 +872,14 @@ EXPORT STATUS_T CmdStructureAction( case C_DOWN: DYNARR_RESET(trkSeg_t,anchors_da); - if ( curStructure == NULL ) return C_CONTINUE; + if ( curStructure == NULL ) { return C_CONTINUE; } ShowPierL(); + if ((MyGetKeyState()&WKEY_ALT) == 0) { + angle = Dst.angle; + if (SnapPosAngle(&pos, &angle)) { + Dst.angle = angle; + } + } Dst.pos = pos; rot0 = pos; origPos = Dst.pos; @@ -831,15 +891,26 @@ EXPORT STATUS_T CmdStructureAction( case C_MOVE: DYNARR_RESET(trkSeg_t,anchors_da); - if ( curStructure == NULL ) return C_CONTINUE; + if ( curStructure == NULL ) { return C_CONTINUE; } + if ((MyGetKeyState()&WKEY_ALT) == 0) { + angle = Dst.angle; + if (SnapPosAngle(&pos, &angle)) { + Dst.angle = angle; + } + } PlaceStructure( rot0, pos, origPos, &Dst.pos, &Dst.angle ); CreateMoveAnchor(pos); - InfoMessage( "[ %0.3f %0.3f ]", pos.x - origPos.x, pos.y - origPos.y ); + if (!magneticSnap) { + InfoMessage(_("+Alt for Magnetic Snap")); + } else { + InfoMessage(_("+Alt to inhibit Magnetic Snap")); + } + // InfoMessage( "[ %0.3f %0.3f ]", pos.x - origPos.x, pos.y - origPos.y ); return C_CONTINUE; case C_RDOWN: DYNARR_RESET(trkSeg_t,anchors_da); - if ( curStructure == NULL ) return C_CONTINUE; + if ( curStructure == NULL ) { return C_CONTINUE; } if (Dst.state == 0) { Dst.pos = pos; // If first, use pos, otherwise use current } @@ -854,7 +925,7 @@ EXPORT STATUS_T CmdStructureAction( case C_RMOVE: DYNARR_RESET(trkSeg_t,anchors_da); - if ( curStructure == NULL ) return C_CONTINUE; + if ( curStructure == NULL ) { return C_CONTINUE; } rot1 = pos; if ( FindDistance( rot0, rot1 ) > (6.0/BASE_DPI)*mainD.scale ) { angle = FindAngle( rot0, rot1 ); @@ -867,17 +938,18 @@ EXPORT STATUS_T CmdStructureAction( Dst.angle = NormalizeAngle( origAngle + angle ); Rotate( &Dst.pos, rot0, angle ); } - InfoMessage( _("Angle = %0.3f"), Dst.angle ); + // InfoMessage( _("Angle = %0.3f"), Dst.angle ); Dst.state = 2; CreateRotateAnchor(rot0); return C_CONTINUE; - + case C_RUP: case C_UP: DYNARR_RESET(trkSeg_t,anchors_da); CreateMoveAnchor(pos); Dst.state = 1; - InfoMessage(_("Left-Drag to place, Ctrl+Left-Drag or Right-Drag to Rotate, Space or Enter to accept, Esc to Cancel")); + InfoMessage( + _("Left-Drag to place, Ctrl+Left-Drag or Right-Drag to Rotate, Space or Enter to accept, Esc to Cancel")); return C_CONTINUE; case C_CMDMENU: @@ -888,22 +960,25 @@ EXPORT STATUS_T CmdStructureAction( case C_REDRAW: wSetCursor(mainD.d,defaultCursor); - if (Dst.state) + if (Dst.state) { DrawSegs( &tempD, Dst.pos, Dst.angle, - curStructure->segs, curStructure->segCnt, 0.0, selectedColor ); + curStructure->segs, curStructure->segCnt, 0.0, selectedColor ); + } + DrawSegsDA( &tempD, NULL, zero, 0.0, &anchors_da, trackGauge, wDrawColorBlack, + 0 ); if (anchors_da.cnt>0) { - DrawSegs( &tempD, zero, 0.0, &anchors(0), anchors_da.cnt, trackGauge, wDrawColorBlack ); - wSetCursor(mainD.d,wCursorNone); - } - if (Dst.state == 2) + wSetCursor(mainD.d,wCursorNone); + } + if (Dst.state == 2) { DrawLine( &tempD, rot0, rot1, 0, wDrawColorBlack ); + } return C_CONTINUE; case C_LCLICK: DYNARR_RESET(trkSeg_t,anchors_da); - if ( curStructure == NULL ) return C_CONTINUE; + if ( curStructure == NULL ) { return C_CONTINUE; } CmdStructureAction( C_DOWN, pos ); - CmdStructureAction( C_UP, pos ); + CmdStructureAction( C_UP, pos ); return C_CONTINUE; case C_CANCEL: @@ -915,9 +990,10 @@ EXPORT STATUS_T CmdStructureAction( return C_TERMINATE; case C_TEXT: - if ((action>>8) != ' ') + if ((action>>8) != ' ') { return C_CONTINUE; - /*no break*/ + } + /*no break*/ case C_OK: DYNARR_RESET(trkSeg_t,anchors_da); NewStructure(); @@ -926,10 +1002,11 @@ EXPORT STATUS_T CmdStructureAction( case C_FINISH: DYNARR_RESET(trkSeg_t,anchors_da); - if (Dst.state != 0) + if (Dst.state != 0) { CmdStructureAction( C_OK, pos ); - else + } else { CmdStructureAction( C_CANCEL, pos ); + } return C_TERMINATE; default: @@ -939,8 +1016,8 @@ EXPORT STATUS_T CmdStructureAction( static STATUS_T CmdStructure( - wAction_t action, - coOrd pos ) + wAction_t action, + coOrd pos ) { wIndex_t structureIndex; @@ -950,7 +1027,9 @@ static STATUS_T CmdStructure( case C_START: if (structureW == NULL) { - structureW = ParamCreateDialog( &structurePG, MakeWindowTitle(_("Structure")), _("Close"), (paramActionOkProc)DoStructOk, wHide, TRUE, NULL, F_RESIZE, StructureDlgUpdate ); + structureW = ParamCreateDialog( &structurePG, MakeWindowTitle(_("Structure")), + _("Close"), (paramActionOkProc)DoStructOk, wHide, TRUE, NULL, F_RESIZE, + StructureDlgUpdate ); RegisterChangeNotification( structureChange ); } ParamDialogOkActive( &structurePG, FALSE ); @@ -986,17 +1065,18 @@ static STATUS_T CmdStructure( if (MyGetKeyState()&WKEY_CTRL) { return CmdStructureAction( C_RDOWN, pos ); } - /* no break*/ + /* no break*/ case C_RDOWN: ParamDialogOkActive( &structurePG, TRUE ); - if (hideStructureWindow) + if (hideStructureWindow) { wHide( structureW ); + } return CmdStructureAction( action, pos ); case C_MOVE: if (MyGetKeyState()&WKEY_CTRL) { return CmdStructureAction( C_RMOVE, pos ); } - /*no break*/ + /*no break*/ case C_RMOVE: return CmdStructureAction( action, pos ); case C_RUP: @@ -1004,9 +1084,11 @@ static STATUS_T CmdStructure( if (MyGetKeyState()&WKEY_CTRL) { return CmdStructureAction( C_RUP, pos ); } - if (hideStructureWindow) + if (hideStructureWindow) { wShow( structureW ); - InfoMessage( _("Left drag to move, right drag to rotate, or press Return or click Ok to finalize") ); + } + InfoMessage( + _("Left drag to move, right drag to rotate, or press Return or click Ok to finalize") ); return CmdStructureAction( action, pos ); return C_CONTINUE; @@ -1016,7 +1098,8 @@ static STATUS_T CmdStructure( case C_CANCEL: wHide( structureW ); - /*no break*/ + return C_CANCEL; + case C_REDRAW: case C_TEXT: case C_OK: @@ -1032,10 +1115,10 @@ static STATUS_T CmdStructure( static char * CmdStructureHotBarProc( - hotBarProc_e op, - void * data, - drawCmd_p d, - coOrd * origP ) + hotBarProc_e op, + void * data, + drawCmd_p d, + coOrd * origP ) { turnoutInfo_t * to = (turnoutInfo_t*)data; switch ( op ) { @@ -1046,8 +1129,9 @@ static char * CmdStructureHotBarProc( return NULL; case HB_LISTTITLE: FormatCompoundTitle( listLabels, to->title ); - if (message[0] == '\0') + if (message[0] == '\0') { FormatCompoundTitle( listLabels|LABEL_DESCR, to->title ); + } return message; case HB_BARTITLE: FormatCompoundTitle( hotBarLabels<<1, to->title ); @@ -1071,18 +1155,22 @@ EXPORT void AddHotBarStructures( void ) for ( inx=0; inx < structureInfo_da.cnt; inx ++ ) { to = structureInfo(inx); if ( !( IsParamValid(to->paramFileIndex) && - to->segCnt > 0 && - (FIT_NONE != CompatibleScale( FIT_STRUCTURE, to->scaleInx, GetLayoutCurScale())) ) ) - /*( (strcmp( to->scale, "*" ) == 0 && strcasecmp( curScaleName, "DEMO" ) != 0 ) || - strncasecmp( to->scale, curScaleName, strlen(to->scale) ) == 0 ) ) )*/ - continue; - AddHotBarElement( to->contentsLabel, to->size, to->orig, FALSE, FALSE, to->barScale, to, CmdStructureHotBarProc ); + to->segCnt > 0 && + (FIT_NONE != CompatibleScale( FIT_STRUCTURE, to->scaleInx, + GetLayoutCurScale())) ) ) + /*( (strcmp( to->scale, "*" ) == 0 && strcasecmp( curScaleName, "DEMO" ) != 0 ) || + strncasecmp( to->scale, curScaleName, strlen(to->scale) ) == 0 ) ) )*/ + { + continue; + } + AddHotBarElement( to->contentsLabel, to->size, to->orig, FALSE, FALSE, + to->barScale, to, CmdStructureHotBarProc ); } } static STATUS_T CmdStructureHotBar( - wAction_t action, - coOrd pos ) + wAction_t action, + coOrd pos ) { switch (action & 0xFF) { @@ -1094,9 +1182,10 @@ static STATUS_T CmdStructureHotBar( } FormatCompoundTitle( listLabels|LABEL_DESCR, curStructure->title ); InfoMessage( _("Place %s and draw into position"), message ); - wIndex_t listIndex = FindListItemByContext( structureListL, curStructure ); - if ( listIndex >= 0 ) - structureInx = listIndex; + wIndex_t listIndex = FindListItemByContext( structureListL, curStructure ); + if ( listIndex >= 0 ) { + structureInx = listIndex; + } ParamLoadControls( &structurePG ); ParamGroupRecord( &structurePG ); return CmdStructureAction( action, pos ); @@ -1109,6 +1198,9 @@ static STATUS_T CmdStructureHotBar( if (MyGetKeyState()&WKEY_CTRL) { return CmdStructureAction( C_RDOWN, pos ); } + if ((MyGetKeyState()&WKEY_ALT) == 0) { + SnapPos(&pos); + } return CmdStructureAction( action, pos ); case C_RMOVE: @@ -1116,6 +1208,9 @@ static STATUS_T CmdStructureHotBar( if (MyGetKeyState()&WKEY_CTRL) { return CmdStructureAction( C_RMOVE, pos ); } + if ((MyGetKeyState()&WKEY_ALT) == 0) { + SnapPos(&pos); + } return CmdStructureAction( action, pos ); case C_RUP: @@ -1123,31 +1218,37 @@ static STATUS_T CmdStructureHotBar( if (MyGetKeyState()&WKEY_CTRL) { return CmdStructureAction( C_RUP, pos ); } - InfoMessage( _("Left-Drag to place, Ctrl+Left-Drag or Right-Drag to Rotate, Space or Enter to accept, Esc to Cancel") ); + InfoMessage( + _("Left-Drag to place, Ctrl+Left-Drag or Right-Drag to Rotate, Space or Enter to accept, Esc to Cancel") ); return CmdStructureAction( action, pos ); case C_TEXT: - if ((action>>8) != ' ') + if ((action>>8) != ' ') { return C_CONTINUE; - /*no break*/ + } + /*no break*/ case C_OK: CmdStructureAction( action, pos ); return C_CONTINUE; case C_CANCEL: HotBarCancel(); - /* no break*/ + /* no break*/ default: return CmdStructureAction( action, pos ); } } -#include "bitmaps/building.xpm" +#include "bitmaps/building.xpm3" EXPORT void InitCmdStruct( wMenu_p menu ) { - AddMenuButton( menu, CmdStructure, "cmdStructure", _("Structure"), wIconCreatePixMap(building_xpm[iconSize]), LEVEL0_50, IC_WANT_MOVE|IC_STICKY|IC_CMDMENU|IC_POPUP2, ACCL_STRUCTURE, NULL ); - structureHotBarCmdInx = AddMenuButton( menu, CmdStructureHotBar, "cmdStructureHotBar", "", NULL, LEVEL0_50, IC_WANT_MOVE|IC_STICKY|IC_CMDMENU|IC_POPUP2, 0, NULL ); + AddMenuButton( menu, CmdStructure, "cmdStructure", _("Structure"), + wIconCreatePixMap(building_xpm3[iconSize]), LEVEL0_50, + IC_WANT_MOVE|IC_STICKY|IC_CMDMENU|IC_POPUP2, ACCL_STRUCTURE, NULL ); + structureHotBarCmdInx = AddMenuButton( menu, CmdStructureHotBar, + "cmdStructureHotBar", "", NULL, LEVEL0_50, + IC_WANT_MOVE|IC_STICKY|IC_CMDMENU|IC_POPUP2, 0, NULL ); ParamRegister( &structurePG ); if ( structPopupM == NULL ) { structPopupM = MenuRegister( "Structure Rotate" ); diff --git a/app/bin/cswitchmotor.c b/app/bin/cswitchmotor.c index 563e4b8..7bdbbcf 100644 --- a/app/bin/cswitchmotor.c +++ b/app/bin/cswitchmotor.c @@ -44,7 +44,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * */ @@ -56,7 +56,6 @@ #include "fileio.h" #include "param.h" #include "track.h" -#include "trackx.h" #include "common-ui.h" #ifdef UTFCONVERT #include "include/utf8convert.h" @@ -74,7 +73,8 @@ static drawCmd_t switchmotorD = { 1.0, 0.0, {0.0,0.0}, {0.0,0.0}, - Pix2CoOrd, CoOrd2Pix }; + Pix2CoOrd, CoOrd2Pix +}; static char switchmotorName[STR_SHORT_SIZE]; static char switchmotorNormal[STR_LONG_SIZE]; @@ -86,10 +86,10 @@ static track_p last_motor; static track_p first_motor; static paramData_t switchmotorPLs[] = { -/*0*/ { PD_STRING, switchmotorName, "name", PDO_NOPREF|PDO_NOTBLANK, I2VP(200), N_("Name"), 0, 0, sizeof(switchmotorName)}, -/*1*/ { PD_STRING, switchmotorNormal, "normal", PDO_NOPREF, I2VP(350), N_("Normal"), 0, 0, sizeof(switchmotorNormal)}, -/*2*/ { PD_STRING, switchmotorReverse, "reverse", PDO_NOPREF, I2VP(350), N_("Reverse"), 0, 0, sizeof(switchmotorReverse)}, -/*3*/ { PD_STRING, switchmotorPointSense, "pointSense", PDO_NOPREF, I2VP(350), N_("Point Sense"), 0, 0, sizeof(switchmotorPointSense)} + /*0*/ { PD_STRING, switchmotorName, "name", PDO_NOPREF|PDO_NOTBLANK, I2VP(200), N_("Name"), 0, 0, sizeof(switchmotorName)}, + /*1*/ { PD_STRING, switchmotorNormal, "normal", PDO_NOPREF, I2VP(350), N_("Normal"), 0, 0, sizeof(switchmotorNormal)}, + /*2*/ { PD_STRING, switchmotorReverse, "reverse", PDO_NOPREF, I2VP(350), N_("Reverse"), 0, 0, sizeof(switchmotorReverse)}, + /*3*/ { PD_STRING, switchmotorPointSense, "pointSense", PDO_NOPREF, I2VP(350), N_("Point Sense"), 0, 0, sizeof(switchmotorPointSense)} }; static paramGroup_t switchmotorPG = { "switchmotor", 0, switchmotorPLs, COUNT( switchmotorPLs ) }; @@ -105,11 +105,11 @@ static track_p switchmotorEditTrack; static paramIntegerRange_t r0_999999 = { 0, 999999 }; static paramData_t switchmotorEditPLs[] = { - /*0*/ { PD_STRING, switchmotorEditName, "name", PDO_NOPREF | PDO_NOTBLANK, I2VP(200), N_("Name"), 0, 0, sizeof(switchmotorEditName)}, -/*1*/ { PD_STRING, switchmotorEditNormal, "normal", PDO_NOPREF, I2VP(350), N_("Normal"), 0, 0, sizeof(switchmotorEditNormal)}, -/*2*/ { PD_STRING, switchmotorEditReverse, "reverse", PDO_NOPREF, I2VP(350), N_("Reverse"), 0, 0, sizeof(switchmotorEditReverse)}, -/*3*/ { PD_STRING, switchmotorEditPointSense, "pointSense", PDO_NOPREF, I2VP(350), N_("Point Sense"), 0, 0, sizeof(switchmotorEditPointSense)}, -/*4*/ { PD_LONG, &switchmotorEditTonum, "turnoutNumber", PDO_NOPREF, &r0_999999, N_("Turnout Number"), BO_READONLY }, + /*0*/ { PD_STRING, switchmotorEditName, "name", PDO_NOPREF | PDO_NOTBLANK, I2VP(200), N_("Name"), 0, 0, sizeof(switchmotorEditName)}, + /*1*/ { PD_STRING, switchmotorEditNormal, "normal", PDO_NOPREF, I2VP(350), N_("Normal"), 0, 0, sizeof(switchmotorEditNormal)}, + /*2*/ { PD_STRING, switchmotorEditReverse, "reverse", PDO_NOPREF, I2VP(350), N_("Reverse"), 0, 0, sizeof(switchmotorEditReverse)}, + /*3*/ { PD_STRING, switchmotorEditPointSense, "pointSense", PDO_NOPREF, I2VP(350), N_("Point Sense"), 0, 0, sizeof(switchmotorEditPointSense)}, + /*4*/ { PD_LONG, &switchmotorEditTonum, "turnoutNumber", PDO_NOPREF, &r0_999999, N_("Turnout Number"), BO_READONLY }, }; static paramGroup_t switchmotorEditPG = { "switchmotorEdit", 0, switchmotorEditPLs, COUNT( switchmotorEditPLs ) }; @@ -121,15 +121,15 @@ static dynArr_t switchmotorTrk_da; */ typedef struct switchmotorData_t { - extraDataBase_t base; - char * name; - char * normal; - char * reverse; - char * pointsense; - BOOL_T IsHilite; - TRKINX_T turnindx; - track_p turnout; - track_p next_motor; + extraDataBase_t base; + char * name; + char * normal; + char * reverse; + char * pointsense; + BOOL_T IsHilite; + TRKINX_T turnindx; + track_p turnout; + track_p next_motor; } switchmotorData_t, *switchmotorData_p; static switchmotorData_p GetswitchmotorData ( track_p trk ) @@ -143,69 +143,76 @@ static wDrawBitMap_p switchmotormark_bm = NULL; #endif static coOrd switchmotorPoly_Pix[] = { - {6,0}, {6,13}, {4,13}, {4,19}, {6,19}, {6,23}, {9,23}, {9,19}, {13,19}, - {13,23}, {27,23}, {27,10}, {13,10}, {13,13}, {9,13}, {9,0}, {6,0} }; + {6,0}, {6,13}, {4,13}, {4,19}, {6,19}, {6,23}, {9,23}, {9,19}, {13,19}, + {13,23}, {27,23}, {27,10}, {13,10}, {13,13}, {9,13}, {9,0}, {6,0} +}; #define switchmotorPoly_CNT (COUNT(switchmotorPoly_Pix)) #define switchmotorPoly_SF (3.0) static void ComputeSwitchMotorBoundingBox (track_p t) { - coOrd hi, lo, p; - switchmotorData_p data_p = GetswitchmotorData(t); - struct extraDataCompound_t *xx = GET_EXTRA_DATA(data_p->turnout, T_TURNOUT, extraDataCompound_t); - coOrd orig = xx->orig; - ANGLE_T angle = xx->angle; - SCALEINX_T s = GetTrkScale(data_p->turnout); - DIST_T scaleRatio = GetScaleRatio(s); - int iPoint; - ANGLE_T x_angle, y_angle; - - x_angle = 90-(360-angle); - if (x_angle < 0) x_angle += 360; - y_angle = -(360-angle); - if (y_angle < 0) y_angle += 360; - - - for (iPoint = 0; iPoint < switchmotorPoly_CNT; iPoint++) { - Translate (&p, orig, x_angle, switchmotorPoly_Pix[iPoint].x * switchmotorPoly_SF / scaleRatio ); - Translate (&p, p, y_angle, (10+switchmotorPoly_Pix[iPoint].y) * switchmotorPoly_SF / scaleRatio ); - if (iPoint == 0) { - lo = p; - hi = p; - } else { - if (p.x < lo.x) lo.x = p.x; - if (p.y < lo.y) lo.y = p.y; - if (p.x > hi.x) hi.x = p.x; - if (p.y > hi.y) hi.y = p.y; - } - } - SetBoundingBox(t, hi, lo); + coOrd hi, lo, p; + switchmotorData_p data_p = GetswitchmotorData(t); + struct extraDataCompound_t *xx = GET_EXTRA_DATA(data_p->turnout, T_TURNOUT, + extraDataCompound_t); + coOrd orig = xx->orig; + ANGLE_T angle = xx->angle; + SCALEINX_T s = GetTrkScale(data_p->turnout); + DIST_T scaleRatio = GetScaleRatio(s); + int iPoint; + ANGLE_T x_angle, y_angle; + + x_angle = 90-(360-angle); + if (x_angle < 0) { x_angle += 360; } + y_angle = -(360-angle); + if (y_angle < 0) { y_angle += 360; } + + + for (iPoint = 0; iPoint < switchmotorPoly_CNT; iPoint++) { + Translate (&p, orig, x_angle, + switchmotorPoly_Pix[iPoint].x * switchmotorPoly_SF / scaleRatio ); + Translate (&p, p, y_angle, + (10+switchmotorPoly_Pix[iPoint].y) * switchmotorPoly_SF / scaleRatio ); + if (iPoint == 0) { + lo = p; + hi = p; + } else { + if (p.x < lo.x) { lo.x = p.x; } + if (p.y < lo.y) { lo.y = p.y; } + if (p.x > hi.x) { hi.x = p.x; } + if (p.y > hi.y) { hi.y = p.y; } + } + } + SetBoundingBox(t, hi, lo); } - - + + static void DrawSwitchMotor (track_p t, drawCmd_p d, wDrawColor color ) { - coOrd p[switchmotorPoly_CNT]; - switchmotorData_p data_p = GetswitchmotorData(t); - struct extraDataCompound_t *xx = GET_EXTRA_DATA(data_p->turnout, T_TURNOUT, extraDataCompound_t); - coOrd orig = xx->orig; - ANGLE_T angle = xx->angle; - SCALEINX_T s = GetTrkScale(data_p->turnout); - DIST_T scaleRatio = GetScaleRatio(s); - int iPoint; - ANGLE_T x_angle, y_angle; - - x_angle = 90-(360-angle); - if (x_angle < 0) x_angle += 360; - y_angle = -(360-angle); - if (y_angle < 0) y_angle += 360; - - - for (iPoint = 0; iPoint < switchmotorPoly_CNT; iPoint++) { - Translate (&p[iPoint], orig, x_angle, switchmotorPoly_Pix[iPoint].x * switchmotorPoly_SF / scaleRatio ); - Translate (&p[iPoint], p[iPoint], y_angle, (10+switchmotorPoly_Pix[iPoint].y) * switchmotorPoly_SF / scaleRatio ); - } - DrawPoly(d, switchmotorPoly_CNT, p, NULL, color, 0, DRAW_FILL); + coOrd p[switchmotorPoly_CNT]; + switchmotorData_p data_p = GetswitchmotorData(t); + struct extraDataCompound_t *xx = GET_EXTRA_DATA(data_p->turnout, T_TURNOUT, + extraDataCompound_t); + coOrd orig = xx->orig; + ANGLE_T angle = xx->angle; + SCALEINX_T s = GetTrkScale(data_p->turnout); + DIST_T scaleRatio = GetScaleRatio(s); + int iPoint; + ANGLE_T x_angle, y_angle; + + x_angle = 90-(360-angle); + if (x_angle < 0) { x_angle += 360; } + y_angle = -(360-angle); + if (y_angle < 0) { y_angle += 360; } + + + for (iPoint = 0; iPoint < switchmotorPoly_CNT; iPoint++) { + Translate (&p[iPoint], orig, x_angle, + switchmotorPoly_Pix[iPoint].x * switchmotorPoly_SF / scaleRatio ); + Translate (&p[iPoint], p[iPoint], y_angle, + (10+switchmotorPoly_Pix[iPoint].y) * switchmotorPoly_SF / scaleRatio ); + } + DrawPoly(d, switchmotorPoly_CNT, p, NULL, color, 0, DRAW_FILL); } static struct { @@ -218,14 +225,16 @@ static struct { typedef enum { NM, NOR, REV, PS, TO } switchmotorDesc_e; static descData_t switchmotorDesc[] = { -/*NM */ { DESC_STRING, N_("Name"), &switchmotorData.name, sizeof(switchmotorData.name) }, -/*NOR*/ { DESC_STRING, N_("Normal"), &switchmotorData.normal, sizeof(switchmotorData.normal) }, -/*REV*/ { DESC_STRING, N_("Reverse"), &switchmotorData.reverse, sizeof(switchmotorData.reverse) }, -/*PS */ { DESC_STRING, N_("Point Sense"), &switchmotorData.pointsense, sizeof(switchmotorData.pointsense) }, -/*TO */ { DESC_LONG, N_("Turnout"), &switchmotorData.turnout }, - { DESC_NULL } }; - -static void UpdateSwitchMotor (track_p trk, int inx, descData_p descUpd, BOOL_T needUndoStart ) + /*NM */ { DESC_STRING, N_("Name"), &switchmotorData.name, sizeof(switchmotorData.name) }, + /*NOR*/ { DESC_STRING, N_("Normal"), &switchmotorData.normal, sizeof(switchmotorData.normal) }, + /*REV*/ { DESC_STRING, N_("Reverse"), &switchmotorData.reverse, sizeof(switchmotorData.reverse) }, + /*PS */ { DESC_STRING, N_("Point Sense"), &switchmotorData.pointsense, sizeof(switchmotorData.pointsense) }, + /*TO */ { DESC_LONG, N_("Turnout"), &switchmotorData.turnout }, + { DESC_NULL } +}; + +static void UpdateSwitchMotor (track_p trk, int inx, descData_p descUpd, + BOOL_T needUndoStart ) { switchmotorData_p xx = GetswitchmotorData(trk); const char * thename, *thenormal, *thereverse, *thepointsense; @@ -233,7 +242,8 @@ static void UpdateSwitchMotor (track_p trk, int inx, descData_p descUpd, BOOL_T unsigned int max_str; BOOL_T changed, nChanged, norChanged, revChanged, psChanged; - LOG( log_switchmotor, 1, ("*** UpdateSwitchMotor(): needUndoStart = %d\n",needUndoStart)) + LOG( log_switchmotor, 1, ("*** UpdateSwitchMotor(): needUndoStart = %d\n", + needUndoStart)) if ( inx == -1 ) { nChanged = norChanged = revChanged = psChanged = changed = FALSE; thename = wStringGetValue( (wString_p)switchmotorDesc[NM].control0 ); @@ -245,7 +255,7 @@ static void UpdateSwitchMotor (track_p trk, int inx, descData_p descUpd, BOOL_T newName[max_str-1] = '\0'; strncat(newName,thename,max_str-1); NoticeMessage2(0, MSG_ENTERED_STRING_TRUNCATED, _("Ok"), NULL, max_str-1); - } else newName = MyStrdup(thename); + } else { newName = MyStrdup(thename); } } thenormal = wStringGetValue( (wString_p)switchmotorDesc[NOR].control0 ); @@ -257,7 +267,7 @@ static void UpdateSwitchMotor (track_p trk, int inx, descData_p descUpd, BOOL_T newNormal[max_str-1] = '\0'; strncat(newNormal,thenormal, max_str-1); NoticeMessage2(0, MSG_ENTERED_STRING_TRUNCATED, _("Ok"), NULL, max_str-1); - } else newNormal = MyStrdup(thenormal); + } else { newNormal = MyStrdup(thenormal); } } thereverse = wStringGetValue( (wString_p)switchmotorDesc[REV].control0 ); @@ -269,7 +279,7 @@ static void UpdateSwitchMotor (track_p trk, int inx, descData_p descUpd, BOOL_T newReverse[max_str-1] = '\0'; strncat(newReverse,thereverse,max_str-1); NoticeMessage2(0, MSG_ENTERED_STRING_TRUNCATED, _("Ok"), NULL, max_str-1); - } else newReverse = MyStrdup(thereverse); + } else { newReverse = MyStrdup(thereverse); } } thepointsense = wStringGetValue( (wString_p)switchmotorDesc[PS].control0 ); @@ -281,12 +291,13 @@ static void UpdateSwitchMotor (track_p trk, int inx, descData_p descUpd, BOOL_T newPointSense[max_str-1] = '\0'; strncat(newPointSense,thepointsense, max_str-1); NoticeMessage2(0, MSG_ENTERED_STRING_TRUNCATED, _("Ok"), NULL, max_str-1); - } else newPointSense = MyStrdup(thepointsense); + } else { newPointSense = MyStrdup(thepointsense); } } - if ( ! changed ) return; - if ( needUndoStart ) + if ( ! changed ) { return; } + if ( needUndoStart ) { UndoStart( _("Change Switch Motor"), "Change Switch Motor" ); + } UndoModify( trk ); if (nChanged) { MyFree(xx->name); @@ -311,13 +322,13 @@ static void UpdateSwitchMotor (track_p trk, int inx, descData_p descUpd, BOOL_T static DIST_T DistanceSwitchMotor (track_p t, coOrd * p ) { switchmotorData_p xx = GetswitchmotorData(t); - if (xx->turnout == NULL) return 0; - coOrd center,hi,lo; - GetBoundingBox(t,&hi,&lo); - center.x = (hi.x+lo.x)/2; - center.y = (hi.y+lo.y)/2; - DIST_T d = FindDistance(center,*p); - *p = center; + if (xx->turnout == NULL) { return 0; } + coOrd center,hi,lo; + GetBoundingBox(t,&hi,&lo); + center.x = (hi.x+lo.x)/2; + center.y = (hi.y+lo.y)/2; + DIST_T d = FindDistance(center,*p); + *p = center; return d; } @@ -326,10 +337,12 @@ static void DescribeSwitchMotor (track_p trk, char * str, CSIZE_T len ) switchmotorData_p xx = GetswitchmotorData(trk); long listLabelsOption = listLabels; - LOG( log_switchmotor, 1, ("*** DescribeSwitchMotor(): trk is T%d\n",GetTrkIndex(trk))) + LOG( log_switchmotor, 1, ("*** DescribeSwitchMotor(): trk is T%d\n", + GetTrkIndex(trk))) FormatCompoundTitle( listLabelsOption, xx->name ); - if (message[0] == '\0') + if (message[0] == '\0') { FormatCompoundTitle( listLabelsOption|LABEL_DESCR, xx->name ); + } strcpy( str, _(GetTrkTypeName( trk )) ); str++; while (*str) { @@ -337,7 +350,7 @@ static void DescribeSwitchMotor (track_p trk, char * str, CSIZE_T len ) str++; } sprintf( str, _("(%d): Layer=%u %s"), - GetTrkIndex(trk), GetTrkLayer(trk)+1, message ); + GetTrkIndex(trk), GetTrkLayer(trk)+1, message ); strncpy(switchmotorData.name,xx->name,STR_SHORT_SIZE-1); switchmotorData.name[STR_SHORT_SIZE-1] = '\0'; strncpy(switchmotorData.normal,xx->normal,STR_LONG_SIZE-1); @@ -346,13 +359,13 @@ static void DescribeSwitchMotor (track_p trk, char * str, CSIZE_T len ) switchmotorData.reverse[STR_LONG_SIZE-1] = '\0'; strncpy(switchmotorData.pointsense,xx->pointsense,STR_LONG_SIZE-1); switchmotorData.pointsense[STR_LONG_SIZE-1] = '\0'; - if (xx->turnout == NULL) switchmotorData.turnout = 0; - else switchmotorData.turnout = GetTrkIndex(xx->turnout); + if (xx->turnout == NULL) { switchmotorData.turnout = 0; } + else { switchmotorData.turnout = GetTrkIndex(xx->turnout); } switchmotorDesc[TO].mode = DESC_RO; switchmotorDesc[NM].mode = - switchmotorDesc[NOR].mode = - switchmotorDesc[REV].mode = - switchmotorDesc[PS].mode = DESC_NOREDRAW; + switchmotorDesc[NOR].mode = + switchmotorDesc[REV].mode = + switchmotorDesc[PS].mode = DESC_NOREDRAW; DoDescribe(_("Switch motor"), trk, switchmotorDesc, UpdateSwitchMotor ); } @@ -360,35 +373,43 @@ static void switchmotorDebug (track_p trk) { switchmotorData_p xx = GetswitchmotorData(trk); LOG( log_switchmotor, 1, ("*** switchmotorDebug(): trk = %08x\n",trk)) - LOG( log_switchmotor, 1, ("*** switchmotorDebug(): Index = %d\n",GetTrkIndex(trk))) + LOG( log_switchmotor, 1, ("*** switchmotorDebug(): Index = %d\n", + GetTrkIndex(trk))) LOG( log_switchmotor, 1, ("*** switchmotorDebug(): name = \"%s\"\n",xx->name)) - LOG( log_switchmotor, 1, ("*** switchmotorDebug(): normal = \"%s\"\n",xx->normal)) - LOG( log_switchmotor, 1, ("*** switchmotorDebug(): reverse = \"%s\"\n",xx->reverse)) - LOG( log_switchmotor, 1, ("*** switchmotorDebug(): pointsense = \"%s\"\n",xx->pointsense)) - LOG( log_switchmotor, 1, ("*** switchmotorDebug(): turnindx = %d\n",xx->turnindx)) - if (xx->turnout != NULL) { - LOG( log_switchmotor, 1, ("*** switchmotorDebug(): turnout = T%d, %s\n", - GetTrkIndex(xx->turnout), GetTrkTypeName(xx->turnout))) - } + LOG( log_switchmotor, 1, ("*** switchmotorDebug(): normal = \"%s\"\n", + xx->normal)) + LOG( log_switchmotor, 1, ("*** switchmotorDebug(): reverse = \"%s\"\n", + xx->reverse)) + LOG( log_switchmotor, 1, ("*** switchmotorDebug(): pointsense = \"%s\"\n", + xx->pointsense)) + LOG( log_switchmotor, 1, ("*** switchmotorDebug(): turnindx = %d\n", + xx->turnindx)) + if (xx->turnout != NULL) { + LOG( log_switchmotor, 1, ("*** switchmotorDebug(): turnout = T%d, %s\n", + GetTrkIndex(xx->turnout), GetTrkTypeName(xx->turnout))) + } } static void DeleteSwitchMotor ( track_p trk ) { - track_p trk1; + track_p trk1; switchmotorData_p xx1; LOG( log_switchmotor, 1,("*** DeleteSwitchMotor(%p)\n",trk)) - LOG( log_switchmotor, 1,("*** DeleteSwitchMotor(): index is %d\n",GetTrkIndex(trk))) + LOG( log_switchmotor, 1,("*** DeleteSwitchMotor(): index is %d\n", + GetTrkIndex(trk))) switchmotorData_p xx = GetswitchmotorData(trk); - LOG( log_switchmotor, 1,("*** DeleteSwitchMotor(): xx = %p, xx->name = %p, xx->normal = %p, xx->reverse = %p, xx->pointsense = %p\n", - xx,xx->name,xx->normal,xx->reverse,xx->pointsense)) + LOG( log_switchmotor, 1, + ("*** DeleteSwitchMotor(): xx = %p, xx->name = %p, xx->normal = %p, xx->reverse = %p, xx->pointsense = %p\n", + xx,xx->name,xx->normal,xx->reverse,xx->pointsense)) MyFree(xx->name); xx->name = NULL; MyFree(xx->normal); xx->normal = NULL; MyFree(xx->reverse); xx->reverse = NULL; MyFree(xx->pointsense); xx->pointsense = NULL; - if (first_motor == trk) - first_motor = xx->next_motor; + if (first_motor == trk) { + first_motor = xx->next_motor; + } trk1 = first_motor; while(trk1) { xx1 = GetswitchmotorData (trk1); @@ -398,8 +419,9 @@ static void DeleteSwitchMotor ( track_p trk ) } trk1 = xx1->next_motor; } - if (trk == last_motor) - last_motor = trk1; + if (trk == last_motor) { + last_motor = trk1; + } } static BOOL_T WriteSwitchMotor ( track_p t, FILE * f ) @@ -407,16 +429,17 @@ static BOOL_T WriteSwitchMotor ( track_p t, FILE * f ) BOOL_T rc = TRUE; switchmotorData_p xx = GetswitchmotorData(t); char *switchMotorName = MyStrdup(xx->name); - + #ifdef UTFCONVERT switchMotorName = Convert2UTF8(switchMotorName); #endif // UTFCONVERT - if (xx->turnout == NULL) + if (xx->turnout == NULL) { return FALSE; + } rc &= fprintf(f, "SWITCHMOTOR %d %d \"%s\" \"%s\" \"%s\" \"%s\"\n", - GetTrkIndex(t), GetTrkIndex(xx->turnout), switchMotorName, - xx->normal, xx->reverse, xx->pointsense)>0; + GetTrkIndex(t), GetTrkIndex(xx->turnout), switchMotorName, + xx->normal, xx->reverse, xx->pointsense)>0; MyFree(switchMotorName); return rc; @@ -431,7 +454,8 @@ static BOOL_T ReadSwitchMotor ( char * line ) char *name, *normal, *reverse, *pointsense; LOG( log_switchmotor, 1, ("*** ReadSwitchMotor: line is '%s'\n",line)) - if (!GetArgs(line+12,"ddqqqq",&index,&trkindex,&name,&normal,&reverse,&pointsense)) { + if (!GetArgs(line+12,"ddqqqq",&index,&trkindex,&name,&normal,&reverse, + &pointsense)) { return FALSE; } #ifdef UTFCONVERT @@ -443,37 +467,42 @@ static BOOL_T ReadSwitchMotor ( char * line ) xx->normal = normal; xx->reverse = reverse; xx->pointsense = pointsense; - xx->turnindx = trkindex; - if (last_motor) { - last_trk = last_motor; - xx1 = GetswitchmotorData(last_trk); - xx1->next_motor = trk; - } else first_motor = trk; - xx->next_motor = NULL; - last_motor = trk; - - LOG( log_switchmotor, 1,("*** ReadSwitchMotor(): trk = %p (%d), xx = %p\n",trk,GetTrkIndex(trk),xx)) - LOG( log_switchmotor, 1,("*** ReadSwitchMotor(): name = %p, normal = %p, reverse = %p, pointsense = %p\n", - name,normal,reverse,pointsense)) - switchmotorDebug(trk); + xx->turnindx = trkindex; + if (last_motor) { + last_trk = last_motor; + xx1 = GetswitchmotorData(last_trk); + xx1->next_motor = trk; + } else { first_motor = trk; } + xx->next_motor = NULL; + last_motor = trk; + + LOG( log_switchmotor, 1,("*** ReadSwitchMotor(): trk = %p (%d), xx = %p\n",trk, + GetTrkIndex(trk),xx)) + LOG( log_switchmotor, 1, + ("*** ReadSwitchMotor(): name = %p, normal = %p, reverse = %p, pointsense = %p\n", + name,normal,reverse,pointsense)) + switchmotorDebug(trk); return TRUE; } EXPORT void ResolveSwitchmotorTurnout ( track_p trk ) { - LOG( log_switchmotor, 1,("*** ResolveSwitchmotorTurnout(%p)\n",trk)) - switchmotorData_p xx; - track_p t_trk; - if (GetTrkType(trk) != T_SWITCHMOTOR) return; - xx = GetswitchmotorData(trk); - LOG( log_switchmotor, 1, ("*** ResolveSwitchmotorTurnout(%d)\n",GetTrkIndex(trk))) - t_trk = FindTrack(xx->turnindx); - if (t_trk == NULL) { - NoticeMessage( _("ResolveSwitchmotor: Turnout T%d: T%d doesn't exist"), _("Continue"), NULL, GetTrkIndex(trk), xx->turnindx ); - } - xx->turnout = t_trk; - ComputeSwitchMotorBoundingBox(trk); - LOG( log_switchmotor, 1,("*** ResolveSwitchmotorTurnout(): t_trk = (%d) %p\n",xx->turnindx,t_trk)) + LOG( log_switchmotor, 1,("*** ResolveSwitchmotorTurnout(%p)\n",trk)) + switchmotorData_p xx; + track_p t_trk; + if (GetTrkType(trk) != T_SWITCHMOTOR) { return; } + xx = GetswitchmotorData(trk); + LOG( log_switchmotor, 1, ("*** ResolveSwitchmotorTurnout(%d)\n", + GetTrkIndex(trk))) + t_trk = FindTrack(xx->turnindx); + if (t_trk == NULL) { + NoticeMessage( _("ResolveSwitchmotor: Turnout T%d: T%d doesn't exist"), + _("Continue"), NULL, GetTrkIndex(trk), xx->turnindx ); + } + xx->turnout = t_trk; + ComputeSwitchMotorBoundingBox(trk); + LOG( log_switchmotor, 1,("*** ResolveSwitchmotorTurnout(): t_trk = (%d) %p\n", + xx->turnindx,t_trk)) } static void MoveSwitchMotor (track_p trk, coOrd orig ) {} @@ -523,7 +552,7 @@ static track_p FindSwitchMotor (track_p trk) while (a_trk) { xx = GetswitchmotorData(a_trk); if (!IsTrackDeleted(a_trk)) { - if (xx->turnout == trk) return a_trk; + if (xx->turnout == trk) { return a_trk; } } a_trk = xx->next_motor; } @@ -555,10 +584,11 @@ static void SwitchMotorOk ( void * junk ) if (trk1) { xx1 = GetswitchmotorData( trk1 ); xx1->next_motor = trk; - } else first_motor = trk; + } else { first_motor = trk; } xx->next_motor = NULL; last_motor = trk; - LOG( log_switchmotor, 1,("*** SwitchMotorOk(): trk = %p (%d), xx = %p\n",trk,GetTrkIndex(trk),xx)) + LOG( log_switchmotor, 1,("*** SwitchMotorOk(): trk = %p (%d), xx = %p\n",trk, + GetTrkIndex(trk),xx)) switchmotorDebug(trk); UndoEnd(); wHide( switchmotorW ); @@ -571,10 +601,12 @@ static void NewSwitchMotorDialog(track_p trk) LOG( log_switchmotor, 1, ("*** NewSwitchMotorDialog()\n")) switchmotorTurnout = trk; - if ( log_switchmotor < 0 ) log_switchmotor = LogFindIndex( "switchmotor" ); + if ( log_switchmotor < 0 ) { log_switchmotor = LogFindIndex( "switchmotor" ); } if ( !switchmotorW ) { ParamRegister( &switchmotorPG ); - switchmotorW = ParamCreateDialog (&switchmotorPG, MakeWindowTitle(_("Create switch motor")), _("Ok"), SwitchMotorOk, wHide, TRUE, NULL, F_BLOCK, NULL ); + switchmotorW = ParamCreateDialog (&switchmotorPG, + MakeWindowTitle(_("Create switch motor")), _("Ok"), SwitchMotorOk, wHide, TRUE, + NULL, F_BLOCK, NULL ); switchmotorD.dpi = mainD.dpi; } ParamLoadControls( &switchmotorPG ); @@ -585,7 +617,8 @@ static STATUS_T CmdSwitchMotorCreate( wAction_t action, coOrd pos ) { track_p trk; - LOG( log_switchmotor, 1, ("*** CmdSwitchMotorCreate(%08x,{%f,%f})\n",action,pos.x,pos.y)) + LOG( log_switchmotor, 1, ("*** CmdSwitchMotorCreate(%08x,{%f,%f})\n",action, + pos.x,pos.y)) switch (action & 0xFF) { case C_START: InfoMessage( _("Select a turnout") ); @@ -611,7 +644,6 @@ static STATUS_T CmdSwitchMotorCreate( wAction_t action, coOrd pos ) } #if 0 -extern BOOL_T inDescribeCmd; static STATUS_T CmdSwitchMotorEdit( wAction_t action, coOrd pos ) { @@ -665,7 +697,8 @@ static STATUS_T CmdSwitchMotorDelete( wAction_t action, coOrd pos ) } /* Confirm Delete SwitchMotor */ xx = GetswitchmotorData(btrk); - if ( NoticeMessage( _("Really delete switch motor %s?"), _("Yes"), _("No"), xx->name) ) { + if ( NoticeMessage( _("Really delete switch motor %s?"), _("Yes"), _("No"), + xx->name) ) { UndoStart( _("Delete Switch Motor"), "delete" ); DeleteTrack (btrk, FALSE); UndoEnd(); @@ -690,7 +723,8 @@ static STATUS_T CmdSwitchMotorDelete( wAction_t action, coOrd pos ) static STATUS_T CmdSwitchMotor (wAction_t action, coOrd pos ) { - LOG( log_switchmotor, 1, ("*** CmdSwitchMotor(%08x,{%f,%f})\n",action,pos.x,pos.y)) + LOG( log_switchmotor, 1, ("*** CmdSwitchMotor(%08x,{%f,%f})\n",action,pos.x, + pos.y)) switch (VP2L(commandContext)) { case SWITCHMOTOR_CREATE: return CmdSwitchMotorCreate(action,pos); @@ -703,51 +737,51 @@ static STATUS_T CmdSwitchMotor (wAction_t action, coOrd pos ) static void SwitchMotorEditOk ( void * junk ) { - switchmotorData_p xx; - track_p trk; - - LOG( log_switchmotor, 1, ("*** SwitchMotorEditOk()\n")) - ParamUpdate (&switchmotorEditPG ); - if ( switchmotorEditName[0]==0 ) { - NoticeMessage( _("Switch motor must have a name!") , _("Ok"), NULL); - return; - } - wDrawDelayUpdate( mainD.d, TRUE ); - UndoStart( _("Modify Switch Motor"), "Modify Switch Motor" ); - trk = switchmotorEditTrack; - xx = GetswitchmotorData( trk ); - xx->name = MyStrdup(switchmotorEditName); - xx->normal = MyStrdup(switchmotorEditNormal); - xx->reverse = MyStrdup(switchmotorEditReverse); - xx->pointsense = MyStrdup(switchmotorEditPointSense); - switchmotorDebug(trk); - UndoEnd(); - wHide( switchmotorEditW ); + switchmotorData_p xx; + track_p trk; + + LOG( log_switchmotor, 1, ("*** SwitchMotorEditOk()\n")) + ParamUpdate (&switchmotorEditPG ); + if ( switchmotorEditName[0]==0 ) { + NoticeMessage( _("Switch motor must have a name!"), _("Ok"), NULL); + return; + } + wDrawDelayUpdate( mainD.d, TRUE ); + UndoStart( _("Modify Switch Motor"), "Modify Switch Motor" ); + trk = switchmotorEditTrack; + xx = GetswitchmotorData( trk ); + xx->name = MyStrdup(switchmotorEditName); + xx->normal = MyStrdup(switchmotorEditNormal); + xx->reverse = MyStrdup(switchmotorEditReverse); + xx->pointsense = MyStrdup(switchmotorEditPointSense); + switchmotorDebug(trk); + UndoEnd(); + wHide( switchmotorEditW ); } static void EditSwitchMotor (track_p trk) { - switchmotorData_p xx = GetswitchmotorData(trk); - strncpy(switchmotorEditName,xx->name,STR_SHORT_SIZE); - strncpy(switchmotorEditNormal,xx->normal,STR_LONG_SIZE); - strncpy(switchmotorEditReverse,xx->reverse,STR_LONG_SIZE); - strncpy(switchmotorEditPointSense,xx->pointsense,STR_LONG_SIZE); - if (xx->turnout == NULL) switchmotorEditTonum = 0; - else switchmotorEditTonum = GetTrkIndex(xx->turnout); - switchmotorEditTrack = trk; - if ( !switchmotorEditW ) { - ParamRegister( &switchmotorEditPG ); - switchmotorEditW = ParamCreateDialog (&switchmotorEditPG, - MakeWindowTitle(_("Edit switch motor")), - _("Ok"), SwitchMotorEditOk, - wHide, TRUE, NULL, F_BLOCK, - NULL ); - } - ParamLoadControls( &switchmotorEditPG ); - sprintf( message, _("Edit switch motor %d"), GetTrkIndex(trk) ); - wWinSetTitle( switchmotorEditW, message ); - wShow (switchmotorEditW); + switchmotorData_p xx = GetswitchmotorData(trk); + strncpy(switchmotorEditName,xx->name,STR_SHORT_SIZE); + strncpy(switchmotorEditNormal,xx->normal,STR_LONG_SIZE); + strncpy(switchmotorEditReverse,xx->reverse,STR_LONG_SIZE); + strncpy(switchmotorEditPointSense,xx->pointsense,STR_LONG_SIZE); + if (xx->turnout == NULL) { switchmotorEditTonum = 0; } + else { switchmotorEditTonum = GetTrkIndex(xx->turnout); } + switchmotorEditTrack = trk; + if ( !switchmotorEditW ) { + ParamRegister( &switchmotorEditPG ); + switchmotorEditW = ParamCreateDialog (&switchmotorEditPG, + MakeWindowTitle(_("Edit switch motor")), + _("Ok"), SwitchMotorEditOk, + wHide, TRUE, NULL, F_BLOCK, + NULL ); + } + ParamLoadControls( &switchmotorEditPG ); + sprintf( message, _("Edit switch motor %d"), GetTrkIndex(trk) ); + wWinSetTitle( switchmotorEditW, message ); + wShow (switchmotorEditW); } static coOrd swmhiliteOrig, swmhiliteSize; @@ -755,70 +789,72 @@ static POS_T swmhiliteBorder; static wDrawColor swmhiliteColor = 0; static void DrawSWMotorTrackHilite( void ) { - if (swmhiliteColor==0) + if (swmhiliteColor==0) { swmhiliteColor = wDrawColorGray(87); - DrawRectangle( &tempD, swmhiliteOrig, swmhiliteSize, swmhiliteColor, DRAW_TRANSPARENT ); + } + DrawRectangle( &tempD, swmhiliteOrig, swmhiliteSize, swmhiliteColor, + DRAW_TRANSPARENT ); } static int SwitchmotorMgmProc ( int cmd, void * data ) { - track_p trk = (track_p) data; - switchmotorData_p xx = GetswitchmotorData(trk); - /*char msg[STR_SIZE];*/ - - switch ( cmd ) { - case CONTMGM_CAN_EDIT: - return TRUE; - break; - case CONTMGM_DO_EDIT: - EditSwitchMotor (trk); - /*inDescribeCmd = TRUE;*/ - /*DescribeTrack (trk, msg, sizeof msg );*/ - /*InfoMessage( msg );*/ - return TRUE; - break; - case CONTMGM_CAN_DELETE: - return TRUE; - break; - case CONTMGM_DO_DELETE: - DeleteTrack (trk, FALSE); - return TRUE; - break; - case CONTMGM_DO_HILIGHT: - if (xx->turnout != NULL && !xx->IsHilite) { - swmhiliteBorder = mainD.scale*0.1; - if ( swmhiliteBorder < trackGauge ) swmhiliteBorder = trackGauge; - GetBoundingBox( xx->turnout, &swmhiliteSize, &swmhiliteOrig ); - swmhiliteOrig.x -= swmhiliteBorder; - swmhiliteOrig.y -= swmhiliteBorder; - swmhiliteSize.x -= swmhiliteOrig.x-swmhiliteBorder; - swmhiliteSize.y -= swmhiliteOrig.y-swmhiliteBorder; - DrawSWMotorTrackHilite(); - xx->IsHilite = TRUE; - } - break; - case CONTMGM_UN_HILIGHT: - if (xx->turnout != NULL && xx->IsHilite) { - swmhiliteBorder = mainD.scale*0.1; - if ( swmhiliteBorder < trackGauge ) swmhiliteBorder = trackGauge; - GetBoundingBox( xx->turnout, &swmhiliteSize, &swmhiliteOrig ); - swmhiliteOrig.x -= swmhiliteBorder; - swmhiliteOrig.y -= swmhiliteBorder; - swmhiliteSize.x -= swmhiliteOrig.x-swmhiliteBorder; - swmhiliteSize.y -= swmhiliteOrig.y-swmhiliteBorder; - DrawSWMotorTrackHilite(); - xx->IsHilite = FALSE; - } - break; - case CONTMGM_GET_TITLE: - if (xx->turnout == NULL) { - sprintf( message, "\t%s\t%d", xx->name, 0); - } else { - sprintf( message, "\t%s\t%d", xx->name, GetTrkIndex(xx->turnout)); - } - break; - } - return FALSE; + track_p trk = (track_p) data; + switchmotorData_p xx = GetswitchmotorData(trk); + /*char msg[STR_SIZE];*/ + + switch ( cmd ) { + case CONTMGM_CAN_EDIT: + return TRUE; + break; + case CONTMGM_DO_EDIT: + EditSwitchMotor (trk); + /*inDescribeCmd = TRUE;*/ + /*DescribeTrack (trk, msg, sizeof msg );*/ + /*InfoMessage( msg );*/ + return TRUE; + break; + case CONTMGM_CAN_DELETE: + return TRUE; + break; + case CONTMGM_DO_DELETE: + DeleteTrack (trk, FALSE); + return TRUE; + break; + case CONTMGM_DO_HILIGHT: + if (xx->turnout != NULL && !xx->IsHilite) { + swmhiliteBorder = mainD.scale*0.1; + if ( swmhiliteBorder < trackGauge ) { swmhiliteBorder = trackGauge; } + GetBoundingBox( xx->turnout, &swmhiliteSize, &swmhiliteOrig ); + swmhiliteOrig.x -= swmhiliteBorder; + swmhiliteOrig.y -= swmhiliteBorder; + swmhiliteSize.x -= swmhiliteOrig.x-swmhiliteBorder; + swmhiliteSize.y -= swmhiliteOrig.y-swmhiliteBorder; + DrawSWMotorTrackHilite(); + xx->IsHilite = TRUE; + } + break; + case CONTMGM_UN_HILIGHT: + if (xx->turnout != NULL && xx->IsHilite) { + swmhiliteBorder = mainD.scale*0.1; + if ( swmhiliteBorder < trackGauge ) { swmhiliteBorder = trackGauge; } + GetBoundingBox( xx->turnout, &swmhiliteSize, &swmhiliteOrig ); + swmhiliteOrig.x -= swmhiliteBorder; + swmhiliteOrig.y -= swmhiliteBorder; + swmhiliteSize.x -= swmhiliteOrig.x-swmhiliteBorder; + swmhiliteSize.y -= swmhiliteOrig.y-swmhiliteBorder; + DrawSWMotorTrackHilite(); + xx->IsHilite = FALSE; + } + break; + case CONTMGM_GET_TITLE: + if (xx->turnout == NULL) { + sprintf( message, "\t%s\t%d", xx->name, 0); + } else { + sprintf( message, "\t%s\t%d", xx->name, GetTrkIndex(xx->turnout)); + } + break; + } + return FALSE; } //#include "bitmaps/switchmotor.xpm" @@ -826,20 +862,21 @@ static int SwitchmotorMgmProc ( int cmd, void * data ) //#include "bitmaps/switchmnew.xpm" //#include "bitmaps/switchmedit.xpm" //#include "bitmaps/switchmdel.xpm" -#include "bitmaps/switchm.xpm" +#include "bitmaps/switch-motor.xpm3" EXPORT void SwitchmotorMgmLoad( void ) { - track_p trk; - static wIcon_p switchmI = NULL; - - if ( switchmI == NULL) - switchmI = wIconCreatePixMap( switchm_xpm ); - - TRK_ITERATE(trk) { - if (GetTrkType(trk) != T_SWITCHMOTOR) continue; - ContMgmLoad( switchmI, SwitchmotorMgmProc, trk ); - } + track_p trk; + static wIcon_p switchmI = NULL; + + if ( switchmI == NULL) { + switchmI = wIconCreatePixMap( switch_motor_xpm3[iconSize] ); + } + + TRK_ITERATE(trk) { + if (GetTrkType(trk) != T_SWITCHMOTOR) { continue; } + ContMgmLoad( switchmI, SwitchmotorMgmProc, trk ); + } } EXPORT void InitCmdSwitchMotor( wMenu_p menu ) @@ -847,24 +884,25 @@ EXPORT void InitCmdSwitchMotor( wMenu_p menu ) switchmotorName[0] = '\0'; switchmotorNormal[0] = '\0'; switchmotorReverse[0] = '\0'; - switchmotorPointSense[0] = '\0'; - AddMenuButton( menu, CmdSwitchMotorCreate, "cmdSwitchMotorCreate", - _("Switch Motor"), wIconCreatePixMap( switchm_xpm ), - LEVEL0_50, IC_STICKY|IC_POPUP2, ACCL_SWITCHMOTOR1, - NULL ); + switchmotorPointSense[0] = '\0'; + AddMenuButton( menu, CmdSwitchMotorCreate, "cmdSwitchMotorCreate", + _("Switch Motor"), wIconCreatePixMap( switch_motor_xpm3[iconSize] ), + LEVEL0_50, IC_STICKY|IC_POPUP2, ACCL_SWITCHMOTOR1, + NULL ); ParamRegister( &switchmotorPG ); } EXPORT void CheckDeleteSwitchmotor(track_p t) { - track_p sm; - switchmotorData_p xx; - if (GetTrkType( t ) != T_TURNOUT) return; // SMs only on turnouts - - while ((sm = FindSwitchMotor( t ))) { //Cope with multiple motors for one Turnout! - xx = GetswitchmotorData (sm); - InfoMessage(_("Deleting Switch Motor %s"),xx->name); - DeleteTrack (sm, FALSE); - }; + track_p sm; + switchmotorData_p xx; + if (GetTrkType( t ) != T_TURNOUT) { return; } // SMs only on turnouts + + while ((sm = FindSwitchMotor( + t ))) { //Cope with multiple motors for one Turnout! + xx = GetswitchmotorData (sm); + InfoMessage(_("Deleting Switch Motor %s"),xx->name); + DeleteTrack (sm, FALSE); + }; } diff --git a/app/bin/ctext.c b/app/bin/ctext.c index 3ab301c..673e4f7 100644 --- a/app/bin/ctext.c +++ b/app/bin/ctext.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "cundo.h" @@ -28,7 +28,8 @@ #include "misc.h" #include "common-ui.h" -track_p NewText( wIndex_t index, coOrd p, ANGLE_T angle, char * text, CSIZE_T textSize, wDrawColor color, BOOL_T boxed ); +track_p NewText( wIndex_t index, coOrd p, ANGLE_T angle, char * text, + CSIZE_T textSize, wDrawColor color, BOOL_T boxed ); void LoadFontSizeList( wList_p, long ); void UpdateFontSizeList( long *, wList_p, wIndex_t ); @@ -42,43 +43,42 @@ static wMenu_p textPopupM; */ static struct { - STATE_T state; - CSIZE_T len; - coOrd cursPos0, cursPos1; - POS_T cursHeight; - POS_T textLen; - POS_T lastLineLen; - POS_T lastLineOffset; - coOrd pos; - ANGLE_T angle; - long size; - wIndex_t fontSizeInx; - char text[STR_HUGE_SIZE]; - wDrawColor color; - BOOL_T boxed; - } Dt; + STATE_T state; + CSIZE_T len; + coOrd cursPos0, cursPos1; + POS_T cursHeight; + POS_T textLen; + POS_T lastLineLen; + POS_T lastLineOffset; + coOrd pos; + ANGLE_T angle; + long size; + wIndex_t fontSizeInx; + char text[STR_HUGE_SIZE]; + wDrawColor color; + BOOL_T boxed; +} Dt; static char * boxLabels[] = { "", NULL }; static paramData_t textPLs[] = { #define textPD (textPLs[0]) - { PD_DROPLIST, &Dt.fontSizeInx, "fontsize", 0, NULL, N_("Font Size"), BL_EDITABLE }, + { PD_DROPLIST, &Dt.fontSizeInx, "fontsize", 0, NULL, N_("Font Size"), BL_EDITABLE }, #define colorPD (textPLs[1]) - { PD_COLORLIST, &Dt.color, "color", PDO_NORECORD, NULL, N_("Color") }, + { PD_COLORLIST, &Dt.color, "color", PDO_NORECORD, NULL, N_("Color") }, #define boxPD (textPLs[2]) - { PD_TOGGLE, &Dt.boxed, "boxed", 0, boxLabels, N_("Boxed"), 0 } - }; + { PD_TOGGLE, &Dt.boxed, "boxed", 0, boxLabels, N_("Boxed"), 0 } +}; static paramGroup_t textPG = { "text", 0, textPLs, COUNT( textPLs ) }; -enum TEXT_POSITION -{ +enum TEXT_POSITION { POSITION_TEXT = 0, SHOW_TEXT }; static void TextDlgUpdate( - paramGroup_p pg, - int inx, - void * context ) + paramGroup_p pg, + int inx, + void * context ) { coOrd size, lastline; @@ -100,7 +100,7 @@ static void TextDlgUpdate( Dt.cursPos0.x = Dt.cursPos1.x = Dt.pos.x+Dt.lastLineLen; Dt.cursPos1.y = Dt.pos.y+Dt.cursHeight+Dt.lastLineOffset; } - break; + break; } } @@ -115,7 +115,7 @@ static STATUS_T CmdText( wAction_t action, coOrd pos ) switch (action & 0xFF) { case C_START: - Dt.state = POSITION_TEXT; + Dt.state = POSITION_TEXT; Dt.cursPos0 = Dt.cursPos1 = zero; Dt.len = 0; Dt.textLen = 0; @@ -123,8 +123,7 @@ static STATUS_T CmdText( wAction_t action, coOrd pos ) Dt.lastLineLen = 0; Dt.lastLineOffset = 0; - if (textPD.control == NULL) - { + if (textPD.control == NULL) { ParamCreateControls(&textPG, TextDlgUpdate); LoadFontSizeList((wList_p)textPD.control, Dt.size); ParamRegister(&textPG); @@ -140,11 +139,11 @@ static STATUS_T CmdText( wAction_t action, coOrd pos ) controls[0] = textPD.control; controls[1] = colorPD.control; - controls[2] = boxPD.control; - controls[3] = 0; + controls[2] = boxPD.control; + controls[3] = 0; labels[0] = N_("Font Size"); - labels[1] = N_("Color"); - labels[2] = N_("Boxed"); + labels[1] = N_("Color"); + labels[2] = N_("Boxed"); InfoSubstituteControls( controls, labels ); return C_CONTINUE; break; @@ -154,17 +153,18 @@ static STATUS_T CmdText( wAction_t action, coOrd pos ) Dt.pos = pos; Dt.cursPos0.y = Dt.cursPos1.y = pos.y + Dt.lastLineOffset; Dt.cursPos0.x = Dt.cursPos1.x = pos.x + Dt.lastLineLen; - DrawTextSize(&mainD, "Aquilp", NULL, Dt.size, TRUE, &size); //In case fontsize change + DrawTextSize(&mainD, "Aquilp", NULL, Dt.size, TRUE, + &size); //In case fontsize change Dt.cursHeight = size.y; Dt.cursPos1.y += Dt.cursHeight; - Dt.state = SHOW_TEXT; + Dt.state = SHOW_TEXT; return C_CONTINUE; case C_MOVE: Dt.pos = pos; Dt.cursPos0.y = Dt.cursPos1.y = pos.y + Dt.lastLineOffset; Dt.cursPos0.x = Dt.cursPos1.x = pos.x + Dt.lastLineLen; Dt.cursPos1.y += Dt.cursHeight; - return C_CONTINUE; + return C_CONTINUE; case C_UP: return C_CONTINUE; case C_TEXT: @@ -172,7 +172,7 @@ static STATUS_T CmdText( wAction_t action, coOrd pos ) NoticeMessage( MSG_SEL_POS_FIRST, _("Ok"), NULL ); return C_CONTINUE; } - + c = (unsigned char)(action >> 8); switch (c) { case '\b': @@ -192,7 +192,8 @@ static STATUS_T CmdText( wAction_t action, coOrd pos ) break; case '\015': UndoStart( _("Create Text"), "newText - CR" ); - t = NewText( 0, Dt.pos, Dt.angle, Dt.text, (CSIZE_T)Dt.size, Dt.color, Dt.boxed ); + t = NewText( 0, Dt.pos, Dt.angle, Dt.text, (CSIZE_T)Dt.size, Dt.color, + Dt.boxed ); UndoEnd(); DrawNewTrack(t); Dt.state = POSITION_TEXT; @@ -210,21 +211,23 @@ static STATUS_T CmdText( wAction_t action, coOrd pos ) InfoMessage("Text too long - truncated"); wBeep(); } - DrawMultiLineTextSize( &mainD, Dt.text, NULL, Dt.size, TRUE, &size, &lastline); + DrawMultiLineTextSize( &mainD, Dt.text, NULL, Dt.size, TRUE, &size, &lastline); Dt.textLen = size.x; Dt.lastLineLen = lastline.x; Dt.lastLineOffset = lastline.y; Dt.cursPos0.x = Dt.cursPos1.x = Dt.pos.x + Dt.lastLineLen; Dt.cursPos0.y = Dt.cursPos1.y = Dt.pos.y + Dt.lastLineOffset; POS_T descent, ascent; - DrawTextSize2(&mainD, "Aquilp", NULL, Dt.size, TRUE, &size, &descent, &ascent); //In case fontsize change + DrawTextSize2(&mainD, "Aquilp", NULL, Dt.size, TRUE, &size, &descent, + &ascent); //In case fontsize change Dt.cursHeight = size.y; Dt.cursPos0.y -=descent; Dt.cursPos1.y +=Dt.cursHeight; return C_CONTINUE; case C_REDRAW: DrawLine( &tempD, Dt.cursPos0, Dt.cursPos1, 0, Dt.color ); - DrawMultiString(&tempD, Dt.pos, Dt.text, NULL, (FONTSIZE_T)Dt.size, Dt.color, 0.0, NULL, NULL, Dt.boxed ); + DrawMultiString(&tempD, Dt.pos, Dt.text, NULL, (FONTSIZE_T)Dt.size, Dt.color, + 0.0, NULL, NULL, Dt.boxed ); return C_CONTINUE; case C_CANCEL: if (Dt.state != POSITION_TEXT) { @@ -237,7 +240,8 @@ static STATUS_T CmdText( wAction_t action, coOrd pos ) Dt.state = POSITION_TEXT; if (Dt.len) { UndoStart( _("Create Text"), "newText - OK" ); - t = NewText( 0, Dt.pos, Dt.angle, Dt.text, (CSIZE_T)Dt.size, Dt.color, Dt.boxed ); + t = NewText( 0, Dt.pos, Dt.angle, Dt.text, (CSIZE_T)Dt.size, Dt.color, + Dt.boxed ); UndoEnd(); DrawNewTrack(t); } @@ -246,10 +250,11 @@ static STATUS_T CmdText( wAction_t action, coOrd pos ) return C_TERMINATE; case C_FINISH: - if (Dt.state != POSITION_TEXT && Dt.len > 0) - CmdText( C_OK, pos ); - else + if (Dt.state != POSITION_TEXT && Dt.len > 0) { + CmdText( C_OK, pos ); + } else { CmdText( C_CANCEL, pos ); + } return C_TERMINATE; case C_CMDMENU: @@ -261,15 +266,17 @@ static STATUS_T CmdText( wAction_t action, coOrd pos ) } -#include "bitmaps/text.xpm" +#include "bitmaps/text.xpm3" void InitCmdText( wMenu_p menu ) { - AddMenuButton( menu, CmdText, "cmdText", _("Text"), wIconCreatePixMap(text_xpm[iconSize]), LEVEL0_50, IC_STICKY|IC_CMDMENU|IC_POPUP2, ACCL_TEXT, NULL ); + AddMenuButton( menu, CmdText, "cmdText", _("Text"), + wIconCreatePixMap(text_xpm3[iconSize]), LEVEL0_50, + IC_STICKY|IC_CMDMENU|IC_POPUP2, ACCL_TEXT, NULL ); textPopupM = MenuRegister( "Text Font" ); wMenuPushCreate( textPopupM, "", _("Fonts..."), 0, SelectFont, NULL ); Dt.size = (CSIZE_T)wSelectedFontSize(); - Dt.color = wDrawColorBlack; + Dt.color = wDrawColorBlack; } void InitTrkText( void ) diff --git a/app/bin/ctie.c b/app/bin/ctie.c new file mode 100644 index 0000000..6881bc4 --- /dev/null +++ b/app/bin/ctie.c @@ -0,0 +1,53 @@ +/** \file ctie.c + * TIE + */ + +/* XTrkCad - Model Railroad CAD + * Copyright (C) 2005 Dave Bullis + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +//#include "cselect.h" +//#include "custom.h" +//#include "fileio.h" +#include "layout.h" +//#include "param.h" +//#include "paths.h" +#include "track.h" +//#include "include/paramfile.h" +#include "common-ui.h" + +static int log_tieList; + +/**************************************************************************** +* +* TIE DATA +* +*/ + +/** +* @brief Default tie data for a scale in tieLength, tieWidth, tieSpacing +*/ +EXPORT void GetDefaultTieData( SCALEINX_T inx, tieData_p tieData ) +{ + SCALEDESCINX_T scaleInx; + GAUGEINX_T gaugeInx; + GetScaleGauge( inx, &scaleInx, &gaugeInx ); + + tieData->length = (96.0-54.0) / GetScaleRatio(inx) + GetScaleTrackGauge(inx); + tieData->width = 16.0 / GetScaleRatio(inx); + tieData->spacing = 2 * (tieData->width); +} diff --git a/app/bin/ctodesgn.c b/app/bin/ctodesgn.c index ea124cf..1b50d91 100644 --- a/app/bin/ctodesgn.c +++ b/app/bin/ctodesgn.c @@ -18,7 +18,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "ccurve.h" @@ -29,13 +29,15 @@ #include "param.h" #include "track.h" +#include "trkendpt.h" #include "ccornu.h" #include "cbezier.h" #include "misc.h" #include "common-ui.h" +static int log_cornuturnoutdesigner; + dynArr_t tempSegs_da; -dynArr_t tempEndPts_da; char tempCustom[4096]; #define TURNOUTDESIGNER "CTURNOUT DESIGNER" @@ -74,35 +76,37 @@ dynArr_t tempSegs_da; typedef struct { - struct { - wWinPix_t x, y; - } pos; - int index; - char * winLabel; - char * printLabel; - enum { Dim_e, Frog_e, Angle_e, Rad_e } mode; - } toDesignFloat_t; + struct { + wWinPix_t x, y; + } pos; + int index; + char * winLabel; + char * printLabel; + enum { Dim_e, Frog_e, Angle_e, Rad_e } mode; +} toDesignFloat_t; typedef struct { - PATHPTR_T paths; - char * segOrder; - } toDesignSchema_t; + PATHPTR_T paths; + char * segOrder; +} toDesignSchema_t; typedef struct { - int type; - char * label; - int strCnt; - int lineCnt; - wLines_t * lines; - int floatCnt; - toDesignFloat_t * floats; - toDesignSchema_t * paths; - int angleModeCnt; - wLine_p lineC; - wBool_t slipmode; - } toDesignDesc_t; + int type; + char * label; + int strCnt; + int lineCnt; + wLines_t * lines; + int floatCnt; + toDesignFloat_t * floats; + toDesignSchema_t * paths; + int angleModeCnt; + wLine_p lineC; + wBool_t slipmode; +} toDesignDesc_t; +#ifndef MKTURNOUT static wWin_p newTurnW; +#endif static FLOAT_T newTurnRad0; static FLOAT_T newTurnAngle0; @@ -135,27 +139,31 @@ static char newTurnManufacturer[STR_SIZE]; static char *newTurnAngleModeLabels[] = { N_("Frog #"), N_("Degrees"), NULL }; static char *newTurnSlipModeLabels[] = { N_("Dual Path"), N_("Quad Path"), NULL }; static DIST_T newTurnRoadbedWidth; -static long newTurnRoadbedLineWidth = 0; -static wDrawColor roadbedColor; +static LWIDTH_T newTurnRoadbedLineWidth = 0; +static wDrawColor newTurnRoadbedColor; static DIST_T newTurnTrackGauge; static char * newTurnScaleName; static paramFloatRange_t r0d001_10000 = { 0.001, 10000, 80 }; static paramFloatRange_t r0d300_10000 = { 0.300, 10000, 80 }; -static paramFloatRange_t r0_10000 = { 0, 10000, 80 }; +//static paramFloatRange_t r0_10000 = { 0, 10000, 80 }; static paramFloatRange_t r_10000_10000 = { -1000, 10000, 80 }; static paramFloatRange_t r0d001_90 = { 0.001, 90, 80 }; -static paramFloatRange_t r_90_90 = { -90, 90, 80 }; static paramFloatRange_t r0_100 = { 0, 100, 80 }; static paramIntegerRange_t i0_100 = { 0, 100, 40 }; static void NewTurnOk( void * context ); +#ifndef MKTURNOUT +static paramFloatRange_t r_90_90 = { -90, 90, 80 }; static void ShowTurnoutDesigner( void * context ); +#endif static coOrd points[20]; +#ifndef MKTURNOUT static coOrd end_points[20]; static coOrd end_centers[20]; static double end_arcs[20]; static double end_angles[20]; +#endif static DIST_T radii[10]; static double angles[10]; @@ -199,23 +207,22 @@ static paramData_t turnDesignPLs[] = { { PD_STRING, &newTurnRightPartno, "partno2", PDO_DLGHORZ | PDO_NOTBLANK, NULL, N_(" #"),0, 0, sizeof(newTurnRightPartno)}, { PD_FLOAT, &newTurnRoadbedWidth, "roadbedWidth", PDO_DIM, &r0_100, N_("Roadbed Width") }, { PD_LONG, &newTurnRoadbedLineWidth, "roadbedLineWidth", PDO_DLGHORZ, &i0_100, N_("Line Width") }, - { PD_COLORLIST, &roadbedColor, "color", PDO_DLGHORZ|PDO_DLGBOXEND, NULL, N_("Color") }, + { PD_COLORLIST, &newTurnRoadbedColor, "color", PDO_DLGHORZ|PDO_DLGBOXEND, NULL, N_("Color") }, { PD_BUTTON, NewTurnOk, "done", PDO_DLGCMDBUTTON, NULL, N_("Ok") }, { PD_BUTTON, wPrintSetup, "printsetup", 0, NULL, N_("Print Setup") }, #define I_TOANGMODE (28) { PD_RADIO, &newTurnAngleMode, "angleMode", 0, newTurnAngleModeLabels }, #define I_TOSLIPMODE (29) { PD_RADIO, &newTurnSlipMode, "slipMode", 0, newTurnSlipModeLabels } - }; +}; #ifndef MKTURNOUT static paramGroup_t turnDesignPG = { "turnoutNew", 0, turnDesignPLs, COUNT( turnDesignPLs ) }; static turnoutInfo_t * customTurnout1, * customTurnout2; static BOOL_T includeNontrackSegments; -#endif -#ifdef MKTURNOUT +#else int doCustomInfoLine = 1; int doRoadBed = 0; char specialLine[256]; @@ -230,531 +237,619 @@ static toDesignDesc_t * curDesign; static wLines_t RegLines[] = { #include "toreg.lin" - }; +}; static toDesignFloat_t RegFloats[] = { -{ { 175, 10 }, I_TOLENGTH+0, N_("Length"), N_("Diverging Length"), Dim_e }, -{ { 400, 28 }, I_TOANGLE+0, N_("Angle"), N_("Diverging Angle"), Frog_e }, -{ { 325, 68 }, I_TOOFFSET+0, N_("Offset"), N_("Diverging Offset"), Dim_e }, -{ { 100, 120 }, I_TOLENGTH+1, N_("Length"), N_("Overall Length"), Dim_e }, - }; + { { 175, 10 }, I_TOLENGTH+0, N_("Length"), N_("Diverging Length"), Dim_e }, + { { 400, 28 }, I_TOANGLE+0, N_("Angle"), N_("Diverging Angle"), Frog_e }, + { { 325, 68 }, I_TOOFFSET+0, N_("Offset"), N_("Diverging Offset"), Dim_e }, + { { 100, 120 }, I_TOLENGTH+1, N_("Length"), N_("Overall Length"), Dim_e }, +}; static signed char RegPaths[] = { - 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 2, 0, 0, - 'R', 'e', 'v', 'e', 'r', 's', 'e', 0, 1, 3, 4, 0, 0, 0 }; + 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 2, 0, 0, + 'R', 'e', 'v', 'e', 'r', 's', 'e', 0, 1, 3, 4, 0, 0, 0 +}; static toDesignSchema_t RegSchema = { - RegPaths, - "030" "310" "341" "420" }; + RegPaths, + "030" "310" "341" "420" +}; static toDesignDesc_t RegDesc = { - NTO_REGULAR, - N_("Regular Turnout"), - 2, - COUNT( RegLines ), RegLines, - COUNT( RegFloats ), RegFloats, - &RegSchema, 1 }; + NTO_REGULAR, + N_("Regular Turnout"), + 2, + COUNT( RegLines ), RegLines, + COUNT( RegFloats ), RegFloats, + &RegSchema, 1 +}; static wLines_t CrvLines[] = { #include "tocrv.lin" - }; +}; static toDesignFloat_t CrvFloats[] = { -{ { 175, 10 }, I_TOLENGTH+0, N_("Length"), N_("Inner Length"), Dim_e }, -{ { 375, 12 }, I_TOANGLE+0, N_("Angle"), N_("Inner Angle"), Frog_e }, -{ { 375, 34 }, I_TOOFFSET+0, N_("Offset"), N_("Inner Offset"), Dim_e }, -{ { 400, 62 }, I_TOANGLE+1, N_("Angle"), N_("Outer Angle"), Frog_e }, -{ { 400, 84 }, I_TOOFFSET+1, N_("Offset"), N_("Outer Offset"), Dim_e }, -{ { 175, 120 }, I_TOLENGTH+1, N_("Length"), N_("Outer Length"), Dim_e } }; + { { 175, 10 }, I_TOLENGTH+0, N_("Length"), N_("Inner Length"), Dim_e }, + { { 375, 12 }, I_TOANGLE+0, N_("Angle"), N_("Inner Angle"), Frog_e }, + { { 375, 34 }, I_TOOFFSET+0, N_("Offset"), N_("Inner Offset"), Dim_e }, + { { 400, 62 }, I_TOANGLE+1, N_("Angle"), N_("Outer Angle"), Frog_e }, + { { 400, 84 }, I_TOOFFSET+1, N_("Offset"), N_("Outer Offset"), Dim_e }, + { { 175, 120 }, I_TOLENGTH+1, N_("Length"), N_("Outer Length"), Dim_e } +}; static signed char Crv1Paths[] = { - 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 4, 5, 0, 0, - 'R', 'e', 'v', 'e', 'r', 's', 'e', 0, 1, 2, 3, 0, 0, 0 }; + 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 4, 5, 0, 0, + 'R', 'e', 'v', 'e', 'r', 's', 'e', 0, 1, 2, 3, 0, 0, 0 +}; static toDesignSchema_t Crv1Schema = { - Crv1Paths, - "030" "341" "410" "362" "620" }; + Crv1Paths, + "030" "341" "410" "362" "620" +}; static signed char Crv2Paths[] = { - 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 4, 5, 0, 0, - 'R', 'e', 'v', 'e', 'r', 's', 'e', 0, 1, 6, 2, 3, 0, 0, 0 }; + 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 4, 5, 0, 0, + 'R', 'e', 'v', 'e', 'r', 's', 'e', 0, 1, 6, 2, 3, 0, 0, 0 +}; static toDesignSchema_t Crv2Schema = { - Crv2Paths, - "050" "341" "410" "562" "620" "530" }; + Crv2Paths, + "050" "341" "410" "562" "620" "530" +}; static signed char Crv3Paths[] = { - 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 6, 4, 5, 0, 0, - 'R', 'e', 'v', 'e', 'r', 's', 'e', 0, 1, 2, 3, 0, 0, 0 }; + 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 6, 4, 5, 0, 0, + 'R', 'e', 'v', 'e', 'r', 's', 'e', 0, 1, 2, 3, 0, 0, 0 +}; static toDesignSchema_t Crv3Schema = { - Crv3Paths, - "030" "341" "410" "562" "620" "350" }; + Crv3Paths, + "030" "341" "410" "562" "620" "350" +}; static toDesignDesc_t CrvDesc = { - NTO_CURVED, - N_("Curved Turnout"), - 2, - COUNT( CrvLines ), CrvLines, - COUNT( CrvFloats ), CrvFloats, - &Crv1Schema, 1 }; + NTO_CURVED, + N_("Curved Turnout"), + 2, + COUNT( CrvLines ), CrvLines, + COUNT( CrvFloats ), CrvFloats, + &Crv1Schema, 1 +}; +#ifndef MKTURNOUT static wLines_t CornuLines[] = { #include "tocornu.lin" - }; +}; static toDesignFloat_t CornuFloats[] = { -{ { 175, 10 }, I_TOLENGTH+0, N_("Length"), N_("Inner Length"), Dim_e }, -{ { 375, 0 }, I_TOANGLE+0, N_("Angle"), N_("Inner Angle"), Frog_e }, -{ { 375, 22 }, I_TOOFFSET+0, N_("Offset"), N_("Inner Offset"), Dim_e }, -{ { 375, 44 }, I_TORAD+0, N_("Radius"), N_("Inner Radius"), Dim_e }, -{ { 400, 62 }, I_TOANGLE+1, N_("Angle"), N_("Outer Angle"), Frog_e }, -{ { 400, 84 }, I_TOOFFSET+1, N_("Offset"), N_("Outer Offset"), Dim_e }, -{ { 400, 106 }, I_TORAD+1, N_("Radius"), N_("Outer Radius"), Dim_e }, -{ { 175, 120 }, I_TOLENGTH+1, N_("Length"), N_("Outer Length"), Dim_e }, -{ { 50, 90 }, I_TORAD+2, N_("Radius"), N_("Toe Radius"), Dim_e }, -{ { 50, 40 }, I_TOTOELENGTH+0, N_("Length"), N_("Toe Length"), Dim_e } }; + { { 175, 10 }, I_TOLENGTH+0, N_("Length"), N_("Inner Length"), Dim_e }, + { { 375, 0 }, I_TOANGLE+0, N_("Angle"), N_("Inner Angle"), Frog_e }, + { { 375, 22 }, I_TOOFFSET+0, N_("Offset"), N_("Inner Offset"), Dim_e }, + { { 375, 44 }, I_TORAD+0, N_("Radius"), N_("Inner Radius"), Dim_e }, + { { 400, 62 }, I_TOANGLE+1, N_("Angle"), N_("Outer Angle"), Frog_e }, + { { 400, 84 }, I_TOOFFSET+1, N_("Offset"), N_("Outer Offset"), Dim_e }, + { { 400, 106 }, I_TORAD+1, N_("Radius"), N_("Outer Radius"), Dim_e }, + { { 175, 120 }, I_TOLENGTH+1, N_("Length"), N_("Outer Length"), Dim_e }, + { { 50, 90 }, I_TORAD+2, N_("Radius"), N_("Toe Radius"), Dim_e }, + { { 50, 40 }, I_TOTOELENGTH+0, N_("Length"), N_("Toe Length"), Dim_e } +}; static signed char CornuPaths[] = { - 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 4, 0, 0, 0, - 'R', 'e', 'v', 'e', 'r', 's', 'e', 0, 1, 2, 0, 0, 0, 0 }; + 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 4, 0, 0, 0, + 'R', 'e', 'v', 'e', 'r', 's', 'e', 0, 1, 2, 0, 0, 0, 0 +}; static toDesignSchema_t CornuSchema = { - CornuPaths, - "033" "343" "413" }; + CornuPaths, + "033" "343" "413" +}; static toDesignDesc_t CornuDesc = { - NTO_CORNU, - N_("Cornu Curved Turnout"), - 2, - COUNT( CornuLines ), CornuLines, - COUNT( CornuFloats ), CornuFloats, - &CornuSchema, 1 }; + NTO_CORNU, + N_("Cornu Curved Turnout"), + 2, + COUNT( CornuLines ), CornuLines, + COUNT( CornuFloats ), CornuFloats, + &CornuSchema, 1 +}; +#endif static wLines_t WyeLines[] = { #include "towye.lin" - }; +}; static toDesignFloat_t WyeFloats[] = { -{ { 175, 10 }, I_TOLENGTH+0, N_("Length"), N_("Left Length"), Dim_e }, -{ { 400, 28 }, I_TOANGLE+0, N_("Angle"), N_("Left Angle"), Frog_e }, -{ { 325, 68 }, I_TOOFFSET+0, N_("Offset"), N_("Left Offset"), Dim_e }, -{ { 325, 115 }, I_TOOFFSET+1, N_("Offset"), N_("Right Offset"), Dim_e }, -{ { 400, 153 }, I_TOANGLE+1, N_("Angle"), N_("Right Angle"), Frog_e }, -{ { 175, 170 }, I_TOLENGTH+1, N_("Length"), N_("Right Length"), Dim_e }, - }; + { { 175, 10 }, I_TOLENGTH+0, N_("Length"), N_("Left Length"), Dim_e }, + { { 400, 28 }, I_TOANGLE+0, N_("Angle"), N_("Left Angle"), Frog_e }, + { { 325, 68 }, I_TOOFFSET+0, N_("Offset"), N_("Left Offset"), Dim_e }, + { { 325, 115 }, I_TOOFFSET+1, N_("Offset"), N_("Right Offset"), Dim_e }, + { { 400, 153 }, I_TOANGLE+1, N_("Angle"), N_("Right Angle"), Frog_e }, + { { 175, 170 }, I_TOLENGTH+1, N_("Length"), N_("Right Length"), Dim_e }, +}; static signed char Wye1Paths[] = { - 'L', 'e', 'f', 't', 0, 1, 2, 3, 0, 0, - 'R', 'i', 'g', 'h', 't', 0, 1, 4, 5, 0, 0, 0 }; + 'L', 'e', 'f', 't', 0, 1, 2, 3, 0, 0, + 'R', 'i', 'g', 'h', 't', 0, 1, 4, 5, 0, 0, 0 +}; static toDesignSchema_t Wye1Schema = { - Wye1Paths, - "030" "341" "410" "362" "620" }; + Wye1Paths, + "030" "341" "410" "362" "620" +}; static signed char Wye2Paths[] = { - 'L', 'e', 'f', 't', 0, 1, 2, 3, 4, 0, 0, - 'R', 'i', 'g', 'h', 't', 0, 1, 5, 6, 0, 0, 0 }; + 'L', 'e', 'f', 't', 0, 1, 2, 3, 4, 0, 0, + 'R', 'i', 'g', 'h', 't', 0, 1, 5, 6, 0, 0, 0 +}; static toDesignSchema_t Wye2Schema = { - Wye2Paths, - "050" "530" "341" "410" "562" "620" }; + Wye2Paths, + "050" "530" "341" "410" "562" "620" +}; static signed char Wye3Paths[] = { - 'L', 'e', 'f', 't', 0, 1, 2, 3, 0, 0, - 'R', 'i', 'g', 'h', 't', 0, 1, 4, 5, 6, 0, 0, 0 }; + 'L', 'e', 'f', 't', 0, 1, 2, 3, 0, 0, + 'R', 'i', 'g', 'h', 't', 0, 1, 4, 5, 6, 0, 0, 0 +}; static toDesignSchema_t Wye3Schema = { - Wye3Paths, - "030" "341" "410" "350" "562" "620" }; + Wye3Paths, + "030" "341" "410" "350" "562" "620" +}; static toDesignDesc_t WyeDesc = { - NTO_WYE, - N_("Wye Turnout"), - 1, - COUNT( WyeLines ), WyeLines, - COUNT( WyeFloats ), WyeFloats, - NULL, 1 }; + NTO_WYE, + N_("Wye Turnout"), + 1, + COUNT( WyeLines ), WyeLines, + COUNT( WyeFloats ), WyeFloats, + NULL, 1 +}; +#ifndef MKTURNOUT static wLines_t CornuWyeLines[] = { #include "tocornuwye.lin" - }; +}; static toDesignFloat_t CornuWyeFloats[] = { -{ { 175, 10 }, I_TOLENGTH+0, N_("Length"), N_("Left Length"), Dim_e }, -{ { 400, 28 }, I_TOANGLE+0, N_("Angle"), N_("Left Angle"), Frog_e }, -{ { 400, 48 }, I_TOOFFSET+0, N_("Offset"), N_("Left Offset"), Dim_e }, -{ { 400, 68 }, I_TORAD+0, N_("Radius"), N_("Left Radius"), Dim_e }, -{ { 400, 108 }, I_TORAD+1, N_("Radius"), N_("Right Radius"), Dim_e }, -{ { 400, 128 }, I_TOOFFSET+1, N_("Offset"), N_("Right Offset"), Dim_e }, -{ { 400, 148 }, I_TOANGLE+1, N_("Angle"), N_("Right Angle"), Frog_e }, -{ { 175, 170 }, I_TOLENGTH+1, N_("Length"), N_("Right Length"), Dim_e }, -{ { 80, 48 }, I_TOTOELENGTH+0, N_("Length"), N_("Toe Length"), Dim_e }, -{ { 80, 28 }, I_TORAD+2, N_("Radius"), N_("Toe Radius"), Dim_e }, - }; + { { 175, 10 }, I_TOLENGTH+0, N_("Length"), N_("Left Length"), Dim_e }, + { { 400, 28 }, I_TOANGLE+0, N_("Angle"), N_("Left Angle"), Frog_e }, + { { 400, 48 }, I_TOOFFSET+0, N_("Offset"), N_("Left Offset"), Dim_e }, + { { 400, 68 }, I_TORAD+0, N_("Radius"), N_("Left Radius"), Dim_e }, + { { 400, 108 }, I_TORAD+1, N_("Radius"), N_("Right Radius"), Dim_e }, + { { 400, 128 }, I_TOOFFSET+1, N_("Offset"), N_("Right Offset"), Dim_e }, + { { 400, 148 }, I_TOANGLE+1, N_("Angle"), N_("Right Angle"), Frog_e }, + { { 175, 170 }, I_TOLENGTH+1, N_("Length"), N_("Right Length"), Dim_e }, + { { 80, 48 }, I_TOTOELENGTH+0, N_("Length"), N_("Toe Length"), Dim_e }, + { { 80, 28 }, I_TORAD+2, N_("Radius"), N_("Toe Radius"), Dim_e }, +}; static signed char CornuWyePaths[] = { - 'L', 'e', 'f', 't', 0, 1, 2, 3, 0, 0, - 'R', 'i', 'g', 'h', 't', 0, 1, 4, 5, 0, 0, 0 }; /* Not Used */ + 'L', 'e', 'f', 't', 0, 1, 2, 3, 0, 0, + 'R', 'i', 'g', 'h', 't', 0, 1, 4, 5, 0, 0, 0 +}; /* Not Used */ static toDesignSchema_t CornuWyeSchema = { - CornuWyePaths, - "030" "341" "410" "362" "620" }; /* Not Used */ + CornuWyePaths, + "030" "341" "410" "362" "620" +}; /* Not Used */ static toDesignDesc_t CornuWyeDesc = { - NTO_CORNUWYE, - N_("Cornu Wye Turnout"), - 1, - COUNT( CornuWyeLines ), CornuWyeLines, - COUNT( CornuWyeFloats ), CornuWyeFloats, - NULL, 1 }; + NTO_CORNUWYE, + N_("Cornu Wye Turnout"), + 1, + COUNT( CornuWyeLines ), CornuWyeLines, + COUNT( CornuWyeFloats ), CornuWyeFloats, + NULL, 1 +}; +#endif static wLines_t ThreewayLines[] = { #include "to3way.lin" - }; +}; static toDesignFloat_t ThreewayFloats[] = { -{ { 175, 10 }, I_TOLENGTH+0, N_("Length"), N_("Left Length"), Dim_e }, -{ { 400, 28 }, I_TOANGLE+0, N_("Angle"), N_("Left Angle"), Frog_e }, -{ { 325, 68 }, I_TOOFFSET+0, N_("Offset"), N_("Left Offset"), Dim_e }, -{ { 100, 90 }, I_TOLENGTH+2, N_("Length"), N_("Length"), Dim_e }, -{ { 325, 115 }, I_TOOFFSET+1, N_("Offset"), N_("Right Offset"), Dim_e }, -{ { 400, 153 }, I_TOANGLE+1, N_("Angle"), N_("Right Angle"), Frog_e }, -{ { 175, 170 }, I_TOLENGTH+1, N_("Length"), N_("Right Length"), Dim_e }, - }; + { { 175, 10 }, I_TOLENGTH+0, N_("Length"), N_("Left Length"), Dim_e }, + { { 400, 28 }, I_TOANGLE+0, N_("Angle"), N_("Left Angle"), Frog_e }, + { { 325, 68 }, I_TOOFFSET+0, N_("Offset"), N_("Left Offset"), Dim_e }, + { { 100, 90 }, I_TOLENGTH+2, N_("Length"), N_("Length"), Dim_e }, + { { 325, 115 }, I_TOOFFSET+1, N_("Offset"), N_("Right Offset"), Dim_e }, + { { 400, 153 }, I_TOANGLE+1, N_("Angle"), N_("Right Angle"), Frog_e }, + { { 175, 170 }, I_TOLENGTH+1, N_("Length"), N_("Right Length"), Dim_e }, +}; static signed char Tri1Paths[] = { - 'L', 'e', 'f', 't', 0, 1, 2, 3, 0, 0, - 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 6, 0, 0, - 'R', 'i', 'g', 'h', 't', 0, 1, 4, 5, 0, 0, 0 }; + 'L', 'e', 'f', 't', 0, 1, 2, 3, 0, 0, + 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 6, 0, 0, + 'R', 'i', 'g', 'h', 't', 0, 1, 4, 5, 0, 0, 0 +}; static toDesignSchema_t Tri1Schema = { - Tri1Paths, - "030" "341" "410" "362" "620" "370" }; + Tri1Paths, + "030" "341" "410" "362" "620" "370" +}; static signed char Tri2Paths[] = { - 'L', 'e', 'f', 't', 0, 1, 2, 3, 4, 0, 0, - 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 2, 7, 0, 0, - 'R', 'i', 'g', 'h', 't', 0, 1, 5, 6, 0, 0, 0 }; + 'L', 'e', 'f', 't', 0, 1, 2, 3, 4, 0, 0, + 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 2, 7, 0, 0, + 'R', 'i', 'g', 'h', 't', 0, 1, 5, 6, 0, 0, 0 +}; static toDesignSchema_t Tri2Schema = { - Tri2Paths, - "050" "530" "341" "410" "562" "620" "370" }; + Tri2Paths, + "050" "530" "341" "410" "562" "620" "370" +}; static signed char Tri3Paths[] = { - 'L', 'e', 'f', 't', 0, 1, 2, 3, 0, 0, - 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 4, 7, 0, 0, - 'R', 'i', 'g', 'h', 't', 0, 1, 4, 5, 6, 0, 0, 0 }; + 'L', 'e', 'f', 't', 0, 1, 2, 3, 0, 0, + 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 4, 7, 0, 0, + 'R', 'i', 'g', 'h', 't', 0, 1, 4, 5, 6, 0, 0, 0 +}; static toDesignSchema_t Tri3Schema = { - Tri3Paths, - "030" "341" "410" "350" "562" "620" "570" }; + Tri3Paths, + "030" "341" "410" "350" "562" "620" "570" +}; static toDesignDesc_t ThreewayDesc = { - NTO_3WAY, - N_("3-way Turnout"), - 1, - COUNT( ThreewayLines ), ThreewayLines, - COUNT( ThreewayFloats ), ThreewayFloats, - NULL, 1 }; + NTO_3WAY, + N_("3-way Turnout"), + 1, + COUNT( ThreewayLines ), ThreewayLines, + COUNT( ThreewayFloats ), ThreewayFloats, + NULL, 1 +}; +#ifndef MKTURNOUT static wLines_t CornuThreewayLines[] = { #include "tocornu3way.lin" - }; +}; static toDesignFloat_t CornuThreewayFloats[] = { -{ { 175, 10 }, I_TOLENGTH+0, N_("Length"), N_("Left Length"), Dim_e }, -{ { 380, 10 }, I_TOANGLE+0, N_("Angle"), N_("Left Angle"), Frog_e }, -{ { 380, 50 }, I_TOOFFSET+0, N_("Offset"), N_("Left Offset"), Dim_e }, -{ { 380, 30 }, I_TORAD+0, N_("Radius"), N_("Left Radius"), Dim_e }, -{ { 130, 90 }, I_TOLENGTH+3, N_("Length"), N_("Center Length"), Dim_e }, -{ { 400, 70 }, I_TOANGLE+3, N_("Angle"), N_("Center Angle"), Dim_e }, -{ { 400, 90}, I_TOOFFSET+3, N_("Offset"), N_("Center Offset"), Dim_e }, -{ { 400, 110 }, I_TORAD+3, N_("Radius"), N_("Center Radius"), Dim_e }, -{ { 420, 150 }, I_TORAD+1, N_("Radius"), N_("Right Radius"), Dim_e }, -{ { 420, 130 }, I_TOOFFSET+1, N_("Offset"), N_("Right Offset"), Dim_e }, -{ { 420, 170 }, I_TOANGLE+1, N_("Angle"), N_("Right Angle"), Frog_e }, -{ { 175, 170 }, I_TOLENGTH+1, N_("Length"), N_("Right Length"), Dim_e }, -{ { 45, 50 }, I_TOTOELENGTH+0, N_("Length"), N_("Toe Length Left"), Dim_e }, -{ { 55, 140 }, I_TOTOELENGTH+1, N_("Length"), N_("Toe Length Right"), Dim_e }, -{ { 40, 105 }, I_TORAD+2, N_("Radius"), N_("Toe Radius"), Dim_e }, - }; + { { 175, 10 }, I_TOLENGTH+0, N_("Length"), N_("Left Length"), Dim_e }, + { { 380, 10 }, I_TOANGLE+0, N_("Angle"), N_("Left Angle"), Frog_e }, + { { 380, 50 }, I_TOOFFSET+0, N_("Offset"), N_("Left Offset"), Dim_e }, + { { 380, 30 }, I_TORAD+0, N_("Radius"), N_("Left Radius"), Dim_e }, + { { 130, 90 }, I_TOLENGTH+3, N_("Length"), N_("Center Length"), Dim_e }, + { { 400, 70 }, I_TOANGLE+3, N_("Angle"), N_("Center Angle"), Dim_e }, + { { 400, 90}, I_TOOFFSET+3, N_("Offset"), N_("Center Offset"), Dim_e }, + { { 400, 110 }, I_TORAD+3, N_("Radius"), N_("Center Radius"), Dim_e }, + { { 420, 150 }, I_TORAD+1, N_("Radius"), N_("Right Radius"), Dim_e }, + { { 420, 130 }, I_TOOFFSET+1, N_("Offset"), N_("Right Offset"), Dim_e }, + { { 420, 170 }, I_TOANGLE+1, N_("Angle"), N_("Right Angle"), Frog_e }, + { { 175, 170 }, I_TOLENGTH+1, N_("Length"), N_("Right Length"), Dim_e }, + { { 45, 50 }, I_TOTOELENGTH+0, N_("Length"), N_("Toe Length Left"), Dim_e }, + { { 55, 140 }, I_TOTOELENGTH+1, N_("Length"), N_("Toe Length Right"), Dim_e }, + { { 40, 105 }, I_TORAD+2, N_("Radius"), N_("Toe Radius"), Dim_e }, +}; static signed char CornuTriPaths[] = { - 'L', 'e', 'f', 't', 0, 1, 2, 3, 0, 0, - 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 6, 0, 0, - 'R', 'i', 'g', 'h', 't', 0, 1, 4, 5, 0, 0, 0 }; + 'L', 'e', 'f', 't', 0, 1, 2, 3, 0, 0, + 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 6, 0, 0, + 'R', 'i', 'g', 'h', 't', 0, 1, 4, 5, 0, 0, 0 +}; static toDesignSchema_t CornuTriSchema = { - CornuTriPaths, - "030" "341" "410" "362" "620" "370" }; + CornuTriPaths, + "030" "341" "410" "362" "620" "370" +}; static toDesignDesc_t CornuThreewayDesc = { - NTO_CORNU3WAY, - N_("Cornu 3-way Turnout"), - 1, - COUNT( CornuThreewayLines ), CornuThreewayLines, - COUNT( CornuThreewayFloats ), CornuThreewayFloats, - NULL, 1 }; + NTO_CORNU3WAY, + N_("Cornu 3-way Turnout"), + 1, + COUNT( CornuThreewayLines ), CornuThreewayLines, + COUNT( CornuThreewayFloats ), CornuThreewayFloats, + NULL, 1 +}; +#endif static wLines_t CrossingLines[] = { #include "toxing.lin" - }; +}; static toDesignFloat_t CrossingFloats[] = { -{ { 329, 30 }, I_TOLENGTH+0, N_("Length"), N_("Length"), Dim_e }, -{ { 370, 90 }, I_TOANGLE+0, N_("Angle"), N_("Angle"), Frog_e }, -{ { 329, 150 }, I_TOLENGTH+1, N_("Length"), N_("Length"), Dim_e } }; + { { 329, 30 }, I_TOLENGTH+0, N_("Length"), N_("Length"), Dim_e }, + { { 370, 90 }, I_TOANGLE+0, N_("Angle"), N_("Angle"), Frog_e }, + { { 329, 150 }, I_TOLENGTH+1, N_("Length"), N_("Length"), Dim_e } +}; static signed char CrossingPaths[] = { - 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 0, 2, 0, 0, 0 }; + 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 0, 2, 0, 0, 0 +}; static toDesignSchema_t CrossingSchema = { - CrossingPaths, - "010" "230" }; + CrossingPaths, + "010" "230" +}; static toDesignDesc_t CrossingDesc = { - NTO_CROSSING, - N_("Crossing"), - 1, - COUNT( CrossingLines ), CrossingLines, - COUNT( CrossingFloats ), CrossingFloats, - &CrossingSchema, 1 }; + NTO_CROSSING, + N_("Crossing"), + 1, + COUNT( CrossingLines ), CrossingLines, + COUNT( CrossingFloats ), CrossingFloats, + &CrossingSchema, 1 +}; static wLines_t SingleSlipLines[] = { #include "tosslip.lin" - }; +}; static toDesignFloat_t SingleSlipFloats[] = { -{ { 329, 30 }, I_TOLENGTH+0, N_("Length"), N_("Length"), Dim_e }, -{ { 370, 90 }, I_TOANGLE+0, N_("Angle"), N_("Angle"), Frog_e }, -{ { 329, 155 }, I_TOLENGTH+1, N_("Length"), N_("Length"), Dim_e } }; + { { 329, 30 }, I_TOLENGTH+0, N_("Length"), N_("Length"), Dim_e }, + { { 370, 90 }, I_TOANGLE+0, N_("Angle"), N_("Angle"), Frog_e }, + { { 329, 155 }, I_TOLENGTH+1, N_("Length"), N_("Length"), Dim_e } +}; static signed char SingleSlipPaths[] = { - 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 2, 0, 3, 4, 0, 0, - 'R', 'e', 'v', 'e', 'r', 's', 'e', 0, 1, 5, 4, 0, 0, 0 }; + 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 2, 0, 3, 4, 0, 0, + 'R', 'e', 'v', 'e', 'r', 's', 'e', 0, 1, 5, 4, 0, 0, 0 +}; static toDesignSchema_t SingleSlipSchema = { - SingleSlipPaths, - "040" "410" "250" "530" "451" }; + SingleSlipPaths, + "040" "410" "250" "530" "451" +}; static toDesignDesc_t SingleSlipDesc = { - NTO_S_SLIP, - N_("Single Slipswitch"), - 1, - COUNT( SingleSlipLines ), SingleSlipLines, - COUNT( SingleSlipFloats ), SingleSlipFloats, - &SingleSlipSchema, 1 }; + NTO_S_SLIP, + N_("Single Slipswitch"), + 1, + COUNT( SingleSlipLines ), SingleSlipLines, + COUNT( SingleSlipFloats ), SingleSlipFloats, + &SingleSlipSchema, 1 +}; static wLines_t DoubleSlipLines[] = { #include "todslip.lin" - }; +}; static toDesignFloat_t DoubleSlipFloats[] = { -{ { 329, 30 }, I_TOLENGTH+0, N_("Length"), N_("Length"), Dim_e }, -{ { 370, 90 }, I_TOANGLE+0, N_("Angle"), N_("Angle"), Frog_e }, -{ { 329, 155 }, I_TOLENGTH+1, N_("Length"), N_("Length"), Dim_e } }; + { { 329, 30 }, I_TOLENGTH+0, N_("Length"), N_("Length"), Dim_e }, + { { 370, 90 }, I_TOANGLE+0, N_("Angle"), N_("Angle"), Frog_e }, + { { 329, 155 }, I_TOLENGTH+1, N_("Length"), N_("Length"), Dim_e } +}; static signed char DoubleSlipPaths[] = { - 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 2, 3, 0, 4, 5, 6, 0, 0, - 'R', 'e', 'v', 'e', 'r', 's', 'e', 0, 1, 7, 6, 0, 4, 8, 3, 0, 0, 0 }; + 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 2, 3, 0, 4, 5, 6, 0, 0, + 'R', 'e', 'v', 'e', 'r', 's', 'e', 0, 1, 7, 6, 0, 4, 8, 3, 0, 0, 0 +}; static signed char DoubleSlipPaths2[] = { - 'C', 'r', 'o', 's', 's', '1', 0, 1, 2, 3, 0, 0, - 'C', 'r', 'o', 's', 's', '2', 0, 4, 5, 6, 0, 0, - 'S', 'l', 'i', 'p', '1', 0, 1, 7, 6, 0, 0, - 'S', 'l', 'i', 'p', '2', 0, 4, 8, 3, 0, 0, 0 }; + 'C', 'r', 'o', 's', 's', '1', 0, 1, 2, 3, 0, 0, + 'C', 'r', 'o', 's', 's', '2', 0, 4, 5, 6, 0, 0, + 'S', 'l', 'i', 'p', '1', 0, 1, 7, 6, 0, 0, + 'S', 'l', 'i', 'p', '2', 0, 4, 8, 3, 0, 0, 0 +}; static toDesignSchema_t DoubleSlipSchema = { - DoubleSlipPaths, - "040" "460" "610" "270" "750" "530" "451" "762" }; + DoubleSlipPaths, + "040" "460" "610" "270" "750" "530" "451" "762" +}; static toDesignSchema_t DoubleSlipSchema2 = { - DoubleSlipPaths2, - "040" "460" "610" "270" "750" "530" "451" "762" }; + DoubleSlipPaths2, + "040" "460" "610" "270" "750" "530" "451" "762" +}; static toDesignDesc_t DoubleSlipDesc = { - NTO_D_SLIP, - N_("Double Slipswitch"), - 1, - COUNT( DoubleSlipLines ), DoubleSlipLines, - COUNT( DoubleSlipFloats ), DoubleSlipFloats, - &DoubleSlipSchema, 1 }; + NTO_D_SLIP, + N_("Double Slipswitch"), + 1, + COUNT( DoubleSlipLines ), DoubleSlipLines, + COUNT( DoubleSlipFloats ), DoubleSlipFloats, + &DoubleSlipSchema, 1 +}; +#ifndef MKTURNOUT static wLines_t RightCrossoverLines[] = { #include "torcross.lin" - }; +}; static toDesignFloat_t RightCrossoverFloats[] = { -{ { 200, 10 }, I_TOLENGTH+0, N_("Length"), N_("Length"), Dim_e }, -{ { 90, 85 }, I_TOOFFSET+0, N_("Separation"), N_("Separation"), Dim_e } }; + { { 200, 10 }, I_TOLENGTH+0, N_("Length"), N_("Length"), Dim_e }, + { { 90, 85 }, I_TOOFFSET+0, N_("Separation"), N_("Separation"), Dim_e } +}; static signed char RightCrossoverPaths[] = { - 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 2, 0, 3, 4, 0, 0, - 'R', 'e', 'v', 'e', 'r', 's', 'e', 0, 3, 5, 6, 7, 2, 0, 0, 0 }; + 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 2, 0, 3, 4, 0, 0, + 'R', 'e', 'v', 'e', 'r', 's', 'e', 0, 3, 5, 6, 7, 2, 0, 0, 0 +}; static toDesignSchema_t RightCrossoverSchema = { - RightCrossoverPaths, - "060" "610" "280" "830" "892" "970" "761" }; + RightCrossoverPaths, + "060" "610" "280" "830" "892" "970" "761" +}; static toDesignDesc_t RightCrossoverDesc = { - NTO_R_CROSSOVER, - N_("Right Crossover"), - 1, - COUNT( RightCrossoverLines ), RightCrossoverLines, - COUNT( RightCrossoverFloats ), RightCrossoverFloats, - &RightCrossoverSchema, 0 }; + NTO_R_CROSSOVER, + N_("Right Crossover"), + 1, + COUNT( RightCrossoverLines ), RightCrossoverLines, + COUNT( RightCrossoverFloats ), RightCrossoverFloats, + &RightCrossoverSchema, 0 +}; +#endif +#ifndef MKTURNOUT static wLines_t LeftCrossoverLines[] = { #include "tolcross.lin" - }; +}; static toDesignFloat_t LeftCrossoverFloats[] = { -{ { 200, 10 }, I_TOLENGTH+0, N_("Length"), N_("Length"), Dim_e }, -{ { 90, 85 }, I_TOOFFSET+0, N_("Separation"), N_("Separation"), Dim_e } }; + { { 200, 10 }, I_TOLENGTH+0, N_("Length"), N_("Length"), Dim_e }, + { { 90, 85 }, I_TOOFFSET+0, N_("Separation"), N_("Separation"), Dim_e } +}; static signed char LeftCrossoverPaths[] = { - 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 2, 0, 3, 4, 0, 0, - 'R', 'e', 'v', 'e', 'r', 's', 'e', 0, 1, 5, 6, 7, 4, 0, 0, 0 }; + 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 2, 0, 3, 4, 0, 0, + 'R', 'e', 'v', 'e', 'r', 's', 'e', 0, 1, 5, 6, 7, 4, 0, 0, 0 +}; static toDesignSchema_t LeftCrossoverSchema = { - LeftCrossoverPaths, - "040" "410" "2A0" "A30" "451" "5B0" "BA2" }; + LeftCrossoverPaths, + "040" "410" "2A0" "A30" "451" "5B0" "BA2" +}; static toDesignDesc_t LeftCrossoverDesc = { - NTO_L_CROSSOVER, - N_("Left Crossover"), - 1, - COUNT( LeftCrossoverLines ), LeftCrossoverLines, - COUNT( LeftCrossoverFloats ), LeftCrossoverFloats, - &LeftCrossoverSchema, 0 }; + NTO_L_CROSSOVER, + N_("Left Crossover"), + 1, + COUNT( LeftCrossoverLines ), LeftCrossoverLines, + COUNT( LeftCrossoverFloats ), LeftCrossoverFloats, + &LeftCrossoverSchema, 0 +}; +#endif static wLines_t DoubleCrossoverLines[] = { #include "todcross.lin" - }; +}; static toDesignFloat_t DoubleCrossoverFloats[] = { -{ { 200, 10 }, I_TOLENGTH+0, N_("Length"), N_("Length"), Dim_e }, -{ { 90, 85 }, I_TOOFFSET+0, N_("Separation"), N_("Separation"), Dim_e } }; + { { 200, 10 }, I_TOLENGTH+0, N_("Length"), N_("Length"), Dim_e }, + { { 90, 85 }, I_TOOFFSET+0, N_("Separation"), N_("Separation"), Dim_e } +}; static signed char DoubleCrossoverPaths[] = { - 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 2, 3, 0, 4, 5, 6, 0, 0, - 'R', 'e', 'v', 'e', 'r', 's', 'e', 0, 1, 7, 8, 9, 6, 0, 4, 10, 11, 12, 3, 0, 0, 0 }; + 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 2, 3, 0, 4, 5, 6, 0, 0, + 'R', 'e', 'v', 'e', 'r', 's', 'e', 0, 1, 7, 8, 9, 6, 0, 4, 10, 11, 12, 3, 0, 0, 0 +}; static toDesignSchema_t DoubleCrossoverSchema = { - DoubleCrossoverPaths, - "040" "460" "610" "280" "8A0" "A30" "451" "5B0" "BA2" "892" "970" "761" }; + DoubleCrossoverPaths, + "040" "460" "610" "280" "8A0" "A30" "451" "5B0" "BA2" "892" "970" "761" +}; static toDesignDesc_t DoubleCrossoverDesc = { - NTO_D_CROSSOVER, - N_("Double Crossover"), - 1, - COUNT( DoubleCrossoverLines ), DoubleCrossoverLines, - COUNT( DoubleCrossoverFloats ), DoubleCrossoverFloats, - &DoubleCrossoverSchema, 0 }; + NTO_D_CROSSOVER, + N_("Double Crossover"), + 1, + COUNT( DoubleCrossoverLines ), DoubleCrossoverLines, + COUNT( DoubleCrossoverFloats ), DoubleCrossoverFloats, + &DoubleCrossoverSchema, 0 +}; static wLines_t StrSectionLines[] = { #include "tostrsct.lin" - }; +}; static toDesignFloat_t StrSectionFloats[] = { -{ { 200, 10 }, I_TOLENGTH+0, N_("Length"), N_("Length"), Dim_e } }; + { { 200, 10 }, I_TOLENGTH+0, N_("Length"), N_("Length"), Dim_e } +}; static signed char StrSectionPaths[] = { - 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 0, 0, 0 }; + 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 0, 0, 0 +}; static toDesignSchema_t StrSectionSchema = { - StrSectionPaths, - "010" }; + StrSectionPaths, + "010" +}; static toDesignDesc_t StrSectionDesc = { - NTO_STR_SECTION, - N_("Straight Section"), - 1, - COUNT( StrSectionLines ), StrSectionLines, - COUNT( StrSectionFloats ), StrSectionFloats, - &StrSectionSchema, 0 }; + NTO_STR_SECTION, + N_("Straight Section"), + 1, + COUNT( StrSectionLines ), StrSectionLines, + COUNT( StrSectionFloats ), StrSectionFloats, + &StrSectionSchema, 0 +}; static wLines_t CrvSectionLines[] = { #include "tocrvsct.lin" - }; +}; static toDesignFloat_t CrvSectionFloats[] = { -{ { 225, 90 }, I_TOLENGTH+0, N_("Radius"), N_("Radius"), Dim_e }, -{ { 225, 140}, I_TOANGLE+0, N_("Angle (Degrees)"), N_("Angle"), Angle_e } }; + { { 225, 90 }, I_TOLENGTH+0, N_("Radius"), N_("Radius"), Dim_e }, + { { 225, 140}, I_TOANGLE+0, N_("Angle (Degrees)"), N_("Angle"), Angle_e } +}; static signed char CrvSectionPaths[] = { - 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 0, 0, 0 }; + 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 0, 0, 0 +}; static toDesignSchema_t CrvSectionSchema = { - CrvSectionPaths, - "011" }; + CrvSectionPaths, + "011" +}; static toDesignDesc_t CrvSectionDesc = { - NTO_CRV_SECTION, - N_("Curved Section"), - 1, - COUNT( CrvSectionLines ), CrvSectionLines, - COUNT( CrvSectionFloats ), CrvSectionFloats, - &CrvSectionSchema, 0 }; + NTO_CRV_SECTION, + N_("Curved Section"), + 1, + COUNT( CrvSectionLines ), CrvSectionLines, + COUNT( CrvSectionFloats ), CrvSectionFloats, + &CrvSectionSchema, 0 +}; #ifdef LATER static wLines_t BumperLines[] = { #include "tostrsct.lin" - }; +}; static toDesignFloat_t BumperFloats[] = { -{ { 200, 10 }, I_TOLENGTH+0, N_("Length"), N_("Length"), Dim_e } }; + { { 200, 10 }, I_TOLENGTH+0, N_("Length"), N_("Length"), Dim_e } +}; static signed char BumperPaths[] = { - 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 0, 0, 0 }; + 'N', 'o', 'r', 'm', 'a', 'l', 0, 1, 0, 0, 0 +}; static toDesignSchema_t BumperSchema = { - BumperPaths, - "010" }; + BumperPaths, + "010" +}; static toDesignDesc_t BumperDesc = { - NTO_BUMPER, - N_("Bumper Section"), - 1, - COUNT( BumberLines ), BumperLines, - COUNT( BumperFloats ), BumperFloats, - &BumperSchema, 0 }; + NTO_BUMPER, + N_("Bumper Section"), + 1, + COUNT( BumberLines ), BumperLines, + COUNT( BumperFloats ), BumperFloats, + &BumperSchema, 0 +}; static wLines_t TurntableLines[] = { #include "tostrsct.lin" - }; +}; static toDesignFloat_t TurntableFloats[] = { -{ { 200, 10 }, I_TOOFFSET+0, N_("Offset"), N_("Count"), 0 }, -{ { 200, 10 }, I_TOLENGTH+0, N_("Length"), N_("Radius1"), Dim_e }, -{ { 200, 10 }, I_TOLENGTH+1, N_("Length"), N_("Radius2"), Dim_e } }; + { { 200, 10 }, I_TOOFFSET+0, N_("Offset"), N_("Count"), 0 }, + { { 200, 10 }, I_TOLENGTH+0, N_("Length"), N_("Radius1"), Dim_e }, + { { 200, 10 }, I_TOLENGTH+1, N_("Length"), N_("Radius2"), Dim_e } +}; static signed char TurntablePaths[] = { - '1', 0, 1, 0, 0, - '2', 0, 2, 0, 0, - '3', 0, 3, 0, 0, - '4', 0, 4, 0, 0, - '5', 0, 5, 0, 0, - '6', 0, 6, 0, 0, - '7', 0, 7, 0, 0, - '8', 0, 8, 0, 0, - '9', 0, 9, 0, 0, - '1', '0', 0, 10, 0, 0, - '1', '1', 0, 11, 0, 0, - '1', '2', 0, 12, 0, 0, - '1', '3', 0, 13, 0, 0, - '1', '4', 0, 14, 0, 0, - '1', '5', 0, 15, 0, 0, - '1', '6', 0, 16, 0, 0, - '1', '7', 0, 17, 0, 0, - '1', '8', 0, 18, 0, 0, - '1', '9', 0, 19, 0, 0, - '2', '0', 0, 20, 0, 0, - '2', '1', 0, 21, 0, 0, - '2', '2', 0, 22, 0, 0, - '2', '3', 0, 23, 0, 0, - '2', '4', 0, 24, 0, 0, - '2', '5', 0, 25, 0, 0, - '2', '6', 0, 26, 0, 0, - '2', '7', 0, 27, 0, 0, - '2', '8', 0, 28, 0, 0, - '2', '9', 0, 29, 0, 0, - '3', '0', 0, 30, 0, 0, - '3', '1', 0, 31, 0, 0, - '3', '2', 0, 32, 0, 0, - '3', '3', 0, 33, 0, 0, - '3', '4', 0, 34, 0, 0, - '3', '5', 0, 35, 0, 0, - '3', '6', 0, 36, 0, 0, - '3', '7', 0, 37, 0, 0, - '3', '8', 0, 38, 0, 0, - '3', '9', 0, 39, 0, 0, - '4', '0', 0, 40, 0, 0, - '4', '1', 0, 41, 0, 0, - '4', '2', 0, 42, 0, 0, - '4', '3', 0, 43, 0, 0, - '4', '4', 0, 44, 0, 0, - '4', '5', 0, 45, 0, 0, - '4', '6', 0, 46, 0, 0, - '4', '7', 0, 47, 0, 0, - '4', '8', 0, 48, 0, 0, - '4', '9', 0, 49, 0, 0, - '5', '0', 0, 50, 0, 0, - '5', '1', 0, 51, 0, 0, - '5', '2', 0, 52, 0, 0, - '5', '3', 0, 53, 0, 0, - '5', '4', 0, 54, 0, 0, - '5', '5', 0, 55, 0, 0, - '5', '6', 0, 56, 0, 0, - '5', '7', 0, 57, 0, 0, - '5', '8', 0, 58, 0, 0, - '5', '9', 0, 59, 0, 0, - '6', '0', 0, 60, 0, 0, - '6', '1', 0, 61, 0, 0, - '6', '2', 0, 62, 0, 0, - '6', '3', 0, 63, 0, 0, - '6', '4', 0, 64, 0, 0, - '6', '5', 0, 65, 0, 0, - '6', '6', 0, 66, 0, 0, - '6', '7', 0, 67, 0, 0, - '6', '8', 0, 68, 0, 0, - '6', '9', 0, 69, 0, 0, - '7', '0', 0, 70, 0, 0, - '7', '1', 0, 71, 0, 0, - '7', '2', 0, 72, 0, 0, - 0 }; + '1', 0, 1, 0, 0, + '2', 0, 2, 0, 0, + '3', 0, 3, 0, 0, + '4', 0, 4, 0, 0, + '5', 0, 5, 0, 0, + '6', 0, 6, 0, 0, + '7', 0, 7, 0, 0, + '8', 0, 8, 0, 0, + '9', 0, 9, 0, 0, + '1', '0', 0, 10, 0, 0, + '1', '1', 0, 11, 0, 0, + '1', '2', 0, 12, 0, 0, + '1', '3', 0, 13, 0, 0, + '1', '4', 0, 14, 0, 0, + '1', '5', 0, 15, 0, 0, + '1', '6', 0, 16, 0, 0, + '1', '7', 0, 17, 0, 0, + '1', '8', 0, 18, 0, 0, + '1', '9', 0, 19, 0, 0, + '2', '0', 0, 20, 0, 0, + '2', '1', 0, 21, 0, 0, + '2', '2', 0, 22, 0, 0, + '2', '3', 0, 23, 0, 0, + '2', '4', 0, 24, 0, 0, + '2', '5', 0, 25, 0, 0, + '2', '6', 0, 26, 0, 0, + '2', '7', 0, 27, 0, 0, + '2', '8', 0, 28, 0, 0, + '2', '9', 0, 29, 0, 0, + '3', '0', 0, 30, 0, 0, + '3', '1', 0, 31, 0, 0, + '3', '2', 0, 32, 0, 0, + '3', '3', 0, 33, 0, 0, + '3', '4', 0, 34, 0, 0, + '3', '5', 0, 35, 0, 0, + '3', '6', 0, 36, 0, 0, + '3', '7', 0, 37, 0, 0, + '3', '8', 0, 38, 0, 0, + '3', '9', 0, 39, 0, 0, + '4', '0', 0, 40, 0, 0, + '4', '1', 0, 41, 0, 0, + '4', '2', 0, 42, 0, 0, + '4', '3', 0, 43, 0, 0, + '4', '4', 0, 44, 0, 0, + '4', '5', 0, 45, 0, 0, + '4', '6', 0, 46, 0, 0, + '4', '7', 0, 47, 0, 0, + '4', '8', 0, 48, 0, 0, + '4', '9', 0, 49, 0, 0, + '5', '0', 0, 50, 0, 0, + '5', '1', 0, 51, 0, 0, + '5', '2', 0, 52, 0, 0, + '5', '3', 0, 53, 0, 0, + '5', '4', 0, 54, 0, 0, + '5', '5', 0, 55, 0, 0, + '5', '6', 0, 56, 0, 0, + '5', '7', 0, 57, 0, 0, + '5', '8', 0, 58, 0, 0, + '5', '9', 0, 59, 0, 0, + '6', '0', 0, 60, 0, 0, + '6', '1', 0, 61, 0, 0, + '6', '2', 0, 62, 0, 0, + '6', '3', 0, 63, 0, 0, + '6', '4', 0, 64, 0, 0, + '6', '5', 0, 65, 0, 0, + '6', '6', 0, 66, 0, 0, + '6', '7', 0, 67, 0, 0, + '6', '8', 0, 68, 0, 0, + '6', '9', 0, 69, 0, 0, + '7', '0', 0, 70, 0, 0, + '7', '1', 0, 71, 0, 0, + '7', '2', 0, 72, 0, 0, + 0 +}; static toDesignSchema_t TurntableSchema = { - TurntablePaths, - "010" "020" "030" "040" "050" "060" "070" "080" "090" "0A0" "0B0" }; + TurntablePaths, + "010" "020" "030" "040" "050" "060" "070" "080" "090" "0A0" "0B0" +}; static toDesignDesc_t TurntableDesc = { - NTO_TURNTABLE, - N_("Turntable Section"), - 1, - COUNT( TurntableLines ), TurntableLines, - COUNT( TurntableFloats ), TurntableFLoats, - &TurntableSchema, 0 }; + NTO_TURNTABLE, + N_("Turntable Section"), + 1, + COUNT( TurntableLines ), TurntableLines, + COUNT( TurntableFloats ), TurntableFLoats, + &TurntableSchema, 0 +}; #endif #ifndef MKTURNOUT static toDesignDesc_t * designDescs[] = { - &RegDesc, - &CrvDesc, - &CornuDesc, - &WyeDesc, - &CornuWyeDesc, - &ThreewayDesc, - &CornuThreewayDesc, - &CrossingDesc, - &SingleSlipDesc, - &DoubleSlipDesc, - &RightCrossoverDesc, - &LeftCrossoverDesc, - &DoubleCrossoverDesc, - &StrSectionDesc, - &CrvSectionDesc }; + &RegDesc, + &CrvDesc, + &CornuDesc, + &WyeDesc, + &CornuWyeDesc, + &ThreewayDesc, + &CornuThreewayDesc, + &CrossingDesc, + &SingleSlipDesc, + &DoubleSlipDesc, + &RightCrossoverDesc, + &LeftCrossoverDesc, + &DoubleCrossoverDesc, + &StrSectionDesc, + &CrvSectionDesc +}; #endif /************************************************************************** @@ -766,50 +861,51 @@ static toDesignDesc_t * designDescs[] = { int debugComputeRoadbed = 0; #ifdef LATER typedef struct { - int start; - unsigned long bits; - unsigned long mask; - int width; - } searchTable_t; + int start; + unsigned long bits; + unsigned long mask; + int width; +} searchTable_t; static searchTable_t searchTable[] = { - { 0, 0xFFFF0000, 0xFFFF0000, 32000} , - { 32, 0x0000FFFF, 0x0000FFFF, 32000} , - - { 16, 0x00FFFF00, 0x00FFFF00, 16} , - - { 8, 0x0FF00000, 0x0FF00000, 8} , - { 24, 0x00000FF0, 0x00000FF0, 8} , - - { 4, 0x3C000000, 0x3C000000, 4} , - { 12, 0x003C0000, 0x003C0000, 4} , - { 20, 0x00003C00, 0x00003C00, 4} , - { 28, 0x0000003C, 0x0000003C, 4} , - - { 2, 0x60000000, 0x60000000, 2} , - { 6, 0x06000000, 0x06000000, 2}, - { 10, 0x00600000, 0x00600000, 2}, - { 14, 0x00060000, 0x00060000, 2}, - { 18, 0x00006000, 0x00006000, 2}, - { 22, 0x00000600, 0x00000600, 2}, - { 26, 0x00000060, 0x00000060, 2}, - { 30, 0x00000006, 0x00000006, 2}, - - { 1, 0x40000000, 0x60000000, 1}, - { 3, 0x10000000, 0x30000000, 1}, - { 5, 0x04000000, 0x06000000, 1}, - { 7, 0x01000000, 0x03000000, 1}, - { 9, 0x00400000, 0x00600000, 1}, - { 11, 0x00100000, 0x00300000, 1}, - { 13, 0x00040000, 0x00060000, 1}, - { 15, 0x00010000, 0x00030000, 1}, - { 17, 0x00004000, 0x00006000, 1}, - { 19, 0x00001000, 0x00003000, 1}, - { 21, 0x00000400, 0x00000600, 1}, - { 23, 0x00000100, 0x00000300, 1}, - { 25, 0x00000040, 0x00000060, 1}, - { 27, 0x00000010, 0x00000030, 1}, - { 29, 0x00000004, 0x00000006, 1}, - { 31, 0x00000001, 0x00000003, 1}}; + { 0, 0xFFFF0000, 0xFFFF0000, 32000}, + { 32, 0x0000FFFF, 0x0000FFFF, 32000}, + + { 16, 0x00FFFF00, 0x00FFFF00, 16}, + + { 8, 0x0FF00000, 0x0FF00000, 8}, + { 24, 0x00000FF0, 0x00000FF0, 8}, + + { 4, 0x3C000000, 0x3C000000, 4}, + { 12, 0x003C0000, 0x003C0000, 4}, + { 20, 0x00003C00, 0x00003C00, 4}, + { 28, 0x0000003C, 0x0000003C, 4}, + + { 2, 0x60000000, 0x60000000, 2}, + { 6, 0x06000000, 0x06000000, 2}, + { 10, 0x00600000, 0x00600000, 2}, + { 14, 0x00060000, 0x00060000, 2}, + { 18, 0x00006000, 0x00006000, 2}, + { 22, 0x00000600, 0x00000600, 2}, + { 26, 0x00000060, 0x00000060, 2}, + { 30, 0x00000006, 0x00000006, 2}, + + { 1, 0x40000000, 0x60000000, 1}, + { 3, 0x10000000, 0x30000000, 1}, + { 5, 0x04000000, 0x06000000, 1}, + { 7, 0x01000000, 0x03000000, 1}, + { 9, 0x00400000, 0x00600000, 1}, + { 11, 0x00100000, 0x00300000, 1}, + { 13, 0x00040000, 0x00060000, 1}, + { 15, 0x00010000, 0x00030000, 1}, + { 17, 0x00004000, 0x00006000, 1}, + { 19, 0x00001000, 0x00003000, 1}, + { 21, 0x00000400, 0x00000600, 1}, + { 23, 0x00000100, 0x00000300, 1}, + { 25, 0x00000040, 0x00000060, 1}, + { 27, 0x00000010, 0x00000030, 1}, + { 29, 0x00000004, 0x00000006, 1}, + { 31, 0x00000001, 0x00000003, 1} +}; #endif @@ -851,20 +947,21 @@ double CircleSegDistance( coOrd p, coOrd c, double r, double a0, double a1 ) d0 = FindDistance( p, p1 ); PointOnCircle( &p1, c, r, a0+a1 ); d1 = FindDistance( p, p1 ); - if (d0 < d1) + if (d0 < d1) { return d0; - else + } else { return d1; + } } BOOL_T HittestTurnoutRoadbed( - trkSeg_p segPtr, - int segCnt, - int segInx, - ANGLE_T side, - int fraction, - DIST_T roadbedWidth ) + trkSeg_p segPtr, + int segCnt, + int segInx, + ANGLE_T side, + int fraction, + DIST_T roadbedWidth ) { ANGLE_T a; DIST_T d; @@ -888,10 +985,11 @@ BOOL_T HittestTurnoutRoadbed( fraction = 31-fraction; } a = sp->u.c.a0 + sp->u.c.a1*(fraction*2+1)/64.0; - if (side>0) + if (side>0) { d += roadbedWidth/2.0; - else + } else { d -= roadbedWidth/2.0; + } PointOnCircle( &p0, sp->u.c.center, d, a ); } dd = DIST_INF; @@ -904,33 +1002,36 @@ BOOL_T HittestTurnoutRoadbed( d = LineSegDistance( p1, sp->u.l.pos[0], sp->u.l.pos[1] ); break; case SEG_CRVTRK: - d = CircleSegDistance( p1, sp->u.c.center, fabs(sp->u.c.radius), sp->u.c.a0, sp->u.c.a1 ); + d = CircleSegDistance( p1, sp->u.c.center, fabs(sp->u.c.radius), sp->u.c.a0, + sp->u.c.a1 ); break; default: continue; } #ifdef LATER - if (inx==segInx) + if (inx==segInx) { d *= .999; + } #endif if ( d < dd ) { dd = d; closest = inx; } } - if (closest == segInx) + if (closest == segInx) { return FALSE; - else + } else { return TRUE; + } } #ifdef LATER EXPORT long ComputeTurnoutRoadbedSide( - trkSeg_p segPtr, - int segCnt, - int segInx, - ANGLE_T side, - DIST_T roadbedWidth ) + trkSeg_p segPtr, + int segCnt, + int segInx, + ANGLE_T side, + DIST_T roadbedWidth ) { DIST_T length; int rbw; @@ -940,42 +1041,45 @@ EXPORT long ComputeTurnoutRoadbedSide( trkSeg_p sp; sp = &segPtr[segInx]; - if (sp->type == SEG_STRTRK) + if (sp->type == SEG_STRTRK) { length = FindDistance( sp->u.l.pos[0], sp->u.l.pos[1] ); - else - length = (fabs(sp->u.c.radius) + (side>0?roadbedWidth/2.0:-roadbedWidth/2.0) ) * 2 * M_PI * sp->u.c.a1 / 360.0; + } else { + length = (fabs(sp->u.c.radius) + (side>0?roadbedWidth/2.0:-roadbedWidth/2.0) ) * + 2 * M_PI * sp->u.c.a1 / 360.0; + } rbw = (int)(roadbedWidth/length*32/2); -/*printf( "L=%0.3f G=%0.3f [%0.3f %0.3f] RBW=%d\n", length, gapWidth, first, last, rbw );*/ + /*printf( "L=%0.3f G=%0.3f [%0.3f %0.3f] RBW=%d\n", length, gapWidth, first, last, rbw );*/ res = 0xFF0000FF; for ( p=searchTable; p<&searchTable[COUNT( searchTable )]; p++) { - if ( (p->width < rbw && res==0xFFFFFFFF) || res==0 ) + if ( (p->width < rbw && res==0xFFFFFFFF) || res==0 ) { break; + } res1 = (p->mask & res); where = p->start*length/32.0; if (p->width >= rbw || (res1!=p->mask && res1!=0)) { if (HittestTurnoutRoadbed(segPtr, segCnt, segInx, side, p->start)) { - res &= ~p->bits; -if (debugComputeRoadbed>=1) printf( "res=%08lx *p={%02d %08lx %08lx %02d} res1=%08lx W=%0.3f HIT\n", res, p->start, p->bits, p->mask, p->width, res1, where ); + res &= ~p->bits; + if (debugComputeRoadbed>=1) { printf( "res=%08lx *p={%02d %08lx %08lx %02d} res1=%08lx W=%0.3f HIT\n", res, p->start, p->bits, p->mask, p->width, res1, where ); } } else { - res |= p->bits; -if (debugComputeRoadbed>=1) printf( "res=%08lx *p={%02d %08lx %08lx %02d} res1=%08lx W=%0.3f MISS\n", res, p->start, p->bits, p->mask, p->width, res1, where ); + res |= p->bits; + if (debugComputeRoadbed>=1) { printf( "res=%08lx *p={%02d %08lx %08lx %02d} res1=%08lx W=%0.3f MISS\n", res, p->start, p->bits, p->mask, p->width, res1, where ); } } } else { -if (debugComputeRoadbed>=2) printf( "res=%08lx *p={%02d %08lx %08lx %02d} res1=%08lx W=%0.3f SKIP\n", res, p->start, p->bits, p->mask, p->width, res1, where ); + if (debugComputeRoadbed>=2) { printf( "res=%08lx *p={%02d %08lx %08lx %02d} res1=%08lx W=%0.3f SKIP\n", res, p->start, p->bits, p->mask, p->width, res1, where ); } } } -if (debugComputeRoadbed>=1) printf( "res=%08lx\n", res ); + if (debugComputeRoadbed>=1) { printf( "res=%08lx\n", res ); } return res; } #endif EXPORT long ComputeTurnoutRoadbedSide( - trkSeg_p segPtr, - int segCnt, - int segInx, - ANGLE_T side, - DIST_T roadbedWidth ) + trkSeg_p segPtr, + int segCnt, + int segInx, + ANGLE_T side, + DIST_T roadbedWidth ) { trkSeg_p sp; DIST_T length; @@ -985,37 +1089,43 @@ EXPORT long ComputeTurnoutRoadbedSide( int i, j, k, hitx; sp = &segPtr[segInx]; - if (sp->type == SEG_STRTRK) + if (sp->type == SEG_STRTRK) { length = FindDistance( sp->u.l.pos[0], sp->u.l.pos[1] ); - else - length = (fabs(sp->u.c.radius) + (side>0?roadbedWidth/2.0:-roadbedWidth/2.0) ) * 2 * M_PI * sp->u.c.a1 / 360.0; + } else { + length = (fabs(sp->u.c.radius) + (side>0?roadbedWidth/2.0:-roadbedWidth/2.0) ) * + 2 * M_PI * sp->u.c.a1 / 360.0; + } bitWidth = (int)floor(roadbedWidth*32/length); - if ( bitWidth > 31 ) + if ( bitWidth > 31 ) { bitWidth = 31; - else if ( bitWidth <= 0 ) + } else if ( bitWidth <= 0 ) { bitWidth = 2; + } res = 0; mask = (1<<bitWidth)-1; hit0 = HittestTurnoutRoadbed( segPtr, segCnt, segInx, side, 0, roadbedWidth ); inx0 = 0; inx1 = bitWidth; -if ( debugComputeRoadbed>=3 ) printf( "bW=%d HT[0]=%d\n", bitWidth, hit0 ); + if ( debugComputeRoadbed>=3 ) { printf( "bW=%d HT[0]=%d\n", bitWidth, hit0 ); } while ( 1 ) { - if ( inx1 > 31 ) + if ( inx1 > 31 ) { inx1 = 31; - hit1 = HittestTurnoutRoadbed( segPtr, segCnt, segInx, side, inx1, roadbedWidth ); -if ( debugComputeRoadbed>=3 ) printf( " HT[%d]=%d\n", inx1, hit1 ); + } + hit1 = HittestTurnoutRoadbed( segPtr, segCnt, segInx, side, inx1, + roadbedWidth ); + if ( debugComputeRoadbed>=3 ) { printf( " HT[%d]=%d\n", inx1, hit1 ); } if ( hit0 != hit1 ) { i=inx0; j=inx1; while ( j-i >= 2 ) { k = (i+j)/2; hitx = HittestTurnoutRoadbed( segPtr, segCnt, segInx, side, k, roadbedWidth ); -if ( debugComputeRoadbed>=3 ) printf( " .HT[%d]=%d\n", k, hitx ); - if ( hitx == hit0 ) + if ( debugComputeRoadbed>=3 ) { printf( " .HT[%d]=%d\n", k, hitx ); } + if ( hitx == hit0 ) { i = k; - else + } else { j = k; + } } if ( !hit0 ) { res |= ((1<<(i-inx0+1))-1)<<inx0; @@ -1025,10 +1135,11 @@ if ( debugComputeRoadbed>=3 ) printf( " .HT[%d]=%d\n", k, hitx ); } else if ( !hit1 ) { res |= mask; } -if ( debugComputeRoadbed>=3 ) printf( " res=%lx\n", res ); + if ( debugComputeRoadbed>=3 ) { printf( " res=%lx\n", res ); } if ( inx1 >= 31 ) { - if ( !hit1 ) + if ( !hit1 ) { res |= 0x80000000; + } break; } mask <<= bitWidth; @@ -1036,7 +1147,7 @@ if ( debugComputeRoadbed>=3 ) printf( " res=%lx\n", res ); inx1 += bitWidth; hit0 = hit1; } -if ( debugComputeRoadbed>=2 ) printf( "S%d %c res=%lx\n", segInx, side>0?'+':'-', res ); + if ( debugComputeRoadbed>=2 ) { printf( "S%d %c res=%lx\n", segInx, side>0?'+':'-', res ); } return (0xFFFFFFFF)&res; } @@ -1050,23 +1161,19 @@ static BOOL_T IsNear( coOrd p0, coOrd p1 ) static void AddRoadbedPieces( - int inx, - ANGLE_T side, - int first, - int last ) + int inx, + ANGLE_T side, + int first, + int last ) { DIST_T d0, d1; ANGLE_T a0, a1; coOrd p0, p1; trkSeg_p sp, sq; -#ifdef MKTURNOUT -#define _DPI (76.0) -#else -#define _DPI mainD.dpi -#endif - if (last<=first) + if (last<=first) { return; + } sp = &tempSegs(inx); if ( sp->type == SEG_STRTRK ) { d0 = FindDistance( sp->u.l.pos[0], sp->u.l.pos[1] ); @@ -1084,20 +1191,20 @@ static void AddRoadbedPieces( a1 = NormalizeAngle( a1-a0+0.5 ); if ( first==0 ) { if ( a1 < 1.0 && IsNear( p0, sq->u.l.pos[1] ) ) { - sq->u.l.pos[1] = p1; - return; + sq->u.l.pos[1] = p1; + return; } else if ( a1 > 180.0 && a1 < 181.0 && IsNear( p0, sq->u.l.pos[0] ) ) { - sq->u.l.pos[0] = p1; - return; + sq->u.l.pos[0] = p1; + return; } } if ( last==32 ) { if ( a1 < 1.0 && IsNear( p1, sq->u.l.pos[0] ) ) { - sq->u.l.pos[0] = p0; - return; + sq->u.l.pos[0] = p0; + return; } else if ( a1 > 180.0 && a1 < 181.0 && IsNear( p1, sq->u.l.pos[1] ) ) { - sq->u.l.pos[1] = p0; - return; + sq->u.l.pos[1] = p0; + return; } } } @@ -1107,8 +1214,8 @@ static void AddRoadbedPieces( DYNARR_APPEND( trkSeg_t, tempSegs_da, 10 ); sp = &tempSegs(inx); sq = &tempSegs(tempSegs_da.cnt-1); - sq->width = newTurnRoadbedLineWidth/(_DPI); - sq->color = roadbedColor; + sq->lineWidth = newTurnRoadbedLineWidth; + sq->color = newTurnRoadbedColor; if (sp->type == SEG_STRTRK) { sq->type = SEG_STRLIN; sq->u.l.pos[0] = p0; @@ -1122,10 +1229,11 @@ static void AddRoadbedPieces( a0 = NormalizeAngle( sp->u.c.a0 + sp->u.c.a1*(32-last)/32.0 ); } a1 = sp->u.c.a1*(last-first)/32.0; - if (side>0) + if (side>0) { d0 += newTurnRoadbedWidth/2.0; - else + } else { d0 -= newTurnRoadbedWidth/2.0; + } sq->type = SEG_CRVLIN; sq->u.c.center = sp->u.c.center; sq->u.c.radius = d0; @@ -1136,14 +1244,15 @@ static void AddRoadbedPieces( static void AddRoadbedToOneSide( - int trkCnt, - int inx, - ANGLE_T side ) + int trkCnt, + int inx, + ANGLE_T side ) { unsigned long res, res1; int b0, b1; - res = ComputeTurnoutRoadbedSide( &tempSegs(0), trkCnt, inx, side, newTurnRoadbedWidth ); + res = ComputeTurnoutRoadbedSide( &tempSegs(0), trkCnt, inx, side, + newTurnRoadbedWidth ); if ( res == 0L ) { return; } else if ( res == 0xFFFFFFFF ) { @@ -1161,13 +1270,15 @@ static void AddRoadbed( void ) { int trkCnt, inx; trkSeg_p sp; - if ( newTurnRoadbedWidth < newTurnTrackGauge ) + if ( newTurnRoadbedWidth < newTurnTrackGauge ) { return; + } trkCnt = tempSegs_da.cnt; for ( inx=0; inx<trkCnt; inx++ ) { sp = &tempSegs(inx); - if ( sp->type!=SEG_STRTRK && sp->type!=SEG_CRVTRK ) + if ( sp->type!=SEG_STRTRK && sp->type!=SEG_CRVTRK ) { continue; + } AddRoadbedToOneSide( trkCnt, inx, +90 ); AddRoadbedToOneSide( trkCnt, inx, -90 ); } @@ -1181,8 +1292,8 @@ static void AddRoadbed( void ) */ static BOOL_T ComputeCurve( - coOrd *p0, coOrd *p1, DIST_T *radius, - DIST_T len, DIST_T off, ANGLE_T angle ) + coOrd *p0, coOrd *p1, DIST_T *radius, + DIST_T len, DIST_T off, ANGLE_T angle ) { coOrd Pf; coOrd Px, Pc; @@ -1198,8 +1309,9 @@ static BOOL_T ComputeCurve( NoticeMessage( MSG_TODSGN_NO_CONVERGE, _("Ok"), NULL ); return FALSE; } - if (Px.x-newTurnTrackGauge < d) + if (Px.x-newTurnTrackGauge < d) { d = Px.x-newTurnTrackGauge; + } *radius = d * cos( D2R(angle/2.0) ) / sin( D2R(angle/2.0) ); p0->x = Px.x - *radius * sin( D2R(angle/2.0) ) / cos( D2R(angle/2.0) ); @@ -1211,54 +1323,57 @@ static BOOL_T ComputeCurve( #ifndef MKTURNOUT /* For Bezier Segs we need to duplicate the subSegs Array as well */ -void AppendSegs(dynArr_t * target, dynArr_t * source) { +void AppendSegs(dynArr_t * target, dynArr_t * source) +{ #define sourceSegs(N) DYNARR_N( trkSeg_t, *source, N ) #define targetSegs(N) DYNARR_N( trkSeg_t, *target, N ) trkSeg_p src; - for (int i=0;i<source->cnt; i++) { + for (int i=0; i<source->cnt; i++) { src = &sourceSegs(i); addSegBezier(target, src); } } /* Bezier Segs will have subSegs Array - free it before resetting the array */ -void ClearSegs(dynArr_t * target) { - for (int i=0;i<(*target).cnt;i++) { - if (targetSegs(i).type == SEG_BEZTRK) - if (targetSegs(i).bezSegs.ptr) MyFree(targetSegs(i).bezSegs.ptr); - targetSegs(i).bezSegs.ptr = NULL; - targetSegs(i).bezSegs.cnt = 0; - targetSegs(i).bezSegs.max = 0; +void ClearSegs(dynArr_t * target) +{ + for (int i=0; i<(*target).cnt; i++) { + if (targetSegs(i).type == SEG_BEZTRK) { + // Free DA if a BEZTRK + DYNARR_FREE( trkSeg_t, targetSegs(i).bezSegs ); + } else { + // Otherwise just clear it + DYNARR_INIT( trkSeg_t, targetSegs(i).bezSegs ); + } } DYNARR_RESET( trkSeg_t, *target ); } -BOOL_T CallCornuNoBez(coOrd pos[2], coOrd center[2], ANGLE_T angle[2], DIST_T radius[2], dynArr_t * array_p) { +BOOL_T CallCornuNoBez(coOrd pos[2], coOrd center[2], ANGLE_T angle[2], + DIST_T radius[2], dynArr_t * array_p) +{ dynArr_t temp_array; - DYNARR_RESET(trkSeg_t,temp_array); - temp_array.ptr=0; - temp_array.max=0; - + DYNARR_INIT(trkSeg_t,temp_array); wBool_t rc = CallCornu0(pos,center,angle,radius, &temp_array, FALSE); - if (!rc) return FALSE; + if (!rc) { return FALSE; } - for (int i=0;i<temp_array.cnt;i++) { + for (int i=0; i<temp_array.cnt; i++) { trkSeg_p from_seg = &DYNARR_N(trkSeg_t,temp_array,i); if ((from_seg->type == SEG_BEZTRK) || (from_seg->type == SEG_BEZLIN)) { - for (int j=0;j<from_seg->bezSegs.cnt;j++) { + for (int j=0; j<from_seg->bezSegs.cnt; j++) { trkSeg_p sub_seg = &DYNARR_N(trkSeg_t,from_seg->bezSegs,j); DYNARR_APPEND(trkSeg_t,*array_p,5); trkSeg_p to_seg = &DYNARR_N(trkSeg_t,*array_p,(*array_p).cnt-1); to_seg->u = sub_seg->u; to_seg->type = sub_seg->type; to_seg->color = wDrawColorBlack; - to_seg->width = sub_seg->width; + to_seg->lineWidth = sub_seg->lineWidth; } } else { DYNARR_APPEND(trkSeg_t,*array_p,5); @@ -1266,7 +1381,7 @@ BOOL_T CallCornuNoBez(coOrd pos[2], coOrd center[2], ANGLE_T angle[2], DIST_T ra to_seg->u = from_seg->u; to_seg->type = from_seg->type; to_seg->color = wDrawColorBlack; - to_seg->width = from_seg->width; + to_seg->lineWidth = from_seg->lineWidth; } } @@ -1279,22 +1394,20 @@ BOOL_T CallCornuNoBez(coOrd pos[2], coOrd center[2], ANGLE_T angle[2], DIST_T ra static toDesignSchema_t * LoadSegs( - toDesignDesc_t * dp, - wBool_t loadPoints ) + toDesignDesc_t * dp, + wBool_t loadPoints ) { wIndex_t s; int p, p0, p1; DIST_T d; -#ifndef MKTURNOUT - wIndex_t pathLen; -#endif toDesignSchema_t * pp; char *segOrder; coOrd pos; - wIndex_t segCnt; + wIndex_t segCnt = 0; ANGLE_T angle0, angle1, angle2, angle3; trkSeg_p segPtr; #ifndef MKTURNOUT + wIndex_t pathLen; struct { coOrd pos[10]; coOrd center[10]; @@ -1312,19 +1425,23 @@ static toDesignSchema_t * LoadSegs( if ( newTurnAngleMode == 0 && dp->type != NTO_CRV_SECTION ) { /* convert from Frog Num to degrees */ - if ( angle0 > 0 ) + if ( angle0 > 0 ) { angle0 = R2D(asin(1.0 / angle0)); - if ( angle1 > 0 ) + } + if ( angle1 > 0 ) { angle1 = R2D(asin(1.0 / angle1)); - if ( angle2 > 0 ) + } + if ( angle2 > 0 ) { angle2 = R2D(asin(1.0 / angle2)); - if ( angle3 > 0 ) + } + if ( angle3 > 0 ) { angle3 = R2D(asin(1.0 / angle3)); + } } pp = dp->paths; if (loadPoints) { - DYNARR_RESET( trkEndPt_t, tempEndPts_da ); + TempEndPtsReset(); // for ( i=0; i<dp->floatCnt; i++ ) // if ( *(FLOAT_T*)(turnDesignPLs[dp->floats[i].index].valueP) == 0.0 ) // if (dp->type != NTO_CORNU && @@ -1337,73 +1454,78 @@ static toDesignSchema_t * LoadSegs( switch (dp->type) { case NTO_REGULAR: - DYNARR_SET( trkEndPt_t, tempEndPts_da, 3 ); + TempEndPtsSet( 3 ); if ( !ComputeCurve( &points[3], &points[4], &radii[0], - (newTurnLen0), fabs(newTurnOff0), angle0 ) ) + (newTurnLen0), fabs(newTurnOff0), angle0 ) ) { return NULL; + } radii[0] = - radii[0]; points[0].x = points[0].y = points[1].y = 0.0; points[1].x = (newTurnLen1); points[2].y = fabs(newTurnOff0); points[2].x = (newTurnLen0); - tempEndPts(0).pos = points[0]; tempEndPts(0).angle = 270.0; - tempEndPts(1).pos = points[1]; tempEndPts(1).angle = 90.0; - tempEndPts(2).pos = points[2]; tempEndPts(2).angle = 90.0-angle0; + SetEndPt( TempEndPt(0), points[0], 270.0 ); + SetEndPt( TempEndPt(1), points[1], 90.0 ); + SetEndPt( TempEndPt(2), points[2], 90.0-angle0 ); break; case NTO_CURVED: - DYNARR_SET( trkEndPt_t, tempEndPts_da, 3 ); + TempEndPtsSet( 3 ); if ( !ComputeCurve( &points[3], &points[4], &radii[0], - (newTurnLen0), fabs(newTurnOff0), angle0 ) ) + (newTurnLen0), fabs(newTurnOff0), angle0 ) ) { return NULL; + } if ( !ComputeCurve( &points[5], &points[6], &radii[1], - (newTurnLen1), fabs(newTurnOff1), angle1 ) ) + (newTurnLen1), fabs(newTurnOff1), angle1 ) ) { return NULL; + } d = points[3].x - points[5].x; - if ( d < -MIN_TRACK_LENGTH ) + if ( d < -MIN_TRACK_LENGTH ) { pp = &Crv3Schema; - else if ( d > MIN_TRACK_LENGTH ) + } else if ( d > MIN_TRACK_LENGTH ) { pp = &Crv2Schema; - else + } else { pp = &Crv1Schema; + } radii[0] = - radii[0]; radii[1] = - radii[1]; points[0].x = points[0].y = 0.0; points[1].y = fabs(newTurnOff0); points[1].x = (newTurnLen0); points[2].y = fabs(newTurnOff1); points[2].x = (newTurnLen1); - tempEndPts(0).pos = points[0]; tempEndPts(0).angle = 270.0; - tempEndPts(2).pos = points[1]; tempEndPts(2).angle = 90.0-angle0; - tempEndPts(1).pos = points[2]; tempEndPts(1).angle = 90.0-angle1; + SetEndPt( TempEndPt(0), points[0], 270.0 ); + SetEndPt( TempEndPt(2), points[1], 90.0-angle0 ); + SetEndPt( TempEndPt(1), points[2], 90.0-angle1 ); break; #ifndef MKTURNOUT case NTO_CORNU: - + TempEndPtsSet( 3 ); radii[0] = fabs(newTurnRad2); /*Toe*/ radii[1] = fabs(newTurnRad0); /*Inner*/ radii[2] = fabs(newTurnRad1); /*Outer*/ angles[0] = 0.0; /*Base*/ - angles[1] = newTurnAngle0; /*Inner*/ - angles[2] = newTurnAngle1; /*Outer*/ + angles[1] = angle0; /*Inner*/ + angles[2] = angle1; /*Outer*/ pp = &CornuSchema; points[0].x = points[0].y = 0.0; points[1].y = (newTurnOff0); points[1].x = (newTurnLen0); /*Inner*/ points[2].y = (newTurnOff1); points[2].x = (newTurnLen1); /*Outer*/ - tempEndPts(0).pos = points[0]; tempEndPts(0).angle = 270.0; - tempEndPts(2).pos = points[1]; tempEndPts(2).angle = 90.0-angles[1]; - tempEndPts(1).pos = points[2]; tempEndPts(1).angle = 90.0-angles[2]; - + SetEndPt( TempEndPt(0), points[0], 270.0 ); + SetEndPt( TempEndPt(2), points[1], 90.0-angles[1] ); + SetEndPt( TempEndPt(1), points[2], 90.0-angles[2] ); break; #endif case NTO_WYE: case NTO_3WAY: - DYNARR_SET( trkEndPt_t, tempEndPts_da, (dp->type==NTO_3WAY)?4:3 ); + TempEndPtsSet( (dp->type==NTO_3WAY)?4:3 ); if ( !ComputeCurve( &points[3], &points[4], &radii[0], - (newTurnLen0), fabs(newTurnOff0), angle0 ) ) + (newTurnLen0), fabs(newTurnOff0), angle0 ) ) { return NULL; + } if ( !ComputeCurve( &points[5], &points[6], &radii[1], - (newTurnLen1), fabs(newTurnOff1), angle1 ) ) + (newTurnLen1), fabs(newTurnOff1), angle1 ) ) { return NULL; + } points[5].y = - points[5].y; points[6].y = - points[6].y; radii[0] = - radii[0]; @@ -1422,17 +1544,17 @@ static toDesignSchema_t * LoadSegs( } else { pp = (dp->type==NTO_3WAY ? &Tri1Schema : &Wye1Schema ); } - tempEndPts(0).pos = points[0]; tempEndPts(0).angle = 270.0; - tempEndPts(1).pos = points[1]; tempEndPts(1).angle = 90.0-angle0; - tempEndPts(2).pos = points[2]; tempEndPts(2).angle = 90.0+angle1; + SetEndPt( TempEndPt(0), points[0], 270.0 ); + SetEndPt( TempEndPt(1), points[1], 90.0-angle0 ); + SetEndPt( TempEndPt(2), points[2], 90.0+angle1 ); if (dp->type == NTO_3WAY) { - tempEndPts(3).pos = points[7]; tempEndPts(3).angle = 90.0; + SetEndPt( TempEndPt(3), points[7], 90.0 ); } break; #ifndef MKTURNOUT case NTO_CORNUWYE: case NTO_CORNU3WAY: - DYNARR_SET( trkEndPt_t, tempEndPts_da, (dp->type==NTO_CORNU3WAY)?4:3 ); + TempEndPtsSet( (dp->type==NTO_CORNU3WAY)?4:3 ); /* * Construct Wye and 3 Way Turnouts with Cornu curves @@ -1457,9 +1579,9 @@ static toDesignSchema_t * LoadSegs( radii[2] = (newTurnRad1); /*Right*/ radii[3] = (newTurnRad3); /*Center*/ angles[0] = 0.0; /*Base*/ - angles[1] = newTurnAngle0; /*Left*/ - angles[2] = newTurnAngle1; /*Right*/ - angles[3] = newTurnAngle3; /*Center*/ + angles[1] = angle0; /*Left*/ + angles[2] = angle1; /*Right*/ + angles[3] = angle3; /*Center*/ points[0].x = points[0].y = 0.0; /*Base*/ points[1].y = (newTurnOff0); /* Left */ points[1].x = (newTurnLen0); @@ -1472,63 +1594,71 @@ static toDesignSchema_t * LoadSegs( pp = (dp->type==NTO_CORNU3WAY ? &CornuTriSchema : &CornuWyeSchema ); - tempEndPts(0).pos = points[0]; tempEndPts(0).angle = 270.0; + SetEndPt( TempEndPt(0), points[0], 270.0 ); if (newTurnRad0<0.0) { - tempEndPts(1).pos = points[1]; tempEndPts(1).angle = 90.0+angles[1]; + SetEndPt( TempEndPt(1), points[1], 90.0+angles[1] ); } else { - tempEndPts(1).pos = points[1]; tempEndPts(1).angle = 90.0-angles[1]; + SetEndPt( TempEndPt(1), points[1], 90.0-angles[1] ); } if (newTurnRad1<0.0) { - tempEndPts(2).pos = points[2]; tempEndPts(2).angle = 90.0-angles[2]; + SetEndPt( TempEndPt(2), points[2], 90.0-angles[2] ); } else { - tempEndPts(2).pos = points[2]; tempEndPts(2).angle = 90.0+angles[2]; + SetEndPt( TempEndPt(2), points[2], 90.0+angles[2] ); } if (dp->type == NTO_CORNU3WAY) { if (newTurnRad3<0.0) { - tempEndPts(3).pos = points[3]; tempEndPts(3).angle = 90.0+angles[3]; + SetEndPt( TempEndPt(3), points[3], 90.0+angles[3] ); } else { - tempEndPts(3).pos = points[3]; tempEndPts(3).angle = 90.0-angles[3]; + SetEndPt( TempEndPt(3), points[3], 90.0-angles[3] ); } } DIST_T end_length = MIN_TRACK_LENGTH; - for (int i=0;i<((dp->type==NTO_CORNU3WAY)?4:3);i++) { + for (int i=0; i<((dp->type==NTO_CORNU3WAY)?4:3); i++) { if (radii[i] == 0.0) { - if (i==2) - Translate(&end_points[i], points[i], NormalizeAngle(90.0+angles[i]+180), end_length); - else - Translate(&end_points[i], points[i], NormalizeAngle(90.0-angles[i]+(i==0?0.0:180.0)), end_length); + if (i==2) { + Translate(&end_points[i], points[i], NormalizeAngle(90.0+angles[i]+180), + end_length); + } else { + Translate(&end_points[i], points[i], + NormalizeAngle(90.0-angles[i]+(i==0?0.0:180.0)), end_length); + } end_angles[i] = angles[i]; } else { if (i!=2) { - if (((i==0) && radii[0]>0.0) || ((i==1 || i==3) && radii[i]>0.0)) + if (((i==0) && radii[0]>0.0) || ((i==1 || i==3) && radii[i]>0.0)) { Translate(&end_centers[i], points[i], -angles[i], fabs(radii[i])); - else + } else { Translate(&end_centers[i], points[i], angles[i]+180, fabs(radii[i])); + } end_arcs[i] = (radii[i]>=0?1:-1)*R2D(end_length/fabs(radii[i])); } else { - if (radii[2]>0.0) + if (radii[2]>0.0) { Translate(&end_centers[i], points[i], angles[i]+180, fabs(radii[i])); - else + } else { Translate(&end_centers[i], points[i], -angles[i], fabs(radii[i])); + } end_arcs[i] = (radii[i]>=0?-1:1)*R2D(end_length/fabs(radii[i])); } end_points[i] = points[i]; Rotate(&end_points[i],end_centers[i],end_arcs[i]); end_angles[i] = angles[i]+end_arcs[i]; } -LogPrintf( "ctoDes0-%d: EP(%f,%f) NEP(%f,%f) EA(%f) NEA(%f) R(%f) ARC(%f) EC(%f,%f) \n", - i+1,points[i].x,points[i].y,end_points[i].x,end_points[i].y,angles[i],end_angles[i],radii[i],end_arcs[i], - end_centers[i].x,end_centers[i].y); + LOG( log_cornuturnoutdesigner, 1, + ( "ctoDes0-%d: EP(%f,%f) NEP(%f,%f) EA(%f) NEA(%f) R(%f) ARC(%f) EC(%f,%f) \n", + \ + i+1,points[i].x,points[i].y,end_points[i].x,end_points[i].y,angles[i], + end_angles[i],radii[i],end_arcs[i], \ + end_centers[i].x,end_centers[i].y) ); } wBool_t LH_main = TRUE, LH_first = TRUE; cornuData.pos[0] = end_points[0]; /*Start*/ if (dp->type == NTO_CORNU3WAY) { - if (newTurnToeR < newTurnToeL) LH_first = FALSE; + if (newTurnToeR < newTurnToeL) { LH_first = FALSE; } cornuData.pos[1] = end_points[3]; /*Center for First Time */ cornuData.pos[5] = end_points[3]; /*Center for last time*/ } else if (newTurnRad1>=0.0) { @@ -1546,44 +1676,53 @@ LogPrintf( "ctoDes0-%d: EP(%f,%f) NEP(%f,%f) EA(%f) NEA(%f) R(%f) ARC(%f) EC(%f, cornuData.pos[5] = end_points[3]; /*Center */ } - if (radii[0] == 0.0) /* Base */ + if (radii[0] == 0.0) { /* Base */ cornuData.center[0] = zero; - else { + } else { cornuData.center[0].x = end_points[0].x; cornuData.center[0].y = end_points[0].y + radii[0]; } - if (radii[1] == 0.0) /* Left */ + if (radii[1] == 0.0) { /* Left */ cornuData.center[7] = zero; - else if (radii[1] >0.0) + } else if (radii[1] >0.0) { Translate(&cornuData.center[7], cornuData.pos[7], -end_angles[1], radii[1]); - else - Translate(&cornuData.center[7], cornuData.pos[7], 180.0+end_angles[1], radii[1]); + } else { + Translate(&cornuData.center[7], cornuData.pos[7], 180.0+end_angles[1], + radii[1]); + } - if (radii[2] == 0.0) /* Right */ + if (radii[2] == 0.0) { /* Right */ cornuData.center[9] = zero; - else if (radii[2] >0.0) - Translate(&cornuData.center[9], cornuData.pos[9], 180.0+end_angles[2], radii[2]); - else + } else if (radii[2] >0.0) { + Translate(&cornuData.center[9], cornuData.pos[9], 180.0+end_angles[2], + radii[2]); + } else { Translate(&cornuData.center[9], cornuData.pos[9], -end_angles[2], radii[2]); + } if (dp->type == NTO_CORNU3WAY) { - if (radii[3] == 0.0) /* Center */ + if (radii[3] == 0.0) { /* Center */ cornuData.center[5] = zero; - else if (radii[3] >0.0) + } else if (radii[3] >0.0) { Translate(&cornuData.center[5], cornuData.pos[5], -end_angles[3], radii[3]); - else - Translate(&cornuData.center[5], cornuData.pos[5], 180.0+end_angles[3], radii[3]); + } else { + Translate(&cornuData.center[5], cornuData.pos[5], 180.0+end_angles[3], + radii[3]); + } } /* Set up for calculation of Toe(s) */ if (dp->type == NTO_CORNU3WAY) { - cornuData.center[1] = cornuData.center[5]; /*For Toe1 calc always use center */ - cornuData.center[3] = cornuData.center[5]; /*For Toe2 calc always use center*/ + cornuData.center[1] = + cornuData.center[5]; /*For Toe1 calc always use center */ + cornuData.center[3] = + cornuData.center[5]; /*For Toe2 calc always use center*/ } else if (LH_main) { cornuData.center[1] = cornuData.center[7]; /* Dominant Curve Left */ - } else - cornuData.center[1] = cornuData.center[9]; /* Right */ + } else { + cornuData.center[1] = cornuData.center[9]; /* Right */ + } cornuData.angle[0] = 270.0; /*Always*/ if (dp->type == NTO_CORNU3WAY) { @@ -1614,11 +1753,7 @@ LogPrintf( "ctoDes0-%d: EP(%f,%f) NEP(%f,%f) EA(%f) NEA(%f) R(%f) ARC(%f) EC(%f, /* Ready to find Toe points */ DYNARR_RESET( trkSeg_t, tempSegs_da ); - trkSeg_t * temp_p; - temp_p = &tempSegs(0); - - - DIST_T radius; + DIST_T radius = 0.0; coOrd center; ANGLE_T angle; int inx,subSeg; @@ -1635,12 +1770,14 @@ LogPrintf( "ctoDes0-%d: EP(%f,%f) NEP(%f,%f) EA(%f) NEA(%f) R(%f) ARC(%f) EC(%f, } else { /*Find Toe 1 from curve */ - CallCornu0(&cornuData.pos[0],&cornuData.center[0],&cornuData.angle[0],&cornuData.radius[0],&tempSegs_da, FALSE); + CallCornu0(&cornuData.pos[0],&cornuData.center[0],&cornuData.angle[0], + &cornuData.radius[0],&tempSegs_da, FALSE); /*Get ToeAngle/Radius/Center for first toe */ pos.x = end_points[0].x+(LH_first?newTurnToeL:newTurnToeR); pos.y = end_points[0].y; /* This will be close to but not on the curve */ - angle = GetAngleSegs(tempSegs_da.cnt,(trkSeg_t *)(tempSegs_da.ptr),&pos,&inx,NULL,&back,&subSeg,&neg); + angle = GetAngleSegs(tempSegs_da.cnt,&tempSegs(0),&pos,&inx, + NULL,&back,&subSeg,&neg); segPtr = &DYNARR_N(trkSeg_t, tempSegs_da, inx); if (segPtr->type == SEG_BEZTRK) { @@ -1692,18 +1829,19 @@ LogPrintf( "ctoDes0-%d: EP(%f,%f) NEP(%f,%f) EA(%f) NEA(%f) R(%f) ARC(%f) EC(%f, } if (dp->type == NTO_CORNU3WAY) { - if (newTurnToeR!=newTurnToeL) { + if (newTurnToeR!=newTurnToeL) { /* Second Toe */ - if (cornuData.radius[0] == 0.0) { + if (cornuData.radius[0] == 0.0) { pos.x = end_points[0].x+(LH_first?newTurnToeR:newTurnToeL)-MIN_TRACK_LENGTH; pos.y = 0.0; angle = 90.0; radius = 0.0; center = zero; - } else { + } else { pos.x = end_points[0].x+(LH_first?newTurnToeR:newTurnToeL); pos.y = end_points[0].y; /* This will be close to but not on the curve */ - angle = GetAngleSegs(tempSegs_da.cnt,(trkSeg_t *)(tempSegs_da.ptr),&pos,&inx,NULL,&back,&subSeg,&neg); + angle = GetAngleSegs(tempSegs_da.cnt,&tempSegs(0),&pos,&inx, + NULL,&back,&subSeg,&neg); segPtr = &DYNARR_N(trkSeg_t, tempSegs_da, inx); if (segPtr->type == SEG_BEZTRK) { @@ -1717,7 +1855,7 @@ LogPrintf( "ctoDes0-%d: EP(%f,%f) NEP(%f,%f) EA(%f) NEA(%f) R(%f) ARC(%f) EC(%f, center = segPtr->u.c.center; radius = fabs(segPtr->u.c.radius); } - } + } cornuData.pos[3] = pos; cornuData.center[3] = center; cornuData.angle[3] = angle; @@ -1762,55 +1900,63 @@ LogPrintf( "ctoDes0-%d: EP(%f,%f) NEP(%f,%f) EA(%f) NEA(%f) R(%f) ARC(%f) EC(%f, ClearSegs(&tempSegs_da); ClearSegs(&cornuSegs_da); - int Toe1Seg = 0 , Toe2Seg = 0, CenterEndSeg = 0, LeftEndSeg = 0, RightEndSeg = 0; + int Toe1Seg = 0, Toe2Seg = 0, CenterEndSeg = 0, LeftEndSeg = 0, RightEndSeg = 0; /* Override if at zero radius at base don't compute end */ if (cornuData.radius[0] == 0.0) { DYNARR_APPEND(trkSeg_t,tempSegs_da,1); - temp_p = &DYNARR_LAST(trkSeg_t,tempSegs_da); + trkSeg_p temp_p = &DYNARR_LAST(trkSeg_t,tempSegs_da); temp_p->type = SEG_STRTRK; temp_p->color = wDrawColorBlack; - temp_p->width = 0.0; + temp_p->lineWidth = 0.0; temp_p->u.l.pos[0] = zero; temp_p->u.l.pos[1] = cornuData.pos[0]; -LogPrintf( "ctoDes1: P0(%f,%f) P1(%f,%f) \n", - temp_p->u.l.pos[0].x,temp_p->u.l.pos[0].y,temp_p->u.l.pos[1].x,temp_p->u.l.pos[1].y ); + LOG( log_cornuturnoutdesigner, 1, ( "ctoDes1: P0(%f,%f) P1(%f,%f) \n", \ + temp_p->u.l.pos[0].x,temp_p->u.l.pos[0].y,temp_p->u.l.pos[1].x, + temp_p->u.l.pos[1].y ) ); } else { DYNARR_APPEND(trkSeg_t,tempSegs_da,1); - temp_p = &DYNARR_LAST(trkSeg_t,tempSegs_da); + trkSeg_p temp_p = &DYNARR_LAST(trkSeg_t,tempSegs_da); temp_p->type = SEG_CRVTRK; temp_p->color = wDrawColorBlack; - temp_p->width = 0.0; + temp_p->lineWidth = 0.0; temp_p->u.c.radius = fabs(radii[0]);; - if (radii[0]>0.0) + if (radii[0]>0.0) { temp_p->u.c.a0 = FindAngle(end_centers[0],end_points[0]); - else + } else { temp_p->u.c.a0 = FindAngle(end_centers[0],points[0]); + } temp_p->u.c.a1 = fabs(end_arcs[0]); temp_p->u.c.center = end_centers[0]; coOrd rp0,rp1; Translate(&rp0,temp_p->u.c.center,temp_p->u.c.a0,temp_p->u.c.radius); - Translate(&rp1,temp_p->u.c.center,temp_p->u.c.a0+temp_p->u.c.a1,temp_p->u.c.radius); -LogPrintf( "ctoDes1: R(%f) A0(%f) A1(%f) C(%f,%f) P(%f,%f), EP(%f,%f) RP0(%f,%f) RP1(%f,%f)\n", - temp_p->u.c.radius,temp_p->u.c.a0,temp_p->u.c.a1,temp_p->u.c.center.x,temp_p->u.c.center.y, - points[0].x,points[0].y,end_points[0].x,end_points[0].y, - rp0.x,rp0.y,rp1.x,rp1.y); + Translate(&rp1,temp_p->u.c.center,temp_p->u.c.a0+temp_p->u.c.a1, + temp_p->u.c.radius); + LOG( log_cornuturnoutdesigner, 1, + ( "ctoDes1: R(%f) A0(%f) A1(%f) C(%f,%f) P(%f,%f), EP(%f,%f) RP0(%f,%f) RP1(%f,%f)\n", + \ + temp_p->u.c.radius,temp_p->u.c.a0,temp_p->u.c.a1,temp_p->u.c.center.x, + temp_p->u.c.center.y, \ + points[0].x,points[0].y,end_points[0].x,end_points[0].y, \ + rp0.x,rp0.y,rp1.x,rp1.y) ) ; } //If Radius zero, just a straight to the First Toe if offset if (cornuData.radius[0] == 0.0) { if ((cornuData.pos[0].x != cornuData.pos[1].x) || (cornuData.pos[0].y != cornuData.pos[1].y)) { DYNARR_APPEND(trkSeg_t,tempSegs_da,1); - temp_p = &DYNARR_LAST(trkSeg_t,tempSegs_da); + trkSeg_p temp_p = &DYNARR_LAST(trkSeg_t,tempSegs_da); temp_p->type = SEG_STRTRK; temp_p->color = wDrawColorBlack; - temp_p->width = 0.0; + temp_p->lineWidth = 0.0; temp_p->u.l.pos[0] = cornuData.pos[0]; temp_p->u.l.pos[1] = cornuData.pos[1]; } } else if ((cornuData.pos[0].x != cornuData.pos[1].x) || - (cornuData.pos[0].y != cornuData.pos[1].y) ) - CallCornuNoBez(&cornuData.pos[0],&cornuData.center[0],&cornuData.angle[0],&cornuData.radius[0],&tempSegs_da); + (cornuData.pos[0].y != cornuData.pos[1].y) ) { + CallCornuNoBez(&cornuData.pos[0],&cornuData.center[0],&cornuData.angle[0], + &cornuData.radius[0],&tempSegs_da); + } Toe1Seg = tempSegs_da.cnt; @@ -1819,15 +1965,17 @@ LogPrintf( "ctoDes1: R(%f) A0(%f) A1(%f) C(%f,%f) P(%f,%f), EP(%f,%f) RP0(%f,%f) /* Toe1 to Toe2 in tempSegs array */ if (cornuData.radius[0] == 0.0) { DYNARR_APPEND(trkSeg_t,cornuSegs_da,1); - temp_p = &DYNARR_LAST(trkSeg_t,cornuSegs_da); + trkSeg_p temp_p = &DYNARR_LAST(trkSeg_t,cornuSegs_da); temp_p->type = SEG_STRTRK; temp_p->color = wDrawColorBlack; - temp_p->width = 0.0; + temp_p->lineWidth = 0.0; temp_p->u.l.pos[0] = cornuData.pos[2]; temp_p->u.l.pos[1] = cornuData.pos[3]; } else if ((cornuData.pos[2].x != cornuData.pos[3].x) || - (cornuData.pos[2].y != cornuData.pos[3].y) ) - CallCornuNoBez(&cornuData.pos[2],&cornuData.center[2],&cornuData.angle[2],&cornuData.radius[2],&cornuSegs_da); + (cornuData.pos[2].y != cornuData.pos[3].y) ) { + CallCornuNoBez(&cornuData.pos[2],&cornuData.center[2],&cornuData.angle[2], + &cornuData.radius[2],&cornuSegs_da); + } Toe2Seg = cornuSegs_da.cnt+Toe1Seg; /* Add to second cornu to tempSegs array */ @@ -1838,38 +1986,45 @@ LogPrintf( "ctoDes1: R(%f) A0(%f) A1(%f) C(%f,%f) P(%f,%f), EP(%f,%f) RP0(%f,%f) Toe2Seg = Toe1Seg; //No Toe2 } /* Toe2 to Center in cornuSegs array */ - CallCornuNoBez(&cornuData.pos[4],&cornuData.center[4],&cornuData.angle[4],&cornuData.radius[4],&cornuSegs_da); + CallCornuNoBez(&cornuData.pos[4],&cornuData.center[4],&cornuData.angle[4], + &cornuData.radius[4],&cornuSegs_da); if (cornuData.radius[5] == 0.0) { DYNARR_APPEND(trkSeg_t,cornuSegs_da,1); - temp_p = &DYNARR_LAST(trkSeg_t,cornuSegs_da); + trkSeg_p temp_p = &DYNARR_LAST(trkSeg_t,cornuSegs_da); temp_p->type = SEG_STRTRK; temp_p->color = wDrawColorBlack; - temp_p->width = 0.0; + temp_p->lineWidth = 0.0; temp_p->u.l.pos[0] = cornuData.pos[5]; temp_p->u.l.pos[1] = points[3]; - LogPrintf( "ctoDes2: P0(%f,%f) P1(%f,%f) \n", - temp_p->u.l.pos[0].x,temp_p->u.l.pos[0].y,temp_p->u.l.pos[1].x,temp_p->u.l.pos[1].y ); + LOG( log_cornuturnoutdesigner, 1, ( "ctoDes2: P0(%f,%f) P1(%f,%f) \n", \ + temp_p->u.l.pos[0].x,temp_p->u.l.pos[0].y,temp_p->u.l.pos[1].x, + temp_p->u.l.pos[1].y )) ; } else { DYNARR_APPEND(trkSeg_t,cornuSegs_da,1); - temp_p = &DYNARR_LAST(trkSeg_t,cornuSegs_da); + trkSeg_p temp_p = &DYNARR_LAST(trkSeg_t,cornuSegs_da); temp_p->type = SEG_CRVTRK; temp_p->color = wDrawColorBlack; - temp_p->width = 0.0; + temp_p->lineWidth = 0.0; temp_p->u.c.radius = -radii[3]; //Assumed Left - if (radii[3]>0) + if (radii[3]>0) { temp_p->u.c.a0 = FindAngle(end_centers[3],points[3]); - else + } else { temp_p->u.c.a0 = FindAngle(end_centers[3],end_points[3]); + } temp_p->u.c.a1 = fabs(end_arcs[3]); temp_p->u.c.center = end_centers[3]; coOrd rp0,rp1; Translate(&rp0,temp_p->u.c.center,temp_p->u.c.a0,temp_p->u.c.radius); - Translate(&rp1,temp_p->u.c.center,temp_p->u.c.a0+temp_p->u.c.a1,temp_p->u.c.radius); - LogPrintf( "ctoDes2: R(%f) A0(%f) A1(%f) C(%f,%f) P(%f,%f) EP(%f,%f) RP0(%f,%f) RP1(%f,%f)\n", - temp_p->u.c.radius,temp_p->u.c.a0,temp_p->u.c.a1,temp_p->u.c.center.x,temp_p->u.c.center.y, - points[3].x,points[3].y,end_points[3].x,end_points[3].y, - rp0.x,rp0.y,rp1.x,rp1.y); + Translate(&rp1,temp_p->u.c.center,temp_p->u.c.a0+temp_p->u.c.a1, + temp_p->u.c.radius); + LOG( log_cornuturnoutdesigner, 1, + ( "ctoDes2: R(%f) A0(%f) A1(%f) C(%f,%f) P(%f,%f) EP(%f,%f) RP0(%f,%f) RP1(%f,%f)\n", + \ + temp_p->u.c.radius,temp_p->u.c.a0,temp_p->u.c.a1,temp_p->u.c.center.x, + temp_p->u.c.center.y, \ + points[3].x,points[3].y,end_points[3].x,end_points[3].y, \ + rp0.x,rp0.y,rp1.x,rp1.y) ); } CenterEndSeg = cornuSegs_da.cnt+Toe2Seg; @@ -1882,38 +2037,45 @@ LogPrintf( "ctoDes1: R(%f) A0(%f) A1(%f) C(%f,%f) P(%f,%f), EP(%f,%f) RP0(%f,%f) } /* Left in cornuSegs array*/ - CallCornuNoBez(&cornuData.pos[6],&cornuData.center[6],&cornuData.angle[6],&cornuData.radius[6],&cornuSegs_da); + CallCornuNoBez(&cornuData.pos[6],&cornuData.center[6],&cornuData.angle[6], + &cornuData.radius[6],&cornuSegs_da); if (cornuData.radius[7] == 0.0) { DYNARR_APPEND(trkSeg_t,cornuSegs_da,1); - temp_p = &DYNARR_LAST(trkSeg_t,cornuSegs_da); + trkSeg_p temp_p = &DYNARR_LAST(trkSeg_t,cornuSegs_da); temp_p->type = SEG_STRTRK; temp_p->color = wDrawColorBlack; - temp_p->width = 0.0; + temp_p->lineWidth = 0.0; temp_p->u.l.pos[0] = cornuData.pos[7]; temp_p->u.l.pos[1] = points[1]; -LogPrintf( "ctoDes2: P0(%f,%f) P1(%f,%f) \n", - temp_p->u.l.pos[0].x,temp_p->u.l.pos[0].y,temp_p->u.l.pos[1].x,temp_p->u.l.pos[1].y ); + LOG( log_cornuturnoutdesigner, 1, ( "ctoDes2: P0(%f,%f) P1(%f,%f) \n", \ + temp_p->u.l.pos[0].x,temp_p->u.l.pos[0].y,temp_p->u.l.pos[1].x, + temp_p->u.l.pos[1].y ) ); } else { DYNARR_APPEND(trkSeg_t,cornuSegs_da,1); - temp_p = &DYNARR_LAST(trkSeg_t,cornuSegs_da); + trkSeg_p temp_p = &DYNARR_LAST(trkSeg_t,cornuSegs_da); temp_p->type = SEG_CRVTRK; temp_p->color = wDrawColorBlack; - temp_p->width = 0.0; + temp_p->lineWidth = 0.0; temp_p->u.c.radius = -radii[1]; //Negative relative to left - if (radii[1]>0) + if (radii[1]>0) { temp_p->u.c.a0 = FindAngle(end_centers[1],points[1]); - else + } else { temp_p->u.c.a0 = FindAngle(end_centers[1],end_points[1]); + } temp_p->u.c.a1 = fabs(end_arcs[1]); temp_p->u.c.center = end_centers[1]; coOrd rp0,rp1; Translate(&rp0,temp_p->u.c.center,temp_p->u.c.a0,temp_p->u.c.radius); - Translate(&rp1,temp_p->u.c.center,temp_p->u.c.a0+temp_p->u.c.a1,temp_p->u.c.radius); -LogPrintf( "ctoDes2: R(%f) A0(%f) A1(%f) C(%f,%f) P(%f,%f) EP(%f,%f) RP0(%f,%f) RP1(%f,%f)\n", - temp_p->u.c.radius,temp_p->u.c.a0,temp_p->u.c.a1,temp_p->u.c.center.x,temp_p->u.c.center.y, - points[1].x,points[1].y,end_points[1].x,end_points[1].y, - rp0.x,rp0.y,rp1.x,rp1.y); + Translate(&rp1,temp_p->u.c.center,temp_p->u.c.a0+temp_p->u.c.a1, + temp_p->u.c.radius); + LOG( log_cornuturnoutdesigner, 1, + ( "ctoDes2: R(%f) A0(%f) A1(%f) C(%f,%f) P(%f,%f) EP(%f,%f) RP0(%f,%f) RP1(%f,%f)\n", + \ + temp_p->u.c.radius,temp_p->u.c.a0,temp_p->u.c.a1,temp_p->u.c.center.x, + temp_p->u.c.center.y, \ + points[1].x,points[1].y,end_points[1].x,end_points[1].y, \ + rp0.x,rp0.y,rp1.x,rp1.y) ); } LeftEndSeg = cornuSegs_da.cnt+CenterEndSeg; @@ -1924,38 +2086,45 @@ LogPrintf( "ctoDes2: R(%f) A0(%f) A1(%f) C(%f,%f) P(%f,%f) EP(%f,%f) RP0(%f,%f) ClearSegs(&cornuSegs_da); /* Right in cornuSegs array*/ - CallCornuNoBez(&cornuData.pos[8],&cornuData.center[8],&cornuData.angle[8],&cornuData.radius[8],&cornuSegs_da); + CallCornuNoBez(&cornuData.pos[8],&cornuData.center[8],&cornuData.angle[8], + &cornuData.radius[8],&cornuSegs_da); if (cornuData.radius[9] == 0.0) { DYNARR_APPEND(trkSeg_t,cornuSegs_da,1); - temp_p = &DYNARR_LAST(trkSeg_t,cornuSegs_da); + trkSeg_p temp_p = &DYNARR_LAST(trkSeg_t,cornuSegs_da); temp_p->type = SEG_STRTRK; temp_p->color = wDrawColorBlack; - temp_p->width = 0.0; + temp_p->lineWidth = 0.0; temp_p->u.l.pos[0] = cornuData.pos[9]; temp_p->u.l.pos[1] = points[2]; -LogPrintf( "ctoDes2: P0(%f,%f) P1(%f,%f) \n", - temp_p->u.l.pos[0].x,temp_p->u.l.pos[0].y,temp_p->u.l.pos[1].x,temp_p->u.l.pos[1].y ); + LOG( log_cornuturnoutdesigner, 1, ( "ctoDes2: P0(%f,%f) P1(%f,%f) \n", \ + temp_p->u.l.pos[0].x,temp_p->u.l.pos[0].y,temp_p->u.l.pos[1].x, + temp_p->u.l.pos[1].y ) ); } else { DYNARR_APPEND(trkSeg_t,cornuSegs_da,1); - temp_p = &DYNARR_LAST(trkSeg_t,cornuSegs_da); + trkSeg_p temp_p = &DYNARR_LAST(trkSeg_t,cornuSegs_da); temp_p->type = SEG_CRVTRK; temp_p->color = wDrawColorBlack; - temp_p->width = 0.0; + temp_p->lineWidth = 0.0; temp_p->u.c.radius = radii[2]; - if (radii[2]>0) + if (radii[2]>0) { temp_p->u.c.a0 = FindAngle(end_centers[2],cornuData.pos[9]); - else + } else { temp_p->u.c.a0 = FindAngle(end_centers[2],end_points[2]); + } temp_p->u.c.a1 = fabs(end_arcs[2]); temp_p->u.c.center = end_centers[2]; coOrd rp0,rp1; Translate(&rp0,temp_p->u.c.center,temp_p->u.c.a0,temp_p->u.c.radius); - Translate(&rp1,temp_p->u.c.center,temp_p->u.c.a0+temp_p->u.c.a1,temp_p->u.c.radius); -LogPrintf( "ctoDes2: R(%f) A0(%f) A1(%f) C(%f,%f) P(%f,%f) EP(%f,%f) RP0(%f,%f) RP1(%f,%f)\n", - temp_p->u.c.radius,temp_p->u.c.a0,temp_p->u.c.a1,temp_p->u.c.center.x,temp_p->u.c.center.y, - points[2].x,points[2].y,end_points[2].x,end_points[2].y, - rp0.x,rp0.y,rp1.x,rp1.y); + Translate(&rp1,temp_p->u.c.center,temp_p->u.c.a0+temp_p->u.c.a1, + temp_p->u.c.radius); + LOG( log_cornuturnoutdesigner, 1, + ( "ctoDes2: R(%f) A0(%f) A1(%f) C(%f,%f) P(%f,%f) EP(%f,%f) RP0(%f,%f) RP1(%f,%f)\n", + \ + temp_p->u.c.radius,temp_p->u.c.a0,temp_p->u.c.a1,temp_p->u.c.center.x, + temp_p->u.c.center.y, \ + points[2].x,points[2].y,end_points[2].x,end_points[2].y, \ + rp0.x,rp0.y,rp1.x,rp1.y) ); } RightEndSeg = cornuSegs_da.cnt+LeftEndSeg; @@ -1976,7 +2145,7 @@ LogPrintf( "ctoDes2: R(%f) A0(%f) A1(%f) C(%f,%f) P(%f,%f) EP(%f,%f) RP0(%f,%f) if (dp->type == NTO_CORNU3WAY) { strcpy(pathChar,"Normal"); /* Also resets array */ pathLen = (wIndex_t)strlen(pathChar)+1; - for (uint8_t i=0;i<CenterEndSeg;i++) { + for (uint8_t i=0; i<CenterEndSeg; i++) { pathChar[pathLen] = i+1; pathLen++; } @@ -1990,18 +2159,18 @@ LogPrintf( "ctoDes2: R(%f) A0(%f) A1(%f) C(%f,%f) P(%f,%f) EP(%f,%f) RP0(%f,%f) strcpy(pathChar,"Left"); pathLen = (wIndex_t)strlen(pathChar)+1; } - for (uint8_t i=0;i<Toe1Seg;i++) { + for (uint8_t i=0; i<Toe1Seg; i++) { pathChar[pathLen] = i+1; pathLen++; } if ((dp->type == NTO_CORNU3WAY) && !LH_first && (newTurnToeR != newTurnToeL)) { - for (uint8_t i=Toe1Seg;i<Toe2Seg;i++) { + for (uint8_t i=Toe1Seg; i<Toe2Seg; i++) { pathChar[pathLen] = i+1; pathLen++; } } - for (uint8_t i=CenterEndSeg;i<LeftEndSeg;i++) { + for (uint8_t i=CenterEndSeg; i<LeftEndSeg; i++) { pathChar[pathLen] = i+1; pathLen++; } @@ -2014,17 +2183,17 @@ LogPrintf( "ctoDes2: R(%f) A0(%f) A1(%f) C(%f,%f) P(%f,%f) EP(%f,%f) RP0(%f,%f) sprintf(&pathChar[pathLen],"%s","Right"); pathLen += (wIndex_t)strlen(&pathChar[pathLen])+1; - for (uint8_t i=0;i<Toe1Seg;i++) { + for (uint8_t i=0; i<Toe1Seg; i++) { pathChar[pathLen] = i+1; pathLen++; } if ((dp->type == NTO_CORNU3WAY) && LH_first && (newTurnToeR != newTurnToeL)) { - for (uint8_t i=Toe1Seg;i<Toe2Seg;i++) { + for (uint8_t i=Toe1Seg; i<Toe2Seg; i++) { pathChar[pathLen] = i+1; pathLen++; } } - for (uint8_t i=LeftEndSeg;i<RightEndSeg;i++) { + for (uint8_t i=LeftEndSeg; i<RightEndSeg; i++) { pathChar[pathLen] = i+1; pathLen++; } @@ -2045,12 +2214,13 @@ LogPrintf( "ctoDes2: R(%f) A0(%f) A1(%f) C(%f,%f) P(%f,%f) EP(%f,%f) RP0(%f,%f) case NTO_S_SLIP: case NTO_CROSSING: if (dp->type == NTO_D_SLIP) { - if (newTurnSlipMode == 1) + if (newTurnSlipMode == 1) { pp = &DoubleSlipSchema2; - else + } else { pp = &DoubleSlipSchema; + } } - DYNARR_SET( trkEndPt_t, tempEndPts_da, 4 ); + TempEndPtsSet( 4 ); points[0].x = points[0].y = points[1].y = 0.0; points[1].x = (newTurnLen0); pos.y = 0; pos.x = (newTurnLen0)/2.0; @@ -2061,24 +2231,25 @@ LogPrintf( "ctoDes2: R(%f) A0(%f) A1(%f) C(%f,%f) P(%f,%f) EP(%f,%f) RP0(%f,%f) if (dp->type != NTO_CROSSING) { Translate( &pos, points[3], 90.0+angle0, -newTurnTrackGauge ); if (!ComputeCurve( &points[4], &points[5], &radii[0], - pos.x, fabs(pos.y), angle0 )) /*???*/ + pos.x, fabs(pos.y), angle0 )) { /*???*/ return NULL; + } radii[1] = - radii[0]; points[5].y = - points[5].y; points[6].y = 0; points[6].x = cpos.x-(points[4].x-cpos.x); points[7].y = -points[5].y; points[7].x = cpos.x-(points[5].x-cpos.x); } - tempEndPts(0).pos = points[0]; tempEndPts(0).angle = 270.0; - tempEndPts(1).pos = points[1]; tempEndPts(1).angle = 90.0; - tempEndPts(2).pos = points[2]; tempEndPts(2).angle = 270.0+angle0; - tempEndPts(3).pos = points[3]; tempEndPts(3).angle = 90.0+angle0; + SetEndPt( TempEndPt(0), points[0], 270.0 ); + SetEndPt( TempEndPt(1), points[1], 90.0 ); + SetEndPt( TempEndPt(2), points[2], 270.0+angle0 ); + SetEndPt( TempEndPt(3), points[3], 90.0+angle0 ); break; case NTO_R_CROSSOVER: case NTO_L_CROSSOVER: case NTO_D_CROSSOVER: - DYNARR_SET( trkEndPt_t, tempEndPts_da, 4 ); + TempEndPtsSet( 4 ); d = (newTurnLen0)/2.0 - newTurnTrackGauge; if (d < 0.0) { NoticeMessage( MSG_TODSGN_CROSSOVER_TOO_SHORT, _("Ok"), NULL ); @@ -2090,8 +2261,9 @@ LogPrintf( "ctoDes2: R(%f) A0(%f) A1(%f) C(%f,%f) P(%f,%f) EP(%f,%f) RP0(%f,%f) points[2].y = fabs(newTurnOff0); points[2].x = 0.0; points[3].y = fabs(newTurnOff0); points[3].x = (newTurnLen0); if (!ComputeCurve( &points[4], &points[5], &radii[1], - (newTurnLen0)/2.0, fabs(newTurnOff0)/2.0, angle0 ) ) + (newTurnLen0)/2.0, fabs(newTurnOff0)/2.0, angle0 ) ) { return NULL; + } radii[0] = - radii[1]; points[6].y = 0.0; points[6].x = (newTurnLen0)-points[4].x; points[7].y = points[5].y; points[7].x = (newTurnLen0)-points[5].x; @@ -2099,35 +2271,35 @@ LogPrintf( "ctoDes2: R(%f) A0(%f) A1(%f) C(%f,%f) P(%f,%f) EP(%f,%f) RP0(%f,%f) points[9].y = fabs(newTurnOff0)-points[5].y; points[9].x = points[5].x; points[10].y = fabs(newTurnOff0); points[10].x = points[6].x; points[11].y = points[9].y; points[11].x = points[7].x; - tempEndPts(0).pos = points[0]; tempEndPts(0).angle = 270.0; - tempEndPts(1).pos = points[1]; tempEndPts(1).angle = 90.0; - tempEndPts(2).pos = points[2]; tempEndPts(2).angle = 270.0; - tempEndPts(3).pos = points[3]; tempEndPts(3).angle = 90.0; + SetEndPt( TempEndPt(0), points[0], 270.0 ); + SetEndPt( TempEndPt(1), points[1], 90.0 ); + SetEndPt( TempEndPt(2), points[2], 270.0 ); + SetEndPt( TempEndPt(3), points[3], 90.0 ); break; case NTO_STR_SECTION: - DYNARR_SET( trkEndPt_t, tempEndPts_da, 2 ); + TempEndPtsSet( 2 ); points[0].y = points[0].x = 0; points[1].y = 0/*(newTurnOff1)*/; points[1].x = (newTurnLen0); - tempEndPts(0).pos = points[0]; tempEndPts(0).angle = 270.0; - tempEndPts(1).pos = points[1]; tempEndPts(1).angle = 90.0; + SetEndPt( TempEndPt(0), points[0], 270.0 ); + SetEndPt( TempEndPt(1), points[1], 90.0 ); break; case NTO_CRV_SECTION: - DYNARR_SET( trkEndPt_t, tempEndPts_da, 2 ); + TempEndPtsSet( 2 ); points[0].y = points[0].x = 0; points[1].y = (newTurnLen0) * (1.0 - cos( D2R(angle0) ) ); points[1].x = (newTurnLen0) * sin( D2R(angle0) ); radii[0] = -(newTurnLen0); - tempEndPts(0).pos = points[0]; tempEndPts(0).angle = 270.0; - tempEndPts(1).pos = points[1]; tempEndPts(1).angle = 90.0-angle0; + SetEndPt( TempEndPt(0), points[0], 270.0 ); + SetEndPt( TempEndPt(1), points[1], 90.0-angle0 ); break; case NTO_BUMPER: - DYNARR_SET( trkEndPt_t, tempEndPts_da, 1 ); + TempEndPtsSet( 1 ); points[0].y = points[0].x = 0; points[1].y = 0/*(newTurnOff1)*/; points[1].x = (newTurnLen0); - tempEndPts(0).pos = points[0]; tempEndPts(0).angle = 270.0; + SetEndPt( TempEndPt(0), points[0], 270.0 ); break; default: @@ -2137,310 +2309,334 @@ LogPrintf( "ctoDes2: R(%f) A0(%f) A1(%f) C(%f,%f) P(%f,%f) EP(%f,%f) RP0(%f,%f) switch (dp->type) { case NTO_CURVED: d = points[3].x - points[5].x; - if ( d < -MIN_TRACK_LENGTH ) + if ( d < -MIN_TRACK_LENGTH ) { pp = &Crv3Schema; - else if ( d > MIN_TRACK_LENGTH ) + } else if ( d > MIN_TRACK_LENGTH ) { pp = &Crv2Schema; - else + } else { pp = &Crv1Schema; + } break; } } #ifndef MKTURNOUT if(dp->type == NTO_CORNU) { - DYNARR_SET( trkEndPt_t, tempEndPts_da, 3 ); - - DIST_T end_length = MIN_TRACK_LENGTH; - - // Adjust end_points to impose small fixed end segments - - for (int i=0;i<3;i++) { - if (radii[i] == 0.0) { - Translate(&end_points[i], points[i], 90-angles[i]+(i==0?0:180), end_length); - end_angles[i] = angles[i]; - } else { - Translate(&end_centers[i], points[i], -angles[i], radii[i]); - end_arcs[i] = (radii[i]>=0?1:-1)*R2D(end_length/fabs(radii[i])); - end_points[i] = points[i]; - Rotate(&end_points[i],end_centers[i],(i>0?1:-1)*end_arcs[i]); - end_angles[i] = angles[i]-(i>0?1:-1)*end_arcs[i]; - } -LogPrintf( "ctoDes0-%d: EP(%f,%f) NEP(%f,%f) EA(%f) NEA(%f) R(%f) ARC(%f) EC(%f,%f) \n", - i+1,points[i].x,points[i].y,end_points[i].x,end_points[i].y,angles[i],end_angles[i],radii[i],end_arcs[i], - end_centers[i].x,end_centers[i].y); - } - - cornuData.pos[0] = end_points[0]; /*Start*/ - cornuData.pos[1] = end_points[2]; /*Outer*/ - cornuData.pos[3] = end_points[2]; /*Outer for second time*/ - cornuData.pos[5] = end_points[1]; /*Inner*/ + DIST_T end_length = MIN_TRACK_LENGTH; + // Adjust end_points to impose small fixed end segments - if (radii[0] == 0.0) /* Toe */ - cornuData.center[0] = zero; - else { - cornuData.center[0].x = end_points[0].x; - cornuData.center[0].y = end_points[0].y + radii[0]; + for (int i=0; i<3; i++) { + if (radii[i] == 0.0) { + Translate(&end_points[i], points[i], 90-angles[i]+(i==0?0:180), end_length); + end_angles[i] = angles[i]; + } else { + Translate(&end_centers[i], points[i], -angles[i], radii[i]); + end_arcs[i] = (radii[i]>=0?1:-1)*R2D(end_length/fabs(radii[i])); + end_points[i] = points[i]; + Rotate(&end_points[i],end_centers[i],(i>0?1:-1)*end_arcs[i]); + end_angles[i] = angles[i]-(i>0?1:-1)*end_arcs[i]; } - if (radii[1] == 0.0) /* Inner */ - cornuData.center[5] = zero; - else - Translate(&cornuData.center[5], cornuData.pos[5], -end_angles[1], radii[1]); - - if (radii[2] == 0.0) /* Outer */ - cornuData.center[1] = zero; - else - Translate(&cornuData.center[1], cornuData.pos[1], -end_angles[2], radii[2]); - cornuData.center[3] = cornuData.center[1]; - - cornuData.angle[0] = 270.0; - cornuData.angle[1] = 90.0-end_angles[2]; - cornuData.angle[3] = 90.0-end_angles[2]; - cornuData.angle[5] = 90.0-end_angles[1]; /*Inner*/ - - cornuData.radius[0] = fabs(radii[0]); - cornuData.radius[1] = fabs(radii[2]); - cornuData.radius[3] = fabs(radii[2]); - cornuData.radius[5] = fabs(radii[1]); /*Inner*/ - - DYNARR_RESET( trkSeg_t, tempSegs_da ); - trkSeg_t * temp_p, * cornu_p; - temp_p = &tempSegs(0); + LOG( log_cornuturnoutdesigner, 1, + ( "ctoDes0-%d: EP(%f,%f) NEP(%f,%f) EA(%f) NEA(%f) R(%f) ARC(%f) EC(%f,%f) \n", + \ + i+1,points[i].x,points[i].y,end_points[i].x,end_points[i].y,angles[i], + end_angles[i],radii[i],end_arcs[i], \ + end_centers[i].x,end_centers[i].y) ); + } - /*Map out the full outer curve */ - CallCornu0(&cornuData.pos[0],&cornuData.center[0],&cornuData.angle[0],&cornuData.radius[0],&tempSegs_da, FALSE); + cornuData.pos[0] = end_points[0]; /*Start*/ + cornuData.pos[1] = end_points[2]; /*Outer*/ + cornuData.pos[3] = end_points[2]; /*Outer for second time*/ + cornuData.pos[5] = end_points[1]; /*Inner*/ - /*Get ToeAngle/Radius/Center */ - int inx,subSeg; - wBool_t back, neg; - DIST_T radius; - coOrd center; - pos.x = end_points[0].x+newTurnToeL-MIN_TRACK_LENGTH; - pos.y = end_points[0].y; /* This will be close to but not on the curve */ - ANGLE_T angle = GetAngleSegs(tempSegs_da.cnt,(trkSeg_t *)(tempSegs_da.ptr),&pos,&inx,NULL,&back,&subSeg,&neg); - segPtr = &DYNARR_N(trkSeg_t, tempSegs_da, inx); - - if (segPtr->type == SEG_BEZTRK) { - segPtr = &DYNARR_N(trkSeg_t,segPtr->bezSegs,subSeg); - } - - if (segPtr->type == SEG_STRTRK) { - radius = 0.0; - center = zero; - } else if (segPtr->type == SEG_CRVTRK) { - center = segPtr->u.c.center; - radius = fabs(segPtr->u.c.radius); - } - cornuData.pos[1] = pos; - cornuData.center[1] = center; - cornuData.angle[1] = angle; - cornuData.radius[1] = radius; - cornuData.pos[2] = pos; - cornuData.center[2] = center; - cornuData.angle[2] = NormalizeAngle(180.0+angle); - cornuData.radius[2] = radius; - cornuData.pos[4] = pos; - cornuData.center[4] = center; - cornuData.angle[4] = NormalizeAngle(180.0+angle); - cornuData.radius[4] = radius; - static dynArr_t cornuSegs_da; + if (radii[0] == 0.0) { /* Toe */ + cornuData.center[0] = zero; + } else { + cornuData.center[0].x = end_points[0].x; + cornuData.center[0].y = end_points[0].y + radii[0]; + } + if (radii[1] == 0.0) { /* Inner */ + cornuData.center[5] = zero; + } else { + Translate(&cornuData.center[5], cornuData.pos[5], -end_angles[1], radii[1]); + } - ClearSegs(&tempSegs_da); - ClearSegs(&cornuSegs_da); + if (radii[2] == 0.0) { /* Outer */ + cornuData.center[1] = zero; + } else { + Translate(&cornuData.center[1], cornuData.pos[1], -end_angles[2], radii[2]); + } + cornuData.center[3] = cornuData.center[1]; + + cornuData.angle[0] = 270.0; + cornuData.angle[1] = 90.0-end_angles[2]; + cornuData.angle[3] = 90.0-end_angles[2]; + cornuData.angle[5] = 90.0-end_angles[1]; /*Inner*/ + + cornuData.radius[0] = fabs(radii[0]); + cornuData.radius[1] = fabs(radii[2]); + cornuData.radius[3] = fabs(radii[2]); + cornuData.radius[5] = fabs(radii[1]); /*Inner*/ + + DYNARR_RESET( trkSeg_t, tempSegs_da ); + + /*Map out the full outer curve */ + + CallCornu0(&cornuData.pos[0],&cornuData.center[0],&cornuData.angle[0], + &cornuData.radius[0],&tempSegs_da, FALSE); + + /*Get ToeAngle/Radius/Center */ + int inx,subSeg; + wBool_t back, neg; + DIST_T radius = 0.0; + coOrd center; + pos.x = end_points[0].x+newTurnToeL-MIN_TRACK_LENGTH; + pos.y = end_points[0].y; /* This will be close to but not on the curve */ + ANGLE_T angle = GetAngleSegs(tempSegs_da.cnt,&tempSegs(0),&pos, + &inx,NULL,&back,&subSeg,&neg); + segPtr = &DYNARR_N(trkSeg_t, tempSegs_da, inx); + + if (segPtr->type == SEG_BEZTRK) { + segPtr = &DYNARR_N(trkSeg_t,segPtr->bezSegs,subSeg); + } - /* Override if at zero radius at base don't compute end */ - if (cornuData.radius[0] == 0.0) { - DYNARR_APPEND(trkSeg_t,tempSegs_da,1); - temp_p = &DYNARR_LAST(trkSeg_t,tempSegs_da); - temp_p->type = SEG_STRTRK; - temp_p->color = wDrawColorBlack; - temp_p->width = 0.0; - temp_p->u.l.pos[0] = zero; - temp_p->u.l.pos[1] = cornuData.pos[1]; -LogPrintf( "ctoDes1: P0(%f,%f) P1(%f,%f) \n", - temp_p->u.l.pos[0].x,temp_p->u.l.pos[0].y,temp_p->u.l.pos[1].x,temp_p->u.l.pos[1].y ); + if (segPtr->type == SEG_STRTRK) { + radius = 0.0; + center = zero; + } else if (segPtr->type == SEG_CRVTRK) { + center = segPtr->u.c.center; + radius = fabs(segPtr->u.c.radius); + } + cornuData.pos[1] = pos; + cornuData.center[1] = center; + cornuData.angle[1] = angle; + cornuData.radius[1] = radius; + cornuData.pos[2] = pos; + cornuData.center[2] = center; + cornuData.angle[2] = NormalizeAngle(180.0+angle); + cornuData.radius[2] = radius; + cornuData.pos[4] = pos; + cornuData.center[4] = center; + cornuData.angle[4] = NormalizeAngle(180.0+angle); + cornuData.radius[4] = radius; + + static dynArr_t cornuSegs_da; + + ClearSegs(&tempSegs_da); + ClearSegs(&cornuSegs_da); + + /* Override if at zero radius at base don't compute end */ + if (cornuData.radius[0] == 0.0) { + DYNARR_APPEND(trkSeg_t,tempSegs_da,1); + trkSeg_p temp_p = &DYNARR_LAST(trkSeg_t,tempSegs_da); + temp_p->type = SEG_STRTRK; + temp_p->color = wDrawColorBlack; + temp_p->lineWidth = 0.0; + temp_p->u.l.pos[0] = zero; + temp_p->u.l.pos[1] = cornuData.pos[1]; + LOG( log_cornuturnoutdesigner, 1, ( "ctoDes1: P0(%f,%f) P1(%f,%f) \n", \ + temp_p->u.l.pos[0].x,temp_p->u.l.pos[0].y,temp_p->u.l.pos[1].x, + temp_p->u.l.pos[1].y ) ); + } else { + DYNARR_APPEND(trkSeg_t,tempSegs_da,1); + trkSeg_p temp_p = &DYNARR_LAST(trkSeg_t,tempSegs_da); + temp_p->type = SEG_CRVTRK; + temp_p->color = wDrawColorBlack; + temp_p->lineWidth = 0.0; + temp_p->u.c.radius = -radii[0]; + if (radii[0]>0.0) { + temp_p->u.c.a0 = FindAngle(end_centers[0],end_points[0]); } else { - DYNARR_APPEND(trkSeg_t,tempSegs_da,1); - temp_p = &DYNARR_LAST(trkSeg_t,tempSegs_da); - temp_p->type = SEG_CRVTRK; - temp_p->color = wDrawColorBlack; - temp_p->width = 0.0; - temp_p->u.c.radius = -radii[0]; - if (radii[0]>0.0) - temp_p->u.c.a0 = FindAngle(end_centers[0],end_points[0]); - else - temp_p->u.c.a0 = FindAngle(end_centers[0],points[0]); - temp_p->u.c.a1 = fabs(end_arcs[0]); - temp_p->u.c.center = end_centers[0]; - coOrd rp0,rp1; - Translate(&rp0,temp_p->u.c.center,temp_p->u.c.a0,temp_p->u.c.radius); - Translate(&rp1,temp_p->u.c.center,temp_p->u.c.a0+temp_p->u.c.a1,temp_p->u.c.radius); -LogPrintf( "ctoDes1: R(%f) A0(%f) A1(%f) C(%f,%f) P(%f,%f), EP(%f,%f) RP0(%f,%f) RP1(%f,%f)\n", - temp_p->u.c.radius,temp_p->u.c.a0,temp_p->u.c.a1,temp_p->u.c.center.x,temp_p->u.c.center.y, - points[0].x,points[0].y,end_points[0].x,end_points[0].y, - rp0.x,rp0.y,rp1.x,rp1.y); - - /* Base to Toe in tempSegs array */ - CallCornuNoBez(&cornuData.pos[0],&cornuData.center[0],& cornuData.angle[0],&cornuData.radius[0],&tempSegs_da); + temp_p->u.c.a0 = FindAngle(end_centers[0],points[0]); } + temp_p->u.c.a1 = fabs(end_arcs[0]); + temp_p->u.c.center = end_centers[0]; + coOrd rp0,rp1; + Translate(&rp0,temp_p->u.c.center,temp_p->u.c.a0,temp_p->u.c.radius); + Translate(&rp1,temp_p->u.c.center,temp_p->u.c.a0+temp_p->u.c.a1, + temp_p->u.c.radius); + LOG( log_cornuturnoutdesigner, 1, + ( "ctoDes1: R(%f) A0(%f) A1(%f) C(%f,%f) P(%f,%f), EP(%f,%f) RP0(%f,%f) RP1(%f,%f)\n", + \ + temp_p->u.c.radius,temp_p->u.c.a0,temp_p->u.c.a1,temp_p->u.c.center.x, + temp_p->u.c.center.y, \ + points[0].x,points[0].y,end_points[0].x,end_points[0].y, \ + rp0.x,rp0.y,rp1.x,rp1.y) ); + + /* Base to Toe in tempSegs array */ + CallCornuNoBez(&cornuData.pos[0],&cornuData.center[0],& cornuData.angle[0], + &cornuData.radius[0],&tempSegs_da); + } - int ToeSeg = tempSegs_da.cnt; - - /* Toe to Outer in cornuSegs array */ - CallCornuNoBez(&cornuData.pos[2],&cornuData.center[2],&cornuData.angle[2],&cornuData.radius[2],&cornuSegs_da); - - cornu_p = (trkSeg_p)cornuSegs_da.ptr; - - if (cornuData.radius[3] == 0.0) { - DYNARR_APPEND(trkSeg_t,cornuSegs_da,1); - temp_p = &DYNARR_LAST(trkSeg_t,cornuSegs_da); - temp_p->type = SEG_STRTRK; - temp_p->color = wDrawColorBlack; - temp_p->width = 0.0; - temp_p->u.l.pos[0] = cornuData.pos[3]; - temp_p->u.l.pos[1] = end_points[2]; -LogPrintf( "ctoDes2: P0(%f,%f) P1(%f,%f) \n", - temp_p->u.l.pos[0].x,temp_p->u.l.pos[0].y,temp_p->u.l.pos[1].x,temp_p->u.l.pos[1].y ); + int ToeSeg = tempSegs_da.cnt; + + /* Toe to Outer in cornuSegs array */ + CallCornuNoBez(&cornuData.pos[2],&cornuData.center[2],&cornuData.angle[2], + &cornuData.radius[2],&cornuSegs_da); + if (cornuData.radius[3] == 0.0) { + DYNARR_APPEND(trkSeg_t,cornuSegs_da,1); + trkSeg_p temp_p = &DYNARR_LAST(trkSeg_t,cornuSegs_da); + temp_p->type = SEG_STRTRK; + temp_p->color = wDrawColorBlack; + temp_p->lineWidth = 0.0; + temp_p->u.l.pos[0] = cornuData.pos[3]; + temp_p->u.l.pos[1] = end_points[2]; + LOG( log_cornuturnoutdesigner, 1, ( "ctoDes2: P0(%f,%f) P1(%f,%f) \n", \ + temp_p->u.l.pos[0].x,temp_p->u.l.pos[0].y,temp_p->u.l.pos[1].x, + temp_p->u.l.pos[1].y ) ); + } else { + DYNARR_APPEND(trkSeg_t,cornuSegs_da,1); + trkSeg_p temp_p = &DYNARR_LAST(trkSeg_t,cornuSegs_da); + temp_p->type = SEG_CRVTRK; + temp_p->color = wDrawColorBlack; + temp_p->lineWidth = 0.0; + temp_p->u.c.radius = -radii[2]; + if (radii[2]>0) { + temp_p->u.c.a0 = FindAngle(end_centers[2],points[2]); } else { - DYNARR_APPEND(trkSeg_t,cornuSegs_da,1); - temp_p = &DYNARR_LAST(trkSeg_t,cornuSegs_da); - temp_p->type = SEG_CRVTRK; - temp_p->color = wDrawColorBlack; - temp_p->width = 0.0; - temp_p->u.c.radius = -radii[2]; - if (radii[2]>0) - temp_p->u.c.a0 = FindAngle(end_centers[2],points[2]); - else - temp_p->u.c.a0 = FindAngle(end_centers[2],end_points[2]); - temp_p->u.c.a1 = fabs(end_arcs[2]); - temp_p->u.c.center = end_centers[2]; - coOrd rp0,rp1; - Translate(&rp0,temp_p->u.c.center,temp_p->u.c.a0,temp_p->u.c.radius); - Translate(&rp1,temp_p->u.c.center,temp_p->u.c.a0+temp_p->u.c.a1,temp_p->u.c.radius); -LogPrintf( "ctoDes2: R(%f) A0(%f) A1(%f) C(%f,%f) P(%f,%f) EP(%f,%f) RP0(%f,%f) RP1(%f,%f)\n", - temp_p->u.c.radius,temp_p->u.c.a0,temp_p->u.c.a1,temp_p->u.c.center.x,temp_p->u.c.center.y, - points[2].x,points[2].y,end_points[2].x,end_points[2].y, - rp0.x,rp0.y,rp1.x,rp1.y); + temp_p->u.c.a0 = FindAngle(end_centers[2],end_points[2]); } + temp_p->u.c.a1 = fabs(end_arcs[2]); + temp_p->u.c.center = end_centers[2]; + coOrd rp0,rp1; + Translate(&rp0,temp_p->u.c.center,temp_p->u.c.a0,temp_p->u.c.radius); + Translate(&rp1,temp_p->u.c.center,temp_p->u.c.a0+temp_p->u.c.a1, + temp_p->u.c.radius); + LOG( log_cornuturnoutdesigner, 1, + ( "ctoDes2: R(%f) A0(%f) A1(%f) C(%f,%f) P(%f,%f) EP(%f,%f) RP0(%f,%f) RP1(%f,%f)\n", + \ + temp_p->u.c.radius,temp_p->u.c.a0,temp_p->u.c.a1,temp_p->u.c.center.x, + temp_p->u.c.center.y, \ + points[2].x,points[2].y,end_points[2].x,end_points[2].y, \ + rp0.x,rp0.y,rp1.x,rp1.y) ); + } - int OuterEndSeg = cornuSegs_da.cnt + ToeSeg; - - /* Add to second cornu to tempSegs array */ - AppendSegs(&tempSegs_da,&cornuSegs_da); - - /* Get ready to reuse cornuSegs array*/ - ClearSegs(&cornuSegs_da); - - /* Toe to Inner in cornuSegs array*/ - CallCornuNoBez(&cornuData.pos[4],&cornuData.center[4],&cornuData.angle[4],&cornuData.radius[4],&cornuSegs_da); - - if (cornuData.radius[5] == 0.0) { - DYNARR_APPEND(trkSeg_t,cornuSegs_da,1); - temp_p = &DYNARR_LAST(trkSeg_t,cornuSegs_da); - temp_p->type = SEG_STRTRK; - temp_p->color = wDrawColorBlack; - temp_p->width = 0.0; - temp_p->u.l.pos[0] = cornuData.pos[5]; - temp_p->u.l.pos[1] = points[1]; -LogPrintf( "ctoDes3: P0(%f,%f) P1(%f,%f) \n", - temp_p->u.l.pos[0].x,temp_p->u.l.pos[0].y,temp_p->u.l.pos[1].x,temp_p->u.l.pos[1].y ); + int OuterEndSeg = cornuSegs_da.cnt + ToeSeg; + + /* Add to second cornu to tempSegs array */ + AppendSegs(&tempSegs_da,&cornuSegs_da); + + /* Get ready to reuse cornuSegs array*/ + ClearSegs(&cornuSegs_da); + + /* Toe to Inner in cornuSegs array*/ + CallCornuNoBez(&cornuData.pos[4],&cornuData.center[4],&cornuData.angle[4], + &cornuData.radius[4],&cornuSegs_da); + + if (cornuData.radius[5] == 0.0) { + DYNARR_APPEND(trkSeg_t,cornuSegs_da,1); + trkSeg_p temp_p = &DYNARR_LAST(trkSeg_t,cornuSegs_da); + temp_p->type = SEG_STRTRK; + temp_p->color = wDrawColorBlack; + temp_p->lineWidth = 0.0; + temp_p->u.l.pos[0] = cornuData.pos[5]; + temp_p->u.l.pos[1] = points[1]; + LOG( log_cornuturnoutdesigner, 1, ( "ctoDes3: P0(%f,%f) P1(%f,%f) \n", \ + temp_p->u.l.pos[0].x,temp_p->u.l.pos[0].y,temp_p->u.l.pos[1].x, + temp_p->u.l.pos[1].y ) ); + } else { + DYNARR_APPEND(trkSeg_t,cornuSegs_da,1); + trkSeg_p temp_p = &DYNARR_LAST(trkSeg_t,cornuSegs_da); + temp_p->type = SEG_CRVTRK; + temp_p->color = wDrawColorBlack; + temp_p->lineWidth = 0.0; + temp_p->u.c.radius = -radii[1]; + if (radii[1]>0) { + temp_p->u.c.a0 = FindAngle(end_centers[1],points[1]); } else { - DYNARR_APPEND(trkSeg_t,cornuSegs_da,1); - temp_p = &DYNARR_LAST(trkSeg_t,cornuSegs_da); - temp_p->type = SEG_CRVTRK; - temp_p->color = wDrawColorBlack; - temp_p->width = 0.0; - temp_p->u.c.radius = -radii[1]; - if (radii[1]>0) - temp_p->u.c.a0 = FindAngle(end_centers[1],points[1]); - else - temp_p->u.c.a0 = FindAngle(end_centers[1],end_points[1]); - temp_p->u.c.a1 = fabs(end_arcs[1]); - temp_p->u.c.center = end_centers[1]; - coOrd rp0,rp1; - Translate(&rp0,temp_p->u.c.center,temp_p->u.c.a0,temp_p->u.c.radius); - Translate(&rp1,temp_p->u.c.center,temp_p->u.c.a0+temp_p->u.c.a1,temp_p->u.c.radius); -LogPrintf( "ctoDes3: R(%f) A0(%f) A1(%f) C(%f,%f) P(%f,%f) EP(%f,%f) RP0(%f,%f) RP1(%f,%f)\n", - temp_p->u.c.radius,temp_p->u.c.a0,temp_p->u.c.a1,temp_p->u.c.center.x,temp_p->u.c.center.y, - points[1].x,points[1].y,end_points[1].x,end_points[1].y, - rp0.x,rp0.y,rp1.x,rp1.y); + temp_p->u.c.a0 = FindAngle(end_centers[1],end_points[1]); } + temp_p->u.c.a1 = fabs(end_arcs[1]); + temp_p->u.c.center = end_centers[1]; + coOrd rp0,rp1; + Translate(&rp0,temp_p->u.c.center,temp_p->u.c.a0,temp_p->u.c.radius); + Translate(&rp1,temp_p->u.c.center,temp_p->u.c.a0+temp_p->u.c.a1, + temp_p->u.c.radius); + LOG( log_cornuturnoutdesigner, 1, + ( "ctoDes3: R(%f) A0(%f) A1(%f) C(%f,%f) P(%f,%f) EP(%f,%f) RP0(%f,%f) RP1(%f,%f)\n", + \ + temp_p->u.c.radius,temp_p->u.c.a0,temp_p->u.c.a1,temp_p->u.c.center.x, + temp_p->u.c.center.y, \ + points[1].x,points[1].y,end_points[1].x,end_points[1].y, \ + rp0.x,rp0.y,rp1.x,rp1.y) ); + } - int InnerEndSeg = cornuSegs_da.cnt + OuterEndSeg; + int InnerEndSeg = cornuSegs_da.cnt + OuterEndSeg; - /*Add Third Part to tempSegs Array */ - AppendSegs(&tempSegs_da,&cornuSegs_da); + /*Add Third Part to tempSegs Array */ + AppendSegs(&tempSegs_da,&cornuSegs_da); - /* Safety - clear out cornu Array */ - ClearSegs(&cornuSegs_da); + /* Safety - clear out cornu Array */ + ClearSegs(&cornuSegs_da); - if (tempSegs_da.cnt >128 ) { - NoticeMessage( MSG_TODSGN_CORNU_TOO_COMPLEX, _("Ok"), NULL ); - return NULL; - } + if (tempSegs_da.cnt >128 ) { + NoticeMessage( MSG_TODSGN_CORNU_TOO_COMPLEX, _("Ok"), NULL ); + return NULL; + } - static char pathChar[512]; - strcpy(pathChar,"Normal"); /* Also resets array */ + static char pathChar[512]; + strcpy(pathChar,"Normal"); /* Also resets array */ - pathLen = (wIndex_t)strlen(pathChar)+1; + pathLen = (wIndex_t)strlen(pathChar)+1; - for (uint8_t i=0;i<OuterEndSeg;i++) { - pathChar[pathLen] = i+1; - pathLen++; - } - pathChar[pathLen] = 0; - pathLen++; - pathChar[pathLen] = 0; + for (uint8_t i=0; i<OuterEndSeg; i++) { + pathChar[pathLen] = i+1; pathLen++; + } + pathChar[pathLen] = 0; + pathLen++; + pathChar[pathLen] = 0; + pathLen++; - sprintf(&pathChar[pathLen],"%s","Reverse"); + sprintf(&pathChar[pathLen],"%s","Reverse"); - pathLen += (wIndex_t)strlen(&pathChar[pathLen])+1; - for (uint8_t i=0;i<ToeSeg;i++) { - pathChar[pathLen] = i+1; - pathLen++; - } - for (uint8_t i=OuterEndSeg;i<InnerEndSeg;i++) { - pathChar[pathLen] = i+1; - pathLen++; - } - pathChar[pathLen] = 0; + pathLen += (wIndex_t)strlen(&pathChar[pathLen])+1; + for (uint8_t i=0; i<ToeSeg; i++) { + pathChar[pathLen] = i+1; pathLen++; - pathChar[pathLen] = 0; + } + for (uint8_t i=OuterEndSeg; i<InnerEndSeg; i++) { + pathChar[pathLen] = i+1; pathLen++; - pathChar[pathLen] = 0; - pathLen++; - - pp->paths = (signed char *)pathChar; - segCnt = tempSegs_da.cnt; + } + pathChar[pathLen] = 0; + pathLen++; + pathChar[pathLen] = 0; + pathLen++; + pathChar[pathLen] = 0; + pathLen++; + + pp->paths = (signed char *)pathChar; + segCnt = tempSegs_da.cnt; } #endif - if (!( (dp->type== NTO_CORNU) || (dp->type == NTO_CORNUWYE) || (dp->type == NTO_CORNU3WAY))) { + if (!( (dp->type== NTO_CORNU) || (dp->type == NTO_CORNUWYE) + || (dp->type == NTO_CORNU3WAY))) { segOrder = pp->segOrder; segCnt = (wIndex_t)strlen( segOrder ); - if (segCnt%3 != 0) - AbortProg( dp->label ); + CHECKMSG( segCnt%3 == 0, ( "%s", dp->label ) ); segCnt /= 3; DYNARR_SET( trkSeg_t, tempSegs_da, segCnt ); - tempSegs_da.cnt = segCnt; memset( &tempSegs(0), 0, segCnt * sizeof tempSegs(0) ); for ( s=0; s<segCnt; s++ ) { segPtr = &tempSegs(s); segPtr->color = wDrawColorBlack; - if (*segOrder <= '9') + if (*segOrder <= '9') { p0 = *segOrder++ - '0'; - else + } else { p0 = *segOrder++ - 'A' + 10; - if (*segOrder <= '9') + } + if (*segOrder <= '9') { p1 = *segOrder++ - '0'; - else + } else { p1 = *segOrder++ - 'A' + 10; + } p = *segOrder++ - '0'; if (p == 3) { /* cornu */ @@ -2459,18 +2655,21 @@ LogPrintf( "ctoDes3: R(%f) A0(%f) A1(%f) C(%f,%f) P(%f,%f) EP(%f,%f) RP0(%f,%f) AddRoadbed(); #ifndef MKTURNOUT - if ( CheckPaths( segCnt, &tempSegs(0), pp->paths ) < 0 ) + if ( CheckPaths( segCnt, &tempSegs(0), pp->paths, dp->label ) < 0 ) { return NULL; + } #endif return pp; } +#ifndef MKTURNOUT static void CopyNonTracks( turnoutInfo_t * to ) { trkSeg_p sp0; for ( sp0=to->segs; sp0<&to->segs[to->segCnt]; sp0++ ) { - if ( sp0->type != SEG_STRTRK && sp0->type != SEG_CRVTRK && sp0->type != SEG_BEZTRK ) { + if ( sp0->type != SEG_STRTRK && sp0->type != SEG_CRVTRK + && sp0->type != SEG_BEZTRK ) { DYNARR_APPEND( trkSeg_t, tempSegs_da, 10 ); tempSegs(tempSegs_da.cnt-1) = *sp0; } @@ -2478,9 +2677,8 @@ static void CopyNonTracks( turnoutInfo_t * to ) } -#ifndef MKTURNOUT static void NewTurnPrint( - void * junk ) + void * junk ) { coOrd pos, p0, p1; WDOUBLE_T px, py; @@ -2499,12 +2697,15 @@ static void NewTurnPrint( 0.0, { 0.0, 0.0 }, { 0.0, 0.0 }, - Pix2CoOrd, CoOrd2Pix }; + Pix2CoOrd, CoOrd2Pix + }; - if ((pp=LoadSegs( curDesign, TRUE )) == NULL) + if ((pp=LoadSegs( curDesign, TRUE )) == NULL) { return; - if (includeNontrackSegments && customTurnout1) + } + if (includeNontrackSegments && customTurnout1) { CopyNonTracks( customTurnout1 ); + } GetSegBounds( zero, 0.0, tempSegs_da.cnt, &tempSegs(0), &orig, &size ); tmp = orig.x; orig.x = orig.y; orig.y = tmp; @@ -2522,19 +2723,23 @@ static void NewTurnPrint( case SEG_CRVTRK: case SEG_CRVLIN: PointOnCircle( &pos[0], segPtr->u.c.center, segPtr->u.c.radius, - segPtr->u.c.a0 ); + segPtr->u.c.a0 ); PointOnCircle( &pos[1], segPtr->u.c.center, segPtr->u.c.radius, - segPtr->u.c.a0+segPtr->u.c.a1 ); + segPtr->u.c.a0+segPtr->u.c.a1 ); } for ( ep=0; ep<2; ep++ ) { - if (pos[ep].x < orig.x) + if (pos[ep].x < orig.x) { orig.x = pos[ep].x; - if (pos[ep].x > size.x) + } + if (pos[ep].x > size.x) { size.x = pos[ep].x; - if (pos[ep].y < orig.y) + } + if (pos[ep].y < orig.y) { orig.y = pos[ep].y; - if (pos[ep].y > size.y) + } + if (pos[ep].y > size.y) { size.y = pos[ep].y; + } } } @@ -2548,8 +2753,9 @@ static void NewTurnPrint( newTurnout_d.size.y = py; ii = (int)(size.y/newTurnout_d.size.x)+1; jj = (int)(size.x/newTurnout_d.size.y)+1; - if ( !wPrintDocStart( sTurnoutDesignerW, ii*jj, NULL ) ) + if ( !wPrintDocStart( sTurnoutDesignerW, ii*jj, NULL ) ) { return; + } #ifdef LATER orig.x -= (0.5); orig.y -= (jj*newTurnout_d.size.y-size.y)/2.0; @@ -2558,9 +2764,9 @@ static void NewTurnPrint( orig.y -= (0.5); coOrd strPos; for ( i=0, newTurnout_d.orig.x=orig.x; i<ii; - i++, newTurnout_d.orig.x+=newTurnout_d.size.x ) { + i++, newTurnout_d.orig.x+=newTurnout_d.size.x ) { for ( j=0, newTurnout_d.orig.y=orig.y; j<jj; - j++, newTurnout_d.orig.y+=newTurnout_d.size.y ) { + j++, newTurnout_d.orig.y+=newTurnout_d.size.y ) { newTurnout_d.d = wPrintPageStart(); newTurnout_d.dpi = wDrawGetDPI(newTurnout_d.d); strPos.x = newTurnout_d.orig.x + 3.0; @@ -2578,45 +2784,52 @@ static void NewTurnPrint( for ( p=0; p<curDesign->floatCnt; p++ ) { tmpR = *(FLOAT_T*)(turnDesignPLs[curDesign->floats[p].index].valueP); sprintf( message, "%s: %s", - (curDesign->floats[p].mode!=Frog_e||newTurnAngleMode!=0)?_(curDesign->floats[p].printLabel):_("Frog Number"), - curDesign->floats[p].mode==Dim_e? - FormatDistance(tmpR): - FormatFloat(tmpR) ); + (curDesign->floats[p].mode!=Frog_e + ||newTurnAngleMode!=0)?_(curDesign->floats[p].printLabel):_("Frog Number"), + curDesign->floats[p].mode==Dim_e? + FormatDistance(tmpR): + FormatFloat(tmpR) ); strPos.y -= 0.25; DrawString( &newTurnout_d, strPos, 0.0, message, fp, 16, wDrawColorBlack ); } if (newTurnLeftDesc[0] || newTurnLeftPartno[0]) { - sprintf( message, "%s %s %s", newTurnManufacturer, newTurnLeftPartno, newTurnLeftDesc ); + sprintf( message, "%s %s %s", newTurnManufacturer, newTurnLeftPartno, + newTurnLeftDesc ); strPos.y -= 0.25; DrawString( &newTurnout_d, strPos, 0.0, message, fp, 16, wDrawColorBlack ); } if (newTurnRightDesc[0] || newTurnRightPartno[0]) { - sprintf( message, "%s %s %s", newTurnManufacturer, newTurnRightPartno, newTurnRightDesc ); + sprintf( message, "%s %s %s", newTurnManufacturer, newTurnRightPartno, + newTurnRightDesc ); strPos.y -= 0.25; DrawString( &newTurnout_d, strPos, 0.0, message, fp, 16, wDrawColorBlack ); } - DrawRectangle( &newTurnout_d, newTurnout_d.orig, newTurnout_d.size, wDrawColorBlack, DRAW_CLOSED ); + DrawRectangle( &newTurnout_d, newTurnout_d.orig, newTurnout_d.size, + wDrawColorBlack, DRAW_CLOSED ); - DrawSegs( &newTurnout_d, zero, 270.0, &tempSegs(0), tempSegs_da.cnt, newTurnTrackGauge, wDrawColorBlack ); + DrawSegsDA( &newTurnout_d, NULL, zero, 270.0, &tempSegs_da, newTurnTrackGauge, + wDrawColorBlack, 0 ); - for ( ep=0; ep<tempEndPts_da.cnt; ep++ ) { - pos.x = -tempEndPts(ep).pos.y; - pos.y = tempEndPts(ep).pos.x; - Translate( &p0, pos, tempEndPts(ep).angle+90+270.0, - newTurnTrackGauge ); - Translate( &p1, pos, tempEndPts(ep).angle+270+270.0, - newTurnTrackGauge ); + for ( ep=0; ep<TempEndPtsCount(); ep++ ) { + pos.x = - GetEndPtPos( TempEndPt(ep) ).y; + pos.y = GetEndPtPos( TempEndPt(ep) ).x; + ANGLE_T angle = GetEndPtAngle( TempEndPt(ep) ); + Translate( &p0, pos, angle+90+270.0, + newTurnTrackGauge ); + Translate( &p1, pos, angle+270+270.0, + newTurnTrackGauge ); DrawLine( &newTurnout_d, p0, p1, 0, wDrawColorBlack ); - Translate( &p0, pos, tempEndPts(ep).angle+270.0, - newTurnout_d.size.y/2.0 ); + Translate( &p0, pos, angle+270.0, + newTurnout_d.size.y/2.0 ); DrawStraightTrack( &newTurnout_d, pos, p0, - tempEndPts(ep).angle+270.0, - NULL, wDrawColorBlack, 0 ); + angle+270.0, + NULL, wDrawColorBlack, 0 ); } - if ( !wPrintPageEnd( newTurnout_d.d ) ) + if ( !wPrintPageEnd( newTurnout_d.d ) ) { goto quitPrinting; + } } } quitPrinting: @@ -2624,27 +2837,45 @@ quitPrinting: } #endif + +static char * BuildTrimedTitle( char * cp, const char * sep, const char * mfg, + const char * desc, const char * partno ) +{ + cp = Strcpytrimed( cp, mfg, FALSE ); + strcpy( cp, sep ); + cp += strlen(cp); + cp = Strcpytrimed( cp, desc, FALSE ); + strcpy( cp, sep ); + cp += strlen(cp); + cp = Strcpytrimed( cp, partno, FALSE ); + return cp; +} + static void NewTurnOk( void * context ) { FILE * f; toDesignSchema_t * pp; int i; - BOOL_T foundR=FALSE; char * cp; #ifndef MKTURNOUT + BOOL_T foundR=FALSE; turnoutInfo_t *to; #endif FLOAT_T flt; - wIndex_t segCnt; char * customInfoP; + coOrd pos; + ANGLE_T angle; + #ifndef MKTURNOUT - if ( ! ParamCheckInputs( &turnDesignPG, (wControl_p)turnDesignPG.okB ) ) + if ( ! ParamCheckInputs( &turnDesignPG, (wControl_p)turnDesignPG.okB ) ) { return; + } #endif - if ((pp=LoadSegs( curDesign, TRUE )) == NULL) + if ((pp=LoadSegs( curDesign, TRUE )) == NULL) { return; + } // if ( (curDesign->strCnt >= 1 && newTurnLeftDesc[0] == 0) || // (curDesign->strCnt >= 2 && newTurnRightDesc[0] == 0) ) { @@ -2652,12 +2883,14 @@ static void NewTurnOk( void * context ) // return; // } - BuildTrimedTitle( message, "\t", newTurnManufacturer, newTurnLeftDesc, newTurnLeftPartno ); + BuildTrimedTitle( message, "\t", newTurnManufacturer, newTurnLeftDesc, + newTurnLeftPartno ); #ifndef MKTURNOUT if ( customTurnout1 == NULL && - ( foundR || FindCompound( FIND_TURNOUT, newTurnScaleName, message ) ) ) { - if ( !NoticeMessage( MSG_TODSGN_REPLACE, _("Yes"), _("No") ) ) + ( foundR || FindCompound( FIND_TURNOUT, newTurnScaleName, message ) ) ) { + if ( !NoticeMessage( MSG_TODSGN_REPLACE, _("Yes"), _("No") ) ) { return; + } } SetCLocale(); #endif @@ -2665,7 +2898,7 @@ static void NewTurnOk( void * context ) f = OpenCustom("a"); sprintf( tempCustom, "\"%s\" \"%s\" \"", - curDesign->label, "" ); + curDesign->label, "" ); cp = tempCustom + strlen(tempCustom); cp = Strcpytrimed( cp, newTurnManufacturer, TRUE ); strcpy( cp, "\" \"" ); @@ -2676,7 +2909,8 @@ static void NewTurnOk( void * context ) cp = Strcpytrimed( cp, newTurnLeftPartno, TRUE ); strcpy( cp, "\"" ); cp += 1; - if (curDesign->type == NTO_REGULAR || curDesign->type == NTO_CURVED || curDesign->type == NTO_CORNU ) { + if (curDesign->type == NTO_REGULAR || curDesign->type == NTO_CURVED + || curDesign->type == NTO_CORNU ) { strcpy( cp, " \"" ); cp += 2; cp = Strcpytrimed( cp, newTurnRightDesc, TRUE ); @@ -2686,59 +2920,64 @@ static void NewTurnOk( void * context ) strcpy( cp, "\"" ); cp += 1; } - if ( cp-tempCustom > sizeof tempCustom ) - AbortProg( "Custom line overflow" ); + CHECK( cp-tempCustom <= sizeof tempCustom ); for ( i=0; i<curDesign->floatCnt; i++ ) { flt = *(FLOAT_T*)(turnDesignPLs[curDesign->floats[i].index].valueP); switch( curDesign->floats[i].mode ) { - case Dim_e: - flt = ( flt ); - break; - case Frog_e: - if (newTurnAngleMode == 0 && flt > 0.0) - flt = R2D(asin(1.0/flt)); - break; - case Angle_e: - break; - case Rad_e: - break; + case Dim_e: + flt = ( flt ); + break; + case Frog_e: + if (newTurnAngleMode == 0 && flt > 0.0) { + flt = R2D(asin(1.0/flt)); + } + break; + case Angle_e: + break; + case Rad_e: + break; } sprintf( cp, " %0.6f", flt ); cp += strlen(cp); } - sprintf( cp, " %0.6f %0.6f %ld", newTurnRoadbedWidth, newTurnRoadbedLineWidth/(_DPI), wDrawGetRGB(roadbedColor) ); + sprintf( cp, " %0.6f %0.6f %ld", newTurnRoadbedWidth, + newTurnRoadbedLineWidth, wDrawGetRGB(newTurnRoadbedColor) ); customInfoP = MyStrdup( tempCustom ); strcpy( tempCustom, message ); - segCnt = tempSegs_da.cnt; long options = 0; - if ( curDesign->type == NTO_D_SLIP && newTurnSlipMode == 1) + if ( curDesign->type == NTO_D_SLIP && newTurnSlipMode == 1) { options |= COMPOUND_OPTION_PATH_NOCOMBINE; + } #ifndef MKTURNOUT - if (includeNontrackSegments && customTurnout1) + if (includeNontrackSegments && customTurnout1) { CopyNonTracks( customTurnout1 ); - if ( customTurnout1 ) + } + if ( customTurnout1 ) { customTurnout1->segCnt = 0; + } - DIST_T * radii_ends = NULL; +// DIST_T * radii_ends = NULL; - if ((curDesign->type == NTO_CORNU) || - (curDesign->type == NTO_CORNUWYE) || - (curDesign->type == NTO_CORNU3WAY)) { - radii_ends = &radii[0]; - } - to = CreateNewTurnout( newTurnScaleName, tempCustom, tempSegs_da.cnt, &tempSegs(0), - pp->paths, tempEndPts_da.cnt, &tempEndPts(0), FALSE, options ); + if ((curDesign->type == NTO_CORNU) || + (curDesign->type == NTO_CORNUWYE) || + (curDesign->type == NTO_CORNU3WAY)) { +// radii_ends = &radii[0]; + } + to = CreateNewTurnout( newTurnScaleName, tempCustom, tempSegs_da.cnt, + &tempSegs(0), + pp->paths, TempEndPtsCount(), TempEndPt(0), FALSE, options ); to->customInfo = customInfoP; #endif if (f) { - fprintf( f, "TURNOUT %s \"%s\" %ld\n", newTurnScaleName, PutTitle(tempCustom), options ); + fprintf( f, "TURNOUT %s \"%s\" %ld\n", newTurnScaleName, PutTitle(tempCustom), + options ); #ifdef MKTURNOUT if (doCustomInfoLine) #endif - fprintf( f, "\tU %s\n", customInfoP ); + fprintf( f, "\tU %s\n", customInfoP ); WriteCompoundPathsEndPtsSegs( f, pp->paths, tempSegs_da.cnt, &tempSegs(0), - tempEndPts_da.cnt, &tempEndPts(0) ); + TempEndPtsCount(), TempEndPt(0) ); } switch (curDesign->type) { @@ -2748,26 +2987,34 @@ static void NewTurnOk( void * context ) points[4].y = - points[4].y; radii[0] = - radii[0]; LoadSegs( curDesign, FALSE ); - tempEndPts(2).pos.y = - tempEndPts(2).pos.y; - tempEndPts(2).angle = 180.0 - tempEndPts(2).angle; - BuildTrimedTitle( tempCustom, "\t", newTurnManufacturer, newTurnRightDesc, newTurnRightPartno ); - tempSegs_da.cnt = segCnt; + pos = GetEndPtPos(TempEndPt(2)); + angle = GetEndPtAngle(TempEndPt(2)); + pos.y = - pos.y; + angle = 180.0 - angle; + SetEndPt(TempEndPt(2), pos, angle ); + BuildTrimedTitle( tempCustom, "\t", newTurnManufacturer, newTurnRightDesc, + newTurnRightPartno ); #ifndef MKTURNOUT - if (includeNontrackSegments && customTurnout2) + if (includeNontrackSegments && customTurnout2) { CopyNonTracks( customTurnout2 ); - if ( customTurnout2 ) + } + if ( customTurnout2 ) { customTurnout2->segCnt = 0; - to = CreateNewTurnout( newTurnScaleName, tempCustom, tempSegs_da.cnt, &tempSegs(0), - pp->paths, tempEndPts_da.cnt, &tempEndPts(0), FALSE, options ); + } + to = CreateNewTurnout( newTurnScaleName, tempCustom, tempSegs_da.cnt, + &tempSegs(0), + pp->paths, TempEndPtsCount(), TempEndPt(0), FALSE, options ); to->customInfo = customInfoP; #endif if (f) { - fprintf( f, "TURNOUT %s \"%s\" %ld\n", newTurnScaleName, PutTitle(tempCustom), options ); + fprintf( f, "TURNOUT %s \"%s\" %ld\n", newTurnScaleName, PutTitle(tempCustom), + options ); #ifdef MKTURNOUT if (doCustomInfoLine) #endif - fprintf( f, "\tU %s\n", customInfoP ); - WriteCompoundPathsEndPtsSegs( f, pp->paths, tempSegs_da.cnt, &tempSegs(0), tempEndPts_da.cnt, &tempEndPts(0) ); + fprintf( f, "\tU %s\n", customInfoP ); + WriteCompoundPathsEndPtsSegs( f, pp->paths, tempSegs_da.cnt, &tempSegs(0), + TempEndPtsCount(), TempEndPt(0) ); } break; case NTO_CURVED: @@ -2793,28 +3040,39 @@ static void NewTurnOk( void * context ) angles[5] = -angles[5]; angles[6] = -angles[6]; LoadSegs( curDesign, FALSE ); - tempEndPts(1).pos.y = - tempEndPts(1).pos.y; - tempEndPts(1).angle = 180.0 - tempEndPts(1).angle; - tempEndPts(2).pos.y = - tempEndPts(2).pos.y; - tempEndPts(2).angle = 180.0 - tempEndPts(2).angle; - BuildTrimedTitle( tempCustom, "\t", newTurnManufacturer, newTurnRightDesc, newTurnRightPartno ); - //tempSegs_da.cnt = segCnt; + pos = GetEndPtPos(TempEndPt(1)); + angle = GetEndPtAngle(TempEndPt(1)); + pos.y = - pos.y; + angle = 180.0 - angle; + SetEndPt( TempEndPt(1), pos, angle ); + pos = GetEndPtPos(TempEndPt(2)); + angle = GetEndPtAngle(TempEndPt(2)); + pos.y = - pos.y; + angle = 180.0 - angle; + SetEndPt( TempEndPt(2), pos, angle ); + BuildTrimedTitle( tempCustom, "\t", newTurnManufacturer, newTurnRightDesc, + newTurnRightPartno ); #ifndef MKTURNOUT - if (includeNontrackSegments && customTurnout2) + if (includeNontrackSegments && customTurnout2) { CopyNonTracks( customTurnout2 ); - if ( customTurnout2 ) + } + if ( customTurnout2 ) { customTurnout2->segCnt = 0; - to = CreateNewTurnout( newTurnScaleName, tempCustom, tempSegs_da.cnt, &tempSegs(0), - pp->paths, tempEndPts_da.cnt, &tempEndPts(0), FALSE, options ); + } + to = CreateNewTurnout( newTurnScaleName, tempCustom, tempSegs_da.cnt, + &tempSegs(0), + pp->paths, TempEndPtsCount(), TempEndPt(0), FALSE, options ); to->customInfo = customInfoP; #endif if (f) { - fprintf( f, "TURNOUT %s \"%s\" %ld\n", newTurnScaleName, PutTitle(tempCustom), options ); + fprintf( f, "TURNOUT %s \"%s\" %ld\n", newTurnScaleName, PutTitle(tempCustom), + options ); #ifdef MKTURNOUT if (doCustomInfoLine) #endif - fprintf( f, "\tU %s\n", customInfoP ); - WriteCompoundPathsEndPtsSegs( f, pp->paths, tempSegs_da.cnt, &tempSegs(0), tempEndPts_da.cnt, &tempEndPts(0) ); + fprintf( f, "\tU %s\n", customInfoP ); + WriteCompoundPathsEndPtsSegs( f, pp->paths, tempSegs_da.cnt, &tempSegs(0), + TempEndPtsCount(), TempEndPt(0) ); } break; default: @@ -2823,8 +3081,9 @@ static void NewTurnOk( void * context ) tempCustom[0] = '\0'; #ifndef MKTURNOUT - if (f) + if (f) { fclose(f); + } SetUserLocale(); includeNontrackSegments = TRUE; wHide( newTurnW ); @@ -2848,15 +3107,16 @@ static wWinPix_t turnDesignWidth; static wWinPix_t turnDesignHeight; static void TurnDesignLayout( - paramData_t * pd, - int index, - wWinPix_t colX, - wWinPix_t * w, - wWinPix_t * h ) + paramData_t * pd, + int index, + wWinPix_t colX, + wWinPix_t * w, + wWinPix_t * h ) { wIndex_t inx; - if ( curDesign == NULL ) + if ( curDesign == NULL ) { return; + } if ( index >= I_TO_FIRST_FLOAT && index <= I_TO_LAST_FLOAT ) { for ( inx=0; inx<curDesign->floatCnt; inx++ ) { if ( index == curDesign->floats[inx].index ) { @@ -2865,7 +3125,7 @@ static void TurnDesignLayout( return; } } - AbortProg( "turnDesignLayout: bad index = %d", index ); + CHECKMSG( FALSE, ( "turnDesignLayout: bad index = %d", index ) ); } else if ( index == I_TOMANUF ) { *h = turnDesignHeight + 10; } @@ -2881,18 +3141,21 @@ static void SetupTurnoutDesignerW( toDesignDesc_t * newDesign ) if ( newTurnW == NULL ) { partnoWidth = wLabelWidth( "999-99999-9999" ); turnDesignPLs[I_TOLDESC+1].winData = - turnDesignPLs[I_TORDESC+1].winData = - I2VP(partnoWidth); + turnDesignPLs[I_TORDESC+1].winData = + I2VP(partnoWidth); partnoWidth += wLabelWidth( " # " ); - newTurnW = ParamCreateDialog( &turnDesignPG, _("Turnout Designer"), _("Print"), NewTurnPrint, NewTurnCancel, TRUE, TurnDesignLayout, F_BLOCK, NULL ); + newTurnW = ParamCreateDialog( &turnDesignPG, _("Turnout Designer"), _("Print"), + NewTurnPrint, NewTurnCancel, TRUE, TurnDesignLayout, F_BLOCK, NULL ); for ( inx=0; inx<COUNT( designDescs ); inx++ ) { - designDescs[inx]->lineC = wLineCreate( turnDesignPG.win, NULL, designDescs[inx]->lineCnt, designDescs[inx]->lines ); + designDescs[inx]->lineC = wLineCreate( turnDesignPG.win, NULL, + designDescs[inx]->lineCnt, designDescs[inx]->lines ); wControlShow( (wControl_p)designDescs[inx]->lineC, FALSE ); } } if ( curDesign != newDesign ) { - if ( curDesign ) + if ( curDesign ) { wControlShow( (wControl_p)curDesign->lineC, FALSE ); + } curDesign = newDesign; sprintf( message, _("%s %s Designer"), sProdName, _(curDesign->label) ); wWinSetTitle( newTurnW, message ); @@ -2902,7 +3165,8 @@ static void SetupTurnoutDesignerW( toDesignDesc_t * newDesign ) } for ( inx=0; inx<curDesign->floatCnt; inx++ ) { turnDesignPLs[curDesign->floats[inx].index].option &= ~PDO_DLGIGNORE; - wControlSetLabel( turnDesignPLs[curDesign->floats[inx].index].control, _(curDesign->floats[inx].winLabel) ); + wControlSetLabel( turnDesignPLs[curDesign->floats[inx].index].control, + _(curDesign->floats[inx].winLabel) ); wControlShow( turnDesignPLs[curDesign->floats[inx].index].control, TRUE ); } wControlShow( turnDesignPLs[I_TORDESC+0].control, curDesign->strCnt>1 ); @@ -2910,24 +3174,30 @@ static void SetupTurnoutDesignerW( toDesignDesc_t * newDesign ) wControlShow( (wControl_p)curDesign->lineC, TRUE ); turnDesignWidth = turnDesignHeight = 0; - for (inx=0;inx<curDesign->lineCnt;inx++) { - if (curDesign->lines[inx].x0 > turnDesignWidth) + for (inx=0; inx<curDesign->lineCnt; inx++) { + if (curDesign->lines[inx].x0 > turnDesignWidth) { turnDesignWidth = curDesign->lines[inx].x0; - if (curDesign->lines[inx].x1 > turnDesignWidth) + } + if (curDesign->lines[inx].x1 > turnDesignWidth) { turnDesignWidth = curDesign->lines[inx].x1; - if (curDesign->lines[inx].y0 > turnDesignHeight) + } + if (curDesign->lines[inx].y0 > turnDesignHeight) { turnDesignHeight = curDesign->lines[inx].y0; - if (curDesign->lines[inx].y1 > turnDesignHeight) + } + if (curDesign->lines[inx].y1 > turnDesignHeight) { turnDesignHeight = curDesign->lines[inx].y1; + } } ctlH = wControlGetHeight( turnDesignPLs[I_TO_FIRST_FLOAT].control ); for ( inx=0; inx<curDesign->floatCnt; inx++ ) { w = curDesign->floats[inx].pos.x + 80; h = curDesign->floats[inx].pos.y + ctlH; - if (turnDesignWidth < w) + if (turnDesignWidth < w) { turnDesignWidth = w; - if (turnDesignHeight < h) + } + if (turnDesignHeight < h) { turnDesignHeight = h; + } } if ( curDesign->strCnt > 1 ) { w = wLabelWidth( _("Right Description") ); @@ -2966,22 +3236,22 @@ static void SetupTurnoutDesignerW( toDesignDesc_t * newDesign ) curDesign->type == NTO_CORNUWYE || curDesign->type == NTO_CORNU3WAY ) { turnDesignPLs[I_TOOFFSET+0].winData = - turnDesignPLs[I_TOOFFSET+1].winData = - turnDesignPLs[I_TOOFFSET+2].winData = - turnDesignPLs[I_TOOFFSET+3].winData = &r_10000_10000; + turnDesignPLs[I_TOOFFSET+1].winData = + turnDesignPLs[I_TOOFFSET+2].winData = + turnDesignPLs[I_TOOFFSET+3].winData = &r_10000_10000; turnDesignPLs[I_TOANGLE+0].winData = - turnDesignPLs[I_TOANGLE+1].winData = - turnDesignPLs[I_TOANGLE+2].winData = - turnDesignPLs[I_TOANGLE+3].winData = &r_90_90; + turnDesignPLs[I_TOANGLE+1].winData = + turnDesignPLs[I_TOANGLE+2].winData = + turnDesignPLs[I_TOANGLE+3].winData = &r_90_90; } else { turnDesignPLs[I_TOOFFSET+0].winData = - turnDesignPLs[I_TOOFFSET+1].winData = - turnDesignPLs[I_TOOFFSET+2].winData = - turnDesignPLs[I_TOOFFSET+3].winData = &r0d001_10000; + turnDesignPLs[I_TOOFFSET+1].winData = + turnDesignPLs[I_TOOFFSET+2].winData = + turnDesignPLs[I_TOOFFSET+3].winData = &r0d001_10000; turnDesignPLs[I_TOANGLE+0].winData = - turnDesignPLs[I_TOANGLE+1].winData = - turnDesignPLs[I_TOANGLE+2].winData = - turnDesignPLs[I_TOANGLE+3].winData = &r0d001_90; + turnDesignPLs[I_TOANGLE+1].winData = + turnDesignPLs[I_TOANGLE+2].winData = + turnDesignPLs[I_TOANGLE+3].winData = &r0d001_90; } ParamLayoutDialog( &turnDesignPG ); } @@ -2991,12 +3261,15 @@ static void SetupTurnoutDesignerW( toDesignDesc_t * newDesign ) static void ShowTurnoutDesigner( void * context ) { wBool_t sameTurnout = FALSE; - if (recordF) - fprintf( recordF, TURNOUTDESIGNER " SHOW %s\n", ((toDesignDesc_t*)context)->label ); + if (recordF) { + fprintf( recordF, TURNOUTDESIGNER " SHOW %s\n", + ((toDesignDesc_t*)context)->label ); + } newTurnScaleName = curScaleName; newTurnTrackGauge = trackGauge; - if (context && (curDesign == context)) + if (context && (curDesign == context)) { sameTurnout = TRUE; + } SetupTurnoutDesignerW( (toDesignDesc_t*)context ); if (!sameTurnout) { /* Clear Values unless same as last time */ newTurnRightDesc[0] = '\0'; @@ -3004,10 +3277,10 @@ static void ShowTurnoutDesigner( void * context ) newTurnLeftDesc[0] = '\0'; newTurnLeftPartno[0] = '\0'; newTurnOff0 = newTurnLen0 = newTurnAngle0 = newTurnRad0 = - newTurnOff1 = newTurnLen1 = newTurnAngle1 = newTurnRad1 = - newTurnOff2 = newTurnLen2 = newTurnAngle2 = newTurnRad2 = - newTurnOff3 = newTurnLen3 = newTurnAngle3 = newTurnRad3 = - newTurnToeL = newTurnToeR = 0.0; + newTurnOff1 = newTurnLen1 = newTurnAngle1 = newTurnRad1 = + newTurnOff2 = newTurnLen2 = newTurnAngle2 = newTurnRad2 = + newTurnOff3 = newTurnLen3 = newTurnAngle3 = newTurnRad3 = + newTurnToeL = newTurnToeR = 0.0; } ParamLoadControls( &turnDesignPG ); ParamGroupRecord( &turnDesignPG ); @@ -3031,18 +3304,21 @@ EXPORT void EditCustomTurnout( turnoutInfo_t * to, turnoutInfo_t * to1 ) long rgb; trkSeg_p sp0, sp1; BOOL_T segsDiff; - DIST_T width; + LWIDTH_T lineWidth; - if ( ! GetArgs( to->customInfo, "qqqqqc", &type, &name, &mfg, &descL, &partL, &cp ) ) + if ( ! GetArgs( to->customInfo, "qqqqqc", &type, &name, &mfg, &descL, &partL, + &cp ) ) { return; + } for ( i=0; i<COUNT( designDescs ); i++ ) { dp = designDescs[i]; if ( strcmp( type, dp->label ) == 0 ) { break; } } - if ( i >= COUNT( designDescs ) ) + if ( i >= COUNT( designDescs ) ) { return; + } SetupTurnoutDesignerW(dp); newTurnTrackGauge = GetScaleTrackGauge( to->scaleInx ); @@ -3050,25 +3326,30 @@ EXPORT void EditCustomTurnout( turnoutInfo_t * to, turnoutInfo_t * to1 ) strcpy( newTurnManufacturer, mfg ); strcpy( newTurnLeftDesc, descL ); strcpy( newTurnLeftPartno, partL ); - if (dp->type == NTO_REGULAR || dp->type == NTO_CURVED || dp->type == NTO_CORNU) { - if ( ! GetArgs( cp, "qqc", &descR, &partR, &cp )) + if (dp->type == NTO_REGULAR || dp->type == NTO_CURVED + || dp->type == NTO_CORNU) { + if ( ! GetArgs( cp, "qqc", &descR, &partR, &cp )) { return; + } strcpy( newTurnRightDesc, descR ); strcpy( newTurnRightPartno, partR ); } else { descR = partR = ""; } for ( i=0; i<dp->floatCnt; i++ ) { - if ( ! GetArgs( cp, "fc", turnDesignPLs[dp->floats[i].index].valueP, &cp ) ) + if ( ! GetArgs( cp, "fc", turnDesignPLs[dp->floats[i].index].valueP, &cp ) ) { return; + } switch (dp->floats[i].mode) { case Dim_e: /* *dp->floats[i].valueP = PutDim( *dp->floats[i].valueP ); */ break; case Frog_e: if (newTurnAngleMode == 0) { - if ( *(FLOAT_T*)(turnDesignPLs[dp->floats[i].index].valueP) > 0.0 ) - *(FLOAT_T*)(turnDesignPLs[dp->floats[i].index].valueP) = 1.0/sin(D2R(*(FLOAT_T*)(turnDesignPLs[dp->floats[i].index].valueP))); + if ( *(FLOAT_T*)(turnDesignPLs[dp->floats[i].index].valueP) > 0.0 ) { + *(FLOAT_T*)(turnDesignPLs[dp->floats[i].index].valueP) = 1.0/sin(D2R(* + (FLOAT_T*)(turnDesignPLs[dp->floats[i].index].valueP))); + } } break; case Angle_e: @@ -3078,13 +3359,13 @@ EXPORT void EditCustomTurnout( turnoutInfo_t * to, turnoutInfo_t * to1 ) } } rgb = 0; - if ( cp && GetArgs( cp, "ffl", &newTurnRoadbedWidth, &width, &rgb ) ) { - roadbedColor = wDrawFindColor(rgb); - newTurnRoadbedLineWidth = (long)floor(width*mainD.dpi+0.5); + if ( cp && GetArgs( cp, "ffl", &newTurnRoadbedWidth, &lineWidth, &rgb ) ) { + newTurnRoadbedColor = wDrawFindColor(rgb); + newTurnRoadbedLineWidth = lineWidth; } else { newTurnRoadbedWidth = 0; newTurnRoadbedLineWidth = 0; - roadbedColor = wDrawColorBlack; + newTurnRoadbedColor = wDrawColorBlack; } customTurnout1 = to; @@ -3095,28 +3376,31 @@ EXPORT void EditCustomTurnout( turnoutInfo_t * to, turnoutInfo_t * to1 ) LoadSegs( dp, TRUE ); segsDiff = FALSE; if ( to->segCnt == tempSegs_da.cnt ) { - for ( sp0=to->segs,sp1=&tempSegs(0); (!segsDiff) && sp0<&to->segs[to->segCnt]; sp0++,sp1++ ) { + for ( sp0=to->segs,sp1=&tempSegs(0); (!segsDiff) + && sp0<&to->segs[to->segCnt]; sp0++,sp1++ ) { switch (sp0->type) { case SEG_STRLIN: if (sp0->type != sp1->type || - sp0->color != sp1->color || - NotClose(sp0->width-width) || - NotClose(sp0->u.l.pos[0].x-sp1->u.l.pos[0].x) || - NotClose(sp0->u.l.pos[0].y-sp1->u.l.pos[0].y) || - NotClose(sp0->u.l.pos[1].x-sp1->u.l.pos[1].x) || - NotClose(sp0->u.l.pos[1].y-sp1->u.l.pos[1].y) ) - segsDiff = TRUE; + sp0->color != sp1->color || + NotClose(sp0->lineWidth-lineWidth) || + NotClose(sp0->u.l.pos[0].x-sp1->u.l.pos[0].x) || + NotClose(sp0->u.l.pos[0].y-sp1->u.l.pos[0].y) || + NotClose(sp0->u.l.pos[1].x-sp1->u.l.pos[1].x) || + NotClose(sp0->u.l.pos[1].y-sp1->u.l.pos[1].y) ) { + segsDiff = TRUE; + } break; case SEG_CRVLIN: if (sp0->type != sp1->type || - sp0->color != sp1->color || - NotClose(sp0->width-width) || - NotClose(sp0->u.c.center.x-sp1->u.c.center.x) || - NotClose(sp0->u.c.center.y-sp1->u.c.center.y) || - NotClose(sp0->u.c.radius-sp1->u.c.radius) || - NotClose(sp0->u.c.a0-sp1->u.c.a0) || - NotClose(sp0->u.c.a1-sp1->u.c.a1) ) - segsDiff = TRUE; + sp0->color != sp1->color || + NotClose(sp0->lineWidth-lineWidth) || + NotClose(sp0->u.c.center.x-sp1->u.c.center.x) || + NotClose(sp0->u.c.center.y-sp1->u.c.center.y) || + NotClose(sp0->u.c.radius-sp1->u.c.radius) || + NotClose(sp0->u.c.a0-sp1->u.c.a0) || + NotClose(sp0->u.c.a1-sp1->u.c.a1) ) { + segsDiff = TRUE; + } break; case SEG_STRTRK: case SEG_CRVTRK: @@ -3128,12 +3412,15 @@ EXPORT void EditCustomTurnout( turnoutInfo_t * to, turnoutInfo_t * to1 ) } } else { for ( sp0=to->segs; (!segsDiff) && sp0<&to->segs[to->segCnt]; sp0++ ) { - if ( sp0->type != SEG_STRTRK && sp0->type != SEG_CRVTRK && sp0->type != SEG_BEZTRK) + if ( sp0->type != SEG_STRTRK && sp0->type != SEG_CRVTRK + && sp0->type != SEG_BEZTRK) { segsDiff = TRUE; + } } } } - if ( (!segsDiff) && to1 && (dp->type==NTO_REGULAR||dp->type==NTO_CURVED||dp->type == NTO_CORNU) ) { + if ( (!segsDiff) && to1 && (dp->type==NTO_REGULAR||dp->type==NTO_CURVED + ||dp->type == NTO_CORNU) ) { if ( dp->type==NTO_REGULAR ) { points[2].y = - points[2].y; radii[0] = - radii[0]; @@ -3169,28 +3456,31 @@ EXPORT void EditCustomTurnout( turnoutInfo_t * to, turnoutInfo_t * to1 ) } segsDiff = FALSE; if ( to1->segCnt == tempSegs_da.cnt ) { - for ( sp0=to1->segs,sp1=&tempSegs(0); (!segsDiff) && sp0<&to1->segs[to1->segCnt]; sp0++,sp1++ ) { + for ( sp0=to1->segs,sp1=&tempSegs(0); (!segsDiff) + && sp0<&to1->segs[to1->segCnt]; sp0++,sp1++ ) { switch (sp0->type) { case SEG_STRLIN: if (sp0->type != sp1->type || - sp0->color != sp1->color || - NotClose(sp0->width-width) || - NotClose(sp0->u.l.pos[0].x-sp1->u.l.pos[0].x) || - NotClose(sp0->u.l.pos[0].y-sp1->u.l.pos[0].y) || - NotClose(sp0->u.l.pos[1].x-sp1->u.l.pos[1].x) || - NotClose(sp0->u.l.pos[1].y-sp1->u.l.pos[1].y) ) - segsDiff = TRUE; + sp0->color != sp1->color || + NotClose(sp0->lineWidth-lineWidth) || + NotClose(sp0->u.l.pos[0].x-sp1->u.l.pos[0].x) || + NotClose(sp0->u.l.pos[0].y-sp1->u.l.pos[0].y) || + NotClose(sp0->u.l.pos[1].x-sp1->u.l.pos[1].x) || + NotClose(sp0->u.l.pos[1].y-sp1->u.l.pos[1].y) ) { + segsDiff = TRUE; + } break; case SEG_CRVLIN: if (sp0->type != sp1->type || - sp0->color != sp1->color || - NotClose(sp0->width-width) || - NotClose(sp0->u.c.center.x-sp1->u.c.center.x) || - NotClose(sp0->u.c.center.y-sp1->u.c.center.y) || - NotClose(sp0->u.c.radius-sp1->u.c.radius) || - NotClose(sp0->u.c.a0-sp1->u.c.a0) || - NotClose(sp0->u.c.a1-sp1->u.c.a1) ) - segsDiff = TRUE; + sp0->color != sp1->color || + NotClose(sp0->lineWidth-lineWidth) || + NotClose(sp0->u.c.center.x-sp1->u.c.center.x) || + NotClose(sp0->u.c.center.y-sp1->u.c.center.y) || + NotClose(sp0->u.c.radius-sp1->u.c.radius) || + NotClose(sp0->u.c.a0-sp1->u.c.a0) || + NotClose(sp0->u.c.a1-sp1->u.c.a1) ) { + segsDiff = TRUE; + } break; case SEG_STRTRK: case SEG_CRVTRK: @@ -3202,8 +3492,10 @@ EXPORT void EditCustomTurnout( turnoutInfo_t * to, turnoutInfo_t * to1 ) } } else { for ( sp0=to1->segs; (!segsDiff) && sp0<&to1->segs[to1->segCnt]; sp0++ ) { - if ( sp0->type != SEG_STRTRK && sp0->type != SEG_CRVTRK && sp0->type != SEG_BEZTRK) + if ( sp0->type != SEG_STRTRK && sp0->type != SEG_CRVTRK + && sp0->type != SEG_BEZTRK) { segsDiff = TRUE; + } } } } @@ -3230,12 +3522,13 @@ EXPORT void InitNewTurn( wMenu_p m ) ParamRegister( &turnDesignPG ); for ( i=0; i<COUNT( designDescs ); i++ ) { wMenuPushCreate( m, NULL, _(designDescs[i]->label), 0, - ShowTurnoutDesigner, designDescs[i] ); + ShowTurnoutDesigner, designDescs[i] ); sprintf( message, "%s SHOW %s", TURNOUTDESIGNER, designDescs[i]->label ); AddPlaybackProc( message, (playbackProc_p)ShowTurnoutDesigner, designDescs[i] ); } - roadbedColor = wDrawColorBlack; + newTurnRoadbedColor = wDrawColorBlack; includeNontrackSegments = TRUE; + log_cornuturnoutdesigner = LogFindIndex( "cornuturnoutdesigner" ); } #endif @@ -3247,19 +3540,30 @@ char * curScaleName; double trackGauge; long units = 0; wDrawColor drawColorBlack; -long roadbedColorRGB = 0; +long newTurnRoadbedColorRGB = 0; -EXPORT void AbortProg( - const char * msg, - ... ) +EXPORT const char * AbortMessage( + const char * sFormat, + ... ) { - static BOOL_T abort2 = FALSE; -// int rc; + static char sMessage[STR_SIZE]; + if ( sFormat == NULL ) { + return ""; + } va_list ap; - va_start( ap, msg ); - vsprintf( message, msg, ap ); - va_end( ap ); - fprintf( stderr, "%s", message ); + va_start(ap, sFormat); + vsnprintf(sMessage, sizeof sMessage, sFormat, ap); + va_end(ap); + return sMessage; +} + +EXPORT void AbortProg( + const char * sCond, + const char * sFileName, + int iLineNumber, + const char * sMsg ) +{ + fprintf( stderr, "%s: %s:%d %s", sCond, sFileName, iLineNumber, sMsg ); abort(); } @@ -3276,6 +3580,11 @@ EXPORT char * MyStrdup( const char * str ) return ret; } +EXPORT void LogPrintf( + const char * format, + ... ) +{ +} int NoticeMessage( const char * msg, const char * yes, const char * no, ... ) { @@ -3293,10 +3602,10 @@ void wPrintSetup( wPrintSetupCallBack_p notused ) } EXPORT void ComputeCurvedSeg( - trkSeg_p s, - DIST_T radius, - coOrd p0, - coOrd p1 ) + trkSeg_p s, + DIST_T radius, + coOrd p0, + coOrd p1 ) { DIST_T d; ANGLE_T a, aa, aaa; @@ -3321,14 +3630,16 @@ EXPORT void ComputeCurvedSeg( EXPORT char * Strcpytrimed( char * dst, const char * src, BOOL_T double_quotes ) { const char * cp; - while (*src && isspace((unsigned char)*src) ) src++; - if (!*src) + while (*src && isspace((unsigned char)*src) ) { src++; } + if (!*src) { return dst; + } cp = src+strlen(src)-1; - while ( cp>src && isspace((unsigned char)*cp) ) cp--; + while ( cp>src && isspace((unsigned char)*cp) ) { cp--; } while ( src<=cp ) { - if (*src == '"' && double_quotes) + if (*src == '"' && double_quotes) { *dst++ = '"'; + } *dst++ = *src++; } *dst = '\0'; @@ -3336,17 +3647,6 @@ EXPORT char * Strcpytrimed( char * dst, const char * src, BOOL_T double_quotes ) } -EXPORT char * BuildTrimedTitle( char * cp, const char * sep, const char * mfg, const char * desc, const char * partno ) -{ - cp = Strcpytrimed( cp, mfg, FALSE ); - strcpy( cp, sep ); - cp += strlen(cp); - cp = Strcpytrimed( cp, desc, FALSE ); - strcpy( cp, sep ); - cp += strlen(cp); - cp = Strcpytrimed( cp, partno, FALSE ); - return cp; -} EXPORT char * PutTitle( char * cp ) @@ -3368,15 +3668,15 @@ EXPORT char * PutTitle( char * cp ) long wDrawGetRGB( - wDrawColor color ) + wDrawColor color ) { - return roadbedColorRGB; + return newTurnRoadbedColorRGB; } EXPORT BOOL_T WriteSegs( - FILE * f, - wIndex_t segCnt, - trkSeg_p segs ) + FILE * f, + wIndex_t segCnt, + trkSeg_p segs ) { int i, j; BOOL_T rc = TRUE; @@ -3385,32 +3685,34 @@ EXPORT BOOL_T WriteSegs( case SEG_STRLIN: case SEG_STRTRK: rc &= fprintf( f, "\t%c %ld %0.6f %0.6f %0.6f %0.6f %0.6f\n", - segs[i].type, (segs[i].type==SEG_STRTRK?0:roadbedColorRGB), segs[i].width, - segs[i].u.l.pos[0].x, segs[i].u.l.pos[0].y, - segs[i].u.l.pos[1].x, segs[i].u.l.pos[1].y )>0; + segs[i].type, (segs[i].type==SEG_STRTRK?0:newTurnRoadbedColorRGB), + segs[i].lineWidth, + segs[i].u.l.pos[0].x, segs[i].u.l.pos[0].y, + segs[i].u.l.pos[1].x, segs[i].u.l.pos[1].y )>0; break; case SEG_CRVTRK: case SEG_CRVLIN: rc &= fprintf( f, "\t%c %ld %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f\n", - segs[i].type, (segs[i].type==SEG_CRVTRK?0:roadbedColorRGB), segs[i].width, - fabs(segs[i].u.c.radius), - segs[i].u.c.center.x, segs[i].u.c.center.y, - segs[i].u.c.a0, segs[i].u.c.a1 )>0; + segs[i].type, (segs[i].type==SEG_CRVTRK?0:newTurnRoadbedColorRGB), + segs[i].lineWidth, + fabs(segs[i].u.c.radius), + segs[i].u.c.center.x, segs[i].u.c.center.y, + segs[i].u.c.a0, segs[i].u.c.a1 )>0; break; case SEG_FILCRCL: rc &= fprintf( f, "\t%c %ld %0.6f %0.6f %0.6f %0.6f\n", - segs[i].type, roadbedColorRGB, segs[i].width, - fabs(segs[i].u.c.radius), - segs[i].u.c.center.x, segs[i].u.c.center.y )>0; + segs[i].type, newTurnRoadbedColorRGB, segs[i].lineWidth, + fabs(segs[i].u.c.radius), + segs[i].u.c.center.x, segs[i].u.c.center.y )>0; break; case SEG_POLY: case SEG_FILPOLY: rc &= fprintf( f, "\t%c %ld %0.6f %d\n", - segs[i].type, roadbedColorRGB, segs[i].width, - segs[i].u.p.cnt )>0; + segs[i].type, newTurnRoadbedColorRGB, segs[i].lineWidth, + segs[i].u.p.cnt )>0; for ( j=0; j<segs[i].u.p.cnt; j++ ) rc &= fprintf( f, "\t\t%0.6f %0.6f\n", - segs[i].u.p.pts[j].pt.x, segs[i].u.p.pts[j].pt.y )>0; + segs[i].u.p.pts[j].pt.x, segs[i].u.p.pts[j].pt.y )>0; break; } } @@ -3419,28 +3721,32 @@ EXPORT BOOL_T WriteSegs( } BOOL_T WriteCompoundPathsEndPtsSegs( - FILE * f, - PATHPTR_T paths, - wIndex_t segCnt, - trkSeg_p segs, - EPINX_T endPtCnt, - trkEndPt_t * endPts ) + FILE * f, + PATHPTR_T paths, + wIndex_t segCnt, + trkSeg_p segs, + EPINX_T endPtCnt, + trkEndPt_p endPts ) { int i; PATHPTR_T pp; BOOL_T rc = TRUE; for ( pp=paths; *pp; pp+=2 ) { rc &= fprintf( f, "\tP \"%s\"", (char*)pp )>0; - for ( pp+=strlen((char*)pp)+1; pp[0]!=0||pp[1]!=0; pp++ ) + for ( pp+=strlen((char*)pp)+1; pp[0]!=0||pp[1]!=0; pp++ ) { rc &= fprintf( f, " %d", *pp )>0; + } rc &= fprintf( f, "\n" )>0; } for ( i=0; i<endPtCnt; i++ ) rc &= fprintf( f, "\tE %0.6f %0.6f %0.6f\n", - endPts[i].pos.x, endPts[i].pos.y, endPts[i].angle )>0; + GetEndPtPos(EndPtIndex(endPts,i)).x, + GetEndPtPos(EndPtIndex(endPts,i)).y, + GetEndPtAngle(EndPtIndex(endPts,i)) )>0; #ifdef MKTURNOUT - if ( specialLine[0] ) + if ( specialLine[0] ) { rc &= fprintf( f, "%s\n", specialLine ); + } #endif rc &= WriteSegs( f, segCnt, segs ); return rc; @@ -3450,39 +3756,40 @@ BOOL_T WriteCompoundPathsEndPtsSegs( void Usage( int argc, char **argv ) { int inx; - for (inx=1;inx<argc;inx++) + for (inx=1; inx<argc; inx++) { fprintf( stderr, "%s ", argv[inx] ); + } fprintf( stderr, -"\nUsage: [-m] [-u] [-r#] [-c#] [-l#]\n" -" <SCL> <MNF> B <DSC> <PNO> <LEN> # Create bumper\n" -" <SCL> <MNF> S <DSC> <PNO> <LEN> # Create straight track\n" -" <SCL> <MNF> J <DSC> <PNO> <LEN1> <LEN2> # Create adjustable track\n" -" <SCL> <MNF> C <DSC> <PNO> <RAD> <ANG> # Create curved track\n" -" <SCL> <MNF> R <LDSC> <LPNO> <RDSC> <RPNO> <LEN2> <ANG> <OFF> <LEN1> # Create Regular Turnout\n" -" <SCL> <MNF> Q <LDSC> <LPNO> <RDSC> <RPNO> <RAD> <ANG> <LEN> # Create Radial Turnout\n" -" <SCL> <MNF> V <LDSC> <LPNO> <RDSC> <RPNO> <LEN1> <ANG1> <OFF1> <LEN2> <ANG2> <OFF2> # Create Curved Turnout\n" -" <SCL> <MNF> W <LDSC> <LPNO> <RDSC> <RPNO> <RAD1> <ANG2> <RAD2> <ANG2> # Create Radial Curved Turnout\n" -" <SCL> <MNF> Y <LDSC> <LPNO> <RDSC> <RPNO> <LENL> <ANGL> <OFFL> <LENR> <ANGR> <OFFR> # Create Wye Turnout\n" -" <SCL> <MNF> 3 <DSC> <PNO> <LEN0> <LENL> <ANGL> <OFFL> <LENR> <ANGR> <OFFR> # Create 3-Way Turnout\n" -" <SCL> <MNF> X <DSC> <PNO> <LEN1> <ANG> <LEN2> # Create Crossing\n" -" <SCL> <MNF> 1 <DSC> <PNO> <LEN1> <ANG> <LEN2> # Create Single Slipswitch\n" -" <SCL> <MNF> 2 <DSC> <PNO> <LEN1> <ANG> <LEN2> # Create Double Slipswitch\n" -" <SCL> <MNF> D <DSC> <PNO> <LEN> <OFF> # Create Double Crossover\n" -" <SCL> <MNF> T <DSC> <PNO> <CNT> <IN-DIAM> <OUT-DIAM> # Create TurnTable\n" -); - exit(1); + "\nUsage: [-m] [-u] [-r#] [-c#] [-l#]\n" + " <SCL> <MNF> B <DSC> <PNO> <LEN> # Create bumper\n" + " <SCL> <MNF> S <DSC> <PNO> <LEN> # Create straight track\n" + " <SCL> <MNF> J <DSC> <PNO> <LEN1> <LEN2> # Create adjustable track\n" + " <SCL> <MNF> C <DSC> <PNO> <RAD> <ANG> # Create curved track\n" + " <SCL> <MNF> R <LDSC> <LPNO> <RDSC> <RPNO> <LEN2> <ANG> <OFF> <LEN1> # Create Regular Turnout\n" + " <SCL> <MNF> Q <LDSC> <LPNO> <RDSC> <RPNO> <RAD> <ANG> <LEN> # Create Radial Turnout\n" + " <SCL> <MNF> V <LDSC> <LPNO> <RDSC> <RPNO> <LEN1> <ANG1> <OFF1> <LEN2> <ANG2> <OFF2> # Create Curved Turnout\n" + " <SCL> <MNF> W <LDSC> <LPNO> <RDSC> <RPNO> <RAD1> <ANG2> <RAD2> <ANG2> # Create Radial Curved Turnout\n" + " <SCL> <MNF> Y <LDSC> <LPNO> <RDSC> <RPNO> <LENL> <ANGL> <OFFL> <LENR> <ANGR> <OFFR> # Create Wye Turnout\n" + " <SCL> <MNF> 3 <DSC> <PNO> <LEN0> <LENL> <ANGL> <OFFL> <LENR> <ANGR> <OFFR> # Create 3-Way Turnout\n" + " <SCL> <MNF> X <DSC> <PNO> <LEN1> <ANG> <LEN2> # Create Crossing\n" + " <SCL> <MNF> 1 <DSC> <PNO> <LEN1> <ANG> <LEN2> # Create Single Slipswitch\n" + " <SCL> <MNF> 2 <DSC> <PNO> <LEN1> <ANG> <LEN2> # Create Double Slipswitch\n" + " <SCL> <MNF> D <DSC> <PNO> <LEN> <OFF> # Create Double Crossover\n" + " <SCL> <MNF> T <DSC> <PNO> <CNT> <IN-DIAM> <OUT-DIAM> # Create TurnTable\n" + ); + exit(1); } struct { - char * scale; - double trackGauge; - } scaleMap[] = { - { "N", 0.3531 }, - { "HO", 0.6486 }, - { "O", 1.1770 }, - { "HOm", 0.472440 }, - { "G", 1.770 } - }; + char * scale; + double trackGauge; +} scaleMap[] = { + { "N", 0.3531 }, + { "HO", 0.6486 }, + { "O", 1.1770 }, + { "HOm", 0.472440 }, + { "G", 1.770 } +}; @@ -3514,15 +3821,16 @@ int main ( int argc, char * argv[] ) break; case 'r': doRoadBed = TRUE; - if (argv[0][2] == '\0') + if (argv[0][2] == '\0') { Usage(argc0,argv0); + } newTurnRoadbedWidth = atof(&argv[0][2]); - roadbedColorRGB = 0; - roadbedColor = 0; + newTurnRoadbedColorRGB = 0; + newTurnRoadbedColor = 0; newTurnRoadbedLineWidth = 0; break; case 'c': - roadbedColorRGB = atol(&argv[0][2]); + newTurnRoadbedColorRGB = atol(&argv[0][2]); break; case 'l': newTurnRoadbedLineWidth = atol(&argv[0][2]); @@ -3550,7 +3858,7 @@ int main ( int argc, char * argv[] ) specialLine[0] = '\0'; switch (tolower((unsigned char)(*argv++)[0])) { case 'b': - if (argc != 7) Usage(argc0,argv0); + if (argc != 7) { Usage(argc0,argv0); } strcpy( newTurnLeftDesc, *argv++ ); strcpy( newTurnLeftPartno, *argv++ ); newTurnLen0 = GetDim(atof( *argv++ )); @@ -3558,7 +3866,7 @@ int main ( int argc, char * argv[] ) NewTurnOk( &StrSectionDesc ); break; case 's': - if (argc != 7) Usage(argc0,argv0); + if (argc != 7) { Usage(argc0,argv0); } strcpy( newTurnLeftDesc, *argv++ ); strcpy( newTurnLeftPartno, *argv++ ); newTurnLen0 = GetDim(atof( *argv++ )); @@ -3566,7 +3874,7 @@ int main ( int argc, char * argv[] ) NewTurnOk( &StrSectionDesc ); break; case 'j': - if (argc != 8) Usage(argc0,argv0); + if (argc != 8) { Usage(argc0,argv0); } strcpy( newTurnLeftDesc, *argv++ ); strcpy( newTurnLeftPartno, *argv++ ); newTurnLen0 = GetDim(atof( *argv++ )); @@ -3576,7 +3884,7 @@ int main ( int argc, char * argv[] ) NewTurnOk( &StrSectionDesc ); break; case 'c': - if (argc != 8) Usage(argc0,argv0); + if (argc != 8) { Usage(argc0,argv0); } strcpy( newTurnLeftDesc, *argv++ ); strcpy( newTurnLeftPartno, *argv++ ); newTurnLen0 = GetDim(atof( *argv++ )); @@ -3585,7 +3893,7 @@ int main ( int argc, char * argv[] ) NewTurnOk( &CrvSectionDesc ); break; case 'r': - if (argc != 12) Usage(argc0,argv0); + if (argc != 12) { Usage(argc0,argv0); } strcpy( newTurnLeftDesc, *argv++ ); strcpy( newTurnLeftPartno, *argv++ ); strcpy( newTurnRightDesc, *argv++ ); @@ -3598,7 +3906,7 @@ int main ( int argc, char * argv[] ) NewTurnOk( &RegDesc ); break; case 'q': - if (argc != 11) Usage(argc0,argv0); + if (argc != 11) { Usage(argc0,argv0); } strcpy( newTurnLeftDesc, *argv++ ); strcpy( newTurnLeftPartno, *argv++ ); strcpy( newTurnRightDesc, *argv++ ); @@ -3612,7 +3920,7 @@ int main ( int argc, char * argv[] ) NewTurnOk( &RegDesc ); break; case 'v': - if (argc != 14) Usage(argc0,argv0); + if (argc != 14) { Usage(argc0,argv0); } strcpy( newTurnLeftDesc, *argv++ ); strcpy( newTurnLeftPartno, *argv++ ); strcpy( newTurnRightDesc, *argv++ ); @@ -3627,7 +3935,7 @@ int main ( int argc, char * argv[] ) NewTurnOk( &CrvDesc ); break; case 'w': - if (argc != 12) Usage(argc0,argv0); + if (argc != 12) { Usage(argc0,argv0); } strcpy( newTurnLeftDesc, *argv++ ); strcpy( newTurnLeftPartno, *argv++ ); strcpy( newTurnRightDesc, *argv++ ); @@ -3644,7 +3952,7 @@ int main ( int argc, char * argv[] ) NewTurnOk( &CrvDesc ); break; case 'y': - if (argc != 14) Usage(argc0,argv0); + if (argc != 14) { Usage(argc0,argv0); } strcpy( newTurnLeftDesc, *argv++ ); strcpy( newTurnLeftPartno, *argv++ ); strcpy( newTurnRightDesc, *argv++ ); @@ -3659,7 +3967,7 @@ int main ( int argc, char * argv[] ) NewTurnOk( &WyeDesc ); break; case '3': - if (argc != 13) Usage(argc0,argv0); + if (argc != 13) { Usage(argc0,argv0); } strcpy( newTurnLeftDesc, *argv++ ); strcpy( newTurnLeftPartno, *argv++ ); newTurnLen2 = GetDim(atof( *argv++ )); @@ -3673,7 +3981,7 @@ int main ( int argc, char * argv[] ) NewTurnOk( &ThreewayDesc ); break; case 'x': - if (argc<9) Usage(argc0,argv0); + if (argc<9) { Usage(argc0,argv0); } strcpy( newTurnLeftDesc, *argv++ ); strcpy( newTurnLeftPartno, *argv++ ); newTurnLen0 = GetDim(atof( *argv++ )); @@ -3683,7 +3991,7 @@ int main ( int argc, char * argv[] ) NewTurnOk( &CrossingDesc ); break; case '1': - if (argc<9) Usage(argc0,argv0); + if (argc<9) { Usage(argc0,argv0); } strcpy( newTurnLeftDesc, *argv++ ); strcpy( newTurnLeftPartno, *argv++ ); newTurnLen0 = GetDim(atof( *argv++ )); @@ -3695,7 +4003,7 @@ int main ( int argc, char * argv[] ) case '2': strcpy( newTurnLeftDesc, *argv++ ); strcpy( newTurnLeftPartno, *argv++ ); - if (argc<9) Usage(argc0,argv0); + if (argc<9) { Usage(argc0,argv0); } newTurnLen0 = GetDim(atof( *argv++ )); newTurnAngle0 = atof( *argv++ ); newTurnLen1 = GetDim(atof( *argv++ )); @@ -3705,7 +4013,7 @@ int main ( int argc, char * argv[] ) case 'd': strcpy( newTurnLeftDesc, *argv++ ); strcpy( newTurnLeftPartno, *argv++ ); - if (argc<8) Usage(argc0,argv0); + if (argc<8) { Usage(argc0,argv0); } newTurnLen0 = GetDim(atof( *argv++ )); newTurnOff0 = GetDim(atof( *argv++ )); curDesign = &DoubleCrossoverDesc; @@ -3714,17 +4022,19 @@ int main ( int argc, char * argv[] ) case 't': strcpy( newTurnLeftDesc, *argv++ ); strcpy( newTurnLeftPartno, *argv++ ); - if (argc<9) Usage(argc0,argv0); + if (argc<9) { Usage(argc0,argv0); } cnt = atoi( *argv++ )/2; radius = GetDim(atof( *argv++ ))/2.0; radius2 = GetDim(atof( *argv++ ))/2.0; - BuildTrimedTitle( message, "\t", newTurnManufacturer, newTurnLeftDesc, newTurnLeftPartno ); + BuildTrimedTitle( message, "\t", newTurnManufacturer, newTurnLeftDesc, + newTurnLeftPartno ); fprintf( stdout, "TURNOUT %s \"%s\"\n", curScaleName, PutTitle(message) ); for (inx=0; inx<cnt; inx++) { fprintf( stdout, "\tP \"%d\" %d %d %d\n", inx+1, inx*3+1, inx*3+2, inx*3+3 ); } for (inx=0; inx<cnt; inx++) { - fprintf( stdout, "\tP \"%d\" %d %d %d\n", inx+1+cnt, -(inx*3+3), -(inx*3+2), -(inx*3+1) ); + fprintf( stdout, "\tP \"%d\" %d %d %d\n", inx+1+cnt, -(inx*3+3), -(inx*3+2), + -(inx*3+1) ); } for (inx=0; inx<cnt; inx++) { ang = inx*180.0/cnt; @@ -3743,8 +4053,10 @@ int main ( int argc, char * argv[] ) fprintf( stdout, "\tS 0 0 %0.6f %0.6f %0.6f %0.6f\n", x1, y1, -x1, -y1 ); fprintf( stdout, "\tS 0 0 %0.6f %0.6f %0.6f %0.6f\n", -x1, -y1, -x0, -y0 ); } - fprintf( stdout, "\tA 16711680 0 %0.6f 0.000000 0.000000 0.000000 360.000000\n", radius2 ); - fprintf( stdout, "\tA 16711680 0 %0.6f 0.000000 0.000000 0.000000 360.000000\n", radius ); + fprintf( stdout, "\tA 16711680 0 %0.6f 0.000000 0.000000 0.000000 360.000000\n", + radius2 ); + fprintf( stdout, "\tA 16711680 0 %0.6f 0.000000 0.000000 0.000000 360.000000\n", + radius ); fprintf( stdout, "\t%s\n", END_SEGS ); break; default: diff --git a/app/bin/ctrain.c b/app/bin/ctrain.c index f113ee5..015f9e8 100644 --- a/app/bin/ctrain.c +++ b/app/bin/ctrain.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "compound.h" @@ -29,33 +29,31 @@ #include "layout.h" #include "param.h" #include "track.h" -#include "trackx.h" #include "common-ui.h" long programMode; long maxCouplingSpeed = 100; long hideTrainsInTunnels; -extern int doDrawTurnoutPosition; -extern void NextTurnoutPosition(track_p); +static int doDrawTurnoutPosition = 1; static TRKTYP_T T_CAR = -1; typedef enum { ST_NotOnTrack, ST_StopManual, ST_EndOfTrack, ST_OpenTurnout, ST_NoRoom, ST_Crashed } trainStatus_e; typedef struct extraDataCar_t { - extraDataBase_t base; - traverseTrack_t trvTrk; - long state; - carItem_p item; - double speed; - BOOL_T pencils; - BOOL_T direction; - BOOL_T autoReverse; - trainStatus_e status; - DIST_T distance; - coOrd couplerPos[2]; - unsigned int trkLayer; + extraDataBase_t base; + traverseTrack_t trvTrk; + long state; + carItem_p item; + double speed; + BOOL_T pencils; + BOOL_T direction; + BOOL_T autoReverse; + trainStatus_e status; + DIST_T distance; + coOrd couplerPos[2]; + unsigned int trkLayer; } extraDataCar_t; #define NOTALAYER (127) @@ -93,7 +91,7 @@ static wButton_p newcarB; static void ControllerDialogSyncAll(void); static STATUS_T CmdTrain(wAction_t, coOrd); static wMenu_p trainPopupM; -static wMenuPush_p trainPopupMI[10]; +static wMenuPush_p trainPopupMI[11]; static track_p followTrain; static coOrd followCenter; static BOOL_T trainsTimeoutPending; @@ -101,14 +99,16 @@ static enum { TRAINS_STOP, TRAINS_RUN, TRAINS_IDLE, TRAINS_PAUSE } trainsState; static wIcon_p stopI, goI; static wIcon_p stopB, goB; static void RestartTrains(void); -static void DrawAllCars(void); -static void UncoupleCars(track_p, track_p); +static void DrawAllCars(track_p); +//static void UncoupleCars(track_p, track_p); static void TrainTimeEndPause(void); static void TrainTimeStartPause(void); static int log_trainMove; static int log_trainPlayback; +static track_p trainHighlighted; + static void PlaceCar(track_p); @@ -133,128 +133,128 @@ static void PlaceCar(track_p); */ void CarGetPos( - track_p car, - coOrd * posR, - ANGLE_T * angleR) + track_p car, + coOrd * posR, + ANGLE_T * angleR) { - struct extraDataCar_t * xx = GET_EXTRA_DATA(car, T_CAR, extraDataCar_t); + struct extraDataCar_t * xx = GET_EXTRA_DATA(car, T_CAR, extraDataCar_t); - if (GetTrkType(car) != T_CAR) { - AbortProg("getCarPos"); - } + CHECK (GetTrkType(car) == T_CAR); - *posR = xx->trvTrk.pos; - *angleR = xx->trvTrk.angle; + *posR = xx->trvTrk.pos; + *angleR = xx->trvTrk.angle; } void CarSetVisible( - track_p car) + track_p car) { - struct extraDataCar_t * xx; - int dir; - dir = 0; - WALK_CARS_START(car, xx, dir) - - if (GetTrkType(car) != T_CAR) { - AbortProg("carSetVisible"); - } - - WALK_CARS_END(car, xx, dir) - dir = 1-dir; - WALK_CARS_START(car, xx, dir) { - xx->state &= ~(CAR_STATE_ONHIDENTRACK); - xx->trkLayer = NOTALAYER; - } - WALK_CARS_END(car, xx, dir) + struct extraDataCar_t * xx; + int dir; + dir = 0; + WALK_CARS_START(car, xx, dir) + + CHECK( GetTrkType(car) == T_CAR ); + + WALK_CARS_END(car, xx, dir) + dir = 1-dir; + WALK_CARS_START(car, xx, dir) { + xx->state &= ~(CAR_STATE_ONHIDENTRACK); + xx->trkLayer = NOTALAYER; + } + WALK_CARS_END(car, xx, dir) } static struct { - long index; - coOrd pos; - ANGLE_T angle; - DIST_T length; - DIST_T width; - char desc[STR_SIZE]; - char number[STR_SIZE]; + long index; + coOrd pos; + ANGLE_T angle; + DIST_T length; + DIST_T width; + char desc[STR_SIZE]; + char number[STR_SIZE]; } carData; typedef enum { IT, PN, AN, LN, WD, DE, NM } carDesc_e; static descData_t carDesc[] = { - /*IT*/ { DESC_LONG, N_("Index"), &carData.index }, - /*PN*/ { DESC_POS, N_("Position"), &carData.pos }, - /*AN*/ { DESC_ANGLE, N_("Angle"), &carData.angle }, - /*LN*/ { DESC_DIM, N_("Length"), &carData.length }, - /*WD*/ { DESC_DIM, N_("Width"), &carData.width }, - /*DE*/ { DESC_STRING, N_("Description"), &carData.desc, sizeof(carData.desc) }, - /*NM*/ { DESC_STRING, N_("Rep Marks"), &carData.number, sizeof(carData.number) }, - { DESC_NULL } + /*IT*/ { DESC_LONG, N_("Index"), &carData.index }, + /*PN*/ { DESC_POS, N_("Position"), &carData.pos }, + /*AN*/ { DESC_ANGLE, N_("Angle"), &carData.angle }, + /*LN*/ { DESC_DIM, N_("Length"), &carData.length }, + /*WD*/ { DESC_DIM, N_("Width"), &carData.width }, + /*DE*/ { DESC_STRING, N_("Description"), &carData.desc, sizeof(carData.desc) }, + /*NM*/ { DESC_STRING, N_("Report Marks"), &carData.number, sizeof(carData.number) }, + { DESC_NULL } }; static void UpdateCar( - track_p trk, - int inx, - descData_p descUpd, - BOOL_T needUndoStart) -{ - if (inx == -1) { - BOOL_T titleChanged; - const char * cp; - titleChanged = FALSE; - cp = wStringGetValue((wString_p)carDesc[NM].control0); - unsigned int max_str = sizeof(carData.number); + track_p trk, + int inx, + descData_p descUpd, + BOOL_T needUndoStart) +{ + unsigned int max_str; + struct extraDataCar_t *xx = GET_EXTRA_DATA(trk, T_CAR, extraDataCar_t); + if (inx == -1) { + BOOL_T numberChanged; + const char * cp; + numberChanged = FALSE; + + cp = wStringGetValue((wString_p)carDesc[NM].control0); + max_str = sizeof(carData.number); if (max_str && strlen(cp)>max_str) { NoticeMessage2(0, MSG_ENTERED_STRING_TRUNCATED, _("Ok"), NULL, max_str-1); - } - if (cp && strcmp(carData.number, cp) != 0) { - titleChanged = TRUE; + } + if (cp && strcmp(CarItemNumber(xx->item), cp) != 0) { + numberChanged = TRUE; carData.number[0] = '\0'; strncat(carData.number, cp, max_str - 1); - } + } - if (!titleChanged) { - return; - } + if (!numberChanged) { + return; + } - if (needUndoStart) { - UndoStart(_("Change Track"), "Change Track"); - } + if (needUndoStart) { + UndoStart(_("Change Track"), "Change Track"); + } - UndoModify(trk); - UndrawNewTrack(trk); - DrawNewTrack(trk); - return; - } + UndoModify(trk); + CarItemSetNumber(xx->item, carData.number); + UndrawNewTrack(trk); + DrawNewTrack(trk); + return; + } - UndrawNewTrack(trk); + UndrawNewTrack(trk); - switch (inx) { - case NM: - break; + switch (inx) { + case NM: + break; - default: - break; - } + default: + break; + } - DrawNewTrack(trk); + DrawNewTrack(trk); } static void DescribeCar( - track_p trk, - char * str, - CSIZE_T len) -{ - struct extraDataCar_t *xx = GET_EXTRA_DATA(trk, T_CAR, extraDataCar_t); - char * cp; - coOrd size; - CarItemSize(xx->item, &size); - carData.length = size.x; - carData.width = size.y; - cp = CarItemDescribe(xx->item, 0, &carData.index); + track_p trk, + char * str, + CSIZE_T len) +{ + struct extraDataCar_t *xx = GET_EXTRA_DATA(trk, T_CAR, extraDataCar_t); + char * cp; + coOrd size; + CarItemSize(xx->item, &size); + carData.length = size.x; + carData.width = size.y; + cp = CarItemDescribe(xx->item, 0, &carData.index); carData.number[0] = '\0'; strncat(carData.number, CarItemNumber(xx->item), - sizeof(carData.number) - 1); + sizeof(carData.number) - 1); str[0] = '\0'; strncat(str, cp, len - 1); carData.pos = xx->trvTrk.pos; @@ -263,70 +263,71 @@ static void DescribeCar( carData.desc[0] = '\0'; strncat(carData.desc, cp, sizeof(carData.desc) - 1); - carDesc[IT].mode = - carDesc[PN].mode = - carDesc[AN].mode = - carDesc[LN].mode = - carDesc[WD].mode = DESC_RO; - carDesc[DE].mode = - carDesc[NM].mode = DESC_RO; - DoDescribe(_("Car"), trk, carDesc, UpdateCar); + carDesc[IT].mode = + carDesc[PN].mode = + carDesc[AN].mode = + carDesc[LN].mode = + carDesc[WD].mode = DESC_RO; + carDesc[DE].mode = DESC_RO; + carDesc[NM].mode = 0; + DoDescribe(_("Car"), trk, carDesc, UpdateCar); } void FlipTraverseTrack( - traverseTrack_p trvTrk) + traverseTrack_p trvTrk) { - trvTrk->angle = NormalizeAngle(trvTrk->angle + 180.0); + trvTrk->angle = NormalizeAngle(trvTrk->angle + 180.0); - if (trvTrk->length > 0) { - trvTrk->dist = trvTrk->length - trvTrk->dist; - } + if (trvTrk->length > 0) { + trvTrk->dist = trvTrk->length - trvTrk->dist; + } } BOOL_T TraverseTrack2( - traverseTrack_p trvTrk0, - DIST_T dist0) + traverseTrack_p trvTrk0, + DIST_T dist0) { - traverseTrack_t trvTrk = *trvTrk0; - DIST_T dist = dist0; + traverseTrack_t trvTrk = *trvTrk0; + DIST_T dist = dist0; - if (dist0 < 0) { - dist = -dist; - FlipTraverseTrack(&trvTrk); - } + if (dist0 < 0) { + dist = -dist; + FlipTraverseTrack(&trvTrk); + } - if (trvTrk.trk==NULL || - (!TraverseTrack(&trvTrk,&dist)) || - trvTrk.trk==NULL || - dist!=0.0) { - Translate(&trvTrk.pos, trvTrk.pos, trvTrk.angle, dist); + if (trvTrk.trk==NULL || + (!TraverseTrack(&trvTrk,&dist)) || + trvTrk.trk==NULL || + dist!=0.0) { + Translate(&trvTrk.pos, trvTrk.pos, trvTrk.angle, dist); - } + } - if (dist0 < 0) { - FlipTraverseTrack(&trvTrk); - } + if (dist0 < 0) { + FlipTraverseTrack(&trvTrk); + } - *trvTrk0 = trvTrk; - return TRUE; + *trvTrk0 = trvTrk; + return TRUE; } /*************** * When a track is deleted, cross check that the Traverse Track reference is removed. */ -EXPORT void CheckCarTraverse(track_p track) { +EXPORT void CheckCarTraverse(track_p track) +{ - track_p car; + track_p car; for (car=NULL; TrackIterate(&car);) { - if (GetTrkType(car) == T_CAR) { - struct extraDataCar_t * xx = GET_EXTRA_DATA(car, T_CAR, extraDataCar_t); + if (GetTrkType(car) == T_CAR) { + struct extraDataCar_t * xx = GET_EXTRA_DATA(car, T_CAR, extraDataCar_t); if (xx->trvTrk.trk == track) { xx->trvTrk.trk=NULL; xx->status = ST_NotOnTrack; } - } + } } } @@ -337,225 +338,294 @@ static BOOL_T drawCarEnable = TRUE; static BOOL_T noCarDraw = FALSE; static void DrawCar( - track_p car, - drawCmd_p d, - wDrawColor color) + track_p car, + drawCmd_p d, + wDrawColor color) { - struct extraDataCar_t * xx = GET_EXTRA_DATA(car, T_CAR, extraDataCar_t); - int dir; - vector_t coupler[2]; - struct extraDataCar_t * xx1; - int dir1; - - if (drawCarEnable == FALSE) { - return; - } + struct extraDataCar_t * xx = GET_EXTRA_DATA(car, T_CAR, extraDataCar_t); + int dir; + vector_t coupler[2]; + struct extraDataCar_t * xx1; + int dir1; + + if (drawCarEnable == FALSE) { + return; + } - if (d == &mapD) { - return; - } + if (d == &mapD) { + return; + } - if (noCarDraw) { - return; - } + if (noCarDraw) { + return; + } - if (hideTrainsInTunnels && - ((((xx->state&CAR_STATE_ONHIDENTRACK)!=0) && drawTunnel==0) || - (xx->trkLayer!=NOTALAYER && !GetLayerVisible(xx->trkLayer)))) { - return; - } + if (hideTrainsInTunnels && + ((((xx->state&CAR_STATE_ONHIDENTRACK)!=0) && drawTunnel==0) || + (xx->trkLayer!=NOTALAYER && !GetLayerVisible(xx->trkLayer)))) { + return; + } - for (dir=0; dir<2; dir++) { - track_p car1; - coupler[dir].pos = xx->couplerPos[dir]; + for (dir=0; dir<2; dir++) { + track_p car1; + coupler[dir].pos = xx->couplerPos[dir]; - if ((car1 = GetTrkEndTrk(car,dir))) { - xx1 = GET_EXTRA_DATA(car1, T_CAR, extraDataCar_t); - dir1 = (GetTrkEndTrk(car1,0)==car)?0:1; - coupler[dir].angle = FindAngle(xx->couplerPos[dir], xx1->couplerPos[dir1]); - } else { - coupler[dir].angle = NormalizeAngle(xx->trvTrk.angle+(dir==0?0.0:180.0)-15.0); - } - } + if ((car1 = GetTrkEndTrk(car,dir))) { + xx1 = GET_EXTRA_DATA(car1, T_CAR, extraDataCar_t); + dir1 = (GetTrkEndTrk(car1,0)==car)?0:1; + coupler[dir].angle = FindAngle(xx->couplerPos[dir], xx1->couplerPos[dir1]); + } else { + coupler[dir].angle = NormalizeAngle(xx->trvTrk.angle+(dir==0?0.0:180.0)-15.0); + } + } - CarItemDraw(d, xx->item, color, xx->direction, IsLocoMaster(xx), coupler, xx->pencils, xx->trvTrk.trk); + CarItemDraw(d, xx->item, color, xx->direction, IsLocoMaster(xx), coupler, + xx->pencils, xx->trvTrk.trk); } static DIST_T DistanceCar( - track_p trk, - coOrd * pos) + track_p trk, + coOrd * pos) { - struct extraDataCar_t * xx = GET_EXTRA_DATA(trk, T_CAR, extraDataCar_t); - DIST_T dist; - coOrd pos1; - coOrd size; + struct extraDataCar_t * xx = GET_EXTRA_DATA(trk, T_CAR, extraDataCar_t); + DIST_T dist; + coOrd ends[4]; + coOrd size; + + if (IsIgnored(xx)) { + return 10000.0; + } - if (IsIgnored(xx)) { - return DIST_INF; - } + if (hideTrainsInTunnels && + ((((xx->state&CAR_STATE_ONHIDENTRACK)!=0) && drawTunnel==0) || + (xx->trkLayer!=NOTALAYER && !GetLayerVisible(xx->trkLayer)))) { + return 10000.0; + } - CarItemSize(xx->item, - &size); /* TODO assumes xx->trvTrk.pos is the car center */ - dist = FindDistance(*pos, xx->trvTrk.pos); + CarItemSize(xx->item, + &size); - if (dist < size.x/2.0) { - pos1 = *pos; - Rotate(&pos1, xx->trvTrk.pos, -xx->trvTrk.angle); - pos1.x += -xx->trvTrk.pos.x + size.y/2.0; /* TODO: why not size.x? */ - pos1.y += -xx->trvTrk.pos.y + size.x/2.0; + size.x = CarItemCoupledLength(xx->item); /* Coupling included */ - if (pos1.x >= 0 && pos1.x <= size.y && - pos1.y >= 0 && pos1.y <= size.x) { - dist = 0; - } - } + coOrd carPos; + CarItemPos(xx->item, + &carPos); - *pos = xx->trvTrk.pos; - return dist; -} + dist = FindDistance(*pos, carPos); /* Basic distance to center */ + if (dist < size.x/2.0 + +size.y/2.0) { /* Crude circle to evaluate if "close" */ + + coOrd point = *pos; + point.x += -carPos.x; + point.y += -carPos.y; + Rotate(&point,zero,-(xx->trvTrk.angle+90.0)); /* Convert to simple coOrds */ + + for (int i=0; i<4; i++) { + ends[i].x = 0.0; + ends[i].y = 0.0; + } + ends[0].x = size.x/2.0; + ends[0].y = size.y/2.0; + ends[1].x = - size.x/2.0; + ends[1].y = size.y/2.0; + ends[2].x = - size.x/2.0; + ends[2].y = - size.y/2.0; + ends[3].x = size.x/2.0; + ends[3].y = - size.y/2.0; + + + /* + * A | B | C + * --1------------------------0--- + * D | 0.0 | E + * --2------------------------3--- + * F | G | H + */ + + if ((point.x >= ends[2].x) && (point.x <= ends[0].x) && (point.y >= ends[2].y) + && (point.y <= ends[0].y)) { + dist = 0.0; /* center */ + *pos = carPos; + } else { + if (point.x > ends[2].x && point.x < ends[0].x ) { + if (point.y > ends[0].y) { + dist = fabs(point.y - ends[0].y); /* B */ + point.y = ends[0].y; + } else { + dist = fabs(point.y - ends[2].y); /* G */ + point.y = ends[2].y; + } + } else if (point.y > ends[2].y && point.y < ends[0].y) { + if (point.x > ends[0].x) { + dist = fabs(point.x - ends[0].x); /* E */ + point.x = ends[0].x; + } else { + dist = fabs(point.x - ends[2].x); /* D */ + point.x = ends[2].x; + } + } else { /* A,C,F,G */ + for (int i=0; i<4; i++) { + if (dist>FindDistance(point,ends[i])) { + dist = FindDistance(point,ends[i]); + point = ends[i]; + } + } + } + Rotate(&point,zero,(xx->trvTrk.angle+90.0)); + point.x +=carPos.x; + point.y +=carPos.y; + *pos = point; + } + + } + + return dist; +} static void SetCarBoundingBox( - track_p car) + track_p car) { - struct extraDataCar_t * xx = GET_EXTRA_DATA(car, T_CAR, extraDataCar_t); - coOrd lo, hi, p[4]; - int inx; - coOrd size; - /* TODO: should be bounding box of all pieces aligned on track */ - CarItemSize(xx->item, - &size); /* TODO assumes xx->trvTrk.pos is the car center */ - Translate(&p[0], xx->trvTrk.pos, xx->trvTrk.angle, size.x/2.0); - Translate(&p[1], p[0], xx->trvTrk.angle+90, size.y/2.0); - Translate(&p[0], p[0], xx->trvTrk.angle-90, size.y/2.0); - Translate(&p[2], xx->trvTrk.pos, xx->trvTrk.angle+180, size.x/2.0); - Translate(&p[3], p[2], xx->trvTrk.angle+90, size.y/2.0); - Translate(&p[2], p[2], xx->trvTrk.angle-90, size.y/2.0); - lo = hi = p[0]; - - for (inx = 1; inx < 4; inx++) { - if (p[inx].x < lo.x) { - lo.x = p[inx].x; - } + struct extraDataCar_t * xx = GET_EXTRA_DATA(car, T_CAR, extraDataCar_t); + coOrd lo, hi, p[4]; + int inx; + coOrd size; + /* TODO: should be bounding box of all pieces aligned on track */ + CarItemSize(xx->item, + &size); /* TODO assumes xx->trvTrk.pos is the car center */ + Translate(&p[0], xx->trvTrk.pos, xx->trvTrk.angle, size.x/2.0); + Translate(&p[1], p[0], xx->trvTrk.angle+90, size.y/2.0); + Translate(&p[0], p[0], xx->trvTrk.angle-90, size.y/2.0); + Translate(&p[2], xx->trvTrk.pos, xx->trvTrk.angle+180, size.x/2.0); + Translate(&p[3], p[2], xx->trvTrk.angle+90, size.y/2.0); + Translate(&p[2], p[2], xx->trvTrk.angle-90, size.y/2.0); + lo = hi = p[0]; + + for (inx = 1; inx < 4; inx++) { + if (p[inx].x < lo.x) { + lo.x = p[inx].x; + } - if (p[inx].y < lo.y) { - lo.y = p[inx].y; - } + if (p[inx].y < lo.y) { + lo.y = p[inx].y; + } - if (p[inx].x > hi.x) { - hi.x = p[inx].x; - } + if (p[inx].x > hi.x) { + hi.x = p[inx].x; + } - if (p[inx].y > hi.y) { - hi.y = p[inx].y; - } - } + if (p[inx].y > hi.y) { + hi.y = p[inx].y; + } + } - SetBoundingBox(car, hi, lo); + SetBoundingBox(car, hi, lo); } track_p NewCar( - wIndex_t index, - carItem_p item, - coOrd pos, - ANGLE_T angle) -{ - track_p trk; - struct extraDataCar_t * xx; - trk = NewTrack(index, T_CAR, 2, sizeof(*xx)); - /*SetEndPts( trk, 0 );*/ - xx = GET_EXTRA_DATA(trk, T_CAR, extraDataCar_t); - /*SetTrkVisible( trk, IsVisible(xx) );*/ - xx->item = item; - xx->trvTrk.pos = pos; - xx->trvTrk.angle = angle; - xx->state = 0; - SetCarBoundingBox(trk); - CarItemSetTrack(item, trk); - PlaceCar(trk); - return trk; + wIndex_t index, + carItem_p item, + coOrd pos, + ANGLE_T angle) +{ + track_p trk; + struct extraDataCar_t * xx; + trk = NewTrack(index, T_CAR, 2, sizeof(*xx)); + /*SetEndPts( trk, 0 );*/ + xx = GET_EXTRA_DATA(trk, T_CAR, extraDataCar_t); + /*SetTrkVisible( trk, IsVisible(xx) );*/ + xx->item = item; + xx->trvTrk.pos = pos; + xx->trvTrk.angle = angle; + xx->state = 0; + SetCarBoundingBox(trk); + CarItemSetTrack(item, trk); + PlaceCar(trk); + return trk; } static void DeleteCar( - track_p trk) + track_p trk) { - struct extraDataCar_t * xx = GET_EXTRA_DATA(trk, T_CAR, extraDataCar_t); - CarItemSetTrack(xx->item, NULL); + struct extraDataCar_t * xx = GET_EXTRA_DATA(trk, T_CAR, extraDataCar_t); + CarItemSetTrack(xx->item, NULL); } static BOOL_T ReadCar( - char * line) + char * line) { - return CarItemRead(line); + return CarItemRead(line); } static BOOL_T WriteCar( - track_p trk, - FILE * f) + track_p trk, + FILE * f) { - BOOL_T rc = TRUE; - return rc; + BOOL_T rc = TRUE; + return rc; } static void MoveCar( - track_p car, - coOrd pos) + track_p car, + coOrd pos) { - struct extraDataCar_t *xx = GET_EXTRA_DATA(car, T_CAR, extraDataCar_t); - xx->trvTrk.pos.x += pos.x; - xx->trvTrk.pos.y += pos.y; - xx->trvTrk.trk = NULL; - PlaceCar(car); - SetCarBoundingBox(car); + struct extraDataCar_t *xx = GET_EXTRA_DATA(car, T_CAR, extraDataCar_t); + xx->trvTrk.pos.x += pos.x; + xx->trvTrk.pos.y += pos.y; + xx->trvTrk.trk = NULL; + PlaceCar(car); + SetCarBoundingBox(car); } static void RotateCar( - track_p car, - coOrd pos, - ANGLE_T angle) + track_p car, + coOrd pos, + ANGLE_T angle) { - struct extraDataCar_t *xx = GET_EXTRA_DATA(car, T_CAR, extraDataCar_t); - Rotate(&xx->trvTrk.pos, pos, angle); - xx->trvTrk.angle = NormalizeAngle(xx->trvTrk.angle + angle); - xx->trvTrk.trk = NULL; - PlaceCar(car); - SetCarBoundingBox(car); + struct extraDataCar_t *xx = GET_EXTRA_DATA(car, T_CAR, extraDataCar_t); + Rotate(&xx->trvTrk.pos, pos, angle); + xx->trvTrk.angle = NormalizeAngle(xx->trvTrk.angle + angle); + xx->trvTrk.trk = NULL; + PlaceCar(car); + SetCarBoundingBox(car); } static BOOL_T QueryCar(track_p trk, int query) { - switch (query) { - case Q_NODRAWENDPT: - return TRUE; - case Q_ISTRAIN: - return TRUE; - - default: - return FALSE; - } + switch (query) { + case Q_NODRAWENDPT: + return TRUE; + case Q_ISTRAIN: + return TRUE; + + default: + return FALSE; + } } static BOOL_T StoreCar( - track_p car, - void **data, - long * len) { + track_p car, + void **data, + long * len) +{ struct extraDataCar_t *xx = GET_EXTRA_DATA(car, T_CAR, extraDataCar_t); return StoreCarItem(xx->item,data,len); } -static BOOL_T ReplayCar (track_p car, void *data,long len) { +static BOOL_T ReplayCar (track_p car, void *data,long len) +{ struct extraDataCar_t *xx = GET_EXTRA_DATA(car, T_CAR, extraDataCar_t); return ReplayCarItem(xx->item,data,len); @@ -570,41 +640,41 @@ static wBool_t CompareCar( track_cp trk1, track_cp trk2 ) static trackCmd_t carCmds = { - "CAR ", - DrawCar, /* draw */ - DistanceCar, /* distance */ - DescribeCar, /* describe */ - DeleteCar, /* delete */ - WriteCar, /* write */ - ReadCar, /* read */ - MoveCar, /* move */ - RotateCar, /* rotate */ - NULL, /* rescale */ - NULL, /* audit */ - NULL, /* getAngle */ - NULL, /* split */ - NULL, /* traverse */ - NULL, /* enumerate */ - NULL, /* redraw*/ - NULL, /* trim*/ - NULL, /* merge*/ - NULL, /* modify */ - NULL, /* getLength */ - NULL, /* getParams */ - NULL, /* moveEndPt */ - QueryCar, /* query */ - NULL, /* ungroup */ - NULL, /* flip */ - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - ReplayCar, - StoreCar, - NULL, /*activate*/ - CompareCar + "CAR ", + DrawCar, /* draw */ + DistanceCar, /* distance */ + DescribeCar, /* describe */ + DeleteCar, /* delete */ + WriteCar, /* write */ + ReadCar, /* read */ + MoveCar, /* move */ + RotateCar, /* rotate */ + NULL, /* rescale */ + NULL, /* audit */ + NULL, /* getAngle */ + NULL, /* split */ + NULL, /* traverse */ + NULL, /* enumerate */ + NULL, /* redraw*/ + NULL, /* trim*/ + NULL, /* merge*/ + NULL, /* modify */ + NULL, /* getLength */ + NULL, /* getParams */ + NULL, /* moveEndPt */ + QueryCar, /* query */ + NULL, /* ungroup */ + NULL, /* flip */ + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + ReplayCar, + StoreCar, + NULL, /*activate*/ + CompareCar }; /* @@ -621,36 +691,35 @@ static int numTrainDlg; #define MAX_SPEED (100.0) typedef struct { - wWin_p win; - wIndex_t inx; - track_p train; - long direction; - long followMe; - long autoReverse; - coOrd pos; - char posS[STR_SHORT_SIZE]; - DIST_T speed; - char speedS[10]; - paramGroup_p trainPGp; + wWin_p win; + wIndex_t inx; + track_p train; + long direction; + long followMe; + long autoReverse; + coOrd pos; + char posS[STR_SHORT_SIZE]; + DIST_T speed; + char speedS[10]; + paramGroup_p trainPGp; } trainControlDlg_t, * trainControlDlg_p; static trainControlDlg_t * curTrainDlg; static void SpeedRedraw(wDraw_p, void *, wWinPix_t, wWinPix_t); static void SpeedAction(wAction_t, coOrd); -static void LocoListChangeEntry(track_p, track_p); static void CmdTrainExit(void * unused); drawCmd_t speedD = { - NULL, - &screenDrawFuncs, - 0, - 1.0, - 0.0, - { 0.0, 0.0 }, - { 0.0, 0.0 }, - Pix2CoOrd, - CoOrd2Pix + NULL, + &screenDrawFuncs, + 0, + 1.0, + 0.0, + { 0.0, 0.0 }, + { 0.0, 0.0 }, + Pix2CoOrd, + CoOrd2Pix }; static paramDrawData_t speedParamData = { SLIDER_WIDTH, SLIDER_HEIGHT, SpeedRedraw, SpeedAction, &speedD }; #ifndef WINDOWS @@ -661,56 +730,56 @@ static char * trainAutoReverseLabels[] = { N_("Auto Reverse"), NULL }; static paramData_t trainPLs[] = { #define I_LIST (0) #ifdef WINDOWS - /*0*/ { PD_DROPLIST, NULL, "list", PDO_NOPREF|PDO_NOPSHUPD, I2VP(120), NULL, 0 }, + /*0*/ { PD_DROPLIST, NULL, "list", PDO_NOPREF|PDO_NOPSHUPD, I2VP(120), NULL, 0 }, #else - /*0*/ { PD_LIST, NULL, "list", PDO_NOPREF|PDO_NOPSHUPD, &listData, NULL, 0 }, + /*0*/ { PD_LIST, NULL, "list", PDO_NOPREF|PDO_NOPSHUPD, &listData, NULL, 0 }, #endif #define I_STATUS (1) - { PD_MESSAGE, NULL, NULL, 0, I2VP(120) }, + { PD_MESSAGE, NULL, NULL, 0, I2VP(120) }, #define I_POS (2) - { PD_MESSAGE, NULL, NULL, 0, I2VP(120) }, + { PD_MESSAGE, NULL, NULL, 0, I2VP(120) }, #define I_SLIDER (3) - { PD_DRAW, NULL, "speed", PDO_NOPSHUPD|PDO_DLGSETY, &speedParamData }, + { PD_DRAW, NULL, "speed", PDO_NOPSHUPD|PDO_DLGSETY, &speedParamData }, #define I_DIST (4) - { PD_STRING, NULL, "distance", PDO_DLGNEWCOLUMN, I2VP(100-SLIDER_WIDTH), NULL, BO_READONLY }, + { PD_STRING, NULL, "distance", PDO_DLGNEWCOLUMN, I2VP(100-SLIDER_WIDTH), NULL, BO_READONLY }, #define I_ZERO (5) - { PD_BUTTON, NULL, "zeroDistance", PDO_NOPSHUPD|PDO_NOPREF|PDO_DLGHORZ, NULL, NULL, BO_ICON }, + { PD_BUTTON, NULL, "zeroDistance", PDO_NOPSHUPD|PDO_NOPREF|PDO_DLGHORZ, NULL, NULL, BO_ICON }, #define I_GOTO (6) - { PD_BUTTON, NULL, "goto", PDO_NOPSHUPD|PDO_NOPREF|PDO_DLGWIDE, NULL, N_("Find") }, + { PD_BUTTON, NULL, "goto", PDO_NOPSHUPD|PDO_NOPREF|PDO_DLGWIDE, NULL, N_("Find") }, #define I_FOLLOW (7) - { PD_TOGGLE, NULL, "follow", PDO_NOPREF|PDO_DLGWIDE, trainFollowMeLabels, NULL, BC_HORZ|BC_NOBORDER }, + { PD_TOGGLE, NULL, "follow", PDO_NOPREF|PDO_DLGWIDE, trainFollowMeLabels, NULL, BC_HORZ|BC_NOBORDER }, #define I_AUTORVRS (8) - { PD_TOGGLE, NULL, "autoreverse", PDO_NOPREF, trainAutoReverseLabels, NULL, BC_HORZ|BC_NOBORDER }, + { PD_TOGGLE, NULL, "autoreverse", PDO_NOPREF, trainAutoReverseLabels, NULL, BC_HORZ|BC_NOBORDER }, #define I_DIR (9) - { PD_BUTTON, NULL, "direction", PDO_NOPREF|PDO_DLGWIDE, NULL, N_("Forward"), 0 }, + { PD_BUTTON, NULL, "direction", PDO_NOPREF|PDO_DLGWIDE, NULL, N_("Forward"), 0 }, #define I_STOP (10) - { PD_BUTTON, NULL, "stop", PDO_DLGWIDE, NULL, N_("Stop") }, + { PD_BUTTON, NULL, "stop", PDO_DLGWIDE, NULL, N_("Stop") }, #define I_SPEED (11) - { PD_MESSAGE, NULL, NULL, PDO_DLGIGNOREX, I2VP(120) } + { PD_MESSAGE, NULL, NULL, PDO_DLGIGNOREX, I2VP(120) } }; static paramGroup_t trainPG = { "train", 0, trainPLs, COUNT( trainPLs ) }; typedef struct { - track_p loco; - BOOL_T running; + track_p loco; + BOOL_T running; } locoList_t; dynArr_t locoList_da; #define locoList(N) DYNARR_N( locoList_t, locoList_da, N ) static wIndex_t FindLoco( - track_p loco) + track_p loco) { - wIndex_t inx; + wIndex_t inx; - for (inx = 0; inx<locoList_da.cnt; inx++) { - if (locoList(inx).loco == loco) { - return inx; - } - } + for (inx = 0; inx<locoList_da.cnt; inx++) { + if (locoList(inx).loco == loco) { + return inx; + } + } - return -1; + return -1; } /** @@ -724,34 +793,34 @@ static wIndex_t FindLoco( */ static void SpeedRedraw( - wDraw_p d, - void * context, - wWinPix_t w, - wWinPix_t h) -{ - wDrawPix_t y; - trainControlDlg_p dlg = (trainControlDlg_p)context; - struct extraDataCar_t * xx; - wDrawColor drawColor; - wDrawClear(d); - - if (dlg == NULL || dlg->train == NULL) { - return; - } - - xx = GET_EXTRA_DATA(dlg->train, T_CAR, extraDataCar_t); - - if (xx->speed > MAX_SPEED) { - xx->speed = MAX_SPEED; - } - - if (xx->speed < 0) { - xx->speed = 0; - } - - y = (xx->speed/MAX_SPEED*((SLIDER_HEIGHT-SLIDER_THICKNESS)) - +SLIDER_THICKNESS/2); - drawColor = wDrawFindColor(wRGB(160, 160, 160)); + wDraw_p d, + void * context, + wWinPix_t w, + wWinPix_t h) +{ + wDrawPix_t y; + trainControlDlg_p dlg = (trainControlDlg_p)context; + struct extraDataCar_t * xx; + wDrawColor drawColor; + wDrawClear(d); + + if (dlg == NULL || dlg->train == NULL) { + return; + } + + xx = GET_EXTRA_DATA(dlg->train, T_CAR, extraDataCar_t); + + if (xx->speed > MAX_SPEED) { + xx->speed = MAX_SPEED; + } + + if (xx->speed < 0) { + xx->speed = 0; + } + + y = (xx->speed/MAX_SPEED*((SLIDER_HEIGHT-SLIDER_THICKNESS)) + +SLIDER_THICKNESS/2); + drawColor = wDrawFindColor(wRGB(160, 160, 160)); coOrd pos0, pos1, siz; y /= speedD.dpi; siz.x = SLIDER_WIDTH/speedD.dpi; @@ -766,547 +835,551 @@ static void SpeedRedraw( DrawLine( &speedD, pos0, pos1, 3, drawColorRed ); pos0.y = pos1.y = y + siz.y/2.0; DrawLine( &speedD, pos0, pos1, 1, drawColorBlack ); - sprintf(dlg->speedS, "%3d %s", - (int)(units==UNITS_ENGLISH?xx->speed:xx->speed*1.6), - (units==UNITS_ENGLISH?"mph":"km/h")); - ParamLoadMessage(dlg->trainPGp, I_SPEED, dlg->speedS); - LOG(log_trainPlayback, 3, ("Speed = %d\n", (int)xx->speed)); + sprintf(dlg->speedS, "%3d %s", + (int)(units==UNITS_ENGLISH?xx->speed:xx->speed*1.6), + (units==UNITS_ENGLISH?"mph":"km/h")); + ParamLoadMessage(dlg->trainPGp, I_SPEED, dlg->speedS); + LOG(log_trainPlayback, 3, ("Speed = %d\n", (int)xx->speed)); } static void SpeedAction( - wAction_t action, - coOrd pos) + wAction_t action, + coOrd pos) { - trainControlDlg_p dlg = curTrainDlg; - struct extraDataCar_t * xx; - FLOAT_T speed; - BOOL_T startStop; + trainControlDlg_p dlg = curTrainDlg; + struct extraDataCar_t * xx; + FLOAT_T speed; + BOOL_T startStop; - if (dlg == NULL || dlg->train == NULL) { - return; - } + if (dlg == NULL || dlg->train == NULL) { + return; + } - xx = GET_EXTRA_DATA(dlg->train, T_CAR, extraDataCar_t); + xx = GET_EXTRA_DATA(dlg->train, T_CAR, extraDataCar_t); - switch (action) { - case C_DOWN: - InfoMessage(""); + switch (action) { + case C_DOWN: + InfoMessage(""); - case C_MOVE: - case C_UP: - TrainTimeEndPause(); + case C_MOVE: + case C_UP: + TrainTimeEndPause(); - if (IsOnTrack(xx)) { - speed = ((FLOAT_T)((pos.y*speedD.dpi)-SLIDER_THICKNESS/2))/ - (SLIDER_HEIGHT-SLIDER_THICKNESS)*MAX_SPEED; - } else { - speed = 0; - } + if (IsOnTrack(xx)) { + speed = ((FLOAT_T)((pos.y*speedD.dpi)-SLIDER_THICKNESS/2))/ + (SLIDER_HEIGHT-SLIDER_THICKNESS)*MAX_SPEED; + } else { + speed = 0; + } - if (speed > MAX_SPEED) { - speed = MAX_SPEED; - } + if (speed > MAX_SPEED) { + speed = MAX_SPEED; + } - if (speed < 0) { - speed = 0; - } + if (speed < 0) { + speed = 0; + } - startStop = (xx->speed == 0) != (speed == 0); - xx->speed = speed; - SpeedRedraw((wDraw_p)dlg->trainPGp->paramPtr[I_SLIDER].control, dlg, - SLIDER_WIDTH, SLIDER_HEIGHT); + startStop = (xx->speed == 0) != (speed == 0); + xx->speed = speed; + SpeedRedraw((wDraw_p)dlg->trainPGp->paramPtr[I_SLIDER].control, dlg, + SLIDER_WIDTH, SLIDER_HEIGHT); - if (startStop) { - if (xx->speed == 0) { - xx->status = ST_StopManual; - } + if (startStop) { + if (xx->speed == 0) { + xx->status = ST_StopManual; + } - LocoListChangeEntry(dlg->train, dlg->train); - } + LocoListChangeEntry(dlg->train, dlg->train); + } - TrainTimeStartPause(); + TrainTimeStartPause(); - if (trainsState == TRAINS_IDLE) { - RestartTrains(); - } + if (trainsState == TRAINS_IDLE) { + RestartTrains(); + } - break; + break; - default: - break; - } + default: + break; + } } static void ControllerDialogSync( - trainControlDlg_p dlg) -{ - struct extraDataCar_t * xx=NULL; - wIndex_t inx; - BOOL_T dir; - BOOL_T followMe; - BOOL_T autoReverse; - coOrd pos; - - if (dlg == NULL) { - return; - } - - inx = wListGetIndex((wList_p)dlg->trainPGp->paramPtr[I_LIST].control); - - if (dlg->train) { - if (inx >= 0 && inx < locoList_da.cnt && dlg->train && - dlg->train != locoList(inx).loco) { - inx = FindLoco(dlg->train); - - if (inx >= 0) { - wListSetIndex((wList_p)dlg->trainPGp->paramPtr[I_LIST].control, inx); - } - } - } else { - wListSetIndex((wList_p)dlg->trainPGp->paramPtr[I_LIST].control, -1); - } - - if (dlg->train) { - char * statusMsg; - DIST_T speed; - xx = GET_EXTRA_DATA(dlg->train, T_CAR, extraDataCar_t); - dir = xx->direction==0?0:1; - speed = xx->speed; - pos = xx->trvTrk.pos; - followMe = followTrain == dlg->train; - autoReverse = xx->autoReverse; - - if (xx->trvTrk.trk == NULL) { - if (xx->status == ST_Crashed) { - statusMsg = _("Crashed"); - } else { - statusMsg = _("Not on Track"); - } - } else if (xx->speed > 0) { - if (trainsState == TRAINS_STOP) { - statusMsg = _("Trains Paused"); - } else { - statusMsg = _("Running"); - } - } else { - switch (xx->status) { - case ST_EndOfTrack: - statusMsg = _("End of Track"); - break; - - case ST_OpenTurnout: - statusMsg = _("Open Turnout"); - break; - - case ST_StopManual: - statusMsg = _("Manual Stop"); - break; - - case ST_NoRoom: - statusMsg = _("No Room"); - break; - - case ST_Crashed: - statusMsg = _("Crashed"); - break; - - default: - statusMsg = _("Unknown Status"); - break; - } - } - - ParamLoadMessage(dlg->trainPGp, I_STATUS, statusMsg); - } else { - dir = 0; - followMe = FALSE; - autoReverse = FALSE; - ParamLoadMessage(dlg->trainPGp, I_STATUS, _("No trains")); - } - - if (dlg->followMe != followMe) { - dlg->followMe = followMe; - ParamLoadControl(dlg->trainPGp, I_FOLLOW); - } - - if (dlg->autoReverse != autoReverse) { - dlg->autoReverse = autoReverse; - ParamLoadControl(dlg->trainPGp, I_AUTORVRS); - } - - if (dlg->direction != dir) { - dlg->direction = dir; - wButtonSetLabel((wButton_p)dlg->trainPGp->paramPtr[I_DIR].control, - (dlg->direction?_("Reverse"):_("Forward"))); - } - - if (dlg->train) { - if (dlg->posS[0] == '\0' || - dlg->pos.x != xx->trvTrk.pos.x || - dlg->pos.y != xx->trvTrk.pos.y) { - long format; - dlg->pos = xx->trvTrk.pos; - format = GetDistanceFormat(); - format &= ~DISTFMT_DECS; - sprintf(dlg->posS, "X:%s Y:%s", - FormatDistanceEx(xx->trvTrk.pos.x, format), - FormatDistanceEx(xx->trvTrk.pos.y, format)); - ParamLoadMessage(dlg->trainPGp, I_POS, dlg->posS); - } - - if (dlg->speed != xx->speed) { - dlg->speed = xx->speed; - sprintf(dlg->speedS, "%3d", - (int)(units==UNITS_ENGLISH?xx->speed:xx->speed*1.6)); - ParamLoadMessage(dlg->trainPGp, I_SPEED, dlg->speedS); - SpeedRedraw((wDraw_p)dlg->trainPGp->paramPtr[I_SLIDER].control, dlg, - SLIDER_WIDTH, SLIDER_HEIGHT); - } - - ParamLoadMessage(dlg->trainPGp, I_DIST, FormatDistance(xx->distance)); - } else { - if (dlg->posS[0] != '\0') { - dlg->posS[0] = '\0'; - ParamLoadMessage(dlg->trainPGp, I_POS, dlg->posS); - } - - if (dlg->speed >= 0) { - dlg->speed = -1; - dlg->speedS[0] = '\0'; - ParamLoadMessage(dlg->trainPGp, I_SPEED, dlg->speedS); - wDrawClear((wDraw_p)dlg->trainPGp->paramPtr[I_SLIDER].control); - } - - ParamLoadMessage(dlg->trainPGp, I_DIST, ""); - } + trainControlDlg_p dlg) +{ + struct extraDataCar_t * xx=NULL; + wIndex_t inx; + BOOL_T dir; + BOOL_T followMe; + BOOL_T autoReverse; +// coOrd pos; + + if (dlg == NULL) { + return; + } + + inx = wListGetIndex((wList_p)dlg->trainPGp->paramPtr[I_LIST].control); + + if (dlg->train) { + if (inx >= 0 && inx < locoList_da.cnt && dlg->train && + dlg->train != locoList(inx).loco) { + inx = FindLoco(dlg->train); + + if (inx >= 0) { + wListSetIndex((wList_p)dlg->trainPGp->paramPtr[I_LIST].control, inx); + } + } + } else { + wListSetIndex((wList_p)dlg->trainPGp->paramPtr[I_LIST].control, -1); + } + + if (dlg->train) { + char * statusMsg; +// DIST_T speed; + xx = GET_EXTRA_DATA(dlg->train, T_CAR, extraDataCar_t); + dir = xx->direction==0?0:1; +// speed = xx->speed; +// pos = xx->trvTrk.pos; + followMe = followTrain == dlg->train; + autoReverse = xx->autoReverse; + + if (xx->trvTrk.trk == NULL) { + if (xx->status == ST_Crashed) { + statusMsg = _("Crashed"); + } else { + statusMsg = _("Not on Track"); + } + } else if (xx->speed > 0) { + if (trainsState == TRAINS_STOP) { + statusMsg = _("Trains Paused"); + } else { + statusMsg = _("Running"); + } + } else { + switch (xx->status) { + case ST_EndOfTrack: + statusMsg = _("End of Track"); + break; + + case ST_OpenTurnout: + statusMsg = _("Open Turnout"); + break; + + case ST_StopManual: + statusMsg = _("Manual Stop"); + break; + + case ST_NoRoom: + statusMsg = _("No Room"); + break; + + case ST_Crashed: + statusMsg = _("Crashed"); + break; + + default: + statusMsg = _("Unknown Status"); + break; + } + } + + ParamLoadMessage(dlg->trainPGp, I_STATUS, statusMsg); + } else { + dir = 0; + followMe = FALSE; + autoReverse = FALSE; + ParamLoadMessage(dlg->trainPGp, I_STATUS, _("No trains")); + } + + if (dlg->followMe != followMe) { + dlg->followMe = followMe; + ParamLoadControl(dlg->trainPGp, I_FOLLOW); + } + + if (dlg->autoReverse != autoReverse) { + dlg->autoReverse = autoReverse; + ParamLoadControl(dlg->trainPGp, I_AUTORVRS); + } + + if (dlg->direction != dir) { + dlg->direction = dir; + wButtonSetLabel((wButton_p)dlg->trainPGp->paramPtr[I_DIR].control, + (dlg->direction?_("Reverse"):_("Forward"))); + } + + if (dlg->train) { + if (dlg->posS[0] == '\0' || + dlg->pos.x != xx->trvTrk.pos.x || + dlg->pos.y != xx->trvTrk.pos.y) { + long format; + dlg->pos = xx->trvTrk.pos; + format = GetDistanceFormat(); + format &= ~DISTFMT_DECS; + sprintf(dlg->posS, "X:%s Y:%s", + FormatDistanceEx(xx->trvTrk.pos.x, format), + FormatDistanceEx(xx->trvTrk.pos.y, format)); + ParamLoadMessage(dlg->trainPGp, I_POS, dlg->posS); + } + + if (dlg->speed != xx->speed) { + dlg->speed = xx->speed; + sprintf(dlg->speedS, "%3d", + (int)(units==UNITS_ENGLISH?xx->speed:xx->speed*1.6)); + ParamLoadMessage(dlg->trainPGp, I_SPEED, dlg->speedS); + SpeedRedraw((wDraw_p)dlg->trainPGp->paramPtr[I_SLIDER].control, dlg, + SLIDER_WIDTH, SLIDER_HEIGHT); + } + + ParamLoadMessage(dlg->trainPGp, I_DIST, FormatDistance(xx->distance)); + } else { + if (dlg->posS[0] != '\0') { + dlg->posS[0] = '\0'; + ParamLoadMessage(dlg->trainPGp, I_POS, dlg->posS); + } + + if (dlg->speed >= 0) { + dlg->speed = -1; + dlg->speedS[0] = '\0'; + ParamLoadMessage(dlg->trainPGp, I_SPEED, dlg->speedS); + wDrawClear((wDraw_p)dlg->trainPGp->paramPtr[I_SLIDER].control); + } + + ParamLoadMessage(dlg->trainPGp, I_DIST, ""); + } } static void ControllerDialogSyncAll(void) { - if (curTrainDlg) { - ControllerDialogSync(curTrainDlg); - } + if (curTrainDlg) { + ControllerDialogSync(curTrainDlg); + } } -static void LocoListChangeEntry( - track_p oldLoco, - track_p newLoco) +EXPORT void LocoListChangeEntry( + track_p oldLoco, + track_p newLoco) { - wIndex_t inx = -1; - struct extraDataCar_t * xx; + wIndex_t inx = -1; + struct extraDataCar_t * xx; - if (curTrainDlg == NULL) { - return; - } - - if (oldLoco && (inx=FindLoco(oldLoco))>=0) { - if (newLoco) { - locoList(inx).loco = newLoco; - xx = GET_EXTRA_DATA(newLoco, T_CAR, extraDataCar_t); - locoList(inx).running = IsOnTrack(xx) && xx->speed > 0; - wListSetValues((wList_p)curTrainDlg->trainPGp->paramPtr[I_LIST].control, inx, - CarItemNumber(xx->item), locoList(inx).running?goI:stopI, newLoco); - } else { - wListDelete((wList_p)curTrainDlg->trainPGp->paramPtr[I_LIST].control, inx); + if (curTrainDlg == NULL) { + return; + } - for (; inx<locoList_da.cnt-1; inx++) { - locoList(inx) = locoList(inx+1); - } + if (oldLoco && (inx=FindLoco(oldLoco))>=0) { + if (newLoco) { + locoList(inx).loco = newLoco; + xx = GET_EXTRA_DATA(newLoco, T_CAR, extraDataCar_t); + locoList(inx).running = IsOnTrack(xx) && xx->speed > 0; + wListSetValues((wList_p)curTrainDlg->trainPGp->paramPtr[I_LIST].control, inx, + CarItemNumber(xx->item), locoList(inx).running?goI:stopI, newLoco); + } else { + wListDelete((wList_p)curTrainDlg->trainPGp->paramPtr[I_LIST].control, inx); + + for (; inx<locoList_da.cnt-1; inx++) { + locoList(inx) = locoList(inx+1); + } - locoList_da.cnt -= 1; + locoList_da.cnt -= 1; - if (inx >= locoList_da.cnt) { - inx--; - } - } - } else if (newLoco) { - inx = locoList_da.cnt; - DYNARR_APPEND(locoList_t, locoList_da, 10); - locoList(inx).loco = newLoco; - xx = GET_EXTRA_DATA(newLoco, T_CAR, extraDataCar_t); - locoList(inx).running = IsOnTrack(xx) && xx->speed > 0; - wListAddValue((wList_p)curTrainDlg->trainPGp->paramPtr[I_LIST].control, - CarItemNumber(xx->item), locoList(inx).running?goI:stopI, newLoco); - } + if (inx >= locoList_da.cnt) { + inx--; + } + } + } else if (newLoco) { + inx = locoList_da.cnt; + DYNARR_APPEND(locoList_t, locoList_da, 10); + locoList(inx).loco = newLoco; + xx = GET_EXTRA_DATA(newLoco, T_CAR, extraDataCar_t); + locoList(inx).running = IsOnTrack(xx) && xx->speed > 0; + wListAddValue((wList_p)curTrainDlg->trainPGp->paramPtr[I_LIST].control, + CarItemNumber(xx->item), locoList(inx).running?goI:stopI, newLoco); + } - if (curTrainDlg->train == oldLoco) { - if (newLoco || locoList_da.cnt <= 0) { - curTrainDlg->train = newLoco; - } else { - curTrainDlg->train = wListGetItemContext((wList_p) - curTrainDlg->trainPGp->paramPtr[I_LIST].control, inx); - } - } + if (curTrainDlg->train == oldLoco) { + if (newLoco || locoList_da.cnt <= 0) { + curTrainDlg->train = newLoco; + } else { + curTrainDlg->train = wListGetItemContext((wList_p) + curTrainDlg->trainPGp->paramPtr[I_LIST].control, inx); + } + } - ControllerDialogSync(curTrainDlg); + ControllerDialogSync(curTrainDlg); } static void LocoListInit(void) { - track_p train; - struct extraDataCar_t * xx; - locoList_da.cnt = 0; + track_p train; + struct extraDataCar_t * xx; + DYNARR_RESET( locoList_t, locoList_da ); - for (train=NULL; TrackIterate(&train);) { - if (GetTrkType(train) != T_CAR) { - continue; - } + for (train=NULL; TrackIterate(&train);) { + if (GetTrkType(train) != T_CAR) { + continue; + } - xx = GET_EXTRA_DATA(train, T_CAR, extraDataCar_t); + xx = GET_EXTRA_DATA(train, T_CAR, extraDataCar_t); - if (!CarItemIsLoco(xx->item)) { - continue; - } + if (!CarItemIsLoco(xx->item)) { + continue; + } - if (!IsLocoMaster(xx)) { - continue; - } + if (!IsLocoMaster(xx)) { + continue; + } - LocoListChangeEntry(NULL, train); - } + LocoListChangeEntry(NULL, train); + } } static void SetCurTrain( - track_p train) + track_p train) { - curTrainDlg->train = train; - ControllerDialogSync(curTrainDlg); + curTrainDlg->train = train; + ControllerDialogSync(curTrainDlg); } static void StopTrain( - track_p train, - trainStatus_e status) + track_p train, + trainStatus_e status) { - struct extraDataCar_t * xx; + struct extraDataCar_t * xx; - if (train == NULL) { - return; - } + if (train == NULL) { + return; + } - xx = GET_EXTRA_DATA(train, T_CAR, extraDataCar_t); - xx->speed = 0; - xx->status = status; - LocoListChangeEntry(train, train); + xx = GET_EXTRA_DATA(train, T_CAR, extraDataCar_t); + xx->speed = 0; + xx->status = status; + LocoListChangeEntry(train, train); } static void MoveMainWindow( - coOrd pos, - ANGLE_T angle) + coOrd pos, + ANGLE_T angle) { - DIST_T dist; - static DIST_T factor = 0.5; - ANGLE_T angle1 = angle, angle2; + DIST_T dist; + static DIST_T factor = 0.5; + ANGLE_T angle1 = angle, angle2; - if (angle1 > 180.0) { - angle1 = 360.0 - angle1; - } + if (angle1 > 180.0) { + angle1 = 360.0 - angle1; + } - if (angle1 > 90.0) { - angle1 = 180.0 - angle1; - } + if (angle1 > 90.0) { + angle1 = 180.0 - angle1; + } - angle2 = R2D(atan2(mainD.size.x,mainD.size.y)); + angle2 = R2D(atan2(mainD.size.x,mainD.size.y)); - if (angle1 < angle2) { - dist = mainD.size.y/2.0/cos(D2R(angle1)); - } else { - dist = mainD.size.x/2.0/cos(D2R(90.0-angle1)); - } + if (angle1 < angle2) { + dist = mainD.size.y/2.0/cos(D2R(angle1)); + } else { + dist = mainD.size.x/2.0/cos(D2R(90.0-angle1)); + } - dist *= factor; - Translate(&pos, pos, angle, dist); - mainD.orig.x = pos.x-mainD.size.x/2;; - mainD.orig.y = pos.y-mainD.size.y/2;; - panCenter = pos; - LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); - MainLayout( TRUE, TRUE ); // MoveTrainWindow + dist *= factor; + Translate(&pos, pos, angle, dist); + mainD.orig.x = pos.x-mainD.size.x/2;; + mainD.orig.y = pos.y-mainD.size.y/2;; + panCenter = pos; + LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, + panCenter.y ) ); + MainLayout( TRUE, TRUE ); // MoveTrainWindow } static void SetTrainDirection( - track_p train) + track_p train) { - struct extraDataCar_t *xx, *xx0=GET_EXTRA_DATA(train, T_CAR, extraDataCar_t); - int dir0; - track_p car; - car = train; - - for (dir0 = 0; dir0 < 2; dir0++) { - int dir; - dir = dir0; - WALK_CARS_START(car, xx, dir) - - if (car != train) { - if (CarItemIsLoco(xx->item)) { - xx->direction = (dir==dir0?xx0->direction:!xx0->direction); - } - } + struct extraDataCar_t *xx, *xx0=GET_EXTRA_DATA(train, T_CAR, extraDataCar_t); + int dir0; + track_p car; + car = train; + + for (dir0 = 0; dir0 < 2; dir0++) { + int dir; + dir = dir0; + WALK_CARS_START(car, xx, dir) + + if (car != train) { + if (CarItemIsLoco(xx->item)) { + xx->direction = (dir==dir0?xx0->direction:!xx0->direction); + } + } - WALK_CARS_END(car, xx, dir) - } + WALK_CARS_END(car, xx, dir) + } } static void ControllerDialogUpdate( - paramGroup_p pg, - int inx, - void * valueP) -{ - trainControlDlg_p dlg = curTrainDlg; - track_p train; - struct extraDataCar_t * xx; - - if (dlg == NULL) { - return; - } - - TrainTimeEndPause(); - - switch (inx) { - case I_LIST: - train = (track_p)wListGetItemContext((wList_p)pg->paramPtr[inx].control, - (wIndex_t)*(long*)valueP); - - if (train == NULL) { - return; - } - - dlg->train = train; - ControllerDialogSync(dlg); - break; - - case I_ZERO: - if (dlg->train == NULL) { - return; - } - - TrainTimeEndPause(); - xx = GET_EXTRA_DATA(dlg->train, T_CAR, extraDataCar_t); - xx->distance = 0.0; - ParamLoadMessage(dlg->trainPGp, I_DIST, FormatDistance(xx->distance)); - ParamLoadControl(curTrainDlg->trainPGp, I_DIST); - TrainTimeStartPause(); - break; - - case I_GOTO: - if (dlg->train == NULL) { - return; - } - - TrainTimeEndPause(); - xx = GET_EXTRA_DATA(dlg->train, T_CAR, extraDataCar_t); - followTrain = NULL; - dlg->followMe = FALSE; - ParamLoadControl(curTrainDlg->trainPGp, I_FOLLOW); - CarSetVisible(dlg->train); - MoveMainWindow(xx->trvTrk.pos, xx->trvTrk.angle); - TrainTimeStartPause(); - break; - - case I_FOLLOW: - if (dlg->train == NULL) { - return; - } - - if (*(long*)valueP) { - followTrain = dlg->train; - xx = GET_EXTRA_DATA(dlg->train, T_CAR, extraDataCar_t); - - if (OFF_MAIND(xx->trvTrk.pos, xx->trvTrk.pos)) { - MoveMainWindow(xx->trvTrk.pos, xx->trvTrk.angle); - } - - followCenter = mainCenter; - } else { - followTrain = NULL; - } - - break; - - case I_AUTORVRS: - if (dlg->train == NULL) { - return; - } - - xx = GET_EXTRA_DATA(dlg->train, T_CAR, extraDataCar_t); - xx->autoReverse = *(long*)valueP!=0; - break; - - case I_DIR: - if (dlg->train == NULL) { - return; - } - - xx = GET_EXTRA_DATA(dlg->train, T_CAR, extraDataCar_t); - dlg->direction = xx->direction = !xx->direction; - wButtonSetLabel((wButton_p)pg->paramPtr[I_DIR].control, - (dlg->direction?_("Reverse"):_("Forward"))); - SetTrainDirection(dlg->train); - TempRedraw(); // ctrain: change direction - break; - - case I_STOP: - if (dlg->train == NULL) { - return; - } - - TrainTimeEndPause(); - StopTrain(dlg->train, ST_StopManual); - TrainTimeStartPause(); - break; - - case -1: - /* Close window */ - CmdTrainExit(NULL); - break; - } - - /*ControllerDialogSync( dlg );*/ - TrainTimeStartPause(); + paramGroup_p pg, + int inx, + void * valueP) +{ + trainControlDlg_p dlg = curTrainDlg; + track_p train; + struct extraDataCar_t * xx; + + if (dlg == NULL) { + return; + } + + TrainTimeEndPause(); + + switch (inx) { + case I_LIST: + train = (track_p)wListGetItemContext((wList_p)pg->paramPtr[inx].control, + (wIndex_t)*(long*)valueP); + + if (train == NULL) { + return; + } + + dlg->train = train; + ControllerDialogSync(dlg); + break; + + case I_ZERO: + if (dlg->train == NULL) { + return; + } + + TrainTimeEndPause(); + xx = GET_EXTRA_DATA(dlg->train, T_CAR, extraDataCar_t); + xx->distance = 0.0; + ParamLoadMessage(dlg->trainPGp, I_DIST, FormatDistance(xx->distance)); + ParamLoadControl(curTrainDlg->trainPGp, I_DIST); + TrainTimeStartPause(); + break; + + case I_GOTO: + if (dlg->train == NULL) { + return; + } + + + + TrainTimeEndPause(); + xx = GET_EXTRA_DATA(dlg->train, T_CAR, extraDataCar_t); + followTrain = NULL; + dlg->followMe = FALSE; + ParamLoadControl(curTrainDlg->trainPGp, I_FOLLOW); + CarSetVisible(dlg->train); + MoveMainWindow(xx->trvTrk.pos, xx->trvTrk.angle); + trainHighlighted = dlg->train; + TrainTimeStartPause(); + break; + + case I_FOLLOW: + if (dlg->train == NULL) { + return; + } + + if (*(long*)valueP) { + followTrain = dlg->train; + xx = GET_EXTRA_DATA(dlg->train, T_CAR, extraDataCar_t); + + if (OFF_MAIND(xx->trvTrk.pos, xx->trvTrk.pos)) { + MoveMainWindow(xx->trvTrk.pos, xx->trvTrk.angle); + } + + followCenter = mainCenter; + } else { + followTrain = NULL; + } + + break; + + case I_AUTORVRS: + if (dlg->train == NULL) { + return; + } + + xx = GET_EXTRA_DATA(dlg->train, T_CAR, extraDataCar_t); + xx->autoReverse = *(long*)valueP!=0; + break; + + case I_DIR: + if (dlg->train == NULL) { + return; + } + + xx = GET_EXTRA_DATA(dlg->train, T_CAR, extraDataCar_t); + dlg->direction = xx->direction = !xx->direction; + wButtonSetLabel((wButton_p)pg->paramPtr[I_DIR].control, + (dlg->direction?_("Reverse"):_("Forward"))); + SetTrainDirection(dlg->train); + TempRedraw(); // ctrain: change direction + break; + + case I_STOP: + if (dlg->train == NULL) { + return; + } + + TrainTimeEndPause(); + StopTrain(dlg->train, ST_StopManual); + TrainTimeStartPause(); + break; + + case -1: + /* Close window */ + CmdTrainExit(NULL); + break; + } + + /*ControllerDialogSync( dlg );*/ + TrainTimeStartPause(); } static trainControlDlg_p CreateTrainControlDlg(void) { - trainControlDlg_p dlg; - char * title; - paramData_p PLp; - dlg = (trainControlDlg_p)MyMalloc(sizeof *dlg); - PLp = trainPLs; - dlg->posS[0] = '\0'; - dlg->speedS[0] = '\0'; - PLp[I_LIST].valueP = &dlg->inx; - PLp[I_LIST].context = dlg; - PLp[I_POS].valueP = &dlg->posS; - PLp[I_POS].context = dlg; - /*PLp[I_GOTO].valueP = NULL;*/ - PLp[I_GOTO].context = dlg; - PLp[I_SLIDER].context = dlg; - PLp[I_SPEED].valueP = &dlg->speedS; - PLp[I_SPEED].context = dlg; - PLp[I_DIR].context = dlg; - /*PLp[I_STOP].valueP = NULL;*/ - PLp[I_STOP].context = dlg; - PLp[I_FOLLOW].valueP = &dlg->followMe; - PLp[I_FOLLOW].context = dlg; - PLp[I_AUTORVRS].valueP = &dlg->autoReverse; - PLp[I_AUTORVRS].context = dlg; - title = MyStrdup(_("Train Control XXX")); - sprintf(title, _("Train Control %d"), ++numTrainDlg); - dlg->trainPGp = &trainPG; - dlg->win = ParamCreateDialog(dlg->trainPGp, _("Train Control"), NULL, NULL, - NULL, FALSE, NULL, 0, ControllerDialogUpdate); - speedD.size.x = SLIDER_WIDTH/speedD.dpi; - speedD.size.y = SLIDER_HEIGHT/speedD.dpi; - return dlg; + trainControlDlg_p dlg; + char * title; + paramData_p PLp; + dlg = (trainControlDlg_p)MyMalloc(sizeof *dlg); + PLp = trainPLs; + dlg->posS[0] = '\0'; + dlg->speedS[0] = '\0'; + PLp[I_LIST].valueP = &dlg->inx; + PLp[I_LIST].context = dlg; + PLp[I_POS].valueP = &dlg->posS; + PLp[I_POS].context = dlg; + /*PLp[I_GOTO].valueP = NULL;*/ + PLp[I_GOTO].context = dlg; + PLp[I_SLIDER].context = dlg; + PLp[I_SPEED].valueP = &dlg->speedS; + PLp[I_SPEED].context = dlg; + PLp[I_DIR].context = dlg; + /*PLp[I_STOP].valueP = NULL;*/ + PLp[I_STOP].context = dlg; + PLp[I_FOLLOW].valueP = &dlg->followMe; + PLp[I_FOLLOW].context = dlg; + PLp[I_AUTORVRS].valueP = &dlg->autoReverse; + PLp[I_AUTORVRS].context = dlg; + title = MyStrdup(_("Train Control XXX")); + sprintf(title, _("Train Control %d"), ++numTrainDlg); + dlg->trainPGp = &trainPG; + dlg->win = ParamCreateDialog(dlg->trainPGp, _("Train Control"), NULL, NULL, + NULL, FALSE, NULL, 0, ControllerDialogUpdate); + speedD.size.x = SLIDER_WIDTH/speedD.dpi; + speedD.size.y = SLIDER_HEIGHT/speedD.dpi; + return dlg; } @@ -1316,431 +1389,443 @@ static trainControlDlg_p CreateTrainControlDlg(void) */ static struct { - STATE_T state; - coOrd pos0; + STATE_T state; + coOrd pos0; } Dtrain; long trainPause = 200; static track_p followTrain = NULL; -static void DrawAllCars(void) -{ - track_p car; - struct extraDataCar_t * xx; - coOrd size, lo, hi; - BOOL_T drawCarEnable1 = drawCarEnable; - drawCarEnable = TRUE; - wDrawDelayUpdate(mainD.d, TRUE); - wDrawRestoreImage(mainD.d); - DrawPositionIndicators(); - - for (car=NULL; TrackIterate(&car);) { - if (GetTrkType(car) == T_CAR) { - xx = GET_EXTRA_DATA(car, T_CAR, extraDataCar_t); - CarItemSize(xx->item, - &size); /* TODO assumes xx->trvTrk.pos is the car center */ - lo.x = xx->trvTrk.pos.x - size.x/2.0; - lo.y = xx->trvTrk.pos.y - size.x/2.0; - hi.x = lo.x + size.x; - hi.y = lo.y + size.x; - - if (!OFF_MAIND(lo, hi)) { - DrawCar(car, &tempD, wDrawColorBlack); - } - } - } - - wDrawDelayUpdate(mainD.d, FALSE); - drawCarEnable = drawCarEnable1; +static void DrawAllCars(track_p trk) +{ + track_p car; + struct extraDataCar_t * xx; + coOrd size, lo, hi; + BOOL_T drawCarEnable1 = drawCarEnable; + drawCarEnable = TRUE; + wDrawDelayUpdate(mainD.d, TRUE); + wDrawRestoreImage(mainD.d); + DrawPositionIndicators(); + + for (car=NULL; TrackIterate(&car);) { + if (GetTrkType(car) == T_CAR) { + xx = GET_EXTRA_DATA(car, T_CAR, extraDataCar_t); + CarItemSize(xx->item, + &size); /* TODO assumes xx->trvTrk.pos is the car center */ + lo.x = xx->trvTrk.pos.x - size.x/2.0; + lo.y = xx->trvTrk.pos.y - size.x/2.0; + hi.x = lo.x + size.x; + hi.y = lo.y + size.x; + + if (!OFF_MAIND(lo, hi)) { + DrawCar(car, &tempD, wDrawColorBlack); + if (car == trk) { + DrawCar(trk,&tempD,wDrawColorPreviewSelected); + } + } + } + } + + wDrawDelayUpdate(mainD.d, FALSE); + drawCarEnable = drawCarEnable1; } static DIST_T GetTrainLength2( - track_p * car0, - BOOL_T * dir) + track_p * car0, + BOOL_T * dir) { - DIST_T length = 0, carLength; - struct extraDataCar_t * xx; - WALK_CARS_START(*car0, xx, *dir) - carLength = CarItemCoupledLength(xx->item); - - if (length == 0) { - length = carLength/2.0; /* TODO assumes xx->trvTrk.pos is the car center */ - } else { - length += carLength; - } + DIST_T length = 0, carLength; + struct extraDataCar_t * xx; + WALK_CARS_START(*car0, xx, *dir) + carLength = CarItemCoupledLength(xx->item); + + if (length == 0) { + length = carLength/2.0; /* TODO assumes xx->trvTrk.pos is the car center */ + } else { + length += carLength; + } - WALK_CARS_END(*car0, xx, *dir) - return length; + WALK_CARS_END(*car0, xx, *dir) + return length; } static DIST_T GetTrainLength( - track_p car0, - BOOL_T dir) + track_p car0, + BOOL_T dir) { - return GetTrainLength2(&car0, &dir); + return GetTrainLength2(&car0, &dir); } static void PlaceCar( - track_p car) + track_p car) { - struct extraDataCar_t *xx = GET_EXTRA_DATA(car, T_CAR, extraDataCar_t); - DIST_T dists[2]; - CarItemPlace(xx->item, &xx->trvTrk, dists); - - CarItemFindCouplerMountPoint(xx->item, xx->trvTrk, xx->couplerPos); - - car->endPt[0].angle = xx->trvTrk.angle; - Translate(&car->endPt[0].pos, xx->trvTrk.pos, car->endPt[0].angle, dists[0]); - car->endPt[1].angle = NormalizeAngle(xx->trvTrk.angle + 180.0); - Translate(&car->endPt[1].pos, xx->trvTrk.pos, car->endPt[1].angle, dists[1]); - LOG(log_trainMove, 4, ("%s @ [%0.3f,%0.3f] A%0.3f\n", CarItemNumber(xx->item), - xx->trvTrk.pos.x, xx->trvTrk.pos.y, xx->trvTrk.angle)) - SetCarBoundingBox(car); - xx->state &= ~(CAR_STATE_ONHIDENTRACK); - xx->trkLayer = NOTALAYER; - - if (xx->trvTrk.trk) { - if (!GetTrkVisible(xx->trvTrk.trk)) { - xx->state |= CAR_STATE_ONHIDENTRACK; - } + struct extraDataCar_t *xx = GET_EXTRA_DATA(car, T_CAR, extraDataCar_t); + DIST_T dists[2]; + CarItemPlace(xx->item, &xx->trvTrk, dists); + + CarItemFindCouplerMountPoint(xx->item, xx->trvTrk, xx->couplerPos); + + coOrd tempPos; + ANGLE_T tempAng; + tempAng = xx->trvTrk.angle; + Translate( &tempPos, xx->trvTrk.pos, tempAng, dists[0] ); + SetTrkEndPointSilent( car, 0, tempPos, tempAng ); + tempAng = NormalizeAngle( tempAng+180.0 ); + Translate( &tempPos, xx->trvTrk.pos, tempAng, dists[1] ); + SetTrkEndPointSilent( car, 1, tempPos, tempAng ); + + LOG(log_trainMove, 4, ("%s @ [%0.3f,%0.3f] A%0.3f\n", CarItemNumber(xx->item), + xx->trvTrk.pos.x, xx->trvTrk.pos.y, xx->trvTrk.angle)) + SetCarBoundingBox(car); + xx->state &= ~(CAR_STATE_ONHIDENTRACK); + xx->trkLayer = NOTALAYER; + + if (xx->trvTrk.trk) { + if (!GetTrkVisible(xx->trvTrk.trk)) { + xx->state |= CAR_STATE_ONHIDENTRACK; + } - xx->trkLayer = GetTrkLayer(xx->trvTrk.trk); - } + xx->trkLayer = GetTrkLayer(xx->trvTrk.trk); + } } static track_p FindCar( - coOrd * pos) + coOrd * pos) { - coOrd pos0, pos1; - track_p trk, trk1; - DIST_T dist1 = DIST_INF, dist; - struct extraDataCar_t * xx; - trk1 = NULL; + coOrd pos0, pos1; + track_p trk, trk1; + DIST_T dist1 = DIST_INF, dist; + struct extraDataCar_t * xx; + trk1 = NULL; + + for (trk=NULL; TrackIterate(&trk);) { + if (GetTrkType(trk) == T_CAR) { + xx = GET_EXTRA_DATA(trk, T_CAR, extraDataCar_t); + + if (IsIgnored(xx)) { + continue; + } - for (trk=NULL; TrackIterate(&trk);) { - if (GetTrkType(trk) == T_CAR) { - xx = GET_EXTRA_DATA(trk, T_CAR, extraDataCar_t); + pos0 = *pos; - if (IsIgnored(xx)) { - continue; - } + coOrd hi,lo; - pos0 = *pos; - dist = DistanceCar(trk, &pos0); + GetBoundingBox(trk,&hi,&lo); - if (dist < dist1) { - dist1 = dist; - trk1 = trk; - pos1 = pos0; - } - } - } + if (hi.x < pos0.x || + lo.x > pos0.x || + hi.y < pos0.y || + lo.y > pos0.y ) { + continue; + } + + dist = DistanceCar(trk, &pos0); + + if (dist < dist1) { + dist1 = dist; + trk1 = trk; + pos1 = pos0; + } + } + } - if (dist1 < 10) { - *pos = pos1; - return trk1; - } else { - return NULL; - } + if (dist1 < trackGauge*2.0) { + *pos = pos1; + return trk1; + } else { + return NULL; + } } static track_p FindMasterLoco( - track_p train, - int * dirR) + track_p train, + int * dirR) { - struct extraDataCar_t *xx0; - int dir; - - for (dir = 0; dir<2; dir++) { - track_p car0; - int dir0; - car0 = train; - dir0 = dir; - WALK_CARS_START(car0, xx0, dir0) - - if (CarItemIsLoco(xx0->item) && IsLocoMaster(xx0)) { - if (dirR) { - *dirR = 1-dir0; - } + struct extraDataCar_t *xx0; + int dir; + + for (dir = 0; dir<2; dir++) { + track_p car0; + int dir0; + car0 = train; + dir0 = dir; + WALK_CARS_START(car0, xx0, dir0) + + if (CarItemIsLoco(xx0->item) && IsLocoMaster(xx0)) { + if (dirR) { + *dirR = 1-dir0; + } - return car0; - } + return car0; + } - WALK_CARS_END(car0, xx0, dir0) - } + WALK_CARS_END(car0, xx0, dir0) + } - return NULL; + return NULL; } static track_p PickMasterLoco( - track_p car, - int dir) + track_p car, + int dir) { - track_p loco=NULL; - struct extraDataCar_t *xx; - WALK_CARS_START(car, xx, dir) + track_p loco=NULL; + struct extraDataCar_t *xx; + WALK_CARS_START(car, xx, dir) - if (CarItemIsLoco(xx->item)) { - if (IsLocoMaster(xx)) { - return car; - } + if (CarItemIsLoco(xx->item)) { + if (IsLocoMaster(xx)) { + return car; + } - if (loco == NULL) { - loco = car; - } - } + if (loco == NULL) { + loco = car; + } + } - WALK_CARS_END(car, xx, dir) + WALK_CARS_END(car, xx, dir) - if (loco == NULL) { - return NULL; - } + if (loco == NULL) { + return NULL; + } - xx = GET_EXTRA_DATA(loco, T_CAR, extraDataCar_t); - SetLocoMaster(xx); - xx->speed = 0; - LOG(log_trainMove, 1, ("%s becomes master\n", CarItemNumber(xx->item))) - return loco; + xx = GET_EXTRA_DATA(loco, T_CAR, extraDataCar_t); + SetLocoMaster(xx); + xx->speed = 0; + LOG(log_trainMove, 1, ("%s becomes master\n", CarItemNumber(xx->item))) + return loco; } -static void UncoupleCars( - track_p car1, - track_p car2) +EXPORT void UncoupleCars( + track_p car1, + int dir1 ) { - track_p loco; - int dir1, dir2; - - if (GetTrkEndTrk(car1,0) == car2) { - dir1 = 0; - } else if (GetTrkEndTrk(car1,1) == car2) { - dir1 = 1; - } else { - ErrorMessage("uncoupleCars - not coupled"); - return; - } - - if (GetTrkEndTrk(car2,0) == car1) { - dir2 = 0; - } else if (GetTrkEndTrk(car2,1) == car1) { - dir2 = 1; - } else { - ErrorMessage("uncoupleCars - not coupled"); - return; - } + track_p car2 = GetTrkEndTrk(car1,dir1); + if ( car2 == NULL ) { + return; + } + track_p loco; + int dir2; + + if (GetTrkEndTrk(car2,0) == car1) { + dir2 = 0; + } else if (GetTrkEndTrk(car2,1) == car1) { + dir2 = 1; + } else { + ErrorMessage("uncoupleCars - not coupled"); + return; + } - loco = FindMasterLoco(car1, NULL); - car1->endPt[dir1].track = NULL; - car2->endPt[dir2].track = NULL; + loco = FindMasterLoco(car1, NULL); + DisconnectTracks( car1, dir1, car2, dir2 ); - if (loco) { - track_p loco1, loco2; - loco1 = PickMasterLoco(car1, 1-dir1); + if (loco) { + track_p loco1, loco2; + loco1 = PickMasterLoco(car1, 1-dir1); - if (loco1 != loco) { - LocoListChangeEntry(NULL, loco1); - } + if (loco1 != loco) { + LocoListChangeEntry(NULL, loco1); + } - loco2 = PickMasterLoco(car2, 1-dir2); + loco2 = PickMasterLoco(car2, 1-dir2); - if (loco2 != loco) { - LocoListChangeEntry(NULL, loco2); - } - } + if (loco2 != loco) { + LocoListChangeEntry(NULL, loco2); + } + } } static void CoupleCars( - track_p car1, - int dir1, - track_p car2, - int dir2) + track_p car1, + int dir1, + track_p car2, + int dir2) { - struct extraDataCar_t * xx1, * xx2; - track_p loco1, loco2; - track_p car; - int dir; - xx1 = GET_EXTRA_DATA(car1, T_CAR, extraDataCar_t); - xx2 = GET_EXTRA_DATA(car2, T_CAR, extraDataCar_t); - - if (GetTrkEndTrk(car1,dir1) != NULL || GetTrkEndTrk(car2,dir2) != NULL) { - LOG(log_trainMove, 1, ("coupleCars - already coupled\n")) - return; - } + struct extraDataCar_t * xx1, * xx2; + track_p loco1, loco2; + track_p car; + int dir; + xx1 = GET_EXTRA_DATA(car1, T_CAR, extraDataCar_t); + xx2 = GET_EXTRA_DATA(car2, T_CAR, extraDataCar_t); + + if (GetTrkEndTrk(car1,dir1) != NULL || GetTrkEndTrk(car2,dir2) != NULL) { + LOG(log_trainMove, 1, ("coupleCars - already coupled\n")) + return; + } - car = car1; - dir = 1-dir1; - WALK_CARS_START(car, xx1, dir) + car = car1; + dir = 1-dir1; + WALK_CARS_START(car, xx1, dir) - if (car == car2) { - LOG(log_trainMove, 1, ("coupleCars - already coupled\n")) - ErrorMessage("Car coupling loop"); - return; - } + if (car == car2) { + LOG(log_trainMove, 1, ("coupleCars - already coupled\n")) + ErrorMessage("Car coupling loop"); + return; + } - WALK_CARS_END(car, xx1, dir) - car = car2; - dir = 1-dir2; - WALK_CARS_START(car, xx2, dir) + WALK_CARS_END(car, xx1, dir) + car = car2; + dir = 1-dir2; + WALK_CARS_START(car, xx2, dir) - if (car == car1) { - LOG(log_trainMove, 1, ("coupleCars - already coupled\n")) - ErrorMessage("Car coupling loop"); - return; - } + if (car == car1) { + LOG(log_trainMove, 1, ("coupleCars - already coupled\n")) + ErrorMessage("Car coupling loop"); + return; + } - WALK_CARS_END(car, xx1, dir) - loco1 = FindMasterLoco(car1, NULL); - loco2 = FindMasterLoco(car2, NULL); - car1->endPt[dir1].track = car2; - car2->endPt[dir2].track = car1; + WALK_CARS_END(car, xx1, dir) + loco1 = FindMasterLoco(car1, NULL); + loco2 = FindMasterLoco(car2, NULL); + ConnectTracks( car1, dir1, car2, dir2 ); - /*ConnectTracks( car1, dir1, car2, dir2 );*/ - if (logTable(log_trainMove).level >= 2) { - LogPrintf("Coupling %s[%d] ", CarItemNumber(xx1->item), dir1); - LogPrintf(" and %s[%d]\n", CarItemNumber(xx2->item), dir2); - } + if (logTable(log_trainMove).level >= 2) { + LogPrintf("Coupling %s[%d] ", CarItemNumber(xx1->item), dir1); + LogPrintf(" and %s[%d]\n", CarItemNumber(xx2->item), dir2); + } - if ((loco1 != NULL && loco2 != NULL)) { - xx1 = GET_EXTRA_DATA(loco1, T_CAR, extraDataCar_t); - xx2 = GET_EXTRA_DATA(loco2, T_CAR, extraDataCar_t); + if ((loco1 != NULL && loco2 != NULL)) { + xx1 = GET_EXTRA_DATA(loco1, T_CAR, extraDataCar_t); + xx2 = GET_EXTRA_DATA(loco2, T_CAR, extraDataCar_t); - if (xx1->speed == 0) { - ClrLocoMaster(xx1); - LOG(log_trainMove, 2, ("%s loses master\n", CarItemNumber(xx1->item))) + if (xx1->speed == 0) { + ClrLocoMaster(xx1); + LOG(log_trainMove, 2, ("%s loses master\n", CarItemNumber(xx1->item))) - if (followTrain == loco1) { - followTrain = loco2; - } + if (followTrain == loco1) { + followTrain = loco2; + } - LocoListChangeEntry(loco1, NULL); - loco1 = loco2; - } else { - ClrLocoMaster(xx2); - xx1->speed = (xx1->speed + xx2->speed)/2.0; + LocoListChangeEntry(loco1, NULL); + loco1 = loco2; + } else { + ClrLocoMaster(xx2); + xx1->speed = (xx1->speed + xx2->speed)/2.0; - if (xx1->speed < 0) { - xx1->speed = 0; - } + if (xx1->speed < 0) { + xx1->speed = 0; + } - if (xx1->speed > 100) { - xx1->speed = 100; - } + if (xx1->speed > 100) { + xx1->speed = 100; + } - LOG(log_trainMove, 2, ("%s loses master\n", CarItemNumber(xx2->item))) + LOG(log_trainMove, 2, ("%s loses master\n", CarItemNumber(xx2->item))) - if (followTrain == loco2) { - followTrain = loco1; - } + if (followTrain == loco2) { + followTrain = loco1; + } - LocoListChangeEntry(loco2, NULL); - } + LocoListChangeEntry(loco2, NULL); + } - SetTrainDirection(loco1); - } + SetTrainDirection(loco1); + } } long crashDistFactor=60; static void PlaceCars( - track_p car0, - int dir0, - long crashSpeed, - BOOL_T crashFlip) + track_p car0, + int dir0, + long crashSpeed, + BOOL_T crashFlip) { - struct extraDataCar_t *xx0 = GET_EXTRA_DATA(car0, T_CAR, extraDataCar_t), *xx; - int dir; - traverseTrack_t trvTrk; - DIST_T length; - track_p car_curr; - DIST_T flipflop = 1; - - if (crashFlip) { - flipflop = -1; - } + struct extraDataCar_t *xx0 = GET_EXTRA_DATA(car0, T_CAR, extraDataCar_t), *xx; + int dir; + traverseTrack_t trvTrk; + DIST_T length; + track_p car_curr; + DIST_T flipflop = 1; + + if (crashFlip) { + flipflop = -1; + } - dir = dir0; - trvTrk = xx0->trvTrk; + dir = dir0; + trvTrk = xx0->trvTrk; - if (dir0) { - FlipTraverseTrack(&trvTrk); - } + if (dir0) { + FlipTraverseTrack(&trvTrk); + } - length = CarItemCoupledLength(xx0->item)/2.0; - car_curr = car0; - ClrIgnored(xx0); - WALK_CARS_START(car_curr, xx, dir) + length = CarItemCoupledLength(xx0->item)/2.0; + car_curr = car0; + ClrIgnored(xx0); + WALK_CARS_START(car_curr, xx, dir) - if (car_curr != car0) { - DIST_T dist, length1; - ClrIgnored(xx); - length1 = CarItemCoupledLength(xx->item)/2.0; - dist = length + length1; - crashSpeed = crashSpeed*CRASHSPEEDDECAY/10; + if (car_curr != car0) { + DIST_T dist, length1; + ClrIgnored(xx); + length1 = CarItemCoupledLength(xx->item)/2.0; + dist = length + length1; + crashSpeed = crashSpeed*CRASHSPEEDDECAY/10; - if (crashSpeed > 0) { - dist -= dist * crashSpeed/crashDistFactor; - } + if (crashSpeed > 0) { + dist -= dist * crashSpeed/crashDistFactor; + } - TraverseTrack2(&trvTrk, dist); - xx->trvTrk = trvTrk; + TraverseTrack2(&trvTrk, dist); + xx->trvTrk = trvTrk; - if (crashSpeed > 0) { - xx->trvTrk.angle = NormalizeAngle(xx->trvTrk.angle + flipflop*crashSpeed); - xx->trvTrk.trk = NULL; - } + if (crashSpeed > 0) { + xx->trvTrk.angle = NormalizeAngle(xx->trvTrk.angle + flipflop*crashSpeed); + xx->trvTrk.trk = NULL; + } - flipflop = -flipflop; + flipflop = -flipflop; - if (dir != 0) { - FlipTraverseTrack(&xx->trvTrk); - } + if (dir != 0) { + FlipTraverseTrack(&xx->trvTrk); + } - PlaceCar(car_curr); - length = length1; - } + PlaceCar(car_curr); + length = length1; + } - WALK_CARS_END(car_curr, xx, dir) + WALK_CARS_END(car_curr, xx, dir) } static void CrashTrain( - track_p car, - int dir, - traverseTrack_p trvTrkP, - long speed, - BOOL_T flip) + track_p car, + int dir, + traverseTrack_p trvTrkP, + long speed, + BOOL_T flip) { - track_p loco; - struct extraDataCar_t *xx; - loco = FindMasterLoco(car,NULL); + track_p loco; + struct extraDataCar_t *xx; + loco = FindMasterLoco(car,NULL); - if (loco != NULL) { - StopTrain(loco, ST_Crashed); - } + if (loco != NULL) { + StopTrain(loco, ST_Crashed); + } - xx = GET_EXTRA_DATA(car, T_CAR, extraDataCar_t); - xx->trvTrk = *trvTrkP; + xx = GET_EXTRA_DATA(car, T_CAR, extraDataCar_t); + xx->trvTrk = *trvTrkP; - if (dir) { - FlipTraverseTrack(&xx->trvTrk); - } + if (dir) { + FlipTraverseTrack(&xx->trvTrk); + } - PlaceCars(car, 1-dir, speed, flip); + PlaceCars(car, 1-dir, speed, flip); - if (flip) { - speed = - speed; - } + if (flip) { + speed = - speed; + } - xx->trvTrk.angle = NormalizeAngle(xx->trvTrk.angle - speed); - xx->trvTrk.trk = NULL; - PlaceCar(car); + xx->trvTrk.angle = NormalizeAngle(xx->trvTrk.angle - speed); + xx->trvTrk.trk = NULL; + PlaceCar(car); } /* @@ -1749,105 +1834,107 @@ static void CrashTrain( * Returns TRUE if we should continue. */ static BOOL_T CheckCoupling( - track_p car0, - int dir00, - BOOL_T doCheckCrash) -{ - track_p car1; - struct extraDataCar_t *xx0, *xx1; - coOrd pos1; - DIST_T dist0, distc, dist=DIST_INF; - int dir0, dir1, dirl; - ANGLE_T angle; - traverseTrack_t trvTrk0, trvTrk1; - xx0 = xx1 = GET_EXTRA_DATA(car0, T_CAR, extraDataCar_t); - /* find length of train from loco to start and end */ - dir0 = dir00; - dist0 = GetTrainLength2(&car0, &dir0); - trvTrk0 = xx0->trvTrk; - - if (dir00) { - FlipTraverseTrack(&trvTrk0); - } - - TraverseTrack2(&trvTrk0, dist0); - pos1 = trvTrk0.pos; - car1 = FindCar(&pos1); - - if (!car1) { - return TRUE; - } - - xx1 = GET_EXTRA_DATA(car1, T_CAR, extraDataCar_t); - - if (!IsOnTrack(xx1)) { - return TRUE; - } - - /* determine which EP of the found car to couple to */ - angle = NormalizeAngle(trvTrk0.angle-xx1->trvTrk.angle); - - if (angle > 90 && angle < 270) { - dir1 = 0; - angle = NormalizeAngle(angle+180); - } else { - dir1 = 1; - } - - /* already coupled? */ - if (GetTrkEndTrk(car1,dir1) != NULL) { - return TRUE; - } - - /* are we close to aligned? Uses 45 degrees offset today */ - /* It assumes that if the cars are aligned they could/should be coupled */ - if (angle > COUPLERCONNECTIONANGLE && angle < 360.0-COUPLERCONNECTIONANGLE) { - return TRUE; - } - - /* find pos of found end car's coupler, and dist btw couplers */ - distc = CarItemCoupledLength(xx1->item); - /* pos1 is the end of the xx1 car (end car) */ - Translate(&pos1, xx1->trvTrk.pos, xx1->trvTrk.angle+(dir1?180.0:0.0), - distc/2.0); - dist = FindDistance(trvTrk0.pos, pos1); - /* How far away are the two ends?*/ - if (dist < trackGauge/10) { - return TRUE; - } - - /* not real close: are we overlapped? */ - angle = FindAngle(trvTrk0.pos, pos1); - angle = NormalizeAngle(angle - trvTrk0.angle); - - if (angle < 90 || angle > 270) { - return TRUE; - } - - /* are we beyond the end of the found car? */ - if (dist > distc) { - return TRUE; - } - - /* are we on the same track? */ - trvTrk1 = xx1->trvTrk; - - if (dir1) { - FlipTraverseTrack(&trvTrk1); - } - - /* Move second train back along track half a car length */ - TraverseTrack2(&trvTrk1, distc/2.0-dist); - if ( trvTrk0.trk == NULL || trvTrk1.trk == NULL ) - // fell off the end of track - return FALSE; - - /* If tracks are not the same - dont couple */ - if (trvTrk1.trk != trvTrk0.trk) { - return TRUE; - } - - /* If this is further apart than 2 track gauges on a turnout, dont couple */ + track_p car0, + int dir00, + BOOL_T doCheckCrash) +{ + track_p car1; + struct extraDataCar_t *xx0, *xx1; + coOrd pos1; + DIST_T dist0, distc, dist=DIST_INF; + int dir0, dir1, dirl; + ANGLE_T angle; + traverseTrack_t trvTrk0, trvTrk1; + xx0 = xx1 = GET_EXTRA_DATA(car0, T_CAR, extraDataCar_t); + /* find length of train from loco to start and end */ + dir0 = dir00; + dist0 = GetTrainLength2(&car0, &dir0); + trvTrk0 = xx0->trvTrk; + + if (dir00) { + FlipTraverseTrack(&trvTrk0); + } + + TraverseTrack2(&trvTrk0, dist0); + pos1 = trvTrk0.pos; + car1 = FindCar(&pos1); + + if (!car1) { + return TRUE; + } + + xx1 = GET_EXTRA_DATA(car1, T_CAR, extraDataCar_t); + + if (!IsOnTrack(xx1)) { + return TRUE; + } + + /* determine which EP of the found car to couple to */ + angle = NormalizeAngle(trvTrk0.angle-xx1->trvTrk.angle); + + if (angle > 90 && angle < 270) { + dir1 = 0; + angle = NormalizeAngle(angle+180); + } else { + dir1 = 1; + } + + /* already coupled? */ + if (GetTrkEndTrk(car1,dir1) != NULL) { + return TRUE; + } + + /* are we close to aligned? Uses 45 degrees offset today */ + /* It assumes that if the cars are aligned they could/should be coupled */ + if (angle > COUPLERCONNECTIONANGLE && angle < 360.0-COUPLERCONNECTIONANGLE) { + return TRUE; + } + + /* find pos of found end car's coupler, and dist btw couplers */ + distc = CarItemCoupledLength(xx1->item); + /* pos1 is the end of the xx1 car (end car) */ + Translate(&pos1, xx1->trvTrk.pos, xx1->trvTrk.angle+(dir1?180.0:0.0), + distc/2.0); + dist = FindDistance(trvTrk0.pos, pos1); + /* How far away are the two ends?*/ + if (dist < trackGauge/10) { + return TRUE; + } + + /* not real close: are we overlapped? */ + angle = FindAngle(trvTrk0.pos, pos1); + angle = NormalizeAngle(angle - trvTrk0.angle); + + if (angle < 90 || angle > 270) { + return TRUE; + } + + /* are we beyond the end of the found car? */ + if (dist > distc) { + return TRUE; + } + + /* are we on the same track? */ + trvTrk1 = xx1->trvTrk; + + if (dir1) { + FlipTraverseTrack(&trvTrk1); + } + + /* Move second train back along track half a car length */ + TraverseTrack2(&trvTrk1, distc/2.0-dist); + if ( trvTrk0.trk == NULL || trvTrk1.trk == NULL ) + // fell off the end of track + { + return FALSE; + } + + /* If tracks are not the same - dont couple */ + if (trvTrk1.trk != trvTrk0.trk) { + return TRUE; + } + + /* If this is further apart than 2 track gauges on a turnout, dont couple */ if (GetTrkType(trvTrk0.trk) == T_TURNOUT) { if (dist > GetTrkGauge(trvTrk0.trk)*2) { return TRUE; @@ -1856,617 +1943,622 @@ static BOOL_T CheckCoupling( /* Concluded we are hitting each other */ - if (doCheckCrash) { - track_p loco1; - long speed, speed0, speed1; - speed0 = (long)xx0->speed; + if (doCheckCrash) { + track_p loco1; + long speed, speed0, speed1; + speed0 = (long)xx0->speed; - if ((xx0->direction==0) != (dir00==0)) { - speed0 = - speed0; - } + if ((xx0->direction==0) != (dir00==0)) { + speed0 = - speed0; + } - loco1 = FindMasterLoco(car1, &dirl); - xx1 = NULL; + loco1 = FindMasterLoco(car1, &dirl); + xx1 = NULL; - if (loco1) { - xx1 = GET_EXTRA_DATA(loco1, T_CAR, extraDataCar_t); - speed1 = (long)xx1->speed; + if (loco1) { + xx1 = GET_EXTRA_DATA(loco1, T_CAR, extraDataCar_t); + speed1 = (long)xx1->speed; - if (car1 == loco1) { - dirl = IsAligned(xx1->trvTrk.angle, FindAngle(trvTrk0.pos, - xx1->trvTrk.pos))?1:0; - } + if (car1 == loco1) { + dirl = IsAligned(xx1->trvTrk.angle, FindAngle(trvTrk0.pos, + xx1->trvTrk.pos))?1:0; + } - if ((xx1->direction==1) != (dirl==1)) { - speed1 = -speed1; - } - } else { - speed1 = 0; - } + if ((xx1->direction==1) != (dirl==1)) { + speed1 = -speed1; + } + } else { + speed1 = 0; + } - speed = labs(speed0 + speed1); - LOG(log_trainMove, 2, ("coupling speed=%ld\n", speed)) + speed = labs(speed0 + speed1); + LOG(log_trainMove, 2, ("coupling speed=%ld\n", speed)) - if (speed > maxCouplingSpeed) { - CrashTrain(car0, dir0, &trvTrk0, speed, FALSE); - CrashTrain(car1, dir1, &trvTrk1, speed, TRUE); - return FALSE; - } - } + if (speed > maxCouplingSpeed) { + CrashTrain(car0, dir0, &trvTrk0, speed, FALSE); + CrashTrain(car1, dir1, &trvTrk1, speed, TRUE); + return FALSE; + } + } - if (dir00) { - dist = -dist; - } + if (dir00) { + dist = -dist; + } - TraverseTrack2(&xx0->trvTrk, dist); - CoupleCars(car0, dir0, car1, dir1); - LOG(log_trainMove, 3, (" -> %0.3f\n", dist)) - return TRUE; + TraverseTrack2(&xx0->trvTrk, dist); + CoupleCars(car0, dir0, car1, dir1); + LOG(log_trainMove, 3, (" -> %0.3f\n", dist)) + return TRUE; } static void PlaceTrain( - track_p car0, - BOOL_T doCheckCrash, - BOOL_T doCheckCoupling) -{ - track_p car_curr; - struct extraDataCar_t *xx0; - int dir0; - xx0 = GET_EXTRA_DATA(car0, T_CAR, extraDataCar_t); - LOG(log_trainMove, 2, (" placeTrain: %s [%0.3f %0.3f] A%0.3f", - CarItemNumber(xx0->item), xx0->trvTrk.pos.x, xx0->trvTrk.pos.y, - xx0->trvTrk.angle)) - car_curr = car0; - - for (dir0=0; dir0<2; dir0++) { - int dir; - struct extraDataCar_t *xx; - car_curr = car0; - dir = dir0; - xx = xx0; - WALK_CARS_START(car_curr, xx, dir) - SetIgnored(xx); - WALK_CARS_END(car_curr, xx, dir); - } - - /* check for coupling to other cars */ - if (doCheckCoupling) { - if (xx0->trvTrk.trk) - if (!CheckCoupling(car0, 0, doCheckCrash)) { - return; - } - - if (xx0->trvTrk.trk) - if (!CheckCoupling(car0, 1, doCheckCrash)) { - return; - } - } - - PlaceCar(car0); - - for (dir0=0; dir0<2; dir0++) { - PlaceCars(car0, dir0, 0, FALSE); - } + track_p car0, + BOOL_T doCheckCrash, + BOOL_T doCheckCoupling) +{ + track_p car_curr; + struct extraDataCar_t *xx0; + int dir0; + xx0 = GET_EXTRA_DATA(car0, T_CAR, extraDataCar_t); + LOG(log_trainMove, 2, (" placeTrain: %s [%0.3f %0.3f] A%0.3f", + CarItemNumber(xx0->item), xx0->trvTrk.pos.x, xx0->trvTrk.pos.y, + xx0->trvTrk.angle)) + car_curr = car0; + + for (dir0=0; dir0<2; dir0++) { + int dir; + struct extraDataCar_t *xx; + car_curr = car0; + dir = dir0; + xx = xx0; + WALK_CARS_START(car_curr, xx, dir) + SetIgnored(xx); + WALK_CARS_END(car_curr, xx, dir); + } + + /* check for coupling to other cars */ + if (doCheckCoupling) { + if (xx0->trvTrk.trk) + if (!CheckCoupling(car0, 0, doCheckCrash)) { + return; + } + + if (xx0->trvTrk.trk) + if (!CheckCoupling(car0, 1, doCheckCrash)) { + return; + } + } + + PlaceCar(car0); + + for (dir0=0; dir0<2; dir0++) { + PlaceCars(car0, dir0, 0, FALSE); + } } static void PlaceTrainInit( - track_p car0, - track_p trk0, - coOrd pos0, - ANGLE_T angle0, - BOOL_T doCheckCoupling) + track_p car0, + track_p trk0, + coOrd pos0, + ANGLE_T angle0, + BOOL_T doCheckCoupling) { - struct extraDataCar_t * xx = GET_EXTRA_DATA(car0, T_CAR, extraDataCar_t); - xx->trvTrk.trk = trk0; - xx->trvTrk.dist = xx->trvTrk.length = -1; - xx->trvTrk.pos = pos0; - xx->trvTrk.angle = angle0; - PlaceTrain(car0, FALSE, doCheckCoupling); + struct extraDataCar_t * xx = GET_EXTRA_DATA(car0, T_CAR, extraDataCar_t); + xx->trvTrk.trk = trk0; + xx->trvTrk.dist = xx->trvTrk.length = -1; + xx->trvTrk.pos = pos0; + xx->trvTrk.angle = angle0; + PlaceTrain(car0, FALSE, doCheckCoupling); } static void FlipTrain( - track_p train) + track_p train) { - DIST_T d0, d1; - struct extraDataCar_t * xx; + DIST_T d0, d1; + struct extraDataCar_t * xx; - if (train == NULL) { - return; - } + if (train == NULL) { + return; + } - d0 = GetTrainLength(train, 0); - d1 = GetTrainLength(train, 1); - xx = GET_EXTRA_DATA(train, T_CAR, extraDataCar_t); - TraverseTrack2(&xx->trvTrk, d0-d1); - FlipTraverseTrack(&xx->trvTrk); - xx->trvTrk.length = -1; - PlaceTrain(train, FALSE, TRUE); + d0 = GetTrainLength(train, 0); + d1 = GetTrainLength(train, 1); + xx = GET_EXTRA_DATA(train, T_CAR, extraDataCar_t); + TraverseTrack2(&xx->trvTrk, d0-d1); + FlipTraverseTrack(&xx->trvTrk); + xx->trvTrk.length = -1; + PlaceTrain(train, FALSE, TRUE); } static BOOL_T MoveTrain( - track_p train, - long timeD) -{ - DIST_T ips, dist0, dist1; - struct extraDataCar_t *xx, *xx1; - traverseTrack_t trvTrk; - DIST_T length; - track_p car1; - int dir1; - int measured; /* make sure the distance is only measured once per train */ - - if (train == NULL) { - return FALSE; - } - - xx = GET_EXTRA_DATA(train, T_CAR, extraDataCar_t); - - if (xx->speed <= 0) { - return FALSE; - } - - ips = ((xx->speed*5280.0*12.0)/(60.0*60.0*GetScaleRatio(GetLayoutCurScale()))); - dist0 = ips * timeD/1000.0; - length = GetTrainLength(train, xx->direction); - dist1 = length + dist0; - trvTrk = xx->trvTrk; - - if (trvTrk.trk == NULL) { - return FALSE; - } - - LOG(log_trainMove, 1, - ("moveTrain: %s t%ld->%0.3f S%0.3f D%d [%0.3f %0.3f] A%0.3f T%d\n", - CarItemNumber(xx->item), timeD, dist0, xx->speed, xx->direction, - xx->trvTrk.pos.x, xx->trvTrk.pos.y, xx->trvTrk.angle, - xx->trvTrk.trk?GetTrkIndex(xx->trvTrk.trk):-1)) - - if (xx->direction) { - FlipTraverseTrack(&trvTrk); - } - - TraverseTrack(&trvTrk, &dist1); - - if (dist1 > 0.0) { - if (dist1 > dist0) { - /*ErrorMessage( "%s no room: L%0.3f D%0.3f", CarItemNumber(xx->item), length, dist1 );*/ - StopTrain(train, ST_NoRoom); - return FALSE; - } else { - dist0 -= dist1; - LOG(log_trainMove, 1, (" %s STOP D%d [%0.3f %0.3f] A%0.3f D%0.3f\n", - CarItemNumber(xx->item), xx->direction, xx->trvTrk.pos.x, xx->trvTrk.pos.y, - xx->trvTrk.angle, dist0)) - } - - /*ErrorMessage( "%s stopped at End Of Track", CarItemNumber(xx->item) );*/ - if (xx->autoReverse) { - xx->direction = !xx->direction; - SetTrainDirection(train); - } else { - if (xx->speed > maxCouplingSpeed) { - car1 = train; - dir1 = xx->direction; - GetTrainLength2(&car1, &dir1); - CrashTrain(car1, dir1, &trvTrk, (long)xx->speed, FALSE); - return TRUE; - } else { - if (trvTrk.trk && trvTrk.trk->endCnt > 1) //Test for null track after Traverse - StopTrain(train, ST_OpenTurnout ); - else - StopTrain(train, ST_EndOfTrack); - return (FALSE); - } - } - } - - trvTrk = xx->trvTrk; - TraverseTrack2(&xx->trvTrk, xx->direction==0?dist0:-dist0); - car1 = train; - dir1 = 0; - GetTrainLength2(&car1, &dir1); - dir1 = 1-dir1; - measured = FALSE; - WALK_CARS_START(car1, xx1, dir1); - - if (CarItemIsLoco(xx1->item) && !measured) { - xx->distance += dist0; - measured = TRUE; - } - - WALK_CARS_END(car1, xx1, dir1); - - if (train == followTrain) { - if (followCenter.x != mainCenter.x || - followCenter.y != mainCenter.y) { - if (curTrainDlg->train == followTrain) { - curTrainDlg->followMe = FALSE; - ParamLoadControl(curTrainDlg->trainPGp, I_FOLLOW); - } - - followTrain = NULL; - } else if (OFF_FOLLOW(xx->trvTrk.pos, xx->trvTrk.pos)) { - MoveMainWindow(xx->trvTrk.pos, - NormalizeAngle(xx->trvTrk.angle+(xx->direction?180.0:0.0))); - followCenter = mainCenter; - } - } - - PlaceTrain(train, TRUE, TRUE); - return TRUE; + track_p train, + long timeD) +{ + DIST_T ips, dist0, dist1; + struct extraDataCar_t *xx, *xx1; + traverseTrack_t trvTrk; + DIST_T length; + track_p car1; + int dir1; + int measured; /* make sure the distance is only measured once per train */ + + if (train == NULL) { + return FALSE; + } + + xx = GET_EXTRA_DATA(train, T_CAR, extraDataCar_t); + + if (xx->speed <= 0) { + return FALSE; + } + + ips = ((xx->speed*5280.0*12.0)/(60.0*60.0*GetScaleRatio(GetLayoutCurScale()))); + dist0 = ips * timeD/1000.0; + length = GetTrainLength(train, xx->direction); + dist1 = length + dist0; + trvTrk = xx->trvTrk; + + if (trvTrk.trk == NULL) { + return FALSE; + } + + LOG(log_trainMove, 1, + ("moveTrain: %s t%ld->%0.3f S%0.3f D%d [%0.3f %0.3f] A%0.3f T%d\n", + CarItemNumber(xx->item), timeD, dist0, xx->speed, xx->direction, + xx->trvTrk.pos.x, xx->trvTrk.pos.y, xx->trvTrk.angle, + xx->trvTrk.trk?GetTrkIndex(xx->trvTrk.trk):-1)) + + if (xx->direction) { + FlipTraverseTrack(&trvTrk); + } + + TraverseTrack(&trvTrk, &dist1); + + if (dist1 > 0.0) { + if (dist1 > dist0) { + /*ErrorMessage( "%s no room: L%0.3f D%0.3f", CarItemNumber(xx->item), length, dist1 );*/ + StopTrain(train, ST_NoRoom); + return FALSE; + } else { + dist0 -= dist1; + LOG(log_trainMove, 1, (" %s STOP D%d [%0.3f %0.3f] A%0.3f D%0.3f\n", + CarItemNumber(xx->item), xx->direction, xx->trvTrk.pos.x, xx->trvTrk.pos.y, + xx->trvTrk.angle, dist0)) + } + + /*ErrorMessage( "%s stopped at End Of Track", CarItemNumber(xx->item) );*/ + if (xx->autoReverse) { + xx->direction = !xx->direction; + SetTrainDirection(train); + } else { + if (xx->speed > maxCouplingSpeed) { + car1 = train; + dir1 = xx->direction; + GetTrainLength2(&car1, &dir1); + CrashTrain(car1, dir1, &trvTrk, (long)xx->speed, FALSE); + return TRUE; + } else { + if (trvTrk.trk + && GetTrkEndPtCnt( trvTrk.trk ) > 1) { //Test for null track after Traverse + StopTrain(train, ST_OpenTurnout ); + } else { + StopTrain(train, ST_EndOfTrack); + } + return (FALSE); + } + } + } + + trvTrk = xx->trvTrk; + TraverseTrack2(&xx->trvTrk, xx->direction==0?dist0:-dist0); + car1 = train; + dir1 = 0; + GetTrainLength2(&car1, &dir1); + dir1 = 1-dir1; + measured = FALSE; + WALK_CARS_START(car1, xx1, dir1); + + if (CarItemIsLoco(xx1->item) && !measured) { + xx->distance += dist0; + measured = TRUE; + } + + WALK_CARS_END(car1, xx1, dir1); + + if (train == followTrain) { + if (followCenter.x != mainCenter.x || + followCenter.y != mainCenter.y) { + if (curTrainDlg->train == followTrain) { + curTrainDlg->followMe = FALSE; + ParamLoadControl(curTrainDlg->trainPGp, I_FOLLOW); + } + + followTrain = NULL; + } else if (OFF_FOLLOW(xx->trvTrk.pos, xx->trvTrk.pos)) { + MoveMainWindow(xx->trvTrk.pos, + NormalizeAngle(xx->trvTrk.angle+(xx->direction?180.0:0.0))); + followCenter = mainCenter; + } + } + + PlaceTrain(train, TRUE, TRUE); + return TRUE; } static BOOL_T MoveTrains(long timeD) { - BOOL_T trains_moved = FALSE; - track_p train; - struct extraDataCar_t * xx; + BOOL_T trains_moved = FALSE; + track_p train; + struct extraDataCar_t * xx; - for (train=NULL; TrackIterate(&train);) { - if (GetTrkType(train) != T_CAR) { - continue; - } + for (train=NULL; TrackIterate(&train);) { + if (GetTrkType(train) != T_CAR) { + continue; + } - xx = GET_EXTRA_DATA(train, T_CAR, extraDataCar_t); + xx = GET_EXTRA_DATA(train, T_CAR, extraDataCar_t); - if (!CarItemIsLoco(xx->item)) { - continue; - } + if (!CarItemIsLoco(xx->item)) { + continue; + } - if (!IsLocoMaster(xx)) { - continue; - } + if (!IsLocoMaster(xx)) { + continue; + } - if (xx->speed == 0) { - continue; - } + if (xx->speed == 0) { + continue; + } - trains_moved |= MoveTrain(train, timeD); - } + trains_moved |= MoveTrain(train, timeD); + } - ControllerDialogSyncAll(); - TempRedraw(); // MoveTrains - return trains_moved; + ControllerDialogSyncAll(); + TempRedraw(); // MoveTrains + return trains_moved; } static void MoveTrainsLoop(void) { - long time1, timeD; - static long time0 = 0; - trainsTimeoutPending = FALSE; + long time1, timeD; + static long time0 = 0; + trainsTimeoutPending = FALSE; - if (trainsState != TRAINS_RUN) { - time0 = 0; - return; - } + if (trainsState != TRAINS_RUN) { + time0 = 0; + return; + } - if (time0 == 0) { - time0 = wGetTimer(); - } + if (time0 == 0) { + time0 = wGetTimer(); + } - time1 = wGetTimer(); - timeD = time1-time0; - time0 = time1; + time1 = wGetTimer(); + timeD = time1-time0; + time0 = time1; - if (timeD > 1000) { - timeD = 1000; - } + if (timeD > 1000) { + timeD = 1000; + } - if (MoveTrains(timeD)) { - wAlarm(trainPause, MoveTrainsLoop); - trainsTimeoutPending = TRUE; - } else { - time0 = 0; - trainsState = TRAINS_IDLE; - TrainTimeEndPause(); - } + if (MoveTrains(timeD)) { + wAlarm(trainPause, MoveTrainsLoop); + trainsTimeoutPending = TRUE; + } else { + time0 = 0; + trainsState = TRAINS_IDLE; + TrainTimeEndPause(); + } } static void RestartTrains(void) { - if (trainsState != TRAINS_RUN) { - TrainTimeStartPause(); - } + if (trainsState != TRAINS_RUN) { + TrainTimeStartPause(); + } - trainsState = TRAINS_RUN; + trainsState = TRAINS_RUN; - if (!trainsTimeoutPending) { - MoveTrainsLoop(); - } + if (!trainsTimeoutPending) { + MoveTrainsLoop(); + } } static long trainTime0 = 0; static long playbackTrainPause = 0; static drawCmd_t trainMovieD = { - NULL, - &screenDrawFuncs, - 0, - 16.0, - 0, - {0,0}, {1,1}, - Pix2CoOrd, CoOrd2Pix + NULL, + &screenDrawFuncs, + 0, + 16.0, + 0, + {0,0}, {1,1}, + Pix2CoOrd, CoOrd2Pix }; static long trainMovieFrameDelay; static long trainMovieFrameNext; static void TrainTimeEndPause(void) { - if (recordF) { - if (trainTime0 != 0) { - long delay; - delay = wGetTimer()-trainTime0; + if (recordF) { + if (trainTime0 != 0) { + long delay; + delay = wGetTimer()-trainTime0; - if (delay > 0) { - fprintf(recordF, "TRAINPAUSE %ld\n", delay); - } - } + if (delay > 0) { + fprintf(recordF, "TRAINPAUSE %ld\n", delay); + } + } - trainTime0 = 0; - } + trainTime0 = 0; + } } static void TrainTimeStartPause(void) { - if (trainTime0 == 0) { - trainTime0 = wGetTimer(); - } + if (trainTime0 == 0) { + trainTime0 = wGetTimer(); + } } static BOOL_T TrainTimeDoPause(char * line) { - BOOL_T drawCarEnable2; - playbackTrainPause = atol(line); - LOG(log_trainPlayback, 1, ("DoPause %ld\n", playbackTrainPause)); - trainsState = TRAINS_RUN; - - if (trainMovieFrameDelay > 0) { - drawCarEnable2 = drawCarEnable; - drawCarEnable = TRUE; - TakeSnapshot(&trainMovieD); - drawCarEnable = drawCarEnable2; - LOG(log_trainPlayback, 1, ("SNAP 0\n")); - trainMovieFrameNext = trainMovieFrameDelay; - } - - /*MoveTrains();*/ - while (playbackTrainPause > 0) { - if (playbackTrainPause > trainPause) { - wPause(trainPause); - MoveTrains(trainPause); - playbackTrainPause -= trainPause; - - if (trainMovieFrameDelay > 0) { - trainMovieFrameNext -= trainPause; - } - } else { - wPause(playbackTrainPause); - MoveTrains(playbackTrainPause); - - if (trainMovieFrameDelay > 0) { - trainMovieFrameNext -= playbackTrainPause; - } - - playbackTrainPause = 0; - } - - if (trainMovieFrameDelay > 0 && - trainMovieFrameNext <= 0) { - drawCarEnable2 = drawCarEnable; - drawCarEnable = TRUE; - TakeSnapshot(&trainMovieD); - drawCarEnable = drawCarEnable2; - LOG(log_trainPlayback, 1, ("SNAP %ld\n", trainMovieFrameNext)); - trainMovieFrameNext = trainMovieFrameDelay; - } - } - - return TRUE; + BOOL_T drawCarEnable2; + playbackTrainPause = atol(line); + LOG(log_trainPlayback, 1, ("DoPause %ld\n", playbackTrainPause)); + trainsState = TRAINS_RUN; + + if (trainMovieFrameDelay > 0) { + drawCarEnable2 = drawCarEnable; + drawCarEnable = TRUE; + TakeSnapshot(&trainMovieD); + drawCarEnable = drawCarEnable2; + LOG(log_trainPlayback, 1, ("SNAP 0\n")); + trainMovieFrameNext = trainMovieFrameDelay; + } + + /*MoveTrains();*/ + while (playbackTrainPause > 0) { + if (playbackTrainPause > trainPause) { + wPause(trainPause); + MoveTrains(trainPause); + playbackTrainPause -= trainPause; + + if (trainMovieFrameDelay > 0) { + trainMovieFrameNext -= trainPause; + } + } else { + wPause(playbackTrainPause); + MoveTrains(playbackTrainPause); + + if (trainMovieFrameDelay > 0) { + trainMovieFrameNext -= playbackTrainPause; + } + + playbackTrainPause = 0; + } + + if (trainMovieFrameDelay > 0 && + trainMovieFrameNext <= 0) { + drawCarEnable2 = drawCarEnable; + drawCarEnable = TRUE; + TakeSnapshot(&trainMovieD); + drawCarEnable = drawCarEnable2; + LOG(log_trainPlayback, 1, ("SNAP %ld\n", trainMovieFrameNext)); + trainMovieFrameNext = trainMovieFrameDelay; + } + } + + return TRUE; } static BOOL_T TrainDoMovie(char * line) { - /* on/off, scale, orig, size */ - long fps; + /* on/off, scale, orig, size */ + long fps; - if (trainMovieD.dpi == 0) { - trainMovieD.dpi = mainD.dpi; - } + if (trainMovieD.dpi == 0) { + trainMovieD.dpi = mainD.dpi; + } - if (!GetArgs(line, "lfpp", &fps, &trainMovieD.scale, &trainMovieD.orig, - &trainMovieD.size)) { - return FALSE; - } + if (!GetArgs(line, "lfpp", &fps, &trainMovieD.scale, &trainMovieD.orig, + &trainMovieD.size)) { + return FALSE; + } - if (fps > 0) { - trainMovieFrameDelay = 1000/fps; - } else { - trainMovieFrameDelay = 0; - } + if (fps > 0) { + trainMovieFrameDelay = 1000/fps; + } else { + trainMovieFrameDelay = 0; + } - trainMovieFrameNext = 0; - return TRUE; + trainMovieFrameNext = 0; + return TRUE; } void AttachTrains(void) { - track_p car; - track_p loco; - struct extraDataCar_t * xx; - coOrd pos; - track_p trk; - ANGLE_T angle; - EPINX_T ep0, ep1; - int dir; - - for (car=NULL; TrackIterate(&car);) { - ClrTrkBits(car, TB_CARATTACHED); - - if (GetTrkType(car) != T_CAR) { - continue; - } - - xx = GET_EXTRA_DATA(car, T_CAR, extraDataCar_t); - ClrProcessed(xx); - } - - for (car=NULL; TrackIterate(&car);) { - if (GetTrkType(car) != T_CAR) { - continue; - } - - xx = GET_EXTRA_DATA(car, T_CAR, extraDataCar_t); - - if (IsProcessed(xx)) { - continue; - } - - loco = FindMasterLoco(car, NULL); - - if (loco != NULL) { - xx = GET_EXTRA_DATA(loco, T_CAR, extraDataCar_t); - } else { - loco = car; - } - - pos = xx->trvTrk.pos; - - if (xx->status == ST_Crashed) { - continue; - } - - TRK_ITERATE(trk) { - if (trk == xx->trvTrk.trk) { - break; - } - } - - if (trk!=NULL && !QueryTrack(trk, Q_ISTRACK)) { - trk = NULL; - } - if (trk==NULL || GetTrkDistance(trk,&pos)>trackGauge*2.0) { - trk = OnTrack2(&pos, FALSE, TRUE, FALSE, NULL); - } - - if (trk!=NULL) { - /*if ( trk == xx->trvTrk.trk ) - continue;*/ - angle = GetAngleAtPoint(trk, pos, &ep0, &ep1); - - if (NormalizeAngle(xx->trvTrk.angle-angle+90) > 180) { - angle = NormalizeAngle(angle+180); - } - - PlaceTrainInit(loco, trk, pos, angle, TRUE); - } else { - PlaceTrainInit(loco, NULL, xx->trvTrk.pos, xx->trvTrk.angle, FALSE); - } - - dir = 0; - WALK_CARS_START(loco, xx, dir) - WALK_CARS_END(loco, xx, dir) - dir = 1-dir; - WALK_CARS_START(loco, xx, dir) - SetProcessed(xx); - - if (xx->trvTrk.trk) { - SetTrkBits(xx->trvTrk.trk, TB_CARATTACHED); - xx->status = ST_StopManual; - } else { - xx->status = ST_NotOnTrack; - } - - WALK_CARS_END(loco, xx, dir) - } - - for (car=NULL; TrackIterate(&car);) { - if (GetTrkType(car) != T_CAR) { - continue; - } - - xx = GET_EXTRA_DATA(car, T_CAR, extraDataCar_t); - ClrProcessed(xx); - } + track_p car; + track_p loco; + struct extraDataCar_t * xx; + coOrd pos; + track_p trk; + ANGLE_T angle; + EPINX_T ep0, ep1; + int dir; + + for (car=NULL; TrackIterate(&car);) { + ClrTrkBits(car, TB_CARATTACHED); + + if (GetTrkType(car) != T_CAR) { + continue; + } + + xx = GET_EXTRA_DATA(car, T_CAR, extraDataCar_t); + ClrProcessed(xx); + } + + for (car=NULL; TrackIterate(&car);) { + if (GetTrkType(car) != T_CAR) { + continue; + } + + xx = GET_EXTRA_DATA(car, T_CAR, extraDataCar_t); + + if (IsProcessed(xx)) { + continue; + } + + loco = FindMasterLoco(car, NULL); + + if (loco != NULL) { + xx = GET_EXTRA_DATA(loco, T_CAR, extraDataCar_t); + } else { + loco = car; + } + + pos = xx->trvTrk.pos; + + if (xx->status == ST_Crashed) { + continue; + } + + TRK_ITERATE(trk) { + if (trk == xx->trvTrk.trk) { + break; + } + } + + if (trk!=NULL && !QueryTrack(trk, Q_ISTRACK)) { + trk = NULL; + } + if (trk==NULL || GetTrkDistance(trk,&pos)>trackGauge*2.0) { + // Suppress moving pos to turnout endPt + onTrackInSplit = TRUE; + trk = OnTrack2(&pos, FALSE, TRUE, FALSE, NULL); + onTrackInSplit = FALSE; + } + + if (trk!=NULL) { + /*if ( trk == xx->trvTrk.trk ) + continue;*/ + angle = GetAngleAtPoint(trk, pos, &ep0, &ep1); + + if (NormalizeAngle(xx->trvTrk.angle-angle+90) > 180) { + angle = NormalizeAngle(angle+180); + } + + PlaceTrainInit(loco, trk, pos, angle, TRUE); + } else { + PlaceTrainInit(loco, NULL, xx->trvTrk.pos, xx->trvTrk.angle, FALSE); + } + + dir = 0; + WALK_CARS_START(loco, xx, dir) + WALK_CARS_END(loco, xx, dir) + dir = 1-dir; + WALK_CARS_START(loco, xx, dir) + SetProcessed(xx); + + if (xx->trvTrk.trk) { + SetTrkBits(xx->trvTrk.trk, TB_CARATTACHED); + xx->status = ST_StopManual; + } else { + xx->status = ST_NotOnTrack; + } + + WALK_CARS_END(loco, xx, dir) + } + + for (car=NULL; TrackIterate(&car);) { + if (GetTrkType(car) != T_CAR) { + continue; + } + + xx = GET_EXTRA_DATA(car, T_CAR, extraDataCar_t); + ClrProcessed(xx); + } } static void UpdateTrainAttachment(void) { - track_p trk; - struct extraDataCar_t * xx; + track_p trk; + struct extraDataCar_t * xx; - for (trk=NULL; TrackIterate(&trk);) { - ClrTrkBits(trk, TB_CARATTACHED); - } + for (trk=NULL; TrackIterate(&trk);) { + ClrTrkBits(trk, TB_CARATTACHED); + } - for (trk=NULL; TrackIterate(&trk);) { - if (GetTrkType(trk) == T_CAR) { - xx = GET_EXTRA_DATA(trk, T_CAR, extraDataCar_t); + for (trk=NULL; TrackIterate(&trk);) { + if (GetTrkType(trk) == T_CAR) { + xx = GET_EXTRA_DATA(trk, T_CAR, extraDataCar_t); - if (xx->trvTrk.trk != NULL) { - SetTrkBits(xx->trvTrk.trk, TB_CARATTACHED); - } - } - } + if (xx->trvTrk.trk != NULL) { + SetTrkBits(xx->trvTrk.trk, TB_CARATTACHED); + } + } + } } static BOOL_T TrainOnMovableTrack( - track_p trk, - track_p *trainR) + track_p trk, + track_p *trainR) { - track_p train; - struct extraDataCar_t * xx; - int dir; + track_p train; + struct extraDataCar_t * xx; + int dir; - for (train=NULL; TrackIterate(&train);) { - if (GetTrkType(train) != T_CAR) { - continue; - } + for (train=NULL; TrackIterate(&train);) { + if (GetTrkType(train) != T_CAR) { + continue; + } - xx = GET_EXTRA_DATA(train, T_CAR, extraDataCar_t); + xx = GET_EXTRA_DATA(train, T_CAR, extraDataCar_t); - if (IsOnTrack(xx)) { - if (xx->trvTrk.trk == trk) { - break; - } - } - } + if (IsOnTrack(xx)) { + if (xx->trvTrk.trk == trk) { + break; + } + } + } - *trainR = train; + *trainR = train; - if (train == NULL) { - return TRUE; - } + if (train == NULL) { + return TRUE; + } - dir = 0; - WALK_CARS_START(train, xx, dir) - WALK_CARS_END(train, xx, dir) - dir = 1-dir; - WALK_CARS_START(train, xx, dir) + dir = 0; + WALK_CARS_START(train, xx, dir) + WALK_CARS_END(train, xx, dir) + dir = 1-dir; + WALK_CARS_START(train, xx, dir) - if (xx->trvTrk.trk != trk) { - ErrorMessage(MSG_CANT_MOVE_UNDER_TRAIN); - return FALSE; - } + if (xx->trvTrk.trk != trk) { + ErrorMessage(MSG_CANT_MOVE_UNDER_TRAIN); + return FALSE; + } - WALK_CARS_END(train, xx, dir) - train = FindMasterLoco(train, NULL); + WALK_CARS_END(train, xx, dir) + train = FindMasterLoco(train, NULL); - if (train != NULL) { - *trainR = train; - } + if (train != NULL) { + *trainR = train; + } - return TRUE; + return TRUE; } /* @@ -2483,363 +2575,384 @@ static BOOL_T TrainOnMovableTrack( #define DO_STOP (7) #define DO_PENCILS_ON (8) #define DO_PENCILS_OFF (9) +#define DO_DESCRIBE (10) static track_p trainFuncCar; static coOrd trainFuncPos; static wButton_p trainPauseB; + static STATUS_T CmdTrain(wAction_t action, coOrd pos) { - track_p trk0, trk1; - static track_p currCar; - coOrd pos0, pos1; - static coOrd delta; - ANGLE_T angle1; - EPINX_T ep0, ep1; - int dir; - struct extraDataCar_t * xx=NULL; - wWinPix_t w, h; - - switch (action) { - case C_START: - /*UndoStart( "Trains", "Trains" );*/ - UndoSuspend(); - programMode = MODE_TRAIN; - drawCarEnable = FALSE; - doDrawTurnoutPosition = 1; - DoChangeNotification(CHANGE_PARAMS|CHANGE_TOOLBAR); - - if (CarAvailableCount() <= 0) { - if (NoticeMessage(MSG_NO_CARS, _("Yes"), _("No")) > 0) { - DoCarDlg(NULL); - DoChangeNotification(CHANGE_PARAMS); - } - } - SetAllTrackSelect( FALSE ); - EnableCommands(); - - if (curTrainDlg == NULL) { - curTrainDlg = CreateTrainControlDlg(); - } - - curTrainDlg->train = NULL; - wListClear((wList_p)curTrainDlg->trainPGp->paramPtr[I_LIST].control); - Dtrain.state = 0; - trk0 = NULL; - tempSegs_da.cnt = 0; - DYNARR_SET(trkSeg_t, tempSegs_da, 8); - RestartTrains(); - wButtonSetLabel(trainPauseB, (char*)goB); - trainTime0 = 0; - AttachTrains(); - curTrainDlg->train = NULL; - curTrainDlg->speed = -1; - wDrawClear((wDraw_p)curTrainDlg->trainPGp->paramPtr[I_SLIDER].control); - LocoListInit(); - ControllerDialogSync(curTrainDlg); - wShow(curTrainDlg->win); - wControlShow((wControl_p)newcarB, (toolbarSet&(1<<BG_TRAIN))); - currCarItemPtr = NULL; - TempRedraw(); // CmdTrain C_START - return C_CONTINUE; - - case C_TEXT: - if (Dtrain.state == 0) { - return C_CONTINUE; - } else { - return C_CONTINUE; - } - - case C_DOWN: - /*trainEnable = FALSE;*/ - InfoMessage(""); - - if (trainsState == TRAINS_RUN) { - trainsState = TRAINS_PAUSE; - TrainTimeEndPause(); - } - - pos0 = pos; - - if (currCarItemPtr != NULL) { - DIST_T dist; - currCar = NewCar(-1, currCarItemPtr, zero, 0.0); - CarItemUpdate(currCarItemPtr); - HotBarCancel(); - - if (currCar == NULL) { - LOG1(log_error, ("Train: currCar became NULL 1\n")) - return C_CONTINUE; - } - - xx = GET_EXTRA_DATA(currCar, T_CAR, extraDataCar_t); - xx->pencils = FALSE; - dist = CarItemCoupledLength(xx->item)/2.0; - Translate(&pos, xx->trvTrk.pos, xx->trvTrk.angle, dist); - SetTrkEndPoint(currCar, 0, pos, xx->trvTrk.angle); - Translate(&pos, xx->trvTrk.pos, xx->trvTrk.angle+180.0, dist); - SetTrkEndPoint(currCar, 1, pos, NormalizeAngle(xx->trvTrk.angle+180.0)); - /*xx->state |= (xx->item->options&CAR_DESC_BITS);*/ - ClrLocoMaster(xx); - - if (CarItemIsLoco(xx->item)) { - SetLocoMaster(xx); - LocoListChangeEntry(NULL, currCar); - } - - if ((trk0 = OnTrack(&pos0, FALSE, TRUE))) { - xx->trvTrk.angle = GetAngleAtPoint(trk0, pos0, &ep0, &ep1); - - if (NormalizeAngle(FindAngle(pos, pos0) - xx->trvTrk.angle) > 180.0) { - xx->trvTrk.angle = NormalizeAngle(xx->trvTrk.angle + 180); - } - - xx->status = ST_StopManual; - } else { - xx->trvTrk.angle = 90; - } - - PlaceTrainInit(currCar, trk0, pos0, xx->trvTrk.angle, - (MyGetKeyState()&WKEY_SHIFT) == 0); - /*DrawCars( &tempD, currCar, TRUE );*/ - } else { - currCar = FindCar(&pos); - delta.x = pos.x - pos0.x; - delta.y = pos.y - pos0.y; - - if (logTable(log_trainMove).level >= 1) { - if (currCar) { - xx = GET_EXTRA_DATA(currCar, T_CAR, extraDataCar_t); - LogPrintf("selected %s\n", CarItemNumber(xx->item)); - - for (dir=0; dir<2; dir++) { - int dir1 = dir; - track_p car1 = currCar; - struct extraDataCar_t * xx1 = GET_EXTRA_DATA(car1, T_CAR, extraDataCar_t); - LogPrintf("dir=%d\n", dir1); - WALK_CARS_START(car1, xx1, dir1) - LogPrintf(" %s [%0.3f,%d]\n", CarItemNumber(xx1->item), xx1->trvTrk.angle, - dir1); - WALK_CARS_END(car1, xx1, dir1) - } - } - } - } - - if (currCar == NULL) { - return C_CONTINUE; - } - - trk0 = FindMasterLoco(currCar, NULL); - - if (trk0) { - SetCurTrain(trk0); - } - - return C_CONTINUE; - - case C_MOVE: - if (currCar == NULL) { - return C_CONTINUE; - } - - pos.x += delta.x; - pos.y += delta.y; - pos0 = pos; - xx = GET_EXTRA_DATA(currCar, T_CAR, extraDataCar_t); - trk0 = OnTrack(&pos0, FALSE, TRUE); - - if (/*currCarItemPtr != NULL &&*/ trk0) { - angle1 = GetAngleAtPoint(trk0, pos0, &ep0, &ep1); - - if (currCarItemPtr != NULL) { - if (NormalizeAngle(FindAngle(pos, pos0) - angle1) > 180.0) { - angle1 = NormalizeAngle(angle1 + 180); - } - } else { - if (NormalizeAngle(xx->trvTrk.angle - angle1 + 90.0) > 180.0) { - angle1 = NormalizeAngle(angle1 + 180); - } - } - - xx->trvTrk.angle = angle1; - } - - tempSegs_da.cnt = 1; - PlaceTrainInit(currCar, trk0, pos0, xx->trvTrk.angle, - (MyGetKeyState()&WKEY_SHIFT) == 0); - ControllerDialogSync(curTrainDlg); - return C_CONTINUE; - - case C_UP: - if (currCar != NULL) { - trk0 = FindMasterLoco(currCar, NULL); - - if (trk0) { - xx = GET_EXTRA_DATA(trk0, T_CAR, extraDataCar_t); - - if (!IsOnTrack(xx) || xx->speed <= 0) { - StopTrain(trk0, ST_StopManual); - } - } - - Dtrain.state = 1; - ControllerDialogSync(curTrainDlg); - } - - InfoSubstituteControls(NULL, NULL); - currCar = trk0 = NULL; - currCarItemPtr = NULL; - - /*trainEnable = TRUE;*/ - if (trainsState == TRAINS_PAUSE) { - RestartTrains(); - } - - return C_CONTINUE; - - case C_LCLICK: - if (MyGetKeyState() & WKEY_SHIFT) { - pos0 = pos; - programMode = MODE_DESIGN; - - if ((trk0=OnTrack(&pos,FALSE,TRUE)) && - QueryTrack(trk0, Q_CAN_NEXT_POSITION) && - TrainOnMovableTrack(trk0, &trk1)) { - if (trk1) { - xx = GET_EXTRA_DATA(trk1, T_CAR, extraDataCar_t); - pos1 = xx->trvTrk.pos; - angle1 = xx->trvTrk.angle; - } else { - pos1 = pos0; - angle1 = 0; - } - - AdvancePositionIndicator(trk0, pos0, &pos1, &angle1); - - if (trk1) { - xx->trvTrk.pos = pos1; - xx->trvTrk.angle = angle1; - PlaceTrain(trk1, FALSE, TRUE); - } - } - - programMode = MODE_TRAIN; - trk0 = NULL; - MainRedraw(); //CmdTrain: Make sure track is redrawn after switch thrown - } else { - trk0 = FindCar(&pos); - - if (trk0 == NULL) { - return C_CONTINUE; - } - - trk0 = FindMasterLoco(trk0, NULL); - - if (trk0 == NULL) { - return C_CONTINUE; - } - - SetCurTrain(trk0); - } - - return C_CONTINUE; - - case C_RCLICK: - trainFuncPos = pos; - trainFuncCar = FindCar(&pos); - - if (trainFuncCar == NULL || - GetTrkType(trainFuncCar) != T_CAR) { - return C_CONTINUE; - } - - xx = GET_EXTRA_DATA(trainFuncCar, T_CAR, extraDataCar_t); - if (xx->pencils) { - wMenuPushEnable(trainPopupMI[DO_PENCILS_OFF], TRUE); - wMenuPushEnable(trainPopupMI[DO_PENCILS_ON], FALSE); - } else { - wMenuPushEnable(trainPopupMI[DO_PENCILS_OFF], FALSE); - wMenuPushEnable(trainPopupMI[DO_PENCILS_ON], TRUE); - } - - trk0 = FindMasterLoco(trainFuncCar,NULL); - dir = IsAligned(xx->trvTrk.angle, FindAngle(xx->trvTrk.pos, - trainFuncPos)) ? 0 : 1; - wMenuPushEnable(trainPopupMI[DO_UNCOUPLE], GetTrkEndTrk(trainFuncCar, - dir)!=NULL); - wMenuPushEnable(trainPopupMI[DO_MUMASTER], CarItemIsLoco(xx->item) && - !IsLocoMaster(xx)); - - if (trk0) { - xx = GET_EXTRA_DATA(trk0, T_CAR, extraDataCar_t); - } - - wMenuPushEnable(trainPopupMI[DO_CHANGEDIR], trk0!=NULL); - wMenuPushEnable(trainPopupMI[DO_STOP], trk0!=NULL && xx->speed>0); - /*trainEnable = FALSE;*/ - trk0 = FindMasterLoco(trainFuncCar, NULL); - - if (trk0) { - SetCurTrain(trk0); - } - - if (!inPlayback) { - wMenuPopupShow(trainPopupM); - } - - return C_CONTINUE; - - case C_REDRAW: - wDrawSaveImage(mainD.d); - DrawAllCars(); - wWinGetSize(mainW, &w, &h); - w -= wControlGetPosX(newCarControls[0]) + 4; - - if (w > 20) { - wListSetSize((wList_p)newCarControls[0], w, - wControlGetHeight(newCarControls[0])); - } - - return C_CONTINUE; - - case C_CANCEL: - /*trainEnable = FALSE;*/ - trainsState = TRAINS_STOP; - TrainTimeEndPause(); - LOG(log_trainMove, 1, ("Train Cancel\n")) - Dtrain.state = 0; - doDrawTurnoutPosition = 0; - drawCarEnable = TRUE; - programMode = MODE_DESIGN; - UpdateTrainAttachment(); - UndoResume(); - DoChangeNotification(CHANGE_PARAMS|CHANGE_TOOLBAR); - - if (curTrainDlg->win) { - wHide(curTrainDlg->win); - } - - MainRedraw(); // CmdTrain: Exit - curTrainDlg->train = NULL; - return C_CONTINUE; - - case C_CONFIRM: - - /*trainEnable = FALSE;*/ - if (trainsState != TRAINS_STOP) { - trainsState = TRAINS_STOP; - wButtonSetLabel(trainPauseB, (char*)stopI); - TrainTimeEndPause(); - } - - currCar = NULL; - currCarItemPtr = NULL; - HotBarCancel(); - InfoSubstituteControls(NULL, NULL); - return C_TERMINATE; - } - - return C_CONTINUE; + static track_p trk0, trk1; + static track_p currCar; + coOrd pos0, pos1; + static coOrd delta; + ANGLE_T angle1; + EPINX_T ep0, ep1; + int dir; + struct extraDataCar_t * xx=NULL; + wWinPix_t w, h; + char msg[STR_SIZE]; + + switch (action) { + case C_START: + /*UndoStart( "Trains", "Trains" );*/ + UndoSuspend(); + programMode = MODE_TRAIN; + drawCarEnable = FALSE; + doDrawTurnoutPosition = 1; + DoChangeNotification(CHANGE_PARAMS|CHANGE_TOOLBAR); + + if (CarAvailableCount() <= 0) { + if (NoticeMessage(MSG_NO_CARS, _("Yes"), _("No")) > 0) { + DoCarDlg(NULL); + DoChangeNotification(CHANGE_PARAMS); + } + } + SetAllTrackSelect( FALSE ); + EnableCommands(); + + if (curTrainDlg == NULL) { + curTrainDlg = CreateTrainControlDlg(); + } + + curTrainDlg->train = NULL; + wListClear((wList_p)curTrainDlg->trainPGp->paramPtr[I_LIST].control); + Dtrain.state = 0; + trk0 = NULL; + trainHighlighted = NULL; + DYNARR_SET(trkSeg_t, tempSegs_da, 8); + RestartTrains(); + wButtonSetLabel(trainPauseB, (char*)goB); + trainTime0 = 0; + AttachTrains(); + curTrainDlg->train = NULL; + curTrainDlg->speed = -1; + wDrawClear((wDraw_p)curTrainDlg->trainPGp->paramPtr[I_SLIDER].control); + LocoListInit(); + ControllerDialogSync(curTrainDlg); + wShow(curTrainDlg->win); + wControlShow((wControl_p)newcarB, (toolbarSet&(1<<BG_TRAIN))); + currCarItemPtr = NULL; + TempRedraw(); // CmdTrain C_START + return C_CONTINUE; + + case wActionMove: + + trainHighlighted = FindCar(&pos); + + return C_CONTINUE; + break; + + + case C_TEXT: + return C_CONTINUE; + + case C_DOWN: + /*trainEnable = FALSE;*/ + InfoMessage(""); + + if (trainsState == TRAINS_RUN) { + trainsState = TRAINS_PAUSE; + TrainTimeEndPause(); + } + + pos0 = pos; + + if (currCarItemPtr != NULL) { + DIST_T dist; + currCar = NewCar(-1, currCarItemPtr, zero, 0.0); + CarItemUpdate(currCarItemPtr); + HotBarCancel(); + + CHECK(currCar != NULL); + + xx = GET_EXTRA_DATA(currCar, T_CAR, extraDataCar_t); + xx->pencils = FALSE; + dist = CarItemCoupledLength(xx->item)/2.0; + Translate(&pos, xx->trvTrk.pos, xx->trvTrk.angle, dist); + SetTrkEndPoint(currCar, 0, pos, xx->trvTrk.angle); + Translate(&pos, xx->trvTrk.pos, xx->trvTrk.angle+180.0, dist); + SetTrkEndPoint(currCar, 1, pos, NormalizeAngle(xx->trvTrk.angle+180.0)); + /*xx->state |= (xx->item->options&CAR_DESC_BITS);*/ + ClrLocoMaster(xx); + + if (CarItemIsLoco(xx->item)) { + SetLocoMaster(xx); + LocoListChangeEntry(NULL, currCar); + } + + if ((trk0 = OnTrack(&pos0, FALSE, TRUE))) { + xx->trvTrk.angle = GetAngleAtPoint(trk0, pos0, &ep0, &ep1); + + if (NormalizeAngle(FindAngle(pos, pos0) - xx->trvTrk.angle) > 180.0) { + xx->trvTrk.angle = NormalizeAngle(xx->trvTrk.angle + 180); + } + + xx->status = ST_StopManual; + } else { + xx->trvTrk.angle = 90; + } + + PlaceTrainInit(currCar, trk0, pos0, xx->trvTrk.angle, + (MyGetKeyState()&WKEY_SHIFT) == 0); + /*DrawCars( &tempD, currCar, TRUE );*/ + } else { + currCar = FindCar(&pos); + delta.x = pos.x - pos0.x; + delta.y = pos.y - pos0.y; + + if (logTable(log_trainMove).level >= 1) { + if (currCar) { + xx = GET_EXTRA_DATA(currCar, T_CAR, extraDataCar_t); + LogPrintf("selected %s\n", CarItemNumber(xx->item)); + + for (dir=0; dir<2; dir++) { + int dir1 = dir; + track_p car1 = currCar; + struct extraDataCar_t * xx1 = GET_EXTRA_DATA(car1, T_CAR, extraDataCar_t); + LogPrintf("dir=%d\n", dir1); + WALK_CARS_START(car1, xx1, dir1) + LogPrintf(" %s [%0.3f,%d]\n", CarItemNumber(xx1->item), xx1->trvTrk.angle, + dir1); + WALK_CARS_END(car1, xx1, dir1) + } + } + } + } + + if (currCar == NULL) { + return C_CONTINUE; + } + + trainHighlighted = currCar; + + trk0 = FindMasterLoco(currCar, NULL); + + if (trk0) { + SetCurTrain(trk0); + } + + return C_CONTINUE; + + case C_MOVE: + if (currCar == NULL) { + return C_CONTINUE; + } + + pos.x += delta.x; + pos.y += delta.y; + pos0 = pos; + xx = GET_EXTRA_DATA(currCar, T_CAR, extraDataCar_t); + trk0 = OnTrack(&pos0, FALSE, TRUE); + + if (/*currCarItemPtr != NULL &&*/ trk0) { + angle1 = GetAngleAtPoint(trk0, pos0, &ep0, &ep1); + + if (currCarItemPtr != NULL) { + if (NormalizeAngle(FindAngle(pos, pos0) - angle1) > 180.0) { + angle1 = NormalizeAngle(angle1 + 180); + } + } else { + if (NormalizeAngle(xx->trvTrk.angle - angle1 + 90.0) > 180.0) { + angle1 = NormalizeAngle(angle1 + 180); + } + } + + xx->trvTrk.angle = angle1; + } + + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); + PlaceTrainInit(currCar, trk0, pos0, xx->trvTrk.angle, + (MyGetKeyState()&WKEY_SHIFT) == 0); + ControllerDialogSync(curTrainDlg); + return C_CONTINUE; + + case C_UP: + if (currCar != NULL) { + trk0 = FindMasterLoco(currCar, NULL); + + if (trk0) { + xx = GET_EXTRA_DATA(trk0, T_CAR, extraDataCar_t); + + if (!IsOnTrack(xx) || xx->speed <= 0) { + StopTrain(trk0, ST_StopManual); + } + } + + Dtrain.state = 1; + ControllerDialogSync(curTrainDlg); + } + + InfoSubstituteControls(NULL, NULL); + currCar = trk0 = NULL; + currCarItemPtr = NULL; + trainHighlighted = NULL; + + /*trainEnable = TRUE;*/ + if (trainsState == TRAINS_PAUSE) { + RestartTrains(); + } + + return C_CONTINUE; + + case C_LCLICK: + if (MyGetKeyState() & WKEY_SHIFT) { + pos0 = pos; + programMode = MODE_DESIGN; + + if ((trk0=OnTrack(&pos,FALSE,TRUE)) && + QueryTrack(trk0, Q_CAN_NEXT_POSITION) && + TrainOnMovableTrack(trk0, &trk1)) { + if (trk1) { + xx = GET_EXTRA_DATA(trk1, T_CAR, extraDataCar_t); + pos1 = xx->trvTrk.pos; + angle1 = xx->trvTrk.angle; + } else { + pos1 = pos0; + angle1 = 0; + } + + AdvancePositionIndicator(trk0, pos0, &pos1, &angle1); + + if (trk1) { + xx->trvTrk.pos = pos1; + xx->trvTrk.angle = angle1; + PlaceTrain(trk1, FALSE, TRUE); + } + } + + programMode = MODE_TRAIN; + trk0 = NULL; + MainRedraw(); //CmdTrain: Make sure track is redrawn after switch thrown + } else { + trk0 = FindCar(&pos); + + if (trk0 == NULL) { + return C_CONTINUE; + } + + trainHighlighted = trk0; + DescribeTrack( trk0, msg, sizeof msg ); + InfoMessage( msg ); + + trk0 = FindMasterLoco(trk0, NULL); + + if (trk0 == NULL) { + return C_CONTINUE; + } + + SetCurTrain(trk0); + } + + return C_CONTINUE; + + case C_RCLICK: + trainFuncPos = pos; + trainFuncCar = FindCar(&pos); + + if (trainFuncCar == NULL || + GetTrkType(trainFuncCar) != T_CAR) { + return C_CONTINUE; + } + + xx = GET_EXTRA_DATA(trainFuncCar, T_CAR, extraDataCar_t); + if (xx->pencils) { +// wMenuPushEnable(trainPopupMI[DO_PENCILS_OFF], TRUE); +// wMenuPushEnable(trainPopupMI[DO_PENCILS_ON], FALSE); + } else { +// wMenuPushEnable(trainPopupMI[DO_PENCILS_OFF], FALSE); +// wMenuPushEnable(trainPopupMI[DO_PENCILS_ON], TRUE); + } + + trk0 = FindMasterLoco(trainFuncCar,NULL); + dir = IsAligned(xx->trvTrk.angle, FindAngle(xx->trvTrk.pos, + trainFuncPos)) ? 0 : 1; + wMenuPushEnable(trainPopupMI[DO_UNCOUPLE], GetTrkEndTrk(trainFuncCar, + dir)!=NULL); + wMenuPushEnable(trainPopupMI[DO_MUMASTER], CarItemIsLoco(xx->item) && + !IsLocoMaster(xx)); + + if (trk0) { + xx = GET_EXTRA_DATA(trk0, T_CAR, extraDataCar_t); + } + + wMenuPushEnable(trainPopupMI[DO_CHANGEDIR], trk0!=NULL); + wMenuPushEnable(trainPopupMI[DO_STOP], trk0!=NULL && xx->speed>0); + /*trainEnable = FALSE;*/ + trainHighlighted = trk0; + trk0 = FindMasterLoco(trainFuncCar, NULL); + + if (trk0) { + SetCurTrain(trk0); + } + + if (!inPlayback) { + wMenuPopupShow(trainPopupM); + } + + return C_CONTINUE; + + case C_REDRAW: + wDrawSaveImage(mainD.d); + DrawAllCars(trainHighlighted); + + wWinGetSize(mainW, &w, &h); + w -= wControlGetPosX(newCarControls[0]) + 4; + + if (w > 20) { + wListSetSize((wList_p)newCarControls[0], w, + wControlGetHeight(newCarControls[0])); + } + + + + return C_CONTINUE; + + case C_CANCEL: + /*trainEnable = FALSE;*/ + trainsState = TRAINS_STOP; + TrainTimeEndPause(); + LOG(log_trainMove, 1, ("Train Cancel\n")) + Dtrain.state = 0; + doDrawTurnoutPosition = 0; + drawCarEnable = TRUE; + programMode = MODE_DESIGN; + UpdateTrainAttachment(); + UndoResume(); + DoChangeNotification(CHANGE_PARAMS|CHANGE_TOOLBAR); + + if (curTrainDlg && curTrainDlg->win) { + wHide(curTrainDlg->win); + } + + MainRedraw(); // CmdTrain: Exit + if ( curTrainDlg ) { + curTrainDlg->train = NULL; + } + trk0 = NULL; + trainHighlighted = NULL; + return C_CONTINUE; + + case C_CONFIRM: + + /*trainEnable = FALSE;*/ + if (trainsState != TRAINS_STOP) { + trainsState = TRAINS_STOP; + wButtonSetLabel(trainPauseB, (char*)stopI); + TrainTimeEndPause(); + } + + currCar = NULL; + currCarItemPtr = NULL; + HotBarCancel(); + InfoSubstituteControls(NULL, NULL); + trk0 = NULL; + trainHighlighted = NULL; + return C_TERMINATE; + } + + return C_CONTINUE; } @@ -2847,298 +2960,290 @@ static STATUS_T CmdTrain(wAction_t action, coOrd pos) * */ -STATUS_T CmdCarDescAction( - wAction_t action, - coOrd pos) +static STATUS_T CmdCarDescAction( + wAction_t action, + coOrd pos) { - return CmdTrain(action, pos); + return CmdTrain(action, pos); } -#include "bitmaps/train.xpm" -#include "bitmaps/exit.xpm" -#include "bitmaps/new-car.xpm" +#include "bitmaps/train.xpm3" +#include "bitmaps/exit.xpm3" +#include "bitmaps/new-car.xpm3" +#include "bitmaps/go.xpm3" +#include "bitmaps/stop.xpm3" + #include "bitmaps/zero.xpm" -#include "bitmaps/go.xpm" -#include "bitmaps/stop.xpm" #include "bitmaps/greendot.xpm" #include "bitmaps/reddot.xpm" static void CmdTrainStopGo(void * unused) { - wIcon_p icon; - - if (trainsState == TRAINS_STOP) { - icon = goB; - RestartTrains(); - } else { - trainsState = TRAINS_STOP; - icon = stopB; - TrainTimeEndPause(); - } + wIcon_p icon; + + if (trainsState == TRAINS_STOP) { + icon = goB; + RestartTrains(); + } else { + trainsState = TRAINS_STOP; + icon = stopB; + TrainTimeEndPause(); + } - ControllerDialogSync(curTrainDlg); - wButtonSetLabel(trainPauseB, (char*)icon); + ControllerDialogSync(curTrainDlg); + wButtonSetLabel(trainPauseB, (char*)icon); - if (recordF) { - fprintf(recordF, "TRAINSTOPGO %s\n", trainsState==TRAINS_STOP?"STOP":"GO"); - } + if (recordF) { + fprintf(recordF, "TRAINSTOPGO %s\n", trainsState==TRAINS_STOP?"STOP":"GO"); + } } static BOOL_T TrainStopGoPlayback(char * line) { - while (*line && isspace((unsigned char)*line)) { - line++; - } + while (*line && isspace((unsigned char)*line)) { + line++; + } - if ((strcasecmp(line, "STOP") == 0) != (trainsState == TRAINS_STOP)) { - CmdTrainStopGo(NULL); - } + if ((strcasecmp(line, "STOP") == 0) != (trainsState == TRAINS_STOP)) { + CmdTrainStopGo(NULL); + } - return TRUE; + return TRUE; } static void CmdTrainExit(void * unused) { - Reset(); - InfoSubstituteControls(NULL, NULL); + Reset(); + InfoSubstituteControls(NULL, NULL); } static void TrainFunc( - void * action) -{ - struct extraDataCar_t * xx, *xx1; - ANGLE_T angle; - int dir; - track_p loco; - track_p temp0, temp1; - coOrd pos0, pos1; - ANGLE_T angle0, angle1; - EPINX_T ep0=-1, ep1=-1; - - if (trainFuncCar == NULL) { - fprintf(stderr, "trainFunc: trainFuncCar==NULL\n"); - return; - } - - xx = GET_EXTRA_DATA(trainFuncCar, T_CAR, extraDataCar_t); - angle = FindAngle(xx->trvTrk.pos, trainFuncPos); - angle = NormalizeAngle(angle-xx->trvTrk.angle); - dir = (angle>90&&angle<270); - - switch (VP2L(action)) { - case DO_UNCOUPLE: - if (GetTrkEndTrk(trainFuncCar,dir)) { - UncoupleCars(trainFuncCar, GetTrkEndTrk(trainFuncCar,dir)); - } - - break; - - case DO_PENCILS_ON: - xx->pencils = TRUE; - break; - - case DO_PENCILS_OFF: - xx->pencils = FALSE; - break; - - case DO_FLIPCAR: - temp0 = GetTrkEndTrk(trainFuncCar,0); - pos0 = GetTrkEndPos(trainFuncCar,0); - angle0 = GetTrkEndAngle(trainFuncCar,0); - temp1 = GetTrkEndTrk(trainFuncCar,1); - pos1 = GetTrkEndPos(trainFuncCar,1); - angle1 = GetTrkEndAngle(trainFuncCar,1); - - if (temp0) { - ep0 = GetEndPtConnectedToMe(temp0,trainFuncCar); - trainFuncCar->endPt[0].track = NULL; - temp0->endPt[ep0].track = NULL; - } - - if (temp1) { - ep1 = GetEndPtConnectedToMe(temp1,trainFuncCar); - trainFuncCar->endPt[1].track = NULL; - temp1->endPt[ep1].track = NULL; - } - - xx->direction = !xx->direction; - FlipTraverseTrack(&xx->trvTrk); - SetTrkEndPoint(trainFuncCar, 0, pos1, angle1); - SetTrkEndPoint(trainFuncCar, 1, pos0, angle0); - - if (temp0) { - trainFuncCar->endPt[1].track = temp0; - temp0->endPt[ep0].track = trainFuncCar; - } - - if (temp1) { - trainFuncCar->endPt[0].track = temp1; - temp1->endPt[ep1].track = trainFuncCar; - } - - ControllerDialogSync(curTrainDlg); - PlaceCar(trainFuncCar); - break; - - case DO_FLIPTRAIN: - FlipTrain(trainFuncCar); - /*PlaceTrain( trainFuncCar, xx->trk, xx->trvTrk.pos, xx->trvTrk.angle );*/ - break; - - case DO_DELCAR: - for (dir=0; dir<2; dir++) - if (GetTrkEndTrk(trainFuncCar,dir)) { - UncoupleCars(trainFuncCar, GetTrkEndTrk(trainFuncCar,dir)); - } - - if (CarItemIsLoco(xx->item)) { - LocoListChangeEntry(trainFuncCar, NULL); - } - - trainFuncCar->deleted = TRUE; - /*DeleteTrack( trainFuncCar, FALSE );*/ - CarItemUpdate(xx->item); - HotBarCancel(); - InfoSubstituteControls(NULL, NULL); - break; - - case DO_DELTRAIN: - dir = 0; - loco = FindMasterLoco(trainFuncCar, NULL); - WALK_CARS_START(trainFuncCar, xx, dir) - WALK_CARS_END(trainFuncCar, xx, dir) - dir = 1-dir; - temp0 = NULL; - WALK_CARS_START(trainFuncCar, xx, dir) - - if (temp0) { - xx1 = GET_EXTRA_DATA(temp0, T_CAR, extraDataCar_t); - temp0->deleted = TRUE; - /*DeleteTrack( temp0, FALSE );*/ - CarItemUpdate(xx1->item); - } - - temp0 = trainFuncCar; - WALK_CARS_END(trainFuncCar, xx, dir) - - if (temp0) { - xx1 = GET_EXTRA_DATA(temp0, T_CAR, extraDataCar_t); - temp0->deleted = TRUE; - /*DeleteTrack( temp0, FALSE );*/ - CarItemUpdate(xx1->item); - } - - if (loco) { - LocoListChangeEntry(loco, NULL); - } - - HotBarCancel(); - InfoSubstituteControls(NULL, NULL); - break; - - case DO_MUMASTER: - if (CarItemIsLoco(xx->item)) { - loco = FindMasterLoco(trainFuncCar, NULL); - - if (loco != trainFuncCar) { - SetLocoMaster(xx); - LOG(log_trainMove, 1, ("%s gets master\n", CarItemNumber(xx->item))) - - if (loco) { - xx1 = GET_EXTRA_DATA(loco, T_CAR, extraDataCar_t); - ClrLocoMaster(xx1); - LOG(log_trainMove, 1, ("%s looses master\n", CarItemNumber(xx1->item))) - xx->speed = xx1->speed; - xx1->speed = 0; - } - - LocoListChangeEntry(loco, trainFuncCar); - } - } - - break; - - case DO_CHANGEDIR: - loco = FindMasterLoco(trainFuncCar, NULL); - - if (loco) { - xx = GET_EXTRA_DATA(loco, T_CAR, extraDataCar_t); - xx->direction = !xx->direction; - SetTrainDirection(loco); - ControllerDialogSync(curTrainDlg); - } - - break; - - case DO_STOP: - loco = FindMasterLoco(trainFuncCar, NULL); - - if (loco) { - StopTrain(loco, ST_StopManual); - ControllerDialogSync(curTrainDlg); - } - - break; - } - - MainRedraw(); //TrainFunc: Redraw if Train altered - - if (trainsState == TRAINS_PAUSE) { - RestartTrains(); - } else { - } + void * action) +{ + struct extraDataCar_t * xx, *xx1; + ANGLE_T angle; + int dir; + track_p loco; + track_p temp0, temp1; + coOrd pos0, pos1; + ANGLE_T angle0, angle1; + EPINX_T ep0, ep1; + char describe_str[STR_SIZE]; + + if (trainFuncCar == NULL) { + fprintf(stderr, "trainFunc: trainFuncCar==NULL\n"); + return; + } + + xx = GET_EXTRA_DATA(trainFuncCar, T_CAR, extraDataCar_t); + angle = FindAngle(xx->trvTrk.pos, trainFuncPos); + angle = NormalizeAngle(angle-xx->trvTrk.angle); + dir = (angle>90&&angle<270); + + switch (VP2L(action)) { + case DO_UNCOUPLE: + UncoupleCars( trainFuncCar, dir ); + break; + + case DO_PENCILS_ON: + xx->pencils = TRUE; + break; + + case DO_PENCILS_OFF: + xx->pencils = FALSE; + break; + + case DO_FLIPCAR: + temp0 = GetTrkEndTrk(trainFuncCar,0); + pos0 = GetTrkEndPos(trainFuncCar,0); + angle0 = GetTrkEndAngle(trainFuncCar,0); + temp1 = GetTrkEndTrk(trainFuncCar,1); + pos1 = GetTrkEndPos(trainFuncCar,1); + angle1 = GetTrkEndAngle(trainFuncCar,1); + + xx->direction = !xx->direction; + FlipTraverseTrack(&xx->trvTrk); + if ( temp0 ) { + ep0 = GetEndPtConnectedToMe( temp0, trainFuncCar ); + DisconnectTracks( trainFuncCar, 0, temp0, ep0 ); + } + if ( temp1 ) { + ep1 = GetEndPtConnectedToMe( temp1, trainFuncCar ); + DisconnectTracks( trainFuncCar, 1, temp1, ep1 ); + } + SetTrkEndPoint(trainFuncCar, 0, pos1, angle1); + SetTrkEndPoint(trainFuncCar, 1, pos0, angle0); + if ( temp1 ) { + ConnectTracks( trainFuncCar, 0, temp1, ep1 ); + } + if ( temp0 ) { + ConnectTracks( trainFuncCar, 1, temp0, ep0 ); + } + + ControllerDialogSync(curTrainDlg); + PlaceCar(trainFuncCar); + break; + + case DO_FLIPTRAIN: + FlipTrain(trainFuncCar); + /*PlaceTrain( trainFuncCar, xx->trk, xx->trvTrk.pos, xx->trvTrk.angle );*/ + break; + + case DO_DESCRIBE: + pos0 = trainFuncPos; + CmdDescribe(C_START, pos0); + CmdDescribe(C_DOWN, pos0); + CmdDescribe(C_UP, pos0); + break; + + case DO_DELCAR: + CarItemShelve( xx->item ); + break; + + case DO_DELTRAIN: + dir = 0; + loco = FindMasterLoco(trainFuncCar, NULL); + WALK_CARS_START(trainFuncCar, xx, dir) + WALK_CARS_END(trainFuncCar, xx, dir) + dir = 1-dir; + temp0 = NULL; + WALK_CARS_START(trainFuncCar, xx, dir) + + if (temp0) { + xx1 = GET_EXTRA_DATA(temp0, T_CAR, extraDataCar_t); + //temp0->deleted = TRUE; + DeleteTrack( temp0, FALSE ); + CarItemUpdate(xx1->item); + } + + temp0 = trainFuncCar; + WALK_CARS_END(trainFuncCar, xx, dir) + + if (temp0) { + xx1 = GET_EXTRA_DATA(temp0, T_CAR, extraDataCar_t); + //temp0->deleted = TRUE; + DeleteTrack( temp0, FALSE ); + CarItemUpdate(xx1->item); + } + + if (loco) { + LocoListChangeEntry(loco, NULL); + } + + HotBarCancel(); + InfoSubstituteControls(NULL, NULL); + break; + + case DO_MUMASTER: + if (CarItemIsLoco(xx->item)) { + loco = FindMasterLoco(trainFuncCar, NULL); + + if (loco != trainFuncCar) { + SetLocoMaster(xx); + LOG(log_trainMove, 1, ("%s gets master\n", CarItemNumber(xx->item))) + + if (loco) { + xx1 = GET_EXTRA_DATA(loco, T_CAR, extraDataCar_t); + ClrLocoMaster(xx1); + LOG(log_trainMove, 1, ("%s looses master\n", CarItemNumber(xx1->item))) + xx->speed = xx1->speed; + xx1->speed = 0; + } + + LocoListChangeEntry(loco, trainFuncCar); + } + } + + break; + + case DO_CHANGEDIR: + loco = FindMasterLoco(trainFuncCar, NULL); + + if (loco) { + xx = GET_EXTRA_DATA(loco, T_CAR, extraDataCar_t); + xx->direction = !xx->direction; + SetTrainDirection(loco); + ControllerDialogSync(curTrainDlg); + } + + break; + + case DO_STOP: + loco = FindMasterLoco(trainFuncCar, NULL); + + if (loco) { + StopTrain(loco, ST_StopManual); + ControllerDialogSync(curTrainDlg); + } + + break; + } + + MainRedraw(); //TrainFunc: Redraw if Train altered + + if (trainsState == TRAINS_PAUSE) { + RestartTrains(); + } else { + } } EXPORT wIndex_t trainCmdInx; void InitCmdTrain(wMenu_p menu) { - log_trainMove = LogFindIndex("trainMove"); - log_trainPlayback = LogFindIndex("trainPlayback"); - trainPLs[I_ZERO].winLabel = (char*)wIconCreatePixMap(zero_xpm); - ParamRegister(&trainPG); - trainCmdInx = AddMenuButton(menu, CmdTrain, "cmdTrain", _("Run Trains"), - wIconCreatePixMap(train_xpm[iconSize]), LEVEL0_50, IC_POPUP3|IC_LCLICK|IC_RCLICK, 0, - NULL); - stopI = wIconCreatePixMap(reddot); - goI = wIconCreatePixMap(greendot); - stopB = wIconCreatePixMap(stop_xpm[iconSize]); - goB = wIconCreatePixMap(go_xpm[iconSize]); + log_trainMove = LogFindIndex("trainMove"); + log_trainPlayback = LogFindIndex("trainPlayback"); + trainPLs[I_ZERO].winLabel = (char*)wIconCreatePixMap(zero_xpm); + ParamRegister(&trainPG); + trainCmdInx = AddMenuButton(menu, CmdTrain, "cmdTrain", _("Run Trains"), + wIconCreatePixMap(train_xpm3[iconSize]), LEVEL0_50, + IC_POPUP3|IC_LCLICK|IC_RCLICK|IC_WANT_MOVE, 0, + NULL); + stopI = wIconCreatePixMap(reddot); + goI = wIconCreatePixMap(greendot); + stopB = wIconCreatePixMap(stop_xpm3[iconSize]); + goB = wIconCreatePixMap(go_xpm3[iconSize]); trainPauseB = AddToolbarButton("cmdTrainPause", stopB, IC_MODETRAIN_ONLY, - CmdTrainStopGo, NULL); - AddToolbarButton("cmdTrainExit", wIconCreatePixMap(exit_xpm[iconSize]), IC_MODETRAIN_ONLY, - CmdTrainExit, NULL); - newcarB = AddToolbarButton("cmdTrainNewCar", wIconCreatePixMap(new_car_xpm[iconSize]), - IC_MODETRAIN_ONLY, CarItemLoadList, NULL); - T_CAR = InitObject(&carCmds); + CmdTrainStopGo, NULL); + AddToolbarButton("cmdTrainExit", wIconCreatePixMap(exit_xpm3[iconSize]), + IC_MODETRAIN_ONLY, + CmdTrainExit, NULL); + newcarB = AddToolbarButton("cmdTrainNewCar", + wIconCreatePixMap(new_car_xpm3[iconSize]), + IC_MODETRAIN_ONLY, CarItemLoadList, NULL); + T_CAR = InitObject(&carCmds); trainPopupM = MenuRegister("Train Commands"); - trainPopupMI[DO_UNCOUPLE] = wMenuPushCreate(trainPopupM, "", _("Uncouple"), 0, - TrainFunc, I2VP(DO_UNCOUPLE)); - trainPopupMI[DO_FLIPCAR] = wMenuPushCreate(trainPopupM, "", _("Flip Car"), 0, - TrainFunc, I2VP(DO_FLIPCAR)); - trainPopupMI[DO_PENCILS_ON] = wMenuPushCreate(trainPopupM, "", _("Clearance Lines On"), 0, - TrainFunc, I2VP(DO_PENCILS_ON)); - trainPopupMI[DO_PENCILS_OFF] = wMenuPushCreate(trainPopupM, "", _("Clearance Lines Off"), 0, - TrainFunc, I2VP(DO_PENCILS_OFF)); - trainPopupMI[DO_FLIPTRAIN] = wMenuPushCreate(trainPopupM, "", _("Flip Train"), - 0, TrainFunc, I2VP(DO_FLIPTRAIN)); - trainPopupMI[DO_MUMASTER] = wMenuPushCreate(trainPopupM, "", _("MU Master"), - 0, TrainFunc, I2VP(DO_MUMASTER)); - trainPopupMI[DO_CHANGEDIR] = wMenuPushCreate(trainPopupM, "", - _("Change Direction"), 0, TrainFunc, I2VP(DO_CHANGEDIR)); - trainPopupMI[DO_STOP] = wMenuPushCreate(trainPopupM, "", _("Stop"), 0, - TrainFunc, I2VP(DO_STOP)); - wMenuSeparatorCreate(trainPopupM); - trainPopupMI[DO_DELCAR] = wMenuPushCreate(trainPopupM, "", _("Remove Car"), - 0, TrainFunc, I2VP(DO_DELCAR)); - trainPopupMI[DO_DELTRAIN] = wMenuPushCreate(trainPopupM, "", - _("Remove Train"), 0, TrainFunc, I2VP(DO_DELTRAIN)); - AddPlaybackProc("TRAINSTOPGO", (playbackProc_p)TrainStopGoPlayback, NULL); - AddPlaybackProc("TRAINPAUSE", (playbackProc_p)TrainTimeDoPause, NULL); - AddPlaybackProc("TRAINMOVIE", (playbackProc_p)TrainDoMovie, NULL); + trainPopupMI[DO_UNCOUPLE] = wMenuPushCreate(trainPopupM, "", _("Uncouple"), 0, + TrainFunc, I2VP(DO_UNCOUPLE)); + trainPopupMI[DO_FLIPCAR] = wMenuPushCreate(trainPopupM, "", _("Flip Car"), 0, + TrainFunc, I2VP(DO_FLIPCAR)); + trainPopupMI[DO_PENCILS_ON] = wMenuPushCreate(trainPopupM, "", + _("Clearance Lines On"), 0, + TrainFunc, I2VP(DO_PENCILS_ON)); + trainPopupMI[DO_PENCILS_OFF] = wMenuPushCreate(trainPopupM, "", + _("Clearance Lines Off"), 0, + TrainFunc, I2VP(DO_PENCILS_OFF)); + trainPopupMI[DO_FLIPTRAIN] = wMenuPushCreate(trainPopupM, "", _("Flip Train"), + 0, TrainFunc, I2VP(DO_FLIPTRAIN)); + trainPopupMI[DO_DESCRIBE] = wMenuPushCreate(trainPopupM, "", _("Describe"), + 0, TrainFunc, I2VP(DO_DESCRIBE)); + trainPopupMI[DO_MUMASTER] = wMenuPushCreate(trainPopupM, "", _("MU Master"), + 0, TrainFunc, I2VP(DO_MUMASTER)); + trainPopupMI[DO_CHANGEDIR] = wMenuPushCreate(trainPopupM, "", + _("Change Direction"), 0, TrainFunc, I2VP(DO_CHANGEDIR)); + trainPopupMI[DO_STOP] = wMenuPushCreate(trainPopupM, "", _("Stop"), 0, + TrainFunc, I2VP(DO_STOP)); + wMenuSeparatorCreate(trainPopupM); + trainPopupMI[DO_DELCAR] = wMenuPushCreate(trainPopupM, "", _("Remove Car"), + 0, TrainFunc, I2VP(DO_DELCAR)); + trainPopupMI[DO_DELTRAIN] = wMenuPushCreate(trainPopupM, "", + _("Remove Train"), 0, TrainFunc, I2VP(DO_DELTRAIN)); + AddPlaybackProc("TRAINSTOPGO", (playbackProc_p)TrainStopGoPlayback, NULL); + AddPlaybackProc("TRAINPAUSE", (playbackProc_p)TrainTimeDoPause, NULL); + AddPlaybackProc("TRAINMOVIE", (playbackProc_p)TrainDoMovie, NULL); } diff --git a/app/bin/ctrain.h b/app/bin/ctrain.h index f11ba81..0e06332 100644 --- a/app/bin/ctrain.h +++ b/app/bin/ctrain.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef HAVE_CTRAIN_H @@ -28,43 +28,61 @@ extern wIndex_t trainCmdInx; +extern long trainPause; + struct carItem_t; typedef struct carItem_t carItem_t; typedef carItem_t * carItem_p; typedef struct { - coOrd pos; - ANGLE_T angle; - } vector_t; + coOrd pos; + ANGLE_T angle; +} vector_t; extern carItem_p currCarItemPtr; extern wControl_p newCarControls[2]; void DoCarDlg( void * unused ); BOOL_T CarItemRead( char * ); +void CarItemShelve( carItem_p ); track_p NewCar( wIndex_t, carItem_p, coOrd, ANGLE_T ); +void UncoupleCars( track_p, int ); void CarGetPos( track_p, coOrd *, ANGLE_T * ); void CarSetVisible( track_p ); void CarItemUpdate( carItem_p ); void CarItemLoadList( void * ); char * CarItemDescribe( carItem_p, long, long * ); void CarItemFindCouplerMountPoint( carItem_p, traverseTrack_t, coOrd[2] ); +void CarItemPos( carItem_p, coOrd *); void CarItemSize( carItem_p, coOrd * ); char * CarItemNumber( carItem_p ); +void CarItemSetNumber( carItem_p, char *); DIST_T CarItemCoupledLength( carItem_p ); BOOL_T CarItemIsLoco( carItem_p ); BOOL_T CarItemIsLocoMaster( carItem_p ); void CarItemSetLocoMaster( carItem_p, BOOL_T ); void CarItemSetTrack( carItem_p, track_p ); void CarItemPlace( carItem_p, traverseTrack_p, DIST_T * ); -void CarItemDraw( drawCmd_p, carItem_p, wDrawColor, int, BOOL_T, vector_t *, BOOL_T, track_p ); +void CarItemDraw( drawCmd_p, carItem_p, wDrawColor, int, BOOL_T, vector_t *, + BOOL_T, track_p ); + +BOOL_T WriteCars( FILE * ); +void ClearCars( void ); +void CarDlgAddProto( void ); +void CarDlgAddDesc( void ); +void AttachTrains( void ); + BOOL_T StoreCarItem (carItem_p item, void **data,long *len); BOOL_T ReplayCarItem(carItem_p item, void *data,long len); -enum paramFileState GetCarPartCompatibility(int paramFileIndex, SCALEINX_T scaleIndex); -enum paramFileState GetCarProtoCompatibility(int paramFileIndex, SCALEINX_T scaleIndex); +enum paramFileState GetCarPartCompatibility(int paramFileIndex, + SCALEINX_T scaleIndex); +enum paramFileState GetCarProtoCompatibility(int paramFileIndex, + SCALEINX_T scaleIndex); int CarAvailableCount( void ); BOOL_T TraverseTrack2( traverseTrack_p, DIST_T ); void FlipTraverseTrack( traverseTrack_p ); void CheckCarTraverse( track_p trk); + void DeleteCarProto(int fileIndex); void DeleteCarPart(int fileIndex); +void LocoListChangeEntry( track_p, track_p ); #endif // !HAVE_CTRAIN_H diff --git a/app/bin/cturnout.c b/app/bin/cturnout.c index 02eadef..9bae6ae 100644 --- a/app/bin/cturnout.c +++ b/app/bin/cturnout.c @@ -1,24 +1,24 @@ /** \file cturnout.c - * Turnout object handling and drawing + * Turnout object handling */ - /* XTrkCad - Model Railroad CAD - * Copyright (C) 2005 Dave Bullis - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ +/* XTrkCad - Model Railroad CAD + * Copyright (C) 2005 Dave Bullis + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ #include "common.h" #include "ccurve.h" @@ -35,7 +35,7 @@ #include "cselect.h" #include "include/paramfile.h" #include "track.h" -#include "trackx.h" +#include "trkendpt.h" #include "common-ui.h" EXPORT TRKTYP_T T_TURNOUT = -1; @@ -48,7 +48,7 @@ EXPORT dynArr_t turnoutInfo_da; EXPORT turnoutInfo_t* curTurnout = NULL; EXPORT long curTurnoutEp = 0; -static int curTurnoutInx = -1; +//static int curTurnoutInx = -1; /** @logcmd @showrefby turnout=n cturnout.c */ static int log_turnout = 0; @@ -63,18 +63,20 @@ static wMenu_p turnoutPopupM; #ifdef TURNOUTCMD static drawCmd_t turnoutD = { - NULL, - &screenDrawFuncs, - 0, - 1.0, - 0.0, - {0.0,0.0}, {0.0,0.0}, - Pix2CoOrd, CoOrd2Pix }; + NULL, + &screenDrawFuncs, + 0, + 1.0, + 0.0, + {0.0,0.0}, {0.0,0.0}, + Pix2CoOrd, CoOrd2Pix +}; static wIndex_t turnoutHotBarCmdInx; static wIndex_t turnoutInx; static long hideTurnoutWindow; -static void RedrawTurnout( wDraw_p d, void * context, wWinPix_t x, wWinPix_t y ); +static void RedrawTurnout( wDraw_p d, void * context, wWinPix_t x, + wWinPix_t y ); static void SelTurnoutEndPt(wIndex_t, coOrd); static void HilightEndPt(void); @@ -95,76 +97,10 @@ static paramData_t turnoutPLs[] = { { PD_MENU, NULL, "new", PDO_DLGCMDBUTTON, NULL, N_("New") }, #define I_HIDE (3) #define turnoutHideT ((wChoice_p)turnoutPLs[I_HIDE].control) - { PD_TOGGLE, &hideTurnoutWindow, "hide", PDO_DLGCMDBUTTON, hideLabels, NULL, BC_NOBORDER } }; -static paramGroup_t turnoutPG = { "turnout", 0, turnoutPLs, COUNT( turnoutPLs ) }; -#endif - -/* Draw turnout data */ - -/** - * The types of turnouts that get enhanced drawing methods - */ -enum dtoType { - DTO_INVALID, - DTO_NORMAL, - DTO_THREE, - DTO_WYE, - - DTO_CURVED, - - DTO_XING, - DTO_XNG9, - DTO_SSLIP, - DTO_DSLIP, - - DTO_LCROSS, - DTO_RCROSS, - DTO_DCROSS -}; - -// Define to plot control points (DTO_NORMAL, DTO_CURVED, DTO_XING, DTO_LCROSS) -// #define DTO_DEBUG DTO_XING - -#define DTO_DIM 4 // Maximum number of paths -#define DTO_SEGS 24 // Maximum number of control points - -static struct DrawToData_t { - TRKINX_T index; - enum dtoType toType; - track_p trk; - int bridge; - int endCnt; - int pathCnt; - int routeCnt; - int strCnt; - int crvCnt; - int rgtCnt; - int lftCnt; - int strPath; - int str2Path; - int crvPath; - int crv2Path; - int origCnt; - int origins[DTO_DIM]; - coOrd midPt; - struct extraDataCompound_t* xx; -} dtod; - -struct DrawTo_t { - int n; - trkSeg_p trkSeg[DTO_SEGS]; - coOrd base[DTO_SEGS]; - coOrd baseLast; - DIST_T dy[DTO_SEGS]; - ANGLE_T angle; - ANGLE_T crvAngle; - coOrd pts[DTO_SEGS]; - coOrd ptsLast; - char type; + { PD_TOGGLE, &hideTurnoutWindow, "hide", PDO_DLGCMDBUTTON, hideLabels, NULL, BC_NOBORDER } }; - -static struct DrawTo_t dto[DTO_DIM]; - +static paramGroup_t turnoutPG = { "newFixedTrack", 0, turnoutPLs, COUNT( turnoutPLs ) }; +#endif /**************************************** @@ -175,15 +111,15 @@ static struct DrawTo_t dto[DTO_DIM]; EXPORT turnoutInfo_t* CreateNewTurnout( - char* scale, - char* title, - wIndex_t segCnt, - trkSeg_p segData, - PATHPTR_T paths, - EPINX_T endPtCnt, - trkEndPt_t* endPts, - wBool_t updateList, - long options) + char* scale, + char* title, + wIndex_t segCnt, + trkSeg_p segData, + PATHPTR_T paths, + EPINX_T endPtCnt, + trkEndPt_p endPts, + wBool_t updateList, + long options) { turnoutInfo_t* to; long changes = 0; @@ -202,38 +138,42 @@ EXPORT turnoutInfo_t* CreateNewTurnout( to->segs = (trkSeg_p)memdup(segData, (sizeof(*segData) * segCnt)); seg_p = to->segs; for (int i = 0; i < segCnt; i++) { - seg_p[i].bezSegs.ptr = NULL; - seg_p[i].bezSegs.cnt = 0; - seg_p[i].bezSegs.max = 0; + DYNARR_INIT( trackSeg_t, seg_p[i].bezSegs ); } CopyPoly(to->segs, segCnt); FixUpBezierSegs(to->segs, to->segCnt); GetSegBounds(zero, 0.0, segCnt, to->segs, &to->orig, &to->size); to->endCnt = endPtCnt; - to->endPt = (trkEndPt_t*)memdup(endPts, (sizeof * endPts) * to->endCnt); + to->endPt = (trkEndPt_p)memdup(endPts, EndPtSize(to->endCnt)); - if (options & COMPOUND_OPTION_PATH_OVERRIDE) + if (options & COMPOUND_OPTION_PATH_OVERRIDE) { to->pathOverRide = TRUE; - if (options & COMPOUND_OPTION_PATH_NOCOMBINE) + } + if (options & COMPOUND_OPTION_PATH_NOCOMBINE) { to->pathNoCombine = TRUE; + } SetParamPaths( to, paths ); to->paramFileIndex = curParamFileIndex; - if (curParamFileIndex == PARAM_CUSTOM) + if (curParamFileIndex == PARAM_CUSTOM) { to->contentsLabel = MyStrdup("Custom Turnouts"); - else + } else { to->contentsLabel = curSubContents; + } #ifdef TURNOUTCMD if (updateList && turnoutListL != NULL) { - FormatCompoundTitle(LABEL_TABBED | LABEL_MANUF | LABEL_PARTNO | LABEL_DESCR, title); - if (message[0] != '\0') + FormatCompoundTitle(LABEL_TABBED | LABEL_MANUF | LABEL_PARTNO | LABEL_DESCR, + title); + if (message[0] != '\0') { wListAddValue(turnoutListL, message, NULL, to); + } } #endif to->barScale = curBarScale > 0 ? curBarScale : -1; to->special = TOnormal; - if (updateList && changes) + if (updateList && changes) { DoChangeNotification(changes); + } return to; } @@ -281,17 +221,20 @@ DeleteTurnoutParams(int fileIndex) // go to the start of the block while (inx < turnoutInfo_da.cnt && - turnoutInfo(inx)->paramFileIndex != fileIndex) { + turnoutInfo(inx)->paramFileIndex != fileIndex) { startInx = inx++; } // delete them for (; inx < turnoutInfo_da.cnt && - turnoutInfo(inx)->paramFileIndex == fileIndex; inx++) { + turnoutInfo(inx)->paramFileIndex == fileIndex; inx++) { turnoutInfo_t* to = turnoutInfo(inx); if (to->paramFileIndex == fileIndex) { DeleteTurnout(to); cnt++; + if ( to == curTurnout ) { + curTurnout = NULL; + } } } @@ -320,26 +263,26 @@ DeleteTurnoutParams(int fileIndex) */ enum paramFileState - GetTrackCompatibility(int paramFileIndex, SCALEINX_T scaleIndex) -{ +GetTrackCompatibility(int paramFileIndex, SCALEINX_T scaleIndex) { int i; enum paramFileState ret = PARAMFILE_NOTUSABLE; - DIST_T gauge = GetScaleTrackGauge(scaleIndex); +// DIST_T gauge = GetScaleTrackGauge(scaleIndex); - if (!IsParamValid(paramFileIndex)) { + if (!IsParamValid(paramFileIndex)) + { return(PARAMFILE_UNLOADED); } // loop over all parameter entries or until a exact fit is found - for (i = 0; i < turnoutInfo_da.cnt && ret < PARAMFILE_FIT; i++) { + for (i = 0; i < turnoutInfo_da.cnt && ret < PARAMFILE_FIT; i++) + { turnoutInfo_t* to = turnoutInfo(i); if (to->paramFileIndex == paramFileIndex) { SCALE_FIT_T fit = CompatibleScale(FIT_TURNOUT, to->scaleInx, scaleIndex); if (fit == FIT_EXACT) { ret = PARAMFILE_FIT; break; - } - else if (fit == FIT_COMPATIBLE) { + } else if (fit == FIT_COMPATIBLE) { ret = PARAMFILE_COMPATIBLE; } } @@ -358,24 +301,31 @@ enum paramFileState * \returns -1 if a track segment is not on a path */ EXPORT wIndex_t CheckPaths( - wIndex_t segCnt, - trkSeg_p segs, - PATHPTR_T paths) + wIndex_t segCnt, + trkSeg_p segs, + PATHPTR_T paths, + char * sTitle ) { - if ((segCnt == 0) || !segs) return -1; - if (!paths) return -1; + if ((segCnt == 0) || !segs) { return -1; } + if (!paths) { return -1; } int pc, ps; PATHPTR_T pp = 0; int segInx[2], segEp[2]; - int segTrkLast = -1; +// int segTrkLast = -1; // Check that each track segment is on at least one path // Note - In new-P the tracks may be preceded by draws (or interspersed by them) - int suppressCheckPaths = log_suppressCheckPaths > 0 ? logTable(log_suppressCheckPaths).level : 0; + int suppressCheckPaths = log_suppressCheckPaths > 0 ? logTable( + log_suppressCheckPaths).level : 0; if (suppressCheckPaths == 0) { for (int inx = 0; inx < segCnt; inx++) { if (IsSegTrack(&segs[inx])) { + if ( inx > MAX_PATH_SEGS ) { + InputError("Too many segments %d in Turnout definition %s", FALSE, inx + 1, + PutTitle(sTitle)); + return -1; + } PATHPTR_T cp = paths; while (*cp) { // 0-9 are x00 to x09 or the negative equivalent (backwards) @@ -383,19 +333,24 @@ EXPORT wIndex_t CheckPaths( // Path is: NAME01203400 for (; *cp; cp++); //Skip Name cp++; //Skip 0 after name - // check each path component - for (; cp[0] || cp[1]; cp++) { //keeps going even if there are two or more parts - if (!cp[0]) continue; //ignore the 0 between parts of the same PATH!! - GetSegInxEP(cp[0], &segInx[0], &segEp[0]); //GetSegInxEP subtracts one to match inx - if (segInx[0] == inx) break; //Found it! + // check each path component + for (; cp[0] + || cp[1]; cp++) { //keeps going even if there are two or more parts + if (!cp[0]) { continue; } //ignore the 0 between parts of the same PATH!! + GetSegInxEP(cp[0], &segInx[0], + &segEp[0]); //GetSegInxEP subtracts one to match inx + if (segInx[0] == inx) { break; } //Found it! + } + if (*cp) { // we broke early + break; // get out - we found it } - if (*cp) // we broke early - break; // get out - we found it cp++; cp++; // Go to next path - past two 0s } if (!*cp) { // we looked through all the paths and didn't find it - InputError("Track segment %d not on Path", FALSE, inx + 1); +// InputError("Track segment %d not on Path", FALSE, inx + 1); + NoticeMessage(MSG_SEGMENT_NOT_ON_PATH, _("OK"), NULL, inx + 1, + PutTitle(sTitle)); return -1;; } } @@ -403,7 +358,8 @@ EXPORT wIndex_t CheckPaths( } for (pc = 0, pp = paths; *pp; pp += 2, pc++) { - for (ps = 0, pp += strlen((char*)pp) + 1; pp[0] != 0 || pp[1] != 0; pp++, ps++) { + for (ps = 0, pp += strlen((char*)pp) + 1; pp[0] != 0 + || pp[1] != 0; pp++, ps++) { if (pp[0] != 0 && ps == 0) { // First or only one } if (pp[0] != 0 && pp[1] != 0) { @@ -413,20 +369,21 @@ EXPORT wIndex_t CheckPaths( GetSegInxEP(pp[1], &segInx[1], &segEp[1]); if (!IsSegTrack(&segs[segInx[0]])) { InputError(_("CheckPath: Turnout path[%d] %d is not a track segment"), - FALSE, pc, pp[0]); + FALSE, pc, pp[0]); return -1; } if (!IsSegTrack(&segs[segInx[1]])) { InputError(_("CheckPath: Turnout path[%d] %d is not a track segment"), - FALSE, pc, pp[1]); + FALSE, pc, pp[1]); return -1; } coOrd p0 = GetSegEndPt(&segs[segInx[0]], 1 - segEp[0], FALSE, NULL); coOrd p1 = GetSegEndPt(&segs[segInx[1]], segEp[1], FALSE, NULL); d = FindDistance(p0, p1); if (d > MIN_TURNOUT_SEG_CONNECT_DIST) { - InputError(_("CheckPath: Turnout path[%d] %d-%d not connected: %0.3f P0(%f,%f) P1(%f,%f)"), - FALSE, pc, pp[0], pp[1], d, p0.x, p0.y, p1.x, p1.y); + InputError( + _("CheckPath: Turnout path[%d] %d-%d not connected: %0.3f P0(%f,%f) P1(%f,%f)"), + FALSE, pc, pp[0], pp[1], d, p0.x, p0.y, p1.x, p1.y); return -1; } } @@ -438,7 +395,7 @@ EXPORT wIndex_t CheckPaths( static BOOL_T ReadTurnoutParam( - char* firstLine) + char* firstLine) { char scale[10]; char* title; @@ -446,32 +403,37 @@ static BOOL_T ReadTurnoutParam( PATHPTR_T cp; long options = 0; - if (!GetArgs(firstLine + 8, "sqc", scale, &title, &cp)) + if (!GetArgs(firstLine + 8, "sqc", scale, &title, &cp)) { return FALSE; + } if (cp != NULL) - if (!GetArgs((char*)cp, "l", &options)) + if (!GetArgs((char*)cp, "l", &options)) { return FALSE; - DYNARR_RESET(trkEndPt_t, tempEndPts_da); + } + TempEndPtsReset(); pathCnt = 0; - if (!ReadSegs()) + if (!ReadSegs()) { return FALSE; + } PATHPTR_T pPaths = NULL; - if ( pathPtr && pathPtr[0] && pathCnt > 0 ) + if ( pathPtr && pathPtr[0] && pathCnt > 0 ) { pPaths = pathPtr; - CheckPaths( tempSegs_da.cnt, &tempSegs(0), pPaths ); + } + CheckPaths( tempSegs_da.cnt, &tempSegs(0), pPaths, title ); to = CreateNewTurnout(scale, title, tempSegs_da.cnt, &tempSegs(0), - pPaths, tempEndPts_da.cnt, &tempEndPts(0), FALSE, options ); + pPaths, TempEndPtsCount(), TempEndPt(0), FALSE, options ); MyFree(title); - if (to == NULL) + if (to == NULL) { return FALSE; + } if (tempSpecial[0] != '\0') { if (strncmp(tempSpecial, ADJUSTABLE, strlen(ADJUSTABLE)) == 0) { to->special = TOadjustable; if (!GetArgs(tempSpecial + strlen(ADJUSTABLE), "ff", - &to->u.adjustable.minD, &to->u.adjustable.maxD)) + &to->u.adjustable.minD, &to->u.adjustable.maxD)) { return FALSE; - } - else { + } + } else { InputError(_("Unknown special case"), TRUE); return FALSE; } @@ -483,7 +445,8 @@ static BOOL_T ReadTurnoutParam( } -EXPORT turnoutInfo_t* TurnoutAdd(long mode, SCALEINX_T scale, wList_p list, coOrd* maxDim, EPINX_T epCnt) +EXPORT turnoutInfo_t* TurnoutAdd(long mode, SCALEINX_T scale, wList_p list, + coOrd* maxDim, EPINX_T epCnt) { wIndex_t inx; turnoutInfo_t* to, * to1 = NULL; @@ -491,12 +454,13 @@ EXPORT turnoutInfo_t* TurnoutAdd(long mode, SCALEINX_T scale, wList_p list, coOr for (inx = 0; inx < turnoutInfo_da.cnt; inx++) { to = turnoutInfo(inx); if (IsParamValid(to->paramFileIndex) && - to->segCnt > 0 && - (FIT_NONE != CompatibleScale(FIT_TURNOUT, to->scaleInx, scale)) && - /*strcasecmp( to->scale, scaleName ) == 0 && */ - (epCnt <= 0 || epCnt == to->endCnt)) { - if (to1 == NULL) + to->segCnt > 0 && + (FIT_NONE != CompatibleScale(FIT_TURNOUT, to->scaleInx, scale)) && + /*strcasecmp( to->scale, scaleName ) == 0 && */ + (epCnt <= 0 || epCnt == to->endCnt)) { + if (to1 == NULL) { to1 = to; + } if (to == curTurnout) { to1 = to; turnoutInx = wListGetCount(list); @@ -505,10 +469,12 @@ EXPORT turnoutInfo_t* TurnoutAdd(long mode, SCALEINX_T scale, wList_p list, coOr if (message[0] != '\0') { wListAddValue(list, message, NULL, to); if (maxDim) { - if (to->size.x > maxDim->x) + if (to->size.x > maxDim->x) { maxDim->x = to->size.x; - if (to->size.y > maxDim->y) + } + if (to->size.y > maxDim->y) { maxDim->y = to->size.y; + } } } } @@ -524,19 +490,21 @@ EXPORT turnoutInfo_t* TurnoutAdd(long mode, SCALEINX_T scale, wList_p list, coOr static void ChangeAdjustableEndPt( - track_p trk, - EPINX_T ep, - DIST_T d) + track_p trk, + EPINX_T ep, + DIST_T d) { - struct extraDataCompound_t* xx = GET_EXTRA_DATA(trk, T_TURNOUT, extraDataCompound_t); + struct extraDataCompound_t* xx = GET_EXTRA_DATA(trk, T_TURNOUT, + extraDataCompound_t); coOrd pos; trkSeg_p segPtr; ANGLE_T angle = GetTrkEndAngle(trk, ep); Translate(&pos, GetTrkEndPos(trk, 1 - ep), angle, d); UndoModify(trk); SetTrkEndPoint(trk, ep, pos, angle); - if (ep == 0) + if (ep == 0) { xx->orig = pos; + } for (segPtr = xx->segs; segPtr < &xx->segs[xx->segCnt]; segPtr++) { switch (segPtr->type) { case SEG_STRLIN: @@ -553,10 +521,10 @@ static void ChangeAdjustableEndPt( EXPORT BOOL_T ConnectAdjustableTracks( - track_p trk1, - EPINX_T ep1, - track_p trk2, - EPINX_T ep2) + track_p trk1, + EPINX_T ep1, + track_p trk2, + EPINX_T ep2) { struct extraDataCompound_t* xx1; struct extraDataCompound_t* xx2; @@ -568,43 +536,45 @@ EXPORT BOOL_T ConnectAdjustableTracks( coOrd off; DIST_T beyond; - if ((GetTrkType(trk1) != T_TURNOUT) && (GetTrkType(trk2) != T_TURNOUT)) return FALSE; + if ((GetTrkType(trk1) != T_TURNOUT) && (GetTrkType(trk2) != T_TURNOUT)) { return FALSE; } adj1 = adj2 = FALSE; if (GetTrkType(trk1) == T_TURNOUT) { xx1 = GET_EXTRA_DATA(trk1, T_TURNOUT, extraDataCompound_t); - if (xx1->special == TOadjustable) + if (xx1->special == TOadjustable) { adj1 = TRUE; + } } if (GetTrkType(trk2) == T_TURNOUT) { xx2 = GET_EXTRA_DATA(trk2, T_TURNOUT, extraDataCompound_t); - if (xx2->special == TOadjustable) + if (xx2->special == TOadjustable) { adj2 = TRUE; + } } - if (adj1 == FALSE && adj2 == FALSE) + if (adj1 == FALSE && adj2 == FALSE) { return FALSE; + } a1 = GetTrkEndAngle(trk1, ep1); a2 = GetTrkEndAngle(trk2, ep2); a = NormalizeAngle(a1 - a2 + 180.0 + connectAngle / 2.0); - if (a > connectAngle) + if (a > connectAngle) { return FALSE; + } UndoStart(_("Connect Adjustable Tracks"), "changeAdjustableEndPt"); maxD = 0.0; if (adj1) { p1 = GetTrkEndPos(trk1, 1 - ep1); Translate(&p1, p1, a1, xx1->u.adjustable.minD); maxD += xx1->u.adjustable.maxD - xx1->u.adjustable.minD; - } - else { + } else { p1 = GetTrkEndPos(trk1, ep1); } if (adj2) { p2 = GetTrkEndPos(trk2, 1 - ep2); Translate(&p2, p2, a2, xx2->u.adjustable.minD); maxD += xx2->u.adjustable.maxD - xx2->u.adjustable.minD; - } - else { + } else { p2 = GetTrkEndPos(trk2, ep2); } d = FindDistance(p1, p2); @@ -614,16 +584,19 @@ EXPORT BOOL_T ConnectAdjustableTracks( rc = FALSE; } FindPos(&off, &beyond, p1, p2, a1, DIST_INF); - if (fabs(off.y) > connectDistance) + if (fabs(off.y) > connectDistance) { rc = FALSE; + } if (adj1) { UndrawNewTrack(trk1); - d1 = d * (xx1->u.adjustable.maxD - xx1->u.adjustable.minD) / maxD + xx1->u.adjustable.minD; + d1 = d * (xx1->u.adjustable.maxD - xx1->u.adjustable.minD) / maxD + + xx1->u.adjustable.minD; ChangeAdjustableEndPt(trk1, ep1, d1); } if (adj2) { UndrawNewTrack(trk2); - d2 = d * (xx2->u.adjustable.maxD - xx2->u.adjustable.minD) / maxD + xx2->u.adjustable.minD; + d2 = d * (xx2->u.adjustable.maxD - xx2->u.adjustable.minD) / maxD + + xx2->u.adjustable.minD; ChangeAdjustableEndPt(trk2, ep2, d2); } if (rc) { @@ -638,118 +611,27 @@ EXPORT BOOL_T ConnectAdjustableTracks( /**************************************** * - * Draw Turnout Roadbed - * - */ - -int roadbedOnScreen = 0; - - -void DrawTurnoutRoadbedSide(drawCmd_p d, wDrawColor color, coOrd orig, ANGLE_T angle, trkSeg_p sp, ANGLE_T side, int first, int last) -{ - segProcData_t data; - if (last <= first) - return; - data.drawRoadbedSide.first = first; - data.drawRoadbedSide.last = last; - data.drawRoadbedSide.side = side; - data.drawRoadbedSide.roadbedWidth = roadbedWidth; - data.drawRoadbedSide.rbw = (wDrawWidth)floor(roadbedLineWidth * (d->dpi / d->scale) + 0.5); - data.drawRoadbedSide.orig = orig; - data.drawRoadbedSide.angle = angle; - data.drawRoadbedSide.color = color; - data.drawRoadbedSide.d = d; - SegProc(SEGPROC_DRAWROADBEDSIDE, sp, &data); -} - - -static void ComputeAndDrawTurnoutRoadbedSide( - drawCmd_p d, - wDrawColor color, - coOrd orig, - ANGLE_T angle, - trkSeg_p segPtr, - int segCnt, - int segInx, - ANGLE_T side) -{ - unsigned long res, res1; - int b0, b1; - res = ComputeTurnoutRoadbedSide(segPtr, segCnt, segInx, side, roadbedWidth); - if (res == 0L) { - } - else if (res == 0xFFFFFFFF) { - DrawTurnoutRoadbedSide(d, color, orig, angle, &segPtr[segInx], side, 0, 32); - } - else { - for (b0 = 0, res1 = 0x00000001; res1 && (res1 & res); b0++, res1 <<= 1); - for (b1 = 32, res1 = 0x80000000; res1 && (res1 & res); b1--, res1 >>= 1); - DrawTurnoutRoadbedSide(d, color, orig, angle, &segPtr[segInx], side, 0, b0); - DrawTurnoutRoadbedSide(d, color, orig, angle, &segPtr[segInx], side, b1, 32); - } -} - - -static void DrawTurnoutRoadbed( - drawCmd_p d, - wDrawColor color, - coOrd orig, - ANGLE_T angle, - trkSeg_p segPtr, - int segCnt) -{ - int inx, trkCnt = 0, segInx = 0; - for (inx = 0; inx < segCnt; inx++) { - if (IsSegTrack(&segPtr[inx])) { - segInx = inx; - trkCnt++; - if (trkCnt > 1) - break; - } - } - if (trkCnt == 0) - return; - if (trkCnt == 1) { - DrawTurnoutRoadbedSide(d, color, orig, angle, &segPtr[segInx], +90, 0, 32); - DrawTurnoutRoadbedSide(d, color, orig, angle, &segPtr[segInx], -90, 0, 32); - } - else { - for (inx = 0; inx < segCnt; inx++) { - if (IsSegTrack(&segPtr[inx])) { - ComputeAndDrawTurnoutRoadbedSide(d, color, orig, angle, segPtr, segCnt, inx, +90); - ComputeAndDrawTurnoutRoadbedSide(d, color, orig, angle, segPtr, segCnt, inx, -90); - } - } - } -} - -/**************************************** - * * HAND LAID TURNOUTS * */ track_p NewHandLaidTurnout( - coOrd p0, - ANGLE_T a0, - coOrd p1, - ANGLE_T a1, - coOrd p2, - ANGLE_T a2, - ANGLE_T frogA) + coOrd p0, + ANGLE_T a0, + coOrd p1, + ANGLE_T a1, + coOrd p2, + ANGLE_T a2, + ANGLE_T frogA) { track_p trk; struct extraDataCompound_t* xx; trkSeg_t segs[2]; sprintf(message, "\tHand Laid Turnout, Angle=%0.1f\t", frogA); - DYNARR_SET(trkEndPt_t, tempEndPts_da, 2); - memset(&tempEndPts(0), 0, tempEndPts_da.cnt * sizeof tempEndPts(0)); - tempEndPts(0).pos = p0; - tempEndPts(0).angle = a0; - tempEndPts(1).pos = p1; - tempEndPts(1).angle = a1; - tempEndPts(2).pos = p2; - tempEndPts(2).angle = a2; + TempEndPtsSet( 3 ); + SetEndPt( TempEndPt(0), p0, a0 ); + SetEndPt( TempEndPt(1), p1, a1 ); + SetEndPt( TempEndPt(2), p2, a2 ); Rotate(&p1, p0, -a0); p1.x -= p0.x; p1.y -= p0.y; @@ -764,7 +646,8 @@ track_p NewHandLaidTurnout( segs[1].color = wDrawColorBlack; segs[1].u.l.pos[0] = zero; segs[1].u.l.pos[1] = p2; - trk = NewCompound(T_TURNOUT, 0, p0, a0, message, 3, &tempEndPts(0), (PATHPTR_T)"Normal\0\1\0\0Reverse\0\2\0\0\0", 2, segs); + trk = NewCompound(T_TURNOUT, 0, p0, a0, message, 3, TempEndPt(0), + (PATHPTR_T)"Normal\0\1\0\0Reverse\0\2\0\0\0", 2, segs); xx = GET_EXTRA_DATA(trk, T_TURNOUT, extraDataCompound_t); xx->handlaid = TRUE; @@ -778,9 +661,9 @@ track_p NewHandLaidTurnout( */ static coOrd MapPathPos( - struct extraDataCompound_t* xx, - signed char segInx, - EPINX_T ep) + struct extraDataCompound_t* xx, + signed char segInx, + EPINX_T ep) { trkSeg_p segPtr; coOrd pos; @@ -802,8 +685,9 @@ static coOrd MapPathPos( } static trkSeg_p MapPathSeg( - struct extraDataCompound_t* xx, - signed char segInx) { + struct extraDataCompound_t* xx, + signed char segInx) +{ if (segInx < 0) { segInx = -segInx; @@ -812,1897 +696,30 @@ static trkSeg_p MapPathSeg( } -/**************************************** - * - * TURNOUT DRAWING - * - */ - - /** - * Get the paths from the turnout definition. Puts the results into static dto structure. - * Curved segments are broken up into short sections of the lesser of 5 degrees or 5 * tie spacing. - * - * \param trk track_p pointer to a track - * \param xx pointer to the extraDataCompound struct - * - * \returns the number of paths - */ -int GetTurnoutPaths(track_p trk, struct extraDataCompound_t* xx) { - wIndex_t segInx; - wIndex_t segEP; - - SCALEINX_T scaleInx = GetTrkScale(trk); - tieData_p td = GetScaleTieData(scaleInx); - - int i; - ANGLE_T a0, a1, aa0, aa1; - DIST_T r, len; - coOrd p0, p1; - - PATHPTR_T pp; - int pathCnt = 0, routeCnt = 0; - - for (i = 0; i < DTO_DIM; i++) - dto[i].n = 0; - - dtod.trk = trk; - dtod.index = trk->index; - dtod.xx = xx; - - // Validate that the first segment starts at (0, 0) - // and if STR p1.y == 0, if CRV angle == 0 or angle == 180 - GetSegInxEP(1, &segInx, &segEP); - trkSeg_p segPtr = &xx->segs[segInx]; - switch (segPtr->type) { - case SEG_STRTRK: - p0 = segPtr->u.l.pos[0]; - p1 = segPtr->u.l.pos[1]; - if ((FindDistance(p0, zero) > EPSILON) || (fabs(p1.y) > EPSILON)) - return -1; - break; - case SEG_CRVTRK: - r = fabs(segPtr->u.c.radius); - a0 = segPtr->u.c.a0; - a1 = segPtr->u.c.a1; - - if (segPtr->u.c.radius > 0) { - aa0 = a0; - } - else { - aa0 = a0 + a1; - } - PointOnCircle(&p0, segPtr->u.c.center, r, aa0); - if ((FindDistance(p0, zero) > EPSILON) - || ((fabs(aa0 - 180) > EPSILON) && (fabs(aa0) > EPSILON))) - return -1; - break; - } - - pp = GetPaths(trk); - while (pp[0]) { - pp += strlen((char*)pp) + 1; - - ANGLE_T angle = 0; - while (pp[0]) { - if (pathCnt < DTO_DIM) - dto[pathCnt].type = 'S'; - while (pp[0]) { - GetSegInxEP(pp[0], &segInx, &segEP); - // trkSeg_p - segPtr = &xx->segs[segInx]; - switch (segPtr->type) { - case SEG_STRTRK: - p0 = segPtr->u.l.pos[0]; - p1 = segPtr->u.l.pos[1]; - - wIndex_t n = dto[pathCnt].n; - dto[pathCnt].trkSeg[n] = segPtr; - dto[pathCnt].base[n] = p0; - n++; - dto[pathCnt].trkSeg[n] = segPtr; - dto[pathCnt].base[n] = p1; - // n++; - dto[pathCnt].n = n; - - if (n >= DTO_SEGS - 1) return -1; - - break; - case SEG_CRVTRK: - r = fabs(segPtr->u.c.radius); - - dto[pathCnt].type = segPtr->u.c.center.y < 0 ? 'R' : 'L'; - - a0 = segPtr->u.c.a0; - a1 = segPtr->u.c.a1; - - angle += a1; - - len = D2R(a1) * r; - // Every 5 degrees or 5 * tie spacing - int cnt = (int)floor(a1 / 5.0); - int cnt2 = (int)floor(len / 5 / td->spacing); - if (cnt2 > cnt) cnt = cnt2; - if (cnt <= 0) cnt = 1; - - aa1 = a1 / cnt; - if (dto[pathCnt].type == 'R') { - aa0 = a0; - } - else { - aa0 = a0 + a1; - aa1 = -aa1; - } - PointOnCircle(&p0, segPtr->u.c.center, r, aa0); - n = dto[pathCnt].n; - dto[pathCnt].trkSeg[n] = segPtr; - dto[pathCnt].base[n] = p0; - n++; - dto[pathCnt].n = n; - - while (cnt > 0) { - aa0 += aa1; - PointOnCircle(&p0, segPtr->u.c.center, r, aa0); - - // n = dto[pathCnt].n; - dto[pathCnt].trkSeg[n] = segPtr; - dto[pathCnt].base[n] = p0; - n++; - - if (n >= DTO_SEGS - 1) return -1; - - cnt--; - } - n--; // remove that last point count - dto[pathCnt].n = n; - } - pp++; - } - // Include the last point - dto[pathCnt].crvAngle = angle; - dto[pathCnt].n++; - - pathCnt++; - if (pathCnt > DTO_DIM) return -1; - pp++; - } - routeCnt++; - pp++; - } - dtod.pathCnt = pathCnt; - dtod.routeCnt = routeCnt; - dtod.endCnt = trk->endCnt; - - // Guard value: n < DTO_SEGS - 2 - for (i = 0; i < pathCnt; i++) - dto[i].pts[dto[i].n].x = DIST_INF; - - return pathCnt; -} - -/** -* Sets the turnout type if compatible with enhanced drawing methods. The data is -* from the path data saved in dtod and dto by GetTurnoutPaths. The turnout type is -* stored in the dtod.toType. DTO_INVALID (0) if the enhanced methods cannot handle -* it. -*/ -void GetTurnoutType() { - dtod.strPath = -1; - dtod.str2Path = -1; - dtod.crvPath = -1; - dtod.crv2Path = -1; - - dtod.toType = DTO_INVALID; - - int strCnt = 0, crvCnt = 0, lftCnt = 0, rgtCnt = 0; - enum dtoType toType = DTO_INVALID; - int i, j; - - // Count path origins - dtod.origCnt = 1; - dtod.origins[0] = 0; - - for (i = 1; i < dtod.pathCnt; i++) { - int eq = 0; - for (j = 0; j < i; j++) { - if (CoOrdEqual(dto[dtod.origins[j]].base[0], dto[i].base[0])) - eq++; - } - if (eq == 0) { - dtod.origins[dtod.origCnt] = i; - dtod.origCnt++; - } - - if (dtod.origCnt > 4) - return; - } - - // Determine the path type - for (i = 0; i < dtod.pathCnt; i++) { - switch (dto[i].type) { - case 'S': - strCnt++; - if (strCnt == 1) - dtod.strPath = i; - else - dtod.str2Path = i; - break; - case 'L': - lftCnt++; - crvCnt++; - if (crvCnt == 1) - dtod.crvPath = i; - else - dtod.crv2Path = i; - break; - case 'R': - rgtCnt++; - crvCnt++; - if (crvCnt == 1) - dtod.crvPath = i; - else - dtod.crv2Path = i; - break; - } - } - - dtod.strCnt = strCnt; - dtod.crvCnt = crvCnt; - dtod.lftCnt = lftCnt; - dtod.rgtCnt = rgtCnt; - - // Normal two- or three-way turnout, or a curved turnout - if (dtod.origCnt == 1) { - if (dtod.pathCnt == 2) { - if (strCnt == 1 && crvCnt == 1) { - dtod.toType = DTO_NORMAL; - } - else if ((strCnt == 0) && ((lftCnt == 2) || (rgtCnt == 2))) { - // Assumes outer curve is [0] and inner is [1] - if ((dto[0].crvAngle <= 20) && (dto[1].crvAngle - dto[0].crvAngle <= 15)) - dtod.toType = DTO_CURVED; - } - else if (lftCnt == 1 && rgtCnt == 1) { - dtod.toType = DTO_WYE; - } - } - else if ((dtod.pathCnt == 3) && (strCnt == 1) - && (lftCnt == 1) && (rgtCnt == 1)) { - dtod.toType = DTO_THREE; - } - } - else - // Crossing, single- and double-slip - if ((dtod.origCnt == 2) && (dtod.endCnt == 4) - && strCnt == 2) { - - ANGLE_T a0, a1, a2; - a1 = FindAngle(dto[dtod.strPath].base[0], dto[dtod.strPath].base[1]); - a2 = FindAngle(dto[dtod.str2Path].base[0], dto[dtod.str2Path].base[1]); - // Swap the ends of the strPath if large angle - if((a1 > 180.0) && (dto[dtod.strPath].n == 2)) - { - coOrd tmp = dto[dtod.strPath].base[0]; - dto[dtod.strPath].base[0] = dto[dtod.strPath].base[1]; - dto[dtod.strPath].base[1] = tmp; - - i = dto[dtod.strPath].n - 1; - tmp = dto[dtod.strPath].pts[0]; - dto[dtod.strPath].pts[0] = dto[dtod.strPath].pts[i]; - dto[dtod.strPath].pts[i] = tmp; - - a1 = a1 - 180.0; - dto[dtod.strPath].angle = a1; - } - // Swap the ends of the str2Path if large angle - if((a2 > 180.0) && (dto[dtod.str2Path].n == 2)) - { - coOrd tmp = dto[dtod.str2Path].base[0]; - dto[dtod.str2Path].base[0] = dto[dtod.str2Path].base[1]; - dto[dtod.str2Path].base[1] = tmp; - - i = dto[dtod.str2Path].n - 1; - tmp = dto[dtod.str2Path].pts[0]; - dto[dtod.str2Path].pts[0] = dto[dtod.str2Path].pts[i]; - dto[dtod.str2Path].pts[i] = tmp; - - a2 = a2 - 180.0; - dto[dtod.str2Path].angle = a2; - } - a0 = DifferenceBetweenAngles(a1, a2); - if(a0 < 0) - { - int tmp = dtod.strPath; - dtod.strPath = dtod.str2Path; - dtod.str2Path = tmp; - a0 = NormalizeAngle(-a0); - } - if ((a0 > 90.0) || (a0 < 0.0)) - return; - - coOrd p1 = dto[dtod.strPath].base[0]; - coOrd p2 = dto[dtod.str2Path].base[0]; - coOrd pos = zero; - int intersect = FindIntersection(&pos, p1, a1, p2, a2); - - if (intersect) { - if(strCnt == 2 && dtod.pathCnt == 2){ - if((a0 <= 61) && (a0 >= -61)) - dtod.toType = DTO_XING; - else - dtod.toType = DTO_XNG9; - } - else if(dtod.pathCnt == 3 && (lftCnt == 1 || rgtCnt == 1)){ - dtod.toType = DTO_SSLIP; - } - else if(dtod.pathCnt == 4 && lftCnt == 1 && rgtCnt == 1){ - dtod.toType = DTO_DSLIP; - } - } - // No intersect, it could be a crossover - else if (strCnt == 2) { - if (dtod.pathCnt == 4 && lftCnt == 1 && rgtCnt == 1) { - dtod.toType = DTO_DCROSS; - } - else if(dtod.pathCnt == 3){ - // Perverse test because the cross paths go Left then Right, for example - if(lftCnt == 1){ - dtod.toType = DTO_RCROSS; - } - else if(rgtCnt == 1){ - dtod.toType = DTO_LCROSS; - } - else{ - dtod.toType = DTO_INVALID; - } - } - } - } -} - -/** - * Draw Layout lines and points - * - * \param d The drawing object - * \param scaleInx The layout/track scale index - */ -static void DrawDtoLayout( - drawCmd_p d, - SCALEINX_T scaleInx -) -{ - tieData_p td; - td = GetScaleTieData(scaleInx); - - // Draw the points and lines from dto - double r = td->width / 2; - // if (r < 1) r = 1; - - int i, j; - for (i = 0; i < DTO_DIM; i++) { - for (j = 0; j < dto[i].n; j++) { - DrawFillCircle(d, dto[i].pts[j], r, drawColorPurple); - if (j < dto[i].n - 1) - DrawLine(d, dto[i].pts[j], dto[i].pts[j + 1], 0, drawColorPurple); - } - } -} - -/** -* Use the coOrds to build a polygon and draw the bridge fill. Note that the coordinates are -* passed as pairs, and rearranged into a polygon with the 1,2,4,3 order. -* -* \param d The drawing object -* \param b1 The first coordinate -* \param b2 The second coordinate -* \param b3 The third coordinate -* \param b4 The fourth coordinate -*/ -static void DrawBridgeFill( - drawCmd_p d, - coOrd b1, - coOrd b2, - coOrd b3, - coOrd b4 - ) -{ - coOrd p[4] = {b1, b2, b4, b3}; - DrawPoly(d,4,p,NULL,drawColorGrey90,0,DRAW_FILL ); -} - -/** -* Draw Bridge parapets and background for a turnout -* -* \param d The drawing object -* \param path1 The first path -* \param path2 The second path -*/ -static void DrawTurnoutBridge( - drawCmd_p d, - int path1, - int path2 -) -{ - DIST_T trackGauge = GetTrkGauge(dtod.trk); - wDrawWidth width2 = (wDrawWidth)round((2.0 * d->dpi) / BASE_DPI); - if (d->options&DC_PRINT) - width2 = (wDrawWidth)round(d->dpi / BASE_DPI); - - coOrd b1,b2,b3,b4,b5,b6; - ANGLE_T angle = dtod.xx->angle,a = 0.0; - int i,j,i1,i2; - i1 = path1; - i2 = path2; - if(dto[i1].base[dto[i1].n - 1].y < dto[i2].base[dto[i2].n - 1].y) { - i1 = path2; - i2 = path1; - // a = -a; - } - - if(dtod.toType == DTO_THREE) { - i = dtod.strPath; - DIST_T dy = fabs(dto[i].dy[0]) + trackGauge * 1.5; - b1 = dto[i].pts[0]; - Translate(&b3,b1,(angle + a),dy); - b1 = dto[i].pts[dto[i].n - 1]; - Translate(&b4,b1,(angle + a),dy); - b2 = dto[i].pts[0]; - Translate(&b5,b2,(angle + a),-dy); - b2 = dto[i].pts[dto[i].n - 1]; - Translate(&b6,b2,(angle + a),-dy); - - // Draw the bridge background - DrawBridgeFill(d,b3,b4,b5,b6); - } - - for(i = i1; 1; i = i2,a = 180.0) { - DIST_T dy = fabs(dto[i].dy[0]) + trackGauge * 1.5; - b1 = dto[i].pts[0]; - Translate(&b3,b1,(angle + a),dy); - Translate(&b5,b1,(angle + a),-(dy * 0.75)); - for(j = 1; j < dto[i].n; j++) { - dy = fabs(dto[i].dy[j]) + trackGauge * 1.5; - b2 = dto[i].pts[j]; - Translate(&b4,b2,(angle + a),dy); - Translate(&b6,b2,(angle + a),-(dy * 0.75)); - - // Draw the bridge background - DrawBridgeFill(d,b3,b4,b5,b6); - - // Draw the bridge edge - DrawLine(d,b3,b4,width2,drawColorBlack); - - b1 = b2; - b3 = b4; - b5 = b6; - } - - if(i == i2) - break; - } - - EPINX_T ep; - coOrd p; - track_p trk1; - coOrd p0,p1; - - for(ep = 0; ep < 3; ep++) { - trk1 = GetTrkEndTrk(dtod.trk,ep); - - if((trk1) && (!GetTrkBridge(trk1))) { - - p = GetTrkEndPos(dtod.trk,ep); - a = GetTrkEndAngle(dtod.trk,ep) + 90.0; - - int i = (dtod.lftCnt > 0) && (dtod.rgtCnt == 0) ? 2 : 1; - if(ep != i) { - Translate(&p0,p,a,trackGauge * 1.5); - Translate(&p1,p0,a - 45.0,trackGauge * 1.5); - DrawLine(d,p0,p1,width2,drawColorBlack); - } - if(ep != (3 - i)) { - Translate(&p0,p,a,-trackGauge * 1.5); - Translate(&p1,p0,a + 45.0,-trackGauge * 1.5); - DrawLine(d,p0,p1,width2,drawColorBlack); - } - } - } -} - -/** -* Draw Bridge parapets and background for a cross-over -* -* \param d The drawing object -* \param path1 The first path, straight -* \param path2 The second path, straight -*/ -static void DrawCrossBridge( - drawCmd_p d, - int path1, - int path2 -) -{ - DIST_T trackGauge = GetTrkGauge(dtod.trk); - wDrawWidth width2 = (wDrawWidth)round((2.0 * d->dpi)/BASE_DPI); - if (d->options&DC_PRINT) - width2 = (wDrawWidth)round(d->dpi / BASE_DPI); - - coOrd b1, b2, b3, b4, b5, b6; - ANGLE_T angle = dtod.xx->angle, a = 0.0; - int i1, i2; - i1 = path1; - i2 = path2; - if(dto[i1].base[dto[i1].n - 1].y < dto[i2].base[dto[i2].n - 1].y) { - i1 = path2; - i2 = path1; - // a = -a; - } - - DIST_T dy = fabs(dto[i1].dy[0]) + trackGauge * 1.5; - b1 = dto[i1].pts[0]; - Translate(&b3,b1,(angle + a),dy); - b1 = dto[i1].pts[dto[i1].n-1]; - Translate(&b4,b1,(angle + a),dy); - b2 = dto[i2].pts[0]; - Translate(&b5,b2,(angle + a),-dy); - b2 = dto[i2].pts[dto[i2].n-1]; - Translate(&b6,b2,(angle + a),-dy); - - // Draw the bridge background - DrawBridgeFill(d, b3, b4, b5, b6); - - // Draw the bridge edges - DrawLine(d,b3,b4,width2,drawColorBlack); - DrawLine(d,b5,b6,width2,drawColorBlack); - - EPINX_T ep; - coOrd p; - track_p trk1; - coOrd p0,p1; - - for(ep = 0; ep < 4; ep++) { - trk1 = GetTrkEndTrk(dtod.trk,ep); - - if((trk1) && (!GetTrkBridge(trk1))) { - p = GetTrkEndPos(dtod.trk,ep); - a = GetTrkEndAngle(dtod.trk,ep) + 90.0; - - if((ep == 1) || (ep == 2)) { - Translate(&p0,p,a,trackGauge * 1.5); - Translate(&p1,p0,a - 45.0,trackGauge * 1.5); - DrawLine(d,p0,p1,width2,drawColorBlack); - } - if((ep == 0) || (ep == 3)) { - Translate(&p0,p,a,-trackGauge * 1.5); - Translate(&p1,p0,a + 45.0,-trackGauge * 1.5); - DrawLine(d,p0,p1,width2,drawColorBlack); - } - } - } -} - -/** -* Draw Bridge parapets and background for a crossing -* -* \param d The drawing object -* \param path1 The first path -* \param path2 The second path -*/ -static void DrawXingBridge( - drawCmd_p d, - int path1, - int path2 -) -{ - DIST_T trackGauge = GetTrkGauge(dtod.trk); - wDrawWidth width2 = (wDrawWidth)round((2.0 * d->dpi)/BASE_DPI); - if (d->options&DC_PRINT) - width2 = (wDrawWidth)round(d->dpi / BASE_DPI); - - coOrd b0, b1, b2, b3, b4, b5, b6; - int i, j, i1, i2; - i1 = dtod.strPath; - i2 = dtod.str2Path; - - // Bridge fill both straight sections - wDrawWidth width3 = (wDrawWidth)round(trackGauge * 3 * d->dpi/d->scale); - b1 = dto[i1].pts[0]; - b2 = dto[i1].pts[dto[i1].n-1]; - DrawLine(d,b1,b2,width3,wDrawColorGrey90); - b1 = dto[i2].pts[0]; - b2 = dto[i2].pts[dto[i1].n-1]; - DrawLine(d,b1,b2,width3,wDrawColorGrey90); - - i1 = path1; - i2 = path2; - if(dto[i1].base[dto[i1].n - 1].y < dto[i2].base[dto[i2].n - 1].y) { - i1 = path2; - i2 = path1; - } - - // Handle curved sections for slips - BOOL_T hasLeft = 0, hasRgt = 0; - ANGLE_T angle = dtod.xx->angle, a = 0.0; - for(i = i1; 1; i = i2,a = 180.0) { - DIST_T dy = fabs(dto[i].dy[0]) + trackGauge * 1.5; - b1 = dto[i].pts[0]; - Translate(&b3,b1,(angle + a),dy); - Translate(&b5,b1,(angle + a),-(dy * 0.75)); - if(dto[i].type != 'S') { - if(dto[i].type == 'L') - hasLeft = 1; - else if(dto[i].type == 'R') - hasRgt = 1; - for(j = 1; j < dto[i].n; j++) { - dy = fabs(dto[i].dy[j]) + trackGauge * 1.5; - b2 = dto[i].pts[j]; - Translate(&b4,b2,(angle + a),dy); - Translate(&b6,b2,(angle + a),-(dy * 0.75)); - - // Draw the bridge background - DrawBridgeFill(d,b3,b4,b5,b6); - - // Draw the bridge edge - DrawLine(d,b3,b4,width2,drawColorBlack); - b1 = b2; - b3 = b4; - b5 = b6; - } - } - if(i == i2) - break; - } - - if(dtod.strPath >= 0 && dtod.str2Path >= 0) { - i1 = dtod.strPath; - i2 = dtod.str2Path; - if(!hasRgt) { - DIST_T dy = trackGauge * 1.5; - ANGLE_T a1, a2; - b1 = dto[i1].pts[0]; - a1 = dto[i1].angle + 90; - Translate(&b3,b1,a1,dy); - - b2 = dto[i2].pts[dto[i2].n - 1]; - a2 = dto[i2].angle + 90; - Translate(&b4,b2,a2,dy); - - FindIntersection(&b0, b3, a1-90.0, b4, a2-90.0); - - // Draw the bridge edge - DrawLine(d,b3,b0,width2,drawColorBlack); - DrawLine(d,b0,b4,width2,drawColorBlack); - } - - if(!hasLeft) { - DIST_T dy = trackGauge * 1.5; - ANGLE_T a1, a2; - b1 = dto[i2].pts[0]; - a1 = dto[i2].angle - 90; - Translate(&b3,b1,a1,dy); - - b2 = dto[i1].pts[dto[i1].n - 1]; - a2 = dto[i1].angle - 90; - Translate(&b4,b2,a2,dy); - - FindIntersection(&b0, b3, a1+90.0, b4, a2+90.0); - - // Draw the bridge edge - DrawLine(d,b3,b0,width2,drawColorBlack); - DrawLine(d,b0,b4,width2,drawColorBlack); - } - - if(dtod.toType == DTO_XNG9) { - DIST_T dy = trackGauge * 1.5; - ANGLE_T a1, a2; - b1 = dto[i1].pts[dto[i1].n - 1]; - a1 = dto[i1].angle + 90; - Translate(&b3,b1,a1,dy); - - b2 = dto[i2].pts[dto[i2].n - 1]; - a2 = dto[i2].angle - 90; - Translate(&b4,b2,a2,dy); - - FindIntersection(&b0, b3, a1-90.0, b4, a2+90.0); - - // Draw the bridge edge - DrawLine(d,b3,b0,width2,drawColorBlack); - DrawLine(d,b0,b4,width2,drawColorBlack); - - b1 = dto[i1].pts[0]; - a1 = dto[i1].angle - 90; - Translate(&b3,b1,a1,dy); - - b2 = dto[i2].pts[0]; - a2 = dto[i2].angle + 90; - Translate(&b4,b2,a2,dy); - - FindIntersection(&b0, b3, a1+90.0, b4, a2-90.0); - - // Draw the bridge edge - DrawLine(d,b3,b0,width2,drawColorBlack); - DrawLine(d,b0,b4,width2,drawColorBlack); - } - } - - // Bridge wings - EPINX_T ep; - coOrd p; - track_p trk1; - coOrd p0,p1; - - for(ep = 0; ep < 4; ep++) { - trk1 = GetTrkEndTrk(dtod.trk,ep); - - if((trk1) && (!GetTrkBridge(trk1))) { - p = GetTrkEndPos(dtod.trk,ep); - a = GetTrkEndAngle(dtod.trk,ep) + 90.0; - - if((dtod.toType == DTO_XNG9) || (ep == 2) || (ep == 3)) { - Translate(&p0,p,a,trackGauge * 1.5); - Translate(&p1,p0,a - 45.0,trackGauge * 1.5); - DrawLine(d,p0,p1,width2,drawColorBlack); - } - if((dtod.toType == DTO_XNG9) || (ep == 0) || (ep == 1)) { - Translate(&p0,p,a,-trackGauge * 1.5); - Translate(&p1,p0,a + 45.0,-trackGauge * 1.5); - DrawLine(d,p0,p1,width2,drawColorBlack); - } - } - } -} - -/** - * Init Normal Turnout data structure - * Calculates the dy value of each segment - * Sets pts values REORIGIN base to actual position and angle - * Save often used last base and last point coOrd - */ -static void DrawDtoInit() -{ - struct extraDataCompound_t* xx = dtod.xx; - coOrd p1; - int i, j; - - for(i = 0; i < DTO_DIM; i++) { - int n = dto[i].n; - for(j = 0; j < n; j++) { - REORIGIN(p1,dto[i].base[j],xx->angle,xx->orig); - dto[i].pts[j] = p1; - if(j < n - 1) - dto[i].dy[j] = (dto[i].base[j + 1].y - dto[i].base[j].y) / (dto[i].base[j + 1].x - dto[i].base[j].x); - } - dto[i].ptsLast = dto[i].pts[n - 1]; - dto[i].baseLast = dto[i].base[n - 1]; - } -} - -/** - * Draw Normal (Single Origin) Turnout Bridge and Ties. Uses the static dto and dtod structures. - * - * \param d The drawing object - * \param scaleInx The layout/track scale index - * \param color The tie color. If black the color is read from the global tieColor. - */ -static void DrawNormalTurnout( - drawCmd_p d, - SCALEINX_T scaleInx, - BOOL_T omitTies, - wDrawColor color) -{ - tieData_p td; - DIST_T len; - coOrd pos; - int cnt; - ANGLE_T angle; - coOrd s1, s2, p1, p2, q1, q2; - int s0, p0, q0; - ANGLE_T a0; - - if (color == wDrawColorBlack) - color = tieColor; - - DIST_T trackGauge = GetTrkGauge(dtod.trk); - - DrawDtoInit(); - - // draw the points -#ifdef DTO_DEBUG - if (DTO_DEBUG == DTO_NORMAL) DrawDtoLayout(d, scaleInx); -#endif - - int strPath = dtod.strPath, othPath = 0, secPath = 1; - int toType = dtod.toType; - int first = 1; - - switch (toType) { - case DTO_NORMAL: - othPath = 1 - strPath; - secPath = strPath; - break; - case DTO_WYE: - // strPath = 2; - othPath = 0; secPath = 1; - break; - case DTO_THREE: - switch (strPath) { - case 0: - othPath = 1; secPath = 2; - break; - case 1: - othPath = 0; secPath = 2; - break; - case 2: - othPath = 0; secPath = 1; - break; - } - break; - } - - if(dtod.bridge) { - DrawTurnoutBridge(d,othPath,secPath); - } - if (omitTies) - return; - - // Straight vector for tie angle - if (toType == DTO_WYE) { - s1 = dto[othPath].pts[0]; - s2 = MidPtCoOrd(dto[othPath].ptsLast, dto[secPath].ptsLast); - } - else { - s1 = dto[strPath].pts[0]; - s2 = dto[strPath].ptsLast; - } - // Diverging vector(s) - p1 = dto[othPath].pts[0]; - p2 = dto[othPath].ptsLast; - q1 = dto[secPath].pts[0]; - q2 = dto[secPath].ptsLast; - - td = GetScaleTieData(scaleInx); - len = FindDistance(s1, s2); - angle = FindAngle(s1, s2); // The straight segment - - cnt = (int)floor(len / td->spacing + 0.5); - if (cnt > 0) { - int pn = dto[othPath].n; - int qn = dto[secPath].n; - DIST_T dx = len / cnt; - s0 = p0 = q0 = 0; - DIST_T tdlen = td->length; - DIST_T tdmax = (toType == DTO_WYE) ? 2.0 * tdlen : 2.5 * tdlen; - DIST_T px = len, dlenx = dx / 2; - - cnt = cnt > 1 ? cnt - 1 : 1; - for (px = dlenx; cnt; cnt--, px += dx) { - if (px >= dto[othPath].base[p0 + 1].x) p0++; - if (px >= dto[secPath].base[q0 + 1].x) q0++; - if (p0 >= pn || q0 >= qn) - break; - - if ((px + dx >= dto[othPath].baseLast.x) || (px + dx >= dto[secPath].baseLast.x)) { - break; - } - - DIST_T dy1 = dto[othPath].base[p0].y + (px - dto[othPath].base[p0].x) * dto[othPath].dy[p0]; - DIST_T dy2 = dto[secPath].base[q0].y + (px - dto[secPath].base[q0].x) * dto[secPath].dy[q0]; - tdlen = td->length + fabs(dy1) + fabs(dy2); - if (tdlen > tdmax) - break; - - DIST_T dy = dy1 + dy2; - Translate(&pos, s1, angle, px); - Translate(&pos, pos, (angle - 90.0), dy / 2); - - DrawTie(d, pos, angle, tdlen, td->width, color, tieDrawMode == TIEDRAWMODE_SOLID); - } - - // Asymmetric? Use longer ties for remaining two tracks (strPath, othPath) - DIST_T sx = px; // Save these values for second code block - int s0 = p0; - if((dtod.toType == DTO_THREE) && (px + dx >= dto[secPath].baseLast.x)){ - for ( ; cnt; cnt--, px += dx) { - if (px >= dto[othPath].base[p0 + 1].x) p0++; - // if (px >= dto[secPath].base[q0 + 1].x) q0++; - if (p0 >= pn) - break; - - if (px + dx >= dto[othPath].baseLast.x) { - break; - } - - DIST_T dy1 = dto[othPath].base[p0].y + (px - dto[othPath].base[p0].x) * dto[othPath].dy[p0]; - tdlen = td->length + fabs(dy1); - if (tdlen > tdmax) - break; - - DIST_T dy = dy1; - Translate(&pos, s1, angle, px); - Translate(&pos, pos, (angle - 90.0), dy / 2); - - DrawTie(d, pos, angle, tdlen, td->width, color, tieDrawMode == TIEDRAWMODE_SOLID); - } - } - - // Draw remaining ties, if any - if (px + dx < dto[othPath].baseLast.x){ - p1 = dto[othPath].pts[p0]; - p2 = dto[othPath].ptsLast; - angle = FindAngle(p1, p2); - a0 = FindAngle(dto[othPath].base[p0], dto[othPath].baseLast); - DIST_T lenr = (dto[othPath].baseLast.x - px + dlenx) / cos(D2R(90.0 - a0)); - Translate(&p1, p2, angle, -lenr); - DrawStraightTies(d, scaleInx, p1, p2, color); - } - else { - p1 = dto[othPath].pts[pn - 2]; - a0 = FindAngle(p1, p2); - Translate(&pos, p2, a0, -dx / 2); - DrawTie(d, pos, a0, td->length, td->width, color, tieDrawMode == TIEDRAWMODE_SOLID); - } - // Restore saved values - if(dtod.toType == DTO_THREE){ - px = sx; - p0 = s0; - } - - // Asymmetric? Use longer ties for remaining two tracks (strPath, secPath) - if((dtod.toType == DTO_THREE) && (px + dx >= dto[othPath].baseLast.x)){ - for ( ; cnt; cnt--, px += dx) { - // if (px >= dto[othPath].base[p0 + 1].x) p0++; - if (px >= dto[secPath].base[q0 + 1].x) q0++; - if (q0 >= qn) - break; - - if (px + dx >= dto[secPath].baseLast.x) { - break; - } - - DIST_T dy1 = dto[secPath].base[q0].y + (px - dto[secPath].base[q0].x) * dto[secPath].dy[q0]; - tdlen = td->length + fabs(dy1); - if (tdlen > tdmax) - break; - - DIST_T dy = dy1; - Translate(&pos, s1, angle, px); - Translate(&pos, pos, (angle - 90.0), dy / 2); - - DrawTie(d, pos, angle, tdlen, td->width, color, tieDrawMode == TIEDRAWMODE_SOLID); - } - } - if (px + dx < dto[secPath].baseLast.x) { - q1 = dto[secPath].pts[q0]; - q2 = dto[secPath].ptsLast; - angle = FindAngle(q1, q2); - a0 = FindAngle(dto[secPath].base[q0], dto[secPath].baseLast); - DIST_T lenr = (dto[secPath].baseLast.x - px + dlenx) / cos(D2R(90.0 - a0)); - Translate(&q1, q2, angle, -lenr); - DrawStraightTies(d, scaleInx, q1, q2, color); - } - else { - q1 = dto[secPath].pts[qn - 2]; - a0 = FindAngle(q1, q2); - Translate(&pos, q2, a0, -dx / 2); - DrawTie(d, pos, a0, td->length, td->width, color, tieDrawMode == TIEDRAWMODE_SOLID); - } - - // Final ties at end - if (dtod.toType == DTO_THREE) { - - int n = (int)(dto[strPath].baseLast.x); - if (px + dx < len) { - angle = FindAngle(s1, s2); - DIST_T lenr = len - px + dlenx; - Translate(&s1, s2, angle, -lenr); - DrawStraightTies(d, scaleInx, s1, s2, color); - } - else { - n = dto[strPath].n; - s1 = dto[strPath].pts[n - 2]; - a0 = FindAngle(s1, s2); - Translate(&pos, s2, a0, -dx / 2); - DrawTie(d, pos, a0, td->length, td->width, color, tieDrawMode == TIEDRAWMODE_SOLID); - } - } - } -} - -/** - * Draw Curved (Single Origin) Turnout Bridge and Ties. Uses the static dto and dtod structures. - * - * \param d The drawing object - * \param scaleInx The layout/track scale index - * \param color The tie color. If black the color is read from the global tieColor. - */ -static void DrawCurvedTurnout( - drawCmd_p d, - SCALEINX_T scaleInx, - BOOL_T omitTies, - wDrawColor color) -{ - tieData_p td; - DIST_T len, r; - coOrd pos; - int cnt; - ANGLE_T angle, dang; - coOrd center; - coOrd p1, p2, q1, q2; - ANGLE_T a0, a1, a2; - struct extraDataCompound_t* xx = dtod.xx; - - if (color == wDrawColorBlack) - color = tieColor; - - DrawDtoInit(); - - // draw the points -#ifdef DTO_DEBUG - if (DTO_DEBUG == DTO_CURVED) DrawDtoLayout(d, scaleInx); -#endif - - int othPath = 0, secPath = 1; - int toType = dtod.toType; - - if(dtod.bridge) { - DrawTurnoutBridge(d,othPath,secPath); - } - if (omitTies) - return; - - td = GetScaleTieData(scaleInx); - - // Save the ending coordinates - coOrd othEnd = zero, secEnd = zero; - - trkSeg_p trk; - DIST_T tdlen = td->length, tdmax = tdlen * 2.5; - DIST_T tdspc = td->spacing, tdspc2 = tdspc / 2.0; - double rdot = td->width / 2; - - int pn = dto[othPath].n; - int qn = dto[secPath].n; - int p0 = 0, q0 = 0; - DIST_T px = 0, qx = 0, dy = 0, dy1 = 0, dy2 = 0; - - double cosAdj = 1.0; - - angle = 0; - px = tdspc2; - qx = tdspc2; - int segs = max(dto[othPath].n, dto[secPath].n); - for (; segs > 0; segs--) { - - if (px >= dto[othPath].base[p0 + 1].x) - p0++; - if (qx >= dto[secPath].base[q0 + 1].x) - q0++; - if ((p0 >= pn - 1) || (q0 >= qn - 1)) { - break; - } - - trk = dto[othPath].trkSeg[p0]; - if (trk->type == SEG_CRVTRK) { - - center = trk->u.c.center; - r = fabs(trk->u.c.radius); - a0 = NormalizeAngle(trk->u.c.a0 + dtod.xx->angle); - a1 = trk->u.c.a1; - - pos = center; - REORIGIN(center, pos, xx->angle, xx->orig); - - len = r * D2R(a1); - cnt = (int)floor(len / tdspc + 0.5); - if (len - tdspc * cnt >= tdspc2) { - cnt++; - } - DIST_T tdlen = td->length; - DIST_T dx = len / cnt, dx2 = dx / 2; - - if (cnt != 0) { - dang = (len / cnt) * 360 / (2 * M_PI * r); - DIST_T dx = len / cnt, dx2 = dx / 2; - - if (dto[othPath].type == 'R') { - a2 = a0 + dang / 2; - } - else { - a2 = a0 + a1 - dang / 2; - dang = -dang; - } - angle += fabs(dang / 2); - - cosAdj = fabs(cos(D2R(angle))); - px += dx2 * cosAdj; - qx += dx2 * cosAdj; - - for (; cnt; cnt--, a2 += dang, angle += dang) { - if (px >= dto[othPath].base[p0 + 1].x) - p0++; - if (qx >= dto[secPath].base[q0 + 1].x) - q0++; - if ((p0 >= pn - 1) || (q0 >= qn - 1)) { - break; - } - - coOrd e1, e2; - PointOnCircle(&e1, center, r, a2); - - q1 = dto[secPath].pts[q0]; - q2 = dto[secPath].pts[q0 + 1]; - FindIntersection(&e2, e1, a2, q1, FindAngle(q1, q2)); - - dy = FindDistance(e1, e2); - DIST_T tlen = tdlen + dy; - - if (tlen > tdmax) { - break; - } - - Translate(&pos, e1, a2, -dy / 2); - DrawTie(d, pos, angle + xx->angle + 90, tlen, td->width, color, tieDrawMode == TIEDRAWMODE_SOLID); - - // Assures that these ends are the last point drawn before break - othEnd = e1; - secEnd = e2; - - cosAdj = fabs(cos(D2R(angle))); - if (cnt > 1) { - px += dx * cosAdj; - qx += dx * cosAdj; - } - else { - px += dx2 * cosAdj; - qx += dx2 * cosAdj; - } - } - } - } - else { - cosAdj = fabs(cos(D2R(angle))); - - p1 = dto[othPath].base[p0]; - p2 = dto[othPath].base[p0 + 1]; - len = FindDistance(p1, p2); - cnt = (int)floor(len / tdspc + 0.6); - if (cnt > 0) { - DIST_T dx = len / cnt, dx2 = dx / 2; - - for (; cnt; cnt--) { - if (px >= dto[othPath].base[p0 + 1].x) - p0++; - if (qx >= dto[secPath].base[q0 + 1].x) - q0++; - if ((p0 >= pn - 1) || (q0 >= qn - 1)) { - break; - } - - p1 = dto[othPath].base[p0]; - p2 = dto[othPath].base[p0 + 1]; - - if ((px >= dto[othPath].baseLast.x) - || (qx >= dto[secPath].baseLast.x)) { - break; - } - - dy1 = dto[secPath].base[q0].y + (qx - dto[secPath].base[q0].x) * dto[secPath].dy[q0]; - dy2 = dto[othPath].base[p0].y + (px - dto[othPath].base[p0].x) * dto[othPath].dy[p0]; - dy = dy1 - dy2; - DIST_T tlen = tdlen + fabs(cosAdj * dy); - if (tlen > tdmax) { - break; - } - - q1 = dto[secPath].pts[q0]; - q2 = dto[secPath].pts[q0 + 1]; - a1 = FindAngle(q1, q2); - DIST_T xlen = qx - dto[secPath].base[q0].x; - Translate(&pos, q1, a1, xlen); - secEnd = pos; - - q1 = dto[othPath].pts[p0]; - q2 = dto[othPath].pts[p0 + 1]; - a1 = FindAngle(q1, q2); - xlen = px - dto[othPath].base[p0].x; - Translate(&pos, q1, a1, xlen); - othEnd = pos; - - Translate(&pos, pos, (a1 - 90.0), dy / 2); - DrawTie(d, pos, a1, tlen, td->width, color, tieDrawMode == TIEDRAWMODE_SOLID); - - cosAdj = fabs(cos(D2R(angle))); - px += dx * cosAdj; - qx += dx * cosAdj; - } - } - else { - break; - } - } - } - -#ifdef DTO_DEBUG - if (DTO_DEBUG == DTO_CURVED) { - DrawFillCircle(d, othEnd, rdot, drawColorGreen); - DrawFillCircle(d, secEnd, rdot, drawColorGreen); - - DrawFillCircle(d, dto[othPath].pts[p0], rdot, drawColorBlue); - DrawFillCircle(d, dto[secPath].pts[q0], rdot, drawColorBlue); - } -#endif - - // Draw remaining ties, if any - p1 = othEnd; - p2 = dto[othPath].ptsLast; - a0 = FindAngle(p1, p2); - len = FindDistance(p1, p2); - if (len >= 2 * tdspc) { - Translate(&p1, p1, a0, tdspc2); - DrawStraightTies(d, scaleInx, p1, p2, color); - } - else if (len > tdspc2) { - Translate(&p2, p2, a0, -tdspc2); - DrawTie(d, p2, a0, td->length, td->width, color, tieDrawMode == TIEDRAWMODE_SOLID); - } - - q1 = secEnd; - q2 = dto[secPath].ptsLast; - a0 = FindAngle(q1, q2); - len = FindDistance(q1, q2); - if (len >= 2 * tdspc) { - Translate(&q1, q1, a0, tdspc2); - DrawStraightTies(d, scaleInx, q1, q2, color); - } - else if (len > tdspc2) { - Translate(&q2, q2, a0, -tdspc2); - DrawTie(d, q2, a0, td->length, td->width, color, tieDrawMode == TIEDRAWMODE_SOLID); - } -} - -/** - * Draw Crossing and Slip Turnout Bridge and Ties - Uses the static dto and dtod structures. - * - * \param d The drawing object - * \param scaleInx The layout/track scale index - * \param color The tie color. If black the color is read from the global tieColor. - */ -static void DrawXingTurnout( - drawCmd_p d, - SCALEINX_T scaleInx, - BOOL_T omitTies, - wDrawColor color) -{ - tieData_p td; - DIST_T len; - coOrd pos; - int cnt; - ANGLE_T cAngle; - - if (color == wDrawColorBlack) - color = tieColor; - - coOrd c1, c2, s1, s2, p1, p2, q1; - int p0, q0; - ANGLE_T a0, a1, a2; - int strPath = dtod.strPath, str2Path = dtod.str2Path; - - struct extraDataCompound_t* xx = dtod.xx; - - DrawDtoInit(); - - dto[strPath].angle = FindAngle(dto[strPath].pts[0], dto[strPath].ptsLast); - dto[str2Path].angle = FindAngle(dto[str2Path].pts[0], dto[str2Path].ptsLast); - - int othPath = strPath, secPath = str2Path; - int toType = dtod.toType; - - int i, j; - switch (toType) { - case DTO_XING: - case DTO_XNG9: - break; - case DTO_SSLIP: - for (i = 0; i < dtod.pathCnt; i++) { - if (dto[i].type == 'L' || dto[i].type == 'R') { - secPath = i; - break; - } - } - break; - case DTO_DSLIP: - for (i = 0; i < dtod.pathCnt; i++) { - if (dto[i].type == 'L') { - othPath = i; - } - else if (dto[i].type == 'R') { - secPath = i; - } - } - break; - } - - if(dtod.bridge) { - DrawXingBridge(d,othPath,secPath); - } - // draw the points -#ifdef DTO_DEBUG - if (DTO_DEBUG == DTO_XING) DrawDtoLayout(d, scaleInx); -#endif - - if (omitTies) - return; - - td = GetScaleTieData(scaleInx); - DIST_T tdlen = td->length, tdmax = 2.0 * tdlen; - DIST_T tdspc = td->spacing, tdspc2 = tdspc / 2; - - // Midpoint - p1 = dto[strPath].pts[0]; - a1 = dto[strPath].angle; - - q1 = dto[str2Path].pts[0]; - a2 = dto[str2Path].angle; - - FindIntersection(&pos, p1, a1, q1, a2); - dtod.midPt = pos; - -#ifdef DTO_DEBUG - if(DTO_DEBUG == DTO_XING) - { - double r = td->width / 2; - DrawFillCircle(d,p1,r,drawColorPurple); - DrawFillCircle(d,q1,r,drawColorPurple); - DrawFillCircle(d,dtod.midPt,r,drawColorPurple); - } -#endif - - // Tie length adjust - double dAngle = fabs(DifferenceBetweenAngles(a1, a2)); - double magic = 1.0; - - // Short circuit the complex code for this simple case - if (toType == DTO_XNG9) { - p1 = dto[strPath].pts[0]; - p2 = dto[strPath].ptsLast; - DrawStraightTies(d, scaleInx, p1, p2, color); - - p1 = dto[str2Path].pts[0]; - p2 = dto[str2Path].ptsLast; - - // Omit the center ties - magic = 1 / cos(D2R(90 - dAngle)); - DIST_T tdadj = (tdlen / 2) * magic; - DIST_T tdadj2 = tdspc2 * magic; - - dAngle = (dAngle - 90) / 2; - Translate(&pos, dtod.midPt, a2, -tdadj - tdadj2); - DrawTie(d, pos, a2 - dAngle, tdlen, td->width, color, tieDrawMode == TIEDRAWMODE_SOLID); - - Translate(&pos, dtod.midPt, a2, -tdadj - tdspc); - DrawStraightTies(d, scaleInx, p1, pos, color); - - Translate(&pos, dtod.midPt, a2, tdadj + tdadj2); - DrawTie(d, pos, a2 - dAngle, tdlen, td->width, color, tieDrawMode == TIEDRAWMODE_SOLID); - - Translate(&pos, dtod.midPt, a2, tdadj + tdspc); - DrawStraightTies(d, scaleInx, pos, p2, color); - return; - } - - // Straight vector for tie angle - s1 = MidPtCoOrd(dto[strPath].base[0], dto[str2Path].base[0]); - s2 = MidPtCoOrd(dto[strPath].baseLast, dto[str2Path].baseLast); - - // Rotate base coordinates so that the tie line is aligned with x-axis and origin is at zero - cAngle = FindAngle(s1, s2); - for (i = 0; i < DTO_DIM; i++) - for (j = 0; j < dto[i].n; j++) { - dto[i].base[j].x -= s1.x; - dto[i].base[j].y -= s1.y; - Rotate(&dto[i].base[j], zero, (90.0 - cAngle)); - } - - for (i = 0; i < DTO_DIM; i++) { - for (j = 0; j < dto[i].n - 1; j++) { - dto[i].dy[j] = (dto[i].base[j + 1].y - dto[i].base[j].y) / (dto[i].base[j + 1].x - dto[i].base[j].x); - } - if (dto[i].type == 'S') - dto[i].angle = FindAngle(dto[i].pts[0], dto[i].ptsLast); - } - - // Tie center line in drawing coordinates - REORIGIN(c1, s1, xx->angle, xx->orig); - REORIGIN(c2, s2, xx->angle, xx->orig); - cAngle = FindAngle(c1, c2); - - int pn = dto[othPath].n; - int qn = dto[secPath].n; - - // Tie length adjust - magic = 1 / cos(0.5 * D2R(dAngle)); - // Extra ties length adjust - double magic2 = 1.0 / cos(0.5 * D2R(dAngle)); - - // Draw right half - len = FindDistance(dtod.midPt, c2); - cnt = (int)floor(len / td->spacing + 0.5); - if (cnt <= 0) - return; - - DIST_T dx = len / cnt; - p0 = q0 = 0; - DIST_T dx2 = dx / 2; - DIST_T px = len + dx2; - DIST_T lenx = 0; - - while (p0 < pn && px > dto[othPath].base[p0 + 1].x) p0++; - while (q0 < qn && px > dto[secPath].base[q0 + 1].x) q0++; - while (p0 < pn && q0 < qn) { - if (px > dto[othPath].base[p0 + 1].x) p0++; - if (px > dto[secPath].base[q0 + 1].x) q0++; - if (p0 >= pn || q0 >= qn) - break; - // Dont use baseLast, as base coOrds have been rotated - if ((px + dx >= dto[othPath].base[pn - 1].x) - || (px + dx >= dto[secPath].base[qn - 1].x)) { - break; - } - - DIST_T dy1 = dto[othPath].base[p0].y + (px - dto[othPath].base[p0].x) * dto[othPath].dy[p0]; - DIST_T dy2 = dto[secPath].base[q0].y + (px - dto[secPath].base[q0].x) * dto[secPath].dy[q0]; - tdlen = (td->length + fabs(dy1) + fabs(dy2)) * magic; - if(tdlen > tdmax) - { - if(dAngle >= 30) - { - DIST_T dy = (dy1 + dy2) / 2; - Translate(&pos,dtod.midPt,cAngle,px - len); - Translate(&pos,pos,(cAngle - 90.0),dy); - DrawTie(d,pos,cAngle,tdlen - td->length * magic,td->width,color,tieDrawMode == TIEDRAWMODE_SOLID); - lenx += dx2 * magic2; - } - break; - } - - DIST_T dy = (dy1 + dy2) / 2; - Translate(&pos, dtod.midPt, cAngle, px - len); - Translate(&pos, pos, (cAngle - 90.0), dy); - DrawTie(d, pos, cAngle, tdlen, td->width, color, tieDrawMode == TIEDRAWMODE_SOLID); - - px += dx; - lenx += dx; - } - - p1 = dtod.midPt; - p2 = dto[strPath].ptsLast; - DIST_T lenr = FindDistance(p1, p2) - lenx * magic2; - a0 = dto[strPath].angle; - if (lenr > dx) { - Translate(&pos, p2, a0, -lenr); - DrawStraightTies(d, scaleInx, pos, p2, color); - } - else { - Translate(&pos, p2, a0, -dx2); - DrawTie(d, pos, a0, td->length, td->width, color, tieDrawMode == TIEDRAWMODE_SOLID); - } - - // p1 = dtod.midPt; - p2 = dto[str2Path].ptsLast; - lenr = FindDistance(p1, p2) - lenx * magic2; - a0 = dto[str2Path].angle; - if (lenr > dx) { - Translate(&pos, p2, a0, -lenr); - DrawStraightTies(d, scaleInx, pos, p2, color); - } - else { - Translate(&pos, p2, a0, -dx2); - DrawTie(d, pos, a0, td->length, td->width, color, tieDrawMode == TIEDRAWMODE_SOLID); - } - - // Draw left half - // Change the straight path used - if (dtod.toType == DTO_SSLIP) { - othPath = str2Path; - } - - len = FindDistance(c1, dtod.midPt); - cnt = (int)floor(len / td->spacing + 0.5); - if (cnt <= 0) - return; - - p0 = q0 = 0; - tdlen = td->length; - - dx = len / cnt; - dx2 = dx / 2; - px = len - dx2; - lenx = 0; - - while (p0 < pn && px > dto[othPath].base[p0 + 1].x) p0++; - while (q0 < qn && px > dto[secPath].base[q0 + 1].x) q0++; - while (p0 >= 0 && q0 >= 0) { - if (px < dto[othPath].base[p0].x) p0--; - if (px < dto[secPath].base[q0].x) q0--; - if (p0 < 0 || q0 < 0) - break; - - if ((px - dx < dto[othPath].base[0].x) - || (px - dx < dto[secPath].base[0].x)) { - break; - } - - DIST_T dy1 = dto[othPath].base[p0].y + (px - dto[othPath].base[p0].x) * dto[othPath].dy[p0]; - DIST_T dy2 = dto[secPath].base[q0].y + (px - dto[secPath].base[q0].x) * dto[secPath].dy[q0]; - tdlen = (td->length + fabs(dy1) + fabs(dy2)) * magic; - if(tdlen > tdmax) - { - if(dAngle >= 30) - { - DIST_T dy = (dy1 + dy2) / 2; - Translate(&pos,dtod.midPt,cAngle,px - len); - Translate(&pos,pos,(cAngle - 90.0),dy); - DrawTie(d,pos,cAngle,tdlen - td->length * magic,td->width,color,tieDrawMode == TIEDRAWMODE_SOLID); - lenx += dx2 * magic2; - } - break; - } - - DIST_T dy = (dy1 + dy2) / 2; - Translate(&pos, dtod.midPt, cAngle, px - len); - Translate(&pos, pos, (cAngle - 90.0), dy); - DrawTie(d, pos, cAngle, tdlen, td->width, color, tieDrawMode == TIEDRAWMODE_SOLID); - - px -= dx; - lenx += dx; - } - - p1 = dto[strPath].pts[0]; - p2 = dtod.midPt; - a0 = dto[strPath].angle; - lenr = FindDistance(p1, p2) - lenx * magic2; - if (lenr > dx) { - Translate(&pos, p1, a0, lenr); - DrawStraightTies(d, scaleInx, p1, pos, color); - } - else { - Translate(&pos, p1, a0, dx2); - DrawTie(d, pos, a0, td->length, td->width, color, tieDrawMode == TIEDRAWMODE_SOLID); - } - p1 = dto[str2Path].pts[0]; - // p2 = dtod.midPt; - a0 = dto[str2Path].angle; - lenr = FindDistance(p1, p2) - lenx * magic2; - if (lenr > dx) { - Translate(&pos, p1, a0, lenr); - DrawStraightTies(d, scaleInx, p1, pos, color); - } - else { - Translate(&pos, p1, a0, dx2); - DrawTie(d, pos, a0, td->length, td->width, color, tieDrawMode == TIEDRAWMODE_SOLID); - } -} - -/** - * Draw Crossover (Two Origin) Turnout Bridge and Ties. Uses the static dto and dtod structures. - * - * \param d The drawing object - * \param scaleInx The layout/track scale index - * \param color The tie color. If black the color is read from the global tieColor. - */ -static void DrawCrossTurnout( - drawCmd_p d, - SCALEINX_T scaleInx, - BOOL_T omitTies, - wDrawColor color) -{ - tieData_p td; - DIST_T len, dx; - coOrd pos; - int cnt; - ANGLE_T angle; - - if (color == wDrawColorBlack) - color = tieColor; - - struct extraDataCompound_t* xx = dtod.xx; - - DrawDtoInit(); - - // draw the points -#ifdef DTO_DEBUG - if (DTO_DEBUG == DTO_LCROSS) DrawDtoLayout(d, scaleInx); -#endif - - int strPath = dtod.strPath, str2Path = dtod.str2Path; - // Bad assumption - int othPath = 2, secPath = 2; - if (dtod.pathCnt == 4) secPath = 3; - - dto[strPath].angle = FindAngle(dto[strPath].pts[0], dto[strPath].ptsLast); - dto[str2Path].angle = FindAngle(dto[str2Path].pts[0], dto[str2Path].ptsLast); - - if(dtod.bridge) { - DrawCrossBridge(d,strPath,str2Path); - } - if (omitTies) - return; - - td = GetScaleTieData(scaleInx); - - coOrd s1, s2, t1, t2, p1, p2, q1, q2; - int s0, t0, p0, q0; - - int sn = dto[strPath].n; - int tn = dto[str2Path].n; - int pn = dto[othPath].n; - int qn = dto[secPath].n; - - s1 = dto[strPath].pts[0]; - s2 = dto[strPath].ptsLast; - t1 = dto[str2Path].pts[0]; - t2 = dto[str2Path].ptsLast; - angle = dto[strPath].angle; - - p1 = dto[othPath].base[0]; - p2 = dto[othPath].baseLast; - q1 = dto[secPath].base[0]; - q2 = dto[secPath].baseLast; - - td = GetScaleTieData(scaleInx); - len = FindDistance(s1, s2); - angle = dto[strPath].angle; - - cnt = (int)floor(len / td->spacing + 0.5); - if (cnt > 0) { - DIST_T px = 0; - DIST_T dy, dy1, dy2; - int cflag = 0; - dy = dto[str2Path].base[0].y - dto[strPath].base[0].y; - - dx = len / cnt; - s0 = t0 = p0 = q0 = 0; - DIST_T tdlen = td->length; - DIST_T dlenx = dx / 2; - - DIST_T px1 = len / 2 - dlenx * 5, - px2 = len / 2 + dlenx * 4; - - for (px = dlenx; cnt; cnt--, px += dx) { - if (px >= dto[strPath].base[s0 + 1].x) s0++; - if (px >= dto[str2Path].base[t0 + 1].x) t0++; - if (px >= dto[othPath].base[p0 + 1].x) p0++; - if (px >= dto[secPath].base[q0 + 1].x) q0++; - if (s0 >= sn || t0 >= tn || p0 >= pn || q0 >= qn) - break; - - if ((px >= dto[strPath].baseLast.x) - || (px >= dto[str2Path].baseLast.x)) { - break; - } - - dy1 = dy2 = 0; - cflag = 0; - if (px < px1) { - switch (dtod.toType) { - case DTO_DCROSS: - dy1 = dto[othPath].base[p0].y + (px - dto[othPath].base[p0].x) * dto[othPath].dy[p0]; - dy2 = dy - dto[secPath].base[q0].y - (px - dto[secPath].base[q0].x) * dto[secPath].dy[q0]; - break; - case DTO_LCROSS: - dy1 = dto[othPath].base[p0].y + (px - dto[othPath].base[p0].x) * dto[othPath].dy[p0]; - dy2 = 0; - break; - case DTO_RCROSS: - dy1 = 0; - dy2 = dy - dto[secPath].base[q0].y - (px - dto[secPath].base[q0].x) * dto[secPath].dy[q0]; - break; - default: - break; - } - } - else if (px < px2) { - dy1 = (dto[str2Path].base[s0].y - dto[strPath].base[t0].y); - dy2 = 0; - cflag = 1; - } - else { - switch (dtod.toType) { - case DTO_DCROSS: - dy1 = dto[secPath].base[q0].y + (px - dto[secPath].base[q0].x) * dto[secPath].dy[q0]; - dy2 = dy - dto[othPath].base[p0].y - (px - dto[othPath].base[p0].x) * dto[othPath].dy[p0]; - break; - case DTO_LCROSS: - dy1 = 0; - dy2 = dy - dto[secPath].base[q0].y - (px - dto[secPath].base[q0].x) * dto[secPath].dy[q0]; - break; - case DTO_RCROSS: - dy1 = dto[othPath].base[p0].y + (px - dto[othPath].base[p0].x) * dto[othPath].dy[p0]; - dy2 = 0; - break; - default: - break; - } - } - - if (fabs(dy1) + fabs(dy2) >= dy) { - dy1 = (dto[str2Path].base[s0].y - dto[strPath].base[t0].y); - dy2 = 0; - cflag = 1; - } - - tdlen = td->length + fabs(dy1); - Translate(&pos, s1, angle, px); - Translate(&pos, pos, (angle - 90.0), dy1 / 2); - DrawTie(d, pos, angle, tdlen, td->width, color, tieDrawMode == TIEDRAWMODE_SOLID); - - if (!cflag) { - tdlen = td->length + fabs(dy2); - Translate(&pos, t1, angle, px); - Translate(&pos, pos, (angle - 90.0), -dy2 / 2); - DrawTie(d, pos, angle, tdlen, td->width, color, tieDrawMode == TIEDRAWMODE_SOLID); - } - } - return; - - // Draw remaining ties, if any - // Currently by definition, there won't be any - /* - if (px + dx < dto[strPath].baseLast.x) { - p1 = dto[strPath].pts[p0]; - p2 = dto[strPath].ptsLast; - angle = FindAngle(p1, p2); - a0 = FindAngle(dto[strPath].base[p0], dto[strPath].baseLast); - DIST_T lenr = (dto[strPath].baseLast.x - px + dlenx) / cos(D2R(90.0 - a0)); - Translate(&p1, p2, angle, -lenr); - DrawStraightTies(d, scaleInx, p1, p2, color); - } - else { - p1 = dto[strPath].pts[pn - 2]; - a0 = FindAngle(p1, p2); - Translate(&pos, p2, a0, -dx / 2); - DrawTie(d, pos, a0, td->length, td->width, color, tieDrawMode == TIEDRAWMODE_SOLID); - } - - if (px + dx < dto[str2Path].baseLast.x) { - q1 = dto[str2Path].pts[q0]; - q2 = dto[str2Path].ptsLast; - angle = FindAngle(q1, q2); - a0 = FindAngle(dto[str2Path].base[q0], dto[str2Path].baseLast); - DIST_T lenr = (dto[str2Path].baseLast.x - px + dlenx) / cos(D2R(90.0 - a0)); - Translate(&q1, q2, angle, -lenr); - DrawStraightTies(d, scaleInx, q1, q2, color); - } - else { - q1 = dto[str2Path].pts[qn - 2]; - a0 = FindAngle(q1, q2); - Translate(&pos, q2, a0, -dx / 2); - DrawTie(d, pos, a0, td->length, td->width, color, tieDrawMode == TIEDRAWMODE_SOLID); - } - */ - } -} - -/** - * Draw all turnout components: ties, rail, roadbed, etc. The turnout is checked - * to see if the enhanced methods can be used. If so the ties are drawn and the - * TB_NOTIES bit is set so that the rails and such are drawn on top of the ties. - * That bit is restored to its previous state before return. - * - * \param trk Pointer to the track object - * \param d The drawing object - * \param color The turnout color. - */ -static void DrawTurnout( - track_p trk, - drawCmd_p d, - wDrawColor color) -{ - struct extraDataCompound_t* xx = GET_EXTRA_DATA(trk, T_TURNOUT, extraDataCompound_t); - wIndex_t i; - long widthOptions = 0; - SCALEINX_T scaleInx = GetTrkScale(trk); - DIST_T scale2rail = (d->options & DC_PRINT) ? (twoRailScale * 2 + 1) : twoRailScale; - BOOL_T omitTies = !DoDrawTies(d, trk) || (d->scale > scale2rail) || ((d->options & DC_SIMPLE) != 0); // || (scaleInx == 0); - - widthOptions = DTS_LEFT | DTS_RIGHT; - - int noTies = GetTrkNoTies(trk); - int bridge = GetTrkBridge(trk); - - long skip = 0; - /** @prefs [Preference] NormalTurnoutDraw=1 to skip enhanced drawing methods */ - wPrefGetInteger("Preference", "NormalTurnoutDraw", (long *) &skip, 0); - - int pathCnt = (skip == 0 ? GetTurnoutPaths(trk, xx) : 0); - - if ( (pathCnt > 1) && (pathCnt <= DTO_DIM) - && (trk->endCnt <= 4) - && (xx->special == TOnormal) ) - { - - dtod.bridge = bridge; - - int strPath = -1; - GetTurnoutType(); - - if (dtod.toType != DTO_INVALID) { - - switch (dtod.toType) - { - case DTO_NORMAL: - case DTO_THREE: - case DTO_WYE: - DrawNormalTurnout(d, scaleInx, omitTies, color); - break; - case DTO_CURVED: - DrawCurvedTurnout(d, scaleInx, omitTies, color); - break; - case DTO_XING: - case DTO_XNG9: - case DTO_SSLIP: - case DTO_DSLIP: - DrawXingTurnout(d, scaleInx, omitTies, color); - break; - case DTO_LCROSS: - case DTO_RCROSS: - case DTO_DCROSS: - DrawCrossTurnout(d, scaleInx, omitTies, color); - break; - default: - break; - } - SetTrkNoTies(trk, 1); - ClrTrkBits(trk, TB_BRIDGE); - } - } - - // Begin standard DrawTurnout code to draw rails or centerline - DrawSegsO(d, trk, xx->orig, xx->angle, xx->segs, xx->segCnt, GetTrkGauge(trk), color, widthOptions | DTS_NOCENTER); // no curve center for turnouts - - - for (i = 0; i < GetTrkEndPtCnt(trk); i++) { - DrawEndPt(d, trk, i, color); - } - if ((d->options & DC_SIMPLE) == 0 && - (labelWhen == 2 || (labelWhen == 1 && (d->options & DC_PRINT))) && - labelScale >= d->scale && - (GetTrkBits(trk) & TB_HIDEDESC) == 0) { - DrawCompoundDescription(trk, d, color); - if (!xx->handlaid) - LabelLengths(d, trk, color); - } - if (roadbedWidth > GetTrkGauge(trk) && - (((d->options & DC_PRINT) && d->scale <= (twoRailScale * 2 + 1) / 2.0) || - (roadbedOnScreen && d->scale <= twoRailScale))) - DrawTurnoutRoadbed(d, color, xx->orig, xx->angle, xx->segs, xx->segCnt); - - // Restore these settings - if (noTies == 0) ClrTrkBits(trk, TB_NOTIES); - if (bridge) SetTrkBits(trk, TB_BRIDGE); -} - - static BOOL_T ReadTurnout( - char* line) + char* line) { - if (!ReadCompound(line + 8, T_TURNOUT)) + if (!ReadCompound(line + 8, T_TURNOUT)) { return FALSE; + } return TRUE; } static ANGLE_T GetAngleTurnout( - track_p trk, - coOrd pos, - EPINX_T* ep0, - EPINX_T* ep1) + track_p trk, + coOrd pos, + EPINX_T* ep0, + EPINX_T* ep1) { - struct extraDataCompound_t* xx = GET_EXTRA_DATA(trk, T_TURNOUT, extraDataCompound_t); + struct extraDataCompound_t* xx = GET_EXTRA_DATA(trk, T_TURNOUT, + extraDataCompound_t); wIndex_t segCnt, segInx; ANGLE_T angle; - if (ep0 && ep1) + if (ep0 && ep1) { *ep0 = *ep1 = PickEndPoint(pos, trk); + } coOrd pos0 = pos; double dd = DIST_INF; int found = -1; @@ -2721,21 +738,21 @@ static ANGLE_T GetAngleTurnout( pos.x -= xx->orig.x; pos.y -= xx->orig.y; Rotate(&pos, zero, -xx->angle); - angle = GetAngleSegs(1, &xx->segs[found], &pos, &segInx, NULL, NULL, NULL, NULL); + angle = GetAngleSegs(1, &xx->segs[found], &pos, &segInx, NULL, NULL, NULL, + NULL); return NormalizeAngle(angle + xx->angle); - } - else return 0.0; + } else { return 0.0; } } static BOOL_T SplitTurnoutCheckPath( - wIndex_t segInxEnd, - PATHPTR_T pp1, - int dir1, - PATHPTR_T pp2, - int dir2, - trkSeg_p segs, - coOrd epPos) + wIndex_t segInxEnd, + PATHPTR_T pp1, + int dir1, + PATHPTR_T pp2, + int dir2, + trkSeg_p segs, + coOrd epPos) { wIndex_t segInx1, segInx2; EPINX_T segEP; @@ -2743,18 +760,21 @@ static BOOL_T SplitTurnoutCheckPath( DIST_T dist; GetSegInxEP(pp2[0], &segInx2, &segEP); - if (dir2 < 0) segEP = 1 - segEP; + if (dir2 < 0) { segEP = 1 - segEP; } pos = GetSegEndPt(&segs[segInx2], segEP, FALSE, NULL); dist = FindDistance(pos, epPos); - if (dist > connectDistance) + if (dist > connectDistance) { return TRUE; + } while (pp2[0]) { GetSegInxEP(pp1[0], &segInx1, &segEP); GetSegInxEP(pp2[0], &segInx2, &segEP); - if (segInx1 != segInx2) + if (segInx1 != segInx2) { break; - if (segInxEnd == segInx2) + } + if (segInxEnd == segInx2) { return TRUE; + } pp1 += dir1; pp2 += dir2; } @@ -2763,22 +783,25 @@ static BOOL_T SplitTurnoutCheckPath( static BOOL_T SplitTurnoutCheckEP( - wIndex_t segInx0, - coOrd epPos, - PATHPTR_T pp1, - int dir1, - PATHPTR_T pp, - trkSeg_p segs) + wIndex_t segInx0, + coOrd epPos, + PATHPTR_T pp1, + int dir1, + PATHPTR_T pp, + trkSeg_p segs) { while (pp[0]) { pp += strlen((char*)pp) + 1; while (pp[0]) { - if (!SplitTurnoutCheckPath(segInx0, pp1, dir1, pp, 1, segs, epPos)) + if (!SplitTurnoutCheckPath(segInx0, pp1, dir1, pp, 1, segs, epPos)) { return FALSE; - while (pp[0]) + } + while (pp[0]) { pp++; - if (!SplitTurnoutCheckPath(segInx0, pp1, dir1, pp - 1, -1, segs, epPos)) + } + if (!SplitTurnoutCheckPath(segInx0, pp1, dir1, pp - 1, -1, segs, epPos)) { return FALSE; + } pp++; } pp++; @@ -2788,10 +811,11 @@ static BOOL_T SplitTurnoutCheckEP( EXPORT EPINX_T TurnoutPickEndPt( - coOrd epPos, - track_p trk) + coOrd epPos, + track_p trk) { - struct extraDataCompound_t* xx = GET_EXTRA_DATA(trk, T_TURNOUT, extraDataCompound_t); + struct extraDataCompound_t* xx = GET_EXTRA_DATA(trk, T_TURNOUT, + extraDataCompound_t); wIndex_t segInx, segInx0; EPINX_T segEP; PATHPTR_T cp, cq, pps[2]; @@ -2818,7 +842,7 @@ EXPORT EPINX_T TurnoutPickEndPt( for (dir = 0; dir < 2; dir++) { for (cq = cp; cq[dir ? -1 : 1]; cq += (dir ? -1 : 1)); GetSegInxEP(cq[0], &segInx, &segEP); - if (dir == 0) segEP = 1 - segEP; + if (dir == 0) { segEP = 1 - segEP; } pos = GetSegEndPt(&xx->segs[segInx], segEP, FALSE, NULL); dist = FindDistance(pos, epPos); if (eps[dir] < 0 || dist < dists[dir]) { @@ -2827,12 +851,14 @@ EXPORT EPINX_T TurnoutPickEndPt( pos.y += xx->orig.y; Rotate(&pos, xx->orig, xx->angle); for (ep = 0; ep < epCnt; ep++) { - if (FindDistance(pos, GetTrkEndPos(trk, ep)) < connectDistance) + if (FindDistance(pos, GetTrkEndPos(trk, ep)) < connectDistance) { break; + } } if (ep < epCnt) { - if (eps[dir] >= 0 && eps[dir] != ep) + if (eps[dir] >= 0 && eps[dir] != ep) { unique_eps[dir] = FALSE; + } eps[dir] = ep; dists[dir] = dist; pps[dir] = cq; @@ -2850,23 +876,29 @@ EXPORT EPINX_T TurnoutPickEndPt( for (dir = 0; dir < 2; dir++) { if (unique_eps[dir] && eps[dir] >= 0) { GetSegInxEP(pps[dir][0], &segInx, &segEP); - if (dir == 0) segEP = 1 - segEP; + if (dir == 0) { segEP = 1 - segEP; } epPos = GetSegEndPt(&xx->segs[segInx], segEP, FALSE, NULL); - if (!SplitTurnoutCheckEP(segInx0, epPos, pps[dir], dir ? 1 : -1, GetPaths(trk), xx->segs)) + if (!SplitTurnoutCheckEP(segInx0, epPos, pps[dir], dir ? 1 : -1, GetPaths(trk), + xx->segs)) { unique_eps[dir] = FALSE; + } } } if (unique_eps[0] == unique_eps[1]) { - if (eps[0] >= 0 && eps[1] >= 0) + if (eps[0] >= 0 && eps[1] >= 0) { return (dists[0] < dists[1]) ? eps[0] : eps[1]; + } } - if (unique_eps[0] && eps[0] >= 0) + if (unique_eps[0] && eps[0] >= 0) { return eps[0]; - if (unique_eps[1] && eps[1] >= 0) + } + if (unique_eps[1] && eps[1] >= 0) { return eps[1]; - if (eps[0] >= 0 && eps[1] >= 0) + } + if (eps[0] >= 0 && eps[1] >= 0) { return (dists[0] < dists[1]) ? eps[0] : eps[1]; + } return eps[0] >= 0 ? eps[0] : eps[1]; } @@ -2876,11 +908,11 @@ static PATHPTR_T splitTurnoutRoot; static int splitTurnoutDir; static void SplitTurnoutCheckEndPt( - PATHPTR_T path, - int dir, - trkSeg_p segs, - coOrd epPos, - coOrd splitPos) + PATHPTR_T path, + int dir, + trkSeg_p segs, + coOrd epPos, + coOrd splitPos) { PATHPTR_T path0; wIndex_t segInx; @@ -2890,19 +922,23 @@ static void SplitTurnoutCheckEndPt( path0 = path; GetSegInxEP(path[0], &segInx, &segEP); - if (dir < 0) segEP = 1 - segEP; + if (dir < 0) { segEP = 1 - segEP; } pos = GetSegEndPt(&segs[segInx], segEP, FALSE, NULL); dist = FindDistance(pos, epPos); - LOG(log_splitturnout, 1, (" SPTChkEp P%d DIR:%d SegInx:%d SegEP:%d POS[%0.3f %0.3f] DIST:%0.3f\n", *path, dir, segInx, segEP, pos.x, pos.y, dist)); - if (dist > connectDistance) + LOG(log_splitturnout, 1, + (" SPTChkEp P%d DIR:%d SegInx:%d SegEP:%d POS[%0.3f %0.3f] DIST:%0.3f\n", + *path, dir, segInx, segEP, pos.x, pos.y, dist)); + if (dist > connectDistance) { return; + } minDist = trackGauge; while (path[0]) { GetSegInxEP(path[0], &segInx, &segEP); - if (dir < 0) segEP = 1 - segEP; + if (dir < 0) { segEP = 1 - segEP; } pos = splitPos; dist = DistanceSegs(zero, 0.0, 1, &segs[segInx], &pos, NULL); - LOG(log_splitturnout, 1, (" - P:%d SegInx:%d SegEP:%d DIST:%0.3f\n", path[0], segInx, segEP, dist)); + LOG(log_splitturnout, 1, (" - P:%d SegInx:%d SegEP:%d DIST:%0.3f\n", path[0], + segInx, segEP, dist)); if (dist < minDist) { minDist = dist; splitTurnoutPath = path; @@ -2914,23 +950,26 @@ static void SplitTurnoutCheckEndPt( } EXPORT BOOL_T SplitTurnoutCheck( - track_p trk, - coOrd pos, - EPINX_T ep, - track_p* leftover, - EPINX_T* ep0, - EPINX_T* ep1, - BOOL_T check, - coOrd* outPos, - ANGLE_T* outAngle) -{ - struct extraDataCompound_t* xx = GET_EXTRA_DATA(trk, T_TURNOUT, extraDataCompound_t); + track_p trk, + coOrd pos, + EPINX_T ep, + track_p* leftover, + EPINX_T* ep0, + EPINX_T* ep1, + BOOL_T check, + coOrd* outPos, + ANGLE_T* outAngle) +{ + struct extraDataCompound_t* xx = GET_EXTRA_DATA(trk, T_TURNOUT, + extraDataCompound_t); wIndex_t segInx0, segInx, segCnt; - EPINX_T segEP, epCnt, ep2 = 0, epN; + EPINX_T segEP, ep2 = 0, epN; +// EPINX_T epCnt; PATHPTR_T pp, pp1, pp2; unsigned char c; char* cp; - int negCnt, posCnt, pathCnt, dir; + int negCnt, posCnt, dir; +// int pathCnt; segProcData_t segProcDataSplit; segProcData_t segProcDataNewTrack; track_p trk2 = NULL; @@ -2945,17 +984,19 @@ EXPORT BOOL_T SplitTurnoutCheck( trkSeg_t newSeg; if ((MyGetKeyState() & WKEY_SHIFT) == 0) { - if (!check) + if (!check) { ErrorMessage(MSG_CANT_SPLIT_TRK, _("Turnout")); + } return FALSE; } /* * 1. Find segment on path that ends at 'ep' */ - epCnt = GetTrkEndPtCnt(trk); +// epCnt = GetTrkEndPtCnt(trk); epPos = GetTrkEndPos(trk, ep); - for (segCnt = 0; segCnt < xx->segCnt && IsSegTrack(&xx->segs[segCnt]); segCnt++); + for (segCnt = 0; segCnt < xx->segCnt + && IsSegTrack(&xx->segs[segCnt]); segCnt++); Rotate(&pos, xx->orig, -xx->angle); pos.x -= xx->orig.x; pos.y -= xx->orig.y; @@ -2964,24 +1005,30 @@ EXPORT BOOL_T SplitTurnoutCheck( epPos.y -= xx->orig.y; splitTurnoutPath = NULL; pp = GetPaths(trk); - LOG(log_splitturnout, 1, ("SplitTurnoutCheck T%d POS[%0.3f %0.3f] EP:%d CHK:%d EPPOS[%0.3f %0.3f]\n", trk ? trk->index : 0, pos.x, pos.y, ep, check, epPos.x, epPos.y)); + LOG(log_splitturnout, 1, + ("SplitTurnoutCheck T%d POS[%0.3f %0.3f] EP:%d CHK:%d EPPOS[%0.3f %0.3f]\n", + trk ? GetTrkIndex( trk ): 0, pos.x, pos.y, ep, check, epPos.x, epPos.y)); while (pp[0]) { pp += strlen((char*)pp) + 1; while (pp[0]) { SplitTurnoutCheckEndPt(pp, 1, xx->segs, epPos, pos); - if (splitTurnoutPath != NULL) + if (splitTurnoutPath != NULL) { goto foundSeg; - while (pp[0]) + } + while (pp[0]) { pp++; + } SplitTurnoutCheckEndPt(pp - 1, -1, xx->segs, epPos, pos); - if (splitTurnoutPath != NULL) + if (splitTurnoutPath != NULL) { goto foundSeg; + } pp++; } pp++; } - if (!check) + if (!check) { ErrorMessage(_("splitTurnout: can't find segment")); + } return FALSE; foundSeg: @@ -2989,9 +1036,10 @@ foundSeg: * 2a. Check that all other paths thru found segment are the same */ GetSegInxEP(splitTurnoutPath[0], &segInx0, &segEP); - LOG(log_splitturnout, 1, (" Found Seg: %d SEG:%d EP:%d\n", *splitTurnoutPath, segInx0, segEP)); + LOG(log_splitturnout, 1, (" Found Seg: %d SEG:%d EP:%d\n", *splitTurnoutPath, + segInx0, segEP)); pp = GetPaths(trk); - pathCnt = 0; +// pathCnt = 0; while (pp[0]) { pp += strlen((char*)pp) + 1; while (pp[0]) { @@ -3002,14 +1050,16 @@ foundSeg: pp2 = pp; dir = (pp2[0] > 0 ? 1 : -1) * splitTurnoutDir; while (pp1[0] && pp2[0]) { - if (splitTurnoutDir * pp1[0] != dir * pp2[0]) + if (splitTurnoutDir * pp1[0] != dir * pp2[0]) { break; + } pp1 += splitTurnoutDir; pp2 += dir; } if (pp1[0] != '\0' || pp2[0] != '\0') { - if (!check) + if (!check) { ErrorMessage(MSG_SPLIT_POS_BTW_MERGEPTS); + } return FALSE; } } @@ -3023,9 +1073,11 @@ foundSeg: /* * 2b. Check that all paths from ep pass thru segInx0 */ - if (!SplitTurnoutCheckEP(segInx0, epPos, splitTurnoutRoot, -splitTurnoutDir, GetPaths(trk), xx->segs)) { - if (!check) + if (!SplitTurnoutCheckEP(segInx0, epPos, splitTurnoutRoot, -splitTurnoutDir, + GetPaths(trk), xx->segs)) { + if (!check) { ErrorMessage(MSG_SPLIT_PATH_NOT_UNIQUE); + } return FALSE; } @@ -3048,21 +1100,20 @@ foundSeg: s1 = 1 - s0; SegProc(SEGPROC_SPLIT, xx->segs + segInx0, &segProcDataSplit); if (segProcDataSplit.split.length[s1] <= minLength) { - if (splitTurnoutPath[splitTurnoutDir] == '\0') + if (splitTurnoutPath[splitTurnoutDir] == '\0') { return FALSE; + } segProcDataSplit.split.length[s0] += segProcDataSplit.split.length[s1]; segProcDataSplit.split.length[s1] = 0; segProcDataSplit.split.newSeg[s0] = xx->segs[segInx0]; epPos = GetSegEndPt(&segProcDataSplit.split.newSeg[s0], s1, FALSE, &epAngle); - } - else if (segProcDataSplit.split.length[s0] <= minLength) { + } else if (segProcDataSplit.split.length[s0] <= minLength) { segProcDataSplit.split.length[s1] += segProcDataSplit.split.length[s0]; segProcDataSplit.split.length[s0] = 0; segProcDataSplit.split.newSeg[s1] = xx->segs[segInx0]; epPos = GetSegEndPt(&segProcDataSplit.split.newSeg[s1], s0, FALSE, &epAngle); epAngle += 180.0; - } - else { + } else { epPos = GetSegEndPt(&segProcDataSplit.split.newSeg[s1], s0, FALSE, &epAngle); epAngle += 180.0; } @@ -3071,11 +1122,13 @@ foundSeg: * 4. Map the old segments to new */ DYNARR_SET(int, segIndexMap_da, xx->segCnt); - for (segInx = 0; segInx < xx->segCnt; segInx++) + for (segInx = 0; segInx < xx->segCnt; segInx++) { segIndexMap(segInx) = segInx + 1; + } pp = splitTurnoutPath; - if (segProcDataSplit.split.length[s0] > minLength) + if (segProcDataSplit.split.length[s0] > minLength) { pp += splitTurnoutDir; + } negCnt = 0; while (*pp) { GetSegInxEP(*pp, &segInx, &segEP); @@ -3084,16 +1137,16 @@ foundSeg: pp += splitTurnoutDir; } for (segInx = posCnt = 0; segInx < xx->segCnt; segInx++) { - if (segIndexMap(segInx) > 0) + if (segIndexMap(segInx) > 0) { segIndexMap(segInx) = ++posCnt; + } } DYNARR_SET(trkSeg_t, tempSegs_da, posCnt); for (segInx = posCnt = 0; segInx < xx->segCnt; segInx++) { if (segIndexMap(segInx) > 0) { if (segInx == segInx0) { tempSegs(segIndexMap(segInx) - 1) = segProcDataSplit.split.newSeg[s0]; - } - else { + } else { tempSegs(segIndexMap(segInx) - 1) = xx->segs[segInx]; } posCnt++; @@ -3115,8 +1168,9 @@ foundSeg: GetSegInxEP(*pp, &segInx, &segEP); if (segIndexMap(segInx) > 0) { c = segIndexMap(segInx); - if (*pp < 0) + if (*pp < 0) { c = -c; + } *pp1++ = c; } pp++; @@ -3144,12 +1198,10 @@ foundSeg: memcpy(message, xx->title, cp - xx->title + 1); strcpy(message + (cp - xx->title + 1), "Split "); strcat(message, cp + 1); - } - else { + } else { strcpy(message, xx->title); } - } - else { + } else { sprintf(message, "Split %s", xx->title); } @@ -3158,15 +1210,15 @@ foundSeg: */ int trks = 0; path = splitTurnoutPath; - if (segProcDataSplit.split.length[s1] < minLength) + if (segProcDataSplit.split.length[s1] < minLength) { path += splitTurnoutDir; + } while (path[0]) { GetSegInxEP(path[0], &segInx, &segEP); s0 = (path[0] > 0) != (splitTurnoutDir > 0); if (segInx0 != segInx) { newSeg = xx->segs[segInx]; - } - else { + } else { newSeg = segProcDataSplit.split.newSeg[s1]; } MoveSegs(1, &newSeg, xx->orig); @@ -3176,8 +1228,7 @@ foundSeg: *ep0 = segProcDataNewTrack.newTrack.ep[s0]; *leftover = trk2 = segProcDataNewTrack.newTrack.trk; ep2 = 1 - *ep0; - } - else { + } else { epN = segProcDataNewTrack.newTrack.ep[s0]; ConnectTracks(trk2, ep2, segProcDataNewTrack.newTrack.trk, epN); trk2 = segProcDataNewTrack.newTrack.trk; @@ -3209,21 +1260,22 @@ foundSeg: } static BOOL_T SplitTurnout( - track_p trk, - coOrd pos, - EPINX_T ep, - track_p* leftover, - EPINX_T* ep0, - EPINX_T* ep1) + track_p trk, + coOrd pos, + EPINX_T ep, + track_p* leftover, + EPINX_T* ep0, + EPINX_T* ep1) { return SplitTurnoutCheck(trk, pos, ep, leftover, ep0, ep1, FALSE, NULL, NULL); } static BOOL_T CheckTraverseTurnout( - track_p trk, - coOrd pos) + track_p trk, + coOrd pos) { - struct extraDataCompound_t* xx = GET_EXTRA_DATA(trk, T_TURNOUT, extraDataCompound_t); + struct extraDataCompound_t* xx = GET_EXTRA_DATA(trk, T_TURNOUT, + extraDataCompound_t); coOrd pos1; #ifdef LATER int inx, foundInx = 0; @@ -3234,67 +1286,73 @@ static BOOL_T CheckTraverseTurnout( int segInx; EPINX_T segEP; - LOG(log_traverseTurnout, 1, ("CheckTraverseTurnout( T%d, [%0.3f %0.3f])\n", GetTrkIndex(trk), pos.x, pos.y)) - Rotate(&pos, xx->orig, -xx->angle); + LOG(log_traverseTurnout, 1, ("CheckTraverseTurnout( T%d, [%0.3f %0.3f])\n", + GetTrkIndex(trk), pos.x, pos.y)) + Rotate(&pos, xx->orig, -xx->angle); pos.x -= xx->orig.x; pos.y -= xx->orig.y; LOG(log_traverseTurnout, 1, ("After rotation = [%0.3f %0.3f])\n", pos.x, pos.y)) #ifdef LATER - for (inx = 0; inx < xx->segCnt; inx++) { - switch (xx->segs[inx].type) { - case SEG_STRTRK: - case SEG_CRVTRK: - pos1 = GetSegEndPt(&xx->segs[inx], 0, FALSE, NULL); - d = FindDistance(pos, pos1); - if (foundInx == 0 || d < foundD) { - foundInx = inx + 1; - foundD = d; - } - pos1 = GetSegEndPt(&xx->segs[inx], 1, FALSE, NULL); - d = FindDistance(pos, pos1); - if (foundInx == 0 || d < foundD) { - foundInx = -(inx + 1); - foundD = d; - } - break; + for (inx = 0; inx < xx->segCnt; inx++) { + switch (xx->segs[inx].type) { + case SEG_STRTRK: + case SEG_CRVTRK: + pos1 = GetSegEndPt(&xx->segs[inx], 0, FALSE, NULL); + d = FindDistance(pos, pos1); + if (foundInx == 0 || d < foundD) { + foundInx = inx + 1; + foundD = d; } + pos1 = GetSegEndPt(&xx->segs[inx], 1, FALSE, NULL); + d = FindDistance(pos, pos1); + if (foundInx == 0 || d < foundD) { + foundInx = -(inx + 1); + foundD = d; + } + break; } - if (foundInx == 0) + } + if (foundInx == 0) { return FALSE; + } #endif PATHPTR_T pathName = GetCurrPath(trk); for (pathCurr = pathName + strlen((char*)pathName) + 1; - pathCurr[0] || pathCurr[1]; pathCurr++) { - LOG(log_traverseTurnout, 1, ("P[%d] = %d ", pathCurr - GetPaths(trk), pathCurr[0])) - if (pathCurr[-1] == 0) { - GetSegInxEP(pathCurr[0], &segInx, &segEP); - pos1 = GetSegEndPt(&xx->segs[segInx], segEP, FALSE, NULL); - d = FindDistance(pos, pos1); - LOG(log_traverseTurnout, 1, ("d=%0.3f\n", d)) - if (d < connectDistance) - return TRUE; + pathCurr[0] || pathCurr[1]; pathCurr++) { + LOG(log_traverseTurnout, 1, ("P[%d] = %d ", pathCurr - GetPaths(trk), + pathCurr[0])) + if (pathCurr[-1] == 0) { + GetSegInxEP(pathCurr[0], &segInx, &segEP); + pos1 = GetSegEndPt(&xx->segs[segInx], segEP, FALSE, NULL); + d = FindDistance(pos, pos1); + LOG(log_traverseTurnout, 1, ("d=%0.3f\n", d)) + if (d < connectDistance) { + return TRUE; } + } if (pathCurr[1] == 0) { GetSegInxEP(pathCurr[0], &segInx, &segEP); pos1 = GetSegEndPt(&xx->segs[segInx], 1 - segEP, FALSE, NULL); d = FindDistance(pos, pos1); LOG(log_traverseTurnout, 1, ("d=%0.3f\n", d)) - if (d < connectDistance) - return TRUE; + if (d < connectDistance) { + return TRUE; + } } } LOG(log_traverseTurnout, 1, (" not found\n")) - return FALSE; + return FALSE; } static BOOL_T TraverseTurnout( - traverseTrack_p trvTrk, - DIST_T* distR) + traverseTrack_p trvTrk, + DIST_T* distR) { track_p trk = trvTrk->trk; - struct extraDataCompound_t* xx = GET_EXTRA_DATA(trk, T_TURNOUT, extraDataCompound_t); + struct extraDataCompound_t* xx = GET_EXTRA_DATA(trk, T_TURNOUT, + extraDataCompound_t); coOrd pos0, pos1, pos2; DIST_T d, dist; PATHPTR_T path, pathCurr; @@ -3310,12 +1368,16 @@ static BOOL_T TraverseTurnout( pos0.x -= xx->orig.x; pos0.y -= xx->orig.y; dist = *distR; - LOG(log_traverseTurnout, 1, ("TraverseTurnout( T%d, [%0.3f %0.3f] [%0.3f %0.3f], A%0.3f, D%0.3f\n", GetTrkIndex(trk), trvTrk->pos.x, trvTrk->pos.y, pos0.x, pos0.y, trvTrk->angle, *distR)) - pathCurr = 0; + LOG(log_traverseTurnout, 1, + ("TraverseTurnout( T%d, [%0.3f %0.3f] [%0.3f %0.3f], A%0.3f, D%0.3f\n", + GetTrkIndex(trk), trvTrk->pos.x, trvTrk->pos.y, pos0.x, pos0.y, trvTrk->angle, + *distR)) + pathCurr = 0; path = GetCurrPath(trk); for (path += strlen((char*)path) + 1; path[0] || path[1]; path++) { - if (path[0] == 0) + if (path[0] == 0) { continue; + } GetSegInxEP(path[0], &segInx, &segEP); segPtr = xx->segs + segInx; segProcData.distance.pos1 = pos0; @@ -3331,7 +1393,7 @@ static BOOL_T TraverseTurnout( return FALSE; } LOG(log_traverseTurnout, 1, (" PC=%d ", pathCurr[0])) - GetSegInxEP(pathCurr[0], &segInx, &segEP); + GetSegInxEP(pathCurr[0], &segInx, &segEP); segPtr = xx->segs + segInx; segProcData.traverse1.pos = pos2; segProcData.traverse1.angle = -xx->angle + trvTrk->angle; @@ -3348,45 +1410,50 @@ static BOOL_T TraverseTurnout( // a curve that is flipped is negative (the end points are reversed) which Traverse1 handles, // and a path can also be reversed (negative path number) and will have segEP = 1 BOOL_T turnout_backwards = backwards; - if (segEP) turnout_backwards = !turnout_backwards; //direction modified if path reversed + if (segEP) { turnout_backwards = !turnout_backwards; } //direction modified if path reversed - LOG(log_traverseTurnout, 2, (" SI%d TB%d SP%d B%d SB%d N%d BSI%d D%0.3f\n", segInx, turnout_backwards, segEP, backwards, segs_backwards, neg, BezSegInx, dist)) - while (*pathCurr) { - //Set up Traverse2 - GetSegInxEP(pathCurr[0], &segInx, &segEP); - segPtr = xx->segs + segInx; - segProcData.traverse2.segDir = backwards; - segProcData.traverse2.dist = dist; - segProcData.traverse2.BezSegInx = BezSegInx; - segProcData.traverse2.segs_backwards = segs_backwards; - SegProc(SEGPROC_TRAVERSE2, segPtr, &segProcData); - if (segProcData.traverse2.dist <= 0) { - *distR = 0; - REORIGIN(trvTrk->pos, segProcData.traverse2.pos, xx->angle, xx->orig); - trvTrk->angle = NormalizeAngle(xx->angle + segProcData.traverse2.angle); - LOG(log_traverseTurnout, 2, (" -> [%0.3f %0.3f] A%0.3f D%0.3f\n", trvTrk->pos.x, trvTrk->pos.y, trvTrk->angle, *distR)) - return TRUE; - } - dist = segProcData.traverse2.dist; //Remainder after segment - pathCurr += (turnout_backwards ? -1 : 1); //Use master direction for turnout - //Redrive Traverse 1 for each segment for Bezier - to pick up backwards elements - if (pathCurr[0] == '\0') continue; // - //Set up Traverse1 - copy all of Traverse2 values first - GetSegInxEP(pathCurr[0], &segInx, &segEP); - segPtr = xx->segs + segInx; - ANGLE_T angle = segProcData.traverse2.angle; - coOrd pos = segProcData.traverse2.pos; - LOG(log_traverseTurnout, 1, (" Loop2-1 SI%d SP%d [%0.3f %0.3f] A%0.3f D%0.3f\n", segInx, segEP, pos.x, pos.y, angle, dist)) - segProcData.traverse1.pos = pos; - segProcData.traverse1.angle = angle; - SegProc(SEGPROC_TRAVERSE1, segPtr, &segProcData); - // dist += segProcData.traverse1.dist; //Add distance from end to pos (could be zero or whole length if backwards) - backwards = segProcData.traverse1.backwards; - segs_backwards = segProcData.traverse1.segs_backwards; - neg = segProcData.traverse1.negative; - BezSegInx = segProcData.traverse1.BezSegInx; - LOG(log_traverseTurnout, 1, (" Loop1-2 B%d SB%d N%d BSI%d D%0.3f\n", backwards, segs_backwards, neg, BezSegInx, dist)) + LOG(log_traverseTurnout, 2, (" SI%d TB%d SP%d B%d SB%d N%d BSI%d D%0.3f\n", + segInx, turnout_backwards, segEP, backwards, segs_backwards, neg, BezSegInx, + dist)) + while (*pathCurr) { + //Set up Traverse2 + GetSegInxEP(pathCurr[0], &segInx, &segEP); + segPtr = xx->segs + segInx; + segProcData.traverse2.segDir = backwards; + segProcData.traverse2.dist = dist; + segProcData.traverse2.BezSegInx = BezSegInx; + segProcData.traverse2.segs_backwards = segs_backwards; + SegProc(SEGPROC_TRAVERSE2, segPtr, &segProcData); + if (segProcData.traverse2.dist <= 0) { + *distR = 0; + REORIGIN(trvTrk->pos, segProcData.traverse2.pos, xx->angle, xx->orig); + trvTrk->angle = NormalizeAngle(xx->angle + segProcData.traverse2.angle); + LOG(log_traverseTurnout, 2, (" -> [%0.3f %0.3f] A%0.3f D%0.3f\n", + trvTrk->pos.x, trvTrk->pos.y, trvTrk->angle, *distR)) + return TRUE; } + dist = segProcData.traverse2.dist; //Remainder after segment + pathCurr += (turnout_backwards ? -1 : 1); //Use master direction for turnout + //Redrive Traverse 1 for each segment for Bezier - to pick up backwards elements + if (pathCurr[0] == '\0') { continue; } // + //Set up Traverse1 - copy all of Traverse2 values first + GetSegInxEP(pathCurr[0], &segInx, &segEP); + segPtr = xx->segs + segInx; + ANGLE_T angle = segProcData.traverse2.angle; + coOrd pos = segProcData.traverse2.pos; + LOG(log_traverseTurnout, 1, (" Loop2-1 SI%d SP%d [%0.3f %0.3f] A%0.3f D%0.3f\n", + segInx, segEP, pos.x, pos.y, angle, dist)) + segProcData.traverse1.pos = pos; + segProcData.traverse1.angle = angle; + SegProc(SEGPROC_TRAVERSE1, segPtr, &segProcData); + // dist += segProcData.traverse1.dist; //Add distance from end to pos (could be zero or whole length if backwards) + backwards = segProcData.traverse1.backwards; + segs_backwards = segProcData.traverse1.segs_backwards; + neg = segProcData.traverse1.negative; + BezSegInx = segProcData.traverse1.BezSegInx; + LOG(log_traverseTurnout, 1, (" Loop1-2 B%d SB%d N%d BSI%d D%0.3f\n", backwards, + segs_backwards, neg, BezSegInx, dist)) + } pathCurr += (turnout_backwards ? 1 : -1); pos1 = MapPathPos(xx, pathCurr[0], (turnout_backwards ? 0 : 1)); @@ -3404,15 +1471,15 @@ static BOOL_T TraverseTurnout( if (dist > connectDistance) { trk = NULL; trvTrk->pos = pos1; - } - else { + } else { trvTrk->pos = GetTrkEndPos(trk, ep); trvTrk->angle = GetTrkEndAngle(trk, ep); trk = GetTrkEndTrk(trk, ep); } dist = FindDistance(trvTrk->pos, pos1); - LOG(log_traverseTurnout, 1, (" -> [%0.3f %0.3f] A%0.3f D%0.3f\n", trvTrk->pos.x, trvTrk->pos.y, trvTrk->angle, *distR)) - trvTrk->trk = trk; + LOG(log_traverseTurnout, 1, (" -> [%0.3f %0.3f] A%0.3f D%0.3f\n", + trvTrk->pos.x, trvTrk->pos.y, trvTrk->angle, *distR)) + trvTrk->trk = trk; return TRUE; } @@ -3421,7 +1488,7 @@ static STATUS_T ModifyTurnout(track_p trk, wAction_t action, coOrd pos) { struct extraDataCompound_t* xx; static EPINX_T ep; - static wBool_t curved; +// static wBool_t curved; DIST_T d; xx = GET_EXTRA_DATA(trk, T_TURNOUT, extraDataCompound_t); @@ -3429,29 +1496,33 @@ static STATUS_T ModifyTurnout(track_p trk, wAction_t action, coOrd pos) switch (action) { case C_START: ep = -1; - curved = FALSE; +// curved = FALSE; return C_CONTINUE; case C_DOWN: ep = PickUnconnectedEndPoint(pos, trk); - if (ep == -1) + if (ep == -1) { return C_ERROR; + } UndrawNewTrack(trk); + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); tempSegs(0).type = SEG_STRTRK; - tempSegs(0).width = 0; + tempSegs(0).lineWidth = 0; tempSegs(0).u.l.pos[0] = GetTrkEndPos(trk, 1 - ep); - tempSegs_da.cnt = 1; InfoMessage(_("Drag to change track length")); return C_CONTINUE; case C_MOVE: d = FindDistance(tempSegs(0).u.l.pos[0], pos); - if (d < xx->u.adjustable.minD) + if (d < xx->u.adjustable.minD) { d = xx->u.adjustable.minD; - else if (d > xx->u.adjustable.maxD) + } else if (d > xx->u.adjustable.maxD) { d = xx->u.adjustable.maxD; - Translate(&tempSegs(0).u.l.pos[1], tempSegs(0).u.l.pos[0], GetTrkEndAngle(trk, ep), d); - tempSegs_da.cnt = 1; - if (action == C_MOVE) + } + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); + Translate(&tempSegs(0).u.l.pos[1], tempSegs(0).u.l.pos[0], GetTrkEndAngle(trk, + ep), d); + if (action == C_MOVE) { InfoMessage(_("Length=%s"), FormatDistance(d)); + } return C_CONTINUE; case C_UP: d = FindDistance(tempSegs(0).u.l.pos[0], tempSegs(0).u.l.pos[1]); @@ -3466,7 +1537,8 @@ static STATUS_T ModifyTurnout(track_p trk, wAction_t action, coOrd pos) } -static BOOL_T GetParamsTurnout(int inx, track_p trk, coOrd pos, trackParams_t* params) +static BOOL_T GetParamsTurnout(int inx, track_p trk, coOrd pos, + trackParams_t* params) { struct extraDataCompound_t* xx; xx = GET_EXTRA_DATA(trk, T_TURNOUT, extraDataCompound_t); @@ -3488,8 +1560,9 @@ static BOOL_T GetParamsTurnout(int inx, track_p trk, coOrd pos, trackParams_t* p path = GetCurrPath(trk); pathCurr = path; for (path += strlen((char*)path) + 1; path[0] || path[1]; path++) { - if (path[0] == 0) + if (path[0] == 0) { continue; + } GetSegInxEP(path[0], &segInx, &segEP); segPtr = xx->segs + segInx; segProcData.distance.pos1 = pos; @@ -3511,12 +1584,14 @@ static BOOL_T GetParamsTurnout(int inx, track_p trk, coOrd pos, trackParams_t* p pathCurr += segEP ? 1 : -1; } params->len = d; - } - else { + } else { // Centroid is middle of bounding box - params->centroid.x = (trk->lo.x + trk->hi.x) / 2.0; - params->centroid.y = (trk->lo.y + trk->hi.y) / 2.0; - params->len = FindDistance(params->centroid, pos) * 2; //Times two because it will be halved by track.c + coOrd lo, hi; + GetBoundingBox( trk, &hi, &lo ); + params->centroid.x = (lo.x + hi.x) / 2.0; + params->centroid.y = (lo.y + hi.y) / 2.0; + params->len = FindDistance(params->centroid, + pos) * 2; //Times two because it will be halved by track.c } return TRUE; } @@ -3529,17 +1604,17 @@ static BOOL_T GetParamsTurnout(int inx, track_p trk, coOrd pos, trackParams_t* p if (params->ep >= 0) { params->angle = GetTrkEndAngle(trk, params->ep); params->track_angle = params->angle + params->ep ? 0 : 180; - } - else { + } else { params->angle = params->track_angle = 0; return FALSE; } /* Find the path we are closest to */ - PATHPTR_T pathCurr = 0; +// PATHPTR_T pathCurr = 0; int segInx, subSegInx; trkSeg_p segPtr; DIST_T d = DIST_INF; - struct extraDataCompound_t* xx = GET_EXTRA_DATA(trk, T_TURNOUT, extraDataCompound_t); + struct extraDataCompound_t* xx = GET_EXTRA_DATA(trk, T_TURNOUT, + extraDataCompound_t); /* Get parms from that seg */ wBool_t back, negative; coOrd segPos = pos; @@ -3548,15 +1623,15 @@ static BOOL_T GetParamsTurnout(int inx, track_p trk, coOrd pos, trackParams_t* p segPos.y -= xx->orig.y; params->track_angle = GetAngleSegs( //Find correct subSegment - xx->segCnt, xx->segs, - &segPos, &segInx, &d, &back, &subSegInx, &negative); - if (segInx == -1) return FALSE; + xx->segCnt, xx->segs, + &segPos, &segInx, &d, &back, &subSegInx, &negative); + if (segInx == -1) { return FALSE; } segPtr = xx->segs + segInx; switch (segPtr->type) { case SEG_BEZTRK: - if (negative != back) params->track_angle = NormalizeAngle(params->track_angle + 180); //Bezier is in reverse + if (negative != back) { params->track_angle = NormalizeAngle(params->track_angle + 180); } //Bezier is in reverse segPtr = xx->segs + segInx; - trkSeg_p subSegPtr = (trkSeg_p)segPtr->bezSegs.ptr + subSegInx; + trkSeg_p subSegPtr = &DYNARR_N(trkSeg_t,segPtr->bezSegs,subSegInx); if (subSegPtr->type == SEG_CRVTRK) { params->type = curveTypeCurve; params->arcR = fabs(subSegPtr->u.c.radius); @@ -3587,19 +1662,20 @@ static BOOL_T GetParamsTurnout(int inx, track_p trk, coOrd pos, trackParams_t* p if (params->ep >= 0) { params->angle = GetTrkEndAngle(trk, params->ep); params->track_angle = params->angle + params->ep ? 0 : 180; - } - else { + } else { params->angle = params->track_angle = 0; return FALSE; } return TRUE; } - if ((inx == PARAMS_1ST_JOIN) || (inx == PARAMS_2ND_JOIN)) + if ((inx == PARAMS_1ST_JOIN) || (inx == PARAMS_2ND_JOIN)) { params->ep = PickEndPoint(pos, trk); - else + } else { params->ep = PickUnconnectedEndPointSilent(pos, trk); - if (params->ep == -1) + } + if (params->ep == -1) { return FALSE; + } params->lineOrig = GetTrkEndPos(trk, params->ep); params->lineEnd = params->lineOrig; params->len = 0.0; @@ -3653,16 +1729,17 @@ static BOOL_T QueryTurnout(track_p trk, int query) case Q_IS_TURNOUT: return TRUE; case Q_CAN_PARALLEL: - if (GetTrkEndPtCnt(trk) == 2 && fabs(GetTrkEndAngle(trk, 0) - GetTrkEndAngle(trk, 1)) == 180.0) + if (GetTrkEndPtCnt(trk) == 2 + && fabs(GetTrkEndAngle(trk, 0) - GetTrkEndAngle(trk, 1)) == 180.0) { return TRUE; - else + } else { return FALSE; - case Q_CAN_NEXT_POSITION: - { - PATHPTR_T path = GetPaths( trk ); // QueryTurnout - for ( path += strlen((char*)path) + 1; path[0] || path[1]; path++ ); - return ( path[2] != 0 ); } + case Q_CAN_NEXT_POSITION: { + PATHPTR_T path = GetPaths( trk ); // QueryTurnout + for ( path += strlen((char*)path) + 1; path[0] || path[1]; path++ ); + return ( path[2] != 0 ); + } case Q_CORNU_CAN_MODIFY: return FALSE; default: @@ -3671,28 +1748,29 @@ static BOOL_T QueryTurnout(track_p trk, int query) } -EXPORT int doDrawTurnoutPosition = 1; static wIndex_t drawTurnoutPositionWidth = 3; static void DrawTurnoutPositionIndicator( - track_p trk, - wDrawColor color) + track_p trk, + wDrawColor color) { - struct extraDataCompound_t* xx = GET_EXTRA_DATA(trk, T_TURNOUT, extraDataCompound_t); + struct extraDataCompound_t* xx = GET_EXTRA_DATA(trk, T_TURNOUT, + extraDataCompound_t); PATHPTR_T path, path1; coOrd pos0 = zero, pos1; trkSeg_p seg; BOOL_T multiPart = FALSE; // Only 1 path? Don't draw - if ( ! QueryTurnout( trk, Q_CAN_NEXT_POSITION ) ) + if ( ! QueryTurnout( trk, Q_CAN_NEXT_POSITION ) ) { return; + } path = GetCurrPath(trk); //Is this a multi-part path? path1 = path; for (path1 += strlen((char*)path1) + 1; path1[0]; path1++); - if (path1[1] != 0) multiPart = TRUE; + if (path1[1] != 0) { multiPart = TRUE; } for (path += strlen((char*)path); path[0] || path[1]; path++) { @@ -3701,52 +1779,55 @@ static void DrawTurnoutPositionIndicator( pos0 = MapPathPos(xx, path[1], 0); if ((tempD.scale <= 10) || !multiPart) { seg = MapPathSeg(xx, path[1]); - DrawSegsO(&tempD, trk, xx->orig, xx->angle, seg, 1, GetTrkGauge(trk), color, DTS_CENTERONLY); + DrawSegsO(&tempD, trk, xx->orig, xx->angle, seg, 1, GetTrkGauge(trk), color, + DTS_CENTERONLY); } - } - else if (path[1] == 0) { + } else if (path[1] == 0) { pos1 = MapPathPos(xx, path[0], 1); - if ((tempD.scale > 10) && multiPart) + if ((tempD.scale > 10) && multiPart) { DrawLine(&tempD, pos0, pos1, drawTurnoutPositionWidth, color); - else { + } else { seg = MapPathSeg(xx, path[0]); - DrawSegsO(&tempD, trk, xx->orig, xx->angle, seg, 1, GetTrkGauge(trk), color, DTS_CENTERONLY); + DrawSegsO(&tempD, trk, xx->orig, xx->angle, seg, 1, GetTrkGauge(trk), color, + DTS_CENTERONLY); } - } - else if ((tempD.scale <= 10) || !multiPart) { + } else if ((tempD.scale <= 10) || !multiPart) { seg = MapPathSeg(xx, path[0]); - DrawSegsO(&tempD, trk, xx->orig, xx->angle, seg, 1, GetTrkGauge(trk), color, DTS_CENTERONLY); + DrawSegsO(&tempD, trk, xx->orig, xx->angle, seg, 1, GetTrkGauge(trk), color, + DTS_CENTERONLY); } } } EXPORT void AdvanceTurnoutPositionIndicator( - track_p trk, - coOrd pos, - coOrd* posR, - ANGLE_T* angleR) + track_p trk, + coOrd pos, + coOrd* posR, + ANGLE_T* angleR) { traverseTrack_t trvtrk; DIST_T dist; - if (GetTrkType(trk) != T_TURNOUT) - AbortProg("nextTurnoutPosition"); + CHECK( GetTrkType(trk) == T_TURNOUT ); SetCurrPathIndex(trk, GetCurrPathIndex(trk) + 1); InfoMessage(_("Turnout %d Path: %s"), GetTrkIndex(trk), GetCurrPath(trk)); - if (angleR == NULL || posR == NULL) + if (angleR == NULL || posR == NULL) { return; + } trvtrk.trk = trk; trvtrk.length = 0; trvtrk.dist = 0; trvtrk.pos = *posR; trvtrk.angle = *angleR; dist = 0; - if (!TraverseTurnout(&trvtrk, &dist)) + if (!TraverseTurnout(&trvtrk, &dist)) { return; - if (NormalizeAngle(trvtrk.angle - *angleR + 90.0) > 180) + } + if (NormalizeAngle(trvtrk.angle - *angleR + 90.0) > 180) { trvtrk.angle = NormalizeAngle(trvtrk.angle + 180.0); + } *posR = trvtrk.pos; *angleR = trvtrk.angle; } @@ -3765,27 +1846,28 @@ EXPORT void AdvanceTurnoutPositionIndicator( */ static BOOL_T MakeParallelTurnout( - track_p trk, - coOrd pos, - DIST_T sep, - DIST_T factor, - track_p* newTrk, - coOrd* p0R, - coOrd* p1R, - BOOL_T track) + track_p trk, + coOrd pos, + DIST_T sep, + DIST_T factor, + track_p* newTrk, + coOrd* p0R, + coOrd* p1R, + BOOL_T track) { ANGLE_T angle = GetTrkEndAngle(trk, 1); struct extraDataCompound_t* xx, * yy; coOrd* endPts; - trkEndPt_p endPt; int i; int option; DIST_T d; - if (NormalizeAngle(FindAngle(GetTrkEndPos(trk, 0), pos) - GetTrkEndAngle(trk, 1)) < 180.0) + if (NormalizeAngle(FindAngle(GetTrkEndPos(trk, 0), pos) - GetTrkEndAngle(trk, + 1)) < 180.0) { angle += 90; - else + } else { angle -= 90; + } /* * get all endpoints of current piece and translate them for the new piece @@ -3801,19 +1883,18 @@ static BOOL_T MakeParallelTurnout( if (newTrk) { if (track) { - endPt = MyMalloc(GetTrkEndPtCnt(trk) * sizeof(trkEndPt_t)); - endPt[0].pos = endPts[0]; - endPt[0].angle = GetTrkEndAngle(trk, 0); - endPt[1].pos = endPts[1]; - endPt[1].angle = GetTrkEndAngle(trk, 1); + TempEndPtsSet(2); + SetEndPt( TempEndPt(0), endPts[0], GetTrkEndAngle(trk,0)); + SetEndPt( TempEndPt(1), endPts[1], GetTrkEndAngle(trk,1)); yy = GET_EXTRA_DATA(trk, T_TURNOUT, extraDataCompound_t); PATHPTR_T paths = GetPaths(trk); // MakeParallelTurnout - *newTrk = NewCompound(T_TURNOUT, 0, endPt[0].pos, endPt[0].angle + 90.0, - yy->title, 2, endPt, paths, - yy->segCnt, yy->segs); + *newTrk = NewCompound(T_TURNOUT, 0, + GetEndPtPos(TempEndPt(0)), GetEndPtAngle(TempEndPt(0)) + 90.0, + yy->title, 2, TempEndPt(0), paths, + yy->segCnt, yy->segs); xx = GET_EXTRA_DATA(*newTrk, T_TURNOUT, extraDataCompound_t); xx->customInfo = yy->customInfo; @@ -3836,31 +1917,27 @@ static BOOL_T MakeParallelTurnout( SetTrkEndElev(*newTrk, 0, option, d, NULL); GetTrkEndElev(trk, 1, &option, &d); SetTrkEndElev(*newTrk, 1, option, d, NULL); - - MyFree(endPt); - } - else { + } else { + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); tempSegs(0).color = wDrawColorBlack; - tempSegs(0).width = 0; - tempSegs_da.cnt = 1; + tempSegs(0).lineWidth = 0; tempSegs(0).type = track ? SEG_STRTRK : SEG_STRLIN; tempSegs(0).u.l.pos[0] = endPts[0]; tempSegs(0).u.l.pos[1] = endPts[1]; *newTrk = MakeDrawFromSeg(zero, 0.0, &tempSegs(0)); } - } - else { + } else { /* draw some temporary track while command is in process */ + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); tempSegs(0).color = wDrawColorBlack; - tempSegs(0).width = 0; - tempSegs_da.cnt = 1; + tempSegs(0).lineWidth = 0; tempSegs(0).type = track ? SEG_STRTRK : SEG_STRLIN; tempSegs(0).u.l.pos[0] = endPts[0]; tempSegs(0).u.l.pos[1] = endPts[1]; } - if (p0R) *p0R = endPts[0]; - if (p1R) *p1R = endPts[1]; + if (p0R) { *p0R = endPts[0]; } + if (p1R) { *p1R = endPts[1]; } MyFree(endPts); return TRUE; @@ -3868,58 +1945,61 @@ static BOOL_T MakeParallelTurnout( static wBool_t CompareTurnout(track_cp trk1, track_cp trk2) { - struct extraDataCompound_t* xx1 = GET_EXTRA_DATA(trk1, T_TURNOUT, extraDataCompound_t); - struct extraDataCompound_t* xx2 = GET_EXTRA_DATA(trk2, T_TURNOUT, extraDataCompound_t); + struct extraDataCompound_t* xx1 = GET_EXTRA_DATA(trk1, T_TURNOUT, + extraDataCompound_t); + struct extraDataCompound_t* xx2 = GET_EXTRA_DATA(trk2, T_TURNOUT, + extraDataCompound_t); char* cp = message + strlen(message); REGRESS_CHECK_POS("Orig", xx1, xx2, orig) - REGRESS_CHECK_ANGLE("Angle", xx1, xx2, angle) - REGRESS_CHECK_INT("Handlaid", xx1, xx2, handlaid) - REGRESS_CHECK_INT("Flipped", xx1, xx2, flipped) - REGRESS_CHECK_INT("Ungrouped", xx1, xx2, ungrouped) - REGRESS_CHECK_INT("Split", xx1, xx2, split) - /* desc orig is not stable - REGRESS_CHECK_POS( "DescOrig", xx1, xx2, descriptionOrig ) */ - REGRESS_CHECK_POS("DescOff", xx1, xx2, descriptionOff) - REGRESS_CHECK_POS("DescSize", xx1, xx2, descriptionSize) - return CompareSegs(xx1->segs, xx1->segCnt, xx1->segs, xx1->segCnt); + REGRESS_CHECK_ANGLE("Angle", xx1, xx2, angle) + REGRESS_CHECK_INT("Handlaid", xx1, xx2, handlaid) + REGRESS_CHECK_INT("Flipped", xx1, xx2, flipped) + REGRESS_CHECK_INT("Ungrouped", xx1, xx2, ungrouped) + REGRESS_CHECK_INT("Split", xx1, xx2, split) + /* desc orig is not stable + REGRESS_CHECK_POS( "DescOrig", xx1, xx2, descriptionOrig ) */ + REGRESS_CHECK_POS("DescOff", xx1, xx2, descriptionOff) + REGRESS_CHECK_POS("DescSize", xx1, xx2, descriptionSize) + return CompareSegs(xx1->segs, xx1->segCnt, xx1->segs, xx1->segCnt); } static trackCmd_t turnoutCmds = { - "TURNOUT ", - DrawTurnout, - DistanceCompound, - DescribeCompound, - DeleteCompound, - WriteCompound, - ReadTurnout, - MoveCompound, - RotateCompound, - RescaleCompound, - NULL, - GetAngleTurnout, - SplitTurnout, - TraverseTurnout, - EnumerateCompound, - NULL, /*redraw*/ - NULL, /*trim*/ - NULL, /*merge*/ - ModifyTurnout, - NULL, /* getLength */ - GetParamsTurnout, - MoveEndPtTurnout, - QueryTurnout, - UngroupCompound, - FlipCompound, - DrawTurnoutPositionIndicator, - AdvanceTurnoutPositionIndicator, - CheckTraverseTurnout, - MakeParallelTurnout, - NULL, - NULL, - NULL, - NULL, - NULL, - CompareTurnout }; + "TURNOUT ", + DrawTurnout, + DistanceCompound, + DescribeCompound, + DeleteCompound, + WriteCompound, + ReadTurnout, + MoveCompound, + RotateCompound, + RescaleCompound, + NULL, + GetAngleTurnout, + SplitTurnout, + TraverseTurnout, + EnumerateCompound, + NULL, /*redraw*/ + NULL, /*trim*/ + NULL, /*merge*/ + ModifyTurnout, + NULL, /* getLength */ + GetParamsTurnout, + MoveEndPtTurnout, + QueryTurnout, + UngroupCompound, + FlipCompound, + DrawTurnoutPositionIndicator, + AdvanceTurnoutPositionIndicator, + CheckTraverseTurnout, + MakeParallelTurnout, + NULL, + NULL, + NULL, + NULL, + NULL, + CompareTurnout +}; #ifdef TURNOUTCMD @@ -3942,14 +2022,18 @@ static void RescaleTurnout(void) DIST_T xscale, yscale; wWinPix_t ww, hh; DIST_T w, h; + if ( curTurnout == NULL ) { + return; + } wDrawGetSize(turnoutD.d, &ww, &hh); w = ww / turnoutD.dpi; h = hh / turnoutD.dpi; - xscale = maxTurnoutDim.x / w; - yscale = maxTurnoutDim.y / h; + xscale = (curTurnout->size.x + trackGauge*2) / w; + yscale = (curTurnout->size.y + trackGauge*2) / h; turnoutD.scale = max(xscale, yscale); - if (turnoutD.scale == 0.0) + if (turnoutD.scale == 0.0) { turnoutD.scale = 1.0; + } turnoutD.size.x = w * turnoutD.scale; turnoutD.size.y = h * turnoutD.scale; return; @@ -3959,22 +2043,26 @@ static void RescaleTurnout(void) static void TurnoutChange(long changes) { static char* lastScaleName = NULL; - if (turnoutW == NULL) + if (turnoutW == NULL) { return; + } wListSetIndex(turnoutListL, 0); if ((!wWinIsVisible(turnoutW)) || - (((changes & CHANGE_SCALE) == 0 || lastScaleName == curScaleName) && - (changes & CHANGE_PARAMS) == 0)) + (((changes & CHANGE_SCALE) == 0 || lastScaleName == curScaleName) && + (changes & CHANGE_PARAMS) == 0)) { return; + } lastScaleName = curScaleName; //curTurnout = NULL; curTurnoutEp = 0; wControlShow((wControl_p)turnoutListL, FALSE); wListClear(turnoutListL); maxTurnoutDim.x = maxTurnoutDim.y = 0.0; - if (turnoutInfo_da.cnt <= 0) + if (turnoutInfo_da.cnt <= 0) { return; - curTurnout = TurnoutAdd(LABEL_TABBED | LABEL_MANUF | LABEL_PARTNO | LABEL_DESCR, GetLayoutCurScale(), turnoutListL, &maxTurnoutDim, -1); + } + curTurnout = TurnoutAdd(LABEL_TABBED | LABEL_MANUF | LABEL_PARTNO | LABEL_DESCR, + GetLayoutCurScale(), turnoutListL, &maxTurnoutDim, -1); wListSetIndex(turnoutListL, turnoutInx); wControlShow((wControl_p)turnoutListL, TRUE); if (curTurnout == NULL) { @@ -3993,16 +2081,18 @@ static void TurnoutChange(long changes) static void RedrawTurnout( wDraw_p d, void * context, wWinPix_t x, wWinPix_t y ) { RescaleTurnout(); - LOG(log_turnout, 2, ("SelTurnout(%s)\n", (curTurnout ? curTurnout->title : "<NULL>"))) + LOG(log_turnout, 2, ("SelTurnout(%s)\n", + (curTurnout ? curTurnout->title : "<NULL>"))) - wDrawClear(turnoutD.d); + wDrawClear(turnoutD.d); if (curTurnout == NULL) { return; } turnoutD.orig.x = curTurnout->orig.x - trackGauge; - turnoutD.orig.y = (curTurnout->size.y + curTurnout->orig.y) - turnoutD.size.y + trackGauge; + turnoutD.orig.y = (curTurnout->size.y + curTurnout->orig.y) - turnoutD.size.y + + trackGauge; DrawSegs(&turnoutD, zero, 0.0, curTurnout->segs, curTurnout->segCnt, - trackGauge, wDrawColorBlack); + trackGauge, wDrawColorBlack); curTurnoutEp = 0; HilightEndPt(); } @@ -4016,13 +2106,14 @@ static void TurnoutOk(void) static void TurnoutDlgUpdate( - paramGroup_p pg, - int inx, - void* valueP) + paramGroup_p pg, + int inx, + void* valueP) { turnoutInfo_t* to; - if (inx != I_LIST) return; - to = (turnoutInfo_t*)wListGetItemContext((wList_p)pg->paramPtr[inx].control, (wIndex_t) * (long*)valueP); + if (inx != I_LIST) { return; } + to = (turnoutInfo_t*)wListGetItemContext((wList_p)pg->paramPtr[inx].control, + (wIndex_t) * (long*)valueP); AddTurnout(); curTurnout = to; RedrawTurnout( turnoutD.d, NULL, 0, 0 ); @@ -4031,17 +2122,18 @@ static void TurnoutDlgUpdate( static wIndex_t TOpickEndPoint( - coOrd p, - turnoutInfo_t* to) + coOrd p, + turnoutInfo_t* to) { wIndex_t inx, i; DIST_T d, dd; coOrd posI; - d = FindDistance(p, to->endPt[0].pos); + d = FindDistance(p, GetEndPtPos(to->endPt)); + inx = 0; for (i = 1; i < to->endCnt; i++) { - posI = to->endPt[i].pos; + posI = GetEndPtPos(EndPtIndex(to->endPt, i)); if ((dd = FindDistance(p, posI)) < d) { d = dd; inx = i; @@ -4054,18 +2146,20 @@ static wIndex_t TOpickEndPoint( static void HilightEndPt(void) { coOrd p, s; - p.x = curTurnout->endPt[(int)curTurnoutEp].pos.x - trackGauge; - p.y = curTurnout->endPt[(int)curTurnoutEp].pos.y - trackGauge; + trkEndPt_p epp = EndPtIndex( curTurnout->endPt, (EPINX_T)curTurnoutEp ); + p.x = GetEndPtPos(epp).x - trackGauge; + p.y = GetEndPtPos(epp).y - trackGauge; s.x = s.y = trackGauge * 2.0 /*+ turnoutD.minSize*/; DrawHilight(&turnoutD, p, s, FALSE); } static void SelTurnoutEndPt( - wIndex_t action, - coOrd pos) + wIndex_t action, + coOrd pos) { - if (action != C_DOWN) return; + if (action != C_DOWN) { return; } + if ( curTurnout == NULL ) { return; } curTurnoutEp = TOpickEndPoint(pos, curTurnout); HilightEndPt(); @@ -4079,9 +2173,9 @@ static void SelTurnoutEndPt( * */ - /* - * STATE INFO - */ +/* + * STATE INFO + */ static struct { int state; coOrd pos; @@ -4113,13 +2207,13 @@ typedef struct { * OUT Vector - An array of end points positions and offsets */ static void PlaceTurnoutTrial( - track_p* trkR, - coOrd* posR, - ANGLE_T* angle1R, - ANGLE_T* angle2R, - int* connCntR, - DIST_T* maxDR, - vector_t* v) + track_p* trkR, + coOrd* posR, + ANGLE_T* angle1R, + ANGLE_T* angle2R, + int* connCntR, + DIST_T* maxDR, + vector_t* v) { coOrd pos = *posR; ANGLE_T aa; @@ -4132,65 +2226,68 @@ static void PlaceTurnoutTrial( DIST_T d, maxD = 0; coOrd testP = pos; - if (*trkR && (GetTrkDistance(*trkR, &testP) < trackGauge)) { //Have Track, stick with it unless outside bounds + if (*trkR && (GetTrkDistance(*trkR, + &testP) < trackGauge)) { //Have Track, stick with it unless outside bounds trk = *trkR; pos = testP; - } - else *trkR = trk = OnTrack(&pos, FALSE, TRUE); + } else { *trkR = trk = OnTrack(&pos, FALSE, TRUE); } if ((trk) != NULL && - !QueryTrack(trk, Q_CANNOT_PLACE_TURNOUT) && - (ep0 = PickEndPoint(pos, trk)) >= 0 && - !(GetTrkType(trk) == T_TURNOUT && - (trk1 = GetTrkEndTrk(trk, ep0)) && - GetTrkType(trk1) == T_TURNOUT) && - !GetLayerFrozen(GetTrkLayer(trk)) && - !GetLayerModule(GetTrkLayer(trk))) { + !QueryTrack(trk, Q_CANNOT_PLACE_TURNOUT) && + (ep0 = PickEndPoint(pos, trk)) >= 0 && + !(GetTrkType(trk) == T_TURNOUT && + (trk1 = GetTrkEndTrk(trk, ep0)) && + GetTrkType(trk1) == T_TURNOUT) && + !GetLayerFrozen(GetTrkLayer(trk)) && + !GetLayerModule(GetTrkLayer(trk))) { epPos = GetTrkEndPos(trk, ep0); d = FindDistance(pos, epPos); - if (d <= minLength) + if (d <= minLength) { pos = epPos; + } if (GetTrkType(trk) == T_TURNOUT) { //Only on the end ep0 = ep1 = PickEndPoint(pos, trk); angle = GetTrkEndAngle(trk, ep0); - } - else { + } else { angle = GetAngleAtPoint(trk, pos, &ep0, &ep1); - if (ep0 == 1) angle = NormalizeAngle(angle + 180); //Reverse if curve backwards + if (ep0 == 1) { angle = NormalizeAngle(angle + 180); } //Reverse if curve backwards } angle = NormalizeAngle(angle + 180.0); - if (NormalizeAngle(FindAngle(pos, *posR) - angle) < 180.0 && ep0 != ep1) + if (NormalizeAngle(FindAngle(pos, *posR) - angle) < 180.0 && ep0 != ep1) { angle = NormalizeAngle(angle + 180); + } *angle2R = angle; - epPos = curTurnout->endPt[(int)curTurnoutEp].pos; - *angle1R = angle = NormalizeAngle(angle - curTurnout->endPt[(int)curTurnoutEp].angle); + trkEndPt_p epp = EndPtIndex( curTurnout->endPt, (EPINX_T)curTurnoutEp ); + epPos = GetEndPtPos(epp); + *angle1R = angle = NormalizeAngle(angle - GetEndPtAngle(epp) ); Rotate(&epPos, zero, angle); pos.x -= epPos.x; pos.y -= epPos.y; *posR = pos; //The place the Turnout end sits LOG(log_turnout, 3, ("placeTurnout T%d (%0.3f %0.3f) A%0.3f\n", - GetTrkIndex(trk), pos.x, pos.y, angle)) - /*InfoMessage( "Turnout(%d): Angle=%0.3f", GetTrkIndex(trk), angle );*/ - track_p ctrk = NULL; - int ccnt = 0; - DIST_T clarge = DIST_INF; + GetTrkIndex(trk), pos.x, pos.y, angle)) + /*InfoMessage( "Turnout(%d): Angle=%0.3f", GetTrkIndex(trk), angle );*/ +// track_p ctrk = NULL; +// int ccnt = 0; +// DIST_T clarge = DIST_INF; for (i = 0; i < curTurnout->endCnt; i++) { - posI = curTurnout->endPt[i].pos; + posI = GetEndPtPos(EndPtIndex(curTurnout->endPt,(EPINX_T)i)); epPos = AddCoOrd(pos, posI, angle); - epAngle = NormalizeAngle(curTurnout->endPt[i].angle + angle); + epAngle = NormalizeAngle(GetEndPtAngle(EndPtIndex(curTurnout->endPt, + (EPINX_T)i)) + angle); conPos = epPos; if ((trk = OnTrack(&conPos, FALSE, TRUE)) != NULL && - !GetLayerFrozen(GetTrkLayer(trk)) && - !GetLayerModule(GetTrkLayer(trk))) { + !GetLayerFrozen(GetTrkLayer(trk)) && + !GetLayerModule(GetTrkLayer(trk))) { v->off = FindDistance(epPos, conPos); v->angle = FindAngle(epPos, conPos); if (GetTrkType(trk) == T_TURNOUT) { ep0 = ep1 = PickEndPoint(conPos, trk); aa = GetTrkEndAngle(trk, ep0); - } - else { + } else { aa = GetAngleAtPoint(trk, conPos, &ep0, &ep1); - if (ep0) //Backwards - so reverse + if (ep0) { //Backwards - so reverse aa = NormalizeAngle(aa + 180); + } } v->ep = i; aa = fabs(DifferenceBetweenAngles(aa, epAngle)); @@ -4198,29 +2295,29 @@ static void PlaceTurnoutTrial( int k = 0; v->trk = trk; for (int j = 0; j < i; j++) { - if (vector(j).trk == trk) k++; + if (vector(j).trk == trk) { k++; } } if (k < 2) { //Already two conns to this track connCnt++; - if (v->off > maxD) + if (v->off > maxD) { maxD = v->off; + } v++; } - } - else if ((IsClose(v->off) && (aa < connectAngle || aa>180 - connectAngle) && - !(GetTrkType(trk) == T_TURNOUT && - (trk1 = GetTrkEndTrk(trk, ep0)) && - GetTrkType(trk1) == T_TURNOUT))) { - if (v->off > maxD) + } else if ((IsClose(v->off) && (aa < connectAngle || aa>180 - connectAngle) && + !(GetTrkType(trk) == T_TURNOUT && + (trk1 = GetTrkEndTrk(trk, ep0)) && + GetTrkType(trk1) == T_TURNOUT))) { + if (v->off > maxD) { maxD = v->off; + } connCnt++; v++; } } } - } - else { + } else { trk = NULL; *trkR = NULL; } @@ -4230,7 +2327,7 @@ static void PlaceTurnoutTrial( static void PlaceTurnout( - coOrd pos, track_p trk) + coOrd pos, track_p trk) { coOrd p, pos1, pos2; track_p trk1, trk2; @@ -4243,18 +2340,20 @@ static void PlaceTurnout( pos1 = Dto.place = Dto.pos = pos; LOG(log_turnout, 1, ("Place Turnout @ %0.3fx%0.3f\n", Dto.pos.x, Dto.pos.y)); - if (curTurnoutEp >= (long)curTurnout->endCnt) + if (curTurnoutEp >= (long)curTurnout->endCnt) { curTurnoutEp = 0; + } DYNARR_SET(vector_t, vector_da, curTurnout->endCnt); - if (trk) trk1 = trk; - else trk1 = NULL; + if (trk) { trk1 = trk; } + else { trk1 = NULL; } PlaceTurnoutTrial(&trk1, &pos1, &a1, &a2, &connCnt1, &maxD1, &vector(0)); if (connCnt1 > 0) { Dto.pos = pos1; //First track pos LOG(log_turnout, 1, (" trial 1 @ %0.3fx%0.3f\n", Dto.pos.x, Dto.pos.y)); Dto.trk = trk1; //Track Dto.angle = a1; //Angle of track to put down - if (((MyGetKeyState() & WKEY_SHIFT) == 0) && (connCnt1 > 1) && (maxD1 >= 0.001)) { //Adjust if not Shift + if (((MyGetKeyState() & WKEY_SHIFT) == 0) && (connCnt1 > 1) + && (maxD1 >= 0.001)) { //Adjust if not Shift maxV = &vector(0); for (i = 1; i < connCnt1; i++) { //Ignore first point V = &vector(i); @@ -4262,13 +2361,15 @@ static void PlaceTurnout( maxV = V; } } - a3 = NormalizeAngle(Dto.angle + curTurnout->endPt[maxV->ep].angle); + a3 = NormalizeAngle(Dto.angle + GetEndPtAngle(EndPtIndex(curTurnout->endPt, + maxV->ep))); a = NormalizeAngle(a2 - a3); sina = sin(D2R(a)); if (fabs(sina) > 0.01) { d = maxV->off / sina; - if (NormalizeAngle(maxV->angle - a3) > 180) + if (NormalizeAngle(maxV->angle - a3) > 180) { d = -d; + } Translate(&pos2, pos, a2, d); trk2 = trk1; PlaceTurnoutTrial(&trk2, &pos2, &a2, &a, &connCnt2, &maxD2, &vector(0)); @@ -4286,13 +2387,12 @@ static void PlaceTurnout( if (connCnt1 > 0) { FormatCompoundTitle(listLabels, curTurnout->title); InfoMessage(_("%d connections, max distance %0.3f (%s)"), - connCnt1, PutDim(maxD1), message); - } - else { + connCnt1, PutDim(maxD1), message); + } else { Dto.trk = NULL; FormatCompoundTitle(listLabels, curTurnout->title); InfoMessage(_("0 connections (%s)"), message); - p = curTurnout->endPt[(int)curTurnoutEp].pos; + p = GetEndPtPos(EndPtIndex(curTurnout->endPt,(EPINX_T)curTurnoutEp)); Rotate(&p, zero, Dto.angle); Dto.pos.x = pos.x - p.x; Dto.pos.y = pos.y - p.y; @@ -4323,24 +2423,25 @@ static void AddTurnout(void) BOOL_T noConnections; coOrd p0, p1; - if (Dto.state == 0) + if (Dto.state == 0) { return; - - if (curTurnout->segCnt < 1 || curTurnout->endCnt < 1) { - AbortProg("addTurnout: bad cnt"); } + CHECK( curTurnout->segCnt >= 1 ); + CHECK( curTurnout->endCnt >= 1 ); + UndoStart(_("Place New Turnout"), "addTurnout"); - DYNARR_SET(trkEndPt_t, tempEndPts_da, curTurnout->endCnt); + TempEndPtsSet( curTurnout->endCnt); DYNARR_SET(junk_t, connection_da, curTurnout->endCnt); DYNARR_SET(junk_t, leftover_da, curTurnout->endCnt); for (i = 0; i < curTurnout->endCnt; i++) { coOrd posI; - posI = curTurnout->endPt[i].pos; - tempEndPts(i).pos = AddCoOrd(Dto.pos, posI, Dto.angle); - tempEndPts(i).angle = NormalizeAngle(curTurnout->endPt[i].angle + Dto.angle); + trkEndPt_p epp = EndPtIndex( curTurnout->endPt, i); + posI = GetEndPtPos( epp ); + SetEndPt( TempEndPt(i), AddCoOrd(Dto.pos, posI, Dto.angle), + NormalizeAngle(GetEndPtAngle(epp) + Dto.angle) ); } AuditTracks("addTurnout begin"); @@ -4351,56 +2452,53 @@ static void AddTurnout(void) connection(i).ep = -1; leftover(i).ep = -1; /* connect each endPt ... */ - epPos = tempEndPts(i).pos; - if ((trk = OnTrack(&epPos, FALSE, TRUE)) != NULL && //Adjust epPos onto existing track - (!GetLayerFrozen(GetTrkLayer(trk))) && - (!GetLayerModule(GetTrkLayer(trk))) && - (!QueryTrack(trk, Q_CANNOT_PLACE_TURNOUT))) { + epPos = GetEndPtPos( TempEndPt(i) ); + if ((trk = OnTrack(&epPos, FALSE, TRUE)) != NULL + && //Adjust epPos onto existing track + (!GetLayerFrozen(GetTrkLayer(trk))) && + (!GetLayerModule(GetTrkLayer(trk))) && + (!QueryTrack(trk, Q_CANNOT_PLACE_TURNOUT))) { LOG(log_turnout, 1, ("ep[%d] on T%d @(%0.3f %0.3f)\n", - i, GetTrkIndex(trk), epPos.x, epPos.y)) - DIST_T dd = DIST_INF; + i, GetTrkIndex(trk), epPos.x, epPos.y)) + DIST_T dd = DIST_INF; int nearest = -1; for (int j = 0; j < curTurnout->endCnt; j++) { - if (j < i && (connection(j).trk == trk)) { - nearest = -1; - goto nextEnd; //Track already chosen in use - } - if (dd > FindDistance(epPos, tempEndPts(j).pos)) { - dd = FindDistance(epPos, tempEndPts(j).pos); + DIST_T dd1 = FindDistance( epPos, GetEndPtPos(TempEndPt(j))); + if (dd > dd1) { + dd = dd1; nearest = j; } } - if (nearest != i) continue; //Not this one - d = FindDistance(tempEndPts(i).pos, epPos); + if (nearest != i) { continue; } //Not this one + d = FindDistance(GetEndPtPos(TempEndPt(i)), epPos); if (GetTrkType(trk) == T_TURNOUT) { ep0 = ep1 = PickEndPoint(epPos, trk); a = GetTrkEndAngle(trk, ep0); - } - else { + } else { a = GetAngleAtPoint(trk, epPos, &ep0, &ep1); } - aa = fabs(DifferenceBetweenAngles(a, tempEndPts(i).angle)); + aa = fabs(DifferenceBetweenAngles(a, GetEndPtAngle(TempEndPt(i)))); if ((QueryTrack(trk, Q_IS_CORNU) && (d < trackGauge * 2)) || - ((IsClose(d) && (((ep0 != ep1) && (aa <= connectAngle)) || ((aa <= connectAngle) || (aa > 180 - connectAngle))) && - !(GetTrkType(trk) == T_TURNOUT && - (trk1 = GetTrkEndTrk(trk, ep0)) && - GetTrkType(trk1) == T_TURNOUT)))) { + ((IsClose(d) && (((ep0 != ep1) && (aa <= connectAngle)) + || ((aa <= connectAngle) || (aa > 180 - connectAngle))) && + !(GetTrkType(trk) == T_TURNOUT && + (trk1 = GetTrkEndTrk(trk, ep0)) && + GetTrkType(trk1) == T_TURNOUT)))) { /* ... if they are close enough to a track and line up */ if (aa < 90) { epx = ep1; epy = ep0; - } - else { + } else { epx = ep0; epy = ep1; } LOG(log_turnout, 1, (" Attach! epx=%d\n", epx)) - if ((epx != epy) && - ((d = FindDistance(GetTrkEndPos(trk, epy), epPos)) < minLength) && - ((trk1 = GetTrkEndTrk(trk, epy)) != NULL)) { - epx = GetEndPtConnectedToMe(trk1, trk); - trk = trk1; - } + if ((epx != epy) && + ((d = FindDistance(GetTrkEndPos(trk, epy), epPos)) < minLength) && + ((trk1 = GetTrkEndTrk(trk, epy)) != NULL)) { + epx = GetEndPtConnectedToMe(trk1, trk); + trk = trk1; + } /* split the track at the intersection point */ AuditTracks("addTurnout [%d] before splitTrack", i); if (SplitTrack(trk, epPos, epx, &leftover(i).trk, TRUE)) { @@ -4415,8 +2513,8 @@ static void AddTurnout(void) if (connection(i).trk == leftover(j).trk) { /* yes. Remove the latest leftover piece */ LOG(log_turnout, 1, (" deleting leftover T%d\n", - GetTrkIndex(leftover(i).trk))) - AuditTracks("addTurnout [%d] before delete", i); + GetTrkIndex(leftover(i).trk))) + AuditTracks("addTurnout [%d] before delete", i); UndrawNewTrack(leftover(i).trk); DeleteTrack(leftover(i).trk, FALSE); AuditTracks("addTurnout [%d] before delete", i); @@ -4431,7 +2529,6 @@ static void AddTurnout(void) } } } - nextEnd:; } AuditTracks("addTurnout after loop"); @@ -4439,7 +2536,9 @@ static void AddTurnout(void) /* * copy data */ - newTrk = NewCompound(T_TURNOUT, 0, Dto.pos, Dto.angle, curTurnout->title, tempEndPts_da.cnt, &tempEndPts(0), GetParamPaths(curTurnout), curTurnout->segCnt, curTurnout->segs); + newTrk = NewCompound(T_TURNOUT, 0, Dto.pos, Dto.angle, curTurnout->title, + TempEndPtsCount(), TempEndPt(0), GetParamPaths(curTurnout), curTurnout->segCnt, + curTurnout->segs); xx = GET_EXTRA_DATA(newTrk, T_TURNOUT, extraDataCompound_t); xx->customInfo = curTurnout->customInfo; if (connection((int)curTurnoutEp).trk) { @@ -4459,7 +2558,7 @@ static void AddTurnout(void) AuditTracks("addTurnout T%d before connection", GetTrkIndex(newTrk)); for (i = 0; i < curTurnout->endCnt; i++) { if (connection(i).trk != NULL) { - if (GetTrkEndTrk(connection(i).trk, connection(i).ep)) continue; + if (GetTrkEndTrk(connection(i).trk, connection(i).ep)) { continue; } p0 = GetTrkEndPos(newTrk, i); p1 = GetTrkEndPos(connection(i).trk, connection(i).ep); ANGLE_T a0 = GetTrkEndAngle(newTrk, i); @@ -4471,16 +2570,16 @@ static void AddTurnout(void) if (IsClose(d) || fabs(a) <= 90.0) { trk1 = connection(i).trk; ep0 = connection(i).ep; - if (GetTrkEndTrk(trk1, ep0)) continue; + if (GetTrkEndTrk(trk1, ep0)) { continue; } DrawEndPt(&mainD, trk1, ep0, wDrawColorWhite); trackParams_t params; GetTrackParams(PARAMS_EXTEND, newTrk, GetTrkEndPos(newTrk, i), ¶ms); - SetCornuEndPt(trk1, ep0, GetTrkEndPos(newTrk, i), params.arcP, NormalizeAngle(params.angle + 180.0), params.arcR); + SetCornuEndPt(trk1, ep0, GetTrkEndPos(newTrk, i), params.arcP, + NormalizeAngle(params.angle + 180.0), params.arcR); ConnectTracks(newTrk, i, trk1, ep0); DrawEndPt(&mainD, trk1, ep0, wDrawColorBlack); } - } - else if (d < connectDistance && (a <= connectAngle)) { + } else if (d < connectDistance && (a <= connectAngle)) { noConnections = FALSE; trk1 = connection(i).trk; ep0 = connection(i).ep; @@ -4492,17 +2591,20 @@ static void AddTurnout(void) } } } - if (noConnections) + if (noConnections) { visible = TRUE; + } SetTrkVisible(newTrk, visible); SetTrkNoTies(newTrk, no_ties); SetTrkBridge(newTrk, FALSE); + SetTrkRoadbed(newTrk, FALSE); - AuditTracks("addTurnout T%d before dealing with leftovers", GetTrkIndex(newTrk)); + AuditTracks("addTurnout T%d before dealing with leftovers", + GetTrkIndex(newTrk)); /* deal with the leftovers */ for (i = 0; i < curTurnout->endCnt; i++) { if ((trk = leftover(i).trk) != NULL) { - ASSERT( !IsTrackDeleted(trk) ); + CHECK( !IsTrackDeleted(trk) ); /* move endPt beyond the turnout */ /* it it is short then delete it */ coOrd off; @@ -4524,7 +2626,8 @@ static void AddTurnout(void) DIST_T dd = DIST_INF; a = NormalizeAngle(GetTrkEndAngle(lt, le) + 180.0); for (ep = 0; ep < curTurnout->endCnt; ep++) { - FindPos(&off, NULL, GetTrkEndPos(newTrk, ep), GetTrkEndPos(lt, le), a, DIST_INF); + FindPos(&off, NULL, GetTrkEndPos(newTrk, ep), GetTrkEndPos(lt, le), a, + DIST_INF); pos = GetTrkEndPos(newTrk, ep); DIST_T d = GetTrkDistance(lt, &pos); if ((d < dd) && (d < trackGauge / 2)) { @@ -4542,26 +2645,29 @@ static void AddTurnout(void) dd = d; } } - if (off.x > maxX) + if (off.x > maxX) { maxX = off.x; + } } maxX += trackGauge; pos = Dto.pos; if (QueryTrack(lt, Q_IS_CORNU)) { if (nearest_ep >= 0) { - SetCornuEndPt(lt, le, nearest_pos, nearest_center, nearest_angle, nearest_radius); + SetCornuEndPt(lt, le, nearest_pos, nearest_center, nearest_angle, + nearest_radius); ConnectTracks(newTrk, nearest_ep, lt, le); - } - else { + } else { UndrawNewTrack(lt); DeleteTrack(lt, TRUE); leftover(i).trk = NULL; } - } - else { - AuditTracks("addTurnout T%d[%d] before trimming L%d[%d]", GetTrkIndex(newTrk), i, GetTrkIndex(lt), le); - wBool_t rc = TrimTrack(lt, le, maxX, nearest_pos, nearest_angle, nearest_radius, nearest_center); - AuditTracks("addTurnout T%d[%d] after trimming L%d[%d]", GetTrkIndex(newTrk), i, GetTrkIndex(lt), le); + } else { + AuditTracks("addTurnout T%d[%d] before trimming L%d[%d]", GetTrkIndex(newTrk), + i, GetTrkIndex(lt), le); + TrimTrack(lt, le, maxX, nearest_pos, nearest_angle, nearest_radius, + nearest_center); + AuditTracks("addTurnout T%d[%d] after trimming L%d[%d]", GetTrkIndex(newTrk), i, + GetTrkIndex(lt), le); } } @@ -4583,8 +2689,9 @@ static void AddTurnout(void) static void TurnoutRotate(void* pangle) { - if (Dto.state == 0) + if (Dto.state == 0) { return; + } ANGLE_T angle = (ANGLE_T)VP2L(pangle); angle /= 1000.0; Dto.pos = cmdMenuPos; @@ -4596,29 +2703,31 @@ static void TurnoutRotate(void* pangle) static dynArr_t anchors_da; #define anchors(N) DYNARR_N(trkSeg_t,anchors_da,N) -void static CreateArrowAnchor(coOrd pos, ANGLE_T a, DIST_T len) { +void static CreateArrowAnchor(coOrd pos, ANGLE_T a, DIST_T len) +{ DYNARR_APPEND(trkSeg_t, anchors_da, 1); int i = anchors_da.cnt - 1; anchors(i).type = SEG_STRLIN; - anchors(i).width = 0; + anchors(i).lineWidth = 0; anchors(i).u.l.pos[0] = pos; Translate(&anchors(i).u.l.pos[1], pos, NormalizeAngle(a + 135), len); anchors(i).color = wDrawColorBlue; DYNARR_APPEND(trkSeg_t, anchors_da, 1); i = anchors_da.cnt - 1; anchors(i).type = SEG_STRLIN; - anchors(i).width = 0; + anchors(i).lineWidth = 0; anchors(i).u.l.pos[0] = pos; Translate(&anchors(i).u.l.pos[1], pos, NormalizeAngle(a - 135), len); anchors(i).color = wDrawColorBlue; } -void static CreateRotateAnchor(coOrd pos) { +void static CreateRotateAnchor(coOrd pos) +{ DIST_T d = tempD.scale * 0.15; DYNARR_APPEND(trkSeg_t, anchors_da, 1); int i = anchors_da.cnt - 1; anchors(i).type = SEG_CRVLIN; - anchors(i).width = 0.5; + anchors(i).lineWidth = 0.5; anchors(i).u.c.center = pos; anchors(i).u.c.a0 = 180.0; anchors(i).u.c.a1 = 360.0; @@ -4631,11 +2740,14 @@ void static CreateRotateAnchor(coOrd pos) { } } -void static CreateMoveAnchor(coOrd pos) { +void static CreateMoveAnchor(coOrd pos) +{ DYNARR_SET(trkSeg_t, anchors_da, anchors_da.cnt + 5); - DrawArrowHeads(&DYNARR_N(trkSeg_t, anchors_da, anchors_da.cnt - 5), pos, 0, TRUE, wDrawColorBlue); + DrawArrowHeads(&DYNARR_N(trkSeg_t, anchors_da, anchors_da.cnt - 5), pos, 0, + TRUE, wDrawColorBlue); DYNARR_SET(trkSeg_t, anchors_da, anchors_da.cnt + 5); - DrawArrowHeads(&DYNARR_N(trkSeg_t, anchors_da, anchors_da.cnt - 5), pos, 90, TRUE, wDrawColorBlue); + DrawArrowHeads(&DYNARR_N(trkSeg_t, anchors_da, anchors_da.cnt - 5), pos, 90, + TRUE, wDrawColorBlue); } /** @@ -4647,14 +2759,14 @@ void static CreateMoveAnchor(coOrd pos) { */ EXPORT STATUS_T CmdTurnoutAction( - wAction_t action, - coOrd pos) + wAction_t action, + coOrd pos) { ANGLE_T angle; static BOOL_T validAngle; - static ANGLE_T baseAngle; static coOrd origPos; #ifdef NEWROTATE + static ANGLE_T baseAngle; static ANGLE_T origAngle; #endif @@ -4672,36 +2784,37 @@ EXPORT STATUS_T CmdTurnoutAction( DYNARR_RESET(trkSeg_t, anchors_da); if (Dto.state && (MyGetKeyState() & WKEY_CTRL)) { CreateRotateAnchor(pos); - } - else { + } else { CreateMoveAnchor(pos); } return C_CONTINUE; break; case C_DOWN: DYNARR_RESET(trkSeg_t, anchors_da); - if (curTurnout == NULL) return C_CONTINUE; + if (curTurnout == NULL) { return C_CONTINUE; } PlaceTurnout(pos, NULL); Dto.state = 1; return C_CONTINUE; case C_MOVE: DYNARR_RESET(trkSeg_t, anchors_da); - if (curTurnout == NULL) return C_CONTINUE; - if (curTurnoutEp >= (long)curTurnout->endCnt) + if (curTurnout == NULL) { return C_CONTINUE; } + if (curTurnoutEp >= (long)curTurnout->endCnt) { curTurnoutEp = 0; + } Dto.state = 1; PlaceTurnout(pos, Dto.trk); return C_CONTINUE; case C_UP: DYNARR_RESET(trkSeg_t, anchors_da); - InfoMessage(_("Left-Drag to place, Ctrl+Left-Drag or Right-Drag to Rotate, Space or Enter to accept, Esc to Cancel")); + InfoMessage( + _("Left-Drag to place, Ctrl+Left-Drag or Right-Drag to Rotate, Space or Enter to accept, Esc to Cancel")); return C_CONTINUE; case C_RDOWN: DYNARR_RESET(trkSeg_t, anchors_da); - if (curTurnout == NULL) return C_CONTINUE; + if (curTurnout == NULL) { return C_CONTINUE; } if (Dto.state == 0) { Dto.pos = pos; // If first, use pos, otherwise use current LOG(log_turnout, 1, ("RDOWN @ %0.3fx%0.3f\n", Dto.pos.x, Dto.pos.y)); @@ -4712,19 +2825,23 @@ EXPORT STATUS_T CmdTurnoutAction( #ifdef NEWROTATE origAngle = Dto.angle; #else - Rotate(&origPos, Dto.rot0, -(Dto.angle + curTurnout->endPt[(int)curTurnoutEp].angle)); + Rotate(&origPos, Dto.rot0, + -(Dto.angle + GetEndPtAngle(EndPtIndex(curTurnout->endPt, + (EPINX_T)curTurnoutEp)))); #endif validAngle = FALSE; return C_CONTINUE; case C_RMOVE: DYNARR_RESET(trkSeg_t, anchors_da); - if (curTurnout == NULL) return C_CONTINUE; + if (curTurnout == NULL) { return C_CONTINUE; } Dto.rot1 = pos; if (FindDistance(Dto.rot0, Dto.rot1) > 0.1 * mainD.scale) { angle = FindAngle(Dto.rot0, Dto.rot1); if (!validAngle) { +#ifdef NEWROTATE baseAngle = angle/* - Dto.angle*/; +#endif validAngle = TRUE; } Dto.pos = origPos; @@ -4734,36 +2851,41 @@ EXPORT STATUS_T CmdTurnoutAction( Dto.angle = NormalizeAngle(origAngle + angle); #else angle += 180.0; - Dto.angle = angle - curTurnout->endPt[(int)curTurnoutEp].angle; + Dto.angle = angle - GetEndPtAngle(EndPtIndex(curTurnout->endPt, + (EPINX_T)curTurnoutEp)); #endif Rotate(&Dto.pos, Dto.rot0, angle); LOG(log_turnout, 1, ("RMOVE post @ %0.3fx%0.3f\n", Dto.pos.x, Dto.pos.y)); } FormatCompoundTitle(listLabels, curTurnout->title); - InfoMessage(_("Angle = %0.3f (%s)"), PutAngle(NormalizeAngle(Dto.angle + 90.0)), message); + InfoMessage(_("Angle = %0.3f (%s)"), PutAngle(NormalizeAngle(Dto.angle + 90.0)), + message); Dto.state = 2; return C_CONTINUE; case C_RUP: DYNARR_RESET(trkSeg_t, anchors_da); - if (curTurnout == NULL) return C_CONTINUE; + if (curTurnout == NULL) { return C_CONTINUE; } Dto.state = 1; - InfoMessage(_("Left-Drag to place, Ctrl+Left-Drag or Right-Drag to Rotate, Space or Enter to accept, Esc to Cancel")); + InfoMessage( + _("Left-Drag to place, Ctrl+Left-Drag or Right-Drag to Rotate, Space or Enter to accept, Esc to Cancel")); return C_CONTINUE; case C_LCLICK: DYNARR_RESET(trkSeg_t, anchors_da); - if (curTurnout == NULL) return C_CONTINUE; + if (curTurnout == NULL) { return C_CONTINUE; } if (MyGetKeyState() & WKEY_SHIFT) { - angle = curTurnout->endPt[(int)curTurnoutEp].angle; + angle = GetEndPtAngle( EndPtIndex( curTurnout->endPt, (EPINX_T)curTurnoutEp ) ); curTurnoutEp++; - if (curTurnoutEp >= (long)curTurnout->endCnt) + if (curTurnoutEp >= (long)curTurnout->endCnt) { curTurnoutEp = 0; - if (Dto.trk == NULL) - Dto.angle = NormalizeAngle(Dto.angle + (angle - curTurnout->endPt[(int)curTurnoutEp].angle)); + } + if (Dto.trk == NULL) { + Dto.angle = NormalizeAngle(Dto.angle + (angle - GetEndPtAngle( EndPtIndex( + curTurnout->endPt, (EPINX_T)curTurnoutEp)))); + } PlaceTurnout(Dto.place, Dto.trk); - } - else { + } else { CmdTurnoutAction(C_DOWN, pos); CmdTurnoutAction(C_UP, pos); } @@ -4773,14 +2895,16 @@ EXPORT STATUS_T CmdTurnoutAction( wSetCursor(mainD.d, defaultCursor); if (Dto.state) { DrawSegs(&tempD, Dto.pos, Dto.angle, - curTurnout->segs, curTurnout->segCnt, trackGauge, selectedColor); + curTurnout->segs, curTurnout->segCnt, trackGauge, selectedColor); } + DrawSegsDA(&tempD, NULL, zero, 0.0, &anchors_da, trackGauge, wDrawColorBlack, + 0 ); if (anchors_da.cnt > 0) { - DrawSegs(&tempD, zero, 0.0, &anchors(0), anchors_da.cnt, trackGauge, wDrawColorBlack); wSetCursor(mainD.d, wCursorNone); } - if (Dto.state == 2) + if (Dto.state == 2) { DrawLine(&tempD, Dto.rot0, Dto.rot1, 0, wDrawColorBlue); + } return C_CONTINUE; case C_CANCEL: @@ -4791,9 +2915,10 @@ EXPORT STATUS_T CmdTurnoutAction( return C_TERMINATE; case C_TEXT: - if ((action >> 8) != ' ') + if ((action >> 8) != ' ') { return C_CONTINUE; - /*no break*/ + } + /*no break*/ case C_OK: DYNARR_RESET(trkSeg_t, anchors_da); AddTurnout(); @@ -4803,10 +2928,11 @@ EXPORT STATUS_T CmdTurnoutAction( case C_FINISH: DYNARR_RESET(trkSeg_t, anchors_da); - if (Dto.state != 0 && Dto.trk != NULL) + if (Dto.state != 0 && Dto.trk != NULL) { CmdTurnoutAction(C_OK, pos); - else + } else { CmdTurnoutAction(C_CANCEL, pos); + } return C_TERMINATE; case C_CMDMENU: @@ -4822,8 +2948,8 @@ EXPORT STATUS_T CmdTurnoutAction( #ifdef TURNOUTCMD static STATUS_T CmdTurnout( - wAction_t action, - coOrd pos) + wAction_t action, + coOrd pos) { wIndex_t turnoutIndex; turnoutInfo_t* turnoutPtr; @@ -4832,8 +2958,10 @@ static STATUS_T CmdTurnout( case C_START: if (turnoutW == NULL) { - /* turnoutW = ParamCreateDialog( &turnoutPG, MakeWindowTitle("Turnout"), "Ok", , (paramActionCancelProc)Reset, TRUE, NULL, F_RESIZE|F_RECALLSIZE, TurnoutDlgUpdate ); */ - turnoutW = ParamCreateDialog(&turnoutPG, MakeWindowTitle(_("Turnout")), _("Close"), (paramActionOkProc)TurnoutOk, wHide, TRUE, NULL, F_RESIZE | F_RECALLSIZE | PD_F_ALT_CANCELLABEL, TurnoutDlgUpdate); + /* turnoutW = ParamCreateDialog( &turnoutPG, MakeWindowTitle("Fixed-Track"), "Ok", , (paramActionCancelProc)Reset, TRUE, NULL, F_RESIZE|F_RECALLSIZE, TurnoutDlgUpdate ); */ + turnoutW = ParamCreateDialog(&turnoutPG, MakeWindowTitle(_("Add Fixed-Track")), + _("Close"), (paramActionOkProc)TurnoutOk, wHide, TRUE, NULL, + F_RESIZE | F_RECALLSIZE | PD_F_ALT_CANCELLABEL, TurnoutDlgUpdate); InitNewTurn(turnoutNewM); } /* ParamDialogOkActive( &turnoutPG, FALSE ); */ @@ -4862,26 +2990,32 @@ static STATUS_T CmdTurnout( case C_DOWN: case C_RDOWN: ParamDialogOkActive(&turnoutPG, TRUE); - if (hideTurnoutWindow) + if (hideTurnoutWindow) { wHide(turnoutW); - if (((action & 0xFF) == C_DOWN) && (MyGetKeyState() & WKEY_CTRL)) - return CmdTurnoutAction(C_RDOWN, pos); //Convert CTRL into Right - /*no break*/ + } + if (((action & 0xFF) == C_DOWN) && (MyGetKeyState() & WKEY_CTRL)) { + return CmdTurnoutAction(C_RDOWN, pos); //Convert CTRL into Right + } + /*no break*/ case C_MOVE: - if (MyGetKeyState() & WKEY_CTRL) + if (MyGetKeyState() & WKEY_CTRL) { return CmdTurnoutAction(C_RMOVE, pos); - /*no break*/ + } + /*no break*/ case C_RMOVE: return CmdTurnoutAction(action, pos); case C_UP: case C_RUP: - if (hideTurnoutWindow) + if (hideTurnoutWindow) { wShow(turnoutW); + } - InfoMessage(_("Left-Drag to place, Ctrl+Left-Drag or Right-Drag to Rotate, Space or Enter to accept, Esc to Cancel")); - if (((action & 0xFF) == C_UP) && (MyGetKeyState() & WKEY_CTRL)) + InfoMessage( + _("Left-Drag to place, Ctrl+Left-Drag or Right-Drag to Rotate, Space or Enter to accept, Esc to Cancel")); + if (((action & 0xFF) == C_UP) && (MyGetKeyState() & WKEY_CTRL)) { return CmdTurnoutAction(C_RUP, pos); + } return CmdTurnoutAction(action, pos); case C_LCLICK: @@ -4919,22 +3053,24 @@ static STATUS_T CmdTurnout( */ static char* CmdTurnoutHotBarProc( - hotBarProc_e op, - void* data, - drawCmd_p d, - coOrd* origP) + hotBarProc_e op, + void* data, + drawCmd_p d, + coOrd* origP) { turnoutInfo_t* to = (turnoutInfo_t*)data; switch (op) { case HB_SELECT: /* new element is selected */ CmdTurnoutAction(C_FINISH, zero); /* finish current operation */ curTurnout = to; - DoCommandB(I2VP(turnoutHotBarCmdInx)); /* continue with new turnout / structure */ + DoCommandB(I2VP( + turnoutHotBarCmdInx)); /* continue with new turnout / structure */ return NULL; case HB_LISTTITLE: FormatCompoundTitle(listLabels, to->title); - if (message[0] == '\0') + if (message[0] == '\0') { FormatCompoundTitle(listLabels | LABEL_DESCR, to->title); + } return message; case HB_BARTITLE: FormatCompoundTitle(hotBarLabels << 1, to->title); @@ -4956,10 +3092,13 @@ EXPORT void AddHotBarTurnouts(void) for (inx = 0; inx < turnoutInfo_da.cnt; inx++) { to = turnoutInfo(inx); if (!(IsParamValid(to->paramFileIndex) && - to->segCnt > 0 && - (FIT_NONE != CompatibleScale(FIT_TURNOUT, to->scaleInx, GetLayoutCurScale())))) + to->segCnt > 0 && + (FIT_NONE != CompatibleScale(FIT_TURNOUT, to->scaleInx, + GetLayoutCurScale())))) { continue; - AddHotBarElement(to->contentsLabel, to->size, to->orig, TRUE, FALSE, to->barScale, to, CmdTurnoutHotBarProc); + } + AddHotBarElement(to->contentsLabel, to->size, to->orig, TRUE, FALSE, + to->barScale, to, CmdTurnoutHotBarProc); } } @@ -4972,8 +3111,8 @@ EXPORT void AddHotBarTurnouts(void) */ static STATUS_T CmdTurnoutHotBar( - wAction_t action, - coOrd pos) + wAction_t action, + coOrd pos) { switch (action & 0xFF) { @@ -4987,8 +3126,9 @@ static STATUS_T CmdTurnoutHotBar( FormatCompoundTitle(listLabels | LABEL_DESCR, curTurnout->title); InfoMessage(_("Place %s and draw into position"), message); wIndex_t listIndex = FindListItemByContext(turnoutListL, curTurnout); - if (listIndex >= 0) + if (listIndex >= 0) { turnoutInx = listIndex; + } ParamLoadControls(&turnoutPG); ParamGroupRecord(&turnoutPG); return CmdTurnoutAction(action, pos); @@ -5000,7 +3140,7 @@ static STATUS_T CmdTurnoutHotBar( if (MyGetKeyState() & WKEY_CTRL) { return CmdTurnoutAction(C_RDOWN, pos); } - /*no break*/ + /*no break*/ case C_RDOWN: return CmdTurnoutAction(action, pos); @@ -5008,7 +3148,7 @@ static STATUS_T CmdTurnoutHotBar( if (MyGetKeyState() & WKEY_CTRL) { return CmdTurnoutAction(C_RMOVE, pos); } - /*no break*/ + /*no break*/ case C_RMOVE: return CmdTurnoutAction(action, pos); @@ -5016,37 +3156,44 @@ static STATUS_T CmdTurnoutHotBar( if (MyGetKeyState() & WKEY_CTRL) { return CmdTurnoutAction(C_RUP, pos); } - /*no break*/ + /*no break*/ case C_RUP: - InfoMessage(_("Left-Drag to place, Ctrl+Left-Drag or Right-Drag to Rotate, Space or Enter to accept, Esc to Cancel")); + InfoMessage( + _("Left-Drag to place, Ctrl+Left-Drag or Right-Drag to Rotate, Space or Enter to accept, Esc to Cancel")); return CmdTurnoutAction(action, pos); case C_REDRAW: return CmdTurnoutAction(action, pos); case C_TEXT: - if ((action >> 8) != ' ') + if ((action >> 8) != ' ') { return C_CONTINUE; - /* no break*/ + } + /* no break*/ case C_OK: CmdTurnoutAction(action, pos); return C_CONTINUE; case C_CANCEL: HotBarCancel(); - /*no break*/ + /*no break*/ default: return CmdTurnoutAction(action, pos); } } #ifdef TURNOUTCMD -#include "bitmaps/turnout.xpm" +#include "bitmaps/turnout.xpm3" EXPORT void InitCmdTurnout(wMenu_p menu) { - AddMenuButton(menu, CmdTurnout, "cmdTurnout", _("Predefined Track"), wIconCreatePixMap(turnout_xpm[iconSize]), LEVEL0_50, IC_WANT_MOVE | IC_STICKY | IC_LCLICK | IC_CMDMENU | IC_POPUP2, ACCL_TURNOUT, NULL); - turnoutHotBarCmdInx = AddMenuButton(menu, CmdTurnoutHotBar, "cmdTurnoutHotBar", "", NULL, LEVEL0_50, IC_WANT_MOVE | IC_STICKY | IC_LCLICK | IC_CMDMENU | IC_POPUP2, 0, NULL); + AddMenuButton(menu, CmdTurnout, "cmdNewFixedTrack", _("Fixed-Track"), + wIconCreatePixMap(turnout_xpm3[iconSize]), LEVEL0_50, + IC_WANT_MOVE | IC_STICKY | IC_LCLICK | IC_CMDMENU | IC_POPUP2, ACCL_TURNOUT, + NULL); + turnoutHotBarCmdInx = AddMenuButton(menu, CmdTurnoutHotBar, "cmdTurnoutHotBar", + "", NULL, LEVEL0_50, IC_WANT_MOVE | IC_STICKY | IC_LCLICK | IC_CMDMENU | + IC_POPUP2, 0, NULL); RegisterChangeNotification(TurnoutChange); ParamRegister(&turnoutPG); log_turnout = LogFindIndex("turnout"); @@ -5072,7 +3219,8 @@ EXPORT void InitTrkTurnout(void) wDrawable_t turnoutD; -void wListAddValue(wList_p bl, char* val, wIcon_p, void* listData, void* itemData) +void wListAddValue(wList_p bl, char* val, wIcon_p, void* listData, + void* itemData) { } @@ -5095,7 +3243,8 @@ void GetTrkCurveCenter(track_p t, coOrd* pos, DIST_T* radius) #ifdef NOTRACK_C -track_p NewTrack(wIndex_t index, TRKTYP_T type, EPINX_T endCnt, SIZE_T extraSize) +track_p NewTrack(wIndex_t index, TRKTYP_T type, EPINX_T endCnt, + SIZE_T extraSize) { return NULL; } diff --git a/app/bin/cturntbl.c b/app/bin/cturntbl.c index 2ef49d1..bab9850 100644 --- a/app/bin/cturntbl.c +++ b/app/bin/cturntbl.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "cstraigh.h" @@ -32,12 +32,12 @@ static TRKTYP_T T_TURNTABLE = -1; typedef struct extraDataTurntable_t { - extraDataBase_t base; - coOrd pos; - DIST_T radius; - EPINX_T currEp; - BOOL_T reverse; - } extraDataTurntable_t; + extraDataBase_t base; + coOrd pos; + DIST_T radius; + EPINX_T currEp; + BOOL_T reverse; +} extraDataTurntable_t; static DIST_T turntableDiameter = 1.0; @@ -46,18 +46,21 @@ EXPORT ANGLE_T turntableAngle = 0.0; static paramFloatRange_t r1_100 = { 1.0, 100.0, 100 }; static paramData_t turntablePLs[] = { #define turntableDiameterPD (turntablePLs[0]) - { PD_FLOAT, &turntableDiameter, "diameter", PDO_DIM|PDO_NOPREF, &r1_100, N_("Diameter") } }; + { PD_FLOAT, &turntableDiameter, "diameter", PDO_DIM|PDO_NOPREF, &r1_100, N_("Diameter") } +}; static paramGroup_t turntablePG = { "turntable", 0, turntablePLs, COUNT( turntablePLs ) }; static BOOL_T ValidateTurntablePosition( - track_p trk ) + track_p trk ) { EPINX_T ep, epCnt = GetTrkEndPtCnt(trk); - - if ( epCnt <= 0 ) + + if ( epCnt <= 0 ) { return FALSE; - struct extraDataTurntable_t * xx = GET_EXTRA_DATA(trk, T_TURNTABLE, extraDataTurntable_t); + } + struct extraDataTurntable_t * xx = GET_EXTRA_DATA(trk, T_TURNTABLE, + extraDataTurntable_t); ep = xx->currEp; do { if ( GetTrkEndTrk(trk,ep) ) { @@ -65,8 +68,9 @@ static BOOL_T ValidateTurntablePosition( return TRUE; } ep++; - if ( ep >= epCnt ) + if ( ep >= epCnt ) { ep = 0; + } } while ( ep != xx->currEp ); return FALSE; } @@ -75,7 +79,8 @@ static BOOL_T ValidateTurntablePosition( static void ComputeTurntableBoundingBox( track_p trk ) { coOrd hi, lo; - struct extraDataTurntable_t *xx = GET_EXTRA_DATA(trk, T_TURNTABLE, extraDataTurntable_t); + struct extraDataTurntable_t *xx = GET_EXTRA_DATA(trk, T_TURNTABLE, + extraDataTurntable_t); hi.x = xx->pos.x+xx->radius; lo.x = xx->pos.x-xx->radius; hi.y = xx->pos.y+xx->radius; @@ -99,57 +104,70 @@ static track_p NewTurntable( coOrd p, DIST_T r ) #ifdef LATER -static void PruneTurntable( track_p trk ) --{ -- EPINX_T inx0; -- EPINX_T inx1; -- for (inx0=inx1=0; inx0<trk->endCnt; inx0++) { -- if (GetTrkEndTrk(trk,inx0) == NULL) { -- continue; -- } else { -- if (inx0 != inx1) { -- trk->endPt[inx1] = GetTrkEndTrk(trk,inx0); -- } -- inx1++; -- } -- } -- trk->endPt = Realloc( trk->endPt, inx1*sizeof trk->endPt[0] ); -- trk->endCnt = inx1; --} + - +{ + - EPINX_T inx0; + - EPINX_T inx1; + - for (inx0=inx1=0; inx0<trk->endCnt; inx0++) { + - if (GetTrkEndTrk(trk,inx0) == NULL) { + - continue; + - + } else { + - if (inx0 != inx1) { + - trk->endPt[inx1] = GetTrkEndTrk(trk,inx0); + - + } + - inx1++; + - + } + - + } + - trk->endPt = Realloc( trk->endPt, inx1*sizeof trk->endPt[0] ); + - trk->endCnt = inx1; + - + } #endif static ANGLE_T ConstrainTurntableAngle( track_p trk, coOrd pos ) { - struct extraDataTurntable_t *xx = GET_EXTRA_DATA(trk, T_TURNTABLE, extraDataTurntable_t); + struct extraDataTurntable_t *xx = GET_EXTRA_DATA(trk, T_TURNTABLE, + extraDataTurntable_t); ANGLE_T a, al, ah, aa, aaa; EPINX_T inx, cnt; a = FindAngle( xx->pos, pos ); cnt = GetTrkEndPtCnt(trk); - if ( cnt == 0 || turntableAngle == 0.0 ) + if ( cnt == 0 || turntableAngle == 0.0 ) { return a; + } ah = 360.0; al = 360.0; for ( inx = 0; inx<cnt; inx++ ) { - if (GetTrkEndTrk(trk,inx) == NULL) + if (GetTrkEndTrk(trk,inx) == NULL) { continue; + } aa = NormalizeAngle( GetTrkEndAngle(trk,inx) - a ); - if (aa < al) + if (aa < al) { al = aa; + } aa = 360 - aa; - if (aa < ah) + if (aa < ah) { ah = aa; + } } - if (al+ah>361) + if (al+ah>361) { return a; + } if ( (al+ah) < turntableAngle*2.0 ) { ErrorMessage( MSG_NO_ROOM_BTW_TRKS ); aaa = -1; - } else if ( al <= turntableAngle) + } else if ( al <= turntableAngle) { aaa = NormalizeAngle( a - ( turntableAngle - al ) ); - else if ( ah <= turntableAngle) + } else if ( ah <= turntableAngle) { aaa = NormalizeAngle( a + ( turntableAngle - ah ) ); - else + } else { aaa = a; + } #ifdef VERBOSE Lprintf( "CTA( %0.3f ) [ %0.3f .. %0.3f ] = %0.3f\n", a, ah, al, aaa ); #endif @@ -158,10 +176,11 @@ static ANGLE_T ConstrainTurntableAngle( track_p trk, coOrd pos ) static EPINX_T NewTurntableEndPt( track_p trk, ANGLE_T angle ) { - struct extraDataTurntable_t *xx = GET_EXTRA_DATA(trk, T_TURNTABLE, extraDataTurntable_t); + struct extraDataTurntable_t *xx = GET_EXTRA_DATA(trk, T_TURNTABLE, + extraDataTurntable_t); EPINX_T ep = -1; /* Reuse an old empty ep if it exists */ - for (int i =0;i< GetTrkEndPtCnt(trk)-1;i++) { + for (int i =0; i< GetTrkEndPtCnt(trk)-1; i++) { if (GetTrkEndTrk(trk,i) == NULL) { ep = i; break; @@ -179,14 +198,16 @@ static EPINX_T NewTurntableEndPt( track_p trk, ANGLE_T angle ) static void TurntableGetCenter( track_p trk, coOrd * center, DIST_T * radius) { - struct extraDataTurntable_t *xx = GET_EXTRA_DATA(trk, T_TURNTABLE, extraDataTurntable_t); + struct extraDataTurntable_t *xx = GET_EXTRA_DATA(trk, T_TURNTABLE, + extraDataTurntable_t); *center = xx->pos; *radius = xx->radius; } static void DrawTurntable( track_p t, drawCmd_p d, wDrawColor color ) { - struct extraDataTurntable_t *xx = GET_EXTRA_DATA(t, T_TURNTABLE, extraDataTurntable_t); + struct extraDataTurntable_t *xx = GET_EXTRA_DATA(t, T_TURNTABLE, + extraDataTurntable_t); coOrd p0, p1; EPINX_T ep; long widthOptions = DTS_LEFT|DTS_RIGHT; @@ -200,24 +221,29 @@ static void DrawTurntable( track_p t, drawCmd_p d, wDrawColor color ) p0 = GetTrkEndPos( t, xx->currEp ); Translate( &p1, xx->pos, GetTrkEndAngle(t,xx->currEp)+180.0, xx->radius ); } - if (color == wDrawColorBlack) + if (color == wDrawColorBlack) { color = normalColor; - DrawArc( d, xx->pos, xx->radius, 0.0, 360.0, 0, (color == wDrawColorPreviewSelected || color == wDrawColorPreviewUnselected)?3:0, color ); + } + DrawArc( d, xx->pos, xx->radius, 0.0, 360.0, 0, + (color == wDrawColorPreviewSelected + || color == wDrawColorPreviewUnselected)?3:0, color ); DrawStraightTrack( d, p0, p1, FindAngle(p0,p1), t, color, widthOptions ); for ( ep=0; ep<GetTrkEndPtCnt(t); ep++ ) { - if (GetTrkEndTrk(t,ep) != NULL ) + if (GetTrkEndTrk(t,ep) != NULL ) { DrawEndPt( d, t, ep, color ); + } } if ( ((d->options&DC_SIMPLE)==0) && - (labelWhen == 2 || (labelWhen == 1 && (d->options&DC_PRINT))) && - labelScale >= d->scale ) { + (labelWhen == 2 || (labelWhen == 1 && (d->options&DC_PRINT))) && + labelScale >= d->scale ) { LabelLengths( d, t, color ); } } static DIST_T DistanceTurntable( track_p trk, coOrd * p ) { - struct extraDataTurntable_t *xx = GET_EXTRA_DATA(trk, T_TURNTABLE, extraDataTurntable_t); + struct extraDataTurntable_t *xx = GET_EXTRA_DATA(trk, T_TURNTABLE, + extraDataTurntable_t); DIST_T d; ANGLE_T a; coOrd pos0, pos1; @@ -227,8 +253,9 @@ static DIST_T DistanceTurntable( track_p trk, coOrd * p ) a = FindAngle( xx->pos, *p ); Translate( p, xx->pos, a, d+xx->radius ); } else { - if ( !ValidateTurntablePosition(trk) ) + if ( !ValidateTurntablePosition(trk) ) { return DIST_INF; + } pos0 = GetTrkEndPos(trk,xx->currEp); Translate( &pos1, xx->pos, GetTrkEndAngle(trk,xx->currEp)+180.0, xx->radius ); LineDistance( p, pos0, pos1 ); @@ -237,34 +264,39 @@ static DIST_T DistanceTurntable( track_p trk, coOrd * p ) } static struct { - coOrd orig; - DIST_T diameter; - long epCnt; - unsigned int layerNumber; - } trntblData; + coOrd orig; + DIST_T diameter; + long epCnt; + unsigned int layerNumber; +} trntblData; typedef enum { OR, RA, EC, LY } trntblDesc_e; static descData_t trntblDesc[] = { -/*OR*/ { DESC_POS, N_("Origin: X"), &trntblData.orig }, -/*RA*/ { DESC_DIM, N_("Diameter"), &trntblData.diameter }, -/*EC*/ { DESC_LONG, N_("# EndPt"), &trntblData.epCnt }, -/*LY*/ { DESC_LAYER, N_("Layer"), &trntblData.layerNumber }, - { DESC_NULL } }; + /*OR*/ { DESC_POS, N_("Origin: X"), &trntblData.orig }, + /*RA*/ { DESC_DIM, N_("Diameter"), &trntblData.diameter }, + /*EC*/ { DESC_LONG, N_("# EndPt"), &trntblData.epCnt }, + /*LY*/ { DESC_LAYER, N_("Layer"), &trntblData.layerNumber }, + { DESC_NULL } +}; -static void UpdateTurntable( track_p trk, int inx, descData_p descUpd, BOOL_T final ) +static void UpdateTurntable( track_p trk, int inx, descData_p descUpd, + BOOL_T final ) { - struct extraDataTurntable_t *xx = GET_EXTRA_DATA(trk, T_TURNTABLE, extraDataTurntable_t); + struct extraDataTurntable_t *xx = GET_EXTRA_DATA(trk, T_TURNTABLE, + extraDataTurntable_t); - if ( inx == -1 ) + if ( inx == -1 ) { return; + } UndrawNewTrack( trk ); switch ( inx ) { case OR: xx->pos = trntblData.orig; break; case RA: - if ( trntblData.diameter > 2.0 ) + if ( trntblData.diameter > 2.0 ) { xx->radius = trntblData.diameter/2.0; + } break; case LY: SetTrkLayer( trk, trntblData.layerNumber ); @@ -279,24 +311,25 @@ static void UpdateTurntable( track_p trk, int inx, descData_p descUpd, BOOL_T fi static void DescribeTurntable( track_p trk, char * str, CSIZE_T len ) { - struct extraDataTurntable_t *xx = GET_EXTRA_DATA(trk, T_TURNTABLE, extraDataTurntable_t); + struct extraDataTurntable_t *xx = GET_EXTRA_DATA(trk, T_TURNTABLE, + extraDataTurntable_t); sprintf( str, _("Turntable(%d): Layer=%d Center=[%s %s] Diameter=%s #EP=%d"), - GetTrkIndex(trk), GetTrkLayer(trk)+1, - FormatDistance(xx->pos.x), FormatDistance(xx->pos.y), - FormatDistance(xx->radius * 2.0), GetTrkEndPtCnt(trk) ); + GetTrkIndex(trk), GetTrkLayer(trk)+1, + FormatDistance(xx->pos.x), FormatDistance(xx->pos.y), + FormatDistance(xx->radius * 2.0), GetTrkEndPtCnt(trk) ); trntblData.orig = xx->pos; trntblData.diameter = xx->radius*2.0; int j=0; - for (int i=0;i<GetTrkEndPtCnt(trk);i++) { - if (GetTrkEndTrk(trk,i)) j++; //Only count if track + for (int i=0; i<GetTrkEndPtCnt(trk); i++) { + if (GetTrkEndTrk(trk,i)) { j++; } //Only count if track } trntblData.epCnt = j; trntblData.layerNumber = GetTrkLayer(trk); trntblDesc[OR].mode = - trntblDesc[RA].mode = - trntblData.epCnt>0?DESC_RO:0; + trntblDesc[RA].mode = + trntblData.epCnt>0?DESC_RO:0; trntblDesc[EC].mode = DESC_RO; trntblDesc[LY].mode = DESC_NOREDRAW; DoDescribe( _("Turntable"), trk, trntblDesc, UpdateTurntable ); @@ -308,19 +341,20 @@ static void DeleteTurntable( track_p t ) static BOOL_T WriteTurntable( track_p t, FILE * f ) { - struct extraDataTurntable_t *xx = GET_EXTRA_DATA(t, T_TURNTABLE, extraDataTurntable_t); + struct extraDataTurntable_t *xx = GET_EXTRA_DATA(t, T_TURNTABLE, + extraDataTurntable_t); EPINX_T ep; BOOL_T rc = TRUE; int j = -1, k = 0; for (ep=0; ep<GetTrkEndPtCnt(t); ep++) { - if (GetTrkEndTrk(t,ep)) j++; - if (ep == xx->currEp) k=j; //Write out the curr->Ep reset to real endPts + if (GetTrkEndTrk(t,ep)) { j++; } + if (ep == xx->currEp) { k=j; } //Write out the curr->Ep reset to real endPts } rc &= fprintf(f, "TURNTABLE %d %d 0 0 0 %s %d %0.6f %0.6f 0 %0.6f %d\n", - GetTrkIndex(t), GetTrkLayer(t), GetTrkScaleName(t), GetTrkVisible(t), - xx->pos.x, xx->pos.y, xx->radius, k )>0; + GetTrkIndex(t), GetTrkLayer(t), GetTrkScaleName(t), GetTrkVisible(t), + xx->pos.x, xx->pos.y, xx->radius, k )>0; for (ep=0; ep<GetTrkEndPtCnt(t); ep++) { - if (GetTrkEndTrk(t,ep)) rc &= WriteEndPt( f, t, ep ); //Only write if there is a track + if (GetTrkEndTrk(t,ep)) { rc &= WriteEndPt( f, t, ep ); } //Only write if there is a track } rc &= fprintf(f, "\t%s\n", END_SEGS)>0; return rc; @@ -340,14 +374,16 @@ static BOOL_T ReadTurntable( char * line ) int currEp; if ( !GetArgs( line+10, - paramVersion<3?"dXsdpYfX": - paramVersion<9?"dL000sdpYfX": - paramVersion<10?"dL000sdpffX": - "dL000sdpffd", - &index, &layer, scale, &visible, &p, &elev, &r, &currEp )) + paramVersion<3?"dXsdpYfX": + paramVersion<9?"dL000sdpYfX": + paramVersion<10?"dL000sdpffX": + "dL000sdpffd", + &index, &layer, scale, &visible, &p, &elev, &r, &currEp )) { return FALSE; - if ( !ReadSegs() ) + } + if ( !ReadSegs() ) { return FALSE; + } trk = NewTrack( index, T_TURNTABLE, 0, sizeof *xx ); SetEndPts( trk, 0 ); xx = GET_EXTRA_DATA(trk, T_TURNTABLE, extraDataTurntable_t); @@ -361,7 +397,7 @@ static BOOL_T ReadTurntable( char * line ) xx->pos = p; xx->radius = r; xx->currEp = currEp; - if (xx->currEp > GetTrkEndPtCnt(trk)) xx->currEp = 0; + if (xx->currEp > GetTrkEndPtCnt(trk)) { xx->currEp = 0; } xx->reverse = 0; ComputeTurntableBoundingBox( trk ); return TRUE; @@ -369,7 +405,8 @@ static BOOL_T ReadTurntable( char * line ) static void MoveTurntable( track_p trk, coOrd orig ) { - struct extraDataTurntable_t *xx = GET_EXTRA_DATA(trk, T_TURNTABLE, extraDataTurntable_t); + struct extraDataTurntable_t *xx = GET_EXTRA_DATA(trk, T_TURNTABLE, + extraDataTurntable_t); xx->pos.x += orig.x; xx->pos.y += orig.y; ComputeTurntableBoundingBox( trk ); @@ -377,56 +414,65 @@ static void MoveTurntable( track_p trk, coOrd orig ) static void RotateTurntable( track_p trk, coOrd orig, ANGLE_T angle ) { - struct extraDataTurntable_t *xx = GET_EXTRA_DATA(trk, T_TURNTABLE, extraDataTurntable_t); + struct extraDataTurntable_t *xx = GET_EXTRA_DATA(trk, T_TURNTABLE, + extraDataTurntable_t); Rotate( &xx->pos, orig, angle ); ComputeTurntableBoundingBox( trk ); } static void RescaleTurntable( track_p trk, FLOAT_T ratio ) { - struct extraDataTurntable_t *xx = GET_EXTRA_DATA(trk, T_TURNTABLE, extraDataTurntable_t); + struct extraDataTurntable_t *xx = GET_EXTRA_DATA(trk, T_TURNTABLE, + extraDataTurntable_t); xx->pos.x *= ratio; xx->pos.y *= ratio; } -static ANGLE_T GetAngleTurntable( track_p trk, coOrd pos, EPINX_T * ep0, EPINX_T * ep1 ) +static ANGLE_T GetAngleTurntable( track_p trk, coOrd pos, EPINX_T * ep0, + EPINX_T * ep1 ) { - struct extraDataTurntable_t *xx = GET_EXTRA_DATA(trk, T_TURNTABLE, extraDataTurntable_t); + struct extraDataTurntable_t *xx = GET_EXTRA_DATA(trk, T_TURNTABLE, + extraDataTurntable_t); if ( programMode == MODE_DESIGN ) { return FindAngle( xx->pos, pos ); } else { - if ( !ValidateTurntablePosition( trk ) ) + if ( !ValidateTurntablePosition( trk ) ) { return 90.0; - else + } else { return GetTrkEndAngle( trk, xx->currEp ); + } } } -static BOOL_T SplitTurntable( track_p trk, coOrd pos, EPINX_T ep, track_p *leftover, EPINX_T *ep0, EPINX_T *ep1 ) +static BOOL_T SplitTurntable( track_p trk, coOrd pos, EPINX_T ep, + track_p *leftover, EPINX_T *ep0, EPINX_T *ep1 ) { - if (leftover) + if (leftover) { *leftover = NULL; - ErrorMessage( MSG_CANT_SPLIT_TRK, "Turntable" ); + } + ErrorMessage( MSG_CANT_SPLIT_TRK, _("Turntable") ); return FALSE; } static BOOL_T FindTurntableEndPt( - track_p trk, - ANGLE_T *angleR, - EPINX_T *epR, - BOOL_T *reverseR ) + track_p trk, + ANGLE_T *angleR, + EPINX_T *epR, + BOOL_T *reverseR ) { - EPINX_T ep, ep0, epCnt=GetTrkEndPtCnt(trk); + EPINX_T ep, /*ep0,*/ epCnt=GetTrkEndPtCnt(trk); ANGLE_T angle=*angleR, angle0, angle1; - for (ep=0,ep0=-1,epCnt=GetTrkEndPtCnt(trk),angle0=370.0; ep<epCnt; ep++) { - if ( (GetTrkEndTrk(trk,ep)) == NULL ) + for (ep=0,/*ep0=-1,*/epCnt=GetTrkEndPtCnt(trk),angle0=370.0; ep<epCnt; ep++) { + if ( (GetTrkEndTrk(trk,ep)) == NULL ) { continue; + } angle1 = GetTrkEndAngle(trk,ep); angle1 = NormalizeAngle(angle1-angle); - if ( angle1 > 180.0 ) - angle1 = 360.0-angle1; + if ( angle1 > 180.0 ) { + angle1 = 360.0-angle1; + } if ( angle1 < angle0 ) { *epR = ep; *reverseR = FALSE; @@ -453,71 +499,81 @@ static BOOL_T FindTurntableEndPt( static EPINX_T FindTurntableNextEndPt( - track_p trk, - coOrd pos) { - - EPINX_T ep,epfound=-1,epCnt; - struct extraDataTurntable_t * xx = GET_EXTRA_DATA(trk, T_TURNTABLE, extraDataTurntable_t); - ANGLE_T a = FindAngle(xx->pos,pos); - ANGLE_T foundangle = 370.0; - ANGLE_T diff = DifferenceBetweenAngles(GetTrkEndAngle(trk,xx->currEp),a); - BOOL_T forward = TRUE; - if (diff>90) { - forward = FALSE; - } - if (diff<0 && diff>-90) { - forward = FALSE; - } - ANGLE_T currdiff, angle1; - for (ep=0,epCnt=GetTrkEndPtCnt(trk); ep<epCnt; ep++) { - if ( (GetTrkEndTrk(trk,ep)) == NULL ) - continue; - angle1 = GetTrkEndAngle(trk,ep); - if (forward) - currdiff = NormalizeAngle(angle1-a); - else - currdiff = NormalizeAngle(a-angle1); - if (currdiff<foundangle) { - foundangle = currdiff; - epfound = ep; - } + track_p trk, + coOrd pos) +{ + + EPINX_T ep,epfound=-1,epCnt; + struct extraDataTurntable_t * xx = GET_EXTRA_DATA(trk, T_TURNTABLE, + extraDataTurntable_t); + ANGLE_T a = FindAngle(xx->pos,pos); + ANGLE_T foundangle = 370.0; + ANGLE_T diff = DifferenceBetweenAngles(GetTrkEndAngle(trk,xx->currEp),a); + BOOL_T forward = TRUE; + if (diff>90) { + forward = FALSE; + } + if (diff<0 && diff>-90) { + forward = FALSE; + } + ANGLE_T currdiff, angle1; + for (ep=0,epCnt=GetTrkEndPtCnt(trk); ep<epCnt; ep++) { + if ( (GetTrkEndTrk(trk,ep)) == NULL ) { + continue; + } + angle1 = GetTrkEndAngle(trk,ep); + if (forward) { + currdiff = NormalizeAngle(angle1-a); + } else { + currdiff = NormalizeAngle(a-angle1); } - return epfound; + if (currdiff<foundangle) { + foundangle = currdiff; + epfound = ep; + } + } + return epfound; } static BOOL_T CheckTraverseTurntable( - track_p trk, - coOrd pos ) + track_p trk, + coOrd pos ) { - struct extraDataTurntable_t * xx = GET_EXTRA_DATA(trk, T_TURNTABLE, extraDataTurntable_t); + struct extraDataTurntable_t * xx = GET_EXTRA_DATA(trk, T_TURNTABLE, + extraDataTurntable_t); ANGLE_T angle; - if ( !ValidateTurntablePosition( trk ) ) + if ( !ValidateTurntablePosition( trk ) ) { return FALSE; - angle = FindAngle( xx->pos, pos ) - GetTrkEndAngle( trk, xx->currEp )+connectAngle/2.0; - if ( angle <= connectAngle || - ( angle >= 180.0 && angle <= 180+connectAngle ) ) + } + angle = FindAngle( xx->pos, pos ) - GetTrkEndAngle( trk, + xx->currEp )+connectAngle/2.0; + if ( angle <= connectAngle || + ( angle >= 180.0 && angle <= 180+connectAngle ) ) { return TRUE; + } return FALSE; } static BOOL_T TraverseTurntable( - traverseTrack_p trvTrk, - DIST_T * distR ) + traverseTrack_p trvTrk, + DIST_T * distR ) { track_p trk = trvTrk->trk; - struct extraDataTurntable_t * xx = GET_EXTRA_DATA(trk, T_TURNTABLE, extraDataTurntable_t); + struct extraDataTurntable_t * xx = GET_EXTRA_DATA(trk, T_TURNTABLE, + extraDataTurntable_t); coOrd pos0; DIST_T dist, dist1; ANGLE_T angle, angle1; - EPINX_T ep; + EPINX_T ep = 0; BOOL_T reverse; - if ( !ValidateTurntablePosition( trk ) ) + if ( !ValidateTurntablePosition( trk ) ) { return FALSE; + } dist = FindDistance( xx->pos, trvTrk->pos ); pos0 = GetTrkEndPos( trk, xx->currEp ); angle = FindAngle( pos0, xx->pos ); @@ -529,8 +585,9 @@ static BOOL_T TraverseTurntable( if ( dist > xx->radius*0.9 ) { angle = NormalizeAngle( angle-trvTrk->angle ); if ( ( angle < 90.0 && angle > connectAngle ) || - ( angle > 270.0 && angle < 360.0-connectAngle ) ) + ( angle > 270.0 && angle < 360.0-connectAngle ) ) { return FALSE; + } } trvTrk->angle = angle1; angle = FindAngle( trvTrk->pos, xx->pos ); @@ -552,7 +609,8 @@ static BOOL_T TraverseTurntable( } Translate( &trvTrk->pos, xx->pos, angle1, xx->radius ); *distR -= dist1; - if ( FindTurntableEndPt( trk, &angle1, &ep, &reverse ) && angle1 < connectAngle ) { + if ( FindTurntableEndPt( trk, &angle1, &ep, &reverse ) + && angle1 < connectAngle ) { trk = GetTrkEndTrk(trk,ep); } else { trk = NULL; @@ -575,10 +633,12 @@ static BOOL_T EnumerateTurntable( track_p trk ) xx = GET_EXTRA_DATA(trk, T_TURNTABLE, extraDataTurntable_t); DYNARR_APPEND( FLOAT_T, turntables_da, 10 ); turntables(turntables_da.cnt-1) = xx->radius*2.0; - sprintf( tmp, "Turntable, diameter %s", FormatDistance(turntables(turntables_da.cnt-1)) ); + sprintf( tmp, "Turntable, diameter %s", + FormatDistance(turntables(turntables_da.cnt-1)) ); inx = strlen( tmp ); - if ( inx > enumerateMaxDescLen ) + if ( inx > enumerateMaxDescLen ) { enumerateMaxDescLen = (int)inx; + } } else { for (inx=0; inx<turntables_da.cnt; inx++) { content = TRUE; @@ -606,7 +666,7 @@ static STATUS_T ModifyTurntable( track_p trk, wAction_t action, coOrd pos ) case C_DOWN: TurntableGetCenter( trk, &ttCenter, &ttRadius ); tempSegs(0).type = SEG_STRTRK; - tempSegs(0).width = 0; + tempSegs(0).lineWidth = 0; InfoMessage( _("Drag to create stall track") ); case C_MOVE: @@ -616,22 +676,25 @@ static STATUS_T ModifyTurntable( track_p trk, wAction_t action, coOrd pos ) } else if ((r=FindDistance( ttCenter, pos )) < ttRadius) { ErrorMessage( MSG_POINT_INSIDE_TURNTABLE ); } else if ( (r-ttRadius) <= minLength ) { - if (action == C_MOVE) - ErrorMessage( MSG_TRK_TOO_SHORT, "Stall ", PutDim(fabs(minLength-(r-ttRadius))) ); + if (action == C_MOVE) { + ErrorMessage( MSG_TRK_TOO_SHORT, "Stall ", + PutDim(fabs(minLength-(r-ttRadius))) ); + } } else { Translate( &tempSegs(0).u.l.pos[0], ttCenter, angle, ttRadius ); Translate( &tempSegs(0).u.l.pos[1], ttCenter, angle, r ); if (action == C_MOVE) InfoMessage( _("Straight Track: Length=%s Angle=%0.3f"), - FormatDistance( r-ttRadius ), PutAngle( angle ) ); - tempSegs_da.cnt = 1; + FormatDistance( r-ttRadius ), PutAngle( angle ) ); + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); valid = TRUE; } return C_CONTINUE; case C_UP: - if (!valid) + if (!valid) { return C_TERMINATE; + } ep = NewTurntableEndPt( trk, angle ); trk1 = NewStraightTrack( tempSegs(0).u.l.pos[0], tempSegs(0).u.l.pos[1] ); CopyAttributes( trk, trk1 ); @@ -646,22 +709,25 @@ static STATUS_T ModifyTurntable( track_p trk, wAction_t action, coOrd pos ) } EXPORT BOOL_T ConnectTurntableTracks( - track_p trk1, /*The turntable */ - EPINX_T ep1, /*Ignored */ - track_p trk2, - EPINX_T ep2 ) { + track_p trk1, /*The turntable */ + EPINX_T ep1, /*Ignored */ + track_p trk2, + EPINX_T ep2 ) +{ coOrd center, pos; DIST_T radius; DIST_T dist; - if (!QueryTrack(trk1,Q_CAN_ADD_ENDPOINTS)) return FALSE; + if (!QueryTrack(trk1,Q_CAN_ADD_ENDPOINTS)) { return FALSE; } TurntableGetCenter( trk1, ¢er, &radius ); pos = GetTrkEndPos(trk2,ep2); ANGLE_T angle = FindAngle(center, GetTrkEndPos(trk2,ep2)); - if (fabs(DifferenceBetweenAngles(GetTrkEndAngle(trk2,ep2),angle+180)) <= connectAngle) { + if (fabs(DifferenceBetweenAngles(GetTrkEndAngle(trk2,ep2), + angle+180)) <= connectAngle) { dist = FindDistance(center,pos)-radius; if (dist < connectDistance) { - UndoStart( _("Connect Turntable Tracks"), "TurnTracks(T%d[%d] T%d[%d] D%0.3f A%0.3F )", - GetTrkIndex(trk1), ep1, GetTrkIndex(trk2), ep2, dist, angle ); + UndoStart( _("Connect Turntable Tracks"), + "TurnTracks(T%d[%d] T%d[%d] D%0.3f A%0.3F )", + GetTrkIndex(trk1), ep1, GetTrkIndex(trk2), ep2, dist, angle ); UndoModify(trk1); EPINX_T ep = NewTurntableEndPt(trk1,angle); if (ConnectTracks( trk1, ep, trk2, ep2 )) { @@ -676,7 +742,8 @@ EXPORT BOOL_T ConnectTurntableTracks( } -static BOOL_T GetParamsTurntable( int inx, track_p trk, coOrd pos, trackParams_t * params ) +static BOOL_T GetParamsTurntable( int inx, track_p trk, coOrd pos, + trackParams_t * params ) { coOrd center; DIST_T radius; @@ -688,8 +755,9 @@ static BOOL_T GetParamsTurntable( int inx, track_p trk, coOrd pos, trackParams_t params->type = curveTypeStraight; params->ep = -1; params->angle = ConstrainTurntableAngle( trk, pos ); - if (params->angle < 0.0) - return FALSE; + if (params->angle < 0.0) { + return FALSE; + } TurntableGetCenter( trk, ¢er, &radius ); PointOnCircle( ¶ms->lineOrig, center, radius, params->angle ); params->lineEnd = params->lineOrig; @@ -701,7 +769,8 @@ static BOOL_T GetParamsTurntable( int inx, track_p trk, coOrd pos, trackParams_t } -static BOOL_T MoveEndPtTurntable( track_p *trk, EPINX_T *ep, coOrd pos, DIST_T d0 ) +static BOOL_T MoveEndPtTurntable( track_p *trk, EPINX_T *ep, coOrd pos, + DIST_T d0 ) { coOrd posCen; DIST_T r; @@ -725,14 +794,16 @@ static BOOL_T MoveEndPtTurntable( track_p *trk, EPINX_T *ep, coOrd pos, DIST_T d //Look for empty slot BOOL_T found = FALSE; for (*ep=0; *ep<GetTrkEndPtCnt(*trk); *ep=*ep+1) { - if ( (GetTrkEndTrk(*trk,*ep)) == NULL ) + if ( (GetTrkEndTrk(*trk,*ep)) == NULL ) { found = TRUE; - break; + } + break; } - if (!found) + if (!found) { *ep = NewTurntableEndPt(*trk,angle0); - else { - struct extraDataTurntable_t *xx = GET_EXTRA_DATA(*trk, T_TURNTABLE, extraDataTurntable_t); + } else { + struct extraDataTurntable_t *xx = GET_EXTRA_DATA(*trk, T_TURNTABLE, + extraDataTurntable_t); coOrd pos1; PointOnCircle( &pos1, xx->pos, xx->radius, angle0 ); SetTrkEndPoint(*trk, *ep, pos1, angle0); //Reuse @@ -759,7 +830,7 @@ static BOOL_T QueryTurntable( track_p trk, int query ) case Q_ISTRACK: case Q_NOT_PLACE_FROGPOINTS: case Q_MODIFY_REDRAW_DONT_UNDRAW_TRACK: - case Q_CAN_ADD_ENDPOINTS: + case Q_CAN_ADD_ENDPOINTS: return TRUE; case Q_MODIFY_CAN_SPLIT: case Q_CORNU_CAN_MODIFY: @@ -771,11 +842,12 @@ static BOOL_T QueryTurntable( track_p trk, int query ) static void FlipTurntable( - track_p trk, - coOrd orig, - ANGLE_T angle ) + track_p trk, + coOrd orig, + ANGLE_T angle ) { - struct extraDataTurntable_t * xx = GET_EXTRA_DATA(trk, T_TURNTABLE, extraDataTurntable_t); + struct extraDataTurntable_t * xx = GET_EXTRA_DATA(trk, T_TURNTABLE, + extraDataTurntable_t); FlipPoint( &xx->pos, orig, angle ); ComputeBoundingBox( trk ); } @@ -784,12 +856,14 @@ BOOL_T debug = 0; static void DrawTurntablePositionIndicator( track_p trk, wDrawColor color ) { - struct extraDataTurntable_t * xx = GET_EXTRA_DATA(trk, T_TURNTABLE, extraDataTurntable_t); + struct extraDataTurntable_t * xx = GET_EXTRA_DATA(trk, T_TURNTABLE, + extraDataTurntable_t); coOrd pos0, pos1; ANGLE_T angle; - - if ( !ValidateTurntablePosition(trk) ) + + if ( !ValidateTurntablePosition(trk) ) { return; + } pos0 = GetTrkEndPos(trk,xx->currEp); angle = FindAngle( xx->pos, pos0 ); PointOnCircle( &pos1, xx->pos, xx->radius, angle+180.0 ); @@ -808,8 +882,10 @@ static void DrawTurntablePositionIndicator( track_p trk, wDrawColor color ) static wBool_t CompareTurntable( track_cp trk1, track_cp trk2 ) { - struct extraDataTurntable_t *xx1 = GET_EXTRA_DATA( trk1, T_TURNTABLE, extraDataTurntable_t ); - struct extraDataTurntable_t *xx2 = GET_EXTRA_DATA( trk2, T_TURNTABLE, extraDataTurntable_t ); + struct extraDataTurntable_t *xx1 = GET_EXTRA_DATA( trk1, T_TURNTABLE, + extraDataTurntable_t ); + struct extraDataTurntable_t *xx2 = GET_EXTRA_DATA( trk2, T_TURNTABLE, + extraDataTurntable_t ); char * cp = message + strlen(message); REGRESS_CHECK_POS( "Pos", xx1, xx2, pos ) REGRESS_CHECK_DIST( "Radius", xx1, xx2, radius ) @@ -819,13 +895,14 @@ static wBool_t CompareTurntable( track_cp trk1, track_cp trk2 ) } static void AdvanceTurntablePositionIndicator( - track_p trk, - coOrd pos, - coOrd * posR, - ANGLE_T * angleR ) + track_p trk, + coOrd pos, + coOrd * posR, + ANGLE_T * angleR ) { - struct extraDataTurntable_t * xx = GET_EXTRA_DATA(trk, T_TURNTABLE, extraDataTurntable_t); + struct extraDataTurntable_t * xx = GET_EXTRA_DATA(trk, T_TURNTABLE, + extraDataTurntable_t); EPINX_T ep; ANGLE_T angle0, angle1; BOOL_T reverse=FALSE, train_reversed = FALSE; @@ -834,12 +911,13 @@ static void AdvanceTurntablePositionIndicator( coOrd inpos = *posR; ANGLE_T inangle = *angleR; angle0 = GetTrkEndAngle(trk,xx->currEp); - if (fabs(DifferenceBetweenAngles(angle0,*angleR))>90) train_reversed = TRUE; + if (fabs(DifferenceBetweenAngles(angle0,*angleR))>90) { train_reversed = TRUE; } DIST_T dd = DIST_INF; // If on ep, use that for (ep=0; ep<epCnt; ep++) { - if ( (GetTrkEndTrk(trk,ep)) == NULL ) + if ( (GetTrkEndTrk(trk,ep)) == NULL ) { continue; + } coOrd end = GetTrkEndPos(trk,ep); DIST_T d = FindDistance(end,pos); if (d<dd) { @@ -861,7 +939,8 @@ static void AdvanceTurntablePositionIndicator( train_reversed = !train_reversed; } else { //If back end moving, flip result - if (fabs(DifferenceBetweenAngles(FindAngle(xx->pos,pos),GetTrkEndAngle(trk,xx->currEp)))>90) { + if (fabs(DifferenceBetweenAngles(FindAngle(xx->pos,pos),GetTrkEndAngle(trk, + xx->currEp)))>90) { if (epfound>=0 && epfound != xx->currEp) { reverse = TRUE; xx->reverse = !xx->reverse; @@ -879,48 +958,51 @@ static void AdvanceTurntablePositionIndicator( Translate(posR, xx->pos, *angleR, FindDistance(*posR,xx->pos) ); } coOrd outpos = *posR; - if (debug) - InfoMessage("AO:%0.3f PO:(%0.3f,%0.3f) AI:%0.3f PI:(%0.3f,%0.3f)",*angleR,outpos.x,outpos.y,inangle,inpos.x,inpos.y); + if (debug) { + InfoMessage("AO:%0.3f PO:(%0.3f,%0.3f) AI:%0.3f PI:(%0.3f,%0.3f)",*angleR, + outpos.x,outpos.y,inangle,inpos.x,inpos.y); + } } } static trackCmd_t turntableCmds = { - "TURNTABLE", - DrawTurntable, - DistanceTurntable, - DescribeTurntable, - DeleteTurntable, - WriteTurntable, - ReadTurntable, - MoveTurntable, - RotateTurntable, - RescaleTurntable, - NULL, /* audit */ - GetAngleTurntable, - SplitTurntable, /* split */ - TraverseTurntable, - EnumerateTurntable, - NULL, /* redraw */ - NULL, /* trim */ - NULL, /* merge */ - ModifyTurntable, - NULL, /* getLength */ - GetParamsTurntable, - MoveEndPtTurntable, - QueryTurntable, - NULL, /* ungroup */ - FlipTurntable, - DrawTurntablePositionIndicator, - AdvanceTurntablePositionIndicator, - CheckTraverseTurntable, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - CompareTurntable }; + "TURNTABLE", + DrawTurntable, + DistanceTurntable, + DescribeTurntable, + DeleteTurntable, + WriteTurntable, + ReadTurntable, + MoveTurntable, + RotateTurntable, + RescaleTurntable, + NULL, /* audit */ + GetAngleTurntable, + SplitTurntable, /* split */ + TraverseTurntable, + EnumerateTurntable, + NULL, /* redraw */ + NULL, /* trim */ + NULL, /* merge */ + ModifyTurntable, + NULL, /* getLength */ + GetParamsTurntable, + MoveEndPtTurntable, + QueryTurntable, + NULL, /* ungroup */ + FlipTurntable, + DrawTurntablePositionIndicator, + AdvanceTurntablePositionIndicator, + CheckTraverseTurntable, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + CompareTurntable +}; static STATUS_T CmdTurntable( wAction_t action, coOrd pos ) @@ -934,8 +1016,9 @@ static STATUS_T CmdTurntable( wAction_t action, coOrd pos ) switch (action) { case C_START: - if (turntableDiameterPD.control==NULL) + if (turntableDiameterPD.control==NULL) { ParamCreateControls( &turntablePG, NULL ); + } sprintf( message, "turntable-diameter-%s", curScaleName ); turntableDiameter = ceil(80.0*12.0/curScaleRatio); wPrefGetFloat( "misc", message, &turntableDiameter, turntableDiameter ); @@ -984,7 +1067,8 @@ static STATUS_T CmdTurntable( wAction_t action, coOrd pos ) case C_REDRAW: if ( state > 0 ) { - DrawArc( &tempD, pos0, turntableDiameter/2.0, 0.0, 360.0, 0, 0, wDrawColorBlack ); + DrawArc( &tempD, pos0, turntableDiameter/2.0, 0.0, 360.0, 0, 0, + wDrawColorBlack ); } return C_CONTINUE; @@ -998,12 +1082,14 @@ static STATUS_T CmdTurntable( wAction_t action, coOrd pos ) } -#include "bitmaps/turntable.xpm" +#include "bitmaps/turntable.xpm3" EXPORT void InitCmdTurntable( wMenu_p menu ) { - AddMenuButton( menu, CmdTurntable, "cmdTurntable", _("Custom Turntable"), wIconCreatePixMap(turntable_xpm[iconSize]), LEVEL0_50, IC_STICKY|IC_INITNOTSTICKY, ACCL_TURNTABLE, NULL ); + AddMenuButton( menu, CmdTurntable, "cmdTurntable", _("Custom Turntable"), + wIconCreatePixMap(turntable_xpm3[iconSize]), LEVEL0_50, + IC_STICKY|IC_INITNOTSTICKY, ACCL_TURNTABLE, NULL ); } diff --git a/app/bin/cundo.c b/app/bin/cundo.c index fda012f..b58d541 100644 --- a/app/bin/cundo.c +++ b/app/bin/cundo.c @@ -1,5 +1,5 @@ /** \file cundo.c - * Undo / redo functions. + * Undo / redo functions. */ /* XTrkCad - Model Railroad CAD @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* @@ -45,7 +45,7 @@ * At this point, any DeleteOp records in the old transaction are processed * (DeleteInStream) and the deleted track is Free'd * - * The streams are expandable ring buffers. + * The streams are expandable ring buffers. * When the transaction buffer wraps, the unreferenced start of the undoStreams is trimmed. * THe redoStream is purged for every transaction. * @@ -56,7 +56,7 @@ * 1 Marks the track's transaction record with DeleteOp * When the transaction record is recycled, the old track object will be Free'd. * 2 Sets the .delete flag in the track object - * For the most part (except dcar.c and cundo.c) IsTrackDeleted() is used in ASSERTs + * For the most part (except dcar.c and cundo.c) IsTrackDeleted() is used in CHECKs * There are a few cases where we have to deal with deleted track. * In general, we do not need to look inside a deleted track and * GET_EXTRA_DATA will complain if we try (FreeTrack is the exception) @@ -67,10 +67,13 @@ #include "fileio.h" #include "paths.h" #include "track.h" -#include "trackx.h" +// We need to fiddle with the track list +#include "trackx.h" // tempTrk, to_first, to_last +#include "trkendpt.h" #include "draw.h" #include "cundo.h" #include "common-ui.h" +#include "ctrain.h" #include <inttypes.h> @@ -79,6 +82,52 @@ #define SLOG_FMT "0x%.12" PRIxPTR +/**************************************************************************** + * + * RPRINTF + * + */ + + +#define RBUFF_SIZE (8192) +static char rbuff[RBUFF_SIZE+1]; +static int roff; +static int rbuff_record = 0; + +EXPORT void Rdump( FILE * outf ) +{ + fprintf( outf, "Record Buffer:\n" ); + rbuff[RBUFF_SIZE] = '\0'; + fprintf( outf, "%s", rbuff+roff ); + rbuff[roff] = '\0'; + fprintf( outf, "%s", rbuff ); + memset( rbuff, 0, sizeof rbuff ); + roff = 0; +} + + +static void Rprintf( + char * format, + ... ) +{ + static char buff[STR_SIZE]; + char * cp; + va_list ap; + va_start( ap, format ); + vsprintf( buff, format, ap ); + va_end( ap ); + if (rbuff_record >= 1) { + lprintf( buff ); + } + for ( cp=buff; *cp; cp++ ) { + rbuff[roff] = *cp; + roff++; + if (roff>=RBUFF_SIZE) { + roff=0; + } + } +} + /***************************************************************************** * * UNDO @@ -90,20 +139,20 @@ static int log_undo = 0; /**< loglevel, can only be set at compile time */ #define UNDO_STACK_SIZE (10) typedef struct { - wIndex_t modCnt; - wIndex_t newCnt; - wIndex_t delCnt; - wIndex_t trackCount; - track_p newTrks; - uintptr_t undoStart; - uintptr_t undoEnd; - uintptr_t redoStart; - uintptr_t redoEnd; - BOOL_T needRedo; - track_p * oldTail; - track_p * newTail; - char * label; - } undoStack_t, *undoStack_p; + wIndex_t modCnt; + wIndex_t newCnt; + wIndex_t delCnt; + wIndex_t trackCount; + track_p newTrks; + uintptr_t undoStart; + uintptr_t undoEnd; + uintptr_t redoStart; + uintptr_t redoEnd; + BOOL_T needRedo; + track_p * oldTail; + track_p * newTail; + char * label; +} undoStack_t, *undoStack_p; static undoStack_t undoStack[UNDO_STACK_SIZE]; static wIndex_t undoHead = -1; @@ -134,11 +183,11 @@ static BOOL_T recordUndo = 1; typedef char streamBlocks_t[BSTREAM_SIZE]; typedef streamBlocks_t *streamBlocks_p; typedef struct { - dynArr_t stream_da; - long startBInx; - uintptr_t end; - uintptr_t curr; - } stream_t; + dynArr_t stream_da; + long startBInx; + uintptr_t end; + uintptr_t curr; +} stream_t; typedef stream_t *stream_p; static stream_t undoStream; static stream_t redoStream; @@ -175,8 +224,10 @@ static void DumpStream( FILE * outf, stream_p stream, char * name ) if ( memcmp( &((*blk)[i]), zeros, 16 ) == 0 ) { zeroCnt++; } else { - if ( zeroCnt == 2 ) - fprintf( outf, "%6.6lx 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n", (unsigned long)off-16 ); + if ( zeroCnt == 2 ) { + fprintf( outf, "%6.6lx 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n", + (unsigned long)off-16 ); + } zeroCnt = 0; } if ( zeroCnt <= 1 ) { @@ -186,52 +237,65 @@ static void DumpStream( FILE * outf, stream_p stream, char * name ) } fprintf( outf, "\n" ); } else if ( zeroCnt == 3 ) { - fprintf( outf, SLOG_FMT" .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..\n", off ); + fprintf( outf, SLOG_FMT" .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..\n", + off ); } off += 16; } } - if ( zeroCnt > 2 ) - fprintf( outf, SLOG_FMT" 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n", off-16 ); + if ( zeroCnt > 2 ) { + fprintf( outf, SLOG_FMT" 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n", + off-16 ); + } } -static BOOL_T UndoFail( char * cause, uintptr_t val, char * fileName, int lineNumber ) +static BOOL_T UndoFail( char * cause, uintptr_t val, char * fileName, + int lineNumber ) { int inx, cnt; undoStack_p us; FILE * outf; time_t clock; - char *temp; - NoticeMessage( MSG_UNDO_ASSERT, _("Ok"), NULL, fileName, lineNumber, val, val, cause ); + char *temp; + NoticeMessage( MSG_UNDO_ASSERT, _("Ok"), NULL, fileName, lineNumber, val, val, + cause ); MakeFullpath(&temp, workingDir, sUndoF, NULL); outf = fopen( temp, "a+" ); free(temp); if ( outf == NULL ) { - NoticeMessage( MSG_OPEN_FAIL, _("Ok"), NULL, _("Undo Trace"), temp, strerror(errno) ); + NoticeMessage( MSG_OPEN_FAIL, _("Ok"), NULL, _("Undo Trace"), temp, + strerror(errno) ); return FALSE; } time( &clock ); - fprintf(outf, "\nUndo Assert: %s @ %s:%d (%s)\n", cause, fileName, lineNumber, ctime(&clock) ); + fprintf(outf, "\nUndo Assert: %s @ %s:%d (%s)\n", cause, fileName, lineNumber, + ctime(&clock) ); fprintf(outf, "Val = %lld(" SLOG_FMT ")\n", (long long)val, val ); - fprintf(outf, "to_first="SLOG_FMT", to_last="SLOG_FMT"\n", (uintptr_t)to_first, (uintptr_t)to_last ); - fprintf(outf, "undoHead=%d, doCount=%d, undoCount=%d\n", undoHead, doCount, undoCount ); - if (undoHead >= 0 && undoHead < UNDO_STACK_SIZE) + fprintf(outf, "to_first="SLOG_FMT", to_last="SLOG_FMT"\n", (uintptr_t)to_first, + (uintptr_t)to_last ); + fprintf(outf, "undoHead=%d, doCount=%d, undoCount=%d\n", undoHead, doCount, + undoCount ); + if (undoHead >= 0 && undoHead < UNDO_STACK_SIZE) { inx=undoHead; - else + } else { inx = 0; + } for (cnt=0; cnt<UNDO_STACK_SIZE; cnt++) { us = &undoStack[inx]; - fprintf( outf, "US[%d]: M:%d N:%d D:%d TC:%d NT:"SLOG_FMT" OT:"SLOG_FMT" NT:"SLOG_FMT" US:"SLOG_FMT" UE:"SLOG_FMT" RS:"SLOG_FMT" RE:"SLOG_FMT" NR:%d\n", - inx, us->modCnt, us->newCnt, us->delCnt, us->trackCount, - (uintptr_t)us->newTrks, (uintptr_t)us->oldTail, (uintptr_t)us->newTail, - us->undoStart, us->undoEnd, us->redoStart, us->redoEnd, us->needRedo ); + fprintf( outf, + "US[%d]: M:%d N:%d D:%d TC:%d NT:"SLOG_FMT" OT:"SLOG_FMT" NT:"SLOG_FMT" US:"SLOG_FMT" UE:"SLOG_FMT" RS:"SLOG_FMT" RE:"SLOG_FMT" NR:%d\n", + inx, us->modCnt, us->newCnt, us->delCnt, us->trackCount, + (uintptr_t)us->newTrks, (uintptr_t)us->oldTail, (uintptr_t)us->newTail, + us->undoStart, us->undoEnd, us->redoStart, us->redoEnd, us->needRedo ); INC_UNDO_INX(inx); } fprintf( outf, "Undo: SBI:%ld E:"SLOG_FMT" C:"SLOG_FMT" SC:%d SM:%d\n", - undoStream.startBInx, undoStream.end, undoStream.curr, undoStream.stream_da.cnt, undoStream.stream_da.max ); + undoStream.startBInx, undoStream.end, undoStream.curr, undoStream.stream_da.cnt, + undoStream.stream_da.max ); fprintf( outf, "Redo: SBI:%ld E:"SLOG_FMT" C:"SLOG_FMT" SC:%d SM:%d\n", - redoStream.startBInx, redoStream.end, redoStream.curr, redoStream.stream_da.cnt, redoStream.stream_da.max ); + redoStream.startBInx, redoStream.end, redoStream.curr, redoStream.stream_da.cnt, + redoStream.stream_da.max ); DumpStream( outf, &undoStream, "undoStream" ); DumpStream( outf, &redoStream, "redoStream" ); Rdump(outf); @@ -247,10 +311,12 @@ BOOL_T ReadStream( stream_t * stream, void * ptr, int size ) size_t binx, boff, brem; streamBlocks_p blk; if ( stream->curr+size > stream->end ) { - UndoFail( "Overrun on stream", (uintptr_t)(stream->curr+size), __FILE__, __LINE__ ); + UndoFail( "Overrun on stream", (uintptr_t)(stream->curr+size), __FILE__, + __LINE__ ); return FALSE; } -LOG( log_undo, 5, ( "ReadStream( , "SLOG_FMT", %d ) %ld %ld %ld\n", (uintptr_t)ptr, size, stream->startBInx, stream->curr, stream->end ) ) + LOG( log_undo, 5, ( "ReadStream( , "SLOG_FMT", %d ) %ld %ld %ld\n", + (uintptr_t)ptr, size, stream->startBInx, stream->curr, stream->end ) ) binx = stream->curr/BSTREAM_SIZE; boff = stream->curr%BSTREAM_SIZE; stream->curr += size; @@ -278,9 +344,12 @@ BOOL_T WriteStream( stream_p stream, void * ptr, int size ) { size_t binx, boff, brem; streamBlocks_p blk; -LOG( log_undo, 5, ( "WriteStream( , "SLOG_FMT", %d ) %ld "SLOG_FMT" "SLOG_FMT"\n", (uintptr_t)ptr, size, stream->startBInx, stream->curr, stream->end ) ) - if (size == 0) + LOG( log_undo, 5, + ( "WriteStream( , "SLOG_FMT", %d ) %ld "SLOG_FMT" "SLOG_FMT"\n", (uintptr_t)ptr, + size, stream->startBInx, stream->curr, stream->end ) ) + if (size == 0) { return TRUE; + } binx = stream->end/BSTREAM_SIZE; boff = stream->end%BSTREAM_SIZE; stream->end += size; @@ -315,20 +384,24 @@ BOOL_T TrimStream( stream_p stream, uintptr_t off ) { size_t binx, cnt, inx; streamBlocks_p blk; -LOG( log_undo, 3, ( " TrimStream( , %ld )\n", off ) ) + LOG( log_undo, 3, ( " TrimStream( , %ld )\n", off ) ) binx = off/BSTREAM_SIZE; cnt = binx-stream->startBInx; - if (recordUndo) - Rprintf("Trim("SLOG_FMT") %ld blocks (out of %d)\n", off, cnt, stream->stream_da.cnt); + if (recordUndo) { + Rprintf("Trim("SLOG_FMT") %ld blocks (out of %d)\n", off, cnt, + stream->stream_da.cnt); + } UASSERT( cnt >= 0 && cnt <= stream->stream_da.cnt, cnt ); - if (cnt == 0) + if (cnt == 0) { return TRUE; + } for (inx=0; inx<cnt; inx++) { blk = DYNARR_N( streamBlocks_p, stream->stream_da, inx ); MyFree( blk ); } for (inx=cnt; inx<stream->stream_da.cnt; inx++ ) { - DYNARR_N( streamBlocks_p, stream->stream_da, inx-cnt ) = DYNARR_N( streamBlocks_p, stream->stream_da, inx ); + DYNARR_N( streamBlocks_p, stream->stream_da, + inx-cnt ) = DYNARR_N( streamBlocks_p, stream->stream_da, inx ); } stream->startBInx =(long)binx; stream->stream_da.cnt -= (wIndex_t)cnt; @@ -345,7 +418,7 @@ void ClearStream( stream_p stream ) blk = DYNARR_N( streamBlocks_p, stream->stream_da, inx ); MyFree( blk ); } - stream->stream_da.cnt = 0; + DYNARR_RESET( streamBlocks_p, stream->stream_da ); stream->startBInx = 0; stream->end = stream->curr = 0; } @@ -355,23 +428,27 @@ BOOL_T TruncateStream( stream_p stream, uintptr_t off ) { size_t binx, boff, cnt, inx; streamBlocks_p blk; -LOG( log_undo, 3, ( "TruncateStream( , %ld )\n", off ) ) + LOG( log_undo, 3, ( "TruncateStream( , %ld )\n", off ) ) binx = off/BSTREAM_SIZE; boff = off%BSTREAM_SIZE; - if (boff!=0) + if (boff!=0) { binx++; + } binx -= stream->startBInx; cnt = stream->stream_da.cnt-binx; - if (recordUndo) - Rprintf("Truncate("SLOG_FMT") %ld blocks (out of %d)\n", off, cnt, stream->stream_da.cnt); + if (recordUndo) { + Rprintf("Truncate("SLOG_FMT") %ld blocks (out of %d)\n", off, cnt, + stream->stream_da.cnt); + } UASSERT( cnt >= 0 && cnt <= stream->stream_da.cnt, cnt ); - if (cnt == 0) + if (cnt == 0) { return TRUE; + } for (inx=binx; inx<stream->stream_da.cnt; inx++) { blk = DYNARR_N( streamBlocks_p, stream->stream_da, inx ); MyFree( blk ); } - stream->stream_da.cnt = (wIndex_t)binx; + DYNARR_SET( streamBlocks_p, stream->stream_da, (wIndex_t)binx ); stream->end = off; UASSERT( stream->stream_da.cnt >= 0, stream->stream_da.cnt ); return TRUE; @@ -383,11 +460,12 @@ BOOL_T WriteObject( stream_p stream, char op, track_p trk ) void * buff = NULL; long len = 0; if (!WriteStream( stream, &op, sizeof op ) || - !WriteStream( stream, &trk, sizeof trk ) || - !WriteStream( stream, trk, sizeof *trk ) || - !WriteStream( stream, trk->endPt, trk->endCnt * sizeof trk->endPt[0] ) || - !WriteStream( stream, trk->extraData, trk->extraSize )) + !WriteStream( stream, &trk, sizeof trk ) || + !WriteStream( stream, trk, sizeof *trk ) || + !WriteStream( stream, trk->endPt, EndPtSize(trk->endCnt) ) || + !WriteStream( stream, trk->extraData, trk->extraSize )) { return FALSE; + } /* Add a copy of the any type specific data before it is tampered with, for example */ if ( !IsTrackDeleted(trk) ) { StoreTrackData(trk,&buff,&len); @@ -395,11 +473,13 @@ BOOL_T WriteObject( stream_p stream, char op, track_p trk ) len = 0; buff = NULL; } - if (!WriteStream( stream, &len, sizeof len )) + if (!WriteStream( stream, &len, sizeof len )) { return FALSE; + } if (len) - if (!WriteStream( stream, buff, len )) + if (!WriteStream( stream, buff, len )) { return FALSE; + } return TRUE; } @@ -416,62 +496,79 @@ static BOOL_T ReadObject( stream_p stream, BOOL_T needRedo ) track_p trk; track_t tempTrk; char op; - if (!ReadStream( stream, &op, sizeof op )) + if (!ReadStream( stream, &op, sizeof op )) { return FALSE; - if (!ReadStream( stream, &trk, sizeof trk )) + } + if (!ReadStream( stream, &trk, sizeof trk )) { return FALSE; - LOG( log_undo, 4, ( " @ " SLOG_FMT " %s\n", stream->curr-1, op==ModifyOp?"Mod":"Del" ) ); + } + LOG( log_undo, 4, ( " @ " SLOG_FMT " %s\n", stream->curr-1, + op==ModifyOp?"Mod":"Del" ) ); if (needRedo) { if (!WriteObject( &redoStream, op, trk )) { return FALSE; } } - if (!ReadStream( stream, &tempTrk, sizeof tempTrk )) + if (!ReadStream( stream, &tempTrk, sizeof tempTrk )) { return FALSE; - if (op == ModifyOp) + } + if (op == ModifyOp) { UASSERT( (op==ModifyOp) && !IsTrackDeleted(&tempTrk), GetTrkIndex(&tempTrk) ); + } // op==DeleteOp doesnot imply that tmpTrk.delete == TRUE: SetDeleteOpInStream - if (tempTrk.endCnt != trk->endCnt) - tempTrk.endPt = MyRealloc( trk->endPt, tempTrk.endCnt * sizeof tempTrk.endPt[0] ); - else + if (tempTrk.endCnt != trk->endCnt) { + tempTrk.endPt = MyRealloc( trk->endPt, EndPtSize(tempTrk.endCnt) ); + } else { tempTrk.endPt = trk->endPt; - if (!ReadStream( stream, tempTrk.endPt, tempTrk.endCnt * sizeof tempTrk.endPt[0] )) + } + if (!ReadStream( stream, tempTrk.endPt, EndPtSize(tempTrk.endCnt) )) { return FALSE; - if (tempTrk.extraSize != trk->extraSize) - tempTrk.extraData = (extraDataBase_t*)MyRealloc( trk->extraData, tempTrk.extraSize ); - else + } + if (tempTrk.extraSize != trk->extraSize) { + tempTrk.extraData = (extraDataBase_t*)MyRealloc( trk->extraData, + tempTrk.extraSize ); + } else { tempTrk.extraData = trk->extraData; - if (!ReadStream( stream, tempTrk.extraData, tempTrk.extraSize )) + } + if (!ReadStream( stream, tempTrk.extraData, tempTrk.extraSize )) { return FALSE; + } long Addsize; void * tempBuff; /* Fix up pts to be as big as it was before -> because it may have changed since */ - if (!ReadStream (stream, &Addsize, sizeof Addsize)) + if (!ReadStream (stream, &Addsize, sizeof Addsize)) { return FALSE; + } if (Addsize) { tempBuff = MyMalloc(Addsize); - if (!ReadStream( stream, tempBuff, Addsize )) + if (!ReadStream( stream, tempBuff, Addsize )) { return FALSE; - if ( ! IsTrackDeleted(&tempTrk) ) + } + if ( ! IsTrackDeleted(&tempTrk) ) { ReplayTrackData(&tempTrk, tempBuff, Addsize); + } MyFree(tempBuff); } - if ( ! IsTrackDeleted(&tempTrk) ) - RebuildTrackSegs(&tempTrk); //If we had an array of Segs - recreate it - if (recordUndo) Rprintf( "Restore T%D(%d) @ "SLOG_FMT"\n", trk->index, tempTrk.index, (uintptr_t)trk ); + if ( ! IsTrackDeleted(&tempTrk) ) { + RebuildTrackSegs(&tempTrk); //If we had an array of Segs - recreate it + } + if (recordUndo) { Rprintf( "Restore T%D(%d) @ "SLOG_FMT"\n", trk->index, tempTrk.index, (uintptr_t)trk ); } tempTrk.index = trk->index; tempTrk.next = trk->next; - if ( (tempTrk.bits&TB_CARATTACHED) != 0 ) + if ( (tempTrk.bits&TB_CARATTACHED) != 0 ) { needAttachTrains = TRUE; + } tempTrk.bits &= ~TB_TEMPBITS; *trk = tempTrk; - if (!IsTrackDeleted(trk)) + if (!IsTrackDeleted(trk)) { ClrTrkElev( trk ); + } return TRUE; } -static BOOL_T RedrawInStream( stream_p stream, uintptr_t start, uintptr_t end, BOOL_T draw ) +static BOOL_T RedrawInStream( stream_p stream, uintptr_t start, uintptr_t end, + BOOL_T draw ) { char op; track_p trk; @@ -479,19 +576,22 @@ static BOOL_T RedrawInStream( stream_p stream, uintptr_t start, uintptr_t end, B stream->curr = start; while (stream->curr < end ) { if (!ReadStream( stream, &op, sizeof op ) || - !ReadStream( stream, &trk, sizeof trk ) || - !ReadStream( stream, &tempTrk, sizeof tempTrk ) ) + !ReadStream( stream, &trk, sizeof trk ) || + !ReadStream( stream, &tempTrk, sizeof tempTrk ) ) { return FALSE; - stream->curr += tempTrk.extraSize + tempTrk.endCnt*sizeof tempTrk.endPt[0];; + } + stream->curr += tempTrk.extraSize + EndPtSize(tempTrk.endCnt); long Addsize; - if (!ReadStream( stream, &Addsize, sizeof Addsize )) - return FALSE; + if (!ReadStream( stream, &Addsize, sizeof Addsize )) { + return FALSE; + } stream->curr += Addsize; if (!IsTrackDeleted(trk)) { - if (draw) + if (draw) { DrawNewTrack( trk ); - else + } else { UndrawNewTrack( trk ); + } } } return TRUE; @@ -515,24 +615,30 @@ static BOOL_T DeleteInStream( stream_p stream, uintptr_t start, uintptr_t end ) track_p *ptrk; track_t tempTrk; int delCount = 0; - LOG( log_undo, 3, ( " DeleteInStream( , "SLOG_FMT", "SLOG_FMT" )\n", start, end ) ) + LOG( log_undo, 3, ( " DeleteInStream( , "SLOG_FMT", "SLOG_FMT" )\n", start, + end ) ) stream->curr = start; while (stream->curr < end ) { - if (!ReadStream( stream, &op, sizeof op )) + if (!ReadStream( stream, &op, sizeof op )) { return FALSE; + } UASSERT( op == ModifyOp || op == DeleteOp, (long)op ); - LOG( log_undo, 4, ( " @ " SLOG_FMT " %s\n", stream->curr-1, op==ModifyOp?"Mod":"Del" ) ); + LOG( log_undo, 4, ( " @ " SLOG_FMT " %s\n", stream->curr-1, + op==ModifyOp?"Mod":"Del" ) ); if (!ReadStream( stream, &trk, sizeof trk ) || - !ReadStream( stream, &tempTrk, sizeof tempTrk )) + !ReadStream( stream, &tempTrk, sizeof tempTrk )) { return FALSE; - stream->curr += tempTrk.extraSize + tempTrk.endCnt*sizeof tempTrk.endPt[0]; + } + stream->curr += tempTrk.extraSize + EndPtSize(tempTrk.endCnt); long Addsize; - if (!ReadStream( stream, &Addsize, sizeof Addsize )) + if (!ReadStream( stream, &Addsize, sizeof Addsize )) { return FALSE; + } stream->curr += Addsize; if (op == DeleteOp) { - if (recordUndo) Rprintf( " Free T%D(%d) @ "SLOG_FMT"\n", trk->index, tempTrk.index, (uintptr_t)trk ); - LOG( log_undo, 3, ( " Free T%d @ "SLOG_FMT"\n", GetTrkIndex(trk), (uintptr_t)trk ) ); + if (recordUndo) { Rprintf( " Free T%D(%d) @ "SLOG_FMT"\n", trk->index, tempTrk.index, (uintptr_t)trk ); } + LOG( log_undo, 3, ( " Free T%d @ "SLOG_FMT"\n", GetTrkIndex(trk), + (uintptr_t)trk ) ); UASSERT( IsTrackDeleted(trk), GetTrkIndex(trk) ); trk->index = -1; delCount++; @@ -567,7 +673,8 @@ static BOOL_T DeleteInStream( stream_p stream, uintptr_t start, uintptr_t end ) * * Note: does not set trk->delete flag */ -static BOOL_T SetDeleteOpInStream( stream_p stream, uintptr_t start, uintptr_t end, track_p trk0 ) +static BOOL_T SetDeleteOpInStream( stream_p stream, uintptr_t start, + uintptr_t end, track_p trk0 ) { char op; track_p trk; @@ -575,20 +682,25 @@ static BOOL_T SetDeleteOpInStream( stream_p stream, uintptr_t start, uintptr_t e size_t binx, boff; streamBlocks_p blk; - LOG( log_undo, 3, ( " SetDeleteOpInStream T%d @ "SLOG_FMT"\n", GetTrkIndex(trk0), (uintptr_t)trk0) ); + LOG( log_undo, 3, ( " SetDeleteOpInStream T%d @ "SLOG_FMT"\n", + GetTrkIndex(trk0), (uintptr_t)trk0) ); stream->curr = start; while (stream->curr < end) { binx = stream->curr/BSTREAM_SIZE; binx -= stream->startBInx; boff = stream->curr%BSTREAM_SIZE; - if (!ReadStream( stream, &op, sizeof op )) + if (!ReadStream( stream, &op, sizeof op )) { return FALSE; + } UASSERT( op == ModifyOp || op == DeleteOp, (long)op ); - LOG( log_undo, 4, ( " @ " SLOG_FMT " %s\n", stream->curr-1, op==ModifyOp?"Mod":"Del" ) ); - if (!ReadStream( stream, &trk, sizeof trk ) ) + LOG( log_undo, 4, ( " @ " SLOG_FMT " %s\n", stream->curr-1, + op==ModifyOp?"Mod":"Del" ) ); + if (!ReadStream( stream, &trk, sizeof trk ) ) { return FALSE; - if (!ReadStream( stream, &tempTrk, sizeof tempTrk )) + } + if (!ReadStream( stream, &tempTrk, sizeof tempTrk )) { return FALSE; + } if (trk == trk0) { UASSERT( op == ModifyOp, (long)op ); blk = DYNARR_N( streamBlocks_p, stream->stream_da, binx ); @@ -597,10 +709,11 @@ static BOOL_T SetDeleteOpInStream( stream_p stream, uintptr_t start, uintptr_t e LOG( log_undo, 3, ( " -> Delete\n") ); return TRUE; } - stream->curr += tempTrk.extraSize + tempTrk.endCnt*sizeof tempTrk.endPt[0]; + stream->curr += tempTrk.extraSize + EndPtSize(tempTrk.endCnt); long Addsize; - if (!ReadStream( stream, &Addsize, sizeof Addsize)) - return FALSE; + if (!ReadStream( stream, &Addsize, sizeof Addsize)) { + return FALSE; + } stream->curr += Addsize; } UASSERT( "Cannot find undo record to convert to DeleteOp", 0 ); @@ -645,11 +758,13 @@ static track_p * FindParent( track_p trk, int lineNum ) { track_p *ptrk; ptrk = &to_first; - while ( 1 ) { - if ( *ptrk == trk ) + while ( 1 ) { + if ( *ptrk == trk ) { return ptrk; - if (*ptrk == NULL) + } + if (*ptrk == NULL) { break; + } ptrk = &(*ptrk)->next; } UndoFail( "Cannot find trk on list", (uintptr_t)trk, "cundo.c", lineNum ); @@ -668,9 +783,9 @@ static int undoIgnoreEmpty = 0; * */ void UndoStart( - char * label, - char * format, - ... ) + char * label, + char * format, + ... ) { static char buff[STR_SIZE]; va_list ap; @@ -679,18 +794,21 @@ void UndoStart( int inx; int usp; -LOG( log_undo, 1, ( "UndoStart[%d] (%s) d:%d u:%d us:"SLOG_FMT"\n", undoHead, label, undoHead, doCount, undoCount, undoStream.end ) ) + LOG( log_undo, 1, ( "UndoStart[%d] (%s) d:%d u:%d us:"SLOG_FMT"\n", undoHead, + label, undoHead, doCount, undoCount, undoStream.end ) ) if (recordUndo) { va_start( ap, format ); vsprintf( buff, format, ap ); va_end( ap ); - Rprintf( "Start(%s)[%d] d:%d u:%d us:"SLOG_FMT"\n", buff, undoHead, doCount, undoCount, undoStream.end ); + Rprintf( "Start(%s)[%d] d:%d u:%d us:"SLOG_FMT"\n", buff, undoHead, doCount, + undoCount, undoStream.end ); } if ( undoHead >= 0 ) { us = &undoStack[undoHead]; if ( us->modCnt == 0 && us->delCnt == 0 && us->newCnt == 0 ) { - LOG( log_undo, 1, ( " noop: %s - %s\n", us->label?us->label:"<>", label?label:"<>" ) ); + LOG( log_undo, 1, ( " noop: %s - %s\n", us->label?us->label:"<>", + label?label:"<>" ) ); if ( undoIgnoreEmpty ) { us->label = label; return; @@ -703,34 +821,38 @@ LOG( log_undo, 1, ( "UndoStart[%d] (%s) d:%d u:%d us:"SLOG_FMT"\n", undoHead, la SetFileChanged(); if (doCount == UNDO_STACK_SIZE) { - if (recordUndo) Rprintf( " Wrapped N:%d M:%d D:%d\n", us->newCnt, us->modCnt, us->delCnt ); + if (recordUndo) { Rprintf( " Wrapped N:%d M:%d D:%d\n", us->newCnt, us->modCnt, us->delCnt ); } /* wrapped around stack */ /* if track saved in undoStream is deleted then really deleted since we can't get it back */ - if (!DeleteInStream( &undoStream, us->undoStart, us->undoEnd )) + if (!DeleteInStream( &undoStream, us->undoStart, us->undoEnd )) { return; + } /* strip off unused head of stream */ - if (!TrimStream( &undoStream, us->undoEnd )) + if (!TrimStream( &undoStream, us->undoEnd )) { return; + } } else if (undoCount != 0) { - if (recordUndo) Rprintf( " Undid N:%d M:%d D:%d\n", us->newCnt, us->modCnt, us->delCnt ); + if (recordUndo) { Rprintf( " Undid N:%d M:%d D:%d\n", us->newCnt, us->modCnt, us->delCnt ); } /* reusing an undid entry */ /* really delete all new tracks since this point */ for( inx=0,usp = undoHead; inx<undoCount; inx++ ) { us1 = &undoStack[usp]; - if (recordUndo) Rprintf(" U[%d] N:%d\n", usp, us1->newCnt ); + if (recordUndo) { Rprintf(" U[%d] N:%d\n", usp, us1->newCnt ); } for (trk=us1->newTrks; trk; trk=next) { - if (recordUndo) Rprintf( " Free T%d @ "SLOG_FMT"\n", trk->index, (uintptr_t)trk ); + if (recordUndo) { Rprintf( " Free T%d @ "SLOG_FMT"\n", trk->index, (uintptr_t)trk ); } // trk->delete may not be TRUE, see SetDeleteOpInStream - LOG( log_undo, 4, (" Free T%d @ "SLOG_FMT"\n", trk->index, (uintptr_t)trk ) ); + LOG( log_undo, 4, (" Free T%d @ "SLOG_FMT"\n", trk->index, + (uintptr_t)trk ) ); next = trk->next; FreeTrack( trk ); } INC_UNDO_INX(usp); } /* strip off unused tail of stream */ - if (!TruncateStream( &undoStream, us->undoStart )) + if (!TruncateStream( &undoStream, us->undoStart )) { return; + } } us->label = label; us->modCnt = 0; @@ -751,8 +873,9 @@ LOG( log_undo, 1, ( "UndoStart[%d] (%s) d:%d u:%d us:"SLOG_FMT"\n", undoHead, la trk->modified = FALSE; trk->new = FALSE; } - if (doCount < UNDO_STACK_SIZE) + if (doCount < UNDO_STACK_SIZE) { doCount++; + } SetButtons( TRUE, FALSE ); } @@ -768,21 +891,26 @@ BOOL_T UndoModify( track_p trk ) { undoStack_p us; - if ( !undoActive ) return TRUE; - if (trk == NULL) return TRUE; + if ( !undoActive ) { return TRUE; } + if (trk == NULL) { return TRUE; } UASSERT(undoCount==0, undoCount); UASSERT(undoHead >= 0, undoHead); UASSERT(!IsTrackDeleted(trk), GetTrkIndex(trk)); - if (trk->modified || trk->new) + if (trk->modified || trk->new) { return TRUE; -LOG( log_undo, 2, ( " UndoModify( T%d, E%d, X%ld @ "SLOG_FMT"\n", trk->index, trk->endCnt, trk->extraSize, (uintptr_t)trk ) ) - if ( (GetTrkBits(trk)&TB_CARATTACHED)!=0 ) + } + LOG( log_undo, 2, ( " UndoModify( T%d, E%d, X%ld @ "SLOG_FMT"\n", trk->index, + trk->endCnt, trk->extraSize, (uintptr_t)trk ) ) + if ( (GetTrkBits(trk)&TB_CARATTACHED)!=0 ) { needAttachTrains = TRUE; + } us = &undoStack[undoHead]; - if (recordUndo) + if (recordUndo) { Rprintf( " MOD T%d @ "SLOG_FMT"\n", trk->index, (uintptr_t)trk ); - if (!WriteObject( &undoStream, ModifyOp, trk )) + } + if (!WriteObject( &undoStream, ModifyOp, trk )) { return FALSE; + } us->undoEnd = undoStream.end; trk->modified = TRUE; us->modCnt++; @@ -804,29 +932,36 @@ LOG( log_undo, 2, ( " UndoModify( T%d, E%d, X%ld @ "SLOG_FMT"\n", trk->index, BOOL_T UndoDelete( track_p trk ) { undoStack_p us; - if ( !undoActive ) return TRUE; -LOG( log_undo, 2, ( " UndoDelete( T%d, E%d, X%ld @ "SLOG_FMT" )\n", trk->index, trk->endCnt, trk->extraSize, (uintptr_t)trk ) ) - if ( (GetTrkBits(trk)&TB_CARATTACHED)!=0 ) + if ( !undoActive ) { return TRUE; } + LOG( log_undo, 2, ( " UndoDelete( T%d, E%d, X%ld @ "SLOG_FMT" )\n", + trk->index, trk->endCnt, trk->extraSize, (uintptr_t)trk ) ) + if ( (GetTrkBits(trk)&TB_CARATTACHED)!=0 ) { needAttachTrains = TRUE; + } us = &undoStack[undoHead]; - if (recordUndo) + if (recordUndo) { Rprintf( " DEL T%d @ "SLOG_FMT"\n", trk->index, (uintptr_t)trk ); + } UASSERT( !IsTrackDeleted(trk), trk->index ); if ( trk->modified ) { - if (!SetDeleteOpInStream( &undoStream, us->undoStart, us->undoEnd, trk )) + if (!SetDeleteOpInStream( &undoStream, us->undoStart, us->undoEnd, trk )) { return FALSE; + } } else if ( !trk->new ) { LOG( log_undo, 3, ( " Write DeleteOp object\n" ) ); - if (!WriteObject( &undoStream, DeleteOp, trk )) - return FALSE; + if (!WriteObject( &undoStream, DeleteOp, trk )) { + return FALSE; + } us->undoEnd = undoStream.end; } else { LOG( log_undo, 3, ( " Remove New object\n" ) ); track_p * ptrk; - if (us->newTrks == trk) + if (us->newTrks == trk) { us->newTrks = trk->next; - if (!(ptrk = FindParent( trk, __LINE__ ))) + } + if (!(ptrk = FindParent( trk, __LINE__ ))) { return FALSE; + } if (trk->next == NULL) { UASSERT( to_last == &(*ptrk)->next, (uintptr_t)&(*ptrk)->next ); to_last = ptrk; @@ -852,22 +987,26 @@ LOG( log_undo, 2, ( " UndoDelete( T%d, E%d, X%ld @ "SLOG_FMT" )\n", trk->inde */ BOOL_T UndoNew( track_p trk ) { - undoStack_p us; - if (!undoActive) + undoStack_p us; + if (!undoActive) { return TRUE; + } -LOG( log_undo, 2, ( " UndoNew( T%d @ "SLOG_FMT")\n", trk->index, (uintptr_t)trk ) ) - - if (recordUndo) + LOG( log_undo, 2, ( " UndoNew( T%d @ "SLOG_FMT")\n", trk->index, + (uintptr_t)trk ) ) + + if (recordUndo) { Rprintf( " NEW T%d @"SLOG_FMT"\n", trk->index, (uintptr_t)trk ); + } UASSERT(undoCount==0, undoCount); UASSERT(undoHead >= 0, undoHead); us = &undoStack[undoHead]; trk->new = TRUE; - if (us->newTrks == NULL) + if (us->newTrks == NULL) { us->newTrks = trk; + } us->newCnt++; - + return TRUE; } @@ -877,7 +1016,7 @@ LOG( log_undo, 2, ( " UndoNew( T%d @ "SLOG_FMT")\n", trk->index, (uintptr_t)t */ void UndoEnd( void ) { - if (recordUndo) Rprintf( "End[%d] d:%d\n", undoHead, doCount ); + if (recordUndo) { Rprintf( "End[%d] d:%d\n", undoHead, doCount ); } /*undoActive = FALSE;*/ if ( needAttachTrains ) { AttachTrains(); @@ -893,7 +1032,7 @@ void UndoEnd( void ) void UndoClear( void ) { int inx; -LOG( log_undo, 2, ( " UndoClear()\n" ) ) + LOG( log_undo, 2, ( " UndoClear()\n" ) ) undoActive = FALSE; undoHead = -1; undoCount = 0; @@ -930,35 +1069,42 @@ void UndoUndo( void * unused ) return; } - int rc = ConfirmReset( FALSE ); + ConfirmReset( FALSE ); wDrawDelayUpdate( mainD.d, TRUE ); us = &undoStack[undoHead]; -LOG( log_undo, 1, ( " UndoUndo[%d] d:%d u:%d N:%d M:%d D:%d %s\n", undoHead, doCount, undoCount, us->newCnt, us->modCnt, us->delCnt, us->needRedo?"Redo":"" ) ) - if (recordUndo) Rprintf( "Undo[%d] d:%d u:%d N:%d M:%d D:%d\n", undoHead, doCount, undoCount, us->newCnt, us->modCnt, us->delCnt ); + LOG( log_undo, 1, ( " UndoUndo[%d] d:%d u:%d N:%d M:%d D:%d %s\n", undoHead, + doCount, undoCount, us->newCnt, us->modCnt, us->delCnt, + us->needRedo?"Redo":"" ) ) + if (recordUndo) { Rprintf( "Undo[%d] d:%d u:%d N:%d M:%d D:%d\n", undoHead, doCount, undoCount, us->newCnt, us->modCnt, us->delCnt ); } //redrawAll = (us->newCnt+us->modCnt) > incrementalDrawLimit; - redrawAll = TRUE; + redrawAll = TRUE; if (!redrawAll) { - for (trk=us->newTrks; trk; trk=trk->next ) + for (trk=us->newTrks; trk; trk=trk->next ) { UndrawNewTrack( trk ); + } RedrawInStream( &undoStream, us->undoStart, us->undoEnd, FALSE ); } - if (us->needRedo) + if (us->needRedo) { us->redoStart = us->redoEnd = redoStream.end; - if (!(us->oldTail=FindParent(us->newTrks,__LINE__))) - return; + } + if (!(us->oldTail=FindParent(us->newTrks,__LINE__))) { + return; + } us->newTail = to_last; to_last = us->oldTail; *to_last = NULL; needAttachTrains = FALSE; undoStream.curr = us->undoStart; while ( undoStream.curr < us->undoEnd ) { - if (!ReadObject( &undoStream, us->needRedo )) + if (!ReadObject( &undoStream, us->needRedo )) { return; + } } - if (us->needRedo) + if (us->needRedo) { us->redoEnd = redoStream.end; + } us->needRedo = FALSE; if ( needAttachTrains ) { @@ -966,10 +1112,11 @@ LOG( log_undo, 1, ( " UndoUndo[%d] d:%d u:%d N:%d M:%d D:%d %s\n", undoHead, needAttachTrains = FALSE; } UpdateAllElevations(); - if (!redrawAll) + if (!redrawAll) { RedrawInStream( &undoStream, us->undoStart, us->undoEnd, TRUE ); - else + } else { DoRedraw(); + } oldCount = trackCount; trackCount = us->trackCount; @@ -1009,15 +1156,16 @@ void UndoRedo( void * unused ) return; } - int rc = ConfirmReset( FALSE ); + ConfirmReset( FALSE ); wDrawDelayUpdate( mainD.d, TRUE ); INC_UNDO_INX( undoHead ); us = &undoStack[undoHead]; -LOG( log_undo, 1, ( " UndoRedo[%d] d:%d u:%d N:%d M:%d D:%d\n", undoHead, doCount, undoCount, us->newCnt, us->modCnt, us->delCnt ) ) - if (recordUndo) Rprintf( "Redo[%d] d:%d u:%d N:%d M:%d D:%d\n", undoHead, doCount, undoCount, us->newCnt, us->modCnt, us->delCnt ); + LOG( log_undo, 1, ( " UndoRedo[%d] d:%d u:%d N:%d M:%d D:%d\n", undoHead, + doCount, undoCount, us->newCnt, us->modCnt, us->delCnt ) ) + if (recordUndo) { Rprintf( "Redo[%d] d:%d u:%d N:%d M:%d D:%d\n", undoHead, doCount, undoCount, us->newCnt, us->modCnt, us->delCnt ); } //redrawAll = (us->newCnt+us->modCnt) > incrementalDrawLimit; - redrawAll = TRUE; + redrawAll = TRUE; if (!redrawAll) { RedrawInStream( &redoStream, us->redoStart, us->redoEnd, FALSE ); } @@ -1031,8 +1179,9 @@ LOG( log_undo, 1, ( " UndoRedo[%d] d:%d u:%d N:%d M:%d D:%d\n", undoHead, doC needAttachTrains = FALSE; redoStream.curr = us->redoStart; while ( redoStream.curr < us->redoEnd ) { - if (!ReadObject( &redoStream, FALSE )) + if (!ReadObject( &redoStream, FALSE )) { return; + } } if ( needAttachTrains ) { @@ -1041,11 +1190,13 @@ LOG( log_undo, 1, ( " UndoRedo[%d] d:%d u:%d N:%d M:%d D:%d\n", undoHead, doC } UpdateAllElevations(); if (!redrawAll) { - for (trk=us->newTrks; trk; trk=trk->next ) + for (trk=us->newTrks; trk; trk=trk->next ) { DrawNewTrack( trk ); + } RedrawInStream( &redoStream, us->redoStart, us->redoEnd, TRUE ); - } else + } else { DoRedraw(); + } oldCount = trackCount; trackCount = us->trackCount; diff --git a/app/bin/cundo.h b/app/bin/cundo.h index 4b7fca1..2282835 100644 --- a/app/bin/cundo.h +++ b/app/bin/cundo.h @@ -17,15 +17,16 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef HAVE_CUNDO_H
-#define HAVE_CUNDO_H
+#ifndef HAVE_CUNDO_H +#define HAVE_CUNDO_H #include "common.h" extern wBool_t undoStatus; // Status of the last Undo/Redo command +void Rdump( FILE * ); void UndoUndo( void * unused ); void UndoRedo( void * unused ); void UndoResume( void ); diff --git a/app/bin/custom.c b/app/bin/custom.c index 1ec38e0..e53372f 100644 --- a/app/bin/custom.c +++ b/app/bin/custom.c @@ -18,7 +18,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "cjoin.h" @@ -88,16 +88,18 @@ void InitCmdEasement( void ) } void DoEasementRedir( void * unused ) { - if (easementP) + if (easementP) { easementP(NULL); + } } #ifdef STRUCTDESIGNER static addButtonCallBack_t structDesignerP; void DoStructDesignerRedir( void ) { - if (structDesignerP) + if (structDesignerP) { structDesignerP(NULL); + } } #endif @@ -121,10 +123,10 @@ BOOL_T Initialize( void ) InitTrkDraw(); InitTrkBlock(); - InitTrkSwitchMotor(); - InitTrkSignal(); - InitTrkControl(); - InitTrkSensor(); + InitTrkSwitchMotor(); + InitTrkSignal(); + InitTrkControl(); + InitTrkSensor(); InitCarDlg(); InitCmdNote(); @@ -142,72 +144,61 @@ void InitCustom( void ) char *buf = malloc(1024); /* Initialize some localized strings */ - if (sTurnoutDesignerW == NULL) - { + if (sTurnoutDesignerW == NULL) { sprintf(buf, _("%s Turnout Designer"), Product); sTurnoutDesignerW = strdup(buf); } - if (sAboutProd == NULL) - { + if (sAboutProd == NULL) { sprintf(buf, _("%s Version %s"), Product, Version); sAboutProd = strdup(buf); } - if (sSourceFilePattern == NULL) - { + if (sSourceFilePattern == NULL) { sprintf(buf, _("All %s Files (*.xtc,*.xtce)|*.xtc;*.xtce|" - "%s Trackplan (*.xtc)|*.xtc|" - "%s Extended Trackplan (*.xtce)|*.xtce|" - "All Files (*)|*"), - Product, - Product, - Product ); + "%s Trackplan (*.xtc)|*.xtc|" + "%s Extended Trackplan (*.xtce)|*.xtce|" + "All Files (*)|*"), + Product, + Product, + Product ); sSourceFilePattern = strdup(buf); } - if (sSaveFilePattern == NULL) - { + if (sSaveFilePattern == NULL) { sprintf(buf, _("%s Trackplan (*.xtc)|*.xtc|" - "%s Extended Trackplan (*.xtce)|*.xtce|" - "All Files (*)|*"), - Product, - Product ); + "%s Extended Trackplan (*.xtce)|*.xtce|" + "All Files (*)|*"), + Product, + Product ); sSaveFilePattern = strdup(buf); } - if (sImageFilePattern == NULL) - { + if (sImageFilePattern == NULL) { sprintf(buf,_("All Files (*)|*")); sImageFilePattern = strdup(buf); } - if (sImportFilePattern == NULL) - { + if (sImportFilePattern == NULL) { sprintf(buf, _("%s Import Files (*.xti)|*.xti"), Product ); sImportFilePattern = strdup(buf); } - if (sDXFFilePattern == NULL) - { + if (sDXFFilePattern == NULL) { sDXFFilePattern = strdup(_("Data Exchange Format Files (*.dxf)|*.dxf")); } - if (sSVGFilePattern == NULL) - { - sSVGFilePattern = strdup(_("Scalable Vector Graphics Format Files (*.svg)|*.svg" )); + if (sSVGFilePattern == NULL) { + sSVGFilePattern = strdup( + _("Scalable Vector Graphics Format Files (*.svg)|*.svg" )); } - if (sRecordFilePattern == NULL) - { + if (sRecordFilePattern == NULL) { sprintf(buf, _("%s Record Files (*.xtr)|*.xtr"), Product); sRecordFilePattern = strdup(buf); } - if (sNoteFilePattern == NULL) - { + if (sNoteFilePattern == NULL) { sprintf(buf, _("%s Note Files (*.not)|*.not"), Product); sNoteFilePattern = strdup(buf); } - if (sLogFilePattern == NULL) - { + if (sLogFilePattern == NULL) { sprintf(buf, _("%s Log Files (*.log)|*.log"), Product); sLogFilePattern = strdup(buf); } - if (sPartsListFilePattern == NULL) - { + if (sPartsListFilePattern == NULL) { sprintf(buf, _("%s PartsList Files (*.txt)|*.txt"), Product); sPartsListFilePattern = strdup(buf); } @@ -219,28 +210,23 @@ void InitCustom( void ) void CleanupCustom( void ) { /* Free dynamically allocated strings */ - if (sTurnoutDesignerW) - { + if (sTurnoutDesignerW) { free(sTurnoutDesignerW); sTurnoutDesignerW = NULL; } - if (sAboutProd) - { + if (sAboutProd) { free(sAboutProd); sAboutProd = NULL; } - if (sSourceFilePattern) - { + if (sSourceFilePattern) { free(sSourceFilePattern); sSourceFilePattern = NULL; } - if (sImportFilePattern) - { + if (sImportFilePattern) { free(sImportFilePattern); sImportFilePattern = NULL; } - if (sDXFFilePattern) - { + if (sDXFFilePattern) { free(sDXFFilePattern); sDXFFilePattern = NULL; } @@ -248,23 +234,19 @@ void CleanupCustom( void ) free(sSVGFilePattern); sSVGFilePattern = NULL; } - if (sRecordFilePattern) - { + if (sRecordFilePattern) { free(sRecordFilePattern); sRecordFilePattern = NULL; } - if (sNoteFilePattern) - { + if (sNoteFilePattern) { free(sNoteFilePattern); sNoteFilePattern = NULL; } - if (sLogFilePattern) - { + if (sLogFilePattern) { free(sLogFilePattern); sLogFilePattern = NULL; } - if (sPartsListFilePattern) - { + if (sPartsListFilePattern) { free(sPartsListFilePattern); sPartsListFilePattern = NULL; } diff --git a/app/bin/custom.h b/app/bin/custom.h index abef217..d14bff7 100644 --- a/app/bin/custom.h +++ b/app/bin/custom.h @@ -1,5 +1,5 @@ /** \file custom.h - * + * */ /* XTrkCad - Model Railroad CAD @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef CUSTOM_H @@ -25,30 +25,6 @@ #include "common.h" -#define ICON_WIDTH (64) -#define ICON_HEIGHT (64) - -#define BG_SELECT (0) -#define BG_ZOOM (1) -#define BG_UNDO (2) -#define BG_EASE (3) -#define BG_TRKCRT (4) -#define BG_TRKMOD (5) -#define BG_TRKGRP (6) -#define BG_MISCCRT (7) -#define BG_RULER (8) -#define BG_LAYER (9) -#define BG_HOTBAR (10) -#define BG_SNAP (11) -#define BG_TRAIN (12) -#define BG_COUNT (13) -#define BG_FILE (14) -#define BG_CONTROL (15) -#define BG_EXPORTIMPORT (16) -#define BG_PRINT (17) -#define BG_BIGGAP (1<<8) -extern int cmdGroup; - extern char * sProdName; extern char * sProdNameLower; extern char * sProdNameUpper; @@ -66,6 +42,7 @@ extern char * sClipboardF; extern char * sParamQF; extern char * sUndoF; extern char * sAuditF; +extern char * sTipF; extern char * sSourceFilePattern; extern char * sSaveFilePattern; @@ -126,8 +103,10 @@ void InitCmdPan( wMenu_p menu ); void InitCmdPan2( wMenu_p menu ); void InitCmdDelete( void ); void InitCmdSplit( wMenu_p menu ); +void InitCmdTies( void ); void InitCmdTunnel( void ); void InitCmdBridge( void ); +void InitCmdRoadbed( void ); void InitCmdRuler( wMenu_p menu ); void InitCmdParallel( wMenu_p menu ); @@ -142,7 +121,6 @@ void InitCmdUndo( void ); void InitCmdStruct( wMenu_p menu ); void InitCmdAboveBelow( void ); //void InitCmdEnumerate( void ); -void InitCmdExport( void ); void InitCmdEasement( void ); char * MakeWindowTitle( char * ); diff --git a/app/bin/dbench.c b/app/bin/dbench.c index 7619fcb..a6284ea 100644 --- a/app/bin/dbench.c +++ b/app/bin/dbench.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "param.h" @@ -53,42 +53,45 @@ static char *benchTypeS[] = { "", N_(" L-Girder"), N_(" T-Girder") }; #include "bitmaps/bo_ti.xpm" typedef struct { - char * name; - char ** xpm; - wIcon_p icon; - } orientData_t; + char * name; + char ** xpm; + wIcon_p icon; +} orientData_t; static orientData_t rectOrientD[] = { - { N_("On Edge"), bo_edge_xpm }, - { N_("Flat"), bo_flat_xpm } }; + { N_("On Edge"), bo_edge_xpm }, + { N_("Flat"), bo_flat_xpm } +}; static orientData_t lgirderOrientD[] = { - { N_("Left"), bo_ll_xpm }, - { N_("Right"), bo_lr_xpm }, - { N_("Left-Down"), bo_lld_xpm }, - { N_("Right-Down"), bo_lrd_xpm }, - { N_("Left-Up"), bo_llu_xpm }, - { N_("Right-Up"), bo_lru_xpm }, - { N_("Left-Inverted"), bo_lli_xpm }, - { N_("Right-Inverted"), bo_lri_xpm } }; + { N_("Left"), bo_ll_xpm }, + { N_("Right"), bo_lr_xpm }, + { N_("Left-Down"), bo_lld_xpm }, + { N_("Right-Down"), bo_lrd_xpm }, + { N_("Left-Up"), bo_llu_xpm }, + { N_("Right-Up"), bo_lru_xpm }, + { N_("Left-Inverted"), bo_lli_xpm }, + { N_("Right-Inverted"), bo_lri_xpm } +}; static orientData_t tgirderOrientD[] = { - { N_("Normal"), bo_t_xpm }, - { N_("Right"), bo_tr_xpm }, - { N_("Left"), bo_tl_xpm }, - { N_("Inverted"), bo_ti_xpm } }; + { N_("Normal"), bo_t_xpm }, + { N_("Right"), bo_tr_xpm }, + { N_("Left"), bo_tl_xpm }, + { N_("Inverted"), bo_ti_xpm } +}; static struct { - int cnt; - orientData_t *data; - } orientD[] = { {2, rectOrientD}, {8, lgirderOrientD}, {4, tgirderOrientD} }; + int cnt; + orientData_t *data; +} orientD[] = { {2, rectOrientD}, {8, lgirderOrientD}, {4, tgirderOrientD} }; + - /* L-N R-N L-D R-D L-U R-U L-I R-I */ static BOOL_T lgirderFlangeLeft[] = { 1, 0, 0, 1, 1, 0, 0, 1 }; static BOOL_T lgirderFlangeDashed[] = { 1, 1, 1, 1, 0, 0, 0, 0 }; static BOOL_T lgirderNarrow[] = { 1, 1, 0, 0, 0, 0, 1, 1 }; EXPORT void BenchUpdateOrientationList( - long benchData, - wList_p list ) + long benchData, + wList_p list ) { long type; orientData_t *op; @@ -99,29 +102,30 @@ EXPORT void BenchUpdateOrientationList( op = orientD[type].data; for (cnt=orientD[type].cnt-1; cnt>=0; cnt--,op++) { #ifdef WINDOWS - if (op->icon == NULL) + if (op->icon == NULL) { op->icon = wIconCreatePixMap( op->xpm ); + } wListAddValue( list, NULL, op->icon, op ); #else /* gtk_combo_find is upset if we try to put anything other that a label on a list */ wListAddValue( list, _(op->name), NULL, op ); #endif - } - wListSetIndex( list, 0 ); + } + wListSetIndex( list, 0 ); } typedef struct { - long type; - long width; - long height0, height1; - } benchType_t, *benchType_p; + long type; + long width; + long height0, height1; +} benchType_t, *benchType_p; static dynArr_t benchType_da; #define benchType(N) DYNARR_N( benchType_t, benchType_da, N ) static void AddBenchTypes( - long type, - const char * key, - const char * defvalue ) + long type, + const char * key, + const char * defvalue ) { benchType_p bt; const char *value, *cp; @@ -140,7 +144,8 @@ static void AddBenchTypes( bt->height0 = strtol( cp=cq, &cq, 10 ); bt->height1 = strtol( cp=cq, &cq, 10 ); if ( cp == cq ) { - NoticeMessage( _("Bad BenchType for %s:\n%s"), _("Continue"), NULL, key, value ); + NoticeMessage( _("Bad BenchType for %s:\n%s"), _("Continue"), NULL, key, + value ); benchType_da.cnt--; return; } @@ -167,12 +172,14 @@ EXPORT void BenchLoadLists( wList_p choiceL, wList_p orientL ) bt = &benchType(inx); for (height=bt->height0; height<=bt->height1; height++ ) { benchData = bt->type<<24 | bt->width<<17 | height<<9; - sprintf( message, "%s", (bt->type==B_LGRIDER?"L-":bt->type==B_TGRIDER?"T-":"") ); + sprintf( message, "%s", (bt->type==B_LGRIDER?"L-":bt->type==B_TGRIDER + ?"T-":"") ); cp = message+strlen(message); - if ( units==UNITS_ENGLISH ) + if ( units==UNITS_ENGLISH ) { sprintf( cp, "%ld\"x%ld\"", bt->width, height ); - else + } else { sprintf( cp, "%ldmm x %ldmm", height*25, bt->width*25 ); + } wListAddValue( choiceL, message, NULL, I2VP(benchData) ); } } @@ -182,15 +189,15 @@ EXPORT void BenchLoadLists( wList_p choiceL, wList_p orientL ) EXPORT long GetBenchData( - long benchData, - long orient ) + long benchData, + long orient ) { return (benchData&0xFFFFFF00)|(orient&0xFF); } EXPORT wIndex_t GetBenchListIndex( - long benchData ) + long benchData ) { wIndex_t inx, cnt; benchType_p bt; @@ -204,11 +211,12 @@ EXPORT wIndex_t GetBenchListIndex( for ( inx=cnt=0; inx<benchType_da.cnt; inx++ ) { bt = &benchType(inx); if ( bt->type == type && - bt->width == iwidth ) { - if ( iheight < bt->height0 ) + bt->width == iwidth ) { + if ( iheight < bt->height0 ) { bt->height0 = iheight; - else if ( iheight > bt->height1 ) + } else if ( iheight > bt->height1 ) { bt->height1 = iheight; + } cnt += (wIndex_t)(iheight - bt->height0); return cnt; } @@ -224,13 +232,13 @@ EXPORT wIndex_t GetBenchListIndex( EXPORT void DrawBench( - drawCmd_p d, - coOrd p0, - coOrd p1, - wDrawColor color1, - wDrawColor color2, - long option, - long benchData ) + drawCmd_p d, + coOrd p0, + coOrd p1, + wDrawColor color1, + wDrawColor color2, + long option, + long benchData ) { long orient; coOrd pp[4]; @@ -257,16 +265,17 @@ EXPORT void DrawBench( DrawPoly( d, 4, pp, NULL, color1, 0, DRAW_FILL ); /* Draw Outline */ if ( /*color1 != color2 &&*/ - ( ( d->scale < ((d->options&DC_PRINT)?(twoRailScale*2+1):twoRailScale) ) || /* big enough scale */ - ( d->funcs == &tempSegDrawFuncs ) ) ) { + DrawTwoRails(d,1) || + d->funcs == &tempSegDrawFuncs ) { DrawPoly( d, 4, pp, NULL, color2, 0, DRAW_CLOSED ); if ( color1 != color2 && type != B_RECT ) { oldOptions = d->options; if ( type == B_LGRIDER || orient == 1 || orient == 2 ) { - if ( type == B_LGRIDER && lgirderFlangeDashed[orient] ) + if ( type == B_LGRIDER && lgirderFlangeDashed[orient] ) { d->options |= DC_DASH; + } if ( (type == B_LGRIDER && lgirderFlangeLeft[orient]) || - (type == B_TGRIDER && orient == 1) ) { + (type == B_TGRIDER && orient == 1) ) { Translate( &pp[0], pp[1], a+90, thickness ); Translate( &pp[3], pp[2], a+90, thickness ); } else { @@ -275,14 +284,15 @@ EXPORT void DrawBench( } DrawLine( d, pp[0], pp[3], 0, color2 ); } else { - Translate( &pp[0], p0, a+90, thickness/2.0 ); - Translate( &pp[1], p0, a-90, thickness/2.0 ); - Translate( &pp[2], p1, a-90, thickness/2.0 ); - Translate( &pp[3], p1, a+90, thickness/2.0 ); - if ( orient == 0 ) - d->options |= DC_DASH; - DrawLine( d, pp[0], pp[3], 0, color2 ); - DrawLine( d, pp[1], pp[2], 0, color2 ); + Translate( &pp[0], p0, a+90, thickness/2.0 ); + Translate( &pp[1], p0, a-90, thickness/2.0 ); + Translate( &pp[2], p1, a-90, thickness/2.0 ); + Translate( &pp[3], p1, a+90, thickness/2.0 ); + if ( orient == 0 ) { + d->options |= DC_DASH; + } + DrawLine( d, pp[0], pp[3], 0, color2 ); + DrawLine( d, pp[1], pp[2], 0, color2 ); } d->options = oldOptions; } @@ -301,8 +311,8 @@ EXPORT addButtonCallBack_t InitBenchDialog( void ) EXPORT void BenchGetDesc( - long benchData, - char * desc ) + long benchData, + char * desc ) { long orient; long type; @@ -314,49 +324,52 @@ EXPORT void BenchGetDesc( iwidth = (benchData>>17)&0x7f; type = (benchData>>24)&0xff; - if ( units==UNITS_ENGLISH ) + if ( units==UNITS_ENGLISH ) { sprintf( name, "%ld\"x%ld\"", iwidth, iheight ); - else + } else { sprintf( name, "%ldmm x %ldmm", iheight*25, iwidth*25 ); + } sprintf( desc, "%s%s %s", - (type==B_LGRIDER?"L - ":type==B_TGRIDER?"T - ":""), - name, - _(orientD[type].data[(int)orient].name) ); + (type==B_LGRIDER?"L - ":type==B_TGRIDER?"T - ":""), + name, + _(orientD[type].data[(int)orient].name) ); } typedef struct { - long type; - long width; - long height; - DIST_T length; - } benchEnum_t, *benchEnum_p; + long type; + long width; + long height; + DIST_T length; +} benchEnum_t, *benchEnum_p; static dynArr_t benchEnum_da; #define benchEnum(N) DYNARR_N( benchEnum_t, benchEnum_da, N ) static void PrintBenchLine( - char * line, - benchEnum_p bp ) + char * line, + benchEnum_p bp ) { char name[40]; - if ( units==UNITS_ENGLISH ) + if ( units==UNITS_ENGLISH ) { sprintf( name, "%ld\"x%ld\"", bp->width, bp->height ); - else + } else { sprintf( name, "%ldmm x %ldmm", bp->height*25, bp->width*25 ); - sprintf( line, "%s - %s%s", FormatDistance(bp->length), name, benchTypeS[bp->type] ); + } + sprintf( line, "%s - %s%s", FormatDistance(bp->length), name, + benchTypeS[bp->type] ); } EXPORT void CountBench( - long benchData, - DIST_T length ) + long benchData, + DIST_T length ) { int inx; - long orient; +// long orient; long type; long iwidth, iheight; benchEnum_p bp; - orient = benchData&0xFF; +// orient = benchData&0xFF; iheight = (benchData>>9)&0xff; iwidth = (benchData>>17)&0x7f; type = (benchData>>24)&0xff; @@ -364,8 +377,8 @@ EXPORT void CountBench( for ( inx=0; inx<benchEnum_da.cnt; inx++ ) { bp = &benchEnum(inx); if ( bp->type == type && - bp->width == iwidth && - bp->height == iheight ) { + bp->width == iwidth && + bp->height == iheight ) { bp->length += length; goto foundBenchEnum; } @@ -379,20 +392,21 @@ EXPORT void CountBench( foundBenchEnum: PrintBenchLine( message, bp ); size_t width = strlen(message); - if ( width > enumerateMaxDescLen) + if ( width > enumerateMaxDescLen) { enumerateMaxDescLen = (int)width; + } } static int Cmp_benchEnum( - const void *p1, - const void *p2 ) + const void *p1, + const void *p2 ) { benchEnum_p bp1 = (benchEnum_p)p1; benchEnum_p bp2 = (benchEnum_p)p2; long diff; - if ( ( diff = bp1->type-bp2->type ) != 0 ) return (int)diff; - if ( ( diff = bp1->width-bp2->width ) != 0 ) return (int)diff; - if ( ( diff = bp1->height-bp2->height ) != 0 ) return (int)diff; + if ( ( diff = bp1->type-bp2->type ) != 0 ) { return (int)diff; } + if ( ( diff = bp1->width-bp2->width ) != 0 ) { return (int)diff; } + if ( ( diff = bp1->height-bp2->height ) != 0 ) { return (int)diff; } return 0; } @@ -402,7 +416,7 @@ EXPORT void TotalBench( void ) char title[STR_SIZE]; benchEnum_p bp; - qsort( benchEnum_da.ptr, benchEnum_da.cnt, sizeof *bp, Cmp_benchEnum ); + qsort( &benchEnum(0), benchEnum_da.cnt, sizeof *bp, Cmp_benchEnum ); for ( inx=0; inx<benchEnum_da.cnt; inx++ ) { bp = &benchEnum(inx); if ( bp->length > 0 ) { diff --git a/app/bin/dbitmap.c b/app/bin/dbitmap.c index 62c708e..0732065 100644 --- a/app/bin/dbitmap.c +++ b/app/bin/dbitmap.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "custom.h" @@ -81,8 +81,9 @@ static drawCmd_t bitmap_d = { * \param yPos The position. */ -static void DrawTextCenterXPosY( char *string, wFont_p font, wFontSize_t fontSize, - POS_T yPos ) +static void DrawTextCenterXPosY( char *string, wFont_p font, + wFontSize_t fontSize, + POS_T yPos ) { coOrd textSize; coOrd p; @@ -142,8 +143,8 @@ static int SaveBitmapFile( { bool result; - assert( fileName != NULL ); - assert( files == 1 ); + CHECK( fileName != NULL ); + CHECK( files == 1 ); wSetCursor( mainD.d, wCursorWait ); InfoMessage( _( "Drawing tracks to bitmap" ) ); diff --git a/app/bin/dcar.c b/app/bin/dcar.c index 5607738..11a5a1e 100644 --- a/app/bin/dcar.c +++ b/app/bin/dcar.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "cselect.h" @@ -36,7 +36,7 @@ static int log_carInvList; static int log_carDlgState; static int log_carDlgList; -static paramFloatRange_t r0_99999 = { 0, 99999, 80 }; +//static paramFloatRange_t r0_99999 = { 0, 99999, 80 }; static paramFloatRange_t r0d001_99999 = { 0.001, 99999, 80 }; static paramFloatRange_t r9999_9999 = {-99999, 99999, 80}; static paramIntegerRange_t i1_999999999 = { 1, 999999999, 80, PDO_NORANGECHECK_HIGH }; @@ -56,9 +56,9 @@ static void CarInvListUpdate( carItem_p item ); #define T_NUMBER (6) typedef struct { - char * name; - long value; - } nameLongMap_t; + char * name; + long value; +} nameLongMap_t; #define CAR_DESC_COUPLER_MODE_BODY (1L<<0) @@ -74,40 +74,40 @@ typedef struct { typedef struct carProto_t * carProto_p; typedef struct { - DIST_T carLength; - DIST_T carWidth; - DIST_T truckCenter; - DIST_T truckCenterOffset; - DIST_T coupledLength; - } carDim_t; + DIST_T carLength; + DIST_T carWidth; + DIST_T truckCenter; + DIST_T truckCenterOffset; + DIST_T coupledLength; +} carDim_t; typedef struct { - char * number; - FLOAT_T purchPrice; - FLOAT_T currPrice; - long condition; - long purchDate; - long serviceDate; - char * notes; - } carData_t; + char * number; + FLOAT_T purchPrice; + FLOAT_T currPrice; + long condition; + long purchDate; + long serviceDate; + char * notes; +} carData_t; struct carItem_t { - long index; - SCALEINX_T scaleInx; - char * contentsLabel; - char * title; - carProto_p proto; - DIST_T barScale; - wDrawColor color; - long options; - long type; - carDim_t dim; - carData_t data; - wIndex_t segCnt; - trkSeg_p segPtr; - track_p car; - coOrd pos; - ANGLE_T angle; - }; + long index; + SCALEINX_T scaleInx; + char * contentsLabel; + char * title; + carProto_p proto; + DIST_T barScale; + wDrawColor color; + long options; + long type; + carDim_t dim; + carData_t data; + wIndex_t segCnt; + trkSeg_p segPtr; + track_p car; + coOrd pos; + ANGLE_T angle; +}; /* @@ -117,23 +117,24 @@ struct carItem_t { typedef struct { - char * ptr; - int len; - } tabString_t, *tabString_p; + char * ptr; + int len; +} tabString_t, *tabString_p; static void TabStringExtract( - char * string, - int count, - tabString_t * tabs ) + char * string, + int count, + tabString_t * tabs ) { int inx; char * next = string; for ( inx=0; inx<count; inx++ ) { tabs[inx].ptr = string; - if ( next ) - next = strchr( string, '\t' ); + if ( next ) { + next = strchr( string, '\t' ); + } if ( next ) { tabs[inx].len = (int)(next-string); string = next+1; @@ -150,7 +151,7 @@ static void TabStringExtract( static char * TabStringDup( - tabString_t * tab ) + tabString_t * tab ) { char * ret; ret = MyMalloc( tab->len+1 ); @@ -161,8 +162,8 @@ static char * TabStringDup( static char * TabStringCpy( - char * dst, - tabString_t * tab ) + char * dst, + tabString_t * tab ) { memcpy( dst, tab->ptr, tab->len ); dst[tab->len] = '\0'; @@ -171,31 +172,34 @@ static char * TabStringCpy( static int TabStringCmp( - char * src, - tabString_t * tab ) + char * src, + tabString_t * tab ) { size_t srclen = strlen(src); size_t len = srclen; int rc; - if ( len > tab->len ) + if ( len > tab->len ) { len = tab->len; + } rc = strncasecmp( src, tab->ptr, len ); - if ( rc != 0 || srclen == tab->len ) + if ( rc != 0 || srclen == tab->len ) { return rc; - else if ( srclen > tab->len ) + } else if ( srclen > tab->len ) { return 1; - else + } else { return -1; + } } static long TabGetLong( - tabString_t * tab ) + tabString_t * tab ) { char old_c; long val; - if ( tab->len <= 0 ) + if ( tab->len <= 0 ) { return 0; + } old_c = tab->ptr[tab->len]; tab->ptr[tab->len] = '\0'; val = atol( tab->ptr ); @@ -205,12 +209,13 @@ static long TabGetLong( static FLOAT_T TabGetFloat( - tabString_t * tab ) + tabString_t * tab ) { char old_c; FLOAT_T val; - if ( tab->len <= 0 ) + if ( tab->len <= 0 ) { return 0.0; + } old_c = tab->ptr[tab->len]; tab->ptr[tab->len] = '\0'; val = atof( tab->ptr ); @@ -220,10 +225,10 @@ static FLOAT_T TabGetFloat( static void RotatePts( - int cnt, - coOrd * pts, - coOrd orig, - ANGLE_T angle ) + int cnt, + coOrd * pts, + coOrd orig, + ANGLE_T angle ) { int inx; for ( inx=0; inx<cnt; inx++ ) { @@ -233,10 +238,10 @@ static void RotatePts( static void RescalePts( - int cnt, - coOrd * pts, - FLOAT_T scale_x, - FLOAT_T scale_y ) + int cnt, + coOrd * pts, + FLOAT_T scale_x, + FLOAT_T scale_y ) { int inx; for ( inx=0; inx<cnt; inx++ ) { @@ -248,10 +253,10 @@ static void RescalePts( static int lookupListIndex; static void * LookupListElem( - dynArr_t * da, - void * key, - int (*cmpFunc)( void *, void * ), - int elem_size ) + dynArr_t * da, + void * key, + int (*cmpFunc)( void *, void * ), + int elem_size ) { int hi, lo, mid, rc; lo = 0; @@ -263,18 +268,20 @@ static void * LookupListElem( lookupListIndex = mid; return DYNARR_N(void*,*da,mid); } - if ( rc > 0 ) + if ( rc > 0 ) { lo = mid+1; - else + } else { hi = mid-1; + } } if ( elem_size == 0 ) { lookupListIndex = -1; return NULL; } DYNARR_APPEND( void*, *da, 10 ); - for ( mid=da->cnt-1; mid>lo; mid-- ) + for ( mid=da->cnt-1; mid>lo; mid-- ) { DYNARR_N(void*,*da,mid) = DYNARR_N(void*,*da,mid-1); + } DYNARR_N(void*,*da,lo) = MyMalloc(elem_size); memset( DYNARR_N(void*,*da,lo), 0, elem_size ); lookupListIndex = lo; @@ -282,17 +289,18 @@ static void * LookupListElem( } static void RemoveListElem( - dynArr_t * da, - void * elem ) + dynArr_t * da, + void * elem ) { int inx; for ( inx=0; inx<da->cnt; inx++ ) - if ( DYNARR_N(void*,*da,inx) == elem ) + if ( DYNARR_N(void*,*da,inx) == elem ) { break; - if ( inx>=da->cnt ) - AbortProg( "removeListElem" ); - for ( inx++; inx<da->cnt; inx++ ) + } + CHECK( inx<da->cnt ); + for ( inx++; inx<da->cnt; inx++ ) { DYNARR_N(void*,*da,inx-1) = DYNARR_N(void*,*da,inx); + } da->cnt--; } @@ -306,53 +314,55 @@ static void RemoveListElem( #define SI (30) #define SO (37) static coOrd truckOutline[] = { - { -TW, -SO }, - { TW, -SO }, - { TW, -SI }, - { BW, -SI }, - { BW, SI }, - { TW, SI }, - { TW, SO }, - { -TW, SO }, - { -TW, SI }, - { -BW, SI }, - { -BW, -SI }, - { -TW, -SI } }; + { -TW, -SO }, + { TW, -SO }, + { TW, -SI }, + { BW, -SI }, + { BW, SI }, + { TW, SI }, + { TW, SO }, + { -TW, SO }, + { -TW, SI }, + { -BW, SI }, + { -BW, -SI }, + { -TW, -SI } +}; #define WO ((56.6-2)/2) #define WI ((56.6-12)/2) #define Wd (36/2) #define AW (8/2) static coOrd wheelOutline[] = { - { -Wd, -WO }, + { -Wd, -WO }, - { -AW, -WO }, - { -AW, -SI }, - { AW, -SI }, - { AW, -WO }, + { -AW, -WO }, + { -AW, -SI }, + { AW, -SI }, + { AW, -WO }, - { Wd, -WO }, - { Wd, -WI }, - { AW, -WI }, - { AW, WI }, - { Wd, WI }, - { Wd, WO }, + { Wd, -WO }, + { Wd, -WI }, + { AW, -WI }, + { AW, WI }, + { Wd, WI }, + { Wd, WO }, - { AW, WO }, - { AW, SI }, - { -AW, SI }, - { -AW, WO }, + { AW, WO }, + { AW, SI }, + { -AW, SI }, + { -AW, WO }, - { -Wd, WO }, - { -Wd, WI }, - { -AW, WI }, - { -AW, -WI }, + { -Wd, WO }, + { -Wd, WI }, + { -AW, WI }, + { -AW, -WI }, - { -Wd, -WI } }; + { -Wd, -WI } +}; static void MovePts( - int cnt, - coOrd * pts, - coOrd orig ) + int cnt, + coOrd * pts, + coOrd orig ) { int inx; for ( inx=0; inx<cnt; inx++ ) { @@ -363,11 +373,11 @@ static void MovePts( static void CarProtoDrawTruck( - drawCmd_t * d, - DIST_T width, - FLOAT_T ratio, - coOrd pos, - ANGLE_T angle ) + drawCmd_t * d, + DIST_T width, + FLOAT_T ratio, + coOrd pos, + ANGLE_T angle ) { coOrd p[24], pp; wDrawColor color = wDrawColorBlack; @@ -399,38 +409,40 @@ static void CarProtoDrawTruck( static coOrd couplerOutline[] = { - { 0, 2.5 }, - { 0, -2.5 }, - { 0, -2.5 }, - { 3, -7 }, - { 14, -5 }, - { 14, 2 }, - { 12, 2 }, - { 12, -2 }, - { 9, -2 }, - { 9, 3 }, - { 13, 6 }, - { 13, 7 }, - { 6, 7 }, - { 0, 2.5 } }; + { 0, 2.5 }, + { 0, -2.5 }, + { 0, -2.5 }, + { 3, -7 }, + { 14, -5 }, + { 14, 2 }, + { 12, 2 }, + { 12, -2 }, + { 9, -2 }, + { 9, 3 }, + { 13, 6 }, + { 13, 7 }, + { 6, 7 }, + { 0, 2.5 } +}; static void CarProtoDrawCoupler( - drawCmd_t * d, - DIST_T length, - FLOAT_T ratio, - coOrd pos, - ANGLE_T angle ) + drawCmd_t * d, + DIST_T length, + FLOAT_T ratio, + coOrd pos, + ANGLE_T angle ) { coOrd p[24], pp; wDrawColor color = wDrawColorBlack; length /= ratio; - if ( length < 12.0 ) + if ( length < 12.0 ) { return; + } memcpy( p, couplerOutline, sizeof couplerOutline ); p[0].x = p[1].x = -(length-12.0); pp.x = length-12.0; pp.y = 0; -/* TODO - if length > 6 then draw Sills */ + /* TODO - if length > 6 then draw Sills */ MovePts( COUNT( couplerOutline ), p, pp ); RescalePts( COUNT( couplerOutline ), p, ratio, ratio ); RotatePts( COUNT( couplerOutline ), p, zero, angle-90.0 ); @@ -449,30 +461,31 @@ struct carProto_t; typedef struct carProto_t carProto_t; struct carProto_t { - char * contentsLabel; - wIndex_t paramFileIndex; - char * desc; - long options; - long type; - carDim_t dim; - int segCnt; - trkSeg_p segPtr; - coOrd size; - coOrd orig; - }; + char * contentsLabel; + wIndex_t paramFileIndex; + char * desc; + long options; + long type; + carDim_t dim; + int segCnt; + trkSeg_p segPtr; + coOrd size; + coOrd orig; +}; static dynArr_t carProto_da; #define carProto(N) DYNARR_N( carProto_t*, carProto_da, N ) #define N_TYPELISTMAP (7) static nameLongMap_t typeListMap[N_TYPELISTMAP] = { - { N_("Diesel Loco"), 10101 }, - { N_("Steam Loco"), 10201 }, - { N_("Elect Loco"), 10301 }, - { N_("Freight Car"), 30100 }, - { N_("Psngr Car"), 50100 }, - { N_("M-O-W"), 70100 }, - { N_("Other"), 90100 } }; + { N_("Diesel Loco"), 10101 }, + { N_("Steam Loco"), 10201 }, + { N_("Elect Loco"), 10301 }, + { N_("Freight Car"), 30100 }, + { N_("Psngr Car"), 50100 }, + { N_("M-O-W"), 70100 }, + { N_("Other"), 90100 } +}; static trkSeg_p carProtoSegPtr; static int carProtoSegCnt; @@ -481,12 +494,12 @@ static int carProtoSegCnt; static pts_t dummyOutlineSegPts[5]; static trkSeg_t dummyOutlineSegs; static void CarProtoDlgCreateDummyOutline( - int * segCntP, - trkSeg_p * segPtrP, - BOOL_T isLoco, - DIST_T length, - DIST_T width, - wDrawColor color ) + int * segCntP, + trkSeg_p * segPtrP, + BOOL_T isLoco, + DIST_T length, + DIST_T width, + wDrawColor color ) { trkSeg_p segPtr; pts_t * pts; @@ -497,7 +510,7 @@ static void CarProtoDlgCreateDummyOutline( segPtr->type = SEG_FILPOLY; segPtr->color = color; - segPtr->width = 0; + segPtr->lineWidth = 0; segPtr->u.p.cnt = isLoco?5:4; segPtr->u.p.pts = pts = dummyOutlineSegPts; segPtr->u.p.orig.x = 0; @@ -530,15 +543,16 @@ static void CarProtoDlgCreateDummyOutline( static int CarProtoFindTypeCode( - long code ) + long code ) { int inx; for ( inx=0; inx<N_TYPELISTMAP; inx++ ) { if ( typeListMap[inx].value > code ) { - if ( inx == 0 ) + if ( inx == 0 ) { return N_TYPELISTMAP-1; - else + } else { return inx-1; + } } } return N_TYPELISTMAP-1; @@ -546,8 +560,8 @@ static int CarProtoFindTypeCode( static int CmpCarProto( - void * key, - void * elem ) + void * key, + void * elem ) { char * key_val=key; carProto_p elem_val=elem; @@ -556,24 +570,26 @@ static int CmpCarProto( static carProto_p CarProtoFind( - char * desc ) + char * desc ) { return LookupListElem( &carProto_da, desc, CmpCarProto, 0 ); } static carProto_p CarProtoLookup( - char * desc, - BOOL_T createMissing, - BOOL_T isLoco, - DIST_T length, - DIST_T width ) + char * desc, + BOOL_T createMissing, + BOOL_T isLoco, + DIST_T length, + DIST_T width ) { carProto_p proto; trkSeg_p segPtr; - proto = LookupListElem( &carProto_da, desc, CmpCarProto, createMissing?sizeof *proto:0 ); - if ( proto == NULL ) + proto = LookupListElem( &carProto_da, desc, CmpCarProto, + createMissing?sizeof *proto:0 ); + if ( proto == NULL ) { return NULL; + } if ( proto->desc == NULL ) { proto->desc = MyStrdup(desc); proto->contentsLabel = "Car Prototype"; @@ -583,10 +599,13 @@ static carProto_p CarProtoLookup( proto->dim.carWidth = width; proto->dim.truckCenter = length - 2.0*59.0; proto->dim.coupledLength = length + 2.0*16.0; - CarProtoDlgCreateDummyOutline( &proto->segCnt, &segPtr, isLoco, length, width, drawColorBlue ); - proto->segPtr = (trkSeg_p)memdup( segPtr, (sizeof *(trkSeg_p)0) * proto->segCnt ); + CarProtoDlgCreateDummyOutline( &proto->segCnt, &segPtr, isLoco, length, width, + drawColorBlue ); + proto->segPtr = (trkSeg_p)memdup( segPtr, + (sizeof *(trkSeg_p)0) * proto->segCnt ); CloneFilledDraw( proto->segCnt, proto->segPtr, FALSE ); - GetSegBounds( zero, 0.0, proto->segCnt, proto->segPtr, &proto->orig, &proto->size ); + GetSegBounds( zero, 0.0, proto->segCnt, proto->segPtr, &proto->orig, + &proto->size ); carProtoListChanged = TRUE; // return proto; } @@ -594,17 +613,18 @@ static carProto_p CarProtoLookup( } enum paramFileState -GetCarProtoCompatibility(int paramFileIndex, SCALEINX_T scaleIndex) -{ +GetCarProtoCompatibility(int paramFileIndex, SCALEINX_T scaleIndex) { int i; enum paramFileState ret = PARAMFILE_NOTUSABLE; - DIST_T ratio = GetScaleRatio(scaleIndex); +// DIST_T ratio = GetScaleRatio(scaleIndex); - if (!IsParamValid(paramFileIndex)) { + if (!IsParamValid(paramFileIndex)) + { return(PARAMFILE_UNLOADED); } - for (i = 0; i < carProto_da.cnt; i++) { + for (i = 0; i < carProto_da.cnt; i++) + { carProto_t *carProto = carProto(i); if (carProto->paramFileIndex == paramFileIndex) { ret = PARAMFILE_FIT; @@ -615,21 +635,22 @@ GetCarProtoCompatibility(int paramFileIndex, SCALEINX_T scaleIndex) } static carProto_p CarProtoNew( - carProto_p proto, - int paramFileIndex, - char * desc, - long options, - long type, - carDim_t * dim, - wIndex_t segCnt, - trkSeg_p segPtr ) + carProto_p proto, + int paramFileIndex, + char * desc, + long options, + long type, + carDim_t * dim, + wIndex_t segCnt, + trkSeg_p segPtr ) { if ( proto == NULL ) { proto = LookupListElem( &carProto_da, desc, CmpCarProto, sizeof *proto ); if ( proto->desc != NULL ) { if ( proto->paramFileIndex == PARAM_CUSTOM && - paramFileIndex != PARAM_CUSTOM ) + paramFileIndex != PARAM_CUSTOM ) { return proto; + } } } if ( proto->desc != NULL ) { @@ -644,22 +665,26 @@ static carProto_p CarProtoNew( proto->segCnt = segCnt; //if (proto->segPtr) Can't do this because segPtr could be static // free(proto->segPtr); - proto->segPtr = (trkSeg_p)memdup( segPtr, (sizeof *(trkSeg_p)0) * proto->segCnt ); + proto->segPtr = (trkSeg_p)memdup( segPtr, + (sizeof *(trkSeg_p)0) * proto->segCnt ); CloneFilledDraw( proto->segCnt, proto->segPtr, FALSE ); - GetSegBounds( zero, 0.0, proto->segCnt, proto->segPtr, &proto->orig, &proto->size ); + GetSegBounds( zero, 0.0, proto->segCnt, proto->segPtr, &proto->orig, + &proto->size ); carProtoListChanged = TRUE; return proto; } static void CarProtoDelete( - carProto_p protoP ) + carProto_p protoP ) { - if ( protoP == NULL ) + if ( protoP == NULL ) { return; + } RemoveListElem( &carProto_da, protoP ); - if ( protoP->desc ) + if ( protoP->desc ) { MyFree( protoP->desc ); + } MyFree( protoP ); } @@ -685,7 +710,8 @@ DeleteCarProto(int fileIndex) } // delete them - for (; inx < carProto_da.cnt && carProto(inx)->paramFileIndex == fileIndex; inx++) { + for (; inx < carProto_da.cnt + && carProto(inx)->paramFileIndex == fileIndex; inx++) { carProto_t * cp = carProto(inx); if (cp->paramFileIndex == fileIndex) { CarProtoDelete(cp); @@ -704,7 +730,7 @@ DeleteCarProto(int fileIndex) } static BOOL_T CarProtoRead( - char * line ) + char * line ) { char * desc; long options; @@ -713,12 +739,16 @@ static BOOL_T CarProtoRead( long longCenterOffset; if ( !GetArgs( line+9, "qllff0lff", - &desc, &options, &type, &dim.carLength, &dim.carWidth, &longCenterOffset, &dim.truckCenter, &dim.coupledLength ) ) + &desc, &options, &type, &dim.carLength, &dim.carWidth, &longCenterOffset, + &dim.truckCenter, &dim.coupledLength ) ) { return FALSE; + } dim.truckCenterOffset = longCenterOffset/1000.0; - if ( !ReadSegs() ) + if ( !ReadSegs() ) { return FALSE; - CarProtoNew( NULL, curParamFileIndex, desc, options, type, &dim, tempSegs_da.cnt, &tempSegs(0) ); + } + CarProtoNew( NULL, curParamFileIndex, desc, options, type, &dim, + tempSegs_da.cnt, &tempSegs(0) ); FreeFilledDraw(tempSegs_da.cnt,&tempSegs(0)); MyFree(desc); return TRUE; @@ -726,8 +756,8 @@ static BOOL_T CarProtoRead( static BOOL_T CarProtoWrite( - FILE * f, - carProto_t * proto ) + FILE * f, + carProto_t * proto ) { BOOL_T rc = TRUE; @@ -736,7 +766,9 @@ static BOOL_T CarProtoWrite( long longCenterOffset = (long)(proto->dim.truckCenterOffset*1000); rc &= fprintf( f, "CARPROTO \"%s\" %ld %ld %0.3f %0.3f 0 %ld %0.3f %0.3f\n", - PutTitle(proto->desc), proto->options, proto->type, proto->dim.carLength, proto->dim.carWidth, longCenterOffset, proto->dim.truckCenter, proto->dim.coupledLength )>0; + PutTitle(proto->desc), proto->options, proto->type, proto->dim.carLength, + proto->dim.carWidth, longCenterOffset, proto->dim.truckCenter, + proto->dim.coupledLength )>0; rc &= WriteSegs( f, proto->segCnt, proto->segPtr ); SetUserLocale(); @@ -747,7 +779,7 @@ static BOOL_T CarProtoWrite( static BOOL_T CarProtoCustomSave( - FILE * f ) + FILE * f ) { int inx; carProto_t * proto; @@ -755,8 +787,9 @@ static BOOL_T CarProtoCustomSave( for ( inx=0; inx<carProto_da.cnt; inx++ ) { proto = carProto(inx); - if ( proto->paramFileIndex == PARAM_CUSTOM ) + if ( proto->paramFileIndex == PARAM_CUSTOM ) { rc &= CarProtoWrite( f, proto ); + } } return rc; } @@ -774,32 +807,32 @@ typedef struct carPartParent_t carPartParent_t; typedef carPartParent_t * carPartParent_p; typedef struct { - char * name; - int len; - } cmp_key_t; + char * name; + int len; +} cmp_key_t; typedef struct { - tabString_t manuf; - tabString_t proto; - SCALEINX_T scale; - } cmp_partparent_t; + tabString_t manuf; + tabString_t proto; + SCALEINX_T scale; +} cmp_partparent_t; struct carPartParent_t { - char * manuf; - char * proto; - SCALEINX_T scale; - dynArr_t parts_da; - }; + char * manuf; + char * proto; + SCALEINX_T scale; + dynArr_t parts_da; +}; struct carPart_t { - carPartParent_p parent; - wIndex_t paramFileIndex; - char * title; - long options; - long type; - carDim_t dim; - wDrawColor color; - char * partnoP; - int partnoL; - }; + carPartParent_p parent; + wIndex_t paramFileIndex; + char * title; + long options; + long type; + carDim_t dim; + wDrawColor color; + char * partnoP; + int partnoL; +}; static dynArr_t carPartParent_da; #define carPartParent(N) DYNARR_N(carPartParent_p, carPartParent_da, N) #define carPart(P,N) DYNARR_N(carPart_p, (P)->parts_da, N) @@ -807,19 +840,17 @@ struct roadnameMap_t; typedef struct roadnameMap_t roadnameMap_t; typedef roadnameMap_t * roadnameMap_p; struct roadnameMap_t { - char * roadname; - char * repmark; - }; + char * roadname; + char * repmark; +}; static dynArr_t roadnameMap_da; #define roadnameMap(N) DYNARR_N(roadnameMap_p, roadnameMap_da, N) static BOOL_T roadnameMapChanged; -static long carPartChangeLevel = 0; - static int Cmp_part( - void * key, - void * elem ) + void * key, + void * elem ) { carPart_p cmp_key=key; carPart_p part_elem=elem; @@ -828,85 +859,100 @@ static int Cmp_part( len = min( cmp_key->partnoL, part_elem->partnoL ); rc = strncasecmp( cmp_key->partnoP, part_elem->partnoP, len+1 ); - if ( rc != 0 ) + if ( rc != 0 ) { return rc; - if ( cmp_key->paramFileIndex == part_elem->paramFileIndex ) + } + if ( cmp_key->paramFileIndex == part_elem->paramFileIndex ) { return 0; - if ( cmp_key->paramFileIndex == PARAM_DEMO ) + } + if ( cmp_key->paramFileIndex == PARAM_DEMO ) { return -1; - if ( part_elem->paramFileIndex == PARAM_DEMO ) + } + if ( part_elem->paramFileIndex == PARAM_DEMO ) { return 1; - if ( cmp_key->paramFileIndex == PARAM_CUSTOM ) + } + if ( cmp_key->paramFileIndex == PARAM_CUSTOM ) { return -1; - if ( part_elem->paramFileIndex == PARAM_CUSTOM ) + } + if ( part_elem->paramFileIndex == PARAM_CUSTOM ) { return 1; - if ( cmp_key->paramFileIndex == PARAM_LAYOUT ) + } + if ( cmp_key->paramFileIndex == PARAM_LAYOUT ) { return 1; - if ( part_elem->paramFileIndex == PARAM_LAYOUT ) + } + if ( part_elem->paramFileIndex == PARAM_LAYOUT ) { return -1; - if ( cmp_key->paramFileIndex > part_elem->paramFileIndex ) + } + if ( cmp_key->paramFileIndex > part_elem->paramFileIndex ) { return -1; - else + } else { return 1; + } } static int Cmp_partparent( - void * key, - void * elem ) + void * key, + void * elem ) { cmp_partparent_t * cmp_key=key; carPartParent_p part_elem=elem; int rc; rc = - TabStringCmp( part_elem->manuf, &cmp_key->manuf ); - if ( rc != 0 ) + if ( rc != 0 ) { return rc; + } rc = cmp_key->scale - part_elem->scale; - if ( rc != 0 ) + if ( rc != 0 ) { return rc; + } rc = - TabStringCmp( part_elem->proto, &cmp_key->proto ); return rc; } static int Cmp_roadnameMap( - void * key, - void * elem ) + void * key, + void * elem ) { cmp_key_t * cmp_key=key; roadnameMap_p roadname_elem=elem; int rc; rc = strncasecmp( cmp_key->name, roadname_elem->roadname, cmp_key->len ); - if ( rc == 0 && roadname_elem->roadname[cmp_key->len] ) + if ( rc == 0 && roadname_elem->roadname[cmp_key->len] ) { return -1; + } return rc; } static roadnameMap_p LoadRoadnameList( - tabString_p roadnameTab, - tabString_p repmarkTab ) + tabString_p roadnameTab, + tabString_p repmarkTab ) { cmp_key_t cmp_key; roadnameMap_p roadnameMapP; lookupListIndex = -1; - if ( roadnameTab->len<=0 ) + if ( roadnameTab->len<=0 ) { return NULL; - if ( TabStringCmp( "undecorated", roadnameTab ) == 0 ) + } + if ( TabStringCmp( "undecorated", roadnameTab ) == 0 ) { return NULL; + } cmp_key.name = roadnameTab->ptr; cmp_key.len = roadnameTab->len; - roadnameMapP = LookupListElem( &roadnameMap_da, &cmp_key, Cmp_roadnameMap, sizeof (roadnameMap_t) ); + roadnameMapP = LookupListElem( &roadnameMap_da, &cmp_key, Cmp_roadnameMap, + sizeof (roadnameMap_t) ); if ( roadnameMapP->roadname == NULL ) { roadnameMapP->roadname = TabStringDup(roadnameTab); roadnameMapP->repmark = TabStringDup(repmarkTab); roadnameMapChanged = TRUE; } else if ( repmarkTab->len > 0 && - ( roadnameMapP->repmark == NULL || roadnameMapP->repmark[0] == '\0' ) ) { + ( roadnameMapP->repmark == NULL || roadnameMapP->repmark[0] == '\0' ) ) { roadnameMapP->repmark = TabStringDup(repmarkTab); roadnameMapChanged = TRUE; } @@ -915,11 +961,11 @@ static roadnameMap_p LoadRoadnameList( static carPart_p CarPartFind( - char * manufP, - int manufL, - char * partnoP, - int partnoL, - SCALEINX_T scale ) + char * manufP, + int manufL, + char * partnoP, + int partnoL, + SCALEINX_T scale ) { wIndex_t inx1, inx2; carPart_p partP; @@ -927,15 +973,15 @@ static carPart_p CarPartFind( for ( inx1=0; inx1<carPartParent_da.cnt; inx1++ ) { parentP = carPartParent(inx1); if ( manufL == (int)strlen(parentP->manuf) && - strncasecmp( manufP, parentP->manuf, manufL ) == 0 && - scale == parentP->scale ) { + strncasecmp( manufP, parentP->manuf, manufL ) == 0 && + scale == parentP->scale ) { for ( inx2=0; inx2<parentP->parts_da.cnt; inx2++ ) { partP = carPart( parentP, inx2 ); if ( partnoL == partP->partnoL && - strncasecmp( partnoP, partP->partnoP, partnoL ) == 0 ) { + strncasecmp( partnoP, partP->partnoP, partnoL ) == 0 ) { return partP; } - } + } } } return NULL; @@ -945,7 +991,7 @@ static carPart_p CarPartFind( static void CarPartParentDelete( - carPartParent_p parentP ) + carPartParent_p parentP ) { RemoveListElem( &carPartParent_da, parentP ); MyFree( parentP->manuf ); @@ -955,7 +1001,7 @@ static void CarPartParentDelete( static void CarPartUnlink( - carPart_p partP ) + carPart_p partP ) { carPartParent_p parentP = partP->parent; RemoveListElem( &parentP->parts_da, partP ); @@ -966,11 +1012,11 @@ static void CarPartUnlink( static carPartParent_p CarPartParentNew( - char * manufP, - int manufL, - char *protoP, - int protoL, - SCALEINX_T scale ) + char * manufP, + int manufL, + char *protoP, + int protoL, + SCALEINX_T scale ) { carPartParent_p parentP; cmp_partparent_t cmp_key; @@ -979,7 +1025,8 @@ static carPartParent_p CarPartParentNew( cmp_key.proto.ptr = protoP; cmp_key.proto.len = protoL; cmp_key.scale = scale; - parentP = (carPartParent_p)LookupListElem( &carPartParent_da, &cmp_key, Cmp_partparent, sizeof * parentP); + parentP = (carPartParent_p)LookupListElem( &carPartParent_da, &cmp_key, + Cmp_partparent, sizeof * parentP); if ( parentP->manuf == NULL ) { parentP->manuf = (char*)MyMalloc( manufL+1 ); memcpy( parentP->manuf, manufP, manufL ); @@ -994,14 +1041,14 @@ static carPartParent_p CarPartParentNew( static carPart_p CarPartNew( - carPart_p partP, - int paramFileIndex, - SCALEINX_T scaleInx, - char * title, - long options, - long type, - carDim_t *dim, - wDrawColor color) + carPart_p partP, + int paramFileIndex, + SCALEINX_T scaleInx, + char * title, + long options, + long type, + carDim_t *dim, + wDrawColor color) { carPartParent_p parentP; carPart_t cmp_key; @@ -1009,27 +1056,34 @@ static carPart_p CarPartNew( TabStringExtract(title, 7, tabs); if (TabStringCmp("Undecorated", &tabs[T_MANUF]) == 0 || - TabStringCmp("Custom", &tabs[T_MANUF]) == 0 || - tabs[T_PART].len == 0) + TabStringCmp("Custom", &tabs[T_MANUF]) == 0 || + tabs[T_PART].len == 0) { return NULL; - if (tabs[T_PROTO].len == 0) + } + if (tabs[T_PROTO].len == 0) { return NULL; + } if (partP == NULL) { - partP = CarPartFind(tabs[T_MANUF].ptr, tabs[T_MANUF].len, tabs[T_PART].ptr, tabs[T_PART].len, scaleInx); + partP = CarPartFind(tabs[T_MANUF].ptr, tabs[T_MANUF].len, tabs[T_PART].ptr, + tabs[T_PART].len, scaleInx); if (partP != NULL && - partP->paramFileIndex == PARAM_CUSTOM && - paramFileIndex != PARAM_CUSTOM) + partP->paramFileIndex == PARAM_CUSTOM && + paramFileIndex != PARAM_CUSTOM) { return partP; - LOG(log_carList, 2, ("new car part: %s (%d) at %d\n", title, paramFileIndex, lookupListIndex)) + } + LOG(log_carList, 2, ("new car part: %s (%d) at %d\n", title, paramFileIndex, + lookupListIndex)) } if (partP != NULL) { CarPartUnlink(partP); - if (partP->title != NULL) + if (partP->title != NULL) { MyFree(partP->title); + } LOG(log_carList, 2, ("upd car part: %s (%d)\n", title, paramFileIndex)) } LoadRoadnameList(&tabs[T_ROADNAME], &tabs[T_REPMARK]); - parentP = CarPartParentNew(tabs[T_MANUF].ptr, tabs[T_MANUF].len, tabs[T_PROTO].ptr, tabs[T_PROTO].len, scaleInx); + parentP = CarPartParentNew(tabs[T_MANUF].ptr, tabs[T_MANUF].len, + tabs[T_PROTO].ptr, tabs[T_PROTO].len, scaleInx); cmp_key.title = title; cmp_key.parent = parentP; cmp_key.paramFileIndex = paramFileIndex; @@ -1039,9 +1093,11 @@ static carPart_p CarPartNew( cmp_key.color = color; cmp_key.partnoP = tabs[T_PART].ptr; cmp_key.partnoL = tabs[T_PART].len; - partP = (carPart_p)LookupListElem(&parentP->parts_da, &cmp_key, Cmp_part, sizeof * partP); - if (partP->title != NULL) + partP = (carPart_p)LookupListElem(&parentP->parts_da, &cmp_key, Cmp_part, + sizeof * partP); + if (partP->title != NULL) { MyFree(partP->title); + } *partP = cmp_key; sprintf(message, "\t\t%s", tabs[2].ptr); partP->title = MyStrdup(message); @@ -1052,13 +1108,15 @@ static carPart_p CarPartNew( static void CarPartDelete( - carPart_p partP ) + carPart_p partP ) { - if ( partP == NULL ) + if ( partP == NULL ) { return; + } CarPartUnlink( partP ); - if ( partP->title ) + if ( partP->title ) { MyFree( partP->title ); + } MyFree( partP ); } @@ -1090,7 +1148,7 @@ DeleteCarPart(int fileIndex) } static BOOL_T CarPartRead( - char * line ) + char * line ) { char scale[10]; long options; @@ -1101,18 +1159,21 @@ static BOOL_T CarPartRead( long longCenterOffset; if ( !GetArgs( line+8, "sqllff0lffl", - scale, &title, &options, &type, &dim.carLength, &dim.carWidth, &longCenterOffset, &dim.truckCenter, &dim.coupledLength, &rgb ) ) + scale, &title, &options, &type, &dim.carLength, &dim.carWidth, + &longCenterOffset, &dim.truckCenter, &dim.coupledLength, &rgb ) ) { return FALSE; + } dim.truckCenterOffset = longCenterOffset/1000.0; - CarPartNew( NULL, curParamFileIndex, LookupScale(scale), title, options, type, &dim, wDrawFindColor(rgb) ); + CarPartNew( NULL, curParamFileIndex, LookupScale(scale), title, options, type, + &dim, wDrawFindColor(rgb) ); MyFree( title ); return TRUE; } static BOOL_T CarPartWrite( - FILE * f, - carPart_p partP ) + FILE * f, + carPart_p partP ) { BOOL_T rc = TRUE; carPartParent_p parentP=partP->parent; @@ -1122,15 +1183,17 @@ static BOOL_T CarPartWrite( TabStringExtract( partP->title, 7, tabs ); sprintf( message, "%s\t%s\t%.*s\t%.*s\t%.*s\t%.*s\t%.*s", - parentP->manuf, parentP->proto, - tabs[T_DESC].len, tabs[T_DESC].ptr, - tabs[T_PART].len, tabs[T_PART].ptr, - tabs[T_ROADNAME].len, tabs[T_ROADNAME].ptr, - tabs[T_REPMARK].len, tabs[T_REPMARK].ptr, - tabs[T_NUMBER].len, tabs[T_NUMBER].ptr ); - rc &= fprintf( f, "CARPART %s \"%s\"", GetScaleName(partP->parent->scale), PutTitle(message) )>0; + parentP->manuf, parentP->proto, + tabs[T_DESC].len, tabs[T_DESC].ptr, + tabs[T_PART].len, tabs[T_PART].ptr, + tabs[T_ROADNAME].len, tabs[T_ROADNAME].ptr, + tabs[T_REPMARK].len, tabs[T_REPMARK].ptr, + tabs[T_NUMBER].len, tabs[T_NUMBER].ptr ); + rc &= fprintf( f, "CARPART %s \"%s\"", GetScaleName(partP->parent->scale), + PutTitle(message) )>0; rc &= fprintf( f, " %ld %ld %0.3f %0.3f 0 0 %0.3f %0.3f %ld\n", - partP->options, partP->type, partP->dim.carLength, partP->dim.carWidth, partP->dim.truckCenter, partP->dim.coupledLength, wDrawGetRGB(partP->color) )>0; + partP->options, partP->type, partP->dim.carLength, partP->dim.carWidth, + partP->dim.truckCenter, partP->dim.coupledLength, wDrawGetRGB(partP->color) )>0; SetUserLocale(); @@ -1140,7 +1203,7 @@ static BOOL_T CarPartWrite( static BOOL_T CarDescCustomSave( - FILE * f ) + FILE * f ) { int parentX; carPartParent_p parentP; @@ -1152,8 +1215,9 @@ static BOOL_T CarDescCustomSave( parentP = carPartParent(parentX); for ( partX=0; partX<parentP->parts_da.cnt; partX++ ) { partP = carPart(parentP,partX); - if ( partP->paramFileIndex == PARAM_CUSTOM ) + if ( partP->paramFileIndex == PARAM_CUSTOM ) { rc &= CarPartWrite(f, partP ); + } } } return rc; @@ -1170,54 +1234,57 @@ static dynArr_t carItemInfo_da; #define N_CONDLISTMAP (6) static nameLongMap_t condListMap[N_CONDLISTMAP] = { - { N_("N/A"), 0 }, - { N_("Mint"), 100 }, - { N_("Excellent"), 80 }, - { N_("Good"), 60 }, - { N_("Fair"), 40 }, - { N_("Poor"), 20 } }; + { N_("N/A"), 0 }, + { N_("Mint"), 100 }, + { N_("Excellent"), 80 }, + { N_("Good"), 60 }, + { N_("Fair"), 40 }, + { N_("Poor"), 20 } +}; static wIndex_t MapCondition( - long conditionValue ) + long conditionValue ) { - if ( conditionValue < 10 ) - return 0; - else if ( conditionValue < 30 ) - return 5; - else if ( conditionValue < 50 ) - return 4; - else if ( conditionValue < 70 ) - return 3; - else if ( conditionValue < 90 ) - return 2; - else - return 1; + if ( conditionValue < 10 ) { + return 0; + } else if ( conditionValue < 30 ) { + return 5; + } else if ( conditionValue < 50 ) { + return 4; + } else if ( conditionValue < 70 ) { + return 3; + } else if ( conditionValue < 90 ) { + return 2; + } else { + return 1; + } } static carItem_p CarItemNew( - carItem_p item, - int paramFileIndex, - long itemIndex, - SCALEINX_T scale, - char * title, - long options, - long type, - carDim_t *dim, - wDrawColor color, - FLOAT_T purchPrice, - FLOAT_T currPrice, - long condition, - long purchDate, - long serviceDate ) + carItem_p item, + int paramFileIndex, + long itemIndex, + SCALEINX_T scale, + char * title, + long options, + long type, + carDim_t *dim, + wDrawColor color, + FLOAT_T purchPrice, + FLOAT_T currPrice, + long condition, + long purchDate, + long serviceDate ) { carPart_p partP; tabString_t tabs[7]; TabStringExtract( title, 7, tabs ); if ( paramFileIndex != PARAM_CUSTOM ) { - partP = CarPartFind( tabs[T_MANUF].ptr, tabs[T_MANUF].len, tabs[T_PART].ptr, tabs[T_PART].len, scale ); + partP = CarPartFind( tabs[T_MANUF].ptr, tabs[T_MANUF].len, tabs[T_PART].ptr, + tabs[T_PART].len, scale ); if ( partP == NULL ) { CarPartNew( NULL, PARAM_LAYOUT, scale, title, options, type, dim, color ); } @@ -1228,8 +1295,8 @@ static carItem_p CarItemNew( item = (carItem_t*)MyMalloc( sizeof * item ); carItemInfo(carItemInfo_da.cnt-1) = item; } else { - if ( item->title ) MyFree( item->title ); - if ( item->data.number ) MyFree( item->data.number ); + if ( item->title ) { MyFree( item->title ); } + if ( item->data.number ) { MyFree( item->data.number ); } } item->index = itemIndex; item->scaleInx = scale; @@ -1241,7 +1308,9 @@ static carItem_p CarItemNew( item->dim = *dim; item->color = color; if ( tabs[T_REPMARK].len>0 || tabs[T_NUMBER].len>0 ) { - sprintf( message, "%.*s%s%.*s", tabs[T_REPMARK].len, tabs[T_REPMARK].ptr, (tabs[T_REPMARK].len>0&&tabs[T_NUMBER].len>0)?" ":"", tabs[T_NUMBER].len, tabs[T_NUMBER].ptr ); + sprintf( message, "%.*s%s%.*s", tabs[T_REPMARK].len, tabs[T_REPMARK].ptr, + (tabs[T_REPMARK].len>0 + &&tabs[T_NUMBER].len>0)?" ":"", tabs[T_NUMBER].len, tabs[T_NUMBER].ptr ); } else { sprintf( message, "#%ld", item->index ); } @@ -1261,24 +1330,25 @@ static carItem_p CarItemNew( /** * Check the whether the parameter file has CARPARTS that are a fit or compatible * with the current state. - * + * * \param paramFileIndex IN the parameter file * \param scaleIndex IN the scale to check against * \return the compatibility state of the the */ -enum paramFileState -GetCarPartCompatibility(int paramFileIndex, SCALEINX_T scaleIndex) -{ +enum paramFileState +GetCarPartCompatibility(int paramFileIndex, SCALEINX_T scaleIndex) { int i; enum paramFileState ret = PARAMFILE_NOTUSABLE; - DIST_T ratio = GetScaleRatio(scaleIndex); - DIST_T gauge = GetScaleTrackGauge(scaleIndex); +// DIST_T ratio = GetScaleRatio(scaleIndex); +// DIST_T gauge = GetScaleTrackGauge(scaleIndex); - if (!IsParamValid(paramFileIndex)) { + if (!IsParamValid(paramFileIndex)) + { return(PARAMFILE_UNLOADED); } - for (i = 0; i < carPartParent_da.cnt && ret != PARAMFILE_FIT; i++) { + for (i = 0; i < carPartParent_da.cnt && ret != PARAMFILE_FIT; i++) + { carPartParent_t *carPartParent = carPartParent( i ); SCALE_FIT_T fit = CompatibleScale(FIT_CAR,carPartParent->scale,scaleIndex); if(fit == FIT_EXACT) { @@ -1298,7 +1368,7 @@ GetCarPartCompatibility(int paramFileIndex, SCALEINX_T scaleIndex) } EXPORT BOOL_T CarItemRead( - char * line ) + char * line ) { long itemIndex; char scale[10]; @@ -1322,31 +1392,38 @@ EXPORT BOOL_T CarItemRead( char * sNote = NULL; if ( !GetArgs( line+4, "lsqll" "ff0lffl" "fflll000000c", - &itemIndex, scale, &title, &options, &type, - &dim.carLength, &dim.carWidth, &longCenterOffset, &dim.truckCenter, &dim.coupledLength, &rgb, - &purchPrice, &currPrice, &condition, &purchDate, &serviceDate, &cp ) ) + &itemIndex, scale, &title, &options, &type, + &dim.carLength, &dim.carWidth, &longCenterOffset, &dim.truckCenter, + &dim.coupledLength, &rgb, + &purchPrice, &currPrice, &condition, &purchDate, &serviceDate, &cp ) ) { return FALSE; + } dim.truckCenterOffset = longCenterOffset/1000.0; if ( paramVersion < VERSION_INLINENOTE ) { if ( (options&CAR_ITEM_HASNOTES) ) { sNote = ReadMultilineText(); } } else { - if ( !GetArgs( cp, "qc", &sNote, &cp ) ) + if ( !GetArgs( cp, "qc", &sNote, &cp ) ) { return FALSE; + } } - item = CarItemNew( NULL, curParamFileIndex, itemIndex, LookupScale(scale), title, - options&(CAR_DESC_BITS|CAR_ITEM_BITS), type, &dim, wDrawFindColor(rgb), - purchPrice, currPrice, condition, purchDate, serviceDate ); - if ( (options&CAR_ITEM_HASNOTES) ) + item = CarItemNew( NULL, curParamFileIndex, itemIndex, LookupScale(scale), + title, + options&(CAR_DESC_BITS|CAR_ITEM_BITS), type, &dim, wDrawFindColor(rgb), + purchPrice, currPrice, condition, purchDate, serviceDate ); + if ( (options&CAR_ITEM_HASNOTES) ) { item->data.notes = sNote; + } MyFree(title); if ( (options&CAR_ITEM_ONLAYOUT) ) { if ( !GetArgs( cp, "dLpf", - &index, &layer, &pos, &angle ) ) + &index, &layer, &pos, &angle ) ) { return FALSE; - if ( !ReadSegs() ) + } + if ( !ReadSegs() ) { return FALSE; + } item->car = NewCar( index, item, pos, angle ); SetTrkLayer( item->car, layer ); SetEndPts( item->car, 2 ); @@ -1357,9 +1434,9 @@ EXPORT BOOL_T CarItemRead( static BOOL_T CarItemWrite( - FILE * f, - carItem_t * item, - BOOL_T layout ) + FILE * f, + carItem_t * item, + BOOL_T layout ) { long options = (item->options&CAR_DESC_BITS); coOrd pos; @@ -1369,15 +1446,20 @@ static BOOL_T CarItemWrite( SetCLocale(); - if ( item->data.notes && item->data.notes[0] ) + if ( item->data.notes && item->data.notes[0] ) { options |= CAR_ITEM_HASNOTES; - if ( layout && item->car && !IsTrackDeleted(item->car) ) + } + if ( layout && item->car && !IsTrackDeleted(item->car) ) { options |= CAR_ITEM_ONLAYOUT; - rc &= fprintf( f, "CAR %ld %s \"%s\" %ld %ld %0.3f %0.3f 0 %ld %0.3f %0.3f %ld %0.3f %0.3f %ld %ld %ld 0 0 0 0 0 0", - item->index, GetScaleName(item->scaleInx), PutTitle(item->title), - options, item->type, - item->dim.carLength, item->dim.carWidth, longCenterOffset, item->dim.truckCenter, item->dim.coupledLength, wDrawGetRGB(item->color), - item->data.purchPrice, item->data.currPrice, item->data.condition, item->data.purchDate, item->data.serviceDate )>0; + } + rc &= fprintf( f, + "CAR %ld %s \"%s\" %ld %ld %0.3f %0.3f 0 %ld %0.3f %0.3f %ld %0.3f %0.3f %ld %ld %ld 0 0 0 0 0 0", + item->index, GetScaleName(item->scaleInx), PutTitle(item->title), + options, item->type, + item->dim.carLength, item->dim.carWidth, longCenterOffset, + item->dim.truckCenter, item->dim.coupledLength, wDrawGetRGB(item->color), + item->data.purchPrice, item->data.currPrice, item->data.condition, + item->data.purchDate, item->data.serviceDate )>0; if ( (options&CAR_ITEM_HASNOTES) ) { char * sEscapedNote = ConvertToEscapedText( item->data.notes ); rc &= fprintf( f, " \"%s\"", sEscapedNote )>0; @@ -1388,7 +1470,7 @@ static BOOL_T CarItemWrite( if ( ( options&CAR_ITEM_ONLAYOUT) ) { CarGetPos( item->car, &pos, &angle ); rc &= fprintf( f, " %d %u %0.3f %0.3f %0.3f\n", - GetTrkIndex(item->car), GetTrkLayer(item->car), pos.x, pos.y, angle )>0; + GetTrkIndex(item->car), GetTrkLayer(item->car), pos.x, pos.y, angle )>0; rc &= WriteEndPt( f, item->car, 0 ); rc &= WriteEndPt( f, item->car, 1 ); rc &= fprintf( f, "\t%s\n", END_SEGS )>0; @@ -1404,29 +1486,31 @@ static BOOL_T CarItemWrite( EXPORT carItem_p CarItemFind( - long itemInx ) + long itemInx ) { - if ( itemInx >= 0 && itemInx < carItemInfo_da.cnt ) + if ( itemInx >= 0 && itemInx < carItemInfo_da.cnt ) { return carItemInfo(itemInx); - else + } else { return NULL; + } } EXPORT long CarItemFindIndex( - carItem_p item ) + carItem_p item ) { long inx; for ( inx=0; inx<carItemInfo_da.cnt; inx++ ) - if ( carItemInfo(inx) == item ) + if ( carItemInfo(inx) == item ) { return inx; - AbortProg( "carItemFindIndex" ); + } + CHECK( FALSE ); return -1; } EXPORT void CarItemGetSegs( - carItem_p item ) + carItem_p item ) { coOrd orig; carProto_p protoP; @@ -1442,7 +1526,9 @@ EXPORT void CarItemGetSegs( segPtr = protoP->segPtr; orig = protoP->orig; } else { - CarProtoDlgCreateDummyOutline( &item->segCnt, &segPtr, (item->options&CAR_DESC_IS_LOCO)!=0, item->dim.carLength, item->dim.carWidth, item->color ); + CarProtoDlgCreateDummyOutline( &item->segCnt, &segPtr, + (item->options&CAR_DESC_IS_LOCO)!=0, item->dim.carLength, item->dim.carWidth, + item->color ); orig = zero; } item->segPtr = (trkSeg_p)MyMalloc( item->segCnt * sizeof *(segPtr) ); @@ -1452,25 +1538,27 @@ EXPORT void CarItemGetSegs( orig.x = -orig.x; orig.y = -orig.y; MoveSegs( item->segCnt, item->segPtr, orig ); - RescaleSegs( item->segCnt, item->segPtr, item->dim.carLength/protoP->size.x, item->dim.carWidth/protoP->size.y, 1/ratio ); + RescaleSegs( item->segCnt, item->segPtr, item->dim.carLength/protoP->size.x, + item->dim.carWidth/protoP->size.y, 1/ratio ); RecolorSegs( item->segCnt, item->segPtr, item->color ); } } EXPORT BOOL_T WriteCars( - FILE * f ) + FILE * f ) { int inx; BOOL_T rc = TRUE; - for ( inx=0; inx<carItemInfo_da.cnt; inx++ ) + for ( inx=0; inx<carItemInfo_da.cnt; inx++ ) { rc &= CarItemWrite( f, carItemInfo(inx), TRUE ); + } return rc; } EXPORT BOOL_T CarCustomSave( - FILE * f ) + FILE * f ) { BOOL_T rc = TRUE; rc &= CarProtoCustomSave( f ); @@ -1489,7 +1577,8 @@ static long carHotbarModes[] = { 0x0002, 0x0012, 0x0312, 0x4312, 0x0021, 0x0321, static long carHotbarContents[] = { 0x0005, 0x0002, 0x0012, 0x0012, 0x0001, 0x0021, 0x0021 }; static long newCarInx; static paramData_t newCarPLs[] = { - { PD_DROPLIST, &newCarInx, "index", PDO_DLGWIDE, I2VP(400), N_("Item") } }; + { PD_DROPLIST, &newCarInx, "index", PDO_DLGWIDE, I2VP(400), N_("Item") } +}; static paramGroup_t newCarPG = { "train-newcar", 0, newCarPLs, COUNT( newCarPLs ) }; EXPORT wControl_p newCarControls[2]; static char newCarLabel1[STR_SIZE]; @@ -1500,8 +1589,8 @@ static dynArr_t carItemHotbar_da; static int Cmp_carHotbar( - const void * ptr1, - const void * ptr2 ) + const void * ptr1, + const void * ptr2 ) { carItem_p item1 = *(carItem_p*)ptr1; carItem_p item2 = *(carItem_p*)ptr2; @@ -1517,18 +1606,22 @@ static int Cmp_carHotbar( rc = (int)(item1->index-item2->index); break; case 1: - rc = strncasecmp( tabs1[T_MANUF].ptr, tabs2[T_MANUF].ptr, max(tabs1[T_MANUF].len,tabs2[T_MANUF].len) ); + rc = strncasecmp( tabs1[T_MANUF].ptr, tabs2[T_MANUF].ptr, + max(tabs1[T_MANUF].len,tabs2[T_MANUF].len) ); break; case 3: - rc = strncasecmp( tabs1[T_PART].ptr, tabs2[T_PART].ptr, max(tabs1[T_PART].len,tabs2[T_PART].len) ); + rc = strncasecmp( tabs1[T_PART].ptr, tabs2[T_PART].ptr, max(tabs1[T_PART].len, + tabs2[T_PART].len) ); break; case 2: - if ( item1->type < item2->type ) + if ( item1->type < item2->type ) { rc = -1; - else if ( item1->type > item2->type ) + } else if ( item1->type > item2->type ) { rc = 1; - else - rc = strncasecmp( tabs1[T_PROTO].ptr, tabs2[T_PROTO].ptr, max(tabs1[T_PROTO].len,tabs2[T_PROTO].len) ); + } else { + rc = strncasecmp( tabs1[T_PROTO].ptr, tabs2[T_PROTO].ptr, + max(tabs1[T_PROTO].len,tabs2[T_PROTO].len) ); + } break; } } @@ -1537,63 +1630,66 @@ static int Cmp_carHotbar( static void CarItemHotbarUpdate( - paramGroup_p pg, - int inx, - void * data ) + paramGroup_p pg, + int inx, + void * data ) { wIndex_t carItemInx; carItem_p item; if ( inx == 0 ) { carItemInx = (wIndex_t)*(long*)data; - if ( carItemInx < 0 ) + if ( carItemInx < 0 ) { return; - carItemInx = (wIndex_t)VP2L(wListGetItemContext( (wList_p)pg->paramPtr[inx].control, carItemInx )); + } + carItemInx = (wIndex_t)VP2L(wListGetItemContext( (wList_p) + pg->paramPtr[inx].control, carItemInx )); item = carItemHotbar(carItemInx); - if ( item != NULL ) + if ( item != NULL ) { currCarItemPtr = item; + } } } static char * FormatCarTitle( - carItem_p item, - long mode ) + carItem_p item, + long mode ) { tabString_t tabs[7]; char * cp; - TabStringExtract( item->title, 7, tabs ); - cp = message; - for ( ; mode!=0; mode>>=4 ) { - switch ( mode&0x000F ) { - case 1: - cp = TabStringCpy( cp, &tabs[T_MANUF] ); - break; - case 2: - cp = TabStringCpy( cp, &tabs[T_PROTO] ); - break; - case 3: - cp = TabStringCpy( cp, &tabs[T_PART] ); - break; - case 4: - sprintf( cp, "%ld ", item->index ); - cp += strlen(cp); - break; - case 5: - strcpy( cp, typeListMap[CarProtoFindTypeCode(item->type)].name ); - cp += strlen(cp); - break; - } - *cp++ = '/'; + TabStringExtract( item->title, 7, tabs ); + cp = message; + for ( ; mode!=0; mode>>=4 ) { + switch ( mode&0x000F ) { + case 1: + cp = TabStringCpy( cp, &tabs[T_MANUF] ); + break; + case 2: + cp = TabStringCpy( cp, &tabs[T_PROTO] ); + break; + case 3: + cp = TabStringCpy( cp, &tabs[T_PART] ); + break; + case 4: + sprintf( cp, "%ld ", item->index ); + cp += strlen(cp); + break; + case 5: + strcpy( cp, typeListMap[CarProtoFindTypeCode(item->type)].name ); + cp += strlen(cp); + break; } - *--cp = '\0'; - return message; + *cp++ = '/'; + } + *--cp = '\0'; + return message; } EXPORT char * CarItemDescribe( - carItem_p item, - long mode, - long * index ) + carItem_p item, + long mode, + long * index ) { tabString_t tabs[7]; char * cp; @@ -1605,15 +1701,18 @@ EXPORT char * CarItemDescribe( sprintf( cp, "%ld ", item->index ); cp = desc+strlen(cp); } - if ( (mode&0xF)!=1 && ((mode>>4)&0xF)!=1 && ((mode>>8)&0xF)!=1 && ((mode>>12)&0xF)!=1 ) { + if ( (mode&0xF)!=1 && ((mode>>4)&0xF)!=1 && ((mode>>8)&0xF)!=1 + && ((mode>>12)&0xF)!=1 ) { cp = TabStringCpy( cp, &tabs[T_MANUF] ); *cp++ = ' '; } - if ( (mode&0xF)!=3 && ((mode>>4)&0xF)!=3 && ((mode>>8)&0xF)!=3 && ((mode>>12)&0xF)!=3 ) { + if ( (mode&0xF)!=3 && ((mode>>4)&0xF)!=3 && ((mode>>8)&0xF)!=3 + && ((mode>>12)&0xF)!=3 ) { cp = TabStringCpy( cp, &tabs[T_PART] ); *cp++ = ' '; } - if ( (mode&0xF)!=2 && ((mode>>4)&0xF)!=2 && ((mode>>8)&0xF)!=2 && ((mode>>12)&0xF)!=2 ) { + if ( (mode&0xF)!=2 && ((mode>>4)&0xF)!=2 && ((mode>>8)&0xF)!=2 + && ((mode>>12)&0xF)!=2 ) { cp = TabStringCpy( cp, &tabs[T_PROTO] ); *cp++ = ' '; } @@ -1635,8 +1734,9 @@ EXPORT char * CarItemDescribe( } } *--cp = '\0'; - if ( index != NULL ) + if ( index != NULL ) { *index = item->index; + } return desc; } @@ -1649,12 +1749,14 @@ EXPORT void CarItemLoadList( void * unused ) wWinPix_t w, h; DYNARR_SET( carItem_t*, carItemHotbar_da, carItemInfo_da.cnt ); - memcpy( carItemHotbar_da.ptr, carItemInfo_da.ptr, carItemInfo_da.cnt * sizeof item ); + memcpy( &carItemHotbar(0), &carItemInfo(0), + carItemInfo_da.cnt * sizeof carItemHotbar(0) ); wListClear( (wList_p)newCarPLs[0].control ); for ( inx=0; inx<carItemHotbar_da.cnt; inx++ ) { item = carItemHotbar(inx); - if ( item->car && !IsTrackDeleted(item->car) ) + if ( item->car && !IsTrackDeleted(item->car) ) { continue; + } cp = CarItemDescribe( item, 0, NULL ); wListAddValue( (wList_p)newCarPLs[0].control, cp, NULL, I2VP(inx) ); } @@ -1665,16 +1767,18 @@ EXPORT void CarItemLoadList( void * unused ) InfoSubstituteControls( newCarControls, newCarLabels ); wWinGetSize( mainW, &w, &h ); w -= wControlGetPosX( newCarControls[0] ) + 4; - if ( w > 20 ) - wListSetSize( (wList_p)newCarControls[0], w, wControlGetHeight( newCarControls[0] ) ); + if ( w > 20 ) { + wListSetSize( (wList_p)newCarControls[0], w, + wControlGetHeight( newCarControls[0] ) ); + } } static char * CarItemHotbarProc( - hotBarProc_e op, - void * data, - drawCmd_p d, - coOrd * origP ) + hotBarProc_e op, + void * data, + drawCmd_p d, + coOrd * origP ) { wIndex_t carItemInx = (wIndex_t)VP2L(data); carItem_p item; @@ -1684,8 +1788,9 @@ static char * CarItemHotbarProc( wWinPix_t w, h; item = carItemHotbar(carItemInx); - if ( item == NULL ) + if ( item == NULL ) { return NULL; + } switch ( op ) { case HB_SELECT: currCarItemPtr = item; @@ -1693,11 +1798,13 @@ static char * CarItemHotbarProc( if ( (mode&0xF000) == 0 ) { wListClear( (wList_p)newCarPLs[0].control ); for ( inx=carItemInx; - inx<carItemHotbar_da.cnt && ( inx==carItemInx || Cmp_carHotbar(&carItemHotbar(carItemInx),&carItemHotbar(inx))==0 ); - inx++ ) { + inx<carItemHotbar_da.cnt && ( inx==carItemInx + || Cmp_carHotbar(&carItemHotbar(carItemInx),&carItemHotbar(inx))==0 ); + inx++ ) { item = carItemHotbar(inx); - if ( item->car && !IsTrackDeleted(item->car) ) + if ( item->car && !IsTrackDeleted(item->car) ) { continue; + } cp = CarItemDescribe( item, mode, NULL ); wListAddValue( (wList_p)newCarPLs[0].control, cp, NULL, I2VP(inx) ); } @@ -1711,8 +1818,10 @@ static char * CarItemHotbarProc( InfoSubstituteControls( newCarControls, newCarLabels ); wWinGetSize( mainW, &w, &h ); w -= wControlGetPosX( newCarControls[0] ) + 4; - if ( w > 20 ) - wListSetSize( (wList_p)newCarControls[0], w, wControlGetHeight( newCarControls[0] ) ); + if ( w > 20 ) { + wListSetSize( (wList_p)newCarControls[0], w, + wControlGetHeight( newCarControls[0] ) ); + } } else { InfoSubstituteControls( NULL, NULL ); cp = CarItemDescribe( item, 0, NULL ); @@ -1725,9 +1834,11 @@ static char * CarItemHotbarProc( case HB_FULLTITLE: return item->title; case HB_DRAW: - if ( item->segCnt == 0 ) + if ( item->segCnt == 0 ) { CarItemGetSegs( item ); - DrawSegs( d, *origP, 0.0, item->segPtr, item->segCnt, trackGauge, wDrawColorBlack ); + } + DrawSegs( d, *origP, 0.0, item->segPtr, item->segCnt, trackGauge, + wDrawColorBlack ); return NULL; } return NULL; @@ -1741,8 +1852,10 @@ EXPORT int CarAvailableCount( void ) carItem_t * item; for ( inx=0; inx < carItemHotbar_da.cnt; inx ++ ) { item = carItemHotbar(inx); - if (FIT_NONE == CompatibleScale( FIT_CAR, item->scaleInx, GetLayoutCurScale())) + if (FIT_NONE == CompatibleScale( FIT_CAR, item->scaleInx, + GetLayoutCurScale())) { continue; + } cnt++; } return cnt; @@ -1757,15 +1870,20 @@ EXPORT void AddHotBarCarDesc( void ) coOrd size; DYNARR_SET( carItem_t*, carItemHotbar_da, carItemInfo_da.cnt ); - memcpy( carItemHotbar_da.ptr, carItemInfo_da.ptr, carItemInfo_da.cnt * sizeof item0 ); - qsort( carItemHotbar_da.ptr, carItemHotbar_da.cnt, sizeof item0, Cmp_carHotbar ); + memcpy( &carItemHotbar(0), &carItemInfo(0), + carItemInfo_da.cnt * sizeof carItemHotbar(0) ); + qsort( &carItemHotbar(0), carItemHotbar_da.cnt, sizeof carItemHotbar(0), + Cmp_carHotbar ); for ( inx=0,item0=NULL; inx < carItemHotbar_da.cnt; inx ++ ) { item1 = carItemHotbar(inx); - if ( item1->car && !IsTrackDeleted(item1->car) ) + if ( item1->car && !IsTrackDeleted(item1->car) ) { continue; - if ( FIT_NONE == CompatibleScale(FIT_CAR,item1->scaleInx,GetLayoutCurScale())) + } + if ( FIT_NONE == CompatibleScale(FIT_CAR,item1->scaleInx,GetLayoutCurScale())) { continue; - if ( (carHotbarModes[carHotbarModeInx]&0xF000)!=0 || ( item0 == NULL || Cmp_carHotbar( &item0, &item1 ) != 0 ) ) { + } + if ( (carHotbarModes[carHotbarModeInx]&0xF000)!=0 || ( item0 == NULL + || Cmp_carHotbar( &item0, &item1 ) != 0 ) ) { #ifdef DESCFIX orig.x = - item->orig.x; orig.y = - item->orig.y; @@ -1773,7 +1891,9 @@ EXPORT void AddHotBarCarDesc( void ) orig = zero; size.x = item1->dim.carLength; size.y = item1->dim.carWidth; - AddHotBarElement( FormatCarTitle( item1, carHotbarContents[carHotbarModeInx] ), size, orig, FALSE, FALSE, (60.0*12.0/curScaleRatio), I2VP(inx), CarItemHotbarProc ); + AddHotBarElement( FormatCarTitle( item1, carHotbarContents[carHotbarModeInx] ), + size, orig, FALSE, FALSE, (60.0*12.0/curScaleRatio), I2VP(inx), + CarItemHotbarProc ); } item0 = item1; } @@ -1781,26 +1901,30 @@ EXPORT void AddHotBarCarDesc( void ) EXPORT void CarItemFindCouplerMountPoint( - carItem_p item, - traverseTrack_t trvTrk0, - coOrd pos[2] ) + carItem_p item, + traverseTrack_t trvTrk0, + coOrd pos[2] ) { // We assume the coupler pivot is 'couplerLength' before the end of the car DIST_T couplerLength = (item->dim.coupledLength - item->dim.carLength) / 2.0; if ( IsClose(item->dim.truckCenter) ) { // Single truck/bogie DIST_T d = item->dim.carLength/2.0 - couplerLength; - Translate( &pos[0], trvTrk0.pos, trvTrk0.angle, d + item->dim.truckCenterOffset ); + Translate( &pos[0], trvTrk0.pos, trvTrk0.angle, + d + item->dim.truckCenterOffset ); FlipTraverseTrack( &trvTrk0 ); - Translate( &pos[1], trvTrk0.pos, trvTrk0.angle, d - item->dim.truckCenterOffset ); + Translate( &pos[1], trvTrk0.pos, trvTrk0.angle, + d - item->dim.truckCenterOffset ); return; } // Find the pos of the 2 trucks // Note this is a slight simplification, we should use the car center, not the on-track position traverseTrack_t trvTrk1 = trvTrk0; - TraverseTrack2( &trvTrk0, item->dim.truckCenter/2.0 + item->dim.truckCenterOffset ); + TraverseTrack2( &trvTrk0, + item->dim.truckCenter/2.0 + item->dim.truckCenterOffset ); FlipTraverseTrack( & trvTrk1 ); - TraverseTrack2( &trvTrk1, item->dim.truckCenter/2.0 - item->dim.truckCenterOffset ); + TraverseTrack2( &trvTrk1, + item->dim.truckCenter/2.0 - item->dim.truckCenterOffset ); // Get the angle to translate from the truck ANGLE_T angle[2]; @@ -1818,111 +1942,143 @@ EXPORT void CarItemFindCouplerMountPoint( // Get the distance to translate DIST_T d[2]; - d[0] = item->dim.carLength/2.0 - couplerLength - ( item->dim.truckCenter/2.0 + item->dim.truckCenterOffset ); - d[1] = item->dim.carLength/2.0 - couplerLength - ( item->dim.truckCenter/2.0 - item->dim.truckCenterOffset ); + d[0] = item->dim.carLength/2.0 - couplerLength - ( item->dim.truckCenter/2.0 + + item->dim.truckCenterOffset ); + d[1] = item->dim.carLength/2.0 - couplerLength - ( item->dim.truckCenter/2.0 - + item->dim.truckCenterOffset ); // And translate Translate( &pos[0], trvTrk0.pos, angle[0], d[0] ); Translate( &pos[1], trvTrk1.pos, angle[1], d[1] ); - + #ifdef LATER if ( trvTrk.trk == NULL || (item->options&CAR_DESC_COUPLER_MODE_BODY)!=0 ) { couplerOffset = item->dim.coupledLength/2.0; Translate( &pos, trvTrk.pos, trvTrk.angle, couplerOffset ); } else { - if (dir) - TraverseTrack2( &trvTrk, item->dim.truckCenter/2.0-item->dim.truckCenterOffset ); - else - TraverseTrack2( &trvTrk, item->dim.truckCenter/2.0+item->dim.truckCenterOffset ); + if (dir) { + TraverseTrack2( &trvTrk, + item->dim.truckCenter/2.0-item->dim.truckCenterOffset ); + } else { + TraverseTrack2( &trvTrk, + item->dim.truckCenter/2.0+item->dim.truckCenterOffset ); + } /*Translate( &pos1, trvTrk.pos, trvTrk.angle, item->dim.truckCenter/2.0 );*/ couplerOffset = (item->dim.coupledLength-item->dim.truckCenter)/2.0; - if (dir) + if (dir) { couplerOffset = couplerOffset + item->dim.truckCenterOffset; - else + } else { couplerOffset = couplerOffset - item->dim.truckCenterOffset; + } Translate( &pos, trvTrk.pos, trvTrk.angle, couplerOffset ); } #endif } +EXPORT void CarItemPos( + carItem_p item, + coOrd * pos ) +{ + pos->x = item->pos.x; + pos->y = item->pos.y; +} + + EXPORT void CarItemSize( - carItem_p item, - coOrd * size ) + carItem_p item, + coOrd * size ) { size->x = item->dim.carLength; size->y = item->dim.carWidth; } +EXPORT void CarItemSetNumber(carItem_p item, char * number) +{ + if (item->data.number && number[0]) { + MyFree(item->data.number); + } + if (number[0]) { + item->data.number = MyStrdup(number); + } +} + EXPORT char * CarItemNumber( - carItem_p item ) + carItem_p item ) { return item->data.number; } + + static DIST_T CarItemTruckCenter( - carItem_p item ) + carItem_p item ) { return item->dim.truckCenter; } static DIST_T CarItemTruckOffset( - carItem_p item ) { - return item->dim.truckCenterOffset; + carItem_p item ) +{ + return item->dim.truckCenterOffset; } EXPORT DIST_T CarItemCoupledLength( - carItem_p item ) + carItem_p item ) { return item->dim.coupledLength; } EXPORT BOOL_T CarItemIsLoco( - carItem_p item ) + carItem_p item ) { return (item->options&CAR_DESC_IS_LOCO) == (CAR_DESC_IS_LOCO); } EXPORT BOOL_T CarItemIsLocoMaster( - carItem_p item ) + carItem_p item ) { - return (item->options&(CAR_DESC_IS_LOCO|CAR_DESC_IS_LOCO_MASTER)) == (CAR_DESC_IS_LOCO|CAR_DESC_IS_LOCO_MASTER); + return (item->options&(CAR_DESC_IS_LOCO|CAR_DESC_IS_LOCO_MASTER)) == + (CAR_DESC_IS_LOCO|CAR_DESC_IS_LOCO_MASTER); } EXPORT void CarItemSetLocoMaster( - carItem_p item, - BOOL_T locoIsMaster ) + carItem_p item, + BOOL_T locoIsMaster ) { - if ( locoIsMaster ) + if ( locoIsMaster ) { item->options |= CAR_DESC_IS_LOCO_MASTER; - else + } else { item->options &= ~CAR_DESC_IS_LOCO_MASTER; + } } EXPORT void CarItemSetTrack( - carItem_p item, - track_p trk ) + carItem_p item, + track_p trk ) { item->car = trk; - if ( trk != NULL ) + if ( trk != NULL ) { SetTrkScale( trk, item->scaleInx ); + } } static DIST_T CarItemCouplerLength( - carItem_p item, - int dir ) + carItem_p item, + int dir ) { return item->dim.coupledLength-item->dim.carLength; } -EXPORT BOOL_T StoreCarItem (carItem_p item, void **data,long *len) { +EXPORT BOOL_T StoreCarItem (carItem_p item, void **data,long *len) +{ *data = item; *len = sizeof (carItem_t); @@ -1930,7 +2086,8 @@ EXPORT BOOL_T StoreCarItem (carItem_p item, void **data,long *len) { } -EXPORT BOOL_T ReplayCarItem(carItem_p item, void *data,long len) { +EXPORT BOOL_T ReplayCarItem(carItem_p item, void *data,long len) +{ item->pos = ((carItem_t *)data)->pos; @@ -1940,54 +2097,39 @@ EXPORT BOOL_T ReplayCarItem(carItem_p item, void *data,long len) { } EXPORT void CarItemPlace( - carItem_p item, - traverseTrack_p trvTrk, - DIST_T * dists ) + carItem_p item, + traverseTrack_p trvTrk, + DIST_T * dists ) { DIST_T dist; DIST_T offset; traverseTrack_t trks[2]; dist = CarItemTruckCenter(item)/2.0; - offset = CarItemTruckOffset(item); //Offset is the amount the truck centers are displaced + offset = CarItemTruckOffset( + item); //Offset is the amount the truck centers are displaced trks[0] = trks[1] = *trvTrk; TraverseTrack2( &trks[0], dist+offset ); TraverseTrack2( &trks[1], -dist+offset ); item->angle = FindAngle( trks[1].pos, trks[0].pos ); item->pos.x = (trks[0].pos.x+trks[1].pos.x)/2.0; item->pos.y = (trks[0].pos.y+trks[1].pos.y)/2.0; - Translate(&item->pos,item->pos,item->angle, -offset); // Put truck center back along line by offset + Translate(&item->pos,item->pos,item->angle, + -offset); // Put truck center back along line by offset dists[0] = dists[1] = CarItemCoupledLength(item)/2.0; } -static dynArr_t clearance; - -static void ClearClearancePoints(void) { - //DYNARR_RESET(trkSeg_t,clearance); -} - -static void CreateClearancePoint(coOrd pos, int position) { - //DYNARR_APPEND(trkSeg_t,clearance,1); - -} - -static void DrawClearancePoints(void) { - //for (int i=0;i<clearance.cnt;i++) { - //DrawSegs(); - //} -} - static int drawCarTrucks = 0; EXPORT void CarItemDraw( - drawCmd_p d, - carItem_p item, - wDrawColor color, - int direction, - BOOL_T locoIsMaster, - vector_t *coupler, - BOOL_T pencils, - track_p traverse) + drawCmd_p d, + carItem_p item, + wDrawColor color, + int direction, + BOOL_T locoIsMaster, + vector_t *coupler, + BOOL_T pencils, + track_p traverse) { coOrd size, pos, pos2; DIST_T length; @@ -1996,12 +2138,11 @@ EXPORT void CarItemDraw( trkSeg_t simpleSegs[1]; pts_t simplePts[4]; int dir; - DIST_T rad; +// DIST_T rad; static int couplerLineWidth = 3; - DIST_T scale2rail; CarItemSize( item, &size ); - if ( d->scale >= ((d->options&DC_PRINT)?(twoRailScale*2+1):twoRailScale) ) { + if ( !DrawTwoRails( d, 1 ) ) { simplePts[0].pt.x = simplePts[3].pt.x = -size.x/2.0; simplePts[1].pt.x = simplePts[2].pt.x = size.x/2.0; simplePts[0].pt.y = simplePts[1].pt.y = -size.y/2.0; @@ -2012,52 +2153,23 @@ EXPORT void CarItemDraw( simplePts[3].pt_type = 0; simpleSegs[0].type = SEG_FILPOLY; simpleSegs[0].color = item->color; - simpleSegs[0].width = 0; + simpleSegs[0].lineWidth = 0; simpleSegs[0].u.p.cnt = 4; simpleSegs[0].u.p.pts = simplePts; simpleSegs[0].u.p.orig = zero; simpleSegs[0].u.p.angle = 0.0; DrawSegs( d, item->pos, item->angle-90.0, simpleSegs, 1, 0.0, color ); } else { - if ( item->segCnt == 0 ) + if ( item->segCnt == 0 ) { CarItemGetSegs( item ); + } Translate( &pos, item->pos, item->angle, -size.x/2.0 ); Translate( &pos, pos, item->angle-90, -size.y/2.0 ); DrawSegs( d, pos, item->angle-90.0, item->segPtr, item->segCnt, 0.0, color ); } if (pencils) { - ClearClearancePoints(); - coOrd posm1,posm2; - Translate( &posm1, item->pos, item->angle-90, -size.y/2.0 ); - Translate( &posm2, item->pos, item->angle+90, -size.y/2.0 ); - coOrd posm1a = posm1; - coOrd posm2a = posm2; - if (GetTrkDistance(traverse, &posm1a)>GetTrkDistance(traverse, &posm2a)) - CreateClearancePoint(posm1,1); - else - CreateClearancePoint(posm2,2); - - coOrd pose1,pose2; - Translate( &pose1, item->pos, item->angle, size.x/2.0 ); - Translate( &pose1, pose1, item->angle-90, -size.y/2.0 ); - Translate( &pose2, pose1, item->angle+90, -size.y ); - - traverseTrack_t traverseTrk; - traverseTrk.trk = traverse; - traverseTrk.pos = item->pos; - traverseTrk.angle = item->angle; - TraverseTrack2(&traverseTrk,size.x/2.0); - coOrd pose1a = pose1; - coOrd pose2a = pose2; - if (GetTrkDistance(traverseTrk.trk, &pose1a)>GetTrkDistance(traverseTrk.trk, &pose2a)) - CreateClearancePoint(pose1,3); - else - CreateClearancePoint(pose2,4); - - - DrawClearancePoints(); - +// No code for pencils } if ( drawCarTrucks ) { @@ -2066,36 +2178,41 @@ EXPORT void CarItemDraw( double offset = CarItemTruckOffset(item); Translate( &pos, item->pos, item->angle, length+(direction?offset:-offset) ); DrawArc( d, pos, trackGauge/2.0, 0.0, 360.0, FALSE, 0, color ); - Translate( &pos, item->pos, item->angle+180, length+(direction?-offset:offset) ); + Translate( &pos, item->pos, item->angle+180, + length+(direction?-offset:offset) ); DrawArc( d, pos, trackGauge/2.0, 0.0, 360.0, FALSE, 0, color ); } if ( (labelEnable&LABELENABLE_CARS) ) { fp = wStandardFont( F_HELV, FALSE, FALSE ); - DrawBoxedString( BOX_BACKGROUND, d, item->pos, item->data.number, fp, (wFontSize_t)descriptionFontSize, color, 0.0 ); + DrawBoxedString( BOX_BACKGROUND, d, item->pos, item->data.number, fp, + (wFontSize_t)descriptionFontSize, color, 0.0 ); } /* draw loco head light */ if ( (item->options&CAR_DESC_IS_LOCO)!=0 ) { - Translate( &pos, item->pos, item->angle+(direction?180.0:0.0), size.x/2.0-trackGauge/2.0 ); + Translate( &pos, item->pos, item->angle+(direction?180.0:0.0), + size.x/2.0-trackGauge/2.0 ); if ( locoIsMaster ) { - DrawFillCircle( d, pos, trackGauge/2.0, (color==wDrawColorBlack?drawColorGold:color) ); + DrawFillCircle( d, pos, trackGauge/2.0, + (color==wDrawColorBlack?drawColorGold:color) ); } else { width = (wDrawWidth)floor( trackGauge/8.0 * d->dpi / d->scale ); - DrawArc( d, pos, trackGauge/2.0, 0.0, 360.0, FALSE, width, (color==wDrawColorBlack?drawColorGold:color) ); + DrawArc( d, pos, trackGauge/2.0, 0.0, 360.0, FALSE, width, + (color==wDrawColorBlack?drawColorGold:color) ); } } /* draw coupler */ - scale2rail = ((d->options&DC_PRINT)?(twoRailScale*2+1):twoRailScale); - if ( d->scale >= scale2rail ) + if ( ! DrawTwoRails(d,0.5) ) { return; - scale2rail /= 2; - rad = trackGauge/8.0; + } +// rad = trackGauge/8.0; for ( dir=0; dir<2; dir++ ) { - Translate( &pos, coupler[dir].pos, coupler[dir].angle, CarItemCouplerLength(item,dir) ); + Translate( &pos, coupler[dir].pos, coupler[dir].angle, + CarItemCouplerLength(item,dir) ); DrawLine( d, coupler[dir].pos, pos, couplerLineWidth, color ); - if ( d->scale < scale2rail ) { + if ( DrawTwoRails(d,1) ) { /*DrawFillCircle( d, p0, rad, dir==0?color:selectedColor );*/ Translate( &pos2, pos, coupler[dir].angle+90.0, trackGauge/3 ); DrawLine( d, pos2, pos, couplerLineWidth, color ); @@ -2105,7 +2222,7 @@ EXPORT void CarItemDraw( EXPORT void CarItemUpdate( - carItem_p item ) + carItem_p item ) { DoChangeNotification( CHANGE_SCALE ); } @@ -2129,9 +2246,10 @@ static wIndex_t carDlgManufInx; static char carDlgManufStr[STR_SIZE]; static wIndex_t carDlgKindInx; static wIndex_t carDlgProtoInx; -static char carDlgProtoStr[STR_SIZE]; +static char carDlgProtoStr[STR_SIZE] = + "Prototype"; // Make sure we have something in ProtoStr static wIndex_t carDlgPartnoInx; -static char carDlgPartnoStr[STR_SIZE]; +static char carDlgPartnoStr[STR_SIZE] = "0"; // and in PartnoStr static char carDlgDescStr[STR_SIZE]; static long carDlgDispMode; @@ -2163,17 +2281,18 @@ static long carDlgMultiNum; static char *dispmodeLabels[] = { N_("Information"), N_("Customize"), NULL }; static drawCmd_t carDlgD = { - NULL, - &screenDrawFuncs, - 0, - 1.0, - 0.0, - { 0, 0 }, { 0, 0 }, - Pix2CoOrd, CoOrd2Pix }; + NULL, + &screenDrawFuncs, + 0, + 1.0, + 0.0, + { 0, 0 }, { 0, 0 }, + Pix2CoOrd, CoOrd2Pix +}; static void CarDlgRedraw( wDraw_p d, void * context, wWinPix_t x, wWinPix_t y ); -static paramDrawData_t carDlgDrawData = { 455, 100, CarDlgRedraw, NULL, &carDlgD }; -static paramTextData_t notesData = { 440, 100 }; +static paramDrawData_t carDlgDrawData = { 500, 120, CarDlgRedraw, NULL, &carDlgD }; +static paramTextData_t notesData = { 500, 156 }; static char *multinumLabels[] = { N_("Sequential"), N_("Repeated"), NULL }; static void CarDlgNewProto( void ); static void CarDlgUpdate( paramGroup_p, int, void * ); @@ -2254,7 +2373,7 @@ static paramData_t carDlgPLs[] = { #define I_CD_MLTNUM (C+7) { PD_RADIO, &carDlgMultiNum, "multinum", PDO_NOPREF|PDO_DLGWIDE|PDO_DLGHORZ, multinumLabels, N_("Numbers"), BC_HORZ|BC_NOBORDER }, #define I_CD_NOTES (C+8) - { PD_TEXT, NULL, "notes", PDO_NOPREF|PDO_DLGWIDE|PDO_DLGNOLABELALIGN|PDO_DLGRESETMARGIN, ¬esData, N_("Notes") }, + { PD_TEXT, NULL, "notes", PDO_NOPREF|PDO_DLGWIDE|PDO_DLGNOLABELALIGN|PDO_DLGRESETMARGIN|PDO_DLGRESIZE, ¬esData, N_("Notes") }, #define D (C+9) #define I_CD_MSG (D+0) @@ -2264,7 +2383,8 @@ static paramData_t carDlgPLs[] = { { PD_MENUITEM, CarDlgNewDesc, "new-part-mi", 0, NULL, N_("Car Part"), 0, I2VP(0) }, { PD_MENUITEM, CarDlgNewProto, "new-proto-mi", 0, NULL, N_("Car Prototype"), 0, I2VP(0) }, #define I_CD_NEWPROTO (D+4) - { PD_BUTTON, CarDlgNewProto, "new", PDO_DLGCMDBUTTON, NULL, N_("New"), 0, I2VP(0) } }; + { PD_BUTTON, CarDlgNewProto, "new", PDO_DLGCMDBUTTON, NULL, N_("New"), 0, I2VP(0) } +}; static paramGroup_t carDlgPG = { "carpart", 0, carDlgPLs, COUNT( carDlgPLs ) }; @@ -2274,151 +2394,163 @@ static dynArr_t carDlgSegs_da; typedef enum { - T_ItemSel, T_ItemEnter, T_ProtoSel, T_ProtoEnter, T_PartnoSel, T_PartnoEnter } carDlgTransistion_e; + T_ItemSel, T_ItemEnter, T_ProtoSel, T_ProtoEnter, T_PartnoSel, T_PartnoEnter +} carDlgTransistion_e; static char *carDlgTransistion_s[] = { - "ItemSel", "ItemEnter", "ProtoSel", "ProtoEnter", "PartnoSel", "PartnoEnter" }; + "ItemSel", "ItemEnter", "ProtoSel", "ProtoEnter", "PartnoSel", "PartnoEnter" +}; typedef enum { - S_Error, - S_ItemSel, S_ItemEnter, S_PartnoSel, S_PartnoEnter, S_ProtoSel } carDlgState_e; + S_Error, + S_ItemSel, S_ItemEnter, S_PartnoSel, S_PartnoEnter, S_ProtoSel +} carDlgState_e; static char *carDlgState_s[] = { - "Error", - "ItemSel", "ItemEnter", "PartnoSel", "PartnoEnter", "ProtoSel" }; + "Error", + "ItemSel", "ItemEnter", "PartnoSel", "PartnoEnter", "ProtoSel" +}; typedef enum { - A_Return, - A_SError, - A_Else, - A_SItemSel, - A_SItemEnter, - A_SPartnoSel, - A_SPartnoEnter, - A_SProtoSel, - A_IsCustom, - A_IsNewPart, - A_IsNewProto, - A_LoadDataFromPartList, - A_LoadDimsFromStack, - A_LoadManufListForScale, - A_LoadManufListAll, - A_LoadProtoListForManuf, - A_LoadProtoListAll, - A_LoadPartnoList, - A_LoadLists, - A_LoadDimsFromProtoList, - A_ConvertDimsToProto, - A_Redraw, - A_ClrManuf, - A_ClrPartnoStr, - A_ClrNumberStr, - A_LoadProtoStrFromList, - A_ShowPartnoList, - A_HidePartnoList, - A_PushDims, - A_PopDims, - A_PopTitleAndTypeinx, - A_PopCouplerLength, - A_ShowControls, - A_LoadInfoFromUpdateItem, - A_LoadDataFromUpdatePart, - A_InitProto, - A_RecallCouplerLength, - A_Last - } carDlgAction_e; + A_Return, + A_SError, + A_Else, + A_SItemSel, + A_SItemEnter, + A_SPartnoSel, + A_SPartnoEnter, + A_SProtoSel, + A_IsCustom, + A_IsNewPart, + A_IsNewProto, + A_LoadDataFromPartList, + A_LoadDimsFromStack, + A_LoadManufListForScale, + A_LoadManufListAll, + A_LoadProtoListForManuf, + A_LoadProtoListAll, + A_LoadPartnoList, + A_LoadLists, + A_LoadDimsFromProtoList, + A_ConvertDimsToProto, + A_Redraw, + A_ClrManuf, + A_ClrPartnoStr, + A_ClrNumberStr, + A_LoadProtoStrFromList, + A_ShowPartnoList, + A_HidePartnoList, + A_PushDims, + A_PopDims, + A_PopTitleAndTypeinx, + A_PopCouplerLength, + A_ShowControls, + A_LoadInfoFromUpdateItem, + A_LoadDataFromUpdatePart, + A_InitProto, + A_RecallCouplerLength, + A_Last +} carDlgAction_e; static char *carDlgAction_s[] = { - "Return", - "SError", - "Else", - "SItemSel", - "SItemEnter", - "SPartnoSel", - "SPartnoEnter", - "SProtoSel", - "IsCustom", - "IsNewPart", - "IsNewProto", - "LoadDataFromPartList", - "LoadDimsFromStack", - "LoadManufListForScale", - "LoadManufListAll", - "LoadProtoListForManuf", - "LoadProtoListAll", - "LoadPartnoList", - "LoadLists", - "LoadDimsFromProtoList", - "ConvertDimsToProto", - "Redraw", - "ClrManuf", - "ClrPartnoStr", - "ClrNumberStr", - "LoadProtoStrFromList", - "ShowPartnoList", - "HidePartnoList", - "PushDims", - "PopDims", - "PopTitleAndTypeinx", - "PopCouplerLength", - "ShowControls", - "LoadInfoFromUpdateItem", - "LoadDataFromUpdatePart", - "InitProto", - "RecallCouplerLength", - "Last" - }; + "Return", + "SError", + "Else", + "SItemSel", + "SItemEnter", + "SPartnoSel", + "SPartnoEnter", + "SProtoSel", + "IsCustom", + "IsNewPart", + "IsNewProto", + "LoadDataFromPartList", + "LoadDimsFromStack", + "LoadManufListForScale", + "LoadManufListAll", + "LoadProtoListForManuf", + "LoadProtoListAll", + "LoadPartnoList", + "LoadLists", + "LoadDimsFromProtoList", + "ConvertDimsToProto", + "Redraw", + "ClrManuf", + "ClrPartnoStr", + "ClrNumberStr", + "LoadProtoStrFromList", + "ShowPartnoList", + "HidePartnoList", + "PushDims", + "PopDims", + "PopTitleAndTypeinx", + "PopCouplerLength", + "ShowControls", + "LoadInfoFromUpdateItem", + "LoadDataFromUpdatePart", + "InitProto", + "RecallCouplerLength", + "Last" +}; static carDlgAction_e stateMachine[7][7][10] = { -/* A_SError */{ {A_SError}, {A_SError}, {A_SError}, {A_SError}, {A_SError}, {A_SError}, {A_SError} }, - -/*A_SItemSel*/{ -/*T_ItemSel*/ { A_LoadProtoListForManuf, A_LoadPartnoList, A_LoadDataFromPartList, A_Redraw }, -/*T_ItemEnter*/ { A_SItemEnter, A_LoadProtoListAll, A_ClrPartnoStr, A_ClrNumberStr, A_LoadDimsFromProtoList, A_Redraw, A_HidePartnoList }, -/*T_ProtoSel*/ { A_LoadPartnoList, A_LoadDataFromPartList, A_Redraw }, -/*T_ProtoEnter*/ { A_SError }, -/*T_PartnoSel*/ { A_LoadDataFromPartList, A_Redraw }, -/*T_PartnoEnter*/{ A_SItemEnter, A_LoadProtoListAll, A_HidePartnoList } }, - -/*A_SItemEnter*/{ -/*T_ItemSel*/ { A_SItemSel, A_LoadProtoListForManuf, A_LoadPartnoList, A_LoadDataFromPartList, A_Redraw, A_ShowPartnoList }, -/*T_ItemEnter*/ { A_Return }, -/*T_ProtoSel*/ { A_LoadDimsFromProtoList, A_Redraw }, -/*T_ProtoEnter*/ { A_SError }, -/*T_PartnoSel*/ { A_SError }, -/*T_PartnoEnter*/{ A_Return } }, - -/*A_SPartnoSel*/{ -/*T_ItemSel*/ { A_SPartnoSel }, -/*T_ItemEnter*/ { A_SPartnoSel }, -/*T_ProtoSel*/ { A_SPartnoSel, A_LoadDimsFromProtoList, A_Redraw }, -/*T_ProtoEnter*/ { A_SError }, -/*T_PartnoSel*/ { A_SError } }, - -/*A_SPartnoEnter*/{ -/*T_ItemSel*/ { A_SPartnoSel }, -/*T_ItemEnter*/ { A_SPartnoEnter }, -/*T_ProtoSel*/ { A_SPartnoEnter, A_LoadDimsFromProtoList, A_Redraw }, -/*T_ProtoEnter*/ { A_SError }, -/*T_PartnoSel*/ { A_SError }, -/*T_PartnoEnter*/{ A_SPartnoEnter } }, - -/*A_SProtoSel*/{ -/*T_ItemSel*/ { A_SError }, -/*T_ItemEnter*/ { A_SError }, -/*T_ProtoSel*/ { A_SError }, -/*T_ProtoEnter*/ { A_SProtoSel }, -/*T_PartnoSel*/ { A_SError }, -/*T_PartnoEnter*/{ A_SError } } }; + /* A_SError */{ {A_SError}, {A_SError}, {A_SError}, {A_SError}, {A_SError}, {A_SError}, {A_SError} }, + + /*A_SItemSel*/{ + /*T_ItemSel*/ { A_LoadProtoListForManuf, A_LoadPartnoList, A_LoadDataFromPartList, A_Redraw }, + /*T_ItemEnter*/ { A_SItemEnter, A_LoadProtoListAll, A_ClrPartnoStr, A_ClrNumberStr, A_LoadDimsFromProtoList, A_Redraw, A_HidePartnoList }, + /*T_ProtoSel*/ { A_LoadPartnoList, A_LoadDataFromPartList, A_Redraw }, + /*T_ProtoEnter*/ { A_SError }, + /*T_PartnoSel*/ { A_LoadDataFromPartList, A_Redraw }, + /*T_PartnoEnter*/{ A_SItemEnter, A_LoadProtoListAll, A_HidePartnoList } + }, + + /*A_SItemEnter*/{ + /*T_ItemSel*/ { A_SItemSel, A_LoadProtoListForManuf, A_LoadPartnoList, A_LoadDataFromPartList, A_Redraw, A_ShowPartnoList }, + /*T_ItemEnter*/ { A_Return }, + /*T_ProtoSel*/ { A_LoadDimsFromProtoList, A_Redraw }, + /*T_ProtoEnter*/ { A_SError }, + /*T_PartnoSel*/ { A_SError }, + /*T_PartnoEnter*/{ A_Return } + }, + + /*A_SPartnoSel*/{ + /*T_ItemSel*/ { A_SPartnoSel }, + /*T_ItemEnter*/ { A_SPartnoSel }, + /*T_ProtoSel*/ { A_SPartnoSel, A_LoadDimsFromProtoList, A_Redraw }, + /*T_ProtoEnter*/ { A_SError }, + /*T_PartnoSel*/ { A_SError } + }, + + /*A_SPartnoEnter*/{ + /*T_ItemSel*/ { A_SPartnoSel }, + /*T_ItemEnter*/ { A_SPartnoEnter }, + /*T_ProtoSel*/ { A_SPartnoEnter, A_LoadDimsFromProtoList, A_Redraw }, + /*T_ProtoEnter*/ { A_SError }, + /*T_PartnoSel*/ { A_SError }, + /*T_PartnoEnter*/{ A_SPartnoEnter } + }, + + /*A_SProtoSel*/{ + /*T_ItemSel*/ { A_SError }, + /*T_ItemEnter*/ { A_SError }, + /*T_ProtoSel*/ { A_SError }, + /*T_ProtoEnter*/ { A_SProtoSel }, + /*T_PartnoSel*/ { A_SError }, + /*T_PartnoEnter*/{ A_SError } + } +}; static carDlgAction_e itemNewActions[] = { - A_RecallCouplerLength, - A_LoadLists, - A_IsCustom, 2+3, - A_LoadDimsFromProtoList, A_ClrPartnoStr, A_ClrNumberStr, - A_Else, 1, - A_LoadDataFromPartList, - A_ShowControls, A_Return }; + A_RecallCouplerLength, + A_LoadLists, + A_IsCustom, 2+3, + A_LoadDimsFromProtoList, A_ClrPartnoStr, A_ClrNumberStr, + A_Else, 1, + A_LoadDataFromPartList, + A_ShowControls, A_Return +}; static carDlgAction_e itemUpdActions[] = { A_LoadInfoFromUpdateItem, /*A_LoadManufListForScale, A_IsCustom, 5, A_LoadProtoListAll, A_HidePartnoList, A_SItemEnter, A_Else, 5, A_LoadProtoListForManuf, A_LoadPartnoList, A_LoadDataFromPartList, A_ShowPartnoList, A_SItemSel,*/ - A_ShowControls, A_Return }; + A_ShowControls, A_Return + }; static carDlgAction_e partNewActions[] = { A_RecallCouplerLength, A_LoadManufListAll, A_LoadProtoListAll, A_ClrPartnoStr, A_ClrNumberStr, A_SPartnoSel, A_LoadDimsFromProtoList, A_ShowControls, A_Redraw, A_Return }; static carDlgAction_e partUpdActions[] = { A_LoadDataFromUpdatePart, A_SPartnoSel, A_ShowControls, A_Return }; @@ -2427,64 +2559,68 @@ static carDlgAction_e protoNewActions[] = { A_InitProto, A_SProtoSel, A_ShowCont static carDlgAction_e protoUpdActions[] = { A_InitProto, A_SProtoSel, A_ShowControls, A_Return }; static carDlgAction_e item2partActions[] = { - A_PushDims, A_LoadManufListAll, A_LoadProtoListAll, - A_IsCustom, 0+1, - A_ClrManuf, - A_SPartnoSel, - A_ShowControls, A_Return }; + A_PushDims, A_LoadManufListAll, A_LoadProtoListAll, + A_IsCustom, 0+1, + A_ClrManuf, + A_SPartnoSel, + A_ShowControls, A_Return +}; static carDlgAction_e part2itemActions[] = { - A_IsNewPart, 2+0, - A_Else, 1, - A_PopTitleAndTypeinx, - A_LoadLists, - A_IsCustom, 2+1, - A_LoadDimsFromProtoList, - A_Else, 1, - A_LoadDataFromPartList, + A_IsNewPart, 2+0, + A_Else, 1, + A_PopTitleAndTypeinx, + A_LoadLists, + A_IsCustom, 2+1, + A_LoadDimsFromProtoList, + A_Else, 1, + A_LoadDataFromPartList, #ifdef LATER - A_IsNewPart, 2+0, - A_Else, 1, - A_LoadDimsFromStack, + A_IsNewPart, 2+0, + A_Else, 1, + A_LoadDimsFromStack, #endif - A_ShowControls, - A_Return }; + A_ShowControls, + A_Return +}; static carDlgAction_e item2protoActions[] = { A_PushDims, A_ConvertDimsToProto, A_SProtoSel, A_ShowControls, A_Return }; static carDlgAction_e proto2itemActions[] = { - A_IsCustom, 2+2+3, - A_IsNewProto, 2+3, - A_LoadProtoListAll, - A_PopCouplerLength, - A_LoadDimsFromProtoList, - A_Else, 2, - A_LoadDimsFromStack, - A_LoadProtoStrFromList, - A_ShowControls, - A_Return }; + A_IsCustom, 2+2+3, + A_IsNewProto, 2+3, + A_LoadProtoListAll, + A_PopCouplerLength, + A_LoadDimsFromProtoList, + A_Else, 2, + A_LoadDimsFromStack, + A_LoadProtoStrFromList, + A_ShowControls, + A_Return +}; static carDlgAction_e part2protoActions[] = { A_PushDims, A_ConvertDimsToProto, A_SProtoSel, A_ShowControls, A_Return }; static carDlgAction_e proto2partActions[] = { - A_IsNewProto, 2+3, - A_LoadProtoListAll, - A_PopCouplerLength, - A_LoadDimsFromProtoList, - A_Else, 2, - A_LoadDimsFromStack, - A_LoadProtoStrFromList, - A_ShowControls, - A_Return }; + A_IsNewProto, 2+3, + A_LoadProtoListAll, + A_PopCouplerLength, + A_LoadDimsFromProtoList, + A_Else, 2, + A_LoadDimsFromStack, + A_LoadProtoStrFromList, + A_ShowControls, + A_Return +}; #define CARDLG_STK_SIZE (2) int carDlgStkPtr = 0; struct { - carDim_t dim; - DIST_T couplerLength; - carDlgState_e state; - int changed; - carPart_p partP; - wIndex_t typeInx; - } carDlgStk[CARDLG_STK_SIZE]; + carDim_t dim; + DIST_T couplerLength; + carDlgState_e state; + int changed; + carPart_p partP; + wIndex_t typeInx; +} carDlgStk[CARDLG_STK_SIZE]; static carDlgState_e currState = S_Error; #define S_ITEM (currState==S_ItemSel||currState==S_ItemEnter) @@ -2497,10 +2633,11 @@ static void CarDlgLoadDimsFromPart( carPart_p partP ) { tabString_t tabs[7]; - if ( partP == NULL ) return; + if ( partP == NULL ) { return; } carDlgDim = partP->dim; carDlgCouplerLength = (carDlgDim.coupledLength-carDlgDim.carLength)/2.0; - sprintf( message, "%s-%s", carDlgPLs[I_CD_CPLRLEN].nameStr, GetScaleName(carDlgScaleInx) ); + sprintf( message, "%s-%s", carDlgPLs[I_CD_CPLRLEN].nameStr, + GetScaleName(carDlgScaleInx) ); wPrefSetFloat( carDlgPG.nameStr, message, carDlgCouplerLength ); carDlgIsLoco = (partP->options&CAR_DESC_IS_LOCO)?1:0; carDlgBodyColor = partP->color; @@ -2508,7 +2645,8 @@ static void CarDlgLoadDimsFromPart( carPart_p partP ) ParamLoadControl( &carDlgPG, I_CD_CARWIDTH ); ParamLoadControl( &carDlgPG, I_CD_TRKCENTER ); ParamLoadControl( &carDlgPG, I_CD_CPLDLEN ); - wColorSelectButtonSetColor( (wButton_p)carDlgPLs[I_CD_BODYCOLOR].control, *(wDrawColor*)carDlgPLs[I_CD_BODYCOLOR].valueP ); + wColorSelectButtonSetColor( (wButton_p)carDlgPLs[I_CD_BODYCOLOR].control, + *(wDrawColor*)carDlgPLs[I_CD_BODYCOLOR].valueP ); TabStringExtract( partP->title, 7, tabs ); } @@ -2531,7 +2669,7 @@ static void CarDlgLoadDimsFromProto( carProto_p protoP ) static void CarDlgRedraw( - wDraw_p d, void * context, wWinPix_t x, wWinPix_t y ) + wDraw_p d, void * context, wWinPix_t x, wWinPix_t y ) { wWinPix_t w, h; DIST_T ww, hh; @@ -2542,33 +2680,37 @@ static void CarDlgRedraw( int segCnt; trkSeg_p segPtr; - if ( S_PROTO ) + if ( S_PROTO ) { ratio = 1; - else + } else { ratio = 1/GetScaleRatio(carDlgScaleInx); + } wDrawClear( carDlgD.d ); - if ( carDlgDim.carLength <= 0 || carDlgDim.carWidth <= 0 ) + if ( carDlgDim.carLength <= 0 || carDlgDim.carWidth <= 0 ) { return; + } FreeFilledDraw( carDlgSegs_da.cnt, &carDlgSegs(0) ); if ( !S_PROTO ) { if ( carDlgProtoInx < 0 || - (protoP = CarProtoLookup( carDlgProtoStr, FALSE, FALSE, 0.0, 0.0 )) == NULL || - protoP->segCnt == 0 ) { - CarProtoDlgCreateDummyOutline( &segCnt, &segPtr, (BOOL_T)carDlgIsLoco, carDlgDim.carLength, carDlgDim.carWidth, carDlgBodyColor ); + (protoP = CarProtoLookup( carDlgProtoStr, FALSE, FALSE, 0.0, 0.0 )) == NULL || + protoP->segCnt == 0 ) { + CarProtoDlgCreateDummyOutline( &segCnt, &segPtr, (BOOL_T)carDlgIsLoco, + carDlgDim.carLength, carDlgDim.carWidth, carDlgBodyColor ); } else { segCnt = protoP->segCnt; segPtr = protoP->segPtr; } } else { if ( carProtoSegCnt <= 0 ) { - CarProtoDlgCreateDummyOutline( &segCnt, &segPtr, (BOOL_T)carDlgIsLoco, carDlgDim.carLength, carDlgDim.carWidth, drawColorBlue ); + CarProtoDlgCreateDummyOutline( &segCnt, &segPtr, (BOOL_T)carDlgIsLoco, + carDlgDim.carLength, carDlgDim.carWidth, drawColorBlue ); } else { segCnt = carProtoSegCnt; segPtr = carProtoSegPtr; } } DYNARR_SET( trkSeg_t, carDlgSegs_da, segCnt ); - memcpy( &carDlgSegs(0), segPtr, segCnt * sizeof *(trkSeg_t*)0 ); + memcpy( &carDlgSegs(0), segPtr, segCnt * sizeof carDlgSegs(0) ); CloneFilledDraw( carDlgSegs_da.cnt, &carDlgSegs(0), TRUE ); GetSegBounds( zero, 0.0, carDlgSegs_da.cnt, &carDlgSegs(0), &orig, &size ); scale_w = carDlgDim.carLength/size.x; @@ -2589,26 +2731,32 @@ static void CarDlgRedraw( hh = h/carDlgD.dpi-0.5; scale_w = carDlgDim.carLength/ww; scale_h = carDlgDim.carWidth/hh; - if ( scale_w > scale_h ) + if ( scale_w > scale_h ) { carDlgD.scale = scale_w; - else + } else { carDlgD.scale = scale_h; + } orig.x = 0.50*carDlgD.scale; orig.y = 0.25*carDlgD.scale; - DrawSegs( &carDlgD, orig, 0.0, &carDlgSegs(0), carDlgSegs_da.cnt, 0.0, wDrawColorBlack ); + DrawSegsDA( &carDlgD, NULL, orig, 0.0, &carDlgSegs_da, 0.0, wDrawColorBlack, + 0 ); pos.y = orig.y+carDlgDim.carWidth/2.0; if ( carDlgDim.truckCenter > 0.0 ) { - pos.x = orig.x+(carDlgDim.carLength-carDlgDim.truckCenter)/2.0-carDlgDim.truckCenterOffset; + pos.x = orig.x+(carDlgDim.carLength-carDlgDim.truckCenter)/2.0 + -carDlgDim.truckCenterOffset; CarProtoDrawTruck( &carDlgD, trackGauge*curScaleRatio, ratio, pos, 0.0 ); - pos.x = orig.x+(carDlgDim.carLength+carDlgDim.truckCenter)/2.0-carDlgDim.truckCenterOffset; + pos.x = orig.x+(carDlgDim.carLength+carDlgDim.truckCenter)/2.0 + -carDlgDim.truckCenterOffset; CarProtoDrawTruck( &carDlgD, trackGauge*curScaleRatio, ratio, pos, 0.0 ); } if ( carDlgDim.coupledLength > carDlgDim.carLength ) { pos.x = orig.x; - CarProtoDrawCoupler( &carDlgD, (carDlgDim.coupledLength-carDlgDim.carLength)/2.0, ratio, pos, 270.0 ); + CarProtoDrawCoupler( &carDlgD, + (carDlgDim.coupledLength-carDlgDim.carLength)/2.0, ratio, pos, 270.0 ); pos.x = orig.x+carDlgDim.carLength; - CarProtoDrawCoupler( &carDlgD, (carDlgDim.coupledLength-carDlgDim.carLength)/2.0, ratio, pos, 90.0 ); + CarProtoDrawCoupler( &carDlgD, + (carDlgDim.coupledLength-carDlgDim.carLength)/2.0, ratio, pos, 90.0 ); } } @@ -2623,97 +2771,119 @@ static void CarDlgLoadRoadnameList( void ) wIndex_t inx; roadnameMap_p roadnameMapP; - if ( !roadnameMapChanged ) return; + if ( !roadnameMapChanged ) { return; } wListClear( (wList_p)carDlgPLs[I_CD_ROADNAME_LIST].control ); - wListAddValue( (wList_p)carDlgPLs[I_CD_ROADNAME_LIST].control, _("Undecorated"), NULL, NULL ); + wListAddValue( (wList_p)carDlgPLs[I_CD_ROADNAME_LIST].control, _("Undecorated"), + NULL, NULL ); for ( inx=0; inx<roadnameMap_da.cnt; inx++ ) { roadnameMapP = DYNARR_N(roadnameMap_p, roadnameMap_da, inx); - wListAddValue( (wList_p)carDlgPLs[I_CD_ROADNAME_LIST].control, roadnameMapP->roadname, NULL, roadnameMapP ); - if ( strcasecmp( carDlgRoadnameStr, roadnameMapP->roadname )==0 ) + wListAddValue( (wList_p)carDlgPLs[I_CD_ROADNAME_LIST].control, + roadnameMapP->roadname, NULL, roadnameMapP ); + if ( strcasecmp( carDlgRoadnameStr, roadnameMapP->roadname )==0 ) { carDlgRoadnameInx = inx+1; + } } roadnameMapChanged = FALSE; } static BOOL_T CheckAvail( - carPartParent_p parentP ) + carPartParent_p parentP ) { wIndex_t inx; carPart_p partP; for ( inx=0; inx<parentP->parts_da.cnt; inx++ ) { partP = carPart(parentP,inx); - if ( IsParamValid(partP->paramFileIndex) ) + if ( IsParamValid(partP->paramFileIndex) ) { return TRUE; + } } return FALSE; } static BOOL_T CarDlgLoadManufList( - BOOL_T bLoadAll, - BOOL_T bInclCustomUnknown, - SCALEINX_T scale ) + BOOL_T bLoadAll, + BOOL_T bInclCustomUnknown, + SCALEINX_T scale ) { carPartParent_p manufP, manufP1; wIndex_t inx, listInx=-1; BOOL_T found = TRUE; char * firstName = NULL; -LOG( log_carDlgList, 3, ( "CarDlgLoadManufList( %s, %s, %d )\n carDlgManufStr=\"%s\"\n", bLoadAll?"TRUE":"FALSE", bInclCustomUnknown?"TRUE":"FALSE", scale, carDlgManufStr ) ) + LOG( log_carDlgList, 3, + ( "CarDlgLoadManufList( %s, %s, %d )\n carDlgManufStr=\"%s\"\n", + bLoadAll?"TRUE":"FALSE", bInclCustomUnknown?"TRUE":"FALSE", scale, + carDlgManufStr ) ) carDlgManufInx = -1; manufP1 = NULL; wListClear( (wList_p)carDlgPLs[I_CD_MANUF_LIST].control ); - for ( inx=0; inx<carPartParent_da.cnt; inx++ ) { - manufP = carPartParent(inx); - if ( manufP1!=NULL && strcasecmp( manufP1->manuf, manufP->manuf ) == 0 ) - continue; - if ( bLoadAll==FALSE && manufP->scale != scale ) - continue; - if ( !CheckAvail(manufP) ) - continue; - listInx = wListAddValue( (wList_p)carDlgPLs[I_CD_MANUF_LIST].control, manufP->manuf, NULL, manufP ); - if ( carDlgManufInx < 0 && ( carDlgManufStr[0] == '\0' || strcasecmp( carDlgManufStr, manufP->manuf ) == 0 ) ) { -LOG( log_carDlgList, 4, ( " found manufStr (inx=%d, listInx=%d)\n", inx, listInx ) ) - carDlgManufInx = listInx; - if ( carDlgManufStr[0] == '\0' ) strcpy( carDlgManufStr, manufP->manuf ); - } - if ( firstName == NULL ) - firstName = manufP->manuf; - manufP1 = manufP; - } - if ( bInclCustomUnknown ) { - listInx = wListAddValue( (wList_p)carDlgPLs[I_CD_MANUF_LIST].control, _("Custom"), NULL, NULL ); - if ( carDlgManufInx < 0 && ( carDlgManufStr[0] == '\0' || strcasecmp( carDlgManufStr, "Custom" ) == 0 ) ) { -LOG( log_carDlgList, 4, ( " found Cus manufStr (inx=%d, listInx=%d)\n", inx, listInx ) ) - carDlgManufInx = listInx; - if ( carDlgManufStr[0] == '\0' ) strcpy( carDlgManufStr, _("Custom") ); - } - if ( firstName == NULL ) - firstName = "Custom"; - wListAddValue( (wList_p)carDlgPLs[I_CD_MANUF_LIST].control, _("Unknown"), NULL, NULL ); - if ( carDlgManufInx < 0 && ( carDlgManufStr[0] == '\0' || strcasecmp( carDlgManufStr, "Unknown" ) == 0 ) ) { -LOG( log_carDlgList, 4, ( " found Unk manufStr (inx=%d, listInx=%d)\n", inx, listInx ) ) - carDlgManufInx = listInx; - if ( carDlgManufStr[0] == '\0' ) strcpy( carDlgManufStr, _("Unknown") ); - } + for ( inx=0; inx<carPartParent_da.cnt; inx++ ) { + manufP = carPartParent(inx); + if ( manufP1!=NULL && strcasecmp( manufP1->manuf, manufP->manuf ) == 0 ) { + continue; } - if ( carDlgManufInx < 0 ) { - found = FALSE; - if ( firstName != NULL ) { -LOG( log_carDlgList, 4, ( " didn't find manufStr, using [0] = %s\n", firstName ) ) - carDlgManufInx = 0; - strcpy( carDlgManufStr, firstName ); - } + if ( bLoadAll==FALSE && manufP->scale != scale ) { + continue; + } + if ( !CheckAvail(manufP) ) { + continue; + } + listInx = wListAddValue( (wList_p)carDlgPLs[I_CD_MANUF_LIST].control, + manufP->manuf, NULL, manufP ); + if ( carDlgManufInx < 0 && ( carDlgManufStr[0] == '\0' + || strcasecmp( carDlgManufStr, manufP->manuf ) == 0 ) ) { + LOG( log_carDlgList, 4, ( " found manufStr (inx=%d, listInx=%d)\n", inx, + listInx ) ) + carDlgManufInx = listInx; + if ( carDlgManufStr[0] == '\0' ) { strcpy( carDlgManufStr, manufP->manuf ); } + } + if ( firstName == NULL ) { + firstName = manufP->manuf; + } + manufP1 = manufP; + } + if ( bInclCustomUnknown ) { + listInx = wListAddValue( (wList_p)carDlgPLs[I_CD_MANUF_LIST].control, + _("Custom"), NULL, NULL ); + if ( carDlgManufInx < 0 && ( carDlgManufStr[0] == '\0' + || strcasecmp( carDlgManufStr, "Custom" ) == 0 ) ) { + LOG( log_carDlgList, 4, ( " found Cus manufStr (inx=%d, listInx=%d)\n", inx, + listInx ) ) + carDlgManufInx = listInx; + if ( carDlgManufStr[0] == '\0' ) { strcpy( carDlgManufStr, _("Custom") ); } + } + if ( firstName == NULL ) { + firstName = "Custom"; + } + wListAddValue( (wList_p)carDlgPLs[I_CD_MANUF_LIST].control, _("Unknown"), NULL, + NULL ); + if ( carDlgManufInx < 0 && ( carDlgManufStr[0] == '\0' + || strcasecmp( carDlgManufStr, "Unknown" ) == 0 ) ) { + LOG( log_carDlgList, 4, ( " found Unk manufStr (inx=%d, listInx=%d)\n", inx, + listInx ) ) + carDlgManufInx = listInx; + if ( carDlgManufStr[0] == '\0' ) { strcpy( carDlgManufStr, _("Unknown") ); } } + } + if ( carDlgManufInx < 0 ) { + found = FALSE; + if ( firstName != NULL ) { + LOG( log_carDlgList, 4, ( " didn't find manufStr, using [0] = %s\n", + firstName ) ) + carDlgManufInx = 0; + strcpy( carDlgManufStr, firstName ); + } + } return found; } static BOOL_T CarDlgLoadProtoList( - char * manuf, - SCALEINX_T scale, - BOOL_T loadTypeList ) + char * manuf, + SCALEINX_T scale, + BOOL_T loadTypeList ) { carPartParent_p parentP; wIndex_t inx, listInx, inx1; @@ -2730,75 +2900,96 @@ static BOOL_T CarDlgLoadProtoList( wListClear( (wList_p)carDlgPLs[I_CD_PROTOTYPE_LIST].control ); memset( typeCount, 0, N_TYPELISTMAP * sizeof typeCount[0] ); -LOG( log_carDlgList, 3, ( "CarDlgLoadProtoList( %s, %d, %s )\n carDlgProtoStr=\"%s\", carDlgTypeInx=%d\n", manuf?manuf:"NULL", scale, loadTypeList?"TRUE":"FALSE", carDlgProtoStr, carDlgTypeInx ) ) + LOG( log_carDlgList, 3, + ( "CarDlgLoadProtoList( %s, %d, %s )\n carDlgProtoStr=\"%s\", carDlgTypeInx=%d\n", + manuf?manuf:"NULL", scale, loadTypeList?"TRUE":"FALSE", carDlgProtoStr, + carDlgTypeInx ) ) if ( manuf==NULL ) { - if ( carProto_da.cnt <= 0 ) return FALSE; - if ( listTypeInx < 0 && carDlgProtoStr[0] && (protoP=CarProtoFind(carDlgProtoStr)) ) + if ( carProto_da.cnt <= 0 ) { return FALSE; } + if ( listTypeInx < 0 && carDlgProtoStr[0] + && (protoP=CarProtoFind(carDlgProtoStr)) ) { listTypeInx = CarProtoFindTypeCode(protoP->type); - if ( listTypeInx < 0 ) + } + if ( listTypeInx < 0 ) { listTypeInx = CarProtoFindTypeCode(carProto(0)->type); + } for ( inx=0; inx<carProto_da.cnt; inx++ ) { protoP = carProto(inx); currTypeInx = CarProtoFindTypeCode(protoP->type); typeCount[currTypeInx]++; if ( carDlgTypeInx >= 0 && - listTypeInx != carDlgTypeInx && - currTypeInx == carDlgTypeInx ) { -LOG( log_carDlgList, 4, ( " found typeinx, reset list (old=%d)\n", listTypeInx ) ) + listTypeInx != carDlgTypeInx && + currTypeInx == carDlgTypeInx ) { + LOG( log_carDlgList, 4, ( " found typeinx, reset list (old=%d)\n", + listTypeInx ) ) wListClear( (wList_p)carDlgPLs[I_CD_PROTOTYPE_LIST].control ); listTypeInx = carDlgTypeInx; carDlgProtoInx = -1; firstName = NULL; } - if ( currTypeInx != listTypeInx ) continue; - listInx = wListAddValue( (wList_p)carDlgPLs[I_CD_PROTOTYPE_LIST].control, protoP->desc, NULL, protoP ); - if ( carDlgProtoInx < 0 && carDlgProtoStr[0] && strcasecmp( carDlgProtoStr, protoP->desc ) == 0 ) { -LOG( log_carDlgList, 4, ( " found protoStr (inx=%d, listInx=%d)\n", inx, listInx ) ) + if ( currTypeInx != listTypeInx ) { continue; } + listInx = wListAddValue( (wList_p)carDlgPLs[I_CD_PROTOTYPE_LIST].control, + protoP->desc, NULL, protoP ); + if ( carDlgProtoInx < 0 && carDlgProtoStr[0] + && strcasecmp( carDlgProtoStr, protoP->desc ) == 0 ) { + LOG( log_carDlgList, 4, ( " found protoStr (inx=%d, listInx=%d)\n", inx, + listInx ) ) carDlgProtoInx = listInx; - if ( carDlgProtoStr[0] == '\0' ) strcpy( carDlgProtoStr, protoP->desc ); + if ( carDlgProtoStr[0] == '\0' ) { strcpy( carDlgProtoStr, protoP->desc ); } } - if ( firstName == NULL ) + if ( firstName == NULL ) { firstName = protoP->desc; + } } } else { for ( inx=0; inx<carPartParent_da.cnt; inx++ ) { parentP = carPartParent(inx); if ( strcasecmp( manuf, parentP->manuf ) != 0 || - scale != parentP->scale ) + scale != parentP->scale ) { continue; - if ( !CheckAvail(parentP) ) + } + if ( !CheckAvail(parentP) ) { continue; + } found = FALSE; for ( inx1=0; inx1<parentP->parts_da.cnt; inx1++ ) { partP = carPart( parentP, inx1 ); currTypeInx = CarProtoFindTypeCode(partP->type); typeCount[currTypeInx]++; - if ( listTypeInx < 0 ) + if ( listTypeInx < 0 ) { listTypeInx = currTypeInx; + } if ( carDlgTypeInx >= 0 && - listTypeInx != carDlgTypeInx && - currTypeInx == carDlgTypeInx ) { -LOG( log_carDlgList, 4, ( " found typeinx, reset list (old=%d)\n", listTypeInx ) ) + listTypeInx != carDlgTypeInx && + currTypeInx == carDlgTypeInx ) { + LOG( log_carDlgList, 4, ( " found typeinx, reset list (old=%d)\n", + listTypeInx ) ) wListClear( (wList_p)carDlgPLs[I_CD_PROTOTYPE_LIST].control ); listTypeInx = carDlgTypeInx; carDlgProtoInx = -1; firstName = NULL; } - if ( listTypeInx == currTypeInx ) + if ( listTypeInx == currTypeInx ) { found = TRUE; + } } - if ( !found ) + if ( !found ) { continue; - listInx = wListAddValue( (wList_p)carDlgPLs[I_CD_PROTOTYPE_LIST].control, parentP->proto, NULL, parentP ); - if ( carDlgProtoInx < 0 && ( carDlgProtoStr[0] == '\0' || strcasecmp( carDlgProtoStr, parentP->proto ) == 0 ) ) { -LOG( log_carDlgList, 4, ( " found protoStr (inx=%d, listInx=%d)\n", inx, listInx ) ) + } + listInx = wListAddValue( (wList_p)carDlgPLs[I_CD_PROTOTYPE_LIST].control, + parentP->proto, NULL, parentP ); + if ( carDlgProtoInx < 0 && ( carDlgProtoStr[0] == '\0' + || strcasecmp( carDlgProtoStr, parentP->proto ) == 0 ) ) { + LOG( log_carDlgList, 4, ( " found protoStr (inx=%d, listInx=%d)\n", inx, + listInx ) ) carDlgProtoInx = listInx; if ( carDlgProtoStr[0] == '\0' ) { strcpy( carDlgProtoStr, parentP->proto ); } } - if ( firstName == NULL ) + if ( firstName == NULL ) { firstName = parentP->proto; + } } } @@ -2806,60 +2997,63 @@ LOG( log_carDlgList, 4, ( " found protoStr (inx=%d, listInx=%d)\n", inx, list if ( carDlgProtoInx < 0 ) { found = FALSE; if ( firstName != NULL ) { -LOG( log_carDlgList, 4, ( " didn't find protoStr, using [0] = %s\n", firstName ) ) + LOG( log_carDlgList, 4, ( " didn't find protoStr, using [0] = %s\n", + firstName ) ) carDlgProtoInx = 0; strcpy( carDlgProtoStr, firstName ); } } - wListSetIndex( (wList_p)carDlgPLs[I_CD_PROTOTYPE_LIST].control, carDlgProtoInx ); + wListSetIndex( (wList_p)carDlgPLs[I_CD_PROTOTYPE_LIST].control, + carDlgProtoInx ); if ( loadTypeList ) { -LOG( log_carDlgList, 4, ( " loading typelist\n" ) ) - wListClear( (wList_p)carDlgPLs[I_CD_PROTOKIND_LIST].control ); - for ( currTypeInx=0; currTypeInx<N_TYPELISTMAP; currTypeInx++ ) { - if ( typeCount[currTypeInx] > 0 ) { - listInx = wListAddValue( (wList_p)carDlgPLs[I_CD_PROTOKIND_LIST].control, _(typeListMap[currTypeInx].name), NULL, I2VP(currTypeInx) ); - if ( currTypeInx == listTypeInx ) { -LOG( log_carDlgList, 4, ( " current = %d\n", listInx ) ) - carDlgKindInx = listInx; + LOG( log_carDlgList, 4, ( " loading typelist\n" ) ) + wListClear( (wList_p)carDlgPLs[I_CD_PROTOKIND_LIST].control ); + for ( currTypeInx=0; currTypeInx<N_TYPELISTMAP; currTypeInx++ ) { + if ( typeCount[currTypeInx] > 0 ) { + listInx = wListAddValue( (wList_p)carDlgPLs[I_CD_PROTOKIND_LIST].control, + _(typeListMap[currTypeInx].name), NULL, I2VP(currTypeInx) ); + if ( currTypeInx == listTypeInx ) { + LOG( log_carDlgList, 4, ( " current = %d\n", listInx ) ) + carDlgKindInx = listInx; + } } } } - } return found; } static void ConstructPartDesc( - tabString_t * tabs ) + tabString_t * tabs ) { char * cp; - cp = message; - *cp = '\0'; - if ( tabs[T_PART].len ) { - cp = TabStringCpy( cp, &tabs[T_PART] ); - *cp++ = ' '; - } - if ( tabs[T_DESC].len ) { - cp = TabStringCpy( cp, &tabs[T_DESC] ); - *cp++ = ' '; - } - if ( tabs[T_REPMARK].len ) { - cp = TabStringCpy( cp, &tabs[T_REPMARK] ); - *cp++ = ' '; - } else if ( tabs[T_ROADNAME].len ) { - cp = TabStringCpy( cp, &tabs[T_ROADNAME] ); - *cp++ = ' '; - } else { - strcpy( cp, _("Undecorated ") ); - cp += strlen( cp ); - } - if ( tabs[T_NUMBER].len ) { - cp = TabStringCpy( cp, &tabs[T_NUMBER] ); - *cp++ = ' '; - } - *cp = '\0'; + cp = message; + *cp = '\0'; + if ( tabs[T_PART].len ) { + cp = TabStringCpy( cp, &tabs[T_PART] ); + *cp++ = ' '; + } + if ( tabs[T_DESC].len ) { + cp = TabStringCpy( cp, &tabs[T_DESC] ); + *cp++ = ' '; + } + if ( tabs[T_REPMARK].len ) { + cp = TabStringCpy( cp, &tabs[T_REPMARK] ); + *cp++ = ' '; + } else if ( tabs[T_ROADNAME].len ) { + cp = TabStringCpy( cp, &tabs[T_ROADNAME] ); + *cp++ = ' '; + } else { + strcpy( cp, _("Undecorated ") ); + cp += strlen( cp ); + } + if ( tabs[T_NUMBER].len ) { + cp = TabStringCpy( cp, &tabs[T_NUMBER] ); + *cp++ = ' '; + } + *cp = '\0'; } @@ -2894,16 +3088,19 @@ static BOOL_T CarDlgLoadPartList( carPartParent_p parentP ) ConstructPartDesc( tabs ); lastPart.paramFileIndex = partP->paramFileIndex; if ( message[0] && IsParamValid(partP->paramFileIndex) && - ( lastPart.title == NULL || Cmp_part( &lastPart, partP ) != 0 ) ) { - listInx = wListAddValue( (wList_p)carDlgPLs[I_CD_PARTNO_LIST].control, message, NULL, partP ); + ( lastPart.title == NULL || Cmp_part( &lastPart, partP ) != 0 ) ) { + listInx = wListAddValue( (wList_p)carDlgPLs[I_CD_PARTNO_LIST].control, message, + NULL, partP ); if ( carDlgPartnoInx<0 && - (carDlgPartnoStr[0]?TabStringCmp( carDlgPartnoStr, &tabs[T_PART] ) == 0:TRUE) ) { + (carDlgPartnoStr[0]?TabStringCmp( carDlgPartnoStr, + &tabs[T_PART] ) == 0:TRUE) ) { carDlgPartnoInx = listInx; found = TRUE; selPartP = partP; } - if ( selPartP == NULL ) + if ( selPartP == NULL ) { selPartP = partP; + } lastPart = *partP; } } @@ -2911,8 +3108,9 @@ static BOOL_T CarDlgLoadPartList( carPartParent_p parentP ) carDlgPartnoStr[0] = '\0'; carDlgDescStr[0] = '\0'; } else { - if ( carDlgPartnoInx<0 ) + if ( carDlgPartnoInx<0 ) { carDlgPartnoInx = 0; + } TabStringExtract( selPartP->title, 7, tabs ); TabStringCpy( carDlgPartnoStr, &tabs[T_PART] ); TabStringCpy( carDlgDescStr, &tabs[T_DESC] ); @@ -2923,7 +3121,7 @@ static BOOL_T CarDlgLoadPartList( carPartParent_p parentP ) static void CarDlgLoadPart( - carPart_p partP ) + carPart_p partP ) { tabString_t tabs[7]; roadnameMap_p roadnameMapP; @@ -2951,9 +3149,9 @@ static void CarDlgLoadPart( static BOOL_T CarDlgLoadLists( - BOOL_T isItem, - tabString_t * tabs, - SCALEINX_T scale ) + BOOL_T isItem, + tabString_t * tabs, + SCALEINX_T scale ) { BOOL_T loadCustomUnknown = isItem; DIST_T ratio; @@ -2961,25 +3159,28 @@ static BOOL_T CarDlgLoadLists( static carProto_t protoTmp; static char protoTmpDesc[STR_SIZE]; - if ( tabs ) TabStringCpy( carDlgManufStr, &tabs[T_MANUF] ); + if ( tabs ) { TabStringCpy( carDlgManufStr, &tabs[T_MANUF] ); } if ( strcasecmp( carDlgManufStr, "unknown" ) == 0 || - strcasecmp( carDlgManufStr, "custom" ) == 0 ) { + strcasecmp( carDlgManufStr, "custom" ) == 0 ) { loadCustomUnknown = TRUE; /*isItem = FALSE;*/ } if ( (!CarDlgLoadManufList( !isItem, loadCustomUnknown, scale )) && tabs ) { TabStringCpy( carDlgManufStr, &tabs[T_MANUF] ); - carDlgManufInx = wListAddValue( (wList_p)carDlgPLs[I_CD_MANUF_LIST].control, carDlgManufStr, NULL, NULL ); + carDlgManufInx = wListAddValue( (wList_p)carDlgPLs[I_CD_MANUF_LIST].control, + carDlgManufStr, NULL, NULL ); isItem = FALSE; } if ( isItem ) { - parentP = (carPartParent_p)wListGetItemContext( (wList_p)carDlgPLs[I_CD_MANUF_LIST].control, carDlgManufInx ); + parentP = (carPartParent_p)wListGetItemContext( (wList_p) + carDlgPLs[I_CD_MANUF_LIST].control, carDlgManufInx ); if ( parentP ) { - if ( tabs ) TabStringCpy( carDlgProtoStr, &tabs[T_PROTO] ); + if ( tabs ) { TabStringCpy( carDlgProtoStr, &tabs[T_PROTO] ); } if ( CarDlgLoadProtoList( carDlgManufStr, scale, TRUE ) || !tabs ) { - parentP = (carPartParent_p)wListGetItemContext( (wList_p)carDlgPLs[I_CD_PROTOTYPE_LIST].control, carDlgProtoInx ); + parentP = (carPartParent_p)wListGetItemContext( (wList_p) + carDlgPLs[I_CD_PROTOTYPE_LIST].control, carDlgProtoInx ); if ( parentP ) { - if ( tabs ) TabStringCpy( carDlgPartnoStr, &tabs[T_PART] ); + if ( tabs ) { TabStringCpy( carDlgPartnoStr, &tabs[T_PART] ); } if ( CarDlgLoadPartList( parentP ) || ( (!tabs) && carDlgPartnoInx>=0 ) ) { return TRUE; } @@ -2987,7 +3188,7 @@ static BOOL_T CarDlgLoadLists( } } } - if ( tabs ) TabStringCpy( carDlgProtoStr, &tabs[T_PROTO] ); + if ( tabs ) { TabStringCpy( carDlgProtoStr, &tabs[T_PROTO] ); } if ( !CarDlgLoadProtoList( NULL, 0, TRUE ) && tabs ) { /* create dummy proto */ ratio = GetScaleRatio( scale ); @@ -3002,12 +3203,16 @@ static BOOL_T CarDlgLoadLists( protoTmp.dim.coupledLength = carDlgDim.coupledLength*ratio; protoTmp.dim.truckCenter = carDlgDim.truckCenter*ratio; protoTmp.dim.truckCenterOffset = carDlgDim.truckCenterOffset*ratio; - CarProtoDlgCreateDummyOutline( &carProtoSegCnt, &carProtoSegPtr, (BOOL_T)carDlgIsLoco, protoTmp.dim.carLength, protoTmp.dim.carWidth, drawColorBlue ); + CarProtoDlgCreateDummyOutline( &carProtoSegCnt, &carProtoSegPtr, + (BOOL_T)carDlgIsLoco, protoTmp.dim.carLength, protoTmp.dim.carWidth, + drawColorBlue ); protoTmp.segCnt = carProtoSegCnt; protoTmp.segPtr = carProtoSegPtr; - GetSegBounds( zero, 0.0, carProtoSegCnt, carProtoSegPtr, &protoTmp.orig, &protoTmp.size ); + GetSegBounds( zero, 0.0, carProtoSegCnt, carProtoSegPtr, &protoTmp.orig, + &protoTmp.size ); TabStringCpy( carDlgProtoStr, &tabs[T_PROTO] ); - carDlgProtoInx = wListAddValue( (wList_p)carDlgPLs[I_CD_PROTOTYPE_LIST].control, carDlgProtoStr, NULL, &protoTmp );/*??*/ + carDlgProtoInx = wListAddValue( (wList_p)carDlgPLs[I_CD_PROTOTYPE_LIST].control, + carDlgProtoStr, NULL, &protoTmp );/*??*/ } carDlgPartnoInx = -1; if ( tabs ) { @@ -3034,30 +3239,45 @@ static void CarDlgShowControls( void ) ParamControlShow( &carDlgPG, I_CD_PURDAT, S_ITEM && carDlgDispMode==0 ); ParamControlShow( &carDlgPG, I_CD_SRVDAT, S_ITEM && carDlgDispMode==0 ); ParamControlShow( &carDlgPG, I_CD_NOTES, S_ITEM && carDlgDispMode==0 ); - ParamControlShow( &carDlgPG, I_CD_MLTNUM, S_ITEM && carDlgUpdateItemPtr==NULL && carDlgDispMode==0 ); - ParamControlShow( &carDlgPG, I_CD_QTY, S_ITEM && carDlgUpdateItemPtr==NULL && carDlgDispMode==0 ); - - ParamControlShow( &carDlgPG, I_CD_ROADNAME_LIST, S_PART || ( S_ITEM && carDlgDispMode==1 ) ); - ParamControlShow( &carDlgPG, I_CD_REPMARK, S_PART || ( S_ITEM && carDlgDispMode==1 ) ); - ParamControlShow( &carDlgPG, I_CD_NUMBER, S_PART || ( S_ITEM && carDlgDispMode==1 ) ); - ParamControlShow( &carDlgPG, I_CD_BODYCOLOR, S_PART || ( S_ITEM && carDlgDispMode==1 ) ); - ParamControlShow( &carDlgPG, I_CD_CARLENGTH, !( S_ITEM && carDlgDispMode==0 ) ); - ParamControlShow( &carDlgPG, I_CD_CARWIDTH, !( S_ITEM && carDlgDispMode==0 ) ); - ParamControlShow( &carDlgPG, I_CD_TRKCENTER, !( S_ITEM && carDlgDispMode==0 ) ); - ParamControlShow( &carDlgPG, I_CD_TRKOFFSET, !( S_ITEM && carDlgDispMode==0 ) ); + ParamControlShow( &carDlgPG, I_CD_MLTNUM, S_ITEM + && carDlgUpdateItemPtr==NULL && carDlgDispMode==0 ); + ParamControlShow( &carDlgPG, I_CD_QTY, S_ITEM && carDlgUpdateItemPtr==NULL + && carDlgDispMode==0 ); + + ParamControlShow( &carDlgPG, I_CD_ROADNAME_LIST, S_PART || ( S_ITEM + && carDlgDispMode==1 ) ); + ParamControlShow( &carDlgPG, I_CD_REPMARK, S_PART || ( S_ITEM + && carDlgDispMode==1 ) ); + ParamControlShow( &carDlgPG, I_CD_NUMBER, S_PART || ( S_ITEM + && carDlgDispMode==1 ) ); + ParamControlShow( &carDlgPG, I_CD_BODYCOLOR, S_PART || ( S_ITEM + && carDlgDispMode==1 ) ); + ParamControlShow( &carDlgPG, I_CD_CARLENGTH, !( S_ITEM + && carDlgDispMode==0 ) ); + ParamControlShow( &carDlgPG, I_CD_CARWIDTH, !( S_ITEM + && carDlgDispMode==0 ) ); + ParamControlShow( &carDlgPG, I_CD_TRKCENTER, !( S_ITEM + && carDlgDispMode==0 ) ); + ParamControlShow( &carDlgPG, I_CD_TRKOFFSET, !( S_ITEM + && carDlgDispMode==0 ) ); ParamControlShow( &carDlgPG, I_CD_CANVAS, !( S_ITEM && carDlgDispMode==0 ) ); - ParamControlShow( &carDlgPG, I_CD_CPLRLEN, S_PART || ( S_ITEM && carDlgDispMode==1 ) ); - ParamControlShow( &carDlgPG, I_CD_CPLDLEN, S_PART || ( S_ITEM && carDlgDispMode==1 ) ); - ParamControlShow( &carDlgPG, I_CD_CPLRMNT, S_PART || ( S_ITEM && carDlgDispMode==1 ) ); + ParamControlShow( &carDlgPG, I_CD_CPLRLEN, S_PART || ( S_ITEM + && carDlgDispMode==1 ) ); + ParamControlShow( &carDlgPG, I_CD_CPLDLEN, S_PART || ( S_ITEM + && carDlgDispMode==1 ) ); + ParamControlShow( &carDlgPG, I_CD_CPLRMNT, S_PART || ( S_ITEM + && carDlgDispMode==1 ) ); ParamControlShow( &carDlgPG, I_CD_DISPMODE, S_ITEM ); ParamControlShow( &carDlgPG, I_CD_TYPE_LIST, S_PROTO ); ParamControlShow( &carDlgPG, I_CD_FLIP, S_PROTO ); - ParamControlShow( &carDlgPG, I_CD_DESC_STR, S_PART || (currState==S_ItemEnter) ); + ParamControlShow( &carDlgPG, I_CD_DESC_STR, S_PART + || (currState==S_ItemEnter) ); ParamControlShow( &carDlgPG, I_CD_IMPORT, S_PROTO ); ParamControlShow( &carDlgPG, I_CD_RESET, S_PROTO ); - ParamControlShow( &carDlgPG, I_CD_PARTNO_STR, S_PART || (currState==S_ItemEnter) ); + ParamControlShow( &carDlgPG, I_CD_PARTNO_STR, S_PART + || (currState==S_ItemEnter) ); ParamControlShow( &carDlgPG, I_CD_PARTNO_LIST, (currState==S_ItemSel) ); ParamControlShow( &carDlgPG, I_CD_ISLOCO, S_PROTO ); ParamControlShow( &carDlgPG, I_CD_PROTOKIND_LIST, !S_PROTO ); @@ -3066,7 +3286,8 @@ static void CarDlgShowControls( void ) ParamControlShow( &carDlgPG, I_CD_MANUF_LIST, !S_PROTO ); /*ParamControlActive( &carDlgPG, I_CD_PROTOTYPE_STR, S_PROTO && carDlgUpdateProtoPtr==NULL );*/ - ParamControlActive( &carDlgPG, I_CD_ITEMINDEX, S_ITEM && carDlgUpdateItemPtr==NULL ); + ParamControlActive( &carDlgPG, I_CD_ITEMINDEX, S_ITEM + && carDlgUpdateItemPtr==NULL ); ParamControlActive( &carDlgPG, I_CD_MLTNUM, S_ITEM && carDlgQuantity>1 ); ParamControlActive( &carDlgPG, I_CD_IMPORT, selectedTrackCount > 0 ); @@ -3086,7 +3307,8 @@ static void CarDlgShowControls( void ) sprintf( message, _("New %s Scale Car Part"), GetScaleName( carDlgScaleInx ) ); wButtonSetLabel( carDlgPG.okB, _("Add") ); } else { - sprintf( message, _("Update %s Scale Car Part"), GetScaleName( carDlgScaleInx ) ); + sprintf( message, _("Update %s Scale Car Part"), + GetScaleName( carDlgScaleInx ) ); wButtonSetLabel( carDlgPG.okB, _("Update") ); } wWinSetTitle( carDlgPG.win, message ); @@ -3109,7 +3331,7 @@ static void CarDlgShowControls( void ) static void CarDlgDoActions( - carDlgAction_e * actions ) + carDlgAction_e * actions ) { carPart_p partP; carPartParent_p parentP; @@ -3136,12 +3358,13 @@ static void CarDlgDoActions( memset( reload, 0, sizeof reload ); while ( 1 ) { -LOG( log_carDlgState, 2, ( "Action = %s\n", carDlgAction_s[*actions] ) ) + LOG( log_carDlgState, 2, ( "Action = %s\n", carDlgAction_s[*actions] ) ) switch ( *actions++ ) { case A_Return: for ( inx=0; inx<COUNT( carDlgPLs ); inx++ ) - if ( reload[inx] ) + if ( reload[inx] ) { ParamLoadControl( &carDlgPG, inx ); + } return; case A_SError: currState = S_Error; @@ -3167,8 +3390,9 @@ LOG( log_carDlgState, 2, ( "Action = %s\n", carDlgAction_s[*actions] ) ) break; case A_IsCustom: offset = (int)*actions++; - if ( currState != S_ItemEnter ) + if ( currState != S_ItemEnter ) { actions += offset; + } break; case A_IsNewPart: offset = (int)*actions++; @@ -3190,8 +3414,9 @@ LOG( log_carDlgState, 2, ( "Action = %s\n", carDlgAction_s[*actions] ) ) } break; case A_LoadDataFromPartList: - partP = (carPart_p)wListGetItemContext( (wList_p)carDlgPLs[I_CD_PARTNO_LIST].control, carDlgPartnoInx ); - if ( partP != NULL ){ + partP = (carPart_p)wListGetItemContext( (wList_p) + carDlgPLs[I_CD_PARTNO_LIST].control, carDlgPartnoInx ); + if ( partP != NULL ) { CarDlgLoadPart(partP); RELOAD_PARTDATA; RELOAD_PARTDATA; @@ -3213,7 +3438,8 @@ LOG( log_carDlgState, 2, ( "Action = %s\n", carDlgAction_s[*actions] ) ) reload[I_CD_MANUF_LIST] = TRUE; break; case A_LoadProtoListForManuf: - parentP = (carPartParent_p)wListGetItemContext( (wList_p)carDlgPLs[I_CD_MANUF_LIST].control, carDlgManufInx ); + parentP = (carPartParent_p)wListGetItemContext( (wList_p) + carDlgPLs[I_CD_MANUF_LIST].control, carDlgManufInx ); CarDlgLoadProtoList( parentP->manuf, parentP->scale, TRUE ); reload[I_CD_PROTOKIND_LIST] = TRUE; reload[I_CD_PROTOTYPE_LIST] = TRUE; @@ -3224,18 +3450,21 @@ LOG( log_carDlgState, 2, ( "Action = %s\n", carDlgAction_s[*actions] ) ) reload[I_CD_PROTOTYPE_LIST] = TRUE; break; case A_LoadPartnoList: - parentP = (carPartParent_p)wListGetItemContext( (wList_p)carDlgPLs[I_CD_PROTOTYPE_LIST].control, carDlgProtoInx ); + parentP = (carPartParent_p)wListGetItemContext( (wList_p) + carDlgPLs[I_CD_PROTOTYPE_LIST].control, carDlgProtoInx ); CarDlgLoadPartList( parentP ); reload[I_CD_PARTNO_LIST] = TRUE; break; case A_LoadLists: - if ( CarDlgLoadLists( TRUE, NULL, carDlgScaleInx ) ) + if ( CarDlgLoadLists( TRUE, NULL, carDlgScaleInx ) ) { currState = S_ItemSel; - else + } else { currState = S_ItemEnter; + } break; case A_LoadDimsFromProtoList: - protoP = (carProto_p)wListGetItemContext( (wList_p)carDlgPLs[I_CD_PROTOTYPE_LIST].control, carDlgProtoInx ); + protoP = (carProto_p)wListGetItemContext( (wList_p) + carDlgPLs[I_CD_PROTOTYPE_LIST].control, carDlgProtoInx ); if ( protoP ) { CarDlgLoadDimsFromProto( protoP ); carDlgTypeInx = CarProtoFindTypeCode( protoP->type ); @@ -3281,9 +3510,11 @@ LOG( log_carDlgState, 2, ( "Action = %s\n", carDlgAction_s[*actions] ) ) reload[I_CD_NUMBER] = TRUE; break; case A_LoadProtoStrFromList: - wListGetValues( (wList_p)carDlgPLs[I_CD_PROTOTYPE_LIST].control, carDlgProtoStr, sizeof carDlgProtoStr, NULL, NULL ); + wListGetValues( (wList_p)carDlgPLs[I_CD_PROTOTYPE_LIST].control, carDlgProtoStr, + sizeof carDlgProtoStr, NULL, NULL ); #ifdef LATER - protoP = (carProto_p)wListGetItemContext( (wList_p)carDlgPLs[I_CD_PROTOTYPE_LIST].control, carDlgProtoInx ); + protoP = (carProto_p)wListGetItemContext( (wList_p) + carDlgPLs[I_CD_PROTOTYPE_LIST].control, carDlgProtoInx ); if ( protoP ) { carDlgTypeInx = CarProtoFindTypeCode( protoP->type ); carDlgIsLoco = (protoP->options&CAR_DESC_IS_LOCO)!=0; @@ -3303,17 +3534,18 @@ LOG( log_carDlgState, 2, ( "Action = %s\n", carDlgAction_s[*actions] ) ) ParamControlShow( &carDlgPG, I_CD_PARTNO_STR, TRUE ); break; case A_PushDims: - if ( carDlgStkPtr >= CARDLG_STK_SIZE ) - AbortProg( "carDlgNewDesc: CARDLG_STK_SIZE" ); + CHECK( carDlgStkPtr < CARDLG_STK_SIZE ); carDlgStk[carDlgStkPtr].dim = carDlgDim; carDlgStk[carDlgStkPtr].couplerLength = carDlgCouplerLength; carDlgStk[carDlgStkPtr].state = currState; carDlgStk[carDlgStkPtr].changed = carDlgChanged; carDlgStk[carDlgStkPtr].typeInx = carDlgTypeInx; - if ( currState == S_ItemSel && carDlgPartnoInx >= 0 ) - carDlgStk[carDlgStkPtr].partP = (carPart_p)wListGetItemContext( (wList_p)carDlgPLs[I_CD_PARTNO_LIST].control, carDlgPartnoInx ); - else + if ( currState == S_ItemSel && carDlgPartnoInx >= 0 ) { + carDlgStk[carDlgStkPtr].partP = (carPart_p)wListGetItemContext( ( + wList_p)carDlgPLs[I_CD_PARTNO_LIST].control, carDlgPartnoInx ); + } else { carDlgStk[carDlgStkPtr].partP = NULL; + } carDlgStkPtr++; break; case A_PopDims: @@ -3348,9 +3580,11 @@ LOG( log_carDlgState, 2, ( "Action = %s\n", carDlgAction_s[*actions] ) ) carDlgTypeInx = CarProtoFindTypeCode( carDlgUpdateItemPtr->type ); carDlgIsLoco = (carDlgUpdateItemPtr->type&1)!=0; carDlgCouplerLength = (carDlgDim.coupledLength-carDlgDim.carLength)/2.0; - sprintf( message, "%s-%s", carDlgPLs[I_CD_CPLRLEN].nameStr, GetScaleName(carDlgScaleInx) ); + sprintf( message, "%s-%s", carDlgPLs[I_CD_CPLRLEN].nameStr, + GetScaleName(carDlgScaleInx) ); wPrefSetFloat( carDlgPG.nameStr, message, carDlgCouplerLength ); - carDlgCouplerMount = (carDlgUpdateItemPtr->options&CAR_DESC_COUPLER_MODE_BODY)!=0; + carDlgCouplerMount = (carDlgUpdateItemPtr->options&CAR_DESC_COUPLER_MODE_BODY)!= + 0; carDlgIsLoco = (carDlgUpdateItemPtr->options&CAR_DESC_IS_LOCO)!=0; carDlgPurchPrice = carDlgUpdateItemPtr->data.purchPrice; sprintf( carDlgPurchPriceStr, "%0.2f", carDlgPurchPrice ); @@ -3359,21 +3593,24 @@ LOG( log_carDlgState, 2, ( "Action = %s\n", carDlgAction_s[*actions] ) ) carDlgCondition = carDlgUpdateItemPtr->data.condition; carDlgConditionInx = MapCondition( carDlgUpdateItemPtr->data.condition ); carDlgPurchDate = carDlgUpdateItemPtr->data.purchDate; - if ( carDlgPurchDate ) + if ( carDlgPurchDate ) { sprintf( carDlgPurchDateStr, "%ld", carDlgPurchDate ); - else + } else { carDlgPurchDateStr[0] = '\0'; + } carDlgServiceDate = carDlgUpdateItemPtr->data.serviceDate; - if ( carDlgServiceDate ) + if ( carDlgServiceDate ) { sprintf( carDlgServiceDateStr, "%ld", carDlgServiceDate ); - else + } else { carDlgServiceDateStr[0] = '\0'; + } wTextClear( (wText_p)carDlgPLs[I_CD_NOTES].control ); if ( carDlgUpdateItemPtr->data.notes ) { - strncpy( message, carDlgUpdateItemPtr->data.notes, sizeof message ); - message[sizeof message - 1] = '\0'; - for ( cp=message; *cp; cp++ ) - if ( *cp == '\n' ) *cp = ' '; + strncpy( message, carDlgUpdateItemPtr->data.notes, sizeof message ); + message[sizeof message - 1] = '\0'; + for ( cp=message; *cp; cp++ ) { + if ( *cp == '\n' ) { *cp = ' '; } + } wTextAppend( (wText_p)carDlgPLs[I_CD_NOTES].control, message ); } LoadRoadnameList( &tabs[T_ROADNAME], &tabs[T_REPMARK] ); @@ -3381,10 +3618,11 @@ LOG( log_carDlgState, 2, ( "Action = %s\n", carDlgAction_s[*actions] ) ) carDlgRoadnameInx = lookupListIndex+1; memset( reload, 1, sizeof reload ); - if ( CarDlgLoadLists( TRUE, tabs, carDlgScaleInx ) ) + if ( CarDlgLoadLists( TRUE, tabs, carDlgScaleInx ) ) { currState = S_ItemSel; - else + } else { currState = S_ItemEnter; + } break; case A_LoadDataFromUpdatePart: carDlgScaleInx = carDlgUpdatePartPtr->parent->scale; @@ -3410,7 +3648,7 @@ LOG( log_carDlgState, 2, ( "Action = %s\n", carDlgAction_s[*actions] ) ) carDlgDim.truckCenterOffset = 0; carDlgIsLoco = (typeListMap[carDlgTypeInx].value&1); } else { - strcpy( carDlgProtoStr , carDlgUpdateProtoPtr->desc ); + strcpy( carDlgProtoStr, carDlgUpdateProtoPtr->desc ); carDlgDim = carDlgUpdateProtoPtr->dim; carDlgCouplerLength = (carDlgDim.coupledLength-carDlgDim.carLength)/2.0; carDlgIsLoco = (carDlgUpdateProtoPtr->options&CAR_DESC_IS_LOCO)!=0; @@ -3422,12 +3660,14 @@ LOG( log_carDlgState, 2, ( "Action = %s\n", carDlgAction_s[*actions] ) ) RELOAD_DIMS; break; case A_RecallCouplerLength: - sprintf( message, "%s-%s", carDlgPLs[I_CD_CPLRLEN].nameStr, GetScaleName(carDlgScaleInx) ); + sprintf( message, "%s-%s", carDlgPLs[I_CD_CPLRLEN].nameStr, + GetScaleName(carDlgScaleInx) ); carDlgCouplerLength = 16.0/GetScaleRatio(carDlgScaleInx); - wPrefGetFloat( carDlgPG.nameStr, message, &carDlgCouplerLength, carDlgCouplerLength ); + wPrefGetFloat( carDlgPG.nameStr, message, &carDlgCouplerLength, + carDlgCouplerLength ); break; default: - AbortProg( "carDlgDoActions: bad action" ); + CHECKMSG( FALSE, ( "carDlgDoActions: bad action %d", (int)(actions[-1]) ) ); break; } } @@ -3435,16 +3675,17 @@ LOG( log_carDlgState, 2, ( "Action = %s\n", carDlgAction_s[*actions] ) ) static void CarDlgDoStateActions( - carDlgAction_e * actions ) + carDlgAction_e * actions ) { CarDlgDoActions( actions ); -LOG( log_carDlgState, 1, ( " ==> S_%s\n", carDlgState_s[currState] ) ) + LOG( log_carDlgState, 1, ( " ==> S_%s\n", carDlgState_s[currState] ) ) } static void CarDlgStateMachine( - carDlgTransistion_e transistion ) + carDlgTransistion_e transistion ) { -LOG( log_carDlgState, 1, ( "S_%s[T_%s]\n", carDlgState_s[currState], carDlgTransistion_s[transistion] ) ) + LOG( log_carDlgState, 1, ( "S_%s[T_%s]\n", carDlgState_s[currState], + carDlgTransistion_s[transistion] ) ) CarDlgDoStateActions( stateMachine[currState][transistion] ); } @@ -3473,9 +3714,9 @@ static BOOL_T CheckCarDlgItemIndex( long * index ) void CarDlgError( - wBool_t ok, - paramData_p p, - char * msg ) + wBool_t ok, + paramData_p p, + char * msg ) { p->bInvalid = !ok; ParamHilite( p->group->win, p->control, !ok ); @@ -3485,9 +3726,9 @@ void CarDlgError( static void CarDlgUpdate( - paramGroup_p pg, - int inx, - void * valueP ) + paramGroup_p pg, + int inx, + void * valueP ) { BOOL_T redraw = FALSE; roadnameMap_p roadnameMapP; @@ -3510,49 +3751,60 @@ static void CarDlgUpdate( ratio = (S_PROTO?1.0:GetScaleRatio(carDlgScaleInx)); -LOG( log_carDlgState, 3, ( "CarDlgUpdate( %d )\n", inx ) ) + LOG( log_carDlgState, 3, ( "CarDlgUpdate( %d )\n", inx ) ) switch ( inx ) { case -1: - if ( carDlgDim.truckCenter > 0 && carDlgDim.carLength > carDlgDim.truckCenter ) { - carDlgTruckOffsetL = (carDlgDim.carLength - carDlgDim.truckCenter)/2 - carDlgDim.truckCenterOffset; - carDlgTruckOffsetR = (carDlgDim.carLength - carDlgDim.truckCenter)/2 + carDlgDim.truckCenterOffset; - } - else { + if ( carDlgDim.truckCenter > 0 + && carDlgDim.carLength > carDlgDim.truckCenter ) { + carDlgTruckOffsetL = (carDlgDim.carLength - carDlgDim.truckCenter)/2 - + carDlgDim.truckCenterOffset; + carDlgTruckOffsetR = (carDlgDim.carLength - carDlgDim.truckCenter)/2 + + carDlgDim.truckCenterOffset; + } else { carDlgTruckOffsetL = 0; carDlgTruckOffsetR = 0; } - carDlgCarLengthClock = carDlgCoupledLengthClock = carDlgTruckCenterClock = carDlgCouplerLengthClock = carDlgClock = 0; + carDlgCarLengthClock = carDlgCoupledLengthClock = carDlgTruckCenterClock = + carDlgCouplerLengthClock = carDlgClock = 0; redraw = TRUE; break; case I_CD_MANUF_LIST: carDlgChanged++; - wListGetValues( (wList_p)pg->paramPtr[inx].control, carDlgManufStr, sizeof carDlgManufStr, NULL, NULL ); + wListGetValues( (wList_p)pg->paramPtr[inx].control, carDlgManufStr, + sizeof carDlgManufStr, NULL, NULL ); if ( carDlgManufInx < 0 || - wListGetItemContext( (wList_p)pg->paramPtr[inx].control, carDlgManufInx ) == NULL ) + wListGetItemContext( (wList_p)pg->paramPtr[inx].control, + carDlgManufInx ) == NULL ) { CarDlgStateMachine( T_ItemEnter ); + } #ifdef LATER else if ( strcasecmp( carDlgManufStr, "unknown" ) == 0 || - strcasecmp( carDlgManufStr, "custom" ) == 0 ) + strcasecmp( carDlgManufStr, "custom" ) == 0 ) { CarDlgStateMachine( T_ItemEnter ); + } #endif - else + else { CarDlgStateMachine( T_ItemSel ); + } /*ParamControlShow( &carDlgPG, I_CD_MANUF_LIST, TRUE );*/ break; case I_CD_PROTOKIND_LIST: carDlgChanged++; - carDlgTypeInx = (int)VP2L(wListGetItemContext( (wList_p)pg->paramPtr[inx].control, carDlgKindInx )); + carDlgTypeInx = (int)VP2L(wListGetItemContext( (wList_p) + pg->paramPtr[inx].control, carDlgKindInx )); if ( S_PART || (currState==S_ItemEnter) ) { CarDlgLoadProtoList( NULL, 0, FALSE ); } else { parentP = NULL; - if ( carDlgProtoInx >= 0 ) - parentP = (carPartParent_p)wListGetItemContext( (wList_p)pg->paramPtr[I_CD_PROTOTYPE_LIST].control, carDlgProtoInx ); + if ( carDlgProtoInx >= 0 ) { + parentP = (carPartParent_p)wListGetItemContext( (wList_p) + pg->paramPtr[I_CD_PROTOTYPE_LIST].control, carDlgProtoInx ); + } CarDlgLoadProtoList( carDlgManufStr, (parentP?parentP->scale:0), FALSE ); } CarDlgStateMachine( T_ProtoSel ); @@ -3560,13 +3812,15 @@ LOG( log_carDlgState, 3, ( "CarDlgUpdate( %d )\n", inx ) ) case I_CD_PROTOTYPE_LIST: carDlgChanged++; - wListGetValues( (wList_p)pg->paramPtr[inx].control, carDlgProtoStr, sizeof carDlgProtoStr, NULL, NULL ); + wListGetValues( (wList_p)pg->paramPtr[inx].control, carDlgProtoStr, + sizeof carDlgProtoStr, NULL, NULL ); CarDlgStateMachine( T_ProtoSel ); break; case I_CD_PARTNO_LIST: carDlgChanged++; - wListGetValues( (wList_p)pg->paramPtr[inx].control, carDlgPartnoStr, sizeof carDlgPartnoStr, NULL, NULL ); + wListGetValues( (wList_p)pg->paramPtr[inx].control, carDlgPartnoStr, + sizeof carDlgPartnoStr, NULL, NULL ); if ( carDlgPartnoInx >= 0 ) { CarDlgStateMachine( T_PartnoSel ); } else { @@ -3582,10 +3836,12 @@ LOG( log_carDlgState, 3, ( "CarDlgUpdate( %d )\n", inx ) ) ParamLoadControl( &carDlgPG, I_CD_DISPMODE ); break; } - for ( inx=B; inx<C; inx++ ) + for ( inx=B; inx<C; inx++ ) { ParamControlShow( &carDlgPG, inx, carDlgDispMode==1 ); - for ( inx=C; inx<D; inx++ ) + } + for ( inx=C; inx<D; inx++ ) { ParamControlShow( &carDlgPG, inx, carDlgDispMode==0 ); + } if ( carDlgDispMode == 0 && carDlgUpdateItemPtr != NULL ) { ParamControlShow( &carDlgPG, I_CD_QTY, FALSE ); ParamControlShow( &carDlgPG, I_CD_MLTNUM, FALSE ); @@ -3597,13 +3853,15 @@ LOG( log_carDlgState, 3, ( "CarDlgUpdate( %d )\n", inx ) ) carDlgChanged++; roadnameMapP = NULL; if ( *(long*)valueP == 0 ) { - roadnameMapP = NULL; - carDlgRoadnameStr[0] = '\0'; + roadnameMapP = NULL; + carDlgRoadnameStr[0] = '\0'; } else if ( *(long*)valueP > 0 ) { - roadnameMapP = (roadnameMap_p)wListGetItemContext( (wList_p)pg->paramPtr[I_CD_ROADNAME_LIST].control, (wIndex_t)*(long*)valueP ); - strcpy( carDlgRoadnameStr, roadnameMapP->roadname ); + roadnameMapP = (roadnameMap_p)wListGetItemContext( (wList_p) + pg->paramPtr[I_CD_ROADNAME_LIST].control, (wIndex_t)*(long*)valueP ); + strcpy( carDlgRoadnameStr, roadnameMapP->roadname ); } else { - wListGetValues( (wList_p)pg->paramPtr[I_CD_ROADNAME_LIST].control, carDlgRoadnameStr, sizeof carDlgRoadnameStr, NULL, NULL ); + wListGetValues( (wList_p)pg->paramPtr[I_CD_ROADNAME_LIST].control, + carDlgRoadnameStr, sizeof carDlgRoadnameStr, NULL, NULL ); cmp_key.name = carDlgRoadnameStr; cmp_key.len = (int)strlen(carDlgRoadnameStr); roadnameMapP = LookupListElem( &roadnameMap_da, &cmp_key, Cmp_roadnameMap, 0 ); @@ -3619,23 +3877,26 @@ LOG( log_carDlgState, 3, ( "CarDlgUpdate( %d )\n", inx ) ) case I_CD_CARLENGTH: carDlgChanged++; if ( carDlgDim.carLength == 0.0 ) { - carDlgCarLengthClock = 0; + carDlgCarLengthClock = 0; } else if ( carDlgDim.carLength < 100/ratio ) { return; - } else if ( carDlgCouplerLength != 0 && ( carDlgDim.coupledLength == 0 || carDlgCouplerLengthClock >= carDlgCoupledLengthClock ) ) { + } else if ( carDlgCouplerLength != 0 && ( carDlgDim.coupledLength == 0 + || carDlgCouplerLengthClock >= carDlgCoupledLengthClock ) ) { len = carDlgDim.carLength+carDlgCouplerLength*2.0; if ( len > 0 ) { carDlgDim.coupledLength = len; ParamLoadControl( &carDlgPG, I_CD_CPLDLEN ); } carDlgCarLengthClock = ++carDlgClock; - } else if ( carDlgDim.coupledLength != 0 && ( carDlgCouplerLength == 0 || carDlgCoupledLengthClock > carDlgCouplerLengthClock ) ) { + } else if ( carDlgDim.coupledLength != 0 && ( carDlgCouplerLength == 0 + || carDlgCoupledLengthClock > carDlgCouplerLengthClock ) ) { len = (carDlgDim.coupledLength-carDlgDim.carLength)/2.0; if ( len > 0 ) { carDlgCouplerLength = len; ParamLoadControl( &carDlgPG, I_CD_CPLRLEN ); if ( !S_PROTO ) { - sprintf( message, "%s-%s", carDlgPLs[I_CD_CPLRLEN].nameStr, GetScaleName(carDlgScaleInx) ); + sprintf( message, "%s-%s", carDlgPLs[I_CD_CPLRLEN].nameStr, + GetScaleName(carDlgScaleInx) ); wPrefSetFloat( carDlgPG.nameStr, message, carDlgCouplerLength ); } } @@ -3651,18 +3912,21 @@ LOG( log_carDlgState, 3, ( "CarDlgUpdate( %d )\n", inx ) ) carDlgCoupledLengthClock = 0; } else if ( carDlgDim.coupledLength < 100/ratio ) { return; - } else if ( carDlgDim.carLength != 0 && ( carDlgCouplerLength == 0 || carDlgCarLengthClock > carDlgCouplerLengthClock ) ) { + } else if ( carDlgDim.carLength != 0 && ( carDlgCouplerLength == 0 + || carDlgCarLengthClock > carDlgCouplerLengthClock ) ) { len = (carDlgDim.coupledLength-carDlgDim.carLength)/2.0; if ( len > 0 ) { carDlgCouplerLength = len; ParamLoadControl( &carDlgPG, I_CD_CPLRLEN ); if ( !S_PROTO ) { - sprintf( message, "%s-%s", carDlgPLs[I_CD_CPLRLEN].nameStr, GetScaleName(carDlgScaleInx) ); + sprintf( message, "%s-%s", carDlgPLs[I_CD_CPLRLEN].nameStr, + GetScaleName(carDlgScaleInx) ); wPrefSetFloat( carDlgPG.nameStr, message, carDlgCouplerLength ); } } carDlgCoupledLengthClock = ++carDlgClock; - } else if ( carDlgCouplerLength != 0 && ( carDlgDim.carLength == 0 || carDlgCouplerLengthClock >= carDlgCarLengthClock ) ) { + } else if ( carDlgCouplerLength != 0 && ( carDlgDim.carLength == 0 + || carDlgCouplerLengthClock >= carDlgCarLengthClock ) ) { len = carDlgDim.coupledLength-carDlgCouplerLength*2.0; if ( len > 0 ) { carDlgDim.carLength = len; @@ -3682,14 +3946,16 @@ LOG( log_carDlgState, 3, ( "CarDlgUpdate( %d )\n", inx ) ) break; } else if ( carDlgCouplerLength < 1/ratio ) { return; - } else if ( carDlgDim.carLength != 0 && ( carDlgDim.coupledLength == 0 || carDlgCarLengthClock >= carDlgCoupledLengthClock ) ) { + } else if ( carDlgDim.carLength != 0 && ( carDlgDim.coupledLength == 0 + || carDlgCarLengthClock >= carDlgCoupledLengthClock ) ) { len = carDlgDim.carLength+carDlgCouplerLength*2.0; if ( len > 0 ) { carDlgDim.coupledLength = len; ParamLoadControl( &carDlgPG, I_CD_CPLDLEN ); } carDlgCouplerLengthClock = ++carDlgClock; - } else if ( carDlgDim.coupledLength != 0 && ( carDlgDim.carLength == 0 || carDlgCoupledLengthClock > carDlgCarLengthClock ) ) { + } else if ( carDlgDim.coupledLength != 0 && ( carDlgDim.carLength == 0 + || carDlgCoupledLengthClock > carDlgCarLengthClock ) ) { len = carDlgDim.coupledLength-carDlgCouplerLength*2.0; if ( len > 0 ) { carDlgDim.carLength = len; @@ -3699,15 +3965,16 @@ LOG( log_carDlgState, 3, ( "CarDlgUpdate( %d )\n", inx ) ) carDlgCouplerLengthClock = ++carDlgClock; } if ( !S_PROTO ) { - sprintf( message, "%s-%s", carDlgPLs[I_CD_CPLRLEN].nameStr, GetScaleName(carDlgScaleInx) ); - wPrefSetFloat( carDlgPG.nameStr, message, carDlgCouplerLength ); + sprintf( message, "%s-%s", carDlgPLs[I_CD_CPLRLEN].nameStr, + GetScaleName(carDlgScaleInx) ); + wPrefSetFloat( carDlgPG.nameStr, message, carDlgCouplerLength ); } redraw = TRUE; break; case I_CD_CARWIDTH: carDlgChanged++; - if ( carDlgDim.carLength < 30/ratio ) return; + if ( carDlgDim.carLength < 30/ratio ) { return; } redraw = TRUE; break; @@ -3727,16 +3994,19 @@ LOG( log_carDlgState, 3, ( "CarDlgUpdate( %d )\n", inx ) ) if ( carDlgDim.truckCenterOffset == 0 ) { carDlgTruckOffsetL = carDlgDim.truckCenter/2; carDlgTruckOffsetR = carDlgTruckOffsetL; - } else if (carDlgDim.carLength - carDlgDim.truckCenter > 2*fabs(carDlgDim.truckCenterOffset)) { + } else if (carDlgDim.carLength - carDlgDim.truckCenter > 2*fabs( + carDlgDim.truckCenterOffset)) { carDlgTruckOffsetL = carDlgDim.truckCenter/2 - carDlgDim.truckCenterOffset; carDlgTruckOffsetR = carDlgDim.truckCenter/2 + carDlgDim.truckCenterOffset; } else { carDlgTruckOffsetL = 0; carDlgTruckOffsetR = 0; } - if ( 2*carDlgDim.truckCenterOffset > carDlgDim.carLength - carDlgDim.truckCenter) { + if ( 2*carDlgDim.truckCenterOffset > carDlgDim.carLength - + carDlgDim.truckCenter) { ok = FALSE; - CarDlgError( ok, &carDlgPLs[I_CD_TRKOFFSET], _("Truck Center Offset plus Truck Centers must be less than Car Length") ); + CarDlgError( ok, &carDlgPLs[I_CD_TRKOFFSET], + _("Truck Center Offset plus Truck Centers must be less than Car Length") ); } redraw = TRUE; break; @@ -3746,11 +4016,13 @@ LOG( log_carDlgState, 3, ( "CarDlgUpdate( %d )\n", inx ) ) if ( carDlgDim.truckCenter == 0 ) { carDlgTruckOffsetL = 0; carDlgTruckOffsetR = 0; - } else if ( carDlgDim.truckCenter < 100/ratio /*&& carDlgDim.carLength == 0.0*/ ) { + } else if ( carDlgDim.truckCenter < + 100/ratio /*&& carDlgDim.carLength == 0.0*/ ) { carDlgTruckOffsetL = 0; carDlgTruckOffsetR = 0; return; - } else if ( carDlgDim.carLength - carDlgDim.truckCenter > 2*fabs(carDlgDim.truckCenterOffset) ) { + } else if ( carDlgDim.carLength - carDlgDim.truckCenter > 2*fabs( + carDlgDim.truckCenterOffset) ) { carDlgTruckOffsetL = carDlgDim.truckCenter/2-carDlgDim.truckCenterOffset; carDlgTruckOffsetR = carDlgDim.truckCenter/2+carDlgDim.truckCenterOffset; } else { @@ -3767,7 +4039,8 @@ LOG( log_carDlgState, 3, ( "CarDlgUpdate( %d )\n", inx ) ) case I_CD_PURPRC: case I_CD_CURPRC: carDlgChanged++; - *(FLOAT_T*)(pg->paramPtr[inx].context) = strtod( (char*)pg->paramPtr[inx].valueP, &cp ); + *(FLOAT_T*)(pg->paramPtr[inx].context) = strtod( (char*) + pg->paramPtr[inx].valueP, &cp ); if ( cp==NULL || *cp!='\0' ) { *(FLOAT_T*)(pg->paramPtr[inx].context) = -1; ok = FALSE; @@ -3779,17 +4052,18 @@ LOG( log_carDlgState, 3, ( "CarDlgUpdate( %d )\n", inx ) ) case I_CD_COND: carDlgChanged++; carDlgCondition = - (carDlgConditionInx==0)?0: - (carDlgConditionInx==1)?100: - (carDlgConditionInx==2)?80: - (carDlgConditionInx==3)?60: - (carDlgConditionInx==4)?40:20; + (carDlgConditionInx==0)?0: + (carDlgConditionInx==1)?100: + (carDlgConditionInx==2)?80: + (carDlgConditionInx==3)?60: + (carDlgConditionInx==4)?40:20; break; case I_CD_PURDAT: case I_CD_SRVDAT: carDlgChanged++; - for ( cp = (char*)pg->paramPtr[inx].valueP; *cp && isspace(*(unsigned char*)cp); cp++ ); + for ( cp = (char*)pg->paramPtr[inx].valueP; *cp + && isspace(*(unsigned char*)cp); cp++ ); if ( *cp ) { valL = strtol( cp, &cq, 10 ); if ( cq==NULL || *cq !='\0' ) { @@ -3824,10 +4098,11 @@ LOG( log_carDlgState, 3, ( "CarDlgUpdate( %d )\n", inx ) ) valL = 0; } CarDlgError( ok, &pg->paramPtr[inx], cp ); - if (inx == I_CD_PURDAT) + if (inx == I_CD_PURDAT) { carDlgPurchDate = valL; - else + } else { carDlgServiceDate = valL; + } break; case I_CD_TYPE_LIST: @@ -3841,12 +4116,12 @@ LOG( log_carDlgState, 3, ( "CarDlgUpdate( %d )\n", inx ) ) carDlgChanged++; WriteSelectedTracksToTempSegs(); carProtoSegCnt = tempSegs_da.cnt; - carProtoSegPtr = (trkSeg_t*)tempSegs_da.ptr; + carProtoSegPtr = &tempSegs(0); CloneFilledDraw( carProtoSegCnt, carProtoSegPtr, TRUE ); GetSegBounds( zero, 0.0, carProtoSegCnt, carProtoSegPtr, &orig, &size ); if ( size.x <= 0.0 || - size.y <= 0.0 || - size.x < size.y ) { + size.y <= 0.0 || + size.x < size.y ) { NoticeMessage( MSG_CARPROTO_BADSEGS, _("Ok"), NULL ); return; } @@ -3855,7 +4130,8 @@ LOG( log_carDlgState, 3, ( "CarDlgUpdate( %d )\n", inx ) ) MoveSegs( carProtoSegCnt, carProtoSegPtr, orig ); size2.x = floor(size.x*curScaleRatio+0.5); size2.y = floor(size.y*curScaleRatio+0.5); - RescaleSegs( carProtoSegCnt, carProtoSegPtr, size2.x/size.x, size2.y/size.y, curScaleRatio ); + RescaleSegs( carProtoSegCnt, carProtoSegPtr, size2.x/size.x, size2.y/size.y, + curScaleRatio ); carDlgDim.carLength = size2.x; carDlgDim.carWidth = size2.y; carDlgDim.coupledLength = carDlgDim.carLength + 32; @@ -3893,7 +4169,8 @@ LOG( log_carDlgState, 3, ( "CarDlgUpdate( %d )\n", inx ) ) if ( checkTruckCenter && carDlgDim.carLength > 0 ) { if ( carDlgTruckOffsetL > 0 || carDlgTruckOffsetR > 0 ) { - carDlgDim.truckCenter = carDlgTruckOffsetL + carDlgTruckOffsetR; + carDlgDim.truckCenter = carDlgDim.carLength - ( carDlgTruckOffsetL + + carDlgTruckOffsetR ); carDlgDim.truckCenterOffset = (carDlgTruckOffsetR - carDlgTruckOffsetL)/2; } else { carDlgDim.truckCenter = carDlgDim.carLength * 0.75; @@ -3903,11 +4180,12 @@ LOG( log_carDlgState, 3, ( "CarDlgUpdate( %d )\n", inx ) ) ParamLoadControl( &carDlgPG, I_CD_TRKOFFSET ); } - if ( S_PART && carDlgManufStr[0] == '\0' ) + if ( S_PART && carDlgManufStr[0] == '\0' ) { ParamLoadMessage( &carDlgPG, I_CD_MSG, _("Select or Enter a Manufacturer") ); - else if ( S_ITEM && carDlgUpdateItemPtr==NULL && - ( valL = carDlgItemIndex , !CheckCarDlgItemIndex(&carDlgItemIndex) ) ) { - sprintf( message, _("Item Index %ld duplicated an existing item: updated to new value"), valL ); + } else if ( S_ITEM && carDlgUpdateItemPtr==NULL && + ( valL = carDlgItemIndex, !CheckCarDlgItemIndex(&carDlgItemIndex) ) ) { + sprintf( message, + _("Item Index %ld duplicated an existing item: updated to new value"), valL ); ParamLoadControl( &carDlgPG, I_CD_ITEMINDEX ); ParamLoadMessage( &carDlgPG, I_CD_MSG, message ); ok = TRUE; @@ -3916,8 +4194,9 @@ LOG( log_carDlgState, 3, ( "CarDlgUpdate( %d )\n", inx ) ) ok = TRUE; } - if ( redraw ) + if ( redraw ) { CarDlgRedraw( carDlgD.d, NULL, 0, 0 ); + } ParamDialogOkActive( pg, ok ); } @@ -3948,10 +4227,11 @@ static void CarDlgNewProto( void ) } carDlgUpdateProtoPtr = NULL; carDlgNewProtoPtr = NULL; - if ( S_ITEM ) + if ( S_ITEM ) { CarDlgDoStateActions( item2protoActions ); - else + } else { CarDlgDoStateActions( part2protoActions ); + } carDlgChanged = 0; } @@ -3962,8 +4242,9 @@ static void CarDlgClose( wWin_p win ) if ( carDlgChanged ) { if ( !inPlayback ) { - if ( NoticeMessage( MSG_CARDESC_CHANGED, _("Yes"), _("No") ) <= 0 ) + if ( NoticeMessage( MSG_CARDESC_CHANGED, _("Yes"), _("No") ) <= 0 ) { return; + } } else { PlaybackMessage( "Car Desc Changed\n" ); } @@ -3974,12 +4255,13 @@ static void CarDlgClose( wWin_p win ) currState = carDlgStk[carDlgStkPtr].state; carDlgChanged = carDlgStk[carDlgStkPtr].changed; if ( oldState == S_ProtoSel ) - if ( S_PART ) + if ( S_PART ) { CarDlgDoStateActions( proto2partActions ); - else + } else { CarDlgDoStateActions( proto2itemActions ); - else - CarDlgDoStateActions( part2itemActions ); + } else { + CarDlgDoStateActions( part2itemActions ); + } } else { wTextClear( (wText_p)carDlgPLs[I_CD_NOTES].control ); wHide( carDlgPG.win ); @@ -3996,27 +4278,27 @@ static void CarDlgOk( void * unused ) char * cp; long count; tabString_t tabs[7]; - char title[STR_LONG_SIZE]; + char title[STR_LONG_SIZE*2]; carItem_p itemP=NULL; carPart_p partP=NULL; carProto_p protoP; BOOL_T reloadRoadnameList = FALSE; -LOG( log_carDlgState, 3, ( "CarDlgOk()\n" ) ) + LOG( log_carDlgState, 3, ( "CarDlgOk()\n" ) ) ParamUpdate(&carDlgPG); /*ParamUpdate( &carDlgPG );*/ if ( carDlgDim.carLength <= 0.0 || - carDlgDim.carWidth <= 0.0 || - carDlgDim.truckCenter <= 0.0 || - carDlgDim.truckCenterOffset < 0.0 || - carDlgDim.coupledLength <= 0.0 ) { + carDlgDim.carWidth <= 0.0 || + carDlgDim.truckCenter <= 0.0 || + carDlgDim.truckCenterOffset < 0.0 || + carDlgDim.coupledLength <= 0.0 ) { NoticeMessage( MSG_CARDESC_VALUE_ZERO, _("Ok"), NULL ); return; } if ( carDlgDim.carLength <= carDlgDim.carWidth || - carDlgDim.truckCenter >= carDlgDim.carLength ) { + carDlgDim.truckCenter >= carDlgDim.carLength ) { NoticeMessage( MSG_CARDESC_BAD_DIM_VALUE, _("Ok"), NULL ); return; } @@ -4025,35 +4307,44 @@ LOG( log_carDlgState, 3, ( "CarDlgOk()\n" ) ) return; } - if ( S_ITEM && carDlgUpdateItemPtr==NULL && !CheckCarDlgItemIndex(&carDlgItemIndex) ) { + if ( S_ITEM && carDlgUpdateItemPtr==NULL + && !CheckCarDlgItemIndex(&carDlgItemIndex) ) { NoticeMessage( MSG_CARITEM_BAD_INDEX, _("Ok"), NULL ); ParamLoadControl( &carDlgPG, I_CD_ITEMINDEX ); return; } - if ( S_ITEM && (carDlgPurchDate<0 || carDlgServiceDate<0 || carDlgPurchPrice <0 || carDlgCurrPrice<0)) return; + if ( S_ITEM && (carDlgPurchDate<0 || carDlgServiceDate<0 || carDlgPurchPrice <0 + || carDlgCurrPrice<0)) { return; } - if ( S_PROTO && carDlgProtoStr[0] == '\0' ) return; + if ( S_PROTO && carDlgProtoStr[0] == '\0' ) { return; } - if ( S_PART && (carDlgManufStr[0] == '\0' || carDlgPartnoStr[0] == '\0')) return; + if ( S_PART && (carDlgManufStr[0] == '\0' || carDlgPartnoStr[0] == '\0')) { return; } - if ( S_ITEM && carDlgItemIndex <= 0 ) return; + if ( S_ITEM && carDlgItemIndex <= 0 ) { return; } - if ( (!S_PROTO) && carDlgCouplerMount != 0 ) + if ( (!S_PROTO) && carDlgCouplerMount != 0 ) { options |= CAR_DESC_COUPLER_MODE_BODY; - if ( carDlgIsLoco == 1 ) + } + if ( carDlgIsLoco == 1 ) { options |= CAR_DESC_IS_LOCO; + } if ( S_ITEM ) { len = wTextGetSize( (wText_p)carDlgPLs[I_CD_NOTES].control ); - sprintf( title, "%s\t%s\t%s\t%s\t%s\t%s\t%s", carDlgManufStr, carDlgProtoStr, carDlgDescStr, carDlgPartnoStr, carDlgRoadnameStr, carDlgRepmarkStr, carDlgNumberStr ); + sprintf( title, "%s\t%s\t%s\t%s\t%s\t%s\t%s", carDlgManufStr, carDlgProtoStr, + carDlgDescStr, carDlgPartnoStr, carDlgRoadnameStr, carDlgRepmarkStr, + carDlgNumberStr ); partP = NULL; if ( ( carDlgManufInx < 0 || carDlgPartnoInx < 0 ) && carDlgPartnoStr[0] ) { - partP = CarPartFind( carDlgManufStr, (int)strlen(carDlgManufStr), carDlgPartnoStr, (int)strlen(carDlgPartnoStr), carDlgScaleInx ); + partP = CarPartFind( carDlgManufStr, (int)strlen(carDlgManufStr), + carDlgPartnoStr, (int)strlen(carDlgPartnoStr), carDlgScaleInx ); if ( partP != NULL && - NoticeMessage( MSG_CARPART_DUPNAME, _("Yes"), _("No") ) <= 0 ) + NoticeMessage( MSG_CARPART_DUPNAME, _("Yes"), _("No") ) <= 0 ) { return; - partP = CarPartNew( NULL, PARAM_CUSTOM, carDlgScaleInx, title, options, typeListMap[carDlgTypeInx].value, &carDlgDim, carDlgBodyColor ); + } + partP = CarPartNew( NULL, PARAM_CUSTOM, carDlgScaleInx, title, options, + typeListMap[carDlgTypeInx].value, &carDlgDim, carDlgBodyColor ); if ( partP != NULL ) { if ( ( f = OpenCustom("a") ) ) { SetCLocale(); @@ -4068,11 +4359,11 @@ LOG( log_carDlgState, 3, ( "CarDlgOk()\n" ) ) } for ( count=0; count<carDlgQuantity; count++ ) { itemP = CarItemNew( carDlgUpdateItemPtr, - PARAM_CUSTOM, carDlgItemIndex, - carDlgScaleInx, title, options, typeListMap[carDlgTypeInx].value, - &carDlgDim, carDlgBodyColor, - carDlgPurchPrice, carDlgCurrPrice, carDlgCondition, - carDlgPurchDate, carDlgServiceDate ); + PARAM_CUSTOM, carDlgItemIndex, + carDlgScaleInx, title, options, typeListMap[carDlgTypeInx].value, + &carDlgDim, carDlgBodyColor, + carDlgPurchPrice, carDlgCurrPrice, carDlgCondition, + carDlgPurchDate, carDlgServiceDate ); if ( carDlgUpdateItemPtr==NULL ) { wPrefSetInteger( "misc", "last-car-item-index", carDlgItemIndex ); carDlgItemIndex++; @@ -4082,15 +4373,18 @@ LOG( log_carDlgState, 3, ( "CarDlgOk()\n" ) ) number = strtol( carDlgNumberStr, &cp, 10 ); if ( cp && *cp == 0 && number > 0 ) { sprintf( carDlgNumberStr, "%ld", number+1 ); - sprintf( title, "%s\t%s\t%s\t%s\t%s\t%s\t%s", carDlgManufStr, carDlgProtoStr, carDlgDescStr, carDlgPartnoStr, carDlgRoadnameStr, carDlgRepmarkStr, carDlgNumberStr ); + sprintf( title, "%s\t%s\t%s\t%s\t%s\t%s\t%s", carDlgManufStr, carDlgProtoStr, + carDlgDescStr, carDlgPartnoStr, carDlgRoadnameStr, carDlgRepmarkStr, + carDlgNumberStr ); } } } if ( len > 0 ) { - if ( itemP->data.notes ) + if ( itemP->data.notes ) { itemP->data.notes = MyRealloc( itemP->data.notes, (len+2) * sizeof(wchar_t) ); - else + } else { itemP->data.notes = MyMalloc( (len+2) * sizeof(wchar_t) ); + } // itemP->data.notes = (char*)MyMalloc( (len+2) * sizeof(wchar_t) ); wTextGetText( (wText_p)carDlgPLs[I_CD_NOTES].control, itemP->data.notes, len ); if ( itemP->data.notes[len-1] != '\n' ) { @@ -4104,10 +4398,11 @@ LOG( log_carDlgState, 3, ( "CarDlgOk()\n" ) ) itemP->data.notes = NULL; } } - if ( carDlgUpdateItemPtr==NULL ) + if ( carDlgUpdateItemPtr==NULL ) { CarInvListAdd( itemP ); - else + } else { CarInvListUpdate( itemP ); + } SetFileChanged(); reloadRoadnameList = TRUE; if ( carDlgUpdateItemPtr==NULL ) { @@ -4120,9 +4415,9 @@ LOG( log_carDlgState, 3, ( "CarDlgOk()\n" ) ) strcpy( message, _("Updated Car") ); } sprintf( message+strlen(message), "%s: %s %s %s %s %s %s", - (partP?_(" and Part"):""), - carDlgManufStr, carDlgPartnoStr, carDlgProtoStr, carDlgDescStr, - (carDlgRepmarkStr[ 0 ]?carDlgRepmarkStr:carDlgRoadnameStr), carDlgNumberStr ); + (partP?_(" and Part"):""), + carDlgManufStr, carDlgPartnoStr, carDlgProtoStr, carDlgDescStr, + (carDlgRepmarkStr[ 0 ]?carDlgRepmarkStr:carDlgRoadnameStr), carDlgNumberStr ); carDlgQuantity = 1; ParamLoadControl( &carDlgPG, I_CD_QTY ); @@ -4132,14 +4427,19 @@ LOG( log_carDlgState, 3, ( "CarDlgOk()\n" ) ) carDlgRepmarkStr[0] = '\0'; } if ( carDlgUpdatePartPtr==NULL ) { - partP = CarPartFind( carDlgManufStr, (int)strlen(carDlgManufStr), carDlgPartnoStr, (int)strlen(carDlgPartnoStr), carDlgScaleInx ); + partP = CarPartFind( carDlgManufStr, (int)strlen(carDlgManufStr), + carDlgPartnoStr, (int)strlen(carDlgPartnoStr), carDlgScaleInx ); if ( partP != NULL && - NoticeMessage( MSG_CARPART_DUPNAME, _("Yes"), _("No") ) <= 0 ) + NoticeMessage( MSG_CARPART_DUPNAME, _("Yes"), _("No") ) <= 0 ) { return; + } } - sprintf( message, "%s\t%s\t%s\t%s\t%s\t%s\t%s", carDlgManufStr, carDlgProtoStr, carDlgDescStr, carDlgPartnoStr, carDlgRoadnameStr, carDlgRepmarkStr, carDlgNumberStr ); - carDlgNewPartPtr = CarPartNew( carDlgUpdatePartPtr, PARAM_CUSTOM, carDlgScaleInx, message, options, typeListMap[carDlgTypeInx].value, - &carDlgDim, carDlgBodyColor ); + sprintf( message, "%s\t%s\t%s\t%s\t%s\t%s\t%s", carDlgManufStr, carDlgProtoStr, + carDlgDescStr, carDlgPartnoStr, carDlgRoadnameStr, carDlgRepmarkStr, + carDlgNumberStr ); + carDlgNewPartPtr = CarPartNew( carDlgUpdatePartPtr, PARAM_CUSTOM, + carDlgScaleInx, message, options, typeListMap[carDlgTypeInx].value, + &carDlgDim, carDlgBodyColor ); if ( carDlgNewPartPtr != NULL && ( f = OpenCustom("a") ) ) { SetCLocale(); CarPartWrite( f, carDlgNewPartPtr ); @@ -4147,16 +4447,22 @@ LOG( log_carDlgState, 3, ( "CarDlgOk()\n" ) ) SetUserLocale(); } reloadRoadnameList = TRUE; - sprintf( message, _("%s Part: %s %s %s %s %s %s"), carDlgUpdatePartPtr==NULL?_("Added new"):_("Updated"), carDlgManufStr, carDlgPartnoStr, carDlgProtoStr, carDlgDescStr, carDlgRepmarkStr[ 0 ]?carDlgRepmarkStr:carDlgRoadnameStr, carDlgNumberStr ); + sprintf( message, _("%s Part: %s %s %s %s %s %s"), + carDlgUpdatePartPtr==NULL?_("Added new"):_("Updated"), carDlgManufStr, + carDlgPartnoStr, carDlgProtoStr, carDlgDescStr, + carDlgRepmarkStr[ 0 ]?carDlgRepmarkStr:carDlgRoadnameStr, carDlgNumberStr ); } else if ( S_PROTO ) { if ( carDlgUpdateProtoPtr==NULL ) { protoP = CarProtoFind( carDlgProtoStr ); if ( protoP != NULL && - NoticeMessage( MSG_CARPROTO_DUPNAME, _("Yes"), _("No") ) <= 0 ) + NoticeMessage( MSG_CARPROTO_DUPNAME, _("Yes"), _("No") ) <= 0 ) { return; + } } - carDlgNewProtoPtr = CarProtoNew( carDlgUpdateProtoPtr, PARAM_CUSTOM, carDlgProtoStr, options, typeListMap[carDlgTypeInx].value, &carDlgDim, carDlgSegs_da.cnt, &carDlgSegs(0) ); + carDlgNewProtoPtr = CarProtoNew( carDlgUpdateProtoPtr, PARAM_CUSTOM, + carDlgProtoStr, options, typeListMap[carDlgTypeInx].value, &carDlgDim, + carDlgSegs_da.cnt, &carDlgSegs(0) ); if ( (f = OpenCustom("a") ) ) { SetCLocale(); CarProtoWrite( f, carDlgNewProtoPtr ); @@ -4164,8 +4470,8 @@ LOG( log_carDlgState, 3, ( "CarDlgOk()\n" ) ) SetUserLocale(); } sprintf( message, _("%s Prototype: %s%s."), - carDlgUpdateProtoPtr==NULL?_("Added new"):_("Updated"), carDlgProtoStr, - carDlgUpdateProtoPtr==NULL?_(". Enter new values or press Close"):"" ); + carDlgUpdateProtoPtr==NULL?_("Added new"):_("Updated"), carDlgProtoStr, + carDlgUpdateProtoPtr==NULL?_(". Enter new values or press Close"):"" ); } if ( reloadRoadnameList ) { @@ -4187,10 +4493,11 @@ LOG( log_carDlgState, 3, ( "CarDlgOk()\n" ) ) if ( carDlgUpdateItemPtr==NULL ) { if ( partP ) { TabStringExtract( title, 7, tabs ); - if ( CarDlgLoadLists( TRUE, tabs, GetLayoutCurScale()) ) + if ( CarDlgLoadLists( TRUE, tabs, GetLayoutCurScale()) ) { currState = S_ItemSel; - else + } else { currState = S_ItemEnter; + } ParamLoadControl( &carDlgPG, I_CD_MANUF_LIST ); ParamLoadControl( &carDlgPG, I_CD_PROTOKIND_LIST ); ParamLoadControl( &carDlgPG, I_CD_PROTOTYPE_LIST ); @@ -4208,10 +4515,11 @@ LOG( log_carDlgState, 3, ( "CarDlgOk()\n" ) ) } else if ( S_PART ) { if ( carDlgUpdatePartPtr==NULL ) { number = strtol( carDlgPartnoStr, &cp, 10 ); - if ( cp && *cp == 0 && number > 0 ) + if ( cp && *cp == 0 && number > 0 ) { sprintf( carDlgPartnoStr, "%ld", number+1 ); - else + } else { carDlgPartnoStr[0] = '\0'; + } carDlgNumberStr[0] = '\0'; ParamLoadControl( &carDlgPG, I_CD_PARTNO_STR ); ParamLoadControl( &carDlgPG, I_CD_NUMBER ); @@ -4230,11 +4538,11 @@ LOG( log_carDlgState, 3, ( "CarDlgOk()\n" ) ) static void CarDlgLayout( - paramData_t * pd, - int inx, - wWinPix_t currX, - wWinPix_t *xx, - wWinPix_t *yy ) + paramData_t * pd, + int inx, + wWinPix_t currX, + wWinPix_t *xx, + wWinPix_t *yy ) { static wWinPix_t col2pos = 0; wWinPix_t y0, y1; @@ -4252,8 +4560,9 @@ static void CarDlgLayout( break; case I_CD_CPLRLEN: case I_CD_CARWIDTH: - if ( col2pos == 0 ) + if ( col2pos == 0 ) { col2pos = wLabelWidth( _("Coupler Length") )+20; + } *xx = wControlBeside(carDlgPLs[inx-1].control) + col2pos; break; case I_CD_DESC_STR: @@ -4286,27 +4595,37 @@ static void DoCarPartDlg( carDlgAction_e *actions ) int inx; if ( carDlgPG.win == NULL ) { - ParamCreateDialog( &carDlgPG, MakeWindowTitle(_("New Car Part")), _("Add"), CarDlgOk, CarDlgClose, TRUE, CarDlgLayout, F_BLOCK|F_RESIZE|F_RECALLSIZE|PD_F_ALT_CANCELLABEL, CarDlgUpdate ); + ParamCreateDialog( &carDlgPG, MakeWindowTitle(_("New Car Part")), _("Add"), + CarDlgOk, CarDlgClose, TRUE, CarDlgLayout, + F_BLOCK|F_RESIZE|F_RECALLSIZE|PD_F_ALT_CANCELLABEL, CarDlgUpdate ); - if ( carDlgDim.carWidth==0 ) + if ( carDlgDim.carWidth==0 ) { carDlgDim.carWidth = 12.0*10.0/curScaleRatio; + } for ( pd=carDlgPG.paramPtr; pd<&carDlgPG.paramPtr[carDlgPG.paramCnt]; pd++ ) { - if ( pd->type == PD_FLOAT && pd->valueP ) { + if ( pd->type == PD_FLOAT && pd->valueP ) { sprintf( message, "%s-%s", pd->nameStr, curScaleName ); - wPrefGetFloat( carDlgPG.nameStr, message, (FLOAT_T*)pd->valueP, *(FLOAT_T*)pd->valueP ); + wPrefGetFloat( carDlgPG.nameStr, message, (FLOAT_T*)pd->valueP, + *(FLOAT_T*)pd->valueP ); } } roadnameMapChanged = TRUE; - for ( inx=0; inx<N_CONDLISTMAP; inx++ ) - wListAddValue( (wList_p)carDlgPLs[I_CD_COND].control, _(condListMap[inx].name), NULL, I2VP(condListMap[inx].value) ); + for ( inx=0; inx<N_CONDLISTMAP; inx++ ) { + wListAddValue( (wList_p)carDlgPLs[I_CD_COND].control, _(condListMap[inx].name), + NULL, I2VP(condListMap[inx].value) ); + } - for ( inx=0; inx<N_TYPELISTMAP; inx++ ) - wListAddValue( (wList_p)carDlgPLs[I_CD_TYPE_LIST].control, _(typeListMap[inx].name), NULL, I2VP(typeListMap[inx].value) ); + for ( inx=0; inx<N_TYPELISTMAP; inx++ ) { + wListAddValue( (wList_p)carDlgPLs[I_CD_TYPE_LIST].control, + _(typeListMap[inx].name), NULL, I2VP(typeListMap[inx].value) ); + } - for ( inx=0; inx<N_TYPELISTMAP; inx++ ) - wListAddValue( (wList_p)carDlgPLs[I_CD_PROTOKIND_LIST].control, _(typeListMap[inx].name), NULL, I2VP(typeListMap[inx].value) ); + for ( inx=0; inx<N_TYPELISTMAP; inx++ ) { + wListAddValue( (wList_p)carDlgPLs[I_CD_PROTOKIND_LIST].control, + _(typeListMap[inx].name), NULL, I2VP(typeListMap[inx].value) ); + } wTextSetReadonly( (wText_p)carDlgPLs[I_CD_NOTES].control, FALSE ); } @@ -4319,8 +4638,9 @@ static void DoCarPartDlg( carDlgAction_e *actions ) carDlgScaleInx = GetLayoutCurScale(); carDlgFlipToggle = FALSE; carDlgChanged = 0; - for ( paramData_p p=carDlgPLs; p < carDlgPLs + COUNT( carDlgPLs ); p++ ) + for ( paramData_p p=carDlgPLs; p < carDlgPLs + COUNT( carDlgPLs ); p++ ) { p->bInvalid = FALSE; + } CarDlgDoStateActions( actions ); @@ -4360,24 +4680,27 @@ static wIndex_t carInvSort[] = { 0, 1, 2, 3 }; static void CarInvDlgAdd( void ); static void CarInvDlgEdit( void ); -static void CarInvDlgDelete( void ); +static void CarInvDlgDeleteShelve( void ); static void CarInvDlgImportCsv( void ); static void CarInvDlgExportCsv( void ); static void CarInvDlgSaveText( void ); static void CarInvListLoad( void ); static wWinPix_t carInvColumnWidths[] = { - -40, 30, 100, -50, 50, 130, 120, 100, - -50, -50, 60, 55, 55, 40, 200 }; + -40, 30, 100, -50, 50, 130, 120, 100, + -50, -50, 60, 55, 55, 40, 200 + }; static const char * carInvColumnTitles[] = { N_("Index"), N_("Scale"), N_("Manufacturer"), N_("Part No"), N_("Type"), N_("Description"), N_("Roadname"), N_("Rep Marks"), N_("Purc Price"), N_("Curr Price"), N_("Condition"), N_("Purc Date"), N_("Srvc Date"), - N_("Locat'n"), N_("Notes") }; + N_("Locat'n"), N_("Notes") +}; static char * sortOrders[] = { N_("Index"), N_("Scale"), N_("Manufacturer"), N_("Part No"), N_("Type"), N_("Description"), N_("Roadname"), N_("RepMarks"), N_("Purch Price"), - N_("Curr Price"), N_("Condition"), N_("Purch Date"), N_("Service Date") }; + N_("Curr Price"), N_("Condition"), N_("Purch Date"), N_("Service Date") +}; #define S_INDEX (0) #define S_SCALE (1) #define S_MANUF (2) @@ -4406,27 +4729,31 @@ static paramData_t carInvPLs[] = { #define I_CI_ADD (S+2) { PD_BUTTON, CarInvDlgAdd, "add", 0, NULL, N_("Add"), 0, 0 }, #define I_CI_DELETE (S+3) - { PD_BUTTON, CarInvDlgDelete, "delete", PDO_DLGWIDE, NULL, N_("Delete") }, + { PD_BUTTON, CarInvDlgDeleteShelve, "delete", PDO_DLGWIDE, NULL, N_("Delete") }, #define I_CI_IMPORT_CSV (S+4) { PD_BUTTON, CarInvDlgImportCsv, "import", PDO_DLGWIDE, NULL, N_("Import") }, #define I_CI_EXPORT_CSV (S+5) { PD_BUTTON, CarInvDlgExportCsv, "export", 0, NULL, N_("Export") }, #define I_CI_PRINT (S+6) - { PD_BUTTON, CarInvDlgSaveText, "savetext", 0, NULL, N_("List") } }; + { PD_BUTTON, CarInvDlgSaveText, "savetext", 0, NULL, N_("List") } +}; static paramGroup_t carInvPG = { "carinv", 0, carInvPLs, COUNT( carInvPLs ) }; static carItem_p CarInvDlgFindCurrentItem( void ) { - wIndex_t selcnt = wListGetSelectedCount( (wList_p)carInvPLs[I_CI_LIST].control ); + wIndex_t selcnt = wListGetSelectedCount( (wList_p) + carInvPLs[I_CI_LIST].control ); wIndex_t inx, cnt; - if ( selcnt != 1 ) return NULL; + if ( selcnt != 1 ) { return NULL; } cnt = wListGetCount( (wList_p)carInvPLs[I_CI_LIST].control ); for ( inx=0; inx<cnt; inx++ ) - if ( wListGetItemSelected( (wList_p)carInvPLs[I_CI_LIST].control, inx ) ) + if ( wListGetItemSelected( (wList_p)carInvPLs[I_CI_LIST].control, inx ) ) { break; - if ( inx>=cnt ) return NULL; - return (carItem_p)wListGetItemContext( (wList_p)carInvPLs[I_CI_LIST].control, inx ); + } + if ( inx>=cnt ) { return NULL; } + return (carItem_p)wListGetItemContext( (wList_p)carInvPLs[I_CI_LIST].control, + inx ); } @@ -4435,11 +4762,12 @@ static void CarInvDlgFind( void * unused ) carItem_p item = CarInvDlgFindCurrentItem(); coOrd pos; ANGLE_T angle; - if ( item == NULL || item->car == NULL || IsTrackDeleted(item->car) ) return; + if ( item == NULL || item->car == NULL || IsTrackDeleted(item->car) ) { return; } CarGetPos( item->car, &pos, &angle ); CarSetVisible( item->car ); panCenter = pos; - LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); + LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, + panCenter.y ) ); PanHere( I2VP(0) ); // CarInvDlgFind } @@ -4458,55 +4786,96 @@ static void CarInvDlgAdd( void ) static void CarInvDlgEdit( void ) { carDlgUpdateItemPtr = CarInvDlgFindCurrentItem(); - if ( carDlgUpdateItemPtr == NULL ) + if ( carDlgUpdateItemPtr == NULL ) { return; + } DoCarPartDlg( itemUpdActions ); } +/** + * Move a CarItem from the layout to the Shelf + * + * \item car item to be moved + */ +EXPORT void CarItemShelve( + carItem_p item ) +{ + if ( item->car == NULL || IsTrackDeleted( item->car ) ) { return; } + DeleteTrack( item->car, FALSE ); + if (CarItemIsLoco(item)) { + LocoListChangeEntry(item->car, NULL); + } + CarItemUpdate(item); + HotBarCancel(); + InfoSubstituteControls(NULL, NULL); +} + -static void CarInvDlgDelete( void ) +static void CarInvDlgDeleteShelve( void ) { carItem_p item; wIndex_t inx, inx1, cnt, selcnt; + wBool_t bShowMsg = FALSE; + wBool_t bNeedReload = FALSE; selcnt = wListGetSelectedCount( (wList_p)carInvPLs[I_CI_LIST].control ); - if ( selcnt == 0 ) - return; - if ( NoticeMessage( MSG_CARINV_DELETE_CONFIRM, _("Yes"), _("No"), selcnt ) <= 0 ) + if ( selcnt == 0 ) { return; + } cnt = wListGetCount( (wList_p)carInvPLs[I_CI_LIST].control ); for ( inx=0; inx<cnt; inx++ ) { - if ( !wListGetItemSelected( (wList_p)carInvPLs[I_CI_LIST].control, inx ) ) + if ( !wListGetItemSelected( (wList_p)carInvPLs[I_CI_LIST].control, inx ) ) { continue; - item = (carItem_p)wListGetItemContext( (wList_p)carInvPLs[I_CI_LIST].control, inx ); - if ( item == NULL ) - continue; - if ( item->car && !IsTrackDeleted(item->car) ) + } + item = (carItem_p)wListGetItemContext( (wList_p)carInvPLs[I_CI_LIST].control, + inx ); + if ( item == NULL ) { continue; - wListDelete( (wList_p)carInvPLs[I_CI_LIST].control, inx ); - if ( item->title ) MyFree( item->title ); - if ( item->data.number ) MyFree( item->data.number ); - MyFree( item ); - for ( inx1=inx; inx1<carItemInfo_da.cnt-1; inx1++ ) - carItemInfo(inx1) = carItemInfo(inx1+1); - carItemInfo_da.cnt -= 1; - inx--; - cnt--; + } + if ( item->car && !IsTrackDeleted(item->car) ) { + // Shelve car from Layout + CarItemShelve( item ); + bNeedReload = TRUE; + } else { + // Delete car from Inventory + if ( ! bShowMsg ) { + if ( NoticeMessage( MSG_CARINV_DELETE_CONFIRM, + _("Yes"), _("No"), selcnt ) <= 0 ) { + return; + } + bShowMsg = TRUE; + } + wListDelete( (wList_p)carInvPLs[I_CI_LIST].control, inx ); + if ( item->title ) { MyFree( item->title ); } + if ( item->data.number ) { MyFree( item->data.number ); } + MyFree( item ); + for ( inx1=inx; inx1<carItemInfo_da.cnt-1; inx1++ ) { + carItemInfo(inx1) = carItemInfo(inx1+1); + } + carItemInfo_da.cnt -= 1; + inx--; + cnt--; + } + } + if ( bNeedReload ) { + CarInvListLoad(); + MainRedraw(); // Shelve Car from layout } SetFileChanged(); carInvInx = -1; ParamLoadControl( &carInvPG, I_CI_LIST ); ParamControlActive( &carInvPG, I_CI_EDIT, FALSE ); ParamControlActive( &carInvPG, I_CI_DELETE, FALSE ); + wButtonSetLabel( (wButton_p)(carInvPLs[I_CI_DELETE].control), "" ); ParamControlActive( &carInvPG, I_CI_EXPORT_CSV, carItemInfo_da.cnt > 0 ); ParamDialogOkActive( &carInvPG, FALSE ); } static int CarInvSaveText( - int files, - char ** fileName, - void * data ) + int files, + char ** fileName, + void * data ) { FILE * f; carItem_p item; @@ -4516,13 +4885,14 @@ static int CarInvSaveText( char * cp0, * cp1; int len; - assert( fileName != NULL ); - assert( files == 1 ); + CHECK( fileName != NULL ); + CHECK( files == 1 ); SetCurrentPath( CARSPATHKEY, fileName[0] ); f = fopen( fileName[0], "w" ); if ( f == NULL ) { - NoticeMessage( MSG_OPEN_FAIL, _("Continue"), NULL, _("Car Inventory"), fileName[0], strerror(errno) ); + NoticeMessage( MSG_OPEN_FAIL, _("Continue"), NULL, _("Car Inventory"), + fileName[0], strerror(errno) ); return FALSE; } @@ -4532,35 +4902,40 @@ static int CarInvSaveText( TabStringExtract( item->title, 7, tabs ); sprintf( message, "%ld", item->index ); width = (int)strlen( message ); - if ( width > widths[0] ) widths[0] = width; - width = (int)strlen(GetScaleName(item->scaleInx)) + 1 + tabs[T_MANUF].len + 1 + tabs[T_PART].len; - if ( width > widths[1] ) widths[1] = width; - if ( tabs[T_PROTO].len > widths[2] ) widths[2] = tabs[T_PROTO].len; + if ( width > widths[0] ) { widths[0] = width; } + width = (int)strlen(GetScaleName(item->scaleInx)) + 1 + tabs[T_MANUF].len + 1 + + tabs[T_PART].len; + if ( width > widths[1] ) { widths[1] = width; } + if ( tabs[T_PROTO].len > widths[2] ) { widths[2] = tabs[T_PROTO].len; } width = tabs[T_REPMARK].len + tabs[T_NUMBER].len; - if ( tabs[T_REPMARK].len > 0 && tabs[T_NUMBER].len > 0 ) + if ( tabs[T_REPMARK].len > 0 && tabs[T_NUMBER].len > 0 ) { width += 1; - if ( width > widths[3] ) widths[3] = width; - if ( item->data.purchDate > 0 ) widths[4] = 8; + } + if ( width > widths[3] ) { widths[3] = width; } + if ( item->data.purchDate > 0 ) { widths[4] = 8; } if ( item->data.purchPrice > 0 ) { sprintf( message, "%0.2f", item->data.purchPrice ); width = (int)strlen(message); - if ( width > widths[5] ) widths[5] = width; + if ( width > widths[5] ) { widths[5] = width; } } - if ( item->data.condition != 0 ) + if ( item->data.condition != 0 ) { widths[6] = 5; + } if ( item->data.currPrice > 0 ) { sprintf( message, "%0.2f", item->data.currPrice ); width = (int)strlen(message); - if ( width > widths[7] ) widths[7] = width; + if ( width > widths[7] ) { widths[7] = width; } } - if ( item->data.serviceDate > 0 ) widths[8] = 8; + if ( item->data.serviceDate > 0 ) { widths[8] = 8; } } - fprintf( f, "%-*.*s %-*.*s %-*.*s %-*.*s", widths[0], widths[0], "#", widths[1], widths[1], "Part", widths[2], widths[2], "Description", widths[3], widths[3], "Rep Mark" ); - if ( widths[4] ) fprintf( f, " %-*.*s", widths[4], widths[4], "PurDate" ); - if ( widths[5] ) fprintf( f, " %-*.*s", widths[5], widths[5], "PurPrice" ); - if ( widths[6] ) fprintf( f, " %-*.*s", widths[6], widths[6], "Cond" ); - if ( widths[7] ) fprintf( f, " %-*.*s", widths[7], widths[7], "CurPrice" ); - if ( widths[8] ) fprintf( f, " %-*.*s", widths[8], widths[8], "SrvDate" ); + fprintf( f, "%-*.*s %-*.*s %-*.*s %-*.*s", widths[0], widths[0], "#", widths[1], + widths[1], "Part", widths[2], widths[2], "Description", widths[3], widths[3], + "Rep Mark" ); + if ( widths[4] ) { fprintf( f, " %-*.*s", widths[4], widths[4], "PurDate" ); } + if ( widths[5] ) { fprintf( f, " %-*.*s", widths[5], widths[5], "PurPrice" ); } + if ( widths[6] ) { fprintf( f, " %-*.*s", widths[6], widths[6], "Cond" ); } + if ( widths[7] ) { fprintf( f, " %-*.*s", widths[7], widths[7], "CurPrice" ); } + if ( widths[8] ) { fprintf( f, " %-*.*s", widths[8], widths[8], "SrvDate" ); } fprintf( f, "\n" ); for ( inx=0; inx<carItemInfo_da.cnt; inx++ ) { @@ -4569,11 +4944,14 @@ static int CarInvSaveText( sprintf( message, "%ld", item->index ); fprintf( f, "%.*s", widths[0], message ); width = tabs[T_MANUF].len + 1 + tabs[T_PART].len; - sprintf( message, "%s %.*s %.*s", GetScaleName(item->scaleInx), tabs[T_MANUF].len, tabs[T_MANUF].ptr, tabs[T_PART].len, tabs[T_PART].ptr ); + sprintf( message, "%s %.*s %.*s", GetScaleName(item->scaleInx), + tabs[T_MANUF].len, tabs[T_MANUF].ptr, tabs[T_PART].len, tabs[T_PART].ptr ); fprintf( f, " %-*s", widths[1], message ); fprintf( f, " %-*.*s", widths[2], tabs[T_PROTO].len, tabs[T_PROTO].ptr ); width = tabs[T_REPMARK].len + tabs[T_NUMBER].len; - sprintf( message, "%.*s%s%.*s", tabs[T_REPMARK].len, tabs[T_REPMARK].ptr, (tabs[T_REPMARK].len > 0 && tabs[T_NUMBER].len > 0)?" ":"", tabs[T_NUMBER].len, tabs[T_NUMBER].ptr ); + sprintf( message, "%.*s%s%.*s", tabs[T_REPMARK].len, tabs[T_REPMARK].ptr, + (tabs[T_REPMARK].len > 0 + && tabs[T_NUMBER].len > 0)?" ":"", tabs[T_NUMBER].len, tabs[T_NUMBER].ptr ); fprintf( f, " %-*s", widths[3], message ); if ( widths[4] > 0 ) { if ( item->data.purchDate > 0 ) { @@ -4593,7 +4971,8 @@ static int CarInvSaveText( } if ( widths[6] > 0 ) { if ( item->data.condition != 0 ) { - fprintf( f, " %-*.*s", widths[6], widths[6], condListMap[MapCondition(item->data.condition)].name ); + fprintf( f, " %-*.*s", widths[6], widths[6], + condListMap[MapCondition(item->data.condition)].name ); } else { fprintf( f, " %*s", widths[6], " " ); } @@ -4623,12 +5002,14 @@ static int CarInvSaveText( len = (int)(cp1-cp0); } else { len = (int)strlen( cp0 ); - if ( len == 0 ) + if ( len == 0 ) { break; + } } fprintf( f, "%*.*s %*.*s\n", widths[0], widths[0], " ", len, len, cp0 ); - if ( cp1 == NULL ) + if ( cp1 == NULL ) { break; + } cp0 = cp1+1; } } @@ -4643,16 +5024,17 @@ static void CarInvDlgSaveText( void ) { if ( carInvSaveText_fs == NULL ) carInvSaveText_fs = wFilSelCreate( mainW, FS_SAVE, 0, _("List Cars"), - "Text (*.txt)|*.txt", CarInvSaveText, NULL ); + "Text (*.txt)|*.txt", CarInvSaveText, NULL ); wFilSelect( carInvSaveText_fs, GetCurrentPath(CARSPATHKEY)); } static char *carCsvColumnTitles[] = { - "Index", "Scale", "Manufacturer", "Type", "Partno", "Prototype", - "Description", "Roadname", "Repmark", "Number", "Options", "CarLength", - "CarWidth", "CoupledLength", "TruckOffset", "TruckCenter", "Color", "PurchPrice", - "CurrPrice", "Condition", "PurchDate", "ServiceDate", "Notes" }; + "Index", "Scale", "Manufacturer", "Type", "Partno", "Prototype", + "Description", "Roadname", "Repmark", "Number", "Options", "CarLength", + "CarWidth", "CoupledLength", "TruckOffset", "TruckCenter", "Color", "PurchPrice", + "CurrPrice", "Condition", "PurchDate", "ServiceDate", "Notes" +}; #define M_INDEX (0) #define M_SCALE (1) #define M_MANUF (2) @@ -4680,10 +5062,10 @@ static char *carCsvColumnTitles[] = { static int ParseCsvLine( - char * line, - int max_elem, - tabString_t * tabs, - int * map ) + char * line, + int max_elem, + tabString_t * tabs, + int * map ) { int elem = 0; char * cp, * cq, * ptr; @@ -4698,7 +5080,7 @@ static int ParseCsvLine( } elem = 0; while ( *cp && elem < max_elem ) { - while ( *cp == ' ' ) cp++; + while ( *cp == ' ' ) { cp++; } if ( *cp == ',' ) { ptr = ""; len = 0; @@ -4714,7 +5096,7 @@ static int ParseCsvLine( *cq++ = *cp++; } cp++; - if ( *cp!='"' ) break; + if ( *cp!='"' ) { break; } *cq++ = *cp++; } if ( *cp && *cp != ',' ) { @@ -4728,10 +5110,10 @@ static int ParseCsvLine( len = (int)(cp-ptr); } if ( map[elem] >= 0 ) { - tabs[map[elem]].ptr = ptr; - tabs[map[elem]].len = len; + tabs[map[elem]].ptr = ptr; + tabs[map[elem]].len = len; } - if ( *cp ) cp++; + if ( *cp ) { cp++; } elem++; } return elem; @@ -4739,9 +5121,9 @@ static int ParseCsvLine( static int CarInvImportCsv( - int files, - char **fileName, - void * data ) + int files, + char **fileName, + void * data ) { FILE * f; carItem_p item; @@ -4759,13 +5141,14 @@ static int CarInvImportCsv( carPart_p partP; int requiredCols; - assert( fileName != NULL ); - assert( files == 1 ); + CHECK( fileName != NULL ); + CHECK( files == 1 ); SetCurrentPath( CARSPATHKEY, fileName[0] ); f = fopen( fileName[0], "r" ); if ( f == NULL ) { - NoticeMessage( MSG_OPEN_FAIL, _("Continue"), NULL, _("Import Cars"), fileName[0], strerror(errno) ); + NoticeMessage( MSG_OPEN_FAIL, _("Continue"), NULL, _("Import Cars"), + fileName[0], strerror(errno) ); return FALSE; } @@ -4777,28 +5160,30 @@ static int CarInvImportCsv( SetUserLocale(); return FALSE; } - for ( j=0; j<40; j++ ) map[j] = j; + for ( j=0; j<40; j++ ) { map[j] = j; } numCol = ParseCsvLine( message, 40, tabs, map ); if ( numCol <= 0 ) { fclose( f ); SetUserLocale(); return FALSE; } - for ( j=0; j<40; j++ ) map[j] = -1; + for ( j=0; j<40; j++ ) { map[j] = -1; } requiredCols = 0; for ( i=0; i<numCol; i++ ) { for ( j=0; j<COUNT( carCsvColumnTitles ); j++ ) { if ( TabStringCmp( carCsvColumnTitles[j], &tabs[i] ) == 0 ) { if ( map[i] >= 0 ) { - NoticeMessage( MSG_CARIMP_DUP_COLUMNS, _("Continue"), NULL, carCsvColumnTitles[j] ); + NoticeMessage( MSG_CARIMP_DUP_COLUMNS, _("Continue"), NULL, + carCsvColumnTitles[j] ); fclose( f ); SetUserLocale(); return FALSE; } map[i] = j; /*j = COUNT( carCsvColumnTitles );*/ - if ( j == M_SCALE || j == M_PROTO || j == M_MANUF || j == M_PARTNO ) + if ( j == M_SCALE || j == M_PROTO || j == M_MANUF || j == M_PARTNO ) { requiredCols++; + } } } if ( map[i] == -1 ) { @@ -4815,7 +5200,7 @@ static int CarInvImportCsv( } while ( fgets( message, sizeof message, f ) != NULL ) { cnt = ParseCsvLine( message, 40, tabs, map ); - if ( cnt > numCol ) cnt = numCol; + if ( cnt > numCol ) { cnt = numCol; } tabs[M_SCALE].ptr[tabs[M_SCALE].len] = '\0'; scale = LookupScale( tabs[M_SCALE].ptr ); tabs[M_SCALE].ptr[tabs[M_SCALE].len] = ','; @@ -4835,9 +5220,10 @@ static int CarInvImportCsv( } #ifdef OBSOLETE if ( TabStringCmp( "Unknown", &tabs[M_MANUF] ) != 0 && - TabStringCmp( "Custom", &tabs[M_MANUF] ) != 0 ) { + TabStringCmp( "Custom", &tabs[M_MANUF] ) != 0 ) { if ( tabs[M_PARTNO].len == 0 ) { - rc = NoticeMessage( MSG_CARIMP_MISSING_PARTNO, _("Continue"), _("Stop"), tabs[M_MANUF].ptr ); + rc = NoticeMessage( MSG_CARIMP_MISSING_PARTNO, _("Continue"), _("Stop"), + tabs[M_MANUF].ptr ); if ( rc <= 0 ) { fclose( f ); SetUserLocale(); @@ -4853,8 +5239,10 @@ static int CarInvImportCsv( dim.truckCenter = TabGetFloat( &tabs[M_TRKCENTER] ); dim.truckCenterOffset = TabGetFloat( &tabs[M_TRKOFFSET] ); partP = NULL; - if ( tabs[M_MANUF].len > 0 && tabs[M_PARTNO].len > 0 ) - partP = CarPartFind( tabs[M_MANUF].ptr, tabs[M_MANUF].len, tabs[M_PARTNO].ptr, tabs[M_PARTNO].len, scale ); + if ( tabs[M_MANUF].len > 0 && tabs[M_PARTNO].len > 0 ) { + partP = CarPartFind( tabs[M_MANUF].ptr, tabs[M_MANUF].len, tabs[M_PARTNO].ptr, + tabs[M_PARTNO].len, scale ); + } if ( partP ) { TabStringExtract( partP->title, 7, partTabs ); if ( tabs[M_PROTO].len == 0 && partTabs[T_PROTO].len > 0 ) { tabs[M_PROTO].ptr = partTabs[T_PROTO].ptr; tabs[M_PROTO].len = partTabs[T_PROTO].len; } @@ -4862,13 +5250,13 @@ static int CarInvImportCsv( if ( tabs[M_ROADNAME].len == 0 && partTabs[T_ROADNAME].len > 0 ) { tabs[M_ROADNAME].ptr = partTabs[T_ROADNAME].ptr; tabs[M_ROADNAME].len = partTabs[T_ROADNAME].len; } if ( tabs[M_REPMARK].len == 0 && partTabs[T_REPMARK].len > 0 ) { tabs[M_REPMARK].ptr = partTabs[T_REPMARK].ptr; tabs[M_REPMARK].len = partTabs[T_REPMARK].len; } if ( tabs[M_NUMBER].len == 0 && partTabs[T_NUMBER].len > 0 ) { tabs[M_NUMBER].ptr = partTabs[T_NUMBER].ptr; tabs[M_NUMBER].len = partTabs[T_NUMBER].len; } - if ( dim.carLength <= 0 ) dim.carLength = partP->dim.carLength; - if ( dim.carWidth <= 0 ) dim.carWidth = partP->dim.carWidth; - if ( dim.coupledLength <= 0 ) dim.coupledLength = partP->dim.coupledLength; - if ( dim.truckCenter <= 0 ) dim.truckCenter = partP->dim.truckCenter; - if ( dim.truckCenterOffset < 0 ) dim.truckCenterOffset = partP->dim.truckCenterOffset; + if ( dim.carLength <= 0 ) { dim.carLength = partP->dim.carLength; } + if ( dim.carWidth <= 0 ) { dim.carWidth = partP->dim.carWidth; } + if ( dim.coupledLength <= 0 ) { dim.coupledLength = partP->dim.coupledLength; } + if ( dim.truckCenter <= 0 ) { dim.truckCenter = partP->dim.truckCenter; } + if ( dim.truckCenterOffset < 0 ) { dim.truckCenterOffset = partP->dim.truckCenterOffset; } } - if (dim.truckCenterOffset <0) dim.truckCenterOffset = 0; + if (dim.truckCenterOffset <0) { dim.truckCenterOffset = 0; } cp = TabStringCpy( title, &tabs[M_MANUF] ); *cp++ = '\t'; cp = TabStringCpy( cp, &tabs[M_PROTO] ); @@ -4891,7 +5279,8 @@ static int CarInvImportCsv( condition = TabGetLong( &tabs[M_CONDITION] ); purchDate = TabGetLong( &tabs[M_PURCHDATE] ); srvcDate = TabGetLong( &tabs[M_SRVDATE] ); - if ( dim.carLength <= 0 || dim.carWidth <= 0 || dim.coupledLength <= 0 || dim.truckCenter <= 0 ) { + if ( dim.carLength <= 0 || dim.carWidth <= 0 || dim.coupledLength <= 0 + || dim.truckCenter <= 0 ) { rc = NoticeMessage( MSG_CARIMP_MISSING_DIMS, _("Yes"), _("No"), message ); if ( rc <= 0 ) { fclose( f ); @@ -4901,8 +5290,8 @@ static int CarInvImportCsv( continue; } item = CarItemNew( NULL, PARAM_CUSTOM, index, scale, title, options, type, - &dim, wDrawFindColor(color), - purchPrice, currPrice, condition, purchDate, srvcDate ); + &dim, wDrawFindColor(color), + purchPrice, currPrice, condition, purchDate, srvcDate ); if ( tabs[M_NOTES].len > 0 ) { item->data.notes = cp = MyMalloc( (tabs[M_NOTES].len+2) ); for ( cq=tabs[M_NOTES].ptr,len=tabs[M_NOTES].len; *cq&&len; ) { @@ -4931,24 +5320,25 @@ static void CarInvDlgImportCsv( void ) { if ( carInvImportCsv_fs == NULL ) carInvImportCsv_fs = wFilSelCreate( mainW, FS_LOAD, 0, _("Import Cars"), - _("Comma-Separated-Values (*.csv)|*.csv"), CarInvImportCsv, NULL ); + _("Comma-Separated-Values (*.csv)|*.csv"), CarInvImportCsv, NULL ); wFilSelect( carInvImportCsv_fs, GetCurrentPath(CARSPATHKEY)); } static void CsvFormatString( - FILE * f, - char * str, - int len, - char * sep ) + FILE * f, + char * str, + int len, + char * sep ) { - while ( str && len>0 && str[len-1]=='\n' ) len--; + while ( str && len>0 && str[len-1]=='\n' ) { len--; } if ( *str && len ) { fputc( '"', f ); for ( ; *str && len; str++,len-- ) { if ( !iscntrl((unsigned char) *str ) ) { - if ( *str == '"' ) + if ( *str == '"' ) { fputc( '"', f ); + } fputc( *str, f ); } else if ( *str == '\n' && str[1] && len > 1 ) { fprintf( f, "<NL>" ); @@ -4961,32 +5351,34 @@ static void CsvFormatString( static void CsvFormatLong( - FILE * f, - long val, - char * sep ) + FILE * f, + long val, + char * sep ) { - if ( val != 0 ) + if ( val != 0 ) { fprintf( f, "%ld", val ); + } fprintf( f, "%s", sep ); } static void CsvFormatFloat( - FILE * f, - FLOAT_T val, - int digits, - char * sep ) + FILE * f, + FLOAT_T val, + int digits, + char * sep ) { - if ( val != 0.0 ) + if ( val != 0.0 ) { fprintf( f, "%0.*f", digits, val ); + } fprintf( f, "%s", sep ); } static int CarInvExportCsv( - int files, - char ** fileName, - void * data ) + int files, + char ** fileName, + void * data ) { FILE * f; carItem_p item; @@ -4994,20 +5386,23 @@ static int CarInvExportCsv( tabString_t tabs[7]; char * sp; - assert( fileName != NULL ); - assert( files == 1 ); + CHECK( fileName != NULL ); + CHECK( files == 1 ); SetCurrentPath( CARSPATHKEY, fileName[0] ); f = fopen( fileName[0], "w" ); if ( f == NULL ) { - NoticeMessage( MSG_OPEN_FAIL, _("Continue"), NULL, _("Export Cars"), fileName[0], strerror(errno) ); + NoticeMessage( MSG_OPEN_FAIL, _("Continue"), NULL, _("Export Cars"), + fileName[0], strerror(errno) ); return FALSE; } SetCLocale(); for ( inx=0; inx<COUNT( carCsvColumnTitles ); inx++ ) { - CsvFormatString( f, carCsvColumnTitles[inx], (int)strlen(carCsvColumnTitles[inx]), inx<(COUNT( carCsvColumnTitles ))-1?",":"\n" ); + CsvFormatString( f, carCsvColumnTitles[inx], + (int)strlen(carCsvColumnTitles[inx]), + inx<(COUNT( carCsvColumnTitles ))-1?",":"\n" ); } for ( inx=0; inx<carItemInfo_da.cnt; inx++ ) { item = carItemInfo( inx ); @@ -5035,10 +5430,11 @@ static int CarInvExportCsv( CsvFormatLong( f, item->data.condition, "," ); CsvFormatLong( f, item->data.purchDate, "," ); CsvFormatLong( f, item->data.serviceDate, "," ); - if ( item->data.notes ) + if ( item->data.notes ) { CsvFormatString( f, item->data.notes, (int)strlen(item->data.notes), "\n" ); - else + } else { CsvFormatString( f, "", (int)strlen(""), "\n" ); + } } fclose( f ); SetUserLocale(); @@ -5049,20 +5445,21 @@ static int CarInvExportCsv( static struct wFilSel_t * carInvExportCsv_fs; static void CarInvDlgExportCsv( void ) { - if ( carItemInfo_da.cnt <= 0 ) + if ( carItemInfo_da.cnt <= 0 ) { return; + } if ( carInvExportCsv_fs == NULL ) carInvExportCsv_fs = wFilSelCreate( mainW, FS_SAVE, 0, _("Export Cars"), - _("Comma-Separated-Values (*.csv)|*.csv"), CarInvExportCsv, NULL ); + _("Comma-Separated-Values (*.csv)|*.csv"), CarInvExportCsv, NULL ); wFilSelect( carInvExportCsv_fs, GetCurrentPath(CARSPATHKEY)); } static void CarInvLoadItem( - carItem_p item ) + carItem_p item ) { -/* "Index", "Scale", "Manufacturer", "Type", "Part No", "Description", "Roadname", "RepMarks", - "Purch Price", "Curr Price", "Condition", "Purch Date", "Service Date", "Location", "Notes" */ + /* "Index", "Scale", "Manufacturer", "Type", "Part No", "Description", "Roadname", "RepMarks", + "Purch Price", "Curr Price", "Condition", "Purch Date", "Service Date", "Location", "Notes" */ char *condition; char *location; char *manuf; @@ -5078,42 +5475,51 @@ static void CarInvLoadItem( notes[0] = '\0'; } condition = - (item->data.condition < 10) ? N_("N/A"): - (item->data.condition < 30) ? N_("Poor"): - (item->data.condition < 50) ? N_("Fair"): - (item->data.condition < 70) ? N_("Good"): - (item->data.condition < 90) ? N_("Excellent"): - N_("Mint"); - - if ( item->car && !IsTrackDeleted(item->car) ) - location = N_("Layout"); - else + (item->data.condition < 10) ? N_("N/A"): + (item->data.condition < 30) ? N_("Poor"): + (item->data.condition < 50) ? N_("Fair"): + (item->data.condition < 70) ? N_("Good"): + (item->data.condition < 90) ? N_("Excellent"): + N_("Mint"); + + char carLocation[30]; + if ( item->car && !IsTrackDeleted(item->car) ) { + coOrd hi, lo; + GetBoundingBox( item->car, &hi, &lo ); + snprintf( carLocation, sizeof carLocation, "%0.0fx%0.0f", + PutDim((lo.x+hi.x)/2.0), + PutDim((lo.y+hi.y)/2.0) ); + location = carLocation; + } else { location = N_("Shelf"); + } manuf = TabStringDup(&tabs[T_MANUF]); road = TabStringDup(&tabs[T_ROADNAME]); - sprintf( message, "%ld\t%s\t%s\t%.*s\t%s\t%.*s%s%.*s\t%s\t%.*s%s%.*s\t%0.2f\t%0.2f\t%s\t%ld\t%ld\t%s\t%s", - item->index, GetScaleName(item->scaleInx), - _(manuf), - tabs[T_PART].len, tabs[T_PART].ptr, - _(typeListMap[CarProtoFindTypeCode(item->type)].name), - tabs[T_PROTO].len, tabs[T_PROTO].ptr, - (tabs[T_PROTO].len>0 && tabs[T_DESC].len)?"/":"", - tabs[T_DESC].len, tabs[T_DESC].ptr, - _(road), - tabs[T_REPMARK].len, tabs[T_REPMARK].ptr, - (tabs[T_REPMARK].len>0&&tabs[T_NUMBER].len>0)?" ":"", - tabs[T_NUMBER].len, tabs[T_NUMBER].ptr, - item->data.purchPrice, item->data.currPrice, _(condition), item->data.purchDate, item->data.serviceDate, _(location), notes ); - if (manuf) MyFree(manuf); - if (road) MyFree(road); + sprintf( message, + "%ld\t%s\t%s\t%.*s\t%s\t%.*s%s%.*s\t%s\t%.*s%s%.*s\t%0.2f\t%0.2f\t%s\t%ld\t%ld\t%s\t%s", + item->index, GetScaleName(item->scaleInx), + _(manuf), + tabs[T_PART].len, tabs[T_PART].ptr, + _(typeListMap[CarProtoFindTypeCode(item->type)].name), + tabs[T_PROTO].len, tabs[T_PROTO].ptr, + (tabs[T_PROTO].len>0 && tabs[T_DESC].len)?"/":"", + tabs[T_DESC].len, tabs[T_DESC].ptr, + _(road), + tabs[T_REPMARK].len, tabs[T_REPMARK].ptr, + (tabs[T_REPMARK].len>0&&tabs[T_NUMBER].len>0)?" ":"", + tabs[T_NUMBER].len, tabs[T_NUMBER].ptr, + item->data.purchPrice, item->data.currPrice, _(condition), item->data.purchDate, + item->data.serviceDate, _(location), notes ); + if (manuf) { MyFree(manuf); } + if (road) { MyFree(road); } wListAddValue( (wList_p)carInvPLs[I_CI_LIST].control, message, NULL, item ); } static int Cmp_carInvItem( - const void * ptr1, - const void * ptr2 ) + const void * ptr1, + const void * ptr2 ) { carItem_p item1 = *(carItem_p*)ptr1; carItem_p item2 = *(carItem_p*)ptr2; @@ -5131,25 +5537,32 @@ static int Cmp_carInvItem( case S_SCALE: rc = (int)(item1->scaleInx-item2->scaleInx); case S_MANUF: - rc = strncasecmp( tabs1[T_MANUF].ptr, tabs2[T_MANUF].ptr, max(tabs1[T_MANUF].len,tabs2[T_MANUF].len) ); + rc = strncasecmp( tabs1[T_MANUF].ptr, tabs2[T_MANUF].ptr, + max(tabs1[T_MANUF].len,tabs2[T_MANUF].len) ); break; case S_TYPE: rc = (int)(item1->type-item2->type); break; case S_PARTNO: - rc = strncasecmp( tabs1[T_PART].ptr, tabs2[T_PART].ptr, max(tabs1[T_PART].len,tabs2[T_PART].len) ); + rc = strncasecmp( tabs1[T_PART].ptr, tabs2[T_PART].ptr, max(tabs1[T_PART].len, + tabs2[T_PART].len) ); break; case S_DESC: - rc = strncasecmp( tabs1[T_PROTO].ptr, tabs2[T_PROTO].ptr, max(tabs1[T_PROTO].len,tabs2[T_PROTO].len) ); - if ( rc != 0 ) + rc = strncasecmp( tabs1[T_PROTO].ptr, tabs2[T_PROTO].ptr, + max(tabs1[T_PROTO].len,tabs2[T_PROTO].len) ); + if ( rc != 0 ) { break; - rc = strncasecmp( tabs1[T_DESC].ptr, tabs2[T_DESC].ptr, max(tabs1[T_DESC].len,tabs2[T_DESC].len) ); + } + rc = strncasecmp( tabs1[T_DESC].ptr, tabs2[T_DESC].ptr, max(tabs1[T_DESC].len, + tabs2[T_DESC].len) ); break; case S_ROADNAME: - rc = strncasecmp( tabs1[T_ROADNAME].ptr, tabs2[T_ROADNAME].ptr, max(tabs1[T_ROADNAME].len,tabs2[T_ROADNAME].len) ); + rc = strncasecmp( tabs1[T_ROADNAME].ptr, tabs2[T_ROADNAME].ptr, + max(tabs1[T_ROADNAME].len,tabs2[T_ROADNAME].len) ); break; case S_REPMARKS: - rc = strncasecmp( tabs1[T_REPMARK].ptr, tabs2[T_REPMARK].ptr, max(tabs1[T_REPMARK].len,tabs2[T_REPMARK].len) ); + rc = strncasecmp( tabs1[T_REPMARK].ptr, tabs2[T_REPMARK].ptr, + max(tabs1[T_REPMARK].len,tabs2[T_REPMARK].len) ); break; case S_PURCHPRICE: rc = (int)(item1->data.purchPrice-item2->data.purchPrice); @@ -5178,7 +5591,8 @@ static void CarInvListLoad( void ) int inx; carItem_p item; - qsort( carItemInfo_da.ptr, carItemInfo_da.cnt, sizeof item, Cmp_carInvItem ); + qsort( &carItemInfo(0), carItemInfo_da.cnt, sizeof carItemInfo(0), + Cmp_carInvItem ); ParamControlShow( &carInvPG, I_CI_LIST, FALSE ); wListClear( (wList_p)carInvPLs[I_CI_LIST].control ); for ( inx=0; inx<carItemInfo_da.cnt; inx++ ) { @@ -5188,51 +5602,63 @@ static void CarInvListLoad( void ) ParamControlShow( &carInvPG, I_CI_LIST, TRUE ); ParamControlActive( &carInvPG, I_CI_EDIT, FALSE ); ParamControlActive( &carInvPG, I_CI_DELETE, FALSE ); + wButtonSetLabel( (wButton_p)(carInvPLs[I_CI_DELETE].control), "" ); ParamControlActive( &carInvPG, I_CI_EXPORT_CSV, carItemInfo_da.cnt > 0 ); ParamDialogOkActive( &carInvPG, FALSE ); } static void CarInvDlgUpdate( - paramGroup_p pg, - int inx, - void * valueP ) + paramGroup_p pg, + int inx, + void * valueP ) { carItem_p item = NULL; wIndex_t cnt, selinx, selcnt; - wBool_t enableDelete; if ( inx >= I_CI_SORT && inx < I_CI_SORT+N_SORT ) { item = CarInvDlgFindCurrentItem(); CarInvListLoad(); if ( item ) { carInvInx = (wIndex_t)CarItemFindIndex( item ); - if ( carInvInx >= 0 ) + if ( carInvInx >= 0 ) { ParamLoadControl( &carInvPG, I_CI_LIST ); + } } } else if ( inx == I_CI_LIST ) { cnt = wListGetCount( (wList_p)carInvPLs[I_CI_LIST].control ); - enableDelete = TRUE; + wIndex_t nOnShelf = 0; + wIndex_t nOnLayout = 0; for ( selinx=selcnt=0; selinx<cnt; selinx++ ) { if ( wListGetItemSelected( (wList_p)carInvPLs[I_CI_LIST].control, selinx ) ) { selcnt++; - item = (carItem_p)wListGetItemContext( (wList_p)carInvPLs[I_CI_LIST].control, selinx ); - if ( item && item->car && !IsTrackDeleted( item->car ) ) { - enableDelete = FALSE; - break; + item = (carItem_p)wListGetItemContext( (wList_p)carInvPLs[I_CI_LIST].control, + selinx ); + if ( ! item ) { continue; } + if ( item->car && !IsTrackDeleted( item->car ) ) { + nOnLayout++; + } else { + nOnShelf++; } } } - item = CarInvDlgFindCurrentItem(); - ParamDialogOkActive( pg, selcnt==1 && item && item->car && !IsTrackDeleted(item->car) ); - ParamControlActive( &carInvPG, I_CI_EDIT, selcnt==1 && item && (item->car==NULL || IsTrackDeleted(item->car)) ); - ParamControlActive( &carInvPG, I_CI_DELETE, selcnt>0 && enableDelete ); + // Enable Find if 1 selected car is on Layout + ParamDialogOkActive( pg, nOnLayout == 1 && nOnShelf == 0 ); + // Enable Edit if 1 selected car is on Shelf + ParamControlActive( &carInvPG, I_CI_EDIT, nOnLayout == 0 && nOnShelf == 1 ); + wBool_t bEnableDelete = nOnLayout+nOnShelf > 0 && + ( nOnLayout == 0 || nOnShelf == 0 ); + wButtonSetLabel( (wButton_p)(carInvPLs[I_CI_DELETE].control), + bEnableDelete == FALSE ? "" : + nOnLayout > 0 ? _("Shelve") : + _("Delete") ); + ParamControlActive( &carInvPG, I_CI_DELETE, bEnableDelete ); } } static void CarInvListAdd( - carItem_p item ) + carItem_p item ) { CarInvListLoad(); carInvInx = (wIndex_t)CarItemFindIndex( item ); @@ -5243,7 +5669,7 @@ static void CarInvListAdd( static void CarInvListUpdate( - carItem_p item ) + carItem_p item ) { CarInvListLoad(); carInvInx = (wIndex_t)CarItemFindIndex( item ); @@ -5257,10 +5683,13 @@ EXPORT void DoCarDlg( void * unused ) { int inx, inx2; if ( carInvPG.win == NULL ) { - ParamCreateDialog( &carInvPG, MakeWindowTitle(_("Car Inventory")), _("Find"), CarInvDlgFind, wHide, TRUE, NULL, F_BLOCK|F_RESIZE|F_RECALLSIZE|PD_F_ALT_CANCELLABEL, CarInvDlgUpdate ); + ParamCreateDialog( &carInvPG, MakeWindowTitle(_("Car Inventory")), _("Find"), + CarInvDlgFind, wHide, TRUE, NULL, + F_BLOCK|F_RESIZE|F_RECALLSIZE|PD_F_ALT_CANCELLABEL, CarInvDlgUpdate ); for ( inx=I_CI_SORT; inx<I_CI_SORT+N_SORT; inx++ ) { for ( inx2=0; inx2<COUNT( sortOrders ); inx2++ ) { - wListAddValue( (wList_p)carInvPLs[inx].control, _(sortOrders[inx2]), NULL, NULL ); + wListAddValue( (wList_p)carInvPLs[inx].control, _(sortOrders[inx2]), NULL, + NULL ); ParamLoadControl( &carInvPG, inx ); } } @@ -5274,7 +5703,6 @@ EXPORT void DoCarDlg( void * unused ) static void CarDlgChange( long changes ) { if ( (changes&CHANGE_SCALE) ) { - carPartChangeLevel = 0; carDlgCouplerLength = 0.0; } } @@ -5283,29 +5711,25 @@ static void CarDlgChange( long changes ) EXPORT void ClearCars( void ) { int inx; - for ( inx=0; inx<carItemInfo_da.cnt; inx++ ) + for ( inx=0; inx<carItemInfo_da.cnt; inx++ ) { MyFree( carItemInfo(inx) ); - carItemInfo_da.cnt = 0; - carItemInfo_da.max = 0; - if ( carItemInfo_da.ptr ) - MyFree( carItemInfo_da.ptr ); - carItemInfo_da.ptr = NULL; + } + DYNARR_FREE( carItem_t*, carItemInfo_da ); } static struct { - dynArr_t carProto_da; - dynArr_t carPartParent_da; - dynArr_t carItemInfo_da; - } savedCarState; + dynArr_t carProto_da; + dynArr_t carPartParent_da; + dynArr_t carItemInfo_da; +} savedCarState; EXPORT void SaveCarState( void ) { savedCarState.carProto_da = carProto_da; savedCarState.carPartParent_da = carPartParent_da; savedCarState.carItemInfo_da = carItemInfo_da; - carItemInfo_da.cnt = carItemInfo_da.max = 0; - carItemInfo_da.ptr = NULL; + DYNARR_INIT( carItem_t*, carItemInfo_da ); } @@ -5344,8 +5768,8 @@ EXPORT void InitCarDlg( void ) */ static int CarPartCustMgmProc( - int cmd, - void * data ) + int cmd, + void * data ) { tabString_t tabs[7]; int rd_inx; @@ -5357,8 +5781,9 @@ static int CarPartCustMgmProc( case CUSTMGM_CAN_EDIT: return TRUE; case CUSTMGM_DO_EDIT: - if ( partP == NULL ) + if ( partP == NULL ) { return FALSE; + } carDlgUpdatePartPtr = partP; DoCarPartDlg( partUpdActions ); return TRUE; @@ -5370,16 +5795,17 @@ static int CarPartCustMgmProc( case CUSTMGM_GET_TITLE: TabStringExtract( partP->title, 7, tabs ); rd_inx = T_REPMARK; - if ( tabs[T_REPMARK].len == 0 ) + if ( tabs[T_REPMARK].len == 0 ) { rd_inx = T_ROADNAME; + } sprintf( message, "\t%s\t%s\t%.*s\t%s%s%.*s%s%.*s%s%.*s", - partP->parent->manuf, - GetScaleName(partP->parent->scale), - tabs[T_PART].len, tabs[T_PART].ptr, - partP->parent->proto, - tabs[T_DESC].len?", ":"", tabs[T_DESC].len, tabs[T_DESC].ptr, - tabs[rd_inx].len?", ":"", tabs[rd_inx].len, tabs[rd_inx].ptr, - tabs[T_NUMBER].len?" ":"", tabs[T_NUMBER].len, tabs[T_NUMBER].ptr ); + partP->parent->manuf, + GetScaleName(partP->parent->scale), + tabs[T_PART].len, tabs[T_PART].ptr, + partP->parent->proto, + tabs[T_DESC].len?", ":"", tabs[T_DESC].len, tabs[T_DESC].ptr, + tabs[rd_inx].len?", ":"", tabs[rd_inx].len, tabs[rd_inx].ptr, + tabs[T_NUMBER].len?" ":"", tabs[T_NUMBER].len, tabs[T_NUMBER].ptr ); return TRUE; } return FALSE; @@ -5387,8 +5813,8 @@ static int CarPartCustMgmProc( static int CarProtoCustMgmProc( - int cmd, - void * data ) + int cmd, + void * data ) { carProto_p protoP = (carProto_p)data; switch ( cmd ) { @@ -5397,8 +5823,9 @@ static int CarProtoCustMgmProc( case CUSTMGM_CAN_EDIT: return TRUE; case CUSTMGM_DO_EDIT: - if ( protoP == NULL ) + if ( protoP == NULL ) { return FALSE; + } carDlgUpdateProtoPtr = protoP; DoCarPartDlg( protoUpdActions ); return TRUE; @@ -5408,7 +5835,8 @@ static int CarProtoCustMgmProc( CarProtoDelete( protoP ); return TRUE; case CUSTMGM_GET_TITLE: - sprintf( message, "\t%s\t\t%s\t%s", _("Prototype"), _(typeListMap[CarProtoFindTypeCode(protoP->type)].name), protoP->desc ); + sprintf( message, "\t%s\t\t%s\t%s", _("Prototype"), + _(typeListMap[CarProtoFindTypeCode(protoP->type)].name), protoP->desc ); return TRUE; } return FALSE; @@ -5427,25 +5855,29 @@ EXPORT void CarCustMgmLoad( void ) static wIcon_p carpartI = NULL; static wIcon_p carprotoI = NULL; - if ( carpartI == NULL ) + if ( carpartI == NULL ) { carpartI = wIconCreatePixMap( carpart_xpm ); - if ( carprotoI == NULL ) + } + if ( carprotoI == NULL ) { carprotoI = wIconCreatePixMap( carproto_xpm ); + } for ( parentX=0; parentX<carPartParent_da.cnt; parentX++ ) { parentP = carPartParent(parentX); for ( partX=0; partX<parentP->parts_da.cnt; partX++ ) { partP = carPart(parentP,partX); - if ( partP->paramFileIndex != PARAM_CUSTOM ) + if ( partP->paramFileIndex != PARAM_CUSTOM ) { continue; + } CustMgmLoad( carpartI, CarPartCustMgmProc, partP ); } } for ( protoX=0; protoX<carProto_da.cnt; protoX++ ) { carProtoP = carProto(protoX); - if ( carProtoP->paramFileIndex != PARAM_CUSTOM ) + if ( carProtoP->paramFileIndex != PARAM_CUSTOM ) { continue; + } if (carProtoP->paramFileIndex == PARAM_CUSTOM) { CustMgmLoad( carprotoI, CarProtoCustMgmProc, carProtoP ); } diff --git a/app/bin/dcmpnd.c b/app/bin/dcmpnd.c index b86ab7b..9b7dfcc 100644 --- a/app/bin/dcmpnd.c +++ b/app/bin/dcmpnd.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "compound.h" @@ -28,6 +28,7 @@ #include "include/paramfile.h" #include "shrtpath.h" #include "track.h" +#include "trkendpt.h" #include "common-ui.h" /***************************************************************************** @@ -42,11 +43,11 @@ static updateType_e updateListType; static BOOL_T updateWVisible; static BOOL_T updateWStale; typedef struct { - updateType_e type; - SCALEINX_T scale; - char * old; - char * new; - } updateTitleElement; + updateType_e type; + SCALEINX_T scale; + char * old; + char * new; +} updateTitleElement; static dynArr_t updateTitles_da; #define updateTitles(N) DYNARR_N( updateTitleElement, updateTitles_da, N ) @@ -69,24 +70,29 @@ static paramData_t updateTitlePLs[] = { { PD_DROPLIST, NULL, "sel", PDO_NOPREF, I2VP(400) }, { PD_BUTTON, UpdateTitleIgnore, "ignore", PDO_DLGCMDBUTTON, NULL, N_("Ignore") }, #define I_UPDATELOAD (12) - { PD_BUTTON, NULL, "load", 0, NULL, N_("Load") } }; + { PD_BUTTON, NULL, "load", 0, NULL, N_("Load") } +}; static paramGroup_t updateTitlePG = { "updatetitle", 0, updateTitlePLs, COUNT( updateTitlePLs ) }; static void UpdateTitleChange( long changes ) { - if ( (changes & (CHANGE_SCALE|CHANGE_PARAMS)) == 0 ) + if ( (changes & (CHANGE_SCALE|CHANGE_PARAMS)) == 0 ) { return; + } if (!updateWVisible) { updateWStale = TRUE; return; } wControlShow( (wControl_p)updateTitleL, FALSE ); wListClear( updateTitleL ); - if (updateTitles(updateTitleInx).type == updateTurnout) - TurnoutAdd( listLabels, updateTitles(updateTitleInx).scale, updateTitleL, NULL, -1 ); - else - StructAdd( listLabels, updateTitles(updateTitleInx).scale, updateTitleL, NULL ); + if (updateTitles(updateTitleInx).type == updateTurnout) { + TurnoutAdd( listLabels, updateTitles(updateTitleInx).scale, updateTitleL, NULL, + -1 ); + } else { + StructAdd( listLabels, updateTitles(updateTitleInx).scale, updateTitleL, + NULL ); + } wControlShow( (wControl_p)updateTitleL, TRUE ); updateListType = updateTitles(updateTitleInx).type; } @@ -112,7 +118,7 @@ static void UpdateTitleNext( void ) xx = GET_EXTRA_DATA(trk, trkType, extraDataCompound_t); for (inx=0; inx<updateTitles_da.cnt; inx++) { if ( updateTitles(inx).old && - strcmp( xx->title, updateTitles(inx).old ) == 0 ) { + strcmp( xx->title, updateTitles(inx).old ) == 0 ) { xx->title = MyStrdup( updateTitles(inx).new ); break; } @@ -126,9 +132,11 @@ static void UpdateTitleNext( void ) DoChangeNotification( CHANGE_MAIN ); return; } - ParamLoadMessage( &updateTitlePG, I_UPDATESTR, updateTitles(updateTitleInx).old ); - if (updateWStale || updateTitles(updateTitleInx).type != updateListType) + ParamLoadMessage( &updateTitlePG, I_UPDATESTR, + updateTitles(updateTitleInx).old ); + if (updateWStale || updateTitles(updateTitleInx).type != updateListType) { UpdateTitleChange( CHANGE_SCALE|CHANGE_PARAMS ); + } } @@ -160,12 +168,15 @@ static void UpdateTitleCancel( wWin_p junk ) void DoUpdateTitles( void ) { - if (updateTitles_da.cnt <= 0) + if (updateTitles_da.cnt <= 0) { return; + } if (updateTitleW == NULL) { ParamRegister( &updateTitlePG ); updateTitlePLs[I_UPDATELOAD].valueP = ParamFilesInit(); - updateTitleW = ParamCreateDialog( &updateTitlePG, MakeWindowTitle(_("Update Title")), _("Update"), UpdateTitleUpdate, UpdateTitleCancel, TRUE, NULL, 0, NULL ); + updateTitleW = ParamCreateDialog( &updateTitlePG, + MakeWindowTitle(_("Update Title")), _("Update"), UpdateTitleUpdate, + UpdateTitleCancel, TRUE, NULL, 0, NULL ); RegisterChangeNotification( UpdateTitleChange ); } updateTitleInx = -1; @@ -176,13 +187,14 @@ void DoUpdateTitles( void ) } EXPORT void UpdateTitleMark( - char * title, - SCALEINX_T scale ) + char * title, + SCALEINX_T scale ) { int inx; updateTitleElement * ut; - if ( inPlayback ) + if ( inPlayback ) { return; + } for (inx=0; inx<updateTitles_da.cnt; inx++) { if (strcmp(title,updateTitles(inx).old) == 0) { return; @@ -190,10 +202,11 @@ EXPORT void UpdateTitleMark( } DYNARR_APPEND( updateTitleElement, updateTitles_da, 10 ); ut = &updateTitles(updateTitles_da.cnt-1); - if ( tempEndPts_da.cnt > 0) + if ( TempEndPtsCount() > 0) { ut->type = updateTurnout; - else + } else { ut->type = updateStructure; + } ut->scale = scale; ut->old = MyStrdup(title); ut->new = NULL; @@ -206,14 +219,15 @@ EXPORT void UpdateTitleMark( */ static BOOL_T CheckCompoundEndPoint( - track_p trk, - EPINX_T trkEp, - turnoutInfo_t * to, - EPINX_T toEp, - BOOL_T flip ) + track_p trk, + EPINX_T trkEp, + turnoutInfo_t * to, + EPINX_T toEp, + BOOL_T flip ) { - - struct extraDataCompound_t *xx = GET_EXTRA_DATA(trk, T_TURNOUT, extraDataCompound_t); + + struct extraDataCompound_t *xx = GET_EXTRA_DATA(trk, T_TURNOUT, + extraDataCompound_t); coOrd pos; DIST_T d; ANGLE_T a, a2; @@ -221,20 +235,24 @@ static BOOL_T CheckCompoundEndPoint( Rotate( &pos, xx->orig, -xx->angle ); pos.x -= xx->orig.x; pos.y -= xx->orig.y; - if ( flip ) + if ( flip ) { pos.y = - pos.y; - d = FindDistance( pos, to->endPt[toEp].pos ); + } + d = FindDistance( pos, GetEndPtPos(EndPtIndex(to->endPt,toEp))); if ( d > connectDistance ) { - sprintf( message, _("End-Point #%d of the selected and actual turnouts are not close"), toEp ); + sprintf( message, + _("End-Point #%d of the selected and actual turnouts are not close"), toEp ); return FALSE; } a = GetTrkEndAngle( trk, trkEp ); - a2 = to->endPt[toEp].angle; - if ( flip ) + a2 = GetEndPtAngle(EndPtIndex(to->endPt,toEp)); + if ( flip ) { a2 = 180.0 - a2; + } a = NormalizeAngle( a - xx->angle - a2 + connectAngle/2.0 ); if ( a > connectAngle ) { - sprintf( message, _("End-Point #%d of the selected and actual turnouts are not aligned"), toEp ); + sprintf( message, + _("End-Point #%d of the selected and actual turnouts are not aligned"), toEp ); return FALSE; } return TRUE; @@ -243,8 +261,8 @@ static BOOL_T CheckCompoundEndPoint( int refreshCompoundCnt; static BOOL_T RefreshCompound1( - track_p trk, - turnoutInfo_t * to ) + track_p trk, + turnoutInfo_t * to ) { EPINX_T ep, epCnt; BOOL_T ok; @@ -252,7 +270,8 @@ static BOOL_T RefreshCompound1( epCnt = GetTrkEndPtCnt(trk); if ( epCnt != to->endCnt ) { - strcpy( message, _("The selected Turnout had a differing number of End-Points") ); + strcpy( message, + _("The selected Turnout had a differing number of End-Points") ); return FALSE; } ok = TRUE; @@ -263,24 +282,25 @@ static BOOL_T RefreshCompound1( } if ( !ok ) { if ( ep > 0 && epCnt == 2 && - CheckCompoundEndPoint( trk, 1, to, 1, TRUE ) ) { + CheckCompoundEndPoint( trk, 1, to, 1, TRUE ) ) { flip = TRUE; ok = TRUE; } else if ( ep > 0 && epCnt == 3 && - CheckCompoundEndPoint( trk, 1, to, 2, FALSE ) && - CheckCompoundEndPoint( trk, 2, to, 1, FALSE ) ) { + CheckCompoundEndPoint( trk, 1, to, 2, FALSE ) && + CheckCompoundEndPoint( trk, 2, to, 1, FALSE ) ) { ok = TRUE; } else if ( ep > 0 && epCnt == 4 && - CheckCompoundEndPoint( trk, 1, to, 3, FALSE ) && - CheckCompoundEndPoint( trk, 2, to, 2, FALSE ) && - CheckCompoundEndPoint( trk, 3, to, 1, FALSE ) ) { + CheckCompoundEndPoint( trk, 1, to, 3, FALSE ) && + CheckCompoundEndPoint( trk, 2, to, 2, FALSE ) && + CheckCompoundEndPoint( trk, 3, to, 1, FALSE ) ) { ok = TRUE; } else { return FALSE; } } UndoModify( trk ); - struct extraDataCompound_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, extraDataCompound_t); + struct extraDataCompound_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, + extraDataCompound_t); FreeFilledDraw( xx->segCnt, xx->segs ); MyFree( xx->segs ); xx->segCnt = to->segCnt; @@ -289,8 +309,9 @@ static BOOL_T RefreshCompound1( xx->pathOverRide = to->pathOverRide; xx->pathNoCombine = to->pathNoCombine; SetPaths( trk, GetParamPaths(to) ); - if ( flip ) + if ( flip ) { FlipSegs( xx->segCnt, xx->segs, zero, 90.0 ); + } ClrTrkBits( trk, TB_SELECTED ); refreshCompoundCnt++; CloneFilledDraw( xx->segCnt, xx->segs, FALSE ); @@ -299,9 +320,9 @@ static BOOL_T RefreshCompound1( typedef struct { - char * name; - turnoutInfo_t * to; - } refreshSpecial_t; + char * name; + turnoutInfo_t * to; +} refreshSpecial_t; static dynArr_t refreshSpecial_da; #define refreshSpecial(N) DYNARR_N( refreshSpecial_t, refreshSpecial_da, N ) static wIndex_t refreshSpecialInx; @@ -310,37 +331,38 @@ static void RefreshSkip( void * junk ); static paramListData_t refreshSpecialListData = { 30, 600, 0, NULL, NULL }; static paramData_t refreshSpecialPLs[] = { #define REFRESH_M1 (0) - { PD_MESSAGE, NULL, NULL, 0/*PDO_DLGRESIZEW*/, I2VP(380) }, + { PD_MESSAGE, NULL, NULL, 0/*PDO_DLGRESIZEW*/, I2VP(380) }, #define REFRESH_M2 (1) - { PD_MESSAGE, NULL, NULL, 0/*PDO_DLGRESIZEW*/, I2VP(380) }, + { PD_MESSAGE, NULL, NULL, 0/*PDO_DLGRESIZEW*/, I2VP(380) }, #define REFRESH_S (2) - { PD_MESSAGE, NULL, NULL, 0/*PDO_DLGRESIZEW*/, I2VP(380) }, + { PD_MESSAGE, NULL, NULL, 0/*PDO_DLGRESIZEW*/, I2VP(380) }, #define REFRESH_L (3) - { PD_LIST, &refreshSpecialInx, "list", PDO_LISTINDEX|PDO_NOPREF|PDO_DLGRESIZE, &refreshSpecialListData, NULL, BO_READONLY }, - { PD_BUTTON, RefreshSkip, "skip", PDO_DLGCMDBUTTON, NULL, N_("Skip") } }; + { PD_LIST, &refreshSpecialInx, "list", PDO_LISTINDEX|PDO_NOPREF|PDO_DLGRESIZE, &refreshSpecialListData, NULL, BO_READONLY }, + { PD_BUTTON, RefreshSkip, "skip", PDO_DLGCMDBUTTON, NULL, N_("Skip") } +}; static paramGroup_t refreshSpecialPG = { "refreshSpecial", 0, refreshSpecialPLs, COUNT( refreshSpecialPLs ) }; static void RefreshSpecialOk( - void * junk ) + void * junk ) { wHide( refreshSpecialPG.win ); } static void RefreshSpecialCancel( - wWin_p win ) + wWin_p win ) { refreshSpecialInx = -1; refreshReturnVal = FALSE; wHide( refreshSpecialPG.win ); } static void RefreshSkip( - void * junk ) + void * junk ) { refreshSpecialInx = -1; wHide( refreshSpecialPG.win ); } EXPORT BOOL_T RefreshCompound( - track_p trk, - BOOL_T junk ) + track_p trk, + BOOL_T junk ) { TRKTYP_T trkType; struct extraDataCompound_t *xx; @@ -353,8 +375,9 @@ EXPORT BOOL_T RefreshCompound( refreshCompoundCnt = 0; for ( inx=0; inx<refreshSpecial_da.cnt; inx++ ) if ( refreshSpecial(inx).name != NULL && - refreshSpecial(inx).to == NULL ) + refreshSpecial(inx).to == NULL ) { refreshSpecial(inx).name = NULL; + } return FALSE; } trkType = GetTrkType(trk); @@ -367,13 +390,14 @@ EXPORT BOOL_T RefreshCompound( refreshReturnVal = TRUE; for ( inx=0; inx<refreshSpecial_da.cnt; inx++ ) { if ( refreshSpecial(inx).name != NULL && - strcasecmp( xx->title, refreshSpecial(inx).name ) == 0 ) { + strcasecmp( xx->title, refreshSpecial(inx).name ) == 0 ) { to = refreshSpecial(inx).to; - if ( to == NULL ) + if ( to == NULL ) { return TRUE; + } if ( IsParamValid(to->paramFileIndex) && - to->segCnt > 0 && - (FIT_NONE != CompatibleScale( GetTrkEndPtCnt(trk)>0, to->scaleInx, scale ) )) { + to->segCnt > 0 && + (FIT_NONE != CompatibleScale( GetTrkEndPtCnt(trk)>0, to->scaleInx, scale ) )) { if ( RefreshCompound1( trk, refreshSpecial(inx).to ) ) { if ( strcasecmp( xx->title, to->title ) != 0 ) { MyFree( xx->title ); @@ -384,24 +408,32 @@ EXPORT BOOL_T RefreshCompound( } } } - if ( ( to = FindCompound( FIND_TURNOUT|FIND_STRUCT, NULL, xx->title ) ) != NULL && - RefreshCompound1( trk, to ) ) + if ( ( to = FindCompound( FIND_TURNOUT|FIND_STRUCT, NULL, xx->title ) ) != NULL + && + RefreshCompound1( trk, to ) ) { return TRUE; + } if ( refreshSpecialPG.win == NULL ) { ParamRegister( &refreshSpecialPG ); - ParamCreateDialog( &refreshSpecialPG, MakeWindowTitle(_("Refresh Turnout/Structure")), _("Ok"), RefreshSpecialOk, RefreshSpecialCancel, TRUE, NULL, F_BLOCK|F_RESIZE|F_RECALLSIZE, NULL ); + ParamCreateDialog( &refreshSpecialPG, + MakeWindowTitle(_("Refresh Turnout/Structure")), _("Ok"), RefreshSpecialOk, + RefreshSpecialCancel, TRUE, NULL, F_BLOCK|F_RESIZE|F_RECALLSIZE, NULL ); } - ParamLoadMessage( &refreshSpecialPG, REFRESH_M1, _("Choose a Turnout/Structure to replace:") ); + ParamLoadMessage( &refreshSpecialPG, REFRESH_M1, + _("Choose a Turnout/Structure to replace:") ); ParamLoadMessage( &refreshSpecialPG, REFRESH_M2, "" ); refreshSpecialInx = -1; wListClear( (wList_p)refreshSpecialPLs[REFRESH_L].control ); - if ( GetTrkEndPtCnt(trk) > 0 ) - to = TurnoutAdd( listLabels, scale, (wList_p)refreshSpecialPLs[REFRESH_L].control, NULL, GetTrkEndPtCnt(trk) ); - else - to = StructAdd( listLabels, scale, (wList_p)refreshSpecialPLs[REFRESH_L].control, NULL ); + if ( GetTrkEndPtCnt(trk) > 0 ) { + to = TurnoutAdd( listLabels, scale, + (wList_p)refreshSpecialPLs[REFRESH_L].control, NULL, GetTrkEndPtCnt(trk) ); + } else { + to = StructAdd( listLabels, scale, + (wList_p)refreshSpecialPLs[REFRESH_L].control, NULL ); + } if ( to == NULL ) { NoticeMessage( MSG_NO_TURNOUTS_AVAILABLE, _("Ok"), NULL, - GetTrkEndPtCnt(trk)>0 ? _("Turnouts") : _("Structures") ); + GetTrkEndPtCnt(trk)>0 ? _("Turnouts") : _("Structures") ); return FALSE; } FormatCompoundTitle( listLabels, xx->title ); @@ -417,9 +449,10 @@ EXPORT BOOL_T RefreshCompound( } return refreshReturnVal; } - to = (turnoutInfo_t*)wListGetItemContext( (wList_p)refreshSpecialPLs[REFRESH_L].control, refreshSpecialInx ); + to = (turnoutInfo_t*)wListGetItemContext( (wList_p) + refreshSpecialPLs[REFRESH_L].control, refreshSpecialInx ); if ( to != NULL && - RefreshCompound1( trk, to ) ) { + RefreshCompound1( trk, to ) ) { DYNARR_APPEND( refreshSpecial_t, refreshSpecial_da, 10 ); refreshSpecial(refreshSpecial_da.cnt-1).to = to; refreshSpecial(refreshSpecial_da.cnt-1).name = MyStrdup( xx->title ); @@ -430,7 +463,8 @@ EXPORT BOOL_T RefreshCompound( return TRUE; } ParamLoadMessage( &refreshSpecialPG, REFRESH_M1, message ); - ParamLoadMessage( &refreshSpecialPG, REFRESH_M2, _("Choose another Turnout/Structure to replace:") ); + ParamLoadMessage( &refreshSpecialPG, REFRESH_M2, + _("Choose another Turnout/Structure to replace:") ); } } @@ -446,14 +480,15 @@ static char renamePartno[STR_SIZE]; static turnoutInfo_t * renameTo; static paramData_t renamePLs[] = { -/*0*/ { PD_STRING, renameManuf, "manuf", PDO_NOPREF | PDO_NOTBLANK, I2VP(350), N_("Manufacturer"), 0, 0, sizeof(renameManuf)}, -/*1*/ { PD_STRING, renameDesc, "desc", PDO_NOPREF | PDO_NOTBLANK, I2VP(230), N_("Description"), 0, 0, sizeof(renameDesc)}, -/*2*/ { PD_STRING, renamePartno, "partno", PDO_NOPREF|PDO_DLGHORZ|PDO_DLGIGNORELABELWIDTH | PDO_NOTBLANK, I2VP(100), N_("#"), 0, 0, sizeof(renamePartno)} }; + /*0*/ { PD_STRING, renameManuf, "manuf", PDO_NOPREF | PDO_NOTBLANK, I2VP(350), N_("Manufacturer"), 0, 0, sizeof(renameManuf)}, + /*1*/ { PD_STRING, renameDesc, "desc", PDO_NOPREF | PDO_NOTBLANK, I2VP(230), N_("Description"), 0, 0, sizeof(renameDesc)}, + /*2*/ { PD_STRING, renamePartno, "partno", PDO_NOPREF|PDO_DLGHORZ|PDO_DLGIGNORELABELWIDTH | PDO_NOTBLANK, I2VP(100), N_("#"), 0, 0, sizeof(renamePartno)} +}; static paramGroup_t renamePG = { "rename", 0, renamePLs, COUNT( renamePLs ) }; EXPORT BOOL_T CompoundCustomSave( - FILE * f ) + FILE * f ) { int inx; turnoutInfo_t * to; @@ -462,19 +497,24 @@ EXPORT BOOL_T CompoundCustomSave( for ( inx=0; inx<turnoutInfo_da.cnt; inx++ ) { to = turnoutInfo(inx); if (to->paramFileIndex == PARAM_CUSTOM && to->segCnt > 0) { - rc &= fprintf( f, "TURNOUT %s \"%s\"\n", GetScaleName(to->scaleInx), PutTitle(to->title) )>0; - if ( to->customInfo ) + rc &= fprintf( f, "TURNOUT %s \"%s\"\n", GetScaleName(to->scaleInx), + PutTitle(to->title) )>0; + if ( to->customInfo ) { rc &= fprintf( f, "\tU %s\n",to->customInfo )>0; - rc &= WriteCompoundPathsEndPtsSegs( f, GetParamPaths( to ), to->segCnt, to->segs, - to->endCnt, to->endPt ); + } + rc &= WriteCompoundPathsEndPtsSegs( f, GetParamPaths( to ), to->segCnt, + to->segs, + to->endCnt, to->endPt ); } } for ( inx=0; inx<structureInfo_da.cnt; inx++ ) { to = structureInfo(inx); if (to->paramFileIndex == PARAM_CUSTOM && to->segCnt > 0) { - rc &= fprintf( f, "STRUCTURE %s \"%s\"\n", GetScaleName(to->scaleInx), PutTitle(to->title) )>0; - if ( to->customInfo ) + rc &= fprintf( f, "STRUCTURE %s \"%s\"\n", GetScaleName(to->scaleInx), + PutTitle(to->title) )>0; + if ( to->customInfo ) { rc &= fprintf( f, "\tU %s\n",to->customInfo )>0; + } rc &= WriteSegs( f, to->segCnt, to->segs ); } } @@ -485,8 +525,9 @@ EXPORT BOOL_T CompoundCustomSave( static void RenameOk( void * junk ) { sprintf( message, "%s\t%s\t%s", renameManuf, renameDesc, renamePartno ); - if ( renameTo->title ) + if ( renameTo->title ) { MyFree( renameTo->title ); + } renameTo->title = MyStrdup( message ); wHide( renamePG.win ); DoChangeNotification( CHANGE_PARAMS ); @@ -494,8 +535,8 @@ static void RenameOk( void * junk ) static int CompoundCustMgmProc( - int cmd, - void * data ) + int cmd, + void * data ) { turnoutInfo_t * to = (turnoutInfo_t*)data; turnoutInfo_t * to2=NULL; @@ -506,19 +547,24 @@ static int CompoundCustMgmProc( switch ( cmd ) { case CUSTMGM_DO_COPYTO: - if ( to->segCnt <= 0 ) + if ( to->segCnt <= 0 ) { return TRUE; + } if ( to->endCnt ) { - rc &= fprintf( customMgmF, "TURNOUT %s \"%s\"\n", GetScaleName(to->scaleInx), PutTitle(to->title) )>0; - if ( to->customInfo ) + rc &= fprintf( customMgmF, "TURNOUT %s \"%s\"\n", GetScaleName(to->scaleInx), + PutTitle(to->title) )>0; + if ( to->customInfo ) { rc &= fprintf( customMgmF, "\tU %s\n",to->customInfo )>0; - rc &= WriteCompoundPathsEndPtsSegs( customMgmF, - GetParamPaths( to ), to->segCnt, to->segs, - to->endCnt, to->endPt ); + } + rc &= WriteCompoundPathsEndPtsSegs( customMgmF, + GetParamPaths( to ), to->segCnt, to->segs, + to->endCnt, to->endPt ); } else { - rc &= fprintf( customMgmF, "STRUCTURE %s \"%s\"\n", GetScaleName(to->scaleInx), PutTitle(to->title) )>0; - if ( to->customInfo ) + rc &= fprintf( customMgmF, "STRUCTURE %s \"%s\"\n", GetScaleName(to->scaleInx), + PutTitle(to->title) )>0; + if ( to->customInfo ) { rc &= fprintf( customMgmF, "\tU %s\n",to->customInfo )>0; + } rc &= WriteSegs( customMgmF, to->segCnt, to->segs ); } return rc; @@ -533,23 +579,24 @@ static int CompoundCustMgmProc( strncpy( renamePartno, nP, nL ); renamePartno[nL] = 0; if ( !renamePG.win ) { ParamRegister( &renamePG ); - ParamCreateDialog( &renamePG, MakeWindowTitle(_("Rename Object")), _("Ok"), RenameOk, wHide, TRUE, NULL, F_BLOCK, NULL ); + ParamCreateDialog( &renamePG, MakeWindowTitle(_("Rename Object")), _("Ok"), + RenameOk, wHide, TRUE, NULL, F_BLOCK, NULL ); } ParamLoadControls( &renamePG ); wShow( renamePG.win ); } else { - for (inx=0; inx<turnoutInfo_da.cnt && to!=turnoutInfo(inx); inx++); - if ( inx > 0 && - turnoutInfo(inx-1)->customInfo && - strcmp( to->customInfo, turnoutInfo(inx-1)->customInfo ) == 0 ) { - to2 = to; - to = turnoutInfo(inx-1); - } else if ( inx < turnoutInfo_da.cnt-1 && - turnoutInfo(inx+1)->customInfo && - strcmp( to->customInfo, turnoutInfo(inx+1)->customInfo ) == 0 ) { - to2 = turnoutInfo(inx+1); - } - EditCustomTurnout( to, to2 ); + for (inx=0; inx<turnoutInfo_da.cnt && to!=turnoutInfo(inx); inx++); + if ( inx > 0 && + turnoutInfo(inx-1)->customInfo && + strcmp( to->customInfo, turnoutInfo(inx-1)->customInfo ) == 0 ) { + to2 = to; + to = turnoutInfo(inx-1); + } else if ( inx < turnoutInfo_da.cnt-1 && + turnoutInfo(inx+1)->customInfo && + strcmp( to->customInfo, turnoutInfo(inx+1)->customInfo ) == 0 ) { + to2 = turnoutInfo(inx+1); + } + EditCustomTurnout( to, to2 ); } return TRUE; case CUSTMGM_CAN_DELETE: @@ -559,15 +606,16 @@ static int CompoundCustMgmProc( return TRUE; case CUSTMGM_GET_TITLE: ParseCompoundTitle( to->title, &mP, &mL, &pP, &pL, &nP, &nL ); - sprintf( message, "\t%.*s\t%s\t%.*s\t%.*s", mL, mP, GetScaleName(to->scaleInx), nL, nP, pL, pP ); + sprintf( message, "\t%.*s\t%s\t%.*s\t%.*s", mL, mP, GetScaleName(to->scaleInx), + nL, nP, pL, pP ); return TRUE; } return FALSE; } -#include "bitmaps/turnout.xpm" -#include "bitmaps/building.xpm" +#include "bitmaps/turnout.xpm3" +#include "bitmaps/building.xpm3" EXPORT void CompoundCustMgmLoad( void ) { @@ -576,10 +624,12 @@ EXPORT void CompoundCustMgmLoad( void ) static wIcon_p turnoutI = NULL; static wIcon_p structI = NULL; - if ( turnoutI == NULL ) - turnoutI = wIconCreatePixMap( turnout_xpm[0] ); - if ( structI == NULL ) - structI = wIconCreatePixMap( building_xpm[0] ); + if ( turnoutI == NULL ) { + turnoutI = wIconCreatePixMap( turnout_xpm3[0] ); + } + if ( structI == NULL ) { + structI = wIconCreatePixMap( building_xpm3[0] ); + } for ( inx=0; inx<turnoutInfo_da.cnt; inx++ ) { to = turnoutInfo(inx); @@ -602,13 +652,15 @@ EXPORT void CompoundCustMgmLoad( void ) */ wIndex_t FindListItemByContext( - wList_p listP, - void * context ) + wList_p listP, + void * context ) { - if ( listP == NULL ) + if ( listP == NULL ) { return -1; - if ( context == NULL ) + } + if ( context == NULL ) { return -1; + } for ( wIndex_t inx = 0; inx < wListGetCount( listP ); ++inx ) { void * itemContext = wListGetItemContext( listP, inx ); if ( itemContext != NULL ) { diff --git a/app/bin/dcontmgm.c b/app/bin/dcontmgm.c index 1ffd067..d9df025 100644 --- a/app/bin/dcontmgm.c +++ b/app/bin/dcontmgm.c @@ -4,36 +4,36 @@ /* -*- C -*- **************************************************************** * - * System : - * Module : + * System : + * Module : * Created By : Robert Heller * Created : Thu Jan 5 10:52:12 2017 * Last Modified : <170411.1447> * * Description - * - * Control Element Mangment. Control Elements are elements related to + * + * Control Element Mangment. Control Elements are elements related to * layout control: Blocks (occupency detection), Switchmotors (actuators * to "throw" turnouts), and (eventually) signals. These elements don't * relate to "physical" items on the layout, but instead refer to the * elements used by the layout control software. These elements contain * "scripts", which are really just textual items that provide information - * for the layout control software and provide a bridge between physical - * layout elements (like tracks or turnouts) and the layout control + * for the layout control software and provide a bridge between physical + * layout elements (like tracks or turnouts) and the layout control * software. These textual items could be actual software code or could - * be LCC Events (for I/O device elements on a LCC network) or DCC + * be LCC Events (for I/O device elements on a LCC network) or DCC * addresses for stationary decoders, etc. XTrkCAD does not impose any * sort of syntax or format -- that is left up to other software that might * load and parse the XTrkCAD layout file. All the XTrkCAD does is provide * a unified place for this information to be stored and to provide a * mapping (association) between this control information and the layout * itself. - * + * * * Notes * * History - * + * **************************************************************************** * * Copyright (C) 2017 Robert Heller D/B/A Deepwoods Software @@ -52,13 +52,13 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * * - * * ****************************************************************************/ -static const char rcsid[] = "@(#) : $Id$"; +//static const char rcsid[] = "@(#) : $Id$"; #include "cundo.h" #include "custom.h" @@ -77,7 +77,8 @@ static void ControlDelete( void * action ); static void ControlDone( void * action ); static wWinPix_t controlListWidths[] = { 18, 100, 150 }; static const char * controlListTitles[] = { "", N_("Name"), - N_("Tracks") }; + N_("Tracks") + }; static paramListData_t controlListData = { 10, 400, 3, controlListWidths, controlListTitles }; static paramData_t controlPLs[] = { #define I_CONTROLLIST (0) @@ -86,45 +87,45 @@ static paramData_t controlPLs[] = { #define I_CONTROLEDIT (1) { PD_BUTTON, ControlEdit, "edit", PDO_DLGCMDBUTTON, NULL, N_("Edit") }, #define I_CONTROLDEL (2) - { PD_BUTTON, ControlDelete, "delete", 0, NULL, N_("Delete") }, - } ; + { PD_BUTTON, ControlDelete, "delete", 0, NULL, N_("Delete") }, +} ; static paramGroup_t controlPG = { "contmgm", 0, controlPLs, COUNT( controlPLs ) }; typedef struct { - contMgmCallBack_p proc; - void * data; - wIcon_p icon; - } contMgmContext_t, *contMgmContext_p; + contMgmCallBack_p proc; + void * data; + wIcon_p icon; +} contMgmContext_t, *contMgmContext_p; static BOOL_T AnyHILIGHT = FALSE; static void ControlDlgUpdate( - paramGroup_p pg, - int inx, - void *valueP ) + paramGroup_p pg, + int inx, + void *valueP ) { - contMgmContext_p context = NULL; - wIndex_t selcnt = wListGetSelectedCount( (wList_p)controlPLs[0].control ); - wIndex_t linx, lcnt; - - if ( inx != I_CONTROLLIST ) return; - lcnt = wListGetCount( (wList_p)controlPLs[0].control ); - AnyHILIGHT = FALSE; - for (linx=0; - linx < lcnt; - linx++ ) { - if (wListGetItemSelected( (wList_p)controlPLs[0].control, linx ) == TRUE) { - context = (contMgmContext_p)wListGetItemContext( controlSelL, linx ); - context->proc( CONTMGM_DO_HILIGHT, context->data ); - AnyHILIGHT = TRUE; - } else { - context = (contMgmContext_p)wListGetItemContext( controlSelL, linx ); - context->proc( CONTMGM_UN_HILIGHT, context->data ); - } - } - ParamControlActive( &controlPG, I_CONTROLEDIT, selcnt>0 ); - ParamControlActive( &controlPG, I_CONTROLDEL, selcnt>0 ); + contMgmContext_p context = NULL; + wIndex_t selcnt = wListGetSelectedCount( (wList_p)controlPLs[0].control ); + wIndex_t linx, lcnt; + + if ( inx != I_CONTROLLIST ) { return; } + lcnt = wListGetCount( (wList_p)controlPLs[0].control ); + AnyHILIGHT = FALSE; + for (linx=0; + linx < lcnt; + linx++ ) { + if (wListGetItemSelected( (wList_p)controlPLs[0].control, linx ) == TRUE) { + context = (contMgmContext_p)wListGetItemContext( controlSelL, linx ); + context->proc( CONTMGM_DO_HILIGHT, context->data ); + AnyHILIGHT = TRUE; + } else { + context = (contMgmContext_p)wListGetItemContext( controlSelL, linx ); + context->proc( CONTMGM_UN_HILIGHT, context->data ); + } + } + ParamControlActive( &controlPG, I_CONTROLEDIT, selcnt>0 ); + ParamControlActive( &controlPG, I_CONTROLDEL, selcnt>0 ); } static void ControlEdit( void * action ) @@ -133,17 +134,20 @@ static void ControlEdit( void * action ) wIndex_t selcnt = wListGetSelectedCount( (wList_p)controlPLs[0].control ); wIndex_t inx, cnt; - if ( selcnt != 1 ) + if ( selcnt != 1 ) { return; + } cnt = wListGetCount( (wList_p)controlPLs[0].control ); for ( inx=0; - inx<cnt && wListGetItemSelected( (wList_p)controlPLs[0].control, inx ) != TRUE; - inx++ ); - if ( inx >= cnt ) + inx<cnt && wListGetItemSelected( (wList_p)controlPLs[0].control, inx ) != TRUE; + inx++ ); + if ( inx >= cnt ) { return; + } context = (contMgmContext_p)wListGetItemContext( controlSelL, inx ); - if ( context == NULL ) + if ( context == NULL ) { return; + } context->proc( CONTMGM_DO_EDIT, context->data ); context->proc( CONTMGM_GET_TITLE, context->data ); wListSetValues( controlSelL, inx, message, context->icon, context ); @@ -156,15 +160,20 @@ static void ControlDelete( void * action ) wIndex_t inx, cnt; contMgmContext_p context = NULL; - if ( selcnt <= 0 ) + if ( selcnt <= 0 ) { return; - if ( (!NoticeMessage2( 1, _("Are you sure you want to delete the %d control element(s)"), _("Yes"), _("No"), selcnt ) ) ) + } + if ( (!NoticeMessage2( 1, + _("Are you sure you want to delete the %d control element(s)"), _("Yes"), + _("No"), selcnt ) ) ) { return; - cnt = wListGetCount( (wList_p)controlPLs[0].control ); - UndoStart( _("Control Elements"), "delete" ); + } + cnt = wListGetCount( (wList_p)controlPLs[0].control ); + UndoStart( _("Control Elements"), "delete" ); for ( inx=0; inx<cnt; inx++ ) { - if ( !wListGetItemSelected( (wList_p)controlPLs[0].control, inx ) ) + if ( !wListGetItemSelected( (wList_p)controlPLs[0].control, inx ) ) { continue; + } context = (contMgmContext_p)wListGetItemContext( controlSelL, inx ); context->proc( CONTMGM_DO_DELETE, context->data ); MyFree( context ); @@ -172,32 +181,32 @@ static void ControlDelete( void * action ) inx--; cnt--; } - UndoEnd(); + UndoEnd(); DoChangeNotification( CHANGE_PARAMS ); } static void ControlDone( void * action ) { - contMgmContext_p context = NULL; - wIndex_t linx, lcnt; - - if (AnyHILIGHT) { - lcnt = wListGetCount( (wList_p)controlPLs[0].control ); - for (linx=0; - linx < lcnt; - linx++ ) { - context = (contMgmContext_p)wListGetItemContext( controlSelL, linx ); - context->proc( CONTMGM_UN_HILIGHT, context->data ); - } - } - wHide( controlPG.win ); + contMgmContext_p context = NULL; + wIndex_t linx, lcnt; + + if (AnyHILIGHT) { + lcnt = wListGetCount( (wList_p)controlPLs[0].control ); + for (linx=0; + linx < lcnt; + linx++ ) { + context = (contMgmContext_p)wListGetItemContext( controlSelL, linx ); + context->proc( CONTMGM_UN_HILIGHT, context->data ); + } + } + wHide( controlPG.win ); } EXPORT void ContMgmLoad( - wIcon_p icon, - contMgmCallBack_p proc, - void * data ) + wIcon_p icon, + contMgmCallBack_p proc, + void * data ) { contMgmContext_p context; context = MyMalloc( sizeof *context ); @@ -214,32 +223,40 @@ static void LoadControlMgmList( void ) wIndex_t curInx, cnt=0; long tempL; contMgmContext_p context; +#ifdef LATER contMgmContext_t curContext; +#endif curInx = wListGetIndex( controlSelL ); +#ifdef LATER curContext.proc = NULL; curContext.data = NULL; curContext.icon = NULL; +#endif if ( curInx >= 0 ) { context = (contMgmContext_p)wListGetItemContext( controlSelL, curInx ); - if ( context != NULL ) +#ifdef LATER + if ( context != NULL ) { curContext = *context; + } +#endif } cnt = wListGetCount( controlSelL ); for ( curInx=0; curInx<cnt; curInx++ ) { context = (contMgmContext_p)wListGetItemContext( controlSelL, curInx ); - if ( context ) + if ( context ) { MyFree( context ); + } } curInx = wListGetIndex( controlSelL ); wControlShow( (wControl_p)controlSelL, FALSE ); wListClear( controlSelL ); BlockMgmLoad(); - SwitchmotorMgmLoad(); - SignalMgmLoad(); - ControlMgmLoad(); - SensorMgmLoad(); + SwitchmotorMgmLoad(); + SignalMgmLoad(); + ControlMgmLoad(); + SensorMgmLoad(); #ifdef LATER curInx = 0; @@ -248,13 +265,15 @@ static void LoadControlMgmList( void ) for ( curInx=0; curInx<cnt; curInx++ ) { context = (contMgmContext_p)wListGetItemContext( controlSelL, curInx ); if ( context && - context->proc == curContext.proc && - context->data == curContext.data ) + context->proc == curContext.proc && + context->data == curContext.data ) { break; + } } } - if ( curInx >= cnt ) + if ( curInx >= cnt ) { curInx = (cnt>0?0:-1); + } wListSetIndex( controlSelL, curInx ); tempL = curInx; @@ -273,8 +292,9 @@ static void ContMgmChange( long changes ) } } if ((changes&CHANGE_PARAMS) == 0 || - controlPG.win == NULL || !wWinIsVisible(controlPG.win) ) + controlPG.win == NULL || !wWinIsVisible(controlPG.win) ) { return; + } LoadControlMgmList(); } @@ -283,22 +303,24 @@ static void ContMgmChange( long changes ) static void DoControlMgr( void * junk ) { - if (controlPG.win == NULL) { - ParamCreateDialog( &controlPG, MakeWindowTitle(_("Manage Layout Control Elements")), _("Done"), ControlDone, wHide, TRUE, NULL, F_RESIZE|F_RECALLSIZE|F_BLOCK, ControlDlgUpdate ); - } else { - wListClear( controlSelL ); - } - /*ParamLoadControls( &controlPG );*/ - /*ParamGroupRecord( &controlPG );*/ - LoadControlMgmList(); - wShow( controlPG.win ); + if (controlPG.win == NULL) { + ParamCreateDialog( &controlPG, + MakeWindowTitle(_("Manage Layout Control Elements")), _("Done"), ControlDone, + wHide, TRUE, NULL, F_RESIZE|F_RECALLSIZE|F_BLOCK, ControlDlgUpdate ); + } else { + wListClear( controlSelL ); + } + /*ParamLoadControls( &controlPG );*/ + /*ParamGroupRecord( &controlPG );*/ + LoadControlMgmList(); + wShow( controlPG.win ); } EXPORT addButtonCallBack_t ControlMgrInit( void ) { - ParamRegister( &controlPG ); - /*ParamRegister( &contMgmContentsPG );*/ - RegisterChangeNotification( ContMgmChange ); - return &DoControlMgr; + ParamRegister( &controlPG ); + /*ParamRegister( &contMgmContentsPG );*/ + RegisterChangeNotification( ContMgmChange ); + return &DoControlMgr; } diff --git a/app/bin/dcustmgm.c b/app/bin/dcustmgm.c index 73de62c..871787f 100644 --- a/app/bin/dcustmgm.c +++ b/app/bin/dcustmgm.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "custom.h" @@ -27,6 +27,7 @@ #include "track.h" #include "include/paramfilelist.h" #include "common-ui.h" +#include "ctrain.h" #ifdef UTFCONVERT #include "include/utf8convert.h" #endif @@ -42,55 +43,59 @@ static wIndex_t selectedType; static wWinPix_t customListWidths[] = { 18, 100, 30, 80, 220 }; static const char * customListTitles[] = { "", N_("Manufacturer"), - N_("Scale"), N_("Part No"), N_("Description") }; + N_("Scale"), N_("Part No"), N_("Description") + }; static paramListData_t customListData = { 10, 400, 5, customListWidths, customListTitles }; static paramData_t customPLs[] = { #define I_CUSTOMLIST (0) #define customSelL ((wList_p)customPLs[I_CUSTOMLIST].control) - { PD_LIST, NULL, "inx", PDO_DLGRESETMARGIN|PDO_DLGRESIZE|PDO_DLGBOXEND, &customListData, NULL, BL_MANY }, + { PD_LIST, NULL, "inx", PDO_DLGRESETMARGIN|PDO_DLGRESIZE|PDO_DLGBOXEND, &customListData, NULL, BL_MANY }, #define I_CUSTOMNEWTYPE (1) - { PD_DROPLIST, &selectedType, "newtype", PDO_DLGRESETMARGIN | PDO_LISTINDEX, I2VP(150), N_("Create a new ") }, -#define I_CUSTOMNEW (2) - { PD_BUTTON, CustomNewCar, "newcar", PDO_DLGHORZ| PDO_DLGBOXEND, NULL, N_("Go") }, + { PD_DROPLIST, &selectedType, "newtype", PDO_DLGRESETMARGIN | PDO_LISTINDEX, I2VP(150), N_("Create a new ") }, +#define I_CUSTOMNEW (2) + { PD_BUTTON, CustomNewCar, "newcar", PDO_DLGHORZ| PDO_DLGBOXEND, NULL, N_("Go") }, #define I_CUSTOMEDIT (3) { PD_BUTTON, CustomEdit, "edit", PDO_DLGCMDBUTTON, NULL, N_("Edit") }, #define I_CUSTOMDEL (4) { PD_BUTTON, CustomDelete, "delete", 0, NULL, N_("Delete") }, #define I_CUSTOMCOPYTO (5) { PD_BUTTON, CustomExport, "export", 0, NULL, N_("Move To") }, - } ; +} ; static paramGroup_t customPG = { "custmgm", 0, customPLs, COUNT( customPLs ) }; typedef struct { - custMgmCallBack_p proc; - void * data; - wIcon_p icon; - } custMgmContext_t, *custMgmContext_p; + custMgmCallBack_p proc; + void * data; + wIcon_p icon; +} custMgmContext_t, *custMgmContext_p; static void CustomDlgUpdate( - paramGroup_p pg, - int inx, - void *valueP ) + paramGroup_p pg, + int inx, + void *valueP ) { custMgmContext_p context = NULL; wIndex_t selcnt = wListGetSelectedCount( (wList_p)customPLs[0].control ); wIndex_t linx, lcnt; - if ( inx == I_CUSTOMNEW ) { - lcnt = wListGetCount( (wList_p)pg->paramPtr[I_CUSTOMNEWTYPE].control ); - } - - if ( inx != I_CUSTOMLIST ) return; + if ( inx == I_CUSTOMNEW ) { + lcnt = wListGetCount( (wList_p)pg->paramPtr[I_CUSTOMNEWTYPE].control ); + } + + if ( inx != I_CUSTOMLIST ) { return; } if ( selcnt == 1 ) { lcnt = wListGetCount( (wList_p)pg->paramPtr[inx].control ); for ( linx=0; - linx<lcnt && wListGetItemSelected( (wList_p)customPLs[0].control, linx ) != TRUE; - linx++ ); + linx<lcnt && wListGetItemSelected( (wList_p)customPLs[0].control, + linx ) != TRUE; + linx++ ); if ( linx < lcnt ) { - context = (custMgmContext_p)wListGetItemContext( (wList_p)pg->paramPtr[inx].control, linx ); - wButtonSetLabel( (wButton_p)customPLs[I_CUSTOMEDIT].control, context->proc( CUSTMGM_CAN_EDIT, context->data )?_("Edit"):_("Rename") ); + context = (custMgmContext_p)wListGetItemContext( (wList_p) + pg->paramPtr[inx].control, linx ); + wButtonSetLabel( (wButton_p)customPLs[I_CUSTOMEDIT].control, + context->proc( CUSTMGM_CAN_EDIT, context->data )?_("Edit"):_("Rename") ); ParamControlActive( &customPG, I_CUSTOMEDIT, TRUE ); } else { ParamControlActive( &customPG, I_CUSTOMEDIT, FALSE ); @@ -109,17 +114,20 @@ static void CustomEdit( void * action ) wIndex_t selcnt = wListGetSelectedCount( (wList_p)customPLs[0].control ); wIndex_t inx, cnt; - if ( selcnt != 1 ) + if ( selcnt != 1 ) { return; + } cnt = wListGetCount( (wList_p)customPLs[0].control ); for ( inx=0; - inx<cnt && wListGetItemSelected( (wList_p)customPLs[0].control, inx ) != TRUE; - inx++ ); - if ( inx >= cnt ) + inx<cnt && wListGetItemSelected( (wList_p)customPLs[0].control, inx ) != TRUE; + inx++ ); + if ( inx >= cnt ) { return; + } context = (custMgmContext_p)wListGetItemContext( customSelL, inx ); - if ( context == NULL ) + if ( context == NULL ) { return; + } context->proc( CUSTMGM_DO_EDIT, context->data ); #ifdef OBSOLETE context->proc( CUSTMGM_GET_TITLE, context->data ); @@ -130,16 +138,16 @@ static void CustomEdit( void * action ) static void CustomNewCar( void * action ) { - switch(selectedType) { - case 1: // car prototype - CarDlgAddProto(); - break; - case 0: // car part - CarDlgAddDesc(); - break; - default: - break; - } + switch(selectedType) { + case 1: // car prototype + CarDlgAddProto(); + break; + case 0: // car part + CarDlgAddDesc(); + break; + default: + break; + } } static void CustomDelete( void * action ) @@ -148,14 +156,18 @@ static void CustomDelete( void * action ) wIndex_t inx, cnt; custMgmContext_p context = NULL; - if ( selcnt <= 0 ) + if ( selcnt <= 0 ) { return; - if ( (!NoticeMessage2( 1, MSG_CUSTMGM_DELETE_CONFIRM, _("Yes"), _("No"), selcnt ) ) ) + } + if ( (!NoticeMessage2( 1, MSG_CUSTMGM_DELETE_CONFIRM, _("Yes"), _("No"), + selcnt ) ) ) { return; + } cnt = wListGetCount( (wList_p)customPLs[0].control ); for ( inx=0; inx<cnt; inx++ ) { - if ( !wListGetItemSelected( (wList_p)customPLs[0].control, inx ) ) + if ( !wListGetItemSelected( (wList_p)customPLs[0].control, inx ) ) { continue; + } context = (custMgmContext_p)wListGetItemContext( customSelL, inx ); context->proc( CUSTMGM_DO_DELETE, context->data ); MyFree( context ); @@ -171,7 +183,8 @@ EXPORT FILE * customMgmF; static char custMgmContentsStr[STR_SIZE]; static BOOL_T custMgmProceed; static paramData_t custMgmContentsPLs[] = { - { PD_STRING, custMgmContentsStr, "label", PDO_NOTBLANK, I2VP(400), N_("Label"), 0, 0, sizeof(custMgmContentsStr)} }; + { PD_STRING, custMgmContentsStr, "label", PDO_NOTBLANK, I2VP(400), N_("Label"), 0, 0, sizeof(custMgmContentsStr)} +}; static paramGroup_t custMgmContentsPG = { "contents", 0, custMgmContentsPLs, COUNT( custMgmContentsPLs ) }; static void CustMgmContentsOk( void * junk ) @@ -182,21 +195,22 @@ static void CustMgmContentsOk( void * junk ) static int CustomDoExport( - int files, - char ** fileName, - void * data ) + int files, + char ** fileName, + void * data ) { int rc; wIndex_t selcnt = wListGetSelectedCount( (wList_p)customPLs[0].control ); wIndex_t inx, cnt; custMgmContext_p context = NULL; - assert( fileName != NULL ); - assert( files == 1 ); + CHECK( fileName != NULL ); + CHECK( files == 1 ); - if ( selcnt <= 0 ) + if ( selcnt <= 0 ) { return FALSE; - + } + SetCurrentPath( PARAMETERPATHKEY, fileName[ 0 ] ); rc = access( fileName[ 0 ], F_OK ); if ( rc != -1 ) { @@ -208,13 +222,15 @@ static int CustomDoExport( custMgmProceed = TRUE; } else { if ( custMgmContentsPG.win == NULL ) { - ParamCreateDialog( &custMgmContentsPG, MakeWindowTitle(_("Contents Label")), _("Ok"), CustMgmContentsOk, wHide, TRUE, NULL, F_BLOCK, NULL ); + ParamCreateDialog( &custMgmContentsPG, MakeWindowTitle(_("Contents Label")), + _("Ok"), CustMgmContentsOk, wHide, TRUE, NULL, F_BLOCK, NULL ); } custMgmProceed = FALSE; wShow( custMgmContentsPG.win ); } - if ( !custMgmProceed ) + if ( !custMgmProceed ) { return FALSE; + } customMgmF = fopen( fileName[ 0 ], "a" ); if ( customMgmF == NULL ) { NoticeMessage( MSG_CUSTMGM_CANT_WRITE, _("Ok"), NULL, fileName[ 0 ] ); @@ -223,26 +239,27 @@ static int CustomDoExport( SetCLocale(); - if (rc == -1) - { - #ifdef UTFCONVERT - char *contents = MyStrdup(custMgmContentsStr); - contents = Convert2UTF8(contents); - fprintf(customMgmF, "CONTENTS %s\n", contents); + if (rc == -1) { +#ifdef UTFCONVERT + char *contents = MyStrdup(custMgmContentsStr); + contents = Convert2UTF8(contents); + fprintf(customMgmF, "CONTENTS %s\n", contents); MyFree(contents); - #else - fprintf(customMgmF, "CONTENTS %s\n", custMgmContentsStr); - #endif // UTFCONVERT +#else + fprintf(customMgmF, "CONTENTS %s\n", custMgmContentsStr); +#endif // UTFCONVERT } cnt = wListGetCount( (wList_p)customPLs[0].control ); for ( inx=0; inx<cnt; inx++ ) { - if ( !wListGetItemSelected( (wList_p)customPLs[0].control, inx ) ) + if ( !wListGetItemSelected( (wList_p)customPLs[0].control, inx ) ) { continue; + } context = (custMgmContext_p)wListGetItemContext( customSelL, inx ); - if ( context == NULL ) continue; + if ( context == NULL ) { continue; } if (!context->proc( CUSTMGM_DO_COPYTO, context->data )) { - NoticeMessage( MSG_WRITE_FAILURE, _("Ok"), NULL, strerror(errno), fileName[ 0 ] ); + NoticeMessage( MSG_WRITE_FAILURE, _("Ok"), NULL, strerror(errno), + fileName[ 0 ] ); fclose( customMgmF ); SetUserLocale(); return FALSE; @@ -265,7 +282,7 @@ static void CustomExport( void * junk ) { if ( customMgmExport_fs == NULL ) customMgmExport_fs = wFilSelCreate( mainW, FS_UPDATE, 0, _("Move To XTP"), - _("Parameter File (*.xtp)|*.xtp"), CustomDoExport, NULL ); + _("Parameter File (*.xtp)|*.xtp"), CustomDoExport, NULL ); wFilSelect( customMgmExport_fs, GetCurrentPath(CUSTOMPATHKEY)); } @@ -288,9 +305,9 @@ static void CustomDone( void * action ) EXPORT void CustMgmLoad( - wIcon_p icon, - custMgmCallBack_p proc, - void * data ) + wIcon_p icon, + custMgmCallBack_p proc, + void * data ) { custMgmContext_p context; context = MyMalloc( sizeof *context ); @@ -307,22 +324,30 @@ static void LoadCustomMgmList( void ) wIndex_t curInx, cnt=0; long tempL; custMgmContext_p context; +#ifdef LATER custMgmContext_t curContext; +#endif curInx = wListGetIndex( customSelL ); +#ifdef LATER curContext.proc = NULL; curContext.data = NULL; curContext.icon = NULL; +#endif if ( curInx >= 0 ) { context = (custMgmContext_p)wListGetItemContext( customSelL, curInx ); - if ( context != NULL ) +#ifdef LATER + if ( context != NULL ) { curContext = *context; + } +#endif } cnt = wListGetCount( customSelL ); for ( curInx=0; curInx<cnt; curInx++ ) { context = (custMgmContext_p)wListGetItemContext( customSelL, curInx ); - if ( context ) + if ( context ) { MyFree( context ); + } } curInx = wListGetIndex( customSelL ); wControlShow( (wControl_p)customSelL, FALSE ); @@ -338,13 +363,15 @@ static void LoadCustomMgmList( void ) for ( curInx=0; curInx<cnt; curInx++ ) { context = (custMgmContext_p)wListGetItemContext( customSelL, curInx ); if ( context && - context->proc == curContext.proc && - context->data == curContext.data ) + context->proc == curContext.proc && + context->data == curContext.data ) { break; + } } } - if ( curInx >= cnt ) + if ( curInx >= cnt ) { curInx = (cnt>0?0:-1); + } wListSetIndex( customSelL, curInx ); tempL = curInx; @@ -363,8 +390,9 @@ static void CustMgmChange( long changes ) } } if ((changes&CHANGE_PARAMS) == 0 || - customPG.win == NULL || !wWinIsVisible(customPG.win) ) + customPG.win == NULL || !wWinIsVisible(customPG.win) ) { return; + } LoadCustomMgmList(); } @@ -372,16 +400,19 @@ static void CustMgmChange( long changes ) static void DoCustomMgr( void * junk ) { - int i = 0; - + int i = 0; + if (customPG.win == NULL) { - ParamCreateDialog( &customPG, MakeWindowTitle(_("Manage custom designed parts")), _("Done"), CustomDone, wHide, TRUE, NULL, F_RESIZE|F_RECALLSIZE|F_BLOCK, CustomDlgUpdate ); - while(customTypes[ i ] != NULL) { - wListAddValue( ((wList_p)customPLs[I_CUSTOMNEWTYPE].control), customTypes[ i++ ], NULL, NULL ); - } - selectedType = 0; - wListSetIndex( ((wList_p)customPLs[I_CUSTOMNEWTYPE].control), selectedType); - + ParamCreateDialog( &customPG, + MakeWindowTitle(_("Manage custom designed parts")), _("Done"), CustomDone, + wHide, TRUE, NULL, F_RESIZE|F_RECALLSIZE|F_BLOCK, CustomDlgUpdate ); + while(customTypes[ i ] != NULL) { + wListAddValue( ((wList_p)customPLs[I_CUSTOMNEWTYPE].control), + customTypes[ i++ ], NULL, NULL ); + } + selectedType = 0; + wListSetIndex( ((wList_p)customPLs[I_CUSTOMNEWTYPE].control), selectedType); + } else { wListClear( customSelL ); } @@ -395,7 +426,7 @@ static void DoCustomMgr( void * junk ) EXPORT addButtonCallBack_t CustomMgrInit( void ) { - ParamRegister( &customPG ); + ParamRegister( &customPG ); ParamRegister( &custMgmContentsPG ); RegisterChangeNotification( CustMgmChange ); return &DoCustomMgr; diff --git a/app/bin/dease.c b/app/bin/dease.c index 2b393db..4112c61 100644 --- a/app/bin/dease.c +++ b/app/bin/dease.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "common.h" @@ -29,6 +29,10 @@ #include "param.h" #include "track.h" +EXPORT DIST_T easementVal = 0.0; +EXPORT DIST_T easeR = 0.0; +EXPORT DIST_T easeL = 0.0; + static wButton_p easementB; static DIST_T easeX = 0.0; @@ -74,13 +78,14 @@ static paramData_t easementPLs[] = { { PD_FLOAT, &easeX, "x", PDO_DIM|PDO_DLGHORZ, &r0_10, N_("X"), BO_READONLY }, { PD_FLOAT, &easeL, "l", PDO_DIM|PDO_DLGHORZ, &r0_100, N_("L"), BO_READONLY }, #define I_EASESEL (4) - { PD_RADIO, &easeM, "radio", PDO_DIM|PDO_NORECORD|PDO_NOPREF|PDO_DLGRESETMARGIN, easementChoiceLabels, NULL, BC_HORZ|BC_NONE } }; + { PD_RADIO, &easeM, "radio", PDO_DIM|PDO_NORECORD|PDO_NOPREF|PDO_DLGRESETMARGIN, easementChoiceLabels, NULL, BC_HORZ|BC_NONE } +}; static paramGroup_t easementPG = { "easement", PGO_RECORD, easementPLs, COUNT( easementPLs ) }; static void SetEasement( - DIST_T val, - void * update ) + DIST_T val, + void * update ) /* * Set transition-curve parameters (R and L). */ @@ -101,14 +106,15 @@ static void SetEasement( val = 0; bm = enone_bm; } else if (val <= 1.0) { - if (val < 0.21) val = 0.21; //Eliminate values that give negative radii + if (val < 0.21) { val = 0.21; } //Eliminate values that give negative radii z = 1.0/val - 1.0; easeR = Rvalues[1] - z * (Rvalues[1] - Rvalues[0]); easeL = Lvalues[1] - z * (Lvalues[1] - Lvalues[0]); - if (easeR != 0.0) + if (easeR != 0.0) { easeX = easeL*easeL/(24*easeR); - else + } else { easeX = 0.0; + } if (val == 1.0) { selVal = 2; bm = enormal_bm; @@ -126,10 +132,11 @@ static void SetEasement( z = val - 1.0; easeR = Rvalues[1] + z * (Rvalues[2] - Rvalues[1]); easeL = Lvalues[1] + z * (Lvalues[2] - Lvalues[1]); - if (easeR != 0.0) + if (easeR != 0.0) { easeX = easeL*easeL/(24*easeR); - else + } else { easeX = 0.0; + } if (val == 2.0) { selVal = 3; bm = ebroad_bm; @@ -154,8 +161,9 @@ static void SetEasement( } /*ParamChange( &easeValPD );*/ - if (easementB) + if (easementB) { wButtonSetLabel( easementB, (char*)bm ); + } } @@ -175,7 +183,7 @@ static void EasementCancel( void ) static void EasementSel( - long arg ) + long arg ) /* * Handle transition-curve parameter selection. */ @@ -198,7 +206,7 @@ static void EasementSel( val = -1.0; break; default: - AbortProg( "easementSel: bad value %ld", arg); + CHECKMSG( FALSE, ( "easementSel: bad value %ld", arg) ); val = 0.0; break; } @@ -207,9 +215,9 @@ static void EasementSel( static void EasementDlgUpdate( - paramGroup_p pg, - int inx, - void * valueP ) + paramGroup_p pg, + int inx, + void * valueP ) { switch (inx) { case I_EASEVAL: @@ -223,21 +231,25 @@ static void EasementDlgUpdate( static void LayoutEasementW( - paramData_t * pd, - int inx, - wWinPix_t colX, - wWinPix_t * x, - wWinPix_t * y ) + paramData_t * pd, + int inx, + wWinPix_t colX, + wWinPix_t * x, + wWinPix_t * y ) { - if ( inx == 2 ) - wControlSetPos( easementPLs[0].control, *x, wControlGetPosY(easementPLs[0].control) ); + if ( inx == 2 ) { + wControlSetPos( easementPLs[0].control, *x, + wControlGetPosY(easementPLs[0].control) ); + } } static void DoEasement( void * unused ) { if (easementW == NULL) { - easementW = ParamCreateDialog( &easementPG, MakeWindowTitle(_("Easement")), _("Ok"), (paramActionOkProc)EasementOk, (paramActionCancelProc)EasementCancel, TRUE, LayoutEasementW, 0, EasementDlgUpdate ); + easementW = ParamCreateDialog( &easementPG, MakeWindowTitle(_("Easement")), + _("Ok"), (paramActionOkProc)EasementOk, (paramActionCancelProc)EasementCancel, + TRUE, LayoutEasementW, 0, EasementDlgUpdate ); SetEasement( easementVal, I2VP(TRUE) ); } oldEasementVal = easementVal; @@ -258,31 +270,32 @@ static void EasementChange( long changes ) } -#include "bitmaps/ease-none.xpm" -#include "bitmaps/ease-sharp.xpm" -#include "bitmaps/ease-gt-sharp.xpm" -#include "bitmaps/ease-lt-sharp.xpm" -#include "bitmaps/ease-normal.xpm" -#include "bitmaps/ease-broad.xpm" -#include "bitmaps/ease-gt-broad.xpm" -#include "bitmaps/ease-lt-broad.xpm" -#include "bitmaps/ease-cornu.xpm" +#include "bitmaps/ease-none.xpm3" +#include "bitmaps/ease-sharp.xpm3" +#include "bitmaps/ease-gt-sharp.xpm3" +#include "bitmaps/ease-lt-sharp.xpm3" +#include "bitmaps/ease-normal.xpm3" +#include "bitmaps/ease-broad.xpm3" +#include "bitmaps/ease-gt-broad.xpm3" +#include "bitmaps/ease-lt-broad.xpm3" +#include "bitmaps/ease-cornu.xpm3" EXPORT addButtonCallBack_t EasementInit( void ) { ParamRegister( &easementPG ); - enone_bm = wIconCreatePixMap( ease_none_xpm[iconSize] ); - eltsharp_bm = wIconCreatePixMap( ease_ltsharp_xpm[iconSize] ); - esharp_bm = wIconCreatePixMap( ease_sharp_xpm[iconSize] ); - egtsharp_bm = wIconCreatePixMap( ease_gtsharp_xpm[iconSize] ); - enormal_bm = wIconCreatePixMap( ease_normal_xpm[iconSize] ); - eltbroad_bm = wIconCreatePixMap( ease_ltbroad_xpm[iconSize] ); - ebroad_bm = wIconCreatePixMap( ease_broad_xpm[iconSize] ); - egtbroad_bm = wIconCreatePixMap( ease_gtbroad_xpm[iconSize] ); - ecornu_bm = wIconCreatePixMap( ease_cornu_xpm[iconSize] ); - easementB = AddToolbarButton( "cmdEasement", enone_bm, 0, DoEasementRedir, NULL ); + enone_bm = wIconCreatePixMap( ease_none_xpm3[iconSize] ); + eltsharp_bm = wIconCreatePixMap( ease_lt_sharp_xpm3[iconSize] ); + esharp_bm = wIconCreatePixMap( ease_sharp_xpm3[iconSize] ); + egtsharp_bm = wIconCreatePixMap( ease_gt_sharp_xpm3[iconSize] ); + enormal_bm = wIconCreatePixMap( ease_normal_xpm3[iconSize] ); + eltbroad_bm = wIconCreatePixMap( ease_lt_broad_xpm3[iconSize] ); + ebroad_bm = wIconCreatePixMap( ease_broad_xpm3[iconSize] ); + egtbroad_bm = wIconCreatePixMap( ease_gt_broad_xpm3[iconSize] ); + ecornu_bm = wIconCreatePixMap( ease_cornu_xpm3[iconSize] ); + easementB = AddToolbarButton( "cmdEasement", enone_bm, 0, DoEasementRedir, + NULL ); RegisterChangeNotification( EasementChange ); return &DoEasement; diff --git a/app/bin/denum.c b/app/bin/denum.c index 9a83ffb..bb87601 100644 --- a/app/bin/denum.c +++ b/app/bin/denum.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "custom.h" @@ -60,30 +60,31 @@ static paramGroup_t enumPG = { "enum", 0, enumPLs, COUNT( enumPLs ) }; static struct wFilSel_t * enumFile_fs; -static int count_utf8_chars(char *s) { +static int count_utf8_chars(char *s) +{ int i = 0, j = 0; while (s[i]) { - if ((s[i] & 0xc0) != 0x80) j++; + if ((s[i] & 0xc0) != 0x80) { j++; } i++; } return j; } static int DoEnumSave( - int files, - char **fileName, - void * data ) + int files, + char **fileName, + void * data ) { - assert( fileName != NULL ); - assert( files == 1 ); - + CHECK( fileName != NULL ); + CHECK( files == 1 ); + SetCurrentPath( PARTLISTPATHKEY, fileName[0] ); return wTextSave( enumT, fileName[ 0 ] ); } static void DoEnumOp( - void * data ) + void * data ) { switch( VP2L(data) ) { case ENUMOP_SAVE: @@ -100,11 +101,11 @@ static void DoEnumOp( static void EnumDlgUpdate( - paramGroup_p pg, - int inx, - void * valueP ) + paramGroup_p pg, + int inx, + void * valueP ) { - if ( inx != I_ENUMLISTPRICE && inx != I_ENUMLISTINDEXES) return; + if ( inx != I_ENUMLISTPRICE && inx != I_ENUMLISTINDEXES) { return; } EnumerateTracks( NULL ); } @@ -113,10 +114,10 @@ int enumerateMaxDescLen; static FLOAT_T enumerateTotal; void EnumerateList( - long count, - FLOAT_T price, - char * desc, - char * indexes ) + long count, + FLOAT_T price, + char * desc, + char * indexes ) { char * cp; size_t len; @@ -124,7 +125,7 @@ void EnumerateList( if (enableListPrices) { cp = message + strlen( message )-1; len = enumerateMaxDescLen-strlen(desc); - if (len<0) len = 0; + if (len<0) { len = 0; } memset( cp, ' ', len ); cp += len; if (price > 0.0) { @@ -134,8 +135,9 @@ void EnumerateList( sprintf( cp, " | %-*s |\n", (int) max( 7, count_utf8_chars( _("Each"))), " " ); } } - if (enableListIndexes && indexes) - sprintf( message, "%s%s -> %s \n", message, N_("Indexes"), indexes); + if (enableListIndexes && indexes) { + sprintf( &message[strlen(message)], "%s -> %s \n", N_("Indexes"), indexes); + } wTextAppend( enumT, message ); } @@ -147,8 +149,10 @@ void EnumerateStart(void) if (enumW == NULL) { ParamRegister( &enumPG ); - enumW = ParamCreateDialog( &enumPG, MakeWindowTitle(_("Parts List")), NULL, NULL, wHide, TRUE, NULL, F_RESIZE, EnumDlgUpdate ); - enumFile_fs = wFilSelCreate( mainW, FS_SAVE, 0, _("Parts List"), sPartsListFilePattern, DoEnumSave, NULL ); + enumW = ParamCreateDialog( &enumPG, MakeWindowTitle(_("Parts List")), NULL, + NULL, wHide, TRUE, NULL, F_RESIZE, EnumDlgUpdate ); + enumFile_fs = wFilSelCreate( mainW, FS_SAVE, 0, _("Parts List"), + sPartsListFilePattern, DoEnumSave, NULL ); } wTextClear( enumT ); @@ -175,37 +179,43 @@ void EnumerateStart(void) } time(&clock); - tm = localtime(&clock); + tm = localtime(&clock); strftime( message, STR_LONG_SIZE, "%x\n", tm ); wTextAppend( enumT, message ); enumerateTotal = 0.0; - if( count_utf8_chars( _("Description")) > enumerateMaxDescLen ) + if( count_utf8_chars( _("Description")) > enumerateMaxDescLen ) { enumerateMaxDescLen = count_utf8_chars( _("Description" )); + } /* create the table header */ - sprintf( message, "%s | %-*s", _("Count"), enumerateMaxDescLen, _("Description")); + sprintf( message, "%s | %-*s", _("Count"), enumerateMaxDescLen, + _("Description")); - if( enableListPrices ) - sprintf( message+strlen(message), " | %-*s | %-*s\n", (int) max( 7, count_utf8_chars( _("Each"))), _("Each"), (int) max( 9, count_utf8_chars(_("Extended"))), _("Extended")); - else + if( enableListPrices ) { + sprintf( message+strlen(message), " | %-*s | %-*s\n", (int) max( 7, + count_utf8_chars( _("Each"))), _("Each"), (int) max( 9, + count_utf8_chars(_("Extended"))), _("Extended")); + } else { strcat( message, "\n" ); + } wTextAppend( enumT, message ); /* underline the header */ cp = message; - while( *cp && *cp != '\n' ) - if( *cp == '|' ) + while( *cp && *cp != '\n' ) + if( *cp == '|' ) { *cp++ = '+'; - else + } else { *cp++ = '-'; + } wTextAppend( enumT, message ); } /** * End of parts list. Print the footer line and the totals if necessary. - * \todo These formatting instructions could be re-written in an easier + * \todo These formatting instructions could be re-written in an easier * to understand fashion using the possibilities of the printf formatting * and some string functions. */ @@ -215,13 +225,13 @@ void EnumerateEnd(void) size_t len; char * cp; ScaleLengthEnd(); - + memset( message, '\0', STR_LONG_SIZE ); memset( message, '-', strlen(_("Count")) + 1 ); strcpy( message + strlen(_("Count")) + 1, "+"); cp = message+strlen(message); memset( cp, '-', enumerateMaxDescLen+2 ); - if (enableListPrices){ + if (enableListPrices) { strcpy( cp+enumerateMaxDescLen+2, "+-" ); memset( cp+enumerateMaxDescLen+4, '-', max( 7, strlen( _("Each")))); strcat( cp, "-+-"); @@ -234,7 +244,8 @@ void EnumerateEnd(void) wTextAppend( enumT, message ); if (enableListPrices) { - len = strlen( message ) - strlen( _("Total")) - max( 9, strlen(_("Extended"))) - 4 ; + len = strlen( message ) - strlen( _("Total")) - max( 9, + strlen(_("Extended"))) - 4 ; memset ( message, ' ', len ); cp = message+len; sprintf( cp, ("%s |%9.2f\n"), _("Total"), enumerateTotal ); diff --git a/app/bin/directory.c b/app/bin/directory.c index 991e139..b0a2b23 100644 --- a/app/bin/directory.c +++ b/app/bin/directory.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "directory.h" @@ -35,18 +35,18 @@ BOOL_T SafeCreateDir(const char *dir) { - int err; - - err = mkdir(dir, 0755); - if (err < 0) { - if (errno != EEXIST) { - NoticeMessage(MSG_DIR_CREATE_FAIL, - _("Continue"), NULL, dir, strerror(errno)); - perror(dir); - return FALSE; - } - } - return TRUE; + int err; + + err = mkdir(dir, 0755); + if (err < 0) { + if (errno != EEXIST) { + NoticeMessage(MSG_DIR_CREATE_FAIL, + _("Continue"), NULL, dir, strerror(errno)); + perror(dir); + return FALSE; + } + } + return TRUE; } /************************************************ @@ -59,83 +59,83 @@ BOOL_T SafeCreateDir(const char *dir) */ BOOL_T DeleteDirectory(const char *dir_path) { - size_t path_len; - char *full_path = NULL; - DIR *dir; - struct stat stat_path, stat_entry; - struct dirent *entry; - DynString path; - - // stat for the path - int resp = stat(dir_path, &stat_path); - - if (resp != 0 && errno == ENOENT) { - return TRUE; //Does not Exist - } - - // if path is not dir - exit - if (!(S_ISDIR(stat_path.st_mode))) { - NoticeMessage(MSG_NOT_DIR_FAIL, - _("Continue"), NULL, dir_path); - return FALSE; - } - - // if not possible to read the directory for this user - if ((dir = opendir(dir_path)) == NULL) { - NoticeMessage(MSG_DIR_OPEN_FAIL, - _("Continue"), NULL, dir_path); - return FALSE; - } - - // the length of the path - path_len = strlen(dir_path) + 1; - DynStringMalloc(&path, path_len + 16); //guessing the total path length - - // iteration through entries in the directory - while ((entry = readdir(dir)) != NULL) { - - // skip entries "." and ".." - if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, "..")) { - continue; - } - - // determinate a full path of an entry - DynStringReset(&path); - DynStringCatCStrs(&path, dir_path, FILE_SEP_CHAR, entry->d_name, NULL); - full_path = DynStringToCStr(&path); - // stat for the entry - stat(full_path, &stat_entry); - - // recursively remove a nested directory - if (S_ISDIR(stat_entry.st_mode) != 0) { - DeleteDirectory(full_path); - continue; - } - - // remove a file object - if (unlink(full_path)) { - NoticeMessage(MSG_UNLINK_FAIL, _("Continue"), NULL, full_path); - DynStringFree(&path); - closedir(dir); - return FALSE; - } else { + size_t path_len; + char *full_path = NULL; + DIR *dir; + struct stat stat_path, stat_entry; + struct dirent *entry; + DynString path; + + // stat for the path + int resp = stat(dir_path, &stat_path); + + if (resp != 0 && errno == ENOENT) { + return TRUE; //Does not Exist + } + + // if path is not dir - exit + if (!(S_ISDIR(stat_path.st_mode))) { + NoticeMessage(MSG_NOT_DIR_FAIL, + _("Continue"), NULL, dir_path); + return FALSE; + } + + // if not possible to read the directory for this user + if ((dir = opendir(dir_path)) == NULL) { + NoticeMessage(MSG_DIR_OPEN_FAIL, + _("Continue"), NULL, dir_path); + return FALSE; + } + + // the length of the path + path_len = strlen(dir_path) + 1; + DynStringMalloc(&path, path_len + 16); //guessing the total path length + + // iteration through entries in the directory + while ((entry = readdir(dir)) != NULL) { + + // skip entries "." and ".." + if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, "..")) { + continue; + } + + // determinate a full path of an entry + DynStringReset(&path); + DynStringCatCStrs(&path, dir_path, FILE_SEP_CHAR, entry->d_name, NULL); + full_path = DynStringToCStr(&path); + // stat for the entry + stat(full_path, &stat_entry); + + // recursively remove a nested directory + if (S_ISDIR(stat_entry.st_mode) != 0) { + DeleteDirectory(full_path); + continue; + } + + // remove a file object + if (unlink(full_path)) { + NoticeMessage(MSG_UNLINK_FAIL, _("Continue"), NULL, full_path); + DynStringFree(&path); + closedir(dir); + return FALSE; + } else { #if DEBUG - printf("Removed a file: %s \n", full_path); + printf("Removed a file: %s \n", full_path); #endif - } - } + } + } - closedir(dir); - DynStringFree(&path); + closedir(dir); + DynStringFree(&path); - // remove the devastated directory and close the object of it - if (rmdir(dir_path)) { - NoticeMessage(MSG_RMDIR_FAIL, _("Continue"), NULL, dir_path); - return FALSE; - } else { + // remove the devastated directory and close the object of it + if (rmdir(dir_path)) { + NoticeMessage(MSG_RMDIR_FAIL, _("Continue"), NULL, dir_path); + return FALSE; + } else { #if DEBUG - printf("Removed a directory: %s \n", dir_path); + printf("Removed a directory: %s \n", dir_path); #endif - } - return TRUE; + } + return TRUE; } diff --git a/app/bin/directory.h b/app/bin/directory.h index 2ddfffd..b88f256 100644 --- a/app/bin/directory.h +++ b/app/bin/directory.h @@ -1,6 +1,6 @@ #ifndef HAVE_DIRECTORY_H
- #define HAVE_DIRECTORY_H
- #include "common.h"
- BOOL_T SafeCreateDir(const char *dir);
- BOOL_T DeleteDirectory(const char *dir_path);
+#define HAVE_DIRECTORY_H
+#include "common.h"
+BOOL_T SafeCreateDir(const char *dir);
+BOOL_T DeleteDirectory(const char *dir_path);
#endif
\ No newline at end of file diff --git a/app/bin/dlayer.c b/app/bin/dlayer.c index e5fed61..92c58c4 100644 --- a/app/bin/dlayer.c +++ b/app/bin/dlayer.c @@ -1,1798 +1,2363 @@ -/** \file dlayer.c - * Functions and dialogs for handling layers. - */ - -/* XTrkCad - Model Railroad CAD - * Copyright (C) 2005 Dave Bullis and (C) 2007 Martin Fischer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "cselect.h" -#include "custom.h" -#include "paths.h" -#include "dynstring.h" -#include "fileio.h" -#include "layout.h" -#include "param.h" -#include "track.h" -#include "include/partcatalog.h" -#include "include/stringxtc.h" -#include "common-ui.h" - -/***************************************************************************** - * - * LAYERS - * - */ - -#define NUM_BUTTONS (99) -#define LAYERPREF_FROZEN (1) -#define LAYERPREF_ONMAP (2) -#define LAYERPREF_VISIBLE (4) -#define LAYERPREF_MODULE (8) -#define LAYERPREF_NOBUTTON (16) -#define LAYERPREF_SECTION ("Layers") -#define LAYERPREF_NAME "name" -#define LAYERPREF_COLOR "color" -#define LAYERPREF_FLAGS "flags" -#define LAYERPREF_LIST "list" -#define LAYERPREF_SETTINGS "settings" - -unsigned int curLayer; -long layerCount = 10; -static long newLayerCount = 10; -static unsigned int layerCurrent = NUM_LAYERS; - - -static BOOL_T layoutLayerChanged = FALSE; - -static wIcon_p show_layer_bmps[NUM_BUTTONS]; -static wButton_p layer_btns[NUM_BUTTONS]; /**< layer buttons on toolbar */ - -/** Layer selector on toolbar */ -static wList_p setLayerL; - -/** Describe the properties of a layer */ -typedef struct { - char name[STR_SHORT_SIZE]; /**< Layer name */ - wDrawColor color; /**< layer color, is an index into a color table */ - BOOL_T useColor; /**< Use Layer color */ - BOOL_T frozen; /**< Frozen flag */ - BOOL_T visible; /**< visible flag */ - BOOL_T onMap; /**< is layer shown map */ - BOOL_T module; /**< is layer a module (all or nothing) */ - BOOL_T button_off; /**< hide button */ - long objCount; /**< number of objects on layer */ - dynArr_t layerLinkList; /**< other layers that show/hide with this one */ - char settingsName[STR_SHORT_SIZE]; /**< name of settings file to load when this is current */ -} layer_t; - -static layer_t layers[NUM_LAYERS]; -static layer_t *layers_save = NULL; - -static Catalog * settingsCatalog; - - -static int oldColorMap[][3] = { - { 255, 255, 255 }, /* White */ - { 0, 0, 0 }, /* Black */ - { 255, 0, 0 }, /* Red */ - { 0, 255, 0 }, /* Green */ - { 0, 0, 255 }, /* Blue */ - { 255, 255, 0 }, /* Yellow */ - { 255, 0, 255 }, /* Purple */ - { 0, 255, 255 }, /* Aqua */ - { 128, 0, 0 }, /* Dk. Red */ - { 0, 128, 0 }, /* Dk. Green */ - { 0, 0, 128 }, /* Dk. Blue */ - { 128, 128, 0 }, /* Dk. Yellow */ - { 128, 0, 128 }, /* Dk. Purple */ - { 0, 128, 128 }, /* Dk. Aqua */ - { 65, 105, 225 }, /* Royal Blue */ - { 0, 191, 255 }, /* DeepSkyBlue */ - { 125, 206, 250 }, /* LightSkyBlue */ - { 70, 130, 180 }, /* Steel Blue */ - { 176, 224, 230 }, /* Powder Blue */ - { 127, 255, 212 }, /* Aquamarine */ - { 46, 139, 87 }, /* SeaGreen */ - { 152, 251, 152 }, /* PaleGreen */ - { 124, 252, 0 }, /* LawnGreen */ - { 50, 205, 50 }, /* LimeGreen */ - { 34, 139, 34 }, /* ForestGreen */ - { 255, 215, 0 }, /* Gold */ - { 188, 143, 143 }, /* RosyBrown */ - { 139, 69, 19 }, /* SaddleBrown */ - { 245, 245, 220 }, /* Beige */ - { 210, 180, 140 }, /* Tan */ - { 210, 105, 30 }, /* Chocolate */ - { 165, 42, 42 }, /* Brown */ - { 255, 165, 0 }, /* Orange */ - { 255, 127, 80 }, /* Coral */ - { 255, 99, 71 }, /* Tomato */ - { 255, 105, 180 }, /* HotPink */ - { 255, 192, 203 }, /* Pink */ - { 176, 48, 96 }, /* Maroon */ - { 238, 130, 238 }, /* Violet */ - { 160, 32, 240 }, /* Purple */ - { 16, 16, 16 }, /* Gray */ - { 32, 32, 32 }, /* Gray */ - { 48, 48, 48 }, /* Gray */ - { 64, 64, 64 }, /* Gray */ - { 80, 80, 80 }, /* Gray */ - { 96, 96, 96 }, /* Gray */ - { 112, 112, 122 }, /* Gray */ - { 128, 128, 128 }, /* Gray */ - { 144, 144, 144 }, /* Gray */ - { 160, 160, 160 }, /* Gray */ - { 176, 176, 176 }, /* Gray */ - { 192, 192, 192 }, /* Gray */ - { 208, 208, 208 }, /* Gray */ - { 224, 224, 224 }, /* Gray */ - { 240, 240, 240 }, /* Gray */ - { 0, 0, 0 } /* BlackPixel */ -}; - -static void DoLayerOp(void * data); -void UpdateLayerDlg(unsigned int); - -static void InitializeLayers(void LayerInitFunc(void), int newCurrLayer); -static void LayerPrefSave(void); -static void LayerPrefLoad(void); - -int IsLayerValid(unsigned int layer) -{ - return (layer <= NUM_LAYERS && layer != -1); -} - -BOOL_T GetLayerVisible(unsigned int layer) -{ - if (!IsLayerValid(layer)) { - return TRUE; - } else { - return layers[layer].visible; - } -} - -BOOL_T GetLayerHidden(unsigned int layer) -{ - if (!IsLayerValid(layer)) { - return TRUE; - } else { - return layers[layer].button_off; - } -} - - -BOOL_T GetLayerFrozen(unsigned int layer) -{ - if (!IsLayerValid(layer)) { - return TRUE; - } else { - return layers[layer].frozen; - } -} - - -BOOL_T GetLayerOnMap(unsigned int layer) -{ - if (!IsLayerValid(layer)) { - return TRUE; - } else { - return layers[layer].onMap; - } -} - -BOOL_T GetLayerModule(unsigned int layer) -{ - if (!IsLayerValid(layer)) { - return TRUE; - } else { - return layers[layer].module; - } -} - -void SetLayerModule(unsigned int layer, BOOL_T module) -{ - if (IsLayerValid(layer)) { - layers[layer].module = module; - } -} - - -char * GetLayerName(unsigned int layer) -{ - if (!IsLayerValid(layer)) { - return NULL; - } else { - return layers[layer].name; - } -} - -void SetLayerName(unsigned int layer, char* name) { - if (IsLayerValid(layer)) { - strcpy(layers[layer].name,name); - } -} - -BOOL_T GetLayerUseColor(unsigned int layer) { - return layers[layer].useColor; -} - -wDrawColor GetLayerColor(unsigned int layer) -{ - return layers[layer].color; -} - -static void RedrawLayer( unsigned int l, BOOL_T draw ) -{ - DoRedraw(); // RedrawLayer -} - - -EXPORT void FlipLayer( void * layerVP ) -{ - unsigned int layer = (unsigned int)VP2L(layerVP); - wBool_t visible; - - if (!IsLayerValid(layer)) { - return; - } - - if (layer == curLayer && layers[layer].visible) { - if (!layers[layer].button_off) - wButtonSetBusy(layer_btns[layer], layers[layer].visible); - NoticeMessage(MSG_LAYER_HIDE, _("Ok"), NULL); - return; - } - - RedrawLayer(layer, FALSE); - visible = !layers[layer].visible; - layers[layer].visible = visible; - - if (layer<NUM_BUTTONS) { - if (!layers[layer].button_off) { - wButtonSetBusy(layer_btns[layer], visible != 0); - wButtonSetLabel(layer_btns[layer], (char *)show_layer_bmps[layer]); - } - } - - /* Set visible on related layers other than current */ - for (int i=0;i<layers[layer].layerLinkList.cnt;i++) { - int l = DYNARR_N(int,layers[layer].layerLinkList,i)-1; - if ((l != curLayer) && (l >=0) && (l < NUM_LAYERS)) { - layers[l].visible = layers[layer].visible; - if (!layers[l].button_off) - wButtonSetBusy(layer_btns[l], layers[l].visible); - } - } - - RedrawLayer(layer, TRUE); -} - -static char lastSettings[STR_SHORT_SIZE]; -void SetCurrLayer(wIndex_t inx, const char * name, wIndex_t op, - void * listContext, void * arg) -{ - unsigned int newLayer = (unsigned int)inx; - - if (layers[newLayer].frozen) { - NoticeMessage(MSG_LAYER_SEL_FROZEN, _("Ok"), NULL); - wListSetIndex(setLayerL, curLayer); - return; - } - - char *array[1]; - if (!layers[inx].settingsName[0] || strcmp(layers[inx].settingsName," ")==0) { - if (lastSettings[0]) { - DoSettingsRead(1,NULL, NULL); - } - lastSettings[0] = '\0'; - } else { - if (strcmp(layers[inx].settingsName,lastSettings)!=0) { - if (!lastSettings[0]) wPrefFlush(""); // Save Last Settings for no settings file - array[0] = layers[inx].settingsName; - DoSettingsRead(1,array, NULL); - } - strcpy(lastSettings,layers[inx].settingsName); - } - - - curLayer = newLayer; - - if (!IsLayerValid(curLayer)) { - curLayer = 0; //Too big or -1 - layers[curLayer].frozen = FALSE; //Make sure the layer is not frozen - } - - - if (!layers[curLayer].visible) { - FlipLayer(I2VP(inx)); - } - - /* Set visible on related layers other than current */ - for (int i=0;i<layers[curLayer].layerLinkList.cnt;i++) { - int l = DYNARR_N(int,layers[curLayer].layerLinkList,i)-1; - if (l != curLayer && l >=0 && l < NUM_LAYERS) { - layers[l].visible = layers[curLayer].visible; - if (!layers[l].button_off) - wButtonSetBusy(layer_btns[l], layers[l].visible); - } - } - - if (recordF) { - fprintf(recordF, "SETCURRLAYER %d\n", inx); - } -} - -static void PlaybackCurrLayer(char * line) -{ - wIndex_t layer; - layer = atoi(line); - wListSetIndex(setLayerL, layer); - SetCurrLayer(layer, NULL, 0, NULL, NULL); -} - -/** - * Change the color of a layer. - * - * \param inx IN layer to change - * \param color IN new color - */ - -static void SetLayerColor(unsigned int inx, wDrawColor color) -{ - if (color != layers[inx].color) { - if (inx < NUM_BUTTONS) { - wIconSetColor(show_layer_bmps[inx], color); - wButtonSetLabel(layer_btns[inx], (char*)show_layer_bmps[inx]); - } - - layers[inx].color = color; - layoutLayerChanged = TRUE; - } -} - -static void SetLayerHideButton(unsigned int inx, wBool_t hide) { - if (hide != layers[inx].button_off) { - if (inx < NUM_BUTTONS) { - wControlShow((wControl_p)layer_btns[inx],!hide); - if (!hide) wButtonSetBusy(layer_btns[inx], layers[inx].visible); - } - layers[inx].button_off = hide; - layoutLayerChanged = TRUE; - } -} - -char * -FormatLayerName(unsigned int layerNumber) -{ - DynString string;// = NaS; - char *result; - DynStringMalloc(&string, 0); - DynStringPrintf(&string, - "%2d %c %s", - layerNumber + 1, - (layers[layerNumber].frozen ? '*': layers[layerNumber].module ? 'm': layers[layerNumber].objCount > 0 ? '+' : '-'), - layers[layerNumber].name); - result = strdup(DynStringToCStr(&string)); - DynStringFree(&string); - return result; -} - -static int lbits_width[3] = {14,20,26}; -static int lbits_height[3] = {16,24,32}; - -#include "bitmaps/l1.xbm" -#include "bitmaps/l2.xbm" -#include "bitmaps/l3.xbm" -#include "bitmaps/l4.xbm" -#include "bitmaps/l5.xbm" -#include "bitmaps/l6.xbm" -#include "bitmaps/l7.xbm" -#include "bitmaps/l8.xbm" -#include "bitmaps/l9.xbm" -#include "bitmaps/l10.xbm" -#include "bitmaps/l11.xbm" -#include "bitmaps/l12.xbm" -#include "bitmaps/l13.xbm" -#include "bitmaps/l14.xbm" -#include "bitmaps/l15.xbm" -#include "bitmaps/l16.xbm" -#include "bitmaps/l17.xbm" -#include "bitmaps/l18.xbm" -#include "bitmaps/l19.xbm" -#include "bitmaps/l20.xbm" -#include "bitmaps/l21.xbm" -#include "bitmaps/l22.xbm" -#include "bitmaps/l23.xbm" -#include "bitmaps/l24.xbm" -#include "bitmaps/l25.xbm" -#include "bitmaps/l26.xbm" -#include "bitmaps/l27.xbm" -#include "bitmaps/l28.xbm" -#include "bitmaps/l29.xbm" -#include "bitmaps/l30.xbm" -#include "bitmaps/l31.xbm" -#include "bitmaps/l32.xbm" -#include "bitmaps/l33.xbm" -#include "bitmaps/l34.xbm" -#include "bitmaps/l35.xbm" -#include "bitmaps/l36.xbm" -#include "bitmaps/l37.xbm" -#include "bitmaps/l38.xbm" -#include "bitmaps/l39.xbm" -#include "bitmaps/l40.xbm" -#include "bitmaps/l41.xbm" -#include "bitmaps/l42.xbm" -#include "bitmaps/l43.xbm" -#include "bitmaps/l44.xbm" -#include "bitmaps/l45.xbm" -#include "bitmaps/l46.xbm" -#include "bitmaps/l47.xbm" -#include "bitmaps/l48.xbm" -#include "bitmaps/l49.xbm" -#include "bitmaps/l50.xbm" -#include "bitmaps/l51.xbm" -#include "bitmaps/l52.xbm" -#include "bitmaps/l53.xbm" -#include "bitmaps/l54.xbm" -#include "bitmaps/l55.xbm" -#include "bitmaps/l56.xbm" -#include "bitmaps/l57.xbm" -#include "bitmaps/l58.xbm" -#include "bitmaps/l59.xbm" -#include "bitmaps/l60.xbm" -#include "bitmaps/l61.xbm" -#include "bitmaps/l62.xbm" -#include "bitmaps/l63.xbm" -#include "bitmaps/l64.xbm" -#include "bitmaps/l65.xbm" -#include "bitmaps/l66.xbm" -#include "bitmaps/l67.xbm" -#include "bitmaps/l68.xbm" -#include "bitmaps/l69.xbm" -#include "bitmaps/l70.xbm" -#include "bitmaps/l71.xbm" -#include "bitmaps/l72.xbm" -#include "bitmaps/l73.xbm" -#include "bitmaps/l74.xbm" -#include "bitmaps/l75.xbm" -#include "bitmaps/l76.xbm" -#include "bitmaps/l77.xbm" -#include "bitmaps/l78.xbm" -#include "bitmaps/l79.xbm" -#include "bitmaps/l80.xbm" -#include "bitmaps/l81.xbm" -#include "bitmaps/l82.xbm" -#include "bitmaps/l83.xbm" -#include "bitmaps/l84.xbm" -#include "bitmaps/l85.xbm" -#include "bitmaps/l86.xbm" -#include "bitmaps/l87.xbm" -#include "bitmaps/l88.xbm" -#include "bitmaps/l89.xbm" -#include "bitmaps/l90.xbm" -#include "bitmaps/l91.xbm" -#include "bitmaps/l92.xbm" -#include "bitmaps/l93.xbm" -#include "bitmaps/l94.xbm" -#include "bitmaps/l95.xbm" -#include "bitmaps/l96.xbm" -#include "bitmaps/l97.xbm" -#include "bitmaps/l98.xbm" -#include "bitmaps/l99.xbm" - - -static char * show_layer_bits[3][NUM_BUTTONS] = { - { l1_x16, l2_x16, l3_x16, l4_x16, l5_x16, l6_x16, l7_x16, l8_x16, l9_x16, l10_x16, - l11_x16, l12_x16, l13_x16, l14_x16, l15_x16, l16_x16, l17_x16, l18_x16, l19_x16, l20_x16, - l21_x16, l22_x16, l23_x16, l24_x16, l25_x16, l26_x16, l27_x16, l28_x16, l29_x16, l30_x16, - l31_x16, l32_x16, l33_x16, l34_x16, l35_x16, l36_x16, l37_x16, l38_x16, l39_x16, l40_x16, - l41_x16, l42_x16, l43_x16, l44_x16, l45_x16, l46_x16, l47_x16, l48_x16, l49_x16, l50_x16, - l51_x16, l52_x16, l53_x16, l54_x16, l55_x16, l56_x16, l57_x16, l58_x16, l59_x16, l60_x16, - l61_x16, l62_x16, l63_x16, l64_x16, l65_x16, l66_x16, l67_x16, l68_x16, l69_x16, l70_x16, - l71_x16, l72_x16, l73_x16, l74_x16, l75_x16, l76_x16, l77_x16, l78_x16, l79_x16, l80_x16, - l81_x16, l82_x16, l83_x16, l84_x16, l85_x16, l86_x16, l87_x16, l88_x16, l89_x16, l90_x16, - l91_x16, l92_x16, l93_x16, l94_x16, l95_x16, l96_x16, l97_x16, l98_x16, l99_x16, }, - { l1_x24, l2_x24, l3_x24, l4_x24, l5_x24, l6_x24, l7_x24, l8_x24, l9_x24, l10_x24, - l11_x24, l12_x24, l13_x24, l14_x24, l15_x24, l16_x24, l17_x24, l18_x24, l19_x24, l20_x24, - l21_x24, l22_x24, l23_x24, l24_x24, l25_x24, l26_x24, l27_x24, l28_x24, l29_x24, l30_x24, - l31_x24, l32_x24, l33_x24, l34_x24, l35_x24, l36_x24, l37_x24, l38_x24, l39_x24, l40_x24, - l41_x24, l42_x24, l43_x24, l44_x24, l45_x24, l46_x24, l47_x24, l48_x24, l49_x24, l50_x24, - l51_x24, l52_x24, l53_x24, l54_x24, l55_x24, l56_x24, l57_x24, l58_x24, l59_x24, l60_x24, - l61_x24, l62_x24, l63_x24, l64_x24, l65_x24, l66_x24, l67_x24, l68_x24, l69_x24, l70_x24, - l71_x24, l72_x24, l73_x24, l74_x24, l75_x24, l76_x24, l77_x24, l78_x24, l79_x24, l80_x24, - l81_x24, l82_x24, l83_x24, l84_x24, l85_x24, l86_x24, l87_x24, l88_x24, l89_x24, l90_x24, - l91_x24, l92_x24, l93_x24, l94_x24, l95_x24, l96_x24, l97_x24, l98_x24, l99_x24, }, - { l1_x32, l2_x32, l3_x32, l4_x32, l5_x32, l6_x32, l7_x32, l8_x32, l9_x32, l10_x32, - l11_x32, l12_x32, l13_x32, l14_x32, l15_x32, l16_x32, l17_x32, l18_x32, l19_x32, l20_x32, - l21_x32, l22_x32, l23_x32, l24_x32, l25_x32, l26_x32, l27_x32, l28_x32, l29_x32, l30_x32, - l31_x32, l32_x32, l33_x32, l34_x32, l35_x32, l36_x32, l37_x32, l38_x32, l39_x32, l40_x32, - l41_x32, l42_x32, l43_x32, l44_x32, l45_x32, l46_x32, l47_x32, l48_x32, l49_x32, l50_x32, - l51_x32, l52_x32, l53_x32, l54_x32, l55_x32, l56_x32, l57_x32, l58_x32, l59_x32, l60_x32, - l61_x32, l62_x32, l63_x32, l64_x32, l65_x32, l66_x32, l67_x32, l68_x32, l69_x32, l70_x32, - l71_x32, l72_x32, l73_x32, l74_x32, l75_x32, l76_x32, l77_x32, l78_x32, l79_x32, l80_x32, - l81_x32, l82_x32, l83_x32, l84_x32, l85_x32, l86_x32, l87_x32, l88_x32, l89_x32, l90_x32, - l91_x32, l92_x32, l93_x32, l94_x32, l95_x32, l96_x32, l97_x32, l98_x32, l99_x32, } -}; - - -static long layerRawColorTab[] = { - wRGB(0, 0,255), /* blue */ - wRGB(0, 0,128), /* dk blue */ - wRGB(0,128, 0), /* dk green */ - wRGB(255,255, 0), /* yellow */ - wRGB(0,255, 0), /* green */ - wRGB(0,255,255), /* lt cyan */ - wRGB(128, 0, 0), /* brown */ - wRGB(128, 0,128), /* purple */ - wRGB(128,128, 0), /* green-brown */ - wRGB(255, 0,255) -}; /* lt-purple */ -static wDrawColor layerColorTab[COUNT(layerRawColorTab)]; - - -static wWin_p layerW; -static char layerName[STR_SHORT_SIZE]; -static char layerLinkList[STR_LONG_SIZE]; -static char settingsName[STR_SHORT_SIZE]; -static wDrawColor layerColor; -static long layerUseColor = TRUE; -static long layerVisible = TRUE; -static long layerFrozen = FALSE; -static long layerOnMap = TRUE; -static long layerModule = FALSE; -static long layerNoButton = FALSE; -static void LayerOk(void * unused); -static BOOL_T layerRedrawMap = FALSE; - -#define ENUMLAYER_RELOAD (1) -#define ENUMLAYER_SAVE (2) -#define ENUMLAYER_CLEAR (3) - -static char *visibleLabels[] = { "", NULL }; -static char *frozenLabels[] = { "", NULL }; -static char *onMapLabels[] = { "", NULL }; -static char *moduleLabels[] = { "", NULL }; -static char *layerColorLabels[] = { "", NULL }; -static paramIntegerRange_t i0_20 = { 0, NUM_BUTTONS }; -static paramListData_t layerUiListData = { 10, 370, 0 }; - -static paramData_t layerPLs[] = { -#define I_LIST (0) - { PD_DROPLIST, NULL, "layer", PDO_LISTINDEX, I2VP(250), N_("Select Layer:") }, -#define I_NAME (1) - { PD_STRING, layerName, "name", PDO_NOPREF|PDO_STRINGLIMITLENGTH, I2VP(250-54), N_("Name"), 0, 0, sizeof(layerName) }, -#define I_COLOR (2) - { PD_COLORLIST, &layerColor, "color", PDO_NOPREF, NULL, N_("Color") }, -#define I_USE_COLOR (3) - { PD_TOGGLE, &layerUseColor, "layercolor", PDO_NOPREF|PDO_DLGHORZ, layerColorLabels, N_("Use Color"), BC_HORZ|BC_NOBORDER }, -#define I_VIS (4) - { PD_TOGGLE, &layerVisible, "visible", PDO_NOPREF, visibleLabels, N_("Visible"), BC_HORZ|BC_NOBORDER }, -#define I_FRZ (5) - { PD_TOGGLE, &layerFrozen, "frozen", PDO_NOPREF|PDO_DLGHORZ, frozenLabels, N_("Frozen"), BC_HORZ|BC_NOBORDER }, -#define I_MAP (6) - { PD_TOGGLE, &layerOnMap, "onmap", PDO_NOPREF|PDO_DLGHORZ, onMapLabels, N_("On Map"), BC_HORZ|BC_NOBORDER }, -#define I_MOD (7) - { PD_TOGGLE, &layerModule, "module", PDO_NOPREF|PDO_DLGHORZ, moduleLabels, N_("Module"), BC_HORZ|BC_NOBORDER }, -#define I_BUT (8) - { PD_TOGGLE, &layerNoButton, "button", PDO_NOPREF|PDO_DLGHORZ, moduleLabels, N_("No Button"), BC_HORZ|BC_NOBORDER }, -#define I_LINKLIST (9) - { PD_STRING, layerLinkList, "layerlist", PDO_NOPREF|PDO_STRINGLIMITLENGTH, I2VP(250-54), N_("Linked Layers"), 0, 0, sizeof(layerLinkList) }, -#define I_SETTINGS (10) - { PD_DROPLIST, NULL, "settings", PDO_LISTINDEX, I2VP( 250), N_("Settings when Current") }, -#define I_COUNT (11) - { PD_MESSAGE, N_("Object Count:"), NULL, PDO_DLGBOXEND|PDO_DLGNOLABELALIGN, I2VP(370) }, - { PD_MESSAGE, N_("All Layer Preferences"), NULL, PDO_DLGRESETMARGIN, I2VP(180) }, - { PD_BUTTON, DoLayerOp, "load", PDO_DLGRESETMARGIN, 0, N_("Load"), 0, I2VP(ENUMLAYER_RELOAD) }, - { PD_BUTTON, DoLayerOp, "save", PDO_DLGHORZ, 0, N_("Save"), 0, I2VP(ENUMLAYER_SAVE) }, - { PD_BUTTON, DoLayerOp, "clear", PDO_DLGHORZ | PDO_DLGBOXEND, 0, N_("Defaults"), 0, I2VP(ENUMLAYER_CLEAR) }, - { PD_LONG, &newLayerCount, "button-count", PDO_DLGBOXEND|PDO_DLGRESETMARGIN, &i0_20, N_("Number of Layer Buttons") }, -}; - -#define settingsListL ((wList_p)layerPLs[I_SETTINGS].control) -#define MESSAGETEXT ((wMessage_p)layerPLs[I_COUNT].control) - -static paramGroup_t layerPG = { "layer", 0, layerPLs, COUNT( layerPLs ) }; - -/** - * Reload the listbox showing the current catalog - */ - -static -int LoadFileListLoad(Catalog *catalog, char * name) -{ - CatalogEntry *currentEntry = catalog->head; - DynString description; - DynStringMalloc(&description, STR_SHORT_SIZE); - - wControlShow((wControl_p)settingsListL, FALSE); - wListClear(settingsListL); - - int currset = 0; - - int i = 0; - - wListAddValue(settingsListL," ",NULL," "); - - while (currentEntry) { - i++; - DynStringClear(&description); - DynStringCatCStr(&description, - currentEntry->contents) ; - wListAddValue(settingsListL, - DynStringToCStr(&description), - NULL, - currentEntry->fullFileName[0]); - if (strcmp(currentEntry->fullFileName[0],name)==0) currset = i; - currentEntry = currentEntry->next; - } - - - wListSetIndex(settingsListL,currset); - - wControlShow((wControl_p)settingsListL, TRUE); - - DynStringFree(&description); - - if (currset == 0 && strcmp(" ",name)!=0) return FALSE; - return TRUE; - -} - -#define layerL ((wList_p)layerPLs[I_LIST].control) - -#define layerS ((wList_p)layerPLs[I_SETTINGS].control) - -void GetLayerLinkString(int inx,char * list) { - - char * cp = &list[0]; - cp[0] = '\0'; - int len = 0; - for (int i = 0; i<layers[inx].layerLinkList.cnt && len<STR_LONG_SIZE-5; i++) { - int l = DYNARR_N(int,layers[inx].layerLinkList,i); - if (i==0) - cp += sprintf(cp,"%d",l); - else - cp += sprintf(cp,";%d",l); - cp[0] = '\0'; - } -} - -void PutLayerListArray(int inx, char * list) { - char * cp = &list[0]; - DYNARR_RESET(int, layers[inx].layerLinkList); - while (cp) { - cp = strpbrk(list,",; "); - if (cp) { - cp[0] ='\0'; - int i = abs((int)strtol(list,&list,0)); - if (i>0 && i !=inx-1 && i<NUM_LAYERS) { - DYNARR_APPEND(int,layers[inx].layerLinkList,1); - DYNARR_LAST(int, layers[inx].layerLinkList) = i; - } - cp[0] = ';'; - list = cp+1; - } else { - int i = abs((int)strtol(list,&list,0)); - if (i>0 && i !=inx-1 && i<NUM_LAYERS) { - DYNARR_APPEND(int,layers[inx].layerLinkList,1); - DYNARR_LAST(int,layers[inx].layerLinkList) = i; - } - cp = 0; - } - } -} - - -/** - * Load the layer settings to hard coded system defaults - */ - -void -LayerSystemDefaults(void) -{ - int inx; - - for (inx=0; inx<NUM_LAYERS; inx++) { - strcpy(layers[inx].name, inx==0?_("Main"):""); - layers[inx].visible = TRUE; - layers[inx].frozen = FALSE; - layers[inx].onMap = TRUE; - layers[inx].module = FALSE; - layers[inx].button_off = FALSE; - layers[inx].objCount = 0; - DYNARR_RESET(int,layers[inx].layerLinkList); - SetLayerColor(inx, layerColorTab[inx%COUNT(layerColorTab)]); - } -} - -/** - * Load the layer listboxes in Manage Layers and the Toolbar with up-to-date information. - */ - -void LoadLayerLists(void) -{ - int inx; - /* clear both lists */ - wListClear(setLayerL); - - if (layerL) { - wListClear(layerL); - } - - if (layerS) { - wListClear(layerS); - } - - - /* add all layers to both lists */ - for (inx=0; inx<NUM_LAYERS; inx++) { - char *layerLabel; - layerLabel = FormatLayerName(inx); - - if (layerL) { - wListAddValue(layerL, layerLabel, NULL, NULL); - } - - wListAddValue(setLayerL, layerLabel, NULL, NULL); - free(layerLabel); - } - - /* set current layer to selected */ - wListSetIndex(setLayerL, curLayer); - - if (layerL) wListSetIndex(layerL,curLayer); - -} - -/** - * Handle button presses for the layer dialog. For all button presses in the layer - * dialog, this function is called. The parameter identifies the button pressed and - * the operation is performed. - * - * \param[IN] data identifier for the button prerssed - * \return - */ - -static void DoLayerOp(void * data) -{ - switch (VP2L(data)) { - case ENUMLAYER_CLEAR: - InitializeLayers(LayerSystemDefaults, -1); - break; - - case ENUMLAYER_SAVE: - LayerPrefSave(); - break; - - case ENUMLAYER_RELOAD: - LayerPrefLoad(); - break; - } - - UpdateLayerDlg(curLayer); //Reset to current Layer - - if (layoutLayerChanged) { - MainProc(mainW, wResize_e, NULL, NULL); - layoutLayerChanged = FALSE; - SetFileChanged(); - } -} - -/** - * Update all dialogs and dialog elements after changing layers preferences. Once the global array containing - * the settings for the labels has been changed, this function needs to be called to update all the user interface - * elements to the new settings. - */ - -EXPORT void UpdateLayerDlg(unsigned int layer) -{ - int inx; - /* update the globals for the layer dialog */ - layerVisible = layers[layer].visible; - layerFrozen = layers[layer].frozen; - layerOnMap = layers[layer].onMap; - layerModule = layers[layer].module; - layerColor = layers[layer].color; - layerUseColor = layers[layer].useColor; - layerNoButton = layers[layer].button_off; - strcpy(layerName, layers[layer].name); - strcpy(settingsName, layers[layer].settingsName); - GetLayerLinkString(layer,layerLinkList); - - layerCurrent = layer; - /* now re-load the layer list boxes */ - LoadLayerLists(); - - - - /* force update of the 'manage layers' dialogbox */ - if (layerL) { - wListSetIndex(layerL,layer); - ParamLoadControls(&layerPG); - } - - if (layerS) { - if (!LoadFileListLoad(settingsCatalog,settingsName)) - layers[layer].settingsName[0] = '\0'; - } - - sprintf(message, "Object Count: %ld", layers[layer].objCount); - if (MESSAGETEXT) wMessageSetValue(MESSAGETEXT, message); - - /* finally show the layer buttons with balloon text */ - for (inx = 0; inx < NUM_BUTTONS; inx++) { - if (!layers[inx].button_off) { - wButtonSetBusy(layer_btns[inx], layers[inx].visible != 0); - wControlSetBalloonText((wControl_p)layer_btns[inx], - (layers[inx].name[0] != '\0' ? layers[inx].name :_("Show/Hide Layer"))); - } - } - -} - -/** - * Fill a layer dropbox with the current layer settings - * - * \param listLayers the dropbox - * \return - */ - -void -FillLayerList( wList_p listLayers) -{ - wListClear(listLayers); // Rebuild list on each invovation - - for (int inx = 0; inx < NUM_LAYERS; inx++) { - char *layerFormattedName; - layerFormattedName = FormatLayerName(inx); - wListAddValue((wList_p)listLayers, layerFormattedName, NULL, I2VP(inx)); - free(layerFormattedName); - } - - /* set current layer to selected */ - wListSetIndex(listLayers, curLayer); -} -/** - * Initialize the layer lists. - * - * \param IN pointer to function that actually initialize tha data structures - * \param IN current layer (0...NUM_LAYERS), (-1) for no change - */ - -static void -InitializeLayers(void LayerInitFunc(void), int newCurrLayer) -{ - /* reset the data structures to default valuses */ - LayerInitFunc(); - /* count the objects on each layer */ - LayerSetCounts(); - - /* Switch the current layer when requested or the first above not frozen*/ - if (newCurrLayer != -1) { - curLayer = -1; - for (int i = newCurrLayer; i< NUM_LAYERS; i++) { - if (!layers[i].frozen) { - curLayer = i; - break; - } - } - if (curLayer == -1) { - ErrorMessage( MSG_NO_EMPTY_LAYER ); - layers[0].frozen = FALSE; - curLayer = 0; - } - } -} - -/** - * Save the customized layer information to preferences. - */ - -static void -LayerPrefSave(void) -{ - unsigned int inx; - int flags; - char buffer[ 80 ]; - char links[STR_LONG_SIZE]; - char layersSaved[ 3 * NUM_LAYERS + 1 ]; /* 0..99 plus separator */ - /* FIXME: values for layers that are configured to default now should be overwritten in the settings */ - layersSaved[ 0 ] = '\0'; - - for (inx = 0; inx < NUM_LAYERS; inx++) { - /* if a name is set that is not the default value or a color different from the default has been set, - information about the layer needs to be saved */ - if ((layers[inx].name[0]) || - layers[inx].frozen || (!layers[inx].onMap) || (!layers[inx].visible) || - layers[inx].button_off || (layers[inx].layerLinkList.cnt>0) || - layers[inx].module || - layers[inx].color != layerColorTab[inx%COUNT(layerColorTab)]) { - sprintf(buffer, LAYERPREF_NAME ".%0u", inx); - wPrefSetString(LAYERPREF_SECTION, buffer, layers[inx].name); - sprintf(buffer, LAYERPREF_COLOR ".%0u", inx); - wPrefSetInteger(LAYERPREF_SECTION, buffer, wDrawGetRGB(layers[inx].color)); - flags = 0; - - if (layers[inx].frozen) { - flags |= LAYERPREF_FROZEN; - } - - if (layers[inx].onMap) { - flags |= LAYERPREF_ONMAP; - } - - if (layers[inx].visible) { - flags |= LAYERPREF_VISIBLE; - } - - if (layers[inx].module) { - flags |= LAYERPREF_MODULE; - } - - if (layers[inx].button_off) { - flags |= LAYERPREF_NOBUTTON; - } - - sprintf(buffer, LAYERPREF_FLAGS ".%0u", inx); - wPrefSetInteger(LAYERPREF_SECTION, buffer, flags); - - if (layers[inx].layerLinkList.cnt>0) { - sprintf(buffer, LAYERPREF_LIST ".%0u", inx); - GetLayerLinkString(inx,links); - wPrefSetString(LAYERPREF_SECTION, buffer, links); - - if (settingsName[0] && strcmp(settingsName," ")!=0) { - sprintf(buffer, LAYERPREF_SETTINGS ".%0u", inx); - wPrefSetString(LAYERPREF_SECTION, buffer, layers[inx].settingsName); - } - } - - /* extend the list of layers that are set up via the preferences */ - if (layersSaved[ 0 ]) { - strcat(layersSaved, ","); - } - - sprintf(buffer, "%u", inx); - strcat(layersSaved, buffer); - } - } - - wPrefSetString(LAYERPREF_SECTION, "layers", layersSaved); -} - - -/** - * Load the settings for all layers from the preferences. - */ - -static void -LayerPrefLoad(void) -{ - const char *prefString; - long rgb; - long flags; - /* reset layer preferences to system default */ - LayerSystemDefaults(); - prefString = wPrefGetString(LAYERPREF_SECTION, "layers"); - - if (prefString && prefString[ 0 ]) { - char layersSaved[3 * NUM_LAYERS]; - strncpy(layersSaved, prefString, sizeof(layersSaved)); - prefString = strtok(layersSaved, ","); - - while (prefString) { - int inx; - char layerOption[20]; - const char *layerValue; - char listValue[STR_LONG_SIZE]; - int color; - inx = atoi(prefString); - sprintf(layerOption, LAYERPREF_NAME ".%d", inx); - layerValue = wPrefGetString(LAYERPREF_SECTION, layerOption); - - if (layerValue) { - strcpy(layers[inx].name, layerValue); - } else { - *(layers[inx].name) = '\0'; - } - - /* get and set the color, using the system default color in case color is not available from prefs */ - sprintf(layerOption, LAYERPREF_COLOR ".%d", inx); - wPrefGetInteger(LAYERPREF_SECTION, layerOption, &rgb, - layerColorTab[inx%COUNT(layerColorTab)]); - color = wDrawFindColor(rgb); - SetLayerColor(inx, color); - /* get and set the flags */ - sprintf(layerOption, LAYERPREF_FLAGS ".%d", inx); - wPrefGetInteger(LAYERPREF_SECTION, layerOption, &flags, - LAYERPREF_ONMAP | LAYERPREF_VISIBLE); - layers[inx].frozen = ((flags & LAYERPREF_FROZEN) != 0); - layers[inx].onMap = ((flags & LAYERPREF_ONMAP) != 0); - layers[inx].visible = ((flags & LAYERPREF_VISIBLE) != 0); - layers[inx].module = ((flags & LAYERPREF_MODULE) !=0); - layers[inx].button_off = ((flags & LAYERPREF_NOBUTTON) !=0); - - sprintf(layerOption, LAYERPREF_LIST ".%d", inx); - layerValue = wPrefGetString(LAYERPREF_SECTION,layerOption); - if (layerValue) { - strcpy(listValue,layerValue); - PutLayerListArray(inx,listValue); - } else { - listValue[0] = '\0'; - PutLayerListArray(inx,listValue); - } - sprintf(layerOption, LAYERPREF_SETTINGS ".%d", inx); - layerValue = wPrefGetString(LAYERPREF_SECTION,layerOption); - if (layerValue) { - strcpy(layers[inx].settingsName,layerValue); - } else { - layers[inx].settingsName[0] = '\0'; - } - - prefString = strtok(NULL, ","); - } - } - //Make sure curLayer not frozen - for (int i=curLayer; i<NUM_LAYERS; i++) { - if (!layers[i].frozen) { - curLayer = i; - break; - } - } - if (layers[curLayer].frozen) { - ErrorMessage( MSG_NO_EMPTY_LAYER ); - layers[0].frozen = FALSE; - curLayer = 0; - } -} - -/** - * Increment the count of objects on a given layer. - * - * \param index IN the layer to change - */ - -void IncrementLayerObjects(unsigned int layer) -{ - assert(layer <= NUM_LAYERS); - layers[layer].objCount++; -} - -/** -* Decrement the count of objects on a given layer. -* -* \param index IN the layer to change -*/ - -void DecrementLayerObjects(unsigned int layer) -{ - assert(layer <= NUM_LAYERS); - layers[layer].objCount--; -} - -/** - * Count the number of objects on each layer and store result in layers data structure. - */ - -void LayerSetCounts(void) -{ - int inx; - track_p trk; - - for (inx=0; inx<NUM_LAYERS; inx++) { - layers[inx].objCount = 0; - } - - for (trk=NULL; TrackIterate(&trk);) { - inx = GetTrkLayer(trk); - - if (inx >= 0 && inx < NUM_LAYERS) { - layers[inx].objCount++; - } - } -} - -int FindUnusedLayer(unsigned int start) { - int inx; - for (inx=start; inx<NUM_LAYERS; inx++) { - if (layers[inx].objCount == 0 && !layers[inx].frozen) return inx; - } - ErrorMessage( MSG_NO_EMPTY_LAYER ); - return -1; -} - -/** - * Reset layer options to their default values. The default values are loaded - * from the preferences file. - */ - -void -DefaultLayerProperties(void) -{ - InitializeLayers(LayerPrefLoad, 0); - UpdateLayerDlg(curLayer); //Use Current Layer - - if (layoutLayerChanged) { - MainProc(mainW, wResize_e, NULL, NULL); - layoutLayerChanged = FALSE; - } -} - -/** - * Update all UI elements after selecting a layer. - * - */ - -static void LayerUpdate(void) -{ - BOOL_T redraw; - char *layerFormattedName; - ParamLoadData(&layerPG); - - if (!IsLayerValid(layerCurrent)) { - return; - } - - if (layerCurrent == curLayer && layerFrozen) { - NoticeMessage(MSG_LAYER_FREEZE, _("Ok"), NULL); - layerFrozen = FALSE; - ParamLoadControl(&layerPG, I_FRZ); - } - - if (layerCurrent == curLayer && !layerVisible) { - NoticeMessage(MSG_LAYER_HIDE, _("Ok"), NULL); - layerVisible = TRUE; - ParamLoadControl(&layerPG, I_VIS); - } - - if (layerCurrent == curLayer && layerModule) { - NoticeMessage(MSG_LAYER_MODULE, _("Ok"), NULL); - layerModule = FALSE; - ParamLoadControl(&layerPG, I_MOD); - } - char oldLinkList[STR_LONG_SIZE]; - GetLayerLinkString((int)layerCurrent,oldLinkList); - - if (strcmp(layers[(int)layerCurrent].name, layerName) || - layerColor != layers[(int)layerCurrent].color || - layers[(int)layerCurrent].useColor != (BOOL_T)layerUseColor || - layers[(int)layerCurrent].visible != (BOOL_T)layerVisible || - layers[(int)layerCurrent].frozen != (BOOL_T)layerFrozen || - layers[(int)layerCurrent].onMap != (BOOL_T)layerOnMap || - layers[(int)layerCurrent].module != (BOOL_T)layerModule || - layers[(int)layerCurrent].button_off != (BOOL_T)layerNoButton || - strcmp(layers[(int)layerCurrent].settingsName,settingsName) || - strcmp(oldLinkList,layerLinkList)) { - SetFileChanged(); - } - - if (layerL) { - strncpy(layers[(int)layerCurrent].name, layerName, - sizeof layers[(int)layerCurrent].name); - layerFormattedName = FormatLayerName(layerCurrent); - wListSetValues(layerL, layerCurrent, layerFormattedName, NULL, NULL); - free(layerFormattedName); - } - - - layerFormattedName = FormatLayerName(layerCurrent); - wListSetValues(setLayerL, layerCurrent, layerFormattedName, NULL, NULL); - free(layerFormattedName); - - if (layerCurrent < NUM_BUTTONS && !layers[(int)layerCurrent].button_off) { - if (strlen(layers[(int)layerCurrent].name)>0) { - wControlSetBalloonText((wControl_p)layer_btns[(int)layerCurrent], - layers[(int)layerCurrent].name); - } else { - wControlSetBalloonText((wControl_p)layer_btns[(int)layerCurrent], - _("Show/Hide Layer")); - } - } - - redraw = (layerColor != layers[(int)layerCurrent].color || - layers[(int)layerCurrent].useColor != (BOOL_T)layerUseColor || - (BOOL_T)layerVisible != layers[(int)layerCurrent].visible); - - if ((!layerRedrawMap) && redraw) { - RedrawLayer((unsigned int)layerCurrent, FALSE); - } - - SetLayerColor(layerCurrent, layerColor); - - if (layerCurrent<NUM_BUTTONS && - layers[(int)layerCurrent].visible!=(BOOL_T)layerVisible && !layers[(int)layerCurrent].button_off) { - wButtonSetBusy(layer_btns[(int)layerCurrent], layerVisible); - } - - layers[(int)layerCurrent].useColor = (BOOL_T)layerUseColor; - if (layers[(int)layerCurrent].visible != (BOOL_T)layerVisible) - FlipLayer(I2VP(layerCurrent)); - layers[(int)layerCurrent].visible = (BOOL_T)layerVisible; - layers[(int)layerCurrent].frozen = (BOOL_T)layerFrozen; - if (layers[(int)layerCurrent].frozen) DeselectLayer(layerCurrent); - layers[(int)layerCurrent].onMap = (BOOL_T)layerOnMap; - layers[(int)layerCurrent].module = (BOOL_T)layerModule; - strcpy(layers[(int)layerCurrent].settingsName,settingsName); - - PutLayerListArray((int)layerCurrent,layerLinkList); - - SetLayerHideButton(layerCurrent,layerNoButton); - - MainProc( mainW, wResize_e, NULL, NULL ); - - if (layerRedrawMap) { - DoRedraw(); - } else if (redraw) { - RedrawLayer((unsigned int)layerCurrent, TRUE); - } - - layerRedrawMap = FALSE; -} - - -static void LayerSelect( - wIndex_t inx) -{ - LayerUpdate(); - - if (inx < 0 || inx >= NUM_LAYERS) { - return; - } - - layerCurrent = (unsigned int)inx; - strcpy(layerName, layers[inx].name); - strcpy(settingsName, layers[inx].settingsName); - layerVisible = layers[inx].visible; - layerFrozen = layers[inx].frozen; - layerOnMap = layers[inx].onMap; - layerModule = layers[inx].module; - layerColor = layers[inx].color; - layerUseColor = layers[inx].useColor; - layerNoButton = layers[inx].button_off; - sprintf(message, "%ld", layers[inx].objCount); - GetLayerLinkString(inx,layerLinkList); - ParamLoadMessage(&layerPG, I_COUNT, message); - ParamLoadControls(&layerPG); - - if (layerS) { - if (!LoadFileListLoad(settingsCatalog,settingsName)) { - settingsName[0] = '\0'; - layers[inx].settingsName[0] = '\0'; - } - - } -} - -void ResetLayers(void) -{ - int inx; - - for (inx=0; inx<NUM_LAYERS; inx++) { - strcpy(layers[inx].name, inx==0?_("Main"):""); - layers[inx].visible = TRUE; - layers[inx].frozen = FALSE; - layers[inx].onMap = TRUE; - layers[inx].module = FALSE; - layers[inx].button_off = FALSE; - layers[inx].objCount = 0; - strcpy(layers[inx].settingsName,""); - DYNARR_RESET(int,layers[inx].layerLinkList); - SetLayerColor(inx, layerColorTab[inx%COUNT(layerColorTab)]); - - - if (inx<NUM_BUTTONS) { - wButtonSetLabel(layer_btns[inx], (char*)show_layer_bmps[inx]); - } - } - - wControlSetBalloonText((wControl_p)layer_btns[0], _("Main")); - - for (inx=1; inx<NUM_BUTTONS; inx++) { - wControlSetBalloonText((wControl_p)layer_btns[inx], _("Show/Hide Layer")); - } - - curLayer = -1; - - for (int i=0;i<NUM_LAYERS;i++) { - if (!layers[i].frozen) { - curLayer = i; - break; - } - } - - if (curLayer == -1) { - ErrorMessage( MSG_NO_EMPTY_LAYER ); - layers[0].frozen = FALSE; - curLayer = 0; - } - - layerVisible = TRUE; - layerFrozen = FALSE; - layerOnMap = TRUE; - layerModule = FALSE; - layerColor = layers[0].color; - layerUseColor = TRUE; - strcpy(layerName, layers[0].name); - strcpy(settingsName, layers[0].settingsName); - - LoadLayerLists(); - - if (layerL) { - ParamLoadControls(&layerPG); - ParamLoadMessage(&layerPG, I_COUNT, "0"); - } -} - - -void SaveLayers(void) -{ - layers_save = malloc(NUM_LAYERS * sizeof(layers[0])); - - if (layers_save == NULL) { - abort(); - } - - for (int i=0;i<NUM_LAYERS;i++) { - layers[i].settingsName[0] = '\0'; - } - - memcpy(layers_save, layers, NUM_LAYERS * sizeof layers[0]); - ResetLayers(); -} - -void RestoreLayers(void) -{ - int inx; - char * label; - wDrawColor color; - assert(layers_save != NULL); - memcpy(layers, layers_save, NUM_LAYERS * sizeof layers[0]); - free(layers_save); - - for (inx=0; inx<NUM_BUTTONS; inx++) { - color = layers[inx].color; - layers[inx].color = -1; - SetLayerColor(inx, color); - - if (layers[inx].name[0] == '\0') { - if (inx == 0) { - label = _("Main"); - } else { - label = _("Show/Hide Layer"); - } - } else { - label = layers[inx].name; - } - - wControlSetBalloonText((wControl_p)layer_btns[inx], label); - } - - if (layerL) { - ParamLoadControls(&layerPG); - ParamLoadMessage(&layerPG, I_COUNT, "0"); - } - - LoadLayerLists(); -} - -/** - * This function is called when the Done button on the layer dialog is pressed. It hides the layer dialog and - * updates the layer information. - * - * \param IN ignored - * - */ - -static void LayerOk(void * unused) -{ - LayerSelect(layerCurrent); - - if (newLayerCount != layerCount) { - layoutLayerChanged = TRUE; - - if (newLayerCount > NUM_BUTTONS) { - newLayerCount = NUM_BUTTONS; - } - - layerCount = newLayerCount; - } - - if (layoutLayerChanged) { - MainProc(mainW, wResize_e, NULL, NULL); - } - - wHide(layerW); -} - - -static void LayerDlgUpdate( - paramGroup_p pg, - int inx, - void * valueP) -{ - switch (inx) { - case I_LIST: - LayerSelect((wIndex_t)*(long*)valueP); - break; - - case I_NAME: - LayerUpdate(); - break; - - case I_MAP: - layerRedrawMap = TRUE; - /* No Break */ - case I_VIS: - case I_FRZ: - case I_MOD: - case I_BUT: - LayerUpdate(); - UpdateLayerDlg(layerCurrent); - break; - - case I_SETTINGS: - if (strcmp((char*)wListGetItemContext(settingsListL,(wIndex_t)*(long*)valueP)," ")==0) - settingsName[0] = '\0'; - else - strcpy(settingsName,(char*)wListGetItemContext(settingsListL,(wIndex_t)*(long*)valueP)); - break; - } - - - -} - -/** - * Scan opened directory for the next settings file - * - * \param dir IN opened directory handle - * \param dirName IN name of directory - * \param fileName OUT fully qualified filename - * - * \return TRUE if file found, FALSE if not - */ - -static bool -GetNextSettingsFile(DIR *dir, const char *dirName, char **fileName) -{ - bool done = false; - bool res = false; - - /* - * get all files from the directory - */ - while (!done) { - struct stat fileState; - struct dirent *ent; - - ent = readdir(dir); - - if (ent) { - if (!XtcStricmp(FindFileExtension(ent->d_name), "xset")) { - /* create full file name and get the state for that file */ - MakeFullpath(fileName, dirName, ent->d_name, NULL); - - if (stat(*fileName, &fileState) == -1) { - fprintf(stderr, "Error getting file state for %s\n", *fileName); - continue; - } - - /* ignore any directories */ - if (!(fileState.st_mode & S_IFDIR)) { - done = true; - res = true; - } - } - } else { - done = true; - res = false; - } - } - return (res); -} - - -/* - * Get all the settings files in the working directory - */ - -static CatalogEntry * -ScanSettingsDirectory(Catalog *catalog, const char *dirName) -{ - DIR *d; - CatalogEntry *newEntry = catalog->head; - char contents[STR_SHORT_SIZE]; - - d = opendir(dirName); - if (d) { - char *fileName = NULL; - - while (GetNextSettingsFile(d, dirName, &fileName)) { - char *contents_start = strrchr(fileName,PATH_SEPARATOR[0]); - if (contents_start[0] == '/') contents_start++; - char *contents_end = strchr(contents_start,'.'); - if (contents_end[0] == '.') contents_end[0] = '\0'; - strcpy(contents,contents_start); - contents_end[0] = '.'; - newEntry = InsertInOrder(catalog,contents, NULL); - UpdateCatalogEntry(newEntry, fileName, contents, NULL); - free(fileName); - fileName = NULL; - } - closedir(d); - } - - return (newEntry); -} - -static void DoLayer(void * unused) -{ - if (layerW == NULL) { - layerW = ParamCreateDialog(&layerPG, MakeWindowTitle(_("Layers")), _("Done"), - LayerOk, wHide, TRUE, NULL, 0, LayerDlgUpdate); - } - - if (settingsCatalog) CatalogDiscard(settingsCatalog); - else settingsCatalog = InitCatalog(); - ScanSettingsDirectory(settingsCatalog, wGetAppWorkDir()); - - - /* set the globals to the values for the current layer */ - UpdateLayerDlg(curLayer); - layerRedrawMap = FALSE; - wShow(layerW); - layoutLayerChanged = FALSE; -} - - - -BOOL_T ReadLayers(char * line) -{ - char * name, *layerLinkList, *layerSettingsName; - int inx, visible, frozen, color, onMap, module, dontUseColor, ColorFlags, button_off; - unsigned long rgb; - - /* older files didn't support layers */ - - if (paramVersion < 7) { - return TRUE; - } - - /* set the current layer */ - - if (strncmp(line, "CURRENT", 7) == 0) { - curLayer = atoi(line+7); - - if (!IsLayerValid(curLayer)) { - - curLayer = 0; - } - - if (layers[curLayer].frozen) { - ErrorMessage( MSG_NOT_UNFROZEN_LAYER ); - layers[curLayer].frozen = FALSE; - } - - if (layerL) { - wListSetIndex(layerL, curLayer); - } - - if (setLayerL) { - wListSetIndex(setLayerL, curLayer); - } - - return TRUE; - } - - if (strncmp(line, "LINK", 4) == 0) { - if (!GetArgs(line+4, "dq" , &inx, &layerLinkList)) { - return FALSE; - } - PutLayerListArray(inx,layerLinkList); - return TRUE; - } - - if (strncmp(line, "SET", 3) == 0) { - if (!GetArgs(line+3, "dq", &inx, &layerSettingsName)) { - return FALSE; - } - strcpy(layers[inx].settingsName,layerSettingsName); - return TRUE; - } - - /* get the properties for a layer from the file and update the layer accordingly */ - - if (!GetArgs(line, "dddduddddq", &inx, &visible, &frozen, &onMap, &rgb, &module, &dontUseColor, &ColorFlags, &button_off, - &name)) { - - return FALSE; - } - - - if (paramVersion < 9) { - if ((int)rgb < COUNT( oldColorMap ) ) { - rgb = wRGB(oldColorMap[(int)rgb][0], oldColorMap[(int)rgb][1], - oldColorMap[(int)rgb][2]); - } else { - rgb = 0; - } - } - - if (inx < 0 || inx >= NUM_LAYERS) { - return FALSE; - } - - color = wDrawFindColor(rgb); - SetLayerColor(inx, color); - strncpy(layers[inx].name, name, sizeof layers[inx].name); - layers[inx].visible = visible; - layers[inx].frozen = frozen; - layers[inx].onMap = onMap; - layers[inx].module = module; - layers[inx].color = color; - layers[inx].useColor = !dontUseColor; - layers[inx].button_off = button_off; - - colorTrack = ColorFlags&1; //Make sure globals are set - colorDraw = ColorFlags&2; - - if (inx<NUM_BUTTONS && !layers[inx].button_off) { - if (strlen(name) > 0) { - wControlSetBalloonText((wControl_p)layer_btns[(int)inx], layers[inx].name); - } - wButtonSetBusy(layer_btns[(int)inx], visible); - } - MyFree(name); - - return TRUE; -} - -/** - * Find out whether layer information should be saved to the layout file. - * Usually only layers where settings are off from the default are written. - * NOTE: as a fix for a problem with XTrkCadReader a layer definition is - * written for each layer that is used. - * - * \param layerNumber IN index of the layer - * \return TRUE if configured, FALSE if not - */ - -BOOL_T -IsLayerConfigured(unsigned int layerNumber) -{ - return (!layers[layerNumber].visible || - layers[layerNumber].frozen || - !layers[layerNumber].onMap || - layers[layerNumber].module || - layers[layerNumber].button_off || - layers[layerNumber].color != - layerColorTab[layerNumber % (COUNT(layerColorTab))] || - layers[layerNumber].name[0] || - layers[layerNumber].layerLinkList.cnt > 0 || - layers[layerNumber].objCount); -} - - -/** - * Save the layer information to the file. - * - * \paran f IN open file handle - * \return always TRUE - */ - -BOOL_T WriteLayers(FILE * f) -{ - unsigned int inx; - - int ColorFlags = 0; - - if (colorTrack) ColorFlags |= 1; - if (colorDraw) ColorFlags |= 2; - - for (inx = 0; inx < NUM_LAYERS; inx++) { - if (IsLayerConfigured(inx)) { - fprintf(f, "LAYERS %u %d %d %d %ld %d %d %d %d \"%s\"\n", - inx, - layers[inx].visible, - layers[inx].frozen, - layers[inx].onMap, - wDrawGetRGB(layers[inx].color), - layers[inx].module, - layers[inx].useColor?0:1, - ColorFlags, layers[inx].button_off, - PutTitle(layers[inx].name)); - } - } - - fprintf(f, "LAYERS CURRENT %u\n", curLayer); - - for (inx = 0; inx < NUM_LAYERS; inx++) { - GetLayerLinkString(inx,layerLinkList); - if (IsLayerConfigured(inx) && strlen(layerLinkList)>0) - fprintf(f, "LAYERS LINK %u \"%s\"\n",inx,layerLinkList); - if (IsLayerConfigured(inx) && layers[inx].settingsName[0]) - fprintf(f, "LAYERS SET %u \"%s\"\n",inx, layers[inx].settingsName); - } - return TRUE; -} - -#include "bitmaps/background.xpm" - -void InitLayers(void) -{ - unsigned int i; - wPrefGetInteger(PREFSECT, "layer-button-count", &layerCount, layerCount); - - for (i = 0; i<COUNT(layerRawColorTab); i++) { - layerColorTab[i] = wDrawFindColor(layerRawColorTab[i]); - } - - /* create the bitmaps for the layer buttons */ - /* all bitmaps have to have the same dimensions */ - for (int i = 0;i<NUM_LAYERS; i++) { - // char *bits = (show_layer_bits[i] + iconSize * sizeof(char*))); - show_layer_bmps[i] = wIconCreateBitMap(lbits_width[iconSize], lbits_height[iconSize], - show_layer_bits[iconSize][i], - layerColorTab[i%(COUNT(layerColorTab))]); - layers[i].color = layerColorTab[i%(COUNT(layerColorTab))]; - layers[i].useColor = TRUE; - } - - /* layer list for toolbar */ - setLayerL = wDropListCreate(mainW, 0, 0, "cmdLayerSet", NULL, 0, 10, 200, NULL, - SetCurrLayer, NULL); - wControlSetBalloonText((wControl_p)setLayerL, GetBalloonHelpStr("cmdLayerSet")); - AddToolbarControl((wControl_p)setLayerL, IC_MODETRAIN_TOO); - - backgroundB = AddToolbarButton("cmdBackgroundShow", wIconCreatePixMap(background_xpm[iconSize]), 0, - BackgroundToggleShow, NULL); - /* add the help text */ - wControlSetBalloonText((wControl_p)backgroundB, _("Show/Hide Background")); - wControlActive((wControl_p)backgroundB, FALSE); - - for (int i = 0; i<NUM_LAYERS; i++) { - char *layerName; - - if (i<NUM_BUTTONS) { - /* create the layer button */ - sprintf(message, "cmdLayerShow%u", i); - layer_btns[i] = wButtonCreate(mainW, 0, 0, message, - (char*)(show_layer_bmps[i]), - BO_ICON, 0, FlipLayer, I2VP(i) ); - /* add the help text */ - wControlSetBalloonText((wControl_p)layer_btns[i], _("Show/Hide Layer")); - /* put on toolbar */ - AddToolbarControl((wControl_p)layer_btns[i], IC_MODETRAIN_TOO); - /* set state of button */ - wButtonSetBusy(layer_btns[i], 1); - } - - layerName = FormatLayerName(i); - wListAddValue(setLayerL, layerName, NULL, I2VP(i)); - free(layerName); - } - - AddPlaybackProc("SETCURRLAYER", PlaybackCurrLayer, NULL); - AddPlaybackProc("LAYERS", (playbackProc_p)ReadLayers, NULL); -} - -addButtonCallBack_t InitLayersDialog(void) -{ - ParamRegister(&layerPG); - return &DoLayer; -} +/** \file dlayer.c
+ * Functions and dialogs for handling layers.
+ */
+
+/* XTrkCad - Model Railroad CAD
+ * Copyright (C) 2005 Dave Bullis and (C) 2007 Martin Fischer
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "common.h"
+#include "cselect.h"
+#include "custom.h"
+#include "paths.h"
+#include "dynstring.h"
+#include "fileio.h"
+#include "layout.h"
+#include "param.h"
+#include "track.h"
+#include "include/partcatalog.h"
+#include "include/stringxtc.h"
+#include "common-ui.h"
+
+/*****************************************************************************
+ *
+ * LAYERS
+ *
+ */
+
+#define NUM_BUTTONS (99)
+#define LAYERPREF_FROZEN (1)
+#define LAYERPREF_ONMAP (2)
+#define LAYERPREF_VISIBLE (4)
+#define LAYERPREF_MODULE (8)
+#define LAYERPREF_NOBUTTON (16)
+#define LAYERPREF_DEFAULT (32)
+#define LAYERPREF_SECTION ("Layers")
+#define LAYERPREF_NAME "name"
+#define LAYERPREF_COLOR "color"
+#define LAYERPREF_FLAGS "flags"
+#define LAYERPREF_SCALEINX "scaleInx"
+#define LAYERPREF_SCLDESCINX "sclDescInx"
+#define LAYERPREF_GAUGEINX "gaugeInx"
+#define LAYERPREF_MINRADIUS "minRadius"
+#define LAYERPREF_MAXGRADE "maxGrade"
+#define LAYERPREF_TIELENGTH "tieLength"
+#define LAYERPREF_TIEWIDTH "tieWidth"
+#define LAYERPREF_TIESPACING "tieSpacing"
+#define LAYERPREF_LIST "list"
+#define LAYERPREF_SETTINGS "settings"
+
+static paramIntegerRange_t r_nocheck = { 0, 1, 100, PDO_NORANGECHECK_LOW | PDO_NORANGECHECK_HIGH };
+static paramFloatRange_t r_tieData = { 0.05, 100.0, 100, PDO_NORANGECHECK_LOW | PDO_NORANGECHECK_HIGH };
+
+static paramFloatRange_t r0_10000 = { 0.0, 10000.0 };
+static paramFloatRange_t r0_90 = { 0.0, 90.0 };
+
+EXPORT unsigned int maxLayer;
+
+unsigned int curLayer;
+long layerCount = 10;
+static long newLayerCount = 10;
+static unsigned int layerSelected = 0;
+
+
+static BOOL_T layoutLayerChanged = FALSE;
+
+static wIcon_p show_layer_bmps[NUM_BUTTONS];
+static wButton_p layer_btns[NUM_BUTTONS]; /**< layer buttons on toolbar */
+
+/** Layer selector on toolbar */
+static wList_p setLayerL;
+
+/** Describe the properties of a layer
+ * Defaults for layout track grade and min radius are in scale.c: SetScale
+ */
+typedef struct {
+ char name[STR_SHORT_SIZE]; /**< Layer name */
+ wDrawColor color; /**< layer color, is an index into a color table */
+ BOOL_T useColor; /**< Use Layer color */
+ BOOL_T frozen; /**< Frozen flag */
+ BOOL_T visible; /**< visible flag */
+ BOOL_T onMap; /**< is layer shown map */
+ BOOL_T module; /**< is layer a module (all or nothing) */
+ BOOL_T button_off; /**< hide button */
+ BOOL_T inherit; /**< inherit layout defaults */
+ SCALEINX_T scaleInx; /**< scale override */
+ SCALEDESCINX_T scaleDescInx; /**< the scale description */
+ GAUGEINX_T gaugeInx; /**< the gauge desc index */
+ DIST_T minTrackRadius; /**< minimum track radius */
+ ANGLE_T maxTrackGrade; /**< maximum track grade */
+ tieData_t tieData; /**< tie data structure */
+ long objCount; /**< number of objects on layer */
+ dynArr_t layerLinkList; /**< other layers that show/hide with this one, 1-based index */
+ char settingsName[STR_SHORT_SIZE]; /**< name of settings file to load when this is current */
+} layer_t;
+
+static layer_t layers[NUM_LAYERS];
+static layer_t *layers_save = NULL;
+
+static Catalog * settingsCatalog;
+
+
+static int oldColorMap[][3] = {
+ { 255, 255, 255 }, /* White */
+ { 0, 0, 0 }, /* Black */
+ { 255, 0, 0 }, /* Red */
+ { 0, 255, 0 }, /* Green */
+ { 0, 0, 255 }, /* Blue */
+ { 255, 255, 0 }, /* Yellow */
+ { 255, 0, 255 }, /* Purple */
+ { 0, 255, 255 }, /* Aqua */
+ { 128, 0, 0 }, /* Dk. Red */
+ { 0, 128, 0 }, /* Dk. Green */
+ { 0, 0, 128 }, /* Dk. Blue */
+ { 128, 128, 0 }, /* Dk. Yellow */
+ { 128, 0, 128 }, /* Dk. Purple */
+ { 0, 128, 128 }, /* Dk. Aqua */
+ { 65, 105, 225 }, /* Royal Blue */
+ { 0, 191, 255 }, /* DeepSkyBlue */
+ { 125, 206, 250 }, /* LightSkyBlue */
+ { 70, 130, 180 }, /* Steel Blue */
+ { 176, 224, 230 }, /* Powder Blue */
+ { 127, 255, 212 }, /* Aquamarine */
+ { 46, 139, 87 }, /* SeaGreen */
+ { 152, 251, 152 }, /* PaleGreen */
+ { 124, 252, 0 }, /* LawnGreen */
+ { 50, 205, 50 }, /* LimeGreen */
+ { 34, 139, 34 }, /* ForestGreen */
+ { 255, 215, 0 }, /* Gold */
+ { 188, 143, 143 }, /* RosyBrown */
+ { 139, 69, 19 }, /* SaddleBrown */
+ { 245, 245, 220 }, /* Beige */
+ { 210, 180, 140 }, /* Tan */
+ { 210, 105, 30 }, /* Chocolate */
+ { 165, 42, 42 }, /* Brown */
+ { 255, 165, 0 }, /* Orange */
+ { 255, 127, 80 }, /* Coral */
+ { 255, 99, 71 }, /* Tomato */
+ { 255, 105, 180 }, /* HotPink */
+ { 255, 192, 203 }, /* Pink */
+ { 176, 48, 96 }, /* Maroon */
+ { 238, 130, 238 }, /* Violet */
+ { 160, 32, 240 }, /* Purple */
+ { 16, 16, 16 }, /* Gray */
+ { 32, 32, 32 }, /* Gray */
+ { 48, 48, 48 }, /* Gray */
+ { 64, 64, 64 }, /* Gray */
+ { 80, 80, 80 }, /* Gray */
+ { 96, 96, 96 }, /* Gray */
+ { 112, 112, 122 }, /* Gray */
+ { 128, 128, 128 }, /* Gray */
+ { 144, 144, 144 }, /* Gray */
+ { 160, 160, 160 }, /* Gray */
+ { 176, 176, 176 }, /* Gray */
+ { 192, 192, 192 }, /* Gray */
+ { 208, 208, 208 }, /* Gray */
+ { 224, 224, 224 }, /* Gray */
+ { 240, 240, 240 }, /* Gray */
+ { 0, 0, 0 } /* BlackPixel */
+};
+
+static void DoLayerOp(void * data);
+void UpdateLayerDlg(unsigned int);
+
+static void InitializeLayers(void LayerInitFunc(void), int newCurrLayer);
+static void LayerPrefSave(void);
+static void LayerPrefLoad(void);
+
+int IsLayerValid(unsigned int layer)
+{
+ return (layer <= NUM_LAYERS && layer != -1);
+}
+
+BOOL_T GetLayerVisible(unsigned int layer)
+{
+ if (!IsLayerValid(layer)) {
+ return TRUE;
+ } else {
+ return layers[layer].visible;
+ }
+}
+
+BOOL_T GetLayerHidden(unsigned int layer)
+{
+ if (!IsLayerValid(layer)) {
+ return TRUE;
+ } else {
+ return layers[layer].button_off;
+ }
+}
+
+
+BOOL_T GetLayerFrozen(unsigned int layer)
+{
+ if (!IsLayerValid(layer)) {
+ return TRUE;
+ } else {
+ return layers[layer].frozen;
+ }
+}
+
+BOOL_T GetLayerOnMap(unsigned int layer)
+{
+ if (!IsLayerValid(layer)) {
+ return TRUE;
+ } else {
+ return layers[layer].onMap;
+ }
+}
+
+EXPORT BOOL_T GetLayerUseDefault(unsigned int layer)
+{
+ if (!IsLayerValid(layer)) {
+ return TRUE;
+ } else {
+ return layers[layer].inherit;
+ }
+}
+
+
+EXPORT SCALEINX_T GetLayerScale( unsigned int layer )
+{
+ if ( IsLayerValid(layer) && !GetLayerUseDefault(layer) ) {
+ return layers[layer].scaleInx;
+ }
+ return GetLayoutCurScale(); // layout scale
+}
+
+EXPORT DIST_T GetLayerMinTrackRadius( unsigned int layer )
+{
+ if ( IsLayerValid(layer) && !GetLayerUseDefault(layer) ) {
+ return layers[layer].minTrackRadius;
+ }
+ return GetLayoutMinTrackRadius();
+}
+
+EXPORT ANGLE_T GetLayerMaxTrackGrade( unsigned int layer )
+{
+ if ( IsLayerValid(layer) && !GetLayerUseDefault(layer) ) {
+ return layers[layer].maxTrackGrade;
+ }
+ return GetLayoutMaxTrackGrade();
+}
+
+EXPORT tieData_t GetLayerTieData( unsigned int layer )
+{
+ if ( IsLayerValid(layer) && !GetLayerUseDefault(layer)
+ && layers[layer].tieData.valid ) {
+ return layers[layer].tieData;
+ }
+ return GetScaleTieData(GetLayoutCurScale()); // layout scale default tie data
+}
+
+BOOL_T GetLayerModule(unsigned int layer)
+{
+ if (!IsLayerValid(layer)) {
+ return TRUE;
+ } else {
+ return layers[layer].module;
+ }
+}
+
+void SetLayerModule(unsigned int layer, BOOL_T module)
+{
+ if (IsLayerValid(layer)) {
+ layers[layer].module = module;
+ }
+}
+
+void SetLayerDefault(unsigned int layer, BOOL_T inherit)
+{
+ if (IsLayerValid(layer)) {
+ layers[layer].inherit = inherit;
+ }
+}
+
+
+char * GetLayerName(unsigned int layer)
+{
+ if (!IsLayerValid(layer)) {
+ return NULL;
+ } else {
+ return layers[layer].name;
+ }
+}
+
+void SetLayerName(unsigned int layer, char* name)
+{
+ if (IsLayerValid(layer)) {
+ strcpy(layers[layer].name, name);
+ }
+}
+
+BOOL_T GetLayerUseColor(unsigned int layer)
+{
+ return layers[layer].useColor;
+}
+
+wDrawColor GetLayerColor(unsigned int layer)
+{
+ return layers[layer].color;
+}
+
+static void RedrawLayer( unsigned int l, BOOL_T draw )
+{
+ DoRedraw();
+}
+
+
+EXPORT void FlipLayer( void * layerVP )
+{
+ unsigned int layer = (unsigned int)VP2L(layerVP);
+ wBool_t visible;
+
+ if (!IsLayerValid(layer)) {
+ return;
+ }
+
+ if (layer == curLayer && layers[layer].visible) {
+ if (!layers[layer].button_off) {
+ wButtonSetBusy(layer_btns[layer], layers[layer].visible);
+ }
+ NoticeMessage(MSG_LAYER_HIDE, _("Ok"), NULL);
+ return;
+ }
+
+ RedrawLayer(layer, FALSE);
+ visible = !layers[layer].visible;
+ layers[layer].visible = visible;
+
+ if (layer < NUM_BUTTONS) {
+ if (!layers[layer].button_off) {
+ wButtonSetBusy(layer_btns[layer], visible != 0);
+ wButtonSetLabel(layer_btns[layer], (char *)show_layer_bmps[layer]);
+ }
+ }
+
+ /* Set visible on related layers other than current */
+ for (int i = 0; i < layers[layer].layerLinkList.cnt; i++) {
+ // .layerLinkList values are 1-based layer indices
+ int l = DYNARR_N(int, layers[layer].layerLinkList, i) - 1;
+ if ((l != curLayer) && (l >= 0) && (l < NUM_LAYERS)) {
+ layers[l].visible = layers[layer].visible;
+ if (!layers[l].button_off) {
+ wButtonSetBusy(layer_btns[l], layers[l].visible);
+ }
+ }
+ }
+
+ RedrawLayer(layer, TRUE);
+}
+
+static char lastSettings[STR_SHORT_SIZE];
+void SetCurrLayer(wIndex_t inx, const char * name, wIndex_t op,
+ void * listContext, void * arg)
+{
+ unsigned int newLayer = (unsigned int)inx;
+
+ if (layers[newLayer].frozen) {
+ NoticeMessage(MSG_LAYER_SEL_FROZEN, _("Ok"), NULL);
+ wListSetIndex(setLayerL, curLayer);
+ return;
+ }
+
+ char *array[1];
+ if (!layers[inx].settingsName[0]
+ || strcmp(layers[inx].settingsName, " ") == 0) {
+ if (lastSettings[0]) {
+ DoSettingsRead(1, NULL, NULL);
+ }
+ lastSettings[0] = '\0';
+ } else {
+ if (strcmp(layers[inx].settingsName, lastSettings) != 0) {
+ if (!lastSettings[0]) { wPrefFlush(""); } // Save Last Settings for no settings file
+ array[0] = layers[inx].settingsName;
+ DoSettingsRead(1, array, NULL);
+ }
+ strcpy(lastSettings, layers[inx].settingsName);
+ }
+
+
+ curLayer = newLayer;
+
+ if (!IsLayerValid(curLayer)) {
+ curLayer = 0; //Too big or -1
+ layers[curLayer].frozen = FALSE; //Make sure the layer is not frozen
+ }
+
+
+ if (!layers[curLayer].visible) {
+ FlipLayer(I2VP(inx));
+ }
+
+ /* Set visible on related layers other than current */
+ for (int i = 0; i < layers[curLayer].layerLinkList.cnt; i++) {
+ // .layerLinkList values are 1-based layer indices
+ int l = DYNARR_N(int, layers[curLayer].layerLinkList, i) - 1;
+ if (l != curLayer && l >= 0 && l < NUM_LAYERS) {
+ layers[l].visible = layers[curLayer].visible;
+ if (!layers[l].button_off) {
+ wButtonSetBusy(layer_btns[l], layers[l].visible);
+ }
+ }
+ }
+
+ if (recordF) {
+ fprintf(recordF, "SETCURRLAYER %d\n", inx);
+ }
+}
+
+static void PlaybackCurrLayer(char * line)
+{
+ wIndex_t layer;
+ layer = atoi(line);
+ wListSetIndex(setLayerL, layer);
+ SetCurrLayer(layer, NULL, 0, NULL, NULL);
+}
+
+/**
+ * Change the color of a layer.
+ *
+ * \param inx IN layer to change
+ * \param color IN new color
+ */
+
+static void SetLayerColor(unsigned int inx, wDrawColor color)
+{
+ if (color != layers[inx].color) {
+ if (inx < NUM_BUTTONS) {
+ wIconSetColor(show_layer_bmps[inx], color);
+ wButtonSetLabel(layer_btns[inx], (char*)show_layer_bmps[inx]);
+ }
+
+ layers[inx].color = color;
+ layoutLayerChanged = TRUE;
+ }
+}
+
+static void SetLayerHideButton(unsigned int inx, wBool_t hide)
+{
+ if (hide != layers[inx].button_off) {
+ if (inx < NUM_BUTTONS) {
+ wControlShow((wControl_p)layer_btns[inx], !hide);
+ if (!hide) { wButtonSetBusy(layer_btns[inx], layers[inx].visible); }
+ }
+ layers[inx].button_off = hide;
+ layoutLayerChanged = TRUE;
+ }
+}
+
+char *
+FormatLayerName(unsigned int layerNumber)
+{
+ DynString string;// = NaS;
+ char *result;
+ DynStringMalloc(&string, 0);
+ DynStringPrintf(&string,
+ "%2d %c %s",
+ layerNumber + 1,
+ (layers[layerNumber].frozen ? '*' : layers[layerNumber].module ? 'm' :
+ layers[layerNumber].objCount > 0 ? '+' : '-'),
+ layers[layerNumber].name);
+ result = strdup(DynStringToCStr(&string));
+ DynStringFree(&string);
+ return result;
+}
+
+static char *show_layer_bits;
+
+static long layerRawColorTab[] = {
+ wRGB( 0, 0, 192), /* blue */
+ wRGB( 0, 192, 0), /* green */
+ wRGB(192, 0, 0), /* red */
+ wRGB(128, 128, 0), /* yellow */
+ wRGB( 0, 128, 128), /* cyan */
+ wRGB( 0, 0, 128), /* dk blue */
+ wRGB( 0, 128, 0), /* dk green */
+ wRGB(128, 0, 0), /* dk red */
+ wRGB( 96, 96, 0), /* green-brown */
+ wRGB( 0, 96, 96) /* dk cyan */
+};
+static wDrawColor layerColorTab[COUNT(layerRawColorTab)];
+
+
+static wWin_p layerW;
+static char layerName[STR_SHORT_SIZE];
+static char layerLinkList[STR_LONG_SIZE];
+static char settingsName[STR_SHORT_SIZE];
+static wDrawColor layerColor;
+static long layerUseColor = TRUE;
+static long layerVisible = TRUE;
+static long layerFrozen = FALSE;
+static long layerOnMap = TRUE;
+static long layerModule = FALSE;
+static long layerNoButton = FALSE;
+static long layerInherit = FALSE;
+
+static SCALEINX_T layerScaleInx;
+static SCALEDESCINX_T layerScaleDescInx;
+static GAUGEINX_T layerGaugeInx;
+static DIST_T layerMinRadius;
+static ANGLE_T layerMaxGrade;
+static tieData_t layerTieData;
+
+static long layerObjectCount;
+static void LayerOk(void * unused);
+static BOOL_T layerRedrawMap = FALSE;
+
+#define ENUMLAYER_RELOAD (1)
+#define ENUMLAYER_SAVE (2)
+#define ENUMLAYER_CLEAR (3)
+#define ENUMLAYER_ADD (4)
+#define ENUMLAYER_DELETE (5)
+#define ENUMLAYER_DEFAULT (6)
+
+static char *visibleLabels[] = { "", NULL };
+static char *frozenLabels[] = { "", NULL };
+static char *onMapLabels[] = { "", NULL };
+static char *moduleLabels[] = { "", NULL };
+static char *noButtonLabels[] = { "", NULL };
+static char *defaultLabels[] = { "", NULL };
+static char *layerColorLabels[] = { "", NULL };
+static paramIntegerRange_t i0_20 = { 0, NUM_BUTTONS };
+//static paramListData_t layerUiListData = { 10, 370, 0 };
+
+static paramData_t layerPLs[] = {
+#define I_LIST (0)
+ { PD_DROPLIST, NULL, "layer", PDO_LISTINDEX, I2VP(250), N_("Select Layer:") },
+#define I_NAME (1)
+ { PD_STRING, layerName, "name", PDO_NOPREF | PDO_STRINGLIMITLENGTH | PDO_DLGBOXEND, I2VP(250 - 54), N_("Name"), 0, 0, sizeof(layerName) },
+#define I_COLOR (2)
+ { PD_COLORLIST, &layerColor, "color", PDO_NOPREF, NULL, N_("Color") },
+#define I_USE_COLOR (3)
+ { PD_TOGGLE, &layerUseColor, "layercolor", PDO_NOPREF | PDO_DLGHORZ, layerColorLabels, N_("Use Color"), BC_HORZ | BC_NOBORDER },
+#define I_VIS (4)
+ { PD_TOGGLE, &layerVisible, "visible", PDO_NOPREF, visibleLabels, N_("Visible"), BC_HORZ | BC_NOBORDER },
+#define I_FRZ (5)
+ { PD_TOGGLE, &layerFrozen, "frozen", PDO_NOPREF | PDO_DLGHORZ, frozenLabels, N_("Frozen"), BC_HORZ | BC_NOBORDER },
+#define I_MAP (6)
+ { PD_TOGGLE, &layerOnMap, "onmap", PDO_NOPREF | PDO_DLGHORZ, onMapLabels, N_("On Map"), BC_HORZ | BC_NOBORDER },
+#define I_MOD (7)
+ { PD_TOGGLE, &layerModule, "module", PDO_NOPREF | PDO_DLGHORZ, moduleLabels, N_("Module"), BC_HORZ | BC_NOBORDER },
+#define I_BUT (8)
+ { PD_TOGGLE, &layerNoButton, "button", PDO_NOPREF | PDO_DLGHORZ, noButtonLabels, N_("No Button"), BC_HORZ | BC_NOBORDER },
+#define I_DEF (9)
+ { PD_TOGGLE, &layerInherit, "inherit", PDO_NOPREF | PDO_DLGHORZ | PDO_DLGBOXEND, defaultLabels, N_("Inherit"), BC_HORZ | BC_NOBORDER },
+#define I_SCALE (10)
+ { PD_DROPLIST, &layerScaleDescInx, "scale", PDO_NOPREF | PDO_NOPSHUPD | PDO_NORECORD | PDO_NOUPDACT, I2VP(180), N_("Scale"), 0, I2VP(CHANGE_LAYER) },
+#define I_GAUGE (11)
+ { PD_DROPLIST, &layerGaugeInx, "gauge", PDO_NOPREF | PDO_NOPSHUPD | PDO_NORECORD | PDO_NOUPDACT | PDO_DLGHORZ, I2VP(180), N_(" Gauge") },
+#define I_MINRADIUSENTRY (12)
+ { PD_FLOAT, &layerMinRadius, "mintrackradius", PDO_DIM | PDO_NOPSHUPD | PDO_NOPREF, &r0_10000, N_("Min Track Radius"), 0, I2VP(CHANGE_MAIN | CHANGE_LIMITS) },
+#define I_MAXGRADEENTRY (13)
+ { PD_FLOAT, &layerMaxGrade, "maxtrackgrade", PDO_NOPSHUPD | PDO_DLGHORZ | PDO_NOPREF, &r0_90, N_(" Max Track Grade (%)"), 0, I2VP(CHANGE_MAIN) },
+#define I_TIELEN (14)
+ { PD_FLOAT, &layerTieData.length, "tielength", PDO_NOPREF, &r_tieData, N_( "Tie Length" ), 0, I2VP( CHANGE_MAIN ) },
+#define I_TIEWID (15)
+ { PD_FLOAT, &layerTieData.width, "tiewidth", PDO_NOPREF | PDO_DLGHORZ, &r_tieData, N_( " Width" ), 0, I2VP( CHANGE_MAIN ) },
+#define I_TIESPC (16)
+ { PD_FLOAT, &layerTieData.spacing, "tiespacing", PDO_NOPREF | PDO_DLGHORZ | PDO_DLGBOXEND, &r_tieData, N_( " Spacing" ), 0, I2VP( CHANGE_MAIN ) },
+
+ { PD_MESSAGE, N_("Layer Actions"), NULL, PDO_DLGRESETMARGIN, I2VP(180) },
+#define I_ADD (18)
+ { PD_BUTTON, DoLayerOp, "add", PDO_DLGRESETMARGIN, 0, N_("Add Layer"), 0, I2VP(ENUMLAYER_ADD) },
+#define I_DELETE (19)
+ { PD_BUTTON, DoLayerOp, "delete", PDO_DLGHORZ, 0, N_("Delete Layer"), 0, I2VP(ENUMLAYER_DELETE) },
+#define I_DEFAULT (20)
+ { PD_BUTTON, DoLayerOp, "default", PDO_DLGHORZ | PDO_DLGBOXEND, 0, N_("Default Values"), 0, I2VP(ENUMLAYER_DEFAULT) },
+ { PD_LONG, &newLayerCount, "button-count", PDO_DLGBOXEND | PDO_DLGRESETMARGIN, &i0_20, N_("Number of Layer Buttons") },
+#define I_LINKLIST (22)
+ { PD_STRING, layerLinkList, "layerlist", PDO_NOPREF | PDO_STRINGLIMITLENGTH, I2VP(250 - 54), N_("Linked Layers"), 0, 0, sizeof(layerLinkList) },
+#define I_SETTINGS (23)
+ { PD_DROPLIST, NULL, "settings", PDO_LISTINDEX, I2VP(250), N_("Settings when Current") },
+#define I_COUNT (24)
+ { PD_LONG, &layerObjectCount, "objectCount", PDO_DLGBOXEND, &r_nocheck, N_("Object Count:"), 0, 0 },
+ { PD_MESSAGE, N_("All Layer Preferences"), NULL, PDO_DLGRESETMARGIN, I2VP(180) },
+ { PD_BUTTON, DoLayerOp, "load", PDO_DLGRESETMARGIN, 0, N_("Load"), 0, I2VP(ENUMLAYER_RELOAD) },
+ { PD_BUTTON, DoLayerOp, "save", PDO_DLGHORZ, 0, N_("Save"), 0, I2VP(ENUMLAYER_SAVE) },
+ { PD_BUTTON, DoLayerOp, "clear", PDO_DLGHORZ | PDO_DLGBOXEND, 0, N_("Defaults"), 0, I2VP(ENUMLAYER_CLEAR) },
+};
+
+#define settingsListL ((wList_p)layerPLs[I_SETTINGS].control)
+
+static paramGroup_t layerPG = { "layer", 0, layerPLs, COUNT( layerPLs ) };
+
+/**
+ * Reload the listbox showing the current catalog
+ */
+static int LoadFileListLoad(Catalog *catalog, char * name)
+{
+ CatalogEntry *currentEntry = catalog->head;
+ DynString description;
+ DynStringMalloc(&description, STR_SHORT_SIZE);
+
+ wControlShow((wControl_p)settingsListL, FALSE);
+ wListClear(settingsListL);
+
+ int currset = 0;
+
+ int i = 0;
+
+ wListAddValue(settingsListL, " ", NULL, " ");
+
+ while (currentEntry) {
+ i++;
+ DynStringClear(&description);
+ DynStringCatCStr(&description,
+ currentEntry->contents) ;
+ wListAddValue(settingsListL,
+ DynStringToCStr(&description),
+ NULL,
+ currentEntry->fullFileName[0]);
+ if (strcmp(currentEntry->fullFileName[0], name) == 0) { currset = i; }
+ currentEntry = currentEntry->next;
+ }
+
+
+ wListSetIndex(settingsListL, currset);
+
+ wControlShow((wControl_p)settingsListL, TRUE);
+
+ DynStringFree(&description);
+
+ if (currset == 0 && strcmp(" ", name) != 0) { return FALSE; }
+ return TRUE;
+}
+
+#define layerL ((wList_p)layerPLs[I_LIST].control)
+
+#define layerS ((wList_p)layerPLs[I_SETTINGS].control)
+
+#define scaleL ((wList_p)layerPLs[I_SCALE].control)
+
+#define gaugeL ((wList_p)layerPLs[I_GAUGE].control)
+
+/**
+* @brief Reload Layer parameters if changes
+* @param changes
+*/
+static void LayerChange(long changes)
+{
+ if (changes & (CHANGE_LAYER))
+ if (layerW != NULL && wWinIsVisible(layerW)) {
+ ParamLoadControls(&layerPG);
+ }
+}
+
+void GetLayerLinkString(int inx, char * list)
+{
+ char * cp = &list[0];
+ cp[0] = '\0';
+ int len = 0;
+ for (int i = 0; i < layers[inx].layerLinkList.cnt
+ && len < STR_LONG_SIZE - 5; i++) {
+ int l = DYNARR_N(int, layers[inx].layerLinkList, i);
+ if (i == 0) {
+ cp += sprintf(cp, "%d", l);
+ } else {
+ cp += sprintf(cp, ";%d", l);
+ }
+ cp[0] = '\0';
+ }
+}
+
+void PutLayerListArray(int inx, char * list)
+{
+ char * cp = &list[0];
+ DYNARR_RESET(int, layers[inx].layerLinkList);
+ while (cp) {
+ cp = strpbrk(list, ",; ");
+ if (cp) {
+ cp[0] = '\0';
+ int i = abs((int)strtol(list, &list, 0));
+ if (i > 0 && i != inx - 1 && i < NUM_LAYERS) {
+ DYNARR_APPEND(int, layers[inx].layerLinkList, 1);
+ DYNARR_LAST(int, layers[inx].layerLinkList) = i;
+ }
+ cp[0] = ';';
+ list = cp + 1;
+ } else {
+ int i = abs((int)strtol(list, &list, 0));
+ if (i > 0 && i != inx - 1 && i < NUM_LAYERS) {
+ DYNARR_APPEND(int, layers[inx].layerLinkList, 1);
+ DYNARR_LAST(int, layers[inx].layerLinkList) = i;
+ }
+ cp = 0;
+ }
+ }
+}
+
+/**
+ * Set a Layer to System Default
+ */
+void LayerSystemDefault( unsigned int inx )
+{
+
+ strcpy(layers[inx].name, inx == 0 ? _("Main") : "");
+ layers[inx].visible = TRUE;
+ layers[inx].frozen = FALSE;
+ layers[inx].onMap = TRUE;
+ layers[inx].module = FALSE;
+ layers[inx].button_off = FALSE;
+ layers[inx].inherit = TRUE;
+ layers[inx].scaleInx = 0;
+ GetScaleGauge(layers[inx].scaleInx, &layers[inx].scaleDescInx,
+ &layers[inx].gaugeInx);
+ layers[inx].minTrackRadius = GetLayoutMinTrackRadius();
+ layers[inx].maxTrackGrade = GetLayoutMaxTrackGrade();
+ layers[inx].tieData.valid = FALSE;
+ layers[inx].tieData.length = 0.0;
+ layers[inx].tieData.width = 0.0;
+ layers[inx].tieData.spacing = 0.0;
+ layers[inx].objCount = 0;
+ DYNARR_RESET(int, layers[inx].layerLinkList);
+ SetLayerColor(inx, layerColorTab[inx % COUNT(layerColorTab)]);
+}
+
+/**
+ * Is a layer the system default?
+ */
+BOOL_T IsLayerDefault( unsigned int inx )
+{
+ return (!layers[inx].name[0]) &&
+ layers[inx].visible &&
+ !layers[inx].frozen &&
+ layers[inx].onMap &&
+ !layers[inx].module &&
+ !layers[inx].button_off &&
+ layers[inx].inherit &&
+ (!layers[inx].layerLinkList.cnt) &&
+ (layers[inx].color == layerColorTab[inx % COUNT(layerColorTab)]) &&
+ layers[inx].scaleInx == 0 &&
+ //layers[inx].scaleDescInx != layerScaleDescInx ||
+ //layers[inx].gaugeInx != layerGaugeInx ||
+ layers[inx].minTrackRadius == GetLayoutMinTrackRadius() &&
+ layers[inx].maxTrackGrade == GetLayoutMaxTrackGrade() &&
+ layers[inx].tieData.valid == FALSE &&
+ layers[inx].tieData.length == 0.0 &&
+ layers[inx].tieData.width == 0.0 &&
+ layers[inx].tieData.spacing == 0.0;
+}
+
+/**
+ * Load the layer settings to hard coded system defaults
+ */
+EXPORT void LayerAllDefaults(void)
+{
+ int inx;
+
+ for (inx = 0; inx < NUM_LAYERS; inx++) {
+ LayerSystemDefault(inx);
+ }
+}
+
+/**
+ * Load the layer listboxes in Manage Layers and the Toolbar with up-to-date information.
+ */
+void LoadLayerLists(void)
+{
+ int inx;
+ /* clear both lists */
+ wListClear(setLayerL);
+
+ if (layerL) {
+ wListClear(layerL);
+ }
+
+ if (layerS) {
+ wListClear(layerS);
+ }
+
+
+ /* add all layers to both lists */
+ for (inx = 0; inx < NUM_LAYERS; inx++) {
+ char *layerLabel;
+ layerLabel = FormatLayerName(inx);
+
+ if (layerL) {
+ wListAddValue(layerL, layerLabel, NULL, NULL);
+ }
+
+ wListAddValue(setLayerL, layerLabel, NULL, NULL);
+ free(layerLabel);
+ }
+
+ /* set current layer to selected */
+ wListSetIndex(setLayerL, curLayer);
+
+ if (layerL) {
+ wListSetIndex(layerL, curLayer);
+ }
+}
+
+/**
+ * Add a layer after selected layer
+ */
+static void LayerAdd( )
+{
+ unsigned int inx;
+ unsigned int newLayer = layerSelected + 1;
+
+ // UndoStart( _("Add Layer"), "addlayer" );
+ maxLayer++;
+ for ( inx = maxLayer; inx > newLayer; inx-- ) {
+ layers[inx] = layers[inx - 1];
+ }
+
+ TrackInsertLayer(newLayer);
+
+ LayerSystemDefault(newLayer);
+ strcpy(layers[newLayer].name, "New Layer");
+ layers[newLayer].objCount = 0;
+
+ UpdateLayerDlg( newLayer );
+
+ layerSelected = newLayer;
+ layoutLayerChanged = TRUE;
+ // UndoEnd();
+}
+
+/**
+* Delete the selected layer
+*/
+static void LayerDelete( )
+{
+ unsigned int inx;
+
+ if (layers[layerSelected].objCount > 0) {
+ NoticeMessage(_("Layer must not have any objects in it."), _("Ok"), NULL);
+ return;
+ }
+
+ if (layerSelected <= maxLayer) {
+ for ( inx = layerSelected; inx < maxLayer; inx++ ) {
+ layers[inx] = layers[inx + 1];
+ }
+ LayerSystemDefault(maxLayer);
+
+ if (maxLayer > 0) {
+ maxLayer--;
+ }
+ }
+
+ TrackDeleteLayer( layerSelected );
+
+ UpdateLayerDlg( layerSelected );
+
+ layoutLayerChanged = TRUE;
+}
+
+/**
+* Set the Min Radius, Max Grade and Tie values to Layout or Scale defaults
+*/
+static void LayerDefault( )
+{
+ if ( layers[layerSelected].inherit ) {
+ layers[layerSelected].scaleInx = GetLayoutCurScale( );
+ GetScaleGauge(layers[layerSelected].scaleInx,
+ &layers[layerSelected].scaleDescInx,
+ &layers[layerSelected].gaugeInx);
+ layers[layerSelected].minTrackRadius = GetLayoutMinTrackRadius();
+ layers[layerSelected].maxTrackGrade = GetLayoutMaxTrackGrade();
+ } else {
+ layers[layerSelected].scaleInx = GetLayerScale( layerSelected );
+ GetScaleGauge(layers[layerSelected].scaleInx,
+ &layers[layerSelected].scaleDescInx,
+ &layers[layerSelected].gaugeInx);
+ layers[layerSelected].minTrackRadius = GetLayoutMinTrackRadius();
+ layers[layerSelected].maxTrackGrade = GetLayoutMaxTrackGrade();
+ }
+ layers[layerSelected].tieData = GetScaleTieData(layers[layerSelected].scaleInx);
+
+ UpdateLayerDlg( layerSelected );
+
+ layoutLayerChanged = TRUE;
+}
+
+/**
+ * Handle button presses for the layer dialog. For all button presses in the layer
+ * dialog, this function is called. The parameter identifies the button pressed and
+ * the operation is performed.
+ *
+ * \param[IN] data identifier for the button pressed
+ * \return
+ */
+
+static void DoLayerOp(void * data)
+{
+ switch (VP2L(data)) {
+ case ENUMLAYER_CLEAR:
+ InitializeLayers(LayerAllDefaults, -1);
+ break;
+
+ case ENUMLAYER_SAVE:
+ LayerPrefSave();
+ break;
+
+ case ENUMLAYER_RELOAD:
+ LayerPrefLoad();
+ break;
+
+ case ENUMLAYER_ADD:
+ LayerAdd();
+ break;
+
+ case ENUMLAYER_DELETE:
+ LayerDelete();
+ break;
+
+ case ENUMLAYER_DEFAULT:
+ LayerDefault();
+ break;
+ }
+
+ // UpdateLayerDlg(curLayer); //Reset to current Layer
+ ParamControlActive( &layerPG, I_DELETE, (layerSelected > 0) ? TRUE : FALSE);
+
+ if (layoutLayerChanged) {
+ MainProc(mainW, wResize_e, NULL, NULL);
+ layoutLayerChanged = FALSE;
+ SetFileChanged();
+ }
+}
+
+/**
+ * Update all dialogs and dialog elements after changing layers preferences. Once the global array containing
+ * the settings for the labels has been changed, this function needs to be called to update all the user interface
+ * elements to the new settings.
+ */
+EXPORT void UpdateLayerDlg(unsigned int layer)
+{
+ int inx;
+ /* update the globals for the layer dialog */
+ layerVisible = layers[layer].visible;
+ layerFrozen = layers[layer].frozen;
+ layerOnMap = layers[layer].onMap;
+ layerModule = layers[layer].module;
+ layerColor = layers[layer].color;
+ layerUseColor = layers[layer].useColor;
+ layerNoButton = layers[layer].button_off;
+ layerInherit = layers[layer].inherit;
+ layerScaleInx = layers[layer].scaleInx;
+ layerScaleDescInx = layers[layer].scaleDescInx;
+ layerGaugeInx = layers[layer].gaugeInx;
+ layerMinRadius = layers[layer].minTrackRadius;
+ layerMaxGrade = layers[layer].maxTrackGrade;
+ layerTieData = layers[layer].tieData;
+ layerObjectCount = layers[layer].objCount;
+ strcpy(layerName, layers[layer].name);
+ strcpy(settingsName, layers[layer].settingsName);
+ GetLayerLinkString(layer, layerLinkList);
+
+ layerSelected = layer;
+
+ /* now re-load the layer list boxes */
+ LoadLayerLists();
+
+ /* Sync Scale and lists */
+ if (gaugeL) {
+ LoadGaugeList(gaugeL, layerScaleDescInx);
+ wListSetIndex(gaugeL, layerGaugeInx);
+ }
+ /* Sync Scale and lists */
+ GetScaleGauge(layerScaleInx, &layerScaleDescInx, &layerGaugeInx);
+
+ /* force update of the 'manage layers' dialogbox */
+ if (layerL) {
+ wListSetIndex(layerL, layer);
+ ParamLoadControls(&layerPG);
+ }
+
+ if (layerS) {
+ if (!LoadFileListLoad(settingsCatalog, settingsName)) {
+ layers[layer].settingsName[0] = '\0';
+ }
+ }
+
+ ParamControlActive( &layerPG, I_DELETE, (layerSelected > 0) ? TRUE : FALSE);
+ ParamControlActive( &layerPG, I_COUNT, FALSE );
+
+ ParamControlActive( &layerPG, I_SCALE, !layerInherit);
+ ParamControlActive( &layerPG, I_GAUGE, !layerInherit);
+ ParamControlActive( &layerPG, I_MINRADIUSENTRY, !layerInherit);
+ ParamControlActive( &layerPG, I_MAXGRADEENTRY, !layerInherit);
+ ParamControlActive( &layerPG, I_TIELEN, !layerInherit);
+ ParamControlActive( &layerPG, I_TIEWID, !layerInherit);
+ ParamControlActive( &layerPG, I_TIESPC, !layerInherit);
+
+ /* finally show the layer buttons with balloon text */
+ for (inx = 0; inx < NUM_BUTTONS; inx++) {
+ if (!layers[inx].button_off) {
+ wButtonSetBusy(layer_btns[inx], layers[inx].visible != 0);
+ wControlSetBalloonText((wControl_p)layer_btns[inx],
+ (layers[inx].name[0] != '\0' ? layers[inx].name : _("Show/Hide Layer")));
+ }
+ }
+}
+
+/**
+ * Fill a layer dropbox with the current layer settings
+ *
+ * \param listLayers the dropbox
+ * \return
+ */
+void FillLayerList( wList_p listLayers)
+{
+ wListClear(listLayers); // Rebuild list on each invocation
+
+ for (int inx = 0; inx < NUM_LAYERS; inx++) {
+ char *layerFormattedName;
+ layerFormattedName = FormatLayerName(inx);
+ wListAddValue((wList_p)listLayers, layerFormattedName, NULL, I2VP(inx));
+ free(layerFormattedName);
+ }
+
+ /* set current layer to selected */
+ wListSetIndex(listLayers, curLayer);
+
+ ParamControlActive( &layerPG, I_DELETE, (curLayer > 0) ? TRUE : FALSE);
+ if ( layerInherit ) {
+ ParamControlActive( &layerPG, I_TIELEN, FALSE);
+ ParamControlActive( &layerPG, I_TIEWID, FALSE);
+ ParamControlActive( &layerPG, I_TIESPC, FALSE);
+ }
+}
+
+/**
+ * Initialize the layer lists.
+ *
+ * \param IN pointer to function that actually initialize tha data structures
+ * \param IN current layer (0...NUM_LAYERS), (-1) for no change
+ */
+static void
+InitializeLayers(void LayerInitFunc(void), int newCurrLayer)
+{
+ /* reset the data structures to default valuses */
+ LayerInitFunc();
+ /* count the objects on each layer */
+ LayerSetCounts();
+
+ /* Switch the current layer when requested or the first above not frozen*/
+ if (newCurrLayer != -1) {
+ curLayer = -1;
+ for (int i = newCurrLayer; i < NUM_LAYERS; i++) {
+ if (!layers[i].frozen) {
+ curLayer = i;
+ break;
+ }
+ }
+ if (curLayer == -1) {
+ ErrorMessage( MSG_NO_EMPTY_LAYER );
+ layers[0].frozen = FALSE;
+ curLayer = 0;
+ }
+ }
+}
+
+/**
+ * Save an integer to Prefs
+ */
+static void
+layerSetInteger( unsigned int inx, char prefName[], int value )
+{
+ char buffer[80];
+ char name[80];
+ strcpy(name, prefName);
+ strcat(name, ".%0u");
+ sprintf( buffer, name, inx );
+ wPrefSetInteger( LAYERPREF_SECTION, buffer, value );
+}
+/**
+* Save a float to Prefs
+*/
+static void
+layerSetFloat( unsigned int inx, char prefName[], double value )
+{
+ char buffer[80];
+ char name[20];
+ strcpy(name, prefName);
+ strcat(name, ".%0u");
+ sprintf( buffer, name, inx );
+ wPrefSetFloat( LAYERPREF_SECTION, buffer, value );
+}
+
+/**
+ * Save the customized layer information to preferences.
+ */
+static void
+LayerPrefSave(void)
+{
+ unsigned int inx;
+ int flags;
+ char buffer[ 80 ];
+ char links[STR_LONG_SIZE];
+ char layersSaved[ 3 * NUM_LAYERS + 1 ]; /* 0..99 plus separator */
+ /* FIXME: values for layers that are configured to default now should be overwritten in the settings */
+ layersSaved[ 0 ] = '\0';
+
+ for (inx = 0; inx < NUM_LAYERS; inx++) {
+ /* if a name is set that is not the default value or a color different from the default has been set,
+ information about the layer needs to be saved */
+ if (inx == 0 || !IsLayerDefault(inx)) {
+ sprintf(buffer, LAYERPREF_NAME ".%0u", inx);
+ wPrefSetString(LAYERPREF_SECTION, buffer, layers[inx].name);
+
+ layerSetInteger(inx, LAYERPREF_COLOR, wDrawGetRGB(layers[inx].color));
+
+ flags = 0;
+ if (layers[inx].frozen) {
+ flags |= LAYERPREF_FROZEN;
+ }
+ if (layers[inx].onMap) {
+ flags |= LAYERPREF_ONMAP;
+ }
+ if (layers[inx].visible) {
+ flags |= LAYERPREF_VISIBLE;
+ }
+ if (layers[inx].module) {
+ flags |= LAYERPREF_MODULE;
+ }
+ if (layers[inx].button_off) {
+ flags |= LAYERPREF_NOBUTTON;
+ }
+ if (layers[inx].inherit) {
+ flags |= LAYERPREF_DEFAULT;
+ }
+ layerSetInteger(inx, LAYERPREF_FLAGS, flags);
+
+ layers[inx].scaleInx = GetScaleInx( layers[inx].scaleDescInx,
+ layers[inx].gaugeInx );
+ layerSetInteger(inx, LAYERPREF_SCALEINX, layers[inx].scaleInx);
+ layerSetInteger(inx, LAYERPREF_SCLDESCINX, layers[inx].scaleDescInx);
+ layerSetInteger(inx, LAYERPREF_GAUGEINX, layers[inx].gaugeInx);
+ layerSetFloat(inx, LAYERPREF_MINRADIUS, layers[inx].minTrackRadius);
+ layerSetFloat(inx, LAYERPREF_MAXGRADE, layers[inx].maxTrackGrade);
+ layerSetFloat(inx, LAYERPREF_TIELENGTH, layers[inx].tieData.length);
+ layerSetFloat(inx, LAYERPREF_TIEWIDTH, layers[inx].tieData.width);
+ layerSetFloat(inx, LAYERPREF_TIESPACING, layers[inx].tieData.spacing);
+
+ if (layers[inx].layerLinkList.cnt > 0) {
+ sprintf(buffer, LAYERPREF_LIST ".%0u", inx);
+ GetLayerLinkString(inx, links);
+ wPrefSetString(LAYERPREF_SECTION, buffer, links);
+
+ if (settingsName[0] && strcmp(settingsName, " ") != 0) {
+ sprintf(buffer, LAYERPREF_SETTINGS ".%0u", inx);
+ wPrefSetString(LAYERPREF_SECTION, buffer, layers[inx].settingsName);
+ }
+ }
+
+ /* extend the list of layers that are set up via the preferences */
+ if (layersSaved[ 0 ]) {
+ strcat(layersSaved, ",");
+ }
+
+ sprintf(buffer, "%u", inx);
+ strcat(layersSaved, buffer);
+ }
+ }
+
+ wPrefSetString(LAYERPREF_SECTION, "layers", layersSaved);
+}
+
+
+/**
+* Load an integer from Prefs
+*/
+static void
+layerGetInteger( unsigned int inx, char prefName[], long *value, int deflt )
+{
+ char buffer[80];
+ char name[80];
+ strcpy(name, prefName);
+ strcat(name, ".%0u");
+ sprintf( buffer, name, inx );
+ wPrefGetInteger( LAYERPREF_SECTION, buffer, value, deflt );
+}
+/**
+* Load a float from Prefs
+*/
+static void
+layerGetFloat( unsigned int inx, char prefName[], double *value, double deflt )
+{
+ char buffer[80];
+ char name[20];
+ strcpy(name, prefName);
+ strcat(name, ".%0u");
+ sprintf( buffer, name, inx );
+ wPrefGetFloat( LAYERPREF_SECTION, buffer, value, deflt );
+}
+
+/**
+ * Load the settings for all layers from the preferences.
+ */
+
+static void
+LayerPrefLoad(void)
+{
+ const char *prefString;
+ long rgb;
+ long flags;
+ /* reset layer preferences to system default */
+ LayerAllDefaults();
+ prefString = wPrefGetString(LAYERPREF_SECTION, "layers");
+
+ if (prefString && prefString[ 0 ]) {
+ char layersSaved[3 * NUM_LAYERS];
+ strncpy(layersSaved, prefString, sizeof(layersSaved));
+ prefString = strtok(layersSaved, ",");
+
+ while (prefString) {
+ int inx;
+ char layerOption[20];
+ const char *layerValue;
+ char listValue[STR_LONG_SIZE];
+ int color;
+ inx = atoi(prefString);
+ sprintf(layerOption, LAYERPREF_NAME ".%d", inx);
+ layerValue = wPrefGetString(LAYERPREF_SECTION, layerOption);
+
+ if (layerValue) {
+ strcpy(layers[inx].name, layerValue);
+ } else {
+ *(layers[inx].name) = '\0';
+ }
+
+ /* get and set the color, using the system default color in case color is not available from prefs */
+ layerGetInteger(inx, LAYERPREF_COLOR, &rgb,
+ layerColorTab[inx % COUNT(layerColorTab)]);
+ color = wDrawFindColor(rgb);
+ SetLayerColor(inx, color);
+ /* get and set the flags */
+ layerGetInteger(inx, LAYERPREF_FLAGS, &flags,
+ LAYERPREF_ONMAP | LAYERPREF_VISIBLE);
+ layers[inx].frozen = ((flags & LAYERPREF_FROZEN) != 0);
+ layers[inx].onMap = ((flags & LAYERPREF_ONMAP) != 0);
+ layers[inx].visible = ((flags & LAYERPREF_VISIBLE) != 0);
+ layers[inx].module = ((flags & LAYERPREF_MODULE) != 0);
+ layers[inx].button_off = ((flags & LAYERPREF_NOBUTTON) != 0);
+ layers[inx].inherit = ((flags & LAYERPREF_DEFAULT) != 0);
+
+ layerGetInteger(inx, LAYERPREF_SCALEINX, &layers[inx].scaleInx,
+ GetLayoutCurScale());
+ layerGetInteger(inx, LAYERPREF_SCLDESCINX, &layers[inx].scaleDescInx,
+ GetLayoutCurScaleDesc());
+ layerGetInteger(inx, LAYERPREF_GAUGEINX, &layers[inx].gaugeInx, 0);
+
+ layerGetFloat(inx, LAYERPREF_MINRADIUS, &layers[inx].minTrackRadius,
+ GetLayoutMinTrackRadius());
+ layerGetFloat(inx, LAYERPREF_MAXGRADE, &layers[inx].maxTrackGrade,
+ GetLayoutMaxTrackGrade());
+ layerGetFloat(inx, LAYERPREF_TIELENGTH, &layers[inx].tieData.length, 0.0);
+ layerGetFloat(inx, LAYERPREF_TIEWIDTH, &layers[inx].tieData.width, 0.0);
+ layerGetFloat(inx, LAYERPREF_TIESPACING, &layers[inx].tieData.spacing, 0.0);
+
+ sprintf(layerOption, LAYERPREF_LIST ".%d", inx);
+ layerValue = wPrefGetString(LAYERPREF_SECTION, layerOption);
+ if (layerValue) {
+ strcpy(listValue, layerValue);
+ PutLayerListArray(inx, listValue);
+ } else {
+ listValue[0] = '\0';
+ PutLayerListArray(inx, listValue);
+ }
+ sprintf(layerOption, LAYERPREF_SETTINGS ".%d", inx);
+ layerValue = wPrefGetString(LAYERPREF_SECTION, layerOption);
+ if (layerValue) {
+ strcpy(layers[inx].settingsName, layerValue);
+ } else {
+ layers[inx].settingsName[0] = '\0';
+ }
+
+ prefString = strtok(NULL, ",");
+ }
+ }
+ //Make sure curLayer not frozen
+ for (int i = curLayer; i < NUM_LAYERS; i++) {
+ if (!layers[i].frozen) {
+ curLayer = i;
+ break;
+ }
+ }
+ if (layers[curLayer].frozen) {
+ ErrorMessage( MSG_NO_EMPTY_LAYER );
+ layers[0].frozen = FALSE;
+ curLayer = 0;
+ }
+}
+
+/**
+ * Increment the count of objects on a given layer.
+ *
+ * \param index IN the layer to change
+ */
+
+void IncrementLayerObjects(unsigned int layer)
+{
+ CHECK(layer <= NUM_LAYERS);
+ layers[layer].objCount++;
+}
+
+/**
+* Decrement the count of objects on a given layer.
+*
+* \param index IN the layer to change
+*/
+
+void DecrementLayerObjects(unsigned int layer)
+{
+ CHECK(layer <= NUM_LAYERS);
+ layers[layer].objCount--;
+}
+
+/**
+ * Count the number of objects on each layer and store result in layers data structure.
+ */
+
+void LayerSetCounts(void)
+{
+ int inx;
+ track_p trk;
+
+ for (inx = 0; inx < NUM_LAYERS; inx++) {
+ layers[inx].objCount = 0;
+ }
+
+ for (trk = NULL; TrackIterate(&trk);) {
+ inx = GetTrkLayer(trk);
+
+ if (inx >= 0 && inx < NUM_LAYERS) {
+ layers[inx].objCount++;
+ }
+ }
+}
+
+int FindUnusedLayer(unsigned int start)
+{
+ int inx;
+ for (inx = start; inx < NUM_LAYERS; inx++) {
+ if (layers[inx].objCount == 0 && !layers[inx].frozen) { return inx; }
+ }
+ ErrorMessage( MSG_NO_EMPTY_LAYER );
+ return -1;
+}
+
+/**
+ * Reset layer options to their default values. The default values are loaded
+ * from the preferences file.
+ */
+
+void
+DefaultLayerProperties(void)
+{
+ InitializeLayers(LayerPrefLoad, 0);
+ UpdateLayerDlg(curLayer); //Use Current Layer
+
+ if (layoutLayerChanged) {
+ MainProc(mainW, wResize_e, NULL, NULL);
+ layoutLayerChanged = FALSE;
+ }
+}
+
+/**
+ * Update all UI elements after selecting a layer.
+ *
+ */
+
+static void LayerUpdate(void)
+{
+ BOOL_T redraw;
+ char *layerFormattedName;
+ ParamLoadData(&layerPG);
+
+ if (!IsLayerValid(layerSelected)) {
+ return;
+ }
+
+ if (layerSelected == curLayer && layerFrozen) {
+ NoticeMessage(MSG_LAYER_FREEZE, _("Ok"), NULL);
+ layerFrozen = FALSE;
+ ParamLoadControl(&layerPG, I_FRZ);
+ }
+
+ if (layerSelected == curLayer && !layerVisible) {
+ NoticeMessage(MSG_LAYER_HIDE, _("Ok"), NULL);
+ layerVisible = TRUE;
+ ParamLoadControl(&layerPG, I_VIS);
+ }
+
+ if (layerSelected == curLayer && layerModule) {
+ NoticeMessage(MSG_LAYER_MODULE, _("Ok"), NULL);
+ layerModule = FALSE;
+ ParamLoadControl(&layerPG, I_MOD);
+ }
+ char oldLinkList[STR_LONG_SIZE];
+ GetLayerLinkString((int)layerSelected, oldLinkList);
+
+ if (strcmp(layers[(int)layerSelected].name, layerName) ||
+ layerColor != layers[(int)layerSelected].color ||
+ layers[(int)layerSelected].useColor != (BOOL_T)layerUseColor ||
+ layers[(int)layerSelected].visible != (BOOL_T)layerVisible ||
+ layers[(int)layerSelected].frozen != (BOOL_T)layerFrozen ||
+ layers[(int)layerSelected].onMap != (BOOL_T)layerOnMap ||
+ layers[(int)layerSelected].module != (BOOL_T)layerModule ||
+ layers[(int)layerSelected].button_off != (BOOL_T)layerNoButton ||
+ layers[(int)layerSelected].inherit != (BOOL_T)layerInherit ||
+ layers[(int)layerSelected].scaleInx != layerScaleInx ||
+ layers[(int)layerSelected].scaleDescInx != layerScaleDescInx ||
+ layers[(int)layerSelected].gaugeInx != layerGaugeInx ||
+ layers[(int)layerSelected].minTrackRadius != layerMinRadius ||
+ layers[(int)layerSelected].maxTrackGrade != layerMaxGrade ||
+ layers[(int)layerSelected].tieData.length != layerTieData.length ||
+ layers[(int)layerSelected].tieData.width != layerTieData.width ||
+ layers[(int)layerSelected].tieData.spacing != layerTieData.spacing ||
+ strcmp(layers[(int)layerSelected].settingsName, settingsName) ||
+ strcmp(oldLinkList, layerLinkList)) {
+ SetFileChanged();
+ }
+
+ if (layerL) {
+ strncpy(layers[(int)layerSelected].name, layerName,
+ sizeof layers[(int)layerSelected].name);
+ layerFormattedName = FormatLayerName(layerSelected);
+ wListSetValues(layerL, layerSelected, layerFormattedName, NULL, NULL);
+ free(layerFormattedName);
+ }
+
+
+ layerFormattedName = FormatLayerName(layerSelected);
+ wListSetValues(setLayerL, layerSelected, layerFormattedName, NULL, NULL);
+ free(layerFormattedName);
+
+ if (layerSelected < NUM_BUTTONS && !layers[(int)layerSelected].button_off) {
+ if (strlen(layers[(int)layerSelected].name) > 0) {
+ wControlSetBalloonText((wControl_p)layer_btns[(int)layerSelected],
+ layers[(int)layerSelected].name);
+ } else {
+ wControlSetBalloonText((wControl_p)layer_btns[(int)layerSelected],
+ _("Show/Hide Layer"));
+ }
+ }
+
+ redraw = (layerColor != layers[(int)layerSelected].color ||
+ layers[(int)layerSelected].useColor != (BOOL_T)layerUseColor ||
+ (BOOL_T)layerVisible != layers[(int)layerSelected].visible);
+
+ SetLayerColor(layerSelected, layerColor);
+
+ if (layerSelected < NUM_BUTTONS &&
+ layers[(int)layerSelected].visible != (BOOL_T)layerVisible
+ && !layers[(int)layerSelected].button_off) {
+ wButtonSetBusy(layer_btns[(int)layerSelected], layerVisible);
+ }
+
+ layers[(int)layerSelected].useColor = (BOOL_T)layerUseColor;
+ if (layers[(int)layerSelected].visible != (BOOL_T)layerVisible) {
+ FlipLayer(I2VP(layerSelected));
+ }
+ layers[(int)layerSelected].visible = (BOOL_T)layerVisible;
+ layers[(int)layerSelected].frozen = (BOOL_T)layerFrozen;
+ if (layers[(int)layerSelected].frozen) { DeselectLayer(layerSelected); }
+ layers[(int)layerSelected].onMap = (BOOL_T)layerOnMap;
+ layers[(int)layerSelected].scaleDescInx = layerScaleDescInx;
+ layers[(int)layerSelected].gaugeInx = layerGaugeInx;
+ layers[(int)layerSelected].scaleInx = GetScaleInx( layerScaleDescInx,
+ layerGaugeInx );
+ layers[(int)layerSelected].minTrackRadius = layerMinRadius;
+ layers[(int)layerSelected].maxTrackGrade = layerMaxGrade;
+ layers[(int)layerSelected].tieData = layerTieData;
+ layers[(int)layerSelected].module = (BOOL_T)layerModule;
+ layers[(int)layerSelected].inherit = (BOOL_T)layerInherit;
+ strcpy(layers[(int)layerSelected].settingsName, settingsName);
+
+ PutLayerListArray((int)layerSelected, layerLinkList);
+
+ SetLayerHideButton(layerSelected, layerNoButton);
+
+ MainProc( mainW, wResize_e, NULL, NULL );
+
+ if (layerRedrawMap) {
+ DoRedraw();
+ } else if (redraw) {
+ RedrawLayer(layerSelected, TRUE);
+ }
+
+ layerRedrawMap = FALSE;
+}
+
+
+static void LayerSelect(
+ wIndex_t inx)
+{
+ LayerUpdate();
+
+ if (inx < 0 || inx >= NUM_LAYERS) {
+ return;
+ }
+
+ layerSelected = (unsigned int)inx;
+ strcpy(layerName, layers[inx].name);
+ strcpy(settingsName, layers[inx].settingsName);
+ layerVisible = layers[inx].visible;
+ layerFrozen = layers[inx].frozen;
+ layerOnMap = layers[inx].onMap;
+ layerModule = layers[inx].module;
+ layerColor = layers[inx].color;
+ layerUseColor = layers[inx].useColor;
+ layerNoButton = layers[inx].button_off;
+ layerInherit = layers[inx].inherit;
+ layerScaleInx = layers[inx].scaleInx;
+ layerScaleDescInx = layers[inx].scaleDescInx;
+ layerGaugeInx = layers[inx].gaugeInx;
+ layerMinRadius = layers[inx].minTrackRadius;
+ layerMaxGrade = layers[inx].maxTrackGrade;
+ layerTieData.valid = layers[inx].tieData.valid;
+ layerTieData.length = layers[inx].tieData.length;
+ layerTieData.width = layers[inx].tieData.width;
+ layerTieData.spacing = layers[inx].tieData.spacing;
+ layerObjectCount = layers[inx].objCount;
+
+ GetLayerLinkString(inx, layerLinkList);
+ // sprintf(message, "%ld", layers[inx].objCount);
+ // ParamLoadMessage(&layerPG, I_COUNT, message);
+ ParamLoadControls(&layerPG);
+
+ ParamControlActive( &layerPG, I_DELETE, (layerSelected > 0) ? TRUE : FALSE);
+
+ ParamControlActive( &layerPG, I_SCALE, !layerInherit);
+ ParamControlActive( &layerPG, I_GAUGE, !layerInherit);
+ ParamControlActive( &layerPG, I_MINRADIUSENTRY, !layerInherit);
+ ParamControlActive( &layerPG, I_MAXGRADEENTRY, !layerInherit);
+ ParamControlActive( &layerPG, I_TIELEN, !layerInherit);
+ ParamControlActive( &layerPG, I_TIEWID, !layerInherit);
+ ParamControlActive( &layerPG, I_TIESPC, !layerInherit);
+
+ if (layerS) {
+ if (!LoadFileListLoad(settingsCatalog, settingsName)) {
+ settingsName[0] = '\0';
+ layers[inx].settingsName[0] = '\0';
+ }
+
+ }
+}
+
+void ResetLayers(void)
+{
+ int inx;
+
+ for (inx = 0; inx < NUM_LAYERS; inx++) {
+ strcpy(layers[inx].name, inx == 0 ? _("Main") : "");
+ layers[inx].visible = TRUE;
+ layers[inx].frozen = FALSE;
+ layers[inx].onMap = TRUE;
+ layers[inx].module = FALSE;
+ layers[inx].button_off = FALSE;
+ layers[inx].inherit = TRUE;
+ layers[inx].objCount = 0;
+ strcpy(layers[inx].settingsName, "");
+ DYNARR_RESET(int, layers[inx].layerLinkList);
+ SetLayerColor(inx, layerColorTab[inx % COUNT(layerColorTab)]);
+
+
+ if (inx < NUM_BUTTONS) {
+ wButtonSetLabel(layer_btns[inx], (char*)show_layer_bmps[inx]);
+ }
+ }
+
+ wControlSetBalloonText((wControl_p)layer_btns[0], _("Main"));
+
+ for (inx = 1; inx < NUM_BUTTONS; inx++) {
+ wControlSetBalloonText((wControl_p)layer_btns[inx], _("Show/Hide Layer"));
+ }
+
+ curLayer = -1;
+
+ for (int i = 0; i < NUM_LAYERS; i++) {
+ if (!layers[i].frozen) {
+ curLayer = i;
+ break;
+ }
+ }
+
+ if (curLayer == -1) {
+ ErrorMessage( MSG_NO_EMPTY_LAYER );
+ layers[0].frozen = FALSE;
+ curLayer = 0;
+ }
+
+ layerVisible = TRUE;
+ layerFrozen = FALSE;
+ layerOnMap = TRUE;
+ layerModule = FALSE;
+ layerInherit = FALSE;
+ layerColor = layers[0].color;
+ layerUseColor = TRUE;
+ strcpy(layerName, layers[0].name);
+ strcpy(settingsName, layers[0].settingsName);
+
+ LoadLayerLists();
+
+ if (layerL) {
+ ParamLoadControls(&layerPG);
+ // ParamLoadMessage(&layerPG, I_COUNT, "0");
+ }
+}
+
+
+void SaveLayers(void)
+{
+ layers_save = malloc(NUM_LAYERS * sizeof(layers[0]));
+
+ CHECK(layers_save != NULL);
+
+ for (int i = 0; i < NUM_LAYERS; i++) {
+ layers[i].settingsName[0] = '\0';
+ }
+
+ memcpy(layers_save, layers, NUM_LAYERS * sizeof layers[0]);
+ ResetLayers();
+}
+
+void RestoreLayers(void)
+{
+ int inx;
+ char * label;
+ wDrawColor color;
+ CHECK(layers_save != NULL);
+ memcpy(layers, layers_save, NUM_LAYERS * sizeof layers[0]);
+ free(layers_save);
+
+ for (inx = 0; inx < NUM_BUTTONS; inx++) {
+ color = layers[inx].color;
+ layers[inx].color = -1;
+ SetLayerColor(inx, color);
+
+ if (layers[inx].name[0] == '\0') {
+ if (inx == 0) {
+ label = _("Main");
+ } else {
+ label = _("Show/Hide Layer");
+ }
+ } else {
+ label = layers[inx].name;
+ }
+
+ wControlSetBalloonText((wControl_p)layer_btns[inx], label);
+ }
+
+ if (layerL) {
+ ParamLoadControls(&layerPG);
+ //ParamLoadMessage(&layerPG, I_COUNT, "0");
+ }
+
+ LoadLayerLists();
+}
+
+
+/**
+ * Scan opened directory for the next settings file
+ *
+ * \param dir IN opened directory handle
+ * \param dirName IN name of directory
+ * \param fileName OUT fully qualified filename
+ *
+ * \return TRUE if file found, FALSE if not
+ */
+
+static bool
+GetNextSettingsFile(DIR *dir, const char *dirName, char **fileName)
+{
+ bool done = false;
+ bool res = false;
+
+ /*
+ * get all files from the directory
+ */
+ while (!done) {
+ struct stat fileState;
+ struct dirent *ent;
+
+ ent = readdir(dir);
+
+ if (ent) {
+ if (!XtcStricmp(FindFileExtension(ent->d_name), "xset")) {
+ /* create full file name and get the state for that file */
+ MakeFullpath(fileName, dirName, ent->d_name, NULL);
+
+ if (stat(*fileName, &fileState) == -1) {
+ fprintf(stderr, "Error getting file state for %s\n", *fileName);
+ continue;
+ }
+
+ /* ignore any directories */
+ if (!(fileState.st_mode & S_IFDIR)) {
+ done = true;
+ res = true;
+ }
+ }
+ } else {
+ done = true;
+ res = false;
+ }
+ }
+ return (res);
+}
+
+
+/*
+ * Get all the settings files in the working directory
+ */
+
+static CatalogEntry *
+ScanSettingsDirectory(Catalog *catalog, const char *dirName)
+{
+ DIR *d;
+ CatalogEntry *newEntry = catalog->head;
+ char contents[STR_SHORT_SIZE];
+
+ d = opendir(dirName);
+ if (d) {
+ char *fileName = NULL;
+
+ while (GetNextSettingsFile(d, dirName, &fileName)) {
+ char *contents_start = strrchr(fileName, PATH_SEPARATOR[0]);
+ if (contents_start[0] == '/') { contents_start++; }
+ char *contents_end = strchr(contents_start, '.');
+ if (contents_end[0] == '.') { contents_end[0] = '\0'; }
+ strcpy(contents, contents_start);
+ contents_end[0] = '.';
+ newEntry = InsertInOrder(catalog, contents, NULL);
+ UpdateCatalogEntry(newEntry, fileName, contents, NULL);
+ free(fileName);
+ fileName = NULL;
+ }
+ closedir(d);
+ }
+
+ return (newEntry);
+}
+
+
+
+/*****************************************************************************
+*
+* FILE READ/WRITE
+*
+*/
+
+BOOL_T ReadLayers(char * line)
+{
+ char *name, *layerLinkList, *layerSettingsName, *extra;
+ int inx, visible, frozen, color, onMap, sclInx, module, dontUseColor,
+ ColorFlags, button_off, inherit;
+ double minRad, maxGrd, tieLen, tieWid, tieSpc;
+ unsigned long rgb;
+
+ /* older files didn't support layers */
+
+ if (paramVersion < 7) {
+ return TRUE;
+ }
+
+ /* set the current layer */
+
+ if (strncmp(line, "CURRENT", 7) == 0) {
+ curLayer = atoi(line + 7);
+
+ if (!IsLayerValid(curLayer)) {
+
+ curLayer = 0;
+ }
+
+ if (layers[curLayer].frozen) {
+ ErrorMessage( MSG_NOT_UNFROZEN_LAYER );
+ layers[curLayer].frozen = FALSE;
+ }
+
+ if (layerL) {
+ wListSetIndex(layerL, curLayer);
+ }
+
+ if (setLayerL) {
+ wListSetIndex(setLayerL, curLayer);
+ }
+
+ return TRUE;
+ }
+
+ if (strncmp(line, "LINK", 4) == 0) {
+ if (!GetArgs(line + 4, "dq", &inx, &layerLinkList)) {
+ return FALSE;
+ }
+ PutLayerListArray(inx, layerLinkList);
+ return TRUE;
+ }
+
+ if (strncmp(line, "SET", 3) == 0) {
+ if (!GetArgs(line + 3, "dq", &inx, &layerSettingsName)) {
+ return FALSE;
+ }
+ strcpy(layers[inx].settingsName, layerSettingsName);
+ return TRUE;
+ }
+
+ /* get the properties for a layer from the file and update the layer accordingly */
+ /* No Scale/tie data version */
+ if (!GetArgs(line, "dddduddddqc", &inx, &visible, &frozen, &onMap, &rgb,
+ &module, &dontUseColor, &ColorFlags, &button_off, &name, &extra)) {
+ return FALSE;
+ }
+ /* Check for old version: name here */
+ if (extra && strlen(extra) > 0) {
+ /* tie data version */
+ if (!GetArgs(extra, "dufffff", &inherit, &sclInx, &minRad, &maxGrd,
+ &tieLen, &tieWid, &tieSpc)) {
+ return FALSE;
+ }
+ } else {
+ sclInx = GetLayoutCurScale();
+ inherit = TRUE;
+ minRad = 0.0;
+ maxGrd = 0.0;
+ tieLen = 0.0;
+ tieWid = 0.0;
+ tieSpc = 0.0;
+ }
+
+ // Provide defaults
+ if ( minRad < EPSILON ) {
+ minRad = GetScaleMinRadius(sclInx);
+ }
+
+ if (paramVersion < 9) {
+ if ((int)rgb < COUNT( oldColorMap ) ) {
+ rgb = wRGB(oldColorMap[(int)rgb][0], oldColorMap[(int)rgb][1],
+ oldColorMap[(int)rgb][2]);
+ } else {
+ rgb = 0;
+ }
+ }
+
+ if (inx < 0 || inx >= NUM_LAYERS) {
+ return FALSE;
+ }
+
+ tieData_t td = {TRUE, tieLen, tieWid, tieSpc};
+ ValidateTieData(&td);
+ if ( !td.valid ) {
+ td = GetScaleTieData(sclInx);
+ }
+ color = wDrawFindColor(rgb);
+ SetLayerColor(inx, color);
+ strncpy(layers[inx].name, name, sizeof layers[inx].name);
+ layers[inx].visible = visible;
+ layers[inx].frozen = frozen;
+ layers[inx].onMap = onMap;
+ layers[inx].scaleInx = sclInx;
+ layers[inx].minTrackRadius = minRad;
+ layers[inx].maxTrackGrade = maxGrd;
+ layers[inx].tieData = td;
+ layers[inx].module = module;
+ layers[inx].color = color;
+ layers[inx].useColor = !dontUseColor;
+ layers[inx].button_off = button_off;
+ layers[inx].inherit = inherit;
+ GetScaleGauge(sclInx, &layers[inx].scaleDescInx, &layers[inx].gaugeInx);
+
+ colorTrack = ( ColorFlags & 1 ) ? 1 : 0; //Make sure globals are set
+ colorDraw = ( ColorFlags & 2 ) ? 1 : 0;
+
+ if (inx < NUM_BUTTONS && !layers[inx].button_off) {
+ if (strlen(name) > 0) {
+ wControlSetBalloonText((wControl_p)layer_btns[(int)inx], layers[inx].name);
+ }
+ wButtonSetBusy(layer_btns[(int)inx], visible);
+ }
+ MyFree(name);
+
+ // The last layer will set this correctly
+ maxLayer = inx;
+
+ return TRUE;
+}
+
+/**
+ * Find out whether layer information should be saved to the layout file.
+ * Usually only layers where settings are off from the default are written.
+ * NOTE: as a fix for a problem with XTrkCadReader a layer definition is
+ * written for each layer that is used.
+ *
+ * \param layerNumber IN index of the layer
+ * \return TRUE if configured, FALSE if not
+ */
+
+BOOL_T
+IsLayerConfigured(unsigned int layerNumber)
+{
+ return (layers[layerNumber].name[0] ||
+ !layers[layerNumber].visible ||
+ layers[layerNumber].frozen ||
+ !layers[layerNumber].onMap ||
+ layers[layerNumber].module ||
+ layers[layerNumber].button_off ||
+ layers[layerNumber].color != layerColorTab[layerNumber % (COUNT(
+ layerColorTab))] ||
+ layers[layerNumber].layerLinkList.cnt > 0 ||
+ layers[layerNumber].objCount);
+}
+
+
+/**
+ * Save the layer information to the file.
+ *
+ * \paran f IN open file handle
+ * \return always TRUE
+ */
+
+BOOL_T WriteLayers(FILE * f)
+{
+ unsigned int inx;
+
+ int ColorFlags = 0;
+
+ if (colorTrack) { ColorFlags |= 1; }
+ if (colorDraw) { ColorFlags |= 2; }
+
+ for (inx = 0; inx < NUM_LAYERS; inx++) {
+ if (IsLayerConfigured(inx)) {
+ fprintf(f,
+ "LAYERS %u %d %d %d %ld %d %d %d %d \"%s\" %d %lu %.6f %.6f %.6f %.6f %.6f\n",
+ inx,
+ layers[inx].visible,
+ layers[inx].frozen,
+ layers[inx].onMap,
+ wDrawGetRGB(layers[inx].color),
+ layers[inx].module,
+ layers[inx].useColor ? 0 : 1,
+ ColorFlags,
+ layers[inx].button_off,
+ PutTitle(layers[inx].name),
+ layers[inx].inherit,
+ layers[inx].scaleInx,
+ layers[inx].minTrackRadius,
+ layers[inx].maxTrackGrade,
+ layers[inx].tieData.length,
+ layers[inx].tieData.width,
+ layers[inx].tieData.spacing
+ );
+ }
+ }
+
+ fprintf(f, "LAYERS CURRENT %u\n", curLayer);
+
+ for (inx = 0; inx < NUM_LAYERS; inx++) {
+ unsigned int layerInx = inx;
+ GetLayerLinkString(inx, layerLinkList);
+ if (IsLayerConfigured(inx) && strlen(layerLinkList) > 0) {
+ fprintf(f, "LAYERS LINK %u \"%s\"\n", layerInx, layerLinkList);
+ }
+ if (IsLayerConfigured(inx) && layers[inx].settingsName[0]) {
+ fprintf(f, "LAYERS SET %u \"%s\"\n", layerInx, layers[inx].settingsName);
+ }
+ }
+ return TRUE;
+}
+
+/*****************************************************************************
+*
+* DIALOG & MENU
+*
+*/
+
+/**
+* This function is called when the Done button on the layer dialog is pressed. It hides the layer dialog and
+* updates the layer information.
+*
+* \param IN ignored
+*
+*/
+static void LayerOk(void * unused)
+{
+ LayerSelect(layerSelected);
+
+ if (newLayerCount != layerCount) {
+ layoutLayerChanged = TRUE;
+
+ if (newLayerCount > NUM_BUTTONS) {
+ newLayerCount = NUM_BUTTONS;
+ }
+
+ layerCount = newLayerCount;
+ }
+
+ if (layoutLayerChanged) {
+ MainProc(mainW, wResize_e, NULL, NULL);
+ }
+
+ wHide(layerW);
+}
+
+
+static void LayerDlgUpdate(
+ paramGroup_p pg,
+ int inx,
+ void * valueP)
+{
+ switch (inx) {
+ case I_LIST:
+ LayerSelect((wIndex_t) * (long*)valueP);
+ break;
+
+ case I_NAME:
+ LayerUpdate();
+ break;
+
+ case I_MAP:
+ layerRedrawMap = TRUE;
+ /* No Break */
+ case I_VIS:
+ case I_FRZ:
+ case I_MOD:
+ case I_BUT:
+ case I_DEF:
+ LayerUpdate();
+ UpdateLayerDlg(layerSelected);
+ break;
+
+ case I_SCALE:
+ LoadGaugeList((wList_p)layerPLs[I_GAUGE].control, *((int *)valueP));
+ // set the first entry as default, usually the standard gauge for a scale
+ wListSetIndex((wList_p)layerPLs[I_GAUGE].control, 0);
+ break;
+
+ case I_TIELEN:
+ case I_TIEWID:
+ case I_TIESPC:
+ ValidateTieData(&layerTieData);
+ r_tieData.rangechecks = layerTieData.valid ? PDO_NORANGECHECK_LOW |
+ PDO_NORANGECHECK_HIGH : 0;
+ break;
+
+ case I_SETTINGS:
+ if (strcmp((char*)wListGetItemContext(settingsListL,
+ (wIndex_t) * (long*)valueP), " ") == 0) {
+ settingsName[0] = '\0';
+ } else {
+ strcpy(settingsName, (char*)wListGetItemContext(settingsListL,
+ (wIndex_t) * (long*)valueP));
+ }
+ break;
+ }
+}
+
+
+static void DoLayer(void * unused)
+{
+ if (layerW == NULL) {
+ layerW = ParamCreateDialog(&layerPG, MakeWindowTitle(_("Layers")), _("Done"),
+ LayerOk, wHide, TRUE, NULL, 0, LayerDlgUpdate);
+ GetScaleGauge(layerScaleInx, &layerScaleDescInx, &layerGaugeInx);
+ LoadScaleList(scaleL);
+ LoadGaugeList(gaugeL, layerScaleDescInx);
+ }
+
+ if (settingsCatalog) { CatalogDiscard(settingsCatalog); }
+ else { settingsCatalog = InitCatalog(); }
+ ScanSettingsDirectory(settingsCatalog, wGetAppWorkDir());
+
+
+ /* set the globals to the values for the current layer */
+ UpdateLayerDlg(curLayer);
+ layerRedrawMap = FALSE;
+ wShow(layerW);
+ layoutLayerChanged = FALSE;
+}
+
+#include "bitmaps/background.xpm3"
+
+#if NUM_BUTTONS < 100
+static int lbmap_width[3] = { 16, 24, 32 }; // For numbers < 100
+#else
+static int lbmap_width[3] = { 20, 28, 36 }; // For numbers > 99
+#endif
+static int lbmap_height[3] = { 16, 24, 32 };
+
+static int lbit0_width[3] = { 6, 10, 14 };
+static int lbit1_width[3] = { 4, 5, 6 };
+
+static int lbits_top[3] = { 3, 4, 6 };
+static int lbits_height[3] = { 10, 15, 20 };
+
+#include "bitmaps/layer_num.inc"
+
+static char** show_layer_digits[3][10] = {
+ {
+ n0_x16, n1_x16, n2_x16, n3_x16, n4_x16, n5_x16, n6_x16, n7_x16, n8_x16, n9_x16
+ },
+ {
+ n0_x24, n1_x24, n2_x24, n3_x24, n4_x24, n5_x24, n6_x24, n7_x24, n8_x24, n9_x24
+ },
+ {
+ n0_x32, n1_x32, n2_x32, n3_x32, n4_x32, n5_x32, n6_x32, n7_x32, n8_x32, n9_x32
+ }
+};
+
+/* Note: If the number of buttons is increased to > ~120, you should
+ * also increase COMMAND_MAX and BUTTON_MAX in command.c
+ * NUM_LAYERS is defined in common.h
+ */
+#define ONE_PIXEL v *= 2; if (v > 128) { show_layer_bits[xx + yy] = b; xx += 1; v = 1; b = 0; }
+
+void InitLayers(void)
+{
+ unsigned int i;
+ wPrefGetInteger(PREFSECT, "layer-button-count", &layerCount, layerCount);
+
+ for (i = 0; i < COUNT(layerRawColorTab); i++) {
+ layerColorTab[i] = wDrawFindColor(layerRawColorTab[i]);
+ }
+
+ /* build the adjust table for starting bit */
+ int dx_table[] = { 1, 2, 4, 8, 16, 32, 64, 128 };
+
+ /* create the bitmaps for the layer buttons */
+ /* all bitmaps have to have the same dimensions */
+ for (int i = 0; i < NUM_LAYERS; i++) {
+ int n = i + 1;
+ int bwid = lbmap_width[iconSize];
+ int wb = (bwid + 7) / 8; // width in bytes
+ int bhgt = lbmap_height[iconSize];
+ int h = lbits_height[iconSize];
+
+ // if (n > 30) n = n + 70; for testing > 100
+
+ show_layer_bits = MyMalloc(bhgt * wb);
+
+ if (n < 10) {
+ // width of char
+ int wc = 0; // width of char
+ if (n == 1) {
+ wc = lbit1_width[iconSize];
+ } else {
+ wc = lbit0_width[iconSize];
+ }
+
+ // X-adjust
+ int dx = (bwid - wc) / 2;
+ int x0 = 0;
+ if (dx > 7) {
+ dx -= 8;
+ x0++;
+ }
+
+ char** cp = show_layer_digits[iconSize][n];
+
+ for (int y = 0; y < h; y++) {
+ int v = dx_table[dx]; // power of two
+ char b = 0; // bits
+
+ int yy = wb * (y + (bhgt - h) / 2);
+
+ int xx = x0; // starting byte
+ for (int x = 0; x < wc; x++) {
+ char z = *(*cp + x + y * wc);
+ if (z != ' ') {
+ b |= v;
+ }
+ ONE_PIXEL
+ }
+ if (v <= 128) {
+ show_layer_bits[xx + yy] = b;
+ }
+ }
+
+ } else if (n < 100) {
+ // width of chars
+ int wc1 = 0;
+ int wc0 = 0;
+ if ((n / 10) == 1) {
+ wc1 = lbit1_width[iconSize];
+ } else {
+ wc1 = lbit0_width[iconSize];
+ }
+ if ((n % 10) == 1) {
+ wc0 = lbit1_width[iconSize];
+ } else {
+ wc0 = lbit0_width[iconSize];
+ }
+
+ // X-adjust
+ int dx = (bwid - wc1 - wc0 - (iconSize >= 1 ? 2 : 1)) / 2;
+ int x0 = 0;
+ if (dx > 7) {
+ dx -= 8;
+ x0++;
+ }
+
+ char** cp1 = show_layer_digits[iconSize][n / 10];
+ char** cp0 = show_layer_digits[iconSize][n % 10];
+
+ for (int y = 0; y < h; y++) {
+ int v = dx_table[dx]; // powers of two
+ char b = 0; // bits
+
+ int yy = wb * (y + (bhgt - h) / 2);
+
+ int xx = x0; // starting byte
+ for (int x = 0; x < wc1; x++) {
+ char z = *(*cp1 + x + y * wc1);
+ if (z != ' ') {
+ b |= v;
+ }
+ ONE_PIXEL
+ }
+ ONE_PIXEL
+ if (iconSize >= 1) {
+ ONE_PIXEL
+ }
+ for (int x = 0; x < wc0; x++) {
+ char z = *(*cp0 + x + y * wc0);
+ if (z != ' ') {
+ b |= v;
+ }
+ ONE_PIXEL
+ }
+ if (v <= 128) {
+ show_layer_bits[xx + yy] = b;
+ }
+ }
+
+ } else { // n >= 100
+ // width of chars
+ int wc2 = 0;
+ int wc1 = 0;
+ int wc0 = 0;
+ if ((n / 100) == 1) {
+ wc2 = lbit1_width[iconSize];
+ } else {
+ wc2 = lbit0_width[iconSize];
+ }
+ if (((n / 10) % 10) == 1) {
+ wc1 = lbit1_width[iconSize];
+ } else {
+ wc1 = lbit0_width[iconSize];
+ }
+ if ((n % 10) == 1) {
+ wc0 = lbit1_width[iconSize];
+ } else {
+ wc0 = lbit0_width[iconSize];
+ }
+
+ // X-adjust and start
+ int dx = (bwid - wc2 - wc1 - wc0 - 2) / 2;
+ int x0 = 0;
+ if (dx > 7) {
+ dx -= 8;
+ x0++;
+ }
+
+ char** cp2 = show_layer_digits[iconSize][n / 100];
+ char** cp1 = show_layer_digits[iconSize][(n / 10) % 10];
+ char** cp0 = show_layer_digits[iconSize][n % 10];
+
+ for (int y = 0; y < h; y++) {
+ int v = dx_table[dx]; // powers of two
+ char b = 0; // bits
+
+ int yy = wb * (y + (bhgt - h) / 2);
+
+ int xx = x0; // byte
+ for (int x = 0; x < wc2; x++) {
+ char z = *(*cp2 + x + y * wc2);
+ if (z != ' ') {
+ b |= v;
+ }
+ ONE_PIXEL
+ }
+ ONE_PIXEL
+ for (int x = 0; x < wc1; x++) {
+ char z = *(*cp1 + x + y * wc1);
+ if (z != ' ') {
+ b |= v;
+ }
+ ONE_PIXEL
+ }
+ ONE_PIXEL
+ for (int x = 0; x < wc0; x++) {
+ char z = *(*cp0 + x + y * wc0);
+ if (z != ' ') {
+ b |= v;
+ }
+ ONE_PIXEL
+ }
+ if (v <= 128) {
+ show_layer_bits[xx + yy] = b;
+ }
+ }
+ }
+
+ show_layer_bmps[i] = wIconCreateBitMap(
+ bwid,
+ bhgt,
+ show_layer_bits,
+ layerColorTab[i % (COUNT(layerColorTab))]);
+ layers[i].color = layerColorTab[i % (COUNT(layerColorTab))];
+ layers[i].useColor = TRUE;
+
+ MyFree(show_layer_bits);
+ }
+
+ /* layer list for toolbar */
+ setLayerL = wDropListCreate(mainW, 0, 0, "cmdLayerSet", NULL, 0, 10, 200, NULL,
+ SetCurrLayer, NULL);
+ wControlSetBalloonText((wControl_p)setLayerL, GetBalloonHelpStr("cmdLayerSet"));
+ AddToolbarControl((wControl_p)setLayerL, IC_MODETRAIN_TOO);
+
+ backgroundB = AddToolbarButton("cmdBackgroundShow",
+ wIconCreatePixMap(background_xpm3[iconSize]), 0,
+ BackgroundToggleShow, NULL);
+ /* add the help text */
+ wControlSetBalloonText((wControl_p)backgroundB, _("Show/Hide Background"));
+ wControlActive((wControl_p)backgroundB, FALSE);
+
+ for (int i = 0; i < NUM_LAYERS; i++) {
+ char *layerName;
+
+ if (i < NUM_BUTTONS) {
+ /* create the layer button */
+ sprintf(message, "cmdLayerShow%u", i);
+ layer_btns[i] = AddToolbarButton(message, show_layer_bmps[i], IC_MODETRAIN_TOO,
+ FlipLayer, I2VP(i) );
+ /* set state of button */
+ wButtonSetBusy(layer_btns[i], 1);
+ }
+
+ layerName = FormatLayerName(i);
+ wListAddValue(setLayerL, layerName, NULL, I2VP(i));
+ free(layerName);
+ }
+
+ AddPlaybackProc("SETCURRLAYER", PlaybackCurrLayer, NULL);
+ AddPlaybackProc("LAYERS", (playbackProc_p)ReadLayers, NULL);
+}
+
+addButtonCallBack_t InitLayersDialog(void)
+{
+ ParamRegister(&layerPG);
+ RegisterChangeNotification(LayerChange);
+ return &DoLayer;
+}
diff --git a/app/bin/dlayer.h b/app/bin/dlayer.h new file mode 100644 index 0000000..bc67063 --- /dev/null +++ b/app/bin/dlayer.h @@ -0,0 +1,69 @@ + +/** \file dlayer.h + * + */ + +/* XTrkCad - Model Railroad CAD + * Copyright (C) 2005 Dave Bullis + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef DLAYER_H +#define DLAYER_H + +#include "common.h" +extern unsigned int curLayer; +extern long layerCount; +void SetCurrLayer(wIndex_t inx, const char * name, wIndex_t op, + void * listContext, void * arg); +wDrawColor GetLayerColor( unsigned int ); +BOOL_T GetLayerUseDefault( unsigned int ); +SCALEINX_T GetLayerScale( unsigned int ); +BOOL_T GetLayerUseColor( unsigned int); +BOOL_T GetLayerVisible( unsigned int ); +void FlipLayer( void * layerVP ); +BOOL_T GetLayerFrozen( unsigned int ); +BOOL_T GetLayerOnMap( unsigned int ); +BOOL_T GetLayerModule( unsigned int ); +BOOL_T GetLayerHidden( unsigned int); +tieData_t GetLayerTieData( unsigned int ); +DIST_T GetLayerMinTrackRadius( unsigned int layer ); +ANGLE_T GetLayerMaxTrackGrade( unsigned int layer ); +void SetLayerModule(unsigned int, BOOL_T); +char * GetLayerName( unsigned int ); +void SetLayerName(unsigned int layer, char* name); +BOOL_T ReadLayers( char * ); +BOOL_T WriteLayers( FILE * ); +char * FormatLayerName(unsigned int layerNumber); +// void UpdateLayerLists( void ); +void DefaultLayerProperties(void); +void UpdateLayerDlg( unsigned int ); +void ResetLayers( void ); +void SaveLayers( void ); +void RestoreLayers( void ); +void LoadLayerLists( void ); +addButtonCallBack_t InitLayersDialog( void ); +addButtonCallBack_t InitDrawOrderDialog( void ); +void FillLayerList(wList_p layerList); + +void LayerAllDefaults(); +void LayerSetCounts(); +int FindUnusedLayer(unsigned int start); +void DecrementLayerObjects(unsigned int index); +void IncrementLayerObjects(unsigned int index); + + +#endif diff --git a/app/bin/doption.c b/app/bin/doption.c index d196558..28010d4 100644 --- a/app/bin/doption.c +++ b/app/bin/doption.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "ccurve.h" @@ -26,8 +26,9 @@ #include "param.h" #include "track.h" #include "common-ui.h" +#include "ctrain.h" -static paramIntegerRange_t i1_64 = { 1, 64 }; +//static paramIntegerRange_t i1_64 = { 1, 64 }; static paramIntegerRange_t i1_100 = { 1, 100 }; static paramIntegerRange_t i0_256 = { 0, 256 }; static paramIntegerRange_t i1_256 = { 1, 256 }; @@ -59,8 +60,9 @@ long GetChanges( paramGroup_p pg ) long changed; int inx; for ( changed=ParamUpdate(pg),inx=0,changes=0; changed; changed>>=1,inx++ ) { - if ( changed&1 ) + if ( changed&1 ) { changes |= VP2L(pg->paramPtr[inx].context); + } } return changes; } @@ -72,7 +74,7 @@ static paramGroup_t prefPG; static void OptionDlgCancel( - wWin_p win ) + wWin_p win ) { wEnableBalloonHelp( (int)enableBalloonHelp ); wHide( win ); @@ -103,9 +105,6 @@ static char * hideTrainsInTunnelsLabels[] = { N_("Hide Trains On Hidden Track"), static char * constrainMainLabels[] = {N_("Constrain Drawing Area to Room boundaries"), NULL}; static char * dontHideLabels[] = {N_("Don't Hide System Cursor when program cursor is active"), NULL}; -extern long trainPause; - - static paramData_t displayPLs[] = { { PD_RADIO, &colorTrack, "color-track", PDO_NOPSHUPD|PDO_DRAW, colorTrackLabels, N_("Color Track"), BC_HORZ, I2VP(CHANGE_MAIN) }, @@ -116,24 +115,24 @@ static paramData_t displayPLs[] = { { PD_RADIO, &tieDrawMode, "tiedraw", PDO_NOPSHUPD|PDO_DRAW, tiedrawLabels, N_("Draw Ties"), BC_HORZ, I2VP(CHANGE_MAIN) }, { PD_RADIO, ¢erDrawMode, "centerdraw", PDO_NOPSHUPD|PDO_DRAW, drawCenterCircle, N_("Draw Centers"), BC_HORZ, I2VP(CHANGE_MAIN | CHANGE_MAP) }, { PD_LONG, &twoRailScale, "tworailscale", PDO_NOPSHUPD, &i1_256, N_("Two Rail Scale"), 0, I2VP(CHANGE_MAIN) }, - { PD_LONG, &mapScale, "mapscale", PDO_NOPSHUPD, &i1_1024, N_("Map Scale"), 0, I2VP(CHANGE_MAP) }, + { PD_FLOAT, &mapD.scale, "mapscale", PDO_NOPSHUPD, &r1_1000, N_("Map Scale"), 0, I2VP(CHANGE_MAP) }, { PD_TOGGLE, &dontHideCursor, "donthidecursor", PDO_NOPSHUPD, dontHideLabels, "", BC_HORZ }, { PD_TOGGLE, &constrainMain, "constrainmain", PDO_NOPSHUPD, constrainMainLabels, "", BC_HORZ }, { PD_TOGGLE, &liveMap, "livemap", PDO_NOPSHUPD, liveMapLabels, "", BC_HORZ }, { PD_TOGGLE, &autoPan, "autoPan", PDO_NOPSHUPD, autoPanLabels, "", BC_HORZ }, -#define labelSelect (12) +#define labelSelect (13) { PD_TOGGLE, &labelEnable, "labelenable", PDO_NOPSHUPD, labelEnableLabels, N_("Label Enable"), 0, I2VP(CHANGE_MAIN) }, { PD_LONG, &labelScale, "labelscale", PDO_NOPSHUPD, &i0_256, N_("Label Scale"), 0, I2VP(CHANGE_MAIN) }, { PD_LONG, &descriptionFontSize, "description-fontsize", PDO_NOPSHUPD, &i1_1000, N_("Label Font Size"), 0, I2VP(CHANGE_MAIN) }, { PD_TOGGLE, &hotBarLabels, "hotbarlabels", PDO_NOPSHUPD, hotBarLabelsLabels, N_("Hot Bar Labels"), BC_HORZ, I2VP(CHANGE_TOOLBAR) }, { PD_TOGGLE, &layoutLabels, "layoutlabels", PDO_NOPSHUPD, listLabelsLabels, N_("Layout Labels"), BC_HORZ, I2VP(CHANGE_MAIN) }, { PD_TOGGLE, &listLabels, "listlabels", PDO_NOPSHUPD, listLabelsLabels, N_("List Labels"), BC_HORZ, I2VP(CHANGE_PARAMS) }, -/* ATTENTION: update the define below if you add entries above */ + /* ATTENTION: update the define below if you add entries above */ #define I_HOTBARLABELS (19) { PD_DROPLIST, &carHotbarModeInx, "carhotbarlabels", PDO_NOPSHUPD|PDO_DLGUNDERCMDBUTT|PDO_LISTINDEX, I2VP(250), N_("Car Labels"), 0, I2VP(CHANGE_SCALE) }, - { PD_LONG, &trainPause, "trainpause", PDO_NOPSHUPD, &i10_1000 , N_("Train Update Delay"), 0, 0 }, + { PD_LONG, &trainPause, "trainpause", PDO_NOPSHUPD, &i10_1000, N_("Train Update Delay"), 0, 0 }, { PD_TOGGLE, &hideTrainsInTunnels, "hideTrainsInTunnels", PDO_NOPSHUPD, hideTrainsInTunnelsLabels, "", BC_HORZ } - }; +}; static paramGroup_t displayPG = { "display", PGO_RECORD|PGO_PREFMISC, displayPLs, COUNT( displayPLs ) }; @@ -147,11 +146,11 @@ static void DisplayOk( void * junk ) static void OptionDlgUpdate( - paramGroup_p pg, - int inx, - void * valueP ) + paramGroup_p pg, + int inx, + void * valueP ) { - if ( inx < 0 ) return; + if ( inx < 0 ) { return; } if ( pg->paramPtr[inx].valueP == &enableBalloonHelp ) { wEnableBalloonHelp((wBool_t)*(long*)valueP); } else { @@ -173,7 +172,8 @@ static void OptionDlgUpdate( checkPtInterval = *(long *)valueP; if (checkPtInterval == 0 ) { wWinPix_t h = wControlGetHeight(pg->paramPtr[inx].control); - wControlSetBalloon( pg->paramPtr[inx].control, 0, h*3/4, _("Turning off AutoSave") ); + wControlSetBalloon( pg->paramPtr[inx].control, 0, h*3/4, + _("Turning off AutoSave") ); UpdateAutoSaveInterval(0); } else { wControlSetBalloon( pg->paramPtr[inx].control, 0, 0, NULL ); @@ -183,7 +183,8 @@ static void OptionDlgUpdate( autosaveChkPoints = *(long *)valueP; if (checkPtInterval == 0 && autosaveChkPoints>0 ) { wWinPix_t h = wControlGetHeight(pg->paramPtr[inx].control); - wControlSetBalloon( pg->paramPtr[inx].control, 0, -h*3/4, _("Turning on CheckPointing") ); + wControlSetBalloon( pg->paramPtr[inx].control, 0, -h*3/4, + _("Turning on CheckPointing") ); UpdateChkPtInterval(10); } else { wControlSetBalloon( pg->paramPtr[inx].control, 0, 0, NULL ); @@ -197,14 +198,22 @@ static void OptionDlgUpdate( static void DoDisplay( void * junk ) { if (displayW == NULL) { - displayW = ParamCreateDialog( &displayPG, MakeWindowTitle(_("Display Options")), _("Ok"), DisplayOk, OptionDlgCancel, TRUE, NULL, 0, OptionDlgUpdate ); - wListAddValue( (wList_p)displayPLs[I_HOTBARLABELS].control, _("Proto"), NULL, I2VP(0x0002) ); - wListAddValue( (wList_p)displayPLs[I_HOTBARLABELS].control, _("Proto/Manuf"), NULL, I2VP(0x0012) ); - wListAddValue( (wList_p)displayPLs[I_HOTBARLABELS].control, _("Proto/Manuf/Part Number"), NULL, I2VP(0x0312) ); - wListAddValue( (wList_p)displayPLs[I_HOTBARLABELS].control, _("Proto/Manuf/Partno/Item"), NULL, I2VP(0x4312) ); - wListAddValue( (wList_p)displayPLs[I_HOTBARLABELS].control, _("Manuf/Proto"), NULL, I2VP(0x0021) ); - wListAddValue( (wList_p)displayPLs[I_HOTBARLABELS].control, _("Manuf/Proto/Part Number"), NULL, I2VP(0x0321) ); - wListAddValue( (wList_p)displayPLs[I_HOTBARLABELS].control, _("Manuf/Proto/Partno/Item"), NULL, I2VP(0x4321) ); + displayW = ParamCreateDialog( &displayPG, MakeWindowTitle(_("Display Options")), + _("Ok"), DisplayOk, OptionDlgCancel, TRUE, NULL, 0, OptionDlgUpdate ); + wListAddValue( (wList_p)displayPLs[I_HOTBARLABELS].control, _("Proto"), NULL, + I2VP(0x0002) ); + wListAddValue( (wList_p)displayPLs[I_HOTBARLABELS].control, _("Proto/Manuf"), + NULL, I2VP(0x0012) ); + wListAddValue( (wList_p)displayPLs[I_HOTBARLABELS].control, + _("Proto/Manuf/Part Number"), NULL, I2VP(0x0312) ); + wListAddValue( (wList_p)displayPLs[I_HOTBARLABELS].control, + _("Proto/Manuf/Partno/Item"), NULL, I2VP(0x4312) ); + wListAddValue( (wList_p)displayPLs[I_HOTBARLABELS].control, _("Manuf/Proto"), + NULL, I2VP(0x0021) ); + wListAddValue( (wList_p)displayPLs[I_HOTBARLABELS].control, + _("Manuf/Proto/Part Number"), NULL, I2VP(0x0321) ); + wListAddValue( (wList_p)displayPLs[I_HOTBARLABELS].control, + _("Manuf/Proto/Partno/Item"), NULL, I2VP(0x4321) ); } ParamLoadControls( &displayPG ); @@ -242,7 +251,7 @@ static char * hideSelectionWindowLabels[] = { N_("Hide"), NULL }; #endif static char * rightClickLabels[] = {N_("Normal: Command List, Shift: Command Options"), N_("Normal: Command Options, Shift: Command List"), NULL }; -EXPORT paramData_t cmdoptPLs[] = { +static paramData_t cmdoptPLs[] = { { PD_RADIO, &preSelect, "preselect", PDO_NOPSHUPD, preSelectLabels, N_("Default Command"), BC_HORZ }, #ifdef HIDESELECTIONWINDOW { PD_TOGGLE, &hideSelectionWindow, PDO_NOPSHUPD, hideSelectionWindowLabels, N_("Hide Selection Window"), BC_HORZ }, @@ -250,7 +259,7 @@ EXPORT paramData_t cmdoptPLs[] = { { PD_RADIO, &rightClickMode, "rightclickmode", PDO_NOPSHUPD, rightClickLabels, N_("Right Click"), 0 }, { PD_RADIO, &selectMode, "selectmode", PDO_NOPSHUPD, selectLabels, N_("Select Mode"), 0}, { PD_TOGGLE, &selectZero, "selectzero", PDO_NOPSHUPD, selectZeroLabels, "", 0 } - }; +}; static paramGroup_t cmdoptPG = { "cmdopt", PGO_RECORD|PGO_PREFMISC, cmdoptPLs, COUNT( cmdoptPLs ) }; static void CmdoptOk( void * junk ) @@ -265,15 +274,17 @@ static void CmdoptOk( void * junk ) static void CmdoptChange( long changes ) { if (changes & CHANGE_CMDOPT) - if (cmdoptW != NULL && wWinIsVisible(cmdoptW) ) + if (cmdoptW != NULL && wWinIsVisible(cmdoptW) ) { ParamLoadControls( &cmdoptPG ); + } } static void DoCmdopt( void * junk ) { if (cmdoptW == NULL) { - cmdoptW = ParamCreateDialog( &cmdoptPG, MakeWindowTitle(_("Command Options")), _("Ok"), CmdoptOk, OptionDlgCancel, TRUE, NULL, 0, OptionDlgUpdate ); + cmdoptW = ParamCreateDialog( &cmdoptPG, MakeWindowTitle(_("Command Options")), + _("Ok"), CmdoptOk, OptionDlgCancel, TRUE, NULL, 0, OptionDlgUpdate ); } ParamLoadControls( &cmdoptPG ); wShow( cmdoptW ); @@ -306,6 +317,7 @@ static char * startOptions[] = { N_("Load Last Layout"), N_("Start New Layout"), static paramData_t prefPLs[] = { { PD_RADIO, &iconSize, "iconsize", PDO_NOPSHUPD, iconSizeLabels, N_("Icon Size"), BC_HORZ, I2VP(CHANGE_ICONSIZE) }, { PD_RADIO, &angleSystem, "anglesystem", PDO_NOPSHUPD, angleSystemLabels, N_("Angles"), BC_HORZ }, +#define I_UNITS (2) { PD_RADIO, &units, "units", PDO_NOPSHUPD|PDO_NOUPDACT, unitsLabels, N_("Units"), BC_HORZ, I2VP(CHANGE_MAIN|CHANGE_UNITS) }, #define I_DSTFMT (3) { PD_DROPLIST, &distanceFormatInx, "dstfmt", PDO_DIM|PDO_NOPSHUPD|PDO_LISTINDEX, I2VP(150), N_("Length Format"), 0, I2VP(CHANGE_MAIN|CHANGE_UNITS) }, @@ -324,54 +336,56 @@ static paramData_t prefPLs[] = { #define I_AUTOSAVE (15) { PD_LONG, &autosaveChkPoints, "autosave", PDO_NOPSHUPD|PDO_FILE, &i0_99, N_("Autosave Checkpoint Frequency") }, { PD_RADIO, &onStartup, "onstartup", PDO_NOPSHUPD, startOptions, N_("On Program Startup"), 0, NULL } - }; +}; static paramGroup_t prefPG = { "pref", PGO_RECORD|PGO_PREFMISC, prefPLs, COUNT( prefPLs ) }; typedef struct { - char * name; - long fmt; - } dstFmts_t; + char * name; + long fmt; +} dstFmts_t; static dstFmts_t englishDstFmts[] = { - { N_("999.999"), DISTFMT_FMT_NONE|DISTFMT_FRACT_NUM|3 }, - { N_("999.999999"), DISTFMT_FMT_NONE|DISTFMT_FRACT_NUM|6 }, - { N_("999.99999"), DISTFMT_FMT_NONE|DISTFMT_FRACT_NUM|5 }, - { N_("999.9999"), DISTFMT_FMT_NONE|DISTFMT_FRACT_NUM|4 }, - { N_("999.999"), DISTFMT_FMT_NONE|DISTFMT_FRACT_NUM|3 }, - { N_("999.99"), DISTFMT_FMT_NONE|DISTFMT_FRACT_NUM|2 }, - { N_("999.9"), DISTFMT_FMT_NONE|DISTFMT_FRACT_NUM|1 }, - { N_("999 7/8"), DISTFMT_FMT_NONE|DISTFMT_FRACT_FRC|3 }, - { N_("999 63/64"), DISTFMT_FMT_NONE|DISTFMT_FRACT_FRC|6 }, - { N_("999' 11.999\""), DISTFMT_FMT_SHRT|DISTFMT_FRACT_NUM|3 }, - { N_("999' 11.99\""), DISTFMT_FMT_SHRT|DISTFMT_FRACT_NUM|2 }, - { N_("999' 11.9\""), DISTFMT_FMT_SHRT|DISTFMT_FRACT_NUM|1 }, - { N_("999' 11 7/8\""), DISTFMT_FMT_SHRT|DISTFMT_FRACT_FRC|3 }, - { N_("999' 11 63/64\""), DISTFMT_FMT_SHRT|DISTFMT_FRACT_FRC|6 }, - { N_("999ft 11.999in"), DISTFMT_FMT_LONG|DISTFMT_FRACT_NUM|3 }, - { N_("999ft 11.99in"), DISTFMT_FMT_LONG|DISTFMT_FRACT_NUM|2 }, - { N_("999ft 11.9in"), DISTFMT_FMT_LONG|DISTFMT_FRACT_NUM|1 }, - { N_("999ft 11 7/8in"), DISTFMT_FMT_LONG|DISTFMT_FRACT_FRC|3 }, - { N_("999ft 11 63/64in"), DISTFMT_FMT_LONG|DISTFMT_FRACT_FRC|6 }, - { NULL, 0 } }; + { N_("999.999"), DISTFMT_FMT_NONE|DISTFMT_FRACT_NUM|3 }, + { N_("999.999999"), DISTFMT_FMT_NONE|DISTFMT_FRACT_NUM|6 }, + { N_("999.99999"), DISTFMT_FMT_NONE|DISTFMT_FRACT_NUM|5 }, + { N_("999.9999"), DISTFMT_FMT_NONE|DISTFMT_FRACT_NUM|4 }, + { N_("999.999"), DISTFMT_FMT_NONE|DISTFMT_FRACT_NUM|3 }, + { N_("999.99"), DISTFMT_FMT_NONE|DISTFMT_FRACT_NUM|2 }, + { N_("999.9"), DISTFMT_FMT_NONE|DISTFMT_FRACT_NUM|1 }, + { N_("999 7/8"), DISTFMT_FMT_NONE|DISTFMT_FRACT_FRC|3 }, + { N_("999 63/64"), DISTFMT_FMT_NONE|DISTFMT_FRACT_FRC|6 }, + { N_("999' 11.999\""), DISTFMT_FMT_SHRT|DISTFMT_FRACT_NUM|3 }, + { N_("999' 11.99\""), DISTFMT_FMT_SHRT|DISTFMT_FRACT_NUM|2 }, + { N_("999' 11.9\""), DISTFMT_FMT_SHRT|DISTFMT_FRACT_NUM|1 }, + { N_("999' 11 7/8\""), DISTFMT_FMT_SHRT|DISTFMT_FRACT_FRC|3 }, + { N_("999' 11 63/64\""), DISTFMT_FMT_SHRT|DISTFMT_FRACT_FRC|6 }, + { N_("999ft 11.999in"), DISTFMT_FMT_LONG|DISTFMT_FRACT_NUM|3 }, + { N_("999ft 11.99in"), DISTFMT_FMT_LONG|DISTFMT_FRACT_NUM|2 }, + { N_("999ft 11.9in"), DISTFMT_FMT_LONG|DISTFMT_FRACT_NUM|1 }, + { N_("999ft 11 7/8in"), DISTFMT_FMT_LONG|DISTFMT_FRACT_FRC|3 }, + { N_("999ft 11 63/64in"), DISTFMT_FMT_LONG|DISTFMT_FRACT_FRC|6 }, + { NULL, 0 } +}; static dstFmts_t metricDstFmts[] = { - { N_("999.999"), DISTFMT_FMT_NONE|DISTFMT_FRACT_NUM|3 }, - { N_("999.99"), DISTFMT_FMT_NONE|DISTFMT_FRACT_NUM|2 }, - { N_("999.9"), DISTFMT_FMT_NONE|DISTFMT_FRACT_NUM|1 }, - { N_("999.999mm"), DISTFMT_FMT_MM|DISTFMT_FRACT_NUM|3 }, - { N_("999.99mm"), DISTFMT_FMT_MM|DISTFMT_FRACT_NUM|2 }, - { N_("999.9mm"), DISTFMT_FMT_MM|DISTFMT_FRACT_NUM|1 }, - { N_("999.999cm"), DISTFMT_FMT_CM|DISTFMT_FRACT_NUM|3 }, - { N_("999.99cm"), DISTFMT_FMT_CM|DISTFMT_FRACT_NUM|2 }, - { N_("999.9cm"), DISTFMT_FMT_CM|DISTFMT_FRACT_NUM|1 }, - { N_("999.999m"), DISTFMT_FMT_M|DISTFMT_FRACT_NUM|3 }, - { N_("999.99m"), DISTFMT_FMT_M|DISTFMT_FRACT_NUM|2 }, - { N_("999.9m"), DISTFMT_FMT_M|DISTFMT_FRACT_NUM|1 }, - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 } }; + { N_("999.999"), DISTFMT_FMT_NONE|DISTFMT_FRACT_NUM|3 }, + { N_("999.99"), DISTFMT_FMT_NONE|DISTFMT_FRACT_NUM|2 }, + { N_("999.9"), DISTFMT_FMT_NONE|DISTFMT_FRACT_NUM|1 }, + { N_("999.999mm"), DISTFMT_FMT_MM|DISTFMT_FRACT_NUM|3 }, + { N_("999.99mm"), DISTFMT_FMT_MM|DISTFMT_FRACT_NUM|2 }, + { N_("999.9mm"), DISTFMT_FMT_MM|DISTFMT_FRACT_NUM|1 }, + { N_("999.999cm"), DISTFMT_FMT_CM|DISTFMT_FRACT_NUM|3 }, + { N_("999.99cm"), DISTFMT_FMT_CM|DISTFMT_FRACT_NUM|2 }, + { N_("999.9cm"), DISTFMT_FMT_CM|DISTFMT_FRACT_NUM|1 }, + { N_("999.999m"), DISTFMT_FMT_M|DISTFMT_FRACT_NUM|3 }, + { N_("999.99m"), DISTFMT_FMT_M|DISTFMT_FRACT_NUM|2 }, + { N_("999.9m"), DISTFMT_FMT_M|DISTFMT_FRACT_NUM|1 }, + { NULL, 0 }, + { NULL, 0 }, + { NULL, 0 }, + { NULL, 0 }, + { NULL, 0 }, + { NULL, 0 } +}; static dstFmts_t *dstFmts[] = { englishDstFmts, metricDstFmts }; void UpdateAutoSaveInterval(long value) @@ -390,19 +404,21 @@ void UpdateChkPtInterval(long value) /** * Load the selection list for number formats with the appropriate list of variants. - */ - + */ + static void LoadDstFmtList( void ) { int inx; wListClear( (wList_p)prefPLs[I_DSTFMT].control ); - for ( inx=0; dstFmts[units][inx].name; inx++ ) - wListAddValue( (wList_p)prefPLs[I_DSTFMT].control, _(dstFmts[units][inx].name), NULL, I2VP(dstFmts[units][inx].fmt) ); + for ( inx=0; dstFmts[units][inx].name; inx++ ) { + wListAddValue( (wList_p)prefPLs[I_DSTFMT].control, _(dstFmts[units][inx].name), + NULL, I2VP(dstFmts[units][inx].fmt) ); + } } /** -* Handle changing of measurement system. The list of number formats is loaded -* and the first entry is selected as default value. +* Handle changing of measurement system. The list of number formats is loaded +* and the first entry is selected as default value. */ static void UpdatePrefD( void ) @@ -410,9 +426,11 @@ static void UpdatePrefD( void ) long newUnits, oldUnits; int inx; - if ( prefW==NULL || (!wWinIsVisible(prefW)) || prefPLs[1].control==NULL ) + if ( prefW==NULL || (!wWinIsVisible(prefW)) + || prefPLs[I_UNITS].control==NULL ) { return; - newUnits = wRadioGetValue( (wChoice_p)prefPLs[1].control ); + } + newUnits = wRadioGetValue( (wChoice_p)prefPLs[I_UNITS].control ); if (newUnits != displayUnits) { oldUnits = units; units = newUnits; @@ -437,10 +455,10 @@ static void UpdatePrefD( void ) static void UpdateMeasureFmt() { - int inx; + int inx; distanceFormatInx = wListGetIndex((wList_p)prefPLs[I_DSTFMT].control); - units = wRadioGetValue((wChoice_p)prefPLs[1].control); + units = wRadioGetValue((wChoice_p)prefPLs[I_UNITS].control); for (inx = 0; inx < COUNT( prefPLs ); inx++) { if ((prefPLs[inx].option&PDO_DIM)) { @@ -482,8 +500,9 @@ static void PrefOk( void * junk ) NoticeMessage2( 0, MSG_CONN_PARAMS_TOO_BIG, _("Ok"), NULL ) ; } - if(changes & CHANGE_ICONSIZE) + if(changes & CHANGE_ICONSIZE) { NoticeMessage( MSG_ICON_SIZE_RESTART, _("Ok"), NULL ) ; + } wHide( prefW ); DoChangeNotification(changes); @@ -494,7 +513,8 @@ static void PrefOk( void * junk ) static void DoPref( void * junk ) { if (prefW == NULL) { - prefW = ParamCreateDialog( &prefPG, MakeWindowTitle(_("Preferences")), _("Ok"), PrefOk, wHide, TRUE, NULL, 0, OptionDlgUpdate ); + prefW = ParamCreateDialog( &prefPG, MakeWindowTitle(_("Preferences")), _("Ok"), + PrefOk, wHide, TRUE, NULL, 0, OptionDlgUpdate ); LoadDstFmtList(); } ParamLoadControls( &prefPG ); @@ -506,21 +526,25 @@ static void DoPref( void * junk ) EXPORT addButtonCallBack_t PrefInit( void ) { ParamRegister( &prefPG ); - if (connectAngle < 1.0) + if (connectAngle < 1.0) { connectAngle = 1.0; - if (connectDistance < 0.1) + } + if (connectDistance < 0.1) { connectDistance = 0.1; - if (minLength < 0.1) + } + if (minLength < 0.1) { minLength = 0.1; + } return &DoPref; } EXPORT long GetDistanceFormat( void ) { - while ( dstFmts[units][distanceFormatInx].name == NULL ) + while ( dstFmts[units][distanceFormatInx].name == NULL ) { distanceFormatInx--; - return dstFmts[units][distanceFormatInx].fmt; + } + return dstFmts[units][distanceFormatInx].fmt; } /***************************************************************************** @@ -541,7 +565,10 @@ static paramData_t colorPLs[] = { { PD_COLORLIST, &selectedColor, "selected", PDO_NOPSHUPD, NULL, N_("Selected Track"), 0, I2VP(CHANGE_MAIN) }, { PD_COLORLIST, &profilePathColor, "profile", PDO_NOPSHUPD, NULL, N_("Profile Path"), 0, I2VP(CHANGE_MAIN) }, { PD_COLORLIST, &exceptionColor, "exception", PDO_NOPSHUPD, NULL, N_("Exception Track"), 0, I2VP(CHANGE_MAIN) }, - { PD_COLORLIST, &tieColor, "tie", PDO_NOPSHUPD, NULL, N_("Track Ties"), 0, I2VP(CHANGE_MAIN) } }; + { PD_COLORLIST, &tieColor, "tie", PDO_NOPSHUPD, NULL, N_("Track Ties"), 0, I2VP(CHANGE_MAIN) }, + { PD_COLORLIST, &bridgeColor, "bridge", PDO_NOPSHUPD, NULL, N_("Bridge Base"), 0, I2VP(CHANGE_MAIN) }, + { PD_COLORLIST, &roadbedColor, "roadbed", PDO_NOPSHUPD, NULL, N_("Track Roadbed"), 0, I2VP(CHANGE_MAIN) } +}; static paramGroup_t colorPG = { "rgbcolor", PGO_RECORD|PGO_PREFGROUP, colorPLs, COUNT( colorPLs ) }; @@ -551,16 +578,19 @@ static void ColorOk( void * junk ) long changes; changes = GetChanges( &colorPG ); wHide( colorW ); - if ( (changes&CHANGE_GRID) && GridIsVisible() ) + if ( (changes&CHANGE_GRID) && GridIsVisible() ) { changes |= CHANGE_MAIN; + } DoChangeNotification( changes ); } static void DoColor( void * junk ) { - if (colorW == NULL) - colorW = ParamCreateDialog( &colorPG, MakeWindowTitle(_("Color")), _("Ok"), ColorOk, wHide, TRUE, NULL, 0, NULL ); + if (colorW == NULL) { + colorW = ParamCreateDialog( &colorPG, MakeWindowTitle(_("Color")), _("Ok"), + ColorOk, wHide, TRUE, NULL, 0, NULL ); + } ParamLoadControls( &colorPG ); wShow( colorW ); } diff --git a/app/bin/dpricels.c b/app/bin/dpricels.c index ef7025e..06931fe 100644 --- a/app/bin/dpricels.c +++ b/app/bin/dpricels.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "compound.h" @@ -51,12 +51,13 @@ static paramData_t priceListPLs[] = { { PD_STRING, &priceListEntryV, "entry", PDO_NOPREF|PDO_NOPSHUPD|PDO_DLGHORZ, I2VP(400-80-3), NULL, BO_READONLY, NULL, sizeof priceListEntryV }, #define I_PRICELSLIST (2) #define priceListSelL ((wList_p)priceListPLs[I_PRICELSLIST].control) - { PD_LIST, NULL, "inx", PDO_NOPREF|PDO_NOPSHUPD, &priceListListData }, + { PD_LIST, NULL, "inx", PDO_DLGRESIZE|PDO_NOPREF|PDO_NOPSHUPD, &priceListListData }, #define I_PRICELSFLEXLEN (3) { PD_FLOAT, &priceListFlexLengthV, "flexlen", PDO_NOPREF|PDO_NOPSHUPD|PDO_DIM|PDO_DLGRESETMARGIN, &priceListFlexData, N_("Flex Track") }, { PD_MESSAGE, N_("costs"), NULL, PDO_DLGHORZ }, #define I_PRICELSFLEXCOST (6) - { PD_FLOAT, &priceListFlexCostV, "flexcost", PDO_NOPREF|PDO_NOPSHUPD|PDO_DLGHORZ, &priceListFlexData } }; + { PD_FLOAT, &priceListFlexCostV, "flexcost", PDO_NOPREF|PDO_NOPSHUPD|PDO_DLGHORZ, &priceListFlexData } +}; static paramGroup_t priceListPG = { "pricelist", 0, priceListPLs, COUNT( priceListPLs ) }; @@ -64,16 +65,21 @@ static void PriceListUpdate() { DIST_T oldPrice; ParamLoadData( &priceListPG ); - if (priceListCurrent == NULL) + if (priceListCurrent == NULL) { return; - FormatCompoundTitle( LABEL_MANUF|LABEL_DESCR|LABEL_PARTNO, priceListCurrent->title ); + } + FormatCompoundTitle( LABEL_MANUF|LABEL_DESCR|LABEL_PARTNO, + priceListCurrent->title ); wPrefGetFloat( "price list", message, &oldPrice, 0.0 ); - if (oldPrice == priceListCostV) + if (oldPrice == priceListCostV) { return; + } wPrefSetFloat( "price list", message, priceListCostV ); FormatCompoundTitle( listLabels|LABEL_COST, priceListCurrent->title ); - if (message[0] != '\0') - wListSetValues( priceListSelL, wListGetIndex(priceListSelL), message, NULL, priceListCurrent ); + if (message[0] != '\0') { + wListSetValues( priceListSelL, wListGetIndex(priceListSelL), message, NULL, + priceListCurrent ); + } } @@ -88,14 +94,16 @@ static void PriceListOk( void * action ) static void PriceListSel( - turnoutInfo_t * to ) + turnoutInfo_t * to ) { FLOAT_T price; PriceListUpdate(); priceListCurrent = to; - if (priceListCurrent == NULL) + if (priceListCurrent == NULL) { return; - FormatCompoundTitle( LABEL_MANUF|LABEL_DESCR|LABEL_PARTNO, priceListCurrent->title ); + } + FormatCompoundTitle( LABEL_MANUF|LABEL_DESCR|LABEL_PARTNO, + priceListCurrent->title ); wPrefGetFloat( "price list", message, &price, 0.00 ); priceListCostV = price; strcpy( priceListEntryV, message ); @@ -108,18 +116,24 @@ static void PriceListChange( long changes ) { turnoutInfo_t * to1, * to2; if ((changes & (CHANGE_SCALE|CHANGE_PARAMS)) == 0 || - priceListW == NULL || !wWinIsVisible( priceListW ) ) + priceListW == NULL || !wWinIsVisible( priceListW ) ) { return; + } wListClear( priceListSelL ); - to1 = TurnoutAdd( listLabels|LABEL_COST, GetLayoutCurScale(), priceListSelL, NULL, -1 ); - to2 = StructAdd( listLabels|LABEL_COST, GetLayoutCurScale(), priceListSelL, NULL ); - if (to1 == NULL) + to1 = TurnoutAdd( listLabels|LABEL_COST, GetLayoutCurScale(), priceListSelL, + NULL, -1 ); + to2 = StructAdd( listLabels|LABEL_COST, GetLayoutCurScale(), priceListSelL, + NULL ); + if (to1 == NULL) { to1 = to2; + } priceListCurrent = NULL; - if (to1) + if (to1) { PriceListSel( to1 ); - if ((changes & CHANGE_SCALE) == 0) + } + if ((changes & CHANGE_SCALE) == 0) { return; + } sprintf( message, "price list %s", curScaleName ); wPrefGetFloat( message, "flex length", &priceListFlexLengthV, 0.0 ); wPrefGetFloat( message, "flex cost", &priceListFlexCostV, 0.0 ); @@ -128,9 +142,9 @@ static void PriceListChange( long changes ) static void PriceListDlgUpdate( - paramGroup_p pg, - int inx, - void * valueP ) + paramGroup_p pg, + int inx, + void * valueP ) { turnoutInfo_t * to; switch( inx ) { @@ -138,7 +152,8 @@ static void PriceListDlgUpdate( PriceListUpdate(); break; case I_PRICELSLIST: - to = (turnoutInfo_t*)wListGetItemContext( (wList_p)pg->paramPtr[inx].control, (wIndex_t)*(long*)valueP ); + to = (turnoutInfo_t*)wListGetItemContext( (wList_p)pg->paramPtr[inx].control, + (wIndex_t)*(long*)valueP ); PriceListSel( to ); break; } @@ -147,8 +162,10 @@ static void PriceListDlgUpdate( static void DoPriceList( void * junk ) { - if (priceListW == NULL) - priceListW = ParamCreateDialog( &priceListPG, MakeWindowTitle(_("Price List")), _("Done"), PriceListOk, wHide, TRUE, NULL, F_RESIZE, PriceListDlgUpdate ); + if (priceListW == NULL) { + priceListW = ParamCreateDialog( &priceListPG, MakeWindowTitle(_("Price List")), + _("Done"), PriceListOk, wHide, TRUE, NULL, F_RESIZE, PriceListDlgUpdate ); + } wShow( priceListW ); PriceListChange( CHANGE_SCALE|CHANGE_PARAMS ); } diff --git a/app/bin/dprmfile.c b/app/bin/dprmfile.c index 7fbe337..ced4c8f 100644 --- a/app/bin/dprmfile.c +++ b/app/bin/dprmfile.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "custom.h" @@ -67,17 +67,17 @@ static char * paramFileLabels[] = { N_("Show File Names"), NULL }; static paramData_t paramFilePLs[] = { #define I_PRMFILLIST (0) #define paramFileL ((wList_p)paramFilePLs[I_PRMFILLIST].control) - { PD_LIST, NULL, "inx", PDO_NOPREF | PDO_DLGRESIZE, ¶mFileListData, NULL, BL_DUP|BL_SETSTAY|BL_MANY }, + { PD_LIST, NULL, "inx", PDO_NOPREF | PDO_DLGRESIZE, ¶mFileListData, NULL, BL_DUP|BL_SETSTAY|BL_MANY }, #define I_PRMFILTOGGLE (1) - { PD_TOGGLE, ¶mFileSel, "mode", 0, paramFileLabels, NULL, BC_HORZ|BC_NOBORDER }, + { PD_TOGGLE, ¶mFileSel, "mode", 0, paramFileLabels, NULL, BC_HORZ|BC_NOBORDER }, #define I_MESSAGE (2) { PD_MESSAGE, "", NULL, 0, I2VP(370) }, - { PD_BUTTON, ParamFileSelectAll, "selectall", PDO_DLGCMDBUTTON, NULL, N_("Select all") }, + { PD_BUTTON, ParamFileSelectAll, "selectall", PDO_DLGCMDBUTTON, NULL, N_("Select all") }, #define I_PRMFILEFAVORITE (4) - { PD_BUTTON, ParamFileFavorite, "favorite", PDO_DLGCMDBUTTON, I2VP(TRUE), N_("Favorite")}, - { PD_BUTTON, ParamUnloadSelectedFiles, "unload", PDO_DLGCMDBUTTON, NULL, N_(PARAMBUTTON_UNLOAD), 0L, FALSE }, + { PD_BUTTON, ParamFileFavorite, "favorite", PDO_DLGCMDBUTTON, I2VP(TRUE), N_("Favorite")}, + { PD_BUTTON, ParamUnloadSelectedFiles, "unload", PDO_DLGCMDBUTTON, NULL, N_(PARAMBUTTON_UNLOAD), 0L, FALSE }, { PD_BUTTON, ParamRefreshSelectedFiles, "refresh", PDO_DLGCMDBUTTON, NULL, N_(PARAMBUTTON_REFRESH), 0L, FALSE }, - { PD_BUTTON, DoSearchParams, "find", 0, NULL, N_("Library...") }, + { PD_BUTTON, DoSearchParams, "find", 0, NULL, N_("Library...") }, { PD_BUTTON, ParamFileBrowse, "browse", 0, NULL, N_("Browse...") }, @@ -100,14 +100,16 @@ static dynArr_t *sortFiles; int CompareParameterFiles(const void *index1, const void *index2) { - paramFileInfo_t paramFile1 = DYNARR_N(paramFileInfo_t, (*sortFiles), *(int*)index1); - paramFileInfo_t paramFile2 = DYNARR_N(paramFileInfo_t, (*sortFiles), *(int*)index2); - - if (paramFile2.trackState != paramFile1.trackState) { - return (paramFile2.trackState - paramFile1.trackState); - } else { - return (strcmp(paramFile1.contents, paramFile2.contents)); - } + paramFileInfo_t paramFile1 = DYNARR_N(paramFileInfo_t, (*sortFiles), + *(int*)index1); + paramFileInfo_t paramFile2 = DYNARR_N(paramFileInfo_t, (*sortFiles), + *(int*)index2); + + if (paramFile2.trackState != paramFile1.trackState) { + return (paramFile2.trackState - paramFile1.trackState); + } else { + return (strcmp(paramFile1.contents, paramFile2.contents)); + } } /** @@ -123,13 +125,13 @@ CompareParameterFiles(const void *index1, const void *index2) void SortParamFileList(size_t cnt, dynArr_t *files, int *list) { - for (size_t i = 0; i < cnt; i++) { - list[i] = (int)i; - } + for (size_t i = 0; i < cnt; i++) { + list[i] = (int)i; + } - sortFiles = files; + sortFiles = files; - qsort(list, (size_t)cnt, sizeof(int), CompareParameterFiles); + qsort(list, (size_t)cnt, sizeof(int), CompareParameterFiles); } @@ -138,45 +140,46 @@ SortParamFileList(size_t cnt, dynArr_t *files, int *list) */ void ParamFileListLoad(int paramFileCnt, dynArr_t *paramFiles) { - DynString description; - DynStringMalloc(&description, STR_SHORT_SIZE); - int *sortedIndex = MyMalloc(sizeof(int)*paramFileCnt); + DynString description; + DynStringMalloc(&description, STR_SHORT_SIZE); + int *sortedIndex = MyMalloc(sizeof(int)*paramFileCnt); int log_params = LogFindIndex("params"); - SortParamFileList(paramFileCnt, paramFiles, sortedIndex); - - wControlShow((wControl_p)paramFileL, FALSE); - wListClear(paramFileL); - - for (int i = 0; i < paramFileCnt; i++) { - paramFileInfo_t paramFileInfo = DYNARR_N(paramFileInfo_t, (*paramFiles), - sortedIndex[ i ]); - if (paramFileInfo.valid) { - DynStringClear(&description); - DynStringCatCStr(&description, - ((!paramFileSel) && paramFileInfo.contents) ? - paramFileInfo.contents : - paramFileInfo.name); - - wListAddValue(paramFileL, - DynStringToCStr(&description), - indicatorIcons[ paramFileInfo.favorite ][paramFileInfo.trackState], - I2VP(sortedIndex[i])); - - LOG1(log_params, ("ParamFileListLoad: = %s: %d\n", paramFileInfo.contents, paramFileInfo.trackState)) - } - } - wControlShow((wControl_p)paramFileL, TRUE); - DynStringFree(&description); - MyFree(sortedIndex); + SortParamFileList(paramFileCnt, paramFiles, sortedIndex); + + wControlShow((wControl_p)paramFileL, FALSE); + wListClear(paramFileL); + + for (int i = 0; i < paramFileCnt; i++) { + paramFileInfo_t paramFileInfo = DYNARR_N(paramFileInfo_t, (*paramFiles), + sortedIndex[ i ]); + if (paramFileInfo.valid) { + DynStringClear(&description); + DynStringCatCStr(&description, + ((!paramFileSel) && paramFileInfo.contents) ? + paramFileInfo.contents : + paramFileInfo.name); + + wListAddValue(paramFileL, + DynStringToCStr(&description), + indicatorIcons[ paramFileInfo.favorite ][paramFileInfo.trackState], + I2VP(sortedIndex[i])); + + LOG1(log_params, ("ParamFileListLoad: = %s: %d\n", paramFileInfo.contents, + paramFileInfo.trackState)) + } + } + wControlShow((wControl_p)paramFileL, TRUE); + DynStringFree(&description); + MyFree(sortedIndex); } static void ParamFileBrowse(void * junk) { wMessageSetValue(MESSAGETEXT, ""); - wFilSelect(paramFile_fs, GetParamFileDir()); - return; + wFilSelect(paramFile_fs, GetParamFileDir()); + return; } /** @@ -188,35 +191,35 @@ static void ParamFileBrowse(void * junk) static void UpdateParamFileButton(void) { - wIndex_t selcnt = wListGetSelectedCount(paramFileL); - wIndex_t inx, cnt; - wIndex_t fileInx; - - //nothing selected -> leave - if (selcnt <= 0) { - return; - } - - // set the default - paramFilePLs[I_PRMFILEFAVORITE].context = FALSE; - - // get the number of items in list - cnt = wListGetCount(paramFileL); - - // walk through the whole list box - for (inx=0; inx<cnt; inx++) { - if (wListGetItemSelected((wList_p)paramFileL, inx)) { - // if item is selected, get status - fileInx = (wIndex_t)VP2L(wListGetItemContext(paramFileL, inx)); - - if (fileInx < 0 || fileInx >= GetParamFileCount()) { - return; - } - if (!IsParamFileFavorite(fileInx)) { - paramFilePLs[I_PRMFILEFAVORITE].context = I2VP(TRUE); - } - } - } + wIndex_t selcnt = wListGetSelectedCount(paramFileL); + wIndex_t inx, cnt; + wIndex_t fileInx; + + //nothing selected -> leave + if (selcnt <= 0) { + return; + } + + // set the default + paramFilePLs[I_PRMFILEFAVORITE].context = FALSE; + + // get the number of items in list + cnt = wListGetCount(paramFileL); + + // walk through the whole list box + for (inx=0; inx<cnt; inx++) { + if (wListGetItemSelected((wList_p)paramFileL, inx)) { + // if item is selected, get status + fileInx = (wIndex_t)VP2L(wListGetItemContext(paramFileL, inx)); + + if (fileInx < 0 || fileInx >= GetParamFileCount()) { + return; + } + if (!IsParamFileFavorite(fileInx)) { + paramFilePLs[I_PRMFILEFAVORITE].context = I2VP(TRUE); + } + } + } } /** @@ -228,20 +231,20 @@ static void UpdateParamFileButton(void) void UpdateParamFileProperties( bool newState) { - wIndex_t inx, cnt; - wIndex_t fileInx; - - // get the number of items in list - cnt = wListGetCount(paramFileL); - - // walk through the whole list box - for (inx = 0; inx < cnt; inx++) { - if (wListGetItemSelected((wList_p)paramFileL, inx)) { - fileInx = (wIndex_t)VP2L(wListGetItemContext(paramFileL, inx)); - SetParamFileFavorite(fileInx, newState); - } - } - DoChangeNotification(CHANGE_PARAMS); + wIndex_t inx, cnt; + wIndex_t fileInx; + + // get the number of items in list + cnt = wListGetCount(paramFileL); + + // walk through the whole list box + for (inx = 0; inx < cnt; inx++) { + if (wListGetItemSelected((wList_p)paramFileL, inx)) { + fileInx = (wIndex_t)VP2L(wListGetItemContext(paramFileL, inx)); + SetParamFileFavorite(fileInx, newState); + } + } + DoChangeNotification(CHANGE_PARAMS); } /** @@ -253,11 +256,11 @@ UpdateParamFileProperties( bool newState) static void ParamFileFavorite(void * setFavorite) { - wIndex_t selcnt = wListGetSelectedCount(paramFileL); + wIndex_t selcnt = wListGetSelectedCount(paramFileL); wMessageSetValue(MESSAGETEXT, ""); - if (selcnt) { - UpdateParamFileProperties(setFavorite?TRUE:FALSE); - } + if (selcnt) { + UpdateParamFileProperties(setFavorite?TRUE:FALSE); + } } /** @@ -295,7 +298,8 @@ ParamChangeSelectedFiles(unsigned paramFileChange) } break; default: - AbortProg("Invalid change type %d in ParamChangeSelectedFiles", paramFileChange); + CHECKMSG( FALSE, ("Invalid change type %d in ParamChangeSelectedFiles", + paramFileChange) ); } } } @@ -312,24 +316,24 @@ ParamChangeSelectedFiles(unsigned paramFileChange) static void ParamRefreshSelectedFiles(void * action) { - wIndex_t selcnt = wListGetSelectedCount(paramFileL); - - //nothing selected -> leave - if (selcnt) { - DynString reloadMessage; - ParamChangeSelectedFiles(PARAMFILE_REFRESH); - - DynStringMalloc(&reloadMessage, 16); - if (selcnt > 1) { - DynStringPrintf(&reloadMessage, _("%d parameter files reloaded."), selcnt); - } else { - DynStringCatCStr(&reloadMessage, _("One parameter file reloaded.")); - } - wMessageSetValue(MESSAGETEXT, DynStringToCStr(&reloadMessage)); + wIndex_t selcnt = wListGetSelectedCount(paramFileL); + + //nothing selected -> leave + if (selcnt) { + DynString reloadMessage; + ParamChangeSelectedFiles(PARAMFILE_REFRESH); + + DynStringMalloc(&reloadMessage, 16); + if (selcnt > 1) { + DynStringPrintf(&reloadMessage, _("%d parameter files reloaded."), selcnt); + } else { + DynStringCatCStr(&reloadMessage, _("One parameter file reloaded.")); + } + wMessageSetValue(MESSAGETEXT, DynStringToCStr(&reloadMessage)); DynStringFree(&reloadMessage); - } else { - wBeep(); - } + } else { + wBeep(); + } } static void ParamUnloadSelectedFiles(void * action) @@ -355,43 +359,43 @@ static void ParamUnloadSelectedFiles(void * action) static void ParamFileSelectAll(void *junk) { wMessageSetValue(MESSAGETEXT, ""); - wListSelectAll(paramFileL); - UpdateParamFileButton(); + wListSelectAll(paramFileL); + UpdateParamFileButton(); } static void ParamFileOk(void * junk) { - SearchUiOk(junk); - + SearchUiOk(junk); + DoChangeNotification(CHANGE_PARAMS); - wHide(paramFileW); + wHide(paramFileW); } static void ParamFileDlgUpdate( - paramGroup_p pg, - int inx, - void * valueP) + paramGroup_p pg, + int inx, + void * valueP) { - switch (inx) { - case I_PRMFILLIST: - UpdateParamFileButton(); - break; - case I_PRMFILTOGGLE: - DoChangeNotification(CHANGE_PARAMS); - break; - } + switch (inx) { + case I_PRMFILLIST: + UpdateParamFileButton(); + break; + case I_PRMFILTOGGLE: + DoChangeNotification(CHANGE_PARAMS); + break; + } } void ParamFilesChange(long changes) { - if (changes & CHANGE_PARAMS || changes & CHANGE_SCALE) { - UpdateParamFileList(); - if (paramFileW) { - ParamFileListLoad(paramFileInfo_da.cnt, ¶mFileInfo_da); - } - } + if (changes & CHANGE_PARAMS || changes & CHANGE_SCALE) { + UpdateParamFileList(); + if (paramFileW) { + ParamFileListLoad(paramFileInfo_da.cnt, ¶mFileInfo_da); + } + } } /** @@ -402,38 +406,38 @@ void ParamFilesChange(long changes) void DoParamFiles(void * junk) { - void * data; - - if (paramFileW == NULL) { - indicatorIcons[ STANDARD_PARAM ][ PARAMFILE_UNLOADED ] = wIconCreatePixMap( - greydot); - indicatorIcons[ STANDARD_PARAM ][ PARAMFILE_NOTUSABLE ] = wIconCreatePixMap( - reddot); - indicatorIcons[ STANDARD_PARAM ][ PARAMFILE_COMPATIBLE ] = wIconCreatePixMap( - yellowdot); - indicatorIcons[ STANDARD_PARAM ][ PARAMFILE_FIT] = wIconCreatePixMap(greendot); - indicatorIcons[ FAVORITE_PARAM ][ PARAMFILE_UNLOADED ] = wIconCreatePixMap( - greystar); - indicatorIcons[ FAVORITE_PARAM ][ PARAMFILE_NOTUSABLE ] = wIconCreatePixMap( - redstar); - indicatorIcons[ FAVORITE_PARAM ][ PARAMFILE_COMPATIBLE ] = wIconCreatePixMap( - yellowstar); - indicatorIcons[ FAVORITE_PARAM ][ PARAMFILE_FIT ] = wIconCreatePixMap( - greenstar); - - ParamRegister(¶mFilePG); - - paramFileW = ParamCreateDialog(¶mFilePG, - MakeWindowTitle(_("Parameter Files")), _("Ok"), ParamFileOk, NULL, - TRUE, NULL, F_RESIZE | F_RECALLSIZE, ParamFileDlgUpdate); - paramFile_fs = wFilSelCreate(mainW, FS_LOAD, FS_MULTIPLEFILES, - _("Load Parameters"), _("Parameter files (*.xtp)|*.xtp"), LoadParamFile, NULL); - } - ParamLoadControls(¶mFilePG); - ParamGroupRecord(¶mFilePG); - if ((wListGetValues(paramFileL, NULL, 0, NULL, &data))>=0) { - UpdateParamFileButton(); - } - - wShow(paramFileW); + void * data; + + if (paramFileW == NULL) { + indicatorIcons[ STANDARD_PARAM ][ PARAMFILE_UNLOADED ] = wIconCreatePixMap( + greydot); + indicatorIcons[ STANDARD_PARAM ][ PARAMFILE_NOTUSABLE ] = wIconCreatePixMap( + reddot); + indicatorIcons[ STANDARD_PARAM ][ PARAMFILE_COMPATIBLE ] = wIconCreatePixMap( + yellowdot); + indicatorIcons[ STANDARD_PARAM ][ PARAMFILE_FIT] = wIconCreatePixMap(greendot); + indicatorIcons[ FAVORITE_PARAM ][ PARAMFILE_UNLOADED ] = wIconCreatePixMap( + greystar); + indicatorIcons[ FAVORITE_PARAM ][ PARAMFILE_NOTUSABLE ] = wIconCreatePixMap( + redstar); + indicatorIcons[ FAVORITE_PARAM ][ PARAMFILE_COMPATIBLE ] = wIconCreatePixMap( + yellowstar); + indicatorIcons[ FAVORITE_PARAM ][ PARAMFILE_FIT ] = wIconCreatePixMap( + greenstar); + + ParamRegister(¶mFilePG); + + paramFileW = ParamCreateDialog(¶mFilePG, + MakeWindowTitle(_("Parameter Files")), _("Ok"), ParamFileOk, NULL, + TRUE, NULL, F_RESIZE | F_RECALLSIZE, ParamFileDlgUpdate); + paramFile_fs = wFilSelCreate(mainW, FS_LOAD, FS_MULTIPLEFILES, + _("Load Parameters"), _("Parameter files (*.xtp)|*.xtp"), LoadParamFile, NULL); + } + ParamLoadControls(¶mFilePG); + ParamGroupRecord(¶mFilePG); + if ((wListGetValues(paramFileL, NULL, 0, NULL, &data))>=0) { + UpdateParamFileButton(); + } + + wShow(paramFileW); } diff --git a/app/bin/draw.c b/app/bin/draw.c index d7ec0c0..d833a7b 100644 --- a/app/bin/draw.c +++ b/app/bin/draw.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "cselect.h" @@ -38,13 +38,13 @@ static void DrawMarkers( void ); static void ConstraintOrig( coOrd *, coOrd, int, int ); static void DoMouse( wAction_t action, coOrd pos ); static void DDrawPoly( - drawCmd_p d, - int cnt, - coOrd * pts, - int * types, - wDrawColor color, - wDrawWidth width, - drawFill_e eFillOpt ); + drawCmd_p d, + int cnt, + coOrd * pts, + int * types, + wDrawColor color, + wDrawWidth width, + drawFill_e eFillOpt ); static void DrawMapBoundingBox( BOOL_T set ); static void DrawTicks( drawCmd_p d, coOrd size ); static void DoZoom( void * pScaleVP ); @@ -54,6 +54,7 @@ static int log_zoom = 0; static int log_mouse = 0; static int log_redraw = 0; static int log_timemainredraw = 0; +static int log_mapsize = 0; static wFontSize_t drawMaxTextFontSize = 100; @@ -65,11 +66,14 @@ static wFontSize_t drawMaxTextFontSize = 100; // static char FAR message[STR_LONG_SIZE]; -EXPORT wDrawPix_t closePixels = 10; EXPORT long maxArcSegStraightLen = 100; EXPORT long drawCount; EXPORT BOOL_T drawEnable = TRUE; EXPORT long currRedraw = 0; +EXPORT long constrainMain = 0; +//EXPORT long mapScale = 64; +EXPORT long liveMap = 0; +EXPORT long descriptionFontSize = 72; EXPORT coOrd panCenter; EXPORT coOrd menuPos; @@ -80,10 +84,15 @@ EXPORT wDrawColor drawColorRed; EXPORT wDrawColor drawColorBlue; EXPORT wDrawColor drawColorGreen; EXPORT wDrawColor drawColorAqua; +EXPORT wDrawColor drawColorDkRed; +EXPORT wDrawColor drawColorDkBlue; +EXPORT wDrawColor drawColorDkGreen; +EXPORT wDrawColor drawColorDkAqua; EXPORT wDrawColor drawColorPreviewSelected; EXPORT wDrawColor drawColorPreviewUnselected; EXPORT wDrawColor drawColorPowderedBlue; EXPORT wDrawColor drawColorPurple; +EXPORT wDrawColor drawColorMagenta; EXPORT wDrawColor drawColorGold; EXPORT wDrawColor drawColorGrey10; EXPORT wDrawColor drawColorGrey20; @@ -122,24 +131,26 @@ EXPORT wDrawColor elevColorDefined; EXPORT wDrawColor profilePathColor; EXPORT wDrawColor exceptionColor; +DIST_T closeDist = 0.100; + static wFont_p rulerFp; static struct { - wStatus_p scale_m; - wStatus_p count_m; - wStatus_p posX_m; - wStatus_p posY_m; - wStatus_p info_m; - wWinPix_t scale_w; - wWinPix_t count_w; - wWinPix_t pos_w; - wWinPix_t info_w; - wBox_p scale_b; - wBox_p count_b; - wBox_p posX_b; - wBox_p posY_b; - wBox_p info_b; - } infoD; + wStatus_p scale_m; + wStatus_p count_m; + wStatus_p posX_m; + wStatus_p posY_m; + wStatus_p info_m; + wWinPix_t scale_w; + wWinPix_t count_w; + wWinPix_t pos_w; + wWinPix_t info_w; + wBox_p scale_b; + wBox_p count_b; + wBox_p posX_b; + wBox_p posY_b; + wBox_p info_b; +} infoD; EXPORT coOrd oldMarker = { 0.0, 0.0 }; @@ -150,7 +161,8 @@ EXPORT BOOL_T inError = FALSE; typedef enum { mouseNone, mouseLeft, mouseRight, mouseLeftPending } mouseState_e; static mouseState_e mouseState; -static wDrawPix_t mousePositionx, mousePositiony; /**< position of mouse pointer */ +static wDrawPix_t mousePositionx, + mousePositiony; /**< position of mouse pointer */ static int delayUpdate = 1; @@ -159,62 +171,72 @@ static char yLabel[] = "Y: "; static char zoomLabel[] = "Zoom: "; static struct { - char * name; - double value; - wMenuRadio_p pdRadio; - wMenuRadio_p btRadio; - wMenuRadio_p ctxRadio1; - wMenuRadio_p panRadio; - } zoomList[] = { - { "1:10", 1.0 / 10.0 }, - { "1:9", 1.0 / 9.0 }, - { "1:8", 1.0 / 8.0 }, - { "1:7", 1.0 / 7.0 }, - { "1:6", 1.0 / 6.0 }, - { "1:5", 1.0 / 5.0 }, - { "1:4", 1.0 / 4.0 }, - { "1:3", 1.0 / 3.0 }, - { "1:2", 1.0 / 2.0 }, - { "1:1", 1.0 }, - { "2:1", 2.0 }, - { "3:1", 3.0 }, - { "4:1", 4.0 }, - { "5:1", 5.0 }, - { "6:1", 6.0 }, - { "7:1", 7.0 }, - { "8:1", 8.0 }, - { "9:1", 9.0 }, - { "10:1", 10.0 }, - { "12:1", 12.0 }, - { "14:1", 14.0 }, - { "16:1", 16.0 }, - { "18:1", 18.0 }, - { "20:1", 20.0 }, - { "24:1", 24.0 }, - { "28:1", 28.0 }, - { "32:1", 32.0 }, - { "36:1", 36.0 }, - { "40:1", 40.0 }, - { "48:1", 48.0 }, - { "56:1", 56.0 }, - { "64:1", 64.0 }, - { "80:1", 80.0 }, - { "96:1", 96.0 }, - { "112:1", 112.0 }, - { "128:1", 128.0 }, - { "160:1", 160.0 }, - { "192:1", 192.0 }, - { "224:1", 224.0 }, - { "256:1", 256.0 }, - { "320:1", 320.0 }, - { "384:1", 384.0 }, - { "448:1", 448.0 }, - { "512:1", 512.0 }, - { "640:1", 640.0 }, - { "768:1", 768.0 }, - { "896:1", 896.0 }, - { "1024:1", 1024.0 }, - }; + char * name; + DIST_T value; + wMenuRadio_p pdRadio; + wMenuRadio_p btRadio; + wMenuRadio_p ctxRadio1; + wMenuRadio_p panRadio; +} zoomList[] = { + { "1:10", 1.0 / 10.0 }, + { "1:9", 1.0 / 9.0 }, + { "1:8", 1.0 / 8.0 }, + { "1:7", 1.0 / 7.0 }, + { "1:6", 1.0 / 6.0 }, + { "1:5", 1.0 / 5.0 }, + { "1:4", 1.0 / 4.0 }, + { "1:3.5", 1.0 / 3.5 }, + { "1:3", 1.0 / 3.0 }, + { "1:2.5", 1.0 / 2.5 }, + { "1:2", 1.0 / 2.0 }, + { "1:1.75", 1.0 / 1.75 }, + { "1:1.5", 1.0 / 1.5 }, + { "1:1.25", 1.0 / 1.25 }, + { "1:1", 1.0 }, + { "1.25:1", 1.25 }, + { "1.5:1", 1.5 }, + { "1.75:1", 1.75 }, + { "2:1", 2.0 }, + { "2.5:1", 2.5 }, + { "3:1", 3.0 }, + { "3.5:1", 3.5 }, + { "4:1", 4.0 }, + { "5:1", 5.0 }, + { "6:1", 6.0 }, + { "7:1", 7.0 }, + { "8:1", 8.0 }, + { "9:1", 9.0 }, + { "10:1", 10.0 }, + { "12:1", 12.0 }, + { "14:1", 14.0 }, + { "16:1", 16.0 }, + { "18:1", 18.0 }, + { "20:1", 20.0 }, + { "24:1", 24.0 }, + { "28:1", 28.0 }, + { "32:1", 32.0 }, + { "36:1", 36.0 }, + { "40:1", 40.0 }, + { "48:1", 48.0 }, + { "56:1", 56.0 }, + { "64:1", 64.0 }, + { "80:1", 80.0 }, + { "96:1", 96.0 }, + { "112:1", 112.0 }, + { "128:1", 128.0 }, + { "160:1", 160.0 }, + { "192:1", 192.0 }, + { "224:1", 224.0 }, + { "256:1", 256.0 }, + { "320:1", 320.0 }, + { "384:1", 384.0 }, + { "448:1", 448.0 }, + { "512:1", 512.0 }, + { "640:1", 640.0 }, + { "768:1", 768.0 }, + { "896:1", 896.0 }, + { "1024:1", 1024.0 }, +}; @@ -224,24 +246,28 @@ static struct { * */ -static void MainCoOrd2Pix( drawCmd_p d, coOrd p, wDrawPix_t * x, wDrawPix_t * y ) +static void MainCoOrd2Pix( drawCmd_p d, coOrd p, wDrawPix_t * x, + wDrawPix_t * y ) { DIST_T t; - if (d->angle != 0.0) + if (d->angle != 0.0) { Rotate( &p, d->orig, -d->angle ); + } p.x = (p.x - d->orig.x) / d->scale; p.y = (p.y - d->orig.y) / d->scale; t = p.x*d->dpi; - if ( t > 0.0 ) + if ( t > 0.0 ) { t += 0.5; - else + } else { t -= 0.5; + } *x = ((wDrawPix_t)t) + ((d->options&DC_TICKS)?LBORDER:0); t = p.y*d->dpi; - if ( t > 0.0 ) + if ( t > 0.0 ) { t += 0.5; - else + } else { t -= 0.5; + } *y = ((wDrawPix_t)t) + ((d->options&DC_TICKS)?BBORDER:0); } @@ -249,10 +275,10 @@ static void MainCoOrd2Pix( drawCmd_p d, coOrd p, wDrawPix_t * x, wDrawPix_t * y static int Pix2CoOrd_interpolate = 0; static void MainPix2CoOrd( - drawCmd_p d, - wDrawPix_t px, - wDrawPix_t py, - coOrd * posR ) + drawCmd_p d, + wDrawPix_t px, + wDrawPix_t py, + coOrd * posR ) { DIST_T x, y; DIST_T bins = pixelBins; @@ -260,19 +286,20 @@ static void MainPix2CoOrd( y = ((((POS_T)((py)-BBORDER))/d->dpi)) * d->scale; x = (long)(x*bins)/bins; y = (long)(y*bins)/bins; -if (Pix2CoOrd_interpolate) { - DIST_T x1, y1; - x1 = ((((POS_T)((px-1)-LBORDER))/d->dpi)) * d->scale; - y1 = ((((POS_T)((py-1)-BBORDER))/d->dpi)) * d->scale; - x1 = (long)(x1*bins)/bins; - y1 = (long)(y1*bins)/bins; - if (x == x1) { - x += 1/bins/2; - printf ("px=%0.1f x1=%0.6f x=%0.6f\n", px, x1, x ); - } - if (y == y1) - y += 1/bins/2; -} + if (Pix2CoOrd_interpolate) { + DIST_T x1, y1; + x1 = ((((POS_T)((px-1)-LBORDER))/d->dpi)) * d->scale; + y1 = ((((POS_T)((py-1)-BBORDER))/d->dpi)) * d->scale; + x1 = (long)(x1*bins)/bins; + y1 = (long)(y1*bins)/bins; + if (x == x1) { + x += 1/bins/2; + printf ("px=%0.1f x1=%0.6f x=%0.6f\n", px, x1, x ); + } + if (y == y1) { + y += 1/bins/2; + } + } x += d->orig.x; y += d->orig.y; posR->x = x; @@ -283,36 +310,38 @@ if (Pix2CoOrd_interpolate) { #define DRAWOPTS( D ) (((D->options&DC_TEMP)?wDrawOptTemp:0)|((D->options&DC_OUTLINE)?wDrawOutlineFont:0)) static void DDrawLine( - drawCmd_p d, - coOrd p0, - coOrd p1, - wDrawWidth width, - wDrawColor color ) + drawCmd_p d, + coOrd p0, + coOrd p1, + wDrawWidth width, + wDrawColor color ) { wDrawPix_t x0, y0, x1, y1; BOOL_T in0 = FALSE, in1 = FALSE; coOrd orig, size; - if (d == &mapD && !mapVisible) + if (d == &mapD && !mapVisible) { return; - if ( (d->options&DC_NOCLIP) == 0 ) { - if (d->angle == 0.0) { - in0 = (p0.x >= d->orig.x && p0.x <= d->orig.x+d->size.x && - p0.y >= d->orig.y && p0.y <= d->orig.y+d->size.y); - in1 = (p1.x >= d->orig.x && p1.x <= d->orig.x+d->size.x && - p1.y >= d->orig.y && p1.y <= d->orig.y+d->size.y); - } - if ( (!in0) || (!in1) ) { - orig = d->orig; - size = d->size; - if (d->options&DC_TICKS) { - orig.x -= LBORDER/d->dpi*d->scale; - orig.y -= BBORDER/d->dpi*d->scale; - size.x += (LBORDER+RBORDER)/d->dpi*d->scale; - size.y += (BBORDER+TBORDER)/d->dpi*d->scale; - } - if (!ClipLine( &p0, &p1, orig, d->angle, size )) - return; } + if ( (d->options&DC_NOCLIP) == 0 ) { + if (d->angle == 0.0) { + in0 = (p0.x >= d->orig.x && p0.x <= d->orig.x+d->size.x && + p0.y >= d->orig.y && p0.y <= d->orig.y+d->size.y); + in1 = (p1.x >= d->orig.x && p1.x <= d->orig.x+d->size.x && + p1.y >= d->orig.y && p1.y <= d->orig.y+d->size.y); + } + if ( (!in0) || (!in1) ) { + orig = d->orig; + size = d->size; + if (d->options&DC_TICKS) { + orig.x -= LBORDER/d->dpi*d->scale; + orig.y -= BBORDER/d->dpi*d->scale; + size.x += (LBORDER+RBORDER)/d->dpi*d->scale; + size.y += (BBORDER+TBORDER)/d->dpi*d->scale; + } + if (!ClipLine( &p0, &p1, orig, d->angle, size )) { + return; + } + } } d->CoOrd2Pix(d,p0,&x0,&y0); d->CoOrd2Pix(d,p1,&x1,&y1); @@ -320,126 +349,126 @@ static void DDrawLine( wDrawLineType_e lineOpt = wDrawLineSolid; unsigned long NotSolid = DC_NOTSOLIDLINE; unsigned long opt = d->options&NotSolid; - if (opt == DC_DASH) - lineOpt = wDrawLineDash; - else if(opt == DC_DOT) - lineOpt = wDrawLineDot; - else if(opt == DC_DASHDOT) - lineOpt = wDrawLineDashDot; - else if (opt == DC_DASHDOTDOT) - lineOpt = wDrawLineDashDotDot; - else if(opt == DC_CENTER) - lineOpt = wDrawLineCenter; - else if (opt == DC_PHANTOM) - lineOpt = wDrawLinePhantom; + if (opt == DC_DASH) { + lineOpt = wDrawLineDash; + } else if(opt == DC_DOT) { + lineOpt = wDrawLineDot; + } else if(opt == DC_DASHDOT) { + lineOpt = wDrawLineDashDot; + } else if (opt == DC_DASHDOTDOT) { + lineOpt = wDrawLineDashDotDot; + } else if(opt == DC_CENTER) { + lineOpt = wDrawLineCenter; + } else if (opt == DC_PHANTOM) { + lineOpt = wDrawLinePhantom; + } if (drawEnable) { wDrawLine( d->d, x0, y0, x1, y1, - width, - lineOpt, - color, DRAWOPTS(d) ); + width, + lineOpt, + color, DRAWOPTS(d) ); } } static void DDrawArc( - drawCmd_p d, - coOrd p, - DIST_T r, - ANGLE_T angle0, - ANGLE_T angle1, - BOOL_T drawCenter, - wDrawWidth width, - wDrawColor color ) -{ - wDrawPix_t x, y; - ANGLE_T da; - coOrd p0, p1; - DIST_T rr; - int i, cnt; - - if (d == &mapD && !mapVisible) - { - return; - } - rr = (r / d->scale) * d->dpi + 0.5; - if (rr > wDrawGetMaxRadius(d->d)) - { - da = (maxArcSegStraightLen * 180) / (M_PI * rr); - cnt = (int)(angle1/da) + 1; - da = angle1 / cnt; - coOrd min,max; - min = d->orig; - max.x = min.x + d->size.x; - max.y = min.y + d->size.y; - PointOnCircle(&p0, p, r, angle0); - for (i=1; i<=cnt; i++) { - angle0 += da; - PointOnCircle(&p1, p, r, angle0); - if (d->angle == 0.0 && - ((p0.x >= min.x && - p0.x <= max.x && - p0.y >= min.y && - p0.y <= max.y) || - (p1.x >= min.x && - p1.x <= max.x && - p1.y >= min.y && - p1.y <= max.y))) { - DrawLine(d, p0, p1, width, color); - } else { - coOrd clip0 = p0, clip1 = p1; - if (ClipLine(&clip0, &clip1, d->orig, d->angle, d->size)) { - DrawLine(d, clip0, clip1, width, color); - } - } - - p0 = p1; - } - return; - } - if (d->angle!=0.0 && angle1 < 360.0) - { - angle0 = NormalizeAngle(angle0-d->angle); - } - d->CoOrd2Pix(d,p,&x,&y); - drawCount++; - wDrawLineType_e lineOpt = wDrawLineSolid; - unsigned long NotSolid = DC_NOTSOLIDLINE; - unsigned long opt = d->options&NotSolid; - if (opt == DC_DASH) + drawCmd_p d, + coOrd p, + DIST_T r, + ANGLE_T angle0, + ANGLE_T angle1, + BOOL_T drawCenter, + wDrawWidth width, + wDrawColor color ) +{ + wDrawPix_t x, y; + ANGLE_T da; + coOrd p0, p1; + DIST_T rr; + int i, cnt; + + if (d == &mapD && !mapVisible) { + return; + } + rr = (r / d->scale) * d->dpi + 0.5; + if (rr > wDrawGetMaxRadius(d->d)) { + da = (maxArcSegStraightLen * 180) / (M_PI * rr); + cnt = (int)(angle1/da) + 1; + da = angle1 / cnt; + coOrd min,max; + min = d->orig; + max.x = min.x + d->size.x; + max.y = min.y + d->size.y; + PointOnCircle(&p0, p, r, angle0); + for (i=1; i<=cnt; i++) { + angle0 += da; + PointOnCircle(&p1, p, r, angle0); + if (d->angle == 0.0 && + ((p0.x >= min.x && + p0.x <= max.x && + p0.y >= min.y && + p0.y <= max.y) || + (p1.x >= min.x && + p1.x <= max.x && + p1.y >= min.y && + p1.y <= max.y))) { + DrawLine(d, p0, p1, width, color); + } else { + coOrd clip0 = p0, clip1 = p1; + if (ClipLine(&clip0, &clip1, d->orig, d->angle, d->size)) { + DrawLine(d, clip0, clip1, width, color); + } + } + + p0 = p1; + } + return; + } + if (d->angle!=0.0 && angle1 < 360.0) { + angle0 = NormalizeAngle(angle0-d->angle); + } + d->CoOrd2Pix(d,p,&x,&y); + drawCount++; + wDrawLineType_e lineOpt = wDrawLineSolid; + unsigned long NotSolid = DC_NOTSOLIDLINE; + unsigned long opt = d->options&NotSolid; + if (opt == DC_DASH) { lineOpt = wDrawLineDash; - else if(opt == DC_DOT) + } else if(opt == DC_DOT) { lineOpt = wDrawLineDot; - else if(opt == DC_DASHDOT) + } else if(opt == DC_DASHDOT) { lineOpt = wDrawLineDashDot; - else if (opt == DC_DASHDOTDOT) + } else if (opt == DC_DASHDOTDOT) { lineOpt = wDrawLineDashDotDot; - else if(opt == DC_CENTER) + } else if(opt == DC_CENTER) { lineOpt = wDrawLineCenter; - else if (opt == DC_PHANTOM) + } else if (opt == DC_PHANTOM) { lineOpt = wDrawLinePhantom; - if (drawEnable) - { - int sizeCenter = (int)(drawCenter ? ((d->options & DC_PRINT) ? (d->dpi / BASE_DPI) : 1) : 0); - wDrawArc(d->d, x, y, (wDrawPix_t)(rr), angle0, angle1, sizeCenter, - width, lineOpt, - color, DRAWOPTS(d) ); - } + } + if (drawEnable) { + int sizeCenter = (int)(drawCenter ? ((d->options & DC_PRINT) ? + (d->dpi / BASE_DPI) : 1) : 0); + wDrawArc(d->d, x, y, (wDrawPix_t)(rr), angle0, angle1, sizeCenter, + width, lineOpt, + color, DRAWOPTS(d) ); + } } static void DDrawString( - drawCmd_p d, - coOrd p, - ANGLE_T a, - char * s, - wFont_p fp, - FONTSIZE_T fontSize, - wDrawColor color ) + drawCmd_p d, + coOrd p, + ANGLE_T a, + char * s, + wFont_p fp, + FONTSIZE_T fontSize, + wDrawColor color ) { wDrawPix_t x, y; - if (d == &mapD && !mapVisible) + if (d == &mapD && !mapVisible) { return; + } d->CoOrd2Pix(d,p,&x,&y); if ( color == wDrawColorWhite ) { wDrawPix_t width, height, descent, ascent; @@ -467,13 +496,13 @@ static void DDrawString( static void DDrawPoly( - drawCmd_p d, - int cnt, - coOrd * pts, - int * types, - wDrawColor color, - wDrawWidth width, - drawFill_e eFillOpt ) + drawCmd_p d, + int cnt, + coOrd * pts, + int * types, + wDrawColor color, + wDrawWidth width, + drawFill_e eFillOpt ) { typedef wDrawPix_t wPos2[2]; static dynArr_t wpts_da; @@ -490,26 +519,28 @@ static void DDrawPoly( d->CoOrd2Pix( d, pts[inx], &x, &y ); wpts(inx)[0] = x; wpts(inx)[1] = y; - if (!types) + if (!types) { wtype(inx) = 0; - else + } else { wtype(inx) = (wPolyLine_e)types[inx]; + } } wDrawLineType_e lineOpt = wDrawLineSolid; unsigned long NotSolid = DC_NOTSOLIDLINE; unsigned long opt = d->options&NotSolid; - if (opt == DC_DASH) + if (opt == DC_DASH) { lineOpt = wDrawLineDash; - else if(opt == DC_DOT) + } else if(opt == DC_DOT) { lineOpt = wDrawLineDot; - else if(opt == DC_DASHDOT) + } else if(opt == DC_DASHDOT) { lineOpt = wDrawLineDashDot; - else if (opt == DC_DASHDOTDOT) + } else if (opt == DC_DASHDOTDOT) { lineOpt = wDrawLineDashDotDot; - else if(opt == DC_CENTER) + } else if(opt == DC_CENTER) { lineOpt = wDrawLineCenter; - else if (opt == DC_PHANTOM) + } else if (opt == DC_PHANTOM) { lineOpt = wDrawLinePhantom; + } wDrawOpts drawOpts = DRAWOPTS(d); switch ( eFillOpt ) { @@ -526,23 +557,25 @@ static void DDrawPoly( drawOpts |= wDrawOptTransparent; break; default: - abort(); + CHECK(FALSE); } - wDrawPolygon( d->d, &wpts(0), &wtype(0), cnt, color, width, lineOpt, drawOpts, fill, open ); + wDrawPolygon( d->d, &wpts(0), &wtype(0), cnt, color, width, lineOpt, drawOpts, + fill, open ); } static void DDrawFillCircle( - drawCmd_p d, - coOrd p, - DIST_T r, - wDrawColor color ) + drawCmd_p d, + coOrd p, + DIST_T r, + wDrawColor color ) { wDrawPix_t x, y; DIST_T rr; - if (d == &mapD && !mapVisible) + if (d == &mapD && !mapVisible) { return; + } rr = (r / d->scale) * d->dpi + 0.5; if (rr > wDrawGetMaxRadius(d->d)) { // Circle too big @@ -553,32 +586,35 @@ static void DDrawFillCircle( wDrawGetSize( d->d, &w, &h ); if ( d->options & DC_TICKS ) { if ( x+rr < LBORDER || x-rr > w-RBORDER || - y+rr < BBORDER || y-rr > h-TBORDER ) + y+rr < BBORDER || y-rr > h-TBORDER ) { return; + } } else { if ( x+rr < 0 || x-rr > w || - y+rr < 0 || y-rr > h ) + y+rr < 0 || y-rr > h ) { return; + } } drawCount++; if (drawEnable) { wDrawFilledCircle( d->d, x, y, (wDrawPix_t)(rr), - color, DRAWOPTS(d) ); + color, DRAWOPTS(d) ); } } static void DDrawRectangle( - drawCmd_p d, - coOrd orig, - coOrd size, - wDrawColor color, - drawFill_e eFillOpt ) + drawCmd_p d, + coOrd orig, + coOrd size, + wDrawColor color, + drawFill_e eFillOpt ) { wDrawPix_t x, y, w, h; - if (d == &mapD && !mapVisible) - return; + if (d == &mapD && !mapVisible) { + return; + } d->CoOrd2Pix(d,orig,&x,&y); w = (wDrawPix_t)((size.x/d->scale)*d->dpi+0.5); h = (wDrawPix_t)((size.y/d->scale)*d->dpi+0.5); @@ -603,12 +639,16 @@ static void DDrawRectangle( break; case DRAW_TRANSPARENT: opts |= wDrawOptTransparent; - // Fallthru + // Fallthru case DRAW_FILL: + if ( d->options & DC_ROUND ) { + x = round(x); + y = round(y); + } wDrawFilledRectangle( d->d, x, y, w, h, color, opts ); break; default: - abort(); + CHECK(FALSE); } } } @@ -619,32 +659,34 @@ EXPORT void DrawHilight( drawCmd_p d, coOrd p, coOrd s, BOOL_T add ) unsigned long options = d->options; d->options |= DC_TEMP; wBool_t bTemp = wDrawSetTempMode( d->d, TRUE ); - DrawRectangle( d, p, s, add?drawColorPowderedBlue:selectedColor, DRAW_TRANSPARENT ); + DrawRectangle( d, p, s, add?drawColorPowderedBlue:selectedColor, + DRAW_TRANSPARENT ); wDrawSetTempMode( d->d, bTemp ); d->options = options; } EXPORT void DrawHilightPolygon( drawCmd_p d, coOrd *p, int cnt ) { - ASSERT( cnt <= 4 ); + CHECK( cnt <= 4 ); static wDrawColor color = 0; - if ( color == 0 ) + if ( color == 0 ) { color = wDrawColorGray( 70 ); + } DrawPoly( d, cnt, p, NULL, color, 0, DRAW_TRANSPARENT ); } EXPORT void DrawMultiString( - drawCmd_p d, - coOrd pos, - char * text, - wFont_p fp, - wFontSize_t fs, - wDrawColor color, - ANGLE_T a, - coOrd * lo, - coOrd * hi, - BOOL_T boxed) + drawCmd_p d, + coOrd pos, + char * text, + wFont_p fp, + wFontSize_t fs, + wDrawColor color, + ANGLE_T a, + coOrd * lo, + coOrd * hi, + BOOL_T boxed) { char * cp; char * cp1; @@ -668,21 +710,24 @@ EXPORT void DrawMultiString( cp = line; // Build up message to hold all of the strings separated by nulls while (*text) { cp1 = cp; - while (*text != '\0' && *text != '\n') + while (*text != '\0' && *text != '\n') { *cp++ = *text++; + } *cp = '\0'; DrawTextSize2( &mainD, cp1, fp, fs, TRUE, &textsize, &descent, &ascent); lineW = textsize.x; - if (lineW>size.x) + if (lineW>size.x) { size.x = lineW; + } posl.x = pos.x; posl.y = pos.y; Rotate( &posl, orig, a); DrawString( d, posl, a, cp1, fp, fs, color ); pos.y -= lineH; size.y += lineH; - if (*text == '\0') + if (*text == '\0') { break; + } text++; cp++; } @@ -700,11 +745,12 @@ EXPORT void DrawMultiString( size.y = fabs(orig.y-posl.y)+bh*d->scale/d->dpi; size.y += descent+ascent; coOrd p[4]; - p[0] = orig; p[0].x -= (bw-br)*d->scale/d->dpi; p[0].y += (bh-bb)*d->scale/d->dpi+ascent; + p[0] = orig; p[0].x -= (bw-br)*d->scale/d->dpi; + p[0].y += (bh-bb)*d->scale/d->dpi+ascent; p[1] = p[0]; p[1].x += size.x; p[2] = p[1]; p[2].y -= size.y; p[3] = p[2]; p[3].x = p[0].x; - for (int i=0;i<4;i++) { + for (int i=0; i<4; i++) { Rotate( &p[i], orig, a); } DrawPoly( d, 4, p, NULL, color, 0, DRAW_CLOSED ); @@ -713,52 +759,64 @@ EXPORT void DrawMultiString( free(line); } +/** + * Draw some text inside a box. The layout of the box can be defined using the style + * parameter. Possibilities are complete frame, underline only, omit background or + * draw inversed. + * The background is drawn in white if not disabled + * + * \param style style of box framed, underlined, no background, inverse + * \param d drawing command + * \param pos position + * \param text text to draw + * \param fp font + * \param fs font size + * \param color text color + * \param a angle + */ EXPORT void DrawBoxedString( - int style, - drawCmd_p d, - coOrd pos, - char * text, - wFont_p fp, wFontSize_t fs, - wDrawColor color, - ANGLE_T a ) -{ - coOrd size, p[4], p0=pos, p1, p2; - static int bw=2, bh=2, br=1, bb=1; + int style, + drawCmd_p d, + coOrd pos, + char* text, + wFont_p fp, wFontSize_t fs, + wDrawColor color, + ANGLE_T a) +{ + coOrd size, p[4], p0 = pos, p1, p2; + static int bw = 2, bh = 2, br = 1, bb = 1; static double arrowScale = 0.5; - unsigned long options = d->options; POS_T descent, ascent; - /*DrawMultiString( d, pos, text, fp, fs, color, a, &lo, &hi );*/ - if ( fs < 2*d->scale ) + if (fs < 2 * d->scale) { return; + } #ifndef WINDOWS - if ( ( d->options & DC_PRINT) != 0 ) { - double scale = ((FLOAT_T)fs)/((FLOAT_T)drawMaxTextFontSize)/mainD.dpi; + if ((d->options & DC_PRINT) != 0) { + double scale = ((FLOAT_T)fs) / ((FLOAT_T)drawMaxTextFontSize) / mainD.dpi; wDrawPix_t w, h, d, a; - wDrawGetTextSize( &w, &h, &d, &a, mainD.d, text, fp, drawMaxTextFontSize ); - size.x = w*scale; - size.y = h*scale; - descent = d*scale; - ascent = a*scale; + wDrawGetTextSize(&w, &h, &d, &a, mainD.d, text, fp, drawMaxTextFontSize); + size.x = w * scale; + size.y = h * scale; + descent = d * scale; + ascent = a * scale; } else #endif - DrawTextSize2( &mainD, text, fp, fs, TRUE, &size, &descent, &ascent ); -#ifdef WINDOWS - /*h -= 15;*/ -#endif - p0.x -= size.x/2.0; - p0.y -= size.y/2.0; + DrawTextSize2(&mainD, text, fp, fs, TRUE, &size, &descent, &ascent); + + p0.x -= size.x / 2.0; + p0.y -= size.y / 2.0; if (style == BOX_NONE || d == &mapD) { - DrawString( d, p0, 0.0, text, fp, fs, color ); + DrawString(d, p0, 0.0, text, fp, fs, color); return; } - size.x += bw*d->scale/d->dpi; - size.y += bh*d->scale/d->dpi; + size.x += bw * d->scale / d->dpi; + size.y += bh * d->scale / d->dpi; p[0] = p0; - p[0].x -= br*d->scale/d->dpi; //Top of box - p[0].y += (bb*d->scale/d->dpi+ascent); + p[0].x -= br * d->scale / d->dpi; //Top of box + p[0].y += (bb * d->scale / d->dpi + ascent); p[1].y = p[0].y; - p[2].y = p[3].y = p[0].y-size.y-descent; //Bottom of box + p[2].y = p[3].y = p[0].y - size.y - descent; //Bottom of box p[1].x = p[2].x = p[0].x + size.x; p[3].x = p[0].x; d->options &= ~DC_DASH; @@ -766,61 +824,64 @@ EXPORT void DrawBoxedString( case BOX_ARROW: case BOX_ARROW_BACKGROUND: // Reset size to actual size of the box - size.x = p[2].x-p[0].x; - size.y = p[0].y-p[2].y; + size.x = p[2].x - p[0].x; + size.y = p[0].y - p[2].y; // Pick a point (p1) outside of Box in arrow direction - Translate( &p1, pos, a, size.x+size.y ); + Translate(&p1, pos, a, size.x + size.y); // Find point on edge of Box (p1) - ClipLine( &pos, &p1, p[3], 0.0, size ); + ClipLine(&pos, &p1, p[3], 0.0, size); // Draw line from edge (p1) to Arrow head (p2) - Translate( &p2, p1, a, size.y*arrowScale ); - DrawLine( d, p1, p2, 0, color ); + Translate(&p2, p1, a, size.y * arrowScale); + DrawLine(d, p1, p2, 0, color); // Draw Arrow edges - Translate( &p1, p2, a+150, size.y*0.7*arrowScale ); - DrawLine( d, p1, p2, 0, color ); - Translate( &p1, p2, a-150, size.y*0.7*arrowScale ); - DrawLine( d, p1, p2, 0, color ); - /* no break */ + Translate(&p1, p2, a + 150, size.y * 0.7 * arrowScale); + DrawLine(d, p1, p2, 0, color); + Translate(&p1, p2, a - 150, size.y * 0.7 * arrowScale); + DrawLine(d, p1, p2, 0, color); + /* no break */ case BOX_BOX: case BOX_BOX_BACKGROUND: - if (style == BOX_ARROW_BACKGROUND || style == BOX_BOX_BACKGROUND) - DrawPoly( d, 4, p, NULL, wDrawColorWhite, 0, DRAW_FILL ); //Clear background for box and box-arrow - DrawLine( d, p[1], p[2], 0, color ); - DrawLine( d, p[2], p[3], 0, color ); - DrawLine( d, p[3], p[0], 0, color ); - /* no break */ + if (style == BOX_ARROW_BACKGROUND || style == BOX_BOX_BACKGROUND) { + DrawPoly(d, 4, p, NULL, wDrawColorWhite, 0, + DRAW_FILL); //Clear background for box and box-arrow + } + DrawLine(d, p[1], p[2], 0, color); + DrawLine(d, p[2], p[3], 0, color); + DrawLine(d, p[3], p[0], 0, color); + /* no break */ case BOX_UNDERLINE: - DrawLine( d, p[0], p[1], 0, color ); - DrawString( d, p0, 0.0, text, fp, fs, color ); + DrawLine(d, p[0], p[1], 0, color); + DrawString(d, p0, 0.0, text, fp, fs, color); break; case BOX_INVERT: - DrawPoly( d, 4, p, NULL, color, 0, DRAW_FILL ); - if ( color != wDrawColorWhite ) - DrawString( d, p0, 0.0, text, fp, fs, wDrawColorGray( 94 ) ); + DrawPoly(d, 4, p, NULL, color, 0, DRAW_FILL); + if (color != wDrawColorWhite) { + DrawString(d, p0, 0.0, text, fp, fs, wDrawColorGray(94)); + } break; case BOX_BACKGROUND: - DrawPoly( d, 4, p, NULL, wDrawColorWhite, 0, DRAW_FILL ); - DrawString( d, p0, 0.0, text, fp, fs, color ); + DrawPoly(d, 4, p, NULL, wDrawColorWhite, 0, DRAW_FILL); + DrawString(d, p0, 0.0, text, fp, fs, color); break; } - d->options = options; } EXPORT void DrawTextSize2( - drawCmd_p dp, - char * text, - wFont_p fp, - wFontSize_t fs, - BOOL_T relative, - coOrd * size, - POS_T * descent, - POS_T * ascent) + drawCmd_p dp, + char * text, + wFont_p fp, + wFontSize_t fs, + BOOL_T relative, + coOrd * size, + POS_T * descent, + POS_T * ascent) { wDrawPix_t w, h, d, a; FLOAT_T scale = 1.0; - if ( relative ) + if ( relative ) { fs /= dp->scale; + } if ( fs > drawMaxTextFontSize ) { scale = ((FLOAT_T)fs)/((FLOAT_T)drawMaxTextFontSize); fs = drawMaxTextFontSize; @@ -836,29 +897,29 @@ EXPORT void DrawTextSize2( *descent *= dp->scale; *ascent *=dp->scale; } -/* printf( "DTS2(\"%s\",%0.3f,%d) = (w%d,h%d,d%d) *%0.3f x%0.3f y%0.3f %0.3f\n", text, fs, relative, w, h, d, scale, size->x, size->y, *descent );*/ + /* printf( "DTS2(\"%s\",%0.3f,%d) = (w%d,h%d,d%d) *%0.3f x%0.3f y%0.3f %0.3f\n", text, fs, relative, w, h, d, scale, size->x, size->y, *descent );*/ } EXPORT void DrawTextSize( - drawCmd_p dp, - char * text, - wFont_p fp, - wFontSize_t fs, - BOOL_T relative, - coOrd * size ) + drawCmd_p dp, + char * text, + wFont_p fp, + wFontSize_t fs, + BOOL_T relative, + coOrd * size ) { POS_T descent, ascent; DrawTextSize2( dp, text, fp, fs, relative, size, &descent, &ascent ); } EXPORT void DrawMultiLineTextSize( - drawCmd_p dp, - char * text, - wFont_p fp, - wFontSize_t fs, - BOOL_T relative, - coOrd * size, - coOrd * lastline ) + drawCmd_p dp, + char * text, + wFont_p fp, + wFontSize_t fs, + BOOL_T relative, + coOrd * size, + coOrd * lastline ) { POS_T descent, ascent, lineW, lineH; coOrd textsize, blocksize; @@ -874,14 +935,16 @@ EXPORT void DrawMultiLineTextSize( lastline->y = 0; while (text && *text != '\0' ) { cp = line; - while (*text != '\0' && *text != '\n') + while (*text != '\0' && *text != '\n') { *cp++ = *text++; + } *cp = '\0'; blocksize.y += lineH; DrawTextSize2( &mainD, line, fp, fs, TRUE, &textsize, &descent, &ascent); lineW = textsize.x; - if (lineW>blocksize.x) + if (lineW>blocksize.x) { blocksize.x = lineW; + } lastline->x = textsize.x; if (*text =='\n') { blocksize.y += lineH; @@ -900,7 +963,8 @@ EXPORT void DrawMultiLineTextSize( } -static void DDrawBitMap( drawCmd_p d, coOrd p, wDrawBitMap_p bm, wDrawColor color) +static void DDrawBitMap( drawCmd_p d, coOrd p, wDrawBitMap_p bm, + wDrawColor color) { wDrawPix_t x, y; d->CoOrd2Pix( d, p, &x, &y ); @@ -909,45 +973,47 @@ static void DDrawBitMap( drawCmd_p d, coOrd p, wDrawBitMap_p bm, wDrawColor colo static void TempSegLine( - drawCmd_p d, - coOrd p0, - coOrd p1, - wDrawWidth width, - wDrawColor color ) + drawCmd_p d, + coOrd p0, + coOrd p1, + wDrawWidth width, + wDrawColor color ) { DYNARR_APPEND( trkSeg_t, tempSegs_da, 10 ); tempSegs(tempSegs_da.cnt-1).type = SEG_STRLIN; tempSegs(tempSegs_da.cnt-1).color = color; - if (d->options&DC_SIMPLE) - tempSegs(tempSegs_da.cnt-1).width = 0; - else if (width<0) - tempSegs(tempSegs_da.cnt-1).width = width; - else - tempSegs(tempSegs_da.cnt-1).width = width*d->scale/d->dpi; + if (d->options&DC_SIMPLE) { + tempSegs(tempSegs_da.cnt-1).lineWidth = 0; + } else if (width<0) { + tempSegs(tempSegs_da.cnt-1).lineWidth = width; + } else { + tempSegs(tempSegs_da.cnt-1).lineWidth = width*d->scale/d->dpi; + } tempSegs(tempSegs_da.cnt-1).u.l.pos[0] = p0; tempSegs(tempSegs_da.cnt-1).u.l.pos[1] = p1; } static void TempSegArc( - drawCmd_p d, - coOrd p, - DIST_T r, - ANGLE_T angle0, - ANGLE_T angle1, - BOOL_T drawCenter, - wDrawWidth width, - wDrawColor color ) + drawCmd_p d, + coOrd p, + DIST_T r, + ANGLE_T angle0, + ANGLE_T angle1, + BOOL_T drawCenter, + wDrawWidth width, + wDrawColor color ) { DYNARR_APPEND( trkSeg_t, tempSegs_da, 10 ); tempSegs(tempSegs_da.cnt-1).type = SEG_CRVLIN; tempSegs(tempSegs_da.cnt-1).color = color; - if (d->options&DC_SIMPLE) - tempSegs(tempSegs_da.cnt-1).width = 0; - else if (width<0) - tempSegs(tempSegs_da.cnt-1).width = width; - else - tempSegs(tempSegs_da.cnt-1).width = width*d->scale/d->dpi; + if (d->options&DC_SIMPLE) { + tempSegs(tempSegs_da.cnt-1).lineWidth = 0; + } else if (width<0) { + tempSegs(tempSegs_da.cnt-1).lineWidth = width; + } else { + tempSegs(tempSegs_da.cnt-1).lineWidth = width*d->scale/d->dpi; + } tempSegs(tempSegs_da.cnt-1).u.c.center = p; tempSegs(tempSegs_da.cnt-1).u.c.radius = r; tempSegs(tempSegs_da.cnt-1).u.c.a0 = angle0; @@ -956,19 +1022,19 @@ static void TempSegArc( static void TempSegString( - drawCmd_p d, - coOrd p, - ANGLE_T a, - char * s, - wFont_p fp, - FONTSIZE_T fontSize, - wDrawColor color ) + drawCmd_p d, + coOrd p, + ANGLE_T a, + char * s, + wFont_p fp, + FONTSIZE_T fontSize, + wDrawColor color ) { DYNARR_APPEND( trkSeg_t, tempSegs_da, 10 ); tempSegs(tempSegs_da.cnt-1).type = SEG_TEXT; tempSegs(tempSegs_da.cnt-1).color = color; tempSegs(tempSegs_da.cnt-1).u.t.boxed = FALSE; - tempSegs(tempSegs_da.cnt-1).width = 0; + tempSegs(tempSegs_da.cnt-1).lineWidth = 0; tempSegs(tempSegs_da.cnt-1).u.t.pos = p; tempSegs(tempSegs_da.cnt-1).u.t.angle = a; tempSegs(tempSegs_da.cnt-1).u.t.fontP = fp; @@ -978,13 +1044,13 @@ static void TempSegString( static void TempSegPoly( - drawCmd_p d, - int cnt, - coOrd * pts, - int * types, - wDrawColor color, - wDrawWidth width, - drawFill_e eFillOpt ) + drawCmd_p d, + int cnt, + coOrd * pts, + int * types, + wDrawColor color, + wDrawWidth width, + drawFill_e eFillOpt ) { int fill = 0; int open = 0; @@ -1001,39 +1067,41 @@ static void TempSegPoly( fill = 1; break; default: - abort(); + CHECK(FALSE); } DYNARR_APPEND( trkSeg_t, tempSegs_da, 1); tempSegs(tempSegs_da.cnt-1).type = fill?SEG_FILPOLY:SEG_POLY; tempSegs(tempSegs_da.cnt-1).color = color; - if (d->options&DC_SIMPLE) - tempSegs(tempSegs_da.cnt-1).width = 0; - else if (width<0) - tempSegs(tempSegs_da.cnt-1).width = width; - else - tempSegs(tempSegs_da.cnt-1).width = width*d->scale/d->dpi; + if (d->options&DC_SIMPLE) { + tempSegs(tempSegs_da.cnt-1).lineWidth = 0; + } else if (width<0) { + tempSegs(tempSegs_da.cnt-1).lineWidth = width; + } else { + tempSegs(tempSegs_da.cnt-1).lineWidth = width*d->scale/d->dpi; + } tempSegs(tempSegs_da.cnt-1).u.p.polyType = open?POLYLINE:FREEFORM; tempSegs(tempSegs_da.cnt-1).u.p.cnt = cnt; tempSegs(tempSegs_da.cnt-1).u.p.orig = zero; tempSegs(tempSegs_da.cnt-1).u.p.angle = 0.0; tempSegs(tempSegs_da.cnt-1).u.p.pts = (pts_t *)MyMalloc(cnt*sizeof(pts_t)); - for (int i=0;i<=cnt-1;i++) { + for (int i=0; i<=cnt-1; i++) { tempSegs(tempSegs_da.cnt-1).u.p.pts[i].pt = pts[i]; - tempSegs(tempSegs_da.cnt-1).u.p.pts[i].pt_type = ((d->options&DC_SIMPLE)==0 && (types!=0))?types[i]:wPolyLineStraight; + tempSegs(tempSegs_da.cnt-1).u.p.pts[i].pt_type = ((d->options&DC_SIMPLE)==0 + && (types!=0))?types[i]:wPolyLineStraight; } } static void TempSegFillCircle( - drawCmd_p d, - coOrd p, - DIST_T r, - wDrawColor color ) + drawCmd_p d, + coOrd p, + DIST_T r, + wDrawColor color ) { DYNARR_APPEND( trkSeg_t, tempSegs_da, 10 ); tempSegs(tempSegs_da.cnt-1).type = SEG_FILCRCL; tempSegs(tempSegs_da.cnt-1).color = color; - tempSegs(tempSegs_da.cnt-1).width = 0; + tempSegs(tempSegs_da.cnt-1).lineWidth = 0; tempSegs(tempSegs_da.cnt-1).u.c.center = p; tempSegs(tempSegs_da.cnt-1).u.c.radius = r; tempSegs(tempSegs_da.cnt-1).u.c.a0 = 0.0; @@ -1042,11 +1110,11 @@ static void TempSegFillCircle( static void TempSegRectangle( - drawCmd_p d, - coOrd orig, - coOrd size, - wDrawColor color, - drawFill_e eOpts ) + drawCmd_p d, + coOrd orig, + coOrd size, + wDrawColor color, + drawFill_e eOpts ) { coOrd p[4]; // p1 p2 @@ -1059,48 +1127,55 @@ static void TempSegRectangle( } -static void NoDrawBitMap( drawCmd_p d, coOrd p, wDrawBitMap_p bm, wDrawColor color ) +static void NoDrawBitMap( drawCmd_p d, coOrd p, wDrawBitMap_p bm, + wDrawColor color ) { } EXPORT drawFuncs_t screenDrawFuncs = { - DDrawLine, - DDrawArc, - DDrawString, - DDrawBitMap, - DDrawPoly, - DDrawFillCircle, - DDrawRectangle}; + DDrawLine, + DDrawArc, + DDrawString, + DDrawBitMap, + DDrawPoly, + DDrawFillCircle, + DDrawRectangle +}; EXPORT drawFuncs_t printDrawFuncs = { - DDrawLine, - DDrawArc, - DDrawString, - NoDrawBitMap, - DDrawPoly, - DDrawFillCircle, - DDrawRectangle}; + DDrawLine, + DDrawArc, + DDrawString, + NoDrawBitMap, + DDrawPoly, + DDrawFillCircle, + DDrawRectangle +}; EXPORT drawFuncs_t tempSegDrawFuncs = { - TempSegLine, - TempSegArc, - TempSegString, - NoDrawBitMap, - TempSegPoly, - TempSegFillCircle, - TempSegRectangle}; + TempSegLine, + TempSegArc, + TempSegString, + NoDrawBitMap, + TempSegPoly, + TempSegFillCircle, + TempSegRectangle +}; EXPORT drawCmd_t mainD = { - NULL, &screenDrawFuncs, DC_TICKS, INIT_MAIN_SCALE, 0.0, {0.0,0.0}, {0.0,0.0}, MainPix2CoOrd, MainCoOrd2Pix, 96.0}; + NULL, &screenDrawFuncs, DC_TICKS, INIT_MAIN_SCALE, 0.0, {0.0,0.0}, {0.0,0.0}, MainPix2CoOrd, MainCoOrd2Pix, 96.0 +}; EXPORT drawCmd_t tempD = { - NULL, &screenDrawFuncs, DC_TICKS|DC_TEMP, INIT_MAIN_SCALE, 0.0, {0.0,0.0}, {0.0,0.0}, MainPix2CoOrd, MainCoOrd2Pix, 96.0}; + NULL, &screenDrawFuncs, DC_TICKS|DC_TEMP, INIT_MAIN_SCALE, 0.0, {0.0,0.0}, {0.0,0.0}, MainPix2CoOrd, MainCoOrd2Pix, 96.0 +}; EXPORT drawCmd_t mapD = { - NULL, &screenDrawFuncs, DC_SIMPLE, INIT_MAP_SCALE, 0.0, {0.0,0.0}, {96.0,48.0}, Pix2CoOrd, CoOrd2Pix, 96.0}; + NULL, &screenDrawFuncs, DC_SIMPLE, INIT_MAP_SCALE, 0.0, {0.0,0.0}, {96.0,48.0}, Pix2CoOrd, CoOrd2Pix, 96.0 +}; /***************************************************************************** @@ -1127,37 +1202,41 @@ static wWinPix_t curInfoLabelWidth[NUM_INFOCTL]; static wWinPix_t GetInfoPosWidth( void ) { wWinPix_t labelWidth; - + DIST_T dist; - if ( mapD.size.x > mapD.size.y ) - dist = mapD.size.x; - else - dist = mapD.size.y; - if ( units == UNITS_METRIC ) { - dist *= 2.54; - if ( dist >= 1000 ) - dist = 9999.999*2.54; - else if ( dist >= 100 ) - dist = 999.999*2.54; - else if ( dist >= 10 ) - dist = 99.999*2.54; - } else { - if ( dist >= 100*12 ) - dist = 999.0*12.0+11.0+3.0/4.0-1.0/64.0; - else if ( dist >= 10*12 ) - dist = 99.0*12.0+11.0+3.0/4.0-1.0/64.0; - else if ( dist >= 1*12 ) - dist = 9.0*12.0+11.0+3.0/4.0-1.0/64.0; + if ( mapD.size.x > mapD.size.y ) { + dist = mapD.size.x; + } else { + dist = mapD.size.y; + } + if ( units == UNITS_METRIC ) { + dist *= 2.54; + if ( dist >= 1000 ) { + dist = 9999.999*2.54; + } else if ( dist >= 100 ) { + dist = 999.999*2.54; + } else if ( dist >= 10 ) { + dist = 99.999*2.54; + } + } else { + if ( dist >= 100*12 ) { + dist = 999.0*12.0+11.0+3.0/4.0-1.0/64.0; + } else if ( dist >= 10*12 ) { + dist = 99.0*12.0+11.0+3.0/4.0-1.0/64.0; + } else if ( dist >= 1*12 ) { + dist = 9.0*12.0+11.0+3.0/4.0-1.0/64.0; } - - labelWidth = (wStatusGetWidth( xLabel ) > wStatusGetWidth( yLabel ) ? wStatusGetWidth( xLabel ):wStatusGetWidth( yLabel )); - - return wStatusGetWidth( FormatDistance(dist) ) + labelWidth; + } + + labelWidth = (wStatusGetWidth( xLabel ) > wStatusGetWidth( + yLabel ) ? wStatusGetWidth( xLabel ):wStatusGetWidth( yLabel )); + + return wStatusGetWidth( FormatDistance(dist) ) + labelWidth; } /** * Initialize the status line at the bottom of the window. - * + * */ EXPORT void InitInfoBar( void ) @@ -1176,27 +1255,33 @@ EXPORT void InitInfoBar( void ) infoD.scale_w = wStatusGetWidth( "999:1" ) + wStatusGetWidth( zoomLabel ); /* we do not use the count label for the moment */ infoD.count_w = 0; - infoD.info_w = width - 20 - infoD.pos_w*2 - infoD.scale_w - infoD.count_w - 45; // Allow Window to resize down + infoD.info_w = width - 20 - infoD.pos_w*2 - infoD.scale_w - infoD.count_w - + 45; // Allow Window to resize down if (infoD.info_w <= 0) { infoD.info_w = 10; } yb = y+info_yb_offset; ym = y+(infoHeight-textHeight)/2; boxH = infoHeight; - x = 2; - infoD.scale_b = wBoxCreate( mainW, x, yb, NULL, wBoxBelow, infoD.scale_w, boxH ); - infoD.scale_m = wStatusCreate( mainW, x+info_xm_offset, ym, "infoBarScale", infoD.scale_w-six, zoomLabel); - x += infoD.scale_w + 2; - infoD.posX_b = wBoxCreate( mainW, x, yb, NULL, wBoxBelow, infoD.pos_w, boxH ); - infoD.posX_m = wStatusCreate( mainW, x+info_xm_offset, ym, "infoBarPosX", infoD.pos_w-six, xLabel ); - x += infoD.pos_w + 2; - infoD.posY_b = wBoxCreate( mainW, x, yb, NULL, wBoxBelow, infoD.pos_w, boxH ); - infoD.posY_m = wStatusCreate( mainW, x+info_xm_offset, ym, "infoBarPosY", infoD.pos_w-six, yLabel ); - x += infoD.pos_w + 2; - messageOrControlX = x+info_xm_offset; //Remember Position - messageOrControlY = ym; - infoD.info_b = wBoxCreate( mainW, x, yb, NULL, wBoxBelow, infoD.info_w, boxH ); - infoD.info_m = wStatusCreate( mainW, x+info_xm_offset, ym, "infoBarStatus", infoD.info_w-six, "" ); + x = 2; + infoD.scale_b = wBoxCreate( mainW, x, yb, NULL, wBoxBelow, infoD.scale_w, + boxH ); + infoD.scale_m = wStatusCreate( mainW, x+info_xm_offset, ym, "infoBarScale", + infoD.scale_w-six, zoomLabel); + x += infoD.scale_w + 2; + infoD.posX_b = wBoxCreate( mainW, x, yb, NULL, wBoxBelow, infoD.pos_w, boxH ); + infoD.posX_m = wStatusCreate( mainW, x+info_xm_offset, ym, "infoBarPosX", + infoD.pos_w-six, xLabel ); + x += infoD.pos_w + 2; + infoD.posY_b = wBoxCreate( mainW, x, yb, NULL, wBoxBelow, infoD.pos_w, boxH ); + infoD.posY_m = wStatusCreate( mainW, x+info_xm_offset, ym, "infoBarPosY", + infoD.pos_w-six, yLabel ); + x += infoD.pos_w + 2; + messageOrControlX = x+info_xm_offset; //Remember Position + messageOrControlY = ym; + infoD.info_b = wBoxCreate( mainW, x, yb, NULL, wBoxBelow, infoD.info_w, boxH ); + infoD.info_m = wStatusCreate( mainW, x+info_xm_offset, ym, "infoBarStatus", + infoD.info_w-six, "" ); } @@ -1217,58 +1302,62 @@ static void SetInfoBar( void ) wBoxSetSize( infoD.posY_b, infoD.pos_w, infoHeight-3 ); wStatusSetWidth( infoD.posY_m, infoD.pos_w-six ); } - infoD.info_w = width - 20 - infoD.pos_w*2 - infoD.scale_w - infoD.count_w - 40 + 4; + infoD.info_w = width - 20 - infoD.pos_w*2 - infoD.scale_w - infoD.count_w - 40 + + 4; if (infoD.info_w <= 0) { infoD.info_w = 10; } yb = y+info_yb_offset; ym = y+(infoHeight-textHeight)/2; boxH = infoHeight; - wWinClear( mainW, 0, y, width-20, infoHeight ); - x = 0; - wControlSetPos( (wControl_p)infoD.scale_b, x, yb ); - wControlSetPos( (wControl_p)infoD.scale_m, x+info_xm_offset, ym ); - x += infoD.scale_w + 10; - wControlSetPos( (wControl_p)infoD.posX_b, x, yb ); - wControlSetPos( (wControl_p)infoD.posX_m, x+info_xm_offset, ym ); - x += infoD.pos_w + 5; - wControlSetPos( (wControl_p)infoD.posY_b, x, yb ); - wControlSetPos( (wControl_p)infoD.posY_m, x+info_xm_offset, ym ); - x += infoD.pos_w + 10; - wControlSetPos( (wControl_p)infoD.info_b, x, yb ); - wControlSetPos( (wControl_p)infoD.info_m, x+info_xm_offset, ym ); - wBoxSetSize( infoD.info_b, infoD.info_w, boxH ); - wStatusSetWidth( infoD.info_m, infoD.info_w-six ); - messageOrControlX = x+info_xm_offset; - messageOrControlY = ym; - if (curInfoControl[0]) { - for ( inx=0; curInfoControl[inx]; inx++ ) { - x += curInfoLabelWidth[inx]; - wWinPix_t y_this = ym + (textHeight/2) - (wControlGetHeight( curInfoControl[inx] )/2); - wControlSetPos( curInfoControl[inx], x, y_this ); - x += wControlGetWidth( curInfoControl[inx] )+3; - wControlShow( curInfoControl[inx], TRUE ); - } - wControlSetPos( (wControl_p)infoD.info_m, x+info_xm_offset, ym ); //Move to end + wWinClear( mainW, 0, y, width-20, infoHeight ); + x = 0; + wControlSetPos( (wControl_p)infoD.scale_b, x, yb ); + wControlSetPos( (wControl_p)infoD.scale_m, x+info_xm_offset, ym ); + x += infoD.scale_w + 10; + wControlSetPos( (wControl_p)infoD.posX_b, x, yb ); + wControlSetPos( (wControl_p)infoD.posX_m, x+info_xm_offset, ym ); + x += infoD.pos_w + 5; + wControlSetPos( (wControl_p)infoD.posY_b, x, yb ); + wControlSetPos( (wControl_p)infoD.posY_m, x+info_xm_offset, ym ); + x += infoD.pos_w + 10; + wControlSetPos( (wControl_p)infoD.info_b, x, yb ); + wControlSetPos( (wControl_p)infoD.info_m, x+info_xm_offset, ym ); + wBoxSetSize( infoD.info_b, infoD.info_w, boxH ); + wStatusSetWidth( infoD.info_m, infoD.info_w-six ); + messageOrControlX = x+info_xm_offset; + messageOrControlY = ym; + if (curInfoControl[0]) { + for ( inx=0; curInfoControl[inx]; inx++ ) { + x += curInfoLabelWidth[inx]; + wWinPix_t y_this = ym + (textHeight/2) - (wControlGetHeight( + curInfoControl[inx] )/2); + wControlSetPos( curInfoControl[inx], x, y_this ); + x += wControlGetWidth( curInfoControl[inx] )+3; + wControlShow( curInfoControl[inx], TRUE ); } + wControlSetPos( (wControl_p)infoD.info_m, x+info_xm_offset, ym ); //Move to end + } } static void InfoScale( void ) { - if (mainD.scale >= 1) - sprintf( message, "%s%0.0f:1", zoomLabel, mainD.scale ); - else - sprintf( message, "%s1:%0.0f", zoomLabel, floor(1/mainD.scale+0.5) ); + if (mainD.scale >= 1.0) { + sprintf( message, "%s%.4g:1", zoomLabel, lround(mainD.scale*4.0)/4.0 ); + } else { + sprintf( message, "%s1:%.4g", zoomLabel, lround((1.0/mainD.scale)*4.0)/4.0 ); + } + wStatusSetValue( infoD.scale_m, message ); } EXPORT void InfoCount( wIndex_t count ) { -/* - sprintf( message, "%d", count ); - wMessageSetValue( infoD.count_m, message ); -*/ + /* + sprintf( message, "%d", count ); + wMessageSetValue( infoD.count_m, message ); + */ } EXPORT void InfoPos( coOrd pos ) @@ -1277,7 +1366,7 @@ EXPORT void InfoPos( coOrd pos ) wStatusSetValue( infoD.posX_m, message ); sprintf( message, "%s%s", yLabel, FormatDistance(pos.y) ); wStatusSetValue( infoD.posY_m, message ); - + oldMarker = pos; } @@ -1285,8 +1374,8 @@ static wControl_p deferSubstituteControls[NUM_INFOCTL+1]; static char * deferSubstituteLabels[NUM_INFOCTL]; EXPORT void InfoSubstituteControls( - wControl_p * controls, - char ** labels ) + wControl_p * controls, + char ** labels ) { wWinPix_t x, y; int inx; @@ -1318,7 +1407,8 @@ EXPORT void InfoSubstituteControls( #ifdef WINDOWS wWinPix_t y_this = y + (infoHeight/2) - (textHeight / 2 ); #else - wWinPix_t y_this = y + (infoHeight / 2) - (wControlGetHeight(controls[inx]) / 2) - 2; + wWinPix_t y_this = y + (infoHeight / 2) - (wControlGetHeight( + controls[inx]) / 2) - 2; #endif wControlSetPos( controls[inx], x, y_this ); x += wControlGetWidth( controls[inx] ); @@ -1337,70 +1427,140 @@ EXPORT void SetMessage( char * msg ) wStatusSetValue( infoD.info_m, msg ); } +/** + * Map Handling + * + */ -static void ChangeMapScale( BOOL_T reset ) +/* + * Set mapW size to fit the rescaled map + * + * \param reset IN + */ +static int mapBorderH = 24; +static int mapBorderW = 24; +static void ChangeMapScale() { wWinPix_t w, h; - wWinPix_t dw, dh; FLOAT_T fw, fh; + // Restrict map size to 1/2 of screen + FLOAT_T fScaleW = mapD.size.x / ( displayWidth * 0.5 / mapD.dpi ); + FLOAT_T fScaleH = mapD.size.y / ( displayHeight * 0.5 / mapD.dpi ); + FLOAT_T fScale = ceil( max( fScaleW, fScaleH ) ); + if ( fScale > mapD.scale ) { + LOG( log_mapsize, 2, ( " ChangeMapScale incr scale from %0.3f to %0.3f\n", + mapD.scale, fScale ) ); + mapD.scale = fScale; + } - fw = (((mapD.size.x/mapD.scale)*mapD.dpi) + 0.5)+2; - fh = (((mapD.size.y/mapD.scale)*mapD.dpi) + 0.5)+2; + fw = (((mapD.size.x/mapD.scale)*mapD.dpi) + 0.5)+2; + fh = (((mapD.size.y/mapD.scale)*mapD.dpi) + 0.5)+2; w = (wWinPix_t)fw; h = (wWinPix_t)fh; - if (reset) { - wGetDisplaySize( &dw, &dh ); - wSetGeometry(mapW, 50, dw, 50, dh, -1, -1, mapD.size.x/mapD.size.y); - wWinSetSize( mapW, w+DlgSepLeft+DlgSepRight, h+DlgSepTop+DlgSepBottom); - } + LOG( log_mapsize, 2, ( " ChangeMapScale mapD.scale=%0.3f w=%ld h=%ld\n", + mapD.scale, w, h ) ); + wWinSetSize( mapW, w+mapBorderW, h+mapBorderH ); + // This should be done by wWinSetSize wDrawSetSize( mapD.d, w, h, NULL ); } EXPORT BOOL_T SetRoomSize( coOrd size ) { + LOG( log_mapsize, 2, ( "SetRoomSize NEW:%0.3fx%0.3f OLD:%0.3fx%0.3f\n", size.x, + size.y, mapD.size.x, mapD.size.y ) ); SetLayoutRoomSize(size); - if (size.x < 12.0) - size.x = 12.0; - if (size.y < 12.0) - size.y = 12.0; + if (size.x < 1.0) { + size.x = 1.0; + } + if (size.y < 1.0) { + size.y = 1.0; + } if ( mapD.size.x == size.x && - mapD.size.y == size.y ) + mapD.size.y == size.y ) { return TRUE; + } mapD.size = size; SetLayoutRoomSize(size); - if ( mapW == NULL) - return TRUE; - ChangeMapScale(TRUE); wPrefSetFloat( "draw", "roomsizeX", mapD.size.x ); wPrefSetFloat( "draw", "roomsizeY", mapD.size.y ); + if ( mapW == NULL) { + return TRUE; + } + ChangeMapScale(); return TRUE; } -EXPORT void GetRoomSize( coOrd * froomSize ) -{ - *froomSize = mapD.size; -} - +/** + * Redraw the Map window using the Scale derived from the Window size and Room size + * \param bd [inout] Map canvas - not used + * \param pContext [inout] Param context - not used + * \param px, py [in] canvas size + */ static void MapRedraw( - wDraw_p bd, void * pContex, wWinPix_t px, wWinPix_t py ) + wDraw_p bd, void * pContex, wWinPix_t px, wWinPix_t py ) { - if (inPlaybackQuit) + if (inPlaybackQuit) { return; + } static int cMR = 0; LOG( log_redraw, 2, ( "MapRedraw: %d\n", cMR++ ) ); - if (!mapVisible) + if (!mapVisible) { return; - if (delayUpdate) - wDrawDelayUpdate( mapD.d, TRUE ); + } + if (delayUpdate) { + wDrawDelayUpdate( mapD.d, TRUE ); + } //wSetCursor( mapD.d, wCursorWait ); wBool_t bTemp = wDrawSetTempMode( mapD.d, FALSE ); - if ( bTemp ) + if ( bTemp ) { printf( "MapRedraw TempMode\n" ); + } + + if ( log_mapsize >= 2 ) { + lprintf( " MapRedraw: parm=%ldx%ld", px, py ); + wWinPix_t tx, ty; + if ( mapW ) { + wWinGetSize( mapW, &tx, &ty ); + lprintf( " win=%ldx%ld", tx, ty ); + } + if ( mapD.d ) { + wDrawGetSize( mapD.d, &tx, &ty ); + lprintf( " draw=%ldx%ld", tx, ty ); + } + lprintf( "\n" ); + } + + // Find new mapD.scale + if ( ( px <= 0 || py <= 0 ) && mapD.d ) { + wDrawGetSize( mapD.d, &px, &py ); + px += 2; + py += 2; + } + if ( px > 0 && py > 0 ) { + FLOAT_T scaleX = mapD.size.x * mapD.dpi / px; + FLOAT_T scaleY = mapD.size.y * mapD.dpi / py; + FLOAT_T scale; + + // Find largest scale + if (scaleX>scaleY) { scale = scaleX; } + else { scale = scaleY; } + + if (scale > MAX_MAIN_SCALE) { scale = MAX_MAIN_SCALE; } + if (scale < MIN_MAIN_MACRO) { scale = MIN_MAIN_MACRO; } + + scale = ceil( scale ); // Round up + LOG( log_mapsize, 2, + ( " %ldx%ld mapD.scale=%0.3f, scaleX=%0.3f scaleY=%0.3f scale=%0.3f\n", + px, py, mapD.scale, scaleX, scaleY, scale ) ); + mapD.scale = scale; + } else { + LOG( log_mapsize, 2, ( " 0x0 mapD.scale=%0.3f\n", mapD.scale ) ); + } wDrawClear( mapD.d ); DrawTracks( &mapD, mapD.scale, mapD.orig, mapD.size ); DrawMapBoundingBox( TRUE ); @@ -1410,14 +1570,6 @@ static void MapRedraw( } -static void MapResize( void ) -{ - mapD.scale = mapScale; - ChangeMapScale(TRUE); - MapRedraw( mapD.d, NULL, 0, 0 ); -} - - EXPORT void SetMainSize( void ) { wWinPix_t ww, hh; @@ -1432,35 +1584,34 @@ EXPORT void SetMainSize( void ) tempD.size = mainD.size; } -// Hack to switch between TempRedraw and MainRedraw -extern wBool_t wDrawDoTempDraw; /* Update temp_surface after executing a command */ -EXPORT void TempRedraw( void ) { +EXPORT void TempRedraw( void ) +{ static int cTR = 0; LOG( log_redraw, 2, ( "TempRedraw: %d\n", cTR++ ) ); -if (wDrawDoTempDraw == FALSE) { - // Remove this after windows supports GTK - MainRedraw(); // TempRedraw - windows -} else { - wDrawDelayUpdate( tempD.d, TRUE ); - wDrawSetTempMode( tempD.d, TRUE ); - DrawMarkers(); - DoCurCommand( C_REDRAW, zero ); - RulerRedraw( FALSE ); - RedrawPlaybackCursor(); //If in playback - wDrawSetTempMode( tempD.d, FALSE ); - wDrawDelayUpdate( tempD.d, FALSE ); -} + if (wDrawDoTempDraw == FALSE) { + // Remove this after windows supports GTK + MainRedraw(); // TempRedraw - windows + } else { + wDrawDelayUpdate( tempD.d, TRUE ); + wDrawSetTempMode( tempD.d, TRUE ); + DrawMarkers(); + DoCurCommand( C_REDRAW, zero ); + RulerRedraw( FALSE ); + RedrawPlaybackCursor(); //If in playback + wDrawSetTempMode( tempD.d, FALSE ); + wDrawDelayUpdate( tempD.d, FALSE ); + } } /** * Calculate position and size of background bitmap * * \param [in] drawP destination drawing area - * \param [in] origX x origin of drawing area + * \param [in] origX x origin of drawing area * \param [in] origY y origin of drawing area * \param [out] posX x position of bitmap * \param [out] posY y position of bitmap @@ -1473,15 +1624,15 @@ void TranslateBackground(drawCmd_p drawP, POS_T origX, POS_T origY, wWinPix_t* posX, wWinPix_t* posY, wWinPix_t* pWidth) { - coOrd back_pos = GetLayoutBackGroundPos(); + coOrd back_pos = GetLayoutBackGroundPos(); - *pWidth = (wWinPix_t)(GetLayoutBackGroundSize() / drawP->scale * - drawP->dpi); + *pWidth = (wWinPix_t)(GetLayoutBackGroundSize() / drawP->scale * + drawP->dpi); - *posX = (wWinPix_t)((back_pos.x - origX) / drawP->scale * - drawP->dpi); - *posY = (wWinPix_t)((back_pos.y - origY) / drawP->scale * - drawP->dpi); + *posX = (wWinPix_t)((back_pos.x - origX) / drawP->scale * + drawP->dpi); + *posY = (wWinPix_t)((back_pos.y - origY) / drawP->scale * + drawP->dpi); } /* @@ -1492,10 +1643,12 @@ EXPORT void MainRedraw( void ) coOrd orig, size; static int cMR = 0; - LOG( log_redraw, 1, ( "MainRedraw: %d\n", cMR++ ) ); + LOG( log_redraw, 1, ( "MainRedraw: %d %0.1fx%0.1f\n", cMR++, mainD.size.x, + mainD.size.y ) ); unsigned long time0 = wGetTimer(); - if (delayUpdate) - wDrawDelayUpdate( mainD.d, TRUE ); + if (delayUpdate) { + wDrawDelayUpdate( mainD.d, TRUE ); + } wDrawSetTempMode( mainD.d, FALSE ); wDrawClear( mainD.d ); @@ -1537,7 +1690,8 @@ EXPORT void MainRedraw( void ) //wSetCursor( mainD.d, defaultCursor ); InfoScale(); - LOG( log_timemainredraw, 1, ( "MainRedraw time = %lu mS\n", wGetTimer()-time0 ) ); + LOG( log_timemainredraw, 1, ( "MainRedraw time = %lu mS\n", + wGetTimer()-time0 ) ); // The remainder is from TempRedraw wDrawSetTempMode( tempD.d, TRUE ); DrawMarkers(); @@ -1555,14 +1709,16 @@ EXPORT void MainRedraw( void ) * \param bNoBorder Don't allow mainD.orig to go negative */ EXPORT void MainLayout( - wBool_t bRedraw, - wBool_t bNoBorder ) + wBool_t bRedraw, + wBool_t bNoBorder ) { DIST_T t1; - if (inPlaybackQuit) + if (inPlaybackQuit) { return; + } static int cML = 0; - LOG( log_redraw, 1, ( "MainLayout: %d\n", cML++ ) ); + LOG( log_redraw, 1, ( "MainLayout: %d %s %s\n", cML++, bRedraw?"RDW":"---", + bNoBorder?"NBR":"---" ) ); SetMainSize(); t1 = mainD.dpi/mainD.scale; @@ -1574,14 +1730,17 @@ EXPORT void MainLayout( pixelBins = 0.127; while (1) { pixelBins *= 2.0; - if ( pixelBins >= t1 ) + if ( pixelBins >= t1 ) { break; + } pixelBins *= 2.0; - if ( pixelBins >= t1 ) + if ( pixelBins >= t1 ) { break; + } pixelBins *= 2.5; - if ( pixelBins >= t1 ) + if ( pixelBins >= t1 ) { break; + } } } LOG( log_pan, 2, ( "PixelBins=%0.6f\n", pixelBins ) ); @@ -1592,30 +1751,34 @@ EXPORT void MainLayout( mainCenter.y = mainD.orig.y + mainD.size.y/2.0; DrawMapBoundingBox( TRUE ); - if ( bRedraw ) + if ( bRedraw ) { MainRedraw(); + } if ( bRedraw && wDrawDoTempDraw ) { // Temporary until mswlib supports TempDraw wAction_t action = wActionMove; coOrd pos; - if ( mouseState == mouseLeft ) + if ( mouseState == mouseLeft ) { action = wActionLDrag; - if ( mouseState == mouseRight ) + } + if ( mouseState == mouseRight ) { action = wActionRDrag; + } mainD.Pix2CoOrd( &mainD, mousePositionx, mousePositiony, &pos ); // Prevent recursion if curCommand calls MainLayout when action if a Move or Drag // ie CmdPan static int iRecursion = 0; iRecursion++; - if ( iRecursion == 1 ) + if ( iRecursion == 1 ) { DoMouse( action, pos ); + } iRecursion--; } } /** * The wlib event handler for the main window. - * + * * \param win wlib window information * \param e the wlib event * \param data additional data (unused) @@ -1623,30 +1786,36 @@ EXPORT void MainLayout( void MainProc( wWin_p win, winProcEvent e, void * refresh, void * data ) { + static int cMP = 0; wWinPix_t width, height; switch( e ) { case wResize_e: - if (mainD.d == NULL) + if (mainD.d == NULL) { return; + } wWinGetSize( mainW, &width, &height ); + LOG( log_redraw, 1, ( "MainProc/Resize: %d %s %ld %ld\n", cMP++, + refresh==NULL?"RDW":"---", width, height ) ); LayoutToolBar(refresh); height -= (toolbarHeight+max(infoHeight,textHeight)+10); if (height >= 0) { wBool_t bTemp = wDrawSetTempMode(mainD.d, FALSE ); -if ( bTemp ) - printf( "MainProc TempMode\n" ); + if ( bTemp ) { + printf( "MainProc TempMode\n" ); + } wDrawSetSize( mainD.d, width-20, height, refresh ); wControlSetPos( (wControl_p)mainD.d, 0, toolbarHeight ); SetMainSize(); SetInfoBar(); panCenter.x = mainD.orig.x + mainD.size.x/2.0; panCenter.y = mainD.orig.y + mainD.size.y/2.0; - LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); + LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, + panCenter.y ) ); MainLayout( !refresh, TRUE ); // MainProc: wResize_e event wPrefSetInteger( "draw", "mainwidth", (int)width ); wPrefSetInteger( "draw", "mainheight", (int)height ); wDrawSetTempMode( mainD.d, bTemp ); - } else DrawMapBoundingBox( TRUE ); + } else { DrawMapBoundingBox( TRUE ); } break; case wState_e: wPrefSetInteger( "draw", "maximized", wWinIsMaximized(win) ); @@ -1666,6 +1835,8 @@ if ( bTemp ) EXPORT void DoRedraw( void ) { + LOG( log_mapsize, 2, ( "DoRedraw\n" ) ); + ChangeMapScale(); MapRedraw( mapD.d, NULL, 0, 0 ); MainRedraw(); // DoRedraw } @@ -1679,8 +1850,9 @@ EXPORT void DoRedraw( void ) static void DrawRoomWalls( wBool_t drawBackground ) { - if (mainD.d == NULL) + if (mainD.d == NULL) { return; + } if (drawBackground) { DrawRectangle( &mainD, mainD.orig, mainD.size, drawColorGrey80, DRAW_FILL ); @@ -1714,13 +1886,13 @@ static DIST_T rulerFontSize = 12.0; EXPORT void DrawRuler( - drawCmd_p d, - coOrd pos0, - coOrd pos1, - DIST_T offset, - int number, - int tickSide, - wDrawColor color ) + drawCmd_p d, + coOrd pos0, + coOrd pos1, + DIST_T offset, + int number, + int tickSide, + wDrawColor color ) { coOrd orig = pos0; wAngle_t a, aa; @@ -1733,9 +1905,10 @@ EXPORT void DrawRuler( coOrd d_orig, d_size; wFontSize_t fs; long mm, mm0, mm1, power, skip; - + static double lengths[] = { - 0, 2.0, 4.0, 2.0, 6.0, 2.0, 4.0, 2.0, 8.0, 2.0, 4.0, 2.0, 6.0, 2.0, 4.0, 2.0, 0.0 }; + 0, 2.0, 4.0, 2.0, 6.0, 2.0, 4.0, 2.0, 8.0, 2.0, 4.0, 2.0, 6.0, 2.0, 4.0, 2.0, 0.0 + }; int fraction, incr, firstFraction, lastFraction; int majorLength; coOrd p0, p1; @@ -1746,18 +1919,21 @@ EXPORT void DrawRuler( aa = NormalizeAngle(a+(tickSide==0?+90:-90)); end = FindDistance( pos0, pos1 ); - if (end < 0.1) + if (end < 0.1) { return; + } d_orig.x = d->orig.x - 0.1; d_orig.y = d->orig.y - 0.1; d_size.x = d->size.x + 0.2; d_size.y = d->size.y + 0.2; - if (!ClipLine( &pos0, &pos1, d_orig, d->angle, d_size )) + if (!ClipLine( &pos0, &pos1, d_orig, d->angle, d_size )) { return; + } start = FindDistance( orig, pos0 ); - if (offset < 0) + if (offset < 0) { start = -start; + } end = FindDistance( orig, pos1 ); DrawLine( d, pos0, pos1, 0, color ); @@ -1779,39 +1955,39 @@ EXPORT void DrawRuler( // Label interval for scale > 40 if (d->scale <= 200) { skip = 2000; - } - else if (d->scale <= 400) { + } else if (d->scale <= 400) { skip = 5000; - } - else { + } else { skip = 10000; } for ( ; power<=1000; power*=10,len+=3 ) { - if (power == 1000) + if (power == 1000) { len = 10; + } for (mm=((mm0+(mm0>0?power-1:0))/power)*power; mm<=mm1; mm+=power) { if (power==1000 || mm%(power*10) != 0) { Translate( &p0, orig, a, mm/25.4 ); Translate( &p1, p0, aa, len*d->scale/mainD.dpi ); DrawLine( d, p0, p1, 0, color ); - if (!number || (d->scale > 40 && mm % skip != 0.0)) + if (!number || (d->scale > 40 && mm % skip != 0.0)) { continue; + } if ( (power>=1000) || - (d->scale<=8 && power>=100) || - (d->scale<=1 && power>=10) ) { + (d->scale<=8 && power>=100) || + (d->scale<=1 && power>=10) ) { if (mm%100 != 0) { sprintf(message, "%ld", mm/10%10 ); fs = rulerFontSize*2/3; Translate( &p0, p0, aa, (fs/2.0+len)*d->scale/mainD.dpi ); - Translate( &p0, p0, 225, fs*d->scale/mainD.dpi ); + Translate( &p0, p0, 225, fs*d->scale/mainD.dpi ); //p0.x = p1.x+4*dxn/10*d->scale/mainD.dpi; //p0.y = p1.y+dyn*d->scale/mainD.dpi; } else { sprintf(message, "%0.1f", mm/1000.0 ); fs = rulerFontSize; Translate( &p0, p0, aa, (fs/2.0+len)*d->scale/mainD.dpi ); - Translate( &p0, p0, 225, 1.5*fs*d->scale/mainD.dpi ); + Translate( &p0, p0, 225, 1.5*fs*d->scale/mainD.dpi ); //p0.x = p0.x+((-(LBORDER-2)/2)+((LBORDER-2)/2+2)*sin_aa)*d->scale/mainD.dpi; //p0.y = p1.y+dyn*d->scale/mainD.dpi; } @@ -1821,18 +1997,19 @@ EXPORT void DrawRuler( } } } else { - if (d->scale <= 1) - incr = 1; //16ths - else if (d->scale <= 3) - incr = 2; //8ths - else if (d->scale <= 5) - incr = 4; //4ths - else if (d->scale <= 7) - incr = 8; //1/2ths - else if (d->scale <= 48) + if (d->scale <= 1) { + incr = 1; //16ths + } else if (d->scale <= 3) { + incr = 2; //8ths + } else if (d->scale <= 5) { + incr = 4; //4ths + } else if (d->scale <= 7) { + incr = 8; //1/2ths + } else if (d->scale <= 48) { incr = 32; - else - incr = 16; //Inches + } else { + incr = 16; //Inches + } lastInch = (int)floor(end); lastFraction = 16; @@ -1842,7 +2019,7 @@ EXPORT void DrawRuler( inch--; firstFraction = 16 - firstFraction; } - for ( ; inch<=lastInch; inch++){ + for ( ; inch<=lastInch; inch++) { if(inch % 12 == 0) { lengths[0] = 12; majorLength = 16; @@ -1855,7 +2032,7 @@ EXPORT void DrawRuler( digit = (int)(inch%12); fs = rulerFontSize*(2.0/3.0); quote = '"'; - } else if (d->scale <= 24){ // 16 + } else if (d->scale <= 24) { // 16 lengths[0] = 10; majorLength = 12; digit = (int)(inch%12); @@ -1863,24 +2040,22 @@ EXPORT void DrawRuler( } else { continue; } - if (inch == lastInch) + if (inch == lastInch) { lastFraction = (((int)((end - lastInch)*16)) / incr) * incr; + } for ( fraction = firstFraction; fraction <= lastFraction; fraction += incr ) { // Tick interval for scale > 128 skip = 0; if(d->scale > 512) { skip = (inch % 120 != 0); - } - else if(d->scale > 256) { + } else if(d->scale > 256) { skip = (inch % 60 != 0); - } - else if(d->scale > 128) { + } else if(d->scale > 128) { skip = (inch % 24 != 0); - } - else if(d->scale > 64) { + } else if(d->scale > 64) { skip = (inch % 12 != 0); } - if(!skip){ + if(!skip) { Translate( &p0, orig, a, inch+fraction/16.0 ); Translate( &p1, p0, aa, lengths[fraction]*d->scale/mainD.dpi ); DrawLine( d, p0, p1, 0, color ); @@ -1889,20 +2064,16 @@ EXPORT void DrawRuler( // Label interval for scale > 40 if (d->scale <= 80) { skip = 2; - } - else if (d->scale <= 120) { + } else if (d->scale <= 120) { skip = 5; - } - else if (d->scale <= 240) { + } else if (d->scale <= 240) { skip = 10; - } - else if (d->scale <= 480) { + } else if (d->scale <= 480) { skip = 20; - } - else { + } else { skip = 50; } - if ( (number == TRUE && d->scale <= 40) || (digit % skip == 0)) { + if ( number == TRUE && ((d->scale <= 40) || (digit % skip == 0.0)) ) { if (inch % 12 == 0 || d->scale <= 2) { Translate( &p0, p0, aa, majorLength*d->scale/mainD.dpi ); Translate( &p0, p0, 225, fs*d->scale/mainD.dpi ); @@ -1911,7 +2082,7 @@ EXPORT void DrawRuler( } } } - firstFraction = 0; + firstFraction = 0; } } } @@ -1928,14 +2099,14 @@ static void DrawTicks( drawCmd_p d, coOrd size ) double blank_zone = 40*d->scale/mainD.dpi; if ( d->orig.x<0.0-blank_zone ) { - p0.y = 0.0; p1.y = mapD.size.y; - p0.x = p1.x = 0.0; - DrawRuler( d, p0, p1, offset, FALSE, TRUE, borderColor ); + p0.y = 0.0; p1.y = mapD.size.y; + p0.x = p1.x = 0.0; + DrawRuler( d, p0, p1, offset, FALSE, TRUE, borderColor ); } if (d->orig.x+d->size.x>mapD.size.x+blank_zone) { - p0.y = 0.0; p1.y = mapD.size.y; - p0.x = p1.x = mapD.size.x; - DrawRuler( d, p0, p1, offset, FALSE, FALSE, borderColor ); + p0.y = 0.0; p1.y = mapD.size.y; + p0.x = p1.x = mapD.size.x; + DrawRuler( d, p0, p1, offset, FALSE, FALSE, borderColor ); } p0.x = 0.0; p1.x = d->size.x; offset = d->orig.x; @@ -1952,9 +2123,9 @@ static void DrawTicks( drawCmd_p d, coOrd size ) DrawRuler( d, p0, p1, offset, FALSE, FALSE, borderColor ); } if (d->orig.y+d->size.y>mapD.size.y+blank_zone) { - p0.x = 0.0; p1.x = mapD.size.x; - p0.y = p1.y = mapD.size.y; - DrawRuler( d, p0, p1, offset, FALSE, TRUE, borderColor ); + p0.x = 0.0; p1.x = mapD.size.x; + p0.y = p1.y = mapD.size.y; + DrawRuler( d, p0, p1, offset, FALSE, TRUE, borderColor ); } p0.y = 0.0; p1.y = d->size.y; offset = d->orig.y; @@ -1974,23 +2145,26 @@ EXPORT coOrd mainCenter; static void DrawMapBoundingBox( BOOL_T set ) { - if (mainD.d == NULL || mapD.d == NULL) - abort(); - if (!mapVisible) + CHECK( mainD.d ); + CHECK( mapD.d ); + if (!mapVisible) { return; + } DrawHilight( &mapD, mainD.orig, mainD.size, TRUE ); } -static void ConstraintOrig( coOrd * orig, coOrd size, wBool_t bNoBorder, wBool_t bRound ) +static void ConstraintOrig( coOrd * orig, coOrd size, wBool_t bNoBorder, + wBool_t bRound ) { -LOG( log_pan, 2, ( "ConstraintOrig [ %0.6f, %0.6f ] RoomSize(%0.3f %0.3f), WxH=%0.3fx%0.3f", - orig->x, orig->y, mapD.size.x, mapD.size.y, - size.x, size.y ) ) + LOG( log_pan, 2, + ( "ConstraintOrig [ %0.6f, %0.6f ] RoomSize(%0.3f %0.3f), WxH=%0.3fx%0.3f", + orig->x, orig->y, mapD.size.x, mapD.size.y, + size.x, size.y ) ) coOrd bound = zero; - if ( !bNoBorder ) { + if ( !bNoBorder ) { bound.x = size.x/2; bound.y = size.y/2; } @@ -2004,8 +2178,9 @@ LOG( log_pan, 2, ( "ConstraintOrig [ %0.6f, %0.6f ] RoomSize(%0.3f %0.3f), WxH=% } } - if (orig->x < (0-bound.x)) - orig->x = 0-bound.x; + if (orig->x < (0-bound.x)) { + orig->x = 0-bound.x; + } if (orig->y > 0.0) { if ((orig->y+size.y) > (mapD.size.y+bound.y) ) { @@ -2015,8 +2190,9 @@ LOG( log_pan, 2, ( "ConstraintOrig [ %0.6f, %0.6f ] RoomSize(%0.3f %0.3f), WxH=% } } - if (orig->y < (0-bound.y)) - orig->y = 0-bound.y; + if (orig->y < (0-bound.y)) { + orig->y = 0-bound.y; + } if (bRound) { orig->x = round(orig->x*pixelBins)/pixelBins; @@ -2026,8 +2202,8 @@ LOG( log_pan, 2, ( "ConstraintOrig [ %0.6f, %0.6f ] RoomSize(%0.3f %0.3f), WxH=% } /** - * Initialize the menu for setting zoom factors. - * + * Initialize the menu for setting zoom factors. + * * \param IN zoomM Menu to which radio button is added * \param IN zoomSubM Second menu to which radio button is added, ignored if NULL * \param IN ctxMenu1 @@ -2035,31 +2211,34 @@ LOG( log_pan, 2, ( "ConstraintOrig [ %0.6f, %0.6f ] RoomSize(%0.3f %0.3f), WxH=% * */ -EXPORT void InitCmdZoom( wMenu_p zoomM, wMenu_p zoomSubM, wMenu_p ctxMenu1, wMenu_p panMenu ) +EXPORT void InitCmdZoom( wMenu_p zoomM, wMenu_p zoomSubM, wMenu_p ctxMenu1, + wMenu_p panMenu ) { int inx; - + for ( inx=0; inx<COUNT( zoomList ); inx++ ) { - if( (zoomList[ inx ].value >= 1.0 && zoomList[ inx ].value<=10 ) || - (ceil(log2(zoomList[ inx ].value)) == floor(log2(zoomList[ inx ].value)))) - { - if (zoomM) - zoomList[inx].btRadio = wMenuRadioCreate( zoomM, "cmdZoom", zoomList[inx].name, 0, DoZoom, (&(zoomList[inx].value))); - if( zoomSubM ) - zoomList[inx].pdRadio = wMenuRadioCreate( zoomSubM, "cmdZoom", zoomList[inx].name, 0, DoZoom, (&(zoomList[inx].value))); - if (panMenu) - zoomList[inx].panRadio = wMenuRadioCreate( panMenu, "cmdZoom", zoomList[inx].name, 0, DoZoom, (&(zoomList[inx].value))); + if (zoomM) { + zoomList[inx].btRadio = wMenuRadioCreate( zoomM, "cmdZoom", zoomList[inx].name, + 0, DoZoom, (&(zoomList[inx].value))); } - if ((zoomList[inx].value >=1.0 && zoomList[inx].value <= 10.0) || (ceil(log2(zoomList[ inx ].value)) == floor(log2(zoomList[ inx ].value)))) { - if (ctxMenu1) - zoomList[inx].ctxRadio1 = wMenuRadioCreate( ctxMenu1, "cmdZoom", zoomList[inx].name, 0, DoZoom, (&(zoomList[inx].value))); + if( zoomSubM ) { + zoomList[inx].pdRadio = wMenuRadioCreate( zoomSubM, "cmdZoom", + zoomList[inx].name, 0, DoZoom, (&(zoomList[inx].value))); + } + if (panMenu) { + zoomList[inx].panRadio = wMenuRadioCreate( panMenu, "cmdZoom", + zoomList[inx].name, 0, DoZoom, (&(zoomList[inx].value))); + } + if (ctxMenu1) { + zoomList[inx].ctxRadio1 = wMenuRadioCreate( ctxMenu1, "cmdZoom", + zoomList[inx].name, 0, DoZoom, (&(zoomList[inx].value))); } } } /** * Set radio button(s) corresponding to current scale. - * + * * \param IN scale current scale * */ @@ -2067,93 +2246,126 @@ EXPORT void InitCmdZoom( wMenu_p zoomM, wMenu_p zoomSubM, wMenu_p ctxMenu1, wMen static void SetZoomRadio( DIST_T scale ) { int inx; - long curScale = (long)scale; - + for ( inx=0; inx<COUNT( zoomList ); inx++ ) { - if( curScale == zoomList[inx].value ) { - if (zoomList[inx].btRadio) + if( scale == zoomList[inx].value ) { + if (zoomList[inx].btRadio) { wMenuRadioSetActive( zoomList[inx].btRadio ); - if( zoomList[inx].pdRadio ) + } + if( zoomList[inx].pdRadio ) { wMenuRadioSetActive( zoomList[inx].pdRadio ); - if (zoomList[inx].ctxRadio1) + } + if (zoomList[inx].ctxRadio1) { wMenuRadioSetActive( zoomList[inx].ctxRadio1 ); - if (zoomList[inx].panRadio) + } + if (zoomList[inx].panRadio) { wMenuRadioSetActive( zoomList[inx].panRadio ); - /* activate / deactivate zoom buttons when appropriate */ + } + /* activate / deactivate zoom buttons when appropriate */ wControlLinkedActive( (wControl_p)zoomUpB, ( inx != 0 ) ); - wControlLinkedActive( (wControl_p)zoomDownB, ( inx < (COUNT( zoomList ) - 1))); + wControlLinkedActive( (wControl_p)zoomDownB, ( inx < (COUNT( zoomList ) - 1))); } } -} +} /** - * Find current scale + * Find current scale * * \param IN scale current scale * \return index in scale table or -1 if error * */ - + static int ScaleInx( DIST_T scale ) { int inx; - + for ( inx=0; inx<COUNT( zoomList); inx++ ) { if( scale == zoomList[inx].value ) { return inx; } } - return -1; + return -1; } /* * Find Nearest Scale */ -static int NearestScaleInx ( DIST_T scale, BOOL_T larger ) { +static int NearestScaleInx ( DIST_T scale, BOOL_T larger ) +{ int inx; - for ( inx=0; inx<COUNT( zoomList ); inx++ ) { + //scale = rintf(scale*4.0)/4.0; + + if (larger) { + for ( inx=0; inx<COUNT( zoomList )-1; inx++ ) { if( scale == zoomList[inx].value ) { return inx; } - if (scale < zoomList[inx].value) return inx; + if (scale < zoomList[inx].value) { + return inx; + } } return inx-1; + } else { + for ( inx=COUNT( zoomList)-1; inx>=0; inx-- ) { + if( scale == zoomList[inx].value ) { + return inx; + } + if (scale > zoomList[inx].value ) { + return inx; + } + } + } + return 0; } /** - * Set up for new drawing scale. After the scale was changed, eg. via zoom button, everything - * is set up for the new scale. + * Set up for new drawing scale. After the scale was changed, eg. via zoom button, everything + * is set up for the new scale. * * \param scale IN new scale */ - + static void DoNewScale( DIST_T scale ) { char tmp[20]; - if (scale > MAX_MAIN_SCALE) + static BOOL_T in_use = 0; //lock for recursion to avoid additional setting. + + if (in_use) { return; } + + in_use = 1; //set lock + + if (scale > MAX_MAIN_SCALE) { scale = MAX_MAIN_SCALE; + } + + if (scale < zoomList[0].value) { + scale = zoomList[0].value; + } tempD.scale = mainD.scale = scale; mainD.dpi = wDrawGetDPI( mainD.d ); - if ( scale > 1.0 && scale <= 12.0 ) { - mainD.dpi = floor( (mainD.dpi + scale/2)/scale) * scale; - } + //if ( scale > 1.0 && scale <= 12.0 ) { + // mainD.dpi = floor( (mainD.dpi + scale/2)/scale) * scale; + //} tempD.dpi = mainD.dpi; - SetZoomRadio( scale ); + SetZoomRadio( scale ); //This routine causes a re-drive of the DoNewScale. + InfoScale(); - SetMainSize(); + SetMainSize(); PanHere( I2VP(1) ); -LOG( log_zoom, 1, ( "center = [%0.3f %0.3f]\n", mainCenter.x, mainCenter.y ) ) + LOG( log_zoom, 1, ( "center = [%0.3f %0.3f]\n", mainCenter.x, mainCenter.y ) ) sprintf( tmp, "%0.3f", mainD.scale ); wPrefSetString( "draw", "zoom", tmp ); if (recordF) { fprintf( recordF, "ORIG %0.3f %0.3f %0.3f\n", - mainD.scale, mainD.orig.x, mainD.orig.y ); + mainD.scale, mainD.orig.x, mainD.orig.y ); } + in_use=0; //release lock } @@ -2167,34 +2379,37 @@ EXPORT void DoZoomUp( void * mode ) { long newScale; int i; - + LOG( log_zoom, 2, ( "DoZoomUp KS:%x\n", MyGetKeyState() ) ); if ( mode != NULL || (MyGetKeyState()&WKEY_SHIFT) == 0) { i = ScaleInx( mainD.scale ); - if (i < 0) i = NearestScaleInx(mainD.scale, TRUE); - /* - * Zooming into macro mode happens when we are at scale 1:1. + if (i < 0) { i = NearestScaleInx(mainD.scale, FALSE); } + /* + * Zooming into macro mode happens when we are at scale 1:1. * To jump into macro mode, the CTRL-key has to be pressed and held. */ if( mainD.scale != 1.0 || (mainD.scale == 1.0 && (MyGetKeyState()&WKEY_CTRL))) { if( i ) { - if (mainD.scale <=1.0) + if (mainD.scale <=1.0) { InfoMessage(_("Macro Zoom Mode")); - else + } else { InfoMessage(""); - DoNewScale( zoomList[ i - 1 ].value ); - - } else InfoMessage("Minimum Macro Zoom"); + } + DoNewScale( zoomList[ i - 1 ].value ); + + } else { InfoMessage("Minimum Macro Zoom"); } } else { InfoMessage(_("Scale 1:1 - Use Ctrl+ to go to Macro Zoom Mode")); } } else if ( (MyGetKeyState()&WKEY_CTRL) == 0 ) { wPrefGetInteger( "misc", "zoomin", &newScale, 4 ); - InfoMessage(_("Preset Zoom In Value selected. Shift+Ctrl+PageDwn to reset value")); + InfoMessage( + _("Preset Zoom In Value selected. Shift+Ctrl+PageDwn to reset value")); DoNewScale( newScale ); } else { wPrefSetInteger( "misc", "zoomin", (long)mainD.scale ); - InfoMessage( _("Zoom In Program Value %ld:1, Shift+PageDwn to use"), (long)mainD.scale ); + InfoMessage( _("Zoom In Program Value %ld:1, Shift+PageDwn to use"), + (long)mainD.scale ); } } @@ -2202,31 +2417,33 @@ EXPORT void DoZoomUp( void * mode ) * Mode - 0 = Extents are Map size * Mode - 1 = Extents are Selected size */ -EXPORT void DoZoomExtents( void * mode) { +EXPORT void DoZoomExtents( void * mode) +{ DIST_T scale_x, scale_y; if ( 1 == VP2L(mode) ) { - if ( selectedTrackCount == 0 ) - return; - track_p trk = NULL; - coOrd bot, top; - BOOL_T first = TRUE; - while ( TrackIterate( &trk ) ) { - if(GetTrkSelected(trk)) { - coOrd hi, lo; - GetBoundingBox(trk,&hi,&lo); - if (first) { - first = FALSE; - bot = lo; - top = hi; - } else { - if (lo.x < bot.x) bot.x = lo.x; - if (lo.y < bot.y) bot.y = lo.y; - if (hi.x > top.x) top.x = hi.x; - if (hi.y > top.y) top.y = hi.y; - } - } + if ( selectedTrackCount == 0 ) { + return; + } + track_p trk = NULL; + coOrd bot, top; + BOOL_T first = TRUE; + while ( TrackIterate( &trk ) ) { + if(GetTrkSelected(trk)) { + coOrd hi, lo; + GetBoundingBox(trk,&hi,&lo); + if (first) { + first = FALSE; + bot = lo; + top = hi; + } else { + if (lo.x < bot.x) { bot.x = lo.x; } + if (lo.y < bot.y) { bot.y = lo.y; } + if (hi.x > top.x) { top.x = hi.x; } + if (hi.y > top.y) { top.y = hi.y; } + } } + } panCenter.x = (top.x/2)+(bot.x)/2; panCenter.y = (top.y/2)+(bot.y)/2; PanHere(I2VP(1)); @@ -2238,13 +2455,15 @@ EXPORT void DoZoomExtents( void * mode) { } - if (scale_x<scale_y) + if (scale_x<scale_y) { scale_x = scale_y; + } scale_x = ceil(scale_x); - if (scale_x < 1) scale_x = 1; - if (scale_x > MAX_MAIN_SCALE) scale_x = MAX_MAIN_SCALE; - if (1 != (intptr_t)1) + if (scale_x < 1) { scale_x = 1; } + if (scale_x > MAX_MAIN_SCALE) { scale_x = MAX_MAIN_SCALE; } + if (1 != (intptr_t)1) { mainD.orig = zero; + } DoNewScale(scale_x); MainLayout(TRUE,TRUE); @@ -2261,31 +2480,34 @@ EXPORT void DoZoomDown( void * mode) { long newScale; int i; - + LOG( log_zoom, 2, ( "DoZoomDown KS:%x\n", MyGetKeyState() ) ); if ( mode != NULL || (MyGetKeyState()&WKEY_SHIFT) == 0 ) { i = ScaleInx( mainD.scale ); - if (i < 0) i = NearestScaleInx(mainD.scale, TRUE); - if( i>= 0 && i < ( COUNT( zoomList ) - 1 )) { + if (i < 0) { i = NearestScaleInx(mainD.scale, TRUE); } + if( i >= 0 && i < ( COUNT( zoomList ) - 1 )) { InfoMessage(""); DoNewScale( zoomList[ i + 1 ].value ); - } else + } else { InfoMessage(_("At Maximum Zoom Out")); - - + } + + } else if ( (MyGetKeyState()&WKEY_CTRL) == 0 ) { wPrefGetInteger( "misc", "zoomout", &newScale, 16 ); - InfoMessage(_("Preset Zoom Out Value selected. Shift+Ctrl+PageUp to reset value")); + InfoMessage( + _("Preset Zoom Out Value selected. Shift+Ctrl+PageUp to reset value")); DoNewScale( newScale ); } else { wPrefSetInteger( "misc", "zoomout", (long)mainD.scale ); - InfoMessage( _("Zoom Out Program Value %ld:1 set, Shift+PageUp to use"), (long)mainD.scale ); + InfoMessage( _("Zoom Out Program Value %ld:1 set, Shift+PageUp to use"), + (long)mainD.scale ); } } /** - * Zoom to user selected value. This is the callback function for the - * user-selectable preset zoom values. + * Zoom to user selected value. This is the callback function for the + * user-selectable preset zoom values. * * \param IN scale current pScale * @@ -2295,26 +2517,27 @@ static void DoZoom( void * pScaleVP ) DIST_T *pScale = pScaleVP; DIST_T scale = *pScale; - if( scale != mainD.scale ) + if( scale != mainD.scale ) { DoNewScale( scale ); + } } EXPORT void Pix2CoOrd( - drawCmd_p d, - wDrawPix_t x, - wDrawPix_t y, - coOrd * pos ) + drawCmd_p d, + wDrawPix_t x, + wDrawPix_t y, + coOrd * pos ) { pos->x = (((DIST_T)x)/d->dpi)*d->scale+d->orig.x; pos->y = (((DIST_T)y)/d->dpi)*d->scale+d->orig.y; } EXPORT void CoOrd2Pix( - drawCmd_p d, - coOrd pos, - wDrawPix_t * x, - wDrawPix_t * y ) + drawCmd_p d, + coOrd pos, + wDrawPix_t * x, + wDrawPix_t * y ) { *x = (wDrawPix_t)((pos.x-d->orig.x)/d->scale*d->dpi); *y = (wDrawPix_t)((pos.y-d->orig.y)/d->scale*d->dpi); @@ -2330,20 +2553,24 @@ EXPORT void CoOrd2Pix( * - 2: same as 0, plus liveMap * - 3: Take position from menuPos */ -EXPORT void PanHere(void * mode) { +EXPORT void PanHere(void * mode) +{ if ( 3 == VP2L(mode ) ) { panCenter = menuPos; - LOG( log_pan, 2, ( "MCenter:Mod-%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); + LOG( log_pan, 2, ( "MCenter:Mod-%d %0.3f %0.3f\n", __LINE__, panCenter.x, + panCenter.y ) ); + } + wBool_t bLiveMap = TRUE; + if ( 2 == VP2L(mode) ) { + bLiveMap = liveMap; } mainD.orig.x = panCenter.x - mainD.size.x/2.0; mainD.orig.y = panCenter.y - mainD.size.y/2.0; wBool_t bNoBorder = (constrainMain != 0); if ( 1 != VP2L(mode) ) - if ( (MyGetKeyState()&WKEY_CTRL)!= 0 ) + if ( (MyGetKeyState()&WKEY_CTRL)!= 0 ) { bNoBorder = !bNoBorder; - wBool_t bLiveMap = TRUE; - if ( 2 == VP2L(mode) ) - bLiveMap = liveMap; + } MainLayout( bLiveMap, bNoBorder ); // PanHere } @@ -2365,44 +2592,52 @@ static int DoPanKeyAction( wAction_t action ) case wAccelKey_Right: panCenter.x = mainD.orig.x + mainD.size.x/2; panCenter.y = mainD.orig.y + mainD.size.y/2; - if ((MyGetKeyState() & WKEY_SHIFT) != 0) - panCenter.x += 0.25*mainD.scale; //~1cm in 1::1, 1ft in 30:1, 1mm in 10:1 - else + if ((MyGetKeyState() & WKEY_SHIFT) != 0) { + panCenter.x += 0.25*mainD.scale; //~1cm in 1::1, 1ft in 30:1, 1mm in 10:1 + } else { panCenter.x += mainD.size.x/2; - LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); + } + LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, + panCenter.y ) ); PanHere(I2VP(0)); break; case wAccelKey_Left: panCenter.x = mainD.orig.x + mainD.size.x/2; panCenter.y = mainD.orig.y + mainD.size.y/2; - if ((MyGetKeyState() & WKEY_SHIFT) != 0) + if ((MyGetKeyState() & WKEY_SHIFT) != 0) { panCenter.x -= 0.25*mainD.scale; - else + } else { panCenter.x -= mainD.size.x/2; - LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); + } + LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, + panCenter.y ) ); PanHere(I2VP(0)); break; case wAccelKey_Up: panCenter.x = mainD.orig.x + mainD.size.x/2; panCenter.y = mainD.orig.y + mainD.size.y/2; - if ((MyGetKeyState() & WKEY_SHIFT) != 0) + if ((MyGetKeyState() & WKEY_SHIFT) != 0) { panCenter.y += 0.25*mainD.scale; - else + } else { panCenter.y += mainD.size.y/2; - LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); + } + LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, + panCenter.y ) ); PanHere(I2VP(0)); break; case wAccelKey_Down: panCenter.x = mainD.orig.x + mainD.size.x/2; panCenter.y = mainD.orig.y + mainD.size.y/2; - if ((MyGetKeyState() & WKEY_SHIFT) != 0) + if ((MyGetKeyState() & WKEY_SHIFT) != 0) { panCenter.y -= 0.25*mainD.scale; - else + } else { panCenter.y -= mainD.size.y/2; - LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); + } + LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, + panCenter.y ) ); PanHere(I2VP(0)); break; @@ -2424,63 +2659,77 @@ static void DoMapPan( wAction_t action, coOrd pos ) switch (action & 0xFF) { case C_DOWN: - if ( mode == noPan ) + if ( mode == noPan ) { mode = movePan; - else + } else { break; + } case C_MOVE: - if ( mode != movePan ) + if ( mode != movePan ) { break; + } // mainD.orig.x = pos.x - mainD.size.x/2.0; // mainD.orig.y = pos.y - mainD.size.y/2.0; panCenter = pos; -LOG( log_pan, 1, ( "%s = [ %0.3f, %0.3f ]\n", action == C_DOWN? "START":"MOVE", mainD.orig.x, mainD.orig.y ) ) + LOG( log_pan, 1, ( "%s = [ %0.3f, %0.3f ]\n", action == C_DOWN? "START":"MOVE", + mainD.orig.x, mainD.orig.y ) ) PanHere( I2VP(2)); break; case C_UP: - if ( mode != movePan ) + if ( mode != movePan ) { break; + } panCenter = pos; PanHere( I2VP(0)); -LOG( log_pan, 1, ( "FINAL = [ %0.3f, %0.3f ]\n", mainD.orig.x, mainD.orig.y ) ) + LOG( log_pan, 1, ( "FINAL = [ %0.3f, %0.3f ]\n", mainD.orig.x, mainD.orig.y ) ) mode = noPan; break; case C_RDOWN: - if ( mode == noPan ) + if ( mode == noPan ) { mode = resizePan; - else + } else { break; + } mapOrig = pos; size.x = mainD.size.x/mainD.scale; //How big screen? size.y = mainD.size.y/mainD.scale; xscale = mainD.scale; //start at current panCenter = pos; -LOG( log_pan, 1, ( "START %0.3fx%0.3f %0.3f+%0.3f\n", mapOrig.x, mapOrig.y, size.x, size.y ) ) + LOG( log_pan, 1, ( "START %0.3fx%0.3f %0.3f+%0.3f\n", mapOrig.x, mapOrig.y, + size.x, size.y ) ) break; case C_RMOVE: - if ( mode != resizePan ) + if ( mode != resizePan ) { break; - if (pos.x < 0) + } + if (pos.x < 0) { pos.x = 0; - if (pos.x > mapD.size.x) + } + if (pos.x > mapD.size.x) { pos.x = mapD.size.x; - if (pos.y < 0) + } + if (pos.y < 0) { pos.y = 0; - if (pos.y > mapD.size.y) + } + if (pos.y > mapD.size.y) { pos.y = mapD.size.y; + } xscale = fabs((pos.x-mapOrig.x)*2.0/size.x); yscale = fabs((pos.y-mapOrig.y)*2.0/size.y); - if (xscale < yscale) + if (xscale < yscale) { xscale = yscale; + } xscale = ceil( xscale ); - if (xscale < 0.01) + if (xscale < 0.01) { xscale = 0.01; - if (xscale > 64) + } + if (xscale > 64) { xscale = 64; + } mainD.size.x = size.x * xscale; mainD.size.y = size.y * xscale; @@ -2488,13 +2737,15 @@ LOG( log_pan, 1, ( "START %0.3fx%0.3f %0.3f+%0.3f\n", mapOrig.x, mapOrig.y, size mainD.orig.y = mapOrig.y - mainD.size.y / 2.0; tempD.scale = mainD.scale = xscale; PanHere( I2VP(2)); -LOG( log_pan, 1, ( "MOVE SCL:%0.3f %0.3fx%0.3f %0.3f+%0.3f\n", xscale, mainD.orig.x, mainD.orig.y, mainD.size.x, mainD.size.y ) ) + LOG( log_pan, 1, ( "MOVE SCL:%0.3f %0.3fx%0.3f %0.3f+%0.3f\n", xscale, + mainD.orig.x, mainD.orig.y, mainD.size.x, mainD.size.y ) ) InfoScale(); - break; + break; case C_RUP: - if ( mode != resizePan ) + if ( mode != resizePan ) { break; + } DoNewScale( xscale ); mode = noPan; break; @@ -2515,13 +2766,12 @@ LOG( log_pan, 1, ( "MOVE SCL:%0.3f %0.3fx%0.3f %0.3f+%0.3f\n", xscale, mainD.ori /* * IsClose * is distance smaller than 10 pixels at 72 DPI? +* is distance smaller than 0.1" at 1:1? */ EXPORT BOOL_T IsClose( - DIST_T d ) + DIST_T d ) { - wDrawPix_t pd; - pd = (wDrawPix_t)(d/mainD.scale * mainD.dpi); - return pd <= closePixels; + return d <= closeDist*mainD.scale; } /***************************************************************************** @@ -2548,7 +2798,7 @@ EXPORT void FakeDownMouseState( void ) * * \param x OUT pointer x position * \param y OUT pointer y position - * \return + * \return */ void @@ -2560,7 +2810,8 @@ GetMousePosition( wDrawPix_t *x, wDrawPix_t *y ) } } -coOrd minIncrementSizes() { +coOrd minIncrementSizes() +{ double x,y; if (mainD.scale >= 1.0) { if (units == UNITS_ENGLISH) { @@ -2572,11 +2823,11 @@ coOrd minIncrementSizes() { } } else { if (units == UNITS_ENGLISH) { - x = 1/64; //<1:1 = 1/64 inch - y = 1/64; + x = 1.0/64.0; //<1:1 = 1/64 inch + y = 1.0/64.0; } else { - x = 1/(25.4*2); //>1:1 = 0.5 mm - y = 1/(25.4*2); + x = 1.0/(25.4*2); //>1:1 = 0.5 mm + y = 1.0/(25.4*2); } } coOrd ret; @@ -2591,8 +2842,12 @@ static void DoMouse( wAction_t action, coOrd pos ) BOOL_T rc; wDrawPix_t x, y; static BOOL_T ignoreCommands; + // Middle button pan state + static BOOL_T panActive = FALSE; + static coOrd panOrigin, panStart; - LOG( log_mouse, 2, ( "DoMouse( %d, %0.3f, %0.3f )\n", action, pos.x, pos.y ) ) + LOG( log_mouse, (action == wActionMove)?2:1, + ( "DoMouse( %d, %0.3f, %0.3f )\n", action, pos.x, pos.y ) ) if (recordF) { RecordMouse( "MOUSE", action, pos.x, pos.y ); @@ -2602,8 +2857,9 @@ static void DoMouse( wAction_t action, coOrd pos ) switch (action&0xFF) { case C_UP: - if (mouseState != mouseLeft) + if (mouseState != mouseLeft) { return; + } if (ignoreCommands) { ignoreCommands = FALSE; return; @@ -2611,29 +2867,43 @@ static void DoMouse( wAction_t action, coOrd pos ) mouseState = mouseNone; break; case C_RUP: - if (mouseState != mouseRight) + if (mouseState != mouseRight) { return; + } if (ignoreCommands) { ignoreCommands = FALSE; return; } mouseState = mouseNone; break; + case C_MUP: + if ( !panActive ) { + return; + } + if (ignoreCommands) { + ignoreCommands = FALSE; + return; + } + break; case C_MOVE: if (mouseState == mouseLeftPending ) { action = C_DOWN; mouseState = mouseLeft; } - if (mouseState != mouseLeft) + if (mouseState != mouseLeft) { + return; + } + if (ignoreCommands) { return; - if (ignoreCommands) - return; + } break; case C_RMOVE: - if (mouseState != mouseRight) + if (mouseState != mouseRight) { + return; + } + if (ignoreCommands) { return; - if (ignoreCommands) - return; + } break; case C_DOWN: mouseState = mouseLeft; @@ -2641,11 +2911,19 @@ static void DoMouse( wAction_t action, coOrd pos ) case C_RDOWN: mouseState = mouseRight; break; + case C_MDOWN: + // Set up state for Middle button pan + panActive = TRUE; + panOrigin = panCenter; + panStart.x = pos.x-mainD.orig.x; + panStart.y = pos.y-mainD.orig.y; + break; } inError = FALSE; - if ( deferSubstituteControls[0] ) + if ( deferSubstituteControls[0] ) { InfoSubstituteControls( deferSubstituteControls, deferSubstituteLabels ); + } // panCenter.y = mainD.orig.y + mainD.size.y/2; // panCenter.x = mainD.orig.x + mainD.size.x/2; @@ -2654,105 +2932,131 @@ static void DoMouse( wAction_t action, coOrd pos ) coOrd min = minIncrementSizes(); switch ( action&0xFF ) { - case C_DOWN: - case C_RDOWN: - tempSegs_da.cnt = 0; - break; - case wActionMove: - InfoPos( pos ); - if ( ignoreMoves ) - return; - break; - case wActionExtKey: - mainD.CoOrd2Pix(&mainD,pos,&x,&y); - if ((MyGetKeyState() & - (WKEY_SHIFT | WKEY_CTRL)) == (WKEY_SHIFT | WKEY_CTRL) && - ( action>>8 == wAccelKey_Up || - action>>8 == wAccelKey_Down || - action>>8 == wAccelKey_Left || - action>>8 == wAccelKey_Right )) - break; //Allow SHIFT+CTRL for Move - if (((action>>8)&0xFF) == wAccelKey_LineFeed) { - action = C_TEXT+((int)(0x0A<<8)); - break; - } - int rc = DoPanKeyAction(action); - if (rc!=1) return; - break; - case C_TEXT: - if ((action>>8) == 0x0D) { - action = C_OK; - } else if ((action>>8) == 0x1B) { - ConfirmReset( TRUE ); - return; - } - /*no break */ - case C_MODKEY: - case C_MOVE: - case C_UP: - case C_RMOVE: - case C_RUP: - case C_LDOUBLE: - InfoPos( pos ); - /*DrawTempTrack();*/ - break; - case C_WUP: - DoZoomUp(I2VP(1L)); - break; - case C_WDOWN: - DoZoomDown(I2VP(1L)); - break; - case C_SCROLLUP: - panCenter.y = panCenter.y + ((mainD.size.y/20>min.y)?mainD.size.y/20:min.y); - LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); - PanHere(I2VP(1)); - break; - case C_SCROLLDOWN: - panCenter.y = panCenter.y - ((mainD.size.y/20>min.y)?mainD.size.y/20:min.y); - LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); - PanHere(I2VP(1)); - break; - case C_SCROLLLEFT: - panCenter.x = panCenter.x - ((mainD.size.x/20>min.x)?mainD.size.x/20:min.x); - LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); - PanHere(I2VP(1)); - break; - case C_SCROLLRIGHT: - panCenter.x = panCenter.x + ((mainD.size.x/20>min.x)?mainD.size.x/20:min.x); - LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); - PanHere(I2VP(1)); - break; - default: - NoticeMessage( MSG_DOMOUSE_BAD_OP, _("Ok"), NULL, action&0xFF ); - break; + case C_DOWN: + case C_RDOWN: + DYNARR_RESET( trkSeg_t, tempSegs_da ); + break; + case C_MDOWN: + break; + case wActionMove: + InfoPos( pos ); + if ( ignoreMoves ) { + return; } - if (delayUpdate) - wDrawDelayUpdate( mainD.d, TRUE ); - rc = DoCurCommand( action, pos ); - wDrawDelayUpdate( mainD.d, FALSE ); - switch( rc ) { - case C_CONTINUE: - /*DrawTempTrack();*/ - break; - case C_ERROR: - ignoreCommands = TRUE; - inError = TRUE; - Reset(); - LOG( log_mouse, 1, ( "Mouse returns Error\n" ) ) - break; - case C_TERMINATE: - Reset(); - DoCurCommand( C_START, zero ); + break; + case wActionExtKey: + mainD.CoOrd2Pix(&mainD,pos,&x,&y); + if ((MyGetKeyState() & + (WKEY_SHIFT | WKEY_CTRL)) == (WKEY_SHIFT | WKEY_CTRL) && + ( action>>8 == wAccelKey_Up || + action>>8 == wAccelKey_Down || + action>>8 == wAccelKey_Left || + action>>8 == wAccelKey_Right )) { + break; //Allow SHIFT+CTRL for Move + } + if (((action>>8)&0xFF) == wAccelKey_LineFeed) { + action = C_TEXT+((int)(0x0A<<8)); break; - case C_INFO: - Reset(); + } + int rc = DoPanKeyAction(action); + if (rc!=1) { return; } + break; + case C_TEXT: + if ((action>>8) == 0x0D) { + action = C_OK; + } else if ((action>>8) == 0x1B) { + ConfirmReset( TRUE ); + return; + } + /*no break */ + case C_MODKEY: + case C_MOVE: + case C_UP: + case C_RMOVE: + case C_RUP: + case C_LDOUBLE: + case C_MUP: + InfoPos( pos ); + /*DrawTempTrack();*/ + break; + case C_WUP: + DoZoomUp(I2VP(1L)); + break; + case C_WDOWN: + DoZoomDown(I2VP(1L)); + break; + case C_SCROLLUP: + panCenter.y = panCenter.y + ((mainD.size.y/20>min.y)?mainD.size.y/20:min.y); + LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, + panCenter.y ) ); + PanHere(I2VP(1)); + break; + case C_SCROLLDOWN: + panCenter.y = panCenter.y - ((mainD.size.y/20>min.y)?mainD.size.y/20:min.y); + LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, + panCenter.y ) ); + PanHere(I2VP(1)); + break; + case C_SCROLLLEFT: + panCenter.x = panCenter.x - ((mainD.size.x/20>min.x)?mainD.size.x/20:min.x); + LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, + panCenter.y ) ); + PanHere(I2VP(1)); + break; + case C_SCROLLRIGHT: + panCenter.x = panCenter.x + ((mainD.size.x/20>min.x)?mainD.size.x/20:min.x); + LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, + panCenter.y ) ); + PanHere(I2VP(1)); + break; + case C_MMOVE: + // Middle button pan + if ( !panActive ) { break; } + panCenter.x = panOrigin.x + (panStart.x - ( pos.x - mainD.orig.x ) ); + panCenter.y = panOrigin.y + (panStart.y - ( pos.y - mainD.orig.y ) ); + if ( panCenter.x < 0 ) { panCenter.x = 0; } + if ( panCenter.x > mapD.size.x ) { panCenter.x = mapD.size.x; } + if ( panCenter.y < 0 ) { panCenter.y = 0; } + if ( panCenter.y > mapD.size.y ) { panCenter.y = mapD.size.y; } + LOG( log_pan, 1, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, + panCenter.x, panCenter.y ) ); + PanHere(I2VP(1)); + break; + default: + NoticeMessage( MSG_DOMOUSE_BAD_OP, _("Ok"), NULL, action&0xFF ); + break; + } + if (delayUpdate) { + wDrawDelayUpdate( mainD.d, TRUE ); + } + rc = DoCurCommand( action, pos ); + wDrawDelayUpdate( mainD.d, FALSE ); + switch( rc ) { + case C_CONTINUE: + /*DrawTempTrack();*/ + break; + case C_ERROR: + ignoreCommands = TRUE; + inError = TRUE; + Reset(); + LOG( log_mouse, 1, ( "Mouse returns Error\n" ) ) + break; + case C_TERMINATE: + Reset(); + DoCurCommand( C_START, zero ); + break; + case C_INFO: + Reset(); + break; + } } wDrawPix_t autoPanFactor = 10; -static void DoMousew( wDraw_p d, void * context, wAction_t action, wDrawPix_t x, wDrawPix_t y ) +static void DoMousew( wDraw_p d, void * context, wAction_t action, wDrawPix_t x, + wDrawPix_t y ) { coOrd pos; coOrd orig; @@ -2761,8 +3065,9 @@ static void DoMousew( wDraw_p d, void * context, wAction_t action, wDrawPix_t x, DIST_T minDist; wDrawGetSize( mainD.d, &w, &h ); if ( autoPan && !inPlayback ) { - if ( action == wActionLDown || action == wActionRDown || - (action == wActionLDrag && mouseState == mouseLeftPending ) /*|| + if ( action == wActionLDown || action == wActionRDown + || action == wActionScrollDown || + (action == wActionLDrag && mouseState == mouseLeftPending ) /*|| (action == wActionRDrag && mouseState == mouseRightPending ) */ ) { lastX = x; lastY = y; @@ -2770,39 +3075,45 @@ static void DoMousew( wDraw_p d, void * context, wAction_t action, wDrawPix_t x, if ( action == wActionLDrag || action == wActionRDrag ) { orig = mainD.orig; if ( ( x < 10 && x < lastX ) || - ( x > w-10 && x > lastX ) || - ( y < 10 && y < lastY ) || - ( y > h-10 && y > lastY ) ) { + ( x > w-10 && x > lastX ) || + ( y < 10 && y < lastY ) || + ( y > h-10 && y > lastY ) ) { mainD.Pix2CoOrd( &mainD, x, y, &pos ); - orig.x = mainD.orig.x + (pos.x - (mainD.orig.x + mainD.size.x/2.0) )/autoPanFactor; - orig.y = mainD.orig.y + (pos.y - (mainD.orig.y + mainD.size.y/2.0) )/autoPanFactor; + orig.x = mainD.orig.x + (pos.x - (mainD.orig.x + + mainD.size.x/2.0) )/autoPanFactor; + orig.y = mainD.orig.y + (pos.y - (mainD.orig.y + + mainD.size.y/2.0) )/autoPanFactor; if ( orig.x != mainD.orig.x || orig.y != mainD.orig.y ) { if ( mainD.scale >= 1 ) { - if ( units == UNITS_ENGLISH ) + if ( units == UNITS_ENGLISH ) { minDist = 1.0; - else + } else { minDist = 1.0/2.54; + } if ( orig.x != mainD.orig.x ) { if ( fabs( orig.x-mainD.orig.x ) < minDist ) { - if ( orig.x < mainD.orig.x ) + if ( orig.x < mainD.orig.x ) { orig.x -= minDist; - else + } else { orig.x += minDist; + } } } if ( orig.y != mainD.orig.y ) { if ( fabs( orig.y-mainD.orig.y ) < minDist ) { - if ( orig.y < mainD.orig.y ) + if ( orig.y < mainD.orig.y ) { orig.y -= minDist; - else + } else { orig.y += minDist; + } } } } mainD.orig = orig; panCenter.x = mainD.orig.x + mainD.size.x/2.0; panCenter.y = mainD.orig.y + mainD.size.y/2.0; - LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); + LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, + panCenter.y ) ); MainLayout( TRUE, TRUE ); // DoMouseW: autopan tempD.orig = mainD.orig; wFlush(); @@ -2822,6 +3133,7 @@ static void DoMousew( wDraw_p d, void * context, wAction_t action, wDrawPix_t x, case wActionRDrag: case wActionRUp: case wActionLDownDouble: + case wActionMDrag: mousePositionx = x; mousePositiony = y; break; @@ -2844,7 +3156,8 @@ static wBool_t PlaybackMain( char * line ) SetCLocale(); - rc=sscanf( line, "%d " SCANF_FLOAT_FORMAT SCANF_FLOAT_FORMAT, &action, &pos.x, &pos.y); + rc=sscanf( line, "%d " SCANF_FLOAT_FORMAT SCANF_FLOAT_FORMAT, &action, &pos.x, + &pos.y); SetUserLocale(); if (rc != 3) { @@ -2863,7 +3176,8 @@ static wBool_t PlaybackKey( char * line ) int c; SetCLocale(); - rc=sscanf( line, "%d " SCANF_FLOAT_FORMAT SCANF_FLOAT_FORMAT, &c, &pos.x, &pos.y ); + rc=sscanf( line, "%d " SCANF_FLOAT_FORMAT SCANF_FLOAT_FORMAT, &c, &pos.x, + &pos.y ); SetUserLocale(); if (rc != 3) { @@ -2881,92 +3195,108 @@ static wBool_t PlaybackKey( char * line ) * */ -static paramDrawData_t mapDrawData = { 100, 100, MapRedraw, DoMapPan, &mapD }; +static paramDrawData_t mapDrawData = { 50, 50, MapRedraw, DoMapPan, &mapD }; static paramData_t mapPLs[] = { - { PD_DRAW, NULL, "canvas", 0, &mapDrawData } }; + { PD_DRAW, NULL, "canvas", PDO_DLGRESIZE, &mapDrawData } +}; static paramGroup_t mapPG = { "map", PGO_NODEFAULTPROC, mapPLs, COUNT( mapPLs ) }; -static void MapDlgUpdate( - paramGroup_p pg, - int inx, - void * valueP ) -{ - wWinPix_t width,height; - switch(inx) { - case wResize_e: - if (mapD.d == NULL) - return; - wWinGetSize( mapW, &width, &height ); - if (height >= 100) { - wControlSetPos( (wControl_p)mapD.d, 0, 0 ); - double scaleX = (mapD.size.x/((width-DlgSepLeft-DlgSepRight-10)/mapD.dpi)); - double scaleY = (mapD.size.y/((height-DlgSepTop-DlgSepBottom-10)/mapD.dpi)); - double scale; - - if (scaleX<scaleY) scale = scaleX; - else scale = scaleY; - - if (scale > MAX_MAIN_SCALE) scale = MAX_MAIN_SCALE; - if (scale < MIN_MAIN_MACRO) scale = MIN_MAIN_MACRO; - - mapScale = (long)scale; - - mapD.scale = mapScale; - ChangeMapScale(FALSE); - - if (mapVisible) { - MapRedraw( mapD.d, NULL, 0, 0 ); - } - wPrefSetInteger( "draw", "mapscale", (long)mapD.scale ); - } - break; - case -1: - MapWindowShow( FALSE ); - break; - default: - break; - } -} - static void DrawChange( long changes ) { if (changes & CHANGE_MAIN) { MainLayout( TRUE, FALSE ); // DrawChange: CHANGE_MAIN } - if (changes &CHANGE_UNITS) + if (changes &CHANGE_UNITS) { SetInfoBar(); - if (changes & CHANGE_MAP) - MapResize(); + } + if (changes & CHANGE_MAP) { + LOG( log_mapsize, 2, ( "CHANGE_MAP: mapD.scale=%0.3f\n", mapD.scale ) ); + ChangeMapScale(); + } } static void MainLayoutCB( - wDraw_p bd, void * pContex, wWinPix_t px, wWinPix_t py ) + wDraw_p bd, void * pContex, wWinPix_t px, wWinPix_t py ) { MainLayout( TRUE, FALSE ); } +EXPORT void InitColor( void ) +{ + drawColorBlack = wDrawFindColor( wRGB( 0, 0, 0) ); + drawColorWhite = wDrawFindColor( wRGB(255,255,255) ); + drawColorRed = wDrawFindColor( wRGB(255, 0, 0) ); + drawColorBlue = wDrawFindColor( wRGB( 0, 0,255) ); + drawColorGreen = wDrawFindColor( wRGB( 0,255, 0) ); + drawColorAqua = wDrawFindColor( wRGB( 0,255,255) ); + drawColorDkRed = wDrawFindColor( wRGB(128, 0, 0) ); + drawColorDkBlue = wDrawFindColor( wRGB( 0, 0,128) ); + drawColorDkGreen= wDrawFindColor( wRGB( 0,128, 0) ); + drawColorDkAqua = wDrawFindColor( wRGB( 0,128,128) ); + + // Last component of spectial color must be > 3 + drawColorPreviewSelected = wDrawFindColor( wRGB ( 6, 6, 255) ); //Special Blue + drawColorPreviewUnselected = wDrawFindColor( wRGB( 255, 215, + 6)); //Special Yellow + + drawColorPowderedBlue = wDrawFindColor( wRGB(129, 212, 250) ); + drawColorPurple = wDrawFindColor( wRGB(128, 0,128) ); + drawColorMagenta = wDrawFindColor( wRGB(255, 0, 255) ); + drawColorGold = wDrawFindColor( wRGB(255,215, 0) ); + drawColorGrey10 = wDrawFindColor( wRGB(26,26,26) ); + drawColorGrey20 = wDrawFindColor( wRGB(51,51,51) ); + drawColorGrey30 = wDrawFindColor( wRGB(72,72,72) ); + drawColorGrey40 = wDrawFindColor( wRGB(102,102,102) ); + drawColorGrey50 = wDrawFindColor( wRGB(128,128,128) ); + drawColorGrey60 = wDrawFindColor( wRGB(153,153,153) ); + drawColorGrey70 = wDrawFindColor( wRGB(179,179,179) ); + drawColorGrey80 = wDrawFindColor( wRGB(204,204,204) ); + drawColorGrey90 = wDrawFindColor( wRGB(230,230,230) ); + snapGridColor = drawColorGreen; + markerColor = drawColorRed; + borderColor = drawColorBlack; + crossMajorColor = drawColorRed; + crossMinorColor = drawColorBlue; + selectedColor = drawColorRed; + normalColor = drawColorBlack; + elevColorIgnore = drawColorBlue; + elevColorDefined = drawColorGold; + profilePathColor = drawColorPurple; + exceptionColor = wDrawFindColor(wRGB(255, 89, 0 )); + tieColor = wDrawFindColor(wRGB(153, 89, 68)); +} + + EXPORT void DrawInit( int initialZoom ) { wWinPix_t w, h; + log_pan = LogFindIndex( "pan" ); + log_zoom = LogFindIndex( "zoom" ); + log_mouse = LogFindIndex( "mouse" ); + log_redraw = LogFindIndex( "redraw" ); + log_timemainredraw = LogFindIndex( "timemainredraw" ); + log_mapsize = LogFindIndex( "mapsize" ); +// InitColor(); wWinGetSize( mainW, &w, &h ); /*LayoutToolBar();*/ h = h - (toolbarHeight+max(textHeight,infoHeight)+10); - if ( w <= 0 ) w = 1; - if ( h <= 0 ) h = 1; - tempD.d = mainD.d = wDrawCreate( mainW, 0, toolbarHeight, "", BD_TICKS|BD_MODKEYS, - w, h, &mainD, - MainLayoutCB, DoMousew ); + if ( w <= 0 ) { w = 1; } + if ( h <= 0 ) { h = 1; } + tempD.d = mainD.d = wDrawCreate( mainW, 0, toolbarHeight, "", + BD_TICKS|BD_MODKEYS, + w, h, &mainD, + MainLayoutCB, DoMousew ); if (initialZoom == 0) { WDOUBLE_T tmpR; wPrefGetFloat( "draw", "zoom", &tmpR, mainD.scale ); mainD.scale = tmpR; - } else { + } else { while (initialZoom > 0 && mainD.scale < MAX_MAIN_SCALE) { mainD.scale *= 2; initialZoom--; @@ -2986,38 +3316,33 @@ EXPORT void DrawInit( int initialZoom ) SetMainSize(); panCenter.x = mainD.size.x/2 +mainD.orig.x; panCenter.y = mainD.size.y/2 +mainD.orig.y; - mapD.scale = mapScale; /*w = (wWinPix_t)((mapD.size.x/mapD.scale)*mainD.dpi + 0.5)+2;*/ /*h = (wWinPix_t)((mapD.size.y/mapD.scale)*mainD.dpi + 0.5)+2;*/ ParamRegister( &mapPG ); - mapW = ParamCreateDialog( &mapPG, MakeWindowTitle(_("Map")), NULL, NULL, NULL, FALSE, NULL, F_RESIZE, MapDlgUpdate ); - ChangeMapScale(TRUE); - - log_pan = LogFindIndex( "pan" ); - log_zoom = LogFindIndex( "zoom" ); - log_mouse = LogFindIndex( "mouse" ); - log_redraw = LogFindIndex( "redraw" ); - log_timemainredraw = LogFindIndex( "timemainredraw" ); + LOG( log_mapsize, 2, ( "DrawInit/ParamCreateDialog(&mapPG\n" ) ); + mapW = ParamCreateDialog( &mapPG, MakeWindowTitle(_("Map")), NULL, NULL, NULL, + FALSE, NULL, F_RESIZE, NULL ); + ChangeMapScale(); AddPlaybackProc( "MOUSE ", (playbackProc_p)PlaybackMain, NULL ); AddPlaybackProc( "KEY ", (playbackProc_p)PlaybackKey, NULL ); rulerFp = wStandardFont( F_HELV, FALSE, FALSE ); - SetZoomRadio( mainD.scale ); + SetZoomRadio( mainD.scale ); InfoScale(); SetInfoBar(); InfoPos( zero ); RegisterChangeNotification( DrawChange ); } -#include "bitmaps/pan-zoom.xpm" +#include "bitmaps/pan-zoom.xpm3" -EXPORT static wMenu_p panPopupM; +static wMenu_p panPopupM; static STATUS_T CmdPan( - wAction_t action, - coOrd pos ) + wAction_t action, + coOrd pos ) { static enum { PAN, ZOOM, NONE } panmode; @@ -3035,10 +3360,11 @@ static STATUS_T CmdPan( switch (action&0xFF) { case C_START: start_pos = zero; - panmode = NONE; - InfoMessage(_("Left-Drag to pan, Ctrl+Left-Drag to zoom, 0 to set origin to zero, 1-9 to zoom#, e to set to extents")); - wSetCursor(mainD.d,wCursorSizeAll); - break; + panmode = NONE; + InfoMessage( + _("Left-Drag to pan, Ctrl+Left-Drag to zoom, 0 to set origin to zero, 1-9 to zoom#, e to set to extents")); + wSetCursor(mainD.d,wCursorSizeAll); + break; case C_DOWN: if ((MyGetKeyState()&WKEY_CTRL) == 0) { panmode = PAN; @@ -3055,33 +3381,36 @@ static STATUS_T CmdPan( break; case C_MOVE: if (panmode == PAN) { - double min_inc; - if (mainD.scale >= 1.0) { - if (units == UNITS_ENGLISH) { - min_inc = 1/4; //>1:1 = 1/4 inch - } else { - min_inc = 1/(2.54*2); //>1:1 = 0.5 cm - } + double min_inc; + if (mainD.scale >= 1.0) { + if (units == UNITS_ENGLISH) { + min_inc = 1.0/4.0; //>1:1 = 1/4 inch } else { - if (units == UNITS_ENGLISH) { - min_inc = 1/64; //<1:1 = 1/64 inch - } else { - min_inc = 1/(25.4*2); //>1:1 = 0.5 mm - } + min_inc = 1.0/(2.54*2); //>1:1 = 0.5 cm } - if ((fabs(pos.x-start_pos.x) > min_inc) || (fabs(pos.y-start_pos.y) > min_inc)) { - coOrd oldOrig = mainD.orig; - mainD.orig.x -= (pos.x - start_pos.x); - mainD.orig.y -= (pos.y - start_pos.y); - if ((MyGetKeyState()&WKEY_SHIFT) != 0) - ConstraintOrig(&mainD.orig,mainD.size,TRUE,TRUE); - if ((oldOrig.x == mainD.orig.x) && (oldOrig.y == mainD.orig.y)) - InfoMessage(_("Can't move any further in that direction")); - else - InfoMessage(_("Left click to pan, right click to zoom, 'o' for origin, 'e' for extents")); + } else { + if (units == UNITS_ENGLISH) { + min_inc = 1.0/64.0; //<1:1 = 1/64 inch + } else { + min_inc = 1.0/(25.4*2); //>1:1 = 0.5 mm } } - else if (panmode == ZOOM) { + if ((fabs(pos.x-start_pos.x) > min_inc) + || (fabs(pos.y-start_pos.y) > min_inc)) { + coOrd oldOrig = mainD.orig; + mainD.orig.x -= (pos.x - start_pos.x); + mainD.orig.y -= (pos.y - start_pos.y); + if ((MyGetKeyState()&WKEY_SHIFT) != 0) { + ConstraintOrig(&mainD.orig,mainD.size,TRUE,TRUE); + } + if ((oldOrig.x == mainD.orig.x) && (oldOrig.y == mainD.orig.y)) { + InfoMessage(_("Can't move any further in that direction")); + } else { + InfoMessage( + _("Left click to pan, right click to zoom, 'o' for origin, 'e' for extents")); + } + } + } else if (panmode == ZOOM) { base = start_pos; size.x = pos.x - base.x; if (size.x < 0) { @@ -3103,32 +3432,36 @@ static STATUS_T CmdPan( scale_x = size.x/mainD.size.x*mainD.scale; scale_y = size.y/mainD.size.y*mainD.scale; - if (scale_x<scale_y) - scale_x = scale_y; - if (scale_x>1) scale_x = ceil( scale_x ); - else scale_x = 1/(ceil(1/scale_x)); + if (scale_x<scale_y) { + scale_x = scale_y; + } + if (scale_x>1) { scale_x = ceil( scale_x ); } + else { scale_x = 1/(ceil(1/scale_x)); } - if (scale_x > MAX_MAIN_SCALE) scale_x = MAX_MAIN_SCALE; - if (scale_x < MIN_MAIN_MACRO) scale_x = MIN_MAIN_MACRO; + if (scale_x > MAX_MAIN_SCALE) { scale_x = MAX_MAIN_SCALE; } + if (scale_x < MIN_MAIN_MACRO) { scale_x = MIN_MAIN_MACRO; } mainD.orig.x = base.x; mainD.orig.y = base.y; panmode = NONE; - InfoMessage(_("Left Drag to Pan, +CTRL to Zoom, 0 to set Origin to 0,0, 1-9 to Zoom#, e to set to Extent")); + InfoMessage( + _("Left Drag to Pan, +CTRL to Zoom, 0 to set Origin to 0,0, 1-9 to Zoom#, e to set to Extent")); DoNewScale(scale_x); break; } else if (panmode == PAN) { panCenter.x = mainD.orig.x + mainD.size.x/2.0; panCenter.y = mainD.orig.y + mainD.size.y/2.0; - LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); + LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, + panCenter.y ) ); panmode = NONE; } break; case C_REDRAW: if (panmode == ZOOM) { - if (base.x && base.y && size.x && size.y) + if (base.x && base.y && size.x && size.y) { DrawHilight( &tempD, base, size, TRUE ); + } } break; case C_CANCEL: @@ -3146,14 +3479,16 @@ static STATUS_T CmdPan( mainD.orig = zero; panCenter.x = mainD.size.x/2.0; panCenter.y = mainD.size.y/2.0; - LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); + LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, + panCenter.y ) ); MainLayout( TRUE, TRUE ); // CmdPan C_TEXT '0' 'o' } else if ((action>>8) >= '1' && (action>>8) <= '9') { //"1" to "9" scale_x = (action>>8)&0x0F; DoNewScale(scale_x); } else if ((action>>8) == 'c') { // "c" panCenter = pos; - LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); + LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, + panCenter.y ) ); PanHere( I2VP(0)); // CmdPan C_TEXT 'c' } @@ -3175,7 +3510,8 @@ static STATUS_T CmdPan( return C_CONTINUE; } static wMenuPush_p zoomExtents,panOrig,panHere; -static wMenuPush_p zoomLvl1,zoomLvl2,zoomLvl3,zoomLvl4,zoomLvl5,zoomLvl6,zoomLvl7,zoomLvl8,zoomLvl9; +static wMenuPush_p zoomLvl1,zoomLvl2,zoomLvl3,zoomLvl4,zoomLvl5,zoomLvl6, + zoomLvl7,zoomLvl8,zoomLvl9; EXPORT void PanMenuEnter( void * keyVP ) { @@ -3186,35 +3522,47 @@ EXPORT void PanMenuEnter( void * keyVP ) CmdPan(action,zero); } -extern wIndex_t selectCmdInx; -extern wIndex_t describeCmdInx; -extern wIndex_t joinCmdInx; -extern wIndex_t modifyCmdInx; EXPORT void InitCmdPan( wMenu_p menu ) { - panCmdInx = AddMenuButton( menu, CmdPan, "cmdPan", _("Pan/Zoom"), wIconCreatePixMap(pan_zoom_xpm[iconSize]), - LEVEL0, IC_CANCEL|IC_POPUP|IC_LCLICK|IC_CMDMENU, ACCL_PAN, NULL ); + panCmdInx = AddMenuButton( menu, CmdPan, "cmdPan", _("Pan/Zoom"), + wIconCreatePixMap(pan_zoom_xpm3[iconSize]), + LEVEL0, IC_CANCEL|IC_POPUP|IC_LCLICK|IC_CMDMENU, ACCL_PAN, NULL ); } EXPORT void InitCmdPan2( wMenu_p menu ) { panPopupM = MenuRegister( "Pan Options" ); - wMenuPushCreate(panPopupM, "cmdSelectMode", GetBalloonHelpStr("cmdSelectMode"), 0, DoCommandB, I2VP(selectCmdInx)); - wMenuPushCreate(panPopupM, "cmdDescribeMode", GetBalloonHelpStr("cmdDescribeMode"), 0, DoCommandB, I2VP(describeCmdInx)); - wMenuPushCreate(panPopupM, "cmdModifyMode", GetBalloonHelpStr("cmdModifyMode"), 0, DoCommandB, I2VP(modifyCmdInx)); + wMenuPushCreate(panPopupM, "cmdSelectMode", GetBalloonHelpStr("cmdSelectMode"), + 0, DoCommandB, I2VP(selectCmdInx)); + wMenuPushCreate(panPopupM, "cmdDescribeMode", + GetBalloonHelpStr("cmdDescribeMode"), 0, DoCommandB, I2VP(describeCmdInx)); + wMenuPushCreate(panPopupM, "cmdModifyMode", GetBalloonHelpStr("cmdModifyMode"), + 0, DoCommandB, I2VP(modifyCmdInx)); wMenuSeparatorCreate(panPopupM); - zoomExtents = wMenuPushCreate( panPopupM, "", _("Zoom to extents - 'e'"), 0, PanMenuEnter, I2VP( 'e')); - zoomLvl1 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:1 - '1'"), 0, PanMenuEnter, I2VP( '1')); - zoomLvl2 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:2 - '2'"), 0, PanMenuEnter, I2VP( '2')); - zoomLvl3 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:3 - '3'"), 0, PanMenuEnter, I2VP( '3')); - zoomLvl4 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:4 - '4'"), 0, PanMenuEnter, I2VP( '4')); - zoomLvl5 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:5 - '5'"), 0, PanMenuEnter, I2VP( '5')); - zoomLvl6 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:6 - '6'"), 0, PanMenuEnter, I2VP( '6')); - zoomLvl7 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:7 - '7'"), 0, PanMenuEnter, I2VP( '7')); - zoomLvl8 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:8 - '8'"), 0, PanMenuEnter, I2VP( '8')); - zoomLvl9 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:9 - '9'"), 0, PanMenuEnter, I2VP( '9')); - panOrig = wMenuPushCreate( panPopupM, "", _("Pan to Origin - 'o'/'0'"), 0, PanMenuEnter, I2VP( 'o')); + zoomExtents = wMenuPushCreate( panPopupM, "", _("Zoom to extents - 'e'"), 0, + PanMenuEnter, I2VP( 'e')); + zoomLvl1 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:1 - '1'"), 0, + PanMenuEnter, I2VP( '1')); + zoomLvl2 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:2 - '2'"), 0, + PanMenuEnter, I2VP( '2')); + zoomLvl3 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:3 - '3'"), 0, + PanMenuEnter, I2VP( '3')); + zoomLvl4 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:4 - '4'"), 0, + PanMenuEnter, I2VP( '4')); + zoomLvl5 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:5 - '5'"), 0, + PanMenuEnter, I2VP( '5')); + zoomLvl6 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:6 - '6'"), 0, + PanMenuEnter, I2VP( '6')); + zoomLvl7 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:7 - '7'"), 0, + PanMenuEnter, I2VP( '7')); + zoomLvl8 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:8 - '8'"), 0, + PanMenuEnter, I2VP( '8')); + zoomLvl9 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:9 - '9'"), 0, + PanMenuEnter, I2VP( '9')); + panOrig = wMenuPushCreate( panPopupM, "", _("Pan to Origin - 'o'/'0'"), 0, + PanMenuEnter, I2VP( 'o')); wMenu_p zoomPanM = wMenuMenuCreate(panPopupM, "", _("&Zoom")); InitCmdZoom(NULL, NULL, NULL, zoomPanM); - panHere = wMenuPushCreate( panPopupM, "", _("Pan center here - 'c'"), 0, PanHere, I2VP( 3)); + panHere = wMenuPushCreate( panPopupM, "", _("Pan center here - 'c'"), 0, + PanHere, I2VP( 3)); } diff --git a/app/bin/draw.h b/app/bin/draw.h index 4942b8d..0ddf547 100644 --- a/app/bin/draw.h +++ b/app/bin/draw.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef DRAW_H @@ -44,6 +44,8 @@ #define DC_TEMP (1<<6) // OUTLINE: use outline font #define DC_OUTLINE (1<<7) +// Round pixel pos for performance +#define DC_ROUND (1<<8) // Line styles #define DC_THICK (1<<9) @@ -64,44 +66,48 @@ typedef enum { DRAW_OPEN, DRAW_CLOSED, DRAW_FILL, DRAW_TRANSPARENT } drawFill_e; +struct drawCmd_t; typedef struct drawCmd_t * drawCmd_p; typedef struct { - void (*drawLine)(drawCmd_p, coOrd, coOrd, wDrawWidth, wDrawColor); - void (*drawArc)(drawCmd_p, coOrd, DIST_T, ANGLE_T, ANGLE_T, BOOL_T, wDrawWidth, - wDrawColor); - void (*drawString)(drawCmd_p, coOrd, ANGLE_T, char *, wFont_p, FONTSIZE_T, - wDrawColor); - void (*drawBitMap)(drawCmd_p, coOrd, wDrawBitMap_p, wDrawColor); - void (*drawPoly)(drawCmd_p, int, coOrd *, int *, wDrawColor, wDrawWidth, drawFill_e); - void (*drawFillCircle)(drawCmd_p, coOrd, DIST_T, wDrawColor); - void (*drawRectangle)(drawCmd_p, coOrd, coOrd, wDrawColor, drawFill_e); + void (*drawLine)(drawCmd_p, coOrd, coOrd, wDrawWidth, wDrawColor); + void (*drawArc)(drawCmd_p, coOrd, DIST_T, ANGLE_T, ANGLE_T, BOOL_T, wDrawWidth, + wDrawColor); + void (*drawString)(drawCmd_p, coOrd, ANGLE_T, char *, wFont_p, FONTSIZE_T, + wDrawColor); + void (*drawBitMap)(drawCmd_p, coOrd, wDrawBitMap_p, wDrawColor); + void (*drawPoly)(drawCmd_p, int, coOrd *, int *, wDrawColor, wDrawWidth, + drawFill_e); + void (*drawFillCircle)(drawCmd_p, coOrd, DIST_T, wDrawColor); + void (*drawRectangle)(drawCmd_p, coOrd, coOrd, wDrawColor, drawFill_e); } drawFuncs_t; -typedef void (*drawConvertPix2CoOrd)(drawCmd_p, wDrawPix_t, wDrawPix_t, coOrd *); -typedef void (*drawConvertCoOrd2Pix)(drawCmd_p, coOrd, wDrawPix_t *, wDrawPix_t *); +typedef void (*drawConvertPix2CoOrd)(drawCmd_p, wDrawPix_t, wDrawPix_t, + coOrd *); +typedef void (*drawConvertCoOrd2Pix)(drawCmd_p, coOrd, wDrawPix_t *, + wDrawPix_t *); typedef struct drawCmd_t { - wDraw_p d; - drawFuncs_t * funcs; - unsigned long options; - DIST_T scale; - ANGLE_T angle; - coOrd orig; - coOrd size; - drawConvertPix2CoOrd Pix2CoOrd; - drawConvertCoOrd2Pix CoOrd2Pix; - FLOAT_T dpi; + wDraw_p d; + drawFuncs_t * funcs; + unsigned long options; + DIST_T scale; + ANGLE_T angle; + coOrd orig; + coOrd size; + drawConvertPix2CoOrd Pix2CoOrd; + drawConvertCoOrd2Pix CoOrd2Pix; + FLOAT_T dpi; } drawCmd_t; #define SCALEX(D,X) ((X)/(D).dpi) #define SCALEY(D,Y) ((Y)/(D).dpi) #ifdef WINDOWS - #define LBORDER (33) - #define BBORDER (32) +#define LBORDER (33) +#define BBORDER (32) #else - #define LBORDER (26) - #define BBORDER (27) +#define LBORDER (26) +#define BBORDER (27) #endif #define RBORDER (9) #define TBORDER (8) @@ -120,7 +126,6 @@ extern drawCmd_t mapD; extern drawCmd_t tempD; #define RoomSize (mapD.size) extern coOrd oldMarker; -extern wDrawPix_t closePixels; #define dragDistance (dragPixels*mainD.scale / mainD.dpi) extern long dragPixels; extern long dragTimeout; @@ -129,12 +134,16 @@ extern long minGridSpacing; extern long drawCount; extern BOOL_T drawEnable; extern long currRedraw; +extern long constrainMain; +extern long liveMap; +extern long descriptionFontSize; extern coOrd panCenter; extern coOrd menuPos; extern int log_pan; +extern wBool_t wDrawDoTempDraw; extern wDrawColor drawColorBlack; extern wDrawColor drawColorWhite; @@ -142,8 +151,13 @@ extern wDrawColor drawColorRed; extern wDrawColor drawColorBlue; extern wDrawColor drawColorGreen; extern wDrawColor drawColorAqua; +extern wDrawColor drawColorDkRed; +extern wDrawColor drawColorDkBlue; +extern wDrawColor drawColorDkGreen; +extern wDrawColor drawColorDkAqua; extern wDrawColor drawColorPowderedBlue; extern wDrawColor drawColorPurple; +extern wDrawColor drawColorMagenta; extern wDrawColor drawColorGold; extern wDrawColor drawColorGrey10; extern wDrawColor drawColorGrey20; @@ -219,14 +233,15 @@ extern drawFuncs_t printDrawFuncs; void DrawHilight(drawCmd_p, coOrd, coOrd, BOOL_T add); void DrawHilightPolygon(drawCmd_p, coOrd *, int); -#define BOX_NONE (0) -#define BOX_UNDERLINE (1) -#define BOX_BOX (2) -#define BOX_INVERT (3) -#define BOX_ARROW (4) -#define BOX_BACKGROUND (5) -#define BOX_ARROW_BACKGROUND (6) -#define BOX_BOX_BACKGROUND (7) +#define BOX_NONE (0) // do not draw a frame around text +#define BOX_UNDERLINE (1) // draw underline under text only +#define BOX_BOX (2) // draw a frame around text +#define BOX_INVERT (3) // invert colors, text is drawn gray +#define BOX_ARROW (4) // box has a connector +#define BOX_BACKGROUND (5) // draw box with backgound only, no frame +#define BOX_ARROW_BACKGROUND (6) // box has a connector and background +#define BOX_BOX_BACKGROUND (7) // draw complete frame and background + void DrawBoxedString(int, drawCmd_p, coOrd, char *, wFont_p, wFontSize_t, wDrawColor, ANGLE_T); void DrawMultiLineTextSize(drawCmd_p dp, char * text, wFont_p fp, @@ -241,7 +256,6 @@ void TranslateBackground(drawCmd_p drawP, POS_T origX, POS_T origY, wWinPix_t* posX, wWinPix_t* posY, wWinPix_t* pWidth); BOOL_T SetRoomSize(coOrd); -void GetRoomSize(coOrd *); void DoRedraw(void); void SetMainSize(void); void MainRedraw(void); @@ -250,6 +264,7 @@ void TempRedraw(void); void DrawRuler(drawCmd_p, coOrd, coOrd, DIST_T, int, int, wDrawColor); void MainProc(wWin_p, winProcEvent, void *, void *); void InitInfoBar(void); +void InitColor(void); void DrawInit(int); void DoZoomUp(void * modeVP); void DoZoomDown(void * modeVP); diff --git a/app/bin/drawgeom.c b/app/bin/drawgeom.c index f249ff0..b52d42a 100644 --- a/app/bin/drawgeom.c +++ b/app/bin/drawgeom.c @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "ccurve.h" @@ -46,11 +46,12 @@ static void EndPoly( drawContext_t * context, int cnt, wBool_t open) pts_t * pts; int inx; - if (context->State==0 || cnt == 0) + if (context->State==0 || cnt == 0) { return; - + } + if ( cnt < 3 ) { - tempSegs_da.cnt = 0; + DYNARR_RESET( trkSeg_t, tempSegs_da ); ErrorMessage( MSG_POLY_SHAPES_3_SIDES ); return; } @@ -61,7 +62,8 @@ static void EndPoly( drawContext_t * context, int cnt, wBool_t open) } DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); segPtr = &tempSegs(0); - segPtr->type = ( (context->Op == OP_POLY || context->Op == OP_POLYLINE )? SEG_POLY:SEG_FILPOLY ); + segPtr->type = ( (context->Op == OP_POLY + || context->Op == OP_POLYLINE )? SEG_POLY:SEG_FILPOLY ); segPtr->u.p.cnt = cnt; segPtr->u.p.pts = pts; segPtr->u.p.angle = 0.0; @@ -70,7 +72,7 @@ static void EndPoly( drawContext_t * context, int cnt, wBool_t open) UndoStart( _("Create Lines"), "newDraw" ); trk = MakeDrawFromSeg( zero, 0.0, segPtr ); DrawNewTrack( trk ); - tempSegs_da.cnt = 0; + DYNARR_RESET( trkSeg_t, tempSegs_da ); } @@ -80,18 +82,21 @@ static void DrawGeomOk( BOOL_T started ) track_p trk; int inx; - if (tempSegs_da.cnt <= 0) + if (tempSegs_da.cnt <= 0) { return; - if (!started) + } + if (!started) { UndoStart( _("Create Lines"), "newDraw" ); + } for ( inx=0; inx<tempSegs_da.cnt; inx++ ) { trk = MakeDrawFromSeg( zero, 0.0, &tempSegs(inx) ); DrawNewTrack( trk ); } - tempSegs_da.cnt = 0; + DYNARR_RESET( trkSeg_t, tempSegs_da ); } -static void CreateEndAnchor(coOrd p, wBool_t lock) { +static void CreateEndAnchor(coOrd p, wBool_t lock) +{ DIST_T d = tempD.scale*0.15; DYNARR_APPEND(trkSeg_t,anchors_da,1); @@ -102,10 +107,11 @@ static void CreateEndAnchor(coOrd p, wBool_t lock) { anchors(i).u.c.radius = d/2; anchors(i).u.c.a0 = 0.0; anchors(i).u.c.a1 = 360.0; - anchors(i).width = 0; + anchors(i).lineWidth = 0; } -static void CreateLineAnchor(coOrd p, coOrd p0) { +static void CreateLineAnchor(coOrd p, coOrd p0) +{ DIST_T d = tempD.scale*0.15; coOrd p1; ANGLE_T a = FindAngle(p0,p); @@ -116,62 +122,67 @@ static void CreateLineAnchor(coOrd p, coOrd p0) { anchors(i).color = wDrawColorBlue; anchors(i).u.l.pos[0] = p; anchors(i).u.l.pos[1] = p0; - anchors(i).width = 0; + anchors(i).lineWidth = 0; } -static void CreateSquareAnchor(coOrd p) { +static void CreateSquareAnchor(coOrd p) +{ DIST_T d = tempD.scale*0.15; int i = anchors_da.cnt; DYNARR_SET(trkSeg_t,anchors_da,i+4); - for (int j =0; j<4;j++) { + for (int j =0; j<4; j++) { anchors(i+j).type = SEG_STRLIN; anchors(i+j).color = wDrawColorBlue; - anchors(i+j).width = 0; + anchors(i+j).lineWidth = 0; } anchors(i).u.l.pos[0].x = anchors(i+2).u.l.pos[1].x = - anchors(i+3).u.l.pos[0].x = anchors(i+3).u.l.pos[1].x = p.x-d/2; + anchors(i+3).u.l.pos[0].x = anchors(i+3).u.l.pos[1].x = p.x-d/2; anchors(i).u.l.pos[0].y = anchors(i).u.l.pos[1].y = - anchors(i+1).u.l.pos[0].y = anchors(i+3).u.l.pos[1].y = p.y-d/2; + anchors(i+1).u.l.pos[0].y = anchors(i+3).u.l.pos[1].y = p.y-d/2; anchors(i).u.l.pos[1].x = - anchors(i+1).u.l.pos[0].x = anchors(i+1).u.l.pos[1].x = - anchors(i+2).u.l.pos[0].x = p.x+d/2; + anchors(i+1).u.l.pos[0].x = anchors(i+1).u.l.pos[1].x = + anchors(i+2).u.l.pos[0].x = p.x+d/2; anchors(i+1).u.l.pos[1].y = - anchors(i+2).u.l.pos[0].y = anchors(i+2).u.l.pos[1].y = - anchors(i+3).u.l.pos[0].y = p.y+d/2; + anchors(i+2).u.l.pos[0].y = anchors(i+2).u.l.pos[1].y = + anchors(i+3).u.l.pos[0].y = p.y+d/2; } -BOOL_T FindTempNear(drawContext_t *context, coOrd *p) { +BOOL_T FindTempNear(drawContext_t *context, coOrd *p) +{ if (context->State == 2) { if ((context->Op >= OP_CURVE1) && (context->Op <= OP_CURVE4)) { if (context->ArcData.type == curveTypeCurve) { ANGLE_T a = FindAngle(context->ArcData.curvePos,*p); - if (IsClose(FindDistance(context->ArcData.curvePos,*p)-context->ArcData.curveRadius) && - (a>=context->ArcData.a0) && (a<=context->ArcData.a0+context->ArcData.a1)) { + if (IsClose(FindDistance(context->ArcData.curvePos, + *p)-context->ArcData.curveRadius) && + (a>=context->ArcData.a0) && (a<=context->ArcData.a0+context->ArcData.a1)) { Translate(p,context->ArcData.curvePos,a,context->ArcData.curveRadius); return TRUE; } } else { - if (IsClose(LineDistance(p,tempSegs(0).u.l.pos[0],tempSegs(0).u.l.pos[1]))) + if (IsClose(LineDistance(p,tempSegs(0).u.l.pos[0],tempSegs(0).u.l.pos[1]))) { return TRUE; + } } } else if ( (context->Op >=OP_LINE) && (context->Op <= OP_BENCH)) { - if (IsClose(LineDistance(p,tempSegs(0).u.l.pos[0],tempSegs(0).u.l.pos[1]))) + if (IsClose(LineDistance(p,tempSegs(0).u.l.pos[0],tempSegs(0).u.l.pos[1]))) { return TRUE; + } } } return FALSE; } /** - * Create and draw a graphics primitive (lines, arc, circle). The complete handling of mouse - * movements and clicks during the editing process is done here. + * Create and draw a graphics primitive (lines, arc, circle). The complete handling of mouse + * movements and clicks during the editing process is done here. * - * \param action IN mouse action + * \param action IN mouse action * \param pos IN position of mouse pointer - * \param context IN/OUT parameters for drawing op + * \param context IN/OUT parameters for drawing op * \return next command state * * Note - Poly supports both clicking points and/or dragging sides. Close is space or enter. @@ -180,30 +191,29 @@ BOOL_T FindTempNear(drawContext_t *context, coOrd *p) { */ STATUS_T DrawGeomMouse( - wAction_t action, - coOrd pos, - drawContext_t *context) + wAction_t action, + coOrd pos, + drawContext_t *context) { - static int lastValid = FALSE; +// static int lastValid = FALSE; static BOOL_T locked; static coOrd pos0, pos0x, pos1, lastPos, movePos; trkSeg_p segPtr; pts_t *pts; int inx; - DIST_T width; static int segCnt; DIST_T d; ANGLE_T a1,a2; static ANGLE_T line_angle; - BOOL_T createTrack; - - width = context->line_Width/context->D->dpi; +// BOOL_T createTrack; switch (action&0xFF) { case C_UPDATE: - if (context->State == 0 ) return C_TERMINATE; - if (context->Op != OP_POLY && context->Op != OP_FILLPOLY && context->Op != OP_POLYLINE && context->State == 1) return C_TERMINATE; + if (context->State == 0 ) { return C_TERMINATE; } + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); + if (context->Op != OP_POLY && context->Op != OP_FILLPOLY + && context->Op != OP_POLYLINE && context->State == 1) { return C_TERMINATE; } switch (context->Op) { case OP_CIRCLE1: case OP_CIRCLE2: @@ -212,7 +222,7 @@ STATUS_T DrawGeomMouse( case OP_FILLCIRCLE2: case OP_FILLCIRCLE3: tempSegs(0).u.c.radius = context->radius; - break; + break; case OP_CURVE1: case OP_CURVE2: case OP_CURVE3: @@ -220,7 +230,8 @@ STATUS_T DrawGeomMouse( if (context->ArcData.type == curveTypeCurve) { if (tempSegs(0).u.c.radius != context->radius) { coOrd end; - Translate(&end,context->ArcData.curvePos,context->ArcData.a0,context->ArcData.curveRadius); + Translate(&end,context->ArcData.curvePos,context->ArcData.a0, + context->ArcData.curveRadius); tempSegs(0).u.c.radius = context->radius; Translate(&tempSegs(0).u.c.center,end,context->ArcData.a0+180,context->radius); context->ArcData.curvePos = tempSegs(0).u.c.center; @@ -228,20 +239,24 @@ STATUS_T DrawGeomMouse( } tempSegs(0).u.c.a1 = context->angle; context->ArcData.a1 = tempSegs(0).u.c.a1; - Translate(&context->ArcData.pos1,context->ArcData.curvePos,context->ArcData.a0,context->ArcData.curveRadius); - Translate(&context->ArcData.pos2,context->ArcData.curvePos,context->ArcData.a0+context->ArcData.a1,context->ArcData.curveRadius); - } else - Translate(&tempSegs(0).u.l.pos[1],tempSegs(0).u.l.pos[0],context->angle,context->length); - break; + Translate(&context->ArcData.pos1,context->ArcData.curvePos,context->ArcData.a0, + context->ArcData.curveRadius); + Translate(&context->ArcData.pos2,context->ArcData.curvePos, + context->ArcData.a0+context->ArcData.a1,context->ArcData.curveRadius); + } else { + Translate(&tempSegs(0).u.l.pos[1],tempSegs(0).u.l.pos[0],context->angle, + context->length); + } + break; case OP_LINE: case OP_BENCH: case OP_TBLEDGE: a1 = FindAngle(pos0,pos1); - Translate(&tempSegs(0).u.l.pos[1],tempSegs(0).u.l.pos[0],context->angle,context->length); + Translate(&tempSegs(0).u.l.pos[1],tempSegs(0).u.l.pos[0],context->angle, + context->length); lastPos = pos1 = tempSegs(0).u.l.pos[1]; - tempSegs_da.cnt = 1; context->angle = NormalizeAngle(context->angle); - break; + break; case OP_BOX: case OP_FILLBOX: pts = tempSegs(0).u.p.pts; @@ -250,29 +265,31 @@ STATUS_T DrawGeomMouse( a2 = FindAngle(pts[0].pt,pts[3].pt); Translate(&pts[2].pt,pts[1].pt,a2,context->width); Translate(&pts[3].pt,pts[0].pt,a2,context->width); - tempSegs_da.cnt = 1; - break; + break; case OP_POLY: case OP_FILLPOLY: case OP_POLYLINE: - tempSegs_da.cnt = segCnt; + DYNARR_SET( trkSeg_t, tempSegs_da, segCnt ); if (segCnt>1) { - ANGLE_T an = FindAngle(tempSegs(segCnt-2).u.l.pos[0],tempSegs(segCnt-2).u.l.pos[1]); + ANGLE_T an = FindAngle(tempSegs(segCnt-2).u.l.pos[0], + tempSegs(segCnt-2).u.l.pos[1]); an = an+context->angle; - Translate(&tempSegs(segCnt-1).u.l.pos[1],tempSegs(segCnt-1).u.l.pos[0],an,context->length); + Translate(&tempSegs(segCnt-1).u.l.pos[1],tempSegs(segCnt-1).u.l.pos[0],an, + context->length); } else { - Translate(&tempSegs(0).u.l.pos[1],tempSegs(0).u.l.pos[0],context->angle,context->length); + Translate(&tempSegs(0).u.l.pos[1],tempSegs(0).u.l.pos[0],context->angle, + context->length); } pos1 = lastPos = tempSegs(segCnt-1).u.l.pos[1]; context->angle = fabs(context->angle); - if (context->angle >180) context->angle = context->angle - 180.0; - break; + if (context->angle >180) { context->angle = context->angle - 180.0; } + break; default: - break; + break; } context->Changed = TRUE; //Update made MainRedraw(); - anchors_da.cnt = 0; + DYNARR_RESET( trkSeg_t, anchors_da ); return C_CONTINUE; case C_START: @@ -283,10 +300,11 @@ STATUS_T DrawGeomMouse( DYNARR_RESET( trkSeg_t, tempSegs_da ); DYNARR_RESET( trkSeg_t, anchors_da ); locked = FALSE; - if (!magneticSnap) + if (!magneticSnap) { InfoMessage(_("+Alt for Magnetic Snap")); - else + } else { InfoMessage(_("+Alt to inhibit Magnetic Snap")); + } wSetCursor(mainD.d,defaultCursor); movePos = zero; context->UndoStarted = FALSE; @@ -296,56 +314,57 @@ STATUS_T DrawGeomMouse( locked = FALSE; wSetCursor(mainD.d,defaultCursor); if ((context->State == 0 && - context->Op != OP_FILLCIRCLE2 && context->Op != OP_CIRCLE2) || - context->State ==2 || - (context->State == 1 && - (context->Op == OP_POLY || context->Op == OP_FILLPOLY || context->Op == OP_POLYLINE))) { + context->Op != OP_FILLCIRCLE2 && context->Op != OP_CIRCLE2) || + context->State ==2 || + (context->State == 1 && + (context->Op == OP_POLY || context->Op == OP_FILLPOLY + || context->Op == OP_POLYLINE))) { DYNARR_RESET( trkSeg_t, anchors_da ); wSetCursor(mainD.d,defaultCursor); switch (context->Op) { //Snap pos to nearest line for lines and some curves - case OP_CURVE1: - case OP_CURVE2: - case OP_CURVE3: - case OP_CURVE4: - case OP_CIRCLE2: - case OP_CIRCLE3: - case OP_FILLCIRCLE2: - case OP_FILLCIRCLE3: - case OP_LINE: - case OP_DIMLINE: - case OP_BENCH: - case OP_TBLEDGE: - case OP_BOX: - case OP_FILLBOX: - case OP_POLY: - case OP_FILLPOLY: - case OP_POLYLINE:; - if (((MyGetKeyState() & WKEY_ALT)==0) == magneticSnap ) { - coOrd p = pos; - track_p t; - if (((t=OnTrack(&p,FALSE,FALSE))!=NULL) && (IsClose(FindDistance(p,pos))) ) { - if (context->Op == OP_DIMLINE ) { - CreateEndAnchor(p,FALSE); - wSetCursor(mainD.d,wCursorNone); - movePos = p; - locked = TRUE; - } else if (!IsTrack(t)) { - CreateEndAnchor(p,FALSE); - wSetCursor(mainD.d,wCursorNone); - movePos = p; - locked = TRUE; - } + case OP_CURVE1: + case OP_CURVE2: + case OP_CURVE3: + case OP_CURVE4: + case OP_CIRCLE2: + case OP_CIRCLE3: + case OP_FILLCIRCLE2: + case OP_FILLCIRCLE3: + case OP_LINE: + case OP_DIMLINE: + case OP_BENCH: + case OP_TBLEDGE: + case OP_BOX: + case OP_FILLBOX: + case OP_POLY: + case OP_FILLPOLY: + case OP_POLYLINE:; + if (((MyGetKeyState() & WKEY_ALT)==0) == magneticSnap ) { + coOrd p = pos; + track_p t; + if (((t=OnTrack(&p,FALSE,FALSE))!=NULL) && (IsClose(FindDistance(p,pos))) ) { + if (context->Op == OP_DIMLINE ) { + CreateEndAnchor(p,FALSE); + // wSetCursor(mainD.d,wCursorNone); + movePos = p; + locked = TRUE; + } else if (!IsTrack(t)) { + CreateEndAnchor(p,FALSE); + // wSetCursor(mainD.d,wCursorNone); + movePos = p; + locked = TRUE; } } - if (!locked && SnapPos(&pos)) { - CreateEndAnchor(pos,FALSE); - wSetCursor(mainD.d,wCursorNone); - movePos = pos; - locked = TRUE; - } - break; - default: - ; + } + if (!locked && SnapPos(&pos)) { + CreateEndAnchor(pos,FALSE); + // wSetCursor(mainD.d,wCursorNone); + movePos = pos; + locked = TRUE; + } + break; + default: + ; } } return C_CONTINUE; @@ -355,36 +374,41 @@ STATUS_T DrawGeomMouse( DYNARR_RESET( trkSeg_t, anchors_da ); wSetCursor(mainD.d,defaultCursor); if (context->State == 2) { - tempSegs_da.cnt = segCnt; - if ((context->Op == OP_POLY || context->Op == OP_FILLPOLY || context->Op == OP_POLYLINE)) { + DYNARR_SET( trkSeg_t, tempSegs_da, segCnt ); + if ((context->Op == OP_POLY || context->Op == OP_FILLPOLY + || context->Op == OP_POLYLINE)) { EndPoly(context, segCnt, context->Op==OP_POLYLINE); } else { DrawGeomOk(TRUE); } context->UndoStarted = FALSE; segCnt = 0; - anchors_da.cnt = 0; + DYNARR_RESET( trkSeg_t, anchors_da ); context->State = 0; TryCheckPoint(); } + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); context->Started = TRUE; line_angle = 90.0; if ((context->Op == OP_CURVE1 && context->State != 2) || - (context->Op == OP_CURVE2 && context->State == 0) || - (context->Op == OP_CURVE3 && context->State != 0) || - (context->Op == OP_CURVE4 && context->State != 2) || - (context->Op == OP_CIRCLE2 && context->State != 0) || - (context->Op == OP_CIRCLE3 && context->State == 0) || - (context->Op == OP_FILLCIRCLE2 && context->State != 0) || - (context->Op == OP_FILLCIRCLE3 && context->State == 0) || - (context->Op == OP_LINE) || (context->Op == OP_DIMLINE) || - (context->Op == OP_BENCH) || (context->Op == OP_TBLEDGE) || - (context->Op == OP_BOX) || (context->Op == OP_FILLBOX) || - (context->Op == OP_POLY) || (context->Op == OP_POLYLINE) || (context->Op == OP_FILLPOLY) ) { - if (locked) pos = movePos; - } - if ((context->Op == OP_CURVE1 || context->Op == OP_CURVE2 || context->Op == OP_CURVE3 || context->Op == OP_CURVE4) && context->State == 1) { - ; + (context->Op == OP_CURVE2 && context->State == 0) || + (context->Op == OP_CURVE3 && context->State != 0) || + (context->Op == OP_CURVE4 && context->State != 2) || + (context->Op == OP_CIRCLE2 && context->State != 0) || + (context->Op == OP_CIRCLE3 && context->State == 0) || + (context->Op == OP_FILLCIRCLE2 && context->State != 0) || + (context->Op == OP_FILLCIRCLE3 && context->State == 0) || + (context->Op == OP_LINE) || (context->Op == OP_DIMLINE) || + (context->Op == OP_BENCH) || (context->Op == OP_TBLEDGE) || + (context->Op == OP_BOX) || (context->Op == OP_FILLBOX) || + (context->Op == OP_POLY) || (context->Op == OP_POLYLINE) + || (context->Op == OP_FILLPOLY) ) { + if (locked) { pos = movePos; } + } + if ((context->Op == OP_CURVE1 || context->Op == OP_CURVE2 + || context->Op == OP_CURVE3 || context->Op == OP_CURVE4) + && context->State == 1) { + ; } else { pos0 = pos; pos1 = pos; @@ -394,33 +418,40 @@ STATUS_T DrawGeomMouse( case OP_LINE: case OP_DIMLINE: case OP_BENCH: - DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); switch (context->Op) { - case OP_LINE: tempSegs(0).type = SEG_STRLIN; break; - case OP_DIMLINE: tempSegs(0).type = SEG_DIMLIN; break; - case OP_BENCH: tempSegs(0).type = SEG_BENCH; break; + case OP_LINE: + tempSegs(0).type = SEG_STRLIN; + tempSegs(0).color = lineColor; + break; + case OP_DIMLINE: + tempSegs(0).type = SEG_DIMLIN; + tempSegs(0).color = wDrawColorBlack; + break; + case OP_BENCH: + tempSegs(0).type = SEG_BENCH; + tempSegs(0).color = benchColor; + break; } - tempSegs(0).color = context->Color; - tempSegs(0).width = width; + tempSegs(0).lineWidth = lineWidth; tempSegs(0).u.l.pos[0] = tempSegs(0).u.l.pos[1] = pos; if ( context->Op == OP_BENCH || context->Op == OP_DIMLINE ) { tempSegs(0).u.l.option = context->benchOption; } else { tempSegs(0).u.l.option = 0; } - tempSegs_da.cnt = 0; - context->message( _("Drag next point, +Alt reverse Magnetic Snap or +Ctrl lock to 90 deg") ); + context->message( + _("Drag next point, +Alt reverse Magnetic Snap or +Ctrl lock to 90 deg") ); break; case OP_TBLEDGE: OnTableEdgeEndPt( NULL, &pos ); - DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); tempSegs(0).type = SEG_TBLEDGE; - tempSegs(0).color = context->Color; - tempSegs(0).width = (mainD.scale<=16)?(3/context->D->dpi*context->D->scale):0; + tempSegs(0).color = wDrawColorBlack; + tempSegs(0).lineWidth = (mainD.scale<=16)?(3/context->D->dpi*context->D->scale) + :0; tempSegs(0).u.l.pos[0] = tempSegs(0).u.l.pos[1] = pos; tempSegs(0).u.l.option = 0; - tempSegs_da.cnt = 0; - context->message( _("Drag next point, +Alt reverse Magnetic Snap, or +Ctrl to lock to 90 degrees") ); + context->message( + _("Drag next point, +Alt reverse Magnetic Snap, or +Ctrl to lock to 90 degrees") ); break; case OP_CURVE1: case OP_CURVE2: case OP_CURVE3: case OP_CURVE4: if (context->State == 0) { @@ -430,8 +461,10 @@ STATUS_T DrawGeomMouse( case OP_CURVE3: drawGeomCurveMode = crvCmdFromCenter; break; case OP_CURVE4: drawGeomCurveMode = crvCmdFromChord; break; } - CreateCurve( C_START, pos, FALSE, context->Color, width, drawGeomCurveMode, &anchors_da, context->message ); - CreateCurve( C_DOWN, pos, FALSE, context->Color, width, drawGeomCurveMode, &anchors_da, context->message ); + CreateCurve( C_START, pos, FALSE, lineColor, lineWidth, drawGeomCurveMode, + &anchors_da, context->message ); + CreateCurve( C_DOWN, pos, FALSE, lineColor, lineWidth, drawGeomCurveMode, + &anchors_da, context->message ); } break; case OP_CIRCLE1: @@ -440,13 +473,13 @@ STATUS_T DrawGeomMouse( case OP_FILLCIRCLE1: case OP_FILLCIRCLE2: case OP_FILLCIRCLE3: - DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); tempSegs(0).type = SEG_CRVLIN; - tempSegs(0).color = context->Color; - if ( context->Op >= OP_CIRCLE1 && context->Op <= OP_CIRCLE3 ) - tempSegs(0).width = width; - else - tempSegs(0).width = 0; + tempSegs(0).color = lineColor; + if ( context->Op >= OP_CIRCLE1 && context->Op <= OP_CIRCLE3 ) { + tempSegs(0).lineWidth = lineWidth; + } else { + tempSegs(0).lineWidth = 0; + } tempSegs(0).u.c.a0 = 0; tempSegs(0).u.c.a1 = 360; tempSegs(0).u.c.radius = 0; @@ -455,14 +488,14 @@ STATUS_T DrawGeomMouse( context->State = 1; break; case OP_FILLBOX: - width = 0; - /* no break */ + lineWidth = 0; + /* no break */ case OP_BOX: DYNARR_SET( trkSeg_t, tempSegs_da, 4 ); for ( inx=0; inx<4; inx++ ) { tempSegs(inx).type = SEG_STRLIN; - tempSegs(inx).color = context->Color; - tempSegs(inx).width = width; + tempSegs(inx).color = lineColor; + tempSegs(inx).lineWidth = lineWidth; tempSegs(inx).u.l.pos[0] = tempSegs(inx).u.l.pos[1] = pos; } context->message( _("Drag set box size") ); @@ -470,7 +503,7 @@ STATUS_T DrawGeomMouse( case OP_POLY: case OP_FILLPOLY: case OP_POLYLINE: - tempSegs_da.cnt = segCnt; + DYNARR_SET( trkSeg_t, tempSegs_da, segCnt ); wBool_t first_spot = FALSE; if (segCnt == 1 && tempSegs(0).type == SEG_CRVLIN) { coOrd start; @@ -483,8 +516,9 @@ STATUS_T DrawGeomMouse( } segPtr = &tempSegs(tempSegs_da.cnt-1); segPtr->type = SEG_STRLIN; - segPtr->color = context->Color; - segPtr->width = (context->Op==OP_POLY?width:0); + segPtr->color = lineColor; + segPtr->lineWidth = (context->Op==OP_POLY + || context->Op==OP_POLYLINE ? lineWidth : 0); //End if over start if ( segCnt>2 && IsClose(FindDistance(tempSegs(0).u.l.pos[0], pos ))) { segPtr->u.l.pos[0] = tempSegs(segCnt-1).u.l.pos[1]; @@ -517,17 +551,18 @@ STATUS_T DrawGeomMouse( coOrd p = pos1 = pos; BOOL_T locked = FALSE, poslocked = FALSE; if ((context->Op == OP_CURVE1 && context->State == 1) || - (context->Op == OP_CURVE2 && context->State == 0) || - (context->Op == OP_CURVE4 && context->State != 1) || - (context->Op == OP_CIRCLE2 && context->State != 0) || - (context->Op == OP_CIRCLE3 && context->State == 0) || - (context->Op == OP_FILLCIRCLE2 && context->State != 0) || - (context->Op == OP_FILLCIRCLE3 && context->State == 0) || - (context->Op == OP_BOX ) || - (context->Op == OP_FILLBOX ) || - (context->Op == OP_DIMLINE ) || (context->Op == OP_TBLEDGE) || - (context->Op == OP_LINE ) || (context->Op == OP_BENCH) || - (context->Op == OP_POLY) || (context->Op == OP_POLYLINE) || (context->Op == OP_FILLPOLY) ) { + (context->Op == OP_CURVE2 && context->State == 0) || + (context->Op == OP_CURVE4 && context->State != 1) || + (context->Op == OP_CIRCLE2 && context->State != 0) || + (context->Op == OP_CIRCLE3 && context->State == 0) || + (context->Op == OP_FILLCIRCLE2 && context->State != 0) || + (context->Op == OP_FILLCIRCLE3 && context->State == 0) || + (context->Op == OP_BOX ) || + (context->Op == OP_FILLBOX ) || + (context->Op == OP_DIMLINE ) || (context->Op == OP_TBLEDGE) || + (context->Op == OP_LINE ) || (context->Op == OP_BENCH) || + (context->Op == OP_POLY) || (context->Op == OP_POLYLINE) + || (context->Op == OP_FILLPOLY) ) { if ( ( (MyGetKeyState() & WKEY_ALT)==0) == magneticSnap) { p = pos; if ((OnTrack( &p, FALSE, FALSE )!=NULL) && (IsClose(FindDistance(p,pos)))) { @@ -547,18 +582,21 @@ STATUS_T DrawGeomMouse( switch (context->Op) { case OP_TBLEDGE: - if ((MyGetKeyState() & WKEY_CTRL) == WKEY_CTRL) { //If +Ctrl, snap to table edge end + if ((MyGetKeyState() & WKEY_CTRL) == + WKEY_CTRL) { //If +Ctrl, snap to table edge end p = pos; if (OnTableEdgeEndPt( NULL, &p )) { locked = TRUE; pos1 = p; } } - /* no break */ + /* no break */ case OP_LINE: case OP_DIMLINE: case OP_BENCH: - if (!locked && ((MyGetKeyState() & WKEY_CTRL) == WKEY_CTRL )) { //If not found already +Ctl = Right Angle + if (!locked + && ((MyGetKeyState() & WKEY_CTRL) == + WKEY_CTRL )) { //If not found already +Ctl = Right Angle //Snap to Right-Angle from previous or from 0 DIST_T l = FindDistance(pos0, pos); ANGLE_T angle2 = NormalizeAngle(FindAngle(pos0, pos)-line_angle); @@ -566,60 +604,76 @@ STATUS_T DrawGeomMouse( if (tempSegs_da.cnt != 1 && (quad == 2)) { pos1 = pos0; } else if (quad == 1 || quad == 3) { - if (tempSegs_da.cnt != 1) - l = fabs(l*cos(D2R(((quad==1)?line_angle+90.0:line_angle-90.0)-FindAngle(pos,pos0)))); - Translate( &pos1, pos0, NormalizeAngle(quad==1?line_angle+90.0:line_angle-90.0), l ); + if (tempSegs_da.cnt != 1) { + l = fabs(l*cos(D2R(((quad==1)?line_angle+90.0:line_angle-90.0)-FindAngle(pos, + pos0)))); + } + Translate( &pos1, pos0, NormalizeAngle(quad==1?line_angle+90.0:line_angle-90.0), + l ); } else { - if (tempSegs_da.cnt != 1) - l = fabs(l*cos(D2R(((quad==0||quad==4)?line_angle:line_angle+180.0)-FindAngle(pos,pos0)))); - Translate( &pos1, pos0, NormalizeAngle((quad==0||quad==4)?line_angle:line_angle+180.0), l ); + if (tempSegs_da.cnt != 1) { + l = fabs(l*cos(D2R(((quad==0 + ||quad==4)?line_angle:line_angle+180.0)-FindAngle(pos,pos0)))); + } + Translate( &pos1, pos0, NormalizeAngle((quad==0 + ||quad==4)?line_angle:line_angle+180.0), l ); } CreateLineAnchor(pos1,pos0); } + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); tempSegs(0).u.l.pos[1] = pos1; context->message( _("Length = %s, Angle = %0.2f"), - FormatDistance(FindDistance( pos0, pos1 )), - PutAngle(FindAngle( pos0, pos1 )) ); - tempSegs_da.cnt = 1; - if (anchors_da.cnt == 0) CreateEndAnchor(pos1, FALSE); + FormatDistance(FindDistance( pos0, pos1 )), + PutAngle(FindAngle( pos0, pos1 )) ); + if (anchors_da.cnt == 0) { CreateEndAnchor(pos1, FALSE); } break; case OP_POLY: case OP_FILLPOLY: case OP_POLYLINE: if ((MyGetKeyState() & WKEY_CTRL) == WKEY_CTRL ) { coOrd last_point = zero; - ANGLE_T last_angle, initial_angle; + ANGLE_T last_angle; +// ANGLE_T initial_angle; if (tempSegs_da.cnt == 1) { last_angle = 90.0; last_point = tempSegs(0).u.l.pos[0]; - initial_angle = 90.0; +// initial_angle = 90.0; } else { last_point = tempSegs(tempSegs_da.cnt-2).u.l.pos[1]; - last_angle = FindAngle(tempSegs(tempSegs_da.cnt-2).u.l.pos[0],tempSegs(tempSegs_da.cnt-2).u.l.pos[1]); - initial_angle = FindAngle(tempSegs(0).u.l.pos[0],tempSegs(0).u.l.pos[1]); + last_angle = FindAngle(tempSegs(tempSegs_da.cnt-2).u.l.pos[0], + tempSegs(tempSegs_da.cnt-2).u.l.pos[1]); +// initial_angle = FindAngle(tempSegs(0).u.l.pos[0],tempSegs(0).u.l.pos[1]); } //Snap to Right-Angle from previous or from 0 DIST_T l = FindDistance(tempSegs(tempSegs_da.cnt-1).u.l.pos[0], pos); - ANGLE_T angle2 = NormalizeAngle(FindAngle(tempSegs(tempSegs_da.cnt-1).u.l.pos[0], pos)-last_angle); + ANGLE_T angle2 = NormalizeAngle(FindAngle(tempSegs(tempSegs_da.cnt + -1).u.l.pos[0], pos)-last_angle); int quad = (int)((angle2+45.0)/90.0); if (tempSegs_da.cnt != 1 && (quad == 2)) { pos = tempSegs(tempSegs_da.cnt-1).u.l.pos[0]; } else if (quad == 1 || quad == 3) { - if (tempSegs_da.cnt != 1) - l = fabs(l*cos(D2R(((quad==1)?last_angle+90.0:last_angle-90.0)-FindAngle(pos,last_point)))); - Translate( &pos, tempSegs(tempSegs_da.cnt-1).u.l.pos[0], NormalizeAngle(quad==1?last_angle+90.0:last_angle-90.0), l ); + if (tempSegs_da.cnt != 1) { + l = fabs(l*cos(D2R(((quad==1)?last_angle+90.0:last_angle-90.0)-FindAngle(pos, + last_point)))); + } + Translate( &pos, tempSegs(tempSegs_da.cnt-1).u.l.pos[0], + NormalizeAngle(quad==1?last_angle+90.0:last_angle-90.0), l ); } else { - if (tempSegs_da.cnt != 1) - l = fabs(l*cos(D2R(((quad==0||quad==4)?last_angle:last_angle+180.0)-FindAngle(pos,last_point)))); - Translate( &pos, tempSegs(tempSegs_da.cnt-1).u.l.pos[0], NormalizeAngle((quad==0||quad==4)?last_angle:last_angle+180.0), l ); + if (tempSegs_da.cnt != 1) { + l = fabs(l*cos(D2R(((quad==0 + ||quad==4)?last_angle:last_angle+180.0)-FindAngle(pos,last_point)))); + } + Translate( &pos, tempSegs(tempSegs_da.cnt-1).u.l.pos[0], NormalizeAngle((quad==0 + ||quad==4)?last_angle:last_angle+180.0), l ); } CreateEndAnchor(pos,TRUE); - if (FindDistance(pos,last_point)>0.0) CreateLineAnchor(pos,last_point); + if (FindDistance(pos,last_point)>0.0) { CreateLineAnchor(pos,last_point); } //If there is any point on this line that will give a 90 degree return to the first point, show it if (tempSegs_da.cnt > 1) { coOrd intersect; ANGLE_T an_this = FindAngle(tempSegs(tempSegs_da.cnt-2).u.l.pos[1],pos); - if (FindIntersection(&intersect,tempSegs(0).u.l.pos[0],an_this+90.0,tempSegs(tempSegs_da.cnt-2).u.l.pos[1],an_this)) { + if (FindIntersection(&intersect,tempSegs(0).u.l.pos[0],an_this+90.0, + tempSegs(tempSegs_da.cnt-2).u.l.pos[1],an_this)) { ANGLE_T an_inter = FindAngle(tempSegs(tempSegs_da.cnt-2).u.l.pos[1],intersect); if (fabs(DifferenceBetweenAngles(an_inter,an_this))<90.0) { CreateSquareAnchor(intersect); @@ -630,36 +684,37 @@ STATUS_T DrawGeomMouse( } } } - } else if (poslocked) pos = pos1; + } else if (poslocked) { pos = pos1; } tempSegs(tempSegs_da.cnt-1).type = SEG_STRLIN; tempSegs(tempSegs_da.cnt-1).u.l.pos[1] = pos; context->message( _("Length = %s, Angle = %0.2f"), - FormatDistance(FindDistance( tempSegs(tempSegs_da.cnt-1).u.l.pos[0], pos )), - PutAngle(FindAngle( tempSegs(tempSegs_da.cnt-1).u.l.pos[0], pos )) ); + FormatDistance(FindDistance( tempSegs(tempSegs_da.cnt-1).u.l.pos[0], pos )), + PutAngle(FindAngle( tempSegs(tempSegs_da.cnt-1).u.l.pos[0], pos )) ); segCnt = tempSegs_da.cnt; break; case OP_CURVE1: case OP_CURVE2: case OP_CURVE3: case OP_CURVE4: if (context->State == 0) { pos0x = pos1; - CreateCurve( C_MOVE, pos, FALSE, context->Color, width, drawGeomCurveMode, &anchors_da, context->message ); + CreateCurve( C_MOVE, pos, FALSE, lineColor, lineWidth, drawGeomCurveMode, + &anchors_da, context->message ); } else { - PlotCurve( drawGeomCurveMode, pos0, pos0x, pos1, &context->ArcData, FALSE, 0.0 ); - tempSegs(0).color = context->Color; - tempSegs(0).width = width; - DYNARR_SET(trkSeg_t,tempSegs_da,1); + PlotCurve( drawGeomCurveMode, pos0, pos0x, pos1, &context->ArcData, FALSE, + 0.0 ); + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); + tempSegs(0).color = lineColor; + tempSegs(0).lineWidth = lineWidth; if (context->ArcData.type == curveTypeStraight) { tempSegs(0).type = SEG_STRLIN; tempSegs(0).u.l.pos[0] = pos0; tempSegs(0).u.l.pos[1] = context->ArcData.pos1; - tempSegs_da.cnt = 1; CreateEndAnchor(pos0, FALSE); CreateEndAnchor(context->ArcData.pos1, FALSE); context->message( _("Straight Line: Length=%s Angle=%0.3f"), - FormatDistance(FindDistance( pos0, context->ArcData.pos1 )), - PutAngle(FindAngle( pos0, context->ArcData.pos1 )) ); + FormatDistance(FindDistance( pos0, context->ArcData.pos1 )), + PutAngle(FindAngle( pos0, context->ArcData.pos1 )) ); } else if (context->ArcData.type == curveTypeNone) { - tempSegs_da.cnt = 0; + DYNARR_RESET( trkSeg_t, tempSegs_da ); context->message( _("Back") ); } else if (context->ArcData.type == curveTypeCurve) { tempSegs(0).type = SEG_CRVLIN; @@ -667,29 +722,32 @@ STATUS_T DrawGeomMouse( tempSegs(0).u.c.radius = context->ArcData.curveRadius; tempSegs(0).u.c.a0 = context->ArcData.a0; tempSegs(0).u.c.a1 = context->ArcData.a1; - tempSegs_da.cnt = 1; d = D2R(context->ArcData.a1); - if (d < 0.0) + if (d < 0.0) { d = 2*M_PI+d; + } if ( d*context->ArcData.curveRadius > mapD.size.x+mapD.size.y ) { ErrorMessage( MSG_CURVE_TOO_LARGE ); - tempSegs_da.cnt = 0; + DYNARR_RESET( trkSeg_t, tempSegs_da ); context->ArcData.type = curveTypeNone; return C_CONTINUE; } context->message( _("Curved Line: Radius=%s Angle=%0.3f Length=%s"), - FormatDistance(context->ArcData.curveRadius), context->ArcData.a1, - FormatDistance(context->ArcData.curveRadius*d) ); - if (context->Op == OP_CURVE1 || context->Op == OP_CURVE4 ) - DrawArrowHeadsArray(&anchors_da,pos1,FindAngle(context->ArcData.curvePos,pos),TRUE,wDrawColorRed); - else if (context->Op == OP_CURVE2 || context->Op == OP_CURVE3 ) { + FormatDistance(context->ArcData.curveRadius), context->ArcData.a1, + FormatDistance(context->ArcData.curveRadius*d) ); + if (context->Op == OP_CURVE1 || context->Op == OP_CURVE4 ) { + DrawArrowHeadsArray(&anchors_da,pos1,FindAngle(context->ArcData.curvePos,pos), + TRUE,wDrawColorRed); + } else if (context->Op == OP_CURVE2 || context->Op == OP_CURVE3 ) { CreateEndAnchor(context->ArcData.pos2,FALSE); - DrawArrowHeadsArray(&anchors_da,context->ArcData.pos2,FindAngle(context->ArcData.curvePos,context->ArcData.pos2)+90,TRUE,wDrawColorRed); + DrawArrowHeadsArray(&anchors_da,context->ArcData.pos2, + FindAngle(context->ArcData.curvePos,context->ArcData.pos2)+90,TRUE, + wDrawColorRed); } CreateEndAnchor(context->ArcData.curvePos,TRUE); } } - if (anchors_da.cnt == 0) CreateEndAnchor(pos, FALSE); + if (anchors_da.cnt == 0) { CreateEndAnchor(pos, FALSE); } break; case OP_CIRCLE1: case OP_FILLCIRCLE1: @@ -697,30 +755,30 @@ STATUS_T DrawGeomMouse( case OP_CIRCLE2: case OP_FILLCIRCLE2: tempSegs(0).u.c.center = pos1; - if (context->State == 1 && locked) CreateEndAnchor(pos1, FALSE); - else wSetCursor(mainD.d,defaultCursor); + if (context->State == 1 && locked) { CreateEndAnchor(pos1, FALSE); } + else { wSetCursor(mainD.d,defaultCursor); } tempSegs(0).u.c.radius = FindDistance( pos0, pos1 ); context->message( _("Radius = %s"), - FormatDistance(FindDistance( pos0, pos1 )) ); + FormatDistance(FindDistance( pos0, pos1 )) ); break; case OP_CIRCLE3: case OP_FILLCIRCLE3: - if (context->State == 1) CreateEndAnchor(pos0, TRUE); + if (context->State == 1) { CreateEndAnchor(pos0, TRUE); } wSetCursor(mainD.d,defaultCursor); tempSegs(0).u.c.radius = FindDistance( pos0, pos1 ); context->message( _("Radius = %s"), - FormatDistance(FindDistance( pos0, pos1 )) ); + FormatDistance(FindDistance( pos0, pos1 )) ); break; case OP_BOX: case OP_FILLBOX: - tempSegs_da.cnt = 4; - tempSegs(0).u.l.pos[1].x = tempSegs(1).u.l.pos[0].x = - tempSegs(1).u.l.pos[1].x = tempSegs(2).u.l.pos[0].x = pos1.x; - tempSegs(1).u.l.pos[1].y = tempSegs(2).u.l.pos[0].y = - tempSegs(2).u.l.pos[1].y = tempSegs(3).u.l.pos[0].y = pos1.y; - if (locked) CreateEndAnchor(pos1,FALSE); + DYNARR_SET( trkSeg_t, tempSegs_da, 4 ); + tempSegs(0).u.l.pos[1].x = tempSegs(1).u.l.pos[0].x = + tempSegs(1).u.l.pos[1].x = tempSegs(2).u.l.pos[0].x = pos1.x; + tempSegs(1).u.l.pos[1].y = tempSegs(2).u.l.pos[0].y = + tempSegs(2).u.l.pos[1].y = tempSegs(3).u.l.pos[0].y = pos1.y; + if (locked) { CreateEndAnchor(pos1,FALSE); } context->message( _("Width = %s, Height = %s"), - FormatDistance(fabs(pos1.x - pos0.x)), FormatDistance(fabs(pos1.y - pos0.y)) ); + FormatDistance(fabs(pos1.x - pos0.x)), FormatDistance(fabs(pos1.y - pos0.y)) ); break; } wSetCursor(mainD.d,wCursorNone); @@ -728,38 +786,37 @@ STATUS_T DrawGeomMouse( case wActionLUp: case wActionRUp: - lastValid = FALSE; - createTrack = FALSE; +// lastValid = FALSE; +// createTrack = FALSE; //Note - pos1 is last drag point wSetCursor(mainD.d,defaultCursor); - if ((context->Op == OP_POLY) || (context->Op == OP_POLYLINE) || (context->Op == OP_FILLPOLY ) - || (context->Op == OP_BOX) || (context->Op == OP_FILLBOX) ){ ; + if ((context->Op == OP_POLY) || (context->Op == OP_POLYLINE) + || (context->Op == OP_FILLPOLY ) + || (context->Op == OP_BOX) || (context->Op == OP_FILLBOX) ) { + ; } else if (context->Op == OP_LINE || context->Op == OP_DIMLINE || - context->Op == OP_BENCH || context->Op == OP_TBLEDGE ) { + context->Op == OP_BENCH || context->Op == OP_TBLEDGE ) { tempSegs(0).u.l.pos[1] = pos1; } else if ((context->Op>=OP_FILLCIRCLE1 && context->Op<=OP_FILLCIRCLE3) || - (context->Op>=OP_CIRCLE1 && context->Op<=OP_CIRCLE3)) { + (context->Op>=OP_CIRCLE1 && context->Op<=OP_CIRCLE3)) { ; } else { - PlotCurve( drawGeomCurveMode, pos0, pos0x, pos1, &context->ArcData, FALSE, 0.0 ); + PlotCurve( drawGeomCurveMode, pos0, pos0x, pos1, &context->ArcData, FALSE, + 0.0 ); if (context->ArcData.type == curveTypeStraight) { - DYNARR_RESET(trkSeg_t,tempSegs_da); - DYNARR_APPEND(trkSeg_t,tempSegs_da,1); + DYNARR_SET(trkSeg_t,tempSegs_da,1); tempSegs(0).type = SEG_STRLIN; tempSegs(0).u.l.pos[0] = pos0; tempSegs(0).u.l.pos[1] = context->ArcData.pos1; - tempSegs_da.cnt = 1; } else if (context->ArcData.type == curveTypeNone) { DYNARR_RESET(trkSeg_t,tempSegs_da); } else if (context->ArcData.type == curveTypeCurve) { - DYNARR_RESET(trkSeg_t,tempSegs_da); - DYNARR_APPEND(trkSeg_t,tempSegs_da,1); + DYNARR_SET(trkSeg_t,tempSegs_da,1); tempSegs(0).type = SEG_CRVLIN; tempSegs(0).u.c.center = context->ArcData.curvePos; tempSegs(0).u.c.radius = context->ArcData.curveRadius; tempSegs(0).u.c.a0 = context->ArcData.a0; tempSegs(0).u.c.a1 = context->ArcData.a1; - tempSegs_da.cnt = 1; } } switch ( context->Op ) { @@ -767,7 +824,7 @@ STATUS_T DrawGeomMouse( case OP_DIMLINE: case OP_BENCH: case OP_TBLEDGE: - lastValid = TRUE; +// lastValid = TRUE; lastPos = pos1; context->length = FindDistance(pos1,pos0); context->angle = FindAngle(pos0,pos1); @@ -779,7 +836,8 @@ STATUS_T DrawGeomMouse( context->State = 1; context->ArcAngle = FindAngle( pos0, pos1 ); pos0x = pos1; - CreateCurve( C_UP, pos, FALSE, context->Color, width, drawGeomCurveMode, &anchors_da, context->message ); + CreateCurve( C_UP, pos, FALSE, lineColor, lineWidth, drawGeomCurveMode, + &anchors_da, context->message ); context->message( _("Drag on Red arrows to adjust curve") ); context->show = FALSE; return C_CONTINUE; @@ -788,8 +846,8 @@ STATUS_T DrawGeomMouse( if (context->ArcData.type == curveTypeCurve) { segPtr = &tempSegs(0); segPtr->type = SEG_CRVLIN; - segPtr->color = context->Color; - segPtr->width = width; + segPtr->color = lineColor; + segPtr->lineWidth = lineWidth; segPtr->u.c.center = context->ArcData.curvePos; segPtr->u.c.radius = context->ArcData.curveRadius; segPtr->u.c.a0 = context->ArcData.a0; @@ -799,22 +857,25 @@ STATUS_T DrawGeomMouse( } else if (context->ArcData.type == curveTypeStraight) { segPtr = &tempSegs(0); segPtr->type = SEG_STRLIN; - segPtr->color = context->Color; - segPtr->width = width; + segPtr->color = lineColor; + segPtr->lineWidth = lineWidth; segPtr->u.l.pos[0] = pos0; segPtr->u.l.pos[1] = pos1; context->radius = 0; context->length = FindDistance(pos0,pos1); context->angle = FindAngle(pos0,pos1); } - lastValid = TRUE; +// lastValid = TRUE; lastPos = pos1; context->State = 2; - if (context->Op == OP_CURVE1 || context->Op == OP_CURVE4 ) - DrawArrowHeadsArray(&anchors_da,pos1,FindAngle(context->ArcData.curvePos,pos),TRUE,wDrawColorRed); - else if (context->Op == OP_CURVE2 || context->Op == OP_CURVE3 ) { + if (context->Op == OP_CURVE1 || context->Op == OP_CURVE4 ) { + DrawArrowHeadsArray(&anchors_da,pos1,FindAngle(context->ArcData.curvePos,pos), + TRUE,wDrawColorRed); + } else if (context->Op == OP_CURVE2 || context->Op == OP_CURVE3 ) { CreateEndAnchor(context->ArcData.pos2,FALSE); - DrawArrowHeadsArray(&anchors_da,context->ArcData.pos2,FindAngle(context->ArcData.curvePos,context->ArcData.pos2)+90,TRUE,wDrawColorRed); + DrawArrowHeadsArray(&anchors_da,context->ArcData.pos2, + FindAngle(context->ArcData.curvePos,context->ArcData.pos2)+90,TRUE, + wDrawColorRed); } CreateEndAnchor(context->ArcData.curvePos,TRUE); /*drawContext = context; @@ -827,9 +888,10 @@ STATUS_T DrawGeomMouse( case OP_FILLCIRCLE1: case OP_FILLCIRCLE2: case OP_FILLCIRCLE3: - if ( context->Op>=OP_FILLCIRCLE1 && context->Op<=OP_FILLCIRCLE3 ) + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); + if ( context->Op>=OP_FILLCIRCLE1 && context->Op<=OP_FILLCIRCLE3 ) { tempSegs(0).type = SEG_FILCRCL; - tempSegs_da.cnt = 1; + } context->State = 2; context->radius = tempSegs(0).u.c.radius; break; @@ -840,13 +902,13 @@ STATUS_T DrawGeomMouse( pts[inx].pt = tempSegs(inx).u.l.pos[0]; pts[inx].pt_type = wPolyLineStraight; } + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); tempSegs(0).type = (context->Op == OP_FILLBOX)?SEG_FILPOLY:SEG_POLY; tempSegs(0).u.p.cnt = 4; tempSegs(0).u.p.pts = pts; tempSegs(0).u.p.angle = 0.0; tempSegs(0).u.p.orig = zero; tempSegs(0).u.p.polyType = RECTANGLE; - tempSegs_da.cnt = 1; /*drawContext = context; DrawGeomOp( I2VP(context->Op) );*/ context->length = FindDistance(pts[0].pt,pts[1].pt); @@ -857,8 +919,8 @@ STATUS_T DrawGeomMouse( case OP_POLY: case OP_FILLPOLY: case OP_POLYLINE: - tempSegs_da.cnt = segCnt; - anchors_da.cnt=0; + DYNARR_SET( trkSeg_t, tempSegs_da, segCnt ); + DYNARR_RESET( trkSeg_t, anchors_da ); //End if close to start if ( segCnt>2 && IsClose(FindDistance(tempSegs(0).u.l.pos[0], pos))) { EndPoly(context, tempSegs_da.cnt, context->Op==OP_POLYLINE); @@ -886,12 +948,16 @@ STATUS_T DrawGeomMouse( } int text_inx = tempSegs_da.cnt-1; //tempSegs(tempSegs_da.cnt-1).u.l.pos[1] = pos; - context->length = FindDistance(tempSegs(text_inx).u.l.pos[0],tempSegs(text_inx).u.l.pos[1]); + context->length = FindDistance(tempSegs(text_inx).u.l.pos[0], + tempSegs(text_inx).u.l.pos[1]); if (text_inx>1) { - ANGLE_T an = FindAngle(tempSegs(text_inx-1).u.l.pos[0],tempSegs(text_inx-1).u.l.pos[1]); - context->angle = NormalizeAngle(FindAngle(tempSegs(text_inx).u.l.pos[0],tempSegs(text_inx).u.l.pos[1])-an); - } else + ANGLE_T an = FindAngle(tempSegs(text_inx-1).u.l.pos[0], + tempSegs(text_inx-1).u.l.pos[1]); + context->angle = NormalizeAngle(FindAngle(tempSegs(text_inx).u.l.pos[0], + tempSegs(text_inx).u.l.pos[1])-an); + } else { context->angle = FindAngle(tempSegs(1).u.l.pos[0],tempSegs(1).u.l.pos[1]); + } context->State = 1; context->index = text_inx; segCnt = tempSegs_da.cnt; @@ -915,24 +981,28 @@ STATUS_T DrawGeomMouse( DYNARR_RESET(trkSeg_t, anchors_da ); int key = (action>>8&0xFF); if ( key == 0x0D || - key == ' ' || - (key == 0x09 && ((MyGetKeyState() & (WKEY_SHIFT|WKEY_CTRL|WKEY_ALT)) != WKEY_SHIFT))) { //Tab continue - if ((context->Op == OP_POLY) || (context->Op == OP_FILLPOLY) || (context->Op == OP_POLYLINE)) { - tempSegs_da.cnt = segCnt; + key == ' ' || + (key == 0x09 + && ((MyGetKeyState() & (WKEY_SHIFT|WKEY_CTRL|WKEY_ALT)) != + WKEY_SHIFT))) { //Tab continue + if ((context->Op == OP_POLY) || (context->Op == OP_FILLPOLY) + || (context->Op == OP_POLYLINE)) { + DYNARR_SET( trkSeg_t, tempSegs_da, segCnt ); //If last segment wasn't just a point, add another starting on its end - if (!IsClose(FindDistance(tempSegs(segCnt-1).u.l.pos[0],tempSegs(segCnt-1).u.l.pos[1]))) { + if (!IsClose(FindDistance(tempSegs(segCnt-1).u.l.pos[0], + tempSegs(segCnt-1).u.l.pos[1]))) { DYNARR_APPEND(trkSeg_t,tempSegs_da,1); - segPtr = &tempSegs(tempSegs_da.cnt-1); + segPtr = &DYNARR_LAST( trkSeg_t, tempSegs_da ); segPtr->type = SEG_STRLIN; segPtr->u.l.pos[0] = segPtr[-1].u.l.pos[1]; segPtr->u.l.pos[1] = tempSegs(0).u.l.pos[0]; } - EndPoly(context, tempSegs_da.cnt, context->Op == OP_POLYLINE); - DYNARR_RESET(pts_t, points_da); + EndPoly(context, tempSegs_da.cnt, context->Op == OP_POLYLINE); + DYNARR_RESET(pts_t, points_da); DYNARR_RESET(trkSeg_t,tempSegs_da); } else { if (context->State == 2) { - tempSegs_da.cnt = segCnt; + DYNARR_SET( trkSeg_t, tempSegs_da, segCnt ); DrawGeomOk(context->UndoStarted); context->UndoStarted = FALSE; @@ -940,9 +1010,11 @@ STATUS_T DrawGeomMouse( } context->State = 0; segCnt = 0; - if (key == 0x0D) return C_CONTINUE; //Esc - go to Reset - else return C_TERMINATE; //Space/Enter/Tab - end command - } else if (key == 0x09 && ((MyGetKeyState() & (WKEY_SHIFT|WKEY_CTRL|WKEY_ALT)) == WKEY_SHIFT)) { //Tab plus shift - abandon + if (key == 0x0D) { return C_CONTINUE; } //Esc - go to Reset + else { return C_TERMINATE; } //Space/Enter/Tab - end command + } else if (key == 0x09 + && ((MyGetKeyState() & (WKEY_SHIFT|WKEY_CTRL|WKEY_ALT)) == + WKEY_SHIFT)) { //Tab plus shift - abandon context->State = 0; segCnt = 0; return C_TERMINATE; @@ -958,21 +1030,20 @@ STATUS_T DrawGeomMouse( case C_CANCEL: DYNARR_RESET(trkSeg_t, anchors_da ); - tempSegs_da.cnt = 0; + DYNARR_RESET( trkSeg_t, tempSegs_da ); context->message( "" ); context->Changed = FALSE; context->State = 0; segCnt = 0; - lastValid = FALSE; +// lastValid = FALSE; return C_TERMINATE; case C_REDRAW: - DrawSegs( &tempD, zero, 0.0, &tempSegs(0), tempSegs_da.cnt, trackGauge, wDrawColorBlack ); - if (anchors_da.cnt > 0) { - DrawSegs( &tempD, zero, 0.0, &anchors(0), anchors_da.cnt, 0.0, wDrawColorBlack ); - } + DrawSegsDA( &tempD, NULL, zero, 0.0, &tempSegs_da, trackGauge, wDrawColorBlack, + 0 ); + DrawSegsDA( &tempD, NULL, zero, 0.0, &anchors_da, 0.0, wDrawColorBlack, 0 ); return C_CONTINUE; - + case C_CMDMENU: return C_CONTINUE; @@ -989,10 +1060,12 @@ typedef enum {POLY_NONE, POLY_SELECTED, POLYPOINT_SELECTED} PolyState_e; static PolyState_e polyState = POLY_NONE; static coOrd rotate_origin; static ANGLE_T rotate_angle; -static dynArr_t origin_da; +//static dynArr_t origin_da; -void static CreateCircleAnchor(wBool_t selected,coOrd center, DIST_T rad, ANGLE_T angle) { +void static CreateCircleAnchor(wBool_t selected,coOrd center, DIST_T rad, + ANGLE_T angle) +{ DYNARR_RESET(trkSeg_t,anchors_da); double d = tempD.scale*0.15; DYNARR_APPEND(trkSeg_t,anchors_da,2); @@ -1003,7 +1076,8 @@ void static CreateCircleAnchor(wBool_t selected,coOrd center, DIST_T rad, ANGLE_ PointOnCircle(&anchors(0).u.c.center,center,rad,angle); } -void static CreateLineAnchors(int index, coOrd p0, coOrd p1) { +void static CreateLineAnchors(int index, coOrd p0, coOrd p1) +{ DYNARR_RESET(trkSeg_t,anchors_da); double d = tempD.scale*0.15; DYNARR_APPEND(trkSeg_t,anchors_da,2); @@ -1018,29 +1092,35 @@ void static CreateLineAnchors(int index, coOrd p0, coOrd p1) { anchors(1).color = wDrawColorBlue; anchors(1).u.c.radius = d/2; anchors(1).u.c.center = p1; - if (index>=0) wSetCursor(mainD.d,wCursorNone); + if (index>=0) { wSetCursor(mainD.d,wCursorNone); } } -void static CreateBoxAnchors(int index, pts_t pt[4]) { +void static CreateBoxAnchors(int index, pts_t pt[4]) +{ DYNARR_RESET(trkSeg_t,anchors_da); - double d = tempD.scale*0.15; +// double d = tempD.scale*0.15; ANGLE_T a = FindAngle(pt[0].pt,pt[1].pt); ANGLE_T diag = FindAngle(pt[0].pt,pt[2].pt); - if (index>=0) wSetCursor(mainD.d,wCursorNone); - for (int i=0;i<4;i++) { + if (index>=0) { wSetCursor(mainD.d,wCursorNone); } + for (int i=0; i<4; i++) { DYNARR_SET(trkSeg_t,anchors_da,anchors_da.cnt+5); - DrawArrowHeads(&DYNARR_N(trkSeg_t,anchors_da,anchors_da.cnt-5),pt[i].pt,(diag>a?45.0:-45.0)+a+(90.0*(i)),TRUE,i==index?wDrawColorRed:wDrawColorBlue); + DrawArrowHeads(&DYNARR_N(trkSeg_t,anchors_da,anchors_da.cnt-5),pt[i].pt, + (diag>a?45.0:-45.0)+a+(90.0*(i)),TRUE,i==index?wDrawColorRed:wDrawColorBlue); } coOrd pp; - for (int i=0;i<4;i++) { - pp.x = (i==3?((((pt[0].pt.x - pt[i].pt.x)/2))+pt[i].pt.x):((pt[i+1].pt.x - pt[i].pt.x)/2)+pt[i].pt.x); - pp.y = (i==3?((((pt[0].pt.y - pt[i].pt.y)/2))+pt[i].pt.y):((pt[i+1].pt.y - pt[i].pt.y)/2)+pt[i].pt.y); + for (int i=0; i<4; i++) { + pp.x = (i==3?((((pt[0].pt.x - pt[i].pt.x)/2))+pt[i].pt.x):(( + pt[i+1].pt.x - pt[i].pt.x)/2)+pt[i].pt.x); + pp.y = (i==3?((((pt[0].pt.y - pt[i].pt.y)/2))+pt[i].pt.y):(( + pt[i+1].pt.y - pt[i].pt.y)/2)+pt[i].pt.y); DYNARR_SET(trkSeg_t,anchors_da,anchors_da.cnt+5); - DrawArrowHeads(&DYNARR_N(trkSeg_t,anchors_da,anchors_da.cnt-5),pp,90.0*(i-1)+a,TRUE,i==index+5?wDrawColorRed:wDrawColorBlue); + DrawArrowHeads(&DYNARR_N(trkSeg_t,anchors_da,anchors_da.cnt-5),pp,90.0*(i-1)+a, + TRUE,i==index+5?wDrawColorRed:wDrawColorBlue); } } -void static CreateOriginAnchor(coOrd origin, wBool_t trans_selected) { +void static CreateOriginAnchor(coOrd origin, wBool_t trans_selected) +{ double d = tempD.scale*0.15; DYNARR_APPEND(trkSeg_t,anchors_da,2); int i = anchors_da.cnt-1; @@ -1051,7 +1131,7 @@ void static CreateOriginAnchor(coOrd origin, wBool_t trans_selected) { anchors(i).u.l.pos[0] = p0; anchors(i).u.l.pos[1] = p1; anchors(i).color = trans_selected?wDrawColorAqua:wDrawColorBlue; - anchors(i).width = 0; + anchors(i).lineWidth = 0; DYNARR_APPEND(trkSeg_t,anchors_da,1); Translate(&p0,origin,90,d*4); Translate(&p1,origin,90,-d*4); @@ -1060,11 +1140,13 @@ void static CreateOriginAnchor(coOrd origin, wBool_t trans_selected) { anchors(i).u.l.pos[0] = p0; anchors(i).u.l.pos[1] = p1; anchors(i).color = wDrawColorBlue; - anchors(i).width = 0; - if (trans_selected) wSetCursor(mainD.d,wCursorNone); + anchors(i).lineWidth = 0; + if (trans_selected) { wSetCursor(mainD.d,wCursorNone); } } -void static CreateCurveAnchors(int index, coOrd pm, coOrd pc, coOrd p0, coOrd p1) { +void static CreateCurveAnchors(int index, coOrd pm, coOrd pc, coOrd p0, + coOrd p1) +{ DYNARR_RESET(trkSeg_t,anchors_da); double d = tempD.scale*0.15; DYNARR_APPEND(trkSeg_t,anchors_da,9); @@ -1073,69 +1155,73 @@ void static CreateCurveAnchors(int index, coOrd pm, coOrd pc, coOrd p0, coOrd p1 anchors(0).color = wDrawColorBlue; anchors(0).u.c.radius = d/2; anchors(0).u.c.center = p0; - anchors(0).width = 0; + anchors(0).lineWidth = 0; DYNARR_APPEND(trkSeg_t,anchors_da,8); anchors(1).type = (index ==1)?SEG_FILCRCL:SEG_CRVLIN; anchors(1).u.c.a1 = 360.0; anchors(1).color = wDrawColorBlue; anchors(1).u.c.radius = d/2; anchors(1).u.c.center = p1; - anchors(1).width = 0; + anchors(1).lineWidth = 0; DYNARR_SET(trkSeg_t,anchors_da,anchors_da.cnt+5); - DrawArrowHeads(&DYNARR_N(trkSeg_t,anchors_da,anchors_da.cnt-5),pm,FindAngle(pm,pc),TRUE,index==2?wDrawColorAqua:wDrawColorBlue); - if (index>=0) wSetCursor(mainD.d,wCursorNone); - else wSetCursor(mainD.d,defaultCursor); + DrawArrowHeads(&DYNARR_N(trkSeg_t,anchors_da,anchors_da.cnt-5),pm,FindAngle(pm, + pc),TRUE,index==2?wDrawColorAqua:wDrawColorBlue); + if (index>=0) { wSetCursor(mainD.d,wCursorNone); } + else { wSetCursor(mainD.d,defaultCursor); } } -void static CreatePolyAnchors(int index) { - DYNARR_RESET(trkSeg_t,anchors_da); - double d = tempD.scale*0.15; - for ( int inx=0; inx<points_da.cnt; inx++ ) { - DYNARR_APPEND(trkSeg_t,anchors_da,3); - - anchors(inx).type = point_selected(inx)?SEG_FILCRCL:SEG_CRVLIN; - anchors(inx).u.c.a0 = 0.0; - anchors(inx).u.c.a1 = 360.0; - anchors(inx).width = 0; - anchors(inx).color = wDrawColorBlue; - anchors(inx).u.c.radius = d/2; - anchors(inx).u.c.center = points(inx).pt; - } - if (index>=0) { - DYNARR_APPEND(trkSeg_t,anchors_da,1); - int inx = anchors_da.cnt-1; - anchors(inx).type = SEG_STRLIN; - anchors(inx).u.l.pos[0] = points(index==0?points_da.cnt-1:index-1).pt; - anchors(inx).u.l.pos[1] = points(index).pt; - anchors(inx).color = wDrawColorBlue; - anchors(inx).width = 0; - DYNARR_APPEND(trkSeg_t,anchors_da,1); - inx = anchors_da.cnt-1; - int index0 = index==0?points_da.cnt-1:index-1; - ANGLE_T an0 = FindAngle(points(index0).pt, points(index).pt); - ANGLE_T an1 = FindAngle(points(index0==0?points_da.cnt-1:index0-1).pt, points(index0).pt); - anchors(inx).type = SEG_CRVLIN; - if (DifferenceBetweenAngles(an0,an1)<=0) { - anchors(inx).u.c.a1 = DifferenceBetweenAngles(an0,an1)-180; - anchors(inx).u.c.a0 = an0; - } else { - anchors(inx).u.c.a1 = 180-DifferenceBetweenAngles(an0,an1); - anchors(inx).u.c.a0 = NormalizeAngle(180+an1); - } - anchors(inx).color = wDrawColorBlue; - anchors(inx).u.c.radius = d; - anchors(inx).u.c.center = points(index0).pt; +void static CreatePolyAnchors(int index) +{ + DYNARR_RESET(trkSeg_t,anchors_da); + double d = tempD.scale*0.15; + for ( int inx=0; inx<points_da.cnt; inx++ ) { + DYNARR_APPEND(trkSeg_t,anchors_da,3); + + anchors(inx).type = point_selected(inx)?SEG_FILCRCL:SEG_CRVLIN; + anchors(inx).u.c.a0 = 0.0; + anchors(inx).u.c.a1 = 360.0; + anchors(inx).lineWidth = 0; + anchors(inx).color = wDrawColorBlue; + anchors(inx).u.c.radius = d/2; + anchors(inx).u.c.center = points(inx).pt; + } + if (index>=0) { + DYNARR_APPEND(trkSeg_t,anchors_da,1); + int inx = anchors_da.cnt-1; + anchors(inx).type = SEG_STRLIN; + anchors(inx).u.l.pos[0] = points(index==0?points_da.cnt-1:index-1).pt; + anchors(inx).u.l.pos[1] = points(index).pt; + anchors(inx).color = wDrawColorBlue; + anchors(inx).lineWidth = 0; + DYNARR_APPEND(trkSeg_t,anchors_da,1); + inx = anchors_da.cnt-1; + int index0 = index==0?points_da.cnt-1:index-1; + ANGLE_T an0 = FindAngle(points(index0).pt, points(index).pt); + ANGLE_T an1 = FindAngle(points(index0==0?points_da.cnt-1:index0-1).pt, + points(index0).pt); + anchors(inx).type = SEG_CRVLIN; + if (DifferenceBetweenAngles(an0,an1)<=0) { + anchors(inx).u.c.a1 = DifferenceBetweenAngles(an0,an1)-180; + anchors(inx).u.c.a0 = an0; + } else { + anchors(inx).u.c.a1 = 180-DifferenceBetweenAngles(an0,an1); + anchors(inx).u.c.a0 = NormalizeAngle(180+an1); } + anchors(inx).color = wDrawColorBlue; + anchors(inx).u.c.radius = d; + anchors(inx).u.c.center = points(index0).pt; + } } -void CreateMovingAnchor(coOrd pos,BOOL_T fill) { +void CreateMovingAnchor(coOrd pos,BOOL_T fill) +{ double d = tempD.scale*0.15; DYNARR_APPEND(trkSeg_t,anchors_da,1); int inx = anchors_da.cnt-1; anchors(inx).type = fill?SEG_FILCRCL:SEG_CRVLIN; anchors(inx).u.c.a0 = 0.0; anchors(inx).u.c.a1 = 360.0; - anchors(inx).width = 0; + anchors(inx).lineWidth = 0; anchors(inx).color = wDrawColorBlue; anchors(inx).u.c.radius = d/4; anchors(inx).u.c.center = pos; @@ -1150,546 +1236,586 @@ void CreateMovingAnchor(coOrd pos,BOOL_T fill) { * The last selected node can be deleted * */ -STATUS_T DrawGeomPolyModify( - wAction_t action, - coOrd pos, - drawModContext_t *context) { +static STATUS_T DrawGeomPolyModify( + wAction_t action, + coOrd pos, + drawModContext_t *context) +{ double d; static int selected_count; static int segInx; static int prev_inx; - static wDrawColor save_color; - static wBool_t drawnAngle; - static double currentAngle; - static double baseAngle; - static BOOL_T lock; +// static wDrawColor save_color; +// static wBool_t drawnAngle; +// static double currentAngle; +// static double baseAngle; +// static BOOL_T lock; switch ( action&0xFF ) { - case C_START: - lock = FALSE; - DistanceSegs( context->orig, context->angle, context->segCnt, context->segPtr, &pos, &segInx ); - if (segInx == -1) - return C_ERROR; - if (context->type != SEG_POLY && context->type != SEG_FILPOLY) - return C_ERROR; - prev_inx = -1; - polyState = POLY_SELECTED; - polyInx = -1; - //Copy points - DYNARR_RESET( pts_t, points_da); - DYNARR_RESET( wBool_t, select_da); - for (int inx=0;inx<context->segPtr->u.p.cnt;inx++) { - DYNARR_APPEND(pts_t, points_da,3); - DYNARR_APPEND(wBool_t,select_da,3); - REORIGIN( points(inx).pt, context->segPtr[segInx].u.p.pts[inx].pt, context->angle, context->orig ); - points(inx).pt_type = context->segPtr[segInx].u.p.pts[inx].pt_type; - point_selected(inx) = FALSE; - } - context->prev_inx = -1; - context->max_inx = points_da.cnt-1; - selected_count=0; - rotate_origin = context->orig; - rotate_angle = context->angle; - context->p0 = points(0).pt; - context->p1 = points(1).pt; - //Show points - tempSegs_da.cnt = 1; - tempSegs(0).width = context->segPtr->width; - save_color = context->segPtr->color; - tempSegs(0).color = wDrawColorRed; - tempSegs(0).type = context->type; - tempSegs(0).u.p.cnt = context->segPtr[segInx].u.p.cnt; - tempSegs(0).u.p.angle = 0.0; - tempSegs(0).u.p.orig = zero; - tempSegs(0).u.p.polyType = context->segPtr[segInx].u.p.polyType; - tempSegs(0).u.p.pts = &points(0); - CreatePolyAnchors( -1); - InfoMessage(_("Select points or use context menu")); - ClrAllTrkBitsRedraw( TB_UNDRAWN, TRUE ); - UndrawNewTrack( context->trk ); - return C_CONTINUE; - case wActionMove: - DYNARR_RESET(trkSeg_t,anchors_da); - CreatePolyAnchors(context->prev_inx); - for (int i = 0; i<points_da.cnt; i++) { - if (IsClose(FindDistance(pos,points(i).pt))) { - CreateMovingAnchor(points(i).pt,TRUE); - return C_CONTINUE; - } + case C_START: +// lock = FALSE; + DistanceSegs( context->orig, context->angle, context->segCnt, context->segPtr, + &pos, &segInx ); + if (segInx == -1) { + return C_ERROR; + } + if (context->type != SEG_POLY && context->type != SEG_FILPOLY) { + return C_ERROR; + } + prev_inx = -1; + polyState = POLY_SELECTED; + polyInx = -1; + //Copy points + DYNARR_RESET( pts_t, points_da); + DYNARR_RESET( wBool_t, select_da); + for (int inx=0; inx<context->segPtr->u.p.cnt; inx++) { + DYNARR_APPEND(pts_t, points_da,3); + DYNARR_APPEND(wBool_t,select_da,3); + REORIGIN( points(inx).pt, context->segPtr[segInx].u.p.pts[inx].pt, + context->angle, context->orig ); + points(inx).pt_type = context->segPtr[segInx].u.p.pts[inx].pt_type; + point_selected(inx) = FALSE; + } + context->prev_inx = -1; + context->max_inx = points_da.cnt-1; + selected_count=0; + rotate_origin = context->orig; + rotate_angle = context->angle; + context->p0 = points(0).pt; + context->p1 = points(1).pt; + //Show points + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); + tempSegs(0).lineWidth = context->segPtr->lineWidth; +// save_color = context->segPtr->color; + tempSegs(0).color = wDrawColorRed; + tempSegs(0).type = context->type; + tempSegs(0).u.p.cnt = context->segPtr[segInx].u.p.cnt; + tempSegs(0).u.p.angle = 0.0; + tempSegs(0).u.p.orig = zero; + tempSegs(0).u.p.polyType = context->segPtr[segInx].u.p.polyType; + tempSegs(0).u.p.pts = &points(0); + CreatePolyAnchors( -1); + InfoMessage(_("Select points or use context menu")); + ClrAllTrkBitsRedraw( TB_UNDRAWN, TRUE ); + UndrawNewTrack( context->trk ); + return C_CONTINUE; + case wActionMove: + DYNARR_RESET(trkSeg_t,anchors_da); + CreatePolyAnchors(context->prev_inx); + for (int i = 0; i<points_da.cnt; i++) { + if (IsClose(FindDistance(pos,points(i).pt))) { + CreateMovingAnchor(points(i).pt,TRUE); + return C_CONTINUE; } - wSetCursor(mainD.d,defaultCursor); - int pInx=0; - coOrd pm0,pm1; - DIST_T dm = DIST_INF; - for ( int inx=0; inx<points_da.cnt; inx++ ) { - pm0 = pos; - DIST_T ddm = LineDistance( &pm0, points( inx==0?points_da.cnt-1:inx-1).pt, points(inx).pt ); - if ( dm > ddm ) { - dm = ddm; - pm1 = pm0; - pInx = inx; - } + } + wSetCursor(mainD.d,defaultCursor); + int pInx=0; + coOrd pm0,pm1; + DIST_T dm = DIST_INF; + for ( int inx=0; inx<points_da.cnt; inx++ ) { + pm0 = pos; + DIST_T ddm = LineDistance( &pm0, points( inx==0?points_da.cnt-1:inx-1).pt, + points(inx).pt ); + if ( dm > ddm ) { + dm = ddm; + pm1 = pm0; + pInx = inx; } - if (!IsClose(dm)) return C_CONTINUE; - int inxm = pInx==0?points_da.cnt-1:pInx-1; - dm = FindDistance( points(inxm).pt, pm1 ); - DIST_T ddm = FindDistance( points(inxm).pt, points(pInx).pt ); - if ( (dm > 0.25*ddm) && (dm < 0.75*ddm)) { - CreateMovingAnchor(pm1,FALSE); + } + if (!IsClose(dm)) { return C_CONTINUE; } + int inxm = pInx==0?points_da.cnt-1:pInx-1; + dm = FindDistance( points(inxm).pt, pm1 ); + DIST_T ddm = FindDistance( points(inxm).pt, points(pInx).pt ); + if ( (dm > 0.25*ddm) && (dm < 0.75*ddm)) { + CreateMovingAnchor(pm1,FALSE); + } else { + if (dm < FindDistance( points(pInx).pt, pm1 )) { + CreateMovingAnchor(points(inxm).pt,TRUE); } else { - if (dm < FindDistance( points(pInx).pt, pm1 )) - CreateMovingAnchor(points(inxm).pt,TRUE); - else - CreateMovingAnchor(points(pInx).pt,TRUE); + CreateMovingAnchor(points(pInx).pt,TRUE); } - return C_CONTINUE; - break; - case C_DOWN: - d = DIST_INF; - polyInx = -1; - coOrd p0; - double dd; - int inx; - if ((MyGetKeyState() & (WKEY_SHIFT|WKEY_CTRL|WKEY_ALT)) != WKEY_SHIFT) { - if (selected_count <2 ) { - //Wipe out selection(s) if we don't have multiple already (i,e. move with >1 selected) - for (int i=0;i<points_da.cnt;i++) { + } + return C_CONTINUE; + break; + case C_DOWN: + d = DIST_INF; + polyInx = -1; + coOrd p0; + double dd; + int inx; + if ((MyGetKeyState() & (WKEY_SHIFT|WKEY_CTRL|WKEY_ALT)) != WKEY_SHIFT) { + if (selected_count <2 ) { + //Wipe out selection(s) if we don't have multiple already (i,e. move with >1 selected) + for (int i=0; i<points_da.cnt; i++) { + point_selected(i) = FALSE; + } + selected_count = 0; + } else { + for (int i=0; i<points_da.cnt; i++) { + if (IsClose(FindDistance(pos,points(i).pt)) && point_selected(i)==TRUE) { point_selected(i) = FALSE; - } - selected_count = 0; - } else { - for (int i=0;i<points_da.cnt;i++) { - if (IsClose(FindDistance(pos,points(i).pt)) && point_selected(i)==TRUE) { - point_selected(i) = FALSE; - selected_count--; - } + selected_count--; } } } - //Select Point (polyInx) - for ( int inx=0; inx<points_da.cnt; inx++ ) { - p0 = pos; - dd = LineDistance( &p0, points( inx==0?points_da.cnt-1:inx-1).pt, points(inx).pt ); - if ( d > dd ) { - d = dd; - polyInx = inx; - } + } + //Select Point (polyInx) + for ( int inx=0; inx<points_da.cnt; inx++ ) { + p0 = pos; + dd = LineDistance( &p0, points( inx==0?points_da.cnt-1:inx-1).pt, + points(inx).pt ); + if ( d > dd ) { + d = dd; + polyInx = inx; } - if (!IsClose(d)) { //Not on/near object - de-select all points - for (int i=0;i<points_da.cnt;i++) { - point_selected(i) = FALSE; + } + if (!IsClose(d)) { //Not on/near object - de-select all points + for (int i=0; i<points_da.cnt; i++) { + point_selected(i) = FALSE; + } + polyInx = -1; + selected_count = 0; + CreatePolyAnchors( -1); + context->prev_inx = -1; + return C_CONTINUE; //Not close to any line + } + polyState = POLYPOINT_SELECTED; + inx = polyInx==0?points_da.cnt-1:polyInx-1; + //Find if the point is to be added + d = FindDistance( points(inx).pt, pos ); + dd = FindDistance( points(inx).pt, points(polyInx).pt ); + if ( d < 0.25*dd ) { + polyInx = inx; + } else if ( d > 0.75*dd ) { + ; + } else { + if (selected_count == + 0) { //Only add a new point if no points are already selected! + DYNARR_APPEND(wBool_t,select_da,1); + for (int i=0; i<select_da.cnt; i++) { + if (i == polyInx) { point_selected(i) = TRUE; } + else { point_selected(i) = FALSE; } } - polyInx = -1; - selected_count = 0; - CreatePolyAnchors( -1); - context->prev_inx = -1; - return C_CONTINUE; //Not close to any line - } - polyState = POLYPOINT_SELECTED; - inx = polyInx==0?points_da.cnt-1:polyInx-1; - //Find if the point is to be added - d = FindDistance( points(inx).pt, pos ); - dd = FindDistance( points(inx).pt, points(polyInx).pt ); - if ( d < 0.25*dd ) { - polyInx = inx; - } else if ( d > 0.75*dd ) { - ; - } else { - if (selected_count == 0) { //Only add a new point if no points are already selected! - DYNARR_APPEND(wBool_t,select_da,1); - for (int i=0;i<select_da.cnt;i++) { - if (i == polyInx) point_selected(i) = TRUE; - else point_selected(i) = FALSE; - } - selected_count=1; - DYNARR_APPEND(pts_t,points_da,1); - tempSegs(0).u.p.pts = &points(0); - for (inx=points_da.cnt-1; inx>polyInx; inx-- ) { - points(inx) = points(inx-1); - } - points(polyInx).pt_type = wPolyLineStraight; - tempSegs(0).u.p.cnt = points_da.cnt; - context->max_inx = points_da.cnt-1; + selected_count=1; + DYNARR_APPEND(pts_t,points_da,1); + tempSegs(0).u.p.pts = &points(0); + for (inx=points_da.cnt-1; inx>polyInx; inx-- ) { + points(inx) = points(inx-1); } + points(polyInx).pt_type = wPolyLineStraight; + tempSegs(0).u.p.cnt = points_da.cnt; + context->max_inx = points_da.cnt-1; } - //If already selected (multiple points), not using shift (to add) select, and on object move to first point - if (selected_count>0 && ((MyGetKeyState() & (WKEY_SHIFT|WKEY_CTRL|WKEY_ALT)) != WKEY_SHIFT)) { - for (int i=0; i<points_da.cnt;i++) { - if (IsClose(FindDistance(pos,points(i).pt))) { + } + //If already selected (multiple points), not using shift (to add) select, and on object move to first point + if (selected_count>0 + && ((MyGetKeyState() & (WKEY_SHIFT|WKEY_CTRL|WKEY_ALT)) != WKEY_SHIFT)) { + for (int i=0; i<points_da.cnt; i++) { + if (IsClose(FindDistance(pos,points(i).pt))) { - point_selected(i) = FALSE; + point_selected(i) = FALSE; - } - if (point_selected(i) == TRUE) { - polyInx = i; - } } - } - pos = points(polyInx).pt; //Move to point - if (point_selected(polyInx)) { //Already selected - } else { - point_selected(polyInx) = TRUE; - ++selected_count; - } - //Work out before and after point - int first_inx = -1; - if (selected_count >0 && selected_count < points_da.cnt-2) { - for (int i=0; i<points_da.cnt;i++) { - if (point_selected(i)) { - first_inx = i; - break; - } + if (point_selected(i) == TRUE) { + polyInx = i; } } - int last_inx = -1, next_inx = -1; - ANGLE_T an1, an0; - if (first_inx >=0) { - if (first_inx == 0) { - last_inx = points_da.cnt-1; - } else { - last_inx = first_inx-1; - } - if (first_inx == points_da.cnt-1) { - next_inx = 0; - } else { - next_inx = first_inx+1; - } - context->length = FindDistance(points(last_inx).pt,points(first_inx).pt); - an1 = FindAngle(points(last_inx).pt,points(first_inx).pt); - an0 = FindAngle(points(last_inx==0?(points_da.cnt-1):(last_inx-1)).pt,points(last_inx).pt); - if (DifferenceBetweenAngles(an0,an1)<=0) { - context->rel_angle = 180+DifferenceBetweenAngles(an0,an1); - } else { - context->rel_angle = 180-DifferenceBetweenAngles(an0,an1); + } + pos = points(polyInx).pt; //Move to point + if (point_selected(polyInx)) { //Already selected + } else { + point_selected(polyInx) = TRUE; + ++selected_count; + } + //Work out before and after point + int first_inx = -1; + if (selected_count >0 && selected_count < points_da.cnt-2) { + for (int i=0; i<points_da.cnt; i++) { + if (point_selected(i)) { + first_inx = i; + break; } + } + } + int last_inx = -1; +// int next_inx = -1; + ANGLE_T an1, an0; + if (first_inx >=0) { + if (first_inx == 0) { + last_inx = points_da.cnt-1; } else { - + last_inx = first_inx-1; + } +// if (first_inx == points_da.cnt-1) { +// next_inx = 0; +// } else { +// next_inx = first_inx+1; +// } + context->length = FindDistance(points(last_inx).pt,points(first_inx).pt); + an1 = FindAngle(points(last_inx).pt,points(first_inx).pt); + an0 = FindAngle(points(last_inx==0?(points_da.cnt-1):(last_inx-1)).pt, + points(last_inx).pt); + if (DifferenceBetweenAngles(an0,an1)<=0) { + context->rel_angle = 180+DifferenceBetweenAngles(an0,an1); + } else { + context->rel_angle = 180-DifferenceBetweenAngles(an0,an1); } - context->prev_inx = first_inx; - context->p0 = points(0).pt; - context->p1 = points(1).pt; - //Show three anchors only - CreatePolyAnchors(first_inx); - return C_CONTINUE; - case C_LDOUBLE: + } else { + + } + context->prev_inx = first_inx; + context->p0 = points(0).pt; + context->p1 = points(1).pt; + //Show three anchors only + CreatePolyAnchors(first_inx); + return C_CONTINUE; + case C_LDOUBLE: + return C_CONTINUE; + case C_MOVE: + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); + if (polyState != POLYPOINT_SELECTED) { return C_CONTINUE; - case C_MOVE: - tempSegs_da.cnt = 1; - if (polyState != POLYPOINT_SELECTED) { - return C_CONTINUE; - } - //Moving with Point Selected - if (polyInx<0) return C_ERROR; - first_inx = -1; - if (selected_count >0 && selected_count < points_da.cnt-2) { - for (int i=0; i<points_da.cnt;i++) { - if (point_selected(i)) { - first_inx = i; - break; - } + } + //Moving with Point Selected + if (polyInx<0) { return C_ERROR; } + first_inx = -1; + if (selected_count >0 && selected_count < points_da.cnt-2) { + for (int i=0; i<points_da.cnt; i++) { + if (point_selected(i)) { + first_inx = i; + break; } } - last_inx = -1; - next_inx = -1; - coOrd intersect; - wBool_t show_intersect = FALSE; - if (first_inx >=0) { + } + last_inx = -1; +// next_inx = -1; + coOrd intersect; + wBool_t show_intersect = FALSE; + if (first_inx >=0) { + if (first_inx == 0) { + last_inx = points_da.cnt-1; + } else { + last_inx = first_inx-1; + } +// if (first_inx == points_da.cnt-1) { +// next_inx = 0; +// } else { +// next_inx = first_inx+1; +// } + //Lock to 90 degrees first/last point + if ((MyGetKeyState() & (WKEY_SHIFT|WKEY_CTRL|WKEY_ALT)) == WKEY_CTRL ) { + ANGLE_T last_angle; +// ANGLE_T next_angle; + coOrd last_point,next_point; if (first_inx == 0) { - last_inx = points_da.cnt-1; + last_point = points(points_da.cnt-1).pt; + last_angle = FindAngle(points(points_da.cnt-2).pt,last_point); + } else if (first_inx == 1) { + last_point = points(0).pt; + last_angle = FindAngle(points(points_da.cnt-1).pt,last_point); } else { - last_inx = first_inx-1; + last_point = points(first_inx-1).pt; + last_angle = FindAngle(points(first_inx-2).pt,last_point); } if (first_inx == points_da.cnt-1) { - next_inx = 0; + next_point = points(0).pt; +// next_angle = FindAngle(next_point,points(1).pt); + } else if (first_inx == points_da.cnt-2) { + next_point = points(points_da.cnt-1).pt; +// next_angle = FindAngle(next_point,points(0).pt); } else { - next_inx = first_inx+1; + next_point = points(first_inx+1).pt; +// next_angle = FindAngle(next_point,points(first_inx+2).pt); } - //Lock to 90 degrees first/last point - if ((MyGetKeyState() & (WKEY_SHIFT|WKEY_CTRL|WKEY_ALT)) == WKEY_CTRL ) { - ANGLE_T last_angle,next_angle; - coOrd last_point,next_point; - if (first_inx == 0) { - last_point = points(points_da.cnt-1).pt; - last_angle = FindAngle(points(points_da.cnt-2).pt,last_point); - } else if (first_inx == 1) { - last_point = points(0).pt; - last_angle = FindAngle(points(points_da.cnt-1).pt,last_point); - } else { - last_point = points(first_inx-1).pt; - last_angle = FindAngle(points(first_inx-2).pt,last_point); - } - if (first_inx == points_da.cnt-1) { - next_point = points(0).pt; - next_angle = FindAngle(next_point,points(1).pt); - } else if (first_inx == points_da.cnt-2){ - next_point = points(points_da.cnt-1).pt; - next_angle = FindAngle(next_point,points(0).pt); - } else { - next_point = points(first_inx+1).pt; - next_angle = FindAngle(next_point,points(first_inx+2).pt); - } - coOrd diff; - diff.x = pos.x - points(polyInx).pt.x; - diff.y = pos.y - points(polyInx).pt.y; - coOrd pos_lock = points(first_inx).pt; - pos_lock.x += diff.x; - pos_lock.y += diff.y; - //Snap to Right-Angle from previous or from 0 - DIST_T l = FindDistance(last_point, pos_lock); - ANGLE_T angle2 = NormalizeAngle(FindAngle(last_point, pos_lock)-last_angle); - int quad = (int)((angle2+45.0)/90.0); - if (tempSegs_da.cnt != 1 && (quad == 2)) { - pos_lock = last_point; - } else if (quad == 1 || quad == 3) { - l = fabs(l*cos(D2R(((quad==1)?last_angle+90.0:last_angle-90.0)-FindAngle(pos_lock,last_point)))); - Translate( &pos_lock, last_point, NormalizeAngle((quad==1)?last_angle+90.0:last_angle-90.0), l ); - } else { - l = fabs(l*cos(D2R(((quad==0||quad==4)?last_angle:last_angle+180.0)-FindAngle(pos_lock,last_point)))); - Translate( &pos_lock, last_point, NormalizeAngle((quad==0||quad==4)?last_angle:last_angle+180.0), l ); - } - diff.x = pos_lock.x - points(first_inx).pt.x; - diff.y = pos_lock.y - points(first_inx).pt.y; - pos.x = points(polyInx).pt.x+diff.x; - pos.y = points(polyInx).pt.y+diff.y; - if (selected_count<2) { - if (FindIntersection(&intersect,last_point,last_angle+90.0,next_point,last_angle+180.0)) { - show_intersect = TRUE; - } - } - d = FindDistance(intersect,pos_lock); - if (IsClose(d)) { - pos = intersect; + coOrd diff; + diff.x = pos.x - points(polyInx).pt.x; + diff.y = pos.y - points(polyInx).pt.y; + coOrd pos_lock = points(first_inx).pt; + pos_lock.x += diff.x; + pos_lock.y += diff.y; + //Snap to Right-Angle from previous or from 0 + DIST_T l = FindDistance(last_point, pos_lock); + ANGLE_T angle2 = NormalizeAngle(FindAngle(last_point, pos_lock)-last_angle); + int quad = (int)((angle2+45.0)/90.0); + if (tempSegs_da.cnt != 1 && (quad == 2)) { + pos_lock = last_point; + } else if (quad == 1 || quad == 3) { + l = fabs(l*cos(D2R(((quad==1)?last_angle+90.0:last_angle-90.0)-FindAngle( + pos_lock,last_point)))); + Translate( &pos_lock, last_point, + NormalizeAngle((quad==1)?last_angle+90.0:last_angle-90.0), l ); + } else { + l = fabs(l*cos(D2R(((quad==0 + ||quad==4)?last_angle:last_angle+180.0)-FindAngle(pos_lock,last_point)))); + Translate( &pos_lock, last_point, NormalizeAngle((quad==0 + ||quad==4)?last_angle:last_angle+180.0), l ); + } + diff.x = pos_lock.x - points(first_inx).pt.x; + diff.y = pos_lock.y - points(first_inx).pt.y; + pos.x = points(polyInx).pt.x+diff.x; + pos.y = points(polyInx).pt.y+diff.y; + if (selected_count<2) { + if (FindIntersection(&intersect,last_point,last_angle+90.0,next_point, + last_angle+180.0)) { + show_intersect = TRUE; } - InfoMessage( _("Length = %s, Last angle = %0.2f"), - FormatDistance(FindDistance(pos_lock,last_point)), - PutAngle(FindAngle(pos_lock,last_point))); - - } else SnapPos(&pos); //If not using CTL and snap enabled - } - context->prev_inx = first_inx; - coOrd diff; - diff.x = pos.x - points(polyInx).pt.x; - diff.y = pos.y - points(polyInx).pt.y; - //points(polyInx) = pos; - for (int i=0;i<points_da.cnt;i++) { - if (point_selected(i)) { - points(i).pt.x = points(i).pt.x + diff.x; - points(i).pt.y = points(i).pt.y + diff.y; } + d = FindDistance(intersect,pos_lock); + if (IsClose(d)) { + pos = intersect; + } + InfoMessage( _("Length = %s, Last angle = %0.2f"), + FormatDistance(FindDistance(pos_lock,last_point)), + PutAngle(FindAngle(pos_lock,last_point))); + + } else { SnapPos(&pos); } //If not using CTL and snap enabled + } + context->prev_inx = first_inx; + coOrd diff; + diff.x = pos.x - points(polyInx).pt.x; + diff.y = pos.y - points(polyInx).pt.y; + //points(polyInx) = pos; + for (int i=0; i<points_da.cnt; i++) { + if (point_selected(i)) { + points(i).pt.x = points(i).pt.x + diff.x; + points(i).pt.y = points(i).pt.y + diff.y; } - if (first_inx>=0) { - context->length = FindDistance(points(first_inx).pt,points(last_inx).pt); - an1 = FindAngle(points(last_inx).pt,points(first_inx).pt); - an0 = FindAngle(points(first_inx==0?(points_da.cnt-1):(first_inx-1)).pt,points(first_inx).pt); - context->rel_angle = NormalizeAngle(180-(an1-an0)); + } + if (first_inx>=0) { + context->length = FindDistance(points(first_inx).pt,points(last_inx).pt); + an1 = FindAngle(points(last_inx).pt,points(first_inx).pt); + an0 = FindAngle(points(first_inx==0?(points_da.cnt-1):(first_inx-1)).pt, + points(first_inx).pt); + context->rel_angle = NormalizeAngle(180-(an1-an0)); + } + CreatePolyAnchors(first_inx); + if (show_intersect) { + CreateSquareAnchor(intersect); + } + context->p0 = points(0).pt; + context->p1 = points(1).pt; + return C_CONTINUE; + case C_UP: + context->prev_inx = -1; + if (segInx == -1 || polyState != POLYPOINT_SELECTED) { + return C_CONTINUE; //Didn't get a point selected/added + } + polyState = POLY_SELECTED; //Return to base state + DYNARR_RESET( trkSeg_t, anchors_da ); + CreatePolyAnchors(polyInx); //Show last selection + prev_inx = polyInx; + for (int i=0; i<points_da.cnt; i++) { + if (point_selected(i)) { + first_inx = i; + break; } - CreatePolyAnchors(first_inx); - if (show_intersect) - CreateSquareAnchor(intersect); - context->p0 = points(0).pt; - context->p1 = points(1).pt; - return C_CONTINUE; - case C_UP: - context->prev_inx = -1; - if (segInx == -1 || polyState != POLYPOINT_SELECTED) - return C_CONTINUE; //Didn't get a point selected/added - polyState = POLY_SELECTED; //Return to base state - anchors_da.cnt = 0; - CreatePolyAnchors(polyInx); //Show last selection - prev_inx = polyInx; - for (int i=0;i<points_da.cnt;i++) { - if (point_selected(i)) { - first_inx = i; - break; - } + } + last_inx = first_inx==0?(points_da.cnt-1):(first_inx-1); + if (first_inx>=0) { + context->length = FindDistance(points(first_inx).pt,points(last_inx).pt); + an1 = FindAngle(points(last_inx).pt,points(first_inx).pt); + an0 = FindAngle(points(last_inx==0?(points_da.cnt-1):(last_inx-1)).pt, + points(last_inx).pt); + if (DifferenceBetweenAngles(an0,an1)<=0) { + context->rel_angle = 180+DifferenceBetweenAngles(an0,an1); + } else { + context->rel_angle = 180-DifferenceBetweenAngles(an0,an1); } - last_inx = first_inx==0?(points_da.cnt-1):(first_inx-1); - if (first_inx>=0) { - context->length = FindDistance(points(first_inx).pt,points(last_inx).pt); - an1 = FindAngle(points(last_inx).pt,points(first_inx).pt); - an0 = FindAngle(points(last_inx==0?(points_da.cnt-1):(last_inx-1)).pt,points(last_inx).pt); - if (DifferenceBetweenAngles(an0,an1)<=0) { - context->rel_angle = 180+DifferenceBetweenAngles(an0,an1); - } else { - context->rel_angle = 180-DifferenceBetweenAngles(an0,an1); - } + } + context->prev_inx = first_inx; + context->p0 = points(0).pt; + context->p1 = points(1).pt; + polyInx = -1; + return C_CONTINUE; + case C_UPDATE: + if (context->prev_inx>=0) { + int last_index = context->prev_inx==0?(points_da.cnt-1):(context->prev_inx-1); + an0 = FindAngle(points(last_index==0?(points_da.cnt-1):(last_index-1)).pt, + points(last_index).pt); + an1 = FindAngle(points(last_index).pt,points(context->prev_inx).pt); + if (DifferenceBetweenAngles(an0,an1)<=0) { + an1 = NormalizeAngle(an0-(180-context->rel_angle)); + } else { + an1 = NormalizeAngle((180-context->rel_angle)+an0); } - context->prev_inx = first_inx; - context->p0 = points(0).pt; - context->p1 = points(1).pt; - polyInx = -1; + Translate(&points(prev_inx).pt,points(last_index).pt,an1,context->length); + } + context->rel_angle = fabs(context->rel_angle); + if (context->rel_angle >180) { context->rel_angle = context->rel_angle - 180.0; } + CreatePolyAnchors(prev_inx); + context->p0 = points(0).pt; + context->p1 = points(1).pt; + break; + case C_TEXT: + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); + if (action>>8 == 'o') { //"o" -> origin mode + MenuMode(I2VP(1)); + InfoMessage("Move Origin Mode: Place Origin, p for Points, Enter or Esc"); return C_CONTINUE; - case C_UPDATE: - if (context->prev_inx>=0) { - int last_index = context->prev_inx==0?(points_da.cnt-1):(context->prev_inx-1); - an0 = FindAngle(points(last_index==0?(points_da.cnt-1):(last_index-1)).pt,points(last_index).pt); - an1 = FindAngle(points(last_index).pt,points(context->prev_inx).pt); - if (DifferenceBetweenAngles(an0,an1)<=0) { - an1 = NormalizeAngle(an0-(180-context->rel_angle)); - } else { - an1 = NormalizeAngle((180-context->rel_angle)+an0); - } - Translate(&points(prev_inx).pt,points(last_index).pt,an1,context->length); - } - context->rel_angle = fabs(context->rel_angle); - if (context->rel_angle >180) context->rel_angle = context->rel_angle - 180.0; - CreatePolyAnchors(prev_inx); - context->p0 = points(0).pt; - context->p1 = points(1).pt; - break; - case C_TEXT: - if (action>>8 == 'o') { //"o" -> origin mode - MenuMode(I2VP(1)); - InfoMessage("Move Origin Mode: Place Origin, p for Points, Enter or Esc"); + } + if (((prev_inx>=0 && tempSegs(0).u.p.polyType != POLYLINE) || + ((tempSegs(0).u.p.polyType == POLYLINE) && (prev_inx>=1) + && (prev_inx<=points_da.cnt-2)) ) && + ((action>>8 == 's') || (action>>8 == 'v') || (action>>8 == 'r'))) { + switch(action>>8) { + case 's': + points(context->prev_inx).pt_type = wPolyLineSmooth; return C_CONTINUE; + case 'v': + points(context->prev_inx).pt_type = wPolyLineStraight; + return C_CONTINUE; + case 'r': + points(context->prev_inx).pt_type = wPolyLineRound; + return C_CONTINUE; + default:; } - if (((prev_inx>=0 && tempSegs(0).u.p.polyType != POLYLINE) || - ((tempSegs(0).u.p.polyType == POLYLINE) && (prev_inx>=1) && (prev_inx<=points_da.cnt-2)) ) && - ((action>>8 == 's') || (action>>8 == 'v') || (action>>8 == 'r'))) { - switch(action>>8) { - case 's': - points(context->prev_inx).pt_type = wPolyLineSmooth; - return C_CONTINUE; - case 'v': - points(context->prev_inx).pt_type = wPolyLineStraight; + } + if ((action>>8 == 'g') && (tempSegs(0).type == SEG_POLY) + && (tempSegs(0).u.p.polyType == POLYLINE) ) { + tempSegs(0).u.p.polyType = FREEFORM; + context->subtype=FREEFORM; + context->open = FALSE; + CreatePolyAnchors( -1); + return C_CONTINUE; + } + if ((action>>8 == 'l') && (tempSegs(0).type == SEG_POLY) + && (tempSegs(0).u.p.polyType != POLYLINE)) { + tempSegs(0).u.p.polyType = POLYLINE; + context->subtype=POLYLINE; + context->open = TRUE; + CreatePolyAnchors( -1); + return C_CONTINUE; + } + if ((action>>8 == 'f') && (tempSegs(0).type == SEG_POLY) + && (tempSegs(0).u.p.polyType != POLYLINE )) { + tempSegs(0).type = SEG_FILPOLY; + context->type = SEG_FILPOLY; + context->subtype=tempSegs(0).u.p.polyType; + context->filled = TRUE; + CreatePolyAnchors( -1); + return C_CONTINUE; + } + if ((action>>8 == 'u') && (tempSegs(0).type == SEG_FILPOLY) ) { + tempSegs(0).type = SEG_POLY; + context->type = SEG_POLY; + context->subtype=tempSegs(0).u.p.polyType; + context->filled = FALSE; + CreatePolyAnchors( -1); + return C_CONTINUE; + } + //Delete or backspace deletes last selected index + if (action>>8 == 127 || action>>8 == 8) { + if (polyState == POLY_SELECTED && prev_inx >=0) { + if (selected_count >1) { + ErrorMessage( MSG_POLY_MULTIPLE_SELECTED ); return C_CONTINUE; - case 'r': - points(context->prev_inx).pt_type = wPolyLineRound; + } + if (points_da.cnt <= 3) { + ErrorMessage( MSG_POLY_SHAPES_3_SIDES ); return C_CONTINUE; - default:; } - } - if ((action>>8 == 'g') && (tempSegs(0).type == SEG_POLY) && (tempSegs(0).u.p.polyType == POLYLINE) ) { - tempSegs(0).u.p.polyType = FREEFORM; - context->subtype=FREEFORM; - context->open = FALSE; - CreatePolyAnchors( -1); - return C_CONTINUE; - } - if ((action>>8 == 'l') && (tempSegs(0).type == SEG_POLY) && (tempSegs(0).u.p.polyType == FREEFORM)) { - tempSegs(0).u.p.polyType = POLYLINE; - context->subtype=POLYLINE; - context->open = TRUE; - CreatePolyAnchors( -1); - return C_CONTINUE; - } - if ((action>>8 == 'f') && (tempSegs(0).type == SEG_POLY) && (tempSegs(0).u.p.polyType != POLYLINE )) { - tempSegs(0).type = SEG_FILPOLY; - tempSegs(0).u.p.polyType = FREEFORM; - context->type = SEG_FILPOLY; - context->subtype=FREEFORM; - context->filled = TRUE; - CreatePolyAnchors( -1); - return C_CONTINUE; - } - if ((action>>8 == 'u') && (tempSegs(0).type == SEG_FILPOLY) ) { - tempSegs(0).type = SEG_POLY; - tempSegs(0).u.p.polyType = FREEFORM; - context->type = SEG_POLY; - context->subtype=FREEFORM; - context->filled = FALSE; - CreatePolyAnchors( -1); - return C_CONTINUE; - } - //Delete or backspace deletes last selected index - if (action>>8 == 127 || action>>8 == 8) { - if (polyState == POLY_SELECTED && prev_inx >=0) { - if (selected_count >1) { - ErrorMessage( MSG_POLY_MULTIPLE_SELECTED ); - return C_CONTINUE; - } - if (points_da.cnt <= 3) { - ErrorMessage( MSG_POLY_SHAPES_3_SIDES ); - return C_CONTINUE; - } - for (int i=0;i<points_da.cnt;i++) { - point_selected(i) = FALSE; - if (i>=prev_inx && i<points_da.cnt-1) - points(i) = points(i+1); + for (int i=0; i<points_da.cnt; i++) { + point_selected(i) = FALSE; + if (i>=prev_inx && i<points_da.cnt-1) { + points(i) = points(i+1); } - points_da.cnt--; - select_da.cnt--; - selected_count=0; - tempSegs(0).u.p.cnt = points_da.cnt; - context->max_inx = points_da.cnt-1; - } else { - ErrorMessage( MSG_POLY_NOTHING_SELECTED ); } - prev_inx = -1; - context->prev_inx = -1; - polyInx = -1; - polyState = POLY_SELECTED; - CreatePolyAnchors( -1); - InfoMessage(_("Point Deleted")); - return C_CONTINUE; - } - if (action>>8 != 32 && action>>8 != 13 && action>>8 !=9) return C_CONTINUE; - if (action>>8 == 9 && (MyGetKeyState() & WKEY_SHIFT) != 0) return C_TERMINATE; - /* no break */ - case C_CONFIRM: - case C_OK: - case C_FINISH: - //copy changes back into track - if (polyState != POLY_SELECTED) { - polyState = POLY_NONE; - DYNARR_RESET(trkSeg_t,anchors_da); - DYNARR_RESET(trkSeg_t,tempSegs_da); - return C_TERMINATE; - } - //If ends overlap precisely remove last segment and close if >3 points - DIST_T dist = FindDistance(points(0).pt,points(points_da.cnt-1).pt); - if (IsClose(dist*4) && points_da.cnt>3 && tempSegs(0).u.p.polyType == POLYLINE) { - tempSegs(0).u.p.polyType = FREEFORM; - context->subtype=FREEFORM; - context->open = FALSE; points_da.cnt--; select_da.cnt--; selected_count=0; tempSegs(0).u.p.cnt = points_da.cnt; context->max_inx = points_da.cnt-1; + } else { + ErrorMessage( MSG_POLY_NOTHING_SELECTED ); } - pts_t * oldPts = context->segPtr[segInx].u.p.pts; - void * newPts = (pts_t*)MyMalloc( points_da.cnt * sizeof (pts_t) ); - context->segPtr[segInx].u.p.pts = newPts; - context->segPtr[segInx].u.p.cnt = points_da.cnt; - context->orig = rotate_origin; - context->angle = rotate_angle; - for (int i=0; i<points_da.cnt; i++) { - pos = points(i).pt; - pos.x -= context->orig.x; - pos.y -= context->orig.y; - Rotate( &pos, zero, -context->angle ); - context->segPtr[segInx].u.p.pts[i].pt = pos; - context->segPtr[segInx].u.p.pts[i].pt_type = points(i).pt_type; - } - MyFree(oldPts); + prev_inx = -1; + context->prev_inx = -1; + polyInx = -1; + polyState = POLY_SELECTED; + CreatePolyAnchors( -1); + InfoMessage(_("Point Deleted")); + return C_CONTINUE; + } + if (action>>8 != 32 && action>>8 != 13 && action>>8 !=9) { return C_CONTINUE; } + if (action>>8 == 9 && (MyGetKeyState() & WKEY_SHIFT) != 0) { return C_TERMINATE; } + /* no break */ + case C_CONFIRM: + case C_OK: + case C_FINISH: + //copy changes back into track + if (polyState != POLY_SELECTED) { polyState = POLY_NONE; DYNARR_RESET(trkSeg_t,anchors_da); - DYNARR_RESET(trkSeg_t,points_da); DYNARR_RESET(trkSeg_t,tempSegs_da); - if ((action&0xFF)==C_CONFIRM) return C_CONTINUE; - else return C_TERMINATE; - case C_REDRAW: - if (polyState == POLY_NONE) return C_CONTINUE; - DrawSegs( &tempD, zero, 0.0, &tempSegs(0), tempSegs_da.cnt,trackGauge, wDrawColorBlack); - DrawSegs( &tempD, zero, 0.0, &anchors(0), anchors_da.cnt, trackGauge, wDrawColorBlack ); - break; - default: - ; + return C_TERMINATE; } - return C_CONTINUE; + //If ends overlap precisely remove last segment and close if >3 points + DIST_T dist = FindDistance(points(0).pt,points(points_da.cnt-1).pt); + if (IsClose(dist*4) && points_da.cnt>3 + && tempSegs(0).u.p.polyType == POLYLINE) { + tempSegs(0).u.p.polyType = FREEFORM; + context->subtype=FREEFORM; + context->open = FALSE; + points_da.cnt--; + select_da.cnt--; + selected_count=0; + tempSegs(0).u.p.cnt = points_da.cnt; + context->max_inx = points_da.cnt-1; + } + pts_t * oldPts = context->segPtr[segInx].u.p.pts; + void * newPts = (pts_t*)MyMalloc( points_da.cnt * sizeof (pts_t) ); + context->segPtr[segInx].u.p.pts = newPts; + context->segPtr[segInx].u.p.cnt = points_da.cnt; + context->orig = rotate_origin; + context->angle = rotate_angle; + for (int i=0; i<points_da.cnt; i++) { + pos = points(i).pt; + pos.x -= context->orig.x; + pos.y -= context->orig.y; + Rotate( &pos, zero, -context->angle ); + context->segPtr[segInx].u.p.pts[i].pt = pos; + context->segPtr[segInx].u.p.pts[i].pt_type = points(i).pt_type; + } + MyFree(oldPts); + polyState = POLY_NONE; + DYNARR_RESET(trkSeg_t,anchors_da); + DYNARR_RESET(trkSeg_t,points_da); + DYNARR_RESET(trkSeg_t,tempSegs_da); + if ((action&0xFF)==C_CONFIRM) { + return C_CONTINUE; + } else { + return C_TERMINATE; + } + case C_REDRAW: + if (polyState == POLY_NONE) { return C_CONTINUE; } + DrawSegsDA( &tempD, NULL, zero, 0.0, &tempSegs_da, trackGauge, wDrawColorBlack, + 0 ); + DrawSegsDA( &tempD, NULL, zero, 0.0, &anchors_da, trackGauge, wDrawColorBlack, + 0 ); + break; + default: + ; + } + return C_CONTINUE; } -void BuildCircleContext(drawModContext_t * context,int segInx) { +void BuildCircleContext(drawModContext_t * context,int segInx) +{ context->radius = fabs(context->segPtr[segInx].u.c.radius); - REORIGIN( context->pc, context->segPtr[segInx].u.c.center, context->angle, context->orig ); - PointOnCircle( &context->p0, context->segPtr[segInx].u.c.center, fabs(context->segPtr[segInx].u.c.radius), context->segPtr[segInx].u.c.a0 ); + REORIGIN( context->pc, context->segPtr[segInx].u.c.center, context->angle, + context->orig ); + PointOnCircle( &context->p0, context->segPtr[segInx].u.c.center, + fabs(context->segPtr[segInx].u.c.radius), context->segPtr[segInx].u.c.a0 ); REORIGIN( context->p0, context->p0, context->angle, context->orig ); - PointOnCircle( &context->p1, context->segPtr[segInx].u.c.center, fabs(context->segPtr[segInx].u.c.radius), context->segPtr[segInx].u.c.a0 + context->segPtr[segInx].u.c.a1); + PointOnCircle( &context->p1, context->segPtr[segInx].u.c.center, + fabs(context->segPtr[segInx].u.c.radius), + context->segPtr[segInx].u.c.a0 + context->segPtr[segInx].u.c.a1); REORIGIN( context->p1, context->p1, context->angle, context->orig ); if (context->segPtr[segInx].u.c.a1<360) { context->arc_angle = context->segPtr[segInx].u.c.a1; - PointOnCircle( &context->pm, context->segPtr[segInx].u.c.center, fabs(context->segPtr[segInx].u.c.radius), context->segPtr[segInx].u.c.a0 + (context->segPtr[segInx].u.c.a1/2)); + PointOnCircle( &context->pm, context->segPtr[segInx].u.c.center, + fabs(context->segPtr[segInx].u.c.radius), + context->segPtr[segInx].u.c.a0 + (context->segPtr[segInx].u.c.a1/2)); REORIGIN( context->pm, context->pm, context->angle, context->orig ); coOrd cm; cm = context->pm; @@ -1703,7 +1829,8 @@ void BuildCircleContext(drawModContext_t * context,int segInx) { } } -void CreateSelectedAnchor(coOrd pos) { +void CreateSelectedAnchor(coOrd pos) +{ double d = tempD.scale*0.15; DYNARR_APPEND(trkSeg_t,anchors_da,1); int inx = anchors_da.cnt-1; @@ -1728,125 +1855,135 @@ void CreateSelectedAnchor(coOrd pos) { **/ STATUS_T DrawGeomOriginMove( - wAction_t action, - coOrd pos, - drawModContext_t * context) { + wAction_t action, + coOrd pos, + drawModContext_t * context) +{ switch ( action&0xFF ) { - case C_START: + case C_START: + context->state = MOD_ORIGIN; + context->rotate_state = TRUE; + context->rot_moved = TRUE; + DYNARR_RESET(trkSeg_t,anchors_da); + CreateOriginAnchor(context->rot_center,FALSE); + if ((tempSegs(0).type == SEG_POLY || tempSegs(0).type == SEG_FILPOLY) + && (context->prev_inx>=0)) { + CreateSelectedAnchor(points(context->prev_inx).pt); + } + InfoMessage("Move Origin Mode: Place Origin, 0-4, c or l, Enter or Esc"); + return C_CONTINUE; + break; + case wActionMove: + CreateOriginAnchor(context->rot_center, FALSE); + if ((tempSegs(0).type == SEG_POLY || tempSegs(0).type == SEG_FILPOLY) + && (context->prev_inx>=0)) { + CreateSelectedAnchor(points(context->prev_inx).pt); + } + return C_CONTINUE; + break; + case C_DOWN: + if (context->state == MOD_ORIGIN || context->state == MOD_AFTER_ORIG) { context->state = MOD_ORIGIN; - context->rotate_state = TRUE; - context->rot_moved = TRUE; DYNARR_RESET(trkSeg_t,anchors_da); - CreateOriginAnchor(context->rot_center,FALSE); - if ((tempSegs(0).type == SEG_POLY || tempSegs(0).type == SEG_FILPOLY) && (context->prev_inx>=0)) { - CreateSelectedAnchor(points(context->prev_inx).pt); - } - InfoMessage("Move Origin Mode: Place Origin, 0-4, c or l, Enter or Esc"); - return C_CONTINUE; - break; - case wActionMove: - CreateOriginAnchor(context->rot_center, FALSE); - if ((tempSegs(0).type == SEG_POLY || tempSegs(0).type == SEG_FILPOLY) && (context->prev_inx>=0)) { - CreateSelectedAnchor(points(context->prev_inx).pt); - } - return C_CONTINUE; - break; - case C_DOWN: - if (context->state == MOD_ORIGIN || context->state == MOD_AFTER_ORIG) { - context->state = MOD_ORIGIN; - DYNARR_RESET(trkSeg_t,anchors_da); - if (IsClose(FindDistance(pos,context->rot_center))) { - pos = context->rot_center; - } else { - context->rot_center = pos; - } - CreateOriginAnchor(context->rot_center, TRUE); - if ((tempSegs(0).type == SEG_POLY || tempSegs(0).type == SEG_FILPOLY) && (context->prev_inx>=0)) { - CreateSelectedAnchor(points(context->prev_inx).pt); - } - } - return C_CONTINUE; - break; - case C_MOVE: - if (context->state == MOD_ORIGIN || context->state == MOD_AFTER_ORIG){ + if (IsClose(FindDistance(pos,context->rot_center))) { + pos = context->rot_center; + } else { context->rot_center = pos; - DYNARR_RESET(trkSeg_t,anchors_da); - CreateOriginAnchor(context->rot_center, TRUE); - if ((tempSegs(0).type == SEG_POLY || tempSegs(0).type == SEG_FILPOLY) && (context->prev_inx>=0)) { - CreateSelectedAnchor(points(context->prev_inx).pt); - } - } - return C_CONTINUE; - break; - case C_UP: - DYNARR_RESET(trkSeg_t,anchors_da); - if (context->state == MOD_ORIGIN) { - context->state = MOD_AFTER_ORIG; } - CreateOriginAnchor(context->rot_center,FALSE); - if ((tempSegs(0).type == SEG_POLY || tempSegs(0).type == SEG_FILPOLY) && (context->prev_inx>=0)) { + CreateOriginAnchor(context->rot_center, TRUE); + if ((tempSegs(0).type == SEG_POLY || tempSegs(0).type == SEG_FILPOLY) + && (context->prev_inx>=0)) { CreateSelectedAnchor(points(context->prev_inx).pt); } - return C_CONTINUE; - break; - case C_UPDATE: + } + return C_CONTINUE; + break; + case C_MOVE: + if (context->state == MOD_ORIGIN || context->state == MOD_AFTER_ORIG) { + context->rot_center = pos; DYNARR_RESET(trkSeg_t,anchors_da); - if (context->state == MOD_AFTER_ORIG) { - if (context->rot_center.x != context->rel_center.x && - context->rot_center.y != context->rel_center.y ) { - context->rel_center = context->rot_center; - CreateOriginAnchor(context->rot_center, FALSE); - if ((tempSegs(0).type == SEG_POLY || tempSegs(0).type == SEG_FILPOLY) && (context->prev_inx>=0)) { - CreateSelectedAnchor(points(context->prev_inx).pt); - } - } + CreateOriginAnchor(context->rot_center, TRUE); + if ((tempSegs(0).type == SEG_POLY || tempSegs(0).type == SEG_FILPOLY) + && (context->prev_inx>=0)) { + CreateSelectedAnchor(points(context->prev_inx).pt); } - return C_CONTINUE; - break; - case C_TEXT: - if ((context->state == MOD_ORIGIN || context->state == MOD_AFTER_ORIG) && - ((action>>8 >= '0' && action>>8 <= '1') || action>>8 == 'l' || action>>8 == 'm' || action>>8 == 'p')) { - // 0,1,2,3,4 -> reset rot center - if (action>>8 == '0') { - context->rot_center = zero; - } else if (action>>8 == '1') { - context->rot_center = context->p0; - } else if (action>>8 == '2') { - context->rot_center = context->p1; - } else if (tempSegs(0).type == SEG_POLY || tempSegs(0).type == SEG_FILPOLY) { - if (action>>8 == '3' || action>>8 == '4') { - context->rot_center = action>>8 == '3'?points(2).pt:points(3).pt; - } else if (action>>8 == 'l') { //"l" - last selected - if (context->prev_inx !=-1) { - context->rot_center = points(context->prev_inx).pt; - } - } else if (action>>8 == 'm') { - context->rot_center = FindCentroid(points_da.cnt,&points(0)); - } - } - if (action>>8 == 'p') { //"p" - points mode - MenuMode(I2VP(0)); - return C_CONTINUE; - } + } + return C_CONTINUE; + break; + case C_UP: + DYNARR_RESET(trkSeg_t,anchors_da); + if (context->state == MOD_ORIGIN) { + context->state = MOD_AFTER_ORIG; + } + CreateOriginAnchor(context->rot_center,FALSE); + if ((tempSegs(0).type == SEG_POLY || tempSegs(0).type == SEG_FILPOLY) + && (context->prev_inx>=0)) { + CreateSelectedAnchor(points(context->prev_inx).pt); + } + return C_CONTINUE; + break; + case C_UPDATE: + DYNARR_RESET(trkSeg_t,anchors_da); + if (context->state == MOD_AFTER_ORIG) { + if (context->rot_center.x != context->rel_center.x && + context->rot_center.y != context->rel_center.y ) { context->rel_center = context->rot_center; - context->rot_angle = 0; - DYNARR_RESET(trkSeg_t,anchors_da); - context->state = MOD_AFTER_ORIG; CreateOriginAnchor(context->rot_center, FALSE); - if ((tempSegs(0).type == SEG_POLY || tempSegs(0).type == SEG_FILPOLY) && (context->prev_inx>=0)) { + if ((tempSegs(0).type == SEG_POLY || tempSegs(0).type == SEG_FILPOLY) + && (context->prev_inx>=0)) { CreateSelectedAnchor(points(context->prev_inx).pt); } + } + } + return C_CONTINUE; + break; + case C_TEXT: + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); + if ((context->state == MOD_ORIGIN || context->state == MOD_AFTER_ORIG) && + ((action>>8 >= '0' && action>>8 <= '1') || action>>8 == 'l' || action>>8 == 'm' + || action>>8 == 'p')) { + // 0,1,2,3,4 -> reset rot center + if (action>>8 == '0') { + context->rot_center = zero; + } else if (action>>8 == '1') { + context->rot_center = context->p0; + } else if (action>>8 == '2') { + context->rot_center = context->p1; + } else if (tempSegs(0).type == SEG_POLY || tempSegs(0).type == SEG_FILPOLY) { + if (action>>8 == '3' || action>>8 == '4') { + context->rot_center = action>>8 == '3'?points(2).pt:points(3).pt; + } else if (action>>8 == 'l') { //"l" - last selected + if (context->prev_inx !=-1) { + context->rot_center = points(context->prev_inx).pt; + } + } else if (action>>8 == 'm') { + context->rot_center = FindCentroid(points_da.cnt,&points(0)); + } + } + if (action>>8 == 'p') { //"p" - points mode + MenuMode(I2VP(0)); return C_CONTINUE; } - break; - case C_FINISH: - context->rotate_state = FALSE; - context->state = MOD_STARTED; + context->rel_center = context->rot_center; + context->rot_angle = 0; + DYNARR_RESET(trkSeg_t,anchors_da); + context->state = MOD_AFTER_ORIG; + CreateOriginAnchor(context->rot_center, FALSE); + if ((tempSegs(0).type == SEG_POLY || tempSegs(0).type == SEG_FILPOLY) + && (context->prev_inx>=0)) { + CreateSelectedAnchor(points(context->prev_inx).pt); + } return C_CONTINUE; - break; - default: - break; + } + break; + case C_FINISH: + context->rotate_state = FALSE; + context->state = MOD_STARTED; + return C_CONTINUE; + break; + default: + break; } return C_CONTINUE; @@ -1857,26 +1994,28 @@ STATUS_T DrawGeomOriginMove( * Base Modify function for Draw objects. */ STATUS_T DrawGeomModify( - wAction_t action, - coOrd pos, - drawModContext_t * context) + wAction_t action, + coOrd pos, + drawModContext_t * context) { ANGLE_T a; coOrd p0, p1, pc, pm; static coOrd start_pos; static wIndex_t segInx; - static EPINX_T segEp; +// static EPINX_T segEp; static ANGLE_T segA1; - static int inx_other, inx_line, inx_origin; + static int inx_line, inx_origin; +// static int inx_other; static BOOL_T corner_mode; static BOOL_T polyMode; - static ANGLE_T original_angle; - int inx, inx1, inx2; +// static ANGLE_T original_angle; + int inx, inx2; +// int inx1; DIST_T d, d1, d2, dd; - coOrd * newPts = NULL; - tempSegs_da.cnt = 1; +// coOrd * newPts = NULL; switch ( action&0xFF ) { case C_START: + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); if (!context->rotate_state && !context->rot_moved) { context->rot_center.x = context->orig.x; context->rot_center.y = context->orig.y; @@ -1888,81 +2027,86 @@ STATUS_T DrawGeomModify( curveInx = -1; segInx = -1; polyMode = FALSE; - DistanceSegs( context->orig, context->angle, context->segCnt, context->segPtr, &pos, &segInx ); - if (segInx == -1) + DistanceSegs( context->orig, context->angle, context->segCnt, context->segPtr, + &pos, &segInx ); + if (segInx == -1) { return C_ERROR; + } context->type = context->segPtr[segInx].type; switch(context->type) { - case SEG_TBLEDGE: - case SEG_STRLIN: - case SEG_DIMLIN: - case SEG_BENCH: - REORIGIN( p0, context->segPtr[segInx].u.l.pos[0], context->angle, context->orig ); - REORIGIN( p1, context->segPtr[segInx].u.l.pos[1], context->angle, context->orig ); - tempSegs(0).type = SEG_STRLIN; - tempSegs(0).color = wDrawColorRed; - tempSegs(0).u.l.pos[0] = p0; - tempSegs(0).u.l.pos[1] = p1; - tempSegs(0).width = 0; - tempSegs_da.cnt = 1; - tempSegs(0).u.l.option = context->segPtr[segInx].u.l.option; - context->p0 = p0; - context->p1 = p1; - CreateLineAnchors(-1,p0,p1); - break; - case SEG_CRVLIN: - case SEG_FILCRCL: - BuildCircleContext(context,segInx); - tempSegs(0).type = SEG_CRVLIN; + case SEG_TBLEDGE: + case SEG_STRLIN: + case SEG_DIMLIN: + case SEG_BENCH: + REORIGIN( p0, context->segPtr[segInx].u.l.pos[0], context->angle, + context->orig ); + REORIGIN( p1, context->segPtr[segInx].u.l.pos[1], context->angle, + context->orig ); + tempSegs(0).type = SEG_STRLIN; + tempSegs(0).color = wDrawColorRed; + tempSegs(0).u.l.pos[0] = p0; + tempSegs(0).u.l.pos[1] = p1; + tempSegs(0).lineWidth = 0; + tempSegs(0).u.l.option = context->segPtr[segInx].u.l.option; + context->p0 = p0; + context->p1 = p1; + CreateLineAnchors(-1,p0,p1); + break; + case SEG_CRVLIN: + case SEG_FILCRCL: + BuildCircleContext(context,segInx); + tempSegs(0).type = SEG_CRVLIN; + tempSegs(0).color = wDrawColorRed; + tempSegs(0).u.c.center = context->pc; + tempSegs(0).u.c.radius = context->radius; + tempSegs(0).u.c.a0 = context->segPtr[segInx].u.c.a0; + tempSegs(0).u.c.a1 = context->segPtr[segInx].u.c.a1; + tempSegs(0).lineWidth = 0; + if (tempSegs(0).u.c.a1<360.0) { + CreateCurveAnchors(-1,context->pm,context->pc,context->p0,context->p1); + } else { + CreateCircleAnchor(FALSE,tempSegs(0).u.c.center,tempSegs(0).u.c.radius, + FindAngle(tempSegs(0).u.c.center,pos)); + } + context->last_inx = 2; + break; + case SEG_POLY: + case SEG_FILPOLY: + if (context->segPtr[segInx].u.p.polyType !=RECTANGLE) { + polyMode = TRUE; + return DrawGeomPolyModify(action,pos,context); + } else { + tempSegs(0).type = SEG_POLY; tempSegs(0).color = wDrawColorRed; - tempSegs(0).u.c.center = context->pc; - tempSegs(0).u.c.radius = context->radius; - tempSegs(0).u.c.a0 = context->segPtr[segInx].u.c.a0; - tempSegs(0).u.c.a1 = context->segPtr[segInx].u.c.a1; - tempSegs(0).width = 0; - tempSegs_da.cnt = 1; - if (tempSegs(0).u.c.a1<360.0) { - CreateCurveAnchors(-1,context->pm,context->pc,context->p0,context->p1); - } else - CreateCircleAnchor(FALSE,tempSegs(0).u.c.center,tempSegs(0).u.c.radius,FindAngle(tempSegs(0).u.c.center,pos)); - context->last_inx = 2; - break; - case SEG_POLY: - case SEG_FILPOLY: - if (context->segPtr[segInx].u.p.polyType !=RECTANGLE) { - polyMode = TRUE; - return DrawGeomPolyModify(action,pos,context); - } else { - tempSegs(0).type = SEG_POLY; - tempSegs(0).color = wDrawColorRed; - DYNARR_RESET( pts_t, points_da); - for (int inx=0;inx<context->segPtr->u.p.cnt;inx++) { - DYNARR_APPEND(pts_t, points_da,3); - REORIGIN( points(inx).pt, context->segPtr[segInx].u.p.pts[inx].pt, context->angle, context->orig ); - } - tempSegs(0).u.p.pts = &points(0); - tempSegs(0).u.p.cnt = points_da.cnt; - tempSegs(0).width = 0; - tempSegs_da.cnt = 1; - context->p0 = points(0).pt; - CreateBoxAnchors(-1,&context->segPtr[segInx].u.p.pts[0]); - context->p0 = points(0).pt; - context->p1 = points(1).pt; + DYNARR_RESET( pts_t, points_da); + for (int inx=0; inx<context->segPtr->u.p.cnt; inx++) { + DYNARR_APPEND(pts_t, points_da,3); + REORIGIN( points(inx).pt, context->segPtr[segInx].u.p.pts[inx].pt, + context->angle, context->orig ); } - break; - case SEG_TEXT: - InfoMessage("Text can only be modified with Describe"); - wBeep(); - return C_ERROR; - default: - ; + tempSegs(0).u.p.pts = &points(0); + tempSegs(0).u.p.cnt = points_da.cnt; + tempSegs(0).lineWidth = 0; + context->p0 = points(0).pt; + CreateBoxAnchors(-1,&context->segPtr[segInx].u.p.pts[0]); + context->p0 = points(0).pt; + context->p1 = points(1).pt; + + } + break; + case SEG_TEXT: + InfoMessage("Text can only be modified with Describe"); + wBeep(); + return C_ERROR; + default: + ; } InfoMessage("Points Mode - Select and drag Anchor Point"); return C_CONTINUE; break; case wActionMove: - if (context->rotate_state) return DrawGeomOriginMove(action,pos,context); - if (polyMode) return DrawGeomPolyModify(action,pos,context); + if (context->rotate_state) { return DrawGeomOriginMove(action,pos,context); } + if (polyMode) { return DrawGeomPolyModify(action,pos,context); } DYNARR_RESET(trkSeg_t,anchors_da); wSetCursor(mainD.d,defaultCursor); switch( context->type) { @@ -1981,7 +2125,7 @@ STATUS_T DrawGeomModify( CreateMovingAnchor(context->p1,TRUE); } } - break; + break; case SEG_CRVLIN: case SEG_FILCRCL: DYNARR_RESET(trkSeg_t,anchors_da); @@ -1991,7 +2135,8 @@ STATUS_T DrawGeomModify( Translate(&p,context->pc,FindAngle(context->pc,pos),context->radius); CreateMovingAnchor(p,TRUE); DYNARR_SET(trkSeg_t,anchors_da,anchors_da.cnt+5); - DrawArrowHeads(&DYNARR_N(trkSeg_t,anchors_da,anchors_da.cnt-5),p,FindAngle(context->pc,pos),TRUE,wDrawColorBlue); + DrawArrowHeads(&DYNARR_N(trkSeg_t,anchors_da,anchors_da.cnt-5),p, + FindAngle(context->pc,pos),TRUE,wDrawColorBlue); } } else { CreateCurveAnchors(curveInx,context->pm,context->pc,context->p0,context->p1); @@ -2010,7 +2155,7 @@ STATUS_T DrawGeomModify( } } } - break; + break; case SEG_POLY: case SEG_FILPOLY:; CreateBoxAnchors(-1,&points(0)); @@ -2020,12 +2165,13 @@ STATUS_T DrawGeomModify( return C_CONTINUE; break; case C_DOWN: - if (context->rotate_state) return DrawGeomOriginMove(action,pos,context); - if (polyMode) return DrawGeomPolyModify(action,pos,context); + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); + if (context->rotate_state) { return DrawGeomOriginMove(action,pos,context); } + if (polyMode) { return DrawGeomPolyModify(action,pos,context); } corner_mode = FALSE; segInx = 0; context->state = MOD_STARTED; - tempSegs(0).width = context->segPtr[segInx].width; + tempSegs(0).lineWidth = context->segPtr[segInx].lineWidth; tempSegs(0).color = context->segPtr[segInx].color; switch ( context->type ) { case SEG_TBLEDGE: @@ -2047,27 +2193,27 @@ STATUS_T DrawGeomModify( if (lineInx < 0 ) { InfoMessage( _("Not close to end of line")); } else { - if (context->type == SEG_TBLEDGE) + if (context->type == SEG_TBLEDGE) { InfoMessage("End selected, drag to move +Ctl to lock to other edge end, +Shift lock to line"); - else + } else { InfoMessage("End selected, drag to reposition +Shift lock to line"); + } context->state = MOD_SELECTED_PT; } tempSegs(0).color = wDrawColorBlack; - tempSegs(0).width = 0; + tempSegs(0).lineWidth = 0; tempSegs(0).type = context->type; tempSegs(0).u.l.pos[0] = p0; tempSegs(0).u.l.pos[1] = p1; tempSegs(0).u.l.option = context->segPtr[segInx].u.l.option; segA1 = FindAngle( p1, p0 ); - tempSegs_da.cnt = 1; CreateLineAnchors(lineInx,p0,p1); break; case SEG_CRVLIN: case SEG_FILCRCL: curveInx = -1; tempSegs(0).color = wDrawColorBlack; - tempSegs(0).width = 0; + tempSegs(0).lineWidth = 0; tempSegs(0).type = context->type; tempSegs(0).u.c.center = context->pc; tempSegs(0).u.c.radius = context->radius; @@ -2075,14 +2221,16 @@ STATUS_T DrawGeomModify( tempSegs(0).u.c.a0 = 0.0; tempSegs(0).u.c.a1 = 360.0; InfoMessage("Drag to Change Radius"); - CreateCircleAnchor(TRUE,tempSegs(0).u.c.center,tempSegs(0).u.c.radius,FindAngle(tempSegs(0).u.c.center,pos)); + CreateCircleAnchor(TRUE,tempSegs(0).u.c.center,tempSegs(0).u.c.radius, + FindAngle(tempSegs(0).u.c.center,pos)); } else { p0 = context->p0; p1 = context->p1; pm = context->pm; pc = context->pc; tempSegs(0).u.c.a0 = FindAngle(context->pc,context->p0); - tempSegs(0).u.c.a1 = DifferenceBetweenAngles(FindAngle(context->pc,context->p0),FindAngle(context->pc,context->p1)); + tempSegs(0).u.c.a1 = DifferenceBetweenAngles(FindAngle(context->pc,context->p0), + FindAngle(context->pc,context->p1)); tempSegs(0).u.c.center = context->pc; tempSegs(0).u.c.radius = context->radius; curveInx = -1; @@ -2104,14 +2252,15 @@ STATUS_T DrawGeomModify( InfoMessage( _("Not close to ends or middle of mine, reselect")); return C_CONTINUE; } else { - if (curveInx <2 ) + if (curveInx <2 ) { InfoMessage("Drag to move end, +Ctrl to lock to other objects"); - else + } else { InfoMessage("Drag to change radius"); + } } - tempSegs_da.cnt = 1; - if (tempSegs(0).u.c.a1 < 360.0) + if (tempSegs(0).u.c.a1 < 360.0) { CreateCurveAnchors(curveInx,pm,pc,p0,p1); + } } context->state = MOD_SELECTED_PT; break; @@ -2142,21 +2291,23 @@ STATUS_T DrawGeomModify( polyInx = inx_line; } } - inx1 = (polyInx==0?3:polyInx-1); //Prev point +// inx1 = (polyInx==0?3:polyInx-1); //Prev point inx2 = (polyInx==3?0:polyInx+1); //Next Point inx_origin = (inx2==3?0:inx2+1); //Opposite point if ( corner_mode ) { start_pos = pos; pos = points(inx).pt; DYNARR_SET(trkSeg_t,anchors_da,5); - DrawArrowHeads( &anchors(0), pos, FindAngle(points(polyInx).pt,points(inx_origin).pt), TRUE, wDrawColorRed ); + DrawArrowHeads( &anchors(0), pos, FindAngle(points(polyInx).pt, + points(inx_origin).pt), TRUE, wDrawColorRed ); InfoMessage( _("Drag to Move Corner Point")); } else { start_pos = pos; pos.x = (points(inx_line).pt.x + points(inx_line==0?3:inx_line-1).pt.x)/2; pos.y = (points(inx_line).pt.y + points(inx_line==0?3:inx_line-1).pt.y)/2; DYNARR_SET(trkSeg_t,anchors_da,5); - DrawArrowHeads( &anchors(0), pos, FindAngle(points(polyInx).pt,pos)+90, TRUE, wDrawColorRed ); + DrawArrowHeads( &anchors(0), pos, FindAngle(points(polyInx).pt,pos)+90, TRUE, + wDrawColorRed ); InfoMessage( _("Drag to Move Edge ")); } context->state = MOD_SELECTED_PT; @@ -2165,13 +2316,10 @@ STATUS_T DrawGeomModify( segInx = -1; return C_ERROR; default: - ASSERT( FALSE ); /* CHECKME */ + CHECK( FALSE ); /* CHECKME */ } - if ( FindDistance( p0, pos ) < FindDistance( p1, pos ) ) - segEp = 0; - else { - segEp = 1; + if ( FindDistance( p0, pos ) >= FindDistance( p1, pos ) ) { switch ( context->type ) { case SEG_TBLEDGE: case SEG_STRLIN: @@ -2187,18 +2335,19 @@ STATUS_T DrawGeomModify( return C_CONTINUE; case C_MOVE: - if (context->rotate_state) return DrawGeomOriginMove(action,pos,context); - if (polyMode) return DrawGeomPolyModify(action,pos,context); - if (context->state != MOD_SELECTED_PT) return C_CONTINUE; + if (context->rotate_state) { return DrawGeomOriginMove(action,pos,context); } + if (polyMode) { return DrawGeomPolyModify(action,pos,context); } + if (context->state != MOD_SELECTED_PT) { return C_CONTINUE; } BOOL_T locked = FALSE; switch (tempSegs(0).type) { case SEG_TBLEDGE: - if ( (MyGetKeyState() & WKEY_CTRL) == WKEY_CTRL ) { //Special Snap to Table End Point if Ctrl - if (OnTableEdgeEndPt( NULL, &pos )) { + if ( (MyGetKeyState() & WKEY_CTRL) == + WKEY_CTRL ) { //Special Snap to Table End Point if Ctrl + if (OnTableEdgeEndPt( NULL, &pos )) { locked = TRUE; - } + } } - /* No Break*/ + /* No Break*/ case SEG_STRLIN: case SEG_DIMLIN: case SEG_BENCH: @@ -2207,7 +2356,8 @@ STATUS_T DrawGeomModify( d = FindDistance( pos, tempSegs(0).u.l.pos[1-lineInx] ); Translate( &pos, tempSegs(0).u.l.pos[1-lineInx], segA1, d ); locked = TRUE; - } else if (((MyGetKeyState() & WKEY_ALT) == 0) == magneticSnap ) { //M.S. Either on or Off + } else if (((MyGetKeyState() & WKEY_ALT) == 0) == + magneticSnap ) { //M.S. Either on or Off if (OnTrack( &pos, FALSE, FALSE )!=NULL) { CreateEndAnchor(pos,TRUE); locked = TRUE; @@ -2215,7 +2365,7 @@ STATUS_T DrawGeomModify( } }; if (!locked) { - if (SnapPos(&pos)) locked = TRUE; + if (SnapPos(&pos)) { locked = TRUE; } } break; default: @@ -2223,16 +2373,16 @@ STATUS_T DrawGeomModify( } int prior_pnt, next_pnt, orig_pnt; ANGLE_T prior_angle, next_angle, line_angle; - tempSegs_da.cnt = 1; switch (tempSegs(0).type) { case SEG_TBLEDGE: case SEG_STRLIN: case SEG_DIMLIN: case SEG_BENCH: - if (lineInx<0 || lineInx>1) return C_CONTINUE; + if (lineInx<0 || lineInx>1) { return C_CONTINUE; } tempSegs(0).u.l.pos[lineInx] = pos; - InfoMessage( _("Length = %0.3f Angle = %0.3f"), FindDistance( tempSegs(0).u.l.pos[lineInx], tempSegs(0).u.l.pos[1-lineInx] ), FindAngle( tempSegs(0).u.l.pos[1-lineInx], tempSegs(0).u.l.pos[lineInx] ) ); - tempSegs_da.cnt = 1; + InfoMessage( _("Length = %0.3f Angle = %0.3f"), + FindDistance( tempSegs(0).u.l.pos[lineInx], tempSegs(0).u.l.pos[1-lineInx] ), + FindAngle( tempSegs(0).u.l.pos[1-lineInx], tempSegs(0).u.l.pos[lineInx] ) ); context->p0 = tempSegs(0).u.l.pos[0]; context->p1 = tempSegs(0).u.l.pos[1]; p0 = context->p0; @@ -2243,10 +2393,11 @@ STATUS_T DrawGeomModify( case SEG_FILCRCL: if (tempSegs(0).u.c.a1 >= 360.0) { tempSegs(0).u.c.radius = FindDistance( context->pc, pos ); - CreateCircleAnchor(TRUE,tempSegs(0).u.c.center,tempSegs(0).u.c.radius,FindAngle(tempSegs(0).u.c.center,pos)); + CreateCircleAnchor(TRUE,tempSegs(0).u.c.center,tempSegs(0).u.c.radius, + FindAngle(tempSegs(0).u.c.center,pos)); } else { - if (context->state != MOD_SELECTED_PT) return C_CONTINUE; - if (curveInx < 0 || curveInx > 2) return C_CONTINUE; + if (context->state != MOD_SELECTED_PT) { return C_CONTINUE; } + if (curveInx < 0 || curveInx > 2) { return C_CONTINUE; } wSetCursor(mainD.d,wCursorNone); p0 = context->p0; p1 = context->p1; @@ -2287,8 +2438,9 @@ STATUS_T DrawGeomModify( if ( fabs(d) >= 0.01 ) { d2 = sqrt( d0*d0 + d*d )/2.0; r = d2*d2*2.0/d; - if ( fabs(r) > 1000.0 ) + if ( fabs(r) > 1000.0 ) { r = ((r > 0)? 1 : -1) *1000.0; + } } else { r = ((r > 0) ? 1 : -1 ) *1000.0; } @@ -2302,10 +2454,12 @@ STATUS_T DrawGeomModify( context->radius = tempSegs(0).u.c.radius = fabs(r); Translate( &pc, posx, a0, fabs(r)-fabs(d) ); context->pc = tempSegs(0).u.c.center = pc; - tempSegs(0).u.c.a0 = FindAngle(pc,p0); - context->arc_angle = tempSegs(0).u.c.a1 = NormalizeAngle(FindAngle(pc,p1)-FindAngle(pc,p0)); - PointOnCircle(&pm,pc,context->radius,tempSegs(0).u.c.a0+(tempSegs(0).u.c.a1/2.0)); - context->pm = pm; + tempSegs(0).u.c.a0 = FindAngle(pc,p0); + context->arc_angle = tempSegs(0).u.c.a1 = NormalizeAngle(FindAngle(pc, + p1)-FindAngle(pc,p0)); + PointOnCircle(&pm,pc,context->radius, + tempSegs(0).u.c.a0+(tempSegs(0).u.c.a1/2.0)); + context->pm = pm; } else { //Change radius using chord p0 = context->p0; @@ -2320,8 +2474,9 @@ STATUS_T DrawGeomModify( if ( fabs(pos2.x) >= 0.01 ) { d2 = sqrt( d0*d0 + pos2.x*pos2.x )/2.0; r = d2*d2*2.0/pos2.x; - if ( fabs(r) > 1000.0 ) + if ( fabs(r) > 1000.0 ) { r = ((r > 0) ? 1 : -1 ) *1000.0; + } } else { r = ((r > 0) ? 1 : -1 ) *1000.0; } @@ -2349,8 +2504,9 @@ STATUS_T DrawGeomModify( context->disp = pos2.x; } } - if (tempSegs(0).u.c.a1 < 360.0) + if (tempSegs(0).u.c.a1 < 360.0) { CreateCurveAnchors(curveInx,pm,pc,p0,p1); + } } break; case SEG_POLY: @@ -2359,7 +2515,8 @@ STATUS_T DrawGeomModify( if (!corner_mode) { /* Constrain movement to be perpendicular */ d = FindDistance(start_pos, pos); - line_angle = NormalizeAngle(FindAngle(points(inx_line).pt,points(inx_line==3?0:inx_line+1).pt)); + line_angle = NormalizeAngle(FindAngle(points(inx_line).pt, + points(inx_line==3?0:inx_line+1).pt)); a = FindAngle(pos,start_pos); Translate( &pos, start_pos, line_angle, - d*cos(D2R(line_angle-a))); } @@ -2373,19 +2530,23 @@ STATUS_T DrawGeomModify( d = FindDistance(points(orig_pnt).pt,points(polyInx).pt); a = FindAngle(points(orig_pnt).pt,points(polyInx).pt); prior_angle = FindAngle(points(orig_pnt).pt,points(prior_pnt).pt); - Translate( &points(prior_pnt).pt, points(orig_pnt).pt, prior_angle, d*cos(D2R(prior_angle-a))); + Translate( &points(prior_pnt).pt, points(orig_pnt).pt, prior_angle, + d*cos(D2R(prior_angle-a))); next_angle = FindAngle(points(orig_pnt).pt,points(next_pnt).pt); - Translate( &points(next_pnt).pt, points(orig_pnt).pt, next_angle, d*cos(D2R(next_angle-a))); + Translate( &points(next_pnt).pt, points(orig_pnt).pt, next_angle, + d*cos(D2R(next_angle-a))); if (!corner_mode) { pos.x = (points(inx_line).pt.x + points(inx_line==0?3:inx_line-1).pt.x)/2; pos.y = (points(inx_line).pt.y + points(inx_line==0?3:inx_line-1).pt.y)/2; DYNARR_SET(trkSeg_t,anchors_da,5); - DrawArrowHeads( &anchors(0), pos, FindAngle(points(inx_line).pt,points(inx_line==0?3:inx_line-1).pt)+90, TRUE, wDrawColorRed ); + DrawArrowHeads( &anchors(0), pos, FindAngle(points(inx_line).pt, + points(inx_line==0?3:inx_line-1).pt)+90, TRUE, wDrawColorRed ); InfoMessage( _("Drag to Move Edge")); } else { pos = points(polyInx).pt; DYNARR_SET(trkSeg_t,anchors_da,5); - DrawArrowHeads( &anchors(0), pos, FindAngle(points(polyInx).pt,points(inx_origin).pt), TRUE, wDrawColorRed ); + DrawArrowHeads( &anchors(0), pos, FindAngle(points(polyInx).pt, + points(inx_origin).pt), TRUE, wDrawColorRed ); InfoMessage( _("Drag to Move Corner Point")); } context->p0 = points(0).pt; @@ -2396,17 +2557,19 @@ STATUS_T DrawGeomModify( } return C_CONTINUE; case C_UP: - if (context->rotate_state) return DrawGeomOriginMove(action, pos, context); + if (context->rotate_state) { return DrawGeomOriginMove(action, pos, context); } if (polyMode) { int rc; rc = DrawGeomPolyModify(action,pos,context); - if (context->prev_inx != -1) + if (context->prev_inx != -1) { context->state = MOD_AFTER_PT; + } return rc; } wSetCursor(mainD.d,defaultCursor); - if (segInx == -1) + if (segInx == -1) { return C_CONTINUE; + } switch (tempSegs(0).type) { case SEG_TBLEDGE: case SEG_STRLIN: @@ -2421,10 +2584,12 @@ STATUS_T DrawGeomModify( break; case SEG_CRVLIN: case SEG_FILCRCL: - if ( (tempSegs(0).type == SEG_FILCRCL) || (tempSegs(0).u.c.a1 == 360.0 || tempSegs(0).u.c.a1 == 0.0) ) { + if ( (tempSegs(0).type == SEG_FILCRCL) || (tempSegs(0).u.c.a1 == 360.0 + || tempSegs(0).u.c.a1 == 0.0) ) { context->radius = fabs(tempSegs(0).u.c.radius); context->arc_angle = 360.0; - CreateCircleAnchor(FALSE,tempSegs(0).u.c.center,tempSegs(0).u.c.radius,FindAngle(tempSegs(0).u.c.center,pos)); + CreateCircleAnchor(FALSE,tempSegs(0).u.c.center,tempSegs(0).u.c.radius, + FindAngle(tempSegs(0).u.c.center,pos)); } else { p0 = context->p0; p1 = context->p1; @@ -2442,10 +2607,12 @@ STATUS_T DrawGeomModify( case SEG_POLY: case SEG_FILPOLY: CreateBoxAnchors(-1,tempSegs(0).u.p.pts); - context->width = FindDistance(tempSegs(0).u.p.pts[0].pt,tempSegs(0).u.p.pts[1].pt); - context->height = FindDistance(tempSegs(0).u.p.pts[1].pt,tempSegs(0).u.p.pts[2].pt); + context->width = FindDistance(tempSegs(0).u.p.pts[0].pt, + tempSegs(0).u.p.pts[1].pt); + context->height = FindDistance(tempSegs(0).u.p.pts[1].pt, + tempSegs(0).u.p.pts[2].pt); context->last_inx = polyInx; - if (corner_mode) context->last_inx +=5; + if (corner_mode) { context->last_inx +=5; } break; default: ; @@ -2457,122 +2624,147 @@ STATUS_T DrawGeomModify( InfoMessage("Enter/Space to Accept, ESC to Reject"); return C_CONTINUE; case C_UPDATE: - if (context->rotate_state) return DrawGeomOriginMove(action, pos, context); + if (context->rotate_state) { return DrawGeomOriginMove(action, pos, context); } - if (polyMode) return DrawGeomPolyModify(action,pos,context); + if (polyMode) { return DrawGeomPolyModify(action,pos,context); } if (context->state == MOD_AFTER_PT) { switch (tempSegs(0).type) { - case SEG_TBLEDGE: - case SEG_STRLIN: - case SEG_DIMLIN: - case SEG_BENCH: - context->abs_angle = NormalizeAngle(context->abs_angle); - Translate(&tempSegs(0).u.l.pos[1],tempSegs(0).u.l.pos[0],context->abs_angle,context->length); - CreateLineAnchors(context->last_inx,tempSegs(0).u.l.pos[0],tempSegs(0).u.l.pos[1]); - context->p0 = tempSegs(0).u.l.pos[0]; - context->p1 = tempSegs(0).u.l.pos[1]; - break; - case SEG_CRVLIN: - case SEG_FILCRCL: - if (tempSegs(0).u.c.a1 == 360.0 || tempSegs(0).u.c.a1 == 0.0) { - tempSegs(0).u.c.a1 = 360.0; - tempSegs(0).u.c.radius = context->radius; - Translate(&p0,tempSegs(0).u.c.center,tempSegs(0).u.c.a0,tempSegs(0).u.c.radius); - context->p0 = p0; - context->p1 = p0; - context->pm = p0; - context->pc = tempSegs(0).u.c.center; - break; - } - if (context->radius < 0) { //swap ends - context->radius = fabs(context->radius); - p1 = context->p0; - p0 = context->p1; - a = FindAngle(context->pc,context->pm); - Translate(&pm,context->pm,a+180,2*context->disp); - Translate(&pc,pm,a,context->radius); - context->pm = pm; - context->pc = pc; - context->p0 = p0; - context->p1 = p1; - } else { - pm = context->pm; - pc = context->pc; - p0 = context->p0; - p1 = context->p1; - } - if (context->last_inx == 0) { - p1 = context->p1; - pc = context->pc; - a = FindAngle(p1,pc); - Translate(&pc,p1,a,context->radius); - context->pc = pc; - PointOnCircle( &p0, context->pc, context->radius, NormalizeAngle(a+180-context->arc_angle) ); - context->p0 = p0; - PointOnCircle( &pm, context->pc, context->radius, NormalizeAngle(a+180-(context->arc_angle/2))); - context->pm = pm; - } else if (context->last_inx == 1) { - p0 = context->p0; - pc = context->pc; - a = FindAngle(p0,pc); - Translate(&pc,p0,a,context->radius); - context->pc = pc; - PointOnCircle( &p1, context->pc, context->radius, NormalizeAngle(a+180+context->arc_angle) ); - context->p1 = p1; - PointOnCircle( &pm, context->pc, context->radius, NormalizeAngle(a+180+(context->arc_angle/2))); - context->pm = pm; - } else { // Middle if neither - a = FindAngle(context->pm,context->pc); - Translate(&pc,context->pm,a,context->radius); - context->pc = pc; - PointOnCircle( &p1, context->pc, context->radius, NormalizeAngle(FindAngle(context->pc,context->pm)+(context->arc_angle/2)) ); - PointOnCircle( &p0, context->pc, context->radius, NormalizeAngle(FindAngle(context->pc,context->pm)-(context->arc_angle/2)) ); - context->p1 = p1; - context->p0 = p0; - } - a = FindAngle(p1,p0); - Rotate(&pm,p1,-a); - context->disp = pm.x-p1.x; - tempSegs(0).u.c.center = context->pc; - tempSegs(0).u.c.a0 = FindAngle(context->pc,context->p0); - tempSegs(0).u.c.a1 = NormalizeAngle(FindAngle(context->pc,context->p1)-tempSegs(0).u.c.a0); - if (tempSegs(0).u.c.a1 == 0.0) tempSegs(0).u.c.a1 = 360.0; + case SEG_TBLEDGE: + case SEG_STRLIN: + case SEG_DIMLIN: + case SEG_BENCH: + context->abs_angle = NormalizeAngle(context->abs_angle); + Translate(&tempSegs(0).u.l.pos[1],tempSegs(0).u.l.pos[0],context->abs_angle, + context->length); + CreateLineAnchors(context->last_inx,tempSegs(0).u.l.pos[0], + tempSegs(0).u.l.pos[1]); + context->p0 = tempSegs(0).u.l.pos[0]; + context->p1 = tempSegs(0).u.l.pos[1]; + break; + case SEG_CRVLIN: + case SEG_FILCRCL: + if (tempSegs(0).u.c.a1 == 360.0 || tempSegs(0).u.c.a1 == 0.0) { + tempSegs(0).u.c.a1 = 360.0; tempSegs(0).u.c.radius = context->radius; - CreateCurveAnchors(context->last_inx,context->pm,context->pc,context->p0,context->p1); - break; - case SEG_POLY: - case SEG_FILPOLY: - a = NormalizeAngle(FindAngle(points(0).pt,points(3).pt)); - Translate( &points(3).pt, points(0).pt, a, context->height); - Translate( &points(2).pt, points(1).pt, a, context->height); - a = NormalizeAngle(FindAngle(points(0).pt,points(1).pt));; - Translate( &points(1).pt, points(0).pt, a, context->width); - Translate( &points(2).pt, points(3).pt, a, context->width); - CreateBoxAnchors(context->last_inx,&points(0)); - break; - default: + Translate(&p0,tempSegs(0).u.c.center,tempSegs(0).u.c.a0,tempSegs(0).u.c.radius); + context->p0 = p0; + context->p1 = p0; + context->pm = p0; + context->pc = tempSegs(0).u.c.center; break; + } + if (context->radius < 0) { //swap ends + context->radius = fabs(context->radius); + p1 = context->p0; + p0 = context->p1; + a = FindAngle(context->pc,context->pm); + Translate(&pm,context->pm,a+180,2*context->disp); + Translate(&pc,pm,a,context->radius); + context->pm = pm; + context->pc = pc; + context->p0 = p0; + context->p1 = p1; + } else { + pm = context->pm; + pc = context->pc; + p0 = context->p0; + p1 = context->p1; + } + if (context->last_inx == 0) { + p1 = context->p1; + pc = context->pc; + a = FindAngle(p1,pc); + Translate(&pc,p1,a,context->radius); + context->pc = pc; + PointOnCircle( &p0, context->pc, context->radius, + NormalizeAngle(a+180-context->arc_angle) ); + context->p0 = p0; + PointOnCircle( &pm, context->pc, context->radius, + NormalizeAngle(a+180-(context->arc_angle/2))); + context->pm = pm; + } else if (context->last_inx == 1) { + p0 = context->p0; + pc = context->pc; + a = FindAngle(p0,pc); + Translate(&pc,p0,a,context->radius); + context->pc = pc; + PointOnCircle( &p1, context->pc, context->radius, + NormalizeAngle(a+180+context->arc_angle) ); + context->p1 = p1; + PointOnCircle( &pm, context->pc, context->radius, + NormalizeAngle(a+180+(context->arc_angle/2))); + context->pm = pm; + } else { // Middle if neither + a = FindAngle(context->pm,context->pc); + Translate(&pc,context->pm,a,context->radius); + context->pc = pc; + PointOnCircle( &p1, context->pc, context->radius, + NormalizeAngle(FindAngle(context->pc,context->pm)+(context->arc_angle/2)) ); + PointOnCircle( &p0, context->pc, context->radius, + NormalizeAngle(FindAngle(context->pc,context->pm)-(context->arc_angle/2)) ); + context->p1 = p1; + context->p0 = p0; + } + a = FindAngle(p1,p0); + Rotate(&pm,p1,-a); + context->disp = pm.x-p1.x; + tempSegs(0).u.c.center = context->pc; + tempSegs(0).u.c.a0 = FindAngle(context->pc,context->p0); + tempSegs(0).u.c.a1 = NormalizeAngle(FindAngle(context->pc, + context->p1)-tempSegs(0).u.c.a0); + if (tempSegs(0).u.c.a1 == 0.0) { tempSegs(0).u.c.a1 = 360.0; } + tempSegs(0).u.c.radius = context->radius; + CreateCurveAnchors(context->last_inx,context->pm,context->pc,context->p0, + context->p1); + break; + case SEG_POLY: + case SEG_FILPOLY: + a = NormalizeAngle(FindAngle(points(0).pt,points(3).pt)); + Translate( &points(3).pt, points(0).pt, a, context->height); + Translate( &points(2).pt, points(1).pt, a, context->height); + a = NormalizeAngle(FindAngle(points(0).pt,points(1).pt));; + Translate( &points(1).pt, points(0).pt, a, context->width); + Translate( &points(2).pt, points(3).pt, a, context->width); + CreateBoxAnchors(context->last_inx,&points(0)); + break; + default: + break; } } break; case wActionExtKey: - if ((((action>>8)&0xFF)== wAccelKey_Del) && polyMode) //Convert Del key to be BackSpace in PolyModify + if ((((action>>8)&0xFF)== wAccelKey_Del) + && polyMode) { //Convert Del key to be BackSpace in PolyModify return DrawGeomPolyModify(C_TEXT+((int)(127<<8)),pos,context); + } break; case C_TEXT: - if (context->rotate_state) DrawGeomOriginMove(action, pos, context); + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); + if (context->rotate_state) { DrawGeomOriginMove(action, pos, context); } - if (polyMode) return DrawGeomPolyModify(action,pos,context); + if (polyMode) { return DrawGeomPolyModify(action,pos,context); } if (action>>8 == 'o') { MenuMode(I2VP(1)); } + if (context->subtype == RECTANGLE) { + switch (action>>8) { + case 'f': + tempSegs(0).type = SEG_FILPOLY; + context->type = SEG_FILPOLY; + break; + case 'u': + tempSegs(0).type = SEG_POLY; + context->type = SEG_POLY; + break; + } + } - if (action>>8 != 32 && action>>8 != 13) return C_CONTINUE; - /* no break */ + if (action>>8 != 32 && action>>8 != 13) { return C_CONTINUE; } + /* no break */ case C_CONFIRM: return C_CONTINUE; - /* no break*/ + /* no break*/ case C_OK: case C_FINISH: UndoStart("Modify Draw", "OK"); @@ -2581,10 +2773,13 @@ STATUS_T DrawGeomModify( DrawGeomPolyModify(action,pos,context); context->segPtr[segInx].type = context->type; context->segPtr[segInx].u.p.polyType = context->subtype; - if (context->segPtr[segInx].type == SEG_FILPOLY) - context->segPtr[segInx].u.p.polyType = FREEFORM; //Ensure Filled is closed + if (context->segPtr[segInx].type == SEG_FILPOLY) { + context->segPtr[segInx].u.p.polyType = + FREEFORM; //Ensure Filled is closed + } context->state = MOD_NONE; DrawNewTrack( context->trk ); + DYNARR_RESET( trkSeg_t, tempSegs_da ); return C_TERMINATE; } //copy changes back into track @@ -2593,56 +2788,61 @@ STATUS_T DrawGeomModify( context->rot_moved = FALSE; context->angle = 0.0; switch (tempSegs(0).type) { - case SEG_TBLEDGE: - case SEG_STRLIN: - case SEG_DIMLIN: - case SEG_BENCH: - for (int i=0;i<2;i++) { - pos = i==0?context->p0:context->p1; - pos.x -= context->rot_center.x; - pos.y -= context->rot_center.y; - context->segPtr[segInx].u.l.pos[i] = pos; - } - break; - case SEG_CRVLIN: - case SEG_FILCRCL: - pc = context->pc; - pc.x -= context->rot_center.x; - pc.y -= context->rot_center.y; - context->segPtr[segInx].u.c.center = pc; - p0 = context->p0; - p0.x -= context->rot_center.x; - p0.y -= context->rot_center.y; - p1 = context->p1; - p1.x -= context->rot_center.x; - p1.y -= context->rot_center.y; - context->segPtr[segInx].u.c.a0 = FindAngle(pc,p0); - context->segPtr[segInx].u.c.a1 = NormalizeAngle(FindAngle(pc,p1)-FindAngle(pc,p0)); - if (context->segPtr[segInx].u.c.a1 == 0) context->segPtr[segInx].u.c.a1 = 360.0; - context->segPtr[segInx].u.c.radius = context->radius; - break; - case SEG_POLY: - case SEG_FILPOLY: - for (int i=0;i<4;i++) { - pos = points(i).pt; - pos.x -= context->rot_center.x; - pos.y -= context->rot_center.y; - context->segPtr[segInx].u.p.pts[i].pt = pos; - } - break; - default: - break; + case SEG_TBLEDGE: + case SEG_STRLIN: + case SEG_DIMLIN: + case SEG_BENCH: + for (int i=0; i<2; i++) { + pos = i==0?context->p0:context->p1; + pos.x -= context->rot_center.x; + pos.y -= context->rot_center.y; + context->segPtr[segInx].u.l.pos[i] = pos; + } + break; + case SEG_CRVLIN: + case SEG_FILCRCL: + pc = context->pc; + pc.x -= context->rot_center.x; + pc.y -= context->rot_center.y; + context->segPtr[segInx].u.c.center = pc; + p0 = context->p0; + p0.x -= context->rot_center.x; + p0.y -= context->rot_center.y; + p1 = context->p1; + p1.x -= context->rot_center.x; + p1.y -= context->rot_center.y; + context->segPtr[segInx].u.c.a0 = FindAngle(pc,p0); + context->segPtr[segInx].u.c.a1 = NormalizeAngle(FindAngle(pc,p1)-FindAngle(pc, + p0)); + if (context->segPtr[segInx].u.c.a1 == 0) { context->segPtr[segInx].u.c.a1 = 360.0; } + context->segPtr[segInx].u.c.radius = context->radius; + break; + case SEG_POLY: + case SEG_FILPOLY: + for (int i=0; i<4; i++) { + pos = points(i).pt; + pos.x -= context->rot_center.x; + pos.y -= context->rot_center.y; + context->segPtr[segInx].u.p.pts[i].pt = pos; + } + break; + default: + break; } context->state = MOD_NONE; context->rotate_state = FALSE; context->last_inx = -1; DYNARR_RESET(trkSeg_t,anchors_da); + DYNARR_RESET( trkSeg_t, tempSegs_da ); + DrawNewTrack( context->trk ); return C_TERMINATE; case C_REDRAW: - if (polyMode) return DrawGeomPolyModify(action,pos,context); - if (context->state == MOD_NONE) return C_CONTINUE; - DrawSegs( &tempD, zero, 0.0, &tempSegs(0), tempSegs_da.cnt, trackGauge, wDrawColorBlack); - DrawSegs( &tempD, zero, 0.0, &anchors(0), anchors_da.cnt, trackGauge, wDrawColorBlack ); + if (polyMode) { return DrawGeomPolyModify(action,pos,context); } + if (context->state == MOD_NONE) { return C_CONTINUE; } + DrawSegsDA( &tempD, NULL, zero, 0.0, &tempSegs_da, trackGauge, wDrawColorBlack, + 0 ); + DrawSegsDA( &tempD, NULL, zero, 0.0, &anchors_da, trackGauge, wDrawColorBlack, + 0 ); break; case C_CANCEL: context->state = MOD_NONE; @@ -2650,6 +2850,7 @@ STATUS_T DrawGeomModify( context->rot_moved = FALSE; polyMode = FALSE; DYNARR_RESET(trkSeg_t,anchors_da); + DYNARR_RESET( trkSeg_t, tempSegs_da ); DrawNewTrack( context->trk ); break; default: @@ -2657,3 +2858,5 @@ STATUS_T DrawGeomModify( } return C_CONTINUE; } + + diff --git a/app/bin/drawgeom.h b/app/bin/drawgeom.h index 19a982d..d98cf1d 100644 --- a/app/bin/drawgeom.h +++ b/app/bin/drawgeom.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef HAVE_DRAWGEOM_H @@ -49,78 +49,78 @@ #define OP_LAST (OP_POLYLINE) typedef struct { - void (*message)( const char *, ... ); - void (*Redraw)( void ); - drawCmd_p D; - long Op; - wDrawColor Color; - long line_Width; - double width; - ANGLE_T angle; - double length; - double radius; - long benchOption; - drawLineType_e lineType; - int State; - int index; - curveData_t ArcData; - ANGLE_T ArcAngle; - int Started; - BOOL_T Changed; - BOOL_T show; - BOOL_T UndoStarted; - } drawContext_t; + void (*message)( const char *, ... ); + void (*Redraw)( void ); + drawCmd_p D; + long Op; + double width; + ANGLE_T angle; + double length; + double radius; + long benchOption; + drawLineType_e lineType; + int State; + int index; + curveData_t ArcData; + ANGLE_T ArcAngle; + int Started; + BOOL_T Changed; + BOOL_T show; + BOOL_T UndoStarted; +} drawContext_t; typedef enum {MOD_NONE, MOD_STARTED, MOD_SELECTED_PT, MOD_AFTER_PT, - MOD_ORIGIN, MOD_AFTER_ORIG } ModState_e; + MOD_ORIGIN, MOD_AFTER_ORIG + } ModState_e; typedef struct { - void (*message)( const char *, ... ); - void (*Redraw)( void ); - drawCmd_p D; - double length; - ANGLE_T rel_angle; - double radius; - ANGLE_T arc_angle; - int last_inx; - ANGLE_T abs_angle; - double height; - double width; - int prev_inx; - int max_inx; - track_p trk; - char type; - coOrd orig; //Origin Pos - ANGLE_T angle; //Origin Angle - wIndex_t segCnt; - trkSeg_p segPtr; - wBool_t selected; - wBool_t circle; - ModState_e state; - coOrd rel_center; - coOrd rot_center; - wBool_t rot_moved; - coOrd translate_center; - coOrd moved; - coOrd arm; - coOrd new_arm; - ANGLE_T rot_angle; - coOrd p0; - coOrd p1; - coOrd pm; - coOrd pc; - DIST_T disp; - wBool_t rotate_state; - wBool_t open; - wBool_t filled; - PolyType_e subtype; - } drawModContext_t; + void (*message)( const char *, ... ); + void (*Redraw)( void ); + drawCmd_p D; + double length; + ANGLE_T rel_angle; + double radius; + ANGLE_T arc_angle; + int last_inx; + ANGLE_T abs_angle; + double height; + double width; + int prev_inx; + int max_inx; + track_p trk; + char type; + coOrd orig; //Origin Pos + ANGLE_T angle; //Origin Angle + wIndex_t segCnt; + trkSeg_p segPtr; + wBool_t selected; + wBool_t circle; + ModState_e state; + coOrd rel_center; + coOrd rot_center; + wBool_t rot_moved; + coOrd translate_center; + coOrd moved; + coOrd arm; + coOrd new_arm; + ANGLE_T rot_angle; + coOrd p0; + coOrd p1; + coOrd pm; + coOrd pc; + DIST_T disp; + wBool_t rotate_state; + wBool_t open; + wBool_t filled; + PolyType_e subtype; +} drawModContext_t; typedef enum {LENGTH_UPDATE, WIDTH_UPDATE} drawUpdateType_e; extern drawContext_t * drawContext; extern wDrawColor lineColor; -extern long lineWidth; +extern wDrawColor benchColor; +extern DIST_T lineWidth; void DrawGeomOp( void * ); STATUS_T DrawGeomMouse( wAction_t, coOrd, drawContext_t *); diff --git a/app/bin/dxfformat.c b/app/bin/dxfformat.c index 3adc1b7..ac634cf 100644 --- a/app/bin/dxfformat.c +++ b/app/bin/dxfformat.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <dynstring.h> @@ -26,8 +26,9 @@ extern char *sProdNameUpper; extern long units; /**< meaning is 0 = English, 1 = metric */ -static char *dxfDimensionDefaults[][3] = { /**< default values for dimensions, English, metric and DXF variable name */ - { "1.0", "25.0", "$DIMTXT" }, +static char *dxfDimensionDefaults[][3] = { + /**< default values for dimensions, English, metric and DXF variable name */ + { "1.0", "25.0", "$DIMTXT" }, { "0.8", "20.0", "$DIMASZ"} }; @@ -42,14 +43,27 @@ static char *dxfDimensionDefaults[][3] = { /**< default values for dimensions, E void DxfLayerName(DynString *result, char *name, int layer) { - DynStringPrintf(result, DXF_INDENT "8\n%s%d\n", name, layer); + DynStringPrintf(result, DXF_INDENT "8\n%s%d\n", name, layer); +} + +/** +* Build and format an integer. +* +* \param result OUT buffer for result +* \param type IN type of integer following DXF specs +* \param value IN position +*/ + +void DxfFormatInteger(DynString *result, int type, int value) +{ + DynStringPrintf(result, DXF_INDENT "%d\n%d\n", type, value); } /** * Build and format a position. If it specifies a point the value * is assumed to be in inches and will be converted to millimeters * if the metric system is active. -* If it is an angle (group codes 50 to 59) it is not converted. +* If it is an angle (group codes 50 to 59) it is not converted. * * \param result OUT buffer for result * \param type IN type of position following DXF specs @@ -58,26 +72,30 @@ void DxfLayerName(DynString *result, char *name, int layer) void DxfFormatPosition(DynString *result, int type, double value) { - if (units == 1) - { - if( type < 50 || type > 58 ) + if (units == 1) { + if( type < 50 || type > 58 ) { value *= 25.4; + } } - - DynStringPrintf(result, DXF_INDENT "%d\n%0.6f\n", type, value); + + DynStringPrintf(result, DXF_INDENT "%d\n%0.6f\n", type, value); } /** * Build and format the line style definition * * \param result OUT buffer for result -* \param type IN line style TRUE for dashed, FALSE for solid lines +* \param type IN line style */ -void DxfLineStyle(DynString *result, int isDashed) +void DxfLineStyle(DynString *result, int style) { - DynStringPrintf(result, DXF_INDENT "6\n%s\n", - (isDashed ? "DASHED" : "CONTINUOUS")); + char* s = "CONTINUOUS"; + switch ( style ) { + case 1: s = "DASHEDTINY"; break; + case 2: s = "DOTTINY"; break; + } + DynStringPrintf(result, DXF_INDENT "6\n%s\n", s); } /** @@ -92,11 +110,11 @@ void DxfLineStyle(DynString *result, int isDashed) static void DxfAppendLayerName(DynString *output, int layer) { - DynString formatted = NaS; - DynStringMalloc(&formatted, 0); - DxfLayerName(&formatted, sProdNameUpper, layer); - DynStringCatStr(output, &formatted); - DynStringFree(&formatted); + DynString formatted = NaS; + DynStringMalloc(&formatted, 0); + DxfLayerName(&formatted, sProdNameUpper, layer); + DynStringCatStr(output, &formatted); + DynStringFree(&formatted); } /** @@ -110,28 +128,46 @@ DxfAppendLayerName(DynString *output, int layer) static void DxfAppendPosition(DynString *output, int type, double value) { - DynString formatted = NaS; - DynStringMalloc(&formatted, 0); - DxfFormatPosition(&formatted, type, value); - DynStringCatStr(output, &formatted); - DynStringFree(&formatted); + DynString formatted = NaS; + DynStringMalloc(&formatted, 0); + DxfFormatPosition(&formatted, type, value); + DynStringCatStr(output, &formatted); + DynStringFree(&formatted); +} + +/** +* Build and format an integer. The result is appended to the existing result buffer. +* +* \param output OUT buffer for result +* \param type IN type of integer following DXF specs +* \param value IN position +*/ + +static void +DxfAppendInteger(DynString *output, int type, int value) +{ + DynString formatted = NaS; + DynStringMalloc(&formatted, 0); + DxfFormatInteger(&formatted, type, value); + DynStringCatStr(output, &formatted); + DynStringFree(&formatted); } /** * Build and format the line style definition. The result is appended to the existing result buffer. * * \param result OUT buffer for result -* \param type IN line style TRUE for dashed, FALSE for solid lines +* \param type IN line style 0 CONTINUOUS, 1 DASHED or 2 DOT */ static void DxfAppendLineStyle(DynString *output, int style) { - DynString formatted = NaS; - DynStringMalloc(&formatted, 0); - DxfLineStyle(&formatted, style); - DynStringCatStr(output, &formatted); - DynStringFree(&formatted); + DynString formatted = NaS; + DynStringMalloc(&formatted, 0); + DxfLineStyle(&formatted, style); + DynStringCatStr(output, &formatted); + DynStringFree(&formatted); } /** @@ -142,19 +178,21 @@ DxfAppendLineStyle(DynString *output, int style) * \param x0, y0 IN first endpoint * \param x1, y1 IN second endpoint * \param style IN line style, TRUE for dashed, FALSE for continuous +* \param color IN line color */ void DxfLineCommand(DynString *result, int layer, double x0, - double y0, double x1, double y1, int style) + double y0, double x1, double y1, int style, int color) { - DynStringCatCStr(result, DXF_INDENT "0\nLINE\n"); - DxfAppendLayerName(result, layer); - DxfAppendPosition(result, 10, x0); - DxfAppendPosition(result, 20, y0); - DxfAppendPosition(result, 11, x1); - DxfAppendPosition(result, 21, y1); - DxfAppendLineStyle(result, style); + DynStringCatCStr(result, DXF_INDENT "0\nLINE\n"); + DxfAppendLayerName(result, layer); + DxfAppendPosition(result, 10, x0); + DxfAppendPosition(result, 20, y0); + DxfAppendPosition(result, 11, x1); + DxfAppendPosition(result, 21, y1); + DxfAppendLineStyle(result, style); + DxfAppendInteger(result, 420, color); } /** @@ -165,18 +203,20 @@ DxfLineCommand(DynString *result, int layer, double x0, * \param x, y IN center point * \param r IN radius * \param style IN line style, TRUE for dashed, FALSE for continuous +* \param color IN line color */ void DxfCircleCommand(DynString *result, int layer, double x, - double y, double r, int style) + double y, double r, int style, int color) { - DynStringCatCStr(result, DXF_INDENT "0\nCIRCLE\n"); - DxfAppendPosition(result, 10, x); - DxfAppendPosition(result, 20, y); - DxfAppendPosition(result, 40, r); - DxfAppendLayerName(result, layer); - DxfAppendLineStyle(result, style); + DynStringCatCStr(result, DXF_INDENT "0\nCIRCLE\n"); + DxfAppendPosition(result, 10, x); + DxfAppendPosition(result, 20, y); + DxfAppendPosition(result, 40, r); + DxfAppendLayerName(result, layer); + DxfAppendLineStyle(result, style); + DxfAppendInteger(result, 420, color); } /** @@ -189,20 +229,22 @@ DxfCircleCommand(DynString *result, int layer, double x, * \param a0 IN starting angle * \param a1 IN ending angle * \param style IN line style, TRUE for dashed, FALSE for continuous +* \param color IN line color */ void DxfArcCommand(DynString *result, int layer, double x, double y, - double r, double a0, double a1, int style) + double r, double a0, double a1, int style, int color) { - DynStringCatCStr(result, DXF_INDENT "0\nARC\n"); - DxfAppendPosition(result, 10, x); - DxfAppendPosition(result, 20, y); - DxfAppendPosition(result, 40, r); - DxfAppendPosition(result, 50, a0); - DxfAppendPosition(result, 51, a0+a1); - DxfAppendLayerName(result, layer); - DxfAppendLineStyle(result, style); + DynStringCatCStr(result, DXF_INDENT "0\nARC\n"); + DxfAppendPosition(result, 10, x); + DxfAppendPosition(result, 20, y); + DxfAppendPosition(result, 40, r); + DxfAppendPosition(result, 50, a0); + DxfAppendPosition(result, 51, a0+a1); + DxfAppendLayerName(result, layer); + DxfAppendLineStyle(result, style); + DxfAppendInteger(result, 420, color); } /** @@ -213,18 +255,20 @@ DxfArcCommand(DynString *result, int layer, double x, double y, * \param x, y IN text position * \param size IN font size * \param text IN text +* \param color IN text color */ void DxfTextCommand(DynString *result, int layer, double x, - double y, double size, char *text) + double y, double size, char *text, int color) { - DynStringCatCStr(result, DXF_INDENT "0\nTEXT\n"); - DynStringCatCStrs(result, DXF_INDENT "1\n", text, "\n", NULL); - DxfAppendPosition(result, 10, x); - DxfAppendPosition(result, 20, y); - DxfAppendPosition(result, 40, size/72.0); - DxfAppendLayerName(result, layer); + DynStringCatCStr(result, DXF_INDENT "0\nTEXT\n"); + DynStringCatCStrs(result, DXF_INDENT "1\n", text, "\n", NULL); + DxfAppendPosition(result, 10, x); + DxfAppendPosition(result, 20, y); + DxfAppendPosition(result, 40, size/72.0); + DxfAppendLayerName(result, layer); + DxfAppendInteger(result, 420, color); } /** @@ -238,29 +282,29 @@ DxfTextCommand(DynString *result, int layer, double x, void DxfUnits(DynString *result) { - char *value; - DynStringCatCStr(result, DXF_INDENT "9\n$MEASUREMENT\n 70\n"); + char *value; + DynStringCatCStr(result, DXF_INDENT "9\n$MEASUREMENT\n 70\n"); - if (units == 1) { - value = "1\n"; - } else { - value = "0\n"; - } + if (units == 1) { + value = "1\n"; + } else { + value = "0\n"; + } - DynStringCatCStr(result, value); - DynStringCatCStr(result, DXF_INDENT "9\n$INSUNITS\n 70\n"); + DynStringCatCStr(result, value); + DynStringCatCStr(result, DXF_INDENT "9\n$INSUNITS\n 70\n"); - if (units == 1) { - value = "4\n"; - } else { - value = "1\n"; - } + if (units == 1) { + value = "4\n"; + } else { + value = "1\n"; + } - DynStringCatCStr(result, value); + DynStringCatCStr(result, value); } /** -* Define a size of dimensions. The default values are taken from +* Define a size of dimensions. The default values are taken from * static array dxfDimensionDefaults * * \PARAM result OUT the completed command is appended to this buffer @@ -273,10 +317,10 @@ DxfDimensionSize(DynString *result, enum DXF_DIMENSIONS dimension ) DynString formatted; DynStringMalloc(&formatted, 0); - DynStringPrintf(&formatted, - DXF_INDENT "9\n%s\n 40\n%s\n", - dxfDimensionDefaults[dimension][2], - dxfDimensionDefaults[dimension][units]); + DynStringPrintf(&formatted, + DXF_INDENT "9\n%s\n 40\n%s\n", + dxfDimensionDefaults[dimension][2], + dxfDimensionDefaults[dimension][units]); DynStringCatStr(result, &formatted); DynStringFree(&formatted); @@ -296,24 +340,24 @@ void DxfPrologue(DynString *result, int layerCount, double x0, double y0, double x1, double y1) { - int i; - DynString layer = NaS; - DynStringMalloc(&layer, 0); - DynStringCatCStr(result, "\ + int i; + DynString layer = NaS; + DynStringMalloc(&layer, 0); + DynStringCatCStr(result, "\ 0\nSECTION\n\ 2\nHEADER\n\ 9\n$ACADVER\n 1\nAC1009\n"); DxfUnits(result); DxfDimensionSize(result, DXF_DIMTEXTSIZE); DxfDimensionSize(result, DXF_DIMARROWSIZE); - - DynStringCatCStr(result, " 9\n$EXTMIN\n"); - DxfAppendPosition(result, 10, x0); - DxfAppendPosition(result, 20, y0); - DynStringCatCStr(result, " 9\n$EXTMAX\n"); - DxfAppendPosition(result, 10, x1); - DxfAppendPosition(result, 20, y1); - DynStringCatCStr(result, "\ + + DynStringCatCStr(result, " 9\n$EXTMIN\n"); + DxfAppendPosition(result, 10, x0); + DxfAppendPosition(result, 20, y0); + DynStringCatCStr(result, " 9\n$EXTMAX\n"); + DxfAppendPosition(result, 10, x1); + DxfAppendPosition(result, 20, y1); + DynStringCatCStr(result, "\ 9\n$TEXTSTYLE\n 7\nSTANDARD\n\ 0\nENDSEC\n\ 0\nSECTION\n\ @@ -334,14 +378,14 @@ DxfPrologue(DynString *result, int layerCount, double x0, double y0, double x1, 2\nLAYER\n\ 70\n0\n"); - for (i = 0; i < layerCount; i++) { - DynStringPrintf(&layer, - DXF_INDENT"0\nLAYER\n 2\n%s%d\n 6\nCONTINUOUS\n 62\n7\n 70\n0\n", - sProdNameUpper, i + 1); - DynStringCatStr(result, &layer); - } + for (i = 0; i < layerCount; i++) { + DynStringPrintf(&layer, + DXF_INDENT"0\nLAYER\n 2\n%s%d\n 6\nCONTINUOUS\n 62\n7\n 70\n0\n", + sProdNameUpper, i + 1); + DynStringCatStr(result, &layer); + } - DynStringCatCStr(result, "\ + DynStringCatCStr(result, "\ 0\nENDTAB\n\ 0\nENDSEC\n\ 0\nSECTION\n\ @@ -358,5 +402,5 @@ DxfPrologue(DynString *result, int layerCount, double x0, double y0, double x1, void DxfEpilogue(DynString *result) { - DynStringCatCStr(result, DXF_INDENT "0\nENDSEC\n" DXF_INDENT "0\nEOF\n"); + DynStringCatCStr(result, DXF_INDENT "0\nENDSEC\n" DXF_INDENT "0\nEOF\n"); } diff --git a/app/bin/dxfformat.h b/app/bin/dxfformat.h index dbb1ee9..d0bd7ab 100644 --- a/app/bin/dxfformat.h +++ b/app/bin/dxfformat.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef HAVE_DXFFORMAT_H @@ -25,8 +25,7 @@ #include "dynstring.h" -enum DXF_DIMENSIONS -{ +enum DXF_DIMENSIONS { DXF_DIMTEXTSIZE, DXF_DIMARROWSIZE }; @@ -35,14 +34,19 @@ void DxfLayerName(DynString *result, char *name, int layer); void DxfFormatPosition(DynString *result, int type, double value); void DxfLineStyle(DynString *result, int isDashed); -void DxfLineCommand(DynString *result, int layer, double x0, double yo, double x1, double y1, int style); -void DxfCircleCommand(DynString *result, int layer, double x, double y, double r, int style); -void DxfArcCommand(DynString *result, int layer, double x, double y, double r, double a0, double a1, int style); -void DxfTextCommand(DynString *result, int layer, double x, double y, double size, char *text); +void DxfLineCommand(DynString *result, int layer, double x0, double yo, + double x1, double y1, int style, int color); +void DxfCircleCommand(DynString *result, int layer, double x, double y, + double r, int style, int color); +void DxfArcCommand(DynString *result, int layer, double x, double y, double r, + double a0, double a1, int style, int color); +void DxfTextCommand(DynString *result, int layer, double x, double y, + double size, char *text, int color); void DxfUnits(DynString *result); void DxfDimensionSize(DynString *result, enum DXF_DIMENSIONS dimension); -void DxfPrologue(DynString *result, int layerCount, double x0, double y0, double x1, double y1); +void DxfPrologue(DynString *result, int layerCount, double x0, double y0, + double x1, double y1); void DxfEpilogue(DynString *result); #define DXF_INDENT " " diff --git a/app/bin/dxfoutput.c b/app/bin/dxfoutput.c index 957110e..3988696 100644 --- a/app/bin/dxfoutput.c +++ b/app/bin/dxfoutput.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <xtrkcad-config.h> @@ -36,114 +36,128 @@ static struct wFilSel_t * exportDXFFile_fs; static void DxfLine( - drawCmd_p d, - coOrd p0, - coOrd p1, - wDrawWidth width, - wDrawColor color) + drawCmd_p d, + coOrd p0, + coOrd p1, + wDrawWidth width, + wDrawColor color) { - DynString command = NaS; - DynStringMalloc(&command, 100); - DxfLineCommand(&command, - curTrackLayer + 1, - p0.x, p0.y, - p1.x, p1.y, - ((d->options&DC_DASH) != 0)); - fputs(DynStringToCStr(&command), (FILE *)d->d); - DynStringFree(&command); + long c = wDrawGetRGB( color ); + long s = d->options & DC_DASH ? 1 : (d->options & DC_DOT ? 2 : 0); + + DynString command = NaS; + DynStringMalloc(&command, 100); + DxfLineCommand(&command, + curTrackLayer + 1, + p0.x, p0.y, + p1.x, p1.y, + s, + c); + fputs(DynStringToCStr(&command), (FILE *)d->d); + DynStringFree(&command); } static void DxfArc( - drawCmd_p d, - coOrd p, - DIST_T r, - ANGLE_T angle0, - ANGLE_T angle1, - BOOL_T drawCenter, - wDrawWidth width, - wDrawColor color) + drawCmd_p d, + coOrd p, + DIST_T r, + ANGLE_T angle0, + ANGLE_T angle1, + BOOL_T drawCenter, + wDrawWidth width, + wDrawColor color) { - DynString command = NaS; - DynStringMalloc(&command, 100); - angle0 = NormalizeAngle(90.0-(angle0+angle1)); - - if (angle1 >= 360.0) { - DxfCircleCommand(&command, - curTrackLayer + 1, - p.x, - p.y, - r, - ((d->options&DC_DASH) != 0)); - } else { - DxfArcCommand(&command, - curTrackLayer + 1, - p.x, - p.y, - r, - angle0, - angle1, - ((d->options&DC_DASH) != 0)); - } - - fputs(DynStringToCStr(&command), (FILE *)d->d); - DynStringFree(&command); + long c = wDrawGetRGB( color ); + long s = d->options & DC_DASH ? 1 : (d->options & DC_DOT ? 2 : 0); + + DynString command = NaS; + DynStringMalloc(&command, 100); + angle0 = NormalizeAngle(90.0-(angle0+angle1)); + + if (angle1 >= 360.0) { + DxfCircleCommand(&command, + curTrackLayer + 1, + p.x, + p.y, + r, + s, + c); + } else { + DxfArcCommand(&command, + curTrackLayer + 1, + p.x, + p.y, + r, + angle0, + angle1, + s, + c); + } + + fputs(DynStringToCStr(&command), (FILE *)d->d); + DynStringFree(&command); } static void DxfString( - drawCmd_p d, - coOrd p, - ANGLE_T a, - char * s, - wFont_p fp, - FONTSIZE_T fontSize, - wDrawColor color) + drawCmd_p d, + coOrd p, + ANGLE_T a, + char * s, + wFont_p fp, + FONTSIZE_T fontSize, + wDrawColor color) { - DynString command = NaS; - DynStringMalloc(&command, 100); - DxfTextCommand(&command, - curTrackLayer + 1, - p.x, - p.y, - fontSize, - s); - fputs(DynStringToCStr(&command), (FILE *)d->d); - DynStringFree(&command); + long c = wDrawGetRGB( color ); + + DynString command = NaS; + DynStringMalloc(&command, 100); + DxfTextCommand(&command, + curTrackLayer + 1, + p.x, + p.y, + fontSize, + s, + c); + fputs(DynStringToCStr(&command), (FILE *)d->d); + DynStringFree(&command); } static void DxfBitMap( - drawCmd_p d, - coOrd p, - wDrawBitMap_p bm, - wDrawColor color) + drawCmd_p d, + coOrd p, + wDrawBitMap_p bm, + wDrawColor color) { } static void DxfPoly( - drawCmd_p d, - int cnt, - coOrd * pts, - int * types, - wDrawColor color, - wDrawWidth width, - drawFill_e eOpts ) + drawCmd_p d, + int cnt, + coOrd * pts, + int * types, + wDrawColor color, + wDrawWidth width, + drawFill_e eOpts ) { - int inx; - - for (inx=1; inx<cnt; inx++) { - DxfLine(d, pts[inx-1], pts[inx], width, color); - } - if (eOpts != DRAW_OPEN) - DxfLine(d, pts[cnt-1], pts[0], width, color); + int inx; + + for (inx=1; inx<cnt; inx++) { + DxfLine(d, pts[inx-1], pts[inx], width, color); + } + if (eOpts != DRAW_OPEN) { + DxfLine(d, pts[cnt-1], pts[0], width, color); + } } static void DxfFillCircle(drawCmd_p d, coOrd center, DIST_T radius, wDrawColor color) { - DxfArc(d, center, radius, 0.0, 360, FALSE, 0, color); + DxfArc(d, center, radius, 0.0, 360, FALSE, 0, color); } -static void DxfRectangle(drawCmd_p d, coOrd orig, coOrd size, wDrawColor color, drawFill_e eOpts) +static void DxfRectangle(drawCmd_p d, coOrd orig, coOrd size, wDrawColor color, + drawFill_e eOpts) { coOrd p[4]; // p1 p2 @@ -157,61 +171,61 @@ static void DxfRectangle(drawCmd_p d, coOrd orig, coOrd size, wDrawColor color, static drawFuncs_t dxfDrawFuncs = { - DxfLine, - DxfArc, - DxfString, - DxfBitMap, - DxfPoly, - DxfFillCircle, - DxfRectangle + DxfLine, + DxfArc, + DxfString, + DxfBitMap, + DxfPoly, + DxfFillCircle, + DxfRectangle }; static drawCmd_t dxfD = { - NULL, &dxfDrawFuncs, 0, 1.0, 0.0, {0.0,0.0}, {0.0,0.0}, Pix2CoOrd, CoOrd2Pix, 100.0 + NULL, &dxfDrawFuncs, 0, 1.0, 0.0, {0.0,0.0}, {0.0,0.0}, Pix2CoOrd, CoOrd2Pix, 100.0 }; static int DoExportDXFTracks( - int cnt, - char ** fileName, - void * data) + int cnt, + char ** fileName, + void * data) { - time_t clock; + time_t clock; DynString command = NaS; FILE * dxfF; - assert(fileName != NULL); - assert(cnt == 1); + CHECK(fileName != NULL); + CHECK(cnt == 1); DynStringMalloc(&command, 100); SetCurrentPath(DXFPATHKEY, fileName[ 0 ]); - dxfF = fopen(fileName[0], "w"); - - if (dxfF==NULL) { - NoticeMessage(MSG_OPEN_FAIL, _("Continue"), NULL, "DXF", fileName[0], - strerror(errno)); - return FALSE; - } - - SetCLocale(); - wSetCursor(mainD.d, wCursorWait); - time(&clock); - + dxfF = fopen(fileName[0], "w"); + + if (dxfF==NULL) { + NoticeMessage(MSG_OPEN_FAIL, _("Continue"), NULL, "DXF", fileName[0], + strerror(errno)); + return FALSE; + } + + SetCLocale(); + wSetCursor(mainD.d, wCursorWait); + time(&clock); + DxfPrologue(&command, 10, 0.0, 0.0, mapD.size.x, mapD.size.y); fputs(DynStringToCStr(&command), dxfF); dxfD.d = (wDraw_p)dxfF; - DrawSelectedTracks(&dxfD); + DrawSelectedTracks( &dxfD, false ); DynStringClear(&command); DxfEpilogue(&command); fputs(DynStringToCStr(&command), dxfF); - fclose(dxfF); - SetUserLocale(); - Reset(); - wSetCursor(mainD.d, defaultCursor); - return TRUE; + fclose(dxfF); + SetUserLocale(); + Reset(); + wSetCursor(mainD.d, defaultCursor); + return TRUE; } /** @@ -220,17 +234,17 @@ static int DoExportDXFTracks( void DoExportDXF(void* unused ) { - //if (selectedTrackCount <= 0) { - // ErrorMessage(MSG_NO_SELECTED_TRK); - // return; - //} - assert(selectedTrackCount > 0); + //if (selectedTrackCount <= 0) { + // ErrorMessage(MSG_NO_SELECTED_TRK); + // return; + //} + CHECK(selectedTrackCount > 0); - if (exportDXFFile_fs == NULL) - exportDXFFile_fs = wFilSelCreate(mainW, FS_SAVE, 0, _("Export to DXF"), - sDXFFilePattern, DoExportDXFTracks, NULL); + if (exportDXFFile_fs == NULL) + exportDXFFile_fs = wFilSelCreate(mainW, FS_SAVE, 0, _("Export to DXF"), + sDXFFilePattern, DoExportDXFTracks, NULL); - wFilSelect(exportDXFFile_fs, GetCurrentPath(DXFPATHKEY)); + wFilSelect(exportDXFFile_fs, GetCurrentPath(DXFPATHKEY)); } diff --git a/app/bin/elev.c b/app/bin/elev.c index ff987cc..98fcbab 100644 --- a/app/bin/elev.c +++ b/app/bin/elev.c @@ -1,5 +1,5 @@ /** \file elev.c - * + * */ /* XTrkCad - Model Railroad CAD @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "ccurve.h" @@ -40,10 +40,10 @@ static char * elevPrefix; static void SetTrkOnElevPath( track_p trk, int mode, DIST_T elev ); typedef struct { - track_p trk; - EPINX_T ep; - DIST_T len; - } elist_t; + track_p trk; + EPINX_T ep; + DIST_T len; +} elist_t; static dynArr_t elist_da; #define elist(N) DYNARR_N( elist_t, elist_da, N ) #define elistAppend( T, E, L ) \ @@ -52,33 +52,35 @@ static dynArr_t elist_da; EPINX_T GetNextTrkOnPath( track_p trk, EPINX_T ep ) { -/* Get next track on Path: - 1 - there is only 1 connected (not counting ep) - 2 - there are >1 but only 1 on Path - 3 - one of them is PST:PSE or PET:PEE -*/ + /* Get next track on Path: + 1 - there is only 1 connected (not counting ep) + 2 - there are >1 but only 1 on Path + 3 - one of them is PST:PSE or PET:PEE + */ EPINX_T ep2; track_p trkN; int epCnt = GetTrkEndPtCnt(trk); for ( ep2=0; ep2<epCnt; ep2++) { - if ( ep2 == ep ) + if ( ep2 == ep ) { continue; + } trkN = GetTrkEndTrk(trk,ep2); - if (trkN && (GetTrkBits(trkN)&TB_PROFILEPATH)) + if (trkN && (GetTrkBits(trkN)&TB_PROFILEPATH)) { return ep2; + } } return -1; } EXPORT int FindDefinedElev( - track_p trk, - EPINX_T ep, - int dir, - BOOL_T onpath, - DIST_T * Relev, - DIST_T *Rdist ) + track_p trk, + EPINX_T ep, + int dir, + BOOL_T onpath, + DIST_T * Relev, + DIST_T *Rdist ) { track_p trk0, trk1; EPINX_T ep0, ep1, ep2; @@ -86,8 +88,9 @@ EXPORT int FindDefinedElev( if (dir) { trk1 = GetTrkEndTrk( trk, ep ); - if (trk1 == NULL) + if (trk1 == NULL) { return FDE_END; + } ep = GetEndPtConnectedToMe( trk1, trk ); trk = trk1; } @@ -96,7 +99,7 @@ EXPORT int FindDefinedElev( while (1) { for (ep2=0; ep2<GetTrkEndPtCnt(trk); ep2++) { if ((trk!=trk0||ep2!=ep0)&& - EndPtIsDefinedElev(trk,ep2) ) { + EndPtIsDefinedElev(trk,ep2) ) { dist += GetTrkLength( trk, ep, ep2 ); *Relev = GetTrkEndElevHeight(trk,ep2); *Rdist = dist; @@ -126,19 +129,20 @@ EXPORT int FindDefinedElev( dist += GetTrkLength( trk, ep, ep2 ); trk = trk1; ep = ep1; - if (trk == trk0) + if (trk == trk0) { return FDE_UDF; + } } } BOOL_T ComputeElev( - track_p trk, - EPINX_T ep, - BOOL_T onpath, - DIST_T *elevR, - DIST_T *gradeR, - BOOL_T force ) + track_p trk, + EPINX_T ep, + BOOL_T onpath, + DIST_T *elevR, + DIST_T *gradeR, + BOOL_T force ) { DIST_T grade = 0.0; DIST_T elev0; @@ -182,10 +186,12 @@ BOOL_T ComputeElev( } } - if ( elevR ) + if ( elevR ) { *elevR = elev0; - if ( gradeR ) + } + if ( gradeR ) { *gradeR = grade; + } return rc; } @@ -198,10 +204,10 @@ BOOL_T ComputeElev( */ typedef struct { - track_p trk; - EPINX_T ep; - DIST_T elev; - } defelev_t; + track_p trk; + EPINX_T ep; + DIST_T elev; +} defelev_t; static dynArr_t defelev_da; #define defelev(N) DYNARR_N( defelev_t, defelev_da, N ) @@ -217,8 +223,9 @@ static void FindDefElev( void ) while ( TrackIterate( &trk ) ) { cnt = GetTrkEndPtCnt( trk ); for ( ep = 0; ep < cnt; ep++ ) { - if ( !EndPtIsDefinedElev( trk, ep ) ) + if ( !EndPtIsDefinedElev( trk, ep ) ) { continue; + } DYNARR_APPEND( defelev_t, defelev_da, 10 ); dep = &defelev( defelev_da.cnt-1 ); dep->trk = trk; @@ -226,7 +233,8 @@ static void FindDefElev( void ) dep->elev = GetTrkEndElevHeight(trk,ep); } } -LOG( log_fillElev, 1, ( "%s: findDefElev [%d] (%ld)\n", elevPrefix, defelev_da.cnt, wGetTimer()-time0 ) ) + LOG( log_fillElev, 1, ( "%s: findDefElev [%d] (%ld)\n", elevPrefix, + defelev_da.cnt, wGetTimer()-time0 ) ) } @@ -250,15 +258,17 @@ static void FindAttachedDefElev( track_p trk, BOOL_T remove ) DYNARR_RESET( elist_t, elist_da ); elistAppend( trk, 0, 0 ); SetTrkBits( trk, TB_PROCESSED ); - if (remove) + if (remove) { ClrTrkBits( trk, TB_ELEVPATH ); + } for ( i1=0; i1<elist_da.cnt; i1++ ) { trk = elist(i1).trk; - if (!IsTrack(trk)) + if (!IsTrack(trk)) { continue; + } cnt = GetTrkEndPtCnt(trk); for ( ep=0; ep<cnt; ep++ ) { - if ( EndPtIsDefinedElev(trk,ep) ) { + if ( EndPtIsDefinedElev(trk,ep) ) { DYNARR_APPEND( defelev_t, defelev_da, 10 ); dep = &defelev( defelev_da.cnt-1 ); dep->trk = trk; @@ -286,8 +296,9 @@ static void FindAttachedDefElev( track_p trk, BOOL_T remove ) if ( !(GetTrkBits(trk1)&TB_PROCESSED) ) { elistAppend( trk1, 0, 0 ); SetTrkBits( trk1, TB_PROCESSED ); - if (remove) + if (remove) { ClrTrkBits( trk1, TB_ELEVPATH ); + } } } } @@ -311,7 +322,8 @@ static int FindObsoleteElevs( void ) FindAttachedDefElev( trk, TRUE ); } } -LOG( log_fillElev, 1, ( "%s: findObsoleteElevs [%d] (%ld)\n", elevPrefix, cnt, wGetTimer()-time0 ) ) + LOG( log_fillElev, 1, ( "%s: findObsoleteElevs [%d] (%ld)\n", elevPrefix, cnt, + wGetTimer()-time0 ) ) return cnt; } @@ -325,22 +337,22 @@ LOG( log_fillElev, 1, ( "%s: findObsoleteElevs [%d] (%ld)\n", elevPrefix, cnt, w */ typedef struct { - track_p trk; - EPINX_T ep; - EPINX_T ep2; - DIST_T dist; - DIST_T elev; - } fork_t; + track_p trk; + EPINX_T ep; + EPINX_T ep2; + DIST_T dist; + DIST_T elev; +} fork_t; static dynArr_t fork_da; #define fork(N) DYNARR_N( fork_t, fork_da, N ) static int FillElevShortestPathFunc( - SPTF_CMD cmd, - track_p trk, - EPINX_T ep, - EPINX_T ep2, - DIST_T dist, - void * data ) + SPTF_CMD cmd, + track_p trk, + EPINX_T ep, + EPINX_T ep2, + DIST_T dist, + void * data ) { defelev_t * dep = (defelev_t *)data; track_p trk1; @@ -351,10 +363,11 @@ static int FillElevShortestPathFunc( case SPTC_MATCH: /*if ( (GetTrkBits(trk)&TB_PROCESSED) ) epRc = 0; - else*/ if ( (dep->trk!=trk || dep->ep!=ep) && EndPtIsDefinedElev(trk,ep)) + else*/ if ( (dep->trk!=trk || dep->ep!=ep) && EndPtIsDefinedElev(trk,ep)) { epRc = 1; - else + } else { epRc = 0; + } break; case SPTC_MATCHANY: @@ -374,12 +387,18 @@ static int FillElevShortestPathFunc( if (!(GetTrkBits(trk)&TB_PROCESSED)) { SetTrkBits(trk, TB_PROCESSED); if ( EndPtIsDefinedElev( trk, ep ) ) { -if (log_shortPath<=0||logTable(log_shortPath).level<4) LOG( log_fillElev, 5, ( " ADD_TRK: T%d:%d D=%0.1f -> DefElev\n", GetTrkIndex(trk), ep, dist ) ) -LOG( log_shortPath, 4, ( "DefElev " ) ) - } else if ( GetNextTrk( trk, ep, &trk1, &ep1, GNTignoreIgnore ) < 0 && trk1 != NULL ) { -if (log_shortPath<=0||logTable(log_shortPath).level<4) LOG( log_fillElev, 4, ( " ADD_TRK: T%d:%d D=%0.3f E=%0.3f -> Fork[%d]\n", GetTrkIndex(trk), ep, dist, dep->elev, fork_da.cnt ) ) -LOG( log_shortPath, 4, ( "E:%0.3f Fork[%d] ", dep->elev, fork_da.cnt ) ) - DYNARR_APPEND( fork_t, fork_da, 10 ); + if (log_shortPath<=0 + ||logTable(log_shortPath).level<4) LOG( log_fillElev, 5, + ( " ADD_TRK: T%d:%d D=%0.1f -> DefElev\n", GetTrkIndex(trk), ep, dist ) ) + LOG( log_shortPath, 4, ( "DefElev " ) ) + } else if ( GetNextTrk( trk, ep, &trk1, &ep1, GNTignoreIgnore ) < 0 + && trk1 != NULL ) { + if (log_shortPath<=0 + ||logTable(log_shortPath).level<4) LOG( log_fillElev, 4, + ( " ADD_TRK: T%d:%d D=%0.3f E=%0.3f -> Fork[%d]\n", GetTrkIndex(trk), ep, + dist, dep->elev, fork_da.cnt ) ) + LOG( log_shortPath, 4, ( "E:%0.3f Fork[%d] ", dep->elev, fork_da.cnt ) ) + DYNARR_APPEND( fork_t, fork_da, 10 ); n = &fork(fork_da.cnt-1); n->trk = trk; n->ep = ep; @@ -391,10 +410,10 @@ LOG( log_shortPath, 4, ( "E:%0.3f Fork[%d] ", dep->elev, fork_da.cnt ) ) n->nep = dep->ep; #endif } else { -LOG( log_shortPath, 4, ( "Normal " ) ) + LOG( log_shortPath, 4, ( "Normal " ) ) } } else { -LOG( log_shortPath, 4, ( "Processed " ) ) + LOG( log_shortPath, 4, ( "Processed " ) ) } return 0; @@ -404,10 +423,10 @@ LOG( log_shortPath, 4, ( "Processed " ) ) case SPTC_IGNNXTTRK: if ( EndPtIsIgnoredElev(trk,ep2) ) { -LOG( log_shortPath, 4, ( "2 Ignore " ) ) + LOG( log_shortPath, 4, ( "2 Ignore " ) ) epRc = 1; } else if ( (!EndPtIsDefinedElev(trk,ep)) && GetTrkEndTrk(trk,ep)==NULL ) { -LOG( log_shortPath, 4, ( "1 Null && !DefElev " ) ) + LOG( log_shortPath, 4, ( "1 Null && !DefElev " ) ) epRc = 1; } else { epRc = 0; @@ -436,19 +455,20 @@ static void FindForks( void ) { int i; defelev_t * dep; - int rc; long time0 = wGetTimer(); DYNARR_RESET( fork_t, fork_da ); for ( i=0; i<defelev_da.cnt; i++ ) { dep = &defelev(i); - + ClrAllTrkBits( TB_PROCESSED ); -LOG( log_fillElev, 3, ( " findForks from T%d:%d\n", GetTrkIndex(dep->trk), dep->ep ) ) - rc = FindShortestPath( dep->trk, dep->ep, FALSE, FillElevShortestPathFunc, dep ); + LOG( log_fillElev, 3, ( " findForks from T%d:%d\n", GetTrkIndex(dep->trk), + dep->ep ) ) + FindShortestPath( dep->trk, dep->ep, FALSE, FillElevShortestPathFunc, dep ); } ClrAllTrkBits( TB_PROCESSED ); -LOG( log_fillElev, 1, ( "%s: findForks [%d] (%ld)\n", elevPrefix, fork_da.cnt, wGetTimer()-time0 ) ) + LOG( log_fillElev, 1, ( "%s: findForks [%d] (%ld)\n", elevPrefix, fork_da.cnt, + wGetTimer()-time0 ) ) } @@ -462,9 +482,9 @@ LOG( log_fillElev, 1, ( "%s: findForks [%d] (%ld)\n", elevPrefix, fork_da.cnt, w */ typedef struct { - DIST_T elev; - DIST_T dist; - } elevdist_t; + DIST_T elev; + DIST_T dist; +} elevdist_t; static dynArr_t elevdist_da; #define elevdist(N) DYNARR_N( elevdist_t, elevdist_da, N ); @@ -488,7 +508,8 @@ static DIST_T ComputeWeightedElev( DIST_T totalDist ) w = &elevdist(i2); if (w->dist < 0.001) { e = w->elev; -LOG( log_fillElev, 3, ( " computeWeightedElev: close! D%0.3f E%0.3f\n", w->dist, e ) ) + LOG( log_fillElev, 3, ( " computeWeightedElev: close! D%0.3f E%0.3f\n", + w->dist, e ) ) return e; } d2 += totalDist/w->dist; @@ -501,13 +522,13 @@ LOG( log_fillElev, 3, ( " computeWeightedElev: close! D%0.3f E%0.3f\n", w- e += ((totalDist/w->dist)/d2)*w->elev; } - if (log_fillElev >= 4) { - for ( i2=0; i2<elevdist_da.cnt; i2++ ) { - w = &elevdist(i2); - lprintf( " E%0.3f D%0.3f\n", w->elev, w->dist ); - } + if (log_fillElev >= 4) { + for ( i2=0; i2<elevdist_da.cnt; i2++ ) { + w = &elevdist(i2); + lprintf( " E%0.3f D%0.3f\n", w->elev, w->dist ); } -LOG( log_fillElev, 3, ( " computeWeightedElev: E%0.3f\n", e ) ) + } + LOG( log_fillElev, 3, ( " computeWeightedElev: E%0.3f\n", e ) ) return e; } @@ -536,8 +557,9 @@ static void ComputeForkElev( void ) n1 = &fork(i1); if ((trk=n1->trk)) { cnt = GetTrkEndPtCnt(n1->trk); - if (cnt<=0) + if (cnt<=0) { continue; + } /* collect dist/elev to connected DefElev points */ d1 = 0; @@ -554,21 +576,25 @@ static void ComputeForkElev( void ) n2->trk = NULL; d1 += w->dist; if ( ! ( ( n1->ep == n2->ep && n1->ep2 == n2->ep2 ) || - ( n1->ep == n2->ep2 && n1->ep2 == n2->ep ) ) ) + ( n1->ep == n2->ep2 && n1->ep2 == n2->ep ) ) ) { singlePath = FALSE; + } } } /* Also check my EPs */ for (ep=0; ep<cnt; ep++) { - if ( (trk1=GetTrkEndTrk(trk,ep)) ) + if ( (trk1=GetTrkEndTrk(trk,ep)) ) { SetTrkBits( trk1, TB_PROCESSED ); - if (!EndPtIsDefinedElev(trk,ep)) + } + if (!EndPtIsDefinedElev(trk,ep)) { continue; + } for (i2=i1; i2<fork_da.cnt; i2++) { n2 = &fork(i2); - if (trk==n2->trk && ep==n2->ep) + if (trk==n2->trk && ep==n2->ep) { break; + } } if (i2 >= fork_da.cnt) { DYNARR_APPEND( elevdist_t, elevdist_da, 10 ); @@ -591,12 +617,13 @@ static void ComputeForkElev( void ) SetTrkOnElevPath( trk, ELEV_FORK, e ); /* 3 or more EPs are to DefElevs */ n3->ep = -1; -LOG( log_fillElev, 2, ( " 1 T%d E%0.3f\n", GetTrkIndex(trk), e ) ) + LOG( log_fillElev, 2, ( " 1 T%d E%0.3f\n", GetTrkIndex(trk), e ) ) } forkCnt++; } } -LOG( log_fillElev, 1, ( "%s: computeForkElev [%d] (%ld)\n", elevPrefix, forkCnt, wGetTimer()-time0 ) ) + LOG( log_fillElev, 1, ( "%s: computeForkElev [%d] (%ld)\n", elevPrefix, forkCnt, + wGetTimer()-time0 ) ) } @@ -618,8 +645,7 @@ static void RedrawCompGradeElev( track_p trk, EPINX_T ep ) pos = GetTrkEndPos( trk, ep ); if (!OFF_MAIND( pos, pos ) ) { trk1 = GetTrkEndTrk( trk, ep ); - if ( (trk1=GetTrkEndTrk(trk,ep)) && GetTrkIndex(trk1)<GetTrkIndex(trk) ) -{ + if ( (trk1=GetTrkEndTrk(trk,ep)) && GetTrkIndex(trk1)<GetTrkIndex(trk) ) { ep = GetEndPtConnectedToMe( trk1, trk ); trk = trk1; } @@ -631,10 +657,10 @@ static void RedrawCompGradeElev( track_p trk, EPINX_T ep ) static void PropogateForkElev( - track_p trk1, - EPINX_T ep1, - DIST_T d1, - DIST_T e ) + track_p trk1, + EPINX_T ep1, + DIST_T d1, + DIST_T e ) /* Propogate elev from fork connection * The track list starting from trk1:ep1 ends at a DefElev or a Fork * Inputs: @@ -651,74 +677,77 @@ static void PropogateForkElev( fork_t * n1; int i2, i3; - DYNARR_RESET( elist_t, elist_da ); - while (trk1) { - if ( GetTrkIndex(trk1) == checkTrk ) - printf( "found btw forks\n" ); - if ( GetTrkOnElevPath( trk1, &e1 ) ) { - d1 += GetTrkLength( trk1, ep1, -1 ); - goto nextStep; - } - cnt2 = GetTrkEndPtCnt(trk1); - for ( ep2=0; ep2<cnt2; ep2++ ) { - if ( ep2!=ep1 && EndPtIsDefinedElev(trk1,ep2) ) { - e1 = GetTrkEndElevHeight( trk1, ep2 ); - d2 = GetTrkLength( trk1, ep1, ep2 )/2.0; - d1 += d2; - elistAppend( trk1, ep1, d1 ); - d1 += d2; - goto nextStep; - } - } - ep2 = GetNextTrk( trk1, ep1, &trkN, &epN, GNTignoreIgnore ); - if ( ep2<0 ) { - /* is this really a fork? */ - for ( i2=0; i2<forkCnt; i2++ ) { - n1 = &fork(i2); - if ( trk1 == n1->trk && n1->ep >= 0 ) { - /* no: make sure we are on the path */ - if ( n1->ep == ep1 ) - ep2 = n1->ep2; - else if ( n1->ep2 == ep1 ) - ep2 = n1->ep; - else - return; - trkN = GetTrkEndTrk(trk1,ep2); - epN = GetEndPtConnectedToMe( trkN, trk1 ); - break; - } - } - if ( i2 >= forkCnt ) - return; + DYNARR_RESET( elist_t, elist_da ); + while (trk1) { + if ( GetTrkIndex(trk1) == checkTrk ) { + printf( "found btw forks\n" ); + } + if ( GetTrkOnElevPath( trk1, &e1 ) ) { + d1 += GetTrkLength( trk1, ep1, -1 ); + goto nextStep; + } + cnt2 = GetTrkEndPtCnt(trk1); + for ( ep2=0; ep2<cnt2; ep2++ ) { + if ( ep2!=ep1 && EndPtIsDefinedElev(trk1,ep2) ) { + e1 = GetTrkEndElevHeight( trk1, ep2 ); + d2 = GetTrkLength( trk1, ep1, ep2 )/2.0; + d1 += d2; + elistAppend( trk1, ep1, d1 ); + d1 += d2; + goto nextStep; + } + } + ep2 = GetNextTrk( trk1, ep1, &trkN, &epN, GNTignoreIgnore ); + if ( ep2<0 ) { + /* is this really a fork? */ + for ( i2=0; i2<forkCnt; i2++ ) { + n1 = &fork(i2); + if ( trk1 == n1->trk && n1->ep >= 0 ) { + /* no: make sure we are on the path */ + if ( n1->ep == ep1 ) { + ep2 = n1->ep2; + } else if ( n1->ep2 == ep1 ) { + ep2 = n1->ep; + } else { + return; } - d2 = GetTrkLength( trk1, ep1, ep2 )/2.0; - d1 += d2; - elistAppend( trk1, ep1, d1 ); - d1 += d2; - trk1 = trkN; - ep1 = epN; + trkN = GetTrkEndTrk(trk1,ep2); + epN = GetEndPtConnectedToMe( trkN, trk1 ); + break; } + } + if ( i2 >= forkCnt ) { + return; + } + } + d2 = GetTrkLength( trk1, ep1, ep2 )/2.0; + d1 += d2; + elistAppend( trk1, ep1, d1 ); + d1 += d2; + trk1 = trkN; + ep1 = epN; + } nextStep: - ASSERT(d1>0.0); - e1 = (e1-e)/d1; - trk1 = NULL; - i3 = elist_da.cnt; - for (i2=0; i2<elist_da.cnt; i2++) { - trk1 = elist(i2).trk; - ep1 = elist(i2).ep; - if ( GetTrkOnElevPath( trk1, &e1 ) ) { - i3=i2; - break; - } - d2 = elist(i2).len; - SetTrkOnElevPath( trk1, ELEV_BRANCH, e+e1*d2 ); -LOG( log_fillElev, 2, ( " 2 T%d E%0.3f\n", GetTrkIndex(trk1), e+e1*d2 ) ) - } - for (i2=0; i2<i3; i2++) { - trk1 = elist(i2).trk; - ep1 = elist(i2).ep; - RedrawCompGradeElev( trk1, ep1 ); - } + CHECK(d1>0.0); + e1 = (e1-e)/d1; + trk1 = NULL; + i3 = elist_da.cnt; + for (i2=0; i2<elist_da.cnt; i2++) { + trk1 = elist(i2).trk; + ep1 = elist(i2).ep; + if ( GetTrkOnElevPath( trk1, &e1 ) ) { + i3=i2; + break; + } + d2 = elist(i2).len; + SetTrkOnElevPath( trk1, ELEV_BRANCH, e+e1*d2 ); + LOG( log_fillElev, 2, ( " 2 T%d E%0.3f\n", GetTrkIndex(trk1), e+e1*d2 ) ) + } + for (i2=0; i2<i3; i2++) { + trk1 = elist(i2).trk; + ep1 = elist(i2).ep; + RedrawCompGradeElev( trk1, ep1 ); + } } static void PropogateForkElevs( void ) @@ -743,8 +772,9 @@ static void PropogateForkElevs( void ) /* propogate elevs between forks */ for ( i1=0; i1<forkCnt; i1++ ) { n1 = &fork(i1); - if ( n1->ep >= 0 ) + if ( n1->ep >= 0 ) { continue; + } trk = n1->trk; GetTrkOnElevPath( trk, &e ); cnt = GetTrkEndPtCnt(trk); @@ -762,7 +792,8 @@ static void PropogateForkElevs( void ) } } } -LOG( log_fillElev, 1, ( "%s: propogateForkElev (%ld)\n", elevPrefix, wGetTimer()-time0 ) ) + LOG( log_fillElev, 1, ( "%s: propogateForkElev (%ld)\n", elevPrefix, + wGetTimer()-time0 ) ) } static void PropogateDefElevs( void ) @@ -783,11 +814,14 @@ static void PropogateDefElevs( void ) dep = &defelev(i1); if (GetTrkOnElevPath( dep->trk, &e )) /* propogateForkElevs beat us to it */ + { continue; + } e = GetTrkEndElevHeight( dep->trk, dep->ep ); PropogateForkElev( dep->trk, dep->ep, 0, e ); } -LOG( log_fillElev, 1, ( "%s: propogateDefElevs [%d] (%ld)\n", elevPrefix, defelev_da.cnt, wGetTimer()-time0 ) ) + LOG( log_fillElev, 1, ( "%s: propogateDefElevs [%d] (%ld)\n", elevPrefix, + defelev_da.cnt, wGetTimer()-time0 ) ) } @@ -803,16 +837,16 @@ LOG( log_fillElev, 1, ( "%s: propogateDefElevs [%d] (%ld)\n", elevPrefix, defele */ typedef struct { - track_p trk; - coOrd pos; - DIST_T elev; - } pivot_t; + track_p trk; + coOrd pos; + DIST_T elev; +} pivot_t; static dynArr_t pivot_da; #define pivot(N) DYNARR_N(pivot_t, pivot_da, N) static void SurveyIsland( - track_p trk, - BOOL_T stopAtElevPath ) + track_p trk, + BOOL_T stopAtElevPath ) /* Find the tracks in this island and the pivots of this island * Outputs: * elist_da - tracks in the island @@ -833,8 +867,9 @@ static void SurveyIsland( SetTrkBits( trk, TB_PROCESSED ); for ( i1=0; i1 < elist_da.cnt; i1++ ) { trk = elist(i1).trk; - if ( GetTrkIndex(trk) == checkTrk ) + if ( GetTrkIndex(trk) == checkTrk ) { printf( "found in island\n" ); + } cnt = GetTrkEndPtCnt(trk); for ( ep=0; ep<cnt; ep++ ) { trk1 = GetTrkEndTrk( trk, ep ); @@ -862,7 +897,7 @@ static void SurveyIsland( } static void ComputeIslandElev( - track_p trk ) + track_p trk ) /* Compute elev of tracks connected to 'trk' * An island is the set of tracks bounded by a DefElev EP or a track already on ElevPath * Inputs: @@ -885,8 +920,9 @@ static void ComputeIslandElev( for ( i1=0; i1 < elist_da.cnt; i1++ ) { trk = elist(i1).trk; - if ( !IsTrack(trk) ) + if ( !IsTrack(trk) ) { continue; + } mode = ELEV_ISLAND; if (pivot_da.cnt == 0) { elev = 0; @@ -912,7 +948,7 @@ static void ComputeIslandElev( elev = ComputeWeightedElev( totalDist ); } SetTrkOnElevPath( trk, mode, elev ); -LOG( log_fillElev, 1, ( " 3 T%d E%0.3f\n", GetTrkIndex(trk), elev ) ) + LOG( log_fillElev, 1, ( " 3 T%d E%0.3f\n", GetTrkIndex(trk), elev ) ) } for ( i1=0; i1<elist_da.cnt; i1++ ) { @@ -945,12 +981,13 @@ static void FindIslandElevs( void ) } } } -LOG( log_fillElev, 1, ( "%s: findIslandElevs [%d] (%ld)\n", elevPrefix, islandCnt, wGetTimer()-time0 ) ) + LOG( log_fillElev, 1, ( "%s: findIslandElevs [%d] (%ld)\n", elevPrefix, + islandCnt, wGetTimer()-time0 ) ) } /* * DYNAMIC ELEVATION COMPUTATION - * + * * Drivers * */ @@ -968,26 +1005,28 @@ EXPORT void RecomputeElevations( void * unused ) PropogateDefElevs(); FindIslandElevs(); MainRedraw(); // RecomputeElevations -LOG( log_fillElev, 1, ( "%s: Total (%ld)\n", elevPrefix, wGetTimer()-time0 ) ) + LOG( log_fillElev, 1, ( "%s: Total (%ld)\n", elevPrefix, wGetTimer()-time0 ) ) if ( log_dumpElev > 0 ) { track_p trk; DIST_T elev; for ( trk=NULL; TrackIterate( &trk ); ) { printf( "T%4.4d = ", GetTrkIndex(trk) ); - if ( GetTrkOnElevPath( trk, &elev ) ) + if ( GetTrkOnElevPath( trk, &elev ) ) { printf( "%d:%0.2f\n", GetTrkElevMode(trk), elev ); - else + } else { printf( "noelev\n" ); + } EPINX_T ep; int mode; for ( ep=0; ep<GetTrkEndPtCnt(trk); ep++ ) { mode = GetTrkEndElevMode( trk, ep ); ComputeElev( trk, ep, FALSE, &elev, NULL, FALSE ); printf( "T%4.4d[%2.2d] = %s:%0.3f\n", - GetTrkIndex(trk), ep, - mode==ELEV_NONE?"None":mode==ELEV_DEF?"Def":mode==ELEV_COMP?"Comp": - mode==ELEV_GRADE?"Grade":mode==ELEV_IGNORE?"Ignore":mode==ELEV_STATION?"Station":"???", - elev ); + GetTrkIndex(trk), ep, + mode==ELEV_NONE?"None":mode==ELEV_DEF?"Def":mode==ELEV_COMP?"Comp": + mode==ELEV_GRADE?"Grade":mode==ELEV_IGNORE?"Ignore":mode==ELEV_STATION + ?"Station":"???", + elev ); } } } @@ -1002,18 +1041,20 @@ EXPORT void UpdateAllElevations( void ) elevPrefix = "UPDELV"; if ( !log_fillElev_initted ) { log_fillElev = LogFindIndex( "fillElev" ); log_dumpElev = LogFindIndex( "dumpElev" ); log_fillElev_initted = TRUE; } - if (!needElevUpdate) + if (!needElevUpdate) { return; + } work = FindObsoleteElevs(); - if (!work) + if (!work) { return; + } FindForks(); ComputeForkElev(); PropogateForkElevs(); PropogateDefElevs(); FindIslandElevs(); needElevUpdate = FALSE; -LOG( log_fillElev, 1, ( "%s: Total (%ld)\n", elevPrefix, wGetTimer()-time0 ) ) + LOG( log_fillElev, 1, ( "%s: Total (%ld)\n", elevPrefix, wGetTimer()-time0 ) ) } @@ -1038,13 +1079,15 @@ EXPORT DIST_T GetElevation( track_p trk ) ComputeForkElev(); PropogateForkElevs(); PropogateDefElevs(); - if ( GetTrkOnElevPath(trk,&elev) ) + if ( GetTrkOnElevPath(trk,&elev) ) { return elev; + } ComputeIslandElev( trk ); - if ( GetTrkOnElevPath(trk,&elev) ) + if ( GetTrkOnElevPath(trk,&elev) ) { return elev; + } printf( "GetElevation(T%d) failed\n", GetTrkIndex(trk) ); return 0; @@ -1053,7 +1096,7 @@ EXPORT DIST_T GetElevation( track_p trk ) /* * DYNAMIC ELEVATION COMPUTATION - * + * * Utilities * */ @@ -1072,8 +1115,9 @@ static void PropogateElevMode( track_p trk, DIST_T elev, int mode ) { int i1; SurveyIsland( trk, FALSE ); - for ( i1=0; i1<elist_da.cnt; i1++ ) + for ( i1=0; i1<elist_da.cnt; i1++ ) { SetTrkOnElevPath( elist(i1).trk, mode, elev ); + } } @@ -1081,17 +1125,20 @@ static BOOL_T CheckForElevAlone( track_p trk ) { int i1; SurveyIsland( trk, FALSE ); - if ( pivot_da.cnt!=0 ) + if ( pivot_da.cnt!=0 ) { return FALSE; - for ( i1=0; i1<elist_da.cnt; i1++ ) + } + for ( i1=0; i1<elist_da.cnt; i1++ ) { SetTrkOnElevPath( elist(i1).trk, ELEV_ALONE, 0.0 ); + } return TRUE; } -EXPORT void SetTrkElevModes( BOOL_T connect, track_p trk0, EPINX_T ep0, track_p trk1, EPINX_T ep1 ) +EXPORT void SetTrkElevModes( BOOL_T connect, track_p trk0, EPINX_T ep0, + track_p trk1, EPINX_T ep1 ) { - int mode0, mode1; + int mode0, mode1; DIST_T elev, diff, elev0, elev1; char * station; BOOL_T update = TRUE; @@ -1112,11 +1159,13 @@ EXPORT void SetTrkElevModes( BOOL_T connect, track_p trk0, EPINX_T ep0, track_p } } else { if ( mode0 == ELEV_ISLAND ) { - if (CheckForElevAlone( trk0 )) + if (CheckForElevAlone( trk0 )) { update = FALSE; + } } else if ( mode1 == ELEV_ISLAND ) { - if (CheckForElevAlone( trk1 )) + if (CheckForElevAlone( trk1 )) { update = FALSE; + } } } @@ -1126,13 +1175,15 @@ EXPORT void SetTrkElevModes( BOOL_T connect, track_p trk0, EPINX_T ep0, track_p elev = 0.0; station = NULL; if (mode0 == ELEV_DEF && mode1 == ELEV_DEF) { - mode0 = GetTrkEndElevUnmaskedMode( trk0, ep0 ) | GetTrkEndElevUnmaskedMode( trk1, ep1 ); + mode0 = GetTrkEndElevUnmaskedMode( trk0, + ep0 ) | GetTrkEndElevUnmaskedMode( trk1, ep1 ); elev0 = GetTrkEndElevHeight( trk0, ep0 ); elev1 = GetTrkEndElevHeight( trk1, ep1 ); elev = (elev0+elev1)/2.0; diff = fabs( elev0-elev1 ); - if (diff>0.1) + if (diff>0.1) { ErrorMessage( MSG_JOIN_DIFFER_ELEV, PutDim(diff) ); + } } else if (mode0 == ELEV_DEF) { mode0 = GetTrkEndElevUnmaskedMode( trk0, ep0 ); elev = GetTrkEndElevHeight( trk0, ep0 ); @@ -1168,18 +1219,18 @@ EXPORT void SetTrkElevModes( BOOL_T connect, track_p trk0, EPINX_T ep0, track_p EXPORT void UpdateTrkEndElev( - track_p trk, - EPINX_T ep, - int newMode, - DIST_T newElev, - char * newStation ) + track_p trk, + EPINX_T ep, + int newMode, + DIST_T newElev, + char * newStation ) { int oldMode; DIST_T oldElev; char * oldStation; BOOL_T changed = TRUE; track_p trk1; - EPINX_T ep1; +// EPINX_T ep1; oldMode = GetTrkEndElevUnmaskedMode( trk, ep ); if ( (oldMode&ELEV_MASK) == (newMode&ELEV_MASK) ) { @@ -1187,8 +1238,9 @@ EXPORT void UpdateTrkEndElev( case ELEV_DEF: oldElev = GetTrkEndElevHeight( trk, ep ); if ( oldElev == newElev ) { - if ( oldMode == newMode ) + if ( oldMode == newMode ) { return; + } changed = FALSE; } break; @@ -1204,8 +1256,9 @@ EXPORT void UpdateTrkEndElev( } else { changed = TRUE; if ( (newMode&ELEV_MASK)==ELEV_DEF || (oldMode&ELEV_MASK)==ELEV_DEF || - (newMode&ELEV_MASK)==ELEV_IGNORE || (oldMode&ELEV_MASK)==ELEV_IGNORE ) + (newMode&ELEV_MASK)==ELEV_IGNORE || (oldMode&ELEV_MASK)==ELEV_IGNORE ) { changed = TRUE; + } } UndoModify( trk ); if ( (trk1 = GetTrkEndTrk( trk, ep )) ) { @@ -1217,7 +1270,7 @@ EXPORT void UpdateTrkEndElev( if ( changed ) { ClrTrkElev( trk ); if ( trk1 ) { - ep1 = GetEndPtConnectedToMe( trk1, trk ); +// ep1 = GetEndPtConnectedToMe( trk1, trk ); ClrTrkElev( trk1 ); } UpdateAllElevations(); @@ -1231,23 +1284,28 @@ static void SetTrkOnElevPath( track_p trk, int mode, DIST_T elev ) DIST_T oldElev; coOrd hi, lo; - if ( !GetTrkOnElevPath( trk, &oldElev ) ) + if ( !GetTrkOnElevPath( trk, &oldElev ) ) { oldElev = 0.0; + } GetBoundingBox( trk, &hi, &lo ); if ((labelEnable&LABELENABLE_TRACK_ELEV) && - labelScale >= mainD.scale && - (! OFF_MAIND( lo, hi ) ) && - (GetTrkVisible(trk) || drawTunnel!=0/*DRAW_TUNNEL_NONE*/) && - GetLayerVisible(GetTrkLayer(trk)) ) + labelScale >= mainD.scale && + (! OFF_MAIND( lo, hi ) ) && + (GetTrkVisible(trk) || drawTunnel!=0/*DRAW_TUNNEL_NONE*/) && + GetLayerVisible(GetTrkLayer(trk)) ) { redraw = TRUE; - - if ( (GetTrkBits(trk)&TB_ELEVPATH) && (oldElev == elev && oldMode == mode) ) + } + + if ( (GetTrkBits(trk)&TB_ELEVPATH) && (oldElev == elev && oldMode == mode) ) { return; - if ( redraw && (GetTrkBits(trk)&TB_ELEVPATH)) + } + if ( redraw && (GetTrkBits(trk)&TB_ELEVPATH)) { DrawTrackElev( trk, &mainD, FALSE ); + } SetTrkElev( trk, mode, elev ); - if ( redraw ) + if ( redraw ) { DrawTrackElev( trk, &mainD, TRUE ); + } } @@ -1260,40 +1318,45 @@ EXPORT void DrawTrackElev( track_cp trk, drawCmd_p d, BOOL_T drawIt ) coOrd lo, hi; if ( (!IsTrack(trk)) || - (!(labelEnable&LABELENABLE_TRACK_ELEV)) || - (d == &mapD) || - (labelScale < d->scale) || - (!GetTrkOnElevPath( trk, &elev )) || - ((GetTrkBits(trk)&TB_ELEVPATH) == 0) || - (d->options & DC_SIMPLE) != 0 ) + (!(labelEnable&LABELENABLE_TRACK_ELEV)) || + (d == &mapD) || + (labelScale < d->scale) || + (!GetTrkOnElevPath( trk, &elev )) || + ((GetTrkBits(trk)&TB_ELEVPATH) == 0) || + (d->options & DC_SIMPLE) != 0 ) { return; + } - if ( !GetCurveMiddle( trk, &pos ) && !GetCornuMiddle(trk, &pos) && !GetBezierMiddle(trk, &pos)) { + if ( !GetCurveMiddle( trk, &pos ) && !GetCornuMiddle(trk, &pos) + && !GetBezierMiddle(trk, &pos)) { GetBoundingBox( trk, &hi, &lo ); pos.x = (hi.x+lo.x)/2.0; pos.y = (hi.y+lo.y)/2.0; } - if ( d==&mainD && OFF_MAIND( pos, pos ) ) + if ( d==&mainD && OFF_MAIND( pos, pos ) ) { return; + } switch ( GetTrkElevMode(trk) ) { case ELEV_FORK: - color = drawColorBlue; + color = drawColorDkBlue; break; case ELEV_BRANCH: color = drawColorPurple; break; case ELEV_ISLAND: - color = drawColorGold; + color = drawColorDkAqua; break; case ELEV_ALONE: return; } - if ( !drawIt ) + if ( !drawIt ) { color = wDrawColorWhite; + } sprintf( message, "%s", FormatDistance(elev)); fp = wStandardFont( F_HELV, FALSE, FALSE ); - DrawBoxedString( BOX_INVERT, d, pos, message, fp, (wFontSize_t)descriptionFontSize, color, 0 ); + DrawBoxedString( BOX_INVERT, d, pos, message, fp, + (wFontSize_t)descriptionFontSize, color, 0 ); } diff --git a/app/bin/file2uri.c b/app/bin/file2uri.c index dd690cc..86a67cf 100644 --- a/app/bin/file2uri.c +++ b/app/bin/file2uri.c @@ -2,44 +2,44 @@ * Conversion for filename to URI and reverse */ - /* XTrackCAD - Model Railroad CAD - * Copyright (C) 2019 Martin Fischer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - +/* XTrackCAD - Model Railroad CAD + * Copyright (C) 2019 Martin Fischer + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + #include "common.h" static char *reservedChars = "?#[]@!$&'()*+,;= "; -unsigned +unsigned File2URI(char *fileName, unsigned resultLen, char *resultBuffer) { char *currentSource = fileName; - char *currentDest; + char *currentDest; currentDest = resultBuffer; - while (*currentSource && ((unsigned)(currentDest - resultBuffer) < resultLen - 1)) { + while (*currentSource + && ((unsigned)(currentDest - resultBuffer) < resultLen - 1)) { if (*currentSource == FILE_SEP_CHAR[ 0 ]) { *currentDest++ = '/'; currentSource++; continue; } - if (strchr(reservedChars, *currentSource)) - { + if (strchr(reservedChars, *currentSource)) { sprintf(currentDest, "%%%02x", *currentSource); currentSource++; currentDest += 3; @@ -52,14 +52,15 @@ File2URI(char *fileName, unsigned resultLen, char *resultBuffer) return((unsigned)strlen(resultBuffer)); } -unsigned +unsigned URI2File(char *encodedFileName, unsigned resultLen, char *resultBuffer) { char *currentSource = encodedFileName; char *currentDest = resultBuffer; currentSource = encodedFileName; - while (*currentSource && ((unsigned)(currentDest - resultBuffer) < resultLen - 1)) { + while (*currentSource + && ((unsigned)(currentDest - resultBuffer) < resultLen - 1)) { if (*currentSource == '/') { *currentDest++ = FILE_SEP_CHAR[0]; currentSource++; diff --git a/app/bin/file2uri.h b/app/bin/file2uri.h index 921976a..f6700dd 100644 --- a/app/bin/file2uri.h +++ b/app/bin/file2uri.h @@ -2,26 +2,27 @@ * Include file for file2uri.c */ - /* XTrackCAD - Model Railroad CAD - * Copyright (C) 2019 Martin Fischer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */
-
-#ifndef HAVE_FILE2URI_H
-unsigned File2URI(char *fileName, unsigned resultLen, char *resultBuffer);
-unsigned URI2File(char *encodedFileName, unsigned resultLen, char *resultBuffer);
-#endif // !HAVE_FILE2URI_H
-
+/* XTrackCAD - Model Railroad CAD + * Copyright (C) 2019 Martin Fischer + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef HAVE_FILE2URI_H +unsigned File2URI(char *fileName, unsigned resultLen, char *resultBuffer); +unsigned URI2File(char *encodedFileName, unsigned resultLen, + char *resultBuffer); +#endif // !HAVE_FILE2URI_H + diff --git a/app/bin/fileio.c b/app/bin/fileio.c index 0a2e576..4741c05 100644 --- a/app/bin/fileio.c +++ b/app/bin/fileio.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <cJSON.h> @@ -37,11 +37,13 @@ #include "misc.h" #include "param.h" #include "include/paramfile.h" +#include "include/paramfilelist.h" #include "paths.h" #include "track.h" #include "version.h" #include "dynstring.h" #include "common-ui.h" +#include "ctrain.h" #ifdef UTFCONVERT #include "include/utf8convert.h" @@ -54,44 +56,45 @@ EXPORT dynArr_t paramProc_da; EXPORT const char * workingDir; EXPORT const char * libDir; -EXPORT wMenuList_p fileList_ml; - EXPORT char * clipBoardN; static coOrd paste_offset, cursor_offset; EXPORT wBool_t bExample = FALSE; EXPORT wBool_t bReadOnly = FALSE; +EXPORT wBool_t bInReadTracks = FALSE; #ifdef WINDOWS #define rename( F1, F2 ) Copyfile( F1, F2 ) +#endif -static int Copyfile( char * fn1, char * fn2 ) +EXPORT int Copyfile( const char * fn1, const char * fn2 ) { FILE *f1, *f2; size_t size; f1 = fopen( fn1, "r" ); - if ( f1 == NULL ) + if ( f1 == NULL ) { return 0; + } f2 = fopen( fn2, "w" ); if ( f2 == NULL ) { fclose( f1 ); return -1; } - while ( (size=fread( message, 1, sizeof message, f1 )) > 0 ) + while ( (size=fread( message, 1, sizeof message, f1 )) > 0 ) { fwrite( message, size, 1, f2 ); + } fclose( f1 ); fclose( f2 ); return 0; } -#endif // // Locale handling // SetCLocale is called before reading/writing any data files (.xtc, .xti, .xtq, .cus...) // SetUserLocale is called after // Calls can be nested: C, C, User, User -// +// static char * sUserLocale = NULL; // current user locale static long lCLocale = 0; // locale state: > 0 C locale, <= 0 user locale static long nCLocale = 0; // total # of setlocals calls @@ -105,7 +108,10 @@ EXPORT void SetCLocale() } if ( lCLocale == 0 ) { LOG( log_locale, 1, ( "Set C Locale: %ld\n", ++nCLocale ) ); - setlocale( LC_ALL, "C" ); + setlocale( LC_ALL, "C" ); +#ifdef LC_MESSAGES + setlocale( LC_MESSAGES, ""); +#endif } lCLocale++; if ( lCLocale > 1 ) { @@ -151,13 +157,16 @@ EXPORT void Stripcr( char * line ) { char * cp; cp = line + strlen(line); - if (cp == line) + if (cp == line) { return; + } cp--; - if (*cp == '\n') + if (*cp == '\n') { *cp-- = '\0'; - if (cp >= line && *cp == '\r') + } + if (cp >= line && *cp == '\r') { *cp = '\0'; + } } EXPORT char * GetNextLine( void ) @@ -194,16 +203,16 @@ EXPORT char * GetNextLine( void ) */ EXPORT int InputError( - char * msg, - BOOL_T showLine, - ... ) + char * msg, + BOOL_T showLine, + ... ) { va_list ap; char * mp = message; int ret; mp += sprintf( message, "INPUT ERROR: %s:%d\n", - paramFileName, paramLineNum ); + paramFileName, paramLineNum ); va_start( ap, showLine ); mp += vsprintf( mp, msg, ap ); va_end( ap ); @@ -227,12 +236,12 @@ EXPORT int InputError( EXPORT void SyntaxError( - char * event, - wIndex_t actual, - wIndex_t expected ) + char * event, + wIndex_t actual, + wIndex_t expected ) { InputError( "%s scan returned %d (expected %d)", - TRUE, event, actual, expected ); + TRUE, event, actual, expected ); } @@ -264,9 +273,9 @@ EXPORT void SyntaxError( */ EXPORT BOOL_T GetArgs( - char * line, - char * format, - ... ) + char * line, + char * format, + ... ) { char * cp, * cq; long * pl; @@ -279,13 +288,14 @@ EXPORT BOOL_T GetArgs( va_list ap; char * sError = NULL; - if ( lCLocale < 1 ) + if ( lCLocale < 1 ) { LOG( log_locale, 1, ( "GetArgs: not in C locale\n" ) ); + } cp = line; va_start( ap, format ); for ( ; sError==NULL && *format; format++ ) { - while (isspace((unsigned char)*cp)) cp++; + while (isspace((unsigned char)*cp)) { cp++; } if (!*cp && strchr( "XZYzc", *format ) == NULL ) { sError = "EOL unexpected"; break; @@ -336,10 +346,11 @@ EXPORT BOOL_T GetArgs( sError = "%s: expected integer"; break; } - if (*cq == '.') + if (*cq == '.') { *pf = strtod( cp, &cq ); - else + } else { *pf /= mainD.dpi; + } cp = cq; break; case 'u': @@ -391,24 +402,25 @@ EXPORT BOOL_T GetArgs( break; case 's': ps = va_arg( ap, char * ); - while (isspace((unsigned char)*cp)) cp++; - while (*cp && !isspace((unsigned char)*cp)) *ps++ = *cp++; + while (isspace((unsigned char)*cp)) { cp++; } + while (*cp && !isspace((unsigned char)*cp)) { *ps++ = *cp++; } *ps++ = '\0'; break; case 'q': qp = va_arg( ap, char * * ); if (*cp != '\"') /* Stupid windows */ + { cq = strchr( cp, '\"' ); - else + } else { cq = cp; + } if (cq!=NULL) { cp = cq; ps = &message[0]; cp++; while (*cp) { - if ( (ps-message)>=sizeof message) - AbortProg( "Quoted title argument too long" ); + CHECK( (ps-message)<sizeof message ); if (*cp == '\"') { if (*++cp == '\"') { *ps++ = '\"'; @@ -433,14 +445,15 @@ EXPORT BOOL_T GetArgs( break; case 'c': qp = va_arg( ap, char * * ); - while (isspace((unsigned char)*cp)) cp++; - if (*cp) + while (isspace((unsigned char)*cp)) { cp++; } + if (*cp) { *qp = cp; - else + } else { *qp = NULL; + } break; default: - AbortProg( "getArgs: bad format char: %c", *format ); + CHECKMSG( FALSE, ( "getArgs: bad format char: %c", *format ) ); } } va_end( ap ); @@ -458,15 +471,17 @@ wBool_t IsEND( char * sEnd ) char * cp; wBool_t bAllowNakedENDs = paramVersion < VERSION_NONAKEDENDS; for( cp = paramLine; *cp && (isspace( *cp ) || *cp == '\t'); cp++ ); - if ( strncmp( cp, sEnd, strlen(sEnd) ) == 0 ) + if ( strncmp( cp, sEnd, strlen(sEnd) ) == 0 ) { cp += strlen( sEnd ); - else if ( bAllowNakedENDs && strncmp( cp, "END", 3 ) == 0 ) + } else if ( bAllowNakedENDs && strncmp( cp, "END", 3 ) == 0 ) { cp += 3; - else + } else { return FALSE; + } for ( ; *cp && isspace( *cp ); cp++ ); - if ( *cp != '\0' ) + if ( *cp != '\0' ) { return FALSE; + } return TRUE; } @@ -510,8 +525,8 @@ ReadMultilineText() EXPORT wBool_t ParseRoomSize( - char * s, - coOrd * roomSizeRet ) + char * s, + coOrd * roomSizeRet ) { coOrd size; char *cp; @@ -519,7 +534,7 @@ EXPORT wBool_t ParseRoomSize( size.x = strtod( s, &cp ); if (cp != s) { s = cp; - while (isspace((unsigned char)*s)) s++; + while (isspace((unsigned char)*s)) { s++; } if (*s == 'x' || *s == 'X') { size.y = strtod( ++s, &cp ); if (cp != s) { @@ -545,8 +560,8 @@ EXPORT wBool_t ParseRoomSize( * \param [IN] delete if not NULL function for freeing the definition */ EXPORT void AddParam( - char * name, - readParam_t proc) + char * name, + readParam_t proc) { DYNARR_APPEND( paramProc_t, paramProc_da, 10 ); paramProc(paramProc_da.cnt-1).name = name; @@ -576,8 +591,9 @@ EXPORT char * PutTitle( char * cp ) } cp++; } - if ( *cp ) + if ( *cp ) { NoticeMessage( _("putTitle: title too long: %s"), _("Ok"), NULL, title ); + } *tp = '\0'; #ifdef UTFCONVERT @@ -602,15 +618,16 @@ void SetWindowTitle( void ) { char *filename; - if ( changed > 2 || inPlayback ) + if ( changed > 2 || inPlayback ) { return; + } filename = GetLayoutFilename(); sprintf( message, "%s%s%s - %s(%s)", - (filename && filename[0])?filename: _("Unnamed Trackplan"), - bReadOnly?_(" (R/O)"):"", - changed>0?"*":"", - sProdName, sVersion ); + (filename && filename[0])?filename: _("Unnamed Trackplan"), + bReadOnly?_(" (R/O)"):"", + changed>0?"*":"", + sProdName, sVersion ); wWinSetTitle( mainW, message ); } @@ -635,18 +652,18 @@ static char * checkPtFileNameBackup; * \param IN pathName filename including directory * \param IN fileName pointer to filename part in pathName * \param IN full - * \param IN noSetCurDir if FALSE current diurectory is changed to file location + * \param IN noSetCurDir if FALSE current directory is changed to file location * \param IN complain if FALSE error messages are supressed * * \return FALSE in case of load error */ static BOOL_T ReadTrackFile( - const char * pathName, - const char * fileName, - BOOL_T full, - BOOL_T noSetCurDir, - BOOL_T complain ) + const char * pathName, + const char * fileName, + BOOL_T full, + BOOL_T noSetCurDir, + BOOL_T complain ) { int count; coOrd roomSize; @@ -656,11 +673,14 @@ static BOOL_T ReadTrackFile( paramFile = fopen( pathName, "r" ); if (paramFile == NULL) { - if ( complain ) - NoticeMessage( MSG_OPEN_FAIL, _("Continue"), NULL, sProdName, pathName, strerror(errno) ); + if ( complain ) { + NoticeMessage( MSG_OPEN_FAIL, _("Continue"), NULL, sProdName, pathName, + strerror(errno) ); + } return FALSE; } + bInReadTracks = TRUE; SetCLocale(); checkPtFileNameBackup = NULL; paramLineNum = 0; @@ -670,7 +690,8 @@ static BOOL_T ReadTrackFile( count = 0; int skipLines = 0; BOOL_T skip = FALSE; - while ( paramFile && ( fgets(paramLine, sizeof paramLine, paramFile) ) != NULL ) { + while ( paramFile + && ( fgets(paramLine, sizeof paramLine, paramFile) ) != NULL ) { count++; BOOL_T old_skip = skip; skip = FALSE; @@ -680,14 +701,15 @@ static BOOL_T ReadTrackFile( } paramLineNum++; if (strlen(paramLine) == (sizeof paramLine) -1 && - paramLine[(sizeof paramLine)-1] != '\n') { - if( !(ret = InputError( "Line too long", TRUE ))) + paramLine[(sizeof paramLine)-1] != '\n') { + if( !(ret = InputError( "Line too long", TRUE ))) { break; + } } Stripcr( paramLine ); if (paramLine[0] == '#' || - paramLine[0] == '\n' || - paramLine[0] == '\0' ) { + paramLine[0] == '\n' || + paramLine[0] == '\0' ) { /* comment */ continue; } @@ -699,22 +721,26 @@ static BOOL_T ReadTrackFile( } else if (strncmp( paramLine, "VERSION ", 8 ) == 0) { paramVersion = strtol( paramLine+8, &cp, 10 ); if (cp) - while (*cp && isspace((unsigned char)*cp)) cp++; + while (*cp && isspace((unsigned char)*cp)) { cp++; } if ( paramVersion > iParamVersion ) { if (cp && *cp) { - NoticeMessage( MSG_UPGRADE_VERSION1, _("Ok"), NULL, paramVersion, iParamVersion, sProdName, cp ); + NoticeMessage( MSG_UPGRADE_VERSION1, _("Ok"), NULL, paramVersion, iParamVersion, + sProdName, cp ); } else { - NoticeMessage( MSG_UPGRADE_VERSION2, _("Ok"), NULL, paramVersion, iParamVersion, sProdName ); + NoticeMessage( MSG_UPGRADE_VERSION2, _("Ok"), NULL, paramVersion, iParamVersion, + sProdName ); } break; } if ( paramVersion < iMinParamVersion ) { - NoticeMessage( MSG_BAD_FILE_VERSION, _("Ok"), NULL, paramVersion, iMinParamVersion, sProdName ); + NoticeMessage( MSG_BAD_FILE_VERSION, _("Ok"), NULL, paramVersion, + iMinParamVersion, sProdName ); break; } } else if (!full) { - if( !(ret = InputError( "unknown command", TRUE ))) + if( !(ret = InputError( "unknown command", TRUE ))) { break; + } } else if (strncmp( paramLine, "TITLE1 ", 7 ) == 0) { #ifdef UTFCONVERT ConvertUTF8ToSystem(paramLine + 7); @@ -731,24 +757,27 @@ static BOOL_T ReadTrackFile( /*wFloatSetValue( roomSizeXPD.control, PutDim(roomSize.x) );*/ /*wFloatSetValue( roomSizeYPD.control, PutDim(roomSize.y) );*/ } else { - if( !(ret = InputError( "ROOMSIZE: bad value", TRUE ))) + if( !(ret = InputError( "ROOMSIZE: bad value", TRUE ))) { break; + } } } else if (strncmp( paramLine, "SCALE ", 6 ) == 0) { - if ( !DoSetScale( paramLine+5 ) ) { - if( !(ret = InputError( "SCALE: bad value", TRUE ))) + if ( !DoSetScale( paramLine+6 ) ) { + if( !(ret = InputError( "SCALE: bad value", TRUE ))) { break; + } } } else if (strncmp( paramLine, "MAPSCALE ", 9 ) == 0) { scale = atol( paramLine+9 ); if (scale > 1) { - mapD.scale = mapScale = scale; + mapD.scale = scale; } } else if (strncmp( paramLine, "LAYERS ", 7 ) == 0) { ReadLayers( paramLine+7 ); } else { if (!old_skip) { - if (InputError(_("Unknown layout file object - skip until next good object?"), TRUE)) { //OK to carry on + if (InputError(_("Unknown layout file object - skip until next good object?"), + TRUE)) { //OK to carry on /* SKIP until next main line we recognize */ skip = TRUE; skipLines++; @@ -756,56 +785,61 @@ static BOOL_T ReadTrackFile( } else { break; //Close File } - } else skip = TRUE; + } else { skip = TRUE; } skipLines++; } } + bInReadTracks = FALSE; if (paramFile) { fclose(paramFile); paramFile = NULL; } if( ret ) { - if (!noSetCurDir) + if (!noSetCurDir) { SetCurrentPath( LAYOUTPATHKEY, fileName ); + } } - if (skipLines>0) - NoticeMessage( MSG_LAYOUT_LINES_SKIPPED, _("Ok"), NULL, paramFileName, skipLines); + if (skipLines>0) { + NoticeMessage( MSG_LAYOUT_LINES_SKIPPED, _("Ok"), NULL, paramFileName, + skipLines); + } paramFile = NULL; SetUserLocale(); free(paramFileName); - paramFileName = NULL; + paramFileName = NULL; InfoMessage( "%d", count ); return ret; } int LoadTracks( - int cnt, - char **fileName, - void * data) + int cnt, + char **fileName, + void * data) { char *nameOfFile = NULL; char *extOfFile; - assert( fileName != NULL ); - assert( cnt == 1 ); + CHECK( fileName != NULL ); + CHECK( cnt == 1 ); nameOfFile = FindFilename(fileName[0]); // Make sure it exists and it is readable - if (access(fileName[0], R_OK) != 0) - { - NoticeMessage(MSG_OPEN_FAIL, _("Continue"), NULL, _("Track"), nameOfFile, _("Not Found")); + if (access(fileName[0], R_OK) != 0) { + NoticeMessage(MSG_OPEN_FAIL, _("Continue"), NULL, _("Track"), nameOfFile, + _("Not Found")); return FALSE; } - if ( ! bExample ) + if ( ! bExample ) { SetCurrentPath(LAYOUTPATHKEY, fileName[0]); + } bReadOnly = bExample; paramVersion = -1; wSetCursor( mainD.d, wCursorWait ); @@ -813,17 +847,19 @@ int LoadTracks( ClearTracks(); ResetLayers(); checkPtMark = changed = 0; - if (!data) - LayoutBackGroundInit(TRUE); //Keep values of background -> will be overriden by archive + if (!data) { + LayoutBackGroundInit( + TRUE); //Keep values of background -> will be overriden by archive + } UndoSuspend(); useCurrentLayer = FALSE; - /* - * Support zipped filetype - */ + /* + * Support zipped filetype + */ extOfFile = FindFileExtension( nameOfFile); - BOOL_T zipped = FALSE; +// BOOL_T zipped = FALSE; BOOL_T loadXTC = TRUE; char * full_path = strdup(fileName[0]); @@ -847,20 +883,18 @@ int LoadTracks( FILE * f = fopen (manifest_file, "rb"); - if (f) - { - fseek(f, 0, SEEK_END); - length = ftell(f); - fseek(f, 0, SEEK_SET); - manifest = malloc(length + 1); - if (manifest) { - size_t siz = fread(manifest, 1, length, f); - manifest[length] = '\0'; - } - fclose(f); - } else - { - NoticeMessage(MSG_MANIFEST_OPEN_FAIL, _("Continue"), NULL, manifest_file); + if (f) { + fseek(f, 0, SEEK_END); + length = ftell(f); + fseek(f, 0, SEEK_SET); + manifest = malloc(length + 1); + if (manifest) { + fread(manifest, 1, length, f); + manifest[length] = '\0'; + } + fclose(f); + } else { + NoticeMessage(MSG_MANIFEST_OPEN_FAIL, _("Continue"), NULL, manifest_file); } free(manifest_file); @@ -868,56 +902,54 @@ int LoadTracks( //Set filename to point to included .xtc file //Use the name inside manifest (this helps if a user renames the zip) - if (manifest) - { - arch_file = ParseManifest(manifest, zip_input); + if (manifest) { + arch_file = ParseManifest(manifest, zip_input); free(manifest); } free(full_path); full_path = NULL; // If no manifest value use same name as the archive - if (arch_file && arch_file[0]) - { - MakeFullpath(&full_path, zip_input, arch_file, NULL); - } else - { - MakeFullpath(&full_path, zip_input, nameOfFile, NULL); + if (arch_file && arch_file[0]) { + MakeFullpath(&full_path, zip_input, arch_file, NULL); + } else { + MakeFullpath(&full_path, zip_input, nameOfFile, NULL); } nameOfFile = FindFilename(full_path); extOfFile = FindFileExtension(full_path); - if (strcmp(extOfFile, ZIPFILETYPEEXTENSION )==0) - { - for (int i=0; i<4; i++) { - extOfFile[i] = extOfFile[i+1]; - } + if (strcmp(extOfFile, ZIPFILETYPEEXTENSION )==0) { + for (int i=0; i<4; i++) { + extOfFile[i] = extOfFile[i+1]; + } } LOG(log_zip, 1, ("Zip-File %s \n", full_path)) - #if DEBUG - printf("File Path: %s \n", full_path); - #endif +#if DEBUG + printf("File Path: %s \n", full_path); +#endif } else { loadXTC = FALSE; // when unzipping fails, don't attempt loading the trackplan } - zipped = TRUE; +// zipped = TRUE; free(zip_input); } - if ( bExample ) + if ( bExample ) { bReadOnly = TRUE; - else if ( access( fileName[0], W_OK ) == -1 ) + } else if ( access( fileName[0], W_OK ) == -1 ) { bReadOnly = TRUE; - else + } else { bReadOnly = FALSE; + } char *copyOfFileName = MyStrdup(fileName[0]); unsigned long time0 = wGetTimer(); - if (loadXTC && ReadTrackFile( full_path, FindFilename( fileName[0]), TRUE, TRUE, TRUE )) { + if (loadXTC + && ReadTrackFile( full_path, FindFilename( fileName[0]), TRUE, TRUE, TRUE )) { nameOfFile = NULL; extOfFile = NULL; @@ -927,13 +959,15 @@ int LoadTracks( if ( ! bExample && (nameOfFile != NULL) ) { char * copyFile = strdup(fileName[0]); - char * listName = FindFilename(strdup(fileName[0])); //Make sure the list name is new + char * listName = FindFilename(strdup( + fileName[0])); //Make sure the list name is new wMenuListAdd( fileList_ml, 0, listName, copyFile ); } ResolveIndex(); - LOG( log_timereadfile, 1, ( "Read time (%s) = %lu mS \n", fileName[0], wGetTimer()-time0 ) ); + LOG( log_timereadfile, 1, ( "Read time (%s) = %lu mS \n", fileName[0], + wGetTimer()-time0 ) ); RecomputeElevations(NULL); AttachTrains(); DoChangeNotification( CHANGE_ALL ); @@ -962,20 +996,21 @@ int LoadTracks( */ EXPORT void DoFileList( - int index, - char * label, - void * data ) + int index, + char * label, + void * data ) { char *pathName = (char*)data; bExample = FALSE; - if (label) + if (label) { LoadTracks( 1, &pathName, I2VP(1)); - else + } else { LoadTracks( 1, &pathName, NULL ); + } } static BOOL_T DoSaveTracks( - const char * fileName ) + const char * fileName ) { FILE * f; time_t clock; @@ -984,13 +1019,15 @@ static BOOL_T DoSaveTracks( f = fopen( fileName, "w" ); if (f==NULL) { - NoticeMessage( MSG_OPEN_FAIL, _("Continue"), NULL, _("Track"), fileName, strerror(errno) ); + NoticeMessage( MSG_OPEN_FAIL, _("Continue"), NULL, _("Track"), fileName, + strerror(errno) ); return FALSE; } SetCLocale(); wSetCursor( mainD.d, wCursorWait ); time(&clock); - rc &= fprintf(f,"#%s Version: %s, Date: %s\n", sProdName, sVersion, ctime(&clock) )>0; + rc &= fprintf(f,"#%s Version: %s, Date: %s\n", sProdName, sVersion, + ctime(&clock) )>0; rc &= fprintf(f, "VERSION %d %s\n", iParamVersion, PARAMVERSIONVERSION )>0; Stripcr( GetLayoutTitle() ); Stripcr( GetLayoutSubtitle() ); @@ -1003,8 +1040,9 @@ static BOOL_T DoSaveTracks( rc &= WriteMainNote( f ); rc &= WriteTracks( f, TRUE ); rc &= fprintf(f, "%s\n", END_TRK_FILE)>0; - if ( !rc ) + if ( !rc ) { NoticeMessage( MSG_WRITE_FAILURE, _("Ok"), NULL, strerror(errno), fileName ); + } fclose(f); bReadOnly = FALSE; @@ -1025,74 +1063,83 @@ static BOOL_T DoSaveTracks( */ static BOOL_T CopyDependency(char * name, char * target_dir) { - char * backname = FindFilename(name); + char * backname = FindFilename(name); BOOL_T copied = TRUE; FILE * source = fopen(name, "rb"); - if (source != NULL) { - char * target_file; - MakeFullpath(&target_file, target_dir, backname, NULL); - FILE * target = fopen(target_file, "wb"); - - if (target != NULL) { - char *buffer = MyMalloc(COPYBLOCKSIZE); - while (!feof(source)) { - size_t bytes = fread(buffer, 1, sizeof(buffer), source); - if (bytes) { - fwrite(buffer, 1, bytes, target); - } - } + if (source != NULL) { + char * target_file; + MakeFullpath(&target_file, target_dir, backname, NULL); + FILE * target = fopen(target_file, "wb"); + + if (target != NULL) { + char *buffer = MyMalloc(COPYBLOCKSIZE); + while (!feof(source)) { + size_t bytes = fread(buffer, 1, sizeof(buffer), source); + if (bytes) { + fwrite(buffer, 1, bytes, target); + } + } MyFree(buffer); - LOG(log_zip, 1, ("Zip-Include %s into %s \n", name, target_file)) + LOG(log_zip, 1, ("Zip-Include %s into %s \n", name, target_file)) #if DEBUG - printf("xtrkcad: Included file %s into %s \n", - name, target_file); + printf("xtrkcad: Included file %s into %s \n", + name, target_file); #endif - fclose(target); - } else { - NoticeMessage(MSG_COPY_FAIL, _("Continue"), NULL, name, target_file); - copied = FALSE; - } - free(target_file); - fclose(source); - } else { - NoticeMessage(MSG_COPY_OPEN_FAIL, _("Continue"), NULL, name); - copied = FALSE; - } - return copied; + fclose(target); + } else { + NoticeMessage(MSG_COPY_FAIL, _("Continue"), NULL, name, target_file); + copied = FALSE; + } + free(target_file); + fclose(source); + } else { + NoticeMessage(MSG_COPY_OPEN_FAIL, _("Continue"), NULL, name); + copied = FALSE; + } + return copied; } static doSaveCallBack_p doAfterSave; - +/** + * Save the layout to file. This function handles either cases, classic xtc + * files as well as xtce zip archives. + * + * \param cnt Number of files, must be 1 + * \param fileName name of destination file including extension (xtc or xtce) + * \param data unused + * + * \returns TRUE for success + */ static int SaveTracks( - int cnt, - char **fileName, - void * data ) + int cnt, + char** fileName, + void* data) { + BOOL_T success = FALSE; - assert( fileName != NULL ); - assert( cnt == 1 ); + CHECK(fileName != NULL); + CHECK(cnt == 1); - char *nameOfFile = FindFilename(fileName[0]); + char* nameOfFile = FindFilename(fileName[0]); SetCurrentPath(LAYOUTPATHKEY, fileName[0]); //Support Archive zipped files - char * extOfFile = FindFileExtension( fileName[0]); - + char* extOfFile = FindFileExtension(fileName[0]); - if (extOfFile && (strcmp(extOfFile,ZIPFILETYPEEXTENSION)==0)) { + if (extOfFile && (strcmp(extOfFile, ZIPFILETYPEEXTENSION) == 0)) { - char * ArchiveName; + char* ArchiveName; //Set filename to point to be the same as the included .xtc file. //This is also in the manifest - in case a user renames the archive file. - char * zip_output = GetZipDirectoryName(ARCHIVE_WRITE); + char* zip_output = GetZipDirectoryName(ARCHIVE_WRITE); DeleteDirectory(zip_output); SafeCreateDir(zip_output); @@ -1102,75 +1149,125 @@ static int SaveTracks( nameOfFile = FindFilename(ArchiveName); extOfFile = FindFileExtension(ArchiveName); - if (extOfFile && strcmp(extOfFile, ZIPFILETYPEEXTENSION)==0) { + if (extOfFile && strcmp(extOfFile, ZIPFILETYPEEXTENSION) == 0) { // Get rid of the 'e' extOfFile[3] = '\0'; } - char * DependencyDir; + char* DependencyDir; - //The included files are placed (for now) into an includes directory - TODO an array of includes with directories by type + // The included files are placed (for now) into an includes directory - + // TODO an array of includes with directories by type MakeFullpath(&DependencyDir, zip_output, "includes", NULL); SafeCreateDir(DependencyDir); - char * background = GetLayoutBackGroundFullPath(); + char* background = GetLayoutBackGroundFullPath(); - if (background && background[0]) - CopyDependency(background,DependencyDir); + // if used, get the background file + // else ignore this step + if (background && background[0]) { + success = CopyDependency(background, DependencyDir); + } else { + background = NULL; + success = TRUE; + } - //The details are stored into the manifest - TODO use arrays for files, locations - SetCLocale(); - char* json_Manifest = CreateManifest(nameOfFile, background, "includes"); - char * manifest_file; + if (success) { + //The details are stored into the manifest - TODO use arrays for files, locations + SetCLocale(); + char* json_Manifest = CreateManifest(nameOfFile, background, "includes"); + char* manifest_file; - MakeFullpath(&manifest_file, zip_output, "manifest.json", NULL); + MakeFullpath(&manifest_file, zip_output, "manifest.json", NULL); - FILE *fp = fopen(manifest_file, "wb"); - if (fp != NULL) - { - fputs(json_Manifest, fp); - fclose(fp); - } else { - NoticeMessage( MSG_MANIFEST_FAIL, _("Continue"), NULL, manifest_file ); - } - SetUserLocale(); + FILE* fp = fopen(manifest_file, "wb"); + if (fp != NULL) { + fputs(json_Manifest, fp); + fclose(fp); + } else { + NoticeMessage(MSG_MANIFEST_FAIL, _("Continue"), NULL, manifest_file); + success = FALSE; + } + SetUserLocale(); - free(manifest_file); - free(json_Manifest); + free(manifest_file); + free(json_Manifest); + } - DoSaveTracks( ArchiveName ); + success &= DoSaveTracks(ArchiveName); - if (CreateArchive( zip_output, fileName[0]) != TRUE) { - NoticeMessage( MSG_ARCHIVE_FAIL, _("Continue"), NULL, fileName[0], zip_output ); + if (success) { + if (CreateArchive(zip_output, fileName[0]) != TRUE) { + NoticeMessage(MSG_ARCHIVE_FAIL, _("Continue"), NULL, fileName[0], zip_output); + } } + free(zip_output); free(ArchiveName); - } else + } else { + success = DoSaveTracks(fileName[0]); + } - DoSaveTracks( fileName[ 0 ] ); + if (success) { + nameOfFile = FindFilename(fileName[0]); + wMenuListAdd(fileList_ml, 0, nameOfFile, MyStrdup(fileName[0])); + checkPtMark = changed = 0; - nameOfFile = FindFilename( fileName[ 0 ] ); - wMenuListAdd( fileList_ml, 0, nameOfFile, MyStrdup(fileName[ 0 ]) ); - checkPtMark = changed = 0; - - SetLayoutFullPath(fileName[0]); + SetLayoutFullPath(fileName[0]); + } - if (doAfterSave) + if (doAfterSave) { doAfterSave(); - doAfterSave = NULL; - return TRUE; + } + return success; } -EXPORT void SetAutoSave() { +/** + * Save information about current files and some settings to preferences file. + */ + +EXPORT void SaveState(void) +{ + wWinPix_t width, height; + const char * fileName; + void * pathName; + char file[6]; + int inx; + + wWinGetSize(mainW, &width, &height); + wPrefSetInteger("draw", "mainwidth", (int)width); + wPrefSetInteger("draw", "mainheight", (int)height); + SaveParamFileList(); + ParamUpdatePrefs(); + + wPrefSetString( "misc", "lastlayout", GetLayoutFullPath()); + wPrefSetInteger( "misc", "lastlayoutexample", bExample ); + + if (fileList_ml) { + strcpy(file, "file"); + file[5] = 0; + for (inx = 0; inx < NUM_FILELIST; inx++) { + fileName = wMenuListGet(fileList_ml, inx, &pathName); + if (fileName) { + file[4] = '0' + inx; + sprintf(message, "%s", (char* )pathName); + wPrefSetString("filelist", file, message); + } + } + } + wPrefFlush(""); +} +static void SetAutoSave() +{ if (saveFile_fs == NULL) saveFile_fs = wFilSelCreate( mainW, FS_SAVE, 0, _("AutoSave Tracks As"), - sSourceFilePattern, SaveTracks, NULL ); + sSourceFilePattern, SaveTracks, NULL ); wFilSelect( saveFile_fs, GetCurrentPath(LAYOUTPATHKEY)); checkPtMark = 1; SetWindowTitle(); - CleanupFiles(); //Remove old checkpoint + CleanupCheckpointFiles(); //Remove old checkpoint SaveState(); } @@ -1181,7 +1278,7 @@ EXPORT void DoSave( void * doAfterSaveVP ) if ( bReadOnly || *(GetLayoutFilename()) == '\0') { if (saveFile_fs == NULL) saveFile_fs = wFilSelCreate( mainW, FS_SAVE, 0, _("Save Tracks"), - sSourceFilePattern, SaveTracks, NULL ); + sSourceFilePattern, SaveTracks, NULL ); wFilSelect( saveFile_fs, GetCurrentPath(LAYOUTPATHKEY)); checkPtMark = 1; } else { @@ -1189,7 +1286,7 @@ EXPORT void DoSave( void * doAfterSaveVP ) SaveTracks( 1, &temp, NULL ); } SetWindowTitle(); - CleanupFiles(); //Remove old checkpoint + CleanupCheckpointFiles(); //Remove old checkpoint SaveState(); } @@ -1198,11 +1295,11 @@ EXPORT void DoSaveAs( void * doAfterSaveVP ) doAfterSave = doAfterSaveVP; if (saveFile_fs == NULL) saveFile_fs = wFilSelCreate( mainW, FS_SAVE, 0, _("Save Tracks As"), - sSaveFilePattern, SaveTracks, NULL ); + sSaveFilePattern, SaveTracks, NULL ); wFilSelect( saveFile_fs, GetCurrentPath(LAYOUTPATHKEY)); checkPtMark = 1; SetWindowTitle(); - CleanupFiles(); //Remove old checkpoint + CleanupCheckpointFiles(); //Remove old checkpoint SaveState(); } @@ -1210,12 +1307,12 @@ EXPORT void DoLoad( void ) { if (loadFile_fs == NULL) loadFile_fs = wFilSelCreate( mainW, FS_LOAD, 0, _("Open Tracks"), - sSourceFilePattern, LoadTracks, NULL ); + sSourceFilePattern, LoadTracks, NULL ); bExample = FALSE; wFilSelect( loadFile_fs, GetCurrentPath(LAYOUTPATHKEY)); paste_offset = zero; cursor_offset = zero; - CleanupFiles(); //Remove old checkpoint + CleanupCheckpointFiles(); //Remove old checkpoint SaveState(); } @@ -1223,14 +1320,13 @@ EXPORT void DoLoad( void ) EXPORT void DoExamples( void ) { if (examplesFile_fs == NULL) { - static wBool_t bExample = TRUE; examplesFile_fs = wFilSelCreate( mainW, FS_LOAD, 0, _("Example Tracks"), - sSourceFilePattern, LoadTracks, NULL ); + sSourceFilePattern, LoadTracks, NULL ); } bExample = TRUE; sprintf( message, "%s" FILE_SEP_CHAR "examples" FILE_SEP_CHAR, libDir ); wFilSelect( examplesFile_fs, message ); - CleanupFiles(); //Remove old checkpoint + CleanupCheckpointFiles(); //Remove old checkpoint SaveState(); } @@ -1239,7 +1335,7 @@ wIndex_t max_generations_count = 10; static char sCheckPointBF[STR_LONG_SIZE]; -EXPORT void DoCheckPoint( void ) +static void DoCheckPoint( void ) { int rc; @@ -1279,6 +1375,35 @@ EXPORT void DoCheckPoint( void ) wShow( mainW ); } + +static wIndex_t autosave_count = 0; +EXPORT wIndex_t checkPtMark = 0; +EXPORT long checkPtInterval = 10; +EXPORT long autosaveChkPoints = 0; + +EXPORT void TryCheckPoint() +{ + if (checkPtInterval > 0 + && changed >= checkPtMark + (wIndex_t) checkPtInterval + && !inPlayback) { + DoCheckPoint(); + checkPtMark = changed; + + autosave_count++; + + if ((autosaveChkPoints>0) && (autosave_count>=autosaveChkPoints)) { + if ( bReadOnly || *(GetLayoutFilename()) == '\0') { + SetAutoSave(); + } else { + DoSave(NULL); + } + InfoMessage(_("File AutoSaved")); + autosave_count = 0; + } + } +} + + /** * Remove all temporary files before exiting. When the program terminates * normally through the exit choice, files and directories that were created @@ -1289,10 +1414,8 @@ EXPORT void DoCheckPoint( void ) * */ -EXPORT void CleanupFiles( void ) +EXPORT void CleanupCheckpointFiles( void ) { - char *tempDir; - if( checkPtFileName1 ) { if (checkPtFileNameBackup) { remove( checkPtFileNameBackup ); @@ -1301,6 +1424,22 @@ EXPORT void CleanupFiles( void ) remove( checkPtFileName1 ); } +} + +/** + * Remove all temporary files used for archive handling. When the program terminates + * normally through the exit choice, files and directories that were created + * temporarily are removed: zip_in.<pid> and zip_out.<pid> + * + * \param none + * \return none + * + */ + +EXPORT void CleanupTempArchive(void) +{ + char* tempDir; + for (int i = ARCHIVE_READ; i <= ARCHIVE_WRITE; ++i) { tempDir = GetZipDirectoryName(i); if (tempDir) { @@ -1352,7 +1491,8 @@ EXPORT int LoadCheckpoint( BOOL_T sameName ) MakeFullpath(&search, workingDir, sCheckPointF, NULL); UndoSuspend(); - if (ReadTrackFile( search, search + strlen(search) - strlen( sCheckPointF ), TRUE, TRUE, TRUE )) { + if (ReadTrackFile( search, search + strlen(search) - strlen( sCheckPointF ), + TRUE, TRUE, TRUE )) { ResolveIndex(); LayoutBackGroundInit(FALSE); //Get Prior BackGround LayoutBackGroundSave(); //Save Background Values @@ -1366,14 +1506,14 @@ EXPORT int LoadCheckpoint( BOOL_T sameName ) SetCurrentPath( LAYOUTPATHKEY, initialFile ); SetLayoutFullPath(initialFile); } - } else SetLayoutFullPath(""); + } else { SetLayoutFullPath(""); } RecomputeElevations(NULL); AttachTrains(); DoChangeNotification( CHANGE_ALL ); DoUpdateTitles(); - } else SetLayoutFullPath(""); + } else { SetLayoutFullPath(""); } LayerSetCounts(); UpdateLayerDlg(curLayer); @@ -1410,15 +1550,15 @@ static int importAsModule; */ static int ImportTracks( - int cnt, - char **fileName, - void * data ) + int cnt, + char **fileName, + void * data ) { char *nameOfFile; long paramVersionOld = paramVersion; - assert( fileName != NULL ); - assert( cnt == 1 ); + CHECK( fileName != NULL ); + CHECK( cnt == 1 ); nameOfFile = FindFilename(fileName[ 0 ]); paramVersion = -1; @@ -1426,14 +1566,14 @@ static int ImportTracks( Reset(); SetAllTrackSelect( FALSE ); int saveLayer = curLayer; - int layer; + int layer = 0; if (importAsModule) { layer = FindUnusedLayer(0); - if (layer==-1) return FALSE; + if (layer==-1) { return FALSE; } char LayerName[80]; LayerName[0] = '\0'; sprintf(LayerName,_("Module - %s"),nameOfFile); - if (layer>=0) SetCurrLayer(layer, NULL, 0, NULL, NULL); + if (layer>=0) { SetCurrLayer(layer, NULL, 0, NULL, NULL); } SetLayerName(layer,LayerName); } ImportStart(); @@ -1441,7 +1581,7 @@ static int ImportTracks( useCurrentLayer = TRUE; ReadTrackFile( fileName[ 0 ], nameOfFile, FALSE, FALSE, TRUE ); ImportEnd(zero, TRUE, FALSE); - if (importAsModule) SetLayerModule(layer,TRUE); + if (importAsModule) { SetLayerModule(layer,TRUE); } useCurrentLayer = FALSE; SetCurrLayer(saveLayer, NULL, 0, NULL, NULL); /*DoRedraw();*/ @@ -1457,8 +1597,9 @@ EXPORT void DoImport( void * type ) { importAsModule = (int)VP2L(type); if (importFile_fs == NULL) - importFile_fs = wFilSelCreate( mainW, FS_LOAD, 0, _("Import Tracks"), - sImportFilePattern, ImportTracks, NULL ); + importFile_fs = wFilSelCreate( mainW, FS_LOAD, 0, + type == 0 ? _("Import Tracks") : _("Import Module"), + sImportFilePattern, ImportTracks, NULL ); wFilSelect( importFile_fs, GetCurrentPath(LAYOUTPATHKEY)); } @@ -1474,20 +1615,21 @@ EXPORT void DoImport( void * type ) */ static int DoExportTracks( - int cnt, - char **fileName, - void * data ) + int cnt, + char **fileName, + void * data ) { FILE * f; time_t clock; - assert( fileName != NULL ); - assert( cnt == 1 ); + CHECK( fileName != NULL ); + CHECK( cnt == 1 ); SetCurrentPath( IMPORTPATHKEY, fileName[ 0 ] ); f = fopen( fileName[ 0 ], "w" ); if (f==NULL) { - NoticeMessage( MSG_OPEN_FAIL, _("Continue"), NULL, _("Export"), fileName[0], strerror(errno) ); + NoticeMessage( MSG_OPEN_FAIL, _("Continue"), NULL, _("Export"), fileName[0], + strerror(errno) ); return FALSE; } @@ -1498,7 +1640,7 @@ static int DoExportTracks( fprintf(f,"#%s Version: %s, Date: %s\n", sProdName, sVersion, ctime(&clock) ); fprintf(f, "VERSION %d %s\n", iParamVersion, PARAMVERSIONVERSION ); coOrd offset; - ExportTracks( f , &offset); + ExportTracks( f, &offset ); fprintf(f, "%s\n", END_TRK_FILE); fclose(f); @@ -1513,13 +1655,9 @@ static int DoExportTracks( EXPORT void DoExport( void * unused ) { - if (selectedTrackCount <= 0) { - ErrorMessage( MSG_NO_SELECTED_TRK ); - return; - } if (exportFile_fs == NULL) exportFile_fs = wFilSelCreate( mainW, FS_SAVE, 0, _("Export Tracks"), - sImportFilePattern, DoExportTracks, NULL ); + sImportFilePattern, DoExportTracks, NULL ); wFilSelect( exportFile_fs, GetCurrentPath(LAYOUTPATHKEY)); } @@ -1539,7 +1677,8 @@ EXPORT void EditCopy( void * unused ) } f = fopen( clipBoardN, "w" ); if (f == NULL) { - NoticeMessage( MSG_OPEN_FAIL, _("Continue"), NULL, _("Clipboard"), clipBoardN, strerror(errno) ); + NoticeMessage( MSG_OPEN_FAIL, _("Continue"), NULL, _("Clipboard"), clipBoardN, + strerror(errno) ); return; } @@ -1548,7 +1687,7 @@ EXPORT void EditCopy( void * unused ) time(&clock); fprintf(f,"#%s Version: %s, Date: %s\n", sProdName, sVersion, ctime(&clock) ); fprintf(f, "VERSION %d %s\n", iParamVersion, PARAMVERSIONVERSION ); - ExportTracks(f, &paste_offset); + ExportTracks(f, &paste_offset ); fprintf(f, "%s\n", END_TRK_FILE ); SetUserLocale(); fclose(f); @@ -1560,7 +1699,7 @@ EXPORT void EditCopy( void * unused ) EXPORT void EditCut( void * unused ) { EditCopy(NULL); - if ( !editStatus ) return; + if ( !editStatus ) { return; } SelectDelete(); } @@ -1594,10 +1733,11 @@ static BOOL_T EditPastePlace( wBool_t inPlace ) NoticeMessage( MSG_CANT_PASTE, _("Continue"), NULL ); rc = FALSE; } - if (inPlace) + if (inPlace) { ImportEnd(paste_offset, FALSE, TRUE); - else + } else { ImportEnd(zero, FALSE, FALSE); + } useCurrentLayer = FALSE; /*DoRedraw();*/ EnableCommands(); @@ -1609,13 +1749,15 @@ static BOOL_T EditPastePlace( wBool_t inPlace ) return rc; } -EXPORT void EditPaste( void * unused ) { +EXPORT void EditPaste( void * unused ) +{ editStatus = EditPastePlace(FALSE); } -EXPORT void EditClone( void * unused ) { +EXPORT void EditClone( void * unused ) +{ EditCopy( NULL ); - if ( !editStatus ) return; + if ( !editStatus ) { return; } editStatus = EditPastePlace(TRUE); } @@ -1625,16 +1767,39 @@ EXPORT void EditClone( void * unused ) { * */ -EXPORT void FileInit( void ) + +EXPORT void LoadFileList(void) { - if ( (libDir = wGetAppLibDir()) == NULL ) { - abort(); + char file[6]; + int inx; + const char * cp; + const char *fileName, *pathName; + strcpy(file, "fileX"); + for (inx = NUM_FILELIST - 1; inx >= 0; inx--) { + file[4] = '0' + inx; + cp = wPrefGetString("filelist", file); + if (!cp) { + continue; + } + pathName = MyStrdup(cp); + fileName = FindFilename((char *) pathName); + if (fileName) { + wMenuListAdd(fileList_ml, 0, fileName, pathName); + } } - if ( (workingDir = wGetAppWorkDir()) == NULL ) - AbortProg( "wGetAppWorkDir()" ); +} + + + +EXPORT void FileInit( void ) +{ + libDir = wGetAppLibDir(); + CHECK( libDir ); + workingDir = wGetAppWorkDir(); + CHECK( workingDir ); SetLayoutFullPath(""); - MakeFullpath(&clipBoardN, workingDir, sClipboardF, NULL); + MakeFullpath(&clipBoardN, workingDir, sClipboardF, NULL); log_locale = LogFindIndex( "locale" ); log_timereadfile = LogFindIndex( "timereadfile" ); diff --git a/app/bin/fileio.h b/app/bin/fileio.h index a037063..0ea80af 100644 --- a/app/bin/fileio.h +++ b/app/bin/fileio.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef FILEIO_H @@ -42,6 +42,9 @@ extern const char * libDir; extern wBool_t bReadOnly; extern wBool_t bExample; +// Processing an input file, objects may be incomplete so avoid some ops (MapRedraw) +extern wBool_t bInReadTracks; + #define PARAM_CUSTOM (-2) #define PARAM_LAYOUT (-3) extern int curParamFileIndex; @@ -56,8 +59,6 @@ extern wBool_t inPlaybackQuit; extern wWin_p demoW; extern int curDemo; -extern wMenuList_p fileList_ml; - #define ZIPFILETYPEEXTENSION "xtce" #define PARAM_SUBDIR "params" @@ -96,7 +97,7 @@ BOOL_T GetArgs( char *, char *, ... ); char * ReadMultilineText(); BOOL_T ParseRoomSize( char *, coOrd * ); int InputError( char *, BOOL_T, ... ); -void SyntaxError( char *, wIndex_t, wIndex_t ); +void SyntaxError( char *, wIndex_t, wIndex_t ); void AddParam( char *name, readParam_t proc ); @@ -110,21 +111,23 @@ void DoParamFiles(void * unused); int LoadTracks( int cnt, char **fileName, void *data ); -typedef void (*doSaveCallBack_p)( void ); -void SetAutoSave(void); +void SaveState( void ); void DoSave( void * doAfterSaveVP ); void DoSaveAs( void * doAfterSaveVP ); void DoLoad( void ); void DoExamples( void ); void DoFileList( int, char *, void * ); -void DoCheckPoint( void ); -void CleanupFiles( void ); +void TryCheckPoint( void ); +void CleanupCheckpointFiles( void ); +void CleanupTempArchive( void ); int ExistsCheckpoint( void ); int LoadCheckpoint( BOOL_T ); void DoImport( void * typeVP ); void DoExport( void * unused ); void DoExportDXF( void * unused ); -void DoExportSVG(void); +#if XTRKCAD_CREATE_SVG +void DoExportSVG( void * unused ); +#endif extern wBool_t editStatus; // Status of last Edit* command void EditCopy( void * unused ); void EditCut( void * unused ); @@ -143,10 +146,12 @@ int RegLevel( void ); void ReadKey( void ); void PopupRegister( void * ); +void LoadFileList( void ); void FileInit( void ); BOOL_T MacroInit( void ); +int Copyfile( const char * fn1, const char * fn2); void SetCLocale(); void SetUserLocale(); diff --git a/app/bin/filenoteui.c b/app/bin/filenoteui.c index 2470836..9b1c2d5 100644 --- a/app/bin/filenoteui.c +++ b/app/bin/filenoteui.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "custom.h" @@ -30,33 +30,42 @@ #include "include/stringxtc.h" #include "track.h" -extern BOOL_T inDescribeCmd; - #define MYMIN(x, y) (((x) < (y)) ? (x) : (y)) #define DOCUMENTFILEPATTERN "All Files (*.*)|*.*" #define DOCUMENTPATHKEY "document" -static struct extraDataNote_t noteDataInUI; +struct { + coOrd pos; + int layer; + track_p trk; + char title[TITLEMAXIMUMLENGTH]; + char path[PATHMAXIMUMLENGTH]; +} fileNoteData; + static struct wFilSel_t * documentFile_fs; static void NoteFileOpenExternal(void * junk); static void NoteFileBrowse(void * junk); +static void FileDlgUpdate( + paramGroup_p pg, + int inx, + void * valueP); -static paramFloatRange_t r_1000_1000 = { -1000.0, 1000.0, 80 }; +static paramFloatRange_t noRangeCheck = { 0.0, 0.0, 80, PDO_NORANGECHECK_HIGH | PDO_NORANGECHECK_LOW }; // static char *toggleLabels[] = { N_("Copy to archive"), NULL }; -static paramData_t fileEditPLs[] = { +static paramData_t fileNotePLs[] = { #define I_ORIGX (0) - /*0*/ { PD_FLOAT, ¬eDataInUI.pos.x, "origx", PDO_DIM, &r_1000_1000, N_("Position X") }, + /*0*/ { PD_FLOAT, &fileNoteData.pos.x, "origx", PDO_DIM|PDO_NOPREF, &noRangeCheck, N_("Position X") }, #define I_ORIGY (1) - /*1*/ { PD_FLOAT, ¬eDataInUI.pos.y, "origy", PDO_DIM, &r_1000_1000, N_("Position Y") }, + /*1*/ { PD_FLOAT, &fileNoteData.pos.y, "origy", PDO_DIM|PDO_NOPREF, &noRangeCheck, N_("Position Y") }, #define I_LAYER (2) - /*2*/ { PD_DROPLIST, ¬eDataInUI.layer, "layer", 0, I2VP(150), "Layer", 0 }, + /*2*/ { PD_DROPLIST, &fileNoteData.layer, "layer", PDO_NOPREF, I2VP(150), "Layer", 0 }, #define I_TITLE (3) - /*3*/ { PD_STRING, NULL, "title", PDO_NOPREF | PDO_STRINGLIMITLENGTH, I2VP(200), N_("Title"), 0, 0, TITLEMAXIMUMLENGTH-1 }, + /*3*/ { PD_STRING, &fileNoteData.title, "title", PDO_NOPREF | PDO_NOTBLANK, I2VP(200), N_("Title"), 0, 0, sizeof fileNoteData.title }, #define I_PATH (4) - { PD_STRING, NULL, "filename", PDO_NOPSHUPD, I2VP(200), N_("Document"), BO_READONLY, I2VP(0L), PATHMAXIMUMLENGTH-1 }, + { PD_STRING, &fileNoteData.path, "filename", PDO_NOPREF | PDO_NOTBLANK, I2VP(200), N_("Document"), BO_READONLY, I2VP(0L), sizeof fileNoteData.path }, #define I_BROWSE (5) { PD_BUTTON, NoteFileBrowse, "browse", 0L, NULL, N_("Select...") }, #define I_OPEN (6) @@ -66,12 +75,12 @@ static paramData_t fileEditPLs[] = { }; -static paramGroup_t fileEditPG = { "fileEdit", 0, fileEditPLs, COUNT( fileEditPLs ) }; -static wWin_p fileEditW; +static paramGroup_t fileNotePG = { "fileNote", 0, fileNotePLs, COUNT( fileNotePLs ) }; +static wWin_p fileNoteW; BOOL_T IsFileNote(track_p trk) { - struct extraDataNote_t * xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); + struct extraDataNote_t * xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); return(xx->op == OP_NOTEFILE ); } @@ -84,13 +93,13 @@ BOOL_T IsFileNote(track_p trk) BOOL_T IsFileValid(char *fileName) { if (!strlen(fileName)) { - return(FALSE); + return(FALSE); } else { if (access(fileName, F_OK) == -1) { return(FALSE); } } - + return(TRUE); } @@ -103,50 +112,52 @@ BOOL_T IsFileValid(char *fileName) * \return always 0 */ int LoadDocumentFile( - int files, - char ** fileName, - void * data) + int files, + char ** fileName, + void * data) { - wControlActive(fileEditPLs[I_OPEN].control, TRUE); - ParamDialogOkActive(&fileEditPG, TRUE); - strscpy(noteDataInUI.noteData.fileData.path, *fileName, PATHMAXIMUMLENGTH ); - ParamLoadControl(&fileEditPG, I_PATH); + wControlActive(fileNotePLs[I_OPEN].control, TRUE); + ParamDialogOkActive(&fileNotePG, TRUE); + strscpy(fileNoteData.path, *fileName, PATHMAXIMUMLENGTH ); + ParamLoadControl(&fileNotePG, I_PATH); return(0); } /** * Select the file to attach - * + * * \param junk unused */ static void NoteFileBrowse(void * junk) { - documentFile_fs = wFilSelCreate(mainW, FS_LOAD, 0, _("Add Document"), DOCUMENTFILEPATTERN, LoadDocumentFile, NULL); + documentFile_fs = wFilSelCreate(mainW, FS_LOAD, 0, _("Add Document"), + DOCUMENTFILEPATTERN, LoadDocumentFile, NULL); wFilSelect(documentFile_fs, GetCurrentPath(DOCUMENTPATHKEY)); - wControlActive(fileEditPLs[I_OPEN].control, - (strlen(noteDataInUI.noteData.fileData.path) ? TRUE : FALSE)); - + wControlActive(fileNotePLs[I_OPEN].control, + (strlen(fileNoteData.path) ? TRUE : FALSE)); + FileDlgUpdate( &fileNotePG, I_PATH, NULL ); return; } /** * Open the file using an external program. Before opening the file existance and permissions are checked. * If access is not allowed the Open Button is disabled - * + * * \param fileName IN file */ - + static void NoteFileOpen(char *fileName) { if (IsFileValid(fileName)) { wOpenFileExternal(fileName); } else { - wNoticeEx(NT_ERROR, _("The file doesn't exist or cannot be read!"), _("Cancel"), NULL); - if (fileEditW) { - wControlActive(fileEditPLs[I_OPEN].control, FALSE); + wNoticeEx(NT_ERROR, _("The file doesn't exist or cannot be read!"), _("Cancel"), + NULL); + if (fileNoteW) { + wControlActive(fileNotePLs[I_OPEN].control, FALSE); } } } @@ -154,50 +165,47 @@ static void NoteFileOpen(char *fileName) static void NoteFileOpenExternal(void * junk) { - NoteFileOpen(noteDataInUI.noteData.fileData.path); + NoteFileOpen(fileNoteData.path); } /** * Handle the dialog actions */ static void FileDlgUpdate( - paramGroup_p pg, - int inx, - void * valueP) + paramGroup_p pg, + int inx, + void * valueP) { - switch (inx) { + switch (inx) { case I_ORIGX: case I_ORIGY: - UpdateFile(¬eDataInUI, OR_NOTE, FALSE); + // TODO: redraw bitmap at new location + //UpdateFile(¬eDataInUI, OR_NOTE, FALSE); break; - case I_LAYER: - UpdateFile(¬eDataInUI, LY_NOTE, FALSE); + case I_PATH: + if (!IsFileValid(fileNoteData.path)) { + paramData_p p = &fileNotePLs[I_PATH]; + p->bInvalid = TRUE; + wWinPix_t h = wControlGetHeight(p->control); + wControlSetBalloon( p->control, 0, h, "Document path is invalid" ); + ParamHilite( p->group->win, p->control, TRUE ); + } break; - case I_PATH: - if (IsFileValid(noteDataInUI.noteData.fileData.path)) { - wControlActive(fileEditPLs[I_OPEN].control, TRUE); - } else { - wControlActive(fileEditPLs[I_OPEN].control, FALSE); - } - break; - default: + default: break; - } + } } -/** +/** * Handle Cancel button: restore old values for layer and position */ static void FileEditCancel( wWin_p junk) { - if (inDescribeCmd) { - UpdateFile(¬eDataInUI, CANCEL_NOTE, FALSE); - } ResetIfNotSticky(); - wHide(fileEditW); + wHide(fileNoteW); } /** * Handle OK button: make sure the entered filename is syntactically valid, update @@ -209,8 +217,21 @@ FileEditCancel( wWin_p junk) static void FileEditOK(void *junk) { - UpdateFile(¬eDataInUI, OK_FILE, FALSE); - wHide(fileEditW); + track_p trk = fileNoteData.trk; + if ( trk == NULL ) { + // new file note + trk = NewNote( -1, fileNoteData.pos, OP_NOTEFILE ); + } + struct extraDataNote_t * xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); + xx->pos = fileNoteData.pos; + SetTrkLayer( trk, fileNoteData.layer ); + MyFree( xx->noteData.fileData.title ); + xx->noteData.fileData.title = MyStrdup( fileNoteData.title ); + MyFree( xx->noteData.fileData.path ); + xx->noteData.fileData.path = MyStrdup( fileNoteData.path ); + SetBoundingBox( trk, xx->pos, xx->pos ); + DrawNewTrack( trk ); + wHide(fileNoteW); ResetIfNotSticky(); SetFileChanged(); } @@ -222,38 +243,27 @@ FileEditOK(void *junk) * \param windowTitle IN title for the edit dialog window */ -void CreateEditFileDialog(track_p trk, char * windowTitle) +static void CreateEditFileDialog(char * windowTitle) { - if (!fileEditW) { - noteDataInUI.base.trkType = T_NOTE; - noteDataInUI.noteData.fileData.path = MyMalloc(PATHMAXIMUMLENGTH); - noteDataInUI.noteData.fileData.title = MyMalloc(TITLEMAXIMUMLENGTH); - fileEditPLs[I_TITLE].valueP = noteDataInUI.noteData.fileData.title; - fileEditPLs[I_PATH].valueP = noteDataInUI.noteData.fileData.path; - - ParamRegister(&fileEditPG); - fileEditW = ParamCreateDialog(&fileEditPG, - "", - _("Done"), FileEditOK, - FileEditCancel, TRUE, NULL, - F_BLOCK, - FileDlgUpdate); - } - - wWinSetTitle(fileEditPG.win, MakeWindowTitle(windowTitle)); - - struct extraDataNote_t *xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); - noteDataInUI.pos = xx->pos; - noteDataInUI.layer = xx->layer; - noteDataInUI.trk = trk; - strscpy(noteDataInUI.noteData.fileData.title, xx->noteData.fileData.title, TITLEMAXIMUMLENGTH); - strscpy(noteDataInUI.noteData.fileData.path, xx->noteData.fileData.path, PATHMAXIMUMLENGTH); - FillLayerList((wList_p)fileEditPLs[I_LAYER].control); - ParamLoadControls(&fileEditPG); - wControlActive(fileEditPLs[I_OPEN].control, (IsFileValid(noteDataInUI.noteData.fileData.path)?TRUE:FALSE)); - - wShow(fileEditW); + if (!fileNoteW) { + ParamRegister(&fileNotePG); + fileNoteW = ParamCreateDialog(&fileNotePG, + "", + _("Done"), FileEditOK, + FileEditCancel, TRUE, NULL, + F_BLOCK, + FileDlgUpdate); + } + + wWinSetTitle(fileNotePG.win, MakeWindowTitle(windowTitle)); + + FillLayerList((wList_p)fileNotePLs[I_LAYER].control); + ParamLoadControls(&fileNotePG); + wControlActive(fileNotePLs[I_OPEN].control, + (IsFileValid(fileNoteData.path)?TRUE:FALSE)); + + wShow(fileNoteW); } /** @@ -263,7 +273,7 @@ void CreateEditFileDialog(track_p trk, char * windowTitle) void ActivateFileNote(track_p trk) { - struct extraDataNote_t *xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); + struct extraDataNote_t *xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); NoteFileOpen(xx->noteData.fileData.path); } @@ -279,25 +289,33 @@ void ActivateFileNote(track_p trk) void DescribeFileNote(track_p trk, char * str, CSIZE_T len) { struct extraDataNote_t *xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); - DynString statusLine; - - DynStringMalloc(&statusLine, 80); + DynString statusLine; - DynStringPrintf(&statusLine, - _("Document(%d) Layer=%d %-.80s [%s]"), - GetTrkIndex(trk), - GetTrkLayer(trk) + 1, - xx->noteData.fileData.title, - xx->noteData.fileData.path); + DynStringMalloc(&statusLine, 80); - strcpy(str, DynStringToCStr(&statusLine)); - DynStringFree(&statusLine); + DynStringPrintf(&statusLine, + _("Document(%d) Layer=%d %-.80s [%s]"), + GetTrkIndex(trk), + GetTrkLayer(trk) + 1, + xx->noteData.fileData.title, + xx->noteData.fileData.path); - if (inDescribeCmd) { - NoteStateSave(trk); - - CreateEditFileDialog(trk, _("Update document")); + strcpy(str, DynStringToCStr(&statusLine)); + DynStringFree(&statusLine); + if ( ! inDescribeCmd ) { + return; } + + + fileNoteData.pos = xx->pos; + fileNoteData.layer = GetTrkLayer( trk ); + fileNoteData.trk = trk; + strscpy( fileNoteData.title, xx->noteData.fileData.title, + sizeof fileNoteData.title ); + strscpy( fileNoteData.path, xx->noteData.fileData.path, + sizeof fileNoteData.path ); + + CreateEditFileDialog(_("Update Document")); } /** @@ -307,14 +325,15 @@ void DescribeFileNote(track_p trk, char * str, CSIZE_T len) * \param the newly created trk */ -void NewFileNoteUI(track_p trk) +void NewFileNoteUI(coOrd pos) { - struct extraDataNote_t * xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); char *tmpPtrText = _("Describe the file"); - xx->noteData.fileData.title = MyStrdup(tmpPtrText); - xx->noteData.fileData.path = MyStrdup(""); + fileNoteData.pos = pos; + fileNoteData.layer = curLayer; + fileNoteData.trk = NULL; + strscpy( fileNoteData.title, tmpPtrText, sizeof fileNoteData.title ); + strscpy( fileNoteData.path, "", sizeof fileNoteData.path ); - CreateEditFileDialog(trk, - _("Attach document")); + CreateEditFileDialog( _("Attach Document")); } diff --git a/app/bin/helphelper.c b/app/bin/helphelper.c index 36083b8..52bce2d 100644 --- a/app/bin/helphelper.c +++ b/app/bin/helphelper.c @@ -1,5 +1,5 @@ /** \file helphelper.c - * use OSX Help system + * use OSX Help system */ /* XTrkCad - Model Railroad CAD @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #import <CoreFoundation/CoreFoundation.h> @@ -43,50 +43,56 @@ OSStatus MyGoToHelpPage (CFStringRef pagePath, CFStringRef anchorName) { - CFBundleRef myApplicationBundle = NULL; - CFStringRef myBookName = NULL; - OSStatus err = noErr; - printf("HelpHelper: Started to look for help\n"); - - myApplicationBundle = CFBundleGetMainBundle(); - if (myApplicationBundle == NULL) { - printf("HelpHelper: Error - No Application Bundle\n"); - err = fnfErr; - return err; - } - printf("HelpHelper: Application Bundle Found\n"); - - myBookName = CFBundleGetValueForInfoDictionaryKey( - myApplicationBundle, - CFSTR("CFBundleHelpBookName")); - if (myBookName == NULL) { - myBookName = CFStringCreateWithCString(NULL, "XTrackCAD Help", kCFStringEncodingMacRoman); - printf("HelpHelper: Defaulting to 'XTrackCAD Help'\n" ); - err = fnfErr; - return err; - } - printf("HelpHelper: BookName dictionary name %s found\n",CFStringGetCStringPtr(myBookName, kCFStringEncodingMacRoman)); - - if (CFGetTypeID(myBookName) != CFStringGetTypeID()) { - printf("HelpHelper: Error - BookName is not a string\n" ); - err = paramErr; - } - - if (err == noErr) { - err = AHGotoPage (myBookName, pagePath, anchorName); - if (err != noErr) { - printf("HelpHelper: Error in AHGoToPage('%s','%s')\n",CFStringGetCStringPtr(myBookName, kCFStringEncodingMacRoman), CFStringGetCStringPtr(pagePath, kCFStringEncodingMacRoman)); - } - } - - return err; - + CFBundleRef myApplicationBundle = NULL; + CFStringRef myBookName = NULL; + OSStatus err = noErr; + printf("HelpHelper: Started to look for help\n"); + + myApplicationBundle = CFBundleGetMainBundle(); + if (myApplicationBundle == NULL) { + printf("HelpHelper: Error - No Application Bundle\n"); + err = fnfErr; + return err; + } + printf("HelpHelper: Application Bundle Found\n"); + + myBookName = CFBundleGetValueForInfoDictionaryKey( + myApplicationBundle, + CFSTR("CFBundleHelpBookName")); + if (myBookName == NULL) { + myBookName = CFStringCreateWithCString(NULL, "XTrackCAD Help", + kCFStringEncodingMacRoman); + printf("HelpHelper: Defaulting to 'XTrackCAD Help'\n" ); + err = fnfErr; + return err; + } + printf("HelpHelper: BookName dictionary name %s found\n", + CFStringGetCStringPtr(myBookName, kCFStringEncodingMacRoman)); + + if (CFGetTypeID(myBookName) != CFStringGetTypeID()) { + printf("HelpHelper: Error - BookName is not a string\n" ); + err = paramErr; + } + + if (err == noErr) { + err = AHGotoPage (myBookName, pagePath, anchorName); + if (err != noErr) { + printf("HelpHelper: Error in AHGoToPage('%s','%s')\n", + CFStringGetCStringPtr(myBookName, kCFStringEncodingMacRoman), + CFStringGetCStringPtr(pagePath, kCFStringEncodingMacRoman)); + } + } + + return err; + }; -int displayHelp(char* name) { - CFStringRef str = CFStringCreateWithCString(NULL,name,kCFStringEncodingMacRoman); +int displayHelp(char* name) +{ + CFStringRef str = CFStringCreateWithCString(NULL,name, + kCFStringEncodingMacRoman); OSStatus err = MyGoToHelpPage(str, NULL); - if (err != noErr) printf("HelpHelper: MyGoToHelpPage had error %d\n", err); + if (err != noErr) { printf("HelpHelper: MyGoToHelpPage had error %d\n", err); } return err; }; @@ -97,51 +103,54 @@ main( int argc, char **argv ) int handleOfPipe = 0; char buffer[ 100 ]; char issue[ 100 ]; - + int len; int finished = 0; int numBytes = 0; int numBytes2 = 0; - + printf( "HelpHelper: starting!\n" ); - + handleOfPipe = open( HELPCOMMANDPIPE, O_RDONLY ); if( handleOfPipe ) { printf( "HelpHelper: opened pipe for reading\n" ); while( !finished ) { printf( "HelpHelper: reading from pipe...\n" ); numBytes = read( handleOfPipe, &len, sizeof( int )); - - if( numBytes > 0 ) + + if( numBytes > 0 ) { printf( "HelpHelper: read %d bytes\n", numBytes ); + } if( numBytes == sizeof(int)) { printf( "HelpHelper: Expecting %d bytes\n", len ); numBytes2 = read( handleOfPipe, buffer, len + 1 ); buffer[numBytes2] = '\0'; - if (numBytes2 > 0) + if (numBytes2 > 0) { printf( "HelpHelper: Display help on: %s\n", buffer ); - + } + if( !strcmp(buffer, EXITCOMMAND )) { finished = 1; } else { - if (displayHelp(buffer) != 0) + if (displayHelp(buffer) != 0) { printf( "HelpHelper: Error\n"); - } + } + } } if( numBytes <= 0 ) { printf( "HelpHelper: exiting on pipe error\n" ); exit( 1 ); - } + } } } else { printf( "HelpHelper: Could not open pipe for reading\n" ); - } - + } + printf( "HelpHelper: exiting!" ); - + exit( 0 ); }; - + diff --git a/app/bin/i18n.c b/app/bin/i18n.c index e6abe70..8782803 100644 --- a/app/bin/i18n.c +++ b/app/bin/i18n.c @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <locale.h> @@ -26,9 +26,9 @@ #include "wlib.h" /** - * Initialize gettext environment. By default, the language files are installed - * in <install_dir>\share\locale\<language> - * The install dir is derived from the library directory by removing the last + * Initialize gettext environment. By default, the language files are installed + * in <install_dir>\share\locale\<language> + * The install dir is derived from the library directory by removing the last * directory in the path (xtrkcad) * Directory layout on Windows is: * <install_dir>\bin\ @@ -39,15 +39,15 @@ void InitGettext( void ) { #ifdef XTRKCAD_USE_GETTEXT char directory[2048]; - + setlocale(LC_ALL, ""); - + // build the correct directory path strcpy(directory, wGetAppLibDir()); strcat( directory, "/../locale" ); #ifdef WINDOWS _fullpath( directory, directory, 2048 ); -#endif +#endif // initialize gettext bindtextdomain(XTRKCAD_PACKAGE, directory); bind_textdomain_codeset(XTRKCAD_PACKAGE, "UTF-8"); @@ -55,7 +55,7 @@ void InitGettext( void ) #ifdef VERBOSE printf(_("Gettext initialized (PACKAGE=%s, LOCALEDIR=%s, LC_ALL=%s).\n"), - XTRKCAD_PACKAGE, directory, setlocale(LC_ALL, NULL)); + XTRKCAD_PACKAGE, directory, setlocale(LC_ALL, NULL)); #endif #endif /* XTRKCAD_USE_GETTEXT */ diff --git a/app/bin/i18n.h b/app/bin/i18n.h index f70c87d..9b53944 100644 --- a/app/bin/i18n.h +++ b/app/bin/i18n.h @@ -13,31 +13,31 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "xtrkcad-config.h" #ifdef XTRKCAD_USE_GETTEXT /* Use gettext */ - #ifndef USE_SIMPLE_GETTEXT - #include <libintl.h> - #endif +#ifndef USE_SIMPLE_GETTEXT +#include <libintl.h> +#endif - #include <string.h> +#include <string.h> - #define _(String) ((String && strlen(String) > 0) \ +#define _(String) ((String && strlen(String) > 0) \ ? gettext(String) : String) - #define p_(Context, String) ((Context && strlen(Context) > 0) \ +#define p_(Context, String) ((Context && strlen(Context) > 0) \ ? pgettext(Context, String) : _(String)) - #define gettext_noop(String) String - #define N_(String) gettext_noop(String) +#define gettext_noop(String) String +#define N_(String) gettext_noop(String) #else - /* Don't use gettext */ - #define _(String) String - #define gettext_noop(String) String - #define N_(String) String +/* Don't use gettext */ +#define _(String) String +#define gettext_noop(String) String +#define N_(String) String #endif /* XTRKCAD_USE_GETTEXT */ void InitGettext( void ); diff --git a/app/bin/include/dirent.h b/app/bin/include/dirent.h index 2ebf703..31e31e3 100644 --- a/app/bin/include/dirent.h +++ b/app/bin/include/dirent.h @@ -9,10 +9,10 @@ #ifndef DIRENT_H
#define DIRENT_H
- /*
- * Include windows.h without Windows Sockets 1.1 to prevent conflicts with
- * Windows Sockets 2.0.
- */
+/*
+ * Include windows.h without Windows Sockets 1.1 to prevent conflicts with
+ * Windows Sockets 2.0.
+ */
#ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
#endif
@@ -23,12 +23,11 @@ #include <wchar.h>
#include <string.h>
#include <stdlib.h>
-#include <malloc.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
- /* Indicates that d_type field is available in dirent structure */
+/* Indicates that d_type field is available in dirent structure */
#define _DIRENT_HAVE_D_TYPE
/* Indicates that d_namlen field is available in dirent structure */
@@ -197,7 +196,7 @@ # define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
#endif
- /* Return the exact length of the file name without zero terminator */
+/* Return the exact length of the file name without zero terminator */
#define _D_EXACT_NAMLEN(p) ((p)->d_namlen)
/* Return the maximum size of a file name */
@@ -209,103 +208,103 @@ extern "C" { #endif
- /* Wide-character version */
- struct _wdirent {
- /* Always zero */
- long d_ino;
+/* Wide-character version */
+struct _wdirent {
+ /* Always zero */
+ long d_ino;
- /* File position within stream */
- long d_off;
+ /* File position within stream */
+ long d_off;
- /* Structure size */
- unsigned short d_reclen;
+ /* Structure size */
+ unsigned short d_reclen;
- /* Length of name without \0 */
- size_t d_namlen;
+ /* Length of name without \0 */
+ size_t d_namlen;
- /* File type */
- int d_type;
+ /* File type */
+ int d_type;
- /* File name */
- wchar_t d_name[PATH_MAX + 1];
- };
- typedef struct _wdirent _wdirent;
+ /* File name */
+ wchar_t d_name[PATH_MAX + 1];
+};
+typedef struct _wdirent _wdirent;
- struct _WDIR {
- /* Current directory entry */
- struct _wdirent ent;
+struct _WDIR {
+ /* Current directory entry */
+ struct _wdirent ent;
- /* Private file data */
- WIN32_FIND_DATAW data;
+ /* Private file data */
+ WIN32_FIND_DATAW data;
- /* True if data is valid */
- int cached;
+ /* True if data is valid */
+ int cached;
- /* Win32 search handle */
- HANDLE handle;
+ /* Win32 search handle */
+ HANDLE handle;
- /* Initial directory name */
- wchar_t *patt;
- };
- typedef struct _WDIR _WDIR;
+ /* Initial directory name */
+ wchar_t *patt;
+};
+typedef struct _WDIR _WDIR;
- /* Multi-byte character version */
- struct dirent {
- /* Always zero */
- long d_ino;
+/* Multi-byte character version */
+struct dirent {
+ /* Always zero */
+ long d_ino;
- /* File position within stream */
- long d_off;
+ /* File position within stream */
+ long d_off;
- /* Structure size */
- unsigned short d_reclen;
+ /* Structure size */
+ unsigned short d_reclen;
- /* Length of name without \0 */
- size_t d_namlen;
+ /* Length of name without \0 */
+ size_t d_namlen;
- /* File type */
- int d_type;
+ /* File type */
+ int d_type;
- /* File name */
- char d_name[PATH_MAX + 1];
- };
- typedef struct dirent dirent;
+ /* File name */
+ char d_name[PATH_MAX + 1];
+};
+typedef struct dirent dirent;
- struct DIR {
- struct dirent ent;
- struct _WDIR *wdirp;
- };
- typedef struct DIR DIR;
+struct DIR {
+ struct dirent ent;
+ struct _WDIR *wdirp;
+};
+typedef struct DIR DIR;
- /* Dirent functions */
- static DIR *opendir(const char *dirname);
- static _WDIR *_wopendir(const wchar_t *dirname);
+/* Dirent functions */
+static DIR *opendir(const char *dirname);
+static _WDIR *_wopendir(const wchar_t *dirname);
- static struct dirent *readdir(DIR *dirp);
- static struct _wdirent *_wreaddir(_WDIR *dirp);
+static struct dirent *readdir(DIR *dirp);
+static struct _wdirent *_wreaddir(_WDIR *dirp);
- static int readdir_r(
- DIR *dirp, struct dirent *entry, struct dirent **result);
- static int _wreaddir_r(
- _WDIR *dirp, struct _wdirent *entry, struct _wdirent **result);
+static int readdir_r(
+ DIR *dirp, struct dirent *entry, struct dirent **result);
+static int _wreaddir_r(
+ _WDIR *dirp, struct _wdirent *entry, struct _wdirent **result);
- static int closedir(DIR *dirp);
- static int _wclosedir(_WDIR *dirp);
+static int closedir(DIR *dirp);
+static int _wclosedir(_WDIR *dirp);
- static void rewinddir(DIR* dirp);
- static void _wrewinddir(_WDIR* dirp);
+static void rewinddir(DIR* dirp);
+static void _wrewinddir(_WDIR* dirp);
- static int scandir(const char *dirname, struct dirent ***namelist,
- int(*filter)(const struct dirent*),
- int(*compare)(const struct dirent**, const struct dirent**));
+static int scandir(const char *dirname, struct dirent ***namelist,
+ int(*filter)(const struct dirent*),
+ int(*compare)(const struct dirent**, const struct dirent**));
- static int alphasort(const struct dirent **a, const struct dirent **b);
+static int alphasort(const struct dirent **a, const struct dirent **b);
- static int versionsort(const struct dirent **a, const struct dirent **b);
+static int versionsort(const struct dirent **a, const struct dirent **b);
- /* For compatibility with Symbian */
+/* For compatibility with Symbian */
#define wdirent _wdirent
#define WDIR _WDIR
#define wopendir _wopendir
@@ -315,937 +314,907 @@ extern "C" { /* Internal utility functions */
- static WIN32_FIND_DATAW *dirent_first(_WDIR *dirp);
- static WIN32_FIND_DATAW *dirent_next(_WDIR *dirp);
+static WIN32_FIND_DATAW *dirent_first(_WDIR *dirp);
+static WIN32_FIND_DATAW *dirent_next(_WDIR *dirp);
- static int dirent_mbstowcs_s(
- size_t *pReturnValue,
- wchar_t *wcstr,
- size_t sizeInWords,
- const char *mbstr,
- size_t count);
+static int dirent_mbstowcs_s(
+ size_t *pReturnValue,
+ wchar_t *wcstr,
+ size_t sizeInWords,
+ const char *mbstr,
+ size_t count);
- static int dirent_wcstombs_s(
- size_t *pReturnValue,
- char *mbstr,
- size_t sizeInBytes,
- const wchar_t *wcstr,
- size_t count);
+static int dirent_wcstombs_s(
+ size_t *pReturnValue,
+ char *mbstr,
+ size_t sizeInBytes,
+ const wchar_t *wcstr,
+ size_t count);
- static void dirent_set_errno(int error);
+static void dirent_set_errno(int error);
- /*
- * Open directory stream DIRNAME for read and return a pointer to the
- * internal working area that is used to retrieve individual directory
- * entries.
- */
- static _WDIR*
- _wopendir(
- const wchar_t *dirname)
- {
- _WDIR *dirp = NULL;
- int error;
+/*
+ * Open directory stream DIRNAME for read and return a pointer to the
+ * internal working area that is used to retrieve individual directory
+ * entries.
+ */
+static _WDIR*
+_wopendir(
+ const wchar_t *dirname)
+{
+ _WDIR *dirp = NULL;
+ int error;
+
+ /* Must have directory name */
+ if (dirname == NULL || dirname[0] == '\0') {
+ dirent_set_errno(ENOENT);
+ return NULL;
+ }
- /* Must have directory name */
- if (dirname == NULL || dirname[0] == '\0') {
- dirent_set_errno(ENOENT);
- return NULL;
- }
+ /* Allocate new _WDIR structure */
+ dirp = (_WDIR*)malloc(sizeof(struct _WDIR));
+ if (dirp != NULL) {
+ DWORD n;
- /* Allocate new _WDIR structure */
- dirp = (_WDIR*)malloc(sizeof(struct _WDIR));
- if (dirp != NULL) {
- DWORD n;
+ /* Reset _WDIR structure */
+ dirp->handle = INVALID_HANDLE_VALUE;
+ dirp->patt = NULL;
+ dirp->cached = 0;
- /* Reset _WDIR structure */
- dirp->handle = INVALID_HANDLE_VALUE;
- dirp->patt = NULL;
- dirp->cached = 0;
+ /* Compute the length of full path plus zero terminator
+ *
+ * Note that on WinRT there's no way to convert relative paths
+ * into absolute paths, so just assume it is an absolute path.
+ */
+# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
+ n = wcslen(dirname);
+# else
+ n = GetFullPathNameW(dirname, 0, NULL, NULL);
+# endif
- /* Compute the length of full path plus zero terminator
+ /* Allocate room for absolute directory name and search pattern */
+ dirp->patt = (wchar_t*)malloc(sizeof(wchar_t) * n + 16);
+ if (dirp->patt) {
+
+ /*
+ * Convert relative directory name to an absolute one. This
+ * allows rewinddir() to function correctly even when current
+ * working directory is changed between opendir() and rewinddir().
*
* Note that on WinRT there's no way to convert relative paths
* into absolute paths, so just assume it is an absolute path.
*/
-# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
- n = wcslen(dirname);
-# else
- n = GetFullPathNameW(dirname, 0, NULL, NULL);
-# endif
-
- /* Allocate room for absolute directory name and search pattern */
- dirp->patt = (wchar_t*)malloc(sizeof(wchar_t) * n + 16);
- if (dirp->patt) {
-
- /*
- * Convert relative directory name to an absolute one. This
- * allows rewinddir() to function correctly even when current
- * working directory is changed between opendir() and rewinddir().
- *
- * Note that on WinRT there's no way to convert relative paths
- * into absolute paths, so just assume it is an absolute path.
- */
# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
- wcsncpy_s(dirp->patt, n + 1, dirname, n);
+ wcsncpy_s(dirp->patt, n + 1, dirname, n);
# else
- n = GetFullPathNameW(dirname, n, dirp->patt, NULL);
+ n = GetFullPathNameW(dirname, n, dirp->patt, NULL);
# endif
- if (n > 0) {
- wchar_t *p;
-
- /* Append search pattern \* to the directory name */
- p = dirp->patt + n;
- if (dirp->patt < p) {
- switch (p[-1]) {
- case '\\':
- case '/':
- case ':':
- /* Directory ends in path separator, e.g. c:\temp\ */
- /*NOP*/;
- break;
-
- default:
- /* Directory name doesn't end in path separator */
- *p++ = '\\';
- }
- }
- *p++ = '*';
- *p = '\0';
+ if (n > 0) {
+ wchar_t *p;
+
+ /* Append search pattern \* to the directory name */
+ p = dirp->patt + n;
+ if (dirp->patt < p) {
+ switch (p[-1]) {
+ case '\\':
+ case '/':
+ case ':':
+ /* Directory ends in path separator, e.g. c:\temp\ */
+ /*NOP*/;
+ break;
- /* Open directory stream and retrieve the first entry */
- if (dirent_first(dirp)) {
- /* Directory stream opened successfully */
- error = 0;
- }
- else {
- /* Cannot retrieve first entry */
- error = 1;
- dirent_set_errno(ENOENT);
+ default:
+ /* Directory name doesn't end in path separator */
+ *p++ = '\\';
}
-
}
- else {
- /* Cannot retrieve full path name */
- dirent_set_errno(ENOENT);
+ *p++ = '*';
+ *p = '\0';
+
+ /* Open directory stream and retrieve the first entry */
+ if (dirent_first(dirp)) {
+ /* Directory stream opened successfully */
+ error = 0;
+ } else {
+ /* Cannot retrieve first entry */
error = 1;
+ dirent_set_errno(ENOENT);
}
- }
- else {
- /* Cannot allocate memory for search pattern */
+ } else {
+ /* Cannot retrieve full path name */
+ dirent_set_errno(ENOENT);
error = 1;
}
- }
- else {
- /* Cannot allocate _WDIR structure */
+ } else {
+ /* Cannot allocate memory for search pattern */
error = 1;
}
- /* Clean up in case of error */
- if (error && dirp) {
- _wclosedir(dirp);
- dirp = NULL;
- }
+ } else {
+ /* Cannot allocate _WDIR structure */
+ error = 1;
+ }
- return dirp;
+ /* Clean up in case of error */
+ if (error && dirp) {
+ _wclosedir(dirp);
+ dirp = NULL;
}
+ return dirp;
+}
+
+/*
+ * Read next directory entry.
+ *
+ * Returns pointer to static directory entry which may be overwritten by
+ * subsequent calls to _wreaddir().
+ */
+static struct _wdirent*
+_wreaddir(
+ _WDIR *dirp)
+{
+ struct _wdirent *entry;
+
/*
- * Read next directory entry.
- *
- * Returns pointer to static directory entry which may be overwritten by
- * subsequent calls to _wreaddir().
+ * Read directory entry to buffer. We can safely ignore the return value
+ * as entry will be set to NULL in case of error.
*/
- static struct _wdirent*
- _wreaddir(
- _WDIR *dirp)
- {
- struct _wdirent *entry;
+ (void)_wreaddir_r(dirp, &dirp->ent, &entry);
+
+ /* Return pointer to statically allocated directory entry */
+ return entry;
+}
+
+/*
+ * Read next directory entry.
+ *
+ * Returns zero on success. If end of directory stream is reached, then sets
+ * result to NULL and returns zero.
+ */
+static int
+_wreaddir_r(
+ _WDIR *dirp,
+ struct _wdirent *entry,
+ struct _wdirent **result)
+{
+ WIN32_FIND_DATAW *datap;
+
+ /* Read next directory entry */
+ datap = dirent_next(dirp);
+ if (datap) {
+ size_t n;
+ DWORD attr;
/*
- * Read directory entry to buffer. We can safely ignore the return value
- * as entry will be set to NULL in case of error.
+ * Copy file name as wide-character string. If the file name is too
+ * long to fit in to the destination buffer, then truncate file name
+ * to PATH_MAX characters and zero-terminate the buffer.
*/
- (void)_wreaddir_r(dirp, &dirp->ent, &entry);
+ n = 0;
+ while (n < PATH_MAX && datap->cFileName[n] != 0) {
+ entry->d_name[n] = datap->cFileName[n];
+ n++;
+ }
+ entry->d_name[n] = 0;
- /* Return pointer to statically allocated directory entry */
- return entry;
- }
+ /* Length of file name excluding zero terminator */
+ entry->d_namlen = n;
- /*
- * Read next directory entry.
- *
- * Returns zero on success. If end of directory stream is reached, then sets
- * result to NULL and returns zero.
- */
- static int
- _wreaddir_r(
- _WDIR *dirp,
- struct _wdirent *entry,
- struct _wdirent **result)
- {
- WIN32_FIND_DATAW *datap;
-
- /* Read next directory entry */
- datap = dirent_next(dirp);
- if (datap) {
- size_t n;
- DWORD attr;
+ /* File type */
+ attr = datap->dwFileAttributes;
+ if ((attr & FILE_ATTRIBUTE_DEVICE) != 0) {
+ entry->d_type = DT_CHR;
+ } else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
+ entry->d_type = DT_DIR;
+ } else {
+ entry->d_type = DT_REG;
+ }
- /*
- * Copy file name as wide-character string. If the file name is too
- * long to fit in to the destination buffer, then truncate file name
- * to PATH_MAX characters and zero-terminate the buffer.
- */
- n = 0;
- while (n < PATH_MAX && datap->cFileName[n] != 0) {
- entry->d_name[n] = datap->cFileName[n];
- n++;
- }
- entry->d_name[n] = 0;
+ /* Reset dummy fields */
+ entry->d_ino = 0;
+ entry->d_off = 0;
+ entry->d_reclen = sizeof(struct _wdirent);
- /* Length of file name excluding zero terminator */
- entry->d_namlen = n;
+ /* Set result address */
+ *result = entry;
- /* File type */
- attr = datap->dwFileAttributes;
- if ((attr & FILE_ATTRIBUTE_DEVICE) != 0) {
- entry->d_type = DT_CHR;
- }
- else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
- entry->d_type = DT_DIR;
- }
- else {
- entry->d_type = DT_REG;
- }
+ } else {
- /* Reset dummy fields */
- entry->d_ino = 0;
- entry->d_off = 0;
- entry->d_reclen = sizeof(struct _wdirent);
+ /* Return NULL to indicate end of directory */
+ *result = NULL;
- /* Set result address */
- *result = entry;
+ }
- }
- else {
+ return /*OK*/0;
+}
- /* Return NULL to indicate end of directory */
- *result = NULL;
+/*
+ * Close directory stream opened by opendir() function. This invalidates the
+ * DIR structure as well as any directory entry read previously by
+ * _wreaddir().
+ */
+static int
+_wclosedir(
+ _WDIR *dirp)
+{
+ int ok;
+ if (dirp) {
+
+ /* Release search handle */
+ if (dirp->handle != INVALID_HANDLE_VALUE) {
+ FindClose(dirp->handle);
+ dirp->handle = INVALID_HANDLE_VALUE;
+ }
+ /* Release search pattern */
+ if (dirp->patt) {
+ free(dirp->patt);
+ dirp->patt = NULL;
}
- return /*OK*/0;
- }
+ /* Release directory structure */
+ free(dirp);
+ ok = /*success*/0;
- /*
- * Close directory stream opened by opendir() function. This invalidates the
- * DIR structure as well as any directory entry read previously by
- * _wreaddir().
- */
- static int
- _wclosedir(
- _WDIR *dirp)
- {
- int ok;
- if (dirp) {
-
- /* Release search handle */
- if (dirp->handle != INVALID_HANDLE_VALUE) {
- FindClose(dirp->handle);
- dirp->handle = INVALID_HANDLE_VALUE;
- }
+ } else {
- /* Release search pattern */
- if (dirp->patt) {
- free(dirp->patt);
- dirp->patt = NULL;
- }
+ /* Invalid directory stream */
+ dirent_set_errno(EBADF);
+ ok = /*failure*/-1;
- /* Release directory structure */
- free(dirp);
- ok = /*success*/0;
+ }
+ return ok;
+}
+/*
+ * Rewind directory stream such that _wreaddir() returns the very first
+ * file name again.
+ */
+static void
+_wrewinddir(
+ _WDIR* dirp)
+{
+ if (dirp) {
+ /* Release existing search handle */
+ if (dirp->handle != INVALID_HANDLE_VALUE) {
+ FindClose(dirp->handle);
}
- else {
-
- /* Invalid directory stream */
- dirent_set_errno(EBADF);
- ok = /*failure*/-1;
- }
- return ok;
+ /* Open new search handle */
+ dirent_first(dirp);
}
+}
- /*
- * Rewind directory stream such that _wreaddir() returns the very first
- * file name again.
- */
- static void
- _wrewinddir(
- _WDIR* dirp)
- {
- if (dirp) {
- /* Release existing search handle */
- if (dirp->handle != INVALID_HANDLE_VALUE) {
- FindClose(dirp->handle);
- }
-
- /* Open new search handle */
- dirent_first(dirp);
- }
- }
+/* Get first directory entry (internal) */
+static WIN32_FIND_DATAW*
+dirent_first(
+ _WDIR *dirp)
+{
+ WIN32_FIND_DATAW *datap;
- /* Get first directory entry (internal) */
- static WIN32_FIND_DATAW*
- dirent_first(
- _WDIR *dirp)
- {
- WIN32_FIND_DATAW *datap;
-
- /* Open directory and retrieve the first entry */
- dirp->handle = FindFirstFileExW(
- dirp->patt, FindExInfoStandard, &dirp->data,
- FindExSearchNameMatch, NULL, 0);
- if (dirp->handle != INVALID_HANDLE_VALUE) {
+ /* Open directory and retrieve the first entry */
+ dirp->handle = FindFirstFileExW(
+ dirp->patt, FindExInfoStandard, &dirp->data,
+ FindExSearchNameMatch, NULL, 0);
+ if (dirp->handle != INVALID_HANDLE_VALUE) {
- /* a directory entry is now waiting in memory */
- datap = &dirp->data;
- dirp->cached = 1;
+ /* a directory entry is now waiting in memory */
+ datap = &dirp->data;
+ dirp->cached = 1;
- }
- else {
+ } else {
- /* Failed to re-open directory: no directory entry in memory */
- dirp->cached = 0;
- datap = NULL;
+ /* Failed to re-open directory: no directory entry in memory */
+ dirp->cached = 0;
+ datap = NULL;
- }
- return datap;
}
+ return datap;
+}
- /*
- * Get next directory entry (internal).
- *
- * Returns
- */
- static WIN32_FIND_DATAW*
- dirent_next(
- _WDIR *dirp)
- {
- WIN32_FIND_DATAW *p;
-
- /* Get next directory entry */
- if (dirp->cached != 0) {
+/*
+ * Get next directory entry (internal).
+ *
+ * Returns
+ */
+static WIN32_FIND_DATAW*
+dirent_next(
+ _WDIR *dirp)
+{
+ WIN32_FIND_DATAW *p;
- /* A valid directory entry already in memory */
- p = &dirp->data;
- dirp->cached = 0;
+ /* Get next directory entry */
+ if (dirp->cached != 0) {
- }
- else if (dirp->handle != INVALID_HANDLE_VALUE) {
+ /* A valid directory entry already in memory */
+ p = &dirp->data;
+ dirp->cached = 0;
- /* Get the next directory entry from stream */
- if (FindNextFileW(dirp->handle, &dirp->data) != FALSE) {
- /* Got a file */
- p = &dirp->data;
- }
- else {
- /* The very last entry has been processed or an error occurred */
- FindClose(dirp->handle);
- dirp->handle = INVALID_HANDLE_VALUE;
- p = NULL;
- }
+ } else if (dirp->handle != INVALID_HANDLE_VALUE) {
+ /* Get the next directory entry from stream */
+ if (FindNextFileW(dirp->handle, &dirp->data) != FALSE) {
+ /* Got a file */
+ p = &dirp->data;
+ } else {
+ /* The very last entry has been processed or an error occurred */
+ FindClose(dirp->handle);
+ dirp->handle = INVALID_HANDLE_VALUE;
+ p = NULL;
}
- else {
- /* End of directory stream reached */
- p = NULL;
+ } else {
- }
+ /* End of directory stream reached */
+ p = NULL;
- return p;
}
- /*
- * Open directory stream using plain old C-string.
- */
- static DIR*
- opendir(
- const char *dirname)
- {
- struct DIR *dirp;
- int error;
-
- /* Must have directory name */
- if (dirname == NULL || dirname[0] == '\0') {
- dirent_set_errno(ENOENT);
- return NULL;
- }
+ return p;
+}
- /* Allocate memory for DIR structure */
- dirp = (DIR*)malloc(sizeof(struct DIR));
- if (dirp) {
- wchar_t wname[PATH_MAX + 1];
- size_t n;
-
- /* Convert directory name to wide-character string */
- error = dirent_mbstowcs_s(
- &n, wname, PATH_MAX + 1, dirname, PATH_MAX + 1);
- if (!error) {
-
- /* Open directory stream using wide-character name */
- dirp->wdirp = _wopendir(wname);
- if (dirp->wdirp) {
- /* Directory stream opened */
- error = 0;
- }
- else {
- /* Failed to open directory stream */
- error = 1;
- }
+/*
+ * Open directory stream using plain old C-string.
+ */
+static DIR*
+opendir(
+ const char *dirname)
+{
+ struct DIR *dirp;
+ int error;
+
+ /* Must have directory name */
+ if (dirname == NULL || dirname[0] == '\0') {
+ dirent_set_errno(ENOENT);
+ return NULL;
+ }
- }
- else {
- /*
- * Cannot convert file name to wide-character string. This
- * occurs if the string contains invalid multi-byte sequences or
- * the output buffer is too small to contain the resulting
- * string.
- */
+ /* Allocate memory for DIR structure */
+ dirp = (DIR*)malloc(sizeof(struct DIR));
+ if (dirp) {
+ wchar_t wname[PATH_MAX + 1];
+ size_t n;
+
+ /* Convert directory name to wide-character string */
+ error = dirent_mbstowcs_s(
+ &n, wname, PATH_MAX + 1, dirname, PATH_MAX + 1);
+ if (!error) {
+
+ /* Open directory stream using wide-character name */
+ dirp->wdirp = _wopendir(wname);
+ if (dirp->wdirp) {
+ /* Directory stream opened */
+ error = 0;
+ } else {
+ /* Failed to open directory stream */
error = 1;
}
- }
- else {
- /* Cannot allocate DIR structure */
+ } else {
+ /*
+ * Cannot convert file name to wide-character string. This
+ * occurs if the string contains invalid multi-byte sequences or
+ * the output buffer is too small to contain the resulting
+ * string.
+ */
error = 1;
}
- /* Clean up in case of error */
- if (error && dirp) {
- free(dirp);
- dirp = NULL;
- }
-
- return dirp;
+ } else {
+ /* Cannot allocate DIR structure */
+ error = 1;
}
- /*
- * Read next directory entry.
- */
- static struct dirent*
- readdir(
- DIR *dirp)
- {
- struct dirent *entry;
+ /* Clean up in case of error */
+ if (error && dirp) {
+ free(dirp);
+ dirp = NULL;
+ }
- /*
- * Read directory entry to buffer. We can safely ignore the return value
- * as entry will be set to NULL in case of error.
- */
- (void)readdir_r(dirp, &dirp->ent, &entry);
+ return dirp;
+}
- /* Return pointer to statically allocated directory entry */
- return entry;
- }
+/*
+ * Read next directory entry.
+ */
+static struct dirent*
+readdir(
+ DIR *dirp)
+{
+ struct dirent *entry;
/*
- * Read next directory entry into called-allocated buffer.
- *
- * Returns zero on success. If the end of directory stream is reached, then
- * sets result to NULL and returns zero.
+ * Read directory entry to buffer. We can safely ignore the return value
+ * as entry will be set to NULL in case of error.
*/
- static int
- readdir_r(
- DIR *dirp,
- struct dirent *entry,
- struct dirent **result)
- {
- WIN32_FIND_DATAW *datap;
-
- /* Read next directory entry */
- datap = dirent_next(dirp->wdirp);
- if (datap) {
- size_t n;
- int error;
-
- /* Attempt to convert file name to multi-byte string */
- error = dirent_wcstombs_s(
- &n, entry->d_name, PATH_MAX + 1, datap->cFileName, PATH_MAX + 1);
+ (void)readdir_r(dirp, &dirp->ent, &entry);
- /*
- * If the file name cannot be represented by a multi-byte string,
- * then attempt to use old 8+3 file name. This allows traditional
- * Unix-code to access some file names despite of unicode
- * characters, although file names may seem unfamiliar to the user.
- *
- * Be ware that the code below cannot come up with a short file
- * name unless the file system provides one. At least
- * VirtualBox shared folders fail to do this.
- */
- if (error && datap->cAlternateFileName[0] != '\0') {
- error = dirent_wcstombs_s(
- &n, entry->d_name, PATH_MAX + 1,
- datap->cAlternateFileName, PATH_MAX + 1);
- }
+ /* Return pointer to statically allocated directory entry */
+ return entry;
+}
- if (!error) {
- DWORD attr;
+/*
+ * Read next directory entry into called-allocated buffer.
+ *
+ * Returns zero on success. If the end of directory stream is reached, then
+ * sets result to NULL and returns zero.
+ */
+static int
+readdir_r(
+ DIR *dirp,
+ struct dirent *entry,
+ struct dirent **result)
+{
+ WIN32_FIND_DATAW *datap;
+
+ /* Read next directory entry */
+ datap = dirent_next(dirp->wdirp);
+ if (datap) {
+ size_t n;
+ int error;
- /* Length of file name excluding zero terminator */
- entry->d_namlen = n - 1;
+ /* Attempt to convert file name to multi-byte string */
+ error = dirent_wcstombs_s(
+ &n, entry->d_name, PATH_MAX + 1, datap->cFileName, PATH_MAX + 1);
- /* File attributes */
- attr = datap->dwFileAttributes;
- if ((attr & FILE_ATTRIBUTE_DEVICE) != 0) {
- entry->d_type = DT_CHR;
- }
- else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
- entry->d_type = DT_DIR;
- }
- else {
- entry->d_type = DT_REG;
- }
+ /*
+ * If the file name cannot be represented by a multi-byte string,
+ * then attempt to use old 8+3 file name. This allows traditional
+ * Unix-code to access some file names despite of unicode
+ * characters, although file names may seem unfamiliar to the user.
+ *
+ * Be ware that the code below cannot come up with a short file
+ * name unless the file system provides one. At least
+ * VirtualBox shared folders fail to do this.
+ */
+ if (error && datap->cAlternateFileName[0] != '\0') {
+ error = dirent_wcstombs_s(
+ &n, entry->d_name, PATH_MAX + 1,
+ datap->cAlternateFileName, PATH_MAX + 1);
+ }
- /* Reset dummy fields */
- entry->d_ino = 0;
- entry->d_off = 0;
- entry->d_reclen = sizeof(struct dirent);
+ if (!error) {
+ DWORD attr;
- }
- else {
-
- /*
- * Cannot convert file name to multi-byte string so construct
- * an erroneous directory entry and return that. Note that
- * we cannot return NULL as that would stop the processing
- * of directory entries completely.
- */
- entry->d_name[0] = '?';
- entry->d_name[1] = '\0';
- entry->d_namlen = 1;
- entry->d_type = DT_UNKNOWN;
- entry->d_ino = 0;
- entry->d_off = -1;
- entry->d_reclen = 0;
+ /* Length of file name excluding zero terminator */
+ entry->d_namlen = n - 1;
+ /* File attributes */
+ attr = datap->dwFileAttributes;
+ if ((attr & FILE_ATTRIBUTE_DEVICE) != 0) {
+ entry->d_type = DT_CHR;
+ } else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
+ entry->d_type = DT_DIR;
+ } else {
+ entry->d_type = DT_REG;
}
- /* Return pointer to directory entry */
- *result = entry;
+ /* Reset dummy fields */
+ entry->d_ino = 0;
+ entry->d_off = 0;
+ entry->d_reclen = sizeof(struct dirent);
- }
- else {
+ } else {
- /* No more directory entries */
- *result = NULL;
+ /*
+ * Cannot convert file name to multi-byte string so construct
+ * an erroneous directory entry and return that. Note that
+ * we cannot return NULL as that would stop the processing
+ * of directory entries completely.
+ */
+ entry->d_name[0] = '?';
+ entry->d_name[1] = '\0';
+ entry->d_namlen = 1;
+ entry->d_type = DT_UNKNOWN;
+ entry->d_ino = 0;
+ entry->d_off = -1;
+ entry->d_reclen = 0;
}
- return /*OK*/0;
+ /* Return pointer to directory entry */
+ *result = entry;
+
+ } else {
+
+ /* No more directory entries */
+ *result = NULL;
+
}
- /*
- * Close directory stream.
- */
- static int
- closedir(
- DIR *dirp)
- {
- int ok;
- if (dirp) {
+ return /*OK*/0;
+}
- /* Close wide-character directory stream */
- ok = _wclosedir(dirp->wdirp);
- dirp->wdirp = NULL;
+/*
+ * Close directory stream.
+ */
+static int
+closedir(
+ DIR *dirp)
+{
+ int ok;
+ if (dirp) {
- /* Release multi-byte character version */
- free(dirp);
+ /* Close wide-character directory stream */
+ ok = _wclosedir(dirp->wdirp);
+ dirp->wdirp = NULL;
- }
- else {
+ /* Release multi-byte character version */
+ free(dirp);
- /* Invalid directory stream */
- dirent_set_errno(EBADF);
- ok = /*failure*/-1;
+ } else {
- }
- return ok;
- }
+ /* Invalid directory stream */
+ dirent_set_errno(EBADF);
+ ok = /*failure*/-1;
- /*
- * Rewind directory stream to beginning.
- */
- static void
- rewinddir(
- DIR* dirp)
- {
- /* Rewind wide-character string directory stream */
- _wrewinddir(dirp->wdirp);
}
+ return ok;
+}
- /*
- * Scan directory for entries.
- */
- static int
- scandir(
- const char *dirname,
- struct dirent ***namelist,
- int(*filter)(const struct dirent*),
- int(*compare)(const struct dirent**, const struct dirent**))
- {
- struct dirent **files = NULL;
- size_t size = 0;
- size_t allocated = 0;
- const size_t init_size = 1;
- DIR *dir = NULL;
- struct dirent *entry;
- struct dirent *tmp = NULL;
- size_t i;
- int result = 0;
-
- /* Open directory stream */
- dir = opendir(dirname);
- if (dir) {
-
- /* Read directory entries to memory */
- while (1) {
-
- /* Enlarge pointer table to make room for another pointer */
- if (size >= allocated) {
- void *p;
- size_t num_entries;
-
- /* Compute number of entries in the enlarged pointer table */
- if (size < init_size) {
- /* Allocate initial pointer table */
- num_entries = init_size;
- }
- else {
- /* Double the size */
- num_entries = size * 2;
- }
+/*
+ * Rewind directory stream to beginning.
+ */
+static void
+rewinddir(
+ DIR* dirp)
+{
+ /* Rewind wide-character string directory stream */
+ _wrewinddir(dirp->wdirp);
+}
- /* Allocate first pointer table or enlarge existing table */
- p = realloc(files, sizeof(void*) * num_entries);
- if (p != NULL) {
- /* Got the memory */
- files = (dirent**)p;
- allocated = num_entries;
- }
- else {
- /* Out of memory */
- result = -1;
- break;
- }
+/*
+ * Scan directory for entries.
+ */
+static int
+scandir(
+ const char *dirname,
+ struct dirent ***namelist,
+ int(*filter)(const struct dirent*),
+ int(*compare)(const struct dirent**, const struct dirent**))
+{
+ struct dirent **files = NULL;
+ size_t size = 0;
+ size_t allocated = 0;
+ const size_t init_size = 1;
+ DIR *dir = NULL;
+ struct dirent *entry;
+ struct dirent *tmp = NULL;
+ size_t i;
+ int result = 0;
+
+ /* Open directory stream */
+ dir = opendir(dirname);
+ if (dir) {
+
+ /* Read directory entries to memory */
+ while (1) {
+
+ /* Enlarge pointer table to make room for another pointer */
+ if (size >= allocated) {
+ void *p;
+ size_t num_entries;
+
+ /* Compute number of entries in the enlarged pointer table */
+ if (size < init_size) {
+ /* Allocate initial pointer table */
+ num_entries = init_size;
+ } else {
+ /* Double the size */
+ num_entries = size * 2;
+ }
+ /* Allocate first pointer table or enlarge existing table */
+ p = realloc(files, sizeof(void*) * num_entries);
+ if (p != NULL) {
+ /* Got the memory */
+ files = (dirent**)p;
+ allocated = num_entries;
+ } else {
+ /* Out of memory */
+ result = -1;
+ break;
}
- /* Allocate room for temporary directory entry */
+ }
+
+ /* Allocate room for temporary directory entry */
+ if (tmp == NULL) {
+ tmp = (struct dirent*) malloc(sizeof(struct dirent));
if (tmp == NULL) {
- tmp = (struct dirent*) malloc(sizeof(struct dirent));
- if (tmp == NULL) {
- /* Cannot allocate temporary directory entry */
- result = -1;
- break;
- }
+ /* Cannot allocate temporary directory entry */
+ result = -1;
+ break;
}
+ }
- /* Read directory entry to temporary area */
- if (readdir_r(dir, tmp, &entry) == /*OK*/0) {
-
- /* Did we get an entry? */
- if (entry != NULL) {
- int pass;
+ /* Read directory entry to temporary area */
+ if (readdir_r(dir, tmp, &entry) == /*OK*/0) {
- /* Determine whether to include the entry in result */
- if (filter) {
- /* Let the filter function decide */
- pass = filter(tmp);
- }
- else {
- /* No filter function, include everything */
- pass = 1;
- }
+ /* Did we get an entry? */
+ if (entry != NULL) {
+ int pass;
- if (pass) {
- /* Store the temporary entry to pointer table */
- files[size++] = tmp;
- tmp = NULL;
+ /* Determine whether to include the entry in result */
+ if (filter) {
+ /* Let the filter function decide */
+ pass = filter(tmp);
+ } else {
+ /* No filter function, include everything */
+ pass = 1;
+ }
- /* Keep up with the number of files */
- result++;
- }
+ if (pass) {
+ /* Store the temporary entry to pointer table */
+ files[size++] = tmp;
+ tmp = NULL;
+ /* Keep up with the number of files */
+ result++;
}
- else {
-
- /*
- * End of directory stream reached => sort entries and
- * exit.
- */
- qsort(files, size, sizeof(void*),
- (int(*) (const void*, const void*)) compare);
- break;
- }
+ } else {
- }
- else {
- /* Error reading directory entry */
- result = /*Error*/ -1;
+ /*
+ * End of directory stream reached => sort entries and
+ * exit.
+ */
+ qsort(files, size, sizeof(void*),
+ (int(*) (const void*, const void*)) compare);
break;
+
}
+ } else {
+ /* Error reading directory entry */
+ result = /*Error*/ -1;
+ break;
}
}
- else {
- /* Cannot open directory */
- result = /*Error*/ -1;
- }
- /* Release temporary directory entry */
- if (tmp) {
- free(tmp);
- }
-
- /* Release allocated memory on error */
- if (result < 0) {
- for (i = 0; i < size; i++) {
- free(files[i]);
- }
- free(files);
- files = NULL;
- }
+ } else {
+ /* Cannot open directory */
+ result = /*Error*/ -1;
+ }
- /* Close directory stream */
- if (dir) {
- closedir(dir);
- }
+ /* Release temporary directory entry */
+ if (tmp) {
+ free(tmp);
+ }
- /* Pass pointer table to caller */
- if (namelist) {
- *namelist = files;
+ /* Release allocated memory on error */
+ if (result < 0) {
+ for (i = 0; i < size; i++) {
+ free(files[i]);
}
- return result;
+ free(files);
+ files = NULL;
}
- /* Alphabetical sorting */
- static int
- alphasort(
- const struct dirent **a, const struct dirent **b)
- {
- return strcoll((*a)->d_name, (*b)->d_name);
+ /* Close directory stream */
+ if (dir) {
+ closedir(dir);
}
- /* Sort versions */
- static int
- versionsort(
- const struct dirent **a, const struct dirent **b)
- {
- /* FIXME: implement strverscmp and use that */
- return alphasort(a, b);
+ /* Pass pointer table to caller */
+ if (namelist) {
+ *namelist = files;
}
+ return result;
+}
- /* Convert multi-byte string to wide character string */
- static int
- dirent_mbstowcs_s(
- size_t *pReturnValue,
- wchar_t *wcstr,
- size_t sizeInWords,
- const char *mbstr,
- size_t count)
- {
- int error;
- int n;
- size_t len;
- UINT cp;
- DWORD flags;
-
- /* Determine code page for multi-byte string */
- if (AreFileApisANSI()) {
- /* Default ANSI code page */
- cp = GetACP();
- }
- else {
- /* Default OEM code page */
- cp = GetOEMCP();
- }
+/* Alphabetical sorting */
+static int
+alphasort(
+ const struct dirent **a, const struct dirent **b)
+{
+ return strcoll((*a)->d_name, (*b)->d_name);
+}
+
+/* Sort versions */
+static int
+versionsort(
+ const struct dirent **a, const struct dirent **b)
+{
+ /* FIXME: implement strverscmp and use that */
+ return alphasort(a, b);
+}
+
+/* Convert multi-byte string to wide character string */
+static int
+dirent_mbstowcs_s(
+ size_t *pReturnValue,
+ wchar_t *wcstr,
+ size_t sizeInWords,
+ const char *mbstr,
+ size_t count)
+{
+ int error;
+ int n;
+ size_t len;
+ UINT cp;
+ DWORD flags;
+
+ /* Determine code page for multi-byte string */
+ if (AreFileApisANSI()) {
+ /* Default ANSI code page */
+ cp = GetACP();
+ } else {
+ /* Default OEM code page */
+ cp = GetOEMCP();
+ }
+ /*
+ * Determine flags based on the character set. For more information,
+ * please see https://docs.microsoft.com/fi-fi/windows/desktop/api/stringapiset/nf-stringapiset-multibytetowidechar
+ */
+ switch (cp) {
+ case 42:
+ case 50220:
+ case 50221:
+ case 50222:
+ case 50225:
+ case 50227:
+ case 50229:
+ case 57002:
+ case 57003:
+ case 57004:
+ case 57005:
+ case 57006:
+ case 57007:
+ case 57008:
+ case 57009:
+ case 57010:
+ case 57011:
+ case 65000:
+ /* MultiByteToWideChar does not support MB_ERR_INVALID_CHARS */
+ flags = 0;
+ break;
+
+ default:
/*
- * Determine flags based on the character set. For more information,
- * please see https://docs.microsoft.com/fi-fi/windows/desktop/api/stringapiset/nf-stringapiset-multibytetowidechar
+ * Ask MultiByteToWideChar to return an error if a multi-byte
+ * character cannot be converted to a wide-character.
*/
- switch (cp) {
- case 42:
- case 50220:
- case 50221:
- case 50222:
- case 50225:
- case 50227:
- case 50229:
- case 57002:
- case 57003:
- case 57004:
- case 57005:
- case 57006:
- case 57007:
- case 57008:
- case 57009:
- case 57010:
- case 57011:
- case 65000:
- /* MultiByteToWideChar does not support MB_ERR_INVALID_CHARS */
- flags = 0;
- break;
-
- default:
- /*
- * Ask MultiByteToWideChar to return an error if a multi-byte
- * character cannot be converted to a wide-character.
- */
- flags = MB_ERR_INVALID_CHARS;
- }
+ flags = MB_ERR_INVALID_CHARS;
+ }
- /* Compute the length of input string without zero-terminator */
- len = 0;
- while (mbstr[len] != '\0' && len < count) {
- len++;
- }
+ /* Compute the length of input string without zero-terminator */
+ len = 0;
+ while (mbstr[len] != '\0' && len < count) {
+ len++;
+ }
- /* Convert to wide-character string */
- n = MultiByteToWideChar(
- /* Source code page */ cp,
- /* Flags */ flags,
- /* Pointer to string to convert */ mbstr,
- /* Size of multi-byte string */ (int)len,
- /* Pointer to output buffer */ wcstr,
- /* Size of output buffer */ (int)sizeInWords - 1
- );
-
- /* Ensure that output buffer is zero-terminated */
- wcstr[n] = '\0';
-
- /* Return length of wide-character string with zero-terminator */
- *pReturnValue = (size_t)(n + 1);
-
- /* Return zero if conversion succeeded */
- if (n > 0) {
- error = 0;
- }
- else {
- error = 1;
- }
- return error;
+ /* Convert to wide-character string */
+ n = MultiByteToWideChar(
+ /* Source code page */ cp,
+ /* Flags */ flags,
+ /* Pointer to string to convert */ mbstr,
+ /* Size of multi-byte string */ (int)len,
+ /* Pointer to output buffer */ wcstr,
+ /* Size of output buffer */ (int)sizeInWords - 1
+ );
+
+ /* Ensure that output buffer is zero-terminated */
+ wcstr[n] = '\0';
+
+ /* Return length of wide-character string with zero-terminator */
+ *pReturnValue = (size_t)(n + 1);
+
+ /* Return zero if conversion succeeded */
+ if (n > 0) {
+ error = 0;
+ } else {
+ error = 1;
}
+ return error;
+}
- /* Convert wide-character string to multi-byte string */
- static int
- dirent_wcstombs_s(
- size_t *pReturnValue,
- char *mbstr,
- size_t sizeInBytes, /* max size of mbstr */
- const wchar_t *wcstr,
- size_t count)
- {
- int n;
- int error;
- UINT cp;
- size_t len;
- BOOL flag = 0;
- LPBOOL pflag;
-
- /* Determine code page for multi-byte string */
- if (AreFileApisANSI()) {
- /* Default ANSI code page */
- cp = GetACP();
- }
- else {
- /* Default OEM code page */
- cp = GetOEMCP();
- }
+/* Convert wide-character string to multi-byte string */
+static int
+dirent_wcstombs_s(
+ size_t *pReturnValue,
+ char *mbstr,
+ size_t sizeInBytes, /* max size of mbstr */
+ const wchar_t *wcstr,
+ size_t count)
+{
+ int n;
+ int error;
+ UINT cp;
+ size_t len;
+ BOOL flag = 0;
+ LPBOOL pflag;
+
+ /* Determine code page for multi-byte string */
+ if (AreFileApisANSI()) {
+ /* Default ANSI code page */
+ cp = GetACP();
+ } else {
+ /* Default OEM code page */
+ cp = GetOEMCP();
+ }
- /* Compute the length of input string without zero-terminator */
- len = 0;
- while (wcstr[len] != '\0' && len < count) {
- len++;
- }
+ /* Compute the length of input string without zero-terminator */
+ len = 0;
+ while (wcstr[len] != '\0' && len < count) {
+ len++;
+ }
+ /*
+ * Determine if we can ask WideCharToMultiByte to return information on
+ * broken characters. For more information, please see
+ * https://docs.microsoft.com/en-us/windows/desktop/api/stringapiset/nf-stringapiset-widechartomultibyte
+ */
+ switch (cp) {
+ case CP_UTF7:
+ case CP_UTF8:
/*
- * Determine if we can ask WideCharToMultiByte to return information on
- * broken characters. For more information, please see
- * https://docs.microsoft.com/en-us/windows/desktop/api/stringapiset/nf-stringapiset-widechartomultibyte
+ * WideCharToMultiByte fails if we request information on default
+ * characters. This is just a nuisance but doesn't affect the
+ * conversion: if Windows is configured to use UTF-8, then the default
+ * character should not be needed anyway.
*/
- switch (cp) {
- case CP_UTF7:
- case CP_UTF8:
- /*
- * WideCharToMultiByte fails if we request information on default
- * characters. This is just a nuisance but doesn't affect the
- * conversion: if Windows is configured to use UTF-8, then the default
- * character should not be needed anyway.
- */
- pflag = NULL;
- break;
+ pflag = NULL;
+ break;
- default:
- /*
- * Request that WideCharToMultiByte sets the flag if it uses the
- * default character.
- */
- pflag = &flag;
- }
+ default:
+ /*
+ * Request that WideCharToMultiByte sets the flag if it uses the
+ * default character.
+ */
+ pflag = &flag;
+ }
- /* Convert wide-character string to multi-byte character string */
- n = WideCharToMultiByte(
- /* Target code page */ cp,
- /* Flags */ 0,
- /* Pointer to unicode string */ wcstr,
- /* Length of unicode string */ (int)len,
- /* Pointer to output buffer */ mbstr,
- /* Size of output buffer */ (int)sizeInBytes - 1,
- /* Default character */ NULL,
- /* Whether default character was used or not */ pflag
- );
-
- /* Ensure that output buffer is zero-terminated */
- mbstr[n] = '\0';
-
- /* Return length of multi-byte string with zero-terminator */
- *pReturnValue = (size_t)(n + 1);
-
- /* Return zero if conversion succeeded without using default characters */
- if (n > 0 && flag == 0) {
- error = 0;
- }
- else {
- error = 1;
- }
- return error;
+ /* Convert wide-character string to multi-byte character string */
+ n = WideCharToMultiByte(
+ /* Target code page */ cp,
+ /* Flags */ 0,
+ /* Pointer to unicode string */ wcstr,
+ /* Length of unicode string */ (int)len,
+ /* Pointer to output buffer */ mbstr,
+ /* Size of output buffer */ (int)sizeInBytes - 1,
+ /* Default character */ NULL,
+ /* Whether default character was used or not */ pflag
+ );
+
+ /* Ensure that output buffer is zero-terminated */
+ mbstr[n] = '\0';
+
+ /* Return length of multi-byte string with zero-terminator */
+ *pReturnValue = (size_t)(n + 1);
+
+ /* Return zero if conversion succeeded without using default characters */
+ if (n > 0 && flag == 0) {
+ error = 0;
+ } else {
+ error = 1;
}
+ return error;
+}
- /* Set errno variable */
- static void
- dirent_set_errno(
- int error)
- {
+/* Set errno variable */
+static void
+dirent_set_errno(
+ int error)
+{
#if defined(_MSC_VER) && _MSC_VER >= 1400
- /* Microsoft Visual Studio 2005 and later */
- _set_errno(error);
+ /* Microsoft Visual Studio 2005 and later */
+ _set_errno(error);
#else
- /* Non-Microsoft compiler or older Microsoft compiler */
- errno = error;
+ /* Non-Microsoft compiler or older Microsoft compiler */
+ errno = error;
#endif
- }
+}
#ifdef __cplusplus
diff --git a/app/bin/include/levenshtein.h b/app/bin/include/levenshtein.h index b3e0111..1ea6c36 100644 --- a/app/bin/include/levenshtein.h +++ b/app/bin/include/levenshtein.h @@ -15,7 +15,8 @@ size_t levenshtein(const char *a, const char *b);
size_t
-levenshtein_n (const char *a, const size_t length, const char *b, const size_t bLength);
+levenshtein_n (const char *a, const size_t length, const char *b,
+ const size_t bLength);
#ifdef __cplusplus
}
diff --git a/app/bin/include/paramfile.h b/app/bin/include/paramfile.h index 97f635a..8ae7f59 100644 --- a/app/bin/include/paramfile.h +++ b/app/bin/include/paramfile.h @@ -1,35 +1,35 @@ #ifndef HAVE_PARAMFILE_H - #define HAVE_PARAMFILE_H - #include <stdbool.h> - #include <wlib.h> - #include "common.h" +#define HAVE_PARAMFILE_H +#include <stdbool.h> +#include <wlib.h> +#include "common.h" - extern DIST_T curBarScale; - extern dynArr_t paramProc_da; - extern dynArr_t paramFileInfo_da; +extern DIST_T curBarScale; +extern dynArr_t paramProc_da; +extern dynArr_t paramFileInfo_da; - void ParamCheckSumLine(char * line); - wBool_t IsParamValid(int fileInx); - bool IsParamFileDeleted(int fileInx); - bool IsParamFileFavorite(int fileInx); - void SetParamFileState(int index); - int ReadParamFile(const char *fileName); - int ReloadDeletedParamFile(int fileindex); - void SetParamFileDeleted(int fileInx, bool deleted); - void SetParamFileFavorite(int fileInx, bool favorite); - char * GetParamFileName(int fileInx); - char * GetParamFileContents(int fileInx); - bool ReadParams(long key, const char * dirName, const char * fileName); +void ParamCheckSumLine(char * line); +wBool_t IsParamValid(int fileInx); +bool IsParamFileDeleted(int fileInx); +bool IsParamFileFavorite(int fileInx); +void SetParamFileState(int index); +int ReadParamFile(const char *fileName); +int ReloadDeletedParamFile(int fileindex); +void SetParamFileDeleted(int fileInx, bool deleted); +void SetParamFileFavorite(int fileInx, bool favorite); +char * GetParamFileName(int fileInx); +char * GetParamFileContents(int fileInx); +bool ReadParams(long key, const char * dirName, const char * fileName); - #define CONTENTSCOMMAND "CONTENTS" - char *GetParameterFileContent(char *file); +#define CONTENTSCOMMAND "CONTENTS" +char *GetParameterFileContent(char *file); - #define TURNOUTCOMMAND "TURNOUT" - #define STRUCTURECOMMAND "STRUCTURE" - #define CARCOMMAND "CARPART" - #define CARPROTOCOMMAND "CARPROTO" +#define TURNOUTCOMMAND "TURNOUT" +#define STRUCTURECOMMAND "STRUCTURE" +#define CARCOMMAND "CARPART" +#define CARPROTOCOMMAND "CARPROTO" - char * GetParameterFileScale(char *file); +char * GetParameterFileScale(char *file); #endif // !HAVE_PARAMFILE_H diff --git a/app/bin/include/paramfilelist.h b/app/bin/include/paramfilelist.h index 0ad7523..2893292 100644 --- a/app/bin/include/paramfilelist.h +++ b/app/bin/include/paramfilelist.h @@ -1,37 +1,37 @@ #ifndef HAVE_PARAMFILELIST_H - #define HAVE_PARAMFILELIST_H - #include <stdbool.h> - #include "include/paramfile.h" +#define HAVE_PARAMFILELIST_H +#include <stdbool.h> +#include "include/paramfile.h" - typedef struct { - char * name; /** < name of parameter file */ - char * contents; - int deleted; - int deletedShadow; - int valid; /** < FALSE for dropped file */ - bool favorite; - enum paramFileState trackState; - enum paramFileState structureState; - } paramFileInfo_t; - typedef paramFileInfo_t * paramFileInfo_p; +typedef struct { + char * name; /** < name of parameter file */ + char * contents; + int deleted; + int deletedShadow; + int valid; /** < FALSE for dropped file */ + bool favorite; + enum paramFileState trackState; + enum paramFileState structureState; +} paramFileInfo_t; +typedef paramFileInfo_t * paramFileInfo_p; - #define paramFileInfo(N) DYNARR_N( paramFileInfo_t, paramFileInfo_da, N ) - - char *GetParamFileDir(void); - void SetParamFileDir(char *fullPath); - void LoadParamFileList(void); - //BOOL_T ReadDefaultParams(const char * dirName); - void SaveParamFileList(void); - int GetParamFileCount(); - void UpdateParamFileList(void); - void ParamFilesChange(long changes); - int LoadParamFile(int files, char ** fileName, void * data); +#define paramFileInfo(N) DYNARR_N( paramFileInfo_t, paramFileInfo_da, N ) + +char *GetParamFileDir(void); +void SetParamFileDir(char *fullPath); +void LoadParamFileList(void); +//BOOL_T ReadDefaultParams(const char * dirName); +void SaveParamFileList(void); +int GetParamFileCount(); +void UpdateParamFileList(void); +void ParamFilesChange(long changes); +int LoadParamFile(int files, char ** fileName, void * data); // void InitializeParamDir(void); - void ParamFileListConfirmChange(void); - void ParamFileListCancelChange(void); - BOOL_T ParamFileListInit(void); +void ParamFileListConfirmChange(void); +void ParamFileListCancelChange(void); +BOOL_T ParamFileListInit(void); - void SearchUiOk(void * junk); - bool ReloadParamFile(wIndex_t index); - bool UnloadParamFile(wIndex_t fileIndex); +void SearchUiOk(void * junk); +bool ReloadParamFile(wIndex_t index); +bool UnloadParamFile(wIndex_t fileIndex); #endif // !HAVE_PARAMFILELIST_H diff --git a/app/bin/include/partcatalog.h b/app/bin/include/partcatalog.h index e1ea110..365e78b 100644 --- a/app/bin/include/partcatalog.h +++ b/app/bin/include/partcatalog.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef HAVE_TRACKCATALOG_H @@ -28,16 +28,16 @@ #define MAXFILESPERCONTENT 10 /**< count of files with the same content header */ struct sCatalogEntry { - struct sCatalogEntry *next, *prev; - unsigned files; /**< current count of files */ - char *fullFileName[MAXFILESPERCONTENT]; /**< fully qualified file name */ - char *contents; /**< content field of parameter file */ - char *tag; /**< data about the file */ + struct sCatalogEntry *next, *prev; + unsigned files; /**< current count of files */ + char *fullFileName[MAXFILESPERCONTENT]; /**< fully qualified file name */ + char *contents; /**< content field of parameter file */ + char *tag; /**< data about the file */ }; typedef struct sCatalogEntry CatalogEntry; struct sCatalog { - CatalogEntry *head; /**< The entries */ + CatalogEntry *head; /**< The entries */ }; typedef struct sCatalog Catalog; @@ -48,54 +48,57 @@ CatalogEntry It is managed as a linked list */ struct sIndexEntry { - struct sIndexEntry *next; - struct sIndexEntry *prev; - char *keyWord; /**< keyword */ - dynArr_t *references; /**< references to the CatalogEntry */ + struct sIndexEntry *next; + struct sIndexEntry *prev; + char *keyWord; /**< keyword */ + dynArr_t *references; /**< references to the CatalogEntry */ }; typedef struct sIndexEntry IndexEntry; struct sParameterLib { - Catalog *catalog; /**< list of files cataloged */ - IndexEntry *index; /**< Index for lookup */ - unsigned wordCount; /**< How many words indexed */ - unsigned parameterFileCount; /**< */ - char *words; + Catalog *catalog; /**< list of files cataloged */ + IndexEntry *index; /**< Index for lookup */ + unsigned wordCount; /**< How many words indexed */ + unsigned parameterFileCount; /**< */ + char *words; }; typedef struct sParameterLib - ParameterLib; /**< core data structure for the catalog */ + ParameterLib; /**< core data structure for the catalog */ enum WORDSTATE { - SEARCHED, - DISCARDED, - NOTFOUND, + SEARCHED, + DISCARDED, + NOTFOUND, CLOSE, - STATE_COUNT + STATE_COUNT }; struct sSearchResult { - Catalog subCatalog; - unsigned totalFound; - unsigned words; /**< no of words in search string */ - struct sSingleResult { - char *keyWord; - unsigned count; - enum WORDSTATE state; - } *kw; + Catalog subCatalog; + unsigned totalFound; + unsigned words; /**< no of words in search string */ + struct sSingleResult { + char *keyWord; + unsigned count; + enum WORDSTATE state; + } *kw; }; typedef struct sSearchResult SearchResult; Catalog *InitCatalog(void); void DestroyCatalog(Catalog *catalog); -CatalogEntry * InsertInOrder(Catalog *catalog, const char *contents, const char *tag); -void UpdateCatalogEntry(CatalogEntry *entry, char *path, char *contents, char *tag); +CatalogEntry * InsertInOrder(Catalog *catalog, const char *contents, + const char *tag); +void UpdateCatalogEntry(CatalogEntry *entry, char *path, char *contents, + char *tag); ParameterLib *InitLibrary(void); ParameterLib *CreateLibrary(char *directory); void DestroyLibrary(ParameterLib *tracklib); bool CreateCatalogFromDir(ParameterLib *trackLib, char *directory); unsigned CreateLibraryIndex(ParameterLib *trackLib); -unsigned SearchLibrary(ParameterLib *library, char *searchExpression, SearchResult *totalResult); +unsigned SearchLibrary(ParameterLib *library, char *searchExpression, + SearchResult *totalResult); char *SearchStatistics(SearchResult *result); void SearchDiscardResult(SearchResult *res); unsigned CountCatalogEntries(Catalog *catalog); diff --git a/app/bin/include/problemrep.h b/app/bin/include/problemrep.h new file mode 100644 index 0000000..bcc6982 --- /dev/null +++ b/app/bin/include/problemrep.h @@ -0,0 +1,37 @@ +/** \file problemrep.h + * Collect data for a problem report and remove private info +*/ + +/* XTrkCad - Model Railroad CAD + * Copyright (C) 2024 Martin Fischer + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef HAVE_PROBLEMREP_H +#define HAVE_PROBLEMREP_H + +//problemrep.c + +void DoProblemCollect(void* unused); + +// problemrepui.c + +void ProblemrepCreateW(void* ptr); +void ProblemrepUpdateW(char* text, ...); +int ProblemSaveLayout(void); + +#endif // !HAVE_PROBLEMREP_H + diff --git a/app/bin/include/stringxtc.h b/app/bin/include/stringxtc.h index cbadd0e..dc054d7 100644 --- a/app/bin/include/stringxtc.h +++ b/app/bin/include/stringxtc.h @@ -1,8 +1,9 @@ #include <stddef.h>
#ifndef HAVE_STRINGXTC_H
- #define HAVE_STRINGXTC_H
- size_t strscpy(char *dest, const char *src, size_t count);
- char *XtcStrlwr(char *str);
- int XtcStricmp(const char *a, const char *b);
+#define HAVE_STRINGXTC_H
+size_t strscat(char *dest, const char *src, size_t count);
+size_t strscpy(char *dest, const char *src, size_t count);
+char *XtcStrlwr(char *str);
+int XtcStricmp(const char *a, const char *b);
#endif
diff --git a/app/bin/include/svgformat.h b/app/bin/include/svgformat.h index 7cf5c85..075bbe1 100644 --- a/app/bin/include/svgformat.h +++ b/app/bin/include/svgformat.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef HAVE_SVGFORMAT_H @@ -25,7 +25,7 @@ #include <stdbool.h> #include <mxml.h> -#define MININMUMLINEWIDTH 3.0 +#define MINIMUMLINEWIDTH 4.0 typedef mxml_node_t SVGParent; typedef mxml_node_t SVGDocument; diff --git a/app/bin/include/utf8convert.h b/app/bin/include/utf8convert.h index 6a3e678..f6d8fb6 100644 --- a/app/bin/include/utf8convert.h +++ b/app/bin/include/utf8convert.h @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef HAVE_UTF8CONVERT_H diff --git a/app/bin/layout.c b/app/bin/layout.c index 4bf1936..c61c23f 100644 --- a/app/bin/layout.c +++ b/app/bin/layout.c @@ -17,52 +17,70 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <dynstring.h> #include "custom.h" #include "layout.h" -#include "misc2.h" #include "param.h" #include "paths.h" #include "track.h" #include "fileio.h" +#include "cselect.h" #define MINTRACKRADIUSPREFS "minTrackRadius" +#define MAXTRACKGRADEPREFS "maxTrackGrade" +#define TEXT_FIELD_LEN 40 + +/** + * @brief Layout properties in Dialog +*/ struct sLayoutProps { - char title1[TITLEMAXLEN]; - char title2[TITLEMAXLEN]; - SCALEINX_T curScaleInx; - SCALEDESCINX_T curScaleDescInx; - GAUGEINX_T curGaugeInx; - DIST_T minTrackRadius; - DIST_T maxTrackGrade; - coOrd roomSize; - DynString backgroundFileName; - coOrd backgroundPos; - ANGLE_T backgroundAngle; - int backgroundScreen; - double backgroundSize; + char title1[TITLEMAXLEN]; + char title2[TITLEMAXLEN]; + SCALEINX_T curScaleInx; + SCALEDESCINX_T curScaleDescInx; + GAUGEINX_T curGaugeInx; + DIST_T minTrackRadius; + DIST_T maxTrackGrade; + coOrd roomSize; + char backgroundTextBox[TEXT_FIELD_LEN+1]; + coOrd backgroundPos; + ANGLE_T backgroundAngle; + int backgroundScreen; + double backgroundSize; }; + +/** + * @brief Layout properties not in dialog, and save values for Cancel +*/ struct sDataLayout { - struct sLayoutProps props; - DynString fullFileName; - struct sLayoutProps *copyOfLayoutProps; + struct sLayoutProps props; + DynString fullFileName; + DynString + backgroundFileName; /** This is used to hold the entire path string */ + struct sLayoutProps + *copyOfLayoutProps; /** Copy of props used to restore initial values in the event of Cancel */ + DynString + copyBackgroundFileName; /** Copy of Background Path used to restore initial value in the event of Cancel */ }; static struct sDataLayout thisLayout = { - { "", "", -1, 0, 0, 0.0, 5.0, {0.0, 0.0}, NaS, {0.0, 0.0}, 0.0, 0, 0.0 }, - NaS, - NULL, + { "", "", 0, 0, 0, 0.0, 0.0, {0.0, 0.0}, "", {0.0, 0.0}, 0.0, 0, 0.0}, + NaS, + NaS, + NULL, + NaS }; EXPORT wIndex_t changed = 0; static paramFloatRange_t r0_90 = { 0, 90 }; +// static paramFloatRange_t r0o05_100 = { 0.05, 100 }; static paramFloatRange_t r0_10000 = { 0, 10000 }; static paramFloatRange_t r0_9999999 = { 0, 9999999 }; static paramFloatRange_t r1_9999999 = { 1, 9999999 }; @@ -84,19 +102,19 @@ static void LayoutDlgUpdate(paramGroup_p pg, int inx, void * valueP); void SetLayoutFullPath(const char *fileName) { - if (fileName && fileName[0]) { - if (DynStringSize(&thisLayout.fullFileName)) { - if (strcmp(DynStringToCStr(&thisLayout.fullFileName),fileName)==0) { - return; - } - DynStringClear(&thisLayout.fullFileName); - } - DynStringMalloc(&thisLayout.fullFileName, strlen(fileName) + 1); - DynStringCatCStr(&thisLayout.fullFileName, fileName); - } else { - DynStringMalloc(&thisLayout.fullFileName, 2); - DynStringCatCStr(&thisLayout.fullFileName, ""); - } + if (fileName && fileName[0]) { + if (DynStringSize(&thisLayout.fullFileName)) { + if (strcmp(DynStringToCStr(&thisLayout.fullFileName),fileName)==0) { + return; + } + DynStringClear(&thisLayout.fullFileName); + } + DynStringMalloc(&thisLayout.fullFileName, strlen(fileName) + 1); + DynStringCatCStr(&thisLayout.fullFileName, fileName); + } else { + DynStringMalloc(&thisLayout.fullFileName, 2); + DynStringCatCStr(&thisLayout.fullFileName, ""); + } } /** @@ -105,23 +123,44 @@ SetLayoutFullPath(const char *fileName) * \param scaleName IN name of the scale/gauge eg. HOn3 * \param defaltValue IN default value will be used if no preference is set */ - void LoadLayoutMinRadiusPref(char *scaleName, double defaultValue) { - DynString prefString = { NULL }; + DynString prefString = { NULL }; - DynStringPrintf(&prefString, MINTRACKRADIUSPREFS "-%s", scaleName); - wPrefGetFloat("misc", DynStringToCStr(&prefString), - &thisLayout.props.minTrackRadius, defaultValue); - DynStringFree(&prefString); + DynStringPrintf(&prefString, MINTRACKRADIUSPREFS "-%s", scaleName); + wPrefGetFloat("misc", DynStringToCStr(&prefString), + &thisLayout.props.minTrackRadius, defaultValue); + DynStringFree(&prefString); } +/** +* Set the maximum grade for the selected scale/gauge into the dialog +* +* \param scaleName IN name of the scale/gauge eg. HOn3 +* \param defaltValue IN default value will be used if no preference is set +*/ +void +LoadLayoutMaxGradePref(char* scaleName, double defaultValue) +{ + DynString prefString = { NULL }; + + DynStringPrintf(&prefString, MAXTRACKGRADEPREFS "-%s", scaleName); + wPrefGetFloat("misc", DynStringToCStr(&prefString), + &thisLayout.props.maxTrackGrade, defaultValue); + DynStringFree(&prefString); +} + +/** + * @brief Copy Layout title making sure there is a null at the end + * @param dest The destination to copy to + * @param src The source of the copy +*/ static void CopyLayoutTitle(char* dest, char *src) { - strncpy(dest, src, TITLEMAXLEN); - *(dest + TITLEMAXLEN - 1) = '\0'; + strncpy(dest, src, TITLEMAXLEN); + *(dest + TITLEMAXLEN - 1) = '\0'; } @@ -136,91 +175,161 @@ SetFileChanged(void) SetWindowTitle(); } +/** + * @brief Set the Layout title + * @param title The Layout title +*/ void SetLayoutTitle(char *title) { - CopyLayoutTitle(thisLayout.props.title1, title); + CopyLayoutTitle(thisLayout.props.title1, title); } +/** + * @brief Set the layout Subtitle + * @param title The Layout subtitle +*/ void SetLayoutSubtitle(char *title) { - CopyLayoutTitle(thisLayout.props.title2, title); + CopyLayoutTitle(thisLayout.props.title2, title); } +/** + * @brief Set the Layout minimum track radius. + * @param radius +*/ void SetLayoutMinTrackRadius(DIST_T radius) { - thisLayout.props.minTrackRadius = radius; + thisLayout.props.minTrackRadius = radius; } +/** + * @brief Set the Layout maximum track grade. + * @param angle The maximum track grade. +*/ void SetLayoutMaxTrackGrade(ANGLE_T angle) { - thisLayout.props.maxTrackGrade = angle; + thisLayout.props.maxTrackGrade = angle; } - +/** + * @brief Set the layout room size + * @param size The room size (coOrd) +*/ void SetLayoutRoomSize(coOrd size) { - thisLayout.props.roomSize = size; + thisLayout.props.roomSize = size; } +/** + * @brief Set the Layout scale (index). Also set the default Tie Data. + * @param scale The Layout scale index. +*/ void SetLayoutCurScale(SCALEINX_T scale) { - thisLayout.props.curScaleInx = scale; + thisLayout.props.curScaleInx = scale; } +/** + * @brief Set the Layout scale description (index) + * @param desc The Layout scale description index. +*/ void SetLayoutCurScaleDesc(SCALEDESCINX_T desc) { - thisLayout.props.curScaleDescInx = desc; + thisLayout.props.curScaleDescInx = desc; } +/** + * @brief Set the Layout current gauge (index) + * @param gauge The Layout gauge index. +*/ void SetLayoutCurGauge(GAUGEINX_T gauge) { - thisLayout.props.curGaugeInx = gauge; + thisLayout.props.curGaugeInx = gauge; } -void SetLayoutBackGroundFullPath(const char *fileName) { +/** + * @brief Set the Layout background full path. + * @param fileName The Layout background full path string. +*/ +void SetLayoutBackGroundFullPath(const char *fileName) +{ if (fileName && fileName[0]) { - if (DynStringSize(&thisLayout.props.backgroundFileName)) { - if (strcmp(DynStringToCStr(&thisLayout.props.backgroundFileName),fileName)==0) { + if (DynStringSize(&thisLayout.backgroundFileName)) { + if (strcmp(DynStringToCStr(&thisLayout.backgroundFileName),fileName)==0) { return; } - DynStringClear(&thisLayout.props.backgroundFileName); + DynStringClear(&thisLayout.backgroundFileName); } - DynStringMalloc(&thisLayout.props.backgroundFileName, strlen(fileName) + 1); - DynStringCatCStr(&thisLayout.props.backgroundFileName, fileName); + DynStringMalloc(&thisLayout.backgroundFileName, strlen(fileName) + 1); + DynStringCatCStr(&thisLayout.backgroundFileName, fileName); } else { - DynStringClear(&thisLayout.props.backgroundFileName); - DynStringCatCStr(&thisLayout.props.backgroundFileName, ""); + DynStringClear(&thisLayout.backgroundFileName); + DynStringMalloc(&thisLayout.backgroundFileName, 1); + DynStringCatCStr(&thisLayout.backgroundFileName, ""); } } -void SetLayoutBackGroundSize(double size) { - thisLayout.props.backgroundSize = size; +/** + * @brief Set the Layout background size (relative to the layout width) + * @param size The Layout background size. +*/ +void SetLayoutBackGroundSize(double size) +{ + thisLayout.props.backgroundSize = size; } -void SetLayoutBackGroundPos(coOrd pos) { +/** + * @brief Set the Layout background position (origin). + * @param pos The Layout background origin (coOrd). +*/ +void SetLayoutBackGroundPos(coOrd pos) +{ thisLayout.props.backgroundPos = pos; } -void SetLayoutBackGroundAngle(ANGLE_T angle) { +/** + * @brief Set the Layout Background angle. + * @param angle The Layout Background angle (ANGLE_T). +*/ +void SetLayoutBackGroundAngle(ANGLE_T angle) +{ thisLayout.props.backgroundAngle = angle; } -void SetLayoutBackGroundScreen(int screen) { +/** + * @brief Set the Layout Background screen (percent of transparency) + * @param screen The Screen value (0-100) +*/ +void SetLayoutBackGroundScreen(int screen) +{ thisLayout.props.backgroundScreen = screen; } /** + * Get changed-State of layout. + * + * \return true if changed + */ + +BOOL_T +GetLayoutChanged(void) +{ + return(changed > 0); +} + + +/** * Return the full filename. * * \return pointer to the full filename, should not be modified or freed @@ -230,7 +339,7 @@ char * GetLayoutFullPath() { char * s = DynStringToCStr(&thisLayout.fullFileName); - return s; + return s; } /** @@ -242,58 +351,90 @@ GetLayoutFullPath() char * GetLayoutFilename() { - char *string = DynStringToCStr(&thisLayout.fullFileName); + char *string = DynStringToCStr(&thisLayout.fullFileName); - if (string) { - return FindFilename(string); - } else { - return (NULL); - } + if (string) { + return FindFilename(string); + } else { + return (NULL); + } } +/** + * @brief Return the layout title + * @return The title string +*/ char * GetLayoutTitle() { - return (thisLayout.props.title1); + return (thisLayout.props.title1); } +/** + * @brief Return the layout subtitle + * @return The subtitle string +*/ char * GetLayoutSubtitle() { - return (thisLayout.props.title2); + return (thisLayout.props.title2); } +/** + * @brief Returns the layout minimum radius + * @return The minimum radius (DIST_T) +*/ DIST_T GetLayoutMinTrackRadius() { - return (thisLayout.props.minTrackRadius); + return (thisLayout.props.minTrackRadius); } +/** + * @brief Returns the layout maximum track grade + * @return The Maximum grade (ANGLE_T) +*/ ANGLE_T GetLayoutMaxTrackGrade() { - return (thisLayout.props.maxTrackGrade); + return (thisLayout.props.maxTrackGrade); } +/** + * @brief Returns the scale index of layout scale description + * @return The Scale Description index +*/ SCALEDESCINX_T GetLayoutCurScaleDesc() { - return (thisLayout.props.curScaleDescInx); + return (thisLayout.props.curScaleDescInx); } +/** +* @brief Returns the scale index of layout scale setting +* @return The Scale Index +*/ SCALEINX_T GetLayoutCurScale() { - return (thisLayout.props.curScaleInx); + return (thisLayout.props.curScaleInx); } +/** + * @brief Returns the Layout Background full path + * @return The Background full path +*/ char * GetLayoutBackGroundFullPath() { - char * s = DynStringToCStr(&thisLayout.props.backgroundFileName); + char * s = DynStringToCStr(&thisLayout.backgroundFileName); return s; } +/** + * @brief Returns the layout background size. + * @return The background size, or room size if zero +*/ double GetLayoutBackGroundSize() { @@ -304,18 +445,30 @@ GetLayoutBackGroundSize() } } +/** + * @brief Returns the background position (origin) + * @return The background position (coOrd) +*/ coOrd GetLayoutBackGroundPos() { return (thisLayout.props.backgroundPos); } +/** + * @brief Returns the background angle + * @return The background angle (ANGLE_T) +*/ ANGLE_T GetLayoutBackGroundAngle() { return (thisLayout.props.backgroundAngle); } +/** + * @brief Returns the background screen percent (the amount of transparency) + * @return The background Screen value (0-100) +*/ int GetLayoutBackGroundScreen() { return (thisLayout.props.backgroundScreen); @@ -338,29 +491,23 @@ GetLayoutRoomSize(coOrd *roomSize) * Layout Dialog * */ -static char backgroundFileName[STR_LONG_SIZE]; - -#define TEXT_FIELD_LEN 40 static wWin_p layoutW; +static void LayoutChange(long changes); -/************************************************************************************** -* Show only the end of the background file path including the filename in the Dialog +/** +* Show only the filename in the Dialog */ -void SetName() { - char * name = GetLayoutBackGroundFullPath(); +void SetName() +{ + char *name = GetLayoutBackGroundFullPath(); if (name && name[0]) { //Ignore "" - if (name && (strlen(name)<=TEXT_FIELD_LEN)) { - for (unsigned int i=0; i<=strlen(name);i++) { - backgroundFileName[i] = name[i]; - } - backgroundFileName[strlen(name)] = '\0'; + char *f = FindFilename(name); + if ( f ) { + strncpy( thisLayout.props.backgroundTextBox,f,TEXT_FIELD_LEN ); } else { - for (int i=TEXT_FIELD_LEN;i>=0; i--) { - backgroundFileName[i] = name[strlen(name)-(TEXT_FIELD_LEN-i)]; - } - backgroundFileName[TEXT_FIELD_LEN] = '\0'; //Insurance + thisLayout.props.backgroundTextBox[0] = '\0'; } - } else backgroundFileName[0] = '\0'; + } else { thisLayout.props.backgroundTextBox[0] = '\0'; } } static struct wFilSel_t * imageFile_fs; @@ -374,6 +521,12 @@ BOOL_T backgroundVisible = TRUE; char * noname = ""; +EXPORT wButton_p backgroundB; + +/** + * @brief Enable background visibility toggle from Menu or Button + * @param unused +*/ void BackgroundToggleShow( void * unused ) { @@ -382,18 +535,27 @@ BackgroundToggleShow( void * unused ) MainRedraw(); } +/** + * @brief Returns status of backgroundVisible + * @return backgroundVisible +*/ int GetLayoutBackGroundVisible() { return(backgroundVisible); } +/** + * @brief Returns status of layout background. + * @return true if a background is defined, false otherwise +*/ bool HasBackGround() { return(haveBackground); } -/***************************************** -* Try to load the background image file +/** +* Try to load the background image file. Display notice if failed to load. +* @return TRUE if successful, FALSE if not. */ wBool_t LoadBackGroundImage(void) @@ -410,72 +572,84 @@ LoadBackGroundImage(void) return TRUE; } -/******************************************************* +#define BACKGROUNDFILEENTRY (8) + +/** * Callback from File Select for Background Image File -* +* * \param files number of files selected (only first file is used) * \param fileName array of pointers to filenames * \param data unused * \return FALSE */ EXPORT int LoadImageFile( - int files, - char ** fileName, - void * data ) + int files, + char ** fileName, + void * data ) { - if (files >0) { - SetLayoutBackGroundFullPath( strdup(fileName[0])); + if (files >0) { + SetLayoutBackGroundFullPath( strdup(fileName[0]) ); - if (!LoadBackGroundImage()) { - SetLayoutBackGroundFullPath(noname); - backgroundVisible = FALSE; - } - else { - backgroundVisible = TRUE; - SetCurrentPath(BACKGROUNDPATHKEY, fileName[0]); - } - } else { + if (!LoadBackGroundImage()) { SetLayoutBackGroundFullPath(noname); backgroundVisible = FALSE; + } else { + backgroundVisible = TRUE; + SetCurrentPath(BACKGROUNDPATHKEY, fileName[0]); + + file_changed = TRUE; + haveBackground = TRUE; + ParamLoadControl(layout_pg_p, BACKGROUNDFILEENTRY); + + MainRedraw(); } - wControlActive((wControl_p)backgroundB, backgroundVisible); - wButtonSetBusy(backgroundB, backgroundVisible); + } else { + SetLayoutBackGroundFullPath(noname); + backgroundVisible = FALSE; + } + wControlActive((wControl_p)backgroundB, backgroundVisible); + wButtonSetBusy(backgroundB, backgroundVisible); - SetName(); - file_changed = TRUE; - ParamLoadControl(layout_pg_p, 8); - return FALSE; + SetName(); + file_changed = TRUE; + ParamLoadControl(layout_pg_p, BACKGROUNDFILEENTRY); + LayoutChange( CHANGE_BACKGROUND ); + + return FALSE; } -/********************************************************** - * Save the Background Parms - forcing a write - */ -void LayoutBackGroundSave(void) { - char * background = GetLayoutBackGroundFullPath(); +/** + * Save the Layout Background Parms in section [layout]. Force a write. +*/ +void LayoutBackGroundSave(void) +{ + char * background = GetLayoutBackGroundFullPath(); wPrefSetString("layout", "BackgroundPath", background); - wPrefSetFloat("layout", "BackgroundPosX", thisLayout.props.backgroundPos.x); - wPrefSetFloat("layout", "BackgroundPosY", thisLayout.props.backgroundPos.y); - wPrefSetFloat("layout", "BackgroundAngle", thisLayout.props.backgroundAngle); - wPrefSetInteger("layout", "BackgroundScreen", thisLayout.props.backgroundScreen); - wPrefSetFloat("layout", "BackgroundSize", thisLayout.props.backgroundSize); - - wPrefFlush(""); + wPrefSetFloat("layout", "BackgroundPosX", thisLayout.props.backgroundPos.x); + wPrefSetFloat("layout", "BackgroundPosY", thisLayout.props.backgroundPos.y); + wPrefSetFloat("layout", "BackgroundAngle", thisLayout.props.backgroundAngle); + wPrefSetInteger("layout", "BackgroundScreen", + thisLayout.props.backgroundScreen); + wPrefSetFloat("layout", "BackgroundSize", thisLayout.props.backgroundSize); + + wPrefFlush(""); } -/************************************************************ +/** * Run File Select for the Background Image File - */ +*/ static void ImageFileBrowse( void * unused ) { - imageFile_fs = wFilSelCreate( mainW, FS_LOAD, FS_PICTURES, _("Load Background"), sImageFilePattern, LoadImageFile, NULL ); + imageFile_fs = wFilSelCreate( mainW, FS_LOAD, FS_PICTURES, _("Load Background"), + sImageFilePattern, LoadImageFile, NULL ); wFilSelect( imageFile_fs, GetCurrentPath( BACKGROUNDPATHKEY ) ); return; } -/************************************************************ +/** * Remove the background Image File - */ +*/ static void ImageFileClear( void * unused) { char * noname = ""; @@ -485,24 +659,27 @@ static void ImageFileClear( void * unused) wControlActive((wControl_p)backgroundB, FALSE); file_changed = TRUE; haveBackground = false; - ParamLoadControl(layout_pg_p, 8); + ParamLoadControl(layout_pg_p, BACKGROUNDFILEENTRY); + + LayoutChange( CHANGE_BACKGROUND ); + MainRedraw(); } static paramData_t layoutPLs[] = { - { PD_FLOAT, &thisLayout.props.roomSize.x, "roomsizeX", PDO_NOPREF | PDO_DIM | PDO_NOPSHUPD | PDO_DRAW, &r1_9999999, N_("Room Width"), 0, I2VP(CHANGE_MAIN | CHANGE_MAP) }, - { PD_FLOAT, &thisLayout.props.roomSize.y, "roomsizeY", PDO_NOPREF | PDO_DIM | PDO_NOPSHUPD | PDO_DRAW | PDO_DLGHORZ, &r1_9999999, N_(" Height"), 0, I2VP(CHANGE_MAIN | CHANGE_MAP) }, - { PD_STRING, &thisLayout.props.title1, "title1", PDO_NOPSHUPD | PDO_STRINGLIMITLENGTH, NULL, N_("Layout Title"), 0, 0, sizeof(thisLayout.props.title1)}, - { PD_STRING, &thisLayout.props.title2, "title2", PDO_NOPSHUPD | PDO_STRINGLIMITLENGTH, NULL, N_("Subtitle"), 0, 0, sizeof(thisLayout.props.title2)}, + { PD_FLOAT, &thisLayout.props.roomSize.x, "roomsizeX", PDO_NOPREF | PDO_DIM | PDO_NOPSHUPD | PDO_DRAW, &r1_9999999, N_("Room Width"), 0, I2VP(CHANGE_MAIN | CHANGE_MAP) }, + { PD_FLOAT, &thisLayout.props.roomSize.y, "roomsizeY", PDO_NOPREF | PDO_DIM | PDO_NOPSHUPD | PDO_DRAW | PDO_DLGHORZ, &r1_9999999, N_(" Height"), 0, I2VP(CHANGE_MAIN | CHANGE_MAP) }, + { PD_STRING, &thisLayout.props.title1, "title1", PDO_NOPSHUPD | PDO_STRINGLIMITLENGTH, NULL, N_("Layout Title"), 0, 0, sizeof(thisLayout.props.title1)}, + { PD_STRING, &thisLayout.props.title2, "title2", PDO_NOPSHUPD | PDO_STRINGLIMITLENGTH, NULL, N_("Subtitle"), 0, 0, sizeof(thisLayout.props.title2)}, #define SCALEINX (4) - { PD_DROPLIST, &thisLayout.props.curScaleDescInx, "scale", PDO_NOPREF | PDO_NOPSHUPD | PDO_NORECORD | PDO_NOUPDACT, I2VP(180), N_("Scale"), 0, I2VP(CHANGE_SCALE) }, + { PD_DROPLIST, &thisLayout.props.curScaleDescInx, "scale", PDO_NOPREF | PDO_NOPSHUPD | PDO_NORECORD | PDO_NOUPDACT, I2VP(180), N_("Scale"), 0, I2VP(CHANGE_SCALE) }, #define GAUGEINX (5) - { PD_DROPLIST, &thisLayout.props.curGaugeInx, "gauge", PDO_NOPREF | PDO_NOPSHUPD | PDO_NORECORD | PDO_NOUPDACT | PDO_DLGHORZ, I2VP(180), N_(" Gauge"), 0, I2VP(CHANGE_SCALE) }, + { PD_DROPLIST, &thisLayout.props.curGaugeInx, "gauge", PDO_NOPREF | PDO_NOPSHUPD | PDO_NORECORD | PDO_NOUPDACT | PDO_DLGHORZ, I2VP(180), N_(" Gauge"), 0, I2VP(CHANGE_SCALE) }, #define MINRADIUSENTRY (6) - { PD_FLOAT, &thisLayout.props.minTrackRadius, "mintrackradius", PDO_DIM | PDO_NOPSHUPD | PDO_NOPREF, &r0_10000, N_("Min Track Radius"), 0, I2VP(CHANGE_MAIN | CHANGE_LIMITS) }, - { PD_FLOAT, &thisLayout.props.maxTrackGrade, "maxtrackgrade", PDO_NOPSHUPD | PDO_DLGHORZ, &r0_90, N_(" Max Track Grade (%)"), 0, I2VP(CHANGE_MAIN) }, -#define BACKGROUNDFILEENTRY (8) //Note this value used in the file section routines above - if it chnages, they will need to change - { PD_STRING, &backgroundFileName, "backgroundfile", PDO_NOPSHUPD | PDO_NORECORD|PDO_STRINGLIMITLENGTH, NULL, N_("Background File Path"), 0, I2VP(CHANGE_BACKGROUND),sizeof(backgroundFileName) }, + { PD_FLOAT, &thisLayout.props.minTrackRadius, "mintrackradius", PDO_DIM | PDO_NOPSHUPD | PDO_NOPREF, &r0_10000, N_("Min Track Radius"), 0, I2VP(CHANGE_MAIN | CHANGE_LIMITS) }, + { PD_FLOAT, &thisLayout.props.maxTrackGrade, "maxtrackgrade", PDO_NOPSHUPD | PDO_DLGHORZ, &r0_90, N_(" Max Track Grade (%)"), 0, I2VP(CHANGE_MAIN) }, +#define BACKGROUNDFILECHECK (8) //Note this value used in the file section routines above - if it changes, they will need to change + { PD_STRING, &thisLayout.props.backgroundTextBox, "backgroundfile", PDO_NOPSHUPD|PDO_NOPREF|PDO_NORECORD|PDO_STRINGLIMITLENGTH, NULL, N_("Background File Path"), 0, I2VP(CHANGE_BACKGROUND), TEXT_FIELD_LEN }, { PD_BUTTON, ImageFileBrowse, "browse", PDO_DLGHORZ, NULL, N_("Browse ...") }, { PD_BUTTON, ImageFileClear, "clear", PDO_DLGHORZ, NULL, N_("Clear") }, #define BACKGROUNDPOSX (11) @@ -518,46 +695,48 @@ static paramData_t layoutPLs[] = { { PD_MESSAGE, N_("Named Settings File"), NULL, PDO_DLGRESETMARGIN, I2VP(180) }, { PD_BUTTON, SettingsWrite, "write", PDO_DLGHORZ, 0, N_("Write"), 0, I2VP(0) }, { PD_BUTTON, SettingsRead, "read", PDO_DLGHORZ | PDO_DLGBOXEND, 0, N_("Read"), 0, I2VP(0) } - }; static paramGroup_t layoutPG = { "layout", PGO_RECORD | PGO_PREFMISC, layoutPLs, COUNT( layoutPLs ) }; +/** + * @brief Handle the Layout changes, setting the values of changed items from dialog. +*/ +static void ChangeLayout() +{ -static void ChangeLayout() { - - long changes; + long changes; - changes = GetChanges(&layoutPG); + changes = GetChanges(&layoutPG); - /* [mf Nov. 15, 2005] Get the gauge/scale settings */ - if (changes & CHANGE_SCALE) { - SetScaleGauge(thisLayout.props.curScaleDescInx, thisLayout.props.curGaugeInx); + /* [mf Nov. 15, 2005] Get the gauge/scale settings */ + if (changes & CHANGE_SCALE) { + SetScaleGauge(thisLayout.props.curScaleDescInx, thisLayout.props.curGaugeInx); file_changed = TRUE; } - /* [mf Nov. 15, 2005] end */ + /* [mf Nov. 15, 2005] end */ - if (changes & CHANGE_MAP) { - SetRoomSize(thisLayout.props.roomSize); + if (changes & CHANGE_MAP) { + SetRoomSize(thisLayout.props.roomSize); file_changed = TRUE; } - DoChangeNotification(changes); + DoChangeNotification(changes); - if (changes & CHANGE_LIMITS) { - char prefString[30]; - // now set the minimum track radius - sprintf(prefString, "minTrackRadius-%s", curScaleName); - wPrefSetFloat("misc", prefString, thisLayout.props.minTrackRadius); + if (changes & CHANGE_LIMITS) { + char prefString[30]; + // now set the minimum track radius + sprintf(prefString, "minTrackRadius-%s", curScaleName); + wPrefSetFloat("misc", prefString, thisLayout.props.minTrackRadius); file_changed = TRUE; } - if (changes & CHANGE_BACKGROUND) { + if (changes & CHANGE_BACKGROUND) { - LayoutBackGroundSave(); - file_changed = TRUE; - } + LayoutBackGroundSave(); + file_changed = TRUE; + } } /** @@ -569,15 +748,18 @@ static void ChangeLayout() { static void LayoutOk(void * unused) { ChangeLayout(); - if(file_changed){ + if(file_changed) { + LayoutBackGroundSave(); SetFileChanged(); file_changed = FALSE; } - free(thisLayout.copyOfLayoutProps); - wHide(layoutW); + free(thisLayout.copyOfLayoutProps); + DynStringFree(&thisLayout.copyBackgroundFileName); + + wHide(layoutW); - MainLayout( TRUE, TRUE ); + MainLayout( TRUE, TRUE ); } @@ -590,52 +772,102 @@ static void LayoutOk(void * unused) static void LayoutCancel(struct wWin_t *unused) { - thisLayout.props = *(thisLayout.copyOfLayoutProps); - ParamLoadControls(&layoutPG); - LayoutOk(unused); + // thisLayout.props = *(thisLayout.copyOfLayoutProps); + char* curr = DynStringToCStr(&thisLayout.backgroundFileName); + char* prev = DynStringToCStr(&thisLayout.copyBackgroundFileName); + if ((curr == NULL && prev != NULL) || (curr != NULL && prev == NULL) + || (strcmp(curr, prev) != 0) ) { + if (DynStringSize(&thisLayout.backgroundFileName)) { + DynStringClear(&thisLayout.backgroundFileName); + } + size_t bgSize = DynStringSize(&thisLayout.copyBackgroundFileName); + if ( bgSize ) { + DynStringMalloc(&thisLayout.backgroundFileName, bgSize + 1); + char* fileName = DynStringToCStr(&thisLayout.copyBackgroundFileName); + DynStringCatCStr(&thisLayout.backgroundFileName, fileName); + haveBackground = TRUE; + wDrawSetBackground( mainD.d, fileName, NULL); + } else { + haveBackground = FALSE; + wDrawSetBackground( mainD.d, NULL, NULL); + } + SetName(); + // ChangeLayout(); + } + + ParamLoadControls(&layoutPG); + + free(thisLayout.copyOfLayoutProps); + DynStringFree(&thisLayout.copyBackgroundFileName); + + wHide(layoutW); + + MainLayout( TRUE, TRUE ); } +/** + * @brief Reload Layout parameters if changes + * @param changes +*/ static void LayoutChange(long changes) { - if (changes & (CHANGE_SCALE | CHANGE_UNITS | CHANGE_BACKGROUND)) - if (layoutW != NULL && wWinIsVisible(layoutW)) { - ParamLoadControls(&layoutPG); - } + if (changes & (CHANGE_SCALE | CHANGE_UNITS | CHANGE_BACKGROUND)) + if (layoutW != NULL && wWinIsVisible(layoutW)) { + ParamLoadControls(&layoutPG); + } } +/** + * @brief Initialize Layout dialog + * @param unused +*/ void DoLayout(void * unused) { - SetLayoutRoomSize(mapD.size); + CHECK(BACKGROUNDFILEENTRY == BACKGROUNDFILECHECK); + + SetLayoutRoomSize(mapD.size); + + if (layoutW == NULL) { + layoutW = ParamCreateDialog(&layoutPG, MakeWindowTitle(_("Layout Options")), + _("Ok"), LayoutOk, LayoutCancel, TRUE, NULL, 0, LayoutDlgUpdate); + LoadScaleList((wList_p)layoutPLs[4].control); + } - if (layoutW == NULL) { - layoutW = ParamCreateDialog(&layoutPG, MakeWindowTitle(_("Layout Options")), - _("Ok"), LayoutOk, LayoutCancel, TRUE, NULL, 0, LayoutDlgUpdate); - LoadScaleList((wList_p)layoutPLs[4].control); - } + ParamControlActive(&layoutPG, BACKGROUNDFILEENTRY, FALSE); - ParamControlActive(&layoutPG, BACKGROUNDFILEENTRY, FALSE); + LoadGaugeList((wList_p)layoutPLs[5].control, + thisLayout.props.curScaleDescInx); /* set correct gauge list here */ + thisLayout.copyOfLayoutProps = malloc(sizeof(struct sLayoutProps)); - LoadGaugeList((wList_p)layoutPLs[5].control, - thisLayout.props.curScaleDescInx); /* set correct gauge list here */ - thisLayout.copyOfLayoutProps = malloc(sizeof(struct sLayoutProps)); + if (!thisLayout.copyOfLayoutProps) { + exit(1); + } + SetName(); + *(thisLayout.copyOfLayoutProps) = thisLayout.props; - if (!thisLayout.copyOfLayoutProps) { - exit(1); - } - SetName(); - *(thisLayout.copyOfLayoutProps) = thisLayout.props; + char* curr = DynStringToCStr(&thisLayout.backgroundFileName); + size_t bgSize = DynStringSize(&thisLayout.backgroundFileName); + if ( bgSize ) { + DynStringMalloc(&thisLayout.copyBackgroundFileName, bgSize + 1); + DynStringCatCStr(&thisLayout.copyBackgroundFileName, curr); + } - ParamLoadControls(&layoutPG); - wShow(layoutW); + ParamLoadControls(&layoutPG); + wShow(layoutW); } +/** + * @brief Callback for Menu and Shortcut key to open Layout Dialog. + * @param void + * @return Address of layout dialog (DoLayout) +*/ EXPORT addButtonCallBack_t LayoutInit(void) { - ParamRegister(&layoutPG); - RegisterChangeNotification(LayoutChange); - layout_p = layoutPLs; - layout_pg_p = &layoutPG; - return &DoLayout; + ParamRegister(&layoutPG); + RegisterChangeNotification(LayoutChange); + layout_p = layoutPLs; + layout_pg_p = &layoutPG; + return &DoLayout; } /** @@ -650,86 +882,98 @@ EXPORT addButtonCallBack_t LayoutInit(void) static void LayoutDlgUpdate( - paramGroup_p pg, - int inx, - void * valueP) -{ - /* did the scale change ? */ - if (inx == SCALEINX) { - char prefString[100]; - char scaleDesc[100]; - - LoadGaugeList((wList_p)layoutPLs[GAUGEINX].control, *((int *)valueP)); - // set the first entry as default, usually the standard gauge for a scale - wListSetIndex((wList_p)layoutPLs[GAUGEINX].control, 0); - - // get the minimum radius - // get the selected scale first - wListGetValues((wList_p)layoutPLs[SCALEINX].control, scaleDesc, 99, NULL, NULL); - strtok(scaleDesc, " "); - - // now get the minimum track radius - sprintf(prefString, "minTrackRadius-%s", scaleDesc); - wPrefGetFloat("misc", prefString, &thisLayout.props.minTrackRadius, 0.0); - - // put the scale's minimum value into the dialog - wStringSetValue((wString_p)layoutPLs[MINRADIUSENTRY].control, - FormatDistance(thisLayout.props.minTrackRadius)); - } - if (inx == BACKGROUNDPOSX) { - coOrd pos; - pos.x = *(double *)valueP; - pos.y = GetLayoutBackGroundPos().y; - SetLayoutBackGroundPos(pos); - MainRedraw(); - } - if (inx == BACKGROUNDPOSY) { - coOrd pos; + paramGroup_p pg, + int inx, + void * valueP) +{ + /* did the scale change ? */ + if (inx == SCALEINX) { + char prefString[130]; + char scaleDesc[100]; + + LoadGaugeList((wList_p)layoutPLs[GAUGEINX].control, *((int *)valueP)); + // set the first entry as default, usually the standard gauge for a scale + wListSetIndex((wList_p)layoutPLs[GAUGEINX].control, 0); + + // get the minimum radius + // get the selected scale first + wListGetValues((wList_p)layoutPLs[SCALEINX].control, scaleDesc, 99, NULL, NULL); + strtok(scaleDesc, " "); + + // now get the minimum track radius + sprintf(prefString, "minTrackRadius-%s", scaleDesc); + wPrefGetFloat("misc", prefString, &thisLayout.props.minTrackRadius, 0.0); + + // put the scale's minimum value into the dialog + wStringSetValue((wString_p)layoutPLs[MINRADIUSENTRY].control, + FormatDistance(thisLayout.props.minTrackRadius)); + } + if (inx == BACKGROUNDFILEENTRY) { + SetName(); + MainRedraw(); + } + if (inx == BACKGROUNDPOSX) { + coOrd pos; + pos.x = *(double *)valueP; + pos.y = GetLayoutBackGroundPos().y; + SetLayoutBackGroundPos(pos); + MainRedraw(); + } + if (inx == BACKGROUNDPOSY) { + coOrd pos; pos.y = *(double *)valueP; pos.x = GetLayoutBackGroundPos().x; SetLayoutBackGroundPos(pos); - MainRedraw(); - } - if (inx == BACKGROUNDWIDTH) { - SetLayoutBackGroundSize(*(double *)valueP); - MainRedraw(); - } - if (inx == BACKGROUNDSCREEN) { - SetLayoutBackGroundScreen(*(int *)valueP); - MainRedraw(); - } - if (inx == BACKGROUNDANGLE) { - - ANGLE_T angle = NormalizeAngle(*(double *)valueP); - wStringSetValue((wString_p)layoutPLs[BACKGROUNDANGLE].control,FormatFloat(angle)); - SetLayoutBackGroundAngle(angle); - MainRedraw(); - } - -} -/*************************************************************************************** - * Load Background Options from Saved Parms - ***************************************************************************************/ + MainRedraw(); + } + if (inx == BACKGROUNDWIDTH) { + SetLayoutBackGroundSize(*(double *)valueP); + MainRedraw(); + } + if (inx == BACKGROUNDSCREEN) { + SetLayoutBackGroundScreen(*(int *)valueP); + MainRedraw(); + } + if (inx == BACKGROUNDANGLE) { + + ANGLE_T angle = NormalizeAngle(*(double *)valueP); + wStringSetValue((wString_p)layoutPLs[BACKGROUNDANGLE].control, + FormatFloat(angle)); + SetLayoutBackGroundAngle(angle); + MainRedraw(); + } + +} +/** + * Load Background Options from Saved Parms section [layout] +*/ void -LayoutBackGroundLoad(void) { +LayoutBackGroundLoad(void) +{ SetLayoutBackGroundFullPath(wPrefGetString("layout", "BackgroundPath")); - wPrefGetFloat("layout", "BackgroundPosX", &thisLayout.props.backgroundPos.x, 0.0); - wPrefGetFloat("layout", "BackgroundPosY", &thisLayout.props.backgroundPos.y, 0.0); - wPrefGetFloat("layout", "BackgroundAngle", &thisLayout.props.backgroundAngle, 0.0); + wPrefGetFloat("layout", "BackgroundPosX", &thisLayout.props.backgroundPos.x, + 0.0); + wPrefGetFloat("layout", "BackgroundPosY", &thisLayout.props.backgroundPos.y, + 0.0); + wPrefGetFloat("layout", "BackgroundAngle", &thisLayout.props.backgroundAngle, + 0.0); long screen_long; wPrefGetInteger("layout", "BackgroundScreen", &screen_long, 0L); thisLayout.props.backgroundScreen = screen_long; - wPrefGetFloat("layout", "BackgroundSize", &thisLayout.props.backgroundSize, 0.0); + wPrefGetFloat("layout", "BackgroundSize", &thisLayout.props.backgroundSize, + 0.0); } static wBool_t inited; -/************************************************************************************** - * Either Clear Background Parms or (if the first time called) Load from Saved Parms - **************************************************************************************/ +/** + * @brief Either Clear Background Parms or (if the first time called) Load from Saved Parms + * @param clear TRUE: Background is cleared, FALSE: Background is loaded (if defined) +*/ void -LayoutBackGroundInit(BOOL_T clear) { +LayoutBackGroundInit(BOOL_T clear) +{ if (clear) { SetLayoutBackGroundFullPath(noname); SetLayoutBackGroundPos(zero); @@ -743,31 +987,48 @@ LayoutBackGroundInit(BOOL_T clear) { } char * str = GetLayoutBackGroundFullPath(); if (str && str[0]) { - haveBackground = true; - if (!LoadBackGroundImage()) { //Failed -> Wipe Out + haveBackground = true; + if (!LoadBackGroundImage()) { //Failed -> Wipe Out SetLayoutBackGroundFullPath(noname); SetLayoutBackGroundPos(zero); SetLayoutBackGroundAngle(0.0); SetLayoutBackGroundScreen(0); SetLayoutBackGroundSize(0.0); LayoutBackGroundSave(); - haveBackground = false; + haveBackground = false; } } else { haveBackground = false; + } + + if ( haveBackground ) { + char *error; + if (wDrawSetBackground( mainD.d, str, &error) == -1) { + NoticeMessage(_("Unable to load Image File - %s"),_("Ok"),NULL,error); + haveBackground = false; + } + } else { wDrawSetBackground( mainD.d, NULL, NULL); } + SetName(); } +/** + * Read the settings defined in the file from sections [misc] and [DialogItem] + * @param files Number of files chosen + * @param fileName Filename(s) shosen. Only the first is used + * @param data Not used + * @return TRUE (always) +*/ EXPORT int DoSettingsRead( - int files, - char ** fileName, - void * data ) + int files, + char ** fileName, + void * data ) { char * pref; - assert( files == 1 ); - if (fileName == NULL) wPrefsLoad(NULL); - else wPrefsLoad(fileName[0]); + CHECK( files == 1 ); + if (fileName == NULL) { wPrefsLoad(NULL); } + else { wPrefsLoad(fileName[0]); } // get the preferred scale from the new configuration file pref = wPrefGetString("misc", "scale"); if (pref) { @@ -777,13 +1038,16 @@ EXPORT int DoSettingsRead( } //Get command options wPrefGetInteger("DialogItem","cmdopt-preselect",&preSelect,preSelect); - wPrefGetInteger("DialogItem","cmdopt-rightclickmode",&rightClickMode,rightClickMode); + wPrefGetInteger("DialogItem","cmdopt-rightclickmode",&rightClickMode, + rightClickMode); wPrefGetInteger("DialogItem","cmdopt-selectmode",&selectMode,selectMode); wPrefGetInteger("DialogItem","cmdopt-selectzero",&selectZero,selectZero); //Get Toolbar showing wPrefGetInteger( "misc", "toolbarset",&toolbarSet,toolbarSet); + LayoutBackGroundInit( FALSE ); + //Redraw the screen to reflect changes MainProc( mainW, wResize_e, NULL, NULL ); return TRUE; @@ -791,34 +1055,49 @@ EXPORT int DoSettingsRead( static struct wFilSel_t * settingsRead_fs; +/** + * @brief Read button in Layout. File Open dialog to read a Settings file (*.xset) + * @param void + */ static void SettingsRead( void ) { if (settingsRead_fs == NULL) settingsRead_fs = wFilSelCreate( mainW, FS_LOAD, 0, _("Read Settings"), - _("Settings File (*.xset)|*.xset"), DoSettingsRead, NULL ); + _("Settings File (*.xset)|*.xset"), DoSettingsRead, NULL ); bExample = FALSE; wFilSelect( settingsRead_fs, wGetAppWorkDir()); } +/** + * @brief Write the settings file (after Dialog) + * @param files Number of Files selected (must be 1) + * @param fileName The selected Filename + * @param data Not used + * @return TRUE (always) +*/ static int DoSettingsWrite( - int files, - char ** fileName, - void * data ) + int files, + char ** fileName, + void * data ) { - assert( fileName != NULL ); - assert( files == 1 ); + CHECK( fileName != NULL ); + CHECK( files == 1 ); wPrefFlush(fileName[0]); return TRUE; } static struct wFilSel_t * settingsWrite_fs; +/** + * @brief Write button in Layout. File Save dialog for a settings file (*.xset) + * @param void +*/ static void SettingsWrite( void ) { ChangeLayout(); if ( settingsWrite_fs == NULL ) settingsWrite_fs = wFilSelCreate( mainW, FS_UPDATE, 0, _("Write Settings"), - _("Settings File (*.xset)|*.xset"), DoSettingsWrite, NULL ); + _("Settings File (*.xset)|*.xset"), DoSettingsWrite, NULL ); wFilSelect( settingsWrite_fs, wGetAppWorkDir()); } diff --git a/app/bin/layout.h b/app/bin/layout.h index 6e9496d..1d6c694 100644 --- a/app/bin/layout.h +++ b/app/bin/layout.h @@ -1,9 +1,9 @@ /** \file layout.h - * Layout data + * Layout data */ /* XTrkCad - Model Railroad CAD - * Copyright (C) 2017 Martin Fischer + * Copyright (C) 2017 Martin Fischer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef HAVE_LAYOUT_H @@ -25,9 +25,10 @@ #include "common.h" - +extern wButton_p backgroundB; /** background visibility control */ void SetLayoutFullPath(const char *fileName); void LoadLayoutMinRadiusPref(char *scaleName, double defaultValue); +void LoadLayoutMaxGradePref(char *scaleName, double defaultValue); void SetLayoutTitle(char *title); void SetLayoutSubtitle(char *title); void SetLayoutMinTrackRadius(DIST_T radius); @@ -36,7 +37,6 @@ void SetLayoutRoomSize(coOrd size); void SetLayoutCurScale(SCALEINX_T scale); void SetLayoutCurScaleDesc(SCALEDESCINX_T desc); void SetLayoutCurGauge(GAUGEINX_T gauge); -void SetLayoutScaleGauge(SCALEDESCINX_T desc, GAUGEINX_T gauge); void SetLayoutBackGroundFullPath(const char *fileName); void SetLayoutBackGroundSize(double size); void SetLayoutBackGroundPos(coOrd pos); @@ -45,17 +45,17 @@ void SetLayoutBackGroundScreen(int screen); int DoSettingsRead(int files, char ** fileName, void * data ); +BOOL_T GetLayoutChanged(void); char *GetLayoutFullPath(void); char *GetLayoutFilename(void); char *GetLayoutTitle(void); char *GetLayoutSubtitle(void); DIST_T GetLayoutMinTrackRadius(void); +ANGLE_T GetLayoutMaxTrackGrade(void); SCALEINX_T GetLayoutCurScale(void ); SCALEDESCINX_T GetLayoutCurScaleDesc(void); -//GAUGEINX_T GetLayoutCurGauge(void); void GetLayoutRoomSize(coOrd *roomSize); -ANGLE_T GetLayoutMaxTrackGrade(void); SCALEDESCINX_T GetLayoutCurScaleDesc(void); char *GetLayoutBackGroundFullPath(void); double GetLayoutBackGroundSize(void); diff --git a/app/bin/levenshtein.c b/app/bin/levenshtein.c index 8dc56aa..d51af01 100644 --- a/app/bin/levenshtein.c +++ b/app/bin/levenshtein.c @@ -10,63 +10,66 @@ // Returns a size_t, depicting the difference between `a` and `b`. // See <https://en.wikipedia.org/wiki/Levenshtein_distance> for more information. size_t -levenshtein_n(const char *a, const size_t length, const char *b, const size_t bLength) { - // Shortcut optimizations / degenerate cases. - if (a == b) { - return 0; - } +levenshtein_n(const char *a, const size_t length, const char *b, + const size_t bLength) +{ + // Shortcut optimizations / degenerate cases. + if (a == b) { + return 0; + } - if (length == 0) { - return bLength; - } + if (length == 0) { + return bLength; + } - if (bLength == 0) { - return length; - } + if (bLength == 0) { + return length; + } - size_t *cache = calloc(length, sizeof(size_t)); - size_t index = 0; - size_t bIndex = 0; - size_t distance; - size_t bDistance; - size_t result; - char code; + size_t *cache = calloc(length, sizeof(size_t)); + size_t index = 0; + size_t bIndex = 0; + size_t distance; + size_t bDistance; + size_t result; + char code; - // initialize the vector. - while (index < length) { - cache[index] = index + 1; - index++; - } + // initialize the vector. + while (index < length) { + cache[index] = index + 1; + index++; + } - // Loop. - while (bIndex < bLength) { - code = b[bIndex]; - result = distance = bIndex++; - index = SIZE_MAX; + // Loop. + while (bIndex < bLength) { + code = b[bIndex]; + result = distance = bIndex++; + index = SIZE_MAX; - while (++index < length) { - bDistance = code == a[index] ? distance : distance + 1; - distance = cache[index]; + while (++index < length) { + bDistance = code == a[index] ? distance : distance + 1; + distance = cache[index]; - cache[index] = result = distance > result - ? bDistance > result - ? result + 1 - : bDistance - : bDistance > distance - ? distance + 1 - : bDistance; - } - } + cache[index] = result = distance > result + ? bDistance > result + ? result + 1 + : bDistance + : bDistance > distance + ? distance + 1 + : bDistance; + } + } - free(cache); + free(cache); - return result; + return result; } size_t -levenshtein(const char *a, const char *b) { - const size_t length = strlen(a); - const size_t bLength = strlen(b); +levenshtein(const char *a, const char *b) +{ + const size_t length = strlen(a); + const size_t bLength = strlen(b); - return levenshtein_n(a, length, b, bLength); + return levenshtein_n(a, length, b, bLength); } diff --git a/app/bin/linknoteui.c b/app/bin/linknoteui.c index cb98686..a47bb58 100644 --- a/app/bin/linknoteui.c +++ b/app/bin/linknoteui.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "custom.h" @@ -29,39 +29,42 @@ #include "track.h" #include "validator.h" -extern BOOL_T inDescribeCmd; - #define DEFAULTLINKURL "http://www.xtrkcad.org/" #define DEFAULTLINKTITLE "The XTrackCAD Homepage" - -static struct extraDataNote_t noteDataInUI; +struct { + coOrd pos; + int layer; + track_p trk; + char title[TITLEMAXIMUMLENGTH]; + char url[URLMAXIMUMLENGTH]; +} linkNoteData; static void NoteLinkBrowse(void *junk); static void NoteLinkOpen(char *url ); -static paramFloatRange_t r_1000_1000 = { -1000.0, 1000.0, 80 }; -static paramData_t linkEditPLs[] = { +static paramFloatRange_t noRangeCheck = { 0.0, 0.0, 80, PDO_NORANGECHECK_HIGH | PDO_NORANGECHECK_LOW }; +static paramData_t linkNotePLs[] = { #define I_ORIGX (0) - /*0*/ { PD_FLOAT, ¬eDataInUI.pos.x, "origx", PDO_DIM, &r_1000_1000, N_("Position X") }, + /*0*/ { PD_FLOAT, &linkNoteData.pos.x, "origx", PDO_DIM|PDO_NOPREF, &noRangeCheck, N_("Position X") }, #define I_ORIGY (1) - /*1*/ { PD_FLOAT, ¬eDataInUI.pos.y, "origy", PDO_DIM, &r_1000_1000, N_("Position Y") }, + /*1*/ { PD_FLOAT, &linkNoteData.pos.y, "origy", PDO_DIM|PDO_NOPREF, &noRangeCheck, N_("Position Y") }, #define I_LAYER (2) - /*2*/ { PD_DROPLIST, ¬eDataInUI.layer, "layer", 0, I2VP(150), "Layer", 0 }, + /*2*/ { PD_DROPLIST, &linkNoteData.layer, "layer", PDO_NOPREF, I2VP(150), "Layer", 0 }, #define I_TITLE (3) - /*3*/ { PD_STRING, NULL, "title", PDO_NOPREF | PDO_STRINGLIMITLENGTH, I2VP(200), N_("Title"), 0, 0, TITLEMAXIMUMLENGTH-1 }, + /*3*/ { PD_STRING, &linkNoteData.title, "title", PDO_NOPREF | PDO_NOTBLANK, I2VP(200), N_("Title"), 0, 0, sizeof(linkNoteData.title ) }, #define I_URL (4) - /*4*/ { PD_STRING, NULL, "name", PDO_NOPREF | PDO_STRINGLIMITLENGTH, I2VP(200), N_("URL"), 0, 0, URLMAXIMUMLENGTH-1 }, + /*4*/ { PD_STRING, &linkNoteData.url, "name", PDO_NOPREF | PDO_NOTBLANK, I2VP(200), N_("URL"), 0, 0, sizeof(linkNoteData.url ) }, #define I_OPEN (5) /*5*/{ PD_BUTTON, NoteLinkBrowse, "openlink", PDO_DLGHORZ, NULL, N_("Open...") }, }; -static paramGroup_t linkEditPG = { "linkEdit", 0, linkEditPLs, COUNT( linkEditPLs ) }; -static wWin_p linkEditW; +static paramGroup_t linkNotePG = { "linkNote", 0, linkNotePLs, COUNT( linkNotePLs ) }; +static wWin_p linkNoteW; BOOL_T IsLinkNote(track_p trk) { - struct extraDataNote_t * xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); + struct extraDataNote_t * xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); return(xx->op == OP_NOTELINK); } @@ -74,7 +77,7 @@ IsLinkNote(track_p trk) */ static void NoteLinkBrowse(void *junk) { - NoteLinkOpen(noteDataInUI.noteData.linkData.url); + NoteLinkOpen(linkNoteData.url); } /** @@ -84,49 +87,33 @@ static void NoteLinkBrowse(void *junk) */ static void NoteLinkOpen(char *url) { - wOpenFileExternal(url); + wOpenFileExternal(url); } static void LinkDlgUpdate( - paramGroup_p pg, - int inx, - void * valueP) + paramGroup_p pg, + int inx, + void * valueP) { - switch (inx) { - case I_URL: - if (strlen(noteDataInUI.noteData.linkData.url) > URLMAXIMUMLENGTH) { - DynString message; - - DynStringMalloc(&message, 80); - DynStringPrintf(&message, _("The entered URL is too long. The maximum allowed length is %d. Please edit the entered value."), URLMAXIMUMLENGTH); - wNoticeEx(NT_ERROR, - DynStringToCStr(&message), - _("Re-edit"), - NULL); - DynStringFree(&message); + switch (inx) { + case I_URL: + if ( ! IsValidURL( linkNoteData.url ) ) { + printf( "URL %s is invalid\n", linkNoteData.url ); + paramData_p p = &linkNotePLs[I_URL]; + p->bInvalid = TRUE; + wWinPix_t h = wControlGetHeight(p->control); + wControlSetBalloon( p->control, 0, -h*3/4, "URL is invalid" ); + ParamHilite( p->group->win, p->control, TRUE ); } - - if (IsValidURL(noteDataInUI.noteData.linkData.url) && - (strlen(noteDataInUI.noteData.linkData.url) <= URLMAXIMUMLENGTH)) - { - wControlActive(linkEditPLs[I_OPEN].control, TRUE); - ParamDialogOkActive(&linkEditPG, TRUE); - } else { - wControlActive(linkEditPLs[I_OPEN].control, FALSE); - ParamDialogOkActive(&linkEditPG, FALSE); - } - break; + break; case I_ORIGX: case I_ORIGY: - UpdateLink(¬eDataInUI, OR_NOTE, FALSE); - break; - case I_LAYER: - UpdateLink(¬eDataInUI, LY_NOTE, FALSE); + // TODO: Redraw bitmap at new location break; default: break; - } + } } /** @@ -136,11 +123,8 @@ LinkDlgUpdate( static void LinkEditCancel( wWin_p junk) { - if (inDescribeCmd) { - UpdateFile(¬eDataInUI, CANCEL_NOTE, FALSE); - } ResetIfNotSticky(); - wHide(linkEditW); + wHide(linkNoteW); } /** @@ -153,48 +137,48 @@ LinkEditCancel( wWin_p junk) static void LinkEditOK(void *junk) { - UpdateLink(¬eDataInUI, OK_LINK, FALSE); - wHide(linkEditW); + track_p trk = linkNoteData.trk; + if ( trk == NULL ) { + // new note + trk = NewNote( -1, linkNoteData.pos, OP_NOTELINK ); + } + struct extraDataNote_t * xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); + xx->pos = linkNoteData.pos; + SetTrkLayer( trk, linkNoteData.layer ); + MyFree( xx->noteData.linkData.title ); + xx->noteData.linkData.title = MyStrdup( linkNoteData.title ); + MyFree( xx->noteData.linkData.url ); + xx->noteData.linkData.url = MyStrdup( linkNoteData.url ); + SetBoundingBox( trk, xx->pos, xx->pos ); + DrawNewTrack( trk ); + wHide(linkNoteW); ResetIfNotSticky(); SetFileChanged(); } -static void -CreateEditLinkDialog(track_p trk, char *title) +static void +CreateEditLinkDialog(char *title) { // create the dialog if necessary - if (!linkEditW) { - noteDataInUI.base.trkType = T_NOTE; - noteDataInUI.noteData.linkData.url = MyMalloc(URLMAXIMUMLENGTH); - noteDataInUI.noteData.linkData.title = MyMalloc(TITLEMAXIMUMLENGTH); - linkEditPLs[I_TITLE].valueP = noteDataInUI.noteData.linkData.title; - linkEditPLs[I_URL].valueP = noteDataInUI.noteData.linkData.url; - ParamRegister(&linkEditPG); - linkEditW = ParamCreateDialog(&linkEditPG, - "", - _("Done"), LinkEditOK, - LinkEditCancel, TRUE, NULL, - F_BLOCK, - LinkDlgUpdate); - } - - wWinSetTitle(linkEditPG.win, MakeWindowTitle(title)); - - // initialize the dialog fields - struct extraDataNote_t *xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); - noteDataInUI.pos = xx->pos; - noteDataInUI.layer = xx->layer; - noteDataInUI.trk = trk; - strscpy(noteDataInUI.noteData.linkData.url, xx->noteData.linkData.url,URLMAXIMUMLENGTH ); - strscpy(noteDataInUI.noteData.linkData.title, xx->noteData.linkData.title, TITLEMAXIMUMLENGTH ); - - FillLayerList((wList_p)linkEditPLs[I_LAYER].control); - ParamLoadControls(&linkEditPG); - + if (!linkNoteW) { + ParamRegister(&linkNotePG); + linkNoteW = ParamCreateDialog(&linkNotePG, + "", + _("Done"), LinkEditOK, + LinkEditCancel, TRUE, NULL, + F_BLOCK, + LinkDlgUpdate); + } + + wWinSetTitle(linkNotePG.win, MakeWindowTitle(title)); + + FillLayerList((wList_p)linkNotePLs[I_LAYER].control); + ParamLoadControls(&linkNotePG); + // and show the dialog - wShow(linkEditW); + wShow(linkNoteW); } /** @@ -204,7 +188,7 @@ CreateEditLinkDialog(track_p trk, char *title) void ActivateLinkNote(track_p trk) { - struct extraDataNote_t *xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); + struct extraDataNote_t *xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); NoteLinkOpen(xx->noteData.linkData.url); } @@ -219,23 +203,31 @@ void ActivateLinkNote(track_p trk) void DescribeLinkNote(track_p trk, char * str, CSIZE_T len) { - struct extraDataNote_t *xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); - DynString statusLine; - - DynStringMalloc(&statusLine, 80); - DynStringPrintf(&statusLine, - "Link: Layer=%d %-.80s (%s)", - GetTrkLayer(trk)+1, - xx->noteData.linkData.title, - xx->noteData.linkData.url); - strcpy(str, DynStringToCStr(&statusLine)); - DynStringFree(&statusLine); - - if (inDescribeCmd) { - NoteStateSave(trk); - - CreateEditLinkDialog(trk, _("Update link")); + struct extraDataNote_t *xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); + DynString statusLine; + + DynStringMalloc(&statusLine, 80); + DynStringPrintf(&statusLine, + "Weblink (%d) Layer=%d %-.80s (%s)", + GetTrkIndex(trk), + GetTrkLayer(trk)+1, + xx->noteData.linkData.title, + xx->noteData.linkData.url); + strncpy(str, DynStringToCStr(&statusLine), len-1); + str[len-1] = '\0'; + DynStringFree(&statusLine); + if ( ! inDescribeCmd ) { + return; } + + linkNoteData.pos = xx->pos; + linkNoteData.layer = GetTrkLayer( trk ); + linkNoteData.trk = trk; + strscpy( linkNoteData.url, xx->noteData.linkData.url, sizeof linkNoteData.url ); + strscpy( linkNoteData.title, xx->noteData.linkData.title, + sizeof linkNoteData.title ); + + CreateEditLinkDialog(_("Update Weblink")); } /** @@ -245,12 +237,13 @@ void DescribeLinkNote(track_p trk, char * str, CSIZE_T len) * \param the newly created trk */ -void NewLinkNoteUI(track_p trk) +void NewLinkNoteUI( coOrd pos ) { - struct extraDataNote_t *xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); - - xx->noteData.linkData.url = MyStrdup( DEFAULTLINKURL ); - xx->noteData.linkData.title = MyStrdup( DEFAULTLINKTITLE ); + linkNoteData.pos = pos; + linkNoteData.layer = curLayer; + linkNoteData.trk = NULL; + strscpy( linkNoteData.url, DEFAULTLINKURL, sizeof( linkNoteData.url ) ); + strscpy( linkNoteData.title, DEFAULTLINKTITLE, sizeof( linkNoteData.title ) ); - CreateEditLinkDialog(trk, _("Create link")); + CreateEditLinkDialog(_("Create Weblink")); } diff --git a/app/bin/lprintf.c b/app/bin/lprintf.c index 802fa24..0989ec9 100644 --- a/app/bin/lprintf.c +++ b/app/bin/lprintf.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "custom.h" @@ -46,8 +46,9 @@ static void LogInit( void ) { int inx=0; - if ( logTable_da.cnt != 0 ) + if ( logTable_da.cnt != 0 ) { return; + } DYNARR_APPEND( logTable_t, logTable_da,10); logTable(inx).name = ""; logTable(inx).level = 0; @@ -74,14 +75,17 @@ static void LogDoOpen( void ) if ( logFileName ) { logFile = fopen( logFileName, "a" ); if ( logFile == NULL ) { - NoticeMessage( MSG_OPEN_FAIL, "Continue", NULL, "Log", logFileName, strerror(errno) ); + NoticeMessage( MSG_OPEN_FAIL, "Continue", NULL, "Log", logFileName, + strerror(errno) ); perror( logFileName ); return; } } - fprintf( logFile, "# %s Version: %s, Date: %s\n", sProdName, sVersion, ctime(&logClock) ); - if ( recordF ) + fprintf( logFile, "# %s Version: %s, Date: %s\n", sProdName, sVersion, + ctime(&logClock) ); + if ( recordF ) { fprintf( recordF, "# LOG CLOCK %s\n", ctime(&logClock) ); + } } EXPORT void LogClose( void ) @@ -90,10 +94,11 @@ EXPORT void LogClose( void ) if ( logFile ) { time(&clock); fprintf( logFile, "LOG END %s\n", ctime(&clock) ); - if ( logFile != stdout ) + if ( logFile != stdout ) { fclose( logFile ); - } - logFile = NULL; + } + } + logFile = NULL; } EXPORT void LogSet( char * name, int level ) @@ -109,22 +114,24 @@ EXPORT int LogFindIndex( const char * name ) { int inx; for ( inx=0; inx<logTable_da.cnt; inx++ ) - if ( strcasecmp( logTable(inx).name, name ) == 0 ) + if ( strcasecmp( logTable(inx).name, name ) == 0 ) { return inx; + } return 0; } EXPORT void LogPrintf( - const char * format, - ... ) + const char * format, + ... ) { va_list ap; if (!logInitted) { LogDoOpen(); logInitted = TRUE; } - if ( logFile == NULL ) + if ( logFile == NULL ) { return; + } logLineNumber++; if ( logLineNumber % 100 == 0 ) { if ( recordF ) { diff --git a/app/bin/macro.c b/app/bin/macro.c index 1c38dd2..7105e98 100644 --- a/app/bin/macro.c +++ b/app/bin/macro.c @@ -1,5 +1,5 @@ /** \file macro.c - + * * Macros */ @@ -18,7 +18,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "common.h" @@ -28,13 +28,16 @@ #include "draw.h" #include "fileio.h" #include "misc.h" -#include "param.h" +#include "param.h" #include "paths.h" #include "track.h" -#include "trackx.h" #include "version.h" #include "common-ui.h" +#ifdef UTFCONVERT +#include "include/utf8convert.h" +#endif // UTFCONVERT + EXPORT long adjTimer; static void DemoInitValues( void ); @@ -67,7 +70,8 @@ static paramData_t recordPLs[] = { { PD_BUTTON, DoRecordButton, "end", PDO_NORECORD|PDO_DLGHORZ, NULL, N_("End"), BO_DISABLED, I2VP(4) }, #define I_RECTEXT (3) #define recordT ((wText_p)recordPLs[I_RECTEXT].control) - { PD_TEXT, NULL, "text", PDO_NORECORD|PDO_DLGRESIZE, &recordTextData, NULL, BT_CHARUNITS|BO_READONLY} }; + { PD_TEXT, NULL, "text", PDO_NORECORD|PDO_DLGRESIZE, &recordTextData, NULL, BT_CHARUNITS|BO_READONLY} +}; static paramGroup_t recordPG = { "record", 0, recordPLs, COUNT( recordPLs ) }; @@ -82,37 +86,45 @@ static void ComputePause( void ) long msecs; gettimeofday( &tim, NULL ); secs = tim.tv_sec-lastTim.tv_sec; - if (secs > 10 || secs < 0) + if (secs > 10 || secs < 0) { return; + } msecs = secs * 1000 + (tim.tv_usec - lastTim.tv_usec)/1000; - if (msecs > 5000) + if (msecs > 5000) { msecs = 5000; - if (msecs > 1) + } + if (msecs > 1) { fprintf( recordF, "PAUSE %ld\n", msecs ); + } lastTim = tim; } #else +#include <sys/types.h> #include <sys/timeb.h> +#include <time.h> -static struct _timeb lastTim; +static struct __timeb64 lastTim; static void ComputePause( void ) { - struct _timeb tim; + struct __timeb64 tim; long secs, msecs; _ftime( &tim ); secs = (long)(tim.time - lastTim.time); - if (secs > 10 || secs < 0) + if (secs > 10 || secs < 0) { return; + } msecs = secs * 1000; if (tim.millitm >= lastTim.millitm) { msecs += (tim.millitm - lastTim.millitm); } else { msecs -= (lastTim.millitm - tim.millitm); } - if (msecs > 5000) + if (msecs > 5000) { msecs = 5000; - if (msecs > 1) + } + if (msecs > 1) { fprintf( recordF, "PAUSE %ld\n", msecs ); + } lastTim = tim; } #endif @@ -121,19 +133,21 @@ static void ComputePause( void ) EXPORT void RecordMouse( char * name, wAction_t action, POS_T px, POS_T py ) { int keyState; - if ( action == C_MOVE || action == C_RMOVE || (action&0xFF) == C_TEXT ) + if ( action == C_MOVE || action == C_RMOVE || (action&0xFF) == C_TEXT ) { ComputePause(); - else if ( action == C_DOWN || action == C_RDOWN ) + } else if ( action == C_DOWN || action == C_RDOWN ) #ifndef WINDOWS gettimeofday( &lastTim, NULL ); #else _ftime( &lastTim ); #endif - if (action == wActionMove && !recordMouseMoves) + if (action == wActionMove && !recordMouseMoves) { return; + } keyState = wGetKeyState(); - if (keyState) + if (keyState) { fprintf( recordF, "KEYSTATE %d\n", keyState ); + } fprintf( recordF, "%s %d %0.3f %0.3f\n", name, (int)action, px, py ); fflush( recordF ); } @@ -143,25 +157,30 @@ static int StartRecord( int cnt, char ** pathName, void * context ) { time_t clock; - assert( pathName != NULL ); - assert( cnt == 1 ); + CHECK( pathName != NULL ); + CHECK( cnt == 1 ); SetCurrentPath( MACROPATHKEY, pathName[0] ); recordF = fopen(pathName[0], "w"); if (recordF==NULL) { - NoticeMessage( MSG_OPEN_FAIL, _("Continue"), NULL, _("Recording"), pathName[0], strerror(errno) ); + NoticeMessage( MSG_OPEN_FAIL, _("Continue"), NULL, _("Recording"), pathName[0], + strerror(errno) ); return FALSE; } time(&clock); - fprintf(recordF, "# %s Version: %s, Date: %s\n", sProdName, sVersion, ctime(&clock) ); + fprintf(recordF, "# %s Version: %s, Date: %s\n", sProdName, sVersion, + ctime(&clock) ); fprintf(recordF, "VERSION %d\n", iParamVersion ); fprintf(recordF, "ROOMSIZE %0.1f x %0.1f\n", mapD.size.x, mapD.size.y ); fprintf(recordF, "SCALE %s\n", curScaleName ); - fprintf(recordF, "ORIG %0.3f %0.3f %0.3f\n", mainD.scale, mainD.orig.x, mainD.orig.y ); - if ( logClock != 0 ) + fprintf(recordF, "ORIG %0.3f %0.3f %0.3f\n", mainD.scale, mainD.orig.x, + mainD.orig.y ); + if ( logClock != 0 ) { fprintf( recordF, "# LOG CLOCK %s\n", ctime(&logClock) ); - if ( logTable_da.cnt > 11 ) + } + if ( logTable_da.cnt > 11 ) { lprintf( "StartRecord( %s ) @ %s\n", pathName, ctime(&clock) ); + } ParamStartRecord(); WriteTracks( recordF, TRUE ); WriteLayers( recordF ); @@ -181,7 +200,7 @@ static void DoRecordButton( void * context ) char * cp; int len; - switch( (int)VP2L(context) ){ + switch( (int)VP2L(context) ) { case 0: /* Stop */ fprintf( recordF, "CLEAR\nMESSAGE\n"); fprintf( recordF, N_("End of Playback. Hit Step to exit\n")); @@ -198,11 +217,12 @@ static void DoRecordButton( void * context ) case 4: /* End */ if (recordingMessage) { len = wTextGetSize( recordT ); - if (len == 0) + if (len == 0) { break; + } cp = (char*)MyMalloc( len+2 ); wTextGetText( recordT, cp, len ); - if ( cp[len-1] == '\n' ) len--; + if ( cp[len-1] == '\n' ) { len--; } cp[len] = '\0'; fprintf( recordF, "%s\n%s\nSTEP\n", cp, END_MESSAGE ); MyFree( cp ); @@ -249,8 +269,10 @@ EXPORT void DoRecord( void * context ) { if (recordW == NULL) { char * title = MakeWindowTitle(_("Record")); - recordW = ParamCreateDialog( &recordPG, title, NULL, NULL, NULL, FALSE, NULL, F_RESIZE, NULL ); - recordFile_fs = wFilSelCreate( mainW, FS_SAVE, 0, title, sRecordFilePattern, StartRecord, NULL ); + recordW = ParamCreateDialog( &recordPG, title, NULL, NULL, NULL, FALSE, NULL, + F_RESIZE, NULL ); + recordFile_fs = wFilSelCreate( mainW, FS_SAVE, 0, title, sRecordFilePattern, + StartRecord, NULL ); } wTextClear( recordT ); wFilSelect( recordFile_fs, GetCurrentPath(MACROPATHKEY )); @@ -308,7 +330,8 @@ int DBMCount=0; #define DRAWALL typedef enum { FLASH_PLUS, FLASH_MINUS, REDRAW, CLEAR, DRAW, RESET, ORIG, MOVE_PLYBCK1, MOVE_PLYBCK2, MOVE_PLYBCK3, MOVE_PLYBCK4, QUIT } DrawBitMap_e; -char * DrawBitMapToString(DrawBitMap_e dbm) { +char * DrawBitMapToString(DrawBitMap_e dbm) +{ switch(dbm) { case FLASH_PLUS: return "Flsh+"; @@ -340,15 +363,16 @@ char * DrawBitMapToString(DrawBitMap_e dbm) { } static void MacroDrawBitMap( - DrawBitMap_e dbm, - wDrawBitMap_p bm, - coOrd pos, - wDrawColor color ) + DrawBitMap_e dbm, + wDrawBitMap_p bm, + coOrd pos, + wDrawColor color ) { DrawBitMap( playbackD, pos, bm, color ); // wFlush(); - LOG( log_playbackCursor, 2, ("%s %d DrawBitMap( %p %p [%0.3f %0.3f] %d )\n", DrawBitMapToString(dbm), DBMCount++, playbackD->d, bm, pos, color ) ); + LOG( log_playbackCursor, 2, ("%s %d DrawBitMap( %p %p [%0.3f %0.3f] %d )\n", + DrawBitMapToString(dbm), DBMCount++, playbackD->d, bm, pos, color ) ); } @@ -363,7 +387,7 @@ EXPORT long playbackDelay = 100; static long playbackSpeed = 2; static void SetPlaybackSpeed( - wIndex_t inx ) + wIndex_t inx ) { switch (inx) { case 0: playbackDelay = 500; break; @@ -378,7 +402,8 @@ static void SetPlaybackSpeed( } -EXPORT void RedrawPlaybackCursor() { +EXPORT void RedrawPlaybackCursor() +{ if ( playbackD && playbackBm && inPlayback) { unsigned long options = playbackD->options; playbackD->options |= DC_TEMP; @@ -404,26 +429,29 @@ EXPORT void RedrawPlaybackCursor() { } static void MoveCursor( - drawCmd_p d, - playbackProc proc, - wAction_t action, - coOrd pos, - wDrawBitMap_p bm, - wDrawColor color ) + drawCmd_p d, + playbackProc proc, + wAction_t action, + coOrd pos, + wDrawBitMap_p bm, + wDrawColor color ) { DIST_T dist; - coOrd dpos; + coOrd dpos; int i, steps; - if (d == NULL) + if (d == NULL) { return; + } if (playbackTimer == 0 /*&& !didPause*/) { playbackBm = bm; playbackColor = color; dist = FindDistance( playbackPos, pos ); steps = (int)(dist / (PixelsPerStep*d->scale/d->dpi)) + 1; - LOG( log_playbackCursor, 1, ( "PBC: [%0.3f %0.3f] - [%0.3f %0.3f] Dist:%0.3f Steps:%d\n", playbackPos.x, playbackPos.y, pos.x, pos.y, dist, steps ) ); + LOG( log_playbackCursor, 1, + ( "PBC: [%0.3f %0.3f] - [%0.3f %0.3f] Dist:%0.3f Steps:%d\n", playbackPos.x, + playbackPos.y, pos.x, pos.y, dist, steps ) ); dpos.x = (pos.x-playbackPos.x)/steps; dpos.y = (pos.y-playbackPos.y)/steps; @@ -454,11 +482,11 @@ static void MoveCursor( static void PlaybackCursor( - drawCmd_p d, - playbackProc proc, - wAction_t action, - coOrd pos, - wDrawColor color ) + drawCmd_p d, + playbackProc proc, + wAction_t action, + coOrd pos, + wDrawColor color ) { wDrawBitMap_p bm = playbackBm; playbackD = d; @@ -469,51 +497,62 @@ static void PlaybackCursor( switch( action&0xFF ) { case wActionMove: - bm = ((MyGetKeyState()&WKEY_SHIFT)?arrow0_shift_bm:(MyGetKeyState()&WKEY_CTRL)?arrow0_ctl_bm:arrow0_bm); //0 is normal, shift, ctrl + bm = ((MyGetKeyState()&WKEY_SHIFT)?arrow0_shift_bm:(MyGetKeyState()&WKEY_CTRL) + ?arrow0_ctl_bm:arrow0_bm); //0 is normal, shift, ctrl MoveCursor( d, proc, wActionMove, pos, bm, wDrawColorBlack ); break; case C_DOWN: - bm = ((MyGetKeyState()&WKEY_SHIFT)?arrow0_shift_bm:(MyGetKeyState()&WKEY_CTRL)?arrow0_ctl_bm:arrow0_bm); + bm = ((MyGetKeyState()&WKEY_SHIFT)?arrow0_shift_bm:(MyGetKeyState()&WKEY_CTRL) + ?arrow0_ctl_bm:arrow0_bm); MoveCursor( d, proc, wActionMove, pos, bm, wDrawColorBlack ); //Go to spot - bm = ((MyGetKeyState()&WKEY_SHIFT)?arrow3_shift_bm:(MyGetKeyState()&WKEY_CTRL)?arrow3_ctl_bm:arrow3_bm); + bm = ((MyGetKeyState()&WKEY_SHIFT)?arrow3_shift_bm:(MyGetKeyState()&WKEY_CTRL) + ?arrow3_ctl_bm:arrow3_bm); Flash( playbackColor=rightDragColor ); proc( action, pos ); - /* no break */ + /* no break */ case C_MOVE: - bm = ((MyGetKeyState()&WKEY_SHIFT)?arrow3_shift_bm:(MyGetKeyState()&WKEY_CTRL)?arrow3_ctl_bm:arrow3_bm); + bm = ((MyGetKeyState()&WKEY_SHIFT)?arrow3_shift_bm:(MyGetKeyState()&WKEY_CTRL) + ?arrow3_ctl_bm:arrow3_bm); MoveCursor( d, proc, C_MOVE, pos, bm, rightDragColor ); break; case C_UP: - bm = ((MyGetKeyState()&WKEY_SHIFT)?arrow3_shift_bm:(MyGetKeyState()&WKEY_CTRL)?arrow3_ctl_bm:arrow0_bm); + bm = ((MyGetKeyState()&WKEY_SHIFT)?arrow3_shift_bm:(MyGetKeyState()&WKEY_CTRL) + ?arrow3_ctl_bm:arrow0_bm); MoveCursor( d, proc, C_MOVE, pos, bm, rightDragColor ); Flash( rightDragColor ); proc( action, pos ); - bm = ((MyGetKeyState()&WKEY_SHIFT)?arrow0_shift_bm:(MyGetKeyState()&WKEY_CTRL)?arrow0_ctl_bm:arrow0_bm); + bm = ((MyGetKeyState()&WKEY_SHIFT)?arrow0_shift_bm:(MyGetKeyState()&WKEY_CTRL) + ?arrow0_ctl_bm:arrow0_bm); MoveCursor( d, NULL, 0, pos, bm, wDrawColorBlack ); break; case C_RDOWN: - bm = ((MyGetKeyState()&WKEY_SHIFT)?arrow0_shift_bm:(MyGetKeyState()&WKEY_CTRL)?arrow0_ctl_bm:arrow0_bm); + bm = ((MyGetKeyState()&WKEY_SHIFT)?arrow0_shift_bm:(MyGetKeyState()&WKEY_CTRL) + ?arrow0_ctl_bm:arrow0_bm); MoveCursor( d, proc, wActionMove, pos, bm, wDrawColorBlack ); //Go to spot - bm = ((MyGetKeyState()&WKEY_SHIFT)?arrowr3_shift_bm:(MyGetKeyState()&WKEY_CTRL)?arrowr3_ctl_bm:arrowr3_bm); + bm = ((MyGetKeyState()&WKEY_SHIFT)?arrowr3_shift_bm:(MyGetKeyState()&WKEY_CTRL) + ?arrowr3_ctl_bm:arrowr3_bm); Flash( playbackColor=leftDragColor ); proc( action, pos ); - /* no break */ + /* no break */ case C_RMOVE: - bm = ((MyGetKeyState()&WKEY_SHIFT)?arrowr3_shift_bm:(MyGetKeyState()&WKEY_CTRL)?arrowr3_ctl_bm:arrowr3_bm); + bm = ((MyGetKeyState()&WKEY_SHIFT)?arrowr3_shift_bm:(MyGetKeyState()&WKEY_CTRL) + ?arrowr3_ctl_bm:arrowr3_bm); MoveCursor( d, proc, C_RMOVE, pos, bm, leftDragColor ); break; case C_RUP: - bm = ((MyGetKeyState()&WKEY_SHIFT)?arrowr3_shift_bm:(MyGetKeyState()&WKEY_CTRL)?arrowr3_ctl_bm:arrowr3_bm); + bm = ((MyGetKeyState()&WKEY_SHIFT)?arrowr3_shift_bm:(MyGetKeyState()&WKEY_CTRL) + ?arrowr3_ctl_bm:arrowr3_bm); MoveCursor( d, proc, C_RMOVE, pos, bm, leftDragColor ); Flash( leftDragColor ); proc( action, pos ); - bm = ((MyGetKeyState()&WKEY_SHIFT)?arrow0_shift_bm:(MyGetKeyState()&WKEY_CTRL)?arrow0_ctl_bm:arrow0_bm); + bm = ((MyGetKeyState()&WKEY_SHIFT)?arrow0_shift_bm:(MyGetKeyState()&WKEY_CTRL) + ?arrow0_ctl_bm:arrow0_bm); MoveCursor( d, NULL, 0, pos, bm, wDrawColorBlack ); break; @@ -526,7 +565,7 @@ static void PlaybackCursor( case C_TEXT: proc( action, pos); - char c = action>>8; +// char c = action>>8; bm = playbackBm; break; @@ -542,11 +581,11 @@ static void PlaybackCursor( EXPORT void PlaybackMouse( - playbackProc proc, - drawCmd_p d, - wAction_t action, - coOrd pos, - wDrawColor color ) + playbackProc proc, + drawCmd_p d, + wAction_t action, + coOrd pos, + wDrawColor color ) { PlaybackCursor( d, proc, action, pos, wDrawColorBlack ); didPause = FALSE; @@ -554,16 +593,17 @@ EXPORT void PlaybackMouse( EXPORT void MovePlaybackCursor( - drawCmd_p d, - coOrd pos, - wBool_t direct, wControl_p control) + drawCmd_p d, + coOrd pos, + wBool_t direct, wControl_p control) { #ifdef MOVECURSORTOCOMMANDBUTTON // Show the cursor clicking on the command button // Not possile with current structure playbackD = &tempD; - if (!direct) + if (!direct) { MoveCursor( d, NULL, wActionMove, pos, arrow0_bm, wDrawColorBlack ); + } unsigned long options = d->options; d->options |= DC_TEMP; wBool_t bTemp = wDrawSetTempMode( d->d, TRUE ); @@ -605,18 +645,18 @@ EXPORT wWin_p demoW; EXPORT int curDemo = -1; typedef struct { - char * title; - char * fileName; - } demoList_t; + char * title; + char * fileName; +} demoList_t; static dynArr_t demoList_da; #define demoList(N) DYNARR_N( demoList_t, demoList_da, N ) static struct wFilSel_t * playbackFile_fs; typedef struct { - char * label; - playbackProc_p proc; - void * data; - } playbackProc_t; + char * label; + playbackProc_p proc; + void * data; +} playbackProc_t; static dynArr_t playbackProc_da; #define playbackProc(N) DYNARR_N( playbackProc_t, playbackProc_da, N ) @@ -655,15 +695,17 @@ static paramData_t demoPLs[] = { { PD_DROPLIST, &playbackSpeed, "speed", PDO_NORECORD|PDO_LISTINDEX|PDO_DLGHORZ, I2VP(80), N_("Speed") }, #define I_DEMOTEXT (4) #define demoT ((wText_p)demoPLs[I_DEMOTEXT].control) - { PD_TEXT, NULL, "text", PDO_NORECORD|PDO_DLGRESIZE, &demoTextData, NULL, BT_CHARUNITS|BO_READONLY} }; + { PD_TEXT, NULL, "text", PDO_NORECORD|PDO_DLGRESIZE, &demoTextData, NULL, BT_CHARUNITS|BO_READONLY} +}; static paramGroup_t demoPG = { "demo", 0, demoPLs, COUNT( demoPLs ) }; EXPORT int MyGetKeyState( void ) { - if (inPlayback) + if (inPlayback) { return playbackKeyState; - else + } else { return wGetKeyState(); + } } @@ -679,8 +721,9 @@ EXPORT void AddPlaybackProc( char * label, playbackProc_p proc, void * data ) static void PlaybackQuit( void ) { long playbackSpeed1 = playbackSpeed; - if (paramFile) + if (paramFile) { fclose( paramFile ); + } paramFile = NULL; inPlaybackQuit = TRUE; wPrefReset(); @@ -702,8 +745,8 @@ static void PlaybackQuit( void ) ClearTracks(); checkPtMark = changed = 0; RestoreTrackState(); - inPlaybackQuit = FALSE; DoSetScale( oldScaleName ); + inPlaybackQuit = FALSE; DoChangeNotification( CHANGE_ALL ); CloseDemoWindows(); curDemo = -1; @@ -719,13 +762,14 @@ static int documentEnable = 0; static int documentAutoSnapshot = 0; static drawCmd_t snapshot_d = { - NULL, - &screenDrawFuncs, - 0, - 16.0, - 0, - {0.0, 0.0}, {1.0, 1.0}, - Pix2CoOrd, CoOrd2Pix }; + NULL, + &screenDrawFuncs, + 0, + 16.0, + 0, + {0.0, 0.0}, {1.0, 1.0}, + Pix2CoOrd, CoOrd2Pix +}; static int documentSnapshotNum = 1; static int documentCopy = 0; static FILE * documentFile; @@ -735,14 +779,18 @@ EXPORT void TakeSnapshot( drawCmd_t * d ) { char * cp; wWinPix_t ix, iy; - if (d->dpi < 0) + if (d->dpi < 0) { d->dpi = mainD.dpi; - if (d->scale < 0) + } + if (d->scale < 0) { d->scale = mainD.scale; - if (d->orig.x < 0 || d->orig.y < 0) + } + if (d->orig.x < 0 || d->orig.y < 0) { d->orig = mainD.orig; - if (d->size.x < 0 || d->size.y < 0) + } + if (d->size.x < 0 || d->size.y < 0) { d->size = mainD.size; + } ix = (wWinPix_t)(d->dpi*d->size.x/d->scale); iy = (wWinPix_t)(d->dpi*d->size.y/d->scale); d->d = wBitMapCreate( ix, iy, 8 ); @@ -777,7 +825,7 @@ EXPORT void TakeSnapshot( drawCmd_t * d ) * Regression test */ static int log_regression = 0; -wBool_t bWriteEndPtDirectIndex; +static int nRegressionFail = 0; static BOOL_T DoRegression( char * sFileName ) { @@ -787,115 +835,56 @@ static BOOL_T DoRegression( char * sFileName ) long regressVersion; FILE * fRegression; char * sRegressionFile = NULL; - wBool_t bWroteActualTracks; +// wBool_t bWroteActualTracks; eRegression = log_regression > 0 ? logTable(log_regression).level : 0; char * cp; regressVersion = strtol( paramLine+16, &cp, 10 ); - if (cp == paramLine+16 ) + if (cp == paramLine+16 ) { regressVersion = PARAMVERSION; + } LOG( log_regression, 1, ("REGRESSION %s %d %s:%d %s\n", - eRegression==REGRESSION_SAVE?"SAVE":"CHECK", - regressVersion, - sFileName, paramLineNum, - cp ) ); + eRegression==REGRESSION_SAVE?"SAVE":"CHECK", + regressVersion, + sFileName, paramLineNum, + cp ) ); MakeFullpath( &sRegressionFile, workingDir, "xtrkcad.regress", NULL ); - switch ( eRegression ){ + switch ( eRegression ) { case REGRESSION_SAVE: fRegression = fopen( sRegressionFile, "a" ); if ( fRegression == NULL ) { - NoticeMessage( MSG_OPEN_FAIL, _("Continue"), NULL, _("Regression"), sFileName, strerror(errno) ); + NoticeMessage( MSG_OPEN_FAIL, _("Continue"), NULL, _("Regression"), sFileName, + strerror(errno) ); } else { fprintf( fRegression, "REGRESSION START %d %s\n", - PARAMVERSION, cp ); + PARAMVERSION, cp ); fprintf( fRegression, "# %s - %d\n", sFileName, paramLineNum ); WriteTracks( fRegression, FALSE ); fprintf( fRegression, "REGRESSION END\n" ); fclose( fRegression ); } while ( fgets(paramLine, STR_LONG_SIZE, paramFile) != NULL ) { - if ( strncmp( paramLine, "REGRESSION END", 14 ) == 0) + if ( strncmp( paramLine, "REGRESSION END", 14 ) == 0) { break; + } } break; case REGRESSION_CHECK: case REGRESSION_QUIET: oldParamVersion = paramVersion; - paramVersion = regressVersion; - bWroteActualTracks = FALSE; - track_p to_first_save = to_first; - track_p* to_last_save = to_last; - while ( GetNextLine() ) { - if ( paramLine[0] == '#' ) - continue; - // Read Expected track - to_first = NULL; - to_last = &to_first; - paramVersion = regressVersion; - if ( !ReadTrack( paramLine ) ) { - if ( paramFile == NULL ) - return FALSE; - break; - } - if ( to_first == NULL ) { - // Something bad happened - break; - } - track_cp tExpected = to_first; - to_first = to_first_save; - // Find corresponding Actual track - track_cp tActual = FindTrack( GetTrkIndex( tExpected ) ); - strcat( message, "Regression " ); - if ( ! CompareTrack( tActual, tExpected ) ) { - // Actual doesn't match Expected - LOG( log_regression, 1, (" FAIL: %s", message) ); - fRegression = fopen( sRegressionFile, "a" ); - if ( fRegression == NULL ) { - NoticeMessage( MSG_OPEN_FAIL, _("Continue"), NULL, _("Regression"), sRegressionFile, strerror(errno) ); - break; - } - fprintf( fRegression, "REGRESSION FAIL %d\n", - PARAMVERSION ); - fprintf( fRegression, "# %s - %d\n", sFileName, paramLineNum ); - fprintf( fRegression, "# %s", message ); - if ( !bWroteActualTracks ) { - // Print Actual tracks - fprintf( fRegression, "Actual Tracks\n" ); - paramVersion = PARAMVERSION; - WriteTracks( fRegression, FALSE ); - bWroteActualTracks = TRUE; - } - // Print Expected track - to_first = tExpected; - fprintf( fRegression, "Expected Track\n" ); - WriteTracks( fRegression, FALSE ); - fclose( fRegression ); - strcat( message, "Continue test?" ); - if ( eRegression == REGRESSION_CHECK ) { - int rc = wNoticeEx( NT_ERROR, message, _("Stop"), _("Continue") ); - if ( !rc ) { - while ( GetNextLine() && - strncmp( paramLine, "REGRESSION END", 14 ) != 0 ) - ; - break; - } - } - } - // Delete Expected track - to_first = tExpected; - to_last = &to_first; - FreeTrack( tExpected ); - } - to_first = to_first_save; - to_last = to_last_save; - if ( strncmp( paramLine, "REGRESSION END", 14 ) != 0 ) - InputError( "Expected REGRESSION END", TRUE ); + int nFail = CheckRegressionResult( regressVersion, sFileName, + eRegression == REGRESSION_QUIET ); paramVersion = oldParamVersion; + if ( nFail < 0 ) { + return FALSE; + } + nRegressionFail += nFail; break; case REGRESSION_NONE: default: while ( GetNextLine() ) { - if ( strncmp( paramLine, "REGRESSION END", 14 ) == 0 ) + if ( strncmp( paramLine, "REGRESSION END", 14 ) == 0 ) { break; + } } break; } @@ -905,7 +894,7 @@ static BOOL_T DoRegression( char * sFileName ) } static void EnableButtons( - BOOL_T enable ) + BOOL_T enable ) { wButtonSetBusy( demoStep, !enable ); wButtonSetBusy( demoNext, !enable ); @@ -917,7 +906,7 @@ static void EnableButtons( } EXPORT void PlaybackMessage( - char * line ) + char * line ) { char * cp; wTextAppend( demoT, _(line) ); @@ -966,6 +955,7 @@ static void PlaybackSetup( void ) paramTogglePlaybackHilite = FALSE; CompoundClearDemoDefns(); SaveLayers(); + nRegressionFail = 0; } @@ -975,7 +965,7 @@ static void Playback( void ) POS_T zoom; wIndex_t inx; long timeout; - static enum { pauseCmd, mouseCmd, otherCmd } thisCmd, lastCmd; + static enum { pauseCmd, mouseCmd, otherCmd } thisCmd/*, lastCmd*/; size_t len; static wBool_t demoWinOnTop = FALSE; coOrd roomSize; @@ -985,7 +975,7 @@ static void Playback( void ) useCurrentLayer = FALSE; inPlayback = TRUE; EnableButtons( FALSE ); - lastCmd = otherCmd; +// lastCmd = otherCmd; playbackTimer = 0; if (demoWinOnTop) { wWinTop( mainW ); @@ -995,9 +985,11 @@ static void Playback( void ) while (TRUE) { if ( ! inPlayback ) // User pressed Quit + { break; + } if ( paramFile == NULL || - fgets(paramLine, STR_LONG_SIZE, paramFile) == NULL ) { + fgets(paramLine, STR_LONG_SIZE, paramFile) == NULL ) { paramTogglePlaybackHilite = FALSE; CloseDemoWindows(); if (paramFile) { @@ -1009,17 +1001,19 @@ static void Playback( void ) documentFile = NULL; } Reset(); - if (curDemo < 0 || curDemo >= demoList_da.cnt) + if (curDemo < 0 || curDemo >= demoList_da.cnt) { break; + } demoFileName = strdup(demoList(curDemo).fileName ); paramFile = fopen( demoFileName, "r" ); if ( paramFile == NULL ) { - NoticeMessage( MSG_OPEN_FAIL, _("Continue"), NULL, _("Demo"), demoFileName, strerror(errno) ); + NoticeMessage( MSG_OPEN_FAIL, _("Continue"), NULL, _("Demo"), demoFileName, + strerror(errno) ); inPlayback = FALSE; SetUserLocale(); return; } - + paramFileName = strdup( demoFileName ); playbackColor=wDrawColorBlack; paramLineNum = 0; @@ -1032,7 +1026,8 @@ static void Playback( void ) DoChangeNotification( CHANGE_ALL ); CompoundClearDemoDefns(); if ( fgets(paramLine, STR_LONG_SIZE, paramFile) == NULL ) { - NoticeMessage( MSG_CANT_READ_DEMO, _("Continue"), NULL, sProdName, demoFileName ); + NoticeMessage( MSG_CANT_READ_DEMO, _("Continue"), NULL, sProdName, + demoFileName ); fclose( paramFile ); paramFile = NULL; inPlayback = FALSE; @@ -1054,8 +1049,9 @@ static void Playback( void ) } thisCmd = otherCmd; paramLineNum++; - if (showParamLineNum) + if (showParamLineNum) { InfoCount( paramLineNum ); + } Stripcr( paramLine ); if (paramLine[0] == '#') { /* comment */ @@ -1077,7 +1073,8 @@ static void Playback( void ) demoWinOnTop = TRUE; } if ( documentAutoSnapshot ) { - snapshot_d.dpi=snapshot_d.scale=snapshot_d.orig.x=snapshot_d.orig.y=snapshot_d.size.x=snapshot_d.size.y=-1; + snapshot_d.dpi=snapshot_d.scale=snapshot_d.orig.x=snapshot_d.orig.y= + snapshot_d.size.x=snapshot_d.size.y=-1; TakeSnapshot(&snapshot_d); } if (playbackNonStop) { @@ -1096,8 +1093,12 @@ static void Playback( void ) demoWinOnTop = TRUE; while ( ( fgets( paramLine, STR_LONG_SIZE, paramFile ) ) != NULL ) { paramLineNum++; - if ( IsEND( END_MESSAGE ) ) +#ifdef UTFCONVERT + ConvertUTF8ToSystem(paramLine); +#endif + if ( IsEND( END_MESSAGE ) ) { break; + } if ( strncmp(paramLine, "STEP", 3) == 0 ) { wWinTop( demoW ); demoWinOnTop = TRUE; @@ -1109,8 +1110,9 @@ static void Playback( void ) PlaybackMessage( paramLine ); } } else if (strncmp( paramLine, "ROOMSIZE ", 9 ) == 0) { - if (ParseRoomSize( paramLine+9, &roomSize )) + if (ParseRoomSize( paramLine+9, &roomSize )) { SetRoomSize( roomSize ); + } } else if (strncmp( paramLine, "SCALE ", 6 ) == 0) { DoSetScale( paramLine+6 ); } else if (strncmp( paramLine, "REDRAW", 6 ) == 0) { @@ -1128,24 +1130,28 @@ static void Playback( void ) } else if (strncmp( paramLine, "VERSION", 7 ) == 0) { paramVersion = atol( paramLine+8 ); if ( paramVersion > iParamVersion ) { - NoticeMessage( MSG_PLAYBACK_VERSION_UPGRADE, _("Ok"), NULL, paramVersion, iParamVersion, sProdName ); + NoticeMessage( MSG_PLAYBACK_VERSION_UPGRADE, _("Ok"), NULL, paramVersion, + iParamVersion, sProdName ); break; } if ( paramVersion < iMinParamVersion ) { - NoticeMessage( MSG_PLAYBACK_VERSION_DOWNGRADE, _("Ok"), NULL, paramVersion, iMinParamVersion, sProdName ); + NoticeMessage( MSG_PLAYBACK_VERSION_DOWNGRADE, _("Ok"), NULL, paramVersion, + iMinParamVersion, sProdName ); break; } } else if (strncmp( paramLine, "ORIG ", 5 ) == 0) { - if ( !GetArgs( paramLine+5, "fff", &zoom, &x, &y ) ) + if ( !GetArgs( paramLine+5, "fff", &zoom, &x, &y ) ) { continue; + } if (zoom == 0.0) { double scale_x = mapD.size.x/(mainD.size.x/mainD.scale); double scale_y = mapD.size.y/(mainD.size.y/mainD.scale); - if (scale_x<scale_y) + if (scale_x<scale_y) { scale_x = scale_y; + } scale_x = ceil(scale_x); - if (scale_x < 1) scale_x = 1; - if (scale_x > MAX_MAIN_SCALE) scale_x = MAX_MAIN_SCALE; + if (scale_x < 1) { scale_x = 1; } + if (scale_x > MAX_MAIN_SCALE) { scale_x = MAX_MAIN_SCALE; } zoom = scale_x; } mainD.scale = zoom; @@ -1163,12 +1169,15 @@ static void Playback( void ) paramTogglePlaybackHilite = TRUE; didPause = TRUE; - if ( !GetArgs( paramLine+6, "l", &timeout ) ) + if ( !GetArgs( paramLine+6, "l", &timeout ) ) { continue; - if (timeout > 10000) + } + if (timeout > 10000) { timeout = 1000; - if (playbackTimer == 0) + } + if (playbackTimer == 0) { wPause( timeout*playbackDelay/100 ); + } wFlush(); if (demoWinOnTop) { wWinTop( mainW ); @@ -1180,8 +1189,9 @@ static void Playback( void ) if (playbackTimer == 0) { timeout = bigPause*playbackDelay/100; - if (timeout <= dragTimeout) + if (timeout <= dragTimeout) { timeout = dragTimeout+1; + } wPause( timeout ); } } else if (strncmp( paramLine, "KEYSTATE ", 9 ) == 0 ) { @@ -1189,12 +1199,15 @@ static void Playback( void ) playbackKeyState = atoi( paramLine+9 ); } else { playbackKeyState = 0; - if ( strchr( paramLine+9, 'S' ) ) + if ( strchr( paramLine+9, 'S' ) ) { playbackKeyState |= WKEY_SHIFT; - if ( strchr( paramLine+9, 'C' ) ) + } + if ( strchr( paramLine+9, 'C' ) ) { playbackKeyState |= WKEY_CTRL; - if ( strchr( paramLine+9, 'A' ) ) + } + if ( strchr( paramLine+9, 'A' ) ) { playbackKeyState |= WKEY_ALT; + } } } else if (strncmp( paramLine, "TIMESTART", 9 ) == 0 ) { playbackTimer = wGetTimer(); @@ -1211,23 +1224,26 @@ static void Playback( void ) wTextAppend( demoT, wMemStats() ); wTextAppend( demoT, "\n" ); } else if (strncmp( paramLine, "SNAPSHOT", 8 ) == 0 ) { - if ( !documentEnable ) + if ( !documentEnable ) { continue; - snapshot_d.dpi=snapshot_d.scale=snapshot_d.orig.x=snapshot_d.orig.y=snapshot_d.size.x=snapshot_d.size.y=-1; + } + snapshot_d.dpi=snapshot_d.scale=snapshot_d.orig.x=snapshot_d.orig.y= + snapshot_d.size.x=snapshot_d.size.y=-1; cp = paramLine+8; - while (*cp && isspace((unsigned char)*cp)) cp++; - if (snapshot_d.dpi = strtod( cp, &cq ), cp == cq) + while (*cp && isspace((unsigned char)*cp)) { cp++; } + if (snapshot_d.dpi = strtod( cp, &cq ), cp == cq) { snapshot_d.dpi = -1; - else if (snapshot_d.scale = strtod( cq, &cp ), cp == cq) + } else if (snapshot_d.scale = strtod( cq, &cp ), cp == cq) { snapshot_d.scale = -1; - else if (snapshot_d.orig.x = strtod( cp, &cq ), cp == cq) + } else if (snapshot_d.orig.x = strtod( cp, &cq ), cp == cq) { snapshot_d.orig.x = -1; - else if (snapshot_d.orig.y = strtod( cq, &cp ), cp == cq) + } else if (snapshot_d.orig.y = strtod( cq, &cp ), cp == cq) { snapshot_d.orig.y = -1; - else if (snapshot_d.size.x = strtod( cp, &cq ), cp == cq) + } else if (snapshot_d.size.x = strtod( cp, &cq ), cp == cq) { snapshot_d.size.x = -1; - else if (snapshot_d.size.y = strtod( cq, &cp ), cp == cq) + } else if (snapshot_d.size.y = strtod( cq, &cp ), cp == cq) { snapshot_d.size.y = -1; + } TakeSnapshot(&snapshot_d); } else if (strncmp( paramLine, "DOCUMENT ON", 11 ) == 0 ) { documentCopy = documentEnable; @@ -1236,16 +1252,18 @@ static void Playback( void ) } else if (strncmp( paramLine, "DOCUMENT COPY", 13 ) == 0 ) { while ( ( fgets( paramLine, STR_LONG_SIZE, paramFile ) ) != NULL ) { paramLineNum++; - if ( IsEND( END_MESSAGE ) ) + if ( IsEND( END_MESSAGE ) ) { break; - if ( documentCopy && documentFile ) + } + if ( documentCopy && documentFile ) { fprintf( documentFile, "%s", paramLine ); + } } } else if ( strncmp( paramLine, "DEMOINIT", 8 ) == 0 ) { DemoInitValues(); } else if ( strncmp( paramLine, "REGRESSION START", 16 ) == 0 ) { DoRegression( curDemo < 1 ? paramFileName : - demoList(curDemo-1).fileName ); + demoList(curDemo-1).fileName ); } else { if (strncmp( paramLine, "MOUSE ", 6 ) == 0) { thisCmd = mouseCmd; @@ -1253,14 +1271,18 @@ static void Playback( void ) if (strncmp( paramLine, "MAP ", 6 ) == 0) { thisCmd = mouseCmd; } +#ifdef UTFCONVERT + ConvertUTF8ToSystem(paramLine); +#endif for ( inx=0; inx<playbackProc_da.cnt; inx++ ) { len = strlen(playbackProc(inx).label); if (strncmp( paramLine, playbackProc(inx).label, len ) == 0) { if (playbackProc(inx).data == NULL) { - while (paramLine[len] == ' ') len++; + while (paramLine[len] == ' ') { len++; } playbackProc(inx).proc( paramLine+len ); - } else + } else { playbackProc(inx).proc( (char*)playbackProc(inx).data ); + } break; } } @@ -1272,7 +1294,7 @@ static void Playback( void ) NoticeMessage( MSG_PLAYBACK_UNK_CMD, _("Ok"), NULL, paramLineNum, paramLine ); } } - lastCmd = thisCmd; +// lastCmd = thisCmd; wFlush(); if (pauseDemo) { EnableButtons( TRUE ); @@ -1298,13 +1320,14 @@ static void Playback( void ) static int StartPlayback( int cnt, char **pathName, void * context ) { - assert( pathName != NULL ); - assert( cnt ==1 ); + CHECK( pathName != NULL ); + CHECK( cnt ==1 ); SetCurrentPath( MACROPATHKEY, pathName[0] ); paramFile = fopen( pathName[0], "r" ); if ( paramFile == NULL ) { - NoticeMessage( MSG_OPEN_FAIL, _("Continue"), NULL, _("Playback"), pathName[0], strerror(errno) ); + NoticeMessage( MSG_OPEN_FAIL, _("Continue"), NULL, _("Playback"), pathName[0], + strerror(errno) ); return FALSE; } @@ -1328,7 +1351,6 @@ static void DoDemoButton( void * command ) case 0: /* step */ playbackNonStop = (wGetKeyState() & WKEY_SHIFT) != 0; - paramHiliteFast = (wGetKeyState() & WKEY_CTRL) != 0; Playback(); break; case 1: @@ -1336,15 +1358,17 @@ static void DoDemoButton( void * command ) DoSaveAs( NULL ); } else { /* next */ - if (paramFile) + if (paramFile) { fclose(paramFile); + } paramFile = NULL; wTextClear( demoT ); if ( (wGetKeyState()&WKEY_SHIFT)!=0 ) { - if ( curDemo >= 2 ) + if ( curDemo >= 2 ) { curDemo -= 2; - else + } else { curDemo = 0; + } } Playback(); } @@ -1372,11 +1396,11 @@ static void DoDemoButton( void * command ) static void DemoDlgUpdate( - paramGroup_p pg, - int inx, - void * valueP ) + paramGroup_p pg, + int inx, + void * valueP ) { - if ( inx != I_DEMOSPEED ) return; + if ( inx != I_DEMOSPEED ) { return; } SetPlaybackSpeed( (wIndex_t)*(long*)valueP ); } @@ -1384,7 +1408,8 @@ static void DemoDlgUpdate( static void CreateDemoW( void ) { char * title = MakeWindowTitle(_("Demo")); - demoW = ParamCreateDialog( &demoPG, title, NULL, NULL, NULL, FALSE, NULL, F_RESIZE, DemoDlgUpdate ); + demoW = ParamCreateDialog( &demoPG, title, NULL, NULL, NULL, FALSE, NULL, + F_RESIZE, DemoDlgUpdate ); wListAddValue( demoSpeedL, _("Slowest"), NULL, I2VP(0) ); wListAddValue( demoSpeedL, _("Slow"), NULL, I2VP(1) ); @@ -1393,14 +1418,16 @@ static void CreateDemoW( void ) wListAddValue( demoSpeedL, _("Faster"), NULL, I2VP(4) ); wListAddValue( demoSpeedL, _("Fastest"), NULL, I2VP(5) ); wListSetIndex( demoSpeedL, (wIndex_t)playbackSpeed ); - playbackFile_fs = wFilSelCreate( mainW, FS_LOAD, 0, title, sRecordFilePattern, StartPlayback, NULL ); + playbackFile_fs = wFilSelCreate( mainW, FS_LOAD, 0, title, sRecordFilePattern, + StartPlayback, NULL ); } EXPORT void DoPlayBack( void * context ) { - if (demoW == NULL) + if (demoW == NULL) { CreateDemoW(); + } wButtonSetLabel( demoNext, _("Save") ); wFilSelect( playbackFile_fs, GetCurrentPath(MACROPATHKEY)); } @@ -1414,82 +1441,84 @@ EXPORT void DoPlayBack( void * context ) */ static char * demoInitParams[] = { - "layout title1 XTrackCAD", - "layout title2 Demo", - "GROUP layout", - "display tunnels 1", - "display endpt 2", - "display labelenable 0", - "display description-fontsize 48", - "display labelscale 8", - "display layoutlabels 6", - "display tworailscale 16", - "display tiedraw 0", - "pref mingridspacing 5", - "pref balloonhelp 1", - "display hotbarlabels 1", - "display mapscale 64", - "display livemap 0", - "display carhotbarlabels 1", - "display hideTrainsInTunnels 0", - "GROUP display", - "pref turntable-angle 15.00", - "cmdopt preselect 1", - "pref coupling-speed-max 100", - "cmdopt rightclickmode 0", - "GROUP cmdopt", - "pref checkpoint 0", - "pref units 0", - "pref dstfmt 1", - "pref anglesystem 0", - "pref minlength 0.100", - "pref connectdistance 0.100", - "pref connectangle 1.000", - "pref dragpixels 20", - "pref dragtimeout 500", - "display autoPan 0", - "display listlabels 7", - "layout mintrackradius 1.000", - "layout maxtrackgrade 5.000", - "display trainpause 300", - "GROUP pref", - "rgbcolor snapgrid 65280", - "rgbcolor marker 16711680", - "rgbcolor border 0", - "rgbcolor crossmajor 16711680", - "rgbcolor crossminor 255", - "rgbcolor normal 0", - "rgbcolor selected 16711680", - "rgbcolor profile 16711935", - "rgbcolor exception 16711808", - "rgbcolor tie 16744448", - "GROUP rgbcolor", - "easement val 0.000", - "easement r 0.000", - "easement x 0.000", - "easement l 0.000", - "GROUP easement", - "grid horzspacing 12.000", - "grid horzdivision 12", - "grid horzenable 0", - "grid vertspacing 12.000", - "grid vertdivision 12", - "grid vertenable 0", - "grid origx 0.000", - "grid origy 0.000", - "grid origa 0.000", - "grid show 0", - "GROUP grid", - "misc toolbarset 65535", - "misc cur-turnout-ep 0", - "GROUP misc", - "sticky set 67108479", /* 0x3fffe7f - all but Helix and Turntable */ - "GROUP sticky", - "turnout hide 0", - "layer button-count 10", - "cmdopt selectmode 0", - "cmdopt selectzero 1", - NULL }; + "layout title1 XTrackCAD", + "layout title2 Demo", + "GROUP layout", + "display tunnels 1", + "display endpt 2", + "display labelenable 0", + "display description-fontsize 48", + "display labelscale 8", + "display layoutlabels 6", + "display tworailscale 16", + "display tiedraw 0", + "pref mingridspacing 5", + "pref balloonhelp 1", + "display hotbarlabels 1", + "display mapscale 64", + "display livemap 0", + "display carhotbarlabels 1", + "display hideTrainsInTunnels 0", + "GROUP display", + "pref turntable-angle 15.00", + "cmdopt preselect 1", + "pref coupling-speed-max 100", + "cmdopt rightclickmode 0", + "GROUP cmdopt", + "pref checkpoint 0", + "pref units 0", + "pref dstfmt 1", + "pref anglesystem 0", + "pref minlength 0.100", + "pref connectdistance 0.100", + "pref connectangle 1.000", + "pref dragpixels 20", + "pref dragtimeout 500", + "display autoPan 0", + "display listlabels 7", + "layout mintrackradius 1.000", + "layout maxtrackgrade 5.000", + "display trainpause 300", + "GROUP pref", + "rgbcolor snapgrid 65280", + "rgbcolor marker 16711680", + "rgbcolor border 0", + "rgbcolor crossmajor 16711680", + "rgbcolor crossminor 255", + "rgbcolor normal 0", + "rgbcolor selected 16711680", + "rgbcolor profile 16711935", + "rgbcolor exception 16711808", + "rgbcolor tie 16744448", + "GROUP rgbcolor", + "easement val 0.000", + "easement r 0.000", + "easement x 0.000", + "easement l 0.000", + "GROUP easement", + "grid horzspacing 12.000", + "grid horzdivision 12", + "grid horzenable 0", + "grid vertspacing 12.000", + "grid vertdivision 12", + "grid vertenable 0", + "grid origx 0.000", + "grid origy 0.000", + "grid origa 0.000", + "grid show 0", + "GROUP grid", + "misc toolbarset 65535", + "misc cur-turnout-ep 0", + "GROUP misc", + "sticky set 67108479", /* 0x3fffe7f - all but Helix and Turntable */ + "GROUP sticky", + "newFixedTrack hide 0", + "layer button-count 10", + "cmdopt selectmode 0", + "cmdopt selectzero 1", + "rescale change-dim 0", + NULL +}; static void DemoInitValues( void ) { @@ -1510,13 +1539,13 @@ static void DemoInitValues( void ) strcpy( scaleName, "DEMO" ); DoSetScale( scaleName ); if ( paramPlaybackProc == NULL ) { - wNoticeEx( NT_INFORMATION, _("Can not find PARAMETER playback proc"), _("Ok"), NULL ); + wNoticeEx( NT_INFORMATION, _("Can not find PARAMETER playback proc"), _("Ok"), + NULL ); return; } - paramHiliteFast = TRUE; - for ( cpp = demoInitParams; *cpp; cpp++ ) + for ( cpp = demoInitParams; *cpp; cpp++ ) { paramPlaybackProc( *cpp ); - paramHiliteFast = FALSE; + } // Have to do this manually oldMagneticSnap = MagneticSnap( TRUE ); } @@ -1525,8 +1554,9 @@ static void DemoInitValues( void ) static void DoDemo( void * demoNumber ) { - if (demoW == NULL) + if (demoW == NULL) { CreateDemoW(); + } wButtonSetLabel( demoNext, _("Next") ); curDemo = (int)VP2L(demoNumber); if ( curDemo < 0 || curDemo >= demoList_da.cnt ) { @@ -1541,39 +1571,43 @@ static void DoDemo( void * demoNumber ) static BOOL_T ReadDemo( - char * line ) + char * line ) { - static wMenu_p m; - char * cp; - char *path; - - if ( m == NULL ) - m = demoM; - - if ( strncmp( line, "DEMOGROUP ", 10 ) == 0 ) { - m = wMenuMenuCreate( demoM, NULL, _(line+10) ); - - } else if ( strncmp( line, "DEMO ", 5 ) == 0 ) { - if (line[5] != '"') - goto error; - cp = line+6; - while (*cp && *cp != '"') cp++; - if ( !*cp ) - goto error; - *cp++ = '\0'; - while (*cp && *cp == ' ') cp++; - if ( strlen(cp)==0 ) - goto error; - DYNARR_APPEND( demoList_t, demoList_da, 10 ); - demoList( demoList_da.cnt-1 ).title = MyStrdup( _(line+6) ); - MakeFullpath(&path, libDir, "demos", cp, NULL); - demoList(demoList_da.cnt - 1).fileName = path; - wMenuPushCreate( m, NULL, _(line+6), 0, DoDemo, I2VP(demoList_da.cnt-1) ); + static wMenu_p m = NULL; + char * cp; + char *path; + + if ( m == NULL ) { + m = demoM; + } + + if ( strncmp( line, "DEMOGROUP ", 10 ) == 0 ) { + m = wMenuMenuCreate( demoM, NULL, _(line+10) ); + + } else if ( strncmp( line, "DEMO ", 5 ) == 0 ) { + if (line[5] != '"') { + goto error; + } + cp = line+6; + while (*cp && *cp != '"') { cp++; } + if ( !*cp ) { + goto error; + } + *cp++ = '\0'; + while (*cp && *cp == ' ') { cp++; } + if ( strlen(cp)==0 ) { + goto error; } - return TRUE; + DYNARR_APPEND( demoList_t, demoList_da, 10 ); + demoList( demoList_da.cnt-1 ).title = MyStrdup( _(line+6) ); + MakeFullpath(&path, libDir, "demos", cp, NULL); + demoList(demoList_da.cnt - 1).fileName = path; + wMenuPushCreate( m, NULL, _(line+6), 0, DoDemo, I2VP(demoList_da.cnt-1) ); + } + return TRUE; error: - InputError( "Expected 'DEMO \"<Demo Name>\" <File Name>'", TRUE ); - return FALSE; + InputError( "Expected 'DEMO \"<Demo Name>\" <File Name>'", TRUE ); + return FALSE; } @@ -1588,17 +1622,28 @@ EXPORT BOOL_T MacroInit( void ) rightDragColor = drawColorRed; leftDragColor = drawColorBlue; - arrow0_bm = wDrawBitMapCreate( mainD.d, arrow0_width, arrow0_height, 12, 12, arrow0_bits ); - arrow0_shift_bm = wDrawBitMapCreate( mainD.d, arrow0_shift_width, arrow0_shift_height, 12, 12, arrow0_shift_bits ); - arrow0_ctl_bm = wDrawBitMapCreate( mainD.d, arrow0_ctl_width, arrow0_ctl_height, 12, 12, arrow0_ctl_bits ); - arrow3_bm = wDrawBitMapCreate( mainD.d, arrow3_width, arrow3_height, 12, 12, arrow3_bits ); - arrow3_shift_bm = wDrawBitMapCreate( mainD.d, arrow3_shift_width, arrow3_shift_height, 12, 12, arrow3_shift_bits ); - arrow3_ctl_bm = wDrawBitMapCreate( mainD.d, arrow3_ctl_width, arrow3_ctl_height, 12, 12, arrow3_ctl_bits ); - arrowr3_bm = wDrawBitMapCreate( mainD.d, arrowr3_width, arrowr3_height, 12, 12, arrowr3_bits ); - arrowr3_shift_bm = wDrawBitMapCreate( mainD.d, arrowr3_shift_width, arrowr3_shift_height, 12, 12, arrowr3_shift_bits ); - arrowr3_ctl_bm = wDrawBitMapCreate( mainD.d, arrowr3_ctl_width, arrowr3_ctl_height, 12, 12, arrowr3_ctl_bits ); - arrows_bm = wDrawBitMapCreate( mainD.d, arrows_width, arrows_height, 12, 12, arrows_bits ); - flash_bm = wDrawBitMapCreate( mainD.d, flash_width, flash_height, 12, 12, flash_bits ); + arrow0_bm = wDrawBitMapCreate( mainD.d, arrow0_width, arrow0_height, 12, 12, + arrow0_bits ); + arrow0_shift_bm = wDrawBitMapCreate( mainD.d, arrow0_shift_width, + arrow0_shift_height, 12, 12, arrow0_shift_bits ); + arrow0_ctl_bm = wDrawBitMapCreate( mainD.d, arrow0_ctl_width, arrow0_ctl_height, + 12, 12, arrow0_ctl_bits ); + arrow3_bm = wDrawBitMapCreate( mainD.d, arrow3_width, arrow3_height, 12, 12, + arrow3_bits ); + arrow3_shift_bm = wDrawBitMapCreate( mainD.d, arrow3_shift_width, + arrow3_shift_height, 12, 12, arrow3_shift_bits ); + arrow3_ctl_bm = wDrawBitMapCreate( mainD.d, arrow3_ctl_width, arrow3_ctl_height, + 12, 12, arrow3_ctl_bits ); + arrowr3_bm = wDrawBitMapCreate( mainD.d, arrowr3_width, arrowr3_height, 12, 12, + arrowr3_bits ); + arrowr3_shift_bm = wDrawBitMapCreate( mainD.d, arrowr3_shift_width, + arrowr3_shift_height, 12, 12, arrowr3_shift_bits ); + arrowr3_ctl_bm = wDrawBitMapCreate( mainD.d, arrowr3_ctl_width, + arrowr3_ctl_height, 12, 12, arrowr3_ctl_bits ); + arrows_bm = wDrawBitMapCreate( mainD.d, arrows_width, arrows_height, 12, 12, + arrows_bits ); + flash_bm = wDrawBitMapCreate( mainD.d, flash_width, flash_height, 12, 12, + flash_bits ); ParamRegister( &recordPG ); ParamRegister( &demoPG ); @@ -1608,3 +1653,20 @@ EXPORT BOOL_T MacroInit( void ) return TRUE; } + + +/** + * Run all regression tests + * + * return number of failed tests + */ +EXPORT int RegressionTestAll() +{ + playbackNonStop = TRUE; + playbackSpeed = 5; + CreateDemoW(); + curDemo = 0; + PlaybackSetup(); + Playback(); + return nRegressionFail; +} diff --git a/app/bin/manifest.c b/app/bin/manifest.c index 5fd9b5a..8adf0b1 100644 --- a/app/bin/manifest.c +++ b/app/bin/manifest.c @@ -1,55 +1,53 @@ /** \file manifest.c * JSON routines */ - /* XTrkCad - Model Railroad CAD - * Copyright (C) 2018 Adam Richards and Martin Fischer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - +/* XTrkCad - Model Railroad CAD + * Copyright (C) 2018 Adam Richards and Martin Fischer + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + #include <string.h> #include "cJSON.h" #include "fileio.h" #include "layout.h" -#include "misc2.h" #include "paths.h" #include "include/utf8convert.h" extern int log_zip; - /********************************************************** - * Build JSON Manifest - manifest.json - * There are only two objects in the root - - * - The layout object defines the correct filename for the layout - * - The dependencies object is an arraylist of included elements - * - * Each element has a name, a filename and an arch-path (where in the archive it is located) - * It may have other values - a common one the copy-path is where it was copied from the originators machine (info only) - * - * There is one reserved name - "background" which is for the image file that is used as a layout background - * - *\param IN nameOfLayout - the layout this is a manifest for - *\param IN background - the full filepath to the background image (or NULL) -> TODO this will become an array with a count - *\param IN DependencyDir - the relative path in the archive to the directory in which the included object(s) will be stored - * - *\returns a String containing the JSON object - */ +/********************************************************** + * Build JSON Manifest - manifest.json + * There are only two objects in the root - + * - The layout object defines the correct filename for the layout + * - The dependencies object is an arraylist of included elements + * + * Each element has a name, a filename and an arch-path (where in the archive it is located) + * + * There is one reserved name - "background" which is for the image file that is used as a layout background + * + *\param IN nameOfLayout - the layout this is a manifest for + *\param IN background - the full filepath to the background image (or NULL) -> TODO this will become an array with a count + *\param IN DependencyDir - the relative path in the archive to the directory in which the included object(s) will be stored + * + *\returns a String containing the JSON object + */ char* CreateManifest(char* nameOfLayout, char* background, - char* dependencyDir) + char* dependencyDir) { cJSON* manifest = cJSON_CreateObject(); if (manifest != NULL) { @@ -75,13 +73,7 @@ char* CreateManifest(char* nameOfLayout, char* background, cJSON_AddStringToObject(b_object, "filename", backg); MyFree(backg); backg = MyStrdup(background); -#ifdef UTFCONVERT - backg = Convert2UTF8(backg); - ConvertPathForward(backg); -#endif // UTFCONVERT - cJSON_AddStringToObject(b_object, "copy-path", backg); cJSON_AddStringToObject(b_object, "arch-path", dependencyDir); - MyFree(backg); cJSON_AddNumberToObject(b_object, "size", GetLayoutBackGroundSize()); cJSON_AddNumberToObject(b_object, "pos-x", GetLayoutBackGroundPos().x); cJSON_AddNumberToObject(b_object, "pos-y", GetLayoutBackGroundPos().y); @@ -121,11 +113,11 @@ char* ParseManifest(char* manifest, char* zip_directory) LOG(log_zip, 1, ("Zip-Manifest %s \n", layoutname)) #if DEBUG - fprintf(stderr, "Layout name %s \n", layoutname); + fprintf(stderr, "Layout name %s \n", layoutname); #endif cJSON* dependencies = cJSON_GetObjectItemCaseSensitive(json_manifest, - "dependencies"); + "dependencies"); cJSON* dependency; cJSON_ArrayForEach(dependency, dependencies) { cJSON* name = cJSON_GetObjectItemCaseSensitive(dependency, "name"); @@ -141,7 +133,7 @@ char* ParseManifest(char* manifest, char* zip_directory) ConvertUTF8ToSystem(path); #endif MakeFullpath(&background_file[0], zip_directory, path, - file, NULL); + file, NULL); MyFree(file); MyFree(path); #if DEBUG diff --git a/app/bin/manifest.h b/app/bin/manifest.h index 8e751f0..20de6b3 100644 --- a/app/bin/manifest.h +++ b/app/bin/manifest.h @@ -1,6 +1,6 @@ #ifndef HAVE_MANIFEST_H #define HAVE_MANIFEST_H - char* CreateManifest(char* nameOfLayout, char* background, - char* DependencyDir); - char* ParseManifest(char* manifest, char* zip_directory);
-#endif
+char* CreateManifest(char* nameOfLayout, char* background, + char* DependencyDir); +char* ParseManifest(char* manifest, char* zip_directory); +#endif diff --git a/app/bin/menu.c b/app/bin/menu.c new file mode 100644 index 0000000..ae2cfe2 --- /dev/null +++ b/app/bin/menu.c @@ -0,0 +1,1486 @@ +/* file misc.c + * Main routine and initialization for the application + */ + +/* XTrkCad - Model Railroad CAD + * Copyright (C) 2005 Dave Bullis + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + + + +#include "menu.h" +#include "common.h" +#include "compound.h" +#include "cselect.h" +#include "cundo.h" +#include "custom.h" +#include "fileio.h" +#include "layout.h" +#include "param.h" +#include "include/problemrep.h" +#include "smalldlg.h" +#include "common-ui.h" +#include "ctrain.h" + +static paramData_t menuPLs[101] = { { PD_LONG, &toolbarSet, "toolbarset" }, { + PD_LONG, &curTurnoutEp, "cur-turnout-ep" + } +}; +static paramGroup_t menuPG = { "misc", PGO_RECORD, menuPLs, 2 }; + +static void InitCmdExport( void ); + +EXPORT wMenu_p demoM; +EXPORT wMenu_p popup1M, popup2M; +static wMenu_p popup1aM, popup2aM; +static wMenu_p popup1mM, popup2mM; +EXPORT wButton_p undoB; +EXPORT wButton_p redoB; +EXPORT wButton_p zoomUpB; +EXPORT wButton_p zoomDownB; +EXPORT wButton_p zoomExtentsB; +EXPORT wButton_p mapShowB; +static wButton_p magnetsB; +EXPORT wMenuToggle_p mapShowMI; +static wMenuToggle_p magnetsMI; +EXPORT wMenuList_p winList_mi; +EXPORT wMenuList_p fileList_ml; +EXPORT wMenuToggle_p snapGridEnableMI; +EXPORT wMenuToggle_p snapGridShowMI; + + +/*--------------------------------------------------------------------*/ +typedef struct { + char * label; + wMenu_p menu; +} menuTrace_t, *menuTrace_p; +static dynArr_t menuTrace_da; +#define menuTrace(N) DYNARR_N( menuTrace_t, menuTrace_da, N ) + +static void DoMenuTrace(wMenu_p menu, const char * label, void * data) +{ + /*printf( "MENUTRACE: %s/%s\n", (char*)data, label );*/ + if (recordF) { + fprintf(recordF, "MOUSE 1 %0.3f %0.3f\n", oldMarker.x, oldMarker.y); + fprintf(recordF, "MENU %0.3f %0.3f \"%s\" \"%s\"\n", oldMarker.x, + oldMarker.y, (char*) data, label); + } +} + +EXPORT wMenu_p MenuRegister(const char * label) +{ + wMenu_p m; + menuTrace_p mt; + m = wMenuPopupCreate(mainW, label); + DYNARR_APPEND(menuTrace_t, menuTrace_da, 10); + mt = &menuTrace(menuTrace_da.cnt - 1); + mt->label = strdup(label); + mt->menu = m; + wMenuSetTraceCallBack(m, DoMenuTrace, mt->label); + return m; +} + +static void MenuPlayback(char * line) +{ + char * menuName, *itemName; + coOrd pos; + menuTrace_p mt; + + if (!GetArgs(line, "pqq", &pos, &menuName, &itemName)) { + return; + } + for (mt = &menuTrace(0); mt < &menuTrace(menuTrace_da.cnt); mt++) { + if (strcmp(mt->label, menuName) == 0) { + MovePlaybackCursor(&mainD, pos, FALSE, NULL); + oldMarker = cmdMenuPos = pos; + wMenuAction(mt->menu, _(itemName)); + return; + } + } + CHECKMSG( FALSE, ("menuPlayback: %s not found", menuName) ); +} + + +/***************************************************************************** + * + * TOOLBAR + * + */ + + +/* + * These array control the choices available in the Toolbar setup. + * For each choice, the text is given and the respective mask is + * specified in the following array. + * Note: text and choices must be given in the same order. + */ +static char *AllToolbarLabels[] = { N_("File Buttons"), N_("Print Buttons"), N_("Import/Export Buttons"), + N_("Zoom Buttons"), N_("Undo Buttons"), N_("Easement Button"), N_("SnapGrid Buttons"), + N_("Create Track Buttons"), N_("Layout Control Elements"), + N_("Modify Track Buttons"), N_("Properties/Select"), + N_("Track Group Buttons"), N_("Train Group Buttons"), + N_("Create Misc Buttons"), N_("Ruler Button"), + N_("Layer Buttons"), N_("Hot Bar"), + NULL + }; +static long AllToolbarMasks[] = { 1 << BG_FILE, 1<< BG_PRINT, 1<< BG_EXPORTIMPORT, + 1<< BG_ZOOM, 1<< BG_UNDO, 1<< BG_EASE, 1 << BG_SNAP, 1 << BG_TRKCRT, + 1<< BG_CONTROL, 1<< BG_TRKMOD, 1 << BG_SELECT, 1 << BG_TRKGRP, 1 << BG_TRAIN, + 1<< BG_MISCCRT, 1<< BG_RULER, 1 << BG_LAYER, 1 << BG_HOTBAR + }; + +static wMenuToggle_p AllToolbarMI[ COUNT( AllToolbarMasks ) ]; + +static void ToolbarAction(void * data) +{ + int inx = (int)VP2L(data); + CHECK( inx >=0 && inx < COUNT( AllToolbarMasks ) ); + wBool_t set = wMenuToggleGet( AllToolbarMI[inx] ); + long mask = AllToolbarMasks[inx]; + if (set) { + toolbarSet |= mask; + } else { + toolbarSet &= ~mask; + } + wPrefSetInteger( "misc", "toolbarset", toolbarSet ); + MainProc( mainW, wResize_e, NULL, NULL ); + if (recordF) + fprintf(recordF, "PARAMETER %s %s %ld", "misc", "toolbarset", + toolbarSet); +} + +/** + * Create the Toolbar configuration submenu. Based on two arrays of descriptions and + * masks, the toolbar submenu is created dynamically. + * + * \param toolbarM IN menu to which the toogles will be added + */ + +static void CreateToolbarM(wMenu_p toolbarM) +{ + int inx, cnt; + long *masks; + char **labels; + wBool_t set; + + cnt = COUNT(AllToolbarMasks); + masks = AllToolbarMasks; + labels = AllToolbarLabels; + for (inx = 0; inx < cnt; inx++, masks++, labels++) { + set = (toolbarSet & *masks) != 0; + AllToolbarMI[inx] = wMenuToggleCreate(toolbarM, "toolbarM", _(*labels), 0, set, + ToolbarAction, I2VP(inx)); + } +} + + +/***************************************************************************** + * + * ELEVATION HELPERS + * + */ + + +static wWin_p addElevW; +#define addElevF (wFloat_p)addElevPD.control +static DIST_T addElevValueV; +static void DoAddElev(void * unused); + +static paramFloatRange_t rn1000_1000 = { -1000.0, 1000.0 }; +static paramData_t addElevPLs[] = { { + PD_FLOAT, &addElevValueV, "value", + PDO_NOPREF|PDO_DIM, &rn1000_1000, NULL, 0 + } +}; +static paramGroup_t addElevPG = { "addElev", 0, addElevPLs, COUNT( addElevPLs ) }; + +static void DoAddElev(void * unused) +{ + ParamLoadData(&addElevPG); + AddElevations(addElevValueV); + wHide(addElevW); +} + +static void ShowAddElevations(void * unused) +{ + if (selectedTrackCount <= 0) { + ErrorMessage(MSG_NO_SELECTED_TRK); + return; + } + if (addElevW == NULL) + addElevW = ParamCreateDialog(&addElevPG, + MakeWindowTitle(_("Change Elevations")), _("Change"), DoAddElev, + wHide, FALSE, NULL, 0, NULL); + wShow(addElevW); +} + +/***************************************************************************** + * + * MOVE/ROTATE/INDEX HELPERS + * + */ + + +static wWin_p rotateW; +static wWin_p indexW; +static wWin_p moveW; +static double rotateValue; +static char trackIndex[STR_LONG_SIZE]; +static coOrd moveValue; +static rotateDialogCallBack_t rotateDialogCallBack; +static indexDialogCallBack_t indexDialogCallBack; +static moveDialogCallBack_t moveDialogCallBack; + +static void RotateEnterOk(void * unused); + +static paramFloatRange_t rn360_360 = { -360.0, 360.0, 80 }; +static paramData_t rotatePLs[] = { { PD_FLOAT, &rotateValue, "rotate", PDO_NOPREF|PDO_ANGLE|PDO_NORECORD, &rn360_360, N_("Angle:") } }; +static paramGroup_t rotatePG = { "rotate", 0, rotatePLs, COUNT( rotatePLs ) }; + +static void IndexEnterOk(void * unused); +static paramData_t indexPLs[] = { + { PD_STRING, &trackIndex, "select", PDO_NOPREF|PDO_NORECORD|PDO_STRINGLIMITLENGTH, I2VP(STR_SIZE-1), N_("Indexes:"), 0, 0, sizeof(trackIndex) } +}; +static paramGroup_t indexPG = { "index", 0, indexPLs, COUNT( indexPLs ) }; + +static paramFloatRange_t r_1000_1000 = { -1000.0, 1000.0, 80 }; +static void MoveEnterOk(void * unused); +static paramData_t movePLs[] = { + { PD_FLOAT, &moveValue.x, "moveX", PDO_NOPREF|PDO_DIM|PDO_NORECORD, &r_1000_1000, N_("Move X:") }, + { PD_FLOAT, &moveValue.y, "moveY", PDO_NOPREF|PDO_DIM|PDO_NORECORD, &r_1000_1000, N_("Move Y:") } +}; +static paramGroup_t movePG = { "move", 0, movePLs, COUNT( movePLs ) }; + +static void StartRotateDialog(void * funcVP) +{ + rotateDialogCallBack_t func = funcVP; + if (rotateW == NULL) + rotateW = ParamCreateDialog(&rotatePG, MakeWindowTitle(_("Rotate")), + _("Ok"), RotateEnterOk, wHide, FALSE, NULL, 0, NULL); + ParamLoadControls(&rotatePG); + rotateDialogCallBack = func; + wShow(rotateW); +} + +static void StartIndexDialog(void * funcVP) +{ + indexDialogCallBack_t func = funcVP; + if (indexW == NULL) + indexW = ParamCreateDialog(&indexPG, MakeWindowTitle(_("Select Index")), + _("Ok"), IndexEnterOk, wHide, FALSE, NULL, 0, NULL); + ParamLoadControls(&indexPG); + indexDialogCallBack = func; + trackIndex[0] = '\0'; + wShow(indexW); +} + +static void StartMoveDialog(void * funcVP) +{ + moveDialogCallBack_t func = funcVP; + if (moveW == NULL) + moveW = ParamCreateDialog(&movePG, MakeWindowTitle(_("Move")), _("Ok"), + MoveEnterOk, wHide, FALSE, NULL, 0, NULL); + ParamLoadControls(&movePG); + moveDialogCallBack = func; + moveValue = zero; + wShow(moveW); +} + +static void MoveEnterOk(void * unused) +{ + ParamLoadData(&movePG); + moveDialogCallBack(&moveValue); + wHide(moveW); +} + +static void IndexEnterOk(void * unused) +{ + ParamLoadData(&indexPG); + indexDialogCallBack(trackIndex); + wHide(indexW); +} + +static void RotateEnterOk(void * unused) +{ + ParamLoadData(&rotatePG); + if (angleSystem == ANGLE_POLAR) { + rotateDialogCallBack(I2VP(rotateValue * 1000)); + } else { + rotateDialogCallBack(I2VP(rotateValue * 1000)); + } + wHide(rotateW); +} + + +EXPORT void AddMoveMenu(wMenu_p m, moveDialogCallBack_t func) +{ + wMenuPushCreate(m, "", _("Enter Move ..."), 0, + StartMoveDialog, func); +} + +EXPORT void AddIndexMenu(wMenu_p m, indexDialogCallBack_t func) +{ + wMenuPushCreate(m, "cmdSelectIndex", _("Select Track Index ..."), 0, + StartIndexDialog, func); +} + +//All values multipled by 100 to support decimal points from PD_FLOAT +EXPORT void AddRotateMenu(wMenu_p m, rotateDialogCallBack_t func) +{ + wMenuPushCreate(m, "", _("180 "), 0, func, I2VP(180000)); + wMenuPushCreate(m, "", _("90 CW"), 0, func, I2VP(90000)); + wMenuPushCreate(m, "", _("45 CW"), 0, func, I2VP(45000)); + wMenuPushCreate(m, "", _("30 CW"), 0, func, I2VP(30000)); + wMenuPushCreate(m, "", _("15 CW"), 0, func, I2VP(15000)); + wMenuPushCreate(m, "", _("15 CCW"), 0, func, I2VP(360000 - 15000)); + wMenuPushCreate(m, "", _("30 CCW"), 0, func, I2VP(360000 - 30000)); + wMenuPushCreate(m, "", _("45 CCW"), 0, func, I2VP(360000 - 45000)); + wMenuPushCreate(m, "", _("90 CCW"), 0, func, I2VP(360000 - 90000)); + wMenuPushCreate(m, "", _("Enter Angle ..."), 0, + StartRotateDialog, func); +} + +/***************************************************************************** + * + * MISC HELPERS + * + */ + +static void ChkLoad(void * unused) +{ + Confirm(_("Load"), DoLoad); +} + +static void ChkExamples( void * unused ) +{ + Confirm(_("examples"), DoExamples); +} + +static void ChkRevert(void * unused) +{ + int rc; + + if (changed) { + rc = wNoticeEx(NT_WARNING, + _("Do you want to return to the last saved state?\n\n" + "Revert will cause all changes done since last save to be lost."), + _("&Revert"), _("&Cancel")); + if (rc) { + /* load the file */ + char *filename = GetLayoutFullPath(); + LoadTracks(1, &filename, I2VP(1)); //Keep background + } + } +} + +static char * fileListPathName; +static void AfterFileList(void) +{ + DoFileList(0, NULL, fileListPathName); +} + +static void ChkFileList(int index, const char * label, void * data) +{ + fileListPathName = (char*) data; + Confirm(_("Load"), AfterFileList); +} + + +static void DoCommandBIndirect(void * cmdInxP) +{ + wIndex_t cmdInx; + cmdInx = *(wIndex_t*) cmdInxP; + DoCommandB(I2VP(cmdInx)); +} + +/** + * Set magnets state + */ +EXPORT int MagneticSnap(int state) +{ + int oldState = magneticSnap; + magneticSnap = state; + wPrefSetInteger("misc", "magnets", magneticSnap); + wMenuToggleSet(magnetsMI, magneticSnap); + wButtonSetBusy(magnetsB, (wBool_t) magneticSnap); + return oldState; +} + +/** + * Toggle magnets on/off + */ +static void MagneticSnapToggle(void * unused) +{ + MagneticSnap(!magneticSnap); +} + + +EXPORT void SelectFont(void * unused) +{ + wSelectFont(_("XTrackCAD Font")); +} + + +EXPORT long stickySet = 0; +static wWin_p stickyW; +static const char * stickyLabels[33]; +static paramData_t stickyPLs[] = { { + PD_TOGGLE, &stickySet, "set", 0, + stickyLabels + } +}; +static paramGroup_t stickyPG = { "sticky", PGO_RECORD, stickyPLs, + COUNT( stickyPLs ) + }; + +static void StickyOk(void * unused) +{ + wHide(stickyW); +} + + +EXPORT void DoSticky(void * unused) +{ + if (!stickyW) + stickyW = ParamCreateDialog(&stickyPG, + MakeWindowTitle(_("Sticky Commands")), _("Ok"), StickyOk, wHide, + TRUE, NULL, 0, NULL); + ParamLoadControls(&stickyPG); + wShow(stickyW); +} + +/***************************************************************************** + * + * DEBUG DIALOG + * + */ + +static wWin_p debugW; + +static int debugCnt = 0; +static paramIntegerRange_t r0_100 = { 0, 100, 80 }; +static void DebugOk(void * unused); +static paramData_t debugPLs[30]; +static paramData_t p0[] = { + { PD_BUTTON, TestMallocs, "test", PDO_DLGHORZ, NULL, N_("Test Mallocs") } +}; +static long debug_values[30]; +static int debug_index[30]; + +static paramGroup_t debugPG = { "debug", 0, debugPLs, 0 }; + +static void DebugOk(void * unused) +{ + for (int i = 0; i<debugCnt; i++) { + logTable(debug_index[i]).level = debug_values[i]; + } + wHide(debugW); +} + +static void CreateDebugW(void) +{ + debugPG.paramCnt = debugCnt+1; + ParamRegister(&debugPG); + debugW = ParamCreateDialog(&debugPG, MakeWindowTitle(_("Debug")), _("Ok"), + DebugOk, wHide, FALSE, NULL, 0, NULL); + wHide(debugW); +} + +static void InitDebug(const char * label, long * valueP) +{ + CHECK( debugCnt+1 < COUNT( debugPLs ) ); + memset(&debugPLs[debugCnt+1], 0, sizeof debugPLs[debugCnt]); + debugPLs[debugCnt+1].type = PD_LONG; + debugPLs[debugCnt+1].valueP = valueP; + debugPLs[debugCnt+1].nameStr = label; + debugPLs[debugCnt+1].winData = &r0_100; + debugPLs[debugCnt+1].winLabel = label; + debugCnt++; +} + +static void DebugInit(void * unused) +{ + + if (!debugW) { + debugPLs[0] = p0[0]; + BOOL_T default_line = FALSE; + debugCnt = 0; //Reset to start building the dynamic dialog over again + int i = 0; + for ( int inx=0; inx<logTable_da.cnt; inx++ ) { + if (logTable(inx).name[0]) { + debug_values[i] = logTable(inx).level; + debug_index[i] = inx; + InitDebug(logTable(inx).name,&debug_values[i]); + i++; + } else { + if (!default_line) { + debug_values[i] = logTable(inx).level; + debug_index[i] = inx; + InitDebug("Default Trace",&debug_values[i]); + i++; + default_line = TRUE; + } + } + } + + //ParamCreateControls( &debugPG, NULL ); + CreateDebugW(); + } + ParamLoadControls( &debugPG ); + wShow(debugW); +} + + +/***************************************************************************** + * + * ENABLE MENUS + * + */ + +EXPORT void EnableMenus( void ) +{ + int inx; + BOOL_T enable; + for (inx = 0; inx < menuPG.paramCnt; inx++) { + if (menuPG.paramPtr[inx].control == NULL) { + continue; + } + if ((menuPG.paramPtr[inx].option & IC_SELECTED) && selectedTrackCount <= 0) { + enable = FALSE; + } else if ((programMode == MODE_TRAIN + && (menuPG.paramPtr[inx].option & (IC_MODETRAIN_TOO | IC_MODETRAIN_ONLY)) + == 0) + || (programMode != MODE_TRAIN + && (menuPG.paramPtr[inx].option & IC_MODETRAIN_ONLY) != 0)) { + enable = FALSE; + } else { + enable = TRUE; + } + wMenuPushEnable((wMenuPush_p) menuPG.paramPtr[inx].control, enable); + } +} +/***************************************************************************** + * + * RECENT MESSAGES LIST + * + */ + +static wMenuList_p messageList_ml; +#define MESSAGE_LIST_EMPTY N_("No Messages") + +EXPORT void MessageListAppend( + char * cp1, + const char * msgSrc ) +{ + static wBool_t messageListIsEmpty = TRUE; + if ( messageListIsEmpty ) { + wMenuListDelete(messageList_ml, _(MESSAGE_LIST_EMPTY)); + messageListIsEmpty = FALSE; + } + wMenuListAdd(messageList_ml, 0, cp1, _(msgSrc)); +} + + +static void ShowMessageHelp(int index, const char * label, void * data) +{ + char msgKey[STR_SIZE], *cp, *msgSrc; + msgSrc = (char*) data; + if (!msgSrc) { + return; + } + cp = strchr(msgSrc, '\t'); + if (cp == NULL) { + sprintf(msgKey, _("No help for %s"), msgSrc); + wNoticeEx( NT_INFORMATION, msgKey, _("Ok"), NULL); + return; + } + memcpy(msgKey, msgSrc, cp - msgSrc); + msgKey[cp - msgSrc] = 0; + wHelp(msgKey); +} + +/***************************************************************************** + * + * Balloon Help + * + */ + +// defined in ${BUILDIR}/app/bin/bllnhlp.c +extern wBalloonHelp_t balloonHelp[]; + +#ifdef DEBUG +#define CHECK_BALLOONHELP +/*#define CHECK_UNUSED_BALLOONHELP*/ +#endif +#ifdef CHECK_UNUSED_BALLOONHELP +static void ShowUnusedBalloonHelp(void); +#endif + + +#ifdef CHECK_UNUSED_BALLOONHELP +int * balloonHelpCnts; +#endif + +EXPORT const char * GetBalloonHelpStr(const char * helpKey) +{ + wBalloonHelp_t * bh; +#ifdef CHECK_UNUSED_BALLOONHELP + if ( balloonHelpCnts == NULL ) { + for ( bh=balloonHelp; bh->name; bh++ ); + balloonHelpCnts = (int*)malloc( (sizeof *(int*)0) * (bh-balloonHelp) ); + memset( balloonHelpCnts, 0, (sizeof *(int*)0) * (bh-balloonHelp) ); + } +#endif + for (bh = balloonHelp; bh->name; bh++) { + if (strcmp(bh->name, helpKey) == 0) { +#ifdef CHECK_UNUSED_BALLOONHELP + balloonHelpCnts[(bh-balloonHelp)]++; +#endif + return _(bh->value); + } + } +#ifdef CHECK_BALLOONHELP + fprintf( stderr, _("No balloon help for %s\n"), helpKey ); +#endif + return _("No Help"); +} + +#ifdef CHECK_UNUSED_BALLOONHELP +static void ShowUnusedBalloonHelp( void ) +{ + int cnt; + for ( cnt=0; balloonHelp[cnt].name; cnt++ ) + if ( balloonHelpCnts[cnt] == 0 ) { + fprintf( stderr, "unused BH %s\n", balloonHelp[cnt].name ); + } +} +#endif + +/***************************************************************************** + * + * CREATE MENUS + * + */ + + +EXPORT wButton_p AddToolbarButton(const char * helpStr, wIcon_p icon, + long options, + wButtonCallBack_p action, void * context) +{ + wButton_p bb; + wIndex_t inx; + + GetBalloonHelpStr(helpStr); + if (context == NULL) { + for (inx = 0; inx < menuPG.paramCnt; inx++) { + if (action != DoCommandB && menuPG.paramPtr[inx].valueP == I2VP(action)) { + context = &menuPG.paramPtr[inx]; + action = ParamMenuPush; + menuPG.paramPtr[inx].context = I2VP(buttonCnt); + menuPG.paramPtr[inx].option |= IC_PLAYBACK_PUSH; + break; + } + } + } + bb = wButtonCreate(mainW, 0, 0, helpStr, (char*) icon, + BO_ICON/*|((options&IC_CANCEL)?BB_CANCEL:0)*/, 0, action, context); + AddToolbarControl((wControl_p) bb, options); + return bb; +} + +#include "bitmaps/down.xpm3" +static const char * buttonGroupMenuTitle; +static const char * buttonGroupHelpKey; +static const char * buttonGroupStickyLabel; +static wMenu_p buttonGroupPopupM; +static int stickyCnt = 0; + +EXPORT void ButtonGroupBegin(const char * menuTitle, const char * helpKey, + const char * stickyLabel) +{ + buttonGroupMenuTitle = menuTitle; + buttonGroupHelpKey = helpKey; + buttonGroupStickyLabel = stickyLabel; + buttonGroupPopupM = NULL; +} + +EXPORT void ButtonGroupEnd(void) +{ + buttonGroupMenuTitle = NULL; + buttonGroupHelpKey = NULL; + buttonGroupPopupM = NULL; +} + +EXPORT wIndex_t AddMenuButton(wMenu_p menu, procCommand_t command, + const char * helpKey, const char * nameStr, wIcon_p icon, int reqLevel, + long options, long acclKey, void * context) +{ + wIndex_t buttInx = -1; + wIndex_t cmdInx; + wBool_t newButtonGroup = FALSE; + wMenu_p tm, p1m, p2m; + static wIcon_p openbuttIcon = NULL; + static wMenu_p commandsSubmenu; + static wMenu_p popup1Submenu; + static wMenu_p popup2Submenu; + + if (icon) { + if (buttonGroupPopupM != NULL) { + buttInx = buttonCnt - 2; + } else { + buttInx = buttonCnt; + AddToolbarButton(helpKey, icon, options, + DoCommandB, + I2VP(commandCnt)); + } + if (buttonGroupMenuTitle != NULL && buttonGroupPopupM == NULL) { + if (openbuttIcon == NULL) { + openbuttIcon = wIconCreatePixMap(down_xpm3[iconSize]); + } + buttonGroupPopupM = wMenuPopupCreate(mainW, buttonGroupMenuTitle); + AddToolbarButton(buttonGroupHelpKey, openbuttIcon, IC_ABUT, + (wButtonCallBack_p) wMenuPopupShow, + buttonGroupPopupM); + newButtonGroup = TRUE; + commandsSubmenu = wMenuMenuCreate(menu, "", buttonGroupMenuTitle); + if (options & IC_POPUP2) { + popup1Submenu = wMenuMenuCreate(popup1aM, "", buttonGroupMenuTitle); + popup2Submenu = wMenuMenuCreate(popup2aM, "", buttonGroupMenuTitle); + } else if (options & IC_POPUP3) { + popup1Submenu= wMenuMenuCreate(popup1mM, "", buttonGroupMenuTitle); + popup2Submenu = wMenuMenuCreate(popup2mM, "", buttonGroupMenuTitle); + + } else { + popup1Submenu = wMenuMenuCreate(popup1M, "", buttonGroupMenuTitle); + popup2Submenu = wMenuMenuCreate(popup2M, "", buttonGroupMenuTitle); + } + } + } + long stickyMask = 0; + wMenuPush_p cmdMenus[NUM_CMDMENUS] = { NULL, NULL, NULL, NULL }; + if (nameStr[0] != '\0') { + if (options & IC_STICKY) { + if (buttonGroupPopupM == NULL || newButtonGroup) { + CHECK( stickyCnt <= 32 ); + stickyCnt++; + } + if (buttonGroupPopupM == NULL) { + stickyLabels[stickyCnt - 1] = nameStr; + } else { + stickyLabels[stickyCnt - 1] = buttonGroupStickyLabel; + } + stickyLabels[stickyCnt] = NULL; + stickyMask = 1L<<(stickyCnt-1); + if ( ( options & IC_INITNOTSTICKY ) == 0 ) { + stickySet |= stickyMask; + } + } + if (buttonGroupPopupM) { + cmdMenus[0] = wMenuPushCreate(buttonGroupPopupM, + helpKey, GetBalloonHelpStr(helpKey), 0, DoCommandB, + I2VP(commandCnt)); + tm = commandsSubmenu; + p1m = popup1Submenu; + p2m = popup2Submenu; + } else { + tm = menu; + p1m = (options & IC_POPUP2) ? popup1aM : (options & IC_POPUP3) ? popup1mM : + popup1M; + p2m = (options & IC_POPUP2) ? popup2aM : (options & IC_POPUP3) ? popup2mM : + popup2M; + } + cmdMenus[1] = wMenuPushCreate(tm, helpKey, nameStr, acclKey, + DoCommandB, I2VP(commandCnt)); + if ((options & (IC_POPUP | IC_POPUP2 | IC_POPUP3))) { + if (!(options & IC_SELECTED)) { + cmdMenus[2] = wMenuPushCreate(p1m, helpKey, nameStr, + 0, DoCommandB, I2VP(commandCnt)); + } + cmdMenus[3] = wMenuPushCreate(p2m, helpKey, nameStr, 0, + DoCommandB, I2VP(commandCnt)); + } + } + + cmdInx = AddCommand(command, helpKey, nameStr, icon, reqLevel, options, + acclKey, buttInx, stickyMask, cmdMenus, context); + return cmdInx; +} + + +static void MiscMenuItemCreate(wMenu_p m1, wMenu_p m2, const char * name, + const char * label, long acclKey, void * func, long option, void * context) +{ + wMenuPush_p mp; + mp = wMenuPushCreate(m1, name, label, acclKey, ParamMenuPush, + &menuPLs[menuPG.paramCnt]); + if (m2) + wMenuPushCreate(m2, name, label, acclKey, ParamMenuPush, + &menuPLs[menuPG.paramCnt]); + menuPLs[menuPG.paramCnt].control = (wControl_p) mp; + menuPLs[menuPG.paramCnt].type = PD_MENUITEM; + menuPLs[menuPG.paramCnt].valueP = func; + menuPLs[menuPG.paramCnt].nameStr = name; + menuPLs[menuPG.paramCnt].option = option; + menuPLs[menuPG.paramCnt].context = context; + + if (name) { + GetBalloonHelpStr(name); + } + menuPG.paramCnt++; +} + + +#include "bitmaps/zoom-in.xpm3" +#include "bitmaps/zoom-choose.xpm3" +#include "bitmaps/zoom-out.xpm3" +#include "bitmaps/zoom-extent.xpm3" +#include "bitmaps/undo.xpm3" +#include "bitmaps/redo.xpm3" +// #include "bitmaps/partlist.xpm" // unused +#include "bitmaps/doc-export.xpm3" +#include "bitmaps/doc-export-bmap.xpm3" +#include "bitmaps/doc-export-dxf.xpm3" +#if XTRKCAD_CREATE_SVG +#include "bitmaps/doc-export-svg.xpm3" +#endif +#include "bitmaps/doc-import.xpm3" +#include "bitmaps/doc-import-mod.xpm3" +#include "bitmaps/doc-new.xpm3" +#include "bitmaps/doc-save.xpm3" +#include "bitmaps/doc-open.xpm3" +// #include "bitmaps/doc-print.xpm" +#include "bitmaps/doc-setup.xpm3" +#include "bitmaps/parameter.xpm3" +#include "bitmaps/map.xpm3" +#include "bitmaps/magnet.xpm3" + +//static wMenu_p toolbarM; +static addButtonCallBack_t paramFilesCallback; + +EXPORT void CreateMenus(void) +{ + wMenu_p fileM, editM, viewM, optionM, windowM, macroM, helpM, toolbarM, + manageM, addM, changeM, drawM; + wMenu_p zoomM, zoomSubM; + + wMenuPush_p zoomInM, zoomOutM, zoomExtentsM; + + wPrefGetInteger("DialogItem", "pref-iconsize", (long *) &iconSize, 0); + + wSetBalloonHelp( balloonHelp ); + fileM = wMenuBarAdd(mainW, "menuFile", _("&File")); + editM = wMenuBarAdd(mainW, "menuEdit", _("&Edit")); + viewM = wMenuBarAdd(mainW, "menuView", _("&View")); + addM = wMenuBarAdd(mainW, "menuAdd", _("&Add")); + changeM = wMenuBarAdd(mainW, "menuChange", _("&Change")); + drawM = wMenuBarAdd(mainW, "menuDraw", _("&Draw")); + manageM = wMenuBarAdd(mainW, "menuManage", _("&Manage")); + optionM = wMenuBarAdd(mainW, "menuOption", _("&Options")); + macroM = wMenuBarAdd(mainW, "menuMacro", _("&Macro")); + windowM = wMenuBarAdd(mainW, "menuWindow", _("&Window")); + helpM = wMenuBarAdd(mainW, "menuHelp", _("&Help")); + + /* + * POPUP MENUS + */ + /* Select Commands */ + /* Select All */ + /* Select All Current */ + + /* Common View Commands Menu */ + /* Zoom In/Out */ + /* Snap Grid Menu */ + /* Show/Hide Map */ + /* Show/Hide Background */ + + /* Selected Commands */ + /*--------------*/ + /* DeSelect All */ + /* Select All */ + /* Select All Current */ + /*--------------*/ + /* Quick Move */ + /* Quick Rotate */ + /* Quick Align */ + /*--------------*/ + /* Move To Current Layer */ + /* Move/Rotate Cmds */ + /* Cut/Paste/Delete */ + /* Group/Un-group Selected */ + /*----------*/ + /* Thick/Thin */ + /* Bridge/Roadbed/Tunnel */ + /* Ties/NoTies */ + /*-----------*/ + /* More Commands */ + + popup1M = wMenuPopupCreate(mainW, _("Context Commands")); + popup2M = wMenuPopupCreate(mainW, _("Shift Context Commands")); + MiscMenuItemCreate(popup1M, popup2M, "cmdUndo", _("Undo"), 0, + UndoUndo, 0, NULL); + MiscMenuItemCreate(popup1M, popup2M, "cmdRedo", _("Redo"), 0, + UndoRedo, 0, NULL); + /* Zoom */ + wMenuPushCreate(popup1M, "cmdZoomIn", _("Zoom In"), 0, + DoZoomUp, I2VP(1)); + wMenuPushCreate(popup2M, "cmdZoomIn", _("Zoom In"), 0, + DoZoomUp, I2VP(1)); + wMenuPushCreate(popup1M, "cmdZoomOut", _("Zoom Out"), 0, + DoZoomDown, I2VP(1)); + wMenuPushCreate(popup2M, "cmdZoomOut", _("Zoom Out"), 0, + DoZoomDown, I2VP(1)); + wMenuPushCreate(popup1M, "cmdZoomExtents", _("Zoom Extents"), 0, + DoZoomExtents, I2VP(1)); + wMenuPushCreate(popup2M, "cmdZoomExtents", _("Zoom Extents"), 0, + DoZoomExtents, I2VP(1)); + /* Display */ + MiscMenuItemCreate(popup1M, popup2M, "cmdGridEnable", _("Enable SnapGrid"), + 0, SnapGridEnable, 0, NULL); + MiscMenuItemCreate(popup1M, popup2M, "cmdGridShow", _("SnapGrid Show"), 0, + SnapGridShow, 0, NULL); + MiscMenuItemCreate(popup1M, popup2M, "cmdMagneticSnap", + _(" Enable Magnetic Snap"), 0, + MagneticSnapToggle, 0, NULL); + MiscMenuItemCreate(popup1M, popup2M, "cmdMapShow", _("Show/Hide Map"), 0, + MapWindowToggleShow, 0, NULL); + MiscMenuItemCreate(popup1M, popup2M, "cmdBackgroundShow", + _("Show/Hide Background"), 0, + BackgroundToggleShow, 0, NULL); + wMenuSeparatorCreate(popup1M); + wMenuSeparatorCreate(popup2M); + /* Copy/Paste */ + MiscMenuItemCreate(popup2M, NULL, "cmdCut", _("Cut"), 0, + EditCut, 0, NULL); + MiscMenuItemCreate(popup2M, NULL, "cmdCopy", _("Copy"), 0, + EditCopy, 0, NULL); + MiscMenuItemCreate(popup1M, popup2M, "cmdPaste", _("Paste"), 0, + EditPaste, 0, NULL); + MiscMenuItemCreate(popup2M, NULL, "cmdClone", _("Clone"), 0, + EditClone, 0, NULL); + /*Select*/ + MiscMenuItemCreate(popup1M, popup2M, "cmdSelectAll", _("Select All"), 0, + (wMenuCallBack_p) SetAllTrackSelect, 0, I2VP(1)); + MiscMenuItemCreate(popup1M, popup2M, "cmdSelectCurrentLayer", + _("Select Current Layer"), 0, + SelectCurrentLayer, 0, NULL); + MiscMenuItemCreate(popup2M, NULL, "cmdDeselectAll", _("Deselect All"), 0, + (wMenuCallBack_p) SetAllTrackSelect, 0, I2VP(FALSE)); + wMenuPushCreate(popup1M, "cmdSelectIndex", _("Select Track Index..."), 0, + StartIndexDialog, &SelectByIndex); + wMenuPushCreate(popup2M, "cmdSelectIndex", _("Select Track Index..."), 0, + StartIndexDialog, &SelectByIndex); + /* Modify */ + wMenuPushCreate(popup2M, "cmdMove", _("Move"), 0, + DoCommandBIndirect, &moveCmdInx); + wMenuPushCreate(popup2M, "cmdRotate", _("Rotate"), 0, + DoCommandBIndirect, &rotateCmdInx); + wMenuSeparatorCreate(popup1M); + wMenuSeparatorCreate(popup2M); + MiscMenuItemCreate(popup2M, NULL, "cmdDelete", _("Delete"), 0, + (wMenuCallBack_p) SelectDelete, 0, NULL); + wMenuSeparatorCreate(popup2M); + popup1aM = wMenuMenuCreate(popup1M, "", _("Add...")); + popup2aM = wMenuMenuCreate(popup2M, "", _("Add...")); + wMenuSeparatorCreate(popup2M); + wMenuSeparatorCreate(popup1M); + popup1mM = wMenuMenuCreate(popup1M, "", _("More...")); + popup2mM = wMenuMenuCreate(popup2M, "", _("More...")); + + /* + * FILE MENU + */ + MiscMenuItemCreate(fileM, NULL, "menuFile-clear", _("&New ..."), ACCL_NEW, + DoClear, 0, NULL); + wMenuPushCreate(fileM, "menuFile-load", _("&Open ..."), ACCL_OPEN, + ChkLoad, NULL); + wMenuSeparatorCreate(fileM); + + wMenuPushCreate(fileM, "menuFile-save", _("&Save"), ACCL_SAVE, + DoSave, NULL); + wMenuPushCreate(fileM, "menuFile-saveAs", _("Save &As ..."), ACCL_SAVEAS, + DoSaveAs, NULL); + wMenuPushCreate(fileM, "menuFile-revert", _("Revert"), ACCL_REVERT, + ChkRevert, NULL); + wMenuSeparatorCreate(fileM); + + cmdGroup = BG_FILE; + AddToolbarButton("menuFile-clear", wIconCreatePixMap(doc_new_xpm3[iconSize]), + IC_MODETRAIN_TOO, DoClear, NULL); + AddToolbarButton("menuFile-load", wIconCreatePixMap(doc_open_xpm3[iconSize]), + IC_MODETRAIN_TOO, ChkLoad, NULL); + AddToolbarButton("menuFile-save", wIconCreatePixMap(doc_save_xpm3[iconSize]), + IC_MODETRAIN_TOO, DoSave, NULL); + + cmdGroup = BG_PRINT; + MiscMenuItemCreate(fileM, NULL, "printSetup", _("P&rint Setup ..."), + ACCL_PRINTSETUP, (wMenuCallBack_p) wPrintSetup, 0, + I2VP(0)); + InitCmdPrint(fileM); + AddToolbarButton("menuFile-setup", wIconCreatePixMap(doc_setup_xpm3[iconSize]), + IC_MODETRAIN_TOO, (wMenuCallBack_p) wPrintSetup, I2VP(0)); + + wMenuSeparatorCreate(fileM); + MiscMenuItemCreate(fileM, NULL, "cmdImport", _("&Import"), ACCL_IMPORT, + DoImport, 0, I2VP(0)); + MiscMenuItemCreate(fileM, NULL, "cmdImportModule", _("Import &Module"), + ACCL_IMPORT_MOD, + DoImport, 0, I2VP(1)); + MiscMenuItemCreate(fileM, NULL, "cmdOutputbitmap", _("Export to &Bitmap"), + ACCL_PRINTBM, OutputBitMapInit(), 0, + NULL); + MiscMenuItemCreate(fileM, NULL, "cmdExport", _("E&xport"), ACCL_EXPORT, + DoExport, IC_SELECTED, NULL); + MiscMenuItemCreate(fileM, NULL, "cmdExportDXF", _("Export D&XF"), + ACCL_EXPORTDXF, DoExportDXF, IC_SELECTED, + NULL); +#if XTRKCAD_CREATE_SVG + MiscMenuItemCreate( fileM, NULL, "cmdExportSVG", _("Export S&VG"), + ACCL_EXPORTSVG, DoExportSVG, IC_SELECTED, NULL); +#endif + wMenuSeparatorCreate(fileM); + + paramFilesCallback = ParamFilesInit(); + MiscMenuItemCreate(fileM, NULL, "cmdPrmfile", _("Parameter &Files ..."), + ACCL_PARAMFILES, paramFilesCallback, 0, NULL); + MiscMenuItemCreate(fileM, NULL, "cmdFileNote", _("No&tes ..."), ACCL_NOTES, + DoNote, 0, NULL); + + wMenuSeparatorCreate(fileM); + fileList_ml = wMenuListCreate(fileM, "menuFileList", NUM_FILELIST, + ChkFileList); + wMenuSeparatorCreate(fileM); + wMenuPushCreate(fileM, "menuFile-quit", _("E&xit"), 0, + DoQuit, NULL); + + InitCmdExport(); + + AddToolbarButton("menuFile-parameter", + wIconCreatePixMap(parameter_xpm3[iconSize]), + IC_MODETRAIN_TOO, paramFilesCallback, NULL); + + cmdGroup = BG_ZOOM; + zoomUpB = AddToolbarButton("cmdZoomIn", + wIconCreatePixMap(zoom_in_xpm3[iconSize]), + IC_MODETRAIN_TOO, DoZoomUp, NULL); + zoomM = wMenuPopupCreate(mainW, ""); + AddToolbarButton("cmdZoom", wIconCreatePixMap(zoom_choose_xpm3[iconSize]), + IC_MODETRAIN_TOO, + (wButtonCallBack_p) wMenuPopupShow, zoomM); + zoomDownB = AddToolbarButton("cmdZoomOut", + wIconCreatePixMap(zoom_out_xpm3[iconSize]), + IC_MODETRAIN_TOO, DoZoomDown, NULL); + zoomExtentsB = AddToolbarButton("cmdZoomExtent", + wIconCreatePixMap(zoom_extent_xpm3[iconSize]), + IC_MODETRAIN_TOO, DoZoomExtents, NULL); + + cmdGroup = BG_UNDO; + undoB = AddToolbarButton("cmdUndo", wIconCreatePixMap(undo_xpm3[iconSize]), 0, + UndoUndo, NULL); + redoB = AddToolbarButton("cmdRedo", wIconCreatePixMap(redo_xpm3[iconSize]), 0, + UndoRedo, NULL); + + wControlActive((wControl_p) undoB, FALSE); + wControlActive((wControl_p) redoB, FALSE); + InitCmdUndo(); + + /* + * EDIT MENU + */ + MiscMenuItemCreate(editM, NULL, "cmdUndo", _("&Undo"), ACCL_UNDO, + UndoUndo, 0, NULL); + MiscMenuItemCreate(editM, NULL, "cmdRedo", _("R&edo"), ACCL_REDO, + UndoRedo, 0, NULL); + wMenuSeparatorCreate(editM); + MiscMenuItemCreate(editM, NULL, "cmdCut", _("Cu&t"), ACCL_CUT, + EditCut, IC_SELECTED, NULL); + MiscMenuItemCreate(editM, NULL, "cmdCopy", _("&Copy"), ACCL_COPY, + EditCopy, IC_SELECTED, NULL); + MiscMenuItemCreate(editM, NULL, "cmdPaste", _("&Paste"), ACCL_PASTE, + EditPaste, 0, NULL); + MiscMenuItemCreate(editM, NULL, "cmdClone", _("C&lone"), ACCL_CLONE, + EditClone, 0, NULL); + MiscMenuItemCreate(editM, NULL, "cmdDelete", _("De&lete"), ACCL_DELETE, + (wMenuCallBack_p) SelectDelete, IC_SELECTED, NULL); + MiscMenuItemCreate(editM, NULL, "cmdMoveToCurrentLayer", + _("Move To Current Layer"), ACCL_MOVCURLAYER, + MoveSelectedTracksToCurrentLayer, + IC_SELECTED, NULL); + wMenuSeparatorCreate( editM ); + menuPLs[menuPG.paramCnt].context = I2VP(1); + MiscMenuItemCreate( editM, NULL, "cmdSelectAll", _("Select &All"), + ACCL_SELECTALL, (wMenuCallBack_p)SetAllTrackSelect, 0, I2VP(TRUE) ); + MiscMenuItemCreate( editM, NULL, "cmdSelectCurrentLayer", + _("Select Current Layer"), ACCL_SETCURLAYER, SelectCurrentLayer, 0, NULL); + MiscMenuItemCreate( editM, NULL, "cmdSelectByIndex", _("Select By Index"), 0L, + StartIndexDialog, 0, &SelectByIndex ); + MiscMenuItemCreate( editM, NULL, "cmdDeselectAll", _("&Deselect All"), + ACCL_DESELECTALL, (wMenuCallBack_p)SetAllTrackSelect, 0, I2VP(FALSE) ); + MiscMenuItemCreate( editM, NULL, "cmdSelectInvert", _("&Invert Selection"), 0L, + InvertTrackSelect, 0, NULL); + MiscMenuItemCreate( editM, NULL, "cmdSelectOrphaned", + _("Select Stranded Track"), 0L, OrphanedTrackSelect, 0, NULL); + wMenuSeparatorCreate( editM ); + MiscMenuItemCreate( editM, NULL, "cmdTunnel", _("Tu&nnel"), ACCL_TUNNEL, + SelectTunnel, IC_SELECTED, NULL); + MiscMenuItemCreate( editM, NULL, "cmdBridge", _("B&ridge"), ACCL_BRIDGE, + SelectBridge, IC_SELECTED, NULL); + MiscMenuItemCreate( editM, NULL, "cmdRoadbed", _("&Roadbed"), ACCL_ROADBED, + SelectRoadbed, IC_SELECTED, NULL); + MiscMenuItemCreate( editM, NULL, "cmdTies", _("Ties/NoTies"), ACCL_TIES, + SelectTies, IC_SELECTED, NULL); + MiscMenuItemCreate( editM, NULL, "cmdAbove", _("Move to &Front"), ACCL_ABOVE, + SelectAbove, IC_SELECTED, NULL); + MiscMenuItemCreate( editM, NULL, "cmdBelow", _("Move to &Back"), ACCL_BELOW, + SelectBelow, IC_SELECTED, NULL); + + wMenuSeparatorCreate( editM ); + MiscMenuItemCreate( editM, NULL, "cmdWidth0", _("Thin Tracks"), ACCL_THIN, + SelectTrackWidth, IC_SELECTED, I2VP(0) ); + MiscMenuItemCreate( editM, NULL, "cmdWidth2", _("Medium Tracks"), ACCL_MEDIUM, + SelectTrackWidth, IC_SELECTED, I2VP(2) ); + MiscMenuItemCreate( editM, NULL, "cmdWidth3", _("Thick Tracks"), ACCL_THICK, + SelectTrackWidth, IC_SELECTED, I2VP(3) ); + + /* + * VIEW MENU + */ + + zoomInM = wMenuPushCreate(viewM, "menuEdit-zoomIn", _("Zoom &In"), + ACCL_ZOOMIN, DoZoomUp, I2VP(1)); + zoomSubM = wMenuMenuCreate(viewM, "menuEdit-zoomTo", _("&Zoom")); + zoomOutM = wMenuPushCreate(viewM, "menuEdit-zoomOut", _("Zoom &Out"), + ACCL_ZOOMOUT, DoZoomDown, I2VP(1)); + zoomExtentsM = wMenuPushCreate(viewM, "menuEdit-zoomExtents", + _("Zoom &Extents"), + 0, DoZoomExtents, I2VP(0)); + wMenuSeparatorCreate(viewM); + + InitCmdZoom(zoomM, zoomSubM, NULL, NULL); + + /* these menu choices and toolbar buttons are synonymous and should be treated as such */ + wControlLinkedSet((wControl_p) zoomInM, (wControl_p) zoomUpB); + wControlLinkedSet((wControl_p) zoomOutM, (wControl_p) zoomDownB); + wControlLinkedSet((wControl_p) zoomExtentsM, (wControl_p) zoomExtentsB); + + wMenuPushCreate(viewM, "menuEdit-redraw", _("&Redraw"), ACCL_REDRAW, + (wMenuCallBack_p) MainRedraw, NULL); + wMenuPushCreate(viewM, "menuEdit-redraw", _("Redraw All"), ACCL_REDRAWALL, + (wMenuCallBack_p) DoRedraw, NULL); + wMenuSeparatorCreate(viewM); + + snapGridEnableMI = wMenuToggleCreate(viewM, "cmdGridEnable", + _("Enable SnapGrid"), ACCL_SNAPENABLE, 0, + SnapGridEnable, NULL); + snapGridShowMI = wMenuToggleCreate(viewM, "cmdGridShow", _("Show SnapGrid"), + ACCL_SNAPSHOW, + FALSE, SnapGridShow, NULL); + InitGrid(viewM); + + // visibility toggle for anchors + // get the start value + long anchors_long; + wPrefGetInteger("misc", "anchors", &anchors_long, 1); + magneticSnap = anchors_long ? TRUE : FALSE; + magnetsMI = wMenuToggleCreate(viewM, "cmdMagneticSnap", + _("Enable Magnetic Snap"), + 0, magneticSnap, + MagneticSnapToggle, NULL); + + // visibility toggle for map window + // get the start value + long mapVisible_long; + wPrefGetInteger("misc", "mapVisible", (long *) &mapVisible_long, 1); + mapVisible = mapVisible_long ? TRUE : FALSE; + mapShowMI = wMenuToggleCreate(viewM, "cmdMapShow", _("Show/Hide Map"), + ACCL_MAPSHOW, mapVisible, + MapWindowToggleShow, NULL); + + wMenuSeparatorCreate(viewM); + + toolbarM = wMenuMenuCreate(viewM, "toolbarM", _("&Tool Bar")); + CreateToolbarM(toolbarM); + + cmdGroup = BG_EASE; + InitCmdEasement(); + + cmdGroup = BG_SNAP; + InitSnapGridButtons(); + magnetsB = AddToolbarButton("cmdMagneticSnap", + wIconCreatePixMap(magnet_xpm3[iconSize]), + IC_MODETRAIN_TOO, MagneticSnapToggle, NULL); + wControlLinkedSet((wControl_p) magnetsMI, (wControl_p) magnetsB); + wButtonSetBusy(magnetsB, (wBool_t) magneticSnap); + + mapShowB = AddToolbarButton("cmdMapShow", wIconCreatePixMap(map_xpm3[iconSize]), + IC_MODETRAIN_TOO, MapWindowToggleShow, NULL); + wControlLinkedSet((wControl_p) mapShowMI, (wControl_p) mapShowB); + wButtonSetBusy(mapShowB, (wBool_t) mapVisible); + + /* + * ADD MENU + */ + + cmdGroup = BG_TRKCRT | BG_BIGGAP; + InitCmdStraight(addM); + InitCmdCurve(addM); + InitCmdParallel(addM); + InitCmdTurnout(addM); + InitCmdHandLaidTurnout(addM); + InitCmdStruct(addM); + InitCmdHelix(addM); + InitCmdTurntable(addM); + + cmdGroup = BG_CONTROL; + ButtonGroupBegin( _("Control Element"), "cmdControlElements", + _("Control Element") ); + InitCmdBlock(addM); + InitCmdSwitchMotor(addM); + InitCmdSignal(addM); + InitCmdControl(addM); + InitCmdSensor(addM); + ButtonGroupEnd(); + + /* + * CHANGE MENU + */ + cmdGroup = BG_SELECT; + InitCmdDescribe(changeM); + InitCmdSelect(changeM); + InitCmdPan(viewM); + + wMenuSeparatorCreate(changeM); + + cmdGroup = BG_TRKGRP; + InitCmdMove(changeM); + InitCmdMoveDescription(changeM); + InitCmdDelete(); + InitCmdTunnel(); + InitCmdTies(); + InitCmdBridge(); + InitCmdRoadbed(); + InitCmdAboveBelow(); + + cmdGroup = BG_TRKMOD; + InitCmdModify(changeM); + InitCmdCornu(changeM); + + MiscMenuItemCreate(changeM, NULL, "cmdRescale", _("Change Scale"), 0, + DoRescale, IC_SELECTED, NULL); + + + wMenuSeparatorCreate(changeM); + + InitCmdJoin(changeM); + InitCmdSplit(changeM); + + wMenuSeparatorCreate(changeM); + + InitCmdPull(changeM); + + wMenuSeparatorCreate(changeM); + + MiscMenuItemCreate(changeM, NULL, "cmdAddElevations", + _("Raise/Lower Elevations"), ACCL_CHGELEV, + ShowAddElevations, IC_SELECTED, + NULL); + InitCmdElevation(changeM); + InitCmdProfile(changeM); + + MiscMenuItemCreate(changeM, NULL, "cmdClearElevations", + _("Clear Elevations"), ACCL_CLRELEV, + ClearElevations, IC_SELECTED, NULL); + MiscMenuItemCreate(changeM, NULL, "cmdElevation", _("Recompute Elevations"), + 0, RecomputeElevations, 0, NULL); + ParamRegister(&addElevPG); + + /* + * DRAW MENU + */ + cmdGroup = BG_MISCCRT; + InitCmdDraw(drawM); + InitCmdText(drawM); + InitTrkNote(drawM); + + cmdGroup = BG_RULER; + InitCmdRuler(drawM); + + /* + * OPTION MENU + */ + MiscMenuItemCreate(optionM, NULL, "cmdLayout", _("L&ayout ..."), + ACCL_LAYOUTW, LayoutInit(), IC_MODETRAIN_TOO, NULL); + MiscMenuItemCreate(optionM, NULL, "cmdDisplay", _("&Display ..."), + ACCL_DISPLAYW, DisplayInit(), IC_MODETRAIN_TOO, NULL); + MiscMenuItemCreate(optionM, NULL, "cmdCmdopt", _("Co&mmand ..."), + ACCL_CMDOPTW, CmdoptInit(), IC_MODETRAIN_TOO, NULL); + MiscMenuItemCreate(optionM, NULL, "cmdEasement", _("&Easements ..."), + ACCL_EASEW, DoEasementRedir, + IC_MODETRAIN_TOO, NULL); + MiscMenuItemCreate(optionM, NULL, "fontSelW", _("&Fonts ..."), ACCL_FONTW, + SelectFont, IC_MODETRAIN_TOO, NULL); + MiscMenuItemCreate(optionM, NULL, "cmdSticky", _("Stic&ky ..."), + ACCL_STICKY, DoSticky, IC_MODETRAIN_TOO, + NULL); + if (extraButtons) { + menuPLs[menuPG.paramCnt].context = debugW; + MiscMenuItemCreate(optionM, NULL, "cmdDebug", _("&Debug ..."), 0, + DebugInit, IC_MODETRAIN_TOO, NULL); + } + MiscMenuItemCreate(optionM, NULL, "cmdPref", _("&Preferences ..."), + ACCL_PREFERENCES, PrefInit(), IC_MODETRAIN_TOO, NULL); + MiscMenuItemCreate(optionM, NULL, "cmdColor", _("&Colors ..."), ACCL_COLORW, + ColorInit(), IC_MODETRAIN_TOO, NULL); + + /* + * MACRO MENU + */ + wMenuPushCreate(macroM, "cmdRecord", _("&Record ..."), ACCL_RECORD, + DoRecord, NULL); + wMenuPushCreate(macroM, "cmdDemo", _("&Play Back ..."), ACCL_PLAYBACK, + DoPlayBack, NULL); + + /* + * WINDOW MENU + */ + wMenuPushCreate(windowM, "menuWindow", _("Main window"), 0, + (wMenuCallBack_p) wShow, mainW); + winList_mi = wMenuListCreate(windowM, "menuWindow", -1, DoShowWindow); + + /* + * HELP MENU + */ + + /* main help window */ + wMenuAddHelp(helpM); + + /* help on recent messages */ + wMenuSeparatorCreate(helpM); + wMenu_p messageListM = wMenuMenuCreate(helpM, "menuHelpRecentMessages", + _("Recent Messages")); + messageList_ml = wMenuListCreate(messageListM, "messageListM", 10, + ShowMessageHelp); + wMenuListAdd(messageList_ml, 0, _(MESSAGE_LIST_EMPTY), NULL); + wMenuPushCreate(helpM, "menuHelpProblemrep", _("Collect Problem Info"), 0, + DoProblemCollect, NULL); + + /* tip of the day */ + wMenuSeparatorCreate( helpM ); + wMenuPushCreate( helpM, "cmdTip", _("Tip of the Day..."), 0, ShowTip, + I2VP(SHOWTIP_FORCESHOW | SHOWTIP_NEXTTIP)); + demoM = wMenuMenuCreate( helpM, "cmdDemo", _("&Demos") ); + wMenuPushCreate( helpM, "cmdExamples", _("Examples..."), 0, ChkExamples, NULL); + + /* about window */ + wMenuSeparatorCreate(helpM); + wMenuPushCreate(helpM, "about", _("About"), 0, + CreateAboutW, NULL); + + /* + * MANAGE MENU + */ + + cmdGroup = BG_TRAIN | BG_BIGGAP; + InitCmdTrain(manageM); + wMenuSeparatorCreate(manageM); + + InitNewTurn( + wMenuMenuCreate(manageM, "cmdTurnoutNew", + _("Tur&nout Designer..."))); + + MiscMenuItemCreate(manageM, NULL, "cmdContmgm", + _("Layout &Control Elements"), ACCL_CONTMGM, + ControlMgrInit(), 0, NULL); + MiscMenuItemCreate(manageM, NULL, "cmdGroup", _("&Group"), ACCL_GROUP, + DoGroup, IC_SELECTED, NULL); + MiscMenuItemCreate(manageM, NULL, "cmdUngroup", _("&Ungroup"), ACCL_UNGROUP, + DoUngroup, IC_SELECTED, NULL); + + MiscMenuItemCreate(manageM, NULL, "cmdCustmgm", + _("Custom defined parts..."), ACCL_CUSTMGM, CustomMgrInit(), + 0, NULL); + MiscMenuItemCreate(manageM, NULL, "cmdRefreshCompound", + _("Update Turnouts and Structures"), 0, + DoRefreshCompound, 0, NULL); + + MiscMenuItemCreate(manageM, NULL, "cmdCarInventory", _("Car Inventory"), + ACCL_CARINV, DoCarDlg, IC_MODETRAIN_TOO, + NULL); + + wMenuSeparatorCreate(manageM); + + MiscMenuItemCreate(manageM, NULL, "cmdLayer", _("Layers ..."), ACCL_LAYERS, + InitLayersDialog(), 0, NULL); + wMenuSeparatorCreate(manageM); + + MiscMenuItemCreate(manageM, NULL, "cmdEnumerate", _("Parts &List ..."), + ACCL_PARTSLIST, EnumerateTracks, 0, + NULL); + MiscMenuItemCreate(manageM, NULL, "cmdPricelist", _("Price List..."), + ACCL_PRICELIST, PriceListInit(), 0, NULL); + + cmdGroup = BG_LAYER | BG_BIGGAP; + + InitCmdSelect2(changeM); + InitCmdDescribe2(changeM); + InitCmdPan2(changeM); + + InitLayers(); + + cmdGroup = BG_HOTBAR; + InitHotBar(); + + InitBenchDialog(); + + ParamRegister(&rotatePG); + ParamRegister(&movePG); + ParamRegister(&indexPG); + + // stickySet is initialized by AddMenuButton based on IC_STICKY flag + // Now check to see if there is saved value + wPrefGetInteger( "DialogItem", "sticky-set", &stickySet, stickySet ); + ParamRegister(&stickyPG); +} + + +static void InitCmdExport(void) +{ + ButtonGroupBegin( _("Import/Export"), "cmdExportImportSetCmd", + _("Import/Export") ); + cmdGroup = BG_EXPORTIMPORT; + AddToolbarButton("cmdExport", wIconCreatePixMap(doc_export_xpm3[iconSize]), + IC_SELECTED | IC_ACCLKEY, DoExport, NULL); + AddToolbarButton("cmdExportDXF", + wIconCreatePixMap(doc_export_dxf_xpm3[iconSize]), + IC_SELECTED | IC_ACCLKEY, DoExportDXF, I2VP(1)); + AddToolbarButton("cmdExportBmap", + wIconCreatePixMap(doc_export_bmap_xpm3[iconSize]), IC_ACCLKEY, + OutputBitMapInit(), NULL); +#if XTRKCAD_CREATE_SVG + AddToolbarButton("cmdExportSVG", + wIconCreatePixMap(doc_export_svg_xpm3[iconSize]), + IC_ACCLKEY, DoExportSVG, NULL); // IC_SELECTED | +#endif + AddToolbarButton("cmdImport", wIconCreatePixMap(doc_import_xpm3[iconSize]), + IC_ACCLKEY, + DoImport, I2VP(0)); + AddToolbarButton("cmdImportModule", + wIconCreatePixMap(doc_import_mod_xpm3[iconSize]), IC_ACCLKEY, + DoImport, I2VP(1)); + ButtonGroupEnd(); + ParamRegister( &menuPG ); + AddPlaybackProc( "MENU", MenuPlayback, NULL ); +} diff --git a/app/bin/menu.h b/app/bin/menu.h new file mode 100644 index 0000000..eb95f90 --- /dev/null +++ b/app/bin/menu.h @@ -0,0 +1,69 @@ +/** \file menu.h + * Application wide declarations and defines + */ + +/* XTrkCad - Model Railroad CAD + * Copyright (C) 2005 Dave Bullis + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef MENU_H +#define MENU_H + +#include "common.h" + +extern wMenu_p demoM; +extern wMenu_p popup1M, popup2M; +extern wButton_p undoB; +extern wButton_p redoB; +extern wButton_p zoomUpB; +extern wButton_p zoomDownB; +extern wButton_p zoomExtentsB; +extern wButton_p mapShowB; +extern wMenuToggle_p mapShowMI; +extern wMenuList_p winList_mi; +extern wMenuList_p fileList_ml; +extern wMenuToggle_p snapGridEnableMI; +extern wMenuToggle_p snapGridShowMI; + +extern long stickySet; + +extern wMenu_p MenuRegister( const char * label ); +typedef void (*rotateDialogCallBack_t) ( void * ); +typedef void (*indexDialogCallBack_t) (void * ); +typedef void (*moveDialogCallBack_t) (void *); +extern void AddMoveMenu(wMenu_p m, moveDialogCallBack_t func); +extern void AddIndexMenu(wMenu_p m, indexDialogCallBack_t func); +extern void AddRotateMenu(wMenu_p m, rotateDialogCallBack_t func); +extern int MagneticSnap( int state ); +extern void SelectFont(void * unused); +extern void DoSticky(void * unused); + +extern void EnableMenus( void ); +extern void MessageListAppend( char *, const char * ); +extern const char * GetBalloonHelpStr(const char * helpKey); +extern wButton_p AddToolbarButton(const char * helpStr, wIcon_p icon, + long options, + wButtonCallBack_p action, void * context); +extern void ButtonGroupBegin(const char * menuTitle, const char * helpKey, + const char * stickyLabel); +extern void ButtonGroupEnd(void); +extern wIndex_t AddMenuButton(wMenu_p menu, procCommand_t command, + const char * helpKey, const char * nameStr, wIcon_p icon, int reqLevel, + long options, long acclKey, void * context); +extern void CreateMenus(void); + +#endif diff --git a/app/bin/misc.c b/app/bin/misc.c index e976481..901b684 100644 --- a/app/bin/misc.c +++ b/app/bin/misc.c @@ -17,49 +17,30 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "cjoin.h" -#include "common.h" -#include "compound.h" +#include "misc.h" #include "cselect.h" #include "cundo.h" #include "custom.h" #include "draw.h" #include "fileio.h" #include "layout.h" -#include "misc.h" #include "param.h" #include "include/paramfilelist.h" #include "paths.h" #include "smalldlg.h" #include "track.h" #include "common-ui.h" -#include "ctrain.h" #include <inttypes.h> -#include <stdint.h> - #define DEFAULT_SCALE ("N") -extern wBalloonHelp_t balloonHelp[]; - -static wMenuToggle_p mapShowMI; -static wMenuToggle_p magnetsMI; - -#ifdef DEBUG -#define CHECK_BALLOONHELP -/*#define CHECK_UNUSED_BALLOONHELP*/ -#endif -#ifdef CHECK_UNUSED_BALLOONHELP -static void ShowUnusedBalloonHelp(void); -#endif - /**************************************************************************** * EXPORTED VARIABLES @@ -68,108 +49,51 @@ static void ShowUnusedBalloonHelp(void); EXPORT int iconSize = 0; -EXPORT int foobar = 0; - -EXPORT int log_error; -static int log_command; - +EXPORT wWinPix_t displayWidth; +EXPORT wWinPix_t displayHeight; EXPORT wWin_p mainW; EXPORT char message[STR_HUGE_SIZE]; static char message2[STR_LONG_SIZE]; -EXPORT REGION_T curRegion = 0; - EXPORT long paramVersion = -1; EXPORT coOrd zero = { 0.0, 0.0 }; EXPORT wBool_t extraButtons = FALSE; -EXPORT long onStartup; /**< controls behaviour after startup: load last layout if zero, else start with blank canvas */ - -EXPORT wButton_p undoB; -EXPORT wButton_p redoB; - -EXPORT wButton_p zoomUpB; -EXPORT wButton_p zoomDownB; -EXPORT wButton_p zoomExtentsB; -wButton_p mapShowB; -wButton_p magnetsB; -wButton_p backgroundB; - -EXPORT wIndex_t checkPtMark = 0; - -EXPORT wMenu_p demoM; -EXPORT wMenu_p popup1M, popup2M; -EXPORT wMenu_p popup1aM, popup2aM; -EXPORT wMenu_p popup1mM, popup2mM; - -static wIndex_t curCommand = 0; -EXPORT void * commandContext; -EXPORT wIndex_t cmdGroup; -EXPORT wIndex_t joinCmdInx; -EXPORT wIndex_t modifyCmdInx; -EXPORT long rightClickMode = 0; -EXPORT long selectMode = 0; -EXPORT long selectZero = 1; -EXPORT DIST_T easementVal = 0.0; -EXPORT DIST_T easeR = 0.0; -EXPORT DIST_T easeL = 0.0; -EXPORT coOrd cmdMenuPos; - -EXPORT wWinPix_t DlgSepLeft = 12; -EXPORT wWinPix_t DlgSepMid = 18; -EXPORT wWinPix_t DlgSepRight = 12; -EXPORT wWinPix_t DlgSepTop = 12; -EXPORT wWinPix_t DlgSepBottom = 12; -EXPORT wWinPix_t DlgSepNarrow = 6; -EXPORT wWinPix_t DlgSepWide = 12; -EXPORT wWinPix_t DlgSepFrmLeft = 4; -EXPORT wWinPix_t DlgSepFrmRight = 4; -EXPORT wWinPix_t DlgSepFrmTop = 4; -EXPORT wWinPix_t DlgSepFrmBottom = 4; +EXPORT long +onStartup; /**< controls behaviour after startup: load last layout if zero, else start with blank canvas */ static int verbose = 0; -static wMenuList_p winList_mi; static BOOL_T inMainW = TRUE; -static long stickySet = 0; -static long stickyCnt = 0; -static const char * stickyLabels[33]; -#define TOOLBARSET_INIT (0xFFFF) -EXPORT long toolbarSet = TOOLBARSET_INIT; -EXPORT wWinPix_t toolbarHeight = 0; -static wWinPix_t toolbarWidth = 0; - -static wMenuList_p messageList_ml; -static BOOL_T messageListEmpty = TRUE; -#define MESSAGE_LIST_EMPTY N_("No Messages") +EXPORT long units = 0; /**< measurement units: 0 = English, 1 = metric */ -#define NUM_FILELIST (5) +EXPORT long labelScale = 8; +EXPORT long labelEnable = (LABELENABLE_ENDPT_ELEV|LABELENABLE_CARS); +/** @prefs [draw] label-when=2 Unknown */ +EXPORT long labelWhen = 2; -extern long curTurnoutEp; -static wIndex_t printCmdInx; -static wIndex_t gridCmdInx; -static paramData_t menuPLs[101] = { { PD_LONG, &toolbarSet, "toolbarset" }, { - PD_LONG, &curTurnoutEp, "cur-turnout-ep" } }; -static paramGroup_t menuPG = { "misc", PGO_RECORD, menuPLs, 2 }; +EXPORT long dontHideCursor = 0; +#ifdef HIDESELECTIONWINDOW +EXPORT long hideSelectionWindow = 0; +#endif -extern wBool_t wDrawDoTempDraw; /**************************************************************************** * - * LOCAL UTILITIES + * MEMORY ALLOCATION * */ -EXPORT size_t totalMallocs = 0; -EXPORT size_t totalMalloced = 0; -EXPORT size_t totalRealloced = 0; -EXPORT size_t totalReallocs = 0; -EXPORT size_t totalFreeed = 0; -EXPORT size_t totalFrees = 0; +static size_t totalMallocs = 0; +static size_t totalMalloced = 0; +static size_t totalRealloced = 0; +static size_t totalReallocs = 0; +static size_t totalFreeed = 0; +static size_t totalFrees = 0; static void * StorageLog; @@ -189,10 +113,11 @@ static unsigned long guard0 = 0xDEADBEEF; static unsigned long guard1 = 0xAF00BA8A; static int log_malloc; -static void RecordMalloc(void * p, size_t size) { +static void RecordMalloc(void * p, size_t size) +{ - if (!StorageLog) StorageLog = malloc(sizeof(slog_t)*LOG_SIZE); + if (!StorageLog) { StorageLog = malloc(sizeof(slog_t)*LOG_SIZE); } slog_p log_p = StorageLog; if (StorageLogCurrent<LOG_SIZE) { log_p[StorageLogCurrent].storage_p = p; @@ -206,10 +131,11 @@ static void RecordMalloc(void * p, size_t size) { } } -static void RecordMyFree(void *p) { +static void RecordMyFree(void *p) +{ slog_p log_p = StorageLog; if (log_p) { - for (int i=0;i<StorageLogCurrent;i++) { + for (int i=0; i<StorageLogCurrent; i++) { if (!log_p[i].freed && log_p[i].storage_p == p) { log_p[i].freed = TRUE; } @@ -219,20 +145,21 @@ static void RecordMyFree(void *p) { #define SLOG_FMT "0x%.12" PRIxPTR -EXPORT BOOL_T TestMallocs() { +EXPORT BOOL_T TestMallocs() +{ size_t oldSize; size_t testedMallocs = 0; void * old; slog_p log_p = StorageLog; BOOL_T rc = TRUE; if (log_p) { - for (int i=0;i<StorageLogCurrent;i++) { - if (log_p[i].freed) continue; + for (int i=0; i<StorageLogCurrent; i++) { + if (log_p[i].freed) { continue; } old = log_p[i].storage_p; oldSize = log_p[i].storage_size; if (*(unsigned long*) ((char*) old - sizeof(unsigned long)) != guard0) { LogPrintf("Guard 0 hosed, " SLOG_FMT " size: %llu \n", (uintptr_t)old, oldSize); - rc = FALSE; + rc = FALSE; } if (*(unsigned long*) ((char*) old + oldSize) != guard1) { LogPrintf("Guard 1 hosed, " SLOG_FMT " size: %llu \n", (uintptr_t)old, oldSize); @@ -242,24 +169,38 @@ EXPORT BOOL_T TestMallocs() { } } LogPrintf("Tested: %llu Mallocs: %llu Total Malloced: %llu Freed: %llu Total Freed: %llu \n", - testedMallocs, totalMallocs, totalMalloced, totalFrees, totalFreeed); + testedMallocs, totalMallocs, totalMalloced, totalFrees, totalFreeed); return rc; } +/** + * Allocate memory + * + * Allocated memory has 'guard' values, before and after to detect overruns. + * Aborts on allocation failure. + * + * \param size IN amount of memory to allocate + * + * \return Pointer to allocated memory - never NULL + */ -EXPORT void * MyMalloc(size_t size) { +EXPORT void * MyMalloc(size_t size) +{ void * p; totalMallocs++; totalMalloced += size; p = malloc((size_t) size + sizeof(size_t) + 2 * sizeof(unsigned long)); - if (p == NULL) - AbortProg("No memory"); + if ( p == NULL ) { + // We're hosed, get out of town + lprintf( "malloc(%ld) failed\n", size ); + abort(); + } LOG1(log_malloc, - ( " Malloc(%ld) = " SLOG_FMT " (" SLOG_FMT "-" SLOG_FMT ")\n", - size, (size_t)((char*)p+sizeof (size_t) + sizeof (unsigned long)), - (size_t)p, - (size_t)((char*)p+size+sizeof (size_t) + 2 * sizeof(unsigned long)))); + ( " Malloc(%ld) = " SLOG_FMT " (" SLOG_FMT "-" SLOG_FMT ")\n", + size, (size_t)((char*)p+sizeof (size_t) + sizeof (unsigned long)), + (size_t)p, + (size_t)((char*)p+size+sizeof (size_t) + 2 * sizeof(unsigned long)))); *(size_t*) p = (size_t) size; p = (char*) p + sizeof(size_t); @@ -267,86 +208,101 @@ EXPORT void * MyMalloc(size_t size) { p = (char*) p + sizeof(unsigned long); *(unsigned long*) ((char*) p + size) = guard1; memset(p, 0, (size_t )size); - if (extraButtons) + if (extraButtons) { RecordMalloc(p,size); + } return p; } -EXPORT void * MyRealloc(void * old, size_t size) { +/** + * Reallocate memory + * + * Allocated memory has 'guard' values, before and after to detect overruns. + * Aborts on allocation failure. + * + * \param old IN existing pointer to allocated memory + * \param size IN amount of memory to allocate + * + * \return Pointer to reallocated memory - never NULL + */ + +EXPORT void * MyRealloc(void * old, size_t size) +{ size_t oldSize; void * new; - if (old == NULL) + if (old == NULL) { return MyMalloc(size); + } totalReallocs++; totalRealloced += size; - if (*(unsigned long*) ((char*) old - sizeof(unsigned long)) != guard0) { - AbortProg("Guard0 is hosed"); - } + CHECKMSG( (*(unsigned long*) ((char*) old - sizeof(unsigned long)) == guard0), + ("Guard0 is hosed") ); oldSize = *(size_t*) ((char*) old - sizeof(unsigned long) - sizeof(size_t)); - if (*(unsigned long*) ((char*) old + oldSize) != guard1) { - AbortProg("Guard1 is hosed"); - } + CHECKMSG( (*(unsigned long*) ((char*) old + oldSize) == guard1), + ( "Guard1 is hosed" ) ); - LOG1(log_malloc, (" Realloc (" SLOG_FMT ",%ld) was %d\n", (size_t)old, size, oldSize )) + LOG1(log_malloc, (" Realloc (" SLOG_FMT ",%ld) was %d\n", (size_t)old, size, + oldSize )) if ((long) oldSize == size) { return old; } - if (size == 0) { - free((char*) old - sizeof *(long*) 0 - sizeof *(size_t*) 0); - return NULL; - } new = MyMalloc(size); - if (new == NULL && size) - AbortProg("No memory"); memcpy(new, old, min((size_t )size, oldSize)); MyFree(old); return new; } -EXPORT void MyFree(void * ptr) { +EXPORT void MyFree(void * ptr) +{ size_t oldSize; totalFrees++; - if (ptr) { - if (*(unsigned long*) ((char*) ptr - sizeof(unsigned long)) != guard0) { - AbortProg("Guard0 is hosed"); - } - oldSize = *(size_t*) ((char*) ptr - sizeof(unsigned long) - - sizeof(size_t)); - if (*(unsigned long*) ((char*) ptr + oldSize) != guard1) { - AbortProg("Guard1 is hosed"); - } + if (ptr==NULL) { + return; + } + CHECKMSG( (*(unsigned long*) ((char*) ptr - sizeof(unsigned long)) == guard0), + ( "Guard0 is hosed") ); + oldSize = *(size_t*) ((char*) ptr - sizeof(unsigned long) + - sizeof(size_t)); + CHECKMSG( (*(unsigned long*) ((char*) ptr + oldSize) == guard1), + ( "Guard1 is hosed" ) ); - LOG1(log_malloc, - (" Free %d at " SLOG_FMT " (" SLOG_FMT "-" SLOG_FMT ")\n", - oldSize, - (size_t)ptr, - (size_t)((char*)ptr-sizeof *(size_t*)0-sizeof *(long*)0), - (size_t)((char*)ptr+oldSize+sizeof *(long*)0))); - - totalFreeed += oldSize; - free((char*) ptr - sizeof *(long*) 0 - sizeof *(size_t*) 0); - if (extraButtons) - RecordMyFree(ptr); + LOG1(log_malloc, + (" Free %ld at " SLOG_FMT " (" SLOG_FMT "-" SLOG_FMT ")\n", + oldSize, + (size_t)ptr, + (size_t)((char*)ptr-sizeof *(size_t*)0-sizeof *(long*)0), + (size_t)((char*)ptr+oldSize+sizeof *(long*)0))); + + totalFreeed += oldSize; + free((char*) ptr - sizeof *(long*) 0 - sizeof *(size_t*) 0); + if (extraButtons) { + RecordMyFree(ptr); } } -EXPORT void * memdup(void * src, size_t size) { +EXPORT void * memdup(void * src, size_t size) +{ void * p; p = MyMalloc(size); - if (p == NULL) - AbortProg("No memory"); memcpy(p, src, size); return p; } -EXPORT char * MyStrdup(const char * str) { +EXPORT char * MyStrdup(const char * str) +{ char * ret; ret = (char*) MyMalloc(strlen(str) + 1); strcpy(ret, str); return ret; } + +/**************************************************************************** + * + * CHARACTER CONVERSION + * + */ /* * Convert Text into the equivalent form that can be written to a file or put in a text box by adding escape characters * @@ -356,7 +312,8 @@ EXPORT char * MyStrdup(const char * str) { * "" for " This is so that a CSV conformant type program can interpret the file output * */ -EXPORT char * ConvertToEscapedText(const char * text) { +EXPORT char * ConvertToEscapedText(const char * text) +{ int text_i = 0; int add = 0; //extra chars for escape while (text[text_i]) { @@ -417,9 +374,6 @@ EXPORT char * ConvertToEscapedText(const char * text) { text_i++; } cout[cout_i] = '\0'; -#ifdef UTFCONVERT - wSystemToUTF8(cout, cout, (unsigned int)cnt); -#endif // UTFCONVERT return cout; } @@ -433,7 +387,8 @@ EXPORT char * ConvertToEscapedText(const char * text) { * \\ = \ The way to still produce backslash * */ -EXPORT char * ConvertFromEscapedText(const char * text) { +EXPORT char * ConvertFromEscapedText(const char * text) +{ enum { CHARACTER, ESCAPE } state = CHARACTER; @@ -477,18 +432,65 @@ EXPORT char * ConvertFromEscapedText(const char * text) { return cout; } -EXPORT void AbortProg(const char * msg, ...) { - static BOOL_T abort2 = FALSE; - int rc; + +/**************************************************************************** + * + * MESSAGES + * + */ +/** + * Print the message into internal buffer + * + * Called from CHECKMSG define + * \param sFormat IN printf-type format string + * \param ... IN vargs printf-type operands + * + * \return address of internal buffer containing formatted message + */ +EXPORT const char * AbortMessage( + const char * sFormat, + ... ) +{ + static char sMessage[STR_SIZE]; + if ( sFormat == NULL ) { + return ""; + } va_list ap; - va_start(ap, msg); - vsprintf(message, msg, ap); + va_start(ap, sFormat); + vsnprintf(sMessage, sizeof sMessage, sFormat, ap); va_end(ap); + return sMessage; +} + +/** + * Display error notice box + * Offer chance to save layout + * Abort the program + * + * Called from CHECK/CHECKMSG defines + * + * \param sCond IN string-ized error condition + * \param sFileName IN file name of fault + * \param iLineNumber IN line number of fault + * \param sMsg IN extra message with additional info + * + * \return No return + */ +EXPORT void AbortProg( + const char * sCond, + const char * sFileName, + int iLineNumber, + const char * sMsg ) +{ + static BOOL_T abort2 = FALSE; + snprintf( message, sizeof message, "%s: %s:%d %s", sCond, sFileName, + iLineNumber, sMsg?sMsg:"" ); if (abort2) { wNoticeEx( NT_ERROR, message, _("ABORT"), NULL); } else { + abort2 = TRUE; // no 2nd chance strcat(message, _("\nDo you want to save your layout?")); - rc = wNoticeEx( NT_ERROR, message, _("Ok"), _("ABORT")); + int rc = wNoticeEx( NT_ERROR, message, _("Ok"), _("ABORT")); if (rc) { DoSaveAs(abort); } else { @@ -497,88 +499,69 @@ EXPORT void AbortProg(const char * msg, ...) { } } -EXPORT char * Strcpytrimed(char * dst, const char * src, BOOL_T double_quotes) { +EXPORT char * Strcpytrimed(char * dst, const char * src, BOOL_T double_quotes) +{ const char * cp; - while (*src && isspace((unsigned char) *src)) + while (*src && isspace((unsigned char) *src)) { src++; - if (!*src) + } + if (!*src) { return dst; + } cp = src + strlen(src) - 1; - while (cp > src && isspace((unsigned char) *cp)) + while (cp > src && isspace((unsigned char) *cp)) { cp--; + } while (src <= cp) { - if (*src == '"' && double_quotes) + if (*src == '"' && double_quotes) { *dst++ = '"'; + } *dst++ = *src++; } *dst = '\0'; return dst; } +// ??? Referenced from gtklib.browserhelp.c ??? static char * directory; -EXPORT wBool_t CheckHelpTopicExists(const char * topic) { +EXPORT wBool_t CheckHelpTopicExists(const char * topic) +{ char * htmlFile; - // Check the file exits in the distro + // Check the file exits in the distro - if (!directory) + if (!directory) { directory = malloc(BUFSIZ); + } - if (directory == NULL) return 0; - - sprintf(directory, "%s/html/", wGetAppLibDir()); - - htmlFile = malloc(strlen(directory)+strlen(topic) + 6); + if (directory == NULL) { return 0; } - sprintf(htmlFile, "%s%s.html", directory, topic); + sprintf(directory, "%s/html/", wGetAppLibDir()); - if( access( htmlFile, F_OK ) == -1 ) { + htmlFile = malloc(strlen(directory)+strlen(topic) + 6); - printf("Missing help topic %s\n",topic); + sprintf(htmlFile, "%s%s.html", directory, topic); - free(htmlFile); + if( access( htmlFile, F_OK ) == -1 ) { - return 0; + printf("Missing help topic %s\n",topic); - } + free(htmlFile); - free(htmlFile); + return 0; - return 1; + } -} + free(htmlFile); -EXPORT char * BuildTrimedTitle(char * cp, const char * sep, const char * mfg, const char * desc, - const char * partno) { - cp = Strcpytrimed(cp, mfg, FALSE); - strcpy(cp, sep); - cp += strlen(cp); - cp = Strcpytrimed(cp, desc, FALSE); - strcpy(cp, sep); - cp += strlen(cp); - cp = Strcpytrimed(cp, partno, FALSE); - return cp; -} + return 1; -static void ShowMessageHelp(int index, const char * label, void * data) { - char msgKey[STR_SIZE], *cp, *msgSrc; - msgSrc = (char*) data; - if (!msgSrc) - return; - cp = strchr(msgSrc, '\t'); - if (cp == NULL) { - sprintf(msgKey, _("No help for %s"), msgSrc); - wNoticeEx( NT_INFORMATION, msgKey, _("Ok"), NULL); - return; - } - memcpy(msgKey, msgSrc, cp - msgSrc); - msgKey[cp - msgSrc] = 0; - wHelp(msgKey); } -static const char * ParseMessage(const char *msgSrc) { +static const char * ParseMessage(const char *msgSrc) +{ char *cp1 = NULL, *cp2 = NULL; static char shortMsg[STR_SIZE]; cp1 = strchr(_(msgSrc), '\t'); @@ -594,30 +577,29 @@ static const char * ParseMessage(const char *msgSrc) { cp1++; cp2 = cp1; } - if (messageListEmpty) { - wMenuListDelete(messageList_ml, _(MESSAGE_LIST_EMPTY)); - messageListEmpty = FALSE; - } - wMenuListAdd(messageList_ml, 0, cp1, _(msgSrc)); + MessageListAppend( cp1, _(msgSrc) ); return cp2; } else { return _(msgSrc); } } -EXPORT void InfoMessage(const char * format, ...) { +EXPORT void InfoMessage(const char * format, ...) +{ va_list ap; va_start(ap, format); format = ParseMessage(format); vsnprintf(message2, 1020, format, ap); va_end(ap); /*InfoSubstituteControl( NULL, NULL );*/ - if (inError) + if (inError) { return; + } SetMessage(message2); } -EXPORT void ErrorMessage(const char * format, ...) { +EXPORT void ErrorMessage(const char * format, ...) +{ va_list ap; va_start(ap, format); format = ParseMessage(format); @@ -629,7 +611,9 @@ EXPORT void ErrorMessage(const char * format, ...) { inError = TRUE; } -EXPORT int NoticeMessage(const char * format, const char * yes, const char * no, ...) { +EXPORT int NoticeMessage(const char * format, const char * yes, const char * no, + ...) +{ va_list ap; va_start(ap, no); format = ParseMessage(format); @@ -638,11 +622,14 @@ EXPORT int NoticeMessage(const char * format, const char * yes, const char * no, return wNotice(message2, yes, no); } -EXPORT int NoticeMessage2(int playbackRC, const char * format, const char * yes, const char * no, - ...) { +EXPORT int NoticeMessage2(int playbackRC, const char * format, const char * yes, + const char * no, + ...) +{ va_list ap; - if (inPlayback) + if (inPlayback) { return playbackRC; + } va_start(ap, no); format = ParseMessage(format); vsnprintf(message2, 1020, format, ap); @@ -656,24 +643,23 @@ EXPORT int NoticeMessage2(int playbackRC, const char * format, const char * yes, * MAIN BUTTON HANDLERS * */ - /** - * Confirm a requested operation in case of possible loss of changes. - * - * \param label2 IN operation to be cancelled, unused at the moment - * \param after IN function to be executed on positive confirmation - * \return true if proceed, false if cancel operation - */ +/** + * Confirm a requested operation in case of possible loss of changes. + * + * \param label2 IN operation to be cancelled, unused at the moment + * \param after IN function to be executed on positive confirmation + * \return true if proceed, false if cancel operation + */ /** TODO: make sensible messages when requesting confirmation */ -bool -Confirm(char * label2, doSaveCallBack_p after) +EXPORT bool Confirm(char * label2, doSaveCallBack_p after) { int rc = -1; if (changed) { rc = wNotice3(_("Save changes to the layout design before closing?\n\n" - "If you don't save now, your unsaved changes will be discarded."), - _("&Save"), _("&Cancel"), _("&Don't Save")); + "If you don't save now, your unsaved changes will be discarded."), + _("&Save"), _("&Cancel"), _("&Don't Save")); } switch (rc) { @@ -683,91 +669,23 @@ Confirm(char * label2, doSaveCallBack_p after) case 0: /* cancel operation */ break; case 1: /* save */ - LayoutBackGroundInit(FALSE); - LayoutBackGroundSave(); + //LayoutBackGroundInit(FALSE); + //LayoutBackGroundSave(); DoSave(after); break; } return(rc != 0); } -static void ChkLoad(void * unused) { - Confirm(_("Load"), DoLoad); -} - -static void ChkExamples( void * unused ) -{ - Confirm(_("examples"), DoExamples); -} - -static void ChkRevert(void * unused) -{ - int rc; - - if (changed) { - rc = wNoticeEx(NT_WARNING, - _("Do you want to return to the last saved state?\n\n" - "Revert will cause all changes done since last save to be lost."), - _("&Revert"), _("&Cancel")); - if (rc) { - /* load the file */ - char *filename = GetLayoutFullPath(); - LoadTracks(1, &filename, I2VP(1)); //Keep background - } - } -} - -static char * fileListPathName; -static void AfterFileList(void) { - DoFileList(0, NULL, fileListPathName); -} - -static void ChkFileList(int index, const char * label, void * data) { - fileListPathName = (char*) data; - Confirm(_("Load"), AfterFileList); -} - -/** - * Save information about current files and some settings to preferences file. - */ - -EXPORT void SaveState(void) { - wWinPix_t width, height; - const char * fileName; - void * pathName; - char file[6]; - int inx; - - wWinGetSize(mainW, &width, &height); - wPrefSetInteger("draw", "mainwidth", (int)width); - wPrefSetInteger("draw", "mainheight", (int)height); - SaveParamFileList(); - ParamUpdatePrefs(); - - wPrefSetString( "misc", "lastlayout", GetLayoutFullPath()); - wPrefSetInteger( "misc", "lastlayoutexample", bExample ); - - if (fileList_ml) { - strcpy(file, "file"); - file[5] = 0; - for (inx = 0; inx < NUM_FILELIST; inx++) { - fileName = wMenuListGet(fileList_ml, inx, &pathName); - if (fileName) { - file[4] = '0' + inx; - sprintf(message, "%s", (char* )pathName); - wPrefSetString("filelist", file, message); - } - } - } - wPrefFlush(""); -} /* * Clean up before quitting */ -static void DoQuitAfter(void) { +static void DoQuitAfter(void) +{ changed = 0; - CleanupFiles(); //Get rid of checkpoint if we quit. + CleanupCheckpointFiles(); //Get rid of checkpoint if we quit. + CleanupTempArchive(); // removefiels used for archive handling SaveState(); } /** @@ -775,7 +693,8 @@ static void DoQuitAfter(void) { * to close the application. Before shutting down confirmation is gotten to * prevent data loss. */ -void DoQuit(void * unused) { +EXPORT void DoQuit(void * unused) +{ if (Confirm(_("Quit"), DoQuitAfter)) { #ifdef CHECK_UNUSED_BALLOONHELP @@ -786,12 +705,13 @@ void DoQuit(void * unused) { } } -static void DoClearAfter(void) { +static void DoClearAfter(void) +{ Reset(); ClearTracks(); + ResetLayers(); // set all layers to their default properties and set current layer to 0 - /* set all layers to their default properties and set current layer to 0 */ DoLayout(NULL); checkPtMark = changed = 0; DoChangeNotification( CHANGE_MAIN|CHANGE_MAP ); @@ -802,7 +722,8 @@ static void DoClearAfter(void) { LayoutBackGroundInit(TRUE); } -static void DoClear(void * unused) { +EXPORT void DoClear(void * unused) +{ Confirm(_("Clear"), DoClearAfter); } @@ -810,7 +731,8 @@ static void DoClear(void * unused) { * Toggle visibility state of map window. */ -void MapWindowToggleShow(void * unused) { +EXPORT void MapWindowToggleShow(void * unused) +{ MapWindowShow(!mapVisible); } @@ -820,7 +742,8 @@ void MapWindowToggleShow(void * unused) { * \param state IN TRUE if visible, FALSE if hidden */ -void MapWindowShow(int state) { +EXPORT void MapWindowShow(int state) +{ mapVisible = state; wPrefSetInteger("misc", "mapVisible", mapVisible); wMenuToggleSet(mapShowMI, mapVisible); @@ -833,28 +756,9 @@ void MapWindowShow(int state) { wButtonSetBusy(mapShowB, (wBool_t) mapVisible); } -/** - * Set magnets state - */ -int MagneticSnap(int state) -{ - int oldState = magneticSnap; - magneticSnap = state; - wPrefSetInteger("misc", "magnets", magneticSnap); - wMenuToggleSet(magnetsMI, magneticSnap); - wButtonSetBusy(magnetsB, (wBool_t) magneticSnap); - return oldState; -} -/** - * Toggle magnets on/off - */ -void MagneticSnapToggle(void * unused) { - MagneticSnap(!magneticSnap); -} - - -static void DoShowWindow(int index, const char * name, void * data) { +EXPORT void DoShowWindow(int index, const char * name, void * data) +{ if (data == mapW) { if (mapVisible == FALSE) { MapWindowShow( TRUE); @@ -867,17 +771,20 @@ static void DoShowWindow(int index, const char * name, void * data) { static dynArr_t demoWindows_da; #define demoWindows(N) DYNARR_N( wWin_p, demoWindows_da, N ) -EXPORT void wShow(wWin_p win) { +EXPORT void wShow(wWin_p win) +{ int inx; if (inPlayback && win != demoW) { wWinSetBusy(win, TRUE); for (inx = 0; inx < demoWindows_da.cnt; inx++) - if ( demoWindows(inx) == win) + if ( demoWindows(inx) == win) { break; + } if (inx >= demoWindows_da.cnt) { for (inx = 0; inx < demoWindows_da.cnt; inx++) - if ( demoWindows(inx) == NULL) + if ( demoWindows(inx) == NULL) { break; + } if (inx >= demoWindows_da.cnt) { DYNARR_APPEND(wWin_p, demoWindows_da, 10); inx = demoWindows_da.cnt - 1; @@ -885,39 +792,47 @@ EXPORT void wShow(wWin_p win) { demoWindows(inx) = win; } } - if (win != mainW) + if (win != mainW) { wMenuListAdd(winList_mi, -1, wWinGetTitle(win), win); + } wWinShow(win, TRUE); } -EXPORT void wHide(wWin_p win) { +EXPORT void wHide(wWin_p win) +{ int inx; wWinShow(win, FALSE); wWinSetBusy(win, FALSE); - if (inMainW && win == aboutW) + if (inMainW && win == aboutW) { return; + } wMenuListDelete(winList_mi, wWinGetTitle(win)); ParamResetInvalid( win ); if (inPlayback) for (inx = 0; inx < demoWindows_da.cnt; inx++) - if ( demoWindows(inx) == win) + if ( demoWindows(inx) == win) { demoWindows(inx) = NULL; + } } -EXPORT void CloseDemoWindows(void) { +EXPORT void CloseDemoWindows(void) +{ int inx; for (inx = 0; inx < demoWindows_da.cnt; inx++) - if ( demoWindows(inx) != NULL) + if ( demoWindows(inx) != NULL) { wHide(demoWindows(inx)); - demoWindows_da.cnt = 0; + } + DYNARR_RESET( wWin_p, demoWindows_da ); } -EXPORT void DefaultProc(wWin_p win, winProcEvent e, void * data) { +EXPORT void DefaultProc(wWin_p win, winProcEvent e, void * data) +{ switch (e) { case wClose_e: wMenuListDelete(winList_mi, wWinGetTitle(win)); - if (data != NULL) + if (data != NULL) { ConfirmReset( FALSE); + } wWinDoCancel(win); break; default: @@ -925,1321 +840,15 @@ EXPORT void DefaultProc(wWin_p win, winProcEvent e, void * data) { } } -static void NextWindow(void) { -} - -EXPORT void SelectFont(void * unused) { - wSelectFont(_("XTrackCAD Font")); -} - -/***************************************************************************** - * - * COMMAND - * - */ - -#define COMMAND_MAX (180) -#define BUTTON_MAX (180) -#define NUM_CMDMENUS (4) - -static struct { - wControl_p control; - wBool_t enabled; - wWinPix_t x, y; - long options; - int group; - wIndex_t cmdInx; -} buttonList[BUTTON_MAX]; -static int buttonCnt = 0; - -static struct { - procCommand_t cmdProc; - char * helpKey; - wIndex_t buttInx; - char * labelStr; - wIcon_p icon; - int reqLevel; - wBool_t enabled; - long options; - long stickyMask; - long acclKey; - wMenuPush_p menu[NUM_CMDMENUS]; - void * context; -} commandList[COMMAND_MAX]; -static int commandCnt = 0; - -#ifdef CHECK_UNUSED_BALLOONHELP -int * balloonHelpCnts; -#endif - -EXPORT const char * GetBalloonHelpStr(const char * helpKey) { - wBalloonHelp_t * bh; -#ifdef CHECK_UNUSED_BALLOONHELP - if ( balloonHelpCnts == NULL ) { - for ( bh=balloonHelp; bh->name; bh++ ); - balloonHelpCnts = (int*)malloc( (sizeof *(int*)0) * (bh-balloonHelp) ); - memset( balloonHelpCnts, 0, (sizeof *(int*)0) * (bh-balloonHelp) ); - } -#endif - for (bh = balloonHelp; bh->name; bh++) { - if (strcmp(bh->name, helpKey) == 0) { -#ifdef CHECK_UNUSED_BALLOONHELP - balloonHelpCnts[(bh-balloonHelp)]++; -#endif - return _(bh->value); - } - } -#ifdef CHECK_BALLOONHELP - fprintf( stderr, _("No balloon help for %s\n"), helpKey ); -#endif - return _("No Help"); -} - -#ifdef CHECK_UNUSED_BALLOONHELP -static void ShowUnusedBalloonHelp( void ) +static void NextWindow(void) { - int cnt; - for ( cnt=0; balloonHelp[cnt].name; cnt++ ) - if ( balloonHelpCnts[cnt] == 0 ) - fprintf( stderr, "unused BH %s\n", balloonHelp[cnt].name ); -} -#endif - -EXPORT const char* GetCurCommandName() { - return commandList[curCommand].helpKey; -} - -EXPORT void EnableCommands(void) { - int inx, minx; - wBool_t enable; - - LOG(log_command, 5, - ( "COMMAND enable S%d M%d\n", selectedTrackCount, programMode )) - for (inx = 0; inx < commandCnt; inx++) { - if (commandList[inx].buttInx) { - if ((commandList[inx].options & IC_SELECTED) - && selectedTrackCount <= 0) - enable = FALSE; - else if ((programMode == MODE_TRAIN - && (commandList[inx].options - & (IC_MODETRAIN_TOO | IC_MODETRAIN_ONLY)) == 0) - || (programMode != MODE_TRAIN - && (commandList[inx].options & IC_MODETRAIN_ONLY) - != 0)) - enable = FALSE; - else - enable = TRUE; - if (commandList[inx].enabled != enable) { - if (commandList[inx].buttInx >= 0) - wControlActive(buttonList[commandList[inx].buttInx].control, - enable); - for (minx = 0; minx < NUM_CMDMENUS; minx++) - if (commandList[inx].menu[minx]) - wMenuPushEnable(commandList[inx].menu[minx], enable); - commandList[inx].enabled = enable; - } - } - } - - for (inx = 0; inx < menuPG.paramCnt; inx++) { - if (menuPLs[inx].control == NULL) - continue; - if ((menuPLs[inx].option & IC_SELECTED) && selectedTrackCount <= 0) - enable = FALSE; - else if ((programMode == MODE_TRAIN - && (menuPLs[inx].option & (IC_MODETRAIN_TOO | IC_MODETRAIN_ONLY)) - == 0) - || (programMode != MODE_TRAIN - && (menuPLs[inx].option & IC_MODETRAIN_ONLY) != 0)) - enable = FALSE; - else - enable = TRUE; - wMenuPushEnable((wMenuPush_p) menuPLs[inx].control, enable); - } - - for (inx = 0; inx < buttonCnt; inx++) { - if (buttonList[inx].cmdInx < 0 - && (buttonList[inx].options & IC_SELECTED)) - wControlActive(buttonList[inx].control, selectedTrackCount > 0); - } -} - -EXPORT wIndex_t GetCurrentCommand() { - return curCommand; -} - -static wIndex_t autosave_count = 0; - -EXPORT void TryCheckPoint() { - if (checkPtInterval > 0 - && changed >= checkPtMark + (wIndex_t) checkPtInterval - && !inPlayback) { - DoCheckPoint(); - checkPtMark = changed; - - autosave_count++; - - if ((autosaveChkPoints>0) && (autosave_count>=autosaveChkPoints)) { - if ( bReadOnly || *(GetLayoutFilename()) == '\0') { - SetAutoSave(); - } else - DoSave(NULL); - InfoMessage(_("File AutoSaved")); - autosave_count = 0; - } - } -} - -EXPORT void Reset(void) { - if (recordF) { - fprintf(recordF, "RESET\n"); - fflush(recordF); - } - LOG(log_command, 2, - ( "COMMAND CANCEL %s\n", commandList[curCommand].helpKey )) - commandList[curCommand].cmdProc( C_CANCEL, zero); - if (commandList[curCommand].buttInx >= 0) - wButtonSetBusy( - (wButton_p) buttonList[commandList[curCommand].buttInx].control, - FALSE); - curCommand = (preSelect ? selectCmdInx : describeCmdInx); - wSetCursor(mainD.d, preSelect ? defaultCursor : wCursorQuestion); - commandContext = commandList[curCommand].context; - if (commandList[curCommand].buttInx >= 0) - wButtonSetBusy( - (wButton_p) buttonList[commandList[curCommand].buttInx].control, - TRUE); - tempSegs_da.cnt = 0; - - TryCheckPoint(); - - ClrAllTrkBits( TB_UNDRAWN ); - DoRedraw(); // Reset - EnableCommands(); - ResetMouseState(); - LOG(log_command, 1, - ( "COMMAND RESET %s\n", commandList[curCommand].helpKey )) - (void) commandList[curCommand].cmdProc( C_START, zero); -} - -static BOOL_T CheckClick(wAction_t *action, coOrd *pos, BOOL_T checkLeft, - BOOL_T checkRight) { - static long time0; - static coOrd pos0; - long time1; - long timeDelta; - DIST_T distDelta; - - switch (*action) { - case C_LDOUBLE: - if (!checkLeft) - return TRUE; - time0 = 0; - break; - case C_DOWN: - if (!checkLeft) - return TRUE; - time0 = wGetTimer() - adjTimer; - pos0 = *pos; - return FALSE; - case C_MOVE: - if (!checkLeft) - return TRUE; - if (time0 != 0) { - time1 = wGetTimer() - adjTimer; - timeDelta = time1 - time0; - distDelta = FindDistance(*pos, pos0); - if (timeDelta > dragTimeout || distDelta > dragDistance) { - time0 = 0; - *pos = pos0; - *action = C_DOWN; - } else { - return FALSE; - } - } - break; - case C_UP: - if (!checkLeft) - return TRUE; - if (time0 != 0) { - time1 = wGetTimer() - adjTimer; - timeDelta = time1 - time0; - distDelta = FindDistance(*pos, pos0); - time0 = 0; - *action = C_LCLICK; - } - break; - case C_RDOWN: - if (!checkRight) - return TRUE; - time0 = wGetTimer() - adjTimer; - pos0 = *pos; - return FALSE; - case C_RMOVE: - if (!checkRight) - return TRUE; - if (time0 != 0) { - time1 = wGetTimer() - adjTimer; - timeDelta = time1 - time0; - distDelta = FindDistance(*pos, pos0); - if (timeDelta > dragTimeout || distDelta > dragDistance) { - time0 = 0; - *pos = pos0; - *action = C_RDOWN; - } else { - return FALSE; - } - } - break; - case C_RUP: - if (!checkRight) - return TRUE; - if (time0 != 0) { - time0 = 0; - *action = C_RCLICK; - } - break; - } - return TRUE; } -EXPORT wBool_t DoCurCommand(wAction_t action, coOrd pos) { - wAction_t rc; - int mode; - wBool_t bExit = FALSE; - - if (action == wActionMove) { - if ((commandList[curCommand].options & IC_WANT_MOVE) == 0) { - bExit = TRUE; - } - } else if ((action&0xFF) == wActionModKey) { - if ((commandList[curCommand].options & IC_WANT_MODKEYS) == 0) { - bExit = TRUE; - } - } else if (!CheckClick(&action, &pos, - (int) (commandList[curCommand].options & IC_LCLICK), TRUE)) { - bExit = TRUE; - } else if (action == C_RCLICK - && (commandList[curCommand].options & IC_RCLICK) == 0) { - if (!inPlayback) { - mode = MyGetKeyState(); - if ((mode & (~WKEY_SHIFT)) != 0) { - wBeep(); - bExit = TRUE; - } else if (((mode & WKEY_SHIFT) == 0) == (rightClickMode == 0)) { - if (selectedTrackCount > 0) { - if (commandList[curCommand].options & IC_CMDMENU) { - } - wMenuPopupShow(popup2M); - } else { - wMenuPopupShow(popup1M); - } - bExit = TRUE; - } else if ((commandList[curCommand].options & IC_CMDMENU)) { - cmdMenuPos = pos; - action = C_CMDMENU; - } else { - wBeep(); - bExit = TRUE; - } - } else { - bExit = TRUE; - } - } - if ( bExit ) { - TempRedraw(); // DoCurCommand: precommand - return C_CONTINUE; - } - - LOG(log_command, 2, - ( "COMMAND MOUSE %s %d @ %0.3f %0.3f\n", commandList[curCommand].helpKey, (int)action, pos.x, pos.y )) - rc = commandList[curCommand].cmdProc(action, pos); - LOG(log_command, 4, ( " COMMAND returns %d\n", rc )) - switch ( action & 0xFF ) { - case wActionMove: - case wActionModKey: - case C_DOWN: - case C_MOVE: - case C_UP: - case C_RDOWN: - case C_RMOVE: - case C_RUP: - case C_LCLICK: - case C_RCLICK: - case C_TEXT: - case C_OK: - if (rc== C_TERMINATE) MainRedraw(); - else TempRedraw(); // DoCurCommand: postcommand - break; - default: - break; - } - if ((rc == C_TERMINATE || rc == C_INFO) - && (commandList[curCommand].options & IC_STICKY) - && (commandList[curCommand].stickyMask & stickySet)) { - tempSegs_da.cnt = 0; - UpdateAllElevations(); - if (commandList[curCommand].options & IC_NORESTART) { - return C_CONTINUE; - } - //Make sure we checkpoint even sticky commands - TryCheckPoint(); - LOG(log_command, 1, - ( "COMMAND START %s\n", commandList[curCommand].helpKey )) - wSetCursor(mainD.d,defaultCursor); - rc = commandList[curCommand].cmdProc( C_START, pos); - LOG(log_command, 4, ( " COMMAND returns %d\n", rc )) - switch (rc) { - case C_CONTINUE: - break; - case C_ERROR: - Reset(); -#ifdef VERBOSE - lprintf( "Start returns Error"); -#endif - break; - case C_TERMINATE: - InfoMessage(""); - case C_INFO: - Reset(); - break; - } - } - return rc; -} - -/* - * \parm reset says if the user used Esc rather than undo/redo - */ -EXPORT int ConfirmReset(BOOL_T retry) { - wAction_t rc; - if (curCommand != describeCmdInx) { - LOG(log_command, 3, - ( "COMMAND CONFIRM %s\n", commandList[curCommand].helpKey )) - rc = commandList[curCommand].cmdProc( C_CONFIRM, zero); - LOG(log_command, 4, ( " COMMAND returns %d\n", rc )) - if (rc == C_ERROR) { - if (retry) - rc = - wNotice3( - _( - "Cancelling the current command will undo the changes\n" - "you are currently making. Do you want to do the update instead?"), - _("Yes"), _("No"), _("Cancel")); - else - rc = - wNoticeEx( NT_WARNING, - _( - "Cancelling the current command will undo the changes\n" - "you are currently making. Do you want to do the update instead?"), - _("Yes"), _("No")); - if (rc == 1) { - LOG(log_command, 3, - ( "COMMAND OK %s\n", commandList[curCommand].helpKey )) - commandList[curCommand].cmdProc( C_OK, zero); - return C_OK; - } else if (rc == -1) { - return C_CANCEL; - } - } else if (rc == C_TERMINATE) { - return C_TERMINATE; - } - } - if (retry) { - /* because user pressed esc */ - SetAllTrackSelect( FALSE); - } - Reset(); - LOG(log_command, 1, - ( "COMMAND RESET %s\n", commandList[curCommand].helpKey )) - commandList[curCommand].cmdProc( C_START, zero); - return C_CONTINUE; -} - -EXPORT BOOL_T IsCurCommandSticky(void) { - if ((commandList[curCommand].options & IC_STICKY) != 0 - && (commandList[curCommand].stickyMask & stickySet) != 0) - return TRUE; - return FALSE; -} - -EXPORT void ResetIfNotSticky(void) { - if ((commandList[curCommand].options & IC_STICKY) == 0 - || (commandList[curCommand].stickyMask & stickySet) == 0) - Reset(); -} - -EXPORT void DoCommandB(void * data) { - wIndex_t inx = (wIndex_t)VP2L(data); - STATUS_T rc; - static coOrd pos = { 0, 0 }; - static int inDoCommandB = FALSE; - wIndex_t buttInx; - - if (inDoCommandB) - return; - inDoCommandB = TRUE; - - if (inx < 0 || inx >= commandCnt) { - ASSERT(FALSE); - inDoCommandB = FALSE; - return; - } - - if ((!inPlayback) && (!commandList[inx].enabled)) { - ErrorMessage(MSG_COMMAND_DISABLED); - inx = describeCmdInx; - } - - InfoMessage(""); - if (curCommand != selectCmdInx) { - LOG(log_command, 3, - ( "COMMAND FINISH %s\n", commandList[curCommand].helpKey )) - rc = commandList[curCommand].cmdProc( C_FINISH, zero); - LOG(log_command, 3, - ( "COMMAND CONFIRM %s\n", commandList[curCommand].helpKey )) - rc = commandList[curCommand].cmdProc( C_CONFIRM, zero); - LOG(log_command, 4, ( " COMMAND returns %d\n", rc )) - if (rc == C_ERROR) { - rc = wNotice3( - _("Cancelling the current command will undo the changes\n" - "you are currently making. Do you want to update?"), - _("Yes"), _("No"), _("Cancel")); - if (rc == 1) - commandList[curCommand].cmdProc( C_OK, zero); - else if (rc == -1) { - inDoCommandB = FALSE; - return; - } - } - LOG(log_command, 3, - ( "COMMAND CANCEL %s\n", commandList[curCommand].helpKey )) - commandList[curCommand].cmdProc( C_CANCEL, pos); - tempSegs_da.cnt = 0; - } else { - LOG(log_command, 3, - ( "COMMAND FINISH %s\n", commandList[curCommand].helpKey )) - rc = commandList[curCommand].cmdProc( C_FINISH, zero); - } - if (commandList[curCommand].buttInx >= 0) - wButtonSetBusy( - (wButton_p) buttonList[commandList[curCommand].buttInx].control, - FALSE); - - if (recordF) { - fprintf(recordF, "COMMAND %s\n", commandList[inx].helpKey + 3); - fflush(recordF); - } - - curCommand = inx; - commandContext = commandList[curCommand].context; - if ((buttInx = commandList[curCommand].buttInx) >= 0) { - if (buttonList[buttInx].cmdInx != curCommand) { - wButtonSetLabel((wButton_p) buttonList[buttInx].control, - (char*) commandList[curCommand].icon); - wControlSetHelp(buttonList[buttInx].control, - GetBalloonHelpStr(commandList[curCommand].helpKey)); - wControlSetContext(buttonList[buttInx].control, - I2VP(curCommand)); - buttonList[buttInx].cmdInx = curCommand; - } - wButtonSetBusy( - (wButton_p) buttonList[commandList[curCommand].buttInx].control, - TRUE); - } - LOG(log_command, 1, - ( "COMMAND START %s\n", commandList[curCommand].helpKey )) - wSetCursor(mainD.d,defaultCursor); - rc = commandList[curCommand].cmdProc( C_START, pos); - LOG(log_command, 4, ( " COMMAND returns %d\n", rc )) - TempRedraw(); // DoCommandB - switch (rc) { - case C_CONTINUE: - break; - case C_ERROR: - Reset(); -#ifdef VERBOSE - lprintf( "Start returns Error"); -#endif - break; - case C_TERMINATE: - case C_INFO: - if (rc == C_TERMINATE) - InfoMessage(""); - Reset(); - break; - } - inDoCommandB = FALSE; -} - -static void DoCommandBIndirect(void * cmdInxP) { - wIndex_t cmdInx; - cmdInx = *(wIndex_t*) cmdInxP; - DoCommandB(I2VP(cmdInx)); -} - -EXPORT void LayoutSetPos(wIndex_t inx) { - wWinPix_t w, h, offset; - static wWinPix_t toolbarRowHeight = 0; - static wWinPix_t width; - static int lastGroup; - static wWinPix_t gap; - static int layerButtCnt; - static int layerButtNumber; - int currGroup; - - if (inx == 0) { - lastGroup = 0; - wWinGetSize(mainW, &width, &h); - gap = 5; - toolbarWidth = width - 20 + 5; - layerButtCnt = 0; - layerButtNumber = 0; - toolbarHeight = 0; - } - - if (buttonList[inx].control) { - if (toolbarRowHeight <= 0) - toolbarRowHeight = wControlGetHeight(buttonList[inx].control); - - currGroup = buttonList[inx].group & ~BG_BIGGAP; - if (currGroup != lastGroup && (buttonList[inx].group & BG_BIGGAP)) { - gap = 15; - } - if ((toolbarSet & (1 << currGroup)) - && (programMode != MODE_TRAIN - || (buttonList[inx].options - & (IC_MODETRAIN_TOO | IC_MODETRAIN_ONLY))) - && (programMode == MODE_TRAIN - || (buttonList[inx].options & IC_MODETRAIN_ONLY) == 0) - && ((buttonList[inx].group & ~BG_BIGGAP) != BG_LAYER - || layerButtCnt < layerCount)) { - if (currGroup != lastGroup) { - toolbarWidth += gap; - lastGroup = currGroup; - gap = 5; - } - w = wControlGetWidth(buttonList[inx].control); - h = wControlGetHeight(buttonList[inx].control); - if (h<toolbarRowHeight) { - offset = (h-toolbarRowHeight)/2; - h = toolbarRowHeight; //Uniform - } else offset = 0; - if (inx < buttonCnt - 1 && (buttonList[inx + 1].options & IC_ABUT)) - w += wControlGetWidth(buttonList[inx + 1].control); - if (toolbarWidth + w > width - 20) { - toolbarWidth = 0; - toolbarHeight += h + 5; - } - if ((currGroup == BG_LAYER) && layerButtNumber>1 && GetLayerHidden(layerButtNumber-2) ) { - wControlShow(buttonList[inx].control, FALSE); - layerButtNumber++; - } else { - if (currGroup == BG_LAYER ) { - if (layerButtNumber>1) layerButtCnt++; // Ignore List and Background - layerButtNumber++; - } - wControlSetPos(buttonList[inx].control, toolbarWidth, - toolbarHeight - (h + 5 +offset)); - buttonList[inx].x = toolbarWidth; - buttonList[inx].y = toolbarHeight - (h + 5 + offset); - toolbarWidth += wControlGetWidth(buttonList[inx].control); - wControlShow(buttonList[inx].control, TRUE); - } - } else { - wControlShow(buttonList[inx].control, FALSE); - } - } -} - -EXPORT void LayoutToolBar( void * data ) -{ - int inx; - - for (inx = 0; inx < buttonCnt; inx++) { - LayoutSetPos(inx); - } - if (toolbarSet&(1<<BG_HOTBAR)) { - LayoutHotBar(data); - } else { - HideHotBar(); - } -} - -static void ToolbarChange(long changes) { - if ((changes & CHANGE_TOOLBAR)) { - /*if ( !(changes&CHANGE_MAIN) )*/ - MainProc( mainW, wResize_e, NULL, NULL ); - /*else - LayoutToolBar();*/ - } -} -/*************************************************************************** - * - * - * - */ - -EXPORT BOOL_T CommandEnabled(wIndex_t cmdInx) { - return commandList[cmdInx].enabled; -} - -static wIndex_t AddCommand(procCommand_t cmdProc, const char * helpKey, - const char * nameStr, wIcon_p icon, int reqLevel, long options, long acclKey, - void * context) { - if (commandCnt >= COMMAND_MAX - 1) { - AbortProg("addCommand: too many commands"); - } - commandList[commandCnt].labelStr = MyStrdup(nameStr); - commandList[commandCnt].helpKey = MyStrdup(helpKey); - commandList[commandCnt].cmdProc = cmdProc; - commandList[commandCnt].icon = icon; - commandList[commandCnt].reqLevel = reqLevel; - commandList[commandCnt].enabled = TRUE; - commandList[commandCnt].options = options; - commandList[commandCnt].acclKey = acclKey; - commandList[commandCnt].context = context; - commandList[commandCnt].buttInx = -1; - commandList[commandCnt].menu[0] = NULL; - commandList[commandCnt].menu[1] = NULL; - commandList[commandCnt].menu[2] = NULL; - commandList[commandCnt].menu[3] = NULL; - commandCnt++; - return commandCnt - 1; -} - -EXPORT void AddToolbarControl(wControl_p control, long options) { - if (buttonCnt >= COMMAND_MAX - 1) { - AbortProg("addToolbarControl: too many buttons"); - } - buttonList[buttonCnt].enabled = TRUE; - buttonList[buttonCnt].options = options; - buttonList[buttonCnt].group = cmdGroup; - buttonList[buttonCnt].x = 0; - buttonList[buttonCnt].y = 0; - buttonList[buttonCnt].control = control; - buttonList[buttonCnt].cmdInx = -1; - LayoutSetPos(buttonCnt); - buttonCnt++; -} - -EXPORT wButton_p AddToolbarButton(const char * helpStr, wIcon_p icon, long options, - wButtonCallBack_p action, void * context) { - wButton_p bb; - wIndex_t inx; - - GetBalloonHelpStr(helpStr); - if (context == NULL) { - for (inx = 0; inx < menuPG.paramCnt; inx++) { - if (action != DoCommandB && menuPLs[inx].valueP == I2VP(action)) { - context = &menuPLs[inx]; - action = ParamMenuPush; - menuPLs[inx].context = I2VP(buttonCnt); - menuPLs[inx].option |= IC_PLAYBACK_PUSH; - break; - } - } - } - bb = wButtonCreate(mainW, 0, 0, helpStr, (char*) icon, - BO_ICON/*|((options&IC_CANCEL)?BB_CANCEL:0)*/, 0, action, context); - AddToolbarControl((wControl_p) bb, options); - return bb; -} - -EXPORT void PlaybackButtonMouse(wIndex_t buttInx) { - wWinPix_t cmdX, cmdY; - coOrd pos; - - if (buttInx < 0 || buttInx >= buttonCnt) - return; - if (buttonList[buttInx].control == NULL) - return; - cmdX = buttonList[buttInx].x + 17; - cmdY = toolbarHeight - (buttonList[buttInx].y + 17) - + (wWinPix_t) (mainD.size.y / mainD.scale * mainD.dpi) + 30; - - mainD.Pix2CoOrd( &mainD, cmdX, cmdY, &pos ); - MovePlaybackCursor(&mainD, pos, TRUE, buttonList[buttInx].control); - if (playbackTimer == 0) { - wButtonSetBusy((wButton_p) buttonList[buttInx].control, TRUE); - wFlush(); - wPause(500); - wButtonSetBusy((wButton_p) buttonList[buttInx].control, FALSE); - wFlush(); - } -} - -#include "bitmaps/down.xpm" -static const char * buttonGroupMenuTitle; -static const char * buttonGroupHelpKey; -static const char * buttonGroupStickyLabel; -static wMenu_p buttonGroupPopupM; - -EXPORT void ButtonGroupBegin(const char * menuTitle, const char * helpKey, - const char * stickyLabel) { - buttonGroupMenuTitle = menuTitle; - buttonGroupHelpKey = helpKey; - buttonGroupStickyLabel = stickyLabel; - buttonGroupPopupM = NULL; -} - -EXPORT void ButtonGroupEnd(void) { - buttonGroupMenuTitle = NULL; - buttonGroupHelpKey = NULL; - buttonGroupPopupM = NULL; -} - -EXPORT wIndex_t AddMenuButton(wMenu_p menu, procCommand_t command, - const char * helpKey, const char * nameStr, wIcon_p icon, int reqLevel, - long options, long acclKey, void * context) { - wIndex_t buttInx = -1; - wIndex_t cmdInx; - BOOL_T newButtonGroup = FALSE; - wMenu_p tm, p1m, p2m; - static wIcon_p openbuttIcon = NULL; - static wMenu_p commandsSubmenu; - static wMenu_p popup1Submenu; - static wMenu_p popup2Submenu; - - if (icon) { - if (buttonGroupPopupM != NULL) { - buttInx = buttonCnt - 2; - } else { - buttInx = buttonCnt; - AddToolbarButton(helpKey, icon, options, - DoCommandB, - I2VP(commandCnt)); - buttonList[buttInx].cmdInx = commandCnt; - } - if (buttonGroupMenuTitle != NULL && buttonGroupPopupM == NULL) { - if (openbuttIcon == NULL) - openbuttIcon = wIconCreatePixMap(down_xpm[iconSize]); - buttonGroupPopupM = wMenuPopupCreate(mainW, buttonGroupMenuTitle); - AddToolbarButton(buttonGroupHelpKey, openbuttIcon, IC_ABUT, - (wButtonCallBack_p) wMenuPopupShow, - buttonGroupPopupM); - newButtonGroup = TRUE; - commandsSubmenu = wMenuMenuCreate(menu, "", buttonGroupMenuTitle); - if (options & IC_POPUP2) { - popup1Submenu = wMenuMenuCreate(popup1aM, "", buttonGroupMenuTitle); - popup2Submenu = wMenuMenuCreate(popup2aM, "", buttonGroupMenuTitle); - } else if (options & IC_POPUP3) { - popup1Submenu= wMenuMenuCreate(popup1mM, "", buttonGroupMenuTitle); - popup2Submenu = wMenuMenuCreate(popup2mM, "", buttonGroupMenuTitle); - - } else { - popup1Submenu = wMenuMenuCreate(popup1M, "", buttonGroupMenuTitle); - popup2Submenu = wMenuMenuCreate(popup2M, "", buttonGroupMenuTitle); - } - } - } - cmdInx = AddCommand(command, helpKey, nameStr, icon, reqLevel, options, - acclKey, context); - commandList[cmdInx].buttInx = buttInx; - if (nameStr[0] == '\0') - return cmdInx; - if (commandList[cmdInx].options & IC_STICKY) { - if (buttonGroupPopupM == NULL || newButtonGroup) { - if (stickyCnt > 32) - AbortProg("stickyCnt>32"); - stickyCnt++; - } - if (buttonGroupPopupM == NULL) { - stickyLabels[stickyCnt - 1] = nameStr; - } else { - stickyLabels[stickyCnt - 1] = buttonGroupStickyLabel; - } - stickyLabels[stickyCnt] = NULL; - long stickyMask = 1L<<(stickyCnt-1); - commandList[cmdInx].stickyMask = stickyMask; - if ( ( commandList[cmdInx].options & IC_INITNOTSTICKY ) == 0 ) - stickySet |= stickyMask; - } - if (buttonGroupPopupM) { - commandList[cmdInx].menu[0] = wMenuPushCreate(buttonGroupPopupM, - helpKey, GetBalloonHelpStr(helpKey), 0, DoCommandB, - I2VP(cmdInx)); - tm = commandsSubmenu; - p1m = popup1Submenu; - p2m = popup2Submenu; - } else { - tm = menu; - p1m = (options & IC_POPUP2) ? popup1aM : (options & IC_POPUP3) ? popup1mM : popup1M; - p2m = (options & IC_POPUP2) ? popup2aM : (options & IC_POPUP3) ? popup2mM : popup2M; - } - commandList[cmdInx].menu[1] = wMenuPushCreate(tm, helpKey, nameStr, acclKey, - DoCommandB, I2VP(cmdInx)); - if ((options & (IC_POPUP | IC_POPUP2 | IC_POPUP3))) { - if (!(options & IC_SELECTED)) { - commandList[cmdInx].menu[2] = wMenuPushCreate(p1m, helpKey, nameStr, - 0, DoCommandB, I2VP(cmdInx)); - } - commandList[cmdInx].menu[3] = wMenuPushCreate(p2m, helpKey, nameStr, 0, - DoCommandB, I2VP(cmdInx)); - } - - return cmdInx; -} - -EXPORT wIndex_t InitCommand(wMenu_p menu, procCommand_t command, const char * nameStr, - const char * bits, int reqLevel, long options, long acclKey) { - char helpKey[STR_SHORT_SIZE]; - wIcon_p icon = NULL; - if (bits) - icon = wIconCreateBitMap(16, 16, bits, wDrawColorBlack); - strcpy(helpKey, "cmd"); - strcat(helpKey, nameStr); - return AddMenuButton(menu, command, helpKey, _(nameStr), icon, reqLevel, - options, acclKey, NULL); -} - -/*--------------------------------------------------------------------*/ - -EXPORT void PlaybackCommand(const char * line, wIndex_t lineNum) { - size_t inx; - wIndex_t buttInx; - size_t len1, len2; - len1 = strlen(line + 8); - for (inx = 0; inx < commandCnt; inx++) { - len2 = strlen(commandList[inx].helpKey + 3); - if (len1 == len2 - && strncmp(line + 8, commandList[inx].helpKey + 3, len2) == 0) { - break; - } - } - if (inx >= commandCnt) { - fprintf(stderr, "Unknown playback COMMAND command %d : %s\n", lineNum, - line); - } else { - wWinPix_t cmdX, cmdY; - coOrd pos; - if ((buttInx = commandList[inx].buttInx) >= 0) { - cmdX = buttonList[buttInx].x + 17; - cmdY = toolbarHeight - (buttonList[buttInx].y + 17) - + (wWinPix_t) (mainD.size.y / mainD.scale * mainD.dpi) + 30; - mainD.Pix2CoOrd( &mainD, cmdX, cmdY, &pos ); - MovePlaybackCursor(&mainD, pos,TRUE,buttonList[buttInx].control); - } - if (strcmp(line + 8, "Undo") == 0) { - if (buttInx > 0 && playbackTimer == 0) { - wButtonSetBusy((wButton_p) buttonList[buttInx].control, TRUE); - wFlush(); - wPause(500); - wButtonSetBusy((wButton_p) buttonList[buttInx].control, FALSE); - wFlush(); - } - UndoUndo(NULL); - } else if (strcmp(line + 8, "Redo") == 0) { - if (buttInx >= 0 && playbackTimer == 0) { - wButtonSetBusy((wButton_p) buttonList[buttInx].control, TRUE); - wFlush(); - wPause(500); - wButtonSetBusy((wButton_p) buttonList[buttInx].control, FALSE); - wFlush(); - } - UndoRedo(NULL); - } else { - if (buttInx >= 0 && playbackTimer == 0) { - wButtonSetBusy((wButton_p) buttonList[buttInx].control, TRUE); - wFlush(); - wPause(500); - wButtonSetBusy((wButton_p) buttonList[buttInx].control, FALSE); - wFlush(); - } - DoCommandB(I2VP(inx)); - } - } -} - -/*--------------------------------------------------------------------*/ -typedef struct { - char * label; - wMenu_p menu; -} menuTrace_t, *menuTrace_p; -static dynArr_t menuTrace_da; -#define menuTrace(N) DYNARR_N( menuTrace_t, menuTrace_da, N ) - -static void DoMenuTrace(wMenu_p menu, const char * label, void * data) { - /*printf( "MENUTRACE: %s/%s\n", (char*)data, label );*/ - if (recordF) { - fprintf(recordF, "MOUSE 1 %0.3f %0.3f\n", oldMarker.x, oldMarker.y); - fprintf(recordF, "MENU %0.3f %0.3f \"%s\" \"%s\"\n", oldMarker.x, - oldMarker.y, (char*) data, label); - } -} - -EXPORT wMenu_p MenuRegister(const char * label) { - wMenu_p m; - menuTrace_p mt; - m = wMenuPopupCreate(mainW, label); - DYNARR_APPEND(menuTrace_t, menuTrace_da, 10); - mt = &menuTrace(menuTrace_da.cnt - 1); - mt->label = strdup(label); - mt->menu = m; - wMenuSetTraceCallBack(m, DoMenuTrace, mt->label); - return m; -} - -void MenuPlayback(char * line) { - char * menuName, *itemName; - coOrd pos; - menuTrace_p mt; - - if (!GetArgs(line, "pqq", &pos, &menuName, &itemName)) - return; - for (mt = &menuTrace(0); mt < &menuTrace(menuTrace_da.cnt); mt++) { - if (strcmp(mt->label, menuName) == 0) { - MovePlaybackCursor(&mainD, pos, FALSE, NULL); - oldMarker = cmdMenuPos = pos; - wMenuAction(mt->menu, _(itemName)); - return; - } - } - AbortProg("menuPlayback: %s not found", menuName); -} -/*--------------------------------------------------------------------*/ - -static wWin_p stickyW; - -static void StickyOk(void * unused); -static paramData_t stickyPLs[] = { { PD_TOGGLE, &stickySet, "set", 0, - stickyLabels } }; -static paramGroup_t stickyPG = { "sticky", PGO_RECORD, stickyPLs, - COUNT( stickyPLs ) }; - -static void StickyOk(void * unused) { - wHide(stickyW); -} - -static void DoSticky(void * unused) { - if (!stickyW) - stickyW = ParamCreateDialog(&stickyPG, - MakeWindowTitle(_("Sticky Commands")), _("Ok"), StickyOk, wHide, - TRUE, NULL, 0, NULL); - ParamLoadControls(&stickyPG); - wShow(stickyW); -} -/*--------------------------------------------------------------------*/ - -/* - * These array control the choices available in the Toolbar setup. - * For each choice, the text is given and the respective mask is - * specified in the following array. - * Note: text and choices must be given in the same order. - */ -static char *AllToolbarLabels[] = { N_("File Buttons"), N_("Print Buttons"), N_("Import/Export Buttons"), - N_("Zoom Buttons"), N_("Undo Buttons"), N_("Easement Button"), N_("SnapGrid Buttons"), - N_("Create Track Buttons"), N_("Layout Control Elements"), - N_("Modify Track Buttons"), N_("Properties/Select"), - N_("Track Group Buttons"), N_("Train Group Buttons"), - N_("Create Misc Buttons"), N_("Ruler Button"), - N_("Layer Buttons"), N_("Hot Bar"), -NULL }; -static long AllToolbarMasks[] = { 1 << BG_FILE, 1<< BG_PRINT, 1<< BG_EXPORTIMPORT, - 1<< BG_ZOOM, 1<< BG_UNDO, 1<< BG_EASE, 1 << BG_SNAP, 1 << BG_TRKCRT, - 1<< BG_CONTROL, 1<< BG_TRKMOD, 1 << BG_SELECT, 1 << BG_TRKGRP, 1 << BG_TRAIN, - 1<< BG_MISCCRT, 1<< BG_RULER, 1 << BG_LAYER, 1 << BG_HOTBAR }; - -static wMenuToggle_p AllToolbarMI[ COUNT( AllToolbarMasks ) ]; - -static void ToolbarAction(void * data) { - int inx = (int)VP2L(data); - ASSERT( inx >=0 && inx < COUNT( AllToolbarMasks ) ); - wBool_t set = wMenuToggleGet( AllToolbarMI[inx] ); - long mask = AllToolbarMasks[inx]; - if (set) - toolbarSet |= mask; - else - toolbarSet &= ~mask; - wPrefSetInteger( "misc", "toolbarset", toolbarSet ); - MainProc( mainW, wResize_e, NULL, NULL ); - if (recordF) - fprintf(recordF, "PARAMETER %s %s %ld", "misc", "toolbarset", - toolbarSet); -} - -/** - * Create the Toolbar configuration submenu. Based on two arrays of descriptions and - * masks, the toolbar submenu is created dynamically. - * - * \param toolbarM IN menu to which the toogles will be added - */ - -static void CreateToolbarM(wMenu_p toolbarM) { - int inx, cnt; - long *masks; - char **labels; - wBool_t set; - - cnt = COUNT(AllToolbarMasks); - masks = AllToolbarMasks; - labels = AllToolbarLabels; - for (inx = 0; inx < cnt; inx++, masks++, labels++) { - set = (toolbarSet & *masks) != 0; - AllToolbarMI[inx] = wMenuToggleCreate(toolbarM, "toolbarM", _(*labels), 0, set, - ToolbarAction, I2VP(inx)); - } -} - -/*--------------------------------------------------------------------*/ - -static wWin_p addElevW; -#define addElevF (wFloat_p)addElevPD.control -EXPORT DIST_T addElevValueV; -static void DoAddElev(void * unused); - -static paramFloatRange_t rn1000_1000 = { -1000.0, 1000.0 }; -static paramData_t addElevPLs[] = { { PD_FLOAT, &addElevValueV, "value", - PDO_NOPREF|PDO_DIM, &rn1000_1000, NULL, 0 } }; -static paramGroup_t addElevPG = { "addElev", 0, addElevPLs, COUNT( addElevPLs ) }; - -static void DoAddElev(void * unused) { - ParamLoadData(&addElevPG); - AddElevations(addElevValueV); - wHide(addElevW); -} - -static void ShowAddElevations(void * unused) { - if (selectedTrackCount <= 0) { - ErrorMessage(MSG_NO_SELECTED_TRK); - return; - } - if (addElevW == NULL) - addElevW = ParamCreateDialog(&addElevPG, - MakeWindowTitle(_("Change Elevations")), _("Change"), DoAddElev, - wHide, FALSE, NULL, 0, NULL); - wShow(addElevW); -} - -/*--------------------------------------------------------------------*/ - -static wWin_p rotateW; -static wWin_p indexW; -static wWin_p moveW; -static double rotateValue; -static char trackIndex[STR_LONG_SIZE]; -static coOrd moveValue; -static rotateDialogCallBack_t rotateDialogCallBack; -static indexDialogCallBack_t indexDialogCallBack; -static moveDialogCallBack_t moveDialogCallBack; - -static void RotateEnterOk(void * unused); - -static paramFloatRange_t rn360_360 = { -360.0, 360.0, 80 }; -static paramData_t rotatePLs[] = { { PD_FLOAT, &rotateValue, "rotate", PDO_NOPREF|PDO_ANGLE|PDO_NORECORD, &rn360_360, N_("Angle:") } }; -static paramGroup_t rotatePG = { "rotate", 0, rotatePLs, COUNT( rotatePLs ) }; - -static void IndexEnterOk(void * unused); -static paramData_t indexPLs[] = { - { PD_STRING, &trackIndex, "select", PDO_NOPREF|PDO_NORECORD|PDO_STRINGLIMITLENGTH, I2VP(STR_SIZE-1), N_("Indexes:"), 0, 0, sizeof(trackIndex) } }; -static paramGroup_t indexPG = { "index", 0, indexPLs, COUNT( indexPLs ) }; - -static paramFloatRange_t r_1000_1000 = { -1000.0, 1000.0, 80 }; -static void MoveEnterOk(void * unused); -static paramData_t movePLs[] = { - { PD_FLOAT, &moveValue.x, "moveX", PDO_NOPREF|PDO_DIM|PDO_NORECORD, &r_1000_1000, N_("Move X:") }, - { PD_FLOAT, &moveValue.y, "moveY", PDO_NOPREF|PDO_DIM|PDO_NORECORD, &r_1000_1000, N_("Move Y:") } }; -static paramGroup_t movePG = { "move", 0, movePLs, COUNT( movePLs ) }; - -static void StartRotateDialog(void * funcVP) -{ - rotateDialogCallBack_t func = funcVP; - if (rotateW == NULL) - rotateW = ParamCreateDialog(&rotatePG, MakeWindowTitle(_("Rotate")), - _("Ok"), RotateEnterOk, wHide, FALSE, NULL, 0, NULL); - ParamLoadControls(&rotatePG); - rotateDialogCallBack = func; - wShow(rotateW); -} - -static void StartIndexDialog(void * funcVP) -{ - indexDialogCallBack_t func = funcVP; - if (indexW == NULL) - indexW = ParamCreateDialog(&indexPG, MakeWindowTitle(_("Select Index")), - _("Ok"), IndexEnterOk, wHide, FALSE, NULL, 0, NULL); - ParamLoadControls(&indexPG); - indexDialogCallBack = func; - trackIndex[0] = '\0'; - wShow(indexW); -} - -static void StartMoveDialog(void * funcVP) -{ - moveDialogCallBack_t func = funcVP; - if (moveW == NULL) - moveW = ParamCreateDialog(&movePG, MakeWindowTitle(_("Move")), _("Ok"), - MoveEnterOk, wHide, FALSE, NULL, 0, NULL); - ParamLoadControls(&movePG); - moveDialogCallBack = func; - moveValue = zero; - wShow(moveW); -} - -static void MoveEnterOk(void * unused) { - ParamLoadData(&movePG); - moveDialogCallBack(&moveValue); - wHide(moveW); -} - -static void IndexEnterOk(void * unused) { - ParamLoadData(&indexPG); - indexDialogCallBack(trackIndex); - wHide(indexW); -} - -static void RotateEnterOk(void * unused) { - ParamLoadData(&rotatePG); - if (angleSystem == ANGLE_POLAR) - rotateDialogCallBack(I2VP(rotateValue * 1000)); - else - rotateDialogCallBack(I2VP(rotateValue * 1000)); - wHide(rotateW); -} - -static void RotateDialogInit(void) { - ParamRegister(&rotatePG); -} - -static void MoveDialogInit(void) { - ParamRegister(&movePG); -} - -static void IndexDialogInit(void) { - ParamRegister(&indexPG); -} - -EXPORT void AddMoveMenu(wMenu_p m, moveDialogCallBack_t func) { - wMenuPushCreate(m, "", _("Enter Move ..."), 0, - StartMoveDialog, func); -} - -EXPORT void AddIndexMenu(wMenu_p m, indexDialogCallBack_t func) { - wMenuPushCreate(m, "cmdSelectIndex", _("Select Track Index ..."), 0, - StartIndexDialog, func); -} - -//All values multipled by 100 to support decimal points from PD_FLOAT -EXPORT void AddRotateMenu(wMenu_p m, rotateDialogCallBack_t func) { - wMenuPushCreate(m, "", _("180 "), 0, func, I2VP(180000)); - wMenuPushCreate(m, "", _("90 CW"), 0, func, I2VP(90000)); - wMenuPushCreate(m, "", _("45 CW"), 0, func, I2VP(45000)); - wMenuPushCreate(m, "", _("30 CW"), 0, func, I2VP(30000)); - wMenuPushCreate(m, "", _("15 CW"), 0, func, I2VP(15000)); - wMenuPushCreate(m, "", _("15 CCW"), 0, func, I2VP(360000 - 15000)); - wMenuPushCreate(m, "", _("30 CCW"), 0, func, I2VP(360000 - 30000)); - wMenuPushCreate(m, "", _("45 CCW"), 0, func, I2VP(360000 - 45000)); - wMenuPushCreate(m, "", _("90 CCW"), 0, func, I2VP(360000 - 90000)); - wMenuPushCreate(m, "", _("Enter Angle ..."), 0, - StartRotateDialog, func); -} /***************************************************************************** * - * INITIALIZATON - * - */ - -static wWin_p debugW; - -static int debugCnt = 0; -static paramIntegerRange_t r0_100 = { 0, 100, 80 }; -static void DebugOk(void * unused); -static paramData_t debugPLs[30]; -static paramData_t p0[] = { - { PD_BUTTON, TestMallocs, "test", PDO_DLGHORZ, NULL, N_("Test Mallocs") } - }; -static long debug_values[30]; -static int debug_index[30]; - -static paramGroup_t debugPG = { "debug", 0, debugPLs, 0 }; - -static void DebugOk(void * unused) { - for (int i = 0; i<debugCnt;i++) { - logTable(debug_index[i]).level = debug_values[i]; - } - wHide(debugW); -} - -static void CreateDebugW(void) { - debugPG.paramCnt = debugCnt+1; - ParamRegister(&debugPG); - debugW = ParamCreateDialog(&debugPG, MakeWindowTitle(_("Debug")), _("Ok"), - DebugOk, wHide, FALSE, NULL, 0, NULL); - wHide(debugW); -} - -EXPORT void DebugInit(void * unused) { - - if (!debugW) { - debugPLs[0] = p0[0]; - BOOL_T default_line = FALSE; - debugCnt = 0; //Reset to start building the dynamic dialog over again - int i = 0; - for ( int inx=0; inx<logTable_da.cnt; inx++ ) { - if (logTable(inx).name[0]) { - debug_values[i] = logTable(inx).level; - debug_index[i] = inx; - InitDebug(logTable(inx).name,&debug_values[i]); - i++; - } else { - if (!default_line) { - debug_values[i] = logTable(inx).level; - debug_index[i] = inx; - InitDebug("Default Trace",&debug_values[i]); - i++; - default_line = TRUE; - } - } - } - - //ParamCreateControls( &debugPG, NULL ); - CreateDebugW(); - } - ParamLoadControls( &debugPG ); - wShow(debugW); -} - - -EXPORT void InitDebug(const char * label, long * valueP) { - if (debugCnt+1 >= COUNT( debugPLs ) ) - AbortProg("Too many debug flags"); - memset(&debugPLs[debugCnt+1], 0, sizeof debugPLs[debugCnt]); - debugPLs[debugCnt+1].type = PD_LONG; - debugPLs[debugCnt+1].valueP = valueP; - debugPLs[debugCnt+1].nameStr = label; - debugPLs[debugCnt+1].winData = &r0_100; - debugPLs[debugCnt+1].winLabel = label; - debugCnt++; -} - -void RecomputeElevations(void * unused ); - -static void MiscMenuItemCreate(wMenu_p m1, wMenu_p m2, const char * name, - const char * label, long acclKey, void * func, long option, void * context) { - wMenuPush_p mp; - mp = wMenuPushCreate(m1, name, label, acclKey, ParamMenuPush, - &menuPLs[menuPG.paramCnt]); - if (m2) - wMenuPushCreate(m2, name, label, acclKey, ParamMenuPush, - &menuPLs[menuPG.paramCnt]); - menuPLs[menuPG.paramCnt].control = (wControl_p) mp; - menuPLs[menuPG.paramCnt].type = PD_MENUITEM; - menuPLs[menuPG.paramCnt].valueP = func; - menuPLs[menuPG.paramCnt].nameStr = name; - menuPLs[menuPG.paramCnt].option = option; - menuPLs[menuPG.paramCnt].context = context; - - if (name) - GetBalloonHelpStr(name); - menuPG.paramCnt++; -} - - -/***************************************************************************** - * - * ACCEL KEY + * ACCEL KEYS * */ @@ -2249,22 +858,24 @@ struct accelKey_s { wAccelKey_e eKey; int iMode; enum eAccelAction_t iAction; - int iContext; } aAccelKeys[] = { - { "zoomUp", wAccelKey_Pgdn, 0, EA_ZOOMUP, 1 }, - { "zoomDown", wAccelKey_Pgup, 0, EA_ZOOMDOWN, 1 }, - { "redraw", wAccelKey_F5, 0, EA_REDRAW, 0 }, + int iContext; +} aAccelKeys[] = { + { "zoomUp", wAccelKey_Pgdn, 0, EA_ZOOMUP, 1 }, + { "zoomDown", wAccelKey_Pgup, 0, EA_ZOOMDOWN, 1 }, + { "redraw", wAccelKey_F5, 0, EA_REDRAW, 0 }, #ifdef WINDOWS - { "delete", wAccelKey_Del, 0, EA_DELETE, 0 }, + { "delete", wAccelKey_Del, 0, EA_DELETE, 0 }, #endif - { "undo", wAccelKey_Back, WKEY_SHIFT, EA_UNDO, 0 }, - { "copy", wAccelKey_Ins, WKEY_CTRL, EA_COPY, 0 }, - { "paste", wAccelKey_Ins, WKEY_SHIFT, EA_PASTE, 0 }, - { "cut", wAccelKey_Del, WKEY_SHIFT, EA_CUT, 0 }, - { "nextWindow", wAccelKey_F6, 0, EA_NEXT, 0 }, - { "zoomUp", wAccelKey_Numpad_Add, WKEY_CTRL, EA_ZOOMUP, 1 }, - { "zoomDown", wAccelKey_Numpad_Subtract, WKEY_CTRL, EA_ZOOMDOWN, 1 }, - { "help", wAccelKey_F1, WKEY_SHIFT, EA_HELP, 1 }, - { "help-context", wAccelKey_F1, 0, EA_HELP, 3 } }; + { "undo", wAccelKey_Back, WKEY_SHIFT, EA_UNDO, 0 }, + { "copy", wAccelKey_Ins, WKEY_CTRL, EA_COPY, 0 }, + { "paste", wAccelKey_Ins, WKEY_SHIFT, EA_PASTE, 0 }, + { "cut", wAccelKey_Del, WKEY_SHIFT, EA_CUT, 0 }, + { "nextWindow", wAccelKey_F6, 0, EA_NEXT, 0 }, + { "zoomUp", wAccelKey_Numpad_Add, WKEY_CTRL, EA_ZOOMUP, 1 }, + { "zoomDown", wAccelKey_Numpad_Subtract, WKEY_CTRL, EA_ZOOMDOWN, 1 }, + { "help", wAccelKey_F1, WKEY_SHIFT, EA_HELP, 1 }, + { "help-context", wAccelKey_F1, 0, EA_HELP, 3 } +}; static void AccelKeyDispatch( wAccelKey_e key, void * accelKeyIndexVP ) { @@ -2301,18 +912,18 @@ static void AccelKeyDispatch( wAccelKey_e key, void * accelKeyIndexVP ) wDoAccelHelp(key, I2VP(aAccelKeys[iAccelKeyIndex].iContext)); break; default: - abort(); + CHECK(FALSE); } } static char * accelKeyNames[] = { "Del", "Ins", "Home", "End", "Pgup", "Pgdn", - "Up", "Down", "Right", "Left", "Back", "F1", "F2", "F3", "F4", "F5", - "F6", "F7", "F8", "F9", "F10", "F11", "F12", "NumpadAdd", "NumpadSub" }; + "Up", "Down", "Right", "Left", "Back", "F1", "F2", "F3", "F4", "F5", + "F6", "F7", "F8", "F9", "F10", "F11", "F12", "NumpadAdd", "NumpadSub" + }; static void SetAccelKeys() { - for ( int iAccelKey = 0; iAccelKey < COUNT( aAccelKeys ); iAccelKey++ ) - { + for ( int iAccelKey = 0; iAccelKey < COUNT( aAccelKeys ); iAccelKey++ ) { struct accelKey_s * akP = &aAccelKeys[iAccelKey]; int eKey = akP->eKey; int iMode = akP->iMode; @@ -2348,624 +959,20 @@ static void SetAccelKeys() } -/***************************************************************************** +//EXPORT void InitCmdEnumerate(void) { +// AddToolbarButton("cmdEnumerate", wIconCreatePixMap(partlist_xpm), +// IC_SELECTED | IC_ACCLKEY, EnumerateTracks, +// NULL); +//} + + + +/**************************************************************************** * - * MENUS + * WMAIN * */ - -#include "bitmaps/zoom-in.xpm" -#include "bitmaps/zoom-choose.xpm" -#include "bitmaps/zoom-out.xpm" -#include "bitmaps/zoom-extent.xpm" -#include "bitmaps/undo.xpm" -#include "bitmaps/redo.xpm" -#include "bitmaps/partlist.xpm" // unused icon -#include "bitmaps/doc-export.xpm" -#include "bitmaps/doc-export-dxf.xpm" -#include "bitmaps/doc-export-bmap.xpm" -#include "bitmaps/doc-import.xpm" -#include "bitmaps/doc-import-xtc.xpm" -#include "bitmaps/doc-new.xpm" -#include "bitmaps/doc-save.xpm" -#include "bitmaps/doc-open.xpm" -#include "bitmaps/doc-print.xpm" -#include "bitmaps/doc-setup.xpm" -#include "bitmaps/parameter.xpm" -#include "bitmaps/map.xpm" -#include "bitmaps/magnet.xpm" - -static wMenu_p toolbarM; -static addButtonCallBack_t paramFilesCallback; - -static void CreateMenus(void) { - wMenu_p fileM, editM, viewM, optionM, windowM, macroM, helpM, toolbarM, - messageListM, manageM, addM, changeM, drawM; - wMenu_p zoomM, zoomSubM; - - wMenuPush_p zoomInM, zoomOutM, zoomExtentsM; - - wPrefGetInteger("DialogItem", "pref-iconsize", (long *) &iconSize, 0); - - fileM = wMenuBarAdd(mainW, "menuFile", _("&File")); - editM = wMenuBarAdd(mainW, "menuEdit", _("&Edit")); - viewM = wMenuBarAdd(mainW, "menuView", _("&View")); - addM = wMenuBarAdd(mainW, "menuAdd", _("&Add")); - changeM = wMenuBarAdd(mainW, "menuChange", _("&Change")); - drawM = wMenuBarAdd(mainW, "menuDraw", _("&Draw")); - manageM = wMenuBarAdd(mainW, "menuManage", _("&Manage")); - optionM = wMenuBarAdd(mainW, "menuOption", _("&Options")); - macroM = wMenuBarAdd(mainW, "menuMacro", _("&Macro")); - windowM = wMenuBarAdd(mainW, "menuWindow", _("&Window")); - helpM = wMenuBarAdd(mainW, "menuHelp", _("&Help")); - - /* - * POPUP MENUS - */ - /* Select Commands */ - /* Select All */ - /* Select All Current */ - - /* Common View Commands Menu */ - /* Zoom In/Out */ - /* Snap Grid Menu */ - /* Show/Hide Map */ - /* Show/Hide Background */ - - /* Selected Commands */ - /*--------------*/ - /* DeSelect All */ - /* Select All */ - /* Select All Current */ - /*--------------*/ - /* Quick Move */ - /* Quick Rotate */ - /* Quick Align */ - /*--------------*/ - /* Move To Current Layer */ - /* Move/Rotate Cmds */ - /* Cut/Paste/Delete */ - /* Group/Un-group Selected */ - /*----------*/ - /* Thick/Thin */ - /* Bridge/Tunnel */ - /* Ties/NoTies */ - /*-----------*/ - /* More Commands */ - - popup1M = wMenuPopupCreate(mainW, _("Context Commands")); - popup2M = wMenuPopupCreate(mainW, _("Shift Context Commands")); - MiscMenuItemCreate(popup1M, popup2M, "cmdUndo", _("Undo"), 0, - UndoUndo, 0, NULL); - MiscMenuItemCreate(popup1M, popup2M, "cmdRedo", _("Redo"), 0, - UndoRedo, 0, NULL); - /* Zoom */ - wMenuPushCreate(popup1M, "cmdZoomIn", _("Zoom In"), 0, - DoZoomUp, I2VP(1)); - wMenuPushCreate(popup2M, "cmdZoomIn", _("Zoom In"), 0, - DoZoomUp, I2VP(1)); - wMenuPushCreate(popup1M, "cmdZoomOut", _("Zoom Out"), 0, - DoZoomDown, I2VP(1)); - wMenuPushCreate(popup2M, "cmdZoomOut", _("Zoom Out"), 0, - DoZoomDown, I2VP(1)); - wMenuPushCreate(popup1M, "cmdZoomExtents", _("Zoom Extents"), 0, - DoZoomExtents, I2VP(1)); - wMenuPushCreate(popup2M, "cmdZoomExtents", _("Zoom Extents"), 0, - DoZoomExtents, I2VP(1)); - /* Display */ - MiscMenuItemCreate(popup1M, popup2M, "cmdGridEnable", _("Enable SnapGrid"), - 0, SnapGridEnable, 0, NULL); - MiscMenuItemCreate(popup1M, popup2M, "cmdGridShow", _("SnapGrid Show"), 0, - SnapGridShow, 0, NULL); - MiscMenuItemCreate(popup1M, popup2M, "cmdMagneticSnap", _(" Enable Magnetic Snap"), 0, - MagneticSnapToggle, 0, NULL); - MiscMenuItemCreate(popup1M, popup2M, "cmdMapShow", _("Show/Hide Map"), 0, - MapWindowToggleShow, 0, NULL); - MiscMenuItemCreate(popup1M, popup2M, "cmdBackgroundShow", _("Show/Hide Background"), 0, - BackgroundToggleShow, 0, NULL); - wMenuSeparatorCreate(popup1M); - wMenuSeparatorCreate(popup2M); - /* Copy/Paste */ - MiscMenuItemCreate(popup2M, NULL, "cmdCut", _("Cut"), 0, - EditCut, 0, NULL); - MiscMenuItemCreate(popup2M, NULL, "cmdCopy", _("Copy"), 0, - EditCopy, 0, NULL); - MiscMenuItemCreate(popup1M, popup2M, "cmdPaste", _("Paste"), 0, - EditPaste, 0, NULL); - MiscMenuItemCreate(popup2M, NULL, "cmdClone", _("Clone"), 0, - EditClone, 0, NULL); - /*Select*/ - MiscMenuItemCreate(popup1M, popup2M, "cmdSelectAll", _("Select All"), 0, - (wMenuCallBack_p) SetAllTrackSelect, 0, I2VP(1)); - MiscMenuItemCreate(popup1M, popup2M, "cmdSelectCurrentLayer", - _("Select Current Layer"), 0, - SelectCurrentLayer, 0, NULL); - MiscMenuItemCreate(popup2M, NULL, "cmdDeselectAll", _("Deselect All"), 0, - (wMenuCallBack_p) SetAllTrackSelect, 0, I2VP(FALSE)); - wMenuPushCreate(popup1M, "cmdSelectIndex", _("Select Track Index..."), 0, - StartIndexDialog, &SelectByIndex); - wMenuPushCreate(popup2M, "cmdSelectIndex", _("Select Track Index..."), 0, - StartIndexDialog, &SelectByIndex); - /* Modify */ - wMenuPushCreate(popup2M, "cmdMove", _("Move"), 0, - DoCommandBIndirect, &moveCmdInx); - wMenuPushCreate(popup2M, "cmdRotate", _("Rotate"), 0, - DoCommandBIndirect, &rotateCmdInx); - wMenuSeparatorCreate(popup1M); - wMenuSeparatorCreate(popup2M); - MiscMenuItemCreate(popup2M, NULL, "cmdDelete", _("Delete"), 0, - (wMenuCallBack_p) SelectDelete, 0, NULL); - wMenuSeparatorCreate(popup2M); - popup1aM = wMenuMenuCreate(popup1M, "", _("Add...")); - popup2aM = wMenuMenuCreate(popup2M, "", _("Add...")); - wMenuSeparatorCreate(popup2M); - wMenuSeparatorCreate(popup1M); - popup1mM = wMenuMenuCreate(popup1M, "", _("More...")); - popup2mM = wMenuMenuCreate(popup2M, "", _("More...")); - - /* - * FILE MENU - */ - MiscMenuItemCreate(fileM, NULL, "menuFile-clear", _("&New ..."), ACCL_NEW, - DoClear, 0, NULL); - wMenuPushCreate(fileM, "menuFile-load", _("&Open ..."), ACCL_OPEN, - ChkLoad, NULL); - wMenuSeparatorCreate(fileM); - - wMenuPushCreate(fileM, "menuFile-save", _("&Save"), ACCL_SAVE, - DoSave, NULL); - wMenuPushCreate(fileM, "menuFile-saveAs", _("Save &As ..."), ACCL_SAVEAS, - DoSaveAs, NULL); - wMenuPushCreate(fileM, "menuFile-revert", _("Revert"), ACCL_REVERT, - ChkRevert, NULL); - wMenuSeparatorCreate(fileM); - - cmdGroup = BG_FILE; - AddToolbarButton("menuFile-clear", wIconCreatePixMap(doc_new_xpm[iconSize]), - IC_MODETRAIN_TOO, DoClear, NULL); - AddToolbarButton("menuFile-load", wIconCreatePixMap(doc_open_xpm[iconSize]), - IC_MODETRAIN_TOO, ChkLoad, NULL); - AddToolbarButton("menuFile-save", wIconCreatePixMap(doc_save_xpm[iconSize]), - IC_MODETRAIN_TOO, DoSave, NULL); - - cmdGroup = BG_PRINT; - MiscMenuItemCreate(fileM, NULL, "printSetup", _("P&rint Setup ..."), - ACCL_PRINTSETUP, (wMenuCallBack_p) wPrintSetup, 0, - I2VP(0)); - printCmdInx = InitCmdPrint(fileM); - AddToolbarButton("menuFile-setup", wIconCreatePixMap(doc_setup_xpm[iconSize]), - IC_MODETRAIN_TOO, (wMenuCallBack_p) wPrintSetup, I2VP(0)); - - wMenuSeparatorCreate(fileM); - MiscMenuItemCreate(fileM, NULL, "cmdImport", _("&Import"), ACCL_IMPORT, - DoImport, 0, I2VP(0)); - MiscMenuItemCreate(fileM, NULL, "cmdImportModule", _("Import &Module"), ACCL_IMPORT_MOD, - DoImport, 0, I2VP(1)); - MiscMenuItemCreate(fileM, NULL, "cmdOutputbitmap", _("Export to &Bitmap"), - ACCL_PRINTBM, OutputBitMapInit(), 0, - NULL); - MiscMenuItemCreate(fileM, NULL, "cmdExport", _("E&xport"), ACCL_EXPORT, - DoExport, IC_SELECTED, NULL); - MiscMenuItemCreate(fileM, NULL, "cmdExportDXF", _("Export D&XF"), - ACCL_EXPORTDXF, DoExportDXF, IC_SELECTED, - NULL); -#if XTRKCAD_CREATE_SVG - MiscMenuItemCreate( fileM, NULL, "cmdExportSVG", _("Export S&VG"), ACCL_EXPORTDXF, - DoExportSVG, IC_SELECTED, NULL); -#endif - wMenuSeparatorCreate(fileM); - - paramFilesCallback = ParamFilesInit(); - MiscMenuItemCreate(fileM, NULL, "cmdPrmfile", _("Parameter &Files ..."), - ACCL_PARAMFILES, paramFilesCallback, 0, NULL); - MiscMenuItemCreate(fileM, NULL, "cmdFileNote", _("No&tes ..."), ACCL_NOTES, - DoNote, 0, NULL); - - wMenuSeparatorCreate(fileM); - fileList_ml = wMenuListCreate(fileM, "menuFileList", NUM_FILELIST, - ChkFileList); - wMenuSeparatorCreate(fileM); - wMenuPushCreate(fileM, "menuFile-quit", _("E&xit"), 0, - DoQuit, NULL); - - InitCmdExport(); - - AddToolbarButton("menuFile-parameter", wIconCreatePixMap(parameter_xpm[iconSize]), - IC_MODETRAIN_TOO, paramFilesCallback, NULL); - - cmdGroup = BG_ZOOM; - zoomUpB = AddToolbarButton("cmdZoomIn", wIconCreatePixMap(zoom_in_xpm[iconSize]), - IC_MODETRAIN_TOO, DoZoomUp, NULL); - zoomM = wMenuPopupCreate(mainW, ""); - AddToolbarButton("cmdZoom", wIconCreatePixMap(zoom_choose_xpm[iconSize]), IC_MODETRAIN_TOO, - (wButtonCallBack_p) wMenuPopupShow, zoomM); - zoomDownB = AddToolbarButton("cmdZoomOut", wIconCreatePixMap(zoom_out_xpm[iconSize]), - IC_MODETRAIN_TOO, DoZoomDown, NULL); - zoomExtentsB = AddToolbarButton("cmdZoomExtent", wIconCreatePixMap(zoom_extent_xpm[iconSize]), - IC_MODETRAIN_TOO, DoZoomExtents, NULL); - - cmdGroup = BG_UNDO; - undoB = AddToolbarButton("cmdUndo", wIconCreatePixMap(undo_xpm[iconSize]), 0, - UndoUndo, NULL); - redoB = AddToolbarButton("cmdRedo", wIconCreatePixMap(redo_xpm[iconSize]), 0, - UndoRedo, NULL); - - wControlActive((wControl_p) undoB, FALSE); - wControlActive((wControl_p) redoB, FALSE); - InitCmdUndo(); - - /* - * EDIT MENU - */ - MiscMenuItemCreate(editM, NULL, "cmdUndo", _("&Undo"), ACCL_UNDO, - UndoUndo, 0, NULL); - MiscMenuItemCreate(editM, NULL, "cmdRedo", _("R&edo"), ACCL_REDO, - UndoRedo, 0, NULL); - wMenuSeparatorCreate(editM); - MiscMenuItemCreate(editM, NULL, "cmdCut", _("Cu&t"), ACCL_CUT, - EditCut, IC_SELECTED, NULL); - MiscMenuItemCreate(editM, NULL, "cmdCopy", _("&Copy"), ACCL_COPY, - EditCopy, IC_SELECTED, NULL); - MiscMenuItemCreate(editM, NULL, "cmdPaste", _("&Paste"), ACCL_PASTE, - EditPaste, 0, NULL); - MiscMenuItemCreate(editM, NULL, "cmdClone", _("C&lone"), ACCL_CLONE, - EditClone, 0, NULL); - MiscMenuItemCreate(editM, NULL, "cmdDelete", _("De&lete"), ACCL_DELETE, - (wMenuCallBack_p) SelectDelete, IC_SELECTED, NULL); - MiscMenuItemCreate(editM, NULL, "cmdMoveToCurrentLayer", - _("Move To Current Layer"), ACCL_MOVCURLAYER, - MoveSelectedTracksToCurrentLayer, - IC_SELECTED, NULL); - wMenuSeparatorCreate( editM ); - menuPLs[menuPG.paramCnt].context = I2VP(1); - MiscMenuItemCreate( editM, NULL, "cmdSelectAll", _("Select &All"), ACCL_SELECTALL, (wMenuCallBack_p)SetAllTrackSelect, 0, I2VP(TRUE) ); - MiscMenuItemCreate( editM, NULL, "cmdSelectCurrentLayer", _("Select Current Layer"), ACCL_SETCURLAYER, SelectCurrentLayer, 0, NULL); - MiscMenuItemCreate( editM, NULL, "cmdSelectByIndex", _("Select By Index"), 0L, StartIndexDialog, 0, &SelectByIndex ); - MiscMenuItemCreate( editM, NULL, "cmdDeselectAll", _("&Deselect All"), ACCL_DESELECTALL, (wMenuCallBack_p)SetAllTrackSelect, 0, I2VP(FALSE) ); - MiscMenuItemCreate( editM, NULL, "cmdSelectInvert", _("&Invert Selection"), 0L, InvertTrackSelect, 0, NULL); - MiscMenuItemCreate( editM, NULL, "cmdSelectOrphaned", _("Select Stranded Track"), 0L, OrphanedTrackSelect, 0, NULL); - wMenuSeparatorCreate( editM ); - MiscMenuItemCreate( editM, NULL, "cmdTunnel", _("Tu&nnel"), ACCL_TUNNEL, SelectTunnel, IC_SELECTED, NULL); - MiscMenuItemCreate( editM, NULL, "cmdBridge", _("B&ridge"), ACCL_BRIDGE, SelectBridge, IC_SELECTED, NULL); - MiscMenuItemCreate( editM, NULL, "cmdTies", _("Ties/NoTies"), ACCL_TIES, SelectTies, IC_SELECTED, NULL); - MiscMenuItemCreate( editM, NULL, "cmdAbove", _("Move to &Front"), ACCL_ABOVE, SelectAbove, IC_SELECTED, NULL); - MiscMenuItemCreate( editM, NULL, "cmdBelow", _("Move to &Back"), ACCL_BELOW, SelectBelow, IC_SELECTED, NULL); - - wMenuSeparatorCreate( editM ); - MiscMenuItemCreate( editM, NULL, "cmdWidth0", _("Thin Tracks"), ACCL_THIN, SelectTrackWidth, IC_SELECTED, I2VP(0) ); - MiscMenuItemCreate( editM, NULL, "cmdWidth2", _("Medium Tracks"), ACCL_MEDIUM, SelectTrackWidth, IC_SELECTED, I2VP(2) ); - MiscMenuItemCreate( editM, NULL, "cmdWidth3", _("Thick Tracks"), ACCL_THICK, SelectTrackWidth, IC_SELECTED, I2VP(3) ); - - /* - * VIEW MENU - */ - - zoomInM = wMenuPushCreate(viewM, "menuEdit-zoomIn", _("Zoom &In"), - ACCL_ZOOMIN, DoZoomUp, I2VP(1)); - zoomSubM = wMenuMenuCreate(viewM, "menuEdit-zoomTo", _("&Zoom")); - zoomOutM = wMenuPushCreate(viewM, "menuEdit-zoomOut", _("Zoom &Out"), - ACCL_ZOOMOUT, DoZoomDown, I2VP(1)); - zoomExtentsM = wMenuPushCreate(viewM, "menuEdit-zoomExtents", _("Zoom &Extents"), - 0, DoZoomExtents, I2VP(0)); - wMenuSeparatorCreate(viewM); - - InitCmdZoom(zoomM, zoomSubM, NULL, NULL); - - /* these menu choices and toolbar buttons are synonymous and should be treated as such */ - wControlLinkedSet((wControl_p) zoomInM, (wControl_p) zoomUpB); - wControlLinkedSet((wControl_p) zoomOutM, (wControl_p) zoomDownB); - wControlLinkedSet((wControl_p) zoomExtentsM, (wControl_p) zoomExtentsB); - - wMenuPushCreate(viewM, "menuEdit-redraw", _("&Redraw"), ACCL_REDRAW, - (wMenuCallBack_p) MainRedraw, NULL); - wMenuPushCreate(viewM, "menuEdit-redraw", _("Redraw All"), ACCL_REDRAWALL, - (wMenuCallBack_p) DoRedraw, NULL); - wMenuSeparatorCreate(viewM); - - snapGridEnableMI = wMenuToggleCreate(viewM, "cmdGridEnable", - _("Enable SnapGrid"), ACCL_SNAPENABLE, 0, - SnapGridEnable, NULL); - snapGridShowMI = wMenuToggleCreate(viewM, "cmdGridShow", _("Show SnapGrid"), - ACCL_SNAPSHOW, - FALSE, SnapGridShow, NULL); - gridCmdInx = InitGrid(viewM); - - // visibility toggle for anchors - // get the start value - long anchors_long; - wPrefGetInteger("misc", "anchors", &anchors_long, 1); - magneticSnap = anchors_long ? TRUE : FALSE; - magnetsMI = wMenuToggleCreate(viewM, "cmdMagneticSnap", _("Enable Magnetic Snap"), - 0, magneticSnap, - MagneticSnapToggle, NULL); - - // visibility toggle for map window - // get the start value - long mapVisible_long; - wPrefGetInteger("misc", "mapVisible", (long *) &mapVisible_long, 1); - mapVisible = mapVisible_long ? TRUE : FALSE; - mapShowMI = wMenuToggleCreate(viewM, "cmdMapShow", _("Show/Hide Map"), - ACCL_MAPSHOW, mapVisible, - MapWindowToggleShow, NULL); - - wMenuSeparatorCreate(viewM); - - toolbarM = wMenuMenuCreate(viewM, "toolbarM", _("&Tool Bar")); - CreateToolbarM(toolbarM); - - cmdGroup = BG_EASE; - InitCmdEasement(); - - cmdGroup = BG_SNAP; - InitSnapGridButtons(); - magnetsB = AddToolbarButton("cmdMagneticSnap", wIconCreatePixMap(magnet_xpm[iconSize]), - IC_MODETRAIN_TOO, MagneticSnapToggle, NULL); - wControlLinkedSet((wControl_p) magnetsMI, (wControl_p) magnetsB); - wButtonSetBusy(magnetsB, (wBool_t) magneticSnap); - - mapShowB = AddToolbarButton("cmdMapShow", wIconCreatePixMap(map_xpm[iconSize]), - IC_MODETRAIN_TOO, MapWindowToggleShow, NULL); - wControlLinkedSet((wControl_p) mapShowMI, (wControl_p) mapShowB); - wButtonSetBusy(mapShowB, (wBool_t) mapVisible); - - /* - * ADD MENU - */ - - cmdGroup = BG_TRKCRT | BG_BIGGAP; - InitCmdStraight(addM); - InitCmdCurve(addM); - InitCmdParallel(addM); - InitCmdTurnout(addM); - InitCmdHandLaidTurnout(addM); - InitCmdStruct(addM); - InitCmdHelix(addM); - InitCmdTurntable(addM); - - cmdGroup = BG_CONTROL; - ButtonGroupBegin( _("Control Element"), "cmdControlElements", _("Control Element") ); - InitCmdBlock(addM); - InitCmdSwitchMotor(addM); - InitCmdSignal(addM); - InitCmdControl(addM); - InitCmdSensor(addM); - ButtonGroupEnd(); - - /* - * CHANGE MENU - */ - cmdGroup = BG_SELECT; - InitCmdDescribe(changeM); - InitCmdSelect(changeM); - InitCmdPan(viewM); - - wMenuSeparatorCreate(changeM); - - cmdGroup = BG_TRKGRP; - InitCmdMove(changeM); - InitCmdMoveDescription(changeM); - InitCmdDelete(); - InitCmdTunnel(); - InitCmdBridge(); - InitCmdAboveBelow(); - - cmdGroup = BG_TRKMOD; - InitCmdModify(changeM); - InitCmdCornu(changeM); - - MiscMenuItemCreate(changeM, NULL, "cmdRescale", _("Change Scale"), 0, - DoRescale, IC_SELECTED, NULL); - - - wMenuSeparatorCreate(changeM); - - InitCmdJoin(changeM); - InitCmdSplit(changeM); - - wMenuSeparatorCreate(changeM); - - InitCmdPull(changeM); - if (extraButtons) - MiscMenuItemCreate(changeM, NULL, "loosen", _("&Loosen Tracks"), - ACCL_LOOSEN, LoosenTracks, - IC_SELECTED, NULL); - - wMenuSeparatorCreate(changeM); - - MiscMenuItemCreate(changeM, NULL, "cmdAddElevations", - _("Raise/Lower Elevations"), ACCL_CHGELEV, - ShowAddElevations, IC_SELECTED, - NULL); - InitCmdElevation(changeM); - InitCmdProfile(changeM); - - MiscMenuItemCreate(changeM, NULL, "cmdClearElevations", - _("Clear Elevations"), ACCL_CLRELEV, - ClearElevations, IC_SELECTED, NULL); - MiscMenuItemCreate(changeM, NULL, "cmdElevation", _("Recompute Elevations"), - 0, RecomputeElevations, 0, NULL); - ParamRegister(&addElevPG); - - /* - * DRAW MENU - */ - cmdGroup = BG_MISCCRT; - InitCmdDraw(drawM); - InitCmdText(drawM); - InitTrkNote(drawM); - - cmdGroup = BG_RULER; - InitCmdRuler(drawM); - - /* - * OPTION MENU - */ - MiscMenuItemCreate(optionM, NULL, "cmdLayout", _("L&ayout ..."), - ACCL_LAYOUTW, LayoutInit(), IC_MODETRAIN_TOO, NULL); - MiscMenuItemCreate(optionM, NULL, "cmdDisplay", _("&Display ..."), - ACCL_DISPLAYW, DisplayInit(), IC_MODETRAIN_TOO, NULL); - MiscMenuItemCreate(optionM, NULL, "cmdCmdopt", _("Co&mmand ..."), - ACCL_CMDOPTW, CmdoptInit(), IC_MODETRAIN_TOO, NULL); - MiscMenuItemCreate(optionM, NULL, "cmdEasement", _("&Easements ..."), - ACCL_EASEW, DoEasementRedir, - IC_MODETRAIN_TOO, NULL); - MiscMenuItemCreate(optionM, NULL, "fontSelW", _("&Fonts ..."), ACCL_FONTW, - SelectFont, IC_MODETRAIN_TOO, NULL); - MiscMenuItemCreate(optionM, NULL, "cmdSticky", _("Stic&ky ..."), - ACCL_STICKY, DoSticky, IC_MODETRAIN_TOO, - NULL); - if (extraButtons) { - menuPLs[menuPG.paramCnt].context = debugW; - MiscMenuItemCreate(optionM, NULL, "cmdDebug", _("&Debug ..."), 0, - DebugInit, IC_MODETRAIN_TOO, NULL); - } - MiscMenuItemCreate(optionM, NULL, "cmdPref", _("&Preferences ..."), - ACCL_PREFERENCES, PrefInit(), IC_MODETRAIN_TOO, NULL); - MiscMenuItemCreate(optionM, NULL, "cmdColor", _("&Colors ..."), ACCL_COLORW, - ColorInit(), IC_MODETRAIN_TOO, NULL); - - /* - * MACRO MENU - */ - wMenuPushCreate(macroM, "cmdRecord", _("&Record ..."), ACCL_RECORD, - DoRecord, NULL); - wMenuPushCreate(macroM, "cmdDemo", _("&Play Back ..."), ACCL_PLAYBACK, - DoPlayBack, NULL); - - /* - * WINDOW MENU - */ - wMenuPushCreate(windowM, "menuWindow", _("Main window"), 0, - (wMenuCallBack_p) wShow, mainW); - winList_mi = wMenuListCreate(windowM, "menuWindow", -1, DoShowWindow); - - /* - * HELP MENU - */ - - /* main help window */ - wMenuAddHelp(helpM); - - /* help on recent messages */ - wMenuSeparatorCreate(helpM); - messageListM = wMenuMenuCreate(helpM, "menuHelpRecentMessages", - _("Recent Messages")); - messageList_ml = wMenuListCreate(messageListM, "messageListM", 10, - ShowMessageHelp); - wMenuListAdd(messageList_ml, 0, _(MESSAGE_LIST_EMPTY), NULL); - - /* tip of the day */ - wMenuSeparatorCreate( helpM ); - wMenuPushCreate( helpM, "cmdTip", _("Tip of the Day..."), 0, ShowTip, I2VP(SHOWTIP_FORCESHOW | SHOWTIP_NEXTTIP)); - demoM = wMenuMenuCreate( helpM, "cmdDemo", _("&Demos") ); - wMenuPushCreate( helpM, "cmdExamples", _("Examples..."), 0, ChkExamples, NULL); - - /* about window */ - wMenuSeparatorCreate(helpM); - wMenuPushCreate(helpM, "about", _("About"), 0, - CreateAboutW, NULL); - - /* - * MANAGE MENU - */ - - cmdGroup = BG_TRAIN | BG_BIGGAP; - InitCmdTrain(manageM); - wMenuSeparatorCreate(manageM); - - InitNewTurn( - wMenuMenuCreate(manageM, "cmdTurnoutNew", - _("Tur&nout Designer..."))); - - MiscMenuItemCreate(manageM, NULL, "cmdContmgm", - _("Layout &Control Elements"), ACCL_CONTMGM, - ControlMgrInit(), 0, NULL); - MiscMenuItemCreate(manageM, NULL, "cmdGroup", _("&Group"), ACCL_GROUP, - DoGroup, IC_SELECTED, NULL); - MiscMenuItemCreate(manageM, NULL, "cmdUngroup", _("&Ungroup"), ACCL_UNGROUP, - DoUngroup, IC_SELECTED, NULL); - - MiscMenuItemCreate(manageM, NULL, "cmdCustmgm", - _("Custom defined parts..."), ACCL_CUSTMGM, CustomMgrInit(), - 0, NULL); - MiscMenuItemCreate(manageM, NULL, "cmdRefreshCompound", - _("Update Turnouts and Structures"), 0, - DoRefreshCompound, 0, NULL); - - MiscMenuItemCreate(manageM, NULL, "cmdCarInventory", _("Car Inventory"), - ACCL_CARINV, DoCarDlg, IC_MODETRAIN_TOO, - NULL); - - wMenuSeparatorCreate(manageM); - - MiscMenuItemCreate(manageM, NULL, "cmdLayer", _("Layers ..."), ACCL_LAYERS, - InitLayersDialog(), 0, NULL); - wMenuSeparatorCreate(manageM); - - MiscMenuItemCreate(manageM, NULL, "cmdEnumerate", _("Parts &List ..."), - ACCL_PARTSLIST, EnumerateTracks, 0, - NULL); - MiscMenuItemCreate(manageM, NULL, "cmdPricelist", _("Price List..."), - ACCL_PRICELIST, PriceListInit(), 0, NULL); - - cmdGroup = BG_LAYER | BG_BIGGAP; - - InitCmdSelect2(changeM); - InitCmdDescribe2(changeM); - InitCmdPan2(changeM); - - InitLayers(); - - cmdGroup = BG_HOTBAR; - InitHotBar(); - - SetAccelKeys(); - - InitBenchDialog(); - wPrefGetInteger( "DialogItem", "sticky-set", &stickySet, stickySet ); -} - -static void LoadFileList(void) { - char file[6]; - int inx; - const char * cp; - const char *fileName, *pathName; - strcpy(file, "fileX"); - for (inx = NUM_FILELIST - 1; inx >= 0; inx--) { - file[4] = '0' + inx; - cp = wPrefGetString("filelist", file); - if (!cp) - continue; - pathName = MyStrdup(cp); - fileName = FindFilename((char *) pathName); - if (fileName) - wMenuListAdd(fileList_ml, 0, fileName, pathName); - } -} - -EXPORT void InitCmdEnumerate(void) { - AddToolbarButton("cmdEnumerate", wIconCreatePixMap(partlist_xpm), - IC_SELECTED | IC_ACCLKEY, EnumerateTracks, - NULL); -} - -EXPORT void InitCmdExport(void) { - ButtonGroupBegin( _("Import/Export"), "cmdExportImportSetCmd", _("Import/Export") ); - cmdGroup = BG_EXPORTIMPORT; - AddToolbarButton("cmdExport", wIconCreatePixMap(doc_export_xpm[iconSize]), - IC_SELECTED | IC_ACCLKEY, DoExport, NULL); - AddToolbarButton("cmdExportDXF", wIconCreatePixMap(doc_export_dxf_xpm[iconSize]), IC_SELECTED | IC_ACCLKEY, - DoExportDXF, I2VP(1)); - AddToolbarButton("cmdExportBmap", wIconCreatePixMap(doc_export_bmap_xpm[iconSize]), IC_ACCLKEY, - OutputBitMapInit(), NULL); - AddToolbarButton("cmdImport", wIconCreatePixMap(doc_import_xpm[iconSize]), IC_ACCLKEY, - DoImport, I2VP(0)); - AddToolbarButton("cmdImportModule", wIconCreatePixMap(doc_import_xtc_xpm[iconSize]), IC_ACCLKEY, - DoImport, I2VP(1)); - ButtonGroupEnd(); -} - /* Give user the option to continue work after crash. This function gives the user * the option to load the checkpoint file to continue working after a crash. * @@ -2981,17 +988,18 @@ static int OfferCheckpoint( void ) /* sProdName */ ret = - wNotice3( - _( - "Program was not terminated properly. Do you want to resume working on the previous trackplan?"), - _("Resume"), _("Resume with New Name"), _("Ignore Checkpoint")); + wNotice3( + _( + "Program was not terminated properly. Do you want to resume working on the previous trackplan?"), + _("Resume"), _("Resume with New Name"), _("Ignore Checkpoint")); //ret==1 Same, ret==-1 New, ret==0 Ignore - if (ret == 1) + if (ret == 1) { printf(_("Reload Checkpoint Selected\n")); - else if (ret == -1) + } else if (ret == -1) { printf(_("Reload Checkpoint With New Name Selected\n")); - else + } else { printf(_("Ignore Checkpoint Selected\n")); + } if (ret>=0) { /* load the checkpoint file */ LoadCheckpoint(ret==1); @@ -3001,7 +1009,8 @@ static int OfferCheckpoint( void ) return (ret>=0); } -EXPORT wWin_p wMain(int argc, char * argv[]) { +EXPORT wWin_p wMain(int argc, char * argv[]) +{ int c; int resumeWork; char * logFileName = NULL; @@ -3015,8 +1024,7 @@ EXPORT wWin_p wMain(int argc, char * argv[]) { char *cp; char buffer[STR_SIZE]; unsigned int i; - wWinPix_t displayWidth; - wWinPix_t displayHeight; + BOOL_T bRunTests = FALSE; strcpy(buffer, sProdNameLower); @@ -3037,7 +1045,7 @@ EXPORT wWin_p wMain(int argc, char * argv[]) { opterr = 0; LogSet("dummy",0); - while ((c = getopt(argc, argv, "vl:d:c:mV")) != -1) + while ((c = getopt(argc, argv, "vl:d:c:mVT")) != -1) switch (c) { case 'c': /* configuration name */ /* test for valid filename */ @@ -3079,25 +1087,28 @@ EXPORT wWin_p wMain(int argc, char * argv[]) { break; case ':': NoticeMessage("Missing parameter for %s", _("Ok"), NULL, - argv[optind - 1]); + argv[optind - 1]); exit(1); break; case 'V': // display version printf("Version: %s\n",XTRKCAD_VERSION); exit(0); break; + case 'T': // run tests + LogSet( "regression", 2 ); + bRunTests = TRUE; + break; default: - abort(); + CHECK(FALSE); } - if (optind < argc) + if (optind < argc) { initialFile = strdup(argv[optind]); + } extraButtons = (getenv(sEnvExtra) != NULL); LogOpen(logFileName); log_init = LogFindIndex("init"); log_malloc = LogFindIndex("malloc"); - log_error = LogFindIndex("error"); - log_command = LogFindIndex("command"); LOG1(log_init, ( "initCustom\n" )) InitCustom(); @@ -3108,52 +1119,19 @@ EXPORT wWin_p wMain(int argc, char * argv[]) { LOG1(log_init, ( "create main window\n" )) SetLayoutTitle(sProdName); sprintf(message, _("Unnamed Trackplan - %s(%s)"), sProdName, sVersion); - wSetBalloonHelp(balloonHelp); wGetDisplaySize(&displayWidth, &displayHeight); mainW = wWinMainCreate(buffer, (displayWidth * 2) / 3, - (displayHeight * 2) / 3, "xtrkcadW", message, "main", - F_RESIZE | F_MENUBAR | F_NOTAB | F_RECALLPOS | F_RECALLSIZE | F_HIDE, MainProc, - NULL); - if (mainW == NULL) + (displayHeight * 2) / 3, "xtrkcadW", message, "main", + F_RESIZE | F_MENUBAR | F_NOTAB | F_RECALLPOS | F_RECALLSIZE | F_HIDE, MainProc, + NULL); + if (mainW == NULL) { return NULL; + } + wSetGeometry(mainW, displayWidth/2, displayWidth, displayHeight/2, + displayHeight, -1, -1, -1); InitAppDefaults(); - drawColorBlack = wDrawFindColor( wRGB( 0, 0, 0) ); - drawColorWhite = wDrawFindColor( wRGB(255,255,255) ); - drawColorRed = wDrawFindColor( wRGB(255, 0, 0) ); - drawColorBlue = wDrawFindColor( wRGB( 0, 0,255) ); - drawColorGreen = wDrawFindColor( wRGB( 0,255, 0) ); - drawColorAqua = wDrawFindColor( wRGB( 0,255,255) ); - - // Last component of spectial color must be > 3 - drawColorPreviewSelected = wDrawFindColor( wRGB ( 6, 6, 255) ); //Special Blue - drawColorPreviewUnselected = wDrawFindColor( wRGB( 255, 215, 6)); //Special Yellow - - drawColorPowderedBlue = wDrawFindColor( wRGB(129, 212, 250) ); - drawColorPurple = wDrawFindColor( wRGB(255, 0,255) ); - drawColorGold = wDrawFindColor( wRGB(255,215, 0) ); - drawColorGrey10 = wDrawFindColor( wRGB(26,26,26) ); - drawColorGrey20 = wDrawFindColor( wRGB(51,51,51) ); - drawColorGrey30 = wDrawFindColor( wRGB(72,72,72) ); - drawColorGrey40 = wDrawFindColor( wRGB(102,102,102) ); - drawColorGrey50 = wDrawFindColor( wRGB(128,128,128) ); - drawColorGrey60 = wDrawFindColor( wRGB(153,153,153) ); - drawColorGrey70 = wDrawFindColor( wRGB(179,179,179) ); - drawColorGrey80 = wDrawFindColor( wRGB(204,204,204) ); - drawColorGrey90 = wDrawFindColor( wRGB(230,230,230) ); - snapGridColor = drawColorGreen; - markerColor = drawColorRed; - borderColor = drawColorBlack; - crossMajorColor = drawColorRed; - crossMinorColor = drawColorBlue; - selectedColor = drawColorRed; - normalColor = drawColorBlack; - elevColorIgnore = drawColorBlue; - elevColorDefined = drawColorGold; - profilePathColor = drawColorPurple; - exceptionColor = wDrawFindColor(wRGB(255, 89, 0 )); - tieColor = wDrawFindColor(wRGB(153, 89, 68)); newToolbarMax = (1 << BG_COUNT) - 1; wPrefGetInteger("misc", "toolbarset", &toolbarSet, newToolbarMax); @@ -3184,15 +1162,15 @@ EXPORT wWin_p wMain(int argc, char * argv[]) { /* * INITIALIZE */ + LOG1(log_init, ( "initColor\n" )) + InitColor(); LOG1(log_init, ( "initInfoBar\n" )) InitInfoBar(); - wSetSplashInfo("Misc2 Init..."); - LOG1(log_init, ( "misc2Init\n" )) - Misc2Init(); + wSetSplashInfo("Scale Init..."); + LOG1(log_init, ( "ScaleInit\n" )) + ScaleInit(); + wPrefGetInteger( "draw", "label-when", &labelWhen, labelWhen ); - RotateDialogInit(); - MoveDialogInit(); - IndexDialogInit(); wSetSplashInfo(_("Initializing commands")); LOG1(log_init, ( "paramInit\n" )) @@ -3207,28 +1185,20 @@ EXPORT wWin_p wMain(int argc, char * argv[]) { LOG1(log_init, ( "createMenus\n" )) CreateMenus(); + SetAccelKeys(); + LOG1(log_init, ( "initialize\n" )) - if (!Initialize()) + if (!Initialize()) { return NULL; - ParamRegister(&menuPG); - ParamRegister(&stickyPG); + } - /* initialize the layers */ - DefaultLayerProperties(); LOG1(log_init, ( "loadFileList\n" )) LoadFileList(); - AddPlaybackProc("MENU", MenuPlayback, NULL); //CreateDebugW(); /* * TIDY UP */ - curCommand = 0; - commandContext = commandList[curCommand].context; - - /* - * READ PARAMETERS - */ if (toolbarSet&(1<<BG_HOTBAR)) { LayoutHotBar( NULL ); } else { @@ -3239,16 +1209,27 @@ EXPORT wWin_p wMain(int argc, char * argv[]) { DrawInit(initialZoom); MacroInit(); + + /* + * READ PARAMETERS + */ wSetSplashInfo(_("Reading parameter files")); LOG1(log_init, ( "paramFileInit\n" )) - SetParamFileDir(GetCurrentPath(LAYOUTPATHKEY)); //Set default for new parms to be the same as the layout + SetParamFileDir(GetCurrentPath( + LAYOUTPATHKEY)); //Set default for new parms to be the same as the layout - if (!ParamFileListInit()) + if (!ParamFileListInit()) { return NULL; - // LOG1(log_init, ("!ParamFileListInit()\n")) + } + + /* initialize the layers */ + LOG1(log_init, ("DefaultLayerProperties")); + DefaultLayerProperties(); + + // LOG1(log_init, ("!ParamFileListInit()\n")) - curCommand = describeCmdInx; + CommandInit(); LOG1(log_init, ( "Reset\n" )) Reset(); @@ -3257,15 +1238,14 @@ EXPORT wWin_p wMain(int argc, char * argv[]) { */ /* Set up the data for scale and gauge description */ - DoSetScaleDesc(); + DoAllSetScaleDesc(); // get the preferred scale from the configuration file pref = wPrefGetString("misc", "scale"); - if (!pref) + if ( pref == NULL || DoSetScale( pref ) == FALSE ) { // if preferred scale was not set (eg. during initial run), initialize to a default value - pref = DEFAULT_SCALE; - strcpy(buffer, pref); - DoSetScale(buffer); + DoSetScale( DEFAULT_SCALE ); + } /* see whether last layout should be reopened on startup */ wPrefGetInteger("DialogItem", "pref-onstartup", &onStartup, 0); @@ -3278,7 +1258,6 @@ EXPORT wWin_p wMain(int argc, char * argv[]) { EnableCommands(); LOG1(log_init, ( "Initialization complete\n" )) wSetSplashInfo(_("Initialization complete")); - RegisterChangeNotification(ToolbarChange); DoChangeNotification( CHANGE_MAIN | CHANGE_MAP); wWinShow(mainW, TRUE); @@ -3288,22 +1267,19 @@ EXPORT wWin_p wMain(int argc, char * argv[]) { /* this has to be called before ShowTip() */ InitSmallDlg(); - /* Compare the program version and display Beta warning if appropriate */ - pref = wPrefGetString("misc", "version"); - if((!pref) || (strcmp(pref,XTRKCAD_VERSION) != 0)) - { - if(strstr(XTRKCAD_VERSION,"Beta") != NULL) - { - NoticeMessage(MSG_BETA_NOTICE, _("Ok"),NULL, XTRKCAD_VERSION); - } - //else { - // NoticeMessage(_("New version welcome..."),_("Ok"),NULL); - //} - wPrefSetString("misc", "version", XTRKCAD_VERSION); - } - else { - ShowTip(SHOWTIP_NEXTTIP); - } + /* Compare the program version and display Beta warning if appropriate */ + pref = wPrefGetString("misc", "version"); + if((!pref) || (strcmp(pref,XTRKCAD_VERSION) != 0)) { + if(strstr(XTRKCAD_VERSION,"Beta") != NULL) { + NoticeMessage(MSG_BETA_NOTICE, _("Ok"),NULL, XTRKCAD_VERSION); + } + //else { + // NoticeMessage(_("New version welcome..."),_("Ok"),NULL); + //} + wPrefSetString("misc", "version", XTRKCAD_VERSION); + } else { + ShowTip(SHOWTIP_NEXTTIP); + } /* check for existing checkpoint file */ resumeWork = FALSE; @@ -3320,16 +1296,58 @@ EXPORT wWin_p wMain(int argc, char * argv[]) { bExample = (iExample == 1); } if (initialFile && strlen(initialFile)) { - DoFileList(0, "1", initialFile); //Will load Background values, if archive, leave - if (onStartup == 1) - LayoutBackGroundInit(TRUE); //Wipe Out Prior Background - else - LayoutBackGroundInit(FALSE); //Get Prior BackGround - } else - LayoutBackGroundInit(TRUE); // If onStartup==1 and no initial file - Wipe Out Prior Background + DoFileList(0, "1", + initialFile); //Will load Background values, if archive, leave + if (onStartup == 1) { + LayoutBackGroundInit(TRUE); //Wipe Out Prior Background + } else { + LayoutBackGroundInit(FALSE); //Get Prior BackGround + } + } else { + LayoutBackGroundInit( + TRUE); // If onStartup==1 and no initial file - Wipe Out Prior Background + } } MainRedraw(); inMainW = FALSE; + if ( bRunTests ) { + int nFail = RegressionTestAll(); + if ( nFail == 0 ) { + lprintf( "Regression Tests Pass\n" ); + exit( 0 ); + } else { + lprintf( "%d Regression Tests Fail\n", nFail ); + exit( 1 ); + } + } return mainW; } + +/**************************************************************************** + * + * CHANGE NOTIFICATION + * + */ +#define CNCB_COUNT (40) + +static changeNotificationCallBack_t changeNotificationCallBacks[CNCB_COUNT]; +static int changeNotificationCallBackCnt = 0; + +EXPORT void RegisterChangeNotification( + changeNotificationCallBack_t action ) +{ + CHECK( (changeNotificationCallBackCnt + 1) < CNCB_COUNT ); + changeNotificationCallBacks[changeNotificationCallBackCnt] = action; + changeNotificationCallBackCnt++; +} + + +EXPORT void DoChangeNotification( long changes ) +{ + int inx; + for (inx=0; inx<changeNotificationCallBackCnt; inx++) { + changeNotificationCallBacks[inx](changes); + } +} + diff --git a/app/bin/misc.h b/app/bin/misc.h index 509f2d8..641f47f 100644 --- a/app/bin/misc.h +++ b/app/bin/misc.h @@ -17,279 +17,94 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef MISC_H #define MISC_H -#define EXPORT - -#include "acclkeys.h" #include "common.h" -typedef void (*addButtonCallBack_t)(void*); - -#define COUNT(A) (sizeof(A)/sizeof(A[0])) - -#define STR_SIZE (256) -#define STR_SHORT_SIZE (80) -#define STR_LONG_SIZE (1024) -#define STR_HUGE_SIZE (10240) - -#define CAST_AWAY_CONST (char*) - -#define TITLEMAXLEN (40) /* * Globals */ extern int iconSize; - -extern long adjTimer; - -typedef int SCALEINX_T; -typedef int GAUGEINX_T; -typedef int SCALEDESCINX_T; - -extern int log_error; - -extern long toolbarSet; -extern ANGLE_T turntableAngle; -extern long maxCouplingSpeed; -extern long hideSelectionWindow; -extern long labelWhen; -extern long labelScale; -extern long labelEnable; -extern long colorTrack; -extern long colorDraw; -extern long carHotbarModeInx; -extern DIST_T minLength; -extern DIST_T connectDistance; -extern ANGLE_T connectAngle; -extern long twoRailScale; -extern long mapScale; -extern long constrainMain; -extern long dontHideCursor; -extern long checkPtInterval; -extern long autosaveChkPoints; -extern long liveMap; -extern long preSelect; -extern long hideTrainsInTunnels; -extern long listLabels; -extern long layoutLabels; -extern long descriptionFontSize; -extern long units; +extern wWinPix_t displayWidth; +extern wWinPix_t displayHeight; +extern wWin_p mainW; +extern char message[STR_HUGE_SIZE]; +extern long paramVersion; +extern coOrd zero; +extern wBool_t extraButtons; extern long onStartup; -extern long angleSystem; -extern DIST_T trackGauge; -extern DIST_T curScaleRatio; -extern char * curScaleName; -extern int enumerateMaxDescLen; -extern long enableBalloonHelp; -extern long showFlexTrack; -extern long hotBarLabels; -extern long rightClickMode; -extern long selectMode; -extern long selectZero; -extern void * commandContext; -extern coOrd cmdMenuPos; -#define MODE_DESIGN (0) -#define MODE_TRAIN (1) -extern long programMode; -#define DISTFMT_DECS 0x00FF -#define DISTFMT_FMT 0x0300 -#define DISTFMT_FMT_NONE 0x0000 -#define DISTFMT_FMT_SHRT 0x0100 -#define DISTFMT_FMT_LONG 0x0200 -#define DISTFMT_FMT_MM 0x0100 -#define DISTFMT_FMT_CM 0x0200 -#define DISTFMT_FMT_M 0x0300 -#define DISTFMT_FRACT 0x0400 -#define DISTFMT_FRACT_NUM 0x0000 -#define DISTFMT_FRACT_FRC 0x0400 - #define UNITS_ENGLISH (0) #define UNITS_METRIC (1) -#define GetDim(X) ((units==UNITS_METRIC)?(X)/2.54:(X)) -#define PutDim(X) ((units==UNITS_METRIC)?(X)*2.54:(X)) -#define ANGLE_POLAR (0) -#define ANGLE_CART (1) -#define GetAngle(X) ((angleSystem==ANGLE_POLAR)?(X):NormalizeAngle(90.0-(X))) -#define PutAngle(X) ((angleSystem==ANGLE_POLAR)?(X):NormalizeAngle(90.0-(X))) -#define LABELENABLE_TRKDESC (1<<0) -#define LABELENABLE_LENGTHS (1<<1) +extern long units; +extern long labelScale; +#define LABELENABLE_TRKDESC (1<<0) +#define LABELENABLE_LENGTHS (1<<1) #define LABELENABLE_ENDPT_ELEV (1<<2) #define LABELENABLE_TRACK_ELEV (1<<3) -#define LABELENABLE_CARS (1<<4) - -/* - * Command Action - */ -#define C_DOWN wActionLDown -#define C_MOVE wActionLDrag -#define C_UP wActionLUp -#define C_RDOWN wActionRDown -#define C_RMOVE wActionRDrag -#define C_RUP wActionRUp -#define C_TEXT wActionText -#define C_WUP wActionWheelUp -#define C_WDOWN wActionWheelDown -#define C_LDOUBLE wActionLDownDouble -#define C_MODKEY wActionModKey -#define C_SCROLLUP wActionScrollUp -#define C_SCROLLDOWN wActionScrollDown -#define C_SCROLLLEFT wActionScrollLeft -#define C_SCROLLRIGHT wActionScrollRight -#define C_INIT (wActionLast+1) -#define C_START (wActionLast+2) -#define C_REDRAW (wActionLast+3) -#define C_CANCEL (wActionLast+4) -#define C_OK (wActionLast+5) -#define C_CONFIRM (wActionLast+6) -#define C_LCLICK (wActionLast+7) -#define C_RCLICK (wActionLast+8) -#define C_CMDMENU (wActionLast+9) -#define C_FINISH (wActionLast+10) -#define C_UPDATE (wActionLast+11) - -#define C_CONTINUE (100) -#define C_TERMINATE (101) -#define C_INFO (102) -#define C_ERROR (103) - -/* - * Commands - */ -#define LEVEL0 (0) -#define LEVEL0_50 (1) -#define LEVEL1 (2) -#define LEVEL2 (3) - -typedef STATUS_T (*procCommand_t) (wAction_t, coOrd); +#define LABELENABLE_CARS (1<<4) +extern long labelEnable; +extern long labelWhen; -/* - * Windows and buttons - */ -extern wWinPix_t DlgSepLeft; -extern wWinPix_t DlgSepMid; -extern wWinPix_t DlgSepRight; -extern wWinPix_t DlgSepTop; -extern wWinPix_t DlgSepBottom; -extern wWinPix_t DlgSepNarrow; -extern wWinPix_t DlgSepWide; -extern wWinPix_t DlgSepFrmLeft; -extern wWinPix_t DlgSepFrmRight; -extern wWinPix_t DlgSepFrmTop; -extern wWinPix_t DlgSepFrmBottom; +extern long dontHideCursor; // not used +#ifdef HIDESELECTIONWINDOW +extern long hideSelectionWindow; // not used +#endif -extern wWin_p mainW; -extern wWinPix_t toolbarHeight; -extern wIndex_t changed; -extern char message[STR_HUGE_SIZE]; -extern REGION_T curRegion; -extern long paramVersion; -extern coOrd zero; -extern wBool_t extraButtons; -extern wButton_p undoB; -extern wButton_p redoB; -extern wButton_p zoomUpB; /** ZoomUp button on toolbar */ -extern wButton_p zoomDownB; /** ZoomDown button on toolbar */ -extern wButton_p backgroundB; /** background visibility control */ -// extern wButton_p easementB; -extern wIndex_t checkPtMark; -extern wMenu_p demoM; -extern wMenu_p popup1M, popup2M; +#define GetDim(X) ((units==UNITS_METRIC)?(X)/2.54:(X)) +#define PutDim(X) ((units==UNITS_METRIC)?(X)*2.54:(X)) #define wControlBelow( B ) (wControlGetPosY((wControl_p)(B))+wControlGetHeight((wControl_p)(B))) #define wControlBeside( B ) (wControlGetPosX((wControl_p)(B))+wControlGetWidth((wControl_p)(B))) -typedef void (*rotateDialogCallBack_t) ( void * ); -typedef void (*indexDialogCallBack_t) (void * ); -typedef void (*moveDialogCallBack_t) (void *); -extern void AddRotateMenu( wMenu_p, rotateDialogCallBack_t ); -extern void AddMoveMenu( wMenu_p, moveDialogCallBack_t ); -extern void AddIndexMenu(wMenu_p m, indexDialogCallBack_t func); /* * Safe Memory etc */ -void * MyMalloc( size_t ); -void * MyRealloc( void *, size_t ); -void MyFree( void * ); -void * memdup( void *, size_t ); -char * MyStrdup( const char * ); -void AbortProg( const char *, ... ); -#define ASSERT( X ) if ( !(X) ) AbortProg( "%s: %s:%d", #X, __FILE__, __LINE__ ) -char * Strcpytrimed( char *, const char *, BOOL_T ); -char * BuildTrimedTitle( char *, const char *, const char *, const char *, const char * ); -void ErrorMessage( const char *, ... ); -void InfoMessage( const char *, ... ); -int NoticeMessage( const char *, const char*, const char *, ... ); -int NoticeMessage2( int, const char *, const char*, const char *, ... ); -void DoQuit( void * unused ); - -void SetFileChanged(void); -char * ConvertFromEscapedText(const char * text); -char * ConvertToEscapedText(const char * text); - -int MagneticSnap( int state ); -void wShow( wWin_p ); -void wHide( wWin_p ); -void CloseDemoWindows( void ); -void DefaultProc( wWin_p, winProcEvent, void * ); -void SelectFont( void * unused ); - -void CheckRoomSize( BOOL_T ); -const char * GetBalloonHelpStr( const char* ); -const char * GetCurCommandName( void ); -void EnableCommands( void ); -void Reset( void ); -void TryCheckPoint( void ); -wIndex_t GetCurrentCommand(void); -BOOL_T IsCurCommandSticky(void); -void ResetIfNotSticky( void ); -wBool_t DoCurCommand( wAction_t, coOrd ); -int ConfirmReset( BOOL_T ); -void LayoutToolBar( void * ); -#define IC_STICKY (1<<0) -#define IC_INITNOTSTICKY (1<<1) -#define IC_CANCEL (1<<2) -#define IC_MENU (1<<3) -#define IC_NORESTART (1<<4) -#define IC_SELECTED (1<<5) -#define IC_POPUP (1<<6) -#define IC_LCLICK (1<<7) -#define IC_RCLICK (1<<8) -#define IC_CMDMENU (1<<9) -#define IC_POPUP2 (1<<10) -#define IC_ABUT (1<<11) -#define IC_ACCLKEY (1<<12) -#define IC_MODETRAIN_TOO (1<<13) -#define IC_MODETRAIN_ONLY (1<<14) -#define IC_WANT_MOVE (1<<15) -#define IC_PLAYBACK_PUSH (1<<16) -#define IC_WANT_MODKEYS (1<<17) -#define IC_POPUP3 (1<<18) -wIndex_t InitCommand( wMenu_p, procCommand_t, const char *, const char *, int, long, long ); -void AddToolbarControl( wControl_p, long ); -BOOL_T CommandEnabled( wIndex_t ); -wButton_p AddToolbarButton( const char*, wIcon_p, long, wButtonCallBack_p, void * context ); -// RWS not found: wIndex_t AddCommandButton( procCommand_t, char*, char*, wIcon_p, int, long, long, void* ); -wIndex_t AddMenuButton( wMenu_p, procCommand_t, const char*, const char*, wIcon_p, int, long, long, void* ); -void PlaybackButtonMouse( wIndex_t ); -void ButtonGroupBegin( const char *, const char *, const char * ); -void ButtonGroupEnd( void ); - -void SaveState( void ); - -void PlaybackCommand( const char *, wIndex_t ); -wMenu_p MenuRegister( const char * label ); -void DoCommandB( void * ); - -extern void EnumerateTracks( void * unused ); -void InitDebug( const char *, long * ); +extern BOOL_T TestMallocs( void ); +extern void * MyMalloc( size_t ); +extern void * MyRealloc( void *, size_t ); +extern void MyFree( void * ); +extern void * memdup( void *, size_t ); +extern char * MyStrdup( const char * ); + +extern char * ConvertFromEscapedText(const char * text); +extern char * ConvertToEscapedText(const char * text); + +extern const char * AbortMessage( const char *, ... ); +extern void AbortProg( const char *, const char *, int, const char * ); +#ifdef LOG_CHECK_COVERAGE +#define CHECK( X ) lprintf( "CHECK %s:%i\n", __FILE__, __LINE__ ); if ( !(X) ) AbortProg( #X, __FILE__, __LINE__, NULL ) +#define CHECKMSG( X, MSG ) lprintf( "CHECK %s:%i\n", __FILE__, __LINE__ ); if ( !(X) ) AbortProg( #X, __FILE__, __LINE__, AbortMessage MSG ) +#else +#define CHECK( X ) if ( !(X) ) AbortProg( #X, __FILE__, __LINE__, NULL ) +#define CHECKMSG( X, MSG ) if ( !(X) ) AbortProg( #X, __FILE__, __LINE__, AbortMessage MSG ) +#endif +extern char * Strcpytrimed( char *, const char *, BOOL_T ); +extern wBool_t CheckHelpTopicExists(const char * topic); + +extern void InfoMessage( const char *, ... ); +extern void ErrorMessage( const char *, ... ); +extern int NoticeMessage( const char *, const char*, const char *, ... ); +extern int NoticeMessage2( int, const char *, const char*, const char *, ... ); + +extern bool Confirm( char *, doSaveCallBack_p ); +extern void DoQuit( void * unused ); +extern void DoClear( void * unused ); +extern void MapWindowToggleShow( void * unused ); +extern void MapWindowShow( int state ); +extern void DoShowWindow(int index, const char * name, void * data); + +extern void wShow( wWin_p ); +extern void wHide( wWin_p ); +extern void CloseDemoWindows( void ); +extern void DefaultProc( wWin_p, winProcEvent, void * ); +typedef void (*changeNotificationCallBack_t)( long ); #define CHANGE_SCALE (1<<0) #define CHANGE_PARAMS (1<<1) #define CHANGE_MAIN (1<<2) @@ -301,25 +116,32 @@ void InitDebug( const char *, long * ); #define CHANGE_CMDOPT (1<<9) #define CHANGE_LIMITS (1<<10) #define CHANGE_ICONSIZE (1<<11) -#define CHANGE_ALL (CHANGE_SCALE|CHANGE_PARAMS|CHANGE_MAIN|CHANGE_MAP|CHANGE_UNITS|CHANGE_TOOLBAR|CHANGE_CMDOPT|CHANGE_BACKGROUND) -typedef void (*changeNotificationCallBack_t)( long ); -void RegisterChangeNotification( changeNotificationCallBack_t ); -void DoChangeNotification( long ); +#define CHANGE_LAYER (1<<3) +#define CHANGE_ALL (CHANGE_SCALE|CHANGE_PARAMS|CHANGE_MAIN|CHANGE_LAYER|CHANGE_MAP|CHANGE_UNITS|CHANGE_TOOLBAR|CHANGE_CMDOPT|CHANGE_BACKGROUND) +extern void RegisterChangeNotification( changeNotificationCallBack_t ); +extern void DoChangeNotification( long ); -wBool_t CheckHelpTopicExists(const char * topic); /* foreign externs */ -extern STATUS_T CmdEnumerate( wAction_t, coOrd ); -extern wIndex_t modifyCmdInx; -extern wIndex_t joinCmdInx; -extern wIndex_t tunnelCmdInx; - -/* ctodesgn.c */ -void InitNewTurn( wMenu_p m ); +/* Initializers */ +addButtonCallBack_t ColorInit( void ); +addButtonCallBack_t SettingsInit( void ); +addButtonCallBack_t PrefInit( void ); +addButtonCallBack_t LayoutInit( void ); +addButtonCallBack_t DisplayInit( void ); +addButtonCallBack_t CmdoptInit( void ); +addButtonCallBack_t OutputBitMapInit( void ); +addButtonCallBack_t CustomMgrInit( void ); +addButtonCallBack_t PriceListInit( void ); +addButtonCallBack_t ParamFilesInit( void ); +addButtonCallBack_t ControlMgrInit ( void ); /* cnote.c */ void ClearNote( void ); +void DoNote( void * unused ); +BOOL_T WriteMainNote( FILE * ); +BOOL_T ReadMainNote(char * line); /* cprintc.c */ coOrd GetPrintOrig(); @@ -331,45 +153,21 @@ void RulerRedraw( BOOL_T ); STATUS_T ModifyRuler( wAction_t, coOrd ); STATUS_T ModifyProtractor( wAction_t, coOrd ); -/* dialogs */ -void OutputBitMap( void ); - -extern wDrawColor snapGridColor; - -addButtonCallBack_t ColorInit( void ); -addButtonCallBack_t SettingsInit( void ); -addButtonCallBack_t PrefInit( void ); -addButtonCallBack_t LayoutInit( void ); -addButtonCallBack_t DisplayInit( void ); -addButtonCallBack_t CmdoptInit( void ); -addButtonCallBack_t OutputBitMapInit( void ); -addButtonCallBack_t CustomMgrInit( void ); -addButtonCallBack_t PriceListInit( void ); -addButtonCallBack_t ParamFilesInit( void ); -addButtonCallBack_t ControlMgrInit ( void ); - +/* csnap.c */ wIndex_t InitGrid( wMenu_p menu ); - BOOL_T SnapPos( coOrd * ); +BOOL_T SnapPosAngle( coOrd *, ANGLE_T * ); void DrawSnapGrid( drawCmd_p, coOrd, BOOL_T ); BOOL_T GridIsVisible( void ); void InitSnapGridButtons( void ); void SnapGridEnable( void * unused ); void SnapGridShow( void * unused ); -void MapWindowShow( int state ); -extern wMenuToggle_p snapGridEnableMI; -extern wMenuToggle_p snapGridShowMI; -void ScaleLengthEnd( void ); -void EnumerateList( long, FLOAT_T, char * , char * ); -void EnumerateStart(void); -void EnumerateEnd(void); - -/* cnote.c */ -void DoNote( void * unused ); -BOOL_T WriteMainNote( FILE * ); +/* ctodesgn.c */ +void InitNewTurn( wMenu_p m ); -BOOL_T ReadMainNote(char * line); +/* cturntbl.c */ +extern ANGLE_T turntableAngle; /* dbench.c */ long GetBenchData( long, long ); @@ -415,23 +213,21 @@ BOOL_T CarCustomSave(FILE*); typedef int (*contMgmCallBack_p) (int, void *); void ContMgmLoad (wIcon_p,contMgmCallBack_p,void *); -/* dlayer.c */ -void LayerSetCounts(); -int FindUnusedLayer(unsigned int start); -void DecrementLayerObjects(unsigned int index); -void IncrementLayerObjects(unsigned int index); +/* dease.c */ +extern DIST_T easementVal; +extern DIST_T easeR; +extern DIST_T easeL; + +/* denum.c */ +extern int enumerateMaxDescLen; +void EnumerateList( long, FLOAT_T, char *, char * ); +void EnumerateStart(void); +void EnumerateEnd(void); /* doption.c */ +extern long enableBalloonHelp; long GetDistanceFormat( void ); -/* ctrain.c */ -BOOL_T WriteCars( FILE * ); -void ClearCars( void ); -void CarDlgAddProto( void ); -void CarDlgAddDesc( void ); -void AttachTrains( void ); - - /* cblock.c */ void InitCmdBlock( wMenu_p menu ); void BlockMgmLoad( void ); @@ -447,9 +243,55 @@ void InitCmdControl ( wMenu_p menu ); /* csensor.c */ void SensorMgmLoad ( void ); void InitCmdSensor ( wMenu_p menu ); + /* cmodify.c */ +extern wIndex_t modifyCmdInx; STATUS_T CmdModify(wAction_t action,coOrd pos ); -#include "misc2.h" +/* ctrain.c */ +#define MODE_DESIGN (0) +#define MODE_TRAIN (1) +extern long programMode; +extern long maxCouplingSpeed; +extern long hideTrainsInTunnels; + +/* fileio.c */ +extern long checkPtInterval; +extern long autosaveChkPoints; +extern wIndex_t checkPtMark; + +/* layout.c */ +extern wIndex_t changed; +void SetFileChanged(void); + +/* macro.c */ +extern long adjTimer; +int RegressionTestAll(); + +/* lprintf.c */ +typedef struct { + char * name; + int level; +} logTable_t; +extern dynArr_t logTable_da; +#define logTable(N) DYNARR_N( logTable_t, logTable_da, N ) +extern time_t logClock; +void LogOpen( char * ); +void LogClose( void ); +void LogSet( char *, int ); +int LogFindIndex( const char * ); +void LogPrintf( const char *, ... ); +#define LOG( DBINX, DBLVL, DBMSG ) \ + if ( (DBINX) > 0 && logTable( (DBINX) ).level >= (DBLVL) ) { \ + LogPrintf DBMSG ; \ + } +#define LOG1( DBINX, DBMSG ) LOG( DBINX, 1, DBMSG ) +#define LOGNAME( DBNAME, DBMSG ) LOG( LogFindIndex( DBNAME ), DBMSG ) + +#define NUM_FILELIST (5) +#define lprintf LogPrintf + +/* track.c */ +extern void EnumerateTracks( void * unused ); #endif diff --git a/app/bin/misc2.c b/app/bin/misc2.c deleted file mode 100644 index 6334bf2..0000000 --- a/app/bin/misc2.c +++ /dev/null @@ -1,898 +0,0 @@ -/** \file misc2.c - * Management of information about scales and gauges plus rprintf. - */ - -/* XTrkCad - Model Railroad CAD - * Copyright (C) 2005 Dave Bullis - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "cjoin.h" -#include "common.h" -#include "compound.h" -#include "custom.h" -#include "draw.h" -#include "fileio.h" -#include "layout.h" -#include "misc.h" -#include "param.h" -#include "track.h" -#include "common-ui.h" - - -EXPORT long units = 0; /**< measurement units: 0 = English, 1 = metric */ -EXPORT long checkPtInterval = 10; -EXPORT long autosaveChkPoints = 0; - -EXPORT DIST_T curScaleRatio; -EXPORT char * curScaleName; -EXPORT DIST_T trackGauge; -EXPORT long labelScale = 8; -EXPORT long labelEnable = (LABELENABLE_ENDPT_ELEV|LABELENABLE_CARS); -/** @prefs [draw] label-when=2 Unknown */ -EXPORT long labelWhen = 2; -EXPORT long colorTrack = 0; -EXPORT long colorDraw = 0; -EXPORT long constrainMain = 0; -EXPORT long dontHideCursor = 0; -EXPORT long hideSelectionWindow = 0; -EXPORT long angleSystem = 0; -EXPORT DIST_T minLength = 0.1; -EXPORT DIST_T connectDistance = 0.1; -EXPORT ANGLE_T connectAngle = 1.0; -EXPORT long twoRailScale = 16; -EXPORT long mapScale = 64; -EXPORT long liveMap = 0; -EXPORT long preSelect = 0; /**< default command 0 = Describe 1 = Select */ -EXPORT long listLabels = 7; -EXPORT long layoutLabels = 1; -EXPORT long descriptionFontSize = 72; -EXPORT long enableListPrices = 1; -EXPORT void ScaleLengthEnd(void); - -static BOOL_T SetScaleDescGauge(SCALEINX_T scaleInx); - - -/**************************************************************************** - * - * RPRINTF - * - */ - - -#define RBUFF_SIZE (8192) -static char rbuff[RBUFF_SIZE+1]; -static int roff; -static int rbuff_record = 0; - -EXPORT void Rdump( FILE * outf ) -{ - fprintf( outf, "Record Buffer:\n" ); - rbuff[RBUFF_SIZE] = '\0'; - fprintf( outf, "%s", rbuff+roff ); - rbuff[roff] = '\0'; - fprintf( outf, "%s", rbuff ); - memset( rbuff, 0, sizeof rbuff ); - roff = 0; -} - - -EXPORT void Rprintf( - char * format, - ... ) -{ - static char buff[STR_SIZE]; - char * cp; - va_list ap; - va_start( ap, format ); - vsprintf( buff, format, ap ); - va_end( ap ); - if (rbuff_record >= 1) - lprintf( buff ); - for ( cp=buff; *cp; cp++ ) { - rbuff[roff] = *cp; - roff++; - if (roff>=RBUFF_SIZE) - roff=0; - } -} - -/**************************************************************************** - * - * CHANGE NOTIFICATION - * - */ - - -static changeNotificationCallBack_t changeNotificationCallBacks[20]; -static int changeNotificationCallBackCnt = 0; - -EXPORT void RegisterChangeNotification( - changeNotificationCallBack_t action ) -{ - changeNotificationCallBacks[changeNotificationCallBackCnt] = action; - changeNotificationCallBackCnt++; -} - - -EXPORT void DoChangeNotification( long changes ) -{ - int inx; - for (inx=0;inx<changeNotificationCallBackCnt;inx++) - changeNotificationCallBacks[inx](changes); -} - - -/**************************************************************************** - * - * SCALE - * - */ - -typedef struct { - char * scale; - DIST_T ratio; - DIST_T gauge; - DIST_T R[3]; - DIST_T X[3]; - DIST_T L[3]; - wIndex_t index; - DIST_T length; - BOOL_T tieDataValid; - tieData_t tieData; - } scaleInfo_t; -EXPORT typedef scaleInfo_t * scaleInfo_p; -static dynArr_t scaleInfo_da; -#define scaleInfo(N) DYNARR_N( scaleInfo_t, scaleInfo_da, N ) - -typedef struct { - char *in_scales; - SCALE_FIT_TYPE_T type; - char *match_scales; - SCALE_FIT_T result; -} scaleComp_t; -EXPORT typedef scaleComp_t * scaleComp_p; -static dynArr_t scaleCompatible_da; -#define scaleComp(N) DYNARR_N( scaleComp_t, scaleCompatible_da, N ) - -static tieData_t tieData_demo = { - 96.0/160.0, - 16.0/160.0, - 32.0/160.0 }; - -//EXPORT SCALEINX_T curScaleInx = -1; -static scaleInfo_p curScale; -/** @prefs [misc] include same gauge turnouts=1 Unknown */ -EXPORT long includeSameGaugeTurnouts = FALSE; -static SCALEINX_T demoScaleInx = -1; - - -/** this struct holds a gauge description */ -typedef struct { - char * gauge; /** ptr to textual description eg. 'n3' */ - SCALEINX_T scale; /** index of complete information in scaleInfo_da */ - wIndex_t index; - } gaugeInfo_t; - -EXPORT typedef gaugeInfo_t * gaugeInfo_p; - -/** this struct holds a scale description */ -typedef struct { - char *scaleDesc; /** ptr to textual description eg. 'HO' */ - SCALEINX_T scale; /** index of complete information (standard gauge) in scaleInfo_da */ - wIndex_t index; - dynArr_t gauges_da; /** known gauges to this scale */ - } scaleDesc_t; - -EXPORT typedef scaleDesc_t *scaleDesc_p; -static dynArr_t scaleDesc_da; -#define scaleDesc(N) DYNARR_N( scaleDesc_t, scaleDesc_da, N ) - - -/** - * Get the ratio from a scale description. Each member in the list of scale descriptions is - * linked to an entry in the simple linear list of all scales/gauges. From there the ratio is - * fetched and returned. Note that there is no error checking on parameters! - * - * \param IN sdi index into list of scale descriptions - * \return ratio for scale - */ - -EXPORT DIST_T GetScaleDescRatio( SCALEDESCINX_T sdi ) -{ - return GetScaleRatio( scaleDesc(sdi).scale ); -} - -/** - * Get the index into the linear list from a scale description and a gauge. All information about a - * scale/ gauge combination is stored in a linear list. The index in that list for a given scale and the - * gauge is returned by this function. Note that there is no error checking on parameters! - * - * \param IN scaleInx index into list of scale descriptions - * \param IN gaugeInx index into list of gauges available for this scale - * \return index into master list of scale/gauge combinations - */ - -EXPORT SCALEINX_T GetScaleInx( SCALEDESCINX_T scaleInx, GAUGEINX_T gaugeInx ) -{ - scaleDesc_t s; - gaugeInfo_p g; - - s = scaleDesc(scaleInx); - g = &(DYNARR_N(gaugeInfo_t, s.gauges_da, gaugeInx)); - - return g->scale; - -} -EXPORT DIST_T GetScaleTrackGauge( SCALEINX_T si ) -{ - if (si >=0 && si<scaleInfo_da.cnt) - return scaleInfo(si).gauge; - else return 1.0; -} - -EXPORT DIST_T GetScaleRatio( SCALEINX_T si ) -{ - if (si >=0 && si<scaleInfo_da.cnt) - return scaleInfo(si).ratio; - else return 1.0; -} - -EXPORT char * GetScaleName( SCALEINX_T si ) -{ - if ( si == -1 ) - return "DEMO"; - if ( si == SCALE_ANY ) - return "*"; - else if ( si < 0 || si >= scaleInfo_da.cnt ) - return "Unknown"; - else - return scaleInfo(si).scale; -} - -EXPORT void GetScaleEasementValues( DIST_T * R, DIST_T * L ) -{ - wIndex_t i; - for (i=0;i<3;i++) { - *R++ = curScale->R[i]; - *L++ = curScale->L[i]; - } -} - - -EXPORT tieData_p GetScaleTieData( SCALEINX_T si ) -{ - scaleInfo_p s; - DIST_T defLength; - - if ( si == -1 ) - return &tieData_demo; - else if ( si < 0 || si >= scaleInfo_da.cnt ) - return &tieData_demo; - s = &scaleInfo(si); - if ( !s->tieDataValid ) { - sprintf( message, "tiedata-%s", s->scale ); - defLength = (96.0-54.0)/s->ratio+s->gauge; - - /** @prefs [tiedata-<SCALE>] length, width, spacing Sets tie drawing data. - * Example for 6"x8"x6' ties spaced 20" in HOn3 (slash separates 4 lines): - * [tiedata-HOn3] \ length=0.83 \ width=0.07 \ spacing=0.23 - */ - wPrefGetFloat( message, "length", &s->tieData.length, defLength ); - wPrefGetFloat( message, "width", &s->tieData.width, 16.0/s->ratio ); - wPrefGetFloat( message, "spacing", &s->tieData.spacing, 2*s->tieData.width ); - s->tieDataValid = TRUE; - } - return &scaleInfo(si).tieData; -} - -EXPORT char *GetScaleDesc( SCALEDESCINX_T inx ) -{ - return scaleDesc(inx).scaleDesc; -} - -EXPORT char *GetGaugeDesc( SCALEDESCINX_T scaleInx, GAUGEINX_T gaugeInx ) -{ - scaleDesc_t s; - gaugeInfo_p g; - - s = scaleDesc(scaleInx); - g = &(DYNARR_N(gaugeInfo_t, s.gauges_da, gaugeInx)); - - return g->gauge; -} - -void -SetScaleGauge(SCALEDESCINX_T desc, GAUGEINX_T gauge) -{ - dynArr_t gauges_da; - - gauges_da = (scaleDesc(desc)).gauges_da; - SetLayoutCurScale( DYNARR_N( gaugeInfo_t, gauges_da, gauge).scale); -} - -static BOOL_T -SetScaleDescGauge(SCALEINX_T scaleInx) -{ - int i, j; - char *scaleName = GetScaleName(scaleInx); - DIST_T scaleRatio = GetScaleRatio(scaleInx); - dynArr_t gauges_da; - - for (i = 0; i < scaleDesc_da.cnt; i++) { - char *t = strchr(scaleDesc(i).scaleDesc, ' '); - /* are the first characters (which describe the scale) identical? */ - if (!strncmp(scaleDesc(i).scaleDesc, scaleName, t - scaleDesc(i).scaleDesc)) { - /* if yes, are we talking about the same ratio */ - if (scaleInfo(scaleDesc(i).scale).ratio == scaleRatio) { - /* yes, we found the right scale descriptor, so now look for the gauge */ - SetLayoutCurScaleDesc( i ); - gauges_da = scaleDesc(i).gauges_da; - SetLayoutCurGauge(0); - for (j = 0; j < gauges_da.cnt; j++) { - gaugeInfo_p ptr = &(DYNARR_N(gaugeInfo_t, gauges_da, j)); - if (scaleInfo(ptr->scale).gauge == GetScaleTrackGauge(scaleInx)) { - SetLayoutCurGauge( j ); - break; - } - } - break; - } - } - } - - return TRUE; -} - -EXPORT SCALEINX_T LookupScale( const char * name ) -{ - wIndex_t si; - DIST_T gauge; - if ( strcmp( name, "*" ) == 0 ) - return SCALE_ANY; - for ( si=0; si<scaleInfo_da.cnt; si++ ) { - if (strcmp( scaleInfo(si).scale, name ) == 0) - return si; - } - if ( isdigit((unsigned char)name[0]) ) { - gauge = atof( name ); - for ( si=0; si<scaleInfo_da.cnt; si++ ) { - if (scaleInfo(si).gauge == gauge) - return si; - } - } - NoticeMessage( MSG_BAD_SCALE_NAME, "Ok", NULL, name, sProdNameLower ); - si = scaleInfo_da.cnt; - DYNARR_APPEND( scaleInfo_t, scaleInfo_da, 10 ); - scaleInfo(si) = scaleInfo(0); - scaleInfo(si).scale = MyStrdup( name ); - return si; -} - -/* - * Evaluate the fit of a part scale1 to a definition in scale2 for a type. - * - * The rules differ by type of object. - * - * Tracks need to be the same gauge to be a fit. If they are the same scale they are exact. - * If the gauge is the same, but the scale is different they are compatible. - * There are well known exceptions where the scale is not the same but we call them exact. - * - * Structures need to be the same scale to be exact. If they are within 15% they are compatible. - * - * Cars need to be the same gauge and scale to be exact. - * If they are the same gauge, but within 15% of the scale they are compatible. - * - *\param type (FIT_TURNOUT,FIT_STRUCTURE,FIT_CAR) - *\param scale1 the input scale - *\param scale2 the scale to check against - * - *\return FIT_EXACT, FIT_COMPATIBLE, FIT_NONE - */ - -EXPORT SCALE_FIT_T CompatibleScale( - SCALE_FIT_TYPE_T type, - SCALEINX_T scale1, - SCALEINX_T scale2 ) -{ - SCALE_FIT_T rc; - if ( scale1 == scale2 ) - return FIT_EXACT; - if ( scale1 == SCALE_DEMO || scale2 == SCALE_DEMO ) - return FIT_NONE; - if ( scale1 == demoScaleInx || scale2 == demoScaleInx ) - return FIT_NONE; - switch(type) { - case FIT_TURNOUT: - if ( scale1 == SCALE_ANY ) - return FIT_EXACT; - if (scaleInfo(scale1).gauge == scaleInfo(scale2).gauge && - scaleInfo(scale1).scale == scaleInfo(scale2).scale) - return FIT_EXACT; - - rc = FindScaleCompatible(FIT_TURNOUT, scaleInfo(scale1).scale, scaleInfo(scale2).scale); - if (rc != FIT_NONE) return rc; - - if ( includeSameGaugeTurnouts && - scaleInfo(scale1).gauge == scaleInfo(scale2).gauge ) - return FIT_COMPATIBLE; - break; - case FIT_STRUCTURE: - if ( scale1 == SCALE_ANY ) - return FIT_EXACT; - if ( scaleInfo(scale1).ratio == scaleInfo(scale2).ratio ) - return FIT_EXACT; - - rc = FindScaleCompatible(FIT_STRUCTURE, scaleInfo(scale1).scale, scaleInfo(scale2).scale); - if (rc != FIT_NONE) return rc; - - //15% scale match is compatible for structures - if (scaleInfo(scale1).ratio/scaleInfo(scale2).ratio>=0.85 && - scaleInfo(scale1).ratio/scaleInfo(scale2).ratio<=1.15) - return FIT_COMPATIBLE; - break; - case FIT_CAR: - if ( scale1 == SCALE_ANY ) - return FIT_EXACT; - if (scaleInfo(scale1).gauge == scaleInfo(scale2).gauge && - scaleInfo(scale1).scale == scaleInfo(scale2).scale) - return FIT_EXACT; - - rc = FindScaleCompatible(FIT_CAR, scaleInfo(scale1).scale, scaleInfo(scale2).scale); - if (rc != FIT_NONE) return rc; - - //Same gauge and 15% scale match is compatible for cars - if (scaleInfo(scale1).gauge == scaleInfo(scale2).gauge) { - if (scaleInfo(scale1).ratio/scaleInfo(scale2).ratio>=0.85 && - scaleInfo(scale1).ratio/scaleInfo(scale2).ratio<=1.15) - return FIT_COMPATIBLE; - } - break; - - default:; - } - - return FIT_NONE; - -} - -/** Split the scale and the gauge description for a given combination. Eg HOn3 will be - * split to HO and n3. - * \param scaleInx IN scale/gauge combination - * \param scaleDescInx OUT scale part - * \param gaugeInx OUT gauge part - * \return TRUE - */ - -EXPORT BOOL_T -GetScaleGauge( SCALEINX_T scaleInx, SCALEDESCINX_T *scaleDescInx, GAUGEINX_T *gaugeInx) -{ - int i, j; - char *scaleName = GetScaleName( scaleInx ); - DIST_T scaleRatio = GetScaleRatio( scaleInx ); - dynArr_t gauges_da; - - for( i = 0; i < scaleDesc_da.cnt; i++ ) { - char *t = strchr( scaleDesc(i).scaleDesc, ' ' ); - /* are the first characters (which describe the scale) identical? */ - if( !strncmp( scaleDesc(i).scaleDesc, scaleName, t - scaleDesc(i).scaleDesc )) { - /* if yes, are we talking about the same ratio */ - if( scaleInfo(scaleDesc(i).scale).ratio == scaleRatio ) { - /* yes, we found the right scale descriptor, so now look for the gauge */ - *scaleDescInx = i; - gauges_da = scaleDesc(i).gauges_da; - *gaugeInx = 0; - for( j = 0; j < gauges_da.cnt; j++ ) { - gaugeInfo_p ptr = &(DYNARR_N( gaugeInfo_t, gauges_da, j )); - if( scaleInfo(ptr->scale).gauge == GetScaleTrackGauge( scaleInx )) { - *gaugeInx = j; - break; - } - } - break; - } - } - } - - return TRUE; -} - -/** - * Setup XTrkCad for the newly selected scale/gauge combination. - * - * \param newScaleInx IN the index of the selected scale/gauge combination - */ - -static void -SetScale( SCALEINX_T newScaleInx ) -{ - if (newScaleInx < 0 || newScaleInx >= scaleInfo_da.cnt) { - NoticeMessage( MSG_BAD_SCALE_INDEX, _("Ok"), NULL, (int)newScaleInx ); - return; - } - SetLayoutCurScale((SCALEINX_T)newScaleInx ); - curScale = &scaleInfo(newScaleInx); - trackGauge = curScale->gauge; - curScaleRatio = curScale->ratio; - curScaleName = curScale->scale; - - SetLayoutCurScaleDesc( 0 ); - - SetScaleDescGauge((SCALEINX_T)newScaleInx); - - - if (!inPlayback) - wPrefSetString( "misc", "scale", curScaleName ); - - // now load the minimum radius for the newly selected scale - LoadLayoutMinRadiusPref(curScaleName, curScale->R[0]); -} - -/** - * Check the new scale value and update the program if a valid scale was passed - * - * \param newScale IN the name of the new scale - * \returns TRUE if valid, FALSE otherwise - */ - -EXPORT BOOL_T DoSetScale( - char * newScale ) -{ - SCALEINX_T scale; - char * cp; - BOOL_T found = FALSE; - - if ( newScale != NULL ) { - cp = newScale+strlen(newScale)-1; - while ( *cp=='\n' || *cp==' ' || *cp=='\t' ) cp--; - cp[1] = '\0'; - while (isspace((unsigned char)*newScale)) newScale++; - for (scale = 0; scale<scaleInfo_da.cnt; scale++) { - if (strcasecmp( scaleInfo(scale).scale, newScale ) == 0) { - SetLayoutCurScale(scale); - found = TRUE; - break; - } - } - // was a valid scale given? - if( found ) { - DoChangeNotification( CHANGE_SCALE ); - } - } - - return found; -} - -/** - * Setup the data structures for scale and gauge. XTC reads 'scales' into an dynamic array, - * but doesn't differentiate between scale and gauge. - * This da is split into an dynamic array of scales. Each scale holds a dynamic array of gauges, - * with at least one gauge per scale (ie standard gauge) - * - * For usage in the dialogs, a textual description for each scale or gauge is provided - * - * \return TRUE - */ - -EXPORT BOOL_T DoSetScaleDesc( void ) -{ - SCALEINX_T scaleInx; - SCALEINX_T work; - SCALEDESCINX_T descInx; - scaleDesc_p s = NULL; - gaugeInfo_p g; - char *cp; - DIST_T ratio; - BOOL_T found; - char buf[ 80 ]; - size_t len; - - for( scaleInx = 0; scaleInx < scaleInfo_da.cnt; scaleInx++ ) { - ratio = DYNARR_N( scaleInfo_t, scaleInfo_da, scaleInx ).ratio; - - /* do we already have a description for this scale? */ - found = 0; - - if( scaleDesc_da.cnt > 0 ) { - for( descInx = 0; descInx < scaleDesc_da.cnt; descInx++ ) { - work = scaleDesc(descInx).scale; - if( scaleInfo(work).ratio == scaleInfo(scaleInx).ratio ) { - if( !strncmp( scaleInfo(work).scale, scaleInfo(scaleInx).scale, strlen(scaleInfo(work).scale))) - found = TRUE; - } - } - } - - - if( !found ) { - /* if no, add as new scale */ - - DYNARR_APPEND( scaleDesc_t, scaleDesc_da, 1 ); - - s = &(scaleDesc( scaleDesc_da.cnt-1 )); - - s->scale = scaleInx; - - sprintf( buf, "%s (1/%.1f)", scaleInfo(scaleInx).scale, scaleInfo(scaleInx).ratio ); - s->scaleDesc = MyStrdup( buf ); - - /* initialize the array with standard gauge */ - - DYNARR_APPEND( gaugeInfo_t, s->gauges_da, 10 ); - - g = &(DYNARR_N( gaugeInfo_t, s->gauges_da, (s->gauges_da).cnt - 1 )); - g->scale = scaleInx; - sprintf( buf, "Standard (%.1fmm)", scaleInfo(scaleInx).gauge*25.4 ); - g->gauge = MyStrdup( buf ); - - } else { - /* if yes, is this a new gauge to the scale? */ - DYNARR_APPEND( gaugeInfo_t, s->gauges_da, 10 ); - g = &(DYNARR_N( gaugeInfo_t, s->gauges_da, (s->gauges_da).cnt - 1 )); - g->scale = scaleInx; - cp = strchr( s->scaleDesc, ' ' ); - if( cp ) - len = cp - s->scaleDesc; - else - len = strlen(s->scaleDesc); - sprintf( buf, "%s (%.1fmm)", scaleInfo(scaleInx).scale+len, scaleInfo(scaleInx).gauge*25.4 ); - g->gauge = MyStrdup( buf ); - } - } - - return( TRUE ); -} - -static BOOL_T AddScale( - char * line ) -{ - wIndex_t i; - BOOL_T rc; - DIST_T R[3], X[3], L[3]; - DIST_T ratio, gauge; - char scale[40]; - scaleInfo_p s; - - if ( (rc=sscanf( line, "SCALE %[^,]," SCANF_FLOAT_FORMAT "," SCANF_FLOAT_FORMAT "", - scale, &ratio, &gauge )) != 3) { - SyntaxError( "SCALE", rc, 3 ); - return FALSE; - } - for (i=0;i<3;i++) { - line = GetNextLine(); - if ( (rc=sscanf( line, "" SCANF_FLOAT_FORMAT "," SCANF_FLOAT_FORMAT "," SCANF_FLOAT_FORMAT "", - &R[i], &X[i], &L[i] )) != 3 ) { - SyntaxError( "SCALE easement", rc, 3 ); - return FALSE; - } - } - - DYNARR_APPEND( scaleInfo_t, scaleInfo_da, 10 ); - s = &scaleInfo(scaleInfo_da.cnt-1); - s->scale = MyStrdup( scale ); - s->ratio = ratio; - s->gauge = gauge; - s->index = -1; - for (i=0; i<3; i++) { - s->R[i] = R[i]/ratio; - s->X[i] = X[i]/ratio; - s->L[i] = L[i]/ratio; - } - s->tieDataValid = FALSE; - if ( strcmp( scale, "DEMO" ) == 0 ) - demoScaleInx = scaleInfo_da.cnt-1; - return TRUE; -} - -static BOOL_T AddScaleFit( - char * line) { - char scales[STR_SIZE], matches[STR_SIZE], type[20], result[20]; - BOOL_T rc; - scaleComp_p s; - - if ( (rc=sscanf( line, "SCALEFIT %s %s %s %s", - type, result, scales, matches )) != 4) { - SyntaxError( "SCALEFIT", rc, 4 ); - return FALSE; - } - DYNARR_APPEND( scaleComp_t, scaleCompatible_da, 10 ); - s = &scaleComp(scaleCompatible_da.cnt-1); - s->in_scales = MyStrdup(scales); - s->match_scales = MyStrdup(matches); - if (strcmp(type,"STRUCTURE") == 0) { - s->type = FIT_STRUCTURE; - } else if (strcmp(type,"TURNOUT")==0) { - s->type = FIT_TURNOUT; - } else if (strcmp(type,"CAR")==0) { - s->type = FIT_CAR; - } else { - InputError( "Invalid SCALEFIT type %s", TRUE, type ); - return FALSE; - } - if (strcmp(result,"COMPATIBLE")==0) { - s->result = FIT_COMPATIBLE; - } else if (strcmp(result,"EXACT")==0) { - s->result = FIT_EXACT; - } else { - InputError( "Invalid SCALEFIT result %s", TRUE, result ); - return FALSE; - } - - return TRUE; -} - -EXPORT SCALE_FIT_T FindScaleCompatible(SCALE_FIT_TYPE_T type, char * scale1, char * scale2) { - - char * cp, * cq; - - if (!scale1 || !scale1[0]) return FIT_NONE; - if (!scale2 || !scale2[0]) return FIT_NONE; - - for (int i=0; i<scaleCompatible_da.cnt; i++) { - scaleComp_p s; - s = &scaleComp(i); - if (s->type != type) continue; - BOOL_T found = FALSE; - cp = s->in_scales; - //Match input scale - while (cp) { - //Next instance of needle in haystack - cp = strstr(cp,scale2); - if (!cp) break; - //Check that this is start of csv string - if (cp == s->in_scales || cp[-1] == ',') { - //Is this end of haystack? - if (strlen(cp) == strlen(scale2)) { - found = TRUE; - break; - } - //Is it the same until the next ',' - cq=strstr(cp,","); - if (cq && (cq-cp == strlen(scale2))) { - found = TRUE; - break; - } - else cp=cq; - } else cp=strstr(cp,","); - } - if (!found) continue; - found = FALSE; - cp = s->match_scales; - //Match output scale - while (cp) { - //Next instance of needle in haystack - cp = strstr(cp,scale1); - if (!cp) break; - //Check that this is start of csv string - if (cp == s->match_scales || cp[-1] == ',') { - //Is this end of haystack? - if (strlen(cp) == strlen(scale1)) { - found = TRUE; - break; - } - //Is it the same until the next ',' - cq=strstr(cp,","); - if (cq && (cq-cp == strlen(scale1))) { - found = TRUE; - break; - } - else cp=cq; - } else cp=strstr(cp,","); - } - if (!found) continue; - return s->result; - } - return FIT_NONE; -} - -EXPORT void ScaleLengthIncrement( - SCALEINX_T scale, - DIST_T length ) -{ - char * cp; - size_t len; - if (scaleInfo(scale).length == 0.0) { - if (units == UNITS_METRIC) - cp = "999.99m SCALE Flex Track"; - else - cp = "999' 11\" SCALE Flex Track"; - len = strlen( cp )+1; - if (len > enumerateMaxDescLen) - enumerateMaxDescLen = (int)len; - } - scaleInfo(scale).length += length; -} - -EXPORT void ScaleLengthEnd( void ) -{ - wIndex_t si; - size_t count; - DIST_T length; - char tmp[STR_SIZE]; - FLOAT_T flexLen; - long flexUnit; - FLOAT_T flexCost; - for (si=0; si<scaleInfo_da.cnt; si++) { - sprintf( tmp, "price list %s", scaleInfo(si).scale ); - wPrefGetFloat( tmp, "flex length", &flexLen, 0.0 ); - wPrefGetInteger( tmp, "flex unit", &flexUnit, 0 ); - wPrefGetFloat( tmp, "flex cost", &flexCost, 0.0 ); - tmp[0] = '\0'; - if ((length=scaleInfo(si).length) != 0) { - sprintf( tmp, "%s %s Flex Track", FormatDistance(length), scaleInfo(si).scale ); - for (count = strlen(tmp); count<enumerateMaxDescLen; count++) - tmp[count] = ' '; - tmp[enumerateMaxDescLen] = '\0'; - count = 0; - if (flexLen > 0.0) { - count = (int)ceil( length / (flexLen/(flexUnit?2.54:1.00))); - } - EnumerateList( (long)count, flexCost, tmp, NULL ); - } - scaleInfo(si).length = 0; - } -} - - - -EXPORT void LoadScaleList( wList_p scaleList ) -{ - wIndex_t inx; - for (inx=0; inx<scaleDesc_da.cnt-(extraButtons?0:1); inx++) { - scaleDesc(inx).index = - wListAddValue( scaleList, scaleDesc(inx).scaleDesc, NULL, I2VP(inx) ); - } -} - -EXPORT void LoadGaugeList( wList_p gaugeList, SCALEDESCINX_T scale ) -{ - wIndex_t inx; - scaleDesc_t s; - gaugeInfo_p g; - dynArr_t *gauges_da_p; - - s = scaleDesc(scale); - gauges_da_p = &(s.gauges_da); - g = gauges_da_p->ptr; - g = s.gauges_da.ptr; - - wListClear( gaugeList ); /* remove old list in case */ - for (inx=0; inx<gauges_da_p->cnt; inx++) { - (g[inx]).index = wListAddValue( gaugeList, (g[inx]).gauge, NULL, I2VP(g[inx].scale) ); - } -} - -static void ScaleChange( long changes ) -{ - if (changes & CHANGE_SCALE) { - SetScale( GetLayoutCurScale() ); - } -} - -/***************************************************************************** - * - * - * - */ - -EXPORT void Misc2Init( void ) -{ - AddParam( "SCALE ", AddScale ); - AddParam( "SCALEFIT", AddScaleFit); - wPrefGetInteger( "draw", "label-when", &labelWhen, labelWhen ); - RegisterChangeNotification( ScaleChange ); - wPrefGetInteger( "misc", "include same gauge turnouts", &includeSameGaugeTurnouts, 1 ); -} diff --git a/app/bin/misc2.h b/app/bin/misc2.h deleted file mode 100644 index 8020696..0000000 --- a/app/bin/misc2.h +++ /dev/null @@ -1,124 +0,0 @@ -/** \file misc2.h - * - */ - -/* XTrkCad - Model Railroad CAD - * Copyright (C) 2005 Dave Bullis - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef MISC2_H -#define MISC2_H - -#include "common.h" -#include "misc.h" - -#define LABEL_MANUF (1<<0) -#define LABEL_PARTNO (1<<1) -#define LABEL_DESCR (1<<2) -#define LABEL_COST (1<<7) -#define LABEL_FLIPPED (1<<8) -#define LABEL_TABBED (1<<9) -#define LABEL_UNGROUPED (1<<10) -#define LABEL_SPLIT (1<<11) - -typedef struct { - char * name; - int level; - } logTable_t; -extern dynArr_t logTable_da; -#define logTable(N) DYNARR_N( logTable_t, logTable_da, N ) -extern time_t logClock; -void LogOpen( char * ); -void LogClose( void ); -void LogSet( char *, int ); -int LogFindIndex( const char * ); -void LogPrintf( const char *, ... ); -#define LOG( DBINX, DBLVL, DBMSG ) \ - if ( DBINX > 0 && logTable( DBINX ).level >= DBLVL ) { \ - LogPrintf DBMSG ; \ - } -#define LOG1( DBINX, DBMSG ) LOG( DBINX, 1, DBMSG ) -#define LOGNAME( DBNAME, DBMSG ) LOG( LogFindIndex( DBNAME ), DBMSG ) - -#define lprintf LogPrintf -void Rdump( FILE * ); -void Rprintf( char *, ... ); - -typedef struct { - DIST_T length; - DIST_T width; - DIST_T spacing; - } tieData_t, *tieData_p; - -DIST_T GetScaleTrackGauge( SCALEINX_T ); -DIST_T GetScaleRatio( SCALEINX_T ); -DIST_T GetScaleDescRatio( SCALEDESCINX_T sdi ); -char * GetScaleName( SCALEINX_T ); -SCALEINX_T GetScaleInx( SCALEDESCINX_T scaleInx, GAUGEINX_T gaugeInx ); - -char *GetScaleDesc( SCALEDESCINX_T inx ); -char *GetGaugeDesc( SCALEDESCINX_T scaleInx, GAUGEINX_T gaugeInx ); -void GetScaleEasementValues( DIST_T *, DIST_T * ); -tieData_p GetScaleTieData( SCALEINX_T ); -SCALEINX_T LookupScale( const char * ); -BOOL_T GetScaleGauge( SCALEINX_T scaleInx, SCALEDESCINX_T *scaleDescInx, GAUGEINX_T *gaugeInx); -void SetScaleGauge(SCALEDESCINX_T desc, GAUGEINX_T gauge); -BOOL_T DoSetScale( char * ); - -void ScaleLengthIncrement( SCALEINX_T, DIST_T ); -void LoadScaleList( wList_p ); -void LoadGaugeList( wList_p, SCALEDESCINX_T ); - -typedef enum {FIT_STRUCTURE, FIT_TURNOUT, FIT_CAR} SCALE_FIT_TYPE_T; -typedef enum {FIT_NONE, FIT_COMPATIBLE, FIT_EXACT} SCALE_FIT_T; -SCALE_FIT_T CompatibleScale( SCALE_FIT_TYPE_T, SCALEINX_T, SCALEINX_T ); - -SCALE_FIT_T FindScaleCompatible(SCALE_FIT_TYPE_T type, char * scale1, char * scale2); - -BOOL_T DoSetScaleDesc( void ); - -extern unsigned int curLayer; -extern long layerCount; -void SetCurrLayer(wIndex_t inx, const char * name, wIndex_t op, - void * listContext, void * arg); -wDrawColor GetLayerColor( unsigned int ); -BOOL_T GetLayerUseColor( unsigned int); -BOOL_T GetLayerVisible( unsigned int ); -void FlipLayer( void * layerVP ); -BOOL_T GetLayerFrozen( unsigned int ); -BOOL_T GetLayerOnMap( unsigned int ); -BOOL_T GetLayerModule( unsigned int ); -BOOL_T GetLayerHidden( unsigned int); -void SetLayerModule(unsigned int, BOOL_T); -char * GetLayerName( unsigned int ); -void SetLayerName(unsigned int layer, char* name); -BOOL_T ReadLayers( char * ); -BOOL_T WriteLayers( FILE * ); -char * FormatLayerName(unsigned int layerNumber); -/* dlayers.c */ -void UpdateLayerLists( void ); -void DefaultLayerProperties(void); -void UpdateLayerDlg( unsigned int ); -void ResetLayers( void ); -void SaveLayers( void ); -void RestoreLayers( void ); -void LoadLayerLists( void ); -addButtonCallBack_t InitLayersDialog( void ); -void FillLayerList(wList_p layerList); -void Misc2Init( void ); - -#endif diff --git a/app/bin/note.h b/app/bin/note.h index 2d70176..4e744b2 100644 --- a/app/bin/note.h +++ b/app/bin/note.h @@ -2,23 +2,23 @@ * Common definitions for notes */ - /* XTrkCad - Model Railroad CAD - * Copyright (C) 2018 Martin Fischer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ +/* XTrkCad - Model Railroad CAD + * Copyright (C) 2018 Martin Fischer + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ #ifndef HAVE_NOTE_H #define HAVE_NOTE_H @@ -42,7 +42,6 @@ enum noteCommands { typedef struct extraDataNote_t { extraDataBase_t base; coOrd pos; /**< position */ - unsigned int layer; enum noteCommands op; /**< note type */ track_p trk; /**< track */ union { @@ -59,53 +58,26 @@ typedef struct extraDataNote_t { } noteData; } extraDataNote_t; -//struct noteTextData { -// coOrd pos; -// unsigned int layer; -// char *text; -// track_p trk; -//}; - -struct noteLinkData { - coOrd pos; - unsigned int layer; - char title[TITLEMAXIMUMLENGTH]; - char url[URLMAXIMUMLENGTH]; - track_p trk; -}; - -struct noteFileData { - coOrd pos; - unsigned int layer; - char title[TITLEMAXIMUMLENGTH]; - char path[PATHMAXIMUMLENGTH]; - track_p trk; - BOOL_T inArchive; -}; - -enum { OR_NOTE, LY_NOTE, TX_TEXT, OK_TEXT, TITLE_LINK, TX_LINK, OK_LINK, TITLE_FILE, OK_FILE, CANCEL_NOTE }; /* linknoteui.c */ -void NewLinkNoteUI(track_p trk); +void NewLinkNoteUI( coOrd ); BOOL_T IsLinkNote(track_p trk); void DescribeLinkNote(track_p trk, char * str, CSIZE_T len); void ActivateLinkNote(track_p trk); /* filenozeui.c */ -void NewFileNoteUI(track_p trk); +void NewFileNoteUI( coOrd ); BOOL_T IsFileNote(track_p trk); void DescribeFileNote(track_p trk, char * str, CSIZE_T len); void ActivateFileNote(track_p trk); /* textnoteui.c */ -void NewTextNoteUI(track_p trk); +void NewTextNoteUI( coOrd ); void DescribeTextNote(track_p trk, char * str, CSIZE_T len); /* trknote.c */ extern TRKTYP_T T_NOTE; -void NoteStateSave(track_p trk); +//void NoteStateSave(track_p trk); +track_p NewNote(wIndex_t index, coOrd p, enum noteCommands command ); -void UpdateFile(struct extraDataNote_t *noteUIData, int inx, BOOL_T needUndoStart); -void UpdateText(struct extraDataNote_t *noteUIData, int inx, BOOL_T needUndoStart); -void UpdateLink(struct extraDataNote_t *noteUIData, int inx, BOOL_T needUndoStart); #endif // !HAVE_NOTE_H diff --git a/app/bin/param.c b/app/bin/param.c index 67ff7ac..b6ad8c3 100644 --- a/app/bin/param.c +++ b/app/bin/param.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "common.h" @@ -29,8 +29,6 @@ #include "track.h" #include "common-ui.h" -EXPORT int paramHiliteFast = FALSE; - /* Bogus reg vars */ EXPORT int paramLevel = 1; EXPORT int paramLen; @@ -39,6 +37,7 @@ EXPORT char paramId[100]; EXPORT BOOL_T paramTogglePlaybackHilite; EXPORT char *PREFSECT = "DialogItem"; +EXPORT long angleSystem = 0; static int paramCheckErrorCount = 0; static BOOL_T paramCheckShowErrors = FALSE; @@ -46,6 +45,18 @@ static BOOL_T paramCheckShowErrors = FALSE; static int log_paramLayout = 0; static int log_paraminput = 0; +EXPORT wWinPix_t DlgSepLeft = 12; +EXPORT wWinPix_t DlgSepRight = 12; +EXPORT wWinPix_t DlgSepTop = 12; +EXPORT wWinPix_t DlgSepBottom = 12; +static wWinPix_t DlgSepMid = 18; +static wWinPix_t DlgSepNarrow = 6; +static wWinPix_t DlgSepWide = 12; +static wWinPix_t DlgSepFrmLeft = 4; +static wWinPix_t DlgSepFrmRight = 4; +static wWinPix_t DlgSepFrmTop = 4; +static wWinPix_t DlgSepFrmBottom = 4; + /***************************************************************************** * @@ -65,7 +76,7 @@ static int GetDigitStr( char ** cpp, long * numP, int * lenP ) getNumberError = N_("Unexpected End Of String"); return FALSE; } - while ( isspace((unsigned char)*cp) ) cp++; + while ( isspace((unsigned char)*cp) ) { cp++; } *numP = strtol( cp, &cq, 10 ); if ( cp==cq ) { *cpp = cp; @@ -73,13 +84,14 @@ static int GetDigitStr( char ** cpp, long * numP, int * lenP ) return FALSE; } len = cq-cp; - if ( lenP ) + if ( lenP ) { *lenP = (int)len; + } if ( len > 9 ) { getNumberError = N_("Overflow"); return FALSE; } - while ( isspace((unsigned char)*cq) ) cq++; + while ( isspace((unsigned char)*cq) ) { cq++; } *cpp = cq; return TRUE; } @@ -91,14 +103,15 @@ static int GetNumberStr( char ** cpp, FLOAT_T * numP, BOOL_T * hasFract ) char * cp = NULL; struct lconv *lc; - while ( isspace((unsigned char)**cpp) ) (*cpp)++; + while ( isspace((unsigned char)**cpp) ) { (*cpp)++; } /* Find out the decimal separator of the current locale */ lc = localeconv(); if ( **cpp != lc->decimal_point[0] - && !GetDigitStr( cpp, &n0, NULL ) ) + && !GetDigitStr( cpp, &n0, NULL ) ) { return FALSE; + } if ( **cpp == lc->decimal_point[0] ) { (*cpp)++; if ( !isdigit((unsigned char)**cpp) ) { @@ -106,22 +119,22 @@ static int GetNumberStr( char ** cpp, FLOAT_T * numP, BOOL_T * hasFract ) *numP = (FLOAT_T)n0; return TRUE; } - if ( !GetDigitStr( cpp, &f1, &l1 ) ) return FALSE; - for ( f2=1; l1>0; l1-- ) f2 *= 10; + if ( !GetDigitStr( cpp, &f1, &l1 ) ) { return FALSE; } + for ( f2=1; l1>0; l1-- ) { f2 *= 10; } *numP = ((FLOAT_T)n0)+((FLOAT_T)f1)/((FLOAT_T)f2); *hasFract = TRUE; return TRUE; /* 999.999 */ } if ( isdigit( (unsigned char)**cpp ) ) { cp = *cpp; - if ( !GetDigitStr( cpp, &f1, NULL ) ) return FALSE; + if ( !GetDigitStr( cpp, &f1, NULL ) ) { return FALSE; } } else { f1 = n0; n0 = 0; } if ( **cpp == '/' ) { (*cpp)++; - if ( !GetDigitStr( cpp, &f2, &l1 ) ) return FALSE; + if ( !GetDigitStr( cpp, &f2, &l1 ) ) { return FALSE; } if ( f2 == 0 ) { (*cpp) -= l1; getNumberError = N_("Divide by 0"); @@ -141,133 +154,134 @@ static int GetNumberStr( char ** cpp, FLOAT_T * numP, BOOL_T * hasFract ) } return TRUE; } -//extern wIndex_t distanceFormatInx; // distanceFormatInx static BOOL_T GetDistance(char ** cpp, FLOAT_T * distP) { - FLOAT_T n1, n2; - BOOL_T neg = FALSE; - BOOL_T hasFract; - BOOL_T expectInch = FALSE; - long distanceFormat; - - while (isspace((unsigned char)**cpp)) { - (*cpp)++; - } - - if ((*cpp)[0] == '\0') { - *distP = 0.0; - return TRUE; - } - - if ((*cpp)[0] == '-') { - neg = TRUE; - (*cpp)++; - } - - if (!GetNumberStr(cpp, &n1, &hasFract)) { - return FALSE; - } - - distanceFormat = GetDistanceFormat(); - - if ((*cpp)[0] == '\0') { /* EOL */ - if (units==UNITS_METRIC) { - n1 = n1/2.54; - - if ((distanceFormat & DISTFMT_FMT) == DISTFMT_FMT_MM) { - n1 /= 10; - } - - if ((distanceFormat & DISTFMT_FMT) == DISTFMT_FMT_M) { - n1 *= 100; - } - } - - if (neg) { - n1 = -n1; - } - - *distP = n1; - return TRUE; - } - - if ((*cpp)[0] == '\'') { - n1 *= 12.0; - (*cpp) += 1; - expectInch = !hasFract; - } else if (tolower((unsigned char)(*cpp)[0]) == 'f' && - tolower((unsigned char)(*cpp)[1]) == 't') { - n1 *= 12.0; - (*cpp) += 2; - expectInch = !hasFract; - } else if (tolower((unsigned char)(*cpp)[0]) == 'c' && - tolower((unsigned char)(*cpp)[1]) == 'm') { - n1 /= 2.54; - (*cpp) += 2; - } else if (tolower((unsigned char)(*cpp)[0]) == 'm' && - tolower((unsigned char)(*cpp)[1]) == 'm') { - n1 /= 25.4; - (*cpp) += 2; - } else if (tolower((unsigned char)(*cpp)[0]) == 'm') { - n1 *= 100.0/2.54; - (*cpp) += 1; - } else if ((*cpp)[0] == '"') { - (*cpp) += 1; - } else if (tolower((unsigned char)(*cpp)[0]) == 'i' && - tolower((unsigned char)(*cpp)[1]) == 'n') { - (*cpp) += 2; - } else { - getNumberError = N_("Invalid Units Indicator"); - return FALSE; - } - - while (isspace((unsigned char)**cpp)) { - (*cpp)++; - } - - if (expectInch && isdigit((unsigned char)**cpp)) { - if (!GetNumberStr(cpp, &n2, &hasFract)) { - return FALSE; - } - - n1 += n2; - - if ((*cpp)[0] == '"') { - (*cpp) += 1; - } else if (tolower((unsigned char)(*cpp)[0]) == 'i' && - tolower((unsigned char)(*cpp)[1]) == 'n') { - (*cpp) += 2; - } - - while (isspace((unsigned char)**cpp)) { - (*cpp)++; - } - } - - if (**cpp) { - getNumberError = N_("Expected End Of String"); - return FALSE; - } - - if (neg) { - n1 = -n1; - } - - *distP = n1; - return TRUE; + FLOAT_T n1, n2; + BOOL_T neg = FALSE; + BOOL_T hasFract; + BOOL_T expectInch = FALSE; + long distanceFormat; + + while (isspace((unsigned char)**cpp)) { + (*cpp)++; + } + + if ((*cpp)[0] == '\0') { + *distP = 0.0; + return TRUE; + } + + if ((*cpp)[0] == '-') { + neg = TRUE; + (*cpp)++; + } + + if (!GetNumberStr(cpp, &n1, &hasFract)) { + return FALSE; + } + + distanceFormat = GetDistanceFormat(); + + if ((*cpp)[0] == '\0') { /* EOL */ + if (units==UNITS_METRIC) { + n1 = n1/2.54; + + if ((distanceFormat & DISTFMT_FMT) == DISTFMT_FMT_MM) { + n1 /= 10; + } + + if ((distanceFormat & DISTFMT_FMT) == DISTFMT_FMT_M) { + n1 *= 100; + } + } + + if (neg) { + n1 = -n1; + } + + *distP = n1; + return TRUE; + } + + if ((*cpp)[0] == '\'') { + n1 *= 12.0; + (*cpp) += 1; + expectInch = !hasFract; + } else if (tolower((unsigned char)(*cpp)[0]) == 'f' && + tolower((unsigned char)(*cpp)[1]) == 't') { + n1 *= 12.0; + (*cpp) += 2; + expectInch = !hasFract; + } else if (tolower((unsigned char)(*cpp)[0]) == 'c' && + tolower((unsigned char)(*cpp)[1]) == 'm') { + n1 /= 2.54; + (*cpp) += 2; + } else if (tolower((unsigned char)(*cpp)[0]) == 'm' && + tolower((unsigned char)(*cpp)[1]) == 'm') { + n1 /= 25.4; + (*cpp) += 2; + } else if (tolower((unsigned char)(*cpp)[0]) == 'm') { + n1 *= 100.0/2.54; + (*cpp) += 1; + } else if ((*cpp)[0] == '"') { + (*cpp) += 1; + } else if (tolower((unsigned char)(*cpp)[0]) == 'i' && + tolower((unsigned char)(*cpp)[1]) == 'n') { + (*cpp) += 2; + } else { + getNumberError = N_("Invalid Units Indicator"); + return FALSE; + } + + while (isspace((unsigned char)**cpp)) { + (*cpp)++; + } + + if (expectInch && isdigit((unsigned char)**cpp)) { + if (!GetNumberStr(cpp, &n2, &hasFract)) { + return FALSE; + } + + n1 += n2; + + if ((*cpp)[0] == '"') { + (*cpp) += 1; + } else if (tolower((unsigned char)(*cpp)[0]) == 'i' && + tolower((unsigned char)(*cpp)[1]) == 'n') { + (*cpp) += 2; + } + + while (isspace((unsigned char)**cpp)) { + (*cpp)++; + } + } + + if (**cpp) { + getNumberError = N_("Expected End Of String"); + return FALSE; + } + + if (neg) { + n1 = -n1; + } + + *distP = n1; + return TRUE; } EXPORT FLOAT_T DecodeFloat( - wString_p strCtrl, - BOOL_T * validP ) + wString_p strCtrl, + BOOL_T * validP ) { FLOAT_T valF; - const char *cp0, *cp1; - char *cp2; - cp0 = cp1 = wStringGetValue( strCtrl ); - while (isspace((unsigned char)*cp1)) cp1++; + const char *cp1; +// const char *cp0; + char *cp2; +// cp0 = cp1 = wStringGetValue( strCtrl ); + cp1 = wStringGetValue( strCtrl ); + while (isspace((unsigned char)*cp1)) { cp1++; } if ( *cp1 ) { valF = strtod( cp1, &cp2 ); if ( *cp2 != 0 ) { @@ -286,57 +300,57 @@ EXPORT FLOAT_T DecodeFloat( FLOAT_T DecodeDistance( - wString_p strCtrl, - BOOL_T * validP) + wString_p strCtrl, + BOOL_T * validP) { - FLOAT_T valF; - char *cp0, *cp1, *cpN, c1; - // CAST_AWAY_CONST: we temporarily replace *cpN with a NULL and later restore - cp0 = cp1 = cpN = CAST_AWAY_CONST wStringGetValue(strCtrl); - cpN += strlen(cpN)-1; - - while (cpN > cp1 && isspace((unsigned char)*cpN)) { - cpN--; - } - - c1 = *cpN; - - switch (c1) { - case '=': - case 's': - case 'S': - case 'p': - case 'P': - *cpN = '\0'; - break; - - default: - cpN = NULL; - } - - *validP = (GetDistance(&cp1, &valF)); - - if (cpN) { - *cpN = c1; - } - - if (*validP) { - if (c1 == 's' || c1 == 'S') { - valF *= curScaleRatio; - } else if (c1 == 'p' || c1 == 'P') { - valF /= curScaleRatio; - } - - if (cpN) { - wStringSetValue(strCtrl, FormatDistance(valF)); - } - } else { - snprintf(decodeErrorStr, sizeof(decodeErrorStr), "%s @ %s", _(getNumberError), - *cp1?cp1:_("End Of String")); - valF = 0.0; - } - - return valF; + FLOAT_T valF; + char *cp1, *cpN, c1; + // CAST_AWAY_CONST: we temporarily replace *cpN with a NULL and later restore + cp1 = cpN = CAST_AWAY_CONST wStringGetValue(strCtrl); + cpN += strlen(cpN)-1; + + while (cpN > cp1 && isspace((unsigned char)*cpN)) { + cpN--; + } + + c1 = *cpN; + + switch (c1) { + case '=': + case 's': + case 'S': + case 'p': + case 'P': + *cpN = '\0'; + break; + + default: + cpN = NULL; + } + + *validP = (GetDistance(&cp1, &valF)); + + if (cpN) { + *cpN = c1; + } + + if (*validP) { + if (c1 == 's' || c1 == 'S') { + valF *= curScaleRatio; + } else if (c1 == 'p' || c1 == 'P') { + valF /= curScaleRatio; + } + + if (cpN) { + wStringSetValue(strCtrl, FormatDistance(valF)); + } + } else { + snprintf(decodeErrorStr, sizeof(decodeErrorStr), "%s @ %s", _(getNumberError), + *cp1?cp1:_("End Of String")); + valF = 0.0; + } + + return valF; } @@ -346,32 +360,34 @@ static char formatStrings[N_STRING+1][80]; //Add safety EXPORT char * FormatLong( - long valL ) + long valL ) { - if ( ++formatStringInx >= N_STRING ) + if ( ++formatStringInx >= N_STRING ) { formatStringInx = 0; + } sprintf( formatStrings[formatStringInx], "%ld", valL ); return formatStrings[formatStringInx]; } EXPORT char * FormatFloat( - FLOAT_T valF ) + FLOAT_T valF ) { - if ( ++formatStringInx >= N_STRING ) + if ( ++formatStringInx >= N_STRING ) { formatStringInx = 0; + } sprintf( formatStrings[formatStringInx], "%0.3f", valF ); return formatStrings[formatStringInx]; } static void FormatFraction( - char ** cpp, - BOOL_T printZero, - int digits, - BOOL_T rational, - FLOAT_T valF, - char * unitFmt ) + char ** cpp, + BOOL_T printZero, + int digits, + BOOL_T rational, + FLOAT_T valF, + char * unitFmt ) { char * cp = *cpp; long integ; @@ -414,16 +430,17 @@ static void FormatFraction( EXPORT char * FormatDistanceEx( - FLOAT_T valF, - long distanceFormat ) + FLOAT_T valF, + long distanceFormat ) { char * cp; int digits; long feet; char * metricInd; - if ( ++formatStringInx >= N_STRING ) + if ( ++formatStringInx >= N_STRING ) { formatStringInx = 0; + } cp = formatStrings[formatStringInx]; digits = (int)(distanceFormat&DISTFMT_DECS); valF = PutDim(valF); @@ -432,18 +449,21 @@ EXPORT char * FormatDistanceEx( valF = -valF; } if ( (distanceFormat&DISTFMT_FMT) == DISTFMT_FMT_NONE ) { - FormatFraction( &cp, FALSE, digits, (distanceFormat&DISTFMT_FRACT) == DISTFMT_FRACT_FRC, valF, "" ); + FormatFraction( &cp, FALSE, digits, + (distanceFormat&DISTFMT_FRACT) == DISTFMT_FRACT_FRC, valF, "" ); return formatStrings[formatStringInx]; } else if ( units == UNITS_ENGLISH ) { feet = (long)(floor)(valF/12.0); valF -= feet*12.0; if ( feet != 0 ) { - sprintf( cp, "%ld%s", feet, (distanceFormat&DISTFMT_FMT)==DISTFMT_FMT_SHRT?"' ":"ft " ); + sprintf( cp, "%ld%s", feet, + (distanceFormat&DISTFMT_FMT)==DISTFMT_FMT_SHRT?"' ":"ft " ); cp += strlen(cp); } if ( feet==0 || valF != 0 ) { - FormatFraction( &cp, feet==0, digits, (distanceFormat&DISTFMT_FRACT) == DISTFMT_FRACT_FRC, valF, - (distanceFormat&DISTFMT_FMT)==DISTFMT_FMT_SHRT?"\"":"in" ); + FormatFraction( &cp, feet==0, digits, + (distanceFormat&DISTFMT_FRACT) == DISTFMT_FRACT_FRC, valF, + (distanceFormat&DISTFMT_FMT)==DISTFMT_FMT_SHRT?"\"":"in" ); } } else { if ( (distanceFormat&DISTFMT_FMT)==DISTFMT_FMT_M ) { @@ -455,20 +475,21 @@ EXPORT char * FormatDistanceEx( } else { metricInd = "cm"; } - FormatFraction( &cp, FALSE, digits, (distanceFormat&DISTFMT_FRACT) == DISTFMT_FRACT_FRC, valF, metricInd ); + FormatFraction( &cp, FALSE, digits, + (distanceFormat&DISTFMT_FRACT) == DISTFMT_FRACT_FRC, valF, metricInd ); } return formatStrings[formatStringInx]; } EXPORT char * FormatDistance( - FLOAT_T valF ) + FLOAT_T valF ) { return FormatDistanceEx( valF, GetDistanceFormat() ); } EXPORT char * FormatSmallDistance( - FLOAT_T valF ) + FLOAT_T valF ) { long format = GetDistanceFormat(); format &= ~(DISTFMT_FRACT_FRC|DISTFMT_DECS); @@ -486,122 +507,131 @@ static wBool_t ParamIntegerRangeCheck( paramData_p p, long valL ); static wBool_t ParamFloatRangeCheck( paramData_p p, FLOAT_T valF ); EXPORT void ParamControlActive( - paramGroup_p pg, - int inx, - BOOL_T active ) + paramGroup_p pg, + int inx, + BOOL_T active ) { paramData_p p = &pg->paramPtr[inx]; - if ( p->control ) + if ( p->control ) { wControlActive( p->control, active ); + } } EXPORT void ParamLoadMessage( - paramGroup_p pg, - int inx, - char * message ) + paramGroup_p pg, + int inx, + char * message ) { paramData_p p = &pg->paramPtr[inx]; if ( p->control ) { - if ( p->type == PD_MESSAGE ) + if ( p->type == PD_MESSAGE ) { wMessageSetValue( (wMessage_p)p->control, message ); - else if ( p->type == PD_STRING ) + } else if ( p->type == PD_STRING ) { wStringSetValue( (wString_p)p->control, message ); - else - AbortProg( "paramLoadMessage: not a PD_MESSAGE or PD_STRING" ); + } else { + CHECKMSG( FALSE, ("p->tytpe %d", (int)p->type) ); + } } } EXPORT void ParamLoadControl( - paramGroup_p pg, - int inx ) + paramGroup_p pg, + int inx ) { paramData_p p = &pg->paramPtr[inx]; FLOAT_T tmpR; char * valS; - if ( (p->option&PDO_DLGIGNORE) != 0 ) { - p->bInvalid = FALSE; + if ( (p->option&PDO_DLGIGNORE) != 0 ) { + p->bInvalid = FALSE; + return; + } + if (p->control == NULL || p->valueP == NULL) { + return; + } + switch ( p->type ) { + case PD_LONG: + wStringSetValue( (wString_p)p->control, FormatLong( *(long*)p->valueP ) ); + if ( !ParamIntegerRangeCheck( p, *(long*)p->valueP ) ) { return; } - if (p->control == NULL || p->valueP == NULL) - return; - switch ( p->type ) { - case PD_LONG: - wStringSetValue( (wString_p)p->control, FormatLong( *(long*)p->valueP ) ); - if ( !ParamIntegerRangeCheck( p, *(long*)p->valueP ) ) - return; - p->oldD.l = *(long*)p->valueP; - break; - case PD_RADIO: - wRadioSetValue( (wChoice_p)p->control, *(long*)p->valueP ); - p->oldD.l = *(long*)p->valueP; - break; - case PD_TOGGLE: - wToggleSetValue( (wChoice_p)p->control, *(long*)p->valueP ); - p->oldD.l = *(long*)p->valueP; - break; - case PD_LIST: - case PD_DROPLIST: - case PD_COMBOLIST: - wListSetIndex( (wList_p)p->control, *(wIndex_t*)p->valueP ); - p->oldD.l = *(wIndex_t*)p->valueP; - break; - case PD_COLORLIST: - wColorSelectButtonSetColor( (wButton_p)p->control, *(wDrawColor*)p->valueP ); - p->oldD.dc = *(wDrawColor*)p->valueP; - break; - case PD_FLOAT: - tmpR = *(FLOAT_T*)p->valueP; - if (p->option&PDO_DIM) { - if (p->option&PDO_SMALLDIM) - valS = FormatSmallDistance( tmpR ); - else - valS = FormatDistance( tmpR ); + p->oldD.l = *(long*)p->valueP; + break; + case PD_RADIO: + wRadioSetValue( (wChoice_p)p->control, *(long*)p->valueP ); + p->oldD.l = *(long*)p->valueP; + break; + case PD_TOGGLE: + wToggleSetValue( (wChoice_p)p->control, *(long*)p->valueP ); + p->oldD.l = *(long*)p->valueP; + break; + case PD_LIST: + case PD_DROPLIST: + case PD_COMBOLIST: + wListSetIndex( (wList_p)p->control, *(wIndex_t*)p->valueP ); + p->oldD.l = *(wIndex_t*)p->valueP; + break; + case PD_COLORLIST: + wColorSelectButtonSetColor( (wButton_p)p->control, *(wDrawColor*)p->valueP ); + p->oldD.dc = *(wDrawColor*)p->valueP; + break; + case PD_FLOAT: + tmpR = *(FLOAT_T*)p->valueP; + if (p->option&PDO_DIM) { + if (p->option&PDO_SMALLDIM) { + valS = FormatSmallDistance( tmpR ); } else { - if (p->option&PDO_ANGLE) - tmpR = NormalizeAngle( (angleSystem==ANGLE_POLAR)?tmpR:-tmpR ); - valS = FormatFloat( tmpR ); + valS = FormatDistance( tmpR ); } - wStringSetValue( (wString_p)p->control, valS ); - if ( !ParamFloatRangeCheck( p, tmpR ) ) - break; - p->oldD.f = tmpR; - break; - case PD_STRING: - if (p->oldD.s) - MyFree( p->oldD.s ); - ASSERT( p->max_string > 0 ); - if (p->max_string) { - p->oldD.s = MyMalloc(p->max_string); - strncpy(p->oldD.s, (char*)p->valueP, p->max_string-1); - *(p->oldD.s + (uint32_t)p->max_string - 1) = '\0'; - wStringSetValue((wString_p)p->control, (char*)p->oldD.s); - } - else { - p->oldD.s = MyStrdup((char *)p->valueP); - wStringSetValue((wString_p)p->control, (char*)p->valueP); - } - if ( (p->option & PDO_NOTBLANK) && strlen( p->oldD.s ) == 0 ) { - ParamHilite( p->group->win, p->control, TRUE ); - p->bInvalid = TRUE; + } else { + if (p->option&PDO_ANGLE) { + tmpR = NormalizeAngle( (angleSystem==ANGLE_POLAR)?tmpR:-tmpR ); } + valS = FormatFloat( tmpR ); + } + wStringSetValue( (wString_p)p->control, valS ); + if ( !ParamFloatRangeCheck( p, tmpR ) ) { break; - case PD_MESSAGE: - wMessageSetValue( (wMessage_p)p->control, _((char*)p->valueP) ); - break; - case PD_TEXT: - wTextClear( (wText_p)p->control ); - wTextAppend( (wText_p)p->control, (char*)p->valueP ); - break; - case PD_BUTTON: - case PD_DRAW: - case PD_MENU: - case PD_MENUITEM: - case PD_BITMAP: - break; } + p->oldD.f = tmpR; + break; + case PD_STRING: + if (p->oldD.s) { + MyFree( p->oldD.s ); + } + CHECK( p->max_string > 0 ); + if (p->max_string) { + p->oldD.s = MyMalloc(p->max_string); + strncpy(p->oldD.s, (char*)p->valueP, p->max_string-1); + *(p->oldD.s + (uint32_t)p->max_string - 1) = '\0'; + wStringSetValue((wString_p)p->control, (char*)p->oldD.s); + } else { + p->oldD.s = MyStrdup((char *)p->valueP); + wStringSetValue((wString_p)p->control, (char*)p->valueP); + } + if ( (p->option & PDO_NOTBLANK) && strlen( p->oldD.s ) == 0 ) { + ParamHilite( p->group->win, p->control, TRUE ); + p->bInvalid = TRUE; + } else { + p->bInvalid = FALSE; + } + break; + case PD_MESSAGE: + wMessageSetValue( (wMessage_p)p->control, _((char*)p->valueP) ); + break; + case PD_TEXT: + wTextClear( (wText_p)p->control ); + wTextAppend( (wText_p)p->control, (char*)p->valueP ); + break; + case PD_BUTTON: + case PD_DRAW: + case PD_MENU: + case PD_MENUITEM: + case PD_BITMAP: + break; + } } @@ -609,17 +639,18 @@ EXPORT void ParamLoadControl( * \param IN pointer to parameter group to be loaded */ EXPORT void ParamLoadControls( - paramGroup_p pg ) + paramGroup_p pg ) { int inx; LOG( log_paraminput, 1, ( "ParamLoadControls( %s )\n", pg->nameStr ) ); - for ( inx=0; inx<pg->paramCnt; inx++ ) + for ( inx=0; inx<pg->paramCnt; inx++ ) { ParamLoadControl( pg, inx ); + } } EXPORT long ParamUpdate( - paramGroup_p pg ) + paramGroup_p pg ) { long longV; FLOAT_T floatV; @@ -631,24 +662,30 @@ EXPORT long ParamUpdate( BOOL_T valid; for ( p=pg->paramPtr,inx=0; p<&pg->paramPtr[pg->paramCnt]; p++,inx++ ) { - if ( (p->option&PDO_DLGIGNORE) != 0 ) + if ( (p->option&PDO_DLGIGNORE) != 0 ) { continue; - if ( p->control == NULL ) + } + if ( p->control == NULL ) { continue; - if ( p->bInvalid == TRUE ) + } + if ( p->bInvalid == TRUE ) { break; + } switch ( p->type ) { case PD_LONG: stringV = wStringGetValue( (wString_p)p->control ); longV = atol( stringV ); - if ( ! ParamIntegerRangeCheck( p, longV ) ) + if ( ! ParamIntegerRangeCheck( p, longV ) ) { break; + } if (longV != p->oldD.l) { p->oldD.l = longV; - if ( p->valueP) + if ( p->valueP) { *(long*)p->valueP = longV; - if ( (p->option&PDO_NOUPDACT)==0 && pg->changeProc) - pg->changeProc( pg, inx, &longV ); + } + if ( (p->option&PDO_NOUPDACT)==0 && pg->changeProc) { + pg->changeProc( pg, inx, &longV ); + } change |= (1L<<inx); } break; @@ -656,10 +693,12 @@ EXPORT long ParamUpdate( longV = wRadioGetValue( (wChoice_p)p->control ); if (longV != p->oldD.l) { p->oldD.l = longV; - if ( p->valueP) + if ( p->valueP) { *(long*)p->valueP = longV; - if ( (p->option&PDO_NOUPDACT)==0 && pg->changeProc) - pg->changeProc( pg, inx, &longV ); + } + if ( (p->option&PDO_NOUPDACT)==0 && pg->changeProc) { + pg->changeProc( pg, inx, &longV ); + } change |= (1L<<inx); } break; @@ -667,10 +706,12 @@ EXPORT long ParamUpdate( longV = wToggleGetValue( (wChoice_p)p->control ); if (longV != p->oldD.l) { p->oldD.l = longV; - if ( p->valueP) + if ( p->valueP) { *(long*)p->valueP = longV; - if ( (p->option&PDO_NOUPDACT)==0 && pg->changeProc) - pg->changeProc( pg, inx, &longV ); + } + if ( (p->option&PDO_NOUPDACT)==0 && pg->changeProc) { + pg->changeProc( pg, inx, &longV ); + } change |= (1L<<inx); } break; @@ -680,10 +721,12 @@ EXPORT long ParamUpdate( longV = wListGetIndex( (wList_p)p->control ); if (longV != p->oldD.l) { p->oldD.l = longV; - if ( p->valueP) + if ( p->valueP) { *(wIndex_t*)p->valueP = (wIndex_t)longV; - if ( (p->option&PDO_NOUPDACT)==0 && pg->changeProc) - pg->changeProc( pg, inx, &longV ); + } + if ( (p->option&PDO_NOUPDACT)==0 && pg->changeProc) { + pg->changeProc( pg, inx, &longV ); + } change |= (1L<<inx); } break; @@ -691,8 +734,9 @@ EXPORT long ParamUpdate( dc = wColorSelectButtonGetColor( (wButton_p)p->control ); if (dc != p->oldD.dc) { p->oldD.dc = dc; - if ( p->valueP) + if ( p->valueP) { *(wDrawColor*)p->valueP = dc; + } if ( (p->option&PDO_NOUPDACT)==0 && pg->changeProc) { pg->changeProc( pg, inx, &longV ); /* COLORNOP */ } @@ -704,19 +748,24 @@ EXPORT long ParamUpdate( floatV = DecodeDistance( (wString_p)p->control, &valid ); } else { floatV = DecodeFloat( (wString_p)p->control, &valid ); - if (valid && (p->option & PDO_ANGLE) ) + if (valid && (p->option & PDO_ANGLE) ) { floatV = NormalizeAngle( (angleSystem==ANGLE_POLAR)?floatV:-floatV ); + } } - if ( !valid ) + if ( !valid ) { break; - if ( ! ParamFloatRangeCheck( p, floatV ) ) + } + if ( ! ParamFloatRangeCheck( p, floatV ) ) { break; + } if (floatV != p->oldD.f) { p->oldD.f = floatV; - if ( p->valueP) + if ( p->valueP) { *(FLOAT_T*)p->valueP = floatV; - if ( (p->option&PDO_NOUPDACT)==0 && pg->changeProc) - pg->changeProc( pg, inx, &floatV ); + } + if ( (p->option&PDO_NOUPDACT)==0 && pg->changeProc) { + pg->changeProc( pg, inx, &floatV ); + } change |= (1L<<inx); } break; @@ -727,8 +776,9 @@ EXPORT long ParamUpdate( break; } if ( strcmp( stringV, p->oldD.s ) != 0 ) { - if (p->oldD.s) + if (p->oldD.s) { MyFree( p->oldD.s ); + } p->oldD.s = MyStrdup( stringV ); if ( p->valueP ) { strncpy((char*)p->valueP, stringV, p->max_string-1); @@ -740,7 +790,9 @@ EXPORT long ParamUpdate( if ( (p->option&PDO_NOUPDACT)==0 && pg->changeProc) // CAST_AWAY_CONST: param 3 should be const but its a big change - pg->changeProc( pg, inx, CAST_AWAY_CONST stringV ); + { + pg->changeProc( pg, inx, CAST_AWAY_CONST stringV ); + } change |= (1L<<inx); } break; @@ -755,113 +807,114 @@ EXPORT long ParamUpdate( } } #ifdef PGPROC - if (pg->proc) + if (pg->proc) { pg->proc( PGACT_UPDATE, change ); + } #endif return change; } void ParamLoadData( - paramGroup_p pg) + paramGroup_p pg) { - FLOAT_T floatV; - const char * stringV; - paramData_p p; - BOOL_T valid; - BOOL_T inRange; - - for (p=pg->paramPtr; p<&pg->paramPtr[pg->paramCnt]; p++) { - if ((p->option&PDO_DLGIGNORE) != 0) { - continue; - } - - if (p->control == NULL || p->valueP == NULL) { - continue; - } - - switch (p->type) { - long longV; - - case PD_LONG: - longV = atol(wStringGetValue((wString_p)p->control)); - - if (p->winData) { - inRange = (longV <= ((paramIntegerRange_t *)p->winData)->high) && - (longV >= ((paramIntegerRange_t *)p->winData)->low); - } else { - inRange = TRUE; - } - - if (inRange) { - *(long*)p->valueP = longV; - } - - break; - - case PD_RADIO: - *(long*)p->valueP = wRadioGetValue((wChoice_p)p->control); - break; - - case PD_TOGGLE: - *(long*)p->valueP = wToggleGetValue((wChoice_p)p->control); - break; - - case PD_LIST: - case PD_DROPLIST: - case PD_COMBOLIST: - *(wIndex_t*)p->valueP = wListGetIndex((wList_p)p->control); - break; - - case PD_COLORLIST: - *(wDrawColor*)p->valueP = wColorSelectButtonGetColor((wButton_p)p->control); - break; - - case PD_FLOAT: - if (p->option & PDO_DIM) { - floatV = DecodeDistance((wString_p)p->control, &valid); - } else { - floatV = DecodeFloat((wString_p)p->control, &valid); - - if (valid && (p->option & PDO_ANGLE)) { - floatV = NormalizeAngle((angleSystem==ANGLE_POLAR)?floatV:-floatV); - } - } - - if (p->winData) { - inRange = (floatV <= ((paramFloatRange_t *)p->winData)->high) && - (floatV >= ((paramFloatRange_t *)p->winData)->low); - } else { - inRange = TRUE; - } - - if (valid && inRange) { - *(FLOAT_T*)p->valueP = floatV; - } - - break; - - case PD_STRING: - stringV = wStringGetValue((wString_p)p->control); - strcpy((char*)p->valueP, stringV); - break; - - case PD_MESSAGE: - case PD_BUTTON: - case PD_DRAW: - case PD_TEXT: - case PD_MENU: - case PD_MENUITEM: - case PD_BITMAP: - break; - } - } + FLOAT_T floatV; + const char * stringV; + paramData_p p; + BOOL_T valid; + BOOL_T inRange; + + for (p=pg->paramPtr; p<&pg->paramPtr[pg->paramCnt]; p++) { + if ((p->option&PDO_DLGIGNORE) != 0) { + continue; + } + + if (p->control == NULL || p->valueP == NULL) { + continue; + } + + switch (p->type) { + long longV; + + case PD_LONG: + longV = atol(wStringGetValue((wString_p)p->control)); + + if (p->winData) { + inRange = (longV <= ((paramIntegerRange_t *)p->winData)->high) && + (longV >= ((paramIntegerRange_t *)p->winData)->low); + } else { + inRange = TRUE; + } + + if (inRange) { + *(long*)p->valueP = longV; + } + + break; + + case PD_RADIO: + *(long*)p->valueP = wRadioGetValue((wChoice_p)p->control); + break; + + case PD_TOGGLE: + *(long*)p->valueP = wToggleGetValue((wChoice_p)p->control); + break; + + case PD_LIST: + case PD_DROPLIST: + case PD_COMBOLIST: + *(wIndex_t*)p->valueP = wListGetIndex((wList_p)p->control); + break; + + case PD_COLORLIST: + *(wDrawColor*)p->valueP = wColorSelectButtonGetColor((wButton_p)p->control); + break; + + case PD_FLOAT: + if (p->option & PDO_DIM) { + floatV = DecodeDistance((wString_p)p->control, &valid); + } else { + floatV = DecodeFloat((wString_p)p->control, &valid); + + if (valid && (p->option & PDO_ANGLE)) { + floatV = NormalizeAngle((angleSystem==ANGLE_POLAR)?floatV:-floatV); + } + } + + if (p->winData) { + inRange = (floatV <= ((paramFloatRange_t *)p->winData)->high) && + (floatV >= ((paramFloatRange_t *)p->winData)->low); + } else { + inRange = TRUE; + } + + if (valid && inRange) { + *(FLOAT_T*)p->valueP = floatV; + } + + break; + + case PD_STRING: + stringV = wStringGetValue((wString_p)p->control); + strcpy((char*)p->valueP, stringV); + break; + + case PD_MESSAGE: + case PD_BUTTON: + case PD_DRAW: + case PD_TEXT: + case PD_MENU: + case PD_MENUITEM: + case PD_BITMAP: + break; + } + } } static long ParamIntRestore( - paramGroup_p pg, - int class ) + paramGroup_p pg, + int class ) { long change = 0; int inx; @@ -872,15 +925,17 @@ static long ParamIntRestore( for ( p=pg->paramPtr,inx=0; p<&pg->paramPtr[pg->paramCnt]; p++,inx++ ) { oldP = (class==0)?&p->oldD:&p->demoD; - if ( (p->option&PDO_DLGIGNORE) != 0 ) + if ( (p->option&PDO_DLGIGNORE) != 0 ) { continue; - if (p->valueP == NULL) + } + if (p->valueP == NULL) { continue; + } switch ( p->type ) { case PD_LONG: if ( *(long*)p->valueP != oldP->l ) { /*if ((p->option&PDO_NORSTUPD)==0)*/ - *(long*)p->valueP = oldP->l; + *(long*)p->valueP = oldP->l; if (p->control) { wStringSetValue( (wString_p)p->control, FormatLong( oldP->l ) ); } @@ -890,18 +945,20 @@ static long ParamIntRestore( case PD_RADIO: if ( *(long*)p->valueP != oldP->l ) { /*if ((p->option&PDO_NORSTUPD)==0)*/ - *(long*)p->valueP = oldP->l; - if (p->control) + *(long*)p->valueP = oldP->l; + if (p->control) { wRadioSetValue( (wChoice_p)p->control, oldP->l ); + } change |= (1L<<inx); } break; case PD_TOGGLE: if ( *(long*)p->valueP != oldP->l ) { /*if ((p->option&PDO_NORSTUPD)==0)*/ - *(long*)p->valueP = oldP->l; - if (p->control) + *(long*)p->valueP = oldP->l; + if (p->control) { wToggleSetValue( (wChoice_p)p->control, oldP->l ); + } change |= (1L<<inx); } break; @@ -910,35 +967,40 @@ static long ParamIntRestore( case PD_COMBOLIST: if ( *(wIndex_t*)p->valueP != (wIndex_t)oldP->l ) { /*if ((p->option&PDO_NORSTUPD)==0)*/ - *(wIndex_t*)p->valueP = (wIndex_t)oldP->l; - if (p->control) + *(wIndex_t*)p->valueP = (wIndex_t)oldP->l; + if (p->control) { wListSetIndex( (wList_p)p->control, (wIndex_t)oldP->l ); + } change |= (1L<<inx); } break; case PD_COLORLIST: if ( *(wDrawColor*)p->valueP != oldP->dc ) { /*if ((p->option&PDO_NORSTUPD)==0)*/ - *(wDrawColor*)p->valueP = oldP->dc; - if (p->control) - wColorSelectButtonSetColor( (wButton_p)p->control, oldP->dc ); /* COLORNOP */ + *(wDrawColor*)p->valueP = oldP->dc; + if (p->control) { + wColorSelectButtonSetColor( (wButton_p)p->control, + oldP->dc ); /* COLORNOP */ + } change |= (1L<<inx); } break; case PD_FLOAT: if ( *(FLOAT_T*)p->valueP != oldP->f ) { /*if ((p->option&PDO_NORSTUPD)==0)*/ - *(FLOAT_T*)p->valueP = oldP->f; + *(FLOAT_T*)p->valueP = oldP->f; if (p->control) { valR = oldP->f; if (p->option & PDO_DIM) { - if (p->option & PDO_SMALLDIM) + if (p->option & PDO_SMALLDIM) { valS = FormatSmallDistance( valR ); - else + } else { valS = FormatDistance( valR ); + } } else { - if (p->option & PDO_ANGLE) + if (p->option & PDO_ANGLE) { valR = NormalizeAngle( (angleSystem==ANGLE_POLAR)?valR:-valR ); + } valS = FormatFloat( valR ); } wStringSetValue( (wString_p)p->control, valS ); @@ -950,8 +1012,9 @@ static long ParamIntRestore( if ( oldP->s && strcmp((char*)p->valueP,oldP->s) != 0 ) { ((char*)p->valueP)[0] = '\0'; strncat((char*)p->valueP,oldP->s,p->max_string-1); - if (p->control) + if (p->control) { wStringSetValue( (wString_p)p->control, (char*)p->valueP ); + } change |= (1L<<inx); } break; @@ -966,16 +1029,17 @@ static long ParamIntRestore( } } #ifdef PGPROC - if (pg->proc) + if (pg->proc) { pg->proc( PGACT_RESTORE, change ); + } #endif return change; } static void ParamIntSave( - paramGroup_p pg, - int class ) + paramGroup_p pg, + int class ) { paramData_p p; paramOldData_t * oldP; @@ -1001,8 +1065,9 @@ static void ParamIntSave( oldP->f = *(FLOAT_T*)p->valueP; break; case PD_STRING: - if (oldP->s) + if (oldP->s) { MyFree(oldP->s); + } oldP->s = MyStrdup( (char*)p->valueP ); break; case PD_MESSAGE: @@ -1052,21 +1117,23 @@ EXPORT void ParamRegister( paramGroup_p pg ) char prefName1[STR_SHORT_SIZE]; const char *prefSect2, *prefName2; - if (!paramGroups_init) ParamInit(); + if (!paramGroups_init) { ParamInit(); } DYNARR_APPEND( paramGroup_p, paramGroups_da, 10 ); paramGroups(paramGroups_da.cnt-1) = pg; int i; for ( i=0, p=pg->paramPtr; i<(pg->paramCnt); p++, i++ ) { p->group = pg; - if ( p->nameStr == NULL ) + if ( p->nameStr == NULL ) { continue; + } snprintf( prefName1, sizeof(prefName1), "%s-%s", pg->nameStr, p->nameStr ); if ( p->type != PD_MENUITEM ) { (void)GetBalloonHelpStr( prefName1 ); } - if (p->valueP == NULL || (p->option&PDO_NOPREF) != 0) + if (p->valueP == NULL || (p->option&PDO_NOPREF) != 0) { continue; + } prefSect2 = PREFSECT; prefName2 = prefName1; if ( (p->option&PDO_MISC) ) { @@ -1103,48 +1170,58 @@ EXPORT void ParamRegister( paramGroup_p pg ) case PD_LONG: case PD_RADIO: case PD_TOGGLE: - if ( !wPrefGetInteger( PREFSECT, prefName1, p->valueP, *(long*)p->valueP )) + if ( !wPrefGetInteger( PREFSECT, prefName1, p->valueP, *(long*)p->valueP )) { wPrefGetInteger( prefSect2, prefName2, p->valueP, *(long*)p->valueP ); + } break; case PD_LIST: case PD_DROPLIST: case PD_COMBOLIST: if ( (p->option&PDO_LISTINDEX) ) { - if (!wPrefGetInteger( PREFSECT, prefName1, &valL, *(wIndex_t*)p->valueP )) + if (!wPrefGetInteger( PREFSECT, prefName1, &valL, *(wIndex_t*)p->valueP )) { wPrefGetInteger( prefSect2, prefName2, &valL, valL ); - if ( p->control ) + } + if ( p->control ) { wListSetIndex( (wList_p)p->control, (wIndex_t)valL ); + } *(wIndex_t*)p->valueP = (wIndex_t)valL; } else { - if (!p->control) + if (!p->control) { break; + } cp = wPrefGetString( PREFSECT, prefName1 ); - if ( !cp ) + if ( !cp ) { cp = wPrefGetString( prefSect2, prefName2 ); - if ( !cp ) + } + if ( !cp ) { break; + } *(wIndex_t*)p->valueP = wListFindValue( (wList_p)p->control, cp ); } break; case PD_COLORLIST: rgb = wDrawGetRGB( *(wDrawColor*)p->valueP ); - if (!wPrefGetInteger( PREFSECT, prefName1, &rgb, rgb )) + if (!wPrefGetInteger( PREFSECT, prefName1, &rgb, rgb )) { wPrefGetInteger( prefSect2, prefName2, &rgb, rgb ); + } *(wDrawColor*)p->valueP = wDrawFindColor( rgb ); break; case PD_FLOAT: - if (!wPrefGetFloat( PREFSECT, prefName1, &tmpR, *(FLOAT_T*)p->valueP )) + if (!wPrefGetFloat( PREFSECT, prefName1, &tmpR, *(FLOAT_T*)p->valueP )) { wPrefGetFloat( prefSect2, prefName2, &tmpR, *(FLOAT_T*)p->valueP ); + } *(FLOAT_T*)p->valueP = tmpR; break; case PD_STRING: cp = wPrefGetString( PREFSECT, prefName1 ); - if (!cp) + if (!cp) { wPrefGetString( prefSect2, prefName2 ); - if (cp) + } + if (cp) { strcpy( p->valueP, cp ); - else + } else { ((char*)p->valueP)[0] = '\0'; + } break; case PD_MESSAGE: case PD_BUTTON: @@ -1176,114 +1253,127 @@ EXPORT void ParamUpdatePrefs( void ) paramListData_t * listDataP; for ( inx=0; inx<paramGroups_da.cnt; inx++ ) { - pg = paramGroups(inx); - if (pg->nameStr == NULL) continue; - for ( p=pg->paramPtr; p<&pg->paramPtr[pg->paramCnt]; p++ ) { - if (p->valueP == NULL || p->nameStr == NULL || (p->option&PDO_NOPREF)!=0 ) - continue; - if ( (p->option&PDO_DLGIGNORE) != 0 ) - continue; - snprintf( prefName, sizeof(prefName), "%s-%s", pg->nameStr, p->nameStr ); - switch ( p->type ) { - case PD_LONG: - case PD_RADIO: - case PD_TOGGLE: - wPrefSetInteger( PREFSECT, prefName, *(long*)p->valueP ); - break; - case PD_LIST: - listDataP = (paramListData_t*)p->winData; - if ( p->control && listDataP->colCnt > 0 ) { - if ( maxColCnt < listDataP->colCnt ) { - if ( maxColCnt == 0 ) - colWidths = (wWinPix_t*)MyMalloc( listDataP->colCnt * sizeof * colWidths ); - else - colWidths = (wWinPix_t*)MyRealloc( colWidths, listDataP->colCnt * sizeof * colWidths ); - maxColCnt = listDataP->colCnt; - } - len = wListGetColumnWidths( (wList_p)p->control, listDataP->colCnt, colWidths ); - cp = message; - for ( col=0; col<len; col++ ) { - sprintf( cp, "%ld ", colWidths[col] ); - cp += strlen(cp); - } - *cp = '\0'; - len = strlen( prefName ); - strcpy( prefName+len, "-columnwidths" ); - wPrefSetString( PREFSECT, prefName, message ); - prefName[len] = '\0'; + pg = paramGroups(inx); + if (pg->nameStr == NULL) { continue; } + for ( p=pg->paramPtr; p<&pg->paramPtr[pg->paramCnt]; p++ ) { + if (p->valueP == NULL || p->nameStr == NULL || (p->option&PDO_NOPREF)!=0 ) { + continue; } - case PD_DROPLIST: - case PD_COMBOLIST: - if ( (p->option&PDO_LISTINDEX) ) { - wPrefSetInteger( PREFSECT, prefName, *(wIndex_t*)p->valueP ); - } else { - if (p->control) { - wListGetValues( (wList_p)p->control, message, sizeof message, NULL, NULL ); + if ( (p->option&PDO_DLGIGNORE) != 0 ) { + continue; + } + snprintf( prefName, sizeof(prefName), "%s-%s", pg->nameStr, p->nameStr ); + switch ( p->type ) { + case PD_LONG: + case PD_RADIO: + case PD_TOGGLE: + wPrefSetInteger( PREFSECT, prefName, *(long*)p->valueP ); + break; + case PD_LIST: + listDataP = (paramListData_t*)p->winData; + if ( p->control && listDataP->colCnt > 0 ) { + if ( maxColCnt < listDataP->colCnt ) { + if ( maxColCnt == 0 ) { + colWidths = (wWinPix_t*)MyMalloc( listDataP->colCnt * sizeof * colWidths ); + } else { + colWidths = (wWinPix_t*)MyRealloc( colWidths, + listDataP->colCnt * sizeof * colWidths ); + } + maxColCnt = listDataP->colCnt; + } + len = wListGetColumnWidths( (wList_p)p->control, listDataP->colCnt, colWidths ); + cp = message; + for ( col=0; col<len; col++ ) { + sprintf( cp, "%ld ", colWidths[col] ); + cp += strlen(cp); + } + *cp = '\0'; + len = strlen( prefName ); + strcpy( prefName+len, "-columnwidths" ); wPrefSetString( PREFSECT, prefName, message ); + prefName[len] = '\0'; } + case PD_DROPLIST: + case PD_COMBOLIST: + if ( (p->option&PDO_LISTINDEX) ) { + wPrefSetInteger( PREFSECT, prefName, *(wIndex_t*)p->valueP ); + } else { + if (p->control) { + wListGetValues( (wList_p)p->control, message, sizeof message, NULL, NULL ); + wPrefSetString( PREFSECT, prefName, message ); + } + } + break; + case PD_COLORLIST: + rgb = wDrawGetRGB( *(wDrawColor*)p->valueP ); + wPrefSetInteger( PREFSECT, prefName, rgb ); + break; + case PD_FLOAT: + wPrefSetFloat( PREFSECT, prefName, *(FLOAT_T*)p->valueP ); + break; + case PD_STRING: + wPrefSetString( PREFSECT, prefName, (char*)p->valueP ); + break; + case PD_MESSAGE: + case PD_BUTTON: + case PD_DRAW: + case PD_TEXT: + case PD_MENU: + case PD_MENUITEM: + case PD_BITMAP: + break; } - break; - case PD_COLORLIST: - rgb = wDrawGetRGB( *(wDrawColor*)p->valueP ); - wPrefSetInteger( PREFSECT, prefName, rgb ); - break; - case PD_FLOAT: - wPrefSetFloat( PREFSECT, prefName, *(FLOAT_T*)p->valueP ); - break; - case PD_STRING: - wPrefSetString( PREFSECT, prefName, (char*)p->valueP ); - break; - case PD_MESSAGE: - case PD_BUTTON: - case PD_DRAW: - case PD_TEXT: - case PD_MENU: - case PD_MENUITEM: - case PD_BITMAP: - break; } - } } } EXPORT void ParamGroupRecord( - paramGroup_p pg ) + paramGroup_p pg ) { paramData_p p; long rgb; - if (recordF == NULL) + if (recordF == NULL) { return; + } for ( p=pg->paramPtr; p<&pg->paramPtr[pg->paramCnt]; p++ ) { - if ( (p->option&PDO_NORECORD) != 0 || p->valueP == NULL || p->nameStr == NULL ) + if ( (p->option&PDO_NORECORD) != 0 || p->valueP == NULL + || p->nameStr == NULL ) { continue; - if ( (p->option&PDO_DLGIGNORE) != 0 ) + } + if ( (p->option&PDO_DLGIGNORE) != 0 ) { continue; + } switch ( p->type ) { case PD_LONG: case PD_RADIO: case PD_TOGGLE: - fprintf( recordF, "PARAMETER %s %s %ld\n", pg->nameStr, p->nameStr, *(long*)p->valueP ); + fprintf( recordF, "PARAMETER %s %s %ld\n", pg->nameStr, p->nameStr, + *(long*)p->valueP ); break; case PD_LIST: case PD_DROPLIST: case PD_COMBOLIST: - if (p->control) + if (p->control) { wListGetValues( (wList_p)p->control, message, sizeof message, NULL, NULL ); - else + } else { message[0] = '\0'; - fprintf( recordF, "PARAMETER %s %s %d %s\n", pg->nameStr, p->nameStr, *(wIndex_t*)p->valueP, message ); + } + fprintf( recordF, "PARAMETER %s %s %d %s\n", pg->nameStr, p->nameStr, + *(wIndex_t*)p->valueP, message ); break; case PD_COLORLIST: rgb = wDrawGetRGB( *(wDrawColor*)p->valueP ); fprintf( recordF, "PARAMETER %s %s %ld\n", - pg->nameStr, p->nameStr, rgb ); + pg->nameStr, p->nameStr, rgb ); break; case PD_FLOAT: - fprintf( recordF, "PARAMETER %s %s %0.3f\n", pg->nameStr, p->nameStr, *(FLOAT_T*)p->valueP ); + fprintf( recordF, "PARAMETER %s %s %0.3f\n", pg->nameStr, p->nameStr, + *(FLOAT_T*)p->valueP ); break; case PD_STRING: - fprintf( recordF, "PARAMETER %s %s %s\n", pg->nameStr, p->nameStr, (char*)p->valueP ); + fprintf( recordF, "PARAMETER %s %s %s\n", pg->nameStr, p->nameStr, + (char*)p->valueP ); break; case PD_MESSAGE: case PD_BUTTON: @@ -1295,8 +1385,9 @@ EXPORT void ParamGroupRecord( break; } } - if (pg->nameStr) + if (pg->nameStr) { fprintf( recordF, "PARAMETER GROUP %s\n", pg->nameStr ); + } fflush( recordF ); } @@ -1306,8 +1397,9 @@ EXPORT void ParamStartRecord( void ) int inx; paramGroup_p pg; - if (recordF == NULL) + if (recordF == NULL) { return; + } for ( inx=0; inx<paramGroups_da.cnt; inx++ ) { pg = paramGroups(inx); if (pg->options&PGO_RECORD) { @@ -1352,10 +1444,11 @@ static void ParamButtonPush( void * dp ) fflush( recordF ); } if ( (p->option&PDO_NOPSHACT)==0 ) { - if ( p->valueP ) + if ( p->valueP ) { ((wButtonCallBack_p)(p->valueP))( p->context ); - else if ( p->group->changeProc) - p->group->changeProc( p->group, (int)(p-p->group->paramPtr), NULL); + } else if ( p->group->changeProc) { + p->group->changeProc( p->group, (int)(p-p->group->paramPtr), NULL); + } } } @@ -1365,30 +1458,39 @@ static void ParamChoicePush( long valL, void * dp ) paramData_p p = (paramData_p)dp; if (recordF && (p->option&PDO_NORECORD)==0 && p->group->nameStr && p->nameStr) { - fprintf( recordF, "PARAMETER %s %s %ld\n", p->group->nameStr, p->nameStr, valL ); + fprintf( recordF, "PARAMETER %s %s %ld\n", p->group->nameStr, p->nameStr, + valL ); fflush( recordF ); } - if ( (p->option&PDO_NOPSHUPD)==0 && p->valueP) + if ( (p->option&PDO_NOPSHUPD)==0 && p->valueP) { *((long*)(p->valueP)) = valL; - if ( (p->option&PDO_NOPSHACT)==0 && p->group->changeProc) + } + if ( (p->option&PDO_NOPSHACT)==0 && p->group->changeProc) { p->group->changeProc( p->group, (int)(p-p->group->paramPtr), &valL); + } } static wBool_t ParamIntegerRangeCheck( paramData_p p, long valL ) { - if ( inPlayback ) + if ( inPlayback ) { return TRUE; + } paramIntegerRange_t * irangeP = (paramIntegerRange_t*)p->winData; - wBool_t bInvalid = p->bInvalid; - if ( ( (irangeP->rangechecks&PDO_NORANGECHECK_HIGH) == 0 && valL > irangeP->high ) || - ( (irangeP->rangechecks&PDO_NORANGECHECK_LOW) == 0 && valL < irangeP->low ) ) { - if ( (irangeP->rangechecks&(PDO_NORANGECHECK_HIGH|PDO_NORANGECHECK_LOW)) == PDO_NORANGECHECK_HIGH ) +// wBool_t bInvalid = p->bInvalid; + if ( ( (irangeP->rangechecks&PDO_NORANGECHECK_HIGH) == 0 + && valL > irangeP->high ) || + ( (irangeP->rangechecks&PDO_NORANGECHECK_LOW) == 0 && valL < irangeP->low ) ) { + if ( (irangeP->rangechecks&(PDO_NORANGECHECK_HIGH|PDO_NORANGECHECK_LOW)) == + PDO_NORANGECHECK_HIGH ) { sprintf( message, _("Enter a value > %ld"), irangeP->low ); - else if ( (irangeP->rangechecks&(PDO_NORANGECHECK_HIGH|PDO_NORANGECHECK_LOW)) == PDO_NORANGECHECK_LOW ) - sprintf( message, _("Enter a value < %ld"), irangeP->high ); - else - sprintf( message, _("Enter a value between %ld and %ld"), irangeP->low, irangeP->high ); + } else if ( (irangeP->rangechecks&(PDO_NORANGECHECK_HIGH|PDO_NORANGECHECK_LOW)) + == PDO_NORANGECHECK_LOW ) { + sprintf( message, _("Enter a value < %ld"), irangeP->high ); + } else { + sprintf( message, _("Enter a value between %ld and %ld"), irangeP->low, + irangeP->high ); + } wWinPix_t h = wControlGetHeight(p->control); wControlSetBalloon( p->control, 0, -h*3/4, message ); p->bInvalid = TRUE; @@ -1408,7 +1510,7 @@ static void ParamIntegerPush( const char * val, void * dp ) char * cp; const char * value; - wBool_t bInvalid = p->bInvalid; +// wBool_t bInvalid = p->bInvalid; if (strlen(val) == 1 && val[strlen(val)-1] == '\n') { value = wStringGetValue((wString_p)p->control); p->enter_pressed = TRUE; @@ -1416,7 +1518,8 @@ static void ParamIntegerPush( const char * val, void * dp ) value = val; p->enter_pressed = FALSE; } - LOG( log_paraminput, 1, ( "ParamIntegerPush( %s Enter:%d Val:%s )\n", p->nameStr, p->enter_pressed, value ) ); + LOG( log_paraminput, 1, ( "ParamIntegerPush( %s Enter:%d Val:%s )\n", + p->nameStr, p->enter_pressed, value ) ); valL = strtol( value, &cp, 10 ); for ( ; isspace( (unsigned char)*cp); cp++ ); @@ -1428,19 +1531,23 @@ static void ParamIntegerPush( const char * val, void * dp ) ParamHilite( p->group->win, p->control, p->bInvalid ); return; } - if ( ! ParamIntegerRangeCheck( p, valL ) ) + if ( ! ParamIntegerRangeCheck( p, valL ) ) { return; + } wControlSetBalloon( p->control, 0, 0, NULL ); p->bInvalid = FALSE; if (recordF && (p->option&PDO_NORECORD)==0 && p->group->nameStr && p->nameStr) { - fprintf( recordF, "PARAMETER %s %s %ld\n", p->group->nameStr, p->nameStr, valL ); + fprintf( recordF, "PARAMETER %s %s %ld\n", p->group->nameStr, p->nameStr, + valL ); fflush( recordF ); } - if ( (p->option&PDO_NOPSHUPD)==0 && p->valueP) + if ( (p->option&PDO_NOPSHUPD)==0 && p->valueP) { *((long*)(p->valueP)) = valL; - if ( (p->option&PDO_NOPSHACT)==0 && p->group->changeProc) + } + if ( (p->option&PDO_NOPSHACT)==0 && p->group->changeProc) { p->group->changeProc( p->group, (int)(p-p->group->paramPtr), &valL); + } ParamHilite( p->group->win, p->control, p->bInvalid ); LOG( log_paraminput, 1, ( " -> %ld\n", valL ) ); } @@ -1448,22 +1555,26 @@ static void ParamIntegerPush( const char * val, void * dp ) static wBool_t ParamFloatRangeCheck( paramData_p p, FLOAT_T valF ) { - if ( inPlayback ) + if ( inPlayback ) { return TRUE; + } paramFloatRange_t * frangeP = (paramFloatRange_t*)p->winData; - wBool_t bInvalid = p->bInvalid; - if ( ( (frangeP->rangechecks&PDO_NORANGECHECK_HIGH) == 0 && valF > frangeP->high ) || - ( (frangeP->rangechecks&PDO_NORANGECHECK_LOW) == 0 && valF < frangeP->low ) ) { - if ( (frangeP->rangechecks&(PDO_NORANGECHECK_HIGH|PDO_NORANGECHECK_LOW)) == PDO_NORANGECHECK_HIGH ) +// wBool_t bInvalid = p->bInvalid; + if ( ( (frangeP->rangechecks&PDO_NORANGECHECK_HIGH) == 0 + && valF > frangeP->high ) || + ( (frangeP->rangechecks&PDO_NORANGECHECK_LOW) == 0 && valF < frangeP->low ) ) { + if ( (frangeP->rangechecks&(PDO_NORANGECHECK_HIGH|PDO_NORANGECHECK_LOW)) == + PDO_NORANGECHECK_HIGH ) sprintf( message, _("Enter a value > %s"), - (p->option&PDO_DIM)?FormatDistance(frangeP->low):FormatFloat(frangeP->low) ); - else if ( (frangeP->rangechecks&(PDO_NORANGECHECK_HIGH|PDO_NORANGECHECK_LOW)) == PDO_NORANGECHECK_LOW ) - sprintf( message, _("Enter a value < %s"), - (p->option&PDO_DIM)?FormatDistance(frangeP->high):FormatFloat(frangeP->high) ); + (p->option&PDO_DIM)?FormatDistance(frangeP->low):FormatFloat(frangeP->low) ); + else if ( (frangeP->rangechecks&(PDO_NORANGECHECK_HIGH|PDO_NORANGECHECK_LOW)) == + PDO_NORANGECHECK_LOW ) + sprintf( message, _("Enter a value < %s"), + (p->option&PDO_DIM)?FormatDistance(frangeP->high):FormatFloat(frangeP->high) ); else - sprintf( message, _("Enter a value between %s and %s"), - (p->option&PDO_DIM)?FormatDistance(frangeP->low):FormatFloat(frangeP->low), - (p->option&PDO_DIM)?FormatDistance(frangeP->high):FormatFloat(frangeP->high) ); + sprintf( message, _("Enter a value between %s and %s"), + (p->option&PDO_DIM)?FormatDistance(frangeP->low):FormatFloat(frangeP->low), + (p->option&PDO_DIM)?FormatDistance(frangeP->high):FormatFloat(frangeP->high) ); wWinPix_t h = wControlGetHeight(p->control); wControlSetBalloon( p->control, 0, -h*3/4, message ); p->bInvalid = TRUE; @@ -1491,7 +1602,7 @@ static void ParamFloatPush( const char * val, void * dp ) BOOL_T valid; const char * value; - wBool_t bInvalid = p->bInvalid; +// wBool_t bInvalid = p->bInvalid; if (strlen(val) == 1 && val[strlen(val)-1] == '\n') { value = wStringGetValue((wString_p)p->control); p->enter_pressed = TRUE; @@ -1499,14 +1610,16 @@ static void ParamFloatPush( const char * val, void * dp ) value = val; p->enter_pressed = FALSE; } - LOG( log_paraminput, 1, ( "ParamFloatPush( %s: Enter:%d Val:%s )\n", p->nameStr, p->enter_pressed, value ) ); + LOG( log_paraminput, 1, ( "ParamFloatPush( %s: Enter:%d Val:%s )\n", p->nameStr, + p->enter_pressed, value ) ); if (p->option & PDO_DIM) { valF = DecodeDistance( (wString_p)p->control, &valid ); } else { valF = DecodeFloat( (wString_p)p->control, &valid ); - if (p->option & PDO_ANGLE) + if (p->option & PDO_ANGLE) { valF = NormalizeAngle( (angleSystem==ANGLE_POLAR)?valF:-valF ); + } } if ( !valid ) { wWinPix_t h = wControlGetHeight(p->control); @@ -1515,19 +1628,23 @@ static void ParamFloatPush( const char * val, void * dp ) ParamHilite( p->group->win, p->control, p->bInvalid ); return; } - if ( !ParamFloatRangeCheck( p, valF ) ) + if ( !ParamFloatRangeCheck( p, valF ) ) { return; + } wControlSetBalloon( p->control, 0, 0, NULL ); p->bInvalid = FALSE; if (recordF && (p->option&PDO_NORECORD)==0 && p->group->nameStr && p->nameStr) { - fprintf( recordF, "PARAMETER %s %s %0.6f\n", p->group->nameStr, p->nameStr, valF ); + fprintf( recordF, "PARAMETER %s %s %0.6f\n", p->group->nameStr, p->nameStr, + valF ); fflush( recordF ); } - if ( (p->option&PDO_NOPSHUPD)==0 && p->valueP) + if ( (p->option&PDO_NOPSHUPD)==0 && p->valueP) { *((FLOAT_T*)(p->valueP)) = valF; - if ( (p->option&PDO_NOPSHACT)==0 && p->group->changeProc && strlen( value )) + } + if ( (p->option&PDO_NOPSHACT)==0 && p->group->changeProc && strlen( value )) { p->group->changeProc( p->group, (int)(p-p->group->paramPtr), &valF ); + } ParamHilite( p->group->win, p->control, p->bInvalid ); } @@ -1536,7 +1653,7 @@ static void ParamStringPush( const char * val, void * dp ) { paramData_p p = (paramData_p)dp; const char * value; - wBool_t bInvalid = p->bInvalid; +// wBool_t bInvalid = p->bInvalid; if (recordF && (p->option&PDO_NORECORD)==0 && p->group->nameStr && p->nameStr) { fprintf( recordF, "PARAMETER %s %s %s\n", p->group->nameStr, p->nameStr, val ); fflush( recordF ); @@ -1548,7 +1665,8 @@ static void ParamStringPush( const char * val, void * dp ) value = val; p->enter_pressed = FALSE; } - LOG( log_paraminput, 1, ( "ParamStringPush( %s: Enter:%d Val:%s )\n", p->nameStr, p->enter_pressed, value ) ); + LOG( log_paraminput, 1, ( "ParamStringPush( %s: Enter:%d Val:%s )\n", + p->nameStr, p->enter_pressed, value ) ); if ( ((!inPlayback) && p->option & PDO_NOTBLANK) && value[0] == '\0' ) { p->bInvalid = TRUE; wControlSetBalloon( p->control, 0, 0, NULL ); @@ -1561,15 +1679,29 @@ static void ParamStringPush( const char * val, void * dp ) p->bInvalid = FALSE; ParamHilite( p->group->win, p->control, FALSE ); - if ( (p->option&PDO_NOPSHUPD)==0 && p->valueP) - strcpy( (char*)p->valueP, value ); + if ( (p->option&PDO_NOPSHUPD)==0 && p->valueP) { + strncpy((char*)p->valueP, value, p->max_string-1); + ((char *)p->valueP)[p->max_string - 1] = '\0'; + if (strlen(value) > p->max_string-1) { + p->bInvalid = TRUE; + wControlSetBalloon( p->control, 0, 0, NULL ); + wWinPix_t h = wControlGetHeight(p->control); + sprintf( message, _("String is too long, Max length is %u"), p->max_string-1 ); + wControlSetBalloon( p->control, 0, -h*3/4, message ); + ParamHilite( p->group->win, p->control, TRUE ); + } + } if ( (p->option&PDO_NOPSHACT)==0 && p->group->changeProc) // CAST_AWAY_CONST: param 3 should be const but its a big change - p->group->changeProc( p->group, (int)(p-p->group->paramPtr), CAST_AWAY_CONST value ); + { + p->group->changeProc( p->group, (int)(p-p->group->paramPtr), + CAST_AWAY_CONST value ); + } } -static void ParamListPush( wIndex_t inx, const char * val, wIndex_t op, void * dp, void * itemContext ) +static void ParamListPush( wIndex_t inx, const char * val, wIndex_t op, + void * dp, void * itemContext ) { paramData_p p = (paramData_p)dp; long valL; @@ -1579,11 +1711,13 @@ static void ParamListPush( wIndex_t inx, const char * val, wIndex_t op, void * d case PD_DROPLIST: case PD_COMBOLIST: if (recordF && (p->option&PDO_NORECORD)==0 && p->group->nameStr && p->nameStr) { - fprintf( recordF, "PARAMETER %s %s %d %s\n", p->group->nameStr, p->nameStr, inx, val ); + fprintf( recordF, "PARAMETER %s %s %d %s\n", p->group->nameStr, p->nameStr, inx, + val ); fflush( recordF ); } - if ( (p->option&PDO_NOPSHUPD)==0 && p->valueP) + if ( (p->option&PDO_NOPSHUPD)==0 && p->valueP) { *(wIndex_t*)(p->valueP) = inx; + } if ( (p->option&PDO_NOPSHACT)==0 && p->group->changeProc ) { valL = inx; p->group->changeProc( p->group, (int)(p-p->group->paramPtr), &valL ); @@ -1599,12 +1733,14 @@ static void ParamListPush( wIndex_t inx, const char * val, wIndex_t op, void * d EXPORT void ParamMenuPush( void * dp ) { paramData_p p = (paramData_p)dp; - if (recordF && (p->option&PDO_NORECORD)==0 && p->group->nameStr && p->nameStr) { - fprintf( recordF, "PARAMETER %s %s\n", p->group->nameStr, p->nameStr ); + const char * groupNameStr = p->group ? p->group->nameStr : "misc"; + if (recordF && (p->option&PDO_NORECORD)==0 && groupNameStr && p->nameStr) { + fprintf( recordF, "PARAMETER %s %s\n", groupNameStr, p->nameStr ); fflush( recordF ); } - if ( (p->option&PDO_NOPSHACT)==0 && p->valueP ) + if ( (p->option&PDO_NOPSHACT)==0 && p->valueP ) { ((wMenuCallBack_p)(p->valueP))( p->context ); + } } @@ -1617,17 +1753,22 @@ static void ParamColorSelectPush( void * dp, wDrawColor dc ) rgb -= 1; // Make it very close but different if ( ( rgb & 0xFF ) == 0 ) // Ran out of room - bail + { break; + } dc = wDrawFindColor( rgb ); } if (recordF && (p->option&PDO_NORECORD)==0 && p->group->nameStr && p->nameStr) { - fprintf( recordF, "PARAMETER %s %s %ld\n", p->group->nameStr, p->nameStr, wDrawGetRGB(dc) ); + fprintf( recordF, "PARAMETER %s %s %ld\n", p->group->nameStr, p->nameStr, + wDrawGetRGB(dc) ); fflush( recordF ); } - if ( (p->option&PDO_NOPSHUPD)==0 && p->valueP) + if ( (p->option&PDO_NOPSHUPD)==0 && p->valueP) { *(wDrawColor*)(p->valueP) = dc; - if ( (p->option&PDO_NOPSHACT)==0 && p->group->changeProc ) + } + if ( (p->option&PDO_NOPSHACT)==0 && p->group->changeProc ) { p->group->changeProc( p->group, (int)(p-p->group->paramPtr), &dc ); + } } @@ -1635,43 +1776,54 @@ static void ParamDrawRedraw( wDraw_p d, void * dp, wWinPix_t w, wWinPix_t h ) { paramData_p p = (paramData_p)dp; paramDrawData_t * ddp = (paramDrawData_t*)p->winData; - if ( ddp->redraw ) + if ( ddp->redraw ) { ddp->redraw( d, p->context, w, h ); + } } -static void ParamDrawAction( wDraw_p d, void * dp, wAction_t a, wDrawPix_t w, wDrawPix_t h ) +static void ParamDrawAction( wDraw_p d, void * dp, wAction_t a, wDrawPix_t w, + wDrawPix_t h ) { paramData_p p = (paramData_p)dp; paramDrawData_t * ddp = (paramDrawData_t*)p->winData; coOrd pos; ddp->d->Pix2CoOrd( ddp->d, w, h, &pos ); - if ( recordF && (p->option&PDO_NORECORD)==0 && p->group->nameStr && p->nameStr) { - fprintf( recordF, "PARAMETER %s %s %d %0.3f %0.3f\n", p->group->nameStr, p->nameStr, a, pos.x, pos.y ); + if ( recordF && (p->option&PDO_NORECORD)==0 && p->group->nameStr + && p->nameStr) { + fprintf( recordF, "PARAMETER %s %s %d %0.3f %0.3f\n", p->group->nameStr, + p->nameStr, a, pos.x, pos.y ); fflush( recordF ); } - if ( (p->option&PDO_NOPSHACT)== 0 && ddp->action ) + if ( (p->option&PDO_NOPSHACT)== 0 && ddp->action ) { ddp->action( a, pos ); + } } EXPORT wBool_t ParamCheckInputs( - paramGroup_p group, - wControl_p b ) + paramGroup_p group, + wControl_p b ) { wBool_t bInvalid = FALSE; // Check for invalid entries - for ( paramData_p p = group->paramPtr; p < &group->paramPtr[group->paramCnt]; p++ ) { + for ( paramData_p p = group->paramPtr; p < &group->paramPtr[group->paramCnt]; + p++ ) { ParamHilite( group->win, p->control, p->bInvalid ); - if ( p->bInvalid == FALSE ) + if ( p->bInvalid == FALSE ) { continue; + } + if ( p->bShown == FALSE ) { + continue; + } LOG( log_paraminput, 1, ( " %s: Invalid\n", p->nameStr ) ); bInvalid = TRUE; } if ( bInvalid ) { // At least 1 invalid entry LOG( log_paraminput, 1, ( " Group %s Invalid\n", group->nameStr ) ); - wControlSetBalloon( b, 0, -29, _("Invalid input(s), please correct the hilighted field(s)") ); + wControlSetBalloon( b, 0, -29, + _("Invalid input(s), please correct the hilighted field(s)") ); wFlush(); return FALSE; } @@ -1684,15 +1836,17 @@ static void ParamButtonOk( void * groupVP ) paramGroup_p group = groupVP; wFlush(); LOG( log_paraminput, 1, ( "ParamButtonOk: %s\n", group->nameStr ) ); - if ( ! ParamCheckInputs( group, (wControl_p)group->okB ) ) + if ( ! ParamCheckInputs( group, (wControl_p)group->okB ) ) { return; - if ( recordF && group->nameStr ) - fprintf( recordF, "PARAMETER %s %s\n", group->nameStr, "ok" ); { + } + if ( recordF && group->nameStr ) { + fprintf( recordF, "PARAMETER %s %s\n", group->nameStr, "ok" ); fflush( recordF ); } - if ( group->okProc ) + if ( group->okProc ) { group->okProc( group ); + } wControlSetBalloon( (wControl_p)group->okB, 0, 0, NULL ); wFlush(); @@ -1708,8 +1862,9 @@ static void ParamButtonCancel( void * groupVP ) fprintf( recordF, "PARAMETER %s %s\n", group->nameStr, "cancel" ); fflush( recordF ); } - if ( group->cancelProc ) + if ( group->cancelProc ) { group->cancelProc( group->win ); + } } @@ -1718,13 +1873,16 @@ EXPORT void ParamChange( paramData_p p ) { FLOAT_T tmpR; - if (p->valueP==NULL) + if (p->valueP==NULL) { return; + } switch (p->type) { case PD_LONG: - if (recordF && (p->option&PDO_NORECORD)==0 && p->group->nameStr && p->nameStr) - fprintf( recordF, "PARAMETER %s %s %ld\n", p->group->nameStr, p->nameStr, *(long*)p->valueP ); + if (recordF && (p->option&PDO_NORECORD)==0 && p->group->nameStr && p->nameStr) { + fprintf( recordF, "PARAMETER %s %s %ld\n", p->group->nameStr, p->nameStr, + *(long*)p->valueP ); + } #ifdef LATER if ( p->control && (p->option&PDO_NOCONTUPD) == 0 ) { wStringSetValue( (wString_p)p->control, FormatLong( *(long*)p->valueP ) ); @@ -1732,55 +1890,71 @@ EXPORT void ParamChange( paramData_p p ) #endif break; case PD_RADIO: - if (recordF && (p->option&PDO_NORECORD)==0 && p->group->nameStr && p->nameStr) - fprintf( recordF, "PARAMETER %s %s %ld\n", p->group->nameStr, p->nameStr, *(long*)p->valueP ); + if (recordF && (p->option&PDO_NORECORD)==0 && p->group->nameStr && p->nameStr) { + fprintf( recordF, "PARAMETER %s %s %ld\n", p->group->nameStr, p->nameStr, + *(long*)p->valueP ); + } #ifdef LATER - if ( p->control && (p->option&PDO_NOCONTUPD) == 0 ) + if ( p->control && (p->option&PDO_NOCONTUPD) == 0 ) { wRadioSetValue( (wChoice_p)p->control, *(long*)p->valueP ); + } #endif break; case PD_TOGGLE: - if (recordF && (p->option&PDO_NORECORD)==0 && p->group->nameStr && p->nameStr) - fprintf( recordF, "PARAMETER %s %s %ld\n", p->group->nameStr, p->nameStr, *(long*)p->valueP ); + if (recordF && (p->option&PDO_NORECORD)==0 && p->group->nameStr && p->nameStr) { + fprintf( recordF, "PARAMETER %s %s %ld\n", p->group->nameStr, p->nameStr, + *(long*)p->valueP ); + } #ifdef LATER - if ( p->control && (p->option&PDO_NOCONTUPD) == 0 ) + if ( p->control && (p->option&PDO_NOCONTUPD) == 0 ) { wToggleSetValue( (wChoice_p)p->control, *(long*)p->valueP ); + } #endif break; case PD_LIST: case PD_DROPLIST: case PD_COMBOLIST: if (recordF && (p->option&PDO_NORECORD)==0 && p->group->nameStr && p->nameStr) { - fprintf( recordF, "PARAMETER %s %s %d %s\n", p->group->nameStr, p->nameStr, *(wIndex_t*)p->valueP, "???" ); + fprintf( recordF, "PARAMETER %s %s %d %s\n", p->group->nameStr, p->nameStr, + *(wIndex_t*)p->valueP, "???" ); } #ifdef LATER - if ( p->control && (p->option&PDO_NOCONTUPD) == 0 ) + if ( p->control && (p->option&PDO_NOCONTUPD) == 0 ) { wListSetIndex( (wList_p)p->control, *(wIndex_t*)p->valueP ); + } #endif break; case PD_COLORLIST: - if (recordF && (p->option&PDO_NORECORD)==0 && p->group->nameStr && p->nameStr) - fprintf( recordF, "PARAMETER %s %s %ld\n", p->group->nameStr, p->nameStr, rgb ); + if (recordF && (p->option&PDO_NORECORD)==0 && p->group->nameStr && p->nameStr) { + fprintf( recordF, "PARAMETER %s %s %ld\n", p->group->nameStr, p->nameStr, + rgb ); + } break; case PD_FLOAT: tmpR = *(FLOAT_T*)p->valueP; - if (recordF && (p->option&PDO_NORECORD)==0 && p->group->nameStr && p->nameStr) - fprintf( recordF, "PARAMETER %s %s %0.6f\n", p->group->nameStr, p->nameStr, tmpR ); + if (recordF && (p->option&PDO_NORECORD)==0 && p->group->nameStr && p->nameStr) { + fprintf( recordF, "PARAMETER %s %s %0.6f\n", p->group->nameStr, p->nameStr, + tmpR ); + } #ifdef LATER if ( p->control && (p->option&PDO_NOCONTUPD) == 0 ) { if (p->option&PDO_DIM) #endif - if (p->option&PDO_ANGLE) - tmpR = NormalizeAngle( (angleSystem==ANGLE_POLAR)?tmpR:-tmpR ); + if (p->option&PDO_ANGLE) { + tmpR = NormalizeAngle( (angleSystem==ANGLE_POLAR)?tmpR:-tmpR ); + } wStringSetValue( (wString_p)p->control, tmpR ); } break; case PD_STRING: - if (recordF && (p->option&PDO_NORECORD)==0 && p->group->nameStr && p->nameStr) - fprintf( recordF, "PARAMETER %s %s %s\n", p->group->nameStr, p->nameStr, (char*)p->valueP ); + if (recordF && (p->option&PDO_NORECORD)==0 && p->group->nameStr && p->nameStr) { + fprintf( recordF, "PARAMETER %s %s %s\n", p->group->nameStr, p->nameStr, + (char*)p->valueP ); + } #ifdef LATER - if ( p->control && (p->option&PDO_NOCONTUPD) == 0 ) + if ( p->control && (p->option&PDO_NOCONTUPD) == 0 ) { wStringSetValue( (wString_p)p->control, (char*)p->valueP ); + } #endif break; case PD_MESSAGE: @@ -1796,34 +1970,34 @@ EXPORT void ParamChange( paramData_p p ) EXPORT void ParamHilite( - wWin_p win, - wControl_p control, - BOOL_T hilite ) + wWin_p win, + wControl_p control, + BOOL_T hilite ) { - if ( control == NULL ) return; + if ( control == NULL ) { return; } LOG(log_paraminput, 2, ("ParamHilite %s\n", hilite?"Set":"Clr" )); if ( hilite ) { wControlHilite( control, TRUE ); wFlush(); - if ( inPlayback && !paramHiliteFast ) - wPause(500); + if ( inPlayback ) { + wPause(playbackDelay*4+1); + } } else { -// if ( inPlayback && !paramHiliteFast ) -// wPause(500); wControlHilite( control, FALSE ); } } EXPORT void ParamResetInvalid( - wWin_p win ) + wWin_p win ) { for ( int inx=0; inx<paramGroups_da.cnt; inx++ ) { paramGroup_p pg = paramGroups(inx); if ( pg->win == win ) { LOG( log_paraminput, 1, ( "Reset Invalid: %s\n", pg->nameStr ) ); for ( paramData_p p = &pg->paramPtr[0]; p < &pg->paramPtr[pg->paramCnt]; p++ ) { - if ( p->bInvalid ) + if ( p->bInvalid ) { LOG( log_paraminput, 1, ( " %s Invalid\n", p->nameStr ) ); + } ParamHilite( win, p->control, FALSE ); wControlSetBalloon( p->control, 0, 0, NULL ); p->bInvalid = FALSE; @@ -1833,6 +2007,15 @@ EXPORT void ParamResetInvalid( } } + +EXPORT void ParamControlShow( paramGroup_p pg, wIndex_t inx, wBool_t bShow ) +{ + paramData_p p = &pg->paramPtr[inx]; + wControlShow( p->control, bShow ); + p->bShown = bShow; +} + + static void ParamPlayback( char * line ) { paramGroup_p pg; @@ -1866,27 +2049,34 @@ static void ParamPlayback( char * line ) } for ( inx=0; inx<paramGroups_da.cnt; inx++ ) { - pg = paramGroups(inx); - if ( pg->nameStr == NULL ) - continue; - len1 = strlen( pg->nameStr ); - if ( strncmp( pg->nameStr, line, len1 ) != 0 || - line[len1] != ' ' ) - continue; - for ( p=pg->paramPtr,inx=0; inx<pg->paramCnt; p++,inx++ ) { - if ( p->nameStr == NULL ) + pg = paramGroups(inx); + if ( pg->nameStr == NULL ) { continue; - len2 = strlen( p->nameStr ); - if ( strncmp(p->nameStr, line+len1+1, len2) != 0 || - (line[len1+1+len2] != ' ' && line[len1+1+len2] != '\0') ) + } + len1 = strlen( pg->nameStr ); + if ( strncmp( pg->nameStr, line, len1 ) != 0 || + line[len1] != ' ' ) { continue; - len = len1 + 1 + len2 + 1; - if ( p->type != PD_DRAW && p->type != PD_MESSAGE && p->type != PD_MENU && p->type != PD_MENUITEM ) - ParamHilite( p->group->win, p->control, TRUE ); - switch (p->type) { + } + for ( p=pg->paramPtr,inx=0; inx<pg->paramCnt; p++,inx++ ) { + if ( p->nameStr == NULL ) { + continue; + } + len2 = strlen( p->nameStr ); + if ( strncmp(p->nameStr, line+len1+1, len2) != 0 || + (line[len1+1+len2] != ' ' && line[len1+1+len2] != '\0') ) { + continue; + } + len = len1 + 1 + len2 + 1; + if ( p->type != PD_DRAW && p->type != PD_MESSAGE && p->type != PD_MENU + && p->type != PD_MENUITEM ) { + ParamHilite( p->group->win, p->control, TRUE ); + } + switch (p->type) { case PD_BUTTON: - if (p->valueP) - ((wButtonCallBack_p)(p->valueP))( p->context ); + if (p->valueP) { + ((wButtonCallBack_p)(p->valueP))( p->context ); + } if (playbackTimer == 0 && p->control) { wButtonSetBusy( (wButton_p)p->control, TRUE ); wFlush(); @@ -1897,46 +2087,53 @@ static void ParamPlayback( char * line ) break; case PD_LONG: valL = atol( line+len ); - if (p->valueP) + if (p->valueP) { *(long*)p->valueP = valL; + } if (p->control) { wStringSetValue( (wString_p)p->control, FormatLong( valL ) ); wFlush(); } - if (pg->changeProc) + if (pg->changeProc) { pg->changeProc( pg, inx, &valL ); + } break; case PD_RADIO: valL = atol( line+len ); - if (p->valueP) + if (p->valueP) { *(long*)p->valueP = valL; + } if (p->control) { wRadioSetValue( (wChoice_p)p->control, valL ); wFlush(); } - if (pg->changeProc) + if (pg->changeProc) { pg->changeProc( pg, inx, &valL ); + } break; case PD_TOGGLE: valL = atol( line+len ); - if (p->valueP) + if (p->valueP) { *(long*)p->valueP = valL; + } if (p->control) { wToggleSetValue( (wChoice_p)p->control, valL ); wFlush(); } - if (pg->changeProc) + if (pg->changeProc) { pg->changeProc( pg, inx, &valL ); + } break; case PD_LIST: case PD_DROPLIST: case PD_COMBOLIST: line += len; valL = strtol( line, &valS, 10 ); - if ( valS ) + if ( valS ) { valS++; - else + } else { valS = ""; + } if ( p->control != NULL ) { if ( (p->option&PDO_LISTINDEX) == 0 ) { if ( valL < 0 ) { @@ -1953,12 +2150,14 @@ static void ParamPlayback( char * line ) wListSetIndex( (wList_p)p->control, (wIndex_t)valL ); } wFlush(); - wListGetValues( (wList_p)p->control, message, sizeof message, &listContext, &itemContext ); + wListGetValues( (wList_p)p->control, message, sizeof message, &listContext, + &itemContext ); } else if ( (p->option&PDO_LISTINDEX) == 0 ) { break; } - if (p->valueP) + if (p->valueP) { *(wIndex_t*)p->valueP = (wIndex_t)valL; + } if (pg->changeProc) { pg->changeProc( pg, inx, &valL ); } @@ -1967,10 +2166,12 @@ static void ParamPlayback( char * line ) line += len; rgb = atol( line ); dc = wDrawFindColor( rgb ); - if ( p->control) + if ( p->control) { wColorSelectButtonSetColor( (wButton_p)p->control, dc ); - if (p->valueP) + } + if (p->valueP) { *(wDrawColor*)p->valueP = dc; + } if (pg->changeProc) { /* COLORNOP */ pg->changeProc( pg, inx, &valL ); @@ -1980,48 +2181,58 @@ static void ParamPlayback( char * line ) SetCLocale(); valF = valF1 = atof( line+len ); SetUserLocale(); - if (p->valueP) + if (p->valueP) { *(FLOAT_T*)p->valueP = valF; + } if (p->option&PDO_DIM) { - if ( p->option&PDO_SMALLDIM ) + if ( p->option&PDO_SMALLDIM ) { valS = FormatSmallDistance( valF ); - else + } else { valS = FormatDistance( valF ); + } } else { - if (p->option&PDO_ANGLE) + if (p->option&PDO_ANGLE) { valF1 = NormalizeAngle( (angleSystem==ANGLE_POLAR)?valF1:-valF1 ); + } valS = FormatFloat( valF ); } if (p->control) { wStringSetValue( (wString_p)p->control, valS ); wFlush(); } - if (pg->changeProc) + if (pg->changeProc) { pg->changeProc( pg, inx, &valF ); + } break; case PD_STRING: case PD_TEXT: line += len; - while ( *line == ' ' ) line++; + while ( *line == ' ' ) { line++; } Stripcr( line ); - if (p->valueP) + if (p->valueP) { strcpy( (char*)p->valueP, line ); + } if (p->control) { if (p->type == PD_STRING) { wStringSetValue((wString_p)p->control, line); + p->bInvalid = + (p->option & PDO_NOTBLANK) && + strlen( line ) == 0; } else { wTextClear((wText_p)p->control); wTextAppend((wText_p)p->control, line); } wFlush(); } - if (pg->changeProc) + if (pg->changeProc) { pg->changeProc( pg, inx, line ); + } break; case PD_DRAW: ddp = (paramDrawData_t*)p->winData; - if ( ddp->action == NULL ) + if ( ddp->action == NULL ) { break; + } a = (wAction_t)strtol( line+len, &line, 10 ); pos.x = strtod( line, &line ); pos.y = strtod( line, NULL ); @@ -2033,44 +2244,50 @@ static void ParamPlayback( char * line ) break; case PD_MENUITEM: if (p->valueP) { - if ( (p->option&IC_PLAYBACK_PUSH) != 0 ) + if ( (p->option&IC_PLAYBACK_PUSH) != 0 ) { PlaybackButtonMouse( (wIndex_t)VP2L(p->context) ); + } ((wButtonCallBack_p)(p->valueP))( p->context ); } break; } - if ( p->type != PD_DRAW && p->type != PD_MESSAGE && p->type != PD_MENU && p->type != PD_MENUITEM ) - ParamHilite( p->group->win, p->control, FALSE ); + if ( p->type != PD_DRAW && p->type != PD_MESSAGE && p->type != PD_MENU + && p->type != PD_MENUITEM ) { + ParamHilite( p->group->win, p->control, FALSE ); + } #ifdef HUH - pg->action |= p->change; + pg->action |= p->change; #endif + return; + } + button = NULL; + if ( strcmp("ok", line+len1+1) == 0 ) { + ParamHilite( pg->win, (wControl_p)pg->okB, TRUE ); + if ( pg->okProc ) { + pg->okProc( pg ); + } + button = pg->okB; + } else if ( strcmp("cancel", line+len1+1) == 0 ) { + ParamHilite( pg->win, (wControl_p)pg->cancelB, TRUE ); + if ( pg->cancelProc ) { + pg->cancelProc( pg->win ); + } + button = pg->cancelB; + } + if ( playbackTimer == 0 && button ) { + wButtonSetBusy( button, TRUE ); + wFlush(); + wPause( 500 ); + wButtonSetBusy( button, FALSE ); + wFlush(); + } + ParamHilite( pg->win, (wControl_p)button, FALSE ); + if ( !button ) { + NoticeMessage( "Unknown PARAM: %s", _("Ok"), NULL, line ); + } return; } - button = NULL; - if ( strcmp("ok", line+len1+1) == 0 ) { - ParamHilite( pg->win, (wControl_p)pg->okB, TRUE ); - if ( pg->okProc ) - pg->okProc( pg ); - button = pg->okB; - } else if ( strcmp("cancel", line+len1+1) == 0 ) { - ParamHilite( pg->win, (wControl_p)pg->cancelB, TRUE ); - if ( pg->cancelProc ) - pg->cancelProc( pg->win ); - button = pg->cancelB; - } - if ( playbackTimer == 0 && button ) { - wButtonSetBusy( button, TRUE ); - wFlush(); - wPause( 500 ); - wButtonSetBusy( button, FALSE ); - wFlush(); - } - ParamHilite( pg->win, (wControl_p)button, FALSE ); - if ( !button ) - NoticeMessage( "Unknown PARAM: %s", _("Ok"), NULL, line ); - return; - } - NoticeMessage( "Unknown PARAM: %s", _("Ok"), NULL, line ); + NoticeMessage( "Unknown PARAM: %s", _("Ok"), NULL, line ); } @@ -2090,24 +2307,29 @@ static void ParamCheck( char * line ) FILE * f; for ( inx=0; inx<paramGroups_da.cnt; inx++ ) { - pg = paramGroups(inx); - if ( pg->nameStr == NULL ) - continue; - len1 = strlen( pg->nameStr ); - if ( strncmp( pg->nameStr, line, len1 ) != 0 || - line[len1] != ' ' ) - continue; - for ( p=pg->paramPtr,inx=0; inx<pg->paramCnt; p++,inx++ ) { - if ( p->nameStr == NULL ) + pg = paramGroups(inx); + if ( pg->nameStr == NULL ) { continue; - len2 = strlen( p->nameStr ); - if ( strncmp(p->nameStr, line+len1+1, len2) != 0 || - (line[len1+1+len2] != ' ' && line[len1+1+len2] != '\0') ) + } + len1 = strlen( pg->nameStr ); + if ( strncmp( pg->nameStr, line, len1 ) != 0 || + line[len1] != ' ' ) { continue; - if ( p->valueP == NULL ) - return; - len = len1 + 1 + len2 + 1; - switch (p->type) { + } + for ( p=pg->paramPtr,inx=0; inx<pg->paramCnt; p++,inx++ ) { + if ( p->nameStr == NULL ) { + continue; + } + len2 = strlen( p->nameStr ); + if ( strncmp(p->nameStr, line+len1+1, len2) != 0 || + (line[len1+1+len2] != ' ' && line[len1+1+len2] != '\0') ) { + continue; + } + if ( p->valueP == NULL ) { + return; + } + len = len1 + 1 + len2 + 1; + switch (p->type) { case PD_BUTTON: break; case PD_LONG: @@ -2126,12 +2348,14 @@ static void ParamCheck( char * line ) case PD_DROPLIST: case PD_COMBOLIST: line += len; - if ( p->control == NULL ) + if ( p->control == NULL ) { break; + } valL = strtol( line, &valS, 10 ); if ( valS ) { - if ( valS[0] == ' ' ) + if ( valS[0] == ' ' ) { valS++; + } } else { valS = ""; } @@ -2144,7 +2368,8 @@ static void ParamCheck( char * line ) hasError = TRUE; } } else { - wListGetValues( (wList_p)p->control, message, sizeof message, &listContext, &itemContext ); + wListGetValues( (wList_p)p->control, message, sizeof message, &listContext, + &itemContext ); if ( strcasecmp( message, valS ) != 0 ) { expVal = valS; actVal = message; @@ -2167,7 +2392,7 @@ static void ParamCheck( char * line ) break; case PD_STRING: line += len; - while ( *line == ' ' ) line++; + while ( *line == ' ' ) { line++; } wStringGetValue( (wString_p)p->control ); if ( strcasecmp( line, (char*)p->valueP ) != 0 ) { expVal = line; @@ -2182,24 +2407,27 @@ static void ParamCheck( char * line ) case PD_MENUITEM: case PD_BITMAP: break; - } - if ( hasError ) { - f = fopen( "error.log", "a" ); - if ( f==NULL ) { - NoticeMessage( MSG_OPEN_FAIL, _("Continue"), NULL, "PARAMCHECK LOG", "error.log", strerror(errno) ); - } else { - fprintf( f, "CHECK: %s:%d: %s-%s: exp: %s, act=%s\n", - paramFileName, paramLineNum, pg->nameStr, p->nameStr, expVal, actVal ); - fclose( f ); } - if ( paramCheckShowErrors ) - NoticeMessage( "CHECK: %d: %s-%s: exp: %s, act=%s", _("Ok"), NULL, paramLineNum, pg->nameStr, p->nameStr, expVal, actVal ); - paramCheckErrorCount++; + if ( hasError ) { + f = fopen( "error.log", "a" ); + if ( f==NULL ) { + NoticeMessage( MSG_OPEN_FAIL, _("Continue"), NULL, "PARAMCHECK LOG", + "error.log", strerror(errno) ); + } else { + fprintf( f, "CHECK: %s:%d: %s-%s: exp: %s, act=%s\n", + paramFileName, paramLineNum, pg->nameStr, p->nameStr, expVal, actVal ); + fclose( f ); + } + if ( paramCheckShowErrors ) { + NoticeMessage( "CHECK: %d: %s-%s: exp: %s, act=%s", _("Ok"), NULL, paramLineNum, + pg->nameStr, p->nameStr, expVal, actVal ); + } + paramCheckErrorCount++; + } + return; } - return; - } - } - NoticeMessage( "Unknown PARAMCHECK: %s", _("Ok"), NULL, line ); + } + NoticeMessage( "Unknown PARAMCHECK: %s", _("Ok"), NULL, line ); } /* @@ -2209,10 +2437,10 @@ static void ParamCheck( char * line ) static void ParamCreateControl( - paramData_p pd, - char * helpStr, - wWinPix_t xx, - wWinPix_t yy ) + paramData_p pd, + char * helpStr, + wWinPix_t xx, + wWinPix_t yy ) { const paramFloatRange_t * floatRangeP; const paramIntegerRange_t * integerRangeP; @@ -2229,139 +2457,162 @@ static void ParamCreateControl( static wBool_t maxColCnt = 0; int col; const char *cp; - char *cq; + char *cq; static wMenu_p menu = NULL; - if ( ( win = pd->group->win ) == NULL ) + if ( ( win = pd->group->win ) == NULL ) { win = mainW; + } - switch (pd->type) { - case PD_FLOAT: - floatRangeP = pd->winData; - w = floatRangeP->width?floatRangeP->width:100; - pd->control = (wControl_p)wStringCreate( win, xx, yy, helpStr, _(pd->winLabel), pd->winOption, w, NULL, 0, ParamFloatPush, pd ); - break; - case PD_LONG: - integerRangeP = pd->winData; - w = integerRangeP->width?integerRangeP->width:100; - pd->control = (wControl_p)wStringCreate( win, xx, yy, helpStr, _(pd->winLabel), pd->winOption, w, NULL, 0, ParamIntegerPush, pd ); - break; - case PD_STRING: - w = pd->winData?(wWinPix_t)VP2L(pd->winData):(wWinPix_t)250; - pd->control = (wControl_p)wStringCreate( win, xx, yy, helpStr, _(pd->winLabel), pd->winOption, w, (pd->option&PDO_NOPSHUPD)?NULL:pd->valueP, 0, ParamStringPush, pd ); - break; - case PD_RADIO: - pd->control = (wControl_p)wRadioCreate( win, xx, yy, helpStr, _(pd->winLabel), pd->winOption, pd->winData, NULL, ParamChoicePush, pd ); - break; - case PD_TOGGLE: - pd->control = (wControl_p)wToggleCreate( win, xx, yy, helpStr, _(pd->winLabel), pd->winOption, pd->winData, NULL, ParamChoicePush, pd ); - break; - case PD_LIST: - listDataP = (paramListData_t*)pd->winData; - if ( listDataP->colCnt > 1 ) { - if ( maxColCnt < listDataP->colCnt ) { - if ( maxColCnt == 0 ) { - colWidths = (wWinPix_t*)MyMalloc( listDataP->colCnt * sizeof *colWidths ); - colRightJust = (wBool_t*)MyMalloc( listDataP->colCnt * sizeof *colRightJust ); - } else { - colWidths = (wWinPix_t*)MyRealloc( colWidths, listDataP->colCnt * sizeof *colWidths ); - colRightJust = (wBool_t*)MyRealloc( colRightJust, listDataP->colCnt * sizeof *colRightJust ); - } - maxColCnt = listDataP->colCnt; - } - for ( col=0; col<listDataP->colCnt; col++ ) { - colRightJust[col] = listDataP->colWidths[col]<0; - colWidths[col] = labs(listDataP->colWidths[col]); + switch (pd->type) { + case PD_FLOAT: + floatRangeP = pd->winData; + w = floatRangeP->width?floatRangeP->width:100; + pd->control = (wControl_p)wStringCreate( win, xx, yy, helpStr, _(pd->winLabel), + pd->winOption, w, NULL, 0, ParamFloatPush, pd ); + break; + case PD_LONG: + integerRangeP = pd->winData; + w = integerRangeP->width?integerRangeP->width:100; + pd->control = (wControl_p)wStringCreate( win, xx, yy, helpStr, _(pd->winLabel), + pd->winOption, w, NULL, 0, ParamIntegerPush, pd ); + break; + case PD_STRING: + w = pd->winData?(wWinPix_t)VP2L(pd->winData):(wWinPix_t)250; + pd->control = (wControl_p)wStringCreate( win, xx, yy, helpStr, _(pd->winLabel), + pd->winOption, w, (pd->option&PDO_NOPSHUPD)?NULL:pd->valueP, 0, ParamStringPush, + pd ); + break; + case PD_RADIO: + pd->control = (wControl_p)wRadioCreate( win, xx, yy, helpStr, _(pd->winLabel), + pd->winOption, pd->winData, NULL, ParamChoicePush, pd ); + break; + case PD_TOGGLE: + pd->control = (wControl_p)wToggleCreate( win, xx, yy, helpStr, _(pd->winLabel), + pd->winOption, pd->winData, NULL, ParamChoicePush, pd ); + break; + case PD_LIST: + listDataP = (paramListData_t*)pd->winData; + if ( listDataP->colCnt > 1 ) { + if ( maxColCnt < listDataP->colCnt ) { + if ( maxColCnt == 0 ) { + colWidths = (wWinPix_t*)MyMalloc( listDataP->colCnt * sizeof *colWidths ); + colRightJust = (wBool_t*)MyMalloc( listDataP->colCnt * sizeof *colRightJust ); + } else { + colWidths = (wWinPix_t*)MyRealloc( colWidths, + listDataP->colCnt * sizeof *colWidths ); + colRightJust = (wBool_t*)MyRealloc( colRightJust, + listDataP->colCnt * sizeof *colRightJust ); } - sprintf( message, "%s-%s-%s", pd->group->nameStr, pd->nameStr, "columnwidths" ); - cp = wPrefGetString( PREFSECT, message ); - if ( cp != NULL ) { + maxColCnt = listDataP->colCnt; + } + for ( col=0; col<listDataP->colCnt; col++ ) { + colRightJust[col] = listDataP->colWidths[col]<0; + colWidths[col] = labs(listDataP->colWidths[col]); + } + sprintf( message, "%s-%s-%s", pd->group->nameStr, pd->nameStr, "columnwidths" ); + cp = wPrefGetString( PREFSECT, message ); + if ( cp != NULL ) { for ( col=0; col<listDataP->colCnt; col++ ) { colWidth = (wWinPix_t)strtol( cp, &cq, 10 ); - if ( cp == cq ) + if ( cp == cq ) { break; + } colWidths[col] = colWidth; cp = cq; - } } } - pd->control = (wControl_p)wListCreate( win, xx, yy, helpStr, _(pd->winLabel), - pd->winOption, listDataP->number, listDataP->width, listDataP->colCnt, - (listDataP->colCnt>1?colWidths:NULL), - (listDataP->colCnt>1?colRightJust:NULL), - listDataP->colTitles, NULL, ParamListPush, pd ); - listDataP->height = wControlGetHeight( pd->control ); - break; - case PD_DROPLIST: - w = pd->winData?(wWinPix_t)VP2L(pd->winData):(wWinPix_t)100; - pd->control = (wControl_p)wDropListCreate( win, xx, yy, helpStr, _(pd->winLabel), pd->winOption, 10, w, NULL, ParamListPush, pd ); - break; - case PD_COMBOLIST: - listDataP = (paramListData_t*)pd->winData; - pd->control = (wControl_p)wComboListCreate( win, xx, yy, helpStr, _(pd->winLabel), pd->winOption, listDataP->number, listDataP->width, NULL, ParamListPush, pd ); - listDataP->height = wControlGetHeight( pd->control ); - break; - case PD_COLORLIST: - pd->control = (wControl_p)wColorSelectButtonCreate( win, xx, yy, helpStr, _(pd->winLabel), pd->winOption, 0, NULL, ParamColorSelectPush, pd ); - break; - case PD_MESSAGE: - if ( pd->winData != 0 ) - w = (wWinPix_t)VP2L(pd->winData); - else if (pd->valueP) - w = wLabelWidth( _(pd->valueP) ); - else - w = 150; - pd->control = (wControl_p)wMessageCreateEx( win, xx, yy, _(pd->winLabel), w, pd->valueP?_(pd->valueP):" ", pd->winOption ); - break; - case PD_BUTTON: - pd->control = (wControl_p)wButtonCreate( win, xx, yy, helpStr, _(pd->winLabel), pd->winOption, 0, ParamButtonPush, pd ); - break; - case PD_MENU: - menu = wMenuCreate( win, xx, yy, helpStr, _(pd->winLabel), pd->winOption ); - pd->control = (wControl_p)menu; - break; - case PD_MENUITEM: - pd->control = (wControl_p)wMenuPushCreate( menu, helpStr, _(pd->winLabel), 0, ParamMenuPush, pd ); - break; - case PD_DRAW: - drawDataP = pd->winData; - pd->control = (wControl_p)wDrawCreate( win, xx, yy, helpStr, pd->winOption, drawDataP->width, drawDataP->height, pd, ParamDrawRedraw, ParamDrawAction ); - if ( drawDataP->d ) { - drawDataP->d->d = (wDraw_p)pd->control; - drawDataP->d->dpi = wDrawGetDPI( drawDataP->d->d ); - } - break; - case PD_TEXT: - textDataP = pd->winData; - pd->control = (wControl_p)wTextCreate( win, xx, yy, helpStr, NULL, pd->winOption, textDataP->width, textDataP->height ); - if ( (pd->winOption&BO_READONLY) == 0 ) - wTextSetReadonly( (wText_p)pd->control, FALSE ); - break; - case PD_BITMAP: - iconP = pd->winData; - pd->control = (wControl_p)wBitmapCreate( win, xx, yy, pd->winOption, iconP ); - break; - default: - AbortProg( "paramCreatePG" ); } + pd->control = (wControl_p)wListCreate( win, xx, yy, helpStr, _(pd->winLabel), + pd->winOption, listDataP->number, listDataP->width, listDataP->colCnt, + (listDataP->colCnt>1?colWidths:NULL), + (listDataP->colCnt>1?colRightJust:NULL), + listDataP->colTitles, NULL, ParamListPush, pd ); + listDataP->height = wControlGetHeight( pd->control ); + break; + case PD_DROPLIST: + w = pd->winData?(wWinPix_t)VP2L(pd->winData):(wWinPix_t)100; + pd->control = (wControl_p)wDropListCreate( win, xx, yy, helpStr, + _(pd->winLabel), pd->winOption, 10, w, NULL, ParamListPush, pd ); + break; + case PD_COMBOLIST: + listDataP = (paramListData_t*)pd->winData; + pd->control = (wControl_p)wComboListCreate( win, xx, yy, helpStr, + _(pd->winLabel), pd->winOption, listDataP->number, listDataP->width, NULL, + ParamListPush, pd ); + listDataP->height = wControlGetHeight( pd->control ); + break; + case PD_COLORLIST: + pd->control = (wControl_p)wColorSelectButtonCreate( win, xx, yy, helpStr, + _(pd->winLabel), pd->winOption, 0, NULL, ParamColorSelectPush, pd ); + break; + case PD_MESSAGE: + if ( pd->winData != 0 ) { + w = (wWinPix_t)VP2L(pd->winData); + } else if (pd->valueP) { + w = wLabelWidth( _(pd->valueP) ); + } else { + w = 150; + } + pd->control = (wControl_p)wMessageCreateEx( win, xx, yy, _(pd->winLabel), w, + pd->valueP?_(pd->valueP):" ", pd->winOption ); + break; + case PD_BUTTON: + pd->control = (wControl_p)wButtonCreate( win, xx, yy, helpStr, _(pd->winLabel), + pd->winOption, 0, ParamButtonPush, pd ); + break; + case PD_MENU: + menu = wMenuCreate( win, xx, yy, helpStr, _(pd->winLabel), pd->winOption ); + pd->control = (wControl_p)menu; + break; + case PD_MENUITEM: + pd->control = (wControl_p)wMenuPushCreate( menu, helpStr, _(pd->winLabel), 0, + ParamMenuPush, pd ); + break; + case PD_DRAW: + drawDataP = pd->winData; + pd->control = (wControl_p)wDrawCreate( win, xx, yy, helpStr, pd->winOption, + drawDataP->width, drawDataP->height, pd, ParamDrawRedraw, ParamDrawAction ); + if ( drawDataP->d ) { + drawDataP->d->d = (wDraw_p)pd->control; + drawDataP->d->dpi = wDrawGetDPI( drawDataP->d->d ); + } + break; + case PD_TEXT: + textDataP = pd->winData; + pd->control = (wControl_p)wTextCreate( win, xx, yy, helpStr, NULL, + pd->winOption, textDataP->width, textDataP->height ); + if ( (pd->winOption&BO_READONLY) == 0 ) { + wTextSetReadonly( (wText_p)pd->control, FALSE ); + } + break; + case PD_BITMAP: + iconP = pd->winData; + pd->control = (wControl_p)wBitmapCreate( win, xx, yy, pd->winOption, iconP ); + break; + default: + CHECK(FALSE); + } + pd->bShown = TRUE; } static void ParamPositionControl( - paramData_p pd, - char * helpStr, - wWinPix_t xx, - wWinPix_t yy ) + paramData_p pd, + char * helpStr, + wWinPix_t xx, + wWinPix_t yy ) { const paramDrawData_t * drawDataP; const paramTextData_t * textDataP; const paramListData_t * listDataP; wWinPix_t winW, winH, ctlW, ctlH; - if ( pd->type != PD_MENUITEM ) + if ( pd->type != PD_MENUITEM ) { wControlSetPos( pd->control, xx, yy ); + } if ( pd->option&PDO_DLGRESIZE ) { wWinGetSize( pd->group->win, &winW, &winH ); switch (pd->type) { @@ -2376,42 +2627,51 @@ static void ParamPositionControl( ctlW = listDataP->width; ctlH = listDataP->height; } - if ( (pd->option&PDO_DLGRESIZE) == 0 ) + if ( (pd->option&PDO_DLGRESIZE) == 0 ) { break; - if ( (pd->option&PDO_DLGRESIZEW) != 0 ) + } + if ( (pd->option&PDO_DLGRESIZEW) != 0 ) { ctlW = winW - (pd->group->origW-ctlW); - if ( (pd->option&PDO_DLGRESIZEH) != 0 ) + } + if ( (pd->option&PDO_DLGRESIZEH) != 0 ) { ctlH = winH - (pd->group->origH-ctlH); + } wListSetSize( (wList_p)pd->control, ctlW, ctlH ); break; case PD_DRAW: drawDataP = pd->winData; - if ( (pd->option&PDO_DLGRESIZEW) ) + if ( (pd->option&PDO_DLGRESIZEW) ) { ctlW = winW - (pd->group->origW-drawDataP->width); - else + } else { ctlW = wControlGetWidth( pd->control ); - if ( (pd->option&PDO_DLGRESIZEH) ) + } + if ( (pd->option&PDO_DLGRESIZEH) ) { ctlH = winH - (pd->group->origH-drawDataP->height); - else + } else { ctlH = wControlGetHeight( pd->control ); + } wDrawSetSize( (wDraw_p)pd->control, ctlW, ctlH, NULL ); - if ( drawDataP->redraw ) + if ( drawDataP->redraw ) { drawDataP->redraw( (wDraw_p)pd->control, pd->context, ctlW, ctlH ); + } break; case PD_TEXT: textDataP = pd->winData; ctlW = textDataP->width; ctlH = textDataP->height; - if ( (pd->winOption&BT_CHARUNITS) ) + if ( (pd->winOption&BT_CHARUNITS) ) { wTextComputeSize( (wText_p)pd->control, ctlW, ctlH, &ctlW, &ctlH ); - if ( (pd->option&PDO_DLGRESIZEW) ) + } + if ( (pd->option&PDO_DLGRESIZEW) ) { ctlW = winW - (pd->group->origW-ctlW); - else + } else { ctlW = wControlGetWidth( pd->control ); - if ( (pd->option&PDO_DLGRESIZEH) ) + } + if ( (pd->option&PDO_DLGRESIZEH) ) { ctlH = winH - (pd->group->origH-ctlH); - else + } else { ctlH = wControlGetHeight( pd->control ); + } wTextSetSize( (wText_p)pd->control, ctlW, ctlH ); break; case PD_STRING: @@ -2429,7 +2689,7 @@ static void ParamPositionControl( } break; default: - AbortProg( "paramPositionControl" ); + CHECK(FALSE); } } } @@ -2437,10 +2697,10 @@ static void ParamPositionControl( typedef void (*layoutControlsProc)(paramData_p, char *, wWinPix_t, wWinPix_t ); static void LayoutControls( - paramGroup_p group, - layoutControlsProc proc, - wWinPix_t * retW, - wWinPix_t * retH ) + paramGroup_p group, + layoutControlsProc proc, + wWinPix_t * retW, + wWinPix_t * retH ) { struct { struct { wWinPix_t x, y; } orig, term; @@ -2472,33 +2732,41 @@ static void LayoutControls( memset( labelW, 0, sizeof labelW ); lastLabelPos = 0; currLabelPos = 0; - for ( pd=group->paramPtr; pd<&group->paramPtr[group->paramCnt]; pd++,currLabelPos++ ) { - if ( (pd->option&PDO_DLGIGNORE) != 0 ) + for ( pd=group->paramPtr; pd<&group->paramPtr[group->paramCnt]; + pd++,currLabelPos++ ) { + if ( (pd->option&PDO_DLGIGNORE) != 0 ) { continue; - if ( (pd->option&PDO_DLGBOXEND) ) + } + if ( (pd->option&PDO_DLGBOXEND) ) { hasBox = TRUE; + } if ( (pd->option&(PDO_DLGRESETMARGIN|PDO_DLGNEWCOLUMN|PDO_DLGCMDBUTTON)) ) { - for ( inx=lastLabelPos; inx<currLabelPos; inx++ ) + for ( inx=lastLabelPos; inx<currLabelPos; inx++ ) { labelW[inx] = controlK.orig.x; + } controlK.orig.x = 0; lastLabelPos = currLabelPos; } if ( pd->winLabel && (pd->option&(PDO_DLGIGNORELABELWIDTH|PDO_DLGHORZ))==0 && - pd->type!=PD_BUTTON && - pd->type!=PD_MENU && - pd->type!=PD_MENUITEM) { + pd->type!=PD_BUTTON && + pd->type!=PD_MENU && + pd->type!=PD_MENUITEM) { w = wLabelWidth( _(pd->winLabel) ); - if ( w > controlK.orig.x ) + if ( w > controlK.orig.x ) { controlK.orig.x = w; + } } } - for ( inx=lastLabelPos; inx<group->paramCnt; inx++ ) + for ( inx=lastLabelPos; inx<group->paramCnt; inx++ ) { labelW[inx] = controlK.orig.x; + } for ( inx=0; inx<group->paramCnt; inx++ ) - if ( (group->paramPtr[inx].option&PDO_DLGNOLABELALIGN) != 0 ) + if ( (group->paramPtr[inx].option&PDO_DLGNOLABELALIGN) != 0 ) { labelW[inx] = 0; + } - LOG( log_paramLayout, 1, ("Layout %s B?=%s\n", group->nameStr, hasBox?"T":"F" ) ) + LOG( log_paramLayout, 2, ("LayoutControls:%s B?=%s\n", group->nameStr, + hasBox?"T":"F" ) ) windowK.orig.x = DlgSepLeft + (hasBox?DlgSepFrmLeft:0); windowK.orig.y = DlgSepTop + (hasBox?DlgSepFrmTop:0); @@ -2506,12 +2774,15 @@ static void LayoutControls( controlK = columnK = windowK; controlK.orig.x += labelW[0]; - for ( pd = group->paramPtr,inx=0; pd<&group->paramPtr[group->paramCnt]; pd++,inx++ ) { - LOG( log_paramLayout, 1, ("%2d: Col %dx%d..%dx%d Ctl %dx%d..%dx%d\n", inx, - columnK.orig.x, columnK.orig.y, columnK.term.x, columnK.term.y, - controlK.orig.x, controlK.orig.y, controlK.term.x, controlK.term.y ) ) - if ( (pd->option&PDO_DLGIGNORE) != 0 ) + for ( pd = group->paramPtr,inx=0; pd<&group->paramPtr[group->paramCnt]; + pd++,inx++ ) { + if ( (pd->option&PDO_DLGIGNORE) != 0 ) { goto SkipControl; + } + LOG( log_paramLayout, 2, ("%2d: Col %dx%d..%dx%d Ctl %dx%d..%dx%d %s\n", inx, + columnK.orig.x, columnK.orig.y, columnK.term.x, columnK.term.y, + controlK.orig.x, controlK.orig.y, controlK.term.x, controlK.term.y, + pd->nameStr ) ) if ( pd->type == PD_MENUITEM ) { proc( pd, helpStr, 0, 0 ); continue; @@ -2527,19 +2798,22 @@ static void LayoutControls( controlK.orig.y = columnK.orig.y; } else if ( (pd->option&PDO_DLGHORZ) ) { controlK.orig.x = controlK.term.x; - if ( (pd->option&PDO_DLGWIDE) ) + if ( (pd->option&PDO_DLGWIDE) ) { controlK.orig.x += 10; - else if ( (pd->option&PDO_DLGNARROW)== 0) + } else if ( (pd->option&PDO_DLGNARROW)== 0) { controlK.orig.x += 3; - if ( pd->winLabel && ( pd->type!=PD_BUTTON ) ) + } + if ( pd->winLabel && ( pd->type!=PD_BUTTON ) ) { controlK.orig.x += wLabelWidth( _(pd->winLabel) ); + } } else if ( inx != 0 ) { controlK.orig.x = columnK.orig.x + labelW[inx]; controlK.orig.y = controlK.term.y; - if ( (pd->option&PDO_DLGWIDE) ) + if ( (pd->option&PDO_DLGWIDE) ) { controlK.orig.y += 10; - else if ( (pd->option&PDO_DLGNARROW)== 0) + } else if ( (pd->option&PDO_DLGNARROW)== 0) { controlK.orig.y += 3; + } } if ( (pd->option&PDO_DLGSETY) ) { columnK.term.x = controlK.orig.x; @@ -2548,10 +2822,13 @@ static void LayoutControls( /* * Custom layout and create/postion control */ - if (group->layoutProc) - group->layoutProc( pd, inx, columnK.orig.x+labelW[inx], &controlK.orig.x, &controlK.orig.y ); - if ( pd->nameStr ) + if (group->layoutProc) { + group->layoutProc( pd, inx, columnK.orig.x+labelW[inx], &controlK.orig.x, + &controlK.orig.y ); + } + if ( pd->nameStr ) { strcpy( helpStrP, pd->nameStr ); + } proc( pd, helpStr, controlK.orig.x, controlK.orig.y ); /* * Set control term @@ -2560,30 +2837,35 @@ static void LayoutControls( controlSize_y = wControlGetHeight( pd->control ); controlK.term.x = controlK.orig.x+controlSize_x; if ( (pd->option&PDO_DLGHORZ)==0 || - controlK.term.y < controlK.orig.y+controlSize_y ) + controlK.term.y < controlK.orig.y+controlSize_y ) { controlK.term.y = controlK.orig.y+controlSize_y; + } if ( retW && pd->nameStr ) { char * cp; strcpy( message, pd->nameStr ); - for ( cp=message; *cp; cp++ ) if ( *cp == '-' ) *cp = '_'; + for ( cp=message; *cp; cp++ ) if ( *cp == '-' ) { *cp = '_'; } } /* * Set column term */ if ( (pd->option&PDO_DLGIGNOREX) == 0 ) { if ( (pd->option&PDO_DLGUNDERCMDBUTT) == 0 ) { - if ( columnK.term.x < controlK.term.x ) + if ( columnK.term.x < controlK.term.x ) { columnK.term.x = controlK.term.x; + } } else { - if ( columnK.term.x < controlK.term.x-90 ) + if ( columnK.term.x < controlK.term.x-90 ) { columnK.term.x = controlK.term.x-90; + } } } - if ( columnK.term.y < controlK.term.y ) + if ( columnK.term.y < controlK.term.y ) { columnK.term.y = controlK.term.y; + } if ( hasBox ) - if ( boxPos[boxCnt] < columnK.term.y+2 ) + if ( boxPos[boxCnt] < columnK.term.y+2 ) { boxPos[boxCnt] = columnK.term.y+2; + } if ( (pd->option&PDO_DLGBOXEND) ) { columnK.term.y += 8; boxCnt++; @@ -2592,22 +2874,26 @@ static void LayoutControls( /* * Set window term */ - if ( windowK.term.x < columnK.term.x ) + if ( windowK.term.x < columnK.term.x ) { windowK.term.x = columnK.term.x; - if ( windowK.term.y < columnK.term.y ) + } + if ( windowK.term.y < columnK.term.y ) { windowK.term.y = columnK.term.y; - if ( (pd[1].option&PDO_DLGCMDBUTTON) ) + } + if ( (pd[1].option&PDO_DLGCMDBUTTON) ) { areCmdButtons = TRUE; + } SkipControl: if ( (!inCmdButtons) && - (pd==&group->paramPtr[group->paramCnt-1] || (pd[1].option&PDO_DLGCMDBUTTON)) ) { + (pd==&group->paramPtr[group->paramCnt-1] || (pd[1].option&PDO_DLGCMDBUTTON)) ) { columnK.orig.x = columnK.term.x + DlgSepMid; if ( boxCnt ) { boxTop = DlgSepTop; if ( group->boxs == NULL ) { group->boxs = (wBox_p*)MyMalloc( boxCnt * sizeof *(wBox_p*)0 ); for ( box=0; box<boxCnt; box++ ) { - group->boxs[box] = wBoxCreate( group->win, DlgSepLeft, boxTop, NULL, wBoxThickW, columnK.term.x, boxPos[box]-boxTop ); + group->boxs[box] = wBoxCreate( group->win, DlgSepLeft, boxTop, NULL, wBoxThickW, + columnK.term.x, boxPos[box]-boxTop ); boxTop = boxPos[box] + 4; } } else { @@ -2622,69 +2908,88 @@ SkipControl: columnK.orig.y = columnK.term.y = DlgSepTop; controlK = columnK; if ( group->okB ) { - wControlSetPos( (wControl_p)(lastB=group->okB), columnK.orig.x, columnK.orig.y ); + wControlSetPos( (wControl_p)(lastB=group->okB), columnK.orig.x, + columnK.orig.y ); controlK.term.y += wControlGetHeight((wControl_p)group->okB); columnK.term.y = controlK.term.y + 3; } inCmdButtons = TRUE; } - LOG( log_paramLayout, 1, (" Col %dx%d..%dx%d Ctl %dx%d..%dx%d\n", - columnK.orig.x, columnK.orig.y, columnK.term.x, columnK.term.y, - controlK.orig.x, controlK.orig.y, controlK.term.x, controlK.term.y ) ) - if ( windowK.term.x < columnK.term.x ) + if ( (pd->option & PDO_DLGIGNORE) == 0 ) { + LOG( log_paramLayout, 2, (" Col %dx%d..%dx%d Ctl %dx%d..%dx%d\n", + columnK.orig.x, columnK.orig.y, columnK.term.x, columnK.term.y, + controlK.orig.x, controlK.orig.y, controlK.term.x, controlK.term.y ) ) + } + if ( windowK.term.x < columnK.term.x ) { windowK.term.x = columnK.term.x; - if ( windowK.term.y < columnK.term.y ) + } + if ( windowK.term.y < columnK.term.y ) { windowK.term.y = columnK.term.y; + } } if ( group->cancelB ) { - if ( areCmdButtons ) + if ( areCmdButtons ) { columnK.term.y += 10; - else if ( group->okB ) + } else if ( group->okB ) { columnK.term.y += 3; - wControlSetPos( (wControl_p)(lastB=group->cancelB), columnK.orig.x, columnK.term.y ); + } + wControlSetPos( (wControl_p)(lastB=group->cancelB), columnK.orig.x, + columnK.term.y ); columnK.term.y += wControlGetHeight((wControl_p)group->cancelB); } if ( group->helpB ) { columnK.term.y += 10; - wControlSetPos( (wControl_p)(lastB=group->helpB), columnK.orig.x, columnK.term.y ); + wControlSetPos( (wControl_p)(lastB=group->helpB), columnK.orig.x, + columnK.term.y ); columnK.term.y += wControlGetHeight((wControl_p)group->helpB); } if ( lastB ) { controlK.term.x = controlK.orig.x + wControlGetWidth((wControl_p)lastB); - if ( columnK.term.x < controlK.term.x ) + if ( columnK.term.x < controlK.term.x ) { columnK.term.x = controlK.term.x; + } } - if ( windowK.term.x < columnK.term.x ) + if ( windowK.term.x < columnK.term.x ) { windowK.term.x = columnK.term.x; - if ( windowK.term.y < columnK.term.y ) + } + if ( windowK.term.y < columnK.term.y ) { windowK.term.y = columnK.term.y; + } - if ( retW ) + if ( retW ) { *retW = windowK.term.x; - if ( retH ) + } + if ( retH ) { *retH = windowK.term.y; + } + LOG( log_paramLayout, 1, ( "LayoutControls:%s orig:%dx%d compute:%dx%d\n", + group->nameStr, group->origW, group->origH, windowK.term.x, windowK.term.y ) ); } static void ParamDlgProc( - wWin_p win, - winProcEvent e, - void * refresh, - void * data ) + wWin_p win, + winProcEvent e, + void * refresh, + void * data ) { paramGroup_p pg = (paramGroup_p)data; + static int iResizeCnt = 0; switch (e) { case wClose_e: - if ( pg->changeProc ) + if ( pg->changeProc ) { pg->changeProc( pg, -1, NULL ); - if ( (pg->options&PGO_NODEFAULTPROC) == 0 ) + } + if ( (pg->options&PGO_NODEFAULTPROC) == 0 ) { DefaultProc( win, wClose_e, data ); + } break; case wResize_e: - if (win == mapW) - pg->changeProc(pg, wResize_e, NULL); - else - LayoutControls( pg, ParamPositionControl, NULL, NULL ); + if (win == mapW && bInReadTracks ) { + break; + } + LOG( log_paramLayout, 1, ( "ParamDlgProc %d/n", iResizeCnt++ ) ); + LayoutControls( pg, ParamPositionControl, NULL, NULL ); break; default: break; @@ -2692,7 +2997,7 @@ static void ParamDlgProc( } /** - * Create a dialog box from data definition. + * Create a dialog box from data definition. * * \param IN group data definition for the dialog * \param IN title title of the new dialog @@ -2706,15 +3011,15 @@ static void ParamDlgProc( */ wWin_p ParamCreateDialog( - paramGroup_p group, - char * title, - char * okLabel, - paramActionOkProc okProc, - paramActionCancelProc cancelProc, - BOOL_T needHelpButton, - paramLayoutProc layoutProc, - long winOption, - paramChangeProc changeProc ) + paramGroup_p group, + char * title, + char * okLabel, + paramActionOkProc okProc, + paramActionCancelProc cancelProc, + BOOL_T needHelpButton, + paramLayoutProc layoutProc, + long winOption, + paramChangeProc changeProc ) { char helpStr[STR_SHORT_SIZE]; wWinPix_t w0, h0; @@ -2726,39 +3031,53 @@ wWin_p ParamCreateDialog( group->layoutProc = layoutProc; group->changeProc = changeProc; group->winOption = winOption; - if ( (winOption&F_CENTER) == 0 ) + if ( (winOption&F_CENTER) == 0 ) { winOption |= F_RECALLPOS; - if ( (winOption&F_RESIZE) != 0 ) + } + if ( (winOption&F_RESIZE) != 0 ) { winOption |= F_RECALLSIZE; + } - group->win = wWinPopupCreate( mainW, DlgSepRight, DlgSepFrmBottom, helpStr, title, group->nameStr, F_AUTOSIZE|winOption, ParamDlgProc, group ); + group->win = wWinPopupCreate( mainW, DlgSepRight, DlgSepFrmBottom, helpStr, + title, group->nameStr, F_AUTOSIZE|winOption, ParamDlgProc, group ); if ( okLabel && okProc ) { sprintf( helpStr, "%s-ok", group->nameStr ); - group->okB = wButtonCreate( group->win, 0, 0, helpStr, okLabel, BB_DEFAULT, 0, ParamButtonOk, group ); + group->okB = wButtonCreate( group->win, 0, 0, helpStr, okLabel, BB_DEFAULT, 0, + ParamButtonOk, group ); } if ( group->cancelProc ) { - group->cancelB = wButtonCreate( group->win, 0, 0, NULL, cancelLabel, BB_CANCEL, 0, ParamButtonCancel, group ); + group->cancelB = wButtonCreate( group->win, 0, 0, NULL, cancelLabel, BB_CANCEL, + 0, ParamButtonCancel, group ); } if ( needHelpButton ) { sprintf( helpStr, "cmd%s", group->nameStr ); helpStr[3] = toupper((unsigned char)helpStr[3]); - group->helpB = wButtonCreate( group->win, 0, 0, NULL, _("Help"), BB_HELP, 0, (wButtonCallBack_p)wHelp, MyStrdup(helpStr) ); + group->helpB = wButtonCreate( group->win, 0, 0, NULL, _("Help"), BB_HELP, 0, + (wButtonCallBack_p)wHelp, MyStrdup(helpStr) ); } + LOG( log_paramLayout, 1, ( "ParamCreateDialog/" ) ); LayoutControls( group, ParamCreateControl, &group->origW, &group->origH ); group->origW += DlgSepRight; group->origH += DlgSepBottom; wWinGetSize( group->win, &w0, &h0 ); + LOG( log_paramLayout, 1, ( " winSize: %dx%d\n", w0, h0 ) ); if ( (winOption&F_RESIZE) ) { if ( group->origW != w0 || - group->origH != h0 ) { + group->origH != h0 ) { + LOG( log_paramLayout, 1, ( " RESIZE+change/" ) ); LayoutControls( group, ParamPositionControl, NULL, NULL ); } + wWinPix_t scr_w, scr_h; + wGetDisplaySize(&scr_w, &scr_h); + wSetGeometry(group->win, group->origW, scr_w-10, group->origH, scr_h, -1, -1, + -1); } else { w0 = max(group->origW, w0); h0 = max(group->origH, h0); + LOG( log_paramLayout, 1, ( " wWinSetSize( %dx%d )\n", w0, h0 ) ); wWinSetSize( group->win, w0, h0 ); } @@ -2771,13 +3090,15 @@ wWin_p ParamCreateDialog( * */ EXPORT void ParamLayoutDialog( - paramGroup_p pg ) + paramGroup_p pg ) { wWinPix_t w, h; + LOG( log_paramLayout, 1, ( "ParamLayoutDialog/" ) ); LayoutControls( pg, ParamPositionControl, &w, &h ); w += DlgSepRight; h += DlgSepBottom; if ( w != pg->origW || h != pg->origH ) { + LOG( log_paramLayout, 1, ( " wWinSetSize( %dx%d )\n", w, h ) ); wWinSetSize( pg->win, w, h ); pg->origW = w; pg->origH = h; @@ -2786,17 +3107,18 @@ EXPORT void ParamLayoutDialog( EXPORT void ParamDialogOkActive( - paramGroup_p pg, - int active ) + paramGroup_p pg, + int active ) { - if ( pg->okB ) + if ( pg->okB ) { wControlActive( (wControl_p)pg->okB, active ); + } } EXPORT void ParamCreateControls( - paramGroup_p pg, - paramChangeProc changeProc ) + paramGroup_p pg, + paramChangeProc changeProc ) { paramData_p pd; char helpStr[STR_SHORT_SIZE], * helpStrP; @@ -2807,8 +3129,9 @@ EXPORT void ParamCreateControls( pd->group = pg; strcpy( helpStrP, pd->nameStr ); ParamCreateControl( pd, helpStr, 0, 0 ); - if ( pd->type != PD_MENUITEM && pd->control ) + if ( pd->type != PD_MENUITEM && pd->control ) { wControlShow( pd->control, FALSE ); + } } pg->changeProc = changeProc; } @@ -2816,15 +3139,13 @@ EXPORT void ParamCreateControls( EXPORT void ParamInit( void ) { - if (paramGroups_init) return; + if (paramGroups_init) { return; } AddPlaybackProc( "PARAMETER", ParamPlayback, NULL ); AddPlaybackProc( "PARAMCHECK", ParamCheck, NULL ); log_paramLayout = LogFindIndex( "paramlayout" ); log_paraminput = LogFindIndex( "paraminput" ); - paramGroups_da.cnt = 0; - paramGroups_da.max = 0; - paramGroups_da.ptr = NULL; + DYNARR_INIT( paramGroup_p, paramGroups_da ); paramGroups_init = TRUE; } diff --git a/app/bin/param.h b/app/bin/param.h index d72553e..004dcb5 100644 --- a/app/bin/param.h +++ b/app/bin/param.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef PARAM_H @@ -28,24 +28,29 @@ typedef struct turnoutInfo_t * turnoutInfo_p; +extern wWinPix_t DlgSepTop; +extern wWinPix_t DlgSepBottom; +extern wWinPix_t DlgSepLeft; +extern wWinPix_t DlgSepRight; + typedef enum { - PD_LONG, - PD_FLOAT, - PD_RADIO, - PD_TOGGLE, - PD_STRING, - PD_LIST, - PD_DROPLIST, - PD_COMBOLIST, - PD_BUTTON, - PD_COLORLIST, - PD_MESSAGE, /* static text */ - PD_DRAW, - PD_TEXT, - PD_MENU, - PD_MENUITEM, - PD_BITMAP - } parameterType; + PD_LONG, + PD_FLOAT, + PD_RADIO, + PD_TOGGLE, + PD_STRING, + PD_LIST, + PD_DROPLIST, + PD_COMBOLIST, + PD_BUTTON, + PD_COLORLIST, + PD_MESSAGE, /* static text */ + PD_DRAW, + PD_TEXT, + PD_MENU, + PD_MENUITEM, + PD_BITMAP +} parameterType; // PD_FLOAT modifiers #define PDO_DIM (1L<<0) @@ -102,60 +107,61 @@ typedef struct paramGroup_t *paramGroup_p; #define PDO_NORANGECHECK_LOW (1<<0) #define PDO_NORANGECHECK_HIGH (1<<1) typedef struct { - long low; - long high; - wWinPix_t width; - int rangechecks; - } paramIntegerRange_t; + long low; + long high; + wWinPix_t width; + int rangechecks; +} paramIntegerRange_t; typedef struct { - FLOAT_T low; - FLOAT_T high; - wWinPix_t width; - int rangechecks; - } paramFloatRange_t; + FLOAT_T low; + FLOAT_T high; + wWinPix_t width; + int rangechecks; +} paramFloatRange_t; typedef struct { - wWinPix_t width; - wWinPix_t height; - wDrawRedrawCallBack_p redraw; - playbackProc action; - drawCmd_p d; - } paramDrawData_t; + wWinPix_t width; + wWinPix_t height; + wDrawRedrawCallBack_p redraw; + playbackProc action; + drawCmd_p d; +} paramDrawData_t; typedef struct { - wIndex_t number; - wWinPix_t width; - int colCnt; - wWinPix_t * colWidths; - const char * * colTitles; - wWinPix_t height; - } paramListData_t; + wIndex_t number; + wWinPix_t width; + int colCnt; + wWinPix_t * colWidths; + const char * * colTitles; + wWinPix_t height; +} paramListData_t; typedef struct { - wWinPix_t width; - wWinPix_t height; - } paramTextData_t; + wWinPix_t width; + wWinPix_t height; +} paramTextData_t; typedef union { - long l; - FLOAT_T f; - char * s; - turnoutInfo_p p; - wDrawColor dc; - } paramOldData_t; + long l; + FLOAT_T f; + char * s; + turnoutInfo_p p; + wDrawColor dc; +} paramOldData_t; typedef struct { - parameterType type; - void * valueP; - const char * nameStr; - long option; - const void * winData; - const char * winLabel; - long winOption; - void * context; - unsigned int max_string; - wControl_p control; - paramGroup_p group; - paramOldData_t oldD, demoD; - wBool_t enter_pressed; - wBool_t bInvalid; - } paramData_t, *paramData_p; + parameterType type; + void * valueP; + const char * nameStr; + long option; + const void * winData; + const char * winLabel; + long winOption; + void * context; + unsigned int max_string; + wControl_p control; + paramGroup_p group; + paramOldData_t oldD, demoD; + wBool_t enter_pressed; + wBool_t bInvalid; + wBool_t bShown; +} paramData_t, *paramData_p; typedef void (*paramGroupProc_t) ( long, long ); @@ -171,36 +177,56 @@ typedef void (*paramGroupProc_t) ( long, long ); #define PGO_PREFDRAWGROUP (1<<9) #define PGO_PREFMISC (1<<10) -typedef void (*paramLayoutProc)( paramData_t *, int, wWinPix_t, wWinPix_t *, wWinPix_t * ); +typedef void (*paramLayoutProc)( paramData_t *, int, wWinPix_t, wWinPix_t *, + wWinPix_t * ); typedef void (*paramActionOkProc)( void * ); typedef void (*paramActionCancelProc)( wWin_p ); typedef void (*paramChangeProc)( paramGroup_p, int, void * ); typedef struct paramGroup_t { - char * nameStr; - long options; - paramData_p paramPtr; - int paramCnt; - paramActionOkProc okProc; - paramActionCancelProc cancelProc; - paramLayoutProc layoutProc; - long winOption; - paramChangeProc changeProc; - long action; - paramGroupProc_t proc; - wWin_p win; - wButton_p okB; - wButton_p cancelB; - wButton_p helpB; - wWinPix_t origW; - wWinPix_t origH; - wBox_p * boxs; - } paramGroup_t; + char * nameStr; + long options; + paramData_p paramPtr; + int paramCnt; + paramActionOkProc okProc; + paramActionCancelProc cancelProc; + paramLayoutProc layoutProc; + long winOption; + paramChangeProc changeProc; + long action; + paramGroupProc_t proc; + wWin_p win; + wButton_p okB; + wButton_p cancelB; + wButton_p helpB; + wWinPix_t origW; + wWinPix_t origH; + wBox_p * boxs; +} paramGroup_t; wIndex_t ColorTabLookup( wDrawColor ); extern char * PREFSECT; // extern char decodeErrorStr[STR_SHORT_SIZE]; + + +#define ANGLE_POLAR (0) +#define ANGLE_CART (1) +extern long angleSystem; +#define PutAngle(X) ((angleSystem==ANGLE_POLAR)?(X):NormalizeAngle(90.0-(X))) + +#define DISTFMT_DECS 0x00FF +#define DISTFMT_FMT 0x0300 +#define DISTFMT_FMT_NONE 0x0000 +#define DISTFMT_FMT_SHRT 0x0100 +#define DISTFMT_FMT_LONG 0x0200 +#define DISTFMT_FMT_MM 0x0100 +#define DISTFMT_FMT_CM 0x0200 +#define DISTFMT_FMT_M 0x0300 +#define DISTFMT_FRACT 0x0400 +#define DISTFMT_FRACT_NUM 0x0000 +#define DISTFMT_FRACT_FRC 0x0400 + FLOAT_T DecodeFloat( wString_p, BOOL_T * ); FLOAT_T DecodeDistance( wString_p, BOOL_T * ); char * FormatLong( long ); @@ -224,7 +250,6 @@ void ParamRestoreAll( void ); void ParamSaveAll( void ); void ParamMenuPush( void * ); -extern int paramHiliteFast; void ParamHilite( wWin_p, wControl_p, BOOL_T ); wBool_t ParamCheckInputs( paramGroup_p pg, wControl_p b ); @@ -244,7 +269,8 @@ long GetChanges(paramGroup_p pg); if ( HS ) GetBalloonHelpStr(HS); #define PD_F_ALT_CANCELLABEL (1L<<30) /**<use Close or Cancel for the discard button */ -wWin_p ParamCreateDialog( paramGroup_p, char *, char *, paramActionOkProc, paramActionCancelProc, BOOL_T, paramLayoutProc, long, paramChangeProc ); +wWin_p ParamCreateDialog( paramGroup_p, char *, char *, paramActionOkProc, + paramActionCancelProc, BOOL_T, paramLayoutProc, long, paramChangeProc ); void ParamCreateControls( paramGroup_p, paramChangeProc ); void ParamLayoutDialog( paramGroup_p ); @@ -252,6 +278,5 @@ void ParamDialogOkActive( paramGroup_p, int ); void ParamResetInvalid( wWin_p win ); -#define ParamControlShow( PG, INX, SHOW ) \ - wControlShow( ((PG)->paramPtr)[INX].control, SHOW ) +void ParamControlShow( paramGroup_t *, wIndex_t, wBool_t ); #endif diff --git a/app/bin/paramfile.c b/app/bin/paramfile.c index f72f405..994a47d 100644 --- a/app/bin/paramfile.c +++ b/app/bin/paramfile.c @@ -2,23 +2,23 @@ * Handling of parameter files */ - /* XTrackkCad - Model Railroad CAD - * Copyright (C) 2019 Martin Fischer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ +/* XTrackkCad - Model Railroad CAD + * Copyright (C) 2019 Martin Fischer + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ #include "common.h" #include "compound.h" @@ -26,7 +26,6 @@ #include "custom.h" #include "fileio.h" #include "layout.h" -#include "misc2.h" #include "paths.h" #include "include/paramfile.h" #include "include/paramfilelist.h" @@ -36,7 +35,7 @@ static long paramCheckSum; typedef enum paramFileState(*GetCompatibilityFunction)(int index, - SCALEINX_T scale); + SCALEINX_T scale); GetCompatibilityFunction GetCompatibility[] = { GetTrackCompatibility, @@ -55,7 +54,7 @@ GetCompatibilityFunction GetCompatibility[] = { */ wBool_t IsParamValid( - int fileInx) + int fileInx) { if (fileInx == PARAM_DEMO) { return (curDemo >= 0); @@ -82,13 +81,13 @@ SetParamFileDir(char *fullPath) } char * GetParamFileName( - int fileInx) + int fileInx) { return paramFileInfo(fileInx).name; } char * GetParamFileContents( - int fileInx) + int fileInx) { return paramFileInfo(fileInx).contents; } @@ -137,7 +136,7 @@ void SetParamFileState(int index) //Set yet? if (scale>=0) { for (int i = 0; i < COMPATIBILITYCHECKSCOUNT && state < PARAMFILE_FIT && - state != PARAMFILE_UNLOADED; i++) { + state != PARAMFILE_UNLOADED; i++) { newState = (*GetCompatibility[i])(index, scale); if (newState > state || newState == PARAMFILE_UNLOADED) { state = newState; @@ -155,12 +154,12 @@ void SetParamFileState(int index) * * \returns True if it succeeds, false if it fails. */ - + static bool CheckFileReadable(const char *file) { if(!access( file, R_OK )) { - return TRUE; + return TRUE; } else { return FALSE; } @@ -204,7 +203,8 @@ ReloadDeletedParamFile(int fileindex) { curParamFileIndex = fileindex; paramFileInfo(curParamFileIndex).valid = TRUE; - paramFileInfo(curParamFileIndex).deleted = !ReadParams(0, NULL, paramFileInfo(curParamFileIndex).name); + paramFileInfo(curParamFileIndex).deleted = !ReadParams(0, NULL, + paramFileInfo(curParamFileIndex).name); paramFileInfo(curParamFileIndex).contents = MyStrdup(curContents); SetParamFileState(curParamFileIndex); @@ -222,9 +222,9 @@ ReloadDeletedParamFile(int fileindex) */ bool ReadParams( - long key, - const char * dirName, - const char * fileName) + long key, + const char * dirName, + const char * fileName) { FILE * oldFile; char *cp; @@ -233,6 +233,7 @@ bool ReadParams( long oldCheckSum; long checkSum = 0; BOOL_T checkSummed; + BOOL_T bFoundContents = FALSE; paramVersion = -1; if (dirName) { @@ -255,7 +256,7 @@ bool ReadParams( SetUserLocale(); NoticeMessage(MSG_OPEN_FAIL, _("Continue"), NULL, _("Parameter"), paramFileName, - strerror(errno)); + strerror(errno)); return FALSE; } @@ -288,6 +289,7 @@ bool ReadParams( /* Close file and reset the locale settings */ if (paramFile) { fclose(paramFile); + paramFile = NULL; } SetUserLocale(); return FALSE; @@ -312,8 +314,12 @@ bool ReadParams( #ifdef UTFCONVERT ConvertUTF8ToSystem(paramLine + 9); #endif - curContents = MyStrdup(paramLine + 9); - curSubContents = curContents; + if ( bFoundContents == FALSE ) { + // Only use the first CONTENTS + curContents = MyStrdup(paramLine + 9); + curSubContents = curContents; + bFoundContents = TRUE; + } skip = FALSE; } else if (strncmp(paramLine, "SUBCONTENTS ", 12) == 0) { #ifdef UTFCONVERT @@ -324,17 +330,20 @@ bool ReadParams( } else if (strncmp(paramLine, "PARAM ", 6) == 0) { paramVersion = strtol(paramLine + 6, &cp, 10); if (cp) - while (*cp && isspace((unsigned char)*cp)) cp++; + while (*cp && isspace((unsigned char)*cp)) { cp++; } if (paramVersion > iParamVersion) { if (cp && *cp) { - NoticeMessage(MSG_PARAM_UPGRADE_VERSION1, _("Ok"), NULL, paramVersion, iParamVersion, sProdName, cp); + NoticeMessage(MSG_PARAM_UPGRADE_VERSION1, _("Ok"), NULL, paramVersion, + iParamVersion, sProdName, cp); } else { - NoticeMessage(MSG_PARAM_UPGRADE_VERSION2, _("Ok"), NULL, paramVersion, iParamVersion, sProdName); + NoticeMessage(MSG_PARAM_UPGRADE_VERSION2, _("Ok"), NULL, paramVersion, + iParamVersion, sProdName); } break; } if (paramVersion < iMinParamVersion) { - NoticeMessage(MSG_PARAM_BAD_FILE_VERSION, _("Ok"), NULL, paramVersion, iMinParamVersion, sProdName); + NoticeMessage(MSG_PARAM_BAD_FILE_VERSION, _("Ok"), NULL, paramVersion, + iMinParamVersion, sProdName); break; } } else if (skip && (strncmp(paramLine, " ", 1) == 0)) { @@ -344,21 +353,24 @@ bool ReadParams( } else { for (pc = 0; pc < paramProc_da.cnt; pc++) { if (strncmp(paramLine, paramProc(pc).name, - strlen(paramProc(pc).name)) == 0) { + strlen(paramProc(pc).name)) == 0) { skip = FALSE; //Stop skip so we re-message paramProc(pc).proc(paramLine); goto nextLine; } } if (!skip) { - if (InputError(_("Unknown param file line - skip until next good object?"), TRUE)) { //OK to carry on + if (InputError(_("Unknown param file line - skip until next good object?"), + TRUE)) { //OK to carry on /* SKIP until next main line we recognize */ skip = TRUE; skipLines++; goto nextLine; } else { - if (skipLines > 0) - NoticeMessage(MSG_PARAM_LINES_SKIPPED, _("Ok"), NULL, paramFileName, skipLines); + if (skipLines > 0) { + NoticeMessage(MSG_PARAM_LINES_SKIPPED, _("Ok"), NULL, paramFileName, + skipLines); + } if (paramFile) { fclose(paramFile); paramFile = NULL; @@ -373,7 +385,7 @@ bool ReadParams( } skipLines++; } - nextLine: +nextLine: ; } if (key) { @@ -381,6 +393,7 @@ bool ReadParams( /* Close file and reset the locale settings */ if (paramFile) { fclose(paramFile); + paramFile = NULL; } SetUserLocale(); @@ -389,10 +402,13 @@ bool ReadParams( return FALSE; } } - if (skipLines > 0) - NoticeMessage(MSG_PARAM_LINES_SKIPPED, _("Ok"), NULL, paramFileName, skipLines); + if (skipLines > 0) { + NoticeMessage(MSG_PARAM_LINES_SKIPPED, _("Ok"), NULL, paramFileName, + skipLines); + } if (paramFile) { fclose(paramFile); + paramFile = NULL; } free(paramFileName); paramFileName = NULL; diff --git a/app/bin/paramfilelist.c b/app/bin/paramfilelist.c index e922f73..f6703f3 100644 --- a/app/bin/paramfilelist.c +++ b/app/bin/paramfilelist.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -28,7 +28,6 @@ #include "dynstring.h" #include "fileio.h" #include "layout.h" -#include "misc2.h" #include "paths.h" #include "include/paramfile.h" #include "include/paramfilelist.h" @@ -40,6 +39,7 @@ dynArr_t paramFileInfo_da; int curParamFileIndex = PARAM_DEMO; static int log_params; +static int log_paramupdate; static char * customPath; static char * customPathBak; @@ -51,7 +51,7 @@ static char * customPathBak; int GetParamFileCount() { - return (paramFileInfo_da.cnt); + return (paramFileInfo_da.cnt); } /** @@ -66,9 +66,9 @@ ReadParamError(char *file) DynString error_msg; DynStringMalloc(&error_msg, 100); DynStringPrintf(&error_msg, - _("The parameter file: %s could not be found and was probably deleted or moved. " - "The file is removed from the active parameter file list."), - file); + _("The parameter file: %s could not be found and was probably deleted or moved. " + "The file is removed from the active parameter file list."), + file); wNoticeEx(NT_ERROR, DynStringToCStr(&error_msg), "OK", NULL); DynStringFree(&error_msg); } @@ -87,70 +87,108 @@ ReadParamError(char *file) static BOOL_T UpdateParamFiles(void) { - char fileName[STR_LONG_SIZE], *fileNameP; - const char * cp; - FILE * updateF; - long updateTime; - long lastTime; - - MakeFullpath(&fileNameP, libDir, "xtrkcad.upd", NULL); - updateF = fopen(fileNameP, "r"); - free(fileNameP); - if (updateF == NULL) { - return FALSE; - } - if (fgets(message, sizeof message, updateF) == NULL) { - NoticeMessage("short file: xtrkcad.upd", _("Ok"), NULL); - fclose(updateF); - return FALSE; - } - wPrefGetInteger("file", "updatetime", &lastTime, 0); - updateTime = atol(message); - if (lastTime >= updateTime) { - fclose(updateF); - return FALSE; - } - - while ((fgets(fileName, STR_LONG_SIZE, updateF)) != NULL) { - FILE * paramF; - char * contents; - - Stripcr(fileName); - InfoMessage(_("Updating %s"), fileName); - MakeFullpath(&fileNameP, libDir, "params", fileName, NULL); - paramF = fopen(fileNameP, "r"); - if (paramF == NULL) { - NoticeMessage(MSG_PRMFIL_OPEN_NEW, _("Ok"), NULL, fileNameP); - free(fileNameP); - continue; - } - contents = NULL; - while ((fgets(message, sizeof message, paramF)) != NULL) { - if (strncmp(message, "CONTENTS", 8) == 0) { - Stripcr(message); - contents = message + 9; - break; - } - } - fclose(paramF); - if (contents == NULL) { - NoticeMessage(MSG_PRMFIL_NO_CONTENTS, _("Ok"), NULL, fileNameP); - free(fileNameP); - continue; - } - cp = wPrefGetString("Parameter File Map", contents); - wPrefSetString("Parameter File Map", contents, fileNameP); - if (cp != NULL && *cp != '\0') { - /* been there, done that */ - free(fileNameP); - continue; - } - - free(fileNameP); - } - fclose(updateF); - wPrefSetInteger("file", "updatetime", updateTime); - return TRUE; + char fileName[STR_LONG_SIZE], *fileNameP; +// const char * cp; + FILE * updateF; + long updateTime = -1; + long lastTime; + + MakeFullpath(&fileNameP, libDir, "xtrkcad.upd", NULL); + updateF = fopen(fileNameP, "r"); + free(fileNameP); + if (updateF == NULL) { + return FALSE; + } + wPrefGetInteger("file", "updatetime", &lastTime, 0); + + while ((fgets(fileName, STR_LONG_SIZE, updateF)) != NULL) { + if ( fileName[0] == '#' ) { + continue; + } + if ( updateTime == -1 ) { + updateTime = atol(fileName); + LOG1( log_paramupdate, ( "UpdateParamFiles Last: %ld, Update: %ld\n", lastTime, + updateTime ) ); + if ( updateTime == 0 ) { + NoticeMessage( "xtrkcad.upd : invalid Update Time", _("OK"), NULL ); + fclose(updateF); + return FALSE; + } + if (lastTime >= updateTime) { + fclose(updateF); + return FALSE; + } + continue; + } + FILE * paramF; + + Stripcr(fileName); + InfoMessage(_("Updating %s"), fileName); + LOG1( log_paramupdate, ( "Updating %s\n", fileName ) ); + MakeFullpath(&fileNameP, libDir, "params", fileName, NULL); + paramF = fopen(fileNameP, "r"); + if (paramF == NULL) { + NoticeMessage(MSG_PRMFIL_OPEN_NEW, _("Ok"), NULL, fileNameP); + free(fileNameP); + continue; + } + char * newContents = NULL; + char * oldContents = NULL; + while ((fgets(message, sizeof message, paramF)) != NULL) { + if (strncmp(message, "CONTENTS ", 9) == 0) { + Stripcr(message); + if ( newContents == NULL ) { + // first CONTENTS + newContents = MyStrdup(message + 9); + // Get old CONTENTS->FILENAME mapping + char * cp = wPrefGetString("Parameter File Map", newContents); + if ( cp ) { + LOG1( log_paramupdate, ( "ParmUpdate: Upd CONTENTS %s (was %s) -> %s\n", + newContents, + cp?cp:"<>", fileNameP ) ); + } else { + LOG1( log_paramupdate, ( "ParmUpdate: New CONTENTS %s\n", newContents ) ); + } + // Update CONTENTS->FILENAME mapping + wPrefSetString("Parameter File Map", newContents, fileNameP); + } else { + // Subsequent old CONTENTS + oldContents = message + 9; + LOG1( log_paramupdate, ( " Old CONTENTS %s\n", oldContents ) ); + // Check 'Parameter Files Names' map + for (int fileNo = 1; ; fileNo++) { + char fileNoS[4+9+1]; + sprintf(fileNoS, "File%d", fileNo); + char * prevContents = wPrefGetString("Parameter File Names", fileNoS); + if (prevContents == NULL || *prevContents == '\0') { + // End of list + break; + } + if ( strcmp( oldContents, prevContents ) == 0 ) { + // Update contents index map + LOG1( log_paramupdate, ( "ParamUpdate: Found at %s -> %s\n", fileNoS, + newContents ) ); + wPrefSetString( "Parameter File Names", fileNoS, newContents ); + break; + } + } + } + } + } + if ( newContents ) { + MyFree( newContents ); + } + fclose(paramF); + if (newContents == NULL) { + NoticeMessage(MSG_PRMFIL_NO_CONTENTS, _("Ok"), NULL, fileNameP); + } + + free(fileNameP); + } + fclose(updateF); + LOG1( log_paramupdate, ( "Param updatetime -> %d\n", updateTime ) ); + wPrefSetInteger("file", "updatetime", updateTime); + return TRUE; } /** @@ -159,57 +197,67 @@ static BOOL_T UpdateParamFiles(void) */ void LoadParamFileList(void) { - int fileNo; - BOOL_T updated = FALSE; - long *favoriteList = NULL; - long favorites; - int nextFavorite = 0; - - updated = UpdateParamFiles(); - - wPrefGetIntegerBasic(FAVORITESECTION, FAVORITETOTALS, &favorites, 0); - if (favorites) { - DynString topic; - favoriteList = MyMalloc(sizeof(long)*favorites); - if (!favoriteList) { - AbortProg("Couldn't allocate memory for favorite list!\n"); - } - - DynStringMalloc(&topic, 16); - for (int i = 0; i < favorites; i++) { - DynStringPrintf(&topic, FAVORITEKEY, i); - wPrefGetIntegerBasic(FAVORITESECTION, DynStringToCStr(&topic), &favoriteList[i], - 0); - } - DynStringFree(&topic); - } - - for (fileNo = 1; ; fileNo++) { - char *fileName; - const char * contents; - enum paramFileState structState = PARAMFILE_UNLOADED; - - - sprintf(message, "File%d", fileNo); - contents = wPrefGetString("Parameter File Names", message); - if (contents == NULL || *contents == '\0') { - break; - } - InfoMessage("Parameters for %s", contents); - fileName = wPrefGetString("Parameter File Map", contents); - if (fileName == NULL || *fileName == '\0') { - NoticeMessage(MSG_PRMFIL_NO_MAP, _("Ok"), NULL, contents); - continue; - } - char * share; - - // Rewire to the latest system level + int fileNo; + BOOL_T updated = FALSE; + long *favoriteList = NULL; + long favorites; + int nextFavorite = 0; + + updated = UpdateParamFiles(); + + wPrefGetIntegerBasic(FAVORITESECTION, FAVORITETOTALS, &favorites, 0); + if (favorites) { + DynString topic; + favoriteList = MyMalloc(sizeof(long)*favorites); + + DynStringMalloc(&topic, 16); + for (int i = 0; i < favorites; i++) { + DynStringPrintf(&topic, FAVORITEKEY, i); + wPrefGetIntegerBasic(FAVORITESECTION, DynStringToCStr(&topic), &favoriteList[i], + 0); + } + DynStringFree(&topic); + } + + for (fileNo = 1; ; fileNo++) { + char *fileName; + const char * contents; +// enum paramFileState structState = PARAMFILE_UNLOADED; + + + sprintf(message, "File%d", fileNo); + contents = wPrefGetString("Parameter File Names", message); + if (contents == NULL || *contents == '\0') { + break; + } + InfoMessage("Parameters for %s", contents); + fileName = wPrefGetString("Parameter File Map", contents); + if (fileName == NULL || *fileName == '\0') { + NoticeMessage(MSG_PRMFIL_NO_MAP, _("Ok"), NULL, contents); + continue; + } + char * share; + + // Rewire to the latest system level #define SHAREPARAMS (PATH_SEPARATOR "share" PATH_SEPARATOR "xtrkcad" PATH_SEPARATOR "params" PATH_SEPARATOR) - if ((share= strstr(fileName,SHAREPARAMS))) { - share += strlen(SHAREPARAMS); - MakeFullpath(&fileName, wGetAppLibDir(), "params", share, NULL); - wPrefSetString("Parameter File Map", contents, fileName); - } +#define SHAREBETAPARAMS (PATH_SEPARATOR "share" PATH_SEPARATOR "xtrkcad-beta" PATH_SEPARATOR "params" PATH_SEPARATOR) + if ((share= strstr(fileName,SHAREPARAMS))) { + share += strlen(SHAREPARAMS); + } +#ifndef WINDOWS +#ifndef __APPLE__ + if ( share == NULL && + (share= strstr(fileName,SHAREBETAPARAMS))) { + share += strlen(SHAREBETAPARAMS); + } +#endif +#endif + if ( share ) { + MakeFullpath(&fileName, wGetAppLibDir(), "params", share, NULL); + LOG1( log_paramupdate, ( "Param LoadParamList: %s -> %s\n", contents, + fileName ) ); + wPrefSetString("Parameter File Map", contents, fileName); + } if (ReadParamFile(fileName) >= 0) { @@ -234,13 +282,13 @@ void LoadParamFileList(void) } else { ReadParamError(fileName); } - } - curParamFileIndex = PARAM_CUSTOM; - if (updated) { - SaveParamFileList(); - } + } + curParamFileIndex = PARAM_CUSTOM; + if (updated) { + SaveParamFileList(); + } - MyFree(favoriteList); + MyFree(favoriteList); } /** @@ -251,45 +299,56 @@ void LoadParamFileList(void) void SaveParamFileList(void) { - int fileInx; - int fileNo; - int favorites; - char * contents, *cp; - - for (fileInx = 0, fileNo = 1, favorites = 0; fileInx < paramFileInfo_da.cnt; - fileInx++) { - if (paramFileInfo(fileInx).valid && (!paramFileInfo(fileInx).deleted || - paramFileInfo(fileInx).favorite)) { - sprintf(message, "File%d", fileNo); - contents = paramFileInfo(fileInx).contents; - for (cp = contents; *cp; cp++) { - if (*cp == '=' || *cp == '\'' || *cp == '"' || *cp == ':' || *cp == '.') { - *cp = ' '; - } - } - wPrefSetString("Parameter File Names", message, contents); - wPrefSetString("Parameter File Map", contents, paramFileInfo(fileInx).name); - if (paramFileInfo(fileInx).favorite) { - sprintf(message, FAVORITEKEY, favorites); - wPrefSetInteger(FAVORITESECTION, message, fileNo); - sprintf(message, FAVORITEDELETED, fileNo); - wPrefSetInteger(FAVORITESECTION, message, paramFileInfo(fileInx).deleted); - favorites++; - } - fileNo++; - } - } - sprintf(message, "File%d", fileNo); - wPrefSetString("Parameter File Names", message, ""); - wPrefSetInteger(FAVORITESECTION, FAVORITETOTALS, favorites); + int fileInx; + int fileNo; + int favorites; + char * contents, *cp; + + for (fileInx = 0, fileNo = 1, favorites = 0; fileInx < paramFileInfo_da.cnt; + fileInx++) { + if (paramFileInfo(fileInx).valid && (!paramFileInfo(fileInx).deleted || + paramFileInfo(fileInx).favorite)) { + sprintf(message, "File%d", fileNo); + contents = paramFileInfo(fileInx).contents; + for (cp = contents; *cp; cp++) { + if (*cp == '=' || *cp == '\'' || *cp == '"' || *cp == ':' || *cp == '.') { + *cp = ' '; + } + } + LOG1( log_paramupdate, ( "Param SaveFileList: %s -> %s\n", message, + contents ) ); + wPrefSetString("Parameter File Names", message, contents); + LOG1( log_paramupdate, ( "Param %s -> %s\n", contents, + paramFileInfo(fileInx).name ) ); + wPrefSetString("Parameter File Map", contents, paramFileInfo(fileInx).name); + if (paramFileInfo(fileInx).favorite) { + sprintf(message, FAVORITEKEY, favorites); + LOG1( log_paramupdate, ( "Param Favorite %s -> %d\n", message, + fileNo ) ); + wPrefSetInteger(FAVORITESECTION, message, fileNo); + sprintf(message, FAVORITEDELETED, fileNo); + LOG1( log_paramupdate, ( "Param %s -> %d\n", message, + paramFileInfo(fileInx).deleted ) ); + wPrefSetInteger(FAVORITESECTION, message, paramFileInfo(fileInx).deleted); + favorites++; + } + fileNo++; + } + } + sprintf(message, "File%d", fileNo); + LOG1( log_paramupdate, ( "Param SaveFileList: %s -> <>\n", message ) ); + wPrefSetString("Parameter File Names", message, ""); + LOG1( log_paramupdate, ( "Param Favorite %s -> %d\n", FAVORITETOTALS, + favorites ) ); + wPrefSetInteger(FAVORITESECTION, FAVORITETOTALS, favorites); } void UpdateParamFileList(void) { - for (size_t i = 0; i < (unsigned)paramFileInfo_da.cnt; i++) { - SetParamFileState((int)i); - } + for (size_t i = 0; i < (unsigned)paramFileInfo_da.cnt; i++) { + SetParamFileState((int)i); + } } @@ -314,59 +373,68 @@ UpdateParamFileList(void) */ int LoadParamFile( - int files, - char ** fileName, - void * data) + int files, + char ** fileName, + void * data) { - wIndex_t inx; - int i = 0; + wIndex_t inx; + int i = 0; - assert(fileName != NULL); - assert(files > 0); + CHECK(fileName != NULL); + CHECK(files > 0); - for (i = 0; i < files; i++) { - enum paramFileState structState = PARAMFILE_UNLOADED; - int newIndex; + for (i = 0; i < files; i++) { +// enum paramFileState structState = PARAMFILE_UNLOADED; + int newIndex; - curContents = curSubContents = NULL; + curContents = curSubContents = NULL; - newIndex = ReadParamFile(fileName[i]); + newIndex = ReadParamFile(fileName[i]); if (newIndex >= 0) { // in case the contents is already present, make invalid for (inx = 0; inx < newIndex; inx++) { if (paramFileInfo(inx).valid && - strcmp(paramFileInfo(inx).contents, curContents) == 0) { + strcmp(paramFileInfo(inx).contents, curContents) == 0) { paramFileInfo(inx).valid = FALSE; break; } } + LOG1( log_paramupdate, ( "Param Load: %s -> %s\n", curContents, + paramFileInfo(curParamFileIndex).name) ); wPrefSetString("Parameter File Map", curContents, - paramFileInfo(curParamFileIndex).name); + paramFileInfo(curParamFileIndex).name); } else { ReadParamError(fileName[i]); } - } - //Only set the ParamFileDir if not the system directory - if (!strstr(fileName[i-1],SHAREPARAMS)) - SetParamFileDir(fileName[i - 1]); - curParamFileIndex = PARAM_CUSTOM; - DoChangeNotification(CHANGE_PARAMS); - return TRUE; + } + //Only set the ParamFileDir if not the system directory + if ( (!strstr(fileName[i-1],SHAREPARAMS)) +#ifndef WINDOWS +#ifndef __APPLE__ + && (!strstr(fileName[i-1],SHAREBETAPARAMS)) +#endif +#endif + ) { + SetParamFileDir(fileName[i - 1]); + } + curParamFileIndex = PARAM_CUSTOM; + DoChangeNotification(CHANGE_PARAMS); + return TRUE; } static void ReadCustom(void) { - FILE * f; - MakeFullpath(&customPath, workingDir, sCustomF, NULL); - customPathBak = MyStrdup(customPath); - customPathBak[ strlen(customPathBak)-1 ] = '1'; - f = fopen(customPath, "r"); - if (f != NULL) { - fclose(f); - curParamFileIndex = PARAM_CUSTOM; - ReadParams(0, workingDir, sCustomF); - } + FILE * f; + MakeFullpath(&customPath, workingDir, sCustomF, NULL); + customPathBak = MyStrdup(customPath); + customPathBak[ strlen(customPathBak)-1 ] = '1'; + f = fopen(customPath, "r"); + if (f != NULL) { + fclose(f); + curParamFileIndex = PARAM_CUSTOM; + ReadParams(0, workingDir, sCustomF); + } } @@ -376,23 +444,23 @@ static void ReadCustom(void) FILE * OpenCustom(char *mode) { - FILE * ret = NULL; - - if (inPlayback) { - return NULL; - } - if (*mode == 'w') { - rename(customPath, customPathBak); - } - if (customPath) { - ret = fopen(customPath, mode); - if (ret == NULL) { - NoticeMessage(MSG_OPEN_FAIL, _("Continue"), NULL, _("Custom"), customPath, - strerror(errno)); - } - } - - return ret; + FILE * ret = NULL; + + if (inPlayback) { + return NULL; + } + if (*mode == 'w') { + rename(customPath, customPathBak); + } + if (customPath) { + ret = fopen(customPath, mode); + if (ret == NULL) { + NoticeMessage(MSG_OPEN_FAIL, _("Continue"), NULL, _("Custom"), customPath, + strerror(errno)); + } + } + + return ret; } /** * Update and open the parameter files dialog box @@ -402,46 +470,47 @@ FILE * OpenCustom(char *mode) static void DoParamFileListDialog(void *junk) { - DoParamFiles(junk); - ParamFileListLoad(paramFileInfo_da.cnt, ¶mFileInfo_da); + DoParamFiles(junk); + ParamFileListLoad(paramFileInfo_da.cnt, ¶mFileInfo_da); } addButtonCallBack_t ParamFilesInit(void) { RegisterChangeNotification(ParamFilesChange); - return &DoParamFileListDialog; + return &DoParamFileListDialog; } /** * Get the initial parameter files. The Xtrkcad.xtq file containing scale and * demo definitions is read. - * + * * \return FALSE on error, TRUE otherwise */ BOOL_T ParamFileListInit(void) { - /** @logcmd @showrefby params=n paramfilelist.c Log ReadParams - * (including scale file (xtq), custom file (*.cus) and other params (xtp)) + /** @logcmd @showrefby params=n paramfilelist.c Log ReadParams + * (including scale file (xtq), custom file (*.cus) and other params (xtp)) */ - log_params = LogFindIndex("params"); + log_params = LogFindIndex("params"); + log_paramupdate = LogFindIndex("paramupdate"); - SetCLocale(); + SetCLocale(); // get the default definitions - if (ReadParams(lParamKey, libDir, sParamQF) == FALSE) { + if (ReadParams(lParamKey, libDir, sParamQF) == FALSE) { SetUserLocale(); - return FALSE; - } + return FALSE; + } - curParamFileIndex = PARAM_CUSTOM; + curParamFileIndex = PARAM_CUSTOM; - if (lParamKey == 0) { - LoadParamFileList(); - ReadCustom(); - } + if (lParamKey == 0) { + LoadParamFileList(); + ReadCustom(); + } - SetUserLocale(); - return TRUE; + SetUserLocale(); + return TRUE; } @@ -464,8 +533,8 @@ DeleteAllParamTypes(int index) /** * Unload parameter file: all parameter definitions from this file are deleted - * from memory. Strings allocated to store the filename and contents - * description are free'd as well. + * from memory. Strings allocated to store the filename and contents + * description are free'd as well. * In order to keep the overall data structures consistent, the file info * structure is not removed from the array but flagged as garbage * @@ -477,21 +546,21 @@ DeleteAllParamTypes(int index) bool UnloadParamFile(wIndex_t fileIndex) { - paramFileInfo_p paramFileI = ¶mFileInfo(fileIndex); - + paramFileInfo_p paramFileI = ¶mFileInfo(fileIndex); + DeleteAllParamTypes(fileIndex); - - MyFree(paramFileI->name); - MyFree(paramFileI->contents); - paramFileI->valid = FALSE; + MyFree(paramFileI->name); + MyFree(paramFileI->contents); + + paramFileI->valid = FALSE; - for (int i = 0; i < paramFileInfo_da.cnt; i++) { - LOG1(log_params, ("UnloadParamFiles: = %s: %d\n", paramFileInfo(i).contents, - paramFileInfo(i).trackState)) - } + for (int i = 0; i < paramFileInfo_da.cnt; i++) { + LOG1(log_params, ("UnloadParamFiles: = %s: %d\n", paramFileInfo(i).contents, + paramFileInfo(i).trackState)) + } - return (true); + return (true); } /** @@ -506,7 +575,7 @@ bool ReloadParamFile(wIndex_t index) { paramFileInfo_p paramFileI = ¶mFileInfo(index); - + DeleteAllParamTypes(index); MyFree(paramFileI->contents); diff --git a/app/bin/paramfilesearch_ui.c b/app/bin/paramfilesearch_ui.c index 15498f8..5050f22 100644 --- a/app/bin/paramfilesearch_ui.c +++ b/app/bin/paramfilesearch_ui.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "custom.h" @@ -29,7 +29,6 @@ #include "include/paramfile.h" #include "fileio.h" #include "directory.h" -#include "misc2.h" #include "layout.h" static ParameterLib *trackLibrary; /**< Track Library */ @@ -57,25 +56,25 @@ static char * searchFitLabels[] = { N_("Fit Any"), N_("Fit Compatible"), N_("Fit static paramData_t searchUiPLs[] = { #define I_QUERYSTRING (0) - { PD_STRING, searchUiQuery, "query", PDO_ENTER | PDO_NOPREF | PDO_STRINGLIMITLENGTH | PDO_DLGRESIZE, I2VP(340), "", 0, 0, MAXQUERYLENGTH-1 }, + { PD_STRING, searchUiQuery, "query", PDO_ENTER | PDO_NOPREF | PDO_STRINGLIMITLENGTH | PDO_DLGRESIZE, I2VP(340), "", 0, 0, MAXQUERYLENGTH-1 }, #define I_SEARCHBUTTON (1) - { PD_BUTTON, SearchUiDoSearch, "find", PDO_DLGHORZ, 0, NULL, BO_ICON, NULL }, + { PD_BUTTON, SearchUiDoSearch, "find", PDO_DLGHORZ, 0, NULL, BO_ICON, NULL }, #define I_CLEARBUTTON (2) - { PD_BUTTON, SearchUiClearFilter, "clearfilter", PDO_DLGHORZ, 0, NULL, BO_ICON, NULL }, + { PD_BUTTON, SearchUiClearFilter, "clearfilter", PDO_DLGHORZ, 0, NULL, BO_ICON, NULL }, #define I_FITRADIO (3) - { PD_RADIO, &searchFitMode, "fit", PDO_NOPREF | PDO_DLGBOXEND, searchFitLabels, NULL, BC_HORZ|BC_NOBORDER }, + { PD_RADIO, &searchFitMode, "fit", PDO_NOPREF | PDO_DLGBOXEND, searchFitLabels, NULL, BC_HORZ|BC_NOBORDER }, #define I_MESSAGE (4) - { PD_MESSAGE, N_(QUERYPROMPTSTRING), NULL, 0, I2VP(370) }, + { PD_MESSAGE, N_(QUERYPROMPTSTRING), NULL, 0, I2VP(370) }, #define I_STATISTICS (5) - { PD_MESSAGE, "", NULL, PDO_DLGBOXEND, I2VP(370) }, + { PD_MESSAGE, "", NULL, PDO_DLGBOXEND, I2VP(370) }, #define I_RESULTLIST (6) - { PD_LIST, NULL, "inx", PDO_NOPREF | PDO_DLGRESIZE, &searchUiListData, NULL, BL_DUP|BL_SETSTAY|BL_MANY }, + { PD_LIST, NULL, "inx", PDO_NOPREF | PDO_DLGRESIZE, &searchUiListData, NULL, BL_DUP|BL_SETSTAY|BL_MANY }, #define I_MODETOGGLE (7) - { PD_TOGGLE, &searchUiMode, "mode", PDO_DLGBOXEND, searchUiLabels, NULL, BC_HORZ|BC_NOBORDER }, + { PD_TOGGLE, &searchUiMode, "mode", PDO_DLGBOXEND, searchUiLabels, NULL, BC_HORZ|BC_NOBORDER }, #define I_APPLYBUTTON (8) - { PD_BUTTON, SearchUiApply, "apply", PDO_DLGCMDBUTTON, NULL, N_("Add") }, + { PD_BUTTON, SearchUiApply, "apply", PDO_DLGCMDBUTTON, NULL, N_("Add") }, #define I_SELECTALLBUTTON (9) - { PD_BUTTON, SearchUiSelectAll, "selectall", PDO_DLGCMDBUTTON, NULL, N_("Select all") }, + { PD_BUTTON, SearchUiSelectAll, "selectall", PDO_DLGCMDBUTTON, NULL, N_("Select all") }, }; #define SEARCHBUTTON ((wButton_p)searchUiPLs[I_SEARCHBUTTON].control) @@ -95,10 +94,10 @@ static wWin_p searchUiW; #define PARAMDIRECTORY "paramdir" -/** - * Clears the current catalog +/** + * Clears the current catalog */ - + void ClearCurrentCatalog(void) { @@ -119,60 +118,61 @@ static int SearchFileListLoad(Catalog *catalog) { - CatalogEntry *head = catalog->head; - CatalogEntry *catalogEntry; - - DynString description; - DynStringMalloc(&description, STR_SHORT_SIZE); - - wControlShow((wControl_p)RESULTLIST, FALSE); - wListClear(RESULTLIST); - - DL_FOREACH(head, catalogEntry) { - for (unsigned int i=0; i<catalogEntry->files; i++) { - if (catalogEntry->tag && searchFitMode != 0) { - char * type_copy = MyStrdup(catalogEntry->tag); - char * cp = type_copy; - char * type = strtok(cp, " \t"); - SCALE_FIT_TYPE_T fit_type; - if (strcmp(type,TURNOUTCOMMAND) == 0) - fit_type = FIT_TURNOUT; - else if (strcmp(type,STRUCTURECOMMAND)==0) + CatalogEntry *head = catalog->head; + CatalogEntry *catalogEntry; + + DynString description; + DynStringMalloc(&description, STR_SHORT_SIZE); + + wControlShow((wControl_p)RESULTLIST, FALSE); + wListClear(RESULTLIST); + + DL_FOREACH(head, catalogEntry) { + for (unsigned int i=0; i<catalogEntry->files; i++) { + if (catalogEntry->tag && searchFitMode != 0) { + char * type_copy = MyStrdup(catalogEntry->tag); + char * cp = type_copy; + char * type = strtok(cp, " \t"); + SCALE_FIT_TYPE_T fit_type; + if (strcmp(type,TURNOUTCOMMAND) == 0) { + fit_type = FIT_TURNOUT; + } else if (strcmp(type,STRUCTURECOMMAND)==0) { fit_type = FIT_STRUCTURE; - else if ((strcmp(type,CARCOMMAND)==0) || (strcmp(type,CARPROTOCOMMAND)==0)) - fit_type = FIT_CAR; - char * scale = strtok(NULL, " \t\n"); - if (scale) { - SCALEINX_T scale1 = LookupScale(scale); - SCALEINX_T scale2 = GetLayoutCurScale(); - if (searchFitMode == FIT_COMPATIBLE) { - if (CompatibleScale(fit_type,scale1,scale2)<FIT_COMPATIBLE) continue; - } else { - if (CompatibleScale(fit_type,scale1,scale2)<FIT_EXACT) continue; - } - - } - MyFree(type_copy); - } - DynStringClear(&description); - DynStringCatCStr(&description, - ((!searchUiMode) && catalogEntry->contents) ? - catalogEntry->contents : - catalogEntry->fullFileName[i]); - - wListAddValue(RESULTLIST, - DynStringToCStr(&description), - NULL, - catalogEntry->fullFileName[i]); - } - } - - wControlShow((wControl_p)RESULTLIST, TRUE); - wControlActive((wControl_p)SELECTALLBUTTON, - wListGetCount(RESULTLIST)); - - DynStringFree(&description); - return wListGetCount(RESULTLIST); + } else if ((strcmp(type,CARCOMMAND)==0) || (strcmp(type,CARPROTOCOMMAND)==0)) { + fit_type = FIT_CAR; + } + char * scale = strtok(NULL, " \t\n"); + if (scale) { + SCALEINX_T scale1 = LookupScale(scale); + SCALEINX_T scale2 = GetLayoutCurScale(); + if (searchFitMode == FIT_COMPATIBLE) { + if (CompatibleScale(fit_type,scale1,scale2)<FIT_COMPATIBLE) { continue; } + } else { + if (CompatibleScale(fit_type,scale1,scale2)<FIT_EXACT) { continue; } + } + + } + MyFree(type_copy); + } + DynStringClear(&description); + DynStringCatCStr(&description, + ((!searchUiMode) && catalogEntry->contents) ? + catalogEntry->contents : + catalogEntry->fullFileName[i]); + + wListAddValue(RESULTLIST, + DynStringToCStr(&description), + NULL, + catalogEntry->fullFileName[i]); + } + } + + wControlShow((wControl_p)RESULTLIST, TRUE); + wControlActive((wControl_p)SELECTALLBUTTON, + wListGetCount(RESULTLIST)); + + DynStringFree(&description); + return wListGetCount(RESULTLIST); } /** @@ -183,12 +183,14 @@ static void SearchUiDefault(void) { DynString dsSummary; - int matches = SearchFileListLoad(trackLibrary->catalog); //Start with system files + int matches = SearchFileListLoad( + trackLibrary->catalog); //Start with system files wStringSetValue(QUERYSTRING, ""); wMessageSetValue(MESSAGETEXT, _(QUERYPROMPTSTRING)); DynStringMalloc(&dsSummary, 16); - DynStringPrintf(&dsSummary, _("%u parameter files in library. %d Fit Scale."), CountCatalogEntries(trackLibrary->catalog), matches); + DynStringPrintf(&dsSummary, _("%u parameter files in library. %d Fit Scale."), + CountCatalogEntries(trackLibrary->catalog), matches); wMessageSetValue(SEARCHSTAT, DynStringToCStr(&dsSummary)); DynStringFree(&dsSummary); @@ -202,27 +204,23 @@ static void SearchUiDefault(void) void static SearchUILoadResults(void) { - int files = wListGetSelectedCount(RESULTLIST); - - if (files) { - char **fileNames; - int found = 0; - fileNames = MyMalloc(sizeof(char *)*files); - if (!fileNames) { - AbortProg("Couldn't allocate memory for result list: %s (%d)", __FILE__, - __LINE__, NULL); - } - - for (int inx = 0; found < files; inx++) { - if (wListGetItemSelected(RESULTLIST, inx)) { - fileNames[found++] = (char *)wListGetItemContext(RESULTLIST, inx); - } - } - - LoadParamFile(files, fileNames, NULL); - MyFree(fileNames); - SearchUiOk(NULL); - } + int files = wListGetSelectedCount(RESULTLIST); + + if (files) { + char **fileNames; + int found = 0; + fileNames = MyMalloc(sizeof(char *)*files); + + for (int inx = 0; found < files; inx++) { + if (wListGetItemSelected(RESULTLIST, inx)) { + fileNames[found++] = (char *)wListGetItemContext(RESULTLIST, inx); + } + } + + LoadParamFile(files, fileNames, NULL); + MyFree(fileNames); + SearchUiOk(NULL); + } } @@ -237,11 +235,11 @@ SearchUILoadResults(void) static void UpdateSearchUiButton(void) { - wIndex_t selCnt = wListGetSelectedCount(RESULTLIST); - wIndex_t cnt = wListGetCount(RESULTLIST); + wIndex_t selCnt = wListGetSelectedCount(RESULTLIST); + wIndex_t cnt = wListGetCount(RESULTLIST); - wControlActive((wControl_p)APPLYBUTTON, selCnt > 0); - wControlActive((wControl_p)SELECTALLBUTTON, cnt > 0); + wControlActive((wControl_p)APPLYBUTTON, selCnt > 0); + wControlActive((wControl_p)SELECTALLBUTTON, cnt > 0); } /** @@ -254,23 +252,23 @@ static void UpdateSearchUiButton(void) char * StringTrim(char *s) { - char *original = s; - size_t len = 0; - - while (isspace((unsigned char) *s)) { - s++; - } - if (*s) { - char *p = s; - while (*p) { - p++; - } - while (isspace((unsigned char) *(--p))); - p[1] = '\0'; - len = (size_t)(p - s + 1); - } - - return (s == original) ? s : memmove(original, s, len + 1); + char *original = s; + size_t len = 0; + + while (isspace((unsigned char) *s)) { + s++; + } + if (*s) { + char *p = s; + while (*p) { + p++; + } + while (isspace((unsigned char) *(--p))); + p[1] = '\0'; + len = (size_t)(p - s + 1); + } + + return (s == original) ? s : memmove(original, s, len + 1); } /** @@ -281,14 +279,15 @@ char * StringTrim(char *s) static void SearchUiDoSearch(void * ptr) { - unsigned result; - SearchResult *currentResults = MyMalloc(sizeof(SearchResult)); - char * search; + unsigned result; + SearchResult *currentResults = MyMalloc(sizeof(SearchResult)); + char * search; ClearCurrentCatalog(); - strcpy(searchUiQuery, wStringGetValue((wString_p)searchUiPG.paramPtr[I_QUERYSTRING].control)); - search = StringTrim(searchUiQuery); + strcpy(searchUiQuery, wStringGetValue((wString_p) + searchUiPG.paramPtr[I_QUERYSTRING].control)); + search = StringTrim(searchUiQuery); if (search[0]) { result = SearchLibrary(trackLibrary, search, currentResults); @@ -305,7 +304,8 @@ static void SearchUiDoSearch(void * ptr) DynString hitsMessage; DynStringMalloc(&hitsMessage, 16); - DynStringPrintf(&hitsMessage, _("%d parameter files found. %d Fit Scale"), result, matches); + DynStringPrintf(&hitsMessage, _("%d parameter files found. %d Fit Scale"), + result, matches); wMessageSetValue(MESSAGETEXT, DynStringToCStr(&hitsMessage)); DynStringFree(&hitsMessage); @@ -344,7 +344,7 @@ SearchUiClearFilter(void *ptr) static void SearchUiSelectAll(void *junk) { - wListSelectAll(RESULTLIST); + wListSelectAll(RESULTLIST); } /** @@ -355,9 +355,9 @@ static void SearchUiSelectAll(void *junk) void SearchUiOk(void * junk) { - if (searchUiW) { - wHide(searchUiW); - } + if (searchUiW) { + wHide(searchUiW); + } } /** @@ -369,7 +369,7 @@ void SearchUiOk(void * junk) static void SearchUiApply(wWin_p junk) { - SearchUILoadResults(); + SearchUILoadResults(); } /** @@ -382,38 +382,39 @@ static void SearchUiApply(wWin_p junk) */ static void SearchUiDlgUpdate( - paramGroup_p pg, - int inx, - void * valueP) + paramGroup_p pg, + int inx, + void * valueP) { - switch (inx) { - case I_QUERYSTRING: - if (pg->paramPtr[inx].enter_pressed) { - strcpy( searchUiQuery, wStringGetValue((wString_p)pg->paramPtr[inx].control) ); - SearchUiDoSearch(NULL); - } - break; - case I_RESULTLIST: - UpdateSearchUiButton(); - break; - case I_FITRADIO: - strcpy( searchUiQuery, wStringGetValue((wString_p)pg->paramPtr[I_QUERYSTRING].control) ); - SearchUiDoSearch(NULL); - break; - case I_MODETOGGLE: + switch (inx) { + case I_QUERYSTRING: + if (pg->paramPtr[inx].enter_pressed) { + strcpy( searchUiQuery, wStringGetValue((wString_p)pg->paramPtr[inx].control) ); + SearchUiDoSearch(NULL); + } + break; + case I_RESULTLIST: + UpdateSearchUiButton(); + break; + case I_FITRADIO: + strcpy( searchUiQuery, wStringGetValue((wString_p) + pg->paramPtr[I_QUERYSTRING].control) ); + SearchUiDoSearch(NULL); + break; + case I_MODETOGGLE: if (currentCat.head) { SearchFileListLoad(¤tCat); } else { SearchFileListLoad(trackLibrary->catalog); } - break; - case -1: - SearchUiOk(valueP); - break; - } + break; + case -1: + SearchUiOk(valueP); + break; + } } -void +void SearchUiCancel(wWin_p window) { ClearCurrentCatalog(); @@ -432,16 +433,16 @@ SearchUiCancel(wWin_p window) static char * GetParamsPath() { - char * params_path; - char *params_pref; - params_pref = wPrefGetString(FILESECTION, PARAMDIRECTORY); - - if (!params_pref) { - MakeFullpath(¶ms_path, wGetAppLibDir(), "params", NULL); - } else { - params_path = strdup(params_pref); - } - return (params_path); + char * params_path; + char *params_pref; + params_pref = wPrefGetString(FILESECTION, PARAMDIRECTORY); + + if (!params_pref) { + MakeFullpath(¶ms_path, wGetAppLibDir(), "params", NULL); + } else { + params_path = strdup(params_pref); + } + return (params_path); } #include "bitmaps/funnel.xpm" @@ -455,48 +456,48 @@ GetParamsPath() void DoSearchParams(void * junk) { - if (searchUiW == NULL) { + if (searchUiW == NULL) { - //Make the Find menu bound to the System Library initially - char *paramsDir = GetParamsPath(); - trackLibrary = CreateLibrary(paramsDir); - free(paramsDir); + //Make the Find menu bound to the System Library initially + char *paramsDir = GetParamsPath(); + trackLibrary = CreateLibrary(paramsDir); + free(paramsDir); - searchUiPLs[I_SEARCHBUTTON].winLabel = (char *)wIconCreatePixMap(funnel_xpm); - searchUiPLs[I_CLEARBUTTON].winLabel = (char *)wIconCreatePixMap( - funnelclear_xpm); + searchUiPLs[I_SEARCHBUTTON].winLabel = (char *)wIconCreatePixMap(funnel_xpm); + searchUiPLs[I_CLEARBUTTON].winLabel = (char *)wIconCreatePixMap( + funnelclear_xpm); - searchFitMode = FIT_COMPATIBLE; //Default to "Any" after startup + searchFitMode = FIT_COMPATIBLE; //Default to "Any" after startup - ParamRegister(&searchUiPG); + ParamRegister(&searchUiPG); - searchUiW = ParamCreateDialog(&searchUiPG, - MakeWindowTitle(_("Choose parameter files")), _("Done"), NULL, SearchUiCancel, - TRUE, NULL, F_RESIZE | F_RECALLSIZE, SearchUiDlgUpdate); + searchUiW = ParamCreateDialog(&searchUiPG, + MakeWindowTitle(_("Choose parameter files")), _("Done"), NULL, SearchUiCancel, + TRUE, NULL, F_RESIZE | F_RECALLSIZE, SearchUiDlgUpdate); - wControlActive((wControl_p)APPLYBUTTON, FALSE); - wControlActive((wControl_p)SELECTALLBUTTON, FALSE); - } + wControlActive((wControl_p)APPLYBUTTON, FALSE); + wControlActive((wControl_p)SELECTALLBUTTON, FALSE); + } - wControlActive((wControl_p)FITRADIO, TRUE); + wControlActive((wControl_p)FITRADIO, TRUE); - ParamLoadControls(&searchUiPG); - ParamGroupRecord(&searchUiPG); + ParamLoadControls(&searchUiPG); + ParamGroupRecord(&searchUiPG); - if (!trackLibrary) { - wControlActive((wControl_p)SEARCHBUTTON, FALSE); - wControlActive((wControl_p)QUERYSTRING, FALSE); - wMessageSetValue(MESSAGETEXT, - _("No system parameter files found, search is disabled.")); - } else { + if (!trackLibrary) { + wControlActive((wControl_p)SEARCHBUTTON, FALSE); + wControlActive((wControl_p)QUERYSTRING, FALSE); + wMessageSetValue(MESSAGETEXT, + _("No system parameter files found, search is disabled.")); + } else { SearchUiDefault(); - } + } - wShow(searchUiW); + wShow(searchUiW); } diff --git a/app/bin/partcatalog.c b/app/bin/partcatalog.c index 25ae024..205ae50 100644 --- a/app/bin/partcatalog.c +++ b/app/bin/partcatalog.c @@ -16,14 +16,13 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "dynstring.h" #include "fileio.h" #include "include/levenshtein.h" #include "misc.h" -#include "misc2.h" #include "include/paramfile.h" #include "include/partcatalog.h" #include "paths.h" @@ -36,7 +35,7 @@ #define LDISTANCELIMIT (2) static char *stopwords = { - "scale", + "scale", }; static int log_params; @@ -50,11 +49,11 @@ static int log_params; Catalog * InitCatalog(void) { - Catalog *newCatalog = MyMalloc(sizeof(Catalog)); - if (newCatalog) { - newCatalog->head = NULL; - } - return (newCatalog); + Catalog *newCatalog = MyMalloc(sizeof(Catalog)); + if (newCatalog) { + newCatalog->head = NULL; + } + return (newCatalog); } /** @@ -68,27 +67,28 @@ DestroyCatalog(Catalog *catalog) { CatalogEntry *current = catalog->head; CatalogEntry *entry = NULL; - CatalogEntry *tmp = NULL, *old = NULL; - DL_FOREACH_SAFE(current, entry, tmp) - { + CatalogEntry *tmp = NULL; +// CatalogEntry *old = NULL; + DL_FOREACH_SAFE(current, entry, tmp) { //if (old) MyFree(old); - old = NULL; +// old = NULL; for (unsigned int i = 0; i < entry->files; i++) { - MyFree(entry->fullFileName[i]); - entry->fullFileName[i] = NULL; + MyFree(entry->fullFileName[i]); + entry->fullFileName[i] = NULL; } entry->files = 0; MyFree(entry->contents); entry->contents = NULL; MyFree(entry->tag); entry->tag = NULL; - old = entry; +// old = entry; DL_DELETE(catalog->head,entry); } catalog->head = NULL; } +#if 0 /** * Create a new CatalogEntry and add it to the linked list. The newly * created entry is inserted into the list after the given position @@ -100,16 +100,17 @@ DestroyCatalog(Catalog *catalog) static CatalogEntry * InsertIntoCatalogAfter(CatalogEntry *entry) { - CatalogEntry *newEntry = (CatalogEntry *)MyMalloc(sizeof(CatalogEntry)); - newEntry->next = entry->next; - newEntry->prev = entry; - entry->next = newEntry; - newEntry->files = 0; - newEntry->contents = NULL; - newEntry->tag = NULL; - - return (newEntry); + CatalogEntry *newEntry = (CatalogEntry *)MyMalloc(sizeof(CatalogEntry)); + newEntry->next = entry->next; + newEntry->prev = entry; + entry->next = newEntry; + newEntry->files = 0; + newEntry->contents = NULL; + newEntry->tag = NULL; + + return (newEntry); } +#endif /** * Count the elements in the linked list @@ -121,10 +122,10 @@ InsertIntoCatalogAfter(CatalogEntry *entry) unsigned CountCatalogEntries(Catalog *catalog) { - CatalogEntry * entry; - unsigned count = 0; - DL_COUNT(catalog->head, entry, count); - return (count); + CatalogEntry * entry; + unsigned count = 0; + DL_COUNT(catalog->head, entry, count); + return (count); } /** @@ -136,27 +137,28 @@ CountCatalogEntries(Catalog *catalog) EXPORT void CatalogDiscard(Catalog *catalog) { - CatalogEntry *current = catalog->head; - CatalogEntry *element; - CatalogEntry *tmp,*old = NULL; - - DL_FOREACH_SAFE(current, element, tmp) { - //if (old) MyFree(old); - old = NULL; - MyFree(element->contents); - element->contents = NULL; - MyFree(element->tag); - element->tag = NULL; - for (unsigned int i = 0; i < element->files; i++) { - MyFree(element->fullFileName[i]); - element->fullFileName[i] = NULL; - } - element->files = 0; - old = element; - DL_DELETE(catalog->head,element); - } - - catalog->head = NULL; + CatalogEntry *current = catalog->head; + CatalogEntry *element; + CatalogEntry *tmp; +// CatalogEntry *old = NULL; + + DL_FOREACH_SAFE(current, element, tmp) { + //if (old) MyFree(old); +// old = NULL; + MyFree(element->contents); + element->contents = NULL; + MyFree(element->tag); + element->tag = NULL; + for (unsigned int i = 0; i < element->files; i++) { + MyFree(element->fullFileName[i]); + element->fullFileName[i] = NULL; + } + element->files = 0; +// old = element; + DL_DELETE(catalog->head,element); + } + + catalog->head = NULL; } /** @@ -171,7 +173,7 @@ CatalogDiscard(Catalog *catalog) static int CompareEntries(CatalogEntry *a, CatalogEntry *b) { - return XtcStricmp(a->contents, b->contents); + return XtcStricmp(a->contents, b->contents); } /** @@ -187,17 +189,19 @@ CompareEntries(CatalogEntry *a, CatalogEntry *b) EXPORT CatalogEntry * InsertInOrder(Catalog *catalog, const char *contents, const char *tag) { - CatalogEntry *newEntry = MyMalloc(sizeof(CatalogEntry)); - newEntry->files = 0; + CatalogEntry *newEntry = MyMalloc(sizeof(CatalogEntry)); + newEntry->files = 0; - if (contents) - newEntry->contents = MyStrdup(contents); - if (tag) - newEntry->tag = MyStrdup(tag); + if (contents) { + newEntry->contents = MyStrdup(contents); + } + if (tag) { + newEntry->tag = MyStrdup(tag); + } - DL_INSERT_INORDER(catalog->head, newEntry, CompareEntries); + DL_INSERT_INORDER(catalog->head, newEntry, CompareEntries); - return newEntry; + return newEntry; } /** @@ -213,18 +217,18 @@ InsertInOrder(Catalog *catalog, const char *contents, const char *tag) static CatalogEntry * IsExistingContents(Catalog *catalog, const char *contents, BOOL_T silent) { - CatalogEntry *head = catalog->head; - CatalogEntry *currentEntry; - - DL_FOREACH(head, currentEntry) { - if (!XtcStricmp(currentEntry->contents, contents)) { - if (!silent) { - printf("%s already exists in %s\n", contents, currentEntry->fullFileName[0]); - } - return (currentEntry); - } - } - return (NULL); + CatalogEntry *head = catalog->head; + CatalogEntry *currentEntry; + + DL_FOREACH(head, currentEntry) { + if (!XtcStricmp(currentEntry->contents, contents)) { + if (!silent) { + printf("%s already exists in %s\n", contents, currentEntry->fullFileName[0]); + } + return (currentEntry); + } + } + return (NULL); } /** @@ -240,25 +244,24 @@ IsExistingContents(Catalog *catalog, const char *contents, BOOL_T silent) EXPORT void UpdateCatalogEntry(CatalogEntry *entry, char *path, char *contents, char *tag) { - if (!entry->contents) { - MyFree(entry->contents); - entry->contents = NULL; - } - if (contents) - entry->contents = MyStrdup(contents); - - if (!entry->tag) { - MyFree(entry->tag); - entry->tag = NULL; - } - if (tag) - entry->tag = MyStrdup(tag); - - if (entry->files < MAXFILESPERCONTENT) { - entry->fullFileName[entry->files++] = MyStrdup(path); - } else { - AbortProg("Number of files with same content too large!", NULL); - } + if (!entry->contents) { + MyFree(entry->contents); + entry->contents = NULL; + } + if (contents) { + entry->contents = MyStrdup(contents); + } + + if (!entry->tag) { + MyFree(entry->tag); + entry->tag = NULL; + } + if (tag) { + entry->tag = MyStrdup(tag); + } + + CHECK( entry->files < MAXFILESPERCONTENT ); + entry->fullFileName[entry->files++] = MyStrdup(path); } /** @@ -274,40 +277,40 @@ UpdateCatalogEntry(CatalogEntry *entry, char *path, char *contents, char *tag) static bool GetNextParameterFile(DIR *dir, const char *dirName, char **fileName) { - bool done = false; - bool res = false; - - /* - * get all files from the directory - */ - while (!done) { - struct stat fileState; - struct dirent *ent; - - ent = readdir(dir); - - if (ent) { - if (!XtcStricmp(FindFileExtension(ent->d_name), "xtp")) { - /* create full file name and get the state for that file */ - MakeFullpath(fileName, dirName, ent->d_name, NULL); - - if (stat(*fileName, &fileState) == -1) { - fprintf(stderr, "Error getting file state for %s\n", *fileName); - continue; - } - - /* ignore any directories */ - if (!(fileState.st_mode & S_IFDIR)) { - done = true; - res = true; - } - } - } else { - done = true; - res = false; - } - } - return (res); + bool done = false; + bool res = false; + + /* + * get all files from the directory + */ + while (!done) { + struct stat fileState; + struct dirent *ent; + + ent = readdir(dir); + + if (ent) { + if (!XtcStricmp(FindFileExtension(ent->d_name), "xtp")) { + /* create full file name and get the state for that file */ + MakeFullpath(fileName, dirName, ent->d_name, NULL); + + if (stat(*fileName, &fileState) == -1) { + fprintf(stderr, "Error getting file state for %s\n", *fileName); + continue; + } + + /* ignore any directories */ + if (!(fileState.st_mode & S_IFDIR)) { + done = true; + res = true; + } + } + } else { + done = true; + res = false; + } + } + return (res); } /*! @@ -321,21 +324,21 @@ GetNextParameterFile(DIR *dir, const char *dirName, char **fileName) bool FilterKeyword(char *word) { - if (strlen(word) == 1 && strpbrk(word, PUNCTUATION)) { - return (true); - } - - for (int i = 0; i < sizeof(stopwords) / sizeof(char *); i++) { - if (!XtcStricmp(word, stopwords+i)) { - return (true); - } - } - return (false); + if (strlen(word) == 1 && strpbrk(word, PUNCTUATION)) { + return (true); + } + + for (int i = 0; i < sizeof(stopwords) / sizeof(char *); i++) { + if (!XtcStricmp(word, stopwords+i)) { + return (true); + } + } + return (false); } int KeyWordCmp(void *a, void *b) { - return XtcStricmp(((IndexEntry *)a)->keyWord,((IndexEntry *)b)->keyWord); + return XtcStricmp(((IndexEntry *)a)->keyWord,((IndexEntry *)b)->keyWord); } @@ -349,25 +352,25 @@ int KeyWordCmp(void *a, void *b) void StandardizeSpelling(char *word) { - char *p = strchr(word, '-'); - // remove the word 'scale' from combinations like N-scale - if (p) { - if (!XtcStricmp(p+1, "scale")) { - *p = '\0'; - } - } - - if (!strncasecmp(word, "h0", 2)) { - strncpy(word, "ho", 2); - } - - if (!strncasecmp(word, "00", 2)) { - strncpy(word, "oo", 2); - } - - if (word[0] == '0') { - word[0] = 'o'; - } + char *p = strchr(word, '-'); + // remove the word 'scale' from combinations like N-scale + if (p) { + if (!XtcStricmp(p+1, "scale")) { + *p = '\0'; + } + } + + if (!strncasecmp(word, "h0", 2)) { + strcpy(word, "ho"); + } + + if (!strncasecmp(word, "00", 2)) { + strcpy(word, "oo"); + } + + if (word[0] == '0') { + word[0] = 'o'; + } } /** @@ -381,71 +384,71 @@ StandardizeSpelling(char *word) static unsigned CreateKeywordIndex(ParameterLib *library) { - CatalogEntry *listOfEntries = library->catalog->head; - CatalogEntry *curParamFile; - size_t totalMemory = 0; - size_t wordCount = 0; - char *wordList; - char *wordListPtr; - IndexEntry *index = library->index; - - // allocate a buffer for the complete set of keywords - DL_FOREACH(listOfEntries, curParamFile) { - totalMemory += strlen(curParamFile->contents) + 1; - } - wordList = MyMalloc((totalMemory + 1) * sizeof(char)); - - wordListPtr = wordList; - - DL_FOREACH(listOfEntries, curParamFile) { - char *word; - char *content = strdup(curParamFile->contents); - - word = strtok(content, SEARCHDELIMITER); - while (word) { - strcpy(wordListPtr, word); - - XtcStrlwr(wordListPtr); - if (!FilterKeyword(wordListPtr)) { - IndexEntry *searchEntry = MyMalloc(sizeof(IndexEntry)); - IndexEntry *existingEntry = NULL; - searchEntry->keyWord = wordListPtr; - StandardizeSpelling(wordListPtr); - - if (index) { - DL_SEARCH(index, existingEntry, searchEntry, KeyWordCmp); - } - if (existingEntry) { - DYNARR_APPEND(CatalogEntry *, *(existingEntry->references), 5); - DYNARR_LAST(CatalogEntry *, *(existingEntry->references)) = curParamFile; - MyFree(searchEntry); - } else { - searchEntry->references = calloc(1, sizeof(dynArr_t)); - DYNARR_APPEND(CatalogEntry *, *(searchEntry->references), 5); - DYNARR_LAST(CatalogEntry *, *(searchEntry->references)) = curParamFile; - DL_APPEND(index, searchEntry); - LOG1(log_params, ("Index Entry: <%s>\n", searchEntry->keyWord)) - } - - wordListPtr += strlen(word) + 1; - wordCount++; - } - word = strtok(NULL, SEARCHDELIMITER); - } - free(content); - } - *wordListPtr = '\0'; + CatalogEntry *listOfEntries = library->catalog->head; + CatalogEntry *curParamFile; + size_t totalMemory = 0; + size_t wordCount = 0; + char *wordList; + char *wordListPtr; + IndexEntry *index = library->index; + + // allocate a buffer for the complete set of keywords + DL_FOREACH(listOfEntries, curParamFile) { + totalMemory += strlen(curParamFile->contents) + 1; + } + wordList = MyMalloc((totalMemory + 1) * sizeof(char)); + + wordListPtr = wordList; + + DL_FOREACH(listOfEntries, curParamFile) { + char *word; + char *content = strdup(curParamFile->contents); + + word = strtok(content, SEARCHDELIMITER); + while (word) { + strcpy(wordListPtr, word); + + XtcStrlwr(wordListPtr); + if (!FilterKeyword(wordListPtr)) { + IndexEntry *searchEntry = MyMalloc(sizeof(IndexEntry)); + IndexEntry *existingEntry = NULL; + searchEntry->keyWord = wordListPtr; + StandardizeSpelling(wordListPtr); + + if (index) { + DL_SEARCH(index, existingEntry, searchEntry, KeyWordCmp); + } + if (existingEntry) { + DYNARR_APPEND(CatalogEntry *, *(existingEntry->references), 5); + DYNARR_LAST(CatalogEntry *, *(existingEntry->references)) = curParamFile; + MyFree(searchEntry); + } else { + searchEntry->references = calloc(1, sizeof(dynArr_t)); + DYNARR_APPEND(CatalogEntry *, *(searchEntry->references), 5); + DYNARR_LAST(CatalogEntry *, *(searchEntry->references)) = curParamFile; + DL_APPEND(index, searchEntry); + LOG1(log_params, ("Index Entry: <%s>\n", searchEntry->keyWord)) + } + + wordListPtr += strlen(word) + 1; + wordCount++; + } + word = strtok(NULL, SEARCHDELIMITER); + } + free(content); + } + *wordListPtr = '\0'; DL_SORT(index, KeyWordCmp); - library->index = index; - library->words = wordList; - - IndexEntry *existingEntry; - DL_FOREACH(index, existingEntry) { - LOG1(log_params, ("Index Entry: <%s> Count: %d\n", existingEntry->keyWord, - existingEntry->references->cnt)); - } - return (unsigned)(wordCount); + library->index = index; + library->words = wordList; + + IndexEntry *existingEntry; + DL_FOREACH(index, existingEntry) { + LOG1(log_params, ("Index Entry: <%s> Count: %d\n", existingEntry->keyWord, + existingEntry->references->cnt)); + } + return (unsigned)(wordCount); } /** @@ -463,24 +466,24 @@ CreateKeywordIndex(ParameterLib *library) unsigned int FindWord(IndexEntry *index, int length, char *search, IndexEntry **entries) { - IndexEntry *result = NULL; + IndexEntry *result = NULL; - IndexEntry searchWord; - searchWord.keyWord = search; + IndexEntry searchWord; + searchWord.keyWord = search; - *entries = NULL; + *entries = NULL; - DL_SEARCH(index, result, &searchWord, KeyWordCmp); + DL_SEARCH(index, result, &searchWord, KeyWordCmp); if (!result) { int maxdistance = 1; while (maxdistance <= LDISTANCELIMIT && !result ) { IndexEntry *current; - size_t minDistance = LDISTANCELIMIT + 1; +// size_t minDistance = LDISTANCELIMIT + 1; int maxProbability = 0; - LOG1(log_params, ("Close match for: <%s> maxdistance: %d\n", search, maxdistance)); - - DL_FOREACH(index, current) - { + LOG1(log_params, ("Close match for: <%s> maxdistance: %d\n", search, + maxdistance)); + + DL_FOREACH(index, current) { size_t ldist = levenshtein(search, current->keyWord); LOG1(log_params, ("Distance of: <%s> is %d\n", current->keyWord, ldist)); if (ldist == maxdistance) { @@ -497,9 +500,9 @@ FindWord(IndexEntry *index, int length, char *search, IndexEntry **entries) maxdistance++; } } - - *entries = result; - return (result != NULL); + + *entries = result; + return (result != NULL); } /** @@ -512,16 +515,16 @@ FindWord(IndexEntry *index, int length, char *search, IndexEntry **entries) ParameterLib * InitLibrary(void) { - ParameterLib *trackLib = MyMalloc(sizeof(ParameterLib)); + ParameterLib *trackLib = MyMalloc(sizeof(ParameterLib)); - if (trackLib) { - trackLib->catalog = InitCatalog(); - trackLib->index = NULL; - trackLib->wordCount = 0; - trackLib->parameterFileCount = 0; - } + if (trackLib) { + trackLib->catalog = InitCatalog(); + trackLib->index = NULL; + trackLib->wordCount = 0; + trackLib->parameterFileCount = 0; + } - return (trackLib); + return (trackLib); } /** @@ -533,10 +536,10 @@ InitLibrary(void) void DestroyLibrary(ParameterLib *library) { - if (library) { - DestroyCatalog(library->catalog); - MyFree(library); - } + if (library) { + DestroyCatalog(library->catalog); + MyFree(library); + } } /** @@ -550,37 +553,37 @@ DestroyLibrary(ParameterLib *library) bool CreateCatalogFromDir(ParameterLib *paramLib, char *directory) { - DIR *d; - Catalog *catalog = paramLib->catalog; - - d = opendir(directory); - if (d) { - char *fileName = NULL; - - while (GetNextParameterFile(d, directory, &fileName)) { - CatalogEntry *existingEntry; - - char *contents = GetParameterFileContent(fileName); - - char *scale = GetParameterFileScale(fileName); - - - if ((existingEntry = IsExistingContents(catalog, contents, FALSE))) { - UpdateCatalogEntry(existingEntry, fileName, contents, scale); - } else { - CatalogEntry *newEntry; - newEntry = InsertInOrder(catalog, contents, scale); - UpdateCatalogEntry(newEntry, fileName, contents, scale); - } - MyFree(contents); - MyFree(scale); - free(fileName); - fileName = NULL; - } - closedir(d); - } - paramLib->parameterFileCount = CountCatalogEntries(paramLib->catalog); - return (paramLib->parameterFileCount); + DIR *d; + Catalog *catalog = paramLib->catalog; + + d = opendir(directory); + if (d) { + char *fileName = NULL; + + while (GetNextParameterFile(d, directory, &fileName)) { + CatalogEntry *existingEntry; + + char *contents = GetParameterFileContent(fileName); + + char *scale = GetParameterFileScale(fileName); + + + if ((existingEntry = IsExistingContents(catalog, contents, FALSE))) { + UpdateCatalogEntry(existingEntry, fileName, contents, scale); + } else { + CatalogEntry *newEntry; + newEntry = InsertInOrder(catalog, contents, scale); + UpdateCatalogEntry(newEntry, fileName, contents, scale); + } + MyFree(contents); + MyFree(scale); + free(fileName); + fileName = NULL; + } + closedir(d); + } + paramLib->parameterFileCount = CountCatalogEntries(paramLib->catalog); + return (paramLib->parameterFileCount); } /** @@ -592,18 +595,18 @@ CreateCatalogFromDir(ParameterLib *paramLib, char *directory) void DiscardCatalog(ParameterLib *library) { - CatalogEntry *entry; - CatalogEntry *temp; - - DL_FOREACH_SAFE(library->catalog->head, entry, temp) { - MyFree(entry->contents); - MyFree(entry->tag); - for (unsigned int i = 0; i < entry->files; i++) { - MyFree(entry->fullFileName[i]); - } - DL_DELETE(library->catalog->head, entry); - MyFree(entry); - } + CatalogEntry *entry; + CatalogEntry *temp; + + DL_FOREACH_SAFE(library->catalog->head, entry, temp) { + MyFree(entry->contents); + MyFree(entry->tag); + for (unsigned int i = 0; i < entry->files; i++) { + MyFree(entry->fullFileName[i]); + } + DL_DELETE(library->catalog->head, entry); + MyFree(entry); + } } @@ -620,11 +623,11 @@ DiscardCatalog(ParameterLib *library) unsigned CreateLibraryIndex(ParameterLib *parameterLib) { - parameterLib->index = NULL; + parameterLib->index = NULL; - parameterLib->wordCount = CreateKeywordIndex(parameterLib); + parameterLib->wordCount = CreateKeywordIndex(parameterLib); - return (parameterLib->wordCount); + return (parameterLib->wordCount); } /** @@ -638,19 +641,19 @@ CreateLibraryIndex(ParameterLib *parameterLib) void DiscardLibraryIndex(ParameterLib *trackLib) { - IndexEntry *indexEntry; - IndexEntry *tmp; - - DL_FOREACH_SAFE(trackLib->index, indexEntry, tmp) { - DYNARR_FREE(CatalogEntry *, *(indexEntry->references)); - free(indexEntry->references); - DL_DELETE(trackLib->index, indexEntry); - MyFree(indexEntry); - } - - MyFree(trackLib->words); - trackLib->index = NULL; - trackLib->wordCount = 0; + IndexEntry *indexEntry; + IndexEntry *tmp; + + DL_FOREACH_SAFE(trackLib->index, indexEntry, tmp) { + DYNARR_FREE(CatalogEntry *, *(indexEntry->references)); + free(indexEntry->references); + DL_DELETE(trackLib->index, indexEntry); + MyFree(indexEntry); + } + + MyFree(trackLib->words); + trackLib->index = NULL; + trackLib->wordCount = 0; } @@ -664,19 +667,19 @@ DiscardLibraryIndex(ParameterLib *trackLib) ParameterLib * CreateLibrary(char *directory) { - ParameterLib *library; + ParameterLib *library; - log_params = LogFindIndex("params"); + log_params = LogFindIndex("params"); - library = InitLibrary(); - if (library) { - if (!CreateCatalogFromDir(library, directory)) { - return (NULL); - } + library = InitLibrary(); + if (library) { + if (!CreateCatalogFromDir(library, directory)) { + return (NULL); + } - CreateLibraryIndex(library); - } - return (library); + CreateLibraryIndex(library); + } + return (library); } /** @@ -688,23 +691,23 @@ CreateLibrary(char *directory) void DiscardLibrary(ParameterLib* library) { - CatalogEntry *entry = library->catalog->head; - CatalogEntry *element; - CatalogEntry *tmp; - - DiscardLibraryIndex(library); - - DL_FOREACH_SAFE(entry, element, tmp) { - MyFree(element->contents); - MyFree(element->tag); - for (unsigned int i = 0; i < element->files; i++) { - MyFree(element->fullFileName[i]); - } - DL_DELETE(entry, element); - MyFree(element); - } - MyFree(library->words); - MyFree(library); + CatalogEntry *entry = library->catalog->head; + CatalogEntry *element; + CatalogEntry *tmp; + + DiscardLibraryIndex(library); + + DL_FOREACH_SAFE(entry, element, tmp) { + MyFree(element->contents); + MyFree(element->tag); + for (unsigned int i = 0; i < element->files; i++) { + MyFree(element->fullFileName[i]); + } + DL_DELETE(entry, element); + MyFree(element); + } + MyFree(library->words); + MyFree(library); } /** @@ -718,71 +721,71 @@ DiscardLibrary(ParameterLib* library) char * SearchStatistics(SearchResult *result) { - DynString buffer; - DynString subStats[STATE_COUNT]; + DynString buffer; + DynString subStats[STATE_COUNT]; - unsigned searched = 0; - unsigned discarded = 0; - unsigned notfound = 0; + unsigned searched = 0; + unsigned discarded = 0; + unsigned notfound = 0; unsigned close = 0; - char *resStat; - DynStringMalloc(&buffer, 16); + char *resStat; + DynStringMalloc(&buffer, 16); - for (int i = SEARCHED; i < STATE_COUNT; i++) { - DynStringMalloc(subStats + i, 16); - } + for (int i = SEARCHED; i < STATE_COUNT; i++) { + DynStringMalloc(subStats + i, 16); + } - DynStringCatCStr(subStats + SEARCHED, _("Found: ")); + DynStringCatCStr(subStats + SEARCHED, _("Found: ")); DynStringCatCStr(subStats + CLOSE, _("Similar: ")); - DynStringCatCStr(subStats + DISCARDED, _("Ignored: ")); - DynStringCatCStr(subStats + NOTFOUND, _("Not found: ")); - - for (unsigned int i = 0; i < result->words; i++) { - switch (result->kw[i].state) { - case SEARCHED: - DynStringPrintf(&buffer, "%s (%d) ", result->kw[i].keyWord, - result->kw[i].count); - searched++; - break; - case DISCARDED: - DynStringPrintf(&buffer, "%s ", result->kw[i].keyWord); - discarded++; - break; - case NOTFOUND: - DynStringPrintf(&buffer, "%s ", result->kw[i].keyWord); - notfound++; - break; + DynStringCatCStr(subStats + DISCARDED, _("Ignored: ")); + DynStringCatCStr(subStats + NOTFOUND, _("Not found: ")); + + for (unsigned int i = 0; i < result->words; i++) { + switch (result->kw[i].state) { + case SEARCHED: + DynStringPrintf(&buffer, "%s (%d) ", result->kw[i].keyWord, + result->kw[i].count); + searched++; + break; + case DISCARDED: + DynStringPrintf(&buffer, "%s ", result->kw[i].keyWord); + discarded++; + break; + case NOTFOUND: + DynStringPrintf(&buffer, "%s ", result->kw[i].keyWord); + notfound++; + break; case CLOSE: DynStringPrintf(&buffer, "%s ", result->kw[i].keyWord); close++; break; - default: - break; - } - DynStringCatStr(subStats + result->kw[i].state, &buffer); - } - - DynStringReset(&buffer); - if (searched) { - DynStringCatStr(&buffer, subStats + SEARCHED); - } + default: + break; + } + DynStringCatStr(subStats + result->kw[i].state, &buffer); + } + + DynStringReset(&buffer); + if (searched) { + DynStringCatStr(&buffer, subStats + SEARCHED); + } if (close) { DynStringCatStr(&buffer, subStats + CLOSE); } - if (notfound) { - DynStringCatStr(&buffer, subStats + NOTFOUND); - } - if (discarded) { - DynStringCatStr(&buffer, subStats + DISCARDED); - } - - resStat = MyStrdup(DynStringToCStr(&buffer)); - DynStringFree(&buffer); + if (notfound) { + DynStringCatStr(&buffer, subStats + NOTFOUND); + } + if (discarded) { + DynStringCatStr(&buffer, subStats + DISCARDED); + } + + resStat = MyStrdup(DynStringToCStr(&buffer)); + DynStringFree(&buffer); for (int i = SEARCHED; i < STATE_COUNT; i++) { DynStringFree(subStats + i); } - return (resStat); + return (resStat); } /** @@ -795,30 +798,31 @@ SearchStatistics(SearchResult *result) unsigned countWords(char *str) { - int state = FALSE; - unsigned wc = 0; // word count - - // Scan all characters one by one - while (*str) { - // If next character is a separator, set the - // state as FALSE - if (*str == ' ' || *str == '\n' || *str == '\t' || *str == '\r' || *str == '/') { - state = FALSE; - } - - // If next character is not a word separator and - // state is OUT, then set the state as IN and - // increment word count - else if (state == FALSE) { - state = TRUE; - ++wc; - } - - // Move to next character - ++str; - } - - return wc; + int state = FALSE; + unsigned wc = 0; // word count + + // Scan all characters one by one + while (*str) { + // If next character is a separator, set the + // state as FALSE + if (*str == ' ' || *str == '\n' || *str == '\t' || *str == '\r' + || *str == '/') { + state = FALSE; + } + + // If next character is not a word separator and + // state is OUT, then set the state as IN and + // increment word count + else if (state == FALSE) { + state = TRUE; + ++wc; + } + + // Move to next character + ++str; + } + + return wc; } /** @@ -836,101 +840,101 @@ unsigned SearchLibrary(ParameterLib *library, char *searchExpression, SearchResult *results) { - CatalogEntry *element; - IndexEntry *entries; - unsigned entryCount = 0; - char *searchWord; - unsigned words = countWords(searchExpression); - char *searchExp = MyStrdup(searchExpression); - unsigned i = 0; - - if (library->index == NULL || library->wordCount == 0) { - return (0); - } - - results->kw = MyMalloc(words * sizeof(struct sSingleResult)); - results->subCatalog.head = NULL; - - searchWord = strtok(searchExp, SEARCHDELIMITER); - while (searchWord) { - XtcStrlwr(searchWord); - if (!FilterKeyword(searchWord)) { - StandardizeSpelling(searchWord); - results->kw[i].state = SEARCHED; - } else { - results->kw[i].state = DISCARDED; - } - results->kw[i++].keyWord = MyStrdup(searchWord); - searchWord = strtok(NULL, SEARCHDELIMITER); - } - results->words = words; - - i = 0; - while (i < words) { - if (results->kw[i].state == DISCARDED) { - i++; - continue; - } - FindWord(library->index, library->wordCount, results->kw[i].keyWord, &entries); - if (entries) { - results->kw[i].count = entries->references->cnt; + CatalogEntry *element; + IndexEntry *entries; +// unsigned entryCount = 0; + char *searchWord; + unsigned words = countWords(searchExpression); + char *searchExp = MyStrdup(searchExpression); + unsigned i = 0; + + if (library->index == NULL || library->wordCount == 0) { + return (0); + } + + results->kw = MyMalloc(words * sizeof(struct sSingleResult)); + results->subCatalog.head = NULL; + + searchWord = strtok(searchExp, SEARCHDELIMITER); + while (searchWord) { + XtcStrlwr(searchWord); + if (!FilterKeyword(searchWord)) { + StandardizeSpelling(searchWord); + results->kw[i].state = SEARCHED; + } else { + results->kw[i].state = DISCARDED; + } + results->kw[i++].keyWord = MyStrdup(searchWord); + searchWord = strtok(NULL, SEARCHDELIMITER); + } + results->words = words; + + i = 0; + while (i < words) { + if (results->kw[i].state == DISCARDED) { + i++; + continue; + } + FindWord(library->index, library->wordCount, results->kw[i].keyWord, &entries); + if (entries) { + results->kw[i].count = entries->references->cnt; if (XtcStricmp(results->kw[i].keyWord, entries->keyWord)) { results->kw[i].state = CLOSE; MyFree(results->kw[i].keyWord); results->kw[i].keyWord = MyStrdup(entries->keyWord); } - if (results->subCatalog.head == NULL) { - // if first keyword -> initialize result set - for (int j = 0; j < entries->references->cnt; j++) { - CatalogEntry *newEntry = MyMalloc(sizeof(CatalogEntry)); - CatalogEntry *foundEntry = DYNARR_N(CatalogEntry *, *(entries->references), j); - newEntry->contents = MyStrdup(foundEntry->contents); - newEntry->tag = MyStrdup(foundEntry->tag); - newEntry->files = foundEntry->files; - for (unsigned int i=0;i<newEntry->files;i++) { - newEntry->fullFileName[i] = MyStrdup(foundEntry->fullFileName[i]); - } - - DL_APPEND(results->subCatalog.head, newEntry); - } - } else { - // follow up keyword, create intersection with current result set - CatalogEntry *current; - CatalogEntry *temp; - - DL_FOREACH_SAFE(results->subCatalog.head, current, temp) { - int found = 0; - for (int j = 0; j < entries->references->cnt; j++) { - CatalogEntry *foundEntry = DYNARR_N(CatalogEntry *, *(entries->references), j); - - if (strcmp(foundEntry->contents,current->contents)==0) { - found = TRUE; - break; - } - } - if (!found) { - DL_DELETE(results->subCatalog.head, current); - MyFree(current->contents); - MyFree(current->tag); - for (unsigned int i=0;i<current->files;i++) { - MyFree(current->fullFileName[i]); - } - MyFree(current); - } - } - } - } else { - // Searches that don't yield a result are ignored - results->kw[i].state = NOTFOUND; - results->kw[i].count = 0; - } - i++; - } - - DL_COUNT(results->subCatalog.head, element, results->totalFound); - MyFree(searchExp); - return (results->totalFound); + if (results->subCatalog.head == NULL) { + // if first keyword -> initialize result set + for (int j = 0; j < entries->references->cnt; j++) { + CatalogEntry *newEntry = MyMalloc(sizeof(CatalogEntry)); + CatalogEntry *foundEntry = DYNARR_N(CatalogEntry *, *(entries->references), j); + newEntry->contents = MyStrdup(foundEntry->contents); + newEntry->tag = MyStrdup(foundEntry->tag); + newEntry->files = foundEntry->files; + for (unsigned int i=0; i<newEntry->files; i++) { + newEntry->fullFileName[i] = MyStrdup(foundEntry->fullFileName[i]); + } + + DL_APPEND(results->subCatalog.head, newEntry); + } + } else { + // follow up keyword, create intersection with current result set + CatalogEntry *current; + CatalogEntry *temp; + + DL_FOREACH_SAFE(results->subCatalog.head, current, temp) { + int found = 0; + for (int j = 0; j < entries->references->cnt; j++) { + CatalogEntry *foundEntry = DYNARR_N(CatalogEntry *, *(entries->references), j); + + if (strcmp(foundEntry->contents,current->contents)==0) { + found = TRUE; + break; + } + } + if (!found) { + DL_DELETE(results->subCatalog.head, current); + MyFree(current->contents); + MyFree(current->tag); + for (unsigned int i=0; i<current->files; i++) { + MyFree(current->fullFileName[i]); + } + MyFree(current); + } + } + } + } else { + // Searches that don't yield a result are ignored + results->kw[i].state = NOTFOUND; + results->kw[i].count = 0; + } + i++; + } + + DL_COUNT(results->subCatalog.head, element, results->totalFound); + MyFree(searchExp); + return (results->totalFound); } /** @@ -942,21 +946,21 @@ SearchLibrary(ParameterLib *library, char *searchExpression, void SearchDiscardResult(SearchResult *res) { - if (res) { - CatalogEntry *current = res->subCatalog.head; - CatalogEntry *element; - CatalogEntry *tmp; - - DL_FOREACH_SAFE(current, element, tmp) { - DL_DELETE(current, element); - MyFree(element); - } - - for (unsigned int i = 0; i < res->words; i++) { - MyFree(res->kw[i].keyWord); - } - MyFree(res->kw); - } + if (res) { + CatalogEntry *current = res->subCatalog.head; + CatalogEntry *element; + CatalogEntry *tmp; + + DL_FOREACH_SAFE(current, element, tmp) { + DL_DELETE(current, element); + MyFree(element); + } + + for (unsigned int i = 0; i < res->words; i++) { + MyFree(res->kw[i].keyWord); + } + MyFree(res->kw); + } } /** @@ -969,35 +973,35 @@ SearchDiscardResult(SearchResult *res) char * GetParameterFileContent(char *file) { - FILE *fh; - char *result = NULL; - - fh = fopen(file, "rt"); - if (fh) { - bool found = false; - - while (!found) { - char buffer[512]; - if (fgets(buffer, sizeof(buffer), fh)) { - char *ptr = strtok(buffer, " \t"); - if (!XtcStricmp(ptr, CONTENTSCOMMAND)) { - /* if found, store the rest of the line and the filename */ - ptr = ptr+strlen(CONTENTSCOMMAND)+1; - ptr = strtok(ptr, "\r\n"); - result = MyStrdup(ptr); + FILE *fh; + char *result = NULL; + + fh = fopen(file, "rt"); + if (fh) { + bool found = false; + + while (!found) { + char buffer[512]; + if (fgets(buffer, sizeof(buffer), fh)) { + char *ptr = strtok(buffer, " \t"); + if (!XtcStricmp(ptr, CONTENTSCOMMAND)) { + /* if found, store the rest of the line and the filename */ + ptr = ptr+strlen(CONTENTSCOMMAND)+1; + ptr = strtok(ptr, "\r\n"); + result = MyStrdup(ptr); #ifdef UTFCONVERT - ConvertUTF8ToSystem(result); + ConvertUTF8ToSystem(result); #endif // UTFCONVERT - found = true; - } - } else { - fprintf(stderr, "Nothing found in %s\n", file); - found = true; - } - } - fclose(fh); - } - return (result); + found = true; + } + } else { + fprintf(stderr, "Nothing found in %s\n", file); + found = true; + } + } + fclose(fh); + } + return (result); } /** @@ -1010,68 +1014,69 @@ GetParameterFileContent(char *file) char * GetParameterFileScale(char *file) { - FILE *fh; - char *scale = NULL; - - - fh = fopen(file, "rt"); - if (fh) { - bool found = FALSE, found_Turnout = FALSE, found_Structure = FALSE, found_Car = FALSE; - - while (!found) { - char buffer[512]; - if (fgets(buffer, sizeof(buffer), fh)) { - char *ptr = strtok(buffer, " \t"); - if (!found_Turnout && !XtcStricmp(ptr, TURNOUTCOMMAND)) { - /* if found, store the rest of the line and the filename */ - ptr = ptr+strlen(TURNOUTCOMMAND)+1; - ptr = strtok(ptr, " \t"); - scale = MyMalloc(strlen(TURNOUTCOMMAND)+2+strlen(ptr)); - strcpy(scale,TURNOUTCOMMAND); - char * cp = scale + strlen(TURNOUTCOMMAND); - cp[0] = ' '; - cp++; - strcpy(cp,ptr); - found_Turnout = true; - } else if (!found_Structure && !XtcStricmp(ptr, STRUCTURECOMMAND)) { - /* if found, store the rest of the line and the filename */ - ptr = ptr+strlen(STRUCTURECOMMAND)+1; - ptr = strtok(ptr, " \t"); - scale = MyMalloc(strlen(STRUCTURECOMMAND)+2+strlen(ptr)); - strcpy(scale,STRUCTURECOMMAND); + FILE *fh; + char *scale = NULL; + + + fh = fopen(file, "rt"); + if (fh) { + bool found = FALSE, found_Turnout = FALSE, found_Structure = FALSE, + found_Car = FALSE; + + while (!found) { + char buffer[512]; + if (fgets(buffer, sizeof(buffer), fh)) { + char *ptr = strtok(buffer, " \t"); + if (!found_Turnout && !XtcStricmp(ptr, TURNOUTCOMMAND)) { + /* if found, store the rest of the line and the filename */ + ptr = ptr+strlen(TURNOUTCOMMAND)+1; + ptr = strtok(ptr, " \t"); + scale = MyMalloc(strlen(TURNOUTCOMMAND)+2+strlen(ptr)); + strcpy(scale,TURNOUTCOMMAND); + char * cp = scale + strlen(TURNOUTCOMMAND); + cp[0] = ' '; + cp++; + strcpy(cp,ptr); + found_Turnout = true; + } else if (!found_Structure && !XtcStricmp(ptr, STRUCTURECOMMAND)) { + /* if found, store the rest of the line and the filename */ + ptr = ptr+strlen(STRUCTURECOMMAND)+1; + ptr = strtok(ptr, " \t"); + scale = MyMalloc(strlen(STRUCTURECOMMAND)+2+strlen(ptr)); + strcpy(scale,STRUCTURECOMMAND); char * cp = scale + strlen(STRUCTURECOMMAND)+1; cp[-1] = ' '; strcpy(cp,ptr); - found_Structure = true; - } else if (!found_Car && !XtcStricmp(ptr, CARCOMMAND)) { - /* if found, store the rest of the line and the filename */ - ptr = ptr+strlen(CARCOMMAND)+1; - ptr = strtok(ptr, " \t"); - scale = MyMalloc(strlen(CARCOMMAND)+2+strlen(ptr)); - strcpy(scale,CARCOMMAND); + found_Structure = true; + } else if (!found_Car && !XtcStricmp(ptr, CARCOMMAND)) { + /* if found, store the rest of the line and the filename */ + ptr = ptr+strlen(CARCOMMAND)+1; + ptr = strtok(ptr, " \t"); + scale = MyMalloc(strlen(CARCOMMAND)+2+strlen(ptr)); + strcpy(scale,CARCOMMAND); char * cp = scale + strlen(CARCOMMAND)+1; cp[-1] = ' '; strcpy(cp,ptr); - found_Car = true; - } else if (!found_Car && !XtcStricmp(ptr, CARPROTOCOMMAND)) { - /* if found, store the rest of the line and the filename */ - scale = MyMalloc(strlen(CARPROTOCOMMAND)+3); - strcpy(scale,CARPROTOCOMMAND); + found_Car = true; + } else if (!found_Car && !XtcStricmp(ptr, CARPROTOCOMMAND)) { + /* if found, store the rest of the line and the filename */ + scale = MyMalloc(strlen(CARPROTOCOMMAND)+3); + strcpy(scale,CARPROTOCOMMAND); char * cp = scale + strlen(CARPROTOCOMMAND); strcpy(cp," *"); - found_Car = true; - } - } else { - if (!found_Turnout && !found_Structure && !found_Car) { - fprintf(stderr, "Nothing found in %s\n", file); - found = true; - } - } - if (found_Turnout || found_Structure || found_Car) found = TRUE; - } - fclose(fh); - } - return scale; + found_Car = true; + } + } else { + if (!found_Turnout && !found_Structure && !found_Car) { + fprintf(stderr, "Nothing found in %s\n", file); + found = true; + } + } + if (found_Turnout || found_Structure || found_Car) { found = TRUE; } + } + fclose(fh); + } + return scale; } @@ -1079,22 +1084,22 @@ GetParameterFileScale(char *file) /** this is used to test for memory leaks. It should show no leaks from functions in this source file */ RunMemoryTest(char *directory) { - ParameterLib *library; - SearchResult *results; - - mwInit(); - library = InitLibrary(); - if (library) { - CreateCatalogFromDir(library, directory); - CreateLibraryIndex(library); - results = MyMalloc(sizeof(SearchResult)); - SearchLibrary(library, "peco", results); - SearchDiscardResult(results); - MyFree(results); - DiscardLibraryIndex(library); - DiscardCatalog(library); - } - DestroyLibrary(library); - mwTerm(); + ParameterLib *library; + SearchResult *results; + + mwInit(); + library = InitLibrary(); + if (library) { + CreateCatalogFromDir(library, directory); + CreateLibraryIndex(library); + results = MyMalloc(sizeof(SearchResult)); + SearchLibrary(library, "peco", results); + SearchDiscardResult(results); + MyFree(results); + DiscardLibraryIndex(library); + DiscardCatalog(library); + } + DestroyLibrary(library); + mwTerm(); } #endif //MEMWATCH diff --git a/app/bin/paths.c b/app/bin/paths.c index 4a95a8e..785ff6f 100644 --- a/app/bin/paths.c +++ b/app/bin/paths.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <dynstring.h> @@ -28,9 +28,9 @@ #include "paths.h" struct pathTable { - char type[ PATH_TYPE_SIZE]; /**< type of path */ - DynString path; /**< path */ - UT_hash_handle hh; /**< makes this structure hashable */ + char type[ PATH_TYPE_SIZE]; /**< type of path */ + DynString path; /**< path */ + UT_hash_handle hh; /**< makes this structure hashable */ }; static struct pathTable *paths; @@ -51,9 +51,9 @@ static struct pathTable *FindPath(const char *type); static struct pathTable * FindPath(const char *type) { - struct pathTable *entry; - HASH_FIND_STR(paths, type, entry); - return (entry); + struct pathTable *entry; + HASH_FIND_STR(paths, type, entry); + return (entry); } /** @@ -65,23 +65,23 @@ FindPath(const char *type) static void AddPath(const char *type, char*path) { - struct pathTable *tableEntry; - tableEntry = FindPath(type); - - if (tableEntry) { - DynStringClear(&(tableEntry->path)); - } else { - tableEntry = malloc(sizeof(struct pathTable)); - DynStringMalloc(&tableEntry->path, 16); - strcpy(tableEntry->type, type); + struct pathTable *tableEntry; + tableEntry = FindPath(type); + + if (tableEntry) { + DynStringClear(&(tableEntry->path)); + } else { + tableEntry = malloc(sizeof(struct pathTable)); + DynStringMalloc(&tableEntry->path, 16); + strcpy(tableEntry->type, type); #ifdef WINDOWS #pragma warning( disable : 4267) #endif - // This generates warning C4267 on windows - HASH_ADD_STR(paths, type, tableEntry); - } + // This generates warning C4267 on windows + HASH_ADD_STR(paths, type, tableEntry); + } - DynStringCatCStr(&(tableEntry->path), path); + DynStringCatCStr(&(tableEntry->path), path); } /** @@ -96,23 +96,23 @@ AddPath(const char *type, char*path) */ void SetCurrentPath( - const char * pathType, - const char * fileName) + const char * pathType, + const char * fileName) { - char *path; - char *copy; - assert(fileName != NULL); - assert(pathType != NULL); - copy = strdup(fileName); - path = strrchr(copy, FILE_SEP_CHAR[0]); - - if (path) { - *path = '\0'; - AddPath(pathType, copy); - wPrefSetString(PATHS_SECTION, pathType, copy); - } - - free(copy); + char *path; + char *copy; + CHECK(fileName != NULL); + CHECK(pathType != NULL); + copy = strdup(fileName); + path = strrchr(copy, FILE_SEP_CHAR[0]); + + if (path) { + *path = '\0'; + AddPath(pathType, copy); + wPrefSetString(PATHS_SECTION, pathType, copy); + } + + free(copy); } /** @@ -128,29 +128,29 @@ void SetCurrentPath( */ char *GetCurrentPath( - const char *pathType) + const char *pathType) { - struct pathTable *currentPath; - const char *path; - assert(pathType != NULL); - currentPath = FindPath(pathType); + struct pathTable *currentPath; + const char *path; + CHECK(pathType != NULL); + currentPath = FindPath(pathType); - if (currentPath) { - return (DynStringToCStr(&(currentPath->path))); - } + if (currentPath) { + return (DynStringToCStr(&(currentPath->path))); + } - path = wPrefGetString(PATHS_SECTION, pathType); + path = wPrefGetString(PATHS_SECTION, pathType); - if (!path) { - path = wPrefGetString("file", "directory"); - } + if (!path) { + path = wPrefGetString("file", "directory"); + } - if (!path) { - path = wGetUserHomeDir(); - } + if (!path) { + path = wGetUserHomeDir(); + } - AddPath(pathType, (char *)path); - return ((char *)path); + AddPath(pathType, (char *)path); + return ((char *)path); } /** @@ -177,16 +177,16 @@ void ConvertPathForward(char *string) char *FindFilename(char *path) { - char *name; - name = strrchr(path, FILE_SEP_CHAR[0]); + char *name; + name = strrchr(path, FILE_SEP_CHAR[0]); - if (name) { - name++; - } else { - name = path; - } + if (name) { + name++; + } else { + name = path; + } - return (name); + return (name); } /** @@ -196,7 +196,8 @@ char *FindFilename(char *path) * \return pointer to the file extension part, empty string if no extension present */ -char *FindFileExtension(char *path) { +char *FindFileExtension(char *path) +{ char *ext; ext = strrchr(path, '.'); @@ -223,25 +224,25 @@ char *FindFileExtension(char *path) { void MakeFullpath(char **str, ...) { - va_list valist; - const char *part; - char *separator = FILE_SEP_CHAR; - char lastchar = '\0'; - DynString path; - DynStringMalloc(&path, 0); - va_start(valist, str); - - while ((part = va_arg(valist, const char *))) { - if (part[0] !=separator[0] && lastchar && lastchar != separator[0] && - lastchar != ':') { - DynStringNCatCStr(&path, 1, separator); - } - - DynStringCatCStr(&path, part); - lastchar = part[strlen(part) - 1]; - } - - *str = strdup(DynStringToCStr(&path)); - DynStringFree(&path); + va_list valist; + const char *part; + char *separator = FILE_SEP_CHAR; + char lastchar = '\0'; + DynString path; + DynStringMalloc(&path, 0); + va_start(valist, str); + + while ((part = va_arg(valist, const char *))) { + if (part[0] !=separator[0] && lastchar && lastchar != separator[0] && + lastchar != ':') { + DynStringNCatCStr(&path, 1, separator); + } + + DynStringCatCStr(&path, part); + lastchar = part[strlen(part) - 1]; + } + + *str = strdup(DynStringToCStr(&path)); + DynStringFree(&path); va_end(valist); } diff --git a/app/bin/paths.h b/app/bin/paths.h index f3f5f23..c12e325 100644 --- a/app/bin/paths.h +++ b/app/bin/paths.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef HAVE_PATHS_H diff --git a/app/bin/problemrep.c b/app/bin/problemrep.c new file mode 100644 index 0000000..6e23984 --- /dev/null +++ b/app/bin/problemrep.c @@ -0,0 +1,635 @@ +/** \file problemrep.c + * Collect data for a problem report and remove private info +*/ + +/* XTrkCad - Model Railroad CAD + * Copyright (C) 2024 Martin Fischer + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/stat.h> +#include <time.h> + +#ifdef WINDOWS +#include <Windows.h> +#include <FreeImage.h> +#define CONFIG_DELIMITER '=' +#else +#define strnicmp strncasecmp +#define stricmp strcasecmp +#define CONFIG_DELIMITER ':' +#endif // WINDOWS + +#include <wlib.h> + +#include "include/problemrep.h" +#include "archive.h" +#include "directory.h" +#include "dynstring.h" +#include "fileio.h" +#include "layout.h" +#include "misc.h" +#include "include/paramfilelist.h" +#include "paths.h" +#include "version.h" + +static void SaveSystemInfo(char* dir); +static void ZipProblemData(const char* src); +static void ProblemDataCollect(); + +static dynArr_t configFiles_da; +#define configFile(N) DYNARR_N(char *,configFiles_da,N) + +/** + * Create a temporary directory as intermediate space for collected files. + * The returned pointer has to be MyFree()'d by the caller. + * + * \return pointer to directory name, the complete path + */ + +static char * +CreateTempDirectory() +{ + char* dir; +#ifdef WINDOWS + struct _stat fileStatus; +#else + struct stat fileStatus; +#endif + + dir = wGetTempPath(); + + if (!stat(dir, (struct stat *const) &fileStatus)) { + if (fileStatus.st_mode & S_IFDIR) { + return(dir); + } + } else { + mkdir(dir, 0700); + } + + return MyStrdup(dir); +} + +/** + * Save version information about the operating environment to a file. + * + * \param dir destination directory + */ + +void +SaveSystemInfo(char* dir) +{ + FILE* fh; + char* fileName=NULL; + + MakeFullpath(&fileName, dir, "versions.txt", NULL); + + if (fileName) { + fh = fopen(fileName, "w"); + + fprintf(fh, "XTrackCAD: %s\n", VERSION); + fprintf(fh, "OS: %s\n", wGetOSVersion()); +#ifdef WINDOWS + fprintf(fh, "FreeImage: %s\n", FreeImage_GetVersion()); +#else + // get gtk version + fprintf(fh, "GTK Version: %s", wGetPlatformVersion() ); +#endif // WINDOWS + + fclose(fh); + } + free(fileName); +} + +/** + * Replace the directory name in a configuration file line. Assumption is that + * the name of the directory starts after the '=' (Windows) or ':' (UNIX) + * + * \para result pointer to DynString for result, DynString is cleared if + * directory was not found + * \param in line from configuration file + * \param dir directory name to look for + * \param replace replacement string + * \return true if found and replaced, false otherwise + */ + +static bool +ReplaceDirectoryName(DynString *result, char* in, const char* dir, + char* replace) +{ + bool rc = false; + + DynStringClear(result); + +#ifdef WINDOWS + rc = strnicmp(in, dir, strlen(dir)); +#else + rc = strncmp(in, dir, strlen(dir)); +#endif // WINDOWS + + if(!rc) { + DynStringCatCStrs(result, replace, in + strlen(dir), NULL); + } + return(!rc); +} + +/** + * Find the user id in a string and replace it with a placeholer. + * + * \param result resulting string DynFree() after use + * \param in string to search in + * \param replace replacement string + * \return true if found and replaced + */ + +static bool +ReplaceUserID(DynString* result, char* in, char* replace) +{ + char* user = strstr(in, wGetUserID()); + bool rc = false; + DynStringClear(result); + + if (user) { + DynStringNCatCStr(result, user - in, in); + DynStringCatCStrs(result, replace, user + strlen(user), NULL); + rc = true; + } + + return(rc); +} + +/** + * Replace directory names in a configuration value with the appropriate + * symbolic name for that directory. + * The name of the config value is ignored at the moment, but could be used + * for refined logic + * + * \param result pointer to DynString for modified value + * \param name name of configuration value + * \param value the value + * \return + */ +static bool +FilterConfigLine(DynString *result, char* name, char *value) +{ + bool clean; + + DynStringClear(result); + + clean = ReplaceDirectoryName(result, value, wGetAppLibDir(), + "<<applibdir>>"); + + // NOTE: the order of these calls is important, possible subdirs of a + // homedir must be checked first + if (!clean) { + clean = ReplaceDirectoryName(result, value, wGetAppWorkDir(), + "<<workdir>>"); + if (!clean) { + clean = ReplaceDirectoryName(result, value, wGetUserHomeRootDir(), + "<<home>>"); + } + } + + // replace any remaining references to the current userid + if (!clean) { + clean = ReplaceUserID(result, value, "<<user>>"); + } + + if (!clean) { + DynStringCatCStr(result, value); + } + + return(clean); +} + +/** + * Read a configuration file, replace private information and write result + * to a file. + * + * \param srcfile configuration file to read + * \param destdir destination directory + * \return true + */ + +#define DELIMITER_COUNT (4) // count of delimiter chars in config line + +static bool +PickupConfigFile(char *srcfile, char* destdir) +{ + FILE* fhRead; + FILE* fhWrite; + DynString configLine; + DynString destFile; + + DynStringMalloc(&destFile, FILENAME_MAX); + DynStringMalloc(&configLine, FILENAME_MAX); + + DynStringCatCStrs(&destFile, destdir, FILE_SEP_CHAR, + FindFilename(srcfile), NULL); + + ProblemrepUpdateW(_("Get settings file %s\n"), srcfile); + + fhRead = fopen(srcfile, "r"); + fhWrite = fopen(DynStringToCStr(&destFile), "w"); + + if (fhRead && fhWrite) { + char* lineptr = NULL; + size_t linelen = 0; + + while (!feof(fhRead)) { + char* section; + char* name; + char* value; + size_t totalLength; + + if(getline(&lineptr, &linelen, fhRead)==-1) { + continue; + } + + wPrefTokenize(lineptr, §ion, &name, &value); + if (name && value) { + FilterConfigLine(&configLine, name, value); + + // calculate maximum possible length of resulting line + totalLength = (section ? strlen(section) : 0) + + (name ? strlen(name) : 0) + + (value ? strlen(value) : 0) + DELIMITER_COUNT; + + // increase buffer size by 256 byte if too small + if (totalLength > linelen) { + size_t newLen = ((totalLength + 256) & (~0xff)); + lineptr = realloc(lineptr, newLen); + if (!lineptr) { + AbortProg("!lineptr", __FILE__, __LINE__, + "Can't realloc memory"); + } + linelen = newLen; + } + value = DynStringToCStr(&configLine); + } + wPrefFormatLine(section, name, value, lineptr); + fprintf(fhWrite, "%s\n", lineptr); + } + free(lineptr); + fclose(fhRead); + fclose(fhWrite); + } + DynStringFree(&configLine); + DynStringFree(&destFile); + + return(true); +} + +/** + * Replace the leading part of a directory name with a place holder. + * + * \param result modified directory name + * \param dir original name + * \param search path to be replaced is present + * \param replace replacement + * \return true if found and replaced + */ + +static bool +FilterDirectoryName(DynString* result, char* dir, const char* search, + char* replace) +{ + bool rc = false; + if (!strnicmp(dir, search, strlen(search))) { + DynStringReset(result); + DynStringCatCStrs(result, replace, dir + strlen(search), NULL); + rc = true; + } + + return(rc); +} + +/** + * Filter path information from a NOTE subcommand. In case the home directory + * is referenced it is changed using a place holder. + * In case a NOTE references a file (sub format 2) the home directory + * changed using a place holder + * + * \param out open file handle + * \param work subfunction of NOTE without the leading command + */ + +static void +FilterLayoutNote(FILE* out, char* work) +{ + DynString result; + bool isDocument = false; + char* token; + + DynStringMalloc(&result, FILENAME_MAX); + + fprintf(out, "NOTE "); + + for (int i = 0; i < 8; i++) { + token = strtok(NULL, " \t"); + fprintf(out, "%s ", token); + } + + if (token && !strcmp(token, "2")) { + isDocument = true; + } + // filename is next + token = strtok(NULL, " \t\""); + + char * filename = ConvertFromEscapedText(token); + + if (isDocument && FilterDirectoryName(&result, filename, + wGetUserHomeDir(), "<<home>>")) { + MyFree(filename); + filename = ConvertToEscapedText(DynStringToCStr(&result)); + fprintf(out, "\"%s\"", filename); + } else { + fprintf(out, "\"%s\"", token); + } + + MyFree(filename); + filename = NULL; + + token = strtok(NULL, "\n"); + fprintf(out, "%s\n", token); + + DynStringFree(&result); +} + +/** + * Filter path information from a SET subcommand. In case the home directory + * is referenced it is changed using a place holder + * + * \param out open file handle + * \param work subcommand of LAYERS without the leading command + */ + +static void +FilterLayers(FILE *out, char* work) +{ + DynString result; + + DynStringMalloc(&result, FILENAME_MAX ); + + char* token = strtok(NULL, " \t"); + if (token ) { + if (!stricmp(token, "SET")) { + char* filename; + bool clean; + + fprintf(out, "%s ", token); + token = strtok(NULL, " \t"); + fprintf(out, "%s ",token); + token = strtok(NULL, "\""); + filename = ConvertFromEscapedText(token); + + DYNARR_APPEND(char*, configFiles_da, 1); + configFile(configFiles_da.cnt - 1) = MyStrdup(filename); + + clean = FilterDirectoryName(&result, filename, wGetUserHomeDir(), + "<<home>>"); + if (clean) { + MyFree(filename); + filename = ConvertToEscapedText(DynStringToCStr(&result)); + fprintf(out, "\"%s\"\n", filename); + } else { + fprintf(out, "\"%s\"\n", token); + } + MyFree(filename); + + } else { + const char* remainder = token + strlen(token) + 1; + fprintf(out, "%s %s", token, remainder ); + } + } + DynStringFree(&result); +} + +/** + * Filter privacy information from a single line in xtc format. The result is + * saved to a file + * + * \param out open file handle + * \param in valid line from xtc file + * \return true + */ + +static bool +FilterLayoutLine(FILE *out, const char* in) +{ + char* workCopy = MyStrdup(in); + char* token; + + token = strtok(workCopy, " \t\n"); + if (token) { + bool done = false; + if (!stricmp(token, "LAYERS")) { + // handle LAYERS + fprintf(out, "%s ", token); + FilterLayers(out, workCopy); + done = true; + } + if (!stricmp(token, "NOTE")) { + // handle NOTE document + FilterLayoutNote(out, workCopy); + done = true; + } + if (!done) { + fputs(in, out); + } + } + + MyFree(workCopy); + return(true); +} + +/** + * Get the currently open layout file, filter privacy information and place + * it in an temporary directory. + * + * \param dir destination directory + * \return true + */ + +static bool +PickupLayoutFile(char* dir) +{ + FILE* fhRead; + FILE* fhWrite; + DynString layoutLine; + DynString destFile; + + DynStringMalloc(&destFile, FILENAME_MAX); + DynStringMalloc(&layoutLine, STR_SIZE); + + DynStringCatCStrs(&destFile, dir, FILE_SEP_CHAR, + GetLayoutFilename(), NULL); + + ProblemrepUpdateW(_("Add layout file %s\n"), GetLayoutFullPath()); + fhRead = fopen(GetLayoutFullPath(), "r"); + fhWrite = fopen(DynStringToCStr(&destFile), "w"); + + if (fhRead && fhWrite) { + char* lineptr = NULL; + size_t linelen = 0; + while (!feof(fhRead)) { + getline(&lineptr, &linelen, fhRead); + if (!feof(fhRead)) { + FilterLayoutLine(fhWrite, lineptr); + } + } + free(lineptr); + fclose(fhRead); + fclose(fhWrite); + } + DynStringFree(&layoutLine); + DynStringFree(&destFile); + return(true); +} + +/** + * Get the custom parameter file. + * + * \param dest temporary directory + * \return true on success + */ + +static bool +PickupCustomFile(char* dest) +{ + char* inFile; + char* outFile; + bool rc; + + MakeFullpath(&inFile, wGetAppWorkDir(), "xtrkcad.cus", NULL); + MakeFullpath(&outFile, dest, "xtrkcad.cus", NULL); + ProblemrepUpdateW(_("Add custom parameter definitions\n")); + + rc = Copyfile(inFile, outFile); + + free(inFile); + free(outFile); + + return(rc==0); +} + +/** + * Create a zip file from the collected information. The zip file is created + * in the same directory as the layout design. A unique name is generated from + * the current date and time. + * + * \param src directory with collected information + */ + +static void +ZipProblemData(const char* src) +{ + char* dest = MyStrdup(GetLayoutFullPath()); + char* out; + char *filename = strrchr(dest, PATH_SEPARATOR[0]) + 1; + struct tm* currentTime; + time_t clock; + char timestamp[80]; + + time(&clock); + currentTime = gmtime(&clock); + strftime(timestamp, 80, "pd-%y%m%dT%H%M%S.zip", currentTime); + + *filename = '\0'; + + MakeFullpath(&out, dest, timestamp, NULL); + ProblemrepUpdateW(_("Create zip archive %s\n"), out); + + CreateArchive(src, out); + free(out); +} + +void +ProblemDataCollect() +{ + char* tempDirectory; + char* subdirectory = NULL; + bool ret; + char *filename = GetLayoutFullPath(); + + if(*filename == '\0') { + ProblemrepUpdateW(_("No layout design loaded! Operation is cancelled.\n")); + return; + } + + if (!ProblemSaveLayout()) { + return; + } + + tempDirectory = CreateTempDirectory(); + SaveSystemInfo(tempDirectory); + + DYNARR_APPEND(char *, configFiles_da, 1); + configFile(configFiles_da.cnt - 1) = MyStrdup(wGetProfileFilename()); + + ret = PickupLayoutFile(tempDirectory); + + MakeFullpath(&subdirectory, tempDirectory, "workdir", NULL); + mkdir(subdirectory, 0700); + if (ret) { + ret = PickupCustomFile(subdirectory); + } + + for (int i = 0; i < configFiles_da.cnt; i++) { + char *file = configFile(i); + PickupConfigFile(file, subdirectory); + MyFree(file); + } + free(subdirectory); + subdirectory = NULL; + + MakeFullpath(&subdirectory, tempDirectory, "params", NULL); + mkdir(subdirectory, 0700); + + for (int i = 0; i < GetParamFileCount(); i++) { + char* file = GetParamFileName(i); + + if (strncmp(file, wGetAppLibDir(), strlen(wGetAppLibDir()))) { + char* destfile; + ProblemrepUpdateW(_("Get local parameter file %s\n"), file); + + MakeFullpath(&destfile, subdirectory, FindFilename(file), NULL); + Copyfile(file, destfile); + free(destfile); + } + } + free(subdirectory); + subdirectory = NULL; + + if (ret) { + ZipProblemData(tempDirectory); + + DeleteDirectory(tempDirectory); + } + + DYNARR_FREE(char*, configFiles_da); +} + +void +DoProblemCollect(void* unused) +{ + ProblemrepCreateW(NULL); + + ProblemDataCollect(); +} diff --git a/app/bin/problemrepui.c b/app/bin/problemrepui.c new file mode 100644 index 0000000..22610e3 --- /dev/null +++ b/app/bin/problemrepui.c @@ -0,0 +1,109 @@ +/** \file problemrepui.c + * UI for the problem report function +*/ + +/* XTrkCad - Model Railroad CAD + * Copyright (C) 2024 Martin Fischer + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <wlib.h> + +#include "custom.h" +#include "fileio.h" +#include "layout.h" +#include "param.h" +#include "include/problemrep.h" + +static wWin_p problemrepW; + +#define DESCRIPTION N_("This function puts together information that can " \ + "be helpful to analyze a problem. Private information " \ + "like userids is removed\n\n") + +static paramTextData_t textData = { 60, 10 }; + +static paramData_t problemrepPLs[] = { +#define I_PROBLEMREPPROGRESS (0) +#define PROBLEMREP_T ((wText_p)problemrepPLs[I_PROBLEMREPPROGRESS].control) + { PD_TEXT, NULL, NULL, PDO_DLGRESIZE, &textData, NULL, BO_READONLY | BT_TOP | BT_CHARUNITS } +}; +static paramGroup_t problemrepPG = { "problemdata", 0, problemrepPLs, COUNT(problemrepPLs) }; + +/** + * Create and show the problem report window + */ + +void ProblemrepCreateW(void* ptr) +{ + if (!problemrepW) { + ParamRegister(&problemrepPG); + + problemrepW = ParamCreateDialog(&problemrepPG, + MakeWindowTitle(_("Data for Problem Report")), + NULL, NULL, wHide, TRUE, NULL, + F_TOP | F_CENTER | PD_F_ALT_CANCELLABEL, NULL); + } else { + wTextClear(PROBLEMREP_T); + } + wTextAppend(PROBLEMREP_T, DESCRIPTION); + wShow(problemrepW); +} + +void ProblemrepUpdateW(char* fmt, ...) +{ + int length; + char* buffer; + va_list args; + va_list argsc; + va_start(args, fmt); + va_copy(argsc, args); + + length = vsnprintf(NULL, 0, fmt, args); + buffer = MyMalloc(length + sizeof(NULL)); + va_end(args); + + if (buffer) { + memset(buffer, 0, length +sizeof(NULL)); + + vsnprintf(buffer, length+sizeof(NULL), fmt, argsc); + wTextAppend(PROBLEMREP_T, buffer); + + } + va_end(argsc); + MyFree(buffer); +} + +BOOL_T +ProblemSaveLayout(void) +{ + int rc = TRUE; + if (GetLayoutChanged()) { + + rc = wNoticeEx( NT_WARNING, + _("Trackplan has to be saved first. " \ + "Do you want to do so now ? "), + N_("Save Now..."), + N_("Cancel")); + + if (rc) { + DoSave(NULL); + } else { + ProblemrepUpdateW(_("Operation cancelled\n")); + } + } + return(rc); +} diff --git a/app/bin/scale.c b/app/bin/scale.c new file mode 100644 index 0000000..bfc4edd --- /dev/null +++ b/app/bin/scale.c @@ -0,0 +1,1154 @@ +/** \file scale.c + * Management of information about scales and gauges plus rprintf. + */ + +/* XTrkCad - Model Railroad CAD + * Copyright (C) 2005 Dave Bullis + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "common.h" +#include "cundo.h" +#include "cjoin.h" +#include "compound.h" +#include "custom.h" +#include "draw.h" +#include "fileio.h" +#include "layout.h" +#include "param.h" +#include "track.h" +#include "cselect.h" +#include "common-ui.h" + +/**************************************************************************** + * + * SCALE + * + */ + +#define SCALE_DEMO (-1) +#define SCALE_ANY (-2) +#define SCALE_MULTI (-3) +#define SCALE_UNKNOWN (-4) +#define SCALE_ERROR (-5) + +typedef struct { + char * scale; + DIST_T ratio; + DIST_T gauge; + DIST_T R[3]; + DIST_T X[3]; + DIST_T L[3]; + DIST_T length; + BOOL_T tieDataValid; + tieData_t tieData; +} scaleInfo_t; +typedef scaleInfo_t * scaleInfo_p; +static dynArr_t scaleInfo_da; +#define scaleInfo(N) DYNARR_N( scaleInfo_t, scaleInfo_da, N ) +static SCALEINX_T scaleInfo_cnt=0; + +typedef struct { + char *in_scales; + SCALE_FIT_TYPE_T type; + char *match_scales; + SCALE_FIT_T result; +} scaleComp_t; +typedef scaleComp_t * scaleComp_p; +static dynArr_t scaleCompatible_da; +#define scaleComp(N) DYNARR_N( scaleComp_t, scaleCompatible_da, N ) + +static tieData_t tieData_demo = { + TRUE, + 96.0/160.0, + 16.0/160.0, + 32.0/160.0 +}; + +EXPORT DIST_T curScaleRatio; +EXPORT char * curScaleName; +static scaleInfo_p curScale; +/** @prefs [misc] include same gauge turnouts=1 Unknown */ +EXPORT long includeSameGaugeTurnouts = FALSE; +static SCALEINX_T demoScaleInx = -1; + + +/** this struct holds a gauge description */ +typedef struct { + char * gaugeStr; /** ptr to textual description eg. 'n3' */ + SCALEINX_T scaleInx; /** index of complete information in scaleInfo_da */ +} gaugeInfo_t; + +EXPORT typedef gaugeInfo_t * gaugeInfo_p; + +/** this struct holds a scale description */ +typedef struct { + char *scaleDescStr; /** ptr to textual description eg. 'HO' */ + dynArr_t gauges_da; /** known gauges to this scale */ +} scaleDesc_t; + +EXPORT typedef scaleDesc_t *scaleDesc_p; +static dynArr_t scaleDesc_da; +#define scaleDesc(N) DYNARR_N( scaleDesc_t, scaleDesc_da, N ) + + +static BOOL_T DoSetScaleDesc( SCALEINX_T scaleInx ); + +static int log_scale = 0; + +/** + * Get the scale info for index + * + * This is over-engineered but we somehow end up with + * out of range inx + */ +// Substitute layout scale if scaleInx is invalid +static SCALEINX_T altScaleInx = -1; +static scaleInfo_p GetScaleInfo( SCALEINX_T scaleInx ) +{ + if ( scaleInx >= 0 && scaleInx < scaleInfo_da.cnt ) { + // Good index + LOG( log_scale, 5, ( " GetScaleInfo-1(%d)\n", scaleInx ) ); + return &scaleInfo( scaleInx ); + } + if ( altScaleInx >= 0 ) { + // Previously seen bad index + LOG( log_scale, 4, ( " GetScaleInfo-2(%d)\n", scaleInx ) ); + return &scaleInfo( altScaleInx ); + } + // Bad index + altScaleInx = GetLayoutCurScale(); + int rc = NoticeMessage( MSG_BAD_SCALE_INDEX, curScaleName, "Unknown", + scaleInx, curScaleName ); + if ( rc == 1 ) { + // User ok with using layout scale + LOG( log_scale, 3, ( " GetScaleInfo-3(%d)\n", scaleInx ) ); + return &scaleInfo( altScaleInx ); + } + // Clone existing layout scale as 'Unknown' + DYNARR_APPEND( scaleInfo_t, scaleInfo_da, 1 ); + scaleInfo_p si = &DYNARR_LAST( scaleInfo_t, scaleInfo_da ); + *si = scaleInfo(altScaleInx); + altScaleInx = scaleInfo_da.cnt-1; + si->scale = MyStrdup( "Unknown" ); + LOG( log_scale, 3, ( " GetScaleInfo-4(%d)\n", scaleInx ) ); + //DoSetScaleDesc( scaleInfo_da.cnt-1 ); + return si; +} + + +/** + * Get the index into the linear list from a scale description and a gauge. All information about a + * scale/ gauge combination is stored in a linear list. The index in that list for a given scale and the + * gauge is returned by this function. Note that there is no error checking on parameters! + * + * \param IN scaleInx index into list of scale descriptions + * \param IN gaugeInx index into list of gauges available for this scale + * \return index into master list of scale/gauge combinations + */ + +EXPORT SCALEINX_T GetScaleInx( SCALEDESCINX_T scaleInx, GAUGEINX_T gaugeInx ) +{ + scaleDesc_t s; + gaugeInfo_p g; + + if ( scaleInx < 0 || scaleInx >= scaleDesc_da.cnt ) { + lprintf( "GetScaleInx: bad scaleInx %ld (%d)\n", scaleInx, scaleDesc_da.cnt ); + return 0; + } + s = scaleDesc(scaleInx); + if ( gaugeInx < 0 || gaugeInx >= s.gauges_da.cnt ) { + lprintf( "GetScaleInx: bad gaugeInx %ld (%d)\n", gaugeInx, s.gauges_da.cnt ); + return 0; + } + g = &(DYNARR_N(gaugeInfo_t, s.gauges_da, gaugeInx)); + + return g->scaleInx; + +} +EXPORT DIST_T GetScaleTrackGauge( SCALEINX_T si ) +{ + return GetScaleInfo(si)->gauge; +} + +EXPORT DIST_T GetScaleRatio( SCALEINX_T si ) +{ + return GetScaleInfo(si)->ratio; +} + +EXPORT char * GetScaleName( SCALEINX_T si ) +{ + if ( si == SCALE_DEMO ) { + return "DEMO"; + } + if ( si == SCALE_ANY ) { + return "*"; + } + return GetScaleInfo(si)->scale; +} + +EXPORT void GetScaleEasementValues( DIST_T * R, DIST_T * L ) +{ + wIndex_t i; + for (i=0; i<3; i++) { + *R++ = curScale->R[i]; + *L++ = curScale->L[i]; + } +} + +EXPORT DIST_T GetScaleMinRadius( SCALEINX_T si ) +{ + return GetScaleInfo(si)->R[0]; +} + + +EXPORT void ValidateTieData( tieData_p td ) +{ + td->valid = (td->length > 0.05 && td->width > 0.05 && td->spacing > 0.05); +} + +EXPORT tieData_t GetScaleTieData( SCALEINX_T si ) +{ + scaleInfo_p s; + DIST_T defLength; + + if ( si == SCALE_DEMO ) { + return tieData_demo; + } + s = GetScaleInfo(si); + if ( !s->tieDataValid ) { + sprintf( message, "tiedata-%s", s->scale ); + defLength = (96.0-54.0)/s->ratio+s->gauge; + + /** @prefs [tiedata-<SCALE>] length, width, spacing Sets tie drawing data. + * Example for 6"x8"x6' ties spaced 20" in HOn3 (slash separates 4 lines): + * [tiedata-HOn3] \ length=0.83 \ width=0.07 \ spacing=0.23 + */ + wPrefGetFloat( message, "length", &s->tieData.length, defLength ); + wPrefGetFloat( message, "width", &s->tieData.width, 16.0/s->ratio ); + wPrefGetFloat( message, "spacing", &s->tieData.spacing, 2*s->tieData.width ); + s->tieData.valid = TRUE; + s->tieDataValid = TRUE; + } + return s->tieData; +} + +void +SetScaleGauge(SCALEDESCINX_T desc, GAUGEINX_T gauge) +{ + SCALEINX_T scaleInx = GetScaleInx( desc, gauge ); + LOG( log_scale, 1, ( "SetScaleGauge(%d)\n", scaleInx ) ); + CHECK( 0 <= scaleInx && scaleInx < scaleInfo_cnt ); + SetLayoutCurScale( scaleInx ); +} + +static BOOL_T +SetScaleDescGauge(SCALEINX_T scaleInx) +{ + SCALEDESCINX_T scaleDescInx; + GAUGEINX_T gaugeInx; + if ( GetScaleGauge( scaleInx, &scaleDescInx, &gaugeInx ) ) { + SetLayoutCurScaleDesc( scaleDescInx ); + SetLayoutCurGauge( gaugeInx ); + } + return TRUE; +} + +EXPORT SCALEINX_T LookupScale( const char * name ) +{ + wIndex_t scaleInx; + DIST_T gauge; + LOG( log_scale, 2, ( " LookupScale(%s)", name ) ); + if ( strcmp( name, "*" ) == 0 ) { + LOG( log_scale, 2, ( " .any = %d\n", SCALE_ANY ) ); + return SCALE_ANY; + } + for ( scaleInx=0; scaleInx<scaleInfo_da.cnt; scaleInx++ ) { + if (strcmp( scaleInfo(scaleInx).scale, name ) == 0) { + LOG( log_scale, 2, ( " .name = %d\n", scaleInx ) ); + if ( scaleInx >= scaleInfo_cnt ) { + // Bogus scale + return GetLayoutCurScale(); + } else { + return scaleInx; + } + } + } + if ( isdigit((unsigned char)name[0]) ) { + gauge = atof( name ); + for ( scaleInx=0; scaleInx<scaleInfo_da.cnt; scaleInx++ ) { + if (scaleInfo(scaleInx).gauge == gauge) { + LOG( log_scale, 2, ( " .gauge = %d\n", scaleInx ) ); + return scaleInx; + } + } + } + if ( inPlayback ) { + // Invalid SCALE in recording/demo: abort + InputError( _("Invalid Scale: playback aborted\n SCALE %s"), FALSE, name ); + return GetLayoutCurScale(); + } + // Bad name - create a dummy scale + NoticeMessage( MSG_BAD_SCALE_NAME, _("Ok"), NULL, + name, curScaleName ); + // Clone existing layout scale for dummy + DYNARR_APPEND( scaleInfo_t, scaleInfo_da, 1 ); + scaleInfo_p scaleInfoP = &DYNARR_LAST( scaleInfo_t, scaleInfo_da ); + *scaleInfoP = scaleInfo(GetLayoutCurScale()); + scaleInfoP->scale = MyStrdup( name ); + LOG( log_scale, 2, ( " .new = %d\n", scaleInfo_da.cnt-1 ) ); + //DoSetScaleDesc( scaleInfo_da.cnt-1 ); +// return scaleInfo_da.cnt-1; + return GetLayoutCurScale(); +} + +/* + * Evaluate the fit of a part scale1 to a definition in scale2 for a type. + * + * The rules differ by type of object. + * + * Tracks need to be the same gauge to be a fit. If they are the same scale they are exact. + * If the gauge is the same, but the scale is different they are compatible. + * There are well known exceptions where the scale is not the same but we call them exact. + * + * Structures need to be the same scale to be exact. If they are within 15% they are compatible. + * + * Cars need to be the same gauge and scale to be exact. + * If they are the same gauge, but within 15% of the scale they are compatible. + * + *\param type (FIT_TURNOUT,FIT_STRUCTURE,FIT_CAR) + *\param scale1 the input scale + *\param scale2 the scale to check against + * + *\return FIT_EXACT, FIT_COMPATIBLE, FIT_NONE + */ + +EXPORT SCALE_FIT_T CompatibleScale( + SCALE_FIT_TYPE_T type, + SCALEINX_T scale1, + SCALEINX_T scale2 ) +{ + SCALE_FIT_T rc; + if ( scale1 == scale2 ) { + return FIT_EXACT; + } + if ( scale1 == SCALE_DEMO || scale2 == SCALE_DEMO ) { + return FIT_NONE; + } + if ( scale1 == demoScaleInx || scale2 == demoScaleInx ) { + return FIT_NONE; + } + switch(type) { + case FIT_TURNOUT: + if ( scale1 == SCALE_ANY ) { + return FIT_EXACT; + } + if (scaleInfo(scale1).gauge == scaleInfo(scale2).gauge && + scaleInfo(scale1).scale == scaleInfo(scale2).scale) { + return FIT_EXACT; + } + + rc = FindScaleCompatible(FIT_TURNOUT, scaleInfo(scale1).scale, + scaleInfo(scale2).scale); + if (rc != FIT_NONE) { return rc; } + + if ( includeSameGaugeTurnouts && + scaleInfo(scale1).gauge == scaleInfo(scale2).gauge ) { + return FIT_COMPATIBLE; + } + break; + case FIT_STRUCTURE: + if ( scale1 == SCALE_ANY ) { + return FIT_EXACT; + } + if ( scaleInfo(scale1).ratio == scaleInfo(scale2).ratio ) { + return FIT_EXACT; + } + + rc = FindScaleCompatible(FIT_STRUCTURE, scaleInfo(scale1).scale, + scaleInfo(scale2).scale); + if (rc != FIT_NONE) { return rc; } + + //15% scale match is compatible for structures + if (scaleInfo(scale1).ratio/scaleInfo(scale2).ratio>=0.85 && + scaleInfo(scale1).ratio/scaleInfo(scale2).ratio<=1.15) { + return FIT_COMPATIBLE; + } + break; + case FIT_CAR: + if ( scale1 == SCALE_ANY ) { + return FIT_EXACT; + } + if (scaleInfo(scale1).gauge == scaleInfo(scale2).gauge && + scaleInfo(scale1).scale == scaleInfo(scale2).scale) { + return FIT_EXACT; + } + + rc = FindScaleCompatible(FIT_CAR, scaleInfo(scale1).scale, + scaleInfo(scale2).scale); + if (rc != FIT_NONE) { return rc; } + + //Same gauge and 15% scale match is compatible for cars + if (scaleInfo(scale1).gauge == scaleInfo(scale2).gauge) { + if (scaleInfo(scale1).ratio/scaleInfo(scale2).ratio>=0.85 && + scaleInfo(scale1).ratio/scaleInfo(scale2).ratio<=1.15) { + return FIT_COMPATIBLE; + } + } + break; + + default:; + } + + return FIT_NONE; + +} + +/** Split the scale and the gauge description for a given combination. Eg HOn3 will be + * split to HO and n3. + * \param scaleInx IN scale/gauge combination + * \param scaleDescInx OUT scale part + * \param gaugeInx OUT gauge part + * \return TRUE + */ + +EXPORT BOOL_T +GetScaleGauge( SCALEINX_T scaleInx, SCALEDESCINX_T *scaleDescInx, + GAUGEINX_T *gaugeInx) +{ + + if ( scaleInx > scaleInfo_cnt ) { + *scaleDescInx = SCALE_UNKNOWN; + *gaugeInx = SCALE_UNKNOWN; + return FALSE; + } + + for( SCALEDESCINX_T sdx = 0; sdx < scaleDesc_da.cnt; sdx++ ) { + scaleDesc_p scaleDescP = &DYNARR_N(scaleDesc_t, scaleDesc_da, sdx ); + dynArr_t* gaugesDAP = &scaleDescP->gauges_da; + for( GAUGEINX_T gx = 0; gx < gaugesDAP->cnt; gx++ ) { + gaugeInfo_p gp = &(DYNARR_N( gaugeInfo_t, *gaugesDAP, gx )); + if ( gp->scaleInx == scaleInx ) { + *scaleDescInx = sdx; + *gaugeInx = gx; + return TRUE; + } + } + } + *scaleDescInx = SCALE_UNKNOWN; + *gaugeInx = SCALE_UNKNOWN; + return FALSE; +} + +/** + * Setup XTrkCad for the newly selected scale/gauge combination. + * + */ + +static void +SetScale( void ) +{ + SCALEINX_T newScaleInx = GetLayoutCurScale(); + curScale = GetScaleInfo( newScaleInx ); + trackGauge = curScale->gauge; + curScaleRatio = curScale->ratio; + curScaleName = curScale->scale; + + SetLayoutCurScaleDesc( 0 ); + + SetScaleDescGauge(newScaleInx); + + + if (!inPlayback) { + wPrefSetString( "misc", "scale", curScaleName ); + } + + // now load the minimum radius and set default max grade for the newly selected scale + LoadLayoutMinRadiusPref(curScaleName, curScale->R[0]); + LoadLayoutMaxGradePref(curScaleName, 5.0); +} + +/** + * Check the new scale value and update the program if a valid scale was passed + * + * \param newScale IN the name of the new scale + * \returns TRUE if valid, FALSE otherwise + */ + +static struct { + SCALEINX_T altScaleInx; + wIndex_t scaleInfo_cnt; +} setScaleState; + +EXPORT BOOL_T DoSetScale( + const char * newScale ) +{ + SCALEINX_T scaleInx; + + if ( inPlayback ) { + // Save old state in case we are in playback + setScaleState.altScaleInx = altScaleInx; + setScaleState.scaleInfo_cnt = scaleInfo_cnt; + // Reset invalid scale check + altScaleInx = -1; + DYNARR_SET( scaleInfo_t, scaleInfo_da, scaleInfo_cnt ); + } else if ( inPlaybackQuit ) { + // Restore state after playback + altScaleInx = setScaleState.altScaleInx; + scaleInfo_cnt = setScaleState.scaleInfo_cnt; + } else { + // Reset invalid scale check + altScaleInx = -1; + DYNARR_SET( scaleInfo_t, scaleInfo_da, scaleInfo_cnt ); + } + + scaleInx = LookupScale( newScale ); + if ( scaleInx == SCALE_ANY ) { + // Don't know how this could happen + scaleInx = GetLayoutCurScale(); + } + if ( scaleInx >= scaleInfo_cnt ) { + // Trying to set to unknown scale + scaleInx = GetLayoutCurScale(); + } + LOG( log_scale, 1, ( "DoSetScale(%s) = %d\n", newScale, scaleInx ) ); + CHECK( 0 <= scaleInx && scaleInx < scaleInfo_cnt ); + SetLayoutCurScale( scaleInx ); + DoChangeNotification( CHANGE_SCALE ); + return TRUE; +} + +/** + * Setup the data structures for scale and gauge. XTC reads 'scales' into an dynamic array, + * but doesn't differentiate between scale and gauge. + * This da is split into an dynamic array of scales. Each scale holds a dynamic array of gauges, + * with at least one gauge per scale (ie standard gauge) + * + * For usage in the dialogs, a textual description for each scale or gauge is provided + * + * \return TRUE + */ + +static BOOL_T DoSetScaleDesc( SCALEINX_T scaleInx ) +{ + SCALEINX_T work; + SCALEDESCINX_T descInx; + scaleDesc_p scaleDescP = NULL; + gaugeInfo_p g; + char *cp; +// DIST_T ratio; + char buf[ 80 ]; + size_t len; + + + for( descInx = 0; descInx < scaleDesc_da.cnt; descInx++ ) { + work = GetScaleInx( descInx, 0 ); + if( scaleInfo(work).ratio == scaleInfo(scaleInx).ratio ) { + if( !strncmp( scaleInfo(work).scale, scaleInfo(scaleInx).scale, + strlen(scaleInfo(work).scale))) { + scaleDescP = &scaleDesc(descInx); + } + } + } + + + if( scaleDescP == NULL ) { + /* if no, add as new scale */ + + DYNARR_APPEND( scaleDesc_t, scaleDesc_da, 1 ); + + scaleDescP = &(scaleDesc( scaleDesc_da.cnt-1 )); + + sprintf( buf, "%s (1/%.1f)", scaleInfo(scaleInx).scale, + scaleInfo(scaleInx).ratio ); + scaleDescP->scaleDescStr = MyStrdup( buf ); + + sprintf( buf, "Standard (%.1fmm)", scaleInfo(scaleInx).gauge*25.4 ); + + } else { + /* if yes, is this a new gauge to the scale? */ + cp = strchr( scaleDescP->scaleDescStr, ' ' ); + if( cp ) { + len = cp - scaleDescP->scaleDescStr; + } else { + len = strlen(scaleDescP->scaleDescStr); + } + sprintf( buf, "%s (%.1fmm)", scaleInfo(scaleInx).scale+len, + scaleInfo(scaleInx).gauge*25.4 ); + } + DYNARR_APPEND( gaugeInfo_t, scaleDescP->gauges_da, 10 ); + g = &(DYNARR_N( gaugeInfo_t, scaleDescP->gauges_da, + (scaleDescP->gauges_da).cnt - 1 )); + g->scaleInx = scaleInx; + g->gaugeStr = MyStrdup( buf ); + + return( TRUE ); +} + + +EXPORT BOOL_T DoAllSetScaleDesc( void ) +{ + for( SCALEINX_T scaleInx = 0; scaleInx < scaleInfo_da.cnt; scaleInx++ ) { + DoSetScaleDesc( scaleInx ); + } + return TRUE; +} + + +static BOOL_T AddScale( + char * line ) +{ + wIndex_t i; + BOOL_T rc; + DIST_T R[3], X[3], L[3]; + DIST_T ratio, gauge; + char scale[40]; + scaleInfo_p s; + + if ( (rc=sscanf( line, "SCALE %[^,]," SCANF_FLOAT_FORMAT "," SCANF_FLOAT_FORMAT + "", + scale, &ratio, &gauge )) != 3) { + SyntaxError( "SCALE", rc, 3 ); + return FALSE; + } + for (i=0; i<3; i++) { + line = GetNextLine(); + if ( (rc=sscanf( line, "" SCANF_FLOAT_FORMAT "," SCANF_FLOAT_FORMAT "," + SCANF_FLOAT_FORMAT "", + &R[i], &X[i], &L[i] )) != 3 ) { + SyntaxError( "SCALE easement", rc, 3 ); + return FALSE; + } + } + + // The increment size should be > # SCALEs in xtrkcad.xtq + DYNARR_APPEND( scaleInfo_t, scaleInfo_da, 100 ); + s = &scaleInfo(scaleInfo_da.cnt-1); + s->scale = MyStrdup( scale ); + s->ratio = ratio; + s->gauge = gauge; + // Remember last defined scale + scaleInfo_cnt = scaleInfo_da.cnt; + for (i=0; i<3; i++) { + s->R[i] = R[i]/ratio; + s->X[i] = X[i]/ratio; + s->L[i] = L[i]/ratio; + } + s->tieDataValid = FALSE; + if ( strcmp( scale, "DEMO" ) == 0 ) { + demoScaleInx = scaleInfo_da.cnt-1; + } + return TRUE; +} + +static BOOL_T AddScaleFit( + char * line) +{ + char scales[STR_SIZE], matches[STR_SIZE], type[20], result[20]; + BOOL_T rc; + scaleComp_p s; + + if ( (rc=sscanf( line, "SCALEFIT %s %s %s %s", + type, result, scales, matches )) != 4) { + SyntaxError( "SCALEFIT", rc, 4 ); + return FALSE; + } + DYNARR_APPEND( scaleComp_t, scaleCompatible_da, 10 ); + s = &scaleComp(scaleCompatible_da.cnt-1); + s->in_scales = MyStrdup(scales); + s->match_scales = MyStrdup(matches); + if (strcmp(type,"STRUCTURE") == 0) { + s->type = FIT_STRUCTURE; + } else if (strcmp(type,"TURNOUT")==0) { + s->type = FIT_TURNOUT; + } else if (strcmp(type,"CAR")==0) { + s->type = FIT_CAR; + } else { + InputError( "Invalid SCALEFIT type %s", TRUE, type ); + return FALSE; + } + if (strcmp(result,"COMPATIBLE")==0) { + s->result = FIT_COMPATIBLE; + } else if (strcmp(result,"EXACT")==0) { + s->result = FIT_EXACT; + } else { + InputError( "Invalid SCALEFIT result %s", TRUE, result ); + return FALSE; + } + + return TRUE; +} + +EXPORT SCALE_FIT_T FindScaleCompatible(SCALE_FIT_TYPE_T type, char * scale1, + char * scale2) +{ + + char * cp, * cq; + + if (!scale1 || !scale1[0]) { return FIT_NONE; } + if (!scale2 || !scale2[0]) { return FIT_NONE; } + + for (int i=0; i<scaleCompatible_da.cnt; i++) { + scaleComp_p s; + s = &scaleComp(i); + if (s->type != type) { continue; } + BOOL_T found = FALSE; + cp = s->in_scales; + //Match input scale + while (cp) { + //Next instance of needle in haystack + cp = strstr(cp,scale2); + if (!cp) { break; } + //Check that this is start of csv string + if (cp == s->in_scales || cp[-1] == ',') { + //Is this end of haystack? + if (strlen(cp) == strlen(scale2)) { + found = TRUE; + break; + } + //Is it the same until the next ',' + cq=strstr(cp,","); + if (cq && (cq-cp == strlen(scale2))) { + found = TRUE; + break; + } else { cp=cq; } + } else { cp=strstr(cp,","); } + } + if (!found) { continue; } + found = FALSE; + cp = s->match_scales; + //Match output scale + while (cp) { + //Next instance of needle in haystack + cp = strstr(cp,scale1); + if (!cp) { break; } + //Check that this is start of csv string + if (cp == s->match_scales || cp[-1] == ',') { + //Is this end of haystack? + if (strlen(cp) == strlen(scale1)) { + found = TRUE; + break; + } + //Is it the same until the next ',' + cq=strstr(cp,","); + if (cq && (cq-cp == strlen(scale1))) { + found = TRUE; + break; + } else { cp=cq; } + } else { cp=strstr(cp,","); } + } + if (!found) { continue; } + return s->result; + } + return FIT_NONE; +} + +EXPORT void ScaleLengthIncrement( + SCALEINX_T scale, + DIST_T length ) +{ + char * cp; + size_t len; + if (scaleInfo(scale).length == 0.0) { + if (units == UNITS_METRIC) { + cp = "999.99m SCALE Flex Track"; + } else { + cp = "999' 11\" SCALE Flex Track"; + } + len = strlen( cp )+1; + if (len > enumerateMaxDescLen) { + enumerateMaxDescLen = (int)len; + } + } + scaleInfo(scale).length += length; +} + +EXPORT void ScaleLengthEnd( void ) +{ + wIndex_t si; + size_t count; + DIST_T length; + char tmp[STR_SIZE]; + FLOAT_T flexLen; + long flexUnit; + FLOAT_T flexCost; + for (si=0; si<scaleInfo_da.cnt; si++) { + sprintf( tmp, "price list %s", scaleInfo(si).scale ); + wPrefGetFloat( tmp, "flex length", &flexLen, 0.0 ); + wPrefGetInteger( tmp, "flex unit", &flexUnit, 0 ); + wPrefGetFloat( tmp, "flex cost", &flexCost, 0.0 ); + tmp[0] = '\0'; + if ((length=scaleInfo(si).length) != 0) { + sprintf( tmp, "%s %s Flex Track", FormatDistance(length), scaleInfo(si).scale ); + for (count = strlen(tmp); count<enumerateMaxDescLen; count++) { + tmp[count] = ' '; + } + tmp[enumerateMaxDescLen] = '\0'; + count = 0; + if (flexLen > 0.0) { + count = (int)ceil( length / (flexLen/(flexUnit?2.54:1.00))); + } + EnumerateList( (long)count, flexCost, tmp, NULL ); + } + scaleInfo(si).length = 0; + } +} + + + +EXPORT void LoadScaleList( wList_p scaleList ) +{ + wIndex_t inx; + for (inx=0; inx<scaleDesc_da.cnt-(extraButtons?0:1); inx++) { + wListAddValue( scaleList, scaleDesc(inx).scaleDescStr, NULL, I2VP(inx) ); + } +} + +EXPORT void LoadGaugeList( wList_p gaugeList, SCALEDESCINX_T scale ) +{ + wListClear( gaugeList ); /* remove old list in case */ + for ( wIndex_t inx=0; inx<scaleDesc(scale).gauges_da.cnt; inx++ ) { + gaugeInfo_p g = &DYNARR_N( gaugeInfo_t, scaleDesc(scale).gauges_da, inx ); + wListAddValue( gaugeList, g->gaugeStr, NULL, I2VP(g->scaleInx) ); + } +} + +static void ScaleChange( long changes ) +{ + if (changes & CHANGE_SCALE) { + SetScale(); + } +} + +/***************************************************************************** + * + * Change Scale Dlg + * + */ + +static char rescaleFromScaleStr[20]; +static char rescaleFromGaugeStr[20]; + +static char * rescaleToggleLabels[] = { N_("Scale"), N_("Ratio"), NULL }; +static long rescaleMode; +static wIndex_t rescaleFromScaleInx; +static wIndex_t rescaleFromGaugeInx; +static SCALEDESCINX_T rescaleToScaleInx; +static GAUGEINX_T rescaleToGaugeInx; +static wIndex_t rescaleToInx; +static long rescaleNoChangeDim = FALSE; +static FLOAT_T rescalePercent; +static char * rescaleChangeDimLabels[] = { N_("Do not resize track"), NULL }; +static paramFloatRange_t r0o001_10000 = { 0.001, 10000.0 }; +static paramData_t rescalePLs[] = { +#define I_RESCALE_MODE (0) + { PD_RADIO, &rescaleMode, "toggle", PDO_NOPREF, &rescaleToggleLabels, N_("Rescale by:"), BC_HORZ|BC_NOBORDER }, +#define I_RESCALE_FROM_SCALE (1) + { PD_STRING, rescaleFromScaleStr, "fromS", PDO_NOPREF|PDO_STRINGLIMITLENGTH, I2VP(100), N_("From:"),0, 0, sizeof(rescaleFromScaleStr)}, +#define I_RESCALE_FROM_GAUGE (2) + { PD_STRING, rescaleFromGaugeStr, "fromG", PDO_NOPREF|PDO_DLGHORZ | PDO_STRINGLIMITLENGTH, I2VP(100), " / ", 0, 0, sizeof(rescaleFromGaugeStr)}, +#define I_RESCALE_TO_SCALE (3) + { PD_DROPLIST, &rescaleToScaleInx, "toS", PDO_NOPREF|PDO_LISTINDEX, I2VP(100), N_("To: ") }, +#define I_RESCALE_TO_GAUGE (4) + { PD_DROPLIST, &rescaleToGaugeInx, "toG", PDO_NOPREF|PDO_LISTINDEX|PDO_DLGHORZ, NULL, " / " }, +#define I_RESCALE_CHANGE (5) + { PD_TOGGLE, &rescaleNoChangeDim, "change-dim", 0, &rescaleChangeDimLabels, "", BC_HORZ|BC_NOBORDER }, +#define I_RESCALE_PERCENT (6) + { PD_FLOAT, &rescalePercent, "ratio", 0, &r0o001_10000, N_("Ratio") }, + { PD_MESSAGE, "%", NULL, PDO_DLGHORZ } +}; +static paramGroup_t rescalePG = { "rescale", 0, rescalePLs, COUNT( rescalePLs ) }; + + +static coOrd rescaleShift; +static BOOL_T RescaleDoIt( track_p trk, BOOL_T unused ) +{ + EPINX_T ep, ep1; + track_p trk1; + UndrawNewTrack( trk ); + UndoModify(trk); + if ( rescalePercent != 100.0 ) { + for (ep=0; ep<GetTrkEndPtCnt(trk); ep++) { + if ((trk1 = GetTrkEndTrk(trk,ep)) != NULL && + !GetTrkSelected(trk1)) { + ep1 = GetEndPtConnectedToMe( trk1, trk ); + DisconnectTracks( trk, ep, trk1, ep1 ); + } + } + /* should the track dimensions ie. length or radius be changed as well? */ + if( rescaleNoChangeDim == 0 ) { + RescaleTrack( trk, rescalePercent/100.0, rescaleShift ); + } + } + + if ( rescaleMode==0 ) { + SetTrkScale( trk, rescaleToInx ); + } + DrawNewTrack( trk ); + return TRUE; +} + + +static void RescaleDlgOk( + void * unused ) +{ + coOrd center, size; + DIST_T d; + FLOAT_T ratio = rescalePercent/100.0; + coOrd getboundsLo, getboundsHi; + + UndoStart( _("Rescale Tracks"), "Rescale" ); + GetSelectedBounds( &getboundsLo, &getboundsHi ); + center.x = (getboundsLo.x+getboundsHi.x)/2.0; + center.y = (getboundsLo.y+getboundsHi.y)/2.0; + size.x = (getboundsHi.x-getboundsLo.x)/2.0*ratio; + size.y = (getboundsHi.y-getboundsLo.y)/2.0*ratio; + getboundsLo.x = center.x - size.x; + getboundsLo.y = center.y - size.y; + getboundsHi.x = center.x + size.x; + getboundsHi.y = center.y + size.y; + if ( getboundsLo.x < 0 ) { + getboundsHi.x -= getboundsLo.x; + getboundsLo.x = 0; + } else if ( getboundsHi.x > mapD.size.x ) { + d = getboundsHi.x - mapD.size.x; + if ( getboundsLo.x < d ) { + d = getboundsLo.x; + } + getboundsHi.x -= d; + getboundsLo.x -= d; + } + if ( getboundsLo.y < 0 ) { + getboundsHi.y -= getboundsLo.y; + getboundsLo.y = 0; + } else if ( getboundsHi.y > mapD.size.y ) { + d = getboundsHi.y - mapD.size.y; + if ( getboundsLo.y < d ) { + d = getboundsLo.y; + } + getboundsHi.y -= d; + getboundsLo.y -= d; + } + if ( rescaleNoChangeDim == 0 && + (getboundsHi.x > mapD.size.x || + getboundsHi.y > mapD.size.y )) { + NoticeMessage( MSG_RESCALE_TOO_BIG, _("Ok"), NULL, + FormatDistance(getboundsHi.x), FormatDistance(getboundsHi.y) ); + } + rescaleShift.x = (getboundsLo.x+getboundsHi.x)/2.0 - center.x*ratio; + rescaleShift.y = (getboundsLo.y+getboundsHi.y)/2.0 - center.y*ratio; + + rescaleToInx = GetScaleInx( rescaleToScaleInx, rescaleToGaugeInx ); + DoSelectedTracks( RescaleDoIt ); + + // rescale the background if it exists and the layout is resized + if (HasBackGround() && ratio != 1.0) { + coOrd pos = GetLayoutBackGroundPos(); + double size = GetLayoutBackGroundSize(); + pos.x = ratio * pos.x + rescaleShift.x; + pos.y = ratio * pos.y + rescaleShift.y; + SetLayoutBackGroundPos(pos); + + size *= ratio; + SetLayoutBackGroundSize(size); + } + DoRedraw(); + wHide( rescalePG.win ); +} + + +static void RescaleDlgUpdate( + paramGroup_p pg, + int inx, + void * valueP ) +{ + switch (inx) { + case I_RESCALE_MODE: + wControlShow( pg->paramPtr[I_RESCALE_FROM_SCALE].control, rescaleMode==0 ); + wControlActive( pg->paramPtr[I_RESCALE_FROM_SCALE].control, FALSE ); + wControlShow( pg->paramPtr[I_RESCALE_TO_SCALE].control, rescaleMode==0 ); + wControlShow( pg->paramPtr[I_RESCALE_FROM_GAUGE].control, rescaleMode==0 ); + wControlActive( pg->paramPtr[I_RESCALE_FROM_GAUGE].control, FALSE ); + wControlShow( pg->paramPtr[I_RESCALE_TO_GAUGE].control, rescaleMode==0 ); + wControlShow( pg->paramPtr[I_RESCALE_CHANGE].control, rescaleMode==0 ); + wControlActive( pg->paramPtr[I_RESCALE_PERCENT].control, rescaleMode==1 ); + if ( rescaleMode!=0 ) { + break; + } + case I_RESCALE_TO_SCALE: + LoadGaugeList( (wList_p)rescalePLs[I_RESCALE_TO_GAUGE].control, + *((int *)valueP) ); + rescaleToGaugeInx = 0; + ParamLoadControl( pg, I_RESCALE_TO_GAUGE ); + ParamLoadControl( pg, I_RESCALE_TO_SCALE ); + if ( rescaleFromScaleInx >= 0 ) { + rescalePercent = GetScaleRatio(GetScaleInx(rescaleFromScaleInx,0))/ + GetScaleRatio(GetScaleInx(rescaleToScaleInx,0))*100.0; + } else { + rescalePercent = 100.0; + } + wControlActive( pg->paramPtr[I_RESCALE_CHANGE].control, + (rescaleFromScaleInx != rescaleToScaleInx) ); + ParamLoadControl( pg, I_RESCALE_PERCENT ); + break; + case I_RESCALE_TO_GAUGE: + ParamLoadControl( pg, I_RESCALE_TO_GAUGE ); + break; + case I_RESCALE_FROM_SCALE: + ParamLoadControl( pg, I_RESCALE_FROM_SCALE ); + break; + case I_RESCALE_FROM_GAUGE: + ParamLoadControl( pg, I_RESCALE_FROM_GAUGE ); + break; + case I_RESCALE_CHANGE: + ParamLoadControl( pg, I_RESCALE_CHANGE ); + break; + case -1: + break; + } + wBool_t bOkActive = TRUE; + if ( rescaleMode == 0 ) { + // Scale + bOkActive = rescaleFromScaleInx != rescaleToScaleInx || + rescaleFromGaugeInx != rescaleToGaugeInx; + } else { + // Ratio + bOkActive = rescalePercent != 100.0; + } + ParamDialogOkActive( pg, bOkActive ); +} + +/** + * Get the scale gauge information for the selected track pieces. + * FIXME: special cases like tracks pieces with different gauges or scale need to be handled + * + * \param IN trk track element + * \param IN unused + * \return TRUE; + */ + +static BOOL_T SelectedScaleGauge( track_p trk, BOOL_T unused ) +{ + char *scaleName; + SCALEINX_T scale; + SCALEDESCINX_T scaleInx; + GAUGEINX_T gaugeInx; + + scale = GetTrkScale( trk ); + scaleName = GetScaleName( scale ); + if( strcmp( scaleName, "*" )) { + GetScaleGauge( scale, &scaleInx, &gaugeInx ); + // Determine scale + if ( SCALE_ANY == rescaleFromScaleInx ) { + // First time + rescaleFromScaleInx = scaleInx; + rescaleFromGaugeInx = gaugeInx; + } else if ( SCALE_MULTI == rescaleFromScaleInx ) { + // we 've seen Mixed scales + } else if ( scaleInx != rescaleFromScaleInx ) { + // mixed scales + rescaleFromScaleInx = SCALE_MULTI; + rescaleFromGaugeInx = SCALE_MULTI; + } else if ( gaugeInx != rescaleFromGaugeInx ) { + // same scale but different gauge + rescaleFromGaugeInx = SCALE_MULTI; + } + CHECK( SCALE_ANY != rescaleFromScaleInx ); + } + + return TRUE; +} + +/** + * Bring up the rescale dialog. The dialog for rescaling the selected pieces + * of track is created if necessary and shown. Handling of user input is done via + * RescaleDlgUpdate() + */ + +EXPORT void DoRescale( void * unused ) +{ + if ( rescalePG.win == NULL ) { + ParamCreateDialog( &rescalePG, MakeWindowTitle(_("Rescale")), _("Ok"), + RescaleDlgOk, wHide, TRUE, NULL, F_BLOCK, RescaleDlgUpdate ); + LoadScaleList( (wList_p)rescalePLs[I_RESCALE_TO_SCALE].control ); + LoadGaugeList( (wList_p)rescalePLs[I_RESCALE_TO_GAUGE].control, + GetLayoutCurScaleDesc() ); /* set correct gauge list here */ + rescaleFromScaleInx = GetLayoutCurScale(); + rescaleToScaleInx = rescaleFromScaleInx; + rescalePercent = 100.0; + } + + // Get From scale and gauge + rescaleFromScaleInx = SCALE_ANY; + rescaleFromGaugeInx = SCALE_ANY; + DoSelectedTracks( SelectedScaleGauge ); + if ( SCALE_ANY == rescaleFromScaleInx ) { + strcpy( rescaleFromScaleStr, "*" ); + strcpy( rescaleFromGaugeStr, "" ); + } else if ( SCALE_MULTI == rescaleFromScaleInx ) { + strcpy( rescaleFromScaleStr, "Multi-Scale" ); + strcpy( rescaleFromGaugeStr, "" ); + strcpy( rescaleFromGaugeStr, "" ); + } else if ( SCALE_UNKNOWN == rescaleFromScaleInx ) { + strcpy( rescaleFromScaleStr, "Unknown" ); + strcpy( rescaleFromGaugeStr, "" ); + } else { + scaleDesc_t* scaleDescP = &scaleDesc(rescaleFromScaleInx); + strcpy( rescaleFromScaleStr, scaleDescP->scaleDescStr ); + CHECK( SCALE_ANY != rescaleFromGaugeInx ); + if ( SCALE_MULTI == rescaleFromGaugeInx ) { + strcpy( rescaleFromGaugeStr, "Multi-Gauge" ); + } else { + gaugeInfo_p gaugeInfoP = &(DYNARR_N(gaugeInfo_t, scaleDescP->gauges_da, + rescaleFromGaugeInx)); + strcpy( rescaleFromGaugeStr, gaugeInfoP->gaugeStr ); + } + } + + // get To scale and gauge (current) + GetScaleGauge( GetLayoutCurScale(), &rescaleToScaleInx, &rescaleToGaugeInx ); + + RescaleDlgUpdate( &rescalePG, I_RESCALE_MODE, &rescaleMode ); + RescaleDlgUpdate( &rescalePG, I_RESCALE_CHANGE, &rescaleMode ); + + RescaleDlgUpdate( &rescalePG, I_RESCALE_FROM_SCALE, rescaleFromScaleStr ); + RescaleDlgUpdate( &rescalePG, I_RESCALE_FROM_GAUGE, rescaleFromGaugeStr ); + + // TODO: rescale demo shows blank because DEMO scale inx is beyond the drop box entries + RescaleDlgUpdate( &rescalePG, I_RESCALE_TO_SCALE, &rescaleToScaleInx ); + RescaleDlgUpdate( &rescalePG, I_RESCALE_TO_GAUGE, &rescaleToGaugeInx ); + + InfoMessage( _("%ld Objects to be rescaled"), selectedTrackCount ); + wShow( rescalePG.win ); + InfoMessage( "" ); +} + +/***************************************************************************** + * + * + * + */ + +EXPORT void ScaleInit( void ) +{ + AddParam( "SCALE ", AddScale ); + AddParam( "SCALEFIT", AddScaleFit); + RegisterChangeNotification( ScaleChange ); + wPrefGetInteger( "misc", "include same gauge turnouts", + &includeSameGaugeTurnouts, 1 ); + ParamRegister( &rescalePG ); + log_scale = LogFindIndex( "scale" ); +} diff --git a/app/bin/scale.h b/app/bin/scale.h new file mode 100644 index 0000000..b0834bb --- /dev/null +++ b/app/bin/scale.h @@ -0,0 +1,63 @@ +/** \file scale.h + * + */ + +/* XTrkCad - Model Railroad CAD + * Copyright (C) 2005 Dave Bullis + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef SCALE_H +#define SCALE_H + +#include "common.h" + +extern DIST_T curScaleRatio; +extern char * curScaleName; +DIST_T GetScaleTrackGauge( SCALEINX_T ); +DIST_T GetScaleRatio( SCALEINX_T ); +char * GetScaleName( SCALEINX_T ); +SCALEINX_T GetScaleInx( SCALEDESCINX_T scaleInx, GAUGEINX_T gaugeInx ); + +void GetScaleEasementValues( DIST_T *, DIST_T * ); +DIST_T GetScaleMinRadius( SCALEINX_T ); +void ValidateTieData( tieData_p ); +tieData_t GetScaleTieData( SCALEINX_T ); +SCALEINX_T LookupScale( const char * ); +BOOL_T GetScaleGauge( SCALEINX_T scaleInx, SCALEDESCINX_T *scaleDescInx, + GAUGEINX_T *gaugeInx); +void SetScaleGauge(SCALEDESCINX_T desc, GAUGEINX_T gauge); +BOOL_T DoSetScale( const char * ); + +void ScaleLengthIncrement( SCALEINX_T, DIST_T ); +void ScaleLengthEnd( void ); +void LoadScaleList( wList_p ); +void LoadGaugeList( wList_p, SCALEDESCINX_T ); + +typedef enum {FIT_STRUCTURE, FIT_TURNOUT, FIT_CAR} SCALE_FIT_TYPE_T; +typedef enum {FIT_NONE, FIT_COMPATIBLE, FIT_EXACT} SCALE_FIT_T; +SCALE_FIT_T CompatibleScale( SCALE_FIT_TYPE_T, SCALEINX_T, SCALEINX_T ); + +SCALE_FIT_T FindScaleCompatible(SCALE_FIT_TYPE_T type, char * scale1, + char * scale2); + +BOOL_T DoAllSetScaleDesc( void ); + +void DoRescale( void *unused ); + +EXPORT void ScaleInit( void ); + +#endif diff --git a/app/bin/shortentext.c b/app/bin/shortentext.c index b1b2202..9994915 100644 --- a/app/bin/shortentext.c +++ b/app/bin/shortentext.c @@ -2,24 +2,24 @@ * Some assorted string handling functions */ - /* XTrackCAD - Model Railroad CAD - * Copyright (C) 2019 Martin Fischer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - +/* XTrackCAD - Model Railroad CAD + * Copyright (C) 2019 Martin Fischer + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + #include <string.h> #include "shortentext.h" @@ -28,7 +28,7 @@ /** * Replace all whitespace characters with blanks. Successive occurences are reduced to a single blank. - * + * * \param source IN string to convert * \param dest IN buffer for converted string, minimum size is the size of the source string */ @@ -64,15 +64,16 @@ EllipsizeString(char *source, char *dest, size_t length) // trivial case: nothing to do if source is shorter and no inplace - if( strlen(source) <= length ) - { - if( dest ) + if( strlen(source) <= length ) { + if( dest ) { strcpy(dest, source); + } return; } - if ( dest ) + if ( dest ) { strncpy(resultString, source, length); + } resultString[ length ] = '\0'; @@ -86,9 +87,10 @@ EllipsizeString(char *source, char *dest, size_t length) } } - // no blank in string, replace the last n chars + // no blank in string, replace the last n chars if (!position) { - strcpy(resultString + (strlen(resultString) - sizeof(ELLIPSIZE) + 1), ELLIPSIZE); + strcpy(resultString + (strlen(resultString) - sizeof(ELLIPSIZE) + 1), + ELLIPSIZE); } return; } diff --git a/app/bin/shortentext.h b/app/bin/shortentext.h index 1b71a08..c43deff 100644 --- a/app/bin/shortentext.h +++ b/app/bin/shortentext.h @@ -2,27 +2,27 @@ * String handling utilities */ - /* XTrackCAD - Model Railroad CAD - * Copyright (C) 2019 Martin Fischer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ +/* XTrackCAD - Model Railroad CAD + * Copyright (C) 2019 Martin Fischer + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ #ifndef HAVE_STRINGUTILS_H #define HAVE_STRINGUTILS_H - void RemoveFormatChars(char *source, char *dest); - void EllipsizeString(char *source, char *dest, size_t length); +void RemoveFormatChars(char *source, char *dest); +void EllipsizeString(char *source, char *dest, size_t length); #endif // !HAVE_STRINGUTIL_H diff --git a/app/bin/shrtpath.c b/app/bin/shrtpath.c index da60d0f..f969a12 100644 --- a/app/bin/shrtpath.c +++ b/app/bin/shrtpath.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "shrtpath.h" @@ -34,22 +34,22 @@ static int log_shortPathInitted; typedef enum { Unknown, Working, Final } pathState_e; typedef struct { - pathState_e state; - DIST_T dist; /* Distance from root to entry */ - track_p contTrk; /* continuation */ - EPINX_T contEP; - int inxBack; /* Previous node on shortest path */ - int inxTracks; /* List of tracks along this path */ - int numTracks; - } pathNode_t, *pathNode_p; + pathState_e state; + DIST_T dist; /* Distance from root to entry */ + track_p contTrk; /* continuation */ + EPINX_T contEP; + int inxBack; /* Previous node on shortest path */ + int inxTracks; /* List of tracks along this path */ + int numTracks; +} pathNode_t, *pathNode_p; static dynArr_t pathNode_da; #define pathNode(N) DYNARR_N( pathNode_t, pathNode_da, N ) typedef struct { - track_p trk; - EPINX_T ep1, ep2; - DIST_T dist; - } trackep_t, *trackep_p; + track_p trk; + EPINX_T ep1, ep2; + DIST_T dist; +} trackep_t, *trackep_p; static dynArr_t trackep_da; #define trackep(N) DYNARR_N( trackep_t, trackep_da, N ) @@ -57,12 +57,14 @@ static track_p shortPathTrk0, shortPathTrk1; static EPINX_T shortPathEP0, shortPathEP1; -static int DoShortPathFunc( shortestPathFunc_p func, char * title, SPTF_CMD cmd, track_p trk, EPINX_T ep1, EPINX_T ep2, DIST_T dist, void * data ) +static int DoShortPathFunc( shortestPathFunc_p func, char * title, SPTF_CMD cmd, + track_p trk, EPINX_T ep1, EPINX_T ep2, DIST_T dist, void * data ) { int rc; -LOG( log_shortPath, 4, ( " %s: T%d:%d.%d D:%0.3f ", title, trk?GetTrkIndex(trk):-1, ep1, ep2, dist ) ) + LOG( log_shortPath, 4, ( " %s: T%d:%d.%d D:%0.3f ", title, + trk?GetTrkIndex(trk):-1, ep1, ep2, dist ) ) rc = func( cmd, trk, ep1, ep2, dist, data ); -LOG( log_shortPath, 4, ( "-> %d\n", rc ) ) + LOG( log_shortPath, 4, ( "-> %d\n", rc ) ) return rc; } @@ -76,20 +78,21 @@ static void DumpPaths( int pinx ) for (pinx=0; pinx<pathNode_da.cnt; pinx++) { pPath = &pathNode(pinx); lprintf( " %3d: S%c T%d:%d D%0.3f T%d:%d", - pinx, - pPath->state==Unknown?'U':pPath->state==Working?'W':pPath->state==Final?'F':'?', - (pPath->contTrk?GetTrkIndex(pPath->contTrk):-1), - pPath->contEP, - pPath->dist, - pPath->inxTracks, - pPath->numTracks ); + pinx, + pPath->state==Unknown?'U':pPath->state==Working?'W':pPath->state==Final?'F':'?', + (pPath->contTrk?GetTrkIndex(pPath->contTrk):-1), + pPath->contEP, + pPath->dist, + pPath->inxTracks, + pPath->numTracks ); if (pPath->inxBack>=0) { - lprintf(" B%d", pPath->inxBack ); + lprintf(" B%d", pPath->inxBack ); } lprintf("\n "); for (tinx=0; tinx<pPath->numTracks; tinx++) { pTrackep = &trackep(pPath->inxTracks+tinx); - lprintf( " T%d:%d-%d=%0.1f", GetTrkIndex(pTrackep->trk), pTrackep->ep1, pTrackep->ep2, pTrackep->dist ); + lprintf( " T%d:%d-%d=%0.1f", GetTrkIndex(pTrackep->trk), pTrackep->ep1, + pTrackep->ep2, pTrackep->dist ); } lprintf("\n"); } @@ -97,9 +100,9 @@ static void DumpPaths( int pinx ) static void AddTracksToPath( - int inxCurr, - shortestPathFunc_p func, - void * data ) + int inxCurr, + shortestPathFunc_p func, + void * data ) { pathNode_p pPath; int tinx; @@ -107,9 +110,10 @@ static void AddTracksToPath( while (inxCurr>=0) { pPath = &pathNode(inxCurr); - for (tinx=pPath->numTracks-1;tinx>=0;tinx--) { + for (tinx=pPath->numTracks-1; tinx>=0; tinx--) { pTrackep = &trackep(pPath->inxTracks+tinx); - DoShortPathFunc( func, "ADDTRK", SPTC_ADD_TRK, pTrackep->trk, pTrackep->ep1, pTrackep->ep2, pTrackep->dist, data ); + DoShortPathFunc( func, "ADDTRK", SPTC_ADD_TRK, pTrackep->trk, pTrackep->ep1, + pTrackep->ep2, pTrackep->dist, data ); } inxCurr = pPath->inxBack; } @@ -117,10 +121,10 @@ static void AddTracksToPath( static void AddTrackToNode( - track_p trk, - EPINX_T ep1, - EPINX_T ep2, - DIST_T dist) + track_p trk, + EPINX_T ep1, + EPINX_T ep2, + DIST_T dist) { DYNARR_APPEND( trackep_t, trackep_da, 10 ); trackep(trackep_da.cnt-1).trk = trk; @@ -131,13 +135,13 @@ static void AddTrackToNode( static BOOL_T AddPath( - int inxCurr, - track_p trk0, - EPINX_T ep1, - EPINX_T ep2, - DIST_T dist, - shortestPathFunc_p func, - void * data ) + int inxCurr, + track_p trk0, + EPINX_T ep1, + EPINX_T ep2, + DIST_T dist, + shortestPathFunc_p func, + void * data ) { EPINX_T epN; track_p trk=trk0, trkN; @@ -146,7 +150,8 @@ static BOOL_T AddPath( int startTrack; char * msg=NULL; -LOG( log_shortPath, 2, ( " AddPath( T%d:%d.%d D=%0.3f B%d ) -> \n", GetTrkIndex(trk), ep1, ep2, dist, inxCurr ) ) + LOG( log_shortPath, 2, ( " AddPath( T%d:%d.%d D=%0.3f B%d ) -> \n", + GetTrkIndex(trk), ep1, ep2, dist, inxCurr ) ) startTrack = trackep_da.cnt; while (1) { if ( ep2>=0 ) { @@ -164,13 +169,15 @@ LOG( log_shortPath, 2, ( " AddPath( T%d:%d.%d D=%0.3f B%d ) -> \n", GetTrkIndex msg = "dead end"; goto skipNode; } - if ( DoShortPathFunc( func, "IGNORE", SPTC_IGNNXTTRK, trk, ep2, ep1, dist, data ) ) { + if ( DoShortPathFunc( func, "IGNORE", SPTC_IGNNXTTRK, trk, ep2, ep1, dist, + data ) ) { msg = "ignore end"; goto skipNode; } ep1 = GetEndPtConnectedToMe( trkN, trk ); trk = trkN; - if ( (trk==shortPathTrk0 && ep1==shortPathEP0) || (trk==shortPathTrk1 && ep1==shortPathEP1) ) { + if ( (trk==shortPathTrk0 && ep1==shortPathEP0) || (trk==shortPathTrk1 + && ep1==shortPathEP1) ) { msg = "wrap around"; goto skipNode; } @@ -181,7 +188,8 @@ LOG( log_shortPath, 2, ( " AddPath( T%d:%d.%d D=%0.3f B%d ) -> \n", GetTrkIndex goto skipNode; } if ( epCnt > 2 ) { - if ( (epN=DoShortPathFunc( func, "MATCHANY", SPTC_MATCHANY, trk, ep1, -1, dist, data )) >= 0 ) { + if ( (epN=DoShortPathFunc( func, "MATCHANY", SPTC_MATCHANY, trk, ep1, -1, dist, + data )) >= 0 ) { /* special match */ /*dist += GetTrkLength( trk, ep1, epN );*/ AddTrackToNode( trk, ep1, epN, dist ); @@ -195,12 +203,13 @@ LOG( log_shortPath, 2, ( " AddPath( T%d:%d.%d D=%0.3f B%d ) -> \n", GetTrkIndex } makeNode: -if ( trk ) { -LOG( log_shortPath, 2, ( " -> FORK: [%d] T%d:%d", pathNode_da.cnt, GetTrkIndex(trk), ep1 ) ) -} else { -LOG( log_shortPath, 2, ( " -> MATCH%s: [%d]", msg, pathNode_da.cnt ) ) -} -LOG( log_shortPath, 2, ( " t%d D=%0.3f\n", startTrack, dist ) ) + if ( trk ) { + LOG( log_shortPath, 2, ( " -> FORK: [%d] T%d:%d", pathNode_da.cnt, + GetTrkIndex(trk), ep1 ) ) + } else { + LOG( log_shortPath, 2, ( " -> MATCH%s: [%d]", msg, pathNode_da.cnt ) ) + } + LOG( log_shortPath, 2, ( " t%d D=%0.3f\n", startTrack, dist ) ) DYNARR_APPEND( pathNode_t, pathNode_da, 10 ); pNode = &pathNode(pathNode_da.cnt-1); @@ -208,27 +217,29 @@ LOG( log_shortPath, 2, ( " t%d D=%0.3f\n", startTrack, dist ) ) pNode->dist = dist; pNode->contTrk = trk; pNode->contEP = ep1; - pNode->inxBack = inxCurr; + pNode->inxBack = inxCurr; pNode->inxTracks = startTrack; pNode->numTracks = trackep_da.cnt-startTrack; - if ( trk ) + if ( trk ) { SetTrkBits( trk, TB_SHRTPATH ); + } return TRUE; skipNode: -LOG( log_shortPath, 2, ( " -> FAIL: %s @ T%d:%d.%d\n", msg, GetTrkIndex(trk), ep1, ep2 ) ) - trackep_da.cnt = startTrack; + LOG( log_shortPath, 2, ( " -> FAIL: %s @ T%d:%d.%d\n", msg, GetTrkIndex(trk), + ep1, ep2 ) ) + DYNARR_SET( trackep_t, trackep_da, startTrack ); return FALSE; } int FindShortestPath( - track_p trkN, - EPINX_T epN, - BOOL_T bidirectional, - shortestPathFunc_p func, - void * data ) + track_p trkN, + EPINX_T epN, + BOOL_T bidirectional, + shortestPathFunc_p func, + void * data ) { int inxCurr = 0; pathNode_p pCurr; @@ -238,56 +249,66 @@ int FindShortestPath( int rc = 0; EPINX_T ep2, epCnt, ep3; static dynArr_t ep_da; - #define ep(N) DYNARR_N( pathNode_p, ep_da, N ) +#define ep(N) DYNARR_N( pathNode_p, ep_da, N ) DYNARR_RESET( pathNode_t, pathNode_da ); DYNARR_RESET( trackep_t, trackep_da ); if ( !log_shortPathInitted ) { log_shortPath = LogFindIndex( "shortPath" ); - log_shortPathInitted = TRUE; + log_shortPathInitted = TRUE; } -LOG( log_shortPath, 1, ( "FindShortestPath( T%d:%d, %s, ... )\n", GetTrkIndex(trkN), epN, bidirectional?"bidir":"unidir" ) ) + LOG( log_shortPath, 1, ( "FindShortestPath( T%d:%d, %s, ... )\n", + GetTrkIndex(trkN), epN, bidirectional?"bidir":"unidir" ) ) ClrAllTrkBits( TB_SHRTPATH ); /* Note: trkN:epN is not tested for MATCH */ shortPathTrk0 = trkN; shortPathEP0 = epN; shortPathTrk1 = GetTrkEndTrk( trkN, epN ); - if ( shortPathTrk1 != NULL ) + if ( shortPathTrk1 != NULL ) { shortPathEP1 = GetEndPtConnectedToMe( shortPathTrk1, shortPathTrk0 ); + } AddPath( -1, shortPathTrk0, shortPathEP0, -1, 0.0, func, data ); - if ( bidirectional && shortPathTrk1 != NULL ) + if ( bidirectional && shortPathTrk1 != NULL ) { AddPath( -1, shortPathTrk1, shortPathEP1, -1, 0.0, func, data ); + } while (1) { /* select next final node */ minDist = 0.0; inxCurr = -1; for (pinx=0; pinx<pathNode_da.cnt; pinx++) { - pNext = &pathNode(pinx); - if (pNext->state == Working && - (inxCurr < 0 || pNext->dist < minDist) ) { + pNext = &pathNode(pinx); + if (pNext->state == Working && + (inxCurr < 0 || pNext->dist < minDist) ) { minDist = pathNode(pinx).dist; inxCurr = pinx; } } - if ( inxCurr < 0 ) + if ( inxCurr < 0 ) { break; -if (log_shortPath>=4) DumpPaths(inxCurr); + } + if (log_shortPath>=4) { DumpPaths(inxCurr); } pCurr = &pathNode(inxCurr); pCurr->state = Final; if ( pCurr->contTrk == NULL ) { - if ( !DoShortPathFunc( func, "VALID", SPTC_VALID, trackep(pCurr->inxTracks+pCurr->numTracks-1).trk, trackep(pCurr->inxTracks+pCurr->numTracks-1).ep2, -1, 0.0, data ) ) + if ( !DoShortPathFunc( func, "VALID", SPTC_VALID, + trackep(pCurr->inxTracks+pCurr->numTracks-1).trk, + trackep(pCurr->inxTracks+pCurr->numTracks-1).ep2, -1, 0.0, data ) ) { continue; + } AddTracksToPath( inxCurr, func, data ); rc++; - if ( DoShortPathFunc( func, "TERMINATE", SPTC_TERMINATE, trackep(pCurr->inxTracks+pCurr->numTracks-1).trk, trackep(pCurr->inxTracks+pCurr->numTracks-1).ep2, -1, 0.0, data ) ) + if ( DoShortPathFunc( func, "TERMINATE", SPTC_TERMINATE, + trackep(pCurr->inxTracks+pCurr->numTracks-1).trk, + trackep(pCurr->inxTracks+pCurr->numTracks-1).ep2, -1, 0.0, data ) ) { break; + } } else { epCnt = GetTrkEndPtCnt(pCurr->contTrk); DYNARR_SET( pathNode_p, ep_da, epCnt ); - memset( ep_da.ptr, 0, epCnt * sizeof pNext ); + memset( &ep(0), 0, epCnt * sizeof pNext ); if ( (GetTrkBits(pCurr->contTrk) & TB_SHRTPATH) ) { for ( pinx=0; pinx<pathNode_da.cnt; pinx++ ) { pNext = &pathNode(pinx); @@ -300,25 +321,27 @@ if (log_shortPath>=4) DumpPaths(inxCurr); pCurr = &pathNode(inxCurr); /* don't point back at myself */ - if ( pCurr->contEP == ep2 ) continue; + if ( pCurr->contEP == ep2 ) { continue; } /* no route to ep */ - if ( DoShortPathFunc( func, "IGNORE", SPTC_IGNNXTTRK, pCurr->contTrk, pCurr->contEP, ep2, pCurr->dist, data ) ) continue; + if ( DoShortPathFunc( func, "IGNORE", SPTC_IGNNXTTRK, pCurr->contTrk, + pCurr->contEP, ep2, pCurr->dist, data ) ) { continue; } /* somebody got here first */ - if ( ep(ep2) ) continue; + if ( ep(ep2) ) { continue; } /* there is already a path out via ep2 */ for ( ep3=0; ep3<epCnt; ep3++ ) { - if ( ep3==pCurr->contEP || ep3==ep2 ) continue; - if ( ep(ep3) == NULL ) continue; - if ( DoShortPathFunc( func, "IGNORE", SPTC_IGNNXTTRK, pCurr->contTrk, ep2, ep3, pCurr->dist, data ) ) continue; - if ( ep(ep3)->state == Final ) break; + if ( ep3==pCurr->contEP || ep3==ep2 ) { continue; } + if ( ep(ep3) == NULL ) { continue; } + if ( DoShortPathFunc( func, "IGNORE", SPTC_IGNNXTTRK, pCurr->contTrk, ep2, ep3, + pCurr->dist, data ) ) { continue; } + if ( ep(ep3)->state == Final ) { break; } } - if ( ep3 < epCnt ) continue; + if ( ep3 < epCnt ) { continue; } AddPath( inxCurr, pCurr->contTrk, pCurr->contEP, ep2, pCurr->dist, func, data ); } } } -if (log_shortPath>=1) DumpPaths(inxCurr); + if (log_shortPath>=1) { DumpPaths(inxCurr); } ClrAllTrkBits( TB_SHRTPATH ); return rc; } diff --git a/app/bin/shrtpath.h b/app/bin/shrtpath.h index c7cb57f..b106df6 100644 --- a/app/bin/shrtpath.h +++ b/app/bin/shrtpath.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef HAVE_SHRTPATH_H #define HAVE_SHRTPATH_H @@ -25,16 +25,17 @@ #include "common.h" typedef enum { - SPTC_MATCH, /* trk:ep is end of path? */ - SPTC_MATCHANY, /* any EP matches? */ - SPTC_IGNNXTTRK, /* don't traverse via trk:ep? */ - SPTC_ADD_TRK, /* trk:ep is next on current path */ - SPTC_TERMINATE, /* stop processing after current path? */ - SPTC_VALID /* trk:ep is still valid? */ - } SPTF_CMD; + SPTC_MATCH, /* trk:ep is end of path? */ + SPTC_MATCHANY, /* any EP matches? */ + SPTC_IGNNXTTRK, /* don't traverse via trk:ep? */ + SPTC_ADD_TRK, /* trk:ep is next on current path */ + SPTC_TERMINATE, /* stop processing after current path? */ + SPTC_VALID /* trk:ep is still valid? */ +} SPTF_CMD; -typedef int (*shortestPathFunc_p)( SPTF_CMD cmd, track_p, EPINX_T, EPINX_T, DIST_T, void * ); +typedef int (*shortestPathFunc_p)( SPTF_CMD cmd, track_p, EPINX_T, EPINX_T, + DIST_T, void * ); int FindShortestPath( track_p, EPINX_T, BOOL_T, shortestPathFunc_p, void * ); extern int log_shortPath; -#endif //HAVE_SHRTPATH_H
\ No newline at end of file +#endif //HAVE_SHRTPATH_H diff --git a/app/bin/smalldlg.c b/app/bin/smalldlg.c index 3d45809..1dde15e 100644 --- a/app/bin/smalldlg.c +++ b/app/bin/smalldlg.c @@ -1,5 +1,5 @@ /** \file smalldlg.c - * Several simple and smaller dialogs. + * Several simple and smaller dialogs. */ /* XTrkCad - Model Railroad CAD @@ -18,7 +18,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "common.h" @@ -34,7 +34,6 @@ #include <FreeImage.h> #endif -extern char *sTipF; EXPORT wWin_p aboutW; static wWin_p tipW; /**< window handle for tip dialog */ @@ -50,16 +49,17 @@ static paramData_t tipPLs[] = { #define I_TIPTEXT (1) #define tipT ((wText_p)tipPLs[I_TIPTEXT].control) { PD_MESSAGE, N_("Did you know..."), NULL, 0, NULL, NULL, BM_LARGE }, - { PD_TEXT, NULL, "text", 0, &tipTextData, NULL, BO_READONLY|BT_TOP|BT_CHARUNITS }, - { PD_BUTTON, ShowTip, "prev", PDO_DLGRESETMARGIN, NULL, N_("Previous Tip"), 0L, I2VP(SHOWTIP_FORCESHOW | SHOWTIP_PREVTIP) }, + { PD_TEXT, NULL, "text", PDO_DLGRESIZE, &tipTextData, NULL, BO_READONLY|BT_TOP|BT_CHARUNITS }, + { PD_BUTTON, ShowTip, "prev", PDO_DLGRESETMARGIN, NULL, N_("Previous Tip"), 0L, I2VP(SHOWTIP_FORCESHOW | SHOWTIP_PREVTIP) }, { PD_BUTTON, ShowTip, "next", PDO_DLGHORZ, NULL, N_("Next Tip"), 0L, I2VP(SHOWTIP_FORCESHOW | SHOWTIP_NEXTTIP) }, - { PD_TOGGLE, &showTipAtStart, "showatstart", PDO_DLGCMDBUTTON, tipLabels, NULL, BC_NOBORDER }}; + { PD_TOGGLE, &showTipAtStart, "showatstart", PDO_DLGCMDBUTTON, tipLabels, NULL, BC_NOBORDER } +}; static paramGroup_t tipPG = { "tip", 0, tipPLs, COUNT( tipPLs ) }; /** * Create and initialize the tip of the day window. The dialog box is created and the list of tips is loaded - * into memory. + * into memory. */ static void CreateTipW( void ) @@ -69,35 +69,38 @@ static void CreateTipW( void ) char *filename; char * cp; - tipW = ParamCreateDialog( &tipPG, MakeWindowTitle(_("Tip of the Day")), NULL, NULL, wHide, FALSE, NULL, F_RESIZE|F_CENTER|PD_F_ALT_CANCELLABEL, NULL ); + tipW = ParamCreateDialog( &tipPG, MakeWindowTitle(_("Tip of the Day")), NULL, + NULL, wHide, FALSE, NULL, F_RESIZE|F_CENTER|PD_F_ALT_CANCELLABEL, NULL ); /* open the tip file */ MakeFullpath(&filename, libDir, sTipF, NULL); tipF = fopen( filename, "r" ); - + /* if tip file could not be opened, the only tip is an error message for the situation */ if (tipF == NULL) { DYNARR_APPEND( char *, tips_da, 1 ); tips(0) = N_("No tips are available"); -/* TODO: enable buttons only if tips are available - wControlActive( prev, FALSE ); - wControlActive( next, FALSE ); */ + /* TODO: enable buttons only if tips are available + wControlActive( prev, FALSE ); + wControlActive( next, FALSE ); */ } else { /* read all the tips from the file */ while (fgets( buff, sizeof buff, tipF )) { /* lines starting with hash sign are ignored (comments) */ - if (buff[0] == '#') + if (buff[0] == '#') { continue; - - /* remove CRs and LFs at end of line */ + } + + /* remove CRs and LFs at end of line */ cp = buff+strlen(buff)-1; - if (*cp=='\n') cp--; - if (*cp=='\r') cp--; - + if (*cp=='\n') { cp--; } + if (*cp=='\r') { cp--; } + /* get next line if the line was empty */ - if (cp < buff) + if (cp < buff) { continue; + } cp[1] = 0; @@ -105,23 +108,24 @@ static void CreateTipW( void ) while (*cp=='\\') { /* put LF at end */ *cp++ = '\n'; - - /* read a line */ + + /* read a line */ if (!fgets( cp, (int)((sizeof buff) - (cp-buff)), tipF )) { return; } - + /* lines starting with hash sign are ignored (comments) */ - if (*cp=='#') + if (*cp=='#') { continue; + } - /* remove CRs and LFs at end of line */ + /* remove CRs and LFs at end of line */ cp += strlen(cp)-1; - if (*cp=='\n') cp--; - if (*cp=='\r') cp--; + if (*cp=='\n') { cp--; } + if (*cp=='\r') { cp--; } cp[1] = 0; } - + /* allocate memory for the tip and store pointer in dynamic array */ DYNARR_APPEND( char *, tips_da, 10 ); tips(tips_da.cnt-1) = strdup( buff ); @@ -132,7 +136,7 @@ static void CreateTipW( void ) /** * Show tip of the day. As far as necessary, the dialog is created. The index of - * the last tip shown is retrieved from the preferences and the next tip is + * the last tip shown is retrieved from the preferences and the next tip is * selected. At the end, the index of the shown tip is saved into the preferences. * * \param IN flags see definitions in smalldlg.h for possible values @@ -143,9 +147,8 @@ void ShowTip( void * flagsVP ) { long flags = VP2L(flagsVP); long tipNum; - - if (showTipAtStart || (flags & SHOWTIP_FORCESHOW)) - { + + if (showTipAtStart || (flags & SHOWTIP_FORCESHOW)) { if (tipW == NULL) { CreateTipW(); } @@ -153,24 +156,26 @@ void ShowTip( void * flagsVP ) wTextClear( tipT ); /* initial value is -1 which gets incremented 0 below */ wPrefGetInteger( "misc", "tip-number", &tipNum, -1 ); - + if( flags & SHOWTIP_PREVTIP ) { - if(tipNum == 0 ) + if(tipNum == 0 ) { tipNum = tips_da.cnt - 1; - else - tipNum--; + } else { + tipNum--; + } } else { - if (tipNum >= tips_da.cnt - 1) + if (tipNum >= tips_da.cnt - 1) { tipNum = 0; - else - tipNum++; - } + } else { + tipNum++; + } + } wTextAppend( tipT, _(tips(tipNum)) ); wPrefSetInteger( "misc", "tip-number", tipNum ); wShow( tipW ); - } + } } /*--------------------------------------------------------------------*/ @@ -191,43 +196,54 @@ static paramData_t aboutPLs[] = { }; static paramGroup_t aboutPG = { "about", 0, aboutPLs, COUNT( aboutPLs ) }; -/** +/** * Create and show the About window. */ void CreateAboutW(void *ptr) { - char *copyright = sAboutProd; +// char *copyright = sAboutProd; if (!aboutW) { aboutPLs[I_ABOUTDRAW].winData = wIconCreatePixMap(xtc_xpm); ParamRegister(&aboutPG); - aboutW = ParamCreateDialog(&aboutPG, MakeWindowTitle(_("About")), NULL, NULL, wHide, FALSE, NULL, F_TOP | F_CENTER| PD_F_ALT_CANCELLABEL, NULL); + aboutW = ParamCreateDialog(&aboutPG, MakeWindowTitle(_("About")), NULL, NULL, + wHide, FALSE, NULL, F_TOP | F_CENTER| PD_F_ALT_CANCELLABEL, NULL); ParamLoadMessage(&aboutPG, I_ABOUTVERSION, sAboutProd); wTextAppend(COPYRIGHT_T, DESCRIPTION); - wTextAppend(COPYRIGHT_T, "\n\nXTrackCAD is Copyright 2003 by Sillub Technology and 2017 by Bob Blackwell, Martin Fischer and Adam Richards.\n"); - wTextAppend(COPYRIGHT_T, "\nIcons by: Tango Desktop Project (http://tango.freedesktop.org)\n"); - wTextAppend(COPYRIGHT_T, "\nSome icons by Yusuke Kamiyamane. Licensed under a Creative Commons Attribution 3.0 License.\n"); - wTextAppend(COPYRIGHT_T, "\nContributions by: Robert Heller, Mikko Nissinen, Timothy M. Shead, Russell Shilling, Daniel Luis Spagnol"); + wTextAppend(COPYRIGHT_T, + "\n\nXTrackCAD is Copyright 2003 by Sillub Technology and 2017 by Bob Blackwell, Martin Fischer and Adam Richards.\n"); + wTextAppend(COPYRIGHT_T, + "\nIcons by: Tango Desktop Project (http://tango.freedesktop.org)\n"); + wTextAppend(COPYRIGHT_T, + "\nSome icons by Yusuke Kamiyamane. Licensed under a Creative Commons Attribution 3.0 License.\n"); + wTextAppend(COPYRIGHT_T, + "\nContributions by: Robert Heller, Mikko Nissinen, Timothy M. Shead, Russell Shilling, Daniel Luis Spagnol"); wTextAppend(COPYRIGHT_T, "\nParameter Files by: Ralph Boyd, Dwayne Ward\n"); - wTextAppend(COPYRIGHT_T, "\nThe following software is distributed with XTrackCAD\n\n"); + wTextAppend(COPYRIGHT_T, + "\nThe following software is distributed with XTrackCAD\n\n"); #ifdef WINDOWS wTextAppend(COPYRIGHT_T, FreeImage_GetCopyrightMessage()); wTextAppend(COPYRIGHT_T, "\n\n"); #endif wTextAppend(COPYRIGHT_T, "Cornu Algorithm and Implementation by: Raph Levien"); wTextAppend(COPYRIGHT_T, "\n\nuthash, utlist Copyright notice:"); - wTextAppend(COPYRIGHT_T, "\nCopyright (c) 2005-2015, Troy D. Hanson http://troydhanson.github.com/uthash/"); + wTextAppend(COPYRIGHT_T, + "\nCopyright (c) 2005-2015, Troy D. Hanson http://troydhanson.github.com/uthash/"); wTextAppend(COPYRIGHT_T, "\nAll rights reserved."); - wTextAppend(COPYRIGHT_T, "\n\ncJSON: Copyright (c) 2009-2017 Dave Gamble and cJSON contributors"); - wTextAppend(COPYRIGHT_T, "\n\nlibzip: Copyright(C) 1999 - 2019 Dieter Baron and Thomas Klausner\n" \ - "The authors can be contacted at libzip@nih.at"); - - wTextAppend(COPYRIGHT_T, "\n\nMiniXML: Copyright (c) 2003-2019 by Michael R Sweet.\n" \ - "The Mini - XML library is licensed under the Apache License Version 2.0 with an\n" \ - "exception to allow linking against GPL2 / LGPL2 - only software."); + wTextAppend(COPYRIGHT_T, + "\n\ncJSON: Copyright (c) 2009-2017 Dave Gamble and cJSON contributors"); + wTextAppend(COPYRIGHT_T, + "\n\nlibzip: Copyright(C) 1999 - 2019 Dieter Baron and Thomas Klausner\n" \ + "The authors can be contacted at libzip@nih.at"); + + wTextAppend(COPYRIGHT_T, + "\n\nMiniXML: Copyright (c) 2003-2019 by Michael R Sweet.\n" \ + "The Mini - XML library is licensed under the Apache License Version 2.0 with an\n" + \ + "exception to allow linking against GPL2 / LGPL2 - only software."); } wShow(aboutW); @@ -238,8 +254,8 @@ void CreateAboutW(void *ptr) /** * Initialize the functions for small dialogs. */ - + void InitSmallDlg( void ) { - ParamRegister( &tipPG ); -} + ParamRegister( &tipPG ); +} diff --git a/app/bin/smalldlg.h b/app/bin/smalldlg.h index d3c21a6..47e1def 100644 --- a/app/bin/smalldlg.h +++ b/app/bin/smalldlg.h @@ -1,9 +1,9 @@ /** \file smalldlg.h - * Definitions and declarations for the small dialog box functions. + * Definitions and declarations for the small dialog box functions. */ /* XTrkCad - Model Railroad CAD - * Copyright (C) + * Copyright (C) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef SMALLDLG_H diff --git a/app/bin/stringxtc.c b/app/bin/stringxtc.c index 483f1a6..e65a97d 100644 --- a/app/bin/stringxtc.c +++ b/app/bin/stringxtc.c @@ -1,106 +1,145 @@ -/** \file stringxtc.c
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- */
-
- /*
- * stupid library routines.
- */
-
-#include <ctype.h>
-#include <stddef.h>
-#include <errno.h>
-#include "include/stringxtc.h"
-
-/**
- * strscpy - Copy a C-string into a sized buffer
- * @dest: Where to copy the string to
- * @src: Where to copy the string from
- * @count: Size of destination buffer
- *
- * Copy the string, or as much of it as fits, into the dest buffer. The
- * behavior is undefined if the string buffers overlap. The destination
- * buffer is always NUL terminated, unless it's zero-sized.
- *
- * Preferred to strlcpy() since the API doesn't require reading memory
- * from the src string beyond the specified "count" bytes, and since
- * the return value is easier to error-check than strlcpy()'s.
- * In addition, the implementation is robust to the string changing out
- * from underneath it, unlike the current strlcpy() implementation.
- *
- * Preferred to strncpy() since it always returns a valid string, and
- * doesn't unnecessarily force the tail of the destination buffer to be
- * zeroed. If zeroing is desired please use strscpy_pad().
- *
- * Return: The number of characters copied (not including the trailing
- * %NUL) or -E2BIG if the destination buffer wasn't big enough.
- */
-
-size_t strscpy(char *dest, const char *src, size_t count)
-{
- long res = 0;
-
- if (count == 0)
- return -E2BIG;
-
- while (count) {
- char c;
-
- c = src[res];
- dest[res] = c;
- if (!c)
- return res;
- res++;
- count--;
- }
-
- /* Hit buffer length without finding a NUL; force NUL-termination. */
- if (res)
- dest[res - 1] = '\0';
-
- return -E2BIG;
-}
-
-/**
- * Convert a string to lower case
- * Taken from https://stackoverflow.com/questions/23618316/undefined-reference-to-strlwr
- *
- * \param str IN string to convert
- * \return pointer to converted string
- */
-
-char *
-XtcStrlwr(char *str)
-{
- unsigned char *p = (unsigned char *)str;
-
- while (*p) {
- *p = tolower((unsigned char)*p);
- p++;
- }
-
- return str;
-}
-
-/**
- * Compare two strings case insensitive
- * Taken from https://stackoverflow.com/questions/30733786/c99-remove-stricmp-and-strnicmp
- *
- * \param a, b IN strings to compare
- * \return
- */
-
+/** \file stringxtc.c + * + * Copyright (C) 1991, 1992 Linus Torvalds + */ + +/* + * stupid library routines. + */ + +#include <ctype.h> +#include <stddef.h> +#include <errno.h> +#include <string.h> +#include "include/stringxtc.h" + +/** + * strscpy - Copy a C-string into a sized buffer + * @dest: Where to copy the string to + * @src: Where to copy the string from + * @count: Size of destination buffer + * + * Copy the string, or as much of it as fits, into the dest buffer. The + * behavior is undefined if the string buffers overlap. The destination + * buffer is always NUL terminated, unless it's zero-sized. + * + * Preferred to strlcpy() since the API doesn't require reading memory + * from the src string beyond the specified "count" bytes, and since + * the return value is easier to error-check than strlcpy()'s. + * In addition, the implementation is robust to the string changing out + * from underneath it, unlike the current strlcpy() implementation. + * + * Preferred to strncpy() since it always returns a valid string, and + * doesn't unnecessarily force the tail of the destination buffer to be + * zeroed. If zeroing is desired please use strscpy_pad(). + * + * Return: The number of characters copied (not including the trailing + * %NUL) or -E2BIG if the destination buffer wasn't big enough. + */ + +size_t strscpy(char *dest, const char *src, size_t count) +{ + long res = 0; + + if (count == 0) { + return -E2BIG; + } + + while (count) { + char c; + + c = src[res]; + dest[res] = c; + if (!c) { + return res; + } + res++; + count--; + } + + /* Hit buffer length without finding a NUL; force NUL-termination. */ + if (res) { + dest[res - 1] = '\0'; + } + + return -E2BIG; +} + +/* Safe version of strcat - will not overflow buffer + * Return: The number of characters in buffer (not including the trailing + * % NUL) or -E2BIG if the destination buffer wasn't big enough. + */ +size_t +strscat(char* dest, const char* src, size_t count) +{ + long sptr = 0; + long dptr = strlen(dest); + count -= dptr; + + if (count <= 0) { + return -E2BIG; + } + + while (count) { + char c; + + c = src[sptr]; + dest[dptr] = c; + if (!c) { + return dptr; + } + sptr++; + dptr++; + count--; + } + + /* Hit buffer length without finding a NUL; force NUL-termination. */ + if (dptr) { + dest[dptr - 1] = '\0'; + } + + return -E2BIG; +} + +/** + * Convert a string to lower case + * Taken from https://stackoverflow.com/questions/23618316/undefined-reference-to-strlwr + * + * \param str IN string to convert + * \return pointer to converted string + */ + +char * +XtcStrlwr(char *str) +{ + unsigned char *p = (unsigned char *)str; + + while (*p) { + *p = tolower((unsigned char)*p); + p++; + } + + return str; +} + +/** + * Compare two strings case insensitive + * Taken from https://stackoverflow.com/questions/30733786/c99-remove-stricmp-and-strnicmp + * + * \param a, b IN strings to compare + * \return + */ + int XtcStricmp(const char *a, const char *b) { - int ca, cb; - do { - ca = (unsigned char) *a++; - cb = (unsigned char) *b++; - ca = tolower(toupper(ca)); - cb = tolower(toupper(cb)); - } while ((ca == cb) && (ca != '\0')); - return ca - cb; + int ca, cb; + do { + ca = (unsigned char) *a++; + cb = (unsigned char) *b++; + ca = tolower(toupper(ca)); + cb = tolower(toupper(cb)); + } while ((ca == cb) && (ca != '\0')); + return ca - cb; } - diff --git a/app/bin/svgformat.c b/app/bin/svgformat.c index 2c57da0..3dfa621 100644 --- a/app/bin/svgformat.c +++ b/app/bin/svgformat.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #define _USE_MATH_DEFINES @@ -26,35 +26,32 @@ #include <string.h> #include <stdio.h> -#ifdef HAVE_MALLOC_H - #include <malloc.h> -#endif - #include "dynstring.h" #include "mxml.h" #include "include/svgformat.h" #include "include/utlist.h" +#include "common.h" #define SVGDPIFACTOR 90.0 /**< the assumed resolution of the svg, 90 is what Inkscape uses */ #define ROUND2PIXEL( value ) ((int)floor(value * SVGDPIFACTOR + 0.5)) typedef struct sCssStyle { - DynString name; - DynString style; - struct sCssStyle *next; + DynString name; + DynString style; + struct sCssStyle *next; } sCssStyle; static sCssStyle *styleCache = NULL; static unsigned cacheCount; static char *lineStyleCSS[] = { /**< The css class names for line styles */ - NULL, // no style needed for solid line - "linedash", - "linedot", - "linedashdot", - "linedashdot", - "linecenter", - "linephantom" + NULL, // no style needed for solid line + "linedash", + "linedot", + "linedashdot", + "linedashdot", + "linecenter", + "linephantom" }; #define LINESTYLECLASSES \ @@ -73,23 +70,23 @@ static char *lineStyleCSS[] = { /**< The css class names for line styles */ static void SvgInitStyleCache(void) { - sCssStyle *style; + sCssStyle *style; - style = malloc(sizeof(sCssStyle)); - DynStringMalloc(&(style->name), 2); - DynStringCatCStr(&(style->name), "*"); + style = malloc(sizeof(sCssStyle)); + DynStringMalloc(&(style->name), 2); + DynStringCatCStr(&(style->name), "*"); - DynStringMalloc(&(style->style), 16); - DynStringCatCStr(&(style->style), "stroke-width:1; stroke:#000000; fill:none;"); - LL_APPEND(styleCache, style); + DynStringMalloc(&(style->style), 16); + DynStringCatCStr(&(style->style), "stroke-width:1; stroke:#000000; fill:none;"); + LL_APPEND(styleCache, style); - cacheCount = 1; + cacheCount = 1; } static int CompareStyle(sCssStyle *a, sCssStyle *b) { - return (strcmp(DynStringToCStr(&(a->style)), DynStringToCStr(&(b->style)))); + return (strcmp(DynStringToCStr(&(a->style)), DynStringToCStr(&(b->style)))); } /** @@ -106,27 +103,27 @@ CompareStyle(sCssStyle *a, sCssStyle *b) static char * SvgAddStyleToCache(DynString *styleDef) { - sCssStyle *style; - sCssStyle *result; - - style = malloc(sizeof(sCssStyle)); - style->style = *styleDef; - - LL_SEARCH(styleCache, result, style, CompareStyle); - if (result) { - if (!strcmp(DynStringToCStr(&(result->name)), "*")) { - return (NULL); - } else { - return (DynStringToCStr(&(result->name)) + 1); - } - } else { - DynString className; - DynStringMalloc(&className, 16); - DynStringPrintf(&className, ".xtc%u", cacheCount++); - style->name = className; - LL_APPEND(styleCache, style); - return (DynStringToCStr(&className) + 1); //skip leading dot in class name - } + sCssStyle *style; + sCssStyle *result; + + style = malloc(sizeof(sCssStyle)); + style->style = *styleDef; + + LL_SEARCH(styleCache, result, style, CompareStyle); + if (result) { + if (!strcmp(DynStringToCStr(&(result->name)), "*")) { + return (NULL); + } else { + return (DynStringToCStr(&(result->name)) + 1); + } + } else { + DynString className; + DynStringMalloc(&className, 16); + DynStringPrintf(&className, ".xtc%u", cacheCount++); + style->name = className; + LL_APPEND(styleCache, style); + return (DynStringToCStr(&className) + 1); //skip leading dot in class name + } } /** @@ -136,16 +133,16 @@ SvgAddStyleToCache(DynString *styleDef) static void SvgDestroyStyleCache(void) { - sCssStyle *style; - sCssStyle *tmp; + sCssStyle *style; + sCssStyle *tmp; - LL_FOREACH_SAFE(styleCache, style, tmp) { - DynStringFree(&(style->name)); - DynStringFree(&(style->style)); - free(style); - } + LL_FOREACH_SAFE(styleCache, style, tmp) { + DynStringFree(&(style->name)); + DynStringFree(&(style->style)); + free(style); + } - styleCache = NULL; + styleCache = NULL; } /** @@ -161,36 +158,36 @@ static void SvgCreateStyle(mxml_node_t *element, unsigned long colorRGB, double width, bool fill, unsigned lineStyle) { - DynString style; - char color[10]; - char *className = NULL; - char *classLineStyle = NULL; - - assert(lineStyle < 7); - - sprintf(color, "#%2.2x%2.2x%2.2x", ((unsigned int)colorRGB >> 16) & 0xFF, - ((unsigned int)colorRGB >> 8) & 0xFF, (unsigned int)colorRGB & 0xFF); - - DynStringMalloc(&style, 32); - - DynStringPrintf(&style, - "stroke-width:%d; stroke:%s; fill:%s;", - (int)(width + 0.5), - color, - (fill ? color: "none")); - - className = SvgAddStyleToCache(&style); - classLineStyle = lineStyleCSS[lineStyle]; - - if (className && classLineStyle) { - mxmlElementSetAttrf(element, "class", "%s %s", className, classLineStyle); - } else { - if (className || classLineStyle) { - mxmlElementSetAttr(element, "class", (className? className:classLineStyle)); - } else { - // strict default, nothing to add - } - } + DynString style; + char color[10]; + char *className = NULL; + char *classLineStyle = NULL; + + CHECK(lineStyle < 7); + + sprintf(color, "#%2.2x%2.2x%2.2x", ((unsigned int)colorRGB >> 16) & 0xFF, + ((unsigned int)colorRGB >> 8) & 0xFF, (unsigned int)colorRGB & 0xFF); + + DynStringMalloc(&style, 32); + + DynStringPrintf(&style, + "stroke-width:%d; stroke:%s; fill:%s;", + (int)(width + 0.5), + color, + (fill ? color: "none")); + + className = SvgAddStyleToCache(&style); + classLineStyle = lineStyleCSS[lineStyle]; + + if (className && classLineStyle) { + mxmlElementSetAttrf(element, "class", "%s %s", className, classLineStyle); + } else { + if (className || classLineStyle) { + mxmlElementSetAttr(element, "class", (className? className:classLineStyle)); + } else { + // strict default, nothing to add + } + } } /** @@ -204,7 +201,7 @@ SvgCreateStyle(mxml_node_t *element, unsigned long colorRGB, double width, static void SvgAddRealUnit(mxml_node_t *node, char *name, double value) { - mxmlElementSetAttrf(node, name, "%d", (int)(value+0.5)); + mxmlElementSetAttrf(node, name, "%d", (int)(value+0.5)); } /** @@ -220,7 +217,7 @@ SvgAddRealUnit(mxml_node_t *node, char *name, double value) static void SvgAddCoordinate(mxml_node_t *node, char *name, double value) { - mxmlElementSetAttrf(node, name, "%d", ROUND2PIXEL(value)); + mxmlElementSetAttrf(node, name, "%d", ROUND2PIXEL(value)); } /** @@ -239,17 +236,17 @@ void SvgLineCommand(SVGParent *svg, double x0, double y0, double x1, double y1, double w, long c, unsigned lineStyle) { - mxml_node_t *xmlData; + mxml_node_t *xmlData; - xmlData = mxmlNewElement(svg, "line"); + xmlData = mxmlNewElement(svg, "line"); - // line end points - SvgAddCoordinate(xmlData, "x1", x0); - SvgAddCoordinate(xmlData, "y1", y0); - SvgAddCoordinate(xmlData, "x2", x1); - SvgAddCoordinate(xmlData, "y2", y1); + // line end points + SvgAddCoordinate(xmlData, "x1", x0); + SvgAddCoordinate(xmlData, "y1", y0); + SvgAddCoordinate(xmlData, "x2", x1); + SvgAddCoordinate(xmlData, "y2", y1); - SvgCreateStyle(xmlData, c, w, false, lineStyle); + SvgCreateStyle(xmlData, c, w, false, lineStyle); } /** @@ -268,17 +265,17 @@ void SvgRectCommand(SVGParent *svg, double x0, double y0, double x1, double y1, int color, unsigned lineStyle) { - mxml_node_t *xmlData; + mxml_node_t *xmlData; - xmlData = mxmlNewElement(svg, "rect"); + xmlData = mxmlNewElement(svg, "rect"); - // line end points - SvgAddCoordinate(xmlData, "x1", x0); - SvgAddCoordinate(xmlData, "y1", y0); - SvgAddCoordinate(xmlData, "x2", x1); - SvgAddCoordinate(xmlData, "y2", y1); + // line end points + SvgAddCoordinate(xmlData, "x1", x0); + SvgAddCoordinate(xmlData, "y1", y0); + SvgAddCoordinate(xmlData, "x2", x1); + SvgAddCoordinate(xmlData, "y2", y1); - SvgCreateStyle(xmlData, color, 1, false, lineStyle); + SvgCreateStyle(xmlData, color, 1, false, lineStyle); } @@ -298,31 +295,31 @@ void SvgPolyLineCommand(SVGParent *svg, int cnt, double *points, int color, double width, bool fill, unsigned lineStyle) { - mxml_node_t *xmlData; - DynString pointList; - DynString pos; + mxml_node_t *xmlData; + DynString pointList; + DynString pos; - DynStringMalloc(&pointList, 64); - DynStringMalloc(&pos, 20); + DynStringMalloc(&pointList, 64); + DynStringMalloc(&pos, 20); - for (int i = 0; i < cnt; i++) { - DynStringPrintf(&pos, - "%d,%d ", - (int)floor(points[i * 2] * SVGDPIFACTOR + 0.5), - (int)floor(points[ i * 2 + 1] * SVGDPIFACTOR + 0.5)); + for (int i = 0; i < cnt; i++) { + DynStringPrintf(&pos, + "%d,%d ", + (int)floor(points[i * 2] * SVGDPIFACTOR + 0.5), + (int)floor(points[ i * 2 + 1] * SVGDPIFACTOR + 0.5)); - DynStringCatStr(&pointList, &pos); - DynStringClear(&pos); - } + DynStringCatStr(&pointList, &pos); + DynStringClear(&pos); + } - xmlData = mxmlNewElement(svg, "polyline"); - mxmlElementSetAttr(xmlData, "points", DynStringToCStr(&pointList)); + xmlData = mxmlNewElement(svg, "polyline"); + mxmlElementSetAttr(xmlData, "points", DynStringToCStr(&pointList)); - SvgCreateStyle(xmlData, color, width, fill, lineStyle); + SvgCreateStyle(xmlData, color, width, fill, lineStyle); - DynStringFree(&pos); - DynStringFree(&pointList); + DynStringFree(&pos); + DynStringFree(&pointList); } /** @@ -342,17 +339,17 @@ void SvgCircleCommand(SVGParent *svg, double x, double y, double r, double w, long c, bool fill, unsigned lineStyle) { - mxml_node_t *xmlData; + mxml_node_t *xmlData; - xmlData = mxmlNewElement(svg, "circle"); + xmlData = mxmlNewElement(svg, "circle"); - // line end points - SvgAddCoordinate(xmlData, "cx", x); - SvgAddCoordinate(xmlData, "cy", y); + // line end points + SvgAddCoordinate(xmlData, "cx", x); + SvgAddCoordinate(xmlData, "cy", y); - SvgAddCoordinate(xmlData, "r", r); + SvgAddCoordinate(xmlData, "r", r); - SvgCreateStyle(xmlData, c, w, fill, lineStyle); + SvgCreateStyle(xmlData, c, w, fill, lineStyle); } @@ -371,10 +368,10 @@ static void PolarToCartesian(double cx, double cy, double radius, double angle, double *px, double *py) { - double angleInRadians = ((angle) * M_PI) / 180.0; + double angleInRadians = ((angle) * M_PI) / 180.0; - *px = cx + (radius * cos(angleInRadians)); - *py = cy + (radius * sin(angleInRadians)); + *px = cx + (radius * cos(angleInRadians)); + *py = cy + (radius * sin(angleInRadians)); } /** @@ -398,35 +395,35 @@ SvgArcCommand(SVGParent *svg, double x, double y, double r, double a0, double a1, bool center, double w, long c, unsigned lineStyle) { - double startX; - double startY; - double endX; - double endY; - char largeArcFlag = (a1 - a0 <= 180 ? '0' : '1'); - DynString pathArc; - mxml_node_t *xmlData; - - xmlData = mxmlNewElement(svg, "path"); - - PolarToCartesian(x, y, r, a0+a1-90, &startX, &startY); - PolarToCartesian(x, y, r, a0-90, &endX, &endY); - - DynStringMalloc(&pathArc, 64); - DynStringPrintf(&pathArc, - "M %d %d A %d %d 0 %c 0 %d %d", - ROUND2PIXEL(startX), - ROUND2PIXEL(startY), - ROUND2PIXEL(r), - ROUND2PIXEL(r), - largeArcFlag, - ROUND2PIXEL(endX), - ROUND2PIXEL(endY)); - - mxmlElementSetAttr(xmlData, "d", DynStringToCStr(&pathArc)); - - DynStringFree(&pathArc); - - SvgCreateStyle(xmlData, c, w, false, lineStyle); + double startX; + double startY; + double endX; + double endY; + char largeArcFlag = (a1 - a0 <= 180 ? '0' : '1'); + DynString pathArc; + mxml_node_t *xmlData; + + xmlData = mxmlNewElement(svg, "path"); + + PolarToCartesian(x, y, r, a0+a1-90, &startX, &startY); + PolarToCartesian(x, y, r, a0-90, &endX, &endY); + + DynStringMalloc(&pathArc, 64); + DynStringPrintf(&pathArc, + "M %d %d A %d %d 0 %c 0 %d %d", + ROUND2PIXEL(startX), + ROUND2PIXEL(startY), + ROUND2PIXEL(r), + ROUND2PIXEL(r), + largeArcFlag, + ROUND2PIXEL(endX), + ROUND2PIXEL(endY)); + + mxmlElementSetAttr(xmlData, "d", DynStringToCStr(&pathArc)); + + DynStringFree(&pathArc); + + SvgCreateStyle(xmlData, c, w, false, lineStyle); } /** @@ -444,18 +441,18 @@ void SvgTextCommand(SVGParent *svg, double x, double y, double size, long c, char *text) { - mxml_node_t *xmlData; + mxml_node_t *xmlData; - xmlData = mxmlNewElement(svg, "text"); - // starting point - SvgAddCoordinate(xmlData, "x", x); - SvgAddCoordinate(xmlData, "y", y); + xmlData = mxmlNewElement(svg, "text"); + // starting point + SvgAddCoordinate(xmlData, "x", x); + SvgAddCoordinate(xmlData, "y", y); - SvgCreateStyle(xmlData, c, 1, 1, 0); + SvgCreateStyle(xmlData, c, 1, 1, 0); - SvgAddRealUnit(xmlData, "font-size", size); + SvgAddRealUnit(xmlData, "font-size", size); - mxmlNewText(xmlData, false, text); + mxmlNewText(xmlData, false, text); } /** @@ -468,13 +465,13 @@ SvgTextCommand(SVGParent *svg, double x, void SvgAddTitle(SVGParent *svg, char *title) { - mxml_node_t *titleNode; - if (title) { - titleNode = mxmlNewElement(MXML_NO_PARENT, "title"); - mxmlNewText(titleNode, false, title); + mxml_node_t *titleNode; + if (title) { + titleNode = mxmlNewElement(MXML_NO_PARENT, "title"); + mxmlNewText(titleNode, false, title); - mxmlAdd(svg, MXML_ADD_BEFORE, MXML_ADD_TO_PARENT, titleNode); - } + mxmlAdd(svg, MXML_ADD_BEFORE, MXML_ADD_TO_PARENT, titleNode); + } } /** @@ -490,30 +487,30 @@ SvgAddTitle(SVGParent *svg, char *title) void SvgAddCSSStyle(SVGParent *svg) { - mxml_node_t *cssNode; - DynString cssDefs; - DynString tmp; - sCssStyle *style; - - cssNode = mxmlNewElement(MXML_NO_PARENT, "style"); - mxmlElementSetAttr(cssNode, "type", "text/css"); - - DynStringMalloc(&cssDefs, 64); - DynStringMalloc(&tmp, 64); - LL_FOREACH(styleCache, style) { - DynStringPrintf(&tmp, "%s { %s }\n", - DynStringToCStr(&(style->name)), - DynStringToCStr(&(style->style))); - - DynStringCatStr(&cssDefs, &tmp); - } - - DynStringCatCStr(&cssDefs, LINESTYLECLASSES); - mxmlNewCDATA(cssNode, DynStringToCStr(&cssDefs)); - - mxmlAdd(svg, MXML_ADD_BEFORE, MXML_ADD_TO_PARENT, cssNode); - DynStringFree(&tmp); - DynStringFree(&cssDefs); + mxml_node_t *cssNode; + DynString cssDefs; + DynString tmp; + sCssStyle *style; + + cssNode = mxmlNewElement(MXML_NO_PARENT, "style"); + mxmlElementSetAttr(cssNode, "type", "text/css"); + + DynStringMalloc(&cssDefs, 64); + DynStringMalloc(&tmp, 64); + LL_FOREACH(styleCache, style) { + DynStringPrintf(&tmp, "%s { %s }\n", + DynStringToCStr(&(style->name)), + DynStringToCStr(&(style->style))); + + DynStringCatStr(&cssDefs, &tmp); + } + + DynStringCatCStr(&cssDefs, LINESTYLECLASSES); + mxmlNewCDATA(cssNode, DynStringToCStr(&cssDefs)); + + mxmlAdd(svg, MXML_ADD_BEFORE, MXML_ADD_TO_PARENT, cssNode); + DynStringFree(&tmp); + DynStringFree(&cssDefs); } /** @@ -525,9 +522,9 @@ SvgAddCSSStyle(SVGParent *svg) SVGDocument * SvgCreateDocument() { - SvgInitStyleCache(); + SvgInitStyleCache(); - return ((SVGDocument *)mxmlNewXML("1.0")); + return ((SVGDocument *)mxmlNewXML("1.0")); } /** @@ -539,9 +536,9 @@ SvgCreateDocument() void SvgDestroyDocument(SVGDocument *xml) { - mxmlDelete((mxml_node_t *)xml); + mxmlDelete((mxml_node_t *)xml); - SvgDestroyStyleCache(); + SvgDestroyStyleCache(); } /** @@ -563,23 +560,23 @@ SvgPrologue(SVGDocument *parent, char *id, int layerCount, double x0, double y0, double x1, double y1) { - mxml_node_t *xmlData; - - xmlData = mxmlNewElement(parent, - "!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"" - " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\""); - xmlData = mxmlNewElement(parent, "svg"); - mxmlElementSetAttr(xmlData, "xmlns", "http://www.w3.org/2000/svg"); - - if (id) { - mxmlElementSetAttr(xmlData, "id", id); - } - SvgAddCoordinate(xmlData, "x", x0); - SvgAddCoordinate(xmlData, "y", y0); - SvgAddCoordinate(xmlData, "width", x1); - SvgAddCoordinate(xmlData, "height", y1); - - return ((SVGParent *)xmlData); + mxml_node_t *xmlData; + + xmlData = mxmlNewElement(parent, + "!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"" + " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\""); + xmlData = mxmlNewElement(parent, "svg"); + mxmlElementSetAttr(xmlData, "xmlns", "http://www.w3.org/2000/svg"); + + if (id) { + mxmlElementSetAttr(xmlData, "id", id); + } + SvgAddCoordinate(xmlData, "x", x0); + SvgAddCoordinate(xmlData, "y", y0); + SvgAddCoordinate(xmlData, "width", x1); + SvgAddCoordinate(xmlData, "height", y1); + + return ((SVGParent *)xmlData); } /** @@ -594,61 +591,61 @@ SvgPrologue(SVGDocument *parent, char *id, int layerCount, double x0, double y0, const char * whitespace_cb(mxml_node_t *node, int where) { - const char *element; - - /* - * We can conditionally break to a new line before or after - * any element. These are just common HTML elements... - */ - - element = mxmlGetElement(node); - - if (!strcmp(element, "svg") || - !strncmp(element, "!DOCTYPE", strlen("!DOCTYPE"))) { - /* - * Newlines before open and after close... - */ - - if (where == MXML_WS_BEFORE_OPEN || - where == MXML_WS_BEFORE_CLOSE) { - return ("\n"); - } - } else { - if (!strcmp(element, "line") || - !strcmp(element, "circle") || - !strcmp(element, "path") || - !strcmp(element, "polyline")) { - if (where == MXML_WS_BEFORE_OPEN || - where == MXML_WS_AFTER_CLOSE) { - return ("\n\t"); - } - } else { - if (!strcmp(element, "style") || - !strcmp(element, "title") || - !strcmp(element, "text")) { - if (where == MXML_WS_BEFORE_OPEN) { - return ("\n\t"); - } else { - if (where == MXML_WS_AFTER_OPEN) { - return ("\n\t\t"); - } else { - if (where == MXML_WS_AFTER_CLOSE) { - return (""); - } else { - return ("\n\t"); - } - } - } - - } - } - } - - /* - * Otherwise return NULL for no added whitespace... - */ - - return (NULL); + const char *element; + + /* + * We can conditionally break to a new line before or after + * any element. These are just common HTML elements... + */ + + element = mxmlGetElement(node); + + if (!strcmp(element, "svg") || + !strncmp(element, "!DOCTYPE", strlen("!DOCTYPE"))) { + /* + * Newlines before open and after close... + */ + + if (where == MXML_WS_BEFORE_OPEN || + where == MXML_WS_BEFORE_CLOSE) { + return ("\n"); + } + } else { + if (!strcmp(element, "line") || + !strcmp(element, "circle") || + !strcmp(element, "path") || + !strcmp(element, "polyline")) { + if (where == MXML_WS_BEFORE_OPEN || + where == MXML_WS_AFTER_CLOSE) { + return ("\n\t"); + } + } else { + if (!strcmp(element, "style") || + !strcmp(element, "title") || + !strcmp(element, "text")) { + if (where == MXML_WS_BEFORE_OPEN) { + return ("\n\t"); + } else { + if (where == MXML_WS_AFTER_OPEN) { + return ("\n\t\t"); + } else { + if (where == MXML_WS_AFTER_CLOSE) { + return (""); + } else { + return ("\n\t"); + } + } + } + + } + } + } + + /* + * Otherwise return NULL for no added whitespace... + */ + + return (NULL); } /** @@ -663,15 +660,15 @@ whitespace_cb(mxml_node_t *node, int where) bool SvgSaveFile(SVGDocument *svg, char *filename) { - FILE *svgF; + FILE *svgF; - svgF = fopen(filename, "w"); - if (svgF) { - mxmlSetWrapMargin(0); - mxmlSaveFile(svg, svgF, whitespace_cb); - fclose(svgF); + svgF = fopen(filename, "w"); + if (svgF) { + mxmlSetWrapMargin(0); + mxmlSaveFile(svg, svgF, whitespace_cb); + fclose(svgF); - return (true); - } - return (false); + return (true); + } + return (false); } diff --git a/app/bin/svgoutput.c b/app/bin/svgoutput.c index a8224be..e4ff66b 100644 --- a/app/bin/svgoutput.c +++ b/app/bin/svgoutput.c @@ -17,22 +17,21 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <stdio.h> #include <string.h> #include <time.h> #ifdef WINDOWS - #include <io.h> - #define UTFCONVERT +#include <io.h> +#define UTFCONVERT #else - #include <errno.h> +#include <errno.h> #endif #include <xtrkcad-config.h> #include <locale.h> -#include <assert.h> #include <mxml.h> #include <dynstring.h> @@ -53,6 +52,8 @@ static struct wFilSel_t * exportSVGFile_fs; static coOrd roomSize; +static int svgLineWidth[4] = {10, 10, 20, 30}; + /** * get line style for element * @@ -64,35 +65,35 @@ static coOrd roomSize; static unsigned SvgDrawGetLineStyle(drawCmd_p d) { - unsigned long notSolid = DC_NOTSOLIDLINE; - unsigned long opt = d->options & notSolid; - unsigned lineOpt; - - switch (opt) { - case DC_DASH: - lineOpt = wDrawLineDash; - break; - case DC_DOT: - lineOpt = wDrawLineDot; - break; - case DC_DASHDOT: - lineOpt = wDrawLineDashDot; - break; - case DC_DASHDOTDOT: - lineOpt = wDrawLineDashDotDot; - break; - case DC_CENTER: - lineOpt = wDrawLineCenter; - break; - case DC_PHANTOM: - lineOpt = wDrawLinePhantom; - break; - default: - lineOpt = wDrawLineSolid; - break; - } - - return (lineOpt); + unsigned long notSolid = DC_NOTSOLIDLINE; + unsigned long opt = d->options & notSolid; + unsigned lineOpt; + + switch (opt) { + case DC_DASH: + lineOpt = wDrawLineDash; + break; + case DC_DOT: + lineOpt = wDrawLineDot; + break; + case DC_DASHDOT: + lineOpt = wDrawLineDashDot; + break; + case DC_DASHDOTDOT: + lineOpt = wDrawLineDashDotDot; + break; + case DC_CENTER: + lineOpt = wDrawLineCenter; + break; + case DC_PHANTOM: + lineOpt = wDrawLinePhantom; + break; + default: + lineOpt = wDrawLineSolid; + break; + } + + return (lineOpt); } /** @@ -106,22 +107,22 @@ SvgDrawGetLineStyle(drawCmd_p d) */ static void SvgDrawLine( - drawCmd_p d, - coOrd p0, - coOrd p1, - wDrawWidth width, - wDrawColor color) + drawCmd_p d, + coOrd p0, + coOrd p1, + wDrawWidth width, + wDrawColor color) { - unsigned lineOpt = SvgDrawGetLineStyle(d); + unsigned lineOpt = SvgDrawGetLineStyle(d); - width = (wDrawWidth)(width > MININMUMLINEWIDTH ? width : MININMUMLINEWIDTH); + width = (wDrawWidth)(width >= MINIMUMLINEWIDTH ? width : svgLineWidth[width]); - SvgLineCommand((SVGParent *)(d->d), - p0.x, roomSize.y - p0.y, - p1.x, roomSize.y - p1.y, - (double)width, - wDrawGetRGB(color), - lineOpt); + SvgLineCommand((SVGParent *)(d->d), + p0.x, roomSize.y - p0.y, + p1.x, roomSize.y - p1.y, + (double)width, + wDrawGetRGB(color), + lineOpt); } /** @@ -138,38 +139,39 @@ static void SvgDrawLine( */ static void SvgDrawArc( - drawCmd_p d, - coOrd p, - DIST_T r, - ANGLE_T angle0, - ANGLE_T angle1, - BOOL_T drawCenter, - wDrawWidth width, - wDrawColor color) + drawCmd_p d, + coOrd p, + DIST_T r, + ANGLE_T angle0, + ANGLE_T angle1, + BOOL_T drawCenter, + wDrawWidth width, + wDrawColor color) { - unsigned lineOpt = SvgDrawGetLineStyle(d); - - if (angle1 >= 360.0) { - SvgCircleCommand((SVGParent *)(d->d), - p.x, - roomSize.y - p.y, - r, - (width > MININMUMLINEWIDTH ? width : MININMUMLINEWIDTH), - wDrawGetRGB(color), - false, - lineOpt); - } else { - SvgArcCommand((SVGParent *)(d->d), - p.x, - roomSize.y-p.y, - r, - angle0, - angle1, - drawCenter, - (width > MININMUMLINEWIDTH ? width: MININMUMLINEWIDTH), - wDrawGetRGB(color), - lineOpt); - } + unsigned lineOpt = SvgDrawGetLineStyle(d); + wDrawWidth w = (width >= MINIMUMLINEWIDTH ? width : svgLineWidth[width]); + + if (angle1 >= 360.0) { + SvgCircleCommand((SVGParent *)(d->d), + p.x, + roomSize.y - p.y, + r, + w, + wDrawGetRGB(color), + false, + lineOpt); + } else { + SvgArcCommand((SVGParent *)(d->d), + p.x, + roomSize.y-p.y, + r, + angle0, + angle1, + drawCenter, + w, + wDrawGetRGB(color), + lineOpt); + } } @@ -186,28 +188,28 @@ static void SvgDrawArc( */ static void SvgDrawString( - drawCmd_p d, - coOrd p, - ANGLE_T a, - char * s, - wFont_p fp, - FONTSIZE_T fontSize, - wDrawColor color) + drawCmd_p d, + coOrd p, + ANGLE_T a, + char * s, + wFont_p fp, + FONTSIZE_T fontSize, + wDrawColor color) { - char *text = MyStrdup(s); + char *text = MyStrdup(s); #ifdef UTFCONVERT - text = Convert2UTF8(text); + text = Convert2UTF8(text); #endif // UTFCONVERT - SvgTextCommand((SVGParent *)(d->d), - p.x, - roomSize.y - p.y, - fontSize, - wDrawGetRGB(color), - text); + SvgTextCommand((SVGParent *)(d->d), + p.x, + roomSize.y - p.y, + fontSize, + wDrawGetRGB(color), + text); - MyFree(text); + MyFree(text); } /** @@ -220,10 +222,10 @@ static void SvgDrawString( */ static void SvgDrawBitmap( - drawCmd_p d, - coOrd p, - wDrawBitMap_p bm, - wDrawColor color) + drawCmd_p d, + coOrd p, + wDrawBitMap_p bm, + wDrawColor color) { } @@ -240,37 +242,34 @@ static void SvgDrawBitmap( */ static void SvgDrawFillPoly( - drawCmd_p d, - int cnt, - coOrd * pts, - int * pointer, - wDrawColor color, wDrawWidth width, drawFill_e fillStyle) + drawCmd_p d, + int cnt, + coOrd * pts, + int * pointer, + wDrawColor color, wDrawWidth width, drawFill_e fillStyle) { - int i; - double *points = malloc((cnt + 1) * 2 * sizeof(double)); - - unsigned lineOpt = SvgDrawGetLineStyle(d); - - if (!points) { - puts("memory for poly line coordinates could not be allocated!"); - abort(); - } - for (i = 0; i < cnt; i++) { - points[i * 2] = pts[i].x; - points[i * 2 + 1] = roomSize.y - pts[i].y; - } - - if (fillStyle == DRAW_CLOSED || fillStyle == DRAW_FILL) { - points[i * 2] = points[0]; - points[i * 2 + 1] = points[1]; - cnt++; - } - - width = (wDrawWidth)(width > MININMUMLINEWIDTH ? width : MININMUMLINEWIDTH); - SvgPolyLineCommand((SVGParent *)(d->d), cnt, points, wDrawGetRGB(color), - (double)width, fillStyle == DRAW_FILL, lineOpt); - - free(points); + int i; + double *points = malloc((cnt + 1) * 2 * sizeof(double)); + CHECK( points ); + + unsigned lineOpt = SvgDrawGetLineStyle(d); + + for (i = 0; i < cnt; i++) { + points[i * 2] = pts[i].x; + points[i * 2 + 1] = roomSize.y - pts[i].y; + } + + if (fillStyle == DRAW_CLOSED || fillStyle == DRAW_FILL) { + points[i * 2] = points[0]; + points[i * 2 + 1] = points[1]; + cnt++; + } + + width = (wDrawWidth)(width >= MINIMUMLINEWIDTH ? width : svgLineWidth[width]); + SvgPolyLineCommand((SVGParent *)(d->d), cnt, points, wDrawGetRGB(color), + (double)width, fillStyle == DRAW_FILL, lineOpt); + + free(points); } /** @@ -285,14 +284,14 @@ static void SvgDrawFillPoly( static void SvgDrawFillCircle(drawCmd_p d, coOrd center, DIST_T radius, wDrawColor color) { - SvgCircleCommand((SVGParent *)(d->d), - center.x, - roomSize.y - center.y, - radius, - 0, - wDrawGetRGB(color), - true, - 0); + SvgCircleCommand((SVGParent *)(d->d), + center.x, + roomSize.y - center.y, + radius, + 0, + wDrawGetRGB(color), + true, + 0); } /** @@ -309,25 +308,25 @@ static void SvgDrawRectangle(drawCmd_p d, coOrd corner1, coOrd corner2, wDrawColor color, drawFill_e fillOpt) { - SvgRectCommand((SVGParent *)(d->d), - corner1.x, roomSize.y - corner1.y, - corner2.x, roomSize.y - corner2.y, - wDrawGetRGB(color), - fillOpt); + SvgRectCommand((SVGParent *)(d->d), + corner1.x, roomSize.y - corner1.y, + corner2.x, roomSize.y - corner2.y, + wDrawGetRGB(color), + fillOpt); } static drawFuncs_t svgDrawFuncs = { - SvgDrawLine, - SvgDrawArc, - SvgDrawString, - SvgDrawBitmap, - SvgDrawFillPoly, - SvgDrawFillCircle, - SvgDrawRectangle + SvgDrawLine, + SvgDrawArc, + SvgDrawString, + SvgDrawBitmap, + SvgDrawFillPoly, + SvgDrawFillCircle, + SvgDrawRectangle }; static drawCmd_t svgD = { - NULL, &svgDrawFuncs, 0, 1.0, 0.0, {0.0,0.0}, {0.0,0.0}, Pix2CoOrd, CoOrd2Pix, 100.0 + NULL, &svgDrawFuncs, 0, 1.0, 0.0, {0.0,0.0}, {0.0,0.0}, Pix2CoOrd, CoOrd2Pix, 100.0 }; /** @@ -344,30 +343,30 @@ static drawCmd_t svgD = { static char * CreateValidId(char *base) { - const char *idHead = "id"; - char *out = MyMalloc(strlen(idHead) + strlen(base) + 1); - char *tmp; - int j; - - strcpy(out, idHead); - j = strlen(out); - - for (unsigned int i = 0; i < strlen(base); i++) { - if (isblank(base[i])) { - i++; - } else { - out[j++] = base[i]; - } - } - - out[j] = '\0'; - - // strip off the extension - tmp = strchr(out, '.'); - if (tmp) { - *tmp = '\0'; - } - return (out); + const char *idHead = "id"; + char *out = MyMalloc(strlen(idHead) + strlen(base) + 1); + char *tmp; + int j; + + strcpy(out, idHead); + j = strlen(out); + + for (unsigned int i = 0; i < strlen(base); i++) { + if (isblank(base[i])) { + i++; + } else { + out[j++] = base[i]; + } + } + + out[j] = '\0'; + + // strip off the extension + tmp = strchr(out, '.'); + if (tmp) { + *tmp = '\0'; + } + return (out); } /** @@ -378,17 +377,17 @@ CreateValidId(char *base) static char * SvgGetId(void) { - char *fileName = GetLayoutFilename(); - char *id = NULL; + char *fileName = GetLayoutFilename(); + char *id = NULL; - if (fileName) { - id = CreateValidId(fileName); + if (fileName) { + id = CreateValidId(fileName); #ifdef UTFCONVERT - id = Convert2UTF8(id); + id = Convert2UTF8(id); #endif - } + } - return (id); + return (id); } /** @@ -400,17 +399,17 @@ static char * SvgGetId(void) static void SvgSetTitle(drawCmd_p d) { - char *tmp = GetLayoutTitle(); - char *title; + char *tmp = GetLayoutTitle(); + char *title; - if (tmp) { - title = MyStrdup(tmp); + if (tmp) { + title = MyStrdup(tmp); #ifdef UTFCONVERT - title = Convert2UTF8(title); + title = Convert2UTF8(title); #endif - SvgAddTitle((SVGParent *)(d->d), title); - MyFree(title); - } + SvgAddTitle((SVGParent *)(d->d), title); + MyFree(title); + } } @@ -425,66 +424,67 @@ static void SvgSetTitle(drawCmd_p d) */ static int DoExportSVGTracks( - int cnt, - char ** fileName, - void * data) + int cnt, + char ** fileName, + void * data) { - DynString command = NaS; - SVGDocument *svg; - SVGParent *svgData; - char *id; + DynString command = NaS; + SVGDocument *svg; + SVGParent *svgData; + BOOL_T all = (selectedTrackCount == 0); + char *id; - assert(fileName != NULL); - assert(cnt == 1); + CHECK(fileName != NULL); + CHECK(cnt == 1); - SetCLocale(); - GetLayoutRoomSize(&roomSize); + SetCLocale(); + GetLayoutRoomSize(&roomSize); - SetCurrentPath(SVGPATHKEY, fileName[ 0 ]); + SetCurrentPath(SVGPATHKEY, fileName[ 0 ]); - svg = SvgCreateDocument(); - id = SvgGetId(); - svgData = SvgPrologue(svg, id, 0, 0.0, 0.0, roomSize.x, roomSize.y); - MyFree(id); + svg = SvgCreateDocument(); + id = SvgGetId(); + svgData = SvgPrologue(svg, id, 0, 0.0, 0.0, roomSize.x, roomSize.y); + MyFree(id); - wSetCursor(mainD.d, wCursorWait); + wSetCursor(mainD.d, wCursorWait); // time(&clock); - svgD.d = (wDraw_p)svgData; - - DrawSelectedTracks(&svgD); - SvgAddCSSStyle((SVGParent *)svgD.d); - SvgSetTitle(&svgD); // make sure this is the last element - - if (!SvgSaveFile(svg, fileName[0])) { - NoticeMessage(MSG_OPEN_FAIL, _("Cancel"), NULL, "SVG", fileName[0], - strerror(errno)); - - SvgDestroyDocument(svg); - wSetCursor(mainD.d, wCursorNormal); - SetUserLocale(); - return FALSE; - } - SvgDestroyDocument(svg); - Reset(); /**<TODO: was tut das? */ - wSetCursor(mainD.d, wCursorNormal); - SetUserLocale(); - return TRUE; + svgD.d = (wDraw_p)svgData; + + DrawSelectedTracks(&svgD,all); + SvgAddCSSStyle((SVGParent *)svgD.d); + SvgSetTitle(&svgD); // make sure this is the last element + + if (!SvgSaveFile(svg, fileName[0])) { + NoticeMessage(MSG_OPEN_FAIL, _("Cancel"), NULL, "SVG", fileName[0], + strerror(errno)); + + SvgDestroyDocument(svg); + wSetCursor(mainD.d, wCursorNormal); + SetUserLocale(); + return FALSE; + } + SvgDestroyDocument(svg); + Reset(); /**<TODO: was tut das? */ + wSetCursor(mainD.d, wCursorNormal); + SetUserLocale(); + return TRUE; } /** * Create and show the dialog for selecting the DXF export filename */ -void DoExportSVG(void) +void DoExportSVG(void * unused) { - assert(selectedTrackCount > 0); + // CHECK(selectedTrackCount > 0); - if (exportSVGFile_fs == NULL) - exportSVGFile_fs = wFilSelCreate(mainW, FS_SAVE, 0, _("Export to SVG"), - sSVGFilePattern, DoExportSVGTracks, NULL); + if (exportSVGFile_fs == NULL) + exportSVGFile_fs = wFilSelCreate(mainW, FS_SAVE, 0, _("Export to SVG"), + sSVGFilePattern, DoExportSVGTracks, NULL); - wFilSelect(exportSVGFile_fs, GetCurrentPath(SVGPATHKEY)); + wFilSelect(exportSVGFile_fs, GetCurrentPath(SVGPATHKEY)); } diff --git a/app/bin/tbezier.c b/app/bin/tbezier.c index 53b625e..c5cff99 100644 --- a/app/bin/tbezier.c +++ b/app/bin/tbezier.c @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************** * BEZIER TRACK (and LINE) @@ -45,7 +45,6 @@ #include "cundo.h" #include "layout.h" #include "fileio.h" -#include "trackx.h" EXPORT TRKTYP_T T_BEZIER = -1; EXPORT TRKTYP_T T_BZRLIN = -1; @@ -53,6 +52,10 @@ EXPORT TRKTYP_T T_BZRLIN = -1; static int log_bezier = 0; static DIST_T GetLengthBezier( track_p ); +static DIST_T BezierMathDistance( coOrd * pos, coOrd p[4], int segments, + double * t_value); +static void BezierSplit(coOrd input[4], coOrd left[4], coOrd right[4], + double t); /**************************************** * @@ -63,32 +66,36 @@ static DIST_T GetLengthBezier( track_p ); /* * Run after any changes to the Bezier points */ -EXPORT void FixUpBezier(coOrd pos[4], struct extraDataBezier_t * xx, BOOL_T track) { +EXPORT void FixUpBezier(coOrd pos[4], struct extraDataBezier_t * xx, + BOOL_T track) +{ xx->a0 = NormalizeAngle(FindAngle(pos[1], pos[0])); xx->a1 = NormalizeAngle(FindAngle(pos[2], pos[3])); ConvertToArcs(pos, &xx->arcSegs, track, xx->segsColor, - xx->segsWidth); + xx->segsLineWidth); xx->minCurveRadius = BezierMinRadius(pos, - xx->arcSegs); + xx->arcSegs); xx->length = BezierLength(pos, xx->arcSegs); } /* * Run after any changes to the Bezier points for a Segment */ -EXPORT void FixUpBezierSeg(coOrd pos[4], trkSeg_p p, BOOL_T track) { +EXPORT void FixUpBezierSeg(coOrd pos[4], trkSeg_p p, BOOL_T track) +{ p->u.b.angle0 = NormalizeAngle(FindAngle(pos[1], pos[0])); p->u.b.angle3 = NormalizeAngle(FindAngle(pos[2], pos[3])); ConvertToArcs(pos, &p->bezSegs, track, p->color, - p->width); + p->lineWidth); p->u.b.minRadius = BezierMinRadius(pos, - p->bezSegs); + p->bezSegs); p->u.b.length = BezierLength(pos, p->bezSegs); } -EXPORT void FixUpBezierSegs(trkSeg_p p,int segCnt) { - for (int i=0;i<segCnt;i++,p++) { +EXPORT void FixUpBezierSegs(trkSeg_p p,int segCnt) +{ + for (int i=0; i<segCnt; i++,p++) { if (p->type == SEG_BEZTRK || p->type == SEG_BEZLIN) { FixUpBezierSeg(p->u.b.pos,p,p->type == SEG_BEZTRK); } @@ -96,48 +103,67 @@ EXPORT void FixUpBezierSegs(trkSeg_p p,int segCnt) { } +#if 0 static void GetBezierAngles( ANGLE_T *a0, ANGLE_T *a1, track_p trk ) { - assert( trk != NULL ); - - *a0 = NormalizeAngle( GetTrkEndAngle(trk,0) ); - *a1 = NormalizeAngle( GetTrkEndAngle(trk,1) ); - - LOG( log_bezier, 4, ( "getBezierAngles: = %0.3f %0.3f\n", *a0, *a1 ) ) + CHECK( trk != NULL ); + + *a0 = NormalizeAngle( GetTrkEndAngle(trk,0) ); + *a1 = NormalizeAngle( GetTrkEndAngle(trk,1) ); + + LOG( log_bezier, 4, ( "getBezierAngles: = %0.3f %0.3f\n", *a0, *a1 ) ) } +#endif -static void ComputeBezierBoundingBox( track_p trk, struct extraDataBezier_t * xx ) +static void ComputeBezierBoundingBox( track_p trk, + struct extraDataBezier_t * xx ) { - coOrd hi, lo; - hi.x = lo.x = xx->pos[0].x; - hi.y = lo.y = xx->pos[0].y; - - for (int i=1; i<=3;i++) { - hi.x = hi.x < xx->pos[i].x ? xx->pos[i].x : hi.x; - hi.y = hi.y < xx->pos[i].y ? xx->pos[i].y : hi.y; - lo.x = lo.x > xx->pos[i].x ? xx->pos[i].x : lo.x; - lo.y = lo.y > xx->pos[i].y ? xx->pos[i].y : lo.y; - } - SetBoundingBox( trk, hi, lo ); + coOrd hi, lo; + LWIDTH_T lineWidth = xx->segsLineWidth; + LWIDTH_T lwidth = 0; + + if (lineWidth < 0) { + lwidth = -lineWidth / mainD.scale; + } else { + lwidth = lineWidth; + } + + hi.x = lo.x = xx->pos[0].x; + hi.y = lo.y = xx->pos[0].y; + + for (int i=1; i<=3; i++) { + hi.x = hi.x < xx->pos[i].x ? xx->pos[i].x : hi.x; + hi.y = hi.y < xx->pos[i].y ? xx->pos[i].y : hi.y; + lo.x = lo.x > xx->pos[i].x ? xx->pos[i].x : lo.x; + lo.y = lo.y > xx->pos[i].y ? xx->pos[i].y : lo.y; + } + lo.x -= lwidth; + lo.y -= lwidth; + hi.x += lwidth; + hi.y += lwidth; + + SetBoundingBox( trk, hi, lo ); } static DIST_T DistanceBezier( track_p t, coOrd * p ); DIST_T BezierDescriptionDistance( - coOrd pos, - track_p trk, - coOrd * dpos, - BOOL_T show_hidden, - BOOL_T * hidden) + coOrd pos, + track_p trk, + coOrd * dpos, + BOOL_T show_hidden, + BOOL_T * hidden) { coOrd p1; - if (hidden) *hidden = FALSE; - if ( GetTrkType( trk ) != T_BEZIER || ((( GetTrkBits( trk ) & TB_HIDEDESC ) != 0 ) && !show_hidden)) + if (hidden) { *hidden = FALSE; } + if ( GetTrkType( trk ) != T_BEZIER + || ((( GetTrkBits( trk ) & TB_HIDEDESC ) != 0 ) && !show_hidden)) { return DIST_INF; + } struct extraDataBezier_t *xx = GET_EXTRA_DATA(trk, T_BEZIER, extraDataBezier_t); - if (( GetTrkBits( trk ) & TB_HIDEDESC ) != 0 ) xx->descriptionOff = zero; + if (( GetTrkBits( trk ) & TB_HIDEDESC ) != 0 ) { xx->descriptionOff = zero; } coOrd end0, end0off, end1, end1off; end0 = xx->pos[0]; @@ -150,64 +176,71 @@ DIST_T BezierDescriptionDistance( p1.x = (end1off.x - end0off.x)*(xx->descriptionOff.x+0.5) + end0off.x; p1.y = (end1off.y - end0off.y)*(xx->descriptionOff.x+0.5) + end0off.y; - if (hidden) *hidden = (GetTrkBits( trk ) & TB_HIDEDESC); + if (hidden) { *hidden = (GetTrkBits( trk ) & TB_HIDEDESC); } *dpos = p1; coOrd tpos = pos; - if (DistanceBezier(trk,&tpos)<FindDistance( p1, pos )) + if (DistanceBezier(trk,&tpos)<FindDistance( p1, pos )) { return DistanceBezier(trk,&pos); + } return FindDistance( p1, pos ); } static void DrawBezierDescription( - track_p trk, - drawCmd_p d, - wDrawColor color ) + track_p trk, + drawCmd_p d, + wDrawColor color ) { - struct extraDataBezier_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, extraDataBezier_t); - wFont_p fp; - coOrd epos0,epos1; + struct extraDataBezier_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, + extraDataBezier_t); +// wFont_p fp; + coOrd epos0,epos1; - if (layoutLabels == 0) + if (layoutLabels == 0) { return; - if ((labelEnable&LABELENABLE_TRKDESC)==0) + } + if ((labelEnable&LABELENABLE_TRKDESC)==0) { return; + } - epos0 = xx->pos[0]; - epos1 = xx->pos[3]; - ANGLE_T a = FindAngle(epos0,epos1); - Translate(&epos0,epos0,a+90,xx->descriptionOff.y); - Translate(&epos1,epos1,a+90,xx->descriptionOff.y); - fp = wStandardFont( F_TIMES, FALSE, FALSE ); - sprintf( message, _("Bez: L%s A%0.3f trk_len=%s min_rad=%s"), - FormatDistance(FindDistance(xx->pos[0],xx->pos[3])), - FindAngle(xx->pos[0],xx->pos[3]), - FormatDistance(xx->length), FormatDistance(xx->minCurveRadius>10000?0.0:xx->minCurveRadius)); - DrawLine(d,xx->pos[0],epos0,0,color); - DrawLine(d,xx->pos[3],epos1,0,color); - DrawDimLine( d, epos0, epos1, message, (wFontSize_t)descriptionFontSize, xx->descriptionOff.x+0.5, 0, color, 0x00 ); - - if (GetTrkBits( trk ) & TB_DETAILDESC) { - coOrd details_pos; - details_pos.x = (epos1.x - epos0.x)*(xx->descriptionOff.x+0.5) + epos0.x; - details_pos.y = (epos1.y - epos0.y)*(xx->descriptionOff.x+0.5) + epos0.y -(2*descriptionFontSize/mainD.dpi); + epos0 = xx->pos[0]; + epos1 = xx->pos[3]; + ANGLE_T a = FindAngle(epos0,epos1); + Translate(&epos0,epos0,a+90,xx->descriptionOff.y); + Translate(&epos1,epos1,a+90,xx->descriptionOff.y); + /*fp = */wStandardFont( F_TIMES, FALSE, FALSE ); + sprintf( message, _("Bez: L%s A%0.3f trk_len=%s min_rad=%s"), + FormatDistance(FindDistance(xx->pos[0],xx->pos[3])), + FindAngle(xx->pos[0],xx->pos[3]), + FormatDistance(xx->length), + FormatDistance(xx->minCurveRadius>10000?0.0:xx->minCurveRadius)); + DrawLine(d,xx->pos[0],epos0,0,color); + DrawLine(d,xx->pos[3],epos1,0,color); + DrawDimLine( d, epos0, epos1, message, (wFontSize_t)descriptionFontSize, + xx->descriptionOff.x+0.5, 0, color, 0x00 ); + + if (GetTrkBits( trk ) & TB_DETAILDESC) { + coOrd details_pos; + details_pos.x = (epos1.x - epos0.x)*(xx->descriptionOff.x+0.5) + epos0.x; + details_pos.y = (epos1.y - epos0.y)*(xx->descriptionOff.x+0.5) + epos0.y - + (2*descriptionFontSize/mainD.dpi); AddTrkDetails(d, trk, details_pos, xx->length, color); - } + } } STATUS_T BezierDescriptionMove( - track_p trk, - wAction_t action, - coOrd pos ) + track_p trk, + wAction_t action, + coOrd pos ) { - static coOrd p0,p1; - static BOOL_T editState = FALSE; +// static coOrd p0,p1; +// static BOOL_T editState = FALSE; - if (GetTrkType(trk) != T_BEZIER) return C_TERMINATE; + if (GetTrkType(trk) != T_BEZIER) { return C_TERMINATE; } struct extraDataBezier_t *xx = GET_EXTRA_DATA(trk, T_BEZIER, extraDataBezier_t); ANGLE_T ap; coOrd end0, end1; @@ -216,9 +249,10 @@ STATUS_T BezierDescriptionMove( ap = NormalizeAngle(FindAngle(end0,pos)-FindAngle(end0,end1)); xx->descriptionOff.y = FindDistance(end0,pos)*sin(D2R(ap)); - xx->descriptionOff.x = -0.5 + FindDistance(end0,pos)*cos(D2R(ap))/FindDistance(end0,end1); - if (xx->descriptionOff.x > 0.5) xx->descriptionOff.x = 0.5; - if (xx->descriptionOff.x < -0.5) xx->descriptionOff.x = -0.5; + xx->descriptionOff.x = -0.5 + FindDistance(end0, + pos)*cos(D2R(ap))/FindDistance(end0,end1); + if (xx->descriptionOff.x > 0.5) { xx->descriptionOff.x = 0.5; } + if (xx->descriptionOff.x < -0.5) { xx->descriptionOff.x = -0.5; } return C_CONTINUE; } @@ -230,119 +264,127 @@ STATUS_T BezierDescriptionMove( */ static struct { - coOrd pos[4]; - FLOAT_T elev[2]; - FLOAT_T length; - DIST_T minRadius; - FLOAT_T grade; - unsigned int layerNumber; - ANGLE_T angle[2]; - DIST_T radius[2]; - coOrd center[2]; - dynArr_t segs; - long width; - wDrawColor color; - long lineType; - } bezData; + coOrd pos[4]; + FLOAT_T elev[2]; + FLOAT_T length; + DIST_T minRadius; + FLOAT_T grade; + unsigned int layerNumber; + ANGLE_T angle[2]; + DIST_T radius[2]; + coOrd center[2]; + dynArr_t segs; + LWIDTH_T lineWidth; + wDrawColor color; + long lineType; +} bezData; typedef enum { P0, A0, R0, C0, Z0, CP1, CP2, P1, A1, R1, C1, Z1, RA, LN, GR, LT, WI, CO, LY} crvDesc_e; static descData_t bezDesc[] = { -/*P0*/ { DESC_POS, N_("End Pt 1: X,Y"), &bezData.pos[0] }, -/*A0*/ { DESC_ANGLE, N_("End Angle"), &bezData.angle[0] }, -/*R0*/ { DESC_DIM, N_("Radius"), &bezData.radius[0] }, -/*C0*/ { DESC_POS, N_("Center X,Y"), &bezData.center[0]}, -/*Z0*/ { DESC_DIM, N_("Z1"), &bezData.elev[0] }, -/*CP1*/ { DESC_POS, N_("Ctl Pt 1: X,Y"), &bezData.pos[1] }, -/*CP2*/ { DESC_POS, N_("Ctl Pt 2: X,Y"), &bezData.pos[2] }, -/*P1*/ { DESC_POS, N_("End Pt 2: X,Y"), &bezData.pos[3] }, -/*A1*/ { DESC_ANGLE, N_("End Angle"), &bezData.angle[1] }, -/*R1*/ { DESC_DIM, N_("Radius"), &bezData.radius[1] }, -/*C1*/ { DESC_POS, N_("Center X,Y"), &bezData.center[1]}, -/*Z1*/ { DESC_DIM, N_("Z2"), &bezData.elev[1] }, -/*RA*/ { DESC_DIM, N_("MinRadius"), &bezData.radius }, -/*LN*/ { DESC_DIM, N_("Length"), &bezData.length }, -/*GR*/ { DESC_FLOAT, N_("Grade"), &bezData.grade }, -/*LT*/ { DESC_LIST, N_("Line Type"), &bezData.lineType}, -/*WI*/ { DESC_LONG, N_("Line Width"), &bezData.width}, -/*CO*/ { DESC_COLOR, N_("Line Color"), &bezData.color}, -/*LY*/ { DESC_LAYER, N_("Layer"), &bezData.layerNumber }, - { DESC_NULL } }; - -static void UpdateBezier( track_p trk, int inx, descData_p descUpd, BOOL_T final ) + /*P0*/ { DESC_POS, N_("End Pt 1: X,Y"), &bezData.pos[0] }, + /*A0*/ { DESC_ANGLE, N_("End Angle"), &bezData.angle[0] }, + /*R0*/ { DESC_DIM, N_("Radius"), &bezData.radius[0] }, + /*C0*/ { DESC_POS, N_("Center X,Y"), &bezData.center[0]}, + /*Z0*/ { DESC_DIM, N_("Z1"), &bezData.elev[0] }, + /*CP1*/ { DESC_POS, N_("Ctl Pt 1: X,Y"), &bezData.pos[1] }, + /*CP2*/ { DESC_POS, N_("Ctl Pt 2: X,Y"), &bezData.pos[2] }, + /*P1*/ { DESC_POS, N_("End Pt 2: X,Y"), &bezData.pos[3] }, + /*A1*/ { DESC_ANGLE, N_("End Angle"), &bezData.angle[1] }, + /*R1*/ { DESC_DIM, N_("Radius"), &bezData.radius[1] }, + /*C1*/ { DESC_POS, N_("Center X,Y"), &bezData.center[1]}, + /*Z1*/ { DESC_DIM, N_("Z2"), &bezData.elev[1] }, + /*RA*/ { DESC_DIM, N_("MinRadius"), &bezData.radius }, + /*LN*/ { DESC_DIM, N_("Length"), &bezData.length }, + /*GR*/ { DESC_FLOAT, N_("Grade"), &bezData.grade }, + /*LT*/ { DESC_LIST, N_("Line Type"), &bezData.lineType}, + /*WI*/ { DESC_FLOAT, N_("Line Width"), &bezData.lineWidth}, + /*CO*/ { DESC_COLOR, N_("Line Color"), &bezData.color}, + /*LY*/ { DESC_LAYER, N_("Layer"), &bezData.layerNumber }, + { DESC_NULL } +}; + +static void UpdateBezier( track_p trk, int inx, descData_p descUpd, + BOOL_T final ) { - struct extraDataBezier_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, extraDataBezier_t); + struct extraDataBezier_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, + extraDataBezier_t); BOOL_T updateEndPts; EPINX_T ep; ANGLE_T angle1, angle2; BOOL_T is_Track = (GetTrkType(trk)==T_BEZIER); - if ( inx == -1 ) + if ( inx == -1 ) { return; + } updateEndPts = FALSE; UndrawNewTrack( trk ); switch ( inx ) { - case P0: - updateEndPts = TRUE; - xx->pos[0] = bezData.pos[0]; - xx->a0 = bezData.angle[1] = FindAngle(xx->pos[1],xx->pos[0]); - bezDesc[A0].mode |= DESC_CHANGE; - bezDesc[P0].mode |= DESC_CHANGE; - /* no break */ - case P1: - updateEndPts = TRUE; - xx->pos[3]= bezData.pos[3]; - xx->a1 = bezData.angle[1] = FindAngle(xx->pos[2],xx->pos[3]); - bezDesc[A1].mode |= DESC_CHANGE; - bezDesc[P1].mode |= DESC_CHANGE; - break; - case CP1: - if (is_Track) { + case P0: + updateEndPts = TRUE; + xx->pos[0] = bezData.pos[0]; + xx->a0 = bezData.angle[1] = FindAngle(xx->pos[1],xx->pos[0]); + bezDesc[A0].mode |= DESC_CHANGE; + bezDesc[P0].mode |= DESC_CHANGE; + /* no break */ + case P1: + updateEndPts = TRUE; + xx->pos[3]= bezData.pos[3]; + xx->a1 = bezData.angle[1] = FindAngle(xx->pos[2],xx->pos[3]); + bezDesc[A1].mode |= DESC_CHANGE; + bezDesc[P1].mode |= DESC_CHANGE; + break; + case CP1: + if (is_Track) { if (GetTrkEndTrk(trk,0)) { angle1 = NormalizeAngle(GetTrkEndAngle(trk,0)); angle2 = DifferenceBetweenAngles(FindAngle(bezData.pos[1], xx->pos[0]),angle1); - if (fabs(angle2)<90) - Translate( &bezData.pos[1], xx->pos[0], angle1, -FindDistance( xx->pos[0], bezData.pos[1] )*cos(D2R(angle2))); - else bezData.pos[1] = xx->pos[1]; + if (fabs(angle2)<90) { + Translate( &bezData.pos[1], xx->pos[0], angle1, -FindDistance( xx->pos[0], + bezData.pos[1] )*cos(D2R(angle2))); + } else { bezData.pos[1] = xx->pos[1]; } } - } - xx->pos[1] = bezData.pos[1]; - xx->a0 = bezData.angle[0] = FindAngle(xx->pos[1],xx->pos[0]); - bezDesc[A0].mode |= DESC_CHANGE; - bezDesc[CP1].mode |= DESC_CHANGE; - updateEndPts = TRUE; - break; - case CP2: - if (is_Track) { + } + xx->pos[1] = bezData.pos[1]; + xx->a0 = bezData.angle[0] = FindAngle(xx->pos[1],xx->pos[0]); + bezDesc[A0].mode |= DESC_CHANGE; + bezDesc[CP1].mode |= DESC_CHANGE; + updateEndPts = TRUE; + break; + case CP2: + if (is_Track) { if (GetTrkEndTrk(trk,1)) { angle1 = NormalizeAngle(GetTrkEndAngle(trk,1)); angle2 = DifferenceBetweenAngles(FindAngle(bezData.pos[2], xx->pos[3]),angle1); - if (fabs(angle2)<90) - Translate( &bezData.pos[2], xx->pos[3], angle1, -FindDistance( xx->pos[3], bezData.pos[2] )*cos(D2R(angle2))); - else bezData.pos[2] = xx->pos[2]; + if (fabs(angle2)<90) { + Translate( &bezData.pos[2], xx->pos[3], angle1, -FindDistance( xx->pos[3], + bezData.pos[2] )*cos(D2R(angle2))); + } else { bezData.pos[2] = xx->pos[2]; } } - } - xx->pos[2] = bezData.pos[2]; - xx->a1 = bezData.angle[1] = FindAngle(xx->pos[2],xx->pos[3]); - bezDesc[A1].mode |= DESC_CHANGE; - bezDesc[CP2].mode |= DESC_CHANGE; - updateEndPts = TRUE; - break; - case Z0: + } + xx->pos[2] = bezData.pos[2]; + xx->a1 = bezData.angle[1] = FindAngle(xx->pos[2],xx->pos[3]); + bezDesc[A1].mode |= DESC_CHANGE; + bezDesc[CP2].mode |= DESC_CHANGE; + updateEndPts = TRUE; + break; + case Z0: case Z1: ep = (inx==Z0?0:1); - UpdateTrkEndElev( trk, ep, GetTrkEndElevUnmaskedMode(trk,ep), bezData.elev[ep], NULL ); + UpdateTrkEndElev( trk, ep, GetTrkEndElevUnmaskedMode(trk,ep), bezData.elev[ep], + NULL ); ComputeElev( trk, 1-ep, FALSE, &bezData.elev[1-ep], NULL, TRUE ); - if ( bezData.length > minLength ) + if ( bezData.length > minLength ) { bezData.grade = fabs( (bezData.elev[0]-bezData.elev[1])/bezData.length )*100.0; - else + } else { bezData.grade = 0.0; + } bezDesc[GR].mode |= DESC_CHANGE; bezDesc[inx==Z0?Z1:Z0].mode |= DESC_CHANGE; - return; + return; case LY: SetTrkLayer( trk, bezData.layerNumber); break; case WI: - xx->segsWidth = bezData.width/75.0; + xx->segsLineWidth = bezData.lineWidth; break; case CO: xx->segsColor = bezData.color; @@ -351,32 +393,35 @@ static void UpdateBezier( track_p trk, int inx, descData_p descUpd, BOOL_T final xx->lineType = bezData.lineType; break; default: - AbortProg( "updateBezier: Bad inx %d", inx ); + CHECKMSG( FALSE, ( "updateBezier: Bad inx %d", inx ) ); } - ConvertToArcs(xx->pos, &xx->arcSegs, IsTrack(trk)?TRUE:FALSE, xx->segsColor, xx->segsWidth); + ConvertToArcs(xx->pos, &xx->arcSegs, IsTrack(trk)?TRUE:FALSE, xx->segsColor, + xx->segsLineWidth); trackParams_t params; - for (int i=0;i<2;i++) { - GetTrackParams(0,trk,xx->pos[i],¶ms); - bezData.radius[i] = params.arcR; - bezData.center[i] = params.arcP; - } + for (int i=0; i<2; i++) { + GetTrackParams(0,trk,xx->pos[i],¶ms); + bezData.radius[i] = params.arcR; + bezData.center[i] = params.arcP; + } if (updateEndPts && is_Track) { - if ( GetTrkEndTrk(trk,0) == NULL ) { - SetTrkEndPoint( trk, 0, bezData.pos[0], NormalizeAngle( FindAngle(bezData.pos[1], bezData.pos[0]) ) ); - bezData.angle[0] = GetTrkEndAngle(trk,0); - bezDesc[A0].mode |= DESC_CHANGE; - GetTrackParams(PARAMS_CORNU,trk,xx->pos[0],¶ms); - bezData.radius[0] = params.arcR; - bezData.center[0] = params.arcP; - } - if ( GetTrkEndTrk(trk,1) == NULL ) { - SetTrkEndPoint( trk, 1, bezData.pos[3], NormalizeAngle( FindAngle(bezData.pos[2], bezData.pos[3]) ) ); - bezData.angle[1] = GetTrkEndAngle(trk,1); - bezDesc[A1].mode |= DESC_CHANGE; - GetTrackParams(PARAMS_CORNU,trk,xx->pos[1],¶ms); - bezData.radius[1] = params.arcR; - bezData.center[1] = params.arcP; - } + if ( GetTrkEndTrk(trk,0) == NULL ) { + SetTrkEndPoint( trk, 0, bezData.pos[0], + NormalizeAngle( FindAngle(bezData.pos[1], bezData.pos[0]) ) ); + bezData.angle[0] = GetTrkEndAngle(trk,0); + bezDesc[A0].mode |= DESC_CHANGE; + GetTrackParams(PARAMS_CORNU,trk,xx->pos[0],¶ms); + bezData.radius[0] = params.arcR; + bezData.center[0] = params.arcP; + } + if ( GetTrkEndTrk(trk,1) == NULL ) { + SetTrkEndPoint( trk, 1, bezData.pos[3], + NormalizeAngle( FindAngle(bezData.pos[2], bezData.pos[3]) ) ); + bezData.angle[1] = GetTrkEndAngle(trk,1); + bezDesc[A1].mode |= DESC_CHANGE; + GetTrackParams(PARAMS_CORNU,trk,xx->pos[1],¶ms); + bezData.radius[1] = params.arcR; + bezData.center[1] = params.arcP; + } } FixUpBezier(xx->pos, xx, IsTrack(trk)); ComputeBezierBoundingBox(trk, xx); @@ -385,21 +430,23 @@ static void UpdateBezier( track_p trk, int inx, descData_p descUpd, BOOL_T final static void DescribeBezier( track_p trk, char * str, CSIZE_T len ) { - struct extraDataBezier_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, extraDataBezier_t); + struct extraDataBezier_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, + extraDataBezier_t); DIST_T d; int fix0 = 0, fix1 = 0; - + d = xx->length; - sprintf( str, _("Bezier %s(%d): Layer=%u MinRadius=%s Length=%s EP=[%0.3f,%0.3f] [%0.3f,%0.3f] CP1=[%0.3f,%0.3f] CP2=[%0.3f, %0.3f]"), - GetTrkType(trk)==T_BEZIER?"Track":"Line", - GetTrkIndex(trk), - GetTrkLayer(trk)+1, - FormatDistance(xx->minCurveRadius), - FormatDistance(d), - PutDim(xx->pos[0].x),PutDim(xx->pos[0].y), - PutDim(xx->pos[3].x),PutDim(xx->pos[3].y), - PutDim(xx->pos[1].x),PutDim(xx->pos[1].y), - PutDim(xx->pos[2].x),PutDim(xx->pos[2].y)); + sprintf( str, + _("Bezier %s(%d): Layer=%u MinRadius=%s Length=%s EP=[%0.3f,%0.3f] [%0.3f,%0.3f] CP1=[%0.3f,%0.3f] CP2=[%0.3f, %0.3f]"), + GetTrkType(trk)==T_BEZIER?"Track":"Line", + GetTrkIndex(trk), + GetTrkLayer(trk)+1, + FormatDistance(xx->minCurveRadius), + FormatDistance(d), + PutDim(xx->pos[0].x),PutDim(xx->pos[0].y), + PutDim(xx->pos[3].x),PutDim(xx->pos[3].y), + PutDim(xx->pos[1].x),PutDim(xx->pos[1].y), + PutDim(xx->pos[2].x),PutDim(xx->pos[2].y)); if (GetTrkType(trk) == T_BEZIER) { fix0 = GetTrkEndTrk(trk,0)!=NULL; @@ -408,47 +455,47 @@ static void DescribeBezier( track_p trk, char * str, CSIZE_T len ) bezData.length = GetLengthBezier(trk); bezData.minRadius = xx->minCurveRadius; - if (bezData.minRadius >= DIST_INF) bezData.minRadius = 0; - bezData.layerNumber = GetTrkLayer(trk); - bezData.pos[0] = xx->pos[0]; - bezData.pos[1] = xx->pos[1]; - bezData.pos[2] = xx->pos[2]; - bezData.pos[3] = xx->pos[3]; - bezData.angle[0] = xx->a0; - bezData.angle[1] = xx->a1; - trackParams_t params; - GetTrackParams(PARAMS_CORNU,trk,xx->pos[0],¶ms); - bezData.radius[0] = params.arcR; - bezData.center[0] = params.arcP; - GetTrackParams(PARAMS_CORNU,trk,xx->pos[3],¶ms); - bezData.radius[1] = params.arcR; - bezData.center[1] = params.arcP; - - if (GetTrkType(trk) == T_BEZIER) { + if (bezData.minRadius >= DIST_INF) { bezData.minRadius = 0; } + bezData.layerNumber = GetTrkLayer(trk); + bezData.pos[0] = xx->pos[0]; + bezData.pos[1] = xx->pos[1]; + bezData.pos[2] = xx->pos[2]; + bezData.pos[3] = xx->pos[3]; + bezData.angle[0] = xx->a0; + bezData.angle[1] = xx->a1; + trackParams_t params; + GetTrackParams(PARAMS_CORNU,trk,xx->pos[0],¶ms); + bezData.radius[0] = params.arcR; + bezData.center[0] = params.arcP; + GetTrackParams(PARAMS_CORNU,trk,xx->pos[3],¶ms); + bezData.radius[1] = params.arcR; + bezData.center[1] = params.arcP; + + if (GetTrkType(trk) == T_BEZIER) { ComputeElev( trk, 0, FALSE, &bezData.elev[0], NULL, FALSE ); ComputeElev( trk, 1, FALSE, &bezData.elev[1], NULL, FALSE ); - - if ( bezData.length > minLength ) + + if ( bezData.length > minLength ) { bezData.grade = fabs( (bezData.elev[0]-bezData.elev[1])/bezData.length )*100.0; - else + } else { bezData.grade = 0.0; - } + } + } bezDesc[P0].mode = fix0?DESC_RO:0; bezDesc[P1].mode = fix1?DESC_RO:0; bezDesc[LN].mode = DESC_RO; - bezDesc[CP1].mode = 0; - bezDesc[CP2].mode = 0; - if (GetTrkType(trk) == T_BEZIER) { - bezDesc[Z0].mode = EndPtIsDefinedElev(trk,0)?0:DESC_RO; + bezDesc[CP1].mode = 0; + bezDesc[CP2].mode = 0; + if (GetTrkType(trk) == T_BEZIER) { + bezDesc[Z0].mode = EndPtIsDefinedElev(trk,0)?0:DESC_RO; bezDesc[Z1].mode = EndPtIsDefinedElev(trk,1)?0:DESC_RO; bezDesc[LT].mode = DESC_IGNORE; - } - else { - bezDesc[Z0].mode = bezDesc[Z1].mode = DESC_IGNORE; - bezDesc[LT].mode = 0; - bezData.lineType = xx->lineType; - } + } else { + bezDesc[Z0].mode = bezDesc[Z1].mode = DESC_IGNORE; + bezDesc[LT].mode = 0; + bezData.lineType = xx->lineType; + } bezDesc[A0].mode = DESC_RO; bezDesc[A1].mode = DESC_RO; bezDesc[C0].mode = DESC_RO; @@ -456,16 +503,16 @@ static void DescribeBezier( track_p trk, char * str, CSIZE_T len ) bezDesc[R0].mode = DESC_RO; bezDesc[R1].mode = DESC_RO; bezDesc[GR].mode = DESC_RO; - bezDesc[RA].mode = DESC_RO; + bezDesc[RA].mode = DESC_RO; bezDesc[LY].mode = DESC_NOREDRAW; - bezData.width = (long)floor(xx->segsWidth*75.0+0.5); + bezData.lineWidth = xx->segsLineWidth; bezDesc[WI].mode = GetTrkType(trk) == T_BEZIER?DESC_IGNORE:0; bezData.color = xx->segsColor; bezDesc[CO].mode = GetTrkType(trk) == T_BEZIER?DESC_IGNORE:0; - - if (GetTrkType(trk) == T_BEZIER) + + if (GetTrkType(trk) == T_BEZIER) { DoDescribe( _("Bezier Track"), trk, bezDesc, UpdateBezier ); - else { + } else { DoDescribe( _("Bezier Line"), trk, bezDesc, UpdateBezier ); if (bezDesc[LT].control0!=NULL) { wListClear( (wList_p)bezDesc[LT].control0 ); @@ -482,9 +529,11 @@ static void DescribeBezier( track_p trk, char * str, CSIZE_T len ) } -EXPORT void SetBezierLineType( track_p trk, int width ) { +EXPORT void SetBezierLineType( track_p trk, int width ) +{ if (GetTrkType(trk) == T_BZRLIN) { - struct extraDataBezier_t * xx = GET_EXTRA_DATA(trk, T_BZRLIN, extraDataBezier_t); + struct extraDataBezier_t * xx = GET_EXTRA_DATA(trk, T_BZRLIN, + extraDataBezier_t); switch(width) { case 0: xx->lineType = DRAWLINESOLID; @@ -518,7 +567,7 @@ static DIST_T DistanceBezier( track_p t, coOrd * p ) DIST_T d = DIST_INF; coOrd p2 = xx->pos[0]; //Set initial point segProcData_t segProcData; - for (int i = 0;i<xx->arcSegs.cnt;i++) { + for (int i = 0; i<xx->arcSegs.cnt; i++) { segProcData.distance.pos1 = * p; SegProc(SEGPROC_DISTANCE,&DYNARR_N(trkSeg_t,xx->arcSegs,i),&segProcData); if (segProcData.distance.dd<d) { @@ -526,7 +575,7 @@ static DIST_T DistanceBezier( track_p t, coOrd * p ) p2 = segProcData.distance.pos1; } } - * p = p2; + * p = p2; return d; } @@ -540,25 +589,24 @@ static void DrawBezier( track_p t, drawCmd_p d, wDrawColor color ) unsigned long NotSolid = ~(DC_NOTSOLIDLINE); d->options &= NotSolid; if (xx->lineType == DRAWLINESOLID) {} - else if (xx->lineType == DRAWLINEDASH) d->options |= DC_DASH; - else if (xx->lineType == DRAWLINEDOT) d->options |= DC_DOT; - else if (xx->lineType == DRAWLINEDASHDOT) d->options |= DC_DASHDOT; - else if (xx->lineType == DRAWLINEDASHDOTDOT) d->options |= DC_DASHDOTDOT; - else if (xx->lineType == DRAWLINECENTER) d->options |= DC_CENTER; - else if (xx->lineType == DRAWLINEPHANTOM) d->options |= DC_PHANTOM; - DrawSegsO(d,t,zero,0.0,xx->arcSegs.ptr,xx->arcSegs.cnt, 0.0, color, 0); + else if (xx->lineType == DRAWLINEDASH) { d->options |= DC_DASH; } + else if (xx->lineType == DRAWLINEDOT) { d->options |= DC_DOT; } + else if (xx->lineType == DRAWLINEDASHDOT) { d->options |= DC_DASHDOT; } + else if (xx->lineType == DRAWLINEDASHDOTDOT) { d->options |= DC_DASHDOTDOT; } + else if (xx->lineType == DRAWLINECENTER) { d->options |= DC_CENTER; } + else if (xx->lineType == DRAWLINEPHANTOM) { d->options |= DC_PHANTOM; } + DrawSegsDA(d,t,zero,0.0,&xx->arcSegs, 0.0, color, 0); d->options &= NotSolid; return; } if ( ((d->options&DC_SIMPLE)==0) && - (labelWhen == 2 || (labelWhen == 1 && (d->options&DC_PRINT))) && - labelScale >= d->scale && - ( GetTrkBits( t ) & TB_HIDEDESC ) == 0 ) { + (labelWhen == 2 || (labelWhen == 1 && (d->options&DC_PRINT))) && + labelScale >= d->scale && + ( GetTrkBits( t ) & TB_HIDEDESC ) == 0 ) { DrawBezierDescription( t, d, color ); } - DIST_T scale2rail = (d->options&DC_PRINT)?(twoRailScale*2+1):twoRailScale; - DrawSegsO(d,t,zero,0.0,xx->arcSegs.ptr,xx->arcSegs.cnt, GetTrkGauge(t), color, widthOptions); + DrawSegsDA(d,t,zero,0.0,&xx->arcSegs, GetTrkGauge(t), color, widthOptions); DrawEndPt( d, t, 0, color ); DrawEndPt( d, t, 1, color ); } @@ -567,44 +615,44 @@ static void DeleteBezier( track_p t ) { struct extraDataBezier_t *xx = GET_EXTRA_DATA(t, T_NOTRACK, extraDataBezier_t); - for (int i=0;i<xx->arcSegs.cnt;i++) { + // NOTE - should use trkSeg_p so we free seg in orig trk, instead of copy + for (int i=0; i<xx->arcSegs.cnt; i++) { trkSeg_t s = DYNARR_N(trkSeg_t,xx->arcSegs,i); if (s.type == SEG_BEZTRK || s.type == SEG_BEZLIN) { - if (s.bezSegs.ptr) MyFree(s.bezSegs.ptr); - s.bezSegs.max = 0; - s.bezSegs.cnt = 0; - s.bezSegs.ptr = NULL; + DYNARR_FREE( trkSeg_t, s.bezSegs ); } } - if (xx->arcSegs.ptr && !xx->arcSegs.max) - MyFree(xx->arcSegs.ptr); - xx->arcSegs.max = 0; - xx->arcSegs.cnt = 0; - xx->arcSegs.ptr = NULL; + // NOTE orig tests !xx->arcSegs.max ??? + DYNARR_FREE( trkSeg_t, xx->arcSegs ); } static BOOL_T WriteBezier( track_p t, FILE * f ) { struct extraDataBezier_t *xx = GET_EXTRA_DATA(t, T_NOTRACK, extraDataBezier_t); + int bits; long options; BOOL_T rc = TRUE; BOOL_T track =(GetTrkType(t)==T_BEZIER); options = GetTrkWidth(t) & 0x0F; - if ( ( GetTrkBits(t) & TB_HIDEDESC ) == 0 ) options |= 0x80; - rc &= fprintf(f, "%s %d %u %ld %ld %0.6f %s %d %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %d %0.6f %0.6f \n", - track?"BEZIER":"BZRLIN",GetTrkIndex(t), GetTrkLayer(t), (long)options, wDrawGetRGB(xx->segsColor), xx->segsWidth, - GetTrkScaleName(t), GetTrkVisible(t)|(GetTrkNoTies(t)?1<<2:0)|(GetTrkBridge(t)?1<<3:0), - xx->pos[0].x, xx->pos[0].y, - xx->pos[1].x, xx->pos[1].y, - xx->pos[2].x, xx->pos[2].y, - xx->pos[3].x, xx->pos[3].y, - xx->lineType, - xx->descriptionOff.x, xx->descriptionOff.y )>0; + if ( ( GetTrkBits(t) & TB_HIDEDESC ) == 0 ) { options |= 0x80; } + bits = GetTrkVisible(t)|(GetTrkNoTies(t)?1<<2:0)|(GetTrkBridge(t)?1<<3:0)| + (GetTrkRoadbed(t)?1<<4:0); + rc &= fprintf(f, + "%s %d %u %ld %ld %0.6f %s %d %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %d %0.6f %0.6f \n", + track?"BEZIER":"BZRLIN",GetTrkIndex(t), GetTrkLayer(t), (long)options, + wDrawGetRGB(xx->segsColor), xx->segsLineWidth, + GetTrkScaleName(t), bits, + xx->pos[0].x, xx->pos[0].y, + xx->pos[1].x, xx->pos[1].y, + xx->pos[2].x, xx->pos[2].y, + xx->pos[3].x, xx->pos[3].y, + xx->lineType, + xx->descriptionOff.x, xx->descriptionOff.y )>0; if (track) { - rc &= WriteEndPt( f, t, 0 ); - rc &= WriteEndPt( f, t, 1 ); - } - rc &= WriteSegs( f, xx->arcSegs.cnt, xx->arcSegs.ptr ); + rc &= WriteEndPt( f, t, 0 ); + rc &= WriteEndPt( f, t, 1 ); + } + rc &= WriteSegs( f, xx->arcSegs.cnt, &DYNARR_N(trkSeg_t,xx->arcSegs,0) ); return rc; } @@ -619,141 +667,154 @@ static BOOL_T ReadBezier( char * line ) wIndex_t layer; long options; int lt; - char * cp = NULL; +// char * cp = NULL; unsigned long rgb; - DIST_T width; + LWIDTH_T lineWidth; TRKTYP_T trkTyp = strncmp(line,"BEZIER",6)==0?T_BEZIER:T_BZRLIN; if (!GetArgs( line+6, "dLluwsdppppdp", - &index, &layer, &options, &rgb, &width, scale, &visible, &p0, &c1, &c2, &p1, <, &dp ) ) { + &index, &layer, &options, &rgb, &lineWidth, scale, &visible, &p0, &c1, &c2, &p1, + <, &dp ) ) { return FALSE; } - if ( !ReadSegs() ) + if ( !ReadSegs() ) { return FALSE; + } t = NewTrack( index, trkTyp, 0, sizeof *xx ); xx = GET_EXTRA_DATA(t, trkTyp, extraDataBezier_t); SetTrkVisible(t, visible&2); SetTrkNoTies(t,visible&4); SetTrkBridge(t,visible&8); + SetTrkRoadbed(t,visible&16); SetTrkScale(t, LookupScale(scale)); SetTrkLayer(t, layer ); SetTrkWidth(t, (int)(options&0x0F)); - if ( paramVersion < VERSION_DESCRIPTION2 || ( options & 0x80 ) == 0 ) SetTrkBits(t,TB_HIDEDESC); + if ( paramVersion < VERSION_DESCRIPTION2 || ( options & 0x80 ) == 0 ) { SetTrkBits(t,TB_HIDEDESC); } xx->pos[0] = p0; - xx->pos[1] = c1; - xx->pos[2] = c2; - xx->pos[3] = p1; - xx->lineType = lt; - xx->descriptionOff = dp; - xx->segsWidth = width; - xx->segsColor = wDrawFindColor( rgb ); - FixUpBezier(xx->pos,xx,GetTrkType(t) == T_BEZIER); - ComputeBezierBoundingBox(t,xx); - if (GetTrkType(t) == T_BEZIER) { + xx->pos[1] = c1; + xx->pos[2] = c2; + xx->pos[3] = p1; + xx->lineType = lt; + xx->descriptionOff = dp; + xx->segsLineWidth = lineWidth; + xx->segsColor = wDrawFindColor( rgb ); + FixUpBezier(xx->pos,xx,GetTrkType(t) == T_BEZIER); + ComputeBezierBoundingBox(t,xx); + if (GetTrkType(t) == T_BEZIER) { SetEndPts(t,2); } return TRUE; } -static void MoveBezier( track_p trk, coOrd orig ) +EXPORT void MoveBezier( track_p trk, coOrd orig ) { - struct extraDataBezier_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, extraDataBezier_t); - for (int i=0;i<4;i++) { - xx->pos[i].x += orig.x; - xx->pos[i].y += orig.y; - } - FixUpBezier(xx->pos,xx,IsTrack(trk)); - ComputeBezierBoundingBox(trk,xx); + struct extraDataBezier_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, + extraDataBezier_t); + for (int i=0; i<4; i++) { + xx->pos[i].x += orig.x; + xx->pos[i].y += orig.y; + } + FixUpBezier(xx->pos,xx,IsTrack(trk)); + ComputeBezierBoundingBox(trk,xx); } -static void RotateBezier( track_p trk, coOrd orig, ANGLE_T angle ) +EXPORT void RotateBezier( track_p trk, coOrd orig, ANGLE_T angle ) { - struct extraDataBezier_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, extraDataBezier_t); - for (int i=0;i<COUNT(xx->pos);i++) { - Rotate( &xx->pos[i], orig, angle ); - } - FixUpBezier(xx->pos,xx,IsTrack(trk)); - ComputeBezierBoundingBox(trk,xx); + struct extraDataBezier_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, + extraDataBezier_t); + for (int i=0; i<COUNT(xx->pos); i++) { + Rotate( &xx->pos[i], orig, angle ); + } + FixUpBezier(xx->pos,xx,IsTrack(trk)); + ComputeBezierBoundingBox(trk,xx); } static void RescaleBezier( track_p trk, FLOAT_T ratio ) { - struct extraDataBezier_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, extraDataBezier_t); + struct extraDataBezier_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, + extraDataBezier_t); xx->pos[0].x *= ratio; xx->pos[0].y *= ratio; - xx->pos[1].x *= ratio; - xx->pos[1].y *= ratio; - xx->pos[2].x *= ratio; - xx->pos[2].y *= ratio; - xx->pos[3].x *= ratio; - xx->pos[3].y *= ratio; - FixUpBezier(xx->pos,xx,IsTrack(trk)); - ComputeBezierBoundingBox(trk,xx); + xx->pos[1].x *= ratio; + xx->pos[1].y *= ratio; + xx->pos[2].x *= ratio; + xx->pos[2].y *= ratio; + xx->pos[3].x *= ratio; + xx->pos[3].y *= ratio; + FixUpBezier(xx->pos,xx,IsTrack(trk)); + ComputeBezierBoundingBox(trk,xx); } -EXPORT void AdjustBezierEndPt( track_p trk, EPINX_T inx, coOrd pos ) { - struct extraDataBezier_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, extraDataBezier_t); - UndoModify(trk); - if (inx ==0 ) { - xx->pos[1].x += -xx->pos[0].x+pos.x; - xx->pos[1].y += -xx->pos[0].y+pos.y; - xx->pos[0] = pos; - } - else { - xx->pos[2].x += -xx->pos[3].x+pos.x; - xx->pos[2].y += -xx->pos[3].y+pos.y; - xx->pos[3] = pos; - } - FixUpBezier(xx->pos, xx, IsTrack(trk)); - ComputeBezierBoundingBox(trk,xx); - SetTrkEndPoint( trk, inx, pos, inx==0?xx->a0:xx->a1); +EXPORT void AdjustBezierEndPt( track_p trk, EPINX_T inx, coOrd pos ) +{ + struct extraDataBezier_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, + extraDataBezier_t); + UndoModify(trk); + if (inx ==0 ) { + xx->pos[1].x += -xx->pos[0].x+pos.x; + xx->pos[1].y += -xx->pos[0].y+pos.y; + xx->pos[0] = pos; + } else { + xx->pos[2].x += -xx->pos[3].x+pos.x; + xx->pos[2].y += -xx->pos[3].y+pos.y; + xx->pos[3] = pos; + } + FixUpBezier(xx->pos, xx, IsTrack(trk)); + ComputeBezierBoundingBox(trk,xx); + SetTrkEndPoint( trk, inx, pos, inx==0?xx->a0:xx->a1); } /** * Split the Track at approximately the point pos. */ -static BOOL_T SplitBezier( track_p trk, coOrd pos, EPINX_T ep, track_p *leftover, EPINX_T * ep0, EPINX_T * ep1 ) +static BOOL_T SplitBezier( track_p trk, coOrd pos, EPINX_T ep, + track_p *leftover, EPINX_T * ep0, EPINX_T * ep1 ) { - struct extraDataBezier_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, extraDataBezier_t); + struct extraDataBezier_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, + extraDataBezier_t); track_p trk1; - double t; - BOOL_T track; - track = IsTrack(trk); - - coOrd current[4], newl[4], newr[4]; - - double dd = DistanceBezier(trk, &pos); - if (dd>minLength) return FALSE; - - BezierMathDistance(&pos, xx->pos, 500, &t); //Find t value - - for (int i=0;i<4;i++) { - current[i] = xx->pos[i]; - } - - BezierSplit(current, newl, newr, t); - - if (track) { - trk1 = NewBezierTrack(ep?newr:newl,NULL,0); - //Move elev data from ep - } else - trk1 = NewBezierLine(ep?newr:newl,NULL,0, xx->segsColor,xx->segsWidth); - DIST_T height; - int opt; - GetTrkEndElev(trk,ep,&opt,&height); - UpdateTrkEndElev( trk1, ep, opt, height, (opt==ELEV_STATION)?GetTrkEndElevStation(trk,ep):NULL ); - UndoModify(trk); - for (int i=0;i<4;i++) { - xx->pos[i] = ep?newl[i]:newr[i]; - } - FixUpBezier(xx->pos,xx,track); - ComputeBezierBoundingBox(trk,xx); - SetTrkEndPoint( trk, ep, xx->pos[ep?3:0], ep?xx->a1:xx->a0); - UpdateTrkEndElev( trk, ep, ELEV_NONE, 0, NULL); + double t; + BOOL_T track; + track = IsTrack(trk); + + coOrd current[4], newl[4], newr[4]; + + double dd = DistanceBezier(trk, &pos); + if (dd>minLength) { return FALSE; } + + BezierMathDistance(&pos, xx->pos, 500, &t); //Find t value + + for (int i=0; i<4; i++) { + current[i] = xx->pos[i]; + } + + BezierSplit(current, newl, newr, t); + + if (track) { + trk1 = NewBezierTrack(ep?newr:newl,NULL,0); + //Move elev data from ep + DIST_T height; + int opt; + GetTrkEndElev(trk,ep,&opt,&height); + UpdateTrkEndElev( trk1, ep, opt, height, + (opt==ELEV_STATION)?GetTrkEndElevStation(trk,ep):NULL ); + } else { + trk1 = NewBezierLine(ep?newr:newl,NULL,0, xx->segsColor,xx->segsLineWidth); + } + UndoModify(trk); + for (int i=0; i<4; i++) { + xx->pos[i] = ep?newl[i]:newr[i]; + } + FixUpBezier(xx->pos,xx,track); + ComputeBezierBoundingBox(trk,xx); + if ( track ) { + SetTrkEndPoint( trk, ep, xx->pos[ep?3:0], ep?xx->a1:xx->a0); + UpdateTrkEndElev( trk, ep, ELEV_NONE, 0, NULL); + } *leftover = trk1; *ep0 = 1-ep; *ep1 = ep; @@ -782,7 +843,7 @@ static int log_bezierSegments = 0; */ static BOOL_T TraverseBezier( traverseTrack_p trvTrk, DIST_T * distR ) { - track_p trk = trvTrk->trk; + track_p trk = trvTrk->trk; struct extraDataBezier_t *xx = GET_EXTRA_DATA(trk, T_BEZIER, extraDataBezier_t); DIST_T dist = *distR; segProcData_t segProcData; @@ -793,19 +854,22 @@ static BOOL_T TraverseBezier( traverseTrack_p trvTrk, DIST_T * distR ) int inx,segInx = 0; EPINX_T ep; BOOL_T back,neg; - trkSeg_p segPtr = (trkSeg_p)xx->arcSegs.ptr; + trkSeg_p segPtr = &DYNARR_N(trkSeg_t,xx->arcSegs,0); a2 = GetAngleSegs( //Find correct Segment and nearest point in it - xx->arcSegs.cnt,segPtr, - &pos2, &segInx, &d , &back, NULL, &neg ); //d = how far pos2 from old pos2 = trvTrk->pos + xx->arcSegs.cnt,segPtr, + &pos2, &segInx, &d, &back, NULL, + &neg ); //d = how far pos2 from old pos2 = trvTrk->pos if ( d > 10 ) { - ErrorMessage( "traverseBezier: Position is not near track: %0.3f", d ); - return FALSE; //This means the input pos is not on or close to the track. + ErrorMessage( "traverseBezier: Position is not near track: %0.3f", d ); + return FALSE; //This means the input pos is not on or close to the track. } - if (back) a2 = NormalizeAngle(a2+180); //GetAngleSegs has reversed angle for backwards - a1 = NormalizeAngle(a2-trvTrk->angle); //Establish if we are going fwds or backwards globally - if (a1 <270 && a1>90) { //Must add 180 if the seg is reversed or inverted (but not both) + if (back) { a2 = NormalizeAngle(a2+180); } //GetAngleSegs has reversed angle for backwards + a1 = NormalizeAngle(a2 + -trvTrk->angle); //Establish if we are going fwds or backwards globally + if (a1 <270 + && a1>90) { //Must add 180 if the seg is reversed or inverted (but not both) segs_backwards = TRUE; ep = 0; } else { @@ -818,25 +882,34 @@ static BOOL_T TraverseBezier( traverseTrack_p trvTrk, DIST_T * distR ) } segProcData.traverse1.pos = pos2; //actual point on curve - segProcData.traverse1.angle = trvTrk->angle; //direction car is going for Traverse 1 has to be reversed... -LOG( log_traverseBezier, 1, ( " TraverseBezier [%0.3f %0.3f] D%0.3f A%0.3f SB%d \n", trvTrk->pos.x, trvTrk->pos.y, dist, trvTrk->angle, segs_backwards ) ) + segProcData.traverse1.angle = + trvTrk->angle; //direction car is going for Traverse 1 has to be reversed... + LOG( log_traverseBezier, 1, + ( " TraverseBezier [%0.3f %0.3f] D%0.3f A%0.3f SB%d \n", trvTrk->pos.x, + trvTrk->pos.y, dist, trvTrk->angle, segs_backwards ) ) inx = segInx; while (inx >=0 && inx<xx->arcSegs.cnt) { - segPtr = (trkSeg_p)xx->arcSegs.ptr+inx; //move in to the identified segment - SegProc( SEGPROC_TRAVERSE1, segPtr, &segProcData ); //Backwards or forwards for THIS segment - note that this can differ from segs_backward!! + segPtr = &DYNARR_N(trkSeg_t,xx->arcSegs, + inx); //move in to the identified segment + SegProc( SEGPROC_TRAVERSE1, segPtr, + &segProcData ); //Backwards or forwards for THIS segment - note that this can differ from segs_backward!! BOOL_T backwards = segProcData.traverse1.backwards; //Are we going to EP0? - BOOL_T reverse_seg = segProcData.traverse1.reverse_seg; //is it a backwards segment (we don't actually care as Traverse1 takes care of it) + BOOL_T reverse_seg = + segProcData.traverse1.reverse_seg; //is it a backwards segment (we don't actually care as Traverse1 takes care of it) dist += segProcData.traverse1.dist; segProcData.traverse2.dist = dist; segProcData.traverse2.segDir = backwards; -LOG( log_traverseBezier, 2, ( " TraverseBezierT1 D%0.3f B%d RS%d \n", dist, backwards, reverse_seg ) ) + LOG( log_traverseBezier, 2, ( " TraverseBezierT1 D%0.3f B%d RS%d \n", dist, + backwards, reverse_seg ) ) SegProc( SEGPROC_TRAVERSE2, segPtr, &segProcData ); //Angle at pos2 - if ( segProcData.traverse2.dist <= 0 ) { //-ve or zero distance left over so stop there + if ( segProcData.traverse2.dist <= + 0 ) { //-ve or zero distance left over so stop there *distR = 0; trvTrk->pos = segProcData.traverse2.pos; trvTrk->angle = segProcData.traverse2.angle; -LOG( log_traverseBezier, 1, ( " -> [%0.3f %0.3f] A%0.3f D%0.3f\n", trvTrk->pos.x, trvTrk->pos.y, trvTrk->angle, *distR ) ) + LOG( log_traverseBezier, 1, ( " -> [%0.3f %0.3f] A%0.3f D%0.3f\n", + trvTrk->pos.x, trvTrk->pos.y, trvTrk->angle, *distR ) ) return TRUE; } //NOTE Traverse1 and Traverse2 are overlays so get all out before storing dist = segProcData.traverse2.dist; //How far left? @@ -844,30 +917,34 @@ LOG( log_traverseBezier, 1, ( " -> [%0.3f %0.3f] A%0.3f D%0.3f\n", trvTrk->pos. ANGLE_T angle = segProcData.traverse2.angle; //Angle of end segProcData.traverse1.angle = angle; //Reverse to suit Traverse1 segProcData.traverse1.pos = pos; - inx = segs_backwards?inx-1:inx+1; //Here's where the global segment direction comes in -LOG( log_traverseBezier, 2, ( " TraverseBezierL D%0.3f A%0.3f\n", dist, angle ) ) + inx = segs_backwards?inx-1:inx + +1; //Here's where the global segment direction comes in + LOG( log_traverseBezier, 2, ( " TraverseBezierL D%0.3f A%0.3f\n", dist, + angle ) ) } *distR = dist; //Tell caller what is left - //Must be at one end or another + //Must be at one end or another trvTrk->pos = GetTrkEndPos(trk,ep); - trvTrk->angle = NormalizeAngle(GetTrkEndAngle(trk, ep));//+(segs_backwards?180:0)) + trvTrk->angle = NormalizeAngle(GetTrkEndAngle(trk, + ep));//+(segs_backwards?180:0)) trvTrk->trk = GetTrkEndTrk(trk,ep); //go to next track if (trvTrk->trk==NULL) { trvTrk->pos = pos2; - return TRUE; + return TRUE; } -LOG( log_traverseBezier, 1, ( " -> [%0.3f %0.3f] A%0.3f D%0.3f\n", trvTrk->pos.x, trvTrk->pos.y, trvTrk->angle, *distR ) ) + LOG( log_traverseBezier, 1, ( " -> [%0.3f %0.3f] A%0.3f D%0.3f\n", + trvTrk->pos.x, trvTrk->pos.y, trvTrk->angle, *distR ) ) return TRUE; } static BOOL_T MergeBezier( - track_p trk0, - EPINX_T ep0, - track_p trk1, - EPINX_T ep1 ) + track_p trk0, + EPINX_T ep0, + track_p trk1, + EPINX_T ep1 ) { return FALSE; } @@ -880,7 +957,7 @@ static BOOL_T EnumerateBezier( track_p trk ) DIST_T d; struct extraDataBezier_t *xx = GET_EXTRA_DATA(trk, T_BEZIER, extraDataBezier_t); d = max(BezierOffsetLength(xx->arcSegs,-GetTrkGauge(trk)/2.0), - BezierOffsetLength(xx->arcSegs,GetTrkGauge(trk)/2.0)); + BezierOffsetLength(xx->arcSegs,GetTrkGauge(trk)/2.0)); ScaleLengthIncrement( GetTrkScale(trk), d ); return TRUE; } @@ -889,21 +966,24 @@ static BOOL_T EnumerateBezier( track_p trk ) static DIST_T GetLengthBezier( track_p trk ) { - struct extraDataBezier_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, extraDataBezier_t); + struct extraDataBezier_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, + extraDataBezier_t); DIST_T length = 0.0; segProcData_t segProcData; - for(int i=0;i<xx->arcSegs.cnt;i++) { + for(int i=0; i<xx->arcSegs.cnt; i++) { SegProc(SEGPROC_LENGTH,&(DYNARR_N(trkSeg_t,xx->arcSegs,i)), &segProcData); length += segProcData.length.length; } return length; } -EXPORT BOOL_T GetBezierMiddle( track_p trk, coOrd * pos) { +EXPORT BOOL_T GetBezierMiddle( track_p trk, coOrd * pos) +{ - if (GetTrkType(trk) != T_BEZIER) + if (GetTrkType(trk) != T_BEZIER) { return FALSE; - struct extraDataBezier_t *xx = GET_EXTRA_DATA(trk, T_BEZIER, extraDataBezier_t); + } +// struct extraDataBezier_t *xx = GET_EXTRA_DATA(trk, T_BEZIER, extraDataBezier_t); DIST_T length = GetLengthBezier(trk)/2; traverseTrack_t tp; @@ -921,20 +1001,23 @@ EXPORT BOOL_T GetBezierMiddle( track_p trk, coOrd * pos) { } -static BOOL_T GetParamsBezier( int inx, track_p trk, coOrd pos, trackParams_t * params ) +static BOOL_T GetParamsBezier( int inx, track_p trk, coOrd pos, + trackParams_t * params ) { int segInx; BOOL_T back,negative; DIST_T d; params->type = curveTypeBezier; - struct extraDataBezier_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, extraDataBezier_t); - for (int i=0;i<4;i++) params->bezierPoints[i] = xx->pos[i]; + struct extraDataBezier_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, + extraDataBezier_t); + for (int i=0; i<4; i++) { params->bezierPoints[i] = xx->pos[i]; } params->len = xx->length; - params->track_angle = GetAngleSegs( //Find correct Segment and nearest point in it - xx->arcSegs.cnt,xx->arcSegs.ptr, - &pos, &segInx, &d , &back, NULL, &negative ); - if ( negative != back ) params->track_angle = NormalizeAngle(params->track_angle+180); //Bezier is in reverse + params->track_angle = + GetAngleSegs( //Find correct Segment and nearest point in it + xx->arcSegs.cnt,&DYNARR_N(trkSeg_t,xx->arcSegs,0), + &pos, &segInx, &d, &back, NULL, &negative ); + if ( negative != back ) { params->track_angle = NormalizeAngle(params->track_angle+180); } //Bezier is in reverse trkSeg_p segPtr = &DYNARR_N(trkSeg_t,xx->arcSegs,segInx); if (segPtr->type == SEG_STRLIN) { params->arcR = 0.0; @@ -945,19 +1028,21 @@ static BOOL_T GetParamsBezier( int inx, track_p trk, coOrd pos, trackParams_t * params->arcA1 = segPtr->u.c.a1; } if ( inx == PARAMS_NODES ) { - if (GetTrkType(trk) == T_BEZIER) return FALSE; + if (GetTrkType(trk) == T_BEZIER) { return FALSE; } //Pos is the place that is the end of the curve (params->ep set to 1 if the curve starts here) - if (FindDistance(pos,params->bezierPoints[0]) <= FindDistance(pos,params->bezierPoints[3])) - params->ep = 1; - else params->ep = 0; + if (FindDistance(pos,params->bezierPoints[0]) <= FindDistance(pos, + params->bezierPoints[3])) { + params->ep = 1; + } else { params->ep = 0; } coOrd curr_pos = params->bezierPoints[0]; BOOL_T first = TRUE; DYNARR_RESET(coOrd,params->nodes); // Load out the points in order from bezierPoint[0] to bezierPoint[3] - for (int i = 0; i<xx->arcSegs.cnt;i++) { + for (int i = 0; i<xx->arcSegs.cnt; i++) { trkSeg_p segPtr = &DYNARR_N(trkSeg_t,xx->arcSegs,i); if (segPtr->type == SEG_STRLIN) { - BOOL_T eps = FindDistance(segPtr->u.l.pos[0],curr_pos)>FindDistance(segPtr->u.l.pos[1],curr_pos); + BOOL_T eps = FindDistance(segPtr->u.l.pos[0], + curr_pos)>FindDistance(segPtr->u.l.pos[1],curr_pos); if (first) { first = FALSE; DYNARR_APPEND(coOrd,params->nodes,1); @@ -968,23 +1053,27 @@ static BOOL_T GetParamsBezier( int inx, track_p trk, coOrd pos, trackParams_t * } else { coOrd start,end; Translate(&start,segPtr->u.c.center,segPtr->u.c.a0,fabs(segPtr->u.c.radius)); - Translate(&end,segPtr->u.c.center,segPtr->u.c.a0+segPtr->u.c.a1,fabs(segPtr->u.c.radius)); + Translate(&end,segPtr->u.c.center,segPtr->u.c.a0+segPtr->u.c.a1, + fabs(segPtr->u.c.radius)); //Is this segment reversed in the curve? BOOL_T back = FindDistance(start,curr_pos)>FindDistance(end,curr_pos); if (segPtr->u.c.radius > 0.5) { - double min_angle = 360*acos(1.0-(0.1/fabs(segPtr->u.c.radius)))/M_PI; //Error max is 0.1" + double min_angle = 360*acos(1.0-(0.1/fabs( + segPtr->u.c.radius)))/M_PI; //Error max is 0.1" double number = ceil(segPtr->u.c.a1/min_angle); double arc_size = segPtr->u.c.a1/number; if (back) { //If back, list sub-points in reverse. If first show first position, else skip - for (int j=(((int)number)-(1-first));j>=0;j--) { + for (int j=(((int)number)-(1-first)); j>=0; j--) { DYNARR_APPEND(coOrd,params->nodes,((int)number)); - Translate(&DYNARR_LAST(coOrd,params->nodes),segPtr->u.c.center,segPtr->u.c.a0+j*arc_size,fabs(segPtr->u.c.radius) ); + Translate(&DYNARR_LAST(coOrd,params->nodes),segPtr->u.c.center, + segPtr->u.c.a0+j*arc_size,fabs(segPtr->u.c.radius) ); } } else { - for (int j=(1-first);j<=number;j++) { + for (int j=(1-first); j<=number; j++) { DYNARR_APPEND(coOrd,params->nodes,((int)number)); - Translate(&DYNARR_LAST(coOrd,params->nodes),segPtr->u.c.center,segPtr->u.c.a0+j*arc_size,fabs(segPtr->u.c.radius) ); + Translate(&DYNARR_LAST(coOrd,params->nodes),segPtr->u.c.center, + segPtr->u.c.a0+j*arc_size,fabs(segPtr->u.c.radius) ); } } first = FALSE; @@ -1003,19 +1092,23 @@ static BOOL_T GetParamsBezier( int inx, track_p trk, coOrd pos, trackParams_t * params->lineOrig = params->bezierPoints[params->ep?0:3]; params->lineEnd = params->bezierPoints[params->ep?3:0]; return TRUE; - } else if ((inx == PARAMS_CORNU) || (inx == PARAMS_1ST_JOIN) || (inx == PARAMS_2ND_JOIN)){ + } else if ((inx == PARAMS_CORNU) || (inx == PARAMS_1ST_JOIN) + || (inx == PARAMS_2ND_JOIN)) { params->ep = PickEndPoint( pos, trk); } else { params->ep = PickUnconnectedEndPointSilent( pos, trk); } - if (params->ep>=0) + if (params->ep>=0) { params->angle = GetTrkEndAngle(trk, params->ep); + } return TRUE; } -static BOOL_T TrimBezier( track_p trk, EPINX_T ep, DIST_T dist, coOrd endpos, ANGLE_T angle, DIST_T radius, coOrd center ) { +static BOOL_T TrimBezier( track_p trk, EPINX_T ep, DIST_T dist, coOrd endpos, + ANGLE_T angle, DIST_T radius, coOrd center ) +{ UndrawNewTrack( trk ); DeleteTrack(trk, TRUE); return TRUE; @@ -1025,7 +1118,8 @@ static BOOL_T TrimBezier( track_p trk, EPINX_T ep, DIST_T dist, coOrd endpos, AN static BOOL_T QueryBezier( track_p trk, int query ) { - struct extraDataBezier_t * xx = GET_EXTRA_DATA(trk, T_NOTRACK, extraDataBezier_t); + struct extraDataBezier_t * xx = GET_EXTRA_DATA(trk, T_NOTRACK, + extraDataBezier_t); switch ( query ) { case Q_CAN_GROUP: return FALSE; @@ -1037,7 +1131,8 @@ static BOOL_T QueryBezier( track_p trk, int query ) return TRUE; break; case Q_EXCEPTION: - return GetTrkType(trk) == T_BEZIER?fabs(xx->minCurveRadius) < (GetLayoutMinTrackRadius()-EPSILON):FALSE; + return GetTrkType(trk) == T_BEZIER?fabs(xx->minCurveRadius) < + (GetLayoutMinTrackRadius()-EPSILON):FALSE; break; case Q_CAN_MODIFY_CONTROL_POINTS: return TRUE; @@ -1065,15 +1160,16 @@ static BOOL_T QueryBezier( track_p trk, int query ) static void FlipBezier( - track_p trk, - coOrd orig, - ANGLE_T angle ) + track_p trk, + coOrd orig, + ANGLE_T angle ) { - struct extraDataBezier_t * xx = GET_EXTRA_DATA(trk, T_NOTRACK, extraDataBezier_t); + struct extraDataBezier_t * xx = GET_EXTRA_DATA(trk, T_NOTRACK, + extraDataBezier_t); FlipPoint( &xx->pos[0], orig, angle ); FlipPoint( &xx->pos[1], orig, angle ); - FlipPoint( &xx->pos[2], orig, angle ); - FlipPoint( &xx->pos[3], orig, angle ); + FlipPoint( &xx->pos[2], orig, angle ); + FlipPoint( &xx->pos[3], orig, angle ); // Reverse control point order coOrd pos = xx->pos[0]; @@ -1083,65 +1179,73 @@ static void FlipBezier( pos = xx->pos[1]; xx->pos[1] = xx->pos[2]; xx->pos[2] = pos; - + FixUpBezier(xx->pos,xx,IsTrack(trk)); - ComputeBezierBoundingBox(trk,xx); + ComputeBezierBoundingBox(trk,xx); } static ANGLE_T GetAngleBezier( - track_p trk, - coOrd pos, - EPINX_T * ep0, - EPINX_T * ep1 ) + track_p trk, + coOrd pos, + EPINX_T * ep0, + EPINX_T * ep1 ) { - struct extraDataBezier_t * xx = GET_EXTRA_DATA(trk, T_NOTRACK, extraDataBezier_t); + struct extraDataBezier_t * xx = GET_EXTRA_DATA(trk, T_NOTRACK, + extraDataBezier_t); ANGLE_T angle; BOOL_T back, neg; int indx; - angle = GetAngleSegs( xx->arcSegs.cnt, (trkSeg_p)xx->arcSegs.ptr, &pos, &indx, NULL, &back, NULL, &neg ); - if (!back) angle = NormalizeAngle(angle+180); //Make CCW - if ( ep0 ) *ep0 = neg?1:0; - if ( ep1 ) *ep1 = neg?0:1; + angle = GetAngleSegs( xx->arcSegs.cnt, &DYNARR_N(trkSeg_t,xx->arcSegs,0), &pos, + &indx, NULL, &back, NULL, &neg ); + if (!back) { angle = NormalizeAngle(angle+180); } //Make CCW + if ( ep0 ) { *ep0 = neg?1:0; } + if ( ep1 ) { *ep1 = neg?0:1; } return angle; } -BOOL_T GetBezierSegmentFromTrack(track_p trk, trkSeg_p seg_p) { - struct extraDataBezier_t * xx = GET_EXTRA_DATA(trk, T_NOTRACK, extraDataBezier_t); +BOOL_T GetBezierSegmentFromTrack(track_p trk, trkSeg_p seg_p) +{ + struct extraDataBezier_t * xx = GET_EXTRA_DATA(trk, T_NOTRACK, + extraDataBezier_t); seg_p->type = IsTrack(trk)?SEG_BEZTRK:SEG_BEZLIN; - for (int i=0;i<4;i++) seg_p->u.b.pos[i] = xx->pos[i]; + for (int i=0; i<4; i++) { seg_p->u.b.pos[i] = xx->pos[i]; } seg_p->color = xx->segsColor; - seg_p->bezSegs.cnt = 0; - if (seg_p->bezSegs.ptr) MyFree(seg_p->bezSegs.ptr); - seg_p->bezSegs.max = 0; - seg_p->bezSegs.ptr = NULL; + seg_p->lineWidth = xx->segsLineWidth; + DYNARR_FREE( trkSeg_t, seg_p->bezSegs ); FixUpBezierSeg(seg_p->u.b.pos,seg_p,seg_p->type == SEG_BEZTRK); return TRUE; } -BOOL_T GetTracksFromBezierSegment(trkSeg_p bezSeg, track_p newTracks[2], track_p trk) { +BOOL_T GetTracksFromBezierSegment(trkSeg_p bezSeg, track_p newTracks[2], + track_p trk) +{ track_p trk_old = NULL; newTracks[0] = NULL, newTracks[1] = NULL; - if (bezSeg->type != SEG_BEZTRK) return FALSE; - for (int i=0;i<bezSeg->bezSegs.cnt;i++) { + if (bezSeg->type != SEG_BEZTRK) { return FALSE; } + for (int i=0; i<bezSeg->bezSegs.cnt; i++) { trkSeg_p seg = &DYNARR_N(trkSeg_t,bezSeg->bezSegs,i); track_p new_trk; - if (seg->type == SEG_CRVTRK) - new_trk = NewCurvedTrack(seg->u.c.center,fabs(seg->u.c.radius),seg->u.c.a0,seg->u.c.a1,0); - else if (seg->type == SEG_STRTRK) + if (seg->type == SEG_CRVTRK) { + new_trk = NewCurvedTrack(seg->u.c.center,fabs(seg->u.c.radius),seg->u.c.a0, + seg->u.c.a1,0); + } else if (seg->type == SEG_STRTRK) { new_trk = NewStraightTrack(seg->u.l.pos[0],seg->u.l.pos[1]); - if (newTracks[0] == NULL) newTracks[0] = new_trk; + } + if (newTracks[0] == NULL) { newTracks[0] = new_trk; } CopyAttributes( trk, new_trk ); newTracks[1] = new_trk; if (trk_old) { - for (int i=0;i<2;i++) { + for (int i=0; i<2; i++) { if (GetTrkEndTrk(trk_old,i)==NULL) { coOrd pos = GetTrkEndPos(trk_old,i); EPINX_T ep_n = PickUnconnectedEndPoint(pos,new_trk); - if ((connectDistance >= FindDistance(GetTrkEndPos(trk_old,i),GetTrkEndPos(new_trk,ep_n))) && - (connectAngle >= fabs(DifferenceBetweenAngles(GetTrkEndAngle(trk_old,i),GetTrkEndAngle(new_trk,ep_n)+180))) ) { + if ((connectDistance >= FindDistance(GetTrkEndPos(trk_old,i), + GetTrkEndPos(new_trk,ep_n))) && + (connectAngle >= fabs(DifferenceBetweenAngles(GetTrkEndAngle(trk_old,i), + GetTrkEndAngle(new_trk,ep_n)+180))) ) { ConnectTracks(trk_old,i,new_trk,ep_n); break; } @@ -1153,92 +1257,86 @@ BOOL_T GetTracksFromBezierSegment(trkSeg_p bezSeg, track_p newTracks[2], track_p return TRUE; } -BOOL_T GetTracksFromBezierTrack(track_p trk, track_p newTracks[2]) { +BOOL_T GetTracksFromBezierTrack(track_p trk, track_p newTracks[2]) +{ trkSeg_t seg_temp; + DYNARR_INIT( trkSeg_t, seg_temp.bezSegs ); newTracks[0] = NULL, newTracks[1] = NULL; - if (!IsTrack(trk)) return FALSE; - struct extraDataBezier_t * xx = GET_EXTRA_DATA(trk, T_BEZIER, extraDataBezier_t); + if (!IsTrack(trk)) { return FALSE; } + struct extraDataBezier_t * xx = GET_EXTRA_DATA(trk, T_BEZIER, + extraDataBezier_t); seg_temp.type = SEG_BEZTRK; - for (int i=0;i<4;i++) seg_temp.u.b.pos[i] = xx->pos[i]; + for (int i=0; i<4; i++) { seg_temp.u.b.pos[i] = xx->pos[i]; } seg_temp.color = xx->segsColor; - seg_temp.bezSegs.cnt = 0; - seg_temp.bezSegs.max = 0; - //if (seg_temp->bezSegs.ptr) MyFree(seg_temp->bezSegs.ptr); - DYNARR_RESET(trkSeg_t,seg_temp.bezSegs); FixUpBezierSeg(seg_temp.u.b.pos,&seg_temp,TRUE); GetTracksFromBezierSegment(&seg_temp, newTracks, trk); - MyFree(seg_temp.bezSegs.ptr); - seg_temp.bezSegs.cnt = 0; - seg_temp.bezSegs.max = 0; - seg_temp.bezSegs.ptr = NULL; + DYNARR_FREE( trkSeg_t, seg_temp.bezSegs ); return TRUE; } static BOOL_T MakeParallelBezier( - track_p trk, - coOrd pos, - DIST_T sep, - DIST_T factor, - track_p * newTrkR, - coOrd * p0R, - coOrd * p1R, - BOOL_T track) + track_p trk, + coOrd pos, + DIST_T sep, + DIST_T factor, + track_p * newTrkR, + coOrd * p0R, + coOrd * p1R, + BOOL_T track) { - struct extraDataBezier_t * xx = GET_EXTRA_DATA(trk, T_NOTRACK, extraDataBezier_t); - coOrd np[4], p; - ANGLE_T a0, a1,a2; + struct extraDataBezier_t * xx = GET_EXTRA_DATA(trk, T_NOTRACK, + extraDataBezier_t); + coOrd np[4], p; + ANGLE_T a0, a1,a2; //Produce bezier that is translated parallel to the existing Bezier - // - not a precise result if the bezier end angles are not in the same general direction. - // The expectation is that the user will have to adjust it - unless and until we produce - // a new algo to adjust the control points to be parallel to the endpoints. - - a0 = xx->a0; - a1 = xx->a1; - p = pos; - DistanceBezier(trk, &p); - a2 = NormalizeAngle(FindAngle(pos,p)-a0); - a2 = NormalizeAngle(FindAngle(pos,p)-a0); - //find parallel move x and y for points - for (int i =0; i<4;i++) { - np[i] = xx->pos[i]; - } - sep = sep+factor/xx->minCurveRadius; - // Adjust sep based on radius and factor - if ( a2 > 180 ) { - Translate(&np[0],np[0],a0+90,sep); - Translate(&np[1],np[1],a0+90,sep); - Translate(&np[2],np[2],a1-90,sep); - Translate(&np[3],np[3],a1-90,sep); - } else { - Translate(&np[0],np[0],a0-90,sep); - Translate(&np[1],np[1],a0-90,sep); - Translate(&np[2],np[2],a1+90,sep); - Translate(&np[3],np[3],a1+90,sep); - } + // - not a precise result if the bezier end angles are not in the same general direction. + // The expectation is that the user will have to adjust it - unless and until we produce + // a new algo to adjust the control points to be parallel to the endpoints. + + a0 = xx->a0; + a1 = xx->a1; + p = pos; + DistanceBezier(trk, &p); + a2 = NormalizeAngle(FindAngle(pos,p)-a0); + a2 = NormalizeAngle(FindAngle(pos,p)-a0); + //find parallel move x and y for points + for (int i =0; i<4; i++) { + np[i] = xx->pos[i]; + } + sep = sep+factor/xx->minCurveRadius; + // Adjust sep based on radius and factor + if ( a2 > 180 ) { + Translate(&np[0],np[0],a0+90,sep); + Translate(&np[1],np[1],a0+90,sep); + Translate(&np[2],np[2],a1-90,sep); + Translate(&np[3],np[3],a1-90,sep); + } else { + Translate(&np[0],np[0],a0-90,sep); + Translate(&np[1],np[1],a0-90,sep); + Translate(&np[2],np[2],a1+90,sep); + Translate(&np[3],np[3],a1+90,sep); + } if ( newTrkR ) { - if (track) + if (track) { *newTrkR = NewBezierTrack( np, NULL, 0); - else + } else { *newTrkR = NewBezierLine( np, NULL, 0, wDrawColorBlack, 0); + } } else { DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); tempSegs(0).color = wDrawColorBlack; - tempSegs(0).width = 0; - tempSegs_da.cnt = 1; + tempSegs(0).lineWidth = 0; tempSegs(0).type = track?SEG_BEZTRK:SEG_BEZLIN; - if (tempSegs(0).bezSegs.ptr) MyFree(tempSegs(0).bezSegs.ptr); - tempSegs(0).bezSegs.ptr = 0; - tempSegs(0).bezSegs.max = 0; - tempSegs(0).bezSegs.cnt = 0; - for (int i=0;i<4;i++) tempSegs(0).u.b.pos[i] = np[i]; + DYNARR_INIT( trkSeg_t, tempSegs(0).bezSegs ); + for (int i=0; i<4; i++) { tempSegs(0).u.b.pos[i] = np[i]; } FixUpBezierSeg(tempSegs(0).u.b.pos,&tempSegs(0),track); } - if ( p0R ) *p0R = np[0]; - if ( p1R ) *p1R = np[1]; + if ( p0R ) { *p0R = np[0]; } + if ( p1R ) { *p1R = np[1]; } return TRUE; } @@ -1251,17 +1349,18 @@ static BOOL_T MakeParallelBezier( */ BOOL_T RebuildBezier (track_p trk) { - ASSERT( trk != NULL && !IsTrackDeleted(trk) ); + CHECK( trk != NULL && !IsTrackDeleted(trk) ); struct extraDataBezier_t *xx; xx = GET_EXTRA_DATA(trk, T_NOTRACK, extraDataBezier_t); - xx->arcSegs.cnt = 0; + DYNARR_RESET( trkSeg_t, xx->arcSegs ); FixUpBezier(xx->pos,xx,IsTrack(trk)); ComputeBezierBoundingBox(trk, xx); return TRUE; } -BOOL_T MoveBezierEndPt ( track_p *trk, EPINX_T *ep, coOrd pos, DIST_T d0 ) { +BOOL_T MoveBezierEndPt ( track_p *trk, EPINX_T *ep, coOrd pos, DIST_T d0 ) +{ track_p trk2; struct extraDataBezier_t *xx; if (SplitTrack(*trk,pos,*ep,&trk2,TRUE)) { @@ -1280,8 +1379,10 @@ BOOL_T MoveBezierEndPt ( track_p *trk, EPINX_T *ep, coOrd pos, DIST_T d0 ) { static wBool_t CompareBezier( track_cp trk1, track_cp trk2 ) { - struct extraDataBezier_t *xx1 = GET_EXTRA_DATA( trk1, T_NOTRACK, extraDataBezier_t ); - struct extraDataBezier_t *xx2 = GET_EXTRA_DATA( trk2, T_NOTRACK, extraDataBezier_t ); + struct extraDataBezier_t *xx1 = GET_EXTRA_DATA( trk1, T_NOTRACK, + extraDataBezier_t ); + struct extraDataBezier_t *xx2 = GET_EXTRA_DATA( trk2, T_NOTRACK, + extraDataBezier_t ); char * cp = message + strlen(message); REGRESS_CHECK_POS( "Pos[0]", xx1, xx2, pos[0] ) REGRESS_CHECK_POS( "Pos[1]", xx1, xx2, pos[1] ) @@ -1293,93 +1394,93 @@ static wBool_t CompareBezier( track_cp trk1, track_cp trk2 ) // Check arcSegs REGRESS_CHECK_DIST( "Length", xx1, xx2, length ) REGRESS_CHECK_POS( "DescOff", xx1, xx2, descriptionOff ) - REGRESS_CHECK_WIDTH( "SegsWidth", xx1, xx2, segsWidth ) + REGRESS_CHECK_WIDTH( "SegsLineWidth", xx1, xx2, segsLineWidth ) REGRESS_CHECK_COLOR( "SegsColor", xx1, xx2, segsColor ) REGRESS_CHECK_INT( "LineType", xx1, xx2, lineType ) return TRUE; } static trackCmd_t bezlinCmds = { - "BZRLIN", - DrawBezier, - DistanceBezier, - DescribeBezier, - DeleteBezier, - WriteBezier, - ReadBezier, - MoveBezier, - RotateBezier, - RescaleBezier, - NULL, - GetAngleBezier, - SplitBezier, - NULL, - NULL, - NULL, /* redraw */ - NULL, /* trim */ - MergeBezier, - NULL, /* modify */ - GetLengthBezier, - GetParamsBezier, - NULL, /* Move EndPt */ - QueryBezier, - NULL, /* ungroup */ - FlipBezier, - NULL, - NULL, - NULL, - MakeParallelBezier, - NULL, - RebuildBezier, - NULL, - NULL, - NULL, - CompareBezier - }; + "BZRLIN", + DrawBezier, + DistanceBezier, + DescribeBezier, + DeleteBezier, + WriteBezier, + ReadBezier, + MoveBezier, + RotateBezier, + RescaleBezier, + NULL, + GetAngleBezier, + SplitBezier, + NULL, + NULL, + NULL, /* redraw */ + NULL, /* trim */ + MergeBezier, + NULL, /* modify */ + GetLengthBezier, + GetParamsBezier, + NULL, /* Move EndPt */ + QueryBezier, + NULL, /* ungroup */ + FlipBezier, + NULL, + NULL, + NULL, + MakeParallelBezier, + NULL, + RebuildBezier, + NULL, + NULL, + NULL, + CompareBezier +}; static trackCmd_t bezierCmds = { - "BEZIER", - DrawBezier, - DistanceBezier, - DescribeBezier, - DeleteBezier, - WriteBezier, - ReadBezier, - MoveBezier, - RotateBezier, - RescaleBezier, - NULL, - GetAngleBezier, - SplitBezier, - TraverseBezier, - EnumerateBezier, - NULL, /* redraw */ - TrimBezier, /* trim */ - MergeBezier, - NULL, /* modify */ - GetLengthBezier, - GetParamsBezier, - MoveBezierEndPt, /* Move EndPt */ - QueryBezier, - NULL, /* ungroup */ - FlipBezier, - NULL, - NULL, - NULL, - MakeParallelBezier, - NULL, - RebuildBezier, - NULL, - NULL, - NULL, - CompareBezier - }; + "BEZIER", + DrawBezier, + DistanceBezier, + DescribeBezier, + DeleteBezier, + WriteBezier, + ReadBezier, + MoveBezier, + RotateBezier, + RescaleBezier, + NULL, + GetAngleBezier, + SplitBezier, + TraverseBezier, + EnumerateBezier, + NULL, /* redraw */ + TrimBezier, /* trim */ + MergeBezier, + NULL, /* modify */ + GetLengthBezier, + GetParamsBezier, + MoveBezierEndPt, /* Move EndPt */ + QueryBezier, + NULL, /* ungroup */ + FlipBezier, + NULL, + NULL, + NULL, + MakeParallelBezier, + NULL, + RebuildBezier, + NULL, + NULL, + NULL, + CompareBezier +}; EXPORT void BezierSegProc( - segProc_e cmd, - trkSeg_p segPtr, - segProcData_p data ) + segProc_e cmd, + trkSeg_p segPtr, + segProcData_p data ) { ANGLE_T a1, a2; DIST_T d, dd; @@ -1391,7 +1492,7 @@ EXPORT void BezierSegProc( BOOL_T back, segs_backwards, neg; #define bezSegs(N) DYNARR_N( trkSeg_t, segPtr->bezSegs, N ) - switch (cmd) { + switch (cmd) { case SEGPROC_TRAVERSE1: //Work out how much extra dist and what direction if (segPtr->type != SEG_BEZTRK) { @@ -1400,8 +1501,10 @@ EXPORT void BezierSegProc( } d = data->traverse1.dist; p0 = data->traverse1.pos; -LOG( log_bezierSegments, 1, ( " BezTr1-Enter P[%0.3f %0.3f] A%0.3f\n", p0.x, p0.y, data->traverse1.angle )) - a2 = GetAngleSegs(segPtr->bezSegs.cnt,segPtr->bezSegs.ptr,&p0,&segInx,&d,&back, NULL, &neg); //Find right seg and pos + LOG( log_bezierSegments, 1, ( " BezTr1-Enter P[%0.3f %0.3f] A%0.3f\n", p0.x, + p0.y, data->traverse1.angle )) + a2 = GetAngleSegs(segPtr->bezSegs.cnt,&DYNARR_N(trkSeg_t,segPtr->bezSegs,0),&p0, + &segInx,&d,&back, NULL, &neg); //Find right seg and pos inx = segInx; data->traverse1.BezSegInx = segInx; data->traverse1.reverse_seg = FALSE; @@ -1411,33 +1514,44 @@ LOG( log_bezierSegments, 1, ( " BezTr1-Enter P[%0.3f %0.3f] A%0.3f\n", p0.x, return; } - if (back) a2 = NormalizeAngle(a2+180); - a1 = NormalizeAngle(a2-data->traverse1.angle); //Establish if we are going fwds or backwards globally - if (a1<270 && a1>90) { //Must add 180 if the seg is reversed or inverted (but not both) + if (back) { a2 = NormalizeAngle(a2+180); } + a1 = NormalizeAngle(a2 + -data->traverse1.angle); //Establish if we are going fwds or backwards globally + if (a1<270 + && a1>90) { //Must add 180 if the seg is reversed or inverted (but not both) segs_backwards = TRUE; - } else { + } else { segs_backwards = FALSE; - } + } if ( neg ) { segs_backwards = !segs_backwards; //neg implies all the segs are reversed } - segProcData.traverse1.pos = data->traverse1.pos = p0; //actual point on curve - segProcData.traverse1.angle = data->traverse1.angle; //Angle of car - LOG( log_bezierSegments, 1, ( " BezTr1-GSA I%d P[%0.3f %0.3f] N%d SB%d\n", segInx, p0.x, p0.y, neg, segs_backwards )) - subSegsPtr = (trkSeg_p)segPtr->bezSegs.ptr+inx; + segProcData.traverse1.pos = data->traverse1.pos = p0; //actual point on curve + segProcData.traverse1.angle = data->traverse1.angle; //Angle of car + LOG( log_bezierSegments, 1, ( " BezTr1-GSA I%d P[%0.3f %0.3f] N%d SB%d\n", + segInx, p0.x, p0.y, neg, segs_backwards )) + subSegsPtr = &DYNARR_N(trkSeg_t,segPtr->bezSegs,inx); SegProc( SEGPROC_TRAVERSE1, subSegsPtr, &segProcData ); - data->traverse1.reverse_seg = segProcData.traverse1.reverse_seg; //which way is curve (info) - data->traverse1.backwards = segProcData.traverse1.backwards; //Pass through Train direction - data->traverse1.dist = segProcData.traverse1.dist; //Get last seg partial dist + data->traverse1.reverse_seg = + segProcData.traverse1.reverse_seg; //which way is curve (info) + data->traverse1.backwards = + segProcData.traverse1.backwards; //Pass through Train direction + data->traverse1.dist = + segProcData.traverse1.dist; //Get last seg partial dist data->traverse1.segs_backwards = segs_backwards; //Get last - data->traverse1.negative = segProcData.traverse1.negative; //Is curve flipped (info) + data->traverse1.negative = + segProcData.traverse1.negative; //Is curve flipped (info) data->traverse1.BezSegInx = inx; //Copy up Index -LOG( log_bezierSegments, 1, ( " BezTr1-Exit -> A%0.3f B%d R%d N%d D%0.3f\n", a2, segProcData.traverse1.backwards, segProcData.traverse1.reverse_seg, segProcData.traverse1.negative, segProcData.traverse1.dist )) + LOG( log_bezierSegments, 1, ( " BezTr1-Exit -> A%0.3f B%d R%d N%d D%0.3f\n", + a2, segProcData.traverse1.backwards, segProcData.traverse1.reverse_seg, + segProcData.traverse1.negative, segProcData.traverse1.dist )) break; case SEGPROC_TRAVERSE2: - if (segPtr->type != SEG_BEZTRK) return; //Not SEG_BEZLIN -LOG( log_bezierSegments, 1, ( " BezTr2-Enter D%0.3f SD%d SI%d SB%d\n", data->traverse2.dist, data->traverse2.segDir, data->traverse2.BezSegInx, data->traverse2.segs_backwards)) + if (segPtr->type != SEG_BEZTRK) { return; } //Not SEG_BEZLIN + LOG( log_bezierSegments, 1, ( " BezTr2-Enter D%0.3f SD%d SI%d SB%d\n", + data->traverse2.dist, data->traverse2.segDir, data->traverse2.BezSegInx, + data->traverse2.segs_backwards)) segProcData.traverse2.pos = data->traverse2.pos; DIST_T dist = data->traverse2.dist; segProcData.traverse2.dist = data->traverse2.dist; @@ -1447,24 +1561,26 @@ LOG( log_bezierSegments, 1, ( " BezTr2-Enter D%0.3f SD%d SI%d SB%d\n", data-> BOOL_T backwards = data->traverse2.segDir; inx = data->traverse2.BezSegInx; //Special from Traverse1 while (inx>=0 && inx<segPtr->bezSegs.cnt) { - subSegsPtr = (trkSeg_p)segPtr->bezSegs.ptr+inx; + subSegsPtr = &DYNARR_N(trkSeg_t,segPtr->bezSegs,inx); SegProc(SEGPROC_TRAVERSE2, subSegsPtr, &segProcData); if (segProcData.traverse2.dist<=0) { //Done data->traverse2.angle = segProcData.traverse2.angle; data->traverse2.dist = 0; data->traverse2.pos = segProcData.traverse2.pos; -LOG( log_bezierSegments, 1, ( " BezTr2-Exit1 -> A%0.3f P[%0.3f %0.3f] \n", data->traverse2.angle, data->traverse2.pos.x, data->traverse2.pos.y )) + LOG( log_bezierSegments, 1, ( " BezTr2-Exit1 -> A%0.3f P[%0.3f %0.3f] \n", + data->traverse2.angle, data->traverse2.pos.x, data->traverse2.pos.y )) return; - } else dist = segProcData.traverse2.dist; + } else { dist = segProcData.traverse2.dist; } p2 = segProcData.traverse2.pos; a2 = segProcData.traverse2.angle; -LOG( log_bezierSegments, 2, ( " BezTr2-Tr2 D%0.3f P[%0.3f %0.3f] A%0.3f\n", dist, p2.x, p2.y, a2 )) + LOG( log_bezierSegments, 2, ( " BezTr2-Tr2 D%0.3f P[%0.3f %0.3f] A%0.3f\n", + dist, p2.x, p2.y, a2 )) segProcData.traverse1.pos = p2; segProcData.traverse1.angle = a2 ; inx = segs_backwards?inx-1:inx+1; - if (inx<0 || inx>=segPtr->bezSegs.cnt) break; - subSegsPtr = (trkSeg_p)segPtr->bezSegs.ptr+inx; + if (inx<0 || inx>=segPtr->bezSegs.cnt) { break; } + subSegsPtr = &DYNARR_N(trkSeg_t,segPtr->bezSegs,inx); SegProc(SEGPROC_TRAVERSE1, subSegsPtr, &segProcData); BOOL_T reverse_seg = segProcData.traverse1.reverse_seg; //For Info only backwards = segProcData.traverse1.backwards; @@ -1474,21 +1590,26 @@ LOG( log_bezierSegments, 2, ( " BezTr2-Tr2 D%0.3f P[%0.3f %0.3f] A%0.3f\n", d segProcData.traverse2.segDir = backwards; //which way segProcData.traverse2.pos = p2; segProcData.traverse2.angle = NormalizeAngle(a2 + neg_seg?180:0); -LOG( log_bezierSegments, 2, ( " BezTr2-Loop A%0.3f P[%0.3f %0.3f] D%0.3f SI%d B%d RS%d\n", a2, p2.x, p2.y, dist, inx, backwards, reverse_seg )) + LOG( log_bezierSegments, 2, + ( " BezTr2-Loop A%0.3f P[%0.3f %0.3f] D%0.3f SI%d B%d RS%d\n", a2, p2.x, + p2.y, dist, inx, backwards, reverse_seg )) } data->traverse2.dist = dist; - if (segs_backwards) { - data->traverse2.pos = segPtr->u.b.pos[0]; // Backwards so point 0 - data->traverse2.angle = segPtr->u.b.angle0; - } else { - data->traverse2.pos = segPtr->u.b.pos[3]; // Forwards so point 3 - data->traverse2.angle = segPtr->u.b.angle3; - } -LOG( log_bezierSegments, 1, ( " BezTr-Exit2 --> SI%d A%0.3f P[%0.3f %0.3f] D%0.3f\n", inx, data->traverse2.angle, data->traverse2.pos.x, data->traverse2.pos.y, data->traverse2.dist)) + if (segs_backwards) { + data->traverse2.pos = segPtr->u.b.pos[0]; // Backwards so point 0 + data->traverse2.angle = segPtr->u.b.angle0; + } else { + data->traverse2.pos = segPtr->u.b.pos[3]; // Forwards so point 3 + data->traverse2.angle = segPtr->u.b.angle3; + } + LOG( log_bezierSegments, 1, + ( " BezTr-Exit2 --> SI%d A%0.3f P[%0.3f %0.3f] D%0.3f\n", inx, + data->traverse2.angle, data->traverse2.pos.x, data->traverse2.pos.y, + data->traverse2.dist)) break; case SEGPROC_DRAWROADBEDSIDE: - //TODO - needs parallel bezier problem solved... + //TODO - needs parallel bezier problem solved... break; case SEGPROC_DISTANCE: @@ -1496,9 +1617,9 @@ LOG( log_bezierSegments, 1, ( " BezTr-Exit2 --> SI%d A%0.3f P[%0.3f %0.3f] D% dd = DIST_INF; //Just find one distance p0 = data->distance.pos1; - //initialize p2 + //initialize p2 p2 = segPtr->u.b.pos[0]; - for(int i=0;i<segPtr->bezSegs.cnt;i++) { + for(int i=0; i<segPtr->bezSegs.cnt; i++) { segProcData.distance.pos1 = p0; SegProc(SEGPROC_DISTANCE,&(DYNARR_N(trkSeg_t,segPtr->bezSegs,i)),&segProcData); d = segProcData.distance.dd; @@ -1513,9 +1634,9 @@ LOG( log_bezierSegments, 1, ( " BezTr-Exit2 --> SI%d A%0.3f P[%0.3f %0.3f] D% case SEGPROC_FLIP: - temp0 = segPtr->u.b.pos[0]; - temp1 = segPtr->u.b.pos[1]; - temp2 = segPtr->u.b.pos[2]; + temp0 = segPtr->u.b.pos[0]; + temp1 = segPtr->u.b.pos[1]; + temp2 = segPtr->u.b.pos[2]; temp3 = segPtr->u.b.pos[3]; segPtr->u.b.pos[0] = temp3; segPtr->u.b.pos[1] = temp2; @@ -1525,45 +1646,47 @@ LOG( log_bezierSegments, 1, ( " BezTr-Exit2 --> SI%d A%0.3f P[%0.3f %0.3f] D% break; case SEGPROC_NEWTRACK: - data->newTrack.trk = NewBezierTrack( segPtr->u.b.pos, (trkSeg_t *)segPtr->bezSegs.ptr, segPtr->bezSegs.cnt); + data->newTrack.trk = NewBezierTrack( segPtr->u.b.pos, + &DYNARR_N(trkSeg_t,segPtr->bezSegs,0), segPtr->bezSegs.cnt); data->newTrack.ep[0] = 0; data->newTrack.ep[1] = 1; break; case SEGPROC_LENGTH: data->length.length = 0; - for(int i=0;i<segPtr->bezSegs.cnt;i++) { + for(int i=0; i<segPtr->bezSegs.cnt; i++) { SegProc(cmd,&(DYNARR_N(trkSeg_t,segPtr->bezSegs,i)),&segProcData); data->length.length += segProcData.length.length; } break; case SEGPROC_SPLIT: ; - wIndex_t subinx; +// wIndex_t subinx; double t; - double dd; +// double dd; coOrd split_p = data->split.pos; - ANGLE_T angle = GetAngleSegs(segPtr->bezSegs.cnt,(trkSeg_p)segPtr->bezSegs.ptr, &split_p, &inx, &dd, &back, &subinx, NULL); - coOrd current[4]; +// ANGLE_T angle = GetAngleSegs(segPtr->bezSegs.cnt,&DYNARR_N(trkSeg_t,segPtr->bezSegs,0), &split_p, &inx, &dd, &back, &subinx, NULL); +// coOrd current[4]; BezierMathDistance(&split_p, segPtr->u.b.pos, 500, &t); //Find t value - for (int i=0;i<4;i++) { - current[i] = segPtr->u.b.pos[i]; +// for (int i=0;i<4;i++) { +// current[i] = segPtr->u.b.pos[i]; - } - for (int i=0;i<2;i++) { +// } + for (int i=0; i<2; i++) { data->split.newSeg[i].type = segPtr->type; data->split.newSeg[i].color = segPtr->color; - data->split.newSeg[i].width = segPtr->width; - data->split.newSeg[i].bezSegs.ptr = NULL; - data->split.newSeg[i].bezSegs.cnt = 0; - data->split.newSeg[i].bezSegs.max = 0; + data->split.newSeg[i].lineWidth = segPtr->lineWidth; + DYNARR_INIT( trkSeg_t, data->split.newSeg[i].bezSegs ); } - BezierSplit(segPtr->u.b.pos, data->split.newSeg[0].u.b.pos, data->split.newSeg[1].u.b.pos, t); + BezierSplit(segPtr->u.b.pos, data->split.newSeg[0].u.b.pos, + data->split.newSeg[1].u.b.pos, t); - FixUpBezierSeg(data->split.newSeg[0].u.b.pos,&data->split.newSeg[0],segPtr->type == SEG_BEZTRK); - FixUpBezierSeg(data->split.newSeg[1].u.b.pos,&data->split.newSeg[1],segPtr->type == SEG_BEZTRK); + FixUpBezierSeg(data->split.newSeg[0].u.b.pos,&data->split.newSeg[0], + segPtr->type == SEG_BEZTRK); + FixUpBezierSeg(data->split.newSeg[1].u.b.pos,&data->split.newSeg[1], + segPtr->type == SEG_BEZTRK); data->split.length[0] = data->split.newSeg[0].u.b.length; data->split.length[1] = data->split.newSeg[1].u.b.length; @@ -1575,11 +1698,12 @@ LOG( log_bezierSegments, 1, ( " BezTr-Exit2 --> SI%d A%0.3f P[%0.3f %0.3f] D% case SEGPROC_GETANGLE: inx = 0; back = FALSE; - subSegsPtr = (trkSeg_p) segPtr->bezSegs.ptr; + subSegsPtr = &DYNARR_N(trkSeg_t,segPtr->bezSegs,0); coOrd pos = data->getAngle.pos; -LOG( log_bezierSegments, 1, ( " BezGA-In P[%0.3f %0.3f] \n", pos.x, pos.y)) - data->getAngle.angle = GetAngleSegs(segPtr->bezSegs.cnt,subSegsPtr, &pos, &inx, NULL, &back, NULL, NULL); - //Recurse for Bezier sub-segs (only straights and curves) + LOG( log_bezierSegments, 1, ( " BezGA-In P[%0.3f %0.3f] \n", pos.x, pos.y)) + data->getAngle.angle = GetAngleSegs(segPtr->bezSegs.cnt,subSegsPtr, &pos, &inx, + NULL, &back, NULL, NULL); + //Recurse for Bezier sub-segs (only straights and curves) data->getAngle.negative_radius = FALSE; data->getAngle.backwards = back; @@ -1588,13 +1712,13 @@ LOG( log_bezierSegments, 1, ( " BezGA-In P[%0.3f %0.3f] \n", pos.x, pos.y)) subSegsPtr +=inx; if (subSegsPtr->type == SEG_CRVTRK || subSegsPtr->type == SEG_CRVLIN ) { data->getAngle.radius = fabs(subSegsPtr->u.c.radius); - if (subSegsPtr->u.c.radius<0 ) data->getAngle.negative_radius = TRUE; + if (subSegsPtr->u.c.radius<0 ) { data->getAngle.negative_radius = TRUE; } data->getAngle.center = subSegsPtr->u.c.center; - } - else data->getAngle.radius = 0.0; -LOG( log_bezierSegments, 1, ( " BezGA-Out SI%d A%0.3f P[%0.3f %0.3f] B%d\n", inx, data->getAngle.angle, pos.x, pos.y, back)) + } else { data->getAngle.radius = 0.0; } + LOG( log_bezierSegments, 1, ( " BezGA-Out SI%d A%0.3f P[%0.3f %0.3f] B%d\n", + inx, data->getAngle.angle, pos.x, pos.y, back)) break; - + } } @@ -1607,7 +1731,8 @@ LOG( log_bezierSegments, 1, ( " BezGA-Out SI%d A%0.3f P[%0.3f %0.3f] B%d\n", */ -EXPORT void SetBezierData( track_p p, coOrd pos[4], wDrawColor color, DIST_T width ) +EXPORT void SetBezierData( track_p p, coOrd pos[4], wDrawColor color, + LWIDTH_T lineWidth ) { BOOL_T bTrack = (GetTrkType(p) == T_BEZIER); struct extraDataBezier_t *xx = GET_EXTRA_DATA(p, T_NOTRACK, extraDataBezier_t); @@ -1618,15 +1743,12 @@ EXPORT void SetBezierData( track_p p, coOrd pos[4], wDrawColor color, DIST_T wid xx->a0 = FindAngle(pos[1],pos[0]); xx->a1 = FindAngle(pos[2],pos[3]); xx->segsColor = color; - xx->segsWidth = width; + xx->segsLineWidth = lineWidth; FixUpBezier(pos, xx, bTrack); ComputeBezierBoundingBox( p, xx ); if ( bTrack ) { - // Should call SetTrkEndPoint but we may be already connected - p->endPt[0].pos = pos[0]; - p->endPt[0].angle = xx->a0; - p->endPt[1].pos = pos[3]; - p->endPt[1].angle = xx->a1; + SetTrkEndPointSilent( p, 0, pos[0], xx->a0 ); + SetTrkEndPointSilent( p, 1, pos[3], xx->a1 ); CheckTrackLength( p ); SetTrkBits( p, TB_HIDEDESC ); } @@ -1638,17 +1760,25 @@ track_p NewBezierTrack(coOrd pos[4], trkSeg_t * tempsegs, int count) track_p p; p = NewTrack( 0, T_BEZIER, 2, sizeof *(extraDataBezier_t*)NULL ); SetBezierData( p, pos, wDrawColorBlack, 0 ); -LOG( log_bezier, 1, ( "NewBezierTrack( EP1 %0.3f, %0.3f, CP1 %0.3f, %0.3f, CP2 %0.3f, %0.3f, EP2 %0.3f, %0.3f ) = %d\n", pos[0].x, pos[0].y, pos[1].x, pos[1].y, pos[2].x, pos[2].y, pos[3].x, pos[3].y, GetTrkIndex(p) ) ) + LOG( log_bezier, 1, + ( "NewBezierTrack( EP1 %0.3f, %0.3f, CP1 %0.3f, %0.3f, CP2 %0.3f, %0.3f, EP2 %0.3f, %0.3f ) = %d\n", + pos[0].x, pos[0].y, pos[1].x, pos[1].y, pos[2].x, pos[2].y, pos[3].x, pos[3].y, + GetTrkIndex(p) ) ) return p; } -EXPORT track_p NewBezierLine( coOrd pos[4], trkSeg_t * tempsegs, int count, wDrawColor color, DIST_T width ) +EXPORT track_p NewBezierLine( coOrd pos[4], trkSeg_t * tempsegs, int count, + wDrawColor color, LWIDTH_T lineWidth ) { track_p p; - p = NewTrack( 0, T_BZRLIN, 0, sizeof *(extraDataBezier_t*)NULL ); //No endpoints - SetBezierData( p, pos, color, width ); -LOG( log_bezier, 1, ( "NewBezierLine( EP1 %0.3f, %0.3f, CP1 %0.3f, %0.3f, CP2 %0.3f, %0.3f, EP2 %0.3f, %0.3f) = %d\n", pos[0].x, pos[0].y, pos[1].x, pos[1].y, pos[2].x, pos[2].y, pos[3].x, pos[3].y, GetTrkIndex(p) ) ) + p = NewTrack( 0, T_BZRLIN, 0, + sizeof *(extraDataBezier_t*)NULL ); //No endpoints + SetBezierData( p, pos, color, lineWidth ); + LOG( log_bezier, 1, + ( "NewBezierLine( EP1 %0.3f, %0.3f, CP1 %0.3f, %0.3f, CP2 %0.3f, %0.3f, EP2 %0.3f, %0.3f) = %d\n", + pos[0].x, pos[0].y, pos[1].x, pos[1].y, pos[2].x, pos[2].y, pos[3].x, pos[3].y, + GetTrkIndex(p) ) ) return p; } @@ -1673,102 +1803,107 @@ EXPORT void InitTrkBezier( void ) /** * Return point on Bezier using "t" (from 0 to 1) */ -extern coOrd BezierPointByParameter(coOrd p[4], double t) +static coOrd BezierPointByParameter(coOrd p[4], double t) { - double a,b,c,d; - double mt = 1-t; - double mt2 = mt*mt; - double t2 = t*t; + double a,b,c,d; + double mt = 1-t; + double mt2 = mt*mt; + double t2 = t*t; - a = mt2*mt; - b = mt2*t*3; - c = mt*t2*3; - d = t*t2; + a = mt2*mt; + b = mt2*t*3; + c = mt*t2*3; + d = t*t2; - coOrd o; - o.x = a*p[0].x+b*p[1].x+c*p[2].x+d*p[3].x; - o.y = a*p[0].y+b*p[1].y+c*p[2].y+d*p[3].y; + coOrd o; + o.x = a*p[0].x+b*p[1].x+c*p[2].x+d*p[3].x; + o.y = a*p[0].y+b*p[1].y+c*p[2].y+d*p[3].y; - return o; + return o; } /** * Find distance from point to Bezier. Return also the "t" value of that closest point. */ -extern DIST_T BezierMathDistance( coOrd * pos, coOrd p[4], int segments, double * t_value) +static DIST_T BezierMathDistance( coOrd * pos, coOrd p[4], int segments, + double * t_value) { - DIST_T dd = DIST_INF; - double t = 0.0; - coOrd pt; - coOrd save_pt = p[0]; - for (int i=0; i<=segments; i++) { - pt = BezierPointByParameter(p, (double)i/segments); - if (FindDistance(*pos,pt) < dd) { - dd = FindDistance(*pos,pt); - t = (double)i/segments; - save_pt = pt; - } - } - if (t_value) *t_value = t; - * pos = save_pt; - return dd; + DIST_T dd = DIST_INF; + double t = 0.0; + coOrd pt; + coOrd save_pt = p[0]; + for (int i=0; i<=segments; i++) { + pt = BezierPointByParameter(p, (double)i/segments); + if (FindDistance(*pos,pt) < dd) { + dd = FindDistance(*pos,pt); + t = (double)i/segments; + save_pt = pt; + } + } + if (t_value) { *t_value = t; } + * pos = save_pt; + return dd; } -extern coOrd BezierMathFindNearestPoint(coOrd *pos, coOrd p[4], int segments) { - double t = 0.0; - BezierMathDistance(pos, p, segments, &t); - return BezierPointByParameter(p, t); +static coOrd BezierMathFindNearestPoint(coOrd *pos, coOrd p[4], int segments) +{ + double t = 0.0; + BezierMathDistance(pos, p, segments, &t); + return BezierPointByParameter(p, t); } -void BezierSlice(coOrd input[], coOrd output[], double t) { +void BezierSlice(coOrd input[], coOrd output[], double t) +{ coOrd p1,p12,p2,p23,p3,p34,p4; coOrd p123, p234, p1234; - p1 = input[0]; - p2 = input[1]; - p3 = input[2]; - p4 = input[3]; + p1 = input[0]; + p2 = input[1]; + p3 = input[2]; + p4 = input[3]; - p12.x = (p2.x-p1.x)*t+p1.x; - p12.y = (p2.y-p1.y)*t+p1.y; + p12.x = (p2.x-p1.x)*t+p1.x; + p12.y = (p2.y-p1.y)*t+p1.y; - p23.x = (p3.x-p2.x)*t+p2.x; - p23.y = (p3.y-p2.y)*t+p2.y; + p23.x = (p3.x-p2.x)*t+p2.x; + p23.y = (p3.y-p2.y)*t+p2.y; - p34.x = (p4.x-p3.x)*t+p3.x; - p34.y = (p4.y-p3.y)*t+p3.y; + p34.x = (p4.x-p3.x)*t+p3.x; + p34.y = (p4.y-p3.y)*t+p3.y; - p123.x = (p23.x-p12.x)*t+p12.x; - p123.y = (p23.y-p12.y)*t+p12.y; + p123.x = (p23.x-p12.x)*t+p12.x; + p123.y = (p23.y-p12.y)*t+p12.y; - p234.x = (p34.x-p23.x)*t+p23.x; - p234.y = (p34.y-p23.y)*t+p23.y; + p234.x = (p34.x-p23.x)*t+p23.x; + p234.y = (p34.y-p23.y)*t+p23.y; - p1234.x = (p234.x-p123.x)*t+p123.x; - p1234.y = (p234.y-p123.y)*t+p123.y; + p1234.x = (p234.x-p123.x)*t+p123.x; + p1234.y = (p234.y-p123.y)*t+p123.y; - output[0]= p1; - output[1] = p12; - output[2] = p123; - output[3] = p1234; + output[0]= p1; + output[1] = p12; + output[2] = p123; + output[3] = p1234; }; /** * Split bezier into two parts */ -extern void BezierSplit(coOrd input[], coOrd left[], coOrd right[] , double t) { +static void BezierSplit(coOrd input[4], coOrd left[4], coOrd right[4], + double t) +{ BezierSlice(input,left,t); coOrd back[4],backright[4]; - for (int i = 0;i<4;i++) { + for (int i = 0; i<4; i++) { back[i] = input[3-i]; } BezierSlice(back,backright,1-t); - for (int i = 0;i<4;i++) { + for (int i = 0; i<4; i++) { right[i] = backright[3-i]; } @@ -1779,23 +1914,26 @@ extern void BezierSplit(coOrd input[], coOrd left[], coOrd right[] , double t) { * If close enough (length of control polygon exceeds chord by < error) add length of polygon. * Else split and recurse */ -double BezierAddLengthIfClose(coOrd start[4], double error) { - coOrd left[4], right[4]; /* bez poly splits */ - double len = 0.0; /* arc length */ - double chord; /* chord length */ - int index; /* misc counter */ - - for (index = 0; index <= 2; index++) - len = len + FindDistance(start[index],start[index+1]); //add up control polygon +double BezierAddLengthIfClose(coOrd start[4], double error) +{ + coOrd left[4], right[4]; /* bez poly splits */ + double len = 0.0; /* arc length */ + double chord; /* chord length */ + int index; /* misc counter */ + + for (index = 0; index <= 2; index++) { + len = len + FindDistance(start[index], + start[index+1]); //add up control polygon + } - chord = FindDistance(start[0],start[3]); //find chord length + chord = FindDistance(start[0],start[3]); //find chord length - if((len-chord) > error) { // If error too large - - BezierSplit(start,left,right,0.5); /* split in two */ - len = BezierAddLengthIfClose(left, error); /* recurse left side */ - len += BezierAddLengthIfClose(right, error); /* recurse right side */ - } - return len; // Add length of this curve + if((len-chord) > error) { // If error too large - + BezierSplit(start,left,right,0.5); /* split in two */ + len = BezierAddLengthIfClose(left, error); /* recurse left side */ + len += BezierAddLengthIfClose(right, error); /* recurse right side */ + } + return len; // Add length of this curve } @@ -1803,30 +1941,30 @@ double BezierAddLengthIfClose(coOrd start[4], double error) { * Use recursive splitting to get close approximation ot length of bezier * */ -extern double BezierMathLength(coOrd p[4], double error) +static double BezierMathLength(coOrd p[4], double error) { - if (error == 0.0) error = 0.01; - return BezierAddLengthIfClose(p, error); /* kick off recursion */ + if (error == 0.0) { error = 0.01; } + return BezierAddLengthIfClose(p, error); /* kick off recursion */ } coOrd BezierFirstDerivative(coOrd p[4], double t) { - //checkParameterT(t); + //checkParameterT(t); - double tSquared = t * t; - double s0 = -3 + 6 * t - 3 * tSquared; - double s1 = 3 - 12 * t + 9 * tSquared; - double s2 = 6 * t - 9 * tSquared; - double s3 = 3 * tSquared; - double resultX = p[0].x * s0 + p[1].x * s1 + p[2].x * s2 + p[3].x * s3; - double resultY = p[0].y * s0 + p[1].y * s1 + p[2].y * s2 + p[3].y * s3; + double tSquared = t * t; + double s0 = -3 + 6 * t - 3 * tSquared; + double s1 = 3 - 12 * t + 9 * tSquared; + double s2 = 6 * t - 9 * tSquared; + double s3 = 3 * tSquared; + double resultX = p[0].x * s0 + p[1].x * s1 + p[2].x * s2 + p[3].x * s3; + double resultY = p[0].y * s0 + p[1].y * s1 + p[2].y * s2 + p[3].y * s3; - coOrd v; + coOrd v; - v.x = resultX; - v.y = resultY; - return v; + v.x = resultX; + v.y = resultY; + return v; } /** @@ -1835,61 +1973,63 @@ coOrd BezierFirstDerivative(coOrd p[4], double t) */ coOrd BezierSecondDerivative(coOrd p[4], double t) { - //checkParameterT(t); - - double s0 = 6 - 6 * t; - double s1 = -12 + 18 * t; - double s2 = 6 - 18 * t; - double s3 = 6 * t; - double resultX = p[0].x * s0 + p[1].x * s1 + p[2].x * s2 + p[3].x * s3; - double resultY = p[0].y * s0 + p[1].y * s1 + p[2].y * s2 + p[3].y * s3; - - coOrd v; - v.x = resultX; - v.y = resultY; - return v; + //checkParameterT(t); + + double s0 = 6 - 6 * t; + double s1 = -12 + 18 * t; + double s2 = 6 - 18 * t; + double s3 = 6 * t; + double resultX = p[0].x * s0 + p[1].x * s1 + p[2].x * s2 + p[3].x * s3; + double resultY = p[0].y * s0 + p[1].y * s1 + p[2].y * s2 + p[3].y * s3; + + coOrd v; + v.x = resultX; + v.y = resultY; + return v; } /** * Get curvature of a Bezier at a point */ -extern double BezierCurvature(coOrd p[4], double t, coOrd * center) +static double BezierCurvature(coOrd p[4], double t, coOrd * center) { - //checkParameterT(t); + //checkParameterT(t); - coOrd d1 = BezierFirstDerivative(p, t); - coOrd d2 = BezierSecondDerivative(p, t); + coOrd d1 = BezierFirstDerivative(p, t); + coOrd d2 = BezierSecondDerivative(p, t); - if (center) { - double curvnorm = (d1.x * d1.x + d1.y* d1.y)/(d1.x * d2.y - d2.x * d1.y); - coOrd p = BezierPointByParameter(&p, t); - center->x = p.x-d1.y*curvnorm; - center->y = p.y+d1.x*curvnorm; - } + if (center) { + double curvnorm = (d1.x * d1.x + d1.y* d1.y)/(d1.x * d2.y - d2.x * d1.y); + coOrd p1 = BezierPointByParameter(p, t); + center->x = p1.x-d1.y*curvnorm; + center->y = p1.y+d1.x*curvnorm; + } - double r1 = sqrt(pow(d1.x * d1.x + d1.y* d1.y, 3.0)); - double r2 = fabs(d1.x * d2.y - d2.x * d1.y); - return r2 / r1; + double r1 = sqrt(pow(d1.x * d1.x + d1.y* d1.y, 3.0)); + double r2 = fabs(d1.x * d2.y - d2.x * d1.y); + return r2 / r1; } /** * Get Maximum Curvature */ -extern double BezierMaxCurve(coOrd p[4]) { - double max = 0; - for (int t = 0;t<100;t++) { - double curv = BezierCurvature(p, t/100, NULL); - if (max<curv) max = curv; - } - return max; +static double BezierMaxCurve(coOrd p[4]) +{ + double max = 0; + for (int t = 0; t<100; t++) { + double curv = BezierCurvature(p, t/100, NULL); + if (max<curv) { max = curv; } + } + return max; } /** * Get Minimum Radius */ -extern double BezierMathMinRadius(coOrd p[4]) { - double curv = BezierMaxCurve(p); - if (curv >= 1000.0 || curv <= 0.001 ) return 0.0; - return 1/curv; +static double BezierMathMinRadius(coOrd p[4]) +{ + double curv = BezierMaxCurve(p); + if (curv >= 1000.0 || curv <= 0.001 ) { return 0.0; } + return 1/curv; } diff --git a/app/bin/tbezier.h b/app/bin/tbezier.h index 5699eca..e2f28c5 100644 --- a/app/bin/tbezier.h +++ b/app/bin/tbezier.h @@ -17,48 +17,44 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "common.h" #include "track.h" //- drawLineType typedef struct extraDataBezier_t { - extraDataBase_t base; - coOrd pos[4]; - DIST_T minCurveRadius; - ANGLE_T a0, a1; - DIST_T length; - dynArr_t arcSegs; - coOrd descriptionOff; - DIST_T segsWidth; - wDrawColor segsColor; - drawLineType_e lineType; - } extraDataBezier_t; + extraDataBase_t base; + coOrd pos[4]; + DIST_T minCurveRadius; + ANGLE_T a0, a1; + DIST_T length; + dynArr_t arcSegs; + coOrd descriptionOff; + LWIDTH_T segsLineWidth; + wDrawColor segsColor; + drawLineType_e lineType; +} extraDataBezier_t; -void BezierSplit(coOrd[4], coOrd[4], coOrd[4] , double ); -coOrd BezierPointByParameter(coOrd[4], double); -double BezierMathLength(coOrd[4], double); -coOrd BezierFirstDerivative(coOrd p[4], double); -coOrd BezierSecondDerivative(coOrd p[4], double); -double BezierCurvature(coOrd[4], double , coOrd *); -double BezierMaxCurve(coOrd[4]); -double BezierMathMinRadius(coOrd[4]); -coOrd BezierMathFindNearestPoint(coOrd *, coOrd[4] , int ); -void SetBezierData( track_p p, coOrd pos[4], wDrawColor color, DIST_T width ); -track_p NewBezierTrack(coOrd[4], trkSeg_p , int ); -track_p NewBezierLine(coOrd[4], trkSeg_p , int, wDrawColor, DIST_T); -DIST_T BezierMathDistance( coOrd *, coOrd[4], int , double * ); +void SetBezierData( track_p p, coOrd pos[4], wDrawColor color, + LWIDTH_T lineWidth ); +track_p NewBezierTrack(coOrd[4], trkSeg_p, int ); +track_p NewBezierLine(coOrd[4], trkSeg_p, int, wDrawColor, DIST_T); void FixUpBezier(coOrd[4], struct extraDataBezier_t*, BOOL_T); -void FixUpBezierSeg(coOrd[4], trkSeg_p , BOOL_T); +void FixUpBezierSeg(coOrd[4], trkSeg_p, BOOL_T); void FixUpBezierSegs(trkSeg_p p,int segCnt); BOOL_T GetBezierSegmentFromTrack(track_p, trkSeg_p); BOOL_T GetTracksFromBezierTrack(track_p trk, track_p newTracks[2]); -BOOL_T GetTracksFromBezierSegment(trkSeg_p bezSeg, track_p newTracks[2], track_p old); +BOOL_T GetTracksFromBezierSegment(trkSeg_p bezSeg, track_p newTracks[2], + track_p old); void SetBezierLineType( track_p trk, int width ); BOOL_T GetBezierMiddle( track_p, coOrd * ); -DIST_T BezierDescriptionDistance(coOrd pos,track_p trk, coOrd *, BOOL_T, BOOL_T * ); +void MoveBezier( track_p trk, coOrd orig ); +void RotateBezier( track_p trk, coOrd orig, ANGLE_T angle ); + +DIST_T BezierDescriptionDistance(coOrd pos,track_p trk, coOrd *, BOOL_T, + BOOL_T * ); STATUS_T BezierDescriptionMove(track_p trk,wAction_t action,coOrd pos ); diff --git a/app/bin/tcornu.c b/app/bin/tcornu.c index 5119a5e..3e4b772 100644 --- a/app/bin/tcornu.c +++ b/app/bin/tcornu.c @@ -32,7 +32,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -66,7 +66,9 @@ static DIST_T GetLengthCornu( track_p ); /* * Run after any changes to the Cornu points */ -void SetUpCornuParmFromTracks(track_p trk[2],cornuParm_t * cp, struct extraDataCornu_t* xx) { +void SetUpCornuParmFromTracks(track_p trk[2],cornuParm_t * cp, + struct extraDataCornu_t* xx) +{ if (!trk[0]) { cp->center[0] = xx->c[0]; cp->angle[0] = xx->a[0]; @@ -79,13 +81,15 @@ void SetUpCornuParmFromTracks(track_p trk[2],cornuParm_t * cp, struct extraDataC } } -EXPORT BOOL_T FixUpCornu(coOrd pos[2], track_p trk[2], EPINX_T ep[2], struct extraDataCornu_t* xx) { +EXPORT BOOL_T FixUpCornu(coOrd pos[4], track_p trk[2], EPINX_T ep[2], + struct extraDataCornu_t* xx) +{ cornuParm_t cp; SetUpCornuParmFromTracks(trk,&cp,xx); - if (!CallCornu(pos, trk, ep, &xx->arcSegs, &cp)) return FALSE; + if (!CallCornu(pos, trk, ep, &xx->arcSegs, &cp)) { return FALSE; } xx->r[0] = cp.radius[0]; if (cp.radius[0]==0) { @@ -103,34 +107,37 @@ EXPORT BOOL_T FixUpCornu(coOrd pos[2], track_p trk[2], EPINX_T ep[2], struct ext xx->minCurveRadius = CornuMinRadius(pos,xx->arcSegs); xx->windingAngle = CornuTotalWindingArc(pos,xx->arcSegs); DIST_T last_c; - if (xx->r[0] == 0) last_c = 0; - else last_c = 1/xx->r[0]; + if (xx->r[0] == 0) { last_c = 0; } + else { last_c = 1/xx->r[0]; } xx->maxRateofChange = CornuMaxRateofChangeofCurvature(pos,xx->arcSegs,&last_c); xx->length = CornuLength(pos, xx->arcSegs); return TRUE; } -EXPORT BOOL_T FixUpCornu0(coOrd pos[2],coOrd center[2],ANGLE_T angle[2],DIST_T radius[2],struct extraDataCornu_t* xx) { +EXPORT BOOL_T FixUpCornu0(coOrd pos[4],coOrd center[2],ANGLE_T angle[2], + DIST_T radius[2],struct extraDataCornu_t* xx) +{ DIST_T last_c; - if (!CallCornu0(pos, center, angle, radius,&xx->arcSegs,FALSE)) return FALSE; + if (!CallCornu0(pos, center, angle, radius,&xx->arcSegs,FALSE)) { return FALSE; } xx->minCurveRadius = CornuMinRadius(pos, - xx->arcSegs); - if (xx->r[0] == 0) last_c = 0; - else last_c = 1/xx->r[0]; + xx->arcSegs); + if (xx->r[0] == 0) { last_c = 0; } + else { last_c = 1/xx->r[0]; } xx->maxRateofChange = CornuMaxRateofChangeofCurvature(pos,xx->arcSegs,&last_c); xx->length = CornuLength(pos, xx->arcSegs); xx->windingAngle = CornuTotalWindingArc(pos,xx->arcSegs); return TRUE; } -EXPORT char * CreateSegPathList(track_p trk) { +EXPORT char * CreateSegPathList(track_p trk) +{ char * cp = "\0\0"; - if (GetTrkType(trk) != T_CORNU) return cp; + if (GetTrkType(trk) != T_CORNU) { return cp; } struct extraDataCornu_t *xx = GET_EXTRA_DATA(trk, T_CORNU, extraDataCornu_t); - if (xx->cornuPath) MyFree(xx->cornuPath); + if (xx->cornuPath) { MyFree(xx->cornuPath); } xx->cornuPath = MyMalloc(xx->arcSegs.cnt+2); int j= 0; - for (int i = 0;i<xx->arcSegs.cnt;i++,j++) { + for (int i = 0; i<xx->arcSegs.cnt; i++,j++) { xx->cornuPath[j] = i+1; } xx->cornuPath[j] = cp[0]; @@ -139,49 +146,54 @@ EXPORT char * CreateSegPathList(track_p trk) { } +#if 0 static void GetCornuAngles( ANGLE_T *a0, ANGLE_T *a1, track_p trk ) { - assert( trk != NULL ); - - *a0 = NormalizeAngle( GetTrkEndAngle(trk,0) ); - *a1 = NormalizeAngle( GetTrkEndAngle(trk,1) ); - - LOG( log_cornu, 4, ( "getCornuAngles: = %0.3f %0.3f\n", *a0, *a1 ) ) + CHECK( trk != NULL ); + + *a0 = NormalizeAngle( GetTrkEndAngle(trk,0) ); + *a1 = NormalizeAngle( GetTrkEndAngle(trk,1) ); + + LOG( log_cornu, 4, ( "getCornuAngles: = %0.3f %0.3f\n", *a0, *a1 ) ) } +#endif static void ComputeCornuBoundingBox( track_p trk, struct extraDataCornu_t * xx ) { - coOrd orig, size; + coOrd orig, size; + + GetSegBounds(zero,0,xx->arcSegs.cnt,&DYNARR_N(trkSeg_t,xx->arcSegs,0), &orig, + &size); - GetSegBounds(zero,0,xx->arcSegs.cnt,xx->arcSegs.ptr, &orig, &size); + coOrd hi, lo; - coOrd hi, lo; - - lo.x = orig.x; - lo.y = orig.y; - hi.x = orig.x+size.x; - hi.y = orig.y+size.y; + lo.x = orig.x; + lo.y = orig.y; + hi.x = orig.x+size.x; + hi.y = orig.y+size.y; - SetBoundingBox( trk, hi, lo ); + SetBoundingBox( trk, hi, lo ); } DIST_T CornuDescriptionDistance( - coOrd pos, - track_p trk, - coOrd * dpos, - BOOL_T show_hidden, - BOOL_T * hidden) + coOrd pos, + track_p trk, + coOrd * dpos, + BOOL_T show_hidden, + BOOL_T * hidden) { coOrd p1; - if (hidden) *hidden = FALSE; - if ( GetTrkType( trk ) != T_CORNU || ((( GetTrkBits( trk ) & TB_HIDEDESC ) != 0) && !show_hidden) ) + if (hidden) { *hidden = FALSE; } + if ( GetTrkType( trk ) != T_CORNU + || ((( GetTrkBits( trk ) & TB_HIDEDESC ) != 0) && !show_hidden) ) { return DIST_INF; + } struct extraDataCornu_t *xx = GET_EXTRA_DATA(trk, T_CORNU, extraDataCornu_t); - if (( GetTrkBits( trk ) & TB_HIDEDESC ) != 0) xx->descriptionOff = zero; - + if (( GetTrkBits( trk ) & TB_HIDEDESC ) != 0) { xx->descriptionOff = zero; } + coOrd end0, end0off, end1, end1off; end0 = xx->pos[0]; end1 = xx->pos[1]; @@ -193,32 +205,34 @@ DIST_T CornuDescriptionDistance( p1.x = (end1off.x - end0off.x)*(xx->descriptionOff.x+0.5) + end0off.x; p1.y = (end1off.y - end0off.y)*(xx->descriptionOff.x+0.5) + end0off.y; - if (hidden) *hidden = (GetTrkBits( trk ) & TB_HIDEDESC); + if (hidden) { *hidden = (GetTrkBits( trk ) & TB_HIDEDESC); } *dpos = p1; coOrd tpos = pos; - if (DistanceCornu(trk,&tpos)<FindDistance( p1, pos )) + if (DistanceCornu(trk,&tpos)<FindDistance( p1, pos )) { return DistanceCornu(trk,&pos); + } return FindDistance( p1, pos ); } typedef struct { - coOrd pos; - ANGLE_T angle; - } pos_angle_t; + coOrd pos; + ANGLE_T angle; +} pos_angle_t; static void DrawCornuDescription( - track_p trk, - drawCmd_p d, - wDrawColor color ) + track_p trk, + drawCmd_p d, + wDrawColor color ) { - wFont_p fp; - coOrd epos0, epos1, offpos0, offpos1; + coOrd epos0, epos1, offpos0, offpos1; - if (layoutLabels == 0) + if (layoutLabels == 0) { + return; + } + if ((labelEnable&LABELENABLE_TRKDESC)==0) { return; - if ((labelEnable&LABELENABLE_TRKDESC)==0) - return; + } struct extraDataCornu_t *xx = GET_EXTRA_DATA(trk, T_CORNU, extraDataCornu_t); epos0 = xx->pos[0]; @@ -227,50 +241,53 @@ static void DrawCornuDescription( Translate(&offpos0,epos0,a+90,xx->descriptionOff.y); Translate(&offpos1,epos1,a+90,xx->descriptionOff.y); - fp = wStandardFont( F_TIMES, FALSE, FALSE ); + wStandardFont( F_TIMES, FALSE, FALSE ); - sprintf( message, _("Cornu: L %s A %0.3f L %s MinR %s"), - FormatDistance(FindDistance(xx->pos[0], xx->pos[1])), - FindAngle(xx->pos[0], xx->pos[1]), - FormatDistance(xx->length), - FormatDistance((xx->minCurveRadius>=DIST_INF)?0.0:xx->minCurveRadius)); - DrawLine(d,xx->pos[0],offpos0,0,color); - DrawLine(d,xx->pos[1],offpos1,0,color); - DrawDimLine( d, offpos0, offpos1, message, (wFontSize_t)descriptionFontSize, xx->descriptionOff.x+0.5, 0, color, 0x00 ); + sprintf( message, _("Cornu: L %s A %0.3f L %s MinR %s"), + FormatDistance(FindDistance(xx->pos[0], xx->pos[1])), + FindAngle(xx->pos[0], xx->pos[1]), + FormatDistance(xx->length), + FormatDistance((xx->minCurveRadius>=DIST_INF)?0.0:xx->minCurveRadius)); + DrawLine(d,xx->pos[0],offpos0,0,color); + DrawLine(d,xx->pos[1],offpos1,0,color); + DrawDimLine( d, offpos0, offpos1, message, (wFontSize_t)descriptionFontSize, + xx->descriptionOff.x+0.5, 0, color, 0x00 ); - if (GetTrkBits( trk ) & TB_DETAILDESC) { + if (GetTrkBits( trk ) & TB_DETAILDESC) { coOrd details_pos; details_pos.x = (offpos1.x - offpos0.x)*(xx->descriptionOff.x+0.5) + offpos0.x; - details_pos.y = (offpos1.y - offpos0.y)*(xx->descriptionOff.x+0.5) + offpos0.y-(2*descriptionFontSize/mainD.dpi); + details_pos.y = (offpos1.y - offpos0.y)*(xx->descriptionOff.x+0.5) + offpos0.y- + (2*descriptionFontSize/mainD.dpi); AddTrkDetails(d, trk, details_pos, xx->length, color); - } + } } STATUS_T CornuDescriptionMove( - track_p trk, - wAction_t action, - coOrd pos ) + track_p trk, + wAction_t action, + coOrd pos ) { - static coOrd p0,p1; - static BOOL_T editState; +// static coOrd p0,p1; +// static BOOL_T editState; - if (GetTrkType(trk) != T_CORNU) return C_CONTINUE; + if (GetTrkType(trk) != T_CORNU) { return C_CONTINUE; } struct extraDataCornu_t *xx = GET_EXTRA_DATA(trk, T_CORNU, extraDataCornu_t); ANGLE_T ap; - coOrd end0, end1; - end0 = xx->pos[0]; + coOrd end0, end1; + end0 = xx->pos[0]; end1 = xx->pos[1]; ap = NormalizeAngle(FindAngle(end0,pos)-FindAngle(end0,end1)); xx->descriptionOff.y = FindDistance(end0,pos)*sin(D2R(ap)); - xx->descriptionOff.x = -0.5 + FindDistance(end0,pos)*cos(D2R(ap))/FindDistance(end0,end1); - if (xx->descriptionOff.x > 0.5) xx->descriptionOff.x = 0.5; - if (xx->descriptionOff.x < -0.5) xx->descriptionOff.x = -0.5; - + xx->descriptionOff.x = -0.5 + FindDistance(end0, + pos)*cos(D2R(ap))/FindDistance(end0,end1); + if (xx->descriptionOff.x > 0.5) { xx->descriptionOff.x = 0.5; } + if (xx->descriptionOff.x < -0.5) { xx->descriptionOff.x = -0.5; } + return C_CONTINUE; } @@ -281,66 +298,69 @@ STATUS_T CornuDescriptionMove( */ static struct { - coOrd pos[2]; - ANGLE_T angle[2]; - DIST_T radius[2]; - coOrd center[2]; - FLOAT_T elev[2]; - FLOAT_T length; - FLOAT_T grade; - DIST_T minRadius; - DIST_T maxRateOfChange; - ANGLE_T windingAngle; - unsigned int layerNumber; - dynArr_t segs; - long width; - wDrawColor color; - } cornData; + coOrd pos[2]; + ANGLE_T angle[2]; + DIST_T radius[2]; + coOrd center[2]; + FLOAT_T elev[2]; + FLOAT_T length; + FLOAT_T grade; + DIST_T minRadius; + DIST_T maxRateOfChange; + ANGLE_T windingAngle; + unsigned int layerNumber; + dynArr_t segs; + long lineWidth; + wDrawColor color; +} cornData; typedef enum { P0, A0, R0, C0, Z0, P1, A1, R1, C1, Z1, RA, RR, WA, LN, GR, LY } cornuDesc_e; static descData_t cornuDesc[] = { -/*P0*/ { DESC_POS, N_("End Pt 1: X,Y"), &cornData.pos[0] }, -/*A0*/ { DESC_ANGLE, N_("End Angle"), &cornData.angle[0] }, -/*R0*/ { DESC_DIM, N_("Radius "), &cornData.radius[0] }, -/*C0*/ { DESC_POS, N_("Center X,Y"), &cornData.center[0] }, -/*Z0*/ { DESC_DIM, N_("Z1"), &cornData.elev[0] }, -/*P1*/ { DESC_POS, N_("End Pt 2: X,Y"), &cornData.pos[1] }, -/*A1*/ { DESC_ANGLE, N_("End Angle"), &cornData.angle[1] }, -/*R1*/ { DESC_DIM, N_("Radius"), &cornData.radius[1] }, -/*C1*/ { DESC_POS, N_("Center X,Y"), &cornData.center[1] }, -/*Z1*/ { DESC_DIM, N_("Z2"), &cornData.elev[1] }, -/*RA*/ { DESC_DIM, N_("Minimum Radius"), &cornData.minRadius }, -/*RR*/ { DESC_FLOAT, N_("Max Rate Of Curve Change/Scale"), &cornData.maxRateOfChange }, -/*WA*/ { DESC_ANGLE, N_("Total Winding Angle"), &cornData.windingAngle }, -/*LN*/ { DESC_DIM, N_("Length"), &cornData.length }, -/*GR*/ { DESC_FLOAT, N_("Grade"), &cornData.grade }, -/*LY*/ { DESC_LAYER, N_("Layer"), &cornData.layerNumber }, - { DESC_NULL } }; - - -static void UpdateCornu( track_p trk, int inx, descData_p descUpd, BOOL_T final ) + /*P0*/ { DESC_POS, N_("End Pt 1: X,Y"), &cornData.pos[0] }, + /*A0*/ { DESC_ANGLE, N_("End Angle"), &cornData.angle[0] }, + /*R0*/ { DESC_DIM, N_("Radius "), &cornData.radius[0] }, + /*C0*/ { DESC_POS, N_("Center X,Y"), &cornData.center[0] }, + /*Z0*/ { DESC_DIM, N_("Z1"), &cornData.elev[0] }, + /*P1*/ { DESC_POS, N_("End Pt 2: X,Y"), &cornData.pos[1] }, + /*A1*/ { DESC_ANGLE, N_("End Angle"), &cornData.angle[1] }, + /*R1*/ { DESC_DIM, N_("Radius"), &cornData.radius[1] }, + /*C1*/ { DESC_POS, N_("Center X,Y"), &cornData.center[1] }, + /*Z1*/ { DESC_DIM, N_("Z2"), &cornData.elev[1] }, + /*RA*/ { DESC_DIM, N_("Minimum Radius"), &cornData.minRadius }, + /*RR*/ { DESC_FLOAT, N_("Max Rate Of Curve Change/Scale"), &cornData.maxRateOfChange }, + /*WA*/ { DESC_ANGLE, N_("Total Winding Angle"), &cornData.windingAngle }, + /*LN*/ { DESC_DIM, N_("Length"), &cornData.length }, + /*GR*/ { DESC_FLOAT, N_("Grade"), &cornData.grade }, + /*LY*/ { DESC_LAYER, N_("Layer"), &cornData.layerNumber }, + { DESC_NULL } +}; + + +static void UpdateCornu( track_p trk, int inx, descData_p descUpd, + BOOL_T final ) { BOOL_T updateEndPts; EPINX_T ep; cornuParm_t cp; - if ( inx == -1 ) + if ( inx == -1 ) { return; + } updateEndPts = FALSE; UndrawNewTrack(trk); struct extraDataCornu_t *xx = GET_EXTRA_DATA(trk, T_CORNU, extraDataCornu_t); switch ( inx ) { case P0: - if (GetTrkEndTrk(trk,0)) break; + if (GetTrkEndTrk(trk,0)) { break; } updateEndPts = TRUE; xx->pos[0] = cornData.pos[0]; Translate(&xx->c[0],xx->pos[0],xx->a[0]+90,xx->r[0]); cornData.center[0] = xx->c[0]; cornuDesc[P0].mode |= DESC_CHANGE; cornuDesc[C0].mode |= DESC_CHANGE; - /* no break */ + /* no break */ case P1: - if (GetTrkEndTrk(trk,1)) break; + if (GetTrkEndTrk(trk,1)) { break; } updateEndPts = TRUE; xx->pos[1]= cornData.pos[1]; Translate(&xx->c[1],xx->pos[1],xx->a[1]-90,xx->r[1]); @@ -349,7 +369,7 @@ static void UpdateCornu( track_p trk, int inx, descData_p descUpd, BOOL_T final cornuDesc[C1].mode |= DESC_CHANGE; break; case A0: - if (GetTrkEndTrk(trk,0)) break; + if (GetTrkEndTrk(trk,0)) { break; } updateEndPts = TRUE; xx->a[0] = cornData.angle[0]; Translate(&xx->c[0],xx->pos[0],xx->a[0]+90,xx->r[0]); @@ -358,7 +378,7 @@ static void UpdateCornu( track_p trk, int inx, descData_p descUpd, BOOL_T final cornuDesc[C0].mode |= DESC_CHANGE; break; case A1: - if (GetTrkEndTrk(trk,1)) break; + if (GetTrkEndTrk(trk,1)) { break; } updateEndPts = TRUE; xx->a[1]= cornData.angle[1]; Translate(&xx->c[1],xx->pos[1],xx->a[1]-90,xx->r[1]); @@ -367,19 +387,19 @@ static void UpdateCornu( track_p trk, int inx, descData_p descUpd, BOOL_T final cornuDesc[C1].mode |= DESC_CHANGE; break; case C0: - if (GetTrkEndTrk(trk,0)) break; + if (GetTrkEndTrk(trk,0)) { break; } //updateEndPts = TRUE; //xx->c[0] = cornData.center[0]; //cornuDesc[C0].mode |= DESC_CHANGE; break; case C1: - if (GetTrkEndTrk(trk,1)) break; + if (GetTrkEndTrk(trk,1)) { break; } //updateEndPts = TRUE; //xx->c[1] = cornData.center[1]; //cornuDesc[C1].mode |= DESC_CHANGE; break; case R0: - if (GetTrkEndTrk(trk,0)) break; + if (GetTrkEndTrk(trk,0)) { break; } updateEndPts = TRUE; xx->r[0] = fabs(cornData.radius[0]); Translate(&xx->c[0],xx->pos[0],NormalizeAngle(xx->a[0]+90),cornData.radius[0]); @@ -389,7 +409,7 @@ static void UpdateCornu( track_p trk, int inx, descData_p descUpd, BOOL_T final cornuDesc[C0].mode |= DESC_CHANGE; break; case R1: - if (GetTrkEndTrk(trk,1)) break; + if (GetTrkEndTrk(trk,1)) { break; } updateEndPts = TRUE; xx->r[1]= fabs(cornData.radius[1]); Translate(&xx->c[1],xx->pos[1],NormalizeAngle(xx->a[1]-90),cornData.radius[1]); @@ -401,12 +421,15 @@ static void UpdateCornu( track_p trk, int inx, descData_p descUpd, BOOL_T final case Z0: case Z1: ep = (inx==Z0?0:1); - UpdateTrkEndElev( trk, ep, GetTrkEndElevUnmaskedMode(trk,ep), cornData.elev[ep], NULL ); + UpdateTrkEndElev( trk, ep, GetTrkEndElevUnmaskedMode(trk,ep), cornData.elev[ep], + NULL ); ComputeElev( trk, 1-ep, FALSE, &cornData.elev[1-ep], NULL, TRUE ); - if ( cornData.length > minLength ) - cornData.grade = fabs( (cornData.elev[0]-cornData.elev[1])/cornData.length )*100.0; - else + if ( cornData.length > minLength ) { + cornData.grade = fabs( (cornData.elev[0]-cornData.elev[1])/cornData.length ) + *100.0; + } else { cornData.grade = 0.0; + } cornuDesc[GR].mode |= DESC_CHANGE; cornuDesc[inx==Z0?Z1:Z0].mode |= DESC_CHANGE; return; @@ -414,11 +437,11 @@ static void UpdateCornu( track_p trk, int inx, descData_p descUpd, BOOL_T final SetTrkLayer( trk, cornData.layerNumber); break; default: - AbortProg( "updateCornu: Bad inx %d", inx ); + CHECKMSG( FALSE, ( "updateCornu: Bad inx %d", inx ) ); } - track_p tracks[2]; - tracks[0] = GetTrkEndTrk(trk,0); - tracks[1] = GetTrkEndTrk(trk,1); +// track_p tracks[2]; +// tracks[0] = GetTrkEndTrk(trk,0); +// tracks[1] = GetTrkEndTrk(trk,1); if (updateEndPts) { if ( GetTrkEndTrk(trk,0) == NULL ) { @@ -449,45 +472,49 @@ static void DescribeCornu( track_p trk, char * str, CSIZE_T len ) DIST_T d; d = xx->length; - sprintf( str, _("Cornu Track(%d): Layer=%u MinRadius=%s Length=%s EP=[%0.3f,%0.3f] [%0.3f,%0.3f]"), - GetTrkIndex(trk), - GetTrkLayer(trk)+1, - FormatDistance(xx->minCurveRadius), - FormatDistance(d), - PutDim(xx->pos[0].x),PutDim(xx->pos[0].y), - PutDim(xx->pos[1].x),PutDim(xx->pos[1].y) - ); + sprintf( str, + _("Cornu Track(%d): Layer=%u MinRadius=%s Length=%s EP=[%0.3f,%0.3f] [%0.3f,%0.3f]"), + GetTrkIndex(trk), + GetTrkLayer(trk)+1, + FormatDistance(xx->minCurveRadius), + FormatDistance(d), + PutDim(xx->pos[0].x),PutDim(xx->pos[0].y), + PutDim(xx->pos[1].x),PutDim(xx->pos[1].y) + ); cornData.length = xx->length; cornData.minRadius = xx->minCurveRadius; - cornData.maxRateOfChange = xx->maxRateofChange*GetScaleRatio(GetLayoutCurScale()); + cornData.maxRateOfChange = xx->maxRateofChange*GetScaleRatio( + GetLayoutCurScale()); cornData.windingAngle = xx->windingAngle; - cornData.layerNumber = GetTrkLayer(trk); - cornData.pos[0] = xx->pos[0]; - cornData.pos[1] = xx->pos[1]; - cornData.angle[0] = xx->a[0]; - cornData.angle[1] = xx->a[1]; - cornData.center[0] = xx->c[0]; - cornData.center[1] = xx->c[1]; - cornData.radius[0] = xx->r[0]; - cornData.radius[1] = xx->r[1]; - if (GetTrkType(trk) == T_CORNU) { + cornData.layerNumber = GetTrkLayer(trk); + cornData.pos[0] = xx->pos[0]; + cornData.pos[1] = xx->pos[1]; + cornData.angle[0] = xx->a[0]; + cornData.angle[1] = xx->a[1]; + cornData.center[0] = xx->c[0]; + cornData.center[1] = xx->c[1]; + cornData.radius[0] = xx->r[0]; + cornData.radius[1] = xx->r[1]; + if (GetTrkType(trk) == T_CORNU) { ComputeElev( trk, 0, FALSE, &cornData.elev[0], NULL, FALSE ); ComputeElev( trk, 1, FALSE, &cornData.elev[1], NULL, FALSE ); - if ( cornData.length > minLength ) - cornData.grade = fabs( (cornData.elev[0]-cornData.elev[1])/cornData.length )*100.0; - else + if ( cornData.length > minLength ) { + cornData.grade = fabs( (cornData.elev[0]-cornData.elev[1])/cornData.length ) + *100.0; + } else { cornData.grade = 0.0; - } - BOOL_T trk0 = (GetTrkEndTrk(trk,0)!=NULL); - BOOL_T trk1 = (GetTrkEndTrk(trk,1)!=NULL); + } + } + BOOL_T trk0 = (GetTrkEndTrk(trk,0)!=NULL); + BOOL_T trk1 = (GetTrkEndTrk(trk,1)!=NULL); cornuDesc[P0].mode = !trk0?0:DESC_RO; cornuDesc[P1].mode = !trk1?0:DESC_RO; cornuDesc[LN].mode = DESC_RO; - cornuDesc[Z0].mode = EndPtIsDefinedElev(trk,0)?0:DESC_RO; - cornuDesc[Z1].mode = EndPtIsDefinedElev(trk,1)?0:DESC_RO; + cornuDesc[Z0].mode = EndPtIsDefinedElev(trk,0)?0:DESC_RO; + cornuDesc[Z1].mode = EndPtIsDefinedElev(trk,1)?0:DESC_RO; cornuDesc[A0].mode = !trk0?0:DESC_RO; @@ -497,9 +524,9 @@ static void DescribeCornu( track_p trk, char * str, CSIZE_T len ) cornuDesc[R0].mode = !trk0?0:DESC_RO; cornuDesc[R1].mode = !trk1?0:DESC_RO; cornuDesc[GR].mode = DESC_RO; - cornuDesc[RA].mode = DESC_RO; - cornuDesc[RR].mode = DESC_RO; - cornuDesc[WA].mode = DESC_RO; + cornuDesc[RA].mode = DESC_RO; + cornuDesc[RR].mode = DESC_RO; + cornuDesc[WA].mode = DESC_RO; cornuDesc[LY].mode = DESC_NOREDRAW; DoDescribe( _("Cornu Track"), trk, cornuDesc, UpdateCornu ); @@ -515,9 +542,9 @@ DIST_T DistanceCornu( track_p t, coOrd * p ) DIST_T d = DIST_INF; coOrd p2 = xx->pos[0]; //Set initial point segProcData_t segProcData; - for (int i = 0;i<xx->arcSegs.cnt;i++) { + for (int i = 0; i<xx->arcSegs.cnt; i++) { trkSeg_t seg = DYNARR_N(trkSeg_t,xx->arcSegs,i); - if (seg.type == SEG_FILCRCL) continue; + if (seg.type == SEG_FILCRCL) { continue; } segProcData.distance.pos1 = * p; SegProc(SEGPROC_DISTANCE,&seg,&segProcData); if (segProcData.distance.dd<d) { @@ -525,7 +552,7 @@ DIST_T DistanceCornu( track_p t, coOrd * p ) p2 = segProcData.distance.pos1; } } - //d = BezierDistance( p, xx->bezierData.pos[0], xx->bezierData.pos[1], xx->bezierData.pos[2], xx->bezierData.pos[1], 100, NULL ); + //d = BezierDistance( p, xx->bezierData.pos[0], xx->bezierData.pos[1], xx->bezierData.pos[2], xx->bezierData.pos[1], 100, NULL ); * p = p2; return d; } @@ -535,26 +562,21 @@ static void DrawCornu( track_p t, drawCmd_p d, wDrawColor color ) long widthOptions = DTS_LEFT|DTS_RIGHT; if ( ((d->options&DC_SIMPLE)==0) && - (labelWhen == 2 || (labelWhen == 1 && (d->options&DC_PRINT))) && - labelScale >= d->scale && - ( GetTrkBits( t ) & TB_HIDEDESC ) == 0 ) { + (labelWhen == 2 || (labelWhen == 1 && (d->options&DC_PRINT))) && + labelScale >= d->scale && + ( GetTrkBits( t ) & TB_HIDEDESC ) == 0 ) { DrawCornuDescription( t, d, color ); } - DIST_T scale2rail = (d->options&DC_PRINT)?(twoRailScale*2+1):twoRailScale; struct extraDataCornu_t *xx = GET_EXTRA_DATA(t, T_CORNU, extraDataCornu_t); - DrawSegsO(d,t,zero,0.0,xx->arcSegs.ptr,xx->arcSegs.cnt, GetTrkGauge(t), color, widthOptions); + DrawSegsDA(d,t,zero,0.0,&xx->arcSegs, GetTrkGauge(t), color, widthOptions); DrawEndPt( d, t, 0, color ); DrawEndPt( d, t, 1, color ); } -void FreeSubSegs(trkSeg_t* s) { +void FreeSubSegs(trkSeg_t* s) +{ if (s->type == SEG_BEZTRK || s->type == SEG_BEZLIN) { - if (s->bezSegs.ptr) { - MyFree(s->bezSegs.ptr); - } - s->bezSegs.max = 0; - s->bezSegs.cnt = 0; - s->bezSegs.ptr = NULL; + DYNARR_FREE( trkSeg_t, s->bezSegs ); } } @@ -562,41 +584,42 @@ static void DeleteCornu( track_p t ) { struct extraDataCornu_t *xx = GET_EXTRA_DATA(t, T_CORNU, extraDataCornu_t); - for (int i=0;i<xx->arcSegs.cnt;i++) { + for (int i=0; i<xx->arcSegs.cnt; i++) { trkSeg_t s = DYNARR_N(trkSeg_t,xx->arcSegs,i); FreeSubSegs(&s); } - if (xx->arcSegs.ptr) - MyFree(xx->arcSegs.ptr); - xx->arcSegs.max = 0; - xx->arcSegs.cnt = 0; - xx->arcSegs.ptr = NULL; + + DYNARR_FREE( trkSeg_t, xx->arcSegs ); } static BOOL_T WriteCornu( track_p t, FILE * f ) { + int bits; long options; BOOL_T rc = TRUE; BOOL_T track =(GetTrkType(t)==T_CORNU); options = GetTrkWidth(t) & 0x0F; struct extraDataCornu_t *xx = GET_EXTRA_DATA(t, T_CORNU, extraDataCornu_t); - if ( ( GetTrkBits(t) & TB_HIDEDESC ) == 0 ) options |= 0x80; - rc &= fprintf(f, "%s %d %d %ld 0 0 %s %d %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f \n", - "CORNU",GetTrkIndex(t), GetTrkLayer(t), (long)options, - GetTrkScaleName(t), GetTrkVisible(t)|(GetTrkNoTies(t)?1<<2:0)|(GetTrkBridge(t)?1<<3:0), - xx->pos[0].x, xx->pos[0].y, - xx->a[0], - xx->r[0], - xx->c[0].x,xx->c[0].y, - xx->pos[1].x, xx->pos[1].y, - xx->a[1], - xx->r[1], - xx->c[1].x,xx->c[1].y )>0; + if ( ( GetTrkBits(t) & TB_HIDEDESC ) == 0 ) { options |= 0x80; } + bits = GetTrkVisible(t)|(GetTrkNoTies(t)?1<<2:0)|(GetTrkBridge(t)?1<<3:0)| + (GetTrkRoadbed(t)?1<<4:0); + rc &= fprintf(f, + "%s %d %d %ld 0 0 %s %d %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f \n", + "CORNU",GetTrkIndex(t), GetTrkLayer(t), (long)options, + GetTrkScaleName(t), bits, + xx->pos[0].x, xx->pos[0].y, + xx->a[0], + xx->r[0], + xx->c[0].x,xx->c[0].y, + xx->pos[1].x, xx->pos[1].y, + xx->a[1], + xx->r[1], + xx->c[1].x,xx->c[1].y )>0; if (track) { - rc &= WriteEndPt( f, t, 0 ); - rc &= WriteEndPt( f, t, 1 ); - } - rc &= WriteSegs( f, xx->arcSegs.cnt, xx->arcSegs.ptr ); + rc &= WriteEndPt( f, t, 0 ); + rc &= WriteEndPt( f, t, 1 ); + } + rc &= WriteSegs( f, xx->arcSegs.cnt, &DYNARR_N(trkSeg_t,xx->arcSegs,0) ); return rc; } @@ -612,35 +635,38 @@ static BOOL_T ReadCornu( char * line ) char scale[10]; wIndex_t layer; long options; - char * cp = NULL; +// char * cp = NULL; if (!GetArgs( line+6, "dLl00sdpffppffp", - &index, &layer, &options, scale, &visible, &p0, &a0, &r0, &c0, &p1, &a1, &r1, &c1 ) ) { + &index, &layer, &options, scale, &visible, &p0, &a0, &r0, &c0, &p1, &a1, &r1, + &c1 ) ) { return FALSE; } - if ( !ReadSegs() ) + if ( !ReadSegs() ) { return FALSE; + } t = NewTrack( index, T_CORNU, 0, sizeof *xx ); SetTrkVisible(t, visible&2); SetTrkNoTies(t, visible&4); SetTrkBridge(t, visible&8); + SetTrkRoadbed(t, visible&16); SetTrkScale(t, LookupScale(scale)); SetTrkLayer(t, layer ); SetTrkWidth(t, (int)(options&0x0F)); - if ( paramVersion < VERSION_DESCRIPTION2 || ( options & 0x80 ) == 0 ) SetTrkBits(t,TB_HIDEDESC); + if ( paramVersion < VERSION_DESCRIPTION2 || ( options & 0x80 ) == 0 ) { SetTrkBits(t,TB_HIDEDESC); } xx = GET_EXTRA_DATA(t, T_CORNU, extraDataCornu_t); xx->pos[0] = p0; - xx->pos[1] = p1; - xx->a[0] = a0; - xx->r[0] = r0; - xx->a[1] = a1; - xx->c[0] = c0; - xx->c[1] = c1; - xx->r[1] = r1; - xx->descriptionOff.x = xx->descriptionOff.y = 0.0; - FixUpCornu0(xx->pos,xx->c,xx->a, xx->r, xx); - ComputeCornuBoundingBox(t,xx); + xx->pos[1] = p1; + xx->a[0] = a0; + xx->r[0] = r0; + xx->a[1] = a1; + xx->c[0] = c0; + xx->c[1] = c1; + xx->r[1] = r1; + xx->descriptionOff.x = xx->descriptionOff.y = 0.0; + FixUpCornu0(xx->pos,xx->c,xx->a, xx->r, xx); + ComputeCornuBoundingBox(t,xx); SetEndPts(t,2); return TRUE; } @@ -648,62 +674,67 @@ static BOOL_T ReadCornu( char * line ) static void MoveCornu( track_p trk, coOrd orig ) { struct extraDataCornu_t *xx = GET_EXTRA_DATA(trk, T_CORNU, extraDataCornu_t); - for (int i=0;i<2;i++) { - xx->pos[i].x += orig.x; - xx->pos[i].y += orig.y; - xx->c[i].x += orig.x; - xx->c[i].y += orig.y; - } - RebuildCornu(trk); + for (int i=0; i<2; i++) { + xx->pos[i].x += orig.x; + xx->pos[i].y += orig.y; + xx->c[i].x += orig.x; + xx->c[i].y += orig.y; + } + RebuildCornu(trk); } static void RotateCornu( track_p trk, coOrd orig, ANGLE_T angle ) { struct extraDataCornu_t *xx = GET_EXTRA_DATA(trk, T_CORNU, extraDataCornu_t); - for (int i=0;i<2;i++) { - Rotate( &xx->pos[i], orig, angle ); - Rotate( &xx->c[i], orig, angle); - xx->a[i] = NormalizeAngle(xx->a[i]+angle); - } - RebuildCornu(trk); + for (int i=0; i<2; i++) { + Rotate( &xx->pos[i], orig, angle ); + Rotate( &xx->c[i], orig, angle); + xx->a[i] = NormalizeAngle(xx->a[i]+angle); + } + RebuildCornu(trk); } static void RescaleCornu( track_p trk, FLOAT_T ratio ) { struct extraDataCornu_t *xx = GET_EXTRA_DATA(trk, T_CORNU, extraDataCornu_t); - for (int i=0;i<2;i++) { + for (int i=0; i<2; i++) { xx->pos[i].x *= ratio; xx->pos[i].y *= ratio; xx->c[i].x *= ratio; xx->c[i].y *= ratio; xx->r[i] *= ratio; } - RebuildCornu(trk); + RebuildCornu(trk); } -EXPORT BOOL_T SetCornuEndPt(track_p trk, EPINX_T inx, coOrd pos, coOrd center, ANGLE_T angle, DIST_T radius) { - struct extraDataCornu_t *xx = GET_EXTRA_DATA(trk, T_CORNU, extraDataCornu_t); - xx->pos[inx] = pos; - xx->c[inx] = center; - xx->a[inx] = angle; - xx->r[inx] = radius; - if (!RebuildCornu(trk)) return FALSE; - SetTrkEndPoint( trk, inx, xx->pos[inx], xx->a[inx]); - return TRUE; +EXPORT BOOL_T SetCornuEndPt(track_p trk, EPINX_T inx, coOrd pos, coOrd center, + ANGLE_T angle, DIST_T radius) +{ + struct extraDataCornu_t *xx = GET_EXTRA_DATA(trk, T_CORNU, extraDataCornu_t); + xx->pos[inx] = pos; + xx->c[inx] = center; + xx->a[inx] = angle; + xx->r[inx] = radius; + if (!RebuildCornu(trk)) { return FALSE; } + SetTrkEndPoint( trk, inx, xx->pos[inx], xx->a[inx]); + return TRUE; } -void GetCornuParmsNear(track_p t, int sel, coOrd * pos2, coOrd * center, ANGLE_T * angle2, DIST_T * radius ) { +void GetCornuParmsNear(track_p t, int sel, coOrd * pos2, coOrd * center, + ANGLE_T * angle2, DIST_T * radius ) +{ coOrd pos = *pos2; - double dd = DistanceCornu(t, &pos); //Pos adjusted to be on curve +// double dd = DistanceCornu(t, &pos); //Pos adjusted to be on curve int inx; *radius = 0.0; *angle2 = 0.0; *center = zero; wBool_t back,neg; struct extraDataCornu_t *xx = GET_EXTRA_DATA(t, T_CORNU, extraDataCornu_t); - ANGLE_T angle = GetAngleSegs(xx->arcSegs.cnt,(trkSeg_t *)(xx->arcSegs.ptr),&pos,&inx,NULL,&back,NULL,&neg); + ANGLE_T angle = GetAngleSegs(xx->arcSegs.cnt,&DYNARR_N(trkSeg_t,xx->arcSegs,0), + &pos,&inx,NULL,&back,NULL,&neg); if (inx == -1) { return; //Error in GetAngle @@ -712,8 +743,9 @@ void GetCornuParmsNear(track_p t, int sel, coOrd * pos2, coOrd * center, ANGLE_T trkSeg_p segPtr = &DYNARR_N(trkSeg_t, xx->arcSegs, inx); if (segPtr->type == SEG_BEZTRK) { - GetAngleSegs(segPtr->bezSegs.cnt,(trkSeg_t *)(segPtr->bezSegs.ptr),&pos,&inx,NULL,&back,NULL,&neg); - if (inx ==-1) return; + GetAngleSegs(segPtr->bezSegs.cnt,&DYNARR_N(trkSeg_t,segPtr->bezSegs,0),&pos, + &inx,NULL,&back,NULL,&neg); + if (inx ==-1) { return; } segPtr = &DYNARR_N(trkSeg_t, segPtr->bezSegs, inx); } @@ -724,15 +756,18 @@ void GetCornuParmsNear(track_p t, int sel, coOrd * pos2, coOrd * center, ANGLE_T *center = segPtr->u.c.center; *radius = fabs(segPtr->u.c.radius); } - if (sel) + if (sel) { angle = NormalizeAngle(angle+(neg==back?0:180)); - else + } else { angle = NormalizeAngle(angle+(neg==back?180:0)); + } *angle2 = angle; *pos2 = pos; } -void GetCornuParmsTemp(dynArr_t * array_p, int sel, coOrd * pos2, coOrd * center, ANGLE_T * angle2, DIST_T * radius ) { +void GetCornuParmsTemp(dynArr_t * array_p, int sel, coOrd * pos2, + coOrd * center, ANGLE_T * angle2, DIST_T * radius ) +{ coOrd pos = *pos2; int inx; @@ -741,17 +776,19 @@ void GetCornuParmsTemp(dynArr_t * array_p, int sel, coOrd * pos2, coOrd * center *center = zero; *angle2 = 0.0; - ANGLE_T angle = GetAngleSegs(array_p->cnt,(trkSeg_p)array_p->ptr,&pos,&inx,NULL,&back,NULL,&neg); + ANGLE_T angle = GetAngleSegs(array_p->cnt,&DYNARR_N(trkSeg_t,*array_p,0),&pos, + &inx,NULL,&back,NULL,&neg); - if (inx==-1) return; + if (inx==-1) { return; } trkSeg_p segPtr = &DYNARR_N(trkSeg_t, *array_p, inx); if (segPtr->type == SEG_BEZTRK) { - GetAngleSegs(segPtr->bezSegs.cnt,(trkSeg_t *)(segPtr->bezSegs.ptr),&pos,&inx,NULL,&back,NULL,&neg); + GetAngleSegs(segPtr->bezSegs.cnt,&DYNARR_N(trkSeg_t,segPtr->bezSegs,0),&pos, + &inx,NULL,&back,NULL,&neg); - if (inx ==-1) return; + if (inx ==-1) { return; } segPtr = &DYNARR_N(trkSeg_t, segPtr->bezSegs, inx); @@ -764,10 +801,11 @@ void GetCornuParmsTemp(dynArr_t * array_p, int sel, coOrd * pos2, coOrd * center *center = segPtr->u.c.center; *radius = fabs(segPtr->u.c.radius); } - if (sel) + if (sel) { angle = NormalizeAngle(angle+(neg==back?0:180)); - else + } else { angle = NormalizeAngle(angle+(neg==back?180:0)); + } *angle2 = angle; *pos2 = pos; } @@ -776,89 +814,93 @@ void GetCornuParmsTemp(dynArr_t * array_p, int sel, coOrd * pos2, coOrd * center /** * Split the Track at approximately the point pos. */ -static BOOL_T SplitCornu( track_p trk, coOrd pos, EPINX_T ep, track_p *leftover, EPINX_T * ep0, EPINX_T * ep1 ) +static BOOL_T SplitCornu( track_p trk, coOrd pos, EPINX_T ep, track_p *leftover, + EPINX_T * ep0, EPINX_T * ep1 ) { track_p trk1; - DIST_T radius = 0.0; - coOrd center; - int inx,subinx; - BOOL_T track; - track = IsTrack(trk); - - cornuParm_t new; - - double dd = DistanceCornu(trk, &pos); - if (dd>minLength) return FALSE; - BOOL_T back, neg; - + DIST_T radius = 0.0; + coOrd center; + int inx,subinx; +// BOOL_T track; +// track = IsTrack(trk); + + cornuParm_t new; + + double dd = DistanceCornu(trk, &pos); + if (dd>minLength) { return FALSE; } + BOOL_T back, neg; + struct extraDataCornu_t *xx = GET_EXTRA_DATA(trk, T_CORNU, extraDataCornu_t); - ANGLE_T angle = GetAngleSegs(xx->arcSegs.cnt,(trkSeg_t *)(xx->arcSegs.ptr),&pos,&inx,NULL,&back,&subinx,&neg); - - if (inx == -1) return FALSE; - - trkSeg_p segPtr = &DYNARR_N(trkSeg_t, xx->arcSegs, inx); - - if (subinx != -1) { - segPtr = &DYNARR_N(trkSeg_t, segPtr->bezSegs, subinx); - } - - if (segPtr->type == SEG_STRTRK) { - radius = 0.0; - center = zero; - } else if (segPtr->type == SEG_CRVTRK) { - center = segPtr->u.c.center; - radius = fabs(segPtr->u.c.radius); - } - if (ep) { - new.pos[0] = pos; - new.pos[1] = xx->pos[1]; - new.angle[0] = NormalizeAngle(angle+(neg==back?180:0)); - new.angle[1] = xx->a[1]; - new.center[0] = center; - new.center[1] = xx->c[1]; - new.radius[0] = radius; - new.radius[1] = xx->r[1]; - } else { - new.pos[1] = pos; - new.pos[0] = xx->pos[0]; - new.angle[1] = NormalizeAngle(angle+(neg==back?0:180)); - new.angle[0] = xx->a[0]; - new.center[1] = center; - new.center[0] = xx->c[0]; - new.radius[1] = radius; - new.radius[0] = xx->r[0]; - } - - trk1 = NewCornuTrack(new.pos,new.center,new.angle,new.radius,NULL,0); - //Copy elevation details from old ep to new ep 0/1 - if (trk1==NULL) { - wBeep(); - InfoMessage(_("Cornu Create Failed for p1[%0.3f,%0.3f] p2[%0.3f,%0.3f], c1[%0.3f,%0.3f] c2[%0.3f,%0.3f], a1=%0.3f a2=%0.3f, r1=%s r2=%s"), - new.pos[0].x,new.pos[0].y, - new.pos[1].x,new.pos[1].y, - new.center[0].x,new.center[0].y, - new.center[1].x,new.center[1].y, - new.angle[0],new.angle[1], - FormatDistance(new.radius[0]),FormatDistance(new.radius[1])); - UndoEnd(); - return FALSE; - } - DIST_T height; + ANGLE_T angle = GetAngleSegs(xx->arcSegs.cnt,&DYNARR_N(trkSeg_t,xx->arcSegs,0), + &pos, &inx,NULL,&back,&subinx,&neg); + + if (inx == -1) { return FALSE; } + + trkSeg_p segPtr = &DYNARR_N(trkSeg_t, xx->arcSegs, inx); + + if (subinx != -1) { + segPtr = &DYNARR_N(trkSeg_t, segPtr->bezSegs, subinx); + } + + if (segPtr->type == SEG_STRTRK) { + radius = 0.0; + center = zero; + } else if (segPtr->type == SEG_CRVTRK) { + center = segPtr->u.c.center; + radius = fabs(segPtr->u.c.radius); + } + if (ep) { + new.pos[0] = pos; + new.pos[1] = xx->pos[1]; + new.angle[0] = NormalizeAngle(angle+(neg==back?180:0)); + new.angle[1] = xx->a[1]; + new.center[0] = center; + new.center[1] = xx->c[1]; + new.radius[0] = radius; + new.radius[1] = xx->r[1]; + } else { + new.pos[1] = pos; + new.pos[0] = xx->pos[0]; + new.angle[1] = NormalizeAngle(angle+(neg==back?0:180)); + new.angle[0] = xx->a[0]; + new.center[1] = center; + new.center[0] = xx->c[0]; + new.radius[1] = radius; + new.radius[0] = xx->r[0]; + } + + trk1 = NewCornuTrack(new.pos,new.center,new.angle,new.radius,NULL,0); + //Copy elevation details from old ep to new ep 0/1 + if (trk1==NULL) { + wBeep(); + InfoMessage( + _("Cornu Create Failed for p1[%0.3f,%0.3f] p2[%0.3f,%0.3f], c1[%0.3f,%0.3f] c2[%0.3f,%0.3f], a1=%0.3f a2=%0.3f, r1=%s r2=%s"), + new.pos[0].x,new.pos[0].y, + new.pos[1].x,new.pos[1].y, + new.center[0].x,new.center[0].y, + new.center[1].x,new.center[1].y, + new.angle[0],new.angle[1], + FormatDistance(new.radius[0]),FormatDistance(new.radius[1])); + UndoEnd(); + return FALSE; + } + DIST_T height; int opt; GetTrkEndElev(trk,ep,&opt,&height); - UpdateTrkEndElev( trk1, ep, opt, height, (opt==ELEV_STATION)?GetTrkEndElevStation(trk,ep):NULL ); + UpdateTrkEndElev( trk1, ep, opt, height, + (opt==ELEV_STATION)?GetTrkEndElevStation(trk,ep):NULL ); - UndoModify(trk); - xx->pos[ep] = pos; - xx->a[ep] = NormalizeAngle(new.angle[1-ep]+180); - xx->r[ep] = new.radius[1-ep]; - xx->c[ep] = new.center[1-ep]; - //Wipe out old elevation for ep1 + UndoModify(trk); + xx->pos[ep] = pos; + xx->a[ep] = NormalizeAngle(new.angle[1-ep]+180); + xx->r[ep] = new.radius[1-ep]; + xx->c[ep] = new.center[1-ep]; + //Wipe out old elevation for ep1 - RebuildCornu(trk); + RebuildCornu(trk); - SetTrkEndPoint(trk, ep, xx->pos[ep], xx->a[ep]); - UpdateTrkEndElev( trk, ep, ELEV_NONE, 0, NULL); + SetTrkEndPoint(trk, ep, xx->pos[ep], xx->a[ep]); + UpdateTrkEndElev( trk, ep, ELEV_NONE, 0, NULL); *leftover = trk1; *ep0 = 1-ep; //Which end is for new on pos? @@ -867,7 +909,8 @@ static BOOL_T SplitCornu( track_p trk, coOrd pos, EPINX_T ep, track_p *leftover, return TRUE; } -BOOL_T MoveCornuEndPt ( track_p *trk, EPINX_T *ep, coOrd pos, DIST_T d0 ) { +BOOL_T MoveCornuEndPt ( track_p *trk, EPINX_T *ep, coOrd pos, DIST_T d0 ) +{ track_p trk2; if (SplitTrack(*trk,pos,*ep,&trk2,TRUE)) { if (trk2) { @@ -903,7 +946,7 @@ static int log_traverseCornu = 0; */ static BOOL_T TraverseCornu( traverseTrack_p trvTrk, DIST_T * distR ) { - track_p trk = trvTrk->trk; + track_p trk = trvTrk->trk; DIST_T dist = *distR; segProcData_t segProcData; BOOL_T cornu_backwards= FALSE; @@ -914,39 +957,47 @@ static BOOL_T TraverseCornu( traverseTrack_p trvTrk, DIST_T * distR ) int inx, segInx = 0; EPINX_T ep; BOOL_T back; -LOG( log_traverseCornu, 1, ( "TravCornu-In [%0.3f %0.3f] A%0.3f D%0.3f \n", trvTrk->pos.x, trvTrk->pos.y, trvTrk->angle, *distR )) + LOG( log_traverseCornu, 1, ( "TravCornu-In [%0.3f %0.3f] A%0.3f D%0.3f \n", + trvTrk->pos.x, trvTrk->pos.y, trvTrk->angle, *distR )) struct extraDataCornu_t *xx = GET_EXTRA_DATA(trk, T_CORNU, extraDataCornu_t); - trkSeg_p segPtr = (trkSeg_p)xx->arcSegs.ptr; + trkSeg_p segPtr = &DYNARR_N(trkSeg_t,xx->arcSegs,0); a2 = GetAngleSegs( //Find correct Segment and nearest point in it - xx->arcSegs.cnt,segPtr, - &pos2, &segInx, &d , &back , NULL, &neg); //d = how far pos2 from old pos2 = trvTrk->pos + xx->arcSegs.cnt,segPtr, + &pos2, &segInx, &d, &back, NULL, + &neg); //d = how far pos2 from old pos2 = trvTrk->pos if ( d > 10 ) { - ErrorMessage( "traverseCornu: Position is not near track: %0.3f", d ); - return FALSE; //This means the input pos is not on or close to the track. + ErrorMessage( "traverseCornu: Position is not near track: %0.3f", d ); + return FALSE; //This means the input pos is not on or close to the track. } - if (back) a2 = NormalizeAngle(a2+180); //If reverse segs - reverse angle - a1 = NormalizeAngle(a2-trvTrk->angle); //Establish if we are going fwds or backwards globally - if (a1<270 && a1>90) { //Must add 180 if the seg is reversed or inverted (but not both) + if (back) { a2 = NormalizeAngle(a2+180); } //If reverse segs - reverse angle + a1 = NormalizeAngle(a2 + -trvTrk->angle); //Establish if we are going fwds or backwards globally + if (a1<270 + && a1>90) { //Must add 180 if the seg is reversed or inverted (but not both) cornu_backwards = TRUE; ep = 0; } else { cornu_backwards = FALSE; ep = 1; } - if (neg) { + if (neg) { cornu_backwards = !cornu_backwards; //Reversed direction ep = 1-ep; } segProcData.traverse1.pos = pos2; //actual point on curve - segProcData.traverse1.angle = trvTrk->angle; //direction car is going for Traverse 1 -LOG( log_traverseCornu, 1, ( " TravCornu-GetSubA A%0.3f I%d N%d B%d CB%d\n", a2, segInx, neg, back, cornu_backwards )) + segProcData.traverse1.angle = + trvTrk->angle; //direction car is going for Traverse 1 + LOG( log_traverseCornu, 1, ( " TravCornu-GetSubA A%0.3f I%d N%d B%d CB%d\n", + a2, segInx, neg, back, cornu_backwards )) inx = segInx; while (inx >=0 && inx<xx->arcSegs.cnt) { - segPtr = (trkSeg_p)xx->arcSegs.ptr+inx; //move in to the identified Bezier segment + segPtr = (trkSeg_p)xx->arcSegs.ptr + +inx; //move in to the identified Bezier segment SegProc( SEGPROC_TRAVERSE1, segPtr, &segProcData ); - BOOL_T backwards = segProcData.traverse1.backwards; //do we process this segment backwards? + BOOL_T backwards = + segProcData.traverse1.backwards; //do we process this segment backwards? BOOL_T reverse_seg = segProcData.traverse1.reverse_seg; //Info only int BezSegInx = segProcData.traverse1.BezSegInx; //Which subSeg was it? BOOL_T segs_backwards = segProcData.traverse1.segs_backwards; @@ -957,13 +1008,16 @@ LOG( log_traverseCornu, 1, ( " TravCornu-GetSubA A%0.3f I%d N%d B%d CB%d\n", a2 segProcData.traverse2.segDir = backwards; segProcData.traverse2.BezSegInx = BezSegInx; segProcData.traverse2.segs_backwards = segs_backwards; -LOG( log_traverseCornu, 2, ( " TravCornu-Tr1 SI%d D%0.3f B%d RS%d \n", BezSegInx, dist, backwards, reverse_seg ) ) + LOG( log_traverseCornu, 2, ( " TravCornu-Tr1 SI%d D%0.3f B%d RS%d \n", + BezSegInx, dist, backwards, reverse_seg ) ) SegProc( SEGPROC_TRAVERSE2, segPtr, &segProcData ); //Angle at pos2 - if ( segProcData.traverse2.dist <= 0 ) { //-ve or zero distance left over so stop there + if ( segProcData.traverse2.dist <= + 0 ) { //-ve or zero distance left over so stop there *distR = 0; trvTrk->pos = segProcData.traverse2.pos; //Use finishing pos trvTrk->angle = segProcData.traverse2.angle; //Use finishing angle -LOG( log_traverseCornu, 1, ( "TravCornu-Ex1 -> [%0.3f %0.3f] A%0.3f D%0.3f\n", trvTrk->pos.x, trvTrk->pos.y, trvTrk->angle, *distR ) ) + LOG( log_traverseCornu, 1, ( "TravCornu-Ex1 -> [%0.3f %0.3f] A%0.3f D%0.3f\n", + trvTrk->pos.x, trvTrk->pos.y, trvTrk->angle, *distR ) ) return TRUE; } dist = segProcData.traverse2.dist; //How far left? @@ -971,21 +1025,25 @@ LOG( log_traverseCornu, 1, ( "TravCornu-Ex1 -> [%0.3f %0.3f] A%0.3f D%0.3f\n", t ANGLE_T angle = segProcData.traverse2.angle; //Angle of end therefore segProcData.traverse1.angle = angle; //Set up Traverse1 segProcData.traverse1.pos = pos; - inx = cornu_backwards?inx-1:inx+1; //Here's where the global segment direction comes in -LOG( log_traverseCornu, 2, ( " TravCornu-Loop D%0.3f A%0.3f I%d \n", dist, angle, inx ) ) - } - //Ran out of Bez-Segs so punt to next Track + inx = cornu_backwards?inx-1:inx + +1; //Here's where the global segment direction comes in + LOG( log_traverseCornu, 2, ( " TravCornu-Loop D%0.3f A%0.3f I%d \n", dist, + angle, inx ) ) + } + //Ran out of Bez-Segs so punt to next Track *distR = dist; //Tell caller what dist is left trvTrk->pos = GetTrkEndPos(trk,ep); //Which end were we heading for? - trvTrk->angle = NormalizeAngle(GetTrkEndAngle(trk, ep)); //+(cornu_backwards?180:0)); + trvTrk->angle = NormalizeAngle(GetTrkEndAngle(trk, + ep)); //+(cornu_backwards?180:0)); trvTrk->trk = GetTrkEndTrk(trk,ep); //go onto next track (or NULL) if (trvTrk->trk==NULL) { trvTrk->pos = pos1; - return TRUE; + return TRUE; } -LOG( log_traverseCornu, 1, ( "TravCornu-Ex2 --> [%0.3f %0.3f] A%0.3f D%0.3f\n", trvTrk->pos.x, trvTrk->pos.y, trvTrk->angle, *distR ) ) + LOG( log_traverseCornu, 1, ( "TravCornu-Ex2 --> [%0.3f %0.3f] A%0.3f D%0.3f\n", + trvTrk->pos.x, trvTrk->pos.y, trvTrk->angle, *distR ) ) return TRUE; } @@ -998,7 +1056,7 @@ static BOOL_T EnumerateCornu( track_p trk ) struct extraDataCornu_t *xx = GET_EXTRA_DATA(trk, T_CORNU, extraDataCornu_t); DIST_T d; d = max(CornuOffsetLength(xx->arcSegs,-GetTrkGauge(trk)/2.0), - CornuOffsetLength(xx->arcSegs,GetTrkGauge(trk)/2.0)); + CornuOffsetLength(xx->arcSegs,GetTrkGauge(trk)/2.0)); ScaleLengthIncrement( GetTrkScale(trk), d ); return TRUE; } @@ -1006,40 +1064,38 @@ static BOOL_T EnumerateCornu( track_p trk ) } static BOOL_T MergeCornu( - track_p trk0, - EPINX_T ep0, - track_p trk1, - EPINX_T ep1 ) + track_p trk0, + EPINX_T ep0, + track_p trk1, + EPINX_T ep1 ) { return FALSE; } -BOOL_T GetBezierSegmentsFromCornu(track_p trk, dynArr_t * segs, BOOL_T track) { +BOOL_T GetBezierSegmentsFromCornu(track_p trk, dynArr_t * segs, BOOL_T track) +{ struct extraDataCornu_t * xx = GET_EXTRA_DATA(trk, T_CORNU, extraDataCornu_t); - for (int i=0;i<xx->arcSegs.cnt;i++) { - trkSeg_p p = (trkSeg_t *) xx->arcSegs.ptr+i; + for (int i=0; i<xx->arcSegs.cnt; i++) { + trkSeg_p p = &DYNARR_N(trkSeg_t,xx->arcSegs,i); if (p->type == SEG_BEZTRK) { if (track) { DYNARR_APPEND(trkSeg_t, * segs, 10); trkSeg_p segPtr = &DYNARR_N(trkSeg_t,* segs,segs->cnt-1); segPtr->type = SEG_BEZTRK; segPtr->color = wDrawColorBlack; - segPtr->width = 0; - if (segPtr->bezSegs.ptr) MyFree(segPtr->bezSegs.ptr); - segPtr->bezSegs.cnt = 0; - segPtr->bezSegs.max = 0; - segPtr->bezSegs.ptr = NULL; - for (int j=0;j<4;j++) segPtr->u.b.pos[j] = p->u.b.pos[j]; + segPtr->lineWidth = 0; + DYNARR_FREE( trkSeg_t, segPtr->bezSegs ); + for (int j=0; j<4; j++) { segPtr->u.b.pos[j] = p->u.b.pos[j]; } FixUpBezierSeg(segPtr->u.b.pos,segPtr,TRUE); } else { - for (int j=0;j<p->bezSegs.cnt;j++) { + for (int j=0; j<p->bezSegs.cnt; j++) { trkSeg_p bez_p = &DYNARR_N(trkSeg_t,p->bezSegs,j); DYNARR_APPEND(trkSeg_t, * segs, 10); trkSeg_p segPtr = &DYNARR_LAST(trkSeg_t,* segs); - if (bez_p->type == SEG_CRVTRK) segPtr->type = SEG_CRVLIN; - if (bez_p->type == SEG_STRTRK) segPtr->type = SEG_STRLIN; + if (bez_p->type == SEG_CRVTRK) { segPtr->type = SEG_CRVLIN; } + if (bez_p->type == SEG_STRTRK) { segPtr->type = SEG_STRLIN; } segPtr->u = bez_p->u; - segPtr->width = bez_p->width; + segPtr->lineWidth = bez_p->lineWidth; segPtr->color = bez_p->color; } } @@ -1048,8 +1104,8 @@ BOOL_T GetBezierSegmentsFromCornu(track_p trk, dynArr_t * segs, BOOL_T track) { trkSeg_p segPtr = &DYNARR_N(trkSeg_t,* segs,segs->cnt-1); segPtr->type = track?SEG_STRTRK:SEG_STRLIN; segPtr->color = wDrawColorBlack; - segPtr->width = 0; - for (int j=0;j<2;j++) segPtr->u.l.pos[i] = p->u.l.pos[i]; + segPtr->lineWidth = 0; + for (int j=0; j<2; j++) { segPtr->u.l.pos[i] = p->u.l.pos[i]; } segPtr->u.l.angle = p->u.l.angle; segPtr->u.l.option = 0; } else if (p->type == SEG_CRVTRK) { @@ -1057,7 +1113,7 @@ BOOL_T GetBezierSegmentsFromCornu(track_p trk, dynArr_t * segs, BOOL_T track) { trkSeg_p segPtr = &DYNARR_N(trkSeg_t,* segs,segs->cnt-1); segPtr->type = track?SEG_CRVTRK:SEG_CRVLIN; segPtr->color = wDrawColorBlack; - segPtr->width = 0; + segPtr->lineWidth = 0; segPtr->u.c.a0 = p->u.c.a0; segPtr->u.c.a1 = p->u.c.a1; segPtr->u.c.center = p->u.c.center; @@ -1073,19 +1129,21 @@ static DIST_T GetLengthCornu( track_p trk ) struct extraDataCornu_t *xx = GET_EXTRA_DATA(trk, T_CORNU, extraDataCornu_t); DIST_T length = 0.0; segProcData_t segProcData; - for(int i=0;i<xx->arcSegs.cnt;i++) { + for(int i=0; i<xx->arcSegs.cnt; i++) { trkSeg_t seg = DYNARR_N(trkSeg_t,xx->arcSegs,i); - if (seg.type == SEG_FILCRCL) continue; + if (seg.type == SEG_FILCRCL) { continue; } SegProc(SEGPROC_LENGTH, &seg, &segProcData); length += segProcData.length.length; } return length; } -EXPORT BOOL_T GetCornuMiddle( track_p trk, coOrd * pos) { +EXPORT BOOL_T GetCornuMiddle( track_p trk, coOrd * pos) +{ - if (GetTrkType(trk) != T_CORNU) + if (GetTrkType(trk) != T_CORNU) { return FALSE; + } DIST_T length = GetLengthCornu(trk)/2; traverseTrack_t tp; @@ -1103,19 +1161,21 @@ EXPORT BOOL_T GetCornuMiddle( track_p trk, coOrd * pos) { } -static BOOL_T GetParamsCornu( int inx, track_p trk, coOrd pos, trackParams_t * params ) +static BOOL_T GetParamsCornu( int inx, track_p trk, coOrd pos, + trackParams_t * params ) { int segInx, segInx2; BOOL_T back, negative; DIST_T d; struct extraDataCornu_t *xx = GET_EXTRA_DATA(trk, T_CORNU, extraDataCornu_t); params->type = curveTypeCornu; - params->track_angle = GetAngleSegs( //Find correct Segment and nearest point in it - xx->arcSegs.cnt,xx->arcSegs.ptr, - &pos, &segInx, &d , &back, &segInx2, &negative ); - if (segInx ==-1) return FALSE; + params->track_angle = + GetAngleSegs( //Find correct Segment and nearest point in it + xx->arcSegs.cnt,&DYNARR_N(trkSeg_t,xx->arcSegs,0), + &pos, &segInx, &d, &back, &segInx2, &negative ); + if (segInx ==-1) { return FALSE; } trkSeg_p segPtr = &DYNARR_N(trkSeg_t,xx->arcSegs,segInx); - if (negative != back) params->track_angle = NormalizeAngle(params->track_angle+180); //Cornu is in reverse + if (negative != back) { params->track_angle = NormalizeAngle(params->track_angle+180); } //Cornu is in reverse if (segPtr->type == SEG_STRTRK) { params->arcR = 0.0; } else if (segPtr->type == SEG_CRVTRK) { @@ -1134,7 +1194,7 @@ static BOOL_T GetParamsCornu( int inx, track_p trk, coOrd pos, trackParams_t * p params->arcA1 = segPtr2->u.c.a1; } } - for (int i=0;i<2;i++) { + for (int i=0; i<2; i++) { params->cornuEnd[i] = xx->pos[i]; params->cornuAngle[i] = xx->a[i]; params->cornuRadius[i] = xx->r[i]; @@ -1143,13 +1203,14 @@ static BOOL_T GetParamsCornu( int inx, track_p trk, coOrd pos, trackParams_t * p params->len = xx->length; if ( inx == PARAMS_NODES ) { return FALSE; - } else if ((inx == PARAMS_CORNU) || (inx == PARAMS_1ST_JOIN) || (inx == PARAMS_2ND_JOIN) ) { + } else if ((inx == PARAMS_CORNU) || (inx == PARAMS_1ST_JOIN) + || (inx == PARAMS_2ND_JOIN) ) { params->ep = PickEndPoint( pos, trk); } else { params->ep = PickUnconnectedEndPointSilent( pos, trk ); } - if (params->ep == -1) return FALSE; + if (params->ep == -1) { return FALSE; } if (params->ep>=0) { params->angle = GetTrkEndAngle(trk,params->ep); @@ -1174,7 +1235,7 @@ static BOOL_T QueryCornu( track_p trk, int query ) case Q_EXCEPTION: { struct extraDataCornu_t * xx = GET_EXTRA_DATA(trk, T_CORNU, extraDataCornu_t); return fabs(xx->minCurveRadius) < (GetLayoutMinTrackRadius()-EPSILON); - } + } case Q_IS_CORNU: return TRUE; break; @@ -1189,6 +1250,7 @@ static BOOL_T QueryCornu( track_p trk, int query ) case Q_CANNOT_PLACE_TURNOUT: return FALSE; break; + case Q_CORNU_CAN_MODIFY: case Q_IGNORE_EASEMENT_ON_EXTEND: return TRUE; break; @@ -1201,9 +1263,9 @@ static BOOL_T QueryCornu( track_p trk, int query ) static void FlipCornu( - track_p trk, - coOrd orig, - ANGLE_T angle ) + track_p trk, + coOrd orig, + ANGLE_T angle ) { struct extraDataCornu_t * xx = GET_EXTRA_DATA(trk, T_CORNU, extraDataCornu_t); FlipPoint( &xx->pos[0], orig, angle ); @@ -1227,155 +1289,161 @@ static void FlipCornu( xx->r[0] = xx->r[1]; xx->r[1] = rad_save; - RebuildCornu(trk); + RebuildCornu(trk); } static ANGLE_T GetAngleCornu( - track_p trk, - coOrd pos, - EPINX_T * ep0, - EPINX_T * ep1 ) + track_p trk, + coOrd pos, + EPINX_T * ep0, + EPINX_T * ep1 ) { struct extraDataCornu_t * xx = GET_EXTRA_DATA(trk, T_CORNU, extraDataCornu_t); ANGLE_T angle; BOOL_T back, neg; int indx; - angle = GetAngleSegs( xx->arcSegs.cnt, (trkSeg_p)xx->arcSegs.ptr, &pos, &indx, NULL, &back, NULL, &neg ); - if (!back) angle = NormalizeAngle(angle+180); - if ( ep0 ) *ep0 = neg?1:0; - if ( ep1 ) *ep1 = neg?0:1; + angle = GetAngleSegs( xx->arcSegs.cnt, &DYNARR_N(trkSeg_t,xx->arcSegs,0), &pos, + &indx, NULL, &back, NULL, &neg ); + if (!back) { angle = NormalizeAngle(angle+180); } + if ( ep0 ) { *ep0 = neg?1:0; } + if ( ep1 ) { *ep1 = neg?0:1; } return angle; } -BOOL_T GetCornuSegmentFromTrack(track_p trk, trkSeg_p seg_p) { +BOOL_T GetCornuSegmentFromTrack(track_p trk, trkSeg_p seg_p) +{ //TODO If we support Group return TRUE; } -static dynArr_t cornuSegs_da; +//static dynArr_t cornuSegs_da; static BOOL_T MakeParallelCornu( - track_p trk, - coOrd pos, - DIST_T sep, - DIST_T factor, - track_p * newTrkR, - coOrd * p0R, - coOrd * p1R, - BOOL_T track ) + track_p trk, + coOrd pos, + DIST_T sep, + DIST_T factor, + track_p * newTrkR, + coOrd * p0R, + coOrd * p1R, + BOOL_T track ) { - coOrd np[4], p, nc[2]; - ANGLE_T atrk, diff_a, na[2]; - DIST_T nr[2]; + coOrd np[4], p, nc[2]; + ANGLE_T atrk, diff_a, na[2]; + DIST_T nr[2]; //Produce cornu that is translated parallel to the existing Cornu - // - not a precise result if the cornu end angles are not in the same general direction. - // The expectation is that the user will have to adjust it - unless and until we produce - // a new algo to adjust the control points to be parallel to the endpoints. - - p = pos; - DistanceCornu(trk, &p); //Find nearest point on curve + // - not a precise result if the cornu end angles are not in the same general direction. + // The expectation is that the user will have to adjust it - unless and until we produce + // a new algo to adjust the control points to be parallel to the endpoints. + + p = pos; + DistanceCornu(trk, &p); //Find nearest point on curve struct extraDataCornu_t * xx = GET_EXTRA_DATA(trk, T_CORNU, extraDataCornu_t); - atrk = GetAngleSegs(xx->arcSegs.cnt,(trkSeg_t *)(xx->arcSegs.ptr),&p,NULL,NULL,NULL,NULL, NULL); - diff_a = NormalizeAngle(FindAngle(pos,p)-atrk); //we know it will be +/-90... - //find parallel move x and y for points - BOOL_T above = FALSE; - if ( diff_a < 180 ) above = TRUE; //Above track - if (xx->a[0] <180) above = !above; - DIST_T sep0 = sep+((xx->r[0]!=0.0)?fabs(factor/xx->r[0]):0); - DIST_T sep1 = sep+((xx->r[1]!=0.0)?fabs(factor/xx->r[1]):0); - Translate(&np[0],xx->pos[0],xx->a[0]+(above?90:-90),sep0); - Translate(&np[1],xx->pos[1],xx->a[1]+(above?-90:90),sep1); - na[0]=xx->a[0]; - na[1]=xx->a[1]; - if (xx->r[0] != 0.0) { - //Find angle between center and end angle of track - ANGLE_T ea0 = - NormalizeAngle(FindAngle(xx->c[0],xx->pos[0])-xx->a[0]); - if (ea0>180) sep0 = -sep0; - nr[0]=xx->r[0]+(above?sep0:-sep0); //Needs adjustment - nc[0]=xx->c[0]; - } else { - nr[0] = 0.0; - nc[0] = zero; - } - - if (xx->r[1] != 0.0) { - ANGLE_T ea1 = - NormalizeAngle(FindAngle(xx->c[1],xx->pos[1])-xx->a[1]); - if (ea1<180) sep1 = -sep1; - nr[1]=xx->r[1]+(above?sep1:-sep1); //Needs adjustment - nc[1]=xx->c[1]; - } else { - nr[1] = 0.0; - nc[1] = zero; - } + atrk = GetAngleSegs(xx->arcSegs.cnt,&DYNARR_N(trkSeg_t,xx->arcSegs,0),&p, + NULL, NULL, NULL,NULL, NULL); + diff_a = NormalizeAngle(FindAngle(pos,p)-atrk); //we know it will be +/-90... + //find parallel move x and y for points + BOOL_T above = FALSE; + if ( diff_a < 180 ) { above = TRUE; } //Above track + if (xx->a[0] <180) { above = !above; } + DIST_T sep0 = sep+((xx->r[0]!=0.0)?fabs(factor/xx->r[0]):0); + DIST_T sep1 = sep+((xx->r[1]!=0.0)?fabs(factor/xx->r[1]):0); + Translate(&np[0],xx->pos[0],xx->a[0]+(above?90:-90),sep0); + Translate(&np[1],xx->pos[1],xx->a[1]+(above?-90:90),sep1); + na[0]=xx->a[0]; + na[1]=xx->a[1]; + if (xx->r[0] != 0.0) { + //Find angle between center and end angle of track + ANGLE_T ea0 = + NormalizeAngle(FindAngle(xx->c[0],xx->pos[0])-xx->a[0]); + if (ea0>180) { sep0 = -sep0; } + nr[0]=xx->r[0]+(above?sep0:-sep0); //Needs adjustment + nc[0]=xx->c[0]; + } else { + nr[0] = 0.0; + nc[0] = zero; + } + + if (xx->r[1] != 0.0) { + ANGLE_T ea1 = + NormalizeAngle(FindAngle(xx->c[1],xx->pos[1])-xx->a[1]); + if (ea1<180) { sep1 = -sep1; } + nr[1]=xx->r[1]+(above?sep1:-sep1); //Needs adjustment + nc[1]=xx->c[1]; + } else { + nr[1] = 0.0; + nc[1] = zero; + } if ( newTrkR ) { if (track) { *newTrkR = NewCornuTrack( np, nc, na, nr, NULL, 0); if (*newTrkR==NULL) { wBeep(); - InfoMessage(_("Cornu Create Failed for p1[%0.3f,%0.3f] p2[%0.3f,%0.3f], c1[%0.3f,%0.3f] c2[%0.3f,%0.3f], a1=%0.3f a2=%0.3f, r1=%s r2=%s"), - np[0].x,np[0].y, - np[1].x,np[1].y, - nc[0].x,nc[0].y, - nc[1].x,nc[1].y, - na[0],na[1], - FormatDistance(nr[0]),FormatDistance(nr[1])); + InfoMessage( + _("Cornu Create Failed for p1[%0.3f,%0.3f] p2[%0.3f,%0.3f], c1[%0.3f,%0.3f] c2[%0.3f,%0.3f], a1=%0.3f a2=%0.3f, r1=%s r2=%s"), + np[0].x,np[0].y, + np[1].x,np[1].y, + nc[0].x,nc[0].y, + nc[1].x,nc[1].y, + na[0],na[1], + FormatDistance(nr[0]),FormatDistance(nr[1])); return FALSE; } } else { - tempSegs_da.cnt = 0; + DYNARR_RESET( trkSeg_t, tempSegs_da ); CallCornu0(np,nc,na,nr,&tempSegs_da,FALSE); *newTrkR = MakePolyLineFromSegs( zero, 0.0, &tempSegs_da ); } } else { - tempSegs_da.cnt = 0; + DYNARR_RESET( trkSeg_t, tempSegs_da ); CallCornu0(np,nc,na,nr,&tempSegs_da,FALSE); if (!track) { - for (int i=0;i<tempSegs_da.cnt;i++) { + for (int i=0; i<tempSegs_da.cnt; i++) { trkSeg_p seg = &tempSegs(i); if (seg->type == SEG_STRTRK) { seg->type = SEG_STRLIN; seg->color = wDrawColorBlack; - seg->width = 0; + seg->lineWidth = 0; } if (seg->type == SEG_CRVTRK) { seg->type = SEG_CRVLIN; seg->color = wDrawColorBlack; - seg->width = 0; + seg->lineWidth = 0; } if (seg->type == SEG_BEZTRK) { - for (int j=0;j<seg->bezSegs.cnt;j++) { - trkSeg_p bseg = &(((trkSeg_t *)seg->bezSegs.ptr)[j]); + for (int j=0; j<seg->bezSegs.cnt; j++) { + trkSeg_p bseg = &DYNARR_N(trkSeg_t,seg->bezSegs,j); if (bseg->type == SEG_STRTRK) { bseg->type = SEG_STRLIN; bseg->color = wDrawColorBlack; - bseg->width = 0; + bseg->lineWidth = 0; } if (bseg->type == SEG_CRVTRK) { bseg->type = SEG_CRVLIN; bseg->color = wDrawColorBlack; - bseg->width = 0; + bseg->lineWidth = 0; } } seg->type = SEG_BEZLIN; seg->color = wDrawColorBlack; - seg->width = 0; + seg->lineWidth = 0; } } } } - if ( p0R ) *p0R = np[0]; - if ( p1R ) *p1R = np[1]; + if ( p0R ) { *p0R = np[0]; } + if ( p1R ) { *p1R = np[1]; } return TRUE; } -static BOOL_T TrimCornu( track_p trk, EPINX_T ep, DIST_T dist, coOrd endpos, ANGLE_T angle, DIST_T radius, coOrd center ) { +static BOOL_T TrimCornu( track_p trk, EPINX_T ep, DIST_T dist, coOrd endpos, + ANGLE_T angle, DIST_T radius, coOrd center ) +{ UndoModify(trk); if (dist>0.0 && dist<minLength) { UndrawNewTrack( trk ); @@ -1406,11 +1474,9 @@ EXPORT BOOL_T RebuildCornu (track_p trk) { struct extraDataCornu_t *xx; xx = GET_EXTRA_DATA(trk, T_CORNU, extraDataCornu_t); - xx->arcSegs.max = 0; - xx->arcSegs.cnt = 0; - //if (xx->arcSegs.ptr) MyFree(xx->arcSegs.ptr); - xx->arcSegs.ptr = NULL; - if (!FixUpCornu0(xx->pos,xx->c,xx->a,xx->r, xx)) return FALSE; + //NOTE - Original code did not Free .ptr? See CS:c1b85944f448 + DYNARR_INIT( trkSeg_t, xx->arcSegs ); + if (!FixUpCornu0(xx->pos,xx->c,xx->a,xx->r, xx)) { return FALSE; } ComputeCornuBoundingBox(trk, xx); return TRUE; } @@ -1418,8 +1484,10 @@ EXPORT BOOL_T RebuildCornu (track_p trk) static wBool_t CompareCornu( track_cp trk1, track_cp trk2 ) { - struct extraDataCornu_t *xx1 = GET_EXTRA_DATA( trk1, T_CORNU, extraDataCornu_t ); - struct extraDataCornu_t *xx2 = GET_EXTRA_DATA( trk2, T_CORNU, extraDataCornu_t ); + struct extraDataCornu_t *xx1 = GET_EXTRA_DATA( trk1, T_CORNU, + extraDataCornu_t ); + struct extraDataCornu_t *xx2 = GET_EXTRA_DATA( trk2, T_CORNU, + extraDataCornu_t ); char * cp = message + strlen(message); REGRESS_CHECK_POS( "Pos[0]", xx1, xx2, pos[0] ) REGRESS_CHECK_POS( "Pos[1]", xx1, xx2, pos[1] ) @@ -1440,42 +1508,42 @@ static wBool_t CompareCornu( track_cp trk1, track_cp trk2 ) } static trackCmd_t cornuCmds = { - "CORNU", - DrawCornu, - DistanceCornu, - DescribeCornu, - DeleteCornu, - WriteCornu, - ReadCornu, - MoveCornu, - RotateCornu, - RescaleCornu, - NULL, - GetAngleCornu, - SplitCornu, - TraverseCornu, - EnumerateCornu, - NULL, /* redraw */ - TrimCornu, /* trim */ - MergeCornu, - NULL, /* modify */ - GetLengthCornu, - GetParamsCornu, - MoveCornuEndPt, /* Move EndPt */ - QueryCornu, - NULL, /* ungroup */ - FlipCornu, - NULL, - NULL, - NULL, - MakeParallelCornu, - NULL, - RebuildCornu, - NULL, - NULL, - NULL, - CompareCornu - }; + "CORNU", + DrawCornu, + DistanceCornu, + DescribeCornu, + DeleteCornu, + WriteCornu, + ReadCornu, + MoveCornu, + RotateCornu, + RescaleCornu, + NULL, + GetAngleCornu, + SplitCornu, + TraverseCornu, + EnumerateCornu, + NULL, /* redraw */ + TrimCornu, /* trim */ + MergeCornu, + NULL, /* modify */ + GetLengthCornu, + GetParamsCornu, + MoveCornuEndPt, /* Move EndPt */ + QueryCornu, + NULL, /* ungroup */ + FlipCornu, + NULL, + NULL, + NULL, + MakeParallelCornu, + NULL, + RebuildCornu, + NULL, + NULL, + NULL, + CompareCornu +}; @@ -1490,26 +1558,29 @@ static trackCmd_t cornuCmds = { -track_p NewCornuTrack(coOrd pos[2], coOrd center[2],ANGLE_T angle[2], DIST_T radius[2], trkSeg_t * tempsegs, int count) +track_p NewCornuTrack(coOrd pos[2], coOrd center[2],ANGLE_T angle[2], + DIST_T radius[2], trkSeg_t * tempsegs, int count) { struct extraDataCornu_t *xx; track_p p; p = NewTrack( 0, T_CORNU, 2, sizeof *xx ); xx = GET_EXTRA_DATA(p, T_CORNU, extraDataCornu_t); - xx->pos[0] = pos[0]; - xx->pos[1] = pos[1]; - xx->a[0] = angle[0]; - xx->a[1] = angle[1]; - xx->r[0] = radius[0]; - xx->r[1] = radius[1]; - xx->c[0] = center[0]; - xx->c[1] = center[1]; - - if (!FixUpCornu0(xx->pos,xx->c,xx->a,xx->r, xx)) { - ErrorMessage("Create Cornu Failed"); - return NULL; + xx->pos[0] = pos[0]; + xx->pos[1] = pos[1]; + xx->a[0] = angle[0]; + xx->a[1] = angle[1]; + xx->r[0] = radius[0]; + xx->r[1] = radius[1]; + xx->c[0] = center[0]; + xx->c[1] = center[1]; + + if (!FixUpCornu0(xx->pos,xx->c,xx->a,xx->r, xx)) { + ErrorMessage("Create Cornu Failed"); + return NULL; } -LOG( log_cornu, 1, ( "NewCornuTrack( EP1 %0.3f, %0.3f, EP2 %0.3f, %0.3f ) = %d\n", pos[0].x, pos[0].y, pos[1].x, pos[1].y, GetTrkIndex(p) ) ) + LOG( log_cornu, 1, + ( "NewCornuTrack( EP1 %0.3f, %0.3f, EP2 %0.3f, %0.3f ) = %d\n", pos[0].x, + pos[0].y, pos[1].x, pos[1].y, GetTrkIndex(p) ) ) ComputeCornuBoundingBox( p, xx ); SetTrkEndPoint( p, 0, pos[0], xx->a[0]); SetTrkEndPoint( p, 1, pos[1], xx->a[1]); diff --git a/app/bin/tcornu.h b/app/bin/tcornu.h index 7245dfd..cc4ddcf 100644 --- a/app/bin/tcornu.h +++ b/app/bin/tcornu.h @@ -16,50 +16,58 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "common.h" typedef struct extraDataCornu_t { - extraDataBase_t base; - coOrd pos[2]; - coOrd c[2]; - ANGLE_T a[2]; - DIST_T r[2]; - DIST_T minCurveRadius; - DIST_T maxRateofChange; - DIST_T length; - ANGLE_T windingAngle; - dynArr_t arcSegs; - coOrd descriptionOff; - char * cornuPath; - } extraDataCornu_t; + extraDataBase_t base; + coOrd pos[4]; + coOrd c[2]; + ANGLE_T a[2]; + DIST_T r[2]; + DIST_T minCurveRadius; + DIST_T maxRateofChange; + DIST_T length; + ANGLE_T windingAngle; + dynArr_t arcSegs; + coOrd descriptionOff; + char * cornuPath; +} extraDataCornu_t; typedef struct { - coOrd pos[2]; //All values for end if trk[end] = NULL - DIST_T radius[2]; //0.0 if straight - ANGLE_T angle[2]; //Set if straight - coOrd center[2]; //Set if radius >0 - dynArr_t mids; //If there are G2 points added - } cornuParm_t; + coOrd pos[2]; //All values for end if trk[end] = NULL + DIST_T radius[2]; //0.0 if straight + ANGLE_T angle[2]; //Set if straight + coOrd center[2]; //Set if radius >0 + dynArr_t mids; //If there are G2 points added +} cornuParm_t; double CornuMaxCurve(coOrd[2],ANGLE_T[2],DIST_T[2]); double BezierMathMinRadius(coOrd[4]); -coOrd BezierMathFindNearestPoint(coOrd *, coOrd[4] , int ); -track_p NewCornuTrack(coOrd pos[2], coOrd center[2], ANGLE_T angle[2], DIST_T radius[2], trkSeg_p tempsegs, int count); -DIST_T CornuDistance( coOrd *, coOrd[2], ANGLE_T[2], DIST_T[2], trkSeg_p ,int , double * ); -BOOL_T FixUpCornu(coOrd pos[2], track_p [2], EPINX_T ep[2], struct extraDataCornu_t* xx); -BOOL_T FixUpCornu0(coOrd pos[2], coOrd center[2], ANGLE_T angle[2], DIST_T radius[2], struct extraDataCornu_t* xx); +coOrd BezierMathFindNearestPoint(coOrd *, coOrd[4], int ); +track_p NewCornuTrack(coOrd pos[2], coOrd center[2], ANGLE_T angle[2], + DIST_T radius[2], trkSeg_p tempsegs, int count); +DIST_T CornuDistance( coOrd *, coOrd[2], ANGLE_T[2], DIST_T[2], trkSeg_p,int, + double * ); +BOOL_T FixUpCornu(coOrd pos[4], track_p [2], EPINX_T ep[2], + struct extraDataCornu_t* xx); +BOOL_T FixUpCornu0(coOrd pos[4], coOrd center[2], ANGLE_T angle[2], + DIST_T radius[2], struct extraDataCornu_t* xx); BOOL_T GetCornuSegmentsFromTrack(track_p, trkSeg_p); -BOOL_T SetCornuEndPt(track_p trk, EPINX_T inx, coOrd pos, coOrd center, ANGLE_T angle, DIST_T radius); +BOOL_T SetCornuEndPt(track_p trk, EPINX_T inx, coOrd pos, coOrd center, + ANGLE_T angle, DIST_T radius); BOOL_T RebuildCornu (track_p trk); DIST_T DistanceCornu( track_p t, coOrd * p ); STATUS_T CornuDescriptionMove(track_p trk,wAction_t action,coOrd pos ); -DIST_T CornuDescriptionDistance(coOrd pos,track_p trk, coOrd *, BOOL_T show_hidden, BOOL_T * hidden ); -void GetCornuParmsNear(track_p t, int sel, coOrd * pos, coOrd * center, ANGLE_T * angle, DIST_T * radius ); -void GetCornuParmsTemp(dynArr_t *, int sel, coOrd * pos2, coOrd * center, ANGLE_T * angle2, DIST_T * radius ); +DIST_T CornuDescriptionDistance(coOrd pos,track_p trk, coOrd *, + BOOL_T show_hidden, BOOL_T * hidden ); +void GetCornuParmsNear(track_p t, int sel, coOrd * pos, coOrd * center, + ANGLE_T * angle, DIST_T * radius ); +void GetCornuParmsTemp(dynArr_t *, int sel, coOrd * pos2, coOrd * center, + ANGLE_T * angle2, DIST_T * radius ); BOOL_T CallCornu(coOrd[2],track_p[2],EPINX_T[2],dynArr_t *,cornuParm_t *); BOOL_T CallCornu0(coOrd[2], coOrd[2], ANGLE_T[2], DIST_T[2], dynArr_t *,BOOL_T); diff --git a/app/bin/tcurve.c b/app/bin/tcurve.c index f133dc7..65b6bcc 100644 --- a/app/bin/tcurve.c +++ b/app/bin/tcurve.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "ccurve.h" @@ -33,13 +33,13 @@ static TRKTYP_T T_CURVE = -1; typedef struct extraDataCurve_t { - extraDataBase_t base; - coOrd pos; - DIST_T radius; - BOOL_T circle; - long helixTurns; - coOrd descriptionOff; - } extraDataCurve_t; + extraDataBase_t base; + coOrd pos; + DIST_T radius; + BOOL_T circle; + long helixTurns; + coOrd descriptionOff; +} extraDataCurve_t; static int log_curve = 0; static int log_curveSegs = 0; @@ -54,20 +54,21 @@ static DIST_T GetLengthCurve( track_p ); static void GetCurveAngles( ANGLE_T *a0, ANGLE_T *a1, track_p trk ) { - assert( trk != NULL ); + CHECK( trk != NULL ); struct extraDataCurve_t *xx = GET_EXTRA_DATA(trk, T_CURVE, extraDataCurve_t); if (xx->circle != TRUE) { *a0 = NormalizeAngle( GetTrkEndAngle(trk,0) + 90 ); *a1 = NormalizeAngle( - GetTrkEndAngle(trk,1) - GetTrkEndAngle(trk,0) + 180 ); + GetTrkEndAngle(trk,1) - GetTrkEndAngle(trk,0) + 180 ); } else { *a0 = 0.0; *a1 = 360.0; } -LOG( log_curve, 4, ( "getCurveAngles: = %0.3f %0.3f\n", *a0, *a1 ) ) + LOG( log_curve, 4, ( "getCurveAngles: = %0.3f %0.3f\n", *a0, *a1 ) ) } -static void SetCurveAngles( track_p p, ANGLE_T a0, ANGLE_T a1, struct extraDataCurve_t * xx ) +static void SetCurveAngles( track_p p, ANGLE_T a0, ANGLE_T a1, + struct extraDataCurve_t * xx ) { coOrd pos0, pos1; xx->circle = (a0 == 0.0 && a1 == 0.0); @@ -106,14 +107,13 @@ static void AdjustCurveEndPt( track_p t, EPINX_T inx, ANGLE_T a ) { coOrd pos; ANGLE_T aa; - if (GetTrkType(t) != T_CURVE) { - AbortProg( "AdjustCurveEndPt( %d, %d ) not on CURVE %d", - GetTrkIndex(t), inx, GetTrkType(t) ); - return; - } + CHECKMSG( GetTrkType(t) == T_CURVE, + ( "AdjustCurveEndPt( %d, %d ) not on CURVE %d", + GetTrkIndex(t), inx, GetTrkType(t) ) ); struct extraDataCurve_t *xx = GET_EXTRA_DATA(t, T_CURVE, extraDataCurve_t); UndoModify( t ); -LOG( log_curve, 1, ( "adjustCurveEndPt T%d[%d] a=%0.3f\n", GetTrkIndex(t), inx, a ) ) + LOG( log_curve, 1, ( "adjustCurveEndPt T%d[%d] a=%0.3f\n", GetTrkIndex(t), inx, + a ) ) aa = a = NormalizeAngle(a); a += inx==0?90.0:-90.0; (void)PointOnCircle( &pos, xx->pos, xx->radius, a ); @@ -123,9 +123,9 @@ LOG( log_curve, 1, ( "adjustCurveEndPt T%d[%d] a=%0.3f\n", GetTrkIndex(t), inx, SetTrkEndPoint( t, 1-inx, pos, a ); xx->circle = 0; } -LOG( log_curve, 1, ( " E0:[%0.3f %0.3f] A%0.3f, E1:[%0.3f %0.3f] A%0.3f\n", - GetTrkEndPosXY(t,0), GetTrkEndAngle(t,0), - GetTrkEndPosXY(t,1), GetTrkEndAngle(t,1) ) ) + LOG( log_curve, 1, ( " E0:[%0.3f %0.3f] A%0.3f, E1:[%0.3f %0.3f] A%0.3f\n", + GetTrkEndPosXY(t,0), GetTrkEndAngle(t,0), + GetTrkEndPosXY(t,1), GetTrkEndAngle(t,1) ) ) ComputeCurveBoundingBox( t, xx ); CheckTrackLength( t ); } @@ -140,8 +140,9 @@ static void GetTrkCurveCenter( track_p t, coOrd *p, DIST_T *r ) BOOL_T IsCurveCircle( track_p t ) { struct extraDataCurve_t *xx; - if ( GetTrkType(t) != T_CURVE ) + if ( GetTrkType(t) != T_CURVE ) { return FALSE; + } xx = GET_EXTRA_DATA(t, T_CURVE, extraDataCurve_t); return xx->circle || xx->helixTurns>0; } @@ -151,8 +152,9 @@ BOOL_T GetCurveMiddle( track_p trk, coOrd * pos ) { struct extraDataCurve_t *xx; ANGLE_T a0, a1; - if ( GetTrkType(trk) != T_CURVE ) + if ( GetTrkType(trk) != T_CURVE ) { return FALSE; + } xx = GET_EXTRA_DATA(trk, T_CURVE, extraDataCurve_t); if (xx->circle || xx->helixTurns>0) { PointOnCircle( pos, xx->pos, xx->radius, 0 ); @@ -166,54 +168,59 @@ BOOL_T GetCurveMiddle( track_p trk, coOrd * pos ) static DIST_T DistanceCurve( track_p t, coOrd * p ); DIST_T CurveDescriptionDistance( - coOrd pos, - track_p trk, - coOrd * dpos, - BOOL_T show_hidden, - BOOL_T * hidden) + coOrd pos, + track_p trk, + coOrd * dpos, + BOOL_T show_hidden, + BOOL_T * hidden) { - coOrd p0,p1,pd; + coOrd pd; +// coOrd p0,p1; FLOAT_T ratio; ANGLE_T a, a0, a1; - if (hidden) *hidden = FALSE; - if ( (GetTrkType( trk ) != T_CURVE ) || ((( GetTrkBits( trk ) & TB_HIDEDESC ) != 0) && !show_hidden)) + if (hidden) { *hidden = FALSE; } + if ( (GetTrkType( trk ) != T_CURVE ) + || ((( GetTrkBits( trk ) & TB_HIDEDESC ) != 0) && !show_hidden)) { return DIST_INF; + } struct extraDataCurve_t *xx = GET_EXTRA_DATA(trk, T_CURVE, extraDataCurve_t); coOrd offset = xx->descriptionOff; - if (( GetTrkBits( trk ) & TB_HIDEDESC ) != 0) offset = zero; + if (( GetTrkBits( trk ) & TB_HIDEDESC ) != 0) { offset = zero; } if ( xx->helixTurns > 0 ) { pd.x = xx->pos.x + offset.x; pd.y = xx->pos.y + offset.y; - p0 = pd; - p1 = pd; +// p0 = pd; +// p1 = pd; } else { GetCurveAngles( &a0, &a1, trk ); ratio = offset.x; - if (!IsCurveCircle( trk )) + if (!IsCurveCircle( trk )) { a = NormalizeAngle(a0 + a1/2.0 + ratio * a1/ 2.0); - else + } else { a = NormalizeAngle(360.0*ratio+a0); + } ratio = offset.y+0.5; - if (ratio<0.0) ratio = 0.0; - if (ratio>1.0) ratio = 1.0; + if (ratio<0.0) { ratio = 0.0; } + if (ratio>1.0) { ratio = 1.0; } Translate( &pd, xx->pos, a, xx->radius * ratio ); } - if (hidden) *hidden = (GetTrkBits( trk ) & TB_HIDEDESC); + if (hidden) { *hidden = (GetTrkBits( trk ) & TB_HIDEDESC); } *dpos = pd; coOrd tpos = pos; - if (DistanceCurve(trk, &tpos)<FindDistance(pd, pos)) + if (DistanceCurve(trk, &tpos)<FindDistance(pd, pos)) { return DistanceCurve(trk, &pos); + } return FindDistance( pd, pos ); } static void DrawCurveDescription( - track_p trk, - drawCmd_p d, - wDrawColor color ) + track_p trk, + drawCmd_p d, + wDrawColor color ) { wFont_p fp; coOrd pos, p0, p1; @@ -222,10 +229,12 @@ static void DrawCurveDescription( ANGLE_T a, a0, a1; FLOAT_T ratio; - if (layoutLabels == 0) + if (layoutLabels == 0) { return; - if ((labelEnable&LABELENABLE_TRKDESC)==0) + } + if ((labelEnable&LABELENABLE_TRKDESC)==0) { return; + } struct extraDataCurve_t *xx = GET_EXTRA_DATA(trk, T_CURVE, extraDataCurve_t); if ( xx->helixTurns > 0 ) { @@ -235,11 +244,11 @@ static void DrawCurveDescription( dist = GetLengthCurve( trk ); elevValid = FALSE; if ( (!xx->circle) && - ComputeElev( trk, 0, FALSE, &elev0, NULL, FALSE ) && - ComputeElev( trk, 1, FALSE, &elev1, NULL, FALSE ) ) { - if( elev0 == elev1 ) + ComputeElev( trk, 0, FALSE, &elev0, NULL, FALSE ) && + ComputeElev( trk, 1, FALSE, &elev1, NULL, FALSE ) ) { + if( elev0 == elev1 ) { elevValid = FALSE; - else { + } else { elevValid = TRUE; grade = fabs((elev1-elev0)/dist); sep = grade*(xx->radius*M_PI*2.0); @@ -248,17 +257,19 @@ static void DrawCurveDescription( fp = wStandardFont( F_TIMES, FALSE, FALSE ); if (elevValid) sprintf( message, _("Helix: Turns %ld L %0.2f Grade %0.1f%% Sep %0.2f"), - xx->helixTurns, - dist, - grade*100.0, - sep ); + xx->helixTurns, + dist, + grade*100.0, + sep ); else sprintf( message, _("Helix: Turns %ld L %0.2f"), - xx->helixTurns, - dist ); - if (color == drawColorPreviewSelected) + xx->helixTurns, + dist ); + if (color == drawColorPreviewSelected) { DrawLine(d,xx->pos,pos,0,color); - DrawBoxedString( BOX_BOX, d, pos, message, fp, (wFontSize_t)descriptionFontSize, color, 0.0 ); + } + DrawBoxedString( BOX_BOX, d, pos, message, fp, (wFontSize_t)descriptionFontSize, + color, 0.0 ); } else { dist = trackGauge/2.0; DrawArc( d, xx->pos, dist, 0.0, 360.0, FALSE, 0, color ); @@ -270,10 +281,11 @@ static void DrawCurveDescription( DrawLine( d, p0, p1, 0, color ); GetCurveAngles( &a0, &a1, trk ); ratio = xx->descriptionOff.x; // 1.0 to - 1.0 - if (! IsCurveCircle( trk )) + if (! IsCurveCircle( trk )) { a = NormalizeAngle(ratio*a1/2.0 + a0 + a1/2.0); - else + } else { a = NormalizeAngle(ratio*360.0+a0); + } PointOnCircle( &p0, xx->pos, xx->radius, a ); coOrd end0, end1; DIST_T off; @@ -281,19 +293,24 @@ static void DrawCurveDescription( Translate(&end1,xx->pos,a0+a1,xx->radius); off = xx->radius-(cos(D2R(a1/2))*xx->radius); ratio = xx->descriptionOff.y; - if (ratio < -0.5) ratio = -0.5; - if (ratio > 0.5) ratio = 0.5; + if (ratio < -0.5) { ratio = -0.5; } + if (ratio > 0.5) { ratio = 0.5; } if (! IsCurveCircle(trk)) sprintf( message, "R %s L %s A %0.3f O %s", FormatDistance( xx->radius ), - FormatDistance(FindDistance(end0,end1)),FindAngle(end1,end0), FormatDistance(off)); - else - sprintf( message, "R %s L %s A 360.0", FormatDistance( xx->radius ),FormatDistance(xx->radius*2*M_PI)); - DrawDimLine( d, xx->pos, p0, message, (wFontSize_t)descriptionFontSize, ratio+0.5, 0, color, 0x00 ); + FormatDistance(FindDistance(end0,end1)),FindAngle(end1,end0), + FormatDistance(off)); + else { + sprintf( message, "R %s L %s A 360.0", FormatDistance( xx->radius ), + FormatDistance(xx->radius*2*M_PI)); + } + DrawDimLine( d, xx->pos, p0, message, (wFontSize_t)descriptionFontSize, + ratio+0.5, 0, color, 0x00 ); if (GetTrkBits( trk ) & TB_DETAILDESC) { coOrd details_pos; details_pos.x = (p0.x - xx->pos.x)*(ratio+0.5) + xx->pos.x; - details_pos.y = (p0.y - xx->pos.y)*(ratio+0.5) + xx->pos.y-(2*descriptionFontSize/mainD.dpi); + details_pos.y = (p0.y - xx->pos.y)*(ratio+0.5) + xx->pos.y- + (2*descriptionFontSize/mainD.dpi); AddTrkDetails(d, trk, details_pos, a1/180.0*M_PI*xx->radius, color); } @@ -303,27 +320,27 @@ static void DrawCurveDescription( STATUS_T CurveDescriptionMove( - track_p trk, - wAction_t action, - coOrd pos ) + track_p trk, + wAction_t action, + coOrd pos ) { struct extraDataCurve_t *xx = GET_EXTRA_DATA(trk, T_CURVE, extraDataCurve_t); - static coOrd p0,p1; - wDrawColor color; +// static coOrd p0,p1; +// wDrawColor color; ANGLE_T a, a0, a1; DIST_T d; - p0 = xx->pos; +// p0 = xx->pos; - color = GetTrkColor( trk, &mainD ); +// color = GetTrkColor( trk, &mainD ); if ( xx->helixTurns > 0 ) { xx->descriptionOff.x = (pos.x-xx->pos.x); xx->descriptionOff.y = (pos.y-xx->pos.y); - p1 = pos; +// p1 = pos; } else { - p1 = pos; +// p1 = pos; GetCurveAngles( &a0, &a1, trk ); - if ( a1 < 1 ) a1 = 1.0; + if ( a1 < 1 ) { a1 = 1.0; } a = FindAngle( xx->pos, pos ); if ( ! IsCurveCircle( trk ) ) { a = NormalizeAngle( a - a0 ); @@ -341,10 +358,12 @@ STATUS_T CurveDescriptionMove( xx->descriptionOff.x = NormalizeAngle((a - a0)/360.0); } d = FindDistance( xx->pos, pos ) / xx->radius; - if ( d > 1.0 ) + if ( d > 1.0 ) { d = 1.0; - if ( d < 0.0 ) + } + if ( d < 0.0 ) { d = 0.0; + } xx->descriptionOff.y = d-0.5; // -0.5 to 0.5, 0 in the middle } @@ -358,48 +377,51 @@ STATUS_T CurveDescriptionMove( */ static struct { - coOrd endPt[2]; - FLOAT_T elev[2]; - FLOAT_T length; - coOrd center; - DIST_T radius; - long turns; - DIST_T separation; - ANGLE_T angle0; - ANGLE_T angle1; - ANGLE_T angle; - FLOAT_T grade; - descPivot_t pivot; - unsigned int layerNumber; - } crvData; + coOrd endPt[2]; + FLOAT_T elev[2]; + FLOAT_T length; + coOrd center; + DIST_T radius; + long turns; + DIST_T separation; + ANGLE_T angle0; + ANGLE_T angle1; + ANGLE_T angle; + FLOAT_T grade; + descPivot_t pivot; + unsigned int layerNumber; +} crvData; typedef enum { E0, Z0, E1, Z1, CE, RA, TU, SE, LN, AL, A1, A2, GR, PV, LY } crvDesc_e; static descData_t crvDesc[] = { -/*E0*/ { DESC_POS, N_("End Pt 1: X,Y"), &crvData.endPt[0] }, -/*Z0*/ { DESC_DIM, N_("Z"), &crvData.elev[0] }, -/*E1*/ { DESC_POS, N_("End Pt 2: X,Y"), &crvData.endPt[1] }, -/*Z1*/ { DESC_DIM, N_("Z"), &crvData.elev[1] }, -/*CE*/ { DESC_POS, N_("Center: X,Y"), &crvData.center }, -/*RA*/ { DESC_DIM, N_("Radius"), &crvData.radius }, -/*TU*/ { DESC_LONG, N_("Turns"), &crvData.turns }, -/*SE*/ { DESC_DIM, N_("Separation"), &crvData.separation }, -/*LN*/ { DESC_DIM, N_("Length"), &crvData.length }, -/*AL*/ { DESC_FLOAT, N_("Angular Length"), &crvData.angle }, -/*A1*/ { DESC_ANGLE, N_("CCW Angle"), &crvData.angle0 }, -/*A2*/ { DESC_ANGLE, N_("CW Angle"), &crvData.angle1 }, -/*GR*/ { DESC_FLOAT, N_("Grade"), &crvData.grade }, -/*PV*/ { DESC_PIVOT, N_("Lock"), &crvData.pivot }, -/*LY*/ { DESC_LAYER, N_("Layer"), &crvData.layerNumber }, - { DESC_NULL } }; - -static void UpdateCurve( track_p trk, int inx, descData_p descUpd, BOOL_T final ) + /*E0*/ { DESC_POS, N_("End Pt 1: X,Y"), &crvData.endPt[0] }, + /*Z0*/ { DESC_DIM, N_("Z"), &crvData.elev[0] }, + /*E1*/ { DESC_POS, N_("End Pt 2: X,Y"), &crvData.endPt[1] }, + /*Z1*/ { DESC_DIM, N_("Z"), &crvData.elev[1] }, + /*CE*/ { DESC_POS, N_("Center: X,Y"), &crvData.center }, + /*RA*/ { DESC_DIM, N_("Radius"), &crvData.radius }, + /*TU*/ { DESC_LONG, N_("Turns"), &crvData.turns }, + /*SE*/ { DESC_DIM, N_("Separation"), &crvData.separation }, + /*LN*/ { DESC_DIM, N_("Length"), &crvData.length }, + /*AL*/ { DESC_FLOAT, N_("Angular Length"), &crvData.angle }, + /*A1*/ { DESC_ANGLE, N_("CCW Angle"), &crvData.angle0 }, + /*A2*/ { DESC_ANGLE, N_("CW Angle"), &crvData.angle1 }, + /*GR*/ { DESC_FLOAT, N_("Grade"), &crvData.grade }, + /*PV*/ { DESC_PIVOT, N_("Lock"), &crvData.pivot }, + /*LY*/ { DESC_LAYER, N_("Layer"), &crvData.layerNumber }, + { DESC_NULL } +}; + +static void UpdateCurve( track_p trk, int inx, descData_p descUpd, + BOOL_T final ) { BOOL_T updateEndPts; ANGLE_T a0, a1; EPINX_T ep; FLOAT_T turns; - if ( inx == -1 ) + if ( inx == -1 ) { return; + } struct extraDataCurve_t *xx = GET_EXTRA_DATA(trk, T_CURVE, extraDataCurve_t); struct extraDataCurve_t xx0 = *xx; updateEndPts = FALSE; @@ -498,12 +520,14 @@ static void UpdateCurve( track_p trk, int inx, descData_p descUpd, BOOL_T final case Z0: case Z1: ep = (inx==Z0?0:1); - UpdateTrkEndElev( trk, ep, GetTrkEndElevUnmaskedMode(trk,ep), crvData.elev[ep], NULL ); + UpdateTrkEndElev( trk, ep, GetTrkEndElevUnmaskedMode(trk,ep), crvData.elev[ep], + NULL ); ComputeElev( trk, 1-ep, FALSE, &crvData.elev[1-ep], NULL, TRUE ); - if ( crvData.length > minLength ) + if ( crvData.length > minLength ) { crvData.grade = fabs( (crvData.elev[0]-crvData.elev[1])/crvData.length )*100.0; - else + } else { crvData.grade = 0.0; + } crvDesc[GR].mode |= DESC_CHANGE; crvDesc[inx==Z0?Z1:Z0].mode |= DESC_CHANGE; if ( xx->helixTurns > 0 ) { @@ -516,7 +540,7 @@ static void UpdateCurve( track_p trk, int inx, descData_p descUpd, BOOL_T final SetTrkLayer( trk, crvData.layerNumber); break; default: - AbortProg( "updateCurve: Bad inx %d", inx ); + CHECKMSG( FALSE, ( "updateCurve: Bad inx %d", inx ) ); } UndrawNewTrack( trk ); *xx = xx0; @@ -539,10 +563,11 @@ static void UpdateCurve( track_p trk, int inx, descData_p descUpd, BOOL_T final DrawCurveDescription( trk, &mainD, wDrawColorBlack ); turns = crvData.length/(2*M_PI*crvData.radius); crvData.separation = fabs(crvData.elev[0]-crvData.elev[1])/turns; - if ( crvData.length > minLength ) + if ( crvData.length > minLength ) { crvData.grade = fabs( (crvData.elev[0]-crvData.elev[1])/crvData.length )*100.0; - else + } else { crvData.grade = 0.0; + } crvDesc[GR].mode |= DESC_CHANGE; } @@ -562,24 +587,26 @@ static void DescribeCurve( track_p trk, char * str, CSIZE_T len ) d = xx->radius * 2.0 * M_PI * a1 / 360.0; if (xx->helixTurns > 0) { d += (xx->helixTurns-(xx->circle?1:0)) * xx->radius * 2.0 * M_PI; - sprintf( str, _("Helix Track(%d): Layer=%d Radius=%s Turns=%ld Length=%s Center=[%s,%s] EP=[%0.3f,%0.3f A%0.3f] [%0.3f,%0.3f A%0.3f]"), - GetTrkIndex(trk), - GetTrkLayer(trk)+1, - FormatDistance(xx->radius), - xx->helixTurns, - FormatDistance(d), - FormatDistance(xx->pos.x), FormatDistance(xx->pos.y), - GetTrkEndPosXY(trk,0), GetTrkEndAngle(trk,0), - GetTrkEndPosXY(trk,1), GetTrkEndAngle(trk,1) ); + sprintf( str, + _("Helix Track(%d): Layer=%d Radius=%s Turns=%ld Length=%s Center=[%s,%s] EP=[%0.3f,%0.3f A%0.3f] [%0.3f,%0.3f A%0.3f]"), + GetTrkIndex(trk), + GetTrkLayer(trk)+1, + FormatDistance(xx->radius), + xx->helixTurns, + FormatDistance(d), + FormatDistance(xx->pos.x), FormatDistance(xx->pos.y), + GetTrkEndPosXY(trk,0), GetTrkEndAngle(trk,0), + GetTrkEndPosXY(trk,1), GetTrkEndAngle(trk,1) ); } else { - sprintf( str, _("Curved Track(%d): Layer=%d Radius=%s Length=%s Center=[%s,%s] EP=[%0.3f,%0.3f A%0.3f] [%0.3f,%0.3f A%0.3f]"), - GetTrkIndex(trk), - GetTrkLayer(trk)+1, - FormatDistance(xx->radius), - FormatDistance(d), - FormatDistance(xx->pos.x), FormatDistance(xx->pos.y), - GetTrkEndPosXY(trk,0), GetTrkEndAngle(trk,0), - GetTrkEndPosXY(trk,1), GetTrkEndAngle(trk,1) ); + sprintf( str, + _("Curved Track(%d): Layer=%d Radius=%s Length=%s Center=[%s,%s] EP=[%0.3f,%0.3f A%0.3f] [%0.3f,%0.3f A%0.3f]"), + GetTrkIndex(trk), + GetTrkLayer(trk)+1, + FormatDistance(xx->radius), + FormatDistance(d), + FormatDistance(xx->pos.x), FormatDistance(xx->pos.y), + GetTrkEndPosXY(trk,0), GetTrkEndAngle(trk,0), + GetTrkEndPosXY(trk,1), GetTrkEndAngle(trk,1) ); } fix0 = GetTrkEndTrk(trk,0)!=NULL; @@ -603,10 +630,11 @@ static void DescribeCurve( track_p trk, char * str, CSIZE_T len ) } ComputeElev( trk, 0, FALSE, &crvData.elev[0], NULL, FALSE ); ComputeElev( trk, 1, FALSE, &crvData.elev[1], NULL, FALSE ); - if ( crvData.length > minLength ) + if ( crvData.length > minLength ) { crvData.grade = fabs( (crvData.elev[0]-crvData.elev[1])/crvData.length )*100.0; - else + } else { crvData.grade = 0.0; + } if ( xx->helixTurns > 0 ) { turns = crvData.length/(2*M_PI*crvData.radius); crvData.separation = fabs(crvData.elev[0]-crvData.elev[1])/turns; @@ -614,25 +642,25 @@ static void DescribeCurve( track_p trk, char * str, CSIZE_T len ) } crvDesc[E0].mode = - crvDesc[E1].mode = - crvDesc[LN].mode = - DESC_RO; + crvDesc[E1].mode = + crvDesc[LN].mode = + DESC_RO; crvDesc[Z0].mode = (EndPtIsDefinedElev(trk,0)?0:DESC_RO)|DESC_NOREDRAW; crvDesc[Z1].mode = (EndPtIsDefinedElev(trk,1)?0:DESC_RO)|DESC_NOREDRAW; crvDesc[GR].mode = DESC_RO; crvDesc[CE].mode = (fix0|fix1)?DESC_RO:0; crvDesc[RA].mode = - crvDesc[AL].mode = - (fix0&fix1)?DESC_RO:0; + crvDesc[AL].mode = + (fix0&fix1)?DESC_RO:0; crvDesc[TU].mode = DESC_NOREDRAW; crvDesc[A1].mode = fix0?DESC_RO:0; crvDesc[A2].mode = fix1?DESC_RO:0; crvDesc[PV].mode = (fix0|fix1)?DESC_IGNORE:0; crvDesc[LY].mode = DESC_NOREDRAW; crvData.pivot = (fix0&fix1)?DESC_PIVOT_NONE: - fix0?DESC_PIVOT_FIRST: - fix1?DESC_PIVOT_SECOND: - DESC_PIVOT_MID; + fix0?DESC_PIVOT_FIRST: + fix1?DESC_PIVOT_SECOND: + DESC_PIVOT_MID; crvDesc[SE].mode |= DESC_IGNORE; if ( xx->circle ) { @@ -645,10 +673,11 @@ static void DescribeCurve( track_p trk, char * str, CSIZE_T len ) crvDesc[A2].mode |= DESC_IGNORE; crvDesc[PV].mode |= DESC_IGNORE; } - + if ( xx->helixTurns ) { - if ( !xx->circle ) + if ( !xx->circle ) { crvDesc[SE].mode = DESC_RO; + } DoDescribe( _("Helix Track"), trk, crvDesc, UpdateCurve ); } else if ( xx->circle ) { crvDesc[TU].mode |= DESC_IGNORE; @@ -676,31 +705,167 @@ static DIST_T DistanceCurve( track_p t, coOrd * p ) static void DrawCurve( track_p t, drawCmd_p d, wDrawColor color ) { ANGLE_T a0, a1; - track_p tt = t; +// track_p tt = t; long widthOptions = DTS_LEFT|DTS_RIGHT; struct extraDataCurve_t *xx = GET_EXTRA_DATA(t, T_CURVE, extraDataCurve_t); GetCurveAngles( &a0, &a1, t ); - if (xx->circle) { - tt = NULL; - } +// if (xx->circle) { +// tt = NULL; +// } if (xx->helixTurns > 0) { a0 = 0.0; a1 = 360.0; } if ( ((d->options&(DC_SIMPLE|DC_SEGTRACK))==0) && - (labelWhen == 2 || (labelWhen == 1 && (d->options&DC_PRINT))) && - labelScale >= d->scale && - ( GetTrkBits( t ) & TB_HIDEDESC ) == 0 ) { + (labelWhen == 2 || (labelWhen == 1 && (d->options&DC_PRINT))) && + labelScale >= d->scale && + ( GetTrkBits( t ) & TB_HIDEDESC ) == 0 ) { DrawCurveDescription( t, d, color ); } DrawCurvedTrack( d, xx->pos, xx->radius, a0, a1, - t, color, widthOptions ); + t, color, widthOptions ); DrawEndPt( d, t, 0, color ); DrawEndPt( d, t, 1, color ); } +static void DrawCurvedTies( + drawCmd_p d, + tieData_t td, + coOrd p, + DIST_T r, + ANGLE_T a0, + ANGLE_T a1, + wDrawColor color ) +{ + DIST_T len; + ANGLE_T ang, dang; + coOrd pos; + int cnt; + + if ( (d->options&DC_SIMPLE) != 0 ) { + return; + } + + if (color == wDrawColorBlack) { + color = tieColor; + } + len = 2*M_PI*r*a1/360.0; + cnt = (int)floor(len/td.spacing + 0.5); + if ( len - td.spacing*cnt - (td.width/2) > (td.spacing - td.width)/2 ) { + cnt++; + } + if ( cnt != 0 ) { + dang = (360.0*(len)/cnt)/(2*M_PI*r); + for ( ang=a0+dang/2; cnt; cnt--,ang+=dang ) { + PointOnCircle( &pos, p, r, ang ); + DrawTie( d, pos, ang+90, td.length, td.width, color, + tieDrawMode==TIEDRAWMODE_SOLID ); + } + + } +} + +EXPORT void DrawCurvedTrack( + drawCmd_p d, + coOrd p, + DIST_T r, + ANGLE_T a0, + ANGLE_T a1, + track_cp trk, + wDrawColor color, + long options ) +{ + DIST_T trackGauge = GetTrkGauge(trk); + tieData_t td; + wDrawWidth width=0; + trkSeg_p segPtr; + long bridge = 0, roadbed = 0; + if(trk) { + bridge = GetTrkBridge( trk ); + roadbed = GetTrkRoadbed( trk ); + } + + if ( (d->options&DC_SEGTRACK) ) { + DYNARR_APPEND( trkSeg_t, tempSegs_da, 10 ); + segPtr = &tempSegs(tempSegs_da.cnt-1); + segPtr->type = SEG_CRVTRK; + segPtr->lineWidth = 0; + segPtr->color = wDrawColorBlack; + segPtr->u.c.center = p; + segPtr->u.c.a0 = a0; + segPtr->u.c.a1 = a1; + segPtr->u.c.radius = r; + return; + } + + width = trk ? GetTrkWidth( trk ): 0; + if ( d->options&DC_THICK ) { + width = 3; + } + if ( color == wDrawColorPreviewSelected + || color == wDrawColorPreviewUnselected ) { + width = 3; + } + + if ((d->options&DC_PRINT) && (d->dpi>2*BASE_DPI)) { + width = (wDrawWidth)round(width * d->dpi / 2 / BASE_DPI); + } + + LOG(log_curve,4,("DST( (%0.3f %0.3f) R%0.3f A%0.3f..%0.3f)\n", + p.x, p.y, r, a0, a1 ) ) + + // Draw a solid background + if(bridge|roadbed) { + wDrawWidth width3 = (wDrawWidth)round(trackGauge * 3 * d->dpi / d->scale); + DrawArc( d, p, r, a0, a1, 0, width3, bridge?bridgeColor:roadbedColor ); + } + + if ( DoDrawTies( d, trk ) ) { + td = GetTrkTieData( trk ); + DrawCurvedTies( d, td, p, r, a0, a1, color ); + } + if (color == wDrawColorBlack) { + color = normalColor; + } + if ( ! DrawTwoRails( d, 1 ) ) { + DrawArc( d, p, r, a0, a1, (centerDrawMode + && !(options&DTS_NOCENTER)) ? 1 : 0, width, color ); + } else { + if ( hasTrackCenterline(d)) { + long options = d->options; + d->options |= DC_DASH; + DrawArc( d, p, r, a0, a1, 0, 0, color ); + d->options = options; + } + DrawArc( d, p, r+trackGauge/2.0, a0, a1, 0, width, color ); + DrawArc( d, p, r-trackGauge/2.0, a0, a1, (centerDrawMode + && !(options&DTS_NOCENTER) ? 1: 0), width, color ); + if ( (d->options&DC_PRINT) && roadbedWidth > trackGauge + && DrawTwoRails( d, 1 ) ) { + wDrawWidth rbw = (wDrawWidth)floor(roadbedLineWidth*(d->dpi/d->scale)+0.5); + if ( options&DTS_RIGHT ) { + DrawArc( d, p, r+roadbedWidth/2.0, a0, a1, 0, rbw, color ); + } + if ( options&DTS_LEFT ) { + DrawArc( d, p, r-roadbedWidth/2.0, a0, a1, 0, rbw, color ); + } + } + } + if (bridge) { + wDrawWidth width2 = (wDrawWidth)round((2.0 * d->dpi)/BASE_DPI); + if (d->options&DC_PRINT) { + width2 = (wDrawWidth)round(d->dpi / BASE_DPI); + } + + DrawArc( d, p, r+(trackGauge*1.5), a0, a1, 0, width2, color ); + DrawArc( d, p, r-(trackGauge*1.5), a0, a1, 0, width2, color ); + } + +} + + static void DeleteCurve( track_p t ) { } @@ -708,16 +873,22 @@ static void DeleteCurve( track_p t ) static BOOL_T WriteCurve( track_p t, FILE * f ) { struct extraDataCurve_t *xx = GET_EXTRA_DATA(t, T_CURVE, extraDataCurve_t); + int bits; long options; BOOL_T rc = TRUE; options = GetTrkWidth(t) & 0x0F; if ( ( GetTrkBits(t) & TB_HIDEDESC ) == 0 ) - // 0x80 means Show Description - options |= 0x80; - rc &= fprintf(f, "CURVE %d %d %ld 0 0 %s %d %0.6f %0.6f 0 %0.6f %ld %0.6f %0.6f\n", - GetTrkIndex(t), GetTrkLayer(t), (long)options, - GetTrkScaleName(t), GetTrkVisible(t)|(GetTrkNoTies(t)?1<<2:0)|(GetTrkBridge(t)?1<<3:0), xx->pos.x, xx->pos.y, xx->radius, - xx->helixTurns, xx->descriptionOff.x, xx->descriptionOff.y )>0; + // 0x80 means Show Description + { + options |= 0x80; + } + bits = GetTrkVisible(t)|(GetTrkNoTies(t)?1<<2:0)|(GetTrkBridge(t)?1<<3:0)| + (GetTrkRoadbed(t)?1<<4:0); + rc &= fprintf(f, + "CURVE %d %d %ld 0 0 %s %d %0.6f %0.6f 0 %0.6f %ld %0.6f %0.6f\n", + GetTrkIndex(t), GetTrkLayer(t), (long)options, + GetTrkScaleName(t), bits, xx->pos.x, xx->pos.y, xx->radius, + xx->helixTurns, xx->descriptionOff.x, xx->descriptionOff.y )>0; rc &= WriteEndPt( f, t, 0 ); rc &= WriteEndPt( f, t, 1 ); rc &= fprintf(f, "\t%s\n", END_SEGS)>0; @@ -740,16 +911,19 @@ static BOOL_T ReadCurve( char * line ) long helixTurns = 0; coOrd descriptionOff = { 0.0, 0.0 }; - if (!GetArgs( line+6, paramVersion<3?"dXZsdpYfc":paramVersion<9?"dLl00sdpYfc":"dLl00sdpffc", - &index, &layer, &options, scale, &visible, &p, &elev, &r, &cp ) ) { + if (!GetArgs( line+6, paramVersion<3?"dXZsdpYfc":paramVersion<9 + ?"dLl00sdpYfc":"dLl00sdpffc", + &index, &layer, &options, scale, &visible, &p, &elev, &r, &cp ) ) { return FALSE; } if (cp) { - if ( !GetArgs( cp, "lp", &helixTurns, &descriptionOff ) ) + if ( !GetArgs( cp, "lp", &helixTurns, &descriptionOff ) ) { return FALSE; + } } - if ( !ReadSegs() ) + if ( !ReadSegs() ) { return FALSE; + } t = NewTrack( index, T_CURVE, 0, sizeof *xx ); xx = GET_EXTRA_DATA(t, T_CURVE, extraDataCurve_t); xx->helixTurns = helixTurns; @@ -758,10 +932,12 @@ static BOOL_T ReadCurve( char * line ) SetTrkVisible(t, visible!=0); SetTrkNoTies(t, FALSE); SetTrkBridge(t, FALSE); + SetTrkRoadbed(t, FALSE); } else { SetTrkVisible(t, visible&2); SetTrkNoTies(t, visible&4); SetTrkBridge(t, visible&8); + SetTrkRoadbed(t, visible&16); } SetTrkScale(t, LookupScale(scale)); SetTrkLayer(t, layer ); @@ -774,13 +950,15 @@ static BOOL_T ReadCurve( char * line ) SetTrkBits(t,TB_HIDEDESC); } } else { - if ( paramVersion < VERSION_DESCRIPTION2 || ( ( options & 0x80 ) == 0 ) ) - SetTrkBits(t,TB_HIDEDESC); + if ( paramVersion < VERSION_DESCRIPTION2 || ( ( options & 0x80 ) == 0 ) ) { + SetTrkBits(t,TB_HIDEDESC); + } } SetEndPts(t,2); if (GetTrkEndAngle( t, 0 ) == 270.0 && - GetTrkEndAngle( t, 1 ) == 90.0 ) + GetTrkEndAngle( t, 1 ) == 90.0 ) { xx->circle = TRUE; + } ComputeCurveBoundingBox( t, xx ); return TRUE; } @@ -808,17 +986,19 @@ static void RescaleCurve( track_p trk, FLOAT_T ratio ) xx->radius *= ratio; } -static ANGLE_T GetAngleCurve( track_p trk, coOrd pos, EPINX_T *ep0, EPINX_T *ep1 ) +static ANGLE_T GetAngleCurve( track_p trk, coOrd pos, EPINX_T *ep0, + EPINX_T *ep1 ) { coOrd center; DIST_T radius; - if ( ep0 ) *ep0 = 0; - if ( ep1 ) *ep1 = 1; + if ( ep0 ) { *ep0 = 0; } + if ( ep1 ) { *ep1 = 1; } GetTrkCurveCenter( trk, ¢er, &radius ); return FindAngle( center, pos ) - 90.0; } -static BOOL_T SplitCurve( track_p trk, coOrd pos, EPINX_T ep, track_p *leftover, EPINX_T * ep0, EPINX_T * ep1 ) +static BOOL_T SplitCurve( track_p trk, coOrd pos, EPINX_T ep, track_p *leftover, + EPINX_T * ep0, EPINX_T * ep1 ) { struct extraDataCurve_t *xx = GET_EXTRA_DATA(trk, T_CURVE, extraDataCurve_t); ANGLE_T a, a0, a1; @@ -837,9 +1017,9 @@ static BOOL_T SplitCurve( track_p trk, coOrd pos, EPINX_T ep, track_p *leftover, *leftover = NULL; return TRUE; } - if (ep == 0) + if (ep == 0) { a1 = NormalizeAngle(a-a0); - else { + } else { a1 = NormalizeAngle(a0+a1-a); a0 = a; } @@ -847,7 +1027,8 @@ static BOOL_T SplitCurve( track_p trk, coOrd pos, EPINX_T ep, track_p *leftover, DIST_T height; int opt; GetTrkEndElev(trk,ep,&opt,&height); - UpdateTrkEndElev( trk1, 1-ep, opt, height, (opt==ELEV_STATION)?GetTrkEndElevStation(trk,ep):NULL ); + UpdateTrkEndElev( trk1, 1-ep, opt, height, + (opt==ELEV_STATION)?GetTrkEndElevStation(trk,ep):NULL ); AdjustCurveEndPt( trk, ep, a+(ep==0?-90.0:90.0) ); UpdateTrkEndElev( trk, ep, ELEV_NONE, 0, NULL); *leftover = trk1; @@ -866,55 +1047,64 @@ static BOOL_T TraverseCurve( traverseTrack_p trvTrk, DIST_T * distR ) DIST_T circum; DIST_T dist; long turns; - if ( xx->circle ) + if ( xx->circle ) { return FALSE; + } circum = 2*M_PI*xx->radius; GetCurveAngles( &a0, &a1, trk ); a2 = FindAngle( xx->pos, trvTrk->pos ); a = NormalizeAngle( (a2-90.0) - trvTrk->angle ); if ( xx->helixTurns <= 0 ) { if ( NormalizeAngle(a2-a0) > a1 ) { - if ( NormalizeAngle( a2-(a0+a1/2.0+180.0 ) ) < 180.0 ) + if ( NormalizeAngle( a2-(a0+a1/2.0+180.0 ) ) < 180.0 ) { a2 = a0; - else + } else { a2 = NormalizeAngle(a0+a1); + } } } - if ( a>270 || a<90 ) + if ( a>270 || a<90 ) { arcDist = NormalizeAngle(a2-a0)/360.0*circum; - else + } else { arcDist = NormalizeAngle(a0+a1-a2)/360.0*circum; + } if ( xx->helixTurns > 0 ) { turns = xx->helixTurns; - if ( NormalizeAngle(a2-a0) > a1 ) + if ( NormalizeAngle(a2-a0) > a1 ) { turns -= 1; + } dist = (a1/360.0+xx->helixTurns)*circum; if ( trvTrk->length < 0 ) { trvTrk->length = dist; trvTrk->dist = a1/360.0*circum - arcDist; while ( trvTrk->dist < 0 ) { - if ( trvTrk->dist > -0.1 ) + if ( trvTrk->dist > -0.1 ) { trvTrk->dist = 0.0; - else + } else { trvTrk->dist += circum; + } } } else { if ( trvTrk->length != dist ) { - printf( "traverseCurve: trvTrk->length(%0.3f) != Dist(%0.3f)\n", trvTrk->length, dist ); + printf( "traverseCurve: trvTrk->length(%0.3f) != Dist(%0.3f)\n", trvTrk->length, + dist ); trvTrk->length = dist; } if ( trvTrk->length < trvTrk->dist ) { - printf( "traverseCurve: trvTrk->length(%0.3f) < trvTrk->dist(%0.3f)\n", trvTrk->length, trvTrk->dist ); + printf( "traverseCurve: trvTrk->length(%0.3f) < trvTrk->dist(%0.3f)\n", + trvTrk->length, trvTrk->dist ); trvTrk->dist = trvTrk->length; } a3 = trvTrk->dist/circum*360.0; - if ( a>270 || a<90 ) + if ( a>270 || a<90 ) { a3 = (a0+a1-a3); - else + } else { a3 = (a0+a3); + } a3 = NormalizeAngle(a3); - if ( NormalizeAngle(a2-a3+1.0) > 2.0 ) + if ( NormalizeAngle(a2-a3+1.0) > 2.0 ) { printf( "traverseCurve: A2(%0.3f) != A3(%0.3f)\n", a2, a3 ); + } turns = (int)((trvTrk->length-trvTrk->dist)/circum); } arcDist += turns * circum; @@ -962,15 +1152,18 @@ static BOOL_T EnumerateCurve( track_p trk ) xx = GET_EXTRA_DATA(trk, T_CURVE, extraDataCurve_t); GetCurveAngles( &a0, &a1, trk ); d = (xx->radius + (GetTrkGauge(trk)/2.0))* 2.0 * M_PI * a1 / 360.0; - if (xx->helixTurns > 0) - d += (xx->helixTurns-(xx->circle?1:0)) * (xx->radius+(GetTrkGauge(trk)/2.0)) * 2.0 * M_PI; + if (xx->helixTurns > 0) { + d += (xx->helixTurns-(xx->circle?1:0)) * (xx->radius+(GetTrkGauge( + trk)/2.0)) * 2.0 * M_PI; + } ScaleLengthIncrement( GetTrkScale(trk), d ); return TRUE; } return FALSE; } -static BOOL_T TrimCurve( track_p trk, EPINX_T ep, DIST_T dist, coOrd endpos, ANGLE_T angle, DIST_T endradius, coOrd endcenter ) +static BOOL_T TrimCurve( track_p trk, EPINX_T ep, DIST_T dist, coOrd endpos, + ANGLE_T angle, DIST_T endradius, coOrd endcenter ) { DIST_T d; DIST_T radius; @@ -993,16 +1186,17 @@ static BOOL_T TrimCurve( track_p trk, EPINX_T ep, DIST_T dist, coOrd endpos, ANG UndrawNewTrack( trk ); AdjustCurveEndPt( trk, ep, a+(ep==0?-90.0:90.0) ); DrawNewTrack( trk ); - } else + } else { DeleteTrack( trk, TRUE ); + } return TRUE; } static BOOL_T MergeCurve( - track_p trk0, - EPINX_T ep0, - track_p trk1, - EPINX_T ep1 ) + track_p trk0, + EPINX_T ep0, + track_p trk1, + EPINX_T ep1 ) { ANGLE_T a00, a01, a10, a11; DIST_T d; @@ -1010,31 +1204,38 @@ static BOOL_T MergeCurve( EPINX_T ep2=-1; coOrd pos; - if (ep0 == ep1) + if (ep0 == ep1) { return FALSE; + } if ( IsCurveCircle(trk0) || - IsCurveCircle(trk1) ) + IsCurveCircle(trk1) ) { return FALSE; + } struct extraDataCurve_t *xx0 = GET_EXTRA_DATA(trk0, T_CURVE, extraDataCurve_t); struct extraDataCurve_t *xx1 = GET_EXTRA_DATA(trk1, T_CURVE, extraDataCurve_t); if ( xx0->helixTurns > 0 || - xx1->helixTurns > 0 ) + xx1->helixTurns > 0 ) { return FALSE; - if (GetTrkType(trk0) != GetTrkType(trk1)) + } + if (GetTrkType(trk0) != GetTrkType(trk1)) { return FALSE; + } d = FindDistance( xx0->pos, xx1->pos ); d += fabs( xx0->radius - xx1->radius ); - if ( d > connectDistance ) + if ( d > connectDistance ) { return FALSE; + } GetCurveAngles( &a00, &a01, trk0 ); GetCurveAngles( &a10, &a11, trk1 ); - UndoStart( _("Merge Curves"), "MergeCurve( T%d[%d] T%d[%d] )", GetTrkIndex(trk0), ep0, GetTrkIndex(trk1), ep1 ); + UndoStart( _("Merge Curves"), "MergeCurve( T%d[%d] T%d[%d] )", + GetTrkIndex(trk0), ep0, GetTrkIndex(trk1), ep1 ); UndoModify( trk0 ); UndrawNewTrack( trk0 ); - if (GetTrkEndTrk(trk0,ep0) == trk1) + if (GetTrkEndTrk(trk0,ep0) == trk1) { DisconnectTracks( trk0, ep0, trk1, ep1); + } trk2 = GetTrkEndTrk( trk1, 1-ep1 ); if (trk2) { ep2 = GetEndPtConnectedToMe( trk2, trk1 ); @@ -1054,7 +1255,8 @@ static BOOL_T MergeCurve( ConnectTracks( trk0, ep0, trk2, ep2 ); } DrawNewTrack( trk0 ); - ComputeCurveBoundingBox( trk0, GET_EXTRA_DATA(trk0, T_CURVE, extraDataCurve_t) ); + ComputeCurveBoundingBox( trk0, GET_EXTRA_DATA(trk0, T_CURVE, + extraDataCurve_t) ); return TRUE; } @@ -1082,102 +1284,107 @@ static STATUS_T ModifyCurve( track_p trk, wAction_t action, coOrd pos ) case C_DOWN: arcTangent = FALSE; GetCurveAngles( &arcA0, &arcA1, trk ); - if ( arcA0 == 0.0 && arcA1 == 360.0 ) + if ( arcA0 == 0.0 && arcA1 == 360.0 ) { return C_ERROR; + } if ( xx->helixTurns > 0 ) { return C_ERROR; } ep = PickUnconnectedEndPoint( pos, trk ); - if ( ep == -1 ) + if ( ep == -1 ) { return C_ERROR; + } GetTrkCurveCenter( trk, &arcPos, &arcRadius ); UndrawNewTrack( trk ); + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); tempSegs(0).type = SEG_CRVTRK; - tempSegs(0).width = 0; + tempSegs(0).lineWidth = 0; tempSegs(0).u.c.center = arcPos; tempSegs(0).u.c.radius = arcRadius; tempSegs(0).u.c.a0 = arcA0; tempSegs(0).u.c.a1 = arcA1; - tempSegs_da.cnt = 1; InfoMessage( _("Drag to change angle or create tangent") ); case C_MOVE: - if (xx->helixTurns>0) + if (xx->helixTurns>0) { return C_CONTINUE; + } valid = FALSE; - a = FindAngle( arcPos, pos ); - r = FindDistance( arcPos, pos ); - if ( r > arcRadius*(arcTangent?1.0:1.10) ) { - arcTangent = TRUE; - if ( easeR > 0.0 && arcRadius < easeR ) { - ErrorMessage( MSG_RADIUS_LSS_EASE_MIN, - FormatDistance( arcRadius ), FormatDistance( easeR ) ); - return C_CONTINUE; - } - aa1 = 90.0-R2D( asin( arcRadius/r ) ); - aa2 = NormalizeAngle( a + (ep==0?aa1:-aa1) ); - PointOnCircle( &tangentOrig, arcPos, arcRadius, aa2 ); - if (ComputeJoint( ep==0?-arcRadius:+arcRadius, 0, &jointD ) == E_ERROR) - return C_CONTINUE; - tangentEnd = pos; - if (jointD.x != 0.0) { - Translate( &tangentOrig, tangentOrig, aa2, jointD.x ); - Translate( &tangentEnd, tangentEnd, aa2, jointD.x ); - } - if (ep == 0) { - tempSegs(0).u.c.a0 = aa2; - tempSegs(0).u.c.a1 = NormalizeAngle( arcA0+arcA1-aa2 ); - } else { - tempSegs(0).u.c.a1 = NormalizeAngle(aa2-arcA0); - } - d = arcRadius * tempSegs(0).u.c.a1 * 2.0*M_PI/360.0; - d -= jointD.d0; - if ( d <= minLength) { - ErrorMessage( MSG_TRK_TOO_SHORT, _("Curved "), PutDim(fabs(minLength-d)) ); - return C_CONTINUE; - } - d = FindDistance( tangentOrig, tangentEnd ); - d -= jointD.d1; - if ( d <= minLength) { - ErrorMessage( MSG_TRK_TOO_SHORT, _("Tangent "), PutDim(fabs(minLength-d)) ); - return C_CONTINUE; - } - tempSegs(1).type = SEG_STRTRK; - tempSegs(1).width = 0; - tempSegs(1).u.l.pos[0] = tangentOrig; - tempSegs(1).u.l.pos[1] = tangentEnd; - tempSegs_da.cnt = 2; - if (action == C_MOVE) - InfoMessage( _("Tangent track: Length %s Angle %0.3f"), - FormatDistance( d ), - PutAngle( FindAngle( tangentOrig, tangentEnd ) ) ); + a = FindAngle( arcPos, pos ); + r = FindDistance( arcPos, pos ); + if ( r > arcRadius*(arcTangent?1.0:1.10) ) { + arcTangent = TRUE; + if ( easeR > 0.0 && arcRadius < easeR ) { + ErrorMessage( MSG_RADIUS_LSS_EASE_MIN, + FormatDistance( arcRadius ), FormatDistance( easeR ) ); + return C_CONTINUE; + } + aa1 = 90.0-R2D( asin( arcRadius/r ) ); + aa2 = NormalizeAngle( a + (ep==0?aa1:-aa1) ); + PointOnCircle( &tangentOrig, arcPos, arcRadius, aa2 ); + if (ComputeJoint( ep==0?-arcRadius:+arcRadius, 0, &jointD ) == E_ERROR) { + return C_CONTINUE; + } + tangentEnd = pos; + if (jointD.x != 0.0) { + Translate( &tangentOrig, tangentOrig, aa2, jointD.x ); + Translate( &tangentEnd, tangentEnd, aa2, jointD.x ); + } + if (ep == 0) { + tempSegs(0).u.c.a0 = aa2; + tempSegs(0).u.c.a1 = NormalizeAngle( arcA0+arcA1-aa2 ); } else { - arcTangent = FALSE; - angle = NormalizeAngle( a + - ((ep==0)?-90:90)); - PointOnCircle( &pos, arcPos, arcRadius, a ); - if (ep != 0) { - tempSegs(0).u.c.a0 = NormalizeAngle( GetTrkEndAngle(trk,0)+90.0 ); - tempSegs(0).u.c.a1 = NormalizeAngle( a-tempSegs(0).u.c.a0 ); - } else { - tempSegs(0).u.c.a0 = a; - tempSegs(0).u.c.a1 = NormalizeAngle( (GetTrkEndAngle(trk,1)-90.0) - a ); - } - d = arcRadius*tempSegs(0).u.c.a1*2.0*M_PI/360.0; - if ( d <= minLength ) { - ErrorMessage( MSG_TRK_TOO_SHORT, _("Curved "), PutDim( fabs(minLength-d) ) ); - return C_CONTINUE; - } - tempSegs_da.cnt = 1; - if (action == C_MOVE) - InfoMessage( _("Curved: Radius=%s Length=%s Angle=%0.3f"), - FormatDistance( arcRadius ), FormatDistance( d ), - tempSegs(0).u.c.a1 ); + tempSegs(0).u.c.a1 = NormalizeAngle(aa2-arcA0); + } + d = arcRadius * tempSegs(0).u.c.a1 * 2.0*M_PI/360.0; + d -= jointD.d0; + if ( d <= minLength) { + ErrorMessage( MSG_TRK_TOO_SHORT, _("Curved "), PutDim(fabs(minLength-d)) ); + return C_CONTINUE; + } + d = FindDistance( tangentOrig, tangentEnd ); + d -= jointD.d1; + if ( d <= minLength) { + ErrorMessage( MSG_TRK_TOO_SHORT, _("Tangent "), PutDim(fabs(minLength-d)) ); + return C_CONTINUE; } + DYNARR_SET( trkSeg_t, tempSegs_da, 2 ); + tempSegs(1).type = SEG_STRTRK; + tempSegs(1).lineWidth = 0; + tempSegs(1).u.l.pos[0] = tangentOrig; + tempSegs(1).u.l.pos[1] = tangentEnd; + if (action == C_MOVE) + InfoMessage( _("Tangent track: Length %s Angle %0.3f"), + FormatDistance( d ), + PutAngle( FindAngle( tangentOrig, tangentEnd ) ) ); + } else { + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); + arcTangent = FALSE; + angle = NormalizeAngle( a + + ((ep==0)?-90:90)); + PointOnCircle( &pos, arcPos, arcRadius, a ); + if (ep != 0) { + tempSegs(0).u.c.a0 = NormalizeAngle( GetTrkEndAngle(trk,0)+90.0 ); + tempSegs(0).u.c.a1 = NormalizeAngle( a-tempSegs(0).u.c.a0 ); + } else { + tempSegs(0).u.c.a0 = a; + tempSegs(0).u.c.a1 = NormalizeAngle( (GetTrkEndAngle(trk,1)-90.0) - a ); + } + d = arcRadius*tempSegs(0).u.c.a1*2.0*M_PI/360.0; + if ( d <= minLength ) { + ErrorMessage( MSG_TRK_TOO_SHORT, _("Curved "), PutDim( fabs(minLength-d) ) ); + return C_CONTINUE; + } + if (action == C_MOVE) + InfoMessage( _("Curved: Radius=%s Length=%s Angle=%0.3f"), + FormatDistance( arcRadius ), FormatDistance( d ), + tempSegs(0).u.c.a1 ); + } valid = TRUE; return C_CONTINUE; case C_UP: - if (xx->helixTurns>0) + if (xx->helixTurns>0) { return C_CONTINUE; + } if (valid) { if (arcTangent) { trk1 = NewStraightTrack( tangentOrig, tangentEnd ); @@ -1185,7 +1392,7 @@ static STATUS_T ModifyCurve( track_p trk, wAction_t action, coOrd pos ) /*UndrawNewTrack( trk );*/ AdjustCurveEndPt( trk, ep, angle ); JoinTracks( trk, ep, tangentOrig, - trk1, 0, tangentOrig, &jointD ); + trk1, 0, tangentOrig, &jointD ); DrawNewTrack( trk1 ); } else { AdjustCurveEndPt( trk, ep, angle ); @@ -1208,29 +1415,32 @@ static DIST_T GetLengthCurve( track_p trk ) struct extraDataCurve_t *xx = GET_EXTRA_DATA(trk, T_CURVE, extraDataCurve_t); GetTrkCurveCenter( trk, &cen, &rad ); - if (xx->circle) + if (xx->circle) { a1 = 360.0; - else + } else { GetCurveAngles( &a0, &a1, trk ); + } dist = rad*a1*2.0*M_PI/360.0; - if (xx->helixTurns>0) + if (xx->helixTurns>0) { dist += (xx->helixTurns-(xx->circle?1:0)) * xx->radius * 2.0 * M_PI; + } return dist; } -static BOOL_T GetParamsCurve( int inx, track_p trk, coOrd pos, trackParams_t * params ) +static BOOL_T GetParamsCurve( int inx, track_p trk, coOrd pos, + trackParams_t * params ) { params->type = curveTypeCurve; GetTrkCurveCenter( trk, ¶ms->arcP, ¶ms->arcR); GetCurveAngles( ¶ms->arcA0, ¶ms->arcA1, trk ); - ANGLE_T angle1 = FindAngle(params->arcP,pos); +// ANGLE_T angle1 = FindAngle(params->arcP,pos); params->track_angle = NormalizeAngle(FindAngle(params->arcP,pos)+90); if ( easeR > 0.0 && params->arcR < easeR ) { ErrorMessage( MSG_RADIUS_LSS_EASE_MIN, - FormatDistance( params->arcR ), FormatDistance( easeR ) ); + FormatDistance( params->arcR ), FormatDistance( easeR ) ); return FALSE; } struct extraDataCurve_t *xx = GET_EXTRA_DATA(trk, T_CURVE, extraDataCurve_t); @@ -1238,10 +1448,11 @@ static BOOL_T GetParamsCurve( int inx, track_p trk, coOrd pos, trackParams_t * p ErrorMessage( MSG_CANT_EXTEND_HELIX ); return FALSE; } - if (inx == PARAMS_NODES) return FALSE; + if (inx == PARAMS_NODES) { return FALSE; } params->len = params->arcR * params->arcA1 *2.0*M_PI/360.0; - if (xx->helixTurns > 0) + if (xx->helixTurns > 0) { params->len += (xx->helixTurns-(xx->circle?1:0)) * xx->radius * 2.0 * M_PI; + } params->helixTurns = xx->helixTurns; params->circleOrHelix = FALSE; if ( IsCurveCircle( trk ) ) { @@ -1249,13 +1460,15 @@ static BOOL_T GetParamsCurve( int inx, track_p trk, coOrd pos, trackParams_t * p params->angle = params->track_angle; params->circleOrHelix = TRUE; return TRUE; - } else if ((inx == PARAMS_CORNU) || (inx == PARAMS_1ST_JOIN) || (inx == PARAMS_2ND_JOIN) ) { + } else if ((inx == PARAMS_CORNU) || (inx == PARAMS_1ST_JOIN) + || (inx == PARAMS_2ND_JOIN) ) { params->ep = PickEndPoint(pos, trk); } else { params->ep = PickUnconnectedEndPointSilent( pos, trk ); } - if (params->ep == -1) + if (params->ep == -1) { return FALSE; + } params->angle = GetTrkEndAngle(trk,params->ep); ; return TRUE; } @@ -1267,14 +1480,15 @@ static BOOL_T MoveEndPtCurve( track_p *trk, EPINX_T *ep, coOrd pos, DIST_T d0 ) DIST_T r; ANGLE_T angle0; ANGLE_T aa; - + GetTrkCurveCenter( *trk, &posCen, &r ); angle0 = FindAngle( posCen, pos ); aa = R2D( d0/r ); - if ( *ep==0 ) + if ( *ep==0 ) { angle0 += aa - 90.0; - else + } else { angle0 -= aa - 90.0; + } AdjustCurveEndPt( *trk, *ep, angle0 ); return TRUE; } @@ -1296,7 +1510,8 @@ static BOOL_T QueryCurve( track_p trk, int query ) return TRUE; break; case Q_EXCEPTION: - return fabs(xx->radius) < (GetLayoutMinTrackRadius() - EPSILON); + return fabs(xx->radius) < (GetLayerMinTrackRadius(GetTrkLayer( + trk)) - EPSILON); // *new-layer* break; case Q_NOT_PLACE_FROGPOINTS: return IsCurveCircle( trk ); @@ -1309,7 +1524,7 @@ static BOOL_T QueryCurve( track_p trk, int query ) return (xx->helixTurns > 0); break; case Q_HAS_VARIABLE_ENDPOINTS: - if ((xx->helixTurns >0) || xx->circle) return TRUE; + if ((xx->helixTurns >0) || xx->circle) { return TRUE; } return FALSE; break; case Q_NODRAWENDPT: @@ -1321,9 +1536,9 @@ static BOOL_T QueryCurve( track_p trk, int query ) static void FlipCurve( - track_p trk, - coOrd orig, - ANGLE_T angle ) + track_p trk, + coOrd orig, + ANGLE_T angle ) { struct extraDataCurve_t * xx = GET_EXTRA_DATA(trk, T_CURVE, extraDataCurve_t); FlipPoint( &xx->pos, orig, angle ); @@ -1332,14 +1547,14 @@ static void FlipCurve( static BOOL_T MakeParallelCurve( - track_p trk, - coOrd pos, - DIST_T sep, - DIST_T factor, - track_p * newTrkR, - coOrd * p0R, - coOrd * p1R, - BOOL_T track) + track_p trk, + coOrd pos, + DIST_T sep, + DIST_T factor, + track_p * newTrkR, + coOrd * p0R, + coOrd * p1R, + BOOL_T track) { struct extraDataCurve_t * xx = GET_EXTRA_DATA(trk, T_CURVE, extraDataCurve_t); struct extraDataCurve_t * xx1; @@ -1348,10 +1563,11 @@ static BOOL_T MakeParallelCurve( rad = FindDistance( pos, xx->pos ); sep = sep+factor/xx->radius; - if ( rad > xx->radius ) + if ( rad > xx->radius ) { rad = xx->radius + sep; - else + } else { rad = xx->radius - sep; + } GetCurveAngles( &a0, &a1, trk ); if ( newTrkR ) { if (track) { @@ -1359,11 +1575,10 @@ static BOOL_T MakeParallelCurve( xx1 = GET_EXTRA_DATA(*newTrkR, T_CURVE, extraDataCurve_t); xx1->helixTurns = xx->helixTurns; xx1->circle = xx->circle; - } - else { + } else { + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); tempSegs(0).color = wDrawColorBlack; - tempSegs(0).width = 0; - tempSegs_da.cnt = 1; + tempSegs(0).lineWidth = 0; tempSegs(0).type = SEG_CRVLIN; tempSegs(0).u.c.center = xx->pos; tempSegs(0).u.c.radius = rad; @@ -1379,25 +1594,27 @@ static BOOL_T MakeParallelCurve( a0 = 0; a1 = 360.0; } + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); tempSegs(0).color = wDrawColorBlack; - tempSegs(0).width = 0; - tempSegs_da.cnt = 1; + tempSegs(0).lineWidth = 0; tempSegs(0).type = track?SEG_CRVTRK:SEG_CRVLIN; tempSegs(0).u.c.center = xx->pos; tempSegs(0).u.c.radius = rad; tempSegs(0).u.c.a0 = a0; tempSegs(0).u.c.a1 = a1; } - if ( p0R ) PointOnCircle( p0R, xx->pos, rad, a0 ); - if ( p1R ) PointOnCircle( p1R, xx->pos, rad, a0+a1 ); + if ( p0R ) { PointOnCircle( p0R, xx->pos, rad, a0 ); } + if ( p1R ) { PointOnCircle( p1R, xx->pos, rad, a0+a1 ); } return TRUE; } static wBool_t CompareCurve( track_cp trk1, track_cp trk2 ) { - struct extraDataCurve_t * ed1 = GET_EXTRA_DATA( trk1, T_CURVE, extraDataCurve_t ); - struct extraDataCurve_t * ed2 = GET_EXTRA_DATA( trk2, T_CURVE, extraDataCurve_t ); + struct extraDataCurve_t * ed1 = GET_EXTRA_DATA( trk1, T_CURVE, + extraDataCurve_t ); + struct extraDataCurve_t * ed2 = GET_EXTRA_DATA( trk2, T_CURVE, + extraDataCurve_t ); char * cp = message+strlen(message); REGRESS_CHECK_POS( "POS", ed1, ed2, pos ) REGRESS_CHECK_DIST( "RADIUS", ed1, ed2, radius ) @@ -1408,47 +1625,48 @@ static wBool_t CompareCurve( track_cp trk1, track_cp trk2 ) } static trackCmd_t curveCmds = { - "CURVE", - DrawCurve, - DistanceCurve, - DescribeCurve, - DeleteCurve, - WriteCurve, - ReadCurve, - MoveCurve, - RotateCurve, - RescaleCurve, - NULL, - GetAngleCurve, - SplitCurve, - TraverseCurve, - EnumerateCurve, - NULL, /* redraw */ - TrimCurve, - MergeCurve, - ModifyCurve, - GetLengthCurve, - GetParamsCurve, - MoveEndPtCurve, - QueryCurve, - NULL, /* ungroup */ - FlipCurve, - NULL, - NULL, - NULL, - MakeParallelCurve, - NULL, - NULL, - NULL, - NULL, - NULL, - CompareCurve }; + "CURVE", + DrawCurve, + DistanceCurve, + DescribeCurve, + DeleteCurve, + WriteCurve, + ReadCurve, + MoveCurve, + RotateCurve, + RescaleCurve, + NULL, + GetAngleCurve, + SplitCurve, + TraverseCurve, + EnumerateCurve, + NULL, /* redraw */ + TrimCurve, + MergeCurve, + ModifyCurve, + GetLengthCurve, + GetParamsCurve, + MoveEndPtCurve, + QueryCurve, + NULL, /* ungroup */ + FlipCurve, + NULL, + NULL, + NULL, + MakeParallelCurve, + NULL, + NULL, + NULL, + NULL, + NULL, + CompareCurve +}; EXPORT void CurveSegProc( - segProc_e cmd, - trkSeg_p segPtr, - segProcData_p data ) + segProc_e cmd, + trkSeg_p segPtr, + segProcData_p data ) { ANGLE_T a0, a1, a2; DIST_T d, circum, d0; @@ -1468,10 +1686,12 @@ EXPORT void CurveSegProc( //A segment may be fractionally too short - limit to angles within segment! int res = AngleInRange(a2,segPtr->u.c.a0,segPtr->u.c.a1); if (res == 1 ) { -LOG( log_curveSegs, 1, ("CrvSegsAngle miss A%0.3f S%0.3f E%0.3f R%d B%d \n",a2,segPtr->u.c.a0,segPtr->u.c.a1,res,data->traverse1.backwards)) + LOG( log_curveSegs, 1, ("CrvSegsAngle miss A%0.3f S%0.3f E%0.3f R%d B%d \n",a2, + segPtr->u.c.a0,segPtr->u.c.a1,res,data->traverse1.backwards)) a2 = segPtr->u.c.a0; } else if (res == -1) { -LOG( log_curveSegs, 1, ("CrvSegsAngle miss A%0.3f S%0.3f E%0.3f R%d B%d \n",a2,segPtr->u.c.a0,segPtr->u.c.a1,res,data->traverse1.backwards)) + LOG( log_curveSegs, 1, ("CrvSegsAngle miss A%0.3f S%0.3f E%0.3f R%d B%d \n",a2, + segPtr->u.c.a0,segPtr->u.c.a1,res,data->traverse1.backwards)) a2 = segPtr->u.c.a1+segPtr->u.c.a0; } //Fix issue of angles passing through zero - @@ -1482,19 +1702,22 @@ LOG( log_curveSegs, 1, ("CrvSegsAngle miss A%0.3f S%0.3f E%0.3f R%d B%d \n",a2,s } //Make sure backwards means going towards EP0 - if (segPtr->u.c.radius<0) data->traverse1.backwards = !data->traverse1.backwards; - data->traverse1.dist = a2/360.0*2*M_PI*fabs(segPtr->u.c.radius); //Distance from end in direction of travel + if (segPtr->u.c.radius<0) { data->traverse1.backwards = !data->traverse1.backwards; } + data->traverse1.dist = a2/360.0*2*M_PI*fabs( + segPtr->u.c.radius); //Distance from end in direction of travel data->traverse1.reverse_seg = ((segPtr->u.c.a0>=90) && (segPtr->u.c.a0<270)); data->traverse1.negative = (segPtr->u.c.radius < 0); data->traverse1.segs_backwards = FALSE; data->traverse1.BezSegInx = 0; -LOG( log_curveSegs, 2, (" CrvSegs D=%0.3f A%0.3f B%d \n",data->traverse1.dist,data->traverse1.backwards)) + LOG( log_curveSegs, 2, (" CrvSegs D=%0.3f A%0.3f B%d \n",data->traverse1.dist, + data->traverse1.backwards)) break; case SEGPROC_TRAVERSE2: circum = 2*M_PI*segPtr->u.c.radius; - if ( circum < 0 ) - circum = - circum; + if ( circum < 0 ) { + circum = - circum; + } d = (segPtr->u.c.a1*circum)/360; if ( d > data->traverse2.dist ) { a2 = (data->traverse2.dist*360.0)/circum; @@ -1503,7 +1726,7 @@ LOG( log_curveSegs, 2, (" CrvSegs D=%0.3f A%0.3f B%d \n",data->traverse1.dist,d a2 = segPtr->u.c.a1; data->traverse2.dist -= d; } - if (segPtr->u.c.radius<0) data->traverse2.segDir = !data->traverse2.segDir; + if (segPtr->u.c.radius<0) { data->traverse2.segDir = !data->traverse2.segDir; } if ( !data->traverse2.segDir ) { a2 = NormalizeAngle( segPtr->u.c.a0+a2 ); a1 = NormalizeAngle(a2+90); @@ -1511,30 +1734,38 @@ LOG( log_curveSegs, 2, (" CrvSegs D=%0.3f A%0.3f B%d \n",data->traverse1.dist,d a2 = NormalizeAngle( segPtr->u.c.a0+segPtr->u.c.a1-a2 ); a1 = NormalizeAngle(a2-90); } - PointOnCircle( &data->traverse2.pos, segPtr->u.c.center, fabs(segPtr->u.c.radius), a2 ); + PointOnCircle( &data->traverse2.pos, segPtr->u.c.center, + fabs(segPtr->u.c.radius), a2 ); data->traverse2.angle = a1; break; case SEGPROC_DRAWROADBEDSIDE: - REORIGIN( p0, segPtr->u.c.center, data->drawRoadbedSide.angle, data->drawRoadbedSide.orig ); + REORIGIN( p0, segPtr->u.c.center, data->drawRoadbedSide.angle, + data->drawRoadbedSide.orig ); d0 = segPtr->u.c.radius; if ( d0 > 0 ) { - a0 = NormalizeAngle( segPtr->u.c.a0 + segPtr->u.c.a1*data->drawRoadbedSide.first/32.0 + data->drawRoadbedSide.angle ); + a0 = NormalizeAngle( segPtr->u.c.a0 + + segPtr->u.c.a1*data->drawRoadbedSide.first/32.0 + data->drawRoadbedSide.angle ); } else { d0 = -d0; - a0 = NormalizeAngle( segPtr->u.c.a0 + segPtr->u.c.a1*(32-data->drawRoadbedSide.last)/32.0 + data->drawRoadbedSide.angle ); + a0 = NormalizeAngle( segPtr->u.c.a0 + segPtr->u.c.a1*(32 + -data->drawRoadbedSide.last)/32.0 + data->drawRoadbedSide.angle ); } - a1 = segPtr->u.c.a1*(data->drawRoadbedSide.last-data->drawRoadbedSide.first)/32.0; - if (data->drawRoadbedSide.side>0) + a1 = segPtr->u.c.a1*(data->drawRoadbedSide.last + -data->drawRoadbedSide.first)/32.0; + if (data->drawRoadbedSide.side>0) { d0 += data->drawRoadbedSide.roadbedWidth/2.0; - else + } else { d0 -= data->drawRoadbedSide.roadbedWidth/2.0; - DrawArc( data->drawRoadbedSide.d, p0, d0, a0, a1, FALSE, data->drawRoadbedSide.rbw, data->drawRoadbedSide.color ); + } + DrawArc( data->drawRoadbedSide.d, p0, d0, a0, a1, FALSE, + data->drawRoadbedSide.rbw, data->drawRoadbedSide.color ); break; case SEGPROC_DISTANCE: - data->distance.dd = CircleDistance( &data->distance.pos1, segPtr->u.c.center, fabs(segPtr->u.c.radius), segPtr->u.c.a0, segPtr->u.c.a1 ); + data->distance.dd = CircleDistance( &data->distance.pos1, segPtr->u.c.center, + fabs(segPtr->u.c.radius), segPtr->u.c.a0, segPtr->u.c.a1 ); break; case SEGPROC_FLIP: @@ -1542,13 +1773,15 @@ LOG( log_curveSegs, 2, (" CrvSegs D=%0.3f A%0.3f B%d \n",data->traverse1.dist,d break; case SEGPROC_NEWTRACK: - data->newTrack.trk = NewCurvedTrack( segPtr->u.c.center, fabs(segPtr->u.c.radius), segPtr->u.c.a0, segPtr->u.c.a1, 0 ); + data->newTrack.trk = NewCurvedTrack( segPtr->u.c.center, + fabs(segPtr->u.c.radius), segPtr->u.c.a0, segPtr->u.c.a1, 0 ); data->newTrack.ep[0] = (segPtr->u.c.radius>0?0:1); data->newTrack.ep[1] = 1-data->newTrack.ep[0]; break; case SEGPROC_LENGTH: - data->length.length = fabs(segPtr->u.c.radius) * segPtr->u.c.a1 * (2.0*M_PI/360.0); + data->length.length = fabs(segPtr->u.c.radius) * segPtr->u.c.a1 * + (2.0*M_PI/360.0); break; case SEGPROC_SPLIT: @@ -1556,32 +1789,36 @@ LOG( log_curveSegs, 2, (" CrvSegs D=%0.3f A%0.3f B%d \n",data->traverse1.dist,d a2 = FindAngle( segPtr->u.c.center, data->split.pos ); a2 = NormalizeAngle( a2 - segPtr->u.c.a0 ); if ( a2 > segPtr->u.c.a1 ) { - if ( a2-segPtr->u.c.a1 < (360-segPtr->u.c.a1)/2.0 ) + if ( a2-segPtr->u.c.a1 < (360-segPtr->u.c.a1)/2.0 ) { a2 = segPtr->u.c.a1; - else + } else { a2 = 0.0; + } } s0 = 0; - if ( segPtr->u.c.radius<0 ) + if ( segPtr->u.c.radius<0 ) { s0 = 1-s0; + } s1 = 1-s0; data->split.length[s0] = a2/360.0 * 2*M_PI * fabs(segPtr->u.c.radius); data->split.length[s1] = d-data->split.length[s0]; data->split.newSeg[0] = *segPtr; data->split.newSeg[1] = *segPtr; data->split.newSeg[s0].u.c.a1 = a2; - data->split.newSeg[s1].u.c.a0 = NormalizeAngle( data->split.newSeg[s1].u.c.a0 + a2 ); + data->split.newSeg[s1].u.c.a0 = NormalizeAngle( data->split.newSeg[s1].u.c.a0 + + a2 ); data->split.newSeg[s1].u.c.a1 -= a2; break; case SEGPROC_GETANGLE: - data->getAngle.angle = NormalizeAngle( FindAngle( segPtr->u.c.center, data->getAngle.pos ) + 90 ); + data->getAngle.angle = NormalizeAngle( FindAngle( segPtr->u.c.center, + data->getAngle.pos ) + 90 ); data->getAngle.negative_radius = segPtr->u.c.radius<0; data->getAngle.radius = fabs(segPtr->u.c.radius); data->getAngle.center = segPtr->u.c.center; data->getAngle.backwards = segPtr->u.c.a0>=90 && segPtr->u.c.a0<270; - if (data->getAngle.backwards) data->getAngle.angle = NormalizeAngle(data->getAngle.angle+180); + if (data->getAngle.backwards) { data->getAngle.angle = NormalizeAngle(data->getAngle.angle+180); } break; } } @@ -1596,13 +1833,13 @@ LOG( log_curveSegs, 2, (" CrvSegs D=%0.3f A%0.3f B%d \n",data->traverse1.dist,d EXPORT void PlotCurve( - long mode, - coOrd pos0, - coOrd pos1, - coOrd pos2, - curveData_t * curveData, - BOOL_T constrain, //Make the Radius be in steps of radiusGranularity (1/8) - DIST_T desired_r) //Target one radius if close + long mode, + coOrd pos0, + coOrd pos1, + coOrd pos2, + curveData_t * curveData, + BOOL_T constrain, //Make the Radius be in steps of radiusGranularity (1/8) + DIST_T desired_r) //Target one radius if close { DIST_T d0, d2, r; ANGLE_T angle, a0, a1, a2; @@ -1610,19 +1847,21 @@ EXPORT void PlotCurve( switch ( mode ) { case crvCmdFromCornu: - /* Already set curveRadius, pos1, and type */ + /* Already set curveRadius, pos1, and type */ case crvCmdFromEP1: angle = FindAngle( pos0, pos1 ); d0 = FindDistance( pos0, pos2 )/2.0; a0 = FindAngle( pos0, pos2 ); a1 = NormalizeAngle( a0 - angle ); -LOG( log_curve, 3, ( "P1 = [%0.3f %0.3f] D=%0.3f A0=%0.3f A1=%0.3f\n", pos2.x, pos2.y, d0, a0, a1 ) ) + LOG( log_curve, 3, ( "P1 = [%0.3f %0.3f] D=%0.3f A0=%0.3f A1=%0.3f\n", pos2.x, + pos2.y, d0, a0, a1 ) ) if ((fabs(d0*sin(D2R(a1))) < (4.0/75.0)*mainD.scale)) { -LOG( log_curve, 3, ( "Straight: %0.3f < %0.3f\n", d0*sin(D2R(a1)), (4.0/75.0)*mainD.scale ) ) + LOG( log_curve, 3, ( "Straight: %0.3f < %0.3f\n", d0*sin(D2R(a1)), + (4.0/75.0)*mainD.scale ) ) curveData->pos1.x = pos0.x + d0*2.0*sin(D2R(angle)); curveData->pos1.y = pos0.y + d0*2.0*cos(D2R(angle)); curveData->type = curveTypeStraight; - } else if (a1 >= 179.0 && a1 <= 181.0) { + } else if (a1 >= 179.0 && a1 <= 181.0) { curveData->type = curveTypeNone; } else { BOOL_T found = FALSE; @@ -1635,10 +1874,11 @@ LOG( log_curve, 3, ( "Straight: %0.3f < %0.3f\n", d0*sin(D2R(a1)), (4.0/75.0)*ma } } if (!found) { - if (constrain) + if (constrain) { curveData->curveRadius = ConstrainR( d0/sin(D2R(a1)) ); - else + } else { curveData->curveRadius = d0/sin(D2R(a1)); + } } } else { a1 -= 360.0; @@ -1649,11 +1889,12 @@ LOG( log_curve, 3, ( "Straight: %0.3f < %0.3f\n", d0*sin(D2R(a1)), (4.0/75.0)*ma found = TRUE; } } - if (!found){ - if (constrain) + if (!found) { + if (constrain) { curveData->curveRadius = ConstrainR( d0/sin(D2R(-a1)) ); - else + } else { curveData->curveRadius = d0/sin(D2R(-a1)); + } } } if (curveData->curveRadius > 1000) { @@ -1665,7 +1906,7 @@ LOG( log_curve, 3, ( "Straight: %0.3f < %0.3f\n", d0*sin(D2R(a1)), (4.0/75.0)*ma curveData->curvePos.x = pos0.x + curveData->curveRadius*sin(D2R(a2)); curveData->curvePos.y = pos0.y + curveData->curveRadius*cos(D2R(a2)); LOG( log_curve, 3, ( "Center = [%0.3f %0.3f] A1=%0.3f A2=%0.3f R=%0.3f\n", - curveData->curvePos.x, curveData->curvePos.y, a1, a2, curveData->curveRadius ) ) + curveData->curvePos.x, curveData->curvePos.y, a1, a2, curveData->curveRadius ) ) if (a1 > 0.0) { curveData->a0 = NormalizeAngle( a2-180 ); curveData->a1 = a1 * 2.0; @@ -1675,7 +1916,8 @@ LOG( log_curve, 3, ( "Straight: %0.3f < %0.3f\n", d0*sin(D2R(a1)), (4.0/75.0)*ma curveData->a0 = NormalizeAngle( a2-180-curveData->a1 ); curveData->negative = TRUE; } - Translate(&curveData->pos2,curveData->curvePos,FindAngle(curveData->curvePos,pos2),curveData->curveRadius); + Translate(&curveData->pos2,curveData->curvePos,FindAngle(curveData->curvePos, + pos2),curveData->curveRadius); curveData->type = curveTypeCurve; } } @@ -1699,7 +1941,8 @@ LOG( log_curve, 3, ( "Straight: %0.3f < %0.3f\n", d0*sin(D2R(a1)), (4.0/75.0)*ma curveData->a0 = a1; curveData->a1 = NormalizeAngle(a0-a1); } - Translate(&curveData->pos2,curveData->curvePos,FindAngle(curveData->curvePos,pos2),curveData->curveRadius); + Translate(&curveData->pos2,curveData->curvePos,FindAngle(curveData->curvePos, + pos2),curveData->curveRadius); curveData->type = curveTypeCurve; break; case crvCmdFromChord: @@ -1709,16 +1952,20 @@ LOG( log_curve, 3, ( "Straight: %0.3f < %0.3f\n", d0*sin(D2R(a1)), (4.0/75.0)*ma d0 = FindDistance( pos0, pos1 )/2.0; Rotate( &pos2, pos1, -a0 ); pos2.x -= pos1.x; - if ( fabs(pos2.x) < 0.005 ) + if ( fabs(pos2.x) < 0.005 ) { break; - d2 = sqrt( d0*d0 + pos2.x*pos2.x )/2.0; + } + d2 = sqrt( d0*d0 + pos2.x*pos2.x )/2.0; r = d2*d2*2.0/pos2.x; - if ( r > 1000.0 ) + if ( r > 1000.0 ) { break; + } posx.x = (pos1.x+pos0.x)/2.0; posx.y = (pos1.y+pos0.y)/2.0; a0 -= 90.0; - LOG( log_curve, 3, ( "CHORD: [%0.3f %0.3f] [%0.3f %0.3f] [%0.3f %0.3f] A0=%0.3f D0=%0.3f D2=%0.3f R=%0.3f\n", pos0.x, pos0.y, pos1.x, pos1.y, pos2.x, pos2.y, a0, d0, d2, r ) ) + LOG( log_curve, 3, + ( "CHORD: [%0.3f %0.3f] [%0.3f %0.3f] [%0.3f %0.3f] A0=%0.3f D0=%0.3f D2=%0.3f R=%0.3f\n", + pos0.x, pos0.y, pos1.x, pos1.y, pos2.x, pos2.y, a0, d0, d2, r ) ) Translate( &curveData->curvePos, posx, a0, r-pos2.x ); curveData->curveRadius = fabs(r); a0 = FindAngle( curveData->curvePos, pos0 ); @@ -1732,13 +1979,15 @@ LOG( log_curve, 3, ( "Straight: %0.3f < %0.3f\n", d0*sin(D2R(a1)), (4.0/75.0)*ma curveData->a1 = NormalizeAngle(a0-a1); curveData->negative = TRUE; } - Translate(&curveData->pos2,curveData->curvePos,FindAngle(curveData->curvePos,pos2),curveData->curveRadius); + Translate(&curveData->pos2,curveData->curvePos,FindAngle(curveData->curvePos, + pos2),curveData->curveRadius); curveData->type = curveTypeCurve; break; } } -EXPORT track_p NewCurvedTrack( coOrd pos, DIST_T r, ANGLE_T a0, ANGLE_T a1, long helixTurns ) +EXPORT track_p NewCurvedTrack( coOrd pos, DIST_T r, ANGLE_T a0, ANGLE_T a1, + long helixTurns ) { struct extraDataCurve_t *xx; track_p p; @@ -1747,10 +1996,12 @@ EXPORT track_p NewCurvedTrack( coOrd pos, DIST_T r, ANGLE_T a0, ANGLE_T a1, long xx->pos = pos; xx->radius = r; xx->helixTurns = helixTurns; - if ( helixTurns <= 0 ) + if ( helixTurns <= 0 ) { SetTrkBits( p, TB_HIDEDESC ); + } SetCurveAngles( p, a0, a1, xx ); -LOG( log_curve, 1, ( "NewCurvedTrack( %0.3f, %0.3f, %0.3f ) = %d\n", pos.x, pos.y, r, GetTrkIndex(p) ) ) + LOG( log_curve, 1, ( "NewCurvedTrack( %0.3f, %0.3f, %0.3f ) = %d\n", pos.x, + pos.y, r, GetTrkIndex(p) ) ) ComputeCurveBoundingBox( p, xx ); CheckTrackLength( p ); return p; diff --git a/app/bin/tease.c b/app/bin/tease.c index adfff18..806ab22 100644 --- a/app/bin/tease.c +++ b/app/bin/tease.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* @@ -29,7 +29,7 @@ L is the length along the tangent of the curve and R is the radius of an arc at the end of the curve. At any point (l) along the tangent the arc at that point has radius r=(R*L)/l. -The transition curve offset (x) is the closest distance between the arc +The transition curve offset (x) is the closest distance between the arc and the tangent. The center of any arc is at (l/2, r+x). See 'ComputeJointPos()' for details on this. @@ -78,16 +78,16 @@ static TRKTYP_T T_EASEMENT = -1; static ANGLE_T JOINT_ANGLE_INCR = 2.0; typedef struct extraDataEase_t { - extraDataBase_t base; - DIST_T l0, l1; /* curve start and end parameter */ - DIST_T R, L; /* curve control parameters */ - BOOL_T flip; /* T: endPt[1] - is l0 */ - BOOL_T negate; /* T: curves to the left */ - BOOL_T Scurve; /* T: is an S-curve */ - coOrd pos; /* Pos of origin */ - ANGLE_T angle; /* Angle of curve tangent */ - coOrd descriptionOff; /* Offset of description */ - } extraDataEase_t; + extraDataBase_t base; + DIST_T l0, l1; /* curve start and end parameter */ + DIST_T R, L; /* curve control parameters */ + BOOL_T flip; /* T: endPt[1] - is l0 */ + BOOL_T negate; /* T: curves to the left */ + BOOL_T Scurve; /* T: is an S-curve */ + coOrd pos; /* Pos of origin */ + ANGLE_T angle; /* Angle of curve tangent */ + coOrd descriptionOff; /* Offset of description */ +} extraDataEase_t; #define EASE_MIN_X (0.01) @@ -97,9 +97,9 @@ static int log_traverseJoint; static DIST_T FindL( - DIST_T r, - DIST_T R, - DIST_T L ) + DIST_T r, + DIST_T R, + DIST_T L ) /* * Given a radius (r) return control value (l). * This function is it's inverse! @@ -110,15 +110,15 @@ static DIST_T FindL( static void GetLandD( - DIST_T *RL, - DIST_T *RD, - coOrd q, - coOrd p, - ANGLE_T a, - DIST_T R, - DIST_T L, - BOOL_T negate, - BOOL_T Scurve ) + DIST_T *RL, + DIST_T *RD, + coOrd q, + coOrd p, + ANGLE_T a, + DIST_T R, + DIST_T L, + BOOL_T negate, + BOOL_T Scurve ) { DIST_T l, d, x; @@ -132,22 +132,24 @@ static void GetLandD( } else { d = q.x + x; } - if (RL) + if (RL) { *RL = l; - if (RD) + } + if (RD) { *RD = d; + } } int OLDEASE = 0; static void ComputeJoinPos( - DIST_T l, - DIST_T R, - DIST_T L, - DIST_T *RR, - ANGLE_T *RA, - coOrd *P, - coOrd *PC ) + DIST_T l, + DIST_T R, + DIST_T L, + DIST_T *RR, + ANGLE_T *RA, + coOrd *P, + coOrd *PC ) /* * Compute position along transition-curve. * Also compute angle and position of tangent circle's center. @@ -156,35 +158,40 @@ static void ComputeJoinPos( ANGLE_T a; DIST_T r; coOrd pp, pc; - if (l==0.0) + if (l==0.0) { r = DIST_INF; - else + } else { r = (R*L)/l; + } pp.y = l; pc.y = l/2.0; a = asin( l/2.0 / r ); -if (OLDEASE){ - pc.x = l*l / (24*r) + r; - pp.x = pc.x - r*cos(a); -}else{ - pp.x = (l*l*l)/(6*R*L); - pc.x = pp.x + r*cos(a); -} -/*lprintf( "A %0.3f %0.3f %0.3f [%0.3f %0.3f]\n", a, aa, aaa, q.x, q.y );*/ - if (P) + if (OLDEASE) { + pc.x = l*l / (24*r) + r; + pp.x = pc.x - r*cos(a); + } else { + pp.x = (l*l*l)/(6*R*L); + pc.x = pp.x + r*cos(a); + } + /*lprintf( "A %0.3f %0.3f %0.3f [%0.3f %0.3f]\n", a, aa, aaa, q.x, q.y );*/ + if (P) { *P = pp; - if (PC) + } + if (PC) { *PC = pc; - if (RR) + } + if (RR) { *RR = r; - if (RA) + } + if (RA) { *RA = R2D(a); + } } static DIST_T JoinD( - DIST_T l, - DIST_T R, - DIST_T L ) + DIST_T l, + DIST_T R, + DIST_T L ) /* * Compute distance from transition-curve origin to specified point. * Distance is approximately equal to length of arc from origin @@ -209,9 +216,9 @@ static DIST_T JoinD( static DIST_T GetLfromD( - DIST_T D, - DIST_T R, - DIST_T L ) + DIST_T D, + DIST_T R, + DIST_T L ) { DIST_T deltaD, d, l, deltaL; l = L/2.0; @@ -223,28 +230,30 @@ static DIST_T GetLfromD( } else { deltaD = d-D; } - if ( deltaD < 0.000001 ) + if ( deltaD < 0.000001 ) { return l; - if ( d < D ) + } + if ( d < D ) { l += deltaL; - else + } else { l -= deltaL; + } deltaL /= 2.0; } -/*printf( "GetLfromD( %0.3f %0.3f %0.3f ) = %0.3f\n", D, R, L, l );*/ + /*printf( "GetLfromD( %0.3f %0.3f %0.3f ) = %0.3f\n", D, R, L, l );*/ return l; } #ifdef LATER static void JoinDistance( - DIST_T r, - DIST_T R, - DIST_T X, - DIST_T L, - DIST_T *dr, - DIST_T *xr, - DIST_T *lr ) + DIST_T r, + DIST_T R, + DIST_T X, + DIST_T L, + DIST_T *dr, + DIST_T *xr, + DIST_T *lr ) { DIST_T l, d, rr; coOrd p, pc; @@ -256,7 +265,7 @@ static void JoinDistance( l = FindL( r, R, L ); d = JoinD( l, R, L ); ComputeJoinPos( l, R, L, NULL, NULL, &p, NULL ); -LOG( log_ease, 2, ( "joinDistance r=%0.3f rr=%0.3f\n", r, rr ) ) + LOG( log_ease, 2, ( "joinDistance r=%0.3f rr=%0.3f\n", r, rr ) ) *xr = pc.x - rr; *dr = d; *lr = pc.y; @@ -264,10 +273,10 @@ LOG( log_ease, 2, ( "joinDistance r=%0.3f rr=%0.3f\n", r, rr ) ) #endif EXPORT STATUS_T ComputeJoint( - DIST_T r0, - DIST_T r1, - easementData_t * e ) -/* + DIST_T r0, + DIST_T r1, + easementData_t * e ) +/* * Compute joint data given radius of the 2 curves being joined. * Radius is =0 for straight tracks and <0 for left-handed curves. * S-curves are handled by treating them as 2 transition-curves joined @@ -278,7 +287,7 @@ EXPORT STATUS_T ComputeJoint( ANGLE_T a, a0, a1; coOrd rp0, rpc0, rp1, rpc1; -LOG( log_ease, 4, ( "ComputeJoint( %0.3f, %0.3f )\n", r0, r1 ) ) + LOG( log_ease, 4, ( "ComputeJoint( %0.3f, %0.3f )\n", r0, r1 ) ) if (easementVal <= 0.1) { e->d0 = e->d1 = e->x = 0.0; @@ -286,17 +295,18 @@ LOG( log_ease, 4, ( "ComputeJoint( %0.3f, %0.3f )\n", r0, r1 ) ) } if (r0 != 0.0 && fabs(r0) < easeR) { ErrorMessage( MSG_RADIUS_LSS_EASE_MIN, - FormatDistance(fabs(r0)), FormatDistance(easeR) ); + FormatDistance(fabs(r0)), FormatDistance(easeR) ); e->d0 = e->d1 = e->x = 0.0; return E_ERROR; } if (r1 != 0.0 && fabs(r1) < easeR) { - ErrorMessage( MSG_RADIUS_LSS_EASE_MIN, FormatDistance(fabs(r1)), FormatDistance(easeR) ); + ErrorMessage( MSG_RADIUS_LSS_EASE_MIN, FormatDistance(fabs(r1)), + FormatDistance(easeR) ); e->d0 = e->d1 = e->x = 0.0; return E_ERROR; } if (r0 == 0.0 && r1 == 0.0) { - /* ASSERT( FALSE ); CHECKME */ + /* CHECK( FALSE ); CHECKME */ e->d0 = e->d1 = e->x = 0.0; return E_NOTREQ; } @@ -356,8 +366,9 @@ LOG( log_ease, 4, ( "ComputeJoint( %0.3f, %0.3f )\n", r0, r1 ) ) d1 = rr1 * D2R(a1); } } -LOG( log_ease, 2, ( "CJoint(%0.3f %0.3f) l0=%0.3f d0=%0.3f l1=%0.3f d1=%0.3f x=%0.3f S%d F%d N%d\n", - e->r0, e->r1, l0, d0, l1, d1, xx, e->Scurve, e->flip, e->negate ) ) + LOG( log_ease, 2, + ( "CJoint(%0.3f %0.3f) l0=%0.3f d0=%0.3f l1=%0.3f d1=%0.3f x=%0.3f S%d F%d N%d\n", + e->r0, e->r1, l0, d0, l1, d1, xx, e->Scurve, e->flip, e->negate ) ) if (xx < EASE_MIN_X || d0+d1<=minLength) { e->d0 = e->d1 = e->x = 0.0; return E_NOTREQ; @@ -379,14 +390,14 @@ LOG( log_ease, 2, ( "CJoint(%0.3f %0.3f) l0=%0.3f d0=%0.3f l1=%0.3f d1=%0.3f x=% } static track_p NewJoint( - coOrd pos0, - ANGLE_T angle0, - coOrd pos1, - ANGLE_T angle1, - DIST_T trackGauge, - DIST_T R, - DIST_T L, - easementData_t * e ) + coOrd pos0, + ANGLE_T angle0, + coOrd pos1, + ANGLE_T angle1, + DIST_T trackGauge, + DIST_T R, + DIST_T L, + easementData_t * e ) /* * Allocate a joint track segment. * Allocate a track, save relevant data from (*e), @@ -398,7 +409,8 @@ static track_p NewJoint( struct extraDataEase_t *xx; coOrd p, p0, p1, q0, q1; static coOrd qZero = { 0.0, 0.0 }; - ANGLE_T az0, a01, b, b01, b1, d, d1; + ANGLE_T az0, a01, b, b01, d, d1; +// ANGLE_T b1; trk = NewTrack( 0, T_EASEMENT, 2, sizeof *xx ); SetTrkBits(trk, TB_HIDEDESC); //Suppress Description for new Joint SetTrkScale( trk, GetLayoutCurScale() ); @@ -431,7 +443,7 @@ static track_p NewJoint( if (!e->Scurve) { az0 = FindAngle( qZero, q0 ); a01 = FindAngle( q0, q1 ); - b1 = NormalizeAngle( b01 - (a01+az0) ); +// b1 = NormalizeAngle( b01 - (a01+az0) ); b = NormalizeAngle( b01 - a01 ); } else { q1.x = -q1.x; @@ -449,9 +461,10 @@ static track_p NewJoint( ComputeBoundingBox( trk ); d = FindDistance( p0, p1 ); d1 = FindDistance( q0, q1 ); -LOG( log_ease, 1, ( "NewJoint( [%0.3f %0.3f] A%0.3f, [%0.3f %0.3f] A%0.3f\n B01=%0.3f AZ0=%0.3f A01=%0.3f B=%0.3f D0=%0.3f D1=%0.3f\n", - pos0.x, pos0.y, angle0, pos1.x, pos1.y, angle1, - b01, az0, a01, b, d, d1 ) ) + LOG( log_ease, 1, + ( "NewJoint( [%0.3f %0.3f] A%0.3f, [%0.3f %0.3f] A%0.3f\n B01=%0.3f AZ0=%0.3f A01=%0.3f B=%0.3f D0=%0.3f D1=%0.3f\n", + pos0.x, pos0.y, angle0, pos1.x, pos1.y, angle1, + b01, az0, a01, b, d, d1 ) ) CheckTrackLength( trk ); return trk; } @@ -469,10 +482,11 @@ static DIST_T GetLengthJoint( track_p trk ) xx = GET_EXTRA_DATA(trk, T_EASEMENT, extraDataEase_t); d0 = JoinD( xx->l0, xx->R, xx->L ); d1 = JoinD( xx->l1, xx->R, xx->L ); - if (xx->Scurve) + if (xx->Scurve) { return d0+d1; - else + } else { return fabs( d0-d1 ); + } } static DIST_T GetFlexLengthJoint( track_p trk ) @@ -485,55 +499,61 @@ static DIST_T GetFlexLengthJoint( track_p trk ) d3 = JoinD( xx->l1, xx->R-(GetTrkGauge(trk)/2.0), xx->L ); if (xx->Scurve) { return d0+d3; - } else + } else { return fabs( d0-d1 ); + } } static struct { - coOrd endPt[2]; - DIST_T elev[2]; - FLOAT_T length; - coOrd orig; - ANGLE_T angle; - DIST_T r; - DIST_T l; - DIST_T l0; - DIST_T l1; - FLOAT_T grade; - descPivot_t pivot; - unsigned int layerNumber; - } jointData; + coOrd endPt[2]; + DIST_T elev[2]; + FLOAT_T length; + coOrd orig; + ANGLE_T angle; + DIST_T r; + DIST_T l; + DIST_T l0; + DIST_T l1; + FLOAT_T grade; + descPivot_t pivot; + unsigned int layerNumber; +} jointData; typedef enum { E0, Z0, E1, Z1, OR, AL, RR, LL, L0, L1, GR, PV, LY } jointDesc_e; static descData_t jointDesc[] = { -/*E0*/ { DESC_POS, N_("End Pt 1: X,Y"), &jointData.endPt[0] }, -/*Z0*/ { DESC_DIM, N_("Z"), &jointData.elev[0] }, -/*E1*/ { DESC_POS, N_("End Pt 2: X,Y"), &jointData.endPt[1] }, -/*Z1*/ { DESC_DIM, N_("Z"), &jointData.elev[1] }, -/*OR*/ { DESC_POS, N_("Origin: X,Y"), &jointData.orig }, -/*AL*/ { DESC_ANGLE, N_("Angle"), &jointData.angle }, -/*RR*/ { DESC_DIM, N_("R"), &jointData.r }, -/*LL*/ { DESC_DIM, N_("L"), &jointData.l }, -/*L0*/ { DESC_DIM, N_("l0"), &jointData.l0 }, -/*L1*/ { DESC_DIM, N_("l1"), &jointData.l1 }, -/*GR*/ { DESC_FLOAT, N_("Grade"), &jointData.grade }, -/*PV*/ { DESC_PIVOT, N_("Lock"), &jointData.pivot }, -/*LY*/ { DESC_LAYER, N_("Layer"), &jointData.layerNumber }, - { DESC_NULL } }; - -static void UpdateJoint( track_p trk, int inx, descData_p descUpd, BOOL_T final ) + /*E0*/ { DESC_POS, N_("End Pt 1: X,Y"), &jointData.endPt[0] }, + /*Z0*/ { DESC_DIM, N_("Z"), &jointData.elev[0] }, + /*E1*/ { DESC_POS, N_("End Pt 2: X,Y"), &jointData.endPt[1] }, + /*Z1*/ { DESC_DIM, N_("Z"), &jointData.elev[1] }, + /*OR*/ { DESC_POS, N_("Origin: X,Y"), &jointData.orig }, + /*AL*/ { DESC_ANGLE, N_("Angle"), &jointData.angle }, + /*RR*/ { DESC_DIM, N_("R"), &jointData.r }, + /*LL*/ { DESC_DIM, N_("L"), &jointData.l }, + /*L0*/ { DESC_DIM, N_("l0"), &jointData.l0 }, + /*L1*/ { DESC_DIM, N_("l1"), &jointData.l1 }, + /*GR*/ { DESC_FLOAT, N_("Grade"), &jointData.grade }, + /*PV*/ { DESC_PIVOT, N_("Lock"), &jointData.pivot }, + /*LY*/ { DESC_LAYER, N_("Layer"), &jointData.layerNumber }, + { DESC_NULL } +}; + +static void UpdateJoint( track_p trk, int inx, descData_p descUpd, + BOOL_T final ) { EPINX_T ep; switch (inx) { case Z0: case Z1: ep = (inx==Z0?0:1); - UpdateTrkEndElev( trk, ep, GetTrkEndElevUnmaskedMode(trk,ep), jointData.elev[ep], NULL ); + UpdateTrkEndElev( trk, ep, GetTrkEndElevUnmaskedMode(trk,ep), + jointData.elev[ep], NULL ); ComputeElev( trk, 1-ep, FALSE, &jointData.elev[1-ep], NULL, TRUE ); - if ( jointData.length > minLength ) - jointData.grade = fabs( (jointData.elev[0]-jointData.elev[1])/jointData.length )*100.0; - else + if ( jointData.length > minLength ) { + jointData.grade = fabs( (jointData.elev[0]-jointData.elev[1])/jointData.length ) + *100.0; + } else { jointData.grade = 0.0; + } jointDesc[GR].mode |= DESC_CHANGE; jointDesc[inx==Z0?Z1:Z0].mode |= DESC_CHANGE; return; @@ -547,9 +567,9 @@ static void UpdateJoint( track_p trk, int inx, descData_p descUpd, BOOL_T final static void DescribeJoint( - track_p trk, - char * str, - CSIZE_T len ) + track_p trk, + char * str, + CSIZE_T len ) /* * Print some interesting info about the track. */ @@ -557,11 +577,13 @@ static void DescribeJoint( struct extraDataEase_t *xx = GET_EXTRA_DATA(trk, T_EASEMENT, extraDataEase_t); int fix0, fix1; - sprintf( str, _("Joint Track(%d): Layer=%d Length=%0.3f EP=[%0.3f,%0.3f A%0.3f] [%0.3f,%0.3f A%0.3f]"), GetTrkIndex(trk), - GetTrkLayer(trk)+1, - GetLengthJoint( trk ), - GetTrkEndPosXY(trk,0), GetTrkEndAngle(trk,0), - GetTrkEndPosXY(trk,1), GetTrkEndAngle(trk,1) ); + sprintf( str, + _("Joint Track(%d): Layer=%d Length=%0.3f EP=[%0.3f,%0.3f A%0.3f] [%0.3f,%0.3f A%0.3f]"), + GetTrkIndex(trk), + GetTrkLayer(trk)+1, + GetLengthJoint( trk ), + GetTrkEndPosXY(trk,0), GetTrkEndAngle(trk,0), + GetTrkEndPosXY(trk,1), GetTrkEndAngle(trk,1) ); fix0 = GetTrkEndTrk(trk,0)!=NULL; fix1 = GetTrkEndTrk(trk,1)!=NULL; @@ -578,42 +600,44 @@ static void DescribeJoint( jointData.layerNumber = GetTrkLayer(trk); ComputeElev( trk, 0, FALSE, &jointData.elev[0], NULL, FALSE ); ComputeElev( trk, 1, FALSE, &jointData.elev[1], NULL, FALSE ); - if ( jointData.length > minLength ) - jointData.grade = fabs( (jointData.elev[0]-jointData.elev[1])/jointData.length )*100.0; - else + if ( jointData.length > minLength ) { + jointData.grade = fabs( (jointData.elev[0]-jointData.elev[1])/jointData.length ) + *100.0; + } else { jointData.grade = 0.0; + } jointDesc[E0].mode = - jointDesc[E1].mode = - jointDesc[OR].mode = - jointDesc[AL].mode = - jointDesc[RR].mode = - jointDesc[LL].mode = - jointDesc[L0].mode = - jointDesc[L1].mode = - DESC_RO; + jointDesc[E1].mode = + jointDesc[OR].mode = + jointDesc[AL].mode = + jointDesc[RR].mode = + jointDesc[LL].mode = + jointDesc[L0].mode = + jointDesc[L1].mode = + DESC_RO; jointDesc[Z0].mode = (EndPtIsDefinedElev(trk,0)?0:DESC_RO)|DESC_NOREDRAW; jointDesc[Z1].mode = (EndPtIsDefinedElev(trk,1)?0:DESC_RO)|DESC_NOREDRAW; jointDesc[GR].mode = DESC_RO; jointDesc[PV].mode = (fix0|fix1)?DESC_IGNORE:0; jointDesc[LY].mode = DESC_NOREDRAW; jointData.pivot = (fix0&fix1)?DESC_PIVOT_NONE: - fix0?DESC_PIVOT_FIRST: - fix1?DESC_PIVOT_SECOND: - DESC_PIVOT_MID; + fix0?DESC_PIVOT_FIRST: + fix1?DESC_PIVOT_SECOND: + DESC_PIVOT_MID; DoDescribe( _("Easement Track"), trk, jointDesc, UpdateJoint ); } static void GetJointPos( - coOrd * RP, - ANGLE_T * RA, - DIST_T l, - DIST_T R, - DIST_T L, - coOrd P, - ANGLE_T A, - BOOL_T N ) + coOrd * RP, + ANGLE_T * RA, + DIST_T l, + DIST_T R, + DIST_T L, + coOrd P, + ANGLE_T A, + BOOL_T N ) /* * Compute position of point on transition-curve. */ @@ -621,42 +645,46 @@ static void GetJointPos( coOrd p1; static coOrd pZero = {0.0,0.0}; ComputeJoinPos( l, R, L, NULL, RA, &p1, NULL ); - if (N) + if (N) { p1.x = -p1.x; + } Rotate( &p1, pZero, A ); if (RP) { RP->x = P.x + p1.x; RP->y = P.y + p1.y; } - if (RA) + if (RA) { *RA = NormalizeAngle( A + (N?-*RA:*RA) ); + } } EXPORT DIST_T JointDistance( - coOrd * q, - coOrd pos, - ANGLE_T angle, - DIST_T l0, - DIST_T l1, - DIST_T R, - DIST_T L, - BOOL_T negate, - BOOL_T Scurve ) + coOrd * q, + coOrd pos, + ANGLE_T angle, + DIST_T l0, + DIST_T l1, + DIST_T R, + DIST_T L, + BOOL_T negate, + BOOL_T Scurve ) { DIST_T d, l; coOrd p0 = *q; GetLandD( &l, &d, p0, pos, angle, R, L, negate, Scurve ); if (Scurve) { - if ( l < -l1 ) + if ( l < -l1 ) { l = -l1; - else if ( l > l0 ) + } else if ( l > l0 ) { l = l0; + } } else { - if ( l < l0 ) + if ( l < l0 ) { l = l0; - else if ( l > l1 ) + } else if ( l > l1 ) { l = l1; + } } GetJointPos( q, NULL, l, R, L, pos, angle, negate ); d = FindDistance( p0, *q ); @@ -665,31 +693,32 @@ EXPORT DIST_T JointDistance( static DIST_T DistanceJoint( - track_p trk, - coOrd * p ) + track_p trk, + coOrd * p ) /* * Determine how close (p) is to (t). */ { struct extraDataEase_t * xx = GET_EXTRA_DATA(trk, T_EASEMENT, extraDataEase_t); - return JointDistance( p, xx->pos, xx->angle, xx->l0, xx->l1, xx->R, xx->L, xx->negate, xx->Scurve ); + return JointDistance( p, xx->pos, xx->angle, xx->l0, xx->l1, xx->R, xx->L, + xx->negate, xx->Scurve ); } static void DrawJointSegment( - drawCmd_p d, - wIndex_t cnt, - DIST_T l0, - DIST_T l1, - DIST_T R, - DIST_T L, - coOrd P, - ANGLE_T A, - BOOL_T N, - DIST_T trackGauge, - wDrawColor color, - long widthOptions, - track_p trk ) + drawCmd_p d, + wIndex_t cnt, + DIST_T l0, + DIST_T l1, + DIST_T R, + DIST_T L, + coOrd P, + ANGLE_T A, + BOOL_T N, + DIST_T trackGauge, + wDrawColor color, + long widthOptions, + track_p trk ) /* * Draw a transition-curve from (l0) to (l1), * at angle (A) from origin (P). @@ -718,46 +747,48 @@ static void DrawJointSegment( DrawLine(d,p0,p1,thick,color); } DrawStraightTrack( d, p0, p1, FindAngle( p1, p0 ), trk, - color, widthOptions ); + color, widthOptions ); p0 = p1; } } EXPORT coOrd GetJointSegEndPos( - coOrd pos, - ANGLE_T angle, - DIST_T l0, - DIST_T l1, - DIST_T R, - DIST_T L, - BOOL_T negate, - BOOL_T flip, - BOOL_T Scurve, - EPINX_T ep, - ANGLE_T * angleR ) + coOrd pos, + ANGLE_T angle, + DIST_T l0, + DIST_T l1, + DIST_T R, + DIST_T L, + BOOL_T negate, + BOOL_T flip, + BOOL_T Scurve, + EPINX_T ep, + ANGLE_T * angleR ) { coOrd p1; DIST_T ll; - if ( flip ) ep = 1-ep; + if ( flip ) { ep = 1-ep; } ll = (ep==0?l0:l1); if ( Scurve ) { - if ( ep==1 ) + if ( ep==1 ) { angle += 180; + } } GetJointPos( &p1, &angle, ll, R, L, pos, angle, negate ); if ( angleR ) { - if ( (!Scurve) && ep==0 ) + if ( (!Scurve) && ep==0 ) { angle = NormalizeAngle(angle+180); + } *angleR = angle; } return p1; } STATUS_T JointDescriptionMove( - track_p trk, - wAction_t action, - coOrd pos ) + track_p trk, + wAction_t action, + coOrd pos ) { struct extraDataEase_t *xx = GET_EXTRA_DATA(trk, T_EASEMENT, extraDataEase_t); ANGLE_T ap; @@ -767,24 +798,27 @@ STATUS_T JointDescriptionMove( ap = NormalizeAngle(FindAngle(end0,pos)-FindAngle(end0,end1)); xx->descriptionOff.y = FindDistance(end0,pos)*sin(D2R(ap)); - xx->descriptionOff.x = -0.5 + FindDistance(end0,pos)*cos(D2R(ap))/FindDistance(end0,end1); - if (xx->descriptionOff.x > 0.5) xx->descriptionOff.x = 0.5; - if (xx->descriptionOff.x < -0.5) xx->descriptionOff.x = -0.5; + xx->descriptionOff.x = -0.5 + FindDistance(end0, + pos)*cos(D2R(ap))/FindDistance(end0,end1); + if (xx->descriptionOff.x > 0.5) { xx->descriptionOff.x = 0.5; } + if (xx->descriptionOff.x < -0.5) { xx->descriptionOff.x = -0.5; } return C_CONTINUE; } DIST_T JointDescriptionDistance( - coOrd pos, - track_p trk, - coOrd * dpos, - BOOL_T show_hidden, - BOOL_T * hidden) + coOrd pos, + track_p trk, + coOrd * dpos, + BOOL_T show_hidden, + BOOL_T * hidden) { coOrd p1; - if (hidden) *hidden = FALSE; - if ( GetTrkType( trk ) != T_EASEMENT || ((( GetTrkBits( trk ) & TB_HIDEDESC ) != 0 ) && !show_hidden)) + if (hidden) { *hidden = FALSE; } + if ( GetTrkType( trk ) != T_EASEMENT + || ((( GetTrkBits( trk ) & TB_HIDEDESC ) != 0 ) && !show_hidden)) { return DIST_INF; + } struct extraDataEase_t *xx = GET_EXTRA_DATA(trk, T_EASEMENT, extraDataEase_t); coOrd end0, end0off, end1, end1off; @@ -797,25 +831,28 @@ DIST_T JointDescriptionDistance( p1.x = (end1off.x - end0off.x)*(xx->descriptionOff.x+0.5) + end0off.x; p1.y = (end1off.y - end0off.y)*(xx->descriptionOff.x+0.5) + end0off.y; - if (hidden) *hidden = (GetTrkBits( trk ) & TB_HIDEDESC); + if (hidden) { *hidden = (GetTrkBits( trk ) & TB_HIDEDESC); } *dpos = p1; coOrd tpos = pos; - if (DistanceJoint(trk,&tpos)<FindDistance( p1, pos )) + if (DistanceJoint(trk,&tpos)<FindDistance( p1, pos )) { return DistanceJoint(trk,&pos); + } return FindDistance( p1, pos ); } static void DrawJointDescription( - track_p trk, - drawCmd_p d, - wDrawColor color ) + track_p trk, + drawCmd_p d, + wDrawColor color ) { - DIST_T grade=0, sep=0; +// DIST_T grade=0, sep=0; ANGLE_T a; - if (layoutLabels == 0) + if (layoutLabels == 0) { return; - if ((labelEnable&LABELENABLE_TRKDESC)==0 ) + } + if ((labelEnable&LABELENABLE_TRKDESC)==0 ) { return; + } coOrd end0, end0off, end1, end1off; end0 = GetTrkEndPos(trk,0); @@ -826,16 +863,19 @@ static void DrawJointDescription( Translate(&end1off,end1,a+90,xx->descriptionOff.y); sprintf( message, "Joint: L %s A %0.3f, l0 %s l1 %s R %s L %s\n", - FormatDistance(FindDistance(end0,end1)),FindAngle(end0,end1), - FormatDistance(xx->l0), FormatDistance(xx->l1), FormatDistance(xx->R), FormatDistance(xx->L)); + FormatDistance(FindDistance(end0,end1)),FindAngle(end0,end1), + FormatDistance(xx->l0), FormatDistance(xx->l1), FormatDistance(xx->R), + FormatDistance(xx->L)); DrawLine(d,end0,end0off,0,color); DrawLine(d,end1,end1off,0,color); - DrawDimLine( d, end0off, end1off, message, (wFontSize_t)descriptionFontSize, xx->descriptionOff.x+0.5, 0, color, 0x00 ); + DrawDimLine( d, end0off, end1off, message, (wFontSize_t)descriptionFontSize, + xx->descriptionOff.x+0.5, 0, color, 0x00 ); if (GetTrkBits( trk ) & TB_DETAILDESC) { coOrd details_pos; details_pos.x = (end1off.x - end0off.x)*(xx->descriptionOff.x+0.5) + end0off.x; - details_pos.y = (end1off.y - end0off.y)*(xx->descriptionOff.x+0.5) + end0off.y - (2*descriptionFontSize/mainD.dpi); + details_pos.y = (end1off.y - end0off.y)*(xx->descriptionOff.x+0.5) + end0off.y + - (2*descriptionFontSize/mainD.dpi); AddTrkDetails(d, trk, details_pos, FindDistance(end0,end1), color); } @@ -845,22 +885,22 @@ static void DrawJointDescription( EXPORT void DrawJointTrack( - drawCmd_p d, - coOrd pos, - ANGLE_T angle, - DIST_T l0, - DIST_T l1, - DIST_T R, - DIST_T L, - BOOL_T negate, - BOOL_T flip, - BOOL_T Scurve, - track_p trk, - EPINX_T ep0, - EPINX_T ep1, - DIST_T trackGauge, - wDrawColor color, - long options ) + drawCmd_p d, + coOrd pos, + ANGLE_T angle, + DIST_T l0, + DIST_T l1, + DIST_T R, + DIST_T L, + BOOL_T negate, + BOOL_T flip, + BOOL_T Scurve, + track_p trk, + EPINX_T ep0, + EPINX_T ep1, + DIST_T trackGauge, + wDrawColor color, + long options ) { wIndex_t cnt; DIST_T len; @@ -870,7 +910,7 @@ EXPORT void DrawJointTrack( DYNARR_APPEND( trkSeg_t, tempSegs_da, 10 ); segPtr = &tempSegs(tempSegs_da.cnt-1); segPtr->type = SEG_JNTTRK; - segPtr->width = 0; + segPtr->lineWidth = 0; segPtr->color = wDrawColorBlack; segPtr->u.j.pos = pos; segPtr->u.j.angle = angle; @@ -883,43 +923,44 @@ EXPORT void DrawJointTrack( segPtr->u.j.Scurve = Scurve; return; } -LOG( log_ease, 4, ( "DJT( (X%0.3f Y%0.3f A%0.3f) \n", pos.x, pos.y, angle ) ) - if (color == wDrawColorBlack) + LOG( log_ease, 4, ( "DJT( (X%0.3f Y%0.3f A%0.3f) \n", pos.x, pos.y, angle ) ) + if (color == wDrawColorBlack) { color = normalColor; + } if (!Scurve) { /* print segments about 0.20" long */ len = (l0-l1)/(0.20*d->scale); cnt = (int)ceil(fabs(len)); - if (cnt == 0) cnt = 1; + if (cnt == 0) { cnt = 1; } DrawJointSegment( d, cnt, l0, l1, R, L, pos, - angle, negate, trackGauge, color, options, trk ); + angle, negate, trackGauge, color, options, trk ); } else { /* print segments about 0.20" long */ cnt = (int)ceil((l0)/(0.20*d->scale)); - if (cnt == 0) cnt = 1; + if (cnt == 0) { cnt = 1; } DrawJointSegment( d, cnt, 0, l0, R, L, pos, - angle, negate, trackGauge, color, options, trk ); + angle, negate, trackGauge, color, options, trk ); cnt = (int)ceil((l1)/(0.20*d->scale)); - if (cnt == 0) cnt = 1; + if (cnt == 0) { cnt = 1; } DrawJointSegment( d, cnt, 0, l1, R, L, pos, - angle+180, negate, trackGauge, color, options, trk ); + angle+180, negate, trackGauge, color, options, trk ); } DrawEndPt( d, trk, ep0, color ); DrawEndPt( d, trk, ep1, color ); if (((d->options&(DC_SIMPLE|DC_SEGTRACK))==0) && - (labelWhen == 2 || (labelWhen == 1 && (d->options&DC_PRINT))) && - labelScale >= d->scale && - ( GetTrkBits( trk ) & TB_HIDEDESC ) == 0 ) { - DrawJointDescription( trk, d, color ); + (labelWhen == 2 || (labelWhen == 1 && (d->options&DC_PRINT))) && + labelScale >= d->scale && + ( GetTrkBits( trk ) & TB_HIDEDESC ) == 0 ) { + DrawJointDescription( trk, d, color ); } } static void DrawJoint( - track_p trk, - drawCmd_p d, - wDrawColor color ) + track_p trk, + drawCmd_p d, + wDrawColor color ) /* * Draw a transition-curve. */ @@ -927,33 +968,41 @@ static void DrawJoint( struct extraDataEase_t * xx = GET_EXTRA_DATA(trk, T_EASEMENT, extraDataEase_t); long widthOptions = 0; - DrawJointTrack( d, xx->pos, xx->angle, xx->l0, xx->l1, xx->R, xx->L, xx->negate, xx->flip, xx->Scurve, trk, 0, 1, GetTrkGauge(trk), color, widthOptions ); + DrawJointTrack( d, xx->pos, xx->angle, xx->l0, xx->l1, xx->R, xx->L, xx->negate, + xx->flip, xx->Scurve, trk, 0, 1, GetTrkGauge(trk), color, widthOptions ); } static void DeleteJoint( - track_p t ) + track_p t ) /* Delete track - nothing to do */ { } static BOOL_T WriteJoint( - track_p t, - FILE * f ) + track_p t, + FILE * f ) /* * Write track data to a file (f). */ { struct extraDataEase_t * xx = GET_EXTRA_DATA(t, T_EASEMENT, extraDataEase_t); BOOL_T rc = TRUE; + int bits; long options = (long)GetTrkWidth(t); if ( ( GetTrkBits(t) & TB_HIDEDESC ) == 0 ) - // 0x80 means Show Description - options |= 0x80; - rc &= fprintf(f, "JOINT %d %d %ld 0 0 %s %d %0.6f %0.6f %0.6f %0.6f %d %d %d %0.6f %0.6f 0 %0.6f %0.6f %0.6f\n", - GetTrkIndex(t), GetTrkLayer(t), options, - GetTrkScaleName(t), GetTrkVisible(t)|(GetTrkNoTies(t)?1<<2:0)|(GetTrkBridge(t)?1<<3:0), xx->l0, xx->l1, xx->R, xx->L, - xx->flip, xx->negate, xx->Scurve, xx->pos.x, xx->pos.y, xx->angle, xx->descriptionOff.x, xx->descriptionOff.y )>0; + // 0x80 means Show Description + { + options |= 0x80; + } + bits = GetTrkVisible(t)|(GetTrkNoTies(t)?1<<2:0)|(GetTrkBridge(t)?1<<3:0)| + (GetTrkRoadbed(t)?1<<4:0); + rc &= fprintf(f, + "JOINT %d %d %ld 0 0 %s %d %0.6f %0.6f %0.6f %0.6f %d %d %d %0.6f %0.6f 0 %0.6f %0.6f %0.6f\n", + GetTrkIndex(t), GetTrkLayer(t), options, + GetTrkScaleName(t), bits, xx->l0, xx->l1, xx->R, xx->L, + xx->flip, xx->negate, xx->Scurve, xx->pos.x, xx->pos.y, xx->angle, + xx->descriptionOff.x, xx->descriptionOff.y )>0; rc &= WriteEndPt( f, t, 0 ); rc &= WriteEndPt( f, t, 1 ); rc &= fprintf(f, "\t%s\n", END_SEGS )>0; @@ -961,7 +1010,7 @@ static BOOL_T WriteJoint( } static BOOL_T ReadJoint( - char * line ) + char * line ) /* * Read track data from a file (f). */ @@ -977,16 +1026,20 @@ static BOOL_T ReadJoint( char * cp = NULL; coOrd descriptionOff = {0.0,0.0}; - if ( !GetArgs( line+6, paramVersion<3?"dXZsdffffdddpYfc":paramVersion<9?"dLl00sdffffdddpYfc":"dLl00sdffffdddpffc", - &index, &layer, &options, scale, &visible, &e.l0, &e.l1, &e.R, &e.L, - &e.flip, &e.negate, &e.Scurve, &e.pos, &elev, &e.angle, &cp) ) + if ( !GetArgs( line+6, paramVersion<3?"dXZsdffffdddpYfc":paramVersion<9 + ?"dLl00sdffffdddpYfc":"dLl00sdffffdddpffc", + &index, &layer, &options, scale, &visible, &e.l0, &e.l1, &e.R, &e.L, + &e.flip, &e.negate, &e.Scurve, &e.pos, &elev, &e.angle, &cp) ) { return FALSE; + } if (cp) { - if (!GetArgs(cp,"p",&descriptionOff)) + if (!GetArgs(cp,"p",&descriptionOff)) { return FALSE; + } } - if ( !ReadSegs() ) + if ( !ReadSegs() ) { return FALSE; + } trk = NewTrack( index, T_EASEMENT, 0, sizeof e ); xx = GET_EXTRA_DATA(trk, T_EASEMENT, extraDataEase_t); xx->descriptionOff = descriptionOff; @@ -994,16 +1047,19 @@ static BOOL_T ReadJoint( SetTrkVisible(trk, visible!=0); SetTrkNoTies(trk, FALSE); SetTrkBridge(trk, FALSE); + SetTrkRoadbed(trk, FALSE); } else { SetTrkVisible(trk, visible&2); SetTrkNoTies(trk, visible&4); SetTrkBridge(trk, visible&8); + SetTrkRoadbed(trk, visible&16); } SetTrkScale(trk, LookupScale(scale)); SetTrkLayer(trk, layer); SetTrkWidth(trk, (int)(options&3)); - if ( paramVersion < VERSION_DESCRIPTION2 || ( ( options & 0x80 ) == 0 ) ) + if ( paramVersion < VERSION_DESCRIPTION2 || ( ( options & 0x80 ) == 0 ) ) { SetTrkBits(trk,TB_HIDEDESC); + } e.base.trkType = T_EASEMENT; *xx = e; SetEndPts( trk, 2 ); @@ -1012,8 +1068,8 @@ static BOOL_T ReadJoint( } static void MoveJoint( - track_p trk, - coOrd orig ) + track_p trk, + coOrd orig ) /* * Move a track. */ @@ -1025,9 +1081,9 @@ static void MoveJoint( } static void RotateJoint( - track_p trk, - coOrd orig, - ANGLE_T angle ) + track_p trk, + coOrd orig, + ANGLE_T angle ) /* * Rotate a track. */ @@ -1051,7 +1107,8 @@ static void RescaleJoint( track_p trk, FLOAT_T ratio ) } -static ANGLE_T GetAngleJoint( track_p trk, coOrd pos, EPINX_T * ep0, EPINX_T * ep1 ) +static ANGLE_T GetAngleJoint( track_p trk, coOrd pos, EPINX_T * ep0, + EPINX_T * ep1 ) { DIST_T l; ANGLE_T a; @@ -1065,11 +1122,12 @@ static ANGLE_T GetAngleJoint( track_p trk, coOrd pos, EPINX_T * ep0, EPINX_T * e *ep1 = 1; } } - GetLandD( &l, NULL, pos, xx->pos, xx->angle, xx->R, xx->L, xx->negate, xx->Scurve ); + GetLandD( &l, NULL, pos, xx->pos, xx->angle, xx->R, xx->L, xx->negate, + xx->Scurve ); if (small(l)) { a = xx->angle; } else { -/* if (xx->Scurve && NormalizeAngle(FindAngle(xx->pos,pos)-xx->angle+90.0) > 180.0)*/ + /* if (xx->Scurve && NormalizeAngle(FindAngle(xx->pos,pos)-xx->angle+90.0) > 180.0)*/ if (xx->Scurve && l < 0.0) { GetJointPos( NULL, &a, -l, xx->R, xx->L, xx->pos, xx->angle+180.0, xx->negate ); a = NormalizeAngle( a-180.0 ); @@ -1082,11 +1140,11 @@ static ANGLE_T GetAngleJoint( track_p trk, coOrd pos, EPINX_T * ep0, EPINX_T * e static void SplitJointA( - coOrd * posR, - EPINX_T ep, - struct extraDataEase_t * xx, - struct extraDataEase_t * xx1, - ANGLE_T * aR ) + coOrd * posR, + EPINX_T ep, + struct extraDataEase_t * xx, + struct extraDataEase_t * xx1, + ANGLE_T * aR ) { struct extraDataEase_t * xx0; BOOL_T flip; @@ -1101,17 +1159,19 @@ static void SplitJointA( xx1 = xx; flip = TRUE; } - GetLandD( &l, NULL, *posR, xx->pos, xx->angle, xx->R, xx->L, xx->negate, xx->Scurve ); + GetLandD( &l, NULL, *posR, xx->pos, xx->angle, xx->R, xx->L, xx->negate, + xx->Scurve ); if (!xx->Scurve) { if (l < xx->l0 || l > xx->l1) { - NoticeMessage2( 0, "splitJoint: ! %0.3f <= %0.3f <= %0.3f", _("Ok"), NULL, xx->l0, l, xx->l1 ); - if ( l < xx->l0 ) l = xx->l0; - else if ( l > xx->l1 ) l = xx->l1; + NoticeMessage2( 0, "splitJoint: ! %0.3f <= %0.3f <= %0.3f", _("Ok"), NULL, + xx->l0, l, xx->l1 ); + if ( l < xx->l0 ) { l = xx->l0; } + else if ( l > xx->l1 ) { l = xx->l1; } } GetJointPos( posR, aR, l, xx->R, xx->L, xx->pos, xx->angle, xx->negate ); xx0->l1 = xx1->l0 = l; - } else if (small(l)){ + } else if (small(l)) { xx0->Scurve = xx1->Scurve = 0; xx0->l1 = xx0->l0; xx0->flip = !xx0->flip; @@ -1135,12 +1195,14 @@ static void SplitJointA( } *aR = NormalizeAngle( *aR+180.0 ); } - if (flip) + if (flip) { *aR = NormalizeAngle( *aR + 180.0 ); + } } -static BOOL_T SplitJoint( track_p trk, coOrd pos, EPINX_T ep, track_p * leftover, EPINX_T *ep0, EPINX_T *ep1 ) +static BOOL_T SplitJoint( track_p trk, coOrd pos, EPINX_T ep, + track_p * leftover, EPINX_T *ep0, EPINX_T *ep1 ) { struct extraDataEase_t *xx, *xx1; track_p trk1; @@ -1165,34 +1227,36 @@ static BOOL_T SplitJoint( track_p trk, coOrd pos, EPINX_T ep, track_p * leftover static BOOL_T TraverseJoint( - coOrd * posR, - ANGLE_T *angleR, - DIST_T *distR, - coOrd pos, - ANGLE_T angle, - DIST_T l0, - DIST_T l1, - DIST_T R, - DIST_T L, - BOOL_T negate, - BOOL_T flip, - BOOL_T Scurve ) + coOrd * posR, + ANGLE_T *angleR, + DIST_T *distR, + coOrd pos, + ANGLE_T angle, + DIST_T l0, + DIST_T l1, + DIST_T R, + DIST_T L, + BOOL_T negate, + BOOL_T flip, + BOOL_T Scurve ) { - + DIST_T l, lx, d, dx, ll0, ll1, d0, d1; BOOL_T from_tangent, flip_angle; GetLandD( &l, &d, *posR, pos, angle, R, L, negate, Scurve ); -LOG( log_traverseJoint, 2, ( "TJ: [%0.3f %0.3f] D%0.3f l0:%0.3f l1:%0.3f [%0.3f %0.3f] A%0.3f N%d F%d S%d = l:%0.3f ", - posR->x, posR->y, *distR, l0, l1, pos.x, pos.y, angle, negate, flip, Scurve, l ) ) + LOG( log_traverseJoint, 2, + ( "TJ: [%0.3f %0.3f] D%0.3f l0:%0.3f l1:%0.3f [%0.3f %0.3f] A%0.3f N%d F%d S%d = l:%0.3f ", + posR->x, posR->y, *distR, l0, l1, pos.x, pos.y, angle, negate, flip, Scurve, + l ) ) if ( (!Scurve) ) { - if ( l < l0 ) l = l0; - else if ( l > l1 ) l = l1; + if ( l < l0 ) { l = l0; } + else if ( l > l1 ) { l = l1; } } else { - if ( l > l0 ) l = l0; - else if ( l < -l1 ) l = -l1; + if ( l > l0 ) { l = l0; } + else if ( l < -l1 ) { l = -l1; } } lx = l; @@ -1213,10 +1277,11 @@ LOG( log_traverseJoint, 2, ( "TJ: [%0.3f %0.3f] D%0.3f l0:%0.3f l1:%0.3f [%0.3f dx = JoinD( lx, R, L ); d0 = JoinD( ll0, R, L ); d1 = JoinD( ll1, R, L ); - if ( from_tangent ) + if ( from_tangent ) { d = d1 - dx; - else + } else { d = dx - d0; + } if ( *distR < d ) { if ( from_tangent ) { d = dx + *distR; @@ -1224,43 +1289,49 @@ LOG( log_traverseJoint, 2, ( "TJ: [%0.3f %0.3f] D%0.3f l0:%0.3f l1:%0.3f [%0.3f d = dx - *distR; } lx = GetLfromD( d, R, L ); - if ( l < 0 ) + if ( l < 0 ) { lx = - lx; + } /* compute posR and angleR */ GetJointPos( posR, angleR, lx, R, L, pos, angle, negate ); - if ( ! flip_angle ) + if ( ! flip_angle ) { *angleR = NormalizeAngle( *angleR + 180.0 ); + } *distR = 0; goto doreturn; } *distR -= d; if ( Scurve && (!from_tangent) ) { /* skip over midpoint */ - if ( l > 0 ) + if ( l > 0 ) { d = JoinD( l1, R, L ); - else + } else { d = JoinD( l0, R, L ); + } if ( *distR < d ) { lx = GetLfromD( *distR, R, L ); - if ( l > 0 ) + if ( l > 0 ) { lx = - lx; + } GetJointPos( posR, angleR, lx, R, L, pos, angle, negate ); - if ( ! flip_angle ) + if ( ! flip_angle ) { *angleR = NormalizeAngle( *angleR + 180.0 ); + } *distR = 0; goto doreturn; } *distR -= d; } doreturn: -LOG( log_traverseJoint, 2, ( " [%0.3f %0.3f] A%0.3f D%0.3f\n", posR->x, posR->y, *angleR, *distR ) ) + LOG( log_traverseJoint, 2, ( " [%0.3f %0.3f] A%0.3f D%0.3f\n", posR->x, posR->y, + *angleR, *distR ) ) return TRUE; } static BOOL_T TraverseJointTrack( - traverseTrack_p trvTrk, - DIST_T * distR ) + traverseTrack_p trvTrk, + DIST_T * distR ) { track_p trk = trvTrk->trk; struct extraDataEase_t * xx = GET_EXTRA_DATA(trk, T_EASEMENT, extraDataEase_t); @@ -1271,13 +1342,16 @@ static BOOL_T TraverseJointTrack( angle = NormalizeAngle( xx->angle-trvTrk->angle ); flip = ( angle < 270 && angle > 90 ); - rc = TraverseJoint( &trvTrk->pos, &trvTrk->angle, distR, xx->pos, xx->angle, xx->l0, xx->l1, xx->R, xx->L, xx->negate, flip, xx->Scurve ); + rc = TraverseJoint( &trvTrk->pos, &trvTrk->angle, distR, xx->pos, xx->angle, + xx->l0, xx->l1, xx->R, xx->L, xx->negate, flip, xx->Scurve ); if ( *distR > 0 ) { ep = (flip?0:1); - if ( xx->flip ) + if ( xx->flip ) { ep = 1-ep; - if ( xx->Scurve ) + } + if ( xx->Scurve ) { ep = 1-ep; + } trvTrk->pos = GetTrkEndPos( trk, ep ); trvTrk->angle = GetTrkEndAngle( trk, ep ); trvTrk->trk = GetTrkEndTrk( trk, ep ); @@ -1295,7 +1369,8 @@ static BOOL_T EnumerateJoint( track_p trk ) return FALSE; } -static BOOL_T TrimJoint( track_p trk, EPINX_T ep, DIST_T maxX, coOrd endpos, ANGLE_T angle, DIST_T radius, coOrd center ) +static BOOL_T TrimJoint( track_p trk, EPINX_T ep, DIST_T maxX, coOrd endpos, + ANGLE_T angle, DIST_T radius, coOrd center ) { DeleteTrack( trk, FALSE ); return TRUE; @@ -1303,10 +1378,10 @@ static BOOL_T TrimJoint( track_p trk, EPINX_T ep, DIST_T maxX, coOrd endpos, ANG static BOOL_T MergeJoint( - track_p trk0, - EPINX_T ep0, - track_p trk1, - EPINX_T ep1 ) + track_p trk0, + EPINX_T ep0, + track_p trk1, + EPINX_T ep1 ) { track_p trk2; EPINX_T ep2=-1; @@ -1315,19 +1390,22 @@ static BOOL_T MergeJoint( struct extraDataEase_t *xx0 = GET_EXTRA_DATA(trk0, T_EASEMENT, extraDataEase_t); struct extraDataEase_t *xx1 = GET_EXTRA_DATA(trk1, T_EASEMENT, extraDataEase_t); - if ( ep0 == ep1 ) + if ( ep0 == ep1 ) { return FALSE; + } if ( xx0->R != xx1->R || - xx0->L != xx1->L || - xx0->flip != xx1->flip || - xx0->negate != xx1->negate || - xx0->angle != xx1->angle || - xx0->Scurve || - xx1->Scurve || - FindDistance( xx0->pos, xx1->pos ) > connectDistance ) + xx0->L != xx1->L || + xx0->flip != xx1->flip || + xx0->negate != xx1->negate || + xx0->angle != xx1->angle || + xx0->Scurve || + xx1->Scurve || + FindDistance( xx0->pos, xx1->pos ) > connectDistance ) { return FALSE; + } - UndoStart( _("Merge Easements"), "MergeJoint( T%d[%d] T%d[%d] )", GetTrkIndex(trk0), ep0, GetTrkIndex(trk1), ep1 ); + UndoStart( _("Merge Easements"), "MergeJoint( T%d[%d] T%d[%d] )", + GetTrkIndex(trk0), ep0, GetTrkIndex(trk1), ep1 ); UndoModify( trk0 ); UndrawNewTrack( trk0 ); trk2 = GetTrkEndTrk( trk1, 1-ep1 ); @@ -1356,15 +1434,19 @@ static BOOL_T MergeJoint( } -static BOOL_T GetParamsJoint( int inx, track_p trk, coOrd pos, trackParams_t * params ) +static BOOL_T GetParamsJoint( int inx, track_p trk, coOrd pos, + trackParams_t * params ) { params->type = curveTypeStraight; - if ((inx == PARAMS_CORNU) || (inx == PARAMS_1ST_JOIN) || (inx == PARAMS_2ND_JOIN))\ + if ((inx == PARAMS_CORNU) || (inx == PARAMS_1ST_JOIN) + || (inx == PARAMS_2ND_JOIN))\ params->ep = PickEndPoint(pos, trk); - else + else { params->ep = PickUnconnectedEndPointSilent( pos, trk ); - if (params->ep == -1) - return FALSE; + } + if (params->ep == -1) { + return FALSE; + } params->lineOrig = GetTrkEndPos(trk,params->ep); params->lineEnd = params->lineOrig; params->angle = GetTrkEndAngle(trk,params->ep); @@ -1393,9 +1475,11 @@ static BOOL_T QueryJoint( track_p trk, int query ) case Q_CAN_PARALLEL: if ( xx->Scurve ) { if ( FindDistance( xx->pos, GetTrkEndPos(trk,0) ) <= minLength || - FindDistance( xx->pos, GetTrkEndPos(trk,1) ) <= minLength ) + FindDistance( xx->pos, GetTrkEndPos(trk,1) ) <= minLength ) { return FALSE; - UndoStart( _("Split Easement Curve"), "queryJoint T%d Scurve", GetTrkIndex(trk) ); + } + UndoStart( _("Split Easement Curve"), "queryJoint T%d Scurve", + GetTrkIndex(trk) ); SplitTrack( trk, xx->pos, 0, &trk1, FALSE ); } return TRUE; @@ -1408,9 +1492,9 @@ static BOOL_T QueryJoint( track_p trk, int query ) static void FlipJoint( - track_p trk, - coOrd orig, - ANGLE_T angle ) + track_p trk, + coOrd orig, + ANGLE_T angle ) { struct extraDataEase_t * xx = GET_EXTRA_DATA(trk, T_EASEMENT, extraDataEase_t); FlipPoint( &xx->pos, orig, angle ); @@ -1421,32 +1505,37 @@ static void FlipJoint( static BOOL_T MakeParallelJoint( - track_p trk, - coOrd pos, - DIST_T sep, - DIST_T factor, - track_p * newTrkR, - coOrd * p0R, - coOrd * p1R, - BOOL_T track) + track_p trk, + coOrd pos, + DIST_T sep, + DIST_T factor, + track_p * newTrkR, + coOrd * p0R, + coOrd * p1R, + BOOL_T track) { - struct extraDataEase_t * xx = GET_EXTRA_DATA(trk, T_EASEMENT, extraDataEase_t), *xx1; + struct extraDataEase_t * xx = GET_EXTRA_DATA(trk, T_EASEMENT, extraDataEase_t), + *xx1; ANGLE_T angle, A; coOrd p0, p1, P, q1, r1; DIST_T d, d0; DIST_T R, L, l0, l1, len, dl; int cnt, inx; - if ( xx->Scurve ) + if ( xx->Scurve ) { return FALSE; + } GetLandD( NULL, &d, pos, xx->pos, xx->angle, xx->R, xx->L, xx->negate, FALSE ); angle = 90.0; - if ( (d < 0) == xx->negate ) + if ( (d < 0) == xx->negate ) { sep = -sep; - if ( xx->negate ) + } + if ( xx->negate ) { angle = -90.0; - if ( xx->flip ) + } + if ( xx->flip ) { angle = -angle; + } p0 = GetTrkEndPos(trk,0); p1 = GetTrkEndPos(trk,1); d0 = FindDistance( p0, p1 ); @@ -1458,25 +1547,26 @@ static BOOL_T MakeParallelJoint( A = xx->angle; R = xx->R + sep*sin(D2R(angle)); dl = JoinD( xx->l1, xx->R, xx->L ) - JoinD( xx->l0, xx->R, xx->L ); -/*printf( "D = %0.3f %0.3f\n", d, dl );*/ + /*printf( "D = %0.3f %0.3f\n", d, dl );*/ d /= d0; R = xx->R * d; L = xx->L * d; l0 = xx->l0 * d; l1 = xx->l1 * d; -/*printf( " R=%0.3f, L=%0.3f, l0=%0.3f, l1=%0.3f\n", R, L, l0, l1 );*/ + /*printf( " R=%0.3f, L=%0.3f, l0=%0.3f, l1=%0.3f\n", R, L, l0, l1 );*/ Translate( &P, xx->pos, xx->angle+(xx->negate?90:-90), sep ); ComputeJoinPos( l1, R, L, NULL, NULL, &q1, NULL ); r1 = (xx->flip?p0:p1); r1.x -= P.x; r1.y -= P.y; Rotate( &r1, zero, -A ); - if ( xx->negate ) + if ( xx->negate ) { r1.x = -r1.x; + } if ( r1.x > 0 && q1.x > 0 ) { -/*printf( " %0.3f %0.3f, R=%0.3f ", q1.x, r1.x, R );*/ + /*printf( " %0.3f %0.3f, R=%0.3f ", q1.x, r1.x, R );*/ R *= q1.x/r1.x; -/*printf( " %0.3f\n", R );*/ + /*printf( " %0.3f\n", R );*/ } if ( newTrkR ) { @@ -1497,12 +1587,12 @@ static BOOL_T MakeParallelJoint( dl = fabs(l0-l1); len = dl/(0.20*mainD.scale); cnt = (int)ceil(len); - if (cnt == 0) cnt = 1; + if (cnt == 0) { cnt = 1; } dl /= cnt; DYNARR_SET( trkSeg_t, tempSegs_da, cnt ); for ( inx=0; inx<cnt; inx++ ) { tempSegs(inx).color = wDrawColorBlack; - tempSegs(inx).width = 0; + tempSegs(inx).lineWidth = 0; tempSegs(inx).type = track?SEG_STRTRK:SEG_STRLIN; if ( inx == 0 ) { GetJointPos( &tempSegs(inx).u.l.pos[0], NULL, l0, R, L, P, A, xx->negate ); @@ -1513,19 +1603,18 @@ static BOOL_T MakeParallelJoint( GetJointPos( &tempSegs(inx).u.l.pos[1], NULL, l0, R, L, P, A, xx->negate ); *newTrkR = MakeDrawFromSeg( zero, 0.0, &tempSegs(inx) ); } - tempSegs_da.cnt = cnt; } } else { /* print segments about 0.20" long */ dl = fabs(l0-l1); len = dl/(0.20*mainD.scale); cnt = (int)ceil(len); - if (cnt == 0) cnt = 1; + if (cnt == 0) { cnt = 1; } dl /= cnt; DYNARR_SET( trkSeg_t, tempSegs_da, cnt ); for ( inx=0; inx<cnt; inx++ ) { tempSegs(inx).color = wDrawColorBlack; - tempSegs(inx).width = 0; + tempSegs(inx).lineWidth = 0; tempSegs(inx).type = track?SEG_STRTRK:SEG_STRLIN; if ( inx == 0 ) { GetJointPos( &tempSegs(inx).u.l.pos[0], NULL, l0, R, L, P, A, xx->negate ); @@ -1535,17 +1624,18 @@ static BOOL_T MakeParallelJoint( l0 += dl; GetJointPos( &tempSegs(inx).u.l.pos[1], NULL, l0, R, L, P, A, xx->negate ); } - tempSegs_da.cnt = cnt; } - if ( p0R ) *p0R = p0; - if ( p1R ) *p1R = p1; + if ( p0R ) { *p0R = p0; } + if ( p1R ) { *p1R = p1; } return TRUE; } static wBool_t CompareJoint( track_cp trk1, track_cp trk2 ) { - struct extraDataEase_t *xx1 = GET_EXTRA_DATA( trk1, T_EASEMENT, extraDataEase_t ); - struct extraDataEase_t *xx2 = GET_EXTRA_DATA( trk2, T_EASEMENT, extraDataEase_t ); + struct extraDataEase_t *xx1 = GET_EXTRA_DATA( trk1, T_EASEMENT, + extraDataEase_t ); + struct extraDataEase_t *xx2 = GET_EXTRA_DATA( trk2, T_EASEMENT, + extraDataEase_t ); char * cp = message + strlen(message); REGRESS_CHECK_DIST( "L0", xx1, xx2, l0 ); REGRESS_CHECK_DIST( "L1", xx1, xx2, l1 ); @@ -1559,47 +1649,48 @@ static wBool_t CompareJoint( track_cp trk1, track_cp trk2 ) static trackCmd_t easementCmds = { - "JOINT", - DrawJoint, - DistanceJoint, - DescribeJoint, - DeleteJoint, - WriteJoint, - ReadJoint, - MoveJoint, - RotateJoint, - RescaleJoint, - NULL, /* audit */ - GetAngleJoint, - SplitJoint, - TraverseJointTrack, - EnumerateJoint, - NULL, /* redraw */ - TrimJoint, - MergeJoint, - ExtendStraightFromOrig, - GetLengthJoint, - GetParamsJoint, - MoveEndPtJoint, - QueryJoint, - NULL, /* ungroup */ - FlipJoint, - NULL, - NULL, - NULL, - MakeParallelJoint, - NULL, - NULL, - NULL, - NULL, - NULL, - CompareJoint }; + "JOINT", + DrawJoint, + DistanceJoint, + DescribeJoint, + DeleteJoint, + WriteJoint, + ReadJoint, + MoveJoint, + RotateJoint, + RescaleJoint, + NULL, /* audit */ + GetAngleJoint, + SplitJoint, + TraverseJointTrack, + EnumerateJoint, + NULL, /* redraw */ + TrimJoint, + MergeJoint, + ExtendStraightFromOrig, + GetLengthJoint, + GetParamsJoint, + MoveEndPtJoint, + QueryJoint, + NULL, /* ungroup */ + FlipJoint, + NULL, + NULL, + NULL, + MakeParallelJoint, + NULL, + NULL, + NULL, + NULL, + NULL, + CompareJoint +}; EXPORT void JointSegProc( - segProc_e cmd, - trkSeg_p segPtr, - segProcData_p data ) + segProc_e cmd, + trkSeg_p segPtr, + segProcData_p data ) { DIST_T l; ANGLE_T a; @@ -1612,43 +1703,53 @@ EXPORT void JointSegProc( switch (cmd) { case SEGPROC_TRAVERSE1: - GetLandD( &l, NULL, data->traverse1.pos, segPtr->u.j.pos, segPtr->u.j.angle, segPtr->u.j.R, segPtr->u.j.L, segPtr->u.j.negate, segPtr->u.j.Scurve ); + GetLandD( &l, NULL, data->traverse1.pos, segPtr->u.j.pos, segPtr->u.j.angle, + segPtr->u.j.R, segPtr->u.j.L, segPtr->u.j.negate, segPtr->u.j.Scurve ); if (small(l)) { a = segPtr->u.j.angle; } else { if (segPtr->u.j.Scurve && l < 0.0) { - GetJointPos( NULL, &a, -l, segPtr->u.j.R, segPtr->u.j.L, segPtr->u.j.pos, segPtr->u.j.angle+180.0, segPtr->u.j.negate ); + GetJointPos( NULL, &a, -l, segPtr->u.j.R, segPtr->u.j.L, segPtr->u.j.pos, + segPtr->u.j.angle+180.0, segPtr->u.j.negate ); a = NormalizeAngle( a-180.0 ); } else { - GetJointPos( NULL, &a, l, segPtr->u.j.R, segPtr->u.j.L, segPtr->u.j.pos, segPtr->u.j.angle, segPtr->u.j.negate ); + GetJointPos( NULL, &a, l, segPtr->u.j.R, segPtr->u.j.L, segPtr->u.j.pos, + segPtr->u.j.angle, segPtr->u.j.negate ); } } a = NormalizeAngle( data->traverse1.angle+a ); data->traverse1.backwards = (a < 270 && a > 90 ); if ( !segPtr->u.j.Scurve ) { - if ( data->traverse1.backwards==0 ) - data->traverse1.dist = JoinD( l, segPtr->u.j.R, segPtr->u.j.L ) - JoinD( segPtr->u.j.l0, segPtr->u.j.R, segPtr->u.j.L ); - else - data->traverse1.dist = JoinD( segPtr->u.j.l1, segPtr->u.j.R, segPtr->u.j.L ) - JoinD( l, segPtr->u.j.R, segPtr->u.j.L ); + if ( data->traverse1.backwards==0 ) { + data->traverse1.dist = JoinD( l, segPtr->u.j.R, + segPtr->u.j.L ) - JoinD( segPtr->u.j.l0, segPtr->u.j.R, segPtr->u.j.L ); + } else { + data->traverse1.dist = JoinD( segPtr->u.j.l1, segPtr->u.j.R, + segPtr->u.j.L ) - JoinD( l, segPtr->u.j.R, segPtr->u.j.L ); + } } else { data->traverse1.backwards = !data->traverse1.backwards; - if ( data->traverse1.backwards==0 ) - data->traverse1.dist = JoinD( segPtr->u.j.l0, segPtr->u.j.R, segPtr->u.j.L ) - JoinD( l, segPtr->u.j.R, segPtr->u.j.L ); - else - data->traverse1.dist = JoinD( segPtr->u.j.l1, segPtr->u.j.R, segPtr->u.j.L ) + JoinD( l, segPtr->u.j.R, segPtr->u.j.L ); + if ( data->traverse1.backwards==0 ) { + data->traverse1.dist = JoinD( segPtr->u.j.l0, segPtr->u.j.R, + segPtr->u.j.L ) - JoinD( l, segPtr->u.j.R, segPtr->u.j.L ); + } else { + data->traverse1.dist = JoinD( segPtr->u.j.l1, segPtr->u.j.R, + segPtr->u.j.L ) + JoinD( l, segPtr->u.j.R, segPtr->u.j.L ); + } } data->traverse1.reverse_seg = FALSE; if ( segPtr->u.j.flip ) { data->traverse1.backwards = !data->traverse1.backwards; data->traverse1.reverse_seg = TRUE; } -LOG( log_traverseJoint, 1, ( "TJ0: ?[%0.3f %0.3f] A=%0.3f l=%0.3f J[%0.3f %0.3f] A=%0.3f l0=%0.3f l1=%0.3f R=%0.3f L=%0.3f N:%d F:%d S:%d = a=%0.3f D=%0.3f B=%d\n", - data->traverse1.pos.x, data->traverse1.pos.y, data->traverse1.angle, - l, - segPtr->u.j.pos.x, segPtr->u.j.pos.y, segPtr->u.j.angle, - segPtr->u.j.l0, segPtr->u.j.l1, segPtr->u.j.R, segPtr->u.j.L, - segPtr->u.j.negate, segPtr->u.j.flip, segPtr->u.j.Scurve, - a, data->traverse1.dist, data->traverse1.backwards ) ); + LOG( log_traverseJoint, 1, + ( "TJ0: ?[%0.3f %0.3f] A=%0.3f l=%0.3f J[%0.3f %0.3f] A=%0.3f l0=%0.3f l1=%0.3f R=%0.3f L=%0.3f N:%d F:%d S:%d = a=%0.3f D=%0.3f B=%d\n", + data->traverse1.pos.x, data->traverse1.pos.y, data->traverse1.angle, + l, + segPtr->u.j.pos.x, segPtr->u.j.pos.y, segPtr->u.j.angle, + segPtr->u.j.l0, segPtr->u.j.l1, segPtr->u.j.R, segPtr->u.j.L, + segPtr->u.j.negate, segPtr->u.j.flip, segPtr->u.j.Scurve, + a, data->traverse1.dist, data->traverse1.backwards ) ); data->traverse1.negative = FALSE; data->traverse1.BezSegInx = 0; data->traverse1.segs_backwards = FALSE; @@ -1656,12 +1757,18 @@ LOG( log_traverseJoint, 1, ( "TJ0: ?[%0.3f %0.3f] A=%0.3f l=%0.3f J[%0.3f %0.3f] case SEGPROC_TRAVERSE2: flip = segPtr->u.j.flip; - if (data->traverse2.segDir!=0) + if (data->traverse2.segDir!=0) { flip = !flip; - if (segPtr->u.j.Scurve) + } + if (segPtr->u.j.Scurve) { flip = !flip; - data->traverse2.pos = GetSegEndPt( segPtr, data->traverse2.segDir, FALSE, NULL ); - TraverseJoint( &data->traverse2.pos, &data->traverse2.angle, &data->traverse2.dist, segPtr->u.j.pos, segPtr->u.j.angle, segPtr->u.j.l0, segPtr->u.j.l1, segPtr->u.j.R, segPtr->u.j.L, segPtr->u.j.negate, flip, segPtr->u.j.Scurve ); + } + data->traverse2.pos = GetSegEndPt( segPtr, data->traverse2.segDir, FALSE, + NULL ); + TraverseJoint( &data->traverse2.pos, &data->traverse2.angle, + &data->traverse2.dist, segPtr->u.j.pos, segPtr->u.j.angle, segPtr->u.j.l0, + segPtr->u.j.l1, segPtr->u.j.R, segPtr->u.j.L, segPtr->u.j.negate, flip, + segPtr->u.j.Scurve ); break; case SEGPROC_DRAWROADBEDSIDE: @@ -1669,7 +1776,9 @@ LOG( log_traverseJoint, 1, ( "TJ0: ?[%0.3f %0.3f] A=%0.3f l=%0.3f J[%0.3f %0.3f] break; case SEGPROC_DISTANCE: - data->distance.dd = JointDistance( &data->distance.pos1, segPtr->u.j.pos, segPtr->u.j.angle, segPtr->u.j.l0, segPtr->u.j.l1, segPtr->u.j.R, segPtr->u.j.L, segPtr->u.j.negate, segPtr->u.j.Scurve ); + data->distance.dd = JointDistance( &data->distance.pos1, segPtr->u.j.pos, + segPtr->u.j.angle, segPtr->u.j.l0, segPtr->u.j.l1, segPtr->u.j.R, segPtr->u.j.L, + segPtr->u.j.negate, segPtr->u.j.Scurve ); break; case SEGPROC_FLIP: @@ -1689,20 +1798,25 @@ LOG( log_traverseJoint, 1, ( "TJ0: ?[%0.3f %0.3f] A=%0.3f l=%0.3f J[%0.3f %0.3f] xx->flip = segPtr->u.j.flip; xx->Scurve = segPtr->u.j.Scurve; ep0 = 0; - if ( xx->flip ) + if ( xx->flip ) { ep0 = 1-ep0; - if ( xx->Scurve ) + } + if ( xx->Scurve ) { ep0 = 1-ep0; + } GetJointPos( &p, &a, xx->l0, xx->R, xx->L, xx->pos, xx->angle, xx->negate ); - if ( !xx->Scurve ) + if ( !xx->Scurve ) { a = NormalizeAngle(a+180.0); + } SetTrkEndPoint( data->newTrack.trk, ep0, p, a ); a = xx->angle; - if ( xx->Scurve ) + if ( xx->Scurve ) { a = NormalizeAngle(a+180.0); + } GetJointPos( &p, &a, xx->l1, xx->R, xx->L, xx->pos, a, xx->negate ); - if ( xx->Scurve ) + if ( xx->Scurve ) { a = NormalizeAngle(a+180.0); + } SetTrkEndPoint( data->newTrack.trk, 1-ep0, p, a ); ComputeBoundingBox( data->newTrack.trk ); data->newTrack.ep[0] = 0; @@ -1710,10 +1824,13 @@ LOG( log_traverseJoint, 1, ( "TJ0: ?[%0.3f %0.3f] A=%0.3f l=%0.3f J[%0.3f %0.3f] break; case SEGPROC_LENGTH: - if ( !segPtr->u.j.Scurve ) - data->length.length = JoinD( segPtr->u.j.l1, segPtr->u.j.R, segPtr->u.j.L ) - JoinD( segPtr->u.j.l0, segPtr->u.j.R, segPtr->u.j.L ); - else - data->length.length = JoinD( segPtr->u.j.l1, segPtr->u.j.R, segPtr->u.j.L ) + JoinD( segPtr->u.j.l0, segPtr->u.j.R, segPtr->u.j.L ); + if ( !segPtr->u.j.Scurve ) { + data->length.length = JoinD( segPtr->u.j.l1, segPtr->u.j.R, + segPtr->u.j.L ) - JoinD( segPtr->u.j.l0, segPtr->u.j.R, segPtr->u.j.L ); + } else { + data->length.length = JoinD( segPtr->u.j.l1, segPtr->u.j.R, + segPtr->u.j.L ) + JoinD( segPtr->u.j.l0, segPtr->u.j.R, segPtr->u.j.L ); + } break; case SEGPROC_SPLIT: @@ -1741,23 +1858,29 @@ LOG( log_traverseJoint, 1, ( "TJ0: ?[%0.3f %0.3f] A=%0.3f l=%0.3f J[%0.3f %0.3f] data->split.newSeg[inx].u.j.negate = xx->negate; data->split.newSeg[inx].u.j.flip = xx->flip; data->split.newSeg[inx].u.j.Scurve = xx->Scurve; - if ( !xx->Scurve ) - data->split.length[inx] = JoinD( xx->l1, xx->R, xx->L ) - JoinD( xx->l0, xx->R, xx->L ); - else - data->split.length[inx] = JoinD( xx->l1, xx->R, xx->L ) + JoinD( xx->l0, xx->R, xx->L ); + if ( !xx->Scurve ) { + data->split.length[inx] = JoinD( xx->l1, xx->R, xx->L ) - JoinD( xx->l0, xx->R, + xx->L ); + } else { + data->split.length[inx] = JoinD( xx->l1, xx->R, xx->L ) + JoinD( xx->l0, xx->R, + xx->L ); + } } break; case SEGPROC_GETANGLE: - GetLandD( &l, NULL, data->getAngle.pos, segPtr->u.j.pos, segPtr->u.j.angle, segPtr->u.j.R, segPtr->u.j.L, segPtr->u.j.negate, segPtr->u.j.Scurve ); + GetLandD( &l, NULL, data->getAngle.pos, segPtr->u.j.pos, segPtr->u.j.angle, + segPtr->u.j.R, segPtr->u.j.L, segPtr->u.j.negate, segPtr->u.j.Scurve ); if (small(l)) { a = segPtr->u.j.angle; } else { if (segPtr->u.j.Scurve && l < 0.0) { - GetJointPos( NULL, &a, -l, segPtr->u.j.R, segPtr->u.j.L, segPtr->u.j.pos, segPtr->u.j.angle+180.0, segPtr->u.j.negate ); + GetJointPos( NULL, &a, -l, segPtr->u.j.R, segPtr->u.j.L, segPtr->u.j.pos, + segPtr->u.j.angle+180.0, segPtr->u.j.negate ); a = NormalizeAngle( a-180.0 ); } else { - GetJointPos( NULL, &a, l, segPtr->u.j.R, segPtr->u.j.L, segPtr->u.j.pos, segPtr->u.j.angle, segPtr->u.j.negate ); + GetJointPos( NULL, &a, l, segPtr->u.j.R, segPtr->u.j.L, segPtr->u.j.pos, + segPtr->u.j.angle, segPtr->u.j.negate ); } } data->getAngle.angle = a; @@ -1770,13 +1893,13 @@ LOG( log_traverseJoint, 1, ( "TJ0: ?[%0.3f %0.3f] A=%0.3f l=%0.3f J[%0.3f %0.3f] #ifndef TEST BOOL_T JoinTracks( - track_p trk0, - EPINX_T ep0, - coOrd pos0, - track_p trk1, - EPINX_T ep1, - coOrd pos1, - easementData_t * e ) + track_p trk0, + EPINX_T ep0, + coOrd pos0, + track_p trk1, + EPINX_T ep1, + coOrd pos1, + easementData_t * e ) /* * Join 2 tracks with joint described in (e). * (pos0) and (pos1) are points that would be connected if there was no @@ -1790,14 +1913,16 @@ BOOL_T JoinTracks( { track_p joint; -LOG( log_ease, 1, ( "join T%d[%d] @[%0.3f %0.3f], T%d[%d] @[%0.3f %0.3f]\n", - GetTrkIndex(trk0), ep0, pos0.x, pos0.y, GetTrkIndex(trk1), ep1, pos1.x, pos1.y ) ) + LOG( log_ease, 1, ( "join T%d[%d] @[%0.3f %0.3f], T%d[%d] @[%0.3f %0.3f]\n", + GetTrkIndex(trk0), ep0, pos0.x, pos0.y, GetTrkIndex(trk1), ep1, pos1.x, + pos1.y ) ) if ( GetTrkType(trk0) == T_EASEMENT ) { DIST_T d; ANGLE_T aa; d = FindDistance( GetTrkEndPos(trk0,ep0), GetTrkEndPos(trk1,ep1) ); - aa = NormalizeAngle( GetTrkEndAngle(trk0,ep0) - GetTrkEndAngle(trk1,ep1) + 180.0 + connectAngle/2.0 ); + aa = NormalizeAngle( GetTrkEndAngle(trk0,ep0) - GetTrkEndAngle(trk1, + ep1) + 180.0 + connectAngle/2.0 ); if ( d <= connectDistance && aa <= connectAngle ) { ConnectTracks( trk0, ep0, trk1, ep1 ); } @@ -1805,15 +1930,17 @@ LOG( log_ease, 1, ( "join T%d[%d] @[%0.3f %0.3f], T%d[%d] @[%0.3f %0.3f]\n", } /* Move the endPoint for (trk0) */ - if (!MoveEndPt( &trk0, &ep0, pos0, e->d0 )) + if (!MoveEndPt( &trk0, &ep0, pos0, e->d0 )) { return FALSE; + } /* Move the endPoint for (trk1) */ - if (!MoveEndPt( &trk1, &ep1, pos1, e->d1 )) + if (!MoveEndPt( &trk1, &ep1, pos1, e->d1 )) { return FALSE; + } -LOG( log_ease, 1, ( " EASE R%0.3f..%0.3f L%0.3f..%0.3f\n", - e->r0, e->r1, e->d0, e->d1 ) ) + LOG( log_ease, 1, ( " EASE R%0.3f..%0.3f L%0.3f..%0.3f\n", + e->r0, e->r1, e->d0, e->d1 ) ) /* Connect the tracks */ if (e->x == 0.0) { @@ -1840,8 +1967,8 @@ LOG( log_ease, 1, ( " EASE R%0.3f..%0.3f L%0.3f..%0.3f\n", joint = NewCornuTrack(pos,center,angle,radius, NULL, 0); } else { joint = NewJoint( GetTrkEndPos(trk0,ep0), GetTrkEndAngle(trk0,ep0), - GetTrkEndPos(trk1,ep1), GetTrkEndAngle(trk1,ep1), - GetTrkGauge(trk0), easeR, easeL, e ); + GetTrkEndPos(trk1,ep1), GetTrkEndAngle(trk1,ep1), + GetTrkGauge(trk0), easeR, easeL, e ); } CopyAttributes( trk0, joint ); ConnectTracks( trk1, ep1, joint, 1 ); @@ -1853,23 +1980,26 @@ LOG( log_ease, 1, ( " EASE R%0.3f..%0.3f L%0.3f..%0.3f\n", EXPORT void UndoJoint( - track_p trk, - EPINX_T ep, - track_p trk1, - EPINX_T ep1 ) + track_p trk, + EPINX_T ep, + track_p trk1, + EPINX_T ep1 ) { struct extraDataEase_t * xx; DIST_T d; - if ( GetTrkType(trk1) != T_EASEMENT ) + if ( GetTrkType(trk1) != T_EASEMENT ) { return; + } xx = GET_EXTRA_DATA(trk1, T_EASEMENT, extraDataEase_t); - if ( ep1 == 0 ) + if ( ep1 == 0 ) { d = xx->L/2.0 - xx->l0; - else + } else { d = xx->l1 - xx->L/2.0; - if ( d < 0.01 ) + } + if ( d < 0.01 ) { return; + } UndrawNewTrack( trk ); MoveEndPt( &trk, &ep, GetTrkEndPos(trk,ep), -d ); DrawNewTrack( trk ); @@ -1919,7 +2049,7 @@ track_p NewTrack( TRKINX_T a, TRKTYP_T b, EPINX_T c, TRKTYP_T d ) } void DrawStraightTrack( drawCmd_p a, coOrd b, coOrd c, ANGLE_T d, - track_p trk, wDrawColor color, int opts ) + track_p trk, wDrawColor color, int opts ) { } @@ -1928,9 +2058,9 @@ void DrawNewTrack( track_p t ) } static DIST_T JoinDalt( - DIST_T x, - DIST_T R, - DIST_T L ) + DIST_T x, + DIST_T R, + DIST_T L ) /* * Alternative distance computation, integrate over the curve. */ @@ -1941,7 +2071,7 @@ static DIST_T JoinDalt( coOrd p0, p1; d = 0.0; p0.x = p0.y = 0.0; - for ( i=1;i<=DCNT; i++) { + for ( i=1; i<=DCNT; i++) { ComputeJoinPos( x*((DIST_T)i)/((DIST_T)DCNT), R, L, NULL, NULL, &p1, NULL ); d += FindDistance( p0, p1 ); p0 = p1; @@ -1965,14 +2095,14 @@ test_plot( INT_T argc, char * argv[] ) C = atol( *argv++ ); X = L*L/(24*R); lprintf("R=%0.3f X=%0.3f L=%0.3f\n", R, X, L ); - - for (i=0;i<=C;i++) { + + for (i=0; i<=C; i++) { l = L*((DIST_T)i)/((DIST_T)C); d = JoinD( l, R, L ); d1 = JoinDalt( l, R, L ); ComputeJoinPos( l, R, L, &rr, &ra, &p, &pc ); lprintf("d: [%0.3f %0.3f] [%0.3f %03f] R=%0.3f A=%0.3f D=%0.3f D1=%0.3f X=%0.4f\n", - i, p.x, p.y, pc.x, pc.y, rr, ra, d, d1, pc.x-rr ); + i, p.x, p.y, pc.x, pc.y, rr, ra, d, d1, pc.x-rr ); } } @@ -1991,25 +2121,26 @@ test_psplot( INT_T argc, char * argv[] ) C = atol( *argv++ ); S = atof( *argv++ ); X = L*L/(24*R); - -lprintf("%%! kvjfv\nsave\n0 setlinewidth\n"); -lprintf("/Times-BoldItalic findfont 16 scalefont setfont\n"); -lprintf("36 36 moveto (R=%0.3f X=%0.3f L=%0.3f S=%0.3f) show\n", easeR, X, L, S ); -/*lprintf("24 768 translate -90 rotate\n");*/ -lprintf("gsave\n72 72 translate\n"); -lprintf("%0.3f %0.3f scale\n", 72.0/S, 72.0/S ); -lprintf("%0.3f %0.3f moveto %0.3f %0.3f lineto stroke\n", 0.0, 0.0, L, 0.0 ); -lprintf("%0.3f %0.3f %0.3f 270.0 90.0 arc stroke\n", L/2.0, easeR+X, easeR ); -lprintf("%0.3f %0.3f %0.3f 0.0 360.0 arc stroke\n", 0.0, 0.0, 0.25 ); + + lprintf("%%! kvjfv\nsave\n0 setlinewidth\n"); + lprintf("/Times-BoldItalic findfont 16 scalefont setfont\n"); + lprintf("36 36 moveto (R=%0.3f X=%0.3f L=%0.3f S=%0.3f) show\n", easeR, X, L, + S ); + /*lprintf("24 768 translate -90 rotate\n");*/ + lprintf("gsave\n72 72 translate\n"); + lprintf("%0.3f %0.3f scale\n", 72.0/S, 72.0/S ); + lprintf("%0.3f %0.3f moveto %0.3f %0.3f lineto stroke\n", 0.0, 0.0, L, 0.0 ); + lprintf("%0.3f %0.3f %0.3f 270.0 90.0 arc stroke\n", L/2.0, easeR+X, easeR ); + lprintf("%0.3f %0.3f %0.3f 0.0 360.0 arc stroke\n", 0.0, 0.0, 0.25 ); q.x = q.y = 0.0; - for (i=0;i<=C;i++) { + for (i=0; i<=C; i++) { l = L*((DIST_T)i)/((DIST_T)C); ComputeJoinPos( l, R, L, &rr, &ra, &p, &pc ); -lprintf("%0.3f %0.3f moveto %0.3f %0.3f lineto stroke\n", q.x, q.y, p.x, p.y ); + lprintf("%0.3f %0.3f moveto %0.3f %0.3f lineto stroke\n", q.x, q.y, p.x, p.y ); q = p; } -lprintf("%0.3f %0.3f %0.3f 0.0 360.0 arc stroke\n", p.x, p.y, 0.25 ); -lprintf("grestore\nrestore\nshowpage\n%%Trailer\n%%Pages: 1\n"); + lprintf("%0.3f %0.3f %0.3f 0.0 360.0 arc stroke\n", p.x, p.y, 0.25 ); + lprintf("grestore\nrestore\nshowpage\n%%Trailer\n%%Pages: 1\n"); } void Test_compute( INT_T argc, char * argv[] ) @@ -2039,7 +2170,7 @@ void Test_compute( INT_T argc, char * argv[] ) lprintf("ENDPT [%0.3f %0.3f] [%0.3f %0.3f]\n", q0.x, q0.y, q1.x, q1.y ); lprintf("CENTER [%0.3f %0.3f] [%0.3f %0.3f]\n", qc0.x, qc0.y, qc1.x, qc1.y ); lprintf("ComputeJoint( %0.3f %0.3f) { %0.3f %0.3f %0.3f } D0=%0.5f D1=%0.5f, D=%0.3f\n", - r0, r1, easeR, easeL, e.x, e.d0, e.d1, d ); + r0, r1, easeR, easeL, e.x, e.d0, e.d1, d ); } void Test_findL( INT_T argc, char * argv[] ) @@ -2061,8 +2192,8 @@ void Test_findL( INT_T argc, char * argv[] ) main( INT_T argc, char * argv[] ) { -INT_T flagX = 0; -INT_T flagV = 0; + INT_T flagX = 0; + INT_T flagV = 0; if (argc<1) { lprintf("plot|compute\n"); Exit(1); @@ -2072,15 +2203,15 @@ INT_T flagV = 0; switch (argv[0][1]) { case 'x': flagX++; - argc--;argv++; + argc--; argv++; break; case 'v': flagV++; - argc--;argv++; + argc--; argv++; break; default: lprintf("Huh: %s\n", *argv ); - argc--;argv++; + argc--; argv++; break; } } diff --git a/app/bin/textnoteui.c b/app/bin/textnoteui.c index ba255ea..40390bf 100644 --- a/app/bin/textnoteui.c +++ b/app/bin/textnoteui.c @@ -2,81 +2,55 @@ * View for the text note */ - /* XTrkCad - Model Railroad CAD - * Copyright (C) 2018 Martin Fischer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - +/* XTrkCad - Model Railroad CAD + * Copyright (C) 2018 Martin Fischer + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + #include "custom.h" #include "dynstring.h" #include "misc.h" #include "note.h" #include "param.h" #include "shortentext.h" -#include "track.h" +#include "track.h" -static struct extraDataNote_t noteDataInUI; +struct { + coOrd pos; + int layer; + track_p trk; +} textNoteData; static paramTextData_t noteTextData = { 300, 150 }; -static paramFloatRange_t r_1000_1000 = { -1000.0, 1000.0, 80 }; -static paramData_t textEditPLs[] = { +static paramFloatRange_t noRangeCheck = { 0.0, 0.0, 80, PDO_NORANGECHECK_HIGH | PDO_NORANGECHECK_LOW }; +static paramData_t textNotePLs[] = { #define I_ORIGX (0) - /*0*/ { PD_FLOAT, ¬eDataInUI.pos.x, "origx", PDO_DIM, &r_1000_1000, N_("Position X") }, + /*0*/ { PD_FLOAT, &textNoteData.pos.x, "origx", PDO_DIM|PDO_NOPREF, &noRangeCheck, N_("Position X") }, #define I_ORIGY (1) - /*1*/ { PD_FLOAT, ¬eDataInUI.pos.y, "origy", PDO_DIM, &r_1000_1000, N_("Position Y") }, + /*1*/ { PD_FLOAT, &textNoteData.pos.y, "origy", PDO_DIM|PDO_NOPREF, &noRangeCheck, N_("Position Y") }, #define I_LAYER (2) - /*2*/ { PD_DROPLIST, ¬eDataInUI.layer, "layer", 0, I2VP(150), "Layer", 0 }, + /*2*/ { PD_DROPLIST, &textNoteData.layer, "layer", PDO_NOPREF, I2VP(150), "Layer", 0 }, #define I_TEXT (3) /*3*/ { PD_TEXT, NULL, "text", PDO_NOPREF, ¬eTextData, N_("Note") } }; -static paramGroup_t textEditPG = { "textEdit", 0, textEditPLs, COUNT( textEditPLs ) }; -static wWin_p textEditW; +static paramGroup_t textNotePG = { "textNote", 0, textNotePLs, COUNT( textNotePLs ) }; +static wWin_p textNoteW; -#define textEntry ((wText_p)textEditPLs[I_TEXT].control) - -extern BOOL_T inDescribeCmd; - -/** - * Return the current text - * - */ -static void GetNoteTextData() -{ - int len; - - if (noteDataInUI.noteData.text ) { - MyFree(noteDataInUI.noteData.text); - } - len = wTextGetSize(textEntry); - noteDataInUI.noteData.text = (char*)MyMalloc(len + 2); - wTextGetText(textEntry, noteDataInUI.noteData.text, len); - return; -} - -/** - * Check validity of entered text - * - * \return always TRUE for testing - */ -BOOL_T -IsValidText(char * text) -{ - return(TRUE); -} +#define textEntry ((wText_p)textNotePLs[I_TEXT].control) /** @@ -88,26 +62,14 @@ IsValidText(char * text) */ static void TextDlgUpdate( - paramGroup_p pg, - int inx, - void * valueP) + paramGroup_p pg, + int inx, + void * valueP) { switch (inx) { case I_ORIGX: case I_ORIGY: - UpdateText(¬eDataInUI, OR_NOTE, FALSE); - break; - case I_LAYER: - UpdateText(¬eDataInUI, LY_NOTE, FALSE); - break; - case I_TEXT: - /** TODO: this is never called, why doesn't text update trigger this callback? */ - GetNoteTextData(); - if (IsValidText(noteDataInUI.noteData.text)) { - ParamDialogOkActive(&textEditPG, TRUE); - } else { - ParamDialogOkActive(&textEditPG, FALSE); - } + // TODO: Redraw bitmap at new location break; default: break; @@ -121,11 +83,8 @@ TextDlgUpdate( static void TextEditCancel( wWin_p junk ) { - if (inDescribeCmd) { - UpdateText(¬eDataInUI, CANCEL_NOTE, FALSE); - } ResetIfNotSticky(); - wHide(textEditW); + wHide(textNoteW); } /** @@ -138,9 +97,23 @@ TextEditCancel( wWin_p junk ) static void TextEditOK(void *junk) { - GetNoteTextData(); - UpdateText(¬eDataInUI, OK_TEXT, FALSE); - wHide(textEditW); + track_p trk = textNoteData.trk; + if ( trk == NULL ) { + // new note + trk = NewNote( -1, textNoteData.pos, OP_NOTETEXT ); + } + struct extraDataNote_t * xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); + xx->pos = textNoteData.pos; + SetTrkLayer( trk, textNoteData.layer ); + + int len = wTextGetSize(textEntry); + MyFree( xx->noteData.text ); + xx->noteData.text = (char*)MyMalloc(len + 2); + wTextGetText(textEntry, xx->noteData.text, len); + + SetBoundingBox( trk, xx->pos, xx->pos ); + DrawNewTrack( trk ); + wHide(textNoteW); ResetIfNotSticky(); SetFileChanged(); } @@ -149,41 +122,34 @@ TextEditOK(void *junk) /** * Create the edit dialog for text notes. - * + * * \param trk IN selected note * \param title IN dialog title */ static void -CreateEditTextNote(track_p trk, char *title) +CreateEditTextNote(char *title, char * textData ) { - struct extraDataNote_t *xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); - // create the dialog if necessary - if (!textEditW) { - ParamRegister(&textEditPG); - textEditW = ParamCreateDialog(&textEditPG, - "", - _("Done"), TextEditOK, - TextEditCancel, TRUE, NULL, - F_BLOCK, - TextDlgUpdate); + if (!textNoteW) { + ParamRegister(&textNotePG); + textNoteW = ParamCreateDialog(&textNotePG, + "", + _("Done"), TextEditOK, + TextEditCancel, TRUE, NULL, + F_BLOCK, + TextDlgUpdate); } - wWinSetTitle(textEditPG.win, MakeWindowTitle(title)); - - // initialize the dialog fields - noteDataInUI.pos = xx->pos; - noteDataInUI.layer = xx->layer; - noteDataInUI.trk = trk; + wWinSetTitle(textNotePG.win, MakeWindowTitle(title)); wTextClear(textEntry); - wTextAppend(textEntry, xx->noteData.text ); + wTextAppend(textEntry, textData ); wTextSetReadonly(textEntry, FALSE); - FillLayerList((wList_p)textEditPLs[I_LAYER].control); - ParamLoadControls(&textEditPG); - + FillLayerList((wList_p)textNotePLs[I_LAYER].control); + ParamLoadControls(&textNotePG); + // and show the dialog - wShow(textEditW); + wShow(textNoteW); } /** @@ -204,35 +170,39 @@ void DescribeTextNote(track_p trk, char * str, CSIZE_T len) RemoveFormatChars(xx->noteData.text, noteText); EllipsizeString(noteText, NULL, 80); DynStringMalloc(&statusLine, 100); - - DynStringPrintf(&statusLine, - _("Note: Layer=%d %-.80s"), - GetTrkLayer(trk)+1, - noteText ); + + DynStringPrintf(&statusLine, + _("Text Note(%d) Layer=%d %-.80s"), + GetTrkIndex(trk), + GetTrkLayer(trk)+1, + noteText ); strcpy(str, DynStringToCStr(&statusLine)); DynStringFree(&statusLine); - MyFree(noteText); - - if (inDescribeCmd) { - NoteStateSave(trk); - - CreateEditTextNote(trk, _("Update comment")); + if ( ! inDescribeCmd ) { + return; } + textNoteData.pos = xx->pos; + textNoteData.layer = GetTrkLayer( trk ); + textNoteData.trk = trk; + + CreateEditTextNote(_("Update Text Note"), xx->noteData.text ); } /** * Show the UI for entering new text notes - * + * * \param xx Note object data */ -void NewTextNoteUI(track_p trk) { - struct extraDataNote_t * xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); +void NewTextNoteUI(coOrd pos ) +{ char *tmpPtrText = _("Replace this text with your note"); - xx->noteData.text = MyStrdup(tmpPtrText); + textNoteData.pos = pos; + textNoteData.layer = curLayer; + textNoteData.trk = NULL; - CreateEditTextNote(trk, _("Create Text Note")); + CreateEditTextNote(_("Create Text Note"), tmpPtrText ); } diff --git a/app/bin/track.c b/app/bin/track.c index 7a69160..951eec3 100644 --- a/app/bin/track.c +++ b/app/bin/track.c @@ -1,5 +1,5 @@ /** \file track.c - * Track + * Track */ /* XTrkCad - Model Railroad CAD @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "ccurve.h" @@ -33,15 +33,12 @@ #include "param.h" #include "paths.h" #include "track.h" +#include "trackx.h" +#include "trkendpt.h" #include "misc.h" #include "ctrain.h" #include "common-ui.h" - -#ifndef TRACKDEP -#ifndef FASTTRACK -#include "trackx.h" -#endif -#endif +#include "version.h" #include <inttypes.h> @@ -73,14 +70,20 @@ static int log_timedrawtracks = 0; #define CLOSETOTHEEDGE (10) /**< minimum distance between paste position and edge of window */ +EXPORT DIST_T trackGauge; +EXPORT DIST_T minLength = 0.1; +EXPORT DIST_T connectDistance = 0.1; +EXPORT ANGLE_T connectAngle = 1.0; +EXPORT long twoRailScale = 16; + EXPORT wIndex_t trackCount; EXPORT long drawEndPtV = 2; EXPORT long drawUnconnectedEndPt = 0; /**< How do we draw Unconnected EndPts */ -EXPORT long centerDrawMode = FALSE; /**< flag to control drawing of circle centers */ +EXPORT long centerDrawMode = + FALSE; /**< flag to control drawing of circle centers */ -static BOOL_T exportingTracks = FALSE; EXPORT signed char * pathPtr; EXPORT int pathCnt = 0; @@ -98,9 +101,6 @@ EXPORT coOrd descriptionOff; EXPORT DIST_T roadbedWidth = 0.0; EXPORT DIST_T roadbedLineWidth = 3.0/BASE_DPI; -//EXPORT DIST_T minTrackRadius; -//EXPORT DIST_T maxTrackGrade = 5.0; - static int suspendElevUpdates = FALSE; static track_p * importTrack; @@ -109,21 +109,23 @@ EXPORT BOOL_T onTrackInSplit = FALSE; static BOOL_T inDrawTracks; -static wBool_t bWriteEndPtDirectIndex = FALSE; - EXPORT wBool_t bFreeTrack = FALSE; -#ifndef TRACKDEP +EXPORT long colorTrack = 0; +EXPORT long colorDraw = 0; + /***************************************************************************** * - * + * * */ -EXPORT void ActivateTrack( track_cp trk) { +EXPORT void ActivateTrack( track_cp trk) +{ int inx = GetTrkType(trk); - if (trackCmds( inx )->activate != NULL) + if (trackCmds( inx )->activate != NULL) { trackCmds( inx )->activate (trk); + } } @@ -147,20 +149,21 @@ EXPORT DIST_T GetTrkDistance( track_cp trk, coOrd * pos ) /** * Check whether the track passed as parameter is close to an existing piece. Track * pieces that aren't visible (in a tunnel or on an invisble layer) can be ignored, - * depending on flag. If there is a track closeby, the passed track is moved to that + * depending on flag. If there is a track closeby, the passed track is moved to that * position. This implements the snap feature. * * \param fp IN/OUT the old and the new position * \param complain IN show error message if there is no other piece of track - * \param track IN + * \param track IN * \param ignoreHidden IN decide whether hidden track is ignored or not - * \return NULL if there is no track, pointer to track otherwise + * \return NULL if there is no track, pointer to track otherwise */ -EXPORT track_p OnTrack2( coOrd * fp, BOOL_T complain, BOOL_T track, BOOL_T ignoreHidden, track_p t ) +EXPORT track_p OnTrack2( coOrd * fp, BOOL_T complain, BOOL_T track, + BOOL_T ignoreHidden, track_p t ) { track_p trk; - DIST_T distance, closestDistance = 1000000; + DIST_T distance, closestDistance = DIST_INF; track_p closestTrack = NULL; coOrd p, closestPos, q0, q1; @@ -170,30 +173,38 @@ EXPORT track_p OnTrack2( coOrd * fp, BOOL_T complain, BOOL_T track, BOOL_T ignor q0.y -= 1.0; q1.y += 1.0; TRK_ITERATE( trk ) { - if ( track && !IsTrack(trk) ) + if ( track && !IsTrack(trk) ) { continue; - if (trk == t) continue; + } + if (trk == t) { continue; } + // Bounding box check if (trk->hi.x < q0.x || - trk->lo.x > q1.x || - trk->hi.y < q0.y || - trk->lo.y > q1.y ) + trk->lo.x > q1.x || + trk->hi.y < q0.y || + trk->lo.y > q1.y ) { continue; + } if ( ignoreHidden ) { - if ( (!GetTrkVisible(trk)) && drawTunnel == DRAW_TUNNEL_NONE) + if ( (!GetTrkVisible(trk)) && drawTunnel == DRAW_TUNNEL_NONE) { continue; - if ( !GetLayerVisible( GetTrkLayer( trk ) ) ) + } + if ( !GetLayerVisible( GetTrkLayer( trk ) ) ) { continue; + } } + p = *fp; distance = trackCmds( GetTrkType(trk) )->distance( trk, &p ); - if (fabs(distance) <= fabs(closestDistance)) { //Make the last (highest) preferred + if (fabs(distance) <= fabs( + closestDistance)) { //Make the last (highest) preferred closestDistance = distance; closestTrack = trk; closestPos = p; } } - if (closestTrack && closestDistance <0 ) closestDistance = 0.0; //Turntable was closest - inside well - if (closestTrack && ((closestDistance <= mainD.scale*0.25) || (closestDistance <= trackGauge*2.0) )) { + if (closestTrack && closestDistance <0 ) { closestDistance = 0.0; } //Turntable was closest - inside well + if (closestTrack && ((closestDistance <= mainD.scale*0.25) + || (closestDistance <= trackGauge*2.0) )) { *fp = closestPos; return closestTrack; } @@ -215,7 +226,9 @@ EXPORT track_p OnTrack( coOrd * fp, BOOL_T complain, BOOL_T track ) return OnTrack2( fp, complain, track, TRUE, NULL ); } -EXPORT track_p OnTrackIgnore (coOrd * fp, BOOL_T complain, BOOL_T track, track_p t ) { +EXPORT track_p OnTrackIgnore (coOrd * fp, BOOL_T complain, BOOL_T track, + track_p t ) +{ return OnTrack2(fp, complain, track, TRUE, t); } @@ -228,8 +241,9 @@ EXPORT BOOL_T CheckTrackLayer( track_p trk ) } else if (GetLayerModule( GetTrkLayer( trk ) ) ) { ErrorMessage( MSG_CANT_MODIFY_MODULE_TRK ); return FALSE; - } else + } else { return TRUE; + } } EXPORT BOOL_T CheckTrackLayerSilent( track_p trk ) @@ -238,8 +252,9 @@ EXPORT BOOL_T CheckTrackLayerSilent( track_p trk ) return FALSE; } else if (GetLayerModule( GetTrkLayer( trk ) ) ) { return FALSE; - } else + } else { return TRUE; + } } /****************************************************************************** @@ -259,29 +274,32 @@ EXPORT void EnumerateTracks( void * unused ) BOOL_T content = FALSE; TRK_ITERATE( trk ) { - /* + /* * process track piece if none are selected (list all) or if it is one of the * selected pieces (list only selected ) */ - if ((!selectedTrackCount || GetTrkSelected(trk)) && trackCmds(trk->type)->enumerate != NULL) { - if (trackCmds(trk->type)->enumerate( trk )==TRUE) content = TRUE; + if ((!selectedTrackCount || GetTrkSelected(trk)) + && trackCmds(trk->type)->enumerate != NULL) { + if (trackCmds(trk->type)->enumerate( trk )==TRUE) { content = TRUE; } } } if (content == FALSE) { wBeep(); - if (selectedTrackCount == 0) + if (selectedTrackCount == 0) { InfoMessage(_("No track or structure pieces are present in layout")); - else + } else { InfoMessage(_("No track or structure pieces are selected")); + } return; } EnumerateStart(); for (inx=1; inx<trackCmds_da.cnt; inx++) - if (trackCmds(inx)->enumerate != NULL) + if (trackCmds(inx)->enumerate != NULL) { trackCmds(inx)->enumerate( NULL ); + } EnumerateEnd(); } @@ -294,32 +312,33 @@ EXPORT void EnumerateTracks( void * unused ) static void AbortNoTrack( void ) { - AbortProg( "No Track Op called" ); + CHECKMSG( FALSE, ( "No Track Op called" ) ); } static trackCmd_t notrackCmds = { - "NOTRACK", - (void*)AbortNoTrack, - (void*)AbortNoTrack, - (void*)AbortNoTrack, - (void*)AbortNoTrack, - (void*)AbortNoTrack, - (void*)AbortNoTrack, - (void*)AbortNoTrack, - (void*)AbortNoTrack, - (void*)AbortNoTrack, - (void*)AbortNoTrack, - (void*)AbortNoTrack, - (void*)AbortNoTrack, - (void*)AbortNoTrack, - (void*)AbortNoTrack, - (void*)AbortNoTrack, - (void*)AbortNoTrack, - (void*)AbortNoTrack, - (void*)AbortNoTrack, - (void*)AbortNoTrack, - (void*)AbortNoTrack, - (void*)AbortNoTrack }; + "NOTRACK", + (void*)AbortNoTrack, + (void*)AbortNoTrack, + (void*)AbortNoTrack, + (void*)AbortNoTrack, + (void*)AbortNoTrack, + (void*)AbortNoTrack, + (void*)AbortNoTrack, + (void*)AbortNoTrack, + (void*)AbortNoTrack, + (void*)AbortNoTrack, + (void*)AbortNoTrack, + (void*)AbortNoTrack, + (void*)AbortNoTrack, + (void*)AbortNoTrack, + (void*)AbortNoTrack, + (void*)AbortNoTrack, + (void*)AbortNoTrack, + (void*)AbortNoTrack, + (void*)AbortNoTrack, + (void*)AbortNoTrack, + (void*)AbortNoTrack +}; EXPORT TRKTYP_T InitObject( trackCmd_t * cmds ) { @@ -347,7 +366,6 @@ EXPORT void InitTrkTrack( void ) */ -#ifndef FASTTRACK EXPORT TRKINX_T GetTrkIndex( track_p trk ) { @@ -356,14 +374,15 @@ EXPORT TRKINX_T GetTrkIndex( track_p trk ) EXPORT TRKTYP_T GetTrkType( track_p trk ) { - ASSERT( trk->type != T_NOTRACK && !IsTrackDeleted(trk) ); + CHECK( trk->type != T_NOTRACK && !IsTrackDeleted(trk) ); return trk->type; } EXPORT SCALEINX_T GetTrkScale( track_p trk ) { - if ( trk ) + if ( trk ) { return (SCALEINX_T)trk->scale; + } return 0; } @@ -377,6 +396,14 @@ EXPORT unsigned int GetTrkLayer( track_p trk ) return trk->layer; } +EXPORT tieData_t GetTrkTieData( track_p trk ) +{ + if (!GetLayerUseDefault(GetTrkLayer(trk))) { + return GetLayerTieData(GetTrkLayer(trk)); + } + return GetScaleTieData(GetTrkScale(trk)); +} + EXPORT void SetBoundingBox( track_p trk, coOrd hi, coOrd lo ) { trk->hi.x = (float)hi.x; @@ -399,7 +426,16 @@ EXPORT EPINX_T GetTrkEndPtCnt( track_cp trk ) return trk->endCnt; } -EXPORT struct extraDataBase_t * GetTrkExtraData( track_cp trk, TRKTYP_T trkType ) + +EXPORT trkEndPt_p GetTrkEndPt(track_cp trk, EPINX_T ep ) +{ + CHECK( ep < GetTrkEndPtCnt(trk) ); + return EndPtIndex( trk->endPt, ep ); +} + + +EXPORT struct extraDataBase_t * GetTrkExtraData( track_cp trk, + TRKTYP_T trkType ) { //printf( "GTXD T%d TY%d\n", GetTrkIndex(trk), trkType ); if ( IsTrackDeleted(trk) ) { @@ -408,65 +444,35 @@ EXPORT struct extraDataBase_t * GetTrkExtraData( track_cp trk, TRKTYP_T trkType // - DoRegression to remove expected track // - UndoStart / UndoDelete // Anywhere else: needs investigation - if ( bFreeTrack == FALSE ) + if ( bFreeTrack == FALSE ) { printf( "GetExtraData T%d is deleted!\n", trk->index ); + } return trk->extraData; } #ifdef CHECK_EXTRA_DATA - ASSERT( trk->extraData ); - ASSERT( trk->type == trk->extraData->trkType ); - ASSERT( trkType == T_NOTRACK || trk->type == trkType ); + CHECK( trk->extraData ); + CHECK( trk->type == trk->extraData->trkType ); + CHECK( trkType == T_NOTRACK || trk->type == trkType ); #endif return trk->extraData; } -EXPORT void SetTrkEndPoint( track_p trk, EPINX_T ep, coOrd pos, ANGLE_T angle ) -{ - ASSERT( ep < trk->endCnt ); - if (trk->endPt[ep].track != NULL) { - AbortProg( "setTrkEndPoint: endPt is connected" ); - } - trk->endPt[ep].pos = pos; - trk->endPt[ep].angle = angle; -} - -EXPORT coOrd GetTrkEndPos( track_p trk, EPINX_T e ) -{ - ASSERT( e < trk->endCnt ); - return trk->endPt[e].pos; -} - -EXPORT ANGLE_T GetTrkEndAngle( track_p trk, EPINX_T e ) -{ - ASSERT( e < trk->endCnt ); - return trk->endPt[e].angle; -} -EXPORT track_p GetTrkEndTrk( track_p trk, EPINX_T e ) +EXPORT void ResizeExtraData( track_p trk, CSIZE_T newSize ) { - ASSERT( e < trk->endCnt ); - return trk->endPt[e].track; + trk->extraData = MyRealloc( trk->extraData, newSize ); + trk->extraSize = newSize; } -EXPORT long GetTrkEndOption( track_p trk, EPINX_T e ) -{ - ASSERT( e < trk->endCnt ); - return trk->endPt[e].option; -} - -EXPORT long SetTrkEndOption( track_p trk, EPINX_T e, long option ) -{ - ASSERT( e < trk->endCnt ); - return trk->endPt[e].option = option; -} EXPORT DIST_T GetTrkGauge( - track_cp trk ) + track_cp trk ) { - if (trk) + if (trk) { return GetScaleTrackGauge( GetTrkScale( trk ) ); - else + } else { return trackGauge; + } } EXPORT int GetTrkWidth( track_p trk ) @@ -481,10 +487,11 @@ EXPORT void SetTrkWidth( track_p trk, int width ) EXPORT int GetTrkBits( track_p trk ) { - if (trk) + if (trk) { return trk->bits; - else + } else { return 0; + } } EXPORT int SetTrkBits( track_p trk, int bits ) @@ -505,105 +512,25 @@ EXPORT BOOL_T IsTrackDeleted( track_p trk ) { return trk->deleted; } -#endif - -EXPORT void SetTrkEndElev( track_p trk, EPINX_T ep, int option, DIST_T height, char * station ) -{ - track_p trk1; - EPINX_T ep1; - trk->endPt[ep].elev.option = option; - trk->endPt[ep].elev.cacheSet = FALSE; - if (EndPtIsDefinedElev(trk,ep)) { - trk->endPt[ep].elev.u.height = height; - } else if (EndPtIsStationElev(trk,ep)) { - if (station == NULL) - station = ""; - trk->endPt[ep].elev.u.name = MyStrdup(station); - } - if ( (trk1=GetTrkEndTrk(trk, ep)) != NULL ) { - ep1 = GetEndPtConnectedToMe( trk1, trk ); - if (ep1 >= 0) { - trk1->endPt[ep1].elev.option = option; - trk1->endPt[ep1].elev.u.height = height; - if (EndPtIsDefinedElev(trk1,ep1)) - trk1->endPt[ep1].elev.u.height = height; - else if (EndPtIsStationElev(trk,ep)) - trk1->endPt[ep1].elev.u.name = MyStrdup(station); - } - } -} - - -EXPORT void GetTrkEndElev( track_p trk, EPINX_T e, int *option, DIST_T *height ) -{ - *option = trk->endPt[e].elev.option; - *height = trk->endPt[e].elev.u.height; -} - - -EXPORT int GetTrkEndElevUnmaskedMode( track_p trk, EPINX_T e ) -{ - return trk->endPt[e].elev.option; -} - - -EXPORT int GetTrkEndElevMode( track_p trk, EPINX_T e ) -{ - return trk->endPt[e].elev.option&ELEV_MASK; -} - - -EXPORT DIST_T GetTrkEndElevHeight( track_p trk, EPINX_T e ) -{ - ASSERT( EndPtIsDefinedElev(trk,e) ); - return trk->endPt[e].elev.u.height; -} - -BOOL_T bCacheElev = TRUE; - -EXPORT BOOL_T GetTrkEndElevCachedHeight (track_p trk, EPINX_T e, DIST_T * height, DIST_T * grade) -{ - if ( ! bCacheElev ) - return FALSE; - if (trk->endPt[e].elev.cacheSet) { - *height = trk->endPt[e].elev.cachedElev; - *grade = trk->endPt[e].elev.cachedGrade; - return TRUE; - } - return FALSE; -} - -EXPORT void SetTrkEndElevCachedHeight ( track_p trk, EPINX_T e, DIST_T height, DIST_T grade) -{ - trk->endPt[e].elev.cachedElev = height; - trk->endPt[e].elev.cachedGrade = grade; - trk->endPt[e].elev.cacheSet = TRUE; -} - - -EXPORT char * GetTrkEndElevStation( track_p trk, EPINX_T e ) -{ - ASSERT( EndPtIsStationElev(trk,e) ); - if ( trk->endPt[e].elev.u.name == NULL ) - return ""; - else - return trk->endPt[e].elev.u.name; -} EXPORT void SetTrkEndPtCnt( track_p trk, EPINX_T cnt ) { EPINX_T oldCnt = trk->endCnt; trk->endCnt = cnt; - if ((trk->endPt = MyRealloc( trk->endPt, trk->endCnt * sizeof trk->endPt[0] )) == NULL) { - AbortProg("setTrkEndPtCnt: No memory" ); + trk->endPt = MyRealloc( trk->endPt, EndPtSize(trk->endCnt) ); + if (oldCnt < cnt) { + memset( GetTrkEndPt( trk, oldCnt ), 0, EndPtSize(cnt-oldCnt) ); + for ( EPINX_T ep = oldCnt; ep<cnt; ep++ ) { + // Set .index to -1 + SetEndPtTrack( GetTrkEndPt( trk, ep ), NULL ); + } } - if (oldCnt < cnt) - memset( &trk->endPt[oldCnt], 0, (cnt-oldCnt) * sizeof *trk->endPt ); } + /** - * Set the layer for a track. + * Set the layer for a track. * * \param trk IN the layer to change the layer for * \param layer IN the new layer for the track @@ -612,10 +539,11 @@ void SetTrkLayer( track_p trk, int layer ) { DecrementLayerObjects(trk->layer); - if (useCurrentLayer) + if (useCurrentLayer) { trk->layer = (unsigned int)curLayer; - else + } else { trk->layer = (unsigned int)layer; + } IncrementLayerObjects(trk->layer); } @@ -636,8 +564,9 @@ EXPORT int ClrAllTrkBitsRedraw( int bits, wBool_t bRedraw ) if (trk->bits&bits) { cnt++; trk->bits &= ~bits; - if ( bRedraw ) + if ( bRedraw ) { DrawNewTrack( trk ); + } } } return cnt; @@ -650,9 +579,7 @@ EXPORT void SetTrkElev( track_p trk, int mode, DIST_T elev ) SetTrkBits( trk, TB_ELEVPATH ); trk->elev = elev; trk->elevMode = mode; - for (int i=0;i<trk->endCnt;i++) { - trk->endPt[i].elev.cacheSet = FALSE; - } + ClrEndPtElevCache( trk->endCnt, trk->endPt ); } @@ -680,7 +607,7 @@ EXPORT void ClearElevPath( void ) EXPORT BOOL_T GetTrkOnElevPath( track_p trk, DIST_T * elev ) { if (trk->bits&TB_ELEVPATH) { - if ( elev ) *elev = trk->elev; + if ( elev ) { *elev = trk->elev; } return TRUE; } else { return FALSE; @@ -703,67 +630,23 @@ EXPORT void CopyAttributes( track_p src, track_p dst ) */ -EXPORT BOOL_T WriteEndPt( FILE * f, track_cp trk, EPINX_T ep ) -{ - trkEndPt_p endPt = &trk->endPt[ep]; - BOOL_T rc = TRUE; - long option; - - assert ( endPt != NULL ); - if (bWriteEndPtDirectIndex && endPt->index > 0) { - rc &= fprintf( f, "\tT4 %d ", endPt->index )>0; - } else if (endPt->track == NULL || - ( exportingTracks && !GetTrkSelected(endPt->track) ) ) { - rc &= fprintf( f, "\tE4 " )>0; - } else { - rc &= fprintf( f, "\tT4 %d ", endPt->track->index )>0; - } - rc &= fprintf( f, "%0.6f %0.6f %0.6f", endPt->pos.x, endPt->pos.y, endPt->angle )>0; - option = (endPt->option<<8) | (endPt->elev.option&0xFF); - if ( option != 0 ) { - rc &= fprintf( f, " %ld %0.6f %0.6f", option, endPt->elev.doff.x, endPt->elev.doff.y )>0; - switch ( endPt->elev.option&ELEV_MASK ) { - case ELEV_DEF: - rc &= fprintf( f, " %0.6f ", endPt->elev.u.height )>0; - break; - case ELEV_STATION: - rc &= fprintf( f, " \"%s\" ", PutTitle( endPt->elev.u.name ) )>0; - break; - default: - rc &= fprintf( f, " 0.0 ")>0; - } - } else { - rc &= fprintf( f, " 0 0.0 0.0 0.0 ")>0; - } - if ((endPt->elev.option&ELEV_MASK) == ELEV_DEF) - rc &= fprintf( f, "%0.6f ",endPt->elev.u.height)>0; - else - rc &= fprintf( f, "0.0 ")>0; - long elevVisible = (endPt->elev.option&ELEV_VISIBLE)?1:0; - long elevType = endPt->elev.option&ELEV_MASK; - long gapType = endPt->option; - rc &= fprintf( f, "%ld %ld %ld ", elevVisible, elevType, gapType)>0; - rc &= fprintf( f, "%0.6f ", trk->elev)>0; - rc &= fprintf( f, "\n" )>0; - return rc; -} - - EXPORT EPINX_T PickEndPoint( coOrd p, track_cp trk ) { EPINX_T inx, i; DIST_T d, dd; coOrd pos; - if (trk->endCnt <= 0) + if (trk->endCnt <= 0) { return -1; + } if ( onTrackInSplit && trk->endCnt > 2 ) { - if (GetTrkType(trk) == T_TURNOUT) + if (GetTrkType(trk) == T_TURNOUT) { return TurnoutPickEndPt( p, trk ); + } } - d = FindDistance( p, trk->endPt[0].pos ); + d = FindDistance( p, GetEndPtPos( trk->endPt ) ); inx = 0; for ( i=1; i<trk->endCnt; i++ ) { - pos = trk->endPt[i].pos; + pos = GetEndPtPos( EndPtIndex( trk->endPt, i ) ); dd=FindDistance(p, pos); if (dd < d) { d = dd; @@ -774,29 +657,27 @@ EXPORT EPINX_T PickEndPoint( coOrd p, track_cp trk ) } +/** + * Find an endpoint of trk that is close to coOrd p. + * Returns index of endpoint or displays a message + * and returns -1 if none found. + */ EXPORT EPINX_T PickUnconnectedEndPoint( coOrd p, track_cp trk ) { - EPINX_T inx, i; - DIST_T d=0, dd; - coOrd pos; - inx = -1; + EPINX_T inx; - for ( i=0; i<trk->endCnt; i++ ) { - if (trk->endPt[i].track == NULL) { - pos = trk->endPt[i].pos; - dd=FindDistance(p, pos); - if (inx == -1 || dd <= d) { - d = dd; - inx = i; - } - } - } + inx = PickUnconnectedEndPointSilent( p, trk ); - if (inx == -1) + if (inx == -1) { ErrorMessage( MSG_NO_UNCONN_EP ); + } return inx; } +/** + * Find an endpoint of trk that is close to coOrd p. + * Returns index of endpoint or -1 if none found. + */ EXPORT EPINX_T PickUnconnectedEndPointSilent( coOrd p, track_cp trk ) { EPINX_T inx, i; @@ -805,8 +686,9 @@ EXPORT EPINX_T PickUnconnectedEndPointSilent( coOrd p, track_cp trk ) inx = -1; for ( i=0; i<trk->endCnt; i++ ) { - if (trk->endPt[i].track == NULL) { - pos = trk->endPt[i].pos; + trkEndPt_p epp = EndPtIndex( trk->endPt, i ); + if (GetEndPtTrack( epp ) == NULL) { + pos = GetEndPtPos( epp ); dd=FindDistance(p, pos); if (inx == -1 || dd <= d) { d = dd; @@ -819,55 +701,85 @@ EXPORT EPINX_T PickUnconnectedEndPointSilent( coOrd p, track_cp trk ) } +/** + * Connect all the end points to this track (trk0) that are close enough + * (distance and angle) to another track's unconnected endpoint. + */ +EXPORT void ConnectAllEndPts(track_p trk0) +{ + for (EPINX_T ep0 = 0; ep0 < GetTrkEndPtCnt(trk0); ep0++) { + // Skip if already connected + if (GetTrkEndTrk(trk0, ep0) != NULL) { continue; } + + coOrd pos0 = GetTrkEndPos(trk0, ep0); + track_p trk2 = OnTrack2(&pos0, FALSE, TRUE, TRUE, trk0); + + // Not near another track? + if (trk2 == NULL) { continue; } + EPINX_T ep2 = PickUnconnectedEndPointSilent(pos0, trk2); + + // Close enough? + coOrd pos2 = GetTrkEndPos(trk2, ep2); + DIST_T distance = FindDistance(pos0, pos2); + if (distance > connectDistance) { continue; } + + // Aligned? + ANGLE_T a = fabs(DifferenceBetweenAngles( + GetTrkEndAngle(trk0, ep0), + GetTrkEndAngle(trk2, ep2) + 180.0)); + if (a > connectAngle) { continue; } + + // Make the connection + ConnectTracks(trk0, ep0, trk2, ep2); + DrawNewTrack(trk2); + } +} EXPORT EPINX_T GetEndPtConnectedToMe( track_p trk, track_p me ) { EPINX_T ep; for (ep=0; ep<trk->endCnt; ep++) - if (trk->endPt[ep].track == me) + if (GetEndPtTrack( EndPtIndex( trk->endPt, ep ) ) == me) { return ep; + } return -1; } -EXPORT EPINX_T GetNearestEndPtConnectedToMe( track_p trk, track_p me, coOrd pos) { +EXPORT EPINX_T GetNearestEndPtConnectedToMe( track_p trk, track_p me, + coOrd pos) +{ EPINX_T ep, found = -1; DIST_T d = DIST_INF; DIST_T dd; - for (ep=0; ep<trk->endCnt; ep++) { - if (trk->endPt[ep].track == me) { - dd = FindDistance(pos,trk->endPt[ep].pos); - if (dd<d) { - found = ep; - d = dd; - } + for (ep=0; ep<trk->endCnt; ep++) { + trkEndPt_p epp = EndPtIndex( trk->endPt, ep ); + if (GetEndPtTrack( epp ) == me) { + coOrd pos1 = GetEndPtPos( epp ); + dd = FindDistance(pos, pos1 ); + if (dd<d) { + found = ep; + d = dd; } } - return found; + } + return found; } EXPORT void SetEndPts( track_p trk, EPINX_T cnt ) { - EPINX_T inx; - -LOG1( log_readTracks, ( "SetEndPts( T%d, %d )\n", trk->index, cnt ) ) - if (cnt > 0 && tempEndPts_da.cnt != cnt) { - InputError( "Incorrect number of End Points for track, read %d, expected %d.\n", FALSE, tempEndPts_da.cnt, cnt ); + LOG1( log_readTracks, ( "SetEndPts( T%d, %d )\n", trk->index, cnt ) ) + if (cnt > 0 && TempEndPtsCount() != cnt) { + InputError( "Incorrect number of End Points for track, read %d, expected %d.\n", + FALSE, TempEndPtsCount(), cnt ); return; } - if (tempEndPts_da.cnt) { - trk->endPt = (trkEndPt_p)MyMalloc( tempEndPts_da.cnt * sizeof *trk->endPt ); - } else { + trk->endCnt = TempEndPtsCount(); + if ( trk->endCnt <= 0 ) { trk->endPt = NULL; + } else { + trk->endPt = (trkEndPt_p)memdup( TempEndPt(0), EndPtSize( trk->endCnt ) ); } - for ( inx=0; inx<tempEndPts_da.cnt; inx++ ) { - trk->endPt[inx].index = tempEndPts(inx).index; - trk->endPt[inx].pos = tempEndPts(inx).pos; - trk->endPt[inx].angle = tempEndPts(inx).angle; - trk->endPt[inx].elev = tempEndPts(inx).elev; - trk->endPt[inx].option = tempEndPts(inx).option; - } - trk->endCnt = tempEndPts_da.cnt; } @@ -875,8 +787,11 @@ EXPORT void MoveTrack( track_p trk, coOrd orig ) { EPINX_T ep; for (ep=0; ep<trk->endCnt; ep++) { - trk->endPt[ep].pos.x += orig.x; - trk->endPt[ep].pos.y += orig.y; + trkEndPt_p epp = EndPtIndex( trk->endPt, ep ); + coOrd pos = GetEndPtPos( epp ); + pos.x += orig.x; + pos.y += orig.y; + SetEndPt( epp, pos, GetEndPtAngle( epp ) ); } trackCmds( trk->type )->move( trk, orig ); } @@ -885,11 +800,14 @@ EXPORT void MoveTrack( track_p trk, coOrd orig ) EXPORT void RotateTrack( track_p trk, coOrd orig, ANGLE_T angle ) { EPINX_T ep; - if ( trackCmds( trk->type )->rotate == NULL ) - return; + if ( trackCmds( trk->type )->rotate == NULL ) { + return; + } for (ep=0; ep<trk->endCnt; ep++) { - Rotate( &trk->endPt[ep].pos, orig, angle ); - trk->endPt[ep].angle = NormalizeAngle( trk->endPt[ep].angle + angle ); + trkEndPt_p epp = EndPtIndex( trk->endPt, ep ); + coOrd pos = GetEndPtPos( epp ); + Rotate( &pos, orig, angle ); + SetEndPt( epp, pos, NormalizeAngle( GetEndPtAngle(epp) + angle ) ); } trackCmds( trk->type )->rotate( trk, orig, angle ); } @@ -898,11 +816,15 @@ EXPORT void RotateTrack( track_p trk, coOrd orig, ANGLE_T angle ) EXPORT void RescaleTrack( track_p trk, FLOAT_T ratio, coOrd shift ) { EPINX_T ep; - if ( trackCmds( trk->type )->rescale == NULL ) + if ( trackCmds( trk->type )->rescale == NULL ) { return; + } for (ep=0; ep<trk->endCnt; ep++) { - trk->endPt[ep].pos.x *= ratio; - trk->endPt[ep].pos.y *= ratio; + trkEndPt_p epp = EndPtIndex( trk->endPt, ep ); + coOrd pos = GetEndPtPos( epp ); + pos.x *= ratio; + pos.y *= ratio; + SetEndPt( epp, pos, GetEndPtAngle(epp) ); } trackCmds( trk->type )->rescale( trk, ratio ); MoveTrack( trk, shift ); @@ -910,9 +832,9 @@ EXPORT void RescaleTrack( track_p trk, FLOAT_T ratio, coOrd shift ) EXPORT void FlipPoint( - coOrd * pos, - coOrd orig, - ANGLE_T angle ) + coOrd * pos, + coOrd orig, + ANGLE_T angle ) { Rotate( pos, orig, -angle ); pos->x = 2*orig.x - pos->x; @@ -921,33 +843,35 @@ EXPORT void FlipPoint( EXPORT void FlipTrack( - track_p trk, - coOrd orig, - ANGLE_T angle ) + track_p trk, + coOrd orig, + ANGLE_T angle ) { EPINX_T ep; - trkEndPt_t endPt; for ( ep=0; ep<trk->endCnt; ep++ ) { - FlipPoint( &trk->endPt[ep].pos, orig, angle ); - trk->endPt[ep].angle = NormalizeAngle( 2*angle - trk->endPt[ep].angle ); - } - if ( trackCmds(trk->type)->flip ) + trkEndPt_p epp = EndPtIndex( trk->endPt, ep ); + coOrd pos1 = GetEndPtPos( epp ); + FlipPoint( &pos1, orig, angle ); + ANGLE_T angle1 = GetEndPtAngle( epp ); + angle1 = NormalizeAngle( 2*angle - angle1 ); + SetEndPt( epp, pos1, angle1 ); + } + if ( trackCmds(trk->type)->flip ) { trackCmds(trk->type)->flip( trk, orig, angle ); + } if ( QueryTrack( trk, Q_FLIP_ENDPTS ) ) { - endPt = trk->endPt[0]; - trk->endPt[0] = trk->endPt[1]; - trk->endPt[1] = endPt; + SwapEndPts( trk->endPt, 0, 1 ); } } -EXPORT EPINX_T GetNextTrk( - track_p trk1, - EPINX_T ep1, - track_p *Rtrk, - EPINX_T *Rep, - int mode ) +EXPORT EPINX_T GetNextTrk( + track_p trk1, + EPINX_T ep1, + track_p *Rtrk, + EPINX_T *Rep, + int mode ) { EPINX_T ep, epCnt = GetTrkEndPtCnt(trk1), epRet=-1; track_p trk; @@ -955,21 +879,25 @@ EXPORT EPINX_T GetNextTrk( *Rtrk = NULL; *Rep = 0; for (ep=0; ep<epCnt; ep++) { - if (ep==ep1) + if (ep==ep1) { continue; + } trk = GetTrkEndTrk( trk1, ep ); if (trk==NULL) { #ifdef LATER - if (isElev) + if (isElev) { epRet = ep; + } #endif continue; } if ( (mode&GNTignoreIgnore) && - ((trk1->endPt[ep].elev.option&ELEV_MASK)==ELEV_IGNORE)) + ((GetTrkEndElevMode(trk1,ep) == ELEV_IGNORE)) ) { continue; - if (*Rtrk != NULL) + } + if (*Rtrk != NULL) { return -1; + } *Rtrk = trk; *Rep = GetEndPtConnectedToMe( trk, trk1 ); epRet = ep; @@ -978,46 +906,51 @@ EXPORT EPINX_T GetNextTrk( } EXPORT BOOL_T MakeParallelTrack( - track_p trk, - coOrd pos, - DIST_T dist, - DIST_T factor, - track_p * newTrkR, - coOrd * p0R, - coOrd * p1R, - BOOL_T track) -{ - if ( trackCmds(trk->type)->makeParallel ) - return trackCmds(trk->type)->makeParallel( trk, pos, dist, factor, newTrkR, p0R, p1R, track); + track_p trk, + coOrd pos, + DIST_T dist, + DIST_T factor, + track_p * newTrkR, + coOrd * p0R, + coOrd * p1R, + BOOL_T track) +{ + if ( trackCmds(trk->type)->makeParallel ) { + return trackCmds(trk->type)->makeParallel( trk, pos, dist, factor, newTrkR, p0R, + p1R, track); + } return FALSE; } EXPORT BOOL_T RebuildTrackSegs( - track_p trk) + track_p trk) { - if (trackCmds(trk->type)->rebuildSegs) + if (trackCmds(trk->type)->rebuildSegs) { return trackCmds(trk->type)->rebuildSegs(trk); + } return FALSE; } EXPORT BOOL_T ReplayTrackData( - track_p trk, - void * data, - long length) + track_p trk, + void * data, + long length) { - if (trackCmds(trk->type)->replayData) - return trackCmds(trk->type)->replayData(trk,data,length); - return FALSE; + if (trackCmds(trk->type)->replayData) { + return trackCmds(trk->type)->replayData(trk,data,length); + } + return FALSE; } EXPORT BOOL_T StoreTrackData( - track_p trk, - void ** data, - long * length) + track_p trk, + void ** data, + long * length) { - if (trackCmds(trk->type)->storeData) + if (trackCmds(trk->type)->storeData) { return trackCmds(trk->type)->storeData(trk,data,length); - return FALSE; + } + return FALSE; } @@ -1029,19 +962,29 @@ EXPORT BOOL_T StoreTrackData( */ - EXPORT track_p to_first = NULL; - EXPORT TRKINX_T max_index = 0; EXPORT track_p * to_last = &to_first; +EXPORT track_p GetFirstTrack() +{ + return to_first; +} + +EXPORT track_p GetNextTrack( track_p trk ) +{ + return trk->next; +} + + + static struct { - track_p first; - track_p *last; - wIndex_t count; - wIndex_t changed; - TRKINX_T max_index; - } savedTrackState; + track_p first; + track_p *last; + wIndex_t count; + wIndex_t changed; + TRKINX_T max_index; +} savedTrackState; EXPORT void RenumberTracks( void ) @@ -1054,10 +997,10 @@ EXPORT void RenumberTracks( void ) } -EXPORT track_p NewTrack( TRKINX_T index, TRKTYP_T type, EPINX_T endCnt, CSIZE_T extraSize ) +EXPORT track_p NewTrack( TRKINX_T index, TRKTYP_T type, EPINX_T endCnt, + CSIZE_T extraSize ) { track_p trk; - EPINX_T ep; trk = (track_p ) MyMalloc( sizeof *trk ); *to_last = trk; to_last = &trk->next; @@ -1067,27 +1010,31 @@ EXPORT track_p NewTrack( TRKINX_T index, TRKTYP_T type, EPINX_T endCnt, CSIZE_T } else if (max_index < index) { max_index = index; } -LOG( log_track, 1, ( "NewTrack( T%d, t%d, E%d, X%ld)\n", index, type, endCnt, extraSize ) ) + LOG( log_track, 1, ( "NewTrack( T%d, t%d, E%d, X%ld)\n", index, type, endCnt, + extraSize ) ) trk->index = index; trk->type = type; trk->layer = curLayer; - trk->scale = (char)GetLayoutCurScale(); + trk->scale = (char)GetLayerScale(curLayer); // (char)GetLayoutCurScale(); trk->bits = TB_VISIBLE; trk->elevMode = ELEV_ALONE; trk->elev = 0; - trk->endCnt = endCnt; trk->hi.x = trk->hi.y = trk->lo.x = trk->lo.y = (float)0.0; + trk->endCnt = endCnt; if (endCnt) { - trk->endPt = (trkEndPt_p)MyMalloc( endCnt * sizeof *trk->endPt ); - for ( ep = 0; ep < endCnt; ep++ ) - trk->endPt[ep].index = -1; - } else + trk->endPt = (trkEndPt_p)MyMalloc( EndPtSize(endCnt) ); + for ( EPINX_T ep = 0; ep<endCnt; ep++ ) { + SetEndPtTrack( GetTrkEndPt( trk, ep ), NULL ); + } + } else { trk->endPt = NULL; + } if (extraSize) { trk->extraData = (struct extraDataBase_t*)MyMalloc( extraSize ); trk->extraData->trkType = type; - } else + } else { trk->extraData = NULL; + } trk->extraSize = extraSize; UndoNew( trk ); trackCount++; @@ -1101,10 +1048,12 @@ EXPORT void FreeTrack( track_p trk ) { bFreeTrack = TRUE; trackCmds(trk->type)->deleteTrk( trk ); - if (trk->endPt) + if (trk->endPt) { MyFree(trk->endPt); - if (trk->extraData) + } + if (trk->extraData) { MyFree(trk->extraData); + } MyFree(trk); bFreeTrack = FALSE; } @@ -1133,7 +1082,7 @@ EXPORT track_p FindTrack( TRKINX_T index ) { track_p trk; TRK_ITERATE(trk) { - if (trk->index == index) return trk; + if (trk->index == index) { return trk; } } return NULL; } @@ -1144,19 +1093,26 @@ EXPORT void ResolveIndex( void ) track_p trk; EPINX_T ep; TRK_ITERATE(trk) { - LOG (log_track, 1, ( "ResNextTrack( T%d, t%d, E%d, X%ld)\n", trk->index, trk->type, trk->endCnt, trk->extraSize )); - for (ep=0; ep<trk->endCnt; ep++) - if (trk->endPt[ep].index >= 0) { - trk->endPt[ep].track = FindTrack( trk->endPt[ep].index ); - if (trk->endPt[ep].track == NULL) { - int rc = NoticeMessage( MSG_RESOLV_INDEX_BAD_TRK, _("Continue"), _("Quit"), trk->index, ep, trk->endPt[ep].index ); - if ( rc != 1 ) + LOG (log_track, 1, ( "ResNextTrack( T%d, t%d, E%d, X%ld)\n", trk->index, + trk->type, trk->endCnt, trk->extraSize )); + for (ep=0; ep<trk->endCnt; ep++) { + trkEndPt_p epp = GetTrkEndPt( trk, ep ); + TRKINX_T index = GetEndPtIndex( epp ); + if (index >= 0) { + track_p track = FindTrack( index ); + if (track == NULL) { + int rc = NoticeMessage( MSG_RESOLV_INDEX_BAD_TRK, _("Continue"), _("Quit"), + trk->index, ep, index ); + if ( rc != 1 ) { return; + } } + SetEndPtTrack( epp, track ); } - ResolveBlockTrack (trk); - ResolveSwitchmotorTurnout (trk); - } + } + ResolveBlockTrack (trk); + ResolveSwitchmotorTurnout (trk); + } AuditTracks( "readTracks" ); } @@ -1165,11 +1121,13 @@ EXPORT BOOL_T DeleteTrack( track_p trk, BOOL_T all ) { EPINX_T i, ep2; track_p trk2; -LOG( log_track, 4, ( "DeleteTrack(T%d)\n", GetTrkIndex(trk) ) ) + LOG( log_track, 4, ( "DeleteTrack(T%d)\n", GetTrkIndex(trk) ) ) if (all) { if (!QueryTrack(trk,Q_CANNOT_BE_ON_END)) { - for (i=0;i<trk->endCnt;i++) { - if ((trk2=trk->endPt[i].track) != NULL) { + for (i=0; i<trk->endCnt; i++) { + trkEndPt_p epp = EndPtIndex( trk->endPt, i ); + trk2 = GetEndPtTrack(epp); + if (trk2 != NULL) { if (QueryTrack(trk2,Q_CANNOT_BE_ON_END)) { DeleteTrack( trk2, FALSE ); } @@ -1179,30 +1137,25 @@ LOG( log_track, 4, ( "DeleteTrack(T%d)\n", GetTrkIndex(trk) ) ) } /* If Car, simulate Remove Car -> uncouple and mark deleted (no Undo) */ if (QueryTrack(trk,Q_ISTRAIN)) { + UncoupleCars( trk, 0 ); + UncoupleCars( trk, 1 ); trk->deleted = TRUE; - int dir; - for (dir=0; dir<2; dir++) { - if (GetTrkEndTrk(trk,dir)) { - track_p car = GetTrkEndTrk(trk,dir); - for (int dir2=0;dir2<2; dir2++) { - if (car->endPt[dir2].track == trk) car->endPt[dir2].track = NULL; - } - trk->endPt[dir].track = NULL; - } - } + ClrTrkBits( trk, TB_SELECTED ); // Make sure we don't select a deleted car return TRUE; } - for (i=0;i<trk->endCnt;i++) { - if ((trk2=trk->endPt[i].track) != NULL) { + for (i=0; i<trk->endCnt; i++) { + trkEndPt_p epp = EndPtIndex( trk->endPt, i ); + if ((trk2=GetEndPtTrack(epp)) != NULL) { ep2 = GetEndPtConnectedToMe( trk2, trk ); DisconnectTracks( trk2, ep2, trk, i ); - if ( QueryTrack(trk,Q_CANNOT_BE_ON_END) ) + if ( QueryTrack(trk,Q_CANNOT_BE_ON_END) ) { UndoJoint( trk2, ep2, trk, i ); + } } } - CheckDeleteSwitchmotor( trk ); - CheckDeleteBlock( trk ); - CheckCarTraverse( trk ); + CheckDeleteSwitchmotor( trk ); + CheckDeleteBlock( trk ); + CheckCarTraverse( trk ); DecrementLayerObjects(trk->layer); trackCount--; AuditTracks( "deleteTrack T%d", trk->index); @@ -1242,18 +1195,27 @@ EXPORT void RestoreTrackState( void ) BOOL_T TrackIterate( track_p * trk ) { track_p trk1; - if (!*trk) + if (!*trk) { trk1 = to_first; - else + } else { trk1 = (*trk)->next; - while (trk1 && IsTrackDeleted(trk1)) + } + while (trk1 && IsTrackDeleted(trk1)) { trk1 = trk1->next; + } *trk = trk1; return trk1 != NULL; } -wBool_t IsPosClose( coOrd pos1, coOrd pos2 ) { +/***************************************************************************** +* +* REGRESSION +* +*/ + +wBool_t IsPosClose( coOrd pos1, coOrd pos2 ) +{ DIST_T d = FindDistance( pos1, pos2 ); return d < 0.1; } @@ -1262,8 +1224,9 @@ wBool_t IsPosClose( coOrd pos1, coOrd pos2 ) { wBool_t IsAngleClose( ANGLE_T angle1, ANGLE_T angle2 ) { ANGLE_T angle = NormalizeAngle( angle1 - angle2 ); - if (angle > 180) + if (angle > 180) { angle = 360-angle; + } return angle < 0.01; } @@ -1279,14 +1242,19 @@ wBool_t IsWidthClose( DIST_T dist1, DIST_T dist2 ) // width is computed by pixels/dpi // problem is when widths are computed on platforms with differing dpi DIST_T dist = fabs( dist1 - dist2 ); - if ( dist < 0.05 ) + if ( dist < 0.05 ) { return TRUE; -// TODO: This assumes the demo file was written with DPI=72 -// Note: BASE_DPI is 75 so we fudge on dist (was < 0.01) - dist1 *= mainD.dpi/BASE_DPI; + } +// This was using BASE_DPI(=75.0) based on ancient monitors. +// 96 DPI is more reasonable today +// TODO: review BASE_DPI with a plan to change it to 96.0 +// printf( "WidthClose %s:%d D2:%0.3f D1:%0.3f", paramFileName, paramLineNum, dist2, dist1 ); + dist1 *= mainD.dpi/96.0; dist = fabs( dist1 - dist2 ); - if ( dist < 0.05 ) +// printf( " -> %0.3f D:%0.3f\n", dist1, dist ); + if ( dist < 0.05 ) { return TRUE; + } return FALSE; } @@ -1304,17 +1272,17 @@ wBool_t IsColorClose( wDrawColor color1, wDrawColor color2 ) return (diff < 7); } -wBool_t CompareTrack( track_cp trk1, track_cp trk2 ) +static wBool_t CompareTrack( track_cp trk1, track_cp trk2 ) { - wBool_t rc = FALSE; +// wBool_t rc = FALSE; if ( trk1 == NULL ) { sprintf( message, "Compare: T%d not found\n", trk2->index ); return FALSE; } sprintf( message, "Compare T:%d - ", GetTrkIndex(trk1) ); char * cp = message+strlen(message); - REGRESS_CHECK_INT( "Type", trk1, trk2, type ) - REGRESS_CHECK_INT( "Index", trk1, trk2, index ) + REGRESS_CHECK_INT( "Type", trk1, trk2, type ) + REGRESS_CHECK_INT( "Index", trk1, trk2, index ) REGRESS_CHECK_INT( "Layer", trk1, trk2, layer ) REGRESS_CHECK_INT( "Scale", trk1, trk2, scale ) REGRESS_CHECK_INT( "EndPtCnt", trk1, trk2, endCnt ) @@ -1323,25 +1291,139 @@ wBool_t CompareTrack( track_cp trk1, track_cp trk2 ) cp = cq; sprintf( cp, "EP:%d - ", inx ); cp += strlen(cp); - REGRESS_CHECK_POS( "Pos", trk1, trk2, endPt[inx].pos ) - REGRESS_CHECK_ANGLE( "Angle", trk1, trk2, endPt[inx].angle ) - int inx1 = trk1->endPt[inx].index; - track_cp trk1x = GetTrkEndTrk( trk1, inx ); - if ( trk1x ) - inx1 = GetTrkIndex( trk1x ); - int inx2 = trk2->endPt[inx].index; - if ( inx1 != inx2 ) { - sprintf( cp, "Index: Actual` %d, Expected %d\n", inx1, inx2 ); + if ( ! CompareEndPt( cp, trk1, trk2, inx ) ) { return FALSE; } - REGRESS_CHECK_INT( "Option", trk1, trk2, endPt[inx].option ) } - if ( trackCmds( GetTrkType( trk1 ) )->compare == NULL ) + if ( trackCmds( GetTrkType( trk1 ) )->compare == NULL ) { return TRUE; + } return trackCmds( GetTrkType( trk1 ) )->compare( trk1, trk2 ); } - +EXPORT int CheckRegressionResult( long regressVersion,char * sFileName, + wBool_t bQuiet ) +{ + wBool_t bWroteActualTracks = FALSE; + int nFail = 0; + FILE * fRegression = NULL; + char * sRegressionFile = NULL; + track_p to_first_save = to_first; + track_p* to_last_save = to_last; + MakeFullpath( &sRegressionFile, workingDir, "xtrkcad.regress", NULL ); + + while ( GetNextLine() ) { + if ( paramLine[0] == '#' ) { + continue; + } + // Read Expected track + to_first = NULL; + to_last = &to_first; + paramVersion = regressVersion; + if ( !ReadTrack( paramLine ) ) { + if ( paramFile == NULL ) { + return -1; + } + break; + } + if ( to_first == NULL ) { + // Something bad happened + break; + } + track_cp tExpected = to_first; + to_first = to_first_save; + // Find corresponding Actual track + track_cp tActual = FindTrack( GetTrkIndex( tExpected ) ); + strcat( message, "Regression " ); + if ( ! CompareTrack( tActual, tExpected ) ) { + nFail++; + // Actual doesn't match Expected + lprintf( " FAIL: %s\n", message); + fRegression = fopen( sRegressionFile, "a" ); + if ( fRegression == NULL ) { + NoticeMessage( MSG_OPEN_FAIL, _("Continue"), NULL, _("Regression"), + sRegressionFile, strerror(errno) ); + break; + } + fprintf( fRegression, "REGRESSION FAIL %d\n", + PARAMVERSION ); + fprintf( fRegression, "# %s - %d\n", sFileName, paramLineNum ); + fprintf( fRegression, "# %s", message ); + if ( !bWroteActualTracks ) { + // Print Actual tracks + fprintf( fRegression, "Actual Tracks\n" ); + paramVersion = PARAMVERSION; + WriteTracks( fRegression, FALSE ); + bWroteActualTracks = TRUE; + } + // Print Expected track + to_first = tExpected; + fprintf( fRegression, "Expected Track\n" ); + WriteTracks( fRegression, FALSE ); + fclose( fRegression ); + strcat( message, "Continue test?" ); + if ( ! bQuiet ) { + int rc = wNoticeEx( NT_ERROR, message, _("Stop"), _("Continue") ); + if ( !rc ) { + while ( GetNextLine() && + strncmp( paramLine, "REGRESSION END", 14 ) != 0 ) + ; + break; + } + } + } + // Delete Expected track + to_first = tExpected; + to_last = &to_first; + FreeTrack( tExpected ); + } + to_first = to_first_save; + to_last = to_last_save; + if ( strncmp( paramLine, "REGRESSION END", 14 ) != 0 ) { + InputError( "Expected REGRESSION END", TRUE ); + } + return nFail; +} + + +/***************************************************************************** +* +* LAYER +* +*/ + +/** + * @brief Add 1 to track layer numbers that are greater than or equal to New Layer + * @param newLayer +*/ +EXPORT void TrackInsertLayer( int newLayer ) +{ + track_p trk; + + TRK_ITERATE( trk ) { + int layer = GetTrkLayer(trk); + if (layer >= newLayer) { + SetTrkLayer(trk, layer + 1); + } + } +} + +/** +* @brief Subtract 1 from track layer numbers that are greater than Removed Layer +* @param removeLayer +*/ +EXPORT void TrackDeleteLayer( int removeLayer ) +{ + track_p trk; + + TRK_ITERATE( trk ) { + int layer = GetTrkLayer(trk); + if (layer > removeLayer) { + SetTrkLayer(trk, layer - 1); + } + } +} + /***************************************************************************** * * ABOVE / BELOW @@ -1357,7 +1439,7 @@ static void ExciseSelectedTracks( track_p * pxtrk, track_p * pltrk ) ptrk = &(*ptrk)->next; continue; } - ASSERT( !IsTrackDeleted(trk) ); + CHECK( !IsTrackDeleted(trk) ); UndoModify( *ptrk ); UndoModify( trk ); *ptrk = trk->next; @@ -1384,7 +1466,7 @@ EXPORT void SelectAbove( void * unused ) to_last = <rk->next; } UndoEnd(); - DrawSelectedTracks( &mainD ); + DrawSelectedTracks( &mainD, false ); } @@ -1405,14 +1487,18 @@ EXPORT void SelectBelow( void * unused ) GetBoundingBox( trk, &highest, &lowest ); } else { GetBoundingBox( trk, &hi, &lo ); - if (highest.x < hi.x) + if (highest.x < hi.x) { highest.x = hi.x; - if (highest.y < hi.y) + } + if (highest.y < hi.y) { highest.y = hi.y; - if (lowest.x > lo.x) + } + if (lowest.x > lo.x) { lowest.x = lo.x; - if (lowest.y > lo.y) + } + if (lowest.y > lo.y) { lowest.y = lo.y; + } } ClrTrkBits( trk, TB_SELECTED ); } @@ -1426,15 +1512,15 @@ EXPORT void SelectBelow( void * unused ) } -#include "bitmaps/top.xpm" -#include "bitmaps/bottom.xpm" +#include "bitmaps/top.xpm3" +#include "bitmaps/bottom.xpm3" EXPORT void InitCmdAboveBelow( void ) { wIcon_p bm_p; - bm_p = wIconCreatePixMap( top_xpm[iconSize] ); + bm_p = wIconCreatePixMap( top_xpm3[iconSize] ); AddToolbarButton( "cmdAbove", bm_p, IC_SELECTED|IC_POPUP, SelectAbove, NULL ); - bm_p = wIconCreatePixMap( bottom_xpm[iconSize] ); + bm_p = wIconCreatePixMap( bottom_xpm3[iconSize] ); AddToolbarButton( "cmdBelow", bm_p, IC_SELECTED|IC_POPUP, SelectBelow, NULL ); } @@ -1465,38 +1551,40 @@ EXPORT BOOL_T ReadTrack( char * line ) return TRUE; } -if (bsearchRead) { - if (sortedCmds == NULL) { - sortedCmds = (trackCmd_t**)MyMalloc( (trackCmds_da.cnt-1) * sizeof *(trackCmd_t*)0 ); - for (inx=1; inx<trackCmds_da.cnt; inx++) - sortedCmds[inx-1] = trackCmds(inx); - qsort( sortedCmds, trackCmds_da.cnt-1, sizeof *(trackCmd_t**)0, CompareCmds ); - } - - lo = 0; - hi = trackCmds_da.cnt-2; - do { - inx = (lo+hi)/2; - cmp = strncmp( line, sortedCmds[inx]->name, strlen(sortedCmds[inx]->name) ); - if (cmp == 0) { - return sortedCmds[inx]->read(line); - } else if (cmp < 0) { - hi = inx-1; - } else { - lo = inx+1; - } - } while ( lo <= hi ); -} else { - for (inx=1; inx<trackCmds_da.cnt; inx++) { - if (strncmp( line, trackCmds(inx)->name, strlen(trackCmds(inx)->name) ) == 0 ) { - trackCmds(inx)->read( line ); - // Return TRUE means we found the object type and processed it - // Any errors will be handled by the callee's: - // Either skip the definition (ReadSegs) or skip the remainder of the file (InputError) - return TRUE; - } + if (bsearchRead) { + if (sortedCmds == NULL) { + sortedCmds = (trackCmd_t**)MyMalloc( (trackCmds_da.cnt-1) * sizeof * + (trackCmd_t*)0 ); + for (inx=1; inx<trackCmds_da.cnt; inx++) { + sortedCmds[inx-1] = trackCmds(inx); + } + qsort( sortedCmds, trackCmds_da.cnt-1, sizeof *(trackCmd_t**)0, CompareCmds ); + } + + lo = 0; + hi = trackCmds_da.cnt-2; + do { + inx = (lo+hi)/2; + cmp = strncmp( line, sortedCmds[inx]->name, strlen(sortedCmds[inx]->name) ); + if (cmp == 0) { + return sortedCmds[inx]->read(line); + } else if (cmp < 0) { + hi = inx-1; + } else { + lo = inx+1; + } + } while ( lo <= hi ); + } else { + for (inx=1; inx<trackCmds_da.cnt; inx++) { + if (strncmp( line, trackCmds(inx)->name, strlen(trackCmds(inx)->name) ) == 0 ) { + trackCmds(inx)->read( line ); + // Return TRUE means we found the object type and processed it + // Any errors will be handled by the callee's: + // Either skip the definition (ReadSegs) or skip the remainder of the file (InputError) + return TRUE; + } + } } -} // Object type not found return FALSE; } @@ -1506,16 +1594,19 @@ EXPORT BOOL_T WriteTracks( FILE * f, wBool_t bFull ) { track_p trk; BOOL_T rc = TRUE; - if ( bFull ) + if ( bFull ) { RenumberTracks(); - if ( !bFull ) + } + if ( !bFull ) { bWriteEndPtDirectIndex = TRUE; + } TRK_ITERATE( trk ) { rc &= trackCmds(GetTrkType(trk))->write( trk, f ); } bWriteEndPtDirectIndex = FALSE; - if ( bFull ) + if ( bFull ) { rc &= WriteCars( f ); + } return rc; } @@ -1547,7 +1638,7 @@ EXPORT void ImportEnd( coOrd offset, wBool_t import, wBool_t inPlace ) // get the current mouse position GetMousePosition( &x, &y ); mainD.Pix2CoOrd( &mainD, x, y, &pos ); - + // get the size of the drawing area wDrawGetSize( mainD.d, &ww, &hh ); @@ -1562,11 +1653,11 @@ EXPORT void ImportEnd( coOrd offset, wBool_t import, wBool_t inPlace ) for ( trk=*importTrack; trk; trk=trk->next ) { - ASSERT(!IsTrackDeleted(trk)); // Export ignores deleted tracks - if (trk->hi.y > ymax ) ymax = trk->hi.y; - if (trk->lo.y < ymin ) ymin = trk->lo.y; - if (trk->hi.x > xmax ) xmax = trk->hi.x; - if (trk->lo.x < xmin ) xmin = trk->lo.x; + CHECK(!IsTrackDeleted(trk)); // Export ignores deleted tracks + if (trk->hi.y > ymax ) { ymax = trk->hi.y; } + if (trk->lo.y < ymin ) { ymin = trk->lo.y; } + if (trk->hi.x > xmax ) { xmax = trk->hi.x; } + if (trk->lo.x < xmin ) { xmin = trk->lo.x; } } coOrd size = {xmax-xmin,ymax-ymin}; @@ -1593,7 +1684,7 @@ EXPORT void ImportEnd( coOrd offset, wBool_t import, wBool_t inPlace ) wDrawPix_t ox,oy; mainD.CoOrd2Pix( &mainD, middle_object, &ox, &oy ); - if ((ox<0) || (ox>ww) || (oy<0) || (oy>hh) ) offscreen = TRUE; + if ((ox<0) || (ox>ww) || (oy<0) || (oy>hh) ) { offscreen = TRUE; } to_firstOld = to_first; to_first = *importTrack; @@ -1604,7 +1695,7 @@ EXPORT void ImportEnd( coOrd offset, wBool_t import, wBool_t inPlace ) // move the imported track into place for ( trk=*importTrack; trk; trk=trk->next ) { - ASSERT( !IsTrackDeleted(trk) ); + CHECK( !IsTrackDeleted(trk) ); coOrd move; move.x = offset.x; move.y = offset.y; @@ -1612,7 +1703,7 @@ EXPORT void ImportEnd( coOrd offset, wBool_t import, wBool_t inPlace ) trk->bits |= TB_SELECTED; DrawTrack( trk, &mainD, wDrawColorBlack ); } - importTrack = NULL; + importTrack = NULL; trackCount = trackCountOld; InfoCount( trackCount ); // Pan screen if needed to center of new @@ -1625,21 +1716,23 @@ EXPORT void ImportEnd( coOrd offset, wBool_t import, wBool_t inPlace ) /******* * Move Selected Tracks to origin zero and write out *******/ -EXPORT BOOL_T ExportTracks( FILE * f, coOrd * offset) +EXPORT BOOL_T ExportTracks( FILE * f, coOrd * offset ) { track_p trk; coOrd xlat,orig; - - exportingTracks = TRUE; + + bWriteEndPtExporting = TRUE; orig = mapD.size; max_index = 0; TRK_ITERATE(trk) { if ( GetTrkSelected(trk) ) { - if (QueryTrack(trk,Q_ISTRAIN)) continue; //Don't bother with CARs - if (trk->lo.x < orig.x) + if (QueryTrack(trk,Q_ISTRAIN)) { continue; } //Don't bother with CARs + if (trk->lo.x < orig.x) { orig.x = trk->lo.x; - if (trk->lo.y < orig.y) + } + if (trk->lo.y < orig.y) { orig.y = trk->lo.y; + } trk->index = ++max_index; } } @@ -1650,14 +1743,14 @@ EXPORT BOOL_T ExportTracks( FILE * f, coOrd * offset) xlat.y = - orig.y; TRK_ITERATE( trk ) { if ( GetTrkSelected(trk) ) { - if (QueryTrack(trk,Q_ISTRAIN)) continue; //Don't bother with CARs + if (QueryTrack(trk,Q_ISTRAIN)) { continue; } //Don't bother with CARs MoveTrack( trk, xlat ); trackCmds(GetTrkType(trk))->write( trk, f ); MoveTrack( trk, orig ); } } RenumberTracks(); - exportingTracks = FALSE; + bWriteEndPtExporting = FALSE; return TRUE; } @@ -1689,7 +1782,8 @@ static void AuditPrint( char * msg ) auditFile = fopen( path, "a+" ); free(path); if (auditFile == NULL) { - NoticeMessage( MSG_OPEN_FAIL, _("Continue"), NULL, _("Audit"), message, strerror(errno) ); + NoticeMessage( MSG_OPEN_FAIL, _("Continue"), NULL, _("Audit"), message, + strerror(errno) ); auditIgnore = TRUE; return; } @@ -1701,12 +1795,14 @@ static void AuditPrint( char * msg ) } fprintf(auditFile, "# " ); fprintf(auditFile, "%s", msg ); - if (auditIgnore) + if (auditIgnore) { return; + } NoticeMessage( MSG_AUDIT_PRINT_MSG, _("Ok"), NULL, msg ); if (++auditCount>10) { - if (NoticeMessage( MSG_AUDIT_PRINT_IGNORE, _("Yes"), _("No") ) ) + if (NoticeMessage( MSG_AUDIT_PRINT_IGNORE, _("Yes"), _("No") ) ) { auditIgnore = TRUE; + } auditCount = 0; } } @@ -1715,7 +1811,7 @@ static void AuditPrint( char * msg ) EXPORT void CheckTrackLength( track_cp trk ) { DIST_T dist; - + if (trackCmds(trk->type)->getLength) { dist = trackCmds(trk->type)->getLength( trk ); } else { @@ -1745,7 +1841,7 @@ EXPORT void AuditTracks( char * event, ... ) *msgp++ = '\n'; trackCount = 0; - for (i=0;i<sizeof used;i++) { + for (i=0; i<sizeof used; i++) { used[i] = 0; } if (*to_last) { @@ -1764,8 +1860,9 @@ EXPORT void AuditTracks( char * event, ... ) AuditPrint( msg ); } if ((auditCmd = trackCmds( trk->type )->audit) != NULL) { - if (!auditCmd( trk, msgp )) + if (!auditCmd( trk, msgp )) { AuditPrint( msg ); + } } if (trk->index < 8*sizeof used) { if (BIT_SET(used,trk->index)) { @@ -1775,18 +1872,21 @@ EXPORT void AuditTracks( char * event, ... ) SET_BIT(used, trk->index); } for (i=0; i<trk->endCnt; i++) { - if ( (tn = trk->endPt[i].track) != NULL ) { + trkEndPt_p epp = EndPtIndex( trk->endPt, i ); + if ( (tn = GetEndPtTrack(epp)) != NULL ) { if (IsTrackDeleted(tn)) { sprintf( msgp, "T%d[%d]: T%d is deleted\n", trk->index, i, tn->index ); AuditPrint( msg ); - trk->endPt[i].track = NULL; + SetEndPtTrack( epp, NULL ); } else { - for (j=0;j<tn->endCnt;j++) - if (tn->endPt[j].track == trk) + for (j=0; j<tn->endCnt; j++) { + if (GetEndPtTrack( EndPtIndex( tn->endPt, j ) ) == trk) { goto nextEndPt; + } + } sprintf( msgp, "T%d[%d]: T%d doesn\'t point back\n", trk->index, i, tn->index ); AuditPrint( msg ); - trk->endPt[i].track = NULL; + SetEndPtTrack( epp, NULL ); } } nextEndPt:; @@ -1794,28 +1894,29 @@ nextEndPt:; if (!trk->next) { if (to_last != &trk->next) { sprintf( msgp, "last track (T%d @ "SLOG_FMT") is not to_last ("SLOG_FMT")\n", - trk->index, (uintptr_t)trk, (uintptr_t)to_last ); + trk->index, (uintptr_t)trk, (uintptr_t)to_last ); AuditPrint( msg ); } } } InfoCount( trackCount ); if (auditFile != NULL) { - if (auditStop) - if (NoticeMessage( MSG_AUDIT_WRITE_FILE, _("Yes"), _("No"))) { - fprintf( auditFile, "# before undo\n" ); - WriteTracks(auditFile, TRUE); - Rdump( auditFile ); - if (strcmp("undoUndo",event)==0) { - fprintf( auditFile, "# failure in undo\n" ); - } else { - UndoUndo( NULL ); - if ( undoStatus ) { - fprintf( auditFile, "# after undo\n" ); - WriteTracks(auditFile, TRUE); - Rdump( auditFile ); + if (auditStop) { + if (NoticeMessage( MSG_AUDIT_WRITE_FILE, _("Yes"), _("No"))) { + fprintf( auditFile, "# before undo\n" ); + WriteTracks(auditFile, TRUE); + Rdump( auditFile ); + if (strcmp("undoUndo",event)==0) { + fprintf( auditFile, "# failure in undo\n" ); } else { - fprintf( auditFile, "# undo stack is empty\n" ); + UndoUndo( NULL ); + if ( undoStatus ) { + fprintf( auditFile, "# after undo\n" ); + WriteTracks(auditFile, TRUE); + Rdump( auditFile ); + } else { + fprintf( auditFile, "# undo stack is empty\n" ); + } } } } @@ -1842,100 +1943,26 @@ EXPORT void ComputeBoundingBox( track_p trk ) { EPINX_T i; - if (trk->endCnt <= 0) - AbortProg("computeBoundingBox - endCnt<=0"); + CHECK( trk->endCnt > 0 ); - trk->hi.x = trk->lo.x = (float)trk->endPt[0].pos.x; - trk->hi.y = trk->lo.y = (float)trk->endPt[0].pos.y; + coOrd pos = GetEndPtPos( trk->endPt ); + trk->hi.x = trk->lo.x = (float)pos.x; + trk->hi.y = trk->lo.y = (float)pos.y; for ( i=1; i<trk->endCnt; i++ ) { - if (trk->endPt[i].pos.x > trk->hi.x) - trk->hi.x = (float)trk->endPt[i].pos.x; - if (trk->endPt[i].pos.y > trk->hi.y) - trk->hi.y = (float)trk->endPt[i].pos.y; - if (trk->endPt[i].pos.x < trk->lo.x) - trk->lo.x = (float)trk->endPt[i].pos.x; - if (trk->endPt[i].pos.y < trk->lo.y) - trk->lo.y = (float)trk->endPt[i].pos.y; - } -} - - - -EXPORT DIST_T EndPtDescriptionDistance( - coOrd pos, - track_p trk, - EPINX_T ep, - coOrd *dpos, - BOOL_T show_hidden, - BOOL_T * hidden) -{ - elev_t *e; - coOrd pos1; - track_p trk1; - *dpos = pos; - if (hidden) *hidden = FALSE; - e = &trk->endPt[ep].elev; - if ((e->option&ELEV_MASK)==ELEV_NONE) - return DIST_INF; - if (((e->option&ELEV_VISIBLE)==0) && !show_hidden) - return DIST_INF; - if ((trk1=GetTrkEndTrk(trk,ep)) && GetTrkIndex(trk1)<GetTrkIndex(trk)) - return DIST_INF; - if ((e->option&ELEV_VISIBLE)==0) { //Hidden - disregard offset - if (hidden) *hidden = TRUE; - return FindDistance( GetTrkEndPos(trk,ep), pos ); - } - /*REORIGIN( pos1, e->doff, GetTrkEndPos(trk,ep), GetTrkEndAngle(trk,ep) );*/ - pos1 = GetTrkEndPos(trk,ep); - coOrd tpos = pos1; - pos1.x += e->doff.x; - pos1.y += e->doff.y; - *dpos = pos1; - if (hidden) *hidden = !(e->option&ELEV_VISIBLE); - if (FindDistance(tpos,pos)<FindDistance( pos1, pos )) - return FindDistance(tpos,pos); - return FindDistance( pos1, pos ); -} - - -EXPORT STATUS_T EndPtDescriptionMove( - track_p trk, - EPINX_T ep, - wAction_t action, - coOrd pos ) -{ - static coOrd p0, p1; - elev_t *e, *e1; - track_p trk1; - - e = &trk->endPt[ep].elev; - switch (action) { - case C_DOWN: - p0 = GetTrkEndPos(trk,ep); - p1 = pos; - e->option |= ELEV_VISIBLE; //Make sure we make visible - DrawEndElev( &mainD, trk, ep, wDrawColorWhite ); - /*no break*/ - case C_MOVE: - case C_UP: - p1 = pos; - e->doff.x = (pos.x-p0.x); - e->doff.y = (pos.y-p0.y); - if ((trk1=GetTrkEndTrk(trk,ep))) { - e1 = &trk1->endPt[GetEndPtConnectedToMe(trk1,trk)].elev; - e1->doff = e->doff; + pos = GetEndPtPos( EndPtIndex( trk->endPt, i ) ); + if (pos.x > trk->hi.x) { + trk->hi.x = (float)pos.x; } - if ( action == C_UP ) { - wDrawColor color = GetTrkColor( trk, &mainD ); - DrawEndElev( &mainD, trk, ep, color ); + if (pos.y > trk->hi.y) { + trk->hi.y = (float)pos.y; + } + if (pos.x < trk->lo.x) { + trk->lo.x = (float)pos.x; + } + if (pos.y < trk->lo.y) { + trk->lo.y = (float)pos.y; } - return action==C_UP?C_TERMINATE:C_CONTINUE; - - case C_REDRAW: - DrawEndElev( &tempD, trk, ep, drawColorPreviewSelected ); - break; } - return C_CONTINUE; } @@ -1946,119 +1973,118 @@ EXPORT STATUS_T EndPtDescriptionMove( */ -static DIST_T distanceEpsilon = 0.0; -static ANGLE_T angleEpsilon = 0.0; +//static DIST_T distanceEpsilon = 0.0; +//static ANGLE_T angleEpsilon = 0.0; -EXPORT void LoosenTracks( void * unused ) +EXPORT int ConnectTracks( track_p trk0, EPINX_T inx0, track_p trk1, + EPINX_T inx1 ) { - track_p trk, trk1; - EPINX_T ep0, ep1; - ANGLE_T angle0, angle1; - coOrd pos0, pos1; DIST_T d; ANGLE_T a; - int count; + coOrd pos0, pos1; + trkEndPt_p epp0 = EndPtIndex( trk0->endPt, inx0 ); + trkEndPt_p epp1 = EndPtIndex( trk1->endPt, inx1 ); - count = 0; - TRK_ITERATE(trk) { - for (ep0=0; ep0<trk->endCnt; ep0++) { - trk1 = GetTrkEndTrk( trk, ep0 ); - if (trk1 == NULL) - continue; - ASSERT( !IsTrackDeleted(trk1) ); - ep1 = GetEndPtConnectedToMe( trk1, trk ); - if (ep1 < 0) - continue; - pos0 = GetTrkEndPos( trk, ep0 ); - pos1 = GetTrkEndPos( trk1, ep1 ); - angle0 = GetTrkEndAngle( trk, ep0 ); - angle1 = GetTrkEndAngle( trk1, ep1 ); - d = FindDistance( pos0, pos1 ); - a = NormalizeAngle( 180+angle0-angle1+angleEpsilon ); - if (d > distanceEpsilon || a > angleEpsilon*2.0) { - DisconnectTracks( trk, ep0, trk1, ep1 ); - count++; - InfoMessage( _("%d Track(s) loosened"), count ); - } + if (QueryTrack(trk0,Q_ISTRAIN)) { + if (!QueryTrack(trk1,Q_ISTRAIN)) { + NoticeMessage( _("Connecting a car to a non-car T%d T%d"), _("Continue"), NULL, + GetTrkIndex(trk0), GetTrkIndex(trk1) ); + return -1; } + SetEndPtTrack( epp0, trk1 ); + SetEndPtTrack( epp1, trk0 ); + return 0; } - if (count) - MainRedraw(); // LoosenTracks - else - InfoMessage(_("No tracks loosened")); -} - -EXPORT int ConnectTracks( track_p trk0, EPINX_T inx0, track_p trk1, EPINX_T inx1 ) -{ - DIST_T d; - ANGLE_T a; - coOrd pos0, pos1; if ( !IsTrack(trk0) ) { - NoticeMessage( _("Connecting a non-track(%d) to (%d)"), _("Continue"), NULL, GetTrkIndex(trk0), GetTrkIndex(trk1) ); + NoticeMessage( _("Connecting a non-track(%d) to (%d)"), _("Continue"), NULL, + GetTrkIndex(trk0), GetTrkIndex(trk1) ); return -1; } if ( !IsTrack(trk1) ) { - NoticeMessage( _("Connecting a non-track(%d) to (%d)"), _("Continue"), NULL, GetTrkIndex(trk1), GetTrkIndex(trk0) ); + NoticeMessage( _("Connecting a non-track(%d) to (%d)"), _("Continue"), NULL, + GetTrkIndex(trk1), GetTrkIndex(trk0) ); return -1; } - pos0 = trk0->endPt[inx0].pos; - pos1 = trk1->endPt[inx1].pos; -LOG( log_track, 3, ( "ConnectTracks( T%d[%d] @ [%0.3f, %0.3f] = T%d[%d] @ [%0.3f %0.3f]\n", trk0->index, inx0, pos0.x, pos0.y, trk1->index, inx1, pos1.x, pos1.y ) ) + pos0 = GetEndPtPos( epp0 ); + pos1 = GetEndPtPos( epp1 ); + LOG( log_track, 3, + ( "ConnectTracks( T%d[%d] @ [%0.3f, %0.3f] = T%d[%d] @ [%0.3f %0.3f]\n", + trk0->index, inx0, pos0.x, pos0.y, trk1->index, inx1, pos1.x, pos1.y ) ) d = FindDistance( pos0, pos1 ); - a = fabs(DifferenceBetweenAngles( trk0->endPt[inx0].angle, - trk1->endPt[inx1].angle + 180.0 )); + a = fabs(DifferenceBetweenAngles( GetEndPtAngle(epp0), + GetEndPtAngle(epp1) + 180.0 )); if (d > connectDistance || (a > connectAngle ) ) { LOG( log_endPt, 1, ( "connectTracks: T%d[%d] T%d[%d] d=%0.3f a=%0.3f\n", - trk0->index, inx0, trk1->index, inx1, d, a ) ); - NoticeMessage( MSG_CONNECT_TRK, _("Continue"), NULL, trk0->index, inx0, trk1->index, inx1, d, a ); + trk0->index, inx0, trk1->index, inx1, d, a ) ); + NoticeMessage( MSG_CONNECT_TRK, _("Continue"), NULL, trk0->index, inx0, + trk1->index, inx1, d, a ); return -1; /* Stop connecting out of alignment tracks! */ } UndoModify( trk0 ); UndoModify( trk1 ); - if (!suspendElevUpdates) + if (!suspendElevUpdates) { SetTrkElevModes( TRUE, trk0, inx0, trk1, inx1 ); - trk0->endPt[inx0].track = trk1; - trk1->endPt[inx1].track = trk0; - AuditTracks( "connectTracks T%d[%d], T%d[%d]", trk0->index, inx0, trk1->index, inx1 ); + } + SetEndPtTrack( epp0, trk1 ); + SetEndPtTrack( epp1, trk0 ); + AuditTracks( "connectTracks T%d[%d], T%d[%d]", trk0->index, inx0, trk1->index, + inx1 ); return 0; } -EXPORT void DisconnectTracks( track_p trk1, EPINX_T ep1, track_p trk2, EPINX_T ep2 ) +EXPORT void DisconnectTracks( track_p trk1, EPINX_T ep1, track_p trk2, + EPINX_T ep2 ) { - if (trk1->endPt[ep1].track != trk2 || - trk2->endPt[ep2].track != trk1 ) - AbortProg("disconnectTracks: tracks not connected" ); + trkEndPt_p epp1 = EndPtIndex( trk1->endPt, ep1 ); + trkEndPt_p epp2 = EndPtIndex( trk2->endPt, ep2 ); + // Check tracks are connected + CHECK( GetEndPtTrack(epp1) == trk2 ); + CHECK( GetEndPtTrack(epp2) == trk1 ); + if (QueryTrack(trk1,Q_ISTRAIN)) { + if (!QueryTrack(trk2,Q_ISTRAIN)) { + NoticeMessage( _("Disconnecting a car from a non-car T%d T%d"), _("Continue"), + NULL, GetTrkIndex(trk1), GetTrkIndex(trk2) ); + return; + } + SetEndPtTrack( epp1, NULL ); + SetEndPtTrack( epp2, NULL ); + return; + } + UndoModify( trk1 ); UndoModify( trk2 ); - trk1->endPt[ep1].track = NULL; - trk2->endPt[ep2].track = NULL; - if (!suspendElevUpdates) + SetEndPtTrack( epp1, NULL ); + SetEndPtTrack( epp2, NULL ); + if (!suspendElevUpdates) { SetTrkElevModes( FALSE, trk1, ep1, trk2, ep2 ); + } } EXPORT BOOL_T ConnectAbuttingTracks( - track_p trk0, - EPINX_T ep0, - track_p trk1, - EPINX_T ep1 ) + track_p trk0, + EPINX_T ep0, + track_p trk1, + EPINX_T ep1 ) { DIST_T d; ANGLE_T a; d = FindDistance( GetTrkEndPos(trk0,ep0), - GetTrkEndPos(trk1,ep1 ) ); + GetTrkEndPos(trk1,ep1 ) ); a = NormalizeAngle( GetTrkEndAngle(trk0,ep0) - - GetTrkEndAngle(trk1,ep1) + - (180.0+connectAngle/2.0) ); - if ( a < connectAngle && - d < connectDistance ) { - UndoStart( _("Join Abutting Tracks"), "ConnectAbuttingTracks( T%d[%d] T%d[%d] )", GetTrkIndex(trk0), ep0, GetTrkIndex(trk1), ep1 ); + GetTrkEndAngle(trk1,ep1) + + (180.0+connectAngle/2.0) ); + if ( a < connectAngle && + d < connectDistance ) { + UndoStart( _("Join Abutting Tracks"), + "ConnectAbuttingTracks( T%d[%d] T%d[%d] )", GetTrkIndex(trk0), ep0, + GetTrkIndex(trk1), ep1 ); DrawEndPt( &mainD, trk0, ep0, wDrawColorWhite ); DrawEndPt( &mainD, trk1, ep1, wDrawColorWhite ); ConnectTracks( trk0, ep0, - trk1, ep1 ); + trk1, ep1 ); DrawEndPt( &mainD, trk0, ep0, wDrawColorBlack ); DrawEndPt( &mainD, trk1, ep1, wDrawColorBlack ); UndoEnd(); @@ -2068,20 +2094,22 @@ EXPORT BOOL_T ConnectAbuttingTracks( } -EXPORT ANGLE_T GetAngleAtPoint( track_p trk, coOrd pos, EPINX_T *ep0, EPINX_T *ep1 ) +EXPORT ANGLE_T GetAngleAtPoint( track_p trk, coOrd pos, EPINX_T *ep0, + EPINX_T *ep1 ) { ANGLE_T (*getAngleCmd)( track_p, coOrd, EPINX_T *, EPINX_T * ); - if ((getAngleCmd = trackCmds(trk->type)->getAngle) != NULL) + if ((getAngleCmd = trackCmds(trk->type)->getAngle) != NULL) { return getAngleCmd( trk, pos, ep0, ep1 ); - else { + } else { NoticeMessage( MSG_GAAP_BAD_TYPE, _("Continue"), NULL, trk->type, trk->index ); return 0; } } -EXPORT BOOL_T SplitTrack( track_p trk, coOrd pos, EPINX_T ep, track_p *leftover, BOOL_T disconnect ) +EXPORT BOOL_T SplitTrack( track_p trk, coOrd pos, EPINX_T ep, track_p *leftover, + BOOL_T disconnect ) { DIST_T d; track_p trk0, trk2, trkl; @@ -2091,9 +2119,9 @@ EXPORT BOOL_T SplitTrack( track_p trk, coOrd pos, EPINX_T ep, track_p *leftover, coOrd pos0; if (!IsTrack(trk)) { - if ((splitCmd = trackCmds(trk->type)->split) == NULL) return FALSE; + if ((splitCmd = trackCmds(trk->type)->split) == NULL) { return FALSE; } UndrawNewTrack( trk ); - UndoModify( trk ); + UndoModify( trk ); rc = splitCmd( trk, pos, ep, leftover, &epl, &ep1 ); if (*leftover) { SetTrkLayer(*leftover,GetTrkLayer( trk )); @@ -2107,24 +2135,28 @@ EXPORT BOOL_T SplitTrack( track_p trk, coOrd pos, EPINX_T ep, track_p *leftover, epl = ep; epCnt = GetTrkEndPtCnt(trk); *leftover = NULL; -LOG( log_track, 2, ( "SplitTrack( T%d[%d], (%0.3f %0.3f)\n", trk->index, ep, pos.x, pos.y ) ) + LOG( log_track, 2, ( "SplitTrack( T%d[%d], (%0.3f %0.3f)\n", trk->index, ep, + pos.x, pos.y ) ) + trkEndPt_p epp = EndPtIndex( trk->endPt, ep ); + pos0 = GetEndPtPos( epp ); if (((splitCmd = trackCmds(trk->type)->split) == NULL)) { - if (!(FindDistance( trk->endPt[ep].pos, pos) <= minLength)) { - ErrorMessage( MSG_CANT_SPLIT_TRK, trackCmds(trk->type)->name ); + if (!(FindDistance( pos0, pos) <= minLength)) { + ErrorMessage(MSG_SPLITTED_OBJECT_TOO_SHORT, PutDim(fabs(minLength))); return FALSE; } } UndrawNewTrack( trk ); UndoModify( trk ); - pos0 = trk->endPt[ep].pos; if ((d = FindDistance( pos0, pos )) <= minLength) { /* easy: just disconnect */ - if ((trk2=trk->endPt[ep].track) != NULL) { + trk2 = GetEndPtTrack(epp); + if (trk2 != NULL) { UndrawNewTrack( trk2 ); ep2 = GetEndPtConnectedToMe( trk2, trk ); - if (ep2 < 0) + if (ep2 < 0) { return FALSE; + } DisconnectTracks( trk, ep, trk2, ep2 ); LOG( log_track, 2, ( " at endPt with T%d[%d]\n", trk2->index, ep2 ) ) DrawNewTrack( trk2 ); @@ -2135,13 +2167,15 @@ LOG( log_track, 2, ( "SplitTrack( T%d[%d], (%0.3f %0.3f)\n", trk->index, ep, pos } else if ( epCnt == 2 && - (d = FindDistance( trk->endPt[1-ep].pos, pos )) <= minLength) { + (d = FindDistance( GetEndPtPos(EndPtIndex(trk->endPt,1-ep)), + pos )) <= minLength) { /* easy: just disconnect */ - if ((trk2=trk->endPt[1-ep].track) != NULL) { + if ((trk2=GetEndPtTrack(EndPtIndex(trk->endPt,1-ep))) != NULL) { UndrawNewTrack( trk2 ); ep2 = GetEndPtConnectedToMe( trk2, trk ); - if (ep2 < 0) + if (ep2 < 0) { return FALSE; + } DisconnectTracks( trk, 1-ep, trk2, ep2 ); LOG( log_track, 2, ( " at endPt with T%d[%d]\n", trk2->index, ep2 ) ) DrawNewTrack( trk2 ); @@ -2154,16 +2188,18 @@ LOG( log_track, 2, ( "SplitTrack( T%d[%d], (%0.3f %0.3f)\n", trk->index, ep, pos } else { /* TODO circle's don't have ep's */ trk2 = GetTrkEndTrk( trk, ep ); - if ( !disconnect ) + if ( !disconnect ) { suspendElevUpdates = TRUE; + } if (trk2 != NULL) { ep2 = GetEndPtConnectedToMe( trk2, trk ); DisconnectTracks( trk, ep, trk2, ep2 ); } rc = splitCmd( trk, pos, ep, leftover, &epl, &ep1 ); if (!rc) { - if ( trk2 != NULL ) + if ( trk2 != NULL ) { ConnectTracks( trk, ep, trk2, ep2 ); + } suspendElevUpdates = FALSE; DrawNewTrack( trk ); return FALSE; @@ -2172,20 +2208,23 @@ LOG( log_track, 2, ( "SplitTrack( T%d[%d], (%0.3f %0.3f)\n", trk->index, ep, pos if (*leftover) { trkl = *leftover; ep0 = epl; - if ( !disconnect ) + if ( !disconnect ) { ConnectTracks( trk, ep, trkl, epl ); + } ep0 = 1-epl; while ( 1 ) { CopyAttributes( trk, trkl ); ClrTrkElev( trkl ); trk0 = GetTrkEndTrk(trkl,ep0); - if ( trk0 == NULL || trk0->type == T_TURNOUT ) + if ( trk0 == NULL || trk0->type == T_TURNOUT ) { break; + } ep0 = 1-GetEndPtConnectedToMe(trk0,trkl); trkl = trk0; } - if (trk2) + if (trk2) { ConnectTracks( trkl, ep0, trk2, ep2 ); + } LOG( log_track, 2, ( " midTrack (leftover = T%d)\n", (trkl)->index ) ) } suspendElevUpdates = FALSE; @@ -2196,8 +2235,9 @@ LOG( log_track, 2, ( "SplitTrack( T%d[%d], (%0.3f %0.3f)\n", trk->index, ep, pos while ( 1 ) { DrawNewTrack( trkl ); trk0 = GetTrkEndTrk(trkl,ep0); - if ( trk0 == NULL || trk0 == trk2 || trk0->type == T_TURNOUT) + if ( trk0 == NULL || trk0 == trk2 || trk0->type == T_TURNOUT) { break; + } ep0 = 1-GetEndPtConnectedToMe(trk0,trkl); trkl = trk0; } @@ -2208,30 +2248,35 @@ LOG( log_track, 2, ( "SplitTrack( T%d[%d], (%0.3f %0.3f)\n", trk->index, ep, pos EXPORT BOOL_T TraverseTrack( - traverseTrack_p trvTrk, - DIST_T * distR ) + traverseTrack_p trvTrk, + DIST_T * distR ) { track_p oldTrk; EPINX_T ep; while ( *distR > 0.0 && trvTrk->trk ) { - if ( trackCmds((trvTrk->trk)->type)->traverse == NULL ) + if ( trackCmds((trvTrk->trk)->type)->traverse == NULL ) { return FALSE; + } oldTrk = trvTrk->trk; - if ( !trackCmds((trvTrk->trk)->type)->traverse( trvTrk, distR ) ) + if ( !trackCmds((trvTrk->trk)->type)->traverse( trvTrk, distR ) ) { return FALSE; - if ( *distR <= 0.0 ) + } + if ( *distR <= 0.0 ) { return TRUE; - if ( !trvTrk->trk ) + } + if ( !trvTrk->trk ) { return FALSE; + } ep = GetNearestEndPtConnectedToMe( trvTrk->trk, oldTrk, trvTrk->pos ); if ( ep != -1 ) { trvTrk->pos = GetTrkEndPos( trvTrk->trk, ep ); trvTrk->angle = NormalizeAngle( GetTrkEndAngle( trvTrk->trk, ep ) + 180.0 ); } if ( trackCmds((trvTrk->trk)->type)->checkTraverse && - !trackCmds((trvTrk->trk)->type)->checkTraverse( trvTrk->trk, trvTrk->pos ) ) + !trackCmds((trvTrk->trk)->type)->checkTraverse( trvTrk->trk, trvTrk->pos ) ) { return FALSE; + } trvTrk->length = -1; trvTrk->dist = 0.0; @@ -2246,20 +2291,25 @@ EXPORT BOOL_T RemoveTrack( track_p * trk, EPINX_T * ep, DIST_T *dist ) track_p trk1; EPINX_T ep1=-1; while ( *dist > 0.0 ) { - if (trackCmds((*trk)->type)->getLength == NULL) + if (trackCmds((*trk)->type)->getLength == NULL) { return FALSE; - if (GetTrkEndPtCnt(*trk) != 2) + } + if (GetTrkEndPtCnt(*trk) != 2) { return FALSE; + } dist1 = trackCmds((*trk)->type)->getLength(*trk); - if ( dist1 > *dist ) + if ( dist1 > *dist ) { break; + } *dist -= dist1; trk1 = GetTrkEndTrk( *trk, 1-*ep ); - if (trk1) + if (trk1) { ep1 = GetEndPtConnectedToMe( trk1, *trk ); + } DeleteTrack( *trk, FALSE ); - if (!trk1) + if (!trk1) { return FALSE; + } *trk = trk1; *ep = ep1; } @@ -2269,22 +2319,26 @@ EXPORT BOOL_T RemoveTrack( track_p * trk, EPINX_T * ep, DIST_T *dist ) } -EXPORT BOOL_T TrimTrack( track_p trk, EPINX_T ep, DIST_T dist, coOrd pos, ANGLE_T angle, DIST_T radius, coOrd center ) +EXPORT BOOL_T TrimTrack( track_p trk, EPINX_T ep, DIST_T dist, coOrd pos, + ANGLE_T angle, DIST_T radius, coOrd center ) { - if (trackCmds(trk->type)->trim) + if (trackCmds(trk->type)->trim) { return trackCmds(trk->type)->trim( trk, ep, dist, pos, angle, radius, center ); - else + } else { return FALSE; + } } -EXPORT BOOL_T MergeTracks( track_p trk0, EPINX_T ep0, track_p trk1, EPINX_T ep1 ) +EXPORT BOOL_T MergeTracks( track_p trk0, EPINX_T ep0, track_p trk1, + EPINX_T ep1 ) { if (trk0->type == trk1->type && - trackCmds(trk0->type)->merge) + trackCmds(trk0->type)->merge) { return trackCmds(trk0->type)->merge( trk0, ep0, trk1, ep1 ); - else + } else { return FALSE; + } } EXPORT STATUS_T ExtendTrackFromOrig( track_p trk, wAction_t action, coOrd pos ) @@ -2301,15 +2355,17 @@ EXPORT STATUS_T ExtendTrackFromOrig( track_p trk, wAction_t action, coOrd pos ) switch ( action ) { case C_DOWN: ep = PickUnconnectedEndPoint( pos, trk ); - if ( ep == -1 ) + if ( ep == -1 ) { return C_ERROR; + } pos = GetTrkEndPos(trk,ep); - if (!GetTrackParams(PARAMS_CORNU,trk,pos,¶ms)) return C_ERROR; + if (!GetTrackParams(PARAMS_CORNU,trk,pos,¶ms)) { return C_ERROR; } end_pos = pos; + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); if (params.type == curveTypeCurve) { curved = TRUE; tempSegs(0).type = SEG_CRVTRK; - tempSegs(0).width = 0; + tempSegs(0).lineWidth = 0; tempSegs(0).u.c.radius = params.arcR; tempSegs(0).u.c.center = params.arcP; tempSegs(0).u.c.a0 = FindAngle(params.arcP,GetTrkEndPos(trk,ep)); @@ -2317,23 +2373,29 @@ EXPORT STATUS_T ExtendTrackFromOrig( track_p trk, wAction_t action, coOrd pos ) } else { curved = FALSE; tempSegs(0).type = SEG_STRTRK; - tempSegs(0).width = 0; + tempSegs(0).lineWidth = 0; tempSegs(0).u.l.pos[0] = tempSegs(0).u.l.pos[1] = GetTrkEndPos( trk, ep ); } valid = FALSE; InfoMessage( _("Drag to change track length") ); + DYNARR_RESET( trkSeg_t, tempSegs_da ); return C_CONTINUE; - /*no break*/ + case C_MOVE: + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); if (curved) { //Normalize pos - PointOnCircle( &pos, tempSegs(0).u.c.center, tempSegs(0).u.c.radius, FindAngle(tempSegs(0).u.c.center,pos) ); - ANGLE_T a = FindAngle(tempSegs(0).u.c.center,pos)-FindAngle(tempSegs(0).u.c.center,end_pos); + PointOnCircle( &pos, tempSegs(0).u.c.center, tempSegs(0).u.c.radius, + FindAngle(tempSegs(0).u.c.center,pos) ); + ANGLE_T a = FindAngle(tempSegs(0).u.c.center, + pos)-FindAngle(tempSegs(0).u.c.center,end_pos); d = fabs(a)*2*M_PI/360*tempSegs(0).u.c.radius; if ( d <= minLength ) { - if (action == C_MOVE) + if (action == C_MOVE) { ErrorMessage( MSG_TRK_TOO_SHORT, _("Connecting "), PutDim(fabs(minLength-d)) ); + } valid = FALSE; + DYNARR_RESET( trkSeg_t, tempSegs_da ); return C_CONTINUE; } //Restrict to outside track @@ -2343,6 +2405,7 @@ EXPORT STATUS_T ExtendTrackFromOrig( track_p trk, wAction_t action, coOrd pos ) tempSegs(0).u.c.a1 = 0; tempSegs(0).u.c.a0 = end_angle; InfoMessage( _("Inside turnout track")); + DYNARR_RESET( trkSeg_t, tempSegs_da ); return C_CONTINUE; } end_angle = GetTrkEndAngle( trk, ep ); @@ -2350,51 +2413,57 @@ EXPORT STATUS_T ExtendTrackFromOrig( track_p trk, wAction_t action, coOrd pos ) PointOnCircle( &pos, tempSegs(0).u.c.center, tempSegs(0).u.c.radius, a ); ANGLE_T a2 = FindAngle(tempSegs(0).u.c.center,end_pos); if ((end_angle > 180 && (a2>90 && a2 <270)) || - (end_angle < 180 && (a2<90 || a2 >270))) { + (end_angle < 180 && (a2<90 || a2 >270))) { tempSegs(0).u.c.a0 = a2; tempSegs(0).u.c.a1 = NormalizeAngle(a-a2); } else { tempSegs(0).u.c.a0 = a; tempSegs(0).u.c.a1 = NormalizeAngle(a2-a); } - tempSegs_da.cnt = 1; valid = TRUE; if (action == C_MOVE) InfoMessage( _("Curve: Length=%s Radius=%0.3f Arc=%0.3f"), - FormatDistance( d ), FormatDistance(tempSegs(0).u.c.radius), PutAngle( tempSegs(0).u.c.a1 )); + FormatDistance( d ), FormatDistance(tempSegs(0).u.c.radius), + PutAngle( tempSegs(0).u.c.a1 )); return C_CONTINUE; } else { d = FindDistance( end_pos, pos ); valid = TRUE; if ( d <= minLength ) { - if (action == C_MOVE) + if (action == C_MOVE) { ErrorMessage( MSG_TRK_TOO_SHORT, _("Connecting "), PutDim(fabs(minLength-d)) ); + } valid = FALSE; + DYNARR_RESET( trkSeg_t, tempSegs_da ); return C_CONTINUE; } - ANGLE_T diff = NormalizeAngle(GetTrkEndAngle( trk, ep )-FindAngle(end_pos, pos)); + ANGLE_T diff = NormalizeAngle(GetTrkEndAngle( trk, ep )-FindAngle(end_pos, + pos)); if (diff>=90.0 && diff<=270.0) { valid = FALSE; - tempSegs(0).u.c.a1 = 0; - tempSegs(0).u.c.a0 = end_angle; InfoMessage( _("Inside turnout track")); + DYNARR_RESET( trkSeg_t, tempSegs_da ); return C_CONTINUE; } - Translate( &tempSegs(0).u.l.pos[1], tempSegs(0).u.l.pos[0], GetTrkEndAngle( trk, ep ), d ); - tempSegs_da.cnt = 1; + + Translate( &tempSegs(0).u.l.pos[1], tempSegs(0).u.l.pos[0], GetTrkEndAngle( trk, + ep ), d ); if (action == C_MOVE) InfoMessage( _("Straight: Length=%s Angle=%0.3f"), - FormatDistance( d ), PutAngle( GetTrkEndAngle( trk, ep ) ) ); + FormatDistance( d ), PutAngle( GetTrkEndAngle( trk, ep ) ) ); } return C_CONTINUE; case C_UP: - if (!valid) + if (!valid) { return C_TERMINATE; + } + DYNARR_RESET( trkSeg_t, tempSegs_da ); UndrawNewTrack( trk ); EPINX_T jp; if (curved) { - trk1 = NewCurvedTrack(tempSegs(0).u.c.center, tempSegs(0).u.c.radius, tempSegs(0).u.c.a0, tempSegs(0).u.c.a1, 0); + trk1 = NewCurvedTrack(tempSegs(0).u.c.center, tempSegs(0).u.c.radius, + tempSegs(0).u.c.a0, tempSegs(0).u.c.a1, 0); jp = PickUnconnectedEndPoint(end_pos,trk1); } else { trk1 = NewStraightTrack( tempSegs(0).u.l.pos[0], tempSegs(0).u.l.pos[1] ); @@ -2412,7 +2481,8 @@ EXPORT STATUS_T ExtendTrackFromOrig( track_p trk, wAction_t action, coOrd pos ) return C_ERROR; } -EXPORT STATUS_T ExtendStraightFromOrig( track_p trk, wAction_t action, coOrd pos ) +EXPORT STATUS_T ExtendStraightFromOrig( track_p trk, wAction_t action, + coOrd pos ) { static EPINX_T ep; static BOOL_T valid; @@ -2422,10 +2492,12 @@ EXPORT STATUS_T ExtendStraightFromOrig( track_p trk, wAction_t action, coOrd pos switch ( action ) { case C_DOWN: ep = PickUnconnectedEndPoint( pos, trk ); - if ( ep == -1 ) + if ( ep == -1 ) { return C_ERROR; + } + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); tempSegs(0).type = SEG_STRTRK; - tempSegs(0).width = 0; + tempSegs(0).lineWidth = 0; tempSegs(0).u.l.pos[0] = GetTrkEndPos( trk, ep ); InfoMessage( _("Drag to change track length") ); @@ -2433,21 +2505,23 @@ EXPORT STATUS_T ExtendStraightFromOrig( track_p trk, wAction_t action, coOrd pos d = FindDistance( tempSegs(0).u.l.pos[0], pos ); valid = TRUE; if ( d <= minLength ) { - if (action == C_MOVE) + if (action == C_MOVE) { ErrorMessage( MSG_TRK_TOO_SHORT, _("Connecting "), PutDim(fabs(minLength-d)) ); + } valid = FALSE; return C_CONTINUE; } - Translate( &tempSegs(0).u.l.pos[1], tempSegs(0).u.l.pos[0], GetTrkEndAngle( trk, ep ), d ); - tempSegs_da.cnt = 1; + Translate( &tempSegs(0).u.l.pos[1], tempSegs(0).u.l.pos[0], GetTrkEndAngle( trk, + ep ), d ); if (action == C_MOVE) InfoMessage( _("Straight: Length=%s Angle=%0.3f"), - FormatDistance( d ), PutAngle( GetTrkEndAngle( trk, ep ) ) ); + FormatDistance( d ), PutAngle( GetTrkEndAngle( trk, ep ) ) ); return C_CONTINUE; case C_UP: - if (!valid) + if (!valid) { return C_TERMINATE; + } UndrawNewTrack( trk ); trk1 = NewStraightTrack( tempSegs(0).u.l.pos[0], tempSegs(0).u.l.pos[1] ); CopyAttributes( trk, trk1 ); @@ -2474,12 +2548,13 @@ EXPORT STATUS_T ModifyTrack( track_p trk, wAction_t action, coOrd pos ) } -EXPORT BOOL_T GetTrackParams( int inx, track_p trk, coOrd pos, trackParams_t * params ) +EXPORT BOOL_T GetTrackParams( int inx, track_p trk, coOrd pos, + trackParams_t * params ) { if ( trackCmds(trk->type)->getTrackParams ) { return trackCmds(trk->type)->getTrackParams( inx, trk, pos, params ); } else { - ASSERT( FALSE ); /* CHECKME */ + CHECK( FALSE ); /* CHECKME */ return FALSE; } } @@ -2538,23 +2613,29 @@ EXPORT DIST_T GetFlexLength( track_p trk0, EPINX_T ep, coOrd * pos ) d = 0.0; while(1) { trk1 = GetTrkEndTrk( trk, ep ); - if (trk1 == NULL) + if (trk1 == NULL) { break; - if (trk1 == trk0) + } + if (trk1 == trk0) { break; + } ep1 = GetEndPtConnectedToMe( trk1, trk ); - if (ep1 < 0 || ep1 > 1) + if (ep1 < 0 || ep1 > 1) { break; - if (trackCmds(trk1->type)->getLength == NULL) + } + if (trackCmds(trk1->type)->getLength == NULL) { break; + } dd = trackCmds(trk1->type)->getLength(trk1); - if (dd <= 0.0) + if (dd <= 0.0) { break; + } d += dd; trk = trk1; ep = 1-ep1; - if (d>DIST_INF) + if (d>DIST_INF) { break; + } } *pos = GetTrkEndPos( trk, ep ); return d; @@ -2565,12 +2646,13 @@ EXPORT DIST_T GetTrkLength( track_p trk, EPINX_T ep0, EPINX_T ep1 ) { coOrd pos0, pos1; DIST_T d; - if (ep0 == ep1) + if (ep0 == ep1) { return 0.0; - else if (trackCmds(trk->type)->getLength != NULL) { + } else if (trackCmds(trk->type)->getLength != NULL) { d = trackCmds(trk->type)->getLength(trk); - if (ep1==-1) + if (ep1==-1) { d = d/2.0; + } return d; } else { pos0 = GetTrkEndPos(trk,ep0); @@ -2610,7 +2692,6 @@ EXPORT DIST_T GetTrkLength( track_p trk, EPINX_T ep0, EPINX_T ep1 ) return fabs(pos1.y); } } -#endif /*#define DRAW_TUNNEL_NONE (0)*/ #define DRAW_TUNNEL_DASH (1) #define DRAW_TUNNEL_SOLID (2) @@ -2624,24 +2705,39 @@ EXPORT long drawTunnel = DRAW_TUNNEL_DASH; EXPORT long tieDrawMode = TIEDRAWMODE_SOLID; EXPORT wDrawColor tieColor; +EXPORT wDrawColor bridgeColor; +EXPORT wDrawColor roadbedColor; + +/** + * Draw tracks with 2 rails when zoomed in + * + * \param d drawing context + * \return true is we draw tracks with 2 rails + */ +EXPORT BOOL_T DrawTwoRails( drawCmd_p d, DIST_T factor ) +{ + DIST_T scale = twoRailScale; + if ( d->options&DC_PRINT ) { + scale = scale*2+1; + } + scale /= factor; + return d->scale <= scale; +} + /** * Centerline drawing test - * + * * \param d drawing context * \return true for centerline, false if no centerline to draw */ -static bool -HasTrackCenterline( drawCmd_p d ) +EXPORT BOOL_T +hasTrackCenterline( drawCmd_p d ) { // for printing, drawing of center line depends on the scale if( d->options & DC_CENTERLINE && d->options & DC_PRINT ) { - if( d->scale <= ( twoRailScale * 2.0 + 1.0 ) / 2.0 ) { - return true; - } else { - return false; - } + return DrawTwoRails(d,1); } // all other cases of explicit centerline option (ie. bitmap) @@ -2657,32 +2753,38 @@ HasTrackCenterline( drawCmd_p d ) return false; } -EXPORT wBool_t DoDrawTies( drawCmd_p d, track_cp trk ) +EXPORT wBool_t +DoDrawTies( drawCmd_p d, track_cp trk ) { - DIST_T scale2rail = (d->options&DC_PRINT)?(twoRailScale*2+1):twoRailScale; - if ( !trk ) + if ( !trk ) { return FALSE; - if (GetTrkNoTies(trk)) - return FALSE; //No Ties for this Track - if ( tieDrawMode == TIEDRAWMODE_NONE ) + } + if (GetTrkNoTies(trk)) { + return FALSE; //No Ties for this Track + } + if ( tieDrawMode == TIEDRAWMODE_NONE ) { return FALSE; - if ( d == &mapD ) + } + if ( d == &mapD ) { return FALSE; - if ( d->scale >= scale2rail ) + } + if ( !DrawTwoRails(d,1) ) { return FALSE; - if ( !(GetTrkVisible(trk) || drawTunnel==DRAW_TUNNEL_SOLID) ) + } + if ( !(GetTrkVisible(trk) || drawTunnel==DRAW_TUNNEL_SOLID) ) { return FALSE; + } return TRUE; } EXPORT void DrawTie( - drawCmd_p d, - coOrd pos, - ANGLE_T angle, - DIST_T length, - DIST_T width, - wDrawColor color, - BOOL_T solid ) + drawCmd_p d, + coOrd pos, + ANGLE_T angle, + DIST_T length, + DIST_T width, + wDrawColor color, + BOOL_T solid ) { coOrd lo, hi; coOrd p[4]; @@ -2704,7 +2806,7 @@ EXPORT void DrawTie( Translate( &p[3], p[2], angle-90, width ); Translate( &p[2], p[2], angle+90, width ); - for (int i=0;i<4;i++) { + for (int i=0; i<4; i++) { t[i] = 0; } @@ -2713,8 +2815,9 @@ EXPORT void DrawTie( lo.y -= TBORDER/mainD.dpi*mainD.scale; hi.x += LBORDER/mainD.dpi*mainD.scale; hi.y += BBORDER/mainD.dpi*mainD.scale; - if ( OFF_D( d->orig, d->size, lo, hi ) ) + if ( OFF_D( d->orig, d->size, lo, hi ) ) { return; + } } if ( solid ) { DrawPoly( d, 4, p, t, color, 0, DRAW_FILL ); @@ -2724,277 +2827,6 @@ EXPORT void DrawTie( } -static void DrawCurvedTies( - drawCmd_p d, - SCALEINX_T scaleInx, - coOrd p, - DIST_T r, - ANGLE_T a0, - ANGLE_T a1, - wDrawColor color ) -{ - tieData_p td; - DIST_T len; - ANGLE_T ang, dang; - coOrd pos; - int cnt; - - if ( (d->options&DC_SIMPLE) != 0 ) - return; - - if ( scaleInx < 0 ) - return; - td = GetScaleTieData( scaleInx ); - - if (color == wDrawColorBlack) - color = tieColor; - len = 2*M_PI*r*a1/360.0; - cnt = (int)floor(len/td->spacing+0.5); - if ( len-td->spacing*cnt-(td->width/2) > (td->spacing-td->width)/2 ) { - cnt++; - } - if ( cnt != 0 ) { - dang = (360.0*(len)/cnt)/(2*M_PI*r); - for ( ang=a0+dang/2; cnt; cnt--,ang+=dang ) { - PointOnCircle( &pos, p, r, ang ); - DrawTie( d, pos, ang+90, td->length, td->width, color, tieDrawMode==TIEDRAWMODE_SOLID ); - } - - } -} - -EXPORT void DrawCurvedTrack( - drawCmd_p d, - coOrd p, - DIST_T r, - ANGLE_T a0, - ANGLE_T a1, - track_p trk, - wDrawColor color, - long options ) -{ - DIST_T scale2rail; - DIST_T trackGauge = GetTrkGauge(trk); - wDrawWidth width=0; - trkSeg_p segPtr; - long bridge = 0; - if(trk) - bridge = GetTrkBridge( trk ); - - if ( (d->options&DC_SEGTRACK) ) { - DYNARR_APPEND( trkSeg_t, tempSegs_da, 10 ); - segPtr = &tempSegs(tempSegs_da.cnt-1); - segPtr->type = SEG_CRVTRK; - segPtr->width = 0; - segPtr->color = wDrawColorBlack; - segPtr->u.c.center = p; - segPtr->u.c.a0 = a0; - segPtr->u.c.a1 = a1; - segPtr->u.c.radius = r; - return; - } - - scale2rail = (d->options&DC_PRINT)?(twoRailScale*2+1):twoRailScale; - width = trk ? GetTrkWidth( trk ): 0; - if ( d->options&DC_THICK ) - width = 3; - if ( color == wDrawColorPreviewSelected || color == wDrawColorPreviewUnselected ) - width = 3; - - if ((d->options&DC_PRINT) && (d->dpi>2*BASE_DPI)) - width = (wDrawWidth)round(width * d->dpi / 2 / BASE_DPI); - - LOG(log_track,4,("DST( (%0.3f %0.3f) R%0.3f A%0.3f..%0.3f)\n", - p.x, p.y, r, a0, a1 ) ) - - // Draw a solid background - if(bridge) { - wDrawWidth width3 = (wDrawWidth)round(trackGauge * 3 * d->dpi/d->scale); // / BASE_DPI); - DrawArc( d, p, r, a0, a1, 0, width3, drawColorGrey90 ); - } - - if ( DoDrawTies( d, trk ) ) - DrawCurvedTies( d, GetTrkScale(trk), p, r, a0, a1, color ); - if (color == wDrawColorBlack) - color = normalColor; - if ( d->scale >= scale2rail ) { - DrawArc( d, p, r, a0, a1, (centerDrawMode && !(options&DTS_NOCENTER)) ? 1 : 0, width, color ); - } else { - if ( HasTrackCenterline(d)) { - long options = d->options; - d->options |= DC_DASH; - DrawArc( d, p, r, a0, a1, 0, 0, color ); - d->options = options; - } - DrawArc( d, p, r+trackGauge/2.0, a0, a1, 0, width, color ); - DrawArc( d, p, r-trackGauge/2.0, a0, a1, (centerDrawMode && !(options&DTS_NOCENTER) ? 1: 0), width, color ); - if ( (d->options&DC_PRINT) && roadbedWidth > trackGauge && d->scale <= scale2rail/2 ) { - wDrawWidth rbw = (wDrawWidth)floor(roadbedLineWidth*(d->dpi/d->scale)+0.5); - if ( options&DTS_RIGHT ) { - DrawArc( d, p, r+roadbedWidth/2.0, a0, a1, 0, rbw, color ); - } - if ( options&DTS_LEFT ) { - DrawArc( d, p, r-roadbedWidth/2.0, a0, a1, 0, rbw, color ); - } - } - } - if (bridge) { - wDrawWidth width2 = (wDrawWidth)round((2.0 * d->dpi)/BASE_DPI); - if (d->options&DC_PRINT) - width2 = (wDrawWidth)round(d->dpi / BASE_DPI); - - DrawArc( d, p, r+(trackGauge*1.5), a0, a1, 0, width2, color ); - DrawArc( d, p, r-(trackGauge*1.5), a0, a1, 0, width2, color ); - } - -} - - -EXPORT void DrawStraightTies( - drawCmd_p d, - SCALEINX_T scaleInx, - coOrd p0, - coOrd p1, - wDrawColor color ) -{ - tieData_p td; - DIST_T tieOff0=0.0, tieOff1=0.0; - DIST_T len, dlen; - coOrd pos; - int cnt; - ANGLE_T angle; - - if ( (d->options&DC_SIMPLE) != 0 ) - return; - - if ( color == wDrawColorBlack ) - color = tieColor; - if ( scaleInx < 0 ) - return; - td = GetScaleTieData( scaleInx ); - len = FindDistance( p0, p1 ); - len -= tieOff0+tieOff1; - angle = FindAngle( p0, p1 ); - cnt = (int)floor(len/td->spacing+0.5); - if ( len-td->spacing*cnt-td->width > (td->spacing-td->width)/2 ) { - cnt++; - } - if ( cnt != 0 ) { - dlen = FindDistance( p0, p1 )/cnt; - double endsize = FindDistance( p0, p1 )-cnt*dlen-td->width; - for ( len=dlen/2; cnt; cnt--,len+=dlen ) { - Translate( &pos, p0, angle, len ); - DrawTie( d, pos, angle, td->length, td->width, color, tieDrawMode==TIEDRAWMODE_SOLID ); - } - } -} - - - -EXPORT void DrawStraightTrack( - drawCmd_p d, - coOrd p0, - coOrd p1, - ANGLE_T angle, - track_cp trk, - wDrawColor color, - long options ) -{ - coOrd pp0, pp1; - DIST_T scale2rail; - DIST_T trackGauge = GetTrkGauge(trk); - long bridge = 0; - if ( trk ) - bridge = GetTrkBridge(trk); - wDrawWidth width=0; - trkSeg_p segPtr; - - if ( (d->options&DC_SEGTRACK) ) { - DYNARR_APPEND( trkSeg_t, tempSegs_da, 10 ); - segPtr = &tempSegs(tempSegs_da.cnt-1); - segPtr->type = SEG_STRTRK; - segPtr->width = 0; - segPtr->color = wDrawColorBlack; - segPtr->u.l.pos[0] = p0; - segPtr->u.l.pos[1] = p1; - segPtr->u.l.angle = angle; - segPtr->u.l.option = 0; - return; - } - - scale2rail = (d->options&DC_PRINT)?(twoRailScale*2+1):twoRailScale; - - width = trk ? GetTrkWidth( trk ): 0; - if ((d->options&DC_PRINT) && (d->dpi>2*BASE_DPI)) - width = (wDrawWidth)round(width * d->dpi / 2 / BASE_DPI); - - if ( d->options&DC_THICK ) - width = 3; - if ( color == wDrawColorPreviewSelected || color == wDrawColorPreviewUnselected ) - width = 3; - - - LOG(log_track,4,("DST( (%0.3f %0.3f) .. (%0.3f..%0.3f)\n", - p0.x, p0.y, p1.x, p1.y ) ) - - // Draw solid background - if(bridge) { - wDrawWidth width3 = (wDrawWidth)round(trackGauge * 3 * d->dpi/d->scale); - DrawLine(d,p0,p1,width3,wDrawColorGrey90); - } - - if ( DoDrawTies( d, trk ) ) - DrawStraightTies( d, GetTrkScale(trk), p0, p1, color ); - if (color == wDrawColorBlack) - color = normalColor; - if ( d->scale >= scale2rail ) { - DrawLine( d, p0, p1, width, color ); - } else { - if ( HasTrackCenterline(d)) { - long options = d->options; - d->options |= DC_DASH; - DrawLine( d, p0, p1, 0, color ); - d->options = options; - } - Translate( &pp0, p0, angle+90, trackGauge/2.0 ); - Translate( &pp1, p1, angle+90, trackGauge/2.0 ); - DrawLine( d, pp0, pp1, width, color ); - - Translate( &pp0, p0, angle-90, trackGauge/2.0 ); - Translate( &pp1, p1, angle-90, trackGauge/2.0 ); - DrawLine( d, pp0, pp1, width, color ); - - if ( (d->options&DC_PRINT) && roadbedWidth > trackGauge && d->scale <= scale2rail/2.0) { - wDrawWidth rbw = (wDrawWidth)floor(roadbedLineWidth*(d->dpi/d->scale)+0.5); - if ( options&DTS_RIGHT ) { - Translate( &pp0, p0, angle+90, roadbedWidth/2.0 ); - Translate( &pp1, p1, angle+90, roadbedWidth/2.0 ); - DrawLine( d, pp0, pp1, rbw, color ); - } - if ( options&DTS_LEFT ) { - Translate( &pp0, p0, angle-90, roadbedWidth/2.0 ); - Translate( &pp1, p1, angle-90, roadbedWidth/2.0 ); - DrawLine( d, pp0, pp1, rbw, color ); - } - } - } - - if (bridge) { - wDrawWidth width2 = (wDrawWidth)round((2.0 * d->dpi)/BASE_DPI); - if (d->options&DC_PRINT) - width2 = (wDrawWidth)round(d->dpi / BASE_DPI); - - Translate( &pp0, p0, angle-90, trackGauge*1.5 ); - Translate( &pp1, p1, angle-90, trackGauge*1.5 ); - DrawLine( d, pp0, pp1, width2, color ); - - Translate( &pp0, p0, angle+90, trackGauge*1.5 ); - Translate( &pp1, p1, angle+90, trackGauge*1.5 ); - DrawLine( d, pp0, pp1, width2, color); - } -} - - EXPORT wDrawColor GetTrkColor( track_p trk, drawCmd_p d ) { DIST_T len, elev0, elev1; @@ -3004,25 +2836,32 @@ EXPORT wDrawColor GetTrkColor( track_p trk, drawCmd_p d ) ComputeElev( trk, 0, FALSE, &elev0, NULL, FALSE ); len = GetTrkLength( trk, 0, 1 ); ComputeElev( trk, 1, FALSE, &elev1, NULL, FALSE ); - if (len>0.1) + if (len>0.1) { grade = fabs( (elev1-elev0)/len)*100.0; + } } - if ( (d->options&(DC_SIMPLE|DC_SEGTRACK)) != 0 ) + if ( (d->options&(DC_SIMPLE|DC_SEGTRACK)) != 0 ) { return wDrawColorBlack; - if ( grade > GetLayoutMaxTrackGrade()) + } + if ( grade > GetLayerMaxTrackGrade(GetTrkLayer(trk))) { return exceptionColor; - if ( QueryTrack( trk, Q_EXCEPTION ) ) + } + if ( QueryTrack( trk, Q_EXCEPTION ) ) { return exceptionColor; + } if ( (d->options&(DC_PRINT)) == 0 ) { - if (GetTrkBits(trk)&TB_PROFILEPATH) + if (GetTrkBits(trk)&TB_PROFILEPATH) { return profilePathColor; - if ((d->options&DC_PRINT)==0 && GetTrkSelected(trk) && d == &tempD) + } + if ((d->options&DC_PRINT)==0 && GetTrkSelected(trk) && d == &tempD) { return selectedColor; + } } if ( (IsTrack(trk)?(colorTrack):(colorDraw)) ) { unsigned int iLayer = GetTrkLayer( trk ); - if (GetLayerUseColor( iLayer ) ) + if (GetLayerUseColor( iLayer ) ) { return GetLayerColor( iLayer ); + } } return wDrawColorBlack; } @@ -3033,31 +2872,37 @@ EXPORT void DrawTrack( track_cp trk, drawCmd_p d, wDrawColor color ) TRKTYP_T trkTyp; // Hack for WINDOWS - if ( trk->bits & TB_UNDRAWN ) + if ( trk->bits & TB_UNDRAWN ) { return; + } trkTyp = GetTrkType(trk); curTrackLayer = GetTrkLayer(trk); if (d != &mapD ) { if ( (!GetTrkVisible(trk)) ) { - if ( drawTunnel==DRAW_TUNNEL_NONE ) + if ( drawTunnel==DRAW_TUNNEL_NONE ) { return; - if ( drawTunnel==DRAW_TUNNEL_DASH ) + } + if ( drawTunnel==DRAW_TUNNEL_DASH ) { d->options |= DC_DASH; + } } if (color == wDrawColorBlack) { color = GetTrkColor( trk, d ); } - if (color == wDrawColorPreviewSelected || color == wDrawColorPreviewUnselected ) { + if (color == wDrawColorPreviewSelected + || color == wDrawColorPreviewUnselected ) { d->options |= DC_THICK; } } - if (d == &mapD && !GetLayerOnMap(curTrackLayer)) + if (d == &mapD && !GetLayerOnMap(curTrackLayer)) { return; + } if ( (IsTrack(trk)?(colorTrack):(colorDraw)) && - (d != &mapD) && (color == wDrawColorBlack) ) - if (GetLayerUseColor((unsigned int)curTrackLayer)) + (d != &mapD) && (color == wDrawColorBlack) ) + if (GetLayerUseColor((unsigned int)curTrackLayer)) { color = GetLayerColor((unsigned int)curTrackLayer); + } trackCmds(trkTyp)->draw( trk, d, color ); d->options &= ~DC_DASH; @@ -3091,17 +2936,21 @@ EXPORT void DrawPositionIndicators( void ) { track_p trk; coOrd hi, lo; - if ( !doDrawPositionIndicator ) + if ( !doDrawPositionIndicator ) { return; + } TRK_ITERATE( trk ) { if ( trackCmds(trk->type)->drawPositionIndicator ) { - if ( drawTunnel==DRAW_TUNNEL_NONE && (!GetTrkVisible(trk)) ) + if ( drawTunnel==DRAW_TUNNEL_NONE && (!GetTrkVisible(trk)) ) { continue; + } GetBoundingBox( trk, &hi, &lo ); - if ( OFF_MAIND( lo, hi ) ) + if ( OFF_MAIND( lo, hi ) ) { continue; - if (!GetLayerVisible( GetTrkLayer(trk) ) ) + } + if (!GetLayerVisible( GetTrkLayer(trk) ) ) { continue; + } trackCmds(trk->type)->drawPositionIndicator( trk, selectedColor ); } } @@ -3109,13 +2958,14 @@ EXPORT void DrawPositionIndicators( void ) EXPORT void AdvancePositionIndicator( - track_p trk, - coOrd pos, - coOrd * posR, - ANGLE_T * angleR ) + track_p trk, + coOrd pos, + coOrd * posR, + ANGLE_T * angleR ) { - if ( trackCmds(trk->type)->advancePositionIndicator ) + if ( trackCmds(trk->type)->advancePositionIndicator ) { trackCmds(trk->type)->advancePositionIndicator( trk, pos, posR, angleR ); + } } /***************************************************************************** * @@ -3123,90 +2973,23 @@ EXPORT void AdvancePositionIndicator( * */ -static void DrawUnconnectedEndPt( drawCmd_p d, coOrd p, ANGLE_T a, DIST_T trackGauge, wDrawColor color ) +static void DrawUnconnectedEndPt( drawCmd_p d, coOrd p, ANGLE_T a, + DIST_T trackGauge, wDrawColor color ) { coOrd p0, p1; + Translate( &p0, p, a, trackGauge ); + Translate( &p1, p, a-180.0, trackGauge ); + DrawLine( d, p0, p1, 0, color ); + if (d->scale < 8 || drawUnconnectedEndPt > 0) { + Translate( &p, p, a+90.0, 0.2 ); Translate( &p0, p, a, trackGauge ); Translate( &p1, p, a-180.0, trackGauge ); - DrawLine( d, p0, p1, 0, color ); - if (d->scale < 8 || drawUnconnectedEndPt > 0) { - Translate( &p, p, a+90.0, 0.2 ); - Translate( &p0, p, a, trackGauge ); - Translate( &p1, p, a-180.0, trackGauge ); - DrawLine( d, p0, p1, (drawUnconnectedEndPt>0)?4:0, (color==wDrawColorWhite)?color:(drawUnconnectedEndPt>1)?exceptionColor:color ); - } -} - - -EXPORT void DrawEndElev( drawCmd_p d, track_p trk, EPINX_T ep, wDrawColor color ) -{ - coOrd pp; - wFont_p fp; - elev_t * elev; - track_p trk1; - DIST_T elev0, grade; - ANGLE_T a=0; - int style = BOX_BOX; - BOOL_T gradeOk = TRUE; - char *elevStr; - - if ((labelEnable&LABELENABLE_ENDPT_ELEV)==0) - return; - elev = &trk->endPt[ep].elev; /* TRACKDEP */ - if ( (elev->option&ELEV_MASK)==ELEV_NONE || - (elev->option&ELEV_VISIBLE)==0 ) - return; - if ( (trk1=GetTrkEndTrk(trk,ep)) && GetTrkIndex(trk1)<GetTrkIndex(trk) ) - return; - - fp = wStandardFont( F_HELV, FALSE, FALSE ); - pp = GetTrkEndPos( trk, ep ); - switch ((elev->option&ELEV_MASK)) { - case ELEV_COMP: - case ELEV_GRADE: - if ( color == wDrawColorWhite ) { - elev0 = grade = elev->u.height; - } else if ( !ComputeElev( trk, ep, FALSE, &elev0, &grade, FALSE ) ) { - elev0 = grade = 0; - gradeOk = FALSE; - } - if ((elev->option&ELEV_MASK)==ELEV_COMP) { - elevStr = FormatDistance(elev0); - elev->u.height = elev0; - } else if (gradeOk) { - sprintf( message, "%0.1f%%", round(fabs(grade*100.0)*10)/10 ); - elevStr = message; - a = GetTrkEndAngle( trk, ep ); - style = BOX_ARROW_BACKGROUND; - if (grade <= -0.001) - a = NormalizeAngle( a+180.0 ); - else if ( grade < 0.001 ) - style = BOX_BOX_BACKGROUND; - elev->u.height = grade; - } else { - elevStr = "????%%"; - } - break; - case ELEV_DEF: - elevStr = FormatDistance( elev->u.height); - break; - case ELEV_STATION: - elevStr = elev->u.name; - break; - default: - return; + DrawLine( d, p0, p1, (drawUnconnectedEndPt>0)?4:0, + (color==wDrawColorWhite)?color:(drawUnconnectedEndPt>1)?exceptionColor:color ); } - coOrd startLine = pp, endLine = pp; - pp.x += elev->doff.x; - pp.y += elev->doff.y; - if (color==drawColorPreviewSelected) { - Translate(&endLine,pp,FindAngle(pp,startLine),descriptionFontSize/d->dpi); - DrawLine( d, startLine, endLine, 0, color ); - } - DrawBoxedString( style, d, pp, elevStr, fp, (wFontSize_t)descriptionFontSize, color, a ); - } + /** * Draw track endpoints. The correct track endpoint (connected, unconnected etc.) * is drawn to the track. In case the endpoint is on the transition into a @@ -3219,10 +3002,10 @@ EXPORT void DrawEndElev( drawCmd_p d, track_p trk, EPINX_T ep, wDrawColor color */ EXPORT void DrawEndPt( - drawCmd_p d, - track_p trk, - EPINX_T ep, - wDrawColor color) + drawCmd_p d, + track_p trk, + EPINX_T ep, + wDrawColor color) { coOrd p; ANGLE_T a; @@ -3234,24 +3017,30 @@ EXPORT void DrawEndPt( wDrawWidth width; wDrawWidth width2; - if((d->options & (DC_SIMPLE | DC_SEGTRACK)) != 0) + if((d->options & (DC_SIMPLE | DC_SEGTRACK)) != 0) { return; - if(trk && QueryTrack(trk,Q_NODRAWENDPT)) + } + if(trk && QueryTrack(trk,Q_NODRAWENDPT)) { return; - if(trk == NULL || ep < 0) + } + if(trk == NULL || ep < 0) { return; + } // line width for the tunnel portal and bridge parapets, make sure it is rounded correctly width2 = (wDrawWidth)round((2.0 * d->dpi) / BASE_DPI); - if ((d->options&DC_PRINT) && (d->dpi>2*BASE_DPI)) + if ((d->options&DC_PRINT) && (d->dpi>2*BASE_DPI)) { width2 = (wDrawWidth)round(d->dpi / BASE_DPI); + } - if(color == wDrawColorBlack) + if(color == wDrawColorBlack) { color = normalColor; + } - if(((d->options & DC_PRINT) ? (labelScale * 2 + 1) : labelScale) >= d->scale) + if(((d->options & DC_PRINT) ? (labelScale * 2 + 1) : labelScale) >= d->scale) { DrawEndElev(d,trk,ep,color); + } trk1 = GetTrkEndTrk(trk,ep); p = GetTrkEndPos(trk,ep); @@ -3264,15 +3053,14 @@ EXPORT void DrawEndPt( } sepBoundary = FALSE; - if(d->scale < ((d->options & DC_PRINT) ? (twoRailScale * 2 + 1) : twoRailScale)) - { - // return; - - if(inDrawTracks && (d->options & DC_PRINT) == 0 && importTrack == NULL && GetTrkSelected(trk) && (!GetTrkSelected(trk1))) { + if ( DrawTwoRails(d,1) ) { + if(inDrawTracks && (d->options & DC_PRINT) == 0 && importTrack == NULL + && GetTrkSelected(trk) && (!GetTrkSelected(trk1))) { DIST_T len; len = trackGauge * 2.0; - if(len < 0.10 * d->scale) + if(len < 0.10 * d->scale) { len = 0.10 * d->scale; + } long oldOptions = d->options; d->options &= ~DC_NOTSOLIDLINE; Translate(&p0,p,a + 45,len); @@ -3283,8 +3071,8 @@ EXPORT void DrawEndPt( DrawLine(d,p0,p1,2,selectedColor); d->options = oldOptions; sepBoundary = TRUE; - } - else if((d->options & DC_PRINT) == 0 && importTrack == NULL && (!GetTrkSelected(trk)) && GetTrkSelected(trk1)) { + } else if((d->options & DC_PRINT) == 0 && importTrack == NULL + && (!GetTrkSelected(trk)) && GetTrkSelected(trk1)) { sepBoundary = TRUE; } } @@ -3317,11 +3105,10 @@ EXPORT void DrawEndPt( } showBridge = 0; } - } - else if((!GetTrkVisible(trk)) && GetTrkVisible(trk1)) { + } else if((!GetTrkVisible(trk)) && GetTrkVisible(trk1)) { showBridge = 0; - } - else if(GetLayerVisible(GetTrkLayer(trk)) && !GetLayerVisible(GetTrkLayer(trk1))) { + } else if(GetLayerVisible(GetTrkLayer(trk)) + && !GetLayerVisible(GetTrkLayer(trk1))) { a -= 90.0; Translate(&p,p,a,trackGauge / 2.0); Translate(&p0,p,a - 135.0,trackGauge * 2.0); @@ -3330,21 +3117,20 @@ EXPORT void DrawEndPt( DrawLine(d,p0,p,width2,color); showBridge = 0; - } - else if(!GetLayerVisible(GetTrkLayer(trk)) && GetLayerVisible(GetTrkLayer(trk1))) { + } else if(!GetLayerVisible(GetTrkLayer(trk)) + && GetLayerVisible(GetTrkLayer(trk1))) { showBridge = 0; - } - else if(sepBoundary) { + } else if(sepBoundary) { ; - } - else if((drawEndPtV == 1 && (QueryTrack(trk,Q_DRAWENDPTV_1) || QueryTrack(trk1,Q_DRAWENDPTV_1))) || (drawEndPtV == 2)) { + } else if((drawEndPtV == 1 && (QueryTrack(trk,Q_DRAWENDPTV_1) + || QueryTrack(trk1,Q_DRAWENDPTV_1))) || (drawEndPtV == 2)) { Translate(&p0,p,a,trackGauge); width = 0; - if(d != &mapD && d != &tempD && (GetTrkEndOption(trk,ep) & EPOPT_GAPPED) != 0) + if(d != &mapD && d != &tempD && (GetTrkEndOption(trk,ep) & EPOPT_GAPPED) != 0) { width = (wDrawWidth)ceil(trackGauge * d->dpi / 2.0 / d->scale); + } DrawLine(d,p0,p,width,color); - } - else { + } else { ; } @@ -3360,10 +3146,10 @@ EXPORT void DrawEndPt( EXPORT void DrawEndPt2( - drawCmd_p d, - track_p trk, - EPINX_T ep, - wDrawColor color ) + drawCmd_p d, + track_p trk, + EPINX_T ep, + wDrawColor color ) { track_p trk1; EPINX_T ep1; @@ -3371,8 +3157,9 @@ EXPORT void DrawEndPt2( trk1 = GetTrkEndTrk( trk, ep ); if (trk1) { ep1 = GetEndPtConnectedToMe( trk1, trk ); - if (ep1>=0) + if (ep1>=0) { DrawEndPt( d, trk1, ep1, color ); + } } } @@ -3384,47 +3171,52 @@ EXPORT void DrawTracks( drawCmd_p d, DIST_T scale, coOrd orig, coOrd size ) coOrd lo, hi; BOOL_T doSelectRecount = FALSE; unsigned long time0 = wGetTimer(); - + inDrawTracks = TRUE; InfoCount( 0 ); TRK_ITERATE( trk ) { if ( (d->options&DC_PRINT) != 0 && - wPrintQuit() ) { + wPrintQuit() ) { inDrawTracks = FALSE; return; } - if ( GetTrkSelected(trk) && - ( (!GetLayerVisible(GetTrkLayer(trk))) || - (drawTunnel==0 && !GetTrkVisible(trk)) ) ) { + if ( GetTrkSelected(trk) && + ( (!GetLayerVisible(GetTrkLayer(trk))) || + (drawTunnel==0 && !GetTrkVisible(trk)) ) ) { ClrTrkBits( trk, TB_SELECTED ); doSelectRecount = TRUE; } GetBoundingBox( trk, &hi, &lo ); if ( OFF_D( orig, size, lo, hi ) || - (d != &mapD && !GetLayerVisible( GetTrkLayer(trk) ) ) || - (d == &mapD && !GetLayerOnMap( GetTrkLayer(trk) ) ) ) + (d != &mapD && !GetLayerVisible( GetTrkLayer(trk) ) ) || + (d == &mapD && !GetLayerOnMap( GetTrkLayer(trk) ) ) ) { continue; + } DrawTrack( trk, d, wDrawColorBlack ); count++; - if (count%10 == 0) + if (count%10 == 0) { InfoCount( count ); + } } if (d == &mainD) { for (inx=1; inx<trackCmds_da.cnt; inx++) - if (trackCmds(inx)->redraw != NULL) + if (trackCmds(inx)->redraw != NULL) { trackCmds(inx)->redraw(); - LOG( log_timedrawtracks, 1, ( "DrawTracks time = %lu mS\n", wGetTimer()-time0 ) ); + } + LOG( log_timedrawtracks, 1, ( "DrawTracks time = %lu mS\n", + wGetTimer()-time0 ) ); } InfoCount( trackCount ); inDrawTracks = FALSE; - if ( doSelectRecount ) + if ( doSelectRecount ) { SelectRecount(); + } } -EXPORT void DrawSelectedTracks( drawCmd_p d ) +EXPORT void DrawSelectedTracks( drawCmd_p d, BOOL_T all ) { track_cp trk; wIndex_t count; @@ -3433,11 +3225,12 @@ EXPORT void DrawSelectedTracks( drawCmd_p d ) InfoCount( 0 ); TRK_ITERATE( trk ) { - if ( GetTrkSelected( trk ) ) { + if ( (all && GetLayerVisible(GetTrkLayer(trk))) || GetTrkSelected( trk ) ) { DrawTrack( trk, d, wDrawColorBlack ); count++; - if (count%10 == 0) + if (count%10 == 0) { InfoCount( count ); + } } } InfoCount( trackCount ); @@ -3455,24 +3248,29 @@ EXPORT void HilightElevations( BOOL_T hilight ) DIST_T radius; radius = 0.05*mainD.scale; - if ( radius < trackGauge/2.0 ) + if ( radius < trackGauge/2.0 ) { radius = trackGauge/2.0; + } TRK_ITERATE( trk ) { - for (ep=0;ep<GetTrkEndPtCnt(trk);ep++) { - GetTrkEndElev( trk, ep, &mode, &elev ); /* TRACKDEP */ + for (ep=0; ep<GetTrkEndPtCnt(trk); ep++) { + GetTrkEndElev( trk, ep, &mode, &elev ); if ((mode&ELEV_MASK)==ELEV_DEF || (mode&ELEV_MASK)==ELEV_IGNORE) { if ((trk1=GetTrkEndTrk(trk,ep)) != NULL && - GetTrkIndex(trk1) < GetTrkIndex(trk)) + GetTrkIndex(trk1) < GetTrkIndex(trk)) { continue; - if (drawTunnel == DRAW_TUNNEL_NONE && (!GetTrkVisible(trk)) && (trk1==NULL||!GetTrkVisible(trk1)) ) + } + if (drawTunnel == DRAW_TUNNEL_NONE && (!GetTrkVisible(trk)) && (trk1==NULL + ||!GetTrkVisible(trk1)) ) { continue; + } if ((!GetLayerVisible(GetTrkLayer(trk))) && - (trk1==NULL||!GetLayerVisible(GetTrkLayer(trk1)))) + (trk1==NULL||!GetLayerVisible(GetTrkLayer(trk1)))) { continue; + } pos = GetTrkEndPos(trk,ep); if ( !OFF_MAIND( pos, pos ) ) { DrawFillCircle( &tempD, pos, radius, - ((mode&ELEV_MASK)==ELEV_DEF?elevColorDefined:elevColorIgnore) ); + ((mode&ELEV_MASK)==ELEV_DEF?elevColorDefined:elevColorIgnore) ); } } } @@ -3483,7 +3281,7 @@ EXPORT void HilightElevations( BOOL_T hilight ) EXPORT void HilightSelectedEndPt( BOOL_T show, track_p trk, EPINX_T ep ) { coOrd pos; - if (!trk || (ep==-1)) return; + if (!trk || (ep==-1)) { return; } pos = GetTrkEndPos( trk, ep ); if ( show == TRUE ) { pos = GetTrkEndPos( trk, ep ); @@ -3505,15 +3303,17 @@ EXPORT void LabelLengths( drawCmd_p d, track_p trk, wDrawColor color ) char * msg; coOrd textsize; - if ((labelEnable&LABELENABLE_LENGTHS)==0) + if ((labelEnable&LABELENABLE_LENGTHS)==0) { return; + } fp = wStandardFont( F_HELV, FALSE, FALSE ); fs = (float)descriptionFontSize/d->scale; for (i=0; i<GetTrkEndPtCnt(trk); i++) { p0 = GetTrkEndPos( trk, i ); dist = GetFlexLength( trk, i, &p1 ); - if (dist < 0.1) + if (dist < 0.1) { continue; + } if (dist < 3.0) { p0.x = (p0.x+p1.x)/2.0; p0.y = (p0.y+p1.y)/2.0; @@ -3528,8 +3328,10 @@ EXPORT void LabelLengths( drawCmd_p d, track_p trk, wDrawColor color ) } } -EXPORT void AddTrkDetails(drawCmd_p d,track_p trk,coOrd pos, DIST_T length, wDrawColor color) { - #define DESC_LENGTH 6.0; +EXPORT void AddTrkDetails(drawCmd_p d,track_p trk,coOrd pos, DIST_T length, + wDrawColor color) +{ +#define DESC_LENGTH 6.0; double division; division = length/DESC_LENGTH; division = ceil(division); @@ -3540,44 +3342,47 @@ EXPORT void AddTrkDetails(drawCmd_p d,track_p trk,coOrd pos, DIST_T length, wDra tt.pos = GetTrkEndPos(trk,0); dynArr_t pos_array; - pos_array.max = 0; - pos_array.cnt = 0; - pos_array.ptr = NULL; + DYNARR_INIT( pos_angle_t, pos_array ); typedef struct { - coOrd pos; - ANGLE_T angle; - } pos_angle_t; + coOrd pos; + ANGLE_T angle; + } pos_angle_t; DYNARR_SET(pos_angle_t,pos_array,(int)division+1); DYNARR_N(pos_angle_t,pos_array,0).pos = GetTrkEndPos(trk,0); - DYNARR_N(pos_angle_t,pos_array,0).angle = NormalizeAngle(GetTrkEndAngle(trk,0)+180.0); - for (int i=1;i<pos_array.cnt;i++) { + DYNARR_N(pos_angle_t,pos_array,0).angle = NormalizeAngle(GetTrkEndAngle(trk, + 0)+180.0); + for (int i=1; i<pos_array.cnt; i++) { tt.dist = dist; dist1 = dist; TraverseTrack(&tt,&dist1); - if (dist1 > 0 || tt.trk != trk || IsClose(FindDistance(tt.pos,GetTrkEndPos(trk,1)))) { + if (dist1 > 0 || tt.trk != trk + || IsClose(FindDistance(tt.pos,GetTrkEndPos(trk,1)))) { DYNARR_N(pos_angle_t,pos_array,i).pos = GetTrkEndPos(trk,1); DYNARR_N(pos_angle_t,pos_array,i).angle = GetTrkEndAngle(trk,1); - pos_array.cnt = i; + // Truncate pos_array + DYNARR_SET( pos_angle_t, pos_array, i+1 ); break; } DYNARR_N(pos_angle_t,pos_array,i).pos = tt.pos; DYNARR_N(pos_angle_t,pos_array,i).angle = tt.angle; } message[0]='\0'; - for (int i=0;i<pos_array.cnt;i++) { - if (i==pos_array.cnt-1) - sprintf( message, _("%s[%0.2f,%0.2f] A%0.2f"),message,PutDim(DYNARR_N(pos_angle_t,pos_array,i).pos.x),PutDim(DYNARR_N(pos_angle_t,pos_array,i).pos.y),DYNARR_N(pos_angle_t,pos_array,i).angle ); - else - sprintf( message, _("%s[%0.2f,%0.2f] A%0.2f\n"),message,PutDim(DYNARR_N(pos_angle_t,pos_array,i).pos.x),PutDim(DYNARR_N(pos_angle_t,pos_array,i).pos.y),DYNARR_N(pos_angle_t,pos_array,i).angle); + for (int i=0; i<pos_array.cnt; i++) { + if (i==pos_array.cnt-1) { + sprintf( &message[strlen(message)], _("[%0.2f,%0.2f] A%0.2f"), + PutDim(DYNARR_N(pos_angle_t,pos_array,i).pos.x),PutDim(DYNARR_N(pos_angle_t, + pos_array,i).pos.y),DYNARR_N(pos_angle_t,pos_array,i).angle ); + } else { + sprintf( &message[strlen(message)], _("[%0.2f,%0.2f] A%0.2f\n"), + PutDim(DYNARR_N(pos_angle_t,pos_array,i).pos.x),PutDim(DYNARR_N(pos_angle_t, + pos_array,i).pos.y),DYNARR_N(pos_angle_t,pos_array,i).angle); + } } wFont_p fp = wStandardFont( F_TIMES, FALSE, FALSE ); - DrawBoxedString(BOX_BOX,d,pos,message,fp,(wFontSize_t)descriptionFontSize,color,0.0); - if (pos_array.ptr) - MyFree(pos_array.ptr); - pos_array.ptr = 0; - pos_array.max = 0; - pos_array.cnt = 0; + DrawBoxedString(BOX_BOX,d,pos,message,fp,(wFontSize_t)descriptionFontSize,color, + 0.0); + DYNARR_FREE( pos_angle_t, pos_array ); } diff --git a/app/bin/track.h b/app/bin/track.h index 32626c5..fdc7909 100644 --- a/app/bin/track.h +++ b/app/bin/track.h @@ -1,5 +1,5 @@ /** \file track.h - * + * */ /* XTrkCad - Model Railroad CAD @@ -17,24 +17,36 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef TRACK_H #define TRACK_H #include "common.h" +#include "trkseg.h" + extern TRKTYP_T T_NOTRACK; +extern TRKTYP_T T_TURNOUT; +extern TRKTYP_T T_STRUCTURE; +extern TRKTYP_T T_BEZIER; +extern TRKTYP_T T_BZRLIN; +extern TRKTYP_T T_CORNU; struct track_t ; typedef struct track_t * track_p; typedef struct track_t * track_cp; -extern track_p tempTrack; extern wIndex_t trackCount; +extern DIST_T trackGauge; +extern DIST_T minLength; +extern DIST_T connectDistance; +extern ANGLE_T connectAngle; +extern long twoRailScale; extern wBool_t bFreeTrack; extern long colorTrack; extern long colorDraw; + extern long drawTunnel; extern long drawEndPtV; extern long drawUnconnectedEndPt; @@ -55,8 +67,8 @@ extern wDrawColor exceptionColor; #define TIEDRAWMODE_SOLID (2) extern long tieDrawMode; extern wDrawColor tieColor; - - +extern wDrawColor bridgeColor; +extern wDrawColor roadbedColor; extern TRKINX_T max_index; typedef signed char * PATHPTR_T; @@ -78,29 +90,29 @@ typedef enum { curveTypeNone, curveTypeCurve, curveTypeStraight, curveTypeBezier #define PARAMS_LINE (7) //Called on Lines typedef struct { - curveType_e type; //Straight, Curve, Bezier, Cornu - EPINX_T ep; //End point that is nearby pos - dynArr_t nodes; //Array of nodes -> PARAMS_PARALLEL only - DIST_T len; //Length of track - ANGLE_T angle; //Angle at end of track - coOrd lineOrig; //Start of straight - coOrd lineEnd; //End of Straight (or zero for Turnout) - coOrd arcP; //center or zero - DIST_T arcR; //radius or zero - ANGLE_T arcA0, arcA1; //Start angle and angular length (clockwise) - long helixTurns; - ANGLE_T track_angle; - BOOL_T circleOrHelix; //Track is circle or Helix - coOrd bezierPoints[4]; //Bezier Ends and CPs - coOrd cornuEnd[2]; //Cornu Ends - ANGLE_T cornuAngle[2]; //Angle at Cornu Ends - DIST_T cornuRadius[2]; //Radius at Cornu Ends - coOrd cornuCenter[2]; //Center at Cornu Ends - coOrd ttcenter; //Turntable - DIST_T ttradius; //Turntable - coOrd centroid; //Turnout - - } trackParams_t; + curveType_e type; //Straight, Curve, Bezier, Cornu + EPINX_T ep; //End point that is nearby pos + dynArr_t nodes; //Array of nodes -> PARAMS_PARALLEL only + DIST_T len; //Length of track + ANGLE_T angle; //Angle at end of track + coOrd lineOrig; //Start of straight + coOrd lineEnd; //End of Straight (or zero for Turnout) + coOrd arcP; //center or zero + DIST_T arcR; //radius or zero + ANGLE_T arcA0, arcA1; //Start angle and angular length (clockwise) + long helixTurns; + ANGLE_T track_angle; + BOOL_T circleOrHelix; //Track is circle or Helix + coOrd bezierPoints[4]; //Bezier Ends and CPs + coOrd cornuEnd[2]; //Cornu Ends + ANGLE_T cornuAngle[2]; //Angle at Cornu Ends + DIST_T cornuRadius[2]; //Radius at Cornu Ends + coOrd cornuCenter[2]; //Center at Cornu Ends + coOrd ttcenter; //Turntable + DIST_T ttradius; //Turntable + coOrd centroid; //Turnout + +} trackParams_t; #define Q_CANNOT_BE_ON_END (1) #define Q_IGNORE_EASEMENT_ON_EXTEND (2) @@ -135,293 +147,65 @@ typedef struct { #define Q_GET_NODES (32) typedef struct traverseTrack_t { - track_p trk; // IN Current Track OUT Next Track - DIST_T length; // IN How far to go - DIST_T dist; // OUT how far left = 0 if found - coOrd pos; // IN/OUT - where we are, where we will be // IN/OUT - where we are now - ANGLE_T angle; // IN/OUT - angle now - } traverseTrack_t; + track_p trk; // IN Current Track OUT Next Track + DIST_T length; // IN How far to go + DIST_T dist; // OUT how far left = 0 if found + coOrd pos; // IN/OUT - where we are, where we will be // IN/OUT - where we are now + ANGLE_T angle; // IN/OUT - angle now +} traverseTrack_t; typedef struct traverseTrack_t *traverseTrack_p; typedef struct { - char * name; - void (*draw)( track_p, drawCmd_p, wDrawColor ); - DIST_T (*distance)( track_p, coOrd * ); - void (*describe)( track_p, char * line, CSIZE_T len ); - void (*deleteTrk)( track_p ); - BOOL_T (*write)( track_p, FILE * ); - BOOL_T (*read)( char * ); - void (*move)( track_p, coOrd ); - void (*rotate)( track_p, coOrd, ANGLE_T ); - void (*rescale)( track_p, FLOAT_T ); - BOOL_T (*audit)( track_p, char * ); - ANGLE_T (*getAngle)( track_p, coOrd, EPINX_T *, EPINX_T * ); - BOOL_T (*split)( track_p, coOrd, EPINX_T, track_p *, EPINX_T *, EPINX_T * ); - BOOL_T (*traverse)( traverseTrack_p, DIST_T * ); - BOOL_T (*enumerate)( track_p ); - void (*redraw)( void ); - BOOL_T (*trim)( track_p, EPINX_T, DIST_T, coOrd endpos, ANGLE_T angle, DIST_T endradius, coOrd endcenter ); - BOOL_T (*merge)( track_p, EPINX_T, track_p, EPINX_T ); - STATUS_T (*modify)( track_p, wAction_t, coOrd ); - DIST_T (*getLength)( track_p ); - BOOL_T (*getTrackParams)( int, track_p, coOrd pos, trackParams_t * ); - BOOL_T (*moveEndPt)( track_p *, EPINX_T *, coOrd, DIST_T ); - BOOL_T (*query)( track_p, int ); - void (*ungroup)( track_p ); - void (*flip)( track_p, coOrd, ANGLE_T ); - void (*drawPositionIndicator)( track_p, wDrawColor ); - void (*advancePositionIndicator)( track_p, coOrd, coOrd *, ANGLE_T * ); - BOOL_T (*checkTraverse)( track_p, coOrd ); - BOOL_T (*makeParallel)( track_p, coOrd, DIST_T, DIST_T, track_p *, coOrd *, coOrd *, BOOL_T ); - void (*drawDesc)( track_p, drawCmd_p, wDrawColor ); - BOOL_T (*rebuildSegs)(track_p); - BOOL_T (*replayData)(track_p, void *,long ); - BOOL_T (*storeData)(track_p, void **,long *); - void (*activate)(track_p); - wBool_t (*compare)( track_cp, track_cp ); - } trackCmd_t; + char * name; + void (*draw)( track_p, drawCmd_p, wDrawColor ); + DIST_T (*distance)( track_p, coOrd * ); + void (*describe)( track_p, char * line, CSIZE_T len ); + void (*deleteTrk)( track_p ); + BOOL_T (*write)( track_p, FILE * ); + BOOL_T (*read)( char * ); + void (*move)( track_p, coOrd ); + void (*rotate)( track_p, coOrd, ANGLE_T ); + void (*rescale)( track_p, FLOAT_T ); + BOOL_T (*audit)( track_p, char * ); + ANGLE_T (*getAngle)( track_p, coOrd, EPINX_T *, EPINX_T * ); + BOOL_T (*split)( track_p, coOrd, EPINX_T, track_p *, EPINX_T *, EPINX_T * ); + BOOL_T (*traverse)( traverseTrack_p, DIST_T * ); + BOOL_T (*enumerate)( track_p ); + void (*redraw)( void ); + BOOL_T (*trim)( track_p, EPINX_T, DIST_T, coOrd endpos, ANGLE_T angle, + DIST_T endradius, coOrd endcenter ); + BOOL_T (*merge)( track_p, EPINX_T, track_p, EPINX_T ); + STATUS_T (*modify)( track_p, wAction_t, coOrd ); + DIST_T (*getLength)( track_p ); + BOOL_T (*getTrackParams)( int, track_p, coOrd pos, trackParams_t * ); + BOOL_T (*moveEndPt)( track_p *, EPINX_T *, coOrd, DIST_T ); + BOOL_T (*query)( track_p, int ); + void (*ungroup)( track_p ); + void (*flip)( track_p, coOrd, ANGLE_T ); + void (*drawPositionIndicator)( track_p, wDrawColor ); + void (*advancePositionIndicator)( track_p, coOrd, coOrd *, ANGLE_T * ); + BOOL_T (*checkTraverse)( track_p, coOrd ); + BOOL_T (*makeParallel)( track_p, coOrd, DIST_T, DIST_T, track_p *, coOrd *, + coOrd *, BOOL_T ); + void (*drawDesc)( track_p, drawCmd_p, wDrawColor ); + BOOL_T (*rebuildSegs)(track_p); + BOOL_T (*replayData)(track_p, void *,long ); + BOOL_T (*storeData)(track_p, void **,long *); + void (*activate)(track_p); + wBool_t (*compare)( track_cp, track_cp ); +} trackCmd_t; #define NOELEV (-10000.0) typedef enum { ELEV_NONE, ELEV_DEF, ELEV_COMP, ELEV_GRADE, ELEV_IGNORE, ELEV_STATION } elevMode_e; #define ELEV_MASK 0x07 #define ELEV_VISIBLE 0x08 -typedef struct { - int option; - coOrd doff; - union { - DIST_T height; - char * name; - } u; - BOOL_T cacheSet; - double cachedElev; - double cachedGrade; - } elev_t; #define EPOPT_GAPPED (1L<<0) -typedef struct trkEndPt_t { - coOrd pos; - ANGLE_T angle; - TRKINX_T index; - track_p track; - elev_t elev; - long option; - } trkEndPt_t; + +struct trkEndPt_t; typedef struct trkEndPt_t * trkEndPt_p; -extern dynArr_t tempEndPts_da; -#define tempEndPts(N) DYNARR_N( trkEndPt_t, tempEndPts_da, N ) - -typedef enum { FREEFORM, RECTANGLE, POLYLINE -} PolyType_e; - - -typedef struct trkSeg_t { - char type; - wDrawColor color; - DIST_T width; - dynArr_t bezSegs; //placed here to avoid overwrites - union { - struct { - coOrd pos[4]; - ANGLE_T angle; - long option; - } l; - struct { - coOrd pos[4]; - ANGLE_T angle0; - ANGLE_T angle3; - DIST_T minRadius; - DIST_T radius0; - DIST_T radius3; - DIST_T length; - } b; - struct { - coOrd center; - ANGLE_T a0, a1; - DIST_T radius; - } c; - struct { - coOrd pos; - ANGLE_T angle; - DIST_T R, L; - DIST_T l0, l1; - unsigned int flip:1; - unsigned int negate:1; - unsigned int Scurve:1; - } j; - struct { - coOrd pos; - ANGLE_T angle; - wFont_p fontP; - FONTSIZE_T fontSize; - BOOL_T boxed; - char * string; - } t; - struct { - int cnt; - pts_t * pts; - coOrd orig; - ANGLE_T angle; - PolyType_e polyType; - } p; - } u; - } trkSeg_t; -typedef struct trkSeg_t * trkSeg_p; - -#define SEG_STRTRK ('S') -#define SEG_CRVTRK ('C') -#define SEG_BEZTRK ('W') -#define SEG_STRLIN ('L') -#define SEG_CRVLIN ('A') -#define SEG_BEZLIN ('H') -#define SEG_JNTTRK ('J') -#define SEG_FILCRCL ('G') -#define SEG_POLY ('Y') -#define SEG_FILPOLY ('F') -#define SEG_TEXT ('Z') -#define SEG_UNCEP ('E') -#define SEG_CONEP ('T') -#define SEG_PATH ('P') -#define SEG_SPEC ('X') -#define SEG_CUST ('U') -#define SEG_DOFF ('D') -#define SEG_BENCH ('B') -#define SEG_DIMLIN ('M') -#define SEG_TBLEDGE ('Q') - -#define IsSegTrack( S ) ( (S)->type == SEG_STRTRK || (S)->type == SEG_CRVTRK || (S)->type == SEG_JNTTRK || (S)->type == SEG_BEZTRK) - -extern dynArr_t tempSegs_da; - -#define tempSegs(N) DYNARR_N( trkSeg_t, tempSegs_da, N ) - -extern char tempSpecial[4096]; -extern char tempCustom[4096]; - -void ComputeCurvedSeg( - trkSeg_p s, - DIST_T radius, - coOrd p0, - coOrd p1 ); - -coOrd GetSegEndPt( - trkSeg_p segPtr, - EPINX_T ep, - BOOL_T bounds, - ANGLE_T * ); - -void GetTextBounds( coOrd, ANGLE_T, char *, FONTSIZE_T, coOrd *, coOrd * ); -void GetSegBounds( coOrd, ANGLE_T, wIndex_t, trkSeg_p, coOrd *, coOrd * ); -void MoveSegs( wIndex_t, trkSeg_p, coOrd ); -void RotateSegs( wIndex_t, trkSeg_p, coOrd, ANGLE_T ); -void FlipSegs( wIndex_t, trkSeg_p, coOrd, ANGLE_T ); -void RescaleSegs( wIndex_t, trkSeg_p, DIST_T, DIST_T, DIST_T ); -void CloneFilledDraw( wIndex_t, trkSeg_p, BOOL_T ); -void FreeFilledDraw( wIndex_t, trkSeg_p ); -DIST_T DistanceSegs( coOrd, ANGLE_T, wIndex_t, trkSeg_p, coOrd *, wIndex_t * ); -void DrawDimLine( drawCmd_p, coOrd, coOrd, char *, wFontSize_t, FLOAT_T, wDrawWidth, wDrawColor, long ); -void DrawSegs( - drawCmd_p d, - coOrd orig, - ANGLE_T angle, - trkSeg_p segPtr, - wIndex_t segCnt, - DIST_T trackGauge, - wDrawColor color ); -void DrawSegsO( - drawCmd_p d, - track_p trk, - coOrd orig, - ANGLE_T angle, - trkSeg_p segPtr, - wIndex_t segCnt, - DIST_T trackGauge, - wDrawColor color, - long options ); -ANGLE_T GetAngleSegs( wIndex_t, trkSeg_p, coOrd *, wIndex_t *, DIST_T *, BOOL_T *, wIndex_t *, BOOL_T * ); -void RecolorSegs( wIndex_t, trkSeg_p, wDrawColor ); - -BOOL_T ReadSegs( void ); -BOOL_T WriteSegs( FILE * f, wIndex_t segCnt, trkSeg_p segs ); -BOOL_T WriteSegsEnd(FILE * f, wIndex_t segCnt, trkSeg_p segs, BOOL_T writeEnd); -typedef union { - struct { - coOrd pos; /* IN the point to get to */ - ANGLE_T angle; /* IN is the angle that the object starts at (-ve for forwards) */ - DIST_T dist; /* OUT is how far it is along the track to get to pos*/ - BOOL_T backwards; /* OUT which way are we going? */ - BOOL_T reverse_seg; /* OUT the seg is backwards curve */ - BOOL_T negative; /* OUT the curve is negative */ - int BezSegInx; /* OUT for Bezier Seg - the segment we are on in Bezier */ - BOOL_T segs_backwards; /* OUT for Bezier Seg - the direction of the overall Bezier */ - } traverse1; // Find dist between pos and end of track that starts with angle set backwards - struct { - BOOL_T segDir; /* IN Direction to go in this seg*/ - int BezSegInx; /* IN for Bezier Seg which element to start with*/ - BOOL_T segs_backwards; /* IN for Bezier Seg which way to go down the array*/ - DIST_T dist; /* IN/OUT In = distance to go, Out = distance left */ - coOrd pos; /* OUT = point reached if dist = 0 */ - ANGLE_T angle; /* OUT = angle at point */ - } traverse2; //Return distance left (or 0) and angle and pos when going dist from segDir end - struct { - int first, last; /* IN */ - ANGLE_T side; - DIST_T roadbedWidth; - wDrawWidth rbw; - coOrd orig; - ANGLE_T angle; - wDrawColor color; - drawCmd_p d; - } drawRoadbedSide; - struct { - coOrd pos1; /* IN pos to find */ - DIST_T dd; /* OUT distance from nearest point in seg to input pos */ - } distance; - struct { - track_p trk; /* OUT */ - EPINX_T ep[2]; - } newTrack; - struct { - DIST_T length; /* OUT */ - } length; - struct { - coOrd pos; /* IN */ - DIST_T length[2]; /* OUT */ - trkSeg_t newSeg[2]; - } split; - struct { - coOrd pos; /* IN Pos to find nearest to - OUT found pos on curve*/ - ANGLE_T angle; /* OUT angle at pos - (-ve if backwards)*/ - BOOL_T negative_radius; /* OUT Radius <0? */ - BOOL_T backwards; /* OUT Seg is backwards */ - DIST_T radius; /* OUT radius at pos */ - coOrd center; /* OUT center of curvature at pos (0 = straight)*/ - int bezSegInx; /* OUT if a bezier proc, the index of the sub segment */ - } getAngle; // Get pos on seg nearest, angle at that (-ve for forwards) - } segProcData_t, *segProcData_p; -typedef enum { - SEGPROC_TRAVERSE1, - SEGPROC_TRAVERSE2, - SEGPROC_DRAWROADBEDSIDE, - SEGPROC_DISTANCE, - SEGPROC_FLIP, - SEGPROC_NEWTRACK, - SEGPROC_LENGTH, - SEGPROC_SPLIT, - SEGPROC_GETANGLE - } segProc_e; -void SegProc( segProc_e, trkSeg_p, segProcData_p ); -void StraightSegProc( segProc_e, trkSeg_p, segProcData_p ); -void CurveSegProc( segProc_e, trkSeg_p, segProcData_p ); -void JointSegProc( segProc_e, trkSeg_p, segProcData_p ); -void BezierSegProc( segProc_e, trkSeg_p, segProcData_p ); //Used in Cornu join -void CleanSegs( dynArr_t *); -void CopyPoly(trkSeg_p seg_p, wIndex_t segCnt); -wBool_t CompareSegs( trkSeg_p, int, trkSeg_p, int ); - -/* debug.c */ -void SetDebug( char * ); /*Remember to add bits to trackx.h if adding here */ @@ -435,46 +219,14 @@ void SetDebug( char * ); #define TB_CARATTACHED (1<<7) #define TB_NOTIES (1<<8) #define TB_BRIDGE (1<<9) -#define TB_SELREDRAW (1<<10) +#define TB_ROADBED (1<<10) +#define TB_SELREDRAW (1<<11) // Track has been undrawn, don't draw it on Redraw -#define TB_UNDRAWN (1<<11) -#define TB_DETAILDESC (1<<12) +#define TB_UNDRAWN (1<<12) +#define TB_DETAILDESC (1<<13) #define TB_TEMPBITS (TB_PROFILEPATH|TB_PROCESSED|TB_UNDRAWN) /* track.c */ -#ifdef FASTTRACK -#include "trackx.h" -#define GetTrkIndex( T ) ((T)->index) -#define GetTrkType( T ) ((T)->type) -#define GetTrkScale( T ) ((T)->scale) -#define SetTrkScale( T, S ) (T)->scale = ((char)(S)) -/*#define GetTrkSelected( T ) ((T)->bits&TB_SELECTED)*/ -/*#define GetTrkVisible( T ) ((T)->bits&TB_VISIBLE)*/ -/*#define SetTrkVisible( T, V ) ((V) ? (T)->bits |= TB_VISIBLE : (T)->bits &= !TB_VISIBLE)*/ -#define GetTrkLayer( T ) ((T)->layer) -#define SetBoundingBox( T, HI, LO ) \ - (T)->hi.x = (float)(HI).x; (T)->hi.y = (float)(HI).y; (T)->lo.x = (float)(LO).x; (T)->lo.x; (T)->lo.x = (float)(LO).y = (float)(LO).y -#define GetBoundingBox( T, HI, LO ) \ - (HI)->x = (POS_T)(T)->hi.x; (HI)->y = (POS_T)(T)->hi.y; (LO)->x = (POS_T)(T)->lo.x; (LO)->y = (POS_T)(T)->lo.y; -#define GetTrkEndPtCnt( T ) ((T)->endCnt) -#define SetTrkEndPoint( T, I, PP, AA ) \ - Assert((T)->endPt[I].track); \ - (T)->endPt[I].pos = PP; \ - (T)->endPt[I].angle = AA -#define GetTrkEndTrk( T, I ) ((T)->endPt[I].track) -#define GetTrkEndPos( T, I ) ((T)->endPt[I].pos) -#define GetTrkEndPosXY( T, I ) PutDim((T)->endPt[I].pos.x), PutDim((T)->endPt[I].pos.y) -#define GetTrkEndAngle( T, I ) ((T)->endPt[I].angle) -#define GetTrkEndOption( T, I ) ((T)->endPt[I].option) -#define SetTrkEndOption( T, I, O ) ((T)->endPt[I].option=O) -#define GetTrkExtraData( T, TT ) ((T)->extraData) -#define GetTrkWidth( T ) (int)((T)->width) -#define SetTrkWidth( T, W ) (T)->width = (unsigned int)(W) -#define GetTrkBits(T) ((T)?((T)->bits):0) -#define SetTrkBits(T,V) ((T)->bits|=(V)) -#define ClrTrkBits(T,V) ((T)->bits&=~(V)) -#define IsTrackDeleted(T) ((T)->deleted) -#else TRKINX_T GetTrkIndex( track_p ); TRKTYP_T GetTrkType( track_p ); SCALEINX_T GetTrkScale( track_p ); @@ -483,46 +235,40 @@ BOOL_T GetTrkSelected( track_p ); BOOL_T GetTrkVisible( track_p ); void SetTrkVisible( track_p, BOOL_T ); unsigned int GetTrkLayer( track_p ); +tieData_t GetTrkTieData(track_p); void SetBoundingBox( track_p, coOrd, coOrd ); void GetBoundingBox( track_p, coOrd*, coOrd* ); EPINX_T GetTrkEndPtCnt( track_p ); -void SetTrkEndPoint( track_p, EPINX_T, coOrd, ANGLE_T ); -track_p GetTrkEndTrk( track_p, EPINX_T ); -coOrd GetTrkEndPos( track_p, EPINX_T ); -#define GetTrkEndPosXY( trk, ep ) PutDim(GetTrkEndPos(trk,ep).x), PutDim(GetTrkEndPos(trk,ep).y) -ANGLE_T GetTrkEndAngle( track_p, EPINX_T ); -long GetTrkEndOption( track_p, EPINX_T ); -long SetTrkEndOption( track_p, EPINX_T, long ); +trkEndPt_p GetTrkEndPt( track_cp, EPINX_T ); struct extraDataBase_t * GetTrkExtraData( track_p, TRKTYP_T ); +void ResizeExtraData( track_p trk, CSIZE_T newSize ); int GetTrkWidth( track_p ); void SetTrkWidth( track_p, int ); int GetTrkBits( track_p ); int SetTrkBits( track_p, int ); int ClrTrkBits( track_p, int ); BOOL_T IsTrackDeleted( track_p ); -#endif +void TrackInsertLayer( int ); +void TrackDeleteLayer( int ); + +track_p GetFirstTrack(); +track_p GetNextTrack( track_p ); + +#define TRK_ITERATE(TRK) for (TRK=GetFirstTrack(); TRK!=NULL; TRK=GetNextTrack(TRK) ) if (!IsTrackDeleted(TRK)) + #define GetTrkSelected(T) (GetTrkBits(T)&TB_SELECTED) #define GetTrkVisible(T) (GetTrkBits(T)&TB_VISIBLE) #define GetTrkNoTies(T) (GetTrkBits(T)&TB_NOTIES) #define GetTrkBridge(T) ((T)?GetTrkBits(T)&TB_BRIDGE:0) +#define GetTrkRoadbed(T) ((T)?GetTrkBits(T)&TB_ROADBED:0) #define SetTrkVisible(T,V) ((V)?SetTrkBits(T,TB_VISIBLE):ClrTrkBits(T,TB_VISIBLE)) #define SetTrkNoTies(T,V) ((V)?SetTrkBits(T,TB_NOTIES):ClrTrkBits(T,TB_NOTIES)) #define SetTrkBridge(T,V) ((V)?SetTrkBits(T,TB_BRIDGE):ClrTrkBits(T,TB_BRIDGE)) +#define SetTrkRoadbed(T,V) ((V)?SetTrkBits(T,TB_ROADBED):ClrTrkBits(T,TB_ROADBED)) int ClrAllTrkBits( int ); int ClrAllTrkBitsRedraw( int, wBool_t ); -void GetTrkEndElev( track_p trk, EPINX_T e, int *option, DIST_T *height ); -void SetTrkEndElev( track_p, EPINX_T, int, DIST_T, char * ); -int GetTrkEndElevMode( track_p, EPINX_T ); -int GetTrkEndElevUnmaskedMode( track_p, EPINX_T ); -DIST_T GetTrkEndElevHeight( track_p, EPINX_T ); -BOOL_T GetTrkEndElevCachedHeight (track_p trk, EPINX_T e, DIST_T *height, DIST_T *grade); -void SetTrkEndElevCachedHeight ( track_p trk, EPINX_T e, DIST_T height, DIST_T grade); -char * GetTrkEndElevStation( track_p, EPINX_T ); -#define EndPtIsDefinedElev( T, E ) (GetTrkEndElevMode(T,E)==ELEV_DEF) -#define EndPtIsIgnoredElev( T, E ) (GetTrkEndElevMode(T,E)==ELEV_IGNORE) -#define EndPtIsStationElev( T, E ) (GetTrkEndElevMode(T,E)==ELEV_STATION) void SetTrkElev( track_p, int, DIST_T ); int GetTrkElevMode( track_p ); DIST_T GetTrkElev( track_p trk ); @@ -536,7 +282,6 @@ void CopyAttributes( track_p, track_p ); DIST_T GetTrkGauge( track_cp ); #define GetTrkScaleName( T ) GetScaleName(GetTrkScale(T)) void SetTrkEndPtCnt( track_p, EPINX_T ); -BOOL_T WriteEndPt( FILE *, track_cp, EPINX_T ); EPINX_T PickEndPoint( coOrd, track_cp ); EPINX_T PickUnconnectedEndPoint( coOrd, track_cp ); EPINX_T PickUnconnectedEndPointSilent( coOrd, track_cp ); @@ -593,7 +338,8 @@ wBool_t IsAngleClose( ANGLE_T, ANGLE_T ); wBool_t IsDistClose( DIST_T, DIST_T ); wBool_t IsWidthClose( DIST_T, DIST_T ); wBool_t IsColorClose( wDrawColor, wDrawColor ); -wBool_t CompareTrack( track_cp, track_cp ); +wBool_t CheckRegressionResult( long regressionVersion, char * sFileName, + wBool_t bQuiet ); void MoveTrack( track_p, coOrd ); void RotateTrack( track_p, coOrd, ANGLE_T ); @@ -607,7 +353,8 @@ EPINX_T GetNextTrkOnPath( track_p, EPINX_T ); #define FDE_UDF 1 #define FDE_END 2 int FindDefinedElev( track_p, EPINX_T, int, BOOL_T, DIST_T *, DIST_T *); -BOOL_T ComputeElev( track_p trk, EPINX_T ep, BOOL_T on_path, DIST_T * elev, DIST_T * grade, BOOL_T force); +BOOL_T ComputeElev( track_p trk, EPINX_T ep, BOOL_T on_path, DIST_T * elev, + DIST_T * grade, BOOL_T force); #define DTS_LEFT (1<<0) #define DTS_RIGHT (1<<1) @@ -618,49 +365,52 @@ BOOL_T ComputeElev( track_p trk, EPINX_T ep, BOOL_T on_path, DIST_T * elev, DIST #define DTS_DASHDOTDOT (1<<10) #define DTS_CENTERONLY (1<<11) -void DrawCurvedTrack( drawCmd_p, coOrd, DIST_T, ANGLE_T, ANGLE_T, track_cp, wDrawColor, long ); -void DrawStraightTrack( drawCmd_p, coOrd, coOrd, ANGLE_T, track_cp, wDrawColor, long ); +BOOL_T DrawTwoRails( drawCmd_p d, DIST_T factor ); +BOOL_T hasTrackCenterline( drawCmd_p d ); +void DrawCurvedTrack( drawCmd_p, coOrd, DIST_T, ANGLE_T, ANGLE_T, track_cp, + wDrawColor, long ); +void DrawStraightTrack( drawCmd_p, coOrd, coOrd, ANGLE_T, track_cp, wDrawColor, + long ); -void DrawStraightTies( drawCmd_p d, SCALEINX_T scaleInx, coOrd p0, coOrd p1, wDrawColor color ); +void DrawStraightTies( drawCmd_p d, tieData_t td, coOrd p0, coOrd p1, + wDrawColor color ); wBool_t DoDrawTies(drawCmd_p d, track_cp trk); -void DrawTie(drawCmd_p d, coOrd pos, ANGLE_T angle, DIST_T length, DIST_T width, wDrawColor color, BOOL_T solid); +void DrawTie(drawCmd_p d, coOrd pos, ANGLE_T angle, DIST_T length, DIST_T width, + wDrawColor color, BOOL_T solid); ANGLE_T GetAngleAtPoint( track_p, coOrd, EPINX_T *, EPINX_T * ); DIST_T GetTrkDistance( track_cp, coOrd *); track_p OnTrack( coOrd *, INT_T, BOOL_T ); -track_p OnTrackIgnore(coOrd *, INT_T, BOOL_T , track_p ); +track_p OnTrackIgnore(coOrd *, INT_T, BOOL_T, track_p ); track_p OnTrack2( coOrd *, INT_T, BOOL_T, BOOL_T, track_p ); void ComputeRectBoundingBox( track_p, coOrd, coOrd ); void ComputeBoundingBox( track_p ); -void DrawEndPt( drawCmd_p, track_p, EPINX_T, wDrawColor ); -void DrawEndPt2( drawCmd_p, track_p, EPINX_T, wDrawColor ); -void DrawEndElev( drawCmd_p, track_p, EPINX_T, wDrawColor ); +void DrawEndPt( drawCmd_p, track_p, EPINX_T, wDrawColor ); +void DrawEndPt2( drawCmd_p, track_p, EPINX_T, wDrawColor ); wDrawColor GetTrkColor( track_p, drawCmd_p ); void DrawTrack( track_cp, drawCmd_p, wDrawColor ); void DrawTracks( drawCmd_p, DIST_T, coOrd, coOrd ); void DrawNewTrack( track_cp ); void DrawOneTrack( track_cp, drawCmd_p ); void UndrawNewTrack( track_cp ); -void DrawSelectedTracks( drawCmd_p ); +void DrawSelectedTracks( drawCmd_p, BOOL_T ); void HilightElevations( BOOL_T ); void HilightSelectedEndPt( BOOL_T, track_p, EPINX_T ); -DIST_T EndPtDescriptionDistance( coOrd, track_p, EPINX_T, coOrd *, BOOL_T show_hidden, BOOL_T * hidden ); -STATUS_T EndPtDescriptionMove( track_p, EPINX_T, wAction_t, coOrd ); track_p FindTrack( TRKINX_T ); void ResolveIndex( void ); void RenumberTracks( void ); BOOL_T ReadTrack( char * ); BOOL_T WriteTracks( FILE *, wBool_t ); -BOOL_T ExportTracks( FILE * , coOrd *); +BOOL_T ExportTracks( FILE *, coOrd * ); void ImportStart( void ); -void ImportEnd( coOrd , wBool_t, wBool_t); +void ImportEnd( coOrd, wBool_t, wBool_t); void FreeTrack( track_p ); void ClearTracks( void ); BOOL_T TrackIterate( track_p * ); -void LoosenTracks( void * unused ); +void LoosenTracks( void * ); void SaveTrackState( void ); void RestoreTrackState( void ); @@ -669,6 +419,7 @@ void RestoreCarState( void ); TRKTYP_T InitObject( trackCmd_t* ); int ConnectTracks( track_p, EPINX_T, track_p, EPINX_T ); +void ConnectAllEndPts(track_p); BOOL_T ReconnectTrack( track_p, EPINX_T, track_p, EPINX_T ); void DisconnectTracks( track_p, EPINX_T, track_p, EPINX_T ); BOOL_T ConnectAbuttingTracks( track_p, EPINX_T, track_p, EPINX_T ); @@ -676,7 +427,8 @@ BOOL_T ConnectTurntableTracks(track_p, EPINX_T, track_p, EPINX_T ); BOOL_T SplitTrack( track_p, coOrd, EPINX_T, track_p *leftover, BOOL_T ); BOOL_T TraverseTrack( traverseTrack_p, DIST_T * ); BOOL_T RemoveTrack( track_p*, EPINX_T*, DIST_T* ); -BOOL_T TrimTrack( track_p, EPINX_T, DIST_T, coOrd pos, ANGLE_T angle, DIST_T radius, coOrd center); +BOOL_T TrimTrack( track_p, EPINX_T, DIST_T, coOrd pos, ANGLE_T angle, + DIST_T radius, coOrd center); BOOL_T MergeTracks( track_p, EPINX_T, track_p, EPINX_T ); STATUS_T ExtendStraightFromOrig( track_p, wAction_t, coOrd ); STATUS_T ExtendTrackFromOrig( track_p, wAction_t, coOrd ); @@ -694,7 +446,8 @@ BOOL_T ReplayTrackData(track_p, void *, long); DIST_T GetFlexLength( track_p, EPINX_T, coOrd * ); void LabelLengths( drawCmd_p, track_p, wDrawColor ); DIST_T GetTrkLength( track_p, EPINX_T, EPINX_T ); -void AddTrkDetails(drawCmd_p d, track_p trk, coOrd pos, DIST_T length, wDrawColor color); +void AddTrkDetails(drawCmd_p d, track_p trk, coOrd pos, DIST_T length, + wDrawColor color); void SelectAbove( void * unused ); void SelectBelow( void * unused ); @@ -702,21 +455,55 @@ void SelectBelow( void * unused ); void FlipPoint( coOrd*, coOrd, ANGLE_T ); void FlipTrack( track_p, coOrd, ANGLE_T ); +void DrawTurnout(track_p, drawCmd_p, wDrawColor); void DrawPositionIndicators( void ); void AdvancePositionIndicator( track_p, coOrd, coOrd *, ANGLE_T * ); -BOOL_T MakeParallelTrack( track_p, coOrd, DIST_T, DIST_T, track_p *, coOrd *, coOrd * , BOOL_T); +BOOL_T MakeParallelTrack( track_p, coOrd, DIST_T, DIST_T, track_p *, coOrd *, + coOrd *, BOOL_T); + +/*trkendpt.c*/ +coOrd GetTrkEndPos( track_p, EPINX_T ); +#define GetTrkEndPosXY( trk, ep ) PutDim(GetTrkEndPos(trk,ep).x), PutDim(GetTrkEndPos(trk,ep).y) +ANGLE_T GetTrkEndAngle( track_p, EPINX_T ); +long GetTrkEndOption( track_p, EPINX_T ); +long SetTrkEndOption( track_p, EPINX_T, long ); +void SetTrkEndPoint( track_p, EPINX_T, coOrd, ANGLE_T ); +void SetTrkEndPointSilent( track_p, EPINX_T, coOrd, ANGLE_T ); +track_p GetTrkEndTrk( track_p, EPINX_T ); +BOOL_T WriteEndPt( FILE *, track_cp, EPINX_T ); +void DrawEndElev( drawCmd_p, track_p, EPINX_T, wDrawColor ); +DIST_T EndPtDescriptionDistance( coOrd, track_p, EPINX_T, coOrd *, + BOOL_T show_hidden, BOOL_T * hidden ); +STATUS_T EndPtDescriptionMove( track_p, EPINX_T, wAction_t, coOrd ); +void SetTrkEndElev( track_p, EPINX_T, int, DIST_T, char * ); +void GetTrkEndElev( track_p trk, EPINX_T e, int *option, DIST_T *height ); +int GetTrkEndElevMode( track_p, EPINX_T ); +int GetTrkEndElevUnmaskedMode( track_p, EPINX_T ); +DIST_T GetTrkEndElevHeight( track_p, EPINX_T ); +BOOL_T GetTrkEndElevCachedHeight (track_p trk, EPINX_T e, DIST_T *height, + DIST_T *grade); +void SetTrkEndElevCachedHeight ( track_p trk, EPINX_T e, DIST_T height, + DIST_T grade); +char * GetTrkEndElevStation( track_p, EPINX_T ); +#define EndPtIsDefinedElev( T, E ) (GetTrkEndElevMode(T,E)==ELEV_DEF) +#define EndPtIsIgnoredElev( T, E ) (GetTrkEndElevMode(T,E)==ELEV_IGNORE) +#define EndPtIsStationElev( T, E ) (GetTrkEndElevMode(T,E)==ELEV_STATION) /*tstraight.c*/ -DIST_T StraightDescriptionDistance(coOrd pos, track_p trk, coOrd * dpos, BOOL_T show_hidden, BOOL_T * hidden); +DIST_T StraightDescriptionDistance(coOrd pos, track_p trk, coOrd * dpos, + BOOL_T show_hidden, BOOL_T * hidden); STATUS_T StraightDescriptionMove(track_p trk,wAction_t action,coOrd pos ); /*tease.c*/ -DIST_T JointDescriptionDistance(coOrd pos,track_p trk,coOrd * dpos,BOOL_T show_hidden,BOOL_T * hidden); +DIST_T JointDescriptionDistance(coOrd pos,track_p trk,coOrd * dpos, + BOOL_T show_hidden,BOOL_T * hidden); STATUS_T JointDescriptionMove(track_p trk,wAction_t action,coOrd pos ); /* cmisc.c */ extern wIndex_t describeCmdInx; +extern BOOL_T inDescribeCmd; +extern BOOL_T descUndoStarted; typedef enum { DESC_NULL, DESC_POS, DESC_FLOAT, DESC_ANGLE, DESC_LONG, DESC_COLOR, DESC_DIM, DESC_PIVOT, DESC_LAYER, DESC_STRING, DESC_TEXT, DESC_LIST, DESC_EDITABLELIST, DESC_BOXED } descType; #define DESC_RO (1<<0) #define DESC_IGNORE (1<<1) @@ -726,27 +513,37 @@ typedef enum { DESC_NULL, DESC_POS, DESC_FLOAT, DESC_ANGLE, DESC_LONG, DESC_COLO typedef enum { DESC_PIVOT_FIRST, DESC_PIVOT_MID, DESC_PIVOT_SECOND, DESC_PIVOT_NONE } descPivot_t; #define DESC_PIVOT_1 typedef struct { - coOrd pos; - POS_T ang; - } descEndPt_t; + coOrd pos; + POS_T ang; +} descEndPt_t; typedef struct { - descType type; - char * label; - void * valueP; - unsigned int max_string; - int mode; - wControl_p control0; - wControl_p control1; - wWinPix_t posy; - } descData_t, * descData_p; + descType type; + char * label; + void * valueP; + unsigned int max_string; + int mode; + wControl_p control0; + wControl_p control1; + wWinPix_t posy; +} descData_t, * descData_p; typedef void (*descUpdate_t)( track_p, int, descData_p, BOOL_T ); void DoDescribe( char *, track_p, descData_p, descUpdate_t ); void DescribeCancel( void ); BOOL_T UpdateDescStraight( int, int, int, int, int, descData_p, long ); STATUS_T CmdDescribe(wAction_t,coOrd); - + /* compound.c */ +#define LABEL_MANUF (1<<0) +#define LABEL_PARTNO (1<<1) +#define LABEL_DESCR (1<<2) +#define LABEL_COST (1<<7) +#define LABEL_FLIPPED (1<<8) +#define LABEL_TABBED (1<<9) +#define LABEL_UNGROUPED (1<<10) +#define LABEL_SPLIT (1<<11) +extern long listLabels; +extern long layoutLabels; DIST_T CompoundDescriptionDistance( coOrd, track_p, coOrd *, BOOL_T, BOOL_T * ); STATUS_T CompoundDescriptionMove( track_p, wAction_t, coOrd ); @@ -770,12 +567,13 @@ void DrawTrackElev( track_p, drawCmd_p, BOOL_T ); /* cdraw.c */ typedef enum {DRAWLINESOLID, - DRAWLINEDASH, - DRAWLINEDOT, - DRAWLINEDASHDOT, - DRAWLINEDASHDOTDOT, - DRAWLINECENTER, - DRAWLINEPHANTOM } drawLineType_e; + DRAWLINEDASH, + DRAWLINEDOT, + DRAWLINEDASHDOT, + DRAWLINEDASHDOTDOT, + DRAWLINECENTER, + DRAWLINEPHANTOM + } drawLineType_e; track_p MakeDrawFromSeg( coOrd, ANGLE_T, trkSeg_p ); track_p MakePolyLineFromSegs( coOrd, ANGLE_T, dynArr_t * ); void DrawOriginAnchor(track_p); @@ -787,13 +585,17 @@ void SetLineType( track_p trk, int width ); void MenuMode( void * moveVP ); /* chotbar.c */ +extern long showFlexTrack; +extern long hotBarLabels; +extern long carHotbarModeInx; extern DIST_T curBarScale; void InitHotBar( void ); void HideHotBar( void ); void LayoutHotBar ( void *); typedef enum { HB_SELECT, HB_DRAW, HB_LISTTITLE, HB_BARTITLE, HB_FULLTITLE } hotBarProc_e; typedef char * (*hotBarProc_t)( hotBarProc_e, void *, drawCmd_p, coOrd * ); -void AddHotBarElement( char *, coOrd, coOrd, BOOL_T, BOOL_T, DIST_T, void *, hotBarProc_t ); +void AddHotBarElement( char *, coOrd, coOrd, BOOL_T, BOOL_T, DIST_T, void *, + hotBarProc_t ); void HotBarCancel( void ); void AddHotBarTurnouts( void ); void AddHotBarStructures( void ); diff --git a/app/bin/trackx.h b/app/bin/trackx.h index e572011..5e1bc88 100644 --- a/app/bin/trackx.h +++ b/app/bin/trackx.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -28,26 +28,25 @@ #include "track.h" typedef struct track_t { - struct track_t *next; - TRKINX_T index; - TRKTYP_T type; - unsigned int layer; - signed char scale; - BOOL_T modified:1; - BOOL_T deleted:1; - BOOL_T new:1; - unsigned int width:2; - unsigned int elevMode:2; - unsigned int bits:13; - EPINX_T endCnt; - trkEndPt_p endPt; - struct { float x; float y; } lo, hi; - struct extraDataBase_t * extraData; - CSIZE_T extraSize; - DIST_T elev; - } track_t; + struct track_t *next; + TRKINX_T index; + TRKTYP_T type; + unsigned int layer; + signed char scale; + BOOL_T modified:1; + BOOL_T deleted:1; + BOOL_T new:1; + unsigned int width:2; + unsigned int elevMode:2; + unsigned int bits:14; // Make sure all TB_ flags can fit + EPINX_T endCnt; + trkEndPt_p endPt; + struct { float x; float y; } lo, hi; + struct extraDataBase_t * extraData; + CSIZE_T extraSize; + DIST_T elev; +} track_t; extern track_p to_first; extern track_p * to_last; -#define TRK_ITERATE(TRK) for (TRK=to_first; TRK!=NULL; TRK=TRK->next) if (!(TRK->deleted)) #endif diff --git a/app/bin/trkendpt.c b/app/bin/trkendpt.c new file mode 100644 index 0000000..a9ca40b --- /dev/null +++ b/app/bin/trkendpt.c @@ -0,0 +1,648 @@ +/* + * $Header: $ + */ + +/* XTrkCad - Model Railroad CAD + * Copyright (C) 2022 Dave Bullis + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "common.h" +#include "common.h" +#include "common-ui.h" +#include "fileio.h" +#include "param.h" +#include "track.h" +#include "trkendpt.h" +#include "trkendptx.h" +#include "draw.h" + + +/************************************************************************ + * Basic Access + */ + +EXPORT CSIZE_T EndPtSize( + EPINX_T epCnt ) +{ + return epCnt * sizeof *(trkEndPt_p)NULL; +} + + +EXPORT coOrd GetEndPtPos( trkEndPt_p epp ) +{ + return epp->pos; +} + + +EXPORT ANGLE_T GetEndPtAngle( trkEndPt_p epp ) +{ + return epp->angle; +} + + +EXPORT track_p GetEndPtTrack( trkEndPt_p epp ) +{ + return epp->track; +} + + +EXPORT void SetEndPt( trkEndPt_p epp, coOrd pos, ANGLE_T angle ) +{ + epp->pos = pos; + epp->angle = angle; +} + + +EXPORT EPINX_T GetEndPtEndPt( trkEndPt_p epp ) +{ + return (EPINX_T)(epp->index); +} + + +EXPORT TRKINX_T GetEndPtIndex( trkEndPt_p epp ) +{ + return (TRKINX_T)(epp->index); +} + + +EXPORT void SetEndPtTrack( trkEndPt_p epp, track_p trk ) +{ + epp->track = trk; + epp->index = -1; +} + + +EXPORT void SetEndPtEndPt( trkEndPt_p epp, EPINX_T ep ) +{ + epp->index = ep; +} + + +EXPORT trkEndPt_p EndPtIndex( trkEndPt_p epp, EPINX_T ep ) +{ + return epp+ep; +} + + +/************************************************************************ + * Temp End Points + */ + +static dynArr_t tempEndPts_da; + +EXPORT void TempEndPtsReset( void ) +{ + DYNARR_RESET( trkEndPt_t, tempEndPts_da ); +} + + +EXPORT void TempEndPtsSet( EPINX_T ep ) +{ + DYNARR_SET( trkEndPt_t, tempEndPts_da, ep ); + memset( &DYNARR_N(trkEndPt_t,tempEndPts_da,0), 0, + ep * sizeof *(trkEndPt_p)NULL ); +} + + +EXPORT EPINX_T TempEndPtsCount( void ) +{ + return tempEndPts_da.cnt; +} + + +EXPORT trkEndPt_p TempEndPt( EPINX_T ep ) +{ + CHECK( ep < tempEndPts_da.cnt ); + return &DYNARR_N( trkEndPt_t, tempEndPts_da, ep ); +} + + +#ifndef MKTURNOUT + +EXPORT trkEndPt_p TempEndPtsAppend( void ) +{ + DYNARR_APPEND( trkEndPt_t, tempEndPts_da, 10 ); + trkEndPt_p epp = &DYNARR_LAST( trkEndPt_t, tempEndPts_da ); + memset( epp, 0, sizeof *epp ); + return epp; +} + + +EXPORT void SwapEndPts( + trkEndPt_p epp, + EPINX_T ep0, + EPINX_T ep1 ) +{ + trkEndPt_t tempEP; + tempEP = epp[ep0]; + epp[ep0] = epp[ep1]; + epp[ep1] = tempEP; +} + + +/************************************************************************ + * Track level access + */ + +EXPORT void SetTrkEndPoint( track_p trk, EPINX_T ep, coOrd pos, ANGLE_T angle ) +{ + CHECK( ep < GetTrkEndPtCnt(trk) ); + // check setTrkEndPoint: endPt is not connected + CHECK( GetEndPtTrack( GetTrkEndPt( trk, ep ) ) == NULL ); + SetEndPt( GetTrkEndPt( trk, ep ), pos, angle ); +} + + +EXPORT void SetTrkEndPointSilent( track_p trk, EPINX_T ep, coOrd pos, + ANGLE_T angle ) +{ + CHECK( ep < GetTrkEndPtCnt(trk) ); + SetEndPt( GetTrkEndPt( trk, ep ), pos, angle ); +} + + +EXPORT coOrd GetTrkEndPos( track_p trk, EPINX_T ep ) +{ + CHECK( ep < GetTrkEndPtCnt(trk) ); + return GetTrkEndPt(trk,ep)->pos; +} + + +EXPORT ANGLE_T GetTrkEndAngle( track_p trk, EPINX_T ep ) +{ + CHECK( ep < GetTrkEndPtCnt(trk) ); + return GetTrkEndPt(trk,ep)->angle; +} + + +EXPORT track_p GetTrkEndTrk( track_p trk, EPINX_T ep ) +{ + CHECK( ep < GetTrkEndPtCnt(trk) ); + return GetTrkEndPt(trk,ep)->track; +} + + +EXPORT long GetTrkEndOption( track_p trk, EPINX_T ep ) +{ + CHECK( ep < GetTrkEndPtCnt(trk) ); + return GetTrkEndPt(trk,ep)->option; +} + + +EXPORT long SetTrkEndOption( track_p trk, EPINX_T ep, long option ) +{ + CHECK( ep < GetTrkEndPtCnt(trk) ); + return GetTrkEndPt(trk,ep)->option = option; +} + + +/************************************************************************ + * Elevations + */ + +EXPORT void SetTrkEndElev( track_p trk, EPINX_T ep, int option, DIST_T height, + char * station ) +{ + track_p trk1; + EPINX_T ep1; + trkEndPt_p epp = GetTrkEndPt( trk, ep ); + epp->elev.option = option; + epp->elev.cacheSet = FALSE; + if (EndPtIsDefinedElev(trk,ep)) { + epp->elev.u.height = height; + } else if (EndPtIsStationElev(trk,ep)) { + if (station == NULL) { + station = ""; + } + epp->elev.u.name = MyStrdup(station); + } + if ( (trk1=GetTrkEndTrk(trk, ep)) != NULL ) { + ep1 = GetEndPtConnectedToMe( trk1, trk ); + if (ep1 >= 0) { + trkEndPt_p epp1 = GetTrkEndPt( trk1, ep1 ); + epp1->elev.option = option; + epp1->elev.u.height = height; + if (EndPtIsDefinedElev(trk1,ep1)) { + epp1->elev.u.height = height; + } else if (EndPtIsStationElev(trk,ep)) { + epp1->elev.u.name = MyStrdup(station); + } + } + } +} + + +EXPORT void GetTrkEndElev( track_p trk, EPINX_T e, int *option, DIST_T *height ) +{ + trkEndPt_p epp = GetTrkEndPt( trk, e ); + *option = epp->elev.option; + *height = epp->elev.u.height; +} + + +EXPORT int GetTrkEndElevUnmaskedMode( track_p trk, EPINX_T e ) +{ + trkEndPt_p epp = GetTrkEndPt( trk, e ); + return epp->elev.option; +} + + +EXPORT int GetTrkEndElevMode( track_p trk, EPINX_T e ) +{ + trkEndPt_p epp = GetTrkEndPt( trk, e ); + return epp->elev.option&ELEV_MASK; +} + + +EXPORT DIST_T GetTrkEndElevHeight( track_p trk, EPINX_T e ) +{ + CHECK( EndPtIsDefinedElev(trk,e) ); + trkEndPt_p epp = GetTrkEndPt( trk, e ); + return epp->elev.u.height; +} + + +EXPORT void ClrEndPtElevCache( + EPINX_T epCnt, + trkEndPt_p epPts ) +{ + for ( EPINX_T ep = 0; ep < epCnt; ep++ ) { + epPts[ep].elev.cacheSet = FALSE; + } +} + + +static BOOL_T bCacheElev = TRUE; + +EXPORT BOOL_T GetTrkEndElevCachedHeight (track_p trk, EPINX_T e, + DIST_T * height, DIST_T * grade) +{ + if ( ! bCacheElev ) { + return FALSE; + } + trkEndPt_p epp = GetTrkEndPt( trk, e ); + if (epp->elev.cacheSet) { + *height = epp->elev.cachedElev; + *grade = epp->elev.cachedGrade; + return TRUE; + } + return FALSE; +} + +EXPORT void SetTrkEndElevCachedHeight ( track_p trk, EPINX_T e, DIST_T height, + DIST_T grade) +{ + trkEndPt_p epp = GetTrkEndPt( trk, e ); + epp->elev.cachedElev = height; + epp->elev.cachedGrade = grade; + epp->elev.cacheSet = TRUE; +} + + +EXPORT char * GetTrkEndElevStation( track_p trk, EPINX_T e ) +{ + CHECK( EndPtIsStationElev(trk,e) ); + trkEndPt_p epp = GetTrkEndPt( trk, e ); + if ( epp->elev.u.name == NULL ) { + return ""; + } else { + return epp->elev.u.name; + } +} + + +EXPORT void DrawEndElev( drawCmd_p d, track_p trk, EPINX_T ep, + wDrawColor color ) +{ + coOrd pp; + wFont_p fp; + elev_t * elev; + track_p trk1; + DIST_T elev0, grade; + ANGLE_T a=0; + int style = BOX_BOX_BACKGROUND; + BOOL_T gradeOk = TRUE; + char *elevStr; + + if ((labelEnable&LABELENABLE_ENDPT_ELEV)==0) { + return; + } + elev = &GetTrkEndPt(trk,ep)->elev; + if ( (elev->option&ELEV_MASK)==ELEV_NONE || + (elev->option&ELEV_VISIBLE)==0 ) { + return; + } + if ( (trk1=GetTrkEndTrk(trk,ep)) && GetTrkIndex(trk1)<GetTrkIndex(trk) ) { + return; + } + + fp = wStandardFont( F_HELV, FALSE, FALSE ); + pp = GetTrkEndPos( trk, ep ); + switch ((elev->option&ELEV_MASK)) { + case ELEV_COMP: + case ELEV_GRADE: + if ( color == wDrawColorWhite ) { + elev0 = grade = elev->u.height; + } else if ( !ComputeElev( trk, ep, FALSE, &elev0, &grade, FALSE ) ) { + elev0 = grade = 0; + gradeOk = FALSE; + } + if ((elev->option&ELEV_MASK)==ELEV_COMP) { + elevStr = FormatDistance(elev0); + elev->u.height = elev0; + } else if (gradeOk) { + sprintf( message, "%0.1f%%", round(fabs(grade*100.0)*10)/10 ); + elevStr = message; + a = GetTrkEndAngle( trk, ep ); + style = BOX_ARROW_BACKGROUND; + if (grade <= -0.001) { + a = NormalizeAngle( a+180.0 ); + } else if ( grade < 0.001 ) { + style = BOX_BOX_BACKGROUND; + } + elev->u.height = grade; + } else { + elevStr = "????%%"; + } + break; + case ELEV_DEF: + elevStr = FormatDistance( elev->u.height); + break; + case ELEV_STATION: + elevStr = elev->u.name; + break; + default: + return; + } + coOrd startLine = pp, endLine = pp; + pp.x += elev->doff.x; + pp.y += elev->doff.y; + if (color==drawColorPreviewSelected) { + Translate(&endLine,pp,FindAngle(pp,startLine),descriptionFontSize/d->dpi); + DrawLine( d, startLine, endLine, 0, color ); + } + DrawBoxedString( style, d, pp, elevStr, fp, (wFontSize_t)descriptionFontSize, + color, a ); + +} + + +/************************************************************************ + * Descriptions + */ + +EXPORT DIST_T EndPtDescriptionDistance( + coOrd pos, + track_p trk, + EPINX_T ep, + coOrd *dpos, + BOOL_T show_hidden, + BOOL_T * hidden) +{ + elev_t *e; + coOrd pos1; + track_p trk1; + *dpos = pos; + if (hidden) { *hidden = FALSE; } + e = &GetTrkEndPt(trk,ep)->elev; + if ((e->option&ELEV_MASK)==ELEV_NONE) { + return DIST_INF; + } + if (((e->option&ELEV_VISIBLE)==0) && !show_hidden) { + return DIST_INF; + } + if ((trk1=GetTrkEndTrk(trk,ep)) && GetTrkIndex(trk1)<GetTrkIndex(trk)) { + return DIST_INF; + } + if ((e->option&ELEV_VISIBLE)==0) { //Hidden - disregard offset + if (hidden) { *hidden = TRUE; } + return FindDistance( GetTrkEndPos(trk,ep), pos ); + } + /*REORIGIN( pos1, e->doff, GetTrkEndPos(trk,ep), GetTrkEndAngle(trk,ep) );*/ + pos1 = GetTrkEndPos(trk,ep); + coOrd tpos = pos1; + pos1.x += e->doff.x; + pos1.y += e->doff.y; + *dpos = pos1; + if (hidden) { *hidden = !(e->option&ELEV_VISIBLE); } + if (FindDistance(tpos,pos)<FindDistance( pos1, pos )) { + return FindDistance(tpos,pos); + } + return FindDistance( pos1, pos ); +} + + +EXPORT STATUS_T EndPtDescriptionMove( + track_p trk, + EPINX_T ep, + wAction_t action, + coOrd pos ) +{ + static coOrd p0; +// static coOrd p1; + elev_t *e; + track_p trk1; + + e = &GetTrkEndPt(trk,ep)->elev; + switch (action) { + case C_DOWN: + p0 = GetTrkEndPos(trk,ep); +// p1 = pos; + e->option |= ELEV_VISIBLE; //Make sure we make visible + DrawEndElev( &mainD, trk, ep, wDrawColorWhite ); + /*no break*/ + case C_MOVE: + case C_UP: +// p1 = pos; + e->doff.x = (pos.x-p0.x); + e->doff.y = (pos.y-p0.y); + if ((trk1=GetTrkEndTrk(trk,ep))) { + EPINX_T ep1 = GetEndPtConnectedToMe(trk1,trk); + trkEndPt_p epp = GetTrkEndPt( trk1, ep1 ); +// e1 = &trk1->endPt[GetEndPtConnectedToMe(trk1,trk)].elev; + epp->elev.doff = e->doff; + } + if ( action == C_UP ) { + wDrawColor color = GetTrkColor( trk, &mainD ); + DrawEndElev( &mainD, trk, ep, color ); + } + return action==C_UP?C_TERMINATE:C_CONTINUE; + + case C_REDRAW: + DrawEndElev( &tempD, trk, ep, drawColorPreviewSelected ); + break; + } + return C_CONTINUE; +} + + +/************************************************************************ + * Read/Write End Points + */ + +EXPORT BOOL_T GetEndPtArg( + char * cp, + char type, + BOOL_T bImprovedEnds ) +{ + long option; + long option2; + trkEndPt_p e = TempEndPtsAppend(); + FLOAT_T ignoreFloat; + + if (type == SEG_CONEP) { + if ( !GetArgs( cp, "dc", &e->index, &cp ) ) { + /*??*/return FALSE; + } + } else { + e->index = -1; + } + if ( !GetArgs( cp, "pfc", + &e->pos, &e->angle, &cp) ) { + /*??*/return FALSE; + } + e->elev.option = 0; + e->elev.u.height = 0.0; + e->elev.doff = zero; + e->option = 0; + if (bImprovedEnds) { //E4 and T4 + if (!GetArgs( cp, "lpc", &option, &e->elev.doff, &cp )) { + /*??*/return FALSE; + } + switch (option&ELEV_MASK) { + case ELEV_STATION: + GetArgs( cp, "qc", &e->elev.u.name, &cp); + break; + default: + GetArgs( cp, "fc", &e->elev.u.height, &cp); //First height + } + DIST_T height2; + if (!GetArgs( cp, "flLlc", &height2, &option2, &e->elev.option, &e->option, + &cp ) ) { + return FALSE; + } + if (option2) { e->elev.option |= ELEV_VISIBLE; } + GetArgs(cp, "fc", &ignoreFloat, &cp); + return TRUE; + } + if ( cp != NULL ) { + if (paramVersion < 7) { + GetArgs( cp, "dfp", &e->elev.option, &e->elev.u.height, &e->elev.doff, &cp ); + /*??*/return TRUE; + } + GetArgs( cp, "lpc", &option, &e->elev.doff, &cp ); + e->option = option >> 8; + e->elev.option = (int)(option&0xFF); + if ( (e->elev.option&ELEV_MASK) != ELEV_NONE ) { + switch (e->elev.option&ELEV_MASK) { + case ELEV_DEF: + GetArgs( cp, "fc", &e->elev.u.height, &cp ); + break; + case ELEV_STATION: + GetArgs( cp, "qc", &e->elev.u.name, &cp ); + /*??*/break; + default: + ; + } + } + } + return TRUE; +} + + +EXPORT BOOL_T bWriteEndPtDirectIndex = FALSE; +EXPORT BOOL_T bWriteEndPtExporting = FALSE; + + +EXPORT BOOL_T WriteEndPt( FILE * f, track_cp trk, EPINX_T ep ) +{ + trkEndPt_p endPt = GetTrkEndPt(trk,ep); + BOOL_T rc = TRUE; + long option; + + CHECK ( endPt ); + if (bWriteEndPtDirectIndex && endPt->index > 0) { + rc &= fprintf( f, "\tT4 %ld ", endPt->index )>0; + } else if (endPt->track == NULL || + ( bWriteEndPtExporting && !GetTrkSelected(endPt->track) ) ) { + rc &= fprintf( f, "\tE4 " )>0; + } else { + rc &= fprintf( f, "\tT4 %d ", GetTrkIndex(endPt->track) )>0; + } + rc &= fprintf( f, "%0.6f %0.6f %0.6f", endPt->pos.x, endPt->pos.y, + endPt->angle )>0; + option = (endPt->option<<8) | (endPt->elev.option&0xFF); + if ( option != 0 ) { + rc &= fprintf( f, " %ld %0.6f %0.6f", option, endPt->elev.doff.x, + endPt->elev.doff.y )>0; + switch ( endPt->elev.option&ELEV_MASK ) { + case ELEV_DEF: + rc &= fprintf( f, " %0.6f ", endPt->elev.u.height )>0; + break; + case ELEV_STATION: + rc &= fprintf( f, " \"%s\" ", PutTitle( endPt->elev.u.name ) )>0; + break; + default: + rc &= fprintf( f, " 0.0 ")>0; + } + } else { + rc &= fprintf( f, " 0 0.0 0.0 0.0 ")>0; + } + if ((endPt->elev.option&ELEV_MASK) == ELEV_DEF) { + rc &= fprintf( f, "%0.6f ",endPt->elev.u.height)>0; + } else { + rc &= fprintf( f, "0.0 ")>0; + } + long elevVisible = (endPt->elev.option&ELEV_VISIBLE)?1:0; + long elevType = endPt->elev.option&ELEV_MASK; + long gapType = endPt->option; + rc &= fprintf( f, "%ld %ld %ld ", elevVisible, elevType, gapType)>0; + rc &= fprintf( f, "%0.6f ", GetTrkElev( trk ) )>0; + rc &= fprintf( f, "\n" )>0; + return rc; +} + + +/************************************************************************ +* Read/Write End Points +*/ + +wBool_t CompareEndPt( + char * cp, + track_p trk1, + track_p trk2, + EPINX_T ep ) +{ + trkEndPt_p epp1 = GetTrkEndPt( trk1, ep ); + trkEndPt_p epp2 = GetTrkEndPt( trk2, ep ); + REGRESS_CHECK_POS( "Pos", epp1, epp2, pos ) + REGRESS_CHECK_ANGLE( "Angle", epp1, epp2, angle ) + // Actual EP connection + int inx1 = -1; + if ( epp1->track ) { + inx1 = GetTrkIndex( epp1->track ); + } + // Expected EP connection. endPt[inx].track is not resolved + int inx2 = epp2->index; + if ( inx1 != inx2 ) { + sprintf( cp, "Index: Actual` %d, Expected %d\n", inx1, inx2 ); + return FALSE; + } + REGRESS_CHECK_INT( "Option", epp1, epp2, option ) + return TRUE; +} +#endif diff --git a/app/bin/trkendpt.h b/app/bin/trkendpt.h new file mode 100644 index 0000000..dc04bfb --- /dev/null +++ b/app/bin/trkendpt.h @@ -0,0 +1,54 @@ +/** \file trkendpt.h + * + */ + +/* XTrkCad - Model Railroad CAD + * Copyright (C) 2022 Dave Bullis + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +#ifndef TRKENDPT_H +#define TRKENDPT_H + +#include "common.h" + +void TempEndPtsReset( void ); +void TempEndPtsSet( EPINX_T ); +EPINX_T TempEndPtsCount( void ); +trkEndPt_p TempEndPt( EPINX_T ); +trkEndPt_p TempEndPtsAppend( void ); + +CSIZE_T EndPtSize( EPINX_T ); +coOrd GetEndPtPos( trkEndPt_p ); +ANGLE_T GetEndPtAngle( trkEndPt_p ); +void SetEndPt( trkEndPt_p, coOrd, ANGLE_T ); +track_p GetEndPtTrack( trkEndPt_p ); +EPINX_T GetEndPtEndPt( trkEndPt_p ); +TRKINX_T GetEndPtIndex( trkEndPt_p ); +void SetEndPtTrack( trkEndPt_p, track_p); +void SetEndPtEndPt( trkEndPt_p, EPINX_T ); +trkEndPt_p EndPtIndex( trkEndPt_p, EPINX_T ); + +void SwapEndPts( trkEndPt_p, EPINX_T, EPINX_T ); +BOOL_T GetEndPtArg( char *, char, BOOL_T ); +void ClrEndPtElevCache( EPINX_T, trkEndPt_p ); + +extern BOOL_T bWriteEndPtDirectIndex; +extern BOOL_T bWriteEndPtExporting; + +wBool_t CompareEndPt( char * cp, track_p trk1, track_p trk2, EPINX_T ep ); +#endif diff --git a/app/bin/cmisc2.c b/app/bin/trkendptx.h index 128e52b..184076a 100644 --- a/app/bin/cmisc2.c +++ b/app/bin/trkendptx.h @@ -1,9 +1,9 @@ -/* - * $Header: /home/dmarkle/xtrkcad-fork-cvs/xtrkcad/app/bin/cmisc2.c,v 1.4 2008-03-10 18:59:53 m_fischer Exp $ +/** \file trkendpt.h + * */ /* XTrkCad - Model Railroad CAD - * Copyright (C) 2005 Dave Bullis + * Copyright (C) 2022 Dave Bullis * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,38 +17,35 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "common.h" -#include "track.h" - -/***************************************************************************** - * - * MISC2 - * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -static STATUS_T CmdBridge( wAction_t action, coOrd pos ) -{ - switch (action) { - case C_DOWN: - return C_INFO; - break; - } - return C_INFO; -} - - - +#ifndef TRKENDPTX_H +#define TRKENDPTX_H +#include "common.h" +#include "track.h" -#include "bitmaps/bridge.xbm" - -void InitCmdMisc2( wMenu_p menu ) -{ - if (extraButtons) { - InitCommand( menu, CmdBridge, N_("Bridge"), bridge_bits, LEVEL2, IC_STICKY, ACCL_BRIDGE ); - } -} +typedef struct { + int option; + coOrd doff; + union { + DIST_T height; + char * name; + } u; + BOOL_T cacheSet; + double cachedElev; + double cachedGrade; +} elev_t; + +typedef struct trkEndPt_t { + coOrd pos; + ANGLE_T angle; + track_p track; + long index; + elev_t elev; + long option; +} trkEndPt_t; + +#endif diff --git a/app/bin/trknote.c b/app/bin/trknote.c index f2462ba..a62c22d 100644 --- a/app/bin/trknote.c +++ b/app/bin/trknote.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "common.h" @@ -31,9 +31,6 @@ #include "track.h" #include "include/utf8convert.h" -extern BOOL_T inDescribeCmd; -extern descData_t noteDesc[]; - EXPORT TRKTYP_T T_NOTE = -1; static wDrawBitMap_p note_bm, link_bm, document_bm; @@ -47,14 +44,14 @@ typedef struct { long acclKey; } trknoteData_t; -#include "bitmaps/sticky-note.xpm" -#include "bitmaps/sticky-link.xpm" -#include "bitmaps/sticky-doc.xpm" +#include "bitmaps/sticky-note.xpm3" +#include "bitmaps/sticky-link.xpm3" +#include "bitmaps/sticky-doc.xpm3" static trknoteData_t noteTypes[] = { - { sticky_note_xpm, OP_NOTETEXT, N_("Note"), N_("Comment"), "cmdTextNote", 0L }, - { sticky_link_xpm, OP_NOTELINK, N_("Link"), N_("Weblink"), "cmdLinkNote", 0L }, - { sticky_doc_xpm, OP_NOTEFILE, N_("Document"), N_("Document"), "cmdFileNote", 0L }, + { sticky_note_xpm3, OP_NOTETEXT, N_("Note"), N_("Text Note"), "cmdTextNote", ACCL_NOTE }, + { sticky_link_xpm3, OP_NOTELINK, N_("Link"), N_("Weblink"), "cmdLinkNote", 0L }, + { sticky_doc_xpm3, OP_NOTEFILE, N_("Document"), N_("Document"), "cmdFileNote", 0L }, }; static long curNoteType; @@ -69,16 +66,16 @@ static coOrd posSave; * NOTE OBJECT */ -static track_p NewNote(wIndex_t index, coOrd p, enum noteCommands command ) +EXPORT track_p NewNote(wIndex_t index, coOrd p, enum noteCommands command ) { - track_p t; - struct extraDataNote_t * xx; - t = NewTrack(index, T_NOTE, 0, sizeof *xx); - xx = GET_EXTRA_DATA( t, T_NOTE, extraDataNote_t ); - xx->pos = p; + track_p t; + struct extraDataNote_t * xx; + t = NewTrack(index, T_NOTE, 0, sizeof *xx); + xx = GET_EXTRA_DATA( t, T_NOTE, extraDataNote_t ); + xx->pos = p; xx->op = command; - SetBoundingBox(t, p, p); - return t; + SetBoundingBox(t, p, p); + return t; } /** @@ -91,9 +88,9 @@ static track_p NewNote(wIndex_t index, coOrd p, enum noteCommands command ) static void DrawNote(track_p t, drawCmd_p d, wDrawColor color) { - struct extraDataNote_t *xx = GET_EXTRA_DATA( t, T_NOTE, extraDataNote_t ); - coOrd p[5]; - int type[5]; + struct extraDataNote_t *xx = GET_EXTRA_DATA( t, T_NOTE, extraDataNote_t ); + coOrd p[5]; + int type[5]; if ((d->options & DC_SIMPLE) || mainD.scale >= 16) { @@ -109,7 +106,7 @@ static void DrawNote(track_p t, drawCmd_p d, wDrawColor color) p[3].y = p[3].y - (dist/2); p[4].x = p[4].x - (dist/2); - for (int i=0;i<5;i++) { + for (int i=0; i<5; i++) { type[i] = 0; } DrawPoly(d, 5, p, type, color, 0, DRAW_CLOSED); @@ -127,21 +124,21 @@ static void DrawNote(track_p t, drawCmd_p d, wDrawColor color) bm = note_bm; } } - DrawBitMap(d, xx->pos, bm, color); - } + DrawBitMap(d, xx->pos, bm, color); + } } static DIST_T DistanceNote(track_p t, coOrd * p) { - struct extraDataNote_t *xx = GET_EXTRA_DATA( t, T_NOTE, extraDataNote_t ); - DIST_T d; - d = FindDistance(*p, xx->pos); + struct extraDataNote_t *xx = GET_EXTRA_DATA( t, T_NOTE, extraDataNote_t ); + DIST_T d; + d = FindDistance(*p, xx->pos); - if (d < 3.0*(mainD.scale/12.0)) { - return d; - } + if (d < 3.0*(mainD.scale/12.0)) { + return d; + } - return DIST_INF; + return DIST_INF; } static void DeleteNote(track_p t) @@ -175,126 +172,8 @@ static void DeleteNote(track_p t) } } -void -NoteStateSave(track_p trk) -{ - struct extraDataNote_t *xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); - layerSave = GetTrkLayer(trk); - posSave = xx->pos; -} - -/** -* Handle Cancel button: restore old values for layer and position -*/ - -void -CommonCancelNote(track_p trk) -{ - if (inDescribeCmd) { - struct extraDataNote_t *xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); - xx->layer = layerSave; - xx->pos = posSave; - SetBoundingBox(trk, xx->pos, xx->pos); - } -} - -static void -CommonUpdateNote(track_p trk, int inx, struct extraDataNote_t *noteData ) -{ - struct extraDataNote_t *xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); - - switch (inx) { - case OR_NOTE: - xx->pos = noteData->pos; - SetBoundingBox(trk, xx->pos, xx->pos); - break; - case LY_NOTE: - SetTrkLayer(trk, noteData->layer); - break; - case CANCEL_NOTE: - CommonCancelNote(trk); - break; - } -} - - -void UpdateFile(struct extraDataNote_t *noteUIData, int inx, BOOL_T needUndoStart) -{ - track_p trk = noteUIData->trk; - struct extraDataNote_t *xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); - - switch (inx) { - case OR_NOTE: - case LY_NOTE: - case CANCEL_NOTE: - CommonUpdateNote(trk, inx, noteUIData); - break; - case OK_FILE: - { - DeleteNote(trk); - xx->noteData.fileData.path = MyStrdup(noteUIData->noteData.fileData.path); - xx->noteData.fileData.title = MyStrdup(noteUIData->noteData.fileData.title); - //result = malloc( maximumSize ); - //resultSize = File2URI(noteFileData->path, maximumSize, result); - //xx->text = (char*)MyMalloc(resultSize + strlen(noteFileData->title) + 2); - //sprintf(xx->text, "%s %s", result, noteFileData->title); - //if (noteFileData->inArchive) { - // CopyFile(noteFileData->path, archiveDirectory); - - //} - //free(result); - } - break; - - default: - break; - } -} - -void UpdateLink(struct extraDataNote_t *noteUIData, int inx, BOOL_T needUndoStart) -{ - track_p trk = noteUIData->trk; - struct extraDataNote_t *xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); - - switch (inx) { - case OR_NOTE: - case LY_NOTE: - case CANCEL_NOTE: - CommonUpdateNote(trk, inx, noteUIData); - break; - - case OK_LINK: - DeleteNote(trk); - xx->noteData.linkData.title = MyStrdup(noteUIData->noteData.linkData.title); - xx->noteData.linkData.url = MyStrdup(noteUIData->noteData.linkData.url); - break; - default: - break; - } -} - -void UpdateText(struct extraDataNote_t *noteUIData, int inx, BOOL_T needUndoStart) -{ - track_p trk = noteUIData->trk; - struct extraDataNote_t *xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); - - switch (inx) { - case OR_NOTE: - case LY_NOTE: - case CANCEL_NOTE: - CommonUpdateNote(trk, inx, noteUIData); - break; - - case OK_TEXT: - DeleteNote(trk); - xx->noteData.text = MyStrdup(noteUIData->noteData.text); - break; - default: - break; - } - changed++; -} +#if 0 /** * Get the delimited marker for the current note. Markers start and end with * a delimiter. The marker itself is a single digit number. For plain text notes @@ -321,6 +200,7 @@ GetNoteMarker(enum noteCommands command ) } return(marker); } +#endif /** * Write the note to file. Handles the complete syntax for a note statement @@ -332,13 +212,15 @@ GetNoteMarker(enum noteCommands command ) static BOOL_T WriteNote(track_p t, FILE * f) { - struct extraDataNote_t *xx = GET_EXTRA_DATA( t, T_NOTE, extraDataNote_t ); - BOOL_T rc = TRUE; + struct extraDataNote_t *xx = GET_EXTRA_DATA( t, T_NOTE, extraDataNote_t ); + BOOL_T rc = TRUE; +#ifdef UTFCONVERT unsigned strings2convert = 1; +#endif rc &= fprintf(f, "NOTE %d %u 0 0 %0.6f %0.6f 0 %d", GetTrkIndex(t), - GetTrkLayer(t), - xx->pos.x, xx->pos.y, xx->op )>0; + GetTrkLayer(t), + xx->pos.x, xx->pos.y, xx->op )>0; char *s[2] = { NULL, NULL }; switch (xx->op) { @@ -348,15 +230,19 @@ static BOOL_T WriteNote(track_p t, FILE * f) case OP_NOTELINK: s[0]=ConvertToEscapedText( xx->noteData.linkData.url ); s[1]=ConvertToEscapedText( xx->noteData.linkData.title ); +#ifdef UTFCONVERT strings2convert = 2; +#endif break; case OP_NOTEFILE: s[0]=ConvertToEscapedText( xx->noteData.fileData.path ); s[1]=ConvertToEscapedText( xx->noteData.fileData.title ); +#ifdef UTFCONVERT strings2convert = 2; +#endif break; default: - AbortProg( "WriteNote: %d", xx->op ); + CHECKMSG( FALSE, ( "WriteNote: %d", xx->op ) ); } #ifdef UTFCONVERT for ( unsigned int inx = 0; inx < strings2convert; inx++ ) { @@ -374,7 +260,7 @@ static BOOL_T WriteNote(track_p t, FILE * f) MyFree( s[1] ); } rc &= fprintf( f, "\n" )>0; - + return rc; } @@ -387,62 +273,67 @@ static BOOL_T WriteNote(track_p t, FILE * f) static BOOL_T ReadTrackNote(char *line) { - track_p t; - int size; - char * cp; - struct extraDataNote_t *xx; - wIndex_t index; - wIndex_t layer; - coOrd pos; - DIST_T elev; + track_p t; + int size; + char * cp; + struct extraDataNote_t *xx; + wIndex_t index; + wIndex_t layer; + coOrd pos; + DIST_T elev; char *noteText; enum noteCommands noteType; char * sText; - if (!GetArgs(line + 5, paramVersion < 3 ? "XXpYdc" : paramVersion < 9 ? - "dL00pYdc" : "dL00pfdc", - &index, &layer, &pos, &elev, &size, &cp)) { - return FALSE; - } + if (!GetArgs(line + 5, paramVersion < 3 ? "XXpYdc" : paramVersion < 9 ? + "dL00pYdc" : "dL00pfdc", + &index, &layer, &pos, &elev, &size, &cp)) { + return FALSE; + } if ( paramVersion >= VERSION_INLINENOTE ) { noteType = size; t = NewNote(index, pos, noteType); - SetTrkLayer(t, layer); - - xx = GET_EXTRA_DATA( t, T_NOTE, extraDataNote_t ); + SetTrkLayer(t, layer); + + xx = GET_EXTRA_DATA( t, T_NOTE, extraDataNote_t ); switch (noteType) { case OP_NOTETEXT: - if ( !GetArgs( cp, "qc", &sText, &cp ) ) + if ( !GetArgs( cp, "qc", &sText, &cp ) ) { return FALSE; + } #ifdef UTFCONVERT ConvertUTF8ToSystem( sText ); #endif xx->noteData.text = sText; break; case OP_NOTELINK: - if ( !GetArgs( cp, "qc", &sText, &cp ) ) + if ( !GetArgs( cp, "qc", &sText, &cp ) ) { return FALSE; + } #ifdef UTFCONVERT ConvertUTF8ToSystem( sText ); #endif xx->noteData.linkData.url = sText; - if ( !GetArgs( cp, "qc", &sText, &cp ) ) + if ( !GetArgs( cp, "qc", &sText, &cp ) ) { return FALSE; + } #ifdef UTFCONVERT ConvertUTF8ToSystem( sText ); #endif xx->noteData.linkData.title = sText; break; case OP_NOTEFILE: - if ( !GetArgs( cp, "qc", &sText, &cp ) ) + if ( !GetArgs( cp, "qc", &sText, &cp ) ) { return FALSE; + } #ifdef UTFCONVERT ConvertUTF8ToSystem( sText ); #endif xx->noteData.fileData.path = sText; - if ( !GetArgs( cp, "qc", &sText, &cp ) ) + if ( !GetArgs( cp, "qc", &sText, &cp ) ) { return FALSE; + } #ifdef UTFCONVERT ConvertUTF8ToSystem( sText ); #endif @@ -450,51 +341,48 @@ ReadTrackNote(char *line) xx->noteData.fileData.inArchive = FALSE; break; default: - AbortProg( "ReadNote: %d", noteType ); + CHECKMSG( FALSE, ( "ReadNote: %d", noteType ) ); } } else { - noteText = ReadMultilineText(); + noteText = ReadMultilineText(); - noteType = OP_NOTETEXT; + noteType = OP_NOTETEXT; - if( !strncmp(noteText, DELIMITER, strlen( DELIMITER )) && - !strncmp(noteText + strlen(DELIMITER) + 1, DELIMITER, strlen(DELIMITER)) && - noteText[strlen(DELIMITER)] - '0' > 0 && - noteText[strlen(DELIMITER)] - '0' <= OP_NOTEFILE) - { - noteType = noteText[strlen(DELIMITER)] - '0'; - } + if( !strncmp(noteText, DELIMITER, strlen( DELIMITER )) && + !strncmp(noteText + strlen(DELIMITER) + 1, DELIMITER, strlen(DELIMITER)) && + noteText[strlen(DELIMITER)] - '0' > 0 && + noteText[strlen(DELIMITER)] - '0' <= OP_NOTEFILE) { + noteType = noteText[strlen(DELIMITER)] - '0'; + } - t = NewNote(index, pos, noteType); - SetTrkLayer(t, layer); - - xx = GET_EXTRA_DATA( t, T_NOTE, extraDataNote_t ); + t = NewNote(index, pos, noteType); + SetTrkLayer(t, layer); - switch (noteType) { - case OP_NOTETEXT: - xx->noteData.text = MyStrdup(noteText); - break; - case OP_NOTELINK: - { - char *ptr; - ptr = strtok(noteText, " "); - xx->noteData.linkData.url = MyStrdup(ptr + 2 * strlen(DELIMITER) + 1); - xx->noteData.linkData.title = MyStrdup(noteText + strlen(ptr) + 1); - break; - } - case OP_NOTEFILE: - { - char *ptr; - ptr = strtok(noteText + 2 * strlen(DELIMITER) + 1, "\""); - xx->noteData.fileData.path = MyStrdup(ptr); - xx->noteData.fileData.title = MyStrdup(ptr + strlen(ptr) + 2 ); - xx->noteData.fileData.inArchive = FALSE; - break; - } + xx = GET_EXTRA_DATA( t, T_NOTE, extraDataNote_t ); + switch (noteType) { + case OP_NOTETEXT: + xx->noteData.text = MyStrdup(noteText); + break; + case OP_NOTELINK: { + char *ptr; + ptr = strtok(noteText, " "); + xx->noteData.linkData.url = MyStrdup(ptr + 2 * strlen(DELIMITER) + 1); + xx->noteData.linkData.title = MyStrdup(noteText + strlen(ptr) + 1); + break; + } + case OP_NOTEFILE: { + char *ptr; + ptr = strtok(noteText + 2 * strlen(DELIMITER) + 1, "\""); + xx->noteData.fileData.path = MyStrdup(ptr); + xx->noteData.fileData.title = MyStrdup(ptr + strlen(ptr) + 2 ); + xx->noteData.fileData.inArchive = FALSE; + break; + } + + } + MyFree(noteText); } - MyFree(noteText); - } return TRUE; } @@ -507,42 +395,41 @@ ReadTrackNote(char *line) static BOOL_T ReadNote(char * line) { - if (strncmp(line, "NOTE MAIN", 9) == 0) { - return ReadMainNote(line); - } else { - return ReadTrackNote(line); - } + if (strncmp(line, "NOTE MAIN", 9) == 0) { + return ReadMainNote(line); + } else { + return ReadTrackNote(line); + } } static void MoveNote(track_p trk, coOrd orig) { - struct extraDataNote_t * xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); - xx->pos.x += orig.x; - xx->pos.y += orig.y; - SetBoundingBox(trk, xx->pos, xx->pos); + struct extraDataNote_t * xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); + xx->pos.x += orig.x; + xx->pos.y += orig.y; + SetBoundingBox(trk, xx->pos, xx->pos); } static void RotateNote(track_p trk, coOrd orig, ANGLE_T angle) { - struct extraDataNote_t * xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); - Rotate(&xx->pos, orig, angle); - SetBoundingBox(trk, xx->pos, xx->pos); + struct extraDataNote_t * xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); + Rotate(&xx->pos, orig, angle); + SetBoundingBox(trk, xx->pos, xx->pos); } static void RescaleNote(track_p trk, FLOAT_T ratio) { - struct extraDataNote_t * xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); - xx->pos.x *= ratio; - xx->pos.y *= ratio; + struct extraDataNote_t * xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); + xx->pos.x *= ratio; + xx->pos.y *= ratio; } static void DescribeNote(track_p trk, char * str, CSIZE_T len) { if (IsLinkNote(trk)) { DescribeLinkNote(trk, str, len); - } - else { + } else { if (IsFileNote(trk)) { DescribeFileNote(trk, str, len); } else { @@ -551,7 +438,8 @@ static void DescribeNote(track_p trk, char * str, CSIZE_T len) } } -static void ActivateNote(track_p trk) { +static void ActivateNote(track_p trk) +{ if (IsLinkNote(trk) ) { ActivateLinkNote(trk); } @@ -564,8 +452,8 @@ static BOOL_T QueryNote( track_p trk, int query ) { switch ( query ) { case Q_IS_ACTIVATEABLE:; - if (IsFileNote(trk)) return TRUE; - if (IsLinkNote(trk)) return TRUE; + if (IsFileNote(trk)) { return TRUE; } + if (IsLinkNote(trk)) { return TRUE; } break; default: return FALSE; @@ -579,28 +467,27 @@ static wBool_t CompareNote( track_cp trk1, track_cp trk2 ) struct extraDataNote_t *xx2 = GET_EXTRA_DATA( trk2, T_NOTE, extraDataNote_t ); char * cp = message + strlen(message); REGRESS_CHECK_POS( "Pos", xx1, xx2, pos ) - REGRESS_CHECK_INT( "Layer", xx1, xx2, layer ) REGRESS_CHECK_INT( "Op", xx1, xx2, op ) return TRUE; } static trackCmd_t noteCmds = { - "NOTE", - DrawNote, - DistanceNote, - DescribeNote, - DeleteNote, - WriteNote, - ReadNote, - MoveNote, - RotateNote, - RescaleNote, - NULL, /* audit */ - NULL, /* getAngle */ - NULL, /* split */ - NULL, /* traverse */ - NULL, /* enumerate */ - NULL, /* redraw */ + "NOTE", + DrawNote, + DistanceNote, + DescribeNote, + DeleteNote, + WriteNote, + ReadNote, + MoveNote, + RotateNote, + RescaleNote, + NULL, /* audit */ + NULL, /* getAngle */ + NULL, /* split */ + NULL, /* traverse */ + NULL, /* enumerate */ + NULL, /* redraw */ NULL, /*trim*/ NULL, /*merge*/ NULL, /*modify*/ @@ -630,51 +517,45 @@ static trackCmd_t noteCmds = { static STATUS_T CmdNote(wAction_t action, coOrd pos) { - static coOrd oldPos; - static int state_on = FALSE; - track_p trk; + static coOrd oldPos; + static int state_on = FALSE; + track_p trk; - switch (action) { - case C_START: - InfoMessage(_("Place a note on the layout")); + switch (action) { + case C_START: + InfoMessage(_("Place a note on the layout")); curNoteType = VP2L(commandContext); - return C_CONTINUE; - - case C_DOWN: - state_on = TRUE; - oldPos = pos; - return C_CONTINUE; - - case C_MOVE: - oldPos = pos; - return C_CONTINUE; - - case C_UP: - UndoStart(_("New Note"), "New Note"); - state_on = FALSE; - trk = NewNote(-1, pos, curNoteType ); - inDescribeCmd = TRUE; - DrawNewTrack(trk); - - switch (curNoteType) - { + return C_CONTINUE; + + case C_DOWN: + state_on = TRUE; + oldPos = pos; + return C_CONTINUE; + + case C_MOVE: + oldPos = pos; + return C_CONTINUE; + + case C_UP: + UndoStart(_("New Note"), "New Note"); + state_on = FALSE; + + switch (curNoteType) { case OP_NOTETEXT: - NewTextNoteUI(trk); + NewTextNoteUI(pos); break; case OP_NOTELINK: - NewLinkNoteUI(trk); + NewLinkNoteUI(pos); break; case OP_NOTEFILE: - NewFileNoteUI(trk); + NewFileNoteUI(pos); break; } - inDescribeCmd = FALSE; - return C_CONTINUE; - case C_REDRAW: - if (state_on) { + case C_REDRAW: + if (state_on) { switch (curNoteType) { case OP_NOTETEXT: DrawBitMap(&tempD, oldPos, note_bm, normalColor); @@ -682,17 +563,20 @@ static STATUS_T CmdNote(wAction_t action, coOrd pos) case OP_NOTELINK: DrawBitMap(&tempD, oldPos, link_bm, normalColor); break; + case OP_NOTEFILE: + DrawBitMap(&tempD, oldPos, document_bm, normalColor); + break; } - } - return C_CONTINUE; + } + return C_CONTINUE; - case C_CANCEL: - DescribeCancel(); - state_on = FALSE; - return C_CONTINUE; - } + case C_CANCEL: + DescribeCancel(); + state_on = FALSE; + return C_CONTINUE; + } - return C_INFO; + return C_INFO; } #include "bitmaps/note.xbm" @@ -702,9 +586,10 @@ static STATUS_T CmdNote(wAction_t action, coOrd pos) void InitTrkNote(wMenu_p menu) { - note_bm = wDrawBitMapCreate(mainD.d, note_width, note_width, 8, 8, note_bits); - link_bm = wDrawBitMapCreate(mainD.d, note_width, note_width, 8, 8, link_bits); - document_bm = wDrawBitMapCreate(mainD.d, note_width, note_width, 8, 8, clip_bits); + note_bm = wDrawBitMapCreate(mainD.d, note_width, note_width, 8, 8, note_bits); + link_bm = wDrawBitMapCreate(mainD.d, note_width, note_width, 8, 8, link_bits); + document_bm = wDrawBitMapCreate(mainD.d, note_width, note_width, 8, 8, + clip_bits); ButtonGroupBegin(_("Notes"), "cmdNoteCmd", _("Add notes")); for (int i = 0; i < NOTETYPESCOUNT; i++) { @@ -713,7 +598,8 @@ void InitTrkNote(wMenu_p menu) nt = noteTypes + i; icon = wIconCreatePixMap(nt->xpm[iconSize]); - AddMenuButton(menu, CmdNote, nt->helpKey, _(nt->cmdName), icon, LEVEL0_50, IC_STICKY | IC_POPUP2, nt->acclKey, I2VP(nt->OP)); + AddMenuButton(menu, CmdNote, nt->helpKey, _(nt->cmdName), icon, LEVEL0_50, + IC_STICKY | IC_POPUP2, nt->acclKey, I2VP(nt->OP)); } ButtonGroupEnd(); diff --git a/app/bin/trkseg.c b/app/bin/trkseg.c index ebe1916..82396a2 100644 --- a/app/bin/trkseg.c +++ b/app/bin/trkseg.c @@ -17,13 +17,14 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "common.h" #include "fileio.h" #include "param.h" #include "track.h" +#include "trkendpt.h" #include "misc.h" #include "cbezier.h" #include "tbezier.h" @@ -49,10 +50,10 @@ * that the center of curve is always on an orthogonal line through the bisection of a chord. */ EXPORT void ComputeCurvedSeg( - trkSeg_p s, - DIST_T radius, - coOrd p0, - coOrd p1 ) + trkSeg_p s, + DIST_T radius, + coOrd p0, + coOrd p1 ) { DIST_T d; ANGLE_T a, aa, aaa; @@ -76,10 +77,10 @@ EXPORT void ComputeCurvedSeg( EXPORT coOrd GetSegEndPt( - trkSeg_p segPtr, - EPINX_T ep, - BOOL_T bounds, - ANGLE_T * angleR ) + trkSeg_p segPtr, + EPINX_T ep, + BOOL_T bounds, + ANGLE_T * angleR ) { coOrd pos; ANGLE_T angle, a, a0, a1 = 0.0; @@ -114,38 +115,41 @@ EXPORT coOrd GetSegEndPt( y1 = r * cos(D2R(a0+a1)); if (ep == 0) { pos.x = segPtr->u.c.center.x + (((a0<=270.0)&&(a0+a1>=270.0)) ? - (-r) : min(x0,x1)); + (-r) : min(x0,x1)); pos.y = segPtr->u.c.center.y + (((a0<=180.0)&&(a0+a1>=180.0)) ? - (-r) : min(y0,y1)); + (-r) : min(y0,y1)); } else { pos.x = segPtr->u.c.center.x + (((a0<= 90.0)&&(a0+a1>= 90.0)) ? - (r) : max(x0,x1)); + (r) : max(x0,x1)); pos.y = segPtr->u.c.center.y + ((a0+a1>=360.0) ? - (r) : max(y0,y1)); + (r) : max(y0,y1)); } } else { PointOnCircle( &pos, segPtr->u.c.center, fabs(segPtr->u.c.radius), a ); } break; case SEG_JNTTRK: - pos = GetJointSegEndPos( segPtr->u.j.pos, segPtr->u.j.angle, segPtr->u.j.l0, segPtr->u.j.l1, segPtr->u.j.R, segPtr->u.j.L, segPtr->u.j.negate, segPtr->u.j.flip, segPtr->u.j.Scurve, ep, &angle ); + pos = GetJointSegEndPos( segPtr->u.j.pos, segPtr->u.j.angle, segPtr->u.j.l0, + segPtr->u.j.l1, segPtr->u.j.R, segPtr->u.j.L, segPtr->u.j.negate, + segPtr->u.j.flip, segPtr->u.j.Scurve, ep, &angle ); break; - case SEG_BEZTRK: - case SEG_BEZLIN: - if (ep ==1) { - pos = segPtr->u.b.pos[3]; //For Bezier, use the End Points of the overall curve - angle = FindAngle(segPtr->u.b.pos[2],segPtr->u.b.pos[3]); - } else { - pos = segPtr->u.b.pos[0]; - angle = FindAngle(segPtr->u.b.pos[1],segPtr->u.b.pos[0]); - } - - break; - default: - AbortProg("GetSegCntPt(%c)", segPtr->type ); + case SEG_BEZTRK: + case SEG_BEZLIN: + if (ep ==1) { + pos = segPtr->u.b.pos[3]; //For Bezier, use the End Points of the overall curve + angle = FindAngle(segPtr->u.b.pos[2],segPtr->u.b.pos[3]); + } else { + pos = segPtr->u.b.pos[0]; + angle = FindAngle(segPtr->u.b.pos[1],segPtr->u.b.pos[0]); + } + + break; + default: + CHECKMSG( FALSE, ("GetSegCntPt(%c)", segPtr->type ) ); } - if ( angleR ) + if ( angleR ) { *angleR = angle; + } return pos; } @@ -160,12 +164,12 @@ EXPORT coOrd GetSegEndPt( * \param hiR OUT top right corner */ EXPORT void GetTextBounds( - coOrd pos, - ANGLE_T angle, - char * str, - FONTSIZE_T fs, - coOrd * loR, - coOrd * hiR ) + coOrd pos, + ANGLE_T angle, + char * str, + FONTSIZE_T fs, + coOrd * loR, + coOrd * hiR ) { coOrd size, size2; @@ -186,25 +190,24 @@ EXPORT void GetTextBounds( lo = hi = zero; // rotate each point - for (i=0; i<4; i++) - { - Rotate(&p[i], zero, angle); + for (i=0; i<4; i++) { + Rotate(&p[i], zero, angle); - if (p[i].x < lo.x) { - lo.x = p[i].x; - } + if (p[i].x < lo.x) { + lo.x = p[i].x; + } - if (p[i].y < lo.y) { - lo.y = p[i].y; - } + if (p[i].y < lo.y) { + lo.y = p[i].y; + } - if (p[i].x > hi.x) { - hi.x = p[i].x; - } + if (p[i].x > hi.x) { + hi.x = p[i].x; + } - if (p[i].y > hi.y) { - hi.y = p[i].y; - } + if (p[i].y > hi.y) { + hi.y = p[i].y; + } } // now recaclulate the corners @@ -215,15 +218,25 @@ EXPORT void GetTextBounds( } -static void Get1SegBounds( trkSeg_p segPtr, coOrd xlat, ANGLE_T angle, coOrd *lo, coOrd *hi ) +static void Get1SegBounds( trkSeg_p segPtr, coOrd xlat, ANGLE_T angle, + coOrd *lo, coOrd *hi ) { int inx; - coOrd p0, p1, pBez[4], pc; + coOrd p0, p1, pBez, pc; ANGLE_T a0, a1; coOrd width; DIST_T radius; + LWIDTH_T lwidth; width = zero; + if (segPtr->lineWidth < 0) { + // TO DO: Using scale is correct, but the correct context may not be mainD + // For now, we're assuming it will be close enough to zero + lwidth = 0; // -(DIST_T)segPtr->lineWidth / mainD.scale; + } else { + lwidth = (LWIDTH_T)segPtr->lineWidth; + } + switch ( segPtr->type ) { case ' ': return; @@ -235,78 +248,91 @@ static void Get1SegBounds( trkSeg_p segPtr, coOrd xlat, ANGLE_T angle, coOrd *lo case SEG_TBLEDGE: case SEG_CRVLIN: case SEG_JNTTRK: - REORIGIN( p0, GetSegEndPt( segPtr, 0, FALSE, NULL ), angle, xlat ) - REORIGIN( p1, GetSegEndPt( segPtr, 1, FALSE, NULL ), angle, xlat ) - if (p0.x < p1.x) { - lo->x = p0.x; - hi->x = p1.x; - } else { - lo->x = p1.x; - hi->x = p0.x; - } - if (p0.y < p1.y) { - lo->y = p0.y; - hi->y = p1.y; - } else { - lo->y = p1.y; - hi->y = p0.y; + REORIGIN( p0, GetSegEndPt( segPtr, 0, FALSE, NULL ), angle, xlat ) + REORIGIN( p1, GetSegEndPt( segPtr, 1, FALSE, NULL ), angle, xlat ) + if (p0.x < p1.x) { + lo->x = p0.x; + hi->x = p1.x; + } else { + lo->x = p1.x; + hi->x = p0.x; + } + if (p0.y < p1.y) { + lo->y = p0.y; + hi->y = p1.y; + } else { + lo->y = p1.y; + hi->y = p0.y; + } + if ( (segPtr->type == SEG_CRVTRK) || + (segPtr->type == SEG_CRVLIN) ) { + /* TODO: be more precise about curved line width */ + width.x = width.y = lwidth; + REORIGIN( pc, segPtr->u.c.center, angle, xlat ); + a0 = NormalizeAngle( segPtr->u.c.a0 + angle ); + a1 = segPtr->u.c.a1; + radius = fabs(segPtr->u.c.radius); + if ( a1 >= 360.0 ) { + lo->x = pc.x - radius; + lo->y = pc.y - radius; + hi->x = pc.x + radius; + hi->y = pc.y + radius; + break; } - if ( (segPtr->type == SEG_CRVTRK) || - (segPtr->type == SEG_CRVLIN) ) { - /* TODO: be more precise about curved line width */ - width.x = width.y = fabs(segPtr->width)/2.0; - REORIGIN( pc, segPtr->u.c.center, angle, xlat ); - a0 = NormalizeAngle( segPtr->u.c.a0 + angle ); - a1 = segPtr->u.c.a1; - radius = fabs(segPtr->u.c.radius); - if ( a1 >= 360.0 ) { - lo->x = pc.x - radius; - lo->y = pc.y - radius; - hi->x = pc.x + radius; - hi->y = pc.y + radius; - break; - } - if ( a0 + a1 >= 360.0 ) - hi->y = pc.y + radius; - if ( a0 < 90.0 && a0+a1 >= 90.0 ) - hi->x = pc.x + radius; - if ( a0 > 90.0 && a0+a1 >= 450.0 ) - hi->x = pc.x + radius; - if ( a0 < 180.0 && a0+a1 >= 180.0 ) - lo->y = pc.y - radius; - if (a0 > 180.0 && a0+a1 >= 540.0 ) - lo->y = pc.y - radius; - if ( a0 < 270.0 && a0+a1 >= 270.0 ) - lo->x = pc.x - radius; - if ( a0 > 270.0 && a0+a1 >= 630.0 ) - lo->x = pc.x - radius; + if ( a0 + a1 >= 360.0 ) { + hi->y = pc.y + radius; + } + if ( a0 < 90.0 && a0+a1 >= 90.0 ) { + hi->x = pc.x + radius; + } + if ( a0 > 90.0 && a0+a1 >= 450.0 ) { + hi->x = pc.x + radius; + } + if ( a0 < 180.0 && a0+a1 >= 180.0 ) { + lo->y = pc.y - radius; + } + if (a0 > 180.0 && a0+a1 >= 540.0 ) { + lo->y = pc.y - radius; + } + if ( a0 < 270.0 && a0+a1 >= 270.0 ) { + lo->x = pc.x - radius; } - if ( segPtr->type == SEG_STRLIN ) { - width.x = fabs(segPtr->width) * fabs(cos( D2R( FindAngle(p0, p1) ) ) ) / 2.0; - width.y = fabs(segPtr->width) * fabs(sin( D2R( FindAngle(p0, p1) ) ) ) / 2.0; - } else if ( segPtr->type == SEG_BENCH ) { - width.x = BenchGetWidth( segPtr->u.l.option ) * fabs(cos( D2R( FindAngle(p0, p1) ) ) ) / 2.0; - width.y = BenchGetWidth( segPtr->u.l.option ) * fabs(sin( D2R( FindAngle(p0, p1) ) ) ) / 2.0; + if ( a0 > 270.0 && a0+a1 >= 630.0 ) { + lo->x = pc.x - radius; } + } + if ( segPtr->type == SEG_STRLIN ) { + width.x = lwidth * fabs(cos(D2R(FindAngle(p0, p1)))); + width.y = lwidth * fabs(sin(D2R(FindAngle(p0, p1)))); + } else if ( segPtr->type == SEG_BENCH ) { + width.x = BenchGetWidth( segPtr->u.l.option ) * fabs(cos( D2R( FindAngle(p0, + p1) ) ) ) / 2.0; + width.y = BenchGetWidth( segPtr->u.l.option ) * fabs(sin( D2R( FindAngle(p0, + p1) ) ) ) / 2.0; + } break; case SEG_POLY: /* TODO: be more precise about poly line width */ - width.x = width.y = fabs(segPtr->width)/2.0; + width.x = width.y = lwidth; case SEG_FILPOLY: for (inx=0; inx<segPtr->u.p.cnt; inx++ ) { REORIGIN( p0, segPtr->u.p.pts[inx].pt, angle, xlat ) if (inx==0) { *lo = *hi = p0; } else { - if (p0.x < lo->x) + if (p0.x < lo->x) { lo->x = p0.x; - if (p0.y < lo->y) + } + if (p0.y < lo->y) { lo->y = p0.y; - if (p0.x > hi->x) + } + if (p0.x > hi->x) { hi->x = p0.x; - if (p0.y > hi->y) + } + if (p0.y > hi->y) { hi->y = p0.y; + } } } break; @@ -319,23 +345,23 @@ static void Get1SegBounds( trkSeg_p segPtr, coOrd xlat, ANGLE_T angle, coOrd *lo break; case SEG_TEXT: REORIGIN( p0, segPtr->u.t.pos, angle, xlat ) - GetTextBounds( p0, angle+segPtr->u.t.angle, segPtr->u.t.string, segPtr->u.t.fontSize, lo, hi ); + GetTextBounds( p0, angle+segPtr->u.t.angle, segPtr->u.t.string, + segPtr->u.t.fontSize, lo, hi ); break; + /* The following code is executed only for Cornu track */ case SEG_BEZLIN: case SEG_BEZTRK: //Bezier control arms form a "tent" around the curve - REORIGIN( pBez[0], segPtr->u.b.pos[0], angle, xlat ) - REORIGIN( pBez[1], segPtr->u.b.pos[1], angle, xlat ) - REORIGIN( pBez[2], segPtr->u.b.pos[2], angle, xlat ) - REORIGIN( pBez[3], segPtr->u.b.pos[3], angle, xlat ) - lo->x = hi->x = pBez[0].x; - lo->y = hi->y = pBez[0].y; - for (int i=1;i<4;i++) { - lo->x = lo->x>pBez[i].x?pBez[i].x:lo->x; - lo->y = lo->y>pBez[i].y?pBez[i].y:lo->y; - hi->x = hi->x<pBez[i].x?pBez[i].x:hi->x; - hi->y = hi->y<pBez[i].y?pBez[i].y:hi->y; + REORIGIN( pBez, segPtr->u.b.pos[0], angle, xlat ) + lo->x = hi->x = pBez.x; + lo->y = hi->y = pBez.y; + for (int i=1; i<4; i++) { + REORIGIN(pBez, segPtr->u.b.pos[i], angle, xlat) + lo->x = lo->x>pBez.x?pBez.x:lo->x; + lo->y = lo->y>pBez.y?pBez.y:lo->y; + hi->x = hi->x<pBez.x?pBez.x:hi->x; + hi->y = hi->y<pBez.y?pBez.y:hi->y; } - width.x = width.y = fabs(segPtr->width)/2.0; + width.x = width.y = lwidth; break; default: ; @@ -348,12 +374,12 @@ static void Get1SegBounds( trkSeg_p segPtr, coOrd xlat, ANGLE_T angle, coOrd *lo EXPORT void GetSegBounds( - coOrd xlat, - ANGLE_T angle, - wIndex_t segCnt, - trkSeg_p segs, - coOrd * orig_ret, - coOrd * size_ret ) + coOrd xlat, + ANGLE_T angle, + wIndex_t segCnt, + trkSeg_p segs, + coOrd * orig_ret, + coOrd * size_ret ) { trkSeg_p s; coOrd lo, hi, tmpLo, tmpHi; @@ -361,21 +387,27 @@ EXPORT void GetSegBounds( first = TRUE; for (s=segs; s<&segs[segCnt]; s++) { - if (s->type == ' ') + if (s->type == ' ') { continue; + } + if (first) { Get1SegBounds( s, xlat, angle, &lo, &hi ); first = FALSE; } else { Get1SegBounds( s, xlat, angle, &tmpLo, &tmpHi ); - if (tmpLo.x < lo.x) + if (tmpLo.x < lo.x) { lo.x = tmpLo.x; - if (tmpLo.y < lo.y) + } + if (tmpLo.y < lo.y) { lo.y = tmpLo.y; - if (tmpHi.x > hi.x) + } + if (tmpHi.x > hi.x) { hi.x = tmpHi.x; - if (tmpHi.y > hi.y) + } + if (tmpHi.y > hi.y) { hi.y = tmpHi.y; + } } } if (first) { @@ -401,9 +433,9 @@ EXPORT void GetSegBounds( EXPORT void MoveSegs( - wIndex_t segCnt, - trkSeg_p segs, - coOrd orig ) + wIndex_t segCnt, + trkSeg_p segs, + coOrd orig ) { trkSeg_p s; int inx; @@ -441,24 +473,24 @@ EXPORT void MoveSegs( s->u.j.pos.x += orig.x; s->u.j.pos.y += orig.y; break; - case SEG_BEZTRK: - case SEG_BEZLIN: - for (inx=0;inx<4;inx++) { - s->u.b.pos[inx].x +=orig.x; - s->u.b.pos[inx].y +=orig.y; - } - FixUpBezierSeg(s->u.b.pos,s,s->type == SEG_BEZTRK); - break; + case SEG_BEZTRK: + case SEG_BEZLIN: + for (inx=0; inx<4; inx++) { + s->u.b.pos[inx].x +=orig.x; + s->u.b.pos[inx].y +=orig.y; + } + FixUpBezierSeg(s->u.b.pos,s,s->type == SEG_BEZTRK); + break; } } } EXPORT void RotateSegs( - wIndex_t segCnt, - trkSeg_p segs, - coOrd orig, - ANGLE_T angle ) + wIndex_t segCnt, + trkSeg_p segs, + coOrd orig, + ANGLE_T angle ) { trkSeg_p s; int inx; @@ -493,23 +525,23 @@ EXPORT void RotateSegs( Rotate( &s->u.j.pos, orig, angle ); s->u.j.angle = NormalizeAngle( s->u.j.angle+angle ); break; - case SEG_BEZLIN: - case SEG_BEZTRK: - Rotate( &s->u.b.pos[0], orig, angle ); - Rotate( &s->u.b.pos[1], orig, angle ); - Rotate( &s->u.b.pos[2], orig, angle ); - Rotate( &s->u.b.pos[3], orig, angle ); - FixUpBezierSeg(s->u.b.pos,s,s->type == SEG_BEZTRK); - break; - } + case SEG_BEZLIN: + case SEG_BEZTRK: + Rotate( &s->u.b.pos[0], orig, angle ); + Rotate( &s->u.b.pos[1], orig, angle ); + Rotate( &s->u.b.pos[2], orig, angle ); + Rotate( &s->u.b.pos[3], orig, angle ); + FixUpBezierSeg(s->u.b.pos,s,s->type == SEG_BEZTRK); + break; + } } } EXPORT void FlipSegs( - wIndex_t segCnt, - trkSeg_p segs, - coOrd orig, - ANGLE_T angle ) + wIndex_t segCnt, + trkSeg_p segs, + coOrd orig, + ANGLE_T angle ) { trkSeg_p s; int inx; @@ -530,12 +562,13 @@ EXPORT void FlipSegs( case SEG_CRVLIN: case SEG_FILCRCL: s->u.c.center.y = -s->u.c.center.y; - if ( s->u.c.a1 < 360.0 ) + if ( s->u.c.a1 < 360.0 ) { s->u.c.a0 = NormalizeAngle( 180.0 - s->u.c.a0 - s->u.c.a1 ); + } break; case SEG_TEXT: s->u.t.pos.y = -s->u.t.pos.y; -/* TODO flip text angle */ + /* TODO flip text angle */ break; case SEG_POLY: case SEG_FILPOLY: @@ -553,32 +586,33 @@ EXPORT void FlipSegs( s->u.j.angle = NormalizeAngle( 180.0 - s->u.j.angle ); s->u.j.negate = ! s->u.j.negate; break; - case SEG_BEZTRK: - case SEG_BEZLIN: - s->u.b.pos[0].y = -s->u.b.pos[0].y; - s->u.b.pos[1].y = -s->u.b.pos[1].y; - s->u.b.pos[2].y = -s->u.b.pos[2].y; - s->u.b.pos[3].y = -s->u.b.pos[3].y; - FixUpBezierSeg(s->u.b.pos,s,s->type == SEG_BEZTRK); - break; + case SEG_BEZTRK: + case SEG_BEZLIN: + s->u.b.pos[0].y = -s->u.b.pos[0].y; + s->u.b.pos[1].y = -s->u.b.pos[1].y; + s->u.b.pos[2].y = -s->u.b.pos[2].y; + s->u.b.pos[3].y = -s->u.b.pos[3].y; + FixUpBezierSeg(s->u.b.pos,s,s->type == SEG_BEZTRK); + break; } } } EXPORT void RescaleSegs( - wIndex_t segCnt, - trkSeg_p segs, - DIST_T scale_x, - DIST_T scale_y, - DIST_T scale_w ) + wIndex_t segCnt, + trkSeg_p segs, + DIST_T scale_x, + DIST_T scale_y, + DIST_T scale_w ) { trkSeg_p s; int inx; for (s=segs; s<&segs[segCnt]; s++) { - if (s->width>0) - s->width *= scale_w; + if (s->lineWidth>0) { + s->lineWidth *= scale_w; + } switch (s->type) { case SEG_STRLIN: case SEG_DIMLIN: @@ -617,19 +651,19 @@ EXPORT void RescaleSegs( s->u.j.l0 *= scale_w; s->u.j.l1 *= scale_w; break; - case SEG_BEZTRK: - case SEG_BEZLIN: - s->u.b.pos[0].y *= scale_y; - s->u.b.pos[0].x *= scale_x; - s->u.b.pos[1].x *= scale_x; - s->u.b.pos[1].y *= scale_y; - s->u.b.pos[2].y *= scale_y; - s->u.b.pos[2].x *= scale_x; - s->u.b.pos[3].x *= scale_x; - s->u.b.pos[3].y *= scale_y; - FixUpBezierSeg(s->u.b.pos,s,s->type == SEG_BEZTRK); + case SEG_BEZTRK: + case SEG_BEZLIN: + s->u.b.pos[0].y *= scale_y; + s->u.b.pos[0].x *= scale_x; + s->u.b.pos[1].x *= scale_x; + s->u.b.pos[1].y *= scale_y; + s->u.b.pos[2].y *= scale_y; + s->u.b.pos[2].x *= scale_x; + s->u.b.pos[3].x *= scale_x; + s->u.b.pos[3].y *= scale_y; + FixUpBezierSeg(s->u.b.pos,s,s->type == SEG_BEZTRK); - break; + break; } } @@ -637,9 +671,9 @@ EXPORT void RescaleSegs( EXPORT void CloneFilledDraw( - int segCnt, - trkSeg_p segs, - BOOL_T reorigin ) + int segCnt, + trkSeg_p segs, + BOOL_T reorigin ) { pts_t * newPts; trkSeg_p sp; @@ -652,8 +686,9 @@ EXPORT void CloneFilledDraw( newPts = (pts_t*)MyMalloc( sp->u.p.cnt * sizeof (pts_t) ); memcpy( newPts, sp->u.p.pts, sp->u.p.cnt * sizeof (pts_t) ); if ( reorigin ) { - for ( inx = 0; inx<sp->u.p.cnt; inx++ ) + for ( inx = 0; inx<sp->u.p.cnt; inx++ ) { REORIGIN( newPts[inx].pt, sp->u.p.pts[inx].pt, sp->u.p.angle, sp->u.p.orig ); + } sp->u.p.angle = 0; sp->u.p.orig = zero; } @@ -666,10 +701,8 @@ EXPORT void CloneFilledDraw( break; case SEG_BEZTRK: case SEG_BEZLIN: - sp->bezSegs.cnt = 0; - //if (sp->bezSegs.ptr) MyFree(sp->bezSegs.ptr); Make sure no update to static - sp->bezSegs.ptr = NULL; - sp->bezSegs.max = 0; + // NOTE Don't free storage See CS:036e709b4ca9 + DYNARR_INIT( trkSeg_t, sp->bezSegs ); FixUpBezierSeg(sp->u.b.pos,sp,sp->type == SEG_BEZTRK); break; default: @@ -680,8 +713,8 @@ EXPORT void CloneFilledDraw( EXPORT void FreeFilledDraw( - int segCnt, - trkSeg_p segs ) + int segCnt, + trkSeg_p segs ) { trkSeg_p sp; @@ -689,13 +722,15 @@ EXPORT void FreeFilledDraw( switch (sp->type) { case SEG_POLY: case SEG_FILPOLY: - if ( sp->u.p.pts ) + if ( sp->u.p.pts ) { MyFree( sp->u.p.pts ); + } sp->u.p.pts = NULL; break; case SEG_TEXT: - if (sp->u.t.string) + if (sp->u.t.string) { MyFree(sp->u.t.string); + } sp->u.t.string = NULL; break; default: @@ -713,12 +748,12 @@ EXPORT void FreeFilledDraw( */ EXPORT DIST_T DistanceSegs( - coOrd orig, - ANGLE_T angle, - wIndex_t segCnt, - trkSeg_p segPtr, - coOrd * pos, - wIndex_t * inx_ret ) + coOrd orig, + ANGLE_T angle, + wIndex_t segCnt, + trkSeg_p segPtr, + coOrd * pos, + wIndex_t * inx_ret ) { DIST_T d, dd = DIST_INF, ddd; coOrd p0, p1, p2, pt, lo, hi; @@ -740,76 +775,85 @@ EXPORT DIST_T DistanceSegs( case SEG_TBLEDGE: dd = LineDistance( &p1, segPtr->u.l.pos[0], segPtr->u.l.pos[1] ); if ( segPtr->type == SEG_BENCH ) { - if ( dd < BenchGetWidth( segPtr->u.l.option )/2.0 ) + if ( dd < BenchGetWidth( segPtr->u.l.option )/2.0 ) { dd = 0.0; + } } break; case SEG_CRVTRK: case SEG_CRVLIN: case SEG_FILCRCL: - dd = CircleDistance( &p1, segPtr->u.c.center, fabs(segPtr->u.c.radius), segPtr->u.c.a0, segPtr->u.c.a1 ); + dd = CircleDistance( &p1, segPtr->u.c.center, fabs(segPtr->u.c.radius), + segPtr->u.c.a0, segPtr->u.c.a1 ); break; case SEG_POLY: case SEG_FILPOLY: ddd = DIST_INF; - for (lin=0;lin<segPtr->u.p.cnt;lin++) { + for (lin=0; lin<segPtr->u.p.cnt; lin++) { pt = p0; - if (lin < segPtr->u.p.cnt-1 ) + if (lin < segPtr->u.p.cnt-1 ) { ddd = LineDistance( &pt, segPtr->u.p.pts[lin].pt, segPtr->u.p.pts[lin+1].pt ); - else if (segPtr->u.p.polyType != POLYLINE) + } else if (segPtr->u.p.polyType != POLYLINE) { ddd = LineDistance( &pt, segPtr->u.p.pts[lin].pt, segPtr->u.p.pts[0].pt ); + } if ( ddd < dd ) { dd = ddd; p1 = pt; } } break; - case SEG_BEZTRK: - case SEG_BEZLIN: - dd = DIST_INF; - pt = p0; - for (int i = 0;i<segPtr->bezSegs.cnt;i++) { - segProcData2.distance.pos1 = pt; - SegProc(SEGPROC_DISTANCE,&DYNARR_N(trkSeg_t,segPtr->bezSegs,i),&segProcData2); - if (segProcData2.distance.dd<dd) { - dd = segProcData2.distance.dd; - p1 = segProcData2.distance.pos1; - } - } - break; + case SEG_BEZTRK: + case SEG_BEZLIN: + dd = DIST_INF; + pt = p0; + for (int i = 0; i<segPtr->bezSegs.cnt; i++) { + segProcData2.distance.pos1 = pt; + SegProc(SEGPROC_DISTANCE,&DYNARR_N(trkSeg_t,segPtr->bezSegs,i),&segProcData2); + if (segProcData2.distance.dd<dd) { + dd = segProcData2.distance.dd; + p1 = segProcData2.distance.pos1; + } + } + break; case SEG_TEXT: /*GetTextBounds( segPtr->u.t.pos, angle+segPtr->u.t.angle, segPtr->u.t.string, segPtr->u.t.fontSize, &lo, &hi );*/ - GetTextBounds( zero, 0, segPtr->u.t.string, segPtr->u.t.fontSize, &lo, &hi ); //lo and hi are relative to seg origin - p0.x -= segPtr->u.t.pos.x; - p0.y -= segPtr->u.t.pos.y; - Rotate( &p0, zero, -segPtr->u.t.angle ); - if (p0.x > lo.x && p0.x < hi.x && p0.y >lo.y && p0.y < hi.y) { //Within rectangle - therefore small dist + GetTextBounds( zero, 0, segPtr->u.t.string, segPtr->u.t.fontSize, &lo, + &hi ); //lo and hi are relative to seg origin + p1.x -= segPtr->u.t.pos.x; + p1.y -= segPtr->u.t.pos.y; + Rotate( &p1, zero, -segPtr->u.t.angle ); + if (p1.x > lo.x && p1.x < hi.x && p1.y >lo.y + && p1.y < hi.y) { //Within rectangle - therefore small dist hi.x /= 2.0; hi.y /= 2.0; - dd = 0.1*FindDistance(hi, p0)/FindDistance(lo,hi); // Proportion to mean that the closer we to the center or the smaller the target in overlapping cases, the more likely we pick it + dd = 0.1*FindDistance(hi, p1)/FindDistance(lo, + hi); // Proportion to mean that the closer we to the center or the smaller the target in overlapping cases, the more likely we pick it break; } hi.x /= 2.0; // rough center of rectangle hi.y /= 2.0; - if (fabs((p0.x-hi.x)/hi.x)<fabs((p0.y-hi.y)/hi.y)) { // Proportionally closer to x - if (p0.x > hi.x) dd = (p0.x - hi.x); - else dd = fabs(p0.x-hi.x); + if (fabs((p1.x-hi.x)/hi.x)<fabs((p1.y + -hi.y)/hi.y)) { // Proportionally closer to x + if (p1.x > hi.x) { dd = (p1.x - hi.x); } + else { dd = fabs(p1.x-hi.x); } } else { // Closer to y - if (p0.y > hi.y) dd = (p0.y - hi.y); - else dd = fabs(p0.y-hi.y); + if (p1.y > hi.y) { dd = (p1.y - hi.y); } + else { dd = fabs(p1.y-hi.y); } } /*printf( "dx=%0.4f dy=%0.4f dd=%0.3f\n", dx, dy, dd );*/ -/* - if ( p0.x >= lo.x && p0.x <= hi.x && - p0.y >= lo.y && p0.y <= hi.y ) { - p1.x = (lo.x+hi.x)/2.0; - p1.y = (lo.y+hi.y)/2.0; - dd = FindDistance( p0, p1 ); - } -*/ + /* + if ( p1.x >= lo.x && p1.x <= hi.x && + p1.y >= lo.y && p1.y <= hi.y ) { + p1.x = (lo.x+hi.x)/2.0; + p1.y = (lo.y+hi.y)/2.0; + dd = FindDistance( p1, p1 ); + } + */ break; case SEG_JNTTRK: - dd = JointDistance( &p1, segPtr->u.j.pos, segPtr->u.j.angle, segPtr->u.j.l0, segPtr->u.j.l1, segPtr->u.j.R, segPtr->u.j.L, segPtr->u.j.negate, segPtr->u.j.Scurve ); + dd = JointDistance( &p1, segPtr->u.j.pos, segPtr->u.j.angle, segPtr->u.j.l0, + segPtr->u.j.l1, segPtr->u.j.R, segPtr->u.j.L, segPtr->u.j.negate, + segPtr->u.j.Scurve ); break; default: dd = DIST_INF; @@ -817,8 +861,9 @@ EXPORT DIST_T DistanceSegs( if (dd < d) { d = dd; p2 = p1; - if (inx_ret) + if (inx_ret) { *inx_ret = inx; + } found = TRUE; } } @@ -837,14 +882,14 @@ EXPORT DIST_T DistanceSegs( * */ EXPORT ANGLE_T GetAngleSegs( - wIndex_t segCnt, - trkSeg_p segPtr, - coOrd * pos1, // Now IN/OUT OUT = - wIndex_t * segInxR, - DIST_T * dist, - BOOL_T * seg_backwards, - wIndex_t * subSegInxR, - BOOL_T * negative_radius) + wIndex_t segCnt, + trkSeg_p segPtr, + coOrd * pos1, // Now IN/OUT OUT = + wIndex_t * segInxR, + DIST_T * dist, + BOOL_T * seg_backwards, + wIndex_t * subSegInxR, + BOOL_T * negative_radius) { wIndex_t inx; ANGLE_T angle = 0.0; @@ -854,10 +899,10 @@ EXPORT ANGLE_T GetAngleSegs( coOrd pos2 = * pos1; BOOL_T negative = FALSE; BOOL_T backwards = FALSE; - if (subSegInxR) *subSegInxR = -1; + if (subSegInxR) { *subSegInxR = -1; } d = DistanceSegs( zero, 0.0, segCnt, segPtr, &pos2, &inx ); // - if (dist) * dist = d; + if (dist) { * dist = d; } segPtr += inx; segProcData.getAngle.pos = pos2; switch ( segPtr->type ) { @@ -881,26 +926,28 @@ EXPORT ANGLE_T GetAngleSegs( JointSegProc( SEGPROC_GETANGLE, segPtr, &segProcData ); angle = segProcData.getAngle.angle; break; - case SEG_BEZTRK: - case SEG_BEZLIN: - BezierSegProc( SEGPROC_GETANGLE, segPtr, &segProcData ); - angle = segProcData.getAngle.angle; - negative = segProcData.getAngle.negative_radius; - backwards = segProcData.getAngle.backwards; - if (subSegInxR) *subSegInxR = segProcData.getAngle.bezSegInx; - break; + case SEG_BEZTRK: + case SEG_BEZLIN: + BezierSegProc( SEGPROC_GETANGLE, segPtr, &segProcData ); + angle = segProcData.getAngle.angle; + negative = segProcData.getAngle.negative_radius; + backwards = segProcData.getAngle.backwards; + if (subSegInxR) { *subSegInxR = segProcData.getAngle.bezSegInx; } + break; case SEG_POLY: case SEG_FILPOLY: p0 = p1 = pos2; - dd = LineDistance( &p0, segPtr->u.p.pts[segPtr->u.p.cnt-1].pt, segPtr->u.p.pts[0].pt ); - angle = FindAngle( segPtr->u.p.pts[segPtr->u.p.cnt-1].pt, segPtr->u.p.pts[0].pt ); + dd = LineDistance( &p0, segPtr->u.p.pts[segPtr->u.p.cnt-1].pt, + segPtr->u.p.pts[0].pt ); + angle = FindAngle( segPtr->u.p.pts[segPtr->u.p.cnt-1].pt, + segPtr->u.p.pts[0].pt ); for ( inx=0; inx<segPtr->u.p.cnt-1; inx++ ) { p0 = p1; d = LineDistance( &p0, segPtr->u.p.pts[inx].pt, segPtr->u.p.pts[inx+1].pt ); if ( d < dd ) { dd = d; angle = FindAngle( segPtr->u.p.pts[inx].pt, segPtr->u.p.pts[inx+1].pt ); - if (subSegInxR) *subSegInxR = inx; + if (subSegInxR) { *subSegInxR = inx; } pos2 = p0; } } @@ -909,11 +956,11 @@ EXPORT ANGLE_T GetAngleSegs( angle = segPtr->u.t.angle; break; default: - AbortProg( "GetAngleSegs(%d)", segPtr->type ); + CHECKMSG( FALSE, ( "GetAngleSegs(%d)", segPtr->type ) ); } - if ( segInxR ) *segInxR = inx; - if (seg_backwards) *seg_backwards = backwards; - if (negative_radius) *negative_radius = negative; + if ( segInxR ) { *segInxR = inx; } + if (seg_backwards) { *seg_backwards = backwards; } + if (negative_radius) { *negative_radius = negative; } * pos1 = pos2; return angle; @@ -926,72 +973,70 @@ EXPORT ANGLE_T GetAngleSegs( ****************************************************************************/ typedef struct { - FLOAT_T h, s, v; - } hsv_t; + FLOAT_T h, s, v; +} hsv_t; static FLOAT_T max_s; static FLOAT_T max_v; static dynArr_t hsv_da; #define hsv(N) DYNARR_N( hsv_t, hsv_da, N ) static void Hsv2rgb( - hsv_t hsv, - long *rgb ) + hsv_t hsv, + long *rgb ) { - int i; - FLOAT_T f, w, q, t, r=0, g=0, b=0; - - if (hsv.s == 0.0) - hsv.s = 0.000001; + int i; + FLOAT_T f, w, q, t, r=0, g=0, b=0; - if (hsv.h == -1.0) - { - r = hsv.v; - g = hsv.v; - b = hsv.v; + if (hsv.s == 0.0) { + hsv.s = 0.000001; } - else - { - if (hsv.h == 360.0) - hsv.h = 0.0; - hsv.h = hsv.h / 60.0; - i = (int) hsv.h; - f = hsv.h - i; - w = hsv.v * (1.0 - hsv.s); - q = hsv.v * (1.0 - (hsv.s * f)); - t = hsv.v * (1.0 - (hsv.s * (1.0 - f))); - - switch (i) - { + + if (hsv.h == -1.0) { + r = hsv.v; + g = hsv.v; + b = hsv.v; + } else { + if (hsv.h == 360.0) { + hsv.h = 0.0; + } + hsv.h = hsv.h / 60.0; + i = (int) hsv.h; + f = hsv.h - i; + w = hsv.v * (1.0 - hsv.s); + q = hsv.v * (1.0 - (hsv.s * f)); + t = hsv.v * (1.0 - (hsv.s * (1.0 - f))); + + switch (i) { case 0: - r = hsv.v; - g = t; - b = w; - break; + r = hsv.v; + g = t; + b = w; + break; case 1: - r = q; - g = hsv.v; - b = w; - break; + r = q; + g = hsv.v; + b = w; + break; case 2: - r = w; - g = hsv.v; - b = t; - break; + r = w; + g = hsv.v; + b = t; + break; case 3: - r = w; - g = q; - b = hsv.v; - break; + r = w; + g = q; + b = hsv.v; + break; case 4: - r = t; - g = w; - b = hsv.v; - break; + r = t; + g = w; + b = hsv.v; + break; case 5: - r = hsv.v; - g = w; - b = q; - break; + r = hsv.v; + g = w; + b = q; + break; } } *rgb = wRGB( (int)(r*255), (int)(g*255), (int)(b*255) ); @@ -999,60 +1044,66 @@ static void Hsv2rgb( static void Rgb2hsv( - long rgb, - hsv_t *hsv ) + long rgb, + hsv_t *hsv ) { - FLOAT_T r, g, b; - FLOAT_T max, min, delta; - - r = ((rgb>>16)&0xFF)/255.0; - g = ((rgb>>8)&0xFF)/255.0; - b = ((rgb)&0xFF)/255.0; - - max = r; - if (g > max) - max = g; - if (b > max) - max = b; - - min = r; - if (g < min) - min = g; - if (b < min) - min = b; - - hsv->v = max; - - if (max != 0.0) - hsv->s = (max - min) / max; - else - hsv->s = 0.0; - - if (hsv->s == 0.0) - hsv->h = -1.0; - else - { - delta = max - min; - - if (r == max) - hsv->h = (g - b) / delta; - else if (g == max) - hsv->h = 2.0 + (b - r) / delta; - else if (b == max) - hsv->h = 4.0 + (r - g) / delta; - - hsv->h = hsv->h * 60.0; - - if (hsv->h < 0.0) - hsv->h = hsv->h + 360; + FLOAT_T r, g, b; + FLOAT_T max, min, delta; + + r = ((rgb>>16)&0xFF)/255.0; + g = ((rgb>>8)&0xFF)/255.0; + b = ((rgb)&0xFF)/255.0; + + max = r; + if (g > max) { + max = g; + } + if (b > max) { + max = b; + } + + min = r; + if (g < min) { + min = g; + } + if (b < min) { + min = b; + } + + hsv->v = max; + + if (max != 0.0) { + hsv->s = (max - min) / max; + } else { + hsv->s = 0.0; + } + + if (hsv->s == 0.0) { + hsv->h = -1.0; + } else { + delta = max - min; + + if (r == max) { + hsv->h = (g - b) / delta; + } else if (g == max) { + hsv->h = 2.0 + (b - r) / delta; + } else if (b == max) { + hsv->h = 4.0 + (r - g) / delta; + } + + hsv->h = hsv->h * 60.0; + + if (hsv->h < 0.0) { + hsv->h = hsv->h + 360; + } } } static void Fill_hsv( - wIndex_t segCnt, - trkSeg_p segPtr, - hsv_t * hsvP ) + wIndex_t segCnt, + trkSeg_p segPtr, + hsv_t * hsvP ) { int inx; @@ -1061,18 +1112,20 @@ static void Fill_hsv( for ( inx=0; inx<segCnt; inx++ ) { Rgb2hsv( wDrawGetRGB(segPtr[inx].color), &hsvP[inx] ); if ( hsvP[inx].h >= 0 ) { - if ( max_s < hsvP[inx].s ) + if ( max_s < hsvP[inx].s ) { max_s = hsvP[inx].s; - if ( max_v < hsvP[inx].v ) + } + if ( max_v < hsvP[inx].v ) { max_v = hsvP[inx].v; + } } } } EXPORT void RecolorSegs( - wIndex_t cnt, - trkSeg_p segs, - wDrawColor color ) + wIndex_t cnt, + trkSeg_p segs, + wDrawColor color ) { long rgb; wIndex_t inx; @@ -1084,18 +1137,21 @@ EXPORT void RecolorSegs( rgb = wDrawGetRGB( color ); Rgb2hsv( rgb, &hsv0 ); h = hsv0.h; - if ( max_s > 0.25 ) + if ( max_s > 0.25 ) { s = hsv0.s/max_s; - else + } else { s = 1.0; - if ( max_v > 0.25 ) + } + if ( max_v > 0.25 ) { v = hsv0.v/max_v; - else + } else { v = 1.0; + } for ( inx=0; inx<cnt; inx++,segs++ ) { hsv0 = hsv(inx); - if ( hsv0.h < 0 ) /* ignore black */ + if ( hsv0.h < 0 ) { /* ignore black */ continue; + } hsv0.h = h; hsv0.s *= s; hsv0.v *= v; @@ -1131,28 +1187,26 @@ EXPORT BOOL_T ReadSegs( void ) char *cp, *cpp; BOOL_T rc=TRUE; trkSeg_p s; - trkEndPt_p e; long rgb; int i; DIST_T elev0, elev1; BOOL_T hasElev; BOOL_T isPolyV1, isPolyV2; BOOL_T improvedEnds; - FLOAT_T ignoreFloat; char type; char * plain_text; - long option, option2; + long option; BOOL_T subsegs = FALSE; descriptionOff = zero; tempSpecial[0] = '\0'; tempCustom[0] = '\0'; DYNARR_RESET( trkSeg_t, tempSegs_da ); - DYNARR_RESET( trkEndPt_t, tempEndPts_da ); + TempEndPtsReset(); pathCnt = 0; AppendPath(0); // End of all paths while ( rc && ((cp = GetNextLine()) != NULL) ) { - while (isspace(*cp)) cp++; + while (isspace(*cp)) { cp++; } hasElev = FALSE; improvedEnds = FALSE; if ( IsEND( END_SEGS ) ) { @@ -1169,15 +1223,17 @@ EXPORT BOOL_T ReadSegs( void ) if ( *cp == '\0' || *cp == '\n' || *cp == '#' ) { continue; } - if (subsegs) continue; + if (subsegs) { continue; } type = *cp++; improvedEnds = isPolyV2 = hasElev = isPolyV1 = FALSE; if ( isdigit( *cp ) ) { long iVersion = strtol( cp, &cp, 10 ); - if ( iVersion >= 3 ) + if ( iVersion >= 3 ) { hasElev = isPolyV1 = TRUE; - if ( iVersion >= 4 ) + } + if ( iVersion >= 4 ) { improvedEnds = isPolyV2 = TRUE; + } if ( iVersion > 4 ) { InputError( "Invalid segment version number, maximum is %d", TRUE, 4 ); break; @@ -1190,7 +1246,7 @@ EXPORT BOOL_T ReadSegs( void ) s = &tempSegs(tempSegs_da.cnt-1); s->type = type; if ( !GetArgs( cp, hasElev?"lwpfpf":"lwpYpY", - &rgb, &s->width, &s->u.l.pos[0], &elev0, &s->u.l.pos[1], &elev1 ) ) { + &rgb, &s->lineWidth, &s->u.l.pos[0], &elev0, &s->u.l.pos[1], &elev1 ) ) { rc = FALSE; break; } @@ -1203,14 +1259,16 @@ EXPORT BOOL_T ReadSegs( void ) s = &tempSegs(tempSegs_da.cnt-1); s->type = type; if ( !GetArgs( cp, hasElev?"lwpfpfl":"lwpYpYZ", - &rgb, &s->width, &s->u.l.pos[0], &elev0, &s->u.l.pos[1], &elev1, &option ) ) { + &rgb, &s->lineWidth, &s->u.l.pos[0], &elev0, &s->u.l.pos[1], &elev1, + &option ) ) { rc = FALSE; break; } - if ( type == SEG_DIMLIN ) + if ( type == SEG_DIMLIN ) { s->u.l.option = option; - else + } else { s->u.l.option = BenchInputOption(option); + } s->color = wDrawFindColor( rgb ); break; case SEG_CRVLIN: @@ -1218,11 +1276,11 @@ EXPORT BOOL_T ReadSegs( void ) s = &tempSegs(tempSegs_da.cnt-1); s->type = SEG_CRVLIN; if ( !GetArgs( cp, hasElev?"lwfpfff":"lwfpYff", - &rgb, &s->width, - &s->u.c.radius, - &s->u.c.center, - &elev0, - &s->u.c.a0, &s->u.c.a1 ) ) { + &rgb, &s->lineWidth, + &s->u.c.radius, + &s->u.c.center, + &elev0, + &s->u.c.a0, &s->u.c.a1 ) ) { rc = FALSE; break; } @@ -1232,13 +1290,11 @@ EXPORT BOOL_T ReadSegs( void ) DYNARR_APPEND( trkSeg_t, tempSegs_da, 10 ); s = &tempSegs(tempSegs_da.cnt-1); s->type = SEG_STRTRK; - s->bezSegs.max = 0; - s->bezSegs.cnt = 0; - s->bezSegs.ptr = NULL; + DYNARR_INIT( trkSeg_t, s->bezSegs ); if ( !GetArgs( cp, hasElev?"lwpfpf":"lwpYpY", - &rgb, &s->width, - &s->u.l.pos[0], &elev0, - &s->u.l.pos[1], &elev1 ) ) { + &rgb, &s->lineWidth, + &s->u.l.pos[0], &elev0, + &s->u.l.pos[1], &elev1 ) ) { rc = FALSE; break; } @@ -1248,15 +1304,13 @@ EXPORT BOOL_T ReadSegs( void ) DYNARR_APPEND( trkSeg_t, tempSegs_da, 10 ); s = &tempSegs(tempSegs_da.cnt-1); s->type = SEG_CRVTRK; - s->bezSegs.max = 0; - s->bezSegs.cnt = 0; - s->bezSegs.ptr = NULL; + DYNARR_INIT( trkSeg_t, s->bezSegs ); if ( !GetArgs( cp, hasElev?"lwfpfff":"lwfpYff", - &rgb, &s->width, - &s->u.c.radius, - &s->u.c.center, - &elev0, - &s->u.c.a0, &s->u.c.a1 ) ) { + &rgb, &s->lineWidth, + &s->u.c.radius, + &s->u.c.center, + &elev0, + &s->u.c.a0, &s->u.c.a1 ) ) { rc = FALSE; break; } @@ -1267,15 +1321,15 @@ EXPORT BOOL_T ReadSegs( void ) s = &tempSegs(tempSegs_da.cnt-1); s->type = SEG_JNTTRK; if ( !GetArgs( cp, hasElev?"lwpffffffl":"lwpYfffffl", - &rgb, &s->width, - &s->u.j.pos, - &elev0, - &s->u.j.angle, - &s->u.j.l0, - &s->u.j.l1, - &s->u.j.R, - &s->u.j.L, - &option ) ) { + &rgb, &s->lineWidth, + &s->u.j.pos, + &elev0, + &s->u.j.angle, + &s->u.j.l0, + &s->u.j.l1, + &s->u.j.R, + &s->u.j.L, + &option ) ) { rc = FALSE; break; } @@ -1284,51 +1338,47 @@ EXPORT BOOL_T ReadSegs( void ) s->u.j.Scurve = ( option&4 )!=0; s->color = wDrawFindColor( rgb ); break; - case SEG_BEZTRK: - DYNARR_APPEND( trkSeg_t, tempSegs_da, 10); - s = &tempSegs(tempSegs_da.cnt-1); - s->type=SEG_BEZTRK; - s->bezSegs.max=0; - s->bezSegs.ptr= NULL; - s->bezSegs.cnt=0; - if ( !GetArgs( cp, "lwpppp", - &rgb, &s->width, - &s->u.b.pos[0], - &s->u.b.pos[1], - &s->u.b.pos[2], - &s->u.b.pos[3])) { - rc = FALSE; - break; - } - s->color = wDrawFindColor( rgb ); - break; - case SEG_BEZLIN: - DYNARR_APPEND( trkSeg_t, tempSegs_da, 10); - s = &tempSegs(tempSegs_da.cnt-1); - s->type=SEG_BEZLIN; - s->bezSegs.max=0; - s->bezSegs.ptr= NULL; - s->bezSegs.cnt=0; - if ( !GetArgs( cp, "lwpppp", - &rgb, &s->width, - &s->u.b.pos[0], - &s->u.b.pos[1], - &s->u.b.pos[2], - &s->u.b.pos[3])) { - rc = FALSE; - break; - } - s->color = wDrawFindColor( rgb ); - break; + case SEG_BEZTRK: + DYNARR_APPEND( trkSeg_t, tempSegs_da, 10); + s = &tempSegs(tempSegs_da.cnt-1); + s->type=SEG_BEZTRK; + DYNARR_INIT( trkSet_t, s->bezSegs ); + if ( !GetArgs( cp, "lwpppp", + &rgb, &s->lineWidth, + &s->u.b.pos[0], + &s->u.b.pos[1], + &s->u.b.pos[2], + &s->u.b.pos[3])) { + rc = FALSE; + break; + } + s->color = wDrawFindColor( rgb ); + break; + case SEG_BEZLIN: + DYNARR_APPEND( trkSeg_t, tempSegs_da, 10); + s = &tempSegs(tempSegs_da.cnt-1); + s->type=SEG_BEZLIN; + DYNARR_INIT( trkSet_t, s->bezSegs ); + if ( !GetArgs( cp, "lwpppp", + &rgb, &s->lineWidth, + &s->u.b.pos[0], + &s->u.b.pos[1], + &s->u.b.pos[2], + &s->u.b.pos[3])) { + rc = FALSE; + break; + } + s->color = wDrawFindColor( rgb ); + break; case SEG_FILCRCL: DYNARR_APPEND( trkSeg_t, tempSegs_da, 10 ); s = &tempSegs(tempSegs_da.cnt-1); s->type = SEG_FILCRCL; if ( !GetArgs( cp, hasElev?"lwfpf":"lwfpY", - &rgb, &s->width, - &s->u.c.radius, - &s->u.c.center, - &elev0 ) ) { + &rgb, &s->lineWidth, + &s->u.c.radius, + &s->u.c.center, + &elev0 ) ) { rc = FALSE; /*??*/break; } @@ -1343,15 +1393,14 @@ EXPORT BOOL_T ReadSegs( void ) s->type = type; s->u.p.polyType = FREEFORM; if ( !GetArgs( cp, - isPolyV2?"lwdd":"lwdX", - &rgb, - &s->width, - &s->u.p.cnt, - &s->u.p.polyType) ) { + isPolyV2?"lwdd":"lwdX", + &rgb, + &s->lineWidth, + &s->u.p.cnt, + &s->u.p.polyType) ) { rc = FALSE; /*??*/break; } - if (s->type == SEG_FILPOLY) s->u.p.polyType = FREEFORM; //Ensure closed if filled s->color = wDrawFindColor( rgb ); s->u.p.pts = (pts_t*)MyMalloc( s->u.p.cnt * sizeof (pts_t) ); for ( i=0; i<s->u.p.cnt; i++ ) { @@ -1359,10 +1408,10 @@ EXPORT BOOL_T ReadSegs( void ) if (cp == NULL || !GetArgs( cp, // TODO: does elev belong here instead of the seg header? - isPolyV2?"pdY":isPolyV1?"pXf":"pXY", - &s->u.p.pts[i].pt, - &s->u.p.pts[i].pt_type, - &elev0 )) { + isPolyV2?"pdY":isPolyV1?"pXf":"pXY", + &s->u.p.pts[i].pt, + &s->u.p.pts[i].pt_type, + &elev0 )) { rc = FALSE; } } @@ -1374,7 +1423,8 @@ EXPORT BOOL_T ReadSegs( void ) s = &tempSegs(tempSegs_da.cnt-1); s->type = type; s->u.t.fontP = NULL; - if ( !GetArgs( cp, "lpfdfq", &rgb, &s->u.t.pos, &s->u.t.angle, &s->u.t.boxed, &s->u.t.fontSize, &plain_text ) ) { + if ( !GetArgs( cp, "lpfdfq", &rgb, &s->u.t.pos, &s->u.t.angle, &s->u.t.boxed, + &s->u.t.fontSize, &plain_text ) ) { rc = FALSE; /*??*/break; } @@ -1383,79 +1433,19 @@ EXPORT BOOL_T ReadSegs( void ) break; case SEG_UNCEP: case SEG_CONEP: - DYNARR_APPEND( trkEndPt_t, tempEndPts_da, 10 ); - e = &tempEndPts(tempEndPts_da.cnt-1); - if (type == SEG_CONEP) { - if ( !GetArgs( cp, "dc", &e->index, &cp ) ) { - rc = FALSE; - /*??*/break; - } - } else { - e->index = -1; - } - if ( !GetArgs( cp, "pfc", - &e->pos, &e->angle, &cp) ) { - rc = FALSE; - /*??*/break; - } - e->elev.option = 0; - e->elev.u.height = 0.0; - e->elev.doff = zero; - e->option = 0; - if (improvedEnds) { //E4 and T4 - if (!GetArgs( cp, "lpc", &option, &e->elev.doff, &cp )) { - rc = FALSE; - /*??*/break; - } - switch (option&ELEV_MASK) { - case ELEV_STATION: - GetArgs( cp, "qc", &e->elev.u.name, &cp); - break; - default: - GetArgs( cp, "fc", &e->elev.u.height, &cp); //First height - } - DIST_T height2; - if (!GetArgs( cp, "flLlc", &height2, &option2, &e->elev.option, &e->option, &cp ) ) { - rc = FALSE; - break; - } - if (option2) e->elev.option |= ELEV_VISIBLE; - GetArgs(cp, "fc", &ignoreFloat, &cp); - break; - } - if ( cp != NULL ) { - if (paramVersion < 7) { - GetArgs( cp, "dfp", &e->elev.option, &e->elev.u.height, &e->elev.doff, &cp ); - /*??*/break; - } - GetArgs( cp, "lpc", &option, &e->elev.doff, &cp ); - e->option = option >> 8; - e->elev.option = (int)(option&0xFF); - if ( (e->elev.option&ELEV_MASK) != ELEV_NONE ) { - switch (e->elev.option&ELEV_MASK) { - case ELEV_DEF: - GetArgs( cp, "fc", &e->elev.u.height, &cp ); - break; - case ELEV_STATION: - GetArgs( cp, "qc", &e->elev.u.name, &cp ); - /*??*/break; - default: - ; - } - } - } + rc = GetEndPtArg( cp, type, improvedEnds ); break; case SEG_PATH: - while (isspace(*cp)) cp++; - if (*cp == '\"') cp++; + while (isspace(*cp)) { cp++; } + if (*cp == '\"') { cp++; } pathCnt--; // Overwrite previous terminator - while ( *cp != '\"') AppendPath((signed char)*cp++); // Name of path + while ( *cp != '\"') { AppendPath((signed char)*cp++); } // Name of path AppendPath(0); // End of name cp++; while (1) { i = (int)strtol(cp, &cpp, 10); if (cp == cpp) - /*??*/break; + /*??*/{ break; } cp = cpp; AppendPath( (signed char)i ); // Segment # of path component } @@ -1491,130 +1481,152 @@ EXPORT BOOL_T ReadSegs( void ) } EXPORT BOOL_T WriteSegs( - FILE * f, - wIndex_t segCnt, - trkSeg_p segs ) + FILE * f, + wIndex_t segCnt, + trkSeg_p segs ) { - return WriteSegsEnd(f,segCnt,segs,TRUE); + return WriteSegsEnd(f,segCnt,segs,TRUE); } EXPORT BOOL_T WriteSegsEnd( - FILE * f, - wIndex_t segCnt, - trkSeg_p segs, BOOL_T writeEnd) + FILE * f, + wIndex_t segCnt, + trkSeg_p segs, BOOL_T writeEnd) { int i, j; BOOL_T rc = TRUE; long option; char * escaped_text; + char* trackText; +#ifdef UTFCONVERT + char* out = NULL; +#endif for ( i=0; i<segCnt; i++ ) { switch ( segs[i].type ) { case SEG_STRTRK: rc &= fprintf( f, "\t%c %ld %0.6f %0.6f %0.6f %0.6f %0.6f\n", - segs[i].type, wDrawGetRGB(segs[i].color), segs[i].width, - segs[i].u.l.pos[0].x, segs[i].u.l.pos[0].y, - segs[i].u.l.pos[1].x, segs[i].u.l.pos[1].y ) > 0; + segs[i].type, wDrawGetRGB(segs[i].color), segs[i].lineWidth, + segs[i].u.l.pos[0].x, segs[i].u.l.pos[0].y, + segs[i].u.l.pos[1].x, segs[i].u.l.pos[1].y ) > 0; break; case SEG_STRLIN: case SEG_TBLEDGE: rc &= fprintf( f, "\t%c3 %ld %0.6f %0.6f %0.6f 0 %0.6f %0.6f 0\n", - segs[i].type, wDrawGetRGB(segs[i].color), segs[i].width, - segs[i].u.l.pos[0].x, segs[i].u.l.pos[0].y, - segs[i].u.l.pos[1].x, segs[i].u.l.pos[1].y ) > 0; + segs[i].type, wDrawGetRGB(segs[i].color), segs[i].lineWidth, + segs[i].u.l.pos[0].x, segs[i].u.l.pos[0].y, + segs[i].u.l.pos[1].x, segs[i].u.l.pos[1].y ) > 0; break; case SEG_DIMLIN: rc &= fprintf( f, "\t%c3 %ld %0.6f %0.6f %0.6f 0 %0.6f %0.6f 0 %ld\n", - segs[i].type, wDrawGetRGB(segs[i].color), segs[i].width, - segs[i].u.l.pos[0].x, segs[i].u.l.pos[0].y, - segs[i].u.l.pos[1].x, segs[i].u.l.pos[1].y, - segs[i].u.l.option ) > 0; + segs[i].type, wDrawGetRGB(segs[i].color), segs[i].lineWidth, + segs[i].u.l.pos[0].x, segs[i].u.l.pos[0].y, + segs[i].u.l.pos[1].x, segs[i].u.l.pos[1].y, + segs[i].u.l.option ) > 0; break; case SEG_BENCH: rc &= fprintf( f, "\t%c3 %ld %0.6f %0.6f %0.6f 0 %0.6f %0.6f 0 %ld\n", - segs[i].type, wDrawGetRGB(segs[i].color), segs[i].width, - segs[i].u.l.pos[0].x, segs[i].u.l.pos[0].y, - segs[i].u.l.pos[1].x, segs[i].u.l.pos[1].y, - BenchOutputOption(segs[i].u.l.option) ) > 0; + segs[i].type, wDrawGetRGB(segs[i].color), segs[i].lineWidth, + segs[i].u.l.pos[0].x, segs[i].u.l.pos[0].y, + segs[i].u.l.pos[1].x, segs[i].u.l.pos[1].y, + BenchOutputOption(segs[i].u.l.option) ) > 0; break; case SEG_CRVTRK: rc &= fprintf( f, "\t%c %ld %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f\n", - segs[i].type, wDrawGetRGB(segs[i].color), segs[i].width, - segs[i].u.c.radius, - segs[i].u.c.center.x, segs[i].u.c.center.y, - segs[i].u.c.a0, segs[i].u.c.a1 ) > 0; + segs[i].type, wDrawGetRGB(segs[i].color), segs[i].lineWidth, + segs[i].u.c.radius, + segs[i].u.c.center.x, segs[i].u.c.center.y, + segs[i].u.c.a0, segs[i].u.c.a1 ) > 0; break; case SEG_JNTTRK: - option = (segs[i].u.j.negate?1:0) + (segs[i].u.j.flip?2:0) + (segs[i].u.j.Scurve?4:0); - rc &= fprintf( f, "\t%c %ld %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %ld\n", - segs[i].type, wDrawGetRGB(segs[i].color), segs[i].width, - segs[i].u.j.pos.x, segs[i].u.j.pos.y, - segs[i].u.j.angle, - segs[i].u.j.l0, - segs[i].u.j.l1, - segs[i].u.j.R, - segs[i].u.j.L, - option )>0; - break; - case SEG_BEZTRK: - case SEG_BEZLIN: - rc &= fprintf( f, "\t%c3 %ld %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f\n", - segs[i].type, wDrawGetRGB(segs[i].color), - segs[i].width, - segs[i].u.l.pos[0].x, segs[i].u.l.pos[0].y, - segs[i].u.l.pos[1].x, segs[i].u.l.pos[1].y, - segs[i].u.l.pos[2].x, segs[i].u.l.pos[2].y, - segs[i].u.l.pos[3].x, segs[i].u.l.pos[3].y ) > 0; - rc &= fprintf(f,"\tSUBSEGS\n"); - rc &= WriteSegsEnd(f,segs[i].bezSegs.cnt,segs[i].bezSegs.ptr,FALSE); - rc &= fprintf(f,"\tSUBSEND\n"); - break; + option = (segs[i].u.j.negate?1:0) + (segs[i].u.j.flip?2:0) + + (segs[i].u.j.Scurve?4:0); + rc &= fprintf( f, + "\t%c %ld %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %ld\n", + segs[i].type, wDrawGetRGB(segs[i].color), segs[i].lineWidth, + segs[i].u.j.pos.x, segs[i].u.j.pos.y, + segs[i].u.j.angle, + segs[i].u.j.l0, + segs[i].u.j.l1, + segs[i].u.j.R, + segs[i].u.j.L, + option )>0; + break; + case SEG_BEZTRK: + case SEG_BEZLIN: + rc &= fprintf( f, + "\t%c3 %ld %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f\n", + segs[i].type, wDrawGetRGB(segs[i].color), + segs[i].lineWidth, + segs[i].u.l.pos[0].x, segs[i].u.l.pos[0].y, + segs[i].u.l.pos[1].x, segs[i].u.l.pos[1].y, + segs[i].u.l.pos[2].x, segs[i].u.l.pos[2].y, + segs[i].u.l.pos[3].x, segs[i].u.l.pos[3].y ) > 0; + rc &= fprintf(f,"\tSUBSEGS\n"); + rc &= WriteSegsEnd(f,segs[i].bezSegs.cnt, + &DYNARR_N(trkSeg_t,segs[i].bezSegs,0), FALSE); + rc &= fprintf(f,"\tSUBSEND\n"); + break; case SEG_CRVLIN: rc &= fprintf( f, "\t%c3 %ld %0.6f %0.6f %0.6f %0.6f 0 %0.6f %0.6f\n", - segs[i].type, wDrawGetRGB(segs[i].color), segs[i].width, - segs[i].u.c.radius, - segs[i].u.c.center.x, segs[i].u.c.center.y, - segs[i].u.c.a0, segs[i].u.c.a1 ) > 0; + segs[i].type, wDrawGetRGB(segs[i].color), segs[i].lineWidth, + segs[i].u.c.radius, + segs[i].u.c.center.x, segs[i].u.c.center.y, + segs[i].u.c.a0, segs[i].u.c.a1 ) > 0; break; case SEG_FILCRCL: rc &= fprintf( f, "\t%c3 %ld %0.6f %0.6f %0.6f %0.6f 0\n", - segs[i].type, wDrawGetRGB(segs[i].color), segs[i].width, - segs[i].u.c.radius, - segs[i].u.c.center.x, segs[i].u.c.center.y ) > 0; + segs[i].type, wDrawGetRGB(segs[i].color), segs[i].lineWidth, + segs[i].u.c.radius, + segs[i].u.c.center.x, segs[i].u.c.center.y ) > 0; break; case SEG_POLY: case SEG_FILPOLY: // TODO: to be consistent, we should add a dummy 0 for elev. See ReadSegs/SEG_POLY rc &= fprintf( f, "\t%c4 %ld %0.6f %d %d \n", - segs[i].type, wDrawGetRGB(segs[i].color), segs[i].width, - segs[i].u.p.cnt, segs[i].u.p.polyType ) > 0; + segs[i].type, wDrawGetRGB(segs[i].color), segs[i].lineWidth, + segs[i].u.p.cnt, segs[i].u.p.polyType ) > 0; for ( j=0; j<segs[i].u.p.cnt; j++ ) rc &= fprintf( f, "\t\t%0.6f %0.6f %d\n", - segs[i].u.p.pts[j].pt.x, segs[i].u.p.pts[j].pt.y, segs[i].u.p.pts[j].pt_type ) > 0; + segs[i].u.p.pts[j].pt.x, segs[i].u.p.pts[j].pt.y, + segs[i].u.p.pts[j].pt_type ) > 0; break; case SEG_TEXT: /* 0pf0fq */ - escaped_text = ConvertToEscapedText(segs[i].u.t.string); +#ifdef UTFCONVERT + if (RequiresConvToUTF8(segs[i].u.t.string)) { + size_t cnt = strlen(segs[i].u.t.string) * 2 + 1; + out = MyMalloc(cnt); + wSystemToUTF8(segs[i].u.t.string, out, (unsigned int)cnt); + trackText = out; + } +#else + trackText = segs[i].u.t.string; +#endif // UTFCONVERT + escaped_text = ConvertToEscapedText(trackText); rc &= fprintf( f, "\t%c %ld %0.6f %0.6f %0.6f %d %0.6f \"%s\"\n", - segs[i].type, wDrawGetRGB(segs[i].color), - segs[i].u.t.pos.x, segs[i].u.t.pos.y, segs[i].u.t.angle, - segs[i].u.t.boxed, - segs[i].u.t.fontSize, escaped_text ) > 0; + segs[i].type, wDrawGetRGB(segs[i].color), + segs[i].u.t.pos.x, segs[i].u.t.pos.y, segs[i].u.t.angle, + segs[i].u.t.boxed, + segs[i].u.t.fontSize, escaped_text ) > 0; MyFree(escaped_text); +#ifdef UTFCONVERT + MyFree(out); +#endif break; } } - if (writeEnd) rc &= fprintf( f, "\t%s\n", END_SEGS )>0; + if (writeEnd) { rc &= fprintf( f, "\t%s\n", END_SEGS )>0; } return rc; } EXPORT void SegProc( - segProc_e cmd, - trkSeg_p segPtr, - segProcData_p data ) + segProc_e cmd, + trkSeg_p segPtr, + segProcData_p data ) { switch (segPtr->type) { case SEG_STRTRK: @@ -1628,12 +1640,12 @@ EXPORT void SegProc( case SEG_JNTTRK: JointSegProc( cmd, segPtr, data ); break; - case SEG_BEZTRK: - case SEG_BEZLIN: - BezierSegProc( cmd, segPtr, data); - break; - default: - AbortProg( "SegProg( %d )", segPtr->type ); + case SEG_BEZTRK: + case SEG_BEZLIN: + BezierSegProc( cmd, segPtr, data); + break; + default: + CHECKMSG( FALSE, ( "SegProg( %d )", segPtr->type ) ); break; } } @@ -1645,15 +1657,15 @@ EXPORT void SegProc( */ EXPORT void DrawDimLine( - drawCmd_p d, - coOrd p0, - coOrd p1, - char * dimP, - wFontSize_t fs, - FLOAT_T middle, - wDrawWidth width, - wDrawColor color, - long option ) + drawCmd_p d, + coOrd p0, + coOrd p1, + char * dimP, + wFontSize_t fs, + FLOAT_T middle, + wDrawWidth width, + wDrawColor color, + long option ) { ANGLE_T a0, a1; wFont_p fp; @@ -1662,8 +1674,8 @@ EXPORT void DrawDimLine( POS_T x, y; coOrd textsize; - if ( middle < 0.0 ) middle = 0.0; - if ( middle > 1.0 ) middle = 1.0; + if ( middle < 0.0 ) { middle = 0.0; } + if ( middle > 1.0 ) { middle = 1.0; } a0 = FindAngle( p0, p1 ); dist = fs/144.0; @@ -1700,37 +1712,37 @@ EXPORT void DrawDimLine( DrawString( d, s_pos, 0.0, dimP, fp, fs, color ); return; } - a1 = FindAngle( zero, size ); - p.x = p0.x+(p1.x-p0.x)*middle; - p.y = p0.y+(p1.y-p0.y)*middle; - pc = p; - p.x -= size.x; - p.y -= size.y; - fx = fy = 1; - if (a0>180) { - a0 = a0-180; - fx = fy = -1; - } - if (a0>90) { - a0 = 180-a0; - fy *= -1; - } - if (a0>a1) { - x = size.x; - y = x * tan(D2R(90-a0)); - } else { - y = size.y; - x = y * tan(D2R(a0)); - } - DrawString( d, p, 0.0, dimP, fp, fs, color ); - p = pc; - p.x -= fx*x; - p.y -= fy*y; - DrawLine( d, p0, p, width, color ); - p = pc; - p.x += fx*x; - p.y += fy*y; - DrawLine( d, p, p1, width, color ); + a1 = FindAngle( zero, size ); + p.x = p0.x+(p1.x-p0.x)*middle; + p.y = p0.y+(p1.y-p0.y)*middle; + pc = p; + p.x -= size.x; + p.y -= size.y; + fx = fy = 1; + if (a0>180) { + a0 = a0-180; + fx = fy = -1; + } + if (a0>90) { + a0 = 180-a0; + fy *= -1; + } + if (a0>a1) { + x = size.x; + y = x * tan(D2R(90-a0)); + } else { + y = size.y; + x = y * tan(D2R(a0)); + } + DrawString( d, p, 0.0, dimP, fp, fs, color ); + p = pc; + p.x -= fx*x; + p.y -= fy*y; + DrawLine( d, p0, p, width, color ); + p = pc; + p.x += fx*x; + p.y += fy*y; + DrawLine( d, p, p1, width, color ); } /* @@ -1738,15 +1750,15 @@ EXPORT void DrawDimLine( * Note that Bezier segments in particular contain sub-arrays of Curve and Straight segments. */ EXPORT void DrawSegsO( - drawCmd_p d, - track_p trk, - coOrd orig, - ANGLE_T angle, - trkSeg_p segPtr, - wIndex_t segCnt, - DIST_T trackGauge, - wDrawColor color, - long options ) + drawCmd_p d, + track_p trk, + coOrd orig, + ANGLE_T angle, + trkSeg_p segPtr, + wIndex_t segCnt, + DIST_T trackGauge, + wDrawColor color, + long options ) { wIndex_t i, j; coOrd p0, p1, p2, p3, c; @@ -1755,7 +1767,7 @@ EXPORT void DrawSegsO( DIST_T factor = d->dpi/d->scale; trkSeg_p tempPtr; - long option; + long option; wFontSize_t fs; wBool_t bFill,bThick; @@ -1768,9 +1780,9 @@ EXPORT void DrawSegsO( color1 = color2 = color; } wDrawWidth thick = 3; -#ifdef WINDOWS - thick *= (wDrawWidth)(d->dpi/75.0); -#endif +//#ifdef WINDOWS +// thick *= (LWIDTH_T)(d->dpi/BASE_DPI); +//#endif switch (segPtr->type) { case SEG_STRLIN: case SEG_DIMLIN: @@ -1781,25 +1793,26 @@ EXPORT void DrawSegsO( REORIGIN( p1, segPtr->u.l.pos[1], angle, orig ) switch (segPtr->type) { case SEG_STRTRK: - if (color1 == wDrawColorBlack) + if (color1 == wDrawColorBlack) { color1 = normalColor; - if ( segPtr->color == wDrawColorWhite ) - break; + } if (options&DTS_CENTERONLY) { DrawLine( d, p0, p1, thick, color1 ); break; } + if ( segPtr->color == wDrawColorWhite ) { break; } DrawStraightTrack( d, - p0, p1, - FindAngle(p1, p0 ), - trk, color1, options ); + p0, p1, + FindAngle(p1, p0 ), + trk, color1, options ); break; case SEG_STRLIN:; wDrawWidth w; - if (segPtr->width <0) - w = (int)floor(fabs(segPtr->width)+0.5); - else - w = (int)floor(fabs(segPtr->width*factor)+0.5); + if (segPtr->lineWidth < 0) { + w = (int)floor(-segPtr->lineWidth + 0.5); + } else { + w = (int)floor(segPtr->lineWidth * factor + 0.5); + } DrawLine( d, p0, p1, (d->options&DC_THICK)?thick:w, color1 ); break; case SEG_DIMLIN: @@ -1817,15 +1830,18 @@ EXPORT void DrawSegsO( fs = descriptionFontSize*4; option = segPtr->u.l.option; fs /= (option==0?8:option==1?4:option==2?2:1); - if ( fs < 2 ) + if ( fs < 2 ) { fs = 2; - DrawDimLine( d, p0, p1, FormatDistance(FindDistance(p0,p1)), fs, 0.5, (d->options&DC_THICK)?thick:0, color, option & 0x00 ); + } + DrawDimLine( d, p0, p1, FormatDistance(FindDistance(p0,p1)), fs, 0.5, + (d->options&DC_THICK)?thick:0, color, option & 0x00 ); break; case SEG_BENCH: DrawBench( d, p0, p1, color1, color2, options, segPtr->u.l.option ); break; case SEG_TBLEDGE: - DrawLine( d, p0, p1, (wDrawWidth)floor(3.0/BASE_DPI*d->dpi+0.5) , color ); + // DrawLine( d, p0, p1, (wDrawWidth)floor(3.0/BASE_DPI*d->dpi+0.5), color ); + DrawLine(d, p0, p1, 3, color); break; } } @@ -1837,110 +1853,120 @@ EXPORT void DrawSegsO( a0 = NormalizeAngle(segPtr->u.c.a0 + angle); REORIGIN( c, segPtr->u.c.center, angle, orig ); if (segPtr->type == SEG_CRVTRK) { - if (color1 == wDrawColorBlack) + if (color1 == wDrawColorBlack) { color1 = normalColor; - if ( segPtr->color == wDrawColorWhite ) - break; + } p0.x = p0.y = p1.x = p1.y = 0; if (options&DTS_CENTERONLY) { DrawArc( d, c, fabs(segPtr->u.c.radius), a0, segPtr->u.c.a1, - FALSE, thick, color1 ); + FALSE, thick, color1 ); break; } + if ( segPtr->color == wDrawColorWhite ) { break; } DrawCurvedTrack( d, - c, - fabs(segPtr->u.c.radius), - a0, segPtr->u.c.a1, - trk, color1, options ); + c, + fabs(segPtr->u.c.radius), + a0, segPtr->u.c.a1, + trk, color1, options ); } else { wDrawWidth w; - if (segPtr->width <0) - w = (int)floor(fabs(segPtr->width)+0.5); - else - w = (int)floor(segPtr->width*factor+0.5); + if (segPtr->lineWidth < 0) { + w = (int)floor(-segPtr->lineWidth + 0.5); + } else { + w = (int)floor(segPtr->lineWidth * factor + 0.5); + } DrawArc( d, c, fabs(segPtr->u.c.radius), a0, segPtr->u.c.a1, - FALSE, (d->options&DC_THICK)?thick:w, color1 ); + FALSE, (d->options&DC_THICK)?thick:w, color1 ); } break; - case SEG_BEZTRK: - case SEG_BEZLIN: - if (segPtr->type == SEG_BEZTRK) { - if (color1 == wDrawColorBlack) - color1 = normalColor; - if ( segPtr->color == wDrawColorWhite ) - break; - } + case SEG_BEZTRK: + case SEG_BEZLIN: + if (segPtr->type == SEG_BEZTRK) { + if (color1 == wDrawColorBlack) { + color1 = normalColor; + } + if ( segPtr->color == wDrawColorWhite ) { + break; + } + } //else { - REORIGIN(p0,segPtr->u.b.pos[0],angle,orig); - REORIGIN(p1,segPtr->u.b.pos[1],angle,orig); - REORIGIN(p2,segPtr->u.b.pos[2],angle,orig); - REORIGIN(p3,segPtr->u.b.pos[3],angle,orig); + REORIGIN(p0,segPtr->u.b.pos[0],angle,orig); + REORIGIN(p1,segPtr->u.b.pos[1],angle,orig); + REORIGIN(p2,segPtr->u.b.pos[2],angle,orig); + REORIGIN(p3,segPtr->u.b.pos[3],angle,orig); //} - for(int j=0;j<segPtr->bezSegs.cnt;j++) { //Loop through sub Segs - tempPtr = &DYNARR_N(trkSeg_t,segPtr->bezSegs,j); - switch (tempPtr->type) { - case SEG_CRVTRK: - case SEG_CRVLIN: - a0 = NormalizeAngle(tempPtr->u.c.a0 + angle); - REORIGIN( c, tempPtr->u.c.center, angle, orig ); - if (tempPtr->type == SEG_CRVTRK) { - if (color1 == wDrawColorBlack) color1 = normalColor; - if ( tempPtr->color == wDrawColorWhite ) break; - p0.x = p0.y = p1.x = p1.y = 0; - if (options&DTS_CENTERONLY) { - DrawArc( d, c, fabs(segPtr->u.c.radius), a0, segPtr->u.c.a1, - FALSE, thick, color1 ); - break; - } - DrawCurvedTrack( d, - c, - fabs(tempPtr->u.c.radius), - a0, tempPtr->u.c.a1, - trk, color1, options ); - } else if (tempPtr->type == SEG_CRVLIN) { - wDrawWidth w; - if (tempPtr->width <0) - w = (int)floor(fabs(tempPtr->width)+0.5); - else - w = (int)floor(tempPtr->width*factor+0.5); - DrawArc( d, c, fabs(tempPtr->u.c.radius), a0, tempPtr->u.c.a1, - FALSE, (d->options&DC_THICK)?thick:w, color1 ); - } - break; - case SEG_STRTRK: - if (color1 == wDrawColorBlack) color1 = normalColor; - if ( tempPtr->color == wDrawColorWhite ) break; - REORIGIN(p0,tempPtr->u.l.pos[0], angle, orig); - REORIGIN(p1,tempPtr->u.l.pos[1], angle, orig); - if (options&DTS_CENTERONLY) { - DrawLine( d, p0, p1, thick, color1 ); + for(int j=0; j<segPtr->bezSegs.cnt; j++) { //Loop through sub Segs + tempPtr = &DYNARR_N(trkSeg_t,segPtr->bezSegs,j); + switch (tempPtr->type) { + case SEG_CRVTRK: + case SEG_CRVLIN: + a0 = NormalizeAngle(tempPtr->u.c.a0 + angle); + REORIGIN( c, tempPtr->u.c.center, angle, orig ); + if (tempPtr->type == SEG_CRVTRK) { + if (color1 == wDrawColorBlack) { color1 = normalColor; } + p0.x = p0.y = p1.x = p1.y = 0; + if (options&DTS_CENTERONLY) { + DrawArc( d, c, fabs(segPtr->u.c.radius), a0, segPtr->u.c.a1, + FALSE, thick, color1 ); break; } - DrawStraightTrack( d, p0, p1, - FindAngle(p1,p0), - trk,color1,options); - break; - case SEG_STRLIN: - REORIGIN(p0,tempPtr->u.l.pos[0], angle, orig); - REORIGIN(p1,tempPtr->u.l.pos[1], angle, orig); - wDrawWidth w; - if (tempPtr->width <0) - w = (int)floor(fabs(tempPtr->width)+0.5); - else - w = (int)floor(tempPtr->width*factor+0.5); - DrawLine( d, p0, p1, (d->options&DC_THICK)?thick:w, color1 ); - break; - } - } - break; + if ( tempPtr->color == wDrawColorWhite ) { break; } + DrawCurvedTrack( d, + c, + fabs(tempPtr->u.c.radius), + a0, tempPtr->u.c.a1, + trk, color1, options ); + } else if (tempPtr->type == SEG_CRVLIN) { + wDrawWidth w; + if (tempPtr->lineWidth < 0) { + w = (int)floor(-tempPtr->lineWidth + 0.5); + } else { + w = (int)floor(tempPtr->lineWidth*factor+0.5); + } + DrawArc( d, c, fabs(tempPtr->u.c.radius), a0, tempPtr->u.c.a1, + FALSE, (d->options&DC_THICK)?thick:w, color1 ); + } + break; + case SEG_STRTRK: + if (color1 == wDrawColorBlack) { color1 = normalColor; } + REORIGIN(p0,tempPtr->u.l.pos[0], angle, orig); + REORIGIN(p1,tempPtr->u.l.pos[1], angle, orig); + if (options&DTS_CENTERONLY) { + DrawLine( d, p0, p1, thick, color1 ); + break; + } + if ( tempPtr->color == wDrawColorWhite ) { break; } + DrawStraightTrack( d, p0, p1, + FindAngle(p1,p0), + trk,color1,options); + break; + case SEG_STRLIN: + REORIGIN(p0,tempPtr->u.l.pos[0], angle, orig); + REORIGIN(p1,tempPtr->u.l.pos[1], angle, orig); + wDrawWidth w; + if (tempPtr->lineWidth < 0) { + w = (int)floor(-tempPtr->lineWidth+0.5); + } else { + w = (int)floor(tempPtr->lineWidth*factor+0.5); + } + DrawLine( d, p0, p1, (d->options&DC_THICK)?thick:w, color1 ); + break; + } + } + break; case SEG_JNTTRK: REORIGIN( p0, segPtr->u.j.pos, angle, orig ); - DrawJointTrack( d, p0, NormalizeAngle(segPtr->u.j.angle+angle), segPtr->u.j.l0, segPtr->u.j.l1, segPtr->u.j.R, segPtr->u.j.L, segPtr->u.j.negate, segPtr->u.j.flip, segPtr->u.j.Scurve, NULL, -1, -1, trackGauge, color1, options ); + DrawJointTrack( d, p0, NormalizeAngle(segPtr->u.j.angle+angle), segPtr->u.j.l0, + segPtr->u.j.l1, segPtr->u.j.R, segPtr->u.j.L, segPtr->u.j.negate, + segPtr->u.j.flip, segPtr->u.j.Scurve, NULL, -1, -1, trackGauge, color1, + options ); break; case SEG_TEXT: REORIGIN( p0, segPtr->u.t.pos, angle, orig ) - DrawMultiString( d, p0, segPtr->u.t.string, segPtr->u.t.fontP, segPtr->u.t.fontSize, color1, NormalizeAngle(angle + segPtr->u.t.angle), NULL, NULL, segPtr->u.t.boxed ); + DrawMultiString( d, p0, segPtr->u.t.string, segPtr->u.t.fontP, + segPtr->u.t.fontSize, color1, NormalizeAngle(angle + segPtr->u.t.angle), NULL, + NULL, segPtr->u.t.boxed ); break; case SEG_FILPOLY: case SEG_POLY: @@ -1950,34 +1976,39 @@ EXPORT void DrawSegsO( coOrd *tempPts = malloc(sizeof(coOrd)*segPtr->u.p.cnt); int *tempTypes = malloc(sizeof(int)*segPtr->u.p.cnt); // coOrd tempPts[segPtr->u.p.cnt]; - for (j=0;j<segPtr->u.p.cnt;j++) { + for (j=0; j<segPtr->u.p.cnt; j++) { REORIGIN( tempPts[j], segPtr->u.p.pts[j].pt, angle, orig ); tempTypes[j] = segPtr->u.p.pts[j].pt_type; } bFill = (segPtr->type == SEG_FILPOLY); - if ( (d->options&DC_SIMPLE) && programMode != MODE_TRAIN ) + if ( (d->options&DC_SIMPLE) && programMode != MODE_TRAIN ) { bFill = FALSE; + } // If we are drawing highlights for Select, don't fill just edges bThick = d->options&DC_THICK; - if (&tempD == d && ( color == wDrawColorPreviewSelected || color == wDrawColorPreviewUnselected || color == selectedColor)) { + if (&tempD == d && ( color == wDrawColorPreviewSelected + || color == wDrawColorPreviewUnselected || color == selectedColor)) { bFill = FALSE; bThick = TRUE; } wDrawWidth w; - if (segPtr->width <0) - w = (int)floor(fabs(segPtr->width)+0.5); - else - w = (int)floor(segPtr->width*factor+0.5); + if (segPtr->lineWidth < 0) { + w = (int)floor(-segPtr->lineWidth + 0.5); + } else { + w = (int)floor(segPtr->lineWidth * factor + 0.5); + } drawFill_e eOptFill; - if ( bFill ) + if ( bFill ) { eOptFill = DRAW_FILL; - else if ( segPtr->u.p.polyType == POLYLINE ) + } else if ( segPtr->u.p.polyType == POLYLINE ) { eOptFill = DRAW_OPEN; - else + } else { eOptFill = DRAW_CLOSED; - DrawPoly( d, segPtr->u.p.cnt, tempPts, tempTypes, color1, bThick?thick:w, eOptFill ); + } + DrawPoly( d, segPtr->u.p.cnt, tempPts, tempTypes, color1, bThick?thick:w, + eOptFill ); free(tempPts); free(tempTypes); @@ -1985,12 +2016,14 @@ EXPORT void DrawSegsO( case SEG_FILCRCL: REORIGIN( c, segPtr->u.c.center, angle, orig ) bFill = TRUE; - if ( (d->options&DC_SIMPLE) && programMode != MODE_TRAIN ) + if ( (d->options&DC_SIMPLE) && programMode != MODE_TRAIN ) { bFill = FALSE; + } // If we are drawing highlights for Select, don't fill just edges bThick = d->options&DC_THICK; - if (&tempD == d && (color == wDrawColorPreviewSelected || color == wDrawColorPreviewUnselected || color == selectedColor)) { + if (&tempD == d && (color == wDrawColorPreviewSelected + || color == wDrawColorPreviewUnselected || color == selectedColor)) { bFill = FALSE; bThick = TRUE; } @@ -1998,7 +2031,7 @@ EXPORT void DrawSegsO( DrawFillCircle( d, c, fabs(segPtr->u.c.radius), color1 ); } else { DrawArc( d, c, fabs(segPtr->u.c.radius), 0, 360, - FALSE, bThick?thick:(wDrawWidth)0, color1 ); + FALSE, bThick?thick:(wDrawWidth)0, color1 ); } break; } @@ -2011,96 +2044,70 @@ EXPORT void DrawSegsO( */ EXPORT void DrawSegs( - drawCmd_p d, - coOrd orig, - ANGLE_T angle, - trkSeg_p segPtr, - wIndex_t segCnt, - DIST_T trackGauge, - wDrawColor color ) + drawCmd_p d, + coOrd orig, + ANGLE_T angle, + trkSeg_p segPtr, + wIndex_t segCnt, + DIST_T trackGauge, + wDrawColor color ) +{ + + DrawSegsO( d, NULL, orig, angle, segPtr, segCnt, trackGauge, color, + DTS_LEFT|DTS_RIGHT ); +} + +/* + * Draw Segments from a DynArr + */ + +EXPORT void DrawSegsDA( + drawCmd_p d, + track_p trk, + coOrd orig, + ANGLE_T angle, + dynArr_t *da, + DIST_T trackGauge, + wDrawColor color, + long options ) { - DrawSegsO( d, NULL, orig, angle, segPtr, segCnt, trackGauge, color, DTS_LEFT|DTS_RIGHT ); + if ( da->cnt > 0 ) { + DrawSegsO( d, trk, orig, angle, &DYNARR_N(trkSeg_t,*da,0), da->cnt, + trackGauge, color, options ); + } } /* * Free dynamic storage added to each of an array of Track Segments. */ -EXPORT void CleanSegs(dynArr_t * seg_p) { - if (seg_p->cnt ==0) return; - for (int i=0;i<seg_p->cnt;i++) { +EXPORT void CleanSegs(dynArr_t * seg_p) +{ + if (seg_p->cnt ==0) { return; } + for (int i=0; i<seg_p->cnt; i++) { trkSeg_t t = DYNARR_N(trkSeg_t,* seg_p,i); if (t.type == SEG_BEZLIN || t.type == SEG_BEZTRK) { - if (t.bezSegs.ptr) MyFree(t.bezSegs.ptr); - t.bezSegs.cnt = 0; - t.bezSegs.max = 0; - t.bezSegs.ptr = NULL; + DYNARR_FREE( trkSeg_t, t.bezSegs ); } if (t.type == SEG_POLY || t.type == SEG_FILPOLY) { - if (t.u.p.pts) MyFree(t.u.p.pts); + if (t.u.p.pts) { MyFree(t.u.p.pts); } t.u.p.cnt = 0; t.u.p.pts = NULL; } } - seg_p->cnt = 0; - if (seg_p->ptr) MyFree(seg_p->ptr); - seg_p->ptr = NULL; - seg_p->max = 0; -} -/* - * Copy Segs from one array to another - */ -EXPORT void AppendSegsToArray(dynArr_t * seg_to, dynArr_t * seg_from) { - if (seg_from->cnt ==0) return; - int j = 0; - DYNARR_APPEND(trkSeg_t, * seg_to, seg_from->cnt); - for (int i=0; i<seg_from->cnt;i++,j++) { - trkSeg_p from_p = &DYNARR_N(trkSeg_t, * seg_from,j); - trkSeg_p to_p = &DYNARR_N(trkSeg_t, * seg_to,i); - memcpy(to_p,from_p,sizeof( trkSeg_t)); - if (from_p->type == SEG_BEZLIN || from_p->type == SEG_BEZTRK) { - if (from_p->bezSegs.ptr) { - to_p->bezSegs.ptr = memdup(from_p->bezSegs.ptr,from_p->bezSegs.cnt*sizeof(trkSeg_t)); - } - } - if (from_p->type == SEG_POLY || from_p->type == SEG_FILPOLY) { - if (from_p->u.p.pts) { - to_p->u.p.pts = memdup(from_p->u.p.pts,from_p->u.p.cnt*sizeof(pts_t)); - } - } + if ( seg_p == &tempSegs_da ) { + DYNARR_RESET( trkSeg_t, *seg_p ); + } else { + DYNARR_FREE( trkSeg_t, *seg_p ); } } -EXPORT void AppendTransformedSegs(dynArr_t * seg_to, dynArr_t * seg_from, coOrd orig, coOrd rotateOrig, ANGLE_T angle) { - if (seg_from->cnt ==0) return; - int j = 0; - DYNARR_APPEND(trkSeg_t, * seg_to, seg_from->cnt); - for (int i=0; i<seg_from->cnt;i++,j++) { - trkSeg_p from_p = &DYNARR_N(trkSeg_t, * seg_from,j); - trkSeg_p to_p = &DYNARR_N(trkSeg_t, * seg_to,i); - memcpy(to_p,from_p,sizeof( trkSeg_t)); - if (from_p->type == SEG_BEZLIN || from_p->type == SEG_BEZTRK) { - if (from_p->bezSegs.ptr) { - to_p->bezSegs.ptr = memdup(from_p->bezSegs.ptr,from_p->bezSegs.cnt*sizeof(trkSeg_t)); - } - } - if (from_p->type == SEG_POLY || from_p->type == SEG_FILPOLY) { - if (from_p->u.p.pts) { - to_p->u.p.pts = memdup(from_p->u.p.pts,from_p->u.p.cnt*sizeof(pts_t)); - } - } - RotateSegs(1,to_p,rotateOrig,angle); - coOrd move; - move.x = orig.x - rotateOrig.x; - move.y = orig.y - rotateOrig.y; - MoveSegs(1,to_p,move); - } -} -EXPORT void CopyPoly(trkSeg_p p, wIndex_t segCnt) { +EXPORT void CopyPoly(trkSeg_p p, wIndex_t segCnt) +{ pts_t * newPts; - for (int i=0;i<segCnt;i++,p++) { + for (int i=0; i<segCnt; i++,p++) { if ((p->type == SEG_POLY) || (p->type == SEG_FILPOLY)) { newPts = memdup( p->u.p.pts, p->u.p.cnt*sizeof (pts_t) ); p->u.p.pts = newPts; @@ -2113,10 +2120,10 @@ EXPORT void CopyPoly(trkSeg_p p, wIndex_t segCnt) { EXPORT wBool_t CompareSegs( - trkSeg_p segPtr1, - int segCnt1, - trkSeg_p segPtr2, - int segCnt2 ) + trkSeg_p segPtr1, + int segCnt1, + trkSeg_p segPtr2, + int segCnt2 ) { char * cp = message+strlen(message); if ( segCnt1 != segCnt2 ) { @@ -2139,7 +2146,7 @@ EXPORT wBool_t CompareSegs( // These don't have widths break; default: - REGRESS_CHECK_WIDTH( "Width", segP1, segP2, width ); + REGRESS_CHECK_WIDTH( "Width", segP1, segP2, lineWidth ); } switch( segP1->type ) { case SEG_DIMLIN: diff --git a/app/bin/trkseg.h b/app/bin/trkseg.h new file mode 100644 index 0000000..8a39097 --- /dev/null +++ b/app/bin/trkseg.h @@ -0,0 +1,252 @@ +/** \file trkseg.h + * + */ + +/* XTrkCad - Model Railroad CAD + * Copyright (C) 2005 Dave Bullis + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef TRKSEG_H +#define TRKSEG_H + +#include "common.h" + +#define MAX_PATH_SEGS (127) + +typedef enum { FREEFORM, RECTANGLE, POLYLINE + } PolyType_e; + + +typedef struct trkSeg_t { + char type; + wDrawColor color; + LWIDTH_T lineWidth; + dynArr_t bezSegs; //placed here to avoid overwrites + union { + struct { + coOrd pos[4]; + ANGLE_T angle; + long option; + } l; + struct { + coOrd pos[4]; + ANGLE_T angle0; + ANGLE_T angle3; + DIST_T minRadius; + DIST_T radius0; + DIST_T radius3; + DIST_T length; + } b; + struct { + coOrd center; + ANGLE_T a0, a1; + DIST_T radius; + } c; + struct { + coOrd pos; + ANGLE_T angle; + DIST_T R, L; + DIST_T l0, l1; + unsigned int flip:1; + unsigned int negate:1; + unsigned int Scurve:1; + } j; + struct { + coOrd pos; + ANGLE_T angle; + wFont_p fontP; + FONTSIZE_T fontSize; + BOOL_T boxed; + char * string; + } t; + struct { + int cnt; + pts_t * pts; + coOrd orig; + ANGLE_T angle; + PolyType_e polyType; + } p; + } u; +} trkSeg_t; +typedef struct trkSeg_t * trkSeg_p; + +#define SEG_STRTRK ('S') +#define SEG_CRVTRK ('C') +#define SEG_BEZTRK ('W') +#define SEG_STRLIN ('L') +#define SEG_CRVLIN ('A') +#define SEG_BEZLIN ('H') +#define SEG_JNTTRK ('J') +#define SEG_FILCRCL ('G') +#define SEG_POLY ('Y') +#define SEG_FILPOLY ('F') +#define SEG_TEXT ('Z') +#define SEG_UNCEP ('E') +#define SEG_CONEP ('T') +#define SEG_PATH ('P') +#define SEG_SPEC ('X') +#define SEG_CUST ('U') +#define SEG_DOFF ('D') +#define SEG_BENCH ('B') +#define SEG_DIMLIN ('M') +#define SEG_TBLEDGE ('Q') + +#define IsSegTrack( S ) ( (S)->type == SEG_STRTRK || (S)->type == SEG_CRVTRK || (S)->type == SEG_JNTTRK || (S)->type == SEG_BEZTRK) + +extern dynArr_t tempSegs_da; + +#define tempSegs(N) DYNARR_N( trkSeg_t, tempSegs_da, N ) + +extern char tempSpecial[4096]; +extern char tempCustom[4096]; + +void ComputeCurvedSeg( + trkSeg_p s, + DIST_T radius, + coOrd p0, + coOrd p1 ); + +coOrd GetSegEndPt( + trkSeg_p segPtr, + EPINX_T ep, + BOOL_T bounds, + ANGLE_T * ); + +void GetTextBounds( coOrd, ANGLE_T, char *, FONTSIZE_T, coOrd *, coOrd * ); +void GetSegBounds( coOrd, ANGLE_T, wIndex_t, trkSeg_p, coOrd *, coOrd * ); +void MoveSegs( wIndex_t, trkSeg_p, coOrd ); +void RotateSegs( wIndex_t, trkSeg_p, coOrd, ANGLE_T ); +void FlipSegs( wIndex_t, trkSeg_p, coOrd, ANGLE_T ); +void RescaleSegs( wIndex_t, trkSeg_p, DIST_T, DIST_T, DIST_T ); +void CloneFilledDraw( wIndex_t, trkSeg_p, BOOL_T ); +void FreeFilledDraw( wIndex_t, trkSeg_p ); +DIST_T DistanceSegs( coOrd, ANGLE_T, wIndex_t, trkSeg_p, coOrd *, wIndex_t * ); +ANGLE_T GetAngleSegs( wIndex_t, trkSeg_p, coOrd *, wIndex_t *, DIST_T *, + BOOL_T *, wIndex_t *, BOOL_T * ); +void RecolorSegs( wIndex_t, trkSeg_p, wDrawColor ); +BOOL_T ReadSegs( void ); +BOOL_T WriteSegs( FILE * f, wIndex_t segCnt, trkSeg_p segs ); +BOOL_T WriteSegsEnd(FILE * f, wIndex_t segCnt, trkSeg_p segs, BOOL_T writeEnd); + + +typedef union { + struct { + coOrd pos; /* IN the point to get to */ + ANGLE_T angle; /* IN is the angle that the object starts at (-ve for forwards) */ + DIST_T dist; /* OUT is how far it is along the track to get to pos*/ + BOOL_T backwards; /* OUT which way are we going? */ + BOOL_T reverse_seg; /* OUT the seg is backwards curve */ + BOOL_T negative; /* OUT the curve is negative */ + int BezSegInx; /* OUT for Bezier Seg - the segment we are on in Bezier */ + BOOL_T segs_backwards; /* OUT for Bezier Seg - the direction of the overall Bezier */ + } traverse1; // Find dist between pos and end of track that starts with angle set backwards + struct { + BOOL_T segDir; /* IN Direction to go in this seg*/ + int BezSegInx; /* IN for Bezier Seg which element to start with*/ + BOOL_T segs_backwards; /* IN for Bezier Seg which way to go down the array*/ + DIST_T dist; /* IN/OUT In = distance to go, Out = distance left */ + coOrd pos; /* OUT = point reached if dist = 0 */ + ANGLE_T angle; /* OUT = angle at point */ + } traverse2; //Return distance left (or 0) and angle and pos when going dist from segDir end + struct { + int first, last; /* IN */ + ANGLE_T side; + DIST_T roadbedWidth; + wDrawWidth rbw; + coOrd orig; + ANGLE_T angle; + wDrawColor color; + drawCmd_p d; + } drawRoadbedSide; + struct { + coOrd pos1; /* IN pos to find */ + DIST_T dd; /* OUT distance from nearest point in seg to input pos */ + } distance; + struct { + track_p trk; /* OUT */ + EPINX_T ep[2]; + } newTrack; + struct { + DIST_T length; /* OUT */ + } length; + struct { + coOrd pos; /* IN */ + DIST_T length[2]; /* OUT */ + trkSeg_t newSeg[2]; + } split; + struct { + coOrd pos; /* IN Pos to find nearest to - OUT found pos on curve*/ + ANGLE_T angle; /* OUT angle at pos - (-ve if backwards)*/ + BOOL_T negative_radius; /* OUT Radius <0? */ + BOOL_T backwards; /* OUT Seg is backwards */ + DIST_T radius; /* OUT radius at pos */ + coOrd center; /* OUT center of curvature at pos (0 = straight)*/ + int bezSegInx; /* OUT if a bezier proc, the index of the sub segment */ + } getAngle; // Get pos on seg nearest, angle at that (-ve for forwards) +} segProcData_t, *segProcData_p; +typedef enum { + SEGPROC_TRAVERSE1, + SEGPROC_TRAVERSE2, + SEGPROC_DRAWROADBEDSIDE, + SEGPROC_DISTANCE, + SEGPROC_FLIP, + SEGPROC_NEWTRACK, + SEGPROC_LENGTH, + SEGPROC_SPLIT, + SEGPROC_GETANGLE +} segProc_e; + +void SegProc( segProc_e, trkSeg_p, segProcData_p ); +void DrawDimLine( drawCmd_p, coOrd, coOrd, char *, wFontSize_t, FLOAT_T, + wDrawWidth, wDrawColor, long ); +void DrawSegs( + drawCmd_p d, + coOrd orig, + ANGLE_T angle, + trkSeg_p segPtr, + wIndex_t segCnt, + DIST_T trackGauge, + wDrawColor color ); +void DrawSegsDA( + drawCmd_p d, + track_p trk, + coOrd orig, + ANGLE_T angle, + dynArr_t * da, + DIST_T trackGauge, + wDrawColor color, + long options ); +void DrawSegsO( + drawCmd_p d, + track_p trk, + coOrd orig, + ANGLE_T angle, + trkSeg_p segPtr, + wIndex_t segCnt, + DIST_T trackGauge, + wDrawColor color, + long options ); + + +void StraightSegProc( segProc_e, trkSeg_p, segProcData_p ); +void CurveSegProc( segProc_e, trkSeg_p, segProcData_p ); +void JointSegProc( segProc_e, trkSeg_p, segProcData_p ); +void BezierSegProc( segProc_e, trkSeg_p, segProcData_p ); //Used in Cornu join +void CleanSegs( dynArr_t *); +void CopyPoly(trkSeg_p seg_p, wIndex_t segCnt); +wBool_t CompareSegs( trkSeg_p, int, trkSeg_p, int ); +#endif diff --git a/app/bin/tstraigh.c b/app/bin/tstraigh.c index 4408023..1a3fa51 100644 --- a/app/bin/tstraigh.c +++ b/app/bin/tstraigh.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "cstraigh.h" @@ -37,11 +37,14 @@ static TRKTYP_T T_STRAIGHT = -1; typedef struct extraDataStraight_t { - extraDataBase_t base; - coOrd descriptionOff; - } extraDataStraight_t; + extraDataBase_t base; + coOrd descriptionOff; +} extraDataStraight_t; +/** @logcmd @showrefby straight=n tstraigh.c */ +static int log_straight = 0; + /**************************************** * * UTILITIES @@ -51,15 +54,13 @@ typedef struct extraDataStraight_t { void AdjustStraightEndPt( track_p t, EPINX_T inx, coOrd pos ) { - if (GetTrkType(t) != T_STRAIGHT) { - AbortProg( "AdjustLIneEndPt( %d, %d ) not on STRAIGHT %d\n", - GetTrkIndex(t), inx, GetTrkType(t) ); - return; - } + CHECKMSG( GetTrkType(t) == T_STRAIGHT, + ("AdjustLIneEndPt( %d, %d ) not on STRAIGHT %d\n", + GetTrkIndex(t), inx, GetTrkType(t) ) ); UndoModify( t ); #ifdef VERBOSE -lprintf("adjustStraightEndPt T%d[%d] p=[%0.3f %0.3f]\n", - GetTrkIndex(t), inx, pos.x, pos.y ); + lprintf("adjustStraightEndPt T%d[%d] p=[%0.3f %0.3f]\n", + GetTrkIndex(t), inx, pos.x, pos.y ); #endif SetTrkEndPoint( t, inx, pos, GetTrkEndAngle(t,inx)); ComputeBoundingBox( t ); @@ -73,69 +74,78 @@ lprintf("adjustStraightEndPt T%d[%d] p=[%0.3f %0.3f]\n", */ static struct { - coOrd endPt[2]; - DIST_T elev[2]; - FLOAT_T length; - ANGLE_T angle; - FLOAT_T grade; - descPivot_t pivot; - unsigned int layerNumber; - } strData; + coOrd endPt[2]; + DIST_T elev[2]; + FLOAT_T length; + ANGLE_T angle; + FLOAT_T grade; + descPivot_t pivot; + unsigned int layerNumber; +} strData; typedef enum { E0, Z0, E1, Z1, LN, AN, GR, PV, LY } strDesc_e; static descData_t strDesc[] = { -/*E0*/ { DESC_POS, N_("End Pt 1: X,Y"), &strData.endPt[0] }, -/*Z0*/ { DESC_DIM, N_("Z"), &strData.elev[0] }, -/*E1*/ { DESC_POS, N_("End Pt 2: X,Y"), &strData.endPt[1] }, -/*Z1*/ { DESC_DIM, N_("Z"), &strData.elev[1] }, -/*LN*/ { DESC_DIM, N_("Length"), &strData.length }, -/*AN*/ { DESC_ANGLE, N_("Track Angle"), &strData.angle }, -/*GR*/ { DESC_FLOAT, N_("Grade"), &strData.grade }, -/*PV*/ { DESC_PIVOT, N_("Pivot"), &strData.pivot }, -/*LY*/ { DESC_LAYER, N_("Layer"), &strData.layerNumber }, - { DESC_NULL } }; + /*E0*/ { DESC_POS, N_("End Pt 1: X,Y"), &strData.endPt[0] }, + /*Z0*/ { DESC_DIM, N_("Z"), &strData.elev[0] }, + /*E1*/ { DESC_POS, N_("End Pt 2: X,Y"), &strData.endPt[1] }, + /*Z1*/ { DESC_DIM, N_("Z"), &strData.elev[1] }, + /*LN*/ { DESC_DIM, N_("Length"), &strData.length }, + /*AN*/ { DESC_ANGLE, N_("Track Angle"), &strData.angle }, + /*GR*/ { DESC_FLOAT, N_("Grade"), &strData.grade }, + /*PV*/ { DESC_PIVOT, N_("Pivot"), &strData.pivot }, + /*LY*/ { DESC_LAYER, N_("Layer"), &strData.layerNumber }, + { DESC_NULL } +}; EXPORT BOOL_T UpdateDescStraight( - int inx, - int e0, - int e1, - int ln, - int an, - descData_p desc, - long pivot ) + int inx, + int e0, + int e1, + int ln, + int an, + descData_p desc, + long pivot ) { coOrd mid; if ( inx == e0 || inx == e1 ) { - *(DIST_T*)desc[ln].valueP = FindDistance( *(coOrd*)desc[e0].valueP, *(coOrd*)desc[e1].valueP ); - *(ANGLE_T*)desc[an].valueP = FindAngle( *(coOrd*)desc[e0].valueP, *(coOrd*)desc[e1].valueP ); - if ( inx == e0 ) + *(DIST_T*)desc[ln].valueP = FindDistance( *(coOrd*)desc[e0].valueP, + *(coOrd*)desc[e1].valueP ); + *(ANGLE_T*)desc[an].valueP = FindAngle( *(coOrd*)desc[e0].valueP, + *(coOrd*)desc[e1].valueP ); + if ( inx == e0 ) { desc[e1].mode |= DESC_CHANGE; - else + } else { desc[e0].mode |= DESC_CHANGE; + } desc[ln].mode |= DESC_CHANGE; desc[an].mode |= DESC_CHANGE; } else if ( inx == ln || inx == an ) { if ( inx == ln && *(DIST_T*)desc[ln].valueP <= minLength ) { ErrorMessage( MSG_OBJECT_TOO_SHORT ); - *(DIST_T*)desc[ln].valueP = FindDistance( *(coOrd*)desc[e0].valueP, *(coOrd*)desc[e1].valueP ); + *(DIST_T*)desc[ln].valueP = FindDistance( *(coOrd*)desc[e0].valueP, + *(coOrd*)desc[e1].valueP ); desc[ln].mode |= DESC_CHANGE; return FALSE; } switch (pivot) { case DESC_PIVOT_FIRST: - Translate( (coOrd*)desc[e1].valueP, *(coOrd*)desc[e0].valueP, *(ANGLE_T*)desc[an].valueP, *(DIST_T*)desc[ln].valueP ); + Translate( (coOrd*)desc[e1].valueP, *(coOrd*)desc[e0].valueP, + *(ANGLE_T*)desc[an].valueP, *(DIST_T*)desc[ln].valueP ); desc[e1].mode |= DESC_CHANGE; break; case DESC_PIVOT_SECOND: - Translate( (coOrd*)desc[e0].valueP, *(coOrd*)desc[e1].valueP, *(ANGLE_T*)desc[an].valueP+180.0, *(DIST_T*)desc[ln].valueP ); + Translate( (coOrd*)desc[e0].valueP, *(coOrd*)desc[e1].valueP, + *(ANGLE_T*)desc[an].valueP+180.0, *(DIST_T*)desc[ln].valueP ); desc[e0].mode |= DESC_CHANGE; break; case DESC_PIVOT_MID: mid.x = (((coOrd*)desc[e0].valueP)->x+((coOrd*)desc[e1].valueP)->x)/2.0; mid.y = (((coOrd*)desc[e0].valueP)->y+((coOrd*)desc[e1].valueP)->y)/2.0; - Translate( (coOrd*)desc[e0].valueP, mid, *(ANGLE_T*)desc[an].valueP+180.0, *(DIST_T*)desc[ln].valueP/2.0 ); - Translate( (coOrd*)desc[e1].valueP, mid, *(ANGLE_T*)desc[an].valueP, *(DIST_T*)desc[ln].valueP/2.0 ); + Translate( (coOrd*)desc[e0].valueP, mid, *(ANGLE_T*)desc[an].valueP+180.0, + *(DIST_T*)desc[ln].valueP/2.0 ); + Translate( (coOrd*)desc[e1].valueP, mid, *(ANGLE_T*)desc[an].valueP, + *(DIST_T*)desc[ln].valueP/2.0 ); desc[e0].mode |= DESC_CHANGE; desc[e1].mode |= DESC_CHANGE; break; @@ -149,7 +159,8 @@ EXPORT BOOL_T UpdateDescStraight( } -static void UpdateStraight( track_p trk, int inx, descData_p descUpd, BOOL_T final ) +static void UpdateStraight( track_p trk, int inx, descData_p descUpd, + BOOL_T final ) { EPINX_T ep; switch ( inx ) { @@ -157,18 +168,21 @@ static void UpdateStraight( track_p trk, int inx, descData_p descUpd, BOOL_T fin case E1: case LN: case AN: - if ( ! UpdateDescStraight( inx, E0, E1, LN, AN, strDesc, strData.pivot ) ) + if ( ! UpdateDescStraight( inx, E0, E1, LN, AN, strDesc, strData.pivot ) ) { return; + } break; case Z0: case Z1: ep = (inx==Z0?0:1); - UpdateTrkEndElev( trk, ep, GetTrkEndElevUnmaskedMode(trk,ep), strData.elev[ep], NULL ); + UpdateTrkEndElev( trk, ep, GetTrkEndElevUnmaskedMode(trk,ep), strData.elev[ep], + NULL ); ComputeElev( trk, 1-ep, FALSE, &strData.elev[1-ep], NULL, TRUE ); - if ( strData.length > minLength ) + if ( strData.length > minLength ) { strData.grade = fabs( (strData.elev[0]-strData.elev[1])/strData.length )*100.0; - else + } else { strData.grade = 0.0; + } strDesc[GR].mode |= DESC_CHANGE; strDesc[inx==Z0?Z1:Z0].mode |= DESC_CHANGE; /*return;*/ @@ -180,22 +194,27 @@ static void UpdateStraight( track_p trk, int inx, descData_p descUpd, BOOL_T fin return; } UndrawNewTrack( trk ); - if ( GetTrkEndTrk(trk,0) == NULL ) - SetTrkEndPoint( trk, 0, strData.endPt[0], NormalizeAngle(strData.angle+180.0) ); - if ( GetTrkEndTrk(trk,1) == NULL ) + if ( GetTrkEndTrk(trk,0) == NULL ) { + SetTrkEndPoint( trk, 0, strData.endPt[0], + NormalizeAngle(strData.angle+180.0) ); + } + if ( GetTrkEndTrk(trk,1) == NULL ) { SetTrkEndPoint( trk, 1, strData.endPt[1], strData.angle ); + } ComputeBoundingBox( trk ); - DrawNewTrack( trk ); + DrawNewTrack( trk ); } static void DescribeStraight( track_p trk, char * str, CSIZE_T len ) { int fix0, fix1; - sprintf( str, _("Straight Track(%d): Layer=%d Length=%s EP=[%0.3f,%0.3f A%0.3f] [%0.3f,%0.3f A%0.3f]"), GetTrkIndex(trk), - GetTrkLayer(trk)+1, - FormatDistance(FindDistance( GetTrkEndPos(trk,0), GetTrkEndPos(trk,1) )), - GetTrkEndPosXY(trk,0), GetTrkEndAngle(trk,0), - GetTrkEndPosXY(trk,1), GetTrkEndAngle(trk,1) ); + sprintf( str, + _("Straight Track(%d): Layer=%d Length=%s EP=[%0.3f,%0.3f A%0.3f] [%0.3f,%0.3f A%0.3f]"), + GetTrkIndex(trk), + GetTrkLayer(trk)+1, + FormatDistance(FindDistance( GetTrkEndPos(trk,0), GetTrkEndPos(trk,1) )), + GetTrkEndPosXY(trk,0), GetTrkEndAngle(trk,0), + GetTrkEndPosXY(trk,1), GetTrkEndAngle(trk,1) ); fix0 = GetTrkEndTrk(trk,0)!=NULL; fix1 = GetTrkEndTrk(trk,1)!=NULL; strData.endPt[0] = GetTrkEndPos(trk,0); @@ -204,13 +223,14 @@ static void DescribeStraight( track_p trk, char * str, CSIZE_T len ) ComputeElev( trk, 1, FALSE, &strData.elev[1], NULL, FALSE ); strData.length = FindDistance( strData.endPt[0], strData.endPt[1] ); strData.layerNumber = GetTrkLayer(trk); - if ( strData.length > minLength ) + if ( strData.length > minLength ) { strData.grade = fabs( (strData.elev[0]-strData.elev[1])/strData.length )*100.0; - else + } else { strData.grade = 0.0; + } strData.angle = FindAngle( strData.endPt[0], strData.endPt[1] ); strDesc[E0].mode = - strDesc[E1].mode = (fix0|fix1)?DESC_RO:0; + strDesc[E1].mode = (fix0|fix1)?DESC_RO:0; strDesc[Z0].mode = (EndPtIsDefinedElev(trk,0)?0:DESC_RO)|DESC_NOREDRAW; strDesc[Z1].mode = (EndPtIsDefinedElev(trk,1)?0:DESC_RO)|DESC_NOREDRAW; strDesc[GR].mode = DESC_RO; @@ -219,9 +239,9 @@ static void DescribeStraight( track_p trk, char * str, CSIZE_T len ) strDesc[PV].mode = (fix0|fix1)?DESC_IGNORE:0; strDesc[LY].mode = DESC_NOREDRAW; strData.pivot = (fix0&fix1)?DESC_PIVOT_NONE: - fix0?DESC_PIVOT_FIRST: - fix1?DESC_PIVOT_SECOND: - DESC_PIVOT_MID; + fix0?DESC_PIVOT_FIRST: + fix1?DESC_PIVOT_SECOND: + DESC_PIVOT_MID; DoDescribe( _("Straight Track"), trk, strDesc, UpdateStraight ); } @@ -231,22 +251,24 @@ static DIST_T DistanceStraight( track_p t, coOrd * p ) } STATUS_T StraightDescriptionMove( - track_p trk, - wAction_t action, - coOrd pos ) + track_p trk, + wAction_t action, + coOrd pos ) { extraDataStraight_t *xx = GET_EXTRA_DATA(trk, T_STRAIGHT, extraDataStraight_t); - ANGLE_T a,ap; + ANGLE_T ap; +// ANGLE_T a; coOrd end0, end1; - end0 = GetTrkEndPos(trk,0); - end1 = GetTrkEndPos(trk,1); - a = FindAngle(end0,end1); - ap = NormalizeAngle(FindAngle(end0,pos)-FindAngle(end0,end1)); + end0 = GetTrkEndPos(trk,0); + end1 = GetTrkEndPos(trk,1); +// a = FindAngle(end0,end1); + ap = NormalizeAngle(FindAngle(end0,pos)-FindAngle(end0,end1)); - xx->descriptionOff.y = FindDistance(end0,pos)*sin(D2R(ap))-2*GetTrkGauge(trk); - xx->descriptionOff.x = -0.5 + FindDistance(end0,pos)*cos(D2R(ap))/FindDistance(end0,end1); - if (xx->descriptionOff.x > 0.5) xx->descriptionOff.x = 0.5; - if (xx->descriptionOff.x < -0.5) xx->descriptionOff.x = -0.5; + xx->descriptionOff.y = FindDistance(end0,pos)*sin(D2R(ap))-2*GetTrkGauge(trk); + xx->descriptionOff.x = -0.5 + FindDistance(end0, + pos)*cos(D2R(ap))/FindDistance(end0,end1); + if (xx->descriptionOff.x > 0.5) { xx->descriptionOff.x = 0.5; } + if (xx->descriptionOff.x < -0.5) { xx->descriptionOff.x = -0.5; } return C_CONTINUE; @@ -254,18 +276,21 @@ STATUS_T StraightDescriptionMove( } DIST_T StraightDescriptionDistance( - coOrd pos, - track_p trk, - coOrd * dpos, - BOOL_T show_hidden, - BOOL_T * hidden) + coOrd pos, + track_p trk, + coOrd * dpos, + BOOL_T show_hidden, + BOOL_T * hidden) { coOrd p1; - if (hidden) *hidden = FALSE; - if ( GetTrkType( trk ) != T_STRAIGHT || ((( GetTrkBits( trk ) & TB_HIDEDESC ) != 0 ) && !show_hidden)) + if (hidden) { *hidden = FALSE; } + if ( GetTrkType( trk ) != T_STRAIGHT + || ((( GetTrkBits( trk ) & TB_HIDEDESC ) != 0 ) && !show_hidden)) { return DIST_INF; + } - struct extraDataStraight_t *xx = GET_EXTRA_DATA(trk, T_STRAIGHT, extraDataStraight_t); + struct extraDataStraight_t *xx = GET_EXTRA_DATA(trk, T_STRAIGHT, + extraDataStraight_t); ANGLE_T a; coOrd end0, end0off, end1, end1off; end0 = GetTrkEndPos(trk,0); @@ -277,27 +302,31 @@ DIST_T StraightDescriptionDistance( p1.x = (end1off.x - end0off.x)*(xx->descriptionOff.x+0.5) + end0off.x; p1.y = (end1off.y - end0off.y)*(xx->descriptionOff.x+0.5) + end0off.y; - if (hidden) *hidden = (GetTrkBits( trk ) & TB_HIDEDESC); + if (hidden) { *hidden = (GetTrkBits( trk ) & TB_HIDEDESC); } *dpos = p1; coOrd tpos = pos; - if (LineDistance(&tpos,end0,end1)<FindDistance( p1, pos )) + if (LineDistance(&tpos,end0,end1)<FindDistance( p1, pos )) { return LineDistance(&pos,end0,end1); + } return FindDistance( p1, pos ); } static void DrawStraightDescription( - track_p trk, - drawCmd_p d, - wDrawColor color ) + track_p trk, + drawCmd_p d, + wDrawColor color ) { ANGLE_T a; - struct extraDataStraight_t *xx = GET_EXTRA_DATA(trk, T_STRAIGHT, extraDataStraight_t); + struct extraDataStraight_t *xx = GET_EXTRA_DATA(trk, T_STRAIGHT, + extraDataStraight_t); - if (layoutLabels == 0) + if (layoutLabels == 0) { return; - if ((labelEnable&LABELENABLE_TRKDESC)==0) + } + if ((labelEnable&LABELENABLE_TRKDESC)==0) { return; + } coOrd end0, end0off, end1, end1off; end0 = GetTrkEndPos(trk,0); @@ -308,16 +337,18 @@ static void DrawStraightDescription( Translate(&end1off,end1,a+90,2*GetTrkGauge(trk)+xx->descriptionOff.y); DrawLine(d,end1,end1off,0,color); sprintf( message, "L%s A%0.3f", - FormatDistance(FindDistance(end0,end1)),FindAngle(end0,end1)); + FormatDistance(FindDistance(end0,end1)),FindAngle(end0,end1)); - DrawDimLine( d, end0off, end1off, message, (wFontSize_t)descriptionFontSize, xx->descriptionOff.x+0.5, 0, color, 0x00 ); + DrawDimLine( d, end0off, end1off, message, (wFontSize_t)descriptionFontSize, + xx->descriptionOff.x+0.5, 0, color, 0x00 ); - if ( !(GetTrkBits( trk ) & TB_DETAILDESC) ) return; + if ( !(GetTrkBits( trk ) & TB_DETAILDESC) ) { return; } if ( GetTrkBits( trk ) & TB_DETAILDESC ) { coOrd details_pos; details_pos.x = (end1off.x - end0off.x)*(xx->descriptionOff.x+0.5) + end0off.x; - details_pos.y = (end1off.y - end0off.y)*(xx->descriptionOff.x+0.5) + end0off.y-(2*descriptionFontSize/mainD.dpi); + details_pos.y = (end1off.y - end0off.y)*(xx->descriptionOff.x+0.5) + end0off.y- + (2*descriptionFontSize/mainD.dpi); AddTrkDetails(d, trk, details_pos, FindDistance(end0,end1), color); } @@ -327,37 +358,195 @@ static void DrawStraightDescription( static void DrawStraight( track_p t, drawCmd_p d, wDrawColor color ) { if (((d->options&(DC_SIMPLE|DC_SEGTRACK))==0) && - (labelWhen == 2 || (labelWhen == 1 && (d->options&DC_PRINT))) && - labelScale >= d->scale && - ( GetTrkBits( t ) & TB_HIDEDESC ) == 0 ) { - DrawStraightDescription( t, d, color ); + (labelWhen == 2 || (labelWhen == 1 && (d->options&DC_PRINT))) && + labelScale >= d->scale && + ( GetTrkBits( t ) & TB_HIDEDESC ) == 0 ) { + DrawStraightDescription( t, d, color ); } - long bridge = GetTrkBridge( t ); + // long bridge = GetTrkBridge( t ); long widthOptions = DTS_LEFT|DTS_RIGHT; DrawStraightTrack( d, GetTrkEndPos(t,0), GetTrkEndPos(t,1), - GetTrkEndAngle(t,0), - t, color, widthOptions ); + GetTrkEndAngle(t,0), + t, color, widthOptions ); DrawEndPt( d, t, 0, color ); DrawEndPt( d, t, 1, color ); } +EXPORT void DrawStraightTies( + drawCmd_p d, + tieData_t td, + coOrd p0, + coOrd p1, + wDrawColor color ) +{ + DIST_T tieOff0=0.0, tieOff1=0.0; + DIST_T len, dlen; + coOrd pos; + int cnt; + ANGLE_T angle; + + if ( (d->options&DC_SIMPLE) != 0 ) { + return; + } + + if ( color == wDrawColorBlack ) { + color = tieColor; + } + len = FindDistance( p0, p1 ); + len -= tieOff0+tieOff1; + angle = FindAngle( p0, p1 ); + cnt = (int)floor(len / td.spacing+0.5); + if ( len - td.spacing*cnt - td.width > (td.spacing - td.width)/2 ) { + cnt++; + } + if ( cnt != 0 ) { + dlen = FindDistance( p0, p1 )/cnt; +// double endsize = FindDistance( p0, p1 )-cnt*dlen-td->width; + for ( len=dlen/2; cnt; cnt--,len+=dlen ) { + Translate( &pos, p0, angle, len ); + DrawTie( d, pos, angle, td.length, td.width, color, + tieDrawMode==TIEDRAWMODE_SOLID ); + } + } +} + + + +EXPORT void DrawStraightTrack( + drawCmd_p d, + coOrd p0, + coOrd p1, + ANGLE_T angle, + track_cp trk, + wDrawColor color, + long options ) +{ + coOrd pp0, pp1; + DIST_T trackGauge = GetTrkGauge(trk); + tieData_t td; + long bridge = 0, roadbed = 0; + if ( trk ) { + bridge = GetTrkBridge(trk); + roadbed = GetTrkRoadbed(trk); + } + wDrawWidth width=0; + trkSeg_p segPtr; + + if ( (d->options&DC_SEGTRACK) ) { + DYNARR_APPEND( trkSeg_t, tempSegs_da, 10 ); + segPtr = &tempSegs(tempSegs_da.cnt-1); + segPtr->type = SEG_STRTRK; + segPtr->lineWidth = 0; + segPtr->color = wDrawColorBlack; + segPtr->u.l.pos[0] = p0; + segPtr->u.l.pos[1] = p1; + segPtr->u.l.angle = angle; + segPtr->u.l.option = 0; + return; + } + + width = trk ? GetTrkWidth( trk ): 0; + if ((d->options&DC_PRINT) && (d->dpi>2*BASE_DPI)) { + width = (wDrawWidth)round(width * d->dpi / 2 / BASE_DPI); + } + + if ( d->options&DC_THICK ) { + width = 3; + } + if ( color == wDrawColorPreviewSelected + || color == wDrawColorPreviewUnselected ) { + width = 3; + } + + + LOG(log_straight,4,("DST( (%0.3f %0.3f) .. (%0.3f..%0.3f)\n", + p0.x, p0.y, p1.x, p1.y ) ) + + // Draw solid background + if(bridge|roadbed) { + wDrawWidth width3 = (wDrawWidth)round(trackGauge * 3 * d->dpi / d->scale); + DrawLine(d,p0,p1,width3,bridge?bridgeColor:roadbedColor); + } + + if ( DoDrawTies( d, trk ) ) { + td = GetTrkTieData( trk ); + DrawStraightTies( d, td, p0, p1, color ); + } + if (color == wDrawColorBlack) { + color = normalColor; + } + if ( ! DrawTwoRails( d, 1 ) ) { + DrawLine( d, p0, p1, width, color ); + } else { + if ( hasTrackCenterline(d)) { + long options = d->options; + d->options |= DC_DASH; + DrawLine( d, p0, p1, 0, color ); + d->options = options; + } + Translate( &pp0, p0, angle+90, trackGauge/2.0 ); + Translate( &pp1, p1, angle+90, trackGauge/2.0 ); + DrawLine( d, pp0, pp1, width, color ); + + Translate( &pp0, p0, angle-90, trackGauge/2.0 ); + Translate( &pp1, p1, angle-90, trackGauge/2.0 ); + DrawLine( d, pp0, pp1, width, color ); + + if ( (d->options&DC_PRINT) && roadbedWidth > trackGauge && DrawTwoRails(d,1) ) { + wDrawWidth rbw = (wDrawWidth)floor(roadbedLineWidth*(d->dpi/d->scale)+0.5); + if ( options&DTS_RIGHT ) { + Translate( &pp0, p0, angle+90, roadbedWidth/2.0 ); + Translate( &pp1, p1, angle+90, roadbedWidth/2.0 ); + DrawLine( d, pp0, pp1, rbw, color ); + } + if ( options&DTS_LEFT ) { + Translate( &pp0, p0, angle-90, roadbedWidth/2.0 ); + Translate( &pp1, p1, angle-90, roadbedWidth/2.0 ); + DrawLine( d, pp0, pp1, rbw, color ); + } + } + } + + if (bridge) { + wDrawWidth width2 = (wDrawWidth)round((2.0 * d->dpi)/BASE_DPI); + if (d->options&DC_PRINT) { + width2 = (wDrawWidth)round(d->dpi / BASE_DPI); + } + + Translate( &pp0, p0, angle-90, trackGauge*1.5 ); + Translate( &pp1, p1, angle-90, trackGauge*1.5 ); + DrawLine( d, pp0, pp1, width2, color ); + + Translate( &pp0, p0, angle+90, trackGauge*1.5 ); + Translate( &pp1, p1, angle+90, trackGauge*1.5 ); + DrawLine( d, pp0, pp1, width2, color); + } +} + + static void DeleteStraight( track_p t ) { } static BOOL_T WriteStraight( track_p t, FILE * f ) { + int bits; long options; - struct extraDataStraight_t *xx = GET_EXTRA_DATA(t, T_STRAIGHT, extraDataStraight_t); + struct extraDataStraight_t *xx = GET_EXTRA_DATA(t, T_STRAIGHT, + extraDataStraight_t); BOOL_T rc = TRUE; options = GetTrkWidth(t) & 0x0F; if ( ( GetTrkBits(t) & TB_HIDEDESC ) == 0 ) // 0x80 means Show Description + { options |= 0x80; + } + bits = GetTrkVisible(t)|(GetTrkNoTies(t)?1<<2:0)|(GetTrkBridge(t)?1<<3:0)| + (GetTrkRoadbed(t)?1<<4:0); rc &= fprintf(f, "STRAIGHT %d %d %ld 0 0 %s %d %0.6f %0.6f\n", - GetTrkIndex(t), GetTrkLayer(t), options, - GetTrkScaleName(t), GetTrkVisible(t)|(GetTrkNoTies(t)?1<<2:0)|(GetTrkBridge(t)?1<<3:0), xx->descriptionOff.x, xx->descriptionOff.y )>0; + GetTrkIndex(t), GetTrkLayer(t), options, + GetTrkScaleName(t), bits, xx->descriptionOff.x, xx->descriptionOff.y )>0; rc &= WriteEndPt( f, t, 0 ); rc &= WriteEndPt( f, t, 1 ); rc &= fprintf(f, "\t%s\n", END_SEGS)>0; @@ -376,14 +565,18 @@ static BOOL_T ReadStraight( char * line ) char * cp = NULL; coOrd descriptionOff = { 0.0, 0.0 }; - if ( !GetArgs( line+8, paramVersion<3?"dXZsdc":"dLl00sdc", &index, &layer, &options, scale, &visible, &cp ) ) + if ( !GetArgs( line+8, paramVersion<3?"dXZsdc":"dLl00sdc", &index, &layer, + &options, scale, &visible, &cp ) ) { return FALSE; + } if (cp) { - if (!GetArgs(cp,"p",&descriptionOff)) + if (!GetArgs(cp,"p",&descriptionOff)) { return FALSE; + } } - if ( !ReadSegs() ) + if ( !ReadSegs() ) { return FALSE; + } trk = NewTrack( index, T_STRAIGHT, 0, sizeof *xx ); xx = GET_EXTRA_DATA(trk, T_STRAIGHT, extraDataStraight_t); xx->descriptionOff = descriptionOff; @@ -392,17 +585,20 @@ static BOOL_T ReadStraight( char * line ) SetTrkVisible(trk, visible!=0); SetTrkNoTies(trk, FALSE); SetTrkBridge(trk, FALSE); + SetTrkRoadbed(trk, FALSE); } else { SetTrkVisible(trk, visible&2); SetTrkNoTies(trk, visible&4); SetTrkBridge(trk, visible&8); + SetTrkRoadbed(trk, visible&16); } SetTrkLayer(trk, layer); SetTrkWidth( trk, (int)(options & 0x0F) ); SetEndPts( trk, 2 ); ComputeBoundingBox( trk ); - if ( paramVersion < VERSION_DESCRIPTION2 || ( ( options & 0x80 ) == 0 ) ) + if ( paramVersion < VERSION_DESCRIPTION2 || ( ( options & 0x80 ) == 0 ) ) { SetTrkBits(trk,TB_HIDEDESC); + } return TRUE; } @@ -431,23 +627,27 @@ static int AuditStraight( track_p trk, char * msg ) } -static ANGLE_T GetAngleStraight( track_p trk, coOrd pos, EPINX_T *ep0, EPINX_T *ep1 ) +static ANGLE_T GetAngleStraight( track_p trk, coOrd pos, EPINX_T *ep0, + EPINX_T *ep1 ) { - if ( ep0 ) *ep0 = 0; - if ( ep1 ) *ep1 = 1; + if ( ep0 ) { *ep0 = 0; } + if ( ep1 ) { *ep1 = 1; } return GetTrkEndAngle( trk, 0 ); } -static BOOL_T SplitStraight( track_p trk, coOrd pos, EPINX_T ep, track_p *leftover, EPINX_T * ep0, EPINX_T * ep1 ) +static BOOL_T SplitStraight( track_p trk, coOrd pos, EPINX_T ep, + track_p *leftover, EPINX_T * ep0, EPINX_T * ep1 ) { track_p trk1; - trk1 = NewStraightTrack( 1-ep?GetTrkEndPos(trk,ep):pos, 1-ep?pos:GetTrkEndPos(trk,ep) ); + trk1 = NewStraightTrack( 1-ep?GetTrkEndPos(trk,ep):pos, + 1-ep?pos:GetTrkEndPos(trk,ep) ); DIST_T height; int opt; GetTrkEndElev(trk,ep,&opt,&height); - UpdateTrkEndElev( trk1, ep, opt, height, (opt==ELEV_STATION)?GetTrkEndElevStation(trk,ep):NULL ); + UpdateTrkEndElev( trk1, ep, opt, height, + (opt==ELEV_STATION)?GetTrkEndElevStation(trk,ep):NULL ); AdjustStraightEndPt( trk, ep, pos ); UpdateTrkEndElev( trk, ep, ELEV_NONE, 0, NULL); *leftover = trk1; @@ -478,7 +678,8 @@ static BOOL_T TraverseStraight( traverseTrack_p trvTrk, DIST_T * distR ) } dist = FindDistance( trvTrk->pos, pos[ep] ); if ( dist > *distR ) { - Translate( &trvTrk->pos, pos[ep], NormalizeAngle(trvTrk->angle+180.0), dist-*distR ); + Translate( &trvTrk->pos, pos[ep], NormalizeAngle(trvTrk->angle+180.0), + dist-*distR ); *distR = 0; } else { trvTrk->pos = pos[ep]; @@ -500,7 +701,8 @@ static BOOL_T EnumerateStraight( track_p trk ) return FALSE; } -static BOOL_T TrimStraight( track_p trk, EPINX_T ep, DIST_T dist, coOrd endpos, ANGLE_T angle, DIST_T radius, coOrd center ) +static BOOL_T TrimStraight( track_p trk, EPINX_T ep, DIST_T dist, coOrd endpos, + ANGLE_T angle, DIST_T radius, coOrd center ) { DIST_T d; ANGLE_T a; @@ -510,10 +712,10 @@ static BOOL_T TrimStraight( track_p trk, EPINX_T ep, DIST_T dist, coOrd endpos, p1 = GetTrkEndPos( trk, 1-ep ); d = FindDistance( pos, p1 ); if (dist < FindDistance( GetTrkEndPos(trk,0), GetTrkEndPos(trk,1) ) && - d > minLength ) { - UndrawNewTrack( trk ); - AdjustStraightEndPt( trk, ep, pos ); - DrawNewTrack( trk ); + d > minLength ) { + UndrawNewTrack( trk ); + AdjustStraightEndPt( trk, ep, pos ); + DrawNewTrack( trk ); } else { UndrawNewTrack( trk ); DeleteTrack( trk, TRUE ); @@ -523,10 +725,10 @@ static BOOL_T TrimStraight( track_p trk, EPINX_T ep, DIST_T dist, coOrd endpos, BOOL_T ExtendStraightToJoin( - track_p trk0, - EPINX_T ep0, - track_p trk1, - EPINX_T ep1 ) + track_p trk0, + EPINX_T ep0, + track_p trk1, + EPINX_T ep1 ) { coOrd off; ANGLE_T a; @@ -543,20 +745,23 @@ BOOL_T ExtendStraightToJoin( Rotate( &off, pos0, -a0 ); off.x -= pos0.x; - if ( a >= connectAngle || - !IsClose( fabs(off.x) ) || - off.y-pos0.y <= connectDistance ) { + if ( a >= connectAngle || + !IsClose( fabs(off.x) ) || + off.y-pos0.y <= connectDistance ) { return FALSE; } if ( GetTrkType(trk0) != T_STRAIGHT && - GetTrkType(trk1) != T_STRAIGHT ) { + GetTrkType(trk1) != T_STRAIGHT ) { aa = FindAngle( pos0, pos1 ); aa = NormalizeAngle( aa-a0+connectAngle/2.0); - if (aa > connectAngle) + if (aa > connectAngle) { return FALSE; + } } - UndoStart( _("Extending Straight Track"), "ExtendStraightToJoin( T%d[%d] T%d[%d] )", GetTrkIndex(trk0), ep0, GetTrkIndex(trk1), ep1 ); + UndoStart( _("Extending Straight Track"), + "ExtendStraightToJoin( T%d[%d] T%d[%d] )", GetTrkIndex(trk0), ep0, + GetTrkIndex(trk1), ep1 ); UndoModify( trk0 ); UndoModify( trk1 ); trk2 = trk0x = trk1x = NULL; @@ -622,36 +827,39 @@ static STATUS_T ModifyStraight( track_p trk, wAction_t action, coOrd pos ) switch ( action ) { case C_DOWN: ep = PickUnconnectedEndPoint( pos, trk ); - if (ep == -1) + if (ep == -1) { return C_ERROR; + } UndrawNewTrack( trk ); + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); tempSegs(0).type = SEG_STRTRK; - tempSegs(0).width = 0; + tempSegs(0).lineWidth = 0; tempSegs(0).u.l.pos[0] = GetTrkEndPos( trk, 1-ep ); - tempSegs_da.cnt = 1; InfoMessage( _("Drag to change track length") ); case C_MOVE: d = FindDistance( tempSegs(0).u.l.pos[0], pos ); valid = TRUE; if ( d <= minLength ) { - if (action == C_MOVE) + if (action == C_MOVE) { ErrorMessage( MSG_TRK_TOO_SHORT, _("Straight "), PutDim(fabs(minLength-d)) ); + } valid = FALSE; return C_CONTINUE; } - Translate( &tempSegs(0).u.l.pos[1], tempSegs(0).u.l.pos[0], GetTrkEndAngle( trk, ep ), d ); - tempSegs_da.cnt = 1; + Translate( &tempSegs(0).u.l.pos[1], tempSegs(0).u.l.pos[0], GetTrkEndAngle( trk, + ep ), d ); if (action == C_MOVE) InfoMessage( _("Straight: Length=%s Angle=%0.3f"), - FormatDistance( d ), PutAngle( GetTrkEndAngle( trk, ep ) ) ); + FormatDistance( d ), PutAngle( GetTrkEndAngle( trk, ep ) ) ); return C_CONTINUE; case C_UP: - if (valid) + if (valid) { AdjustStraightEndPt( trk, ep, tempSegs(0).u.l.pos[1] ); - tempSegs_da.cnt = 0; - DrawNewTrack( trk ); + } + DYNARR_RESET( trkSeg_t, tempSegs_da ); + DrawNewTrack( trk ); return C_TERMINATE; default: @@ -667,19 +875,22 @@ static DIST_T GetLengthStraight( track_p trk ) } -static BOOL_T GetParamsStraight( int inx, track_p trk, coOrd pos, trackParams_t * params ) +static BOOL_T GetParamsStraight( int inx, track_p trk, coOrd pos, + trackParams_t * params ) { params->type = curveTypeStraight; - if ( inx == PARAMS_NODES ) return FALSE; - if ((inx == PARAMS_CORNU) || (inx == PARAMS_1ST_JOIN) || (inx == PARAMS_2ND_JOIN) ){ + if ( inx == PARAMS_NODES ) { return FALSE; } + if ((inx == PARAMS_CORNU) || (inx == PARAMS_1ST_JOIN) + || (inx == PARAMS_2ND_JOIN) ) { params->ep = PickEndPoint( pos, trk); params->arcP = zero; params->arcR = 0.0; } else { params->ep = PickUnconnectedEndPointSilent( pos, trk ); } - if (params->ep == -1) - return FALSE; + if (params->ep == -1) { + return FALSE; + } params->lineOrig = GetTrkEndPos(trk,1-params->ep); params->lineEnd = GetTrkEndPos(trk,params->ep); params->len = FindDistance( params->lineOrig, params->lineEnd ); @@ -690,12 +901,13 @@ static BOOL_T GetParamsStraight( int inx, track_p trk, coOrd pos, trackParams_t } -static BOOL_T MoveEndPtStraight( track_p *trk, EPINX_T *ep, coOrd pos, DIST_T d0 ) +static BOOL_T MoveEndPtStraight( track_p *trk, EPINX_T *ep, coOrd pos, + DIST_T d0 ) { if ( NormalizeAngle( FindAngle( GetTrkEndPos(*trk,1-*ep), pos ) - - GetTrkEndAngle(*trk,*ep) + 0.5 ) > 1.0 ) { - ErrorMessage( MSG_MOVED_BEYOND_END_TRK ); - return FALSE; + GetTrkEndAngle(*trk,*ep) + 0.5 ) > 1.0 ) { + ErrorMessage( MSG_MOVED_BEYOND_END_TRK ); + return FALSE; } Translate( &pos, pos, GetTrkEndAngle(*trk,*ep)+180, d0 ); AdjustStraightEndPt( *trk, *ep, pos ); @@ -722,39 +934,41 @@ static BOOL_T QueryStraight( track_p trk, int query ) static void FlipStraight( - track_p trk, - coOrd orig, - ANGLE_T angle ) + track_p trk, + coOrd orig, + ANGLE_T angle ) { ComputeBoundingBox( trk ); } static BOOL_T MakeParallelStraight( - track_p trk, - coOrd pos, - DIST_T sep, - DIST_T factor, - track_p * newTrkR, - coOrd * p0R, - coOrd * p1R, - BOOL_T track) + track_p trk, + coOrd pos, + DIST_T sep, + DIST_T factor, + track_p * newTrkR, + coOrd * p0R, + coOrd * p1R, + BOOL_T track) { ANGLE_T angle = GetTrkEndAngle(trk,1); coOrd p0, p1; - if ( NormalizeAngle( FindAngle( GetTrkEndPos(trk,0), pos ) - GetTrkEndAngle(trk,1) ) < 180.0 ) + if ( NormalizeAngle( FindAngle( GetTrkEndPos(trk,0), pos ) - GetTrkEndAngle(trk, + 1) ) < 180.0 ) { angle += 90; - else + } else { angle -= 90; + } Translate( &p0, GetTrkEndPos(trk,0), angle, sep ); Translate( &p1, GetTrkEndPos(trk,1), angle, sep ); if ( newTrkR ) { - if (track) + if (track) { *newTrkR = NewStraightTrack( p0, p1 ); - else { + } else { + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); tempSegs(0).color = wDrawColorBlack; - tempSegs(0).width = 0; - tempSegs_da.cnt = 1; + tempSegs(0).lineWidth = 0; tempSegs(0).type = SEG_STRLIN; tempSegs(0).u.l.pos[0] = p0; tempSegs(0).u.l.pos[1] = p1; @@ -763,15 +977,15 @@ static BOOL_T MakeParallelStraight( } } else { + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); tempSegs(0).color = wDrawColorBlack; - tempSegs(0).width = 0; - tempSegs_da.cnt = 1; + tempSegs(0).lineWidth = 0; tempSegs(0).type = track?SEG_STRTRK:SEG_STRLIN; tempSegs(0).u.l.pos[0] = p0; tempSegs(0).u.l.pos[1] = p1; } - if ( p0R ) *p0R = p0; - if ( p1R ) *p1R = p1; + if ( p0R ) { *p0R = p0; } + if ( p1R ) { *p1R = p1; } return TRUE; } @@ -783,46 +997,47 @@ static wBool_t CompareStraight( track_cp trk1, track_cp trk2 ) static trackCmd_t straightCmds = { - "STRAIGHT", - DrawStraight, - DistanceStraight, - DescribeStraight, - DeleteStraight, - WriteStraight, - ReadStraight, - MoveStraight, - RotateStraight, - RescaleStraight, - AuditStraight, - GetAngleStraight, - SplitStraight, - TraverseStraight, - EnumerateStraight, - NULL, /* redraw */ - TrimStraight, - ExtendStraightToJoin, - ModifyStraight, - GetLengthStraight, - GetParamsStraight, - MoveEndPtStraight, - QueryStraight, - NULL, /* ungroup */ - FlipStraight, - NULL, - NULL, - NULL, - MakeParallelStraight, - NULL, - NULL, - NULL, - NULL, - NULL, - CompareStraight }; + "STRAIGHT", + DrawStraight, + DistanceStraight, + DescribeStraight, + DeleteStraight, + WriteStraight, + ReadStraight, + MoveStraight, + RotateStraight, + RescaleStraight, + AuditStraight, + GetAngleStraight, + SplitStraight, + TraverseStraight, + EnumerateStraight, + NULL, /* redraw */ + TrimStraight, + ExtendStraightToJoin, + ModifyStraight, + GetLengthStraight, + GetParamsStraight, + MoveEndPtStraight, + QueryStraight, + NULL, /* ungroup */ + FlipStraight, + NULL, + NULL, + NULL, + MakeParallelStraight, + NULL, + NULL, + NULL, + NULL, + NULL, + CompareStraight +}; EXPORT void StraightSegProc( - segProc_e cmd, - trkSeg_p segPtr, - segProcData_p data ) + segProc_e cmd, + trkSeg_p segPtr, + segProcData_p data ) { ANGLE_T a0, a1, a2; DIST_T d, d0, d1; @@ -834,7 +1049,8 @@ EXPORT void StraightSegProc( a1 = FindAngle( segPtr->u.l.pos[0], segPtr->u.l.pos[1] ); a2 = NormalizeAngle( a1-data->traverse1.angle ); data->traverse1.backwards = ((a2 < 270) && (a2 > 90)); - data->traverse1.dist = FindDistance( segPtr->u.l.pos[data->traverse1.backwards?1:0], data->traverse1.pos ); + data->traverse1.dist = FindDistance( segPtr->u.l.pos[data->traverse1.backwards + ?1:0], data->traverse1.pos ); data->traverse1.reverse_seg = FALSE; data->traverse1.negative = FALSE; data->traverse1.segs_backwards = FALSE; @@ -844,13 +1060,17 @@ EXPORT void StraightSegProc( case SEGPROC_TRAVERSE2: d = FindDistance( segPtr->u.l.pos[0], segPtr->u.l.pos[1] ); if ( d >= data->traverse2.dist ) { - a1 = FindAngle( segPtr->u.l.pos[data->traverse2.segDir], segPtr->u.l.pos[1-data->traverse2.segDir] ); - Translate( &data->traverse2.pos, segPtr->u.l.pos[data->traverse2.segDir], a1, data->traverse2.dist ); + a1 = FindAngle( segPtr->u.l.pos[data->traverse2.segDir], + segPtr->u.l.pos[1-data->traverse2.segDir] ); + Translate( &data->traverse2.pos, segPtr->u.l.pos[data->traverse2.segDir], a1, + data->traverse2.dist ); data->traverse2.dist = 0; data->traverse2.angle = a1; } else { - a1 = FindAngle( segPtr->u.l.pos[data->traverse2.segDir], segPtr->u.l.pos[1-data->traverse2.segDir] ); - Translate( &data->traverse2.pos, segPtr->u.l.pos[data->traverse2.segDir], a1, d ); + a1 = FindAngle( segPtr->u.l.pos[data->traverse2.segDir], + segPtr->u.l.pos[1-data->traverse2.segDir] ); + Translate( &data->traverse2.pos, segPtr->u.l.pos[data->traverse2.segDir], a1, + d ); data->traverse2.dist -= d; data->traverse2.angle = a1; } @@ -861,17 +1081,21 @@ EXPORT void StraightSegProc( a0 = FindAngle( segPtr->u.l.pos[0], segPtr->u.l.pos[1] ); d1 = d0*data->drawRoadbedSide.first/32.0; Translate( &p0, segPtr->u.l.pos[0], a0, d1 ); - Translate( &p0, p0, a0+data->drawRoadbedSide.side, data->drawRoadbedSide.roadbedWidth/2.0 ); + Translate( &p0, p0, a0+data->drawRoadbedSide.side, + data->drawRoadbedSide.roadbedWidth/2.0 ); d1 = d0*data->drawRoadbedSide.last/32.0; Translate( &p1, segPtr->u.l.pos[0], a0, d1 ); - Translate( &p1, p1, a0+data->drawRoadbedSide.side, data->drawRoadbedSide.roadbedWidth/2.0 ); + Translate( &p1, p1, a0+data->drawRoadbedSide.side, + data->drawRoadbedSide.roadbedWidth/2.0 ); REORIGIN1( p0, data->drawRoadbedSide.angle, data->drawRoadbedSide.orig ); REORIGIN1( p1, data->drawRoadbedSide.angle, data->drawRoadbedSide.orig ); - DrawLine( data->drawRoadbedSide.d, p0, p1, data->drawRoadbedSide.rbw, data->drawRoadbedSide.color ); + DrawLine( data->drawRoadbedSide.d, p0, p1, data->drawRoadbedSide.rbw, + data->drawRoadbedSide.color ); break; case SEGPROC_DISTANCE: - data->distance.dd = LineDistance( &data->distance.pos1, segPtr->u.l.pos[0], segPtr->u.l.pos[1] ); + data->distance.dd = LineDistance( &data->distance.pos1, segPtr->u.l.pos[0], + segPtr->u.l.pos[1] ); break; case SEGPROC_FLIP: @@ -899,7 +1123,8 @@ EXPORT void StraightSegProc( data->split.length[0] = d; data->split.length[1] = 0.0; } - Translate( &p0, segPtr->u.l.pos[0], FindAngle( segPtr->u.l.pos[0], segPtr->u.l.pos[1] ), data->split.length[0] ); + Translate( &p0, segPtr->u.l.pos[0], FindAngle( segPtr->u.l.pos[0], + segPtr->u.l.pos[1] ), data->split.length[0] ); data->split.newSeg[0] = *segPtr; data->split.newSeg[1] = *segPtr; data->split.newSeg[0].u.l.pos[1] = data->split.newSeg[1].u.l.pos[0] = p0; @@ -929,7 +1154,7 @@ track_p NewStraightTrack( coOrd p0, coOrd p1 ) track_p t; ANGLE_T a; t = NewTrack( 0, T_STRAIGHT, 2, sizeof (struct extraDataStraight_t) ); - SetTrkScale( t, GetLayoutCurScale() ); + // *new-layer* SetTrkScale( t, GetLayoutCurScale() ); a = FindAngle( p1, p0 ); SetTrkEndPoint( t, 0, p0, a ); SetTrkEndPoint( t, 1, p1, NormalizeAngle( a+180.0 ) ); diff --git a/app/bin/turnout.c b/app/bin/turnout.c new file mode 100644 index 0000000..57c398b --- /dev/null +++ b/app/bin/turnout.c @@ -0,0 +1,2157 @@ +/** \file turnout.c + * Turnout drawing + */ + +/* XTrkCad - Model Railroad CAD + * Copyright (C) 2005 Dave Bullis + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "common.h" +#include "common-ui.h" +#include "compound.h" +#include "custom.h" +#include "draw.h" +#include "track.h" + +/* Draw turnout data */ + +/** + * The types of turnouts that get enhanced drawing methods + */ +enum dtoType { + DTO_INVALID, + DTO_NORMAL, + DTO_THREE, + DTO_WYE, + + DTO_CURVED, + + DTO_XING, + DTO_XNG9, + DTO_SSLIP, + DTO_DSLIP, + + DTO_LCROSS, + DTO_RCROSS, + DTO_DCROSS +}; + +// Define to plot control points (DTO_NORMAL, DTO_CURVED, DTO_XING, DTO_LCROSS) +// #define DTO_DEBUG DTO_XING + +#define DTO_DIM 4 // Maximum number of paths +#define DTO_SEGS 24 // Maximum number of control points + +static struct DrawToData_t { + TRKINX_T index; + enum dtoType toType; + track_p trk; + tieData_t td; + int bridge; + int roadbed; + int endCnt; + int pathCnt; + int routeCnt; + int strCnt; + int crvCnt; + int rgtCnt; + int lftCnt; + int strPath; + int str2Path; + int crvPath; + int crv2Path; + int origCnt; + int origins[DTO_DIM]; + coOrd midPt; + struct extraDataCompound_t* xx; +} dtod; + +struct DrawTo_t { + int n; + trkSeg_p trkSeg[DTO_SEGS]; + coOrd base[DTO_SEGS]; + coOrd baseLast; + DIST_T dy[DTO_SEGS]; + ANGLE_T angle; + ANGLE_T crvAngle; + coOrd pts[DTO_SEGS]; + coOrd ptsLast; + char type; +}; + +static struct DrawTo_t dto[DTO_DIM]; + + + +/**************************************** + * + * Draw Turnout Roadbed + * + */ + +int roadbedOnScreen = 0; + + +void DrawTurnoutRoadbedSide(drawCmd_p d, wDrawColor color, coOrd orig, + ANGLE_T angle, trkSeg_p sp, ANGLE_T side, int first, int last) +{ + segProcData_t data; + if (last <= first) { + return; + } + data.drawRoadbedSide.first = first; + data.drawRoadbedSide.last = last; + data.drawRoadbedSide.side = side; + data.drawRoadbedSide.roadbedWidth = roadbedWidth; + data.drawRoadbedSide.rbw = (wDrawWidth)floor(roadbedLineWidth * + (d->dpi / d->scale) + 0.5); + data.drawRoadbedSide.orig = orig; + data.drawRoadbedSide.angle = angle; + data.drawRoadbedSide.color = color; + data.drawRoadbedSide.d = d; + SegProc(SEGPROC_DRAWROADBEDSIDE, sp, &data); +} + + +static void ComputeAndDrawTurnoutRoadbedSide( + drawCmd_p d, + wDrawColor color, + coOrd orig, + ANGLE_T angle, + trkSeg_p segPtr, + int segCnt, + int segInx, + ANGLE_T side) +{ + unsigned long res, res1; + int b0, b1; + res = ComputeTurnoutRoadbedSide(segPtr, segCnt, segInx, side, roadbedWidth); + if (res == 0L) { + } else if (res == 0xFFFFFFFF) { + DrawTurnoutRoadbedSide(d, color, orig, angle, &segPtr[segInx], side, 0, 32); + } else { + for (b0 = 0, res1 = 0x00000001; res1 && (res1 & res); b0++, res1 <<= 1); + for (b1 = 32, res1 = 0x80000000; res1 && (res1 & res); b1--, res1 >>= 1); + DrawTurnoutRoadbedSide(d, color, orig, angle, &segPtr[segInx], side, 0, b0); + DrawTurnoutRoadbedSide(d, color, orig, angle, &segPtr[segInx], side, b1, 32); + } +} + + +static void DrawTurnoutRoadbed( + drawCmd_p d, + wDrawColor color, + coOrd orig, + ANGLE_T angle, + trkSeg_p segPtr, + int segCnt) +{ + int inx, trkCnt = 0, segInx = 0; + for (inx = 0; inx < segCnt; inx++) { + if (IsSegTrack(&segPtr[inx])) { + segInx = inx; + trkCnt++; + if (trkCnt > 1) { + break; + } + } + } + if (trkCnt == 0) { + return; + } + if (trkCnt == 1) { + DrawTurnoutRoadbedSide(d, color, orig, angle, &segPtr[segInx], +90, 0, 32); + DrawTurnoutRoadbedSide(d, color, orig, angle, &segPtr[segInx], -90, 0, 32); + } else { + for (inx = 0; inx < segCnt; inx++) { + if (IsSegTrack(&segPtr[inx])) { + ComputeAndDrawTurnoutRoadbedSide(d, color, orig, angle, segPtr, segCnt, inx, + +90); + ComputeAndDrawTurnoutRoadbedSide(d, color, orig, angle, segPtr, segCnt, inx, + -90); + } + } + } +} + + +/**************************************** + * + * TURNOUT DRAWING + * + */ + +/** +* Get the paths from the turnout definition. Puts the results into static dto structure. +* Curved segments are broken up into short sections of the lesser of 5 degrees or 5 * tie spacing. +* +* \param trk track_p pointer to a track +* \param xx pointer to the extraDataCompound struct +* +* \returns the number of paths +*/ +int GetTurnoutPaths(track_p trk, struct extraDataCompound_t* xx) +{ + wIndex_t segInx; + wIndex_t segEP; + + int i; + ANGLE_T a0, a1, aa0, aa1; + DIST_T r, len; + coOrd p0, p1; + + PATHPTR_T pp; + + dtod.trk = trk; + dtod.index = GetTrkIndex( trk ); + dtod.xx = xx; + + dtod.td = GetTrkTieData( trk ); + + int pathCnt = 0, routeCnt = 0; + + for (i = 0; i < DTO_DIM; i++) { + dto[i].n = 0; + } + + // Validate that the first segment starts at (0, 0) + // and if STR p1.y == 0, if CRV angle == 0 or angle == 180 + GetSegInxEP(1, &segInx, &segEP); + trkSeg_p segPtr = &xx->segs[segInx]; + switch (segPtr->type) { + case SEG_STRTRK: + p0 = segPtr->u.l.pos[0]; + p1 = segPtr->u.l.pos[1]; + if ((FindDistance(p0, zero) > EPSILON) || (fabs(p1.y) > EPSILON)) { + return -1; + } + break; + case SEG_CRVTRK: + r = fabs(segPtr->u.c.radius); + a0 = segPtr->u.c.a0; + a1 = segPtr->u.c.a1; + + if (segPtr->u.c.radius > 0) { + aa0 = a0; + } else { + aa0 = a0 + a1; + } + PointOnCircle(&p0, segPtr->u.c.center, r, aa0); + if ((FindDistance(p0, zero) > EPSILON) + || ((fabs(aa0 - 180) > EPSILON) && (fabs(aa0) > EPSILON))) { + return -1; + } + break; + } + + pp = GetPaths(trk); + while (pp[0]) { + pp += strlen((char*)pp) + 1; + + ANGLE_T angle = 0; + while (pp[0]) { + if (pathCnt < DTO_DIM) { + dto[pathCnt].type = 'S'; + while (pp[0]) { + GetSegInxEP(pp[0], &segInx, &segEP); + // trkSeg_p + segPtr = &xx->segs[segInx]; + switch (segPtr->type) { + case SEG_STRTRK: + p0 = segPtr->u.l.pos[0]; + p1 = segPtr->u.l.pos[1]; + + wIndex_t n = dto[pathCnt].n; + dto[pathCnt].trkSeg[n] = segPtr; + dto[pathCnt].base[n] = p0; + n++; + dto[pathCnt].trkSeg[n] = segPtr; + dto[pathCnt].base[n] = p1; + // n++; + dto[pathCnt].n = n; + + if (n >= DTO_SEGS - 1) { return -1; } + + break; + case SEG_CRVTRK: + r = fabs(segPtr->u.c.radius); + + dto[pathCnt].type = segPtr->u.c.center.y < 0 ? 'R' : 'L'; + + a0 = segPtr->u.c.a0; + a1 = segPtr->u.c.a1; + + angle += a1; + + len = D2R(a1) * r; + // Every 5 degrees or 5 * tie spacing + int cnt = (int)floor(a1 / 5.0); + int cnt2 = (int)floor(len / 5 / dtod.td.spacing); + if (cnt2 > cnt) { cnt = cnt2; } + if (cnt <= 0) { cnt = 1; } + + aa1 = a1 / cnt; + if (dto[pathCnt].type == 'R') { + aa0 = a0; + } else { + aa0 = a0 + a1; + aa1 = -aa1; + } + PointOnCircle(&p0, segPtr->u.c.center, r, aa0); + n = dto[pathCnt].n; + dto[pathCnt].trkSeg[n] = segPtr; + dto[pathCnt].base[n] = p0; + n++; + dto[pathCnt].n = n; + + while (cnt > 0) { + aa0 += aa1; + PointOnCircle(&p0, segPtr->u.c.center, r, aa0); + + // n = dto[pathCnt].n; + dto[pathCnt].trkSeg[n] = segPtr; + dto[pathCnt].base[n] = p0; + n++; + + if (n >= DTO_SEGS - 1) { return -1; } + + cnt--; + } + n--; // remove that last point count + dto[pathCnt].n = n; + } + pp++; + } + // Include the last point + dto[pathCnt].crvAngle = angle; + dto[pathCnt].n++; + } + + pathCnt++; + if (pathCnt > DTO_DIM) { return -1; } + pp++; + } + routeCnt++; + pp++; + } + dtod.pathCnt = pathCnt; + dtod.routeCnt = routeCnt; + dtod.endCnt = GetTrkEndPtCnt( trk ); + + // Guard value: n < DTO_SEGS - 2 + for (i = 0; i < pathCnt; i++) { + dto[i].pts[dto[i].n].x = DIST_INF; + } + + return pathCnt; +} + +/** +* Sets the turnout type if compatible with enhanced drawing methods. The data is +* from the path data saved in dtod and dto by GetTurnoutPaths. The turnout type is +* stored in the dtod.toType. DTO_INVALID (0) if the enhanced methods cannot handle +* it. +*/ +void GetTurnoutType() +{ + dtod.strPath = -1; + dtod.str2Path = -1; + dtod.crvPath = -1; + dtod.crv2Path = -1; + + dtod.toType = DTO_INVALID; + + int strCnt = 0, crvCnt = 0, lftCnt = 0, rgtCnt = 0; +// enum dtoType toType = DTO_INVALID; + int i, j; + + // Count path origins + dtod.origCnt = 1; + dtod.origins[0] = 0; + + for (i = 1; i < dtod.pathCnt; i++) { + int eq = 0; + for (j = 0; j < i; j++) { + if (CoOrdEqual(dto[dtod.origins[j]].base[0], dto[i].base[0])) { + eq++; + break; + } + } + if (eq == 0) { + if (dtod.origCnt < DTO_DIM) { + dtod.origins[dtod.origCnt] = i; + } + dtod.origCnt++; + } + + if (dtod.origCnt >= DTO_DIM) { + return; + } + } + + // Determine the path type + for (i = 0; i < dtod.pathCnt; i++) { + switch (dto[i].type) { + case 'S': + strCnt++; + if (strCnt == 1) { + dtod.strPath = i; + } else { + dtod.str2Path = i; + } + break; + case 'L': + lftCnt++; + crvCnt++; + if (crvCnt == 1) { + dtod.crvPath = i; + } else { + dtod.crv2Path = i; + } + break; + case 'R': + rgtCnt++; + crvCnt++; + if (crvCnt == 1) { + dtod.crvPath = i; + } else { + dtod.crv2Path = i; + } + break; + } + } + + dtod.strCnt = strCnt; + dtod.crvCnt = crvCnt; + dtod.lftCnt = lftCnt; + dtod.rgtCnt = rgtCnt; + + // Normal two- or three-way turnout, or a curved turnout + if (dtod.origCnt == 1) { + if (dtod.pathCnt == 2) { + if (strCnt == 1 && crvCnt == 1) { + dtod.toType = DTO_NORMAL; + } else if ((strCnt == 0) && ((lftCnt == 2) || (rgtCnt == 2))) { + // Assumes outer curve is [0] and inner is [1] + if ((dto[0].crvAngle <= 20) && (dto[1].crvAngle - dto[0].crvAngle <= 15)) { + dtod.toType = DTO_CURVED; + } + } else if (lftCnt == 1 && rgtCnt == 1) { + dtod.toType = DTO_WYE; + } + } else if ((dtod.pathCnt == 3) && (strCnt == 1) + && (lftCnt == 1) && (rgtCnt == 1)) { + dtod.toType = DTO_THREE; + } + } else + // Crossing, single- and double-slip + if ((dtod.origCnt == 2) && (dtod.endCnt == 4) + && strCnt == 2) { + + ANGLE_T a0, a1, a2; + a1 = FindAngle(dto[dtod.strPath].base[0], dto[dtod.strPath].base[1]); + a2 = FindAngle(dto[dtod.str2Path].base[0], dto[dtod.str2Path].base[1]); + // Swap the ends of the strPath if large angle + if((a1 > 180.0) && (dto[dtod.strPath].n == 2)) { + coOrd tmp = dto[dtod.strPath].base[0]; + dto[dtod.strPath].base[0] = dto[dtod.strPath].base[1]; + dto[dtod.strPath].base[1] = tmp; + + i = dto[dtod.strPath].n - 1; + tmp = dto[dtod.strPath].pts[0]; + dto[dtod.strPath].pts[0] = dto[dtod.strPath].pts[i]; + dto[dtod.strPath].pts[i] = tmp; + + a1 = a1 - 180.0; + dto[dtod.strPath].angle = a1; + } + // Swap the ends of the str2Path if large angle + if((a2 > 180.0) && (dto[dtod.str2Path].n == 2)) { + coOrd tmp = dto[dtod.str2Path].base[0]; + dto[dtod.str2Path].base[0] = dto[dtod.str2Path].base[1]; + dto[dtod.str2Path].base[1] = tmp; + + i = dto[dtod.str2Path].n - 1; + tmp = dto[dtod.str2Path].pts[0]; + dto[dtod.str2Path].pts[0] = dto[dtod.str2Path].pts[i]; + dto[dtod.str2Path].pts[i] = tmp; + + a2 = a2 - 180.0; + dto[dtod.str2Path].angle = a2; + } + a0 = DifferenceBetweenAngles(a1, a2); + if(a0 < 0) { + int tmp = dtod.strPath; + dtod.strPath = dtod.str2Path; + dtod.str2Path = tmp; + a0 = NormalizeAngle(-a0); + } + if ((a0 > 90.0) || (a0 < 0.0)) { + return; + } + + coOrd p1 = dto[dtod.strPath].base[0]; + coOrd p2 = dto[dtod.str2Path].base[0]; + coOrd pos = zero; + int intersect = FindIntersection(&pos, p1, a1, p2, a2); + + if (intersect) { + if(strCnt == 2 && dtod.pathCnt == 2) { + if((a0 <= 61) && (a0 >= -61)) { + dtod.toType = DTO_XING; + } else { + dtod.toType = DTO_XNG9; + } + } else if(dtod.pathCnt == 3 && (lftCnt == 1 || rgtCnt == 1)) { + dtod.toType = DTO_SSLIP; + } else if(dtod.pathCnt == 4 && lftCnt == 1 && rgtCnt == 1) { + dtod.toType = DTO_DSLIP; + } + } + // No intersect, it could be a crossover + else if (strCnt == 2) { + if (dtod.pathCnt == 4 && lftCnt == 1 && rgtCnt == 1) { + dtod.toType = DTO_DCROSS; + } else if(dtod.pathCnt == 3) { + // Perverse test because the cross paths go Left then Right, for example + if(lftCnt == 1) { + dtod.toType = DTO_RCROSS; + } else if(rgtCnt == 1) { + dtod.toType = DTO_LCROSS; + } else { + dtod.toType = DTO_INVALID; + } + } + } + } +} + +#if 0 +/** + * Draw Layout lines and points + * + * \param d The drawing object + * \param scaleInx The layout/track scale index + */ +static void DrawDtoLayout( + drawCmd_p d, + SCALEINX_T scaleInx +) +{ +#ifdef DTO_DEBUG + // Draw the points and lines from dto + double r = dtod.td->width / 2; + // if (r < 1) r = 1; + + int i, j; + for (i = 0; i < DTO_DIM; i++) { + for (j = 0; j < dto[i].n; j++) { + DrawFillCircle(d, dto[i].pts[j], r, drawColorPurple); + if (j < dto[i].n - 1) { + DrawLine(d, dto[i].pts[j], dto[i].pts[j + 1], 0, drawColorPurple); + } + } + } +#endif +} +#endif + +/** +* Use the coOrds to build a polygon and draw the bridge fill. Note that the coordinates are +* passed as pairs, and rearranged into a polygon with the 1,2,4,3 order. +* +* \param d The drawing object +* \param c The color +* \param b1 The first coordinate +* \param b2 The second coordinate +* \param b3 The third coordinate +* \param b4 The fourth coordinate +*/ +static void DrawFill( + drawCmd_p d, + wDrawColor c, + coOrd b1, + coOrd b2, + coOrd b3, + coOrd b4 +) +{ + coOrd p[4] = {b1, b2, b4, b3}; + DrawPoly(d,4,p,NULL,c,0,DRAW_FILL ); +} + +/** +* Draw Bridge parapets and background or Roadbed for a turnout +* +* \param d The drawing object +* \param fillType 0 for bridge, 1 for roadbed +* \param path1 The first path +* \param path2 The second path +*/ +static void DrawTurnoutFill( + drawCmd_p d, + int fillType, + int path1, + int path2 +) +{ + DIST_T trackGauge = GetTrkGauge(dtod.trk); + wDrawWidth width2 = (wDrawWidth)round((2.0 * d->dpi) / BASE_DPI); + if (d->options&DC_PRINT) { + width2 = (wDrawWidth)round(d->dpi / BASE_DPI); + } + + wDrawColor color = (fillType==0?bridgeColor:roadbedColor); + double fillWidth = 1.5; + coOrd b1,b2,b3,b4,b5,b6; + ANGLE_T angle = dtod.xx->angle,a = 0.0; + int i,j,i1,i2; + i1 = path1; + i2 = path2; + if(dto[i1].base[dto[i1].n - 1].y < dto[i2].base[dto[i2].n - 1].y) { + i1 = path2; + i2 = path1; + // a = -a; + } + + if(dtod.toType == DTO_THREE) { + i = dtod.strPath; + DIST_T dy = fabs(dto[i].dy[0]) + trackGauge * fillWidth; + b1 = dto[i].pts[0]; + Translate(&b3,b1,(angle + a),dy); + b1 = dto[i].pts[dto[i].n - 1]; + Translate(&b4,b1,(angle + a),dy); + b2 = dto[i].pts[0]; + Translate(&b5,b2,(angle + a),-dy); + b2 = dto[i].pts[dto[i].n - 1]; + Translate(&b6,b2,(angle + a),-dy); + + // Draw the background + DrawFill(d,color,b3,b4,b5,b6); + } + + for(i = i1; 1; i = i2,a = 180.0) { + DIST_T dy = fabs(dto[i].dy[0]) + trackGauge * fillWidth; + b1 = dto[i].pts[0]; + Translate(&b3,b1,(angle + a),dy); + Translate(&b5,b1,(angle + a),-(dy * 0.75)); + for(j = 1; j < dto[i].n; j++) { + dy = fabs(dto[i].dy[j]) + trackGauge * fillWidth; + b2 = dto[i].pts[j]; + Translate(&b4,b2,(angle + a),dy); + Translate(&b6,b2,(angle + a),-(dy * 0.75)); + + // Draw the background + DrawFill(d,color,b3,b4,b5,b6); + + // Draw the bridge edge + if(fillType==0) { + DrawLine( d,b3,b4,width2,drawColorBlack ); + } + + b1 = b2; + b3 = b4; + b5 = b6; + } + + if(i == i2) { + break; + } + } + + EPINX_T ep; + coOrd p; + track_p trk1; + coOrd p0,p1; + + // Bridge parapet ends + if(fillType==0) { + for(ep = 0; ep < 3; ep++) { + trk1 = GetTrkEndTrk(dtod.trk,ep); + + if((trk1) && (!GetTrkBridge(trk1))) { + + p = GetTrkEndPos(dtod.trk,ep); + a = GetTrkEndAngle(dtod.trk,ep) + 90.0; + + int i = (dtod.lftCnt > 0) && (dtod.rgtCnt == 0) ? 2 : 1; + if(ep != i) { + Translate(&p0,p,a,trackGauge * 1.5); + Translate(&p1,p0,a - 45.0,trackGauge * 1.5); + DrawLine(d,p0,p1,width2,drawColorBlack); + } + if(ep != (3 - i)) { + Translate(&p0,p,a,-trackGauge * 1.5); + Translate(&p1,p0,a + 45.0,-trackGauge * 1.5); + DrawLine(d,p0,p1,width2,drawColorBlack); + } + } + } + } +} + +/** +* Draw Bridge parapets and background or Roadbed for a cross-over +* +* \param d The drawing object +* \param fillType 0 for bridge, 1 for roadbed +* \param path1 The first path, straight +* \param path2 The second path, straight +*/ +static void DrawCrossFill( + drawCmd_p d, + int fillType, + int path1, + int path2 +) +{ + DIST_T trackGauge = GetTrkGauge(dtod.trk); + wDrawWidth width2 = (wDrawWidth)round((2.0 * d->dpi)/BASE_DPI); + if (d->options&DC_PRINT) { + width2 = (wDrawWidth)round(d->dpi / BASE_DPI); + } + + wDrawColor color = (fillType==0?bridgeColor:roadbedColor); + double fillWidth = 1.5; + coOrd b1, b2, b3, b4, b5, b6; + ANGLE_T angle = dtod.xx->angle, a = 0.0; + int i1, i2; + i1 = path1; + i2 = path2; + if(dto[i1].base[dto[i1].n - 1].y < dto[i2].base[dto[i2].n - 1].y) { + i1 = path2; + i2 = path1; + // a = -a; + } + + DIST_T dy = fabs(dto[i1].dy[0]) + trackGauge * fillWidth; + b1 = dto[i1].pts[0]; + Translate(&b3,b1,(angle + a),dy); + b1 = dto[i1].pts[dto[i1].n-1]; + Translate(&b4,b1,(angle + a),dy); + b2 = dto[i2].pts[0]; + Translate(&b5,b2,(angle + a),-dy); + b2 = dto[i2].pts[dto[i2].n-1]; + Translate(&b6,b2,(angle + a),-dy); + + // Draw the background + DrawFill(d, color, b3, b4, b5, b6); + + // Draw the bridge edges + if(fillType == 0) { + DrawLine(d,b3,b4,width2,drawColorBlack); + DrawLine(d,b5,b6,width2,drawColorBlack); + } + + EPINX_T ep; + coOrd p; + track_p trk1; + coOrd p0,p1; + + // Bridge parapet ends + if(fillType==0) { + for(ep = 0; ep < 4; ep++) { + trk1 = GetTrkEndTrk(dtod.trk,ep); + + if((trk1) && (!GetTrkBridge(trk1))) { + p = GetTrkEndPos(dtod.trk,ep); + a = GetTrkEndAngle(dtod.trk,ep) + 90.0; + + if((ep == 1) || (ep == 2)) { + Translate(&p0,p,a,trackGauge * 1.5); + Translate(&p1,p0,a - 45.0,trackGauge * 1.5); + DrawLine(d,p0,p1,width2,drawColorBlack); + } + if((ep == 0) || (ep == 3)) { + Translate(&p0,p,a,-trackGauge * 1.5); + Translate(&p1,p0,a + 45.0,-trackGauge * 1.5); + DrawLine(d,p0,p1,width2,drawColorBlack); + } + } + } + } +} + +/** +* Draw Bridge parapets and background or Roadbed for a crossing +* +* \param d The drawing object +* \param fillType 0 for bridge, 1 for roadbed +* \param path1 The first path +* \param path2 The second path +*/ +static void DrawXingFill( + drawCmd_p d, + int fillType, + int path1, + int path2 +) +{ + DIST_T trackGauge = GetTrkGauge(dtod.trk); + wDrawWidth width2 = (wDrawWidth)round((2.0 * d->dpi)/BASE_DPI); + if (d->options&DC_PRINT) { + width2 = (wDrawWidth)round(d->dpi / BASE_DPI); + } + + double fillWidth = 1.5; + coOrd b0, b1, b2, b3, b4, b5, b6; + int i, j, i1, i2; + i1 = dtod.strPath; + i2 = dtod.str2Path; + + // Fill both straight sections + wDrawWidth width3 = (wDrawWidth)round(trackGauge * 2 * fillWidth * d->dpi / + d->scale); + wDrawColor color = (fillType==0?bridgeColor:roadbedColor); + b1 = dto[i1].pts[0]; + b2 = dto[i1].pts[dto[i1].n-1]; + DrawLine(d,b1,b2,width3,color); + b1 = dto[i2].pts[0]; + b2 = dto[i2].pts[dto[i1].n-1]; + DrawLine(d,b1,b2,width3,color); + + i1 = path1; + i2 = path2; + if(dto[i1].base[dto[i1].n - 1].y < dto[i2].base[dto[i2].n - 1].y) { + i1 = path2; + i2 = path1; + } + + // Handle curved sections for slips + BOOL_T hasLeft = 0, hasRgt = 0; + ANGLE_T angle = dtod.xx->angle, a = 0.0; + for(i = i1; 1; i = i2,a = 180.0) { + DIST_T dy = fabs(dto[i].dy[0]) + trackGauge * fillWidth; + b1 = dto[i].pts[0]; + Translate(&b3,b1,(angle + a),dy); + Translate(&b5,b1,(angle + a),-(dy * 0.75)); + if(dto[i].type != 'S') { + if(dto[i].type == 'L') { + hasLeft = 1; + } else if(dto[i].type == 'R') { + hasRgt = 1; + } + for(j = 1; j < dto[i].n; j++) { + dy = fabs(dto[i].dy[j]) + trackGauge * fillWidth; + b2 = dto[i].pts[j]; + Translate(&b4,b2,(angle + a),dy); + Translate(&b6,b2,(angle + a),-(dy * 0.75)); + + // Draw the background + DrawFill(d,color,b3,b4,b5,b6); + + // Draw the bridge edge + if(fillType==0) { + DrawLine( d,b3,b4,width2,drawColorBlack ); + } + b1 = b2; + b3 = b4; + b5 = b6; + } + } + if(i == i2) { + break; + } + } + + if(dtod.strPath >= 0 && dtod.str2Path >= 0) { + i1 = dtod.strPath; + i2 = dtod.str2Path; + if(!hasRgt&&fillType==0) { + DIST_T dy = trackGauge * 1.5; + ANGLE_T a1, a2; + b1 = dto[i1].pts[0]; + a1 = dto[i1].angle + 90; + Translate(&b3,b1,a1,dy); + + b2 = dto[i2].pts[dto[i2].n - 1]; + a2 = dto[i2].angle + 90; + Translate(&b4,b2,a2,dy); + + FindIntersection(&b0, b3, a1-90.0, b4, a2-90.0); + + // Draw the bridge edge + DrawLine(d,b3,b0,width2,drawColorBlack); + DrawLine(d,b0,b4,width2,drawColorBlack); + } + + if(!hasLeft&&fillType==0) { + DIST_T dy = trackGauge * 1.5; + ANGLE_T a1, a2; + b1 = dto[i2].pts[0]; + a1 = dto[i2].angle - 90; + Translate(&b3,b1,a1,dy); + + b2 = dto[i1].pts[dto[i1].n - 1]; + a2 = dto[i1].angle - 90; + Translate(&b4,b2,a2,dy); + + FindIntersection(&b0, b3, a1+90.0, b4, a2+90.0); + + // Draw the bridge edge + DrawLine(d,b3,b0,width2,drawColorBlack); + DrawLine(d,b0,b4,width2,drawColorBlack); + } + + if(dtod.toType == DTO_XNG9 && fillType==0) { + DIST_T dy = trackGauge * 1.5; + ANGLE_T a1, a2; + b1 = dto[i1].pts[dto[i1].n - 1]; + a1 = dto[i1].angle + 90; + Translate(&b3,b1,a1,dy); + + b2 = dto[i2].pts[dto[i2].n - 1]; + a2 = dto[i2].angle - 90; + Translate(&b4,b2,a2,dy); + + FindIntersection(&b0, b3, a1-90.0, b4, a2+90.0); + + // Draw the bridge edge + DrawLine(d,b3,b0,width2,drawColorBlack); + DrawLine(d,b0,b4,width2,drawColorBlack); + + b1 = dto[i1].pts[0]; + a1 = dto[i1].angle - 90; + Translate(&b3,b1,a1,dy); + + b2 = dto[i2].pts[0]; + a2 = dto[i2].angle + 90; + Translate(&b4,b2,a2,dy); + + FindIntersection(&b0, b3, a1+90.0, b4, a2-90.0); + + // Draw the bridge edge + DrawLine(d,b3,b0,width2,drawColorBlack); + DrawLine(d,b0,b4,width2,drawColorBlack); + } + } + + // Bridge wings + EPINX_T ep; + coOrd p; + track_p trk1; + coOrd p0,p1; + + if(fillType==0) { + for(ep = 0; ep < 4; ep++) { + trk1 = GetTrkEndTrk(dtod.trk,ep); + + if((trk1) && (!GetTrkBridge(trk1))) { + p = GetTrkEndPos(dtod.trk,ep); + a = GetTrkEndAngle(dtod.trk,ep) + 90.0; + + if((dtod.toType == DTO_XNG9) || (ep == 2) || (ep == 3)) { + Translate(&p0,p,a,trackGauge * 1.5); + Translate(&p1,p0,a - 45.0,trackGauge * 1.5); + DrawLine(d,p0,p1,width2,drawColorBlack); + } + if((dtod.toType == DTO_XNG9) || (ep == 0) || (ep == 1)) { + Translate(&p0,p,a,-trackGauge * 1.5); + Translate(&p1,p0,a + 45.0,-trackGauge * 1.5); + DrawLine(d,p0,p1,width2,drawColorBlack); + } + } + } + } +} + +/** + * Init Normal Turnout data structure + * Calculates the dy value of each segment + * Sets pts values REORIGIN base to actual position and angle + * Save often used last base and last point coOrd + */ +static void DrawDtoInit() +{ + struct extraDataCompound_t* xx = dtod.xx; + coOrd p1; + int i, j; + + for(i = 0; i < DTO_DIM; i++) { + int n = dto[i].n; + for(j = 0; j < n; j++) { + REORIGIN(p1,dto[i].base[j],xx->angle,xx->orig); + dto[i].pts[j] = p1; + if(j < n - 1) { + dto[i].dy[j] = (dto[i].base[j + 1].y - dto[i].base[j].y) / + (dto[i].base[j + 1].x - dto[i].base[j].x); + } + } + dto[i].ptsLast = dto[i].pts[n - 1]; + dto[i].baseLast = dto[i].base[n - 1]; + } +} + +/** + * Draw Normal (Single Origin) Turnout Bridge and Ties. Uses the static dto and dtod structures. + * + * \param d The drawing object + * \param scaleInx The layout/track scale index + * \param color The tie color. If black the color is read from the global tieColor. + */ +static void DrawNormalTurnout( + drawCmd_p d, + SCALEINX_T scaleInx, + BOOL_T omitTies, + wDrawColor color) +{ + DIST_T len; + coOrd pos; + int cnt; + ANGLE_T angle; + coOrd s1, s2, p1, p2, q1, q2; + int p0, q0; +// int s0; + ANGLE_T a0; + + if (color == wDrawColorBlack) { + color = tieColor; + } + +// DIST_T trackGauge = GetTrkGauge(dtod.trk); + + DrawDtoInit(); + + // draw the points +#ifdef DTO_DEBUG + if (DTO_DEBUG == DTO_NORMAL) { DrawDtoLayout(d, scaleInx); } +#endif + + int strPath = dtod.strPath, othPath = 0, secPath = 1; + int toType = dtod.toType; +// int first = 1; + + switch (toType) { + case DTO_NORMAL: + othPath = 1 - strPath; + secPath = strPath; + break; + case DTO_WYE: + // strPath = 2; + othPath = 0; secPath = 1; + break; + case DTO_THREE: + switch (strPath) { + case 0: + othPath = 1; secPath = 2; + break; + case 1: + othPath = 0; secPath = 2; + break; + case 2: + othPath = 0; secPath = 1; + break; + } + break; + } + + if(dtod.bridge) { + DrawTurnoutFill(d,0,othPath,secPath); + } else if(dtod.roadbed) { + DrawTurnoutFill( d,1,othPath,secPath ); + } + if (omitTies) { + return; + } + + // Straight vector for tie angle + if (toType == DTO_WYE) { + s1 = dto[othPath].pts[0]; + s2 = MidPtCoOrd(dto[othPath].ptsLast, dto[secPath].ptsLast); + } else { + s1 = dto[strPath].pts[0]; + s2 = dto[strPath].ptsLast; + } + // Diverging vector(s) + p1 = dto[othPath].pts[0]; + p2 = dto[othPath].ptsLast; + q1 = dto[secPath].pts[0]; + q2 = dto[secPath].ptsLast; + + len = FindDistance(s1, s2); + angle = FindAngle(s1, s2); // The straight segment + + cnt = (int)floor(len / dtod.td.spacing + 0.5); + if (cnt > 0) { + int pn = dto[othPath].n; + int qn = dto[secPath].n; + DIST_T dx = len / cnt; + /*s0 =*/ p0 = q0 = 0; + DIST_T tdlen = dtod.td.length; + DIST_T tdmax = (toType == DTO_WYE) ? 2.0 * tdlen : 2.5 * tdlen; + DIST_T tdwid = dtod.td.width; + DIST_T px = len, dlenx = dx / 2; + + cnt = cnt > 1 ? cnt - 1 : 1; + for (px = dlenx; cnt; cnt--, px += dx) { + if (px >= dto[othPath].base[p0 + 1].x) { p0++; } + if (px >= dto[secPath].base[q0 + 1].x) { q0++; } + if (p0 >= pn || q0 >= qn) { + break; + } + + if ((px + dx >= dto[othPath].baseLast.x) + || (px + dx >= dto[secPath].baseLast.x)) { + break; + } + + DIST_T dy1 = dto[othPath].base[p0].y + (px - dto[othPath].base[p0].x) * + dto[othPath].dy[p0]; + DIST_T dy2 = dto[secPath].base[q0].y + (px - dto[secPath].base[q0].x) * + dto[secPath].dy[q0]; + tdlen = dtod.td.length + fabs(dy1) + fabs(dy2); + if (tdlen > tdmax) { + break; + } + + DIST_T dy = dy1 + dy2; + Translate(&pos, s1, angle, px); + Translate(&pos, pos, (angle - 90.0), dy / 2); + + DrawTie(d, pos, angle, tdlen, tdwid, color, tieDrawMode == TIEDRAWMODE_SOLID); + } + + // Asymmetric? Use longer ties for remaining two tracks (strPath, othPath) + DIST_T sx = px; // Save these values for second code block + int s0 = p0; + if((dtod.toType == DTO_THREE) && (px + dx >= dto[secPath].baseLast.x)) { + for ( ; cnt; cnt--, px += dx) { + if (px >= dto[othPath].base[p0 + 1].x) { p0++; } + // if (px >= dto[secPath].base[q0 + 1].x) q0++; + if (p0 >= pn) { + break; + } + + if (px + dx >= dto[othPath].baseLast.x) { + break; + } + + DIST_T dy1 = dto[othPath].base[p0].y + (px - dto[othPath].base[p0].x) * + dto[othPath].dy[p0]; + tdlen = dtod.td.length + fabs(dy1); + if (tdlen > tdmax) { + break; + } + + DIST_T dy = dy1; + Translate(&pos, s1, angle, px); + Translate(&pos, pos, (angle - 90.0), dy / 2); + + DrawTie(d, pos, angle, tdlen, tdwid, color, tieDrawMode == TIEDRAWMODE_SOLID); + } + } + + // Draw remaining ties, if any + if (px + dx < dto[othPath].baseLast.x) { + p1 = dto[othPath].pts[p0]; + p2 = dto[othPath].ptsLast; + angle = FindAngle(p1, p2); + a0 = FindAngle(dto[othPath].base[p0], dto[othPath].baseLast); + DIST_T lenr = (dto[othPath].baseLast.x - px + dlenx) / cos(D2R(90.0 - a0)); + Translate(&p1, p2, angle, -lenr); + DrawStraightTies(d, dtod.td, p1, p2, color); + } else { + p1 = dto[othPath].pts[pn - 2]; + a0 = FindAngle(p1, p2); + Translate(&pos, p2, a0, -dx / 2); + DrawTie(d, pos, a0, dtod.td.length, tdwid, color, + tieDrawMode == TIEDRAWMODE_SOLID); + } + // Restore saved values + if(dtod.toType == DTO_THREE) { + px = sx; + p0 = s0; + } + + // Asymmetric? Use longer ties for remaining two tracks (strPath, secPath) + if((dtod.toType == DTO_THREE) && (px + dx >= dto[othPath].baseLast.x)) { + for ( ; cnt; cnt--, px += dx) { + // if (px >= dto[othPath].base[p0 + 1].x) p0++; + if (px >= dto[secPath].base[q0 + 1].x) { q0++; } + if (q0 >= qn) { + break; + } + + if (px + dx >= dto[secPath].baseLast.x) { + break; + } + + DIST_T dy1 = dto[secPath].base[q0].y + (px - dto[secPath].base[q0].x) * + dto[secPath].dy[q0]; + tdlen = dtod.td.length + fabs(dy1); + if (tdlen > tdmax) { + break; + } + + DIST_T dy = dy1; + Translate(&pos, s1, angle, px); + Translate(&pos, pos, (angle - 90.0), dy / 2); + + DrawTie(d, pos, angle, tdlen, tdwid, color, tieDrawMode == TIEDRAWMODE_SOLID); + } + } + if (px + dx < dto[secPath].baseLast.x) { + q1 = dto[secPath].pts[q0]; + q2 = dto[secPath].ptsLast; + angle = FindAngle(q1, q2); + a0 = FindAngle(dto[secPath].base[q0], dto[secPath].baseLast); + DIST_T lenr = (dto[secPath].baseLast.x - px + dlenx) / cos(D2R(90.0 - a0)); + Translate(&q1, q2, angle, -lenr); + DrawStraightTies(d, dtod.td, q1, q2, color); + } else { + q1 = dto[secPath].pts[qn - 2]; + a0 = FindAngle(q1, q2); + Translate(&pos, q2, a0, -dx / 2); + DrawTie(d, pos, a0, dtod.td.length, tdwid, color, + tieDrawMode == TIEDRAWMODE_SOLID); + } + + // Final ties at end + if (dtod.toType == DTO_THREE) { + + int n = (int)(dto[strPath].baseLast.x); + if (px + dx < len) { + angle = FindAngle(s1, s2); + DIST_T lenr = len - px + dlenx; + Translate(&s1, s2, angle, -lenr); + DrawStraightTies(d, dtod.td, s1, s2, color); + } else { + n = dto[strPath].n; + s1 = dto[strPath].pts[n - 2]; + a0 = FindAngle(s1, s2); + Translate(&pos, s2, a0, -dx / 2); + DrawTie(d, pos, a0, dtod.td.length, tdwid, color, + tieDrawMode == TIEDRAWMODE_SOLID); + } + } + } +} + +/** + * Draw Curved (Single Origin) Turnout Bridge and Ties. Uses the static dto and dtod structures. + * + * \param d The drawing object + * \param scaleInx The layout/track scale index + * \param color The tie color. If black the color is read from the global tieColor. + */ +static void DrawCurvedTurnout( + drawCmd_p d, + SCALEINX_T scaleInx, + BOOL_T omitTies, + wDrawColor color) +{ + DIST_T len, r; + coOrd pos; + int cnt; + ANGLE_T angle, dang; + coOrd center; + coOrd p1, p2, q1, q2; + ANGLE_T a0, a1, a2; + struct extraDataCompound_t* xx = dtod.xx; + + if (color == wDrawColorBlack) { + color = tieColor; + } + + DrawDtoInit(); + + // draw the points +#ifdef DTO_DEBUG + if (DTO_DEBUG == DTO_CURVED) { DrawDtoLayout(d, scaleInx); } +#endif + + int othPath = 0, secPath = 1; +// int toType = dtod.toType; + + if(dtod.bridge) { + DrawTurnoutFill(d,0,othPath,secPath); + } else if(dtod.roadbed) { + DrawTurnoutFill(d,1,othPath,secPath); + } + if (omitTies) { + return; + } + + // Save the ending coordinates + coOrd othEnd = zero, secEnd = zero; + + trkSeg_p trk; + DIST_T tdlen = dtod.td.length, tdmax = tdlen * 2.5; + DIST_T tdspc = dtod.td.spacing, tdspc2 = tdspc / 2.0; + DIST_T tdwid = dtod.td.width; +// double rdot = tdwid / 2; + + int pn = dto[othPath].n; + int qn = dto[secPath].n; + int p0 = 0, q0 = 0; + DIST_T px = 0, qx = 0, dy = 0, dy1 = 0, dy2 = 0; + + double cosAdj = 1.0; + + angle = 0; + px = tdspc2; + qx = tdspc2; + int segs = max(dto[othPath].n, dto[secPath].n); + for (; segs > 0; segs--) { + + if (px >= dto[othPath].base[p0 + 1].x) { + p0++; + } + if (qx >= dto[secPath].base[q0 + 1].x) { + q0++; + } + if ((p0 >= pn - 1) || (q0 >= qn - 1)) { + break; + } + + trk = dto[othPath].trkSeg[p0]; + if (trk->type == SEG_CRVTRK) { + + center = trk->u.c.center; + r = fabs(trk->u.c.radius); + a0 = NormalizeAngle(trk->u.c.a0 + dtod.xx->angle); + a1 = trk->u.c.a1; + + pos = center; + REORIGIN(center, pos, xx->angle, xx->orig); + + len = r * D2R(a1); + cnt = (int)floor(len / tdspc + 0.5); + if (len - tdspc * cnt >= tdspc2) { + cnt++; + } + DIST_T tdlen = dtod.td.length; +// DIST_T dx = len / cnt, dx2 = dx / 2; + + if (cnt != 0) { + dang = (len / cnt) * 360 / (2 * M_PI * r); + DIST_T dx = len / cnt, dx2 = dx / 2; + + if (dto[othPath].type == 'R') { + a2 = a0 + dang / 2; + } else { + a2 = a0 + a1 - dang / 2; + dang = -dang; + } + angle += fabs(dang / 2); + + cosAdj = fabs(cos(D2R(angle))); + px += dx2 * cosAdj; + qx += dx2 * cosAdj; + + for (; cnt; cnt--, a2 += dang, angle += dang) { + if (px >= dto[othPath].base[p0 + 1].x) { + p0++; + } + if (qx >= dto[secPath].base[q0 + 1].x) { + q0++; + } + if ((p0 >= pn - 1) || (q0 >= qn - 1)) { + break; + } + + coOrd e1, e2; + PointOnCircle(&e1, center, r, a2); + + q1 = dto[secPath].pts[q0]; + q2 = dto[secPath].pts[q0 + 1]; + FindIntersection(&e2, e1, a2, q1, FindAngle(q1, q2)); + + dy = FindDistance(e1, e2); + DIST_T tlen = tdlen + dy; + + if (tlen > tdmax) { + break; + } + + Translate(&pos, e1, a2, -dy / 2); + DrawTie(d, pos, angle + xx->angle + 90, tlen, tdwid, color, + tieDrawMode == TIEDRAWMODE_SOLID); + + // Assures that these ends are the last point drawn before break + othEnd = e1; + secEnd = e2; + + cosAdj = fabs(cos(D2R(angle))); + if (cnt > 1) { + px += dx * cosAdj; + qx += dx * cosAdj; + } else { + px += dx2 * cosAdj; + qx += dx2 * cosAdj; + } + } + } + } else { + cosAdj = fabs(cos(D2R(angle))); + + p1 = dto[othPath].base[p0]; + p2 = dto[othPath].base[p0 + 1]; + len = FindDistance(p1, p2); + cnt = (int)floor(len / tdspc + 0.6); + if (cnt > 0) { + DIST_T dx = len / cnt/*, dx2 = dx / 2*/; + + for (; cnt; cnt--) { + if (px >= dto[othPath].base[p0 + 1].x) { + p0++; + } + if (qx >= dto[secPath].base[q0 + 1].x) { + q0++; + } + if ((p0 >= pn - 1) || (q0 >= qn - 1)) { + break; + } + + p1 = dto[othPath].base[p0]; + p2 = dto[othPath].base[p0 + 1]; + + if ((px >= dto[othPath].baseLast.x) + || (qx >= dto[secPath].baseLast.x)) { + break; + } + + dy1 = dto[secPath].base[q0].y + (qx - dto[secPath].base[q0].x) * + dto[secPath].dy[q0]; + dy2 = dto[othPath].base[p0].y + (px - dto[othPath].base[p0].x) * + dto[othPath].dy[p0]; + dy = dy1 - dy2; + DIST_T tlen = tdlen + fabs(cosAdj * dy); + if (tlen > tdmax) { + break; + } + + q1 = dto[secPath].pts[q0]; + q2 = dto[secPath].pts[q0 + 1]; + a1 = FindAngle(q1, q2); + DIST_T xlen = qx - dto[secPath].base[q0].x; + Translate(&pos, q1, a1, xlen); + secEnd = pos; + + q1 = dto[othPath].pts[p0]; + q2 = dto[othPath].pts[p0 + 1]; + a1 = FindAngle(q1, q2); + xlen = px - dto[othPath].base[p0].x; + Translate(&pos, q1, a1, xlen); + othEnd = pos; + + Translate(&pos, pos, (a1 - 90.0), dy / 2); + DrawTie(d, pos, a1, tlen, tdwid, color, tieDrawMode == TIEDRAWMODE_SOLID); + + cosAdj = fabs(cos(D2R(angle))); + px += dx * cosAdj; + qx += dx * cosAdj; + } + } else { + break; + } + } + } + +#ifdef DTO_DEBUG + if (DTO_DEBUG == DTO_CURVED) { + DrawFillCircle(d, othEnd, rdot, drawColorGreen); + DrawFillCircle(d, secEnd, rdot, drawColorGreen); + + DrawFillCircle(d, dto[othPath].pts[p0], rdot, drawColorBlue); + DrawFillCircle(d, dto[secPath].pts[q0], rdot, drawColorBlue); + } +#endif + + // Draw remaining ties, if any + p1 = othEnd; + p2 = dto[othPath].ptsLast; + a0 = FindAngle(p1, p2); + len = FindDistance(p1, p2); + if (len >= 2 * tdspc) { + Translate(&p1, p1, a0, tdspc2); + DrawStraightTies(d, dtod.td, p1, p2, color); + } else if (len > tdspc2) { + Translate(&p2, p2, a0, -tdspc2); + DrawTie(d, p2, a0, dtod.td.length, tdwid, color, + tieDrawMode == TIEDRAWMODE_SOLID); + } + + q1 = secEnd; + q2 = dto[secPath].ptsLast; + a0 = FindAngle(q1, q2); + len = FindDistance(q1, q2); + if (len >= 2 * tdspc) { + Translate(&q1, q1, a0, tdspc2); + DrawStraightTies(d, dtod.td, q1, q2, color); + } else if (len > tdspc2) { + Translate(&q2, q2, a0, -tdspc2); + DrawTie(d, q2, a0, dtod.td.length, tdwid, color, + tieDrawMode == TIEDRAWMODE_SOLID); + } +} + +/** + * Draw Crossing and Slip Turnout Bridge and Ties - Uses the static dto and dtod structures. + * + * \param d The drawing object + * \param scaleInx The layout/track scale index + * \param color The tie color. If black the color is read from the global tieColor. + */ +static void DrawXingTurnout( + drawCmd_p d, + SCALEINX_T scaleInx, + BOOL_T omitTies, + wDrawColor color) +{ + DIST_T len; + coOrd pos; + int cnt; + ANGLE_T cAngle; + + if (color == wDrawColorBlack) { + color = tieColor; + } + + coOrd c1, c2, s1, s2, p1, p2, q1; + int p0, q0; + ANGLE_T a0, a1, a2; + int strPath = dtod.strPath, str2Path = dtod.str2Path; + + struct extraDataCompound_t* xx = dtod.xx; + + DrawDtoInit(); + + dto[strPath].angle = FindAngle(dto[strPath].pts[0], dto[strPath].ptsLast); + dto[str2Path].angle = FindAngle(dto[str2Path].pts[0], dto[str2Path].ptsLast); + + int othPath = strPath, secPath = str2Path; + int toType = dtod.toType; + + int i, j; + switch (toType) { + case DTO_XING: + case DTO_XNG9: + break; + case DTO_SSLIP: + for (i = 0; i < dtod.pathCnt; i++) { + if (dto[i].type == 'L' || dto[i].type == 'R') { + secPath = i; + break; + } + } + break; + case DTO_DSLIP: + for (i = 0; i < dtod.pathCnt; i++) { + if (dto[i].type == 'L') { + othPath = i; + } else if (dto[i].type == 'R') { + secPath = i; + } + } + break; + } + + if(dtod.bridge) { + DrawXingFill(d,0,othPath,secPath); + } else if(dtod.roadbed) { + DrawXingFill(d,1,othPath,secPath); + } + + // draw the points +#ifdef DTO_DEBUG + if (DTO_DEBUG == DTO_XING) { DrawDtoLayout(d, scaleInx); } +#endif + + if (omitTies) { + return; + } + + DIST_T tdlen = dtod.td.length, tdmax = 2.0 * tdlen; + DIST_T tdwid = dtod.td.width; + DIST_T tdspc = dtod.td.spacing, tdspc2 = tdspc / 2; + + // Midpoint + p1 = dto[strPath].pts[0]; + a1 = dto[strPath].angle; + + q1 = dto[str2Path].pts[0]; + a2 = dto[str2Path].angle; + + FindIntersection(&pos, p1, a1, q1, a2); + dtod.midPt = pos; + +#ifdef DTO_DEBUG + if(DTO_DEBUG == DTO_XING) { + double r = td->width / 2; + DrawFillCircle(d,p1,r,drawColorPurple); + DrawFillCircle(d,q1,r,drawColorPurple); + DrawFillCircle(d,dtod.midPt,r,drawColorPurple); + } +#endif + + // Tie length adjust + double dAngle = fabs(DifferenceBetweenAngles(a1, a2)); + double magic = 1.0; + + // Short circuit the complex code for this simple case + if (toType == DTO_XNG9) { + p1 = dto[strPath].pts[0]; + p2 = dto[strPath].ptsLast; + DrawStraightTies(d, dtod.td, p1, p2, color); + + p1 = dto[str2Path].pts[0]; + p2 = dto[str2Path].ptsLast; + + // Omit the center ties + magic = 1 / cos(D2R(90 - dAngle)); + DIST_T tdadj = (tdlen / 2) * magic; + DIST_T tdadj2 = tdspc2 * magic; + + dAngle = (dAngle - 90) / 2; + Translate(&pos, dtod.midPt, a2, -tdadj - tdadj2); + DrawTie(d, pos, a2 - dAngle, tdlen, tdwid, color, + tieDrawMode == TIEDRAWMODE_SOLID); + + Translate(&pos, dtod.midPt, a2, -tdadj - tdspc); + DrawStraightTies(d, dtod.td, p1, pos, color); + + Translate(&pos, dtod.midPt, a2, tdadj + tdadj2); + DrawTie(d, pos, a2 - dAngle, tdlen, tdwid, color, + tieDrawMode == TIEDRAWMODE_SOLID); + + Translate(&pos, dtod.midPt, a2, tdadj + tdspc); + DrawStraightTies(d, dtod.td, pos, p2, color); + return; + } + + // Straight vector for tie angle + s1 = MidPtCoOrd(dto[strPath].base[0], dto[str2Path].base[0]); + s2 = MidPtCoOrd(dto[strPath].baseLast, dto[str2Path].baseLast); + + // Rotate base coordinates so that the tie line is aligned with x-axis and origin is at zero + cAngle = FindAngle(s1, s2); + for (i = 0; i < DTO_DIM; i++) + for (j = 0; j < dto[i].n; j++) { + dto[i].base[j].x -= s1.x; + dto[i].base[j].y -= s1.y; + Rotate(&dto[i].base[j], zero, (90.0 - cAngle)); + } + + for (i = 0; i < DTO_DIM; i++) { + for (j = 0; j < dto[i].n - 1; j++) { + dto[i].dy[j] = (dto[i].base[j + 1].y - dto[i].base[j].y) / + (dto[i].base[j + 1].x - dto[i].base[j].x); + } + if (dto[i].type == 'S') { + dto[i].angle = FindAngle(dto[i].pts[0], dto[i].ptsLast); + } + } + + // Tie center line in drawing coordinates + REORIGIN(c1, s1, xx->angle, xx->orig); + REORIGIN(c2, s2, xx->angle, xx->orig); + cAngle = FindAngle(c1, c2); + + int pn = dto[othPath].n; + int qn = dto[secPath].n; + + // Tie length adjust + magic = 1 / cos(0.5 * D2R(dAngle)); + // Extra ties length adjust + double magic2 = 1.0 / cos(0.5 * D2R(dAngle)); + + // Draw right half + len = FindDistance(dtod.midPt, c2); + cnt = (int)floor(len / dtod.td.spacing + 0.5); + if (cnt <= 0) { + return; + } + + DIST_T dx = len / cnt; + p0 = q0 = 0; + DIST_T dx2 = dx / 2; + DIST_T px = len + dx2; + DIST_T lenx = 0; + + while (p0 < pn && px > dto[othPath].base[p0 + 1].x) { p0++; } + while (q0 < qn && px > dto[secPath].base[q0 + 1].x) { q0++; } + while (p0 < pn && q0 < qn) { + if (px > dto[othPath].base[p0 + 1].x) { p0++; } + if (px > dto[secPath].base[q0 + 1].x) { q0++; } + if (p0 >= pn || q0 >= qn) { + break; + } + // Dont use baseLast, as base coOrds have been rotated + if ((px + dx >= dto[othPath].base[pn - 1].x) + || (px + dx >= dto[secPath].base[qn - 1].x)) { + break; + } + + DIST_T dy1 = dto[othPath].base[p0].y + (px - dto[othPath].base[p0].x) * + dto[othPath].dy[p0]; + DIST_T dy2 = dto[secPath].base[q0].y + (px - dto[secPath].base[q0].x) * + dto[secPath].dy[q0]; + tdlen = (dtod.td.length + fabs(dy1) + fabs(dy2)) * magic; + if(tdlen > tdmax) { + if(dAngle >= 30) { + DIST_T dy = (dy1 + dy2) / 2; + Translate(&pos,dtod.midPt,cAngle,px - len); + Translate(&pos,pos,(cAngle - 90.0),dy); + DrawTie(d,pos,cAngle,tdlen - dtod.td.length * magic,tdwid,color, + tieDrawMode == TIEDRAWMODE_SOLID); + lenx += dx2 * magic2; + } + break; + } + + DIST_T dy = (dy1 + dy2) / 2; + Translate(&pos, dtod.midPt, cAngle, px - len); + Translate(&pos, pos, (cAngle - 90.0), dy); + DrawTie(d, pos, cAngle, tdlen, tdwid, color, tieDrawMode == TIEDRAWMODE_SOLID); + + px += dx; + lenx += dx; + } + + p1 = dtod.midPt; + p2 = dto[strPath].ptsLast; + DIST_T lenr = FindDistance(p1, p2) - lenx * magic2; + a0 = dto[strPath].angle; + if (lenr > dx) { + Translate(&pos, p2, a0, -lenr); + DrawStraightTies(d, dtod.td, pos, p2, color); + } else { + Translate(&pos, p2, a0, -dx2); + DrawTie(d, pos, a0, dtod.td.length, tdwid, color, + tieDrawMode == TIEDRAWMODE_SOLID); + } + + // p1 = dtod.midPt; + p2 = dto[str2Path].ptsLast; + lenr = FindDistance(p1, p2) - lenx * magic2; + a0 = dto[str2Path].angle; + if (lenr > dx) { + Translate(&pos, p2, a0, -lenr); + DrawStraightTies(d, dtod.td, pos, p2, color); + } else { + Translate(&pos, p2, a0, -dx2); + DrawTie(d, pos, a0, dtod.td.length, tdwid, color, + tieDrawMode == TIEDRAWMODE_SOLID); + } + + // Draw left half + // Change the straight path used + if (dtod.toType == DTO_SSLIP) { + othPath = str2Path; + } + + len = FindDistance(c1, dtod.midPt); + cnt = (int)floor(len / dtod.td.spacing + 0.5); + if (cnt <= 0) { + return; + } + + p0 = q0 = 0; + tdlen = dtod.td.length; + + dx = len / cnt; + dx2 = dx / 2; + px = len - dx2; + lenx = 0; + + while (p0 < pn && px > dto[othPath].base[p0 + 1].x) { p0++; } + while (q0 < qn && px > dto[secPath].base[q0 + 1].x) { q0++; } + while (p0 >= 0 && q0 >= 0) { + if (px < dto[othPath].base[p0].x) { p0--; } + if (px < dto[secPath].base[q0].x) { q0--; } + if (p0 < 0 || q0 < 0) { + break; + } + + if ((px - dx < dto[othPath].base[0].x) + || (px - dx < dto[secPath].base[0].x)) { + break; + } + + DIST_T dy1 = dto[othPath].base[p0].y + (px - dto[othPath].base[p0].x) * + dto[othPath].dy[p0]; + DIST_T dy2 = dto[secPath].base[q0].y + (px - dto[secPath].base[q0].x) * + dto[secPath].dy[q0]; + tdlen = (dtod.td.length + fabs(dy1) + fabs(dy2)) * magic; + if(tdlen > tdmax) { + if(dAngle >= 30) { + DIST_T dy = (dy1 + dy2) / 2; + Translate(&pos,dtod.midPt,cAngle,px - len); + Translate(&pos,pos,(cAngle - 90.0),dy); + DrawTie(d,pos,cAngle,tdlen - dtod.td.length * magic,tdwid,color, + tieDrawMode == TIEDRAWMODE_SOLID); + lenx += dx2 * magic2; + } + break; + } + + DIST_T dy = (dy1 + dy2) / 2; + Translate(&pos, dtod.midPt, cAngle, px - len); + Translate(&pos, pos, (cAngle - 90.0), dy); + DrawTie(d, pos, cAngle, tdlen, tdwid, color, tieDrawMode == TIEDRAWMODE_SOLID); + + px -= dx; + lenx += dx; + } + + p1 = dto[strPath].pts[0]; + p2 = dtod.midPt; + a0 = dto[strPath].angle; + lenr = FindDistance(p1, p2) - lenx * magic2; + if (lenr > dx) { + Translate(&pos, p1, a0, lenr); + DrawStraightTies(d, dtod.td, p1, pos, color); + } else { + Translate(&pos, p1, a0, dx2); + DrawTie(d, pos, a0, dtod.td.length, tdwid, color, + tieDrawMode == TIEDRAWMODE_SOLID); + } + p1 = dto[str2Path].pts[0]; + // p2 = dtod.midPt; + a0 = dto[str2Path].angle; + lenr = FindDistance(p1, p2) - lenx * magic2; + if (lenr > dx) { + Translate(&pos, p1, a0, lenr); + DrawStraightTies(d, dtod.td, p1, pos, color); + } else { + Translate(&pos, p1, a0, dx2); + DrawTie(d, pos, a0, dtod.td.length, tdwid, color, + tieDrawMode == TIEDRAWMODE_SOLID); + } +} + +/** + * Draw Crossover (Two Origin) Turnout Bridge and Ties. Uses the static dto and dtod structures. + * + * \param d The drawing object + * \param scaleInx The layout/track scale index + * \param color The tie color. If black the color is read from the global tieColor. + */ +static void DrawCrossTurnout( + drawCmd_p d, + SCALEINX_T scaleInx, + BOOL_T omitTies, + wDrawColor color) +{ + DIST_T len, dx; + coOrd pos; + int cnt; + ANGLE_T angle; + + if (color == wDrawColorBlack) { + color = tieColor; + } + +// struct extraDataCompound_t* xx = dtod.xx; + + DrawDtoInit(); + + // draw the points +#ifdef DTO_DEBUG + if (DTO_DEBUG == DTO_LCROSS) { DrawDtoLayout(d, scaleInx); } +#endif + + int strPath = dtod.strPath, str2Path = dtod.str2Path; + // Bad assumption + int othPath = 2, secPath = 2; + if (dtod.pathCnt == 4) { secPath = 3; } + + dto[strPath].angle = FindAngle(dto[strPath].pts[0], dto[strPath].ptsLast); + dto[str2Path].angle = FindAngle(dto[str2Path].pts[0], dto[str2Path].ptsLast); + + if(dtod.bridge) { + DrawCrossFill(d,0,strPath,str2Path); + } else if(dtod.roadbed) { + DrawCrossFill(d,1,strPath,str2Path); + } + if (omitTies) { + return; + } + + coOrd s1, s2, t1; +// coOrd t2, p1, p2, q1, q2; + int s0, t0, p0, q0; + + int sn = dto[strPath].n; + int tn = dto[str2Path].n; + int pn = dto[othPath].n; + int qn = dto[secPath].n; + + s1 = dto[strPath].pts[0]; + s2 = dto[strPath].ptsLast; + t1 = dto[str2Path].pts[0]; +// t2 = dto[str2Path].ptsLast; + angle = dto[strPath].angle; + +// p1 = dto[othPath].base[0]; +// p2 = dto[othPath].baseLast; +// q1 = dto[secPath].base[0]; +// q2 = dto[secPath].baseLast; + + len = FindDistance(s1, s2); + angle = dto[strPath].angle; + + cnt = (int)floor(len / dtod.td.spacing + 0.5); + if (cnt > 0) { + DIST_T px = 0; + DIST_T dy, dy1, dy2; + int cflag = 0; + dy = dto[str2Path].base[0].y - dto[strPath].base[0].y; + + dx = len / cnt; + s0 = t0 = p0 = q0 = 0; + DIST_T tdlen = dtod.td.length; + DIST_T tdwid = dtod.td.width; + DIST_T dlenx = dx / 2; + + DIST_T px1 = len / 2 - dlenx * 5, + px2 = len / 2 + dlenx * 4; + + for (px = dlenx; cnt; cnt--, px += dx) { + if (px >= dto[strPath].base[s0 + 1].x) { s0++; } + if (px >= dto[str2Path].base[t0 + 1].x) { t0++; } + if (px >= dto[othPath].base[p0 + 1].x) { p0++; } + if (px >= dto[secPath].base[q0 + 1].x) { q0++; } + if (s0 >= sn || t0 >= tn || p0 >= pn || q0 >= qn) { + break; + } + + if ((px >= dto[strPath].baseLast.x) + || (px >= dto[str2Path].baseLast.x)) { + break; + } + + dy1 = dy2 = 0; + cflag = 0; + if (px < px1) { + switch (dtod.toType) { + case DTO_DCROSS: + dy1 = dto[othPath].base[p0].y + (px - dto[othPath].base[p0].x) * + dto[othPath].dy[p0]; + dy2 = dy - dto[secPath].base[q0].y - (px - dto[secPath].base[q0].x) * + dto[secPath].dy[q0]; + break; + case DTO_LCROSS: + dy1 = dto[othPath].base[p0].y + (px - dto[othPath].base[p0].x) * + dto[othPath].dy[p0]; + dy2 = 0; + break; + case DTO_RCROSS: + dy1 = 0; + dy2 = dy - dto[secPath].base[q0].y - (px - dto[secPath].base[q0].x) * + dto[secPath].dy[q0]; + break; + default: + break; + } + } else if (px < px2) { + dy1 = (dto[str2Path].base[s0].y - dto[strPath].base[t0].y); + dy2 = 0; + cflag = 1; + } else { + switch (dtod.toType) { + case DTO_DCROSS: + dy1 = dto[secPath].base[q0].y + (px - dto[secPath].base[q0].x) * + dto[secPath].dy[q0]; + dy2 = dy - dto[othPath].base[p0].y - (px - dto[othPath].base[p0].x) * + dto[othPath].dy[p0]; + break; + case DTO_LCROSS: + dy1 = 0; + dy2 = dy - dto[secPath].base[q0].y - (px - dto[secPath].base[q0].x) * + dto[secPath].dy[q0]; + break; + case DTO_RCROSS: + dy1 = dto[othPath].base[p0].y + (px - dto[othPath].base[p0].x) * + dto[othPath].dy[p0]; + dy2 = 0; + break; + default: + break; + } + } + + if (fabs(dy1) + fabs(dy2) >= dy) { + dy1 = (dto[str2Path].base[s0].y - dto[strPath].base[t0].y); + dy2 = 0; + cflag = 1; + } + + tdlen = dtod.td.length + fabs(dy1); + Translate(&pos, s1, angle, px); + Translate(&pos, pos, (angle - 90.0), dy1 / 2); + DrawTie(d, pos, angle, tdlen, tdwid, color, tieDrawMode == TIEDRAWMODE_SOLID); + + if (!cflag) { + tdlen = dtod.td.length + fabs(dy2); + Translate(&pos, t1, angle, px); + Translate(&pos, pos, (angle - 90.0), -dy2 / 2); + DrawTie(d, pos, angle, tdlen, tdwid, color, tieDrawMode == TIEDRAWMODE_SOLID); + } + } + return; + + // Draw remaining ties, if any + // Currently by definition, there won't be any + /* + if (px + dx < dto[strPath].baseLast.x) { + p1 = dto[strPath].pts[p0]; + p2 = dto[strPath].ptsLast; + angle = FindAngle(p1, p2); + a0 = FindAngle(dto[strPath].base[p0], dto[strPath].baseLast); + DIST_T lenr = (dto[strPath].baseLast.x - px + dlenx) / cos(D2R(90.0 - a0)); + Translate(&p1, p2, angle, -lenr); + DrawStraightTies(d, dtod.td, p1, p2, color); + } + else { + p1 = dto[strPath].pts[pn - 2]; + a0 = FindAngle(p1, p2); + Translate(&pos, p2, a0, -dx / 2); + DrawTie(d, pos, a0, td->length, tdwid, color, tieDrawMode == TIEDRAWMODE_SOLID); + } + + if (px + dx < dto[str2Path].baseLast.x) { + q1 = dto[str2Path].pts[q0]; + q2 = dto[str2Path].ptsLast; + angle = FindAngle(q1, q2); + a0 = FindAngle(dto[str2Path].base[q0], dto[str2Path].baseLast); + DIST_T lenr = (dto[str2Path].baseLast.x - px + dlenx) / cos(D2R(90.0 - a0)); + Translate(&q1, q2, angle, -lenr); + DrawStraightTies(d, dtod.td, q1, q2, color); + } + else { + q1 = dto[str2Path].pts[qn - 2]; + a0 = FindAngle(q1, q2); + Translate(&pos, q2, a0, -dx / 2); + DrawTie(d, pos, a0, td->length, tdwid, color, tieDrawMode == TIEDRAWMODE_SOLID); + } + */ + } +} + +/** + * Draw all turnout components: ties, rail, roadbed, etc. + * + * The turnout is checked to see if the enhanced methods can be used. + * If so the ties are drawn and the TB_NOTIES bit is set so that the + * rails and such are drawn on top of the ties. Similarly the bridge + * and roadbed bits are cleared so the enhanced method can be used. + * Those bits are restored to the previous state before return. + * + * \param trk Pointer to the track object + * \param d The drawing object + * \param color The turnout color. + */ +EXPORT void DrawTurnout( + track_p trk, + drawCmd_p d, + wDrawColor color) +{ + struct extraDataCompound_t* xx = GET_EXTRA_DATA(trk, T_TURNOUT, + extraDataCompound_t); + wIndex_t i; + long widthOptions = 0; + SCALEINX_T scaleInx = GetTrkScale(trk); + BOOL_T omitTies = !DoDrawTies(d, trk) || !DrawTwoRails(d,1) + || ((d->options & DC_SIMPLE) != 0); // || (scaleInx == 0); + + widthOptions = DTS_LEFT | DTS_RIGHT; + + // Save these values + int noTies = GetTrkNoTies(trk); + int bridge = GetTrkBridge(trk); + int roadbed = GetTrkRoadbed(trk); + + long skip = 0; + /** @prefs [Preference] NormalTurnoutDraw=1 to skip enhanced drawing methods */ + wPrefGetInteger("Preference", "NormalTurnoutDraw", (long *) &skip, 0); + + int pathCnt = (skip == 0 ? GetTurnoutPaths(trk, xx) : 0); + + if ( (pathCnt > 1) && (pathCnt <= DTO_DIM) + && ( GetTrkEndPtCnt( trk ) <= 4) + && (xx->special == TOnormal) ) { + + dtod.bridge = bridge; + dtod.roadbed = roadbed; + +// int strPath = -1; + GetTurnoutType(); + + if (dtod.toType != DTO_INVALID) { + + switch (dtod.toType) { + case DTO_NORMAL: + case DTO_THREE: + case DTO_WYE: + DrawNormalTurnout(d, scaleInx, omitTies, color); + break; + case DTO_CURVED: + DrawCurvedTurnout(d, scaleInx, omitTies, color); + break; + case DTO_XING: + case DTO_XNG9: + case DTO_SSLIP: + case DTO_DSLIP: + DrawXingTurnout(d, scaleInx, omitTies, color); + break; + case DTO_LCROSS: + case DTO_RCROSS: + case DTO_DCROSS: + DrawCrossTurnout(d, scaleInx, omitTies, color); + break; + default: + break; + } + // Ignore these settings + SetTrkNoTies(trk, 1); + ClrTrkBits( trk,TB_BRIDGE ); + ClrTrkBits(trk, TB_ROADBED); + } + } + + // Begin standard DrawTurnout code to draw rails or centerline + // no curve center for turnouts, leave centerline for sectional curved + long opts = widthOptions | (xx->segCnt > 1 ? DTS_NOCENTER : 0); + DrawSegsO(d, trk, xx->orig, xx->angle, xx->segs, xx->segCnt, GetTrkGauge(trk), + color, opts); + + + for (i = 0; i < GetTrkEndPtCnt(trk); i++) { + DrawEndPt(d, trk, i, color); + } + if ((d->options & DC_SIMPLE) == 0 && + (labelWhen == 2 || (labelWhen == 1 && (d->options & DC_PRINT))) && + labelScale >= d->scale && + (GetTrkBits(trk) & TB_HIDEDESC) == 0) { + DrawCompoundDescription(trk, d, color); + if (!xx->handlaid) { + LabelLengths(d, trk, color); + } + } + if (roadbedWidth > GetTrkGauge(trk) && + DrawTwoRails( d, 1 ) && + ( (d->options & DC_PRINT) || roadbedOnScreen ) ) { + DrawTurnoutRoadbed(d, color, xx->orig, xx->angle, xx->segs, xx->segCnt); + } + + // Restore these settings + if (noTies == 0) { ClrTrkBits(trk, TB_NOTIES); } + if (bridge) { SetTrkBits(trk, TB_BRIDGE); } + if (roadbed) { SetTrkBits(trk, TB_ROADBED); } +} diff --git a/app/bin/unittest/CMakeLists.txt b/app/bin/unittest/CMakeLists.txt index d4e237f..ce5f2f4 100644 --- a/app/bin/unittest/CMakeLists.txt +++ b/app/bin/unittest/CMakeLists.txt @@ -1,4 +1,7 @@ # build unit tests for the xtrkcad library +# + +# dxf formatting add_executable(dxfformattest dxfformattest.c @@ -11,25 +14,33 @@ target_link_libraries(dxfformattest add_test(DXFOutputTest dxfformattest) +# path manipulation + add_executable( pathstest pathstest.c ) target_link_libraries(pathstest dynstring - ${LIBS}) + xtrkcad-wlib + ${LIBS}) add_test(PathsTest pathstest) +# handling of default settings + add_executable( defaultstest defaultstest.c ) target_link_libraries(defaultstest - ${LIBS}) + xtrkcad-wlib + ${LIBS}) add_test(DefaultsTest defaultstest) +# + add_executable(shortentest shortentest.c ../shortentext.c @@ -40,25 +51,44 @@ target_link_libraries(shortentest add_test(ShortenTest shortentest) -add_test(CatalogTest catalogtest) - -set (TESTXTP - "atl83ho.xtp" "atlasn.xtp" "HO-Peco-Code83.xtp" - ) - -foreach(testfile IN LISTS TESTXTP ) - configure_file ( ${CMAKE_CURRENT_SOURCE_DIR}/testfiles/${testfile} - ${CMAKE_CURRENT_BINARY_DIR} - COPYONLY ) -endforeach() - -add_executable(catalogtest - catalogtest.c - ../partcatalog.c - ../paths.c - ../stringxtc.c - ) - -target_link_libraries(catalogtest - dynstring - ${LIBS})
\ No newline at end of file +# parts catalog +# disabled because it pulls in too many dependencies + +# add_test(CatalogTest catalogtest) + +# # parameter files for test cases: +# # - two manufacturers +# # - two scales from same manufacturer + +# set (TESTXTP +# "atl83ho.xtp" "atlasn.xtp" "HO-Peco-Code83.xtp" +# ) + +# foreach(testfile IN LISTS TESTXTP ) +# configure_file ( ${CMAKE_CURRENT_SOURCE_DIR}/testfiles/${testfile} +# ${CMAKE_CURRENT_BINARY_DIR} +# COPYONLY ) +# endforeach() + +# add_executable(catalogtest +# catalogtest.c +# ../partcatalog.c +# ../paths.c +# ../stringxtc.c +# ../levenshtein.c +# ) + +# target_link_libraries(catalogtest +# dynstring +# ${CMOCKA_LIBRARIES} +# ) + + +set_target_properties( + dxfformattest +# catalogtest + shortentest + defaultstest + pathstest + PROPERTIES FOLDER UnitTests + )
\ No newline at end of file diff --git a/app/bin/unittest/catalogtest.c b/app/bin/unittest/catalogtest.c index 6025990..70eeb22 100644 --- a/app/bin/unittest/catalogtest.c +++ b/app/bin/unittest/catalogtest.c @@ -10,31 +10,58 @@ #include <setjmp.h> #include <cmocka.h> +//#include "../common.h" #include "../include/partcatalog.h" -TrackLibrary *trackLib; -CatalogEntry *catalog; +ParameterLib *trackLib; +Catalog *catalog; +SearchResult* result; // some dummy functions to suppress linking problems +const char * wGetUserHomeDir() { + return(""); +} + +void wPrefSetString(const char* a, const char* b, const char* c) +{ + +} +char* wPrefGetString(const char* section, const char* name) +{ + return(""); } -wPrefSetString() +void AbortProg(const char* a, const char* b, int c, const char*d) { } -wPrefGetString() +void * +MyMalloc(size_t size) { + return(malloc(size)); +} +void +MyFree(void* memory) +{ + free(memory); } -AbortProg() +char * +MyStrdup(const char* string) { + return(strdup(string)); +} +void * +MyRealloc(void *memory, size_t size) +{ + return(realloc(memory, size)); } static void @@ -49,8 +76,8 @@ static void ScanEmptyDir(void **state) { (void)state; bool success; - EmptyCatalog(trackLib->catalog); - success = GetTrackFiles(trackLib, "//"); + DestroyCatalog(trackLib->catalog); + success = CreateCatalogFromDir(trackLib, "//"); assert_false(success); } @@ -58,8 +85,8 @@ static void ScanTestFiles(void **state) { (void)state; bool success; - EmptyCatalog(trackLib->catalog); - success = GetTrackFiles(trackLib, "."); + DestroyCatalog(trackLib->catalog); + success = CreateCatalogFromDir(trackLib, "."); assert_true(success); } @@ -73,25 +100,25 @@ static void CreateIndex(void **state) static void SearchNothing(void **state) { (void)state; - unsigned int files = SearchLibrary(trackLib, "djfhdkljhf", catalog); + unsigned int files = SearchLibrary(trackLib, "djfhdkljhf", result); assert_true(files == 0); - EmptyCatalog(catalog); + SearchDiscardResult(result); } static void SearchSingle(void **state) { (void)state; - int files = SearchLibrary(trackLib, "peco", catalog ); + int files = SearchLibrary(trackLib, "peco", result ); assert_true(files==1); - EmptyCatalog(catalog); + SearchDiscardResult(result); } static void SearchMultiple(void **state) { (void)state; - int files = SearchLibrary(trackLib, "atlas", catalog); + int files = SearchLibrary(trackLib, "atlas", result); assert_true(files == 2); - EmptyCatalog(catalog); + SearchDiscardResult(result); } static void FilterTest(void **state) @@ -107,7 +134,7 @@ static void FilterTest(void **state) int main(void) { - const struct CMUnitTest tests[] = { + const struct CMUnitTest tests[] = { cmocka_unit_test(CreateLib), cmocka_unit_test(ScanEmptyDir), cmocka_unit_test(ScanTestFiles), @@ -116,9 +143,9 @@ int main(void) cmocka_unit_test(SearchSingle), cmocka_unit_test(SearchMultiple), cmocka_unit_test(FilterTest), - }; + }; catalog = InitCatalog(); - return cmocka_run_group_tests(tests, NULL, NULL); + return cmocka_run_group_tests(tests, NULL, NULL); }
\ No newline at end of file diff --git a/app/bin/unittest/defaultstest.c b/app/bin/unittest/defaultstest.c index e930468..06ae304 100644 --- a/app/bin/unittest/defaultstest.c +++ b/app/bin/unittest/defaultstest.c @@ -24,13 +24,13 @@ struct appDefault tests[] = { const char *libDir ="Parameter/directory/"; /** - * A dummy for the real MakePath function + * A dummy for the real MakePath function */ void MakeFullpath( char **result, ...) { - *result = libDir; + *result = libDir; } #define TESTARRAYSIZE (sizeof(tests) / sizeof(tests[0]) ) @@ -43,14 +43,16 @@ struct appDefault test1[] = { int -wPrefGetIntegerBasic(const char *section, const char *name, long *result, long defaultValue) +wPrefGetIntegerBasic(const char *section, const char *name, long *result, + long defaultValue) { *result = defaultValue; return(TRUE); } int -wPrefGetFloatBasic(const char *section, const char *name, double *result, double defaultValue) +wPrefGetFloatBasic(const char *section, const char *name, double *result, + double defaultValue) { *result = defaultValue; return(TRUE); @@ -62,7 +64,7 @@ char * wPrefGetStringBasic(const char *section, const char *name) } /* dummy to make the linker happy */ -void +void wPrefSetInteger(const char *section, const char *name, long value) { return; @@ -108,9 +110,9 @@ static void GetDefaults(void **state) int main(void) { - const struct CMUnitTest tests[] = { + const struct CMUnitTest tests[] = { cmocka_unit_test(BinarySearch), cmocka_unit_test(GetDefaults) - }; - return cmocka_run_group_tests(tests, NULL, NULL); + }; + return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/app/bin/unittest/dxfformattest.c b/app/bin/unittest/dxfformattest.c index b797ad9..3c5474a 100644 --- a/app/bin/unittest/dxfformattest.c +++ b/app/bin/unittest/dxfformattest.c @@ -45,9 +45,10 @@ static void LineCommand(void **state) DynStringMalloc(&string, 0); - DxfLineCommand( &string, 0, 1.0, 2.0, 1.1, 2.2, 1); + DxfLineCommand( &string, 0, 1.0, 2.0, 1.1, 2.2, 1, 1); assert_string_equal(DynStringToCStr(&string), - DXF_INDENT "0\nLINE\n 8\nXTRKCAD0\n 10\n1.000000\n 20\n2.000000\n 11\n1.100000\n 21\n2.200000\n 6\nDASHED\n"); + DXF_INDENT "0\nLINE\n 8\nXTRKCAD0\n 10\n1.000000\n 20\n2.000000" + "\n 11\n1.100000\n 21\n2.200000\n 6\nDASHEDTINY\n 420\n1\n"); DynStringFree(&string); } @@ -60,9 +61,10 @@ static void CircleCommand(void **state) DynStringMalloc(&string, 0); - DxfCircleCommand(&string, 0, 1.0, 2.0, 1.1, 1); + DxfCircleCommand(&string, 0, 1.0, 2.0, 1.1, 1, 1); assert_string_equal(DynStringToCStr(&string), - DXF_INDENT "0\nCIRCLE\n 10\n1.000000\n 20\n2.000000\n 40\n1.100000\n 8\nXTRKCAD0\n 6\nDASHED\n"); + DXF_INDENT "0\nCIRCLE\n 10\n1.000000\n 20\n2.000000\n" + " 40\n1.100000\n 8\nXTRKCAD0\n 6\nDASHEDTINY\n 420\n1\n"); DynStringFree(&string); } @@ -75,9 +77,10 @@ static void ArcCommand(void **state) DynStringMalloc(&string, 0); - DxfArcCommand(&string, 0, 1.0, 2.0, 1.1, 10.0, 180.0, 1); + DxfArcCommand(&string, 0, 1.0, 2.0, 1.1, 10.0, 180.0, 1, 1); assert_string_equal(DynStringToCStr(&string), - DXF_INDENT "0\nARC\n 10\n1.000000\n 20\n2.000000\n 40\n1.100000\n 50\n10.000000\n 51\n190.000000\n 8\nXTRKCAD0\n 6\nDASHED\n"); + DXF_INDENT "0\nARC\n 10\n1.000000\n 20\n2.000000\n 40\n1.100000\n" + " 50\n10.000000\n 51\n190.000000\n 8\nXTRKCAD0\n 6\nDASHEDTINY\n 420\n1\n"); DynStringFree(&string); } @@ -91,10 +94,11 @@ static void TextCommand(void **state) DynStringMalloc(&string, 0); - DxfTextCommand(&string, 0, 10.0, 12.0, 144.0, TESTSTRING); + DxfTextCommand(&string, 0, 10.0, 12.0, 144.0, TESTSTRING, 1); assert_string_equal(DynStringToCStr(&string), - DXF_INDENT "0\nTEXT\n 1\n" TESTSTRING "\n 10\n10.000000\n 20\n12.000000\n 40\n2.000000\n 8\nXTRKCAD0\n"); + DXF_INDENT "0\nTEXT\n 1\n" TESTSTRING "\n 10\n10.000000\n 20\n12.000000\n" + " 40\n2.000000\n 8\nXTRKCAD0\n 420\n1\n"); DynStringFree(&string); } @@ -109,36 +113,40 @@ static void Units(void **state) /* test English units */ units = 0; DxfUnits(&string); - assert_string_equal(DynStringToCStr(&string), DXF_INDENT "9\n$MEASUREMENT\n 70\n0\n" DXF_INDENT "9\n$INSUNITS\n 70\n1\n"); + assert_string_equal(DynStringToCStr(&string), + DXF_INDENT "9\n$MEASUREMENT\n 70\n0\n" DXF_INDENT "9\n$INSUNITS\n 70\n1\n"); DxfFormatPosition(&string, 20, 1.23456789); assert_string_equal(DynStringToCStr(&string), DXF_INDENT "20\n1.234568\n"); - + DynStringClear(&string); DxfDimensionSize(&string, DXF_DIMTEXTSIZE); - assert_string_equal(DynStringToCStr(&string), DXF_INDENT "9\n$DIMTXT\n 40\n1.0\n"); + assert_string_equal(DynStringToCStr(&string), + DXF_INDENT "9\n$DIMTXT\n 40\n1.0\n"); /* test metric units */ units = 1; DynStringClear(&string); DxfUnits(&string); - assert_string_equal(DynStringToCStr(&string), DXF_INDENT "9\n$MEASUREMENT\n 70\n1\n" DXF_INDENT "9\n$INSUNITS\n 70\n4\n"); + assert_string_equal(DynStringToCStr(&string), + DXF_INDENT "9\n$MEASUREMENT\n 70\n1\n" DXF_INDENT "9\n$INSUNITS\n 70\n4\n"); DxfFormatPosition(&string, 20, 1.23456789); assert_string_equal(DynStringToCStr(&string), DXF_INDENT "20\n31.358024\n"); DynStringClear(&string); DxfDimensionSize(&string, DXF_DIMTEXTSIZE); - assert_string_equal(DynStringToCStr(&string), DXF_INDENT "9\n$DIMTXT\n 40\n25.0\n"); + assert_string_equal(DynStringToCStr(&string), + DXF_INDENT "9\n$DIMTXT\n 40\n25.0\n"); } int main(void) { - const struct CMUnitTest tests[] = { + const struct CMUnitTest tests[] = { cmocka_unit_test(BasicFormatting), cmocka_unit_test(LineCommand), cmocka_unit_test(CircleCommand), cmocka_unit_test(ArcCommand), cmocka_unit_test(TextCommand), cmocka_unit_test(Units) - }; - return cmocka_run_group_tests(tests, NULL, NULL); + }; + return cmocka_run_group_tests(tests, NULL, NULL); }
\ No newline at end of file diff --git a/app/bin/unittest/pathstest.c b/app/bin/unittest/pathstest.c index 3ee830e..eccba24 100644 --- a/app/bin/unittest/pathstest.c +++ b/app/bin/unittest/pathstest.c @@ -32,6 +32,9 @@ #define DEFAULTPATH "/Default/Path" #endif //WINDOWS + +// Dummy functions to satisfy the linker + void wPrefSetString(const char *section, const char *key, const char *value) {} @@ -51,6 +54,11 @@ const char *wGetUserHomeDir(void) return(DEFAULTPATH); } +void AbortProg(const char *a, const char *b, int d, const char *c) +{ + return; +} + #include "../paths.c" static void SetGetPath(void **state) @@ -67,7 +75,7 @@ static void SetGetPath(void **state) SetCurrentPath("Test", TESTFILE2); string = GetCurrentPath("Test"); - assert_string_equal(string, TESTPATH2); + assert_string_equal(string, TESTPATH2); } static void Makepath(void **state) @@ -76,38 +84,38 @@ static void Makepath(void **state) char *path; #ifdef WINDOWS - MakeFullpath(&path, - "C:", - TESTRELATIVEPATH, - TESTFILENAME, - NULL); + MakeFullpath(&path, + "C:", + TESTRELATIVEPATH, + TESTFILENAME, + NULL); - assert_string_equal(path, "C:" TESTRELATIVEPATH "\\" TESTFILENAME); + assert_string_equal(path, "C:" TESTRELATIVEPATH "\\" TESTFILENAME); #else - MakeFullpath(&path, - TESTRELATIVEPATH, - TESTFILENAME, - NULL); + MakeFullpath(&path, + TESTRELATIVEPATH, + TESTFILENAME, + NULL); - assert_string_equal(path, TESTRELATIVEPATH "/" TESTFILENAME); + assert_string_equal(path, TESTRELATIVEPATH "/" TESTFILENAME); #endif // WINDOWS free(path); #ifdef WINDOWS MakeFullpath(&path, - "C:", - "test", - "\\subdir", - TESTFILENAME, - NULL); + "C:", + "test", + "\\subdir", + TESTFILENAME, + NULL); assert_string_equal(path, "C:test\\subdir\\" TESTFILENAME); #else MakeFullpath(&path, - "test", - "/subdir", - TESTFILENAME, - NULL); + "test", + "/subdir", + TESTFILENAME, + NULL); assert_string_equal(path, "test/subdir/" TESTFILENAME); #endif // WINDOWS @@ -118,9 +126,9 @@ static void Makepath(void **state) int main(void) { - const struct CMUnitTest tests[] = { + const struct CMUnitTest tests[] = { cmocka_unit_test(SetGetPath), cmocka_unit_test(Makepath), - }; - return cmocka_run_group_tests(tests, NULL, NULL); + }; + return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/app/bin/unittest/shortentest.c b/app/bin/unittest/shortentest.c index 4d24b84..9288017 100644 --- a/app/bin/unittest/shortentest.c +++ b/app/bin/unittest/shortentest.c @@ -111,7 +111,7 @@ static void EllipsizeText(void **state) EllipsizeString(LONGSTRING, result, strlen(LONGSTRING)); assert_string_equal(result, LONGSTRING); - EllipsizeString(LONGSTRING, result, 40); + EllipsizeString(LONGSTRING, result, 40); assert_string_equal(result, "The strrchr() function in C/C++..."); EllipsizeString(LONGSTRING, result, 23); @@ -138,7 +138,7 @@ static void LongText(void **state) int main(void) { - const struct CMUnitTest tests[] = { + const struct CMUnitTest tests[] = { cmocka_unit_test(NoRemoveBlanks), cmocka_unit_test(RemoveMultipleBlanks), cmocka_unit_test(RemoveTabs), @@ -147,6 +147,6 @@ int main(void) cmocka_unit_test(NoEllipsizeText), cmocka_unit_test(EllipsizeText), cmocka_unit_test(LongText), - }; - return cmocka_run_group_tests(tests, NULL, NULL); + }; + return cmocka_run_group_tests(tests, NULL, NULL); }
\ No newline at end of file diff --git a/app/bin/utf8convert.c b/app/bin/utf8convert.c index 977a62c..666ac80 100644 --- a/app/bin/utf8convert.c +++ b/app/bin/utf8convert.c @@ -3,30 +3,30 @@ * * UTF8 conversion functions */ - - /* XTrackCad - Model Railroad CAD - * Copyright (C) 2020 Martin Fischer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "misc.h" +/* XTrackCad - Model Railroad CAD + * Copyright (C) 2020 Martin Fischer + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "common.h" #include "include/utf8convert.h" /** - * Convert to UTF-8. The string must by a dynamically allocated storage block + * Convert to UTF-8. The string must by a dynamically allocated storage block * allocated with MyMalloc(). The functions returns a pointer to the converted * string. If no conversion was necessary the returned string is identical to * the parameter. Otherwise a new buffer is allocated and returned. diff --git a/app/bin/uthash.h b/app/bin/uthash.h index 39fd891..bf74f7b 100644 --- a/app/bin/uthash.h +++ b/app/bin/uthash.h @@ -890,22 +890,22 @@ for((el)=(head),(tmp)=DECLTYPE(el)((head)?(head)->hh.next:NULL); #define HASH_CNT(hh,head) ((head)?((head)->hh.tbl->num_items):0) typedef struct UT_hash_bucket { - struct UT_hash_handle *hh_head; - unsigned count; - - /* expand_mult is normally set to 0. In this situation, the max chain length - * threshold is enforced at its default value, HASH_BKT_CAPACITY_THRESH. (If - * the bucket's chain exceeds this length, bucket expansion is triggered). - * However, setting expand_mult to a non-zero value delays bucket expansion - * (that would be triggered by additions to this particular bucket) - * until its chain length reaches a *multiple* of HASH_BKT_CAPACITY_THRESH. - * (The multiplier is simply expand_mult+1). The whole idea of this - * multiplier is to reduce bucket expansions, since they are expensive, in - * situations where we know that a particular bucket tends to be overused. - * It is better to let its chain length grow to a longer yet-still-bounded - * value, than to do an O(n) bucket expansion too often. - */ - unsigned expand_mult; + struct UT_hash_handle *hh_head; + unsigned count; + + /* expand_mult is normally set to 0. In this situation, the max chain length + * threshold is enforced at its default value, HASH_BKT_CAPACITY_THRESH. (If + * the bucket's chain exceeds this length, bucket expansion is triggered). + * However, setting expand_mult to a non-zero value delays bucket expansion + * (that would be triggered by additions to this particular bucket) + * until its chain length reaches a *multiple* of HASH_BKT_CAPACITY_THRESH. + * (The multiplier is simply expand_mult+1). The whole idea of this + * multiplier is to reduce bucket expansions, since they are expensive, in + * situations where we know that a particular bucket tends to be overused. + * It is better to let its chain length grow to a longer yet-still-bounded + * value, than to do an O(n) bucket expansion too often. + */ + unsigned expand_mult; } UT_hash_bucket; @@ -914,47 +914,47 @@ typedef struct UT_hash_bucket { #define HASH_BLOOM_SIGNATURE 0xb12220f2 typedef struct UT_hash_table { - UT_hash_bucket *buckets; - unsigned num_buckets, log2_num_buckets; - unsigned num_items; - struct UT_hash_handle *tail; /* tail hh in app order, for fast append */ - ptrdiff_t hho; /* hash handle offset (byte pos of hash handle in element */ - - /* in an ideal situation (all buckets used equally), no bucket would have - * more than ceil(#items/#buckets) items. that's the ideal chain length. */ - unsigned ideal_chain_maxlen; - - /* nonideal_items is the number of items in the hash whose chain position - * exceeds the ideal chain maxlen. these items pay the penalty for an uneven - * hash distribution; reaching them in a chain traversal takes >ideal steps */ - unsigned nonideal_items; - - /* ineffective expands occur when a bucket doubling was performed, but - * afterward, more than half the items in the hash had nonideal chain - * positions. If this happens on two consecutive expansions we inhibit any - * further expansion, as it's not helping; this happens when the hash - * function isn't a good fit for the key domain. When expansion is inhibited - * the hash will still work, albeit no longer in constant time. */ - unsigned ineff_expands, noexpand; - - uint32_t signature; /* used only to find hash tables in external analysis */ + UT_hash_bucket *buckets; + unsigned num_buckets, log2_num_buckets; + unsigned num_items; + struct UT_hash_handle *tail; /* tail hh in app order, for fast append */ + ptrdiff_t hho; /* hash handle offset (byte pos of hash handle in element */ + + /* in an ideal situation (all buckets used equally), no bucket would have + * more than ceil(#items/#buckets) items. that's the ideal chain length. */ + unsigned ideal_chain_maxlen; + + /* nonideal_items is the number of items in the hash whose chain position + * exceeds the ideal chain maxlen. these items pay the penalty for an uneven + * hash distribution; reaching them in a chain traversal takes >ideal steps */ + unsigned nonideal_items; + + /* ineffective expands occur when a bucket doubling was performed, but + * afterward, more than half the items in the hash had nonideal chain + * positions. If this happens on two consecutive expansions we inhibit any + * further expansion, as it's not helping; this happens when the hash + * function isn't a good fit for the key domain. When expansion is inhibited + * the hash will still work, albeit no longer in constant time. */ + unsigned ineff_expands, noexpand; + + uint32_t signature; /* used only to find hash tables in external analysis */ #ifdef HASH_BLOOM - uint32_t bloom_sig; /* used only to test bloom exists in external analysis */ - uint8_t *bloom_bv; - char bloom_nbits; + uint32_t bloom_sig; /* used only to test bloom exists in external analysis */ + uint8_t *bloom_bv; + char bloom_nbits; #endif } UT_hash_table; typedef struct UT_hash_handle { - struct UT_hash_table *tbl; - void *prev; /* prev element in app order */ - void *next; /* next element in app order */ - struct UT_hash_handle *hh_prev; /* previous hh in bucket order */ - struct UT_hash_handle *hh_next; /* next hh in bucket order */ - void *key; /* ptr to enclosing struct's key */ - unsigned keylen; /* enclosing struct's key len */ - unsigned hashv; /* result of hash-fcn(key) */ + struct UT_hash_table *tbl; + void *prev; /* prev element in app order */ + void *next; /* next element in app order */ + struct UT_hash_handle *hh_prev; /* previous hh in bucket order */ + struct UT_hash_handle *hh_next; /* next hh in bucket order */ + void *key; /* ptr to enclosing struct's key */ + unsigned keylen; /* enclosing struct's key len */ + unsigned hashv; /* result of hash-fcn(key) */ } UT_hash_handle; #endif /* UTHASH_H */ diff --git a/app/bin/utility.c b/app/bin/utility.c index 93e2ff4..ff457d9 100644 --- a/app/bin/utility.c +++ b/app/bin/utility.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "utility.h" @@ -44,7 +44,7 @@ DEBUGF_T debugIntersection = 0; #ifndef min double max( double a, double b ) { - if (a>b) return a; + if (a>b) { return a; } return b; } @@ -52,7 +52,7 @@ double max( double a, double b ) double min( double a, double b ) { - if (a<b) return a; + if (a<b) { return a; } return b; } #endif @@ -77,23 +77,25 @@ double FindDistance( coOrd p0, coOrd p1 ) double NormalizeAngle( double a ) { - while (a<0.0) a += 360.0; - while (a>=360.0) a -= 360.0; + while (a<0.0) { a += 360.0; } + while (a>=360.0) { a -= 360.0; } return a; } -double DifferenceBetweenAngles(double a, double b) { - double difference = b - a; - while (difference < -180) difference += 360; - while (difference > 180) difference -= 360; - return difference; +double DifferenceBetweenAngles(double a, double b) +{ + double difference = b - a; + while (difference < -180) { difference += 360; } + while (difference > 180) { difference -= 360; } + return difference; } -int AngleInRange(double a, double start, double size) { +int AngleInRange(double a, double start, double size) +{ if (DifferenceBetweenAngles(start+size,a)<=0.0) { - if (DifferenceBetweenAngles(start,a)>=0.0) + if (DifferenceBetweenAngles(start,a)>=0.0) { return 0; - else return 1; + } else { return 1; } } return -1; } @@ -110,7 +112,7 @@ int IsAligned( double a1, double a2 ) double D2R( double D ) { D = NormalizeAngle(D); - if (D >= 180.0) D = D - 360.0; + if (D >= 180.0) { D = D - 360.0; } return D * (M_PI*2) / 360.0; } @@ -157,7 +159,9 @@ double FindAngle( coOrd p0, coOrd p1 ) double dx = p1.x-p0.x, dy = p1.y-p0.y; if ( dx == 0.0 && dy == 0.0 ) // Avoid implementation defined behavior + { return 0.0; + } return R2D(atan2( dx,dy )); } @@ -187,7 +191,8 @@ double ConstrainR( double r ) -void FindPos( coOrd * res, double * beyond, coOrd pos, coOrd orig, double angle, double length ) +void FindPos( coOrd * res, double * beyond, coOrd pos, coOrd orig, double angle, + double length ) { double a0, a1; double d; @@ -207,7 +212,7 @@ void FindPos( coOrd * res, double * beyond, coOrd pos, coOrd orig, double angle, } else { res->x = (POS_T)x; } - if (beyond) *beyond = x - res->x; + if (beyond) { *beyond = x - res->x; } res->y = (POS_T)(d * sin( D2R( a1 )) ); } @@ -216,15 +221,18 @@ void FindPos( coOrd * res, double * beyond, coOrd pos, coOrd orig, double angle, * Given two circles described by centers and radius (C1, R1) (C2, R2) Find the zero, one or two intersection points * */ -BOOL_T FindArcIntersections ( coOrd *Pc, coOrd *Pc2, coOrd center1, DIST_T radius1, coOrd center2, DIST_T radius2) { +BOOL_T FindArcIntersections ( coOrd *Pc, coOrd *Pc2, coOrd center1, + DIST_T radius1, coOrd center2, DIST_T radius2) +{ double d,a,h; - d = sqrt((center2.x-center1.x)*(center2.x-center1.x)+(center2.y-center1.y)*(center2.y-center1.y)); - if (d >(radius1+radius2)) return FALSE; //Too far apart - if (d<fabs(radius1-radius2)) return FALSE; //Inside each other - if ((d == 0) && (radius1 == radius2)) return FALSE; // Coincident and the same + d = sqrt((center2.x-center1.x)*(center2.x-center1.x)+(center2.y-center1.y)* + (center2.y-center1.y)); + if (d >(radius1+radius2)) { return FALSE; } //Too far apart + if (d<fabs(radius1-radius2)) { return FALSE; } //Inside each other + if ((d == 0) && (radius1 == radius2)) { return FALSE; } // Coincident and the same a=((radius1*radius1)-(radius2*radius2)+(d*d))/(2*d); - if ((radius1*radius1)<(a*a)) return FALSE; + if ((radius1*radius1)<(a*a)) { return FALSE; } h = sqrt((radius1*radius1)-(a*a)); coOrd center_c; @@ -249,36 +257,38 @@ BOOL_T FindArcIntersections ( coOrd *Pc, coOrd *Pc2, coOrd center1, DIST_T radiu * Find two intersect points on secant by triangle formed between middle, center and arc point * */ -BOOL_T FindArcAndLineIntersections(coOrd *intersection1, coOrd *intersection2, coOrd c, DIST_T radius, - coOrd point1, coOrd point2 ) +BOOL_T FindArcAndLineIntersections(coOrd *intersection1, coOrd *intersection2, + coOrd c, DIST_T radius, + coOrd point1, coOrd point2 ) { double la, lb, lc; //Line equation - la = point1.y - point2.y; - lb = point2.x - point1.x; - lc = (point1.x-c.x)*(point2.y-c.y) - (point2.x-c.x)*(point1.y-c.y); //Move by c(x,y) + la = point1.y - point2.y; + lb = point2.x - point1.x; + lc = (point1.x-c.x)*(point2.y-c.y) - (point2.x-c.x)*(point1.y + -c.y); //Move by c(x,y) - double x0 = -la*lc/(la*la+lb*lb), y0 = -lb*lc/(la*la+lb*lb); + double x0 = -la*lc/(la*la+lb*lb), y0 = -lb*lc/(la*la+lb*lb); - double dis = radius*radius*(la*la+lb*lb); + double dis = radius*radius*(la*la+lb*lb); - if (lc*lc > dis) { - return FALSE; - } else if (fabs(lc*lc - dis) < EPSILON) { - (*intersection1).x = x0+c.x; - (*intersection1).y = y0+c.y; - *intersection2 = *intersection1; - return TRUE; - } else { - double d = radius*radius - lc*lc/(la*la+lb*lb); - double mult = sqrt(d/(la*la+lb*lb)); - (*intersection1).x = x0+lb*mult+c.x; - (*intersection2).x = x0-lb*mult+c.x; - (*intersection1).y = y0-la*mult+c.y; - (*intersection2).y = y0+la*mult+c.y; - return TRUE; - } + if (lc*lc > dis) { + return FALSE; + } else if (fabs(lc*lc - dis) < EPSILON) { + (*intersection1).x = x0+c.x; + (*intersection1).y = y0+c.y; + *intersection2 = *intersection1; + return TRUE; + } else { + double d = radius*radius - lc*lc/(la*la+lb*lb); + double mult = sqrt(d/(la*la+lb*lb)); + (*intersection1).x = x0+lb*mult+c.x; + (*intersection2).x = x0-lb*mult+c.x; + (*intersection1).y = y0-la*mult+c.y; + (*intersection2).y = y0+la*mult+c.y; + return TRUE; + } } /* Find intersection: @@ -368,7 +378,7 @@ BOOL_T FindArcAndLineIntersections(coOrd *intersection1, coOrd *intersection2, c d1x*d0y - d1y*d0x if (d1x*d0y - d1y*d0x) = 0 then lines are parallel -*/ +*/ BOOL_T FindIntersection( coOrd *Pc, coOrd P0, double A0, coOrd P1, double A1 ) { @@ -378,7 +388,7 @@ BOOL_T FindIntersection( coOrd *Pc, coOrd P0, double A0, coOrd P1, double A1 ) #ifndef WINDOWS if (debugIntersection >= 3) printf("FindIntersection( [%0.3f %0.3f] A%0.3f [%0.3f %0.3f] A%0.3f\n", - P0.x, P0.y, A0, P1.x, P1.y, A1 ); + P0.x, P0.y, A0, P1.x, P1.y, A1 ); #endif dx0 = sin( D2R( A0 ) ); @@ -388,21 +398,21 @@ BOOL_T FindIntersection( coOrd *Pc, coOrd P0, double A0, coOrd P1, double A1 ) d = dx1 * dy0 - dx0 * dy1; if (d < EPSILON && d > -EPSILON) { #ifndef WINDOWS - if (debugIntersection >=3 ) printf("dx1 * dy0 - dx0 * dy1 = %0.3f\n", d ); + if (debugIntersection >=3 ) { printf("dx1 * dy0 - dx0 * dy1 = %0.3f\n", d ); } #endif return FALSE; } -/* - * (P0.x - P1.x) * d0y + (P1.y - P0.y) * d0x - * N1 = ============================================= - * d1x*d0y - d1y*d0x - */ + /* + * (P0.x - P1.x) * d0y + (P1.y - P0.y) * d0x + * N1 = ============================================= + * d1x*d0y - d1y*d0x + */ N1 = dy0 * (P0.x - P1.x) + dx0 * (P1.y - P0.y ); N1 = N1 / d; Pc->x = P1.x + (POS_T)(N1*dx1); Pc->y = P1.y + (POS_T)(N1*dy1); #ifndef WINDOWS - if (debugIntersection >=3 ) printf( " [%0.3f,%0.3f]\n", Pc->x, Pc->y ); + if (debugIntersection >=3 ) { printf( " [%0.3f,%0.3f]\n", Pc->x, Pc->y ); } #endif return TRUE; } @@ -412,20 +422,22 @@ EPINX_T PickArcEndPt( coOrd pc, coOrd p0, coOrd p1 ) { double a; a = NormalizeAngle( FindAngle( pc, p1 ) - FindAngle( pc, p0 ) ); - if (a > 180.0) + if (a > 180.0) { return 0; - else + } else { return 1; + } } EPINX_T PickLineEndPt( coOrd p0, double a0, coOrd p1 ) { double a; a = NormalizeAngle( FindAngle( p0, p1 ) - a0 ); - if (a < 90.0 || a > 270 ) + if (a < 90.0 || a > 270 ) { return 0; - else + } else { return 1; + } } double LineDistance( coOrd *p, coOrd p0, coOrd p1 ) @@ -500,31 +512,34 @@ coOrd AddCoOrd( coOrd p0, coOrd p1, double a ) BOOL_T InRect( coOrd pos, coOrd rect ) { - if (pos.x >= 0.0 && pos.x <= rect.x && pos.y >= 0.0 && pos.y <= rect.y) + if (pos.x >= 0.0 && pos.x <= rect.x && pos.y >= 0.0 && pos.y <= rect.y) { return 1; - else + } else { return 0; + } } -static BOOL_T IntersectLine( POS_T *fx0, POS_T *fy0, POS_T x1, POS_T y1, POS_T x, POS_T y ) +static BOOL_T IntersectLine( POS_T *fx0, POS_T *fy0, POS_T x1, POS_T y1, + POS_T x, POS_T y ) { POS_T x0=*fx0, y0=*fy0, dx, dy; BOOL_T rc; #ifdef TEST printf(" IntersectLine( P0=[%0.2f %0.2f] P1=[%0.2f %0.2f] X=%0.2f Y=%0.2f\n", - x0, y0, x1, y1, x, y ); + x0, y0, x1, y1, x, y ); #endif dx = x1-x0; dy = y1-y0; if (dy==0.0) { - if (y0 == y) + if (y0 == y) { rc = TRUE; - else + } else { rc = FALSE; + } } else { x0 += (y-y0) * dx/dy; - if (x0 < -EPSILON || x0 > x) { + if (x0 < -EPSILON || x0 > (x+EPSILON)) { rc = FALSE; } else { *fx0 = x0; @@ -533,10 +548,11 @@ static BOOL_T IntersectLine( POS_T *fx0, POS_T *fy0, POS_T x1, POS_T y1, POS_T x } } #ifdef TEST - if (rc) + if (rc) { printf(" = TRUE [%0.2f %0.2f]\n", *fx0, *fy0 ); - else + } else { printf(" = FALSE\n"); + } #endif return rc; } @@ -549,19 +565,18 @@ static void IntersectBox( coOrd *p1, coOrd p0, coOrd size, int x1, int y1 ) { #ifdef TEST printf(" IntersectBox( P1=[%0.2f %0.2f] P0=[%0.2f %0.2f] S=[%0.2f %0.2f] X1=%d Y1=%d\n", - p1->x, p1->y, p0.x, p0.y, size.x, size.y, x1, y1 ); + p1->x, p1->y, p0.x, p0.y, size.x, size.y, x1, y1 ); #endif if ( y1!=0 && - IntersectLine( &p1->x, &p1->y, p0.x, p0.y, size.x, (y1==-1?(POS_T)0.0:size.y) )) + IntersectLine( &p1->x, &p1->y, p0.x, p0.y, size.x, + (y1==-1?(POS_T)0.0:size.y) )) { return; - else if ( x1!=0 && - IntersectLine( &p1->y, &p1->x, p0.y, p0.x, size.y, (x1==-1?(POS_T)0.0:size.x) )) + } else if ( x1!=0 && + IntersectLine( &p1->y, &p1->x, p0.y, p0.x, size.y, + (x1==-1?(POS_T)0.0:size.x) )) { return; -#ifndef WINDOWS - else - fprintf(stderr, "intersectBox bogus\n" ); - getchar(); -#endif + } + printf(" intersectBox bogus\n" ); } BOOL_T ClipLine( coOrd *fp0, coOrd *fp1, coOrd orig, double angle, coOrd size ) @@ -571,7 +586,7 @@ BOOL_T ClipLine( coOrd *fp0, coOrd *fp1, coOrd orig, double angle, coOrd size ) #ifdef TEST printf("ClipLine( P0=[%0.2f %0.2f] P1=[%0.2f %0.2f] O=[%0.2f %0.2f] A=%0.2f S=[%0.2f %0.2f]\n", - p0.x, p0.y, p1.x, p1.y, orig.x, orig.y, angle, size.x, size.y ); + p0.x, p0.y, p1.x, p1.y, orig.x, orig.y, angle, size.x, size.y ); #endif Rotate( &p0, orig, -angle ); @@ -586,18 +601,18 @@ BOOL_T ClipLine( coOrd *fp0, coOrd *fp1, coOrd orig, double angle, coOrd size ) ------------O-------------+---------- -1,-1 | 0,-1 + 1,-1 */ - if ( p0.x < 0.0-EPSILON ) x0 = -1; - else if ( p0.x > size.x+EPSILON ) x0 = 1; - else x0 = 0; - if ( p0.y < 0.0-EPSILON ) y0 = -1; - else if ( p0.y > size.y+EPSILON ) y0 = 1; - else y0 = 0; - if ( p1.x < 0.0-EPSILON ) x1 = -1; - else if ( p1.x > size.x+EPSILON ) x1 = 1; - else x1 = 0; - if ( p1.y < 0.0-EPSILON ) y1 = -1; - else if ( p1.y > size.y+EPSILON ) y1 = 1; - else y1 = 0; + if ( p0.x < 0.0-EPSILON ) { x0 = -1; } + else if ( p0.x > size.x+EPSILON ) { x0 = 1; } + else { x0 = 0; } + if ( p0.y < 0.0-EPSILON ) { y0 = -1; } + else if ( p0.y > size.y+EPSILON ) { y0 = 1; } + else { y0 = 0; } + if ( p1.x < 0.0-EPSILON ) { x1 = -1; } + else if ( p1.x > size.x+EPSILON ) { x1 = 1; } + else { x1 = 0; } + if ( p1.y < 0.0-EPSILON ) { y1 = -1; } + else if ( p1.y > size.y+EPSILON ) { y1 = 1; } + else { y1 = 0; } #ifdef TEST printf(" X0=%d Y0=%d X1=%d Y1=%d\n", x0, y0, x1, y1 ); @@ -627,10 +642,12 @@ BOOL_T ClipLine( coOrd *fp0, coOrd *fp1, coOrd orig, double angle, coOrd size ) } /* both points without box and cannot intersect */ - if ( (x0==x1 && y0==y1 && x0!=0 && y0!=0) || /* within same sector (but not the middle one) */ - (x0!=0 && x0==x1) || /* both right or left */ - (y0!=0 && y0==y1) ) /* both above or below */ + if ( (x0==x1 && y0==y1 && x0!=0 && y0!=0) + || /* within same sector (but not the middle one) */ + (x0!=0 && x0==x1) || /* both right or left */ + (y0!=0 && y0==y1) ) { /* both above or below */ return 0; + } #ifdef TEST printf(" complex intersection\n"); @@ -638,18 +655,18 @@ BOOL_T ClipLine( coOrd *fp0, coOrd *fp1, coOrd orig, double angle, coOrd size ) /* possible intersection */ if ( y0!=0 && - IntersectLine( &p0.x, &p0.y, p1.x, p1.y, size.x, (y0==-1?(POS_T)0.0:size.y) )) + IntersectLine( &p0.x, &p0.y, p1.x, p1.y, size.x, (y0==-1?(POS_T)0.0:size.y) )) { IntersectBox( &p1, p0, size, x1, y1 ); - else if ( y1!=0 && - IntersectLine( &p1.x, &p1.y, p0.x, p0.y, size.x, (y1==-1?(POS_T)0.0:size.y) )) + } else if ( y1!=0 && + IntersectLine( &p1.x, &p1.y, p0.x, p0.y, size.x, (y1==-1?(POS_T)0.0:size.y) )) { IntersectBox( &p0, p1, size, x0, y0 ); - else if ( x0!=0 && - IntersectLine( &p0.y, &p0.x, p1.y, p1.x, size.y, (x0==-1?(POS_T)0.0:size.x) )) + } else if ( x0!=0 && + IntersectLine( &p0.y, &p0.x, p1.y, p1.x, size.y, (x0==-1?(POS_T)0.0:size.x) )) { IntersectBox( &p1, p0, size, x1, y1 ); - else if ( x1!=0 && - IntersectLine( &p1.y, &p1.x, p0.y, p0.x, size.y, (x1==-1?(POS_T)0.0:size.x) )) + } else if ( x1!=0 && + IntersectLine( &p1.y, &p1.x, p0.y, p0.x, size.y, (x1==-1?(POS_T)0.0:size.x) )) { IntersectBox( &p0, p1, size, x0, y0 ); - else { + } else { return 0; } p0.x += orig.x; p0.y += orig.y; @@ -663,59 +680,59 @@ BOOL_T ClipLine( coOrd *fp0, coOrd *fp1, coOrd orig, double angle, coOrd size ) coOrd FindCentroid(int vertexCount, pts_t vertices[] ) { - coOrd centroid = {0, 0}; - double signedArea = 0.0; - double x0 = 0.0; // Current vertex X - double y0 = 0.0; // Current vertex Y - double x1 = 0.0; // Next vertex X - double y1 = 0.0; // Next vertex Y - double a = 0.0; // Partial signed area - - // For all vertices except last - int i=0; - for (i=0; i<vertexCount-1; ++i) - { - x0 = vertices[i].pt.x; - y0 = vertices[i].pt.y; - x1 = vertices[i+1].pt.x; - y1 = vertices[i+1].pt.y; - a = x0*y1 - x1*y0; - signedArea += a; - centroid.x += (x0 + x1)*a; - centroid.y += (y0 + y1)*a; - } - - // Do last vertex separately to avoid performing an expensive - // modulus operation in each iteration. - x0 = vertices[i].pt.x; - y0 = vertices[i].pt.y; - x1 = vertices[0].pt.x; - y1 = vertices[0].pt.y; - a = x0*y1 - x1*y0; - signedArea += a; - centroid.x += (x0 + x1)*a; - centroid.y += (y0 + y1)*a; - - signedArea *= 0.5; - centroid.x /= (6.0*signedArea); - centroid.y /= (6.0*signedArea); - - return centroid; + coOrd centroid = {0, 0}; + double signedArea = 0.0; + double x0 = 0.0; // Current vertex X + double y0 = 0.0; // Current vertex Y + double x1 = 0.0; // Next vertex X + double y1 = 0.0; // Next vertex Y + double a = 0.0; // Partial signed area + + // For all vertices except last + int i=0; + for (i=0; i<vertexCount-1; ++i) { + x0 = vertices[i].pt.x; + y0 = vertices[i].pt.y; + x1 = vertices[i+1].pt.x; + y1 = vertices[i+1].pt.y; + a = x0*y1 - x1*y0; + signedArea += a; + centroid.x += (x0 + x1)*a; + centroid.y += (y0 + y1)*a; + } + + // Do last vertex separately to avoid performing an expensive + // modulus operation in each iteration. + x0 = vertices[i].pt.x; + y0 = vertices[i].pt.y; + x1 = vertices[0].pt.x; + y1 = vertices[0].pt.y; + a = x0*y1 - x1*y0; + signedArea += a; + centroid.x += (x0 + x1)*a; + centroid.y += (y0 + y1)*a; + + signedArea *= 0.5; + centroid.x /= (6.0*signedArea); + centroid.y /= (6.0*signedArea); + + return centroid; } double FindArcCenter( - coOrd * pos, - coOrd p0, - coOrd p1, - double radius ) + coOrd * pos, + coOrd p0, + coOrd p1, + double radius ) { double d; double a0, a1; d = FindDistance( p0, p1 )/2.0; a0 = FindAngle( p0, p1 ); a1 = NormalizeAngle(R2D(asin( d/radius ))); - if (a1 > 180) + if (a1 > 180) { a1 -= 360; + } a0 = NormalizeAngle( a0 + (90.0-a1) ); Translate( pos, p0, a0, radius ); return a1*2.0; @@ -723,21 +740,24 @@ double FindArcCenter( #ifdef LATER -BOOL_T ClipArc( double a0, double a1, coOrd pos, double radius, coOrd orig, double angle, double size ) +BOOL_T ClipArc( double a0, double a1, coOrd pos, double radius, coOrd orig, + double angle, double size ) { i = -1; state = unknown; if (pos.y + radius < 0.0 || - pos.y - radius > size.y || - pos.x + radius < 0.0 || - pos.x - radius > size.x ) + pos.y - radius > size.y || + pos.x + radius < 0.0 || + pos.x - radius > size.x ) { return 0; + } if (pos.y + radius <= size.y || - pos.y - radius >= 0.0 || - pos.x + radius <= size.x || - pos.x - radius >= 0.0 ) + pos.y - radius >= 0.0 || + pos.x + radius <= size.x || + pos.x - radius >= 0.0 ) { return 1; + } if (pos.y + radius > size.y) { a = R2D(acos( (size.y-pos.y) / radius ) )); @@ -757,7 +777,8 @@ BOOL_T ClipArc( double a0, double a1, coOrd pos, double radius, coOrd orig, doub #endif #ifdef TEST -void Test( double p0x, double p0y, double p1x, double p1y, double origx, double origy, double angle, double sizex, double sizey ) +void Test( double p0x, double p0y, double p1x, double p1y, double origx, + double origy, double angle, double sizex, double sizey ) { coOrd p0, p1, orig, size, p0a, p1a; @@ -768,7 +789,7 @@ void Test( double p0x, double p0y, double p1x, double p1y, double origx, double p0a = p0; p1a = p1; rc = ClipLine( &p0, &p1, orig, angle, size ); printf("clipLine=%d P0=[%0.3f %0.3f] P1=[%0.3f %0.3f]\n", rc, - p0.x, p0.y, p1.x, p1.y ); + p0.x, p0.y, p1.x, p1.y ); } INT_T Main( INT_T argc, char *argv[] ) @@ -780,8 +801,9 @@ INT_T Main( INT_T argc, char *argv[] ) Exit(1); } argv++; - for (i=0;i<9;i++) + for (i=0; i<9; i++) { a[i] = atof( *argv++ ); + } Test( a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8] ); } diff --git a/app/bin/utility.h b/app/bin/utility.h index 3686ae8..8e8cf17 100644 --- a/app/bin/utility.h +++ b/app/bin/utility.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef UTILITY_H @@ -56,10 +56,13 @@ void Translate( coOrd *res, coOrd orig, double a, double d ); double FindAngle( coOrd p0, coOrd p1 ); int PointOnCircle( coOrd * resP, coOrd center, double radius, double angle ); double ConstrainR( double r ); -void FindPos( coOrd * res, double * beyond, coOrd pos, coOrd orig, double angle, double length ); +void FindPos( coOrd * res, double * beyond, coOrd pos, coOrd orig, double angle, + double length ); int FindIntersection( coOrd *Pc, coOrd P00, double A0, coOrd P10, double A1 ); -BOOL_T FindArcAndLineIntersections (coOrd *Pc1, coOrd *Pc2, coOrd c, DIST_T r, coOrd p0, coOrd p1); -BOOL_T FindArcIntersections ( coOrd *Pc, coOrd *Pc2, coOrd center1, DIST_T radius1, coOrd center2, DIST_T radius2); +BOOL_T FindArcAndLineIntersections (coOrd *Pc1, coOrd *Pc2, coOrd c, DIST_T r, + coOrd p0, coOrd p1); +BOOL_T FindArcIntersections ( coOrd *Pc, coOrd *Pc2, coOrd center1, + DIST_T radius1, coOrd center2, DIST_T radius2); double LineDistance( coOrd *p, coOrd p0, coOrd p1 ); double CircleDistance( coOrd *p, coOrd c, double r, double a0, double a1 ); int PickArcEndPt( coOrd, coOrd, coOrd ); diff --git a/app/bin/validator.c b/app/bin/validator.c index bd481a5..88b41fe 100644 --- a/app/bin/validator.c +++ b/app/bin/validator.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "validator.h" @@ -36,10 +36,10 @@ enum URLSCANSTATE { STATE_SCHEME, STATE_ENDOFSCHEME, STATE_HIER, STATE_PATH, STA #define MINURLLENGTH 5 /* 2 chars domain name, dot, 2 chars TLD */ bool -IsValidURL(char *testString) +IsValidURL(const char *testString) { - char *result = testString; - char *hostname = testString; + const char *result = testString; + const char *hostname = testString; enum URLSCANSTATE state = STATE_SCHEME; if (!*result) { diff --git a/app/bin/validator.h b/app/bin/validator.h index 3706f0f..a49536c 100644 --- a/app/bin/validator.h +++ b/app/bin/validator.h @@ -1,4 +1,4 @@ -/** \file validator.h +/** \file validator.h * Validators for misc textformats */ @@ -17,13 +17,13 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software -*/
-
-#ifndef HAVE_VALIDATOR_H
-#define HAVE_VALIDATOR_H
-
-#include <stdbool.h>
-bool IsValidURL(char *testString);
-
-#endif // !HAVE_VALIDATOR_H
-
+*/ + +#ifndef HAVE_VALIDATOR_H +#define HAVE_VALIDATOR_H + +#include <stdbool.h> +bool IsValidURL(const char *testString); + +#endif // !HAVE_VALIDATOR_H + diff --git a/app/bin/version.h b/app/bin/version.h index 2b2e6ff..b5fda54 100644 --- a/app/bin/version.h +++ b/app/bin/version.h @@ -17,26 +17,26 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef HAVE_VERSION_H #define HAVE_VERSION_H #ifdef XTRKCAD_CMAKE_BUILD - #include "xtrkcad-config.h" +#include "xtrkcad-config.h" - #define VERSION XTRKCAD_VERSION - #define PARAMVERSION XTRKCAD_PARAMVERSION - #define PARAMVERSIONVERSION XTRKCAD_PARAMVERSIONVERSION - #define MINPARAMVERSION XTRKCAD_MINPARAMVERSION +#define VERSION XTRKCAD_VERSION +#define PARAMVERSION XTRKCAD_PARAMVERSION +#define PARAMVERSIONVERSION XTRKCAD_PARAMVERSIONVERSION +#define MINPARAMVERSION XTRKCAD_MINPARAMVERSION #else - #define VERSION "4.1.0b1" - #define PARAMVERSION (10) - #define PARAMVERSIONVERSION "3.0.0" - #define MINPARAMVERSION (1) +#define VERSION "4.1.0b1" +#define PARAMVERSION (10) +#define PARAMVERSIONVERSION "3.0.0" +#define MINPARAMVERSION (1) #endif #endif //HAVE_VERSION_H diff --git a/app/bin/xtrkcad.ico b/app/bin/xtrkcad.ico Binary files differindex da224a4..457422f 100644 --- a/app/bin/xtrkcad.ico +++ b/app/bin/xtrkcad.ico diff --git a/app/bin/xtrkcad.rc b/app/bin/xtrkcad.rc index 3fd5784..010c2f2 100644 --- a/app/bin/xtrkcad.rc +++ b/app/bin/xtrkcad.rc @@ -1,4 +1,10 @@ -#include <windows.h> -#include "mswlib.h" - -0 ICON xtrkcad.ico +/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+101 ICON "xtrkcad.ico"
+
+////////////////////////////////////////////////////////////////////////////
|